@magicpages/kalotyp-core 0.1.0 → 0.1.2
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/LICENSE +21 -0
- package/dist/canvas/viewport-controller.d.ts.map +1 -1
- package/dist/index.d.ts +32 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2197 -1969
- package/dist/index.js.map +1 -1
- package/dist/pipeline/encode.d.ts.map +1 -1
- package/dist/plugins/annotate/bake.d.ts.map +1 -1
- package/dist/plugins/annotate/geometry.d.ts.map +1 -1
- package/dist/plugins/annotate/hit-test.d.ts.map +1 -1
- package/dist/plugins/crop/aspect-ratio.d.ts.map +1 -1
- package/dist/plugins/crop/resize.d.ts.map +1 -1
- package/dist/plugins/finetune/math.d.ts +2 -2
- package/dist/plugins/finetune/math.d.ts.map +1 -1
- package/dist/plugins/resize/bake.d.ts.map +1 -1
- package/dist/plugins/rotate/bake.d.ts.map +1 -1
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -1,1976 +1,2204 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
1
|
+
//#region src/canvas/bake-canvas.ts
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
if (r()) return {
|
|
4
|
+
kind: "offscreen",
|
|
5
|
+
canvas: new OffscreenCanvas(e, t)
|
|
6
|
+
};
|
|
7
|
+
let n = document.createElement("canvas");
|
|
8
|
+
return n.width = e, n.height = t, {
|
|
9
|
+
kind: "html",
|
|
10
|
+
canvas: n
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function t(e) {
|
|
14
|
+
if (e.kind === "offscreen") {
|
|
15
|
+
let t = e.canvas.getContext("2d");
|
|
16
|
+
if (!t) throw Error("2D canvas context is not available");
|
|
17
|
+
return t;
|
|
18
|
+
}
|
|
19
|
+
let t = e.canvas.getContext("2d");
|
|
20
|
+
if (!t) throw Error("2D canvas context is not available");
|
|
21
|
+
return t;
|
|
22
|
+
}
|
|
23
|
+
async function n(e, t, n) {
|
|
24
|
+
return e.kind === "offscreen" ? e.canvas.convertToBlob({
|
|
25
|
+
type: t,
|
|
26
|
+
quality: n
|
|
27
|
+
}) : new Promise((r, i) => {
|
|
28
|
+
e.canvas.toBlob((e) => {
|
|
29
|
+
e ? r(e) : i(/* @__PURE__ */ Error("toBlob produced null"));
|
|
30
|
+
}, t, n);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function r() {
|
|
34
|
+
return typeof OffscreenCanvas > "u" ? !1 : typeof OffscreenCanvas.prototype.convertToBlob == "function";
|
|
35
|
+
}
|
|
36
|
+
var i = /* @__PURE__ */ new Map();
|
|
37
|
+
function a(t) {
|
|
38
|
+
let r = i.get(t);
|
|
39
|
+
if (r) return r;
|
|
40
|
+
let a = (async () => {
|
|
41
|
+
try {
|
|
42
|
+
let r = await n(e(1, 1), t, .5);
|
|
43
|
+
return r.type === t && r.size > 0;
|
|
44
|
+
} catch {
|
|
45
|
+
return !1;
|
|
46
|
+
}
|
|
47
|
+
})();
|
|
48
|
+
return i.set(t, a), a;
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/canvas/load-image.ts
|
|
52
|
+
async function o(e) {
|
|
53
|
+
if (typeof createImageBitmap == "function") {
|
|
54
|
+
let t = await s(e);
|
|
55
|
+
if (t) try {
|
|
56
|
+
let e = await createImageBitmap(t, { imageOrientation: "from-image" });
|
|
57
|
+
return {
|
|
58
|
+
element: e,
|
|
59
|
+
width: e.width,
|
|
60
|
+
height: e.height
|
|
61
|
+
};
|
|
62
|
+
} catch {}
|
|
63
|
+
}
|
|
64
|
+
return c(e);
|
|
65
|
+
}
|
|
66
|
+
async function s(e) {
|
|
67
|
+
if (e instanceof Blob) return e;
|
|
68
|
+
if (typeof fetch != "function") return null;
|
|
69
|
+
try {
|
|
70
|
+
let t = await fetch(e, { credentials: "omit" });
|
|
71
|
+
return t.ok ? await t.blob() : null;
|
|
72
|
+
} catch {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async function c(e) {
|
|
77
|
+
let t = typeof e == "string" ? e : URL.createObjectURL(e), n = typeof e != "string";
|
|
78
|
+
try {
|
|
79
|
+
let e = await new Promise((e, n) => {
|
|
80
|
+
let r = new Image();
|
|
81
|
+
r.crossOrigin = "anonymous", r.onload = () => e(r), r.onerror = () => n(/* @__PURE__ */ Error(`Failed to load image: ${t}`)), r.src = t;
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
element: e,
|
|
85
|
+
width: e.naturalWidth,
|
|
86
|
+
height: e.naturalHeight
|
|
87
|
+
};
|
|
88
|
+
} finally {
|
|
89
|
+
n && URL.revokeObjectURL(t);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/canvas/viewport.ts
|
|
94
|
+
var l = Object.freeze({
|
|
95
|
+
zoom: 1,
|
|
96
|
+
panX: 0,
|
|
97
|
+
panY: 0
|
|
70
98
|
});
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
function
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
function
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
function
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
case "tr":
|
|
408
|
-
return { x: t.x + t.width - n, y: t.y, width: n, height: e };
|
|
409
|
-
case "bl":
|
|
410
|
-
return { x: t.x, y: t.y + t.height - e, width: n, height: e };
|
|
411
|
-
case "br":
|
|
412
|
-
return {
|
|
413
|
-
x: t.x + t.width - n,
|
|
414
|
-
y: t.y + t.height - e,
|
|
415
|
-
width: n,
|
|
416
|
-
height: e
|
|
417
|
-
};
|
|
418
|
-
case "center":
|
|
419
|
-
return {
|
|
420
|
-
x: t.x + (t.width - n) / 2,
|
|
421
|
-
y: t.y + (t.height - e) / 2,
|
|
422
|
-
width: n,
|
|
423
|
-
height: e
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
function It(t, n, e) {
|
|
428
|
-
const i = O(t, n);
|
|
429
|
-
return lt(t, i.width, i.height, e);
|
|
430
|
-
}
|
|
431
|
-
function Zn(t, n, e, i) {
|
|
432
|
-
const r = i.minSize ?? 1, o = t.x, a = t.y, c = t.x + t.width, l = t.y + t.height;
|
|
433
|
-
let s = o, u = a, h = c, f = l;
|
|
434
|
-
(n === "tl" || n === "l" || n === "bl") && (s = e.x), (n === "tr" || n === "r" || n === "br") && (h = e.x), (n === "tl" || n === "t" || n === "tr") && (u = e.y), (n === "bl" || n === "b" || n === "br") && (f = e.y), (n === "l" || n === "r") && (u = a, f = l), (n === "t" || n === "b") && (s = o, h = c);
|
|
435
|
-
let d = Math.min(s, h), m = Math.min(u, f), p = Math.abs(h - s), A = Math.abs(f - u);
|
|
436
|
-
p < r && (p = r, n === "tl" || n === "l" || n === "bl" ? d = c - r : (n === "tr" || n === "r" || n === "br") && (d = o)), A < r && (A = r, n === "tl" || n === "t" || n === "tr" ? m = l - r : (n === "bl" || n === "b" || n === "br") && (m = a));
|
|
437
|
-
let M = { x: d, y: m, width: p, height: A };
|
|
438
|
-
return M = P(M, i.bounds), i.aspectRatio !== void 0 && i.aspectRatio > 0 && (M = Et(M, i.aspectRatio, Tt(n), i.bounds)), M;
|
|
439
|
-
}
|
|
440
|
-
function Tt(t) {
|
|
441
|
-
switch (t) {
|
|
442
|
-
case "tl":
|
|
443
|
-
return "br";
|
|
444
|
-
case "tr":
|
|
445
|
-
return "bl";
|
|
446
|
-
case "bl":
|
|
447
|
-
return "tr";
|
|
448
|
-
case "br":
|
|
449
|
-
return "tl";
|
|
450
|
-
case "t":
|
|
451
|
-
return "bl";
|
|
452
|
-
case "b":
|
|
453
|
-
return "tl";
|
|
454
|
-
case "l":
|
|
455
|
-
return "tr";
|
|
456
|
-
case "r":
|
|
457
|
-
return "tl";
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
function kt(t, n) {
|
|
461
|
-
const [e] = t;
|
|
462
|
-
return e === void 0 || n === void 0 ? !0 : n === "landscape" ? e >= 1 : n === "portrait" ? e < 1 : !0;
|
|
463
|
-
}
|
|
464
|
-
function te(t, n) {
|
|
465
|
-
return t.filter((e) => kt(e, n));
|
|
466
|
-
}
|
|
467
|
-
function ne(t) {
|
|
468
|
-
return {
|
|
469
|
-
rect: { x: 0, y: 0, width: t.imageSize.width, height: t.imageSize.height },
|
|
470
|
-
aspectRatio: void 0,
|
|
471
|
-
activePresetIndex: Ct(t.presets),
|
|
472
|
-
presets: t.presets,
|
|
473
|
-
imageSize: t.imageSize
|
|
474
|
-
};
|
|
475
|
-
}
|
|
476
|
-
function ee(t, n) {
|
|
477
|
-
const e = t.presets[n];
|
|
478
|
-
if (!e) return t;
|
|
479
|
-
const [i] = e;
|
|
480
|
-
if (i === void 0)
|
|
481
|
-
return { ...t, aspectRatio: void 0, activePresetIndex: n };
|
|
482
|
-
const r = {
|
|
483
|
-
x: 0,
|
|
484
|
-
y: 0,
|
|
485
|
-
width: t.imageSize.width,
|
|
486
|
-
height: t.imageSize.height
|
|
487
|
-
}, o = O(r, i);
|
|
488
|
-
return { ...t, rect: o, aspectRatio: i, activePresetIndex: n };
|
|
489
|
-
}
|
|
490
|
-
function Ct(t) {
|
|
491
|
-
return t.findIndex(([n]) => n === void 0);
|
|
492
|
-
}
|
|
493
|
-
function ie(t, n) {
|
|
494
|
-
const e = St(n.rect), i = R(e.x, 0, t.width), r = R(e.y, 0, t.height), o = R(e.width, 1, t.width - i), a = R(e.height, 1, t.height - r), c = g(o, a);
|
|
495
|
-
if (c.kind === "offscreen") {
|
|
496
|
-
const s = c.canvas.getContext("2d");
|
|
497
|
-
if (!s) throw new Error("2D canvas context is not available");
|
|
498
|
-
return s.drawImage(t.bitmap, i, r, o, a, 0, 0, o, a), { bitmap: c.canvas, width: o, height: a, mimeType: t.mimeType };
|
|
499
|
-
}
|
|
500
|
-
const l = c.canvas.getContext("2d");
|
|
501
|
-
if (!l) throw new Error("2D canvas context is not available");
|
|
502
|
-
return l.drawImage(t.bitmap, i, r, o, a, 0, 0, o, a), { bitmap: c.canvas, width: o, height: a, mimeType: t.mimeType };
|
|
503
|
-
}
|
|
504
|
-
function R(t, n, e) {
|
|
505
|
-
return Math.max(n, Math.min(e, t));
|
|
506
|
-
}
|
|
507
|
-
const ut = {
|
|
508
|
-
mimeChoice: "auto",
|
|
509
|
-
quality: 0.85,
|
|
510
|
-
stripMetadata: !0
|
|
511
|
-
}, re = [
|
|
512
|
-
"image/png",
|
|
513
|
-
"image/jpeg",
|
|
514
|
-
"image/webp",
|
|
515
|
-
"image/avif"
|
|
99
|
+
function u(e, t, n = l) {
|
|
100
|
+
let r = Math.max(0, e.width - e.padding * 2), i = Math.max(0, e.height - e.padding * 2);
|
|
101
|
+
if (t.width <= 0 || t.height <= 0 || r <= 0 || i <= 0) return {
|
|
102
|
+
displayRect: {
|
|
103
|
+
x: e.padding,
|
|
104
|
+
y: e.padding,
|
|
105
|
+
width: 0,
|
|
106
|
+
height: 0
|
|
107
|
+
},
|
|
108
|
+
scale: 0
|
|
109
|
+
};
|
|
110
|
+
let a = Math.min(r / t.width, i / t.height) * Math.max(0, n.zoom || 0), o = t.width * a, s = t.height * a, c = e.padding + (r - o) / 2, u = e.padding + (i - s) / 2, f = c + n.panX, p = u + n.panY;
|
|
111
|
+
return {
|
|
112
|
+
displayRect: {
|
|
113
|
+
x: d(f, c, o, r, e.padding),
|
|
114
|
+
y: d(p, u, s, i, e.padding),
|
|
115
|
+
width: o,
|
|
116
|
+
height: s
|
|
117
|
+
},
|
|
118
|
+
scale: a
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function d(e, t, n, r, i) {
|
|
122
|
+
if (n <= r) return t;
|
|
123
|
+
let a = i, o = i + r, s = a + 1 - n, c = o - 1;
|
|
124
|
+
return e < s ? s : e > c ? c : e;
|
|
125
|
+
}
|
|
126
|
+
function f(e, t) {
|
|
127
|
+
return {
|
|
128
|
+
x: t.displayRect.x + e.x * t.scale,
|
|
129
|
+
y: t.displayRect.y + e.y * t.scale
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function p(e, t) {
|
|
133
|
+
return t.scale === 0 ? {
|
|
134
|
+
x: 0,
|
|
135
|
+
y: 0
|
|
136
|
+
} : {
|
|
137
|
+
x: (e.x - t.displayRect.x) / t.scale,
|
|
138
|
+
y: (e.y - t.displayRect.y) / t.scale
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function m(e, t) {
|
|
142
|
+
return {
|
|
143
|
+
x: t.displayRect.x + e.x * t.scale,
|
|
144
|
+
y: t.displayRect.y + e.y * t.scale,
|
|
145
|
+
width: e.width * t.scale,
|
|
146
|
+
height: e.height * t.scale
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function h(e, t) {
|
|
150
|
+
return t.scale === 0 ? {
|
|
151
|
+
x: 0,
|
|
152
|
+
y: 0,
|
|
153
|
+
width: 0,
|
|
154
|
+
height: 0
|
|
155
|
+
} : {
|
|
156
|
+
x: (e.x - t.displayRect.x) / t.scale,
|
|
157
|
+
y: (e.y - t.displayRect.y) / t.scale,
|
|
158
|
+
width: e.width / t.scale,
|
|
159
|
+
height: e.height / t.scale
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/canvas/viewport-controller.ts
|
|
164
|
+
var g = 8, _ = .25, ee = class {
|
|
165
|
+
current;
|
|
166
|
+
isPinching;
|
|
167
|
+
listeners;
|
|
168
|
+
constructor(e = l) {
|
|
169
|
+
this.current = te(e), this.isPinching = !1, this.listeners = /* @__PURE__ */ new Set();
|
|
170
|
+
}
|
|
171
|
+
getTransform() {
|
|
172
|
+
return this.current;
|
|
173
|
+
}
|
|
174
|
+
getSnapshot() {
|
|
175
|
+
return {
|
|
176
|
+
transform: this.current,
|
|
177
|
+
pinching: this.isPinching
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
setTransform(e) {
|
|
181
|
+
let t = te(e);
|
|
182
|
+
y(this.current, t) || (this.current = t, this.emit());
|
|
183
|
+
}
|
|
184
|
+
zoomAt(e, t, n) {
|
|
185
|
+
if (!Number.isFinite(e) || e <= 0) return this.current;
|
|
186
|
+
let r = this.current.zoom, i = v(r * e, _, 8);
|
|
187
|
+
if (i === r) return this.current;
|
|
188
|
+
let a = i / r, o = t.x - n.x, s = t.y - n.y, c = a * this.current.panX + (1 - a) * o, l = a * this.current.panY + (1 - a) * s;
|
|
189
|
+
return this.current = {
|
|
190
|
+
zoom: i,
|
|
191
|
+
panX: c,
|
|
192
|
+
panY: l
|
|
193
|
+
}, this.emit(), this.current;
|
|
194
|
+
}
|
|
195
|
+
panBy(e, t) {
|
|
196
|
+
e === 0 && t === 0 || (this.current = {
|
|
197
|
+
zoom: this.current.zoom,
|
|
198
|
+
panX: this.current.panX + e,
|
|
199
|
+
panY: this.current.panY + t
|
|
200
|
+
}, this.emit());
|
|
201
|
+
}
|
|
202
|
+
resetToFit() {
|
|
203
|
+
y(this.current, l) || (this.current = l, this.emit());
|
|
204
|
+
}
|
|
205
|
+
resetPan() {
|
|
206
|
+
this.current.panX === 0 && this.current.panY === 0 || (this.current = {
|
|
207
|
+
zoom: this.current.zoom,
|
|
208
|
+
panX: 0,
|
|
209
|
+
panY: 0
|
|
210
|
+
}, this.emit());
|
|
211
|
+
}
|
|
212
|
+
getPinching() {
|
|
213
|
+
return this.isPinching;
|
|
214
|
+
}
|
|
215
|
+
setPinching(e) {
|
|
216
|
+
this.isPinching !== e && (this.isPinching = e, this.emit());
|
|
217
|
+
}
|
|
218
|
+
computeViewport(e, t) {
|
|
219
|
+
return u(e, t, this.current);
|
|
220
|
+
}
|
|
221
|
+
subscribe(e) {
|
|
222
|
+
return this.listeners.add(e), () => {
|
|
223
|
+
this.listeners.delete(e);
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
clear() {
|
|
227
|
+
this.listeners.clear();
|
|
228
|
+
}
|
|
229
|
+
emit() {
|
|
230
|
+
let e = this.getSnapshot();
|
|
231
|
+
for (let t of this.listeners) t(e);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
function v(e, t, n) {
|
|
235
|
+
return e < t ? t : e > n ? n : e;
|
|
236
|
+
}
|
|
237
|
+
function te(e) {
|
|
238
|
+
return {
|
|
239
|
+
zoom: v(Number.isFinite(e.zoom) ? e.zoom : 1, _, 8),
|
|
240
|
+
panX: Number.isFinite(e.panX) ? e.panX : 0,
|
|
241
|
+
panY: Number.isFinite(e.panY) ? e.panY : 0
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function y(e, t) {
|
|
245
|
+
return e.zoom === t.zoom && e.panX === t.panX && e.panY === t.panY;
|
|
246
|
+
}
|
|
247
|
+
//#endregion
|
|
248
|
+
//#region src/events/event-bus.ts
|
|
249
|
+
var ne = class {
|
|
250
|
+
listeners = /* @__PURE__ */ new Map();
|
|
251
|
+
on(e, t) {
|
|
252
|
+
let n = this.listeners.get(e);
|
|
253
|
+
return n || (n = /* @__PURE__ */ new Set(), this.listeners.set(e, n)), n.add(t), () => {
|
|
254
|
+
n?.delete(t);
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
off(e, t) {
|
|
258
|
+
this.listeners.get(e)?.delete(t);
|
|
259
|
+
}
|
|
260
|
+
emit(e, t) {
|
|
261
|
+
let n = this.listeners.get(e);
|
|
262
|
+
if (n) for (let e of [...n]) try {
|
|
263
|
+
e(t);
|
|
264
|
+
} catch (e) {
|
|
265
|
+
queueMicrotask(() => {
|
|
266
|
+
throw e;
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
clear() {
|
|
271
|
+
this.listeners.clear();
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
//#endregion
|
|
275
|
+
//#region src/geometry/rect.ts
|
|
276
|
+
function re(e, t) {
|
|
277
|
+
return {
|
|
278
|
+
x: Math.min(e.x, t.x),
|
|
279
|
+
y: Math.min(e.y, t.y),
|
|
280
|
+
width: Math.abs(e.x - t.x),
|
|
281
|
+
height: Math.abs(e.y - t.y)
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
function ie(e) {
|
|
285
|
+
return e.x + e.width;
|
|
286
|
+
}
|
|
287
|
+
function ae(e) {
|
|
288
|
+
return e.y + e.height;
|
|
289
|
+
}
|
|
290
|
+
function oe(e) {
|
|
291
|
+
return {
|
|
292
|
+
x: e.x + e.width / 2,
|
|
293
|
+
y: e.y + e.height / 2
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
function se(e, t) {
|
|
297
|
+
return e.x >= t.x && e.x <= t.x + t.width && e.y >= t.y && e.y <= t.y + t.height;
|
|
298
|
+
}
|
|
299
|
+
function ce(e, t) {
|
|
300
|
+
return e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height;
|
|
301
|
+
}
|
|
302
|
+
function le(e, t, n, r) {
|
|
303
|
+
return b({
|
|
304
|
+
x: e.x + t,
|
|
305
|
+
y: e.y + n,
|
|
306
|
+
width: e.width,
|
|
307
|
+
height: e.height
|
|
308
|
+
}, r);
|
|
309
|
+
}
|
|
310
|
+
function b(e, t) {
|
|
311
|
+
let { x: n, y: r, width: i, height: a } = e;
|
|
312
|
+
return i > t.width && (i = t.width), a > t.height && (a = t.height), n < t.x && (n = t.x), r < t.y && (r = t.y), n + i > t.x + t.width && (n = t.x + t.width - i), r + a > t.y + t.height && (r = t.y + t.height - a), {
|
|
313
|
+
x: n,
|
|
314
|
+
y: r,
|
|
315
|
+
width: i,
|
|
316
|
+
height: a
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function x(e) {
|
|
320
|
+
return {
|
|
321
|
+
x: Math.round(e.x),
|
|
322
|
+
y: Math.round(e.y),
|
|
323
|
+
width: Math.round(e.width),
|
|
324
|
+
height: Math.round(e.height)
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
//#endregion
|
|
328
|
+
//#region src/history/history.ts
|
|
329
|
+
var ue = 50, de = class {
|
|
330
|
+
shadow;
|
|
331
|
+
undoStack = [];
|
|
332
|
+
redoStack = [];
|
|
333
|
+
constructor(e) {
|
|
334
|
+
this.shadow = S(e);
|
|
335
|
+
}
|
|
336
|
+
commit(e) {
|
|
337
|
+
fe(e, this.shadow) || (this.undoStack.push(this.shadow), this.undoStack.length > 50 && this.undoStack.shift(), this.shadow = S(e), this.redoStack.length = 0);
|
|
338
|
+
}
|
|
339
|
+
canUndo() {
|
|
340
|
+
return this.undoStack.length > 0;
|
|
341
|
+
}
|
|
342
|
+
canRedo() {
|
|
343
|
+
return this.redoStack.length > 0;
|
|
344
|
+
}
|
|
345
|
+
undo(e) {
|
|
346
|
+
let t = this.undoStack.pop();
|
|
347
|
+
return t ? (this.redoStack.push(S(e)), this.shadow = t, {
|
|
348
|
+
snapshot: t,
|
|
349
|
+
changed: pe(e, t)
|
|
350
|
+
}) : null;
|
|
351
|
+
}
|
|
352
|
+
redo(e) {
|
|
353
|
+
let t = this.redoStack.pop();
|
|
354
|
+
return t ? (this.undoStack.push(S(e)), this.undoStack.length > 50 && this.undoStack.shift(), this.shadow = t, {
|
|
355
|
+
snapshot: t,
|
|
356
|
+
changed: pe(e, t)
|
|
357
|
+
}) : null;
|
|
358
|
+
}
|
|
359
|
+
size() {
|
|
360
|
+
return {
|
|
361
|
+
undo: this.undoStack.length,
|
|
362
|
+
redo: this.redoStack.length
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
function fe(e, t) {
|
|
367
|
+
if (e.size !== t.size) return !1;
|
|
368
|
+
for (let [n, r] of e) if (!t.has(n) || C(r) !== C(t.get(n))) return !1;
|
|
369
|
+
return !0;
|
|
370
|
+
}
|
|
371
|
+
function pe(e, t) {
|
|
372
|
+
let n = /* @__PURE__ */ new Set();
|
|
373
|
+
for (let [r, i] of t) C(i) !== C(e.get(r)) && n.add(r);
|
|
374
|
+
for (let r of e.keys()) t.has(r) || n.add(r);
|
|
375
|
+
return n;
|
|
376
|
+
}
|
|
377
|
+
function S(e) {
|
|
378
|
+
let t = /* @__PURE__ */ new Map();
|
|
379
|
+
for (let [n, r] of e) t.set(n, structuredClone(r));
|
|
380
|
+
return t;
|
|
381
|
+
}
|
|
382
|
+
function C(e) {
|
|
383
|
+
return JSON.stringify(e, (e, t) => {
|
|
384
|
+
if (t && typeof t == "object" && !Array.isArray(t)) {
|
|
385
|
+
let e = {};
|
|
386
|
+
for (let n of Object.keys(t).sort()) e[n] = t[n];
|
|
387
|
+
return e;
|
|
388
|
+
}
|
|
389
|
+
return t;
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
//#endregion
|
|
393
|
+
//#region src/output/state.ts
|
|
394
|
+
var w = {
|
|
395
|
+
mimeChoice: "auto",
|
|
396
|
+
quality: .85,
|
|
397
|
+
stripMetadata: !0
|
|
398
|
+
}, me = [
|
|
399
|
+
"image/png",
|
|
400
|
+
"image/jpeg",
|
|
401
|
+
"image/webp",
|
|
402
|
+
"image/avif"
|
|
403
|
+
];
|
|
404
|
+
function T(e) {
|
|
405
|
+
return Number.isFinite(e) ? e < 0 ? 0 : e > 1 ? 1 : e : w.quality;
|
|
406
|
+
}
|
|
407
|
+
function he(e, t) {
|
|
408
|
+
return e.mimeChoice === t ? e : {
|
|
409
|
+
...e,
|
|
410
|
+
mimeChoice: t
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
function ge(e, t) {
|
|
414
|
+
let n = T(t);
|
|
415
|
+
return e.quality === n ? e : {
|
|
416
|
+
...e,
|
|
417
|
+
quality: n
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
function _e(e, t) {
|
|
421
|
+
return e.stripMetadata === t ? e : {
|
|
422
|
+
...e,
|
|
423
|
+
stripMetadata: t
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
//#endregion
|
|
427
|
+
//#region src/pipeline/exif.ts
|
|
428
|
+
var E = [255, 216], D = [255, 225], O = [
|
|
429
|
+
69,
|
|
430
|
+
120,
|
|
431
|
+
105,
|
|
432
|
+
102,
|
|
433
|
+
0,
|
|
434
|
+
0
|
|
516
435
|
];
|
|
517
|
-
function
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
async function
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
}
|
|
603
|
-
function
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
}
|
|
611
|
-
function
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
}
|
|
668
|
-
function
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
}
|
|
700
|
-
function
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
}
|
|
731
|
-
function
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
436
|
+
async function ve(e) {
|
|
437
|
+
if (e.output.type && e.output.type !== "image/jpeg") return e.output;
|
|
438
|
+
let t = await ye(e.source);
|
|
439
|
+
if (!be(t, E)) return e.output;
|
|
440
|
+
let n = xe(t);
|
|
441
|
+
if (!n) return e.output;
|
|
442
|
+
let r = await ye(e.output);
|
|
443
|
+
if (!be(r, E)) return e.output;
|
|
444
|
+
let i = new Uint8Array(r.length + n.length);
|
|
445
|
+
return i.set(r.subarray(0, 2), 0), i.set(n, 2), i.set(r.subarray(2), 2 + n.length), new Blob([i], { type: "image/jpeg" });
|
|
446
|
+
}
|
|
447
|
+
async function ye(e) {
|
|
448
|
+
return typeof e.arrayBuffer == "function" ? new Uint8Array(await e.arrayBuffer()) : new Promise((t, n) => {
|
|
449
|
+
let r = new FileReader();
|
|
450
|
+
r.onload = () => {
|
|
451
|
+
let e = r.result;
|
|
452
|
+
e instanceof ArrayBuffer ? t(new Uint8Array(e)) : n(/* @__PURE__ */ Error("FileReader returned a non-ArrayBuffer result"));
|
|
453
|
+
}, r.onerror = () => n(r.error ?? /* @__PURE__ */ Error("FileReader failed")), r.readAsArrayBuffer(e);
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
function be(e, t) {
|
|
457
|
+
if (e.length < t.length) return !1;
|
|
458
|
+
for (let n = 0; n < t.length; n++) if (e[n] !== t[n]) return !1;
|
|
459
|
+
return !0;
|
|
460
|
+
}
|
|
461
|
+
function xe(e) {
|
|
462
|
+
let t = 2;
|
|
463
|
+
for (; t + 4 <= e.length;) {
|
|
464
|
+
if (e[t] !== 255) return;
|
|
465
|
+
let n = e[t + 1];
|
|
466
|
+
if (n === void 0 || n === 218 || n === 217) return;
|
|
467
|
+
let r = e[t + 2] !== void 0 && e[t + 3] !== void 0 ? e[t + 2] * 256 + e[t + 3] : 0;
|
|
468
|
+
if (r < 2) return;
|
|
469
|
+
let i = t + 2 + r;
|
|
470
|
+
if (i > e.length) return;
|
|
471
|
+
if (e[t] === D[0] && e[t + 1] === D[1] && Se(e, t + 4)) return e.slice(t, i);
|
|
472
|
+
t = i;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
function Se(e, t) {
|
|
476
|
+
for (let n = 0; n < O.length; n++) if (e[t + n] !== O[n]) return !1;
|
|
477
|
+
return !0;
|
|
478
|
+
}
|
|
479
|
+
//#endregion
|
|
480
|
+
//#region src/pipeline/encode.ts
|
|
481
|
+
var Ce = "image/png", we = new Set([
|
|
482
|
+
"image/png",
|
|
483
|
+
"image/webp",
|
|
484
|
+
"image/avif"
|
|
485
|
+
]);
|
|
486
|
+
async function Te(e, t) {
|
|
487
|
+
return e.mimeChoice === "auto" ? await a("image/webp") ? "image/webp" : !we.has(t.mimeType) && await a("image/jpeg") ? "image/jpeg" : Ce : await a(e.mimeChoice) ? e.mimeChoice : await a("image/webp") ? "image/webp" : Ce;
|
|
488
|
+
}
|
|
489
|
+
function Ee(e, t) {
|
|
490
|
+
let n = Oe(t);
|
|
491
|
+
if (!e) return `kalotyp-image.${n}`;
|
|
492
|
+
let r = ke(e);
|
|
493
|
+
if (!r) return `kalotyp-image.${n}`;
|
|
494
|
+
let i = je(r);
|
|
495
|
+
return i ? `${i}.${n}` : `kalotyp-image.${n}`;
|
|
496
|
+
}
|
|
497
|
+
async function De(t, r = {}) {
|
|
498
|
+
let i = r.output ?? w, a = await Te(i, t), o = T(i.quality), s = Ee(r.sourceName, a), c = e(t.width, t.height);
|
|
499
|
+
if (c.kind === "offscreen") {
|
|
500
|
+
let e = c.canvas.getContext("2d");
|
|
501
|
+
if (!e) throw Error("2D canvas context is not available");
|
|
502
|
+
e.drawImage(t.bitmap, 0, 0);
|
|
503
|
+
} else {
|
|
504
|
+
let e = c.canvas.getContext("2d");
|
|
505
|
+
if (!e) throw Error("2D canvas context is not available");
|
|
506
|
+
e.drawImage(t.bitmap, 0, 0);
|
|
507
|
+
}
|
|
508
|
+
let l = await n(c, a, o), u = r.output?.stripMetadata === !1 && a === "image/jpeg" && t.mimeType === "image/jpeg" && r.sourceBlob !== void 0 ? await ve({
|
|
509
|
+
source: r.sourceBlob,
|
|
510
|
+
output: l
|
|
511
|
+
}) : l;
|
|
512
|
+
return new File([u], s, { type: a });
|
|
513
|
+
}
|
|
514
|
+
function Oe(e) {
|
|
515
|
+
if (e === "image/jpeg") return "jpg";
|
|
516
|
+
if (e === "image/png") return "png";
|
|
517
|
+
if (e === "image/webp") return "webp";
|
|
518
|
+
if (e === "image/avif") return "avif";
|
|
519
|
+
let t = e.split("/")[1];
|
|
520
|
+
return t && t.length > 0 ? t : "bin";
|
|
521
|
+
}
|
|
522
|
+
function ke(e) {
|
|
523
|
+
let t = Ae(e).split(/[/\\]/);
|
|
524
|
+
return t[t.length - 1];
|
|
525
|
+
}
|
|
526
|
+
function Ae(e) {
|
|
527
|
+
let t = e.indexOf("?");
|
|
528
|
+
return t === -1 ? e : e.slice(0, t);
|
|
529
|
+
}
|
|
530
|
+
function je(e) {
|
|
531
|
+
let t = e.lastIndexOf(".");
|
|
532
|
+
return t <= 0 ? e : e.slice(0, t);
|
|
533
|
+
}
|
|
534
|
+
//#endregion
|
|
535
|
+
//#region src/pipeline/run-chain.ts
|
|
536
|
+
async function Me(e, t) {
|
|
537
|
+
let n = t;
|
|
538
|
+
for (let t of e) n = await t.plugin.bake(t.state, n);
|
|
539
|
+
return n;
|
|
540
|
+
}
|
|
541
|
+
//#endregion
|
|
542
|
+
//#region src/plugins/annotate/smooth.ts
|
|
543
|
+
var Ne = 2;
|
|
544
|
+
function Pe(e) {
|
|
545
|
+
if (e.length <= 1) return [...e];
|
|
546
|
+
let t = e[0];
|
|
547
|
+
if (!t) return [];
|
|
548
|
+
let n = [t], r = t;
|
|
549
|
+
for (let t = 1; t < e.length - 1; t++) {
|
|
550
|
+
let i = e[t];
|
|
551
|
+
if (!i) continue;
|
|
552
|
+
let a = i.x - r.x, o = i.y - r.y;
|
|
553
|
+
a * a + o * o < 4 || (n.push(i), r = i);
|
|
554
|
+
}
|
|
555
|
+
let i = e[e.length - 1];
|
|
556
|
+
return i && i !== r && n.push(i), n;
|
|
557
|
+
}
|
|
558
|
+
function k(e, t) {
|
|
559
|
+
if (t.length === 0) return;
|
|
560
|
+
let n = t[0];
|
|
561
|
+
if (!n) return;
|
|
562
|
+
if (t.length === 1) {
|
|
563
|
+
e.moveTo(n.x, n.y), e.lineTo(n.x, n.y);
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
e.moveTo(n.x, n.y);
|
|
567
|
+
for (let n = 1; n < t.length - 1; n++) {
|
|
568
|
+
let r = t[n], i = t[n + 1];
|
|
569
|
+
if (!r || !i) continue;
|
|
570
|
+
let a = (r.x + i.x) / 2, o = (r.y + i.y) / 2;
|
|
571
|
+
e.quadraticCurveTo(r.x, r.y, a, o);
|
|
572
|
+
}
|
|
573
|
+
let r = t[t.length - 1];
|
|
574
|
+
r && e.lineTo(r.x, r.y);
|
|
575
|
+
}
|
|
576
|
+
//#endregion
|
|
577
|
+
//#region src/plugins/annotate/state.ts
|
|
578
|
+
var Fe = "rgba(255, 235, 59, 0.35)", Ie = 18, Le = 6, Re = 32, ze = "#ff3b30", Be = 4;
|
|
579
|
+
function Ve() {
|
|
580
|
+
return {
|
|
581
|
+
color: ze,
|
|
582
|
+
strokeWidth: 4,
|
|
583
|
+
fillColor: null,
|
|
584
|
+
fontSize: 32
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
function He(e) {
|
|
588
|
+
return {
|
|
589
|
+
shapes: [],
|
|
590
|
+
selectedId: null,
|
|
591
|
+
activeTool: "select",
|
|
592
|
+
currentStyle: Ve(),
|
|
593
|
+
imageSize: e.imageSize,
|
|
594
|
+
nextShapeNumber: 1
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
function Ue(e) {
|
|
598
|
+
return {
|
|
599
|
+
id: `s_${e.nextShapeNumber.toString(36)}`,
|
|
600
|
+
nextShapeNumber: e.nextShapeNumber + 1
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
function We(e, t) {
|
|
604
|
+
return e.activeTool === t ? e : {
|
|
605
|
+
...e,
|
|
606
|
+
activeTool: t,
|
|
607
|
+
selectedId: t === "select" ? e.selectedId : null
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
function Ge(e, t) {
|
|
611
|
+
return {
|
|
612
|
+
...e,
|
|
613
|
+
currentStyle: {
|
|
614
|
+
...e.currentStyle,
|
|
615
|
+
...t
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
function Ke(e, t) {
|
|
620
|
+
return e.selectedId === t ? e : {
|
|
621
|
+
...e,
|
|
622
|
+
selectedId: t
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
function qe(e, t) {
|
|
626
|
+
return {
|
|
627
|
+
...e,
|
|
628
|
+
shapes: [...e.shapes, t],
|
|
629
|
+
selectedId: t.id
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
function Je(e, t) {
|
|
633
|
+
let n = !1, r = e.shapes.map((e) => e.id === t.id ? (n = !0, t) : e);
|
|
634
|
+
return n ? {
|
|
635
|
+
...e,
|
|
636
|
+
shapes: r
|
|
637
|
+
} : e;
|
|
638
|
+
}
|
|
639
|
+
function Ye(e, t) {
|
|
640
|
+
let n = e.shapes.filter((e) => e.id !== t);
|
|
641
|
+
return n.length === e.shapes.length ? e : {
|
|
642
|
+
...e,
|
|
643
|
+
shapes: n,
|
|
644
|
+
selectedId: e.selectedId === t ? null : e.selectedId
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
function Xe(e, t) {
|
|
648
|
+
if (t !== null) return e.shapes.find((e) => e.id === t);
|
|
649
|
+
}
|
|
650
|
+
function Ze(e) {
|
|
651
|
+
let { x: t, y: n, width: r, height: i } = e;
|
|
652
|
+
return r < 0 && (t += r, r = -r), i < 0 && (n += i, i = -i), {
|
|
653
|
+
x: t,
|
|
654
|
+
y: n,
|
|
655
|
+
width: r,
|
|
656
|
+
height: i
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
function Qe(e, t, n) {
|
|
660
|
+
switch (e.kind) {
|
|
661
|
+
case "text": return {
|
|
662
|
+
...e,
|
|
663
|
+
x: e.x + t,
|
|
664
|
+
y: e.y + n
|
|
665
|
+
};
|
|
666
|
+
case "rect":
|
|
667
|
+
case "ellipse": return {
|
|
668
|
+
...e,
|
|
669
|
+
x: e.x + t,
|
|
670
|
+
y: e.y + n
|
|
671
|
+
};
|
|
672
|
+
case "arrow": return {
|
|
673
|
+
...e,
|
|
674
|
+
x1: e.x1 + t,
|
|
675
|
+
y1: e.y1 + n,
|
|
676
|
+
x2: e.x2 + t,
|
|
677
|
+
y2: e.y2 + n
|
|
678
|
+
};
|
|
679
|
+
case "freehand":
|
|
680
|
+
case "highlight": return {
|
|
681
|
+
...e,
|
|
682
|
+
points: e.points.map((e) => ({
|
|
683
|
+
x: e.x + t,
|
|
684
|
+
y: e.y + n
|
|
685
|
+
}))
|
|
686
|
+
};
|
|
687
|
+
default: return A(e);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
function A(e) {
|
|
691
|
+
throw Error(`Unhandled annotation shape kind: ${JSON.stringify(e)}`);
|
|
692
|
+
}
|
|
693
|
+
function $e(e, t, n) {
|
|
694
|
+
if (t === "horizontal") switch (e.kind) {
|
|
695
|
+
case "rect":
|
|
696
|
+
case "ellipse": return {
|
|
697
|
+
...e,
|
|
698
|
+
x: n.width - e.x - e.width
|
|
699
|
+
};
|
|
700
|
+
case "text": return {
|
|
701
|
+
...e,
|
|
702
|
+
x: n.width - e.x
|
|
703
|
+
};
|
|
704
|
+
case "arrow": return {
|
|
705
|
+
...e,
|
|
706
|
+
x1: n.width - e.x1,
|
|
707
|
+
x2: n.width - e.x2
|
|
708
|
+
};
|
|
709
|
+
case "freehand":
|
|
710
|
+
case "highlight": return {
|
|
711
|
+
...e,
|
|
712
|
+
points: e.points.map((e) => ({
|
|
713
|
+
x: n.width - e.x,
|
|
714
|
+
y: e.y
|
|
715
|
+
}))
|
|
716
|
+
};
|
|
717
|
+
default: return A(e);
|
|
718
|
+
}
|
|
719
|
+
switch (e.kind) {
|
|
720
|
+
case "rect":
|
|
721
|
+
case "ellipse": return {
|
|
722
|
+
...e,
|
|
723
|
+
y: n.height - e.y - e.height
|
|
724
|
+
};
|
|
725
|
+
case "text": return {
|
|
726
|
+
...e,
|
|
727
|
+
y: n.height - e.y
|
|
728
|
+
};
|
|
729
|
+
case "arrow": return {
|
|
730
|
+
...e,
|
|
731
|
+
y1: n.height - e.y1,
|
|
732
|
+
y2: n.height - e.y2
|
|
733
|
+
};
|
|
734
|
+
case "freehand":
|
|
735
|
+
case "highlight": return {
|
|
736
|
+
...e,
|
|
737
|
+
points: e.points.map((e) => ({
|
|
738
|
+
x: e.x,
|
|
739
|
+
y: n.height - e.y
|
|
740
|
+
}))
|
|
741
|
+
};
|
|
742
|
+
default: return A(e);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
function et(e, t, n) {
|
|
746
|
+
if (t === 0) return e;
|
|
747
|
+
let r = (e, r) => t === 1 ? {
|
|
748
|
+
x: n.height - r,
|
|
749
|
+
y: e
|
|
750
|
+
} : t === 2 ? {
|
|
751
|
+
x: n.width - e,
|
|
752
|
+
y: n.height - r
|
|
753
|
+
} : {
|
|
754
|
+
x: r,
|
|
755
|
+
y: n.width - e
|
|
756
|
+
};
|
|
757
|
+
switch (e.kind) {
|
|
758
|
+
case "rect":
|
|
759
|
+
case "ellipse": {
|
|
760
|
+
let t = [r(e.x, e.y), r(e.x + e.width, e.y + e.height)], n = Math.min(t[0].x, t[1].x), i = Math.min(t[0].y, t[1].y), a = Math.abs(t[1].x - t[0].x), o = Math.abs(t[1].y - t[0].y);
|
|
761
|
+
return {
|
|
762
|
+
...e,
|
|
763
|
+
x: n,
|
|
764
|
+
y: i,
|
|
765
|
+
width: a,
|
|
766
|
+
height: o
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
case "text": {
|
|
770
|
+
let t = r(e.x, e.y);
|
|
771
|
+
return {
|
|
772
|
+
...e,
|
|
773
|
+
x: t.x,
|
|
774
|
+
y: t.y
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
case "arrow": {
|
|
778
|
+
let t = r(e.x1, e.y1), n = r(e.x2, e.y2);
|
|
779
|
+
return {
|
|
780
|
+
...e,
|
|
781
|
+
x1: t.x,
|
|
782
|
+
y1: t.y,
|
|
783
|
+
x2: n.x,
|
|
784
|
+
y2: n.y
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
case "freehand":
|
|
788
|
+
case "highlight": return {
|
|
789
|
+
...e,
|
|
790
|
+
points: e.points.map((e) => r(e.x, e.y))
|
|
791
|
+
};
|
|
792
|
+
default: return A(e);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
function tt(e, t) {
|
|
796
|
+
return e.shapes.length === 0 ? e : {
|
|
797
|
+
...e,
|
|
798
|
+
shapes: e.shapes.map(t)
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
var nt = [
|
|
802
|
+
"text",
|
|
803
|
+
"rect",
|
|
804
|
+
"ellipse",
|
|
805
|
+
"arrow"
|
|
782
806
|
];
|
|
783
|
-
function
|
|
784
|
-
|
|
785
|
-
}
|
|
786
|
-
function
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
}
|
|
966
|
-
}
|
|
807
|
+
function rt(e) {
|
|
808
|
+
return e === "text" || e === "rect" || e === "ellipse" || e === "arrow";
|
|
809
|
+
}
|
|
810
|
+
function it(e, t) {
|
|
811
|
+
let { imageSize: n, style: r, id: i } = t, a = Math.min(n.width, n.height), o = n.width / 2, s = n.height / 2;
|
|
812
|
+
switch (e) {
|
|
813
|
+
case "rect":
|
|
814
|
+
case "ellipse": {
|
|
815
|
+
let t = Math.max(80, Math.round(a * .25)), n = Math.round(o - t / 2), c = Math.round(s - t / 2);
|
|
816
|
+
return e === "rect" ? {
|
|
817
|
+
id: i,
|
|
818
|
+
kind: "rect",
|
|
819
|
+
x: n,
|
|
820
|
+
y: c,
|
|
821
|
+
width: t,
|
|
822
|
+
height: t,
|
|
823
|
+
strokeColor: r.color,
|
|
824
|
+
strokeWidth: r.strokeWidth,
|
|
825
|
+
fillColor: r.fillColor
|
|
826
|
+
} : {
|
|
827
|
+
id: i,
|
|
828
|
+
kind: "ellipse",
|
|
829
|
+
x: n,
|
|
830
|
+
y: c,
|
|
831
|
+
width: t,
|
|
832
|
+
height: t,
|
|
833
|
+
strokeColor: r.color,
|
|
834
|
+
strokeWidth: r.strokeWidth,
|
|
835
|
+
fillColor: r.fillColor
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
case "arrow": {
|
|
839
|
+
let e = Math.max(100, Math.round(a * .3)), t = Math.round(o - e / 2), n = t + e, c = Math.round(s);
|
|
840
|
+
return {
|
|
841
|
+
id: i,
|
|
842
|
+
kind: "arrow",
|
|
843
|
+
x1: t,
|
|
844
|
+
y1: c,
|
|
845
|
+
x2: n,
|
|
846
|
+
y2: c,
|
|
847
|
+
color: r.color,
|
|
848
|
+
strokeWidth: r.strokeWidth
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
case "text": return {
|
|
852
|
+
id: i,
|
|
853
|
+
kind: "text",
|
|
854
|
+
x: Math.round(o),
|
|
855
|
+
y: Math.round(s - r.fontSize / 2),
|
|
856
|
+
text: "",
|
|
857
|
+
fontSize: r.fontSize,
|
|
858
|
+
color: r.color,
|
|
859
|
+
textAlign: "center"
|
|
860
|
+
};
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
//#endregion
|
|
864
|
+
//#region src/plugins/annotate/bake.ts
|
|
865
|
+
var at = "-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif";
|
|
866
|
+
async function ot(n, r) {
|
|
867
|
+
if (n.shapes.length === 0) return r;
|
|
868
|
+
let i = e(r.width, r.height), a = t(i);
|
|
869
|
+
a.imageSmoothingEnabled = !0, a.imageSmoothingQuality = "high", a.drawImage(r.bitmap, 0, 0, r.width, r.height);
|
|
870
|
+
for (let e of n.shapes) j(a, e);
|
|
871
|
+
return {
|
|
872
|
+
bitmap: i.canvas,
|
|
873
|
+
width: r.width,
|
|
874
|
+
height: r.height,
|
|
875
|
+
mimeType: r.mimeType
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
function j(e, t) {
|
|
879
|
+
switch (t.kind) {
|
|
880
|
+
case "text":
|
|
881
|
+
st(e, t);
|
|
882
|
+
return;
|
|
883
|
+
case "rect":
|
|
884
|
+
ct(e, t);
|
|
885
|
+
return;
|
|
886
|
+
case "ellipse":
|
|
887
|
+
lt(e, t);
|
|
888
|
+
return;
|
|
889
|
+
case "arrow":
|
|
890
|
+
ut(e, t);
|
|
891
|
+
return;
|
|
892
|
+
case "freehand":
|
|
893
|
+
dt(e, t);
|
|
894
|
+
return;
|
|
895
|
+
case "highlight":
|
|
896
|
+
ft(e, t);
|
|
897
|
+
return;
|
|
898
|
+
default: A(t);
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
function st(e, t) {
|
|
902
|
+
e.save(), e.fillStyle = t.color, e.font = `${t.fontSize}px ${at}`, e.textAlign = t.textAlign, e.textBaseline = "top";
|
|
903
|
+
let n = t.text.length === 0 ? [""] : t.text.split("\n"), r = t.fontSize * 1.2;
|
|
904
|
+
for (let i = 0; i < n.length; i++) {
|
|
905
|
+
let a = n[i];
|
|
906
|
+
a !== void 0 && e.fillText(a, t.x, t.y + i * r);
|
|
907
|
+
}
|
|
908
|
+
e.restore();
|
|
909
|
+
}
|
|
910
|
+
function ct(e, t) {
|
|
911
|
+
e.save(), t.fillColor !== null && (e.fillStyle = t.fillColor, e.fillRect(t.x, t.y, t.width, t.height)), t.strokeWidth > 0 && (e.strokeStyle = t.strokeColor, e.lineWidth = t.strokeWidth, e.lineJoin = "miter", e.strokeRect(t.x, t.y, t.width, t.height)), e.restore();
|
|
912
|
+
}
|
|
913
|
+
function lt(e, t) {
|
|
914
|
+
e.save();
|
|
915
|
+
let n = t.width / 2, r = t.height / 2, i = t.x + n, a = t.y + r;
|
|
916
|
+
e.beginPath(), e.ellipse(i, a, Math.max(0, n), Math.max(0, r), 0, 0, Math.PI * 2), t.fillColor !== null && (e.fillStyle = t.fillColor, e.fill()), t.strokeWidth > 0 && (e.strokeStyle = t.strokeColor, e.lineWidth = t.strokeWidth, e.stroke()), e.restore();
|
|
917
|
+
}
|
|
918
|
+
function ut(e, t) {
|
|
919
|
+
let n = t.x2 - t.x1, r = t.y2 - t.y1, i = Math.sqrt(n * n + r * r);
|
|
920
|
+
if (i < .5) return;
|
|
921
|
+
e.save(), e.strokeStyle = t.color, e.fillStyle = t.color, e.lineWidth = t.strokeWidth, e.lineCap = "round", e.lineJoin = "round";
|
|
922
|
+
let a = Math.min(Math.max(t.strokeWidth * 5, 28), i * .6), o = Math.max(t.strokeWidth * 4, 18), s = n / i, c = r / i, l = t.x2 - s * a * .6, u = t.y2 - c * a * .6;
|
|
923
|
+
e.beginPath(), e.moveTo(t.x1, t.y1), e.lineTo(l, u), e.stroke();
|
|
924
|
+
let d = t.x2 - s * a, f = t.y2 - c * a, p = -c, m = s;
|
|
925
|
+
e.beginPath(), e.moveTo(t.x2, t.y2), e.lineTo(d + p * o / 2, f + m * o / 2), e.lineTo(d - p * o / 2, f - m * o / 2), e.closePath(), e.fill(), e.restore();
|
|
926
|
+
}
|
|
927
|
+
function dt(e, t) {
|
|
928
|
+
t.points.length !== 0 && (e.save(), e.strokeStyle = t.color, e.lineWidth = t.strokeWidth, e.lineCap = "round", e.lineJoin = "round", e.beginPath(), k(e, t.points), e.stroke(), e.restore());
|
|
929
|
+
}
|
|
930
|
+
function ft(e, t) {
|
|
931
|
+
t.points.length !== 0 && (e.save(), e.globalCompositeOperation = "multiply", e.strokeStyle = t.color, e.lineWidth = t.strokeWidth, e.lineCap = "round", e.lineJoin = "round", e.beginPath(), k(e, t.points), e.stroke(), e.restore());
|
|
932
|
+
}
|
|
933
|
+
//#endregion
|
|
934
|
+
//#region src/plugins/annotate/geometry.ts
|
|
935
|
+
function M(e) {
|
|
936
|
+
switch (e.kind) {
|
|
937
|
+
case "text": {
|
|
938
|
+
let { width: t, height: n } = N(e.text, e.fontSize);
|
|
939
|
+
return {
|
|
940
|
+
x: P(e.x, t, e.textAlign),
|
|
941
|
+
y: e.y,
|
|
942
|
+
width: t,
|
|
943
|
+
height: n
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
case "rect":
|
|
947
|
+
case "ellipse": return {
|
|
948
|
+
x: e.x,
|
|
949
|
+
y: e.y,
|
|
950
|
+
width: e.width,
|
|
951
|
+
height: e.height
|
|
952
|
+
};
|
|
953
|
+
case "arrow": return {
|
|
954
|
+
x: Math.min(e.x1, e.x2),
|
|
955
|
+
y: Math.min(e.y1, e.y2),
|
|
956
|
+
width: Math.abs(e.x2 - e.x1),
|
|
957
|
+
height: Math.abs(e.y2 - e.y1)
|
|
958
|
+
};
|
|
959
|
+
case "freehand":
|
|
960
|
+
case "highlight": {
|
|
961
|
+
let t = e.points[0];
|
|
962
|
+
if (!t) return {
|
|
963
|
+
x: 0,
|
|
964
|
+
y: 0,
|
|
965
|
+
width: 0,
|
|
966
|
+
height: 0
|
|
967
|
+
};
|
|
968
|
+
let n = t.x, r = t.y, i = t.x, a = t.y;
|
|
969
|
+
for (let t of e.points) t.x < n && (n = t.x), t.x > i && (i = t.x), t.y < r && (r = t.y), t.y > a && (a = t.y);
|
|
970
|
+
return {
|
|
971
|
+
x: n,
|
|
972
|
+
y: r,
|
|
973
|
+
width: i - n,
|
|
974
|
+
height: a - r
|
|
975
|
+
};
|
|
976
|
+
}
|
|
977
|
+
default: return A(e);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
var pt = [
|
|
981
|
+
"tl",
|
|
982
|
+
"tr",
|
|
983
|
+
"bl",
|
|
984
|
+
"br",
|
|
985
|
+
"t",
|
|
986
|
+
"r",
|
|
987
|
+
"b",
|
|
988
|
+
"l"
|
|
967
989
|
];
|
|
968
|
-
function
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
990
|
+
function mt(e) {
|
|
991
|
+
let t = e.x, n = e.x + e.width, r = e.y, i = e.y + e.height, a = e.x + e.width / 2, o = e.y + e.height / 2;
|
|
992
|
+
return {
|
|
993
|
+
tl: {
|
|
994
|
+
x: t,
|
|
995
|
+
y: r
|
|
996
|
+
},
|
|
997
|
+
tr: {
|
|
998
|
+
x: n,
|
|
999
|
+
y: r
|
|
1000
|
+
},
|
|
1001
|
+
bl: {
|
|
1002
|
+
x: t,
|
|
1003
|
+
y: i
|
|
1004
|
+
},
|
|
1005
|
+
br: {
|
|
1006
|
+
x: n,
|
|
1007
|
+
y: i
|
|
1008
|
+
},
|
|
1009
|
+
t: {
|
|
1010
|
+
x: a,
|
|
1011
|
+
y: r
|
|
1012
|
+
},
|
|
1013
|
+
r: {
|
|
1014
|
+
x: n,
|
|
1015
|
+
y: o
|
|
1016
|
+
},
|
|
1017
|
+
b: {
|
|
1018
|
+
x: a,
|
|
1019
|
+
y: i
|
|
1020
|
+
},
|
|
1021
|
+
l: {
|
|
1022
|
+
x: t,
|
|
1023
|
+
y: o
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
function ht(e, t, n) {
|
|
1028
|
+
let r = e.x, i = e.y, a = e.x + e.width, o = e.y + e.height;
|
|
1029
|
+
return (t === "tl" || t === "l" || t === "bl") && (r = n.x), (t === "tr" || t === "r" || t === "br") && (a = n.x), (t === "tl" || t === "t" || t === "tr") && (i = n.y), (t === "bl" || t === "b" || t === "br") && (o = n.y), {
|
|
1030
|
+
x: r,
|
|
1031
|
+
y: i,
|
|
1032
|
+
width: a - r,
|
|
1033
|
+
height: o - i
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
function N(e, t) {
|
|
1037
|
+
let n = e.length === 0 ? [""] : e.split("\n"), r = 0;
|
|
1038
|
+
for (let e of n) e.length > r && (r = e.length);
|
|
1039
|
+
return {
|
|
1040
|
+
width: Math.max(t * .6, r * t * .55),
|
|
1041
|
+
height: n.length * t * 1.2
|
|
1042
|
+
};
|
|
1043
|
+
}
|
|
1044
|
+
function P(e, t, n) {
|
|
1045
|
+
switch (n) {
|
|
1046
|
+
case "left": return e;
|
|
1047
|
+
case "center": return e - t / 2;
|
|
1048
|
+
case "right": return e - t;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
//#endregion
|
|
1052
|
+
//#region src/plugins/annotate/hit-test.ts
|
|
1053
|
+
var gt = 4;
|
|
1054
|
+
function _t(e, t) {
|
|
1055
|
+
for (let n = e.length - 1; n >= 0; n--) {
|
|
1056
|
+
let r = e[n];
|
|
1057
|
+
if (r && F(r, t)) return r;
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
function F(e, t) {
|
|
1061
|
+
switch (e.kind) {
|
|
1062
|
+
case "text": return I(t, M(e));
|
|
1063
|
+
case "rect": {
|
|
1064
|
+
let n = I(t, R(e));
|
|
1065
|
+
if (e.fillColor !== null) return n;
|
|
1066
|
+
let r = L(R(e), e.strokeWidth / 2 + 4), i = L(R(e), -(e.strokeWidth / 2 + 4));
|
|
1067
|
+
return I(t, r) && !I(t, i);
|
|
1068
|
+
}
|
|
1069
|
+
case "ellipse": {
|
|
1070
|
+
let n = R(e), r = n.width / 2, i = n.height / 2, a = n.x + r, o = n.y + i;
|
|
1071
|
+
if (r <= 0 || i <= 0) return !1;
|
|
1072
|
+
let s = (t.x - a) / r, c = (t.y - o) / i, l = s * s + c * c, u = (e.strokeWidth / 2 + 4) / Math.min(r, i);
|
|
1073
|
+
return e.fillColor === null ? l <= (1 + u) ** 2 && l >= (1 - u) ** 2 : l <= (1 + u) ** 2;
|
|
1074
|
+
}
|
|
1075
|
+
case "arrow": return z(t, {
|
|
1076
|
+
x: e.x1,
|
|
1077
|
+
y: e.y1
|
|
1078
|
+
}, {
|
|
1079
|
+
x: e.x2,
|
|
1080
|
+
y: e.y2
|
|
1081
|
+
}, e.strokeWidth / 2 + 4);
|
|
1082
|
+
case "freehand":
|
|
1083
|
+
case "highlight": {
|
|
1084
|
+
if (!I(t, L(M(e), e.strokeWidth / 2 + 4))) return !1;
|
|
1085
|
+
let n = e.strokeWidth / 2 + 4;
|
|
1086
|
+
for (let r = 1; r < e.points.length; r++) {
|
|
1087
|
+
let i = e.points[r - 1], a = e.points[r];
|
|
1088
|
+
if (i && a && z(t, i, a, n)) return !0;
|
|
1089
|
+
}
|
|
1090
|
+
if (e.points.length === 1) {
|
|
1091
|
+
let r = e.points[0];
|
|
1092
|
+
if (!r) return !1;
|
|
1093
|
+
let i = r.x - t.x, a = r.y - t.y;
|
|
1094
|
+
return i * i + a * a <= n * n;
|
|
1095
|
+
}
|
|
1096
|
+
return !1;
|
|
1097
|
+
}
|
|
1098
|
+
default: return A(e);
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
function I(e, t) {
|
|
1102
|
+
return e.x >= t.x && e.y >= t.y && e.x <= t.x + t.width && e.y <= t.y + t.height;
|
|
1103
|
+
}
|
|
1104
|
+
function L(e, t) {
|
|
1105
|
+
return {
|
|
1106
|
+
x: e.x - t,
|
|
1107
|
+
y: e.y - t,
|
|
1108
|
+
width: e.width + t * 2,
|
|
1109
|
+
height: e.height + t * 2
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1112
|
+
function R(e) {
|
|
1113
|
+
let { x: t, y: n, width: r, height: i } = e;
|
|
1114
|
+
return r < 0 && (t += r, r = -r), i < 0 && (n += i, i = -i), {
|
|
1115
|
+
x: t,
|
|
1116
|
+
y: n,
|
|
1117
|
+
width: r,
|
|
1118
|
+
height: i
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
function z(e, t, n, r) {
|
|
1122
|
+
let i = n.x - t.x, a = n.y - t.y, o = i * i + a * a;
|
|
1123
|
+
if (o === 0) {
|
|
1124
|
+
let n = e.x - t.x, i = e.y - t.y;
|
|
1125
|
+
return n * n + i * i <= r * r;
|
|
1126
|
+
}
|
|
1127
|
+
let s = ((e.x - t.x) * i + (e.y - t.y) * a) / o;
|
|
1128
|
+
s < 0 ? s = 0 : s > 1 && (s = 1);
|
|
1129
|
+
let c = t.x + s * i, l = t.y + s * a, u = e.x - c, d = e.y - l;
|
|
1130
|
+
return u * u + d * d <= r * r;
|
|
1131
|
+
}
|
|
1132
|
+
//#endregion
|
|
1133
|
+
//#region src/plugins/crop/aspect-ratio.ts
|
|
1134
|
+
function B(e, t) {
|
|
1135
|
+
if (t <= 0 || e.width <= 0 || e.height <= 0) return {
|
|
1136
|
+
x: e.x,
|
|
1137
|
+
y: e.y,
|
|
1138
|
+
width: 0,
|
|
1139
|
+
height: 0
|
|
1140
|
+
};
|
|
1141
|
+
let n = e.width / e.height, r, i;
|
|
1142
|
+
return t >= n ? (r = e.width, i = r / t) : (i = e.height, r = i * t), {
|
|
1143
|
+
x: e.x + (e.width - r) / 2,
|
|
1144
|
+
y: e.y + (e.height - i) / 2,
|
|
1145
|
+
width: r,
|
|
1146
|
+
height: i
|
|
1147
|
+
};
|
|
1148
|
+
}
|
|
1149
|
+
function V(e, t, n, r) {
|
|
1150
|
+
if (t <= 0) return e;
|
|
1151
|
+
if (e.width <= 0 || e.height <= 0) return B(r, t);
|
|
1152
|
+
let i = e.width / e.height, a, o;
|
|
1153
|
+
i > t ? (o = e.height, a = o * t) : (a = e.width, o = a / t);
|
|
1154
|
+
let s = b(H(e, a, o, n), r), c = s.height === 0 ? 0 : s.width / s.height;
|
|
1155
|
+
return Math.abs(c - t) <= vt ? s : yt(s, t, n);
|
|
1156
|
+
}
|
|
1157
|
+
var vt = 1e-6;
|
|
1158
|
+
function H(e, t, n, r) {
|
|
1159
|
+
switch (r) {
|
|
1160
|
+
case "tl": return {
|
|
1161
|
+
x: e.x,
|
|
1162
|
+
y: e.y,
|
|
1163
|
+
width: t,
|
|
1164
|
+
height: n
|
|
1165
|
+
};
|
|
1166
|
+
case "tr": return {
|
|
1167
|
+
x: e.x + e.width - t,
|
|
1168
|
+
y: e.y,
|
|
1169
|
+
width: t,
|
|
1170
|
+
height: n
|
|
1171
|
+
};
|
|
1172
|
+
case "bl": return {
|
|
1173
|
+
x: e.x,
|
|
1174
|
+
y: e.y + e.height - n,
|
|
1175
|
+
width: t,
|
|
1176
|
+
height: n
|
|
1177
|
+
};
|
|
1178
|
+
case "br": return {
|
|
1179
|
+
x: e.x + e.width - t,
|
|
1180
|
+
y: e.y + e.height - n,
|
|
1181
|
+
width: t,
|
|
1182
|
+
height: n
|
|
1183
|
+
};
|
|
1184
|
+
case "center": return {
|
|
1185
|
+
x: e.x + (e.width - t) / 2,
|
|
1186
|
+
y: e.y + (e.height - n) / 2,
|
|
1187
|
+
width: t,
|
|
1188
|
+
height: n
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
function yt(e, t, n) {
|
|
1193
|
+
let r = B(e, t);
|
|
1194
|
+
return H(e, r.width, r.height, n);
|
|
1195
|
+
}
|
|
1196
|
+
//#endregion
|
|
1197
|
+
//#region src/plugins/crop/bake.ts
|
|
1198
|
+
function bt(t, n) {
|
|
1199
|
+
let r = x(n.rect), i = U(r.x, 0, t.width), a = U(r.y, 0, t.height), o = U(r.width, 1, t.width - i), s = U(r.height, 1, t.height - a), c = e(o, s);
|
|
1200
|
+
if (c.kind === "offscreen") {
|
|
1201
|
+
let e = c.canvas.getContext("2d");
|
|
1202
|
+
if (!e) throw Error("2D canvas context is not available");
|
|
1203
|
+
return e.drawImage(t.bitmap, i, a, o, s, 0, 0, o, s), {
|
|
1204
|
+
bitmap: c.canvas,
|
|
1205
|
+
width: o,
|
|
1206
|
+
height: s,
|
|
1207
|
+
mimeType: t.mimeType
|
|
1208
|
+
};
|
|
1209
|
+
}
|
|
1210
|
+
let l = c.canvas.getContext("2d");
|
|
1211
|
+
if (!l) throw Error("2D canvas context is not available");
|
|
1212
|
+
return l.drawImage(t.bitmap, i, a, o, s, 0, 0, o, s), {
|
|
1213
|
+
bitmap: c.canvas,
|
|
1214
|
+
width: o,
|
|
1215
|
+
height: s,
|
|
1216
|
+
mimeType: t.mimeType
|
|
1217
|
+
};
|
|
1218
|
+
}
|
|
1219
|
+
function U(e, t, n) {
|
|
1220
|
+
return Math.max(t, Math.min(n, e));
|
|
1221
|
+
}
|
|
1222
|
+
//#endregion
|
|
1223
|
+
//#region src/plugins/crop/preset-filter.ts
|
|
1224
|
+
function W(e, t) {
|
|
1225
|
+
let [n] = e;
|
|
1226
|
+
return n === void 0 || t === void 0 ? !0 : t === "landscape" ? n >= 1 : t === "portrait" ? n < 1 : !0;
|
|
1227
|
+
}
|
|
1228
|
+
function xt(e, t) {
|
|
1229
|
+
return e.filter((e) => W(e, t));
|
|
1230
|
+
}
|
|
1231
|
+
//#endregion
|
|
1232
|
+
//#region src/plugins/crop/resize.ts
|
|
1233
|
+
function St(e, t, n, r) {
|
|
1234
|
+
let i = r.minSize ?? 1, a = e.x, o = e.y, s = e.x + e.width, c = e.y + e.height, l = a, u = o, d = s, f = c;
|
|
1235
|
+
(t === "tl" || t === "l" || t === "bl") && (l = n.x), (t === "tr" || t === "r" || t === "br") && (d = n.x), (t === "tl" || t === "t" || t === "tr") && (u = n.y), (t === "bl" || t === "b" || t === "br") && (f = n.y), (t === "l" || t === "r") && (u = o, f = c), (t === "t" || t === "b") && (l = a, d = s);
|
|
1236
|
+
let p = Math.min(l, d), m = Math.min(u, f), h = Math.abs(d - l), g = Math.abs(f - u);
|
|
1237
|
+
h < i && (h = i, t === "tl" || t === "l" || t === "bl" ? p = s - i : (t === "tr" || t === "r" || t === "br") && (p = a)), g < i && (g = i, t === "tl" || t === "t" || t === "tr" ? m = c - i : (t === "bl" || t === "b" || t === "br") && (m = o));
|
|
1238
|
+
let _ = {
|
|
1239
|
+
x: p,
|
|
1240
|
+
y: m,
|
|
1241
|
+
width: h,
|
|
1242
|
+
height: g
|
|
1243
|
+
};
|
|
1244
|
+
return _ = b(_, r.bounds), r.aspectRatio !== void 0 && r.aspectRatio > 0 && (_ = V(_, r.aspectRatio, Ct(t), r.bounds)), _;
|
|
1245
|
+
}
|
|
1246
|
+
function Ct(e) {
|
|
1247
|
+
switch (e) {
|
|
1248
|
+
case "tl": return "br";
|
|
1249
|
+
case "tr": return "bl";
|
|
1250
|
+
case "bl": return "tr";
|
|
1251
|
+
case "br": return "tl";
|
|
1252
|
+
case "t": return "bl";
|
|
1253
|
+
case "b": return "tl";
|
|
1254
|
+
case "l": return "tr";
|
|
1255
|
+
case "r": return "tl";
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
//#endregion
|
|
1259
|
+
//#region src/plugins/crop/state.ts
|
|
1260
|
+
function wt(e) {
|
|
1261
|
+
return {
|
|
1262
|
+
rect: {
|
|
1263
|
+
x: 0,
|
|
1264
|
+
y: 0,
|
|
1265
|
+
width: e.imageSize.width,
|
|
1266
|
+
height: e.imageSize.height
|
|
1267
|
+
},
|
|
1268
|
+
aspectRatio: void 0,
|
|
1269
|
+
activePresetIndex: Et(e.presets),
|
|
1270
|
+
presets: e.presets,
|
|
1271
|
+
imageSize: e.imageSize
|
|
1272
|
+
};
|
|
1273
|
+
}
|
|
1274
|
+
function Tt(e, t) {
|
|
1275
|
+
let n = e.presets[t];
|
|
1276
|
+
if (!n) return e;
|
|
1277
|
+
let [r] = n;
|
|
1278
|
+
if (r === void 0) return {
|
|
1279
|
+
...e,
|
|
1280
|
+
aspectRatio: void 0,
|
|
1281
|
+
activePresetIndex: t
|
|
1282
|
+
};
|
|
1283
|
+
let i = B({
|
|
1284
|
+
x: 0,
|
|
1285
|
+
y: 0,
|
|
1286
|
+
width: e.imageSize.width,
|
|
1287
|
+
height: e.imageSize.height
|
|
1288
|
+
}, r);
|
|
1289
|
+
return {
|
|
1290
|
+
...e,
|
|
1291
|
+
rect: i,
|
|
1292
|
+
aspectRatio: r,
|
|
1293
|
+
activePresetIndex: t
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1296
|
+
function Et(e) {
|
|
1297
|
+
return e.findIndex(([e]) => e === void 0);
|
|
1298
|
+
}
|
|
1299
|
+
//#endregion
|
|
1300
|
+
//#region src/plugins/finetune/state.ts
|
|
1301
|
+
var Dt = -100, Ot = 100, kt = 1, G = {
|
|
1302
|
+
brightness: 0,
|
|
1303
|
+
contrast: 0,
|
|
1304
|
+
saturation: 0,
|
|
1305
|
+
exposure: 0,
|
|
1306
|
+
clarity: 0,
|
|
1307
|
+
gamma: 0
|
|
1308
|
+
}, At = [
|
|
1309
|
+
{
|
|
1310
|
+
key: "brightness",
|
|
1311
|
+
label: "Brightness"
|
|
1312
|
+
},
|
|
1313
|
+
{
|
|
1314
|
+
key: "contrast",
|
|
1315
|
+
label: "Contrast"
|
|
1316
|
+
},
|
|
1317
|
+
{
|
|
1318
|
+
key: "saturation",
|
|
1319
|
+
label: "Saturation"
|
|
1320
|
+
},
|
|
1321
|
+
{
|
|
1322
|
+
key: "exposure",
|
|
1323
|
+
label: "Exposure"
|
|
1324
|
+
},
|
|
1325
|
+
{
|
|
1326
|
+
key: "clarity",
|
|
1327
|
+
label: "Clarity"
|
|
1328
|
+
},
|
|
1329
|
+
{
|
|
1330
|
+
key: "gamma",
|
|
1331
|
+
label: "Gamma"
|
|
1332
|
+
}
|
|
1130
1333
|
];
|
|
1131
|
-
function
|
|
1132
|
-
|
|
1133
|
-
}
|
|
1134
|
-
function
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1334
|
+
function jt() {
|
|
1335
|
+
return G;
|
|
1336
|
+
}
|
|
1337
|
+
function Mt(e) {
|
|
1338
|
+
return e.brightness === 0 && e.contrast === 0 && e.saturation === 0 && e.exposure === 0 && e.clarity === 0 && e.gamma === 0;
|
|
1339
|
+
}
|
|
1340
|
+
function Nt(e, t, n) {
|
|
1341
|
+
let r = It(n);
|
|
1342
|
+
return e[t] === r ? e : {
|
|
1343
|
+
...e,
|
|
1344
|
+
[t]: r
|
|
1345
|
+
};
|
|
1346
|
+
}
|
|
1347
|
+
function Pt(e, t) {
|
|
1348
|
+
return e[t] === 0 ? e : {
|
|
1349
|
+
...e,
|
|
1350
|
+
[t]: 0
|
|
1351
|
+
};
|
|
1352
|
+
}
|
|
1353
|
+
function Ft() {
|
|
1354
|
+
return G;
|
|
1355
|
+
}
|
|
1356
|
+
function It(e) {
|
|
1357
|
+
return Number.isNaN(e) ? 0 : e <= -100 ? Dt : e >= 100 ? 100 : Math.round(e / 1) * 1;
|
|
1358
|
+
}
|
|
1359
|
+
//#endregion
|
|
1360
|
+
//#region src/plugins/filter/presets.ts
|
|
1361
|
+
var Lt = [
|
|
1362
|
+
{
|
|
1363
|
+
id: "none",
|
|
1364
|
+
label: "None",
|
|
1365
|
+
state: G
|
|
1366
|
+
},
|
|
1367
|
+
{
|
|
1368
|
+
id: "vivid",
|
|
1369
|
+
label: "Vivid",
|
|
1370
|
+
state: {
|
|
1371
|
+
brightness: 0,
|
|
1372
|
+
contrast: 10,
|
|
1373
|
+
saturation: 40,
|
|
1374
|
+
exposure: 0,
|
|
1375
|
+
clarity: 5,
|
|
1376
|
+
gamma: 0
|
|
1377
|
+
}
|
|
1378
|
+
},
|
|
1379
|
+
{
|
|
1380
|
+
id: "mono",
|
|
1381
|
+
label: "Mono",
|
|
1382
|
+
state: {
|
|
1383
|
+
brightness: 0,
|
|
1384
|
+
contrast: 15,
|
|
1385
|
+
saturation: -100,
|
|
1386
|
+
exposure: 0,
|
|
1387
|
+
clarity: 0,
|
|
1388
|
+
gamma: 0
|
|
1389
|
+
}
|
|
1390
|
+
},
|
|
1391
|
+
{
|
|
1392
|
+
id: "soft",
|
|
1393
|
+
label: "Soft",
|
|
1394
|
+
state: {
|
|
1395
|
+
brightness: 5,
|
|
1396
|
+
contrast: -10,
|
|
1397
|
+
saturation: 0,
|
|
1398
|
+
exposure: 0,
|
|
1399
|
+
clarity: -25,
|
|
1400
|
+
gamma: 0
|
|
1401
|
+
}
|
|
1402
|
+
},
|
|
1403
|
+
{
|
|
1404
|
+
id: "punch",
|
|
1405
|
+
label: "Punch",
|
|
1406
|
+
state: {
|
|
1407
|
+
brightness: 0,
|
|
1408
|
+
contrast: 30,
|
|
1409
|
+
saturation: 5,
|
|
1410
|
+
exposure: 0,
|
|
1411
|
+
clarity: 25,
|
|
1412
|
+
gamma: 0
|
|
1413
|
+
}
|
|
1414
|
+
},
|
|
1415
|
+
{
|
|
1416
|
+
id: "mute",
|
|
1417
|
+
label: "Mute",
|
|
1418
|
+
state: {
|
|
1419
|
+
brightness: 0,
|
|
1420
|
+
contrast: 5,
|
|
1421
|
+
saturation: -50,
|
|
1422
|
+
exposure: 0,
|
|
1423
|
+
clarity: -5,
|
|
1424
|
+
gamma: 0
|
|
1425
|
+
}
|
|
1426
|
+
},
|
|
1427
|
+
{
|
|
1428
|
+
id: "bright",
|
|
1429
|
+
label: "Bright",
|
|
1430
|
+
state: {
|
|
1431
|
+
brightness: 5,
|
|
1432
|
+
contrast: 5,
|
|
1433
|
+
saturation: 0,
|
|
1434
|
+
exposure: 15,
|
|
1435
|
+
clarity: 0,
|
|
1436
|
+
gamma: 0
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1230
1439
|
];
|
|
1231
|
-
function
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
}
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
case "text":
|
|
1396
|
-
mn(t, n);
|
|
1397
|
-
return;
|
|
1398
|
-
case "rect":
|
|
1399
|
-
yn(t, n);
|
|
1400
|
-
return;
|
|
1401
|
-
case "ellipse":
|
|
1402
|
-
wn(t, n);
|
|
1403
|
-
return;
|
|
1404
|
-
case "arrow":
|
|
1405
|
-
xn(t, n);
|
|
1406
|
-
return;
|
|
1407
|
-
case "freehand":
|
|
1408
|
-
pn(t, n);
|
|
1409
|
-
return;
|
|
1410
|
-
case "highlight":
|
|
1411
|
-
Mn(t, n);
|
|
1412
|
-
return;
|
|
1413
|
-
default:
|
|
1414
|
-
w(n);
|
|
1415
|
-
}
|
|
1416
|
-
}
|
|
1417
|
-
function mn(t, n) {
|
|
1418
|
-
t.save(), t.fillStyle = n.color, t.font = `${n.fontSize}px ${dn}`, t.textAlign = n.textAlign, t.textBaseline = "top";
|
|
1419
|
-
const e = n.text.length === 0 ? [""] : n.text.split(`
|
|
1420
|
-
`), i = n.fontSize * 1.2;
|
|
1421
|
-
for (let r = 0; r < e.length; r++) {
|
|
1422
|
-
const o = e[r];
|
|
1423
|
-
o !== void 0 && t.fillText(o, n.x, n.y + r * i);
|
|
1424
|
-
}
|
|
1425
|
-
t.restore();
|
|
1426
|
-
}
|
|
1427
|
-
function yn(t, n) {
|
|
1428
|
-
t.save(), n.fillColor !== null && (t.fillStyle = n.fillColor, t.fillRect(n.x, n.y, n.width, n.height)), n.strokeWidth > 0 && (t.strokeStyle = n.strokeColor, t.lineWidth = n.strokeWidth, t.lineJoin = "miter", t.strokeRect(n.x, n.y, n.width, n.height)), t.restore();
|
|
1429
|
-
}
|
|
1430
|
-
function wn(t, n) {
|
|
1431
|
-
t.save();
|
|
1432
|
-
const e = n.width / 2, i = n.height / 2, r = n.x + e, o = n.y + i;
|
|
1433
|
-
t.beginPath(), t.ellipse(r, o, Math.max(0, e), Math.max(0, i), 0, 0, Math.PI * 2), n.fillColor !== null && (t.fillStyle = n.fillColor, t.fill()), n.strokeWidth > 0 && (t.strokeStyle = n.strokeColor, t.lineWidth = n.strokeWidth, t.stroke()), t.restore();
|
|
1434
|
-
}
|
|
1435
|
-
function xn(t, n) {
|
|
1436
|
-
const e = n.x2 - n.x1, i = n.y2 - n.y1, r = Math.sqrt(e * e + i * i);
|
|
1437
|
-
if (r < 0.5) return;
|
|
1438
|
-
t.save(), t.strokeStyle = n.color, t.fillStyle = n.color, t.lineWidth = n.strokeWidth, t.lineCap = "round", t.lineJoin = "round";
|
|
1439
|
-
const o = Math.min(Math.max(n.strokeWidth * 5, 28), r * 0.6), a = Math.max(n.strokeWidth * 4, 18), c = e / r, l = i / r, s = n.x2 - c * o * 0.6, u = n.y2 - l * o * 0.6;
|
|
1440
|
-
t.beginPath(), t.moveTo(n.x1, n.y1), t.lineTo(s, u), t.stroke();
|
|
1441
|
-
const h = n.x2 - c * o, f = n.y2 - l * o, d = -l, m = c;
|
|
1442
|
-
t.beginPath(), t.moveTo(n.x2, n.y2), t.lineTo(h + d * a / 2, f + m * a / 2), t.lineTo(h - d * a / 2, f - m * a / 2), t.closePath(), t.fill(), t.restore();
|
|
1443
|
-
}
|
|
1444
|
-
function pn(t, n) {
|
|
1445
|
-
n.points.length !== 0 && (t.save(), t.strokeStyle = n.color, t.lineWidth = n.strokeWidth, t.lineCap = "round", t.lineJoin = "round", t.beginPath(), dt(t, n.points), t.stroke(), t.restore());
|
|
1446
|
-
}
|
|
1447
|
-
function Mn(t, n) {
|
|
1448
|
-
n.points.length !== 0 && (t.save(), t.globalCompositeOperation = "multiply", t.strokeStyle = n.color, t.lineWidth = n.strokeWidth, t.lineCap = "round", t.lineJoin = "round", t.beginPath(), dt(t, n.points), t.stroke(), t.restore());
|
|
1449
|
-
}
|
|
1450
|
-
const oi = ["pixelate", "blur", "solid"], Sn = "#000000", bn = "pixelate";
|
|
1451
|
-
function ai(t) {
|
|
1452
|
-
return {
|
|
1453
|
-
regions: [],
|
|
1454
|
-
nextRegionNumber: 1,
|
|
1455
|
-
selectedId: null,
|
|
1456
|
-
currentMode: bn,
|
|
1457
|
-
currentColor: Sn,
|
|
1458
|
-
imageSize: t.imageSize
|
|
1459
|
-
};
|
|
1460
|
-
}
|
|
1461
|
-
function ci(t) {
|
|
1462
|
-
return {
|
|
1463
|
-
id: `r_${t.nextRegionNumber.toString(36)}`,
|
|
1464
|
-
nextRegionNumber: t.nextRegionNumber + 1
|
|
1465
|
-
};
|
|
1466
|
-
}
|
|
1467
|
-
function si(t, n) {
|
|
1468
|
-
return {
|
|
1469
|
-
...t,
|
|
1470
|
-
regions: [...t.regions, n],
|
|
1471
|
-
selectedId: n.id
|
|
1472
|
-
};
|
|
1473
|
-
}
|
|
1474
|
-
function gt(t, n) {
|
|
1475
|
-
let e = !1;
|
|
1476
|
-
const i = t.regions.map((r) => r.id !== n.id ? r : (e = !0, n));
|
|
1477
|
-
return e ? { ...t, regions: i } : t;
|
|
1478
|
-
}
|
|
1479
|
-
function li(t, n) {
|
|
1480
|
-
const e = t.regions.filter((i) => i.id !== n);
|
|
1481
|
-
return e.length === t.regions.length ? t : {
|
|
1482
|
-
...t,
|
|
1483
|
-
regions: e,
|
|
1484
|
-
selectedId: t.selectedId === n ? null : t.selectedId
|
|
1485
|
-
};
|
|
1486
|
-
}
|
|
1487
|
-
function ui(t, n, e) {
|
|
1488
|
-
if (t.regions.length === 0) return t;
|
|
1489
|
-
const i = t.regions.map((r) => n === "horizontal" ? { ...r, x: e.width - r.x - r.width } : { ...r, y: e.height - r.y - r.height });
|
|
1490
|
-
return { ...t, regions: i, imageSize: e };
|
|
1491
|
-
}
|
|
1492
|
-
function hi(t, n, e, i) {
|
|
1493
|
-
if (t.regions.length === 0) return { ...t, imageSize: i };
|
|
1494
|
-
if (n === 0 && e === 0 && t.imageSize === i) return t;
|
|
1495
|
-
const r = t.regions.map((o) => ({
|
|
1496
|
-
...o,
|
|
1497
|
-
x: o.x + n,
|
|
1498
|
-
y: o.y + e
|
|
1499
|
-
}));
|
|
1500
|
-
return { ...t, regions: r, imageSize: i };
|
|
1501
|
-
}
|
|
1502
|
-
function fi(t, n, e) {
|
|
1503
|
-
if (n === 0) return { ...t, imageSize: e };
|
|
1504
|
-
if (t.regions.length === 0) return { ...t, imageSize: e };
|
|
1505
|
-
const i = t.imageSize.width, r = t.imageSize.height, o = t.regions.map((a) => {
|
|
1506
|
-
const { x: c, y: l, width: s, height: u } = a;
|
|
1507
|
-
return n === 1 ? { ...a, x: r - l - u, y: c, width: u, height: s } : n === 2 ? {
|
|
1508
|
-
...a,
|
|
1509
|
-
x: i - c - s,
|
|
1510
|
-
y: r - l - u
|
|
1511
|
-
} : { ...a, x: l, y: i - c - s, width: u, height: s };
|
|
1512
|
-
});
|
|
1513
|
-
return { ...t, regions: o, imageSize: e };
|
|
1514
|
-
}
|
|
1515
|
-
function di(t, n) {
|
|
1516
|
-
return t.selectedId === n ? t : { ...t, selectedId: n };
|
|
1517
|
-
}
|
|
1518
|
-
function gi(t, n) {
|
|
1519
|
-
return t.currentMode === n ? t : { ...t, currentMode: n };
|
|
1520
|
-
}
|
|
1521
|
-
function mi(t, n) {
|
|
1522
|
-
return t.currentColor === n ? t : { ...t, currentColor: n };
|
|
1523
|
-
}
|
|
1524
|
-
function yi(t, n, e) {
|
|
1525
|
-
const i = t.regions.find((r) => r.id === n);
|
|
1526
|
-
return !i || i.mode === e ? t : gt(t, { ...i, mode: e });
|
|
1527
|
-
}
|
|
1528
|
-
function wi(t, n, e) {
|
|
1529
|
-
const i = t.regions.find((r) => r.id === n);
|
|
1530
|
-
return !i || i.color === e ? t : gt(t, { ...i, color: e });
|
|
1531
|
-
}
|
|
1532
|
-
function xi(t, n) {
|
|
1533
|
-
if (n !== null)
|
|
1534
|
-
return t.regions.find((e) => e.id === n);
|
|
1535
|
-
}
|
|
1536
|
-
function pi(t) {
|
|
1537
|
-
return t.selectedId === null ? null : t.regions.find((n) => n.id === t.selectedId) ?? null;
|
|
1538
|
-
}
|
|
1539
|
-
function Mi(t) {
|
|
1540
|
-
let { x: n, y: e, width: i, height: r } = t;
|
|
1541
|
-
return i < 0 && (n += i, i = -i), r < 0 && (e += r, r = -r), { x: n, y: e, width: i, height: r };
|
|
1542
|
-
}
|
|
1543
|
-
function Si(t) {
|
|
1544
|
-
const { imageSize: n, mode: e, color: i, id: r } = t, o = Math.min(n.width, n.height), a = Math.max(80, Math.round(o * 0.25)), c = n.width / 2, l = n.height / 2, s = Math.round(c - a / 2), u = Math.round(l - a / 2);
|
|
1545
|
-
return {
|
|
1546
|
-
id: r,
|
|
1547
|
-
x: s,
|
|
1548
|
-
y: u,
|
|
1549
|
-
width: a,
|
|
1550
|
-
height: a,
|
|
1551
|
-
mode: e,
|
|
1552
|
-
color: i
|
|
1553
|
-
};
|
|
1554
|
-
}
|
|
1555
|
-
function bi(t, n) {
|
|
1556
|
-
if (t.imageSize.width === n.width && t.imageSize.height === n.height)
|
|
1557
|
-
return t;
|
|
1558
|
-
const e = [];
|
|
1559
|
-
for (const r of t.regions)
|
|
1560
|
-
r.x + r.width <= 0 || r.y + r.height <= 0 || r.x >= n.width || r.y >= n.height || e.push(En(r, n));
|
|
1561
|
-
const i = t.selectedId !== null && !e.some((r) => r.id === t.selectedId);
|
|
1562
|
-
return {
|
|
1563
|
-
...t,
|
|
1564
|
-
regions: e,
|
|
1565
|
-
imageSize: { width: n.width, height: n.height },
|
|
1566
|
-
selectedId: i ? null : t.selectedId
|
|
1567
|
-
};
|
|
1568
|
-
}
|
|
1569
|
-
function En(t, n) {
|
|
1570
|
-
const e = Math.max(0, t.x), i = Math.max(0, t.y), r = Math.min(n.width, t.x + t.width), o = Math.min(n.height, t.y + t.height);
|
|
1571
|
-
return {
|
|
1572
|
-
...t,
|
|
1573
|
-
x: e,
|
|
1574
|
-
y: i,
|
|
1575
|
-
width: Math.max(0, r - e),
|
|
1576
|
-
height: Math.max(0, o - i)
|
|
1577
|
-
};
|
|
1578
|
-
}
|
|
1579
|
-
function Ei(t) {
|
|
1580
|
-
return { x: t.x, y: t.y, width: t.width, height: t.height };
|
|
1581
|
-
}
|
|
1582
|
-
async function Ri(t, n) {
|
|
1583
|
-
if (t.regions.length === 0) return n;
|
|
1584
|
-
const e = g(n.width, n.height), i = y(e);
|
|
1585
|
-
i.drawImage(n.bitmap, 0, 0, n.width, n.height);
|
|
1586
|
-
for (const r of t.regions)
|
|
1587
|
-
Rn(i, e.canvas, r, n);
|
|
1588
|
-
return {
|
|
1589
|
-
bitmap: e.canvas,
|
|
1590
|
-
width: n.width,
|
|
1591
|
-
height: n.height,
|
|
1592
|
-
mimeType: n.mimeType
|
|
1593
|
-
};
|
|
1594
|
-
}
|
|
1595
|
-
function Rn(t, n, e, i) {
|
|
1596
|
-
const r = Math.round(e.width), o = Math.round(e.height);
|
|
1597
|
-
if (r < 1 || o < 1) return;
|
|
1598
|
-
const a = Math.round(e.x), c = Math.round(e.y);
|
|
1599
|
-
switch (e.mode) {
|
|
1600
|
-
case "solid":
|
|
1601
|
-
In(t, e, a, c, r, o);
|
|
1602
|
-
return;
|
|
1603
|
-
case "pixelate":
|
|
1604
|
-
Tn(t, n, i, a, c, r, o);
|
|
1605
|
-
return;
|
|
1606
|
-
case "blur":
|
|
1607
|
-
kn(t, n, i, a, c, r, o);
|
|
1608
|
-
return;
|
|
1609
|
-
}
|
|
1610
|
-
}
|
|
1611
|
-
function In(t, n, e, i, r, o) {
|
|
1612
|
-
t.save(), t.fillStyle = n.color, t.fillRect(e, i, r, o), t.restore();
|
|
1613
|
-
}
|
|
1614
|
-
function Tn(t, n, e, i, r, o, a) {
|
|
1615
|
-
const c = Math.max(o, a), l = Math.max(4, Math.round(8 * Math.min(1, c / 240))), s = Math.max(1, Math.round(o / c * l)), u = Math.max(1, Math.round(a / c * l));
|
|
1616
|
-
t.save();
|
|
1617
|
-
const h = F(s, u);
|
|
1618
|
-
if (!h) {
|
|
1619
|
-
t.restore();
|
|
1620
|
-
return;
|
|
1621
|
-
}
|
|
1622
|
-
h.ctx.imageSmoothingEnabled = !0, h.ctx.imageSmoothingQuality = "low", h.ctx.drawImage(n, i, r, o, a, 0, 0, s, u), t.imageSmoothingEnabled = !1, t.drawImage(h.canvas, 0, 0, s, u, i, r, o, a), t.restore();
|
|
1623
|
-
}
|
|
1624
|
-
function kn(t, n, e, i, r, o, a) {
|
|
1625
|
-
const l = Math.max(1, Math.round(o * 0.125)), s = Math.max(1, Math.round(a * 0.125)), u = F(l, s);
|
|
1626
|
-
if (!u) return;
|
|
1627
|
-
u.ctx.imageSmoothingEnabled = !0, u.ctx.imageSmoothingQuality = "high", u.ctx.drawImage(n, i, r, o, a, 0, 0, l, s);
|
|
1628
|
-
const h = Math.max(1, Math.round(l * 0.5)), f = Math.max(1, Math.round(s * 0.5)), d = F(h, f);
|
|
1629
|
-
if (!d) {
|
|
1630
|
-
t.save(), t.imageSmoothingEnabled = !0, t.imageSmoothingQuality = "high", t.drawImage(u.canvas, 0, 0, l, s, i, r, o, a), t.restore();
|
|
1631
|
-
return;
|
|
1632
|
-
}
|
|
1633
|
-
d.ctx.imageSmoothingEnabled = !0, d.ctx.imageSmoothingQuality = "high", d.ctx.drawImage(u.canvas, 0, 0, l, s, 0, 0, h, f), t.save(), t.imageSmoothingEnabled = !0, t.imageSmoothingQuality = "high", t.drawImage(d.canvas, 0, 0, h, f, i, r, o, a), t.restore();
|
|
1634
|
-
}
|
|
1635
|
-
function F(t, n) {
|
|
1636
|
-
if (typeof OffscreenCanvas < "u")
|
|
1637
|
-
try {
|
|
1638
|
-
const r = new OffscreenCanvas(t, n), o = r.getContext("2d");
|
|
1639
|
-
if (o) return { canvas: r, ctx: o };
|
|
1640
|
-
} catch {
|
|
1641
|
-
}
|
|
1642
|
-
if (typeof document > "u") return null;
|
|
1643
|
-
const e = document.createElement("canvas");
|
|
1644
|
-
e.width = t, e.height = n;
|
|
1645
|
-
const i = e.getContext("2d");
|
|
1646
|
-
return i ? { canvas: e, ctx: i } : null;
|
|
1647
|
-
}
|
|
1648
|
-
const Ii = [
|
|
1649
|
-
"none",
|
|
1650
|
-
"solidSharp",
|
|
1651
|
-
"solidRound",
|
|
1652
|
-
"lineSingle",
|
|
1653
|
-
"hook",
|
|
1654
|
-
"polaroid"
|
|
1655
|
-
], Cn = [
|
|
1656
|
-
{
|
|
1657
|
-
id: "none",
|
|
1658
|
-
label: "None",
|
|
1659
|
-
acceptsColor: !1,
|
|
1660
|
-
defaultColor: "#000000"
|
|
1661
|
-
},
|
|
1662
|
-
{
|
|
1663
|
-
id: "solidSharp",
|
|
1664
|
-
label: "Mat Sharp",
|
|
1665
|
-
acceptsColor: !0,
|
|
1666
|
-
defaultColor: "#000000"
|
|
1667
|
-
},
|
|
1668
|
-
{
|
|
1669
|
-
id: "solidRound",
|
|
1670
|
-
label: "Mat Round",
|
|
1671
|
-
acceptsColor: !0,
|
|
1672
|
-
defaultColor: "#000000"
|
|
1673
|
-
},
|
|
1674
|
-
{
|
|
1675
|
-
id: "lineSingle",
|
|
1676
|
-
label: "Line Single",
|
|
1677
|
-
acceptsColor: !0,
|
|
1678
|
-
defaultColor: "#000000"
|
|
1679
|
-
},
|
|
1680
|
-
{
|
|
1681
|
-
id: "hook",
|
|
1682
|
-
label: "Corner Hooks",
|
|
1683
|
-
acceptsColor: !0,
|
|
1684
|
-
defaultColor: "#000000"
|
|
1685
|
-
},
|
|
1686
|
-
{
|
|
1687
|
-
id: "polaroid",
|
|
1688
|
-
label: "Polaroid",
|
|
1689
|
-
acceptsColor: !0,
|
|
1690
|
-
defaultColor: "#ffffff"
|
|
1691
|
-
}
|
|
1692
|
-
], vn = {
|
|
1693
|
-
presetId: "none",
|
|
1694
|
-
color: "#000000"
|
|
1695
|
-
};
|
|
1696
|
-
function Ti() {
|
|
1697
|
-
return vn;
|
|
1698
|
-
}
|
|
1699
|
-
function An(t) {
|
|
1700
|
-
return t.presetId === "none";
|
|
1701
|
-
}
|
|
1702
|
-
function ki(t, n) {
|
|
1703
|
-
if (t.presetId === n) return t;
|
|
1704
|
-
const e = rt(t.presetId), i = rt(n);
|
|
1705
|
-
if (!i) return { ...t, presetId: n };
|
|
1706
|
-
const o = e !== void 0 && t.color === e.defaultColor ? i.defaultColor : t.color;
|
|
1707
|
-
return { presetId: n, color: o };
|
|
1708
|
-
}
|
|
1709
|
-
function Ci(t, n) {
|
|
1710
|
-
return t.color === n ? t : { ...t, color: n };
|
|
1711
|
-
}
|
|
1712
|
-
function rt(t) {
|
|
1713
|
-
return Cn.find((n) => n.id === t);
|
|
1714
|
-
}
|
|
1715
|
-
async function vi(t, n) {
|
|
1716
|
-
return An(t) ? n : t.presetId === "polaroid" ? zn(t.color, n) : t.presetId === "none" ? n : Nn(t.presetId, t.color, n);
|
|
1717
|
-
}
|
|
1718
|
-
function Nn(t, n, e) {
|
|
1719
|
-
const i = g(e.width, e.height), r = y(i);
|
|
1720
|
-
return r.drawImage(e.bitmap, 0, 0, e.width, e.height), Fn(r, t, n, e.width, e.height), {
|
|
1721
|
-
bitmap: i.canvas,
|
|
1722
|
-
width: e.width,
|
|
1723
|
-
height: e.height,
|
|
1724
|
-
mimeType: e.mimeType
|
|
1725
|
-
};
|
|
1726
|
-
}
|
|
1727
|
-
function Fn(t, n, e, i, r) {
|
|
1728
|
-
switch (n) {
|
|
1729
|
-
case "solidSharp":
|
|
1730
|
-
mt(t, e, i, r);
|
|
1731
|
-
return;
|
|
1732
|
-
case "solidRound":
|
|
1733
|
-
Pn(t, e, i, r);
|
|
1734
|
-
return;
|
|
1735
|
-
case "lineSingle":
|
|
1736
|
-
On(t, e, i, r);
|
|
1737
|
-
return;
|
|
1738
|
-
case "hook":
|
|
1739
|
-
_n(t, e, i, r);
|
|
1740
|
-
return;
|
|
1741
|
-
}
|
|
1742
|
-
}
|
|
1743
|
-
function mt(t, n, e, i) {
|
|
1744
|
-
const r = yt(e, i);
|
|
1745
|
-
t.save(), t.fillStyle = n, t.fillRect(0, 0, e, r), t.fillRect(0, i - r, e, r), t.fillRect(0, r, r, i - 2 * r), t.fillRect(e - r, r, r, i - 2 * r), t.restore();
|
|
1746
|
-
}
|
|
1747
|
-
function Pn(t, n, e, i) {
|
|
1748
|
-
const o = yt(e, i);
|
|
1749
|
-
mt(t, n, e, i), t.save(), t.globalCompositeOperation = "destination-out", t.fillStyle = "#000", T(t, 0, 0, o, "tl"), T(t, e, 0, o, "tr"), T(t, 0, i, o, "bl"), T(t, e, i, o, "br"), t.restore();
|
|
1750
|
-
}
|
|
1751
|
-
function T(t, n, e, i, r) {
|
|
1752
|
-
switch (t.beginPath(), t.moveTo(n, e), r) {
|
|
1753
|
-
case "tl":
|
|
1754
|
-
t.lineTo(n + i, e), t.arc(n + i, e + i, i, -Math.PI / 2, Math.PI, !0), t.lineTo(n, e);
|
|
1755
|
-
break;
|
|
1756
|
-
case "tr":
|
|
1757
|
-
t.lineTo(n, e + i), t.arc(n - i, e + i, i, 0, -Math.PI / 2, !0), t.lineTo(n, e);
|
|
1758
|
-
break;
|
|
1759
|
-
case "bl":
|
|
1760
|
-
t.lineTo(n + i, e), t.arc(n + i, e - i, i, Math.PI / 2, Math.PI, !1), t.lineTo(n, e);
|
|
1761
|
-
break;
|
|
1762
|
-
case "br":
|
|
1763
|
-
t.lineTo(n - i, e), t.arc(n - i, e - i, i, Math.PI / 2, 0, !0), t.lineTo(n, e);
|
|
1764
|
-
break;
|
|
1765
|
-
}
|
|
1766
|
-
t.closePath(), t.fill();
|
|
1767
|
-
}
|
|
1768
|
-
function On(t, n, e, i) {
|
|
1769
|
-
const r = Math.round(Math.min(e, i) * 0.05), o = Math.max(2, Math.round(Math.min(e, i) * 0.01));
|
|
1770
|
-
t.save(), t.strokeStyle = n, t.lineWidth = o;
|
|
1771
|
-
const a = o / 2;
|
|
1772
|
-
t.strokeRect(
|
|
1773
|
-
r + a,
|
|
1774
|
-
r + a,
|
|
1775
|
-
e - 2 * r - o,
|
|
1776
|
-
i - 2 * r - o
|
|
1777
|
-
), t.restore();
|
|
1778
|
-
}
|
|
1779
|
-
function _n(t, n, e, i) {
|
|
1780
|
-
const r = Math.round(Math.min(e, i) * 0.08), o = Math.max(2, Math.round(Math.min(e, i) * 0.01)), a = Math.round(Math.min(e, i) * 0.05);
|
|
1781
|
-
t.save(), t.strokeStyle = n, t.lineWidth = o, t.lineCap = "square";
|
|
1782
|
-
const c = o / 2, l = (s, u, h, f) => {
|
|
1783
|
-
t.beginPath(), t.moveTo(s + h * r, u), t.lineTo(s, u), t.lineTo(s, u + f * r), t.stroke();
|
|
1784
|
-
};
|
|
1785
|
-
l(a + c, a + c, 1, 1), l(e - a - c, a + c, -1, 1), l(a + c, i - a - c, 1, -1), l(e - a - c, i - a - c, -1, -1), t.restore();
|
|
1786
|
-
}
|
|
1787
|
-
function zn(t, n) {
|
|
1788
|
-
const e = Math.min(n.width, n.height), i = Math.round(e * 0.05), r = i, o = i, a = Math.round(e * 0.18), c = n.width + r + o, l = n.height + i + a, s = g(c, l), u = y(s);
|
|
1789
|
-
return u.fillStyle = t, u.fillRect(0, 0, c, l), u.drawImage(n.bitmap, r, i, n.width, n.height), {
|
|
1790
|
-
bitmap: s.canvas,
|
|
1791
|
-
width: c,
|
|
1792
|
-
height: l,
|
|
1793
|
-
mimeType: n.mimeType
|
|
1794
|
-
};
|
|
1795
|
-
}
|
|
1796
|
-
function yt(t, n) {
|
|
1797
|
-
return Math.max(4, Math.round(Math.min(t, n) * 0.04));
|
|
1798
|
-
}
|
|
1799
|
-
function Ai(t, n, e) {
|
|
1800
|
-
if (t !== "polaroid")
|
|
1801
|
-
return { width: n, height: e };
|
|
1802
|
-
const i = Math.min(n, e), r = Math.round(i * 0.05), o = Math.round(i * 0.18);
|
|
1803
|
-
return {
|
|
1804
|
-
width: n + 2 * r,
|
|
1805
|
-
height: e + r + o
|
|
1806
|
-
};
|
|
1807
|
-
}
|
|
1808
|
-
export {
|
|
1809
|
-
Ze as ALL_SELECTION_HANDLES,
|
|
1810
|
-
_ as DEFAULT_FINETUNE_STATE,
|
|
1811
|
-
vn as DEFAULT_FRAME_STATE,
|
|
1812
|
-
ut as DEFAULT_OUTPUT_STATE,
|
|
1813
|
-
cn as DEFAULT_PALETTE_COLOR,
|
|
1814
|
-
Sn as DEFAULT_REDACT_COLOR,
|
|
1815
|
-
bn as DEFAULT_REDACT_MODE,
|
|
1816
|
-
sn as DEFAULT_STROKE_WIDTH,
|
|
1817
|
-
re as ENCODABLE_MIMES,
|
|
1818
|
-
Dn as EventBus,
|
|
1819
|
-
rn as FILTER_PRESETS,
|
|
1820
|
-
Te as FINETUNE_ADJUSTMENTS,
|
|
1821
|
-
J as FINETUNE_MAX,
|
|
1822
|
-
G as FINETUNE_MIN,
|
|
1823
|
-
Z as FINETUNE_STEP,
|
|
1824
|
-
Cn as FRAME_PRESETS,
|
|
1825
|
-
Ii as FRAME_PRESET_IDS,
|
|
1826
|
-
_e as FREEHAND_DEFAULT_STROKE,
|
|
1827
|
-
Yt as FREE_ANGLE_MAX,
|
|
1828
|
-
Wt as FREE_ANGLE_MIN,
|
|
1829
|
-
de as FREE_ANGLE_STEP,
|
|
1830
|
-
Pe as HIGHLIGHT_DEFAULT_COLOR,
|
|
1831
|
-
Oe as HIGHLIGHT_DEFAULT_STROKE,
|
|
1832
|
-
W as HISTORY_MAX_ENTRIES,
|
|
1833
|
-
Jn as History,
|
|
1834
|
-
k as IDENTITY_VIEWPORT_TRANSFORM,
|
|
1835
|
-
Ve as KEYBOARD_PLACEABLE_KINDS,
|
|
1836
|
-
ot as MAX_ZOOM,
|
|
1837
|
-
it as MIN_SAMPLE_DISTANCE,
|
|
1838
|
-
at as MIN_ZOOM,
|
|
1839
|
-
x as PICK_TOLERANCE,
|
|
1840
|
-
oi as REDACT_MODES,
|
|
1841
|
-
ft as RESIZE_MAX_DIMENSION,
|
|
1842
|
-
K as RESIZE_MIN_DIMENSION,
|
|
1843
|
-
dn as SYSTEM_FONT_STACK,
|
|
1844
|
-
an as TEXT_DEFAULT_FONT_SIZE,
|
|
1845
|
-
Un as ViewportController,
|
|
1846
|
-
si as addRegion,
|
|
1847
|
-
Ye as addShape,
|
|
1848
|
-
hn as alignToOrigin,
|
|
1849
|
-
Et as applyAspectRatio,
|
|
1850
|
-
nn as applyClarity,
|
|
1851
|
-
tn as applyFinetuneLutAndSaturation,
|
|
1852
|
-
tt as applyFinetuneToImageData,
|
|
1853
|
-
ee as applyPresetByIndex,
|
|
1854
|
-
w as assertNever,
|
|
1855
|
-
ri as bakeAnnotate,
|
|
1856
|
-
st as bakeCanvasToBlob,
|
|
1857
|
-
ie as bakeCrop,
|
|
1858
|
-
Ne as bakeFinetune,
|
|
1859
|
-
fe as bakeFlip,
|
|
1860
|
-
vi as bakeFrame,
|
|
1861
|
-
Ri as bakeRedact,
|
|
1862
|
-
Ie as bakeResize,
|
|
1863
|
-
xe as bakeRotate,
|
|
1864
|
-
nt as boundingBoxOf,
|
|
1865
|
-
en as boxBlur3x3,
|
|
1866
|
-
Jt as buildFinetuneLut,
|
|
1867
|
-
b as canEncodeMime,
|
|
1868
|
-
ht as clampQuality,
|
|
1869
|
-
P as clampRectInside,
|
|
1870
|
-
pt as computeViewport,
|
|
1871
|
-
vt as copyJpegExif,
|
|
1872
|
-
g as createBakeCanvas,
|
|
1873
|
-
Si as createCenteredRedactRegion,
|
|
1874
|
-
Je as createCenteredShape,
|
|
1875
|
-
Gn as createStore,
|
|
1876
|
-
ii as decimatePoints,
|
|
1877
|
-
ln as defaultStylePalette,
|
|
1878
|
-
li as deleteRedactRegion,
|
|
1879
|
-
Ue as deleteShape,
|
|
1880
|
-
Ot as deriveOutputName,
|
|
1881
|
-
Ut as effectiveAngleDeg,
|
|
1882
|
-
Re as effectivePercent,
|
|
1883
|
-
se as encodeSourceImage,
|
|
1884
|
-
un as estimateTextSize,
|
|
1885
|
-
te as filterPresets,
|
|
1886
|
-
Fe as findActivePreset,
|
|
1887
|
-
rt as findFramePreset,
|
|
1888
|
-
xi as findRedactRegion,
|
|
1889
|
-
He as findShape,
|
|
1890
|
-
on as finetuneStatesEqual,
|
|
1891
|
-
O as fitRectToBoundsWithRatio,
|
|
1892
|
-
Ai as frameOutputSize,
|
|
1893
|
-
y as getBakeContext2D,
|
|
1894
|
-
fn as hitTest,
|
|
1895
|
-
ze as initialAnnotateState,
|
|
1896
|
-
ne as initialCropState,
|
|
1897
|
-
ke as initialFinetuneState,
|
|
1898
|
-
ue as initialFlipState,
|
|
1899
|
-
Ti as initialFrameState,
|
|
1900
|
-
ai as initialRedactState,
|
|
1901
|
-
pe as initialResizeState,
|
|
1902
|
-
ge as initialRotateState,
|
|
1903
|
-
Vt as isFinetuneNoOp,
|
|
1904
|
-
Bt as isFlipNoOp,
|
|
1905
|
-
An as isFrameNoOp,
|
|
1906
|
-
Ge as isKeyboardPlaceableKind,
|
|
1907
|
-
kt as isPresetVisible,
|
|
1908
|
-
jt as isResizeNoOp,
|
|
1909
|
-
Xt as isRotateNoOp,
|
|
1910
|
-
qt as largestInscribedRect,
|
|
1911
|
-
Ln as loadImage,
|
|
1912
|
-
ci as mintRegionId,
|
|
1913
|
-
De as mintShapeId,
|
|
1914
|
-
ui as mirrorRedactRegions,
|
|
1915
|
-
$e as mirrorShape,
|
|
1916
|
-
qe as normaliseRectExtent,
|
|
1917
|
-
Mi as normaliseRedactExtent,
|
|
1918
|
-
Fn as paintInsideFrame,
|
|
1919
|
-
Rn as paintRedactRegion,
|
|
1920
|
-
gn as paintShape,
|
|
1921
|
-
ei as pickShape,
|
|
1922
|
-
Wn as pointDisplayToImage,
|
|
1923
|
-
Bn as pointImageToDisplay,
|
|
1924
|
-
Qn as pointInRect,
|
|
1925
|
-
jn as rectBottom,
|
|
1926
|
-
$n as rectCenter,
|
|
1927
|
-
Xn as rectDisplayToImage,
|
|
1928
|
-
ni as rectFromHandleDrag,
|
|
1929
|
-
Hn as rectFromPoints,
|
|
1930
|
-
Yn as rectImageToDisplay,
|
|
1931
|
-
qn as rectRight,
|
|
1932
|
-
Kn as rectsEqual,
|
|
1933
|
-
Ei as regionBoundingBox,
|
|
1934
|
-
gt as replaceRedactRegion,
|
|
1935
|
-
Xe as replaceShape,
|
|
1936
|
-
Ae as resetAllFinetune,
|
|
1937
|
-
ve as resetFinetune,
|
|
1938
|
-
Zn as resizeRectFromHandle,
|
|
1939
|
-
Pt as resolveOutputMime,
|
|
1940
|
-
$t as resolveOutputSize,
|
|
1941
|
-
bi as revalidateRedactAgainstBounds,
|
|
1942
|
-
me as rotateClockwise,
|
|
1943
|
-
ye as rotateCounterClockwise,
|
|
1944
|
-
fi as rotateRedactRegions,
|
|
1945
|
-
Qe as rotateShape,
|
|
1946
|
-
St as roundRect,
|
|
1947
|
-
le as runUtilityChain,
|
|
1948
|
-
di as selectRedactRegion,
|
|
1949
|
-
We as selectShape,
|
|
1950
|
-
pi as selectedRedactRegionOf,
|
|
1951
|
-
ti as selectionHandlePositions,
|
|
1952
|
-
Le as setActiveTool,
|
|
1953
|
-
Ce as setFinetune,
|
|
1954
|
-
Ci as setFrameColor,
|
|
1955
|
-
ki as setFramePreset,
|
|
1956
|
-
we as setFreeAngle,
|
|
1957
|
-
Se as setHeightPx,
|
|
1958
|
-
Ee as setLockAspect,
|
|
1959
|
-
oe as setOutputMime,
|
|
1960
|
-
ae as setOutputQuality,
|
|
1961
|
-
be as setPercent,
|
|
1962
|
-
mi as setRedactCurrentColor,
|
|
1963
|
-
gi as setRedactCurrentMode,
|
|
1964
|
-
wi as setRedactRegionColor,
|
|
1965
|
-
yi as setRedactRegionMode,
|
|
1966
|
-
ce as setStripMetadata,
|
|
1967
|
-
Be as setStyle,
|
|
1968
|
-
Me as setWidthPx,
|
|
1969
|
-
he as toggleFlip,
|
|
1970
|
-
dt as tracePath,
|
|
1971
|
-
Ke as transformShapes,
|
|
1972
|
-
Vn as translateClampedRect,
|
|
1973
|
-
hi as translateRedactRegions,
|
|
1974
|
-
je as translateShape
|
|
1440
|
+
function Rt(e, t) {
|
|
1441
|
+
return e.brightness === t.brightness && e.contrast === t.contrast && e.saturation === t.saturation && e.exposure === t.exposure && e.clarity === t.clarity && e.gamma === t.gamma;
|
|
1442
|
+
}
|
|
1443
|
+
function zt(e) {
|
|
1444
|
+
for (let t of Lt) if (Rt(t.state, e)) return t;
|
|
1445
|
+
}
|
|
1446
|
+
//#endregion
|
|
1447
|
+
//#region src/plugins/finetune/math.ts
|
|
1448
|
+
function Bt(e) {
|
|
1449
|
+
let t = new Uint8ClampedArray(256), n = e.brightness / 200, r = 1 + e.contrast / 100, i = 1 + e.exposure / 200, a = Vt(e.gamma);
|
|
1450
|
+
for (let e = 0; e < 256; e++) {
|
|
1451
|
+
let o = e / 255;
|
|
1452
|
+
o *= i, o = (o - .5) * r + .5, o += n, o < 0 ? o = 0 : o > 1 && (o = 1), o **= a, o < 0 ? o = 0 : o > 1 && (o = 1), t[e] = Math.round(o * 255);
|
|
1453
|
+
}
|
|
1454
|
+
return t;
|
|
1455
|
+
}
|
|
1456
|
+
function Vt(e) {
|
|
1457
|
+
return e === 0 ? 1 : e > 0 ? 1 - e / 100 * .5 : 1 + 1 * (-e / 100);
|
|
1458
|
+
}
|
|
1459
|
+
function Ht(e, t, n, r) {
|
|
1460
|
+
let i = e.length;
|
|
1461
|
+
if (t.length !== i) throw Error("applyFinetuneLutAndSaturation: src/dst length mismatch");
|
|
1462
|
+
let a = 1 + r.saturation / 100;
|
|
1463
|
+
if (a === 1) {
|
|
1464
|
+
for (let r = 0; r < i; r += 4) t[r] = n[e[r]], t[r + 1] = n[e[r + 1]], t[r + 2] = n[e[r + 2]], t[r + 3] = e[r + 3];
|
|
1465
|
+
return;
|
|
1466
|
+
}
|
|
1467
|
+
for (let r = 0; r < i; r += 4) {
|
|
1468
|
+
let i = n[e[r]], o = n[e[r + 1]], s = n[e[r + 2]], c = .2126 * i + .7152 * o + .0722 * s, l = c + (i - c) * a, u = c + (o - c) * a, d = c + (s - c) * a;
|
|
1469
|
+
l < 0 ? l = 0 : l > 255 && (l = 255), u < 0 ? u = 0 : u > 255 && (u = 255), d < 0 ? d = 0 : d > 255 && (d = 255), t[r] = l, t[r + 1] = u, t[r + 2] = d, t[r + 3] = e[r + 3];
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
function Ut(e, t, n) {
|
|
1473
|
+
if (n === 0) return;
|
|
1474
|
+
let r = e.length;
|
|
1475
|
+
if (t.length !== r) throw Error("applyClarity: dst/blurred length mismatch");
|
|
1476
|
+
let i = n / 100;
|
|
1477
|
+
for (let n = 0; n < r; n += 4) {
|
|
1478
|
+
let r = e[n], a = e[n + 1], o = e[n + 2], s = r + i * (r - t[n]), c = a + i * (a - t[n + 1]), l = o + i * (o - t[n + 2]);
|
|
1479
|
+
s < 0 ? s = 0 : s > 255 && (s = 255), c < 0 ? c = 0 : c > 255 && (c = 255), l < 0 ? l = 0 : l > 255 && (l = 255), e[n] = s, e[n + 1] = c, e[n + 2] = l;
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
function Wt(e, t, n, r, i) {
|
|
1483
|
+
if (e.length !== t.length || e.length !== n.length) throw Error("boxBlur3x3: buffer length mismatch");
|
|
1484
|
+
for (let n = 0; n < i; n++) for (let i = 0; i < r; i++) {
|
|
1485
|
+
let a = i === 0 ? 0 : i - 1, o = i === r - 1 ? r - 1 : i + 1, s = (n * r + i) * 4, c = (n * r + a) * 4, l = (n * r + o) * 4;
|
|
1486
|
+
t[s] = (e[c] + e[s] + e[l]) / 3, t[s + 1] = (e[c + 1] + e[s + 1] + e[l + 1]) / 3, t[s + 2] = (e[c + 2] + e[s + 2] + e[l + 2]) / 3, t[s + 3] = e[s + 3];
|
|
1487
|
+
}
|
|
1488
|
+
for (let e = 0; e < i; e++) {
|
|
1489
|
+
let a = e === 0 ? 0 : e - 1, o = e === i - 1 ? i - 1 : e + 1;
|
|
1490
|
+
for (let i = 0; i < r; i++) {
|
|
1491
|
+
let s = (e * r + i) * 4, c = (a * r + i) * 4, l = (o * r + i) * 4;
|
|
1492
|
+
n[s] = (t[c] + t[s] + t[l]) / 3, n[s + 1] = (t[c + 1] + t[s + 1] + t[l + 1]) / 3, n[s + 2] = (t[c + 2] + t[s + 2] + t[l + 2]) / 3, n[s + 3] = t[s + 3];
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
function K(e, t, n) {
|
|
1497
|
+
if (t.width !== n.width || t.height !== n.height || t.data.length !== n.data.length) throw Error("applyFinetuneToImageData: baseline/dst dimensions mismatch");
|
|
1498
|
+
let r = Bt(e);
|
|
1499
|
+
if (Ht(t.data, n.data, r, e), e.clarity !== 0) {
|
|
1500
|
+
let r = new Uint8ClampedArray(t.data.length), i = new Uint8ClampedArray(t.data.length);
|
|
1501
|
+
Wt(t.data, r, i, t.width, t.height), Ut(n.data, i, e.clarity);
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
//#endregion
|
|
1505
|
+
//#region src/plugins/finetune/bake.ts
|
|
1506
|
+
async function Gt(n, r) {
|
|
1507
|
+
if (Mt(n)) return r;
|
|
1508
|
+
let i = e(r.width, r.height), a = t(i);
|
|
1509
|
+
a.imageSmoothingEnabled = !0, a.imageSmoothingQuality = "high", a.drawImage(r.bitmap, 0, 0, r.width, r.height);
|
|
1510
|
+
let o = a.getImageData(0, 0, r.width, r.height);
|
|
1511
|
+
if (n.clarity === 0) K(n, o, o), a.putImageData(o, 0, 0);
|
|
1512
|
+
else {
|
|
1513
|
+
let e = new ImageData(new Uint8ClampedArray(o.data.length), o.width, o.height);
|
|
1514
|
+
K(n, o, e), a.putImageData(e, 0, 0);
|
|
1515
|
+
}
|
|
1516
|
+
return {
|
|
1517
|
+
bitmap: i.canvas,
|
|
1518
|
+
width: r.width,
|
|
1519
|
+
height: r.height,
|
|
1520
|
+
mimeType: r.mimeType
|
|
1521
|
+
};
|
|
1522
|
+
}
|
|
1523
|
+
//#endregion
|
|
1524
|
+
//#region src/plugins/flip/state.ts
|
|
1525
|
+
function Kt() {
|
|
1526
|
+
return {
|
|
1527
|
+
horizontal: !1,
|
|
1528
|
+
vertical: !1
|
|
1529
|
+
};
|
|
1530
|
+
}
|
|
1531
|
+
function qt(e, t) {
|
|
1532
|
+
return t === "horizontal" ? {
|
|
1533
|
+
...e,
|
|
1534
|
+
horizontal: !e.horizontal
|
|
1535
|
+
} : {
|
|
1536
|
+
...e,
|
|
1537
|
+
vertical: !e.vertical
|
|
1538
|
+
};
|
|
1539
|
+
}
|
|
1540
|
+
function Jt(e) {
|
|
1541
|
+
return !e.horizontal && !e.vertical;
|
|
1542
|
+
}
|
|
1543
|
+
//#endregion
|
|
1544
|
+
//#region src/plugins/flip/bake.ts
|
|
1545
|
+
async function Yt(n, r) {
|
|
1546
|
+
if (Jt(n)) return r;
|
|
1547
|
+
let { width: i, height: a } = r, o = e(i, a), s = t(o), c = n.horizontal ? -1 : 1, l = n.vertical ? -1 : 1, u = n.horizontal ? i : 0, d = n.vertical ? a : 0;
|
|
1548
|
+
return s.setTransform(c, 0, 0, l, u, d), s.drawImage(r.bitmap, 0, 0), {
|
|
1549
|
+
bitmap: o.canvas,
|
|
1550
|
+
width: i,
|
|
1551
|
+
height: a,
|
|
1552
|
+
mimeType: r.mimeType
|
|
1553
|
+
};
|
|
1554
|
+
}
|
|
1555
|
+
//#endregion
|
|
1556
|
+
//#region src/plugins/frame/state.ts
|
|
1557
|
+
var Xt = [
|
|
1558
|
+
"none",
|
|
1559
|
+
"solidSharp",
|
|
1560
|
+
"solidRound",
|
|
1561
|
+
"lineSingle",
|
|
1562
|
+
"hook",
|
|
1563
|
+
"polaroid"
|
|
1564
|
+
], Zt = [
|
|
1565
|
+
{
|
|
1566
|
+
id: "none",
|
|
1567
|
+
label: "None",
|
|
1568
|
+
acceptsColor: !1,
|
|
1569
|
+
defaultColor: "#000000"
|
|
1570
|
+
},
|
|
1571
|
+
{
|
|
1572
|
+
id: "solidSharp",
|
|
1573
|
+
label: "Mat Sharp",
|
|
1574
|
+
acceptsColor: !0,
|
|
1575
|
+
defaultColor: "#000000"
|
|
1576
|
+
},
|
|
1577
|
+
{
|
|
1578
|
+
id: "solidRound",
|
|
1579
|
+
label: "Mat Round",
|
|
1580
|
+
acceptsColor: !0,
|
|
1581
|
+
defaultColor: "#000000"
|
|
1582
|
+
},
|
|
1583
|
+
{
|
|
1584
|
+
id: "lineSingle",
|
|
1585
|
+
label: "Line Single",
|
|
1586
|
+
acceptsColor: !0,
|
|
1587
|
+
defaultColor: "#000000"
|
|
1588
|
+
},
|
|
1589
|
+
{
|
|
1590
|
+
id: "hook",
|
|
1591
|
+
label: "Corner Hooks",
|
|
1592
|
+
acceptsColor: !0,
|
|
1593
|
+
defaultColor: "#000000"
|
|
1594
|
+
},
|
|
1595
|
+
{
|
|
1596
|
+
id: "polaroid",
|
|
1597
|
+
label: "Polaroid",
|
|
1598
|
+
acceptsColor: !0,
|
|
1599
|
+
defaultColor: "#ffffff"
|
|
1600
|
+
}
|
|
1601
|
+
], Qt = {
|
|
1602
|
+
presetId: "none",
|
|
1603
|
+
color: "#000000"
|
|
1975
1604
|
};
|
|
1976
|
-
|
|
1605
|
+
function $t() {
|
|
1606
|
+
return Qt;
|
|
1607
|
+
}
|
|
1608
|
+
function en(e) {
|
|
1609
|
+
return e.presetId === "none";
|
|
1610
|
+
}
|
|
1611
|
+
function tn(e, t) {
|
|
1612
|
+
if (e.presetId === t) return e;
|
|
1613
|
+
let n = q(e.presetId), r = q(t);
|
|
1614
|
+
return r ? {
|
|
1615
|
+
presetId: t,
|
|
1616
|
+
color: n !== void 0 && e.color === n.defaultColor ? r.defaultColor : e.color
|
|
1617
|
+
} : {
|
|
1618
|
+
...e,
|
|
1619
|
+
presetId: t
|
|
1620
|
+
};
|
|
1621
|
+
}
|
|
1622
|
+
function nn(e, t) {
|
|
1623
|
+
return e.color === t ? e : {
|
|
1624
|
+
...e,
|
|
1625
|
+
color: t
|
|
1626
|
+
};
|
|
1627
|
+
}
|
|
1628
|
+
function q(e) {
|
|
1629
|
+
return Zt.find((t) => t.id === e);
|
|
1630
|
+
}
|
|
1631
|
+
//#endregion
|
|
1632
|
+
//#region src/plugins/frame/bake.ts
|
|
1633
|
+
async function rn(e, t) {
|
|
1634
|
+
return en(e) ? t : e.presetId === "polaroid" ? dn(e.color, t) : e.presetId === "none" ? t : an(e.presetId, e.color, t);
|
|
1635
|
+
}
|
|
1636
|
+
function an(n, r, i) {
|
|
1637
|
+
let a = e(i.width, i.height), o = t(a);
|
|
1638
|
+
return o.drawImage(i.bitmap, 0, 0, i.width, i.height), on(o, n, r, i.width, i.height), {
|
|
1639
|
+
bitmap: a.canvas,
|
|
1640
|
+
width: i.width,
|
|
1641
|
+
height: i.height,
|
|
1642
|
+
mimeType: i.mimeType
|
|
1643
|
+
};
|
|
1644
|
+
}
|
|
1645
|
+
function on(e, t, n, r, i) {
|
|
1646
|
+
switch (t) {
|
|
1647
|
+
case "solidSharp":
|
|
1648
|
+
sn(e, n, r, i);
|
|
1649
|
+
return;
|
|
1650
|
+
case "solidRound":
|
|
1651
|
+
cn(e, n, r, i);
|
|
1652
|
+
return;
|
|
1653
|
+
case "lineSingle":
|
|
1654
|
+
ln(e, n, r, i);
|
|
1655
|
+
return;
|
|
1656
|
+
case "hook":
|
|
1657
|
+
un(e, n, r, i);
|
|
1658
|
+
return;
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
function sn(e, t, n, r) {
|
|
1662
|
+
let i = fn(n, r);
|
|
1663
|
+
e.save(), e.fillStyle = t, e.fillRect(0, 0, n, i), e.fillRect(0, r - i, n, i), e.fillRect(0, i, i, r - 2 * i), e.fillRect(n - i, i, i, r - 2 * i), e.restore();
|
|
1664
|
+
}
|
|
1665
|
+
function cn(e, t, n, r) {
|
|
1666
|
+
let i = fn(n, r);
|
|
1667
|
+
sn(e, t, n, r), e.save(), e.globalCompositeOperation = "destination-out", e.fillStyle = "#000", J(e, 0, 0, i, "tl"), J(e, n, 0, i, "tr"), J(e, 0, r, i, "bl"), J(e, n, r, i, "br"), e.restore();
|
|
1668
|
+
}
|
|
1669
|
+
function J(e, t, n, r, i) {
|
|
1670
|
+
switch (e.beginPath(), e.moveTo(t, n), i) {
|
|
1671
|
+
case "tl":
|
|
1672
|
+
e.lineTo(t + r, n), e.arc(t + r, n + r, r, -Math.PI / 2, Math.PI, !0), e.lineTo(t, n);
|
|
1673
|
+
break;
|
|
1674
|
+
case "tr":
|
|
1675
|
+
e.lineTo(t, n + r), e.arc(t - r, n + r, r, 0, -Math.PI / 2, !0), e.lineTo(t, n);
|
|
1676
|
+
break;
|
|
1677
|
+
case "bl":
|
|
1678
|
+
e.lineTo(t + r, n), e.arc(t + r, n - r, r, Math.PI / 2, Math.PI, !1), e.lineTo(t, n);
|
|
1679
|
+
break;
|
|
1680
|
+
case "br":
|
|
1681
|
+
e.lineTo(t - r, n), e.arc(t - r, n - r, r, Math.PI / 2, 0, !0), e.lineTo(t, n);
|
|
1682
|
+
break;
|
|
1683
|
+
}
|
|
1684
|
+
e.closePath(), e.fill();
|
|
1685
|
+
}
|
|
1686
|
+
function ln(e, t, n, r) {
|
|
1687
|
+
let i = Math.round(Math.min(n, r) * .05), a = Math.max(2, Math.round(Math.min(n, r) * .01));
|
|
1688
|
+
e.save(), e.strokeStyle = t, e.lineWidth = a;
|
|
1689
|
+
let o = a / 2;
|
|
1690
|
+
e.strokeRect(i + o, i + o, n - 2 * i - a, r - 2 * i - a), e.restore();
|
|
1691
|
+
}
|
|
1692
|
+
function un(e, t, n, r) {
|
|
1693
|
+
let i = Math.round(Math.min(n, r) * .08), a = Math.max(2, Math.round(Math.min(n, r) * .01)), o = Math.round(Math.min(n, r) * .05);
|
|
1694
|
+
e.save(), e.strokeStyle = t, e.lineWidth = a, e.lineCap = "square";
|
|
1695
|
+
let s = a / 2, c = (t, n, r, a) => {
|
|
1696
|
+
e.beginPath(), e.moveTo(t + r * i, n), e.lineTo(t, n), e.lineTo(t, n + a * i), e.stroke();
|
|
1697
|
+
};
|
|
1698
|
+
c(o + s, o + s, 1, 1), c(n - o - s, o + s, -1, 1), c(o + s, r - o - s, 1, -1), c(n - o - s, r - o - s, -1, -1), e.restore();
|
|
1699
|
+
}
|
|
1700
|
+
function dn(n, r) {
|
|
1701
|
+
let i = Math.min(r.width, r.height), a = Math.round(i * .05), o = a, s = a, c = Math.round(i * .18), l = r.width + o + s, u = r.height + a + c, d = e(l, u), f = t(d);
|
|
1702
|
+
return f.fillStyle = n, f.fillRect(0, 0, l, u), f.drawImage(r.bitmap, o, a, r.width, r.height), {
|
|
1703
|
+
bitmap: d.canvas,
|
|
1704
|
+
width: l,
|
|
1705
|
+
height: u,
|
|
1706
|
+
mimeType: r.mimeType
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1709
|
+
function fn(e, t) {
|
|
1710
|
+
return Math.max(4, Math.round(Math.min(e, t) * .04));
|
|
1711
|
+
}
|
|
1712
|
+
function pn(e, t, n) {
|
|
1713
|
+
if (e !== "polaroid") return {
|
|
1714
|
+
width: t,
|
|
1715
|
+
height: n
|
|
1716
|
+
};
|
|
1717
|
+
let r = Math.min(t, n), i = Math.round(r * .05), a = Math.round(r * .18);
|
|
1718
|
+
return {
|
|
1719
|
+
width: t + 2 * i,
|
|
1720
|
+
height: n + i + a
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1723
|
+
//#endregion
|
|
1724
|
+
//#region src/plugins/redact/bake.ts
|
|
1725
|
+
async function mn(n, r) {
|
|
1726
|
+
if (n.regions.length === 0) return r;
|
|
1727
|
+
let i = e(r.width, r.height), a = t(i);
|
|
1728
|
+
a.drawImage(r.bitmap, 0, 0, r.width, r.height);
|
|
1729
|
+
for (let e of n.regions) hn(a, i.canvas, e, r);
|
|
1730
|
+
return {
|
|
1731
|
+
bitmap: i.canvas,
|
|
1732
|
+
width: r.width,
|
|
1733
|
+
height: r.height,
|
|
1734
|
+
mimeType: r.mimeType
|
|
1735
|
+
};
|
|
1736
|
+
}
|
|
1737
|
+
function hn(e, t, n, r) {
|
|
1738
|
+
let i = Math.round(n.width), a = Math.round(n.height);
|
|
1739
|
+
if (i < 1 || a < 1) return;
|
|
1740
|
+
let o = Math.round(n.x), s = Math.round(n.y);
|
|
1741
|
+
switch (n.mode) {
|
|
1742
|
+
case "solid":
|
|
1743
|
+
gn(e, n, o, s, i, a);
|
|
1744
|
+
return;
|
|
1745
|
+
case "pixelate":
|
|
1746
|
+
_n(e, t, r, o, s, i, a);
|
|
1747
|
+
return;
|
|
1748
|
+
case "blur":
|
|
1749
|
+
vn(e, t, r, o, s, i, a);
|
|
1750
|
+
return;
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
function gn(e, t, n, r, i, a) {
|
|
1754
|
+
e.save(), e.fillStyle = t.color, e.fillRect(n, r, i, a), e.restore();
|
|
1755
|
+
}
|
|
1756
|
+
function _n(e, t, n, r, i, a, o) {
|
|
1757
|
+
let s = Math.max(a, o), c = Math.max(4, Math.round(8 * Math.min(1, s / 240))), l = Math.max(1, Math.round(a / s * c)), u = Math.max(1, Math.round(o / s * c));
|
|
1758
|
+
e.save();
|
|
1759
|
+
let d = Y(l, u);
|
|
1760
|
+
if (!d) {
|
|
1761
|
+
e.restore();
|
|
1762
|
+
return;
|
|
1763
|
+
}
|
|
1764
|
+
d.ctx.imageSmoothingEnabled = !0, d.ctx.imageSmoothingQuality = "low", d.ctx.drawImage(t, r, i, a, o, 0, 0, l, u), e.imageSmoothingEnabled = !1, e.drawImage(d.canvas, 0, 0, l, u, r, i, a, o), e.restore();
|
|
1765
|
+
}
|
|
1766
|
+
function vn(e, t, n, r, i, a, o) {
|
|
1767
|
+
let s = 1 / 8, c = Math.max(1, Math.round(a * s)), l = Math.max(1, Math.round(o * s)), u = Y(c, l);
|
|
1768
|
+
if (!u) return;
|
|
1769
|
+
u.ctx.imageSmoothingEnabled = !0, u.ctx.imageSmoothingQuality = "high", u.ctx.drawImage(t, r, i, a, o, 0, 0, c, l);
|
|
1770
|
+
let d = Math.max(1, Math.round(c * .5)), f = Math.max(1, Math.round(l * .5)), p = Y(d, f);
|
|
1771
|
+
if (!p) {
|
|
1772
|
+
e.save(), e.imageSmoothingEnabled = !0, e.imageSmoothingQuality = "high", e.drawImage(u.canvas, 0, 0, c, l, r, i, a, o), e.restore();
|
|
1773
|
+
return;
|
|
1774
|
+
}
|
|
1775
|
+
p.ctx.imageSmoothingEnabled = !0, p.ctx.imageSmoothingQuality = "high", p.ctx.drawImage(u.canvas, 0, 0, c, l, 0, 0, d, f), e.save(), e.imageSmoothingEnabled = !0, e.imageSmoothingQuality = "high", e.drawImage(p.canvas, 0, 0, d, f, r, i, a, o), e.restore();
|
|
1776
|
+
}
|
|
1777
|
+
function Y(e, t) {
|
|
1778
|
+
if (typeof OffscreenCanvas < "u") try {
|
|
1779
|
+
let n = new OffscreenCanvas(e, t), r = n.getContext("2d");
|
|
1780
|
+
if (r) return {
|
|
1781
|
+
canvas: n,
|
|
1782
|
+
ctx: r
|
|
1783
|
+
};
|
|
1784
|
+
} catch {}
|
|
1785
|
+
if (typeof document > "u") return null;
|
|
1786
|
+
let n = document.createElement("canvas");
|
|
1787
|
+
n.width = e, n.height = t;
|
|
1788
|
+
let r = n.getContext("2d");
|
|
1789
|
+
return r ? {
|
|
1790
|
+
canvas: n,
|
|
1791
|
+
ctx: r
|
|
1792
|
+
} : null;
|
|
1793
|
+
}
|
|
1794
|
+
//#endregion
|
|
1795
|
+
//#region src/plugins/redact/state.ts
|
|
1796
|
+
var yn = [
|
|
1797
|
+
"pixelate",
|
|
1798
|
+
"blur",
|
|
1799
|
+
"solid"
|
|
1800
|
+
], bn = "#000000", xn = "pixelate";
|
|
1801
|
+
function Sn(e) {
|
|
1802
|
+
return {
|
|
1803
|
+
regions: [],
|
|
1804
|
+
nextRegionNumber: 1,
|
|
1805
|
+
selectedId: null,
|
|
1806
|
+
currentMode: xn,
|
|
1807
|
+
currentColor: bn,
|
|
1808
|
+
imageSize: e.imageSize
|
|
1809
|
+
};
|
|
1810
|
+
}
|
|
1811
|
+
function Cn(e) {
|
|
1812
|
+
return {
|
|
1813
|
+
id: `r_${e.nextRegionNumber.toString(36)}`,
|
|
1814
|
+
nextRegionNumber: e.nextRegionNumber + 1
|
|
1815
|
+
};
|
|
1816
|
+
}
|
|
1817
|
+
function wn(e, t) {
|
|
1818
|
+
return {
|
|
1819
|
+
...e,
|
|
1820
|
+
regions: [...e.regions, t],
|
|
1821
|
+
selectedId: t.id
|
|
1822
|
+
};
|
|
1823
|
+
}
|
|
1824
|
+
function X(e, t) {
|
|
1825
|
+
let n = !1, r = e.regions.map((e) => e.id === t.id ? (n = !0, t) : e);
|
|
1826
|
+
return n ? {
|
|
1827
|
+
...e,
|
|
1828
|
+
regions: r
|
|
1829
|
+
} : e;
|
|
1830
|
+
}
|
|
1831
|
+
function Tn(e, t) {
|
|
1832
|
+
let n = e.regions.filter((e) => e.id !== t);
|
|
1833
|
+
return n.length === e.regions.length ? e : {
|
|
1834
|
+
...e,
|
|
1835
|
+
regions: n,
|
|
1836
|
+
selectedId: e.selectedId === t ? null : e.selectedId
|
|
1837
|
+
};
|
|
1838
|
+
}
|
|
1839
|
+
function En(e, t, n) {
|
|
1840
|
+
if (e.regions.length === 0) return e;
|
|
1841
|
+
let r = e.regions.map((e) => t === "horizontal" ? {
|
|
1842
|
+
...e,
|
|
1843
|
+
x: n.width - e.x - e.width
|
|
1844
|
+
} : {
|
|
1845
|
+
...e,
|
|
1846
|
+
y: n.height - e.y - e.height
|
|
1847
|
+
});
|
|
1848
|
+
return {
|
|
1849
|
+
...e,
|
|
1850
|
+
regions: r,
|
|
1851
|
+
imageSize: n
|
|
1852
|
+
};
|
|
1853
|
+
}
|
|
1854
|
+
function Dn(e, t, n, r) {
|
|
1855
|
+
if (e.regions.length === 0) return {
|
|
1856
|
+
...e,
|
|
1857
|
+
imageSize: r
|
|
1858
|
+
};
|
|
1859
|
+
if (t === 0 && n === 0 && e.imageSize === r) return e;
|
|
1860
|
+
let i = e.regions.map((e) => ({
|
|
1861
|
+
...e,
|
|
1862
|
+
x: e.x + t,
|
|
1863
|
+
y: e.y + n
|
|
1864
|
+
}));
|
|
1865
|
+
return {
|
|
1866
|
+
...e,
|
|
1867
|
+
regions: i,
|
|
1868
|
+
imageSize: r
|
|
1869
|
+
};
|
|
1870
|
+
}
|
|
1871
|
+
function On(e, t, n) {
|
|
1872
|
+
if (t === 0 || e.regions.length === 0) return {
|
|
1873
|
+
...e,
|
|
1874
|
+
imageSize: n
|
|
1875
|
+
};
|
|
1876
|
+
let r = e.imageSize.width, i = e.imageSize.height, a = e.regions.map((e) => {
|
|
1877
|
+
let { x: n, y: a, width: o, height: s } = e;
|
|
1878
|
+
return t === 1 ? {
|
|
1879
|
+
...e,
|
|
1880
|
+
x: i - a - s,
|
|
1881
|
+
y: n,
|
|
1882
|
+
width: s,
|
|
1883
|
+
height: o
|
|
1884
|
+
} : t === 2 ? {
|
|
1885
|
+
...e,
|
|
1886
|
+
x: r - n - o,
|
|
1887
|
+
y: i - a - s
|
|
1888
|
+
} : {
|
|
1889
|
+
...e,
|
|
1890
|
+
x: a,
|
|
1891
|
+
y: r - n - o,
|
|
1892
|
+
width: s,
|
|
1893
|
+
height: o
|
|
1894
|
+
};
|
|
1895
|
+
});
|
|
1896
|
+
return {
|
|
1897
|
+
...e,
|
|
1898
|
+
regions: a,
|
|
1899
|
+
imageSize: n
|
|
1900
|
+
};
|
|
1901
|
+
}
|
|
1902
|
+
function kn(e, t) {
|
|
1903
|
+
return e.selectedId === t ? e : {
|
|
1904
|
+
...e,
|
|
1905
|
+
selectedId: t
|
|
1906
|
+
};
|
|
1907
|
+
}
|
|
1908
|
+
function An(e, t) {
|
|
1909
|
+
return e.currentMode === t ? e : {
|
|
1910
|
+
...e,
|
|
1911
|
+
currentMode: t
|
|
1912
|
+
};
|
|
1913
|
+
}
|
|
1914
|
+
function jn(e, t) {
|
|
1915
|
+
return e.currentColor === t ? e : {
|
|
1916
|
+
...e,
|
|
1917
|
+
currentColor: t
|
|
1918
|
+
};
|
|
1919
|
+
}
|
|
1920
|
+
function Mn(e, t, n) {
|
|
1921
|
+
let r = e.regions.find((e) => e.id === t);
|
|
1922
|
+
return !r || r.mode === n ? e : X(e, {
|
|
1923
|
+
...r,
|
|
1924
|
+
mode: n
|
|
1925
|
+
});
|
|
1926
|
+
}
|
|
1927
|
+
function Nn(e, t, n) {
|
|
1928
|
+
let r = e.regions.find((e) => e.id === t);
|
|
1929
|
+
return !r || r.color === n ? e : X(e, {
|
|
1930
|
+
...r,
|
|
1931
|
+
color: n
|
|
1932
|
+
});
|
|
1933
|
+
}
|
|
1934
|
+
function Pn(e, t) {
|
|
1935
|
+
if (t !== null) return e.regions.find((e) => e.id === t);
|
|
1936
|
+
}
|
|
1937
|
+
function Fn(e) {
|
|
1938
|
+
return e.selectedId === null ? null : e.regions.find((t) => t.id === e.selectedId) ?? null;
|
|
1939
|
+
}
|
|
1940
|
+
function In(e) {
|
|
1941
|
+
let { x: t, y: n, width: r, height: i } = e;
|
|
1942
|
+
return r < 0 && (t += r, r = -r), i < 0 && (n += i, i = -i), {
|
|
1943
|
+
x: t,
|
|
1944
|
+
y: n,
|
|
1945
|
+
width: r,
|
|
1946
|
+
height: i
|
|
1947
|
+
};
|
|
1948
|
+
}
|
|
1949
|
+
function Ln(e) {
|
|
1950
|
+
let { imageSize: t, mode: n, color: r, id: i } = e, a = Math.min(t.width, t.height), o = Math.max(80, Math.round(a * .25)), s = t.width / 2, c = t.height / 2;
|
|
1951
|
+
return {
|
|
1952
|
+
id: i,
|
|
1953
|
+
x: Math.round(s - o / 2),
|
|
1954
|
+
y: Math.round(c - o / 2),
|
|
1955
|
+
width: o,
|
|
1956
|
+
height: o,
|
|
1957
|
+
mode: n,
|
|
1958
|
+
color: r
|
|
1959
|
+
};
|
|
1960
|
+
}
|
|
1961
|
+
function Rn(e, t) {
|
|
1962
|
+
if (e.imageSize.width === t.width && e.imageSize.height === t.height) return e;
|
|
1963
|
+
let n = [];
|
|
1964
|
+
for (let r of e.regions) r.x + r.width <= 0 || r.y + r.height <= 0 || r.x >= t.width || r.y >= t.height || n.push(zn(r, t));
|
|
1965
|
+
let r = e.selectedId !== null && !n.some((t) => t.id === e.selectedId);
|
|
1966
|
+
return {
|
|
1967
|
+
...e,
|
|
1968
|
+
regions: n,
|
|
1969
|
+
imageSize: {
|
|
1970
|
+
width: t.width,
|
|
1971
|
+
height: t.height
|
|
1972
|
+
},
|
|
1973
|
+
selectedId: r ? null : e.selectedId
|
|
1974
|
+
};
|
|
1975
|
+
}
|
|
1976
|
+
function zn(e, t) {
|
|
1977
|
+
let n = Math.max(0, e.x), r = Math.max(0, e.y), i = Math.min(t.width, e.x + e.width), a = Math.min(t.height, e.y + e.height);
|
|
1978
|
+
return {
|
|
1979
|
+
...e,
|
|
1980
|
+
x: n,
|
|
1981
|
+
y: r,
|
|
1982
|
+
width: Math.max(0, i - n),
|
|
1983
|
+
height: Math.max(0, a - r)
|
|
1984
|
+
};
|
|
1985
|
+
}
|
|
1986
|
+
function Bn(e) {
|
|
1987
|
+
return {
|
|
1988
|
+
x: e.x,
|
|
1989
|
+
y: e.y,
|
|
1990
|
+
width: e.width,
|
|
1991
|
+
height: e.height
|
|
1992
|
+
};
|
|
1993
|
+
}
|
|
1994
|
+
//#endregion
|
|
1995
|
+
//#region src/plugins/resize/state.ts
|
|
1996
|
+
var Z = 8e3, Vn = 1;
|
|
1997
|
+
function Hn() {
|
|
1998
|
+
return {
|
|
1999
|
+
scaleX: 1,
|
|
2000
|
+
scaleY: 1,
|
|
2001
|
+
lockAspect: !0
|
|
2002
|
+
};
|
|
2003
|
+
}
|
|
2004
|
+
function Un(e) {
|
|
2005
|
+
return Math.abs(e.scaleX - 1) < 1e-9 && Math.abs(e.scaleY - 1) < 1e-9;
|
|
2006
|
+
}
|
|
2007
|
+
function Q(e, t) {
|
|
2008
|
+
return {
|
|
2009
|
+
width: $(Math.round(t.width * e.scaleX)),
|
|
2010
|
+
height: $(Math.round(t.height * e.scaleY))
|
|
2011
|
+
};
|
|
2012
|
+
}
|
|
2013
|
+
function Wn(e, t, n) {
|
|
2014
|
+
if (n.width <= 0) return e;
|
|
2015
|
+
let r = $(Math.round(t)) / n.width, i = e.lockAspect ? r : e.scaleY;
|
|
2016
|
+
return {
|
|
2017
|
+
...e,
|
|
2018
|
+
scaleX: r,
|
|
2019
|
+
scaleY: i
|
|
2020
|
+
};
|
|
2021
|
+
}
|
|
2022
|
+
function Gn(e, t, n) {
|
|
2023
|
+
if (n.height <= 0) return e;
|
|
2024
|
+
let r = $(Math.round(t)) / n.height, i = e.lockAspect ? r : e.scaleX;
|
|
2025
|
+
return {
|
|
2026
|
+
...e,
|
|
2027
|
+
scaleX: i,
|
|
2028
|
+
scaleY: r
|
|
2029
|
+
};
|
|
2030
|
+
}
|
|
2031
|
+
function Kn(e, t) {
|
|
2032
|
+
let n = Yn(t / 100);
|
|
2033
|
+
return {
|
|
2034
|
+
...e,
|
|
2035
|
+
scaleX: n,
|
|
2036
|
+
scaleY: n
|
|
2037
|
+
};
|
|
2038
|
+
}
|
|
2039
|
+
function qn(e, t) {
|
|
2040
|
+
if (e.lockAspect === t) return e;
|
|
2041
|
+
if (!t) return {
|
|
2042
|
+
...e,
|
|
2043
|
+
lockAspect: !1
|
|
2044
|
+
};
|
|
2045
|
+
let n = (e.scaleX + e.scaleY) / 2;
|
|
2046
|
+
return {
|
|
2047
|
+
scaleX: n,
|
|
2048
|
+
scaleY: n,
|
|
2049
|
+
lockAspect: !0
|
|
2050
|
+
};
|
|
2051
|
+
}
|
|
2052
|
+
function Jn(e) {
|
|
2053
|
+
let t = Math.max(e.scaleX, e.scaleY);
|
|
2054
|
+
return Math.round(t * 1e3) / 10;
|
|
2055
|
+
}
|
|
2056
|
+
function $(e) {
|
|
2057
|
+
return Number.isFinite(e) ? Math.max(1, Math.min(Z, Math.trunc(e))) : 1;
|
|
2058
|
+
}
|
|
2059
|
+
function Yn(e) {
|
|
2060
|
+
return !Number.isFinite(e) || e <= 0 ? .01 : Math.max(.01, Math.min(e, Z));
|
|
2061
|
+
}
|
|
2062
|
+
//#endregion
|
|
2063
|
+
//#region src/plugins/resize/bake.ts
|
|
2064
|
+
async function Xn(e, t) {
|
|
2065
|
+
if (Un(e)) return t;
|
|
2066
|
+
let { width: n, height: r } = Q(e, t);
|
|
2067
|
+
if (n <= 0 || r <= 0) return t;
|
|
2068
|
+
let i = Zn(t.width, t.height, n, r), a = {
|
|
2069
|
+
bitmap: t.bitmap,
|
|
2070
|
+
width: t.width,
|
|
2071
|
+
height: t.height
|
|
2072
|
+
}, o = [];
|
|
2073
|
+
for (let e = 0; e < i; e++) {
|
|
2074
|
+
let e = Math.max(n, Math.floor(a.width / 2)), t = Math.max(r, Math.floor(a.height / 2)), i = Qn(a, e, t);
|
|
2075
|
+
o.push(i), a = {
|
|
2076
|
+
bitmap: i.canvas,
|
|
2077
|
+
width: e,
|
|
2078
|
+
height: t
|
|
2079
|
+
};
|
|
2080
|
+
}
|
|
2081
|
+
let s = Qn(a, n, r);
|
|
2082
|
+
return o.length = 0, {
|
|
2083
|
+
bitmap: s.canvas,
|
|
2084
|
+
width: n,
|
|
2085
|
+
height: r,
|
|
2086
|
+
mimeType: t.mimeType
|
|
2087
|
+
};
|
|
2088
|
+
}
|
|
2089
|
+
function Zn(e, t, n, r) {
|
|
2090
|
+
let i = e, a = t, o = 0;
|
|
2091
|
+
for (; (i / 2 > n || a / 2 > r) && o < 16;) i = Math.floor(i / 2), a = Math.floor(a / 2), o += 1;
|
|
2092
|
+
return o;
|
|
2093
|
+
}
|
|
2094
|
+
function Qn(n, r, i) {
|
|
2095
|
+
let a = e(r, i), o = t(a);
|
|
2096
|
+
return o.imageSmoothingEnabled = !0, o.imageSmoothingQuality = "high", o.drawImage(n.bitmap, 0, 0, n.width, n.height, 0, 0, r, i), a;
|
|
2097
|
+
}
|
|
2098
|
+
//#endregion
|
|
2099
|
+
//#region src/plugins/rotate/inscribe.ts
|
|
2100
|
+
function $n(e, t) {
|
|
2101
|
+
let n = e.width, r = e.height;
|
|
2102
|
+
if (n <= 0 || r <= 0) return {
|
|
2103
|
+
width: 0,
|
|
2104
|
+
height: 0
|
|
2105
|
+
};
|
|
2106
|
+
let i = Math.abs(Math.cos(t)), a = Math.abs(Math.sin(t)), o = n * i + r * a, s = n * a + r * i, c = o > er ? n * n / o : Infinity, l = s > er ? n * r / s : Infinity, u = Math.min(c, l);
|
|
2107
|
+
return {
|
|
2108
|
+
width: u,
|
|
2109
|
+
height: u * r / n
|
|
2110
|
+
};
|
|
2111
|
+
}
|
|
2112
|
+
var er = 1e-9, tr = -45, nr = 45, rr = .1;
|
|
2113
|
+
function ir() {
|
|
2114
|
+
return {
|
|
2115
|
+
quarterTurns: 0,
|
|
2116
|
+
freeAngle: 0
|
|
2117
|
+
};
|
|
2118
|
+
}
|
|
2119
|
+
function ar(e) {
|
|
2120
|
+
return {
|
|
2121
|
+
...e,
|
|
2122
|
+
quarterTurns: (e.quarterTurns + 1) % 4
|
|
2123
|
+
};
|
|
2124
|
+
}
|
|
2125
|
+
function or(e) {
|
|
2126
|
+
return {
|
|
2127
|
+
...e,
|
|
2128
|
+
quarterTurns: (e.quarterTurns + 3) % 4
|
|
2129
|
+
};
|
|
2130
|
+
}
|
|
2131
|
+
function sr(e, t) {
|
|
2132
|
+
let n = ur(t, -45, 45), r = Math.round(n * 10) / 10;
|
|
2133
|
+
return {
|
|
2134
|
+
...e,
|
|
2135
|
+
freeAngle: r
|
|
2136
|
+
};
|
|
2137
|
+
}
|
|
2138
|
+
function cr(e) {
|
|
2139
|
+
return e.quarterTurns === 0 && Math.abs(e.freeAngle) < 1e-6;
|
|
2140
|
+
}
|
|
2141
|
+
function lr(e) {
|
|
2142
|
+
return e.quarterTurns * 90 + e.freeAngle;
|
|
2143
|
+
}
|
|
2144
|
+
function ur(e, t, n) {
|
|
2145
|
+
return Math.max(t, Math.min(n, e));
|
|
2146
|
+
}
|
|
2147
|
+
//#endregion
|
|
2148
|
+
//#region src/plugins/rotate/bake.ts
|
|
2149
|
+
async function dr(n, r) {
|
|
2150
|
+
if (cr(n)) return r;
|
|
2151
|
+
let i = lr(n), a = i * Math.PI / 180, o = i - n.quarterTurns * 90, s = Math.abs(o) < 1e-6, c, l;
|
|
2152
|
+
if (s) n.quarterTurns === 1 || n.quarterTurns === 3 ? (c = r.height, l = r.width) : (c = r.width, l = r.height);
|
|
2153
|
+
else {
|
|
2154
|
+
let e = $n(r, a);
|
|
2155
|
+
c = Math.max(1, Math.round(e.width)), l = Math.max(1, Math.round(e.height));
|
|
2156
|
+
}
|
|
2157
|
+
let u = e(c, l), d = t(u);
|
|
2158
|
+
return d.imageSmoothingEnabled = !0, d.imageSmoothingQuality = "high", d.translate(c / 2, l / 2), d.rotate(a), d.drawImage(r.bitmap, -r.width / 2, -r.height / 2), {
|
|
2159
|
+
bitmap: u.canvas,
|
|
2160
|
+
width: c,
|
|
2161
|
+
height: l,
|
|
2162
|
+
mimeType: r.mimeType
|
|
2163
|
+
};
|
|
2164
|
+
}
|
|
2165
|
+
//#endregion
|
|
2166
|
+
//#region src/state/store.ts
|
|
2167
|
+
function fr(e) {
|
|
2168
|
+
let t = e, n = /* @__PURE__ */ new Set();
|
|
2169
|
+
function r(e) {
|
|
2170
|
+
for (let r of [...n]) try {
|
|
2171
|
+
r(t, e);
|
|
2172
|
+
} catch (e) {
|
|
2173
|
+
queueMicrotask(() => {
|
|
2174
|
+
throw e;
|
|
2175
|
+
});
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
return {
|
|
2179
|
+
get() {
|
|
2180
|
+
return t;
|
|
2181
|
+
},
|
|
2182
|
+
set(e) {
|
|
2183
|
+
let n = t;
|
|
2184
|
+
t = {
|
|
2185
|
+
...t,
|
|
2186
|
+
...e
|
|
2187
|
+
}, r(n);
|
|
2188
|
+
},
|
|
2189
|
+
update(e) {
|
|
2190
|
+
let n = t;
|
|
2191
|
+
t = {
|
|
2192
|
+
...t,
|
|
2193
|
+
...e(t)
|
|
2194
|
+
}, r(n);
|
|
2195
|
+
},
|
|
2196
|
+
subscribe(e) {
|
|
2197
|
+
return n.add(e), () => n.delete(e);
|
|
2198
|
+
}
|
|
2199
|
+
};
|
|
2200
|
+
}
|
|
2201
|
+
//#endregion
|
|
2202
|
+
export { pt as ALL_SELECTION_HANDLES, G as DEFAULT_FINETUNE_STATE, Qt as DEFAULT_FRAME_STATE, w as DEFAULT_OUTPUT_STATE, ze as DEFAULT_PALETTE_COLOR, bn as DEFAULT_REDACT_COLOR, xn as DEFAULT_REDACT_MODE, Be as DEFAULT_STROKE_WIDTH, me as ENCODABLE_MIMES, ne as EventBus, Lt as FILTER_PRESETS, At as FINETUNE_ADJUSTMENTS, Ot as FINETUNE_MAX, Dt as FINETUNE_MIN, kt as FINETUNE_STEP, Zt as FRAME_PRESETS, Xt as FRAME_PRESET_IDS, Le as FREEHAND_DEFAULT_STROKE, nr as FREE_ANGLE_MAX, tr as FREE_ANGLE_MIN, rr as FREE_ANGLE_STEP, Fe as HIGHLIGHT_DEFAULT_COLOR, Ie as HIGHLIGHT_DEFAULT_STROKE, ue as HISTORY_MAX_ENTRIES, de as History, l as IDENTITY_VIEWPORT_TRANSFORM, nt as KEYBOARD_PLACEABLE_KINDS, g as MAX_ZOOM, Ne as MIN_SAMPLE_DISTANCE, _ as MIN_ZOOM, gt as PICK_TOLERANCE, yn as REDACT_MODES, Z as RESIZE_MAX_DIMENSION, Vn as RESIZE_MIN_DIMENSION, at as SYSTEM_FONT_STACK, Re as TEXT_DEFAULT_FONT_SIZE, ee as ViewportController, wn as addRegion, qe as addShape, P as alignToOrigin, V as applyAspectRatio, Ut as applyClarity, Ht as applyFinetuneLutAndSaturation, K as applyFinetuneToImageData, Tt as applyPresetByIndex, A as assertNever, ot as bakeAnnotate, n as bakeCanvasToBlob, bt as bakeCrop, Gt as bakeFinetune, Yt as bakeFlip, rn as bakeFrame, mn as bakeRedact, Xn as bakeResize, dr as bakeRotate, M as boundingBoxOf, Wt as boxBlur3x3, Bt as buildFinetuneLut, a as canEncodeMime, T as clampQuality, b as clampRectInside, u as computeViewport, ve as copyJpegExif, e as createBakeCanvas, Ln as createCenteredRedactRegion, it as createCenteredShape, fr as createStore, Pe as decimatePoints, Ve as defaultStylePalette, Tn as deleteRedactRegion, Ye as deleteShape, Ee as deriveOutputName, lr as effectiveAngleDeg, Jn as effectivePercent, De as encodeSourceImage, N as estimateTextSize, xt as filterPresets, zt as findActivePreset, q as findFramePreset, Pn as findRedactRegion, Xe as findShape, Rt as finetuneStatesEqual, B as fitRectToBoundsWithRatio, pn as frameOutputSize, t as getBakeContext2D, F as hitTest, He as initialAnnotateState, wt as initialCropState, jt as initialFinetuneState, Kt as initialFlipState, $t as initialFrameState, Sn as initialRedactState, Hn as initialResizeState, ir as initialRotateState, Mt as isFinetuneNoOp, Jt as isFlipNoOp, en as isFrameNoOp, rt as isKeyboardPlaceableKind, W as isPresetVisible, Un as isResizeNoOp, cr as isRotateNoOp, $n as largestInscribedRect, o as loadImage, Cn as mintRegionId, Ue as mintShapeId, En as mirrorRedactRegions, $e as mirrorShape, Ze as normaliseRectExtent, In as normaliseRedactExtent, on as paintInsideFrame, hn as paintRedactRegion, j as paintShape, _t as pickShape, p as pointDisplayToImage, f as pointImageToDisplay, se as pointInRect, ae as rectBottom, oe as rectCenter, h as rectDisplayToImage, ht as rectFromHandleDrag, re as rectFromPoints, m as rectImageToDisplay, ie as rectRight, ce as rectsEqual, Bn as regionBoundingBox, X as replaceRedactRegion, Je as replaceShape, Ft as resetAllFinetune, Pt as resetFinetune, St as resizeRectFromHandle, Te as resolveOutputMime, Q as resolveOutputSize, Rn as revalidateRedactAgainstBounds, ar as rotateClockwise, or as rotateCounterClockwise, On as rotateRedactRegions, et as rotateShape, x as roundRect, Me as runUtilityChain, kn as selectRedactRegion, Ke as selectShape, Fn as selectedRedactRegionOf, mt as selectionHandlePositions, We as setActiveTool, Nt as setFinetune, nn as setFrameColor, tn as setFramePreset, sr as setFreeAngle, Gn as setHeightPx, qn as setLockAspect, he as setOutputMime, ge as setOutputQuality, Kn as setPercent, jn as setRedactCurrentColor, An as setRedactCurrentMode, Nn as setRedactRegionColor, Mn as setRedactRegionMode, _e as setStripMetadata, Ge as setStyle, Wn as setWidthPx, qt as toggleFlip, k as tracePath, tt as transformShapes, le as translateClampedRect, Dn as translateRedactRegions, Qe as translateShape };
|
|
2203
|
+
|
|
2204
|
+
//# sourceMappingURL=index.js.map
|