@ingcreators/annot-core 0.2.1 → 0.3.1

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
@@ -1,9 +1,12 @@
1
+ import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "./element-tree-Bp-_IB-7.js";
2
+ import { buildPngChunk as u, concat as d, readU32be as f, startsWith as p } from "./xmp-bytes.js";
3
+ import { deflate as m, inflate as h } from "pako";
1
4
  //#region src/editor/font-registry.ts
2
- var e = [
5
+ var g = [
3
6
  "Annot Sans",
4
7
  "Annot Serif",
5
8
  "Annot Mono"
6
- ], t = {
9
+ ], _ = {
7
10
  "Annot Sans": [
8
11
  "-apple-system",
9
12
  "BlinkMacSystemFont",
@@ -43,7 +46,7 @@ var e = [
43
46
  "\"Noto Sans Mono CJK JP\"",
44
47
  "monospace"
45
48
  ].join(", ")
46
- }, n = {
49
+ }, v = {
47
50
  "Annot Sans": {
48
51
  latin: "Calibri",
49
52
  ea: "Yu Gothic UI",
@@ -60,22 +63,22 @@ var e = [
60
63
  cs: "Courier New"
61
64
  }
62
65
  };
63
- function r(e) {
64
- return t[e];
66
+ function y(e) {
67
+ return _[e];
65
68
  }
66
- function i(e) {
67
- return n[e];
69
+ function b(e) {
70
+ return v[e];
68
71
  }
69
- function a(t) {
70
- return t == null ? !1 : e.includes(t);
72
+ function x(e) {
73
+ return e == null ? !1 : g.includes(e);
71
74
  }
72
- function o(e) {
73
- return a(e) ? e : "Annot Sans";
75
+ function S(e) {
76
+ return x(e) ? e : "Annot Sans";
74
77
  }
75
78
  //#endregion
76
79
  //#region src/editor/history-core.ts
77
- var s = 100;
78
- function c(e) {
80
+ var C = 100;
81
+ function ee(e) {
79
82
  let t = [], n = [], r = e.maxDepth ?? 100, i = () => {
80
83
  e.onStateChange?.();
81
84
  }, a = {
@@ -103,19 +106,19 @@ function c(e) {
103
106
  }
104
107
  //#endregion
105
108
  //#region src/editor/toolbar-icons.ts
106
- var l = {
109
+ var w = {
107
110
  rect: "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linejoin=\"miter\" aria-hidden=\"true\"><rect x=\"4\" y=\"4\" width=\"16\" height=\"16\"/></svg>",
108
111
  rounded: "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><rect x=\"4\" y=\"4\" width=\"16\" height=\"16\" rx=\"5\"/></svg>",
109
112
  ellipse: "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><ellipse cx=\"12\" cy=\"12\" rx=\"8\" ry=\"8\"/></svg>"
110
- }, u = {
113
+ }, T = {
111
114
  none: "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M4 12 H20\"/></svg>",
112
115
  end: "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M4 12 H20\"/><path d=\"M16 8 L20 12 L16 16\"/></svg>",
113
116
  both: "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M4 12 H20\"/><path d=\"M16 8 L20 12 L16 16\"/><path d=\"M8 8 L4 12 L8 16\"/></svg>"
114
- }, d = {
117
+ }, E = {
115
118
  circle: "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><ellipse cx=\"12\" cy=\"12\" rx=\"8\" ry=\"8\"/><text x=\"12\" y=\"17\" text-anchor=\"middle\" font-size=\"14\" font-weight=\"800\" font-family=\"system-ui, sans-serif\" fill=\"currentColor\" stroke=\"none\">1</text></svg>",
116
119
  rect: "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linejoin=\"miter\" aria-hidden=\"true\"><rect x=\"4\" y=\"4\" width=\"16\" height=\"16\"/><text x=\"12\" y=\"17\" text-anchor=\"middle\" font-size=\"14\" font-weight=\"800\" font-family=\"system-ui, sans-serif\" fill=\"currentColor\" stroke=\"none\">1</text></svg>",
117
120
  rounded: "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><rect x=\"4\" y=\"4\" width=\"16\" height=\"16\" rx=\"5\"/><text x=\"12\" y=\"17\" text-anchor=\"middle\" font-size=\"14\" font-weight=\"800\" font-family=\"system-ui, sans-serif\" fill=\"currentColor\" stroke=\"none\">1</text></svg>"
118
- }, f = [
121
+ }, D = [
119
122
  {
120
123
  value: "#ffe100",
121
124
  label: "Yellow"
@@ -140,7 +143,7 @@ var l = {
140
143
  value: "#c991ff",
141
144
  label: "Purple"
142
145
  }
143
- ], p = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\" width=\"1em\" height=\"1em\" fill=\"currentColor\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.42 7.42 0 0 1 2-.27c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8Z\"/></svg>", m = {
146
+ ], te = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\" width=\"1em\" height=\"1em\" fill=\"currentColor\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.42 7.42 0 0 1 2-.27c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8Z\"/></svg>", O = {
144
147
  add: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 -960 960 960\" width=\"1em\" height=\"1em\" fill=\"currentColor\" aria-hidden=\"true\"><path d=\"M450-450H200v-60h250v-250h60v250h250v60H510v250h-60v-250Z\"/></svg>",
145
148
  add_to_drive: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 -960 960 960\" width=\"1em\" height=\"1em\" fill=\"currentColor\" aria-hidden=\"true\"><path d=\"M210-100q-12 0-25.5-7.5T165-126L55-318q-6-11-6-26t6-26l270-464q6-11 19.5-18.5T370-860h220q12 0 25.5 7.5T635-834l187 321q-18-5-36.5-7t-37.5-1L585-800H375L109-344l105 184h338q10 17 22.5 32t26.5 28H210Zm80-180-29-51 183-319h72l101 176q-13 9-23.5 20T573-431l-93-161-145 252h193q-4 14-6 29t-2 31H290Zm440 150v-120H610v-60h120v-120h60v120h120v60H790v120h-60Z\"/></svg>",
146
149
  align_horizontal_center: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 -960 960 960\" width=\"1em\" height=\"1em\" fill=\"currentColor\" aria-hidden=\"true\"><path d=\"M450-80v-210H240v-100h210v-180H120v-100h330v-210h60v210h330v100H510v180h210v100H510v210h-60Z\"/></svg>",
@@ -243,27 +246,27 @@ var l = {
243
246
  view_module: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 -960 960 960\" width=\"1em\" height=\"1em\" fill=\"currentColor\" aria-hidden=\"true\"><path d=\"M621-510h159v-190H621v190Zm-221 0h161v-190H400v190Zm-219 0h159v-190H181v190Zm0 250h159v-190H181v190Zm219 0h161v-190H400v190Zm221 0h159v-190H621v190Zm-500 0v-440q0-24.75 17.63-42.38Q156.25-760 181-760h599q24.75 0 42.38 17.62Q840-724.75 840-700v440q0 24.75-17.62 42.37Q804.75-200 780-200H181q-24.75 0-42.37-17.63Q121-235.25 121-260Z\"/></svg>",
244
247
  visibility_off: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 -960 960 960\" width=\"1em\" height=\"1em\" fill=\"currentColor\" aria-hidden=\"true\"><path d=\"m629-419-44-44q26-71-27-118t-115-24l-44-44q17-11 38-16t43-5q71 0 120.5 49.5T650-500q0 22-5.5 43.5T629-419Zm129 129-40-40q49-36 85.5-80.5T857-500q-50-111-150-175.5T490-740q-42 0-86 8t-69 19l-46-47q35-16 89.5-28T485-800q143 0 261.5 81.5T920-500q-26 64-67 117t-95 93Zm58 226L648-229q-35 14-79 21.5t-89 7.5q-146 0-265-81.5T40-500q20-52 55.5-101.5T182-696L56-822l42-43 757 757-39 44ZM223-654q-37 27-71.5 71T102-500q51 111 153.5 175.5T488-260q33 0 65-4t48-12l-64-64q-11 5-27 7.5t-30 2.5q-70 0-120-49t-50-121q0-15 2.5-30t7.5-27l-97-97Zm305 142Zm-116 58Z\"/></svg>",
245
248
  warning: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 -960 960 960\" width=\"1em\" height=\"1em\" fill=\"currentColor\" aria-hidden=\"true\"><path d=\"m40-120 440-760 440 760H40Zm104-60h672L480-760 144-180Zm361.5-65.68q8.5-8.67 8.5-21.5 0-12.82-8.68-21.32-8.67-8.5-21.5-8.5-12.82 0-21.32 8.68-8.5 8.67-8.5 21.5 0 12.82 8.68 21.32 8.67 8.5 21.5 8.5 12.82 0 21.32-8.68ZM454-348h60v-224h-60v224Zm26-122Z\"/></svg>"
246
- }, h = {
247
- "shape.rect": l.rect,
248
- "shape.rounded": l.rounded,
249
- "shape.ellipse": l.ellipse,
250
- "arrow.none": u.none,
251
- "arrow.end": u.end,
252
- "arrow.both": u.both,
253
- "counter.circle": d.circle,
254
- "counter.rect": d.rect,
255
- "counter.rounded": d.rounded,
256
- "brand.github": p
257
- }, g = {
258
- ...m,
259
- ...h
260
- }, _ = Object.keys(g);
261
- function v(e) {
262
- return g[e];
249
+ }, ne = {
250
+ "shape.rect": w.rect,
251
+ "shape.rounded": w.rounded,
252
+ "shape.ellipse": w.ellipse,
253
+ "arrow.none": T.none,
254
+ "arrow.end": T.end,
255
+ "arrow.both": T.both,
256
+ "counter.circle": E.circle,
257
+ "counter.rect": E.rect,
258
+ "counter.rounded": E.rounded,
259
+ "brand.github": te
260
+ }, re = {
261
+ ...O,
262
+ ...ne
263
+ }, ie = Object.keys(re);
264
+ function ae(e) {
265
+ return re[e];
263
266
  }
264
267
  //#endregion
265
268
  //#region src/editor/icons/sanitize.ts
266
- var y = "http://www.w3.org/2000/svg", b = 64 * 1024, x = {
269
+ var oe = "http://www.w3.org/2000/svg", se = 64 * 1024, ce = {
267
270
  svg: "svg",
268
271
  g: "g",
269
272
  path: "path",
@@ -283,64 +286,64 @@ var y = "http://www.w3.org/2000/svg", b = 64 * 1024, x = {
283
286
  desc: "desc",
284
287
  text: "text",
285
288
  tspan: "tspan"
286
- }, S = new Set(/* @__PURE__ */ "id.class.viewBox.preserveAspectRatio.fill.fill-rule.fill-opacity.stroke.stroke-width.stroke-linecap.stroke-linejoin.stroke-dasharray.stroke-dashoffset.stroke-opacity.stroke-miterlimit.transform.opacity.color.aria-hidden.aria-label.role.width.height.x.y.x1.y1.x2.y2.cx.cy.r.rx.ry.d.points.offset.stop-color.stop-opacity.gradientUnits.gradientTransform.spreadMethod.fr.fx.fy.text-anchor.dominant-baseline.font-size.font-family.font-weight.letter-spacing.dx.dy".split(".")), C = { use: new Set(["href", "xlink:href"]) };
287
- function ee(e) {
289
+ }, le = /* @__PURE__ */ new Set(/* @__PURE__ */ "id.class.viewBox.preserveAspectRatio.fill.fill-rule.fill-opacity.stroke.stroke-width.stroke-linecap.stroke-linejoin.stroke-dasharray.stroke-dashoffset.stroke-opacity.stroke-miterlimit.transform.opacity.color.aria-hidden.aria-label.role.width.height.x.y.x1.y1.x2.y2.cx.cy.r.rx.ry.d.points.offset.stop-color.stop-opacity.gradientUnits.gradientTransform.spreadMethod.fr.fx.fy.text-anchor.dominant-baseline.font-size.font-family.font-weight.letter-spacing.dx.dy".split(".")), ue = { use: /* @__PURE__ */ new Set(["href", "xlink:href"]) };
290
+ function de(e) {
288
291
  return /^#[A-Za-z_][A-Za-z0-9_\-:.]*$/.test(e);
289
292
  }
290
- function te(e) {
293
+ function fe(e) {
291
294
  return /^\s*(javascript|data:text\/html|vbscript):/i.test(e);
292
295
  }
293
- function w(e) {
296
+ function pe(e) {
294
297
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
295
298
  }
296
- function T(e) {
297
- if (typeof e != "string" || e.length === 0 || e.length > b) return null;
299
+ function me(e) {
300
+ if (typeof e != "string" || e.length === 0 || e.length > se) return null;
298
301
  let t = globalThis.DOMParser;
299
302
  if (!t) return null;
300
303
  let n = new t().parseFromString(e, "image/svg+xml").documentElement;
301
- return !n || n.namespaceURI !== y || (n.localName ?? "").toLowerCase() !== "svg" ? null : E(n);
304
+ return !n || n.namespaceURI !== oe || (n.localName ?? "").toLowerCase() !== "svg" ? null : he(n);
302
305
  }
303
- function E(e) {
304
- let t = (e.localName ?? "").toLowerCase(), n = x[t];
306
+ function he(e) {
307
+ let t = (e.localName ?? "").toLowerCase(), n = ce[t];
305
308
  if (!n) return "";
306
- let r = D(e, t, n === "svg"), i = [];
309
+ let r = ge(e, t, n === "svg"), i = [];
307
310
  for (let t of Array.from(e.childNodes)) if (t.nodeType === 1) {
308
311
  let e = t;
309
- if (e.namespaceURI !== y) continue;
310
- let n = E(e);
312
+ if (e.namespaceURI !== oe) continue;
313
+ let n = he(e);
311
314
  n && i.push(n);
312
315
  } else if (t.nodeType === 3) {
313
316
  let e = t.nodeValue ?? "";
314
- e.length > 0 && i.push(w(e));
317
+ e.length > 0 && i.push(pe(e));
315
318
  }
316
319
  return i.length === 0 ? `<${n}${r}/>` : `<${n}${r}>${i.join("")}</${n}>`;
317
320
  }
318
- function D(e, t, n) {
319
- let r = C[t], i = [];
320
- n && i.push(` xmlns="${y}"`);
321
+ function ge(e, t, n) {
322
+ let r = ue[t], i = [];
323
+ n && i.push(` xmlns="${oe}"`);
321
324
  for (let t of Array.from(e.attributes)) {
322
325
  let e = t.name;
323
326
  if (e.startsWith("on") || e === "style" || e.startsWith("xmlns")) continue;
324
- let n = S.has(e), a = r?.has(e) === !0;
325
- !n && !a || a && !ee(t.value) || te(t.value) || i.push(` ${e}="${w(t.value)}"`);
327
+ let n = le.has(e), a = r?.has(e) === !0;
328
+ !n && !a || a && !de(t.value) || fe(t.value) || i.push(` ${e}="${pe(t.value)}"`);
326
329
  }
327
330
  return i.join("");
328
331
  }
329
332
  //#endregion
330
333
  //#region src/editor/icons/render.ts
331
- function O(e) {
334
+ function _e(e) {
332
335
  let t = e.trim();
333
336
  return t.length === 0 ? !1 : /^data:image\/svg\+xml[,;]/i.test(t) ? !0 : !(/^javascript:/i.test(t) || /^data:/i.test(t) || /^[a-z][a-z0-9+.-]*:/i.test(t));
334
337
  }
335
- function ne(e) {
338
+ function ve(e) {
336
339
  switch (e.kind) {
337
- case "builtin": return v(e.id) ?? "";
338
- case "svg": return T(e.svg) ?? "";
339
- case "url": return O(e.url) ? `<img src="${e.url.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;")}" alt="" aria-hidden="true" class="annot-icon-img"/>` : "";
340
+ case "builtin": return ae(e.id) ?? "";
341
+ case "svg": return me(e.svg) ?? "";
342
+ case "url": return _e(e.url) ? `<img src="${e.url.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;")}" alt="" aria-hidden="true" class="annot-icon-img"/>` : "";
340
343
  }
341
344
  }
342
- function re(e, t) {
343
- let n = ne(e);
345
+ function ye(e, t) {
346
+ let n = ve(e);
344
347
  if (!n) return null;
345
348
  let r = t ?? globalThis.document ?? null;
346
349
  if (!r) return null;
@@ -349,7 +352,7 @@ function re(e, t) {
349
352
  }
350
353
  //#endregion
351
354
  //#region src/editor/path-utils.ts
352
- var ie = {
355
+ var be = {
353
356
  M: ["x", "y"],
354
357
  L: ["x", "y"],
355
358
  H: ["x"],
@@ -386,7 +389,7 @@ var ie = {
386
389
  ],
387
390
  Z: []
388
391
  };
389
- function ae(e) {
392
+ function xe(e) {
390
393
  let t = [], n = /([A-DF-Za-df-z])|(-?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)/g, r = null, i = n.exec(e);
391
394
  for (; i !== null;) {
392
395
  let a = i[1], o = i[2];
@@ -400,19 +403,19 @@ function ae(e) {
400
403
  }
401
404
  return t;
402
405
  }
403
- function oe(e) {
406
+ function Se(e) {
404
407
  return Math.abs(e) < 1e-9 ? "0" : Number(e.toFixed(6)).toString();
405
408
  }
406
- function se(e) {
409
+ function Ce(e) {
407
410
  let t = [];
408
- for (let n of e) n.params.length === 0 ? t.push(n.cmd) : t.push(n.cmd + n.params.map(oe).join(" "));
411
+ for (let n of e) n.params.length === 0 ? t.push(n.cmd) : t.push(n.cmd + n.params.map(Se).join(" "));
409
412
  return t.join(" ");
410
413
  }
411
- function ce(e, t, n) {
414
+ function we(e, t, n) {
412
415
  if (t === 0 && n === 0) return e;
413
- let r = ae(e), i = !0;
416
+ let r = xe(e), i = !0;
414
417
  for (let e of r) {
415
- let r = e.cmd.toUpperCase(), a = ie[r];
418
+ let r = e.cmd.toUpperCase(), a = be[r];
416
419
  if (!a || a.length === 0) {
417
420
  i = !1;
418
421
  continue;
@@ -430,11 +433,11 @@ function ce(e, t, n) {
430
433
  }
431
434
  i = !1;
432
435
  }
433
- return se(r);
436
+ return Ce(r);
434
437
  }
435
438
  //#endregion
436
439
  //#region src/utils/dash-utils.ts
437
- var le = {
440
+ var Te = {
438
441
  dash: [4, 3],
439
442
  dot: [1, 3],
440
443
  dashDot: [
@@ -446,35 +449,35 @@ var le = {
446
449
  lgDash: [8, 3]
447
450
  };
448
451
  function k(e, t) {
449
- let n = le[e];
452
+ let n = Te[e];
450
453
  return n ? n.map((e) => Math.max(1, Math.round(e * t))).join(",") : "";
451
454
  }
452
- function A(e, t) {
455
+ function Ee(e, t) {
453
456
  if (!e) return "";
454
- for (let [n, r] of Object.entries(le)) if (r.map((e) => Math.max(1, Math.round(e * t))).join(",") === e) return n;
457
+ for (let [n, r] of Object.entries(Te)) if (r.map((e) => Math.max(1, Math.round(e * t))).join(",") === e) return n;
455
458
  let n = e.split(",").map(Number);
456
459
  return n.length === 4 ? "dashDot" : n.length === 2 && n[0] <= t * 2 ? "dot" : n.length === 2 && n[0] > t * 5 ? "lgDash" : "dash";
457
460
  }
458
461
  //#endregion
459
462
  //#region src/editor/arrow-markers.ts
460
- var j = class {
463
+ var A = class {
461
464
  #e = "";
462
465
  begin() {}
463
466
  moveTo(e, t) {
464
- this.#e += `M ${M(e)} ${M(t)} `;
467
+ this.#e += `M ${j(e)} ${j(t)} `;
465
468
  }
466
469
  lineTo(e, t) {
467
- this.#e += `L ${M(e)} ${M(t)} `;
470
+ this.#e += `L ${j(e)} ${j(t)} `;
468
471
  }
469
472
  quadTo(e, t, n, r) {
470
- this.#e += `Q ${M(e)} ${M(t)} ${M(n)} ${M(r)} `;
473
+ this.#e += `Q ${j(e)} ${j(t)} ${j(n)} ${j(r)} `;
471
474
  }
472
475
  close() {
473
476
  this.#e += "Z ";
474
477
  }
475
478
  ellipse(e, t, n, r) {
476
479
  let i = n / 2, a = r / 2, o = e + i, s = t + a;
477
- this.#e += `M ${M(o - i)} ${M(s)} A ${M(i)} ${M(a)} 0 1 0 ${M(o + i)} ${M(s)} A ${M(i)} ${M(a)} 0 1 0 ${M(o - i)} ${M(s)} Z `;
480
+ this.#e += `M ${j(o - i)} ${j(s)} A ${j(i)} ${j(a)} 0 1 0 ${j(o + i)} ${j(s)} A ${j(i)} ${j(a)} 0 1 0 ${j(o - i)} ${j(s)} Z `;
478
481
  }
479
482
  stroke() {}
480
483
  fillAndStroke() {}
@@ -485,68 +488,68 @@ var j = class {
485
488
  this.#e = "";
486
489
  }
487
490
  };
488
- function M(e) {
491
+ function j(e) {
489
492
  return Math.abs(e) < 1e-9 ? "0" : Number(e.toFixed(3)).toString();
490
493
  }
491
- function ue(e, t, n, r, i, a, o, s) {
494
+ function De(e, t, n, r, i, a, o, s) {
492
495
  let c = i * s * 1.118, l = a * s * 1.118, u = i * (o + s), d = a * (o + s), f = {
493
496
  x: r.x - c,
494
497
  y: r.y - l
495
498
  }, p = n ? 3 / 4 : 1;
496
499
  r.x += -u * p - c, r.y += -d * p - l, e.moveTo(f.x, f.y), e.lineTo(f.x - u - d / t, f.y - d + u / t), n && e.lineTo(f.x - u * 3 / 4, f.y - d * 3 / 4), e.lineTo(f.x + d / t - u, f.y - d - u / t), e.close();
497
500
  }
498
- function de(e, t, n, r, i, a, o) {
501
+ function Oe(e, t, n, r, i, a, o) {
499
502
  let s = r * o * 1.118, c = i * o * 1.118, l = r * (a + o), u = i * (a + o), d = {
500
503
  x: n.x - s,
501
504
  y: n.y - c
502
505
  };
503
506
  n.x += -s * 2, n.y += -c * 2, e.moveTo(d.x - l - u / t, d.y - u + l / t), e.lineTo(d.x, d.y), e.lineTo(d.x + u / t - l, d.y - u - l / t);
504
507
  }
505
- function fe(e, t, n, r, i, a) {
508
+ function ke(e, t, n, r, i, a) {
506
509
  let o = n * a * Math.SQRT1_2, s = r * a * Math.SQRT1_2, c = n * (i + a), l = r * (i + a), u = {
507
510
  x: t.x - o,
508
511
  y: t.y - s
509
512
  };
510
513
  t.x += -c - o, t.y += -l - s, e.moveTo(u.x, u.y), e.lineTo(u.x - c / 2 - l / 2, u.y + c / 2 - l / 2), e.lineTo(u.x - c, u.y - l), e.lineTo(u.x - c / 2 + l / 2, u.y - l / 2 - c / 2), e.close();
511
514
  }
512
- function pe(e, t, n, r, i) {
515
+ function Ae(e, t, n, r, i) {
513
516
  let a = i / 2, o = {
514
517
  x: t.x,
515
518
  y: t.y
516
519
  };
517
520
  t.x -= n * a, t.y -= r * a, e.ellipse(o.x - a, o.y - a, i, i);
518
521
  }
519
- var me = {
522
+ var je = {
520
523
  sm: 6,
521
524
  md: 10,
522
525
  lg: 14
523
- }, he = {
526
+ }, Me = {
524
527
  sm: 3.2,
525
528
  md: 2.4,
526
529
  lg: 1.8
527
- }, ge = {
530
+ }, Ne = {
528
531
  sm: 11,
529
532
  md: 15,
530
533
  lg: 20
531
- }, _e = {
534
+ }, Pe = {
532
535
  sm: 2.4,
533
536
  md: 1.8,
534
537
  lg: 1.35
535
538
  };
536
- function ve(e, t, n, r, i, a) {
539
+ function Fe(e, t, n, r, i, a) {
537
540
  if (t.shape === "none") return { filled: !1 };
538
- let o = t.shape === "arrow" ? ge[t.length] : me[t.length], s = t.shape === "arrow" ? _e[t.width] : he[t.width];
541
+ let o = t.shape === "arrow" ? Ne[t.length] : je[t.length], s = t.shape === "arrow" ? Pe[t.width] : Me[t.width];
539
542
  switch (t.shape) {
540
- case "triangle": return ue(e, s, !1, n, r, i, o, a), { filled: !0 };
541
- case "stealth": return ue(e, s, !0, n, r, i, o, a), { filled: !0 };
542
- case "arrow": return de(e, s, n, r, i, o, a), { filled: !1 };
543
- case "diamond": return fe(e, n, r, i, o, a), { filled: !0 };
544
- case "oval": return pe(e, n, r, i, o), { filled: !0 };
543
+ case "triangle": return De(e, s, !1, n, r, i, o, a), { filled: !0 };
544
+ case "stealth": return De(e, s, !0, n, r, i, o, a), { filled: !0 };
545
+ case "arrow": return Oe(e, s, n, r, i, o, a), { filled: !1 };
546
+ case "diamond": return ke(e, n, r, i, o, a), { filled: !0 };
547
+ case "oval": return Ae(e, n, r, i, o), { filled: !0 };
545
548
  }
546
549
  return { filled: !1 };
547
550
  }
548
- function ye(e, t, n, r, i, a, o, s) {
549
- let c = new j(), l = new j(), u = n - e, d = r - t, f = Math.hypot(u, d) || 1, p = u / f, m = d / f, h = p, g = m, _ = p, v = m;
551
+ function Ie(e, t, n, r, i, a, o, s) {
552
+ let c = new A(), l = new A(), u = n - e, d = r - t, f = Math.hypot(u, d) || 1, p = u / f, m = d / f, h = p, g = m, _ = p, v = m;
550
553
  if (s) {
551
554
  let i = s.x - e, a = s.y - t, o = Math.hypot(i, a);
552
555
  o > 1e-6 && (h = i / o, g = a / o);
@@ -559,26 +562,26 @@ function ye(e, t, n, r, i, a, o, s) {
559
562
  }, b = {
560
563
  x: n,
561
564
  y: r
562
- }, x = be(a.shape), S = be(i.shape);
563
- ve(x ? c : l, a, b, _, v, o), ve(S ? c : l, i, y, -h, -g, o);
564
- let C = new j();
565
+ }, x = Le(a.shape), S = Le(i.shape);
566
+ Fe(x ? c : l, a, b, _, v, o), Fe(S ? c : l, i, y, -h, -g, o);
567
+ let C = new A();
565
568
  return C.moveTo(y.x, y.y), s ? C.quadTo(s.x, s.y, b.x, b.y) : C.lineTo(b.x, b.y), {
566
569
  stemD: C.d,
567
570
  headFilledD: c.d,
568
571
  headOpenD: l.d
569
572
  };
570
573
  }
571
- function be(e) {
574
+ function Le(e) {
572
575
  return e === "triangle" || e === "stealth" || e === "diamond" || e === "oval";
573
576
  }
574
- function N(e, t) {
577
+ function M(e, t) {
575
578
  return {
576
579
  shape: e.getAttribute(`data-arrow-${t}-shape`) || "none",
577
580
  width: e.getAttribute(`data-arrow-${t}-width`) || e.getAttribute(`data-arrow-${t}-size`) || "md",
578
581
  length: e.getAttribute(`data-arrow-${t}-length`) || e.getAttribute(`data-arrow-${t}-size`) || "md"
579
582
  };
580
583
  }
581
- function xe(e) {
584
+ function Re(e) {
582
585
  return {
583
586
  x1: Number.parseFloat(e.getAttribute("data-x1") || "0"),
584
587
  y1: Number.parseFloat(e.getAttribute("data-y1") || "0"),
@@ -586,7 +589,7 @@ function xe(e) {
586
589
  y2: Number.parseFloat(e.getAttribute("data-y2") || "0")
587
590
  };
588
591
  }
589
- function Se(e) {
592
+ function ze(e) {
590
593
  let t = e.getAttribute("data-cx"), n = e.getAttribute("data-cy");
591
594
  if (t == null || n == null) return null;
592
595
  let r = Number.parseFloat(t), i = Number.parseFloat(n);
@@ -595,8 +598,8 @@ function Se(e) {
595
598
  y: i
596
599
  };
597
600
  }
598
- function Ce(e) {
599
- let { x1: t, y1: n, x2: r, y2: i } = xe(e), a = Se(e), { stemD: o, headFilledD: s, headOpenD: c } = ye(t, n, r, i, N(e, "start"), N(e, "end"), Number.parseFloat(e.getAttribute("stroke-width") || "3") || 3, a), l = e.querySelector(":scope > [data-role=\"stem\"]");
601
+ function Be(e) {
602
+ let { x1: t, y1: n, x2: r, y2: i } = Re(e), a = ze(e), { stemD: o, headFilledD: s, headOpenD: c } = Ie(t, n, r, i, M(e, "start"), M(e, "end"), Number.parseFloat(e.getAttribute("stroke-width") || "3") || 3, a), l = e.querySelector(":scope > [data-role=\"stem\"]");
600
603
  l || (l = document.createElementNS("http://www.w3.org/2000/svg", "path"), l.setAttribute("data-role", "stem"), e.appendChild(l)), l.setAttribute("fill", "none"), l.removeAttribute("stroke-linecap"), l.removeAttribute("stroke-linejoin"), l.setAttribute("d", o);
601
604
  let u = e.getAttribute("stroke") || "#ff0000", d = (e, t, n) => {
602
605
  e.setAttribute("stroke-dasharray", "none"), e.setAttribute("stroke-linecap", "round"), e.setAttribute("stroke-linejoin", "miter"), e.setAttribute("fill", t), e.removeAttribute("stroke-width"), e.setAttribute("d", n);
@@ -605,11 +608,11 @@ function Ce(e) {
605
608
  let p = e.querySelector(":scope > [data-role=\"head-open\"]");
606
609
  p || (p = document.createElementNS("http://www.w3.org/2000/svg", "path"), p.setAttribute("data-role", "head-open"), e.appendChild(p)), d(p, "none", c);
607
610
  }
608
- function we(e, t = "right") {
609
- let n = Te(e);
611
+ function Ve(e, t = "right") {
612
+ let n = He(e);
610
613
  return `<svg width="40" height="14" viewBox="0 0 40 14">${t === "left" ? `<g transform="translate(40,0) scale(-1,1)">${n}</g>` : n}</svg>`;
611
614
  }
612
- function Te(e) {
615
+ function He(e) {
613
616
  let t = (e) => `<line x1="2" y1="7" x2="${e}" y2="7" stroke="currentColor" stroke-width="1.6" stroke-linecap="butt"/>`;
614
617
  switch (e) {
615
618
  case "none": return "<line x1=\"2\" y1=\"7\" x2=\"38\" y2=\"7\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"butt\"/>";
@@ -620,8 +623,8 @@ function Te(e) {
620
623
  case "oval": return `${t(28)}<circle cx="33" cy="7" r="5" fill="currentColor"/>`;
621
624
  }
622
625
  }
623
- function Ee(e, t, n = "right") {
624
- let r = 1.2, { stemD: i, headFilledD: a, headOpenD: o } = ye(2, 7, 38, 7, {
626
+ function Ue(e, t, n = "right") {
627
+ let r = 1.2, { stemD: i, headFilledD: a, headOpenD: o } = Ie(2, 7, 38, 7, {
625
628
  shape: "none",
626
629
  width: e,
627
630
  length: t
@@ -634,11 +637,11 @@ function Ee(e, t, n = "right") {
634
637
  }
635
638
  //#endregion
636
639
  //#region src/editor/shape-utils.ts
637
- var De = "http://www.w3.org/2000/svg";
638
- function Oe(e) {
640
+ var We = "http://www.w3.org/2000/svg";
641
+ function Ge(e) {
639
642
  return e.tagName === "ellipse" ? "ellipse" : e.tagName === "rect" ? e.hasAttribute("data-rounded") ? "rounded" : "rect" : null;
640
643
  }
641
- function ke(e) {
644
+ function Ke(e) {
642
645
  if (e.tagName === "ellipse") {
643
646
  let t = Number.parseFloat(e.getAttribute("cx") || "0"), n = Number.parseFloat(e.getAttribute("cy") || "0"), r = Number.parseFloat(e.getAttribute("rx") || "0"), i = Number.parseFloat(e.getAttribute("ry") || "0");
644
647
  return {
@@ -655,7 +658,7 @@ function ke(e) {
655
658
  h: Number.parseFloat(e.getAttribute("height") || "0")
656
659
  };
657
660
  }
658
- var Ae = [
661
+ var qe = [
659
662
  "stroke",
660
663
  "stroke-width",
661
664
  "stroke-dasharray",
@@ -664,16 +667,16 @@ var Ae = [
664
667
  "fill",
665
668
  "fill-opacity"
666
669
  ];
667
- function je(e, t) {
668
- let { x: n, y: r, w: i, h: a } = ke(e), o = e.parentNode;
670
+ function Je(e, t) {
671
+ let { x: n, y: r, w: i, h: a } = Ke(e), o = e.parentNode;
669
672
  if (!o) throw Error("convertShape: element is detached from DOM");
670
673
  let s;
671
- if (t === "ellipse") s = document.createElementNS(De, "ellipse"), s.setAttribute("cx", String(n + i / 2)), s.setAttribute("cy", String(r + a / 2)), s.setAttribute("rx", String(i / 2)), s.setAttribute("ry", String(a / 2));
672
- else if (s = document.createElementNS(De, "rect"), s.setAttribute("x", String(n)), s.setAttribute("y", String(r)), s.setAttribute("width", String(i)), s.setAttribute("height", String(a)), t === "rounded") {
674
+ if (t === "ellipse") s = document.createElementNS(We, "ellipse"), s.setAttribute("cx", String(n + i / 2)), s.setAttribute("cy", String(r + a / 2)), s.setAttribute("rx", String(i / 2)), s.setAttribute("ry", String(a / 2));
675
+ else if (s = document.createElementNS(We, "rect"), s.setAttribute("x", String(n)), s.setAttribute("y", String(r)), s.setAttribute("width", String(i)), s.setAttribute("height", String(a)), t === "rounded") {
673
676
  let e = Math.max(2, Math.round(Math.min(i, a) / 6));
674
677
  s.setAttribute("rx", String(e)), s.setAttribute("data-rounded", "true");
675
678
  } else s.setAttribute("rx", "0");
676
- for (let t of Ae) {
679
+ for (let t of qe) {
677
680
  let n = e.getAttribute(t);
678
681
  n != null && s.setAttribute(t, n);
679
682
  }
@@ -681,70 +684,70 @@ function je(e, t) {
681
684
  }
682
685
  //#endregion
683
686
  //#region src/editor/text-utils.ts
684
- var P = "http://www.w3.org/2000/svg", Me = {
687
+ var N = "http://www.w3.org/2000/svg", Ye = {
685
688
  "#ff0000": "rgba(255,255,200,0.92)",
686
689
  "#00ff00": "rgba(200,255,200,0.92)",
687
690
  "#0000ff": "rgba(200,220,255,0.92)",
688
691
  "#ff8800": "rgba(255,230,200,0.92)",
689
692
  "#ff00ff": "rgba(255,210,255,0.92)"
690
693
  };
691
- function Ne(e) {
692
- return Me[e.toLowerCase()] || "rgba(255,255,200,0.92)";
694
+ function Xe(e) {
695
+ return Ye[e.toLowerCase()] || "rgba(255,255,200,0.92)";
693
696
  }
694
- function F(e, t, n) {
697
+ function P(e, t, n) {
695
698
  let r = e.getAttribute(t);
696
699
  if (r == null) return n;
697
700
  let i = Number.parseFloat(r);
698
701
  return Number.isFinite(i) && i >= 0 ? i : n;
699
702
  }
700
- function Pe(e) {
703
+ function Ze(e) {
701
704
  let t = e.getAttribute("data-shape-kind"), n = t === "plain" ? 2 : 10, r = t === "plain" ? 0 : 8;
702
705
  return {
703
- left: F(e, "data-text-margin-l", n),
704
- right: F(e, "data-text-margin-r", n),
705
- top: F(e, "data-text-margin-t", r),
706
- bottom: F(e, "data-text-margin-b", r)
706
+ left: P(e, "data-text-margin-l", n),
707
+ right: P(e, "data-text-margin-r", n),
708
+ top: P(e, "data-text-margin-t", r),
709
+ bottom: P(e, "data-text-margin-b", r)
707
710
  };
708
711
  }
709
- function Fe(e) {
712
+ function Qe(e) {
710
713
  return e === "rect" || e === "rounded" || e === "ellipse" ? "middle" : "start";
711
714
  }
712
- function Ie(e) {
715
+ function $e(e) {
713
716
  return e === "rect" || e === "rounded" || e === "ellipse" ? "middle" : "top";
714
717
  }
715
- var I;
716
- function Le() {
717
- if (I !== void 0) return I;
718
- if (typeof document > "u") return I = null;
718
+ var F;
719
+ function et() {
720
+ if (F !== void 0) return F;
721
+ if (typeof document > "u") return F = null;
719
722
  try {
720
- I = document.createElement("canvas").getContext("2d");
723
+ F = document.createElement("canvas").getContext("2d");
721
724
  } catch {
722
- I = null;
725
+ F = null;
723
726
  }
724
- return I;
727
+ return F;
725
728
  }
726
- function Re(e, t, n, r, i) {
727
- let a = Le();
729
+ function tt(e, t, n, r, i) {
730
+ let a = et();
728
731
  return a ? (a.font = `${`${i ? "italic " : ""}${r ? "bold " : ""}`}${t}px ${n}`, a.measureText(e).width) : 0;
729
732
  }
730
- var L;
731
- function ze() {
732
- if (L !== void 0) return L;
733
- if (typeof Intl > "u" || Intl.Segmenter === void 0) return L = null;
733
+ var I;
734
+ function nt() {
735
+ if (I !== void 0) return I;
736
+ if (typeof Intl > "u" || Intl.Segmenter === void 0) return I = null;
734
737
  try {
735
738
  let e = typeof navigator < "u" ? navigator.language : void 0;
736
- L = new Intl.Segmenter(e, { granularity: "word" });
739
+ I = new Intl.Segmenter(e, { granularity: "word" });
737
740
  } catch {
738
- L = null;
741
+ I = null;
739
742
  }
740
- return L;
743
+ return I;
741
744
  }
742
- var R = /^[\s ]+$/;
743
- function Be(e, t, n, r) {
745
+ var L = /^[\s ]+$/;
746
+ function rt(e, t, n, r) {
744
747
  let i = [], a = {
745
748
  segments: [],
746
749
  maxFontSize: 0
747
- }, o = 0, s = ze(), c = () => {
750
+ }, o = 0, s = nt(), c = () => {
748
751
  i.push(a), a = {
749
752
  segments: [],
750
753
  maxFontSize: 0
@@ -756,8 +759,8 @@ function Be(e, t, n, r) {
756
759
  else {
757
760
  let e = 0;
758
761
  for (; e < i.text.length;) {
759
- let t = R.test(i.text[e]), n = e + 1;
760
- for (; n < i.text.length && R.test(i.text[n]) === t;) n++;
762
+ let t = L.test(i.text[e]), n = e + 1;
763
+ for (; n < i.text.length && L.test(i.text[n]) === t;) n++;
761
764
  f.push(i.text.slice(e, n)), e = n;
762
765
  }
763
766
  }
@@ -773,9 +776,9 @@ function Be(e, t, n, r) {
773
776
  }), e > a.maxFontSize && (a.maxFontSize = e), "");
774
777
  };
775
778
  for (let n of f) {
776
- if (a.segments.length === 0 && p === "" && R.test(n)) continue;
777
- let r = Re(n, e, l, u, d);
778
- o + r > t && (o > 0 || p !== "") && (m(), c(), R.test(n)) || (p += n, o += r);
779
+ if (a.segments.length === 0 && p === "" && L.test(n)) continue;
780
+ let r = tt(n, e, l, u, d);
781
+ o + r > t && (o > 0 || p !== "") && (m(), c(), L.test(n)) || (p += n, o += r);
779
782
  }
780
783
  m(), i.text === "" && a.segments.length === 0 && e > a.maxFontSize && (a.maxFontSize = e), i.line_break_after && c();
781
784
  }
@@ -783,7 +786,7 @@ function Be(e, t, n, r) {
783
786
  for (let e of i) e.maxFontSize === 0 && (e.maxFontSize = n);
784
787
  return i;
785
788
  }
786
- function Ve(e) {
789
+ function it(e) {
787
790
  let { x: t, y: n, w: r, h: i, lineFontSizes: a, margins: o, textAnchor: s, textVerticalAnchor: c } = e, l = a.length > 0 ? a : [16], u = l.map((e) => e * 1.4), d = Array(l.length);
788
791
  d[0] = 0;
789
792
  for (let e = 1; e < l.length; e++) d[e] = d[e - 1] + u[e - 1];
@@ -799,17 +802,17 @@ function Ve(e) {
799
802
  }
800
803
  };
801
804
  }
802
- function He(e) {
805
+ function at(e) {
803
806
  return e.tagName === "g" && e.getAttribute("data-type") === "shape" && e.getAttribute("data-shape-kind") != null;
804
807
  }
805
- function Ue(e) {
808
+ function ot(e) {
806
809
  let t = e.getAttribute("data-shape-kind");
807
810
  return t === "plain" || t === "sticky" || t === "callout" ? t : "sticky";
808
811
  }
809
- function We(e) {
812
+ function st(e) {
810
813
  return e.hasAttribute("x") || e.hasAttribute("y");
811
814
  }
812
- function Ge(e) {
815
+ function ct(e) {
813
816
  let t = e.querySelector("text");
814
817
  if (!t) return [];
815
818
  let n = Array.from(t.querySelectorAll("tspan"));
@@ -834,45 +837,45 @@ function Ge(e) {
834
837
  let c = t.getAttribute("fill");
835
838
  c && (i.color = c);
836
839
  let l = n[e + 1];
837
- i.line_break_after = l != null && We(l), r.push(i);
840
+ i.line_break_after = l != null && st(l), r.push(i);
838
841
  }
839
842
  return r;
840
843
  }
841
- function z(e) {
842
- let t = e.querySelector("rect"), n = Number.parseFloat(t?.getAttribute("x") || "0"), r = Number.parseFloat(t?.getAttribute("y") || "0"), i = Number.parseFloat(t?.getAttribute("width") || "200"), a = Number.parseFloat(t?.getAttribute("height") || "80"), o = Number.parseFloat(e.getAttribute("data-font-size") || "16"), s = e.getAttribute("data-font-family") || "Annot Sans", c = e.getAttribute("data-color") || "#ff0000", l = Ue(e), u = e.getAttribute("data-shape-kind"), d = e.getAttribute("data-tail-x"), f = e.getAttribute("data-tail-y"), p = e.getAttribute("data-text-anchor"), m = e.getAttribute("data-text-vanchor");
844
+ function R(e) {
845
+ let t = e.querySelector("rect"), n = Number.parseFloat(t?.getAttribute("x") || "0"), r = Number.parseFloat(t?.getAttribute("y") || "0"), i = Number.parseFloat(t?.getAttribute("width") || "200"), a = Number.parseFloat(t?.getAttribute("height") || "80"), o = Number.parseFloat(e.getAttribute("data-font-size") || "16"), s = e.getAttribute("data-font-family") || "Annot Sans", c = e.getAttribute("data-color") || "#ff0000", l = ot(e), u = e.getAttribute("data-shape-kind"), d = e.getAttribute("data-tail-x"), f = e.getAttribute("data-tail-y"), p = e.getAttribute("data-text-anchor"), m = e.getAttribute("data-text-vanchor");
843
846
  return {
844
847
  x: n,
845
848
  y: r,
846
849
  w: i,
847
850
  h: a,
848
851
  variant: l,
849
- runs: Ge(e),
852
+ runs: ct(e),
850
853
  fontSize: o,
851
854
  fontFamily: s,
852
855
  color: c,
853
- textAnchor: p ?? Fe(u),
854
- textVerticalAnchor: m ?? Ie(u),
856
+ textAnchor: p ?? Qe(u),
857
+ textVerticalAnchor: m ?? $e(u),
855
858
  tailX: d == null ? void 0 : Number.parseFloat(d),
856
859
  tailY: f == null ? void 0 : Number.parseFloat(f)
857
860
  };
858
861
  }
859
- function Ke(e) {
860
- let t = document.createElementNS(P, "g");
862
+ function lt(e) {
863
+ let t = document.createElementNS(N, "g");
861
864
  t.setAttribute("data-type", "shape"), t.setAttribute("data-shape-kind", e.variant), t.setAttribute("data-font-size", String(e.fontSize)), t.setAttribute("data-font-family", e.fontFamily), t.setAttribute("data-color", e.color);
862
- let n = e.textAnchor ?? Fe(e.variant), r = e.textVerticalAnchor ?? Ie(e.variant);
865
+ let n = e.textAnchor ?? Qe(e.variant), r = e.textVerticalAnchor ?? $e(e.variant);
863
866
  t.setAttribute("data-text-anchor", n), t.setAttribute("data-text-vanchor", r);
864
- let i = document.createElementNS(P, "rect");
865
- if (i.setAttribute("x", String(e.x)), i.setAttribute("y", String(e.y)), i.setAttribute("width", String(e.w)), i.setAttribute("height", String(e.h)), e.variant === "plain" ? (i.setAttribute("fill", "none"), i.setAttribute("stroke", "none"), i.setAttribute("pointer-events", "all")) : e.variant === "sticky" ? (i.setAttribute("rx", "4"), i.setAttribute("fill", Ne(e.color)), i.setAttribute("stroke", "rgba(0,0,0,0.15)"), i.setAttribute("stroke-width", "1")) : (i.setAttribute("rx", "8"), i.setAttribute("fill", Ne(e.color)), i.setAttribute("stroke", "none")), t.appendChild(i), e.variant === "callout") {
867
+ let i = document.createElementNS(N, "rect");
868
+ if (i.setAttribute("x", String(e.x)), i.setAttribute("y", String(e.y)), i.setAttribute("width", String(e.w)), i.setAttribute("height", String(e.h)), e.variant === "plain" ? (i.setAttribute("fill", "none"), i.setAttribute("stroke", "none"), i.setAttribute("pointer-events", "all")) : e.variant === "sticky" ? (i.setAttribute("rx", "4"), i.setAttribute("fill", Xe(e.color)), i.setAttribute("stroke", "rgba(0,0,0,0.15)"), i.setAttribute("stroke-width", "1")) : (i.setAttribute("rx", "8"), i.setAttribute("fill", Xe(e.color)), i.setAttribute("stroke", "none")), t.appendChild(i), e.variant === "callout") {
866
869
  let n = e.tailX ?? e.x - 30, r = e.tailY ?? e.y + e.h + 40;
867
870
  t.setAttribute("data-tail-x", String(n)), t.setAttribute("data-tail-y", String(r));
868
- let i = document.createElementNS(P, "path");
869
- i.setAttribute("d", ""), i.setAttribute("fill", Ne(e.color)), i.setAttribute("stroke", "rgba(0,0,0,0.25)"), i.setAttribute("stroke-width", "1"), t.appendChild(i), Je(t);
871
+ let i = document.createElementNS(N, "path");
872
+ i.setAttribute("d", ""), i.setAttribute("fill", Xe(e.color)), i.setAttribute("stroke", "rgba(0,0,0,0.25)"), i.setAttribute("stroke-width", "1"), t.appendChild(i), dt(t);
870
873
  }
871
- let a = `clip-textshape-${Math.random().toString(36).slice(2, 9)}`, o = document.createElementNS(P, "clipPath");
874
+ let a = `clip-textshape-${Math.random().toString(36).slice(2, 9)}`, o = document.createElementNS(N, "clipPath");
872
875
  o.id = a;
873
- let s = document.createElementNS(P, "rect");
876
+ let s = document.createElementNS(N, "rect");
874
877
  s.setAttribute("x", String(e.x)), s.setAttribute("y", String(e.y)), s.setAttribute("width", String(e.w)), s.setAttribute("height", String(e.h)), o.appendChild(s), t.appendChild(o);
875
- let c = Pe(t), l = Math.max(0, e.w - c.left - c.right), u = Be(e.runs, l, e.fontSize, e.fontFamily), d = Ve({
878
+ let c = Ze(t), l = Math.max(0, e.w - c.left - c.right), u = rt(e.runs, l, e.fontSize, e.fontFamily), d = it({
876
879
  x: e.x,
877
880
  y: e.y,
878
881
  w: e.w,
@@ -881,25 +884,25 @@ function Ke(e) {
881
884
  margins: c,
882
885
  textAnchor: n,
883
886
  textVerticalAnchor: r
884
- }), f = document.createElementNS(P, "text");
885
- return f.setAttribute("font-size", String(e.fontSize)), f.setAttribute("fill", e.color), f.setAttribute("font-family", e.fontFamily), f.setAttribute("clip-path", `url(#${a})`), f.setAttribute("text-anchor", d.textAnchorAttr), f.style.pointerEvents = "none", qe(f, u, d), t.appendChild(f), t;
887
+ }), f = document.createElementNS(N, "text");
888
+ return f.setAttribute("font-size", String(e.fontSize)), f.setAttribute("fill", e.color), f.setAttribute("font-family", e.fontFamily), f.setAttribute("clip-path", `url(#${a})`), f.setAttribute("text-anchor", d.textAnchorAttr), f.style.pointerEvents = "none", ut(f, u, d), t.appendChild(f), t;
886
889
  }
887
- function qe(e, t, n) {
890
+ function ut(e, t, n) {
888
891
  for (let r = 0; r < t.length; r++) {
889
892
  let i = t[r], a = n.xForLine, o = n.yForLine(r);
890
893
  if (i.segments.length === 0) {
891
- let t = document.createElementNS(P, "tspan");
894
+ let t = document.createElementNS(N, "tspan");
892
895
  t.setAttribute("x", String(a)), t.setAttribute("y", String(o)), t.textContent = "", e.appendChild(t);
893
896
  continue;
894
897
  }
895
898
  let s = !0;
896
899
  for (let t of i.segments) {
897
- let n = document.createElementNS(P, "tspan");
900
+ let n = document.createElementNS(N, "tspan");
898
901
  s &&= (n.setAttribute("x", String(a)), n.setAttribute("y", String(o)), !1), t.bold && n.setAttribute("font-weight", "bold"), t.italic && n.setAttribute("font-style", "italic"), t.underline && n.setAttribute("text-decoration", "underline"), t.font_size != null && n.setAttribute("font-size", String(t.font_size)), t.font_family != null && n.setAttribute("font-family", t.font_family), t.color != null && n.setAttribute("fill", t.color), n.textContent = t.text, e.appendChild(n);
899
902
  }
900
903
  }
901
904
  }
902
- function Je(e) {
905
+ function dt(e) {
903
906
  if (e.getAttribute("data-shape-kind") !== "callout") return;
904
907
  let t = e.querySelector("rect"), n = e.querySelector("path");
905
908
  if (!t || !n) return;
@@ -908,14 +911,14 @@ function Je(e) {
908
911
  let e = c - u, t = l - d;
909
912
  m = Math.abs(e) > Math.abs(t) ? e > 0 ? "right" : "left" : t > 0 ? "bottom" : "top";
910
913
  } else m = f > p ? c < r ? "left" : "right" : l < i ? "top" : "bottom";
911
- let h = .1667, g = r, _ = r + a, v = i, y = i + o, b = Math.max(0, Math.min(a * h, a - 2 * s)), x = Math.max(0, Math.min(o * h, o - 2 * s)), S = b / 2, C = x / 2, ee = c < u ? (u + (g + s)) / 2 : (u + (_ - s)) / 2, te = l < d ? (d + (v + s)) / 2 : (d + (y - s)) / 2, w = ee - S, T = ee + S, E = te - C, D = te + C, O = [];
912
- O.push(`M ${g + s} ${v}`), m === "top" && (O.push(`L ${w} ${v}`), O.push(`L ${c} ${l}`), O.push(`L ${T} ${v}`)), O.push(`L ${_ - s} ${v}`), s > 0 && O.push(`A ${s} ${s} 0 0 1 ${_} ${v + s}`), m === "right" && (O.push(`L ${_} ${E}`), O.push(`L ${c} ${l}`), O.push(`L ${_} ${D}`)), O.push(`L ${_} ${y - s}`), s > 0 && O.push(`A ${s} ${s} 0 0 1 ${_ - s} ${y}`), m === "bottom" && (O.push(`L ${T} ${y}`), O.push(`L ${c} ${l}`), O.push(`L ${w} ${y}`)), O.push(`L ${g + s} ${y}`), s > 0 && O.push(`A ${s} ${s} 0 0 1 ${g} ${y - s}`), m === "left" && (O.push(`L ${g} ${D}`), O.push(`L ${c} ${l}`), O.push(`L ${g} ${E}`)), O.push(`L ${g} ${v + s}`), s > 0 && O.push(`A ${s} ${s} 0 0 1 ${g + s} ${v}`), O.push("Z"), n.setAttribute("d", O.join(" "));
914
+ let h = .1667, g = r, _ = r + a, v = i, y = i + o, b = Math.max(0, Math.min(a * h, a - 2 * s)), x = Math.max(0, Math.min(o * h, o - 2 * s)), S = b / 2, C = x / 2, ee = c < u ? (u + (g + s)) / 2 : (u + (_ - s)) / 2, w = l < d ? (d + (v + s)) / 2 : (d + (y - s)) / 2, T = ee - S, E = ee + S, D = w - C, te = w + C, O = [];
915
+ O.push(`M ${g + s} ${v}`), m === "top" && (O.push(`L ${T} ${v}`), O.push(`L ${c} ${l}`), O.push(`L ${E} ${v}`)), O.push(`L ${_ - s} ${v}`), s > 0 && O.push(`A ${s} ${s} 0 0 1 ${_} ${v + s}`), m === "right" && (O.push(`L ${_} ${D}`), O.push(`L ${c} ${l}`), O.push(`L ${_} ${te}`)), O.push(`L ${_} ${y - s}`), s > 0 && O.push(`A ${s} ${s} 0 0 1 ${_ - s} ${y}`), m === "bottom" && (O.push(`L ${E} ${y}`), O.push(`L ${c} ${l}`), O.push(`L ${T} ${y}`)), O.push(`L ${g + s} ${y}`), s > 0 && O.push(`A ${s} ${s} 0 0 1 ${g} ${y - s}`), m === "left" && (O.push(`L ${g} ${te}`), O.push(`L ${c} ${l}`), O.push(`L ${g} ${D}`)), O.push(`L ${g} ${v + s}`), s > 0 && O.push(`A ${s} ${s} 0 0 1 ${g + s} ${v}`), O.push("Z"), n.setAttribute("d", O.join(" "));
913
916
  }
914
- function B(e, t) {
917
+ function z(e, t) {
915
918
  let n = (() => {
916
919
  for (let t of Array.from(e.children)) if (t.tagName === "rect") return t;
917
920
  return null;
918
- })(), r = n ? Number.parseFloat(n.getAttribute("x") || "0") : 0, i = n ? Number.parseFloat(n.getAttribute("y") || "0") : 0, a = n ? Number.parseFloat(n.getAttribute("width") || "0") : 0, o = n ? Number.parseFloat(n.getAttribute("height") || "0") : 0, s = Number.parseFloat(e.getAttribute("data-font-size") || "16"), c = e.getAttribute("data-font-family") || "Annot Sans", l = e.getAttribute("data-color") || "#000000", u = e.getAttribute("data-shape-kind"), d = Pe(e), f = e.getAttribute("data-text-anchor") ?? Fe(u), p = e.getAttribute("data-text-vanchor") ?? Ie(u), m = Be(t, Math.max(0, a - d.left - d.right), s, c), h = m.map((e) => e.maxFontSize), g = Ve({
921
+ })(), r = n ? Number.parseFloat(n.getAttribute("x") || "0") : 0, i = n ? Number.parseFloat(n.getAttribute("y") || "0") : 0, a = n ? Number.parseFloat(n.getAttribute("width") || "0") : 0, o = n ? Number.parseFloat(n.getAttribute("height") || "0") : 0, s = Number.parseFloat(e.getAttribute("data-font-size") || "16"), c = e.getAttribute("data-font-family") || "Annot Sans", l = e.getAttribute("data-color") || "#000000", u = e.getAttribute("data-shape-kind"), d = Ze(e), f = e.getAttribute("data-text-anchor") ?? Qe(u), p = e.getAttribute("data-text-vanchor") ?? $e(u), m = rt(t, Math.max(0, a - d.left - d.right), s, c), h = m.map((e) => e.maxFontSize), g = it({
919
922
  x: r,
920
923
  y: i,
921
924
  w: a,
@@ -929,8 +932,8 @@ function B(e, t) {
929
932
  _ = t;
930
933
  break;
931
934
  }
932
- for (_ || (_ = document.createElementNS(P, "text"), e.appendChild(_)), _.setAttribute("font-size", String(s)), _.setAttribute("font-family", c), _.setAttribute("fill", l), _.setAttribute("text-anchor", g.textAnchorAttr), _.style.pointerEvents = "none"; _.firstChild;) _.removeChild(_.firstChild);
933
- if (qe(_, m, g), e.getAttribute("data-text-autofit") === "resize" && n) {
935
+ for (_ || (_ = document.createElementNS(N, "text"), e.appendChild(_)), _.setAttribute("font-size", String(s)), _.setAttribute("font-family", c), _.setAttribute("fill", l), _.setAttribute("text-anchor", g.textAnchorAttr), _.style.pointerEvents = "none"; _.firstChild;) _.removeChild(_.firstChild);
936
+ if (ut(_, m, g), e.getAttribute("data-text-autofit") === "resize" && n) {
934
937
  let r = 0;
935
938
  for (let e of h) r += e * 1.4;
936
939
  r === 0 && (r = s * 1.4);
@@ -938,22 +941,22 @@ function B(e, t) {
938
941
  if (i > o) {
939
942
  n.setAttribute("height", String(i));
940
943
  let r = e.querySelector("clipPath > rect");
941
- r instanceof Element && r.setAttribute("height", String(i)), Je(e), B(e, t);
944
+ r instanceof Element && r.setAttribute("height", String(i)), dt(e), z(e, t);
942
945
  }
943
946
  }
944
947
  }
945
- function Ye(e, t) {
948
+ function ft(e, t) {
946
949
  let n = e.parentNode;
947
950
  if (!n) throw Error("convertTextVariant: element is detached");
948
- let r = Ke({
949
- ...z(e),
951
+ let r = lt({
952
+ ...R(e),
950
953
  variant: t
951
954
  }), i = e.getAttribute("transform");
952
955
  return i && r.setAttribute("transform", i), n.replaceChild(r, e), r;
953
956
  }
954
957
  //#endregion
955
958
  //#region src/editor/property-schema.ts
956
- var V = {
959
+ var B = {
957
960
  shapeTypePicker: "shapeTypePicker",
958
961
  arrowVariantPicker: "arrowVariantPicker",
959
962
  drawStylePicker: "drawStylePicker",
@@ -993,54 +996,54 @@ var V = {
993
996
  arrowStartSize: "arrowStartSize",
994
997
  arrowEndShape: "arrowEndShape",
995
998
  arrowEndSize: "arrowEndSize"
996
- }, Xe = {
999
+ }, pt = {
997
1000
  textbox: [
998
- V.textVariantPicker,
999
- V.textColor,
1000
- V.fontFamily,
1001
- V.fontSize,
1002
- V.textBold,
1003
- V.textItalic,
1004
- V.textUnderline,
1005
- V.textAnchor,
1006
- V.textVerticalAnchor,
1007
- V.textAutofit,
1008
- V.textMarginLeft,
1009
- V.textMarginRight,
1010
- V.textMarginTop,
1011
- V.textMarginBottom
1001
+ B.textVariantPicker,
1002
+ B.textColor,
1003
+ B.fontFamily,
1004
+ B.fontSize,
1005
+ B.textBold,
1006
+ B.textItalic,
1007
+ B.textUnderline,
1008
+ B.textAnchor,
1009
+ B.textVerticalAnchor,
1010
+ B.textAutofit,
1011
+ B.textMarginLeft,
1012
+ B.textMarginRight,
1013
+ B.textMarginTop,
1014
+ B.textMarginBottom
1012
1015
  ],
1013
1016
  marker: [
1014
- V.markerShapePicker,
1015
- V.markerBgFillColor,
1016
- V.markerBgStrokeColor,
1017
- V.markerBgStrokeWidth,
1018
- V.markerBgStrokeStyle,
1019
- V.markerLabelValue,
1020
- V.markerSize
1017
+ B.markerShapePicker,
1018
+ B.markerBgFillColor,
1019
+ B.markerBgStrokeColor,
1020
+ B.markerBgStrokeWidth,
1021
+ B.markerBgStrokeStyle,
1022
+ B.markerLabelValue,
1023
+ B.markerSize
1021
1024
  ],
1022
- "redact-mosaic": [V.redactStylePicker],
1023
- "redact-solid": [V.redactStylePicker, V.redactSolidColor],
1024
- "redact-blur": [V.redactStylePicker],
1025
- highlight: [V.highlightColorPicker, V.highlightTransparency],
1025
+ "redact-mosaic": [B.redactStylePicker],
1026
+ "redact-solid": [B.redactStylePicker, B.redactSolidColor],
1027
+ "redact-blur": [B.redactStylePicker],
1028
+ highlight: [B.highlightColorPicker, B.highlightTransparency],
1026
1029
  group: [],
1027
1030
  shape: [
1028
- V.shapeTypePicker,
1029
- V.arrowVariantPicker,
1030
- V.drawStylePicker,
1031
- V.fillColor,
1032
- V.fillOpacity,
1033
- V.strokeColor,
1034
- V.strokeOpacity,
1035
- V.strokeWidth,
1036
- V.strokeStyle,
1037
- V.strokeLinecap,
1038
- V.arrowStartShape,
1039
- V.arrowStartSize,
1040
- V.arrowEndShape,
1041
- V.arrowEndSize
1031
+ B.shapeTypePicker,
1032
+ B.arrowVariantPicker,
1033
+ B.drawStylePicker,
1034
+ B.fillColor,
1035
+ B.fillOpacity,
1036
+ B.strokeColor,
1037
+ B.strokeOpacity,
1038
+ B.strokeWidth,
1039
+ B.strokeStyle,
1040
+ B.strokeLinecap,
1041
+ B.arrowStartShape,
1042
+ B.arrowStartSize,
1043
+ B.arrowEndShape,
1044
+ B.arrowEndSize
1042
1045
  ]
1043
- }, H = {
1046
+ }, V = {
1044
1047
  applyArrowVariant: "applyArrowVariant",
1045
1048
  applyDrawStyle: "applyDrawStyle",
1046
1049
  applyMarkerShape: "applyMarkerShape",
@@ -1052,27 +1055,27 @@ var V = {
1052
1055
  applyArrowEndShape: "applyArrowEndShape",
1053
1056
  applyArrowEndSize: "applyArrowEndSize"
1054
1057
  };
1055
- function Ze(e) {
1058
+ function mt(e) {
1056
1059
  let t = (e.getAttribute("data-arrow-start-shape") ?? "none") === "none", n = (e.getAttribute("data-arrow-end-shape") ?? "none") === "none";
1057
1060
  return t && n ? "none" : !t && !n ? "both" : "end";
1058
1061
  }
1059
- function Qe(e) {
1062
+ function ht(e) {
1060
1063
  let t = e.getAttribute("data-draw-style");
1061
1064
  if (t === "pen" || t === "highlighter") return t;
1062
1065
  if (e.tagName === "g" && e.getAttribute("data-type") === "freehand") {
1063
1066
  let t = e.querySelector("path");
1064
- if (t) return Qe(t);
1067
+ if (t) return ht(t);
1065
1068
  }
1066
1069
  return Number.parseFloat(e.getAttribute("stroke-opacity") || "1") < .99 ? "highlighter" : "pen";
1067
1070
  }
1068
- function $e(e) {
1071
+ function gt(e) {
1069
1072
  let t = e.getAttribute("data-shape");
1070
1073
  return t === "circle" || t === "rect" || t === "rounded" ? t : e.querySelector("circle, rect")?.tagName === "rect" ? "rect" : "circle";
1071
1074
  }
1072
- function U(e) {
1075
+ function H(e) {
1073
1076
  return e.querySelector("circle") ?? e.querySelector("rect");
1074
1077
  }
1075
- function W(e) {
1078
+ function U(e) {
1076
1079
  if (e.tagName === "g" && e.getAttribute("data-type") === "freehand") {
1077
1080
  let t = [];
1078
1081
  for (let n of Array.from(e.children)) n.tagName.toLowerCase() === "path" && t.push(n);
@@ -1080,17 +1083,17 @@ function W(e) {
1080
1083
  }
1081
1084
  return [e];
1082
1085
  }
1083
- function G(e, t) {
1086
+ function W(e, t) {
1084
1087
  return e.tagName === "g" ? e.querySelector("path, rect, line, circle")?.getAttribute(t) ?? e.getAttribute(t) : e.getAttribute(t);
1085
1088
  }
1086
- function et(e) {
1089
+ function _t(e) {
1087
1090
  return e.tagName === "g" && e.getAttribute("data-type") === "arrow";
1088
1091
  }
1089
- function tt(e) {
1090
- let t = N(e, "start").shape === "none", n = N(e, "end").shape === "none";
1092
+ function vt(e) {
1093
+ let t = M(e, "start").shape === "none", n = M(e, "end").shape === "none";
1091
1094
  return t && n ? "none" : !t && !n ? "both" : "end";
1092
1095
  }
1093
- function nt(e, t) {
1096
+ function yt(e, t) {
1094
1097
  let n = e === "start" ? "left" : "right";
1095
1098
  return [
1096
1099
  {
@@ -1123,10 +1126,10 @@ function nt(e, t) {
1123
1126
  }).map((e) => ({
1124
1127
  value: e.value,
1125
1128
  label: e.label,
1126
- iconSvg: we(e.value, n)
1129
+ iconSvg: Ve(e.value, n)
1127
1130
  }));
1128
1131
  }
1129
- function rt(e) {
1132
+ function bt(e) {
1130
1133
  let t = e === "start" ? "left" : "right", n = [
1131
1134
  "sm",
1132
1135
  "md",
@@ -1135,82 +1138,82 @@ function rt(e) {
1135
1138
  for (let e of n) for (let i of n) r.push({
1136
1139
  value: `${e}-${i}`,
1137
1140
  label: `W:${e.toUpperCase()} L:${i.toUpperCase()}`,
1138
- iconSvg: Ee(e, i, t)
1141
+ iconSvg: Ue(e, i, t)
1139
1142
  });
1140
1143
  return r;
1141
1144
  }
1142
- function it(e) {
1145
+ function xt(e) {
1143
1146
  let t = e.querySelector("text");
1144
1147
  return Number.parseFloat(t?.getAttribute("font-size") || "13");
1145
1148
  }
1146
- function at(e) {
1149
+ function St(e) {
1147
1150
  let t = e.getAttribute("data-redact-style");
1148
1151
  return t === "mosaic" || t === "solid" || t === "blur" ? t : "mosaic";
1149
1152
  }
1150
- function K(e) {
1153
+ function G(e) {
1151
1154
  return e.tagName === "line" ? !0 : e.tagName === "g" && e.getAttribute("data-type") === "arrow";
1152
1155
  }
1153
- function ot(e) {
1156
+ function Ct(e) {
1154
1157
  return e.tagName === "g" && e.getAttribute("data-type") === "freehand";
1155
1158
  }
1156
- var st = {
1159
+ var wt = {
1157
1160
  shapeTypePicker: {
1158
- id: V.shapeTypePicker,
1161
+ id: B.shapeTypePicker,
1159
1162
  type: "variantPicker",
1160
1163
  label: "Shape type",
1161
- getValue: (e) => Oe(e),
1162
- replace: (e, t) => je(e, t),
1163
- visibleWhen: (e) => Oe(e) !== null,
1164
+ getValue: (e) => Ge(e),
1165
+ replace: (e, t) => Je(e, t),
1166
+ visibleWhen: (e) => Ge(e) !== null,
1164
1167
  options: [
1165
1168
  {
1166
1169
  value: "rect",
1167
1170
  label: "Rectangle",
1168
- iconSvg: l.rect
1171
+ iconSvg: w.rect
1169
1172
  },
1170
1173
  {
1171
1174
  value: "rounded",
1172
1175
  label: "Rounded",
1173
- iconSvg: l.rounded
1176
+ iconSvg: w.rounded
1174
1177
  },
1175
1178
  {
1176
1179
  value: "ellipse",
1177
1180
  label: "Ellipse",
1178
- iconSvg: l.ellipse
1181
+ iconSvg: w.ellipse
1179
1182
  }
1180
1183
  ]
1181
1184
  },
1182
1185
  arrowVariantPicker: {
1183
- id: V.arrowVariantPicker,
1186
+ id: B.arrowVariantPicker,
1184
1187
  type: "variantPicker",
1185
1188
  label: "Arrow type",
1186
- getValue: (e) => Ze(e),
1187
- effect: H.applyArrowVariant,
1188
- visibleWhen: (e) => K(e),
1189
+ getValue: (e) => mt(e),
1190
+ effect: V.applyArrowVariant,
1191
+ visibleWhen: (e) => G(e),
1189
1192
  options: [
1190
1193
  {
1191
1194
  value: "none",
1192
1195
  label: "Line",
1193
- iconSvg: u.none
1196
+ iconSvg: T.none
1194
1197
  },
1195
1198
  {
1196
1199
  value: "end",
1197
1200
  label: "Arrow",
1198
- iconSvg: u.end
1201
+ iconSvg: T.end
1199
1202
  },
1200
1203
  {
1201
1204
  value: "both",
1202
1205
  label: "Double arrow",
1203
- iconSvg: u.both
1206
+ iconSvg: T.both
1204
1207
  }
1205
1208
  ]
1206
1209
  },
1207
1210
  drawStylePicker: {
1208
- id: V.drawStylePicker,
1211
+ id: B.drawStylePicker,
1209
1212
  type: "variantPicker",
1210
1213
  label: "Draw style",
1211
- getValue: (e) => Qe(e),
1212
- effect: H.applyDrawStyle,
1213
- visibleWhen: (e) => e.tagName === "path" || ot(e),
1214
+ getValue: (e) => ht(e),
1215
+ effect: V.applyDrawStyle,
1216
+ visibleWhen: (e) => e.tagName === "path" || Ct(e),
1214
1217
  options: [{
1215
1218
  value: "pen",
1216
1219
  label: "Pen",
@@ -1222,43 +1225,43 @@ var st = {
1222
1225
  }]
1223
1226
  },
1224
1227
  fillColor: {
1225
- id: V.fillColor,
1228
+ id: B.fillColor,
1226
1229
  type: "color",
1227
1230
  label: "Color",
1228
1231
  getValue: (e) => e.getAttribute("fill") ?? "none",
1229
1232
  setValue: (e, t) => {
1230
1233
  e.setAttribute("fill", String(t));
1231
1234
  },
1232
- visibleWhen: (e) => !K(e) && e.tagName !== "path" && !ot(e),
1235
+ visibleWhen: (e) => !G(e) && e.tagName !== "path" && !Ct(e),
1233
1236
  allowNone: !0
1234
1237
  },
1235
1238
  strokeColor: {
1236
- id: V.strokeColor,
1239
+ id: B.strokeColor,
1237
1240
  type: "color",
1238
1241
  label: "Color",
1239
- getValue: (e) => G(e, "stroke") ?? "#000000",
1242
+ getValue: (e) => W(e, "stroke") ?? "#000000",
1240
1243
  setValue: (e, t) => {
1241
1244
  let n = String(t);
1242
- for (let t of W(e)) t.setAttribute("stroke", n);
1243
- if (et(e)) {
1245
+ for (let t of U(e)) t.setAttribute("stroke", n);
1246
+ if (_t(e)) {
1244
1247
  let t = e.querySelector(":scope > [data-role=\"head-filled\"]");
1245
1248
  t && t.setAttribute("fill", n);
1246
1249
  }
1247
1250
  }
1248
1251
  },
1249
1252
  strokeWidth: {
1250
- id: V.strokeWidth,
1253
+ id: B.strokeWidth,
1251
1254
  type: "number",
1252
1255
  label: "Width",
1253
- getValue: (e) => Number.parseFloat(G(e, "stroke-width") || "0"),
1256
+ getValue: (e) => Number.parseFloat(W(e, "stroke-width") || "0"),
1254
1257
  setValue: (e, t) => {
1255
1258
  let n = Number(t);
1256
- for (let t of W(e)) {
1259
+ for (let t of U(e)) {
1257
1260
  t.setAttribute("stroke-width", String(n));
1258
1261
  let e = t.getAttribute("data-dash-key");
1259
1262
  e && t.setAttribute("stroke-dasharray", k(e, n));
1260
1263
  }
1261
- et(e) && Ce(e);
1264
+ _t(e) && Be(e);
1262
1265
  },
1263
1266
  min: .25,
1264
1267
  max: 200,
@@ -1266,18 +1269,18 @@ var st = {
1266
1269
  unit: "pt"
1267
1270
  },
1268
1271
  strokeStyle: {
1269
- id: V.strokeStyle,
1272
+ id: B.strokeStyle,
1270
1273
  type: "select",
1271
1274
  label: "Dash type",
1272
1275
  getValue: (e) => {
1273
- let t = G(e, "data-dash-key");
1276
+ let t = W(e, "data-dash-key");
1274
1277
  if (t != null) return t;
1275
- let n = Number.parseFloat(G(e, "stroke-width") || "1");
1276
- return A(G(e, "stroke-dasharray") || "", n) ?? "";
1278
+ let n = Number.parseFloat(W(e, "stroke-width") || "1");
1279
+ return Ee(W(e, "stroke-dasharray") || "", n) ?? "";
1277
1280
  },
1278
1281
  setValue: (e, t) => {
1279
1282
  let n = String(t);
1280
- for (let t of W(e)) {
1283
+ for (let t of U(e)) {
1281
1284
  let e = Number.parseFloat(t.getAttribute("stroke-width") || "1");
1282
1285
  n ? (t.setAttribute("data-dash-key", n), t.setAttribute("stroke-dasharray", k(n, e))) : (t.removeAttribute("data-dash-key"), t.removeAttribute("stroke-dasharray"));
1283
1286
  }
@@ -1306,11 +1309,11 @@ var st = {
1306
1309
  ]
1307
1310
  },
1308
1311
  textVariantPicker: {
1309
- id: V.textVariantPicker,
1312
+ id: B.textVariantPicker,
1310
1313
  type: "variantPicker",
1311
1314
  label: "Text type",
1312
- getValue: (e) => Ue(e),
1313
- replace: (e, t) => Ye(e, t),
1315
+ getValue: (e) => ot(e),
1316
+ replace: (e, t) => ft(e, t),
1314
1317
  options: [
1315
1318
  {
1316
1319
  value: "plain",
@@ -1330,19 +1333,19 @@ var st = {
1330
1333
  ]
1331
1334
  },
1332
1335
  textColor: {
1333
- id: V.textColor,
1336
+ id: B.textColor,
1334
1337
  type: "color",
1335
1338
  label: "Color",
1336
1339
  getValue: (e) => e.querySelector("text")?.getAttribute("fill") ?? "#ff0000",
1337
- effect: H.applyTextColor
1340
+ effect: V.applyTextColor
1338
1341
  },
1339
1342
  fontFamily: {
1340
- id: V.fontFamily,
1343
+ id: B.fontFamily,
1341
1344
  type: "select",
1342
1345
  label: "Font",
1343
- getValue: (e) => o(e.getAttribute("data-font-family") ?? e.querySelector("text")?.getAttribute("font-family")),
1346
+ getValue: (e) => S(e.getAttribute("data-font-family") ?? e.querySelector("text")?.getAttribute("font-family")),
1344
1347
  setValue: (e, t) => {
1345
- let n = o(String(t));
1348
+ let n = S(String(t));
1346
1349
  e.setAttribute("data-font-family", n), e.querySelector("text")?.setAttribute("font-family", n);
1347
1350
  },
1348
1351
  options: [
@@ -1361,15 +1364,15 @@ var st = {
1361
1364
  ]
1362
1365
  },
1363
1366
  fontSize: {
1364
- id: V.fontSize,
1367
+ id: B.fontSize,
1365
1368
  type: "number",
1366
1369
  label: "Size",
1367
1370
  getValue: (e) => Number.parseFloat(e.querySelector("text")?.getAttribute("font-size") || "16"),
1368
1371
  setValue: (e, t) => {
1369
1372
  let n = Number(t);
1370
- if (e.querySelector("text")?.setAttribute("font-size", String(n)), e.setAttribute("data-font-size", String(n)), He(e)) {
1371
- let t = z(e).runs;
1372
- B(e, t);
1373
+ if (e.querySelector("text")?.setAttribute("font-size", String(n)), e.setAttribute("data-font-size", String(n)), at(e)) {
1374
+ let t = R(e).runs;
1375
+ z(e, t);
1373
1376
  }
1374
1377
  },
1375
1378
  min: 8,
@@ -1378,15 +1381,15 @@ var st = {
1378
1381
  unit: "pt"
1379
1382
  },
1380
1383
  textAnchor: {
1381
- id: V.textAnchor,
1384
+ id: B.textAnchor,
1382
1385
  type: "select",
1383
1386
  label: "Align",
1384
1387
  getValue: (e) => e.getAttribute("data-text-anchor") ?? "start",
1385
1388
  setValue: (e, t) => {
1386
1389
  let n = String(t);
1387
1390
  e.setAttribute("data-text-anchor", n);
1388
- let r = z(e).runs;
1389
- B(e, r);
1391
+ let r = R(e).runs;
1392
+ z(e, r);
1390
1393
  },
1391
1394
  options: [
1392
1395
  {
@@ -1407,15 +1410,15 @@ var st = {
1407
1410
  ]
1408
1411
  },
1409
1412
  textVerticalAnchor: {
1410
- id: V.textVerticalAnchor,
1413
+ id: B.textVerticalAnchor,
1411
1414
  type: "select",
1412
1415
  label: "V-Align",
1413
1416
  getValue: (e) => e.getAttribute("data-text-vanchor") ?? "top",
1414
1417
  setValue: (e, t) => {
1415
1418
  let n = String(t);
1416
1419
  e.setAttribute("data-text-vanchor", n);
1417
- let r = z(e).runs;
1418
- B(e, r);
1420
+ let r = R(e).runs;
1421
+ z(e, r);
1419
1422
  },
1420
1423
  options: [
1421
1424
  {
@@ -1436,15 +1439,15 @@ var st = {
1436
1439
  ]
1437
1440
  },
1438
1441
  textAutofit: {
1439
- id: V.textAutofit,
1442
+ id: B.textAutofit,
1440
1443
  type: "select",
1441
1444
  label: "Autofit",
1442
1445
  getValue: (e) => e.getAttribute("data-text-autofit") || "none",
1443
1446
  setValue: (e, t) => {
1444
1447
  let n = String(t);
1445
1448
  n === "none" ? e.removeAttribute("data-text-autofit") : e.setAttribute("data-text-autofit", n);
1446
- let r = z(e).runs;
1447
- B(e, r);
1449
+ let r = R(e).runs;
1450
+ z(e, r);
1448
1451
  },
1449
1452
  options: [
1450
1453
  {
@@ -1461,19 +1464,19 @@ var st = {
1461
1464
  }
1462
1465
  ]
1463
1466
  },
1464
- textMarginLeft: q(V.textMarginLeft, "Margin L", "data-text-margin-l"),
1465
- textMarginRight: q(V.textMarginRight, "Margin R", "data-text-margin-r"),
1466
- textMarginTop: q(V.textMarginTop, "Margin T", "data-text-margin-t"),
1467
- textMarginBottom: q(V.textMarginBottom, "Margin B", "data-text-margin-b"),
1468
- textBold: lt(V.textBold, "Bold", "font-weight", "bold", (e) => e === "bold" || e === "700"),
1469
- textItalic: lt(V.textItalic, "Italic", "font-style", "italic", (e) => e === "italic"),
1470
- textUnderline: lt(V.textUnderline, "Underline", "text-decoration", "underline", (e) => e.includes("underline")),
1467
+ textMarginLeft: K(B.textMarginLeft, "Margin L", "data-text-margin-l"),
1468
+ textMarginRight: K(B.textMarginRight, "Margin R", "data-text-margin-r"),
1469
+ textMarginTop: K(B.textMarginTop, "Margin T", "data-text-margin-t"),
1470
+ textMarginBottom: K(B.textMarginBottom, "Margin B", "data-text-margin-b"),
1471
+ textBold: Et(B.textBold, "Bold", "font-weight", "bold", (e) => e === "bold" || e === "700"),
1472
+ textItalic: Et(B.textItalic, "Italic", "font-style", "italic", (e) => e === "italic"),
1473
+ textUnderline: Et(B.textUnderline, "Underline", "text-decoration", "underline", (e) => e.includes("underline")),
1471
1474
  redactStylePicker: {
1472
- id: V.redactStylePicker,
1475
+ id: B.redactStylePicker,
1473
1476
  type: "variantPicker",
1474
1477
  label: "Redact style",
1475
- getValue: (e) => at(e),
1476
- effect: H.applyRedactStyle,
1478
+ getValue: (e) => St(e),
1479
+ effect: V.applyRedactStyle,
1477
1480
  options: [
1478
1481
  {
1479
1482
  value: "mosaic",
@@ -1493,31 +1496,31 @@ var st = {
1493
1496
  ]
1494
1497
  },
1495
1498
  redactSolidColor: {
1496
- id: V.redactSolidColor,
1499
+ id: B.redactSolidColor,
1497
1500
  type: "color",
1498
1501
  label: "Color",
1499
1502
  getValue: (e) => e.getAttribute("fill") ?? "#111111",
1500
1503
  setValue: (e, t) => {
1501
1504
  e.setAttribute("fill", String(t));
1502
1505
  },
1503
- visibleWhen: (e) => at(e) === "solid"
1506
+ visibleWhen: (e) => St(e) === "solid"
1504
1507
  },
1505
1508
  highlightColorPicker: {
1506
- id: V.highlightColorPicker,
1509
+ id: B.highlightColorPicker,
1507
1510
  type: "variantPicker",
1508
1511
  label: "Highlight color",
1509
- getValue: (e) => (e.getAttribute("fill") ?? f[0]?.value ?? "#ffff00").toLowerCase(),
1512
+ getValue: (e) => (e.getAttribute("fill") ?? D[0]?.value ?? "#ffff00").toLowerCase(),
1510
1513
  setValue: (e, t) => {
1511
1514
  e.setAttribute("fill", String(t));
1512
1515
  },
1513
- options: f.map((e) => ({
1516
+ options: D.map((e) => ({
1514
1517
  value: e.value,
1515
1518
  label: e.label,
1516
1519
  swatchColor: e.value
1517
1520
  }))
1518
1521
  },
1519
1522
  highlightTransparency: {
1520
- id: V.highlightTransparency,
1523
+ id: B.highlightTransparency,
1521
1524
  type: "number",
1522
1525
  label: "Transparency",
1523
1526
  getValue: (e) => {
@@ -1534,66 +1537,66 @@ var st = {
1534
1537
  unit: "%"
1535
1538
  },
1536
1539
  markerShapePicker: {
1537
- id: V.markerShapePicker,
1540
+ id: B.markerShapePicker,
1538
1541
  type: "variantPicker",
1539
1542
  label: "Counter shape",
1540
- getValue: (e) => $e(e),
1541
- effect: H.applyMarkerShape,
1543
+ getValue: (e) => gt(e),
1544
+ effect: V.applyMarkerShape,
1542
1545
  options: [
1543
1546
  {
1544
1547
  value: "circle",
1545
1548
  label: "Circle",
1546
- iconSvg: d.circle
1549
+ iconSvg: E.circle
1547
1550
  },
1548
1551
  {
1549
1552
  value: "rect",
1550
1553
  label: "Square",
1551
- iconSvg: d.rect
1554
+ iconSvg: E.rect
1552
1555
  },
1553
1556
  {
1554
1557
  value: "rounded",
1555
1558
  label: "Rounded square",
1556
- iconSvg: d.rounded
1559
+ iconSvg: E.rounded
1557
1560
  }
1558
1561
  ]
1559
1562
  },
1560
1563
  markerSize: {
1561
- id: V.markerSize,
1564
+ id: B.markerSize,
1562
1565
  type: "number",
1563
1566
  label: "Size",
1564
- getValue: (e) => it(e),
1565
- effect: H.resizeMarker,
1567
+ getValue: (e) => xt(e),
1568
+ effect: V.resizeMarker,
1566
1569
  min: 8,
1567
1570
  max: 96,
1568
1571
  step: 1,
1569
1572
  unit: "pt"
1570
1573
  },
1571
1574
  markerBgFillColor: {
1572
- id: V.markerBgFillColor,
1575
+ id: B.markerBgFillColor,
1573
1576
  type: "color",
1574
1577
  label: "Color",
1575
- getValue: (e) => U(e)?.getAttribute("fill") ?? "#ff0000",
1578
+ getValue: (e) => H(e)?.getAttribute("fill") ?? "#ff0000",
1576
1579
  setValue: (e, t) => {
1577
- U(e)?.setAttribute("fill", String(t));
1580
+ H(e)?.setAttribute("fill", String(t));
1578
1581
  },
1579
1582
  allowNone: !0
1580
1583
  },
1581
1584
  markerBgStrokeColor: {
1582
- id: V.markerBgStrokeColor,
1585
+ id: B.markerBgStrokeColor,
1583
1586
  type: "color",
1584
1587
  label: "Color",
1585
- getValue: (e) => U(e)?.getAttribute("stroke") ?? "#ffffff",
1588
+ getValue: (e) => H(e)?.getAttribute("stroke") ?? "#ffffff",
1586
1589
  setValue: (e, t) => {
1587
- U(e)?.setAttribute("stroke", String(t));
1590
+ H(e)?.setAttribute("stroke", String(t));
1588
1591
  }
1589
1592
  },
1590
1593
  markerBgStrokeWidth: {
1591
- id: V.markerBgStrokeWidth,
1594
+ id: B.markerBgStrokeWidth,
1592
1595
  type: "number",
1593
1596
  label: "Width",
1594
- getValue: (e) => Number.parseFloat(U(e)?.getAttribute("stroke-width") || "1.5"),
1597
+ getValue: (e) => Number.parseFloat(H(e)?.getAttribute("stroke-width") || "1.5"),
1595
1598
  setValue: (e, t) => {
1596
- let n = U(e);
1599
+ let n = H(e);
1597
1600
  if (!n) return;
1598
1601
  let r = Number(t);
1599
1602
  n.setAttribute("stroke-width", String(r));
@@ -1606,19 +1609,19 @@ var st = {
1606
1609
  unit: "pt"
1607
1610
  },
1608
1611
  markerBgStrokeStyle: {
1609
- id: V.markerBgStrokeStyle,
1612
+ id: B.markerBgStrokeStyle,
1610
1613
  type: "select",
1611
1614
  label: "Dash type",
1612
1615
  getValue: (e) => {
1613
- let t = U(e);
1616
+ let t = H(e);
1614
1617
  if (!t) return "";
1615
1618
  let n = t.getAttribute("data-dash-key");
1616
1619
  if (n != null) return n;
1617
1620
  let r = Number.parseFloat(t.getAttribute("stroke-width") || "1.5");
1618
- return A(t.getAttribute("stroke-dasharray") || "", r) ?? "";
1621
+ return Ee(t.getAttribute("stroke-dasharray") || "", r) ?? "";
1619
1622
  },
1620
1623
  setValue: (e, t) => {
1621
- let n = U(e);
1624
+ let n = H(e);
1622
1625
  if (!n) return;
1623
1626
  let r = String(t), i = Number.parseFloat(n.getAttribute("stroke-width") || "1.5");
1624
1627
  r ? (n.setAttribute("data-dash-key", r), n.setAttribute("stroke-dasharray", k(r, i))) : (n.removeAttribute("data-dash-key"), n.removeAttribute("stroke-dasharray"));
@@ -1647,7 +1650,7 @@ var st = {
1647
1650
  ]
1648
1651
  },
1649
1652
  markerLabelValue: {
1650
- id: V.markerLabelValue,
1653
+ id: B.markerLabelValue,
1651
1654
  type: "number",
1652
1655
  label: "Value",
1653
1656
  getValue: (e) => {
@@ -1665,34 +1668,34 @@ var st = {
1665
1668
  step: 1
1666
1669
  },
1667
1670
  fillOpacity: {
1668
- id: V.fillOpacity,
1671
+ id: B.fillOpacity,
1669
1672
  type: "number",
1670
1673
  label: "Transparency",
1671
1674
  getValue: (e) => {
1672
- let t = Number.parseFloat(G(e, "fill-opacity") || "1");
1675
+ let t = Number.parseFloat(W(e, "fill-opacity") || "1");
1673
1676
  return Math.round((1 - (Number.isFinite(t) ? t : 1)) * 100);
1674
1677
  },
1675
1678
  setValue: (e, t) => {
1676
1679
  let n = 1 - Number(t) / 100;
1677
1680
  e.setAttribute("fill-opacity", String(n));
1678
1681
  },
1679
- visibleWhen: (e) => !K(e) && e.tagName !== "path" && !ot(e),
1682
+ visibleWhen: (e) => !G(e) && e.tagName !== "path" && !Ct(e),
1680
1683
  min: 0,
1681
1684
  max: 100,
1682
1685
  step: 1,
1683
1686
  unit: "%"
1684
1687
  },
1685
1688
  strokeOpacity: {
1686
- id: V.strokeOpacity,
1689
+ id: B.strokeOpacity,
1687
1690
  type: "number",
1688
1691
  label: "Transparency",
1689
1692
  getValue: (e) => {
1690
- let t = e.getAttribute("opacity") ?? (G(e, "stroke-opacity") || "1"), n = Number.parseFloat(t);
1693
+ let t = e.getAttribute("opacity") ?? (W(e, "stroke-opacity") || "1"), n = Number.parseFloat(t);
1691
1694
  return Math.round((1 - (Number.isFinite(n) ? n : 1)) * 100);
1692
1695
  },
1693
1696
  setValue: (e, t) => {
1694
1697
  let n = 1 - Number(t) / 100;
1695
- for (let t of W(e)) K(t) ? (t.setAttribute("opacity", String(n)), t.removeAttribute("stroke-opacity")) : t.setAttribute("stroke-opacity", String(n));
1698
+ for (let t of U(e)) G(t) ? (t.setAttribute("opacity", String(n)), t.removeAttribute("stroke-opacity")) : t.setAttribute("stroke-opacity", String(n));
1696
1699
  },
1697
1700
  min: 0,
1698
1701
  max: 100,
@@ -1700,13 +1703,13 @@ var st = {
1700
1703
  unit: "%"
1701
1704
  },
1702
1705
  strokeLinecap: {
1703
- id: V.strokeLinecap,
1706
+ id: B.strokeLinecap,
1704
1707
  type: "select",
1705
1708
  label: "Cap type",
1706
- getValue: (e) => G(e, "stroke-linecap") ?? "butt",
1709
+ getValue: (e) => W(e, "stroke-linecap") ?? "butt",
1707
1710
  setValue: (e, t) => {
1708
1711
  let n = String(t);
1709
- for (let t of W(e)) t.setAttribute("stroke-linecap", n);
1712
+ for (let t of U(e)) t.setAttribute("stroke-linecap", n);
1710
1713
  },
1711
1714
  options: [
1712
1715
  {
@@ -1724,57 +1727,57 @@ var st = {
1724
1727
  ]
1725
1728
  },
1726
1729
  arrowStartShape: {
1727
- id: V.arrowStartShape,
1730
+ id: B.arrowStartShape,
1728
1731
  type: "select",
1729
1732
  label: "Begin arrow type",
1730
- getValue: (e) => N(e, "start").shape,
1731
- effect: H.applyArrowStartShape,
1732
- visibleWhen: K,
1733
- getOptions: (e) => nt("start", tt(e)),
1733
+ getValue: (e) => M(e, "start").shape,
1734
+ effect: V.applyArrowStartShape,
1735
+ visibleWhen: G,
1736
+ getOptions: (e) => yt("start", vt(e)),
1734
1737
  selectColumns: 3,
1735
1738
  selectPopupWidth: 170
1736
1739
  },
1737
1740
  arrowStartSize: {
1738
- id: V.arrowStartSize,
1741
+ id: B.arrowStartSize,
1739
1742
  type: "select",
1740
1743
  label: "Begin arrow size",
1741
1744
  getValue: (e) => {
1742
- let t = N(e, "start");
1745
+ let t = M(e, "start");
1743
1746
  return `${t.width}-${t.length}`;
1744
1747
  },
1745
- effect: H.applyArrowStartSize,
1746
- visibleWhen: K,
1747
- options: rt("start"),
1748
+ effect: V.applyArrowStartSize,
1749
+ visibleWhen: G,
1750
+ options: bt("start"),
1748
1751
  selectColumns: 3,
1749
1752
  selectPopupWidth: 180
1750
1753
  },
1751
1754
  arrowEndShape: {
1752
- id: V.arrowEndShape,
1755
+ id: B.arrowEndShape,
1753
1756
  type: "select",
1754
1757
  label: "End arrow type",
1755
- getValue: (e) => N(e, "end").shape,
1756
- effect: H.applyArrowEndShape,
1757
- visibleWhen: K,
1758
- getOptions: (e) => nt("end", tt(e)),
1758
+ getValue: (e) => M(e, "end").shape,
1759
+ effect: V.applyArrowEndShape,
1760
+ visibleWhen: G,
1761
+ getOptions: (e) => yt("end", vt(e)),
1759
1762
  selectColumns: 3,
1760
1763
  selectPopupWidth: 170
1761
1764
  },
1762
1765
  arrowEndSize: {
1763
- id: V.arrowEndSize,
1766
+ id: B.arrowEndSize,
1764
1767
  type: "select",
1765
1768
  label: "End arrow size",
1766
1769
  getValue: (e) => {
1767
- let t = N(e, "end");
1770
+ let t = M(e, "end");
1768
1771
  return `${t.width}-${t.length}`;
1769
1772
  },
1770
- effect: H.applyArrowEndSize,
1771
- visibleWhen: K,
1772
- options: rt("end"),
1773
+ effect: V.applyArrowEndSize,
1774
+ visibleWhen: G,
1775
+ options: bt("end"),
1773
1776
  selectColumns: 3,
1774
1777
  selectPopupWidth: 180
1775
1778
  }
1776
1779
  };
1777
- function ct(e) {
1780
+ function Tt(e) {
1778
1781
  let t = e.tagName;
1779
1782
  if (t === "g") {
1780
1783
  let t = e.getAttribute("data-type");
@@ -1787,7 +1790,7 @@ function ct(e) {
1787
1790
  let n = e.getAttribute("data-redact-style");
1788
1791
  return n === "mosaic" ? "redact-mosaic" : n === "solid" ? "redact-solid" : n === "blur" ? "redact-blur" : "shape";
1789
1792
  }
1790
- function q(e, t, n) {
1793
+ function K(e, t, n) {
1791
1794
  return {
1792
1795
  id: e,
1793
1796
  type: "number",
@@ -1802,8 +1805,8 @@ function q(e, t, n) {
1802
1805
  let r = Number(t);
1803
1806
  if (!Number.isFinite(r) || r < 0) return;
1804
1807
  e.setAttribute(n, String(r));
1805
- let i = z(e).runs;
1806
- B(e, i);
1808
+ let i = R(e).runs;
1809
+ z(e, i);
1807
1810
  },
1808
1811
  min: 0,
1809
1812
  max: 200,
@@ -1811,7 +1814,7 @@ function q(e, t, n) {
1811
1814
  unit: "px"
1812
1815
  };
1813
1816
  }
1814
- function lt(e, t, n, r, i) {
1817
+ function Et(e, t, n, r, i) {
1815
1818
  return {
1816
1819
  id: e,
1817
1820
  type: "select",
@@ -1836,13 +1839,13 @@ function lt(e, t, n, r, i) {
1836
1839
  }]
1837
1840
  };
1838
1841
  }
1839
- function ut(e) {
1842
+ function Dt(e) {
1840
1843
  if (e.length === 0) return {
1841
1844
  category: null,
1842
1845
  uniform: !0
1843
1846
  };
1844
- let t = ct(e[0]);
1845
- for (let n = 1; n < e.length; n++) if (ct(e[n]) !== t) return {
1847
+ let t = Tt(e[0]);
1848
+ for (let n = 1; n < e.length; n++) if (Tt(e[n]) !== t) return {
1846
1849
  category: t,
1847
1850
  uniform: !1
1848
1851
  };
@@ -1853,14 +1856,14 @@ function ut(e) {
1853
1856
  }
1854
1857
  //#endregion
1855
1858
  //#region src/editor/selection-geometry.ts
1856
- function dt(e, t, n, r, i) {
1859
+ function Ot(e, t, n, r, i) {
1857
1860
  let a = Math.cos(i), o = Math.sin(i);
1858
1861
  return {
1859
1862
  x: n + (e - n) * a - (t - r) * o,
1860
1863
  y: r + (e - n) * o + (t - r) * a
1861
1864
  };
1862
1865
  }
1863
- var ft = [
1866
+ var kt = [
1864
1867
  "ew-resize",
1865
1868
  "nwse-resize",
1866
1869
  "ns-resize",
@@ -1870,11 +1873,11 @@ var ft = [
1870
1873
  "ns-resize",
1871
1874
  "nesw-resize"
1872
1875
  ];
1873
- function pt(e) {
1876
+ function At(e) {
1874
1877
  let t = Math.PI * 2, n = (e % t + t) % t;
1875
- return n += Math.PI / 8, n >= t && (n -= t), ft[Math.floor(n / (Math.PI / 4)) % 8];
1878
+ return n += Math.PI / 8, n >= t && (n -= t), kt[Math.floor(n / (Math.PI / 4)) % 8];
1876
1879
  }
1877
- function mt(e) {
1880
+ function jt(e) {
1878
1881
  let t = Infinity, n = Infinity, r = -Infinity, i = -Infinity;
1879
1882
  for (let a of e) a.x < t && (t = a.x), a.y < n && (n = a.y), a.x + a.width > r && (r = a.x + a.width), a.y + a.height > i && (i = a.y + a.height);
1880
1883
  return {
@@ -1884,14 +1887,14 @@ function mt(e) {
1884
1887
  height: i - n
1885
1888
  };
1886
1889
  }
1887
- function ht(e) {
1890
+ function Mt(e) {
1888
1891
  let { draggedBoxes: t, dx: n, dy: r, otherBoxes: i, threshold: a } = e;
1889
1892
  if (t.length === 0 || i.length === 0) return {
1890
1893
  dx: n,
1891
1894
  dy: r,
1892
1895
  guides: []
1893
1896
  };
1894
- let o = mt(t), s = {
1897
+ let o = jt(t), s = {
1895
1898
  left: o.x + n,
1896
1899
  right: o.x + o.width + n,
1897
1900
  centerX: o.x + o.width / 2 + n,
@@ -1964,20 +1967,20 @@ function ht(e) {
1964
1967
  }
1965
1968
  //#endregion
1966
1969
  //#region src/editor/svg-format.ts
1967
- var gt = "1", _t = "0", vt = "data-annot-version";
1968
- function yt(e) {
1969
- e.setAttribute(vt, "1");
1970
+ var Nt = "1", Pt = "0", Ft = "data-annot-version";
1971
+ function It(e) {
1972
+ e.setAttribute(Ft, "1");
1970
1973
  }
1971
- function bt(e) {
1974
+ function Lt(e) {
1972
1975
  return e.getAttribute("data-annot-version") || "0";
1973
1976
  }
1974
- function xt(e) {
1977
+ function Rt(e) {
1975
1978
  let t = /\sdata-annot-version="([^"]*)"/.exec(e);
1976
1979
  return t ? t[1] : "0";
1977
1980
  }
1978
1981
  //#endregion
1979
1982
  //#region src/editor/tool-lifecycle.ts
1980
- function St(e) {
1983
+ function zt(e) {
1981
1984
  let t = [], n = [], r = {
1982
1985
  drafts: t,
1983
1986
  committed: n,
@@ -1996,32 +1999,32 @@ function St(e) {
1996
1999
  }
1997
2000
  //#endregion
1998
2001
  //#region src/editor/tool-style-writer.ts
1999
- function J(e, t) {
2002
+ function q(e, t) {
2000
2003
  t.strokeColor && e.setAttribute("stroke", t.strokeColor), t.strokeWidth != null && e.setAttribute("stroke-width", String(t.strokeWidth)), t.strokeDasharray != null && (e.setAttribute("stroke-dasharray", k(t.strokeDasharray, t.strokeWidth)), e.setAttribute("data-dash-key", t.strokeDasharray)), t.fillColor && e.setAttribute("fill", t.fillColor), t.fillOpacity != null && e.setAttribute("fill-opacity", String(t.fillOpacity)), t.strokeLinecap && e.setAttribute("stroke-linecap", t.strokeLinecap), t.strokeLinejoin && e.setAttribute("stroke-linejoin", t.strokeLinejoin), t.strokeOpacity != null && (e.tagName === "line" || e.tagName === "g" && e.getAttribute("data-type") === "arrow" ? e.setAttribute("opacity", String(t.strokeOpacity)) : e.setAttribute("stroke-opacity", String(t.strokeOpacity)));
2001
2004
  }
2002
2005
  //#endregion
2003
2006
  //#region src/editor/tool-registry.ts
2004
- var Ct = [
2007
+ var Bt = [
2005
2008
  "tool.typeChips",
2006
2009
  "tool.transparencyPercent",
2007
2010
  "tool.fillTransparencyPercent",
2008
2011
  "tool.fillOpacityPercent",
2009
2012
  "tool.freehandDone"
2010
- ], Y = [
2013
+ ], J = [
2011
2014
  "strokeColor",
2012
2015
  "strokeWidth",
2013
2016
  "strokeDasharray",
2014
2017
  "strokeOpacity",
2015
2018
  "strokeLinecap"
2016
2019
  ];
2017
- function wt(e) {
2020
+ function Vt(e) {
2018
2021
  return e.getAttribute("data-highlight") === "1" || e.getAttribute("data-redact-style") === "solid" ? null : e.hasAttribute("data-rounded") ? "rounded" : "rect";
2019
2022
  }
2020
- function Tt(e) {
2023
+ function Ht(e) {
2021
2024
  let t = (e.getAttribute("data-arrow-start-shape") ?? "none") !== "none", n = (e.getAttribute("data-arrow-end-shape") ?? "none") !== "none";
2022
2025
  return t && n ? "both" : t || n ? "end" : "none";
2023
2026
  }
2024
- function Et(e, t, n) {
2027
+ function Ut(e, t, n) {
2025
2028
  if (e !== "arrow") return;
2026
2029
  let r = n, i = "triangle", a = "none", o = n.arrowHeadStart, s = n.arrowHeadEnd;
2027
2030
  switch (t) {
@@ -2036,7 +2039,7 @@ function Et(e, t, n) {
2036
2039
  break;
2037
2040
  }
2038
2041
  }
2039
- var Dt = {
2042
+ var Wt = {
2040
2043
  arrow: {
2041
2044
  id: "arrow",
2042
2045
  label: "Line",
@@ -2048,23 +2051,23 @@ var Dt = {
2048
2051
  value: "none",
2049
2052
  icon: "horizontal_rule",
2050
2053
  label: "Line (no arrow)",
2051
- svg: u.none
2054
+ svg: T.none
2052
2055
  },
2053
2056
  {
2054
2057
  value: "end",
2055
2058
  icon: "north_east",
2056
2059
  label: "Arrow",
2057
- svg: u.end
2060
+ svg: T.end
2058
2061
  },
2059
2062
  {
2060
2063
  value: "both",
2061
2064
  icon: "sync_alt",
2062
2065
  label: "Double arrow",
2063
- svg: u.both
2066
+ svg: T.both
2064
2067
  }
2065
2068
  ],
2066
2069
  presetFields: [
2067
- ...Y,
2070
+ ...J,
2068
2071
  "arrowHead",
2069
2072
  "arrowHeadStart",
2070
2073
  "arrowHeadEnd",
@@ -2080,7 +2083,7 @@ var Dt = {
2080
2083
  },
2081
2084
  {
2082
2085
  section: "Line",
2083
- id: V.strokeColor
2086
+ id: B.strokeColor
2084
2087
  },
2085
2088
  {
2086
2089
  section: "Line",
@@ -2088,43 +2091,43 @@ var Dt = {
2088
2091
  },
2089
2092
  {
2090
2093
  section: "Line",
2091
- id: V.strokeWidth
2094
+ id: B.strokeWidth
2092
2095
  },
2093
2096
  {
2094
2097
  section: "Line",
2095
- id: V.strokeStyle
2098
+ id: B.strokeStyle
2096
2099
  },
2097
2100
  {
2098
2101
  section: "Line",
2099
- id: V.strokeLinecap
2102
+ id: B.strokeLinecap
2100
2103
  },
2101
2104
  {
2102
2105
  section: "Line",
2103
- id: V.arrowStartShape
2106
+ id: B.arrowStartShape
2104
2107
  },
2105
2108
  {
2106
2109
  section: "Line",
2107
- id: V.arrowStartSize
2110
+ id: B.arrowStartSize
2108
2111
  },
2109
2112
  {
2110
2113
  section: "Line",
2111
- id: V.arrowEndShape
2114
+ id: B.arrowEndShape
2112
2115
  },
2113
2116
  {
2114
2117
  section: "Line",
2115
- id: V.arrowEndSize
2118
+ id: B.arrowEndSize
2116
2119
  }
2117
2120
  ],
2118
2121
  variantKeyForElement(e) {
2119
- return e.tagName === "line" || e.tagName === "g" && e.getAttribute("data-type") === "arrow" ? `arrow.${Tt(e)}` : null;
2122
+ return e.tagName === "line" || e.tagName === "g" && e.getAttribute("data-type") === "arrow" ? `arrow.${Ht(e)}` : null;
2120
2123
  },
2121
2124
  extractStyleFromElement(e, t) {
2122
- t.arrowHead = Tt(e);
2125
+ t.arrowHead = Ht(e);
2123
2126
  let n = e.getAttribute("data-arrow-start-shape"), r = e.getAttribute("data-arrow-end-shape"), i = e.getAttribute("data-arrow-start-width"), a = e.getAttribute("data-arrow-start-length"), o = e.getAttribute("data-arrow-end-width"), s = e.getAttribute("data-arrow-end-length");
2124
- n && (t.arrowHeadStart = n), r && (t.arrowHeadEnd = r), i && (t.arrowWidthStart = i), a && (t.arrowLengthStart = a), o && (t.arrowWidthEnd = o), s && (t.arrowLengthEnd = s), Et("arrow", t.arrowHead, t);
2127
+ n && (t.arrowHeadStart = n), r && (t.arrowHeadEnd = r), i && (t.arrowWidthStart = i), a && (t.arrowLengthStart = a), o && (t.arrowWidthEnd = o), s && (t.arrowLengthEnd = s), Ut("arrow", t.arrowHead, t);
2125
2128
  },
2126
2129
  applyStyleToElement(e, t) {
2127
- J(e, t), e.tagName === "g" && e.getAttribute("data-type") === "arrow" && Ce(e);
2130
+ q(e, t), e.tagName === "g" && e.getAttribute("data-type") === "arrow" && Be(e);
2128
2131
  }
2129
2132
  },
2130
2133
  shape: {
@@ -2138,23 +2141,23 @@ var Dt = {
2138
2141
  value: "rect",
2139
2142
  icon: "rectangle",
2140
2143
  label: "Rectangle",
2141
- svg: l.rect
2144
+ svg: w.rect
2142
2145
  },
2143
2146
  {
2144
2147
  value: "rounded",
2145
2148
  icon: "crop_square",
2146
2149
  label: "Rounded rectangle",
2147
- svg: l.rounded
2150
+ svg: w.rounded
2148
2151
  },
2149
2152
  {
2150
2153
  value: "ellipse",
2151
2154
  icon: "circle",
2152
2155
  label: "Ellipse",
2153
- svg: l.ellipse
2156
+ svg: w.ellipse
2154
2157
  }
2155
2158
  ],
2156
2159
  presetFields: [
2157
- ...Y,
2160
+ ...J,
2158
2161
  "fillColor",
2159
2162
  "fillOpacity",
2160
2163
  "shapeType",
@@ -2167,7 +2170,7 @@ var Dt = {
2167
2170
  },
2168
2171
  {
2169
2172
  section: "Fill",
2170
- id: V.fillColor
2173
+ id: B.fillColor
2171
2174
  },
2172
2175
  {
2173
2176
  section: "Fill",
@@ -2175,7 +2178,7 @@ var Dt = {
2175
2178
  },
2176
2179
  {
2177
2180
  section: "Line",
2178
- id: V.strokeColor
2181
+ id: B.strokeColor
2179
2182
  },
2180
2183
  {
2181
2184
  section: "Line",
@@ -2183,21 +2186,21 @@ var Dt = {
2183
2186
  },
2184
2187
  {
2185
2188
  section: "Line",
2186
- id: V.strokeWidth
2189
+ id: B.strokeWidth
2187
2190
  },
2188
2191
  {
2189
2192
  section: "Line",
2190
- id: V.strokeStyle
2193
+ id: B.strokeStyle
2191
2194
  },
2192
2195
  {
2193
2196
  section: "Line",
2194
- id: V.strokeLinecap
2197
+ id: B.strokeLinecap
2195
2198
  }
2196
2199
  ],
2197
2200
  variantKeyForElement(e) {
2198
2201
  if (e.tagName === "ellipse") return "shape.ellipse";
2199
2202
  if (e.tagName === "rect") {
2200
- let t = wt(e);
2203
+ let t = Vt(e);
2201
2204
  return t ? `shape.${t}` : null;
2202
2205
  }
2203
2206
  return null;
@@ -2206,7 +2209,7 @@ var Dt = {
2206
2209
  e.tagName === "ellipse" ? t.shapeType = "ellipse" : e.tagName === "rect" && (t.shapeType = e.hasAttribute("data-rounded") ? "rounded" : "rect");
2207
2210
  },
2208
2211
  applyStyleToElement(e, t) {
2209
- J(e, t);
2212
+ q(e, t);
2210
2213
  }
2211
2214
  },
2212
2215
  highlight: {
@@ -2214,8 +2217,8 @@ var Dt = {
2214
2217
  label: "Highlight",
2215
2218
  icon: "ink_highlighter",
2216
2219
  variantField: "highlightColor",
2217
- defaultVariant: f[0].value,
2218
- variants: f.map((e) => ({
2220
+ defaultVariant: D[0].value,
2221
+ variants: D.map((e) => ({
2219
2222
  value: e.value,
2220
2223
  icon: "ink_highlighter",
2221
2224
  label: e.label
@@ -2223,7 +2226,7 @@ var Dt = {
2223
2226
  flyoutKind: "color",
2224
2227
  tooltipLabelForVariant: (e) => {
2225
2228
  let t = e.toLowerCase();
2226
- return f.find((e) => e.value === t)?.label ?? "";
2229
+ return D.find((e) => e.value === t)?.label ?? "";
2227
2230
  },
2228
2231
  ensurePresetForVariantChange: (e) => {
2229
2232
  e.shapeType = "highlight";
@@ -2239,7 +2242,7 @@ var Dt = {
2239
2242
  variantKeyForElement(e) {
2240
2243
  if (e.tagName !== "rect" || e.getAttribute("data-highlight") !== "1") return null;
2241
2244
  let t = e.getAttribute("fill");
2242
- return `highlight.${t ? t.toLowerCase() : f[0].value}`;
2245
+ return `highlight.${t ? t.toLowerCase() : D[0].value}`;
2243
2246
  },
2244
2247
  extractStyleFromElement(e, t) {
2245
2248
  let n = e.getAttribute("fill");
@@ -2288,23 +2291,23 @@ var Dt = {
2288
2291
  },
2289
2292
  {
2290
2293
  section: "Line",
2291
- id: V.strokeColor
2294
+ id: B.strokeColor
2292
2295
  },
2293
2296
  {
2294
2297
  section: "Line",
2295
- id: V.fontFamily
2298
+ id: B.fontFamily
2296
2299
  },
2297
2300
  {
2298
2301
  section: "Line",
2299
- id: V.fontSize
2302
+ id: B.fontSize
2300
2303
  },
2301
2304
  {
2302
2305
  section: "Label",
2303
- id: V.textAnchor
2306
+ id: B.textAnchor
2304
2307
  },
2305
2308
  {
2306
2309
  section: "Label",
2307
- id: V.textVerticalAnchor
2310
+ id: B.textVerticalAnchor
2308
2311
  }
2309
2312
  ],
2310
2313
  variantKeyForElement(e) {
@@ -2347,7 +2350,7 @@ var Dt = {
2347
2350
  }
2348
2351
  return;
2349
2352
  }
2350
- J(e, t);
2353
+ q(e, t);
2351
2354
  }
2352
2355
  },
2353
2356
  freehand: {
@@ -2365,7 +2368,7 @@ var Dt = {
2365
2368
  icon: "ink_highlighter",
2366
2369
  label: "Highlighter"
2367
2370
  }],
2368
- presetFields: [...Y, "drawStyle"],
2371
+ presetFields: [...J, "drawStyle"],
2369
2372
  panelControls: [
2370
2373
  {
2371
2374
  section: "Type",
@@ -2373,7 +2376,7 @@ var Dt = {
2373
2376
  },
2374
2377
  {
2375
2378
  section: "Line",
2376
- id: V.strokeColor
2379
+ id: B.strokeColor
2377
2380
  },
2378
2381
  {
2379
2382
  section: "Line",
@@ -2381,15 +2384,15 @@ var Dt = {
2381
2384
  },
2382
2385
  {
2383
2386
  section: "Line",
2384
- id: V.strokeWidth
2387
+ id: B.strokeWidth
2385
2388
  },
2386
2389
  {
2387
2390
  section: "Line",
2388
- id: V.strokeStyle
2391
+ id: B.strokeStyle
2389
2392
  },
2390
2393
  {
2391
2394
  section: "Line",
2392
- id: V.strokeLinecap
2395
+ id: B.strokeLinecap
2393
2396
  },
2394
2397
  {
2395
2398
  section: "Line",
@@ -2404,7 +2407,7 @@ var Dt = {
2404
2407
  (n === "pen" || n === "highlighter") && (t.drawStyle = n);
2405
2408
  },
2406
2409
  applyStyleToElement(e, t) {
2407
- J(e, t);
2410
+ q(e, t);
2408
2411
  }
2409
2412
  },
2410
2413
  marker: {
@@ -2418,23 +2421,23 @@ var Dt = {
2418
2421
  value: "circle",
2419
2422
  icon: "circle",
2420
2423
  label: "Circle",
2421
- svg: d.circle
2424
+ svg: E.circle
2422
2425
  },
2423
2426
  {
2424
2427
  value: "rect",
2425
2428
  icon: "square",
2426
2429
  label: "Square",
2427
- svg: d.rect
2430
+ svg: E.rect
2428
2431
  },
2429
2432
  {
2430
2433
  value: "rounded",
2431
2434
  icon: "crop_square",
2432
2435
  label: "Rounded square",
2433
- svg: d.rounded
2436
+ svg: E.rounded
2434
2437
  }
2435
2438
  ],
2436
2439
  presetFields: [
2437
- ...Y,
2440
+ ...J,
2438
2441
  "fillColor",
2439
2442
  "fontSize",
2440
2443
  "markerShape"
@@ -2446,23 +2449,23 @@ var Dt = {
2446
2449
  },
2447
2450
  {
2448
2451
  section: "Fill",
2449
- id: V.fillColor
2452
+ id: B.fillColor
2450
2453
  },
2451
2454
  {
2452
2455
  section: "Line",
2453
- id: V.strokeColor
2456
+ id: B.strokeColor
2454
2457
  },
2455
2458
  {
2456
2459
  section: "Line",
2457
- id: V.strokeWidth
2460
+ id: B.strokeWidth
2458
2461
  },
2459
2462
  {
2460
2463
  section: "Line",
2461
- id: V.strokeStyle
2464
+ id: B.strokeStyle
2462
2465
  },
2463
2466
  {
2464
2467
  section: "Label",
2465
- id: V.fontSize
2468
+ id: B.fontSize
2466
2469
  }
2467
2470
  ],
2468
2471
  variantKeyForElement(e) {
@@ -2525,7 +2528,7 @@ var Dt = {
2525
2528
  id: "tool.typeChips"
2526
2529
  }, {
2527
2530
  section: "Fill",
2528
- id: V.fillColor,
2531
+ id: B.fillColor,
2529
2532
  visibleWhen: (e) => e.redactStyle === "solid"
2530
2533
  }],
2531
2534
  variantKeyForElement(e) {
@@ -2550,8 +2553,15 @@ var Dt = {
2550
2553
  icon: "crop",
2551
2554
  category: "image-op",
2552
2555
  presetFields: []
2556
+ },
2557
+ overlay: {
2558
+ id: "overlay",
2559
+ label: "Overlay",
2560
+ icon: "label",
2561
+ category: "annotation",
2562
+ presetFields: []
2553
2563
  }
2554
- }, Ot = [
2564
+ }, Gt = [
2555
2565
  "arrow",
2556
2566
  "shape",
2557
2567
  "highlight",
@@ -2559,147 +2569,148 @@ var Dt = {
2559
2569
  "freehand",
2560
2570
  "marker",
2561
2571
  "redact",
2562
- "crop"
2563
- ], kt = (e, t) => Math.round((1 - (Number.isFinite(e) ? e : t)) * 100), At = (e) => 1 - e / 100, jt = (e, t) => Math.round((Number.isFinite(e) ? e : t) * 100), Mt = (e) => e / 100;
2564
- function Nt(e) {
2572
+ "crop",
2573
+ "overlay"
2574
+ ], Kt = (e, t) => Math.round((1 - (Number.isFinite(e) ? e : t)) * 100), qt = (e) => 1 - e / 100, Jt = (e, t) => Math.round((Number.isFinite(e) ? e : t) * 100), Yt = (e) => e / 100;
2575
+ function Xt(e) {
2565
2576
  return e === "sm" || e === "md" || e === "lg";
2566
2577
  }
2567
- function Pt(e, t) {
2578
+ function Zt(e, t) {
2568
2579
  return e ?? t;
2569
2580
  }
2570
- function Ft(e, t) {
2571
- return `${Pt(e, "md")}-${Pt(t, "md")}`;
2581
+ function Qt(e, t) {
2582
+ return `${Zt(e, "md")}-${Zt(t, "md")}`;
2572
2583
  }
2573
- function It(e) {
2584
+ function $t(e) {
2574
2585
  let [t, n] = e.split("-");
2575
2586
  return {
2576
- width: t && Nt(t) ? t : "md",
2577
- length: n && Nt(n) ? n : "md"
2587
+ width: t && Xt(t) ? t : "md",
2588
+ length: n && Xt(n) ? n : "md"
2578
2589
  };
2579
2590
  }
2580
- var Lt = {
2581
- [V.strokeColor]: {
2591
+ var en = {
2592
+ [B.strokeColor]: {
2582
2593
  read: (e) => e.strokeColor,
2583
2594
  write: (e, t) => {
2584
2595
  e.strokeColor = String(t);
2585
2596
  },
2586
- selectionDef: V.strokeColor
2597
+ selectionDef: B.strokeColor
2587
2598
  },
2588
- [V.strokeWidth]: {
2599
+ [B.strokeWidth]: {
2589
2600
  read: (e) => e.strokeWidth,
2590
2601
  write: (e, t) => {
2591
2602
  e.strokeWidth = Number(t);
2592
2603
  },
2593
- selectionDef: V.strokeWidth
2604
+ selectionDef: B.strokeWidth
2594
2605
  },
2595
- [V.strokeStyle]: {
2606
+ [B.strokeStyle]: {
2596
2607
  read: (e) => e.strokeDasharray ?? "",
2597
2608
  write: (e, t) => {
2598
2609
  e.strokeDasharray = String(t);
2599
2610
  },
2600
- selectionDef: V.strokeStyle
2611
+ selectionDef: B.strokeStyle
2601
2612
  },
2602
- [V.strokeLinecap]: {
2613
+ [B.strokeLinecap]: {
2603
2614
  read: (e) => e.strokeLinecap ?? "butt",
2604
2615
  write: (e, t) => {
2605
2616
  e.strokeLinecap = t;
2606
2617
  },
2607
- selectionDef: V.strokeLinecap
2618
+ selectionDef: B.strokeLinecap
2608
2619
  },
2609
- [V.fillColor]: {
2620
+ [B.fillColor]: {
2610
2621
  read: (e) => e.fillColor,
2611
2622
  write: (e, t) => {
2612
2623
  e.fillColor = String(t);
2613
2624
  },
2614
- selectionDef: V.fillColor
2625
+ selectionDef: B.fillColor
2615
2626
  },
2616
- [V.fontSize]: {
2627
+ [B.fontSize]: {
2617
2628
  read: (e) => e.fontSize,
2618
2629
  write: (e, t) => {
2619
2630
  e.fontSize = Number(t);
2620
2631
  },
2621
- selectionDef: V.fontSize
2632
+ selectionDef: B.fontSize
2622
2633
  },
2623
- [V.fontFamily]: {
2624
- read: (e) => o(e.fontFamily),
2634
+ [B.fontFamily]: {
2635
+ read: (e) => S(e.fontFamily),
2625
2636
  write: (e, t) => {
2626
- e.fontFamily = o(String(t));
2637
+ e.fontFamily = S(String(t));
2627
2638
  },
2628
- selectionDef: V.fontFamily
2639
+ selectionDef: B.fontFamily
2629
2640
  },
2630
- [V.textAnchor]: {
2641
+ [B.textAnchor]: {
2631
2642
  read: (e) => e.textAnchor ?? "start",
2632
2643
  write: (e, t) => {
2633
2644
  e.textAnchor = t;
2634
2645
  },
2635
- selectionDef: V.textAnchor
2646
+ selectionDef: B.textAnchor
2636
2647
  },
2637
- [V.textVerticalAnchor]: {
2648
+ [B.textVerticalAnchor]: {
2638
2649
  read: (e) => e.textVerticalAnchor ?? "top",
2639
2650
  write: (e, t) => {
2640
2651
  e.textVerticalAnchor = t;
2641
2652
  },
2642
- selectionDef: V.textVerticalAnchor
2653
+ selectionDef: B.textVerticalAnchor
2643
2654
  },
2644
- [V.arrowStartShape]: {
2655
+ [B.arrowStartShape]: {
2645
2656
  read: (e) => e.arrowHeadStart ?? "none",
2646
2657
  write: (e, t) => {
2647
2658
  e.arrowHeadStart = t;
2648
2659
  },
2649
- selectionDef: V.arrowStartShape
2660
+ selectionDef: B.arrowStartShape
2650
2661
  },
2651
- [V.arrowEndShape]: {
2662
+ [B.arrowEndShape]: {
2652
2663
  read: (e) => e.arrowHeadEnd ?? "triangle",
2653
2664
  write: (e, t) => {
2654
2665
  e.arrowHeadEnd = t;
2655
2666
  },
2656
- selectionDef: V.arrowEndShape
2667
+ selectionDef: B.arrowEndShape
2657
2668
  },
2658
- [V.arrowStartSize]: {
2659
- read: (e) => Ft(e.arrowWidthStart, e.arrowLengthStart),
2669
+ [B.arrowStartSize]: {
2670
+ read: (e) => Qt(e.arrowWidthStart, e.arrowLengthStart),
2660
2671
  write: (e, t) => {
2661
- let { width: n, length: r } = It(String(t));
2672
+ let { width: n, length: r } = $t(String(t));
2662
2673
  e.arrowWidthStart = n, e.arrowLengthStart = r;
2663
2674
  },
2664
- selectionDef: V.arrowStartSize
2675
+ selectionDef: B.arrowStartSize
2665
2676
  },
2666
- [V.arrowEndSize]: {
2667
- read: (e) => Ft(e.arrowWidthEnd, e.arrowLengthEnd),
2677
+ [B.arrowEndSize]: {
2678
+ read: (e) => Qt(e.arrowWidthEnd, e.arrowLengthEnd),
2668
2679
  write: (e, t) => {
2669
- let { width: n, length: r } = It(String(t));
2680
+ let { width: n, length: r } = $t(String(t));
2670
2681
  e.arrowWidthEnd = n, e.arrowLengthEnd = r;
2671
2682
  },
2672
- selectionDef: V.arrowEndSize
2683
+ selectionDef: B.arrowEndSize
2673
2684
  },
2674
2685
  "tool.typeChips": {
2675
2686
  read: (e, t) => {
2676
- let n = Dt[t]?.variantField;
2687
+ let n = Wt[t]?.variantField;
2677
2688
  if (n) return e[n];
2678
2689
  },
2679
2690
  write: (e, t, n) => {
2680
- let r = Dt[n]?.variantField;
2691
+ let r = Wt[n]?.variantField;
2681
2692
  r && (e[r] = t);
2682
2693
  },
2683
2694
  selectionDef: null
2684
2695
  },
2685
2696
  "tool.transparencyPercent": {
2686
- read: (e) => kt(e.strokeOpacity ?? 1, 1),
2697
+ read: (e) => Kt(e.strokeOpacity ?? 1, 1),
2687
2698
  write: (e, t) => {
2688
- e.strokeOpacity = At(Number(t));
2699
+ e.strokeOpacity = qt(Number(t));
2689
2700
  },
2690
- selectionDef: V.strokeOpacity
2701
+ selectionDef: B.strokeOpacity
2691
2702
  },
2692
2703
  "tool.fillTransparencyPercent": {
2693
- read: (e) => kt(e.fillOpacity ?? .4, .4),
2704
+ read: (e) => Kt(e.fillOpacity ?? .4, .4),
2694
2705
  write: (e, t) => {
2695
- e.fillOpacity = At(Number(t));
2706
+ e.fillOpacity = qt(Number(t));
2696
2707
  },
2697
- selectionDef: V.fillOpacity
2708
+ selectionDef: B.fillOpacity
2698
2709
  },
2699
2710
  "tool.fillOpacityPercent": {
2700
- read: (e) => jt(e.fillOpacity ?? 1, 1),
2711
+ read: (e) => Jt(e.fillOpacity ?? 1, 1),
2701
2712
  write: (e, t) => {
2702
- e.fillOpacity = Mt(Number(t));
2713
+ e.fillOpacity = Yt(Number(t));
2703
2714
  },
2704
2715
  selectionDef: null
2705
2716
  },
@@ -2709,10 +2720,10 @@ var Lt = {
2709
2720
  selectionDef: null
2710
2721
  }
2711
2722
  };
2712
- function Rt(e) {
2713
- let t = Lt[e];
2723
+ function tn(e) {
2724
+ let t = en[e];
2714
2725
  if (!t?.selectionDef) return null;
2715
- let n = st[t.selectionDef];
2726
+ let n = wt[t.selectionDef];
2716
2727
  return n ? {
2717
2728
  label: n.label,
2718
2729
  options: n.options,
@@ -2723,22 +2734,22 @@ function Rt(e) {
2723
2734
  allowNone: n.allowNone
2724
2735
  } : null;
2725
2736
  }
2726
- var zt = [
2727
- V.strokeColor,
2728
- V.strokeWidth,
2729
- V.strokeStyle,
2730
- V.strokeLinecap,
2731
- V.fillColor,
2732
- V.fontSize,
2733
- V.fontFamily,
2734
- V.textAnchor,
2735
- V.textVerticalAnchor,
2736
- V.arrowStartShape,
2737
- V.arrowEndShape,
2738
- V.arrowStartSize,
2739
- V.arrowEndSize,
2740
- ...Ct
2741
- ], Bt = {
2737
+ var nn = [
2738
+ B.strokeColor,
2739
+ B.strokeWidth,
2740
+ B.strokeStyle,
2741
+ B.strokeLinecap,
2742
+ B.fillColor,
2743
+ B.fontSize,
2744
+ B.fontFamily,
2745
+ B.textAnchor,
2746
+ B.textVerticalAnchor,
2747
+ B.arrowStartShape,
2748
+ B.arrowEndShape,
2749
+ B.arrowStartSize,
2750
+ B.arrowEndSize,
2751
+ ...Bt
2752
+ ], rn = {
2742
2753
  strokeColor: "stroke_color",
2743
2754
  fillColor: "fill_color",
2744
2755
  strokeWidth: "stroke_width",
@@ -2764,49 +2775,49 @@ var zt = [
2764
2775
  strokeOpacity: "stroke_opacity",
2765
2776
  strokeLinecap: "stroke_linecap",
2766
2777
  strokeLinejoin: "stroke_linejoin"
2767
- }, Vt = (() => {
2778
+ }, an = (() => {
2768
2779
  let e = {};
2769
- for (let [t, n] of Object.entries(Bt)) e[n] = t;
2780
+ for (let [t, n] of Object.entries(rn)) e[n] = t;
2770
2781
  return e;
2771
2782
  })();
2772
- function Ht(e, t) {
2773
- return t === "camel" ? e : Bt[e] ?? e;
2783
+ function on(e, t) {
2784
+ return t === "camel" ? e : rn[e] ?? e;
2774
2785
  }
2775
- function Ut(e, t, n) {
2786
+ function sn(e, t, n) {
2776
2787
  if (t === "camel") return e in n ? e : null;
2777
- let r = Bt[e];
2788
+ let r = rn[e];
2778
2789
  return r !== void 0 && r in n ? r : null;
2779
2790
  }
2780
- function Wt(e, t, n) {
2791
+ function cn(e, t, n) {
2781
2792
  let r = {};
2782
2793
  for (let i of t) {
2783
2794
  let t = e[i];
2784
- t !== void 0 && (r[Ht(i, n)] = t);
2795
+ t !== void 0 && (r[on(i, n)] = t);
2785
2796
  }
2786
2797
  return r;
2787
2798
  }
2788
- function Gt(e, t, n) {
2799
+ function ln(e, t, n) {
2789
2800
  let r = {};
2790
2801
  for (let i of t) {
2791
- let t = Ut(i, n, e);
2802
+ let t = sn(i, n, e);
2792
2803
  if (t === null) continue;
2793
2804
  let a = e[t];
2794
2805
  a !== void 0 && a !== "" && (r[i] = a);
2795
2806
  }
2796
2807
  return r;
2797
2808
  }
2798
- function Kt(e) {
2799
- return Vt[e];
2809
+ function un(e) {
2810
+ return an[e];
2800
2811
  }
2801
2812
  //#endregion
2802
2813
  //#region src/editor/tool-style-reader.ts
2803
- function qt(e) {
2814
+ function dn(e) {
2804
2815
  if (e.tagName.toLowerCase() !== "g" || e.getAttribute("data-type") !== "freehand") return e;
2805
2816
  let t = e.querySelectorAll(":scope > path");
2806
2817
  return t.length === 0 ? e : t[t.length - 1];
2807
2818
  }
2808
- function Jt(e, t) {
2809
- let n = qt(e), r = n.getAttribute("stroke");
2819
+ function fn(e, t) {
2820
+ let n = dn(e), r = n.getAttribute("stroke");
2810
2821
  r && (t.strokeColor = r);
2811
2822
  let i = n.getAttribute("fill");
2812
2823
  i && (t.fillColor = i);
@@ -2825,22 +2836,22 @@ function Jt(e, t) {
2825
2836
  }
2826
2837
  //#endregion
2827
2838
  //#region src/editor/viewport-math.ts
2828
- var Yt = .1, Xt = 5, Zt = 40;
2829
- function Qt(e, t = Yt, n = 5) {
2839
+ var pn = .1, mn = 5, hn = 40;
2840
+ function gn(e, t = pn, n = 5) {
2830
2841
  return Math.max(t, Math.min(e, n));
2831
2842
  }
2832
- function $t(e, t, n, r, i = 40, a = 1) {
2843
+ function _n(e, t, n, r, i = 40, a = 1) {
2833
2844
  if (e <= 0 || t <= 0) return 0;
2834
2845
  let o = n - i, s = r - i;
2835
2846
  return o <= 0 || s <= 0 ? 0 : Math.min(o / e, s / t, a);
2836
2847
  }
2837
- function en(e, t, n) {
2848
+ function vn(e, t, n) {
2838
2849
  return {
2839
2850
  width: Math.round(e * n),
2840
2851
  height: Math.round(t * n)
2841
2852
  };
2842
2853
  }
2843
- function tn(e, t, n) {
2854
+ function yn(e, t, n) {
2844
2855
  let [r, i, a, o, s, c] = e, l = r * o - i * a;
2845
2856
  if (l === 0) throw Error("applyInverseAffine: matrix is singular");
2846
2857
  return {
@@ -2850,192 +2861,192 @@ function tn(e, t, n) {
2850
2861
  }
2851
2862
  //#endregion
2852
2863
  //#region src/icons/types.ts
2853
- function nn(e) {
2864
+ function bn(e) {
2854
2865
  return {
2855
2866
  kind: "builtin",
2856
2867
  id: e
2857
2868
  };
2858
2869
  }
2859
- function rn(e) {
2870
+ function xn(e) {
2860
2871
  return {
2861
2872
  kind: "svg",
2862
2873
  svg: e
2863
2874
  };
2864
2875
  }
2865
- function an(e) {
2876
+ function Sn(e) {
2866
2877
  return {
2867
2878
  kind: "url",
2868
2879
  url: e
2869
2880
  };
2870
2881
  }
2871
- function on(e) {
2882
+ function Cn(e) {
2872
2883
  return e.kind === "builtin";
2873
2884
  }
2874
- function sn(e) {
2885
+ function wn(e) {
2875
2886
  return e.kind === "svg";
2876
2887
  }
2877
- function cn(e) {
2888
+ function Tn(e) {
2878
2889
  return e.kind === "url";
2879
2890
  }
2880
2891
  //#endregion
2881
2892
  //#region src/storage/errors.ts
2882
- var X = class extends Error {
2893
+ var Y = class extends Error {
2883
2894
  code;
2884
2895
  path;
2885
2896
  constructor(e, t, n) {
2886
2897
  super(n), this.name = "StorageError", this.code = e, this.path = t;
2887
2898
  }
2888
- }, ln = class extends X {
2899
+ }, En = class extends Y {
2889
2900
  constructor(e, t) {
2890
2901
  super("conflict", e, t ?? `Path already exists: ${e}`), this.name = "StorageConflictError";
2891
2902
  }
2892
- }, un = class extends X {
2903
+ }, Dn = class extends Y {
2893
2904
  constructor(e, t) {
2894
2905
  super("not-found", e, t ?? `Path not found: ${e}`), this.name = "StorageNotFoundError";
2895
2906
  }
2896
- }, dn = class extends X {
2907
+ }, On = class extends Y {
2897
2908
  constructor(e, t) {
2898
2909
  super("permission", e, t ?? `Permission denied: ${e}`), this.name = "StoragePermissionError";
2899
2910
  }
2900
- }, fn = class extends X {
2911
+ }, kn = class extends Y {
2901
2912
  constructor(e, t) {
2902
2913
  super("quota", e, t ?? `Quota exceeded: ${e}`), this.name = "StorageQuotaError";
2903
2914
  }
2904
- }, pn = class extends Error {
2915
+ }, An = class extends Error {
2905
2916
  constructor(e, t) {
2906
2917
  super(e, t), this.name = "MetadataCacheError";
2907
2918
  }
2908
- }, mn = class extends pn {
2919
+ }, jn = class extends An {
2909
2920
  constructor(e = "Metadata cache quota exceeded", t) {
2910
2921
  super(e, t), this.name = "MetadataCacheQuotaError";
2911
2922
  }
2912
2923
  };
2913
- function hn(e) {
2924
+ function Mn(e) {
2914
2925
  let t = e;
2915
2926
  return typeof t.metadataNamespace == "function" && typeof t.attachMetadataCache == "function";
2916
2927
  }
2917
2928
  //#endregion
2918
2929
  //#region src/storage/path.ts
2919
- var gn = "", _n = /[<>:"/\\|?*\x00-\x1f]/;
2920
- function vn(e) {
2930
+ var Nn = "", Pn = /[<>:"/\\|?*\x00-\x1f]/;
2931
+ function Fn(e) {
2921
2932
  if (!e) throw Error("Name must not be empty");
2922
2933
  if (e === "." || e === "..") throw Error(`Name "${e}" is reserved`);
2923
- if (_n.test(e)) throw Error(`Name "${e}" contains invalid characters`);
2934
+ if (Pn.test(e)) throw Error(`Name "${e}" contains invalid characters`);
2924
2935
  if (e.length > 255) throw Error("Name is too long (max 255 chars)");
2925
2936
  }
2926
- function yn(e, t) {
2937
+ function In(e, t) {
2927
2938
  if (!t) throw Error("joinPath: name is required");
2928
2939
  if (t.includes("/")) throw Error(`joinPath: name must not contain "/": "${t}"`);
2929
2940
  return e ? `${e}/${t}` : t;
2930
2941
  }
2931
- function bn(e) {
2942
+ function Ln(e) {
2932
2943
  if (!e) return "";
2933
2944
  let t = e.lastIndexOf("/");
2934
2945
  return t < 0 ? "" : e.slice(0, t);
2935
2946
  }
2936
- function xn(e) {
2947
+ function Rn(e) {
2937
2948
  if (!e) return "";
2938
2949
  let t = e.lastIndexOf("/");
2939
2950
  return t < 0 ? e : e.slice(t + 1);
2940
2951
  }
2941
- function Sn(e) {
2952
+ function zn(e) {
2942
2953
  return e ? e.split("/") : [];
2943
2954
  }
2944
- function Cn(e) {
2945
- let t = Sn(e), n = [], r = "";
2955
+ function Bn(e) {
2956
+ let t = zn(e), n = [], r = "";
2946
2957
  for (let e = 0; e < t.length - 1; e++) r = r ? `${r}/${t[e]}` : t[e], n.push(r);
2947
2958
  return n;
2948
2959
  }
2949
- function wn(e, t) {
2960
+ function Vn(e, t) {
2950
2961
  return t ? e === t || e.startsWith(`${t}/`) : !0;
2951
2962
  }
2952
- function Tn(e) {
2963
+ function Hn(e) {
2953
2964
  let t = e.lastIndexOf(".");
2954
2965
  return t <= 0 ? [e, ""] : [e.slice(0, t), e.slice(t)];
2955
2966
  }
2956
- function En(e, t) {
2967
+ function Un(e, t) {
2957
2968
  if (!t(e)) return e;
2958
- let [n, r] = Tn(e);
2969
+ let [n, r] = Hn(e);
2959
2970
  for (let e = 2; e < 1e4; e++) {
2960
2971
  let i = `${n} (${e})${r}`;
2961
2972
  if (!t(i)) return i;
2962
2973
  }
2963
2974
  throw Error(`Could not find unique name for "${e}"`);
2964
2975
  }
2965
- async function Dn(e, t) {
2976
+ async function Wn(e, t) {
2966
2977
  if (!await t(e)) return e;
2967
- let [n, r] = Tn(e);
2978
+ let [n, r] = Hn(e);
2968
2979
  for (let e = 2; e < 1e4; e++) {
2969
2980
  let i = `${n} (${e})${r}`;
2970
2981
  if (!await t(i)) return i;
2971
2982
  }
2972
2983
  throw Error(`Could not find unique name for "${e}"`);
2973
2984
  }
2974
- function On(e, t, n) {
2985
+ function Gn(e, t, n) {
2975
2986
  return e === t ? n : t && e.startsWith(`${t}/`) ? n ? n + e.slice(t.length) : e.slice(t.length + 1) : t ? e : n ? `${n}/${e}` : e;
2976
2987
  }
2977
2988
  //#endregion
2978
2989
  //#region src/storage/thumbnail-cache.ts
2979
- var kn = class extends Error {
2990
+ var Kn = class extends Error {
2980
2991
  constructor(e, t) {
2981
2992
  super(e, t), this.name = "ThumbnailCacheError";
2982
2993
  }
2983
- }, An = class extends kn {
2994
+ }, qn = class extends Kn {
2984
2995
  constructor(e = "Thumbnail cache quota exceeded", t) {
2985
2996
  super(e, t), this.name = "ThumbnailCacheQuotaError";
2986
2997
  }
2987
2998
  };
2988
2999
  //#endregion
2989
3000
  //#region src/storage/types.ts
2990
- function jn(e) {
3001
+ function Jn(e) {
2991
3002
  return typeof e.resync == "function";
2992
3003
  }
2993
- function Mn(e) {
3004
+ function Yn(e) {
2994
3005
  return typeof e.forceRefresh == "function";
2995
3006
  }
2996
- function Nn(e) {
3007
+ function Xn(e) {
2997
3008
  return typeof e.setTokenRefresher == "function" && typeof e.setToken == "function";
2998
3009
  }
2999
- function Pn(e) {
3010
+ function Zn(e) {
3000
3011
  return typeof e.init == "function";
3001
3012
  }
3002
- function Fn(e) {
3013
+ function Qn(e) {
3003
3014
  return typeof e.getRateLimit == "function" && typeof e.setRateLimitListener == "function";
3004
3015
  }
3005
- function In(e) {
3016
+ function $n(e) {
3006
3017
  let t = e;
3007
3018
  return typeof t.saveDocument == "function" && typeof t.getDocument == "function" && typeof t.listDocuments == "function" && typeof t.updateDocument == "function";
3008
3019
  }
3009
3020
  //#endregion
3010
3021
  //#region src/utils/assert.ts
3011
- function Ln(e, t) {
3022
+ function er(e, t) {
3012
3023
  if (e == null) throw Error(`Assertion failed: ${t}`);
3013
3024
  return e;
3014
3025
  }
3015
3026
  //#endregion
3016
3027
  //#region src/utils/constants.ts
3017
- var Rn = .9, zn = "#ff0000", Bn = "none", Vn = 3, Hn = 24, Un = 10, Wn = "annot";
3018
- function Z(e, t = 2) {
3028
+ var tr = .9, nr = "#ff0000", rr = "none", ir = 3, ar = 24, or = 10, sr = "annot";
3029
+ function X(e, t = 2) {
3019
3030
  return String(e).padStart(t, "0");
3020
3031
  }
3021
- function Gn(e = /* @__PURE__ */ new Date()) {
3022
- return `${e.getFullYear()}${Z(e.getMonth() + 1)}${Z(e.getDate())}-${Z(e.getHours())}${Z(e.getMinutes())}${Z(e.getSeconds())}-${Z(e.getMilliseconds(), 3)}`;
3032
+ function cr(e = /* @__PURE__ */ new Date()) {
3033
+ return `${e.getFullYear()}${X(e.getMonth() + 1)}${X(e.getDate())}-${X(e.getHours())}${X(e.getMinutes())}${X(e.getSeconds())}-${X(e.getMilliseconds(), 3)}`;
3023
3034
  }
3024
- function Kn(e = /* @__PURE__ */ new Date()) {
3025
- return `${Wn}-${Gn(e)}`;
3035
+ function lr(e = /* @__PURE__ */ new Date()) {
3036
+ return `${sr}-${cr(e)}`;
3026
3037
  }
3027
- function qn(e, t = /* @__PURE__ */ new Date()) {
3038
+ function ur(e, t = /* @__PURE__ */ new Date()) {
3028
3039
  let n = e.startsWith("data:image/jpeg") ? "jpg" : "png";
3029
- return `${Kn(t)}.annot.${n}`;
3040
+ return `${lr(t)}.annot.${n}`;
3030
3041
  }
3031
3042
  //#endregion
3032
3043
  //#region src/utils/id.ts
3033
- var Jn = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
3034
- function Yn(e = Date.now()) {
3035
- let t = new Uint8Array(16), n = Math.floor(e / 4294967296), r = e >>> 0;
3044
+ var dr = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
3045
+ function fr(e = Date.now()) {
3046
+ let t = /* @__PURE__ */ new Uint8Array(16), n = Math.floor(e / 4294967296), r = e >>> 0;
3036
3047
  return t[0] = n >>> 8 & 255, t[1] = n & 255, t[2] = r >>> 24 & 255, t[3] = r >>> 16 & 255, t[4] = r >>> 8 & 255, t[5] = r & 255, crypto.getRandomValues(t.subarray(6)), t[6] = t[6] & 15 | 112, t[8] = t[8] & 63 | 128, t;
3037
3048
  }
3038
- function Xn(e) {
3049
+ function pr(e) {
3039
3050
  let t = 0;
3040
3051
  for (; t < e.length && e[t] === 0;) t++;
3041
3052
  let n = Array.from(e), r = [], i = t;
@@ -3049,17 +3060,85 @@ function Xn(e) {
3049
3060
  r.push(e);
3050
3061
  }
3051
3062
  let a = "";
3052
- for (let e = 0; e < t; e++) a += Jn[0];
3053
- for (let e = r.length - 1; e >= 0; e--) a += Jn[r[e]];
3063
+ for (let e = 0; e < t; e++) a += dr[0];
3064
+ for (let e = r.length - 1; e >= 0; e--) a += dr[r[e]];
3054
3065
  return a;
3055
3066
  }
3056
- function Zn() {
3057
- return Xn(Yn());
3067
+ function mr() {
3068
+ return pr(fr());
3069
+ }
3070
+ //#endregion
3071
+ //#region src/xmp/element-tree-payload.ts
3072
+ var hr = "annot:elementTree", Z = new TextEncoder().encode(hr), gr = new TextEncoder().encode("iTXt");
3073
+ function _r(e, t) {
3074
+ if (!br(e)) throw Error("writeElementTreePng: input is not a valid PNG (missing signature)");
3075
+ let n = i(t), r = m(new TextEncoder().encode(n)), a = u(gr, d(Z, new Uint8Array([
3076
+ 0,
3077
+ 1,
3078
+ 0,
3079
+ 0,
3080
+ 0
3081
+ ]), r)), o = Sr(e), s = o.length - 12;
3082
+ return d(o.slice(0, s), a, o.slice(s));
3083
+ }
3084
+ function vr(e) {
3085
+ if (!br(e)) return null;
3086
+ let t = Cr(e);
3087
+ if (t === null) return null;
3088
+ let n = c(t);
3089
+ if (n.version !== 1) throw Error(`readElementTreePng: unsupported ElementTree schema version ${String(n.version)} (this build understands 1)`);
3090
+ return n;
3091
+ }
3092
+ function yr(e) {
3093
+ return br(e) ? xr(e) !== null : !1;
3094
+ }
3095
+ function br(e) {
3096
+ return e.length >= 8 && e[0] === 137 && e[1] === 80 && e[2] === 78 && e[3] === 71;
3097
+ }
3098
+ function xr(e) {
3099
+ let t = 8;
3100
+ for (; t + 12 <= e.length;) {
3101
+ let n = f(e, t), r = String.fromCharCode(e[t + 4], e[t + 5], e[t + 6], e[t + 7]), i = t + 8, a = i + n + 4;
3102
+ if (a > e.length) break;
3103
+ if (r === "iTXt" && p(e, i, Z)) {
3104
+ let r = i + Z.length;
3105
+ if (r < i + n && e[r] === 0) return {
3106
+ start: t,
3107
+ end: a,
3108
+ dataStart: i,
3109
+ dataLength: n
3110
+ };
3111
+ }
3112
+ t = a;
3113
+ }
3114
+ return null;
3115
+ }
3116
+ function Sr(e) {
3117
+ let t = xr(e);
3118
+ return t === null ? e : d(e.slice(0, t.start), e.slice(t.end));
3119
+ }
3120
+ function Cr(e) {
3121
+ let t = xr(e);
3122
+ if (t === null) return null;
3123
+ let n = t.dataStart + Z.length;
3124
+ if (n + 3 > t.dataStart + t.dataLength) return null;
3125
+ let r = e[n + 1] ?? 0, i = e[n + 2] ?? 0;
3126
+ if (r === 1 && i !== 0) throw Error(`extractElementTreeYaml: unsupported compression method ${i} (only deflate is defined)`);
3127
+ let a = n + 3, o = t.dataStart + t.dataLength;
3128
+ for (; a < o && e[a] !== 0;) a++;
3129
+ for (a++; a < o && e[a] !== 0;) a++;
3130
+ if (a++, a > o) return null;
3131
+ let s = e.slice(a, o);
3132
+ if (r === 1) {
3133
+ let e = h(s);
3134
+ return new TextDecoder().decode(e);
3135
+ }
3136
+ return new TextDecoder().decode(s);
3058
3137
  }
3059
3138
  //#endregion
3060
3139
  //#region src/zip/zip-bytes.ts
3061
- var Qn = new TextEncoder();
3062
- function $n(e) {
3140
+ var wr = new TextEncoder();
3141
+ function Tr(e) {
3063
3142
  let t = 4294967295;
3064
3143
  for (let n = 0; n < e.length; n++) {
3065
3144
  t ^= e[n];
@@ -3078,10 +3157,10 @@ function $(e) {
3078
3157
  e >> 24 & 255
3079
3158
  ]);
3080
3159
  }
3081
- function er(e) {
3160
+ function Er(e) {
3082
3161
  let t = [], n = [], r = 0;
3083
3162
  for (let i of e) {
3084
- let e = Qn.encode(i.name), a = $n(i.data), o = i.data.length, s = new Uint8Array([
3163
+ let e = wr.encode(i.name), a = Tr(i.data), o = i.data.length, s = new Uint8Array([
3085
3164
  80,
3086
3165
  75,
3087
3166
  3,
@@ -3146,17 +3225,17 @@ function er(e) {
3146
3225
  }
3147
3226
  //#endregion
3148
3227
  //#region src/zip/zip-builder.ts
3149
- function tr(e) {
3150
- let t = er(e);
3228
+ function Dr(e) {
3229
+ let t = Er(e);
3151
3230
  return new Blob([t], { type: "application/zip" });
3152
3231
  }
3153
- function nr(e) {
3232
+ function Or(e) {
3154
3233
  let t = e.split(",")[1] || "", n = atob(t), r = new Uint8Array(n.length);
3155
3234
  for (let e = 0; e < n.length; e++) r[e] = n.charCodeAt(e);
3156
3235
  return r;
3157
3236
  }
3158
- function rr(e) {
3237
+ function kr(e) {
3159
3238
  return e.startsWith("data:image/png") ? "png" : "jpg";
3160
3239
  }
3161
3240
  //#endregion
3162
- export { Wn as ANNOT_FILENAME_PREFIX, gt as ANNOT_SVG_VERSION, vt as ANNOT_SVG_VERSION_ATTR, _t as ANNOT_SVG_VERSION_UNSTAMPED, g as BUILTIN_ICONS, _ as BUILTIN_ICON_IDS, Xe as CATEGORY_CONTROL_SHAPE, Bn as DEFAULT_FILL_COLOR, Hn as DEFAULT_FONT_SIZE, s as DEFAULT_HISTORY_DEPTH, Xt as DEFAULT_MAX_ZOOM, Yt as DEFAULT_MIN_ZOOM, zn as DEFAULT_STROKE_COLOR, Vn as DEFAULT_STROKE_WIDTH, Zt as FIT_VIEW_PADDING, Rn as JPEG_QUALITY, e as LOGICAL_FAMILIES, Un as MOSAIC_BLOCK_SIZE, pn as MetadataCacheError, mn as MetadataCacheQuotaError, st as PROPERTY_CONTROLS, V as PROPERTY_CONTROL_IDS, H as PROPERTY_EFFECT_IDS, gn as ROOT_PATH, ln as StorageConflictError, X as StorageError, un as StorageNotFoundError, dn as StoragePermissionError, fn as StorageQuotaError, Lt as TOOL_PANEL_ADAPTERS, zt as TOOL_PANEL_ADAPTER_IDS, Ct as TOOL_PANEL_EXTRA_CONTROL_IDS, Dt as TOOL_REGISTRY, Ot as TOOL_REGISTRY_IDS, kn as ThumbnailCacheError, An as ThumbnailCacheQuotaError, Cn as ancestorPaths, tn as applyInverseAffine, Ln as assertNonNull, tr as buildZip, nn as builtinIcon, Qt as clampZoom, ct as classifyPropertyElement, ut as classifyPropertySelection, o as coerceToLogicalFamily, k as computeDasharray, $t as computeFitZoom, en as computeRenderedSize, ht as computeSnap, c as createHistoryCore, St as createMockToolSurface, r as cssStackFor, pt as cursorForAngle, rr as dataUrlExt, nr as dataUrlToBytes, Kn as defaultAnnotFilenameStem, qn as defaultAnnotImageFilename, A as detectDashKey, Kt as fieldForSnakeKey, Gn as formatLocalTimestamp, xt as getAnnotVersionFromString, xn as getFilename, bn as getParentPath, on as isBuiltinIcon, wn as isDescendantOrSame, a as isLogicalFamily, sn as isSvgIcon, cn as isUrlIcon, yn as joinPath, Zn as newIdB58, Et as normalizeVariantSideFields, i as ooxmlTypefacesFor, Gt as presetFromWire, Wt as presetToWire, bt as readAnnotVersion, Jt as readUniversalStyleAttrs, re as renderIconElement, ne as renderIconHtml, v as resolveBuiltinIcon, qt as resolveStyleReadSource, On as rewritePathPrefix, dt as rotateAround, T as sanitizeIconSvg, Rt as selectionDefMetadata, Tn as splitExt, Sn as splitPath, yt as stampAnnotVersion, In as supportsDocuments, Mn as supportsForceRefresh, Pn as supportsInit, hn as supportsMetadataCache, Fn as supportsRateLimit, jn as supportsResync, Nn as supportsTokenRefresher, rn as svgIcon, ce as translatePathD, En as uniquifyFilename, Dn as uniquifyFilenameAsync, an as urlIcon, vn as validateName, J as writeUniversalStyleAttrs };
3241
+ export { sr as ANNOT_FILENAME_PREFIX, Nt as ANNOT_SVG_VERSION, Ft as ANNOT_SVG_VERSION_ATTR, Pt as ANNOT_SVG_VERSION_UNSTAMPED, re as BUILTIN_ICONS, ie as BUILTIN_ICON_IDS, pt as CATEGORY_CONTROL_SHAPE, rr as DEFAULT_FILL_COLOR, ar as DEFAULT_FONT_SIZE, C as DEFAULT_HISTORY_DEPTH, mn as DEFAULT_MAX_ZOOM, pn as DEFAULT_MIN_ZOOM, nr as DEFAULT_STROKE_COLOR, ir as DEFAULT_STROKE_WIDTH, hr as ELEMENT_TREE_ITXT_KEYWORD, hn as FIT_VIEW_PADDING, tr as JPEG_QUALITY, g as LOGICAL_FAMILIES, or as MOSAIC_BLOCK_SIZE, An as MetadataCacheError, jn as MetadataCacheQuotaError, wt as PROPERTY_CONTROLS, B as PROPERTY_CONTROL_IDS, V as PROPERTY_EFFECT_IDS, Nn as ROOT_PATH, En as StorageConflictError, Y as StorageError, Dn as StorageNotFoundError, On as StoragePermissionError, kn as StorageQuotaError, en as TOOL_PANEL_ADAPTERS, nn as TOOL_PANEL_ADAPTER_IDS, Bt as TOOL_PANEL_EXTRA_CONTROL_IDS, Wt as TOOL_REGISTRY, Gt as TOOL_REGISTRY_IDS, Kn as ThumbnailCacheError, qn as ThumbnailCacheQuotaError, Bn as ancestorPaths, yn as applyInverseAffine, er as assertNonNull, Dr as buildZip, bn as builtinIcon, gn as clampZoom, Tt as classifyPropertyElement, Dt as classifyPropertySelection, S as coerceToLogicalFamily, k as computeDasharray, _n as computeFitZoom, vn as computeRenderedSize, Mt as computeSnap, ee as createHistoryCore, zt as createMockToolSurface, y as cssStackFor, At as cursorForAngle, kr as dataUrlExt, Or as dataUrlToBytes, lr as defaultAnnotFilenameStem, ur as defaultAnnotImageFilename, Ee as detectDashKey, un as fieldForSnakeKey, o as findByMatch, n as findByRef, e as flattenTree, cr as formatLocalTimestamp, Rt as getAnnotVersionFromString, Rn as getFilename, Ln as getParentPath, yr as hasElementTreePng, Cn as isBuiltinIcon, Vn as isDescendantOrSame, l as isElementTreeShape, x as isLogicalFamily, wn as isSvgIcon, Tn as isUrlIcon, In as joinPath, mr as newIdB58, Ut as normalizeVariantSideFields, b as ooxmlTypefacesFor, s as parseElementTreeFromJson, c as parseElementTreeFromYaml, ln as presetFromWire, cn as presetToWire, Lt as readAnnotVersion, vr as readElementTreePng, fn as readUniversalStyleAttrs, ye as renderIconElement, ve as renderIconHtml, ae as resolveBuiltinIcon, dn as resolveStyleReadSource, Gn as rewritePathPrefix, Ot as rotateAround, me as sanitizeIconSvg, tn as selectionDefMetadata, t as serializeElementTreeToJson, i as serializeElementTreeToYaml, Hn as splitExt, zn as splitPath, It as stampAnnotVersion, $n as supportsDocuments, Yn as supportsForceRefresh, Zn as supportsInit, Mn as supportsMetadataCache, Qn as supportsRateLimit, Jn as supportsResync, Xn as supportsTokenRefresher, xn as svgIcon, we as translatePathD, Un as uniquifyFilename, Wn as uniquifyFilenameAsync, Sn as urlIcon, r as validateElementTree, Fn as validateName, a as walkTree, _r as writeElementTreePng, q as writeUniversalStyleAttrs };