@kolkrabbi/design-editor 0.48.0 → 0.49.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/README.md +18 -0
- package/dist/{BindDot-Cx-M0iQt.js → BindDot-BAAc-KSs.js} +1 -1
- package/dist/{KolboxView-BjYfn_tl.js → KolboxView-DxcGz6MC.js} +3137 -5182
- package/dist/{Timeline-CRr43b4B.js → Timeline-BH3BF2m4.js} +2 -2
- package/dist/{TreePicker-DXsAlHK6.js → TreePicker-RImJ6I_0.js} +11 -11
- package/dist/{core-BbKj9Svq.js → core-DyfKZlBI.js} +2213 -2185
- package/dist/core.js +5 -5
- package/dist/design-editor.css +1 -1
- package/dist/design-editor.js +6 -6
- package/dist/{effectCategories-wHY9ih8L.js → effectCategories-B5jhXEyy.js} +21 -21
- package/dist/effects-BAwNQ8Kj.js +447 -0
- package/dist/effects.js +1 -1
- package/dist/{generators-BtRZ3Stj.js → generators-OCg5XjTX.js} +838 -838
- package/dist/generators.js +1 -1
- package/dist/{host-II9SeVCH.js → host-DS-pAjP0.js} +2 -2
- package/dist/kolbox-pages.js +2218 -0
- package/dist/kolbox.css +1 -1
- package/dist/{morphStore-s-rjCe-y.js → morphStore-D6xiYiR_.js} +1 -1
- package/dist/{motion-CKtZAccJ.js → motion-p5pHH9_J.js} +95 -95
- package/dist/motion.js +1 -1
- package/dist/portable-Bs8ieXiu.js +2128 -0
- package/dist/{rolls-Cnu6g8th.js → rolls-ZToBSscx.js} +1 -1
- package/dist/{src-3UkpFoNW.js → src-DEx6Oh0D.js} +416 -416
- package/dist/{store-YIW6P2zN.js → store-BDAxvWTE.js} +1 -1
- package/dist/{useLayerEdit-W_Tf3adq.js → useLayerEdit-D6vwfIoB.js} +90 -90
- package/package.json +9 -6
- package/dist/effects-D7J0e5xl.js +0 -447
|
@@ -0,0 +1,2128 @@
|
|
|
1
|
+
import { E as e, o as t, w as n } from "./__vite-browser-external-y2xWjzgx.js";
|
|
2
|
+
import { $ as r, A as i, B as a, E as o, Fn as s, Hn as c, J as l, Mt as u, Nr as d, O as f, Wn as p, X as m, Z as ee, q as h, xn as g, z as _ } from "./rolls-ZToBSscx.js";
|
|
3
|
+
import "./useLayerEdit-D6vwfIoB.js";
|
|
4
|
+
import "./effectCategories-B5jhXEyy.js";
|
|
5
|
+
import "./generators-OCg5XjTX.js";
|
|
6
|
+
import { g as v } from "./store-BDAxvWTE.js";
|
|
7
|
+
import { n as y, r as b } from "./BindDot-BAAc-KSs.js";
|
|
8
|
+
import { l as te } from "./Timeline-BH3BF2m4.js";
|
|
9
|
+
import { h as x } from "./src-DEx6Oh0D.js";
|
|
10
|
+
import { At as ne, C as re, E as ie, It as S, Pt as C, T as ae, Tt as w, _t as T, at as oe, bt as se, gt as ce, in as le, j as ue, rt as de, vt as fe, yt as pe, z as me } from "./core-DyfKZlBI.js";
|
|
11
|
+
import { t as he } from "./previewScale-C6EBx--U.js";
|
|
12
|
+
import { Button as E, ButtonGroup as ge, CommandOverlay as _e, Dropdown as ve, Input as ye, KbdKeys as be, LabeledControl as xe, LabeledControlSection as D, Menu as Se, ModalDialog as Ce, Slider as we, TabsRow as Te, ToggleSwitch as Ee, Tooltip as De, TreeRow as Oe, svgToPngBlob as ke, useModal as Ae } from "@kolkrabbi/kol-component";
|
|
13
|
+
import { useEffect as O, useMemo as je, useRef as k, useState as A, useSyncExternalStore as Me } from "react";
|
|
14
|
+
import { Fragment as Ne, jsx as j, jsxs as M } from "react/jsx-runtime";
|
|
15
|
+
import N from "@kolkrabbi/kol-component/utilities/kolboxGlyph";
|
|
16
|
+
//#region src/editor/kolbox/ui/ask.js
|
|
17
|
+
var P = null, Pe = (e) => new Promise((t) => P ? P("confirm", e, t) : t(!1)), Fe = (e) => new Promise((t) => P ? P("prompt", e, t) : t(null));
|
|
18
|
+
function Ie() {
|
|
19
|
+
let e = Ae(), t = k(null);
|
|
20
|
+
return O(() => {
|
|
21
|
+
let n = (n, r, i) => {
|
|
22
|
+
let a = n === "prompt" ? null : !1;
|
|
23
|
+
t.current?.resolve(t.current.empty);
|
|
24
|
+
let o = {
|
|
25
|
+
resolve: i,
|
|
26
|
+
empty: a
|
|
27
|
+
};
|
|
28
|
+
t.current = o, (n === "prompt" ? e.prompt(r.title, r.value ?? "", {
|
|
29
|
+
okLabel: r.action,
|
|
30
|
+
cancelLabel: r.cancel,
|
|
31
|
+
placeholder: r.placeholder
|
|
32
|
+
}) : r.cancel === null ? e.alert(r.title, {
|
|
33
|
+
okLabel: r.action,
|
|
34
|
+
body: r.message
|
|
35
|
+
}).then(() => !0) : e.confirm(r.title, {
|
|
36
|
+
okLabel: r.action,
|
|
37
|
+
cancelLabel: r.cancel,
|
|
38
|
+
body: r.message
|
|
39
|
+
})).then((e) => {
|
|
40
|
+
t.current === o && (t.current = null, i(e));
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
return P = n, () => {
|
|
44
|
+
P === n && (P = null);
|
|
45
|
+
};
|
|
46
|
+
}, [e]), null;
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/editor/compose/ContentScope.jsx
|
|
50
|
+
var Le = (e, t, n) => e.map((e) => e.id === t ? n : Array.isArray(e.children) ? {
|
|
51
|
+
...e,
|
|
52
|
+
children: Le(e.children, t, n)
|
|
53
|
+
} : e);
|
|
54
|
+
function Re({ hostId: e, rowKey: t, children: n }) {
|
|
55
|
+
let r = l(), i = g(r.layers, e), a = m(i).find((e) => e.key === t), o = je(() => i && a ? ee(i, a) : null, [i, a]), s = je(() => o ? {
|
|
56
|
+
...r,
|
|
57
|
+
layers: Le(r.layers, e, o),
|
|
58
|
+
updateLayer: (n, i) => n === e ? r.updateContent(e, t, i) : r.updateLayer(n, i)
|
|
59
|
+
} : r, [
|
|
60
|
+
r,
|
|
61
|
+
o,
|
|
62
|
+
e,
|
|
63
|
+
t
|
|
64
|
+
]);
|
|
65
|
+
return o ? /* @__PURE__ */ j(p.Provider, {
|
|
66
|
+
value: s,
|
|
67
|
+
children: n
|
|
68
|
+
}) : null;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/editor/kolbox/editor/engine.js
|
|
72
|
+
var ze = { "settings-drawer": "Mod+," }, Be = (e) => e && ze[e.id] ? {
|
|
73
|
+
...e,
|
|
74
|
+
combo: ze[e.id]
|
|
75
|
+
} : e, Ve = (e) => Be(pe(e)), He = (e) => se(e).map(({ section: e, items: t }) => ({
|
|
76
|
+
section: e,
|
|
77
|
+
items: t.map(Be)
|
|
78
|
+
})), Ue = ze["settings-drawer"], F = [
|
|
79
|
+
{
|
|
80
|
+
value: "all",
|
|
81
|
+
label: "Overview"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
value: "actions",
|
|
85
|
+
label: "Actions"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
value: "tools",
|
|
89
|
+
label: "Tools"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
value: "pages",
|
|
93
|
+
label: "Pages"
|
|
94
|
+
}
|
|
95
|
+
], We = [
|
|
96
|
+
"tool:text",
|
|
97
|
+
"tool:rect",
|
|
98
|
+
"tool:pen",
|
|
99
|
+
"action:View›Cards›Layers"
|
|
100
|
+
], I = [], Ge = (e) => {
|
|
101
|
+
I = [e, ...I.filter((t) => t !== e)].slice(0, 8);
|
|
102
|
+
};
|
|
103
|
+
function Ke(e) {
|
|
104
|
+
let t = [], n = (e, r) => (e ?? []).forEach((e) => (Array.isArray(e) ? e : e.rows ?? []).forEach((e) => {
|
|
105
|
+
if (!(!e || e.disabled)) {
|
|
106
|
+
if (e.submenu?.length) return n(e.submenu, [...r, e.label]);
|
|
107
|
+
typeof e.run != "function" || !e.label || t.push({
|
|
108
|
+
id: `action:${[...r, e.label].join("›")}`,
|
|
109
|
+
label: e.label,
|
|
110
|
+
icon: e.icon ?? "command",
|
|
111
|
+
hint: e.shortcut ?? r.join(" › "),
|
|
112
|
+
kbd: !!e.shortcut,
|
|
113
|
+
tab: "actions",
|
|
114
|
+
menu: r[0],
|
|
115
|
+
run: e.run
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}));
|
|
119
|
+
e.forEach((e) => n(e.groups, [e.label]));
|
|
120
|
+
let r = /* @__PURE__ */ new Set();
|
|
121
|
+
return t.filter((e) => r.has(e.id) ? !1 : r.add(e.id));
|
|
122
|
+
}
|
|
123
|
+
var qe = {
|
|
124
|
+
Plus: ["+", "Equal"],
|
|
125
|
+
Space: [" ", "Space"]
|
|
126
|
+
}, Je = {
|
|
127
|
+
",": "Comma",
|
|
128
|
+
".": "Period",
|
|
129
|
+
"/": "Slash",
|
|
130
|
+
"\\": "Backslash",
|
|
131
|
+
";": "Semicolon",
|
|
132
|
+
"'": "Quote",
|
|
133
|
+
"[": "BracketLeft",
|
|
134
|
+
"]": "BracketRight",
|
|
135
|
+
"-": "Minus",
|
|
136
|
+
"=": "Equal",
|
|
137
|
+
"`": "Backquote"
|
|
138
|
+
}, Ye = (e) => !!e && !e.includes("–");
|
|
139
|
+
function Xe(e) {
|
|
140
|
+
if (!Ye(e)) return;
|
|
141
|
+
if (e === "00") {
|
|
142
|
+
Xe("0"), Xe("0");
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
let t = e.split("+"), n = t.pop() || "+", r = t.includes("Mod"), i = t.includes("Shift") || n === "?", a = t.includes("Alt"), o = /Mac|iPhone|iPad/.test(navigator.platform), [s, c] = qe[n] ?? [n, n];
|
|
146
|
+
n.length === 1 && (s = /[a-z]/i.test(n) ? i ? n.toUpperCase() : n.toLowerCase() : n, c = /[a-z]/i.test(n) ? `Key${n.toUpperCase()}` : /[0-9]/.test(n) ? `Digit${n}` : Je[n] ?? "");
|
|
147
|
+
let l = {
|
|
148
|
+
key: s,
|
|
149
|
+
code: c,
|
|
150
|
+
shiftKey: i,
|
|
151
|
+
altKey: a,
|
|
152
|
+
metaKey: r && o,
|
|
153
|
+
ctrlKey: r && !o,
|
|
154
|
+
bubbles: !0,
|
|
155
|
+
cancelable: !0
|
|
156
|
+
};
|
|
157
|
+
document.body.dispatchEvent(new KeyboardEvent("keydown", l)), document.body.dispatchEvent(new KeyboardEvent("keyup", l));
|
|
158
|
+
}
|
|
159
|
+
function Ze({ menus: e = [], tools: t = [], layers: n = [], pages: r = [], files: i = [], shortcuts: a = [] }) {
|
|
160
|
+
return [
|
|
161
|
+
...i.map((e) => ({
|
|
162
|
+
id: `file:${e.id}`,
|
|
163
|
+
label: e.name,
|
|
164
|
+
icon: "file",
|
|
165
|
+
hint: e.hint,
|
|
166
|
+
tab: "files",
|
|
167
|
+
run: e.run
|
|
168
|
+
})),
|
|
169
|
+
...n.map((e) => ({
|
|
170
|
+
id: `layer:${e.id}`,
|
|
171
|
+
label: e.name,
|
|
172
|
+
icon: "layers",
|
|
173
|
+
hint: e.kind,
|
|
174
|
+
tab: "layers",
|
|
175
|
+
run: e.run
|
|
176
|
+
})),
|
|
177
|
+
...r.map((e) => ({
|
|
178
|
+
...e,
|
|
179
|
+
id: `page:${e.id}`,
|
|
180
|
+
tab: "pages"
|
|
181
|
+
})),
|
|
182
|
+
...a.flatMap((e) => e.items.map((t, n) => ({
|
|
183
|
+
id: `key:${e.section}:${t.id ?? n}:${t.combo}`,
|
|
184
|
+
label: t.label,
|
|
185
|
+
hint: t.keys,
|
|
186
|
+
kbd: !0,
|
|
187
|
+
tab: "shortcuts",
|
|
188
|
+
section: e.section,
|
|
189
|
+
run: Ye(t.combo) ? () => setTimeout(() => Xe(t.combo)) : void 0
|
|
190
|
+
}))),
|
|
191
|
+
...Ke(e),
|
|
192
|
+
...t.map((e) => ({
|
|
193
|
+
id: `tool:${e.id ?? e.label}`,
|
|
194
|
+
label: e.label,
|
|
195
|
+
icon: e.icon,
|
|
196
|
+
hint: e.kbd,
|
|
197
|
+
kbd: !!e.kbd,
|
|
198
|
+
tab: "tools",
|
|
199
|
+
run: e.run,
|
|
200
|
+
disabled: e.disabled,
|
|
201
|
+
disabledHint: e.disabledHint
|
|
202
|
+
}))
|
|
203
|
+
];
|
|
204
|
+
}
|
|
205
|
+
function Qe(e) {
|
|
206
|
+
let t = [];
|
|
207
|
+
return e.filter((e) => e.tab === "shortcuts").forEach((e) => {
|
|
208
|
+
let n = t[t.length - 1];
|
|
209
|
+
n?.label !== e.section && (n = {
|
|
210
|
+
id: `cat:${e.section}`,
|
|
211
|
+
label: e.section,
|
|
212
|
+
group: "Shortcuts",
|
|
213
|
+
tab: "shortcuts",
|
|
214
|
+
open: !0,
|
|
215
|
+
items: []
|
|
216
|
+
}, t.push(n)), n.items.push(e);
|
|
217
|
+
}), t;
|
|
218
|
+
}
|
|
219
|
+
function $e(e) {
|
|
220
|
+
let t = new Map(e.map((e) => [e.id, e])), n = [...I, ...We.filter((e) => !I.includes(e))].slice(0, 4);
|
|
221
|
+
return [
|
|
222
|
+
...e.filter((e) => e.tab === "files").map((e) => ({
|
|
223
|
+
...e,
|
|
224
|
+
group: "Files"
|
|
225
|
+
})),
|
|
226
|
+
...e.filter((e) => e.tab === "pages").map((e) => ({
|
|
227
|
+
...e,
|
|
228
|
+
group: "Pages"
|
|
229
|
+
})),
|
|
230
|
+
...Qe(e),
|
|
231
|
+
...n.map((e) => t.get(e)).filter(Boolean).map((e) => ({
|
|
232
|
+
...e,
|
|
233
|
+
id: `recent:${e.id}`,
|
|
234
|
+
group: "Recent",
|
|
235
|
+
key: e.id
|
|
236
|
+
})),
|
|
237
|
+
...e.filter((e) => e.tab === "actions" || e.tab === "tools").map((e) => ({
|
|
238
|
+
...e,
|
|
239
|
+
group: e.tab === "tools" ? "Tools" : e.menu,
|
|
240
|
+
tabOnly: !0
|
|
241
|
+
}))
|
|
242
|
+
];
|
|
243
|
+
}
|
|
244
|
+
var et = {
|
|
245
|
+
files: "Files",
|
|
246
|
+
layers: "Layers",
|
|
247
|
+
pages: "Pages",
|
|
248
|
+
shortcuts: "Shortcuts",
|
|
249
|
+
tools: "Tools",
|
|
250
|
+
actions: "Actions"
|
|
251
|
+
};
|
|
252
|
+
function tt(e, t) {
|
|
253
|
+
let n = t.trim().toLowerCase();
|
|
254
|
+
if (!n) return [];
|
|
255
|
+
let r = (e) => e.label.toLowerCase().includes(n), i = [
|
|
256
|
+
"files",
|
|
257
|
+
"layers",
|
|
258
|
+
"pages",
|
|
259
|
+
"shortcuts"
|
|
260
|
+
].flatMap((t) => e.filter((e) => e.tab === t && r(e))), a = e.filter((e) => e.tab === "tools" || e.tab === "actions").map((e) => ({
|
|
261
|
+
r: e,
|
|
262
|
+
at: e.label.toLowerCase().indexOf(n),
|
|
263
|
+
hinted: String(e.hint ?? "").toLowerCase().includes(n)
|
|
264
|
+
})).filter((e) => e.at >= 0 || e.hinted).sort((e, t) => (t.at === 0) - (e.at === 0)).slice(0, 40).map(({ r: e }) => e);
|
|
265
|
+
return [...i, ...a].map((e) => ({
|
|
266
|
+
...e,
|
|
267
|
+
group: et[e.tab]
|
|
268
|
+
}));
|
|
269
|
+
}
|
|
270
|
+
function nt(e, t) {
|
|
271
|
+
let n = (e) => t === F[0].value ? !e.tabOnly : e.tab === t, r = [], i = /* @__PURE__ */ new Map();
|
|
272
|
+
return e.filter(n).forEach((e) => {
|
|
273
|
+
let t = e.group ?? "";
|
|
274
|
+
i.has(t) || (i.set(t, {
|
|
275
|
+
title: t,
|
|
276
|
+
rows: []
|
|
277
|
+
}), r.push(i.get(t))), i.get(t).rows.push(e);
|
|
278
|
+
}), r;
|
|
279
|
+
}
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region src/editor/kolbox/editor/windows/WindowShortcuts.jsx
|
|
282
|
+
var rt = (e) => He(e).map(({ section: e, items: t }) => ({
|
|
283
|
+
section: e,
|
|
284
|
+
items: t.map((e) => ({
|
|
285
|
+
id: e.id,
|
|
286
|
+
label: e.label,
|
|
287
|
+
combo: e.combo,
|
|
288
|
+
keys: ce(e.combo)
|
|
289
|
+
}))
|
|
290
|
+
}));
|
|
291
|
+
function it({ view: e = "editor" }) {
|
|
292
|
+
return /* @__PURE__ */ j("div", {
|
|
293
|
+
"data-window": "shortcuts",
|
|
294
|
+
children: rt(e).map(({ section: e, items: t }) => /* @__PURE__ */ j(D, {
|
|
295
|
+
variant: "kolbox",
|
|
296
|
+
label: e,
|
|
297
|
+
children: t.map((e, t) => /* @__PURE__ */ j(xe, {
|
|
298
|
+
variant: "kolbox",
|
|
299
|
+
horizontal: !0,
|
|
300
|
+
label: e.label,
|
|
301
|
+
labelWidth: 160,
|
|
302
|
+
children: /* @__PURE__ */ j("span", {
|
|
303
|
+
className: "flex flex-1 justify-end",
|
|
304
|
+
"data-combo": !0,
|
|
305
|
+
children: /* @__PURE__ */ j(be, {
|
|
306
|
+
variant: "kolbox",
|
|
307
|
+
keys: e.keys,
|
|
308
|
+
size: "md"
|
|
309
|
+
})
|
|
310
|
+
})
|
|
311
|
+
}, `${e.id}-${t}`))
|
|
312
|
+
}, e))
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
function at({ onClose: e, view: t = "editor" }) {
|
|
316
|
+
let [n, r] = A(0);
|
|
317
|
+
return /* @__PURE__ */ j(_e, {
|
|
318
|
+
variant: "kolbox",
|
|
319
|
+
open: !0,
|
|
320
|
+
mode: "shortcuts",
|
|
321
|
+
onClose: e,
|
|
322
|
+
groups: [{
|
|
323
|
+
title: "Shortcuts",
|
|
324
|
+
rows: Qe(Ze({ shortcuts: rt(t) }))
|
|
325
|
+
}],
|
|
326
|
+
active: n,
|
|
327
|
+
onActive: r
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
//#endregion
|
|
331
|
+
//#region src/editor/kolbox/editor/windows/WindowSettings.jsx
|
|
332
|
+
var ot = s.map((e) => ({
|
|
333
|
+
value: e.id,
|
|
334
|
+
label: e.label
|
|
335
|
+
})).filter((e) => e.value !== "custom"), st = [{
|
|
336
|
+
value: "full",
|
|
337
|
+
label: "Full"
|
|
338
|
+
}, {
|
|
339
|
+
value: "half",
|
|
340
|
+
label: "Half"
|
|
341
|
+
}], ct = [
|
|
342
|
+
2,
|
|
343
|
+
4,
|
|
344
|
+
8,
|
|
345
|
+
12,
|
|
346
|
+
16
|
|
347
|
+
].map((e) => ({
|
|
348
|
+
value: e,
|
|
349
|
+
label: `${e} s`
|
|
350
|
+
})), lt = [
|
|
351
|
+
"kolcore",
|
|
352
|
+
"kolbox",
|
|
353
|
+
"minimal",
|
|
354
|
+
"folio"
|
|
355
|
+
], ut = (e) => {
|
|
356
|
+
document.documentElement.dataset.themeVariant = e;
|
|
357
|
+
try {
|
|
358
|
+
localStorage.setItem("kolbox-theme-variant", e);
|
|
359
|
+
} catch {}
|
|
360
|
+
};
|
|
361
|
+
function dt() {
|
|
362
|
+
let [e, t] = A(() => lt.includes(document.documentElement.dataset.themeVariant) ? document.documentElement.dataset.themeVariant : "kolbox");
|
|
363
|
+
return /* @__PURE__ */ j(R, {
|
|
364
|
+
label: "Theme",
|
|
365
|
+
options: lt,
|
|
366
|
+
value: e,
|
|
367
|
+
onChange: (e) => {
|
|
368
|
+
ut(e), t(e);
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
var ft = [
|
|
373
|
+
"dark",
|
|
374
|
+
"light",
|
|
375
|
+
"system"
|
|
376
|
+
], pt = (e) => {
|
|
377
|
+
let t = document.documentElement;
|
|
378
|
+
e === "system" ? delete t.dataset.theme : t.dataset.theme = e;
|
|
379
|
+
try {
|
|
380
|
+
localStorage.setItem("kol-theme", e);
|
|
381
|
+
} catch {}
|
|
382
|
+
};
|
|
383
|
+
function mt() {
|
|
384
|
+
let t = e();
|
|
385
|
+
return oe() === "kolbox" ? [["Style", /* @__PURE__ */ j(R, {
|
|
386
|
+
label: "Style",
|
|
387
|
+
options: de,
|
|
388
|
+
value: t.style ?? "default",
|
|
389
|
+
onChange: (e) => n("style", e)
|
|
390
|
+
})]] : [];
|
|
391
|
+
}
|
|
392
|
+
function ht() {
|
|
393
|
+
let [e, t] = A(() => document.documentElement.dataset.theme || "system");
|
|
394
|
+
return /* @__PURE__ */ j(R, {
|
|
395
|
+
label: "Mode",
|
|
396
|
+
options: ft,
|
|
397
|
+
value: e,
|
|
398
|
+
onChange: (e) => {
|
|
399
|
+
pt(e), t(e);
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
var gt = {
|
|
404
|
+
defaultAspect: "4:5",
|
|
405
|
+
defaultTheme: "kol",
|
|
406
|
+
autoplay: !1,
|
|
407
|
+
clipToFrame: !0,
|
|
408
|
+
defaultLoopSeconds: 4
|
|
409
|
+
}, _t = {
|
|
410
|
+
defaultAspect: "4:5",
|
|
411
|
+
defaultTheme: "kol",
|
|
412
|
+
autoplay: !1,
|
|
413
|
+
clipToFrame: !0,
|
|
414
|
+
labsModDots: !1,
|
|
415
|
+
defaultLoopSeconds: 4
|
|
416
|
+
}, vt = (e) => () => {
|
|
417
|
+
for (let [t, r] of Object.entries(e)) n(t, r);
|
|
418
|
+
t.setLoopSeconds(e.defaultLoopSeconds);
|
|
419
|
+
}, yt = {
|
|
420
|
+
name: "FXR",
|
|
421
|
+
about: "A DOM/SVG design compositor — frames, layers, vector tools — with generative, kinetic-type and effects layers on the same engine, served through three chromes: the Editor, Labs, and the Randomiser. Ships as a standalone app and as the embeddable @kolkrabbi/design-editor library.",
|
|
422
|
+
links: [
|
|
423
|
+
{
|
|
424
|
+
label: "GitHub",
|
|
425
|
+
url: "https://github.com/Tor-Grimsson/kol-fxr"
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
label: "Kolkrabbi",
|
|
429
|
+
url: "https://fxr.kolkrabbi.io"
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
label: "Vercel",
|
|
433
|
+
url: "https://vercel.com/tor-grimssons-projects/kol-fxr"
|
|
434
|
+
}
|
|
435
|
+
]
|
|
436
|
+
}, bt = [
|
|
437
|
+
{
|
|
438
|
+
value: "settings",
|
|
439
|
+
label: "Settings"
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
value: "shortcuts",
|
|
443
|
+
label: "Shortcuts"
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
value: "about",
|
|
447
|
+
label: "About"
|
|
448
|
+
}
|
|
449
|
+
], L = ({ label: e, on: t, onChange: n, disabled: r }) => /* @__PURE__ */ j("span", {
|
|
450
|
+
className: "flex flex-1 justify-end",
|
|
451
|
+
children: /* @__PURE__ */ j(Ee, {
|
|
452
|
+
variant: "kolbox",
|
|
453
|
+
"aria-label": e,
|
|
454
|
+
checked: !!t,
|
|
455
|
+
onChange: n,
|
|
456
|
+
disabled: r
|
|
457
|
+
})
|
|
458
|
+
}), R = ({ label: e, options: t, value: n, onChange: r }) => /* @__PURE__ */ j(ve, {
|
|
459
|
+
variant: "kolbox",
|
|
460
|
+
ariaLabel: e,
|
|
461
|
+
options: t,
|
|
462
|
+
value: n,
|
|
463
|
+
onChange: (e) => r(t.find((t) => String(t.value) === e)?.value ?? e),
|
|
464
|
+
className: "flex-1"
|
|
465
|
+
}), xt = ({ sections: e }) => e.map(([e, t], n) => /* @__PURE__ */ j(D, {
|
|
466
|
+
variant: "kolbox",
|
|
467
|
+
label: e,
|
|
468
|
+
children: t.map(([e, t]) => /* @__PURE__ */ j(xe, {
|
|
469
|
+
variant: "kolbox",
|
|
470
|
+
horizontal: !0,
|
|
471
|
+
label: e,
|
|
472
|
+
labelWidth: 160,
|
|
473
|
+
children: t
|
|
474
|
+
}, e))
|
|
475
|
+
}, `${e}-${n}`));
|
|
476
|
+
function St() {
|
|
477
|
+
let r = e(), i = b(), { showGrid: a, toggleGrid: o } = l(), s = d("generators"), c = mt();
|
|
478
|
+
return /* @__PURE__ */ j(xt, { sections: [
|
|
479
|
+
["Display", [
|
|
480
|
+
["Theme", /* @__PURE__ */ j(dt, {})],
|
|
481
|
+
["Mode", /* @__PURE__ */ j(ht, {})],
|
|
482
|
+
...c,
|
|
483
|
+
["Preview resolution", /* @__PURE__ */ j(R, {
|
|
484
|
+
label: "Preview resolution",
|
|
485
|
+
options: st,
|
|
486
|
+
value: r.previewRes,
|
|
487
|
+
onChange: (e) => n("previewRes", e)
|
|
488
|
+
})]
|
|
489
|
+
]],
|
|
490
|
+
["Defaults", [
|
|
491
|
+
["Default aspect", /* @__PURE__ */ j(R, {
|
|
492
|
+
label: "Default aspect",
|
|
493
|
+
options: ot,
|
|
494
|
+
value: r.defaultAspect,
|
|
495
|
+
onChange: (e) => n("defaultAspect", e)
|
|
496
|
+
})],
|
|
497
|
+
...s ? [["Loop theme", /* @__PURE__ */ j(R, {
|
|
498
|
+
label: "Loop theme",
|
|
499
|
+
options: s.THEME_OPTIONS,
|
|
500
|
+
value: r.defaultTheme,
|
|
501
|
+
onChange: (e) => n("defaultTheme", e)
|
|
502
|
+
})]] : [],
|
|
503
|
+
["Clip to frame", /* @__PURE__ */ j(L, {
|
|
504
|
+
label: "Clip to frame",
|
|
505
|
+
on: r.clipToFrame,
|
|
506
|
+
onChange: (e) => n("clipToFrame", e)
|
|
507
|
+
})],
|
|
508
|
+
["Modulation dots", /* @__PURE__ */ j(L, {
|
|
509
|
+
label: "Modulation dots",
|
|
510
|
+
on: i,
|
|
511
|
+
onChange: (e) => {
|
|
512
|
+
e !== i && y();
|
|
513
|
+
}
|
|
514
|
+
})]
|
|
515
|
+
]],
|
|
516
|
+
["Canvas", [
|
|
517
|
+
["Grab (C)", /* @__PURE__ */ j(L, {
|
|
518
|
+
label: "Grab (C)",
|
|
519
|
+
on: r.grab,
|
|
520
|
+
onChange: (e) => n("grab", e)
|
|
521
|
+
})],
|
|
522
|
+
["Interactions", /* @__PURE__ */ j(L, {
|
|
523
|
+
label: "Interactions",
|
|
524
|
+
on: r.interactions !== !1,
|
|
525
|
+
onChange: (e) => n("interactions", e)
|
|
526
|
+
})],
|
|
527
|
+
["Zoom lock (Z)", /* @__PURE__ */ j(L, {
|
|
528
|
+
label: "Zoom lock (Z)",
|
|
529
|
+
on: r.zoomLock,
|
|
530
|
+
onChange: (e) => n("zoomLock", e)
|
|
531
|
+
})]
|
|
532
|
+
]],
|
|
533
|
+
["Transport", [["Autoplay", /* @__PURE__ */ j(L, {
|
|
534
|
+
label: "Autoplay",
|
|
535
|
+
on: r.autoplay,
|
|
536
|
+
onChange: (e) => n("autoplay", e)
|
|
537
|
+
})], ["Loop length", /* @__PURE__ */ j(R, {
|
|
538
|
+
label: "Loop length",
|
|
539
|
+
options: ct,
|
|
540
|
+
value: r.defaultLoopSeconds,
|
|
541
|
+
onChange: (e) => {
|
|
542
|
+
n("defaultLoopSeconds", e), t.setLoopSeconds(e);
|
|
543
|
+
}
|
|
544
|
+
})]]],
|
|
545
|
+
["Canvas", [["Show grid", /* @__PURE__ */ j(L, {
|
|
546
|
+
label: "Show grid",
|
|
547
|
+
on: a,
|
|
548
|
+
onChange: o
|
|
549
|
+
})]]]
|
|
550
|
+
] });
|
|
551
|
+
}
|
|
552
|
+
function Ct() {
|
|
553
|
+
let r = e(), i = d("generators"), a = mt();
|
|
554
|
+
return /* @__PURE__ */ j(xt, { sections: [
|
|
555
|
+
["Display", [
|
|
556
|
+
["Theme", /* @__PURE__ */ j(dt, {})],
|
|
557
|
+
["Mode", /* @__PURE__ */ j(ht, {})],
|
|
558
|
+
...a
|
|
559
|
+
]],
|
|
560
|
+
["Defaults", [
|
|
561
|
+
["Default aspect", /* @__PURE__ */ j(R, {
|
|
562
|
+
label: "Default aspect",
|
|
563
|
+
options: ot,
|
|
564
|
+
value: r.defaultAspect,
|
|
565
|
+
onChange: (e) => n("defaultAspect", e)
|
|
566
|
+
})],
|
|
567
|
+
...i ? [["Loop theme", /* @__PURE__ */ j(R, {
|
|
568
|
+
label: "Loop theme",
|
|
569
|
+
options: i.THEME_OPTIONS,
|
|
570
|
+
value: r.defaultTheme,
|
|
571
|
+
onChange: (e) => n("defaultTheme", e)
|
|
572
|
+
})]] : [],
|
|
573
|
+
["Clip to frame", /* @__PURE__ */ j(L, {
|
|
574
|
+
label: "Clip to frame",
|
|
575
|
+
on: r.clipToFrame,
|
|
576
|
+
onChange: (e) => n("clipToFrame", e)
|
|
577
|
+
})],
|
|
578
|
+
["Modulation dots", /* @__PURE__ */ j(L, {
|
|
579
|
+
label: "Modulation dots",
|
|
580
|
+
on: r.labsModDots,
|
|
581
|
+
onChange: (e) => n("labsModDots", e)
|
|
582
|
+
})]
|
|
583
|
+
]],
|
|
584
|
+
["Transport", [["Autoplay", /* @__PURE__ */ j(L, {
|
|
585
|
+
label: "Autoplay",
|
|
586
|
+
on: r.autoplay,
|
|
587
|
+
onChange: (e) => n("autoplay", e)
|
|
588
|
+
})], ["Loop length", /* @__PURE__ */ j(R, {
|
|
589
|
+
label: "Loop length",
|
|
590
|
+
options: ct,
|
|
591
|
+
value: r.defaultLoopSeconds,
|
|
592
|
+
onChange: (e) => {
|
|
593
|
+
n("defaultLoopSeconds", e), t.setLoopSeconds(e);
|
|
594
|
+
}
|
|
595
|
+
})]]]
|
|
596
|
+
] });
|
|
597
|
+
}
|
|
598
|
+
function wt() {
|
|
599
|
+
return /* @__PURE__ */ M("div", {
|
|
600
|
+
"data-window": "about",
|
|
601
|
+
children: [
|
|
602
|
+
/* @__PURE__ */ j(D, {
|
|
603
|
+
variant: "kolbox",
|
|
604
|
+
label: yt.name,
|
|
605
|
+
children: /* @__PURE__ */ j("p", {
|
|
606
|
+
className: "font-mono text-value text-muted",
|
|
607
|
+
children: yt.about
|
|
608
|
+
})
|
|
609
|
+
}),
|
|
610
|
+
/* @__PURE__ */ j(D, {
|
|
611
|
+
variant: "kolbox",
|
|
612
|
+
label: "Links",
|
|
613
|
+
children: yt.links.map((e) => /* @__PURE__ */ j(xe, {
|
|
614
|
+
variant: "kolbox",
|
|
615
|
+
horizontal: !0,
|
|
616
|
+
label: e.label,
|
|
617
|
+
children: /* @__PURE__ */ j("a", {
|
|
618
|
+
href: e.url,
|
|
619
|
+
target: "_blank",
|
|
620
|
+
rel: "noopener noreferrer",
|
|
621
|
+
className: "min-w-0 font-mono text-value break-all text-text hover:underline",
|
|
622
|
+
children: e.url
|
|
623
|
+
})
|
|
624
|
+
}, e.label))
|
|
625
|
+
}),
|
|
626
|
+
/* @__PURE__ */ j(D, {
|
|
627
|
+
variant: "kolbox",
|
|
628
|
+
children: /* @__PURE__ */ M("span", {
|
|
629
|
+
className: "flex flex-col font-mono text-value text-muted",
|
|
630
|
+
children: [/* @__PURE__ */ j("span", { children: "Kolkrabbi Vinnustofa" }), /* @__PURE__ */ j("span", { children: (/* @__PURE__ */ new Date()).getFullYear() })]
|
|
631
|
+
})
|
|
632
|
+
})
|
|
633
|
+
]
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
function Tt({ onClose: e, view: t = "editor", tab: n = "settings" }) {
|
|
637
|
+
let [r, i] = A(n), a = t === "editor";
|
|
638
|
+
return /* @__PURE__ */ M(Ce, {
|
|
639
|
+
variant: "kolbox",
|
|
640
|
+
open: !0,
|
|
641
|
+
onClose: e,
|
|
642
|
+
title: a ? "Display settings" : "Settings",
|
|
643
|
+
className: "h-modal-generator-height",
|
|
644
|
+
footer: /* @__PURE__ */ j(De, {
|
|
645
|
+
variant: "kolbox",
|
|
646
|
+
label: "Reset to defaults",
|
|
647
|
+
children: /* @__PURE__ */ j(E, {
|
|
648
|
+
variant: "kolbox",
|
|
649
|
+
iconOnly: "refresh",
|
|
650
|
+
"aria-label": "Reset to defaults",
|
|
651
|
+
onClick: vt(a ? gt : _t)
|
|
652
|
+
})
|
|
653
|
+
}),
|
|
654
|
+
children: [/* @__PURE__ */ j("div", {
|
|
655
|
+
className: "shrink-0 px-4 pb-2",
|
|
656
|
+
children: /* @__PURE__ */ j(Te, {
|
|
657
|
+
variant: "kolbox",
|
|
658
|
+
tabs: bt,
|
|
659
|
+
value: r,
|
|
660
|
+
onChange: i,
|
|
661
|
+
className: "w-full"
|
|
662
|
+
})
|
|
663
|
+
}), /* @__PURE__ */ j("div", {
|
|
664
|
+
"data-window": "settings",
|
|
665
|
+
"data-tab": r,
|
|
666
|
+
children: r === "settings" ? j(a ? St : Ct, {}) : r === "shortcuts" ? /* @__PURE__ */ j(it, { view: t }) : /* @__PURE__ */ j(wt, {})
|
|
667
|
+
})]
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
//#endregion
|
|
671
|
+
//#region src/editor/kolbox/app/sampleMedia.js
|
|
672
|
+
var Et = "Sample library: the app hosting the editor has connected no media.", z = (e) => `data:image/svg+xml;utf8,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="800" height="1000" viewBox="0 0 800 1000">${e}</svg>`)}`, Dt = [
|
|
673
|
+
["sample/circle.svg", z("<rect width=\"800\" height=\"1000\" fill=\"#1b1b1b\"/><circle cx=\"400\" cy=\"500\" r=\"260\" fill=\"#f2c230\"/>")],
|
|
674
|
+
["sample/stripes.svg", z("<rect width=\"800\" height=\"1000\" fill=\"#ece8df\"/>" + Array.from({ length: 10 }, (e, t) => `<rect y="${t * 100}" width="800" height="50" fill="#9c4a1e"/>`).join(""))],
|
|
675
|
+
["sample/grid.svg", z("<rect width=\"800\" height=\"1000\" fill=\"#22303c\"/>" + Array.from({ length: 20 }, (e, t) => `<circle cx="${100 + t % 4 * 200}" cy="${100 + Math.floor(t / 4) * 200}" r="60" fill="#8fb3d9"/>`).join(""))],
|
|
676
|
+
["sample/blocks.svg", z("<rect width=\"800\" height=\"1000\" fill=\"#f4f1ea\"/><rect x=\"80\" y=\"120\" width=\"380\" height=\"380\" fill=\"#1f3a5f\"/><rect x=\"340\" y=\"420\" width=\"380\" height=\"460\" fill=\"#d94f30\"/>")]
|
|
677
|
+
], Ot = new Map(Dt), kt = {
|
|
678
|
+
sample: !0,
|
|
679
|
+
buckets: () => [{
|
|
680
|
+
id: "sample",
|
|
681
|
+
label: "Sample library"
|
|
682
|
+
}],
|
|
683
|
+
listMedia: async (e = "") => Dt.filter(([t]) => t.startsWith(e)).map(([e, t]) => ({
|
|
684
|
+
key: e,
|
|
685
|
+
size: t.length,
|
|
686
|
+
contentType: "image/svg+xml",
|
|
687
|
+
lastModified: "2026-11-20T00:00:00Z"
|
|
688
|
+
})),
|
|
689
|
+
mediaUrl: (e) => Ot.get(e) ?? "",
|
|
690
|
+
proxied: (e) => e
|
|
691
|
+
}, B = (e) => (e?.contentType ?? "").split("/")[0], V = (e) => e.replace(/\/$/, "").split("/").pop(), At = [
|
|
692
|
+
[
|
|
693
|
+
"columns",
|
|
694
|
+
"columns",
|
|
695
|
+
"Columns"
|
|
696
|
+
],
|
|
697
|
+
[
|
|
698
|
+
"rows",
|
|
699
|
+
"row",
|
|
700
|
+
"Rows"
|
|
701
|
+
],
|
|
702
|
+
[
|
|
703
|
+
"grid",
|
|
704
|
+
"grid",
|
|
705
|
+
"Grid"
|
|
706
|
+
]
|
|
707
|
+
], jt = ({ label: e, children: t }) => /* @__PURE__ */ j(De, {
|
|
708
|
+
variant: "kolbox",
|
|
709
|
+
label: e,
|
|
710
|
+
children: t
|
|
711
|
+
});
|
|
712
|
+
function Mt(e, t) {
|
|
713
|
+
let n = /* @__PURE__ */ new Set(), r = [];
|
|
714
|
+
for (let i of e) {
|
|
715
|
+
if (!i.key.startsWith(t)) continue;
|
|
716
|
+
let e = i.key.slice(t.length), a = e.indexOf("/");
|
|
717
|
+
a >= 0 ? n.add(t + e.slice(0, a + 1)) : r.push(i);
|
|
718
|
+
}
|
|
719
|
+
return {
|
|
720
|
+
folders: [...n].sort(),
|
|
721
|
+
files: r.sort((e, t) => e.key.localeCompare(t.key))
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
function Nt({ open: e, accept: t = ["image", "video"], onClose: n, onSelect: r }) {
|
|
725
|
+
let i = ie(), a = je(() => i.buckets?.() ?? [], [i]), [o, s] = A(a[0]?.id), [c, l] = A([]), [u, d] = A(""), [f, p] = A(null), [m, ee] = A("columns"), [h, g] = A(!1), [_, v] = A(""), [y, b] = A(96);
|
|
726
|
+
O(() => {
|
|
727
|
+
if (!e) return;
|
|
728
|
+
let t = !0;
|
|
729
|
+
return d(""), p(null), v(""), Promise.resolve(i.listMedia("", { bucket: o })).then((e) => t && l(e ?? [])), () => {
|
|
730
|
+
t = !1;
|
|
731
|
+
};
|
|
732
|
+
}, [
|
|
733
|
+
e,
|
|
734
|
+
o,
|
|
735
|
+
i
|
|
736
|
+
]);
|
|
737
|
+
let te = !!f && (typeof t == "function" ? t(f) : t.includes(B(f))), x = (e = f) => {
|
|
738
|
+
e && (r?.(i.mediaUrl(e.fullKey ?? e.key, o), {
|
|
739
|
+
contentType: e.contentType,
|
|
740
|
+
kind: B(e)
|
|
741
|
+
}), n?.());
|
|
742
|
+
}, ne = k(null);
|
|
743
|
+
ne.current = te ? () => x() : null, O(() => {
|
|
744
|
+
if (!e) return;
|
|
745
|
+
let t = (e) => {
|
|
746
|
+
e.key !== "Enter" || e.metaKey || e.ctrlKey || e.altKey || e.target?.closest?.("input, textarea, button, [contenteditable=\"true\"]") || !ne.current || (e.preventDefault(), e.stopPropagation(), ne.current());
|
|
747
|
+
};
|
|
748
|
+
return window.addEventListener("keydown", t, !0), () => window.removeEventListener("keydown", t, !0);
|
|
749
|
+
}, [e]);
|
|
750
|
+
let re = a.find((e) => e.id === o)?.label ?? o, S = u ? u.replace(/\/$/, "").split("/") : [], C = _.trim().toLowerCase(), w = C ? {
|
|
751
|
+
folders: [],
|
|
752
|
+
files: c.filter((e) => e.key.toLowerCase().includes(C))
|
|
753
|
+
} : Mt(c, u), T = c.reduce((e, t) => e + (t.size ?? 0), 0), oe = (e, t) => B(e) === "image" ? /* @__PURE__ */ j("img", {
|
|
754
|
+
src: i.mediaUrl(e.key, o),
|
|
755
|
+
alt: "",
|
|
756
|
+
loading: "lazy",
|
|
757
|
+
className: `object-cover ${t}`
|
|
758
|
+
}) : /* @__PURE__ */ j("span", {
|
|
759
|
+
className: `flex items-center justify-center bg-field text-muted ${t}`,
|
|
760
|
+
children: /* @__PURE__ */ j(N, { name: B(e) === "video" ? "video" : "file" })
|
|
761
|
+
}), se = (e) => /* @__PURE__ */ j(Oe, {
|
|
762
|
+
variant: "kolbox",
|
|
763
|
+
icon: B(e) === "image" ? "image" : B(e) === "video" ? "video" : "file",
|
|
764
|
+
label: V(e.key),
|
|
765
|
+
active: f?.key === e.key,
|
|
766
|
+
onClick: () => p(e),
|
|
767
|
+
onDoubleClick: () => (typeof t == "function" ? t(e) : t.includes(B(e))) && x(e),
|
|
768
|
+
trailing: /* @__PURE__ */ j("span", {
|
|
769
|
+
className: "shrink-0 font-mono text-meta text-muted",
|
|
770
|
+
children: ae?.(e.size) ?? e.size
|
|
771
|
+
}),
|
|
772
|
+
"data-media-file": e.key
|
|
773
|
+
}, e.key), ce = (e, t) => /* @__PURE__ */ j(Oe, {
|
|
774
|
+
variant: "kolbox",
|
|
775
|
+
icon: "folder",
|
|
776
|
+
label: V(e),
|
|
777
|
+
active: t,
|
|
778
|
+
onClick: () => {
|
|
779
|
+
d(e), p(null);
|
|
780
|
+
},
|
|
781
|
+
trailing: /* @__PURE__ */ j(N, {
|
|
782
|
+
name: "chevron-right",
|
|
783
|
+
size: 12,
|
|
784
|
+
className: "text-muted"
|
|
785
|
+
}),
|
|
786
|
+
"data-media-folder": e
|
|
787
|
+
}, e), le = () => m === "grid" ? /* @__PURE__ */ M("div", {
|
|
788
|
+
className: "grid gap-2 p-2",
|
|
789
|
+
style: { gridTemplateColumns: `repeat(auto-fill, minmax(${y}px, 1fr))` },
|
|
790
|
+
children: [w.folders.map((e) => /* @__PURE__ */ M("button", {
|
|
791
|
+
type: "button",
|
|
792
|
+
onClick: () => {
|
|
793
|
+
d(e), p(null);
|
|
794
|
+
},
|
|
795
|
+
"data-media-folder": e,
|
|
796
|
+
className: "flex flex-col gap-1 rounded-control p-1 text-left outline-none hover:bg-field focus-visible:outline-solid focus-visible:outline-1 focus-visible:outline-accent",
|
|
797
|
+
children: [/* @__PURE__ */ j("span", {
|
|
798
|
+
className: "flex aspect-square w-full items-center justify-center rounded-control bg-field text-muted",
|
|
799
|
+
children: /* @__PURE__ */ j(N, { name: "folder" })
|
|
800
|
+
}), /* @__PURE__ */ j("span", {
|
|
801
|
+
className: "truncate text-label text-text",
|
|
802
|
+
children: V(e)
|
|
803
|
+
})]
|
|
804
|
+
}, e)), w.files.map((e) => /* @__PURE__ */ M("button", {
|
|
805
|
+
type: "button",
|
|
806
|
+
onClick: () => p(e),
|
|
807
|
+
onDoubleClick: () => (typeof t == "function" ? t(e) : t.includes(B(e))) && x(e),
|
|
808
|
+
"data-media-file": e.key,
|
|
809
|
+
className: `flex flex-col gap-1 rounded-control p-1 text-left outline-none focus-visible:outline-solid focus-visible:outline-1 focus-visible:outline-accent ${f?.key === e.key ? "bg-accent-tint" : "hover:bg-field"}`,
|
|
810
|
+
children: [oe(e, "aspect-square w-full rounded-control"), /* @__PURE__ */ j("span", {
|
|
811
|
+
className: `truncate text-label ${f?.key === e.key ? "text-accent" : "text-text"}`,
|
|
812
|
+
children: V(e.key)
|
|
813
|
+
})]
|
|
814
|
+
}, e.key))]
|
|
815
|
+
}) : m === "rows" ? /* @__PURE__ */ M("div", {
|
|
816
|
+
className: "flex flex-col gap-1 p-2",
|
|
817
|
+
children: [w.folders.map((e) => ce(e, !1)), w.files.map(se)]
|
|
818
|
+
}) : /* @__PURE__ */ M("div", {
|
|
819
|
+
className: "flex h-full",
|
|
820
|
+
children: [(C ? [{
|
|
821
|
+
p: "",
|
|
822
|
+
...w
|
|
823
|
+
}] : ["", ...S.map((e, t) => `${S.slice(0, t + 1).join("/")}/`)].map((e) => ({
|
|
824
|
+
p: e,
|
|
825
|
+
...Mt(c, e)
|
|
826
|
+
}))).map(({ p: e, folders: t, files: n }) => /* @__PURE__ */ M("div", {
|
|
827
|
+
className: "flex w-56 shrink-0 flex-col gap-1 overflow-y-auto p-2",
|
|
828
|
+
"data-media-column": e,
|
|
829
|
+
children: [t.map((e) => ce(e, u.startsWith(e))), n.map(se)]
|
|
830
|
+
}, e)), /* @__PURE__ */ M("div", {
|
|
831
|
+
className: "flex min-w-0 flex-1 flex-col items-center justify-center gap-2 p-4",
|
|
832
|
+
"data-media-preview": !0,
|
|
833
|
+
children: [f && oe(f, "max-h-64 w-full rounded-well object-contain"), f && /* @__PURE__ */ j("span", {
|
|
834
|
+
className: "font-mono text-meta text-muted",
|
|
835
|
+
children: ae?.(f.size) ?? f.size
|
|
836
|
+
})]
|
|
837
|
+
})]
|
|
838
|
+
});
|
|
839
|
+
return /* @__PURE__ */ j(Ce, {
|
|
840
|
+
variant: "kolbox",
|
|
841
|
+
open: e,
|
|
842
|
+
onClose: n,
|
|
843
|
+
title: "Media",
|
|
844
|
+
width: "var(--spacing-modal-wide)",
|
|
845
|
+
className: "h-modal-generator-height",
|
|
846
|
+
actions: /* @__PURE__ */ M(Ne, { children: [/* @__PURE__ */ j(ve, {
|
|
847
|
+
variant: "kolbox",
|
|
848
|
+
ariaLabel: "Bucket",
|
|
849
|
+
value: o,
|
|
850
|
+
options: a.map((e) => ({
|
|
851
|
+
value: e.id,
|
|
852
|
+
label: e.label ?? e.id
|
|
853
|
+
})),
|
|
854
|
+
onChange: s,
|
|
855
|
+
className: "w-44"
|
|
856
|
+
}), /* @__PURE__ */ j(jt, {
|
|
857
|
+
label: "Display settings are in the Library",
|
|
858
|
+
children: /* @__PURE__ */ j(E, {
|
|
859
|
+
variant: "kolbox",
|
|
860
|
+
iconOnly: "gear",
|
|
861
|
+
"aria-label": "Display settings",
|
|
862
|
+
disabled: !0
|
|
863
|
+
})
|
|
864
|
+
})] }),
|
|
865
|
+
footer: /* @__PURE__ */ M(Ne, { children: [
|
|
866
|
+
/* @__PURE__ */ j("span", {
|
|
867
|
+
className: "mr-auto min-w-0 truncate font-mono text-meta text-muted",
|
|
868
|
+
"data-media-picked": !0,
|
|
869
|
+
children: f ? f.key : "Select a file"
|
|
870
|
+
}),
|
|
871
|
+
/* @__PURE__ */ j(E, {
|
|
872
|
+
variant: "kolbox",
|
|
873
|
+
tone: "ghost",
|
|
874
|
+
onClick: n,
|
|
875
|
+
children: "Cancel"
|
|
876
|
+
}),
|
|
877
|
+
te ? /* @__PURE__ */ j(E, {
|
|
878
|
+
variant: "kolbox",
|
|
879
|
+
tone: "primary",
|
|
880
|
+
onClick: () => x(),
|
|
881
|
+
"data-media-use": !0,
|
|
882
|
+
children: "Use"
|
|
883
|
+
}) : /* @__PURE__ */ j(jt, {
|
|
884
|
+
label: f ? "This file is not a kind this place takes" : "Select a file first",
|
|
885
|
+
children: /* @__PURE__ */ j(E, {
|
|
886
|
+
variant: "kolbox",
|
|
887
|
+
tone: "primary",
|
|
888
|
+
disabled: !0,
|
|
889
|
+
"data-media-use": !0,
|
|
890
|
+
children: "Use"
|
|
891
|
+
})
|
|
892
|
+
})
|
|
893
|
+
] }),
|
|
894
|
+
children: /* @__PURE__ */ M("div", {
|
|
895
|
+
className: "flex min-h-0 flex-1 flex-col gap-2 px-4 pb-4",
|
|
896
|
+
"data-window": "media-picker",
|
|
897
|
+
children: [
|
|
898
|
+
i.sample && /* @__PURE__ */ j("p", {
|
|
899
|
+
className: "shrink-0 text-help text-muted",
|
|
900
|
+
"data-media-sample": !0,
|
|
901
|
+
children: "Sample library: the app hosting the editor has connected no media."
|
|
902
|
+
}),
|
|
903
|
+
/* @__PURE__ */ M("div", {
|
|
904
|
+
className: "flex h-control shrink-0 items-center gap-2",
|
|
905
|
+
children: [
|
|
906
|
+
/* @__PURE__ */ j("nav", {
|
|
907
|
+
className: "flex min-w-0 flex-1 items-center gap-1 truncate text-label",
|
|
908
|
+
"data-media-crumbs": !0,
|
|
909
|
+
children: [
|
|
910
|
+
["Media", null],
|
|
911
|
+
[re, ""],
|
|
912
|
+
...S.map((e, t) => [e, `${S.slice(0, t + 1).join("/")}/`])
|
|
913
|
+
].map(([e, t], n, r) => /* @__PURE__ */ M("span", {
|
|
914
|
+
className: "flex items-center gap-1",
|
|
915
|
+
children: [n > 0 && /* @__PURE__ */ j("span", {
|
|
916
|
+
className: "text-muted",
|
|
917
|
+
children: "/"
|
|
918
|
+
}), t === null ? /* @__PURE__ */ j("span", {
|
|
919
|
+
className: "truncate text-muted",
|
|
920
|
+
children: e
|
|
921
|
+
}) : /* @__PURE__ */ j("button", {
|
|
922
|
+
type: "button",
|
|
923
|
+
onClick: () => {
|
|
924
|
+
d(t), p(null);
|
|
925
|
+
},
|
|
926
|
+
className: `truncate outline-none focus-visible:outline-solid focus-visible:outline-1 focus-visible:outline-accent ${n === r.length - 1 ? "text-text" : "text-muted hover:text-text"}`,
|
|
927
|
+
children: e
|
|
928
|
+
})]
|
|
929
|
+
}, n))
|
|
930
|
+
}),
|
|
931
|
+
h && /* @__PURE__ */ j(ye, {
|
|
932
|
+
variant: "kolbox",
|
|
933
|
+
size: "md",
|
|
934
|
+
iconLeft: "search",
|
|
935
|
+
placeholder: "Search this bucket",
|
|
936
|
+
"aria-label": "Search this bucket",
|
|
937
|
+
value: _,
|
|
938
|
+
onChange: (e) => v(e.target.value),
|
|
939
|
+
autoFocus: !0,
|
|
940
|
+
className: "w-56"
|
|
941
|
+
}),
|
|
942
|
+
/* @__PURE__ */ j(jt, {
|
|
943
|
+
label: "Filters are in the Library; Search finds by name here",
|
|
944
|
+
children: /* @__PURE__ */ j(E, {
|
|
945
|
+
variant: "kolbox",
|
|
946
|
+
iconOnly: "filter",
|
|
947
|
+
"aria-label": "Filter",
|
|
948
|
+
disabled: !0
|
|
949
|
+
})
|
|
950
|
+
}),
|
|
951
|
+
/* @__PURE__ */ j(E, {
|
|
952
|
+
variant: "kolbox",
|
|
953
|
+
iconOnly: "search",
|
|
954
|
+
"aria-label": "Search",
|
|
955
|
+
pressed: h,
|
|
956
|
+
onClick: () => {
|
|
957
|
+
g((e) => !e), v("");
|
|
958
|
+
}
|
|
959
|
+
}),
|
|
960
|
+
/* @__PURE__ */ j(ge, {
|
|
961
|
+
layout: "joined",
|
|
962
|
+
variant: "kolbox",
|
|
963
|
+
options: At.map(([e, t, n]) => ({
|
|
964
|
+
icon: t,
|
|
965
|
+
ariaLabel: n,
|
|
966
|
+
pressed: m === e,
|
|
967
|
+
onPress: () => ee(e)
|
|
968
|
+
}))
|
|
969
|
+
})
|
|
970
|
+
]
|
|
971
|
+
}),
|
|
972
|
+
/* @__PURE__ */ j("div", {
|
|
973
|
+
className: "min-h-0 flex-1 overflow-auto rounded-well bg-ground",
|
|
974
|
+
"data-media-listing": m,
|
|
975
|
+
children: le()
|
|
976
|
+
}),
|
|
977
|
+
/* @__PURE__ */ M("div", {
|
|
978
|
+
className: "flex h-control shrink-0 items-center gap-2",
|
|
979
|
+
children: [/* @__PURE__ */ j("span", {
|
|
980
|
+
className: "min-w-0 flex-1 truncate font-mono text-meta text-muted",
|
|
981
|
+
"data-media-count": !0,
|
|
982
|
+
children: `${w.folders.length} ${w.folders.length === 1 ? "folder" : "folders"}, ${w.files.length} ${w.files.length === 1 ? "file" : "files"}, ${ae?.(T) ?? T}`
|
|
983
|
+
}), /* @__PURE__ */ j(we, {
|
|
984
|
+
variant: "kolbox",
|
|
985
|
+
"aria-label": "Row size",
|
|
986
|
+
value: y,
|
|
987
|
+
min: 48,
|
|
988
|
+
max: 192,
|
|
989
|
+
step: 8,
|
|
990
|
+
onChange: b,
|
|
991
|
+
formatValue: (e) => `${e}`,
|
|
992
|
+
className: "w-40"
|
|
993
|
+
})]
|
|
994
|
+
})
|
|
995
|
+
]
|
|
996
|
+
})
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
var H = null, Pt = (e = {}) => new Promise((t) => H ? H({
|
|
1000
|
+
...e,
|
|
1001
|
+
resolve: t
|
|
1002
|
+
}) : t(null));
|
|
1003
|
+
function Ft() {
|
|
1004
|
+
let { addLayer: e, updateLayer: t, beginTransaction: n, commitTransaction: r, layers: i } = l(), [o, s] = A(null), c = k(null);
|
|
1005
|
+
O(() => {
|
|
1006
|
+
let e = (e) => {
|
|
1007
|
+
c.current?.resolve(null), c.current = e, s(e);
|
|
1008
|
+
};
|
|
1009
|
+
return H = e, () => {
|
|
1010
|
+
H === e && (H = null);
|
|
1011
|
+
};
|
|
1012
|
+
}, []);
|
|
1013
|
+
let u = (e) => {
|
|
1014
|
+
let t = c.current;
|
|
1015
|
+
c.current = null, s(null), t?.resolve(e);
|
|
1016
|
+
};
|
|
1017
|
+
return /* @__PURE__ */ j(Nt, {
|
|
1018
|
+
open: !!o,
|
|
1019
|
+
accept: o?.accept,
|
|
1020
|
+
onClose: () => c.current && u(null),
|
|
1021
|
+
onSelect: (o, { contentType: s, kind: l } = {}) => {
|
|
1022
|
+
let d = c.current, f = ue(o), p = l === "video" ? "video" : "image";
|
|
1023
|
+
if (d?.place === !1) {
|
|
1024
|
+
u({
|
|
1025
|
+
url: o,
|
|
1026
|
+
contentType: s,
|
|
1027
|
+
kind: l
|
|
1028
|
+
});
|
|
1029
|
+
return;
|
|
1030
|
+
}
|
|
1031
|
+
if (d?.layerId && d.fill) {
|
|
1032
|
+
let e = g(i, d.layerId)?.fill, a = e?.type === "image" || e?.type === "video" ? e : {
|
|
1033
|
+
type: "image",
|
|
1034
|
+
fit: "cover"
|
|
1035
|
+
};
|
|
1036
|
+
n(), t(d.layerId, { fill: {
|
|
1037
|
+
...a,
|
|
1038
|
+
src: f,
|
|
1039
|
+
srcType: p,
|
|
1040
|
+
type: "image"
|
|
1041
|
+
} }), r();
|
|
1042
|
+
} else if (d?.layerId) n(), t(d.layerId, {
|
|
1043
|
+
src: f,
|
|
1044
|
+
srcType: p
|
|
1045
|
+
}), r();
|
|
1046
|
+
else {
|
|
1047
|
+
let t = new Image();
|
|
1048
|
+
t.onload = () => {
|
|
1049
|
+
if (!t.naturalWidth || !t.naturalHeight) return;
|
|
1050
|
+
let n = Math.min(1, 720 / t.naturalWidth, 720 / t.naturalHeight), r = Math.round(t.naturalWidth * n), i = Math.round(t.naturalHeight * n);
|
|
1051
|
+
e("photo", {
|
|
1052
|
+
src: f,
|
|
1053
|
+
srcType: p,
|
|
1054
|
+
x: Math.round((a - r) / 2),
|
|
1055
|
+
y: Math.round((_ - i) / 2),
|
|
1056
|
+
w: r,
|
|
1057
|
+
h: i,
|
|
1058
|
+
fit: "cover"
|
|
1059
|
+
});
|
|
1060
|
+
}, t.src = f;
|
|
1061
|
+
}
|
|
1062
|
+
u({
|
|
1063
|
+
url: o,
|
|
1064
|
+
contentType: s,
|
|
1065
|
+
kind: l
|
|
1066
|
+
});
|
|
1067
|
+
}
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
//#endregion
|
|
1071
|
+
//#region src/editor/kolbox/app/WindowSignIn.jsx
|
|
1072
|
+
function It({ onClose: e }) {
|
|
1073
|
+
return /* @__PURE__ */ j(Ce, {
|
|
1074
|
+
variant: "kolbox",
|
|
1075
|
+
open: !0,
|
|
1076
|
+
movable: "sign-in",
|
|
1077
|
+
onClose: e,
|
|
1078
|
+
title: "Sign in",
|
|
1079
|
+
footer: /* @__PURE__ */ M(Ne, { children: [/* @__PURE__ */ j("span", { className: "flex-1" }), /* @__PURE__ */ j(E, {
|
|
1080
|
+
variant: "kolbox",
|
|
1081
|
+
tone: "primary",
|
|
1082
|
+
onClick: e,
|
|
1083
|
+
children: "OK"
|
|
1084
|
+
})] }),
|
|
1085
|
+
children: /* @__PURE__ */ M("div", {
|
|
1086
|
+
className: "flex flex-col gap-3 px-4 pb-4",
|
|
1087
|
+
"data-window": "sign-in",
|
|
1088
|
+
children: [/* @__PURE__ */ j("p", {
|
|
1089
|
+
className: "text-label text-text",
|
|
1090
|
+
children: "No account is connected."
|
|
1091
|
+
}), /* @__PURE__ */ j("p", {
|
|
1092
|
+
className: "text-help text-muted",
|
|
1093
|
+
children: "The app that hosts the editor connects one by passing its account: the session and its sign-in and sign-out. Until then your files, folders, media, palettes and themes are kept in this browser, on this device."
|
|
1094
|
+
})]
|
|
1095
|
+
})
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
//#endregion
|
|
1099
|
+
//#region src/editor/kolbox/files/account.js
|
|
1100
|
+
var Lt = () => !!x(), Rt = () => x()?.session ?? null, zt = () => x()?.signIn?.(), Bt = () => x()?.signOut?.(), Vt = {
|
|
1101
|
+
"/editor": "editor",
|
|
1102
|
+
"/labs": "labs",
|
|
1103
|
+
"/morph": "labs"
|
|
1104
|
+
}, Ht = new Set(Object.keys(Vt)), Ut = (e) => Vt[e] ?? "home", Wt = (e, t) => () => window.dispatchEvent(new CustomEvent(e, { detail: t })), Gt = (e) => Wt("kolbox:settings", { tab: e })(), Kt = Wt("kolbox:media"), qt = Wt("kolbox:sign-in"), U = () => !!Rt();
|
|
1105
|
+
function Jt({ screen: e, onLeave: t }) {
|
|
1106
|
+
let [n, r] = A(null), [, i] = A(0), a = k(e);
|
|
1107
|
+
a.current = e;
|
|
1108
|
+
let o = k(t);
|
|
1109
|
+
o.current = t;
|
|
1110
|
+
let s = Ut(e);
|
|
1111
|
+
O(() => {
|
|
1112
|
+
let e = (e) => window.dispatchEvent(new CustomEvent(e, { cancelable: !0 })), t = (t) => {
|
|
1113
|
+
e("kol:open-settings") && r((e) => e?.id === "settings" ? null : {
|
|
1114
|
+
id: "settings",
|
|
1115
|
+
tab: t?.detail?.tab ?? "settings"
|
|
1116
|
+
});
|
|
1117
|
+
}, n = () => {
|
|
1118
|
+
e("kol:show-shortcuts") && r((e) => e?.id === "shortcuts" ? null : { id: "shortcuts" });
|
|
1119
|
+
}, o = () => r({ id: "media" }), s = async () => {
|
|
1120
|
+
if (!Rt()) {
|
|
1121
|
+
Lt() ? zt() : r({ id: "sign-in" });
|
|
1122
|
+
return;
|
|
1123
|
+
}
|
|
1124
|
+
await Pe({
|
|
1125
|
+
title: "Sign out? Your files stay on this device.",
|
|
1126
|
+
action: "Sign out"
|
|
1127
|
+
}) && Bt(), i((e) => e + 1), window.dispatchEvent(new CustomEvent("kolbox:account"));
|
|
1128
|
+
}, c = (e) => {
|
|
1129
|
+
if (fe(e, Ue)) {
|
|
1130
|
+
e.preventDefault(), e.repeat || t();
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
T(e) || e.metaKey || e.ctrlKey || e.altKey || e.repeat || e.key === "s" && !e.shiftKey && !Ht.has(a.current) && setTimeout(() => {
|
|
1134
|
+
e.defaultPrevented || n();
|
|
1135
|
+
});
|
|
1136
|
+
}, l = {
|
|
1137
|
+
"kolbox:settings": t,
|
|
1138
|
+
"kolbox:shortcuts": n,
|
|
1139
|
+
"kolbox:media": o,
|
|
1140
|
+
"kolbox:sign-in": s
|
|
1141
|
+
};
|
|
1142
|
+
return Object.entries(l).forEach(([e, t]) => window.addEventListener(e, t)), window.addEventListener("keydown", c), () => {
|
|
1143
|
+
Object.entries(l).forEach(([e, t]) => window.removeEventListener(e, t)), window.removeEventListener("keydown", c);
|
|
1144
|
+
};
|
|
1145
|
+
}, []);
|
|
1146
|
+
let c = () => window.location.hash === "#/settings";
|
|
1147
|
+
O(() => {
|
|
1148
|
+
let e = () => window.dispatchEvent(new CustomEvent("kol:open-settings", { cancelable: !0 })), t = () => {
|
|
1149
|
+
c() && e() && r({
|
|
1150
|
+
id: "settings",
|
|
1151
|
+
tab: "settings"
|
|
1152
|
+
});
|
|
1153
|
+
}, n = () => {
|
|
1154
|
+
c() && o.current?.();
|
|
1155
|
+
};
|
|
1156
|
+
return t(), window.addEventListener("hashchange", t), window.addEventListener("kolbox:settings-closed", n), () => {
|
|
1157
|
+
window.removeEventListener("hashchange", t), window.removeEventListener("kolbox:settings-closed", n);
|
|
1158
|
+
};
|
|
1159
|
+
}, []);
|
|
1160
|
+
let l = () => {
|
|
1161
|
+
r(null), c() && t?.();
|
|
1162
|
+
};
|
|
1163
|
+
return n?.id === "settings" ? /* @__PURE__ */ j(Tt, {
|
|
1164
|
+
onClose: l,
|
|
1165
|
+
view: s,
|
|
1166
|
+
tab: n.tab
|
|
1167
|
+
}) : n?.id === "shortcuts" ? /* @__PURE__ */ j(at, {
|
|
1168
|
+
onClose: l,
|
|
1169
|
+
view: s
|
|
1170
|
+
}) : n?.id === "sign-in" ? /* @__PURE__ */ j(It, { onClose: l }) : n?.id === "media" ? /* @__PURE__ */ j(Nt, {
|
|
1171
|
+
open: !0,
|
|
1172
|
+
onClose: l,
|
|
1173
|
+
onSelect: l
|
|
1174
|
+
}) : null;
|
|
1175
|
+
}
|
|
1176
|
+
//#endregion
|
|
1177
|
+
//#region src/editor/kolbox/ui/MenuMain.jsx
|
|
1178
|
+
var Yt = () => window.dispatchEvent(new CustomEvent("kolbox:search")), W = (e) => () => {
|
|
1179
|
+
window.location.hash = e;
|
|
1180
|
+
};
|
|
1181
|
+
function Xt({ mode: e, settings: t } = {}) {
|
|
1182
|
+
return [
|
|
1183
|
+
{
|
|
1184
|
+
label: "Home",
|
|
1185
|
+
run: W("#/home")
|
|
1186
|
+
},
|
|
1187
|
+
{
|
|
1188
|
+
label: "Chromes",
|
|
1189
|
+
submenu: [[
|
|
1190
|
+
{
|
|
1191
|
+
label: "Home",
|
|
1192
|
+
check: e === "home",
|
|
1193
|
+
run: W("#/home")
|
|
1194
|
+
},
|
|
1195
|
+
{
|
|
1196
|
+
label: "Library",
|
|
1197
|
+
check: e === "library",
|
|
1198
|
+
run: W("#/library")
|
|
1199
|
+
},
|
|
1200
|
+
{
|
|
1201
|
+
label: "Editor",
|
|
1202
|
+
check: e === "editor",
|
|
1203
|
+
run: W("#/editor")
|
|
1204
|
+
},
|
|
1205
|
+
{
|
|
1206
|
+
label: "Labs",
|
|
1207
|
+
check: e === "labs",
|
|
1208
|
+
run: W("#/labs")
|
|
1209
|
+
},
|
|
1210
|
+
{
|
|
1211
|
+
label: "Randomiser",
|
|
1212
|
+
check: e === "randomiser",
|
|
1213
|
+
run: W("#/randomiser")
|
|
1214
|
+
},
|
|
1215
|
+
{
|
|
1216
|
+
label: "Morph",
|
|
1217
|
+
check: e === "morph",
|
|
1218
|
+
run: W("#/morph")
|
|
1219
|
+
}
|
|
1220
|
+
]]
|
|
1221
|
+
},
|
|
1222
|
+
{
|
|
1223
|
+
label: "Media",
|
|
1224
|
+
run: Kt
|
|
1225
|
+
},
|
|
1226
|
+
{
|
|
1227
|
+
label: U() ? "Signed in" : "Sign in",
|
|
1228
|
+
run: qt
|
|
1229
|
+
},
|
|
1230
|
+
{
|
|
1231
|
+
label: "Settings…",
|
|
1232
|
+
shortcut: "⌘,",
|
|
1233
|
+
run: () => Gt(),
|
|
1234
|
+
...t
|
|
1235
|
+
}
|
|
1236
|
+
];
|
|
1237
|
+
}
|
|
1238
|
+
var G = (e) => () => window.dispatchEvent(new CustomEvent("kolbox:labs", { detail: e })), Zt = [{
|
|
1239
|
+
label: "File",
|
|
1240
|
+
groups: [[{
|
|
1241
|
+
label: "Save",
|
|
1242
|
+
shortcut: "⌘S",
|
|
1243
|
+
run: G("save")
|
|
1244
|
+
}, {
|
|
1245
|
+
label: "Files…",
|
|
1246
|
+
shortcut: "⌘O",
|
|
1247
|
+
run: G("files")
|
|
1248
|
+
}], [{
|
|
1249
|
+
label: "Export PNG",
|
|
1250
|
+
run: G("export-png")
|
|
1251
|
+
}, {
|
|
1252
|
+
label: "Export loop (webm)",
|
|
1253
|
+
run: G("export-loop")
|
|
1254
|
+
}]]
|
|
1255
|
+
}, {
|
|
1256
|
+
label: "Window",
|
|
1257
|
+
groups: [[{
|
|
1258
|
+
label: "Output",
|
|
1259
|
+
run: G("output")
|
|
1260
|
+
}, {
|
|
1261
|
+
label: "File",
|
|
1262
|
+
run: G("file")
|
|
1263
|
+
}], [
|
|
1264
|
+
{
|
|
1265
|
+
label: "Shortcuts",
|
|
1266
|
+
shortcut: "S",
|
|
1267
|
+
run: G("shortcuts")
|
|
1268
|
+
},
|
|
1269
|
+
{
|
|
1270
|
+
label: "Settings",
|
|
1271
|
+
shortcut: "⌘,",
|
|
1272
|
+
run: G("settings")
|
|
1273
|
+
},
|
|
1274
|
+
{
|
|
1275
|
+
label: "Media",
|
|
1276
|
+
run: G("media")
|
|
1277
|
+
}
|
|
1278
|
+
]]
|
|
1279
|
+
}];
|
|
1280
|
+
function Qt({ anchor: e, open: t, onClose: n, menus: r = [], app: i = [] }) {
|
|
1281
|
+
return /* @__PURE__ */ j(Se, {
|
|
1282
|
+
variant: "kolbox",
|
|
1283
|
+
"aria-label": "Main menu",
|
|
1284
|
+
minWidth: 196,
|
|
1285
|
+
anchor: e,
|
|
1286
|
+
open: t,
|
|
1287
|
+
onClose: n,
|
|
1288
|
+
onSelect: (e) => e.run?.(),
|
|
1289
|
+
groups: [
|
|
1290
|
+
i.filter((e) => e.label === "Home"),
|
|
1291
|
+
[{
|
|
1292
|
+
label: "Actions…",
|
|
1293
|
+
icon: "search",
|
|
1294
|
+
shortcut: "⌘K",
|
|
1295
|
+
run: Yt
|
|
1296
|
+
}],
|
|
1297
|
+
r.map((e) => ({
|
|
1298
|
+
label: e.label,
|
|
1299
|
+
submenu: e.groups
|
|
1300
|
+
})),
|
|
1301
|
+
i.filter((e) => e.label !== "Home")
|
|
1302
|
+
].filter((e) => e.length)
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1305
|
+
//#endregion
|
|
1306
|
+
//#region src/editor/kolbox/editor/windows/InsertImage.jsx
|
|
1307
|
+
var $t = () => window.dispatchEvent(new CustomEvent("kol:insert-image"));
|
|
1308
|
+
function en() {
|
|
1309
|
+
let { addLayer: e } = l(), t = k(null);
|
|
1310
|
+
return O(() => {
|
|
1311
|
+
let e = () => t.current?.click(), n = (t) => {
|
|
1312
|
+
T(t) || !fe(t, Ve("insert-image").combo) || (t.preventDefault(), t.stopPropagation(), e());
|
|
1313
|
+
};
|
|
1314
|
+
return window.addEventListener("kol:insert-image", e), window.addEventListener("keydown", n, !0), () => {
|
|
1315
|
+
window.removeEventListener("kol:insert-image", e), window.removeEventListener("keydown", n, !0);
|
|
1316
|
+
};
|
|
1317
|
+
}, []), /* @__PURE__ */ j("input", {
|
|
1318
|
+
ref: t,
|
|
1319
|
+
type: "file",
|
|
1320
|
+
accept: "image/*",
|
|
1321
|
+
className: "hidden",
|
|
1322
|
+
onChange: (t) => {
|
|
1323
|
+
let n = t.target.files?.[0];
|
|
1324
|
+
if (t.target.value = "", !n) return;
|
|
1325
|
+
let r = new FileReader();
|
|
1326
|
+
r.onload = () => {
|
|
1327
|
+
let t = new Image();
|
|
1328
|
+
t.onload = () => {
|
|
1329
|
+
if (!t.naturalWidth || !t.naturalHeight) return;
|
|
1330
|
+
let n = Math.min(1, 720 / t.naturalWidth, 720 / t.naturalHeight), i = Math.round(t.naturalWidth * n), o = Math.round(t.naturalHeight * n);
|
|
1331
|
+
e("photo", {
|
|
1332
|
+
src: r.result,
|
|
1333
|
+
x: Math.round((a - i) / 2),
|
|
1334
|
+
y: Math.round((_ - o) / 2),
|
|
1335
|
+
w: i,
|
|
1336
|
+
h: o,
|
|
1337
|
+
fit: "cover"
|
|
1338
|
+
});
|
|
1339
|
+
}, t.src = r.result;
|
|
1340
|
+
}, r.readAsDataURL(n);
|
|
1341
|
+
},
|
|
1342
|
+
"data-insert-image": !0
|
|
1343
|
+
});
|
|
1344
|
+
}
|
|
1345
|
+
//#endregion
|
|
1346
|
+
//#region src/editor/kolbox/editor/windows/eyedrop.jsx
|
|
1347
|
+
var tn = () => window.dispatchEvent(new CustomEvent("kol:eyedrop"));
|
|
1348
|
+
function nn() {
|
|
1349
|
+
let e = me(), { layers: t, palette: n, aspect: r, customRatio: i, canvasFill: a } = l(), o = k(null);
|
|
1350
|
+
return o.current = async () => {
|
|
1351
|
+
let o = typeof a == "string" && a.startsWith("var(") ? null : h(a, n) ?? null;
|
|
1352
|
+
try {
|
|
1353
|
+
let a = await re({
|
|
1354
|
+
layers: t,
|
|
1355
|
+
palette: n,
|
|
1356
|
+
aspect: r,
|
|
1357
|
+
customRatio: i,
|
|
1358
|
+
canvasFillHex: o
|
|
1359
|
+
});
|
|
1360
|
+
a && e.onChange(a);
|
|
1361
|
+
} catch {}
|
|
1362
|
+
}, O(() => {
|
|
1363
|
+
let e = () => o.current();
|
|
1364
|
+
return window.addEventListener("kol:eyedrop", e), () => window.removeEventListener("kol:eyedrop", e);
|
|
1365
|
+
}, []), null;
|
|
1366
|
+
}
|
|
1367
|
+
//#endregion
|
|
1368
|
+
//#region src/editor/kolbox/search/ModalSearchHost.jsx
|
|
1369
|
+
var rn = (e) => () => window.dispatchEvent(new CustomEvent("kol:command", { detail: { id: e } })), an = {
|
|
1370
|
+
editor: "editor",
|
|
1371
|
+
labs: "labs",
|
|
1372
|
+
morph: "labs"
|
|
1373
|
+
};
|
|
1374
|
+
function on() {
|
|
1375
|
+
let { setTool: e } = le(), t = l(), n = [
|
|
1376
|
+
{
|
|
1377
|
+
id: "select",
|
|
1378
|
+
icon: "pointer",
|
|
1379
|
+
label: "Select",
|
|
1380
|
+
kbd: "V"
|
|
1381
|
+
},
|
|
1382
|
+
{
|
|
1383
|
+
id: "zoom",
|
|
1384
|
+
icon: "search",
|
|
1385
|
+
label: "Zoom",
|
|
1386
|
+
kbd: "Z"
|
|
1387
|
+
},
|
|
1388
|
+
{
|
|
1389
|
+
id: "rect",
|
|
1390
|
+
icon: "square",
|
|
1391
|
+
label: "Rectangle",
|
|
1392
|
+
kbd: "R"
|
|
1393
|
+
},
|
|
1394
|
+
{
|
|
1395
|
+
id: "ellipse",
|
|
1396
|
+
icon: "circle",
|
|
1397
|
+
label: "Ellipse",
|
|
1398
|
+
kbd: "O"
|
|
1399
|
+
},
|
|
1400
|
+
{
|
|
1401
|
+
id: "text",
|
|
1402
|
+
icon: "aa",
|
|
1403
|
+
label: "Text",
|
|
1404
|
+
kbd: "T"
|
|
1405
|
+
},
|
|
1406
|
+
{
|
|
1407
|
+
id: "pen",
|
|
1408
|
+
icon: "pen",
|
|
1409
|
+
label: "Pen",
|
|
1410
|
+
kbd: "P"
|
|
1411
|
+
},
|
|
1412
|
+
{
|
|
1413
|
+
id: "image",
|
|
1414
|
+
icon: "image",
|
|
1415
|
+
label: "Insert image",
|
|
1416
|
+
run: $t
|
|
1417
|
+
},
|
|
1418
|
+
{
|
|
1419
|
+
id: "pattern",
|
|
1420
|
+
icon: "pattern-tool",
|
|
1421
|
+
label: "Pattern"
|
|
1422
|
+
},
|
|
1423
|
+
{
|
|
1424
|
+
id: "hand",
|
|
1425
|
+
icon: "hand",
|
|
1426
|
+
label: "Hand"
|
|
1427
|
+
},
|
|
1428
|
+
{
|
|
1429
|
+
id: "orbit",
|
|
1430
|
+
icon: "shape-torus",
|
|
1431
|
+
label: "Orbit",
|
|
1432
|
+
kbd: "C"
|
|
1433
|
+
},
|
|
1434
|
+
{
|
|
1435
|
+
label: "Node select",
|
|
1436
|
+
icon: "pointer-node",
|
|
1437
|
+
kbd: "A",
|
|
1438
|
+
run: () => window.dispatchEvent(new CustomEvent("kol:node-edit"))
|
|
1439
|
+
},
|
|
1440
|
+
{
|
|
1441
|
+
id: "triangle",
|
|
1442
|
+
icon: "triangle",
|
|
1443
|
+
label: "Triangle"
|
|
1444
|
+
},
|
|
1445
|
+
{
|
|
1446
|
+
id: "line",
|
|
1447
|
+
icon: "line",
|
|
1448
|
+
label: "Line"
|
|
1449
|
+
},
|
|
1450
|
+
{
|
|
1451
|
+
id: "polygon",
|
|
1452
|
+
icon: "polygon",
|
|
1453
|
+
label: "Polygon"
|
|
1454
|
+
},
|
|
1455
|
+
{
|
|
1456
|
+
id: "star",
|
|
1457
|
+
icon: "star",
|
|
1458
|
+
label: "Star"
|
|
1459
|
+
},
|
|
1460
|
+
...d("motion") ? [{
|
|
1461
|
+
label: "Kinetic type",
|
|
1462
|
+
icon: "type-02",
|
|
1463
|
+
run: () => t.addLayer("kinetic")
|
|
1464
|
+
}] : [],
|
|
1465
|
+
{
|
|
1466
|
+
label: "Fill / stroke",
|
|
1467
|
+
icon: "swap",
|
|
1468
|
+
kbd: "X",
|
|
1469
|
+
run: rn("paint-toggle")
|
|
1470
|
+
},
|
|
1471
|
+
{
|
|
1472
|
+
label: "Reset colours",
|
|
1473
|
+
icon: "refresh",
|
|
1474
|
+
kbd: "D",
|
|
1475
|
+
run: rn("paint-default")
|
|
1476
|
+
},
|
|
1477
|
+
{
|
|
1478
|
+
label: "Eyedropper",
|
|
1479
|
+
icon: "eyedropper",
|
|
1480
|
+
kbd: "I",
|
|
1481
|
+
run: tn
|
|
1482
|
+
}
|
|
1483
|
+
], r = [], i = (e) => (e ?? []).forEach((e) => {
|
|
1484
|
+
r.push({
|
|
1485
|
+
id: e.id,
|
|
1486
|
+
name: te(e),
|
|
1487
|
+
kind: e.type,
|
|
1488
|
+
run: () => t.select(e.id)
|
|
1489
|
+
}), i(e.children);
|
|
1490
|
+
});
|
|
1491
|
+
return i(t.layers), {
|
|
1492
|
+
tools: n.map((t) => ({
|
|
1493
|
+
...t,
|
|
1494
|
+
run: t.run ?? (() => e(t.id))
|
|
1495
|
+
})),
|
|
1496
|
+
layers: r
|
|
1497
|
+
};
|
|
1498
|
+
}
|
|
1499
|
+
var K = (e) => () => {
|
|
1500
|
+
window.location.hash = e;
|
|
1501
|
+
}, sn = (e, t) => {
|
|
1502
|
+
let n = new URL(window.location.href);
|
|
1503
|
+
n.searchParams.set("open", e), n.hash = t === "morph" ? "#/morph" : "#/editor", window.history.pushState(null, "", n.pathname + n.search + n.hash), window.dispatchEvent(new HashChangeEvent("hashchange"));
|
|
1504
|
+
}, cn = (e) => e ? `Edited ${new Date(e).toLocaleDateString(void 0, {
|
|
1505
|
+
day: "numeric",
|
|
1506
|
+
month: "short"
|
|
1507
|
+
})}, ${new Date(e).toLocaleTimeString(void 0, {
|
|
1508
|
+
hour: "2-digit",
|
|
1509
|
+
minute: "2-digit"
|
|
1510
|
+
})}` : void 0, ln = () => (v().preset ?? []).filter((e) => !e.shipped).map((e) => ({
|
|
1511
|
+
id: e.id,
|
|
1512
|
+
name: e.name || "Untitled",
|
|
1513
|
+
hint: cn(e.updatedAt ?? e.savedAt),
|
|
1514
|
+
run: () => sn(e.id, e.mode ?? "editor")
|
|
1515
|
+
})), un = () => [
|
|
1516
|
+
{
|
|
1517
|
+
id: "/home",
|
|
1518
|
+
icon: "home-01",
|
|
1519
|
+
label: "Home",
|
|
1520
|
+
run: K("#/home")
|
|
1521
|
+
},
|
|
1522
|
+
{
|
|
1523
|
+
id: "/library",
|
|
1524
|
+
icon: "nav-library",
|
|
1525
|
+
label: "Library",
|
|
1526
|
+
run: K("#/library")
|
|
1527
|
+
},
|
|
1528
|
+
{
|
|
1529
|
+
id: "/editor",
|
|
1530
|
+
icon: "desktop",
|
|
1531
|
+
label: "Editor",
|
|
1532
|
+
run: K("#/editor")
|
|
1533
|
+
},
|
|
1534
|
+
{
|
|
1535
|
+
id: "/labs",
|
|
1536
|
+
icon: "globe",
|
|
1537
|
+
label: "Labs",
|
|
1538
|
+
run: K("#/labs")
|
|
1539
|
+
},
|
|
1540
|
+
{
|
|
1541
|
+
id: "/randomiser",
|
|
1542
|
+
icon: "refresh",
|
|
1543
|
+
label: "Randomiser",
|
|
1544
|
+
run: K("#/randomiser")
|
|
1545
|
+
},
|
|
1546
|
+
{
|
|
1547
|
+
id: "/morph",
|
|
1548
|
+
icon: "swap",
|
|
1549
|
+
label: "Morph",
|
|
1550
|
+
run: K("#/morph")
|
|
1551
|
+
},
|
|
1552
|
+
{
|
|
1553
|
+
id: "media",
|
|
1554
|
+
icon: "image",
|
|
1555
|
+
label: "Media",
|
|
1556
|
+
run: Kt
|
|
1557
|
+
},
|
|
1558
|
+
{
|
|
1559
|
+
id: "sign-in",
|
|
1560
|
+
icon: U() ? "cloud" : "user",
|
|
1561
|
+
label: U() ? "Signed in" : "Sign in",
|
|
1562
|
+
run: qt
|
|
1563
|
+
},
|
|
1564
|
+
{
|
|
1565
|
+
id: "settings",
|
|
1566
|
+
icon: "nav-settings",
|
|
1567
|
+
label: "Settings",
|
|
1568
|
+
run: () => Gt()
|
|
1569
|
+
}
|
|
1570
|
+
].map((e) => ({
|
|
1571
|
+
hint: "Page",
|
|
1572
|
+
...e
|
|
1573
|
+
}));
|
|
1574
|
+
function dn({ mode: e, menus: t, tools: n = [], layers: r = [] }) {
|
|
1575
|
+
let [i, a] = A(!1), [o, s] = A(""), [c, l] = A(F[0].value), [u, d] = A(0);
|
|
1576
|
+
O(() => {
|
|
1577
|
+
let e = () => a((e) => !e);
|
|
1578
|
+
return window.addEventListener("kolbox:search", e), () => window.removeEventListener("kolbox:search", e);
|
|
1579
|
+
}, []), O(() => {
|
|
1580
|
+
i || (s(""), l(F[0].value));
|
|
1581
|
+
}, [i]);
|
|
1582
|
+
let f = i ? Ze({
|
|
1583
|
+
menus: t,
|
|
1584
|
+
tools: n,
|
|
1585
|
+
layers: r,
|
|
1586
|
+
pages: un(),
|
|
1587
|
+
files: ln(),
|
|
1588
|
+
shortcuts: rt(an[e] ?? "home")
|
|
1589
|
+
}) : [], p = i ? nt(o ? tt(f, o) : $e(f), c) : [], m = p.flatMap((e) => e.rows);
|
|
1590
|
+
return O(() => {
|
|
1591
|
+
d(Math.max(0, m.findIndex((e) => !e.disabled)));
|
|
1592
|
+
}, [
|
|
1593
|
+
o,
|
|
1594
|
+
i,
|
|
1595
|
+
c,
|
|
1596
|
+
m.map((e) => e.id).join("\0")
|
|
1597
|
+
]), /* @__PURE__ */ j(_e, {
|
|
1598
|
+
variant: "kolbox",
|
|
1599
|
+
open: i,
|
|
1600
|
+
onClose: () => a(!1),
|
|
1601
|
+
query: o,
|
|
1602
|
+
onQueryChange: s,
|
|
1603
|
+
tabs: F,
|
|
1604
|
+
tab: c,
|
|
1605
|
+
onTab: l,
|
|
1606
|
+
groups: p,
|
|
1607
|
+
active: u,
|
|
1608
|
+
onActive: d,
|
|
1609
|
+
onSelect: (e) => {
|
|
1610
|
+
Ge(e.key ?? e.id), a(!1), e.run?.();
|
|
1611
|
+
},
|
|
1612
|
+
empty: e === "editor" ? "Search files, layers, pages, tools, menu actions and shortcuts by name." : "Search files, pages, menu actions and shortcuts by name."
|
|
1613
|
+
});
|
|
1614
|
+
}
|
|
1615
|
+
function fn({ menus: e }) {
|
|
1616
|
+
let { tools: t, layers: n } = on();
|
|
1617
|
+
return /* @__PURE__ */ j(dn, {
|
|
1618
|
+
mode: "editor",
|
|
1619
|
+
menus: e,
|
|
1620
|
+
tools: t,
|
|
1621
|
+
layers: n
|
|
1622
|
+
});
|
|
1623
|
+
}
|
|
1624
|
+
function pn({ mode: e, menus: t }) {
|
|
1625
|
+
return e === "editor" ? /* @__PURE__ */ j(fn, { menus: t ?? [] }) : /* @__PURE__ */ j(dn, {
|
|
1626
|
+
mode: e,
|
|
1627
|
+
menus: t ?? [{
|
|
1628
|
+
label: "FXR",
|
|
1629
|
+
groups: [Xt({ mode: e })]
|
|
1630
|
+
}]
|
|
1631
|
+
});
|
|
1632
|
+
}
|
|
1633
|
+
//#endregion
|
|
1634
|
+
//#region src/editor/kolbox/files/places.js
|
|
1635
|
+
var mn = "kolbox.places.v1", q = {
|
|
1636
|
+
id: "drafts",
|
|
1637
|
+
name: "Drafts",
|
|
1638
|
+
builtIn: !0
|
|
1639
|
+
}, hn = {
|
|
1640
|
+
media: !0,
|
|
1641
|
+
theme: !0
|
|
1642
|
+
}, gn = {
|
|
1643
|
+
folders: [],
|
|
1644
|
+
placeOf: {},
|
|
1645
|
+
keepOf: {},
|
|
1646
|
+
trashed: {},
|
|
1647
|
+
starred: []
|
|
1648
|
+
}, J = null;
|
|
1649
|
+
function Y() {
|
|
1650
|
+
if (J) return J;
|
|
1651
|
+
try {
|
|
1652
|
+
J = {
|
|
1653
|
+
...gn,
|
|
1654
|
+
...JSON.parse(localStorage.getItem(mn) || "null")
|
|
1655
|
+
};
|
|
1656
|
+
} catch {
|
|
1657
|
+
J = { ...gn };
|
|
1658
|
+
}
|
|
1659
|
+
return J;
|
|
1660
|
+
}
|
|
1661
|
+
function X(e) {
|
|
1662
|
+
J = e;
|
|
1663
|
+
try {
|
|
1664
|
+
localStorage.setItem(mn, JSON.stringify(e));
|
|
1665
|
+
} catch (e) {
|
|
1666
|
+
console.warn("places: could not save to this browser:", e?.message || e);
|
|
1667
|
+
}
|
|
1668
|
+
window.dispatchEvent(new CustomEvent("kolbox:places"));
|
|
1669
|
+
}
|
|
1670
|
+
var _n = (e) => {
|
|
1671
|
+
let t = (t) => {
|
|
1672
|
+
t.key === mn && (J = null, e());
|
|
1673
|
+
};
|
|
1674
|
+
return window.addEventListener("kolbox:places", e), window.addEventListener("storage", t), () => {
|
|
1675
|
+
window.removeEventListener("kolbox:places", e), window.removeEventListener("storage", t);
|
|
1676
|
+
};
|
|
1677
|
+
}, vn = () => [q, ...Y().folders], yn = (e) => vn().find((t) => t.id === e) ?? q;
|
|
1678
|
+
function bn(e) {
|
|
1679
|
+
let t = String(e ?? "").trim();
|
|
1680
|
+
if (!t) return null;
|
|
1681
|
+
let n = Y(), r = n.folders.find((e) => e.name.toLowerCase() === t.toLowerCase());
|
|
1682
|
+
if (r) return r.id;
|
|
1683
|
+
let i = `f-${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}`;
|
|
1684
|
+
return X({
|
|
1685
|
+
...n,
|
|
1686
|
+
folders: [...n.folders, {
|
|
1687
|
+
id: i,
|
|
1688
|
+
name: t,
|
|
1689
|
+
created: Date.now()
|
|
1690
|
+
}]
|
|
1691
|
+
}), i;
|
|
1692
|
+
}
|
|
1693
|
+
var xn = (e) => Y().placeOf[e] && vn().some((t) => t.id === Y().placeOf[e]) ? Y().placeOf[e] : q.id;
|
|
1694
|
+
function Sn(e, t) {
|
|
1695
|
+
if (!e) return;
|
|
1696
|
+
let n = Y();
|
|
1697
|
+
X({
|
|
1698
|
+
...n,
|
|
1699
|
+
placeOf: {
|
|
1700
|
+
...n.placeOf,
|
|
1701
|
+
[e]: t || q.id
|
|
1702
|
+
}
|
|
1703
|
+
});
|
|
1704
|
+
}
|
|
1705
|
+
var Cn = (e) => ({
|
|
1706
|
+
...hn,
|
|
1707
|
+
...Y().keepOf[e] ?? {}
|
|
1708
|
+
});
|
|
1709
|
+
function wn(e, t) {
|
|
1710
|
+
if (!e) return;
|
|
1711
|
+
let n = Y();
|
|
1712
|
+
X({
|
|
1713
|
+
...n,
|
|
1714
|
+
keepOf: {
|
|
1715
|
+
...n.keepOf,
|
|
1716
|
+
[e]: {
|
|
1717
|
+
...hn,
|
|
1718
|
+
...t
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
});
|
|
1722
|
+
}
|
|
1723
|
+
function Tn(e) {
|
|
1724
|
+
let t = Y(), { [e]: n, ...r } = t.placeOf, { [e]: i, ...a } = t.keepOf, { [e]: o, ...s } = t.trashed;
|
|
1725
|
+
X({
|
|
1726
|
+
...t,
|
|
1727
|
+
placeOf: r,
|
|
1728
|
+
keepOf: a,
|
|
1729
|
+
trashed: s,
|
|
1730
|
+
starred: t.starred.filter((t) => t !== e)
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1733
|
+
var En = (e) => Y().trashed[e] ?? null;
|
|
1734
|
+
function Dn(e) {
|
|
1735
|
+
let t = Y();
|
|
1736
|
+
X({
|
|
1737
|
+
...t,
|
|
1738
|
+
trashed: {
|
|
1739
|
+
...t.trashed,
|
|
1740
|
+
[e]: Date.now()
|
|
1741
|
+
},
|
|
1742
|
+
starred: t.starred.filter((t) => t !== e)
|
|
1743
|
+
});
|
|
1744
|
+
}
|
|
1745
|
+
function On(e) {
|
|
1746
|
+
let t = Y(), { [e]: n, ...r } = t.trashed;
|
|
1747
|
+
X({
|
|
1748
|
+
...t,
|
|
1749
|
+
trashed: r
|
|
1750
|
+
});
|
|
1751
|
+
}
|
|
1752
|
+
var kn = () => Y().starred, An = (e) => Y().starred.includes(e);
|
|
1753
|
+
function jn(e) {
|
|
1754
|
+
let t = Y();
|
|
1755
|
+
X({
|
|
1756
|
+
...t,
|
|
1757
|
+
starred: t.starred.includes(e) ? t.starred.filter((t) => t !== e) : [...t.starred, e]
|
|
1758
|
+
});
|
|
1759
|
+
}
|
|
1760
|
+
function Mn(e, t) {
|
|
1761
|
+
let n = String(t ?? "").trim(), r = Y();
|
|
1762
|
+
n && X({
|
|
1763
|
+
...r,
|
|
1764
|
+
folders: r.folders.map((t) => t.id === e ? {
|
|
1765
|
+
...t,
|
|
1766
|
+
name: n
|
|
1767
|
+
} : t)
|
|
1768
|
+
});
|
|
1769
|
+
}
|
|
1770
|
+
function Nn(e) {
|
|
1771
|
+
let t = Y(), n = Date.now(), r = Object.keys(t.placeOf).filter((n) => t.placeOf[n] === e), i = { ...t.trashed };
|
|
1772
|
+
r.forEach((e) => {
|
|
1773
|
+
i[e] ??= n;
|
|
1774
|
+
}), X({
|
|
1775
|
+
...t,
|
|
1776
|
+
folders: t.folders.filter((t) => t.id !== e),
|
|
1777
|
+
trashed: i,
|
|
1778
|
+
starred: t.starred.filter((t) => t !== e)
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
function Pn() {
|
|
1782
|
+
return Me(_n, Y, Y);
|
|
1783
|
+
}
|
|
1784
|
+
//#endregion
|
|
1785
|
+
//#region src/editor/kolbox/editor/export/render.js
|
|
1786
|
+
var Fn = [
|
|
1787
|
+
{
|
|
1788
|
+
value: "png",
|
|
1789
|
+
label: "PNG"
|
|
1790
|
+
},
|
|
1791
|
+
{
|
|
1792
|
+
value: "jpg",
|
|
1793
|
+
label: "JPG"
|
|
1794
|
+
},
|
|
1795
|
+
{
|
|
1796
|
+
value: "svg",
|
|
1797
|
+
label: "SVG"
|
|
1798
|
+
},
|
|
1799
|
+
{
|
|
1800
|
+
value: "pdf",
|
|
1801
|
+
label: "PDF"
|
|
1802
|
+
},
|
|
1803
|
+
{
|
|
1804
|
+
value: "webm",
|
|
1805
|
+
label: "Video (WebM)"
|
|
1806
|
+
}
|
|
1807
|
+
], In = Fn.filter((e) => e.value !== "webm"), Z = 30, Ln = [
|
|
1808
|
+
.5,
|
|
1809
|
+
1,
|
|
1810
|
+
2,
|
|
1811
|
+
3,
|
|
1812
|
+
4
|
|
1813
|
+
], Q = (e, t = "Untitled") => String(e ?? "").replace(/[\\/:*?"<>|]+/g, "-").replace(/\s+/g, " ").trim().slice(0, 80) || t, Rn = (e, t = 0) => e?.name || `Frame ${t + 1}`, zn = (e) => typeof e.x == "number" && e.w > 0 && e.h > 0;
|
|
1814
|
+
function Bn(e, t, n) {
|
|
1815
|
+
let r = t.density > 0 ? t.density : 1, i = u(e, t.id).map((e) => typeof e.x == "number" ? {
|
|
1816
|
+
...e,
|
|
1817
|
+
x: e.x - t.x,
|
|
1818
|
+
y: e.y - t.y
|
|
1819
|
+
} : e);
|
|
1820
|
+
return {
|
|
1821
|
+
name: Rn(t, n),
|
|
1822
|
+
layers: i,
|
|
1823
|
+
w: Math.max(1, Math.round(t.w * r)),
|
|
1824
|
+
h: Math.max(1, Math.round(t.h * r)),
|
|
1825
|
+
fill: t.color ?? null,
|
|
1826
|
+
fillOpacity: t.fillOpacity ?? 1,
|
|
1827
|
+
viewW: t.w,
|
|
1828
|
+
edge: t,
|
|
1829
|
+
framed: !0
|
|
1830
|
+
};
|
|
1831
|
+
}
|
|
1832
|
+
function $(e, t, n = !1) {
|
|
1833
|
+
let r = t.filter((e) => e && e.visible !== !1 && zn(e)), i = n ? [...r.filter((e) => e.type === "frame"), ...r.filter((e) => e.type !== "frame")] : r.filter((e) => e.type !== "frame");
|
|
1834
|
+
if (!i.length) return null;
|
|
1835
|
+
let a = Math.min(...i.map((e) => e.x)), o = Math.min(...i.map((e) => e.y)), s = Math.max(...i.map((e) => e.x + e.w)) - a, c = Math.max(...i.map((e) => e.y + e.h)) - o;
|
|
1836
|
+
return {
|
|
1837
|
+
name: e,
|
|
1838
|
+
layers: i.map((e) => ({
|
|
1839
|
+
...e,
|
|
1840
|
+
x: e.x - a,
|
|
1841
|
+
y: e.y - o
|
|
1842
|
+
})),
|
|
1843
|
+
w: Math.max(1, Math.round(s)),
|
|
1844
|
+
h: Math.max(1, Math.round(c)),
|
|
1845
|
+
fill: null,
|
|
1846
|
+
fillOpacity: 1,
|
|
1847
|
+
viewW: s,
|
|
1848
|
+
framed: !1
|
|
1849
|
+
};
|
|
1850
|
+
}
|
|
1851
|
+
function Vn(e, t) {
|
|
1852
|
+
let { layers: n, frameMode: r, activeFrame: i, selectedIds: a = [] } = e, o = r ? n.filter((e) => e.type === "frame") : [], s = (e) => o.indexOf(e), c = () => ({
|
|
1853
|
+
name: e.canvasName || "Canvas",
|
|
1854
|
+
layers: n,
|
|
1855
|
+
w: e.canvasW,
|
|
1856
|
+
h: e.canvasH,
|
|
1857
|
+
fill: e.canvasFill,
|
|
1858
|
+
fillOpacity: e.canvasFillOpacity ?? 1,
|
|
1859
|
+
viewW: null,
|
|
1860
|
+
framed: !0
|
|
1861
|
+
});
|
|
1862
|
+
if (t === "frames" || t === "frames:all") {
|
|
1863
|
+
if (!r) return [c()];
|
|
1864
|
+
let n = t === "frames:all", i = e.everyFrame(n ? null : e.pageId), a = n && new Set(i.map((e) => e.pageId)).size > 1;
|
|
1865
|
+
return i.flatMap((t) => Vn({
|
|
1866
|
+
...e,
|
|
1867
|
+
layers: t.layers
|
|
1868
|
+
}, `layer:${t.frame.id}`).map((e) => a ? {
|
|
1869
|
+
...e,
|
|
1870
|
+
name: `${t.pageName} ${e.name}`
|
|
1871
|
+
} : e));
|
|
1872
|
+
}
|
|
1873
|
+
if (t === "page") {
|
|
1874
|
+
if (!r) return [c()];
|
|
1875
|
+
let t = $(e.pages?.find((t) => t.id === e.pageId)?.name || "Page", n, !0);
|
|
1876
|
+
return t ? [t] : [];
|
|
1877
|
+
}
|
|
1878
|
+
if (t === "selection") {
|
|
1879
|
+
let e = a.filter((e) => e !== "canvas").map((e) => g(n, e)).filter(Boolean);
|
|
1880
|
+
if (e.length === 1 && e[0].type === "frame") return [Bn(n, e[0], s(e[0]))];
|
|
1881
|
+
let t = $(e.length === 1 && e[0].name || "Selection", e);
|
|
1882
|
+
return t ? [t] : [];
|
|
1883
|
+
}
|
|
1884
|
+
if (typeof t == "string" && t.startsWith("layer:")) {
|
|
1885
|
+
let e = g(n, t.slice(6));
|
|
1886
|
+
if (!e) return [];
|
|
1887
|
+
if (e.type === "frame") return [Bn(n, e, s(e))];
|
|
1888
|
+
let r = $(e.name || "Layer", [e]);
|
|
1889
|
+
return r ? [r] : [];
|
|
1890
|
+
}
|
|
1891
|
+
if (!r) return [c()];
|
|
1892
|
+
if (i) return [Bn(n, i, s(i))];
|
|
1893
|
+
let l = $("Page", n);
|
|
1894
|
+
return l ? [l] : [];
|
|
1895
|
+
}
|
|
1896
|
+
function Hn(e) {
|
|
1897
|
+
let { frameMode: t, activeFrame: n, layers: r, selectedIds: i = [] } = e, a = t ? r.filter((e) => e.type === "frame") : [], o = [{
|
|
1898
|
+
value: "frame",
|
|
1899
|
+
label: t ? n ? `Frame: ${Rn(n, a.indexOf(n))}` : "Page" : "Frame"
|
|
1900
|
+
}], s = i.filter((e) => e !== "canvas");
|
|
1901
|
+
s.length && !(s.length === 1 && n?.id === s[0]) && o.push({
|
|
1902
|
+
value: "selection",
|
|
1903
|
+
label: s.length === 1 ? "Selection" : `Selection (${s.length})`
|
|
1904
|
+
});
|
|
1905
|
+
let c = t ? e.everyFrame().length : 0;
|
|
1906
|
+
return c > 1 && o.push({
|
|
1907
|
+
value: "frames",
|
|
1908
|
+
label: `Every frame (${c})`
|
|
1909
|
+
}), o;
|
|
1910
|
+
}
|
|
1911
|
+
function Un(e) {
|
|
1912
|
+
let t = (e) => (e ?? []).some((e) => o(e) || e.type === "loop" || e.type === "kinetic" || e.type === "photo" && (e.srcType === "video" || e.srcType === "webcam") || t(e.children));
|
|
1913
|
+
return t(r(e));
|
|
1914
|
+
}
|
|
1915
|
+
var Wn = /* @__PURE__ */ new Map(), Gn = (e) => typeof e == "string" && !e.startsWith("data:"), Kn = (e) => new Promise((t, n) => {
|
|
1916
|
+
let r = new FileReader();
|
|
1917
|
+
r.onload = () => t(r.result), r.onerror = n, r.readAsDataURL(e);
|
|
1918
|
+
}), qn = (e) => e.type === "photo" && e.srcType === "video" || e.fill?.type === "video", Jn = (e, t) => qn(e) && !t ? null : e.type === "photo" && e.srcType !== "webcam" && Gn(e.src) ? e.src : (e.fill?.type === "image" || e.fill?.type === "video") && Gn(e.fill.src) ? e.fill.src : null;
|
|
1919
|
+
async function Yn(e, { clips: t = 0 } = {}) {
|
|
1920
|
+
let n = [], r = (e) => (e ?? []).forEach((e) => {
|
|
1921
|
+
let i = Jn(e, t);
|
|
1922
|
+
i && !Wn.has(i) && n.push([i, qn(e)]), r(e.children);
|
|
1923
|
+
});
|
|
1924
|
+
r(e), await Promise.all(n.map(async ([e, n]) => {
|
|
1925
|
+
try {
|
|
1926
|
+
let r = await fetch(e), i = r.ok ? await r.blob() : null;
|
|
1927
|
+
i && (!n || i.size <= t) && Wn.set(e, await Kn(i));
|
|
1928
|
+
} catch {}
|
|
1929
|
+
}));
|
|
1930
|
+
let i = (e) => e.map((e) => {
|
|
1931
|
+
let n = Jn(e, t), r = n && Wn.get(n), a = r && (!qn(e) || r.length * .75 <= t) ? r : null, o = Array.isArray(e.children) ? i(e.children) : e.children;
|
|
1932
|
+
if (!a && o === e.children) return e;
|
|
1933
|
+
let s = {
|
|
1934
|
+
...e,
|
|
1935
|
+
...o === e.children ? {} : { children: o }
|
|
1936
|
+
};
|
|
1937
|
+
return a && e.type === "photo" ? s.src = a : a && (s.fill = {
|
|
1938
|
+
...e.fill,
|
|
1939
|
+
src: a
|
|
1940
|
+
}), s;
|
|
1941
|
+
});
|
|
1942
|
+
return i(e);
|
|
1943
|
+
}
|
|
1944
|
+
async function Xn(e, { palette: n, aspect: a, fill: o = !0, rasterScale: s = 1, ctx: l = t.getCtx() }) {
|
|
1945
|
+
let u = i(r(e.layers), l);
|
|
1946
|
+
await S(u), u.some((e) => e.type === "kinetic") && await d("motion")?.warmFontCss?.();
|
|
1947
|
+
let f = o ? h(e.fill ?? null, n) : null, p = typeof f == "string" && f.match(/^var\((--[^),\s]+)/), m = p ? c(p[1]) || null : f;
|
|
1948
|
+
return ne({
|
|
1949
|
+
layers: await Yn(u),
|
|
1950
|
+
palette: n,
|
|
1951
|
+
aspect: a,
|
|
1952
|
+
canvasW: e.w,
|
|
1953
|
+
canvasH: e.h,
|
|
1954
|
+
rasterScale: s,
|
|
1955
|
+
fill: m,
|
|
1956
|
+
fillOpacity: e.fillOpacity ?? 1,
|
|
1957
|
+
viewW: e.viewW,
|
|
1958
|
+
edge: e.edge ?? null
|
|
1959
|
+
});
|
|
1960
|
+
}
|
|
1961
|
+
async function Zn(e) {
|
|
1962
|
+
let t = await createImageBitmap(e), n = document.createElement("canvas");
|
|
1963
|
+
n.width = t.width, n.height = t.height;
|
|
1964
|
+
let r = n.getContext("2d");
|
|
1965
|
+
return r.fillStyle = "#fff", r.fillRect(0, 0, n.width, n.height), r.drawImage(t, 0, 0), {
|
|
1966
|
+
blob: await new Promise((e) => n.toBlob(e, "image/jpeg", .92)),
|
|
1967
|
+
w: n.width,
|
|
1968
|
+
h: n.height
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1971
|
+
async function Qn({ blob: e, w: t, h: n }, r, i) {
|
|
1972
|
+
let a = new Uint8Array(await e.arrayBuffer()), o = new TextEncoder(), s = `q ${r} 0 0 ${i} 0 0 cm /Im0 Do Q`, c = [
|
|
1973
|
+
"<< /Type /Catalog /Pages 2 0 R >>",
|
|
1974
|
+
"<< /Type /Pages /Kids [3 0 R] /Count 1 >>",
|
|
1975
|
+
`<< /Type /Page /Parent 2 0 R /MediaBox [0 0 ${r} ${i}] /Resources << /XObject << /Im0 4 0 R >> >> /Contents 5 0 R >>`,
|
|
1976
|
+
[
|
|
1977
|
+
`<< /Type /XObject /Subtype /Image /Width ${t} /Height ${n} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length ${a.length} >>\nstream\n`,
|
|
1978
|
+
a,
|
|
1979
|
+
"\nendstream"
|
|
1980
|
+
],
|
|
1981
|
+
`<< /Length ${s.length} >>\nstream\n${s}\nendstream`
|
|
1982
|
+
], l = [], u = 0, d = (e) => {
|
|
1983
|
+
let t = typeof e == "string" ? o.encode(e) : e;
|
|
1984
|
+
l.push(t), u += t.length;
|
|
1985
|
+
}, f = [];
|
|
1986
|
+
d("%PDF-1.4\n"), c.forEach((e, t) => {
|
|
1987
|
+
f.push(u), d(`${t + 1} 0 obj\n`), [].concat(e).forEach(d), d("\nendobj\n");
|
|
1988
|
+
});
|
|
1989
|
+
let p = u;
|
|
1990
|
+
return d(`xref\n0 ${c.length + 1}\n0000000000 65535 f \n${f.map((e) => `${String(e).padStart(10, "0")} 00000 n \n`).join("")}`), d(`trailer\n<< /Size ${c.length + 1} /Root 1 0 R >>\nstartxref\n${p}\n%%EOF\n`), new Blob(l, { type: "application/pdf" });
|
|
1991
|
+
}
|
|
1992
|
+
async function $n(e, { format: t, scale: n = 1, fill: r = !0, palette: i, aspect: a, name: o, suffix: s = "" }) {
|
|
1993
|
+
let c = t !== "svg", l = await Xn(e, {
|
|
1994
|
+
palette: i,
|
|
1995
|
+
aspect: a,
|
|
1996
|
+
fill: r,
|
|
1997
|
+
rasterScale: c ? n : 1
|
|
1998
|
+
}), u = `${Q(o ?? e.name)}${s ? Q(s, "") : !c || n === 1 ? "" : `@${n}x`}`;
|
|
1999
|
+
if (t === "svg") return {
|
|
2000
|
+
name: `${u}.svg`,
|
|
2001
|
+
blob: new Blob([l], { type: "image/svg+xml" })
|
|
2002
|
+
};
|
|
2003
|
+
let d = await ke(l, n);
|
|
2004
|
+
if (t === "png") return {
|
|
2005
|
+
name: `${u}.png`,
|
|
2006
|
+
blob: d
|
|
2007
|
+
};
|
|
2008
|
+
let f = await Zn(d);
|
|
2009
|
+
return t === "jpg" ? {
|
|
2010
|
+
name: `${u}.jpg`,
|
|
2011
|
+
blob: f.blob
|
|
2012
|
+
} : {
|
|
2013
|
+
name: `${u}.pdf`,
|
|
2014
|
+
blob: await Qn(f, e.w, e.h)
|
|
2015
|
+
};
|
|
2016
|
+
}
|
|
2017
|
+
var er = () => new Promise((e) => requestAnimationFrame(e));
|
|
2018
|
+
async function tr(e, t, n, r) {
|
|
2019
|
+
let i = URL.createObjectURL(new Blob([t], { type: "image/svg+xml" }));
|
|
2020
|
+
try {
|
|
2021
|
+
let t = new Image();
|
|
2022
|
+
await new Promise((e, n) => {
|
|
2023
|
+
t.onload = e, t.onerror = () => n(/* @__PURE__ */ Error("SVG rasterize failed")), t.src = i;
|
|
2024
|
+
}), e.clearRect(0, 0, n, r), e.drawImage(t, 0, 0, n, r);
|
|
2025
|
+
} finally {
|
|
2026
|
+
URL.revokeObjectURL(i);
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
async function nr(e, { scale: n = 1, palette: a, aspect: o, name: s, onProgress: c }) {
|
|
2030
|
+
let l = Math.max(1, Math.round(t.getLoopSeconds() * Z)), u = Math.round(e.w * n), d = Math.round(e.h * n), p = document.createElement("canvas");
|
|
2031
|
+
p.width = u, p.height = d;
|
|
2032
|
+
let m = p.getContext("2d"), { Output: ee, WebMOutputFormat: h, BufferTarget: g, CanvasSource: _ } = await import("./src-D-TQbBo2.js"), v = new ee({
|
|
2033
|
+
format: new h(),
|
|
2034
|
+
target: new g()
|
|
2035
|
+
}), y = new _(p, {
|
|
2036
|
+
codec: "vp9",
|
|
2037
|
+
bitrate: Math.round(u * d * Z * .1)
|
|
2038
|
+
});
|
|
2039
|
+
v.addVideoTrack(y, { frameRate: Z }), await v.start();
|
|
2040
|
+
let b = f();
|
|
2041
|
+
for (let n = 0; n < l; n++) i(r(e.layers), {
|
|
2042
|
+
...t.getCtx(),
|
|
2043
|
+
t: n / l,
|
|
2044
|
+
smoothState: b
|
|
2045
|
+
});
|
|
2046
|
+
for (let r = 0; r < l; r++) t.seek(r / l), await er(), await er(), await tr(m, await Xn(e, {
|
|
2047
|
+
palette: a,
|
|
2048
|
+
aspect: o,
|
|
2049
|
+
rasterScale: n,
|
|
2050
|
+
ctx: {
|
|
2051
|
+
...t.getCtx(),
|
|
2052
|
+
smoothState: b
|
|
2053
|
+
}
|
|
2054
|
+
}), u, d), await y.add(r / Z, 1 / Z), c?.(r + 1, l);
|
|
2055
|
+
return await v.finalize(), {
|
|
2056
|
+
name: `${Q(s ?? e.name)}.webm`,
|
|
2057
|
+
blob: new Blob([v.target.buffer], { type: "video/webm" })
|
|
2058
|
+
};
|
|
2059
|
+
}
|
|
2060
|
+
var rr = (e, { names: n = [], onProgress: r, ...i }) => he(async () => {
|
|
2061
|
+
let a = t.isPlaying(), o = t.getT();
|
|
2062
|
+
a && t.pause();
|
|
2063
|
+
try {
|
|
2064
|
+
let t = [];
|
|
2065
|
+
for (let a = 0; a < e.length; a++) t.push(await nr(e[a], {
|
|
2066
|
+
...i,
|
|
2067
|
+
name: n[a],
|
|
2068
|
+
onProgress: (t, n) => r?.(a * n + t, e.length * n)
|
|
2069
|
+
}));
|
|
2070
|
+
return t;
|
|
2071
|
+
} finally {
|
|
2072
|
+
t.seek(o), a && t.play();
|
|
2073
|
+
}
|
|
2074
|
+
});
|
|
2075
|
+
async function ir(e, t) {
|
|
2076
|
+
if (e.length) {
|
|
2077
|
+
if (e.length === 1) {
|
|
2078
|
+
C(e[0].blob, e[0].name);
|
|
2079
|
+
return;
|
|
2080
|
+
}
|
|
2081
|
+
C(w(await Promise.all(e.map(async (e) => ({
|
|
2082
|
+
name: e.name,
|
|
2083
|
+
data: new Uint8Array(await e.blob.arrayBuffer())
|
|
2084
|
+
})))), `${Q(t)}.zip`);
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
//#endregion
|
|
2088
|
+
//#region src/editor/kolbox/files/portable.js
|
|
2089
|
+
var ar = "kol-design-editor", or = 1, sr = ".kol.json", cr = 15e5;
|
|
2090
|
+
async function lr(e, { media: t = !0, theme: n = !0 } = {}, r = cr) {
|
|
2091
|
+
let i = { ...e };
|
|
2092
|
+
return t && (i.layers = await Yn(e.layers ?? [], { clips: r })), n || (i.palette = null), i;
|
|
2093
|
+
}
|
|
2094
|
+
async function ur(e, t) {
|
|
2095
|
+
let n = {
|
|
2096
|
+
page: ar,
|
|
2097
|
+
version: or,
|
|
2098
|
+
spec: await lr(e, {
|
|
2099
|
+
media: !0,
|
|
2100
|
+
theme: !0
|
|
2101
|
+
}, Infinity)
|
|
2102
|
+
};
|
|
2103
|
+
return {
|
|
2104
|
+
blob: new Blob([JSON.stringify(n, null, 2)], { type: "application/json" }),
|
|
2105
|
+
name: `${Q(t)}${sr}`
|
|
2106
|
+
};
|
|
2107
|
+
}
|
|
2108
|
+
async function dr(e) {
|
|
2109
|
+
let t;
|
|
2110
|
+
try {
|
|
2111
|
+
t = JSON.parse(await e.text());
|
|
2112
|
+
} catch {
|
|
2113
|
+
throw Error("Not a JSON file");
|
|
2114
|
+
}
|
|
2115
|
+
if (!t || t.page !== ar) throw Error("Not a KOL file");
|
|
2116
|
+
if (t.version !== or) throw Error(`Unsupported file version (${t.version})`);
|
|
2117
|
+
if (!t.spec || typeof t.spec != "object" || !Array.isArray(t.spec.layers)) throw Error("No document in file");
|
|
2118
|
+
return {
|
|
2119
|
+
...t.spec,
|
|
2120
|
+
name: t.spec.name || e.name.replace(/\.kol\.json$|\.json$/i, "")
|
|
2121
|
+
};
|
|
2122
|
+
}
|
|
2123
|
+
var fr = () => new Promise((e) => {
|
|
2124
|
+
let t = document.createElement("input");
|
|
2125
|
+
t.type = "file", t.accept = `${sr},.json,application/json`, t.onchange = () => e(t.files?.[0] ?? null), t.addEventListener("cancel", () => e(null)), t.click();
|
|
2126
|
+
});
|
|
2127
|
+
//#endregion
|
|
2128
|
+
export { Pt as $, kn as A, Zt as B, vn as C, Mn as D, Nn as E, pn as F, Jt as G, Xt as H, nn as I, Gt as J, U as K, tn as L, Dn as M, En as N, On as O, Pn as P, Ft as Q, en as R, Cn as S, xn as T, G as U, Qt as V, Yt as W, Rt as X, qt as Y, Bt as Z, hn as _, Fn as a, Re as at, Tn as b, Un as c, Fe as ct, rr as d, Et as et, Vn as f, q as g, ir as h, dr as i, Ve as it, jn as j, wn as k, $n as l, N as lt, Hn as m, fr as n, Tt as nt, Ln as o, Ie as ot, Q as p, Kt as q, ur as r, at as rt, In as s, Pe as st, lr as t, kt as tt, Xn as u, bn as v, Sn as w, An as x, yn as y, $t as z };
|