@magicpages/kalotyp-core 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -166,7 +166,7 @@ var g = 8, _ = .25, ee = class {
166
166
  isPinching;
167
167
  listeners;
168
168
  constructor(e = l) {
169
- this.current = te(e), this.isPinching = !1, this.listeners = /* @__PURE__ */ new Set();
169
+ this.current = ne(e), this.isPinching = !1, this.listeners = /* @__PURE__ */ new Set();
170
170
  }
171
171
  getTransform() {
172
172
  return this.current;
@@ -178,12 +178,12 @@ var g = 8, _ = .25, ee = class {
178
178
  };
179
179
  }
180
180
  setTransform(e) {
181
- let t = te(e);
182
- y(this.current, t) || (this.current = t, this.emit());
181
+ let t = ne(e);
182
+ re(this.current, t) || (this.current = t, this.emit());
183
183
  }
184
184
  zoomAt(e, t, n) {
185
185
  if (!Number.isFinite(e) || e <= 0) return this.current;
186
- let r = this.current.zoom, i = v(r * e, _, 8);
186
+ let r = this.current.zoom, i = te(r * e, _, 8);
187
187
  if (i === r) return this.current;
188
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
189
  return this.current = {
@@ -200,7 +200,7 @@ var g = 8, _ = .25, ee = class {
200
200
  }, this.emit());
201
201
  }
202
202
  resetToFit() {
203
- y(this.current, l) || (this.current = l, this.emit());
203
+ re(this.current, l) || (this.current = l, this.emit());
204
204
  }
205
205
  resetPan() {
206
206
  this.current.panX === 0 && this.current.panY === 0 || (this.current = {
@@ -231,22 +231,22 @@ var g = 8, _ = .25, ee = class {
231
231
  for (let t of this.listeners) t(e);
232
232
  }
233
233
  };
234
- function v(e, t, n) {
234
+ function te(e, t, n) {
235
235
  return e < t ? t : e > n ? n : e;
236
236
  }
237
- function te(e) {
237
+ function ne(e) {
238
238
  return {
239
- zoom: v(Number.isFinite(e.zoom) ? e.zoom : 1, _, 8),
239
+ zoom: te(Number.isFinite(e.zoom) ? e.zoom : 1, _, 8),
240
240
  panX: Number.isFinite(e.panX) ? e.panX : 0,
241
241
  panY: Number.isFinite(e.panY) ? e.panY : 0
242
242
  };
243
243
  }
244
- function y(e, t) {
244
+ function re(e, t) {
245
245
  return e.zoom === t.zoom && e.panX === t.panX && e.panY === t.panY;
246
246
  }
247
247
  //#endregion
248
248
  //#region src/events/event-bus.ts
249
- var ne = class {
249
+ var ie = class {
250
250
  listeners = /* @__PURE__ */ new Map();
251
251
  on(e, t) {
252
252
  let n = this.listeners.get(e);
@@ -273,7 +273,7 @@ var ne = class {
273
273
  };
274
274
  //#endregion
275
275
  //#region src/geometry/rect.ts
276
- function re(e, t) {
276
+ function ae(e, t) {
277
277
  return {
278
278
  x: Math.min(e.x, t.x),
279
279
  y: Math.min(e.y, t.y),
@@ -281,33 +281,33 @@ function re(e, t) {
281
281
  height: Math.abs(e.y - t.y)
282
282
  };
283
283
  }
284
- function ie(e) {
284
+ function oe(e) {
285
285
  return e.x + e.width;
286
286
  }
287
- function ae(e) {
287
+ function se(e) {
288
288
  return e.y + e.height;
289
289
  }
290
- function oe(e) {
290
+ function ce(e) {
291
291
  return {
292
292
  x: e.x + e.width / 2,
293
293
  y: e.y + e.height / 2
294
294
  };
295
295
  }
296
- function se(e, t) {
296
+ function le(e, t) {
297
297
  return e.x >= t.x && e.x <= t.x + t.width && e.y >= t.y && e.y <= t.y + t.height;
298
298
  }
299
- function ce(e, t) {
299
+ function ue(e, t) {
300
300
  return e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height;
301
301
  }
302
- function le(e, t, n, r) {
303
- return b({
302
+ function de(e, t, n, r) {
303
+ return v({
304
304
  x: e.x + t,
305
305
  y: e.y + n,
306
306
  width: e.width,
307
307
  height: e.height
308
308
  }, r);
309
309
  }
310
- function b(e, t) {
310
+ function v(e, t) {
311
311
  let { x: n, y: r, width: i, height: a } = e;
312
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
313
  x: n,
@@ -316,7 +316,7 @@ function b(e, t) {
316
316
  height: a
317
317
  };
318
318
  }
319
- function x(e) {
319
+ function y(e) {
320
320
  return {
321
321
  x: Math.round(e.x),
322
322
  y: Math.round(e.y),
@@ -326,15 +326,15 @@ function x(e) {
326
326
  }
327
327
  //#endregion
328
328
  //#region src/history/history.ts
329
- var ue = 50, de = class {
329
+ var fe = 50, pe = class {
330
330
  shadow;
331
331
  undoStack = [];
332
332
  redoStack = [];
333
333
  constructor(e) {
334
- this.shadow = S(e);
334
+ this.shadow = x(e);
335
335
  }
336
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);
337
+ me(e, this.shadow) || (this.undoStack.push(this.shadow), this.undoStack.length > 50 && this.undoStack.shift(), this.shadow = x(e), this.redoStack.length = 0);
338
338
  }
339
339
  canUndo() {
340
340
  return this.undoStack.length > 0;
@@ -344,16 +344,16 @@ var ue = 50, de = class {
344
344
  }
345
345
  undo(e) {
346
346
  let t = this.undoStack.pop();
347
- return t ? (this.redoStack.push(S(e)), this.shadow = t, {
347
+ return t ? (this.redoStack.push(x(e)), this.shadow = t, {
348
348
  snapshot: t,
349
- changed: pe(e, t)
349
+ changed: b(e, t)
350
350
  }) : null;
351
351
  }
352
352
  redo(e) {
353
353
  let t = this.redoStack.pop();
354
- return t ? (this.undoStack.push(S(e)), this.undoStack.length > 50 && this.undoStack.shift(), this.shadow = t, {
354
+ return t ? (this.undoStack.push(x(e)), this.undoStack.length > 50 && this.undoStack.shift(), this.shadow = t, {
355
355
  snapshot: t,
356
- changed: pe(e, t)
356
+ changed: b(e, t)
357
357
  }) : null;
358
358
  }
359
359
  size() {
@@ -363,23 +363,23 @@ var ue = 50, de = class {
363
363
  };
364
364
  }
365
365
  };
366
- function fe(e, t) {
366
+ function me(e, t) {
367
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;
368
+ for (let [n, r] of e) if (!t.has(n) || S(r) !== S(t.get(n))) return !1;
369
369
  return !0;
370
370
  }
371
- function pe(e, t) {
371
+ function b(e, t) {
372
372
  let n = /* @__PURE__ */ new Set();
373
- for (let [r, i] of t) C(i) !== C(e.get(r)) && n.add(r);
373
+ for (let [r, i] of t) S(i) !== S(e.get(r)) && n.add(r);
374
374
  for (let r of e.keys()) t.has(r) || n.add(r);
375
375
  return n;
376
376
  }
377
- function S(e) {
377
+ function x(e) {
378
378
  let t = /* @__PURE__ */ new Map();
379
379
  for (let [n, r] of e) t.set(n, structuredClone(r));
380
380
  return t;
381
381
  }
382
- function C(e) {
382
+ function S(e) {
383
383
  return JSON.stringify(e, (e, t) => {
384
384
  if (t && typeof t == "object" && !Array.isArray(t)) {
385
385
  let e = {};
@@ -391,33 +391,33 @@ function C(e) {
391
391
  }
392
392
  //#endregion
393
393
  //#region src/output/state.ts
394
- var w = {
394
+ var C = {
395
395
  mimeChoice: "auto",
396
396
  quality: .85,
397
397
  stripMetadata: !0
398
- }, me = [
398
+ }, he = [
399
399
  "image/png",
400
400
  "image/jpeg",
401
401
  "image/webp",
402
402
  "image/avif"
403
403
  ];
404
- function T(e) {
405
- return Number.isFinite(e) ? e < 0 ? 0 : e > 1 ? 1 : e : w.quality;
404
+ function w(e) {
405
+ return Number.isFinite(e) ? e < 0 ? 0 : e > 1 ? 1 : e : C.quality;
406
406
  }
407
- function he(e, t) {
407
+ function ge(e, t) {
408
408
  return e.mimeChoice === t ? e : {
409
409
  ...e,
410
410
  mimeChoice: t
411
411
  };
412
412
  }
413
- function ge(e, t) {
414
- let n = T(t);
413
+ function _e(e, t) {
414
+ let n = w(t);
415
415
  return e.quality === n ? e : {
416
416
  ...e,
417
417
  quality: n
418
418
  };
419
419
  }
420
- function _e(e, t) {
420
+ function ve(e, t) {
421
421
  return e.stripMetadata === t ? e : {
422
422
  ...e,
423
423
  stripMetadata: t
@@ -425,7 +425,7 @@ function _e(e, t) {
425
425
  }
426
426
  //#endregion
427
427
  //#region src/pipeline/exif.ts
428
- var E = [255, 216], D = [255, 225], O = [
428
+ var ye = [255, 216], T = [255, 225], be = [
429
429
  69,
430
430
  120,
431
431
  105,
@@ -433,18 +433,18 @@ var E = [255, 216], D = [255, 225], O = [
433
433
  0,
434
434
  0
435
435
  ];
436
- async function ve(e) {
436
+ async function xe(e) {
437
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);
438
+ let t = await Se(e.source);
439
+ if (!Ce(t, ye)) return e.output;
440
+ let n = we(t);
441
441
  if (!n) return e.output;
442
- let r = await ye(e.output);
443
- if (!be(r, E)) return e.output;
442
+ let r = await Se(e.output);
443
+ if (!Ce(r, ye)) return e.output;
444
444
  let i = new Uint8Array(r.length + n.length);
445
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
446
  }
447
- async function ye(e) {
447
+ async function Se(e) {
448
448
  return typeof e.arrayBuffer == "function" ? new Uint8Array(await e.arrayBuffer()) : new Promise((t, n) => {
449
449
  let r = new FileReader();
450
450
  r.onload = () => {
@@ -453,12 +453,12 @@ async function ye(e) {
453
453
  }, r.onerror = () => n(r.error ?? /* @__PURE__ */ Error("FileReader failed")), r.readAsArrayBuffer(e);
454
454
  });
455
455
  }
456
- function be(e, t) {
456
+ function Ce(e, t) {
457
457
  if (e.length < t.length) return !1;
458
458
  for (let n = 0; n < t.length; n++) if (e[n] !== t[n]) return !1;
459
459
  return !0;
460
460
  }
461
- function xe(e) {
461
+ function we(e) {
462
462
  let t = 2;
463
463
  for (; t + 4 <= e.length;) {
464
464
  if (e[t] !== 255) return;
@@ -468,34 +468,34 @@ function xe(e) {
468
468
  if (r < 2) return;
469
469
  let i = t + 2 + r;
470
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);
471
+ if (e[t] === T[0] && e[t + 1] === T[1] && Te(e, t + 4)) return e.slice(t, i);
472
472
  t = i;
473
473
  }
474
474
  }
475
- function Se(e, t) {
476
- for (let n = 0; n < O.length; n++) if (e[t + n] !== O[n]) return !1;
475
+ function Te(e, t) {
476
+ for (let n = 0; n < be.length; n++) if (e[t + n] !== be[n]) return !1;
477
477
  return !0;
478
478
  }
479
479
  //#endregion
480
480
  //#region src/pipeline/encode.ts
481
- var Ce = "image/png", we = new Set([
481
+ var Ee = "image/png", De = new Set([
482
482
  "image/png",
483
483
  "image/webp",
484
484
  "image/avif"
485
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;
486
+ async function Oe(e, t) {
487
+ return e.mimeChoice === "auto" ? await a("image/webp") ? "image/webp" : !De.has(t.mimeType) && await a("image/jpeg") ? "image/jpeg" : Ee : await a(e.mimeChoice) ? e.mimeChoice : await a("image/webp") ? "image/webp" : Ee;
488
488
  }
489
- function Ee(e, t) {
490
- let n = Oe(t);
489
+ function ke(e, t) {
490
+ let n = je(t);
491
491
  if (!e) return `kalotyp-image.${n}`;
492
- let r = ke(e);
492
+ let r = Me(e);
493
493
  if (!r) return `kalotyp-image.${n}`;
494
- let i = je(r);
494
+ let i = Pe(r);
495
495
  return i ? `${i}.${n}` : `kalotyp-image.${n}`;
496
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);
497
+ async function Ae(t, r = {}) {
498
+ let i = r.output ?? C, a = await Oe(i, t), o = w(i.quality), s = ke(r.sourceName, a), c = e(t.width, t.height);
499
499
  if (c.kind === "offscreen") {
500
500
  let e = c.canvas.getContext("2d");
501
501
  if (!e) throw Error("2D canvas context is not available");
@@ -505,13 +505,13 @@ async function De(t, r = {}) {
505
505
  if (!e) throw Error("2D canvas context is not available");
506
506
  e.drawImage(t.bitmap, 0, 0);
507
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({
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 xe({
509
509
  source: r.sourceBlob,
510
510
  output: l
511
511
  }) : l;
512
512
  return new File([u], s, { type: a });
513
513
  }
514
- function Oe(e) {
514
+ function je(e) {
515
515
  if (e === "image/jpeg") return "jpg";
516
516
  if (e === "image/png") return "png";
517
517
  if (e === "image/webp") return "webp";
@@ -519,29 +519,196 @@ function Oe(e) {
519
519
  let t = e.split("/")[1];
520
520
  return t && t.length > 0 ? t : "bin";
521
521
  }
522
- function ke(e) {
523
- let t = Ae(e).split(/[/\\]/);
522
+ function Me(e) {
523
+ let t = Ne(e).split(/[/\\]/);
524
524
  return t[t.length - 1];
525
525
  }
526
- function Ae(e) {
526
+ function Ne(e) {
527
527
  let t = e.indexOf("?");
528
528
  return t === -1 ? e : e.slice(0, t);
529
529
  }
530
- function je(e) {
530
+ function Pe(e) {
531
531
  let t = e.lastIndexOf(".");
532
532
  return t <= 0 ? e : e.slice(0, t);
533
533
  }
534
534
  //#endregion
535
535
  //#region src/pipeline/run-chain.ts
536
- async function Me(e, t) {
536
+ async function Fe(e, t) {
537
537
  let n = t;
538
538
  for (let t of e) n = await t.plugin.bake(t.state, n);
539
539
  return n;
540
540
  }
541
541
  //#endregion
542
+ //#region src/plugins/annotate/fonts.ts
543
+ var Ie = "-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif", Le = "\"Apple Color Emoji\", \"Segoe UI Emoji\", \"Noto Color Emoji\", \"Twemoji Mozilla\", \"Android Emoji\", sans-serif", E = [
544
+ {
545
+ key: "system",
546
+ label: "System",
547
+ stack: Ie,
548
+ bunnyName: null,
549
+ generic: "sans-serif"
550
+ },
551
+ {
552
+ key: "inter",
553
+ label: "Inter",
554
+ stack: "\"Inter\", sans-serif",
555
+ bunnyName: "inter",
556
+ generic: "sans-serif"
557
+ },
558
+ {
559
+ key: "roboto",
560
+ label: "Roboto",
561
+ stack: "\"Roboto\", sans-serif",
562
+ bunnyName: "roboto",
563
+ generic: "sans-serif"
564
+ },
565
+ {
566
+ key: "manrope",
567
+ label: "Manrope",
568
+ stack: "\"Manrope\", sans-serif",
569
+ bunnyName: "manrope",
570
+ generic: "sans-serif"
571
+ },
572
+ {
573
+ key: "poppins",
574
+ label: "Poppins",
575
+ stack: "\"Poppins\", sans-serif",
576
+ bunnyName: "poppins",
577
+ generic: "sans-serif"
578
+ },
579
+ {
580
+ key: "nunito",
581
+ label: "Nunito",
582
+ stack: "\"Nunito\", sans-serif",
583
+ bunnyName: "nunito",
584
+ generic: "sans-serif"
585
+ },
586
+ {
587
+ key: "fira-sans",
588
+ label: "Fira Sans",
589
+ stack: "\"Fira Sans\", sans-serif",
590
+ bunnyName: "fira-sans",
591
+ generic: "sans-serif"
592
+ },
593
+ {
594
+ key: "noto-sans",
595
+ label: "Noto Sans",
596
+ stack: "\"Noto Sans\", sans-serif",
597
+ bunnyName: "noto-sans",
598
+ generic: "sans-serif"
599
+ },
600
+ {
601
+ key: "tenor-sans",
602
+ label: "Tenor Sans",
603
+ stack: "\"Tenor Sans\", sans-serif",
604
+ bunnyName: "tenor-sans",
605
+ generic: "sans-serif"
606
+ },
607
+ {
608
+ key: "space-grotesk",
609
+ label: "Space Grotesk",
610
+ stack: "\"Space Grotesk\", sans-serif",
611
+ bunnyName: "space-grotesk",
612
+ generic: "sans-serif"
613
+ },
614
+ {
615
+ key: "chakra-petch",
616
+ label: "Chakra Petch",
617
+ stack: "\"Chakra Petch\", sans-serif",
618
+ bunnyName: "chakra-petch",
619
+ generic: "sans-serif"
620
+ },
621
+ {
622
+ key: "lora",
623
+ label: "Lora",
624
+ stack: "\"Lora\", serif",
625
+ bunnyName: "lora",
626
+ generic: "serif"
627
+ },
628
+ {
629
+ key: "merriweather",
630
+ label: "Merriweather",
631
+ stack: "\"Merriweather\", serif",
632
+ bunnyName: "merriweather",
633
+ generic: "serif"
634
+ },
635
+ {
636
+ key: "noto-serif",
637
+ label: "Noto Serif",
638
+ stack: "\"Noto Serif\", serif",
639
+ bunnyName: "noto-serif",
640
+ generic: "serif"
641
+ },
642
+ {
643
+ key: "ibm-plex-serif",
644
+ label: "IBM Plex Serif",
645
+ stack: "\"IBM Plex Serif\", serif",
646
+ bunnyName: "ibm-plex-serif",
647
+ generic: "serif"
648
+ },
649
+ {
650
+ key: "cardo",
651
+ label: "Cardo",
652
+ stack: "\"Cardo\", serif",
653
+ bunnyName: "cardo",
654
+ generic: "serif"
655
+ },
656
+ {
657
+ key: "old-standard-tt",
658
+ label: "Old Standard TT",
659
+ stack: "\"Old Standard TT\", serif",
660
+ bunnyName: "old-standard-tt",
661
+ generic: "serif"
662
+ },
663
+ {
664
+ key: "prata",
665
+ label: "Prata",
666
+ stack: "\"Prata\", serif",
667
+ bunnyName: "prata",
668
+ generic: "serif"
669
+ },
670
+ {
671
+ key: "rufina",
672
+ label: "Rufina",
673
+ stack: "\"Rufina\", serif",
674
+ bunnyName: "rufina",
675
+ generic: "serif"
676
+ },
677
+ {
678
+ key: "jetbrains-mono",
679
+ label: "JetBrains Mono",
680
+ stack: "\"JetBrains Mono\", monospace",
681
+ bunnyName: "jetbrains-mono",
682
+ generic: "monospace"
683
+ },
684
+ {
685
+ key: "fira-mono",
686
+ label: "Fira Mono",
687
+ stack: "\"Fira Mono\", monospace",
688
+ bunnyName: "fira-mono",
689
+ generic: "monospace"
690
+ },
691
+ {
692
+ key: "space-mono",
693
+ label: "Space Mono",
694
+ stack: "\"Space Mono\", monospace",
695
+ bunnyName: "space-mono",
696
+ generic: "monospace"
697
+ }
698
+ ], D = new Map(E.map((e) => [e.key, e]));
699
+ function O(e) {
700
+ return D.get(e)?.stack ?? "-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif";
701
+ }
702
+ function Re(e) {
703
+ return D.get(e) ?? E[0];
704
+ }
705
+ function k(e, t = 1) {
706
+ return `${e.fontStyle === "italic" ? "italic " : ""}${e.fontWeight === "bold" ? "bold " : ""}${e.fontSize * t}px ${O(e.fontFamily)}`;
707
+ }
708
+ //#endregion
542
709
  //#region src/plugins/annotate/smooth.ts
543
- var Ne = 2;
544
- function Pe(e) {
710
+ var ze = 2;
711
+ function Be(e) {
545
712
  if (e.length <= 1) return [...e];
546
713
  let t = e[0];
547
714
  if (!t) return [];
@@ -555,7 +722,7 @@ function Pe(e) {
555
722
  let i = e[e.length - 1];
556
723
  return i && i !== r && n.push(i), n;
557
724
  }
558
- function k(e, t) {
725
+ function A(e, t) {
559
726
  if (t.length === 0) return;
560
727
  let n = t[0];
561
728
  if (!n) return;
@@ -575,39 +742,59 @@ function k(e, t) {
575
742
  }
576
743
  //#endregion
577
744
  //#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() {
745
+ var Ve = "rgba(255, 235, 59, 0.35)", He = 18, Ue = 6, We = 32, Ge = "#ff3b30", Ke = 4, j = "system", qe = "😀", Je = 8;
746
+ function Ye(e) {
747
+ let t = Math.min(e.width, e.height);
748
+ return Math.max(64, Math.round(t * .2));
749
+ }
750
+ function M(e) {
751
+ return (e % 360 + 360) % 360;
752
+ }
753
+ function N() {
580
754
  return {
581
- color: ze,
755
+ color: Ge,
582
756
  strokeWidth: 4,
583
757
  fillColor: null,
584
- fontSize: 32
758
+ fontSize: 32,
759
+ fontFamily: j,
760
+ fontWeight: "normal",
761
+ fontStyle: "normal",
762
+ textAlign: "left",
763
+ emoji: qe
764
+ };
765
+ }
766
+ function P(e) {
767
+ return typeof e.fontFamily == "string" && (e.fontWeight === "normal" || e.fontWeight === "bold") && (e.fontStyle === "normal" || e.fontStyle === "italic") ? e : {
768
+ ...e,
769
+ fontFamily: typeof e.fontFamily == "string" ? e.fontFamily : j,
770
+ fontWeight: e.fontWeight === "bold" ? "bold" : "normal",
771
+ fontStyle: e.fontStyle === "italic" ? "italic" : "normal"
585
772
  };
586
773
  }
587
- function He(e) {
774
+ function Xe(e) {
588
775
  return {
589
776
  shapes: [],
590
777
  selectedId: null,
591
778
  activeTool: "select",
592
- currentStyle: Ve(),
779
+ currentStyle: N(),
593
780
  imageSize: e.imageSize,
594
781
  nextShapeNumber: 1
595
782
  };
596
783
  }
597
- function Ue(e) {
784
+ function Ze(e) {
598
785
  return {
599
786
  id: `s_${e.nextShapeNumber.toString(36)}`,
600
787
  nextShapeNumber: e.nextShapeNumber + 1
601
788
  };
602
789
  }
603
- function We(e, t) {
790
+ function Qe(e, t) {
604
791
  return e.activeTool === t ? e : {
605
792
  ...e,
606
793
  activeTool: t,
607
794
  selectedId: t === "select" ? e.selectedId : null
608
795
  };
609
796
  }
610
- function Ge(e, t) {
797
+ function $e(e, t) {
611
798
  return {
612
799
  ...e,
613
800
  currentStyle: {
@@ -616,27 +803,27 @@ function Ge(e, t) {
616
803
  }
617
804
  };
618
805
  }
619
- function Ke(e, t) {
806
+ function et(e, t) {
620
807
  return e.selectedId === t ? e : {
621
808
  ...e,
622
809
  selectedId: t
623
810
  };
624
811
  }
625
- function qe(e, t) {
812
+ function tt(e, t) {
626
813
  return {
627
814
  ...e,
628
815
  shapes: [...e.shapes, t],
629
816
  selectedId: t.id
630
817
  };
631
818
  }
632
- function Je(e, t) {
819
+ function nt(e, t) {
633
820
  let n = !1, r = e.shapes.map((e) => e.id === t.id ? (n = !0, t) : e);
634
821
  return n ? {
635
822
  ...e,
636
823
  shapes: r
637
824
  } : e;
638
825
  }
639
- function Ye(e, t) {
826
+ function rt(e, t) {
640
827
  let n = e.shapes.filter((e) => e.id !== t);
641
828
  return n.length === e.shapes.length ? e : {
642
829
  ...e,
@@ -644,10 +831,10 @@ function Ye(e, t) {
644
831
  selectedId: e.selectedId === t ? null : e.selectedId
645
832
  };
646
833
  }
647
- function Xe(e, t) {
834
+ function it(e, t) {
648
835
  if (t !== null) return e.shapes.find((e) => e.id === t);
649
836
  }
650
- function Ze(e) {
837
+ function at(e) {
651
838
  let { x: t, y: n, width: r, height: i } = e;
652
839
  return r < 0 && (t += r, r = -r), i < 0 && (n += i, i = -i), {
653
840
  x: t,
@@ -656,7 +843,7 @@ function Ze(e) {
656
843
  height: i
657
844
  };
658
845
  }
659
- function Qe(e, t, n) {
846
+ function ot(e, t, n) {
660
847
  switch (e.kind) {
661
848
  case "text": return {
662
849
  ...e,
@@ -664,7 +851,8 @@ function Qe(e, t, n) {
664
851
  y: e.y + n
665
852
  };
666
853
  case "rect":
667
- case "ellipse": return {
854
+ case "ellipse":
855
+ case "emoji": return {
668
856
  ...e,
669
857
  x: e.x + t,
670
858
  y: e.y + n
@@ -684,19 +872,24 @@ function Qe(e, t, n) {
684
872
  y: e.y + n
685
873
  }))
686
874
  };
687
- default: return A(e);
875
+ default: return F(e);
688
876
  }
689
877
  }
690
- function A(e) {
878
+ function F(e) {
691
879
  throw Error(`Unhandled annotation shape kind: ${JSON.stringify(e)}`);
692
880
  }
693
- function $e(e, t, n) {
881
+ function st(e, t, n) {
694
882
  if (t === "horizontal") switch (e.kind) {
695
883
  case "rect":
696
884
  case "ellipse": return {
697
885
  ...e,
698
886
  x: n.width - e.x - e.width
699
887
  };
888
+ case "emoji": return {
889
+ ...e,
890
+ x: n.width - e.x - e.size,
891
+ rotation: M(-e.rotation)
892
+ };
700
893
  case "text": return {
701
894
  ...e,
702
895
  x: n.width - e.x
@@ -714,7 +907,7 @@ function $e(e, t, n) {
714
907
  y: e.y
715
908
  }))
716
909
  };
717
- default: return A(e);
910
+ default: return F(e);
718
911
  }
719
912
  switch (e.kind) {
720
913
  case "rect":
@@ -722,6 +915,11 @@ function $e(e, t, n) {
722
915
  ...e,
723
916
  y: n.height - e.y - e.height
724
917
  };
918
+ case "emoji": return {
919
+ ...e,
920
+ y: n.height - e.y - e.size,
921
+ rotation: M(180 - e.rotation)
922
+ };
725
923
  case "text": return {
726
924
  ...e,
727
925
  y: n.height - e.y
@@ -739,10 +937,10 @@ function $e(e, t, n) {
739
937
  y: n.height - e.y
740
938
  }))
741
939
  };
742
- default: return A(e);
940
+ default: return F(e);
743
941
  }
744
942
  }
745
- function et(e, t, n) {
943
+ function ct(e, t, n) {
746
944
  if (t === 0) return e;
747
945
  let r = (e, r) => t === 1 ? {
748
946
  x: n.height - r,
@@ -766,6 +964,15 @@ function et(e, t, n) {
766
964
  height: o
767
965
  };
768
966
  }
967
+ case "emoji": {
968
+ let n = [r(e.x, e.y), r(e.x + e.size, e.y + e.size)], i = Math.min(n[0].x, n[1].x), a = Math.min(n[0].y, n[1].y);
969
+ return {
970
+ ...e,
971
+ x: i,
972
+ y: a,
973
+ rotation: M(e.rotation + t * 90)
974
+ };
975
+ }
769
976
  case "text": {
770
977
  let t = r(e.x, e.y);
771
978
  return {
@@ -789,25 +996,26 @@ function et(e, t, n) {
789
996
  ...e,
790
997
  points: e.points.map((e) => r(e.x, e.y))
791
998
  };
792
- default: return A(e);
999
+ default: return F(e);
793
1000
  }
794
1001
  }
795
- function tt(e, t) {
1002
+ function lt(e, t) {
796
1003
  return e.shapes.length === 0 ? e : {
797
1004
  ...e,
798
1005
  shapes: e.shapes.map(t)
799
1006
  };
800
1007
  }
801
- var nt = [
1008
+ var ut = [
802
1009
  "text",
803
1010
  "rect",
804
1011
  "ellipse",
805
- "arrow"
1012
+ "arrow",
1013
+ "emoji"
806
1014
  ];
807
- function rt(e) {
808
- return e === "text" || e === "rect" || e === "ellipse" || e === "arrow";
1015
+ function dt(e) {
1016
+ return e === "text" || e === "rect" || e === "ellipse" || e === "arrow" || e === "emoji";
809
1017
  }
810
- function it(e, t) {
1018
+ function ft(e, t) {
811
1019
  let { imageSize: n, style: r, id: i } = t, a = Math.min(n.width, n.height), o = n.width / 2, s = n.height / 2;
812
1020
  switch (e) {
813
1021
  case "rect":
@@ -856,66 +1064,132 @@ function it(e, t) {
856
1064
  text: "",
857
1065
  fontSize: r.fontSize,
858
1066
  color: r.color,
859
- textAlign: "center"
1067
+ textAlign: r.textAlign,
1068
+ fontFamily: r.fontFamily,
1069
+ fontWeight: r.fontWeight,
1070
+ fontStyle: r.fontStyle
860
1071
  };
1072
+ case "emoji": {
1073
+ let e = Ye(n);
1074
+ return {
1075
+ id: i,
1076
+ kind: "emoji",
1077
+ x: Math.round(o - e / 2),
1078
+ y: Math.round(s - e / 2),
1079
+ emoji: r.emoji,
1080
+ size: e,
1081
+ rotation: 0
1082
+ };
1083
+ }
1084
+ }
1085
+ }
1086
+ //#endregion
1087
+ //#region src/plugins/annotate/text-layout.ts
1088
+ var I = 1.2;
1089
+ function L(e) {
1090
+ return e.length === 0 ? [""] : e.split("\n");
1091
+ }
1092
+ function R(e, t) {
1093
+ let n = L(e.text), r = 0;
1094
+ for (let e of n) {
1095
+ let n = t(e);
1096
+ n > r && (r = n);
1097
+ }
1098
+ return r = Math.max(r, e.fontSize * .6), {
1099
+ lines: n,
1100
+ width: r,
1101
+ height: n.length * e.fontSize * I
1102
+ };
1103
+ }
1104
+ function z(e, t) {
1105
+ return e.length * t * .55;
1106
+ }
1107
+ function pt(e, t, n) {
1108
+ switch (n) {
1109
+ case "left": return 0;
1110
+ case "center": return (e - t) / 2;
1111
+ case "right": return e - t;
861
1112
  }
862
1113
  }
863
1114
  //#endregion
864
1115
  //#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) {
1116
+ var mt = 400;
1117
+ async function ht(e) {
1118
+ if (typeof document > "u" || !("fonts" in document)) return;
1119
+ let t = /* @__PURE__ */ new Set();
1120
+ for (let n of e) n.kind === "text" && t.add(k(P(n)));
1121
+ if (t.size === 0) return;
1122
+ let n = new Promise((e) => setTimeout(e, mt)), r = Promise.all([...t].map((e) => document.fonts.load(e))).then(() => document.fonts.ready).then(() => void 0).catch(() => void 0);
1123
+ await Promise.race([r, n]);
1124
+ }
1125
+ async function gt(n, r, i) {
867
1126
  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);
1127
+ await ht(n.shapes);
1128
+ let a = e(r.width, r.height), o = t(a);
1129
+ o.imageSmoothingEnabled = !0, o.imageSmoothingQuality = "high", o.drawImage(r.bitmap, 0, 0, r.width, r.height);
1130
+ for (let e of n.shapes) _t(o, e, i);
871
1131
  return {
872
- bitmap: i.canvas,
1132
+ bitmap: a.canvas,
873
1133
  width: r.width,
874
1134
  height: r.height,
875
1135
  mimeType: r.mimeType
876
1136
  };
877
1137
  }
878
- function j(e, t) {
1138
+ function _t(e, t, n) {
879
1139
  switch (t.kind) {
880
1140
  case "text":
881
- st(e, t);
1141
+ yt(e, t);
882
1142
  return;
883
1143
  case "rect":
884
- ct(e, t);
1144
+ bt(e, t);
885
1145
  return;
886
1146
  case "ellipse":
887
- lt(e, t);
1147
+ xt(e, t);
888
1148
  return;
889
1149
  case "arrow":
890
- ut(e, t);
1150
+ St(e, t);
891
1151
  return;
892
1152
  case "freehand":
893
- dt(e, t);
1153
+ Ct(e, t);
894
1154
  return;
895
1155
  case "highlight":
896
- ft(e, t);
1156
+ wt(e, t);
1157
+ return;
1158
+ case "emoji":
1159
+ vt(e, t, n?.resolveEmojiImage);
897
1160
  return;
898
- default: A(t);
1161
+ default: F(t);
1162
+ }
1163
+ }
1164
+ function vt(e, t, n) {
1165
+ let r = n?.(t.emoji) ?? null;
1166
+ if (e.save(), t.rotation) {
1167
+ let n = t.x + t.size / 2, r = t.y + t.size / 2;
1168
+ e.translate(n, r), e.rotate(t.rotation * Math.PI / 180), e.translate(-n, -r);
899
1169
  }
1170
+ r ? e.drawImage(r, t.x, t.y, t.size, t.size) : (e.textAlign = "left", e.textBaseline = "top", e.font = `${t.size}px ${Le}`, e.fillText(t.emoji, t.x, t.y)), e.restore();
900
1171
  }
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);
1172
+ function yt(e, t) {
1173
+ let n = P(t);
1174
+ e.save(), e.fillStyle = n.color, e.font = k(n), e.textAlign = "left", e.textBaseline = "top";
1175
+ let r = L(n.text), i = r.map((t) => e.measureText(t).width), a = i.reduce((e, t) => t > e ? t : e, 0), o = n.fontSize * I;
1176
+ for (let t = 0; t < r.length; t++) {
1177
+ let s = r[t];
1178
+ if (s === void 0) continue;
1179
+ let c = pt(a, i[t] ?? 0, n.textAlign);
1180
+ e.fillText(s, n.x + c, n.y + t * o);
907
1181
  }
908
1182
  e.restore();
909
1183
  }
910
- function ct(e, t) {
1184
+ function bt(e, t) {
911
1185
  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
1186
  }
913
- function lt(e, t) {
1187
+ function xt(e, t) {
914
1188
  e.save();
915
1189
  let n = t.width / 2, r = t.height / 2, i = t.x + n, a = t.y + r;
916
1190
  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
1191
  }
918
- function ut(e, t) {
1192
+ function St(e, t) {
919
1193
  let n = t.x2 - t.x1, r = t.y2 - t.y1, i = Math.sqrt(n * n + r * r);
920
1194
  if (i < .5) return;
921
1195
  e.save(), e.strokeStyle = t.color, e.fillStyle = t.color, e.lineWidth = t.strokeWidth, e.lineCap = "round", e.lineJoin = "round";
@@ -924,23 +1198,23 @@ function ut(e, t) {
924
1198
  let d = t.x2 - s * a, f = t.y2 - c * a, p = -c, m = s;
925
1199
  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
1200
  }
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());
1201
+ function Ct(e, t) {
1202
+ t.points.length !== 0 && (e.save(), e.strokeStyle = t.color, e.lineWidth = t.strokeWidth, e.lineCap = "round", e.lineJoin = "round", e.beginPath(), A(e, t.points), e.stroke(), e.restore());
929
1203
  }
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());
1204
+ function wt(e, t) {
1205
+ 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(), A(e, t.points), e.stroke(), e.restore());
932
1206
  }
933
1207
  //#endregion
934
1208
  //#region src/plugins/annotate/geometry.ts
935
- function M(e) {
1209
+ function B(e) {
936
1210
  switch (e.kind) {
937
1211
  case "text": {
938
- let { width: t, height: n } = N(e.text, e.fontSize);
1212
+ let t = P(e), { width: n, height: r } = R(t, (e) => z(e, t.fontSize));
939
1213
  return {
940
- x: P(e.x, t, e.textAlign),
941
- y: e.y,
942
- width: t,
943
- height: n
1214
+ x: t.x,
1215
+ y: t.y,
1216
+ width: n,
1217
+ height: r
944
1218
  };
945
1219
  }
946
1220
  case "rect":
@@ -950,6 +1224,12 @@ function M(e) {
950
1224
  width: e.width,
951
1225
  height: e.height
952
1226
  };
1227
+ case "emoji": return {
1228
+ x: e.x,
1229
+ y: e.y,
1230
+ width: e.size,
1231
+ height: e.size
1232
+ };
953
1233
  case "arrow": return {
954
1234
  x: Math.min(e.x1, e.x2),
955
1235
  y: Math.min(e.y1, e.y2),
@@ -974,10 +1254,10 @@ function M(e) {
974
1254
  height: a - r
975
1255
  };
976
1256
  }
977
- default: return A(e);
1257
+ default: return F(e);
978
1258
  }
979
1259
  }
980
- var pt = [
1260
+ var Tt = [
981
1261
  "tl",
982
1262
  "tr",
983
1263
  "bl",
@@ -987,7 +1267,7 @@ var pt = [
987
1267
  "b",
988
1268
  "l"
989
1269
  ];
990
- function mt(e) {
1270
+ function Et(e) {
991
1271
  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
1272
  return {
993
1273
  tl: {
@@ -1024,7 +1304,7 @@ function mt(e) {
1024
1304
  }
1025
1305
  };
1026
1306
  }
1027
- function ht(e, t, n) {
1307
+ function Dt(e, t, n) {
1028
1308
  let r = e.x, i = e.y, a = e.x + e.width, o = e.y + e.height;
1029
1309
  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
1310
  x: r,
@@ -1033,46 +1313,40 @@ function ht(e, t, n) {
1033
1313
  height: o - i
1034
1314
  };
1035
1315
  }
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
1316
  //#endregion
1052
1317
  //#region src/plugins/annotate/hit-test.ts
1053
- var gt = 4;
1054
- function _t(e, t) {
1318
+ var Ot = 4;
1319
+ function kt(e, t) {
1055
1320
  for (let n = e.length - 1; n >= 0; n--) {
1056
1321
  let r = e[n];
1057
- if (r && F(r, t)) return r;
1322
+ if (r && At(r, t)) return r;
1058
1323
  }
1059
1324
  }
1060
- function F(e, t) {
1325
+ function At(e, t) {
1061
1326
  switch (e.kind) {
1062
- case "text": return I(t, M(e));
1327
+ case "text": return V(t, B(e));
1328
+ case "emoji": {
1329
+ let n = B(e);
1330
+ if (!e.rotation) return V(t, n);
1331
+ let r = n.x + n.width / 2, i = n.y + n.height / 2, a = -e.rotation * Math.PI / 180, o = t.x - r, s = t.y - i;
1332
+ return V({
1333
+ x: r + o * Math.cos(a) - s * Math.sin(a),
1334
+ y: i + o * Math.sin(a) + s * Math.cos(a)
1335
+ }, n);
1336
+ }
1063
1337
  case "rect": {
1064
- let n = I(t, R(e));
1338
+ let n = V(t, U(e));
1065
1339
  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);
1340
+ let r = H(U(e), e.strokeWidth / 2 + 4), i = H(U(e), -(e.strokeWidth / 2 + 4));
1341
+ return V(t, r) && !V(t, i);
1068
1342
  }
1069
1343
  case "ellipse": {
1070
- let n = R(e), r = n.width / 2, i = n.height / 2, a = n.x + r, o = n.y + i;
1344
+ let n = U(e), r = n.width / 2, i = n.height / 2, a = n.x + r, o = n.y + i;
1071
1345
  if (r <= 0 || i <= 0) return !1;
1072
1346
  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
1347
  return e.fillColor === null ? l <= (1 + u) ** 2 && l >= (1 - u) ** 2 : l <= (1 + u) ** 2;
1074
1348
  }
1075
- case "arrow": return z(t, {
1349
+ case "arrow": return jt(t, {
1076
1350
  x: e.x1,
1077
1351
  y: e.y1
1078
1352
  }, {
@@ -1081,11 +1355,11 @@ function F(e, t) {
1081
1355
  }, e.strokeWidth / 2 + 4);
1082
1356
  case "freehand":
1083
1357
  case "highlight": {
1084
- if (!I(t, L(M(e), e.strokeWidth / 2 + 4))) return !1;
1358
+ if (!V(t, H(B(e), e.strokeWidth / 2 + 4))) return !1;
1085
1359
  let n = e.strokeWidth / 2 + 4;
1086
1360
  for (let r = 1; r < e.points.length; r++) {
1087
1361
  let i = e.points[r - 1], a = e.points[r];
1088
- if (i && a && z(t, i, a, n)) return !0;
1362
+ if (i && a && jt(t, i, a, n)) return !0;
1089
1363
  }
1090
1364
  if (e.points.length === 1) {
1091
1365
  let r = e.points[0];
@@ -1095,13 +1369,13 @@ function F(e, t) {
1095
1369
  }
1096
1370
  return !1;
1097
1371
  }
1098
- default: return A(e);
1372
+ default: return F(e);
1099
1373
  }
1100
1374
  }
1101
- function I(e, t) {
1375
+ function V(e, t) {
1102
1376
  return e.x >= t.x && e.y >= t.y && e.x <= t.x + t.width && e.y <= t.y + t.height;
1103
1377
  }
1104
- function L(e, t) {
1378
+ function H(e, t) {
1105
1379
  return {
1106
1380
  x: e.x - t,
1107
1381
  y: e.y - t,
@@ -1109,7 +1383,7 @@ function L(e, t) {
1109
1383
  height: e.height + t * 2
1110
1384
  };
1111
1385
  }
1112
- function R(e) {
1386
+ function U(e) {
1113
1387
  let { x: t, y: n, width: r, height: i } = e;
1114
1388
  return r < 0 && (t += r, r = -r), i < 0 && (n += i, i = -i), {
1115
1389
  x: t,
@@ -1118,7 +1392,7 @@ function R(e) {
1118
1392
  height: i
1119
1393
  };
1120
1394
  }
1121
- function z(e, t, n, r) {
1395
+ function jt(e, t, n, r) {
1122
1396
  let i = n.x - t.x, a = n.y - t.y, o = i * i + a * a;
1123
1397
  if (o === 0) {
1124
1398
  let n = e.x - t.x, i = e.y - t.y;
@@ -1131,7 +1405,7 @@ function z(e, t, n, r) {
1131
1405
  }
1132
1406
  //#endregion
1133
1407
  //#region src/plugins/crop/aspect-ratio.ts
1134
- function B(e, t) {
1408
+ function W(e, t) {
1135
1409
  if (t <= 0 || e.width <= 0 || e.height <= 0) return {
1136
1410
  x: e.x,
1137
1411
  y: e.y,
@@ -1146,16 +1420,16 @@ function B(e, t) {
1146
1420
  height: i
1147
1421
  };
1148
1422
  }
1149
- function V(e, t, n, r) {
1423
+ function Mt(e, t, n, r) {
1150
1424
  if (t <= 0) return e;
1151
- if (e.width <= 0 || e.height <= 0) return B(r, t);
1425
+ if (e.width <= 0 || e.height <= 0) return W(r, t);
1152
1426
  let i = e.width / e.height, a, o;
1153
1427
  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);
1428
+ let s = v(Pt(e, a, o, n), r), c = s.height === 0 ? 0 : s.width / s.height;
1429
+ return Math.abs(c - t) <= Nt ? s : Ft(s, t, n);
1156
1430
  }
1157
- var vt = 1e-6;
1158
- function H(e, t, n, r) {
1431
+ var Nt = 1e-6;
1432
+ function Pt(e, t, n, r) {
1159
1433
  switch (r) {
1160
1434
  case "tl": return {
1161
1435
  x: e.x,
@@ -1189,14 +1463,14 @@ function H(e, t, n, r) {
1189
1463
  };
1190
1464
  }
1191
1465
  }
1192
- function yt(e, t, n) {
1193
- let r = B(e, t);
1194
- return H(e, r.width, r.height, n);
1466
+ function Ft(e, t, n) {
1467
+ let r = W(e, t);
1468
+ return Pt(e, r.width, r.height, n);
1195
1469
  }
1196
1470
  //#endregion
1197
1471
  //#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);
1472
+ function It(t, n) {
1473
+ let r = y(n.rect), i = G(r.x, 0, t.width), a = G(r.y, 0, t.height), o = G(r.width, 1, t.width - i), s = G(r.height, 1, t.height - a), c = e(o, s);
1200
1474
  if (c.kind === "offscreen") {
1201
1475
  let e = c.canvas.getContext("2d");
1202
1476
  if (!e) throw Error("2D canvas context is not available");
@@ -1216,21 +1490,21 @@ function bt(t, n) {
1216
1490
  mimeType: t.mimeType
1217
1491
  };
1218
1492
  }
1219
- function U(e, t, n) {
1493
+ function G(e, t, n) {
1220
1494
  return Math.max(t, Math.min(n, e));
1221
1495
  }
1222
1496
  //#endregion
1223
1497
  //#region src/plugins/crop/preset-filter.ts
1224
- function W(e, t) {
1498
+ function Lt(e, t) {
1225
1499
  let [n] = e;
1226
1500
  return n === void 0 || t === void 0 ? !0 : t === "landscape" ? n >= 1 : t === "portrait" ? n < 1 : !0;
1227
1501
  }
1228
- function xt(e, t) {
1229
- return e.filter((e) => W(e, t));
1502
+ function Rt(e, t) {
1503
+ return e.filter((e) => Lt(e, t));
1230
1504
  }
1231
1505
  //#endregion
1232
1506
  //#region src/plugins/crop/resize.ts
1233
- function St(e, t, n, r) {
1507
+ function zt(e, t, n, r) {
1234
1508
  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
1509
  (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
1510
  let p = Math.min(l, d), m = Math.min(u, f), h = Math.abs(d - l), g = Math.abs(f - u);
@@ -1241,9 +1515,9 @@ function St(e, t, n, r) {
1241
1515
  width: h,
1242
1516
  height: g
1243
1517
  };
1244
- return _ = b(_, r.bounds), r.aspectRatio !== void 0 && r.aspectRatio > 0 && (_ = V(_, r.aspectRatio, Ct(t), r.bounds)), _;
1518
+ return _ = v(_, r.bounds), r.aspectRatio !== void 0 && r.aspectRatio > 0 && (_ = Mt(_, r.aspectRatio, Bt(t), r.bounds)), _;
1245
1519
  }
1246
- function Ct(e) {
1520
+ function Bt(e) {
1247
1521
  switch (e) {
1248
1522
  case "tl": return "br";
1249
1523
  case "tr": return "bl";
@@ -1257,7 +1531,7 @@ function Ct(e) {
1257
1531
  }
1258
1532
  //#endregion
1259
1533
  //#region src/plugins/crop/state.ts
1260
- function wt(e) {
1534
+ function Vt(e) {
1261
1535
  return {
1262
1536
  rect: {
1263
1537
  x: 0,
@@ -1266,12 +1540,12 @@ function wt(e) {
1266
1540
  height: e.imageSize.height
1267
1541
  },
1268
1542
  aspectRatio: void 0,
1269
- activePresetIndex: Et(e.presets),
1543
+ activePresetIndex: Ut(e.presets),
1270
1544
  presets: e.presets,
1271
1545
  imageSize: e.imageSize
1272
1546
  };
1273
1547
  }
1274
- function Tt(e, t) {
1548
+ function Ht(e, t) {
1275
1549
  let n = e.presets[t];
1276
1550
  if (!n) return e;
1277
1551
  let [r] = n;
@@ -1280,7 +1554,7 @@ function Tt(e, t) {
1280
1554
  aspectRatio: void 0,
1281
1555
  activePresetIndex: t
1282
1556
  };
1283
- let i = B({
1557
+ let i = W({
1284
1558
  x: 0,
1285
1559
  y: 0,
1286
1560
  width: e.imageSize.width,
@@ -1293,19 +1567,19 @@ function Tt(e, t) {
1293
1567
  activePresetIndex: t
1294
1568
  };
1295
1569
  }
1296
- function Et(e) {
1570
+ function Ut(e) {
1297
1571
  return e.findIndex(([e]) => e === void 0);
1298
1572
  }
1299
1573
  //#endregion
1300
1574
  //#region src/plugins/finetune/state.ts
1301
- var Dt = -100, Ot = 100, kt = 1, G = {
1575
+ var Wt = -100, Gt = 100, Kt = 1, K = {
1302
1576
  brightness: 0,
1303
1577
  contrast: 0,
1304
1578
  saturation: 0,
1305
1579
  exposure: 0,
1306
1580
  clarity: 0,
1307
1581
  gamma: 0
1308
- }, At = [
1582
+ }, qt = [
1309
1583
  {
1310
1584
  key: "brightness",
1311
1585
  label: "Brightness"
@@ -1331,38 +1605,38 @@ var Dt = -100, Ot = 100, kt = 1, G = {
1331
1605
  label: "Gamma"
1332
1606
  }
1333
1607
  ];
1334
- function jt() {
1335
- return G;
1608
+ function Jt() {
1609
+ return K;
1336
1610
  }
1337
- function Mt(e) {
1611
+ function Yt(e) {
1338
1612
  return e.brightness === 0 && e.contrast === 0 && e.saturation === 0 && e.exposure === 0 && e.clarity === 0 && e.gamma === 0;
1339
1613
  }
1340
- function Nt(e, t, n) {
1341
- let r = It(n);
1614
+ function Xt(e, t, n) {
1615
+ let r = $t(n);
1342
1616
  return e[t] === r ? e : {
1343
1617
  ...e,
1344
1618
  [t]: r
1345
1619
  };
1346
1620
  }
1347
- function Pt(e, t) {
1621
+ function Zt(e, t) {
1348
1622
  return e[t] === 0 ? e : {
1349
1623
  ...e,
1350
1624
  [t]: 0
1351
1625
  };
1352
1626
  }
1353
- function Ft() {
1354
- return G;
1627
+ function Qt() {
1628
+ return K;
1355
1629
  }
1356
- function It(e) {
1357
- return Number.isNaN(e) ? 0 : e <= -100 ? Dt : e >= 100 ? 100 : Math.round(e / 1) * 1;
1630
+ function $t(e) {
1631
+ return Number.isNaN(e) ? 0 : e <= -100 ? Wt : e >= 100 ? 100 : Math.round(e / 1) * 1;
1358
1632
  }
1359
1633
  //#endregion
1360
1634
  //#region src/plugins/filter/presets.ts
1361
- var Lt = [
1635
+ var en = [
1362
1636
  {
1363
1637
  id: "none",
1364
1638
  label: "None",
1365
- state: G
1639
+ state: K
1366
1640
  },
1367
1641
  {
1368
1642
  id: "vivid",
@@ -1437,26 +1711,26 @@ var Lt = [
1437
1711
  }
1438
1712
  }
1439
1713
  ];
1440
- function Rt(e, t) {
1714
+ function tn(e, t) {
1441
1715
  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
1716
  }
1443
- function zt(e) {
1444
- for (let t of Lt) if (Rt(t.state, e)) return t;
1717
+ function nn(e) {
1718
+ for (let t of en) if (tn(t.state, e)) return t;
1445
1719
  }
1446
1720
  //#endregion
1447
1721
  //#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);
1722
+ function rn(e) {
1723
+ let t = new Uint8ClampedArray(256), n = e.brightness / 200, r = 1 + e.contrast / 100, i = 1 + e.exposure / 200, a = an(e.gamma);
1450
1724
  for (let e = 0; e < 256; e++) {
1451
1725
  let o = e / 255;
1452
1726
  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
1727
  }
1454
1728
  return t;
1455
1729
  }
1456
- function Vt(e) {
1730
+ function an(e) {
1457
1731
  return e === 0 ? 1 : e > 0 ? 1 - e / 100 * .5 : 1 + 1 * (-e / 100);
1458
1732
  }
1459
- function Ht(e, t, n, r) {
1733
+ function on(e, t, n, r) {
1460
1734
  let i = e.length;
1461
1735
  if (t.length !== i) throw Error("applyFinetuneLutAndSaturation: src/dst length mismatch");
1462
1736
  let a = 1 + r.saturation / 100;
@@ -1469,7 +1743,7 @@ function Ht(e, t, n, r) {
1469
1743
  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
1744
  }
1471
1745
  }
1472
- function Ut(e, t, n) {
1746
+ function sn(e, t, n) {
1473
1747
  if (n === 0) return;
1474
1748
  let r = e.length;
1475
1749
  if (t.length !== r) throw Error("applyClarity: dst/blurred length mismatch");
@@ -1479,7 +1753,7 @@ function Ut(e, t, n) {
1479
1753
  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
1754
  }
1481
1755
  }
1482
- function Wt(e, t, n, r, i) {
1756
+ function cn(e, t, n, r, i) {
1483
1757
  if (e.length !== t.length || e.length !== n.length) throw Error("boxBlur3x3: buffer length mismatch");
1484
1758
  for (let n = 0; n < i; n++) for (let i = 0; i < r; i++) {
1485
1759
  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;
@@ -1493,25 +1767,25 @@ function Wt(e, t, n, r, i) {
1493
1767
  }
1494
1768
  }
1495
1769
  }
1496
- function K(e, t, n) {
1770
+ function q(e, t, n) {
1497
1771
  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) {
1772
+ let r = rn(e);
1773
+ if (on(t.data, n.data, r, e), e.clarity !== 0) {
1500
1774
  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);
1775
+ cn(t.data, r, i, t.width, t.height), sn(n.data, i, e.clarity);
1502
1776
  }
1503
1777
  }
1504
1778
  //#endregion
1505
1779
  //#region src/plugins/finetune/bake.ts
1506
- async function Gt(n, r) {
1507
- if (Mt(n)) return r;
1780
+ async function ln(n, r) {
1781
+ if (Yt(n)) return r;
1508
1782
  let i = e(r.width, r.height), a = t(i);
1509
1783
  a.imageSmoothingEnabled = !0, a.imageSmoothingQuality = "high", a.drawImage(r.bitmap, 0, 0, r.width, r.height);
1510
1784
  let o = a.getImageData(0, 0, r.width, r.height);
1511
- if (n.clarity === 0) K(n, o, o), a.putImageData(o, 0, 0);
1785
+ if (n.clarity === 0) q(n, o, o), a.putImageData(o, 0, 0);
1512
1786
  else {
1513
1787
  let e = new ImageData(new Uint8ClampedArray(o.data.length), o.width, o.height);
1514
- K(n, o, e), a.putImageData(e, 0, 0);
1788
+ q(n, o, e), a.putImageData(e, 0, 0);
1515
1789
  }
1516
1790
  return {
1517
1791
  bitmap: i.canvas,
@@ -1522,13 +1796,13 @@ async function Gt(n, r) {
1522
1796
  }
1523
1797
  //#endregion
1524
1798
  //#region src/plugins/flip/state.ts
1525
- function Kt() {
1799
+ function un() {
1526
1800
  return {
1527
1801
  horizontal: !1,
1528
1802
  vertical: !1
1529
1803
  };
1530
1804
  }
1531
- function qt(e, t) {
1805
+ function dn(e, t) {
1532
1806
  return t === "horizontal" ? {
1533
1807
  ...e,
1534
1808
  horizontal: !e.horizontal
@@ -1537,13 +1811,13 @@ function qt(e, t) {
1537
1811
  vertical: !e.vertical
1538
1812
  };
1539
1813
  }
1540
- function Jt(e) {
1814
+ function fn(e) {
1541
1815
  return !e.horizontal && !e.vertical;
1542
1816
  }
1543
1817
  //#endregion
1544
1818
  //#region src/plugins/flip/bake.ts
1545
- async function Yt(n, r) {
1546
- if (Jt(n)) return r;
1819
+ async function pn(n, r) {
1820
+ if (fn(n)) return r;
1547
1821
  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
1822
  return s.setTransform(c, 0, 0, l, u, d), s.drawImage(r.bitmap, 0, 0), {
1549
1823
  bitmap: o.canvas,
@@ -1554,14 +1828,14 @@ async function Yt(n, r) {
1554
1828
  }
1555
1829
  //#endregion
1556
1830
  //#region src/plugins/frame/state.ts
1557
- var Xt = [
1831
+ var mn = [
1558
1832
  "none",
1559
1833
  "solidSharp",
1560
1834
  "solidRound",
1561
1835
  "lineSingle",
1562
1836
  "hook",
1563
1837
  "polaroid"
1564
- ], Zt = [
1838
+ ], hn = [
1565
1839
  {
1566
1840
  id: "none",
1567
1841
  label: "None",
@@ -1598,19 +1872,19 @@ var Xt = [
1598
1872
  acceptsColor: !0,
1599
1873
  defaultColor: "#ffffff"
1600
1874
  }
1601
- ], Qt = {
1875
+ ], gn = {
1602
1876
  presetId: "none",
1603
1877
  color: "#000000"
1604
1878
  };
1605
- function $t() {
1606
- return Qt;
1879
+ function _n() {
1880
+ return gn;
1607
1881
  }
1608
- function en(e) {
1882
+ function vn(e) {
1609
1883
  return e.presetId === "none";
1610
1884
  }
1611
- function tn(e, t) {
1885
+ function yn(e, t) {
1612
1886
  if (e.presetId === t) return e;
1613
- let n = q(e.presetId), r = q(t);
1887
+ let n = J(e.presetId), r = J(t);
1614
1888
  return r ? {
1615
1889
  presetId: t,
1616
1890
  color: n !== void 0 && e.color === n.defaultColor ? r.defaultColor : e.color
@@ -1619,54 +1893,54 @@ function tn(e, t) {
1619
1893
  presetId: t
1620
1894
  };
1621
1895
  }
1622
- function nn(e, t) {
1896
+ function bn(e, t) {
1623
1897
  return e.color === t ? e : {
1624
1898
  ...e,
1625
1899
  color: t
1626
1900
  };
1627
1901
  }
1628
- function q(e) {
1629
- return Zt.find((t) => t.id === e);
1902
+ function J(e) {
1903
+ return hn.find((t) => t.id === e);
1630
1904
  }
1631
1905
  //#endregion
1632
1906
  //#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);
1907
+ async function xn(e, t) {
1908
+ return vn(e) ? t : e.presetId === "polaroid" ? On(e.color, t) : e.presetId === "none" ? t : Sn(e.presetId, e.color, t);
1635
1909
  }
1636
- function an(n, r, i) {
1910
+ function Sn(n, r, i) {
1637
1911
  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), {
1912
+ return o.drawImage(i.bitmap, 0, 0, i.width, i.height), Cn(o, n, r, i.width, i.height), {
1639
1913
  bitmap: a.canvas,
1640
1914
  width: i.width,
1641
1915
  height: i.height,
1642
1916
  mimeType: i.mimeType
1643
1917
  };
1644
1918
  }
1645
- function on(e, t, n, r, i) {
1919
+ function Cn(e, t, n, r, i) {
1646
1920
  switch (t) {
1647
1921
  case "solidSharp":
1648
- sn(e, n, r, i);
1922
+ wn(e, n, r, i);
1649
1923
  return;
1650
1924
  case "solidRound":
1651
- cn(e, n, r, i);
1925
+ Tn(e, n, r, i);
1652
1926
  return;
1653
1927
  case "lineSingle":
1654
- ln(e, n, r, i);
1928
+ En(e, n, r, i);
1655
1929
  return;
1656
1930
  case "hook":
1657
- un(e, n, r, i);
1931
+ Dn(e, n, r, i);
1658
1932
  return;
1659
1933
  }
1660
1934
  }
1661
- function sn(e, t, n, r) {
1662
- let i = fn(n, r);
1935
+ function wn(e, t, n, r) {
1936
+ let i = kn(n, r);
1663
1937
  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
1938
  }
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();
1939
+ function Tn(e, t, n, r) {
1940
+ let i = kn(n, r);
1941
+ wn(e, t, n, r), e.save(), e.globalCompositeOperation = "destination-out", e.fillStyle = "#000", Y(e, 0, 0, i, "tl"), Y(e, n, 0, i, "tr"), Y(e, 0, r, i, "bl"), Y(e, n, r, i, "br"), e.restore();
1668
1942
  }
1669
- function J(e, t, n, r, i) {
1943
+ function Y(e, t, n, r, i) {
1670
1944
  switch (e.beginPath(), e.moveTo(t, n), i) {
1671
1945
  case "tl":
1672
1946
  e.lineTo(t + r, n), e.arc(t + r, n + r, r, -Math.PI / 2, Math.PI, !0), e.lineTo(t, n);
@@ -1683,13 +1957,13 @@ function J(e, t, n, r, i) {
1683
1957
  }
1684
1958
  e.closePath(), e.fill();
1685
1959
  }
1686
- function ln(e, t, n, r) {
1960
+ function En(e, t, n, r) {
1687
1961
  let i = Math.round(Math.min(n, r) * .05), a = Math.max(2, Math.round(Math.min(n, r) * .01));
1688
1962
  e.save(), e.strokeStyle = t, e.lineWidth = a;
1689
1963
  let o = a / 2;
1690
1964
  e.strokeRect(i + o, i + o, n - 2 * i - a, r - 2 * i - a), e.restore();
1691
1965
  }
1692
- function un(e, t, n, r) {
1966
+ function Dn(e, t, n, r) {
1693
1967
  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
1968
  e.save(), e.strokeStyle = t, e.lineWidth = a, e.lineCap = "square";
1695
1969
  let s = a / 2, c = (t, n, r, a) => {
@@ -1697,7 +1971,7 @@ function un(e, t, n, r) {
1697
1971
  };
1698
1972
  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
1973
  }
1700
- function dn(n, r) {
1974
+ function On(n, r) {
1701
1975
  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
1976
  return f.fillStyle = n, f.fillRect(0, 0, l, u), f.drawImage(r.bitmap, o, a, r.width, r.height), {
1703
1977
  bitmap: d.canvas,
@@ -1706,10 +1980,10 @@ function dn(n, r) {
1706
1980
  mimeType: r.mimeType
1707
1981
  };
1708
1982
  }
1709
- function fn(e, t) {
1983
+ function kn(e, t) {
1710
1984
  return Math.max(4, Math.round(Math.min(e, t) * .04));
1711
1985
  }
1712
- function pn(e, t, n) {
1986
+ function An(e, t, n) {
1713
1987
  if (e !== "polaroid") return {
1714
1988
  width: t,
1715
1989
  height: n
@@ -1722,11 +1996,11 @@ function pn(e, t, n) {
1722
1996
  }
1723
1997
  //#endregion
1724
1998
  //#region src/plugins/redact/bake.ts
1725
- async function mn(n, r) {
1999
+ async function jn(n, r) {
1726
2000
  if (n.regions.length === 0) return r;
1727
2001
  let i = e(r.width, r.height), a = t(i);
1728
2002
  a.drawImage(r.bitmap, 0, 0, r.width, r.height);
1729
- for (let e of n.regions) hn(a, i.canvas, e, r);
2003
+ for (let e of n.regions) Mn(a, i.canvas, e, r);
1730
2004
  return {
1731
2005
  bitmap: i.canvas,
1732
2006
  width: r.width,
@@ -1734,47 +2008,47 @@ async function mn(n, r) {
1734
2008
  mimeType: r.mimeType
1735
2009
  };
1736
2010
  }
1737
- function hn(e, t, n, r) {
2011
+ function Mn(e, t, n, r) {
1738
2012
  let i = Math.round(n.width), a = Math.round(n.height);
1739
2013
  if (i < 1 || a < 1) return;
1740
2014
  let o = Math.round(n.x), s = Math.round(n.y);
1741
2015
  switch (n.mode) {
1742
2016
  case "solid":
1743
- gn(e, n, o, s, i, a);
2017
+ Nn(e, n, o, s, i, a);
1744
2018
  return;
1745
2019
  case "pixelate":
1746
- _n(e, t, r, o, s, i, a);
2020
+ Pn(e, t, r, o, s, i, a);
1747
2021
  return;
1748
2022
  case "blur":
1749
- vn(e, t, r, o, s, i, a);
2023
+ Fn(e, t, r, o, s, i, a);
1750
2024
  return;
1751
2025
  }
1752
2026
  }
1753
- function gn(e, t, n, r, i, a) {
2027
+ function Nn(e, t, n, r, i, a) {
1754
2028
  e.save(), e.fillStyle = t.color, e.fillRect(n, r, i, a), e.restore();
1755
2029
  }
1756
- function _n(e, t, n, r, i, a, o) {
2030
+ function Pn(e, t, n, r, i, a, o) {
1757
2031
  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
2032
  e.save();
1759
- let d = Y(l, u);
2033
+ let d = X(l, u);
1760
2034
  if (!d) {
1761
2035
  e.restore();
1762
2036
  return;
1763
2037
  }
1764
2038
  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
2039
  }
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);
2040
+ function Fn(e, t, n, r, i, a, o) {
2041
+ let s = 1 / 8, c = Math.max(1, Math.round(a * s)), l = Math.max(1, Math.round(o * s)), u = X(c, l);
1768
2042
  if (!u) return;
1769
2043
  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);
2044
+ let d = Math.max(1, Math.round(c * .5)), f = Math.max(1, Math.round(l * .5)), p = X(d, f);
1771
2045
  if (!p) {
1772
2046
  e.save(), e.imageSmoothingEnabled = !0, e.imageSmoothingQuality = "high", e.drawImage(u.canvas, 0, 0, c, l, r, i, a, o), e.restore();
1773
2047
  return;
1774
2048
  }
1775
2049
  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
2050
  }
1777
- function Y(e, t) {
2051
+ function X(e, t) {
1778
2052
  if (typeof OffscreenCanvas < "u") try {
1779
2053
  let n = new OffscreenCanvas(e, t), r = n.getContext("2d");
1780
2054
  if (r) return {
@@ -1793,42 +2067,42 @@ function Y(e, t) {
1793
2067
  }
1794
2068
  //#endregion
1795
2069
  //#region src/plugins/redact/state.ts
1796
- var yn = [
2070
+ var In = [
1797
2071
  "pixelate",
1798
2072
  "blur",
1799
2073
  "solid"
1800
- ], bn = "#000000", xn = "pixelate";
1801
- function Sn(e) {
2074
+ ], Ln = "#000000", Rn = "pixelate";
2075
+ function zn(e) {
1802
2076
  return {
1803
2077
  regions: [],
1804
2078
  nextRegionNumber: 1,
1805
2079
  selectedId: null,
1806
- currentMode: xn,
1807
- currentColor: bn,
2080
+ currentMode: Rn,
2081
+ currentColor: Ln,
1808
2082
  imageSize: e.imageSize
1809
2083
  };
1810
2084
  }
1811
- function Cn(e) {
2085
+ function Bn(e) {
1812
2086
  return {
1813
2087
  id: `r_${e.nextRegionNumber.toString(36)}`,
1814
2088
  nextRegionNumber: e.nextRegionNumber + 1
1815
2089
  };
1816
2090
  }
1817
- function wn(e, t) {
2091
+ function Vn(e, t) {
1818
2092
  return {
1819
2093
  ...e,
1820
2094
  regions: [...e.regions, t],
1821
2095
  selectedId: t.id
1822
2096
  };
1823
2097
  }
1824
- function X(e, t) {
2098
+ function Z(e, t) {
1825
2099
  let n = !1, r = e.regions.map((e) => e.id === t.id ? (n = !0, t) : e);
1826
2100
  return n ? {
1827
2101
  ...e,
1828
2102
  regions: r
1829
2103
  } : e;
1830
2104
  }
1831
- function Tn(e, t) {
2105
+ function Hn(e, t) {
1832
2106
  let n = e.regions.filter((e) => e.id !== t);
1833
2107
  return n.length === e.regions.length ? e : {
1834
2108
  ...e,
@@ -1836,7 +2110,7 @@ function Tn(e, t) {
1836
2110
  selectedId: e.selectedId === t ? null : e.selectedId
1837
2111
  };
1838
2112
  }
1839
- function En(e, t, n) {
2113
+ function Un(e, t, n) {
1840
2114
  if (e.regions.length === 0) return e;
1841
2115
  let r = e.regions.map((e) => t === "horizontal" ? {
1842
2116
  ...e,
@@ -1851,7 +2125,7 @@ function En(e, t, n) {
1851
2125
  imageSize: n
1852
2126
  };
1853
2127
  }
1854
- function Dn(e, t, n, r) {
2128
+ function Wn(e, t, n, r) {
1855
2129
  if (e.regions.length === 0) return {
1856
2130
  ...e,
1857
2131
  imageSize: r
@@ -1868,7 +2142,7 @@ function Dn(e, t, n, r) {
1868
2142
  imageSize: r
1869
2143
  };
1870
2144
  }
1871
- function On(e, t, n) {
2145
+ function Gn(e, t, n) {
1872
2146
  if (t === 0 || e.regions.length === 0) return {
1873
2147
  ...e,
1874
2148
  imageSize: n
@@ -1899,45 +2173,45 @@ function On(e, t, n) {
1899
2173
  imageSize: n
1900
2174
  };
1901
2175
  }
1902
- function kn(e, t) {
2176
+ function Kn(e, t) {
1903
2177
  return e.selectedId === t ? e : {
1904
2178
  ...e,
1905
2179
  selectedId: t
1906
2180
  };
1907
2181
  }
1908
- function An(e, t) {
2182
+ function qn(e, t) {
1909
2183
  return e.currentMode === t ? e : {
1910
2184
  ...e,
1911
2185
  currentMode: t
1912
2186
  };
1913
2187
  }
1914
- function jn(e, t) {
2188
+ function Jn(e, t) {
1915
2189
  return e.currentColor === t ? e : {
1916
2190
  ...e,
1917
2191
  currentColor: t
1918
2192
  };
1919
2193
  }
1920
- function Mn(e, t, n) {
2194
+ function Yn(e, t, n) {
1921
2195
  let r = e.regions.find((e) => e.id === t);
1922
- return !r || r.mode === n ? e : X(e, {
2196
+ return !r || r.mode === n ? e : Z(e, {
1923
2197
  ...r,
1924
2198
  mode: n
1925
2199
  });
1926
2200
  }
1927
- function Nn(e, t, n) {
2201
+ function Xn(e, t, n) {
1928
2202
  let r = e.regions.find((e) => e.id === t);
1929
- return !r || r.color === n ? e : X(e, {
2203
+ return !r || r.color === n ? e : Z(e, {
1930
2204
  ...r,
1931
2205
  color: n
1932
2206
  });
1933
2207
  }
1934
- function Pn(e, t) {
2208
+ function Zn(e, t) {
1935
2209
  if (t !== null) return e.regions.find((e) => e.id === t);
1936
2210
  }
1937
- function Fn(e) {
2211
+ function Qn(e) {
1938
2212
  return e.selectedId === null ? null : e.regions.find((t) => t.id === e.selectedId) ?? null;
1939
2213
  }
1940
- function In(e) {
2214
+ function $n(e) {
1941
2215
  let { x: t, y: n, width: r, height: i } = e;
1942
2216
  return r < 0 && (t += r, r = -r), i < 0 && (n += i, i = -i), {
1943
2217
  x: t,
@@ -1946,7 +2220,7 @@ function In(e) {
1946
2220
  height: i
1947
2221
  };
1948
2222
  }
1949
- function Ln(e) {
2223
+ function er(e) {
1950
2224
  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
2225
  return {
1952
2226
  id: i,
@@ -1958,10 +2232,10 @@ function Ln(e) {
1958
2232
  color: r
1959
2233
  };
1960
2234
  }
1961
- function Rn(e, t) {
2235
+ function tr(e, t) {
1962
2236
  if (e.imageSize.width === t.width && e.imageSize.height === t.height) return e;
1963
2237
  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));
2238
+ 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(nr(r, t));
1965
2239
  let r = e.selectedId !== null && !n.some((t) => t.id === e.selectedId);
1966
2240
  return {
1967
2241
  ...e,
@@ -1973,7 +2247,7 @@ function Rn(e, t) {
1973
2247
  selectedId: r ? null : e.selectedId
1974
2248
  };
1975
2249
  }
1976
- function zn(e, t) {
2250
+ function nr(e, t) {
1977
2251
  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
2252
  return {
1979
2253
  ...e,
@@ -1983,7 +2257,7 @@ function zn(e, t) {
1983
2257
  height: Math.max(0, a - r)
1984
2258
  };
1985
2259
  }
1986
- function Bn(e) {
2260
+ function rr(e) {
1987
2261
  return {
1988
2262
  x: e.x,
1989
2263
  y: e.y,
@@ -1993,24 +2267,24 @@ function Bn(e) {
1993
2267
  }
1994
2268
  //#endregion
1995
2269
  //#region src/plugins/resize/state.ts
1996
- var Z = 8e3, Vn = 1;
1997
- function Hn() {
2270
+ var Q = 8e3, ir = 1;
2271
+ function ar() {
1998
2272
  return {
1999
2273
  scaleX: 1,
2000
2274
  scaleY: 1,
2001
2275
  lockAspect: !0
2002
2276
  };
2003
2277
  }
2004
- function Un(e) {
2278
+ function or(e) {
2005
2279
  return Math.abs(e.scaleX - 1) < 1e-9 && Math.abs(e.scaleY - 1) < 1e-9;
2006
2280
  }
2007
- function Q(e, t) {
2281
+ function sr(e, t) {
2008
2282
  return {
2009
2283
  width: $(Math.round(t.width * e.scaleX)),
2010
2284
  height: $(Math.round(t.height * e.scaleY))
2011
2285
  };
2012
2286
  }
2013
- function Wn(e, t, n) {
2287
+ function cr(e, t, n) {
2014
2288
  if (n.width <= 0) return e;
2015
2289
  let r = $(Math.round(t)) / n.width, i = e.lockAspect ? r : e.scaleY;
2016
2290
  return {
@@ -2019,7 +2293,7 @@ function Wn(e, t, n) {
2019
2293
  scaleY: i
2020
2294
  };
2021
2295
  }
2022
- function Gn(e, t, n) {
2296
+ function lr(e, t, n) {
2023
2297
  if (n.height <= 0) return e;
2024
2298
  let r = $(Math.round(t)) / n.height, i = e.lockAspect ? r : e.scaleX;
2025
2299
  return {
@@ -2028,15 +2302,15 @@ function Gn(e, t, n) {
2028
2302
  scaleY: r
2029
2303
  };
2030
2304
  }
2031
- function Kn(e, t) {
2032
- let n = Yn(t / 100);
2305
+ function ur(e, t) {
2306
+ let n = pr(t / 100);
2033
2307
  return {
2034
2308
  ...e,
2035
2309
  scaleX: n,
2036
2310
  scaleY: n
2037
2311
  };
2038
2312
  }
2039
- function qn(e, t) {
2313
+ function dr(e, t) {
2040
2314
  if (e.lockAspect === t) return e;
2041
2315
  if (!t) return {
2042
2316
  ...e,
@@ -2049,36 +2323,36 @@ function qn(e, t) {
2049
2323
  lockAspect: !0
2050
2324
  };
2051
2325
  }
2052
- function Jn(e) {
2326
+ function fr(e) {
2053
2327
  let t = Math.max(e.scaleX, e.scaleY);
2054
2328
  return Math.round(t * 1e3) / 10;
2055
2329
  }
2056
2330
  function $(e) {
2057
- return Number.isFinite(e) ? Math.max(1, Math.min(Z, Math.trunc(e))) : 1;
2331
+ return Number.isFinite(e) ? Math.max(1, Math.min(Q, Math.trunc(e))) : 1;
2058
2332
  }
2059
- function Yn(e) {
2060
- return !Number.isFinite(e) || e <= 0 ? .01 : Math.max(.01, Math.min(e, Z));
2333
+ function pr(e) {
2334
+ return !Number.isFinite(e) || e <= 0 ? .01 : Math.max(.01, Math.min(e, Q));
2061
2335
  }
2062
2336
  //#endregion
2063
2337
  //#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);
2338
+ async function mr(e, t) {
2339
+ if (or(e)) return t;
2340
+ let { width: n, height: r } = sr(e, t);
2067
2341
  if (n <= 0 || r <= 0) return t;
2068
- let i = Zn(t.width, t.height, n, r), a = {
2342
+ let i = hr(t.width, t.height, n, r), a = {
2069
2343
  bitmap: t.bitmap,
2070
2344
  width: t.width,
2071
2345
  height: t.height
2072
2346
  }, o = [];
2073
2347
  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);
2348
+ let e = Math.max(n, Math.floor(a.width / 2)), t = Math.max(r, Math.floor(a.height / 2)), i = gr(a, e, t);
2075
2349
  o.push(i), a = {
2076
2350
  bitmap: i.canvas,
2077
2351
  width: e,
2078
2352
  height: t
2079
2353
  };
2080
2354
  }
2081
- let s = Qn(a, n, r);
2355
+ let s = gr(a, n, r);
2082
2356
  return o.length = 0, {
2083
2357
  bitmap: s.canvas,
2084
2358
  width: n,
@@ -2086,72 +2360,72 @@ async function Xn(e, t) {
2086
2360
  mimeType: t.mimeType
2087
2361
  };
2088
2362
  }
2089
- function Zn(e, t, n, r) {
2363
+ function hr(e, t, n, r) {
2090
2364
  let i = e, a = t, o = 0;
2091
2365
  for (; (i / 2 > n || a / 2 > r) && o < 16;) i = Math.floor(i / 2), a = Math.floor(a / 2), o += 1;
2092
2366
  return o;
2093
2367
  }
2094
- function Qn(n, r, i) {
2368
+ function gr(n, r, i) {
2095
2369
  let a = e(r, i), o = t(a);
2096
2370
  return o.imageSmoothingEnabled = !0, o.imageSmoothingQuality = "high", o.drawImage(n.bitmap, 0, 0, n.width, n.height, 0, 0, r, i), a;
2097
2371
  }
2098
2372
  //#endregion
2099
2373
  //#region src/plugins/rotate/inscribe.ts
2100
- function $n(e, t) {
2374
+ function _r(e, t) {
2101
2375
  let n = e.width, r = e.height;
2102
2376
  if (n <= 0 || r <= 0) return {
2103
2377
  width: 0,
2104
2378
  height: 0
2105
2379
  };
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);
2380
+ 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 > vr ? n * n / o : Infinity, l = s > vr ? n * r / s : Infinity, u = Math.min(c, l);
2107
2381
  return {
2108
2382
  width: u,
2109
2383
  height: u * r / n
2110
2384
  };
2111
2385
  }
2112
- var er = 1e-9, tr = -45, nr = 45, rr = .1;
2113
- function ir() {
2386
+ var vr = 1e-9, yr = -45, br = 45, xr = .1;
2387
+ function Sr() {
2114
2388
  return {
2115
2389
  quarterTurns: 0,
2116
2390
  freeAngle: 0
2117
2391
  };
2118
2392
  }
2119
- function ar(e) {
2393
+ function Cr(e) {
2120
2394
  return {
2121
2395
  ...e,
2122
2396
  quarterTurns: (e.quarterTurns + 1) % 4
2123
2397
  };
2124
2398
  }
2125
- function or(e) {
2399
+ function wr(e) {
2126
2400
  return {
2127
2401
  ...e,
2128
2402
  quarterTurns: (e.quarterTurns + 3) % 4
2129
2403
  };
2130
2404
  }
2131
- function sr(e, t) {
2132
- let n = ur(t, -45, 45), r = Math.round(n * 10) / 10;
2405
+ function Tr(e, t) {
2406
+ let n = Or(t, -45, 45), r = Math.round(n * 10) / 10;
2133
2407
  return {
2134
2408
  ...e,
2135
2409
  freeAngle: r
2136
2410
  };
2137
2411
  }
2138
- function cr(e) {
2412
+ function Er(e) {
2139
2413
  return e.quarterTurns === 0 && Math.abs(e.freeAngle) < 1e-6;
2140
2414
  }
2141
- function lr(e) {
2415
+ function Dr(e) {
2142
2416
  return e.quarterTurns * 90 + e.freeAngle;
2143
2417
  }
2144
- function ur(e, t, n) {
2418
+ function Or(e, t, n) {
2145
2419
  return Math.max(t, Math.min(n, e));
2146
2420
  }
2147
2421
  //#endregion
2148
2422
  //#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;
2423
+ async function kr(n, r) {
2424
+ if (Er(n)) return r;
2425
+ let i = Dr(n), a = i * Math.PI / 180, o = i - n.quarterTurns * 90, s = Math.abs(o) < 1e-6, c, l;
2152
2426
  if (s) n.quarterTurns === 1 || n.quarterTurns === 3 ? (c = r.height, l = r.width) : (c = r.width, l = r.height);
2153
2427
  else {
2154
- let e = $n(r, a);
2428
+ let e = _r(r, a);
2155
2429
  c = Math.max(1, Math.round(e.width)), l = Math.max(1, Math.round(e.height));
2156
2430
  }
2157
2431
  let u = e(c, l), d = t(u);
@@ -2164,7 +2438,7 @@ async function dr(n, r) {
2164
2438
  }
2165
2439
  //#endregion
2166
2440
  //#region src/state/store.ts
2167
- function fr(e) {
2441
+ function Ar(e) {
2168
2442
  let t = e, n = /* @__PURE__ */ new Set();
2169
2443
  function r(e) {
2170
2444
  for (let r of [...n]) try {
@@ -2199,6 +2473,6 @@ function fr(e) {
2199
2473
  };
2200
2474
  }
2201
2475
  //#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 };
2476
+ export { Tt as ALL_SELECTION_HANDLES, qe as DEFAULT_EMOJI, K as DEFAULT_FINETUNE_STATE, j as DEFAULT_FONT_KEY, gn as DEFAULT_FRAME_STATE, C as DEFAULT_OUTPUT_STATE, Ge as DEFAULT_PALETTE_COLOR, Ln as DEFAULT_REDACT_COLOR, Rn as DEFAULT_REDACT_MODE, Ke as DEFAULT_STROKE_WIDTH, Le as EMOJI_FONT_STACK, Je as EMOJI_MIN_SIZE, he as ENCODABLE_MIMES, ie as EventBus, en as FILTER_PRESETS, qt as FINETUNE_ADJUSTMENTS, Gt as FINETUNE_MAX, Wt as FINETUNE_MIN, Kt as FINETUNE_STEP, hn as FRAME_PRESETS, mn as FRAME_PRESET_IDS, Ue as FREEHAND_DEFAULT_STROKE, br as FREE_ANGLE_MAX, yr as FREE_ANGLE_MIN, xr as FREE_ANGLE_STEP, Ve as HIGHLIGHT_DEFAULT_COLOR, He as HIGHLIGHT_DEFAULT_STROKE, fe as HISTORY_MAX_ENTRIES, pe as History, l as IDENTITY_VIEWPORT_TRANSFORM, ut as KEYBOARD_PLACEABLE_KINDS, g as MAX_ZOOM, ze as MIN_SAMPLE_DISTANCE, _ as MIN_ZOOM, Ot as PICK_TOLERANCE, In as REDACT_MODES, Q as RESIZE_MAX_DIMENSION, ir as RESIZE_MIN_DIMENSION, Ie as SYSTEM_FONT_STACK, We as TEXT_DEFAULT_FONT_SIZE, E as TEXT_FONTS, I as TEXT_LINE_HEIGHT, ee as ViewportController, Vn as addRegion, tt as addShape, Mt as applyAspectRatio, sn as applyClarity, on as applyFinetuneLutAndSaturation, q as applyFinetuneToImageData, Ht as applyPresetByIndex, F as assertNever, gt as bakeAnnotate, n as bakeCanvasToBlob, It as bakeCrop, ln as bakeFinetune, pn as bakeFlip, xn as bakeFrame, jn as bakeRedact, mr as bakeResize, kr as bakeRotate, B as boundingBoxOf, cn as boxBlur3x3, rn as buildFinetuneLut, a as canEncodeMime, w as clampQuality, v as clampRectInside, u as computeViewport, xe as copyJpegExif, e as createBakeCanvas, er as createCenteredRedactRegion, ft as createCenteredShape, Ar as createStore, k as cssFontString, Be as decimatePoints, Ye as defaultEmojiSize, N as defaultStylePalette, Hn as deleteRedactRegion, rt as deleteShape, ke as deriveOutputName, Dr as effectiveAngleDeg, fr as effectivePercent, Ae as encodeSourceImage, z as estimateLineWidth, Rt as filterPresets, nn as findActivePreset, J as findFramePreset, Zn as findRedactRegion, it as findShape, tn as finetuneStatesEqual, W as fitRectToBoundsWithRatio, Re as fontDefFor, O as fontStackFor, An as frameOutputSize, t as getBakeContext2D, At as hitTest, Xe as initialAnnotateState, Vt as initialCropState, Jt as initialFinetuneState, un as initialFlipState, _n as initialFrameState, zn as initialRedactState, ar as initialResizeState, Sr as initialRotateState, Yt as isFinetuneNoOp, fn as isFlipNoOp, vn as isFrameNoOp, dt as isKeyboardPlaceableKind, Lt as isPresetVisible, or as isResizeNoOp, Er as isRotateNoOp, _r as largestInscribedRect, R as layoutTextLines, pt as lineOffset, o as loadImage, Bn as mintRegionId, Ze as mintShapeId, Un as mirrorRedactRegions, st as mirrorShape, at as normaliseRectExtent, $n as normaliseRedactExtent, M as normalizeAngle, P as normalizeTextShape, Cn as paintInsideFrame, Mn as paintRedactRegion, _t as paintShape, kt as pickShape, p as pointDisplayToImage, f as pointImageToDisplay, le as pointInRect, se as rectBottom, ce as rectCenter, h as rectDisplayToImage, Dt as rectFromHandleDrag, ae as rectFromPoints, m as rectImageToDisplay, oe as rectRight, ue as rectsEqual, rr as regionBoundingBox, Z as replaceRedactRegion, nt as replaceShape, Qt as resetAllFinetune, Zt as resetFinetune, zt as resizeRectFromHandle, Oe as resolveOutputMime, sr as resolveOutputSize, tr as revalidateRedactAgainstBounds, Cr as rotateClockwise, wr as rotateCounterClockwise, Gn as rotateRedactRegions, ct as rotateShape, y as roundRect, Fe as runUtilityChain, Kn as selectRedactRegion, et as selectShape, Qn as selectedRedactRegionOf, Et as selectionHandlePositions, Qe as setActiveTool, Xt as setFinetune, bn as setFrameColor, yn as setFramePreset, Tr as setFreeAngle, lr as setHeightPx, dr as setLockAspect, ge as setOutputMime, _e as setOutputQuality, ur as setPercent, Jn as setRedactCurrentColor, qn as setRedactCurrentMode, Xn as setRedactRegionColor, Yn as setRedactRegionMode, ve as setStripMetadata, $e as setStyle, cr as setWidthPx, L as textLines, dn as toggleFlip, A as tracePath, lt as transformShapes, de as translateClampedRect, Wn as translateRedactRegions, ot as translateShape };
2203
2477
 
2204
2478
  //# sourceMappingURL=index.js.map