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