@kolkrabbi/design-editor 0.32.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Timeline-BKYyRqYg.js → Timeline-Cz-W72D0.js} +1 -1
- package/dist/{core-Cs-PEiuU.js → core-BeMuE9nC.js} +2376 -2355
- package/dist/core.js +3 -3
- package/dist/design-editor.css +1 -1
- package/dist/design-editor.js +52 -38
- package/dist/{effectCategories-BGIW_dEc.js → effectCategories-DV7i_AgK.js} +1 -1
- package/dist/{effects-RqPdJrRb.js → effects-Dn4_OzYx.js} +19 -17
- package/dist/effects.js +1 -1
- package/dist/{generators-BnuRmK-x.js → generators-XBzHN_kX.js} +34 -33
- package/dist/generators.js +1 -1
- package/dist/{host-DJ8bDKO7.js → host-B4QQewPr.js} +2 -2
- package/dist/{motion-DKZGyk14.js → motion-Cuwxm2ic.js} +25 -21
- package/dist/motion.js +1 -1
- package/dist/{store-D6Si8cRD.js → store-CF9s1Pb2.js} +417 -416
- package/dist/{useLayerEdit-BF9wI5pX.js → useLayerEdit-Cmtx3V3O.js} +20 -18
- package/package.json +11 -11
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Bn as e, Cn as t, D as n, J as r, L as i, Rt as a, Sn as o, _ as s, b as c, bn as l, f as u, g as ee, h as d, m as f, p, pn as m, v as h, vn as g, wn as _, x as te, y as ne } from "./rolls-CEQmdcp3.js";
|
|
2
|
-
import { Button as v,
|
|
3
|
-
import { createContext as
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import {
|
|
2
|
+
import { Button as v, ButtonGroup as re, CloseButton as y, ColorPickerPopover as ie, Dropdown as b, FullscreenOverlay as x, FunctionPlot as S, Input as C, LabeledControl as w, MenuDropdownItem as T, Section as E, Slider as D, Stepper as ae, Tooltip as O } from "@kolkrabbi/kol-component";
|
|
3
|
+
import { createContext as k, useCallback as A, useContext as oe, useEffect as j, useMemo as se, useRef as M, useState as N, useSyncExternalStore as P } from "react";
|
|
4
|
+
import { Fragment as ce, jsx as F, jsxs as I } from "react/jsx-runtime";
|
|
5
|
+
import { IconLoader as le } from "@kolkrabbi/kol-icons";
|
|
6
6
|
//#region src/editor/params/ModulationEditor.jsx
|
|
7
|
-
var
|
|
7
|
+
var ue = [
|
|
8
8
|
{
|
|
9
9
|
code: "wave(t*2)",
|
|
10
10
|
desc: "Fast sine"
|
|
@@ -37,95 +37,96 @@ var fe = [
|
|
|
37
37
|
code: "rand()",
|
|
38
38
|
desc: "Noise"
|
|
39
39
|
}
|
|
40
|
-
],
|
|
41
|
-
function
|
|
42
|
-
let [t, n] =
|
|
43
|
-
|
|
40
|
+
], de = 196, L = 64;
|
|
41
|
+
function R({ expr: e }) {
|
|
42
|
+
let [t, n] = N(0);
|
|
43
|
+
j(() => {
|
|
44
44
|
let e = 0, t = () => {
|
|
45
45
|
n(m.getCtx().t ?? 0), e = requestAnimationFrame(t);
|
|
46
46
|
};
|
|
47
47
|
return e = requestAnimationFrame(t), () => cancelAnimationFrame(e);
|
|
48
48
|
}, []);
|
|
49
|
-
let r = l(e), i = m.getLoopSeconds(), a =
|
|
50
|
-
return /* @__PURE__ */
|
|
49
|
+
let r = l(e), i = m.getLoopSeconds(), a = de, o = Array.from({ length: 197 }, (e, t) => r.ok ? r.fn(t / a * i) : 0);
|
|
50
|
+
return /* @__PURE__ */ F(S, {
|
|
51
51
|
samples: o,
|
|
52
52
|
min: Math.min(0, ...o),
|
|
53
53
|
max: Math.max(1, ...o),
|
|
54
54
|
cursor: t,
|
|
55
|
-
height:
|
|
55
|
+
height: L,
|
|
56
56
|
ariaLabel: "Expression plot over one loop"
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
let s = i(), c = e[r.key], [l, u] =
|
|
59
|
+
function fe({ layer: e, param: r, setProp: a }) {
|
|
60
|
+
let s = i(), c = e[r.key], [l, u] = N(null), [ee, d] = N(!1), [f, p] = N(!1);
|
|
61
61
|
if (!n(c) || c.bind !== "mod") return null;
|
|
62
|
-
let m = c.source, h = c.transform ?? {}, te = m.startsWith("lfo-"), ne = m === "midi",
|
|
62
|
+
let m = c.source, h = c.transform ?? {}, te = m.startsWith("lfo-"), ne = m === "midi", y = o(m), ie = m === "expr", b = h.expr ?? "wave(t)", x = (e) => a(r.key, {
|
|
63
63
|
...c,
|
|
64
64
|
transform: {
|
|
65
65
|
...h,
|
|
66
66
|
...e
|
|
67
67
|
}
|
|
68
|
-
}),
|
|
68
|
+
}), S = (e) => {
|
|
69
69
|
u(null);
|
|
70
70
|
let t = String(e).trim();
|
|
71
|
-
t && t !==
|
|
72
|
-
},
|
|
71
|
+
t && t !== b && x({ expr: t });
|
|
72
|
+
}, E = async () => {
|
|
73
73
|
d(!0);
|
|
74
74
|
let e = await _();
|
|
75
|
-
d(!1), e != null &&
|
|
76
|
-
},
|
|
75
|
+
d(!1), e != null && x({ cc: e });
|
|
76
|
+
}, ae = async () => {
|
|
77
77
|
p(!0);
|
|
78
78
|
let e = await t();
|
|
79
79
|
p(!1), e && a(r.key, {
|
|
80
80
|
...c,
|
|
81
81
|
source: e
|
|
82
82
|
});
|
|
83
|
-
},
|
|
83
|
+
}, O = h.range ?? (r.min != null && r.max != null ? [r.min, r.max] : [0, 1]), k = (e, t) => {
|
|
84
84
|
let n = Number(e);
|
|
85
85
|
return Number.isFinite(n) ? n : t;
|
|
86
86
|
};
|
|
87
|
-
return /* @__PURE__ */
|
|
87
|
+
return /* @__PURE__ */ I("div", {
|
|
88
88
|
className: "flex flex-col gap-3",
|
|
89
89
|
children: [
|
|
90
|
-
/* @__PURE__ */
|
|
90
|
+
/* @__PURE__ */ F(w, {
|
|
91
91
|
label: "Range",
|
|
92
|
-
children: /* @__PURE__ */
|
|
92
|
+
children: /* @__PURE__ */ I("div", {
|
|
93
93
|
className: "flex items-center gap-2 min-w-0",
|
|
94
94
|
children: [
|
|
95
|
-
/* @__PURE__ */
|
|
95
|
+
/* @__PURE__ */ F("div", {
|
|
96
96
|
className: "flex-1 min-w-0",
|
|
97
|
-
children: /* @__PURE__ */
|
|
97
|
+
children: /* @__PURE__ */ F(C, {
|
|
98
98
|
variant: "filled",
|
|
99
99
|
size: s,
|
|
100
100
|
type: "number",
|
|
101
101
|
width: "100%",
|
|
102
|
-
value:
|
|
103
|
-
onChange: (e) =>
|
|
102
|
+
value: O[0],
|
|
103
|
+
onChange: (e) => x({ range: [k(e.target.value, O[0]), O[1]] })
|
|
104
104
|
})
|
|
105
105
|
}),
|
|
106
|
-
/* @__PURE__ */
|
|
106
|
+
/* @__PURE__ */ F("span", {
|
|
107
107
|
className: "kol-helper-10 text-meta shrink-0",
|
|
108
108
|
children: "to"
|
|
109
109
|
}),
|
|
110
|
-
/* @__PURE__ */
|
|
110
|
+
/* @__PURE__ */ F("div", {
|
|
111
111
|
className: "flex-1 min-w-0",
|
|
112
|
-
children: /* @__PURE__ */
|
|
112
|
+
children: /* @__PURE__ */ F(C, {
|
|
113
113
|
variant: "filled",
|
|
114
114
|
size: s,
|
|
115
115
|
type: "number",
|
|
116
116
|
width: "100%",
|
|
117
|
-
value:
|
|
118
|
-
onChange: (e) =>
|
|
117
|
+
value: O[1],
|
|
118
|
+
onChange: (e) => x({ range: [O[0], k(e.target.value, O[1])] })
|
|
119
119
|
})
|
|
120
120
|
})
|
|
121
121
|
]
|
|
122
122
|
})
|
|
123
123
|
}),
|
|
124
|
-
/* @__PURE__ */
|
|
124
|
+
/* @__PURE__ */ I("div", {
|
|
125
125
|
className: "grid grid-cols-2 gap-2",
|
|
126
|
-
children: [/* @__PURE__ */
|
|
126
|
+
children: [/* @__PURE__ */ F(w, {
|
|
127
127
|
label: "Invert",
|
|
128
|
-
children: /* @__PURE__ */
|
|
128
|
+
children: /* @__PURE__ */ F(re, {
|
|
129
|
+
layout: "joined",
|
|
129
130
|
size: s,
|
|
130
131
|
className: "w-full",
|
|
131
132
|
options: [{
|
|
@@ -136,72 +137,72 @@ function me({ layer: e, param: r, setProp: a }) {
|
|
|
136
137
|
label: "On"
|
|
137
138
|
}],
|
|
138
139
|
value: h?.invert ? "on" : "off",
|
|
139
|
-
onChange: (e) =>
|
|
140
|
+
onChange: (e) => x({ invert: e === "on" })
|
|
140
141
|
})
|
|
141
|
-
}), /* @__PURE__ */
|
|
142
|
+
}), /* @__PURE__ */ F(w, {
|
|
142
143
|
label: "Smooth",
|
|
143
|
-
children: /* @__PURE__ */
|
|
144
|
+
children: /* @__PURE__ */ F(D, {
|
|
144
145
|
min: 0,
|
|
145
146
|
max: .95,
|
|
146
147
|
step: .05,
|
|
147
148
|
value: h?.smooth ?? 0,
|
|
148
|
-
onChange: (e) =>
|
|
149
|
+
onChange: (e) => x({ smooth: e })
|
|
149
150
|
})
|
|
150
151
|
})]
|
|
151
152
|
}),
|
|
152
|
-
/* @__PURE__ */
|
|
153
|
+
/* @__PURE__ */ F(w, {
|
|
153
154
|
label: "Curve",
|
|
154
|
-
children: /* @__PURE__ */
|
|
155
|
+
children: /* @__PURE__ */ F(D, {
|
|
155
156
|
min: .25,
|
|
156
157
|
max: 4,
|
|
157
158
|
step: .05,
|
|
158
159
|
value: h?.curve ?? 1,
|
|
159
|
-
onChange: (e) =>
|
|
160
|
+
onChange: (e) => x({ curve: e })
|
|
160
161
|
})
|
|
161
162
|
}),
|
|
162
|
-
te && /* @__PURE__ */
|
|
163
|
+
te && /* @__PURE__ */ I("div", {
|
|
163
164
|
className: "grid grid-cols-2 gap-2",
|
|
164
|
-
children: [/* @__PURE__ */
|
|
165
|
+
children: [/* @__PURE__ */ F(w, {
|
|
165
166
|
label: "Rate",
|
|
166
|
-
children: /* @__PURE__ */
|
|
167
|
+
children: /* @__PURE__ */ F(D, {
|
|
167
168
|
min: .25,
|
|
168
169
|
max: 16,
|
|
169
170
|
step: .25,
|
|
170
171
|
value: h?.rate ?? 1,
|
|
171
|
-
onChange: (e) =>
|
|
172
|
+
onChange: (e) => x({ rate: e })
|
|
172
173
|
})
|
|
173
|
-
}), /* @__PURE__ */
|
|
174
|
+
}), /* @__PURE__ */ F(w, {
|
|
174
175
|
label: "Phase",
|
|
175
|
-
children: /* @__PURE__ */
|
|
176
|
+
children: /* @__PURE__ */ F(D, {
|
|
176
177
|
min: 0,
|
|
177
178
|
max: 1,
|
|
178
179
|
step: .01,
|
|
179
180
|
value: h?.phase ?? 0,
|
|
180
|
-
onChange: (e) =>
|
|
181
|
+
onChange: (e) => x({ phase: e })
|
|
181
182
|
})
|
|
182
183
|
})]
|
|
183
184
|
}),
|
|
184
|
-
ie && /* @__PURE__ */
|
|
185
|
-
/* @__PURE__ */
|
|
185
|
+
ie && /* @__PURE__ */ I(ce, { children: [
|
|
186
|
+
/* @__PURE__ */ F(w, {
|
|
186
187
|
label: "Expression",
|
|
187
|
-
children: /* @__PURE__ */
|
|
188
|
+
children: /* @__PURE__ */ F(C, {
|
|
188
189
|
variant: "ghost",
|
|
189
190
|
size: s,
|
|
190
|
-
value: l ??
|
|
191
|
+
value: l ?? b,
|
|
191
192
|
onChange: (e) => u(e.target.value),
|
|
192
|
-
onBlur: (e) =>
|
|
193
|
+
onBlur: (e) => S(e.target.value),
|
|
193
194
|
onKeyDown: (e) => {
|
|
194
195
|
e.key === "Enter" && e.currentTarget.blur();
|
|
195
196
|
}
|
|
196
197
|
})
|
|
197
198
|
}),
|
|
198
|
-
/* @__PURE__ */
|
|
199
|
-
/* @__PURE__ */
|
|
199
|
+
/* @__PURE__ */ F(R, { expr: b }),
|
|
200
|
+
/* @__PURE__ */ F("div", {
|
|
200
201
|
className: "flex flex-col",
|
|
201
|
-
children:
|
|
202
|
-
onClick: () =>
|
|
202
|
+
children: ue.map((e) => /* @__PURE__ */ F(T, {
|
|
203
|
+
onClick: () => x({ expr: e.code }),
|
|
203
204
|
rowClass: "kol-mono-10 h-6",
|
|
204
|
-
shortcut: /* @__PURE__ */
|
|
205
|
+
shortcut: /* @__PURE__ */ F("span", {
|
|
205
206
|
className: "kol-helper-10 text-meta",
|
|
206
207
|
children: e.desc
|
|
207
208
|
}),
|
|
@@ -209,51 +210,51 @@ function me({ layer: e, param: r, setProp: a }) {
|
|
|
209
210
|
}, e.code))
|
|
210
211
|
})
|
|
211
212
|
] }),
|
|
212
|
-
ne && /* @__PURE__ */
|
|
213
|
+
ne && /* @__PURE__ */ F(w, {
|
|
213
214
|
label: h?.cc == null ? "MIDI · no CC yet" : `MIDI · CC ${h.cc}`,
|
|
214
|
-
children: /* @__PURE__ */
|
|
215
|
+
children: /* @__PURE__ */ F(v, {
|
|
215
216
|
tone: "outline",
|
|
216
217
|
size: s,
|
|
217
|
-
onClick:
|
|
218
|
+
onClick: E,
|
|
218
219
|
children: ee ? "Move a knob…" : "Learn"
|
|
219
220
|
})
|
|
220
221
|
}),
|
|
221
|
-
|
|
222
|
+
y && /* @__PURE__ */ F(w, {
|
|
222
223
|
label: g(m)?.label ?? "Gamepad",
|
|
223
|
-
children: /* @__PURE__ */
|
|
224
|
+
children: /* @__PURE__ */ F(v, {
|
|
224
225
|
tone: "outline",
|
|
225
226
|
size: s,
|
|
226
|
-
onClick:
|
|
227
|
+
onClick: ae,
|
|
227
228
|
children: f ? "Move a control…" : "Learn"
|
|
228
229
|
})
|
|
229
230
|
})
|
|
230
231
|
]
|
|
231
232
|
});
|
|
232
233
|
}
|
|
233
|
-
function
|
|
234
|
+
function pe({ layer: e, schema: t, setProp: r }) {
|
|
234
235
|
let i = (t ?? []).filter((t) => {
|
|
235
236
|
let r = e[t.key];
|
|
236
237
|
return n(r) && r.bind === "mod";
|
|
237
238
|
});
|
|
238
|
-
return i.length === 0 ? null : /* @__PURE__ */
|
|
239
|
+
return i.length === 0 ? null : /* @__PURE__ */ I("div", {
|
|
239
240
|
className: "flex flex-col gap-4",
|
|
240
|
-
children: [/* @__PURE__ */
|
|
241
|
+
children: [/* @__PURE__ */ F("span", {
|
|
241
242
|
className: "kol-eyebrow text-fg-80",
|
|
242
243
|
children: "Modulation"
|
|
243
244
|
}), i.map((t) => {
|
|
244
245
|
let n = g(e[t.key].source);
|
|
245
|
-
return /* @__PURE__ */
|
|
246
|
+
return /* @__PURE__ */ I("div", {
|
|
246
247
|
className: "flex flex-col gap-2 pt-3 border-t border-oq-08",
|
|
247
|
-
children: [/* @__PURE__ */
|
|
248
|
+
children: [/* @__PURE__ */ I("div", {
|
|
248
249
|
className: "flex items-center justify-between",
|
|
249
|
-
children: [/* @__PURE__ */
|
|
250
|
+
children: [/* @__PURE__ */ F("span", {
|
|
250
251
|
className: "kol-helper-12 text-emphasis",
|
|
251
252
|
children: t.label ?? t.key
|
|
252
|
-
}), /* @__PURE__ */
|
|
253
|
+
}), /* @__PURE__ */ F("span", {
|
|
253
254
|
className: "kol-helper-10 text-meta",
|
|
254
255
|
children: n?.label ?? e[t.key].source
|
|
255
256
|
})]
|
|
256
|
-
}), /* @__PURE__ */
|
|
257
|
+
}), /* @__PURE__ */ F(fe, {
|
|
257
258
|
layer: e,
|
|
258
259
|
param: t,
|
|
259
260
|
setProp: r
|
|
@@ -264,7 +265,7 @@ function L({ layer: e, schema: t, setProp: r }) {
|
|
|
264
265
|
}
|
|
265
266
|
//#endregion
|
|
266
267
|
//#region src/editor/modes/pattern/RuleRow.jsx
|
|
267
|
-
var
|
|
268
|
+
var me = [
|
|
268
269
|
{
|
|
269
270
|
value: "all",
|
|
270
271
|
label: "All cells"
|
|
@@ -293,7 +294,7 @@ var he = [
|
|
|
293
294
|
value: "expression",
|
|
294
295
|
label: "Expression…"
|
|
295
296
|
}
|
|
296
|
-
],
|
|
297
|
+
], z = [
|
|
297
298
|
{
|
|
298
299
|
value: 0,
|
|
299
300
|
label: "0°"
|
|
@@ -310,19 +311,19 @@ var he = [
|
|
|
310
311
|
value: 270,
|
|
311
312
|
label: "270°"
|
|
312
313
|
}
|
|
313
|
-
],
|
|
314
|
+
], B = [
|
|
314
315
|
"every-col",
|
|
315
316
|
"every-row",
|
|
316
317
|
"both",
|
|
317
318
|
"every-nth",
|
|
318
319
|
"checker"
|
|
319
|
-
],
|
|
320
|
+
], he = [
|
|
320
321
|
0,
|
|
321
322
|
90,
|
|
322
323
|
180,
|
|
323
324
|
270
|
|
324
|
-
],
|
|
325
|
-
id:
|
|
325
|
+
], ge = 1, _e = () => `r${ge++}`, ve = () => ({
|
|
326
|
+
id: _e(),
|
|
326
327
|
selectKind: "every-col",
|
|
327
328
|
n: 2,
|
|
328
329
|
offset: 0,
|
|
@@ -336,9 +337,9 @@ var he = [
|
|
|
336
337
|
flipV: !1,
|
|
337
338
|
hide: !1,
|
|
338
339
|
opacity: 1
|
|
339
|
-
}),
|
|
340
|
-
id:
|
|
341
|
-
selectKind:
|
|
340
|
+
}), ye = (e) => e[Math.floor(Math.random() * e.length)], be = () => ({
|
|
341
|
+
id: _e(),
|
|
342
|
+
selectKind: ye(B),
|
|
342
343
|
n: Math.floor(Math.random() * 5) + 2,
|
|
343
344
|
offset: Math.floor(Math.random() * 3),
|
|
344
345
|
n2: Math.floor(Math.random() * 5) + 2,
|
|
@@ -346,14 +347,14 @@ var he = [
|
|
|
346
347
|
expression: "sin(col * 0.6) + cos(row * 0.6)",
|
|
347
348
|
groupW: Math.random() > .6 ? Math.floor(Math.random() * 3) + 1 : 1,
|
|
348
349
|
groupH: Math.random() > .6 ? Math.floor(Math.random() * 3) + 1 : 1,
|
|
349
|
-
rotate:
|
|
350
|
+
rotate: ye(he),
|
|
350
351
|
flipH: Math.random() > .6,
|
|
351
352
|
flipV: Math.random() > .6,
|
|
352
353
|
hide: Math.random() > .85,
|
|
353
354
|
opacity: Math.random() > .7 ? .4 + Math.random() * .6 : 1
|
|
354
355
|
});
|
|
355
|
-
function
|
|
356
|
-
return /* @__PURE__ */
|
|
356
|
+
function V({ value: e, onChange: t, min: n = 0, max: r = 99 }) {
|
|
357
|
+
return /* @__PURE__ */ F(ae, {
|
|
357
358
|
size: "sm",
|
|
358
359
|
value: e,
|
|
359
360
|
min: n,
|
|
@@ -362,10 +363,10 @@ function B({ value: e, onChange: t, min: n = 0, max: r = 99 }) {
|
|
|
362
363
|
className: "w-full"
|
|
363
364
|
});
|
|
364
365
|
}
|
|
365
|
-
function
|
|
366
|
-
return /* @__PURE__ */
|
|
366
|
+
function xe({ active: e, onClick: t, children: n, title: r }) {
|
|
367
|
+
return /* @__PURE__ */ F(O, {
|
|
367
368
|
label: r,
|
|
368
|
-
children: /* @__PURE__ */
|
|
369
|
+
children: /* @__PURE__ */ F(v, {
|
|
369
370
|
"aria-label": r,
|
|
370
371
|
tone: e ? "primary" : "outline",
|
|
371
372
|
size: "sm",
|
|
@@ -375,31 +376,31 @@ function Se({ active: e, onClick: t, children: n, title: r }) {
|
|
|
375
376
|
})
|
|
376
377
|
});
|
|
377
378
|
}
|
|
378
|
-
function
|
|
379
|
+
function Se({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
379
380
|
let i = (n) => t({
|
|
380
381
|
...e,
|
|
381
382
|
...n
|
|
382
383
|
}), a = e.selectKind === "every-col" || e.selectKind === "every-row" || e.selectKind === "every-nth" || e.selectKind === "both", o = e.selectKind === "both", s = e.selectKind === "expression";
|
|
383
|
-
return /* @__PURE__ */
|
|
384
|
+
return /* @__PURE__ */ I("div", {
|
|
384
385
|
className: "flex flex-col gap-2 p-2 border border-oq-08 rounded",
|
|
385
386
|
children: [
|
|
386
|
-
/* @__PURE__ */
|
|
387
|
+
/* @__PURE__ */ I("div", {
|
|
387
388
|
className: "flex items-center gap-2",
|
|
388
389
|
children: [
|
|
389
|
-
/* @__PURE__ */
|
|
390
|
+
/* @__PURE__ */ F("div", {
|
|
390
391
|
className: "flex-1 min-w-0",
|
|
391
|
-
children: /* @__PURE__ */
|
|
392
|
+
children: /* @__PURE__ */ F(b, {
|
|
392
393
|
variant: "subtle",
|
|
393
394
|
size: "sm",
|
|
394
395
|
className: "w-full",
|
|
395
|
-
options:
|
|
396
|
+
options: me,
|
|
396
397
|
value: e.selectKind,
|
|
397
398
|
onChange: (e) => i({ selectKind: e })
|
|
398
399
|
})
|
|
399
400
|
}),
|
|
400
|
-
/* @__PURE__ */
|
|
401
|
+
/* @__PURE__ */ F(O, {
|
|
401
402
|
label: "Re-randomize this rule",
|
|
402
|
-
children: /* @__PURE__ */
|
|
403
|
+
children: /* @__PURE__ */ F(v, {
|
|
403
404
|
tone: "ghost",
|
|
404
405
|
size: "sm",
|
|
405
406
|
iconOnly: "refresh",
|
|
@@ -410,9 +411,9 @@ function Ce({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
410
411
|
style: { padding: 6 }
|
|
411
412
|
})
|
|
412
413
|
}),
|
|
413
|
-
/* @__PURE__ */
|
|
414
|
+
/* @__PURE__ */ F(O, {
|
|
414
415
|
label: "Delete rule",
|
|
415
|
-
children: /* @__PURE__ */
|
|
416
|
+
children: /* @__PURE__ */ F(v, {
|
|
416
417
|
tone: "ghost",
|
|
417
418
|
size: "sm",
|
|
418
419
|
iconOnly: "x",
|
|
@@ -425,95 +426,95 @@ function Ce({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
425
426
|
})
|
|
426
427
|
]
|
|
427
428
|
}),
|
|
428
|
-
a && /* @__PURE__ */
|
|
429
|
+
a && /* @__PURE__ */ I("div", {
|
|
429
430
|
className: "grid grid-cols-2 gap-2",
|
|
430
|
-
children: [/* @__PURE__ */
|
|
431
|
+
children: [/* @__PURE__ */ F(E, {
|
|
431
432
|
label: "N",
|
|
432
|
-
children: /* @__PURE__ */
|
|
433
|
+
children: /* @__PURE__ */ F(V, {
|
|
433
434
|
value: e.n,
|
|
434
435
|
onChange: (e) => i({ n: e }),
|
|
435
436
|
min: 1
|
|
436
437
|
})
|
|
437
|
-
}), /* @__PURE__ */
|
|
438
|
+
}), /* @__PURE__ */ F(E, {
|
|
438
439
|
label: "Offset",
|
|
439
|
-
children: /* @__PURE__ */
|
|
440
|
+
children: /* @__PURE__ */ F(V, {
|
|
440
441
|
value: e.offset,
|
|
441
442
|
onChange: (e) => i({ offset: e })
|
|
442
443
|
})
|
|
443
444
|
})]
|
|
444
445
|
}),
|
|
445
|
-
o && /* @__PURE__ */
|
|
446
|
+
o && /* @__PURE__ */ I("div", {
|
|
446
447
|
className: "grid grid-cols-2 gap-2",
|
|
447
|
-
children: [/* @__PURE__ */
|
|
448
|
+
children: [/* @__PURE__ */ F(E, {
|
|
448
449
|
label: "Row N",
|
|
449
|
-
children: /* @__PURE__ */
|
|
450
|
+
children: /* @__PURE__ */ F(V, {
|
|
450
451
|
value: e.n2,
|
|
451
452
|
onChange: (e) => i({ n2: e }),
|
|
452
453
|
min: 1
|
|
453
454
|
})
|
|
454
|
-
}), /* @__PURE__ */
|
|
455
|
+
}), /* @__PURE__ */ F(E, {
|
|
455
456
|
label: "Row offset",
|
|
456
|
-
children: /* @__PURE__ */
|
|
457
|
+
children: /* @__PURE__ */ F(V, {
|
|
457
458
|
value: e.offset2,
|
|
458
459
|
onChange: (e) => i({ offset2: e })
|
|
459
460
|
})
|
|
460
461
|
})]
|
|
461
462
|
}),
|
|
462
|
-
s && /* @__PURE__ */
|
|
463
|
+
s && /* @__PURE__ */ I(E, {
|
|
463
464
|
label: "Expression",
|
|
464
465
|
hint: "matches when > 0",
|
|
465
|
-
children: [/* @__PURE__ */
|
|
466
|
+
children: [/* @__PURE__ */ F(C, {
|
|
466
467
|
variant: "filled",
|
|
467
468
|
size: "sm",
|
|
468
469
|
value: e.expression,
|
|
469
470
|
onChange: (e) => i({ expression: e.target.value }),
|
|
470
471
|
placeholder: "sin(col * 0.6) + cos(row * 0.6)"
|
|
471
|
-
}), /* @__PURE__ */
|
|
472
|
+
}), /* @__PURE__ */ F("span", {
|
|
472
473
|
className: "kol-mono-10 text-subtle mt-1",
|
|
473
474
|
children: "vars: i, col, row, cols, rows · Math.* in scope"
|
|
474
475
|
})]
|
|
475
476
|
}),
|
|
476
|
-
/* @__PURE__ */
|
|
477
|
+
/* @__PURE__ */ I("div", {
|
|
477
478
|
className: "grid grid-cols-2 gap-2",
|
|
478
|
-
children: [/* @__PURE__ */
|
|
479
|
+
children: [/* @__PURE__ */ F(E, {
|
|
479
480
|
label: "Group W",
|
|
480
|
-
children: /* @__PURE__ */
|
|
481
|
+
children: /* @__PURE__ */ F(V, {
|
|
481
482
|
value: e.groupW,
|
|
482
483
|
onChange: (e) => i({ groupW: Math.max(1, e) }),
|
|
483
484
|
min: 1
|
|
484
485
|
})
|
|
485
|
-
}), /* @__PURE__ */
|
|
486
|
+
}), /* @__PURE__ */ F(E, {
|
|
486
487
|
label: "Group H",
|
|
487
|
-
children: /* @__PURE__ */
|
|
488
|
+
children: /* @__PURE__ */ F(V, {
|
|
488
489
|
value: e.groupH,
|
|
489
490
|
onChange: (e) => i({ groupH: Math.max(1, e) }),
|
|
490
491
|
min: 1
|
|
491
492
|
})
|
|
492
493
|
})]
|
|
493
494
|
}),
|
|
494
|
-
/* @__PURE__ */
|
|
495
|
+
/* @__PURE__ */ I("div", {
|
|
495
496
|
className: "flex flex-wrap gap-1",
|
|
496
497
|
children: [
|
|
497
|
-
/* @__PURE__ */
|
|
498
|
+
/* @__PURE__ */ F(b, {
|
|
498
499
|
variant: "subtle",
|
|
499
500
|
size: "sm",
|
|
500
|
-
options:
|
|
501
|
+
options: z,
|
|
501
502
|
value: e.rotate,
|
|
502
503
|
onChange: (e) => i({ rotate: Number(e) })
|
|
503
504
|
}),
|
|
504
|
-
/* @__PURE__ */
|
|
505
|
+
/* @__PURE__ */ F(xe, {
|
|
505
506
|
active: e.flipH,
|
|
506
507
|
onClick: () => i({ flipH: !e.flipH }),
|
|
507
508
|
title: "Flip horizontal",
|
|
508
509
|
children: "⇋"
|
|
509
510
|
}),
|
|
510
|
-
/* @__PURE__ */
|
|
511
|
+
/* @__PURE__ */ F(xe, {
|
|
511
512
|
active: e.flipV,
|
|
512
513
|
onClick: () => i({ flipV: !e.flipV }),
|
|
513
514
|
title: "Flip vertical",
|
|
514
515
|
children: "⇵"
|
|
515
516
|
}),
|
|
516
|
-
/* @__PURE__ */
|
|
517
|
+
/* @__PURE__ */ F(xe, {
|
|
517
518
|
active: e.hide,
|
|
518
519
|
onClick: () => i({ hide: !e.hide }),
|
|
519
520
|
title: "Hide cell",
|
|
@@ -521,10 +522,10 @@ function Ce({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
521
522
|
})
|
|
522
523
|
]
|
|
523
524
|
}),
|
|
524
|
-
/* @__PURE__ */
|
|
525
|
+
/* @__PURE__ */ F(E, {
|
|
525
526
|
label: "Opacity",
|
|
526
527
|
hint: `${Math.round(e.opacity * 100)}%`,
|
|
527
|
-
children: /* @__PURE__ */
|
|
528
|
+
children: /* @__PURE__ */ F(D, {
|
|
528
529
|
min: 0,
|
|
529
530
|
max: 100,
|
|
530
531
|
value: Math.round(e.opacity * 100),
|
|
@@ -536,8 +537,8 @@ function Ce({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
536
537
|
}
|
|
537
538
|
//#endregion
|
|
538
539
|
//#region src/editor/library/mergeRemote.js
|
|
539
|
-
var
|
|
540
|
-
function
|
|
540
|
+
var Ce = (e) => e?.updatedAt ?? e?.savedAt ?? 0, we = (e) => /^(Plan08 |Sync [A-Z] \d{13}|Morph [A-Z] \d{13})/.test(e?.name ?? "");
|
|
541
|
+
function Te(e, t) {
|
|
541
542
|
let n = {}, r = [], i = /* @__PURE__ */ new Map();
|
|
542
543
|
for (let e of t || []) i.has(e.kind) || i.set(e.kind, /* @__PURE__ */ new Map()), i.get(e.kind).set(e.id, e);
|
|
543
544
|
let a = new Set([...Object.keys(e || {}), ...i.keys()]);
|
|
@@ -549,7 +550,7 @@ function Ee(e, t) {
|
|
|
549
550
|
o.push(n);
|
|
550
551
|
continue;
|
|
551
552
|
}
|
|
552
|
-
if (
|
|
553
|
+
if (we(n)) {
|
|
553
554
|
s.add(n.id), e && !e.deleted && r.push({
|
|
554
555
|
op: "remove",
|
|
555
556
|
kind: t,
|
|
@@ -566,7 +567,7 @@ function Ee(e, t) {
|
|
|
566
567
|
continue;
|
|
567
568
|
}
|
|
568
569
|
if (e.deleted) {
|
|
569
|
-
if (e.updatedAt >
|
|
570
|
+
if (e.updatedAt > Ce(n)) continue;
|
|
570
571
|
o.push(n), r.push({
|
|
571
572
|
op: "put",
|
|
572
573
|
kind: t,
|
|
@@ -574,7 +575,7 @@ function Ee(e, t) {
|
|
|
574
575
|
});
|
|
575
576
|
continue;
|
|
576
577
|
}
|
|
577
|
-
e.updatedAt >
|
|
578
|
+
e.updatedAt > Ce(n) ? o.push(e.spec) : (o.push(n), e.updatedAt < Ce(n) && r.push({
|
|
578
579
|
op: "put",
|
|
579
580
|
kind: t,
|
|
580
581
|
item: n
|
|
@@ -582,7 +583,7 @@ function Ee(e, t) {
|
|
|
582
583
|
}
|
|
583
584
|
let c = new Set(o.map((e) => e.id));
|
|
584
585
|
for (let e of a.values()) if (!(e.deleted || c.has(e.id) || s.has(e.id))) {
|
|
585
|
-
if (
|
|
586
|
+
if (we(e.spec)) {
|
|
586
587
|
r.push({
|
|
587
588
|
op: "remove",
|
|
588
589
|
kind: t,
|
|
@@ -601,19 +602,19 @@ function Ee(e, t) {
|
|
|
601
602
|
}
|
|
602
603
|
//#endregion
|
|
603
604
|
//#region src/editor/library/libraryApi.js
|
|
604
|
-
var
|
|
605
|
-
function
|
|
606
|
-
|
|
605
|
+
var H = null;
|
|
606
|
+
function Ee(e) {
|
|
607
|
+
H = typeof e == "string" && e.trim() ? e.trim().replace(/\/+$/, "") : null, Ie();
|
|
607
608
|
}
|
|
608
|
-
function
|
|
609
|
-
return
|
|
609
|
+
function De() {
|
|
610
|
+
return H;
|
|
610
611
|
}
|
|
611
|
-
var
|
|
612
|
+
var U = class extends Error {
|
|
612
613
|
constructor() {
|
|
613
614
|
super("unauthorized"), this.name = "UnauthorizedError";
|
|
614
615
|
}
|
|
615
616
|
};
|
|
616
|
-
function
|
|
617
|
+
function Oe(e, t) {
|
|
617
618
|
let n = `Bearer ${t}`, r = async (t, r = {}) => {
|
|
618
619
|
let i = await fetch(`${e}${t}`, {
|
|
619
620
|
...r,
|
|
@@ -623,7 +624,7 @@ function ke(e, t) {
|
|
|
623
624
|
...r.headers || {}
|
|
624
625
|
}
|
|
625
626
|
});
|
|
626
|
-
if (i.status === 401) throw new
|
|
627
|
+
if (i.status === 401) throw new U();
|
|
627
628
|
if (!i.ok) throw Error(`library api ${i.status}`);
|
|
628
629
|
return i.json();
|
|
629
630
|
};
|
|
@@ -647,33 +648,33 @@ function ke(e, t) {
|
|
|
647
648
|
}
|
|
648
649
|
};
|
|
649
650
|
}
|
|
650
|
-
var
|
|
651
|
-
function
|
|
652
|
-
return
|
|
651
|
+
var ke = "kol.fxr.library-session", W = null, Ae = /* @__PURE__ */ new Set(), G = () => Ae.forEach((e) => e());
|
|
652
|
+
function je() {
|
|
653
|
+
return W;
|
|
653
654
|
}
|
|
654
|
-
var
|
|
655
|
-
function
|
|
655
|
+
var Me = () => P((e) => (Ae.add(e), () => Ae.delete(e)), je, je), Ne = () => Me()?.user ?? null;
|
|
656
|
+
function K(e) {
|
|
656
657
|
try {
|
|
657
|
-
e ? localStorage.setItem(
|
|
658
|
+
e ? localStorage.setItem(ke, JSON.stringify(e)) : localStorage.removeItem(ke);
|
|
658
659
|
} catch {}
|
|
659
660
|
}
|
|
660
|
-
var
|
|
661
|
+
var Pe = () => {
|
|
661
662
|
try {
|
|
662
|
-
return JSON.parse(localStorage.getItem(
|
|
663
|
+
return JSON.parse(localStorage.getItem(ke) || "null");
|
|
663
664
|
} catch {
|
|
664
665
|
return null;
|
|
665
666
|
}
|
|
666
667
|
};
|
|
667
|
-
function
|
|
668
|
-
let { next: n, pushes: r } =
|
|
669
|
-
|
|
670
|
-
...
|
|
668
|
+
function Fe(e, t) {
|
|
669
|
+
let { next: n, pushes: r } = Te(Q(), t);
|
|
670
|
+
st({
|
|
671
|
+
...Q(),
|
|
671
672
|
...n
|
|
672
673
|
});
|
|
673
674
|
for (let t of r) e.push(t).catch(() => {});
|
|
674
675
|
}
|
|
675
|
-
async function
|
|
676
|
-
let r = await fetch(`${
|
|
676
|
+
async function q(e, t = {}, n) {
|
|
677
|
+
let r = await fetch(`${H}${e}`, {
|
|
677
678
|
...t,
|
|
678
679
|
headers: {
|
|
679
680
|
"content-type": "application/json",
|
|
@@ -681,50 +682,50 @@ async function K(e, t = {}, n) {
|
|
|
681
682
|
...t.headers || {}
|
|
682
683
|
}
|
|
683
684
|
});
|
|
684
|
-
if (r.status === 401) throw new
|
|
685
|
+
if (r.status === 401) throw new U();
|
|
685
686
|
let i = await r.json().catch(() => ({}));
|
|
686
687
|
if (!r.ok) throw Error(i.error || `library api ${r.status}`);
|
|
687
688
|
return i;
|
|
688
689
|
}
|
|
689
|
-
function
|
|
690
|
-
if (
|
|
691
|
-
let e =
|
|
692
|
-
if (!e?.token || e.base !==
|
|
693
|
-
let t =
|
|
694
|
-
|
|
690
|
+
function Ie() {
|
|
691
|
+
if (W || !H) return;
|
|
692
|
+
let e = Pe();
|
|
693
|
+
if (!e?.token || e.base !== H || !(e.expiresAt > Date.now()) || !e.user) return;
|
|
694
|
+
let t = Oe(H, e.token);
|
|
695
|
+
W = {
|
|
695
696
|
backend: t,
|
|
696
697
|
user: e.user,
|
|
697
698
|
token: e.token
|
|
698
|
-
},
|
|
699
|
-
|
|
700
|
-
...
|
|
699
|
+
}, G(), q("/api/me", {}, e.token).then(({ user: t }) => {
|
|
700
|
+
W?.token === e.token && (W = {
|
|
701
|
+
...W,
|
|
701
702
|
user: t
|
|
702
|
-
},
|
|
703
|
+
}, K({
|
|
703
704
|
...e,
|
|
704
705
|
user: t
|
|
705
|
-
}),
|
|
706
|
+
}), G());
|
|
706
707
|
}).catch((e) => {
|
|
707
|
-
e instanceof
|
|
708
|
-
}), t.hydrate().then((e) =>
|
|
709
|
-
e instanceof
|
|
708
|
+
e instanceof U && J();
|
|
709
|
+
}), t.hydrate().then((e) => Fe(t, e)).catch((e) => {
|
|
710
|
+
e instanceof U ? J() : console.warn("library sync: hydrate failed —", e?.message || e);
|
|
710
711
|
});
|
|
711
712
|
}
|
|
712
|
-
async function
|
|
713
|
-
let r =
|
|
714
|
-
return
|
|
713
|
+
async function Le({ token: e, expiresAt: t, user: n }) {
|
|
714
|
+
let r = Oe(H, e), i = await r.hydrate();
|
|
715
|
+
return Fe(r, i), W = {
|
|
715
716
|
backend: r,
|
|
716
717
|
user: n,
|
|
717
718
|
token: e
|
|
718
|
-
},
|
|
719
|
-
base:
|
|
719
|
+
}, K({
|
|
720
|
+
base: H,
|
|
720
721
|
token: e,
|
|
721
722
|
expiresAt: t,
|
|
722
723
|
user: n
|
|
723
|
-
}),
|
|
724
|
+
}), G(), i.filter((e) => !e.deleted).length;
|
|
724
725
|
}
|
|
725
|
-
async function
|
|
726
|
-
if (!
|
|
727
|
-
return
|
|
726
|
+
async function Re({ email: e, password: t } = {}) {
|
|
727
|
+
if (!H) throw Error("no library api");
|
|
728
|
+
return Le(await q("/api/auth/signin", {
|
|
728
729
|
method: "POST",
|
|
729
730
|
body: JSON.stringify({
|
|
730
731
|
email: e,
|
|
@@ -732,48 +733,48 @@ async function ze({ email: e, password: t } = {}) {
|
|
|
732
733
|
})
|
|
733
734
|
}));
|
|
734
735
|
}
|
|
735
|
-
async function
|
|
736
|
-
if (!
|
|
737
|
-
return
|
|
736
|
+
async function ze(e) {
|
|
737
|
+
if (!H) throw Error("no library api");
|
|
738
|
+
return Le(await q("/api/auth/signup", {
|
|
738
739
|
method: "POST",
|
|
739
740
|
body: JSON.stringify(e)
|
|
740
741
|
}));
|
|
741
742
|
}
|
|
742
|
-
function
|
|
743
|
-
let e =
|
|
744
|
-
|
|
743
|
+
function J() {
|
|
744
|
+
let e = W?.token ?? Pe()?.token;
|
|
745
|
+
K(null), e && H && q("/api/auth/signout", {
|
|
745
746
|
method: "POST",
|
|
746
747
|
body: "{}"
|
|
747
|
-
}, e).catch(() => {}),
|
|
748
|
+
}, e).catch(() => {}), W && (W = null, G());
|
|
748
749
|
}
|
|
749
|
-
async function
|
|
750
|
-
if (!
|
|
751
|
-
let { user: t } = await
|
|
750
|
+
async function Be(e) {
|
|
751
|
+
if (!W) throw new U();
|
|
752
|
+
let { user: t } = await q("/api/me", {
|
|
752
753
|
method: "PATCH",
|
|
753
754
|
body: JSON.stringify(e)
|
|
754
|
-
},
|
|
755
|
-
return
|
|
756
|
-
...
|
|
755
|
+
}, W.token);
|
|
756
|
+
return W = {
|
|
757
|
+
...W,
|
|
757
758
|
user: t
|
|
758
|
-
},
|
|
759
|
-
...
|
|
759
|
+
}, K({
|
|
760
|
+
...Pe(),
|
|
760
761
|
user: t
|
|
761
|
-
}),
|
|
762
|
+
}), G(), t;
|
|
762
763
|
}
|
|
763
|
-
async function
|
|
764
|
-
if (!
|
|
765
|
-
let { token: e, expiresAt: t } = await
|
|
764
|
+
async function Ve() {
|
|
765
|
+
if (!W) throw new U();
|
|
766
|
+
let { token: e, expiresAt: t } = await q("/api/invites", {
|
|
766
767
|
method: "POST",
|
|
767
768
|
body: "{}"
|
|
768
|
-
},
|
|
769
|
+
}, W.token);
|
|
769
770
|
return {
|
|
770
771
|
url: `${window.location.origin}/join?invite=${encodeURIComponent(e)}`,
|
|
771
772
|
expiresAt: t
|
|
772
773
|
};
|
|
773
774
|
}
|
|
774
|
-
async function
|
|
775
|
-
if (!
|
|
776
|
-
return
|
|
775
|
+
async function He({ name: e, email: t }) {
|
|
776
|
+
if (!H) throw Error("no library api");
|
|
777
|
+
return q("/api/invite-requests", {
|
|
777
778
|
method: "POST",
|
|
778
779
|
body: JSON.stringify({
|
|
779
780
|
name: e,
|
|
@@ -781,16 +782,16 @@ async function Ue({ name: e, email: t }) {
|
|
|
781
782
|
})
|
|
782
783
|
});
|
|
783
784
|
}
|
|
784
|
-
async function
|
|
785
|
-
if (!
|
|
786
|
-
return (await
|
|
785
|
+
async function Ue() {
|
|
786
|
+
if (!W) throw new U();
|
|
787
|
+
return (await q("/api/invite-requests", {}, W.token)).requests;
|
|
787
788
|
}
|
|
788
|
-
async function
|
|
789
|
-
if (!
|
|
790
|
-
let { token: t, expiresAt: n, email: r, name: i } = await
|
|
789
|
+
async function We(e) {
|
|
790
|
+
if (!W) throw new U();
|
|
791
|
+
let { token: t, expiresAt: n, email: r, name: i } = await q(`/api/invite-requests/${encodeURIComponent(e)}/invite`, {
|
|
791
792
|
method: "POST",
|
|
792
793
|
body: "{}"
|
|
793
|
-
},
|
|
794
|
+
}, W.token);
|
|
794
795
|
return {
|
|
795
796
|
url: `${window.location.origin}/join?invite=${encodeURIComponent(t)}`,
|
|
796
797
|
expiresAt: n,
|
|
@@ -800,17 +801,17 @@ async function Ge(e) {
|
|
|
800
801
|
}
|
|
801
802
|
//#endregion
|
|
802
803
|
//#region src/editor/library/LibraryProvider.jsx
|
|
803
|
-
var
|
|
804
|
+
var Ge = "kol.editor.library.v3", Y = [
|
|
804
805
|
"palette",
|
|
805
806
|
"pattern",
|
|
806
807
|
"type",
|
|
807
808
|
"preset"
|
|
808
|
-
],
|
|
809
|
+
], X = Y.reduce((e, t) => (e[t] = [], e), {}), Ke = 1, qe = () => `i${Date.now().toString(36)}-${Ke++}`, Je = (e) => ({
|
|
809
810
|
...e,
|
|
810
|
-
id: e.id ??
|
|
811
|
+
id: e.id ?? qe(),
|
|
811
812
|
savedAt: e.savedAt ?? Date.now()
|
|
812
|
-
}),
|
|
813
|
-
function
|
|
813
|
+
}), Z = (e) => typeof e == "number" && Number.isFinite(e);
|
|
814
|
+
function Ye(e) {
|
|
814
815
|
return !e || !Array.isArray(e.colors) || e.colors.length === 0 ? null : {
|
|
815
816
|
colors: e.colors,
|
|
816
817
|
bgEnabled: !!e.bgEnabled,
|
|
@@ -818,39 +819,39 @@ function Xe(e) {
|
|
|
818
819
|
modeId: e.modeId ?? "random"
|
|
819
820
|
};
|
|
820
821
|
}
|
|
821
|
-
function
|
|
822
|
+
function Xe(e) {
|
|
822
823
|
return !e || typeof e.shapeId != "string" || e.shapeId === "type-composition" ? null : {
|
|
823
824
|
shapeId: e.shapeId,
|
|
824
825
|
customSvg: typeof e.customSvg == "string" ? e.customSvg : "",
|
|
825
|
-
cols:
|
|
826
|
-
rows:
|
|
827
|
-
gap:
|
|
828
|
-
padding:
|
|
826
|
+
cols: Z(e.cols) ? e.cols : 4,
|
|
827
|
+
rows: Z(e.rows) ? e.rows : 4,
|
|
828
|
+
gap: Z(e.gap) ? e.gap : 0,
|
|
829
|
+
padding: Z(e.padding) ? e.padding : 0,
|
|
829
830
|
stretch: !!e.stretch,
|
|
830
831
|
overflow: !!e.overflow,
|
|
831
832
|
bg: e.bg ?? null,
|
|
832
833
|
color: e.color ?? "palette:secondary",
|
|
833
834
|
rules: Array.isArray(e.rules) ? e.rules : [],
|
|
834
|
-
scale:
|
|
835
|
+
scale: Z(e.scale) ? e.scale : 256
|
|
835
836
|
};
|
|
836
837
|
}
|
|
837
|
-
function
|
|
838
|
+
function Ze(e) {
|
|
838
839
|
if (!e || typeof e.text != "string") return null;
|
|
839
840
|
let t = {
|
|
840
841
|
text: e.text,
|
|
841
842
|
width: e.width ?? "Tight",
|
|
842
|
-
weight:
|
|
843
|
+
weight: Z(e.weight) ? e.weight : 600,
|
|
843
844
|
italic: !!e.italic,
|
|
844
|
-
size:
|
|
845
|
-
tracking:
|
|
846
|
-
lineHeight:
|
|
845
|
+
size: Z(e.size) ? e.size : 96,
|
|
846
|
+
tracking: Z(e.tracking) ? e.tracking : -.01,
|
|
847
|
+
lineHeight: Z(e.lineHeight) ? e.lineHeight : 1.05,
|
|
847
848
|
case: e.case ?? "original",
|
|
848
849
|
color: e.color ?? "palette:dark",
|
|
849
850
|
textAlign: e.textAlign ?? "center"
|
|
850
851
|
};
|
|
851
852
|
return e.axisOn !== void 0 && (t.axisOn = e.axisOn, t.width2 = e.width2, t.weight2 = e.weight2, t.blend = e.blend), t;
|
|
852
853
|
}
|
|
853
|
-
function
|
|
854
|
+
function Qe(e) {
|
|
854
855
|
return !e || !Array.isArray(e.layers) ? null : {
|
|
855
856
|
intent: e.intent ?? "whole",
|
|
856
857
|
aspect: e.aspect ?? "1:1",
|
|
@@ -868,38 +869,38 @@ function $e(e) {
|
|
|
868
869
|
...typeof e.sub == "string" ? { sub: e.sub } : {}
|
|
869
870
|
};
|
|
870
871
|
}
|
|
871
|
-
var
|
|
872
|
-
palette:
|
|
873
|
-
pattern:
|
|
874
|
-
type:
|
|
875
|
-
preset:
|
|
876
|
-
},
|
|
872
|
+
var $e = {
|
|
873
|
+
palette: Ye,
|
|
874
|
+
pattern: Xe,
|
|
875
|
+
type: Ze,
|
|
876
|
+
preset: Qe
|
|
877
|
+
}, et = [
|
|
877
878
|
"id",
|
|
878
879
|
"savedAt",
|
|
879
880
|
"updatedAt",
|
|
880
881
|
"name"
|
|
881
882
|
];
|
|
882
|
-
function
|
|
883
|
+
function tt(e) {
|
|
883
884
|
let t = {};
|
|
884
|
-
for (let n of
|
|
885
|
+
for (let n of et) e?.[n] !== void 0 && (t[n] = e[n]);
|
|
885
886
|
return t;
|
|
886
887
|
}
|
|
887
|
-
function
|
|
888
|
-
let t =
|
|
889
|
-
for (let n of
|
|
890
|
-
let r =
|
|
888
|
+
function nt(e) {
|
|
889
|
+
let t = Y.reduce((e, t) => (e[t] = [], e), {});
|
|
890
|
+
for (let n of Y) {
|
|
891
|
+
let r = $e[n];
|
|
891
892
|
t[n] = (Array.isArray(e?.[n]) ? e[n] : []).map((e) => {
|
|
892
893
|
let t = r ? r(e) : e;
|
|
893
894
|
return t ? {
|
|
894
895
|
v: 1,
|
|
895
|
-
...
|
|
896
|
+
...tt(e),
|
|
896
897
|
...t
|
|
897
898
|
} : null;
|
|
898
899
|
}).filter(Boolean);
|
|
899
900
|
}
|
|
900
901
|
return t;
|
|
901
902
|
}
|
|
902
|
-
function
|
|
903
|
+
function rt(e) {
|
|
903
904
|
return Array.isArray(e) ? e.map((e) => e?.type ? e.type === "bg" ? {
|
|
904
905
|
...e,
|
|
905
906
|
type: "background"
|
|
@@ -912,7 +913,7 @@ function it(e) {
|
|
|
912
913
|
kind: "logo"
|
|
913
914
|
} : e : e) : e;
|
|
914
915
|
}
|
|
915
|
-
function
|
|
916
|
+
function it(e) {
|
|
916
917
|
let t = {};
|
|
917
918
|
for (let n of [
|
|
918
919
|
"palette",
|
|
@@ -923,37 +924,37 @@ function at(e) {
|
|
|
923
924
|
"composition"
|
|
924
925
|
]) {
|
|
925
926
|
let r = e?.[n];
|
|
926
|
-
Array.isArray(r) ? t[n] = r : r && typeof r == "object" ? t[n] = [
|
|
927
|
+
Array.isArray(r) ? t[n] = r : r && typeof r == "object" ? t[n] = [Je(r)] : t[n] = [];
|
|
927
928
|
}
|
|
928
929
|
return t;
|
|
929
930
|
}
|
|
930
|
-
function
|
|
931
|
-
let t =
|
|
931
|
+
function at(e) {
|
|
932
|
+
let t = Y.reduce((e, t) => (e[t] = [], e), {}), n = (e) => Array.isArray(e) ? e : e && typeof e == "object" ? [Je(e)] : [];
|
|
932
933
|
t.palette = n(e?.palette), t.pattern = n(e?.pattern), t.type = n(e?.type);
|
|
933
934
|
let r = n(e?.layout), i = n(e?.composition).map((e) => ({
|
|
934
935
|
...e,
|
|
935
|
-
layers:
|
|
936
|
+
layers: rt(e.layers)
|
|
936
937
|
}));
|
|
937
938
|
return t.preset = [...r, ...i], t;
|
|
938
939
|
}
|
|
939
|
-
function
|
|
940
|
-
if (typeof window > "u") return
|
|
940
|
+
function Q() {
|
|
941
|
+
if (typeof window > "u") return X;
|
|
941
942
|
try {
|
|
942
|
-
let e = window.localStorage.getItem(
|
|
943
|
-
if (e) return
|
|
943
|
+
let e = window.localStorage.getItem(Ge);
|
|
944
|
+
if (e) return nt(JSON.parse(e));
|
|
944
945
|
let t = window.localStorage.getItem("kol.generator.library.v2");
|
|
945
|
-
if (t) return window.localStorage.setItem("kol.generator.library.v2._backup", t),
|
|
946
|
+
if (t) return window.localStorage.setItem("kol.generator.library.v2._backup", t), nt(at(JSON.parse(t)));
|
|
946
947
|
let n = window.localStorage.getItem("kol.generator.library.v1");
|
|
947
|
-
return n ?
|
|
948
|
+
return n ? nt(at(it(JSON.parse(n)))) : X;
|
|
948
949
|
} catch {
|
|
949
|
-
return
|
|
950
|
+
return X;
|
|
950
951
|
}
|
|
951
952
|
}
|
|
952
|
-
var
|
|
953
|
-
function
|
|
953
|
+
var ot = (e) => e?.item?.shipped === !0 || String(e?.id ?? e?.item?.id ?? "").startsWith("ship:");
|
|
954
|
+
function st(e) {
|
|
954
955
|
if (!(typeof window > "u")) {
|
|
955
956
|
try {
|
|
956
|
-
window.localStorage.setItem(
|
|
957
|
+
window.localStorage.setItem(Ge, JSON.stringify(e));
|
|
957
958
|
} catch (e) {
|
|
958
959
|
console.warn("library: could not save to this browser —", e?.message || e);
|
|
959
960
|
return;
|
|
@@ -961,23 +962,23 @@ function ct(e) {
|
|
|
961
962
|
window.dispatchEvent(new CustomEvent("kol:library"));
|
|
962
963
|
}
|
|
963
964
|
}
|
|
964
|
-
var
|
|
965
|
+
var ct = (e) => (window.addEventListener("kol:library", e), window.addEventListener("storage", e), () => {
|
|
965
966
|
window.removeEventListener("kol:library", e), window.removeEventListener("storage", e);
|
|
966
|
-
}),
|
|
967
|
+
}), lt = () => {
|
|
967
968
|
try {
|
|
968
|
-
return window.localStorage.getItem(
|
|
969
|
+
return window.localStorage.getItem(Ge);
|
|
969
970
|
} catch {
|
|
970
971
|
return null;
|
|
971
972
|
}
|
|
972
|
-
},
|
|
973
|
-
function
|
|
973
|
+
}, ut = k(null);
|
|
974
|
+
function dt(e, t, n) {
|
|
974
975
|
return e.map((e) => e.id === t ? {
|
|
975
976
|
...e,
|
|
976
977
|
name: String(n ?? "").trim() || null,
|
|
977
978
|
updatedAt: Date.now()
|
|
978
979
|
} : e);
|
|
979
980
|
}
|
|
980
|
-
function
|
|
981
|
+
function ft(e, t, n) {
|
|
981
982
|
let r = e.findIndex((e) => e.id === t);
|
|
982
983
|
if (r === -1) return e;
|
|
983
984
|
let i = e[r], a = {
|
|
@@ -992,20 +993,20 @@ function pt(e, t, n) {
|
|
|
992
993
|
...e.slice(r + 1)
|
|
993
994
|
];
|
|
994
995
|
}
|
|
995
|
-
function
|
|
996
|
-
let [t, n] =
|
|
997
|
-
|
|
998
|
-
|
|
996
|
+
function pt({ children: e }) {
|
|
997
|
+
let [t, n] = N(Q);
|
|
998
|
+
j(() => {
|
|
999
|
+
st(t);
|
|
999
1000
|
}, [t]);
|
|
1000
|
-
let r =
|
|
1001
|
+
let r = M(t);
|
|
1001
1002
|
r.current = t;
|
|
1002
|
-
let i =
|
|
1003
|
+
let i = M(null), [a, o] = N("off"), s = A((e) => {
|
|
1003
1004
|
let t = i.current;
|
|
1004
|
-
!t ||
|
|
1005
|
-
e instanceof
|
|
1005
|
+
!t || ot(e) || t.push(e).catch((e) => {
|
|
1006
|
+
e instanceof U && J(), typeof console < "u" && console.warn("library sync: push failed —", e?.message || e);
|
|
1006
1007
|
});
|
|
1007
|
-
}, []), c =
|
|
1008
|
-
|
|
1008
|
+
}, []), c = Me();
|
|
1009
|
+
j(() => {
|
|
1009
1010
|
if (!c) {
|
|
1010
1011
|
i.current = null, o("off");
|
|
1011
1012
|
return;
|
|
@@ -1013,23 +1014,23 @@ function mt({ children: e }) {
|
|
|
1013
1014
|
let e = !0;
|
|
1014
1015
|
return c.backend.hydrate().then((t) => {
|
|
1015
1016
|
if (!e) return;
|
|
1016
|
-
let { next: a, pushes: l } =
|
|
1017
|
+
let { next: a, pushes: l } = Te(r.current, t);
|
|
1017
1018
|
i.current = c.backend, n({
|
|
1018
|
-
...
|
|
1019
|
+
...X,
|
|
1019
1020
|
...a
|
|
1020
1021
|
}), o("on");
|
|
1021
1022
|
for (let e of l) s(e);
|
|
1022
1023
|
}).catch((e) => {
|
|
1023
|
-
e instanceof
|
|
1024
|
+
e instanceof U && J(), typeof console < "u" && console.warn("library sync: hydrate failed —", e?.message || e);
|
|
1024
1025
|
}), () => {
|
|
1025
1026
|
e = !1;
|
|
1026
1027
|
};
|
|
1027
1028
|
}, [c, s]);
|
|
1028
|
-
let l =
|
|
1029
|
-
if (!
|
|
1030
|
-
let r =
|
|
1029
|
+
let l = A((e, t) => {
|
|
1030
|
+
if (!Y.includes(e) || !t) return null;
|
|
1031
|
+
let r = $e[e], i = r ? r(t) : t;
|
|
1031
1032
|
if (!i) return null;
|
|
1032
|
-
let a =
|
|
1033
|
+
let a = qe(), o = {
|
|
1033
1034
|
v: 1,
|
|
1034
1035
|
id: a,
|
|
1035
1036
|
savedAt: Date.now(),
|
|
@@ -1044,7 +1045,7 @@ function mt({ children: e }) {
|
|
|
1044
1045
|
kind: e,
|
|
1045
1046
|
item: o
|
|
1046
1047
|
}), a;
|
|
1047
|
-
}, [s]), u =
|
|
1048
|
+
}, [s]), u = A((e, t) => {
|
|
1048
1049
|
n((n) => ({
|
|
1049
1050
|
...n,
|
|
1050
1051
|
[e]: (n[e] ?? []).filter((e) => e.id !== t)
|
|
@@ -1053,9 +1054,9 @@ function mt({ children: e }) {
|
|
|
1053
1054
|
kind: e,
|
|
1054
1055
|
id: t
|
|
1055
1056
|
});
|
|
1056
|
-
}, [s]), ee =
|
|
1057
|
-
if (!
|
|
1058
|
-
let a =
|
|
1057
|
+
}, [s]), ee = A((e, t, i) => {
|
|
1058
|
+
if (!Y.includes(e) || !t || !i) return;
|
|
1059
|
+
let a = $e[e], o = a ? a(i) : i;
|
|
1059
1060
|
if (!o) return;
|
|
1060
1061
|
let c = Date.now(), l = (e) => ({
|
|
1061
1062
|
...e,
|
|
@@ -1075,20 +1076,20 @@ function mt({ children: e }) {
|
|
|
1075
1076
|
kind: e,
|
|
1076
1077
|
item: l(u)
|
|
1077
1078
|
});
|
|
1078
|
-
}, [s]), d =
|
|
1079
|
-
if (!
|
|
1079
|
+
}, [s]), d = A((e, t, i) => {
|
|
1080
|
+
if (!Y.includes(e) || !t) return;
|
|
1080
1081
|
n((n) => ({
|
|
1081
1082
|
...n,
|
|
1082
|
-
[e]:
|
|
1083
|
+
[e]: dt(n[e] ?? [], t, i)
|
|
1083
1084
|
}));
|
|
1084
|
-
let a =
|
|
1085
|
+
let a = dt(r.current[e] ?? [], t, i).find((e) => e.id === t);
|
|
1085
1086
|
a && s({
|
|
1086
1087
|
op: "put",
|
|
1087
1088
|
kind: e,
|
|
1088
1089
|
item: a
|
|
1089
1090
|
});
|
|
1090
|
-
}, [s]), f =
|
|
1091
|
-
if (!
|
|
1091
|
+
}, [s]), f = A((e, t, i) => {
|
|
1092
|
+
if (!Y.includes(e) || !t || typeof i != "string" || (r.current[e] ?? []).find((e) => e.id === t)?.shipped) return;
|
|
1092
1093
|
let a = (e) => e.map((e) => e.id === t ? {
|
|
1093
1094
|
...e,
|
|
1094
1095
|
thumb: i
|
|
@@ -1103,30 +1104,30 @@ function mt({ children: e }) {
|
|
|
1103
1104
|
kind: e,
|
|
1104
1105
|
item: o
|
|
1105
1106
|
});
|
|
1106
|
-
}, [s]), p =
|
|
1107
|
-
if (!
|
|
1108
|
-
let i =
|
|
1107
|
+
}, [s]), p = A((e, t) => {
|
|
1108
|
+
if (!Y.includes(e) || !t) return null;
|
|
1109
|
+
let i = qe();
|
|
1109
1110
|
n((n) => ({
|
|
1110
1111
|
...n,
|
|
1111
|
-
[e]:
|
|
1112
|
+
[e]: ft(n[e] ?? [], t, i)
|
|
1112
1113
|
}));
|
|
1113
|
-
let a =
|
|
1114
|
+
let a = ft(r.current[e] ?? [], t, i).find((e) => e.id === i);
|
|
1114
1115
|
return a && s({
|
|
1115
1116
|
op: "put",
|
|
1116
1117
|
kind: e,
|
|
1117
1118
|
item: a
|
|
1118
1119
|
}), i;
|
|
1119
|
-
}, [s]), m =
|
|
1120
|
+
}, [s]), m = A((e) => {
|
|
1120
1121
|
n((t) => ({
|
|
1121
1122
|
...t,
|
|
1122
1123
|
[e]: []
|
|
1123
1124
|
}));
|
|
1124
|
-
}, []), h =
|
|
1125
|
-
...
|
|
1125
|
+
}, []), h = A(() => n(X), []), g = A((e) => n({
|
|
1126
|
+
...X,
|
|
1126
1127
|
...e
|
|
1127
1128
|
}), []), _ = {
|
|
1128
1129
|
library: t,
|
|
1129
|
-
selected:
|
|
1130
|
+
selected: se(() => Y.reduce((e, n) => {
|
|
1130
1131
|
let r = t[n] ?? [];
|
|
1131
1132
|
return e[n] = r.length ? r[r.length - 1] : null, e;
|
|
1132
1133
|
}, {}), [t]),
|
|
@@ -1145,15 +1146,15 @@ function mt({ children: e }) {
|
|
|
1145
1146
|
saveType: (e) => l("type", e),
|
|
1146
1147
|
savePreset: (e) => l("preset", e)
|
|
1147
1148
|
};
|
|
1148
|
-
return /* @__PURE__ */
|
|
1149
|
+
return /* @__PURE__ */ F(ut.Provider, {
|
|
1149
1150
|
value: _,
|
|
1150
1151
|
children: e
|
|
1151
1152
|
});
|
|
1152
1153
|
}
|
|
1153
|
-
function
|
|
1154
|
-
return
|
|
1155
|
-
library:
|
|
1156
|
-
selected:
|
|
1154
|
+
function mt() {
|
|
1155
|
+
return oe(ut) || {
|
|
1156
|
+
library: X,
|
|
1157
|
+
selected: Y.reduce((e, t) => (e[t] = null, e), {}),
|
|
1157
1158
|
addItem: () => null,
|
|
1158
1159
|
removeItem: () => {},
|
|
1159
1160
|
updateItem: () => {},
|
|
@@ -1167,117 +1168,117 @@ function ht() {
|
|
|
1167
1168
|
savePreset: () => null
|
|
1168
1169
|
};
|
|
1169
1170
|
}
|
|
1170
|
-
var
|
|
1171
|
+
var ht = Y, gt = (t) => e("generators")?.loopById(t) ?? null, _t = {
|
|
1171
1172
|
bg: "Background",
|
|
1172
1173
|
fg: "Ink",
|
|
1173
1174
|
accent: "Accent",
|
|
1174
1175
|
dim: "Dim",
|
|
1175
1176
|
warm: "Warm"
|
|
1176
|
-
},
|
|
1177
|
+
}, vt = {
|
|
1177
1178
|
0: "fg",
|
|
1178
1179
|
1: "warm",
|
|
1179
1180
|
3: "dim",
|
|
1180
1181
|
4: "accent",
|
|
1181
1182
|
5: "bg"
|
|
1182
|
-
},
|
|
1183
|
-
function
|
|
1184
|
-
let e = i(), { layers: t, selectedId: n, updateLayer: o, setColorAt: l } = r(), { library: m, addItem: g } =
|
|
1185
|
-
base:
|
|
1183
|
+
}, yt = (e) => e.slice(0, 7).toLowerCase();
|
|
1184
|
+
function bt() {
|
|
1185
|
+
let e = i(), { layers: t, selectedId: n, updateLayer: o, setColorAt: l } = r(), { library: m, addItem: g } = mt(), [_, re] = N("analogous"), [y, x] = N(p), [S, C] = N(() => c(.62, .14, Math.random() * 360)), [w, T] = N(() => ne(u(y), {
|
|
1186
|
+
base: S,
|
|
1186
1187
|
relation: _,
|
|
1187
1188
|
count: 5
|
|
1188
1189
|
}).map((e) => ({
|
|
1189
1190
|
hex: e,
|
|
1190
1191
|
locked: !1
|
|
1191
|
-
}))), [
|
|
1192
|
+
}))), [E, D] = N(null), O = se(() => ee(m), [m]), k = ({ b: e = S, rel: t = _, n = w.length, s: r = y } = {}) => {
|
|
1192
1193
|
let i = ne(u(r), {
|
|
1193
1194
|
base: e,
|
|
1194
1195
|
relation: t,
|
|
1195
1196
|
count: n
|
|
1196
1197
|
});
|
|
1197
|
-
|
|
1198
|
+
T((e) => i.map((t, n) => e[n]?.locked ? e[n] : {
|
|
1198
1199
|
hex: t,
|
|
1199
1200
|
locked: !1
|
|
1200
|
-
})),
|
|
1201
|
-
},
|
|
1201
|
+
})), D(null);
|
|
1202
|
+
}, A = () => {
|
|
1202
1203
|
let e = p();
|
|
1203
|
-
|
|
1204
|
-
},
|
|
1205
|
-
let t =
|
|
1206
|
-
|
|
1207
|
-
},
|
|
1208
|
-
re(e),
|
|
1209
|
-
},
|
|
1204
|
+
x(e), k({ s: e });
|
|
1205
|
+
}, oe = (e) => {
|
|
1206
|
+
let t = yt(e);
|
|
1207
|
+
C(t), k({ b: t });
|
|
1208
|
+
}, j = (e) => {
|
|
1209
|
+
re(e), k({ rel: e });
|
|
1210
|
+
}, M = (e) => {
|
|
1210
1211
|
let t = Number(e);
|
|
1211
|
-
Number.isInteger(t) && t >= 2 && t <= 8 &&
|
|
1212
|
-
},
|
|
1213
|
-
|
|
1212
|
+
Number.isInteger(t) && t >= 2 && t <= 8 && k({ n: t });
|
|
1213
|
+
}, P = (e, t) => {
|
|
1214
|
+
T((n) => n.map((n, r) => r === e ? {
|
|
1214
1215
|
...n,
|
|
1215
|
-
hex:
|
|
1216
|
-
} : n)),
|
|
1217
|
-
},
|
|
1216
|
+
hex: yt(t)
|
|
1217
|
+
} : n)), D(null);
|
|
1218
|
+
}, ce = (e) => T((t) => t.map((t, n) => n === e ? {
|
|
1218
1219
|
...t,
|
|
1219
1220
|
locked: !t.locked
|
|
1220
|
-
} : t)),
|
|
1221
|
-
|
|
1222
|
-
},
|
|
1223
|
-
let t =
|
|
1221
|
+
} : t)), ue = (e) => {
|
|
1222
|
+
T((t) => t.filter((t, n) => n !== e)), D(null);
|
|
1223
|
+
}, de = (e) => {
|
|
1224
|
+
let t = O.find((t) => t.id === e);
|
|
1224
1225
|
if (!t) return;
|
|
1225
1226
|
let n = t.colors.slice(0, 8);
|
|
1226
|
-
|
|
1227
|
-
hex:
|
|
1227
|
+
T((n.length >= 2 ? n : [...n, ...n]).map((e) => ({
|
|
1228
|
+
hex: yt(e),
|
|
1228
1229
|
locked: !1
|
|
1229
|
-
}))),
|
|
1230
|
+
}))), D({
|
|
1230
1231
|
name: t.name,
|
|
1231
1232
|
roles: t.colors.length <= 8 ? t.roles : null
|
|
1232
1233
|
});
|
|
1233
|
-
},
|
|
1234
|
-
name:
|
|
1234
|
+
}, L = w.map((e) => e.hex), R = E?.roles ?? s(L), fe = f.find((e) => e.id === _)?.label ?? "Palette", pe = {
|
|
1235
|
+
name: E?.name ?? fe,
|
|
1235
1236
|
relation: _,
|
|
1236
|
-
colors:
|
|
1237
|
-
roles:
|
|
1238
|
-
},
|
|
1239
|
-
if (!
|
|
1240
|
-
let e = te(
|
|
1241
|
-
o(
|
|
1242
|
-
},
|
|
1243
|
-
return /* @__PURE__ */
|
|
1237
|
+
colors: L,
|
|
1238
|
+
roles: R
|
|
1239
|
+
}, me = (e) => d.filter((t) => R[t]?.toLowerCase() === e).map((e) => _t[e]).join(", "), z = n && n !== "canvas" ? a(t, n) : null, B = z?.type === "loop" ? gt(z.loopId)?.params : null, he = () => {
|
|
1240
|
+
if (!z || !B) return;
|
|
1241
|
+
let e = te(z, B, pe, { rotate: !0 }), t = Object.fromEntries(B.filter((e) => e.type === "color").map((t) => [t.key, e[t.key]]));
|
|
1242
|
+
o(z.id, t);
|
|
1243
|
+
}, ge = () => Object.entries(vt).forEach(([e, t]) => l(Number(e), R[t]));
|
|
1244
|
+
return /* @__PURE__ */ I("div", {
|
|
1244
1245
|
className: "p-4 flex flex-col gap-4",
|
|
1245
1246
|
children: [
|
|
1246
|
-
/* @__PURE__ */
|
|
1247
|
+
/* @__PURE__ */ I("div", {
|
|
1247
1248
|
className: "flex items-center gap-2",
|
|
1248
1249
|
children: [
|
|
1249
|
-
/* @__PURE__ */
|
|
1250
|
-
color:
|
|
1251
|
-
onChange:
|
|
1250
|
+
/* @__PURE__ */ F(ie, {
|
|
1251
|
+
color: S.toUpperCase(),
|
|
1252
|
+
onChange: oe,
|
|
1252
1253
|
size: "sm",
|
|
1253
1254
|
label: "Base"
|
|
1254
1255
|
}),
|
|
1255
|
-
/* @__PURE__ */
|
|
1256
|
+
/* @__PURE__ */ F("span", {
|
|
1256
1257
|
className: "kol-helper-10 uppercase text-meta",
|
|
1257
1258
|
children: "Base"
|
|
1258
1259
|
}),
|
|
1259
|
-
/* @__PURE__ */
|
|
1260
|
+
/* @__PURE__ */ F("span", {
|
|
1260
1261
|
className: "kol-mono-10 text-meta flex-1",
|
|
1261
|
-
children:
|
|
1262
|
+
children: S.toUpperCase()
|
|
1262
1263
|
}),
|
|
1263
|
-
/* @__PURE__ */
|
|
1264
|
+
/* @__PURE__ */ F("span", {
|
|
1264
1265
|
className: "kol-helper-10 uppercase text-meta",
|
|
1265
1266
|
children: "Colors"
|
|
1266
1267
|
}),
|
|
1267
|
-
/* @__PURE__ */
|
|
1268
|
+
/* @__PURE__ */ F(ae, {
|
|
1268
1269
|
size: e,
|
|
1269
1270
|
min: 2,
|
|
1270
1271
|
max: 8,
|
|
1271
|
-
value:
|
|
1272
|
-
onChange: (e) =>
|
|
1272
|
+
value: w.length,
|
|
1273
|
+
onChange: (e) => M(e.target.value),
|
|
1273
1274
|
className: "w-16",
|
|
1274
1275
|
"aria-label": "Colors"
|
|
1275
1276
|
})
|
|
1276
1277
|
]
|
|
1277
1278
|
}),
|
|
1278
|
-
/* @__PURE__ */
|
|
1279
|
+
/* @__PURE__ */ I("div", {
|
|
1279
1280
|
className: "flex items-center gap-2",
|
|
1280
|
-
children: [/* @__PURE__ */
|
|
1281
|
+
children: [/* @__PURE__ */ F(b, {
|
|
1281
1282
|
className: "flex-1 min-w-0",
|
|
1282
1283
|
size: e,
|
|
1283
1284
|
"aria-label": "Relationship",
|
|
@@ -1286,100 +1287,100 @@ function xt() {
|
|
|
1286
1287
|
label: e.label
|
|
1287
1288
|
})),
|
|
1288
1289
|
value: _,
|
|
1289
|
-
onChange:
|
|
1290
|
-
}), /* @__PURE__ */
|
|
1290
|
+
onChange: j
|
|
1291
|
+
}), /* @__PURE__ */ F(v, {
|
|
1291
1292
|
tone: "grey",
|
|
1292
1293
|
size: e,
|
|
1293
|
-
onClick:
|
|
1294
|
+
onClick: A,
|
|
1294
1295
|
children: "Roll"
|
|
1295
1296
|
})]
|
|
1296
1297
|
}),
|
|
1297
|
-
/* @__PURE__ */
|
|
1298
|
+
/* @__PURE__ */ F("div", {
|
|
1298
1299
|
className: "flex flex-col gap-1",
|
|
1299
|
-
children:
|
|
1300
|
+
children: w.map((e, t) => /* @__PURE__ */ I("div", {
|
|
1300
1301
|
className: "flex items-center gap-2",
|
|
1301
1302
|
children: [
|
|
1302
|
-
/* @__PURE__ */
|
|
1303
|
+
/* @__PURE__ */ F(ie, {
|
|
1303
1304
|
color: e.hex.toUpperCase(),
|
|
1304
|
-
onChange: (e) =>
|
|
1305
|
+
onChange: (e) => P(t, e),
|
|
1305
1306
|
size: "sm",
|
|
1306
1307
|
label: `Color ${t + 1}`
|
|
1307
1308
|
}),
|
|
1308
|
-
/* @__PURE__ */
|
|
1309
|
+
/* @__PURE__ */ F("span", {
|
|
1309
1310
|
className: "kol-helper-10 uppercase text-meta flex-1 truncate",
|
|
1310
|
-
children:
|
|
1311
|
+
children: me(e.hex)
|
|
1311
1312
|
}),
|
|
1312
|
-
/* @__PURE__ */
|
|
1313
|
+
/* @__PURE__ */ F("span", {
|
|
1313
1314
|
className: "kol-mono-10 text-meta",
|
|
1314
1315
|
children: e.hex.toUpperCase()
|
|
1315
1316
|
}),
|
|
1316
|
-
/* @__PURE__ */
|
|
1317
|
+
/* @__PURE__ */ F(v, {
|
|
1317
1318
|
tone: "ghost",
|
|
1318
1319
|
quiet: !0,
|
|
1319
1320
|
size: "sm",
|
|
1320
1321
|
iconOnly: e.locked ? "lock" : "unlock",
|
|
1321
1322
|
"aria-label": `${e.locked ? "Unlock" : "Lock"} color ${t + 1}`,
|
|
1322
1323
|
pressed: e.locked,
|
|
1323
|
-
onClick: () =>
|
|
1324
|
+
onClick: () => ce(t)
|
|
1324
1325
|
}),
|
|
1325
|
-
/* @__PURE__ */
|
|
1326
|
-
className:
|
|
1327
|
-
"aria-hidden":
|
|
1328
|
-
children: /* @__PURE__ */
|
|
1326
|
+
/* @__PURE__ */ F("span", {
|
|
1327
|
+
className: w.length <= 2 ? "invisible pointer-events-none" : "contents",
|
|
1328
|
+
"aria-hidden": w.length <= 2 || void 0,
|
|
1329
|
+
children: /* @__PURE__ */ F(v, {
|
|
1329
1330
|
tone: "ghost",
|
|
1330
1331
|
quiet: !0,
|
|
1331
1332
|
size: "sm",
|
|
1332
1333
|
iconOnly: "trash",
|
|
1333
1334
|
"aria-label": `Delete color ${t + 1}`,
|
|
1334
|
-
tabIndex:
|
|
1335
|
-
onClick: () =>
|
|
1335
|
+
tabIndex: w.length <= 2 ? -1 : void 0,
|
|
1336
|
+
onClick: () => ue(t)
|
|
1336
1337
|
})
|
|
1337
1338
|
})
|
|
1338
1339
|
]
|
|
1339
1340
|
}, t))
|
|
1340
1341
|
}),
|
|
1341
|
-
h(
|
|
1342
|
+
h(R.bg, R.fg) < 4.5 && /* @__PURE__ */ I("span", {
|
|
1342
1343
|
className: "kol-helper-10 text-meta inline-flex items-center gap-1",
|
|
1343
|
-
children: [/* @__PURE__ */
|
|
1344
|
+
children: [/* @__PURE__ */ F(le, {
|
|
1344
1345
|
name: "info",
|
|
1345
1346
|
size: 12
|
|
1346
1347
|
}), "Ink on background is under 4.5:1"]
|
|
1347
1348
|
}),
|
|
1348
|
-
/* @__PURE__ */
|
|
1349
|
+
/* @__PURE__ */ F(b, {
|
|
1349
1350
|
size: e,
|
|
1350
1351
|
"aria-label": "Load palette",
|
|
1351
1352
|
value: "",
|
|
1352
1353
|
options: [{
|
|
1353
1354
|
value: "",
|
|
1354
1355
|
label: "Load palette…"
|
|
1355
|
-
}, ...
|
|
1356
|
+
}, ...O.map((e) => ({
|
|
1356
1357
|
value: e.id,
|
|
1357
1358
|
label: e.name
|
|
1358
1359
|
}))],
|
|
1359
|
-
onChange: (e) => e &&
|
|
1360
|
+
onChange: (e) => e && de(e)
|
|
1360
1361
|
}),
|
|
1361
|
-
/* @__PURE__ */
|
|
1362
|
+
/* @__PURE__ */ F(v, {
|
|
1362
1363
|
tone: "grey",
|
|
1363
1364
|
size: e,
|
|
1364
1365
|
onClick: () => g("palette", {
|
|
1365
|
-
name:
|
|
1366
|
-
colors:
|
|
1366
|
+
name: pe.name,
|
|
1367
|
+
colors: L
|
|
1367
1368
|
}),
|
|
1368
1369
|
children: "Save"
|
|
1369
1370
|
}),
|
|
1370
|
-
/* @__PURE__ */
|
|
1371
|
+
/* @__PURE__ */ I("div", {
|
|
1371
1372
|
className: "flex gap-2",
|
|
1372
|
-
children: [
|
|
1373
|
+
children: [B && /* @__PURE__ */ F(v, {
|
|
1373
1374
|
tone: "grey",
|
|
1374
1375
|
size: e,
|
|
1375
1376
|
className: "flex-1",
|
|
1376
|
-
onClick:
|
|
1377
|
+
onClick: he,
|
|
1377
1378
|
children: "Apply to layer"
|
|
1378
|
-
}), /* @__PURE__ */
|
|
1379
|
+
}), /* @__PURE__ */ F(v, {
|
|
1379
1380
|
tone: "grey",
|
|
1380
1381
|
size: e,
|
|
1381
1382
|
className: "flex-1",
|
|
1382
|
-
onClick:
|
|
1383
|
+
onClick: ge,
|
|
1383
1384
|
children: "Apply to document"
|
|
1384
1385
|
})]
|
|
1385
1386
|
})
|
|
@@ -1388,74 +1389,74 @@ function xt() {
|
|
|
1388
1389
|
}
|
|
1389
1390
|
//#endregion
|
|
1390
1391
|
//#region src/editor/color/ColorModesWindow.jsx
|
|
1391
|
-
var
|
|
1392
|
-
function
|
|
1393
|
-
let [e, t] =
|
|
1394
|
-
if (
|
|
1392
|
+
var xt = "kol:open-color-modes", St = () => window.dispatchEvent(new CustomEvent(xt));
|
|
1393
|
+
function Ct() {
|
|
1394
|
+
let [e, t] = N(!1);
|
|
1395
|
+
if (j(() => {
|
|
1395
1396
|
let e = () => t(!0);
|
|
1396
|
-
return window.addEventListener(
|
|
1397
|
+
return window.addEventListener(xt, e), () => window.removeEventListener(xt, e);
|
|
1397
1398
|
}, []), !e) return null;
|
|
1398
1399
|
let n = () => t(!1);
|
|
1399
|
-
return /* @__PURE__ */
|
|
1400
|
+
return /* @__PURE__ */ F(x, {
|
|
1400
1401
|
open: !0,
|
|
1401
1402
|
onClose: n,
|
|
1402
1403
|
closeButton: !1,
|
|
1403
1404
|
scrim: !0,
|
|
1404
|
-
children: /* @__PURE__ */
|
|
1405
|
+
children: /* @__PURE__ */ I("div", {
|
|
1405
1406
|
"aria-label": "Color Modes",
|
|
1406
1407
|
"data-editor-keep-selection": !0,
|
|
1407
1408
|
className: "kol-design-editor kol-popover w-[360px] max-w-full flex flex-col",
|
|
1408
|
-
children: [/* @__PURE__ */
|
|
1409
|
+
children: [/* @__PURE__ */ I("div", {
|
|
1409
1410
|
className: "relative flex h-10 items-center justify-center border-b border-oq-08 px-4",
|
|
1410
|
-
children: [/* @__PURE__ */
|
|
1411
|
+
children: [/* @__PURE__ */ F("span", {
|
|
1411
1412
|
className: "font-sans text-[13px] text-emphasis",
|
|
1412
1413
|
children: "Color Modes"
|
|
1413
|
-
}), /* @__PURE__ */
|
|
1414
|
+
}), /* @__PURE__ */ F(y, {
|
|
1414
1415
|
onClick: n,
|
|
1415
1416
|
size: "sm",
|
|
1416
1417
|
className: "!absolute right-3"
|
|
1417
1418
|
})]
|
|
1418
|
-
}), /* @__PURE__ */
|
|
1419
|
+
}), /* @__PURE__ */ F(bt, {})]
|
|
1419
1420
|
})
|
|
1420
1421
|
});
|
|
1421
1422
|
}
|
|
1422
1423
|
//#endregion
|
|
1423
1424
|
//#region src/editor/generate/store.js
|
|
1424
|
-
var
|
|
1425
|
-
function
|
|
1426
|
-
|
|
1425
|
+
var $ = {}, wt = /* @__PURE__ */ new Set(), Tt = () => wt.forEach((e) => e());
|
|
1426
|
+
function Et(e, t) {
|
|
1427
|
+
$[e] = {
|
|
1427
1428
|
live: !0,
|
|
1428
1429
|
layerId: null,
|
|
1429
|
-
|
|
1430
|
-
...typeof t == "function" ? t(
|
|
1431
|
-
},
|
|
1430
|
+
...$[e],
|
|
1431
|
+
...typeof t == "function" ? t($[e]) : t
|
|
1432
|
+
}, Tt();
|
|
1432
1433
|
}
|
|
1433
|
-
function
|
|
1434
|
-
return
|
|
1434
|
+
function Dt(e, t) {
|
|
1435
|
+
return $[e]?.params || ($[e] = {
|
|
1435
1436
|
live: !0,
|
|
1436
1437
|
layerId: null,
|
|
1437
|
-
|
|
1438
|
+
...$[e],
|
|
1438
1439
|
params: t()
|
|
1439
|
-
}),
|
|
1440
|
+
}), P((e) => (wt.add(e), () => wt.delete(e)), () => $[e]);
|
|
1440
1441
|
}
|
|
1441
|
-
var
|
|
1442
|
-
function
|
|
1442
|
+
var Ot = (e, t = "rail") => Mt(t === "dialog" ? { dialog: e } : { rail: e });
|
|
1443
|
+
function kt(e, t, n = "rail") {
|
|
1443
1444
|
let { id: r, type: i, children: a, ...o } = t;
|
|
1444
|
-
|
|
1445
|
+
Et(e, {
|
|
1445
1446
|
params: o,
|
|
1446
1447
|
layerId: r
|
|
1447
|
-
}),
|
|
1448
|
+
}), Ot(e, n);
|
|
1448
1449
|
}
|
|
1449
|
-
var
|
|
1450
|
+
var At = {
|
|
1450
1451
|
rail: null,
|
|
1451
1452
|
dialog: null
|
|
1452
|
-
},
|
|
1453
|
+
}, jt = /* @__PURE__ */ new Set();
|
|
1453
1454
|
function Mt(e) {
|
|
1454
|
-
|
|
1455
|
-
...
|
|
1455
|
+
At = {
|
|
1456
|
+
...At,
|
|
1456
1457
|
...e
|
|
1457
|
-
},
|
|
1458
|
+
}, jt.forEach((e) => e());
|
|
1458
1459
|
}
|
|
1459
|
-
var Nt = () =>
|
|
1460
|
+
var Nt = () => P((e) => (jt.add(e), () => jt.delete(e)), () => At);
|
|
1460
1461
|
//#endregion
|
|
1461
|
-
export {
|
|
1462
|
+
export { Be as A, Ue as C, Re as D, Ee as E, be as F, pe as I, Me as M, Se as N, J as O, ve as P, We as S, He as T, ct as _, Dt as a, De as b, St as c, ft as d, dt as f, st as g, lt as h, Mt as i, Ne as j, ze as k, pt as l, Q as m, Ot as n, Nt as o, ot as p, Et as r, Ct as s, kt as t, ht as u, mt as v, Ve as w, je as x, U as y };
|