@kolkrabbi/design-editor 0.45.1 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/{BindDot-DqLgF_zQ.js → BindDot-B85UV79g.js} +9 -8
  2. package/dist/{BufferResource-BfLgK37S.js → BufferResource-Di5teicy.js} +2 -2
  3. package/dist/{CanvasPool-YNSF8hsR.js → CanvasPool-JdLj49b-.js} +1 -1
  4. package/dist/CanvasRenderer-fXDObOOi.js +2 -0
  5. package/dist/{FederatedEventTarget-BJgROaRQ.js → FederatedEventTarget-CH0bzxx1.js} +1 -1
  6. package/dist/{FilterSystem-BUrPNXx-.js → FilterSystem-C-ZoyuTO.js} +3 -3
  7. package/dist/{Geometry-C5s5KpWq.js → Geometry-D4tiuMOr.js} +1 -1
  8. package/dist/KolboxView-n6kEPJtV.js +21615 -0
  9. package/dist/{RenderTargetSystem-oFwWv5IW.js → RenderTargetSystem-Bom_vhlS.js} +1 -1
  10. package/dist/{Timeline-Boo1VuFe.js → Timeline-EbecYeGh.js} +49 -47
  11. package/dist/TreePicker-2RUSyGl4.js +209 -0
  12. package/dist/WebGLRenderer-4hvrGmfW.js +2 -0
  13. package/dist/WebGPURenderer-BjzMV7Pg.js +2 -0
  14. package/dist/__vite-browser-external-y2xWjzgx.js +780 -0
  15. package/dist/browserAll-BFE0MRLW.js +6 -0
  16. package/dist/{canvasUtils-BoNfkAod.js → canvasUtils-DUNsu3ct.js} +1 -1
  17. package/dist/{core-gz2DUq8s.js → core-9UlJPBwX.js} +6331 -6299
  18. package/dist/core.js +6 -5
  19. package/dist/design-editor.css +2 -1
  20. package/dist/design-editor.js +7 -3622
  21. package/dist/{effectCategories-CsCbOfy3.js → effectCategories-CCpYmxS0.js} +8965 -4984
  22. package/dist/effects-DspYFJAM.js +447 -0
  23. package/dist/effects.js +1 -1
  24. package/dist/{generators-BrdP7Omn.js → generators-DY4_ymWh.js} +2394 -2423
  25. package/dist/generators.js +1 -1
  26. package/dist/{getTextureBatchBindGroup-CNWhZRbV.js → getTextureBatchBindGroup-ZMqkwiZS.js} +1 -1
  27. package/dist/{host-BLhWuQ9Y.js → host-0qv2SCjk.js} +1 -1
  28. package/dist/{host-DwC1SsjV.js → host-Bo6itV50.js} +50 -50
  29. package/dist/init-DkGhdexn.js +4 -0
  30. package/dist/{morphStore-Ba--Lk9u.js → morphStore-Bm30Ekce.js} +1 -1
  31. package/dist/{motion-DL5Y98d6.js → motion-BOWE4m3Q.js} +762 -759
  32. package/dist/motion.js +1 -1
  33. package/dist/{pipeline-CMpuPUaX.js → pipeline-hZsOKbHd.js} +12 -12
  34. package/dist/{previewScale-xKmJh3wg.js → previewScale-C6EBx--U.js} +8 -8
  35. package/dist/{rolls-CSOfYXm5.js → rolls-DugKaHUw.js} +10550 -4518
  36. package/dist/src-BlvCHYVY.js +3672 -0
  37. package/dist/{src-BSoHkncc.js → src-D-TQbBo2.js} +1 -2
  38. package/dist/{store-BtEnp5i6.js → store-BMGP1qou.js} +295 -275
  39. package/dist/{useLayerEdit-BCGfD3Cv.js → useLayerEdit-B5nF5I9b.js} +103 -102
  40. package/dist/webworkerAll-0WBQ2FBr.js +2 -0
  41. package/package.json +14 -11
  42. package/dist/CanvasRenderer-Bl0rlqNq.js +0 -2
  43. package/dist/TreePicker-YcrYNUx5.js +0 -166
  44. package/dist/WebGLRenderer-CXxpVIx3.js +0 -2
  45. package/dist/WebGPURenderer-BwLEUYBa.js +0 -2
  46. package/dist/browserAll-CAzdTUbR.js +0 -6
  47. package/dist/chunk-3b4jIN3o.js +0 -13
  48. package/dist/effects-BZ8lWlZa.js +0 -447
  49. package/dist/init-jApIMi04.js +0 -4
  50. package/dist/webworkerAll-DEZhpG90.js +0 -2
@@ -0,0 +1,3672 @@
1
+ import { C as e, E as t, T as n, d as r, o as i, s as a, u as o, w as s } from "./__vite-browser-external-y2xWjzgx.js";
2
+ import { $t as c, B as l, D as u, F as d, Fr as f, Gn as p, I as m, In as h, J as g, Kn as _, L as v, P as y, Xn as b, Xt as x, Zn as S, a as C, bn as w, bt as T, d as E, en as D, er as O, f as k, i as A, ir as j, j as M, n as N, o as ee, p as P, qn as F, r as te, rr as I } from "./rolls-DugKaHUw.js";
3
+ import { n as L, r as R, t as ne } from "./useLayerEdit-B5nF5I9b.js";
4
+ import { C as z, D as B, E as V, _ as H, a as re, c as U, d as ie, f as W, g as ae, i as G, l as oe, m as se, n as ce, r as le, t as ue, u as de, v as fe, w as pe, x as K, y as me } from "./effectCategories-CCpYmxS0.js";
5
+ import { r as he } from "./TreePicker-2RUSyGl4.js";
6
+ import { A as ge, F as _e, I as ve, M as ye, P as be, R as xe, V as Se, _ as Ce, g as we, h as Te, j as Ee, v as De, x as Oe, y as ke, z as Ae } from "./generators-DY4_ymWh.js";
7
+ import { b as je, u as Me } from "./store-BMGP1qou.js";
8
+ import { a as Ne, c as Pe, d as Fe, f as Ie, i as Le, l as Re, n as ze, o as Be, p as Ve, r as He, s as q, t as Ue, u as We } from "./morphStore-Bm30Ekce.js";
9
+ import { n as Ge, r as Ke, t as qe } from "./BindDot-B85UV79g.js";
10
+ import { n as Je, r as Ye } from "./effects-DspYFJAM.js";
11
+ import { c as Xe, d as Ze, l as Qe, n as $e, o as et } from "./motion-BOWE4m3Q.js";
12
+ import { t as tt } from "./Timeline-EbecYeGh.js";
13
+ import { $t as nt, A as rt, At as it, Ct as at, F as ot, J as st, Mt as ct, N as lt, P as ut, Q as dt, R as ft, St as pt, U as mt, W as ht, Zt as gt, _ as _t, an as vt, at as yt, b as bt, bt as xt, c as St, d as Ct, en as wt, f as Tt, fn as Et, g as Dt, gn as Ot, gt as kt, h as At, jt, l as Mt, ln as Nt, m as Pt, mn as Ft, mt as It, nn as Lt, on as Rt, pn as zt, rn as Bt, sn as Vt, st as Ht, t as Ut, tn as Wt, u as Gt } from "./core-9UlJPBwX.js";
14
+ import { Button as J, ButtonGroup as Kt, Divider as qt, LabeledControlSection as Jt, MultiSelect as Yt, NavRail as Xt, StepList as Zt, Tag as Qt, Tooltip as $t, useGrabEdge as en, useMediaQuery as tn, useModal as nn } from "@kolkrabbi/kol-component";
15
+ import { Suspense as rn, createContext as an, lazy as on, useContext as sn, useEffect as Y, useRef as X, useState as Z, useSyncExternalStore as cn } from "react";
16
+ import { Fragment as ln, jsx as Q, jsxs as $ } from "react/jsx-runtime";
17
+ import { IconLoader as un } from "@kolkrabbi/kol-icons";
18
+ import { PropertyRail as dn, RailDisplayControls as fn, RailTrigger as pn } from "@kolkrabbi/kol-shell";
19
+ import { useDragResize as mn, useTheme as hn } from "@kolkrabbi/kol-framework";
20
+ import { createPortal as gn } from "react-dom";
21
+ //#region src/editor/kolbox/host.js
22
+ var _n = {
23
+ client: null,
24
+ store: () => null,
25
+ account: null
26
+ };
27
+ function vn(e) {
28
+ let t = _n.account;
29
+ Object.assign(_n, e), "account" in e && e.account !== t && queueMicrotask(() => window.dispatchEvent(new CustomEvent("kolbox:account")));
30
+ }
31
+ var yn = () => _n.client, bn = (e) => _n.store(e), xn = () => _n.account, Sn = (e) => {
32
+ let t = e, n = /* @__PURE__ */ new Set(), r = (e) => (n.add(e), () => n.delete(e));
33
+ return {
34
+ set: (e) => {
35
+ e !== t && (t = e, n.forEach((e) => e()));
36
+ },
37
+ use: () => cn(r, () => t, () => t)
38
+ };
39
+ }, Cn = Sn(null), wn = Sn(null), Tn = Cn.set;
40
+ Cn.use, wn.set;
41
+ var En = wn.use, Dn = [
42
+ {
43
+ id: "shape",
44
+ label: "Shape",
45
+ icon: "line-circle"
46
+ },
47
+ {
48
+ id: "blend",
49
+ label: "Blend",
50
+ icon: "shaper-scurve"
51
+ },
52
+ {
53
+ id: "crossfade",
54
+ label: "Crossfade",
55
+ icon: "dashed-circle"
56
+ }
57
+ ], On = {
58
+ shape: [
59
+ ["Loops", ["morph-circle", "star-morph"]],
60
+ ["Loops", [
61
+ "square-circle",
62
+ "blob",
63
+ "lissajous"
64
+ ]],
65
+ ["Loops", [
66
+ "morph-circle",
67
+ "star-morph",
68
+ "blob",
69
+ "spiral"
70
+ ]],
71
+ ["Math", ["math-spinner", "math-threads"]],
72
+ ["Field", ["halftone", "checker-field"]],
73
+ ["Flow", ["flow-obstacles", "flow-voronoi"]]
74
+ ],
75
+ crossfade: [
76
+ ["Scanline", ["scanline", "plasma"]],
77
+ ["Scanline", [
78
+ "scanline",
79
+ "flow-charges",
80
+ "math-surface"
81
+ ]],
82
+ ["Field", ["plasma", "math-field"]],
83
+ ["Field", ["gradient-field", "optic-moire"]],
84
+ ["Penrose", ["penrose-02-diffgrow", "flow-growth"]],
85
+ ["Penrose", [
86
+ "penrose-01-packing-lloyd",
87
+ "optic-reaction",
88
+ "abstract-rd",
89
+ "flow-voronoi"
90
+ ]],
91
+ ["Math", ["math-threads", "flow-ascii"]],
92
+ ["Math", ["math-waveform", "scanline"]]
93
+ ],
94
+ blend: [
95
+ [
96
+ "Scanline",
97
+ "scanline",
98
+ 2
99
+ ],
100
+ [
101
+ "Scanline",
102
+ "scanline",
103
+ 3
104
+ ],
105
+ [
106
+ "Field",
107
+ "plasma",
108
+ 2
109
+ ],
110
+ [
111
+ "Math",
112
+ "math-curves",
113
+ 2
114
+ ],
115
+ [
116
+ "Math",
117
+ "math-spinner",
118
+ 4
119
+ ],
120
+ [
121
+ "Optic",
122
+ "optic-moire",
123
+ 2
124
+ ],
125
+ [
126
+ "Flow",
127
+ "flow-obstacles",
128
+ 2
129
+ ]
130
+ ]
131
+ }, kn = null;
132
+ function An(e) {
133
+ if (!kn) {
134
+ kn = /* @__PURE__ */ new Map();
135
+ let e = /* @__PURE__ */ new Set();
136
+ for (let t of se) for (let n of V(t.id)) e.has(n.id) || me(n) || (e.add(n.id), kn.has(n.loop) || kn.set(n.loop, []), kn.get(n.loop).push(n));
137
+ }
138
+ return kn.get(e) ?? [];
139
+ }
140
+ var jn = (e, t) => e.length < t ? null : Array.from({ length: t }, (n, r) => e[Math.round(r * (e.length - 1) / (t - 1))]), Mn = null;
141
+ function Nn() {
142
+ if (Mn) return Mn;
143
+ let e = [];
144
+ for (let t of Dn) for (let n of On[t.id]) {
145
+ let [r] = n, i = t.id === "blend" ? jn(An(n[1]), n[2]) : n[1].map((e) => An(e)[0]);
146
+ if (!i || i.some((e) => !e) || new Set(i.map((e) => e.id)).size < i.length) continue;
147
+ let a = i.map((e) => e.label).join(" → "), o = `ship:morph:${t.id}:${i.map((e) => e.id).join("--")}`;
148
+ e.push({
149
+ id: o,
150
+ type: t.id,
151
+ typeLabel: t.label,
152
+ category: r,
153
+ sub: `${t.label} · ${r}`,
154
+ label: a,
155
+ steps: i,
156
+ morph: {
157
+ mode: t.id,
158
+ loopId: i[0].loop,
159
+ steps: i.map(Ce),
160
+ curve: "in-out",
161
+ cycle: "loop",
162
+ resolution: 0,
163
+ syncLoop: !1,
164
+ seconds: 2 * i.length
165
+ }
166
+ });
167
+ }
168
+ return Mn = e;
169
+ }
170
+ var Pn = () => Dn.map((e) => ({
171
+ label: e.label,
172
+ subs: [...new Set(Nn().filter((t) => t.type === e.id).map((e) => e.sub))]
173
+ })), Fn = (e, t) => Nn().find((n) => n.type === e && (!t || n.category === t)), In = (e) => Nn().find((t) => t.id === e);
174
+ function Ln(e) {
175
+ e && (Be({
176
+ active: !0,
177
+ ...e.morph,
178
+ fileId: null,
179
+ fileName: e.label,
180
+ presetId: e.id
181
+ }), i.setLoopSeconds(e.morph.seconds), /\/morph\/?$/.test(window.location.pathname) || Ft("/morph"));
182
+ }
183
+ //#endregion
184
+ //#region src/editor/labs/catalog.js
185
+ var Rn = {
186
+ "fx:halftone": "ptrn-dot",
187
+ "fx:scanline": "grid-horizontal",
188
+ "fx:crt": "desktop",
189
+ "fx:refraction": "circle",
190
+ "fx:fx-rack": "target",
191
+ "fx:pattern": "ptrn-checker",
192
+ "fx:other": "more",
193
+ "gen:Scanline": "grid-horizontal",
194
+ "gen:Pattern": "ptrn-checker",
195
+ "gen:Loops": "refresh",
196
+ "gen:Math": "sum",
197
+ "gen:Penrose": "a-framed",
198
+ "gen:Flow": "wave",
199
+ "gen:Letter Gap": "letter-spacing",
200
+ "gen:Drift": "dith-flow",
201
+ "gen:Gradients": "circle",
202
+ "gen:Soft Forms": "paint-drop",
203
+ "gen:3D Scene": "ball",
204
+ "kin:Type": "font-01",
205
+ "kin:Kinetic": "font-01",
206
+ "misc:Para Type": "aa",
207
+ "vec:Distressor": "scribble",
208
+ "vec:Modulator": "dashed-circle"
209
+ }, zn = {
210
+ effects: "filter",
211
+ generative: "layers",
212
+ vector: "pen-nib",
213
+ composition: "type",
214
+ morph: "swap",
215
+ mode: "mode-toggle-01"
216
+ }, Bn = [
217
+ "Moiré",
218
+ "Mesh Gradient",
219
+ "Reaction",
220
+ "Halftone"
221
+ ], Vn = [
222
+ {
223
+ label: "Spaced",
224
+ patch: {
225
+ geometry: "rows",
226
+ mark: "dots"
227
+ }
228
+ },
229
+ {
230
+ label: "Glyph",
231
+ patch: { mark: "glyph" }
232
+ },
233
+ {
234
+ label: "Lattice",
235
+ patch: { mark: "lattice" }
236
+ },
237
+ {
238
+ label: "Vortex",
239
+ patch: {
240
+ geometry: "radial",
241
+ swirl: .8,
242
+ rayCount: 220
243
+ }
244
+ },
245
+ {
246
+ label: "Rings",
247
+ patch: { geometry: "rings" }
248
+ },
249
+ {
250
+ label: "Spiral",
251
+ patch: { geometry: "spiral" }
252
+ }
253
+ ], Hn = (e = {}) => {
254
+ let t = e.geometry ?? "rows";
255
+ return t === "radial" ? "Vortex" : t === "rings" ? "Rings" : t === "spiral" ? "Spiral" : e.mark === "glyph" ? "Glyph" : e.mark === "lattice" ? "Lattice" : "Spaced";
256
+ };
257
+ function Un({ layer: e, setOnly: t, addFilter: n, patchFilter: r, carriedSource: i }) {
258
+ let a = () => e?.type === "photo" ? (e.filters ?? []).filter((e) => e?.id === "fx-media") : [], o = (e, o) => {
259
+ let s = a(), c = t("photo", {
260
+ ...i(),
261
+ filters: s,
262
+ fxGroup: null
263
+ });
264
+ c && (n(c, e), o && r(c, s.length, o)), window.dispatchEvent(new CustomEvent("kol:open-effects"));
265
+ }, s = (e) => {
266
+ t("photo", {
267
+ ...i(),
268
+ filters: a(),
269
+ fxGroup: e
270
+ }), window.dispatchEvent(new CustomEvent("kol:open-effects"));
271
+ }, c = (e, n) => {
272
+ t("loop", pe(e, n)), window.dispatchEvent(new CustomEvent("kol:open-params"));
273
+ }, l = (e) => {
274
+ t("kinetic", {
275
+ presetId: e.id,
276
+ presetLabel: e.label,
277
+ comp: Ze(e)
278
+ }), window.dispatchEvent(new CustomEvent("kol:open-params"));
279
+ }, u = e?.presetId ?? null, d = (e?.filters ?? []).find((e) => e?.id !== "fx-media")?.id ?? null, f = u ? V(e?.loopGroup).find((e) => e.id === u) ?? null : null, p = (n, r = "loop", i) => {
280
+ let a = V(n), o = [...new Set(a.map((e) => e.sub).filter(Boolean))], s = (e) => r === "misc" ? () => {
281
+ t("misc", pe(e, n)), window.dispatchEvent(new CustomEvent("kol:open-params"));
282
+ } : () => c(e, n);
283
+ return o.length ? o.map((t) => ({
284
+ label: t,
285
+ onSelect: s(B(n, t)[0]),
286
+ active: e?.loopGroup === n && f?.sub === t
287
+ })) : [{
288
+ label: i ?? H(n).label,
289
+ onSelect: s(a[0]),
290
+ active: e?.loopGroup === n
291
+ }];
292
+ }, m = (e) => e.groups.flatMap((t) => {
293
+ let n = e.labels?.[t] ?? H(t).label, r = V(t).some((e) => e.sub), i = p(t, "loop", n);
294
+ return e.groups.length > 1 && r ? [{
295
+ label: n,
296
+ children: i
297
+ }] : i;
298
+ });
299
+ return [
300
+ {
301
+ id: "color",
302
+ label: "Color",
303
+ icon: "clr-tri",
304
+ onSelect: Me,
305
+ pages: []
306
+ },
307
+ {
308
+ id: "sec:effects",
309
+ label: "Effects"
310
+ },
311
+ ...le(W).map((t) => ({
312
+ id: `fx:${t.id}`,
313
+ label: t.label,
314
+ icon: Rn[`fx:${t.id}`] ?? "square",
315
+ pages: t.rack ? ue.map((t) => ({
316
+ label: t.label,
317
+ onSelect: () => s(t.id),
318
+ active: e?.fxGroup === t.id
319
+ })) : t.id === "pattern" ? Bn.map((t) => ({
320
+ label: t,
321
+ onSelect: () => c(B("optic", t)[0], "optic"),
322
+ active: e?.loopGroup === "optic" && f?.sub === t
323
+ })) : t.id === "scanline" ? Vn.map((t) => ({
324
+ label: t.label,
325
+ onSelect: () => o("scanline", t.patch),
326
+ active: !e?.fxGroup && d === "scanline" && Hn((e?.filters ?? []).find((e) => e?.id === "scanline")?.params) === t.label
327
+ })) : t.filters.map((t) => ({
328
+ label: t.label ?? t.id,
329
+ onSelect: () => o(t.id),
330
+ active: !e?.fxGroup && d === t.id
331
+ }))
332
+ })),
333
+ {
334
+ id: "sec:generative",
335
+ label: "Generative"
336
+ },
337
+ ...Ae.map((e) => ({
338
+ id: `gen:${e.label}`,
339
+ label: e.label,
340
+ icon: Rn[`gen:${e.label}`] ?? "square",
341
+ pages: m(e)
342
+ })),
343
+ {
344
+ id: "sec:morph",
345
+ label: "Morph"
346
+ },
347
+ ...Dn.map((e) => ({
348
+ id: `morph:${e.id}`,
349
+ label: e.label,
350
+ icon: e.icon,
351
+ pages: [...new Set(Nn().filter((t) => t.type === e.id).map((e) => e.category))].map((t) => ({
352
+ label: t,
353
+ onSelect: () => Ln(Fn(e.id, t)),
354
+ active: (() => {
355
+ let n = Nn().find((e) => e.id === ze().presetId);
356
+ return n?.type === e.id && n.category === t;
357
+ })()
358
+ }))
359
+ })),
360
+ {
361
+ id: "sec:vector",
362
+ label: "Vector"
363
+ },
364
+ {
365
+ id: "vec:Distressor",
366
+ label: "Distressor",
367
+ icon: Rn["vec:Distressor"] ?? "square",
368
+ pages: p("distress")
369
+ },
370
+ {
371
+ id: "vec:Modulator",
372
+ label: "Modulator",
373
+ icon: Rn["vec:Modulator"] ?? "square",
374
+ pages: p("modulator")
375
+ },
376
+ {
377
+ id: "sec:composition",
378
+ label: "Composition"
379
+ },
380
+ ...Qe.map((t) => ({
381
+ id: `kin:${t.label}`,
382
+ label: t.label,
383
+ icon: Rn[`kin:${t.label}`] ?? "square",
384
+ pages: t.subs.map((t) => ({
385
+ label: t,
386
+ onSelect: () => l(Xe.find((e) => e.sub === t)),
387
+ active: e?.type === "kinetic" && Xe.some((e) => e.sub === t && e.id === u)
388
+ }))
389
+ })),
390
+ ...Se.map((e) => ({
391
+ id: `misc:${e.label}`,
392
+ label: e.label,
393
+ icon: Rn[`misc:${e.label}`] ?? "square",
394
+ pages: e.groups.flatMap((e) => p(e, "misc"))
395
+ }))
396
+ ];
397
+ }
398
+ //#endregion
399
+ //#region src/editor/labs/LabsNav.jsx
400
+ function Wn() {
401
+ let { addFilter: e, patchFilter: t } = g(), { layer: n, setOnly: r } = De(), i = X(null);
402
+ Y(() => {
403
+ n?.type === "photo" && n.src && (i.current = {
404
+ src: n.src,
405
+ srcType: n.srcType,
406
+ fit: n.fit
407
+ });
408
+ }, [
409
+ n?.type,
410
+ n?.src,
411
+ n?.srcType,
412
+ n?.fit
413
+ ]);
414
+ let a = Un({
415
+ layer: n,
416
+ setOnly: r,
417
+ addFilter: e,
418
+ patchFilter: t,
419
+ carriedSource: () => n?.type === "photo" ? {
420
+ src: n.src,
421
+ srcType: n.srcType,
422
+ fit: n.fit
423
+ } : i.current ?? {}
424
+ });
425
+ return Y(() => {
426
+ let e = /* @__PURE__ */ new Map(), t = [];
427
+ return a.forEach((n) => {
428
+ if (n.id.startsWith("sec:")) {
429
+ let e = n.id.slice(4);
430
+ t.push({
431
+ icon: zn[e] ?? "square",
432
+ path: `${St}${n.id}`,
433
+ label: n.label,
434
+ sub: []
435
+ });
436
+ return;
437
+ }
438
+ let r = `${St}${n.id}`, i = n.pages ?? [], a = n.onSelect ?? i[0]?.onSelect ?? i[0]?.children?.[0]?.onSelect;
439
+ a && e.set(r, a);
440
+ let o = t[t.length - 1], s = {
441
+ icon: n.icon,
442
+ path: r,
443
+ label: n.label
444
+ };
445
+ o?.sub ? o.sub.push(s) : t.push(s);
446
+ }), Mt({
447
+ items: t,
448
+ dispatch: (t) => {
449
+ let n = e.get(t);
450
+ return n ? (n(), !0) : !1;
451
+ }
452
+ }), () => Mt(null);
453
+ }), null;
454
+ }
455
+ //#endregion
456
+ //#region src/editor/morph/MorphTab.jsx
457
+ var Gn = (e, t) => JSON.stringify(e) === JSON.stringify(t), Kn = [
458
+ {
459
+ key: "curve",
460
+ label: "Curve",
461
+ type: "select",
462
+ options: Fe,
463
+ section: "Curve"
464
+ },
465
+ {
466
+ key: "cycle",
467
+ label: "Cycle",
468
+ type: "select",
469
+ options: Ie,
470
+ section: "Curve"
471
+ },
472
+ {
473
+ key: "syncLoop",
474
+ label: "Sync loop",
475
+ type: "toggle",
476
+ section: "Curve"
477
+ },
478
+ {
479
+ key: "resolution",
480
+ label: "Resolution",
481
+ type: "range",
482
+ min: 0,
483
+ max: 1024,
484
+ step: 1,
485
+ default: 0,
486
+ format: (e) => e || "Auto",
487
+ when: (e) => e.mode === "shape"
488
+ }
489
+ ];
490
+ function qn({ layer: e, readOnly: t = !1, editTabs: n = null }) {
491
+ let r = v(), a = We(), { steps: s, curve: c, cycle: l, mode: u, resolution: d, editing: f, fileId: h, editRequest: y } = a, { updateLayer: x, removeLayer: S, setCurrentPresetId: C, setCurrentPresetName: w, palette: T } = g(), { setOnly: E } = De(), { buildSavedSpec: D } = at(), { addItem: O, updateItem: k } = je(), A = nn(), j = o(), M = ne(e?.id ?? null, { history: "coalesce" }), [N, ee] = Z("generate"), P = s[0], F = s.every((e) => e.loopId === P?.loopId), te = s.filter((e) => !jt(K(e.loopId)) || !it(K(e.loopId))), I = te.length === 0, R = {
492
+ blend: F ? null : "Blend tweens one generator — these steps are different generators",
493
+ shape: I ? null : `No outline to morph: ${te.map((e) => Pe(e, s.indexOf(e))).join(", ")} (GL)`,
494
+ crossfade: I ? null : `Cannot fade: ${te.map((e) => Pe(e, s.indexOf(e))).join(", ")} (GL)`
495
+ }, z = [
496
+ {
497
+ value: "shape",
498
+ label: "Shape",
499
+ disabled: !!R.shape,
500
+ tooltip: R.shape ?? void 0
501
+ },
502
+ {
503
+ value: "blend",
504
+ label: "Blend",
505
+ disabled: !!R.blend,
506
+ tooltip: R.blend ?? void 0
507
+ },
508
+ {
509
+ value: "crossfade",
510
+ label: "Crossfade",
511
+ disabled: !!R.crossfade,
512
+ tooltip: R.crossfade ?? void 0
513
+ }
514
+ ];
515
+ Y(() => {
516
+ if (t || s.length < 2 || !R[u]) return;
517
+ let e = [
518
+ "shape",
519
+ "crossfade",
520
+ "blend"
521
+ ].find((e) => !R[e]);
522
+ e && q({ mode: e });
523
+ }, [
524
+ u,
525
+ F,
526
+ I,
527
+ s.length,
528
+ t
529
+ ]), Y(() => {
530
+ !t && s.length === 0 && e?.type === "loop" && e.loopId && !e.morph && Ue(we(e));
531
+ }, []);
532
+ let B = X(s.length), V = () => {
533
+ let t = s.length < B.current;
534
+ if (B.current = s.length, s.length < 2) {
535
+ if (!e || !t) return;
536
+ if (s.length === 0) {
537
+ S(e.id);
538
+ return;
539
+ }
540
+ let n = {};
541
+ for (let t in e) e[t]?.bind === "track" && (n[t] = e[t].keys?.[0]?.v);
542
+ let r = s[0];
543
+ x(e.id, {
544
+ ...n,
545
+ loopGroup: r.loopGroup,
546
+ presetId: r.presetId,
547
+ presetLabel: r.presetLabel,
548
+ loopId: r.loopId,
549
+ ...r.params,
550
+ morph: null,
551
+ morphT: null
552
+ });
553
+ return;
554
+ }
555
+ let n = {
556
+ loopGroup: P.loopGroup,
557
+ presetId: P.presetId,
558
+ presetLabel: P.presetLabel,
559
+ loopId: P.loopId
560
+ }, r = {
561
+ mode: u,
562
+ steps: s.map((e, t) => ({
563
+ loopId: e.loopId,
564
+ params: e.params,
565
+ label: Pe(e, t)
566
+ })),
567
+ cycle: l,
568
+ curve: c,
569
+ resolution: d,
570
+ syncLoop: a.syncLoop,
571
+ name: a.fileName
572
+ }, i = u === "blend" ? {
573
+ ...n,
574
+ ...Ve({
575
+ snapshots: s.map((e) => e.params),
576
+ schema: K(P.loopId)?.params ?? [],
577
+ curve: c,
578
+ cycle: l
579
+ }).patch,
580
+ morph: r,
581
+ morphT: null
582
+ } : {
583
+ ...n,
584
+ ...P.params,
585
+ morph: r,
586
+ morphT: {
587
+ bind: "track",
588
+ keys: ct(s.length, l, c)
589
+ }
590
+ };
591
+ e ? x(e.id, i) : E("loop", i);
592
+ }, H = X(V);
593
+ H.current = V;
594
+ let re = JSON.stringify([
595
+ u,
596
+ s.map((e) => [e.loopId, e.params]),
597
+ c,
598
+ l,
599
+ d,
600
+ a.syncLoop
601
+ ]), U = X(null);
602
+ Y(() => {
603
+ t || f != null || re === U.current || s.length >= 2 && R[u] || (U.current = re, H.current());
604
+ }, [
605
+ re,
606
+ f,
607
+ s.length,
608
+ t
609
+ ]), Y(() => {
610
+ if (t || f == null || !e) return;
611
+ let n = He(e, K(e.loopId)?.params ?? []);
612
+ Gn(n, s[f]?.params) || Re(f, n);
613
+ }, [e]), Y(() => {
614
+ t || !j || f == null || (q({ editing: null }), U.current = null);
615
+ }, [
616
+ j,
617
+ f,
618
+ t
619
+ ]), Y(() => () => {
620
+ !t && a.editing != null && (q({ editing: null }), H.current());
621
+ }, []);
622
+ let ie = (e) => {
623
+ let t = s[e];
624
+ t && (i.pause(), q({ editing: e }), E("loop", {
625
+ loopGroup: t.loopGroup,
626
+ presetId: t.presetId,
627
+ presetLabel: t.presetLabel,
628
+ loopId: t.loopId,
629
+ ...t.params,
630
+ morph: null,
631
+ morphT: null
632
+ }));
633
+ };
634
+ return Y(() => {
635
+ t || y == null || (q({ editRequest: null }), ie(y));
636
+ }, [y]), /* @__PURE__ */ $("div", {
637
+ className: "flex flex-col gap-5",
638
+ children: [
639
+ /* @__PURE__ */ Q(_, {
640
+ layout: "joined",
641
+ tone: "sunken",
642
+ value: u,
643
+ onChange: (e) => !t && q({ mode: e }),
644
+ options: z,
645
+ size: r,
646
+ className: m(r)
647
+ }),
648
+ !t && /* @__PURE__ */ Q(b, {
649
+ divided: !0,
650
+ children: /* @__PURE__ */ Q(he, {
651
+ tree: Pn(),
652
+ presets: Nn(),
653
+ current: In(a.presetId) ?? { typeLabel: Dn.find((e) => e.id === u)?.label },
654
+ subLabel: (e) => e.split(" · ").pop(),
655
+ onPick: Ln
656
+ })
657
+ }),
658
+ /* @__PURE__ */ $(b, {
659
+ divided: !0,
660
+ children: [
661
+ /* @__PURE__ */ Q(Zt, {
662
+ items: s.map((e, t) => ({
663
+ id: t,
664
+ label: Pe(e, t)
665
+ })),
666
+ activeIndex: f,
667
+ reorder: "grab",
668
+ readOnly: t,
669
+ size: r,
670
+ onSelect: ie,
671
+ onRemove: Le,
672
+ onMove: Ne,
673
+ onAdd: () => q({
674
+ active: !0,
675
+ picker: "preset"
676
+ }),
677
+ addLabel: "Add a step"
678
+ }),
679
+ s.length < 2 && !t && /* @__PURE__ */ Q("p", {
680
+ className: "kol-mono-12 text-meta",
681
+ children: "Two steps or more and the stage plays the morph."
682
+ }),
683
+ s.length >= 2 && R[u] && /* @__PURE__ */ Q("p", {
684
+ className: "kol-mono-12 text-meta",
685
+ children: R[u]
686
+ })
687
+ ]
688
+ }),
689
+ f != null && !t && e && n && /* @__PURE__ */ $(b, {
690
+ label: `Step ${f + 1}`,
691
+ divided: !0,
692
+ children: [
693
+ /* @__PURE__ */ Q(_, {
694
+ layout: "joined",
695
+ tone: "sunken",
696
+ value: N,
697
+ onChange: ee,
698
+ options: n,
699
+ size: r,
700
+ className: m(r)
701
+ }),
702
+ /* @__PURE__ */ Q(ke, {
703
+ layer: e,
704
+ setProp: M.setProp,
705
+ patch: M.patch,
706
+ updateLayer: x,
707
+ palette: T,
708
+ tab: N,
709
+ tabStrip: null,
710
+ inline: !0,
711
+ picker: !1
712
+ }),
713
+ /* @__PURE__ */ $("p", {
714
+ className: "kol-mono-12 text-emphasis",
715
+ children: [
716
+ "Editing step ",
717
+ f + 1,
718
+ " — press Play to run the morph."
719
+ ]
720
+ })
721
+ ]
722
+ }),
723
+ /* @__PURE__ */ Q(L, {
724
+ schema: Kn,
725
+ layer: a,
726
+ setProp: (e, n) => {
727
+ !t && (typeof n != "object" || !n) && q({ [e]: n });
728
+ },
729
+ inline: !0
730
+ }),
731
+ !t && s.length >= 2 && /* @__PURE__ */ Q(b, {
732
+ divided: !0,
733
+ children: /* @__PURE__ */ Q(p, {
734
+ tone: "primary",
735
+ size: r,
736
+ className: "w-full",
737
+ onClick: async () => {
738
+ if (s.length < 2) return;
739
+ let e = a.fileName;
740
+ if (!h && (e = await A.prompt("Name this morph:", ""), e === null)) return;
741
+ f != null && (q({ editing: null }), H.current());
742
+ let t = {
743
+ ...await D(e || null),
744
+ mode: "morph",
745
+ morph: {
746
+ mode: u,
747
+ loopId: a.loopId,
748
+ steps: s,
749
+ curve: c,
750
+ cycle: l,
751
+ resolution: d,
752
+ syncLoop: a.syncLoop,
753
+ seconds: i.getLoopSeconds()
754
+ }
755
+ };
756
+ if (h) {
757
+ k("preset", h, t);
758
+ return;
759
+ }
760
+ let n = O("preset", t);
761
+ n && (q({
762
+ fileId: n,
763
+ fileName: e || null
764
+ }), C(n), w(e || null));
765
+ },
766
+ children: h ? "Save" : "Save…"
767
+ })
768
+ })
769
+ ]
770
+ });
771
+ }
772
+ //#endregion
773
+ //#region src/editor/params/QuickMotion.jsx
774
+ var Jn = [
775
+ {
776
+ value: "breathe",
777
+ label: "Breathe",
778
+ source: "lfo-sine",
779
+ rate: 1
780
+ },
781
+ {
782
+ value: "sweep",
783
+ label: "Sweep",
784
+ source: "lfo-triangle",
785
+ rate: 1
786
+ },
787
+ {
788
+ value: "jitter",
789
+ label: "Jitter",
790
+ source: "lfo-square",
791
+ rate: 8
792
+ }
793
+ ], Yn = .2;
794
+ function Xn(e) {
795
+ if (!u(e)) return "off";
796
+ if (e.bind !== "mod") return "custom";
797
+ let t = Jn.find((t) => t.source === e.source && (e.transform?.rate ?? 1) === t.rate);
798
+ return t ? t.value : "custom";
799
+ }
800
+ function Zn({ schema: e, layer: t, setProp: n, label: r = "Modulate" }) {
801
+ let a = v(), o = D(e ?? [], t).filter((e) => e.type === "range" && e.animatable !== !1 && c(e) !== "anim" && e.min != null && e.max != null && !/seed/i.test(e.key));
802
+ if (!o.length) return null;
803
+ let s = (e, r) => {
804
+ let a = t[e.key];
805
+ if (r === "off") {
806
+ let r = a?.transform?.range;
807
+ n(e.key, Array.isArray(r) ? (r[0] + r[1]) / 2 : M(a, i.getCtx(), t) ?? e.default ?? e.min);
808
+ return;
809
+ }
810
+ let o = Jn.find((e) => e.value === r);
811
+ if (!o) return;
812
+ let s = Number(M(a, i.getCtx(), t) ?? e.default ?? e.min), c = (e.max - e.min) * Yn, l = Math.max(e.min, s - c), u = Math.min(e.max, s + c);
813
+ n(e.key, {
814
+ bind: "mod",
815
+ source: o.source,
816
+ transform: {
817
+ range: [l, u],
818
+ rate: o.rate
819
+ }
820
+ });
821
+ };
822
+ return /* @__PURE__ */ Q(b, {
823
+ label: r,
824
+ divided: !0,
825
+ children: o.map((e) => {
826
+ let n = Xn(t[e.key]), r = [
827
+ {
828
+ value: "off",
829
+ label: "Off"
830
+ },
831
+ ...Jn.map(({ value: e, label: t }) => ({
832
+ value: e,
833
+ label: t
834
+ })),
835
+ ...n === "custom" ? [{
836
+ value: "custom",
837
+ label: "Custom"
838
+ }] : []
839
+ ];
840
+ return /* @__PURE__ */ Q(S, {
841
+ label: e.label,
842
+ align: "fill",
843
+ labelWidth: d,
844
+ children: /* @__PURE__ */ Q(F, {
845
+ size: a,
846
+ variant: "subtle",
847
+ className: "w-full",
848
+ options: r,
849
+ value: n,
850
+ onChange: (t) => t !== "custom" && s(e, t)
851
+ })
852
+ }, e.key);
853
+ })
854
+ });
855
+ }
856
+ //#endregion
857
+ //#region src/editor/params/InputRows.jsx
858
+ var Qn = [
859
+ {
860
+ value: "off",
861
+ label: "Off"
862
+ },
863
+ {
864
+ value: "mouseX",
865
+ label: "Mouse X"
866
+ },
867
+ {
868
+ value: "mouseY",
869
+ label: "Mouse Y"
870
+ },
871
+ {
872
+ value: "audio-level",
873
+ label: "Mic"
874
+ },
875
+ {
876
+ value: "audio-bass",
877
+ label: "Beat"
878
+ },
879
+ {
880
+ value: "lfo-sine",
881
+ label: "LFO"
882
+ }
883
+ ], $n = new Set(Qn.map((e) => e.value));
884
+ function er({ schema: e, layer: t, setProp: n, inputs: a = null }) {
885
+ let o = v(), s = D(e ?? [], t).filter((e) => e.type === "range" && e.animatable !== !1 && e.min != null && e.max != null && !/seed/i.test(e.key));
886
+ if (!s.length) return null;
887
+ let c = new Map(s.map((e) => [e.key, e])), l = (a ?? []).filter((e) => c.has(e)), d = [...l, ...s.map((e) => e.key).filter((e) => !l.includes(e))], f = l.length ? l : d.slice(0, 3), m = (e) => {
888
+ let n = t[e];
889
+ return u(n) && n.bind === "mod" && $n.has(n.source);
890
+ }, h = d.filter(m), g = (e) => {
891
+ let n = c.get(e);
892
+ return Number(M(t[e], i.getCtx(), t) ?? n.default ?? n.min);
893
+ }, _ = (e, i, a = u(t[e]) ? t[e].transform?.base ?? g(e) : g(e)) => {
894
+ let o = c.get(e);
895
+ r(i)?.ensure?.().catch(() => {}), n(e, {
896
+ bind: "mod",
897
+ source: i,
898
+ transform: {
899
+ range: [o.min, o.max],
900
+ base: a,
901
+ ...i.startsWith("lfo") ? { rate: 1 } : {}
902
+ }
903
+ });
904
+ }, y = (e) => n(e, u(t[e]) ? t[e].transform?.base ?? g(e) : g(e)), x = f.find((e) => !m(e)) ?? d.find((e) => !m(e));
905
+ return /* @__PURE__ */ $(b, {
906
+ label: "Inputs",
907
+ divided: !0,
908
+ children: [h.map((e) => /* @__PURE__ */ Q(Yt, {
909
+ size: o,
910
+ className: "w-full [&>button]:w-full",
911
+ groups: [{
912
+ id: "source",
913
+ label: "Source",
914
+ options: Qn
915
+ }, {
916
+ id: "drives",
917
+ label: "Drives",
918
+ options: d.map((e) => ({
919
+ value: e,
920
+ label: c.get(e).label + (f.includes(e) ? " ★" : "")
921
+ }))
922
+ }],
923
+ value: {
924
+ source: t[e].source,
925
+ drives: e
926
+ },
927
+ label: `${Qn.find((n) => n.value === t[e].source)?.label} → ${c.get(e).label}`,
928
+ onChange: (n, r) => {
929
+ if (n === "source") {
930
+ r === "off" ? y(e) : _(e, r);
931
+ return;
932
+ }
933
+ if (r === e || m(r)) return;
934
+ let i = t[e].source;
935
+ y(e), _(r, i);
936
+ }
937
+ }, e)), x && /* @__PURE__ */ Q(p, {
938
+ size: o,
939
+ iconLeft: "plus",
940
+ className: "w-full",
941
+ onClick: () => _(x, "mouseX"),
942
+ children: "Add input"
943
+ })]
944
+ });
945
+ }
946
+ //#endregion
947
+ //#region src/editor/labs/ModelSource.jsx
948
+ var tr = /\.(obj|glb|gltf|stl)$/i, nr = (e) => tr.test(e.key ?? e.name ?? ""), rr = (e) => (e.match(tr)?.[1] ?? "obj").toLowerCase(), ir = (e) => e?.startsWith("data:") ? "Local file" : decodeURIComponent(String(e ?? "").split("/").pop() || "—");
949
+ function ar({ layer: e, setProp: t }) {
950
+ let n = v(), [r, i] = Z(!1), a = X(null), o = (e, n) => {
951
+ t("meshSrc", e), t("meshType", n);
952
+ };
953
+ return /* @__PURE__ */ $(b, {
954
+ label: "Model",
955
+ divided: !0,
956
+ children: [
957
+ /* @__PURE__ */ Q("span", {
958
+ className: "kol-mono-12 text-meta truncate",
959
+ children: ir(e.meshSrc)
960
+ }),
961
+ /* @__PURE__ */ $("div", {
962
+ className: "grid grid-cols-2 gap-2",
963
+ children: [/* @__PURE__ */ Q(p, {
964
+ tone: "primary",
965
+ size: n,
966
+ onClick: () => i(!0),
967
+ children: "From library"
968
+ }), /* @__PURE__ */ Q(p, {
969
+ tone: "primary",
970
+ size: n,
971
+ onClick: () => a.current?.click(),
972
+ children: "Upload"
973
+ })]
974
+ }),
975
+ /* @__PURE__ */ Q("input", {
976
+ ref: a,
977
+ type: "file",
978
+ accept: ".obj,.glb,.gltf,.stl",
979
+ className: "hidden",
980
+ onChange: (e) => {
981
+ let t = e.target.files?.[0];
982
+ if (e.target.value = "", !t) return;
983
+ let n = new FileReader();
984
+ n.onload = () => o(n.result, rr(t.name)), n.readAsDataURL(t);
985
+ }
986
+ }),
987
+ /* @__PURE__ */ Q(bt, {
988
+ open: r,
989
+ accept: nr,
990
+ onClose: () => i(!1),
991
+ onSelect: (e) => {
992
+ i(!1), o(lt(e), rr(e));
993
+ }
994
+ })
995
+ ]
996
+ });
997
+ }
998
+ //#endregion
999
+ //#region src/editor/labs/useLabsKeys.js
1000
+ function or(e, t) {
1001
+ Y(() => {
1002
+ let n = (n) => {
1003
+ n.key !== "r" && n.key !== "R" || n.metaKey || n.ctrlKey || n.altKey || kt(n) || (n.preventDefault(), n.shiftKey ? t?.() : e?.());
1004
+ };
1005
+ return window.addEventListener("keydown", n), () => window.removeEventListener("keydown", n);
1006
+ });
1007
+ }
1008
+ //#endregion
1009
+ //#region src/editor/labs/LabsParams.jsx
1010
+ var sr = [{
1011
+ value: "effect",
1012
+ label: "Effect"
1013
+ }, {
1014
+ value: "anim",
1015
+ label: "Motion"
1016
+ }], cr = [
1017
+ {
1018
+ value: "generate",
1019
+ label: "Generate"
1020
+ },
1021
+ {
1022
+ value: "style",
1023
+ label: "Style"
1024
+ },
1025
+ {
1026
+ value: "anim",
1027
+ label: "Animation"
1028
+ }
1029
+ ], lr = [
1030
+ {
1031
+ value: "generate",
1032
+ label: "Gen"
1033
+ },
1034
+ {
1035
+ value: "style",
1036
+ label: "Style"
1037
+ },
1038
+ {
1039
+ value: "anim",
1040
+ label: "Anim"
1041
+ }
1042
+ ];
1043
+ function ur({ options: e, active: t, onPick: n, spread: r = !1, pills: i = !1 }) {
1044
+ let a = v();
1045
+ return e?.length ? i ? /* @__PURE__ */ Q("div", {
1046
+ className: "flex items-center gap-1 flex-wrap",
1047
+ children: e.map((e) => /* @__PURE__ */ Q(Qt, {
1048
+ size: "xs",
1049
+ hash: !1,
1050
+ active: e.value === t,
1051
+ onClick: () => n(e.value),
1052
+ children: e.label
1053
+ }, e.value))
1054
+ }) : /* @__PURE__ */ Q(_, {
1055
+ layout: "joined",
1056
+ tone: "sunken",
1057
+ value: t ?? null,
1058
+ onChange: n,
1059
+ options: e,
1060
+ size: a,
1061
+ ariaLabel: "Siblings",
1062
+ className: m(a)
1063
+ }) : null;
1064
+ }
1065
+ function dr() {
1066
+ let { undo: e, redo: t, canUndo: n, canRedo: r } = g(), i = v(), a = (e, t) => e ? t : /* @__PURE__ */ Q("span", {
1067
+ "aria-hidden": "true",
1068
+ className: "invisible pointer-events-none",
1069
+ children: t
1070
+ });
1071
+ return /* @__PURE__ */ $(ln, { children: [a(n, /* @__PURE__ */ Q($t, {
1072
+ label: "Undo",
1073
+ shortcut: "⌘Z",
1074
+ children: /* @__PURE__ */ Q(p, {
1075
+ size: i,
1076
+ iconOnly: "arrow-left",
1077
+ "aria-label": "Undo",
1078
+ tabIndex: n ? void 0 : -1,
1079
+ onClick: e
1080
+ })
1081
+ })), a(r, /* @__PURE__ */ Q($t, {
1082
+ label: "Redo",
1083
+ shortcut: "⇧⌘Z",
1084
+ children: /* @__PURE__ */ Q(p, {
1085
+ size: i,
1086
+ iconOnly: "arrow-right",
1087
+ "aria-label": "Redo",
1088
+ tabIndex: r ? void 0 : -1,
1089
+ onClick: t
1090
+ })
1091
+ }))] });
1092
+ }
1093
+ function fr({ chips: e, active: t, onPick: n, spread: r, pills: i, title: a, tabStrip: o, preStrip: s, fx: c = !1, scope: l, ghostLabels: u, children: f }) {
1094
+ let p = v() === "sm", m = j() === "float";
1095
+ return /* @__PURE__ */ $("div", {
1096
+ className: `flex flex-col gap-5${c ? " kol-labs-fx" : ""}`,
1097
+ "data-label-scope": l,
1098
+ children: [
1099
+ a && p && /* @__PURE__ */ $("div", {
1100
+ className: "flex items-center gap-1",
1101
+ children: [/* @__PURE__ */ Q("p", {
1102
+ className: `${m ? "kol-float-label text-fg-emphasis" : "kol-eyebrow text-fg-96"} flex-1 min-w-0`,
1103
+ children: a
1104
+ }), /* @__PURE__ */ Q(dr, {})]
1105
+ }),
1106
+ e && /* @__PURE__ */ Q(ur, {
1107
+ options: e,
1108
+ active: t,
1109
+ onPick: n,
1110
+ spread: r,
1111
+ pills: i
1112
+ }),
1113
+ s,
1114
+ o,
1115
+ f,
1116
+ u?.length > 0 && /* @__PURE__ */ Q("div", {
1117
+ "aria-hidden": "true",
1118
+ className: "invisible h-0 overflow-hidden flex flex-col",
1119
+ children: u.map((e, t) => /* @__PURE__ */ Q("span", {
1120
+ className: "kol-helper-10 tracking-widest whitespace-nowrap",
1121
+ style: { width: d },
1122
+ children: String(e).toUpperCase()
1123
+ }, t))
1124
+ })
1125
+ ]
1126
+ });
1127
+ }
1128
+ function pr({ layer: e, showMod: n }) {
1129
+ let r = t(), i = v(), [a, o] = Z("effect");
1130
+ Y(() => {
1131
+ let e = () => o("effect");
1132
+ return window.addEventListener("kol:open-effects", e), () => window.removeEventListener("kol:open-effects", e);
1133
+ }, []);
1134
+ let { addFilter: l, replaceFilter: u, removeFilter: f, toggleFilter: h, updateLayer: y, palette: w } = g(), T = ne(e.id, { history: "coalesce" }), E = x(e), D = E.findIndex((e) => !e.def?.first), O = D < 0 ? E.length : D, A = D < 0 ? null : E[D], j = le(W).find((e) => e.id === ce(A?.id)), M = j?.id === "halftone", ee = M ? (j?.filters ?? []).map((e) => ({
1135
+ value: e.id,
1136
+ label: e.label
1137
+ })) : null, te = !M && A ? A.def.label : null, I = (t) => {
1138
+ if (!A) {
1139
+ l(e.id, t);
1140
+ return;
1141
+ }
1142
+ t !== A.id && u(e.id, O, t);
1143
+ }, z = E.map(({ def: e, ...t }) => t), B = A ? {
1144
+ ...e,
1145
+ ...A.params,
1146
+ id: e.id
1147
+ } : e, V = (e) => (t, n) => {
1148
+ let r = z.map((r, i) => i === e ? {
1149
+ ...r,
1150
+ params: {
1151
+ ...r.params,
1152
+ [t]: n
1153
+ }
1154
+ } : r);
1155
+ T.patch({ filters: r });
1156
+ }, H = V(O), re = n ? (e) => /* @__PURE__ */ Q(qe, {
1157
+ layer: B,
1158
+ param: e,
1159
+ setProp: H
1160
+ }) : void 0, U = (t) => {
1161
+ let n = z.map((e, n) => n === O ? {
1162
+ ...e,
1163
+ params: {
1164
+ ...e.params,
1165
+ ...t
1166
+ }
1167
+ } : e);
1168
+ y(e.id, { filters: n });
1169
+ };
1170
+ or(() => {
1171
+ A && y(e.id, { filters: z.map((e, t) => t === 0 ? {
1172
+ ...e,
1173
+ params: {}
1174
+ } : e) });
1175
+ }, () => {
1176
+ A && U(C(B, N(A.def.params, B), P()));
1177
+ });
1178
+ let ae = e.fxGroup ? ue.find((t) => t.id === e.fxGroup) : null;
1179
+ if (ae) {
1180
+ let t = {
1181
+ chain: E,
1182
+ layer: e,
1183
+ hostView: B,
1184
+ toggleFilter: h,
1185
+ removeFilter: f,
1186
+ setStagePropAt: V,
1187
+ palette: w,
1188
+ showMod: n
1189
+ }, r = [{
1190
+ value: "",
1191
+ label: "Add effect…"
1192
+ }, ...ie(ae, W).map((e) => ({
1193
+ value: e.id,
1194
+ label: `${e.label ?? e.id}${e.kind === "pixi" ? " · GPU" : ""}`
1195
+ }))];
1196
+ return /* @__PURE__ */ $(fr, {
1197
+ title: "Effects",
1198
+ fx: !0,
1199
+ tabStrip: /* @__PURE__ */ Q(_, {
1200
+ layout: "joined",
1201
+ tone: "sunken",
1202
+ value: a,
1203
+ onChange: o,
1204
+ options: sr,
1205
+ size: i,
1206
+ className: m(i)
1207
+ }),
1208
+ children: [a === "effect" && /* @__PURE__ */ $(ln, { children: [
1209
+ /* @__PURE__ */ $(b, {
1210
+ label: "Effect stack",
1211
+ divided: !0,
1212
+ children: [E.length === 0 && /* @__PURE__ */ Q(R, {
1213
+ className: "kol-mono-10 text-meta",
1214
+ children: "No effects yet — add one below."
1215
+ }), /* @__PURE__ */ Q(_r, {
1216
+ ...t,
1217
+ from: 0
1218
+ })]
1219
+ }),
1220
+ /* @__PURE__ */ Q(qt, {}),
1221
+ E.length < 8 && /* @__PURE__ */ Q(b, {
1222
+ label: ae.label,
1223
+ divided: !0,
1224
+ children: /* @__PURE__ */ Q(F, {
1225
+ variant: "subtle",
1226
+ size: i,
1227
+ className: "w-full",
1228
+ options: r,
1229
+ value: "",
1230
+ onChange: (t) => {
1231
+ t && l(e.id, t);
1232
+ }
1233
+ })
1234
+ })
1235
+ ] }), a === "anim" && A?.def?.sweeps && /* @__PURE__ */ Q(Ye, {
1236
+ sweeps: Array.isArray(A.params.sweeps) ? A.params.sweeps : [],
1237
+ onChange: (e) => H("sweeps", e),
1238
+ inline: !0
1239
+ })]
1240
+ });
1241
+ }
1242
+ if (!A) return /* @__PURE__ */ Q(fr, {
1243
+ chips: ee,
1244
+ active: null,
1245
+ onPick: I,
1246
+ spread: M,
1247
+ fx: !0,
1248
+ tabStrip: /* @__PURE__ */ Q(_, {
1249
+ layout: "joined",
1250
+ tone: "sunken",
1251
+ value: a,
1252
+ onChange: o,
1253
+ options: sr,
1254
+ size: i,
1255
+ className: m(i)
1256
+ }),
1257
+ children: /* @__PURE__ */ Q(L, {
1258
+ schema: _t,
1259
+ layer: e,
1260
+ setProp: T.setProp,
1261
+ palette: w,
1262
+ renderAnimate: (t) => /* @__PURE__ */ Q(qe, {
1263
+ layer: e,
1264
+ param: t,
1265
+ setProp: T.setProp
1266
+ }),
1267
+ tab: a === "anim" ? "anim" : "style",
1268
+ emptyHint: "Pick an effect from the nav."
1269
+ })
1270
+ });
1271
+ let G = A.def.params.filter((e) => c(e) !== "anim"), se = oe(A.def.id), fe = se ? G.findIndex((e) => e.key === se) : -1, pe = G.length;
1272
+ if (fe >= 0) {
1273
+ let e = fe;
1274
+ for (; e + 1 < G.length && G[e + 1].type === "select";) e++;
1275
+ pe = e + 1;
1276
+ }
1277
+ let K = fe > 0 ? G.slice(0, fe) : [], me = fe >= 0 ? G.slice(fe, pe).map((e) => ({
1278
+ ...e,
1279
+ section: void 0
1280
+ })) : G, he = {
1281
+ layer: B,
1282
+ setProp: H,
1283
+ palette: w,
1284
+ renderAnimate: re,
1285
+ inline: !0
1286
+ };
1287
+ return /* @__PURE__ */ $(fr, {
1288
+ chips: ee,
1289
+ active: A.id,
1290
+ onPick: I,
1291
+ spread: M,
1292
+ title: te,
1293
+ fx: !0,
1294
+ scope: A.id,
1295
+ ghostLabels: A.def.params.map((e) => e.label).filter(Boolean),
1296
+ tabStrip: /* @__PURE__ */ Q(_, {
1297
+ layout: "joined",
1298
+ tone: "sunken",
1299
+ value: a,
1300
+ onChange: o,
1301
+ options: sr,
1302
+ size: i,
1303
+ className: m(i)
1304
+ }),
1305
+ children: [a === "effect" && /* @__PURE__ */ $(ln, { children: [
1306
+ K.length > 0 && /* @__PURE__ */ Q(L, {
1307
+ schema: K,
1308
+ ...he
1309
+ }),
1310
+ /* @__PURE__ */ $(b, {
1311
+ divided: !0,
1312
+ children: [/* @__PURE__ */ Q(L, {
1313
+ schema: me,
1314
+ ...he
1315
+ }), /* @__PURE__ */ Q(Je, {
1316
+ inline: !0,
1317
+ def: A.def,
1318
+ view: B,
1319
+ tab: "effect",
1320
+ onPatch: U,
1321
+ levels: /* @__PURE__ */ $(ln, { children: [
1322
+ [
1323
+ ["type", "Type"],
1324
+ ["category", "Category"],
1325
+ ["preset", "Preset"]
1326
+ ].filter(([e]) => ye(A.def, e)).map(([t, n]) => /* @__PURE__ */ Q(p, {
1327
+ tone: "primary",
1328
+ size: i,
1329
+ className: "flex-1 min-w-0",
1330
+ "aria-label": `Randomize ${n.toLowerCase()}`,
1331
+ onClick: () => {
1332
+ let n = k(P() >>> 0);
1333
+ if (t === "preset") {
1334
+ let e = ve(A.def, B, n);
1335
+ e != null && U(de(A.def, e));
1336
+ return;
1337
+ }
1338
+ let r = _e(A.id, t, n);
1339
+ r && u(e.id, O, r);
1340
+ },
1341
+ children: n
1342
+ }, t)),
1343
+ /* @__PURE__ */ Q(p, {
1344
+ tone: "primary",
1345
+ size: i,
1346
+ className: "flex-1 min-w-0",
1347
+ "aria-label": "Randomize settings",
1348
+ onClick: () => {
1349
+ U(be(B, N(A.def.params.filter((e) => c(e) !== "anim"), B), k(P() >>> 0)));
1350
+ },
1351
+ children: "Settings"
1352
+ }),
1353
+ /* @__PURE__ */ Q(Oe, {
1354
+ def: A.def,
1355
+ isFilter: !0
1356
+ })
1357
+ ] })
1358
+ })]
1359
+ }),
1360
+ /* @__PURE__ */ Q(qt, {}),
1361
+ pe < G.length && /* @__PURE__ */ $(ln, { children: [/* @__PURE__ */ Q(L, {
1362
+ schema: G.slice(pe),
1363
+ ...he
1364
+ }), /* @__PURE__ */ Q(qt, {})] }),
1365
+ /* @__PURE__ */ Q(vr, {
1366
+ chain: E,
1367
+ from: O + 1,
1368
+ layer: e,
1369
+ hostView: B,
1370
+ addFilter: l,
1371
+ removeFilter: f,
1372
+ toggleFilter: h,
1373
+ setStagePropAt: V,
1374
+ palette: w,
1375
+ showMod: n
1376
+ })
1377
+ ] }), a === "anim" && /* @__PURE__ */ $(ln, { children: [
1378
+ /* @__PURE__ */ Q(er, {
1379
+ schema: A.def.params,
1380
+ layer: B,
1381
+ setProp: H,
1382
+ inputs: A.def.inputs
1383
+ }),
1384
+ /* @__PURE__ */ Q(L, {
1385
+ schema: A.def.params,
1386
+ ...he,
1387
+ tab: "anim"
1388
+ }),
1389
+ A.def.orbit && /* @__PURE__ */ Q(b, {
1390
+ label: "Interaction",
1391
+ divided: !0,
1392
+ children: /* @__PURE__ */ Q(S, {
1393
+ label: "ORBIT (C)",
1394
+ align: "fill",
1395
+ labelWidth: d,
1396
+ children: /* @__PURE__ */ Q(_, {
1397
+ layout: "joined",
1398
+ tone: "sunken",
1399
+ size: i,
1400
+ className: "w-full",
1401
+ value: r.grab && B.orbit !== !1 ? "on" : "off",
1402
+ options: [{
1403
+ value: "off",
1404
+ label: "Off"
1405
+ }, {
1406
+ value: "on",
1407
+ label: "On"
1408
+ }],
1409
+ onChange: (e) => {
1410
+ H("orbit", e === "on"), e === "on" && !r.grab && s("grab", !0);
1411
+ }
1412
+ })
1413
+ })
1414
+ }),
1415
+ /* @__PURE__ */ Q(b, {
1416
+ divided: !0,
1417
+ children: /* @__PURE__ */ Q(Je, {
1418
+ inline: !0,
1419
+ def: A.def,
1420
+ view: B,
1421
+ tab: "anim",
1422
+ onPatch: U
1423
+ })
1424
+ }),
1425
+ A.def.sweeps && /* @__PURE__ */ Q(Ye, {
1426
+ sweeps: Array.isArray(A.params.sweeps) ? A.params.sweeps : [],
1427
+ onChange: (e) => H("sweeps", e),
1428
+ inline: !0
1429
+ }),
1430
+ /* @__PURE__ */ Q(Zn, {
1431
+ schema: A.def.params,
1432
+ layer: B,
1433
+ setProp: H
1434
+ }),
1435
+ /* @__PURE__ */ Q(gr, {
1436
+ chain: E,
1437
+ layer: e,
1438
+ hostView: B,
1439
+ addFilter: l,
1440
+ removeFilter: f,
1441
+ setStagePropAt: V,
1442
+ palette: w,
1443
+ showMod: n
1444
+ })
1445
+ ] })]
1446
+ });
1447
+ }
1448
+ var mr = W.filter((e) => !e.kind && !e.first);
1449
+ function hr({ layer: e, edit: t, palette: n, showMod: r }) {
1450
+ let { addFilter: i, removeFilter: a, toggleFilter: o } = g(), s = x(e), c = s.map(({ def: e, ...t }) => t);
1451
+ return /* @__PURE__ */ Q(vr, {
1452
+ chain: s,
1453
+ from: 0,
1454
+ filters: mr,
1455
+ layer: e,
1456
+ hostView: e,
1457
+ addFilter: i,
1458
+ removeFilter: a,
1459
+ toggleFilter: o,
1460
+ setStagePropAt: (e) => (n, r) => t.patch({ filters: c.map((t, i) => i === e ? {
1461
+ ...t,
1462
+ params: {
1463
+ ...t.params,
1464
+ [n]: r
1465
+ }
1466
+ } : t) }),
1467
+ palette: n,
1468
+ showMod: r
1469
+ });
1470
+ }
1471
+ function gr({ chain: e, layer: t, hostView: n, addFilter: r, removeFilter: i, setStagePropAt: a, palette: o, showMod: s }) {
1472
+ let c = v(), l = e.findIndex((e) => e.id === "fx-media"), u = l < 0 ? null : e[l], d = u ? {
1473
+ ...n,
1474
+ ...u.params,
1475
+ id: t.id
1476
+ } : null, f = u ? a(l) : null;
1477
+ return /* @__PURE__ */ Q(b, {
1478
+ label: "Media",
1479
+ divided: !0,
1480
+ children: u?.def ? /* @__PURE__ */ $(ln, { children: [/* @__PURE__ */ Q(L, {
1481
+ schema: u.def.params,
1482
+ layer: d,
1483
+ setProp: f,
1484
+ palette: o,
1485
+ inline: !0,
1486
+ renderAnimate: s ? (e) => /* @__PURE__ */ Q(qe, {
1487
+ layer: d,
1488
+ param: e,
1489
+ setProp: f
1490
+ }) : void 0
1491
+ }), /* @__PURE__ */ Q(p, {
1492
+ tone: "primary",
1493
+ size: c,
1494
+ className: "w-full",
1495
+ iconLeft: "x",
1496
+ iconSize: 12,
1497
+ onClick: () => i(t.id, l),
1498
+ children: "Remove media motion"
1499
+ })] }) : e.length < 8 && /* @__PURE__ */ Q(p, {
1500
+ tone: "primary",
1501
+ size: c,
1502
+ className: "w-full",
1503
+ iconLeft: "plus",
1504
+ iconSize: 12,
1505
+ onClick: () => r(t.id, "fx-media"),
1506
+ children: "Add media motion"
1507
+ })
1508
+ });
1509
+ }
1510
+ function _r({ chain: e, from: t = 0, layer: n, hostView: r, toggleFilter: i, removeFilter: a, setStagePropAt: o, palette: s, showMod: l }) {
1511
+ let u = v();
1512
+ return e.slice(t).map((e, d) => {
1513
+ let f = d + t, m = e.enabled !== !1, h = {
1514
+ ...r,
1515
+ ...e.params,
1516
+ id: n.id
1517
+ }, g = o(f);
1518
+ return /* @__PURE__ */ $("div", {
1519
+ className: "flex flex-col gap-2 p-2 rounded bg-oq-04",
1520
+ children: [/* @__PURE__ */ $("div", {
1521
+ className: "flex items-center gap-2",
1522
+ children: [/* @__PURE__ */ Q(O, {
1523
+ size: u,
1524
+ checked: m,
1525
+ onChange: () => i(n.id, f),
1526
+ label: e.def?.label ?? e.id
1527
+ }), /* @__PURE__ */ Q($t, {
1528
+ asChild: !0,
1529
+ label: "Delete effect",
1530
+ children: /* @__PURE__ */ Q(p, {
1531
+ tone: "ghost",
1532
+ quiet: !0,
1533
+ size: "xs",
1534
+ iconOnly: "x",
1535
+ "aria-label": "Delete effect",
1536
+ className: "ml-auto shrink-0",
1537
+ onClick: () => a(n.id, f)
1538
+ })
1539
+ })]
1540
+ }), m && e.def && /* @__PURE__ */ Q(L, {
1541
+ schema: e.def.params.filter((e) => c(e) !== "anim"),
1542
+ layer: h,
1543
+ setProp: g,
1544
+ palette: s,
1545
+ inline: !0,
1546
+ renderAnimate: l ? (e) => /* @__PURE__ */ Q(qe, {
1547
+ layer: h,
1548
+ param: e,
1549
+ setProp: g
1550
+ }) : void 0
1551
+ })]
1552
+ }, e.key ?? f);
1553
+ });
1554
+ }
1555
+ function vr({ chain: e, from: t = 1, filters: n = null, layer: r, hostView: i, addFilter: a, removeFilter: o, toggleFilter: s, setStagePropAt: c, palette: l, showMod: u }) {
1556
+ let d = v(), f = [{
1557
+ value: "",
1558
+ label: "Add FX…"
1559
+ }, ...(n ?? U(W)).map((e) => ({
1560
+ value: e.id,
1561
+ label: e.label ?? e.id
1562
+ }))];
1563
+ return /* @__PURE__ */ $(b, {
1564
+ label: "Post-Processing",
1565
+ divided: !0,
1566
+ children: [/* @__PURE__ */ Q(_r, {
1567
+ chain: e,
1568
+ from: t,
1569
+ layer: r,
1570
+ hostView: i,
1571
+ toggleFilter: s,
1572
+ removeFilter: o,
1573
+ setStagePropAt: c,
1574
+ palette: l,
1575
+ showMod: u
1576
+ }), e.length < 8 && /* @__PURE__ */ Q(F, {
1577
+ variant: "subtle",
1578
+ size: d,
1579
+ className: "w-full",
1580
+ options: f,
1581
+ value: "",
1582
+ onChange: (e) => {
1583
+ e && a(r.id, e);
1584
+ }
1585
+ })]
1586
+ });
1587
+ }
1588
+ function yr({ layer: e, showMod: t, tree: n }) {
1589
+ let r = v(), [i, a] = Z("generate"), { updateLayer: o, palette: s } = g(), { setOnly: c } = De(), l = ne(e.id, { history: "coalesce" }), u = V(e.loopGroup).find((t) => t.id === e.presetId), d = H(e.loopGroup), f = (n ?? Ae).find((t) => t.groups.includes(e.loopGroup)), p = f?.labels?.[e.loopGroup] ?? d?.label ?? "", h = f && f.label !== p ? `${f.label} / ${p}` : p, y = e.loopGroup === "paratype" && u?.sub === "Glyphs" ? B("paratype", "Glyphs") : null, b = y ? y.map((e) => ({
1590
+ value: e.id,
1591
+ label: e.label
1592
+ })) : null, x = (t) => {
1593
+ let n = y?.find((e) => e.id === t);
1594
+ n && t !== e.presetId && c(e.type, pe(n, e.loopGroup));
1595
+ }, S = () => {
1596
+ u && c(e.type, pe(u, e.loopGroup));
1597
+ };
1598
+ return or(S, () => {
1599
+ let t = K(e.loopId)?.params ?? [];
1600
+ o(e.id, C(e, N(t, e), P(), { withFilters: !0 }));
1601
+ }), /* @__PURE__ */ $(fr, {
1602
+ title: h,
1603
+ chips: b,
1604
+ active: e.presetId,
1605
+ onPick: x,
1606
+ pills: !0,
1607
+ scope: e.loopId,
1608
+ ghostLabels: (K(e.loopId)?.params ?? []).filter((e) => e.type !== "color" && e.label).map((e) => e.label),
1609
+ tabStrip: /* @__PURE__ */ Q(_, {
1610
+ layout: "joined",
1611
+ tone: "sunken",
1612
+ value: i,
1613
+ onChange: a,
1614
+ options: r === "sm" ? cr : lr,
1615
+ size: r,
1616
+ className: m(r)
1617
+ }),
1618
+ children: [
1619
+ i === "anim" && /* @__PURE__ */ Q(er, {
1620
+ schema: K(e.loopId)?.params ?? [],
1621
+ layer: e,
1622
+ setProp: l.setProp,
1623
+ inputs: K(e.loopId)?.inputs
1624
+ }),
1625
+ /* @__PURE__ */ Q(ke, {
1626
+ layer: e,
1627
+ setProp: l.setProp,
1628
+ patch: l.patch,
1629
+ updateLayer: o,
1630
+ palette: s,
1631
+ renderAnimate: t ? (t) => /* @__PURE__ */ Q(qe, {
1632
+ layer: e,
1633
+ param: t,
1634
+ setProp: l.setProp
1635
+ }) : void 0,
1636
+ tab: i,
1637
+ tabStrip: null,
1638
+ tree: n,
1639
+ inline: !0,
1640
+ onReset: S
1641
+ }),
1642
+ i === "generate" && e.loopId === "scene3d" && e.primitive === "mesh" && /* @__PURE__ */ Q(ar, {
1643
+ layer: e,
1644
+ setProp: l.setProp
1645
+ }),
1646
+ i === "style" && /* @__PURE__ */ Q(hr, {
1647
+ layer: e,
1648
+ edit: l,
1649
+ palette: s,
1650
+ showMod: t
1651
+ }),
1652
+ i === "anim" && /* @__PURE__ */ Q(Zn, {
1653
+ schema: K(e.loopId)?.params ?? [],
1654
+ layer: e,
1655
+ setProp: l.setProp
1656
+ })
1657
+ ]
1658
+ });
1659
+ }
1660
+ function br({ layer: e, showMod: t }) {
1661
+ let n = v(), [r, i] = Z("generate"), { updateLayer: a, palette: o } = g(), { setOnly: s } = De(), c = ne(e.id, { history: "coalesce" }), l = Xe.find((t) => t.id === e.presetId), u = Qe.find((e) => e.subs.includes(l?.sub))?.label ?? "Kinetic";
1662
+ return or(() => {
1663
+ l && s("kinetic", {
1664
+ presetId: l.id,
1665
+ presetLabel: l.label,
1666
+ comp: Ze(l)
1667
+ });
1668
+ }, () => {
1669
+ let t = P(), n = k(t >>> 0), r = e.comp ?? { instances: [] };
1670
+ (r.instances ?? []).forEach((e, t) => {
1671
+ r = et(r, t, n);
1672
+ }), a(e.id, {
1673
+ comp: r,
1674
+ _rollSeed: t
1675
+ });
1676
+ }), /* @__PURE__ */ Q(fr, {
1677
+ title: u,
1678
+ tabStrip: /* @__PURE__ */ Q(_, {
1679
+ layout: "joined",
1680
+ tone: "sunken",
1681
+ value: r,
1682
+ onChange: i,
1683
+ options: n === "sm" ? cr : lr,
1684
+ size: n,
1685
+ className: m(n)
1686
+ }),
1687
+ children: /* @__PURE__ */ Q($e, {
1688
+ layer: e,
1689
+ setProp: c.setProp,
1690
+ updateLayer: a,
1691
+ palette: o,
1692
+ renderAnimate: t ? (t) => /* @__PURE__ */ Q(qe, {
1693
+ layer: e,
1694
+ param: t,
1695
+ setProp: c.setProp
1696
+ }) : () => null,
1697
+ tab: r,
1698
+ tabStrip: null
1699
+ })
1700
+ });
1701
+ }
1702
+ function xr() {
1703
+ let { layer: e } = De(), t = We(), n = v(), r = Ke();
1704
+ return Y(() => {
1705
+ let e = (e) => {
1706
+ e.key !== "m" && e.key !== "M" || e.metaKey || e.ctrlKey || e.altKey || kt(e) || Ge();
1707
+ };
1708
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
1709
+ }, []), t.active ? /* @__PURE__ */ Q(fr, {
1710
+ title: "Morph",
1711
+ children: /* @__PURE__ */ Q(qn, {
1712
+ layer: e,
1713
+ editTabs: n === "sm" ? cr : lr
1714
+ })
1715
+ }) : e ? e.type === "photo" ? /* @__PURE__ */ Q(pr, {
1716
+ layer: e,
1717
+ showMod: r
1718
+ }, e.id) : e.type === "loop" ? /* @__PURE__ */ Q(yr, {
1719
+ layer: e,
1720
+ showMod: r
1721
+ }, e.id) : e.type === "misc" ? /* @__PURE__ */ Q(yr, {
1722
+ layer: e,
1723
+ showMod: r,
1724
+ tree: Se
1725
+ }, e.id) : e.type === "kinetic" ? /* @__PURE__ */ Q(br, {
1726
+ layer: e,
1727
+ showMod: r
1728
+ }, e.id) : /* @__PURE__ */ Q(R, { children: "This layer has no labs surface." }) : /* @__PURE__ */ Q(R, { children: "Pick an effect or generator from the nav." });
1729
+ }
1730
+ //#endregion
1731
+ //#region src/editor/mobile/CategoryScreen.jsx
1732
+ function Sr(e) {
1733
+ Y(() => {
1734
+ let t = (t) => {
1735
+ t.key === "Escape" && e?.();
1736
+ };
1737
+ return window.addEventListener("keydown", t), () => window.removeEventListener("keydown", t);
1738
+ }, [e]), Y(() => {
1739
+ let e = i.isPlaying();
1740
+ return i.pause(), () => {
1741
+ e && i.play();
1742
+ };
1743
+ }, []);
1744
+ }
1745
+ function Cr({ onPick: e, onInsert: t, onBack: n, onDismiss: r }) {
1746
+ return Sr(r ?? n), /* @__PURE__ */ Q("div", {
1747
+ className: "fixed inset-y-0 right-0 left-[var(--fxr-rail,0px)] kol-overlay-scrim flex flex-col items-center overflow-y-auto p-6",
1748
+ style: { zIndex: "var(--kol-z-modal)" },
1749
+ children: /* @__PURE__ */ $("div", {
1750
+ className: "my-auto w-full max-w-sm rounded p-8 flex flex-col gap-6",
1751
+ style: { background: "var(--kol-surface-primary)" },
1752
+ children: [
1753
+ /* @__PURE__ */ Q("div", {
1754
+ className: "kol-eyebrow text-body",
1755
+ children: "Pick a generator"
1756
+ }),
1757
+ /* @__PURE__ */ Q("div", {
1758
+ className: "flex flex-col gap-2",
1759
+ children: Ae.map((t) => {
1760
+ let n = Rn[`gen:${t.label}`] ?? "square";
1761
+ return /* @__PURE__ */ Q(J, {
1762
+ tone: "primary",
1763
+ size: "lg",
1764
+ className: wt,
1765
+ iconLeft: n,
1766
+ iconRight: n,
1767
+ onClick: () => e(t),
1768
+ children: t.label
1769
+ }, t.label);
1770
+ })
1771
+ }),
1772
+ /* @__PURE__ */ $("div", {
1773
+ className: "flex flex-col gap-2",
1774
+ children: [t && /* @__PURE__ */ Q(J, {
1775
+ tone: "grey",
1776
+ size: "lg",
1777
+ className: "w-full [&>span]:w-full [&>span]:justify-between",
1778
+ iconLeft: "image",
1779
+ iconRight: "image",
1780
+ onClick: t,
1781
+ children: "Insert image or video"
1782
+ }), n && /* @__PURE__ */ Q(J, {
1783
+ tone: "grey",
1784
+ size: "lg",
1785
+ className: "w-full [&>span]:w-full [&>span]:justify-between",
1786
+ iconLeft: "arrow-left",
1787
+ iconRight: "arrow-left",
1788
+ onClick: n,
1789
+ children: "Back"
1790
+ })]
1791
+ })
1792
+ ]
1793
+ })
1794
+ });
1795
+ }
1796
+ //#endregion
1797
+ //#region src/editor/labs/LabsSourcePicker.jsx
1798
+ var wr = (e) => /\.svg$/i.test(e.key) || /svg/i.test(e.contentType || "");
1799
+ function Tr(e) {
1800
+ let { patch: t } = ne(e.id), n = X(null), [r, i] = Z(!1), a = e.type === "loop" && e.loopGroup === "distress";
1801
+ return {
1802
+ nodes: /* @__PURE__ */ $(ln, { children: [/* @__PURE__ */ Q("input", {
1803
+ ref: n,
1804
+ type: "file",
1805
+ accept: a ? ".svg,image/svg+xml" : "image/*,video/*",
1806
+ className: "hidden",
1807
+ onChange: (n) => {
1808
+ let r = n.target.files?.[0];
1809
+ if (n.target.value = "", r) {
1810
+ if (a) {
1811
+ let e = new FileReader();
1812
+ e.onload = () => t({ svgSrc: e.result }), e.readAsText(r);
1813
+ return;
1814
+ }
1815
+ if (r.type.startsWith("video/")) {
1816
+ w(e.id, r), t({
1817
+ src: URL.createObjectURL(r),
1818
+ srcType: "video"
1819
+ });
1820
+ return;
1821
+ }
1822
+ ft(r).then((e) => t({
1823
+ src: e,
1824
+ srcType: "image"
1825
+ }));
1826
+ }
1827
+ }
1828
+ }), /* @__PURE__ */ Q(bt, {
1829
+ open: r,
1830
+ accept: a ? wr : ["image", "video"],
1831
+ onClose: () => i(!1),
1832
+ onSelect: (e, { contentType: n } = {}) => {
1833
+ if (a) {
1834
+ t({ svgSrc: lt(e) });
1835
+ return;
1836
+ }
1837
+ t({
1838
+ src: lt(e),
1839
+ srcType: rt(n) ? "video" : "image"
1840
+ });
1841
+ }
1842
+ })] }),
1843
+ svgMode: a,
1844
+ openLibrary: () => i(!0),
1845
+ openUpload: () => n.current?.click(),
1846
+ openCamera: () => {
1847
+ ht(e.id).then(() => t({
1848
+ src: null,
1849
+ srcType: "webcam"
1850
+ })).catch(() => {});
1851
+ }
1852
+ };
1853
+ }
1854
+ [
1855
+ {
1856
+ value: "library",
1857
+ label: "Library"
1858
+ },
1859
+ {
1860
+ value: "upload",
1861
+ label: "Upload"
1862
+ },
1863
+ {
1864
+ value: "camera",
1865
+ label: "Camera"
1866
+ }
1867
+ ].slice(0, 2);
1868
+ function Er({ layer: e }) {
1869
+ let t = Tr(e);
1870
+ return /* @__PURE__ */ $("div", {
1871
+ className: "flex flex-col gap-2",
1872
+ children: [
1873
+ /* @__PURE__ */ Q(p, {
1874
+ tone: "primary",
1875
+ size: "lg",
1876
+ className: wt,
1877
+ iconLeft: "image",
1878
+ iconRight: "image",
1879
+ onClick: t.openLibrary,
1880
+ children: "From library"
1881
+ }),
1882
+ /* @__PURE__ */ Q(p, {
1883
+ tone: "primary",
1884
+ size: "lg",
1885
+ className: wt,
1886
+ iconLeft: "upload",
1887
+ iconRight: "upload",
1888
+ onClick: t.openUpload,
1889
+ children: "Upload"
1890
+ }),
1891
+ !t.svgMode && /* @__PURE__ */ Q(p, {
1892
+ tone: "primary",
1893
+ size: "lg",
1894
+ className: "w-full [&>span]:w-full [&>span]:justify-between",
1895
+ iconLeft: "camera",
1896
+ iconRight: "camera",
1897
+ onClick: t.openCamera,
1898
+ children: "Camera"
1899
+ }),
1900
+ t.nodes
1901
+ ]
1902
+ });
1903
+ }
1904
+ function Dr({ layer: e, title: t, onBack: n }) {
1905
+ return Sr(n), /* @__PURE__ */ Q("div", {
1906
+ className: "fixed inset-y-0 right-0 left-[var(--fxr-rail,0px)] kol-overlay-scrim flex flex-col items-center overflow-y-auto p-6",
1907
+ style: { zIndex: "calc(var(--kol-z-sticky) - 2)" },
1908
+ children: /* @__PURE__ */ $("div", {
1909
+ className: "my-auto w-full max-w-sm rounded p-8 flex flex-col gap-6",
1910
+ style: { background: "var(--kol-surface-primary)" },
1911
+ children: [
1912
+ /* @__PURE__ */ $("div", {
1913
+ className: "flex flex-col gap-2",
1914
+ children: [/* @__PURE__ */ Q("span", {
1915
+ className: "kol-eyebrow text-body",
1916
+ children: t
1917
+ }), /* @__PURE__ */ Q("span", {
1918
+ className: "kol-mono-12 text-meta",
1919
+ children: "Pick the media it works on."
1920
+ })]
1921
+ }),
1922
+ /* @__PURE__ */ Q(Er, { layer: e }),
1923
+ /* @__PURE__ */ Q(p, {
1924
+ tone: "grey",
1925
+ size: "lg",
1926
+ className: wt,
1927
+ iconLeft: "arrow-left",
1928
+ iconRight: "arrow-left",
1929
+ onClick: n,
1930
+ children: "Back"
1931
+ })
1932
+ ]
1933
+ })
1934
+ });
1935
+ }
1936
+ //#endregion
1937
+ //#region src/editor/components/PanelHeader.jsx
1938
+ function Or({ title: e, onCollapse: t, action: n, className: r = "px-3" }) {
1939
+ return /* @__PURE__ */ $("div", {
1940
+ className: `flex w-full shrink-0 items-center ${r}`,
1941
+ children: [/* @__PURE__ */ $("button", {
1942
+ className: "kol-helper-12 text-meta flex flex-1 items-center gap-2 py-2.5",
1943
+ onClick: t,
1944
+ children: [/* @__PURE__ */ Q("span", { children: e }), /* @__PURE__ */ Q(un, {
1945
+ name: "chevron-down",
1946
+ size: 16,
1947
+ className: "text-oq-48"
1948
+ })]
1949
+ }), n]
1950
+ });
1951
+ }
1952
+ function kr({ label: e, onOpen: t, size: n = "lg", tone: r = "primary", children: i }) {
1953
+ return /* @__PURE__ */ $("div", {
1954
+ className: "pointer-events-none fixed bottom-[max(0.75rem,env(safe-area-inset-bottom))] left-[var(--fxr-rail,0px)] right-0 z-10 flex flex-nowrap items-center gap-2 px-3 [&>*]:pointer-events-auto",
1955
+ children: [/* @__PURE__ */ Q(J, {
1956
+ tone: r,
1957
+ size: n,
1958
+ onClick: t,
1959
+ className: "min-w-0 shrink",
1960
+ children: /* @__PURE__ */ $("span", {
1961
+ className: "flex items-center gap-2 min-w-0",
1962
+ children: [/* @__PURE__ */ Q("span", {
1963
+ className: "truncate",
1964
+ children: e
1965
+ }), /* @__PURE__ */ Q(un, {
1966
+ name: "chevron-down",
1967
+ size: 16,
1968
+ className: "rotate-180 shrink-0"
1969
+ })]
1970
+ })
1971
+ }), i]
1972
+ });
1973
+ }
1974
+ var Ar = {
1975
+ half: "50dvh",
1976
+ tall: "85dvh"
1977
+ }, jr = 4;
1978
+ function Mr({ tall: e, onToggle: t, onDrag: n, onResize: r, onResizeEnd: i }) {
1979
+ let a = X(null);
1980
+ en(a, { axis: "x" });
1981
+ let o = X({
1982
+ y: null,
1983
+ h0: 0,
1984
+ moved: !1,
1985
+ swallow: !1,
1986
+ last: 0
1987
+ }).current;
1988
+ return /* @__PURE__ */ Q("button", {
1989
+ ref: a,
1990
+ type: "button",
1991
+ "aria-label": e ? "Lower the sheet" : "Raise the sheet",
1992
+ "aria-pressed": e,
1993
+ className: "kol-sheet-grab relative flex h-6 w-full shrink-0 touch-none items-center justify-center",
1994
+ onPointerDown: (e) => {
1995
+ o.y = e.clientY, o.moved = !1, o.h0 = window.innerHeight - e.currentTarget.getBoundingClientRect().top, e.currentTarget.setPointerCapture?.(e.pointerId);
1996
+ },
1997
+ onPointerMove: (e) => {
1998
+ if (o.y === null) return;
1999
+ let t = e.clientY - o.y;
2000
+ Math.abs(t) > jr && (o.moved = !0), o.moved && r && (o.last = o.h0 - t, r(o.last));
2001
+ },
2002
+ onPointerUp: (e) => {
2003
+ if (o.y === null) return;
2004
+ let t = e.clientY - o.y;
2005
+ o.y = null, o.moved && (o.swallow = !0, r ? i?.(o.h0 - t) : n?.(t < 0 ? -1 : 1));
2006
+ },
2007
+ onPointerCancel: () => {
2008
+ o.y = null;
2009
+ },
2010
+ onClick: () => {
2011
+ if (o.swallow) {
2012
+ o.swallow = !1;
2013
+ return;
2014
+ }
2015
+ t?.();
2016
+ },
2017
+ children: /* @__PURE__ */ Q("span", { className: "h-1 w-9 rounded-full bg-oq-16" })
2018
+ });
2019
+ }
2020
+ //#endregion
2021
+ //#region src/editor/labs/LabsCatalogCard.jsx
2022
+ var Nr = new Set(["#rail/sec:effects"]);
2023
+ function Pr({ onPicked: e, onClose: t, initialOpen: n = null, hasMedia: r = !0, onNeedMedia: i }) {
2024
+ let { items: a, dispatch: o } = Gt(), [s, c] = Z(n);
2025
+ Sr(t);
2026
+ let l = a.find((e) => e.path === s) ?? null, u = l ? l.sub : a;
2027
+ return /* @__PURE__ */ Q("div", {
2028
+ className: "fixed bottom-0 top-12 md:top-0 right-0 left-[var(--fxr-rail,0px)] kol-overlay-scrim flex flex-col items-center overflow-y-auto p-6",
2029
+ style: { zIndex: "calc(var(--kol-z-sticky) - 2)" },
2030
+ onClick: (e) => {
2031
+ e.target === e.currentTarget && t?.();
2032
+ },
2033
+ children: /* @__PURE__ */ $("div", {
2034
+ className: "my-auto w-full max-w-sm rounded p-4 flex flex-col gap-6",
2035
+ style: { background: "var(--kol-surface-primary)" },
2036
+ children: [/* @__PURE__ */ Q("span", {
2037
+ className: "kol-eyebrow text-body",
2038
+ children: l ? l.label : "Labs"
2039
+ }), /* @__PURE__ */ $("div", {
2040
+ className: "flex flex-col gap-2",
2041
+ children: [u.map((t) => /* @__PURE__ */ Q(J, {
2042
+ tone: "primary",
2043
+ size: "lg",
2044
+ className: wt,
2045
+ iconLeft: t.icon,
2046
+ iconRight: t.icon,
2047
+ onClick: () => {
2048
+ if (!l && Nr.has(t.path) && !r && i) {
2049
+ i(t.path);
2050
+ return;
2051
+ }
2052
+ if (!l && t.sub?.length) {
2053
+ c(t.path);
2054
+ return;
2055
+ }
2056
+ o?.(t.path) && e?.();
2057
+ },
2058
+ children: t.label
2059
+ }, t.path)), l && /* @__PURE__ */ Q(J, {
2060
+ tone: "grey",
2061
+ size: "lg",
2062
+ className: "w-full [&>span]:w-full [&>span]:justify-between",
2063
+ iconLeft: "arrow-left",
2064
+ iconRight: "arrow-left",
2065
+ onClick: () => c(null),
2066
+ children: "Back"
2067
+ })]
2068
+ })]
2069
+ })
2070
+ });
2071
+ }
2072
+ //#endregion
2073
+ //#region src/editor/labs/sheetLabels.js
2074
+ function Fr(e) {
2075
+ if (ze().active) return {
2076
+ title: "Morph",
2077
+ pill: "Morph"
2078
+ };
2079
+ if (!e) return {
2080
+ title: "Labs",
2081
+ pill: "Labs"
2082
+ };
2083
+ if (e.type === "loop" || e.type === "misc") return {
2084
+ title: H(e.loopGroup)?.label ?? "Labs",
2085
+ kind: e.presetLabel,
2086
+ pill: e.presetLabel
2087
+ };
2088
+ if (e.type === "photo") {
2089
+ let t = x(e)[0]?.def?.label ?? "Media";
2090
+ return {
2091
+ title: t,
2092
+ pill: t
2093
+ };
2094
+ }
2095
+ let t = e.presetLabel ?? "Labs";
2096
+ return {
2097
+ title: t,
2098
+ pill: t
2099
+ };
2100
+ }
2101
+ //#endregion
2102
+ //#region src/editor/labs/LabsView.jsx
2103
+ var Ir = .85, Lr = .3, Rr = 2.5, zr = {
2104
+ 0: 1,
2105
+ 1: .5,
2106
+ 2: 1,
2107
+ 3: 1.5,
2108
+ 4: 2
2109
+ }, Br = "px-2 py-1 rounded border border-oq-08 bg-surface-secondary kol-mono-12 text-emphasis tabular-nums";
2110
+ function Vr() {
2111
+ let { layer: t } = De(), { removeLayer: n, layers: r, updateLayer: a, beginTransaction: o, commitTransaction: s, select: c } = g(), [l, u] = Z(null);
2112
+ Y(() => {
2113
+ let e = (e) => {
2114
+ let { id: t, index: n } = e.detail || {};
2115
+ if (l?.id === t) {
2116
+ u(null);
2117
+ return;
2118
+ }
2119
+ r.some((e) => e.id === t && e.type === "kinetic" && !e.locked) && (c(t), u({
2120
+ id: t,
2121
+ index: n ?? 0
2122
+ }));
2123
+ };
2124
+ return window.addEventListener("kol:kinetic-edit", e), () => window.removeEventListener("kol:kinetic-edit", e);
2125
+ }, [
2126
+ r,
2127
+ l,
2128
+ c
2129
+ ]);
2130
+ let d = l && r.find((e) => e.id === l.id && e.type === "kinetic"), f = t?.type === "photo" && !t.src && t.srcType !== "webcam", [p, m] = Z(1), [h, _] = Z(!1), v = T(h), y = X(null), b = (e) => Math.min(Rr, Math.max(Lr, e)), x = (e) => m((t) => b(t * (e > 0 ? 1.25 : .8))), { tool: S } = gt(), C = S === "orbit", w = X(C);
2131
+ w.current = C, Y(() => {
2132
+ let t = y.current;
2133
+ if (!t) return;
2134
+ let n = (t) => {
2135
+ w.current || (t.preventDefault(), !e().zoomLock && m((e) => b(e * (t.deltaY > 0 ? .94 : 1.06))));
2136
+ };
2137
+ return t.addEventListener("wheel", n, { passive: !1 }), () => t.removeEventListener("wheel", n);
2138
+ }, []), Y(() => {
2139
+ let t = (t) => {
2140
+ if (!(t.metaKey || t.ctrlKey || t.altKey) && !kt(t)) {
2141
+ if (t.key === "f" || t.key === "F") {
2142
+ _((e) => !e);
2143
+ return;
2144
+ }
2145
+ if (!(e().zoomLock && (t.key === "-" || t.key === "_" || t.key === "+" || t.key === "=" || zr[t.key] !== void 0))) {
2146
+ if (t.key === "-" || t.key === "_") {
2147
+ x(-1);
2148
+ return;
2149
+ }
2150
+ if (t.key === "+" || t.key === "=") {
2151
+ x(1);
2152
+ return;
2153
+ }
2154
+ zr[t.key] !== void 0 && m(zr[t.key]);
2155
+ }
2156
+ }
2157
+ };
2158
+ return window.addEventListener("keydown", t), () => window.removeEventListener("keydown", t);
2159
+ }, []);
2160
+ let [E, D] = Z({
2161
+ x: 0,
2162
+ y: 0
2163
+ }), O = X({
2164
+ pts: /* @__PURE__ */ new Map(),
2165
+ start: null,
2166
+ tap: null
2167
+ }), k = X({
2168
+ zoom: p,
2169
+ pan: E
2170
+ });
2171
+ k.current = {
2172
+ zoom: p,
2173
+ pan: E
2174
+ };
2175
+ let A = (e) => {
2176
+ if (e.pointerType !== "touch") return;
2177
+ let t = O.current;
2178
+ if (t.pts.set(e.pointerId, {
2179
+ x: e.clientX,
2180
+ y: e.clientY
2181
+ }), t.tap = t.pts.size === 1 ? {
2182
+ id: e.pointerId,
2183
+ x: e.clientX,
2184
+ y: e.clientY,
2185
+ at: performance.now()
2186
+ } : null, t.pts.size === 2) {
2187
+ let [n, r] = [...t.pts.values()], a = y.current.getBoundingClientRect(), o = a.left + a.width / 2, s = a.top + a.height / 2, c = (n.x + r.x) / 2, l = (n.y + r.y) / 2, { zoom: u, pan: d } = k.current;
2188
+ t.start = {
2189
+ d: Math.hypot(n.x - r.x, n.y - r.y),
2190
+ cx: o,
2191
+ cy: s,
2192
+ z0: u,
2193
+ qx: (c - o - d.x) / u,
2194
+ qy: (l - s - d.y) / u
2195
+ }, i.setStagePointer?.(null), e.stopPropagation();
2196
+ }
2197
+ }, j = (t) => {
2198
+ let n = O.current;
2199
+ if (!(t.pointerType !== "touch" || !n.pts.has(t.pointerId)) && (n.pts.set(t.pointerId, {
2200
+ x: t.clientX,
2201
+ y: t.clientY
2202
+ }), n.pts.size >= 2 && n.start)) {
2203
+ t.stopPropagation();
2204
+ let [r, i] = [...n.pts.values()], a = n.start, o = e().zoomLock ? a.z0 : b(a.z0 * (Math.hypot(r.x - i.x, r.y - i.y) / a.d)), s = (r.x + i.x) / 2, c = (r.y + i.y) / 2;
2205
+ m(o), D({
2206
+ x: s - a.cx - o * a.qx,
2207
+ y: c - a.cy - o * a.qy
2208
+ });
2209
+ }
2210
+ }, M = (e) => {
2211
+ let n = O.current;
2212
+ if (e.pointerType !== "touch") return;
2213
+ let r = n.tap;
2214
+ r && r.id === e.pointerId && e.type === "pointerup" && !n.start && performance.now() - r.at < 350 && Math.hypot(e.clientX - r.x, e.clientY - r.y) < 12 && (t?.type === "loop" ? K(t.loopId) : null)?.group !== "penrose" && i.toggle(), r?.id === e.pointerId && (n.tap = null), n.pts.delete(e.pointerId), n.pts.size < 2 && (n.start = null);
2215
+ };
2216
+ return /* @__PURE__ */ $("div", {
2217
+ ref: y,
2218
+ className: "relative w-full h-full flex items-center justify-center overflow-hidden touch-none",
2219
+ style: { background: "var(--kol-surface-secondary)" },
2220
+ onDoubleClick: () => {
2221
+ m(1), D({
2222
+ x: 0,
2223
+ y: 0
2224
+ });
2225
+ },
2226
+ onPointerDownCapture: A,
2227
+ onPointerMoveCapture: j,
2228
+ onPointerUpCapture: M,
2229
+ onPointerCancelCapture: M,
2230
+ children: [
2231
+ /* @__PURE__ */ Q("div", {
2232
+ style: {
2233
+ flex: "none",
2234
+ width: `${p * Ir * 100}%`,
2235
+ height: `${p * Ir * 100}%`,
2236
+ transform: `translate(${E.x}px, ${E.y}px)`
2237
+ },
2238
+ children: /* @__PURE__ */ Q(Ct, { overlay: d ? (e) => /* @__PURE__ */ Q(mt, {
2239
+ layer: d,
2240
+ initialIndex: l.index,
2241
+ toVirtual: e,
2242
+ updateLayer: a,
2243
+ beginTransaction: o,
2244
+ commitTransaction: s,
2245
+ onExit: () => u(null)
2246
+ }) : void 0 })
2247
+ }),
2248
+ f && /* @__PURE__ */ Q(Dr, {
2249
+ layer: t,
2250
+ title: Fr(t).title,
2251
+ onBack: () => n(t.id)
2252
+ }),
2253
+ h && /* @__PURE__ */ Q("div", {
2254
+ className: "absolute bottom-3 right-3 z-[var(--kol-z-base)] flex items-center gap-2 [@media(pointer:coarse)]:bottom-1",
2255
+ children: /* @__PURE__ */ Q($t, {
2256
+ label: "Framerate — press F to hide",
2257
+ children: /* @__PURE__ */ $("span", {
2258
+ className: Br,
2259
+ children: [v, " fps"]
2260
+ })
2261
+ })
2262
+ })
2263
+ ]
2264
+ });
2265
+ }
2266
+ function Hr() {
2267
+ let e = X(null), { grabProps: t } = mn(e, {
2268
+ token: "kol-rail",
2269
+ side: "right"
2270
+ });
2271
+ return Y(() => {
2272
+ let e = document.documentElement, t = !1, n = () => {
2273
+ let t = parseFloat(getComputedStyle(e).getPropertyValue("--kol-shell-rail-width"));
2274
+ return Number.isFinite(t) ? t <= 49 : null;
2275
+ }, r = () => e.getAttribute("data-rail") === "collapsed", i = () => [...document.querySelectorAll(".kol-rail-grab")].sort((e, t) => e.getBoundingClientRect().left - t.getBoundingClientRect().left)[0], a = () => {
2276
+ let e = i();
2277
+ if (!e) return;
2278
+ let t = e.getBoundingClientRect(), n = {
2279
+ bubbles: !0,
2280
+ cancelable: !0,
2281
+ pointerId: 1,
2282
+ clientX: t.left + t.width / 2,
2283
+ clientY: t.top + t.height / 2
2284
+ };
2285
+ e.dispatchEvent(new PointerEvent("pointerdown", n)), e.dispatchEvent(new PointerEvent("pointerup", n));
2286
+ }, o = () => {
2287
+ if (t) return;
2288
+ let i = n();
2289
+ i === null || i === r() || (t = !0, i ? e.setAttribute("data-rail", "collapsed") : e.removeAttribute("data-rail"), t = !1);
2290
+ }, s = () => {
2291
+ if (t) return;
2292
+ let e = n();
2293
+ e === null || e === r() || (t = !0, a(), t = !1);
2294
+ };
2295
+ o();
2296
+ let c = new MutationObserver(o);
2297
+ c.observe(e, {
2298
+ attributes: !0,
2299
+ attributeFilter: ["style"]
2300
+ });
2301
+ let l = new MutationObserver(s);
2302
+ return l.observe(e, {
2303
+ attributes: !0,
2304
+ attributeFilter: ["data-rail"]
2305
+ }), () => {
2306
+ c.disconnect(), l.disconnect();
2307
+ };
2308
+ }, []), /* @__PURE__ */ $("div", {
2309
+ ref: e,
2310
+ className: "kol-compose-rail kol-compose-rail--inspector",
2311
+ children: [/* @__PURE__ */ Q("div", { ...t }), /* @__PURE__ */ Q("div", {
2312
+ className: "kol-compose-inspector-body",
2313
+ children: /* @__PURE__ */ Q(xr, {})
2314
+ })]
2315
+ });
2316
+ }
2317
+ var Ur = an(null);
2318
+ function Wr() {
2319
+ let { tall: e, setTall: t, collapseParams: n, setSheetPx: r } = sn(Ur);
2320
+ return /* @__PURE__ */ Q(Mr, {
2321
+ tall: e,
2322
+ onToggle: () => {
2323
+ r(null), t((e) => !e);
2324
+ },
2325
+ onResize: (e) => r(Math.max(96, Math.min(window.innerHeight * .92, e))),
2326
+ onResizeEnd: (e) => {
2327
+ e < 96 && (r(null), n());
2328
+ }
2329
+ });
2330
+ }
2331
+ var Gr = [
2332
+ 2,
2333
+ 4,
2334
+ 8,
2335
+ 12,
2336
+ 16
2337
+ ];
2338
+ function Kr({ paramsOpen: e, setParamsOpen: t, catalog: n, toggleCatalog: r, railHeight: i }) {
2339
+ let { playing: o, loopSeconds: s, play: c, pause: l, stop: u, rewind: d, setLoopSeconds: f } = a(), [p, m] = Z(!0), h = [
2340
+ {
2341
+ icon: "home-01",
2342
+ path: "#home",
2343
+ label: "Home",
2344
+ onPress: () => Ft("/")
2345
+ },
2346
+ {
2347
+ icon: "grid",
2348
+ path: "#catalog",
2349
+ label: "Catalog",
2350
+ onPress: r,
2351
+ selected: n
2352
+ },
2353
+ {
2354
+ icon: "slider-01",
2355
+ path: "#params",
2356
+ label: "Params",
2357
+ onPress: () => t((e) => !e),
2358
+ selected: e
2359
+ },
2360
+ {
2361
+ icon: "play-solid",
2362
+ path: "#transport",
2363
+ label: "Transport",
2364
+ onPress: () => m((e) => !e),
2365
+ selected: p
2366
+ }
2367
+ ], g = [{
2368
+ icon: "download",
2369
+ label: "Output",
2370
+ onPress: () => {
2371
+ t(!0), dt("Output");
2372
+ }
2373
+ }, {
2374
+ icon: "file",
2375
+ label: "File",
2376
+ onPress: () => {
2377
+ t(!0), dt("File");
2378
+ }
2379
+ }], _ = p ? {
2380
+ items: [
2381
+ {
2382
+ id: "play",
2383
+ icon: "play",
2384
+ label: "Play",
2385
+ onPress: c,
2386
+ selected: o
2387
+ },
2388
+ {
2389
+ id: "pause",
2390
+ icon: "pause",
2391
+ label: "Pause",
2392
+ onPress: l,
2393
+ selected: !o
2394
+ },
2395
+ {
2396
+ id: "loop",
2397
+ icon: "stopwatch-solid",
2398
+ label: "Loop length"
2399
+ },
2400
+ {
2401
+ id: "stop",
2402
+ icon: "stop",
2403
+ label: "Stop",
2404
+ onPress: u
2405
+ },
2406
+ {
2407
+ id: "rewind",
2408
+ icon: "rewind",
2409
+ label: "Rewind",
2410
+ onPress: d
2411
+ }
2412
+ ],
2413
+ sheetFor: { loop: Gr.map((e) => ({
2414
+ label: `${e} s`,
2415
+ checked: s === e,
2416
+ onPress: () => f(e)
2417
+ })) }
2418
+ } : void 0;
2419
+ return Y(() => {
2420
+ Tn({
2421
+ items: h,
2422
+ actions: g,
2423
+ transport: _,
2424
+ railOpen: e,
2425
+ railHeight: i
2426
+ });
2427
+ }, [
2428
+ e,
2429
+ n,
2430
+ p,
2431
+ o,
2432
+ s,
2433
+ i
2434
+ ]), Y(() => () => Tn(null), []), null;
2435
+ }
2436
+ function qr() {
2437
+ return /* @__PURE__ */ Q("div", {
2438
+ className: "kol-compose-rail kol-compose-rail--inspector",
2439
+ children: /* @__PURE__ */ Q("div", {
2440
+ className: "kol-compose-inspector-body",
2441
+ children: /* @__PURE__ */ Q(xr, {})
2442
+ })
2443
+ });
2444
+ }
2445
+ var Jr = {
2446
+ topbar: () => null,
2447
+ canvas: Vr,
2448
+ panels: [
2449
+ {
2450
+ slot: "canvas.footer",
2451
+ order: 0,
2452
+ Component: tt
2453
+ },
2454
+ {
2455
+ slot: "right.body",
2456
+ order: 0,
2457
+ Component: Hr
2458
+ },
2459
+ {
2460
+ slot: "right.footer",
2461
+ order: 0,
2462
+ Component: Dt
2463
+ }
2464
+ ]
2465
+ }, Yr = {
2466
+ ...Jr,
2467
+ panels: [{
2468
+ slot: "right.header",
2469
+ order: 0,
2470
+ Component: Wr
2471
+ }, ...Jr.panels.map((e) => e.Component === Hr ? {
2472
+ ...e,
2473
+ Component: qr
2474
+ } : e)]
2475
+ };
2476
+ function Xr() {
2477
+ let { setAspect: t } = g(), n = X(!1);
2478
+ Y(() => {
2479
+ if (n.current) return;
2480
+ n.current = !0;
2481
+ let r = e();
2482
+ r.defaultAspect && r.defaultAspect !== "custom" && t(r.defaultAspect), r.defaultLoopSeconds && i.setLoopSeconds(r.defaultLoopSeconds);
2483
+ }, []);
2484
+ let { clearHistory: r } = g();
2485
+ Y(() => {
2486
+ let e = setTimeout(r, 800);
2487
+ return () => clearTimeout(e);
2488
+ }, [r]);
2489
+ }
2490
+ function Zr() {
2491
+ let { selectedId: n, select: r } = g(), { layer: a, setOnly: o } = De(), c = vt(nt), l = Lt() && !Vt() || c;
2492
+ Y(() => {
2493
+ l && document.documentElement.removeAttribute("data-rail");
2494
+ }, [l]);
2495
+ let [u, d] = Z(!0), [f, p] = Z(!1), [m, h] = Z(null), _ = m ? `${m}px` : f ? Ar.tall : Ar.half, v = { "--kol-sheet-h": _ }, b = En(), x = We(), [S, C] = Z(() => !a);
2496
+ Y(() => {
2497
+ C(!a);
2498
+ }, [a?.id]);
2499
+ let [w, T] = Z(null), E = a?.type === "photo" && (!!a.src || a.srcType === "webcam");
2500
+ Y(() => {
2501
+ w && E && C(!0);
2502
+ }, [w, E]), Y(() => {
2503
+ a || T(null);
2504
+ }, [a]), Y(() => {
2505
+ if (!a || l) return;
2506
+ let e = 0, t = 0;
2507
+ return e = requestAnimationFrame(() => {
2508
+ t = requestAnimationFrame(() => document.documentElement.removeAttribute("data-rail"));
2509
+ }), () => {
2510
+ cancelAnimationFrame(e), cancelAnimationFrame(t);
2511
+ };
2512
+ }, [a?.id]), Y(() => {
2513
+ if (!x.active || l) return;
2514
+ let e = 0, t = 0;
2515
+ return e = requestAnimationFrame(() => {
2516
+ t = requestAnimationFrame(() => document.documentElement.removeAttribute("data-rail"));
2517
+ }), () => {
2518
+ cancelAnimationFrame(e), cancelAnimationFrame(t);
2519
+ };
2520
+ }, [x.active, l]), Y(() => xt((e) => o("photo", {
2521
+ src: e.url,
2522
+ srcType: e.srcType
2523
+ })), [o]), Y(() => {
2524
+ if (!l) return;
2525
+ let e = () => d(!0);
2526
+ return window.addEventListener("kol:open-params", e), window.addEventListener("kol:open-effects", e), () => {
2527
+ window.removeEventListener("kol:open-params", e), window.removeEventListener("kol:open-effects", e);
2528
+ };
2529
+ }, [l]), It(), Y(() => (Ot("labs"), () => Ot(null)), []), Xr();
2530
+ let D = X(!1);
2531
+ Y(() => {
2532
+ if (D.current) return;
2533
+ D.current = !0;
2534
+ let e = pt();
2535
+ if (e.open || e.fresh) return;
2536
+ let t = new URLSearchParams(window.location.search).get("preset"), n = t ? fe(t) : null;
2537
+ n && o("loop", pe(z(t), n));
2538
+ }, [o]);
2539
+ let { tool: O, setTool: k } = gt(), A = X(O);
2540
+ A.current = O;
2541
+ let { updateLayer: j, undo: M, redo: N } = g(), ee = X({
2542
+ undo: M,
2543
+ redo: N
2544
+ });
2545
+ ee.current = {
2546
+ undo: M,
2547
+ redo: N
2548
+ };
2549
+ let P = !!t().grab;
2550
+ Y(() => {
2551
+ k(P ? "orbit" : "select");
2552
+ }, [P, k]);
2553
+ let F = X(a);
2554
+ F.current = a;
2555
+ let te = X(j);
2556
+ return te.current = j, Y(() => {
2557
+ let t = (t) => {
2558
+ if (kt(t)) return;
2559
+ if ((t.metaKey || t.ctrlKey) && (t.key === "z" || t.key === "Z")) {
2560
+ t.preventDefault(), t.shiftKey ? ee.current.redo() : ee.current.undo();
2561
+ return;
2562
+ }
2563
+ if (t.code === "Space") {
2564
+ t.preventDefault(), i.toggle();
2565
+ return;
2566
+ }
2567
+ if ((t.key === "s" || t.key === "S") && !t.metaKey && !t.ctrlKey && !t.altKey) {
2568
+ window.dispatchEvent(new CustomEvent("kol:show-shortcuts"));
2569
+ return;
2570
+ }
2571
+ if ((t.key === "c" || t.key === "C") && !t.metaKey && !t.ctrlKey && !t.altKey) {
2572
+ s("grab", !e().grab);
2573
+ return;
2574
+ }
2575
+ if ((t.key === "z" || t.key === "Z") && !t.metaKey && !t.ctrlKey && !t.altKey) {
2576
+ s("zoomLock", !e().zoomLock);
2577
+ return;
2578
+ }
2579
+ let n = !t.metaKey && !t.ctrlKey && !t.altKey && !t.shiftKey && Ee[t.key.length === 1 ? t.key.toLowerCase() : t.key];
2580
+ if (n && F.current) {
2581
+ let e = xe(F.current, n[1], n[0]);
2582
+ e && (t.preventDefault(), te.current(F.current.id, e));
2583
+ }
2584
+ };
2585
+ return window.addEventListener("keydown", t), () => window.removeEventListener("keydown", t);
2586
+ }, [k]), Y(() => {
2587
+ if (!a?.presetId) return;
2588
+ let e = new URLSearchParams(window.location.search);
2589
+ e.get("preset") !== a.presetId && (e.delete("view"), e.set("preset", a.presetId), a.loopGroup ? e.set("cat", a.loopGroup) : e.delete("cat"), window.history.replaceState(null, "", `${window.location.pathname}?${e}`));
2590
+ }, [a?.presetId, a?.loopGroup]), Y(() => {
2591
+ a && n !== a.id && r(a.id);
2592
+ }, [
2593
+ a,
2594
+ n,
2595
+ r
2596
+ ]), /* @__PURE__ */ $("div", {
2597
+ className: "kol-editor-labs contents",
2598
+ "data-touch": l || void 0,
2599
+ "data-params": u ? "open" : void 0,
2600
+ "data-empty": a || x.active ? void 0 : "",
2601
+ style: v,
2602
+ children: [
2603
+ /* @__PURE__ */ Q(Wn, {}),
2604
+ l ? /* @__PURE__ */ $(Ur.Provider, {
2605
+ value: {
2606
+ collapseParams: () => d(!1),
2607
+ tall: f,
2608
+ setTall: p,
2609
+ setSheetPx: h,
2610
+ catalog: S,
2611
+ toggleCatalog: () => C((e) => !e)
2612
+ },
2613
+ children: [/* @__PURE__ */ Q(y.Provider, {
2614
+ value: "md",
2615
+ children: /* @__PURE__ */ Q(st, {
2616
+ registry: Yr,
2617
+ rightIn: (e) => b ? gn(/* @__PURE__ */ Q("div", {
2618
+ className: "kol-editor-labs flex flex-col h-full",
2619
+ "data-touch": "",
2620
+ "data-params": "open",
2621
+ style: v,
2622
+ children: e
2623
+ }), b) : null
2624
+ })
2625
+ }), /* @__PURE__ */ Q(Kr, {
2626
+ paramsOpen: u,
2627
+ setParamsOpen: d,
2628
+ catalog: S,
2629
+ toggleCatalog: () => C((e) => !e),
2630
+ railHeight: _
2631
+ })]
2632
+ }) : /* @__PURE__ */ Q(st, { registry: Jr }),
2633
+ S && !x.picker && !(x.active && !a) && /* @__PURE__ */ Q(Pr, {
2634
+ initialOpen: w,
2635
+ hasMedia: E,
2636
+ onNeedMedia: (e) => {
2637
+ T(e), o("photo", {
2638
+ filters: [],
2639
+ fxGroup: null
2640
+ });
2641
+ },
2642
+ onPicked: () => {
2643
+ T(null), C(!1);
2644
+ },
2645
+ onClose: () => {
2646
+ T(null), C(!1);
2647
+ }
2648
+ })
2649
+ ]
2650
+ });
2651
+ }
2652
+ var Qr = "kol.editor.labs-draft";
2653
+ function $r() {
2654
+ let e = /\/morph\/?$/.test(typeof window > "u" ? "" : window.location.pathname);
2655
+ return Y(() => (q(e ? { active: !0 } : {
2656
+ active: !1,
2657
+ editing: null
2658
+ }), () => q({
2659
+ active: !1,
2660
+ editing: null
2661
+ })), [e]), /* @__PURE__ */ $(Pt, {
2662
+ draftKey: Qr,
2663
+ children: [
2664
+ /* @__PURE__ */ Q(Zr, {}),
2665
+ /* @__PURE__ */ Q(yt, {}),
2666
+ /* @__PURE__ */ Q(Te, {})
2667
+ ]
2668
+ });
2669
+ }
2670
+ //#endregion
2671
+ //#region src/editor/mobile/EffectScreen.jsx
2672
+ function ei({ layer: e, chain: t, onPick: n, onBack: r }) {
2673
+ let [i, a] = Z(null);
2674
+ Sr(r);
2675
+ let { engineHost: o } = G(e), s = o && !t.some((e) => e.def?.kind === "engine"), c = re(W.filter((e) => e.kind !== "engine" || s)), l = c.find((e) => e.id === i) ?? null;
2676
+ return /* @__PURE__ */ Q("div", {
2677
+ className: "fixed inset-y-0 right-0 left-[var(--fxr-rail,0px)] kol-overlay-scrim flex flex-col items-center overflow-y-auto p-6",
2678
+ style: { zIndex: "var(--kol-z-modal)" },
2679
+ children: /* @__PURE__ */ $("div", {
2680
+ className: "my-auto w-full max-w-sm rounded p-8 flex flex-col gap-6",
2681
+ style: { background: "var(--kol-surface-primary)" },
2682
+ children: [
2683
+ /* @__PURE__ */ Q("div", {
2684
+ className: "kol-eyebrow text-body",
2685
+ children: l ? l.label : "Pick an effect"
2686
+ }),
2687
+ /* @__PURE__ */ Q("div", {
2688
+ className: "flex flex-col gap-2",
2689
+ children: (l ? l.filters : c).map((e) => /* @__PURE__ */ Q(J, {
2690
+ tone: "primary",
2691
+ size: "lg",
2692
+ className: wt,
2693
+ iconLeft: l ? "filter" : "chevron-right",
2694
+ iconRight: l ? "filter" : "chevron-right",
2695
+ onClick: () => l ? n(e.id) : a(e.id),
2696
+ children: e.label
2697
+ }, e.id))
2698
+ }),
2699
+ /* @__PURE__ */ Q(J, {
2700
+ tone: "grey",
2701
+ size: "lg",
2702
+ className: wt,
2703
+ iconLeft: "arrow-left",
2704
+ iconRight: "arrow-left",
2705
+ onClick: () => l ? a(null) : r(),
2706
+ children: "Back"
2707
+ })
2708
+ ]
2709
+ })
2710
+ });
2711
+ }
2712
+ //#endregion
2713
+ //#region src/editor/mobile/MobileOverlay.jsx
2714
+ var ti = { background: "var(--kol-surface-primary)" }, ni = [
2715
+ {
2716
+ value: "generate",
2717
+ label: "Generate"
2718
+ },
2719
+ {
2720
+ value: "effects",
2721
+ label: "Effects"
2722
+ },
2723
+ {
2724
+ value: "transport",
2725
+ label: "Transport"
2726
+ },
2727
+ {
2728
+ value: "output",
2729
+ label: "Output"
2730
+ }
2731
+ ], ri = ni.filter((e) => e.value !== "generate"), ii = "[&_.kol-seg-cell]:min-w-0 [&_.kol-seg-cell]:px-1 [&_.kol-seg-cell]:overflow-hidden [@media(hover:none)]:[&_.kol-seg-cell:hover]:text-[var(--kol-oq-48)]", ai = {
2732
+ lg: 9.6,
2733
+ sm: 7.2
2734
+ }, oi = 10, si = 232;
2735
+ function ci(e, t) {
2736
+ let n = t === "sm" ? si : Math.min(window.innerWidth, 480) - 24, r = [], i = [], a = 0;
2737
+ for (let o of e) {
2738
+ let e = o.label.length * ai[t] + oi, s = Math.max(a, e);
2739
+ i.length && (i.length + 1) * s > n ? (r.push(i), i = [o], a = e) : (i.push(o), a = s);
2740
+ }
2741
+ return i.length && r.push(i), r;
2742
+ }
2743
+ function li({ cells: e, size: t }) {
2744
+ return ci(e, t).map((e, n) => /* @__PURE__ */ Q(Kt, {
2745
+ layout: "joined",
2746
+ value: null,
2747
+ onChange: (t) => e.find((e) => e.value === t)?.run(),
2748
+ options: e,
2749
+ size: t,
2750
+ ariaLabel: "Randomize scope",
2751
+ className: ii
2752
+ }, n));
2753
+ }
2754
+ var ui = [
2755
+ 2,
2756
+ 4,
2757
+ 8,
2758
+ 16
2759
+ ].map((e) => ({
2760
+ value: String(e),
2761
+ label: `${e}s`
2762
+ }));
2763
+ function di({ size: e }) {
2764
+ let { loopSeconds: t, setLoopSeconds: n } = a();
2765
+ return /* @__PURE__ */ Q(Kt, {
2766
+ layout: "joined",
2767
+ value: String(t),
2768
+ onChange: (e) => n(Number(e)),
2769
+ options: ui,
2770
+ size: e,
2771
+ ariaLabel: "Loop length"
2772
+ });
2773
+ }
2774
+ var fi = [
2775
+ {
2776
+ value: "9:16",
2777
+ label: "9:16"
2778
+ },
2779
+ {
2780
+ value: "3:5",
2781
+ label: "3:5"
2782
+ },
2783
+ {
2784
+ value: "4:5",
2785
+ label: "4:5"
2786
+ },
2787
+ {
2788
+ value: "1:1",
2789
+ label: "1:1"
2790
+ }
2791
+ ], pi = [
2792
+ {
2793
+ value: "5:4",
2794
+ label: "5:4"
2795
+ },
2796
+ {
2797
+ value: "5:3",
2798
+ label: "5:3"
2799
+ },
2800
+ {
2801
+ value: "16:9",
2802
+ label: "16:9"
2803
+ },
2804
+ {
2805
+ value: "fill",
2806
+ label: "Fill"
2807
+ }
2808
+ ];
2809
+ function mi({ layer: e, onSwitchCategory: t, onInsert: n, onRestart: r, aspectValue: a, onAspect: o, openEffects: s = !1, rail: c = !1, onRail: l, onSheet: u }) {
2810
+ let d = We(), { updateLayer: p, addFilter: m, removeFilter: h } = g(), { onExportPng: _ } = at(), [v, y] = Z(!1), [b, S] = Z(!0), [w, T] = Z(!1), [D, O] = Z(!1), [k, j] = Z("generate"), [M, P] = Z(!1), [F, I] = Z(!1), { aspect: L } = g(), [R, ne] = Z(null), z = E(e);
2811
+ Y(() => {
2812
+ s && (S(!0), O(!0));
2813
+ }, [s]);
2814
+ let B = c ? "sm" : "lg", re = c && !!e && b && !v;
2815
+ Y(() => (l?.(re), () => l?.(!1)), [re]);
2816
+ let U = !c && e && b && !v ? R ? `${R}px` : M ? Ar.tall : Ar.half : null;
2817
+ Y(() => (u?.(U), () => u?.(null)), [U]);
2818
+ let ie = () => {
2819
+ let t = e?.type === "loop" && V(e.loopGroup).find((t) => t.id === e.presetId);
2820
+ t && p(e.id, pe(t, e.loopGroup));
2821
+ };
2822
+ if (or(ie, () => {
2823
+ e?.type === "loop" && p(e.id, C(e, N(K(e.loopId)?.params ?? [], e), z.take(), { withFilters: !0 }));
2824
+ }), !e) return null;
2825
+ if (v) return /* @__PURE__ */ Q("button", {
2826
+ "aria-label": "Show controls",
2827
+ className: "fixed inset-y-0 right-0 left-[var(--fxr-rail,0px)] z-20",
2828
+ onClick: () => y(!1)
2829
+ });
2830
+ let W = e.type === "loop", ae = W ? `${H(e.loopGroup).label} · ${e.presetLabel}` : "Media", oe = W ? K(e.loopId)?.params ?? [] : [], se = W ? ee(oe, e) : [], ce = () => p(e.id, C(e, N(oe, e), z.take(), { withFilters: !0 })), le = (t) => p(e.id, C(e, t.params, z.take(), { stripNoRandom: !!t.motion })), ue = () => {
2831
+ let t = A(e, z.take());
2832
+ t && p(e.id, t);
2833
+ }, de = x(e), { effectable: fe } = G(e), me = () => {
2834
+ let t = te(e, z.take());
2835
+ t && p(e.id, { filters: t });
2836
+ };
2837
+ if (!b) return /* @__PURE__ */ $(kr, {
2838
+ label: W ? e.presetLabel : "Media",
2839
+ onOpen: () => S(!0),
2840
+ size: B,
2841
+ children: [
2842
+ (W || de.length > 0) && /* @__PURE__ */ Q($t, {
2843
+ label: "Randomize all",
2844
+ children: /* @__PURE__ */ Q(J, {
2845
+ tone: "primary",
2846
+ size: B,
2847
+ iconOnly: "bolt",
2848
+ "aria-label": "Randomize all",
2849
+ onClick: ce,
2850
+ className: "shrink-0"
2851
+ })
2852
+ }),
2853
+ /* @__PURE__ */ Q($t, {
2854
+ label: "Download",
2855
+ children: /* @__PURE__ */ Q(J, {
2856
+ tone: "primary",
2857
+ size: B,
2858
+ iconOnly: "download",
2859
+ "aria-label": "Download",
2860
+ onClick: () => _(2),
2861
+ className: "shrink-0"
2862
+ })
2863
+ }),
2864
+ /* @__PURE__ */ Q($t, {
2865
+ label: "Hide UI",
2866
+ children: /* @__PURE__ */ Q(J, {
2867
+ tone: "primary",
2868
+ size: B,
2869
+ iconOnly: "eye-off",
2870
+ "aria-label": "Hide UI",
2871
+ onClick: () => y(!0),
2872
+ className: "shrink-0"
2873
+ })
2874
+ }),
2875
+ /* @__PURE__ */ Q($t, {
2876
+ label: a === "fill" ? "Back to the frame" : "Fill the screen",
2877
+ children: /* @__PURE__ */ Q(J, {
2878
+ tone: "primary",
2879
+ size: B,
2880
+ iconOnly: "maximize",
2881
+ "aria-label": a === "fill" ? "Back to the frame" : "Fill the screen",
2882
+ "aria-pressed": a === "fill",
2883
+ onClick: () => o(a === "fill" ? L : "fill"),
2884
+ className: "shrink-0"
2885
+ })
2886
+ })
2887
+ ]
2888
+ });
2889
+ let he = [...W ? ni : ri, ...W && d.steps.length >= 2 ? [{
2890
+ value: "morph",
2891
+ label: "Morph"
2892
+ }] : []].filter((e) => (e.value !== "effects" || fe) && (e.value !== "transport" || f("motion"))), _e = he.some((e) => e.value === k) ? k : he[0].value;
2893
+ return /* @__PURE__ */ $(ln, { children: [
2894
+ /* @__PURE__ */ Q(ge, {
2895
+ open: F,
2896
+ onClose: () => I(!1),
2897
+ schema: oe,
2898
+ layer: e,
2899
+ size: B
2900
+ }),
2901
+ w && /* @__PURE__ */ Q(Cr, {
2902
+ onPick: (e) => {
2903
+ t(e), T(!1);
2904
+ },
2905
+ onInsert: () => {
2906
+ T(!1), n();
2907
+ },
2908
+ onBack: () => {
2909
+ T(!1), r();
2910
+ },
2911
+ onDismiss: () => T(!1)
2912
+ }),
2913
+ D && /* @__PURE__ */ Q(ei, {
2914
+ layer: e,
2915
+ chain: de,
2916
+ onPick: (t) => {
2917
+ m(e.id, t), O(!1);
2918
+ },
2919
+ onBack: () => O(!1)
2920
+ }),
2921
+ /* @__PURE__ */ $("div", {
2922
+ className: c ? "fixed top-0 right-0 bottom-0 z-10 flex w-[var(--kol-sidenav-w,320px)] flex-col overflow-y-auto border-l border-oq-08" : "fixed right-0 left-[var(--fxr-rail,0px)] bottom-0 z-10 flex flex-col pb-[env(safe-area-inset-bottom)]",
2923
+ style: c ? ti : {
2924
+ ...ti,
2925
+ top: `calc(100dvh - ${U ?? Ar.half})`
2926
+ },
2927
+ children: [
2928
+ !c && /* @__PURE__ */ Q(Mr, {
2929
+ tall: M,
2930
+ onToggle: () => {
2931
+ ne(null), P((e) => !e);
2932
+ },
2933
+ onResize: (e) => ne(Math.max(96, Math.min(window.innerHeight * .92, e))),
2934
+ onResizeEnd: (e) => {
2935
+ e < 96 && (ne(null), S(!1));
2936
+ }
2937
+ }),
2938
+ /* @__PURE__ */ Q(Or, {
2939
+ title: ae,
2940
+ onCollapse: () => S(!1),
2941
+ className: c ? "px-4 pt-2.5 pb-1.5" : "px-3",
2942
+ action: /* @__PURE__ */ Q(J, {
2943
+ tone: "ghost",
2944
+ quiet: !0,
2945
+ size: "sm",
2946
+ onClick: r,
2947
+ children: "Start over"
2948
+ })
2949
+ }),
2950
+ /* @__PURE__ */ $("div", {
2951
+ className: c ? "px-4 pb-5" : "min-h-0 flex-1 overflow-y-auto px-3 pb-3",
2952
+ children: [
2953
+ /* @__PURE__ */ Q(Kt, {
2954
+ layout: "joined",
2955
+ value: _e,
2956
+ onChange: j,
2957
+ options: he,
2958
+ size: B,
2959
+ className: c ? ii : "[&_.kol-seg-cell]:min-w-0 [&_.kol-seg-cell]:px-2 [&_.kol-seg-cell]:overflow-hidden"
2960
+ }),
2961
+ _e === "morph" && W && /* @__PURE__ */ Q(qn, {
2962
+ layer: e,
2963
+ readOnly: !0
2964
+ }),
2965
+ _e === "generate" && W && /* @__PURE__ */ $("div", {
2966
+ className: "flex flex-col gap-2 pt-3",
2967
+ children: [
2968
+ /* @__PURE__ */ $("div", {
2969
+ className: "grid grid-cols-2 gap-2",
2970
+ children: [/* @__PURE__ */ Q(J, {
2971
+ tone: "primary",
2972
+ size: B,
2973
+ iconRight: "refresh",
2974
+ onClick: ue,
2975
+ children: "Preset"
2976
+ }), /* @__PURE__ */ Q(J, {
2977
+ tone: "primary",
2978
+ size: B,
2979
+ onClick: () => T(!0),
2980
+ children: "Generator"
2981
+ })]
2982
+ }),
2983
+ /* @__PURE__ */ $("div", {
2984
+ className: "flex gap-2",
2985
+ children: [
2986
+ /* @__PURE__ */ Q(J, {
2987
+ tone: "primary",
2988
+ size: B,
2989
+ className: "flex-1 min-w-0",
2990
+ onClick: ce,
2991
+ children: "Randomize all"
2992
+ }),
2993
+ /* @__PURE__ */ Q($t, {
2994
+ label: "What Randomize all rolls",
2995
+ children: /* @__PURE__ */ Q(J, {
2996
+ tone: "primary",
2997
+ size: B,
2998
+ iconOnly: "nav-settings",
2999
+ "aria-label": "What Randomize all rolls",
3000
+ onClick: () => I(!0),
3001
+ className: "shrink-0"
3002
+ })
3003
+ }),
3004
+ /* @__PURE__ */ Q($t, {
3005
+ label: "Reset to defaults",
3006
+ shortcut: "R",
3007
+ children: /* @__PURE__ */ Q(J, {
3008
+ tone: "primary",
3009
+ size: B,
3010
+ iconOnly: "refresh",
3011
+ "aria-label": "Reset to defaults",
3012
+ onClick: ie,
3013
+ className: "shrink-0"
3014
+ })
3015
+ })
3016
+ ]
3017
+ }),
3018
+ se.length > 0 && /* @__PURE__ */ Q(li, {
3019
+ size: B,
3020
+ cells: [...se.map((e) => ({
3021
+ value: e.id,
3022
+ label: e.label,
3023
+ run: () => le(e)
3024
+ })), {
3025
+ value: "__retrigger",
3026
+ label: "Re-trigger",
3027
+ run: () => i.rewind()
3028
+ }]
3029
+ })
3030
+ ]
3031
+ }),
3032
+ _e === "effects" && /* @__PURE__ */ $("div", {
3033
+ className: "flex flex-col gap-2 pt-3",
3034
+ children: [/* @__PURE__ */ $("div", {
3035
+ className: "grid grid-cols-2 gap-2",
3036
+ children: [
3037
+ /* @__PURE__ */ Q(J, {
3038
+ tone: "primary",
3039
+ size: B,
3040
+ onClick: () => O(!0),
3041
+ children: "Add effect"
3042
+ }),
3043
+ de.length > 0 && /* @__PURE__ */ Q(J, {
3044
+ tone: "primary",
3045
+ size: B,
3046
+ onClick: me,
3047
+ children: "Randomize"
3048
+ }),
3049
+ " "
3050
+ ]
3051
+ }), de.map((t, n) => {
3052
+ let r = {
3053
+ ...e,
3054
+ ...t.params,
3055
+ id: e.id
3056
+ }, i = t.def ? ee(t.def.params, r) : [], a = (t) => {
3057
+ let i = C(r, t.params, z.take(), { stripNoRandom: !!t.motion }), a = de.map(({ def: e, ...t }) => t);
3058
+ p(e.id, { filters: a.map((e, t) => t === n ? {
3059
+ ...e,
3060
+ params: {
3061
+ ...e.params,
3062
+ ...i
3063
+ }
3064
+ } : e) });
3065
+ };
3066
+ return /* @__PURE__ */ $("div", {
3067
+ className: "flex flex-col gap-2",
3068
+ children: [/* @__PURE__ */ Q(J, {
3069
+ tone: "grey",
3070
+ size: B,
3071
+ className: "w-full [&>span]:w-full [&>span]:justify-between",
3072
+ iconLeft: "trash",
3073
+ iconRight: "trash",
3074
+ onClick: () => h(e.id, n),
3075
+ children: `${n + 1}. ${t.def?.label ?? t.id}`
3076
+ }), i.length > 0 && /* @__PURE__ */ Q(li, {
3077
+ size: B,
3078
+ cells: i.map((e) => ({
3079
+ value: e.id,
3080
+ label: e.label,
3081
+ run: () => a(e)
3082
+ }))
3083
+ })]
3084
+ }, t.key);
3085
+ })]
3086
+ }),
3087
+ _e === "transport" && f("motion") && /* @__PURE__ */ $("div", {
3088
+ className: "flex flex-col gap-2 pt-3",
3089
+ children: [(() => {
3090
+ let e = f("motion").TransportBar;
3091
+ return /* @__PURE__ */ Q(e, { size: B });
3092
+ })(), /* @__PURE__ */ Q(di, { size: B })]
3093
+ }),
3094
+ _e === "output" && /* @__PURE__ */ $("div", {
3095
+ className: "flex flex-col gap-2 pt-3",
3096
+ children: [
3097
+ /* @__PURE__ */ Q(Kt, {
3098
+ layout: "joined",
3099
+ value: a,
3100
+ onChange: o,
3101
+ options: fi,
3102
+ size: B,
3103
+ ariaLabel: "Aspect"
3104
+ }),
3105
+ /* @__PURE__ */ Q(Kt, {
3106
+ layout: "joined",
3107
+ value: a,
3108
+ onChange: o,
3109
+ options: pi,
3110
+ size: B,
3111
+ ariaLabel: "Aspect (landscape) and fill"
3112
+ }),
3113
+ /* @__PURE__ */ $("div", {
3114
+ className: "grid grid-cols-2 gap-2",
3115
+ children: [
3116
+ /* @__PURE__ */ Q(J, {
3117
+ tone: "primary",
3118
+ size: B,
3119
+ onClick: () => Ht({ focusName: !0 }),
3120
+ children: "Save…"
3121
+ }),
3122
+ /* @__PURE__ */ Q(J, {
3123
+ tone: "primary",
3124
+ size: B,
3125
+ onClick: () => _(2),
3126
+ children: "Download"
3127
+ }),
3128
+ /* @__PURE__ */ Q(J, {
3129
+ tone: "primary",
3130
+ size: B,
3131
+ onClick: () => y(!0),
3132
+ children: "Hide UI"
3133
+ }),
3134
+ /* @__PURE__ */ Q(J, {
3135
+ tone: "primary",
3136
+ size: B,
3137
+ onClick: r,
3138
+ children: "Start over"
3139
+ })
3140
+ ]
3141
+ })
3142
+ ]
3143
+ })
3144
+ ]
3145
+ })
3146
+ ]
3147
+ })
3148
+ ] });
3149
+ }
3150
+ //#endregion
3151
+ //#region src/editor/mobile/MobileView.jsx
3152
+ function hi({ onGenerate: e, onEffects: t, chromes: n }) {
3153
+ return /* @__PURE__ */ Q("div", {
3154
+ className: "fixed inset-y-0 right-0 left-[var(--fxr-rail,0px)] kol-overlay-scrim flex flex-col items-center justify-center p-6",
3155
+ style: { zIndex: "var(--kol-z-modal)" },
3156
+ children: /* @__PURE__ */ $("div", {
3157
+ className: "w-full max-w-sm rounded p-8 flex flex-col gap-6",
3158
+ style: { background: "var(--kol-surface-primary)" },
3159
+ children: [n ? /* @__PURE__ */ $("div", {
3160
+ className: "flex flex-col gap-2",
3161
+ children: [/* @__PURE__ */ Q("span", {
3162
+ className: "kol-eyebrow text-body",
3163
+ children: "Select chrome"
3164
+ }), /* @__PURE__ */ Q("span", {
3165
+ className: "kol-mono-16 text-emphasis",
3166
+ children: "FXR"
3167
+ })]
3168
+ }) : /* @__PURE__ */ Q("span", {
3169
+ className: "kol-eyebrow text-body",
3170
+ children: zt("randomiser").label
3171
+ }), /* @__PURE__ */ $("div", {
3172
+ className: "flex flex-col gap-2",
3173
+ children: [
3174
+ /* @__PURE__ */ Q(J, {
3175
+ tone: "primary",
3176
+ size: "lg",
3177
+ className: wt,
3178
+ iconLeft: Nt.randomiser,
3179
+ iconRight: Nt.randomiser,
3180
+ onClick: e,
3181
+ children: "Generate"
3182
+ }),
3183
+ /* @__PURE__ */ Q(J, {
3184
+ tone: "primary",
3185
+ size: "lg",
3186
+ className: wt,
3187
+ iconLeft: "filter",
3188
+ iconRight: "filter",
3189
+ onClick: t,
3190
+ children: "Effects"
3191
+ }),
3192
+ n && Bt() && /* @__PURE__ */ Q(J, {
3193
+ tone: "primary",
3194
+ size: "lg",
3195
+ className: "w-full [&>span]:w-full [&>span]:justify-between",
3196
+ iconLeft: Nt.editor,
3197
+ iconRight: Nt.editor,
3198
+ onClick: Wt,
3199
+ children: zt("editor").label
3200
+ }),
3201
+ n && /* @__PURE__ */ Q(J, {
3202
+ tone: "primary",
3203
+ size: "lg",
3204
+ className: "w-full [&>span]:w-full [&>span]:justify-between",
3205
+ iconLeft: Nt.labs,
3206
+ iconRight: Nt.labs,
3207
+ onClick: Et,
3208
+ children: zt("labs").label
3209
+ }),
3210
+ n && /* @__PURE__ */ Q(J, {
3211
+ tone: "primary",
3212
+ size: "lg",
3213
+ className: "w-full [&>span]:w-full [&>span]:justify-between",
3214
+ iconLeft: "swap",
3215
+ iconRight: "swap",
3216
+ onClick: () => Ft("/morph"),
3217
+ children: "Morph"
3218
+ })
3219
+ ]
3220
+ })]
3221
+ })
3222
+ });
3223
+ }
3224
+ function gi() {
3225
+ let { layers: e, addLayer: t, removeLayer: n, updateLayer: r, canvasW: a, canvasH: o, aspect: s, setAspect: c } = g(), { setTool: u } = gt(), d = Lt() && !Vt(), f = Rt(), p = () => {
3226
+ let e = new URLSearchParams(window.location.search);
3227
+ return e.get("open") ? "live" : e.get("start") === "category" ? "category" : "entry";
3228
+ }, [m, _] = Z(p), [v, y] = Z(!1), [b, x] = Z(null), [S, C] = Z("contain"), [w, T] = Z(!1), [E, D] = Z(null), [O, k] = Z({
3229
+ s: 1,
3230
+ x: 0,
3231
+ y: 0
3232
+ }), A = X(null), j = X({
3233
+ pts: /* @__PURE__ */ new Map(),
3234
+ start: null,
3235
+ live: {
3236
+ s: 1,
3237
+ x: 0,
3238
+ y: 0
3239
+ }
3240
+ }), M = X(null), N = () => {
3241
+ let [e, t] = [...j.current.pts.values()];
3242
+ return {
3243
+ d: Math.hypot(e.x - t.x, e.y - t.y),
3244
+ mx: (e.x + t.x) / 2,
3245
+ my: (e.y + t.y) / 2
3246
+ };
3247
+ }, ee = (e) => `translate(${e.x}px, ${e.y}px) scale(${e.s})`, P = (e) => {
3248
+ if (j.current.pts.set(e.pointerId, {
3249
+ x: e.clientX,
3250
+ y: e.clientY
3251
+ }), M.current = j.current.pts.size === 1 ? {
3252
+ id: e.pointerId,
3253
+ x: e.clientX,
3254
+ y: e.clientY,
3255
+ t: performance.now()
3256
+ } : null, j.current.pts.size === 2) {
3257
+ let t = A.current?.getBoundingClientRect(), n = N(), r = (t?.left ?? 0) - O.x, a = (t?.top ?? 0) - O.y;
3258
+ j.current.start = {
3259
+ ...n,
3260
+ ox: r,
3261
+ oy: a,
3262
+ v: O,
3263
+ px: (n.mx - r - O.x) / O.s,
3264
+ py: (n.my - a - O.y) / O.s
3265
+ }, j.current.live = O, i.setStagePointer(null), e.stopPropagation();
3266
+ }
3267
+ }, F = (e) => {
3268
+ let t = j.current;
3269
+ if (t.pts.has(e.pointerId) && (t.pts.set(e.pointerId, {
3270
+ x: e.clientX,
3271
+ y: e.clientY
3272
+ }), t.pts.size >= 2 && t.start)) {
3273
+ e.stopPropagation();
3274
+ let n = N(), r = t.start, i = Math.min(4, Math.max(.5, r.v.s * (n.d / r.d)));
3275
+ t.live = {
3276
+ s: i,
3277
+ x: n.mx - r.ox - i * r.px,
3278
+ y: n.my - r.oy - i * r.py
3279
+ }, A.current && (A.current.style.transform = ee(t.live));
3280
+ }
3281
+ }, te = (e) => {
3282
+ let t = M.current;
3283
+ t && t.id === e.pointerId && e.type === "pointerup" && m === "live" && performance.now() - t.t < 350 && Math.hypot(e.clientX - t.x, e.clientY - t.y) < 12 && (I?.type === "loop" ? K(I.loopId) : null)?.group !== "penrose" && i.toggle(), t?.id === e.pointerId && (M.current = null), j.current.pts.delete(e.pointerId), j.current.pts.size < 2 && j.current.start && (j.current.start = null, k(j.current.live));
3284
+ };
3285
+ hn(), Y(() => (Ot("randomiser"), () => Ot(null)), []), Y(() => {
3286
+ c("4:5"), u("orbit");
3287
+ }, []);
3288
+ let I = e.find((e) => e.id === b) ?? (e.length === 1 ? e[0] : null), L = m === "live" && I?.type === "photo" && !I.src && I.srcType !== "webcam";
3289
+ Y(() => {
3290
+ if (!L) return;
3291
+ let e = (e) => {
3292
+ e.key === "Escape" && V();
3293
+ };
3294
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
3295
+ }), Y(() => {
3296
+ if (!L) return;
3297
+ let e = i.isPlaying();
3298
+ return i.pause(), () => {
3299
+ e && i.play();
3300
+ };
3301
+ }, [L]);
3302
+ let R = (e) => {
3303
+ let n = ae(e);
3304
+ n && (x(t("loop", n)), _("live"));
3305
+ }, ne = (e) => {
3306
+ let t = ae(e);
3307
+ t && b && r(b, t);
3308
+ }, z = () => {
3309
+ x(t("photo", {
3310
+ fit: "cover",
3311
+ x: 0,
3312
+ y: 0,
3313
+ w: l,
3314
+ h: Math.round(l * o / a)
3315
+ })), _("live");
3316
+ };
3317
+ Y(() => {
3318
+ let e = new URL(window.location.href), t = e.searchParams.get("start");
3319
+ t && (t === "effects" && (y(!0), z()), e.searchParams.delete("start"), window.history.replaceState(window.history.state, "", e));
3320
+ }, []);
3321
+ let B = (e) => {
3322
+ if (e === "fill") {
3323
+ C("cover");
3324
+ return;
3325
+ }
3326
+ C("contain"), c(e);
3327
+ let t = h[e];
3328
+ b && t && r(b, {
3329
+ x: 0,
3330
+ y: 0,
3331
+ w: l,
3332
+ h: Math.round(l * t.h / t.w)
3333
+ });
3334
+ }, V = () => {
3335
+ for (let t of [...e]) n(t.id);
3336
+ x(null), k({
3337
+ s: 1,
3338
+ x: 0,
3339
+ y: 0
3340
+ }), y(!1), _(p());
3341
+ };
3342
+ return /* @__PURE__ */ $("div", {
3343
+ className: "kol-editor-randomiser relative h-dvh bg-black",
3344
+ children: [
3345
+ /* @__PURE__ */ Q("div", {
3346
+ ref: A,
3347
+ className: "absolute inset-y-0 left-0 touch-none overflow-hidden",
3348
+ style: {
3349
+ transform: ee(O),
3350
+ transformOrigin: "0 0",
3351
+ right: w ? "var(--kol-sidenav-w, 320px)" : 0,
3352
+ bottom: E ?? 0
3353
+ },
3354
+ onPointerDownCapture: P,
3355
+ onPointerMoveCapture: F,
3356
+ onPointerUpCapture: te,
3357
+ onPointerCancelCapture: te,
3358
+ onPointerLeave: te,
3359
+ children: /* @__PURE__ */ Q(Tt, { fit: S })
3360
+ }),
3361
+ m === "entry" && /* @__PURE__ */ Q(hi, {
3362
+ chromes: d,
3363
+ onGenerate: () => _("category"),
3364
+ onEffects: () => {
3365
+ y(!0), z();
3366
+ }
3367
+ }),
3368
+ m === "category" && /* @__PURE__ */ Q(Cr, {
3369
+ onPick: R,
3370
+ onInsert: z,
3371
+ onBack: () => _("entry")
3372
+ }),
3373
+ m === "live" && !L && /* @__PURE__ */ Q(mi, {
3374
+ layer: I,
3375
+ onSwitchCategory: ne,
3376
+ onInsert: () => {
3377
+ V(), z();
3378
+ },
3379
+ onRestart: V,
3380
+ aspectValue: S === "cover" ? "fill" : s,
3381
+ openEffects: v && !L,
3382
+ onAspect: B,
3383
+ rail: !d && !f,
3384
+ onRail: T,
3385
+ onSheet: D
3386
+ }),
3387
+ L && /* @__PURE__ */ $("div", {
3388
+ className: "fixed inset-y-0 right-0 left-[var(--fxr-rail,0px)] kol-overlay-scrim flex flex-col",
3389
+ style: { zIndex: "var(--kol-z-modal)" },
3390
+ children: [/* @__PURE__ */ Q("div", {
3391
+ className: "flex-1 min-h-0",
3392
+ children: /* @__PURE__ */ Q(Er, { layer: I })
3393
+ }), /* @__PURE__ */ Q("div", {
3394
+ className: "flex justify-center pb-[max(0.75rem,env(safe-area-inset-bottom))]",
3395
+ children: /* @__PURE__ */ Q(J, {
3396
+ tone: "outline",
3397
+ size: "lg",
3398
+ onClick: V,
3399
+ children: "Back"
3400
+ })
3401
+ })]
3402
+ })
3403
+ ]
3404
+ });
3405
+ }
3406
+ function _i() {
3407
+ return /* @__PURE__ */ $(Pt, {
3408
+ persistDraft: !1,
3409
+ children: [/* @__PURE__ */ Q(gi, {}), /* @__PURE__ */ Q(yt, {})]
3410
+ });
3411
+ }
3412
+ //#endregion
3413
+ //#region src/editor/float/Movable.jsx
3414
+ var vi = "button, a, input, select, textarea, [role=button], [role=tab], [role=slider]", yi = (e, t) => Math.max(0, Math.min(e, t));
3415
+ function bi({ id: e, start: t = {
3416
+ right: 24,
3417
+ bottom: 24
3418
+ }, onMoved: n, className: r = "", children: i }) {
3419
+ let a = `kol-float-pos:${e}`, o = JSON.stringify(t), [s, c] = Z(() => {
3420
+ try {
3421
+ let e = JSON.parse(localStorage.getItem(a));
3422
+ return e?.start === o ? e.right == null ? {
3423
+ left: e.left,
3424
+ top: e.top
3425
+ } : {
3426
+ right: e.right,
3427
+ bottom: e.bottom
3428
+ } : null;
3429
+ } catch {
3430
+ return null;
3431
+ }
3432
+ }), l = X(null);
3433
+ return Y(() => {
3434
+ n?.(!!s);
3435
+ }, [!!s]), /* @__PURE__ */ Q("div", {
3436
+ ref: l,
3437
+ onPointerDown: (e) => {
3438
+ if (e.button !== 0 || e.target.closest(vi)) return;
3439
+ let t = l.current, n = t.getBoundingClientRect(), r = t.offsetParent.getBoundingClientRect(), i = e.clientX - n.left, s = e.clientY - n.top, u = null;
3440
+ t.setPointerCapture(e.pointerId);
3441
+ let d = (t) => {
3442
+ if (!u && Math.hypot(t.clientX - e.clientX, t.clientY - e.clientY) < 4) return;
3443
+ let a = yi(t.clientX - r.left - i, r.width - n.width), o = yi(t.clientY - r.top - s, r.height - n.height);
3444
+ u = {
3445
+ right: r.width - a - n.width,
3446
+ bottom: r.height - o - n.height
3447
+ }, c(u);
3448
+ }, f = () => {
3449
+ if (t.removeEventListener("pointermove", d), t.removeEventListener("pointerup", f), t.removeEventListener("pointercancel", f), u) try {
3450
+ localStorage.setItem(a, JSON.stringify({
3451
+ ...u,
3452
+ start: o
3453
+ }));
3454
+ } catch {}
3455
+ };
3456
+ t.addEventListener("pointermove", d), t.addEventListener("pointerup", f), t.addEventListener("pointercancel", f);
3457
+ },
3458
+ style: s ?? t,
3459
+ onDoubleClick: (e) => {
3460
+ if (!e.target.closest(vi)) {
3461
+ c(null);
3462
+ try {
3463
+ localStorage.removeItem(a);
3464
+ } catch {}
3465
+ }
3466
+ },
3467
+ className: `absolute z-[var(--kol-z-sticky)] cursor-grab active:cursor-grabbing touch-none select-none ${r}`.trim(),
3468
+ children: i
3469
+ });
3470
+ }
3471
+ //#endregion
3472
+ //#region src/editor/labs/FloatLabs.jsx
3473
+ function xi() {
3474
+ let { addFilter: e, patchFilter: t } = g(), { layer: n, setOnly: r } = De(), i = X(null);
3475
+ Y(() => {
3476
+ n?.type === "photo" && n.src && (i.current = {
3477
+ src: n.src,
3478
+ srcType: n.srcType,
3479
+ fit: n.fit
3480
+ });
3481
+ }, [
3482
+ n?.type,
3483
+ n?.src,
3484
+ n?.srcType,
3485
+ n?.fit
3486
+ ]);
3487
+ let a = Un({
3488
+ layer: n,
3489
+ setOnly: r,
3490
+ addFilter: e,
3491
+ patchFilter: t,
3492
+ carriedSource: () => n?.type === "photo" ? {
3493
+ src: n.src,
3494
+ srcType: n.srcType,
3495
+ fit: n.fit
3496
+ } : i.current ?? {}
3497
+ }), o = [], s = /* @__PURE__ */ new Map(), c = null;
3498
+ return a.forEach((e) => {
3499
+ if (e.id.startsWith("sec:")) {
3500
+ o.push({
3501
+ icon: zn[e.id.slice(4)] ?? "square",
3502
+ label: e.label,
3503
+ path: e.id,
3504
+ sub: []
3505
+ });
3506
+ return;
3507
+ }
3508
+ let t = e.pages ?? [], n = e.onSelect ?? t[0]?.onSelect ?? t[0]?.children?.[0]?.onSelect;
3509
+ n && s.set(e.id, n), (e.active || t.some((e) => e.active || e.children?.some((e) => e.active))) && (c = e.id);
3510
+ let r = {
3511
+ icon: e.icon,
3512
+ label: e.label,
3513
+ path: e.id
3514
+ }, i = o[o.length - 1];
3515
+ i?.sub ? i.sub.push(r) : o.push(r);
3516
+ }), {
3517
+ items: o,
3518
+ active: c,
3519
+ pick: (e) => s.get(e)?.()
3520
+ };
3521
+ }
3522
+ function Si() {
3523
+ let { layer: e } = De(), { removeLayer: t } = g(), n = e?.type === "photo" && !e.src && e.srcType !== "webcam";
3524
+ return /* @__PURE__ */ $("div", {
3525
+ className: "kol-float-labs-stage absolute inset-0 flex items-center justify-center overflow-hidden bg-surface-primary",
3526
+ children: [/* @__PURE__ */ Q("div", {
3527
+ style: {
3528
+ flex: "none",
3529
+ width: "85%",
3530
+ height: "85%"
3531
+ },
3532
+ children: /* @__PURE__ */ Q(Ct, {})
3533
+ }), n && /* @__PURE__ */ Q(Dr, {
3534
+ layer: e,
3535
+ title: Fr(e).title,
3536
+ onBack: () => t(e.id)
3537
+ })]
3538
+ });
3539
+ }
3540
+ function Ci() {
3541
+ It(), Xr();
3542
+ let e = tn("(max-width: 767px)"), { layer: t } = De(), { selectedId: n, select: r } = g();
3543
+ Y(() => {
3544
+ t && n !== t.id && r(t.id);
3545
+ }, [
3546
+ t,
3547
+ n,
3548
+ r
3549
+ ]);
3550
+ let i = xi(), { title: a, kind: o } = t ? Fr(t) : { title: "Labs" }, s = i.items.filter((e) => e.sub?.length).map((e) => e.path), [c, l] = Z(e), [u, d] = Z(e), [f, p] = Z(!1), [m, h] = Z(!1);
3551
+ return /* @__PURE__ */ $("div", {
3552
+ className: "kol-float-labs kol-editor-shell relative h-dvh overflow-hidden",
3553
+ "data-editor-keep-selection": !0,
3554
+ children: [
3555
+ /* @__PURE__ */ Q(Si, {}),
3556
+ u ? /* @__PURE__ */ Q(pn, {
3557
+ items: i.items,
3558
+ currentPath: i.active ?? "",
3559
+ onNavigate: i.pick,
3560
+ title: "Labs",
3561
+ breadcrumb: ["Labs", a],
3562
+ onRestore: () => d(!1),
3563
+ className: "absolute left-6 top-6 z-[var(--kol-z-sticky)]"
3564
+ }) : /* @__PURE__ */ Q(Xt, {
3565
+ variant: "float",
3566
+ items: i.items,
3567
+ currentPath: i.active ?? "",
3568
+ onNavigate: i.pick,
3569
+ title: "Labs",
3570
+ icon: "globe",
3571
+ defaultExpanded: s,
3572
+ collapsed: c,
3573
+ onCollapsedChange: l,
3574
+ onHide: () => d(!0),
3575
+ collapsibleV: !0,
3576
+ collapsedV: m,
3577
+ onCollapseV: h,
3578
+ footer: c ? void 0 : /* @__PURE__ */ Q(fn, {
3579
+ onCollapse: () => l(!0),
3580
+ onHide: () => d(!0)
3581
+ }),
3582
+ className: `absolute left-6 top-6 z-[var(--kol-z-sticky)] ${m && !c ? "" : "bottom-6 !h-auto"}`
3583
+ }),
3584
+ !e && /* @__PURE__ */ Q(bi, {
3585
+ id: "labs-transport",
3586
+ start: {
3587
+ right: 24,
3588
+ bottom: 24
3589
+ },
3590
+ onMoved: p,
3591
+ children: /* @__PURE__ */ Q(At, { collapsibleH: !0 })
3592
+ }),
3593
+ /* @__PURE__ */ Q("div", {
3594
+ className: `absolute ${e ? "left-6 right-6 top-[88px]" : "top-6 right-6"} ${!e && !f ? "bottom-24" : "bottom-6"} z-[var(--kol-z-sticky)] flex flex-col pointer-events-none [&>*]:pointer-events-auto`,
3595
+ children: /* @__PURE__ */ Q(dn, {
3596
+ wide: !0,
3597
+ width: e ? "100%" : void 0,
3598
+ density: "compact",
3599
+ surface: "solid",
3600
+ className: "max-h-full",
3601
+ windows: [
3602
+ {
3603
+ id: "params",
3604
+ title: a || "Labs",
3605
+ kind: o,
3606
+ defaultCollapsedV: e,
3607
+ className: "[&_.kol-compose-inspector-body]:!p-0",
3608
+ children: t ? /* @__PURE__ */ Q("div", {
3609
+ className: "kol-editor-labs",
3610
+ children: /* @__PURE__ */ Q("div", {
3611
+ className: "kol-compose-inspector-body",
3612
+ children: /* @__PURE__ */ Q(xr, {})
3613
+ })
3614
+ }) : /* @__PURE__ */ Q(Jt, {
3615
+ variant: "float",
3616
+ label: "Parameters"
3617
+ })
3618
+ },
3619
+ {
3620
+ id: "output",
3621
+ title: "Output",
3622
+ defaultCollapsedV: e,
3623
+ children: /* @__PURE__ */ Q("div", {
3624
+ className: "kol-editor-labs",
3625
+ children: /* @__PURE__ */ Q(Dt, { part: "output" })
3626
+ })
3627
+ },
3628
+ {
3629
+ id: "file",
3630
+ title: "File",
3631
+ defaultCollapsedV: e,
3632
+ children: /* @__PURE__ */ Q("div", {
3633
+ className: "kol-editor-labs",
3634
+ children: /* @__PURE__ */ Q(Dt, { part: "file" })
3635
+ })
3636
+ }
3637
+ ]
3638
+ })
3639
+ })
3640
+ ]
3641
+ });
3642
+ }
3643
+ function wi() {
3644
+ return /* @__PURE__ */ Q(I.Provider, {
3645
+ value: "float",
3646
+ children: /* @__PURE__ */ $(Pt, {
3647
+ draftKey: Qr,
3648
+ modalVariant: "float",
3649
+ children: [/* @__PURE__ */ Q(Ci, {}), /* @__PURE__ */ Q(yt, {})]
3650
+ })
3651
+ });
3652
+ }
3653
+ //#endregion
3654
+ //#region src/index.jsx
3655
+ function Ti(e = {}) {
3656
+ return e.variant === "kolbox" ? /* @__PURE__ */ Q(Di, { ...e }) : /* @__PURE__ */ Q(Ut, { ...e });
3657
+ }
3658
+ var Ei = on(() => import("./KolboxView-n6kEPJtV.js"));
3659
+ function Di({ mediaProxyBase: e, mediaClient: t, settingsStore: r, pages: i, account: a }) {
3660
+ return e != null && ot(e), t && ut(t), Y(() => {
3661
+ if (r) return n(r), () => n(null);
3662
+ }, [r]), hn(), vn({
3663
+ client: t ?? null,
3664
+ store: () => r ?? null,
3665
+ account: a ?? null
3666
+ }), /* @__PURE__ */ Q(rn, {
3667
+ fallback: null,
3668
+ children: /* @__PURE__ */ Q(Ei, { pages: i })
3669
+ });
3670
+ }
3671
+ //#endregion
3672
+ export { yn as _, $r as a, or as c, Un as d, Dn as f, xn as g, Nn as h, Qr as i, Rn as l, In as m, wi as n, Xr as o, Fn as p, _i as r, Fr as s, Ti as t, zn as u, bn as v };