@kolkrabbi/design-editor 0.19.0 → 0.21.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.
@@ -1,19 +1,20 @@
1
- import { B as e, Ft as t, It as n, L as r, S as i, Xt as a, Zt as o, a as s, at as c, b as l, c as u, i as d, it as f, j as p, l as m, n as h, o as g, ot as _, r as v, rt as y, tt as b, u as x, w as S, wt as ee, x as C } from "./rolls-CkmuE-Ya.js";
2
- import { c as w, d as T, f as E, l as D, n as O, o as k, p as te, r as A, t as j } from "./registry-CSOtIU7o.js";
3
- import { c as M, n as N, s as P } from "./generators-Bk3mvrsm.js";
4
- import { n as F, r as I, t as ne } from "./useLayerEdit-DRZ09kNJ.js";
5
- import { a as L, c as R, d as re, f as z, i as ie, l as B, n as ae, o as oe, r as se, s as ce, u as le } from "./effects-DehkU1My.js";
6
- import { t as ue } from "./BindDot-CuCS4LS-.js";
7
- import { a as V, i as de, n as fe, o as pe, r as me, s as he } from "./motion-9j3WO6a2.js";
8
- import { A as ge, B as _e, C as ve, D as ye, E as be, F as xe, G as Se, H as Ce, I as we, K as Te, L as Ee, M as De, N as Oe, O as ke, P as Ae, R as je, S as Me, T as Ne, U as Pe, V as Fe, W as Ie, _ as Le, a as Re, b as ze, c as Be, d as Ve, f as He, g as Ue, h as We, i as Ge, j as Ke, k as qe, l as Je, m as Ye, n as Xe, o as Ze, p as Qe, q as $e, r as et, s as tt, t as nt, u as rt, v as it, w as at, x as ot, y as st, z as ct } from "./core-BeIRJu1Z.js";
9
- import { Button as H, Divider as lt, Dropdown as ut, FullscreenOverlay as dt, LabeledControlSection as U, SegmentedToggle as W, ToggleSwitch as ft, Tooltip as G } from "@kolkrabbi/kol-component";
10
- import { createContext as pt, useCallback as mt, useContext as ht, useEffect as K, useRef as q, useState as J } from "react";
11
- import { Fragment as Y, jsx as X, jsxs as Z } from "react/jsx-runtime";
12
- import { Icon as Q } from "@kolkrabbi/kol-icons";
13
- import { useDragResize as gt, useTheme as _t } from "@kolkrabbi/kol-framework";
1
+ import { B as e, L as t, Rt as n, S as r, a as i, at as a, b as o, c as s, i as c, it as l, j as u, l as d, mn as f, n as p, o as m, ot as h, pn as g, r as _, rt as v, tt as y, u as b, w as x, wt as ee, x as S, zt as C } from "./rolls-Bg1XHuvJ.js";
2
+ import { a as te, d as ne, f as w, g as T, h as E, i as D, l as re, m as O, n as k, o as A, r as j, t as M } from "./useLayerEdit-ieOjHx6x.js";
3
+ import { s as N } from "./RuleRow-BXkjpTyN.js";
4
+ import { n as P } from "./generators-B8_StNAy.js";
5
+ import { a as F, f as I, i as L, l as ie, n as R, o as ae, r as z, s as oe, t as se, u as B } from "./effectCategories-BcaQSD_V.js";
6
+ import { n as ce, r as V } from "./effects-pCd8YTdQ.js";
7
+ import { c as le, i as H, r as ue } from "./labels-B5qkocWy.js";
8
+ import { i as U, n as de, r as fe } from "./motion-DFnAar_2.js";
9
+ import { $ as pe, A as me, B as he, C as ge, D as _e, E as ve, F as ye, G as be, H as xe, I as W, J as Se, K as Ce, L as we, M as Te, N as Ee, O as De, P as Oe, Q as ke, R as G, S as Ae, T as je, U as Me, V as Ne, W as Pe, X as Fe, Y as Ie, Z as Le, _ as Re, a as ze, b as Be, c as Ve, d as He, et as Ue, f as We, g as Ge, h as Ke, i as qe, j as Je, k as Ye, l as Xe, m as Ze, n as Qe, nt as $e, o as et, p as tt, q as nt, r as rt, rt as it, s as at, t as ot, tt as st, u as ct, v as lt, w as ut, x as dt, y as ft, z as pt } from "./core-B2bfXyS5.js";
10
+ import { Button as K, Divider as mt, Dropdown as ht, LabeledControlSection as gt, SegmentedToggle as q, ToggleSwitch as _t, Tooltip as vt } from "@kolkrabbi/kol-component";
11
+ import { createContext as yt, useCallback as bt, useContext as xt, useEffect as J, useRef as Y, useState as X } from "react";
12
+ import { Fragment as St, jsx as Z, jsxs as Q } from "react/jsx-runtime";
13
+ import { Icon as Ct } from "@kolkrabbi/kol-icons";
14
+ import { useDragResize as wt, useTheme as Tt } from "@kolkrabbi/kol-framework";
14
15
  //#region src/editor/labs/useLabsLayer.js
15
- function vt() {
16
- let { layers: e, addLayer: t, removeLayer: n, updateLayer: r, select: i, beginTransaction: a, commitTransaction: o } = p(), s = mt((s, c) => {
16
+ function $() {
17
+ let { layers: e, addLayer: t, removeLayer: n, updateLayer: r, select: i, beginTransaction: a, commitTransaction: o } = u(), s = bt((s, c) => {
17
18
  let [l, ...u] = e;
18
19
  a();
19
20
  for (let e of u) n(e.id);
@@ -34,214 +35,10 @@ function vt() {
34
35
  };
35
36
  }
36
37
  //#endregion
37
- //#region src/editor/labs/catalog.js
38
- var $ = {
39
- "fx:halftone": "ptrn-dot",
40
- "fx:scanline": "grid-horizontal",
41
- "fx:crt": "desktop",
42
- "fx:refraction": "circle",
43
- "fx:fx-rack": "target",
44
- "fx:pattern": "ptrn-checker",
45
- "fx:other": "more",
46
- "gen:Scanline": "grid-horizontal",
47
- "gen:Pattern": "ptrn-checker",
48
- "gen:Loops": "refresh",
49
- "gen:Math": "sum",
50
- "gen:Penrose": "a-framed",
51
- "gen:Drift": "dith-flow",
52
- "gen:Gradients": "circle",
53
- "gen:Soft Forms": "paint-drop",
54
- "gen:Soft Forms 3D": "ball",
55
- "gen:3D Scene": "ball",
56
- "kin:Type": "font-01",
57
- "kin:Kinetic": "font-01",
58
- "misc:Para Type": "aa",
59
- "vec:Distressor": "scribble",
60
- "vec:Modulator": "dashed-circle"
61
- }, yt = {
62
- effects: "filter",
63
- generative: "layers",
64
- vector: "pen-nib",
65
- composition: "type",
66
- modulation: "frequency",
67
- mode: "mode-toggle-01"
68
- }, bt = {
69
- editor: "desktop",
70
- labs: "globe",
71
- randomiser: "refresh"
72
- }, xt = [
73
- "Moiré",
74
- "Mesh Gradient",
75
- "Reaction",
76
- "Halftone"
77
- ], St = [
78
- {
79
- label: "Spaced",
80
- patch: {
81
- geometry: "rows",
82
- mark: "dots"
83
- }
84
- },
85
- {
86
- label: "Glyph",
87
- patch: { mark: "glyph" }
88
- },
89
- {
90
- label: "Lattice",
91
- patch: { mark: "lattice" }
92
- },
93
- {
94
- label: "Vortex",
95
- patch: {
96
- geometry: "radial",
97
- swirl: .8,
98
- rayCount: 220
99
- }
100
- },
101
- {
102
- label: "Rings",
103
- patch: { geometry: "rings" }
104
- },
105
- {
106
- label: "Spiral",
107
- patch: { geometry: "spiral" }
108
- }
109
- ], Ct = (e = {}) => {
110
- let t = e.geometry ?? "rows";
111
- return t === "radial" ? "Vortex" : t === "rings" ? "Rings" : t === "spiral" ? "Spiral" : e.mark === "glyph" ? "Glyph" : e.mark === "lattice" ? "Lattice" : "Spaced";
112
- };
113
- function wt({ layer: e, setOnly: t, addFilter: n, patchFilter: r, carriedSource: i }) {
114
- let a = (e, a) => {
115
- let o = t("photo", {
116
- ...i(),
117
- filters: [],
118
- fxGroup: null
119
- });
120
- o && (n(o, e), a && r(o, 0, a)), window.dispatchEvent(new CustomEvent("kol:open-effects"));
121
- }, o = (e) => {
122
- t("photo", {
123
- ...i(),
124
- filters: [],
125
- fxGroup: e
126
- }), window.dispatchEvent(new CustomEvent("kol:open-effects"));
127
- }, s = (e, n) => {
128
- t("loop", D(e, n)), window.dispatchEvent(new CustomEvent("kol:open-params"));
129
- }, c = (e) => {
130
- t("kinetic", {
131
- presetId: e.id,
132
- presetLabel: e.label,
133
- comp: he(e)
134
- }), window.dispatchEvent(new CustomEvent("kol:open-params"));
135
- }, l = e?.presetId ?? null, u = e?.filters?.[0]?.id ?? null, d = l ? T(e?.loopGroup).find((e) => e.id === l) ?? null : null, f = (n, r = "loop", i) => {
136
- let a = T(n), o = [...new Set(a.map((e) => e.sub).filter(Boolean))], c = (e) => r === "misc" ? () => {
137
- t("misc", D(e, n)), window.dispatchEvent(new CustomEvent("kol:open-params"));
138
- } : () => s(e, n);
139
- return o.length ? o.map((t) => ({
140
- label: t,
141
- onSelect: c(E(n, t)[0]),
142
- active: e?.loopGroup === n && d?.sub === t
143
- })) : [{
144
- label: i ?? O(n).label,
145
- onSelect: c(a[0]),
146
- active: e?.loopGroup === n
147
- }];
148
- }, p = (e) => e.groups.flatMap((t) => {
149
- let n = e.labels?.[t] ?? O(t).label, r = T(t).some((e) => e.sub), i = f(t, "loop", n);
150
- return e.groups.length > 1 && r ? [{
151
- label: n,
152
- children: i
153
- }] : i;
154
- });
155
- return [
156
- {
157
- id: "sec:effects",
158
- label: "Effects"
159
- },
160
- ...oe(z).map((t) => ({
161
- id: `fx:${t.id}`,
162
- label: t.label,
163
- icon: $[`fx:${t.id}`] ?? "square",
164
- pages: t.rack ? ie.map((t) => ({
165
- label: t.label,
166
- onSelect: () => o(t.id),
167
- active: e?.fxGroup === t.id
168
- })) : t.id === "pattern" ? xt.map((t) => ({
169
- label: t,
170
- onSelect: () => s(E("optic", t)[0], "optic"),
171
- active: e?.loopGroup === "optic" && d?.sub === t
172
- })) : t.id === "scanline" ? St.map((t) => ({
173
- label: t.label,
174
- onSelect: () => a("scanline", t.patch),
175
- active: !e?.fxGroup && u === "scanline" && Ct(e?.filters?.[0]?.params) === t.label
176
- })) : t.filters.map((t) => ({
177
- label: t.label ?? t.id,
178
- onSelect: () => a(t.id),
179
- active: !e?.fxGroup && u === t.id
180
- }))
181
- })),
182
- {
183
- id: "sec:generative",
184
- label: "Generative"
185
- },
186
- ...P.map((e) => ({
187
- id: `gen:${e.label}`,
188
- label: e.label,
189
- icon: $[`gen:${e.label}`] ?? "square",
190
- pages: p(e)
191
- })),
192
- {
193
- id: "sec:vector",
194
- label: "Vector"
195
- },
196
- {
197
- id: "vec:Distressor",
198
- label: "Distressor",
199
- icon: $["vec:Distressor"] ?? "square",
200
- pages: f("distress")
201
- },
202
- {
203
- id: "vec:Modulator",
204
- label: "Modulator",
205
- icon: $["vec:Modulator"] ?? "square",
206
- pages: f("modulator")
207
- },
208
- {
209
- id: "sec:composition",
210
- label: "Composition"
211
- },
212
- ...pe.map((t) => ({
213
- id: `kin:${t.label}`,
214
- label: t.label,
215
- icon: $[`kin:${t.label}`] ?? "square",
216
- pages: t.subs.map((t) => ({
217
- label: t,
218
- onSelect: () => c(V.find((e) => e.sub === t)),
219
- active: e?.type === "kinetic" && V.some((e) => e.sub === t && e.id === l)
220
- }))
221
- })),
222
- ...M.map((e) => ({
223
- id: `misc:${e.label}`,
224
- label: e.label,
225
- icon: $[`misc:${e.label}`] ?? "square",
226
- pages: e.groups.flatMap((e) => f(e, "misc"))
227
- })),
228
- {
229
- id: "sec:modulation",
230
- label: "Modulation"
231
- },
232
- {
233
- id: "mod:animation",
234
- label: "Animation",
235
- icon: "frequency",
236
- onSelect: () => window.dispatchEvent(new CustomEvent("kol:open-params"))
237
- }
238
- ];
239
- }
240
- //#endregion
241
38
  //#region src/editor/labs/LabsNav.jsx
242
- function Tt() {
243
- let { addFilter: e, patchFilter: n } = p(), { layer: r, setOnly: i } = vt(), a = q(null);
244
- K(() => {
39
+ function Et() {
40
+ let { addFilter: e, patchFilter: t } = u(), { layer: r, setOnly: i } = $(), a = Y(null);
41
+ J(() => {
245
42
  r?.type === "photo" && r.src && (a.current = {
246
43
  src: r.src,
247
44
  srcType: r.srcType,
@@ -253,193 +50,53 @@ function Tt() {
253
50
  r?.srcType,
254
51
  r?.fit
255
52
  ]);
256
- let o = wt({
53
+ let o = he({
257
54
  layer: r,
258
55
  setOnly: i,
259
56
  addFilter: e,
260
- patchFilter: n,
57
+ patchFilter: t,
261
58
  carriedSource: () => r?.type === "photo" ? {
262
59
  src: r.src,
263
60
  srcType: r.srcType,
264
61
  fit: r.fit
265
62
  } : a.current ?? {}
266
63
  });
267
- return K(() => {
268
- let e = /* @__PURE__ */ new Map(), n = [];
269
- o.forEach((t) => {
270
- if (t.id.startsWith("sec:")) {
271
- let e = t.id.slice(4);
272
- n.push({
273
- icon: yt[e] ?? "square",
274
- path: `${tt}${t.id}`,
275
- label: t.label,
64
+ return J(() => {
65
+ let e = /* @__PURE__ */ new Map(), t = [];
66
+ o.forEach((n) => {
67
+ if (n.id.startsWith("sec:")) {
68
+ let e = n.id.slice(4);
69
+ t.push({
70
+ icon: pt[e] ?? "square",
71
+ path: `${Qe}${n.id}`,
72
+ label: n.label,
276
73
  sub: []
277
74
  });
278
75
  return;
279
76
  }
280
- let r = `${tt}${t.id}`, i = t.pages ?? [], a = t.onSelect ?? i[0]?.onSelect;
77
+ let r = `${Qe}${n.id}`, i = n.pages ?? [], a = n.onSelect ?? i[0]?.onSelect ?? i[0]?.children?.[0]?.onSelect;
281
78
  a && e.set(r, a);
282
- let o = n[n.length - 1], s = {
283
- icon: t.icon,
79
+ let o = t[t.length - 1], s = {
80
+ icon: n.icon,
284
81
  path: r,
285
- label: t.label
82
+ label: n.label
286
83
  };
287
- o?.sub ? o.sub.push(s) : n.push(s);
84
+ o?.sub ? o.sub.push(s) : t.push(s);
288
85
  });
289
- let r = et() && !Ze();
290
- return Be({
291
- items: n,
292
- dispatch: (n) => {
293
- let i = e.get(n);
294
- return i ? (i(), r && t.play(), !0) : !1;
86
+ let r = Me() && !Se();
87
+ return rt({
88
+ items: t,
89
+ dispatch: (t) => {
90
+ let i = e.get(t);
91
+ return i ? (i(), r && n.play(), !0) : !1;
295
92
  }
296
- }), () => Be(null);
93
+ }), () => rt(null);
297
94
  }), null;
298
95
  }
299
96
  //#endregion
300
- //#region src/editor/labs/LabsSourcePicker.jsx
301
- function Et(e) {
302
- let { patch: t } = ne(e.id), n = q(null), [r, i] = J(!1), a = e.type === "loop" && e.loopGroup === "distress";
303
- return {
304
- nodes: /* @__PURE__ */ Z(Y, { children: [/* @__PURE__ */ X("input", {
305
- ref: n,
306
- type: "file",
307
- accept: a ? ".svg,image/svg+xml" : "image/*,video/*",
308
- className: "hidden",
309
- onChange: (n) => {
310
- let r = n.target.files?.[0];
311
- if (n.target.value = "", !r) return;
312
- if (a) {
313
- let e = new FileReader();
314
- e.onload = () => t({ svgSrc: e.result }), e.readAsText(r);
315
- return;
316
- }
317
- if (r.type.startsWith("video/")) {
318
- b(e.id, r), t({
319
- src: URL.createObjectURL(r),
320
- srcType: "video"
321
- });
322
- return;
323
- }
324
- let i = new FileReader();
325
- i.onload = () => t({
326
- src: i.result,
327
- srcType: "image"
328
- }), i.readAsDataURL(r);
329
- }
330
- }), /* @__PURE__ */ X(Ue, {
331
- open: r,
332
- onClose: () => i(!1),
333
- onPick: (e, { contentType: n } = {}) => {
334
- if (a) {
335
- t({ svgSrc: it(e) });
336
- return;
337
- }
338
- t({
339
- src: it(e),
340
- srcType: Le(n) ? "video" : "image"
341
- });
342
- },
343
- accept: a ? "svg" : "all"
344
- })] }),
345
- svgMode: a,
346
- openLibrary: () => i(!0),
347
- openUpload: () => n.current?.click(),
348
- openCamera: () => {
349
- ot(e.id).then(() => t({
350
- src: null,
351
- srcType: "webcam"
352
- })).catch(() => {});
353
- }
354
- };
355
- }
356
- function Dt({ layer: e }) {
357
- let t = i(), n = Et(e);
358
- return /* @__PURE__ */ Z(Y, { children: [/* @__PURE__ */ X(W, {
359
- variant: "filled",
360
- value: null,
361
- onChange: (e) => ({
362
- library: n.openLibrary,
363
- upload: n.openUpload,
364
- camera: n.openCamera
365
- })[e]?.(),
366
- options: n.svgMode ? kt : Ot,
367
- size: t,
368
- ariaLabel: "Source",
369
- className: C(t)
370
- }), n.nodes] });
371
- }
372
- var Ot = [
373
- {
374
- value: "library",
375
- label: "Library"
376
- },
377
- {
378
- value: "upload",
379
- label: "Upload"
380
- },
381
- {
382
- value: "camera",
383
- label: "Camera"
384
- }
385
- ], kt = Ot.slice(0, 2);
386
- function At({ layer: e }) {
387
- let t = Et(e), n = "flex-1 flex flex-col items-center justify-center gap-3 cursor-pointer text-oq-48 hover:text-emphasis hover:bg-oq-02 transition-colors";
388
- return /* @__PURE__ */ Z("div", {
389
- className: "w-full h-full flex items-stretch p-6 gap-px",
390
- children: [
391
- /* @__PURE__ */ Z("button", {
392
- type: "button",
393
- className: n,
394
- onClick: t.openLibrary,
395
- children: [/* @__PURE__ */ X(Q, {
396
- name: "image",
397
- size: 28
398
- }), /* @__PURE__ */ X("span", {
399
- className: "kol-mono-12",
400
- children: "From library"
401
- })]
402
- }),
403
- /* @__PURE__ */ X("div", {
404
- className: "w-px",
405
- style: { background: "var(--kol-oq-08)" }
406
- }),
407
- /* @__PURE__ */ Z("button", {
408
- type: "button",
409
- className: n,
410
- onClick: t.openUpload,
411
- children: [/* @__PURE__ */ X(Q, {
412
- name: "upload",
413
- size: 28
414
- }), /* @__PURE__ */ X("span", {
415
- className: "kol-mono-12",
416
- children: "Upload"
417
- })]
418
- }),
419
- /* @__PURE__ */ X("div", {
420
- className: "w-px",
421
- style: { background: "var(--kol-oq-08)" }
422
- }),
423
- /* @__PURE__ */ Z("button", {
424
- type: "button",
425
- className: n,
426
- onClick: t.openCamera,
427
- children: [/* @__PURE__ */ X(Q, {
428
- name: "camera",
429
- size: 28
430
- }), /* @__PURE__ */ X("span", {
431
- className: "kol-mono-12",
432
- children: "Camera"
433
- })]
434
- }),
435
- t.nodes
436
- ]
437
- });
438
- }
439
- //#endregion
440
97
  //#region src/editor/labs/LabsParams.jsx
441
- function jt(e, t) {
442
- K(() => {
98
+ function Dt(e, t) {
99
+ J(() => {
443
100
  let n = (n) => {
444
101
  if (n.key !== "r" && n.key !== "R" || n.metaKey || n.ctrlKey || n.altKey) return;
445
102
  let r = n.target;
@@ -448,13 +105,13 @@ function jt(e, t) {
448
105
  return window.addEventListener("keydown", n), () => window.removeEventListener("keydown", n);
449
106
  });
450
107
  }
451
- var Mt = [{
108
+ var Ot = [{
452
109
  value: "effect",
453
110
  label: "Effect"
454
111
  }, {
455
112
  value: "anim",
456
113
  label: "Motion"
457
- }], Nt = [
114
+ }], kt = [
458
115
  {
459
116
  value: "generate",
460
117
  label: "Generate"
@@ -467,7 +124,7 @@ var Mt = [{
467
124
  value: "anim",
468
125
  label: "Animation"
469
126
  }
470
- ], Pt = [
127
+ ], At = [
471
128
  {
472
129
  value: "generate",
473
130
  label: "Gen"
@@ -481,67 +138,68 @@ var Mt = [{
481
138
  label: "Anim"
482
139
  }
483
140
  ];
484
- function Ft({ options: e, active: t, onPick: n, spread: r = !1, pills: i = !1 }) {
485
- return e?.length ? i ? /* @__PURE__ */ X("div", {
141
+ function jt({ options: e, active: t, onPick: n, spread: i = !1, pills: a = !1 }) {
142
+ let o = r();
143
+ return e?.length ? a ? /* @__PURE__ */ Z("div", {
486
144
  className: "flex items-center gap-1 flex-wrap",
487
- children: e.map((e) => /* @__PURE__ */ X("button", {
145
+ children: e.map((e) => /* @__PURE__ */ Z("button", {
488
146
  type: "button",
489
147
  onClick: () => n(e.value),
490
148
  className: `px-2 py-0.5 rounded kol-helper-10 tracking-widest border transition-colors cursor-pointer ${e.value === t ? "bg-fg-16 border-oq-24 text-emphasis" : "bg-transparent border-oq-08 text-meta hover:border-oq-16 hover:text-body"}`,
491
149
  children: e.label
492
150
  }, e.value))
493
- }) : /* @__PURE__ */ X("div", {
494
- className: `flex flex-wrap items-center gap-x-5 gap-y-1.5${r ? " justify-between" : ""}`,
495
- children: e.map((e) => /* @__PURE__ */ X("button", {
496
- type: "button",
497
- onClick: () => n(e.value),
498
- className: ["kol-helper-12 cursor-pointer", e.value === t ? "text-emphasis" : "text-meta hover:text-emphasis"].join(" "),
499
- children: e.label
500
- }, e.value))
151
+ }) : /* @__PURE__ */ Z(q, {
152
+ value: t ?? null,
153
+ onChange: n,
154
+ options: e,
155
+ size: o,
156
+ ariaLabel: "Siblings",
157
+ className: S(o)
501
158
  }) : null;
502
159
  }
503
- function It({ chips: e, active: t, onPick: n, spread: r, pills: i, title: a, tabStrip: o, preStrip: s, fx: c = !1, children: l }) {
504
- return /* @__PURE__ */ Z("div", {
505
- className: `flex flex-col gap-5${c ? " kol-labs-fx" : ""}`,
160
+ function Mt({ chips: e, active: t, onPick: n, spread: i, pills: a, title: o, tabStrip: s, preStrip: c, fx: l = !1, children: u }) {
161
+ let d = r() === "sm";
162
+ return /* @__PURE__ */ Q("div", {
163
+ className: `flex flex-col gap-5${l ? " kol-labs-fx" : ""}`,
506
164
  children: [
507
- a && /* @__PURE__ */ X("p", {
165
+ o && d && /* @__PURE__ */ Z("p", {
508
166
  className: "kol-eyebrow text-fg-96",
509
- children: a
167
+ children: o
510
168
  }),
511
- e && /* @__PURE__ */ X(Ft, {
169
+ e && /* @__PURE__ */ Z(jt, {
512
170
  options: e,
513
171
  active: t,
514
172
  onPick: n,
515
- spread: r,
516
- pills: i
173
+ spread: i,
174
+ pills: a
517
175
  }),
176
+ c,
518
177
  s,
519
- o,
520
- l
178
+ u
521
179
  ]
522
180
  });
523
181
  }
524
- function Lt({ layer: t, showMod: n }) {
525
- let a = i(), [o, c] = J("effect");
526
- K(() => {
182
+ function Nt({ layer: n, showMod: a }) {
183
+ let o = r(), [s, c] = X("effect");
184
+ J(() => {
527
185
  let e = () => c("effect");
528
186
  return window.addEventListener("kol:open-effects", e), () => window.removeEventListener("kol:open-effects", e);
529
187
  }, []);
530
- let { addFilter: l, replaceFilter: u, removeFilter: d, toggleFilter: f, updateLayer: m, palette: g } = p(), _ = ne(t.id, { history: "coalesce" }), v = r(t), y = v[0] ?? null, b = oe(z).find((e) => e.id === L(y?.id)), S = b?.id === "halftone", ee = S ? (b?.filters ?? []).map((e) => ({
188
+ let { addFilter: l, replaceFilter: d, removeFilter: f, toggleFilter: m, updateLayer: h, palette: g } = u(), _ = M(n.id, { history: "coalesce" }), v = t(n), y = v[0] ?? null, x = z(I).find((e) => e.id === R(y?.id)), ee = x?.id === "halftone", C = ee ? (x?.filters ?? []).map((e) => ({
531
189
  value: e.id,
532
190
  label: e.label
533
- })) : null, w = !S && y ? y.def.label : null, T = (e) => {
191
+ })) : null, te = !ee && y ? y.def.label : null, ne = (e) => {
534
192
  if (!y) {
535
- l(t.id, e);
193
+ l(n.id, e);
536
194
  return;
537
195
  }
538
- e !== y.id && u(t.id, 0, e);
539
- }, E = v.map(({ def: e, ...t }) => t), D = y ? {
540
- ...t,
196
+ e !== y.id && d(n.id, 0, e);
197
+ }, w = v.map(({ def: e, ...t }) => t), T = y ? {
198
+ ...n,
541
199
  ...y.params,
542
- id: t.id
543
- } : t, O = (e) => (t, n) => {
544
- let r = E.map((r, i) => i === e ? {
200
+ id: n.id
201
+ } : n, E = (e) => (t, n) => {
202
+ let r = w.map((r, i) => i === e ? {
545
203
  ...r,
546
204
  params: {
547
205
  ...r.params,
@@ -549,249 +207,245 @@ function Lt({ layer: t, showMod: n }) {
549
207
  }
550
208
  } : r);
551
209
  _.patch({ filters: r });
552
- }, k = O(0), te = n ? (e) => /* @__PURE__ */ X(ue, {
553
- layer: D,
210
+ }, D = E(0), re = a ? (e) => /* @__PURE__ */ Z(B, {
211
+ layer: T,
554
212
  param: e,
555
- setProp: k
556
- }) : void 0, A = (e) => {
557
- let n = E.map((t, n) => n === 0 ? {
213
+ setProp: D
214
+ }) : void 0, O = (e) => {
215
+ let t = w.map((t, n) => n === 0 ? {
558
216
  ...t,
559
217
  params: {
560
218
  ...t.params,
561
219
  ...e
562
220
  }
563
221
  } : t);
564
- m(t.id, { filters: n });
222
+ h(n.id, { filters: t });
565
223
  };
566
- jt(() => {
567
- y && m(t.id, { filters: E.map((e, t) => t === 0 ? {
224
+ Dt(() => {
225
+ y && h(n.id, { filters: w.map((e, t) => t === 0 ? {
568
226
  ...e,
569
227
  params: {}
570
228
  } : e) });
571
229
  }, () => {
572
- y && A(s(D, h(y.def.params, D), x()));
230
+ y && O(i(T, p(y.def.params, T), b()));
573
231
  });
574
- let j = t.fxGroup ? ie.find((e) => e.id === t.fxGroup) : null;
575
- if (j) {
232
+ let A = n.fxGroup ? se.find((e) => e.id === n.fxGroup) : null;
233
+ if (A) {
576
234
  let e = {
577
235
  chain: v,
578
- layer: t,
579
- hostView: D,
580
- toggleFilter: f,
581
- removeFilter: d,
582
- setStagePropAt: O,
236
+ layer: n,
237
+ hostView: T,
238
+ toggleFilter: m,
239
+ removeFilter: f,
240
+ setStagePropAt: E,
583
241
  palette: g,
584
- showMod: n
585
- }, r = [{
242
+ showMod: a
243
+ }, t = [{
586
244
  value: "",
587
245
  label: "Add effect…"
588
- }, ...re(j, z).map((e) => ({
246
+ }, ...ie(A, I).map((e) => ({
589
247
  value: e.id,
590
248
  label: `${e.label ?? e.id}${e.kind === "pixi" ? " · GPU" : ""}`
591
249
  }))];
592
- return /* @__PURE__ */ Z(It, {
250
+ return /* @__PURE__ */ Q(Mt, {
593
251
  title: "Effects",
594
252
  fx: !0,
595
- tabStrip: /* @__PURE__ */ X(W, {
596
- variant: "filled",
597
- value: o,
253
+ tabStrip: /* @__PURE__ */ Z(q, {
254
+ value: s,
598
255
  onChange: c,
599
- options: Mt,
600
- size: a,
601
- className: C(a)
256
+ options: Ot,
257
+ size: o,
258
+ className: S(o)
602
259
  }),
603
- children: [o === "effect" && /* @__PURE__ */ Z(Y, { children: [
604
- /* @__PURE__ */ Z(U, {
260
+ children: [s === "effect" && /* @__PURE__ */ Q(St, { children: [
261
+ /* @__PURE__ */ Q(gt, {
605
262
  label: "Effect Stack",
606
263
  divided: !0,
607
- children: [v.length === 0 && /* @__PURE__ */ X(I, {
264
+ children: [v.length === 0 && /* @__PURE__ */ Z(j, {
608
265
  className: "kol-mono-10 text-meta",
609
266
  children: "No effects yet — add one below."
610
- }), /* @__PURE__ */ X(Rt, {
267
+ }), /* @__PURE__ */ Z(Pt, {
611
268
  ...e,
612
269
  from: 0
613
270
  })]
614
271
  }),
615
- /* @__PURE__ */ X(lt, {}),
616
- /* @__PURE__ */ X(U, {
617
- label: j.label,
272
+ /* @__PURE__ */ Z(mt, {}),
273
+ /* @__PURE__ */ Z(gt, {
274
+ label: A.label,
618
275
  divided: !0,
619
- children: /* @__PURE__ */ X(ut, {
276
+ children: /* @__PURE__ */ Z(ht, {
620
277
  variant: "subtle",
621
- size: a,
278
+ size: o,
622
279
  className: "w-full",
623
- options: r,
280
+ options: t,
624
281
  value: "",
625
282
  disabled: v.length >= 8,
626
283
  onChange: (e) => {
627
- e && l(t.id, e);
284
+ e && l(n.id, e);
628
285
  }
629
286
  })
630
287
  })
631
- ] }), o === "anim" && y?.def?.sweeps && /* @__PURE__ */ X(se, {
288
+ ] }), s === "anim" && y?.def?.sweeps && /* @__PURE__ */ Z(V, {
632
289
  sweeps: Array.isArray(y.params.sweeps) ? y.params.sweeps : [],
633
- onChange: (e) => k("sweeps", e),
290
+ onChange: (e) => D("sweeps", e),
634
291
  inline: !0
635
292
  })]
636
293
  });
637
294
  }
638
- if (!y) return /* @__PURE__ */ X(It, {
639
- chips: ee,
295
+ if (!y) return /* @__PURE__ */ Z(Mt, {
296
+ chips: C,
640
297
  active: null,
641
- onPick: T,
642
- spread: S,
298
+ onPick: ne,
299
+ spread: ee,
643
300
  fx: !0,
644
- tabStrip: /* @__PURE__ */ X(W, {
645
- variant: "filled",
646
- value: o,
301
+ tabStrip: /* @__PURE__ */ Z(q, {
302
+ value: s,
647
303
  onChange: c,
648
- options: Mt,
649
- size: a,
650
- className: C(a)
304
+ options: Ot,
305
+ size: o,
306
+ className: S(o)
651
307
  }),
652
- children: /* @__PURE__ */ X(F, {
653
- schema: We,
654
- layer: t,
308
+ children: /* @__PURE__ */ Z(k, {
309
+ schema: ct,
310
+ layer: n,
655
311
  setProp: _.setProp,
656
312
  palette: g,
657
- renderAnimate: (e) => /* @__PURE__ */ X(ue, {
658
- layer: t,
313
+ renderAnimate: (e) => /* @__PURE__ */ Z(B, {
314
+ layer: n,
659
315
  param: e,
660
316
  setProp: _.setProp
661
317
  }),
662
- tab: o === "anim" ? "anim" : "style",
318
+ tab: s === "anim" ? "anim" : "style",
663
319
  emptyHint: "Pick an effect from the nav."
664
320
  })
665
321
  });
666
- let M = y.def.params.filter((t) => e(t) !== "anim"), N = le(y.def.id), P = N ? M.findIndex((e) => e.key === N) : -1, R = M.length;
667
- if (P >= 0) {
668
- let e = P;
669
- for (; e + 1 < M.length && M[e + 1].type === "select";) e++;
670
- R = e + 1;
322
+ let N = y.def.params.filter((t) => e(t) !== "anim"), P = oe(y.def.id), F = P ? N.findIndex((e) => e.key === P) : -1, L = N.length;
323
+ if (F >= 0) {
324
+ let e = F;
325
+ for (; e + 1 < N.length && N[e + 1].type === "select";) e++;
326
+ L = e + 1;
671
327
  }
672
- let B = P > 0 ? M.slice(0, P) : [], ce = P >= 0 ? M.slice(P, R).map((e) => ({
328
+ let ae = F > 0 ? N.slice(0, F) : [], le = F >= 0 ? N.slice(F, L).map((e) => ({
673
329
  ...e,
674
330
  section: void 0
675
- })) : M, V = {
676
- layer: D,
677
- setProp: k,
331
+ })) : N, H = {
332
+ layer: T,
333
+ setProp: D,
678
334
  palette: g,
679
- renderAnimate: te,
335
+ renderAnimate: re,
680
336
  inline: !0
681
337
  };
682
- return /* @__PURE__ */ Z(It, {
683
- chips: ee,
338
+ return /* @__PURE__ */ Q(Mt, {
339
+ chips: C,
684
340
  active: y.id,
685
- onPick: T,
686
- spread: S,
687
- title: w,
341
+ onPick: ne,
342
+ spread: ee,
343
+ title: te,
688
344
  fx: !0,
689
- preStrip: /* @__PURE__ */ X(Dt, { layer: t }),
690
- tabStrip: /* @__PURE__ */ X(W, {
691
- variant: "filled",
692
- value: o,
345
+ tabStrip: /* @__PURE__ */ Z(q, {
346
+ value: s,
693
347
  onChange: c,
694
- options: Mt,
695
- size: a,
696
- className: C(a)
348
+ options: Ot,
349
+ size: o,
350
+ className: S(o)
697
351
  }),
698
- children: [o === "effect" && /* @__PURE__ */ Z(Y, { children: [
699
- B.length > 0 && /* @__PURE__ */ X(F, {
700
- schema: B,
701
- ...V
352
+ children: [s === "effect" && /* @__PURE__ */ Q(St, { children: [
353
+ ae.length > 0 && /* @__PURE__ */ Z(k, {
354
+ schema: ae,
355
+ ...H
702
356
  }),
703
- /* @__PURE__ */ Z(U, {
357
+ /* @__PURE__ */ Q(gt, {
704
358
  divided: !0,
705
- children: [/* @__PURE__ */ X(F, {
706
- schema: ce,
707
- ...V
708
- }), /* @__PURE__ */ X(ae, {
359
+ children: [/* @__PURE__ */ Z(k, {
360
+ schema: le,
361
+ ...H
362
+ }), /* @__PURE__ */ Z(ce, {
709
363
  inline: !0,
710
364
  def: y.def,
711
- view: D,
365
+ view: T,
712
366
  tab: "effect",
713
- onPatch: A
367
+ onPatch: O
714
368
  })]
715
369
  }),
716
- /* @__PURE__ */ X(lt, {}),
717
- R < M.length && /* @__PURE__ */ Z(Y, { children: [/* @__PURE__ */ X(F, {
718
- schema: M.slice(R),
719
- ...V
720
- }), /* @__PURE__ */ X(lt, {})] }),
721
- /* @__PURE__ */ X(zt, {
370
+ /* @__PURE__ */ Z(mt, {}),
371
+ L < N.length && /* @__PURE__ */ Q(St, { children: [/* @__PURE__ */ Z(k, {
372
+ schema: N.slice(L),
373
+ ...H
374
+ }), /* @__PURE__ */ Z(mt, {})] }),
375
+ /* @__PURE__ */ Z(Ft, {
722
376
  chain: v,
723
- layer: t,
724
- hostView: D,
377
+ layer: n,
378
+ hostView: T,
725
379
  addFilter: l,
726
- removeFilter: d,
727
- toggleFilter: f,
728
- setStagePropAt: O,
380
+ removeFilter: f,
381
+ toggleFilter: m,
382
+ setStagePropAt: E,
729
383
  palette: g,
730
- showMod: n
384
+ showMod: a
731
385
  })
732
- ] }), o === "anim" && /* @__PURE__ */ Z(Y, { children: [
733
- /* @__PURE__ */ X(F, {
386
+ ] }), s === "anim" && /* @__PURE__ */ Q(St, { children: [
387
+ /* @__PURE__ */ Z(k, {
734
388
  schema: y.def.params,
735
- ...V,
389
+ ...H,
736
390
  tab: "anim"
737
391
  }),
738
- /* @__PURE__ */ X(ae, {
392
+ /* @__PURE__ */ Z(ce, {
739
393
  inline: !0,
740
394
  def: y.def,
741
- view: D,
395
+ view: T,
742
396
  tab: "anim",
743
- onPatch: A
397
+ onPatch: O
744
398
  }),
745
- y.def.sweeps && /* @__PURE__ */ X(se, {
399
+ y.def.sweeps && /* @__PURE__ */ Z(V, {
746
400
  sweeps: Array.isArray(y.params.sweeps) ? y.params.sweeps : [],
747
- onChange: (e) => k("sweeps", e),
401
+ onChange: (e) => D("sweeps", e),
748
402
  inline: !0
749
403
  })
750
404
  ] })]
751
405
  });
752
406
  }
753
- function Rt({ chain: t, from: n = 0, layer: r, hostView: a, toggleFilter: o, removeFilter: s, setStagePropAt: c, palette: l, showMod: u }) {
754
- let d = i();
755
- return t.slice(n).map((t, i) => {
756
- let f = i + n, p = t.enabled !== !1, m = {
407
+ function Pt({ chain: t, from: n = 0, layer: i, hostView: a, toggleFilter: o, removeFilter: s, setStagePropAt: c, palette: l, showMod: u }) {
408
+ let d = r();
409
+ return t.slice(n).map((t, r) => {
410
+ let f = r + n, p = t.enabled !== !1, m = {
757
411
  ...a,
758
412
  ...t.params,
759
- id: r.id
413
+ id: i.id
760
414
  }, h = c(f);
761
- return /* @__PURE__ */ Z("div", {
415
+ return /* @__PURE__ */ Q("div", {
762
416
  className: "flex flex-col gap-2 p-2 rounded bg-oq-04",
763
- children: [/* @__PURE__ */ Z("div", {
417
+ children: [/* @__PURE__ */ Q("div", {
764
418
  className: "flex items-center gap-2",
765
- children: [/* @__PURE__ */ X(ft, {
419
+ children: [/* @__PURE__ */ Z(_t, {
766
420
  size: d,
767
421
  checked: p,
768
- onChange: () => o(r.id, f),
422
+ onChange: () => o(i.id, f),
769
423
  label: t.def?.label ?? t.id
770
- }), /* @__PURE__ */ X(G, {
424
+ }), /* @__PURE__ */ Z(vt, {
771
425
  asChild: !0,
772
426
  label: "Remove effect",
773
- children: /* @__PURE__ */ X("button", {
427
+ children: /* @__PURE__ */ Z("button", {
774
428
  type: "button",
775
429
  "aria-label": "Remove effect",
776
- onClick: () => s(r.id, f),
430
+ onClick: () => s(i.id, f),
777
431
  className: "ml-auto inline-flex items-center justify-center w-5 h-5 shrink-0 text-oq-64 hover:text-emphasis cursor-pointer",
778
432
  style: {
779
433
  border: "none",
780
434
  background: "transparent"
781
435
  },
782
- children: /* @__PURE__ */ X(Q, {
436
+ children: /* @__PURE__ */ Z(Ct, {
783
437
  name: "x",
784
438
  size: 12
785
439
  })
786
440
  })
787
441
  })]
788
- }), p && t.def && /* @__PURE__ */ X(F, {
442
+ }), p && t.def && /* @__PURE__ */ Z(k, {
789
443
  schema: t.def.params.filter((t) => e(t) !== "anim"),
790
444
  layer: m,
791
445
  setProp: h,
792
446
  palette: l,
793
447
  inline: !0,
794
- renderAnimate: u ? (e) => /* @__PURE__ */ X(ue, {
448
+ renderAnimate: u ? (e) => /* @__PURE__ */ Z(B, {
795
449
  layer: m,
796
450
  param: e,
797
451
  setProp: h
@@ -800,18 +454,18 @@ function Rt({ chain: t, from: n = 0, layer: r, hostView: a, toggleFilter: o, rem
800
454
  }, t.key ?? f);
801
455
  });
802
456
  }
803
- function zt({ chain: e, layer: t, hostView: n, addFilter: r, removeFilter: a, toggleFilter: o, setStagePropAt: s, palette: c, showMod: l }) {
804
- let u = i(), d = [{
457
+ function Ft({ chain: e, layer: t, hostView: n, addFilter: i, removeFilter: a, toggleFilter: o, setStagePropAt: s, palette: c, showMod: l }) {
458
+ let u = r(), d = [{
805
459
  value: "",
806
460
  label: "Add FX..."
807
- }, ...B(z).map((e) => ({
461
+ }, ...ae(I).map((e) => ({
808
462
  value: e.id,
809
463
  label: e.label ?? e.id
810
464
  }))];
811
- return /* @__PURE__ */ Z(U, {
465
+ return /* @__PURE__ */ Q(gt, {
812
466
  label: "Post-Processing",
813
467
  divided: !0,
814
- children: [/* @__PURE__ */ X(Rt, {
468
+ children: [/* @__PURE__ */ Z(Pt, {
815
469
  chain: e,
816
470
  from: 1,
817
471
  layer: t,
@@ -821,7 +475,7 @@ function zt({ chain: e, layer: t, hostView: n, addFilter: r, removeFilter: a, to
821
475
  setStagePropAt: s,
822
476
  palette: c,
823
477
  showMod: l
824
- }), /* @__PURE__ */ X(ut, {
478
+ }), /* @__PURE__ */ Z(ht, {
825
479
  variant: "subtle",
826
480
  size: u,
827
481
  className: "w-full",
@@ -829,341 +483,475 @@ function zt({ chain: e, layer: t, hostView: n, addFilter: r, removeFilter: a, to
829
483
  value: "",
830
484
  disabled: e.length >= 8,
831
485
  onChange: (e) => {
832
- e && r(t.id, e);
486
+ e && i(t.id, e);
833
487
  }
834
488
  })]
835
489
  });
836
490
  }
837
- function Bt({ layer: e, showMod: t, tree: n }) {
838
- let r = i(), [a, o] = J("generate"), { updateLayer: c, palette: l } = p(), { setOnly: u } = vt(), d = ne(e.id, { history: "coalesce" }), f = T(e.loopGroup).find((t) => t.id === e.presetId), m = O(e.loopGroup)?.label ?? "", g = e.loopGroup === "paratype" && f?.sub === "Glyphs" ? E("paratype", "Glyphs") : null, _ = g ? g.map((e) => ({
491
+ function It({ layer: e, showMod: t, tree: n }) {
492
+ let a = r(), [o, s] = X("generate"), { updateLayer: c, palette: l } = u(), { setOnly: d } = $(), f = M(e.id, { history: "coalesce" }), m = O(e.loopGroup).find((t) => t.id === e.presetId), h = te(e.loopGroup)?.label ?? "", g = e.loopGroup === "paratype" && m?.sub === "Glyphs" ? E("paratype", "Glyphs") : null, _ = g ? g.map((e) => ({
839
493
  value: e.id,
840
494
  label: e.label
841
495
  })) : null;
842
- return jt(() => {
843
- f && u(e.type, D(f, e.loopGroup));
496
+ return Dt(() => {
497
+ m && d(e.type, w(m, e.loopGroup));
844
498
  }, () => {
845
- let t = k(e.loopId)?.params ?? [];
846
- c(e.id, s(e, h(t, e), x(), { withFilters: !0 }));
847
- }), /* @__PURE__ */ X(It, {
848
- title: m,
499
+ let t = re(e.loopId)?.params ?? [];
500
+ c(e.id, i(e, p(t, e), b(), { withFilters: !0 }));
501
+ }), /* @__PURE__ */ Z(Mt, {
502
+ title: h,
849
503
  chips: _,
850
504
  active: e.presetId,
851
505
  onPick: (t) => {
852
506
  let n = g?.find((e) => e.id === t);
853
- n && t !== e.presetId && u(e.type, D(n, e.loopGroup));
507
+ n && t !== e.presetId && d(e.type, w(n, e.loopGroup));
854
508
  },
855
509
  pills: !0,
856
- preStrip: e.loopGroup === "distress" ? /* @__PURE__ */ X(Dt, { layer: e }) : void 0,
857
- tabStrip: /* @__PURE__ */ X(W, {
858
- variant: "filled",
859
- value: a,
860
- onChange: o,
861
- options: r === "sm" ? Nt : Pt,
862
- size: r,
863
- className: C(r)
510
+ tabStrip: /* @__PURE__ */ Z(q, {
511
+ value: o,
512
+ onChange: s,
513
+ options: a === "sm" ? kt : At,
514
+ size: a,
515
+ className: S(a)
864
516
  }),
865
- children: /* @__PURE__ */ X(N, {
517
+ children: /* @__PURE__ */ Z(P, {
866
518
  layer: e,
867
- setProp: d.setProp,
868
- patch: d.patch,
519
+ setProp: f.setProp,
520
+ patch: f.patch,
869
521
  updateLayer: c,
870
522
  palette: l,
871
- renderAnimate: t ? (t) => /* @__PURE__ */ X(ue, {
523
+ renderAnimate: t ? (t) => /* @__PURE__ */ Z(B, {
872
524
  layer: e,
873
525
  param: t,
874
- setProp: d.setProp
526
+ setProp: f.setProp
875
527
  }) : void 0,
876
- tab: a,
528
+ tab: o,
877
529
  tabStrip: null,
878
530
  tree: n,
879
531
  inline: !0
880
532
  })
881
533
  });
882
534
  }
883
- function Vt({ layer: e, showMod: t }) {
884
- let n = i(), [r, a] = J("generate"), { updateLayer: o, palette: s } = p(), { setOnly: c } = vt(), l = ne(e.id, { history: "coalesce" }), u = V.find((t) => t.id === e.presetId), d = pe.find((e) => e.subs.includes(u?.sub))?.label ?? "Kinetic";
885
- return jt(() => {
886
- u && c("kinetic", {
887
- presetId: u.id,
888
- presetLabel: u.label,
889
- comp: he(u)
535
+ function Lt({ layer: e, showMod: t }) {
536
+ let n = r(), [i, a] = X("generate"), { updateLayer: o, palette: s } = u(), { setOnly: c } = $(), l = M(e.id, { history: "coalesce" }), f = ue.find((t) => t.id === e.presetId), p = H.find((e) => e.subs.includes(f?.sub))?.label ?? "Kinetic";
537
+ return Dt(() => {
538
+ f && c("kinetic", {
539
+ presetId: f.id,
540
+ presetLabel: f.label,
541
+ comp: le(f)
890
542
  });
891
543
  }, () => {
892
- let t = x(), n = m(t >>> 0), r = e.comp ?? { instances: [] };
544
+ let t = b(), n = d(t >>> 0), r = e.comp ?? { instances: [] };
893
545
  (r.instances ?? []).forEach((e, t) => {
894
- r = de(r, t, n);
546
+ r = U(r, t, n);
895
547
  }), o(e.id, {
896
548
  comp: r,
897
549
  _rollSeed: t
898
550
  });
899
- }), /* @__PURE__ */ X(It, {
900
- title: d,
901
- tabStrip: /* @__PURE__ */ X(W, {
902
- variant: "filled",
903
- value: r,
551
+ }), /* @__PURE__ */ Z(Mt, {
552
+ title: p,
553
+ tabStrip: /* @__PURE__ */ Z(q, {
554
+ value: i,
904
555
  onChange: a,
905
- options: n === "sm" ? Nt : Pt,
556
+ options: n === "sm" ? kt : At,
906
557
  size: n,
907
- className: C(n)
558
+ className: S(n)
908
559
  }),
909
- children: /* @__PURE__ */ X(me, {
560
+ children: /* @__PURE__ */ Z(fe, {
910
561
  layer: e,
911
562
  setProp: l.setProp,
912
563
  updateLayer: o,
913
564
  palette: s,
914
- renderAnimate: t ? (t) => /* @__PURE__ */ X(ue, {
565
+ renderAnimate: t ? (t) => /* @__PURE__ */ Z(B, {
915
566
  layer: e,
916
567
  param: t,
917
568
  setProp: l.setProp
918
569
  }) : () => null,
919
- tab: r,
570
+ tab: i,
920
571
  tabStrip: null
921
572
  })
922
573
  });
923
574
  }
924
- function Ht() {
925
- let { layer: e } = vt(), t = !!_().labsModDots;
926
- return K(() => {
575
+ function Rt() {
576
+ let { layer: e } = $(), t = !!h().labsModDots;
577
+ return J(() => {
927
578
  let e = (e) => {
928
579
  if (e.key !== "m" && e.key !== "M" || e.metaKey || e.ctrlKey || e.altKey) return;
929
580
  let t = e.target;
930
- t?.tagName === "INPUT" || t?.tagName === "TEXTAREA" || t?.isContentEditable || f("labsModDots", !y().labsModDots);
581
+ t?.tagName === "INPUT" || t?.tagName === "TEXTAREA" || t?.isContentEditable || l("labsModDots", !v().labsModDots);
931
582
  };
932
583
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
933
- }, []), e ? e.type === "photo" ? /* @__PURE__ */ X(Lt, {
584
+ }, []), e ? e.type === "photo" ? /* @__PURE__ */ Z(Nt, {
934
585
  layer: e,
935
586
  showMod: t
936
- }, e.id) : e.type === "loop" ? /* @__PURE__ */ X(Bt, {
587
+ }, e.id) : e.type === "loop" ? /* @__PURE__ */ Z(It, {
937
588
  layer: e,
938
589
  showMod: t
939
- }, e.id) : e.type === "misc" ? /* @__PURE__ */ X(Bt, {
590
+ }, e.id) : e.type === "misc" ? /* @__PURE__ */ Z(It, {
940
591
  layer: e,
941
592
  showMod: t,
942
- tree: M
943
- }, e.id) : e.type === "kinetic" ? /* @__PURE__ */ X(Vt, {
593
+ tree: N
594
+ }, e.id) : e.type === "kinetic" ? /* @__PURE__ */ Z(Lt, {
944
595
  layer: e,
945
596
  showMod: t
946
- }, e.id) : /* @__PURE__ */ X(I, { children: "This layer has no labs surface." }) : /* @__PURE__ */ X(I, { children: "Pick an effect or generator from the nav." });
597
+ }, e.id) : /* @__PURE__ */ Z(j, { children: "This layer has no labs surface." }) : /* @__PURE__ */ Z(j, { children: "Pick an effect or generator from the nav." });
947
598
  }
948
599
  //#endregion
949
- //#region src/editor/labs/LabsShortcuts.jsx
950
- var Ut = [
951
- ["0.5", "a plain value — stays put (normal slider)"],
952
- ["t", "counts up in seconds: 0, 1, 2 …"],
953
- ["t*0.1", "counts up slowly"],
954
- ["sin(t)", "smooth swing, -1 … 1"],
955
- ["sin(t*2)*0.5", "faster, smaller swing"],
956
- ["wave(t)", "bounce 0 → 1 → 0, once per second"],
957
- ["wave(t*0.5)*40", "bounce, scaled to 0 … 40"],
958
- ["saw(t)", "ramp 0 → 1, repeat"],
959
- ["tri(t)", "triangle 0 → 1 → 0"]
960
- ], Wt = [
961
- ["Oscillators · 0…1", "wave saw tri pulse(t,w) ease(t,c) bell step(t,n)"],
962
- ["Trig", "sin cos tan atan2"],
963
- ["Math", "abs floor ceil round sqrt pow"],
964
- ["Helpers", "clamp(x,a,b) lerp(a,b,u) mod(a,b) frac smooth"],
965
- ["Constants", "PI TAU PHI E"]
966
- ], Gt = () => [...Pe("labs").flatMap(({ items: e }) => e.map((e) => [Ce(e.combo), e.label])), ["Esc", "close"]];
967
- function Kt() {
968
- let [e, t] = J(!1);
969
- return K(() => {
970
- let e = (e) => {
971
- let n = e.target;
972
- n?.tagName === "INPUT" || n?.tagName === "TEXTAREA" || n?.isContentEditable || (e.key === "Escape" && t(!1), (e.key === "s" || e.key === "S") && !e.metaKey && !e.ctrlKey && !e.altKey && (e.preventDefault(), t((e) => !e)));
973
- };
974
- return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
975
- }, []), e ? /* @__PURE__ */ X(dt, {
976
- open: !0,
977
- onClose: () => t(!1),
978
- children: /* @__PURE__ */ Z("div", {
979
- className: "flex flex-col",
980
- style: {
981
- width: 640,
982
- maxWidth: "100%"
600
+ //#region src/editor/labs/LabsSourcePicker.jsx
601
+ function zt(e) {
602
+ let { patch: t } = M(e.id), n = Y(null), [r, i] = X(!1), a = e.type === "loop" && e.loopGroup === "distress";
603
+ return {
604
+ nodes: /* @__PURE__ */ Q(St, { children: [/* @__PURE__ */ Z("input", {
605
+ ref: n,
606
+ type: "file",
607
+ accept: a ? ".svg,image/svg+xml" : "image/*,video/*",
608
+ className: "hidden",
609
+ onChange: (n) => {
610
+ let r = n.target.files?.[0];
611
+ if (n.target.value = "", !r) return;
612
+ if (a) {
613
+ let e = new FileReader();
614
+ e.onload = () => t({ svgSrc: e.result }), e.readAsText(r);
615
+ return;
616
+ }
617
+ if (r.type.startsWith("video/")) {
618
+ y(e.id, r), t({
619
+ src: URL.createObjectURL(r),
620
+ srcType: "video"
621
+ });
622
+ return;
623
+ }
624
+ let i = new FileReader();
625
+ i.onload = () => t({
626
+ src: i.result,
627
+ srcType: "image"
628
+ }), i.readAsDataURL(r);
629
+ }
630
+ }), /* @__PURE__ */ Z(He, {
631
+ open: r,
632
+ onClose: () => i(!1),
633
+ onPick: (e, { contentType: n } = {}) => {
634
+ if (a) {
635
+ t({ svgSrc: tt(e) });
636
+ return;
637
+ }
638
+ t({
639
+ src: tt(e),
640
+ srcType: We(n) ? "video" : "image"
641
+ });
983
642
  },
984
- children: [/* @__PURE__ */ X("div", {
985
- className: "flex items-start justify-between px-6 pt-5",
986
- children: /* @__PURE__ */ Z("div", { children: [/* @__PURE__ */ X("p", {
987
- className: "kol-eyebrow text-meta mb-1",
988
- children: "Shortcuts"
989
- }), /* @__PURE__ */ X("p", {
990
- className: "kol-mono-16 text-emphasis",
991
- children: "Animate any value"
992
- })] })
993
- }), /* @__PURE__ */ Z("div", {
994
- className: "overflow-y-auto px-6 pb-6 flex flex-col gap-5",
995
- children: [
996
- /* @__PURE__ */ Z("p", {
997
- className: "kol-mono-12 text-body",
998
- children: [
999
- "Type math into any slider's number box instead of a number. It re-evaluates every frame, so the value animates — no keyframes.",
1000
- " ",
1001
- /* @__PURE__ */ X("span", {
1002
- className: "text-emphasis",
1003
- children: "t"
1004
- }),
1005
- " is the playhead in seconds, so it pauses / scrubs / tempo-scales with the transport. Drag the slider to clear an expression."
1006
- ]
1007
- }),
1008
- /* @__PURE__ */ X(U, {
1009
- label: "Examples",
1010
- children: /* @__PURE__ */ X("div", {
1011
- className: "flex flex-col gap-1",
1012
- children: Ut.map(([e, t]) => /* @__PURE__ */ Z("div", {
1013
- className: "flex items-center gap-4",
1014
- children: [/* @__PURE__ */ X("code", {
1015
- className: "kol-mono-12 text-emphasis bg-oq-04 rounded px-2 py-0.5",
1016
- style: { minWidth: 132 },
1017
- children: e
1018
- }), /* @__PURE__ */ X("span", {
1019
- className: "kol-mono-12 text-body flex-1 min-w-0",
1020
- children: t
1021
- })]
1022
- }, e))
1023
- })
1024
- }),
1025
- /* @__PURE__ */ X(U, {
1026
- label: "Loop",
1027
- children: /* @__PURE__ */ Z("p", {
1028
- className: "kol-mono-12 text-body",
1029
- children: [
1030
- "The transport clock is a loop, not a BPM —",
1031
- " ",
1032
- /* @__PURE__ */ X("span", {
1033
- className: "text-emphasis",
1034
- children: "Loop / N s"
1035
- }),
1036
- " in the transport bar is the loop length in seconds, and every oscillator, sweep and export wraps seamlessly over it. Type a new length there; the default lives in Settings → Loop length."
1037
- ]
1038
- })
1039
- }),
1040
- /* @__PURE__ */ X(U, {
1041
- label: "Functions",
1042
- children: /* @__PURE__ */ X("div", {
1043
- className: "flex flex-col gap-2",
1044
- children: Wt.map(([e, t]) => /* @__PURE__ */ Z("div", { children: [/* @__PURE__ */ X("p", {
1045
- className: "kol-helper-10 text-subtle",
1046
- children: e
1047
- }), /* @__PURE__ */ X("p", {
1048
- className: "kol-mono-12 text-emphasis",
1049
- children: t
1050
- })] }, e))
1051
- })
1052
- }),
1053
- /* @__PURE__ */ X("div", {
1054
- className: "pt-3 border-t border-oq-08 flex flex-wrap gap-x-5 gap-y-1",
1055
- children: Gt().map(([e, t]) => /* @__PURE__ */ Z("span", {
1056
- className: "kol-mono-12",
1057
- children: [
1058
- /* @__PURE__ */ X("span", {
1059
- className: "text-emphasis",
1060
- children: e
1061
- }),
1062
- " ",
1063
- /* @__PURE__ */ X("span", {
1064
- className: "text-meta",
1065
- children: t
1066
- })
1067
- ]
1068
- }, e))
1069
- })
1070
- ]
643
+ accept: a ? "svg" : "all"
644
+ })] }),
645
+ svgMode: a,
646
+ openLibrary: () => i(!0),
647
+ openUpload: () => n.current?.click(),
648
+ openCamera: () => {
649
+ Ge(e.id).then(() => t({
650
+ src: null,
651
+ srcType: "webcam"
652
+ })).catch(() => {});
653
+ }
654
+ };
655
+ }
656
+ [
657
+ {
658
+ value: "library",
659
+ label: "Library"
660
+ },
661
+ {
662
+ value: "upload",
663
+ label: "Upload"
664
+ },
665
+ {
666
+ value: "camera",
667
+ label: "Camera"
668
+ }
669
+ ].slice(0, 2);
670
+ function Bt({ layer: e }) {
671
+ let t = zt(e);
672
+ return /* @__PURE__ */ Q("div", {
673
+ className: "flex flex-col gap-2",
674
+ children: [
675
+ /* @__PURE__ */ Z(K, {
676
+ tone: "primary",
677
+ size: "lg",
678
+ className: W,
679
+ iconLeft: "image",
680
+ iconRight: "image",
681
+ onClick: t.openLibrary,
682
+ children: "From library"
683
+ }),
684
+ /* @__PURE__ */ Z(K, {
685
+ tone: "primary",
686
+ size: "lg",
687
+ className: W,
688
+ iconLeft: "upload",
689
+ iconRight: "upload",
690
+ onClick: t.openUpload,
691
+ children: "Upload"
692
+ }),
693
+ !t.svgMode && /* @__PURE__ */ Z(K, {
694
+ tone: "primary",
695
+ size: "lg",
696
+ className: "w-full [&>span]:w-full [&>span]:justify-between",
697
+ iconLeft: "camera",
698
+ iconRight: "camera",
699
+ onClick: t.openCamera,
700
+ children: "Camera"
701
+ }),
702
+ t.nodes
703
+ ]
704
+ });
705
+ }
706
+ function Vt({ layer: e, title: t, onBack: n }) {
707
+ return we(n), /* @__PURE__ */ Z("div", {
708
+ 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",
709
+ style: { zIndex: "var(--kol-z-modal)" },
710
+ children: /* @__PURE__ */ Q("div", {
711
+ className: "my-auto w-full max-w-sm rounded p-8 flex flex-col gap-6",
712
+ style: { background: "var(--kol-surface-primary)" },
713
+ children: [
714
+ /* @__PURE__ */ Q("div", {
715
+ className: "flex flex-col gap-2",
716
+ children: [/* @__PURE__ */ Z("span", {
717
+ className: "kol-eyebrow text-body",
718
+ children: t
719
+ }), /* @__PURE__ */ Z("span", {
720
+ className: "kol-mono-12 text-meta",
721
+ children: "Pick the media it works on."
722
+ })]
723
+ }),
724
+ /* @__PURE__ */ Z(Bt, { layer: e }),
725
+ /* @__PURE__ */ Z(K, {
726
+ tone: "grey",
727
+ size: "lg",
728
+ className: W,
729
+ iconLeft: "arrow-left",
730
+ iconRight: "arrow-left",
731
+ onClick: n,
732
+ children: "Back"
733
+ })
734
+ ]
735
+ })
736
+ });
737
+ }
738
+ //#endregion
739
+ //#region src/editor/components/PanelHeader.jsx
740
+ function Ht({ title: e, onCollapse: t, action: n, className: r = "px-3" }) {
741
+ return /* @__PURE__ */ Q("div", {
742
+ className: `flex w-full shrink-0 items-center ${r}`,
743
+ children: [/* @__PURE__ */ Q("button", {
744
+ className: "kol-helper-12 text-meta flex flex-1 items-center gap-2 py-2.5",
745
+ onClick: t,
746
+ children: [/* @__PURE__ */ Z("span", { children: e }), /* @__PURE__ */ Z(Ct, {
747
+ name: "chevron-down",
748
+ size: 16,
749
+ className: "text-oq-48"
750
+ })]
751
+ }), n]
752
+ });
753
+ }
754
+ function Ut({ label: e, onOpen: t, size: n = "lg", tone: r = "primary", children: i }) {
755
+ return /* @__PURE__ */ Q("div", {
756
+ 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-wrap-reverse gap-2 px-3 [&>*]:pointer-events-auto",
757
+ children: [/* @__PURE__ */ Z(K, {
758
+ tone: r,
759
+ size: n,
760
+ onClick: t,
761
+ children: /* @__PURE__ */ Q("span", {
762
+ className: "flex items-center gap-2",
763
+ children: [e, /* @__PURE__ */ Z(Ct, {
764
+ name: "chevron-down",
765
+ size: 16,
766
+ className: "rotate-180"
767
+ })]
768
+ })
769
+ }), i]
770
+ });
771
+ }
772
+ var Wt = {
773
+ half: "50dvh",
774
+ tall: "85dvh"
775
+ };
776
+ function Gt({ tall: e, onToggle: t, onDrag: n }) {
777
+ let r = Y({
778
+ y: null,
779
+ moved: !1,
780
+ swallow: !1
781
+ }).current;
782
+ return /* @__PURE__ */ Z("button", {
783
+ type: "button",
784
+ "aria-label": e ? "Lower the sheet" : "Raise the sheet",
785
+ "aria-pressed": e,
786
+ className: "flex h-6 w-full shrink-0 touch-none items-center justify-center",
787
+ onPointerDown: (e) => {
788
+ r.y = e.clientY, r.moved = !1, e.currentTarget.setPointerCapture?.(e.pointerId);
789
+ },
790
+ onPointerMove: (e) => {
791
+ r.y !== null && Math.abs(e.clientY - r.y) > 32 && (r.moved = !0);
792
+ },
793
+ onPointerUp: (e) => {
794
+ if (r.y === null) return;
795
+ let t = e.clientY - r.y;
796
+ r.y = null, r.moved && n && (n(t < 0 ? -1 : 1), r.swallow = !0);
797
+ },
798
+ onPointerCancel: () => {
799
+ r.y = null;
800
+ },
801
+ onClick: () => {
802
+ if (r.swallow) {
803
+ r.swallow = !1;
804
+ return;
805
+ }
806
+ t?.();
807
+ },
808
+ children: /* @__PURE__ */ Z("span", { className: "h-1 w-9 rounded-full bg-oq-16" })
809
+ });
810
+ }
811
+ //#endregion
812
+ //#region src/editor/labs/LabsCatalogCard.jsx
813
+ function Kt({ onPicked: e, onClose: t }) {
814
+ let { items: n, dispatch: r } = qe(), [i, a] = X(null);
815
+ we(t);
816
+ let o = n.filter((e) => e.path !== "#rail/sec:modulation"), s = o.find((e) => e.path === i) ?? null, c = s ? s.sub : o;
817
+ return /* @__PURE__ */ Z("div", {
818
+ 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",
819
+ style: { zIndex: "var(--kol-z-modal)" },
820
+ children: /* @__PURE__ */ Q("div", {
821
+ className: "my-auto w-full max-w-sm rounded p-8 flex flex-col gap-6",
822
+ style: { background: "var(--kol-surface-primary)" },
823
+ children: [/* @__PURE__ */ Z("span", {
824
+ className: "kol-eyebrow text-body",
825
+ children: s ? s.label : "Labs"
826
+ }), /* @__PURE__ */ Q("div", {
827
+ className: "flex flex-col gap-2",
828
+ children: [c.map((t) => /* @__PURE__ */ Z(K, {
829
+ tone: "primary",
830
+ size: "lg",
831
+ className: W,
832
+ iconLeft: t.icon,
833
+ iconRight: t.icon,
834
+ onClick: () => {
835
+ if (!s && t.sub?.length) {
836
+ a(t.path);
837
+ return;
838
+ }
839
+ r?.(t.path) && e?.();
840
+ },
841
+ children: t.label
842
+ }, t.path)), s && /* @__PURE__ */ Z(K, {
843
+ tone: "grey",
844
+ size: "lg",
845
+ className: "w-full [&>span]:w-full [&>span]:justify-between",
846
+ iconLeft: "arrow-left",
847
+ iconRight: "arrow-left",
848
+ onClick: () => a(null),
849
+ children: "Back"
850
+ })]
1071
851
  })]
1072
852
  })
1073
- }) : null;
853
+ });
854
+ }
855
+ //#endregion
856
+ //#region src/editor/labs/sheetLabels.js
857
+ function qt(e) {
858
+ if (!e) return {
859
+ title: "Labs",
860
+ pill: "Labs"
861
+ };
862
+ if (e.type === "loop" || e.type === "misc") return {
863
+ title: `${te(e.loopGroup)?.label ?? "Labs"} · ${e.presetLabel}`,
864
+ pill: e.presetLabel
865
+ };
866
+ if (e.type === "photo") {
867
+ let n = t(e)[0]?.def?.label ?? "Media";
868
+ return {
869
+ title: n,
870
+ pill: n
871
+ };
872
+ }
873
+ let n = e.presetLabel ?? "Labs";
874
+ return {
875
+ title: n,
876
+ pill: n
877
+ };
1074
878
  }
1075
879
  //#endregion
1076
880
  //#region src/editor/labs/LabsView.jsx
1077
- var qt = .85, Jt = .3, Yt = 2.5, Xt = {
881
+ var Jt = .85, Yt = .3, Xt = 2.5, Zt = {
1078
882
  0: 1,
1079
883
  1: .5,
1080
884
  2: 1,
1081
885
  3: 1.5,
1082
886
  4: 2
1083
- }, Zt = "px-2 py-1 rounded border border-oq-08 bg-surface-secondary kol-mono-12 text-emphasis tabular-nums";
1084
- function Qt() {
1085
- let { layer: e } = vt(), t = e?.type === "photo" && !e.src && e.srcType !== "webcam", [n, r] = J(1), [i, a] = J(!1), o = ct(i), s = q(null), c = (e) => Math.min(Yt, Math.max(Jt, e)), l = (e) => r((t) => c(t * (e > 0 ? 1.25 : .8))), { tool: u } = $e(), d = u === "orbit", f = q(d);
1086
- return f.current = d, K(() => {
1087
- let e = s.current;
887
+ }, Qt = "px-2 py-1 rounded border border-oq-08 bg-surface-secondary kol-mono-12 text-emphasis tabular-nums";
888
+ function $t() {
889
+ let { layer: e } = $(), { removeLayer: t } = u(), n = e?.type === "photo" && !e.src && e.srcType !== "webcam", [r, i] = X(1), [a, o] = X(!1), s = ve(a), c = Y(null), l = (e) => Math.min(Xt, Math.max(Yt, e)), d = (e) => i((t) => l(t * (e > 0 ? 1.25 : .8))), { tool: f } = Oe(), p = f === "orbit", m = Y(p);
890
+ return m.current = p, J(() => {
891
+ let e = c.current;
1088
892
  if (!e) return;
1089
893
  let t = (e) => {
1090
- f.current || (e.preventDefault(), r((t) => c(t * (e.deltaY > 0 ? .94 : 1.06))));
894
+ m.current || (e.preventDefault(), i((t) => l(t * (e.deltaY > 0 ? .94 : 1.06))));
1091
895
  };
1092
896
  return e.addEventListener("wheel", t, { passive: !1 }), () => e.removeEventListener("wheel", t);
1093
- }, []), K(() => {
897
+ }, []), J(() => {
1094
898
  let e = (e) => {
1095
899
  if (e.metaKey || e.ctrlKey || e.altKey) return;
1096
900
  let t = e.target;
1097
901
  if (!(t?.tagName === "INPUT" || t?.tagName === "TEXTAREA" || t?.isContentEditable)) {
1098
902
  if (e.key === "f" || e.key === "F") {
1099
- a((e) => !e);
903
+ o((e) => !e);
1100
904
  return;
1101
905
  }
1102
- Xt[e.key] !== void 0 && r(Xt[e.key]);
906
+ if (e.key === "-" || e.key === "_") {
907
+ d(-1);
908
+ return;
909
+ }
910
+ if (e.key === "+" || e.key === "=") {
911
+ d(1);
912
+ return;
913
+ }
914
+ Zt[e.key] !== void 0 && i(Zt[e.key]);
1103
915
  }
1104
916
  };
1105
917
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
1106
- }, []), /* @__PURE__ */ Z("div", {
1107
- ref: s,
918
+ }, []), /* @__PURE__ */ Q("div", {
919
+ ref: c,
1108
920
  className: "relative w-full h-full flex items-center justify-center",
1109
921
  style: { background: "var(--kol-surface-secondary)" },
1110
- onDoubleClick: () => r(1),
1111
- children: [t ? /* @__PURE__ */ X(At, { layer: e }) : /* @__PURE__ */ X("div", {
1112
- style: {
1113
- width: `${n * qt * 100}%`,
1114
- height: `${n * qt * 100}%`
1115
- },
1116
- children: /* @__PURE__ */ X(rt, {})
1117
- }), /* @__PURE__ */ Z("div", {
1118
- className: "absolute bottom-3 right-3 z-[3] flex items-center gap-2",
1119
- children: [
1120
- /* @__PURE__ */ X(G, {
1121
- label: "Zoom out",
1122
- children: /* @__PURE__ */ X("button", {
1123
- "aria-label": "Zoom out",
1124
- type: "button",
1125
- className: Zt,
1126
- onClick: () => l(-1),
1127
- children: "−"
1128
- })
1129
- }),
1130
- /* @__PURE__ */ X(G, {
1131
- label: "Reset zoom (0)",
1132
- children: /* @__PURE__ */ Z("button", {
1133
- "aria-label": "Reset zoom (0)",
1134
- type: "button",
1135
- className: Zt,
1136
- onClick: () => r(1),
1137
- children: [Math.round(n * 100), "%"]
1138
- })
1139
- }),
1140
- /* @__PURE__ */ X(G, {
1141
- label: "Zoom in",
1142
- children: /* @__PURE__ */ X("button", {
1143
- "aria-label": "Zoom in",
1144
- type: "button",
1145
- className: Zt,
1146
- onClick: () => l(1),
1147
- children: "+"
1148
- })
1149
- }),
1150
- i && /* @__PURE__ */ X(G, {
922
+ onDoubleClick: () => i(1),
923
+ children: [
924
+ /* @__PURE__ */ Z("div", {
925
+ style: {
926
+ width: `${r * Jt * 100}%`,
927
+ height: `${r * Jt * 100}%`
928
+ },
929
+ children: /* @__PURE__ */ Z(ze, {})
930
+ }),
931
+ n && /* @__PURE__ */ Z(Vt, {
932
+ layer: e,
933
+ title: qt(e).title,
934
+ onBack: () => t(e.id)
935
+ }),
936
+ a && /* @__PURE__ */ Z("div", {
937
+ className: "absolute bottom-3 right-3 z-[3] flex items-center gap-2 [@media(pointer:coarse)]:bottom-1",
938
+ children: /* @__PURE__ */ Z(vt, {
1151
939
  label: "Framerate — press F to hide",
1152
- children: /* @__PURE__ */ Z("span", {
1153
- className: Zt,
1154
- children: [o, " fps"]
940
+ children: /* @__PURE__ */ Q("span", {
941
+ className: Qt,
942
+ children: [s, " fps"]
1155
943
  })
1156
944
  })
1157
- ]
1158
- })]
945
+ })
946
+ ]
1159
947
  });
1160
948
  }
1161
- function $t() {
1162
- let e = q(null), { grabProps: t } = gt(e, {
949
+ function en() {
950
+ let e = Y(null), { grabProps: t } = wt(e, {
1163
951
  token: "kol-rail",
1164
952
  side: "right"
1165
953
  });
1166
- return K(() => {
954
+ return J(() => {
1167
955
  let e = document.documentElement, t = !1, n = () => {
1168
956
  let t = parseFloat(getComputedStyle(e).getPropertyValue("--kol-shell-rail-width"));
1169
957
  return Number.isFinite(t) ? t <= 49 : null;
@@ -1200,235 +988,216 @@ function $t() {
1200
988
  }), () => {
1201
989
  c.disconnect(), l.disconnect();
1202
990
  };
1203
- }, []), /* @__PURE__ */ Z("div", {
991
+ }, []), /* @__PURE__ */ Q("div", {
1204
992
  ref: e,
1205
993
  className: "kol-compose-rail kol-compose-rail--inspector",
1206
- children: [/* @__PURE__ */ X("div", { ...t }), /* @__PURE__ */ X("div", {
994
+ children: [/* @__PURE__ */ Z("div", { ...t }), /* @__PURE__ */ Z("div", {
1207
995
  className: "kol-compose-inspector-body",
1208
- children: /* @__PURE__ */ X(Ht, {})
996
+ children: /* @__PURE__ */ Z(Rt, {})
1209
997
  })]
1210
998
  });
1211
999
  }
1212
- var en = pt(null);
1213
- function tn() {
1214
- let { paramsOpen: e, toggleParams: t } = ht(en);
1215
- return /* @__PURE__ */ X("div", {
1216
- className: "flex h-12 shrink-0 items-center border-b border-oq-08 bg-surface-primary px-2",
1217
- children: /* @__PURE__ */ X(G, {
1218
- label: "Parameters",
1219
- children: /* @__PURE__ */ X(H, {
1220
- variant: "nav",
1221
- size: "lg",
1222
- iconOnly: "panel-right",
1223
- "aria-label": "Parameters",
1224
- pressed: e,
1225
- onClick: t
1226
- })
1227
- })
1000
+ var tn = yt(null);
1001
+ function nn() {
1002
+ let { collapseParams: e, catalog: t, toggleCatalog: n } = xt(tn), { layer: r } = $(), i = /* @__PURE__ */ Z("button", {
1003
+ className: "kol-helper-12 text-meta py-2.5",
1004
+ "aria-pressed": t,
1005
+ onClick: n,
1006
+ children: "Catalog"
1007
+ });
1008
+ return /* @__PURE__ */ Z(Ht, {
1009
+ title: qt(r).title,
1010
+ onCollapse: e,
1011
+ className: "px-4",
1012
+ action: i
1228
1013
  });
1229
1014
  }
1230
- function nn() {
1231
- return /* @__PURE__ */ X("div", {
1015
+ function rn() {
1016
+ let { tall: e, setTall: t, collapseParams: n } = xt(tn);
1017
+ return /* @__PURE__ */ Z(Gt, {
1018
+ tall: e,
1019
+ onToggle: () => t((e) => !e),
1020
+ onDrag: (r) => {
1021
+ r < 0 ? t(!0) : e ? t(!1) : n();
1022
+ }
1023
+ });
1024
+ }
1025
+ function an() {
1026
+ return /* @__PURE__ */ Z("div", {
1232
1027
  className: "kol-compose-rail kol-compose-rail--inspector",
1233
- children: /* @__PURE__ */ X("div", {
1028
+ children: /* @__PURE__ */ Z("div", {
1234
1029
  className: "kol-compose-inspector-body",
1235
- children: /* @__PURE__ */ X(Ht, {})
1030
+ children: /* @__PURE__ */ Z(Rt, {})
1236
1031
  })
1237
1032
  });
1238
1033
  }
1239
- var rn = {
1034
+ var on = {
1240
1035
  topbar: () => null,
1241
- canvas: Qt,
1036
+ canvas: $t,
1242
1037
  panels: [
1243
1038
  {
1244
1039
  slot: "canvas.footer",
1245
1040
  order: 0,
1246
- Component: fe
1041
+ Component: de
1247
1042
  },
1248
1043
  {
1249
1044
  slot: "right.body",
1250
1045
  order: 0,
1251
- Component: $t
1046
+ Component: en
1252
1047
  },
1253
1048
  {
1254
1049
  slot: "right.footer",
1255
1050
  order: 0,
1256
- Component: Ye
1051
+ Component: Xe
1257
1052
  }
1258
1053
  ]
1259
- }, an = {
1260
- ...rn,
1261
- topbar: tn,
1262
- panels: rn.panels.map((e) => e.Component === $t ? {
1263
- ...e,
1264
- Component: nn
1265
- } : e)
1054
+ }, sn = {
1055
+ ...on,
1056
+ panels: [
1057
+ {
1058
+ slot: "right.header",
1059
+ order: 0,
1060
+ Component: rn
1061
+ },
1062
+ {
1063
+ slot: "right.header",
1064
+ order: 1,
1065
+ Component: nn
1066
+ },
1067
+ ...on.panels.map((e) => e.Component === en ? {
1068
+ ...e,
1069
+ Component: an
1070
+ } : e)
1071
+ ]
1266
1072
  };
1267
- function on() {
1268
- let { setAspect: e, selectedId: n, select: r } = p(), { layer: i, setOnly: a } = vt(), o = q(!1), s = et() && !Ze(), [c, u] = J(!1);
1269
- Fe(), K(() => {
1270
- if (o.current) return;
1271
- o.current = !0;
1272
- let n = y();
1273
- n.defaultAspect && n.defaultAspect !== "custom" && e(n.defaultAspect), n.defaultLoopSeconds && t.setLoopSeconds(n.defaultLoopSeconds);
1073
+ function cn() {
1074
+ let { setAspect: e, selectedId: t, select: r } = u(), { layer: i, setOnly: a } = $(), s = Y(!1), c = Ce(Ne), l = Me() && !Se() || c;
1075
+ J(() => {
1076
+ l && document.documentElement.removeAttribute("data-rail");
1077
+ }, [l]);
1078
+ let [d, f] = X(!0), [p, m] = X(!1), [h, g] = X(() => !i);
1079
+ J(() => {
1080
+ g(!i);
1081
+ }, [i?.id]), J(() => {
1082
+ i && !l && document.documentElement.removeAttribute("data-rail");
1083
+ }, [i?.id]), J(() => {
1084
+ if (!l) return;
1085
+ let e = () => f(!0);
1086
+ return window.addEventListener("kol:open-params", e), window.addEventListener("kol:open-effects", e), () => {
1087
+ window.removeEventListener("kol:open-params", e), window.removeEventListener("kol:open-effects", e);
1088
+ };
1089
+ }, [l]), De(), J(() => (st("labs"), () => st(null)), []), J(() => {
1090
+ if (s.current) return;
1091
+ s.current = !0;
1092
+ let t = v();
1093
+ t.defaultAspect && t.defaultAspect !== "custom" && e(t.defaultAspect), t.defaultLoopSeconds && n.setLoopSeconds(t.defaultLoopSeconds);
1274
1094
  }, []);
1275
- let d = q(!1);
1276
- K(() => {
1277
- if (d.current) return;
1278
- d.current = !0;
1095
+ let _ = Y(!1);
1096
+ J(() => {
1097
+ if (_.current) return;
1098
+ _.current = !0;
1279
1099
  let e = new URLSearchParams(window.location.search).get("preset"), t = e ? A(e) : null;
1280
- t && a("loop", D(w(e), t));
1100
+ t && a("loop", w(ne(e), t));
1281
1101
  }, [a]);
1282
- let { tool: f, setTool: m } = $e(), h = q(f);
1283
- return h.current = f, K(() => {
1102
+ let { tool: y, setTool: b } = Oe(), x = Y(y);
1103
+ return x.current = y, J(() => {
1284
1104
  let e = (e) => {
1285
- let n = e.target;
1286
- if (!(n?.tagName === "INPUT" || n?.tagName === "TEXTAREA" || n?.isContentEditable)) {
1105
+ let t = e.target;
1106
+ if (!(t?.tagName === "INPUT" || t?.tagName === "TEXTAREA" || t?.isContentEditable)) {
1287
1107
  if (e.code === "Space") {
1288
- e.preventDefault(), t.toggle();
1108
+ e.preventDefault(), n.toggle();
1289
1109
  return;
1290
1110
  }
1291
- (e.key === "c" || e.key === "C") && !e.metaKey && !e.ctrlKey && !e.altKey && m(h.current === "orbit" ? "select" : "orbit");
1111
+ if ((e.key === "s" || e.key === "S") && !e.metaKey && !e.ctrlKey && !e.altKey) {
1112
+ window.dispatchEvent(new CustomEvent("kol:show-shortcuts"));
1113
+ return;
1114
+ }
1115
+ (e.key === "c" || e.key === "C") && !e.metaKey && !e.ctrlKey && !e.altKey && b(x.current === "orbit" ? "select" : "orbit");
1292
1116
  }
1293
1117
  };
1294
1118
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
1295
- }, [m]), K(() => {
1119
+ }, [b]), J(() => {
1296
1120
  if (!i?.presetId) return;
1297
1121
  let e = new URLSearchParams(window.location.search);
1298
1122
  e.get("preset") !== i.presetId && (e.set("view", "labs"), e.set("preset", i.presetId), i.loopGroup ? e.set("cat", i.loopGroup) : e.delete("cat"), window.history.replaceState(null, "", `${window.location.pathname}?${e}`));
1299
- }, [i?.presetId, i?.loopGroup]), K(() => {
1300
- i && n !== i.id && r(i.id);
1123
+ }, [i?.presetId, i?.loopGroup]), J(() => {
1124
+ i && t !== i.id && r(i.id);
1301
1125
  }, [
1302
1126
  i,
1303
- n,
1127
+ t,
1304
1128
  r
1305
- ]), /* @__PURE__ */ Z("div", {
1129
+ ]), /* @__PURE__ */ Q("div", {
1306
1130
  className: "kol-editor-labs contents",
1307
- "data-touch": s || void 0,
1308
- "data-params": c ? "open" : void 0,
1131
+ "data-touch": l || void 0,
1132
+ "data-params": d ? "open" : void 0,
1133
+ "data-empty": i ? void 0 : "",
1134
+ style: p ? { "--kol-sheet-h": Wt.tall } : void 0,
1309
1135
  children: [
1310
- /* @__PURE__ */ X(Tt, {}),
1311
- s ? /* @__PURE__ */ X(en.Provider, {
1136
+ /* @__PURE__ */ Z(Et, {}),
1137
+ l ? /* @__PURE__ */ Q(tn.Provider, {
1312
1138
  value: {
1313
- paramsOpen: c,
1314
- toggleParams: () => u((e) => !e)
1139
+ collapseParams: () => f(!1),
1140
+ tall: p,
1141
+ setTall: m,
1142
+ catalog: h,
1143
+ toggleCatalog: () => g((e) => !e)
1315
1144
  },
1316
- children: /* @__PURE__ */ X(l.Provider, {
1145
+ children: [/* @__PURE__ */ Z(o.Provider, {
1317
1146
  value: "md",
1318
- children: /* @__PURE__ */ X(Me, { registry: an })
1319
- })
1320
- }) : /* @__PURE__ */ X(Me, { registry: rn }),
1321
- /* @__PURE__ */ X(Kt, {})
1147
+ children: /* @__PURE__ */ Z(Re, { registry: sn })
1148
+ }), !d && /* @__PURE__ */ Z(Ut, {
1149
+ tone: "grey",
1150
+ label: qt(i).pill,
1151
+ onOpen: () => f(!0)
1152
+ })]
1153
+ }) : /* @__PURE__ */ Z(Re, { registry: on }),
1154
+ h && /* @__PURE__ */ Z(Kt, {
1155
+ onPicked: () => g(!1),
1156
+ onClose: () => g(!1)
1157
+ })
1322
1158
  ]
1323
1159
  });
1324
1160
  }
1325
- var sn = "kol.editor.labs-draft";
1326
- function cn() {
1327
- return /* @__PURE__ */ X(Qe, {
1328
- draftKey: sn,
1329
- children: /* @__PURE__ */ X(on, {})
1330
- });
1331
- }
1332
- //#endregion
1333
- //#region src/editor/mobile/CategoryScreen.jsx
1334
- var ln = "w-full [&>span]:w-full [&>span]:justify-between";
1335
- function un(e) {
1336
- K(() => {
1337
- let t = (t) => {
1338
- t.key === "Escape" && e?.();
1339
- };
1340
- return window.addEventListener("keydown", t), () => window.removeEventListener("keydown", t);
1341
- }, [e]), K(() => {
1342
- let e = t.isPlaying();
1343
- return t.pause(), () => {
1344
- e && t.play();
1345
- };
1346
- }, []);
1347
- }
1348
- function dn({ onPick: e, onInsert: t, onBack: n, onDismiss: r }) {
1349
- return un(r ?? n), /* @__PURE__ */ X("div", {
1350
- 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",
1351
- style: { zIndex: "var(--kol-z-modal)" },
1352
- children: /* @__PURE__ */ Z("div", {
1353
- className: "my-auto w-full max-w-sm rounded p-8 flex flex-col gap-6",
1354
- style: { background: "var(--kol-surface-primary)" },
1355
- children: [
1356
- /* @__PURE__ */ X("div", {
1357
- className: "kol-eyebrow text-body",
1358
- children: "Pick a generator"
1359
- }),
1360
- /* @__PURE__ */ X("div", {
1361
- className: "flex flex-col gap-2",
1362
- children: P.map((t) => {
1363
- let n = $[`gen:${t.label}`] ?? "square";
1364
- return /* @__PURE__ */ X(H, {
1365
- variant: "primary",
1366
- size: "lg",
1367
- className: ln,
1368
- iconLeft: n,
1369
- iconRight: n,
1370
- onClick: () => e(t),
1371
- children: t.label
1372
- }, t.label);
1373
- })
1374
- }),
1375
- /* @__PURE__ */ Z("div", {
1376
- className: "flex flex-col gap-2",
1377
- children: [t && /* @__PURE__ */ X(H, {
1378
- variant: "grey",
1379
- size: "lg",
1380
- className: "w-full [&>span]:w-full [&>span]:justify-between",
1381
- iconLeft: "image",
1382
- iconRight: "image",
1383
- onClick: t,
1384
- children: "Insert image or video"
1385
- }), n && /* @__PURE__ */ X(H, {
1386
- variant: "grey",
1387
- size: "lg",
1388
- className: "w-full [&>span]:w-full [&>span]:justify-between",
1389
- iconLeft: "arrow-left",
1390
- iconRight: "arrow-left",
1391
- onClick: n,
1392
- children: "Back"
1393
- })]
1394
- })
1395
- ]
1396
- })
1161
+ var ln = "kol.editor.labs-draft";
1162
+ function un() {
1163
+ return /* @__PURE__ */ Z(Ve, {
1164
+ draftKey: ln,
1165
+ children: /* @__PURE__ */ Z(cn, {})
1397
1166
  });
1398
1167
  }
1399
1168
  //#endregion
1400
1169
  //#region src/editor/mobile/EffectScreen.jsx
1401
- function fn({ layer: e, chain: t, onPick: n, onBack: r }) {
1402
- let [i, a] = J(null);
1403
- un(r);
1404
- let { engineHost: o } = ce(e), s = o && !t.some((e) => e.def?.kind === "engine"), c = R(z.filter((e) => e.kind !== "engine" || s)), l = c.find((e) => e.id === i) ?? null;
1405
- return /* @__PURE__ */ X("div", {
1170
+ function dn({ layer: e, chain: t, onPick: n, onBack: r }) {
1171
+ let [i, a] = X(null);
1172
+ we(r);
1173
+ let { engineHost: o } = L(e), s = o && !t.some((e) => e.def?.kind === "engine"), c = F(I.filter((e) => e.kind !== "engine" || s)), l = c.find((e) => e.id === i) ?? null;
1174
+ return /* @__PURE__ */ Z("div", {
1406
1175
  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",
1407
1176
  style: { zIndex: "var(--kol-z-modal)" },
1408
- children: /* @__PURE__ */ Z("div", {
1177
+ children: /* @__PURE__ */ Q("div", {
1409
1178
  className: "my-auto w-full max-w-sm rounded p-8 flex flex-col gap-6",
1410
1179
  style: { background: "var(--kol-surface-primary)" },
1411
1180
  children: [
1412
- /* @__PURE__ */ X("div", {
1181
+ /* @__PURE__ */ Z("div", {
1413
1182
  className: "kol-eyebrow text-body",
1414
1183
  children: l ? l.label : "Pick an effect"
1415
1184
  }),
1416
- /* @__PURE__ */ X("div", {
1185
+ /* @__PURE__ */ Z("div", {
1417
1186
  className: "flex flex-col gap-2",
1418
- children: (l ? l.filters : c).map((e) => /* @__PURE__ */ X(H, {
1419
- variant: "primary",
1187
+ children: (l ? l.filters : c).map((e) => /* @__PURE__ */ Z(K, {
1188
+ tone: "primary",
1420
1189
  size: "lg",
1421
- className: ln,
1190
+ className: W,
1422
1191
  iconLeft: l ? "filter" : "chevron-right",
1423
1192
  iconRight: l ? "filter" : "chevron-right",
1424
1193
  onClick: () => l ? n(e.id) : a(e.id),
1425
1194
  children: e.label
1426
1195
  }, e.id))
1427
1196
  }),
1428
- /* @__PURE__ */ X(H, {
1429
- variant: "grey",
1197
+ /* @__PURE__ */ Z(K, {
1198
+ tone: "grey",
1430
1199
  size: "lg",
1431
- className: ln,
1200
+ className: W,
1432
1201
  iconLeft: "arrow-left",
1433
1202
  iconRight: "arrow-left",
1434
1203
  onClick: () => l ? a(null) : r(),
@@ -1440,7 +1209,7 @@ function fn({ layer: e, chain: t, onPick: n, onBack: r }) {
1440
1209
  }
1441
1210
  //#endregion
1442
1211
  //#region src/editor/mobile/MobileOverlay.jsx
1443
- var pn = { background: "var(--kol-surface-primary)" }, mn = [
1212
+ var fn = { background: "var(--kol-surface-primary)" }, pn = [
1444
1213
  {
1445
1214
  value: "generate",
1446
1215
  label: "Generate"
@@ -1457,25 +1226,27 @@ var pn = { background: "var(--kol-surface-primary)" }, mn = [
1457
1226
  value: "output",
1458
1227
  label: "Output"
1459
1228
  }
1460
- ], hn = mn.filter((e) => e.value !== "generate"), gn = "[&_.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)]", _n = 9.6, vn = 10;
1461
- function yn(e) {
1462
- let t = Math.min(window.innerWidth, 480) - 24, n = [], r = [], i = 0;
1463
- for (let a of e) {
1464
- let e = a.label.length * _n + vn, o = Math.max(i, e);
1465
- r.length && (r.length + 1) * o > t ? (n.push(r), r = [a], i = e) : (r.push(a), i = o);
1229
+ ], mn = pn.filter((e) => e.value !== "generate"), hn = "[&_.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)]", gn = {
1230
+ lg: 9.6,
1231
+ sm: 7.2
1232
+ }, _n = 10, vn = 232;
1233
+ function yn(e, t) {
1234
+ let n = t === "sm" ? vn : Math.min(window.innerWidth, 480) - 24, r = [], i = [], a = 0;
1235
+ for (let o of e) {
1236
+ let e = o.label.length * gn[t] + _n, s = Math.max(a, e);
1237
+ i.length && (i.length + 1) * s > n ? (r.push(i), i = [o], a = e) : (i.push(o), a = s);
1466
1238
  }
1467
- return r.length && n.push(r), n;
1239
+ return i.length && r.push(i), r;
1468
1240
  }
1469
- function bn({ cells: e }) {
1470
- return yn(e).map((e, t) => /* @__PURE__ */ X(W, {
1471
- variant: "filled",
1241
+ function bn({ cells: e, size: t }) {
1242
+ return yn(e, t).map((e, n) => /* @__PURE__ */ Z(q, {
1472
1243
  value: null,
1473
1244
  onChange: (t) => e.find((e) => e.value === t)?.run(),
1474
1245
  options: e,
1475
- size: "lg",
1246
+ size: t,
1476
1247
  ariaLabel: "Randomize scope",
1477
- className: gn
1478
- }, t));
1248
+ className: hn
1249
+ }, n));
1479
1250
  }
1480
1251
  var xn = [
1481
1252
  2,
@@ -1486,14 +1257,13 @@ var xn = [
1486
1257
  value: String(e),
1487
1258
  label: `${e}s`
1488
1259
  }));
1489
- function Sn() {
1490
- let { loopSeconds: e, setLoopSeconds: t } = n();
1491
- return /* @__PURE__ */ X(W, {
1492
- variant: "filled",
1493
- value: String(e),
1494
- onChange: (e) => t(Number(e)),
1260
+ function Sn({ size: e }) {
1261
+ let { loopSeconds: t, setLoopSeconds: n } = C();
1262
+ return /* @__PURE__ */ Z(q, {
1263
+ value: String(t),
1264
+ onChange: (e) => n(Number(e)),
1495
1265
  options: xn,
1496
- size: "lg",
1266
+ size: e,
1497
1267
  ariaLabel: "Loop length"
1498
1268
  });
1499
1269
  }
@@ -1532,304 +1302,304 @@ var Cn = [
1532
1302
  label: "Fill"
1533
1303
  }
1534
1304
  ];
1535
- function Tn({ layer: e, onSwitchCategory: n, onInsert: i, onRestart: o, aspectValue: c, onAspect: l, openEffects: f = !1 }) {
1536
- let { updateLayer: m, addFilter: _, removeFilter: y } = p(), { onExportPng: b } = Ae(), [x, S] = J(!1), [ee, C] = J(!0), [w, T] = J(!1), [E, D] = J(!1), [te, A] = J("generate"), j = u(e);
1537
- if (K(() => {
1538
- f && (C(!0), D(!0));
1539
- }, [f]), !e) return null;
1540
- if (x) return /* @__PURE__ */ X("button", {
1305
+ function Tn({ layer: e, onSwitchCategory: r, onInsert: a, onRestart: o, aspectValue: l, onAspect: d, openEffects: f = !1, rail: h = !1, onRail: v, onSheet: y }) {
1306
+ let { updateLayer: b, addFilter: x, removeFilter: ee } = u(), { onExportPng: S } = dt(), [C, ne] = X(!1), [w, T] = X(!0), [E, D] = X(!1), [O, k] = X(!1), [A, j] = X("generate"), [M, N] = X(!1), P = s(e);
1307
+ J(() => {
1308
+ f && (T(!0), k(!0));
1309
+ }, [f]);
1310
+ let F = h ? "sm" : "lg", I = h && !!e && w && !C;
1311
+ J(() => (v?.(I), () => v?.(!1)), [I]);
1312
+ let ie = !h && e && w && !C ? M ? Wt.tall : Wt.half : null;
1313
+ if (J(() => (y?.(ie), () => y?.(null)), [ie]), !e) return null;
1314
+ if (C) return /* @__PURE__ */ Z("button", {
1541
1315
  "aria-label": "Show controls",
1542
1316
  className: "fixed inset-y-0 right-0 left-[var(--fxr-rail,0px)] z-20",
1543
- onClick: () => S(!1)
1317
+ onClick: () => ne(!1)
1544
1318
  });
1545
- let M = e.type === "loop", N = M ? `${O(e.loopGroup).label} · ${e.presetLabel}` : "Media", P = M ? k(e.loopId)?.params ?? [] : [], F = M ? g(P, e) : [], I = () => m(e.id, s(e, h(P, e), j.take(), { withFilters: !0 })), ne = (t) => m(e.id, s(e, t.params, j.take(), { stripNoRandom: !!t.motion })), L = () => {
1546
- let t = d(e, j.take());
1547
- t && m(e.id, t);
1548
- }, R = r(e), { effectable: re } = ce(e), z = () => {
1549
- let t = v(e, j.take());
1550
- t && m(e.id, { filters: t });
1319
+ let R = e.type === "loop", ae = R ? `${te(e.loopGroup).label} · ${e.presetLabel}` : "Media", z = R ? re(e.loopId)?.params ?? [] : [], oe = R ? m(z, e) : [], se = () => b(e.id, i(e, p(z, e), P.take(), { withFilters: !0 })), B = (t) => b(e.id, i(e, t.params, P.take(), { stripNoRandom: !!t.motion })), ce = () => {
1320
+ let t = c(e, P.take());
1321
+ t && b(e.id, t);
1322
+ }, V = t(e), { effectable: le } = L(e), H = () => {
1323
+ let t = _(e, P.take());
1324
+ t && b(e.id, { filters: t });
1551
1325
  };
1552
- if (!ee) return /* @__PURE__ */ Z("div", {
1553
- className: "fixed bottom-[max(0.75rem,env(safe-area-inset-bottom))] left-[var(--fxr-rail,0px)] z-10 flex gap-2 px-3",
1554
- children: [
1555
- /* @__PURE__ */ X(H, {
1556
- variant: "primary",
1557
- size: "lg",
1558
- onClick: () => C(!0),
1559
- children: /* @__PURE__ */ Z("span", {
1560
- className: "flex items-center gap-2",
1561
- children: [M ? e.presetLabel : "Media", /* @__PURE__ */ X(Q, {
1562
- name: "chevron-down",
1563
- size: 16,
1564
- className: "rotate-180"
1565
- })]
1566
- })
1567
- }),
1568
- (M || R.length > 0) && /* @__PURE__ */ X(H, {
1569
- variant: "primary",
1570
- size: "lg",
1571
- onClick: I,
1572
- children: "Randomize all"
1573
- }),
1574
- /* @__PURE__ */ X(H, {
1575
- variant: "primary",
1576
- size: "lg",
1577
- onClick: () => b(2),
1578
- children: "Download"
1579
- })
1580
- ]
1326
+ if (!w) return /* @__PURE__ */ Q(Ut, {
1327
+ label: R ? e.presetLabel : "Media",
1328
+ onOpen: () => T(!0),
1329
+ size: F,
1330
+ children: [(R || V.length > 0) && /* @__PURE__ */ Z(K, {
1331
+ tone: "primary",
1332
+ size: F,
1333
+ onClick: se,
1334
+ children: "Randomize all"
1335
+ }), /* @__PURE__ */ Z(K, {
1336
+ tone: "primary",
1337
+ size: F,
1338
+ onClick: () => S(2),
1339
+ children: "Download"
1340
+ })]
1581
1341
  });
1582
- let ie = (M ? mn : hn).filter((e) => (e.value !== "effects" || re) && (e.value !== "transport" || a("motion"))), B = ie.some((e) => e.value === te) ? te : ie[0].value;
1583
- return /* @__PURE__ */ Z(Y, { children: [
1584
- w && /* @__PURE__ */ X(dn, {
1342
+ let ue = (R ? pn : mn).filter((e) => (e.value !== "effects" || le) && (e.value !== "transport" || g("motion"))), U = ue.some((e) => e.value === A) ? A : ue[0].value;
1343
+ return /* @__PURE__ */ Q(St, { children: [
1344
+ E && /* @__PURE__ */ Z(ye, {
1585
1345
  onPick: (e) => {
1586
- n(e), T(!1);
1346
+ r(e), D(!1);
1587
1347
  },
1588
1348
  onInsert: () => {
1589
- T(!1), i();
1349
+ D(!1), a();
1590
1350
  },
1591
1351
  onBack: () => {
1592
- T(!1), o();
1352
+ D(!1), o();
1593
1353
  },
1594
- onDismiss: () => T(!1)
1354
+ onDismiss: () => D(!1)
1595
1355
  }),
1596
- E && /* @__PURE__ */ X(fn, {
1356
+ O && /* @__PURE__ */ Z(dn, {
1597
1357
  layer: e,
1598
- chain: R,
1358
+ chain: V,
1599
1359
  onPick: (t) => {
1600
- _(e.id, t), D(!1);
1360
+ x(e.id, t), k(!1);
1601
1361
  },
1602
- onBack: () => D(!1)
1362
+ onBack: () => k(!1)
1603
1363
  }),
1604
- /* @__PURE__ */ Z("div", {
1605
- className: "fixed right-0 left-[var(--fxr-rail,0px)] bottom-0 z-10 pb-[env(safe-area-inset-bottom)]",
1606
- style: pn,
1607
- children: [/* @__PURE__ */ Z("div", {
1608
- className: "flex w-full items-center px-3",
1609
- children: [/* @__PURE__ */ Z("button", {
1610
- className: "kol-helper-12 text-meta flex flex-1 items-center gap-2 py-2.5",
1611
- onClick: () => C(!1),
1612
- children: [/* @__PURE__ */ X("span", { children: N }), /* @__PURE__ */ X(Q, {
1613
- name: "chevron-down",
1614
- size: 16,
1615
- className: "text-oq-48"
1616
- })]
1617
- }), /* @__PURE__ */ X("button", {
1618
- className: "kol-helper-12 text-meta py-2.5",
1619
- onClick: o,
1620
- children: "Start over"
1621
- })]
1622
- }), /* @__PURE__ */ Z("div", {
1623
- className: "px-3 pb-3",
1624
- children: [
1625
- /* @__PURE__ */ X(W, {
1626
- variant: "filled",
1627
- value: B,
1628
- onChange: A,
1629
- options: ie,
1630
- size: "lg",
1631
- className: "[&_.kol-seg-cell]:min-w-0 [&_.kol-seg-cell]:px-2 [&_.kol-seg-cell]:overflow-hidden"
1632
- }),
1633
- B === "generate" && M && /* @__PURE__ */ Z("div", {
1634
- className: "flex flex-col gap-2 pt-3",
1635
- children: [
1636
- /* @__PURE__ */ Z("div", {
1364
+ /* @__PURE__ */ Q("div", {
1365
+ className: h ? "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)]",
1366
+ style: h ? fn : {
1367
+ ...fn,
1368
+ top: `calc(100dvh - ${ie ?? Wt.half})`
1369
+ },
1370
+ children: [
1371
+ !h && /* @__PURE__ */ Z(Gt, {
1372
+ tall: M,
1373
+ onToggle: () => N((e) => !e),
1374
+ onDrag: (e) => {
1375
+ e < 0 ? N(!0) : M ? N(!1) : T(!1);
1376
+ }
1377
+ }),
1378
+ /* @__PURE__ */ Z(Ht, {
1379
+ title: ae,
1380
+ onCollapse: () => T(!1),
1381
+ className: h ? "px-4 pt-2.5 pb-1.5" : "px-3",
1382
+ action: /* @__PURE__ */ Z("button", {
1383
+ className: "kol-helper-12 text-meta py-2.5",
1384
+ onClick: o,
1385
+ children: "Start over"
1386
+ })
1387
+ }),
1388
+ /* @__PURE__ */ Q("div", {
1389
+ className: h ? "px-4 pb-5" : "min-h-0 flex-1 overflow-y-auto px-3 pb-3",
1390
+ children: [
1391
+ /* @__PURE__ */ Z(q, {
1392
+ value: U,
1393
+ onChange: j,
1394
+ options: ue,
1395
+ size: F,
1396
+ className: h ? hn : "[&_.kol-seg-cell]:min-w-0 [&_.kol-seg-cell]:px-2 [&_.kol-seg-cell]:overflow-hidden"
1397
+ }),
1398
+ U === "generate" && R && /* @__PURE__ */ Q("div", {
1399
+ className: "flex flex-col gap-2 pt-3",
1400
+ children: [
1401
+ /* @__PURE__ */ Q("div", {
1402
+ className: "grid grid-cols-2 gap-2",
1403
+ children: [/* @__PURE__ */ Z(K, {
1404
+ tone: "primary",
1405
+ size: F,
1406
+ iconRight: "refresh",
1407
+ onClick: ce,
1408
+ children: "Preset"
1409
+ }), /* @__PURE__ */ Z(K, {
1410
+ tone: "primary",
1411
+ size: F,
1412
+ onClick: () => D(!0),
1413
+ children: "Generator"
1414
+ })]
1415
+ }),
1416
+ /* @__PURE__ */ Z(K, {
1417
+ tone: "primary",
1418
+ size: F,
1419
+ className: "w-full",
1420
+ onClick: se,
1421
+ children: "Randomize all"
1422
+ }),
1423
+ oe.length > 0 && /* @__PURE__ */ Z(bn, {
1424
+ size: F,
1425
+ cells: [...oe.map((e) => ({
1426
+ value: e.id,
1427
+ label: e.label,
1428
+ run: () => B(e)
1429
+ })), {
1430
+ value: "__retrigger",
1431
+ label: "Re-trigger",
1432
+ run: () => n.rewind()
1433
+ }]
1434
+ })
1435
+ ]
1436
+ }),
1437
+ U === "effects" && /* @__PURE__ */ Q("div", {
1438
+ className: "flex flex-col gap-2 pt-3",
1439
+ children: [/* @__PURE__ */ Q("div", {
1637
1440
  className: "grid grid-cols-2 gap-2",
1638
- children: [/* @__PURE__ */ X(H, {
1639
- variant: "primary",
1640
- size: "lg",
1641
- iconRight: "refresh",
1642
- onClick: L,
1643
- children: "Preset"
1644
- }), /* @__PURE__ */ X(H, {
1645
- variant: "primary",
1646
- size: "lg",
1647
- onClick: () => T(!0),
1648
- children: "Generator"
1441
+ children: [/* @__PURE__ */ Z(K, {
1442
+ tone: "primary",
1443
+ size: F,
1444
+ onClick: () => k(!0),
1445
+ children: "Add effect"
1446
+ }), /* @__PURE__ */ Z(K, {
1447
+ tone: "primary",
1448
+ size: F,
1449
+ disabled: !V.length,
1450
+ onClick: H,
1451
+ children: "Randomize"
1649
1452
  })]
1650
- }),
1651
- /* @__PURE__ */ X(H, {
1652
- variant: "primary",
1653
- size: "lg",
1654
- className: "w-full",
1655
- onClick: I,
1656
- children: "Randomize all"
1657
- }),
1658
- F.length > 0 && /* @__PURE__ */ X(bn, { cells: [...F.map((e) => ({
1659
- value: e.id,
1660
- label: e.label,
1661
- run: () => ne(e)
1662
- })), {
1663
- value: "__retrigger",
1664
- label: "Re-trigger",
1665
- run: () => t.rewind()
1666
- }] })
1667
- ]
1668
- }),
1669
- B === "effects" && /* @__PURE__ */ Z("div", {
1670
- className: "flex flex-col gap-2 pt-3",
1671
- children: [/* @__PURE__ */ Z("div", {
1672
- className: "grid grid-cols-2 gap-2",
1673
- children: [/* @__PURE__ */ X(H, {
1674
- variant: "primary",
1675
- size: "lg",
1676
- onClick: () => D(!0),
1677
- children: "Add effect"
1678
- }), /* @__PURE__ */ X(H, {
1679
- variant: "primary",
1680
- size: "lg",
1681
- disabled: !R.length,
1682
- onClick: z,
1683
- children: "Randomize"
1684
- })]
1685
- }), R.map((t, n) => {
1686
- let r = {
1687
- ...e,
1688
- ...t.params,
1689
- id: e.id
1690
- }, i = t.def ? g(t.def.params, r) : [], a = (t) => {
1691
- let i = s(r, t.params, j.take(), { stripNoRandom: !!t.motion }), a = R.map(({ def: e, ...t }) => t);
1692
- m(e.id, { filters: a.map((e, t) => t === n ? {
1453
+ }), V.map((t, n) => {
1454
+ let r = {
1693
1455
  ...e,
1694
- params: {
1695
- ...e.params,
1696
- ...i
1697
- }
1698
- } : e) });
1699
- };
1700
- return /* @__PURE__ */ Z("div", {
1701
- className: "flex flex-col gap-2",
1702
- children: [/* @__PURE__ */ X(H, {
1703
- variant: "grey",
1704
- size: "lg",
1705
- className: "w-full [&>span]:w-full [&>span]:justify-between",
1706
- iconLeft: "trash",
1707
- iconRight: "trash",
1708
- onClick: () => y(e.id, n),
1709
- children: `${n + 1}. ${t.def?.label ?? t.id}`
1710
- }), i.length > 0 && /* @__PURE__ */ X(bn, { cells: i.map((e) => ({
1711
- value: e.id,
1712
- label: e.label,
1713
- run: () => a(e)
1714
- })) })]
1715
- }, t.key);
1716
- })]
1717
- }),
1718
- B === "transport" && a("motion") && /* @__PURE__ */ Z("div", {
1719
- className: "flex flex-col gap-2 pt-3",
1720
- children: [(() => {
1721
- let e = a("motion").TransportBar;
1722
- return /* @__PURE__ */ X(e, { size: "lg" });
1723
- })(), /* @__PURE__ */ X(Sn, {})]
1724
- }),
1725
- B === "output" && /* @__PURE__ */ Z("div", {
1726
- className: "flex flex-col gap-2 pt-3",
1727
- children: [
1728
- /* @__PURE__ */ X(W, {
1729
- variant: "filled",
1730
- value: c,
1731
- onChange: l,
1732
- options: Cn,
1733
- size: "lg",
1734
- ariaLabel: "Aspect"
1735
- }),
1736
- /* @__PURE__ */ X(W, {
1737
- variant: "filled",
1738
- value: c,
1739
- onChange: l,
1740
- options: wn,
1741
- size: "lg",
1742
- ariaLabel: "Aspect (landscape) and fill"
1743
- }),
1744
- /* @__PURE__ */ Z("div", {
1745
- className: "grid grid-cols-3 gap-2",
1746
- children: [
1747
- /* @__PURE__ */ X(H, {
1748
- variant: "primary",
1749
- size: "lg",
1750
- onClick: () => b(2),
1751
- children: "Download"
1752
- }),
1753
- /* @__PURE__ */ X(H, {
1754
- variant: "primary",
1755
- size: "lg",
1756
- onClick: () => S(!0),
1757
- children: "Hide UI"
1758
- }),
1759
- /* @__PURE__ */ X(H, {
1760
- variant: "primary",
1761
- size: "lg",
1762
- onClick: o,
1763
- children: "Start over"
1764
- })
1765
- ]
1766
- })
1767
- ]
1768
- })
1769
- ]
1770
- })]
1456
+ ...t.params,
1457
+ id: e.id
1458
+ }, a = t.def ? m(t.def.params, r) : [], o = (t) => {
1459
+ let a = i(r, t.params, P.take(), { stripNoRandom: !!t.motion }), o = V.map(({ def: e, ...t }) => t);
1460
+ b(e.id, { filters: o.map((e, t) => t === n ? {
1461
+ ...e,
1462
+ params: {
1463
+ ...e.params,
1464
+ ...a
1465
+ }
1466
+ } : e) });
1467
+ };
1468
+ return /* @__PURE__ */ Q("div", {
1469
+ className: "flex flex-col gap-2",
1470
+ children: [/* @__PURE__ */ Z(K, {
1471
+ tone: "grey",
1472
+ size: F,
1473
+ className: "w-full [&>span]:w-full [&>span]:justify-between",
1474
+ iconLeft: "trash",
1475
+ iconRight: "trash",
1476
+ onClick: () => ee(e.id, n),
1477
+ children: `${n + 1}. ${t.def?.label ?? t.id}`
1478
+ }), a.length > 0 && /* @__PURE__ */ Z(bn, {
1479
+ size: F,
1480
+ cells: a.map((e) => ({
1481
+ value: e.id,
1482
+ label: e.label,
1483
+ run: () => o(e)
1484
+ }))
1485
+ })]
1486
+ }, t.key);
1487
+ })]
1488
+ }),
1489
+ U === "transport" && g("motion") && /* @__PURE__ */ Q("div", {
1490
+ className: "flex flex-col gap-2 pt-3",
1491
+ children: [(() => {
1492
+ let e = g("motion").TransportBar;
1493
+ return /* @__PURE__ */ Z(e, { size: F });
1494
+ })(), /* @__PURE__ */ Z(Sn, { size: F })]
1495
+ }),
1496
+ U === "output" && /* @__PURE__ */ Q("div", {
1497
+ className: "flex flex-col gap-2 pt-3",
1498
+ children: [
1499
+ /* @__PURE__ */ Z(q, {
1500
+ value: l,
1501
+ onChange: d,
1502
+ options: Cn,
1503
+ size: F,
1504
+ ariaLabel: "Aspect"
1505
+ }),
1506
+ /* @__PURE__ */ Z(q, {
1507
+ value: l,
1508
+ onChange: d,
1509
+ options: wn,
1510
+ size: F,
1511
+ ariaLabel: "Aspect (landscape) and fill"
1512
+ }),
1513
+ /* @__PURE__ */ Q("div", {
1514
+ className: "grid grid-cols-3 gap-2",
1515
+ children: [
1516
+ /* @__PURE__ */ Z(K, {
1517
+ tone: "primary",
1518
+ size: F,
1519
+ onClick: () => S(2),
1520
+ children: "Download"
1521
+ }),
1522
+ /* @__PURE__ */ Z(K, {
1523
+ tone: "primary",
1524
+ size: F,
1525
+ onClick: () => ne(!0),
1526
+ children: "Hide UI"
1527
+ }),
1528
+ /* @__PURE__ */ Z(K, {
1529
+ tone: "primary",
1530
+ size: F,
1531
+ onClick: o,
1532
+ children: "Start over"
1533
+ })
1534
+ ]
1535
+ })
1536
+ ]
1537
+ })
1538
+ ]
1539
+ })
1540
+ ]
1771
1541
  })
1772
1542
  ] });
1773
1543
  }
1774
1544
  //#endregion
1775
1545
  //#region src/editor/mobile/MobileView.jsx
1776
1546
  function En({ onGenerate: e, onEffects: t, chromes: n }) {
1777
- return /* @__PURE__ */ X("div", {
1547
+ return /* @__PURE__ */ Z("div", {
1778
1548
  className: "fixed inset-y-0 right-0 left-[var(--fxr-rail,0px)] kol-overlay-scrim flex flex-col items-center justify-center p-6",
1779
1549
  style: { zIndex: "var(--kol-z-modal)" },
1780
- children: /* @__PURE__ */ Z("div", {
1550
+ children: /* @__PURE__ */ Q("div", {
1781
1551
  className: "w-full max-w-sm rounded p-8 flex flex-col gap-6",
1782
1552
  style: { background: "var(--kol-surface-primary)" },
1783
- children: [n ? /* @__PURE__ */ Z("div", {
1553
+ children: [n ? /* @__PURE__ */ Q("div", {
1784
1554
  className: "flex flex-col gap-2",
1785
- children: [/* @__PURE__ */ X("span", {
1555
+ children: [/* @__PURE__ */ Z("span", {
1786
1556
  className: "kol-eyebrow text-body",
1787
1557
  children: "Select chrome"
1788
- }), /* @__PURE__ */ X("span", {
1558
+ }), /* @__PURE__ */ Z("span", {
1789
1559
  className: "kol-mono-16 text-emphasis",
1790
1560
  children: "Effexor FXR"
1791
1561
  })]
1792
- }) : /* @__PURE__ */ X("span", {
1562
+ }) : /* @__PURE__ */ Z("span", {
1793
1563
  className: "kol-eyebrow text-body",
1794
- children: ye("randomiser").label
1795
- }), /* @__PURE__ */ Z("div", {
1564
+ children: pe("randomiser").label
1565
+ }), /* @__PURE__ */ Q("div", {
1796
1566
  className: "flex flex-col gap-2",
1797
1567
  children: [
1798
- /* @__PURE__ */ X(H, {
1799
- variant: "primary",
1568
+ /* @__PURE__ */ Z(K, {
1569
+ tone: "primary",
1800
1570
  size: "lg",
1801
- className: ln,
1802
- iconLeft: bt.randomiser,
1803
- iconRight: bt.randomiser,
1571
+ className: W,
1572
+ iconLeft: G.randomiser,
1573
+ iconRight: G.randomiser,
1804
1574
  onClick: e,
1805
1575
  children: "Generate"
1806
1576
  }),
1807
- /* @__PURE__ */ X(H, {
1808
- variant: "primary",
1577
+ /* @__PURE__ */ Z(K, {
1578
+ tone: "primary",
1809
1579
  size: "lg",
1810
- className: ln,
1580
+ className: W,
1811
1581
  iconLeft: "filter",
1812
1582
  iconRight: "filter",
1813
1583
  onClick: t,
1814
1584
  children: "Effects"
1815
1585
  }),
1816
- n && Ge() && /* @__PURE__ */ X(H, {
1817
- variant: "primary",
1586
+ n && Pe() && /* @__PURE__ */ Z(K, {
1587
+ tone: "primary",
1818
1588
  size: "lg",
1819
1589
  className: "w-full [&>span]:w-full [&>span]:justify-between",
1820
- iconLeft: bt.editor,
1821
- iconRight: bt.editor,
1822
- onClick: Xe,
1823
- children: ye("editor").label
1590
+ iconLeft: G.editor,
1591
+ iconRight: G.editor,
1592
+ onClick: xe,
1593
+ children: pe("editor").label
1824
1594
  }),
1825
- n && /* @__PURE__ */ X(H, {
1826
- variant: "primary",
1595
+ n && /* @__PURE__ */ Z(K, {
1596
+ tone: "primary",
1827
1597
  size: "lg",
1828
1598
  className: "w-full [&>span]:w-full [&>span]:justify-between",
1829
- iconLeft: bt.labs,
1830
- iconRight: bt.labs,
1831
- onClick: be,
1832
- children: ye("labs").label
1599
+ iconLeft: G.labs,
1600
+ iconRight: G.labs,
1601
+ onClick: ke,
1602
+ children: pe("labs").label
1833
1603
  })
1834
1604
  ]
1835
1605
  })]
@@ -1837,133 +1607,140 @@ function En({ onGenerate: e, onEffects: t, chromes: n }) {
1837
1607
  });
1838
1608
  }
1839
1609
  function Dn() {
1840
- let { layers: e, addLayer: n, removeLayer: r, updateLayer: i, canvasW: a, canvasH: o, aspect: s, setAspect: c } = p(), { setTool: l } = $e(), u = et() && !Ze(), d = () => "entry", [f, m] = J(d), [h, g] = J(!1), [_, v] = J(null), [y, b] = J("contain"), [x, C] = J(1), w = q({
1610
+ let { layers: e, addLayer: t, removeLayer: r, updateLayer: i, canvasW: a, canvasH: o, aspect: s, setAspect: c } = u(), { setTool: l } = Oe(), d = Me() && !Se(), f = nt(), p = () => "entry", [m, h] = X(p), [g, _] = X(!1), [v, y] = X(null), [b, S] = X("contain"), [C, te] = X(!1), [ne, w] = X(null), [E, O] = X(1), k = Y({
1841
1611
  pts: /* @__PURE__ */ new Map(),
1842
1612
  startDist: 0,
1843
1613
  startScale: 1
1844
- }), T = q(null), E = () => {
1845
- let [e, t] = [...w.current.pts.values()];
1614
+ }), A = Y(null), j = () => {
1615
+ let [e, t] = [...k.current.pts.values()];
1846
1616
  return Math.hypot(e.x - t.x, e.y - t.y);
1847
- }, D = (e) => {
1848
- w.current.pts.set(e.pointerId, {
1617
+ }, M = (e) => {
1618
+ k.current.pts.set(e.pointerId, {
1849
1619
  x: e.clientX,
1850
1620
  y: e.clientY
1851
- }), T.current = w.current.pts.size === 1 ? {
1621
+ }), A.current = k.current.pts.size === 1 ? {
1852
1622
  id: e.pointerId,
1853
1623
  x: e.clientX,
1854
1624
  y: e.clientY,
1855
1625
  t: performance.now()
1856
- } : null, w.current.pts.size === 2 && (w.current.startDist = E(), w.current.startScale = x, t.setStagePointer(null), e.stopPropagation());
1857
- }, O = (e) => {
1858
- let t = w.current;
1626
+ } : null, k.current.pts.size === 2 && (k.current.startDist = j(), k.current.startScale = E, n.setStagePointer(null), e.stopPropagation());
1627
+ }, N = (e) => {
1628
+ let t = k.current;
1859
1629
  t.pts.has(e.pointerId) && (t.pts.set(e.pointerId, {
1860
1630
  x: e.clientX,
1861
1631
  y: e.clientY
1862
- }), t.pts.size >= 2 && t.startDist > 0 && (e.stopPropagation(), C(Math.min(3, Math.max(.5, t.startScale * (E() / t.startDist))))));
1863
- }, A = (e) => {
1864
- let n = T.current;
1865
- if (n && n.id === e.pointerId && e.type === "pointerup" && f === "live" && performance.now() - n.t < 350 && Math.hypot(e.clientX - n.x, e.clientY - n.y) < 12 && M?.type === "loop") {
1866
- let e = k(M.loopId);
1867
- e && e.group !== "penrose" && e.kind !== "engine" && !te(e) && t.rewind();
1632
+ }), t.pts.size >= 2 && t.startDist > 0 && (e.stopPropagation(), O(Math.min(3, Math.max(.5, t.startScale * (j() / t.startDist))))));
1633
+ }, P = (e) => {
1634
+ let t = A.current;
1635
+ if (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 && F?.type === "loop") {
1636
+ let e = re(F.loopId);
1637
+ e && e.group !== "penrose" && e.kind !== "engine" && !T(e) && n.rewind();
1868
1638
  }
1869
- n?.id === e.pointerId && (T.current = null), w.current.pts.delete(e.pointerId), w.current.pts.size < 2 && (w.current.startDist = 0);
1639
+ t?.id === e.pointerId && (A.current = null), k.current.pts.delete(e.pointerId), k.current.pts.size < 2 && (k.current.startDist = 0);
1870
1640
  };
1871
- _t(), K(() => {
1641
+ Tt(), J(() => (st("randomiser"), () => st(null)), []), J(() => {
1872
1642
  c("4:5"), l("orbit");
1873
1643
  }, []);
1874
- let M = e.find((e) => e.id === _) ?? (e.length === 1 ? e[0] : null), N = f === "live" && M?.type === "photo" && !M.src && M.srcType !== "webcam";
1875
- K(() => {
1876
- if (!N) return;
1644
+ let F = e.find((e) => e.id === v) ?? (e.length === 1 ? e[0] : null), I = m === "live" && F?.type === "photo" && !F.src && F.srcType !== "webcam";
1645
+ J(() => {
1646
+ if (!I) return;
1877
1647
  let e = (e) => {
1878
- e.key === "Escape" && L();
1648
+ e.key === "Escape" && z();
1879
1649
  };
1880
1650
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
1881
- }), K(() => {
1882
- if (!N) return;
1883
- let e = t.isPlaying();
1884
- return t.pause(), () => {
1885
- e && t.play();
1651
+ }), J(() => {
1652
+ if (!I) return;
1653
+ let e = n.isPlaying();
1654
+ return n.pause(), () => {
1655
+ e && n.play();
1886
1656
  };
1887
- }, [N]);
1888
- let P = (e) => {
1889
- let r = j(e);
1890
- r && (v(n("loop", r)), t.play(), m("live"));
1891
- }, F = (e) => {
1892
- let t = j(e);
1893
- t && _ && i(_, t);
1894
- }, I = () => {
1895
- v(n("photo", {
1657
+ }, [I]);
1658
+ let L = (e) => {
1659
+ let r = D(e);
1660
+ r && (y(t("loop", r)), n.play(), h("live"));
1661
+ }, ie = (e) => {
1662
+ let t = D(e);
1663
+ t && v && i(v, t);
1664
+ }, R = () => {
1665
+ y(t("photo", {
1896
1666
  fit: "cover",
1897
1667
  x: 0,
1898
1668
  y: 0,
1899
- w: S,
1900
- h: Math.round(S * o / a)
1901
- })), t.play(), m("live");
1902
- }, ne = (e) => {
1669
+ w: x,
1670
+ h: Math.round(x * o / a)
1671
+ })), n.play(), h("live");
1672
+ }, ae = (e) => {
1903
1673
  if (e === "fill") {
1904
- b("cover");
1674
+ S("cover");
1905
1675
  return;
1906
1676
  }
1907
- b("contain"), c(e);
1677
+ S("contain"), c(e);
1908
1678
  let t = ee[e];
1909
- _ && t && i(_, {
1679
+ v && t && i(v, {
1910
1680
  x: 0,
1911
1681
  y: 0,
1912
- w: S,
1913
- h: Math.round(S * t.h / t.w)
1682
+ w: x,
1683
+ h: Math.round(x * t.h / t.w)
1914
1684
  });
1915
- }, L = () => {
1685
+ }, z = () => {
1916
1686
  for (let t of [...e]) r(t.id);
1917
- v(null), C(1), g(!1), m(d());
1687
+ y(null), O(1), _(!1), h(p());
1918
1688
  };
1919
- return /* @__PURE__ */ Z("div", {
1920
- className: "relative h-dvh bg-black",
1689
+ return /* @__PURE__ */ Q("div", {
1690
+ className: "kol-editor-randomiser relative h-dvh bg-black",
1921
1691
  children: [
1922
- /* @__PURE__ */ X("div", {
1923
- className: "absolute inset-0 touch-none",
1924
- style: { transform: `scale(${x})` },
1925
- onPointerDownCapture: D,
1926
- onPointerMoveCapture: O,
1927
- onPointerUpCapture: A,
1928
- onPointerCancelCapture: A,
1929
- onPointerLeave: A,
1930
- children: /* @__PURE__ */ X(Ve, { fit: y })
1692
+ /* @__PURE__ */ Z("div", {
1693
+ className: "absolute inset-y-0 left-0 touch-none overflow-hidden",
1694
+ style: {
1695
+ transform: `scale(${E})`,
1696
+ right: C ? "var(--kol-sidenav-w, 320px)" : 0,
1697
+ bottom: ne ?? 0
1698
+ },
1699
+ onPointerDownCapture: M,
1700
+ onPointerMoveCapture: N,
1701
+ onPointerUpCapture: P,
1702
+ onPointerCancelCapture: P,
1703
+ onPointerLeave: P,
1704
+ children: /* @__PURE__ */ Z(et, { fit: b })
1931
1705
  }),
1932
- f === "entry" && /* @__PURE__ */ X(En, {
1933
- chromes: u,
1934
- onGenerate: () => m("category"),
1706
+ m === "entry" && /* @__PURE__ */ Z(En, {
1707
+ chromes: d,
1708
+ onGenerate: () => h("category"),
1935
1709
  onEffects: () => {
1936
- g(!0), I();
1710
+ _(!0), R();
1937
1711
  }
1938
1712
  }),
1939
- f === "category" && /* @__PURE__ */ X(dn, {
1940
- onPick: P,
1941
- onInsert: I,
1942
- onBack: () => m("entry")
1713
+ m === "category" && /* @__PURE__ */ Z(ye, {
1714
+ onPick: L,
1715
+ onInsert: R,
1716
+ onBack: () => h("entry")
1943
1717
  }),
1944
- f === "live" && /* @__PURE__ */ X(Tn, {
1945
- layer: M,
1946
- onSwitchCategory: F,
1718
+ m === "live" && !I && /* @__PURE__ */ Z(Tn, {
1719
+ layer: F,
1720
+ onSwitchCategory: ie,
1947
1721
  onInsert: () => {
1948
- L(), I();
1722
+ z(), R();
1949
1723
  },
1950
- onRestart: L,
1951
- aspectValue: y === "cover" ? "fill" : s,
1952
- openEffects: h && !N,
1953
- onAspect: ne
1724
+ onRestart: z,
1725
+ aspectValue: b === "cover" ? "fill" : s,
1726
+ openEffects: g && !I,
1727
+ onAspect: ae,
1728
+ rail: !d && !f,
1729
+ onRail: te,
1730
+ onSheet: w
1954
1731
  }),
1955
- N && /* @__PURE__ */ Z("div", {
1732
+ I && /* @__PURE__ */ Q("div", {
1956
1733
  className: "fixed inset-y-0 right-0 left-[var(--fxr-rail,0px)] kol-overlay-scrim flex flex-col",
1957
1734
  style: { zIndex: "var(--kol-z-modal)" },
1958
- children: [/* @__PURE__ */ X("div", {
1735
+ children: [/* @__PURE__ */ Z("div", {
1959
1736
  className: "flex-1 min-h-0",
1960
- children: /* @__PURE__ */ X(At, { layer: M })
1961
- }), /* @__PURE__ */ X("div", {
1737
+ children: /* @__PURE__ */ Z(Bt, { layer: F })
1738
+ }), /* @__PURE__ */ Z("div", {
1962
1739
  className: "flex justify-center pb-[max(0.75rem,env(safe-area-inset-bottom))]",
1963
- children: /* @__PURE__ */ X(H, {
1964
- variant: "outline",
1740
+ children: /* @__PURE__ */ Z(K, {
1741
+ tone: "outline",
1965
1742
  size: "lg",
1966
- onClick: L,
1743
+ onClick: z,
1967
1744
  children: "Back"
1968
1745
  })
1969
1746
  })]
@@ -1972,10 +1749,10 @@ function Dn() {
1972
1749
  });
1973
1750
  }
1974
1751
  function On() {
1975
- return /* @__PURE__ */ X(Qe, {
1752
+ return /* @__PURE__ */ Z(Ve, {
1976
1753
  persistDraft: !1,
1977
- children: /* @__PURE__ */ X(Dn, {})
1754
+ children: /* @__PURE__ */ Z(Dn, {})
1978
1755
  });
1979
1756
  }
1980
1757
  //#endregion
1981
- export { Ke as AppSettingsSections, _e as BRAND, nt as DesignEditor, nt as default, De as DisplaySettingsDrawer, Qe as EditorProviders, je as FilesDialog, Ie as GeneratorLibraryProvider, sn as LABS_DRAFT_KEY, Se as LIBRARY_SLOT_KEYS, cn as LabsView, ve as MODES, On as MobileView, rt as OutputCanvas, Ve as OutputStage, He as OutputView, tt as RAIL_EXTRA_PREFIX, at as VIEW_PATHS, xe as closeFiles, Ce as comboLabel, Ne as currentView, et as isMobileDevice, we as openFiles, o as registerPack, st as setMediaClient, ze as setMediaProxyBase, ke as setMode, qe as setNavigator, Be as setRailExtras, c as setSettingsStore, Re as setWantsDesktop, Pe as shortcutsBySection, Ee as useFilesDialog, Te as useGeneratorLibrary, Je as useRailExtras, Oe as useSettingsSections, Ze as wantsDesktop, ge as withView };
1758
+ export { lt as AppSettingsSections, _e as BRAND, ot as DesignEditor, ot as default, ft as DisplaySettingsDrawer, Ve as EditorProviders, je as FilesDialog, Je as GeneratorLibraryProvider, ln as LABS_DRAFT_KEY, Te as LIBRARY_SLOT_KEYS, un as LabsView, Ie as MODES, On as MobileView, ze as OutputCanvas, et as OutputStage, at as OutputView, Qe as RAIL_EXTRA_PREFIX, Fe as VIEW_PATHS, Ae as closeFiles, Ye as comboLabel, Le as currentView, Me as isMobileDevice, ge as openFiles, f as registerPack, Ze as setMediaClient, Ke as setMediaProxyBase, Ue as setMode, $e as setNavigator, rt as setRailExtras, a as setSettingsStore, be as setWantsDesktop, me as shortcutsBySection, ut as useFilesDialog, Ee as useGeneratorLibrary, qe as useRailExtras, Be as useSettingsSections, Se as wantsDesktop, it as withView };