@sequenza/workbench 1.0.3 → 1.0.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/dist/sequenza.js CHANGED
@@ -1,32 +1,32 @@
1
- import * as z from "twgl.js";
2
- import { jsx as n, jsxs as p, Fragment as le } from "react/jsx-runtime";
3
- import { forwardRef as Ge, useRef as R, useEffect as D, useState as y, useCallback as W, createContext as We, useMemo as Q, useContext as ie } from "react";
4
- import { Handle as Xe, Position as se, getBezierPath as Ee, BaseEdge as Ye, EdgeLabelRenderer as Ke, ReactFlowProvider as Je, applyNodeChanges as Qe, applyEdgeChanges as Ze, addEdge as _e, useReactFlow as en, ReactFlow as nn, Controls as tn, Panel as fe, getOutgoers as Se, getSimpleBezierPath as on } from "@xyflow/react";
5
- const ye = (e) => {
6
- const o = e.replace("#", "");
1
+ import * as L from "twgl.js";
2
+ import { jsx as t, jsxs as m, Fragment as se } from "react/jsx-runtime";
3
+ import { forwardRef as Qe, useRef as $, useEffect as k, useState as y, useCallback as Y, createContext as Ze, useContext as ue, useMemo as re } from "react";
4
+ import { Handle as en, Position as ne, getBezierPath as ke, BaseEdge as nn, EdgeLabelRenderer as tn, ReactFlowProvider as on, applyNodeChanges as rn, applyEdgeChanges as sn, addEdge as Ne, useReactFlow as an, ReactFlow as ln, Controls as cn, Panel as he, getOutgoers as Ie, getSimpleBezierPath as un } from "@xyflow/react";
5
+ const Ee = (n) => {
6
+ const o = n.replace("#", "");
7
7
  return [
8
8
  parseInt(o.substring(0, 2), 16),
9
9
  parseInt(o.substring(2, 4), 16),
10
10
  parseInt(o.substring(4, 6), 16)
11
11
  ];
12
- }, rn = (e, o, r) => {
13
- const [t, s, l] = ye(e), [a, u, i] = ye(o), m = Math.round(t + (a - t) * r).toString(16).padStart(2, "0"), h = Math.round(s + (u - s) * r).toString(16).padStart(2, "0"), c = Math.round(l + (i - l) * r).toString(16).padStart(2, "0");
14
- return `#${m}${h}${c}`;
15
- }, ke = (e, o) => {
16
- const r = Math.max(0, Math.min(1, o)), t = [...e].sort((i, m) => i.position - m.position);
17
- if (t.length === 0) return "#000000";
18
- if (t.length === 1 || r <= t[0].position) return t[0].color;
19
- if (r >= t[t.length - 1].position)
20
- return t[t.length - 1].color;
21
- let s = t[0], l = t[t.length - 1];
22
- for (let i = 0; i < t.length - 1; i++)
23
- if (r >= t[i].position && r <= t[i + 1].position) {
24
- s = t[i], l = t[i + 1];
12
+ }, dn = (n, o, r) => {
13
+ const [s, e, a] = Ee(n), [l, u, i] = Ee(o), c = Math.round(s + (l - s) * r).toString(16).padStart(2, "0"), h = Math.round(e + (u - e) * r).toString(16).padStart(2, "0"), f = Math.round(a + (i - a) * r).toString(16).padStart(2, "0");
14
+ return `#${c}${h}${f}`;
15
+ }, De = (n, o) => {
16
+ const r = Math.max(0, Math.min(1, o)), s = [...n].sort((i, c) => i.position - c.position);
17
+ if (s.length === 0) return "#000000";
18
+ if (s.length === 1 || r <= s[0].position) return s[0].color;
19
+ if (r >= s[s.length - 1].position)
20
+ return s[s.length - 1].color;
21
+ let e = s[0], a = s[s.length - 1];
22
+ for (let i = 0; i < s.length - 1; i++)
23
+ if (r >= s[i].position && r <= s[i + 1].position) {
24
+ e = s[i], a = s[i + 1];
25
25
  break;
26
26
  }
27
- const a = l.position - s.position, u = a === 0 ? 0 : (r - s.position) / a;
28
- return rn(s.color, l.color, u);
29
- }, sn = (e) => typeof e == "object" && e !== null && e.type === "texture" && "src" in e, an = (e) => typeof e == "object" && e !== null && e.type === "gradient", ln = `#version 300 es
27
+ const l = a.position - e.position, u = l === 0 ? 0 : (r - e.position) / l;
28
+ return dn(e.color, a.color, u);
29
+ }, fn = (n) => typeof n == "object" && n !== null && n.type === "texture" && "src" in n, mn = (n) => typeof n == "object" && n !== null && n.type === "gradient", pn = `#version 300 es
30
30
 
31
31
  precision highp float;
32
32
 
@@ -40,7 +40,7 @@ void main() {
40
40
  gl_Position = vec4(position, 0.0, 1.0);
41
41
  }
42
42
  `;
43
- class cn {
43
+ class hn {
44
44
  programs = {};
45
45
  fbos = {};
46
46
  renderOrder = [];
@@ -57,11 +57,11 @@ class cn {
57
57
  onTextureLoaded;
58
58
  error = null;
59
59
  constructor(o, r) {
60
- this.patch = r, this.gl = o, this.defaultTexture = z.createTexture(this.gl, {
60
+ this.patch = r, this.gl = o, this.defaultTexture = L.createTexture(this.gl, {
61
61
  minMag: this.gl.NEAREST,
62
62
  wrap: this.gl.CLAMP_TO_EDGE,
63
63
  auto: !1
64
- }), z.setTextureFromArray(
64
+ }), L.setTextureFromArray(
65
65
  this.gl,
66
66
  this.defaultTexture,
67
67
  new Uint8Array([0, 0, 0, 255]),
@@ -73,20 +73,20 @@ class cn {
73
73
  auto: !1
74
74
  }
75
75
  );
76
- let t = !1;
77
- for (let u = 0; u < r.shaders.length && !t; u++) {
76
+ let s = !1;
77
+ for (let u = 0; u < r.shaders.length && !s; u++) {
78
78
  const i = r.shaders[u];
79
- if (this.programs[i.id] = z.createProgramInfo(
79
+ if (this.programs[i.id] = L.createProgramInfo(
80
80
  this.gl,
81
- [ln, i.source],
81
+ [pn, i.source],
82
82
  void 0,
83
- (m) => {
84
- const h = m.match(/ERROR:\s*\d+:(\d+):/), c = h ? parseInt(h[1], 10) : 0;
85
- this.error = { message: m, line: c, shaderName: i.name }, t = !0;
83
+ (c) => {
84
+ const h = c.match(/ERROR:\s*\d+:(\d+):/), f = h ? parseInt(h[1], 10) : 0;
85
+ this.error = { message: c, line: f, shaderName: i.name }, s = !0;
86
86
  }
87
- ), t)
87
+ ), s)
88
88
  break;
89
- this.fbos[i.id] = z.createFramebufferInfo(
89
+ this.fbos[i.id] = L.createFramebufferInfo(
90
90
  this.gl,
91
91
  [
92
92
  {
@@ -101,41 +101,41 @@ class cn {
101
101
  i.resolution.height
102
102
  );
103
103
  }
104
- this.quad = z.primitives.createXYQuadBufferInfo(this.gl);
105
- const s = {}, l = {};
104
+ this.quad = L.primitives.createXYQuadBufferInfo(this.gl);
105
+ const e = {}, a = {};
106
106
  this.uniforms = {};
107
107
  for (let u = 0; u < this.patch.shaders.length; u++) {
108
108
  const i = this.patch.shaders[u];
109
- s[i.id] = [], l[i.id] = 0, this.dependencyMapping[i.id] = [], this.uniforms[i.id] = {};
109
+ e[i.id] = [], a[i.id] = 0, this.dependencyMapping[i.id] = [], this.uniforms[i.id] = {};
110
110
  }
111
111
  for (const u of this.patch.connections)
112
- s[u.from].push(u.to), l[u.to] += 1, this.dependencyMapping[u.to].push({
112
+ e[u.from].push(u.to), a[u.to] += 1, this.dependencyMapping[u.to].push({
113
113
  input: u.input,
114
114
  from: u.from
115
115
  });
116
- const a = [...Object.entries(l)].reduce(
117
- (u, [i, m]) => m === 0 ? [...u, i] : u,
116
+ const l = [...Object.entries(a)].reduce(
117
+ (u, [i, c]) => c === 0 ? [...u, i] : u,
118
118
  []
119
119
  );
120
- for (; a.length > 0; ) {
121
- const u = a.shift();
120
+ for (; l.length > 0; ) {
121
+ const u = l.shift();
122
122
  this.renderOrder.push(u);
123
- for (const i of s[u]) {
124
- const m = l[i] - 1;
125
- l[i] = m, m === 0 && a.push(i);
123
+ for (const i of e[u]) {
124
+ const c = a[i] - 1;
125
+ a[i] = c, c === 0 && l.push(i);
126
126
  }
127
127
  }
128
128
  if (this.renderOrder.length < this.patch.shaders.length)
129
- throw Error("Cycle detected in graph");
129
+ throw console.log(this.patch, this.renderOrder), Error("Cycle detected in graph");
130
130
  }
131
131
  _getOrCreateTexture(o) {
132
132
  if (!this.textures[o]) {
133
- const r = z.createTexture(this.gl, {
133
+ const r = L.createTexture(this.gl, {
134
134
  minMag: this.gl.NEAREST,
135
135
  wrap: this.gl.CLAMP_TO_EDGE,
136
136
  auto: !1
137
137
  });
138
- z.setTextureFromArray(this.gl, r, new Uint8Array([0, 0, 0, 255]), {
138
+ L.setTextureFromArray(this.gl, r, new Uint8Array([0, 0, 0, 255]), {
139
139
  width: 1,
140
140
  height: 1,
141
141
  minMag: this.gl.NEAREST,
@@ -146,50 +146,50 @@ class cn {
146
146
  return this.textures[o];
147
147
  }
148
148
  _updateGradientUniform(o, r) {
149
- let t = this.gradientCanvases[o];
150
- t || (t = document.createElement("canvas"), t.width = 256, t.height = 1, this.gradientCanvases[o] = t);
151
- const s = t.getContext("2d");
152
- for (let l = 0; l < 256; l++)
153
- s.fillStyle = ke(r.stops, l / 255), s.fillRect(l, 0, 1, 1);
154
- return this._updateTextureUniform(o, { type: "texture", src: t });
149
+ let s = this.gradientCanvases[o];
150
+ s || (s = document.createElement("canvas"), s.width = 256, s.height = 1, this.gradientCanvases[o] = s);
151
+ const e = s.getContext("2d");
152
+ for (let a = 0; a < 256; a++)
153
+ e.fillStyle = De(r.stops, a / 255), e.fillRect(a, 0, 1, 1);
154
+ return this._updateTextureUniform(o, { type: "texture", src: s });
155
155
  }
156
156
  _updateTextureUniform(o, r) {
157
- const t = this._getOrCreateTexture(o), s = r.src;
158
- if (typeof s == "string") {
159
- if (this.textureSrcs[o] !== s) {
160
- this.textureSrcs[o] = s;
161
- const l = new Image();
162
- l.onload = () => {
163
- this.textures[o] === t && (z.setTextureFromElement(this.gl, t, l, {
157
+ const s = this._getOrCreateTexture(o), e = r.src;
158
+ if (typeof e == "string") {
159
+ if (this.textureSrcs[o] !== e) {
160
+ this.textureSrcs[o] = e;
161
+ const a = new Image();
162
+ a.onload = () => {
163
+ this.textures[o] === s && (L.setTextureFromElement(this.gl, s, a, {
164
164
  minMag: this.gl.NEAREST,
165
165
  wrap: this.gl.CLAMP_TO_EDGE,
166
166
  auto: !1
167
167
  }), this.onTextureLoaded?.());
168
- }, l.src = s;
168
+ }, a.src = e;
169
169
  }
170
170
  } else
171
- z.setTextureFromElement(this.gl, t, s, {
171
+ L.setTextureFromElement(this.gl, s, e, {
172
172
  minMag: this.gl.NEAREST,
173
173
  wrap: this.gl.CLAMP_TO_EDGE,
174
174
  auto: !1
175
175
  });
176
- return t;
176
+ return s;
177
177
  }
178
178
  render() {
179
179
  if (!this.error)
180
180
  for (let o = 0; o < this.renderOrder.length; o++) {
181
- const r = this.renderOrder[o], t = this.programs[r], s = { ...this.uniforms[r] };
182
- for (const [l, a] of Object.entries(s))
183
- sn(a) ? s[l] = this._updateTextureUniform(
184
- `${r}::${l}`,
185
- a
186
- ) : an(a) && (s[l] = this._updateGradientUniform(
187
- `${r}::${l}`,
188
- a
181
+ const r = this.renderOrder[o], s = this.programs[r], e = { ...this.uniforms[r] };
182
+ for (const [a, l] of Object.entries(e))
183
+ fn(l) ? e[a] = this._updateTextureUniform(
184
+ `${r}::${a}`,
185
+ l
186
+ ) : mn(l) && (e[a] = this._updateGradientUniform(
187
+ `${r}::${a}`,
188
+ l
189
189
  ));
190
- for (const l of this.dependencyMapping[r])
191
- s[l.input] = this.fbos[l.from].attachments[0];
192
- this.gl.useProgram(t.program), o !== this.renderOrder.length - 1 ? z.bindFramebufferInfo(this.gl, this.fbos[r]) : z.bindFramebufferInfo(this.gl, null), z.setUniforms(t, s), z.setBuffersAndAttributes(this.gl, t, this.quad), z.drawBufferInfo(this.gl, this.quad);
190
+ for (const a of this.dependencyMapping[r])
191
+ e[a.input] = this.fbos[a.from].attachments[0];
192
+ this.gl.useProgram(s.program), o !== this.renderOrder.length - 1 ? L.bindFramebufferInfo(this.gl, this.fbos[r]) : L.bindFramebufferInfo(this.gl, null), L.setUniforms(s, e), L.setBuffersAndAttributes(this.gl, s, this.quad), L.drawBufferInfo(this.gl, this.quad);
193
193
  }
194
194
  }
195
195
  dispose() {
@@ -209,73 +209,73 @@ class cn {
209
209
  o.buffer && this.gl.deleteBuffer(o.buffer);
210
210
  }
211
211
  }
212
- const Re = Ge(
213
- ({ patch: e, uniforms: o, className: r, style: t, width: s = 100, height: l = 100, animate: a, onError: u }, i) => {
214
- const m = R(null);
215
- return D(() => {
216
- if (m.current) {
217
- const h = m.current.getContext("webgl2", {
212
+ const Re = Qe(
213
+ ({ patch: n, uniforms: o, className: r, style: s, width: e = 100, height: a = 100, animate: l, onError: u }, i) => {
214
+ const c = $(null);
215
+ return k(() => {
216
+ if (c.current) {
217
+ const h = c.current.getContext("webgl2", {
218
218
  preserveDrawingBuffer: !0
219
- }), c = new cn(h, e);
220
- u?.(c.error);
221
- let f = null;
222
- const b = () => {
223
- c.uniforms = o.current, c.render();
219
+ }), f = new hn(h, n);
220
+ u?.(f.error);
221
+ let p = null;
222
+ const x = () => {
223
+ f.uniforms = o.current, f.render();
224
224
  };
225
- return a ? f = requestAnimationFrame(function C() {
226
- b(), f = requestAnimationFrame(C);
227
- }) : (c.onTextureLoaded = b, b()), () => {
228
- f !== null && cancelAnimationFrame(f), c.dispose();
225
+ return l ? p = requestAnimationFrame(function w() {
226
+ x(), p = requestAnimationFrame(w);
227
+ }) : (f.onTextureLoaded = x, x()), () => {
228
+ p !== null && cancelAnimationFrame(p), f.dispose();
229
229
  };
230
230
  }
231
- }, [e, s, l, a]), /* @__PURE__ */ n(
231
+ }, [n, e, a, l]), /* @__PURE__ */ t(
232
232
  "canvas",
233
233
  {
234
234
  className: `image-crisp ${r ?? ""}`,
235
- style: t,
236
- width: s,
237
- height: l,
235
+ style: s,
236
+ width: e,
237
+ height: a,
238
238
  ref: (h) => {
239
- m.current = h, typeof i == "function" ? i(h) : i && (i.current = h);
239
+ c.current = h, typeof i == "function" ? i(h) : i && (i.current = h);
240
240
  }
241
241
  }
242
242
  );
243
243
  }
244
- ), T = "([-\\d.]+)", O = "\\s*,\\s*", ae = (e) => {
245
- const o = [], r = e.source.split(`
244
+ ), M = "([-\\d.]+)", q = "\\s*,\\s*", ce = (n) => {
245
+ const o = [], r = n.source.split(`
246
246
  `);
247
- for (const t of r) {
248
- const s = t.trim(), l = s.match(
247
+ for (const s of r) {
248
+ const e = s.trim(), a = e.match(
249
249
  new RegExp(
250
- `^uniform\\s+float\\s+(\\w+)\\s*;.*\\/\\/\\s*\\[\\s*${T}${O}${T}${O}${T}\\s*\\]`
250
+ `^uniform\\s+float\\s+(\\w+)\\s*;.*\\/\\/\\s*\\[\\s*${M}${q}${M}${q}${M}\\s*\\]`
251
251
  )
252
252
  );
253
- if (l?.[1]) {
254
- const v = parseFloat(l[2]), E = parseFloat(l[3]), U = parseFloat(l[4]);
253
+ if (a?.[1]) {
254
+ const v = parseFloat(a[2]), C = parseFloat(a[3]), A = parseFloat(a[4]);
255
255
  o.push({
256
- name: l[1],
256
+ name: a[1],
257
257
  type: "float",
258
258
  min: v,
259
- max: E,
260
- default: U
259
+ max: C,
260
+ default: A
261
261
  });
262
262
  continue;
263
263
  }
264
- const a = s.match(
264
+ const l = e.match(
265
265
  /^uniform\s+float\s+(\w+)\s*;.*\/\/\s*time\b/
266
266
  );
267
- if (a?.[1]) {
268
- o.push({ name: a[1], type: "float", special: "time" });
267
+ if (l?.[1]) {
268
+ o.push({ name: l[1], type: "float", special: "time" });
269
269
  continue;
270
270
  }
271
- const u = s.match(/^uniform\s+float\s+(\w+)\s*;/);
271
+ const u = e.match(/^uniform\s+float\s+(\w+)\s*;/);
272
272
  if (u?.[1]) {
273
273
  o.push({ name: u[1], type: "float" });
274
274
  continue;
275
275
  }
276
- const i = s.match(
276
+ const i = e.match(
277
277
  new RegExp(
278
- `^uniform\\s+vec2\\s+(\\w+)\\s*;.*\\/\\/\\s*\\[\\s*${T}${O}${T}\\s*\\]`
278
+ `^uniform\\s+vec2\\s+(\\w+)\\s*;.*\\/\\/\\s*\\[\\s*${M}${q}${M}\\s*\\]`
279
279
  )
280
280
  );
281
281
  if (i?.[1]) {
@@ -286,28 +286,28 @@ const Re = Ge(
286
286
  o.push({ name: i[1], type: "vec2", default: v });
287
287
  continue;
288
288
  }
289
- const m = s.match(
289
+ const c = e.match(
290
290
  new RegExp(
291
- `^uniform\\s+vec3\\s+(\\w+)\\s*;.*\\/\\/\\s*color(?:\\s*\\[\\s*${T}${O}${T}${O}${T}\\s*\\])?`
291
+ `^uniform\\s+vec3\\s+(\\w+)\\s*;.*\\/\\/\\s*color(?:\\s*\\[\\s*${M}${q}${M}${q}${M}\\s*\\])?`
292
292
  )
293
293
  );
294
- if (m?.[1]) {
295
- const v = m[2] !== void 0 ? [
296
- parseFloat(m[2]),
297
- parseFloat(m[3]),
298
- parseFloat(m[4])
294
+ if (c?.[1]) {
295
+ const v = c[2] !== void 0 ? [
296
+ parseFloat(c[2]),
297
+ parseFloat(c[3]),
298
+ parseFloat(c[4])
299
299
  ] : void 0;
300
300
  o.push({
301
- name: m[1],
301
+ name: c[1],
302
302
  type: "vec3",
303
303
  color: !0,
304
304
  ...v && { default: v }
305
305
  });
306
306
  continue;
307
307
  }
308
- const h = s.match(
308
+ const h = e.match(
309
309
  new RegExp(
310
- `^uniform\\s+vec3\\s+(\\w+)\\s*;.*\\/\\/\\s*\\[\\s*${T}${O}${T}${O}${T}\\s*\\]`
310
+ `^uniform\\s+vec3\\s+(\\w+)\\s*;.*\\/\\/\\s*\\[\\s*${M}${q}${M}${q}${M}\\s*\\]`
311
311
  )
312
312
  );
313
313
  if (h?.[1]) {
@@ -319,75 +319,90 @@ const Re = Ge(
319
319
  o.push({ name: h[1], type: "vec3", default: v });
320
320
  continue;
321
321
  }
322
- const c = s.match(
322
+ const f = e.match(
323
323
  new RegExp(
324
- `^uniform\\s+vec4\\s+(\\w+)\\s*;.*\\/\\/\\s*color(?:\\s*\\[\\s*${T}${O}${T}${O}${T}${O}${T}\\s*\\])?`
324
+ `^uniform\\s+vec4\\s+(\\w+)\\s*;.*\\/\\/\\s*color(?:\\s*\\[\\s*${M}${q}${M}${q}${M}${q}${M}\\s*\\])?`
325
325
  )
326
326
  );
327
- if (c?.[1]) {
328
- const v = c[2] !== void 0 ? [
329
- parseFloat(c[2]),
330
- parseFloat(c[3]),
331
- parseFloat(c[4]),
332
- parseFloat(c[5])
327
+ if (f?.[1]) {
328
+ const v = f[2] !== void 0 ? [
329
+ parseFloat(f[2]),
330
+ parseFloat(f[3]),
331
+ parseFloat(f[4]),
332
+ parseFloat(f[5])
333
333
  ] : void 0;
334
334
  o.push({
335
- name: c[1],
335
+ name: f[1],
336
336
  type: "vec4",
337
337
  color: !0,
338
338
  ...v && { default: v }
339
339
  });
340
340
  continue;
341
341
  }
342
- const f = s.match(
342
+ const p = e.match(
343
343
  new RegExp(
344
- `^uniform\\s+vec4\\s+(\\w+)\\s*;.*\\/\\/\\s*\\[\\s*${T}${O}${T}${O}${T}${O}${T}\\s*\\]`
344
+ `^uniform\\s+vec4\\s+(\\w+)\\s*;.*\\/\\/\\s*\\[\\s*${M}${q}${M}${q}${M}${q}${M}\\s*\\]`
345
345
  )
346
346
  );
347
- if (f?.[1]) {
347
+ if (p?.[1]) {
348
348
  const v = [
349
- parseFloat(f[2]),
350
- parseFloat(f[3]),
351
- parseFloat(f[4]),
352
- parseFloat(f[5])
349
+ parseFloat(p[2]),
350
+ parseFloat(p[3]),
351
+ parseFloat(p[4]),
352
+ parseFloat(p[5])
353
353
  ];
354
- o.push({ name: f[1], type: "vec4", default: v });
354
+ o.push({ name: p[1], type: "vec4", default: v });
355
355
  continue;
356
356
  }
357
- const b = s.match(
357
+ const x = e.match(
358
358
  /^uniform\s+vec2\s+(\w+)\s*;.*\/\/\s*mouse\b/
359
359
  );
360
- if (b?.[1]) {
361
- o.push({ name: b[1], type: "vec2", special: "mouse" });
360
+ if (x?.[1]) {
361
+ o.push({ name: x[1], type: "vec2", special: "mouse" });
362
362
  continue;
363
363
  }
364
- const C = s.match(
364
+ const w = e.match(
365
365
  /^uniform\s+vec2\s+(\w+)\s*;.*\/\/\s*resolution\b/
366
366
  );
367
- if (C?.[1]) {
368
- o.push({ name: C[1], type: "vec2", special: "resolution" });
367
+ if (w?.[1]) {
368
+ o.push({ name: w[1], type: "vec2", special: "resolution" });
369
369
  continue;
370
370
  }
371
- const N = s.match(/^uniform\s+(vec[234])\s+(\w+)\s*;/);
372
- if (N) {
373
- const v = N[1], E = N[2];
374
- v === "vec2" ? o.push({ name: E, type: "vec2" }) : v === "vec3" ? o.push({ name: E, type: "vec3" }) : v === "vec4" && o.push({ name: E, type: "vec4" });
371
+ const E = e.match(/^uniform\s+(vec[234])\s+(\w+)\s*;/);
372
+ if (E) {
373
+ const v = E[1], C = E[2];
374
+ v === "vec2" ? o.push({ name: C, type: "vec2" }) : v === "vec3" ? o.push({ name: C, type: "vec3" }) : v === "vec4" && o.push({ name: C, type: "vec4" });
375
375
  continue;
376
376
  }
377
- const F = s.match(
377
+ const T = e.match(
378
378
  /^uniform\s+sampler2D\s+(\w+)\s*;(?:.*\/\/\s*(texture|gradient)\b)?/
379
379
  );
380
- if (F?.[1]) {
381
- const v = F[2], E = v === "texture" ? "texture" : v === "gradient" ? "gradient" : "input";
380
+ if (T?.[1]) {
381
+ const v = T[2], C = v === "texture" ? "texture" : v === "gradient" ? "gradient" : "input";
382
382
  o.push({
383
- name: F[1],
383
+ name: T[1],
384
384
  type: "sampler2D",
385
- source: E
385
+ source: C
386
386
  });
387
387
  }
388
388
  }
389
389
  return o;
390
- }, un = `import { RendererComponent, type Uniforms, type Patch } from "@sequenza/lib";
390
+ };
391
+ function vn(n) {
392
+ switch (n.type) {
393
+ case "float":
394
+ return n.default ?? 0;
395
+ case "vec2":
396
+ return n.default ?? [0, 0];
397
+ case "vec3":
398
+ return n.default ?? (n.color ? [1, 1, 1] : [0, 0, 0]);
399
+ case "vec4":
400
+ return n.default ?? (n.color ? [1, 1, 1, 1] : [0, 0, 0, 0]);
401
+ case "sampler2D":
402
+ return;
403
+ }
404
+ }
405
+ const gn = `import { RendererComponent, type Uniforms, type Patch } from "@sequenza/lib";
391
406
  import "@sequenza/lib/style.css";
392
407
  import { useRef } from "react";
393
408
 
@@ -415,109 +430,113 @@ function getPatch(): Patch {
415
430
  throw new Error("placeholder for patch");
416
431
  }
417
432
  `;
418
- function dn(e, o) {
419
- let r = un;
420
- const t = Object.keys(e).filter((l) => !!o.shaders.find((u) => u.id === l)), s = {};
421
- for (const l of t)
422
- s[l] = e[l];
433
+ function xn(n, o) {
434
+ let r = gn;
435
+ const s = Object.keys(n).filter((a) => !!o.shaders.find((u) => u.id === a)), e = {};
436
+ for (const a of s)
437
+ e[a] = n[a];
423
438
  return r = r.replace(
424
439
  'throw new Error("placeholder for initial uniforms");',
425
- `return ${JSON.stringify(s, null, 2)};`
440
+ `return ${JSON.stringify(e, null, 2)};`
426
441
  ), r = r.replace(
427
442
  'throw new Error("placeholder for patch");',
428
443
  `return ${JSON.stringify(o, null, 2)};`
429
444
  ), r;
430
445
  }
431
- const we = 16, Ce = ({ id: e, type: o, position: r }) => {
432
- const t = o === "source";
433
- let s;
434
- return t ? s = "bg-neutral-300 text-neutral-500 hover:border-neutral-500 hover:text-neutral-800 bg-[#78A3C4]" : s = "bg-neutral-300", /* @__PURE__ */ n(
435
- Xe,
446
+ const ve = 14, Se = 50, Ue = ({ id: n, type: o, position: r, count: s }) => {
447
+ const e = o === "source";
448
+ let a;
449
+ return e ? a = "bg-neutral-300 text-neutral-500 hover:border-neutral-500 hover:text-neutral-800 bg-[#78A3C4]" : a = "bg-neutral-300", /* @__PURE__ */ t(
450
+ en,
436
451
  {
437
- id: e,
452
+ id: n,
438
453
  type: o,
439
454
  position: r,
455
+ className: `${r === ne.Top ? "top-0 -translate-y-1/2" : r === ne.Bottom ? "bottom-0" : ""}`,
440
456
  style: {
441
457
  background: "none",
442
458
  border: "none",
443
- width: we,
444
- height: we
459
+ width: ve * 2,
460
+ height: ve,
461
+ ...s ? {
462
+ transform: `translateX(${s.index / (s.total - 1) * Se - Se / 2 - ve}px)`
463
+ } : {}
445
464
  },
446
- children: /* @__PURE__ */ n(
465
+ children: /* @__PURE__ */ t(
447
466
  "div",
448
467
  {
449
- className: `absolute inset-0 rounded-full flex items-center justify-center text-xs font-mono leading-none pointer-events-none transition-colors ${s}`
468
+ className: `absolute inset-0 rounded-full flex items-center justify-center text-xs font-mono leading-none pointer-events-none transition-colors ${a}`
450
469
  }
451
470
  )
452
471
  }
453
472
  );
454
- }, H = ({
455
- value: e,
473
+ }, V = ({
474
+ value: n,
456
475
  min: o = -1 / 0,
457
476
  max: r = 1 / 0,
458
- step: t = 0.01,
459
- label: s,
460
- onChange: l
477
+ step: s = 0.01,
478
+ label: e,
479
+ onChange: a
461
480
  }) => {
462
- const a = R(!1), u = R(0), i = R(0), [m, h] = y(!1), [c, f] = y(""), b = R(null), C = R(null), N = (g) => Math.min(r, Math.max(o, g)), F = W(
463
- (g) => {
464
- m || (a.current = !0, u.current = g.clientX, i.current = e, g.preventDefault());
481
+ const l = $(!1), u = $(0), i = $(0), [c, h] = y(!1), [f, p] = y(""), x = $(null), w = $(null), E = (_) => Math.min(r, Math.max(o, _)), T = Y(
482
+ (_) => {
483
+ c || (l.current = !0, u.current = _.clientX, i.current = n, _.preventDefault());
465
484
  },
466
- [e, m]
485
+ [n, c]
467
486
  );
468
- D(() => {
469
- const g = (B) => {
470
- if (!a.current) return;
471
- const _ = (B.clientX - u.current) * t;
472
- l(N(parseFloat((i.current + _).toFixed(6))));
473
- }, k = () => {
474
- a.current = !1;
487
+ k(() => {
488
+ const _ = (I) => {
489
+ if (!l.current) return;
490
+ const H = (I.clientX - u.current) * s;
491
+ a(E(parseFloat((i.current + H).toFixed(6))));
492
+ }, S = () => {
493
+ l.current = !1;
475
494
  };
476
- return window.addEventListener("mousemove", g), window.addEventListener("mouseup", k), () => {
477
- window.removeEventListener("mousemove", g), window.removeEventListener("mouseup", k);
495
+ return window.addEventListener("mousemove", _), window.addEventListener("mouseup", S), () => {
496
+ window.removeEventListener("mousemove", _), window.removeEventListener("mouseup", S);
478
497
  };
479
- }, [t, o, r, l]);
498
+ }, [s, o, r, a]);
480
499
  const v = () => {
481
- f(String(e)), h(!0), setTimeout(() => b.current?.select(), 0);
482
- }, E = () => {
483
- const g = parseFloat(c);
484
- isNaN(g) || l(N(g)), h(!1);
485
- }, U = (g) => {
486
- m || (g.key === "Enter" || g.key === " " ? (g.preventDefault(), f(String(e)), h(!0), setTimeout(() => b.current?.select(), 0)) : g.key === "ArrowRight" || g.key === "ArrowUp" ? (g.preventDefault(), l(N(parseFloat((e + t).toFixed(6))))) : (g.key === "ArrowLeft" || g.key === "ArrowDown") && (g.preventDefault(), l(N(parseFloat((e - t).toFixed(6))))));
487
- }, S = Number.isInteger(e) ? e.toFixed(1) : e.toFixed(3).replace(/0+$/, "");
488
- return /* @__PURE__ */ p("div", { className: "flex items-center w-20 relative nodrag", children: [
489
- s && /* @__PURE__ */ n("span", { className: "absolute left-1 z-10 bg-neutral-200 h-4 w-4 grid place-items-center pointer-events-none rounded-sm", children: /* @__PURE__ */ n("p", { className: "text-[11px] font-mono w-3 text-neutral-500 height-3 leading-0 -translate-y-0.5 translate-x-0.5 ", children: s }) }),
490
- /* @__PURE__ */ n(
500
+ p(String(n)), h(!0), setTimeout(() => x.current?.select(), 0);
501
+ }, C = () => {
502
+ const _ = parseFloat(f);
503
+ isNaN(_) || a(E(_)), h(!1);
504
+ }, A = (_) => {
505
+ c || (_.key === "Enter" || _.key === " " ? (_.preventDefault(), p(String(n)), h(!0), setTimeout(() => x.current?.select(), 0)) : _.key === "ArrowRight" || _.key === "ArrowUp" ? (_.preventDefault(), a(E(parseFloat((n + s).toFixed(6))))) : (_.key === "ArrowLeft" || _.key === "ArrowDown") && (_.preventDefault(), a(E(parseFloat((n - s).toFixed(6))))));
506
+ }, U = Number.isInteger(n) ? n.toFixed(1) : n.toFixed(3).replace(/0+$/, "");
507
+ return /* @__PURE__ */ m("div", { className: "flex items-center w-20 relative nodrag", children: [
508
+ e && /* @__PURE__ */ t("span", { className: "absolute left-1 z-10 bg-neutral-200 h-4 w-4 grid place-items-center pointer-events-none rounded-sm", children: /* @__PURE__ */ t("p", { className: "text-[11px] font-mono w-3 text-neutral-500 height-3 leading-0 -translate-y-0.5 translate-x-0.5 ", children: e }) }),
509
+ /* @__PURE__ */ t(
491
510
  "div",
492
511
  {
493
- ref: C,
512
+ ref: w,
494
513
  tabIndex: 0,
495
- onMouseDown: F,
514
+ onMouseDown: T,
496
515
  onDoubleClick: v,
497
- onKeyDown: U,
516
+ onKeyDown: A,
498
517
  className: [
499
518
  "flex items-center justify-center",
500
519
  "rounded overflow-hidden select-none w-full h-6",
501
520
  "focus:outline-2 focus:outline-neutral-400 focus:outline-offset-1",
502
- m ? "cursor-text" : "cursor-ew-resize"
521
+ c ? "cursor-text" : "cursor-ew-resize"
503
522
  ].join(" "),
504
- children: m ? /* @__PURE__ */ n(
523
+ children: c ? /* @__PURE__ */ t(
505
524
  "input",
506
525
  {
507
- ref: b,
508
- value: c,
509
- onChange: (g) => f(g.target.value),
510
- onBlur: E,
511
- onKeyDown: (g) => {
512
- g.key === "Enter" && E(), g.key === "Escape" && h(!1);
526
+ ref: x,
527
+ value: f,
528
+ onChange: (_) => p(_.target.value),
529
+ onBlur: C,
530
+ onKeyDown: (_) => {
531
+ _.key === "Enter" && C(), _.key === "Escape" && h(!1);
513
532
  },
514
533
  className: "outline-none text-neutral-500 text-xs font-mono border-neutral-200 pl-5 rounded-sm text-right w-full h-full bg-white"
515
534
  }
516
- ) : /* @__PURE__ */ n("span", { className: "text-xs font-mono text-neutral-500 pl-5 pointer-events-none border-neutral-200 bg-white rounded-sm w-full h-full flex items-center justify-end px-1", children: /* @__PURE__ */ n("p", { children: S }) })
535
+ ) : /* @__PURE__ */ t("span", { className: "text-xs font-mono text-neutral-500 pl-5 pointer-events-none border-neutral-200 bg-white rounded-sm w-full h-full flex items-center justify-end px-1", children: /* @__PURE__ */ t("p", { children: U }) })
517
536
  }
518
537
  )
519
538
  ] });
520
- }, oe = We({
539
+ }, ae = Ze({
521
540
  currentTime: { current: 0 },
522
541
  mousePosition: { current: [0, 0] },
523
542
  shaders: [],
@@ -532,286 +551,292 @@ const we = 16, Ce = ({ id: e, type: o, position: r }) => {
532
551
  uniforms: { current: {} },
533
552
  handleUpdateUniforms: () => {
534
553
  },
535
- handleUpdateNode: (e) => e,
554
+ handleUpdateNode: (n) => n,
536
555
  handleInsertShader: () => {
537
556
  }
538
- }), me = (e) => Math.round(Math.min(1, Math.max(0, e)) * 255).toString(16).padStart(2, "0"), pe = (e) => parseInt(e, 16) / 255, Ue = ([e, o, r]) => `#${me(e)}${me(o)}${me(r)}`, Ie = (e) => [
539
- pe(e.slice(1, 3)),
540
- pe(e.slice(3, 5)),
541
- pe(e.slice(5, 7))
542
- ], ve = ({ color: e, onChange: o }) => {
543
- const r = R(null);
544
- return /* @__PURE__ */ p("div", { className: "relative", children: [
545
- /* @__PURE__ */ n(
557
+ }), ge = (n) => Math.round(Math.min(1, Math.max(0, n)) * 255).toString(16).padStart(2, "0"), xe = (n) => parseInt(n, 16) / 255, Fe = ([n, o, r]) => `#${ge(n)}${ge(o)}${ge(r)}`, Pe = (n) => [
558
+ xe(n.slice(1, 3)),
559
+ xe(n.slice(3, 5)),
560
+ xe(n.slice(5, 7))
561
+ ], be = ({ color: n, onChange: o }) => {
562
+ const r = $(null);
563
+ return /* @__PURE__ */ m("div", { className: "relative", children: [
564
+ /* @__PURE__ */ t(
546
565
  "button",
547
566
  {
548
567
  onClick: () => r.current?.click(),
549
568
  className: "w-8 h-5.5 rounded border-2 border-neutral-200 cursor-pointer",
550
- style: { backgroundColor: e },
551
- title: e
569
+ style: { backgroundColor: n },
570
+ title: n
552
571
  }
553
572
  ),
554
- /* @__PURE__ */ n(
573
+ /* @__PURE__ */ t(
555
574
  "input",
556
575
  {
557
576
  ref: r,
558
577
  type: "color",
559
- value: e,
560
- onChange: (t) => o(t.target.value),
578
+ value: n,
579
+ onChange: (s) => o(s.target.value),
561
580
  className: "absolute opacity-0 w-0 h-0 pointer-events-none"
562
581
  }
563
582
  )
564
583
  ] });
565
- }, K = ({ onClick: e }) => /* @__PURE__ */ n(
584
+ }, Q = ({ onClick: n }) => /* @__PURE__ */ t(
566
585
  "button",
567
586
  {
568
- onClick: e,
587
+ onClick: n,
569
588
  className: "w-6 h-6 flex items-center justify-center text-neutral-400 hover:text-neutral-700 hover:bg-neutral-100 rounded-sm select-none shrink-0",
570
589
  title: "Reset to default",
571
590
  children: "↺"
572
591
  }
573
- ), fn = ({ name: e, type: o }) => {
574
- const { showStats: r } = ie(oe);
575
- return /* @__PURE__ */ p("div", { className: " min-w-40 flex flex-col gap-0.5 items-end", children: [
576
- /* @__PURE__ */ n("span", { className: "font-mono text-xs text-neutral-900", children: e.replace("u_", "").replaceAll("_", " ").replace(/\b\w/g, (t) => t.toUpperCase()) }),
577
- r && /* @__PURE__ */ n("span", { className: "font-mono text-[10px] text-neutral-500", children: o })
592
+ ), _n = ({
593
+ name: n,
594
+ type: o
595
+ }) => {
596
+ const { showStats: r } = ue(ae);
597
+ return /* @__PURE__ */ m("div", { className: " min-w-40 flex flex-col gap-0.5 items-end", children: [
598
+ /* @__PURE__ */ t("span", { className: "font-mono text-xs text-neutral-900", children: n.replace("u_", "").replaceAll("_", " ").replace(/\b\w/g, (s) => s.toUpperCase()) }),
599
+ r && /* @__PURE__ */ t("span", { className: "font-mono text-[10px] text-neutral-500", children: o })
578
600
  ] });
579
- }, mn = ({ field: e, initialValue: o, handleUpdateUniformField: r }) => {
580
- const [t, s] = y(o ?? e.default ?? 0), l = (a) => {
581
- s(a), r(a);
601
+ }, bn = ({ field: n, initialValue: o, handleUpdateUniformField: r }) => {
602
+ const [s, e] = y(o);
603
+ k(() => {
604
+ e(o), r(o);
605
+ }, [o]);
606
+ const a = (l) => {
607
+ e(l), r(l);
582
608
  };
583
- return /* @__PURE__ */ p("div", { className: "flex items-center ", children: [
584
- /* @__PURE__ */ n(
585
- H,
609
+ return /* @__PURE__ */ m("div", { className: "flex items-center ", children: [
610
+ /* @__PURE__ */ t(
611
+ V,
586
612
  {
587
- value: t,
588
- min: e.min,
589
- max: e.max,
613
+ value: s,
614
+ min: n.min,
615
+ max: n.max,
590
616
  step: 0.01,
591
- onChange: l
617
+ onChange: a
592
618
  }
593
619
  ),
594
- e.default !== void 0 && /* @__PURE__ */ n(K, { onClick: () => l(e.default) })
595
- ] });
596
- }, pn = ({ field: e, initialValue: o, handleUpdateUniformField: r }) => {
597
- const [t, s] = y(
598
- o ?? e.default ?? [0, 0]
599
- ), l = (a, u) => {
600
- const i = [...t];
601
- i[a] = u, s(i), r(i);
602
- };
603
- return /* @__PURE__ */ p("div", { className: "flex items-center ", children: [
604
- /* @__PURE__ */ n("div", { className: "flex gap-2 flex-wrap flex-col", children: ["x", "y"].map((a, u) => /* @__PURE__ */ n(
605
- H,
606
- {
607
- label: a,
608
- value: t[u],
609
- onChange: (i) => l(u, i)
610
- },
611
- a
612
- )) }),
613
- e.default !== void 0 && /* @__PURE__ */ n(
614
- K,
615
- {
616
- onClick: () => {
617
- s(e.default), r(e.default);
618
- }
619
- }
620
- )
620
+ n.default !== void 0 && /* @__PURE__ */ t(Q, { onClick: () => a(n.default) })
621
621
  ] });
622
- }, hn = ({ field: e, initialValue: o, handleUpdateUniformField: r }) => {
623
- const [t, s] = y(
624
- o ?? e.default ?? [1, 1, 1]
625
- ), l = (a) => {
626
- s(a), r(a);
622
+ }, yn = ({ handleUpdateUniformField: n }) => {
623
+ const [o, r] = y(!1), [s, e] = y(0);
624
+ k(() => {
625
+ if (!o) return;
626
+ const l = Date.now() - s * 1e3;
627
+ let u;
628
+ const i = () => {
629
+ const c = (Date.now() - l) / 1e3;
630
+ e(c), n(c), u = requestAnimationFrame(i);
631
+ };
632
+ return u = requestAnimationFrame(i), () => cancelAnimationFrame(u);
633
+ }, [o]);
634
+ const a = () => {
635
+ r(!1), e(0), n(0);
627
636
  };
628
- return /* @__PURE__ */ p("div", { className: "flex items-center ", children: [
629
- /* @__PURE__ */ n(
630
- ve,
637
+ return /* @__PURE__ */ m("div", { className: "flex items-center ", children: [
638
+ /* @__PURE__ */ t(
639
+ "button",
631
640
  {
632
- color: Ue(t),
633
- onChange: (a) => l(Ie(a))
641
+ onClick: () => r((l) => !l),
642
+ className: "text-xs font-mono text-neutral-500 bg-neutral-100 hover:bg-neutral-200 rounded-sm w-6 h-6 flex items-center justify-center select-none",
643
+ title: o ? "Pause" : "Play",
644
+ children: o ? "⏸" : "▶"
634
645
  }
635
646
  ),
636
- e.default !== void 0 && /* @__PURE__ */ n(K, { onClick: () => l(e.default) })
647
+ /* @__PURE__ */ m("span", { className: "font-mono text-xs text-neutral-500 px-2 w-16 text-right tabular-nums", children: [
648
+ s.toFixed(2),
649
+ "s"
650
+ ] }),
651
+ /* @__PURE__ */ t(Q, { onClick: a })
637
652
  ] });
638
- }, vn = ({ field: e, initialValue: o, handleUpdateUniformField: r }) => {
639
- const [t, s] = y(
640
- o ?? e.default ?? [1, 1, 1, 1]
641
- ), [l, a, u, i] = t, m = (h) => {
642
- s(h), r(h);
653
+ }, wn = ({ field: n, initialValue: o, handleUpdateUniformField: r }) => {
654
+ const [s, e] = y(o);
655
+ k(() => {
656
+ e(o), r(o);
657
+ }, [o]);
658
+ const a = (u, i) => {
659
+ const c = [...s];
660
+ c[u] = i, e(c), r(c);
661
+ }, l = (u) => {
662
+ e(u), r(u);
643
663
  };
644
- return /* @__PURE__ */ p("div", { className: "flex items-center ", children: [
645
- /* @__PURE__ */ n(
646
- ve,
664
+ return /* @__PURE__ */ m("div", { className: "flex items-center ", children: [
665
+ /* @__PURE__ */ t("div", { className: "flex gap-2 flex-wrap flex-col", children: ["x", "y"].map((u, i) => /* @__PURE__ */ t(
666
+ V,
647
667
  {
648
- color: Ue([l, a, u]),
649
- onChange: (h) => {
650
- const [c, f, b] = Ie(h);
651
- m([c, f, b, i]);
652
- }
653
- }
654
- ),
655
- /* @__PURE__ */ n(
656
- H,
657
- {
658
- label: "a",
659
- value: i,
660
- min: 0,
661
- max: 1,
662
- step: 0.01,
663
- onChange: (h) => m([l, a, u, h])
664
- }
665
- ),
666
- e.default !== void 0 && /* @__PURE__ */ n(K, { onClick: () => m(e.default) })
668
+ label: u,
669
+ value: s[i],
670
+ onChange: (c) => a(i, c)
671
+ },
672
+ u
673
+ )) }),
674
+ n.default !== void 0 && /* @__PURE__ */ t(Q, { onClick: () => l(n.default) })
667
675
  ] });
668
- }, gn = ({ field: e, initialValue: o, handleUpdateUniformField: r }) => {
669
- const [t, s] = y(
670
- o ?? e.default ?? [0, 0, 0]
671
- ), l = (a, u) => {
672
- const i = [...t];
673
- i[a] = u, s(i), r(i);
676
+ }, Cn = ({ field: n, initialValue: o, handleUpdateUniformField: r }) => {
677
+ const [s, e] = y(o);
678
+ k(() => {
679
+ e(o), r(o);
680
+ }, [o]);
681
+ const a = (u, i) => {
682
+ const c = [...s];
683
+ c[u] = i, e(c), r(c);
684
+ }, l = (u) => {
685
+ e(u), r(u);
674
686
  };
675
- return /* @__PURE__ */ p("div", { className: "flex items-center ", children: [
676
- /* @__PURE__ */ n("div", { className: "flex flex-col gap-2", children: ["x", "y", "z"].map((a, u) => /* @__PURE__ */ n(
677
- H,
687
+ return /* @__PURE__ */ m("div", { className: "flex items-center ", children: [
688
+ /* @__PURE__ */ t("div", { className: "flex flex-col gap-2", children: ["x", "y", "z"].map((u, i) => /* @__PURE__ */ t(
689
+ V,
678
690
  {
679
- label: a,
680
- value: t[u],
681
- onChange: (i) => l(u, i)
691
+ label: u,
692
+ value: s[i],
693
+ onChange: (c) => a(i, c)
682
694
  },
683
- a
695
+ u
684
696
  )) }),
685
- e.default !== void 0 && /* @__PURE__ */ n(
686
- K,
697
+ n.default !== void 0 && /* @__PURE__ */ t(Q, { onClick: () => l(n.default) })
698
+ ] });
699
+ }, Nn = ({ field: n, initialValue: o, handleUpdateUniformField: r }) => {
700
+ const [s, e] = y(o);
701
+ k(() => {
702
+ e(o);
703
+ }, [o]);
704
+ const a = (l) => {
705
+ e(l), r(l);
706
+ };
707
+ return /* @__PURE__ */ m("div", { className: "flex items-center ", children: [
708
+ /* @__PURE__ */ t(
709
+ be,
687
710
  {
688
- onClick: () => {
689
- s(e.default), r(e.default);
690
- }
711
+ color: Fe(s),
712
+ onChange: (l) => a(Pe(l))
691
713
  }
692
- )
714
+ ),
715
+ n.default !== void 0 && /* @__PURE__ */ t(Q, { onClick: () => a(n.default) })
693
716
  ] });
694
- }, xn = ({ field: e, initialValue: o, handleUpdateUniformField: r }) => {
695
- const [t, s] = y(
696
- o ?? e.default ?? [0, 0, 0, 0]
697
- ), l = (a, u) => {
698
- const i = [...t];
699
- i[a] = u, s(i), r(i);
717
+ }, En = ({ field: n, initialValue: o, handleUpdateUniformField: r }) => {
718
+ const [s, e] = y(o);
719
+ k(() => {
720
+ e(o), r(o);
721
+ }, [o]);
722
+ const a = (u, i) => {
723
+ const c = [...s];
724
+ c[u] = i, e(c), r(c);
725
+ }, l = (u) => {
726
+ e(u), r(u);
700
727
  };
701
- return /* @__PURE__ */ p("div", { className: "flex items-center gap-2 px-2", children: [
702
- /* @__PURE__ */ n("div", { className: "flex flex-col gap-2", children: ["x", "y", "z", "w"].map((a, u) => /* @__PURE__ */ n(
703
- H,
728
+ return /* @__PURE__ */ m("div", { className: "flex items-center gap-2 px-2", children: [
729
+ /* @__PURE__ */ t("div", { className: "flex flex-col gap-2", children: ["x", "y", "z", "w"].map((u, i) => /* @__PURE__ */ t(
730
+ V,
704
731
  {
705
- label: a,
706
- value: t[u],
707
- onChange: (i) => l(u, i)
732
+ label: u,
733
+ value: s[i],
734
+ onChange: (c) => a(i, c)
708
735
  },
709
- a
736
+ u
710
737
  )) }),
711
- e.default !== void 0 && /* @__PURE__ */ n(
712
- K,
713
- {
714
- onClick: () => {
715
- s(e.default), r(e.default);
716
- }
717
- }
718
- )
738
+ n.default !== void 0 && /* @__PURE__ */ t(Q, { onClick: () => l(n.default) })
719
739
  ] });
720
- }, bn = ({ handleUpdateUniformField: e }) => {
721
- const [o, r] = y(!1), [t, s] = y(0), l = R(0), a = R(0), u = R(0), i = R(e);
722
- i.current = e, D(() => {
723
- if (!o) return;
724
- a.current = Date.now();
725
- const c = () => {
726
- const f = l.current + (Date.now() - a.current) / 1e3;
727
- s(f), i.current(f), u.current = requestAnimationFrame(c);
728
- };
729
- return u.current = requestAnimationFrame(c), () => {
730
- cancelAnimationFrame(u.current), l.current += (Date.now() - a.current) / 1e3;
731
- };
740
+ }, Sn = ({ field: n, initialValue: o, handleUpdateUniformField: r }) => {
741
+ const [s, e] = y(o);
742
+ k(() => {
743
+ e(o);
732
744
  }, [o]);
733
- const m = () => r((c) => !c), h = () => {
734
- r(!1), l.current = 0, s(0), i.current(0);
745
+ const [a, l, u, i] = s, c = (h) => {
746
+ e(h), r(h);
735
747
  };
736
- return /* @__PURE__ */ p("div", { className: "flex items-center ", children: [
737
- /* @__PURE__ */ n(
738
- "button",
748
+ return /* @__PURE__ */ m("div", { className: "flex items-center ", children: [
749
+ /* @__PURE__ */ t(
750
+ be,
739
751
  {
740
- onClick: m,
741
- className: "text-xs font-mono text-neutral-500 bg-neutral-100 hover:bg-neutral-200 rounded-sm w-6 h-6 flex items-center justify-center select-none",
742
- title: o ? "Pause" : "Play",
743
- children: o ? "⏸" : "▶"
752
+ color: Fe([a, l, u]),
753
+ onChange: (h) => {
754
+ const [f, p, x] = Pe(h);
755
+ c([f, p, x, i]);
756
+ }
744
757
  }
745
758
  ),
746
- /* @__PURE__ */ p("span", { className: "font-mono text-xs text-neutral-500 px-2 w-16 text-right tabular-nums", children: [
747
- t.toFixed(2),
748
- "s"
749
- ] }),
750
- /* @__PURE__ */ n(K, { onClick: h })
759
+ /* @__PURE__ */ t(
760
+ V,
761
+ {
762
+ label: "a",
763
+ value: i,
764
+ min: 0,
765
+ max: 1,
766
+ step: 0.01,
767
+ onChange: (h) => c([a, l, u, h])
768
+ }
769
+ ),
770
+ n.default !== void 0 && /* @__PURE__ */ t(Q, { onClick: () => c(n.default) })
751
771
  ] });
752
- }, _n = ({ handleUpdateUniformField: e }) => {
753
- const { mousePosition: o } = ie(oe), [r, t] = y([0, 0]), s = R(e);
754
- return s.current = e, D(() => {
755
- let l;
772
+ }, Un = ({ handleUpdateUniformField: n }) => {
773
+ const { mousePosition: o } = ue(ae), [r, s] = y([0, 0]);
774
+ return k(() => {
775
+ let e;
756
776
  const a = () => {
757
- const u = [
758
- o.current[0],
759
- o.current[1]
760
- ];
761
- t(u), s.current(u), l = requestAnimationFrame(a);
777
+ const l = [o.current[0], o.current[1]];
778
+ s(l), n(l), e = requestAnimationFrame(a);
762
779
  };
763
- return l = requestAnimationFrame(a), () => cancelAnimationFrame(l);
764
- }, []), /* @__PURE__ */ n("div", { className: "flex items-center ", children: /* @__PURE__ */ n("div", { className: "flex gap-2 flex-col", children: ["x", "y"].map((l, a) => /* @__PURE__ */ p("div", { className: "flex items-center w-20 relative", children: [
765
- /* @__PURE__ */ n("span", { className: "absolute left-1 z-10 bg-neutral-200 h-4 w-4 grid place-items-center pointer-events-none rounded-sm", children: /* @__PURE__ */ n("p", { className: "text-[11px] font-mono w-3 text-neutral-500 leading-0 -translate-y-0.5 translate-x-0.5", children: l }) }),
766
- /* @__PURE__ */ n("span", { className: "text-xs font-mono text-neutral-500 pl-5 pointer-events-none bg-neutral-100 rounded-sm w-full h-6 flex items-center justify-end px-1 tabular-nums", children: r[a].toFixed(3) })
767
- ] }, l)) }) });
768
- }, yn = ({ initialValue: e, handleUpdateUniformField: o }) => {
769
- const [r, t] = y(!1), s = e?.src instanceof HTMLVideoElement ? e.src : null, l = typeof e?.src == "string" ? e.src : s?.src ?? null, a = s !== null, [u, i] = y(l), [m, h] = y(a), [c, f] = y(
770
- l ? l.split("/").pop() ?? null : null
771
- ), [b, C] = y(() => s && s.readyState >= 1 ? [s.videoWidth, s.videoHeight] : null);
772
- D(() => {
773
- if (b === null) {
774
- if (s) {
775
- const v = () => C([s.videoWidth, s.videoHeight]);
776
- s.readyState >= 1 ? v() : s.addEventListener("loadedmetadata", v, { once: !0 });
777
- } else if (l && !a) {
780
+ return e = requestAnimationFrame(a), () => cancelAnimationFrame(e);
781
+ }, [n]), /* @__PURE__ */ t("div", { className: "flex items-center ", children: /* @__PURE__ */ t("div", { className: "flex gap-2 flex-col", children: ["x", "y"].map((e, a) => /* @__PURE__ */ m("div", { className: "flex items-center w-20 relative", children: [
782
+ /* @__PURE__ */ t("span", { className: "absolute left-1 z-10 bg-neutral-200 h-4 w-4 grid place-items-center pointer-events-none rounded-sm", children: /* @__PURE__ */ t("p", { className: "text-[11px] font-mono w-3 text-neutral-500 leading-0 -translate-y-0.5 translate-x-0.5", children: e }) }),
783
+ /* @__PURE__ */ t("span", { className: "text-xs font-mono text-neutral-500 pl-5 pointer-events-none bg-neutral-100 rounded-sm w-full h-6 flex items-center justify-end px-1 tabular-nums", children: r[a].toFixed(3) })
784
+ ] }, e)) }) });
785
+ }, An = ({ width: n, height: o, handleUpdateUniformField: r }) => {
786
+ const s = $(r);
787
+ return s.current = r, k(() => {
788
+ s.current([n, o]);
789
+ }, [n, o]), /* @__PURE__ */ t("div", { className: "flex items-center ", children: /* @__PURE__ */ t("div", { className: "flex gap-2 flex-col", children: ["w", "h"].map((e, a) => /* @__PURE__ */ m("div", { className: "flex items-center w-20 relative", children: [
790
+ /* @__PURE__ */ t("span", { className: "absolute left-1 z-10 bg-neutral-200 h-4 w-4 grid place-items-center pointer-events-none rounded-sm", children: /* @__PURE__ */ t("p", { className: "text-[11px] font-mono w-3 text-neutral-500 leading-0 -translate-y-0.5 translate-x-0.5", children: e }) }),
791
+ /* @__PURE__ */ t("span", { className: "text-xs font-mono text-neutral-500 pl-5 pointer-events-none bg-neutral-100 rounded-sm w-full h-6 flex items-center justify-end px-1 tabular-nums", children: a === 0 ? n : o })
792
+ ] }, e)) }) });
793
+ }, Tn = ({ value: n, handleUpdateUniformField: o }) => {
794
+ const [r, s] = y(!1), e = n?.src instanceof HTMLVideoElement ? n.src : null, a = typeof n?.src == "string" ? n.src : e?.src ?? null, l = e !== null, [u, i] = y(a), [c, h] = y(l), [f, p] = y(
795
+ a ? a.split("/").pop() ?? null : null
796
+ ), [x, w] = y(() => e && e.readyState >= 1 ? [e.videoWidth, e.videoHeight] : null);
797
+ k(() => {
798
+ if (x === null) {
799
+ if (e) {
800
+ const v = () => w([e.videoWidth, e.videoHeight]);
801
+ e.readyState >= 1 ? v() : e.addEventListener("loadedmetadata", v, { once: !0 });
802
+ } else if (a && !l) {
778
803
  const v = new Image();
779
- v.onload = () => C([v.naturalWidth, v.naturalHeight]), v.src = l;
804
+ v.onload = () => w([v.naturalWidth, v.naturalHeight]), v.src = a;
780
805
  }
781
806
  }
782
807
  }, []);
783
- const N = R(null), F = (v) => {
808
+ const E = $(null), T = (v) => {
784
809
  if (!v) return;
785
- const E = URL.createObjectURL(v), U = v.type.startsWith("video/");
786
- if (i(E), h(U), f(v.name), C(null), U) {
787
- const S = document.createElement("video");
788
- S.autoplay = !0, S.muted = !0, S.loop = !0, S.playsInline = !0, S.onloadedmetadata = () => C([S.videoWidth, S.videoHeight]), S.src = E, S.play(), o({ type: "texture", src: S });
810
+ const C = URL.createObjectURL(v), A = v.type.startsWith("video/");
811
+ if (i(C), h(A), p(v.name), w(null), A) {
812
+ const U = document.createElement("video");
813
+ U.autoplay = !0, U.muted = !0, U.loop = !0, U.playsInline = !0, U.onloadedmetadata = () => w([U.videoWidth, U.videoHeight]), U.src = C, U.play(), o({ type: "texture", src: U });
789
814
  } else {
790
- const S = new Image();
791
- S.onload = () => C([S.naturalWidth, S.naturalHeight]), S.src = E, o({ type: "texture", src: E });
815
+ const U = new Image();
816
+ U.onload = () => w([U.naturalWidth, U.naturalHeight]), U.src = C, o({ type: "texture", src: C });
792
817
  }
793
818
  };
794
- return D(() => {
819
+ return k(() => {
795
820
  if (!r) return;
796
- const v = (E) => {
797
- if (E.clipboardData) {
798
- for (const U of E.clipboardData.items)
799
- if (U.type.startsWith("image/") || U.type.startsWith("video/")) {
800
- F(U.getAsFile());
821
+ const v = (C) => {
822
+ if (C.clipboardData) {
823
+ for (const A of C.clipboardData.items)
824
+ if (A.type.startsWith("image/") || A.type.startsWith("video/")) {
825
+ T(A.getAsFile());
801
826
  break;
802
827
  }
803
828
  }
804
829
  };
805
830
  return window.addEventListener("paste", v), () => window.removeEventListener("paste", v);
806
- }, [r]), /* @__PURE__ */ n("div", { className: "flex items-center ", children: /* @__PURE__ */ p("div", { className: "flex flex-col items-start gap-2", children: [
807
- /* @__PURE__ */ n(
831
+ }, [r]), /* @__PURE__ */ t("div", { className: "flex items-center ", children: /* @__PURE__ */ m("div", { className: "flex flex-col items-start gap-2", children: [
832
+ /* @__PURE__ */ t(
808
833
  "div",
809
834
  {
810
835
  tabIndex: 0,
811
- onFocus: () => t(!0),
812
- onBlur: () => t(!1),
836
+ onFocus: () => s(!0),
837
+ onBlur: () => s(!1),
813
838
  className: `w-32 h-32 rounded overflow-hidden flex flex-col items-center justify-center cursor-pointer select-none transition border-4 text-neutral-500 text-xs font-mono p-2 ${r ? "bg-neutral-50 border-neutral-300" : "bg-neutral-100 border-neutral-50"}`,
814
- children: u ? m ? /* @__PURE__ */ n(
839
+ children: u ? c ? /* @__PURE__ */ t(
815
840
  "video",
816
841
  {
817
842
  src: u,
@@ -821,117 +846,111 @@ const we = 16, Ce = ({ id: e, type: o, position: r }) => {
821
846
  loop: !0,
822
847
  playsInline: !0
823
848
  }
824
- ) : /* @__PURE__ */ n("img", { src: u, className: "w-full h-full object-contain" }) : r ? "cmd+V" : /* @__PURE__ */ p(le, { children: [
825
- /* @__PURE__ */ n("p", { children: "Paste" }),
826
- /* @__PURE__ */ n("p", { children: "Here" })
849
+ ) : /* @__PURE__ */ t("img", { src: u, className: "w-full h-full object-contain" }) : r ? "cmd+V" : /* @__PURE__ */ m(se, { children: [
850
+ /* @__PURE__ */ t("p", { children: "Paste" }),
851
+ /* @__PURE__ */ t("p", { children: "Here" })
827
852
  ] })
828
853
  }
829
854
  ),
830
- /* @__PURE__ */ p("div", { className: "flex flex-col items-start gap-0.5", children: [
831
- /* @__PURE__ */ n(
855
+ /* @__PURE__ */ m("div", { className: "flex flex-col items-start gap-0.5", children: [
856
+ /* @__PURE__ */ t(
832
857
  "button",
833
858
  {
834
859
  className: "button-base",
835
- onClick: () => N.current?.click(),
860
+ onClick: () => E.current?.click(),
836
861
  children: u ? "Replace" : "Upload"
837
862
  }
838
863
  ),
839
- c && /* @__PURE__ */ n(
864
+ f && /* @__PURE__ */ t(
840
865
  "span",
841
866
  {
842
867
  className: "text-[10px] text-neutral-400 font-mono truncate max-w-32",
843
- title: c,
844
- children: c
868
+ title: f,
869
+ children: f
845
870
  }
846
871
  ),
847
- b && /* @__PURE__ */ p("span", { className: "text-[10px] text-neutral-400 font-mono", children: [
848
- b[0],
872
+ x && /* @__PURE__ */ m("span", { className: "text-[10px] text-neutral-400 font-mono", children: [
873
+ x[0],
849
874
  "×",
850
- b[1]
875
+ x[1]
851
876
  ] })
852
877
  ] }),
853
- /* @__PURE__ */ n(
878
+ /* @__PURE__ */ t(
854
879
  "input",
855
880
  {
856
- ref: N,
881
+ ref: E,
857
882
  type: "file",
858
883
  accept: "image/*,video/*",
859
884
  className: "hidden",
860
- onChange: (v) => F(v.target.files?.[0] ?? null)
885
+ onChange: (v) => T(v.target.files?.[0] ?? null)
861
886
  }
862
887
  )
863
888
  ] }) });
864
- }, wn = [
889
+ }, Ae = [
865
890
  { position: 0, color: "#000000" },
866
891
  { position: 1, color: "#ffffff" }
867
- ], Cn = ({ width: e, height: o, handleUpdateUniformField: r }) => {
868
- const t = R(r);
869
- return t.current = r, D(() => {
870
- t.current([e, o]);
871
- }, [e, o]), /* @__PURE__ */ n("div", { className: "flex items-center ", children: /* @__PURE__ */ n("div", { className: "flex gap-2 flex-col", children: ["w", "h"].map((s, l) => /* @__PURE__ */ p("div", { className: "flex items-center w-20 relative", children: [
872
- /* @__PURE__ */ n("span", { className: "absolute left-1 z-10 bg-neutral-200 h-4 w-4 grid place-items-center pointer-events-none rounded-sm", children: /* @__PURE__ */ n("p", { className: "text-[11px] font-mono w-3 text-neutral-500 leading-0 -translate-y-0.5 translate-x-0.5", children: s }) }),
873
- /* @__PURE__ */ n("span", { className: "text-xs font-mono text-neutral-500 pl-5 pointer-events-none bg-neutral-100 rounded-sm w-full h-6 flex items-center justify-end px-1 tabular-nums", children: l === 0 ? e : o })
874
- ] }, s)) }) });
875
- }, Nn = ({ initialValue: e, handleUpdateUniformField: o }) => {
876
- const [r, t] = y(
877
- e?.stops ?? wn
878
- ), s = R(null), l = R(null);
879
- D(() => {
880
- const c = s.current;
881
- if (!c) return;
882
- const f = c.getContext("2d");
883
- if (f) {
884
- for (let b = 0; b < c.width; b++)
885
- f.fillStyle = ke(r, b / (c.width - 1)), f.fillRect(b, 0, 1, c.height);
892
+ ], kn = ({ value: n, handleUpdateUniformField: o }) => {
893
+ const [r, s] = y(
894
+ n?.stops ?? Ae
895
+ ), e = $(null), a = $(null);
896
+ k(() => {
897
+ s(n?.stops ?? Ae);
898
+ }, [n]), k(() => {
899
+ const f = e.current;
900
+ if (!f) return;
901
+ const p = f.getContext("2d");
902
+ if (p) {
903
+ for (let x = 0; x < f.width; x++)
904
+ p.fillStyle = De(r, x / (f.width - 1)), p.fillRect(x, 0, 1, f.height);
886
905
  o({ type: "gradient", stops: r });
887
906
  }
888
907
  }, [r]);
889
- const a = (c) => (f) => {
890
- f.preventDefault();
891
- const b = l.current;
892
- if (!b) return;
893
- const C = (F) => {
894
- const v = b.getBoundingClientRect(), U = Math.max(0, Math.min(F.clientX - v.left, v.width)) / v.width;
895
- t(
896
- (S) => S.map((g, k) => k === c ? { ...g, position: U } : g)
908
+ const l = (f) => (p) => {
909
+ p.preventDefault();
910
+ const x = a.current;
911
+ if (!x) return;
912
+ const w = (T) => {
913
+ const v = x.getBoundingClientRect(), A = Math.max(0, Math.min(T.clientX - v.left, v.width)) / v.width;
914
+ s(
915
+ (U) => U.map((_, S) => S === f ? { ..._, position: A } : _)
897
916
  );
898
- }, N = () => {
899
- window.removeEventListener("mousemove", C), window.removeEventListener("mouseup", N);
917
+ }, E = () => {
918
+ window.removeEventListener("mousemove", w), window.removeEventListener("mouseup", E);
900
919
  };
901
- window.addEventListener("mousemove", C), window.addEventListener("mouseup", N);
902
- }, u = () => t((c) => [...c, { position: 1, color: "#ffffff" }]), i = (c) => {
903
- r.length <= 1 || t((f) => f.filter((b, C) => C !== c));
904
- }, m = (c, f) => t(
905
- (b) => b.map((C, N) => N === c ? { ...C, position: f } : C)
906
- ), h = (c, f) => t((b) => b.map((C, N) => N === c ? { ...C, color: f } : C));
907
- return /* @__PURE__ */ p("div", { className: "flex flex-col gap-3 p-2", children: [
908
- /* @__PURE__ */ p("div", { ref: l, className: "relative w-32 h-4 nodrag nopan", children: [
909
- /* @__PURE__ */ n(
920
+ window.addEventListener("mousemove", w), window.addEventListener("mouseup", E);
921
+ }, u = () => s((f) => [...f, { position: 1, color: "#ffffff" }]), i = (f) => {
922
+ r.length <= 1 || s((p) => p.filter((x, w) => w !== f));
923
+ }, c = (f, p) => s(
924
+ (x) => x.map((w, E) => E === f ? { ...w, position: p } : w)
925
+ ), h = (f, p) => s((x) => x.map((w, E) => E === f ? { ...w, color: p } : w));
926
+ return /* @__PURE__ */ m("div", { className: "flex flex-col gap-3 p-2", children: [
927
+ /* @__PURE__ */ m("div", { ref: a, className: "relative w-32 h-4 nodrag nopan", children: [
928
+ /* @__PURE__ */ t(
910
929
  "canvas",
911
930
  {
912
- ref: s,
931
+ ref: e,
913
932
  width: 128,
914
933
  height: 16,
915
934
  className: "w-32 h-4 rounded-sm border-2 border-neutral-200"
916
935
  }
917
936
  ),
918
- r.map((c, f) => /* @__PURE__ */ n(
937
+ r.map((f, p) => /* @__PURE__ */ t(
919
938
  "button",
920
939
  {
921
- "aria-label": `gradient stop ${f}`,
940
+ "aria-label": `gradient stop ${p}`,
922
941
  className: "absolute w-4 h-4 -translate-x-1/2 -bottom-2 rounded-sm border-2 border-neutral-200 cursor-ew-resize",
923
942
  style: {
924
- left: `${c.position * 100}%`,
925
- backgroundColor: c.color
943
+ left: `${f.position * 100}%`,
944
+ backgroundColor: f.color
926
945
  },
927
- onMouseDown: a(f)
946
+ onMouseDown: l(p)
928
947
  },
929
- f
948
+ p
930
949
  ))
931
950
  ] }),
932
- /* @__PURE__ */ p("div", { className: "flex items-center justify-between w-32", children: [
933
- /* @__PURE__ */ n("span", { className: "font-mono text-[10px] text-neutral-500", children: "STOPS" }),
934
- /* @__PURE__ */ n(
951
+ /* @__PURE__ */ m("div", { className: "flex items-center justify-between w-32", children: [
952
+ /* @__PURE__ */ t("span", { className: "font-mono text-[10px] text-neutral-500", children: "STOPS" }),
953
+ /* @__PURE__ */ t(
935
954
  "button",
936
955
  {
937
956
  onClick: u,
@@ -940,259 +959,223 @@ const we = 16, Ce = ({ id: e, type: o, position: r }) => {
940
959
  }
941
960
  )
942
961
  ] }),
943
- /* @__PURE__ */ n("div", { className: "flex flex-col gap-1.5", children: r.map((c, f) => /* @__PURE__ */ p("div", { className: "flex items-center gap-2", children: [
944
- /* @__PURE__ */ n(
945
- H,
962
+ /* @__PURE__ */ t("div", { className: "flex flex-col gap-1.5", children: r.map((f, p) => /* @__PURE__ */ m("div", { className: "flex items-center gap-2", children: [
963
+ /* @__PURE__ */ t(
964
+ V,
946
965
  {
947
- value: c.position,
966
+ value: f.position,
948
967
  min: 0,
949
968
  max: 1,
950
969
  step: 0.01,
951
- onChange: (b) => m(f, b)
970
+ onChange: (x) => c(p, x)
952
971
  }
953
972
  ),
954
- /* @__PURE__ */ n(
955
- ve,
973
+ /* @__PURE__ */ t(
974
+ be,
956
975
  {
957
- color: c.color,
958
- onChange: (b) => h(f, b)
976
+ color: f.color,
977
+ onChange: (x) => h(p, x)
959
978
  }
960
979
  ),
961
- r.length > 1 && /* @__PURE__ */ n(
980
+ r.length > 1 && /* @__PURE__ */ t(
962
981
  "button",
963
982
  {
964
- onClick: () => i(f),
983
+ onClick: () => i(p),
965
984
  className: "text-xs text-neutral-400 hover:text-neutral-700 leading-none px-1",
966
- "aria-label": `remove stop ${f}`,
985
+ "aria-label": `remove stop ${p}`,
967
986
  children: "×"
968
987
  }
969
988
  )
970
- ] }, f)) })
989
+ ] }, p)) })
971
990
  ] });
972
- }, En = (e, o) => {
973
- const r = {};
974
- for (const t of e)
975
- switch (t.type) {
976
- case "float":
977
- r[t.name] = t.default ?? 0;
978
- break;
979
- case "vec2":
980
- r[t.name] = t.default ?? [0, 0];
981
- break;
982
- case "vec3":
983
- r[t.name] = t.default ?? [0, 0, 0];
984
- break;
985
- case "vec4":
986
- r[t.name] = t.default ?? [0, 0, 0, 0];
987
- break;
988
- }
989
- if (o)
990
- for (const t of e)
991
- t.name in o && (r[t.name] = o[t.name]);
992
- return r;
993
991
  };
994
- function Sn(e) {
995
- switch (e.type) {
992
+ function In(n) {
993
+ switch (n.type) {
996
994
  case "float":
997
- return e.special === "time" ? "float time" : "float";
995
+ return n.special === "time" ? "float time" : "float";
998
996
  case "vec2":
999
- return e.special === "mouse" ? "vec2 mouse" : e.special === "resolution" ? "vec2 resolution" : "vec2";
997
+ return n.special === "mouse" ? "vec2 mouse" : n.special === "resolution" ? "vec2 resolution" : "vec2";
1000
998
  case "vec3":
1001
- return e.color ? "vec3 color" : "vec3";
999
+ return n.color ? "vec3 color" : "vec3";
1002
1000
  case "vec4":
1003
- return e.color ? "vec4 color" : "vec4";
1001
+ return n.color ? "vec4 color" : "vec4";
1004
1002
  case "sampler2D":
1005
- return e.source === "gradient" ? "sampler2D gradient" : "sampler2D texture";
1003
+ return n.source === "gradient" ? "sampler2D gradient" : "sampler2D texture";
1006
1004
  }
1007
1005
  }
1008
- const Ae = ({
1009
- shader: e,
1010
- initialUniforms: o,
1006
+ const Me = ({
1007
+ shader: n,
1008
+ savedUniforms: o,
1011
1009
  handleUpdateUniform: r
1012
1010
  }) => {
1013
- const t = Q(() => ae(e), [e.source]), s = Q(
1014
- () => En(t, o),
1015
- [t]
1016
- ), l = R(s);
1017
- return D(() => {
1018
- l.current = { ...s }, r(l.current);
1019
- }, [s]), t.length === 0 ? /* @__PURE__ */ p("p", { className: "px-2 py-3 font-mono text-xs", children: [
1020
- "No uniforms found.",
1021
- " ",
1022
- /* @__PURE__ */ p("span", { children: [
1023
- "Add ",
1024
- /* @__PURE__ */ n("code", { className: "", children: "// [min, max, default]" }),
1025
- " comments to float uniforms."
1026
- ] })
1027
- ] }) : /* @__PURE__ */ n("div", { className: "rounded flex flex-col gap-1", children: t.map((a) => {
1028
- const u = `${a.name}-${a.type}`, i = (c) => {
1029
- l.current[a.name] = c, r(l.current);
1030
- }, m = (c) => {
1031
- c === null ? delete l.current[a.name] : l.current[a.name] = c, r(l.current);
1032
- };
1011
+ const s = re(() => ce(n), [n.source]);
1012
+ return s.filter((e) => !(e.type === "sampler2D" && e.source === "input")).length === 0 ? /* @__PURE__ */ t(se, {}) : /* @__PURE__ */ t("div", { className: "rounded flex flex-col gap-1", children: s.map((e) => {
1013
+ const a = `${e.name}-${e.type}`, l = (f) => r(e.name, f), u = (f) => {
1014
+ r(e.name, f);
1015
+ }, i = o[e.name], c = vn(e);
1033
1016
  let h = null;
1034
- switch (a.type) {
1017
+ switch (e.type) {
1035
1018
  case "float":
1036
- h = a.special === "time" ? /* @__PURE__ */ n(
1037
- bn,
1019
+ h = e.special === "time" ? /* @__PURE__ */ t(
1020
+ yn,
1038
1021
  {
1039
- field: a,
1040
- handleUpdateUniformField: i
1022
+ field: e,
1023
+ handleUpdateUniformField: l
1041
1024
  }
1042
- ) : /* @__PURE__ */ n(
1043
- mn,
1025
+ ) : /* @__PURE__ */ t(
1026
+ bn,
1044
1027
  {
1045
- field: a,
1046
- initialValue: s[a.name],
1047
- handleUpdateUniformField: i
1028
+ field: e,
1029
+ initialValue: i ?? c,
1030
+ handleUpdateUniformField: l
1048
1031
  }
1049
1032
  );
1050
1033
  break;
1051
1034
  case "vec2":
1052
- h = a.special === "mouse" ? /* @__PURE__ */ n(
1053
- _n,
1035
+ h = e.special === "mouse" ? /* @__PURE__ */ t(
1036
+ Un,
1054
1037
  {
1055
- field: a,
1056
- handleUpdateUniformField: i
1038
+ field: e,
1039
+ handleUpdateUniformField: l
1057
1040
  }
1058
- ) : a.special === "resolution" ? /* @__PURE__ */ n(
1059
- Cn,
1041
+ ) : e.special === "resolution" ? /* @__PURE__ */ t(
1042
+ An,
1060
1043
  {
1061
- field: a,
1062
- width: e.resolution.width,
1063
- height: e.resolution.height,
1064
- handleUpdateUniformField: i
1044
+ field: e,
1045
+ width: n.resolution.width,
1046
+ height: n.resolution.height,
1047
+ handleUpdateUniformField: l
1065
1048
  }
1066
- ) : /* @__PURE__ */ n(
1067
- pn,
1049
+ ) : /* @__PURE__ */ t(
1050
+ wn,
1068
1051
  {
1069
- field: a,
1070
- initialValue: s[a.name],
1071
- handleUpdateUniformField: i
1052
+ field: e,
1053
+ initialValue: i ?? c,
1054
+ handleUpdateUniformField: l
1072
1055
  }
1073
1056
  );
1074
1057
  break;
1075
1058
  case "vec3":
1076
- h = a.color ? /* @__PURE__ */ n(
1077
- hn,
1059
+ h = e.color ? /* @__PURE__ */ t(
1060
+ Nn,
1078
1061
  {
1079
- field: a,
1080
- initialValue: s[a.name],
1081
- handleUpdateUniformField: i
1062
+ field: e,
1063
+ initialValue: i ?? c,
1064
+ handleUpdateUniformField: l
1082
1065
  }
1083
- ) : /* @__PURE__ */ n(
1084
- gn,
1066
+ ) : /* @__PURE__ */ t(
1067
+ Cn,
1085
1068
  {
1086
- field: a,
1087
- initialValue: s[a.name],
1088
- handleUpdateUniformField: i
1069
+ field: e,
1070
+ initialValue: i ?? c,
1071
+ handleUpdateUniformField: l
1089
1072
  }
1090
1073
  );
1091
1074
  break;
1092
1075
  case "vec4":
1093
- h = a.color ? /* @__PURE__ */ n(
1094
- vn,
1076
+ h = e.color ? /* @__PURE__ */ t(
1077
+ Sn,
1095
1078
  {
1096
- field: a,
1097
- initialValue: s[a.name],
1098
- handleUpdateUniformField: i
1079
+ field: e,
1080
+ initialValue: i ?? c,
1081
+ handleUpdateUniformField: l
1099
1082
  }
1100
- ) : /* @__PURE__ */ n(
1101
- xn,
1083
+ ) : /* @__PURE__ */ t(
1084
+ En,
1102
1085
  {
1103
- field: a,
1104
- initialValue: s[a.name],
1105
- handleUpdateUniformField: i
1086
+ field: e,
1087
+ initialValue: i ?? c,
1088
+ handleUpdateUniformField: l
1106
1089
  }
1107
1090
  );
1108
1091
  break;
1109
1092
  case "sampler2D":
1110
- a.source === "texture" ? h = /* @__PURE__ */ n(
1111
- yn,
1093
+ e.source === "texture" ? h = /* @__PURE__ */ t(
1094
+ Tn,
1112
1095
  {
1113
- field: a,
1114
- initialValue: s[a.name],
1115
- handleUpdateUniformField: m
1096
+ field: e,
1097
+ value: i,
1098
+ handleUpdateUniformField: u
1116
1099
  }
1117
- ) : a.source === "gradient" && (h = /* @__PURE__ */ n(
1118
- Nn,
1100
+ ) : e.source === "gradient" && (h = /* @__PURE__ */ t(
1101
+ kn,
1119
1102
  {
1120
- field: a,
1121
- initialValue: s[a.name],
1122
- handleUpdateUniformField: i
1103
+ field: e,
1104
+ value: i,
1105
+ handleUpdateUniformField: l
1123
1106
  }
1124
1107
  ));
1125
1108
  break;
1126
1109
  }
1127
- return h === null ? null : /* @__PURE__ */ p("div", { className: "flex items-center gap-4 rounded-sm mb-1", children: [
1128
- /* @__PURE__ */ n(fn, { name: a.name, type: Sn(a) }),
1129
- /* @__PURE__ */ n("div", { className: "bg-neutral-100 p-1 rounded-md", children: h })
1130
- ] }, u);
1110
+ return h === null ? null : /* @__PURE__ */ m("div", { className: "flex items-center gap-4 rounded-sm mb-1", children: [
1111
+ /* @__PURE__ */ t(_n, { name: e.name, type: In(e) }),
1112
+ /* @__PURE__ */ t("div", { className: "bg-neutral-100 p-1 rounded-md", children: h })
1113
+ ] }, a);
1131
1114
  }) });
1132
- }, ce = ({
1133
- children: e,
1115
+ }, de = ({
1116
+ children: n,
1134
1117
  open: o,
1135
1118
  className: r,
1136
- handleOpenChange: t
1119
+ handleOpenChange: s
1137
1120
  }) => {
1138
- const s = R(null), [l, a] = y(o);
1139
- return D(() => {
1140
- a(!!o);
1141
- }, [o]), D(() => {
1142
- s.current !== null && (l ? s.current.showModal() : s.current.close()), t(l);
1143
- }, [l]), /* @__PURE__ */ n(
1121
+ const e = $(null), [a, l] = y(o);
1122
+ return k(() => {
1123
+ l(!!o);
1124
+ }, [o]), k(() => {
1125
+ e.current !== null && (a ? e.current.showModal() : e.current.close()), s(a);
1126
+ }, [a]), /* @__PURE__ */ t(
1144
1127
  "dialog",
1145
1128
  {
1146
- ref: s,
1147
- className: `top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-3xl h-5/6 border border-neutral-300 rounded-lg starting:opacity-0 opacity-100 transition-all transition-discrete ${l ? "visible" : "hidden"} ${r} nopan nodrag nowheel`,
1148
- children: e
1129
+ ref: e,
1130
+ className: `top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-3xl h-5/6 border border-neutral-300 rounded-lg starting:opacity-0 opacity-100 transition-all transition-discrete ${a ? "visible" : "hidden"} ${r} nopan nodrag nowheel`,
1131
+ children: o && n
1149
1132
  }
1150
1133
  );
1151
- }, Ne = "pnpm i @sequenza/lib", Te = ({
1152
- uniforms: e,
1134
+ }, Te = "pnpm i @sequenza/lib", $e = ({
1135
+ uniforms: n,
1153
1136
  patch: o,
1154
1137
  open: r,
1155
- onOpenChange: t
1138
+ onOpenChange: s
1156
1139
  }) => {
1157
- const s = dn(e, o), [l, a] = y("idle"), [u, i] = y("idle");
1158
- return /* @__PURE__ */ p(
1159
- ce,
1140
+ const e = xn(n, o), [a, l] = y("idle"), [u, i] = y("idle");
1141
+ return /* @__PURE__ */ m(
1142
+ de,
1160
1143
  {
1161
1144
  open: r,
1162
- handleOpenChange: t,
1145
+ handleOpenChange: s,
1163
1146
  className: "flex flex-col gap-4 p-6 overflow-y-auto",
1164
1147
  children: [
1165
- /* @__PURE__ */ p("div", { className: "flex items-center justify-between", children: [
1166
- /* @__PURE__ */ n("h2", { className: "text-sm font-medium text-neutral-800", children: "Integrate shader" }),
1167
- /* @__PURE__ */ n("button", { className: "button-base", onClick: () => t(!1), children: "Close" })
1148
+ /* @__PURE__ */ m("div", { className: "flex items-center justify-between", children: [
1149
+ /* @__PURE__ */ t("h2", { className: "text-sm font-medium text-neutral-800", children: "Integrate shader" }),
1150
+ /* @__PURE__ */ t("button", { className: "button-base", onClick: () => s(!1), children: "Close" })
1168
1151
  ] }),
1169
- /* @__PURE__ */ p("div", { className: "flex flex-col gap-1", children: [
1170
- /* @__PURE__ */ n("p", { className: "text-xs text-neutral-500", children: "Install" }),
1171
- /* @__PURE__ */ p("div", { className: "flex items-center gap-2 bg-neutral-50 rounded py-4 px-4", children: [
1172
- /* @__PURE__ */ n("code", { className: "text-xs text-neutral-700 w-full select-all", children: Ne }),
1173
- /* @__PURE__ */ n("button", { className: "button-base", onClick: () => {
1174
- navigator.clipboard.writeText(Ne), a("done"), setTimeout(() => a("idle"), 1800);
1175
- }, children: l === "done" ? "Copied!" : "Copy" })
1152
+ /* @__PURE__ */ m("div", { className: "flex flex-col gap-1", children: [
1153
+ /* @__PURE__ */ t("p", { className: "text-xs text-neutral-500", children: "Install" }),
1154
+ /* @__PURE__ */ m("div", { className: "flex items-center gap-2 bg-neutral-50 rounded py-4 px-4", children: [
1155
+ /* @__PURE__ */ t("code", { className: "text-xs text-neutral-700 w-full select-all", children: Te }),
1156
+ /* @__PURE__ */ t("button", { className: "button-base", onClick: () => {
1157
+ navigator.clipboard.writeText(Te), l("done"), setTimeout(() => l("idle"), 1800);
1158
+ }, children: a === "done" ? "Copied!" : "Copy" })
1176
1159
  ] })
1177
1160
  ] }),
1178
- /* @__PURE__ */ p("div", { className: "flex flex-col gap-1 flex-1 min-h-0", children: [
1179
- /* @__PURE__ */ n("p", { className: "text-xs text-neutral-500", children: "Component" }),
1180
- /* @__PURE__ */ p("div", { className: "relative flex-1 min-h-0 bg-neutral-50 rounded", children: [
1181
- /* @__PURE__ */ n(
1161
+ /* @__PURE__ */ m("div", { className: "flex flex-col gap-1 flex-1 min-h-0", children: [
1162
+ /* @__PURE__ */ t("p", { className: "text-xs text-neutral-500", children: "Component" }),
1163
+ /* @__PURE__ */ m("div", { className: "relative flex-1 min-h-0 bg-neutral-50 rounded", children: [
1164
+ /* @__PURE__ */ t(
1182
1165
  "button",
1183
1166
  {
1184
1167
  className: "absolute top-4 right-4 button-base",
1185
1168
  onClick: () => {
1186
- navigator.clipboard.writeText(s), i("done"), setTimeout(() => i("idle"), 1800);
1169
+ navigator.clipboard.writeText(e), i("done"), setTimeout(() => i("idle"), 1800);
1187
1170
  },
1188
1171
  children: u === "done" ? "Copied!" : "Copy"
1189
1172
  }
1190
1173
  ),
1191
- /* @__PURE__ */ n(
1174
+ /* @__PURE__ */ t(
1192
1175
  "textarea",
1193
1176
  {
1194
1177
  readOnly: !0,
1195
- value: s,
1178
+ value: e,
1196
1179
  className: "w-full h-full resize-none bg-transparent text-xs text-neutral-700 font-mono p-4 pr-12 outline-none"
1197
1180
  }
1198
1181
  )
@@ -1201,149 +1184,150 @@ const Ae = ({
1201
1184
  ]
1202
1185
  }
1203
1186
  );
1204
- }, kn = ({
1205
- open: e,
1187
+ }, Dn = ({
1188
+ open: n,
1206
1189
  onOpenChange: o,
1207
1190
  shader: r,
1208
- patch: t,
1209
- uniforms: s,
1191
+ patch: s,
1192
+ uniforms: e,
1193
+ savedUniforms: a,
1210
1194
  nodeId: l,
1211
- handleUpdateUniforms: a,
1212
- handleUpdateNode: u
1195
+ handleFieldUpdate: u,
1196
+ handleUpdateNode: i
1213
1197
  }) => {
1214
- const i = R(null), m = R(null), [h, c] = y(!1), [f, b] = y(null), C = (g, k) => {
1215
- const B = g.split(/\n(?=\d+: )/), _ = {};
1216
- for (const j of B) {
1217
- const X = j.match(/^(\d+): ([\s\S]*)/);
1218
- X && (_[parseInt(X[1], 10)] = X[2].trimEnd());
1198
+ const c = $(null), h = $(null), [f, p] = y(!1), [x, w] = y(null), E = (S, I) => {
1199
+ const H = S.split(/\n(?=\d+: )/), X = {};
1200
+ for (const z of H) {
1201
+ const G = z.match(/^(\d+): ([\s\S]*)/);
1202
+ G && (X[parseInt(G[1], 10)] = G[2].trimEnd());
1219
1203
  }
1220
- const P = Math.max(1, k - 3), Z = k + 3, G = [];
1221
- for (let j = P; j <= Z; j++)
1222
- _[j] !== void 0 && G.push(`${j}: ${_[j]}`);
1223
- return G.join(`
1204
+ const K = Math.max(1, I - 3), N = I + 3, D = [];
1205
+ for (let z = K; z <= N; z++)
1206
+ X[z] !== void 0 && D.push(`${z}: ${X[z]}`);
1207
+ return D.join(`
1224
1208
  `);
1225
- }, [N, F] = y({ w: 1, h: 1 }), { width: v, height: E } = r.resolution;
1226
- D(() => {
1227
- const g = m.current;
1228
- if (!g) return;
1229
- const k = new ResizeObserver(([B]) => {
1230
- const { width: _, height: P } = B.contentRect;
1231
- F({ w: _, h: P });
1209
+ }, [T, v] = y({ w: 1, h: 1 }), { width: C, height: A } = r.resolution;
1210
+ k(() => {
1211
+ const S = h.current;
1212
+ if (!S) return;
1213
+ const I = new ResizeObserver(([H]) => {
1214
+ const { width: X, height: K } = H.contentRect;
1215
+ v({ w: X, h: K });
1232
1216
  });
1233
- return k.observe(g), () => k.disconnect();
1217
+ return I.observe(S), () => I.disconnect();
1234
1218
  }, []);
1235
1219
  const U = () => {
1236
- i.current?.toBlob((g) => {
1237
- g && navigator.clipboard.write([new ClipboardItem({ "image/png": g })]);
1220
+ c.current?.toBlob((S) => {
1221
+ S && navigator.clipboard.write([new ClipboardItem({ "image/png": S })]);
1238
1222
  });
1239
- }, S = () => {
1240
- const g = i.current?.toDataURL("image/png");
1241
- if (!g) return;
1242
- const k = document.createElement("a");
1243
- k.href = g, k.download = `${r.name}.png`, k.click();
1223
+ }, _ = () => {
1224
+ const S = c.current?.toDataURL("image/png");
1225
+ if (!S) return;
1226
+ const I = document.createElement("a");
1227
+ I.href = S, I.download = `${r.name}.png`, I.click();
1244
1228
  };
1245
- return /* @__PURE__ */ p(
1246
- ce,
1229
+ return /* @__PURE__ */ m(
1230
+ de,
1247
1231
  {
1248
- open: e,
1232
+ open: n,
1249
1233
  handleOpenChange: o,
1250
1234
  className: "flex flex-col w-full h-full",
1251
1235
  children: [
1252
- /* @__PURE__ */ p("div", { className: "flex items-center justify-between px-6 py-4 shrink-0", children: [
1253
- /* @__PURE__ */ n("h2", { className: "text-sm font-medium text-neutral-800", children: r.name }),
1254
- /* @__PURE__ */ n("button", { className: "button-base", onClick: () => o(!1), children: "Close" })
1236
+ /* @__PURE__ */ m("div", { className: "flex items-center justify-between px-6 py-4 shrink-0", children: [
1237
+ /* @__PURE__ */ t("h2", { className: "text-sm font-medium text-neutral-800", children: r.name }),
1238
+ /* @__PURE__ */ t("button", { className: "button-base", onClick: () => o(!1), children: "Close" })
1255
1239
  ] }),
1256
- /* @__PURE__ */ p("div", { className: "flex gap-16 px-6 pb-6 flex-1 min-h-0 items-center", children: [
1257
- /* @__PURE__ */ n("div", { className: "flex flex-col gap-8", children: /* @__PURE__ */ n("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ n(
1258
- Ae,
1240
+ /* @__PURE__ */ m("div", { className: "flex gap-16 px-6 pb-6 flex-1 min-h-0 items-center", children: [
1241
+ /* @__PURE__ */ t("div", { className: "flex flex-col gap-8", children: /* @__PURE__ */ t("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ t(
1242
+ Me,
1259
1243
  {
1260
1244
  shader: r,
1261
- initialUniforms: s.current[r.id],
1262
- handleUpdateUniform: (g) => a(r.id, g)
1245
+ savedUniforms: a,
1246
+ handleUpdateUniform: u
1263
1247
  }
1264
1248
  ) }) }),
1265
- /* @__PURE__ */ p("div", { className: "h-full w-full flex flex-col gap-4 ", children: [
1266
- /* @__PURE__ */ n(
1249
+ /* @__PURE__ */ m("div", { className: "h-full w-full flex flex-col gap-4 ", children: [
1250
+ /* @__PURE__ */ t(
1267
1251
  "div",
1268
1252
  {
1269
- ref: m,
1253
+ ref: h,
1270
1254
  className: "flex bg-neutral-50 rounded w-4/5 items-center justify-center h-full",
1271
- children: /* @__PURE__ */ n(
1255
+ children: /* @__PURE__ */ t(
1272
1256
  Re,
1273
1257
  {
1274
- ref: i,
1258
+ ref: c,
1275
1259
  animate: !0,
1276
- width: v,
1277
- height: E,
1278
- patch: t,
1279
- uniforms: s,
1280
- className: v / E > N.w / N.h ? "w-full" : "h-full",
1281
- onError: (g) => b(g)
1260
+ width: C,
1261
+ height: A,
1262
+ patch: s,
1263
+ uniforms: e,
1264
+ className: C / A > T.w / T.h ? "w-full" : "h-full",
1265
+ onError: (S) => w(S)
1282
1266
  }
1283
1267
  )
1284
1268
  }
1285
1269
  ),
1286
- /* @__PURE__ */ p("div", { className: "flex flex-col gap-2 ", children: [
1287
- /* @__PURE__ */ p("div", { className: "flex gap-1 bg-neutral-100 p-1 rounded-md w-min", children: [
1288
- /* @__PURE__ */ n(
1289
- H,
1270
+ /* @__PURE__ */ m("div", { className: "flex flex-col gap-2 ", children: [
1271
+ /* @__PURE__ */ m("div", { className: "flex gap-1 bg-neutral-100 p-1 rounded-md w-min", children: [
1272
+ /* @__PURE__ */ t(
1273
+ V,
1290
1274
  {
1291
1275
  label: "w",
1292
- value: v,
1276
+ value: C,
1293
1277
  min: 1,
1294
1278
  step: 1,
1295
- onChange: (g) => u(l, (k) => ({
1296
- ...k,
1297
- shader: { ...k.shader, resolution: { width: g, height: E } }
1279
+ onChange: (S) => i(l, (I) => ({
1280
+ ...I,
1281
+ shader: { ...I.shader, resolution: { width: S, height: A } }
1298
1282
  }))
1299
1283
  }
1300
1284
  ),
1301
- /* @__PURE__ */ n(
1302
- H,
1285
+ /* @__PURE__ */ t(
1286
+ V,
1303
1287
  {
1304
1288
  label: "h",
1305
- value: E,
1289
+ value: A,
1306
1290
  min: 1,
1307
1291
  step: 1,
1308
- onChange: (g) => u(l, (k) => ({
1309
- ...k,
1310
- shader: { ...k.shader, resolution: { width: v, height: g } }
1292
+ onChange: (S) => i(l, (I) => ({
1293
+ ...I,
1294
+ shader: { ...I.shader, resolution: { width: C, height: S } }
1311
1295
  }))
1312
1296
  }
1313
1297
  )
1314
1298
  ] }),
1315
- /* @__PURE__ */ p("div", { className: "flex gap-1 h-min w-min", children: [
1316
- /* @__PURE__ */ n(
1299
+ /* @__PURE__ */ m("div", { className: "flex gap-1 h-min w-min", children: [
1300
+ /* @__PURE__ */ t(
1317
1301
  "button",
1318
1302
  {
1319
1303
  className: "button-base",
1320
- onClick: () => c(!0),
1304
+ onClick: () => p(!0),
1321
1305
  children: "Export"
1322
1306
  }
1323
1307
  ),
1324
- /* @__PURE__ */ n(
1325
- Te,
1308
+ /* @__PURE__ */ t(
1309
+ $e,
1326
1310
  {
1327
- uniforms: s.current,
1328
- patch: t,
1329
- open: h,
1330
- onOpenChange: c
1311
+ uniforms: e.current,
1312
+ patch: s,
1313
+ open: f,
1314
+ onOpenChange: p
1331
1315
  }
1332
1316
  ),
1333
- /* @__PURE__ */ n("button", { className: "button-base", onClick: U, children: "Copy" }),
1334
- /* @__PURE__ */ n("button", { className: "button-base", onClick: S, children: "Save" })
1317
+ /* @__PURE__ */ t("button", { className: "button-base", onClick: U, children: "Copy" }),
1318
+ /* @__PURE__ */ t("button", { className: "button-base", onClick: _, children: "Save" })
1335
1319
  ] })
1336
1320
  ] })
1337
1321
  ] })
1338
1322
  ] }),
1339
- f && /* @__PURE__ */ p("div", { className: "flex flex-col gap-2 mx-6 mb-6 p-2 bg-white border-2 border-red-100 rounded-md", children: [
1340
- /* @__PURE__ */ n("p", { className: "text-white w-min text-nowrap bg-red-700 px-2 py-1 rounded text-xs", children: f.shaderName }),
1341
- /* @__PURE__ */ n("pre", { className: "text-xs text-red-600 font-mono whitespace-pre-wrap break-all", children: C(f.message, f.line) }),
1342
- /* @__PURE__ */ n(
1323
+ x && /* @__PURE__ */ m("div", { className: "flex flex-col gap-2 mx-6 mb-6 p-2 bg-white border-2 border-red-100 rounded-md", children: [
1324
+ /* @__PURE__ */ t("p", { className: "text-white w-min text-nowrap bg-red-700 px-2 py-1 rounded text-xs", children: x.shaderName }),
1325
+ /* @__PURE__ */ t("pre", { className: "text-xs text-red-600 font-mono whitespace-pre-wrap break-all", children: E(x.message, x.line) }),
1326
+ /* @__PURE__ */ t(
1343
1327
  "button",
1344
1328
  {
1345
1329
  className: "self-start text-xs px-2 py-1 rounded border border-red-200 bg-white text-red-600 hover:bg-red-50 cursor-pointer",
1346
- onClick: () => navigator.clipboard.writeText(f.message),
1330
+ onClick: () => navigator.clipboard.writeText(x.message),
1347
1331
  children: "Copy error"
1348
1332
  }
1349
1333
  )
@@ -1351,40 +1335,45 @@ const Ae = ({
1351
1335
  ]
1352
1336
  }
1353
1337
  );
1354
- }, Rn = ({ data: e, selected: o, id: r }) => {
1338
+ }, Rn = ({ data: n, selected: o, id: r }) => {
1355
1339
  const {
1356
- patches: t,
1357
- uniforms: s,
1358
- handleUpdateUniforms: l,
1359
- handleUpdateNode: a,
1340
+ patches: s,
1341
+ uniforms: e,
1342
+ handleUpdateUniforms: a,
1343
+ handleUpdateNode: l,
1360
1344
  showStats: u,
1361
1345
  setOpenExportNodeId: i,
1362
- openPreviewNodeId: m,
1346
+ openPreviewNodeId: c,
1363
1347
  setOpenPreviewNodeId: h
1364
- } = ie(oe);
1365
- if (!t || t[e.shader.id] === void 0) return null;
1366
- const { width: c, height: f } = e.shader.resolution, [b, C] = y(null), N = R(null), [F, v] = y("idle"), [E, U] = y("idle"), S = () => {
1367
- N.current?.toBlob((_) => {
1368
- _ && navigator.clipboard.write([new ClipboardItem({ "image/png": _ })]);
1369
- }), v("done"), setTimeout(() => v("idle"), 1800);
1370
- }, g = () => {
1371
- const _ = N.current?.toDataURL("image/png");
1372
- if (!_) return;
1373
- const P = document.createElement("a");
1374
- P.href = _, P.download = `${e.shader.name}.png`, P.click();
1375
- }, k = Q(() => ae(e.shader).filter((_) => _.type === "sampler2D" && _.source === "input").map((_) => _.name), [e.shader]), B = (_, P) => {
1376
- const Z = _.split(/\n(?=\d+: )/), G = {};
1377
- for (const q of Z) {
1378
- const ne = q.match(/^(\d+): ([\s\S]*)/);
1379
- ne && (G[parseInt(ne[1], 10)] = ne[2].trimEnd());
1348
+ } = ue(ae), [f, p] = y(
1349
+ () => e.current[n.shader.id] ?? {}
1350
+ ), x = (N, D) => {
1351
+ a(n.shader.id, (z) => ({
1352
+ ...z,
1353
+ [N]: D
1354
+ }));
1355
+ }, { width: w, height: E } = n.shader.resolution, [T, v] = y(null), C = $(null), [A, U] = y("idle"), [_, S] = y("idle"), I = () => {
1356
+ C.current?.toBlob((N) => {
1357
+ N && navigator.clipboard.write([new ClipboardItem({ "image/png": N })]);
1358
+ }), U("done"), setTimeout(() => U("idle"), 1800);
1359
+ }, H = () => {
1360
+ const N = C.current?.toDataURL("image/png");
1361
+ if (!N) return;
1362
+ const D = document.createElement("a");
1363
+ D.href = N, D.download = `${n.shader.name}.png`, D.click();
1364
+ }, X = re(() => ce(n.shader).filter((N) => N.type === "sampler2D" && N.source === "input").map((N) => N.name), [n.shader]), K = (N, D) => {
1365
+ const z = N.split(/\n(?=\d+: )/), G = {};
1366
+ for (const W of z) {
1367
+ const Z = W.match(/^(\d+): ([\s\S]*)/);
1368
+ Z && (G[parseInt(Z[1], 10)] = Z[2].trimEnd());
1380
1369
  }
1381
- const j = Math.max(1, P - 3), X = P + 3, ee = [];
1382
- for (let q = j; q <= X; q++)
1383
- G[q] !== void 0 && ee.push(`${q}: ${G[q]}`);
1384
- return ee.join(`
1370
+ const te = Math.max(1, D - 3), fe = D + 3, le = [];
1371
+ for (let W = te; W <= fe; W++)
1372
+ G[W] !== void 0 && le.push(`${W}: ${G[W]}`);
1373
+ return le.join(`
1385
1374
  `);
1386
1375
  };
1387
- return /* @__PURE__ */ p(
1376
+ return !s || s[n.shader.id] === void 0 ? null : /* @__PURE__ */ m(
1388
1377
  "div",
1389
1378
  {
1390
1379
  className: `
@@ -1392,120 +1381,125 @@ const Ae = ({
1392
1381
  ${o ? "outline-4" : "outline-0"}
1393
1382
  `,
1394
1383
  children: [
1395
- /* @__PURE__ */ n("p", { className: "text-sm w-min py-1 px-2 bg-neutral-100 rounded-lg text-neutral-500 text-nowrap", children: e.shader.name }),
1396
- u && /* @__PURE__ */ p(le, { children: [
1397
- /* @__PURE__ */ p("p", { className: "text-xs text-neutral-500 absolute -top-6", children: [
1384
+ /* @__PURE__ */ t("p", { className: "text-sm w-min py-1 px-2 bg-neutral-100 rounded-lg text-neutral-500 text-nowrap", children: n.shader.name }),
1385
+ u && /* @__PURE__ */ m(se, { children: [
1386
+ /* @__PURE__ */ m("p", { className: "text-xs text-neutral-500 absolute -top-6", children: [
1398
1387
  "ID: ",
1399
- e.shader.id
1388
+ n.shader.id
1400
1389
  ] }),
1401
- /* @__PURE__ */ n("p", { className: "text-xs text-neutral-500 absolute -top-10", children: e.shader.name })
1390
+ /* @__PURE__ */ t("p", { className: "text-xs text-neutral-500 absolute -top-10", children: n.shader.name })
1402
1391
  ] }),
1403
- k.map((_) => /* @__PURE__ */ n(
1404
- Ce,
1392
+ X.map((N, D) => /* @__PURE__ */ t(
1393
+ Ue,
1405
1394
  {
1406
- id: _,
1395
+ id: N,
1407
1396
  type: "target",
1408
- position: se.Top
1397
+ position: ne.Top,
1398
+ count: {
1399
+ total: X.length,
1400
+ index: D
1401
+ }
1409
1402
  },
1410
- _
1403
+ N
1411
1404
  )),
1412
- /* @__PURE__ */ p("div", { className: "flex gap-8", children: [
1413
- /* @__PURE__ */ n("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ n(
1414
- Ae,
1405
+ /* @__PURE__ */ m("div", { className: "flex gap-8", children: [
1406
+ /* @__PURE__ */ t(
1407
+ Me,
1415
1408
  {
1416
- shader: e.shader,
1417
- initialUniforms: s.current[e.shader.id],
1418
- handleUpdateUniform: (_) => {
1419
- l(e.shader.id, _);
1420
- }
1409
+ shader: n.shader,
1410
+ savedUniforms: f,
1411
+ handleUpdateUniform: x
1421
1412
  }
1422
- ) }),
1423
- /* @__PURE__ */ p("div", { className: "flex flex-col justify-center items-start gap-4 ", children: [
1424
- /* @__PURE__ */ p("div", { className: "flex flex-col gap-2", children: [
1425
- /* @__PURE__ */ p("div", { className: "relative max-w-96 group", children: [
1426
- /* @__PURE__ */ p("div", { className: "flex absolute top-2 right-2 gap-2", children: [
1427
- /* @__PURE__ */ n(
1413
+ ),
1414
+ /* @__PURE__ */ m("div", { className: "flex flex-col justify-center items-start gap-4 ", children: [
1415
+ /* @__PURE__ */ m("div", { className: "flex flex-col gap-2", children: [
1416
+ /* @__PURE__ */ m("div", { className: "relative max-w-96 group", children: [
1417
+ /* @__PURE__ */ m("div", { className: "flex absolute top-2 right-2 gap-2", children: [
1418
+ /* @__PURE__ */ t(
1428
1419
  "button",
1429
1420
  {
1430
1421
  className: "button-base group-hover:opacity-100 opacity-0",
1431
- onClick: () => h(r),
1422
+ onClick: () => {
1423
+ h(r), p(e.current[n.shader.id] ?? {});
1424
+ },
1432
1425
  children: "Expand"
1433
1426
  }
1434
1427
  ),
1435
- /* @__PURE__ */ n(
1436
- kn,
1428
+ /* @__PURE__ */ t(
1429
+ Dn,
1437
1430
  {
1438
- open: m === r,
1439
- onOpenChange: (_) => {
1440
- h(_ ? r : null);
1431
+ open: c === r,
1432
+ onOpenChange: (N) => {
1433
+ p(e.current[n.shader.id] ?? {}), h(N ? r : null);
1441
1434
  },
1442
- shader: e.shader,
1443
- patch: t[e.shader.id],
1444
- uniforms: s,
1435
+ shader: n.shader,
1436
+ patch: s[n.shader.id],
1437
+ uniforms: e,
1438
+ savedUniforms: f,
1445
1439
  nodeId: r,
1446
- handleUpdateUniforms: l,
1447
- handleUpdateNode: a
1440
+ handleFieldUpdate: x,
1441
+ handleUpdateNode: l
1448
1442
  }
1449
1443
  ),
1450
- /* @__PURE__ */ n(
1444
+ /* @__PURE__ */ t(
1451
1445
  "button",
1452
1446
  {
1453
- className: `button-base ${e.paused ? "opacity-100" : "group-hover:opacity-100 opacity-0"}`,
1447
+ className: `button-base ${n.paused ? "opacity-100" : "group-hover:opacity-100 opacity-0"}`,
1454
1448
  onClick: () => {
1455
- a(r, (_) => ({ ..._, paused: !_.paused }));
1449
+ l(r, (N) => ({ ...N, paused: !N.paused }));
1456
1450
  },
1457
- children: e.paused ? "Resume" : "Pause"
1451
+ children: n.paused ? "Resume" : "Pause"
1458
1452
  }
1459
1453
  )
1460
1454
  ] }),
1461
- /* @__PURE__ */ n(
1455
+ /* @__PURE__ */ t(
1462
1456
  Re,
1463
1457
  {
1464
- ref: N,
1465
- animate: !e.paused,
1466
- width: c,
1467
- height: f,
1468
- patch: t[e.shader.id],
1469
- uniforms: s,
1458
+ ref: C,
1459
+ animate: !n.paused,
1460
+ width: w,
1461
+ height: E,
1462
+ patch: s[n.shader.id],
1463
+ uniforms: e,
1470
1464
  className: "w-full h-auto",
1471
- style: { maxWidth: `${c / f * 24}rem` },
1472
- onError: (_) => {
1473
- C(_);
1465
+ style: { maxWidth: `${w / E * 24}rem` },
1466
+ onError: (N) => {
1467
+ v(N);
1474
1468
  }
1475
1469
  }
1476
1470
  )
1477
1471
  ] }),
1478
- /* @__PURE__ */ p("div", { className: "flex gap-1 bg-neutral-100 rounded-md p-1 w-min", children: [
1479
- /* @__PURE__ */ n(
1480
- H,
1472
+ /* @__PURE__ */ m("div", { className: "flex gap-1 bg-neutral-100 rounded-md p-1 w-min", children: [
1473
+ /* @__PURE__ */ t(
1474
+ V,
1481
1475
  {
1482
1476
  label: "w",
1483
- value: c,
1477
+ value: w,
1484
1478
  min: 1,
1485
1479
  step: 1,
1486
- onChange: (_) => a(r, (P) => ({
1487
- ...P,
1488
- shader: { ...P.shader, resolution: { width: _, height: f } }
1480
+ onChange: (N) => l(r, (D) => ({
1481
+ ...D,
1482
+ shader: { ...D.shader, resolution: { width: N, height: E } }
1489
1483
  }))
1490
1484
  }
1491
1485
  ),
1492
- /* @__PURE__ */ n(
1493
- H,
1486
+ /* @__PURE__ */ t(
1487
+ V,
1494
1488
  {
1495
1489
  label: "h",
1496
- value: f,
1490
+ value: E,
1497
1491
  min: 1,
1498
1492
  step: 1,
1499
- onChange: (_) => a(r, (P) => ({
1500
- ...P,
1501
- shader: { ...P.shader, resolution: { width: c, height: _ } }
1493
+ onChange: (N) => l(r, (D) => ({
1494
+ ...D,
1495
+ shader: { ...D.shader, resolution: { width: w, height: N } }
1502
1496
  }))
1503
1497
  }
1504
1498
  )
1505
1499
  ] })
1506
1500
  ] }),
1507
- /* @__PURE__ */ p("div", { className: "flex gap-1", children: [
1508
- /* @__PURE__ */ n(
1501
+ /* @__PURE__ */ m("div", { className: "flex gap-1", children: [
1502
+ /* @__PURE__ */ t(
1509
1503
  "button",
1510
1504
  {
1511
1505
  className: "button-base",
@@ -1513,96 +1507,96 @@ const Ae = ({
1513
1507
  children: "Export"
1514
1508
  }
1515
1509
  ),
1516
- /* @__PURE__ */ n("button", { className: "button-base", onClick: S, children: F === "done" ? "Copied!" : "Copy" }),
1517
- /* @__PURE__ */ n("button", { className: "button-base", onClick: g, children: "Save" })
1510
+ /* @__PURE__ */ t("button", { className: "button-base", onClick: I, children: A === "done" ? "Copied!" : "Copy" }),
1511
+ /* @__PURE__ */ t("button", { className: "button-base", onClick: H, children: "Save" })
1518
1512
  ] })
1519
1513
  ] })
1520
1514
  ] }),
1521
- b && /* @__PURE__ */ p("div", { className: "flex flex-col gap-2 p-2 bg-white border-2 border-red-100 rounded-md relative", children: [
1522
- /* @__PURE__ */ n("p", { className: "text-white w-min text-nowrap bg-red-700 px-2 py-1 rounded text-xs", children: b.shaderName }),
1523
- /* @__PURE__ */ n("pre", { className: "text-xs text-red-600 font-mono whitespace-pre-wrap break-all", children: B(b.message, b.line) }),
1524
- /* @__PURE__ */ n(
1515
+ T && /* @__PURE__ */ m("div", { className: "flex flex-col gap-2 p-2 bg-white border-2 border-red-100 rounded-md relative", children: [
1516
+ /* @__PURE__ */ t("p", { className: "text-white w-min text-nowrap bg-red-700 px-2 py-1 rounded text-xs", children: T.shaderName }),
1517
+ /* @__PURE__ */ t("pre", { className: "text-xs text-red-600 font-mono whitespace-pre-wrap break-all", children: K(T.message, T.line) }),
1518
+ /* @__PURE__ */ t(
1525
1519
  "button",
1526
1520
  {
1527
1521
  className: "self-start text-xs px-2 py-1 rounded border border-red-200 bg-white text-red-600 hover:bg-red-50 cursor-pointer",
1528
1522
  onClick: () => {
1529
- navigator.clipboard.writeText(b.message), U("done"), setTimeout(() => U("idle"), 1800);
1523
+ navigator.clipboard.writeText(T.message), S("done"), setTimeout(() => S("idle"), 1800);
1530
1524
  },
1531
- children: E === "done" ? "Copied!" : "Copy error"
1525
+ children: _ === "done" ? "Copied!" : "Copy error"
1532
1526
  }
1533
1527
  )
1534
1528
  ] }),
1535
- /* @__PURE__ */ n(Ce, { id: "out", type: "source", position: se.Bottom })
1529
+ /* @__PURE__ */ t(Ue, { id: "out", type: "source", position: ne.Bottom })
1536
1530
  ]
1537
1531
  }
1538
1532
  );
1539
1533
  };
1540
- function Un({
1541
- sourceX: e,
1534
+ function Fn({
1535
+ sourceX: n,
1542
1536
  sourceY: o,
1543
1537
  targetX: r,
1544
- targetY: t,
1545
- sourcePosition: s,
1546
- targetPosition: l,
1547
- style: a = {},
1538
+ targetY: s,
1539
+ sourcePosition: e,
1540
+ targetPosition: a,
1541
+ style: l = {},
1548
1542
  markerEnd: u,
1549
1543
  id: i
1550
1544
  }) {
1551
- const [m, h, c] = Ee({
1552
- sourceX: e,
1545
+ const [c, h, f] = ke({
1546
+ sourceX: n,
1553
1547
  sourceY: o,
1554
- sourcePosition: s,
1548
+ sourcePosition: e,
1555
1549
  targetX: r,
1556
- targetY: t,
1557
- targetPosition: l
1558
- }), { shaders: f, handleInsertShader: b } = ie(oe), [C, N] = y(!1), F = () => {
1559
- console.log("d"), N(!0);
1550
+ targetY: s,
1551
+ targetPosition: a
1552
+ }), { shaders: p, handleInsertShader: x } = ue(ae), [w, E] = y(!1), T = () => {
1553
+ console.log("d"), E(!0);
1560
1554
  };
1561
- return /* @__PURE__ */ p(le, { children: [
1562
- /* @__PURE__ */ n(Ye, { path: m, markerEnd: u, style: a }),
1563
- /* @__PURE__ */ n(Ke, { children: /* @__PURE__ */ p(
1555
+ return /* @__PURE__ */ m(se, { children: [
1556
+ /* @__PURE__ */ t(nn, { path: c, markerEnd: u, style: l }),
1557
+ /* @__PURE__ */ t(tn, { children: /* @__PURE__ */ m(
1564
1558
  "div",
1565
1559
  {
1566
1560
  className: "absolute -translate-1/2 origin-center pointer-events-auto",
1567
1561
  style: {
1568
- transform: `translate(${h}px,${c}px)`
1562
+ transform: `translate(${h}px,${f}px)`
1569
1563
  },
1570
1564
  children: [
1571
- /* @__PURE__ */ n(
1565
+ /* @__PURE__ */ t(
1572
1566
  "button",
1573
1567
  {
1574
1568
  className: "w-6 h-6 bg-neutral-200 rounded-full active:bg-neutral-200 z-10 flex items-center justify-center",
1575
- onClick: () => F(),
1569
+ onClick: () => T(),
1576
1570
  children: "+"
1577
1571
  }
1578
1572
  ),
1579
- /* @__PURE__ */ n(
1580
- ce,
1573
+ /* @__PURE__ */ t(
1574
+ de,
1581
1575
  {
1582
- open: C,
1576
+ open: w,
1583
1577
  handleOpenChange: (v) => {
1584
- N(v);
1578
+ E(v);
1585
1579
  },
1586
- children: /* @__PURE__ */ p("div", { className: "w-full h-full flex flex-col p-4", children: [
1587
- /* @__PURE__ */ p("div", { className: "w-full flex justify-between", children: [
1588
- /* @__PURE__ */ n("p", { children: "Add a Shader" }),
1589
- /* @__PURE__ */ n(
1580
+ children: /* @__PURE__ */ m("div", { className: "w-full h-full flex flex-col p-4", children: [
1581
+ /* @__PURE__ */ m("div", { className: "w-full flex justify-between", children: [
1582
+ /* @__PURE__ */ t("p", { children: "Add a Shader" }),
1583
+ /* @__PURE__ */ t(
1590
1584
  "button",
1591
1585
  {
1592
1586
  className: "button-base",
1593
1587
  onClick: () => {
1594
- N(!1);
1588
+ E(!1);
1595
1589
  },
1596
1590
  children: "Close"
1597
1591
  }
1598
1592
  )
1599
1593
  ] }),
1600
- /* @__PURE__ */ n("div", { className: "w-full flex flex-col", children: f.map((v) => /* @__PURE__ */ n(
1594
+ /* @__PURE__ */ t("div", { className: "w-full flex flex-col", children: p.map((v) => /* @__PURE__ */ t(
1601
1595
  "button",
1602
1596
  {
1603
1597
  className: "text-xs flex justify-start p-1 rounded-sm hover:bg-neutral-100 cursor-pointer text-neutral-500",
1604
1598
  onClick: () => {
1605
- b(v, i);
1599
+ x(v, i);
1606
1600
  },
1607
1601
  children: v.id
1608
1602
  },
@@ -1616,340 +1610,366 @@ function Un({
1616
1610
  ) })
1617
1611
  ] });
1618
1612
  }
1619
- function In({
1620
- fromX: e,
1613
+ function Pn({
1614
+ fromX: n,
1621
1615
  fromY: o,
1622
1616
  toX: r,
1623
- toY: t,
1624
- fromPosition: s,
1625
- toPosition: l,
1626
- toHandle: a
1617
+ toY: s,
1618
+ fromPosition: e,
1619
+ toPosition: a,
1620
+ toHandle: l
1627
1621
  }) {
1628
- const [u] = Ee({
1629
- sourceX: e,
1622
+ const [u] = ke({
1623
+ sourceX: n,
1630
1624
  sourceY: o,
1631
- sourcePosition: s,
1625
+ sourcePosition: e,
1632
1626
  targetX: r,
1633
- targetY: t,
1634
- targetPosition: l
1635
- }), i = a ? "connect" : "new", m = t - 26, h = 6, c = 16, f = i.length * 6 + h * 2;
1636
- return /* @__PURE__ */ p("g", { children: [
1637
- /* @__PURE__ */ n("path", { fill: "none", stroke: "#b1b1b7", strokeWidth: 1.5, d: u }),
1638
- /* @__PURE__ */ n(
1627
+ targetY: s,
1628
+ targetPosition: a
1629
+ }), i = l ? "connect" : "new", c = s - 26, h = 6, f = 16, p = i.length * 6 + h * 2;
1630
+ return /* @__PURE__ */ m("g", { children: [
1631
+ /* @__PURE__ */ t("path", { fill: "none", stroke: "#b1b1b7", strokeWidth: 1.5, d: u }),
1632
+ /* @__PURE__ */ t(
1639
1633
  "rect",
1640
1634
  {
1641
- x: r - f / 2,
1642
- y: m - c / 2,
1643
- width: f,
1644
- height: c,
1635
+ x: r - p / 2,
1636
+ y: c - f / 2,
1637
+ width: p,
1638
+ height: f,
1645
1639
  rx: 4,
1646
- fill: a ? "#404040" : "#e5e5e5",
1640
+ fill: l ? "#404040" : "#e5e5e5",
1647
1641
  style: { pointerEvents: "none" }
1648
1642
  }
1649
1643
  ),
1650
- /* @__PURE__ */ n(
1644
+ /* @__PURE__ */ t(
1651
1645
  "text",
1652
1646
  {
1653
1647
  x: r,
1654
- y: m,
1648
+ y: c,
1655
1649
  textAnchor: "middle",
1656
1650
  dominantBaseline: "central",
1657
1651
  fontSize: 10,
1658
1652
  fontFamily: "monospace",
1659
- fill: a ? "#ffffff" : "#525252",
1653
+ fill: l ? "#ffffff" : "#525252",
1660
1654
  style: { userSelect: "none", pointerEvents: "none" },
1661
1655
  children: i
1662
1656
  }
1663
1657
  ),
1664
- /* @__PURE__ */ n("foreignObject", { x: r - 8, y: t - 8, width: 16, height: 16, style: { overflow: "visible" }, children: /* @__PURE__ */ n("div", { className: "w-4 h-4 rounded-full bg-neutral-400" }) })
1658
+ /* @__PURE__ */ t("foreignObject", { x: r - 8, y: s - 8, width: 16, height: 16, style: { overflow: "visible" }, children: /* @__PURE__ */ t("div", { className: "w-4 h-4 rounded-full bg-neutral-400" }) })
1665
1659
  ] });
1666
1660
  }
1667
- function he(e, o, r) {
1668
- const t = new Map(e.map((l) => [l.id, l])), s = [r];
1669
- for (; s.length > 0; ) {
1670
- const l = s.shift(), a = t.get(l);
1671
- if (!a || a.type !== "shader") continue;
1672
- const u = a, { width: i, height: m } = u.data.shader.resolution, h = Se(
1673
- a,
1674
- [...t.values()],
1661
+ function _e(n, o, r) {
1662
+ const s = new Map(n.map((a) => [a.id, a])), e = [r];
1663
+ for (; e.length > 0; ) {
1664
+ const a = e.shift(), l = s.get(a);
1665
+ if (!l || l.type !== "shader") continue;
1666
+ const u = l, { width: i, height: c } = u.data.shader.resolution, h = Ie(
1667
+ l,
1668
+ [...s.values()],
1675
1669
  o
1676
1670
  );
1677
- for (const c of h) {
1678
- const f = {
1679
- ...c,
1671
+ for (const f of h) {
1672
+ const p = {
1673
+ ...f,
1680
1674
  data: {
1681
- ...c.data,
1675
+ ...f.data,
1682
1676
  shader: {
1683
- ...c.data.shader,
1684
- resolution: { width: i, height: m }
1677
+ ...f.data.shader,
1678
+ resolution: { width: i, height: c }
1685
1679
  }
1686
1680
  }
1687
1681
  };
1688
- t.set(c.id, f), s.push(c.id);
1682
+ s.set(f.id, p), e.push(f.id);
1689
1683
  }
1690
1684
  }
1691
- return [...t.values()];
1685
+ return [...s.values()];
1692
1686
  }
1693
- const An = ({
1694
- shaders: e,
1687
+ const Mn = ({
1688
+ shaders: n,
1695
1689
  initialState: o,
1696
1690
  handleSave: r,
1697
- className: t,
1698
- initialShowStats: s,
1699
- initialShaderPanelOpen: l,
1700
- initialOpenPreviewNodeId: a,
1691
+ className: s,
1692
+ initialShowStats: e,
1693
+ initialShaderPanelOpen: a,
1694
+ initialOpenPreviewNodeId: l,
1701
1695
  onEditorStateChange: u,
1702
1696
  onOpenPreviewNodeIdChange: i
1703
1697
  }) => {
1704
- const [m, h] = y(o?.edges ?? []), [c, f] = y(() => {
1705
- const d = o?.nodes ?? [], x = o?.edges ?? [], w = new Set(x.map((A) => A.target)), M = d.filter((A) => !w.has(A.id)).map((A) => A.id);
1706
- let I = d;
1707
- for (const A of M)
1708
- I = he(I, x, A);
1709
- return I;
1710
- }), b = W(
1711
- (d) => f((x) => Qe(d, x)),
1712
- [f]
1713
- ), C = W(
1714
- (d) => h((x) => Ze(d, x)),
1698
+ const [c, h] = y(o?.edges ?? []), [f, p] = y(() => {
1699
+ const d = o?.nodes ?? [], g = o?.edges ?? [], b = new Set(g.map((P) => P.target)), F = d.filter((P) => !b.has(P.id)).map((P) => P.id);
1700
+ let R = d;
1701
+ for (const P of F)
1702
+ R = _e(R, g, P);
1703
+ return R;
1704
+ }), x = Y(
1705
+ (d) => p((g) => rn(d, g)),
1706
+ [p]
1707
+ ), w = Y(
1708
+ (d) => h((g) => sn(d, g)),
1715
1709
  [h]
1716
- ), N = W(
1710
+ ), E = Y(
1717
1711
  (d) => {
1718
- const x = /* @__PURE__ */ new Set(), w = (M) => x.has(M) ? !1 : M === d.source ? !0 : (x.add(M), Se({ id: M }, c, m).some(
1719
- (I) => w(I.id)
1712
+ const g = /* @__PURE__ */ new Set(), b = (F) => g.has(F) ? !1 : F === d.source ? !0 : (g.add(F), Ie({ id: F }, f, c).some(
1713
+ (R) => b(R.id)
1720
1714
  ));
1721
- return !w(d.target);
1715
+ return !b(d.target);
1722
1716
  },
1723
- [c, m]
1724
- ), F = W(
1717
+ [f, c]
1718
+ ), T = Y(
1725
1719
  (d) => {
1726
- const x = _e({ ...d, type: "insert" }, m), w = he(
1727
- c,
1728
- x,
1720
+ const g = Ne({ ...d, type: "insert" }, c), b = _e(
1721
+ f,
1722
+ g,
1729
1723
  d.source
1730
1724
  );
1731
- h(x), f(w);
1725
+ h(g), p(b);
1732
1726
  },
1733
- [m, c]
1734
- ), { screenToFlowPosition: v } = en(), [E, U] = y(null), S = W(
1735
- (d, x) => {
1736
- if (!x.isValid && x.fromNode) {
1737
- const { clientX: w, clientY: M } = "changedTouches" in d ? d.changedTouches[0] : d;
1738
- U({
1727
+ [c, f]
1728
+ ), { screenToFlowPosition: v } = an(), [C, A] = y(null), U = Y(
1729
+ (d, g) => {
1730
+ if (!g.isValid && g.fromNode) {
1731
+ const { clientX: b, clientY: F } = "changedTouches" in d ? d.changedTouches[0] : d;
1732
+ A({
1739
1733
  position: v({
1740
- x: w,
1741
- y: M
1734
+ x: b,
1735
+ y: F
1742
1736
  }),
1743
- sourceId: x.fromNode.id
1737
+ sourceId: g.fromNode.id
1744
1738
  });
1745
1739
  }
1746
1740
  },
1747
1741
  [v]
1748
- ), g = R(
1742
+ ), _ = $(
1749
1743
  o?.uniforms ?? {}
1750
1744
  );
1751
- D(() => {
1752
- o?.uniforms && (g.current = o.uniforms);
1753
- }, [o]);
1754
- const [k, B] = y(null);
1755
- D(() => {
1756
- const d = (x) => {
1757
- (x.metaKey || x.ctrlKey) && x.key === "s" && (x.preventDefault(), r({ nodes: c, edges: m, uniforms: g.current }), B(/* @__PURE__ */ new Date()));
1745
+ k(() => {
1746
+ o?.uniforms && (_.current = o.uniforms);
1747
+ }, [o]), k(() => {
1748
+ p(
1749
+ (d) => d.map((g) => {
1750
+ if (g.type === "shader") {
1751
+ const b = g;
1752
+ for (const F of n)
1753
+ if (b.data.shader.name === F.name)
1754
+ return {
1755
+ ...b,
1756
+ data: {
1757
+ ...b.data,
1758
+ shader: {
1759
+ ...b.data.shader,
1760
+ source: F.source
1761
+ }
1762
+ }
1763
+ };
1764
+ return b;
1765
+ }
1766
+ return g;
1767
+ })
1768
+ );
1769
+ }, [n]);
1770
+ const [S, I] = y(null);
1771
+ k(() => {
1772
+ const d = (g) => {
1773
+ (g.metaKey || g.ctrlKey) && g.key === "s" && (g.preventDefault(), r({ nodes: f, edges: c, uniforms: _.current }), I(/* @__PURE__ */ new Date()));
1758
1774
  };
1759
1775
  return window.addEventListener("keydown", d), () => window.removeEventListener("keydown", d);
1760
- }, [c, m]);
1761
- const _ = (d) => {
1762
- const x = `${Math.random() * 1e5}`, w = { ...d, id: x };
1763
- return {
1764
- id: x,
1776
+ }, [f, c]);
1777
+ const H = (d) => {
1778
+ const g = `${Math.random() * 1e5}`, b = { ...d, id: g };
1779
+ return _.current[g] = {}, {
1780
+ id: g,
1765
1781
  position: { x: 0, y: 0 },
1766
1782
  data: {
1767
- shader: w,
1768
- uniforms: g,
1783
+ shader: b,
1784
+ uniforms: _,
1769
1785
  paused: !1
1770
1786
  },
1771
1787
  type: "shader"
1772
1788
  };
1773
- }, P = (d) => {
1774
- f((x) => [...x, _(d)]);
1775
- }, Z = (d, x) => {
1776
- const w = m.find(($) => $.id === x);
1777
- if (!w) return;
1778
- const M = w.source, I = w.target, A = c.find(($) => $.id === M), V = c.find(($) => $.id === I), L = w.targetHandle;
1779
- if (A && V && L) {
1780
- const $ = _(d), Le = ae($.data.shader);
1781
- let ue;
1782
- for (const Y of Le)
1783
- if (Y.type === "sampler2D" && Y.source === "input") {
1784
- ue = Y.name;
1789
+ }, X = (d) => {
1790
+ p((g) => [...g, H(d)]);
1791
+ }, K = (d, g) => {
1792
+ const b = c.find((O) => O.id === g);
1793
+ if (!b) return;
1794
+ const F = b.source, R = b.target, P = f.find((O) => O.id === F), B = f.find((O) => O.id === R), j = b.targetHandle;
1795
+ if (P && B && j) {
1796
+ const O = H(d), Ge = ce(O.data.shader);
1797
+ let me;
1798
+ for (const J of Ge)
1799
+ if (J.type === "sampler2D" && J.source === "input") {
1800
+ me = J.name;
1785
1801
  break;
1786
1802
  }
1787
- if (ue === void 0) return;
1788
- const [Hn, je, qe] = on({
1789
- sourceX: A.position.x,
1790
- sourceY: A.position.y,
1791
- sourcePosition: se.Bottom,
1792
- targetX: V.position.x,
1793
- targetY: V.position.y,
1794
- targetPosition: se.Top
1803
+ if (me === void 0) return;
1804
+ const [tt, We, Ve] = un({
1805
+ sourceX: P.position.x,
1806
+ sourceY: P.position.y,
1807
+ sourcePosition: ne.Bottom,
1808
+ targetX: B.position.x,
1809
+ targetY: B.position.y,
1810
+ targetPosition: ne.Top
1795
1811
  });
1796
- $.position.x = je, $.position.y = qe, f((Y) => [...Y, $]), h((Y) => {
1797
- const de = Y.filter(
1798
- (Be) => Be.id !== x
1799
- ), Ve = {
1812
+ O.position.x = We, O.position.y = Ve, p((J) => [...J, O]), h((J) => {
1813
+ const pe = J.filter(
1814
+ (Je) => Je.id !== g
1815
+ ), Ye = {
1800
1816
  id: "" + Math.random() * 1e4,
1801
- source: A.id,
1802
- target: $.id,
1803
- targetHandle: ue,
1817
+ source: P.id,
1818
+ target: O.id,
1819
+ targetHandle: me,
1804
1820
  type: "insert"
1805
- }, He = {
1821
+ }, Ke = {
1806
1822
  id: "" + Math.random() * 1e4,
1807
- source: $.id,
1808
- target: V.id,
1809
- targetHandle: L,
1823
+ source: O.id,
1824
+ target: B.id,
1825
+ targetHandle: j,
1810
1826
  type: "insert"
1811
1827
  };
1812
- return de.push(Ve), de.push(He), de;
1828
+ return pe.push(Ye), pe.push(Ke), pe;
1813
1829
  });
1814
1830
  }
1815
- }, [G, j] = Q(() => {
1831
+ }, [N, D] = re(() => {
1816
1832
  const d = {};
1817
- for (const w of c)
1818
- d[w.id] = [];
1819
- for (const w of m)
1820
- d[w.target].push({
1821
- from: w.source,
1822
- to: w.target,
1823
- input: w.targetHandle ?? ""
1833
+ for (const b of f)
1834
+ d[b.id] = [];
1835
+ for (const b of c)
1836
+ d[b.target].push({
1837
+ from: b.source,
1838
+ to: b.target,
1839
+ input: b.targetHandle ?? ""
1824
1840
  });
1825
1841
  return [JSON.stringify(d), d];
1826
- }, [m, c]), [X, ee] = Q(() => {
1842
+ }, [c, f]), [z, G] = re(() => {
1827
1843
  const d = {};
1828
- for (const x of c)
1829
- if (x.type === "shader") {
1830
- const w = x;
1831
- d[w.id] = w.data.shader;
1844
+ for (const g of f)
1845
+ if (g.type === "shader") {
1846
+ const b = g;
1847
+ d[b.id] = b.data.shader;
1832
1848
  }
1833
1849
  return [JSON.stringify(d), d];
1834
- }, [c]), q = Q(() => {
1850
+ }, [f]), te = re(() => {
1835
1851
  const d = {};
1836
- for (const [x, w] of Object.entries(ee)) {
1837
- d[x] = { shaders: [w], connections: [] };
1838
- const M = [x];
1839
- for (; M.length !== 0; ) {
1840
- const I = M.shift();
1841
- for (const A of j[I]) {
1842
- const V = A.from;
1843
- M.push(V);
1844
- const L = ee[V];
1845
- d[x].shaders.push(L), d[x].connections.push(A);
1852
+ for (const [g, b] of Object.entries(G)) {
1853
+ d[g] = { shaders: [b], connections: [] };
1854
+ const F = [g];
1855
+ for (; F.length !== 0; ) {
1856
+ const R = F.shift();
1857
+ for (const P of D[R]) {
1858
+ const B = P.from;
1859
+ F.push(B);
1860
+ const j = G[B];
1861
+ d[g].shaders.find(
1862
+ (O) => O.id === j.id
1863
+ ) || d[g].shaders.push(j), d[g].connections.push(P);
1846
1864
  }
1847
1865
  }
1848
1866
  }
1849
1867
  return d;
1850
- }, [X, G]), ne = W(
1851
- (d, x) => {
1852
- g.current[d] = x;
1868
+ }, [z, N]), fe = Y(
1869
+ (d, g) => {
1870
+ _.current[d] = g(
1871
+ _.current[d]
1872
+ );
1853
1873
  },
1854
1874
  []
1855
- ), Fe = W(
1856
- (d, x) => {
1857
- f((w) => {
1858
- const M = w.map((I) => {
1859
- if (I.id === d && I.type === "shader") {
1860
- const A = I;
1861
- return { ...A, data: x(A.data) };
1875
+ ), le = Y(
1876
+ (d, g) => {
1877
+ p((b) => {
1878
+ const F = b.map((R) => {
1879
+ if (R.id === d && R.type === "shader") {
1880
+ const P = R;
1881
+ return { ...P, data: g(P.data) };
1862
1882
  }
1863
- return I;
1883
+ return R;
1864
1884
  });
1865
- return he(M, m, d);
1885
+ return _e(F, c, d);
1866
1886
  });
1867
1887
  },
1868
- [m]
1869
- ), ge = R(0), xe = R([0, 0]);
1870
- D(() => {
1888
+ [c]
1889
+ ), W = $(0), Z = $([0, 0]);
1890
+ k(() => {
1871
1891
  const d = setInterval(() => {
1872
- ge.current = Date.now();
1873
- }, 10), x = (w) => {
1874
- xe.current = [
1875
- Math.min(1, w.clientX / window.innerWidth),
1876
- Math.min(w.clientY / innerHeight, 1)
1892
+ W.current = Date.now();
1893
+ }, 10), g = (b) => {
1894
+ Z.current = [
1895
+ Math.min(1, b.clientX / window.innerWidth),
1896
+ Math.min(b.clientY / innerHeight, 1)
1877
1897
  ];
1878
1898
  };
1879
- return window.addEventListener("mousemove", x), () => {
1880
- clearInterval(d), window.removeEventListener("mousemove", x);
1899
+ return window.addEventListener("mousemove", g), () => {
1900
+ clearInterval(d), window.removeEventListener("mousemove", g);
1881
1901
  };
1882
1902
  }, []);
1883
- const Pe = (d, x, w) => {
1884
- if (c.find((I) => I.id === x)) {
1885
- const I = _(d);
1886
- I.position = w;
1887
- const A = ae(I.data.shader);
1888
- let V;
1889
- for (const L of A)
1890
- if (L.type === "sampler2D" && L.source === "input") {
1891
- V = L.name;
1903
+ const Oe = (d, g, b) => {
1904
+ if (f.find((R) => R.id === g)) {
1905
+ const R = H(d);
1906
+ R.position = b;
1907
+ const P = ce(R.data.shader);
1908
+ let B;
1909
+ for (const j of P)
1910
+ if (j.type === "sampler2D" && j.source === "input") {
1911
+ B = j.name;
1892
1912
  break;
1893
1913
  }
1894
- if (f((L) => [...L, I]), V !== void 0) {
1895
- const L = {
1914
+ if (p((j) => [...j, R]), B !== void 0) {
1915
+ const j = {
1896
1916
  id: "" + Math.random(),
1897
- source: x,
1898
- target: I.id,
1899
- targetHandle: V,
1917
+ source: g,
1918
+ target: R.id,
1919
+ targetHandle: B,
1900
1920
  type: "insert"
1901
1921
  };
1902
- h(($) => _e(L, $));
1922
+ h((O) => Ne(j, O));
1903
1923
  }
1904
1924
  }
1905
- }, [J, Me] = y(s ?? !1), [te, De] = y(
1906
- l ?? !0
1907
- ), [re, be] = y(null), [$e, ze] = y(a ?? null), Oe = (d) => {
1908
- ze(d), i?.(d);
1925
+ }, [ye, Le] = y(""), [we, ze] = y(""), [ee, je] = y(e ?? !1), [oe, qe] = y(
1926
+ a ?? !0
1927
+ ), [ie, Ce] = y(null), [He, Be] = y(l ?? null), Xe = (d) => {
1928
+ Be(d), i?.(d);
1909
1929
  };
1910
- return D(() => {
1911
- u?.({ showStats: J, shaderPanelOpen: te });
1912
- }, [J, te]), /* @__PURE__ */ p("div", { className: `w-full h-full ${t}`, children: [
1913
- /* @__PURE__ */ n(
1914
- oe.Provider,
1930
+ return k(() => {
1931
+ u?.({ showStats: ee, shaderPanelOpen: oe });
1932
+ }, [ee, oe]), /* @__PURE__ */ m("div", { className: `w-full h-full ${s}`, children: [
1933
+ /* @__PURE__ */ t(
1934
+ ae.Provider,
1915
1935
  {
1916
1936
  value: {
1917
- currentTime: ge,
1918
- mousePosition: xe,
1919
- shaders: e,
1920
- patches: q,
1921
- showStats: J,
1922
- openExportNodeId: re,
1923
- setOpenExportNodeId: be,
1924
- openPreviewNodeId: $e,
1925
- setOpenPreviewNodeId: Oe,
1926
- uniforms: g,
1927
- handleUpdateUniforms: ne,
1928
- handleUpdateNode: Fe,
1929
- handleInsertShader: Z
1937
+ currentTime: W,
1938
+ mousePosition: Z,
1939
+ shaders: n,
1940
+ patches: te,
1941
+ showStats: ee,
1942
+ openExportNodeId: ie,
1943
+ setOpenExportNodeId: Ce,
1944
+ openPreviewNodeId: He,
1945
+ setOpenPreviewNodeId: Xe,
1946
+ uniforms: _,
1947
+ handleUpdateUniforms: fe,
1948
+ handleUpdateNode: le,
1949
+ handleInsertShader: K
1930
1950
  },
1931
- children: /* @__PURE__ */ p(
1932
- nn,
1951
+ children: /* @__PURE__ */ m(
1952
+ ln,
1933
1953
  {
1934
1954
  panOnScroll: !0,
1935
1955
  proOptions: { hideAttribution: !0 },
1936
- nodes: c,
1956
+ nodes: f,
1937
1957
  nodeTypes: { shader: Rn },
1938
- edges: m,
1939
- edgeTypes: { insert: Un },
1940
- onNodesChange: b,
1941
- onEdgesChange: C,
1942
- onConnect: F,
1943
- onConnectEnd: S,
1944
- connectionLineComponent: In,
1945
- isValidConnection: N,
1958
+ edges: c,
1959
+ edgeTypes: { insert: Fn },
1960
+ onNodesChange: x,
1961
+ onEdgesChange: w,
1962
+ onConnect: T,
1963
+ onConnectEnd: U,
1964
+ connectionLineComponent: Pn,
1965
+ isValidConnection: E,
1946
1966
  style: {
1947
- background: "#F9F9F9"
1967
+ background: "#F3F3F3"
1948
1968
  },
1949
1969
  fitView: !0,
1950
1970
  children: [
1951
- /* @__PURE__ */ n(
1952
- tn,
1971
+ /* @__PURE__ */ t(
1972
+ cn,
1953
1973
  {
1954
1974
  style: {
1955
1975
  "--xy-controls-button-background-color-default": "transparent",
@@ -1957,18 +1977,18 @@ const An = ({
1957
1977
  }
1958
1978
  }
1959
1979
  ),
1960
- /* @__PURE__ */ p(fe, { position: "top-left", className: "flex flex-col gap-4", children: [
1961
- /* @__PURE__ */ n(
1980
+ /* @__PURE__ */ m(he, { position: "top-left", className: "flex flex-col gap-4", children: [
1981
+ /* @__PURE__ */ t(
1962
1982
  "button",
1963
1983
  {
1964
1984
  className: "button-base",
1965
- onClick: () => Me(!J),
1966
- children: J ? "Hide Stats" : "Show Stats"
1985
+ onClick: () => je(!ee),
1986
+ children: ee ? "Hide Stats" : "Show Stats"
1967
1987
  }
1968
1988
  ),
1969
- J && /* @__PURE__ */ p(le, { children: [
1970
- /* @__PURE__ */ n("div", { className: "flex flex-col gap-2", children: c.map((d) => /* @__PURE__ */ n("p", { className: "text-xs text-neutral-400", children: d.id }, d.id)) }),
1971
- /* @__PURE__ */ n("div", { className: "flex flex-col gap-2", children: m.map((d) => /* @__PURE__ */ p("p", { className: "text-xs text-neutral-400", children: [
1989
+ ee && /* @__PURE__ */ m(se, { children: [
1990
+ /* @__PURE__ */ t("div", { className: "flex flex-col gap-2", children: f.map((d) => /* @__PURE__ */ t("p", { className: "text-xs text-neutral-400", children: d.id }, d.id)) }),
1991
+ /* @__PURE__ */ t("div", { className: "flex flex-col gap-2", children: c.map((d) => /* @__PURE__ */ m("p", { className: "text-xs text-neutral-400", children: [
1972
1992
  d.source,
1973
1993
  " ",
1974
1994
  ">",
@@ -1979,109 +1999,137 @@ const An = ({
1979
1999
  ] }, d.id)) })
1980
2000
  ] })
1981
2001
  ] }),
1982
- e.length > 0 && /* @__PURE__ */ n(fe, { position: "bottom-right", children: /* @__PURE__ */ p("div", { className: "w-56 flex flex-col rounded-sm bg-white overflow-hidden", children: [
1983
- /* @__PURE__ */ p("div", { className: "flex items-center justify-between px-3 py-2", children: [
1984
- /* @__PURE__ */ n("p", { className: "text-sm", children: "Add Shader" }),
1985
- /* @__PURE__ */ n(
2002
+ n.length > 0 && /* @__PURE__ */ t(he, { position: "bottom-right", children: /* @__PURE__ */ m("div", { className: "w-56 flex flex-col rounded-sm bg-white overflow-hidden", children: [
2003
+ /* @__PURE__ */ m("div", { className: "flex items-center justify-between px-3 py-2", children: [
2004
+ /* @__PURE__ */ t("p", { className: "text-sm", children: "Add Shader" }),
2005
+ /* @__PURE__ */ t(
1986
2006
  "button",
1987
2007
  {
1988
2008
  className: "button-base",
1989
- onClick: () => De(!te),
1990
- children: te ? "Hide" : "Show"
2009
+ onClick: () => qe(!oe),
2010
+ children: oe ? "Hide" : "Show"
1991
2011
  }
1992
2012
  )
1993
2013
  ] }),
1994
- te && /* @__PURE__ */ n("div", { className: "flex flex-col gap-1 px-2 pb-2", children: e.sort((d, x) => d.name.localeCompare(x.name)).map((d) => /* @__PURE__ */ n(
1995
- "button",
1996
- {
1997
- className: "text-xs flex justify-start p-1 rounded-sm hover:bg-neutral-100 cursor-pointer text-neutral-500",
1998
- onClick: () => P(d),
1999
- children: d.id
2000
- },
2001
- d.id
2002
- )) })
2014
+ oe && /* @__PURE__ */ m("div", { className: "flex flex-col gap-1 px-2 pb-2", children: [
2015
+ /* @__PURE__ */ t(
2016
+ "input",
2017
+ {
2018
+ type: "text",
2019
+ value: ye,
2020
+ onChange: (d) => Le(d.target.value),
2021
+ placeholder: "Search shaders...",
2022
+ className: "text-xs p-1 rounded-sm border border-neutral-200 outline-none mb-1"
2023
+ }
2024
+ ),
2025
+ /* @__PURE__ */ t("div", { className: "flex flex-col gap-1 pb-2 h-[50vh] overflow-y-auto", children: n.filter(
2026
+ (d) => d.name.toLowerCase().includes(ye.toLowerCase())
2027
+ ).sort((d, g) => d.name.localeCompare(g.name)).map((d) => /* @__PURE__ */ t(
2028
+ "button",
2029
+ {
2030
+ className: "text-xs flex justify-start p-1 rounded-sm hover:bg-neutral-100 cursor-pointer text-neutral-500",
2031
+ onClick: () => X(d),
2032
+ children: d.id.length > 25 ? `${d.id.slice(0, 11)}...${d.id.slice(-11)}` : d.id
2033
+ },
2034
+ d.id
2035
+ )) })
2036
+ ] })
2003
2037
  ] }) }),
2004
- k && /* @__PURE__ */ n(fe, { position: "bottom-center", children: /* @__PURE__ */ p("p", { className: "text-xs text-neutral-400", children: [
2038
+ S && /* @__PURE__ */ t(he, { position: "bottom-center", children: /* @__PURE__ */ m("p", { className: "text-xs text-neutral-400", children: [
2005
2039
  "Last saved at ",
2006
- k.toLocaleTimeString()
2040
+ S.toLocaleTimeString()
2007
2041
  ] }) })
2008
2042
  ]
2009
2043
  }
2010
2044
  )
2011
2045
  }
2012
2046
  ),
2013
- re !== null && q[re] && /* @__PURE__ */ n(
2014
- Te,
2047
+ ie !== null && te[ie] && /* @__PURE__ */ t(
2048
+ $e,
2015
2049
  {
2016
- uniforms: g.current,
2017
- patch: q[re],
2050
+ uniforms: _.current,
2051
+ patch: te[ie],
2018
2052
  open: !0,
2019
2053
  onOpenChange: (d) => {
2020
- d || be(null);
2054
+ d || Ce(null);
2021
2055
  }
2022
2056
  }
2023
2057
  ),
2024
- /* @__PURE__ */ n(
2025
- ce,
2058
+ /* @__PURE__ */ t(
2059
+ de,
2026
2060
  {
2027
- open: E !== null,
2061
+ open: C !== null,
2028
2062
  handleOpenChange: (d) => {
2029
- d === !1 && U(null);
2063
+ d === !1 && A(null);
2030
2064
  },
2031
- children: /* @__PURE__ */ p("div", { className: "w-full h-full flex flex-col p-4", children: [
2032
- /* @__PURE__ */ p("div", { className: "w-full flex justify-between", children: [
2033
- /* @__PURE__ */ n("p", { children: "Add a Shader" }),
2034
- /* @__PURE__ */ n(
2065
+ children: /* @__PURE__ */ m("div", { className: "w-full h-full flex flex-col p-4 gap-4", children: [
2066
+ /* @__PURE__ */ m("div", { className: "w-full flex justify-between", children: [
2067
+ /* @__PURE__ */ t("p", { children: "Add a Shader" }),
2068
+ /* @__PURE__ */ t(
2035
2069
  "button",
2036
2070
  {
2037
2071
  className: "button-base",
2038
2072
  onClick: () => {
2039
- U(null);
2073
+ A(null);
2040
2074
  },
2041
2075
  children: "Close"
2042
2076
  }
2043
2077
  )
2044
2078
  ] }),
2045
- /* @__PURE__ */ n("div", { className: "w-full flex flex-col", children: e.map((d) => /* @__PURE__ */ n(
2046
- "button",
2047
- {
2048
- className: "text-xs flex justify-start p-1 rounded-sm hover:bg-neutral-100 cursor-pointer text-neutral-500",
2049
- onClick: () => {
2050
- E && Pe(
2051
- d,
2052
- E.sourceId,
2053
- E.position
2054
- ), U(null);
2079
+ /* @__PURE__ */ m("div", { className: "w-full flex flex-col h-full overflow-hidden gap-2", children: [
2080
+ /* @__PURE__ */ t(
2081
+ "input",
2082
+ {
2083
+ type: "text",
2084
+ value: we,
2085
+ onChange: (d) => ze(d.target.value),
2086
+ placeholder: "Search shaders...",
2087
+ className: "text-xs p-1 rounded-sm border border-neutral-200 outline-none mb-1"
2088
+ }
2089
+ ),
2090
+ /* @__PURE__ */ t("div", { className: "h-full flex flex-col overflow-y-auto", children: n.filter(
2091
+ (d) => d.name.toLowerCase().includes(we.toLowerCase())
2092
+ ).map((d) => /* @__PURE__ */ t(
2093
+ "button",
2094
+ {
2095
+ className: "text-xs flex justify-start p-1 rounded-sm hover:bg-neutral-100 cursor-pointer text-neutral-500",
2096
+ onClick: () => {
2097
+ C && Oe(
2098
+ d,
2099
+ C.sourceId,
2100
+ C.position
2101
+ ), A(null);
2102
+ },
2103
+ children: d.id
2055
2104
  },
2056
- children: d.id
2057
- },
2058
- d.id
2059
- )) })
2105
+ d.id
2106
+ )) })
2107
+ ] })
2060
2108
  ] })
2061
2109
  }
2062
2110
  )
2063
2111
  ] });
2064
- }, Xn = (e) => /* @__PURE__ */ n(Je, { children: /* @__PURE__ */ n(An, { ...e }) });
2065
- function Yn(e, o) {
2066
- const r = { current: o }, t = e.shaders.map((l, a) => ({
2067
- id: l.id,
2112
+ }, at = (n) => /* @__PURE__ */ t(on, { children: /* @__PURE__ */ t(Mn, { ...n }) });
2113
+ function lt(n, o) {
2114
+ const r = { current: o }, s = n.shaders.map((a, l) => ({
2115
+ id: a.id,
2068
2116
  type: "shader",
2069
- position: { x: 0, y: -a * 500 },
2117
+ position: { x: 0, y: -l * 500 },
2070
2118
  data: {
2071
- shader: l,
2119
+ shader: a,
2072
2120
  uniforms: r,
2073
2121
  paused: !1
2074
2122
  }
2075
- })), s = e.connections.map((l, a) => ({
2076
- id: `edge-${a}`,
2077
- source: l.from,
2078
- target: l.to,
2079
- targetHandle: l.input,
2123
+ })), e = n.connections.map((a, l) => ({
2124
+ id: `edge-${l}`,
2125
+ source: a.from,
2126
+ target: a.to,
2127
+ targetHandle: a.input,
2080
2128
  type: "insert"
2081
2129
  }));
2082
- return console.log("build", { nodes: t, edges: s, uniforms: o }), { nodes: t, edges: s, uniforms: o };
2130
+ return console.log("build", { nodes: s, edges: e, uniforms: o }), { nodes: s, edges: e, uniforms: o };
2083
2131
  }
2084
- const Tn = `#version 300 es
2132
+ const $n = `#version 300 es
2085
2133
  precision mediump float;
2086
2134
 
2087
2135
  uniform sampler2D u_texture; // input
@@ -2103,7 +2151,7 @@ void main() {
2103
2151
  fragColor = texColor;
2104
2152
  }
2105
2153
  }
2106
- `, Fn = `#version 300 es
2154
+ `, On = `#version 300 es
2107
2155
 
2108
2156
  precision highp float;
2109
2157
 
@@ -2378,16 +2426,18 @@ void main()
2378
2426
  ),
2379
2427
  1.0
2380
2428
  );
2381
- }`, Pn = `#version 300 es
2429
+ }`, Ln = `#version 300 es
2382
2430
  precision mediump float;
2383
2431
 
2384
- uniform sampler2D u_texture; // input
2385
- uniform float u_resolution; // [1, 100, 20]
2432
+ uniform sampler2D u_texture;
2433
+ uniform vec2 u_resolution; // resolution
2386
2434
  uniform float u_numColors; // [2, 16, 2]
2435
+ uniform float u_dither_size; // [1, 100, 10]
2387
2436
 
2388
2437
  in vec2 vUv;
2389
2438
  out vec4 fragColor;
2390
2439
 
2440
+
2391
2441
  int bayer(int x, int y) {
2392
2442
  int bayer64[64] = int[64](
2393
2443
  0, 32, 8, 40, 2, 34, 10, 42,
@@ -2403,8 +2453,8 @@ int bayer(int x, int y) {
2403
2453
  }
2404
2454
 
2405
2455
  void main() {
2406
- vec2 cell = floor(vUv * u_resolution);
2407
- vec2 cellUv = cell / u_resolution;
2456
+ vec2 cell = floor(vUv * u_resolution / u_dither_size);
2457
+ vec2 cellUv = cell / u_resolution * u_dither_size;
2408
2458
 
2409
2459
  vec4 color = texture(u_texture, cellUv);
2410
2460
 
@@ -2416,7 +2466,7 @@ void main() {
2416
2466
 
2417
2467
  fragColor = vec4(dithered, color.a);
2418
2468
  }
2419
- `, Mn = `#version 300 es
2469
+ `, zn = `#version 300 es
2420
2470
  precision mediump float;
2421
2471
 
2422
2472
  uniform sampler2D u_texture; // input
@@ -2455,7 +2505,7 @@ void main() {
2455
2505
 
2456
2506
  fragColor = dist < dotRadius ? cellColor : u_background;
2457
2507
  }
2458
- `, Dn = `#version 300 es
2508
+ `, jn = `#version 300 es
2459
2509
  precision highp float;
2460
2510
 
2461
2511
  in vec2 vUv;
@@ -2493,58 +2543,7 @@ void main() {
2493
2543
  vec4(vec3(1.0), 1.0),
2494
2544
  smoothstep(0.6, 0.5, dist)
2495
2545
  );
2496
- }`, $n = `#version 300 es
2497
- precision mediump float;
2498
-
2499
- uniform sampler2D u_texture;
2500
- uniform float u_size; // [1, 100, 5]
2501
- uniform vec2 u_resolution; // resolution
2502
-
2503
- in vec2 vUv;
2504
- out vec4 fragColor;
2505
-
2506
- const float PI = 3.1415926535897932384626433832795;
2507
-
2508
- // Gaussian function
2509
- float gaussian(float x, float sigma) {
2510
- return exp(-(x * x) / (2.0 * sigma * sigma)) / (sqrt(2.0 * PI) * sigma);
2511
- }
2512
-
2513
- void main() {
2514
- vec2 texelSize = 1.0 / u_resolution;
2515
- float sigma = u_size / 3.0; // Standard deviation based on size
2516
-
2517
- vec4 result = vec4(0.0);
2518
- float totalWeight = 0.0;
2519
-
2520
- int kernelRadius = int(ceil(u_size));
2521
-
2522
- // Two-pass separable Gaussian blur (horizontal + vertical in one pass for simplicity)
2523
- // For better performance, this should be split into two passes, but for this implementation
2524
- // we'll do a 2D kernel
2525
- for (int x = -25; x <= 25; x++) {
2526
- if (abs(float(x)) > float(kernelRadius)) continue;
2527
-
2528
- for (int y = -25; y <= 25; y++) {
2529
- if (abs(float(y)) > float(kernelRadius)) continue;
2530
-
2531
- vec2 offset = vec2(float(x), float(y)) * texelSize;
2532
- vec2 sampleCoord = vUv + offset;
2533
-
2534
- // Clamp to edges
2535
- sampleCoord = clamp(sampleCoord, vec2(0.0), vec2(1.0));
2536
-
2537
- float distance = length(vec2(float(x), float(y)));
2538
- float weight = gaussian(distance, sigma);
2539
-
2540
- result += texture(u_texture, sampleCoord) * weight;
2541
- totalWeight += weight;
2542
- }
2543
- }
2544
-
2545
- fragColor = result / totalWeight;
2546
- }
2547
- `, zn = `#version 300 es
2546
+ }`, qn = `#version 300 es
2548
2547
  precision mediump float;
2549
2548
 
2550
2549
  uniform sampler2D u_texture;
@@ -2561,7 +2560,7 @@ void main() {
2561
2560
 
2562
2561
  fragColor = vec4(gradientColor.rgb, 1.0);
2563
2562
  }
2564
- `, On = `#version 300 es
2563
+ `, Hn = `#version 300 es
2565
2564
  precision mediump float;
2566
2565
 
2567
2566
  uniform sampler2D u_texture; // input
@@ -2633,7 +2632,7 @@ void main() {
2633
2632
 
2634
2633
  fragColor = vec4(hsl2rgb(hsl), color.a);
2635
2634
  }
2636
- `, Ln = `#version 300 es
2635
+ `, Bn = `#version 300 es
2637
2636
  precision highp float;
2638
2637
 
2639
2638
  in vec2 vUv;
@@ -2643,44 +2642,7 @@ uniform sampler2D u_image_source; // texture
2643
2642
 
2644
2643
  void main() {
2645
2644
  fragColor = texture(u_image_source, vec2(vUv.x, 1.0-vUv.y));
2646
- }`, jn = `#version 300 es
2647
- precision mediump float;
2648
-
2649
- uniform sampler2D u_texture;
2650
- uniform float u_size; // [1, 100, 5]
2651
- uniform vec2 u_resolution; // resolution
2652
-
2653
- in vec2 vUv;
2654
- out vec4 fragColor;
2655
-
2656
- void main() {
2657
- vec2 texelSize = 1.0 / u_resolution;
2658
-
2659
- vec4 result = vec4(0.0);
2660
- int kernelRadius = int(ceil(u_size));
2661
- int sampleCount = 0;
2662
-
2663
- // Box blur - simple average of all pixels in the kernel
2664
- for (int x = -25; x <= 25; x++) {
2665
- if (abs(float(x)) > float(kernelRadius)) continue;
2666
-
2667
- for (int y = -25; y <= 25; y++) {
2668
- if (abs(float(y)) > float(kernelRadius)) continue;
2669
-
2670
- vec2 offset = vec2(float(x), float(y)) * texelSize;
2671
- vec2 sampleCoord = vUv + offset;
2672
-
2673
- // Clamp to edges
2674
- sampleCoord = clamp(sampleCoord, vec2(0.0), vec2(1.0));
2675
-
2676
- result += texture(u_texture, sampleCoord);
2677
- sampleCount++;
2678
- }
2679
- }
2680
-
2681
- fragColor = result / float(sampleCount);
2682
- }
2683
- `, qn = `#version 300 es
2645
+ }`, Xn = `#version 300 es
2684
2646
  precision highp float;
2685
2647
 
2686
2648
  uniform float u_time; // time
@@ -2754,7 +2716,7 @@ void main() {
2754
2716
  }
2755
2717
  }
2756
2718
 
2757
- }`, Vn = `#version 300 es
2719
+ }`, Gn = `#version 300 es
2758
2720
  precision mediump float;
2759
2721
 
2760
2722
  uniform sampler2D u_texture; // input
@@ -2768,33 +2730,267 @@ void main() {
2768
2730
  vec3 adjusted = clamp(color.rgb + u_rgbAdjust / 255.0, 0.0, 1.0);
2769
2731
  fragColor = vec4(adjusted, color.a);
2770
2732
  }
2771
- `, Kn = {
2772
- "chromakey.frag": Tn,
2773
- "dither_bayer.frag": Pn,
2774
- "dots.frag": Mn,
2775
- "daffodil.frag": Fn,
2776
- "diamonds.frag": Dn,
2777
- "gaussian.frag": $n,
2778
- "gradientmap.frag": zn,
2779
- "hsl.frag": On,
2780
- "imageViewer.frag": Ln,
2781
- "linear.frag": jn,
2782
- "lines.frag": qn,
2783
- "rgb.frag": Vn
2733
+ `, Wn = `#version 300 es
2734
+ precision mediump float;
2735
+
2736
+ in vec2 vUv;
2737
+ out vec4 fragColor;
2738
+
2739
+ uniform sampler2D u_texture_1;
2740
+ uniform sampler2D u_texture_2;
2741
+
2742
+ void main() {
2743
+ fragColor = clamp(
2744
+ texture(u_texture_1, vUv) + texture(u_texture_2, vUv),
2745
+ vec4(0.),
2746
+ vec4(1.)
2747
+ );
2748
+
2749
+ }`, Vn = `#version 300 es
2750
+ precision mediump float;
2751
+
2752
+ in vec2 vUv;
2753
+ out vec4 fragColor;
2754
+
2755
+ uniform sampler2D u_texture_1;
2756
+ uniform sampler2D u_texture_2;
2757
+
2758
+ void main() {
2759
+ fragColor = clamp(
2760
+ texture(u_texture_1, vUv) - texture(u_texture_2, vUv),
2761
+ vec4(0.),
2762
+ vec4(1.)
2763
+ );
2764
+
2765
+ }`, Yn = `#version 300 es
2766
+ precision mediump float;
2767
+
2768
+ in vec2 vUv;
2769
+ out vec4 fragColor;
2770
+
2771
+ uniform sampler2D u_texture_1;
2772
+ uniform sampler2D u_texture_2;
2773
+ uniform float u_factor; // [0, 1, 0.5]
2774
+
2775
+ void main() {
2776
+ fragColor = mix(
2777
+ texture(u_texture_1, vUv),
2778
+ texture(u_texture_2, vUv),
2779
+ u_factor
2780
+ );
2781
+ }`, Kn = `#version 300 es
2782
+ precision mediump float;
2783
+
2784
+ in vec2 vUv;
2785
+ out vec4 fragColor;
2786
+
2787
+ uniform sampler2D u_texture_1;
2788
+ uniform sampler2D u_texture_2;
2789
+
2790
+ void main() {
2791
+ fragColor = clamp(
2792
+ texture(u_texture_1, vUv) * texture(u_texture_2, vUv),
2793
+ vec4(0.),
2794
+ vec4(1.)
2795
+ );
2796
+
2797
+ }`, Jn = `#version 300 es
2798
+ precision mediump float;
2799
+
2800
+ in vec2 vUv;
2801
+ out vec4 fragColor;
2802
+
2803
+ uniform sampler2D u_texture_1;
2804
+ uniform sampler2D u_texture_2;
2805
+
2806
+ void main() {
2807
+ fragColor = clamp(
2808
+ texture(u_texture_1, vUv) / (texture(u_texture_2, vUv) + 0.001),
2809
+ vec4(0.),
2810
+ vec4(1.)
2811
+ );
2812
+ }`, Qn = `#version 300 es
2813
+ precision mediump float;
2814
+
2815
+ uniform sampler2D u_texture;
2816
+ uniform float u_blur_radius; // [0, 3, 0.1]
2817
+ uniform vec2 u_resolution; // resolution
2818
+ uniform vec2 u_center; // [0.5, 0.5]
2819
+ uniform float u_blur_sample_count; // [2, 50, 5]
2820
+
2821
+ in vec2 vUv;
2822
+ out vec4 fragColor;
2823
+
2824
+ void main() {
2825
+ vec2 aspect = vec2(u_resolution.x / u_resolution.y, 1.0);
2826
+ vec2 uv = vUv * aspect;
2827
+ vec2 center = u_center * aspect;
2828
+
2829
+ vec2 offset = uv - center;
2830
+ float r = atan(offset.y, offset.x);
2831
+ float dist = length(offset);
2832
+
2833
+ vec4 result = vec4(0.);
2834
+
2835
+ int count = int(floor(u_blur_sample_count));
2836
+ float invCount = 1.0 / float(count);
2837
+
2838
+ for (int i = 0; i < count; i++) {
2839
+ float progress = float(i) * invCount;
2840
+ float angle = r - u_blur_radius * 0.5 + progress * u_blur_radius;
2841
+
2842
+ vec2 rotated = vec2(cos(angle), sin(angle)) * dist;
2843
+
2844
+ vec2 sample_uv = center + rotated;
2845
+ sample_uv /= aspect;
2846
+
2847
+ result += texture(u_texture, sample_uv);
2848
+ }
2849
+
2850
+ fragColor = result * invCount;
2851
+ }
2852
+ `, Zn = `#version 300 es
2853
+ precision mediump float;
2854
+
2855
+ in vec2 vUv;
2856
+ out vec4 fragColor;
2857
+
2858
+ uniform sampler2D u_input_tex;
2859
+ uniform float u_blur_dist; // [0, 1, 0.1]
2860
+ uniform vec2 u_resolution; // resolution
2861
+ uniform float u_angle; // [0, 10, 0]
2862
+ uniform float u_blur_sample_count; // [2, 50, 5]
2863
+ uniform float u_start_offset; // [0, 1, 0.5]
2864
+
2865
+
2866
+ mat2 rotate2D(float angle) {
2867
+ float c = cos(angle);
2868
+ float s = sin(angle);
2869
+ return mat2(
2870
+ c, -s,
2871
+ s, c
2872
+ );
2873
+ }
2874
+
2875
+ void main() {
2876
+ vec2 aspect = vec2(
2877
+ u_resolution.x / u_resolution.y,
2878
+ 1.0
2879
+ );
2880
+
2881
+ vec2 uv = vUv * aspect;
2882
+
2883
+ mat2 rot_mat = rotate2D(u_angle);
2884
+ mat2 inv_rot_mat = rotate2D(-u_angle);
2885
+ vec2 rotated_uv = rot_mat * uv;
2886
+
2887
+ int count = int(floor(u_blur_sample_count));
2888
+
2889
+ vec4 result = vec4(0.0);
2890
+
2891
+ float offset_bias = u_blur_dist * u_start_offset;
2892
+
2893
+ for (int i = 0; i < count; i++) {
2894
+ float offset = float(i) / float(count) * u_blur_dist - offset_bias;
2895
+ vec2 target_pos = rotated_uv + vec2(offset, 0.0);
2896
+
2897
+ result += texture(
2898
+ u_input_tex,
2899
+ (inv_rot_mat * target_pos) / aspect
2900
+ );
2901
+ }
2902
+
2903
+ fragColor = result / float(count);
2904
+ }`, et = `#version 300 es
2905
+ precision mediump float;
2906
+
2907
+ // from book of shaders
2908
+
2909
+ uniform vec2 u_resolution; // resolution
2910
+
2911
+ in vec2 vUv;
2912
+ out vec4 fragColor;
2913
+
2914
+ float random (vec2 st) {
2915
+ return fract(sin(dot(st.xy,
2916
+ vec2(12.9898,78.233)))*
2917
+ 438758.5453123);
2918
+ }
2919
+
2920
+ void main() {
2921
+ vec2 st = vUv.xy/u_resolution.xy;
2922
+
2923
+ float rnd1 = random(st);
2924
+ float rnd2 = random(st + rnd1);
2925
+ float rnd3 = random(vec2(rnd1, rnd2));
2926
+ float rnd4 = random(vec2(rnd1, rnd3));
2927
+
2928
+ fragColor = vec4(rnd1, rnd3, rnd4,1.0);
2929
+ }`, nt = `#version 300 es
2930
+ precision mediump float;
2931
+
2932
+
2933
+ uniform sampler2D u_input_tex;
2934
+ uniform vec2 u_resolution; // resolution
2935
+ uniform float disperse_distance; // [0, 1, 0.1]
2936
+
2937
+ in vec2 vUv;
2938
+ out vec4 fragColor;
2939
+
2940
+ float random (vec2 st) {
2941
+ return fract(sin(dot(st.xy,
2942
+ vec2(12.9898,78.233)))*
2943
+ 438758.5453123);
2944
+ }
2945
+
2946
+ void main() {
2947
+ vec2 aspect = vec2(
2948
+ u_resolution.x / u_resolution.y,
2949
+ 1.0
2950
+ );
2951
+ vec2 uv = vUv.xy * aspect;
2952
+
2953
+ float rnd1 = random(uv);
2954
+ float rnd2 = random(uv.yx);
2955
+
2956
+ fragColor = texture(u_input_tex,
2957
+ (vec2(rnd1, rnd2) * disperse_distance - disperse_distance * 0.5 + uv)
2958
+ / aspect
2959
+ );
2960
+ }`, it = {
2961
+ key: $n,
2962
+ dither: Ln,
2963
+ dots: zn,
2964
+ daffodil: On,
2965
+ diamonds: jn,
2966
+ "gradient map": qn,
2967
+ "hue/saturation/value": Hn,
2968
+ "image viewer": Bn,
2969
+ "blur (radial)": Qn,
2970
+ "blur (linear)": Zn,
2971
+ noise: et,
2972
+ dispersion: nt,
2973
+ lines: Xn,
2974
+ "color adjust": Gn,
2975
+ "mix (add)": Wn,
2976
+ "mix (subtract)": Vn,
2977
+ "mix (multiply)": Kn,
2978
+ "mix (linear)": Yn,
2979
+ "mix (divide)": Jn
2784
2980
  };
2785
2981
  export {
2786
- Ce as CustomHandle,
2787
- ce as Dialog,
2788
- Xn as Editor,
2789
- oe as EditorContext,
2790
- Te as ExportDialog,
2791
- cn as Renderer,
2982
+ Ue as CustomHandle,
2983
+ de as Dialog,
2984
+ at as Editor,
2985
+ ae as EditorContext,
2986
+ $e as ExportDialog,
2987
+ hn as Renderer,
2792
2988
  Re as RendererComponent,
2793
- H as Scrubber,
2989
+ V as Scrubber,
2794
2990
  Rn as ShaderNode,
2795
- Ae as UniformForm,
2796
- Yn as buildEditorState,
2797
- dn as exportSequenzaPatch,
2798
- ae as extractFields,
2799
- Kn as staticShaders
2991
+ Me as UniformForm,
2992
+ lt as buildEditorState,
2993
+ xn as exportSequenzaPatch,
2994
+ ce as extractFields,
2995
+ it as staticShaders
2800
2996
  };