teamsync-pdf-viewer 1.3.1 → 1.3.3

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.
@@ -397,18 +397,18 @@ function Be({ activeTab: e, setActiveTab: t, leftSidebarOpen: n, setLeftSidebarO
397
397
  margin: "4px 0"
398
398
  } }),
399
399
  [
400
- .1,
401
400
  .25,
402
401
  .5,
402
+ .75,
403
403
  1,
404
404
  1.25,
405
405
  1.5,
406
406
  2,
407
+ 3,
407
408
  4,
409
+ 5,
408
410
  8,
409
- 16,
410
- 32,
411
- 64
411
+ 10
412
412
  ].map((e) => /* @__PURE__ */ I("div", {
413
413
  onClick: () => {
414
414
  p && p(e), P(!1);
@@ -439,18 +439,20 @@ function Be({ activeTab: e, setActiveTab: t, leftSidebarOpen: n, setLeftSidebarO
439
439
  /* @__PURE__ */ F(Ve, {
440
440
  icon: /* @__PURE__ */ F(_e, {
441
441
  size: 18,
442
- color: "var(--text-muted)"
442
+ color: u <= .1 ? "var(--border-color)" : "var(--text-muted)"
443
443
  }),
444
444
  title: "Zoom Out",
445
- onClick: f
445
+ onClick: f,
446
+ disabled: u <= .1
446
447
  }),
447
448
  /* @__PURE__ */ F(Ve, {
448
449
  icon: /* @__PURE__ */ F(xe, {
449
450
  size: 18,
450
- color: "var(--text-muted)"
451
+ color: u >= 10 ? "var(--border-color)" : "var(--text-muted)"
451
452
  }),
452
453
  title: "Zoom In",
453
- onClick: d
454
+ onClick: d,
455
+ disabled: u >= 10
454
456
  })
455
457
  ]
456
458
  }),
@@ -571,10 +573,11 @@ function Be({ activeTab: e, setActiveTab: t, leftSidebarOpen: n, setLeftSidebarO
571
573
  })
572
574
  });
573
575
  }
574
- function Ve({ icon: e, onClick: t, active: n = !1, title: r }) {
576
+ function Ve({ icon: e, onClick: t, active: n = !1, disabled: r = !1, title: i }) {
575
577
  return /* @__PURE__ */ F("button", {
576
- title: r,
577
- onClick: t,
578
+ title: i,
579
+ onClick: r ? void 0 : t,
580
+ disabled: r,
578
581
  style: {
579
582
  display: "flex",
580
583
  alignItems: "center",
@@ -585,14 +588,15 @@ function Ve({ icon: e, onClick: t, active: n = !1, title: r }) {
585
588
  borderRadius: "4px",
586
589
  backgroundColor: n ? "#e6f0fa" : "transparent",
587
590
  color: n ? "var(--primary)" : "inherit",
588
- cursor: "pointer",
591
+ cursor: r ? "not-allowed" : "pointer",
592
+ opacity: r ? .4 : 1,
589
593
  outline: "none"
590
594
  },
591
595
  onMouseOver: (e) => {
592
- n || (e.currentTarget.style.backgroundColor = "var(--hover-bg)");
596
+ !n && !r && (e.currentTarget.style.backgroundColor = "var(--hover-bg)");
593
597
  },
594
598
  onMouseOut: (e) => {
595
- n || (e.currentTarget.style.backgroundColor = "transparent");
599
+ !n && !r && (e.currentTarget.style.backgroundColor = "transparent");
596
600
  },
597
601
  children: e
598
602
  });
@@ -1023,8 +1027,8 @@ var Ge = [
1023
1027
  defaultCommand: "Delete",
1024
1028
  command: "Delete"
1025
1029
  }
1026
- ], Ke = "pdfviewer_shortcuts", qe = "pdfviewer-shortcuts-changed", Je = null, H = /* @__PURE__ */ new Set();
1027
- function Ye() {
1030
+ ], Ke = "pdfviewer_shortcuts", qe = "pdfviewer-shortcuts-changed", Je = null, Ye = /* @__PURE__ */ new Set();
1031
+ function Xe() {
1028
1032
  if (typeof window > "u" || !window.localStorage) return Ge;
1029
1033
  try {
1030
1034
  let e = window.localStorage.getItem(Ke);
@@ -1041,29 +1045,29 @@ function Ye() {
1041
1045
  } catch {}
1042
1046
  return Ge;
1043
1047
  }
1044
- function Xe() {
1045
- H.forEach((e) => e()), typeof window < "u" && window.dispatchEvent(new CustomEvent(qe));
1046
- }
1047
1048
  function Ze() {
1048
- let [e, t] = c(() => (Je ||= Ye(), Je));
1049
+ Ye.forEach((e) => e()), typeof window < "u" && window.dispatchEvent(new CustomEvent(qe));
1050
+ }
1051
+ function Qe() {
1052
+ let [e, t] = c(() => (Je ||= Xe(), Je));
1049
1053
  return i(() => {
1050
1054
  let e = () => {
1051
- Je = Ye(), t(Je);
1055
+ Je = Xe(), t(Je);
1052
1056
  };
1053
- return H.add(e), typeof window < "u" && (window.addEventListener("storage", e), window.addEventListener(qe, e)), () => {
1054
- H.delete(e), typeof window < "u" && (window.removeEventListener("storage", e), window.removeEventListener(qe, e));
1057
+ return Ye.add(e), typeof window < "u" && (window.addEventListener("storage", e), window.addEventListener(qe, e)), () => {
1058
+ Ye.delete(e), typeof window < "u" && (window.removeEventListener("storage", e), window.removeEventListener(qe, e));
1055
1059
  };
1056
1060
  }, []), {
1057
1061
  shortcuts: e,
1058
1062
  updateShortcut: n((e, n) => {
1059
- let r = (Je || Ye()).map((t) => t.action === e ? {
1063
+ let r = (Je || Xe()).map((t) => t.action === e ? {
1060
1064
  ...t,
1061
1065
  command: n
1062
1066
  } : t);
1063
- Je = r, typeof window < "u" && window.localStorage && window.localStorage.setItem(Ke, JSON.stringify(r)), t(r), Xe();
1067
+ Je = r, typeof window < "u" && window.localStorage && window.localStorage.setItem(Ke, JSON.stringify(r)), t(r), Ze();
1064
1068
  }, []),
1065
1069
  resetShortcuts: n(() => {
1066
- Je = Ge, typeof window < "u" && window.localStorage && window.localStorage.removeItem(Ke), t(Ge), Xe();
1070
+ Je = Ge, typeof window < "u" && window.localStorage && window.localStorage.removeItem(Ke), t(Ge), Ze();
1067
1071
  }, []),
1068
1072
  getCommand: n((t) => {
1069
1073
  let n = (Je || e).find((e) => e.action === t);
@@ -1071,7 +1075,7 @@ function Ze() {
1071
1075
  }, [e])
1072
1076
  };
1073
1077
  }
1074
- function Qe(e) {
1078
+ function $e(e) {
1075
1079
  if (!e) return {
1076
1080
  meta: !1,
1077
1081
  shift: !1,
@@ -1090,16 +1094,16 @@ function Qe(e) {
1090
1094
  key: a.join("+").toLowerCase()
1091
1095
  };
1092
1096
  }
1093
- function $e(e, t) {
1097
+ function et(e, t) {
1094
1098
  if (!t) return !1;
1095
- let n = Qe(t), r = !!(e.metaKey || e.ctrlKey);
1099
+ let n = $e(t), r = !!(e.metaKey || e.ctrlKey);
1096
1100
  if (n.meta !== r || n.alt !== !!e.altKey) return !1;
1097
1101
  let i = (e.key || "").toLowerCase(), a = n.key.toLowerCase();
1098
1102
  return a === "delete" || a === "backspace" ? n.shift === !!e.shiftKey ? i === "delete" || i === "backspace" : !1 : a === "=" || a === "+" ? !(i !== "=" && i !== "+" && e.code !== "Equal" && e.code !== "NumpadAdd" || n.shift && !e.shiftKey || !n.shift && a === "=" && e.shiftKey) : a === "-" || a === "_" ? !(i !== "-" && i !== "_" && e.code !== "Minus" && e.code !== "NumpadSubtract" || n.shift && !e.shiftKey || !n.shift && a === "-" && e.shiftKey) : n.shift === !!e.shiftKey && !!(i === a || e.code && e.code.toLowerCase() === `key${a}` || e.code && e.code.toLowerCase() === `digit${a}`);
1099
1103
  }
1100
1104
  //#endregion
1101
1105
  //#region src/hooks/usePdfSearch.ts
1102
- async function et(e, t, n = [], r) {
1106
+ async function tt(e, t, n = [], r) {
1103
1107
  if (!e || !t.trim()) return [];
1104
1108
  let i = [], a = t.toLowerCase(), o = e.numPages;
1105
1109
  for (let s = 1; s <= o; s += 10) {
@@ -1176,7 +1180,7 @@ async function et(e, t, n = [], r) {
1176
1180
  }
1177
1181
  return i;
1178
1182
  }
1179
- function tt(e, t = []) {
1183
+ function nt(e, t = []) {
1180
1184
  let [r, i] = c(!1), [a, o] = c([]), [s, l] = c(0);
1181
1185
  return {
1182
1186
  search: n(async (n) => {
@@ -1186,7 +1190,7 @@ function tt(e, t = []) {
1186
1190
  }
1187
1191
  i(!0), l(0);
1188
1192
  try {
1189
- let r = await et(e, n, t, (e) => l(e));
1193
+ let r = await tt(e, n, t, (e) => l(e));
1190
1194
  o(r);
1191
1195
  } catch (e) {
1192
1196
  console.error("Search error:", e);
@@ -1202,7 +1206,7 @@ function tt(e, t = []) {
1202
1206
  }
1203
1207
  //#endregion
1204
1208
  //#region src/components/Sidebar.tsx
1205
- function nt({ isOpen: e, annotations: t, setAnnotations: n, selectedAnnotationId: r, setSelectedAnnotationId: a, onSearch: o, searchResults: l, isSearching: u, searchProgress: d, onResultClick: f, activeTab: p, setActiveTab: m }) {
1209
+ function rt({ isOpen: e, annotations: t, setAnnotations: n, selectedAnnotationId: r, setSelectedAnnotationId: a, onSearch: o, searchResults: l, isSearching: u, searchProgress: d, onResultClick: f, activeTab: p, setActiveTab: m }) {
1206
1210
  let [h, g] = c(""), [_, v] = c(320), [y, b] = c(!1), x = s(null);
1207
1211
  i(() => {
1208
1212
  let e = (e) => {
@@ -1583,7 +1587,7 @@ function nt({ isOpen: e, annotations: t, setAnnotations: n, selectedAnnotationId
1583
1587
  }
1584
1588
  //#endregion
1585
1589
  //#region src/components/LeftSidebar.tsx
1586
- var rt = ({ pdfDoc: e, pageIndex: t, isActive: n, onClick: r, scale: a }) => {
1590
+ var it = ({ pdfDoc: e, pageIndex: t, isActive: n, onClick: r, scale: a }) => {
1587
1591
  let o = s(null), l = s(null), [u, d] = c(!1), [f, p] = c(.77);
1588
1592
  i(() => {
1589
1593
  let e = new IntersectionObserver((e) => {
@@ -1603,7 +1607,7 @@ var rt = ({ pdfDoc: e, pageIndex: t, isActive: n, onClick: r, scale: a }) => {
1603
1607
  if (!c) return;
1604
1608
  let u = c.getContext("2d");
1605
1609
  if (!u) return;
1606
- let d = window.devicePixelRatio || 1;
1610
+ let d = Math.min(window.devicePixelRatio || 1, 2);
1607
1611
  c.width = Math.floor(s.width * d), c.height = Math.floor(s.height * d), c.style.width = `${s.width}px`, c.style.height = `${s.height}px`, n = i.render({
1608
1612
  canvasContext: u,
1609
1613
  canvas: c,
@@ -1672,7 +1676,7 @@ var rt = ({ pdfDoc: e, pageIndex: t, isActive: n, onClick: r, scale: a }) => {
1672
1676
  })]
1673
1677
  });
1674
1678
  };
1675
- function it({ isOpen: e, pdfDoc: t, pageNum: n, setPageNum: r }) {
1679
+ function at({ isOpen: e, pdfDoc: t, pageNum: n, setPageNum: r }) {
1676
1680
  let [a, o] = c("Thumbnails"), [s, l] = c(250), [u, d] = c(!1), [f, m] = c(30), h = .1 + f / 100 * .3;
1677
1681
  i(() => {
1678
1682
  let e = (e) => {
@@ -1823,7 +1827,7 @@ function it({ isOpen: e, pdfDoc: t, pageNum: n, setPageNum: r }) {
1823
1827
  padding: "8px 0",
1824
1828
  backgroundColor: "#f1f1f1"
1825
1829
  },
1826
- children: [t && v.map((e) => /* @__PURE__ */ F(rt, {
1830
+ children: [t && v.map((e) => /* @__PURE__ */ F(it, {
1827
1831
  pdfDoc: t,
1828
1832
  pageIndex: e,
1829
1833
  isActive: e === n,
@@ -1915,7 +1919,7 @@ function it({ isOpen: e, pdfDoc: t, pageNum: n, setPageNum: r }) {
1915
1919
  }
1916
1920
  //#endregion
1917
1921
  //#region src/utils/rotationUtils.ts
1918
- function at(e, t, n, r, i) {
1922
+ function ot(e, t, n, r, i) {
1919
1923
  let a = (n % 360 + 360) % 360;
1920
1924
  return a === 90 ? {
1921
1925
  x: t,
@@ -1931,7 +1935,7 @@ function at(e, t, n, r, i) {
1931
1935
  y: t
1932
1936
  };
1933
1937
  }
1934
- function ot(e, t, n, r, i) {
1938
+ function st(e, t, n, r, i) {
1935
1939
  let a = (n % 360 + 360) % 360;
1936
1940
  return a === 90 ? {
1937
1941
  x: i - t,
@@ -1947,7 +1951,7 @@ function ot(e, t, n, r, i) {
1947
1951
  y: t
1948
1952
  };
1949
1953
  }
1950
- function st(e, t, n, r, i, a, o) {
1954
+ function H(e, t, n, r, i, a, o) {
1951
1955
  let s = (i % 360 + 360) % 360;
1952
1956
  return s === 90 ? {
1953
1957
  x: o - (t + r),
@@ -1981,89 +1985,154 @@ function lt(e) {
1981
1985
  return (e % 360 + 360) % 360;
1982
1986
  }
1983
1987
  //#endregion
1988
+ //#region src/utils/zoomUtils.ts
1989
+ var ut = .1, dt = 10, ft = () => typeof navigator < "u" && (/iPad|iPhone|iPod/.test(navigator.userAgent) || /^((?!chrome|android).)*safari/i.test(navigator.userAgent)), pt = 8192, mt = 4096, ht = 16777216;
1990
+ function gt(e, t = 10) {
1991
+ return Math.min(t, Math.round((e + (e < 2 ? .25 : e < 5 ? .5 : 1)) * 100) / 100);
1992
+ }
1993
+ function _t(e, t = ut) {
1994
+ return Math.max(t, Math.round((e - (e <= 2 ? .25 : e <= 5 ? .5 : 1)) * 100) / 100);
1995
+ }
1996
+ function vt(e, t = ut, n = 10) {
1997
+ return Math.min(n, Math.max(t, Math.round(e * 100) / 100));
1998
+ }
1999
+ function yt(e, t, n, r, i = ft() ? mt : pt, a = ht) {
2000
+ let o = e * t;
2001
+ return n * o > i && (o = i / n), r * o > i && (o = i / r), n * o * (r * o) > a && (o = Math.sqrt(a / (n * r))), o;
2002
+ }
2003
+ function bt(e) {
2004
+ let { prevScale: t, newScale: n, containerWidth: r, containerHeight: i, currentScrollLeft: a, currentScrollTop: o, basePageWidth: s, focusPoint: c, isProgrammatic: l = !1 } = e;
2005
+ if (l) return {
2006
+ scrollLeft: 0,
2007
+ scrollTop: o <= 1 ? 0 : o
2008
+ };
2009
+ let u = c?.vx != null && c?.vy != null;
2010
+ if (!u && o <= 0) return {
2011
+ scrollLeft: 0,
2012
+ scrollTop: 0
2013
+ };
2014
+ let d = u ? c.vx : r / 2, f = u ? c.vy : i / 2, p = d + a, m = f + o, h = Math.max(0, r / 2 - s * t / 2), g = Math.max(0, r / 2 - s * n / 2) + (p - h) * (n / t);
2015
+ return {
2016
+ scrollLeft: Math.max(0, g - d),
2017
+ scrollTop: Math.max(0, n / t * m - f)
2018
+ };
2019
+ }
2020
+ //#endregion
1984
2021
  //#region src/components/PageRenderer.tsx
1985
- function ut({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, containerHeight: l, scrollTop: u, scrollLeft: d, pageTop: f, pageLeft: p = 0, basePageWidth: m, basePageHeight: h, activeTab: g, activeTool: _, annotations: v, selectedAnnotationId: y, activeSearchResult: b, transientHighlights: x, onMouseDown: ee, onMouseMove: S, onMouseUp: C, onAnnotationClick: te, onAnnotationMouseEnter: ne, onClearSelection: re, watermark: ie, watermarkText: w, redactions: T, onDiscardRedaction: ae, onRendered: oe }) {
2022
+ function xt({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, containerHeight: l, scrollTop: u, scrollLeft: d, pageTop: f, pageLeft: p = 0, basePageWidth: m, basePageHeight: h, activeTab: g, activeTool: _, annotations: v, selectedAnnotationId: y, activeSearchResult: b, transientHighlights: x, onMouseDown: ee, onMouseMove: S, onMouseUp: C, onAnnotationClick: te, onAnnotationMouseEnter: ne, onClearSelection: re, watermark: ie, watermarkText: w, redactions: T, onDiscardRedaction: ae, onRendered: oe }) {
1986
2023
  let E = s(oe);
1987
2024
  E.current = oe;
1988
- let D = s(null), O = s(null), k = s(null), se = s(null), [A, ce] = c(null), le = m * r, ue = h * r;
2025
+ let D = s(null), O = s(null), k = s(null), se = s(null), A = s(!1), [ce, le] = c(null), ue = m * r, de = h * r;
1989
2026
  i(() => {
1990
- let e = !1, i = null;
1991
- i = setTimeout(async () => {
2027
+ A.current = !1;
2028
+ }, [n, t]), i(() => {
2029
+ let e = !1, i = null, o = async () => {
1992
2030
  if (!(!D.current || !n)) {
1993
- k.current && k.current.cancel();
2031
+ if (k.current) {
2032
+ try {
2033
+ k.current.cancel();
2034
+ } catch {}
2035
+ k.current = null;
2036
+ }
1994
2037
  try {
1995
2038
  let i = await n.getPage(t);
1996
- if (e) return;
1997
- let o = window.devicePixelRatio || 1, s = i.getViewport({
1998
- scale: r * o,
1999
- rotation: lt(i.rotate + a)
2000
- }), c = document.createElement("canvas");
2001
- c.width = Math.floor(s.width), c.height = Math.floor(s.height);
2002
- let l = c.getContext("2d");
2003
- if (!l || e) return;
2004
- if (k.current = i.render({
2005
- canvasContext: l,
2006
- canvas: c,
2007
- viewport: s
2008
- }), await k.current.promise, T && T.length > 0) {
2009
- l.save(), l.setTransform(1, 0, 0, 1, 0, 0);
2039
+ if (e) {
2040
+ try {
2041
+ i.cleanup?.();
2042
+ } catch {}
2043
+ return;
2044
+ }
2045
+ se.current = i;
2046
+ let o = Math.min(window.devicePixelRatio || 1, 2), s = lt(i.rotate + a), c = i.getViewport({
2047
+ scale: 1,
2048
+ rotation: s
2049
+ }), l = yt(r, o, c.width, c.height), u = i.getViewport({
2050
+ scale: l,
2051
+ rotation: s
2052
+ }), d = document.createElement("canvas");
2053
+ d.width = Math.floor(u.width), d.height = Math.floor(u.height);
2054
+ let f = d.getContext("2d");
2055
+ if (!f || e) {
2056
+ d.width = 0, d.height = 0;
2057
+ return;
2058
+ }
2059
+ let p = i.render({
2060
+ canvasContext: f,
2061
+ canvas: d,
2062
+ viewport: u
2063
+ });
2064
+ if (k.current = p, await p.promise, k.current = null, T && T.length > 0) {
2065
+ f.save(), f.setTransform(1, 0, 0, 1, 0, 0);
2010
2066
  let e = a % 180 == 0 ? m : h, n = a % 180 == 0 ? h : m;
2011
2067
  for (let i of T) if (i.pageIndex === t) {
2012
- let t = st(i.x, i.y, i.width, i.height, a, e, n), s = t.x * r * o, c = t.y * r * o, u = t.width * r * o, d = t.height * r * o;
2013
- i.status === "applied" || i.status === void 0 ? (l.fillStyle = "#000000", l.fillRect(Math.floor(s), Math.floor(c), Math.ceil(u), Math.ceil(d))) : (l.fillStyle = "rgba(0, 0, 0, 0.45)", l.fillRect(Math.floor(s), Math.floor(c), Math.ceil(u), Math.ceil(d)), l.lineWidth = 2 * o, l.strokeStyle = "#dc2626", l.strokeRect(Math.floor(s), Math.floor(c), Math.ceil(u), Math.ceil(d)));
2068
+ let t = H(i.x, i.y, i.width, i.height, a, e, n), o = t.x * l, s = t.y * l, c = t.width * l, u = t.height * l;
2069
+ i.status === "applied" || i.status === void 0 ? (f.fillStyle = "#000000", f.fillRect(Math.floor(o), Math.floor(s), Math.ceil(c), Math.ceil(u))) : (f.fillStyle = "rgba(0, 0, 0, 0.45)", f.fillRect(Math.floor(o), Math.floor(s), Math.ceil(c), Math.ceil(u)), f.lineWidth = Math.max(1, l / (r || 1) * 2), f.strokeStyle = "#dc2626", f.strokeRect(Math.floor(o), Math.floor(s), Math.ceil(c), Math.ceil(u)));
2014
2070
  }
2015
- l.restore();
2071
+ f.restore();
2016
2072
  }
2017
- let u = ie || (w ? {
2073
+ let g = ie || (w ? {
2018
2074
  text: w,
2019
2075
  opacity: .15,
2020
2076
  size: 24,
2021
2077
  mode: "tiled",
2022
2078
  color: "#000000"
2023
2079
  } : void 0);
2024
- if (u && u.text) {
2025
- l.save(), l.setTransform(1, 0, 0, 1, 0, 0);
2026
- let e = u.opacity ?? .15, t = u.mode ?? "tiled", n = t === "single" ? 48 : 18, i = (u.size ?? n) * r * o, a = u.text;
2027
- l.fillStyle = u.color ?? "#000000", l.globalAlpha = e, l.font = `600 ${i}px sans-serif`, l.textAlign = "center", l.textBaseline = "middle";
2028
- let s = c.width, d = c.height;
2029
- if (t === "single") l.translate(s / 2, d / 2), l.rotate(-Math.PI / 4), l.fillText(a, 0, 0);
2080
+ if (g && g.text) {
2081
+ f.save(), f.setTransform(1, 0, 0, 1, 0, 0);
2082
+ let e = g.opacity ?? .15, t = g.mode ?? "tiled", n = t === "single" ? 48 : 18, r = (g.size ?? n) * l, i = g.text;
2083
+ f.fillStyle = g.color ?? "#000000", f.globalAlpha = e, f.font = `600 ${r}px sans-serif`, f.textAlign = "center", f.textBaseline = "middle";
2084
+ let a = d.width, o = d.height;
2085
+ if (t === "single") f.translate(a / 2, o / 2), f.rotate(-Math.PI / 4), f.fillText(i, 0, 0);
2030
2086
  else {
2031
- let e = i * a.length * .8 + 100 * r * o, t = 180 * r * o, n = Math.sqrt(s * s + d * d);
2032
- l.translate(s / 2, d / 2), l.rotate(-Math.PI / 4);
2087
+ let e = r * i.length * .8 + 100 * l, t = 180 * l, n = Math.sqrt(a * a + o * o);
2088
+ f.translate(a / 2, o / 2), f.rotate(-Math.PI / 4);
2033
2089
  for (let r = -n; r < n; r += t) {
2034
- let i = Math.abs(r / t) % 2 * (e / 2);
2035
- for (let t = -n; t < n; t += e) l.fillText(a, t + i, r);
2090
+ let a = Math.abs(r / t) % 2 * (e / 2);
2091
+ for (let t = -n; t < n; t += e) f.fillText(i, t + a, r);
2036
2092
  }
2037
2093
  }
2038
- l.restore();
2094
+ f.restore();
2039
2095
  }
2040
- let d = D.current;
2041
- if (d && !e) {
2042
- d.width = c.width, d.height = c.height;
2043
- let e = d.getContext("2d");
2044
- e && e.drawImage(c, 0, 0), E.current?.(t);
2096
+ let _ = D.current;
2097
+ if (_ && !e) {
2098
+ _.width = d.width, _.height = d.height;
2099
+ let e = _.getContext("2d");
2100
+ e && e.drawImage(d, 0, 0), A.current = !0, E.current?.(t);
2045
2101
  }
2102
+ d.width = 0, d.height = 0;
2046
2103
  } catch (e) {
2047
2104
  e?.name !== "RenderingCancelledException" && console.error(`Page ${t} render failed:`, e);
2105
+ } finally {
2106
+ if (se.current) {
2107
+ try {
2108
+ se.current.cleanup?.();
2109
+ } catch {}
2110
+ se.current = null;
2111
+ }
2048
2112
  }
2049
2113
  }
2050
- }, 60);
2051
- let o = k.current, s = se.current;
2052
- return () => {
2053
- if (e = !0, i && clearTimeout(i), o) try {
2054
- o.cancel();
2055
- } catch {}
2056
- if (s) try {
2057
- s.cleanup();
2058
- } catch {}
2114
+ }, s = A.current ? 150 : 0;
2115
+ return i = setTimeout(o, s), () => {
2116
+ if (e = !0, i && clearTimeout(i), k.current) {
2117
+ try {
2118
+ k.current.cancel();
2119
+ } catch {}
2120
+ k.current = null;
2121
+ }
2122
+ if (se.current) {
2123
+ try {
2124
+ se.current.cleanup?.();
2125
+ } catch {}
2126
+ se.current = null;
2127
+ }
2059
2128
  };
2060
2129
  }, [
2061
2130
  t,
2062
2131
  n,
2063
2132
  r,
2064
2133
  a,
2065
- le,
2066
- ue,
2134
+ m,
2135
+ h,
2067
2136
  ie,
2068
2137
  w,
2069
2138
  T
@@ -2084,7 +2153,7 @@ function ut({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
2084
2153
  return !0;
2085
2154
  }));
2086
2155
  }
2087
- e || ce(r);
2156
+ e || le(r);
2088
2157
  } catch {}
2089
2158
  })(), () => {
2090
2159
  e = !0;
@@ -2095,16 +2164,16 @@ function ut({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
2095
2164
  T
2096
2165
  ]), i(() => {
2097
2166
  let e = O.current;
2098
- !A || !e || (async () => {
2167
+ !ce || !e || (async () => {
2099
2168
  try {
2100
2169
  let r = await n.getPage(t), i = r.getViewport({
2101
2170
  scale: 1,
2102
2171
  rotation: lt(r.rotate + a)
2103
- }), o = A;
2172
+ }), o = ce;
2104
2173
  if (T && T.length > 0) {
2105
2174
  let e = T.filter((e) => e.pageIndex === t);
2106
2175
  if (e.length > 0) {
2107
- let t = A.items.filter((t) => {
2176
+ let t = ce.items.filter((t) => {
2108
2177
  if (!t.str || t.str.trim() === "") return !0;
2109
2178
  let n = t.transform[4], r = t.transform[5], a = t.width, o = t.height || Math.abs(t.transform[3]), s = i.height - r - o;
2110
2179
  for (let t of e) {
@@ -2114,7 +2183,7 @@ function ut({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
2114
2183
  return !0;
2115
2184
  });
2116
2185
  o = {
2117
- ...A,
2186
+ ...ce,
2118
2187
  items: t
2119
2188
  };
2120
2189
  }
@@ -2129,13 +2198,13 @@ function ut({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
2129
2198
  }
2130
2199
  })();
2131
2200
  }, [
2132
- A,
2201
+ ce,
2133
2202
  n,
2134
2203
  t,
2135
2204
  a,
2136
2205
  T
2137
2206
  ]);
2138
- let de = v.filter((e) => e.pageIndex === t);
2207
+ let fe = v.filter((e) => e.pageIndex === t);
2139
2208
  return /* @__PURE__ */ I("div", {
2140
2209
  id: `pdf-page-${t}`,
2141
2210
  className: "pdf-page-container",
@@ -2146,8 +2215,8 @@ function ut({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
2146
2215
  position: "absolute",
2147
2216
  top: `${f}px`,
2148
2217
  left: p === void 0 ? "0px" : `${p}px`,
2149
- width: `${le}px`,
2150
- height: `${ue}px`,
2218
+ width: `${ue}px`,
2219
+ height: `${de}px`,
2151
2220
  backgroundColor: "#fff",
2152
2221
  boxShadow: "0 2px 10px rgba(0,0,0,0.1)",
2153
2222
  marginBottom: "16px"
@@ -2193,7 +2262,7 @@ function ut({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
2193
2262
  children: [
2194
2263
  /* @__PURE__ */ F("style", { children: "\n @keyframes tspdf-transient-pulse {\n 0% {\n box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.75), 0 0 8px rgba(234, 179, 8, 0.4);\n }\n 50% {\n box-shadow: 0 0 0 6px rgba(234, 179, 8, 0.25), 0 0 18px rgba(234, 179, 8, 0.7);\n }\n 100% {\n box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.75), 0 0 8px rgba(234, 179, 8, 0.4);\n }\n }\n " }),
2195
2264
  b && b.pageIndex === t && b.bounds.map((e, t) => {
2196
- let o = st(e.x, i - e.y - e.height, e.width, e.height, a, n, i);
2265
+ let o = H(e.x, i - e.y - e.height, e.width, e.height, a, n, i);
2197
2266
  return /* @__PURE__ */ F("div", { style: {
2198
2267
  position: "absolute",
2199
2268
  left: `${o.x * r}px`,
@@ -2207,7 +2276,7 @@ function ut({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
2207
2276
  } }, `search-${t}`);
2208
2277
  }),
2209
2278
  x && x.filter((e) => e.pageIndex === t).map((t, o) => /* @__PURE__ */ F(e.Fragment, { children: t.bounds.map((e, o) => {
2210
- let s = st(e.x, i - e.y - e.height, e.width, e.height, a, n, i), c = t.color || "rgba(250, 204, 21, 0.45)", l = t.borderColor || "rgba(234, 179, 8, 0.85)";
2279
+ let s = H(e.x, i - e.y - e.height, e.width, e.height, a, n, i), c = t.color || "rgba(250, 204, 21, 0.45)", l = t.borderColor || "rgba(234, 179, 8, 0.85)";
2211
2280
  return /* @__PURE__ */ F("div", {
2212
2281
  style: {
2213
2282
  position: "absolute",
@@ -2267,7 +2336,7 @@ function ut({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
2267
2336
  onMouseLeave: (e) => C(e, t),
2268
2337
  children: /* @__PURE__ */ F("g", {
2269
2338
  transform: n,
2270
- children: /* @__PURE__ */ I(e.Fragment, { children: [de.map((t) => {
2339
+ children: /* @__PURE__ */ I(e.Fragment, { children: [fe.map((t) => {
2271
2340
  let n = t.type === "text" || t.type === "callout" ? "transparent" : `${t.color}${Math.floor(t.opacity * 255).toString(16).padStart(2, "0")}`, r = t.color, i = y === t.id, a = (t.type === "highlight" || t.opacity < 1) && ![
2272
2341
  "text",
2273
2342
  "note",
@@ -2643,17 +2712,17 @@ function ut({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
2643
2712
  ]
2644
2713
  });
2645
2714
  }
2646
- var dt = e.memo(ut, (e, t) => t.scale <= 4 && e.scale <= 4 ? e.pageNum === t.pageNum && e.scale === t.scale && e.rotation === t.rotation && e.basePageWidth === t.basePageWidth && e.basePageHeight === t.basePageHeight && e.containerWidth === t.containerWidth && e.containerHeight === t.containerHeight && e.activeTab === t.activeTab && e.activeTool === t.activeTool && e.selectedAnnotationId === t.selectedAnnotationId && e.activeSearchResult === t.activeSearchResult && e.watermarkText === t.watermarkText && e.redactions === t.redactions && e.annotations === t.annotations && e.transientHighlights === t.transientHighlights : e.pageNum === t.pageNum && e.scale === t.scale && e.rotation === t.rotation && e.basePageWidth === t.basePageWidth && e.basePageHeight === t.basePageHeight && e.containerWidth === t.containerWidth && e.containerHeight === t.containerHeight && e.scrollTop === t.scrollTop && e.scrollLeft === t.scrollLeft && e.activeTab === t.activeTab && e.activeTool === t.activeTool && e.selectedAnnotationId === t.selectedAnnotationId && e.activeSearchResult === t.activeSearchResult && e.watermarkText === t.watermarkText && e.redactions === t.redactions && e.annotations === t.annotations && e.transientHighlights === t.transientHighlights);
2715
+ var St = e.memo(xt, (e, t) => e.pageNum === t.pageNum && e.pdfDoc === t.pdfDoc && e.scale === t.scale && e.rotation === t.rotation && e.basePageWidth === t.basePageWidth && e.basePageHeight === t.basePageHeight && e.pageTop === t.pageTop && e.pageLeft === t.pageLeft && e.activeTab === t.activeTab && e.activeTool === t.activeTool && e.selectedAnnotationId === t.selectedAnnotationId && e.activeSearchResult === t.activeSearchResult && e.watermark === t.watermark && e.watermarkText === t.watermarkText && e.redactions === t.redactions && e.annotations === t.annotations && e.transientHighlights === t.transientHighlights);
2647
2716
  //#endregion
2648
2717
  //#region src/annotations/ids.ts
2649
- function ft() {
2718
+ function Ct() {
2650
2719
  if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
2651
2720
  let e = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
2652
2721
  return `${e.slice(0, 8)}-${e.slice(8, 12)}-4${e.slice(13, 16)}-a${e.slice(17, 20)}-${e.slice(20, 32)}`;
2653
2722
  }
2654
2723
  //#endregion
2655
2724
  //#region src/utils/findRegexRedactions.ts
2656
- async function pt(e, t) {
2725
+ async function wt(e, t) {
2657
2726
  let n = [];
2658
2727
  if (!e || !t || t.length === 0) return n;
2659
2728
  let r = e.numPages, i = t.map((e) => new RegExp(e, e.flags.includes("g") ? e.flags : e.flags + "g"));
@@ -2701,31 +2770,62 @@ async function pt(e, t) {
2701
2770
  return n;
2702
2771
  }
2703
2772
  //#endregion
2773
+ //#region src/utils/layoutUtils.ts
2774
+ var Tt = {
2775
+ width: 612,
2776
+ height: 792
2777
+ };
2778
+ function Et(e, t = Tt) {
2779
+ if (e <= 0) return [];
2780
+ let n = {
2781
+ width: t.width,
2782
+ height: t.height
2783
+ };
2784
+ return Array.from({ length: e }, () => ({ ...n }));
2785
+ }
2786
+ function Dt(e, t, n, r = 16) {
2787
+ let i = e.map((e) => e.length === 0 ? r : Math.max(...e.map((e) => t(e).height)) * n + r), a = [], o = 0;
2788
+ for (let e of i) a.push(o), o += e;
2789
+ return {
2790
+ heights: i,
2791
+ tops: a,
2792
+ total: o
2793
+ };
2794
+ }
2795
+ function U(e, t, n = .5) {
2796
+ if (e.length !== t.length) return !0;
2797
+ for (let r = 0; r < e.length; r++) {
2798
+ let i = e[r], a = t[r];
2799
+ if (Math.abs(i.width - a.width) > n || Math.abs(i.height - a.height) > n) return !0;
2800
+ }
2801
+ return !1;
2802
+ }
2803
+ //#endregion
2704
2804
  //#region src/core/pdfAssets.ts
2705
- var U = {};
2706
- function mt(e) {
2707
- U = {
2708
- ...U,
2805
+ var W = {};
2806
+ function Ot(e) {
2807
+ W = {
2808
+ ...W,
2709
2809
  ...e
2710
2810
  }, e.workerSrc && (L.GlobalWorkerOptions.workerSrc = e.workerSrc);
2711
2811
  }
2712
- function ht() {
2713
- return U;
2812
+ function G() {
2813
+ return W;
2714
2814
  }
2715
- function gt() {
2716
- return !!(U.workerSrc || L.GlobalWorkerOptions.workerSrc);
2815
+ function kt() {
2816
+ return !!(W.workerSrc || L.GlobalWorkerOptions.workerSrc);
2717
2817
  }
2718
- function _t() {
2719
- if (!gt()) throw Error("[teamsync-pdf-viewer] pdf.js worker not configured. Call configurePdfAssets({ workerSrc }) with the URL of pdf.worker.min.mjs (same pdfjs-dist version) before loading a document, or pass `assets={{ workerSrc }}` to <TeamSyncViewer>.");
2818
+ function At() {
2819
+ if (!kt()) throw Error("[teamsync-pdf-viewer] pdf.js worker not configured. Call configurePdfAssets({ workerSrc }) with the URL of pdf.worker.min.mjs (same pdfjs-dist version) before loading a document, or pass `assets={{ workerSrc }}` to <TeamSyncViewer>.");
2720
2820
  }
2721
- function vt() {
2821
+ function jt() {
2722
2822
  let e = {};
2723
- return U.cMapUrl && (e.cMapUrl = U.cMapUrl, e.cMapPacked = !0), U.standardFontDataUrl && (e.standardFontDataUrl = U.standardFontDataUrl), U.wasmUrl && (e.wasmUrl = U.wasmUrl), U.iccUrl && (e.iccUrl = U.iccUrl), e;
2823
+ return W.cMapUrl && (e.cMapUrl = W.cMapUrl, e.cMapPacked = !0), W.standardFontDataUrl && (e.standardFontDataUrl = W.standardFontDataUrl), W.wasmUrl && (e.wasmUrl = W.wasmUrl), W.iccUrl && (e.iccUrl = W.iccUrl), e;
2724
2824
  }
2725
- var yt = L.version;
2825
+ var Mt = L.version;
2726
2826
  //#endregion
2727
2827
  //#region src/components/DiffHighlightOverlay.tsx
2728
- function bt({ boxes: e, scale: t, colorScheme: n = "all", selectedDiffId: r, onSelectDiff: i }) {
2828
+ function Nt({ boxes: e, scale: t, colorScheme: n = "all", selectedDiffId: r, onSelectDiff: i }) {
2729
2829
  let [a, o] = c(null);
2730
2830
  if (!e || e.length === 0) return null;
2731
2831
  let s = e.filter((e) => n === "deletions" ? e.type === "deletion" || e.type === "modification" : n !== "additions" || e.type === "addition" || e.type === "modification");
@@ -2830,7 +2930,7 @@ function bt({ boxes: e, scale: t, colorScheme: n = "all", selectedDiffId: r, onS
2830
2930
  }
2831
2931
  //#endregion
2832
2932
  //#region src/components/SideBySideViewer.tsx
2833
- function xt({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePageDims: o, activeTab: l, activeTool: u, annotations: d, watermark: f, watermarkText: p, redactions: m, diffsA: h = [], diffsB: g = [], selectedDiffId: _, onSelectDiff: v }) {
2933
+ function Pt({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePageDims: o, activeTab: l, activeTool: u, annotations: d, watermark: f, watermarkText: p, redactions: m, diffsA: h = [], diffsB: g = [], selectedDiffId: _, onSelectDiff: v }) {
2834
2934
  let y = s(null), b = s(null), x = s(!1);
2835
2935
  i(() => {
2836
2936
  let e = y.current, t = b.current;
@@ -2936,7 +3036,7 @@ function xt({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
2936
3036
  height: `${re}px`,
2937
3037
  boxShadow: "0 4px 12px rgba(0,0,0,0.15)"
2938
3038
  },
2939
- children: [e && /* @__PURE__ */ F(dt, {
3039
+ children: [e && /* @__PURE__ */ F(St, {
2940
3040
  pageNum: n,
2941
3041
  pdfDoc: e,
2942
3042
  scale: r,
@@ -2962,7 +3062,7 @@ function xt({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
2962
3062
  watermark: f,
2963
3063
  watermarkText: p,
2964
3064
  redactions: m
2965
- }), /* @__PURE__ */ F(bt, {
3065
+ }), /* @__PURE__ */ F(Nt, {
2966
3066
  boxes: h,
2967
3067
  scale: r,
2968
3068
  colorScheme: "deletions",
@@ -3000,7 +3100,7 @@ function xt({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
3000
3100
  height: `${w}px`,
3001
3101
  boxShadow: "0 4px 12px rgba(0,0,0,0.15)"
3002
3102
  },
3003
- children: [t && /* @__PURE__ */ F(dt, {
3103
+ children: [t && /* @__PURE__ */ F(St, {
3004
3104
  pageNum: n,
3005
3105
  pdfDoc: t,
3006
3106
  scale: r,
@@ -3026,7 +3126,7 @@ function xt({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
3026
3126
  watermark: f,
3027
3127
  watermarkText: p,
3028
3128
  redactions: m
3029
- }), /* @__PURE__ */ F(bt, {
3129
+ }), /* @__PURE__ */ F(Nt, {
3030
3130
  boxes: g,
3031
3131
  scale: r,
3032
3132
  colorScheme: "additions",
@@ -3039,7 +3139,7 @@ function xt({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
3039
3139
  }
3040
3140
  //#endregion
3041
3141
  //#region src/components/CompareToolbar.tsx
3042
- function St({ compareState: e, onSetMode: t, onSetColors: n, onToggleCurtain: r, onPrevDiff: i, onNextDiff: a, onExit: o }) {
3142
+ function Ft({ compareState: e, onSetMode: t, onSetColors: n, onToggleCurtain: r, onPrevDiff: i, onNextDiff: a, onExit: o }) {
3043
3143
  let { mode: s, colorA: c, colorB: l, showCurtain: u, diffItems: d, currentDiffIndex: f } = e;
3044
3144
  return /* @__PURE__ */ I("div", {
3045
3145
  style: {
@@ -3295,7 +3395,7 @@ function St({ compareState: e, onSetMode: t, onSetColors: n, onToggleCurtain: r,
3295
3395
  }
3296
3396
  //#endregion
3297
3397
  //#region src/components/DiffSummarySidebar.tsx
3298
- function Ct({ isOpen: e, diffItems: t, textDiffs: n, currentDiffIndex: r, onSelectDiff: i, onJumpToPage: a }) {
3398
+ function It({ isOpen: e, diffItems: t, textDiffs: n, currentDiffIndex: r, onSelectDiff: i, onJumpToPage: a }) {
3299
3399
  return e ? /* @__PURE__ */ I("div", {
3300
3400
  style: {
3301
3401
  width: "320px",
@@ -3526,7 +3626,7 @@ function Ct({ isOpen: e, diffItems: t, textDiffs: n, currentDiffIndex: r, onSele
3526
3626
  }
3527
3627
  //#endregion
3528
3628
  //#region src/components/CompareCurtainSlider.tsx
3529
- function wt({ positionPercent: e, onChangePosition: t, containerRef: n }) {
3629
+ function Lt({ positionPercent: e, onChangePosition: t, containerRef: n }) {
3530
3630
  let [r, a] = c(!1), o = s(null);
3531
3631
  return i(() => {
3532
3632
  let e = (e) => {
@@ -3583,7 +3683,7 @@ function wt({ positionPercent: e, onChangePosition: t, containerRef: n }) {
3583
3683
  }
3584
3684
  //#endregion
3585
3685
  //#region src/utils/pdfDiffEngine.ts
3586
- async function W(e) {
3686
+ async function Rt(e) {
3587
3687
  let t = e.getViewport({
3588
3688
  scale: 1,
3589
3689
  rotation: e.rotate
@@ -3606,8 +3706,8 @@ async function W(e) {
3606
3706
  }
3607
3707
  return r;
3608
3708
  }
3609
- async function Tt(e, t, n) {
3610
- let [r, i] = await Promise.all([e.getPage(n), t.getPage(Math.min(n, t.numPages))]), [a, o] = await Promise.all([W(r), W(i)]), s = a.map((e) => e.text), c = o.map((e) => e.text), l = s.length, u = c.length, d = l + u, f = new Int32Array(2 * d + 1);
3709
+ async function zt(e, t, n) {
3710
+ let [r, i] = await Promise.all([e.getPage(n), t.getPage(Math.min(n, t.numPages))]), [a, o] = await Promise.all([Rt(r), Rt(i)]), s = a.map((e) => e.text), c = o.map((e) => e.text), l = s.length, u = c.length, d = l + u, f = new Int32Array(2 * d + 1);
3611
3711
  f[1] = 0;
3612
3712
  let p = [];
3613
3713
  for (let e = 0; e <= d; e++) {
@@ -3630,7 +3730,7 @@ async function Tt(e, t, n) {
3630
3730
  e > 0 && (m === i ? (_.push(h - 1), h--) : h === a && (g.push(m - 1), m--));
3631
3731
  }
3632
3732
  g.reverse(), _.reverse();
3633
- let v = G(g.map((e) => a[e]), n, "deletion"), y = G(_.map((e) => o[e]), n, "addition"), b = [];
3733
+ let v = Bt(g.map((e) => a[e]), n, "deletion"), y = Bt(_.map((e) => o[e]), n, "addition"), b = [];
3634
3734
  for (let e of v) b.push({
3635
3735
  id: e.id,
3636
3736
  pageIndex: n,
@@ -3657,16 +3757,16 @@ async function Tt(e, t, n) {
3657
3757
  summary: b
3658
3758
  };
3659
3759
  }
3660
- function G(e, t, n) {
3760
+ function Bt(e, t, n) {
3661
3761
  if (e.length === 0) return [];
3662
3762
  let r = [], i = [e[0]];
3663
3763
  for (let a = 1; a < e.length; a++) {
3664
3764
  let o = i[i.length - 1], s = e[a], c = Math.abs(s.y - o.y) < Math.max(o.height, s.height) * .6, l = s.x - (o.x + o.width) < 30;
3665
- c && l ? i.push(s) : (r.push(K(i, t, n, r.length + 1)), i = [s]);
3765
+ c && l ? i.push(s) : (r.push(Vt(i, t, n, r.length + 1)), i = [s]);
3666
3766
  }
3667
- return i.length > 0 && r.push(K(i, t, n, r.length + 1)), r;
3767
+ return i.length > 0 && r.push(Vt(i, t, n, r.length + 1)), r;
3668
3768
  }
3669
- function K(e, t, n, r) {
3769
+ function Vt(e, t, n, r) {
3670
3770
  let i = Math.min(...e.map((e) => e.x)), a = Math.min(...e.map((e) => e.y)), o = Math.max(...e.map((e) => e.x + e.width)), s = Math.max(...e.map((e) => e.y + e.height)), c = e.map((e) => e.text).join(" ");
3671
3771
  return {
3672
3772
  id: `diff-box-${t}-${n}-${r}-${Math.round(i)}-${Math.round(a)}`,
@@ -3679,7 +3779,7 @@ function K(e, t, n, r) {
3679
3779
  height: s - a + 2
3680
3780
  };
3681
3781
  }
3682
- function Et(e, t, n) {
3782
+ function Ht(e, t, n) {
3683
3783
  let r = e.split(/(\s+)/), i = t.split(/(\s+)/), a = r.length, o = i.length, s = a + o, c = new Int32Array(2 * s + 1);
3684
3784
  c[1] = 0;
3685
3785
  let l = [];
@@ -3690,7 +3790,7 @@ function Et(e, t, n) {
3690
3790
  u = t === -e || t !== e && c[t - 1 + s] < c[t + 1 + s] ? c[t + 1 + s] : c[t - 1 + s] + 1;
3691
3791
  let d = u - t;
3692
3792
  for (; u < a && d < o && r[u] === i[d];) u++, d++;
3693
- if (c[t + s] = u, u >= a && d >= o) return Dt(l, r, i, n);
3793
+ if (c[t + s] = u, u >= a && d >= o) return Ut(l, r, i, n);
3694
3794
  }
3695
3795
  }
3696
3796
  return [{
@@ -3703,7 +3803,7 @@ function Et(e, t, n) {
3703
3803
  pageIndex: n
3704
3804
  }];
3705
3805
  }
3706
- function Dt(e, t, n, r) {
3806
+ function Ut(e, t, n, r) {
3707
3807
  let i = t.length, a = n.length, o = t.length + n.length, s = [];
3708
3808
  for (let r = e.length - 1; r >= 0; r--) {
3709
3809
  let c = e[r], l = i - a, u;
@@ -3729,10 +3829,10 @@ function Dt(e, t, n, r) {
3729
3829
  });
3730
3830
  return c;
3731
3831
  }
3732
- function Ot(e, t, n, r, i = .75) {
3832
+ function Wt(e, t, n, r, i = .75) {
3733
3833
  e.save(), e.globalCompositeOperation = "source-atop", e.fillStyle = r, e.globalAlpha = i, e.fillRect(0, 0, t, n), e.restore();
3734
3834
  }
3735
- function kt(e, t, n, r) {
3835
+ function Gt(e, t, n, r) {
3736
3836
  let i = Math.min(e.width, t.width), a = Math.min(e.height, t.height);
3737
3837
  if (i === 0 || a === 0) return [];
3738
3838
  let o = e.getContext("2d"), s = t.getContext("2d");
@@ -3759,8 +3859,8 @@ function kt(e, t, n, r) {
3759
3859
  }
3760
3860
  //#endregion
3761
3861
  //#region src/components/DocumentViewer.tsx
3762
- function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationManager: u, initialDoc: d, loadNonce: p = 0, withCredentials: h = !1, assets: g, sidebars: _ = !0, redactions: v, regexRedactions: x, scale: S, setScale: C, sidebarTab: te, setSidebarTab: ne, onAnnotationsChange: ie, onRedactionsChange: T, onDocumentLoaded: ae, onLoadError: oe, onFirstPageRendered: E, onPageChange: D, pageTransition: O, pageLayout: se, rotation: A, setRotation: le, watermark: ue, watermarkText: de, enableAnnotations: fe, initialPage: pe, page: me, transientHighlights: _e, permissions: ve }) {
3763
- let j = s(null), ye = Le(), [M, xe] = c(null), [Se, Ce] = c(null), [N, we] = c(1), [Te, Ee] = c([]), { getCommand: De } = Ze(), [ke, P] = c(null), [R, z] = c({
3862
+ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationManager: u, initialDoc: d, loadNonce: p = 0, withCredentials: h = !1, assets: g, sidebars: _ = !0, redactions: v, regexRedactions: x, scale: S, setScale: C, sidebarTab: te, setSidebarTab: ne, onAnnotationsChange: ie, onRedactionsChange: T, onDocumentLoaded: ae, onLoadError: oe, onFirstPageRendered: E, onPageChange: D, pageTransition: O, pageLayout: se, rotation: A, setRotation: le, watermark: ue, watermarkText: de, enableAnnotations: fe, initialPage: pe, page: me, transientHighlights: _e, permissions: ve }) {
3863
+ let j = s(null), ye = Le(), [M, xe] = c(null), [Se, Ce] = c(null), [N, we] = c(1), [Te, Ee] = c([]), { getCommand: De } = Qe(), [ke, P] = c(null), [R, z] = c({
3764
3864
  isActive: !1,
3765
3865
  mode: "overlay",
3766
3866
  colorA: "#e11d48",
@@ -3790,9 +3890,9 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
3790
3890
  Be.current = g;
3791
3891
  let Ve = n(async (e) => {
3792
3892
  try {
3793
- _t(), Be.current && mt(Be.current);
3893
+ At(), Be.current && Ot(Be.current);
3794
3894
  let t = typeof e == "string" ? { url: e } : { data: e };
3795
- h && (t.withCredentials = !0), Object.assign(t, vt());
3895
+ h && (t.withCredentials = !0), Object.assign(t, jt());
3796
3896
  let n = await L.getDocument(t).promise;
3797
3897
  xe(n), ze.current.onDocumentLoaded?.(n, typeof e == "string" ? e : "documentA.pdf");
3798
3898
  } catch (e) {
@@ -3800,9 +3900,9 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
3800
3900
  }
3801
3901
  }, [h]), V = n(async (e) => {
3802
3902
  try {
3803
- _t(), Be.current && mt(Be.current);
3903
+ At(), Be.current && Ot(Be.current);
3804
3904
  let t = typeof e == "string" ? { url: e } : { data: e };
3805
- h && (t.withCredentials = !0), Object.assign(t, vt());
3905
+ h && (t.withCredentials = !0), Object.assign(t, jt());
3806
3906
  let n = await L.getDocument(t).promise;
3807
3907
  P(n), z((e) => ({
3808
3908
  ...e,
@@ -3825,7 +3925,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
3825
3925
  try {
3826
3926
  let t = Math.min(M.numPages, ke.numPages), n = [], r = {}, i = {};
3827
3927
  for (let a = 1; a <= t; a++) {
3828
- let { diffsA: t, diffsB: o, summary: s } = await Tt(M, ke, a);
3928
+ let { diffsA: t, diffsB: o, summary: s } = await zt(M, ke, a);
3829
3929
  if (e) return;
3830
3930
  r[a] = t, i[a] = o, n = n.concat(s);
3831
3931
  }
@@ -3835,7 +3935,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
3835
3935
  pageDiffsA: r,
3836
3936
  pageDiffsB: i
3837
3937
  }));
3838
- let a = await M.getPage(N), o = await ke.getPage(Math.min(N, ke.numPages)), s = await a.getTextContent(), c = await o.getTextContent(), l = Et(s.items.map((e) => e.str).join(" "), c.items.map((e) => e.str).join(" "), N);
3938
+ let a = await M.getPage(N), o = await ke.getPage(Math.min(N, ke.numPages)), s = await a.getTextContent(), c = await o.getTextContent(), l = Ht(s.items.map((e) => e.str).join(" "), c.items.map((e) => e.str).join(" "), N);
3839
3939
  e || Fe(l);
3840
3940
  } catch (e) {
3841
3941
  console.error("Error computing document diffs:", e);
@@ -3886,17 +3986,14 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
3886
3986
  Ve,
3887
3987
  V
3888
3988
  ]);
3889
- let [Ue, Ge] = c(null), [Ke, qe] = c([]), Je = Ke[0] ?? {
3890
- width: 800,
3891
- height: 1100
3892
- }, H = n((e) => Ke[e - 1] ?? Je, [
3989
+ let [Ue, Ge] = c(null), [Ke, qe] = c([]), Je = Ke[0] ?? Tt, Ye = n((e) => Ke[e - 1] ?? Je, [
3893
3990
  Ke,
3894
3991
  Je.width,
3895
3992
  Je.height
3896
- ]), [Ye, Xe] = c({
3993
+ ]), [Xe, Ze] = c({
3897
3994
  top: 0,
3898
3995
  left: 0
3899
- }), [Qe, et] = c(!1), rt = s(null), st = o(() => {
3996
+ }), [$e, tt] = c(!1), it = s(null), H = o(() => {
3900
3997
  let e = [];
3901
3998
  if (!M) return e;
3902
3999
  if (se === "single") for (let t = 1; t <= M.numPages; t++) e.push([t]);
@@ -3906,19 +4003,19 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
3906
4003
  for (let t = 2; t <= M.numPages; t += 2) e.push([t, t + 1].filter((e) => e <= M.numPages));
3907
4004
  }
3908
4005
  return e;
3909
- }, [M, se]), ct = o(() => {
3910
- let e = st.map((e) => Math.max(...e.map((e) => H(e).height)) * S + 16), t = [], n = 0;
3911
- for (let r of e) t.push(n), n += r;
3912
- return {
3913
- heights: e,
3914
- tops: t,
3915
- total: n
3916
- };
3917
- }, [
3918
- st,
4006
+ }, [M, se]), ct = o(() => Dt(H, Ye, S, 16), [
4007
+ H,
3919
4008
  S,
3920
- H
3921
- ]), ut = n((e) => st.findIndex((t) => t.includes(e)), [st]), U = n((e) => {
4009
+ Ye
4010
+ ]), ut = s(H);
4011
+ ut.current = H;
4012
+ let dt = s(S);
4013
+ dt.current = S;
4014
+ let ft = s(ct);
4015
+ ft.current = ct;
4016
+ let pt = s(O);
4017
+ pt.current = O;
4018
+ let mt = s(0), ht = n((e) => H.findIndex((t) => t.includes(e)), [H]), gt = n((e) => {
3922
4019
  let t = ct.tops;
3923
4020
  if (t.length === 0) return 0;
3924
4021
  let n = 0, r = t.length - 1;
@@ -3927,30 +4024,30 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
3927
4024
  t[i] <= e ? n = i : r = i - 1;
3928
4025
  }
3929
4026
  return n;
3930
- }, [ct]), ht = n((e, t = {}) => {
4027
+ }, [ct]), _t = n((e, t = {}) => {
3931
4028
  let n = M ? Math.max(1, Math.min(e, M.numPages)) : Math.max(1, e);
3932
4029
  we(n);
3933
- let r = ut(n);
4030
+ let r = ht(n);
3934
4031
  r >= 0 && j.current && (t.smooth ? j.current.scrollTo({
3935
4032
  top: ct.tops[r],
3936
4033
  behavior: "smooth"
3937
4034
  }) : j.current.scrollTop = ct.tops[r]);
3938
4035
  }, [
3939
4036
  M,
3940
- ut,
4037
+ ht,
3941
4038
  ct
3942
4039
  ]);
3943
4040
  i(() => {
3944
4041
  let e = (e) => {
3945
- e?.page && ht(e.page, { smooth: e.smooth ?? !0 });
4042
+ e?.page && _t(e.page, { smooth: e.smooth ?? !0 });
3946
4043
  }, t = ye.on("action-go-to-page", (t) => e(t)), n = (t) => e(t.detail);
3947
4044
  return window.addEventListener("action-go-to-page", n), () => {
3948
4045
  t(), window.removeEventListener("action-go-to-page", n);
3949
4046
  };
3950
- }, [ye, ht]);
3951
- let gt = (e) => {
3952
- we(e.pageIndex), Ge(e), ht(e.pageIndex);
3953
- }, yt = n((e, t) => {
4047
+ }, [ye, _t]);
4048
+ let yt = (e) => {
4049
+ we(e.pageIndex), Ge(e), _t(e.pageIndex);
4050
+ }, xt = n((e, t) => {
3954
4051
  let n = t || R.diffItems[e];
3955
4052
  if (z((t) => ({
3956
4053
  ...t,
@@ -3959,7 +4056,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
3959
4056
  n.pageIndex && n.pageIndex !== N && we(n.pageIndex);
3960
4057
  let r = (n.y ?? 0) * S, i = (n.x ?? 0) * S;
3961
4058
  if (j.current) {
3962
- let e = n.pageIndex || N, t = ut(e), a = O === "continuous" && t >= 0 ? ct.tops[t] ?? 0 : 0, o = j.current.clientHeight || 600, s = j.current.clientWidth || 800, c = Math.max(0, a + r - o / 3), l = Math.max(0, i - s / 4);
4059
+ let e = n.pageIndex || N, t = ht(e), a = O === "continuous" && t >= 0 ? ct.tops[t] ?? 0 : 0, o = j.current.clientHeight || 600, s = j.current.clientWidth || 800, c = Math.max(0, a + r - o / 3), l = Math.max(0, i - s / 4);
3963
4060
  j.current.scrollTo({
3964
4061
  top: c,
3965
4062
  left: l,
@@ -3971,51 +4068,65 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
3971
4068
  N,
3972
4069
  S,
3973
4070
  O,
3974
- ut,
4071
+ ht,
3975
4072
  ct.tops
3976
- ]), W = l(u.subscribe, u.getSnapshot, u.getSnapshot), [G, K] = c("pan");
4073
+ ]), U = l(u.subscribe, u.getSnapshot, u.getSnapshot), [W, G] = c("pan");
3977
4074
  i(() => {
3978
- a === "Annotate" ? (K("highlight"), Ot("#fbc02d"), Nt(.5), At(16)) : a === "Shapes" ? (K("rectangle"), Nt(1), At(2)) : a === "Fill and Sign" ? K("signature") : a === "View" && K("pan");
4075
+ a === "Annotate" ? (G("highlight"), Mt("#fbc02d"), Ut(.5), Bt(16)) : a === "Shapes" ? (G("rectangle"), Ut(1), Bt(2)) : a === "Fill and Sign" ? G("signature") : a === "View" && G("pan");
3979
4076
  }, [a]), i(() => {
3980
- ye.emit("action-tool-changed", { tool: G });
3981
- }, [G, ye]);
3982
- let [Dt, Ot] = c("#d32f2f"), [kt, At] = c(2), [Mt, Nt] = c(.8), [Pt, Ft] = c(!1), [It, Lt] = c(null), [q, Rt] = c({
4077
+ ye.emit("action-tool-changed", { tool: W });
4078
+ }, [W, ye]);
4079
+ let [kt, Mt] = c("#d32f2f"), [Rt, Bt] = c(2), [Vt, Ut] = c(.8), [Wt, Gt] = c(!1), [Kt, Jt] = c(null), [K, Yt] = c({
3983
4080
  x: 0,
3984
4081
  y: 0
3985
- }), [J, zt] = c({
4082
+ }), [q, Xt] = c({
3986
4083
  x: 0,
3987
4084
  y: 0
3988
- }), [Bt, Vt] = c([]), [Y, Ht] = c(null), [Ut, Wt] = c(""), Gt = s(null), [X, Z] = c(null), [Kt, qt] = c(null), [Jt, Yt] = c(!1), Xt = s(!1), Zt = s(null);
3989
- Re("action-set-tool", (e) => K(e?.tool ?? null));
3990
- let Qt = s({
4085
+ }), [Zt, Qt] = c([]), [J, $t] = c(null), [en, tn] = c(""), nn = s(null), [Y, X] = c(null), [rn, an] = c(null), [on, sn] = c(!1), Z = s(!1), cn = s(null);
4086
+ Re("action-set-tool", (e) => G(e?.tool ?? null));
4087
+ let ln = s({
3991
4088
  vx: null,
3992
4089
  vy: null
3993
- }), $t = s(S);
4090
+ }), un = s(S), dn = s(!1), fn = s(!1);
3994
4091
  i(() => {
3995
- if ($t.current !== S) {
3996
- let e = $t.current, t = S;
3997
- $t.current = S;
4092
+ fn.current = !1;
4093
+ }, [M]), i(() => {
4094
+ if (un.current !== S) {
4095
+ let e = un.current, t = S;
4096
+ un.current = S;
3998
4097
  let n = j.current;
3999
- if (n) {
4000
- let r = n.clientWidth, i = n.clientHeight, a = r / 2, o = i / 2;
4001
- Qt.current.vx !== null && Qt.current.vy !== null && (a = Qt.current.vx, o = Qt.current.vy, Qt.current = {
4002
- vx: null,
4003
- vy: null
4004
- });
4005
- let s = a + n.scrollLeft, c = o + n.scrollTop, l = H(N).width, u = Math.max(0, r / 2 - l * e / 2);
4006
- n.scrollLeft = Math.max(0, r / 2 - l * t / 2) + (s - u) * (t / e) - a, n.scrollTop = t / e * c - o;
4007
- }
4098
+ if (!n) return;
4099
+ let r = dn.current || !fn.current || On.current !== M;
4100
+ fn.current = !0, dn.current = !1;
4101
+ let i = bt({
4102
+ prevScale: e,
4103
+ newScale: t,
4104
+ containerWidth: n.clientWidth,
4105
+ containerHeight: n.clientHeight,
4106
+ currentScrollLeft: n.scrollLeft,
4107
+ currentScrollTop: n.scrollTop,
4108
+ basePageWidth: Ye(N).width,
4109
+ focusPoint: ln.current,
4110
+ isProgrammatic: r
4111
+ });
4112
+ if (ln.current = {
4113
+ vx: null,
4114
+ vy: null
4115
+ }, r && N > 1 && O === "continuous") {
4116
+ let e = ht(N);
4117
+ e >= 0 && (n.scrollTop = ct.tops[e] ?? 0), n.scrollLeft = 0;
4118
+ } else n.scrollLeft = i.scrollLeft, n.scrollTop = i.scrollTop;
4008
4119
  }
4009
4120
  }, [S]), i(() => {
4010
4121
  let e = j.current;
4011
- if (!e || !e) return;
4122
+ if (!e) return;
4012
4123
  let t = (t) => {
4013
4124
  if (t.metaKey || t.ctrlKey) {
4014
4125
  t.preventDefault();
4015
4126
  let n = e.getBoundingClientRect(), r = t.clientX, i = t.clientY, a = Math.exp(-t.deltaY * .002);
4016
4127
  C((e) => {
4017
- let t = Math.min(Math.max(e * a, .5), 64);
4018
- return t !== e && (Qt.current = {
4128
+ let t = vt(e * a);
4129
+ return t !== e && (ln.current = {
4019
4130
  vx: r - n.left,
4020
4131
  vy: i - n.top
4021
4132
  }), t;
@@ -4028,50 +4139,50 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4028
4139
  u.commit(e);
4029
4140
  }, [u]);
4030
4141
  Re("action-commit-digital-signature-local", (e) => {
4031
- e?.tempAnn && Q([...W, e.tempAnn]);
4142
+ e?.tempAnn && Q([...U, e.tempAnn]);
4032
4143
  });
4033
- let en = n(() => {
4144
+ let pn = n(() => {
4034
4145
  u.undo();
4035
- }, [u]), tn = n(() => {
4146
+ }, [u]), mn = n(() => {
4036
4147
  u.redo();
4037
4148
  }, [u]);
4038
4149
  Re("viewer-keydown", (e) => {
4039
4150
  let t = document.activeElement?.tagName === "TEXTAREA" || document.activeElement?.tagName === "INPUT";
4040
- if ($e(e, De("ROTATE_CW"))) {
4151
+ if (et(e, De("ROTATE_CW"))) {
4041
4152
  e.preventDefault(), le((e) => (e + 90) % 360);
4042
4153
  return;
4043
4154
  }
4044
- if ($e(e, De("ROTATE_CCW"))) {
4155
+ if (et(e, De("ROTATE_CCW"))) {
4045
4156
  e.preventDefault(), le((e) => (e - 90) % 360);
4046
4157
  return;
4047
4158
  }
4048
- if ($e(e, De("UNDO"))) {
4049
- e.preventDefault(), en();
4159
+ if (et(e, De("UNDO"))) {
4160
+ e.preventDefault(), pn();
4050
4161
  return;
4051
4162
  }
4052
- if ($e(e, De("REDO"))) {
4053
- e.preventDefault(), tn();
4163
+ if (et(e, De("REDO"))) {
4164
+ e.preventDefault(), mn();
4054
4165
  return;
4055
4166
  }
4056
- if ($e(e, De("SEARCH"))) {
4167
+ if (et(e, De("SEARCH"))) {
4057
4168
  e.preventDefault(), ye.emit("action-open-search");
4058
4169
  return;
4059
4170
  }
4060
- if ($e(e, De("FILE_PICKER"))) {
4171
+ if (et(e, De("FILE_PICKER"))) {
4061
4172
  e.preventDefault(), ye.emit("action-open-file-picker");
4062
4173
  return;
4063
4174
  }
4064
- if (!t && !Y) {
4065
- if ($e(e, De("COPY")) && X) {
4066
- let t = W.find((e) => e.id === X);
4067
- t && (e.preventDefault(), Zt.current = t);
4175
+ if (!t && !J) {
4176
+ if (et(e, De("COPY")) && Y) {
4177
+ let t = U.find((e) => e.id === Y);
4178
+ t && (e.preventDefault(), cn.current = t);
4068
4179
  return;
4069
4180
  }
4070
- if ($e(e, De("PASTE")) && Zt.current) {
4181
+ if (et(e, De("PASTE")) && cn.current) {
4071
4182
  e.preventDefault();
4072
- let t = Zt.current, n = {
4183
+ let t = cn.current, n = {
4073
4184
  ...t,
4074
- id: ft(),
4185
+ id: Ct(),
4075
4186
  pageIndex: N,
4076
4187
  x: t.x + 20,
4077
4188
  y: t.y + 20,
@@ -4082,66 +4193,80 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4082
4193
  readOnly: void 0,
4083
4194
  xfdfExtras: void 0
4084
4195
  };
4085
- Q([...W, n]), Z(n.id);
4196
+ Q([...U, n]), X(n.id);
4086
4197
  return;
4087
4198
  }
4088
- if ($e(e, De("DELETE")) && X) {
4089
- e.preventDefault(), Q(W.filter((e) => e.id !== X)), Z(null);
4199
+ if (et(e, De("DELETE")) && Y) {
4200
+ e.preventDefault(), Q(U.filter((e) => e.id !== Y)), X(null);
4090
4201
  return;
4091
4202
  }
4092
4203
  }
4093
4204
  }), i(() => {
4094
- Y && Gt.current && setTimeout(() => {
4095
- Gt.current?.focus();
4205
+ J && nn.current && setTimeout(() => {
4206
+ nn.current?.focus();
4096
4207
  }, 10);
4097
- }, [Y]), i(() => {
4098
- ie && ie(W);
4099
- }, [W, ie]);
4100
- let [nn, rn] = c([]);
4208
+ }, [J]), i(() => {
4209
+ ie && ie(U);
4210
+ }, [U, ie]);
4211
+ let [hn, gn] = c([]);
4101
4212
  i(() => {
4102
4213
  if (M && x && x.length > 0) {
4103
4214
  let e = !1;
4104
- return pt(M, x).then((t) => {
4105
- e || rn(t);
4215
+ return wt(M, x).then((t) => {
4216
+ e || gn(t);
4106
4217
  }), () => {
4107
4218
  e = !0;
4108
4219
  };
4109
4220
  }
4110
- rn([]);
4221
+ gn([]);
4111
4222
  }, [M, x]);
4112
- let [$, an] = c(!1), on = o(() => [
4223
+ let [_n, vn] = c(!1), yn = o(() => [
4113
4224
  ...v || [],
4114
- ...nn,
4225
+ ...hn,
4115
4226
  ...Te
4116
4227
  ], [
4117
4228
  v,
4118
- nn,
4229
+ hn,
4119
4230
  Te
4120
4231
  ]);
4121
4232
  i(() => {
4122
- ze.current.onRedactionsChange?.(on);
4123
- }, [on]);
4124
- let sn = o(() => on.filter((e) => e.status === "pending").length, [on]), cn = n(() => {
4125
- Ee((e) => e.filter((e) => e.status === "applied")), rn((e) => e.filter((e) => e.status === "applied"));
4126
- }, []), ln = n((e) => {
4127
- Ee((t) => t.filter((t) => t !== e && t.id !== e.id)), rn((t) => t.filter((t) => t !== e && t.id !== e.id));
4128
- }, []), { search: un, searchResults: dn, isSearching: fn, searchProgress: pn } = tt(M, on);
4233
+ ze.current.onRedactionsChange?.(yn);
4234
+ }, [yn]);
4235
+ let $ = o(() => yn.filter((e) => e.status === "pending").length, [yn]), bn = n(() => {
4236
+ Ee((e) => e.filter((e) => e.status === "applied")), gn((e) => e.filter((e) => e.status === "applied"));
4237
+ }, []), xn = n((e) => {
4238
+ Ee((t) => t.filter((t) => t !== e && t.id !== e.id)), gn((t) => t.filter((t) => t !== e && t.id !== e.id));
4239
+ }, []), { search: Sn, searchResults: Cn, isSearching: wn, searchProgress: Tn } = nt(M, yn);
4129
4240
  i(() => {
4130
- dn.length === 0 && Ge(null);
4131
- }, [dn]);
4132
- let mn = s(!1);
4241
+ Cn.length === 0 && Ge(null);
4242
+ }, [Cn]);
4243
+ let En = s(!1);
4133
4244
  i(() => {
4134
- if (xe(null), Ce(null), we(1), qe([]), mn.current = !1, !d) return;
4245
+ if (xe(null), Ce(null), we(1), qe([]), En.current = !1, !d) return;
4135
4246
  let e = d, t = !1, n = null;
4136
4247
  return (async () => {
4137
4248
  try {
4138
- Be.current && mt(Be.current), _t(), n = L.getDocument({
4249
+ Be.current && Ot(Be.current), At(), n = L.getDocument({
4139
4250
  url: e,
4140
4251
  withCredentials: h,
4141
- ...vt()
4252
+ ...jt()
4142
4253
  });
4143
4254
  let r = await n.promise;
4144
4255
  if (t) return;
4256
+ try {
4257
+ let e = await r.getPage(1);
4258
+ if (!t) {
4259
+ let t = e.getViewport({
4260
+ scale: 1,
4261
+ rotation: lt(e.rotate + A)
4262
+ });
4263
+ qe(Et(r.numPages, {
4264
+ width: t.width,
4265
+ height: t.height
4266
+ }));
4267
+ }
4268
+ } catch {}
4269
+ if (t) return;
4145
4270
  xe(r), ze.current.onDocumentLoaded?.(r, e);
4146
4271
  } catch (n) {
4147
4272
  if (t) return;
@@ -4157,155 +4282,183 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4157
4282
  }, [
4158
4283
  d,
4159
4284
  p,
4160
- h
4285
+ h,
4286
+ A
4161
4287
  ]);
4162
- let hn = n((e) => {
4163
- mn.current || (mn.current = !0, ze.current.onFirstPageRendered?.(e));
4288
+ let Dn = n((e) => {
4289
+ En.current || (En.current = !0, ze.current.onFirstPageRendered?.(e));
4164
4290
  }, []);
4165
4291
  i(() => {
4166
4292
  M && ze.current.onPageChange?.(N, M.numPages);
4167
4293
  }, [N, M]);
4168
- let gn = s(null), _n = s(void 0);
4294
+ let On = s(null), kn = s(void 0);
4169
4295
  i(() => {
4170
4296
  let e = me ?? pe;
4171
- if (!M || !e || gn.current === M && _n.current === e || Ke.length < Math.min(e, M.numPages)) return;
4172
- let t = gn.current !== M;
4173
- gn.current = M, _n.current = e;
4174
- let n = setTimeout(() => ht(e, { smooth: !t }), 50);
4297
+ if (!M || !e || On.current === M && kn.current === e || Ke.length < Math.min(e, M.numPages)) return;
4298
+ let t = On.current !== M;
4299
+ On.current = M, kn.current = e;
4300
+ let n = setTimeout(() => _t(e, { smooth: !t }), 50);
4175
4301
  return () => clearTimeout(n);
4176
4302
  }, [
4177
4303
  M,
4178
4304
  me,
4179
4305
  pe,
4180
4306
  Ke.length,
4181
- ht
4307
+ _t
4182
4308
  ]), i(() => {
4183
4309
  if (!M) return;
4184
4310
  let e = !1, t = M;
4185
4311
  return (async () => {
4186
- let n = [];
4187
- for (let r = 1; r <= t.numPages; r++) {
4188
- let i;
4189
- try {
4190
- i = await t.getPage(r);
4191
- } catch {
4192
- return;
4193
- }
4312
+ let n;
4313
+ try {
4314
+ n = await t.getPage(1);
4315
+ } catch {
4316
+ return;
4317
+ }
4318
+ if (e) return;
4319
+ let r = n.getViewport({
4320
+ scale: 1,
4321
+ rotation: lt(n.rotate + A)
4322
+ }), i = {
4323
+ width: r.width,
4324
+ height: r.height
4325
+ };
4326
+ if (qe((e) => e.length === t.numPages && Math.abs((e[0]?.width ?? 0) - i.width) <= .5 && Math.abs((e[0]?.height ?? 0) - i.height) <= .5 ? e : Et(t.numPages, i)), t.numPages <= 1) return;
4327
+ let a = Et(t.numPages, i), o = !1;
4328
+ for (let n = 2; n <= t.numPages; n += 25) {
4194
4329
  if (e) return;
4195
- let a = i.getViewport({
4196
- scale: 1,
4197
- rotation: lt(i.rotate + A)
4198
- });
4199
- n.push({
4200
- width: a.width,
4201
- height: a.height
4202
- }), (r === 1 || r % 50 == 0) && qe([...n]);
4330
+ let r = Math.min(t.numPages, n + 25 - 1), s = [];
4331
+ for (let c = n; c <= r; c++) {
4332
+ let n = c;
4333
+ s.push((async () => {
4334
+ try {
4335
+ let r = await t.getPage(n);
4336
+ if (e) return;
4337
+ let s = r.getViewport({
4338
+ scale: 1,
4339
+ rotation: lt(r.rotate + A)
4340
+ });
4341
+ (Math.abs(s.width - i.width) > .5 || Math.abs(s.height - i.height) > .5) && (o = !0), a[n - 1] = {
4342
+ width: s.width,
4343
+ height: s.height
4344
+ };
4345
+ } catch {}
4346
+ })());
4347
+ }
4348
+ await Promise.all(s);
4349
+ }
4350
+ if (!e && o) {
4351
+ let e = j.current;
4352
+ if (e && e.scrollTop > 0 && pt.current === "continuous") {
4353
+ let t = mt.current, n = Dt(ut.current, (e) => a[e - 1] ?? i, dt.current, 16), r = ft.current.tops[t] ?? 0, o = (n.tops[t] ?? 0) - r;
4354
+ o !== 0 && (e.scrollTop += o);
4355
+ }
4356
+ qe(a);
4203
4357
  }
4204
- e || qe(n);
4205
4358
  })(), () => {
4206
4359
  e = !0;
4207
4360
  };
4208
4361
  }, [M, A]);
4209
- let vn = n(() => {
4210
- let e = H(N);
4362
+ let An = n(() => {
4363
+ let e = Ye(N);
4211
4364
  if (!j.current || !e.width) return;
4212
4365
  let t = j.current.clientWidth - 48;
4213
4366
  if (t > 0 && e.width > 0) {
4214
- let n = t / e.width;
4215
- C(Math.max(.1, Math.min(32, parseFloat(n.toFixed(2)))));
4367
+ let n = vt(t / e.width);
4368
+ dn.current = !0, j.current && (N === 1 || j.current.scrollTop <= 1) && (j.current.scrollTop = 0, j.current.scrollLeft = 0), C(n);
4216
4369
  }
4217
4370
  }, [
4218
- H,
4371
+ Ye,
4219
4372
  N,
4220
4373
  C
4221
- ]), yn = n(() => {
4222
- let e = H(N);
4374
+ ]), jn = n(() => {
4375
+ let e = Ye(N);
4223
4376
  if (!j.current || !e.width || !e.height) return;
4224
4377
  let t = j.current.clientWidth - 48, n = j.current.clientHeight - 48;
4225
4378
  if (t > 0 && n > 0 && e.width > 0 && e.height > 0) {
4226
- let r = t / e.width, i = n / e.height;
4227
- C(Math.max(.1, Math.min(32, parseFloat(Math.min(r, i).toFixed(2)))));
4379
+ let r = t / e.width, i = n / e.height, a = vt(Math.min(r, i));
4380
+ dn.current = !0, j.current && (N === 1 || j.current.scrollTop <= 1) && (j.current.scrollTop = 0, j.current.scrollLeft = 0), C(a);
4228
4381
  }
4229
4382
  }, [
4230
- H,
4383
+ Ye,
4231
4384
  N,
4232
4385
  C
4233
4386
  ]);
4234
- Re("action-fit-to-width", () => vn()), Re("action-fit-to-page", () => yn());
4235
- let bn = (e, t) => {
4236
- let n = e.currentTarget.getBoundingClientRect(), r = (e.clientX - n.left) / S, i = (e.clientY - n.top) / S, a = H(t);
4237
- return at(r, i, A, A % 180 == 0 ? a.width : a.height, A % 180 == 0 ? a.height : a.width);
4238
- }, xn = (e, t) => {
4239
- if (!G) return;
4240
- let { x: n, y: r } = bn(e, t);
4241
- if (G === "text" || G === "note") {
4387
+ Re("action-fit-to-width", () => An()), Re("action-fit-to-page", () => jn());
4388
+ let Mn = (e, t) => {
4389
+ let n = e.currentTarget.getBoundingClientRect(), r = (e.clientX - n.left) / S, i = (e.clientY - n.top) / S, a = Ye(t);
4390
+ return ot(r, i, A, A % 180 == 0 ? a.width : a.height, A % 180 == 0 ? a.height : a.width);
4391
+ }, Nn = (e, t) => {
4392
+ if (!W) return;
4393
+ let { x: n, y: r } = Mn(e, t);
4394
+ if (W === "text" || W === "note") {
4242
4395
  e.preventDefault();
4243
4396
  return;
4244
4397
  }
4245
- if (G === "eraser") {
4246
- Ft(!0);
4398
+ if (W === "eraser") {
4399
+ Gt(!0);
4247
4400
  return;
4248
4401
  }
4249
- Rt({
4402
+ Yt({
4250
4403
  x: n,
4251
4404
  y: r
4252
- }), zt({
4405
+ }), Xt({
4253
4406
  x: n,
4254
4407
  y: r
4255
- }), G === "freehand" ? (Ft(!0), Vt([{
4408
+ }), W === "freehand" ? (Gt(!0), Qt([{
4256
4409
  x: n,
4257
4410
  y: r
4258
- }]), Lt(t)) : ([
4411
+ }]), Jt(t)) : ([
4259
4412
  "rectangle",
4260
4413
  "ellipse",
4261
4414
  "line",
4262
4415
  "arrow",
4263
4416
  "highlight",
4264
4417
  "redaction"
4265
- ].includes(G) || ["callout", "link"].includes(G)) && (Ft(!0), Lt(t));
4266
- }, Sn = () => {
4267
- if (Y && Ut.trim()) {
4268
- if (Y.annId) Q(W.map((e) => e.id === Y.annId ? {
4418
+ ].includes(W) || ["callout", "link"].includes(W)) && (Gt(!0), Jt(t));
4419
+ }, Pn = () => {
4420
+ if (J && en.trim()) {
4421
+ if (J.annId) Q(U.map((e) => e.id === J.annId ? {
4269
4422
  ...e,
4270
- text: Ut
4423
+ text: en
4271
4424
  } : e));
4272
4425
  else {
4273
- let e = ft();
4274
- Q([...W, {
4426
+ let e = Ct();
4427
+ Q([...U, {
4275
4428
  id: e,
4276
- type: Y.type,
4277
- pageIndex: Y.pageIndex,
4278
- x: Y.x,
4279
- y: Y.y,
4280
- width: Math.max(100, Ut.length * 8 + 20),
4429
+ type: J.type,
4430
+ pageIndex: J.pageIndex,
4431
+ x: J.x,
4432
+ y: J.y,
4433
+ width: Math.max(100, en.length * 8 + 20),
4281
4434
  height: 30,
4282
- text: Ut,
4283
- points: Y.points,
4284
- color: Dt,
4285
- strokeWidth: kt,
4286
- opacity: Mt
4435
+ text: en,
4436
+ points: J.points,
4437
+ color: kt,
4438
+ strokeWidth: Rt,
4439
+ opacity: Vt
4287
4440
  }]);
4288
4441
  }
4289
4442
  }
4290
- Ht(null), Wt(""), G === "text" && K(null);
4291
- }, Cn = (e, t) => {
4292
- if (!Pt) return;
4293
- let { x: n, y: r } = bn(e, t);
4294
- zt({
4443
+ $t(null), tn(""), W === "text" && G(null);
4444
+ }, Fn = (e, t) => {
4445
+ if (!Wt) return;
4446
+ let { x: n, y: r } = Mn(e, t);
4447
+ Xt({
4295
4448
  x: n,
4296
4449
  y: r
4297
- }), G === "freehand" && Vt((e) => [...e, {
4450
+ }), W === "freehand" && Qt((e) => [...e, {
4298
4451
  x: n,
4299
4452
  y: r
4300
4453
  }]);
4301
- }, wn = (e, t) => {
4302
- if (G === "text" || G === "note" || G === "digital_signature" || G === "link") {
4303
- let { x: n, y: r } = bn(e, t);
4304
- if (G === "link") {
4305
- let e = Math.abs(J.x - q.x), i = Math.abs(J.y - q.y), a = Math.min(q.x, J.x), o = Math.min(q.y, J.y);
4454
+ }, In = (e, t) => {
4455
+ if (W === "text" || W === "note" || W === "digital_signature" || W === "link") {
4456
+ let { x: n, y: r } = Mn(e, t);
4457
+ if (W === "link") {
4458
+ let e = Math.abs(q.x - K.x), i = Math.abs(q.y - K.y), a = Math.min(K.x, q.x), o = Math.min(K.y, q.y);
4306
4459
  (e < 5 || i < 5) && (a = n, o = r, e = 120, i = 35);
4307
- let s = ft();
4308
- Q([...W, {
4460
+ let s = Ct();
4461
+ Q([...U, {
4309
4462
  id: s,
4310
4463
  type: "link",
4311
4464
  pageIndex: t,
@@ -4318,53 +4471,53 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4318
4471
  strokeWidth: 0,
4319
4472
  opacity: 1,
4320
4473
  text: ""
4321
- }]), Ft(!1), Lt(null), Xt.current = !0, Z(s), Yt(!0), K(null);
4474
+ }]), Gt(!1), Jt(null), Z.current = !0, X(s), sn(!0), G(null);
4322
4475
  return;
4323
4476
  }
4324
- (G === "text" || G === "note") && (Y && Sn(), Ht({
4477
+ (W === "text" || W === "note") && (J && Pn(), $t({
4325
4478
  x: n,
4326
4479
  y: r,
4327
- type: G,
4480
+ type: W,
4328
4481
  pageIndex: t
4329
- }), Wt(""));
4482
+ }), tn(""));
4330
4483
  return;
4331
4484
  }
4332
- if (Pt && (Ft(!1), Lt(null), G)) {
4333
- if (G === "freehand") {
4334
- if (Bt.length > 2) {
4335
- let e = Bt.map((e) => e.x), n = Bt.map((e) => e.y), r = Math.min(...e), i = Math.max(...e), a = Math.min(...n), o = Math.max(...n);
4336
- Q([...W, {
4337
- id: ft(),
4338
- type: G,
4485
+ if (Wt && (Gt(!1), Jt(null), W)) {
4486
+ if (W === "freehand") {
4487
+ if (Zt.length > 2) {
4488
+ let e = Zt.map((e) => e.x), n = Zt.map((e) => e.y), r = Math.min(...e), i = Math.max(...e), a = Math.min(...n), o = Math.max(...n);
4489
+ Q([...U, {
4490
+ id: Ct(),
4491
+ type: W,
4339
4492
  pageIndex: t,
4340
4493
  x: r,
4341
4494
  y: a,
4342
4495
  width: i - r,
4343
4496
  height: o - a,
4344
- points: [...Bt],
4345
- strokes: [[...Bt]],
4346
- color: Dt,
4347
- strokeWidth: kt,
4348
- opacity: Mt
4497
+ points: [...Zt],
4498
+ strokes: [[...Zt]],
4499
+ color: kt,
4500
+ strokeWidth: Rt,
4501
+ opacity: Vt
4349
4502
  }]);
4350
4503
  }
4351
- Vt([]);
4504
+ Qt([]);
4352
4505
  } else {
4353
- let e = Math.abs(J.x - q.x), n = Math.abs(J.y - q.y);
4506
+ let e = Math.abs(q.x - K.x), n = Math.abs(q.y - K.y);
4354
4507
  if (e > 5 || n > 5) {
4355
- let r = Math.min(q.x, J.x), i = Math.min(q.y, J.y), a = G === "line" || G === "arrow" || G === "callout" ? [q, J] : void 0;
4356
- if ((G === "highlight" || G === "redaction") && n < 18 && (n = Math.max(18, n), i = q.y - 9), G === "callout") {
4508
+ let r = Math.min(K.x, q.x), i = Math.min(K.y, q.y), a = W === "line" || W === "arrow" || W === "callout" ? [K, q] : void 0;
4509
+ if ((W === "highlight" || W === "redaction") && n < 18 && (n = Math.max(18, n), i = K.y - 9), W === "callout") {
4357
4510
  if (ve?.canAddAnnotations === !1) return;
4358
- Ht({
4359
- x: J.x,
4360
- y: J.y,
4511
+ $t({
4512
+ x: q.x,
4513
+ y: q.y,
4361
4514
  type: "callout",
4362
4515
  points: a,
4363
4516
  pageIndex: t
4364
- }), Wt("");
4517
+ }), tn("");
4365
4518
  return;
4366
4519
  }
4367
- if (G === "redaction") {
4520
+ if (W === "redaction") {
4368
4521
  if (ve?.canRedact === !1) return;
4369
4522
  Ee((a) => [...a, {
4370
4523
  id: `manual-${Date.now()}-${Math.random().toString(36).substr(2, 6)}`,
@@ -4378,34 +4531,34 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4378
4531
  return;
4379
4532
  }
4380
4533
  if (ve?.canAddAnnotations === !1) return;
4381
- Q([...W, {
4382
- id: ft(),
4383
- type: G,
4534
+ Q([...U, {
4535
+ id: Ct(),
4536
+ type: W,
4384
4537
  pageIndex: t,
4385
4538
  x: r,
4386
4539
  y: i,
4387
4540
  width: e,
4388
4541
  height: n,
4389
4542
  points: a,
4390
- color: Dt,
4391
- strokeWidth: kt,
4392
- opacity: Mt
4543
+ color: kt,
4544
+ strokeWidth: Rt,
4545
+ opacity: Vt
4393
4546
  }]);
4394
4547
  }
4395
4548
  }
4396
4549
  }
4397
- }, Tn = (e) => {
4398
- G === "eraser" && Pt && Q(W.filter((t) => t.id !== e));
4399
- }, En = (e, t) => {
4400
- if (t.stopPropagation(), G === "eraser") {
4550
+ }, Ln = (e) => {
4551
+ W === "eraser" && Wt && Q(U.filter((t) => t.id !== e));
4552
+ }, Rn = (e, t) => {
4553
+ if (t.stopPropagation(), W === "eraser") {
4401
4554
  if (ve?.canDeleteAnnotations === !1) return;
4402
- Q(W.filter((t) => t.id !== e)), X === e && (Z(null), qt(null));
4403
- } else if (G === null || G === "pan") {
4404
- let n = W.find((t) => t.id === e);
4555
+ Q(U.filter((t) => t.id !== e)), Y === e && (X(null), an(null));
4556
+ } else if (W === null || W === "pan") {
4557
+ let n = U.find((t) => t.id === e);
4405
4558
  if (n && n.linkUrl && a === "View") {
4406
4559
  if (n.linkUrl.startsWith("#page=")) {
4407
4560
  let e = parseInt(n.linkUrl.split("=")[1]);
4408
- ht(e);
4561
+ _t(e);
4409
4562
  } else {
4410
4563
  let e = n.linkUrl;
4411
4564
  /^https?:\/\//i.test(e) || (e = "https://" + e);
@@ -4416,45 +4569,45 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4416
4569
  }
4417
4570
  if (n && (n.type === "note" || n.type === "callout" || n.type === "text")) {
4418
4571
  if (ve?.canEditAnnotations === !1 || !u.canEdit(n)) {
4419
- Z(e);
4572
+ X(e);
4420
4573
  return;
4421
4574
  }
4422
- Ht({
4575
+ $t({
4423
4576
  x: n.x,
4424
4577
  y: n.y,
4425
4578
  type: n.type,
4426
4579
  annId: n.id,
4427
4580
  points: n.points,
4428
4581
  pageIndex: n.pageIndex
4429
- }), Wt(n.text || ""), n.color && Ot(n.color);
4582
+ }), tn(n.text || ""), n.color && Mt(n.color);
4430
4583
  } else if (n && n.type === "link") {
4431
4584
  if (ve?.canEditAnnotations === !1 || !u.canEdit(n)) {
4432
- Z(e);
4585
+ X(e);
4433
4586
  return;
4434
4587
  }
4435
- Yt(!0);
4588
+ sn(!0);
4436
4589
  }
4437
- Z(e);
4590
+ X(e);
4438
4591
  let r = j.current, i = r?.getBoundingClientRect();
4439
- i && r && qt({
4592
+ i && r && an({
4440
4593
  top: t.clientY - i.top + r.scrollTop,
4441
4594
  left: t.clientX - i.left + r.scrollLeft
4442
4595
  });
4443
4596
  }
4444
- }, Dn = s(0);
4597
+ };
4445
4598
  return i(() => {
4446
4599
  if (M && j.current && O === "continuous") {
4447
- let e = Ye.top + j.current.clientHeight / 2, t = Math.max(0, Math.min(st.length - 1, U(e))), n = st[t] ? st[t][0] : 1;
4600
+ let e = Xe.top + j.current.clientHeight / 2, t = Math.max(0, Math.min(H.length - 1, gt(e))), n = H[t] ? H[t][0] : 1;
4448
4601
  n !== N && we(n);
4449
4602
  }
4450
4603
  }, [
4451
- Ye.top,
4604
+ Xe.top,
4452
4605
  S,
4453
4606
  M,
4454
4607
  N,
4455
- U,
4608
+ gt,
4456
4609
  O,
4457
- st
4610
+ H
4458
4611
  ]), /* @__PURE__ */ I("div", {
4459
4612
  style: {
4460
4613
  flex: 1,
@@ -4464,11 +4617,11 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4464
4617
  overflow: "hidden"
4465
4618
  },
4466
4619
  children: [
4467
- _ && /* @__PURE__ */ F(it, {
4620
+ _ && /* @__PURE__ */ F(at, {
4468
4621
  isOpen: t,
4469
4622
  pdfDoc: M,
4470
4623
  pageNum: N,
4471
- setPageNum: (e) => ht(e)
4624
+ setPageNum: (e) => _t(e)
4472
4625
  }),
4473
4626
  /* @__PURE__ */ I("div", {
4474
4627
  style: {
@@ -4481,7 +4634,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4481
4634
  overflow: "hidden"
4482
4635
  },
4483
4636
  children: [
4484
- R.isActive && /* @__PURE__ */ F(St, {
4637
+ R.isActive && /* @__PURE__ */ F(Ft, {
4485
4638
  compareState: R,
4486
4639
  onSetMode: (e) => z((t) => ({
4487
4640
  ...t,
@@ -4499,12 +4652,12 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4499
4652
  onPrevDiff: () => {
4500
4653
  if (R.diffItems.length === 0) return;
4501
4654
  let e = (R.currentDiffIndex - 1 + R.diffItems.length) % R.diffItems.length;
4502
- yt(e);
4655
+ xt(e);
4503
4656
  },
4504
4657
  onNextDiff: () => {
4505
4658
  if (R.diffItems.length === 0) return;
4506
4659
  let e = (R.currentDiffIndex + 1) % R.diffItems.length;
4507
- yt(e);
4660
+ xt(e);
4508
4661
  },
4509
4662
  onExit: () => {
4510
4663
  z((e) => ({
@@ -4524,35 +4677,35 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4524
4677
  height: "40px"
4525
4678
  },
4526
4679
  children: [
4527
- /* @__PURE__ */ F(jt, {
4680
+ /* @__PURE__ */ F(qt, {
4528
4681
  icon: /* @__PURE__ */ F(k, { size: 16 }),
4529
- active: G === "highlight",
4682
+ active: W === "highlight",
4530
4683
  onClick: () => {
4531
- K("highlight"), Ot("#fbc02d"), Nt(.5), At(16);
4684
+ G("highlight"), Mt("#fbc02d"), Ut(.5), Bt(16);
4532
4685
  },
4533
4686
  label: "Text Highlight"
4534
4687
  }),
4535
- /* @__PURE__ */ F(jt, {
4688
+ /* @__PURE__ */ F(qt, {
4536
4689
  icon: /* @__PURE__ */ F(m, { size: 16 }),
4537
- active: G === "freehand",
4690
+ active: W === "freehand",
4538
4691
  onClick: () => {
4539
- K("freehand"), Ot("#000000"), Nt(1), At(2);
4692
+ G("freehand"), Mt("#000000"), Ut(1), Bt(2);
4540
4693
  },
4541
4694
  label: "Marker"
4542
4695
  }),
4543
- /* @__PURE__ */ F(jt, {
4696
+ /* @__PURE__ */ F(qt, {
4544
4697
  icon: /* @__PURE__ */ F(Me, { size: 16 }),
4545
- active: G === "text",
4698
+ active: W === "text",
4546
4699
  onClick: () => {
4547
- K("text"), Ot("#000000"), Nt(1);
4700
+ G("text"), Mt("#000000"), Ut(1);
4548
4701
  },
4549
4702
  label: "Text"
4550
4703
  }),
4551
- ve?.canRedact !== !1 && /* @__PURE__ */ F(jt, {
4704
+ ve?.canRedact !== !1 && /* @__PURE__ */ F(qt, {
4552
4705
  icon: /* @__PURE__ */ F(w, { size: 16 }),
4553
- active: G === "redaction",
4706
+ active: W === "redaction",
4554
4707
  onClick: () => {
4555
- K("redaction"), Ot("#000000"), Nt(1);
4708
+ G("redaction"), Mt("#000000"), Ut(1);
4556
4709
  },
4557
4710
  label: "Redact"
4558
4711
  }),
@@ -4569,11 +4722,11 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4569
4722
  borderRight: "1px solid var(--border-color)",
4570
4723
  paddingRight: "8px"
4571
4724
  },
4572
- children: /* @__PURE__ */ F(jt, {
4725
+ children: /* @__PURE__ */ F(qt, {
4573
4726
  icon: /* @__PURE__ */ F(he, { size: 16 }),
4574
- active: G === "callout",
4727
+ active: W === "callout",
4575
4728
  onClick: () => {
4576
- K("callout"), Nt(1), At(2);
4729
+ G("callout"), Ut(1), Bt(2);
4577
4730
  },
4578
4731
  label: "Callout"
4579
4732
  })
@@ -4583,17 +4736,17 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4583
4736
  display: "flex",
4584
4737
  gap: "4px"
4585
4738
  },
4586
- children: [/* @__PURE__ */ F(jt, {
4739
+ children: [/* @__PURE__ */ F(qt, {
4587
4740
  icon: /* @__PURE__ */ F(be, { size: 16 }),
4588
- active: G === "freehand" && Mt === 1,
4741
+ active: W === "freehand" && Vt === 1,
4589
4742
  onClick: () => {
4590
- K("freehand"), Nt(1), At(2);
4743
+ G("freehand"), Ut(1), Bt(2);
4591
4744
  },
4592
4745
  label: "Freehand"
4593
- }), ve?.canDeleteAnnotations !== !1 && /* @__PURE__ */ F(jt, {
4746
+ }), ve?.canDeleteAnnotations !== !1 && /* @__PURE__ */ F(qt, {
4594
4747
  icon: /* @__PURE__ */ F(re, { size: 16 }),
4595
- active: G === "eraser",
4596
- onClick: () => K("eraser"),
4748
+ active: W === "eraser",
4749
+ onClick: () => G("eraser"),
4597
4750
  label: "Eraser"
4598
4751
  })]
4599
4752
  }),
@@ -4609,34 +4762,34 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4609
4762
  gap: "4px"
4610
4763
  },
4611
4764
  children: [
4612
- /* @__PURE__ */ F(jt, {
4765
+ /* @__PURE__ */ F(qt, {
4613
4766
  icon: /* @__PURE__ */ F(ge, { size: 16 }),
4614
- active: G === "line",
4615
- onClick: () => K("line"),
4767
+ active: W === "line",
4768
+ onClick: () => G("line"),
4616
4769
  label: "Line"
4617
4770
  }),
4618
- /* @__PURE__ */ F(jt, {
4771
+ /* @__PURE__ */ F(qt, {
4619
4772
  icon: /* @__PURE__ */ F(f, { size: 16 }),
4620
- active: G === "arrow",
4621
- onClick: () => K("arrow"),
4773
+ active: W === "arrow",
4774
+ onClick: () => G("arrow"),
4622
4775
  label: "Arrow"
4623
4776
  }),
4624
- /* @__PURE__ */ F(jt, {
4777
+ /* @__PURE__ */ F(qt, {
4625
4778
  icon: /* @__PURE__ */ F(Ae, { size: 16 }),
4626
- active: G === "rectangle",
4627
- onClick: () => K("rectangle"),
4779
+ active: W === "rectangle",
4780
+ onClick: () => G("rectangle"),
4628
4781
  label: "Rectangle"
4629
4782
  }),
4630
- /* @__PURE__ */ F(jt, {
4783
+ /* @__PURE__ */ F(qt, {
4631
4784
  icon: /* @__PURE__ */ F(ee, { size: 16 }),
4632
- active: G === "ellipse",
4633
- onClick: () => K("ellipse"),
4785
+ active: W === "ellipse",
4786
+ onClick: () => G("ellipse"),
4634
4787
  label: "Ellipse"
4635
4788
  }),
4636
- /* @__PURE__ */ F(jt, {
4789
+ /* @__PURE__ */ F(qt, {
4637
4790
  icon: /* @__PURE__ */ F(ce, { size: 16 }),
4638
- active: G === "link",
4639
- onClick: () => K("link"),
4791
+ active: W === "link",
4792
+ onClick: () => G("link"),
4640
4793
  label: "Link"
4641
4794
  })
4642
4795
  ]
@@ -4656,7 +4809,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4656
4809
  "ellipse",
4657
4810
  "freehand",
4658
4811
  "highlight"
4659
- ].includes(G || "") && /* @__PURE__ */ I("div", {
4812
+ ].includes(W || "") && /* @__PURE__ */ I("div", {
4660
4813
  style: {
4661
4814
  display: "flex",
4662
4815
  alignItems: "center",
@@ -4670,16 +4823,16 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4670
4823
  color: "#666",
4671
4824
  minWidth: "85px"
4672
4825
  },
4673
- children: ["Thickness: ", /* @__PURE__ */ I("strong", { children: [kt, "px"] })]
4826
+ children: ["Thickness: ", /* @__PURE__ */ I("strong", { children: [Rt, "px"] })]
4674
4827
  }), /* @__PURE__ */ F("input", {
4675
4828
  type: "range",
4676
4829
  min: "1",
4677
4830
  max: "24",
4678
- value: Math.min(24, Math.max(1, kt)),
4831
+ value: Math.min(24, Math.max(1, Rt)),
4679
4832
  onMouseDown: (e) => e.stopPropagation(),
4680
4833
  onChange: (e) => {
4681
4834
  let t = parseInt(e.target.value, 10);
4682
- At(t), X && !Y && Q(W.map((e) => e.id === X ? {
4835
+ Bt(t), Y && !J && Q(U.map((e) => e.id === Y ? {
4683
4836
  ...e,
4684
4837
  strokeWidth: t
4685
4838
  } : e));
@@ -4706,7 +4859,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4706
4859
  ].map((e) => /* @__PURE__ */ F("button", {
4707
4860
  onMouseDown: (e) => e.preventDefault(),
4708
4861
  onClick: () => {
4709
- Ot(e), X && !Y && Q(W.map((t) => t.id === X ? {
4862
+ Mt(e), Y && !J && Q(U.map((t) => t.id === Y ? {
4710
4863
  ...t,
4711
4864
  color: e
4712
4865
  } : t));
@@ -4716,14 +4869,14 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4716
4869
  height: "18px",
4717
4870
  borderRadius: "50%",
4718
4871
  backgroundColor: e,
4719
- border: Dt === e ? "2px solid #000" : "1px solid transparent",
4872
+ border: kt === e ? "2px solid #000" : "1px solid transparent",
4720
4873
  cursor: "pointer",
4721
4874
  outline: "none",
4722
4875
  padding: 0
4723
4876
  }
4724
4877
  }, e))
4725
4878
  }),
4726
- sn > 0 && /* @__PURE__ */ I("div", {
4879
+ $ > 0 && /* @__PURE__ */ I("div", {
4727
4880
  style: {
4728
4881
  display: "flex",
4729
4882
  alignItems: "center",
@@ -4731,7 +4884,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4731
4884
  marginLeft: "8px"
4732
4885
  },
4733
4886
  children: [/* @__PURE__ */ I("button", {
4734
- onClick: () => an(!0),
4887
+ onClick: () => vn(!0),
4735
4888
  style: {
4736
4889
  display: "flex",
4737
4890
  alignItems: "center",
@@ -4750,11 +4903,11 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4750
4903
  children: [
4751
4904
  /* @__PURE__ */ F(Oe, { size: 16 }),
4752
4905
  "Apply Redactions (",
4753
- sn,
4906
+ $,
4754
4907
  ")"
4755
4908
  ]
4756
4909
  }), /* @__PURE__ */ I("button", {
4757
- onClick: cn,
4910
+ onClick: bn,
4758
4911
  style: {
4759
4912
  display: "flex",
4760
4913
  alignItems: "center",
@@ -4779,7 +4932,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4779
4932
  })
4780
4933
  ]
4781
4934
  }),
4782
- $ && /* @__PURE__ */ F("div", {
4935
+ _n && /* @__PURE__ */ F("div", {
4783
4936
  style: {
4784
4937
  position: "fixed",
4785
4938
  top: 0,
@@ -4847,7 +5000,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4847
5000
  },
4848
5001
  children: [
4849
5002
  "You are about to permanently apply ",
4850
- /* @__PURE__ */ I("strong", { children: [sn, " redaction(s)"] }),
5003
+ /* @__PURE__ */ I("strong", { children: [$, " redaction(s)"] }),
4851
5004
  ". Marked areas will be blacked out and underlying text will be permanently removed. This action cannot be undone."
4852
5005
  ]
4853
5006
  }),
@@ -4859,7 +5012,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4859
5012
  },
4860
5013
  children: [
4861
5014
  /* @__PURE__ */ F("button", {
4862
- onClick: () => an(!1),
5015
+ onClick: () => vn(!1),
4863
5016
  style: {
4864
5017
  padding: "8px 14px",
4865
5018
  borderRadius: "6px",
@@ -4874,7 +5027,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4874
5027
  }),
4875
5028
  /* @__PURE__ */ F("button", {
4876
5029
  onClick: () => {
4877
- cn(), an(!1);
5030
+ bn(), vn(!1);
4878
5031
  },
4879
5032
  style: {
4880
5033
  padding: "8px 14px",
@@ -4893,10 +5046,10 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4893
5046
  Ee((e) => e.map((e) => ({
4894
5047
  ...e,
4895
5048
  status: "applied"
4896
- }))), rn((e) => e.map((e) => ({
5049
+ }))), gn((e) => e.map((e) => ({
4897
5050
  ...e,
4898
5051
  status: "applied"
4899
- }))), an(!1);
5052
+ }))), vn(!1);
4900
5053
  },
4901
5054
  style: {
4902
5055
  padding: "8px 14px",
@@ -4927,28 +5080,28 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4927
5080
  overflow: "hidden",
4928
5081
  position: "relative"
4929
5082
  },
4930
- children: [R.isActive && R.mode === "side-by-side" ? /* @__PURE__ */ F(xt, {
5083
+ children: [R.isActive && R.mode === "side-by-side" ? /* @__PURE__ */ F(Pt, {
4931
5084
  pdfDocA: M,
4932
5085
  pdfDocB: ke,
4933
5086
  pageNum: N,
4934
5087
  scale: S,
4935
5088
  rotation: A,
4936
- basePageDims: H(N),
5089
+ basePageDims: Ye(N),
4937
5090
  activeTab: a,
4938
- activeTool: G,
4939
- annotations: W,
5091
+ activeTool: W,
5092
+ annotations: U,
4940
5093
  permissions: ve,
4941
5094
  watermark: ue,
4942
5095
  watermarkText: de,
4943
- redactions: on,
5096
+ redactions: yn,
4944
5097
  diffsA: R.pageDiffsA?.[N] || [],
4945
5098
  diffsB: R.pageDiffsB?.[N] || [],
4946
5099
  selectedDiffId: R.diffItems[R.currentDiffIndex]?.id,
4947
5100
  onSelectDiff: (e) => {
4948
5101
  let t = R.diffItems.findIndex((t) => t.id === e);
4949
- t !== -1 && yt(t);
5102
+ t !== -1 && xt(t);
4950
5103
  }
4951
- }) : /* @__PURE__ */ I(Ne, { children: [G === "highlight" && /* @__PURE__ */ F("style", { children: "\n .pdf-viewer-area, .pdf-viewer-area * {\n cursor: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImJsYWNrIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+PHBhdGggZD0iTTkgMTFsLTYgNnYzaDlsMy0zIi8+PHBhdGggZD0iTTIyIDEybC00LjYgNC42YTIgMiAwIDAgMS0yLjggMGwtNS4yLTUuMmEyIDIgMCAwIDEgMC0yLjhMMTQgNCIvPjwvc3ZnPg==') 0 24, auto !important;\n }\n " }), /* @__PURE__ */ I("div", {
5104
+ }) : /* @__PURE__ */ I(Ne, { children: [W === "highlight" && /* @__PURE__ */ F("style", { children: "\n .pdf-viewer-area, .pdf-viewer-area * {\n cursor: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImJsYWNrIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+PHBhdGggZD0iTTkgMTFsLTYgNnYzaDlsMy0zIi8+PHBhdGggZD0iTTIyIDEybC00LjYgNC42YTIgMiAwIDAgMS0yLjggMGwtNS4yLTUuMmEyIDIgMCAwIDEgMC0yLjhMMTQgNCIvPjwvc3ZnPg==') 0 24, auto !important;\n }\n " }), /* @__PURE__ */ I("div", {
4952
5105
  className: "pdf-viewer-area",
4953
5106
  style: {
4954
5107
  flex: 1,
@@ -4959,28 +5112,28 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4959
5112
  overflow: "hidden",
4960
5113
  position: "relative",
4961
5114
  backgroundColor: "var(--bg-color)",
4962
- cursor: Qe ? "grabbing" : G === "pan" || G === null ? "grab" : G === "eraser" ? "cell" : "crosshair"
5115
+ cursor: $e ? "grabbing" : W === "pan" || W === null ? "grab" : W === "eraser" ? "cell" : "crosshair"
4963
5116
  },
4964
5117
  onMouseMove: (e) => {
4965
- if (Qe && rt.current && j.current) {
4966
- let t = e.clientX - rt.current.x, n = e.clientY - rt.current.y;
4967
- j.current.scrollLeft = rt.current.scrollLeft - t, j.current.scrollTop = rt.current.scrollTop - n;
5118
+ if ($e && it.current && j.current) {
5119
+ let t = e.clientX - it.current.x, n = e.clientY - it.current.y;
5120
+ j.current.scrollLeft = it.current.scrollLeft - t, j.current.scrollTop = it.current.scrollTop - n;
4968
5121
  }
4969
5122
  },
4970
5123
  onMouseLeave: () => {
4971
- Qe && (et(!1), rt.current = null);
5124
+ $e && (tt(!1), it.current = null);
4972
5125
  },
4973
5126
  children: [
4974
5127
  /* @__PURE__ */ F("div", {
4975
5128
  ref: j,
4976
5129
  onScroll: (e) => {
4977
- Xe({
5130
+ Ze({
4978
5131
  top: e.currentTarget.scrollTop,
4979
5132
  left: e.currentTarget.scrollLeft
4980
- }), Dn.current = U(e.currentTarget.scrollTop);
5133
+ }), mt.current = gt(e.currentTarget.scrollTop);
4981
5134
  },
4982
5135
  onMouseDown: (e) => {
4983
- (G === "pan" || G === null) && e.button === 0 && (et(!0), rt.current = {
5136
+ (W === "pan" || W === null) && e.button === 0 && (tt(!0), it.current = {
4984
5137
  x: e.clientX,
4985
5138
  y: e.clientY,
4986
5139
  scrollLeft: e.currentTarget.scrollLeft,
@@ -4988,7 +5141,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
4988
5141
  });
4989
5142
  },
4990
5143
  onMouseUp: (e) => {
4991
- Qe && (et(!1), rt.current = null);
5144
+ $e && (tt(!1), it.current = null);
4992
5145
  },
4993
5146
  onContextMenu: (e) => {
4994
5147
  e.preventDefault(), e.stopPropagation();
@@ -5002,42 +5155,45 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
5002
5155
  children: (() => {
5003
5156
  let t = (t, n, r) => {
5004
5157
  let i = r ? ct.tops[n] ?? 0 : 0;
5005
- if (r && j.current && (n < Dn.current - 5 || n > Dn.current + 8)) return null;
5006
- let o = Pt && It && G && G !== "eraser" ? (() => {
5007
- if (G === "freehand") return {
5158
+ if (r && j.current) {
5159
+ let e = S >= 4 ? 1 : S >= 2 ? 2 : 4, t = S >= 4 ? 1 : S >= 2 ? 2 : 5;
5160
+ if (n < mt.current - e || n > mt.current + t) return null;
5161
+ }
5162
+ let o = Wt && Kt && W && W !== "eraser" ? (() => {
5163
+ if (W === "freehand") return {
5008
5164
  id: "temp-live-drawing",
5009
5165
  type: "freehand",
5010
- pageIndex: It,
5166
+ pageIndex: Kt,
5011
5167
  x: 0,
5012
5168
  y: 0,
5013
5169
  width: 0,
5014
5170
  height: 0,
5015
- points: Bt,
5016
- color: Dt,
5017
- strokeWidth: kt,
5018
- opacity: Mt
5171
+ points: Zt,
5172
+ color: kt,
5173
+ strokeWidth: Rt,
5174
+ opacity: Vt
5019
5175
  };
5020
- if (G === "highlight") {
5021
- let e = Math.abs(J.x - q.x), t = Math.abs(J.y - q.y), n = Math.min(q.x, J.x), r = Math.min(q.y, J.y);
5022
- return t < 18 && (t = Math.max(18, t), r = q.y - 9), {
5176
+ if (W === "highlight") {
5177
+ let e = Math.abs(q.x - K.x), t = Math.abs(q.y - K.y), n = Math.min(K.x, q.x), r = Math.min(K.y, q.y);
5178
+ return t < 18 && (t = Math.max(18, t), r = K.y - 9), {
5023
5179
  id: "temp-live-drawing",
5024
5180
  type: "highlight",
5025
- pageIndex: It,
5181
+ pageIndex: Kt,
5026
5182
  x: n,
5027
5183
  y: r,
5028
5184
  width: e,
5029
5185
  height: t,
5030
- color: Dt,
5031
- strokeWidth: kt,
5032
- opacity: Mt
5186
+ color: kt,
5187
+ strokeWidth: Rt,
5188
+ opacity: Vt
5033
5189
  };
5034
5190
  }
5035
- if (G === "redaction") {
5036
- let e = Math.abs(J.x - q.x), t = Math.abs(J.y - q.y), n = Math.min(q.x, J.x), r = Math.min(q.y, J.y);
5037
- return t < 18 && (t = Math.max(18, t), r = q.y - 9), {
5191
+ if (W === "redaction") {
5192
+ let e = Math.abs(q.x - K.x), t = Math.abs(q.y - K.y), n = Math.min(K.x, q.x), r = Math.min(K.y, q.y);
5193
+ return t < 18 && (t = Math.max(18, t), r = K.y - 9), {
5038
5194
  id: "temp-live-drawing",
5039
5195
  type: "rectangle",
5040
- pageIndex: It,
5196
+ pageIndex: Kt,
5041
5197
  x: n,
5042
5198
  y: r,
5043
5199
  width: e,
@@ -5054,64 +5210,64 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
5054
5210
  "rectangle",
5055
5211
  "ellipse",
5056
5212
  "link"
5057
- ].includes(G)) {
5058
- let e = Math.abs(J.x - q.x), t = Math.abs(J.y - q.y), n = Math.min(q.x, J.x), r = Math.min(q.y, J.y);
5213
+ ].includes(W)) {
5214
+ let e = Math.abs(q.x - K.x), t = Math.abs(q.y - K.y), n = Math.min(K.x, q.x), r = Math.min(K.y, q.y);
5059
5215
  return {
5060
5216
  id: "temp-live-drawing",
5061
- type: G,
5062
- pageIndex: It,
5217
+ type: W,
5218
+ pageIndex: Kt,
5063
5219
  x: n,
5064
5220
  y: r,
5065
5221
  width: e,
5066
5222
  height: t,
5067
- points: G === "line" || G === "arrow" || G === "callout" ? [q, J] : void 0,
5068
- color: Dt,
5069
- strokeWidth: kt,
5070
- opacity: Mt
5223
+ points: W === "line" || W === "arrow" || W === "callout" ? [K, q] : void 0,
5224
+ color: kt,
5225
+ strokeWidth: Rt,
5226
+ opacity: Vt
5071
5227
  };
5072
5228
  }
5073
5229
  })() : null;
5074
5230
  return t.map((n, r) => {
5075
- let s, c = j.current?.clientWidth || 0, l = H(n), u = H(t[0]).width * S, d = l.width * S;
5231
+ let s, c = j.current?.clientWidth || 0, l = Ye(n), u = Ye(t[0]).width * S, d = l.width * S;
5076
5232
  t.length === 2 ? (r === 0 && (s = Math.max(0, c / 2 - u)), r === 1 && (s = Math.max(u, c / 2))) : s = Math.max(0, c / 2 - d / 2);
5077
- let f = o && o.pageIndex === n ? [...W, o] : W;
5233
+ let f = o && o.pageIndex === n ? [...U, o] : U;
5078
5234
  return /* @__PURE__ */ I(e.Fragment, { children: [
5079
- /* @__PURE__ */ F(dt, {
5235
+ /* @__PURE__ */ F(St, {
5080
5236
  pageNum: n,
5081
5237
  pdfDoc: M,
5082
5238
  scale: S,
5083
5239
  rotation: A,
5084
5240
  containerWidth: j.current?.clientWidth || 0,
5085
5241
  containerHeight: j.current?.clientHeight || 0,
5086
- scrollTop: Ye.top,
5087
- scrollLeft: Ye.left,
5242
+ scrollTop: Xe.top,
5243
+ scrollLeft: Xe.left,
5088
5244
  pageTop: i,
5089
5245
  pageLeft: s,
5090
5246
  basePageWidth: l.width,
5091
5247
  basePageHeight: l.height,
5092
5248
  activeTab: a,
5093
- activeTool: G,
5249
+ activeTool: W,
5094
5250
  annotations: f,
5095
5251
  transientHighlights: _e?.filter((e) => e.pageIndex === n) || [],
5096
- selectedAnnotationId: X,
5252
+ selectedAnnotationId: Y,
5097
5253
  activeSearchResult: Ue,
5098
- onMouseDown: xn,
5099
- onMouseMove: Cn,
5100
- onMouseUp: wn,
5101
- onAnnotationClick: En,
5102
- onAnnotationMouseEnter: Tn,
5254
+ onMouseDown: Nn,
5255
+ onMouseMove: Fn,
5256
+ onMouseUp: In,
5257
+ onAnnotationClick: Rn,
5258
+ onAnnotationMouseEnter: Ln,
5103
5259
  onClearSelection: () => {
5104
- if (Xt.current || Jt) {
5105
- Xt.current = !1;
5260
+ if (Z.current || on) {
5261
+ Z.current = !1;
5106
5262
  return;
5107
5263
  }
5108
- Z(null), qt(null);
5264
+ X(null), an(null);
5109
5265
  },
5110
5266
  watermark: ue,
5111
5267
  watermarkText: de,
5112
- redactions: on,
5113
- onDiscardRedaction: ln,
5114
- onRendered: hn
5268
+ redactions: yn,
5269
+ onDiscardRedaction: xn,
5270
+ onRendered: Dn
5115
5271
  }),
5116
5272
  R.isActive && R.mode === "overlay" && ke && /* @__PURE__ */ F("div", {
5117
5273
  style: {
@@ -5126,15 +5282,15 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
5126
5282
  zIndex: 12,
5127
5283
  filter: "contrast(1.2) brightness(0.95)"
5128
5284
  },
5129
- children: /* @__PURE__ */ F(dt, {
5285
+ children: /* @__PURE__ */ F(St, {
5130
5286
  pageNum: n,
5131
5287
  pdfDoc: ke,
5132
5288
  scale: S,
5133
5289
  rotation: A,
5134
5290
  containerWidth: j.current?.clientWidth || 0,
5135
5291
  containerHeight: j.current?.clientHeight || 0,
5136
- scrollTop: Ye.top,
5137
- scrollLeft: Ye.left,
5292
+ scrollTop: Xe.top,
5293
+ scrollLeft: Xe.left,
5138
5294
  pageTop: 0,
5139
5295
  pageLeft: 0,
5140
5296
  basePageWidth: l.width,
@@ -5162,18 +5318,18 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
5162
5318
  pointerEvents: "none",
5163
5319
  zIndex: 16
5164
5320
  },
5165
- children: /* @__PURE__ */ F(bt, {
5321
+ children: /* @__PURE__ */ F(Nt, {
5166
5322
  boxes: [...R.pageDiffsA?.[n] || [], ...R.pageDiffsB?.[n] || []],
5167
5323
  scale: S,
5168
5324
  selectedDiffId: R.diffItems[R.currentDiffIndex]?.id,
5169
5325
  onSelectDiff: (e) => {
5170
5326
  let t = R.diffItems.findIndex((t) => t.id === e);
5171
- t !== -1 && yt(t);
5327
+ t !== -1 && xt(t);
5172
5328
  }
5173
5329
  })
5174
5330
  }),
5175
- Y && Y.pageIndex === n && (() => {
5176
- let e = A % 180 == 0 ? l.width : l.height, t = A % 180 == 0 ? l.height : l.width, n = ot(Y.x, Y.y, A, e, t);
5331
+ J && J.pageIndex === n && (() => {
5332
+ let e = A % 180 == 0 ? l.width : l.height, t = A % 180 == 0 ? l.height : l.width, n = st(J.x, J.y, A, e, t);
5177
5333
  return /* @__PURE__ */ I("div", {
5178
5334
  style: {
5179
5335
  position: "absolute",
@@ -5187,19 +5343,19 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
5187
5343
  flexDirection: "column"
5188
5344
  },
5189
5345
  children: [/* @__PURE__ */ F("textarea", {
5190
- ref: Gt,
5191
- value: Ut,
5192
- onChange: (e) => Wt(e.target.value),
5346
+ ref: nn,
5347
+ value: en,
5348
+ onChange: (e) => tn(e.target.value),
5193
5349
  onBlur: (e) => {
5194
- e.currentTarget.parentElement?.contains(e.relatedTarget) || Sn();
5350
+ e.currentTarget.parentElement?.contains(e.relatedTarget) || Pn();
5195
5351
  },
5196
5352
  onKeyDown: (e) => {
5197
- e.key === "Enter" && !e.shiftKey && (e.preventDefault(), Sn());
5353
+ e.key === "Enter" && !e.shiftKey && (e.preventDefault(), Pn());
5198
5354
  },
5199
5355
  style: {
5200
5356
  backgroundColor: "transparent",
5201
5357
  border: "none",
5202
- color: Dt,
5358
+ color: kt,
5203
5359
  fontSize: "16px",
5204
5360
  fontFamily: "sans-serif",
5205
5361
  minWidth: "150px",
@@ -5208,7 +5364,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
5208
5364
  resize: "both",
5209
5365
  padding: "8px"
5210
5366
  },
5211
- placeholder: Y.type === "note" ? "Note text..." : "Type text...",
5367
+ placeholder: J.type === "note" ? "Note text..." : "Type text...",
5212
5368
  autoFocus: !0
5213
5369
  }), /* @__PURE__ */ F("div", {
5214
5370
  style: {
@@ -5219,7 +5375,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
5219
5375
  },
5220
5376
  children: /* @__PURE__ */ F("button", {
5221
5377
  onMouseDown: (e) => {
5222
- e.preventDefault(), Sn();
5378
+ e.preventDefault(), Pn();
5223
5379
  },
5224
5380
  style: {
5225
5381
  padding: "4px 12px",
@@ -5244,10 +5400,10 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
5244
5400
  width: "100%",
5245
5401
  height: `${ct.total}px`
5246
5402
  },
5247
- children: st.map((e, n) => t(e, n, !0))
5403
+ children: H.map((e, n) => t(e, n, !0))
5248
5404
  });
5249
5405
  {
5250
- let e = Math.max(0, st.findIndex((e) => e.includes(N))), n = st[e] || [];
5406
+ let e = Math.max(0, H.findIndex((e) => e.includes(N))), n = H[e] || [];
5251
5407
  return /* @__PURE__ */ F("div", {
5252
5408
  style: {
5253
5409
  position: "relative",
@@ -5366,7 +5522,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
5366
5522
  },
5367
5523
  children: [
5368
5524
  /* @__PURE__ */ F("button", {
5369
- onClick: () => ht(Math.max(1, N - 1)),
5525
+ onClick: () => _t(Math.max(1, N - 1)),
5370
5526
  disabled: N <= 1,
5371
5527
  style: {
5372
5528
  background: "none",
@@ -5393,7 +5549,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
5393
5549
  ]
5394
5550
  }),
5395
5551
  /* @__PURE__ */ F("button", {
5396
- onClick: () => ht(Math.min(M.numPages, N + 1)),
5552
+ onClick: () => _t(Math.min(M.numPages, N + 1)),
5397
5553
  disabled: N >= M.numPages,
5398
5554
  style: {
5399
5555
  background: "none",
@@ -5407,15 +5563,15 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
5407
5563
  })
5408
5564
  ]
5409
5565
  }),
5410
- X && Kt && /* @__PURE__ */ F(He, {
5411
- annotation: W.find((e) => e.id === X),
5412
- position: Kt,
5566
+ Y && rn && /* @__PURE__ */ F(He, {
5567
+ annotation: U.find((e) => e.id === Y),
5568
+ position: rn,
5413
5569
  onCopy: () => {
5414
- let e = W.find((e) => e.id === X);
5570
+ let e = U.find((e) => e.id === Y);
5415
5571
  if (e) {
5416
5572
  let t = {
5417
5573
  ...e,
5418
- id: ft(),
5574
+ id: Ct(),
5419
5575
  author: void 0,
5420
5576
  authorId: void 0,
5421
5577
  createdAt: void 0,
@@ -5425,25 +5581,25 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
5425
5581
  x: e.x + 20,
5426
5582
  y: e.y + 20
5427
5583
  };
5428
- Q([...W, t]);
5584
+ Q([...U, t]);
5429
5585
  }
5430
- Z(null), qt(null);
5586
+ X(null), an(null);
5431
5587
  },
5432
5588
  onDelete: () => {
5433
- Q(W.filter((e) => e.id !== X)), Z(null), qt(null);
5589
+ Q(U.filter((e) => e.id !== Y)), X(null), an(null);
5434
5590
  },
5435
5591
  onUpdateColor: (e) => {
5436
- Q(W.map((t) => t.id === X ? {
5592
+ Q(U.map((t) => t.id === Y ? {
5437
5593
  ...t,
5438
5594
  color: e
5439
5595
  } : t));
5440
5596
  },
5441
5597
  onOpenLinkModal: () => {
5442
- Yt(!0), qt(null);
5598
+ sn(!0), an(null);
5443
5599
  },
5444
5600
  permissions: ve
5445
5601
  }),
5446
- R.isActive && R.showCurtain && /* @__PURE__ */ F(wt, {
5602
+ R.isActive && R.showCurtain && /* @__PURE__ */ F(Lt, {
5447
5603
  positionPercent: R.curtainPosition,
5448
5604
  onChangePosition: (e) => z((t) => ({
5449
5605
  ...t,
@@ -5452,29 +5608,29 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
5452
5608
  containerRef: j
5453
5609
  })
5454
5610
  ]
5455
- })] }), R.isActive && /* @__PURE__ */ F(Ct, {
5611
+ })] }), R.isActive && /* @__PURE__ */ F(It, {
5456
5612
  isOpen: B,
5457
5613
  onClose: () => Ie(!1),
5458
5614
  diffItems: R.diffItems,
5459
5615
  textDiffs: Pe,
5460
5616
  currentDiffIndex: R.currentDiffIndex,
5461
- onSelectDiff: (e, t) => yt(e, t),
5462
- onJumpToPage: (e) => ht(e)
5617
+ onSelectDiff: (e, t) => xt(e, t),
5618
+ onJumpToPage: (e) => _t(e)
5463
5619
  })]
5464
5620
  })
5465
5621
  ]
5466
5622
  }),
5467
- Jt && X && /* @__PURE__ */ F(We, {
5468
- initialUrl: W.find((e) => e.id === X)?.linkUrl || "",
5469
- initialText: W.find((e) => e.id === X)?.text || "",
5470
- showTextInput: !W.find((e) => e.id === X)?.width || W.find((e) => e.id === X)?.text === "" || W.find((e) => e.id === X)?.text !== void 0,
5623
+ on && Y && /* @__PURE__ */ F(We, {
5624
+ initialUrl: U.find((e) => e.id === Y)?.linkUrl || "",
5625
+ initialText: U.find((e) => e.id === Y)?.text || "",
5626
+ showTextInput: !U.find((e) => e.id === Y)?.width || U.find((e) => e.id === Y)?.text === "" || U.find((e) => e.id === Y)?.text !== void 0,
5471
5627
  onClose: () => {
5472
- let e = W.find((e) => e.id === X);
5473
- e && !e.linkUrl && Q(W.filter((e) => e.id !== X)), Yt(!1), Z(null);
5628
+ let e = U.find((e) => e.id === Y);
5629
+ e && !e.linkUrl && Q(U.filter((e) => e.id !== Y)), sn(!1), X(null);
5474
5630
  },
5475
5631
  onSave: (e, t) => {
5476
- Q(W.map((n) => {
5477
- if (n.id === X) {
5632
+ Q(U.map((n) => {
5633
+ if (n.id === Y) {
5478
5634
  let r = t === void 0 ? n.text : t, i = r ? Math.max(100, r.length * 8 + 20) : n.width;
5479
5635
  return {
5480
5636
  ...n,
@@ -5484,27 +5640,27 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
5484
5640
  };
5485
5641
  }
5486
5642
  return n;
5487
- })), Yt(!1), Z(null);
5643
+ })), sn(!1), X(null);
5488
5644
  }
5489
5645
  }),
5490
- _ && /* @__PURE__ */ F(nt, {
5646
+ _ && /* @__PURE__ */ F(rt, {
5491
5647
  isOpen: r,
5492
5648
  activeTab: te,
5493
5649
  setActiveTab: ne,
5494
- annotations: W,
5650
+ annotations: U,
5495
5651
  setAnnotations: Q,
5496
- selectedAnnotationId: X,
5497
- setSelectedAnnotationId: Z,
5498
- onSearch: un,
5499
- searchResults: dn,
5500
- isSearching: fn,
5501
- searchProgress: pn,
5502
- onResultClick: gt
5652
+ selectedAnnotationId: Y,
5653
+ setSelectedAnnotationId: X,
5654
+ onSearch: Sn,
5655
+ searchResults: Cn,
5656
+ isSearching: wn,
5657
+ searchProgress: Tn,
5658
+ onResultClick: yt
5503
5659
  })
5504
5660
  ]
5505
5661
  });
5506
5662
  }
5507
- function jt({ icon: e, active: t, onClick: n, label: r }) {
5663
+ function qt({ icon: e, active: t, onClick: n, label: r }) {
5508
5664
  return /* @__PURE__ */ F("button", {
5509
5665
  onClick: n,
5510
5666
  title: r,
@@ -5531,8 +5687,8 @@ function jt({ icon: e, active: t, onClick: n, label: r }) {
5531
5687
  }
5532
5688
  //#endregion
5533
5689
  //#region src/components/SettingsModal.tsx
5534
- function Mt({ onClose: e, watermarkText: t, setWatermarkText: n }) {
5535
- let { shortcuts: r, updateShortcut: i, resetShortcuts: a } = Ze(), [s, l] = c("Keyboard Shortcuts"), [u, d] = c(null), [f, p] = c(""), m = (e, t) => {
5690
+ function Jt({ onClose: e, watermarkText: t, setWatermarkText: n }) {
5691
+ let { shortcuts: r, updateShortcut: i, resetShortcuts: a } = Qe(), [s, l] = c("Keyboard Shortcuts"), [u, d] = c(null), [f, p] = c(""), m = (e, t) => {
5536
5692
  if (e.preventDefault(), e.stopPropagation(), e.key === "Escape") {
5537
5693
  d(null);
5538
5694
  return;
@@ -5558,7 +5714,7 @@ function Mt({ onClose: e, watermarkText: t, setWatermarkText: n }) {
5558
5714
  },
5559
5715
  children: "None"
5560
5716
  });
5561
- let t = Qe(e), n = typeof navigator < "u" && /mac/i.test(navigator.platform || navigator.userAgent || ""), r = [];
5717
+ let t = $e(e), n = typeof navigator < "u" && /mac/i.test(navigator.platform || navigator.userAgent || ""), r = [];
5562
5718
  if (t.meta && r.push(n ? "⌘" : "Ctrl"), t.alt && r.push(n ? "⌥" : "Alt"), t.shift && r.push(n ? "⇧" : "Shift"), t.key) {
5563
5719
  let e = t.key.toUpperCase();
5564
5720
  e === "DELETE" && (e = n ? "⌫ Delete" : "Del"), r.push(e);
@@ -6060,7 +6216,7 @@ function Mt({ onClose: e, watermarkText: t, setWatermarkText: n }) {
6060
6216
  }
6061
6217
  //#endregion
6062
6218
  //#region src/components/AboutModal.tsx
6063
- function Nt({ onClose: e }) {
6219
+ function K({ onClose: e }) {
6064
6220
  return /* @__PURE__ */ F("div", {
6065
6221
  style: {
6066
6222
  position: "fixed",
@@ -6281,7 +6437,7 @@ function Nt({ onClose: e }) {
6281
6437
  }
6282
6438
  //#endregion
6283
6439
  //#region src/core/eventBus.ts
6284
- var Pt = class {
6440
+ var Yt = class {
6285
6441
  listeners = /* @__PURE__ */ new Map();
6286
6442
  destroyed = !1;
6287
6443
  on(e, t) {
@@ -6323,21 +6479,21 @@ var Pt = class {
6323
6479
  get isDestroyed() {
6324
6480
  return this.destroyed;
6325
6481
  }
6326
- }, Ft = (e) => e === 0 ? 0 : e;
6327
- function It(e, t) {
6482
+ }, q = (e) => e === 0 ? 0 : e;
6483
+ function Xt(e, t) {
6328
6484
  return {
6329
- x: Ft(e.x * t[0] + e.y * t[2] + t[4]),
6330
- y: Ft(e.x * t[1] + e.y * t[3] + t[5])
6485
+ x: q(e.x * t[0] + e.y * t[2] + t[4]),
6486
+ y: q(e.x * t[1] + e.y * t[3] + t[5])
6331
6487
  };
6332
6488
  }
6333
- function Lt(e, t) {
6489
+ function Zt(e, t) {
6334
6490
  let n = t[0] * t[3] - t[1] * t[2];
6335
6491
  return {
6336
- x: Ft((e.x * t[3] - e.y * t[2] + t[2] * t[5] - t[4] * t[3]) / n),
6337
- y: Ft((-e.x * t[1] + e.y * t[0] + t[4] * t[1] - t[5] * t[0]) / n)
6492
+ x: q((e.x * t[3] - e.y * t[2] + t[2] * t[5] - t[4] * t[3]) / n),
6493
+ y: q((-e.x * t[1] + e.y * t[0] + t[4] * t[1] - t[5] * t[0]) / n)
6338
6494
  };
6339
6495
  }
6340
- function q(e, t, n) {
6496
+ function Qt(e, t, n) {
6341
6497
  let r = lt(n), [i, a, o, s] = t, c = (o + i) / 2, l = (s + a) / 2, u, d, f, p;
6342
6498
  switch (r) {
6343
6499
  case 180:
@@ -6375,33 +6531,33 @@ function q(e, t, n) {
6375
6531
  transform: v
6376
6532
  };
6377
6533
  }
6378
- function Rt(e) {
6534
+ function J(e) {
6379
6535
  let t = e.view;
6380
- return q(e.pageNumber, [
6536
+ return Qt(e.pageNumber, [
6381
6537
  t[0],
6382
6538
  t[1],
6383
6539
  t[2],
6384
6540
  t[3]
6385
6541
  ], e.rotate);
6386
6542
  }
6387
- function J(e) {
6543
+ function $t(e) {
6388
6544
  let t = /* @__PURE__ */ new Map();
6389
6545
  return (n) => {
6390
6546
  let r = Math.max(1, Math.min(e.numPages, n)), i = t.get(r);
6391
- return i || (i = e.getPage(r).then(Rt), t.set(r, i)), i;
6547
+ return i || (i = e.getPage(r).then(J), t.set(r, i)), i;
6392
6548
  };
6393
6549
  }
6394
- function zt(e, t) {
6395
- return Lt(t, e.transform);
6550
+ function en(e, t) {
6551
+ return Zt(t, e.transform);
6396
6552
  }
6397
- function Bt(e, t) {
6398
- return It(t, e.transform);
6553
+ function tn(e, t) {
6554
+ return Xt(t, e.transform);
6399
6555
  }
6400
- function Vt(e, t) {
6401
- let n = zt(e, {
6556
+ function nn(e, t) {
6557
+ let n = en(e, {
6402
6558
  x: t.x,
6403
6559
  y: t.y
6404
- }), r = zt(e, {
6560
+ }), r = en(e, {
6405
6561
  x: t.x + t.width,
6406
6562
  y: t.y + t.height
6407
6563
  });
@@ -6413,10 +6569,10 @@ function Vt(e, t) {
6413
6569
  ];
6414
6570
  }
6415
6571
  function Y(e, t) {
6416
- let n = Bt(e, {
6572
+ let n = tn(e, {
6417
6573
  x: t[0],
6418
6574
  y: t[1]
6419
- }), r = Bt(e, {
6575
+ }), r = tn(e, {
6420
6576
  x: t[2],
6421
6577
  y: t[3]
6422
6578
  });
@@ -6427,14 +6583,14 @@ function Y(e, t) {
6427
6583
  height: Math.abs(r.y - n.y)
6428
6584
  };
6429
6585
  }
6430
- function Ht(e, t) {
6431
- return t.map((t) => zt(e, t));
6586
+ function X(e, t) {
6587
+ return t.map((t) => en(e, t));
6432
6588
  }
6433
- function Ut(e, t) {
6434
- return t.map((t) => Bt(e, t));
6589
+ function rn(e, t) {
6590
+ return t.map((t) => tn(e, t));
6435
6591
  }
6436
- function Wt(e, t) {
6437
- let [n, r, i, a] = Vt(e, t);
6592
+ function an(e, t) {
6593
+ let [n, r, i, a] = nn(e, t);
6438
6594
  return [
6439
6595
  n,
6440
6596
  a,
@@ -6446,7 +6602,7 @@ function Wt(e, t) {
6446
6602
  r
6447
6603
  ];
6448
6604
  }
6449
- function Gt(e, t) {
6605
+ function on(e, t) {
6450
6606
  let n = [];
6451
6607
  for (let r = 0; r + 7 < t.length; r += 8) {
6452
6608
  let i = [
@@ -6469,7 +6625,7 @@ function Gt(e, t) {
6469
6625
  }
6470
6626
  return n;
6471
6627
  }
6472
- function X(e) {
6628
+ function sn(e) {
6473
6629
  if (e.length === 0) return {
6474
6630
  x: 0,
6475
6631
  y: 0,
@@ -6484,17 +6640,17 @@ function X(e) {
6484
6640
  height: i - n
6485
6641
  };
6486
6642
  }
6487
- var Z = (e) => (Math.round(e * 1e3) / 1e3).toString(), Kt = 524288e3, qt = (e) => {
6643
+ var Z = (e) => (Math.round(e * 1e3) / 1e3).toString(), cn = 524288e3, ln = (e) => {
6488
6644
  let t = e && /^#[0-9a-f]{6}$/i.test(e) ? e : "#000000", n = parseInt(t.slice(1, 3), 16) / 255, r = parseInt(t.slice(3, 5), 16) / 255, i = parseInt(t.slice(5, 7), 16) / 255;
6489
6645
  return B(n, r, i);
6490
6646
  };
6491
- async function Jt(e, t, n, r, i) {
6492
- let a = qt(r.color), o = r.opacity ?? 1, s = r.strokeWidth || 1, [c, l, u, d] = Vt(n, {
6647
+ async function un(e, t, n, r, i) {
6648
+ let a = ln(r.color), o = r.opacity ?? 1, s = r.strokeWidth || 1, [c, l, u, d] = nn(n, {
6493
6649
  x: r.x,
6494
6650
  y: r.y,
6495
6651
  width: r.width,
6496
6652
  height: r.height
6497
- }), f = u - c, p = d - l, m = Fe(n.rotate), h = (e, t, r) => zt(n, {
6653
+ }), f = u - c, p = d - l, m = Fe(n.rotate), h = (e, t, r) => en(n, {
6498
6654
  x: e,
6499
6655
  y: t + r
6500
6656
  });
@@ -6533,7 +6689,7 @@ async function Jt(e, t, n, r, i) {
6533
6689
  height: r.height
6534
6690
  }];
6535
6691
  for (let r of e) {
6536
- let [e, i, s, c] = Vt(n, r);
6692
+ let [e, i, s, c] = nn(n, r);
6537
6693
  t.drawRectangle({
6538
6694
  x: e,
6539
6695
  y: i,
@@ -6554,7 +6710,7 @@ async function Jt(e, t, n, r, i) {
6554
6710
  }, {
6555
6711
  x: r.x + r.width,
6556
6712
  y: r.y + r.height
6557
- }], [i, c] = Ht(n, [e[0], e[1]]);
6713
+ }], [i, c] = X(n, [e[0], e[1]]);
6558
6714
  if (t.drawLine({
6559
6715
  start: i,
6560
6716
  end: c,
@@ -6562,7 +6718,7 @@ async function Jt(e, t, n, r, i) {
6562
6718
  opacity: o,
6563
6719
  thickness: s
6564
6720
  }), r.type === "arrow") {
6565
- let r = e[0], i = e[1], l = Math.atan2(i.y - r.y, i.x - r.x), u = 15 + s, [d, f] = Ht(n, [{
6721
+ let r = e[0], i = e[1], l = Math.atan2(i.y - r.y, i.x - r.x), u = 15 + s, [d, f] = X(n, [{
6566
6722
  x: i.x - u * Math.cos(l - Math.PI / 6),
6567
6723
  y: i.y - u * Math.sin(l - Math.PI / 6)
6568
6724
  }, {
@@ -6588,7 +6744,7 @@ async function Jt(e, t, n, r, i) {
6588
6744
  case "freehand": {
6589
6745
  let e = r.strokes && r.strokes.length > 0 ? r.strokes : r.points ? [r.points] : [];
6590
6746
  for (let r of e) {
6591
- let e = Ht(n, r);
6747
+ let e = X(n, r);
6592
6748
  for (let n = 1; n < e.length; n++) t.drawLine({
6593
6749
  start: e[n - 1],
6594
6750
  end: e[n],
@@ -6614,7 +6770,7 @@ async function Jt(e, t, n, r, i) {
6614
6770
  return;
6615
6771
  }
6616
6772
  case "note": {
6617
- let [e, i, c, l] = Vt(n, {
6773
+ let [e, i, c, l] = nn(n, {
6618
6774
  x: r.x,
6619
6775
  y: r.y,
6620
6776
  width: 24,
@@ -6648,7 +6804,7 @@ async function Jt(e, t, n, r, i) {
6648
6804
  }, {
6649
6805
  x: r.x,
6650
6806
  y: r.y
6651
- }], [i, c] = Ht(n, [e[0], e[1]]);
6807
+ }], [i, c] = X(n, [e[0], e[1]]);
6652
6808
  if (t.drawLine({
6653
6809
  start: i,
6654
6810
  end: c,
@@ -6656,7 +6812,7 @@ async function Jt(e, t, n, r, i) {
6656
6812
  opacity: o,
6657
6813
  thickness: s
6658
6814
  }), r.text) {
6659
- let i = r.text.length * 8 + 20, [c, l, u, d] = Vt(n, {
6815
+ let i = r.text.length * 8 + 20, [c, l, u, d] = nn(n, {
6660
6816
  x: e[1].x,
6661
6817
  y: e[1].y,
6662
6818
  width: i,
@@ -6749,8 +6905,8 @@ async function Jt(e, t, n, r, i) {
6749
6905
  default: return;
6750
6906
  }
6751
6907
  }
6752
- async function Yt(e, t) {
6753
- let n = qt(t.color || "#737373"), r = t.opacity ?? .08, i = await e.embedFont(Pe.Helvetica), a = -Math.PI / 4, o = Math.cos(a), s = Math.sin(a);
6908
+ async function dn(e, t) {
6909
+ let n = ln(t.color || "#737373"), r = t.opacity ?? .08, i = await e.embedFont(Pe.Helvetica), a = -Math.PI / 4, o = Math.cos(a), s = Math.sin(a);
6754
6910
  for (let a of e.getPages()) {
6755
6911
  let { width: e, height: c } = a.getSize();
6756
6912
  if (t.mode === "single") {
@@ -6781,10 +6937,10 @@ async function Yt(e, t) {
6781
6937
  }
6782
6938
  }
6783
6939
  }
6784
- async function Xt(e, t) {
6940
+ async function fn(e, t) {
6785
6941
  let n = await e.save(), r = L.getDocument({
6786
6942
  data: n,
6787
- ...vt()
6943
+ ...jt()
6788
6944
  }), i = await r.promise, a = await z.create();
6789
6945
  try {
6790
6946
  for (let n = 1; n <= i.numPages; n++) {
@@ -6821,7 +6977,7 @@ async function Xt(e, t) {
6821
6977
  }
6822
6978
  return a;
6823
6979
  }
6824
- async function Zt(e, t = {}) {
6980
+ async function Q(e, t = {}) {
6825
6981
  t.xfdfString && console.warn("[teamsync-pdf-viewer] getFileData({ xfdfString }) is ignored; import the XFDF through annotationManager.importAnnotations() first.");
6826
6982
  let n = await e.getSourceBytes(), r = n instanceof Uint8Array ? n : new Uint8Array(n);
6827
6983
  if (r.byteLength > 524288e3) {
@@ -6831,33 +6987,33 @@ async function Zt(e, t = {}) {
6831
6987
  let i = await z.load(r, { ignoreEncryption: !0 }), a = i.getPages(), o = t.explicitAnnotations || e.annotations, s = e.getPageGeometry, c = null;
6832
6988
  !s && o.length > 0 && (c = L.getDocument({
6833
6989
  data: r.slice(),
6834
- ...vt()
6835
- }), s = J(await c.promise));
6990
+ ...jt()
6991
+ }), s = $t(await c.promise));
6836
6992
  try {
6837
6993
  for (let t of o) {
6838
6994
  let n = Math.max(0, Math.min((t.pageIndex || 1) - 1, a.length - 1)), r = await s(n + 1);
6839
- await Jt(i, a[n], r, t, e.signerName);
6995
+ await un(i, a[n], r, t, e.signerName);
6840
6996
  }
6841
6997
  } finally {
6842
6998
  c && await c.destroy().catch(() => {});
6843
6999
  }
6844
- e.watermark?.text && await Yt(i, e.watermark);
7000
+ e.watermark?.text && await dn(i, e.watermark);
6845
7001
  let l = e.redactions || [];
6846
- return await (l.length > 0 ? await Xt(i, l) : i).save();
7002
+ return await (l.length > 0 ? await fn(i, l) : i).save();
6847
7003
  }
6848
7004
  //#endregion
6849
7005
  //#region src/annotations/xfdf.ts
6850
- var Qt = "http://ns.adobe.com/xfdf/", $t = "tspdf", Q = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
6851
- function en(e, t = 2) {
7006
+ var pn = "http://ns.adobe.com/xfdf/", mn = "tspdf", hn = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
7007
+ function gn(e, t = 2) {
6852
7008
  return String(e).padStart(t, "0");
6853
7009
  }
6854
- function tn(e) {
7010
+ function _n(e) {
6855
7011
  let t = e ? new Date(e) : /* @__PURE__ */ new Date();
6856
- if (Number.isNaN(t.getTime())) return tn(void 0);
6857
- let n = -t.getTimezoneOffset(), r = n >= 0 ? "+" : "-", i = en(Math.floor(Math.abs(n) / 60)), a = en(Math.abs(n) % 60);
6858
- return `D:${t.getFullYear()}${en(t.getMonth() + 1)}${en(t.getDate())}${en(t.getHours())}${en(t.getMinutes())}${en(t.getSeconds())}${r}${i}'${a}'`;
7012
+ if (Number.isNaN(t.getTime())) return _n(void 0);
7013
+ let n = -t.getTimezoneOffset(), r = n >= 0 ? "+" : "-", i = gn(Math.floor(Math.abs(n) / 60)), a = gn(Math.abs(n) % 60);
7014
+ return `D:${t.getFullYear()}${gn(t.getMonth() + 1)}${gn(t.getDate())}${gn(t.getHours())}${gn(t.getMinutes())}${gn(t.getSeconds())}${r}${i}'${a}'`;
6859
7015
  }
6860
- function nn(e) {
7016
+ function vn(e) {
6861
7017
  if (!e) return;
6862
7018
  let t = /^D:(\d{4})(\d{2})?(\d{2})?(\d{2})?(\d{2})?(\d{2})?([+\-Z])?(\d{2})?'?(\d{2})?/.exec(e.trim());
6863
7019
  if (!t) {
@@ -6869,41 +7025,41 @@ function nn(e) {
6869
7025
  let f = Date.parse(`${n}-${r}-${i}T${a}:${o}:${s}${d}`);
6870
7026
  return Number.isNaN(f) ? void 0 : new Date(f).toISOString();
6871
7027
  }
6872
- var rn = (e) => {
7028
+ var yn = (e) => {
6873
7029
  if (!(!e || e === "transparent")) {
6874
7030
  if (/^#[0-9a-f]{6}$/i.test(e)) return e.toUpperCase();
6875
7031
  if (/^#[0-9a-f]{3}$/i.test(e)) return `#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}`.toUpperCase();
6876
7032
  }
6877
- }, $ = (e, t) => t == null || t === "" ? "" : ` ${e}="${Q(String(t))}"`;
6878
- function an(e) {
6879
- return `<trn-custom-data bytes="${Q(JSON.stringify({ [$t]: e }))}"/>`;
7033
+ }, $ = (e, t) => t == null || t === "" ? "" : ` ${e}="${hn(String(t))}"`;
7034
+ function bn(e) {
7035
+ return `<trn-custom-data bytes="${hn(JSON.stringify({ [mn]: e }))}"/>`;
6880
7036
  }
6881
- function on(e) {
7037
+ function xn(e) {
6882
7038
  let t = Array.from(e.children).find((e) => e.localName === "trn-custom-data");
6883
7039
  if (!t) return {};
6884
7040
  try {
6885
- let e = JSON.parse(t.getAttribute("bytes") || "{}")?.[$t];
7041
+ let e = JSON.parse(t.getAttribute("bytes") || "{}")?.[mn];
6886
7042
  return e && typeof e == "object" ? e : {};
6887
7043
  } catch {
6888
7044
  return {};
6889
7045
  }
6890
7046
  }
6891
- function sn(e) {
7047
+ function Sn(e) {
6892
7048
  return e.map((e) => `${Z(e.x)},${Z(e.y)}`).join(";");
6893
7049
  }
6894
- function cn(e) {
7050
+ function Cn(e) {
6895
7051
  return e ? e.split(";").map((e) => e.trim().split(/[,\s]+/).map(Number)).filter((e) => e.length >= 2 && e.every((e) => Number.isFinite(e))).map(([e, t]) => ({
6896
7052
  x: e,
6897
7053
  y: t
6898
7054
  })) : [];
6899
7055
  }
6900
- function ln(e) {
7056
+ function wn(e) {
6901
7057
  return e ? e.split(/[,\s]+/).map(Number).filter((e) => Number.isFinite(e)) : [];
6902
7058
  }
6903
- function un(e) {
7059
+ function Tn(e) {
6904
7060
  return e.map(Z).join(",");
6905
7061
  }
6906
- var dn = /* @__PURE__ */ new Set([
7062
+ var En = /* @__PURE__ */ new Set([
6907
7063
  "page",
6908
7064
  "rect",
6909
7065
  "color",
@@ -6925,7 +7081,7 @@ var dn = /* @__PURE__ */ new Set([
6925
7081
  "IT",
6926
7082
  "callout",
6927
7083
  "style"
6928
- ]), fn = /* @__PURE__ */ new Set([
7084
+ ]), Dn = /* @__PURE__ */ new Set([
6929
7085
  "contents",
6930
7086
  "contents-richtext",
6931
7087
  "inklist",
@@ -6937,33 +7093,33 @@ var dn = /* @__PURE__ */ new Set([
6937
7093
  "popup",
6938
7094
  "vertices"
6939
7095
  ]);
6940
- function pn(e, t, n, r) {
6941
- let i = r ?? Vt(t, {
7096
+ function On(e, t, n, r) {
7097
+ let i = r ?? nn(t, {
6942
7098
  x: e.x,
6943
7099
  y: e.y,
6944
7100
  width: e.width,
6945
7101
  height: e.height
6946
7102
  }), a = e.createdAt ?? (e.timestamp ? new Date(e.timestamp).toISOString() : void 0), o = ["print", ...e.readOnly ? ["readonly", "locked"] : []].join(",");
6947
- return $("page", e.pageIndex - 1) + $("rect", un(i)) + $("name", e.id) + (n ? $("title", e.author) : "") + $("date", tn(e.modifiedAt ?? a)) + $("creationdate", tn(a)) + $("flags", o) + $("opacity", e.opacity !== void 0 && e.opacity !== 1 ? Z(e.opacity) : void 0);
7103
+ return $("page", e.pageIndex - 1) + $("rect", Tn(i)) + $("name", e.id) + (n ? $("title", e.author) : "") + $("date", _n(e.modifiedAt ?? a)) + $("creationdate", _n(a)) + $("flags", o) + $("opacity", e.opacity !== void 0 && e.opacity !== 1 ? Z(e.opacity) : void 0);
6948
7104
  }
6949
- function mn(e) {
7105
+ function kn(e) {
6950
7106
  let t = e.xfdfExtras?.attrs;
6951
- return t ? Object.entries(t).filter(([e]) => !dn.has(e)).map(([e, t]) => $(e, t)).join("") : "";
7107
+ return t ? Object.entries(t).filter(([e]) => !En.has(e)).map(([e, t]) => $(e, t)).join("") : "";
6952
7108
  }
6953
- function hn(e) {
7109
+ function An(e) {
6954
7110
  return (e.xfdfExtras?.children ?? []).join("");
6955
7111
  }
6956
- function gn(e, t = {}) {
7112
+ function jn(e, t = {}) {
6957
7113
  let n = {
6958
7114
  type: e.type,
6959
7115
  ...t
6960
7116
  };
6961
- return e.authorId && (n.authorId = e.authorId), e.strokeWidth !== void 0 && (n.strokeWidth = e.strokeWidth), an(n);
7117
+ return e.authorId && (n.authorId = e.authorId), e.strokeWidth !== void 0 && (n.strokeWidth = e.strokeWidth), bn(n);
6962
7118
  }
6963
- var _n = (e) => e ? `<contents>${Q(e)}</contents>` : "", vn = (e, t) => `<defaultstyle>font: Helvetica ${t}pt; text-align: left; color: ${rn(e.color) ?? "#000000"}</defaultstyle><defaultappearance>0 0 0 rg /Helv ${t} Tf</defaultappearance>`;
6964
- async function yn(e, t, n = {}) {
7119
+ var Mn = (e) => e ? `<contents>${hn(e)}</contents>` : "", Nn = (e, t) => `<defaultstyle>font: Helvetica ${t}pt; text-align: left; color: ${yn(e.color) ?? "#000000"}</defaultstyle><defaultappearance>0 0 0 rg /Helv ${t} Tf</defaultappearance>`;
7120
+ async function Pn(e, t, n = {}) {
6965
7121
  if (e.type === "opaque" && e.rawXfdf) return e.rawXfdf;
6966
- let r = await t(e.pageIndex), i = n.useDisplayAuthor !== !1, a = rn(e.color), o = $("color", a) + $("width", e.strokeWidth), s = (t) => pn(e, r, i, t) + mn(e), c = (t = {}) => gn(e, t) + hn(e);
7122
+ let r = await t(e.pageIndex), i = n.useDisplayAuthor !== !1, a = yn(e.color), o = $("color", a) + $("width", e.strokeWidth), s = (t) => On(e, r, i, t) + kn(e), c = (t = {}) => jn(e, t) + An(e);
6967
7123
  switch (e.type) {
6968
7124
  case "rectangle": return `<square${s()}${o}${$("interior-color", a)} subject="Rectangle">${c()}</square>`;
6969
7125
  case "ellipse": return `<circle${s()}${o}${$("interior-color", a)} subject="Ellipse">${c()}</circle>`;
@@ -6975,7 +7131,7 @@ async function yn(e, t, n = {}) {
6975
7131
  }, {
6976
7132
  x: e.x + e.width,
6977
7133
  y: e.y + e.height
6978
- }], [n, i] = Ht(r, [t[0], t[1]]), a = [
7134
+ }], [n, i] = X(r, [t[0], t[1]]), a = [
6979
7135
  Math.min(n.x, i.x),
6980
7136
  Math.min(n.y, i.y),
6981
7137
  Math.max(n.x, i.x),
@@ -6984,8 +7140,8 @@ async function yn(e, t, n = {}) {
6984
7140
  return `<line${s(a)}${o} start="${Z(n.x)},${Z(n.y)}" end="${Z(i.x)},${Z(i.y)}"${l} subject="${e.type === "arrow" ? "Arrow" : "Line"}">${c()}</line>`;
6985
7141
  }
6986
7142
  case "freehand": {
6987
- let t = e.strokes && e.strokes.length > 0 ? e.strokes : e.points ? [e.points] : [], n = t.map((e) => `<gesture>${sn(Ht(r, e))}</gesture>`).join(""), i = t.flat();
6988
- return `<ink${s(i.length ? Vt(r, bn(i, e.strokeWidth)) : void 0)}${o} subject="Free Hand"><inklist>${n}</inklist>${c()}</ink>`;
7143
+ let t = e.strokes && e.strokes.length > 0 ? e.strokes : e.points ? [e.points] : [], n = t.map((e) => `<gesture>${Sn(X(r, e))}</gesture>`).join(""), i = t.flat();
7144
+ return `<ink${s(i.length ? nn(r, Fn(i, e.strokeWidth)) : void 0)}${o} subject="Free Hand"><inklist>${n}</inklist>${c()}</ink>`;
6989
7145
  }
6990
7146
  case "highlight": {
6991
7147
  let t = e.rects && e.rects.length > 0 ? e.rects : [{
@@ -6993,10 +7149,10 @@ async function yn(e, t, n = {}) {
6993
7149
  y: e.y,
6994
7150
  width: e.width,
6995
7151
  height: e.height
6996
- }], n = t.flatMap((e) => Wt(r, e)).map(Z).join(",");
6997
- return `<highlight${s(Vt(r, X(t)))}${$("color", a)} coords="${n}" subject="Highlight">${c()}</highlight>`;
7152
+ }], n = t.flatMap((e) => an(r, e)).map(Z).join(",");
7153
+ return `<highlight${s(nn(r, sn(t)))}${$("color", a)} coords="${n}" subject="Highlight">${c()}</highlight>`;
6998
7154
  }
6999
- case "text": return `<freetext${s()}${$("color", a)} subject="Free Text">${_n(e.text)}${vn(e, 16)}${c()}</freetext>`;
7155
+ case "text": return `<freetext${s()}${$("color", a)} subject="Free Text">${Mn(e.text)}${Nn(e, 16)}${c()}</freetext>`;
7000
7156
  case "callout": {
7001
7157
  let t = e.points && e.points.length >= 2 ? e.points : [{
7002
7158
  x: e.x,
@@ -7004,7 +7160,7 @@ async function yn(e, t, n = {}) {
7004
7160
  }, {
7005
7161
  x: e.x,
7006
7162
  y: e.y
7007
- }], [n, i] = Ht(r, [t[0], t[1]]), a = Vt(r, {
7163
+ }], [n, i] = X(r, [t[0], t[1]]), a = nn(r, {
7008
7164
  x: t[1].x,
7009
7165
  y: t[1].y,
7010
7166
  width: e.text ? e.text.length * 8 + 20 : 100,
@@ -7015,19 +7171,19 @@ async function yn(e, t, n = {}) {
7015
7171
  Math.min(n.y, a[1]),
7016
7172
  Math.max(i.x, a[2]),
7017
7173
  Math.max(i.y, a[3])
7018
- ])}${o} IT="FreeTextCallout" callout="${Z(n.x)},${Z(n.y)},${Z(i.x)},${Z(i.y)}" subject="Callout">${_n(e.text)}${vn(e, 14)}${c({ box: a })}</freetext>`;
7174
+ ])}${o} IT="FreeTextCallout" callout="${Z(n.x)},${Z(n.y)},${Z(i.x)},${Z(i.y)}" subject="Callout">${Mn(e.text)}${Nn(e, 14)}${c({ box: a })}</freetext>`;
7019
7175
  }
7020
- case "note": return `<text${s(Vt(r, {
7176
+ case "note": return `<text${s(nn(r, {
7021
7177
  x: e.x,
7022
7178
  y: e.y,
7023
7179
  width: 24,
7024
7180
  height: 24
7025
- }))}${$("color", a)} icon="Comment" subject="Sticky Note">${_n(e.text)}${c()}</text>`;
7181
+ }))}${$("color", a)} icon="Comment" subject="Sticky Note">${Mn(e.text)}${c()}</text>`;
7026
7182
  case "link": {
7027
- let t = e.linkUrl ?? "", n = t.startsWith("#page=") ? `<OnActivation><Action Trigger="U"><GoTo><Dest><Fit Page="${Math.max(0, (parseInt(t.slice(6), 10) || 1) - 1)}"/></Dest></GoTo></Action></OnActivation>` : t ? `<OnActivation><Action Trigger="U"><URI Name="${Q(t)}"/></Action></OnActivation>` : "";
7028
- return `<link${s()}${$("color", a)} subject="Link">${n}${_n(e.text)}${c()}</link>`;
7183
+ let t = e.linkUrl ?? "", n = t.startsWith("#page=") ? `<OnActivation><Action Trigger="U"><GoTo><Dest><Fit Page="${Math.max(0, (parseInt(t.slice(6), 10) || 1) - 1)}"/></Dest></GoTo></Action></OnActivation>` : t ? `<OnActivation><Action Trigger="U"><URI Name="${hn(t)}"/></Action></OnActivation>` : "";
7184
+ return `<link${s()}${$("color", a)} subject="Link">${n}${Mn(e.text)}${c()}</link>`;
7029
7185
  }
7030
- case "signature": return `<stamp${s()} subject="Signature">${e.imageUrl ? `<imagedata>${Q(e.imageUrl)}</imagedata>` : ""}${c({
7186
+ case "signature": return `<stamp${s()} subject="Signature">${e.imageUrl ? `<imagedata>${hn(e.imageUrl)}</imagedata>` : ""}${c({
7031
7187
  signer: e.signer,
7032
7188
  signType: e.signType,
7033
7189
  timestamp: e.timestamp
@@ -7040,7 +7196,7 @@ async function yn(e, t, n = {}) {
7040
7196
  default: return "";
7041
7197
  }
7042
7198
  }
7043
- function bn(e, t = 0) {
7199
+ function Fn(e, t = 0) {
7044
7200
  let n = e.map((e) => e.x), r = e.map((e) => e.y), i = t / 2, a = Math.min(...n) - i, o = Math.min(...r) - i;
7045
7201
  return {
7046
7202
  x: a,
@@ -7049,21 +7205,21 @@ function bn(e, t = 0) {
7049
7205
  height: Math.max(...r) - o + i
7050
7206
  };
7051
7207
  }
7052
- async function xn(e, t, n = {}) {
7208
+ async function In(e, t, n = {}) {
7053
7209
  let r = n.annotList ?? e;
7054
- return `<?xml version="1.0" encoding="UTF-8"?><xfdf xmlns="${Qt}" xml:space="preserve"><annots>${(await Promise.all(r.map((e) => yn(e, t, n)))).filter(Boolean).join("")}</annots></xfdf>`;
7210
+ return `<?xml version="1.0" encoding="UTF-8"?><xfdf xmlns="${pn}" xml:space="preserve"><annots>${(await Promise.all(r.map((e) => Pn(e, t, n)))).filter(Boolean).join("")}</annots></xfdf>`;
7055
7211
  }
7056
- function Sn(e) {
7212
+ function Ln(e) {
7057
7213
  let t = {};
7058
- for (let n of Array.from(e.attributes)) !dn.has(n.name) && !n.name.startsWith("xmlns") && (t[n.name] = n.value);
7214
+ for (let n of Array.from(e.attributes)) !En.has(n.name) && !n.name.startsWith("xmlns") && (t[n.name] = n.value);
7059
7215
  let n = [];
7060
- for (let t of Array.from(e.children)) fn.has(t.localName) || n.push(new XMLSerializer().serializeToString(t));
7216
+ for (let t of Array.from(e.children)) Dn.has(t.localName) || n.push(new XMLSerializer().serializeToString(t));
7061
7217
  let r = Array.from(e.children).find((e) => e.localName === "trn-custom-data");
7062
7218
  if (r) try {
7063
7219
  let e = JSON.parse(r.getAttribute("bytes") || "{}");
7064
7220
  if (e && typeof e == "object") {
7065
7221
  let t = { ...e };
7066
- delete t[$t], Object.keys(t).length > 0 && n.push(`<trn-custom-data bytes="${Q(JSON.stringify(t))}"/>`);
7222
+ delete t[mn], Object.keys(t).length > 0 && n.push(`<trn-custom-data bytes="${hn(JSON.stringify(t))}"/>`);
7067
7223
  }
7068
7224
  } catch {
7069
7225
  n.push(new XMLSerializer().serializeToString(r));
@@ -7071,11 +7227,11 @@ function Sn(e) {
7071
7227
  let i = {};
7072
7228
  return Object.keys(t).length && (i.attrs = t), n.length && (i.children = n), Object.keys(i).length ? i : void 0;
7073
7229
  }
7074
- function Cn(e, t) {
7230
+ function Rn(e, t) {
7075
7231
  return Array.from(e.children).find((e) => e.localName === t)?.textContent ?? void 0;
7076
7232
  }
7077
- function wn(e, t) {
7078
- let n = ln(e.getAttribute("rect")), r = n.length === 4 ? Y(t, [
7233
+ function zn(e, t) {
7234
+ let n = wn(e.getAttribute("rect")), r = n.length === 4 ? Y(t, [
7079
7235
  n[0],
7080
7236
  n[1],
7081
7237
  n[2],
@@ -7085,9 +7241,9 @@ function wn(e, t) {
7085
7241
  y: 0,
7086
7242
  width: 0,
7087
7243
  height: 0
7088
- }, i = on(e), a = rn(e.getAttribute("color") || e.getAttribute("interior-color") || void 0) ?? "#000000", o = e.getAttribute("opacity"), s = o !== null && Number.isFinite(Number(o)) ? Number(o) : 1, c = e.getAttribute("width"), l = typeof i.strokeWidth == "number" ? i.strokeWidth : c !== null && Number.isFinite(Number(c)) ? Number(c) : 1, u = (e.getAttribute("flags") || "").toLowerCase(), d = u.includes("readonly") || u.includes("locked");
7244
+ }, i = xn(e), a = yn(e.getAttribute("color") || e.getAttribute("interior-color") || void 0) ?? "#000000", o = e.getAttribute("opacity"), s = o !== null && Number.isFinite(Number(o)) ? Number(o) : 1, c = e.getAttribute("width"), l = typeof i.strokeWidth == "number" ? i.strokeWidth : c !== null && Number.isFinite(Number(c)) ? Number(c) : 1, u = (e.getAttribute("flags") || "").toLowerCase(), d = u.includes("readonly") || u.includes("locked");
7089
7245
  return {
7090
- id: e.getAttribute("name") || ft(),
7246
+ id: e.getAttribute("name") || Ct(),
7091
7247
  pageIndex: (parseInt(e.getAttribute("page") || "0", 10) || 0) + 1,
7092
7248
  x: r.x,
7093
7249
  y: r.y,
@@ -7098,14 +7254,14 @@ function wn(e, t) {
7098
7254
  opacity: s,
7099
7255
  author: e.getAttribute("title") || void 0,
7100
7256
  authorId: typeof i.authorId == "string" ? i.authorId : void 0,
7101
- createdAt: nn(e.getAttribute("creationdate")),
7102
- modifiedAt: nn(e.getAttribute("date")),
7257
+ createdAt: vn(e.getAttribute("creationdate")),
7258
+ modifiedAt: vn(e.getAttribute("date")),
7103
7259
  readOnly: d || void 0,
7104
- xfdfExtras: Sn(e)
7260
+ xfdfExtras: Ln(e)
7105
7261
  };
7106
7262
  }
7107
- function Tn(e, t) {
7108
- let n = e.localName.toLowerCase(), r = on(e), i = wn(e, t), a = () => ({
7263
+ function Bn(e, t) {
7264
+ let n = e.localName.toLowerCase(), r = xn(e), i = zn(e, t), a = () => ({
7109
7265
  ...i,
7110
7266
  type: "opaque",
7111
7267
  opaqueKind: n,
@@ -7122,15 +7278,15 @@ function Tn(e, t) {
7122
7278
  type: "ellipse"
7123
7279
  };
7124
7280
  case "line": {
7125
- let n = ln(e.getAttribute("start")), r = ln(e.getAttribute("end")), o = (e.getAttribute("head") || "None").toLowerCase(), s = (e.getAttribute("tail") || "None").toLowerCase();
7281
+ let n = wn(e.getAttribute("start")), r = wn(e.getAttribute("end")), o = (e.getAttribute("head") || "None").toLowerCase(), s = (e.getAttribute("tail") || "None").toLowerCase();
7126
7282
  if (n.length < 2 || r.length < 2) return a();
7127
- let [c, l] = Ut(t, [{
7283
+ let [c, l] = rn(t, [{
7128
7284
  x: n[0],
7129
7285
  y: n[1]
7130
7286
  }, {
7131
7287
  x: r[0],
7132
7288
  y: r[1]
7133
- }]), u = bn([c, l]), d = o !== "none" || s !== "none";
7289
+ }]), u = Fn([c, l]), d = o !== "none" || s !== "none";
7134
7290
  return {
7135
7291
  ...i,
7136
7292
  ...u,
@@ -7139,24 +7295,24 @@ function Tn(e, t) {
7139
7295
  };
7140
7296
  }
7141
7297
  case "ink": {
7142
- let n = Array.from(e.getElementsByTagName("*")).filter((e) => e.localName === "gesture").map((e) => Ut(t, cn(e.textContent))).filter((e) => e.length > 0);
7298
+ let n = Array.from(e.getElementsByTagName("*")).filter((e) => e.localName === "gesture").map((e) => rn(t, Cn(e.textContent))).filter((e) => e.length > 0);
7143
7299
  if (n.length === 0) return a();
7144
7300
  let r = n.flat();
7145
7301
  return {
7146
7302
  ...i,
7147
- ...bn(r),
7303
+ ...Fn(r),
7148
7304
  type: "freehand",
7149
7305
  points: n[0],
7150
7306
  strokes: n
7151
7307
  };
7152
7308
  }
7153
7309
  case "highlight": {
7154
- let n = ln(e.getAttribute("coords")), r = n.length >= 8 ? Gt(t, n) : [{
7310
+ let n = wn(e.getAttribute("coords")), r = n.length >= 8 ? on(t, n) : [{
7155
7311
  x: i.x,
7156
7312
  y: i.y,
7157
7313
  width: i.width,
7158
7314
  height: i.height
7159
- }], a = X(r);
7315
+ }], a = sn(r);
7160
7316
  return {
7161
7317
  ...i,
7162
7318
  ...a,
@@ -7166,9 +7322,9 @@ function Tn(e, t) {
7166
7322
  };
7167
7323
  }
7168
7324
  case "freetext": {
7169
- let n = Cn(e, "contents") ?? "", a = e.getAttribute("IT") || "", o = ln(e.getAttribute("callout"));
7325
+ let n = Rn(e, "contents") ?? "", a = e.getAttribute("IT") || "", o = wn(e.getAttribute("callout"));
7170
7326
  if (a === "FreeTextCallout" || r.type === "callout" || o.length >= 4) {
7171
- let e = o.length >= 4 ? Ut(t, [{
7327
+ let e = o.length >= 4 ? rn(t, [{
7172
7328
  x: o[0],
7173
7329
  y: o[1]
7174
7330
  }, {
@@ -7203,7 +7359,7 @@ function Tn(e, t) {
7203
7359
  case "text": return {
7204
7360
  ...i,
7205
7361
  type: "note",
7206
- text: Cn(e, "contents") ?? "",
7362
+ text: Rn(e, "contents") ?? "",
7207
7363
  width: 24,
7208
7364
  height: 24
7209
7365
  };
@@ -7213,7 +7369,7 @@ function Tn(e, t) {
7213
7369
  ...i,
7214
7370
  type: "link",
7215
7371
  linkUrl: r,
7216
- text: Cn(e, "contents") ?? "",
7372
+ text: Rn(e, "contents") ?? "",
7217
7373
  color: "transparent",
7218
7374
  strokeWidth: 0,
7219
7375
  opacity: 1,
@@ -7221,7 +7377,7 @@ function Tn(e, t) {
7221
7377
  };
7222
7378
  }
7223
7379
  case "stamp": {
7224
- let t = Cn(e, "imagedata");
7380
+ let t = Rn(e, "imagedata");
7225
7381
  return r.type === "digital_signature_placeholder" ? {
7226
7382
  ...i,
7227
7383
  type: "digital_signature_placeholder",
@@ -7238,7 +7394,7 @@ function Tn(e, t) {
7238
7394
  default: return a();
7239
7395
  }
7240
7396
  }
7241
- function En(e) {
7397
+ function Vn(e) {
7242
7398
  let t = "", n = 0;
7243
7399
  for (;;) {
7244
7400
  let r = e.indexOf("<?xml", n);
@@ -7249,11 +7405,11 @@ function En(e) {
7249
7405
  }
7250
7406
  return t + e.slice(n);
7251
7407
  }
7252
- async function Dn(e, t) {
7253
- let n = En(e).trim();
7408
+ async function Hn(e, t) {
7409
+ let n = Vn(e).trim();
7254
7410
  if (!n) return [];
7255
7411
  if (/<!DOCTYPE|<!ENTITY/i.test(n)) throw Error("[teamsync-pdf-viewer] invalid XFDF: DOCTYPE/ENTITY declarations are not allowed");
7256
- let r = `<xfdf xmlns="${Qt}"><annots>${n}</annots></xfdf>`, i = new DOMParser().parseFromString(r, "application/xml"), a = i.getElementsByTagName("parsererror")[0];
7412
+ let r = `<xfdf xmlns="${pn}"><annots>${n}</annots></xfdf>`, i = new DOMParser().parseFromString(r, "application/xml"), a = i.getElementsByTagName("parsererror")[0];
7257
7413
  if (a) throw Error(`[teamsync-pdf-viewer] invalid XFDF: ${a.textContent?.slice(0, 200)}`);
7258
7414
  let o = /* @__PURE__ */ new Set([
7259
7415
  "xfdf",
@@ -7263,14 +7419,14 @@ async function Dn(e, t) {
7263
7419
  "ids"
7264
7420
  ]), s = Array.from(i.getElementsByTagName("*")).filter((e) => e.parentElement?.localName === "annots" && !o.has(e.localName)), c = [];
7265
7421
  for (let e of s) {
7266
- let n = Tn(e, await t((parseInt(e.getAttribute("page") || "0", 10) || 0) + 1));
7422
+ let n = Bn(e, await t((parseInt(e.getAttribute("page") || "0", 10) || 0) + 1));
7267
7423
  n && c.push(n);
7268
7424
  }
7269
7425
  return c;
7270
7426
  }
7271
7427
  //#endregion
7272
7428
  //#region src/annotations/AnnotationManager.ts
7273
- var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class {
7429
+ var Un = 100, Wn = () => (/* @__PURE__ */ new Date()).toISOString(), Gn = class {
7274
7430
  list = [];
7275
7431
  past = [];
7276
7432
  future = [];
@@ -7281,7 +7437,7 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
7281
7437
  canEditOthers = !1;
7282
7438
  resolver = null;
7283
7439
  setDocument(e) {
7284
- this.resolver = e ? J(e) : null;
7440
+ this.resolver = e ? $t(e) : null;
7285
7441
  }
7286
7442
  hasDocument() {
7287
7443
  return this.resolver !== null;
@@ -7372,7 +7528,7 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
7372
7528
  addAnnotations(e, t = {}) {
7373
7529
  let n = e.map((e) => ({
7374
7530
  ...e,
7375
- id: e.id ?? ft()
7531
+ id: e.id ?? Ct()
7376
7532
  }));
7377
7533
  return this.commit([...this.list, ...n], t), n.map((e) => this.getAnnotationById(e.id)).filter((e) => !!e);
7378
7534
  }
@@ -7396,7 +7552,7 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
7396
7552
  });
7397
7553
  }
7398
7554
  async importAnnotations(e) {
7399
- let t = await Dn(e, this.requireResolver());
7555
+ let t = await Hn(e, this.requireResolver());
7400
7556
  if (t.length === 0) return [];
7401
7557
  let n = new Map(t.map((e) => [e.id, e])), r = this.list.map((e) => n.get(e.id) ?? e);
7402
7558
  for (let e of t) this.list.some((t) => t.id === e.id) || r.push(e);
@@ -7408,7 +7564,7 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
7408
7564
  }
7409
7565
  async exportAnnotations(e = {}) {
7410
7566
  let t = this.requireResolver();
7411
- return e.annotList ? (await Promise.all(e.annotList.map((n) => yn(n, t, e)))).join("") : xn(this.list, t, e);
7567
+ return e.annotList ? (await Promise.all(e.annotList.map((n) => Pn(n, t, e)))).join("") : In(this.list, t, e);
7412
7568
  }
7413
7569
  exportAnnotationsLegacyJson() {
7414
7570
  return JSON.stringify(this.list, null, 2);
@@ -7432,7 +7588,7 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
7432
7588
  }
7433
7589
  let n = r ? t : {
7434
7590
  ...t,
7435
- modifiedAt: kn()
7591
+ modifiedAt: Wn()
7436
7592
  };
7437
7593
  c.push(n), l.push({
7438
7594
  before: e,
@@ -7452,7 +7608,7 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
7452
7608
  added: s,
7453
7609
  modified: l,
7454
7610
  deleted: u
7455
- }), this.past.length > On && this.past.shift(), this.future = []), this.list = d;
7611
+ }), this.past.length > Un && this.past.shift(), this.future = []), this.list = d;
7456
7612
  for (let e of Array.from(this.listListeners)) try {
7457
7613
  e();
7458
7614
  } catch (e) {
@@ -7474,7 +7630,7 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
7474
7630
  }
7475
7631
  stampNew(e, t) {
7476
7632
  if (t) return e;
7477
- let n = e.createdAt ?? kn();
7633
+ let n = e.createdAt ?? Wn();
7478
7634
  return {
7479
7635
  ...e,
7480
7636
  author: e.author ?? this.user.name,
@@ -7490,16 +7646,16 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
7490
7646
  console.error("[teamsync-pdf-viewer] annotationChanged listener threw", e);
7491
7647
  }
7492
7648
  }
7493
- }, jn = () => {
7649
+ }, Kn = () => {
7494
7650
  throw Error("[teamsync-pdf-viewer] viewer is not mounted (was destroy() called?)");
7495
- }, Mn = class {
7651
+ }, qn = class {
7496
7652
  bus;
7497
7653
  annotationManager;
7498
7654
  element = null;
7499
7655
  binding = null;
7500
7656
  unmountRoot = null;
7501
7657
  destroyed = !1;
7502
- constructor(e, t = new An()) {
7658
+ constructor(e, t = new Gn()) {
7503
7659
  this.bus = e, this.annotationManager = t;
7504
7660
  }
7505
7661
  _bind(e, t) {
@@ -7535,7 +7691,7 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
7535
7691
  this.bus.off(e, t);
7536
7692
  }
7537
7693
  loadDocument(e) {
7538
- let t = this.binding ?? jn();
7694
+ let t = this.binding ?? Kn();
7539
7695
  return new Promise((n, r) => {
7540
7696
  let i = this.bus.on("documentLoaded", (t) => {
7541
7697
  t.url === e && (o(), n(t));
@@ -7573,7 +7729,7 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
7573
7729
  let t = this.getPdfDocument();
7574
7730
  if (!t) return [];
7575
7731
  let n = this.binding;
7576
- return et(t, e, n ? n.getRedactions() : []);
7732
+ return tt(t, e, n ? n.getRedactions() : []);
7577
7733
  }
7578
7734
  getTransientHighlights() {
7579
7735
  return this.binding?.getTransientHighlights() ?? [];
@@ -7610,16 +7766,16 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
7610
7766
  this.bus.emit("action-print");
7611
7767
  }
7612
7768
  async getFileData(e = {}) {
7613
- let t = this.binding ?? jn(), n = t.getPdfDocument(), r = t.getDocumentUrl();
7769
+ let t = this.binding ?? Kn(), n = t.getPdfDocument(), r = t.getDocumentUrl();
7614
7770
  if (!n && !r) throw Error("No document loaded");
7615
- return Zt({
7771
+ return Q({
7616
7772
  getSourceBytes: async () => {
7617
7773
  if (n) return n.getData();
7618
7774
  let e = await fetch(r);
7619
7775
  if (!e.ok) throw Error(`Failed to fetch document (${e.status})`);
7620
7776
  return e.arrayBuffer();
7621
7777
  },
7622
- getPageGeometry: n ? J(n) : void 0,
7778
+ getPageGeometry: n ? $t(n) : void 0,
7623
7779
  annotations: this.annotationManager.getAnnotationsList(),
7624
7780
  redactions: t.getRedactions(),
7625
7781
  watermark: t.getWatermark(),
@@ -7678,7 +7834,7 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
7678
7834
  };
7679
7835
  //#endregion
7680
7836
  //#region src/core/print.ts
7681
- async function Nn(e, t = {}) {
7837
+ async function Jn(e, t = {}) {
7682
7838
  if (typeof document > "u") throw Error("[teamsync-pdf-viewer] printing needs a browser");
7683
7839
  let n = new Blob([e], { type: "application/pdf" }), r = URL.createObjectURL(n), i = document.createElement("iframe");
7684
7840
  i.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", i.title = t.title ?? "Print", i.setAttribute("aria-hidden", "true"), await new Promise((e, n) => {
@@ -7703,11 +7859,11 @@ async function Nn(e, t = {}) {
7703
7859
  }
7704
7860
  //#endregion
7705
7861
  //#region src/components/TeamSyncViewer.tsx
7706
- var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, Ln = e.forwardRef(function(e, t) {
7862
+ var Yn = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, Xn = e.forwardRef(function(e, t) {
7707
7863
  let { fileUrl: r, initialDoc: l, initialScale: u, initialPage: d, page: f, transientHighlights: p, plugins: m, redactions: h, regexRedactions: g, enableAnnotations: _, enableSign: v = !1, watermark: y, permissions: b, enableRedactions: x, canAddAnnotations: ee, canEditAnnotations: S, canDeleteAnnotations: C, readOnly: te = !1, assets: ne, withCredentials: re = !1, toolbar: ie = !0, sidebars: w = !0, leftPanelOpen: T = !0, className: ae, style: oe } = e, E = s(e);
7708
7864
  E.current = e;
7709
- let D = s(null), O = o(() => new Pt(), []), k = o(() => new An(), []), se = s(null);
7710
- se.current ||= new Mn(O, k);
7865
+ let D = s(null), O = o(() => new Yt(), []), k = o(() => new Gn(), []), se = s(null);
7866
+ se.current ||= new qn(O, k);
7711
7867
  let A = se.current;
7712
7868
  a(t, () => A, [A]);
7713
7869
  let ce = r ?? l, [le, ue] = c(ce), [de, fe] = c(0);
@@ -7811,7 +7967,7 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
7811
7967
  O.on("action-tool-changed", (e) => O.emit("toolChanged", { tool: e?.tool ?? null })),
7812
7968
  O.on("action-print", async () => {
7813
7969
  try {
7814
- await Nn(await A.getFileData(), { title: E.current.fileName });
7970
+ await Jn(await A.getFileData(), { title: E.current.fileName });
7815
7971
  } catch (e) {
7816
7972
  console.error("[teamsync-pdf-viewer] print failed", e), O.emit("action-print-error", { error: e });
7817
7973
  }
@@ -7829,7 +7985,7 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
7829
7985
  O.on("action-process-digital-signature", async (e) => {
7830
7986
  try {
7831
7987
  let { pageIndex: t, x: n, y: r, width: i, height: a } = e, o = {
7832
- id: In(),
7988
+ id: Yn(),
7833
7989
  type: "digital_signature_placeholder",
7834
7990
  pageIndex: t,
7835
7991
  x: n,
@@ -7907,24 +8063,24 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
7907
8063
  pageNumber: e,
7908
8064
  numPages: t
7909
8065
  }), E.current.onPageChange?.(e, t);
7910
- }, [O]), H = n((e) => {
7911
- O.emit("annotationsChanged", { annotations: e }), E.current.onAnnotationsChange?.(e);
7912
8066
  }, [O]), Ye = n((e) => {
8067
+ O.emit("annotationsChanged", { annotations: e }), E.current.onAnnotationsChange?.(e);
8068
+ }, [O]), Xe = n((e) => {
7913
8069
  z.current = e;
7914
- }, []), { getCommand: Xe } = Ze(), Qe = s(null), et = n(() => {
8070
+ }, []), { getCommand: Ze } = Qe(), $e = s(null), tt = n(() => {
7915
8071
  w && (j(!0), be("Search"), setTimeout(() => O.emit("action-focus-search"), 50));
7916
- }, [w, O]), tt = n(() => {
7917
- Qe.current?.click();
8072
+ }, [w, O]), nt = n(() => {
8073
+ $e.current?.click();
7918
8074
  }, []);
7919
8075
  return i(() => {
7920
- let e = O.on("action-open-search", et), t = O.on("action-open-file-picker", tt);
8076
+ let e = O.on("action-open-search", tt), t = O.on("action-open-file-picker", nt);
7921
8077
  return () => {
7922
8078
  e(), t();
7923
8079
  };
7924
8080
  }, [
7925
8081
  O,
7926
- et,
7927
- tt
8082
+ tt,
8083
+ nt
7928
8084
  ]), i(() => {
7929
8085
  D.current && (document.activeElement === document.body || !document.activeElement) && D.current.focus({ preventScroll: !0 });
7930
8086
  }, []), i(() => {
@@ -7933,12 +8089,12 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
7933
8089
  if (t?.tagName === "INPUT" || t?.tagName === "TEXTAREA" || t?.isContentEditable) return;
7934
8090
  let n = D.current;
7935
8091
  if (n && (document.activeElement === document.body || document.activeElement === document.documentElement || document.activeElement === null || n.contains(document.activeElement)) && !n.contains(document.activeElement)) {
7936
- if ($e(e, Xe("SEARCH"))) {
7937
- e.preventDefault(), et();
8092
+ if (et(e, Ze("SEARCH"))) {
8093
+ e.preventDefault(), tt();
7938
8094
  return;
7939
8095
  }
7940
- if ($e(e, Xe("FILE_PICKER"))) {
7941
- e.preventDefault(), tt();
8096
+ if (et(e, Ze("FILE_PICKER"))) {
8097
+ e.preventDefault(), nt();
7942
8098
  return;
7943
8099
  }
7944
8100
  O.emit("viewer-keydown", e);
@@ -7949,9 +8105,9 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
7949
8105
  };
7950
8106
  }, [
7951
8107
  O,
7952
- Xe,
7953
- et,
7954
- tt
8108
+ Ze,
8109
+ tt,
8110
+ nt
7955
8111
  ]), /* @__PURE__ */ F(Ie.Provider, {
7956
8112
  value: O,
7957
8113
  children: /* @__PURE__ */ I("div", {
@@ -7961,12 +8117,12 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
7961
8117
  tabIndex: -1,
7962
8118
  "data-teamsync-pdf-viewer": "",
7963
8119
  onKeyDownCapture: (e) => {
7964
- if ($e(e.nativeEvent, Xe("SEARCH"))) {
7965
- e.preventDefault(), et();
8120
+ if (et(e.nativeEvent, Ze("SEARCH"))) {
8121
+ e.preventDefault(), tt();
7966
8122
  return;
7967
8123
  }
7968
- if ($e(e.nativeEvent, Xe("FILE_PICKER"))) {
7969
- e.preventDefault(), tt();
8124
+ if (et(e.nativeEvent, Ze("FILE_PICKER"))) {
8125
+ e.preventDefault(), nt();
7970
8126
  return;
7971
8127
  }
7972
8128
  O.emit("viewer-keydown", e.nativeEvent);
@@ -7989,10 +8145,10 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
7989
8145
  setRightSidebarOpen: j,
7990
8146
  sidebarTab: ye,
7991
8147
  scale: M,
7992
- onZoomIn: () => xe((e) => Math.min(e + .25, Fn)),
7993
- onZoomOut: () => xe((e) => Math.max(e - .25, Pn)),
7994
- onZoomSet: (e) => xe(Math.min(Fn, Math.max(Pn, e))),
7995
- onOpenFile: tt,
8148
+ onZoomIn: () => xe((e) => gt(e)),
8149
+ onZoomOut: () => xe((e) => _t(e)),
8150
+ onZoomSet: (e) => xe(vt(e)),
8151
+ onOpenFile: nt,
7996
8152
  onDownload: () => O.emit("action-download"),
7997
8153
  onFullScreen: () => {
7998
8154
  let e = D.current ?? document.documentElement;
@@ -8017,7 +8173,7 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
8017
8173
  permissions: P
8018
8174
  }),
8019
8175
  /* @__PURE__ */ F("input", {
8020
- ref: Qe,
8176
+ ref: $e,
8021
8177
  type: "file",
8022
8178
  accept: "application/pdf",
8023
8179
  style: { display: "none" },
@@ -8038,7 +8194,7 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
8038
8194
  minHeight: 0,
8039
8195
  overflow: "hidden"
8040
8196
  },
8041
- children: /* @__PURE__ */ F(At, {
8197
+ children: /* @__PURE__ */ F(Kt, {
8042
8198
  leftSidebarOpen: w && ge,
8043
8199
  rightSidebarOpen: w && ve,
8044
8200
  sidebarTab: ye,
@@ -8054,8 +8210,8 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
8054
8210
  regexRedactions: g,
8055
8211
  scale: M,
8056
8212
  setScale: xe,
8057
- onAnnotationsChange: H,
8058
- onRedactionsChange: Ye,
8213
+ onAnnotationsChange: Ye,
8214
+ onRedactionsChange: Xe,
8059
8215
  onDocumentLoaded: Ge,
8060
8216
  onLoadError: Ke,
8061
8217
  onFirstPageRendered: qe,
@@ -8073,22 +8229,22 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
8073
8229
  permissions: P
8074
8230
  })
8075
8231
  }),
8076
- Se && /* @__PURE__ */ F(Mt, {
8232
+ Se && /* @__PURE__ */ F(Jt, {
8077
8233
  onClose: () => Ce(!1),
8078
8234
  watermarkText: je,
8079
8235
  setWatermarkText: Me
8080
8236
  }),
8081
- N && /* @__PURE__ */ F(Nt, { onClose: () => we(!1) })
8237
+ N && /* @__PURE__ */ F(K, { onClose: () => we(!1) })
8082
8238
  ]
8083
8239
  })
8084
8240
  });
8085
8241
  });
8086
8242
  //#endregion
8087
8243
  //#region src/core/createWebViewer.tsx
8088
- function Rn(e, t) {
8244
+ function Zn(e, t) {
8089
8245
  return typeof window > "u" || typeof document > "u" ? Promise.reject(/* @__PURE__ */ Error("[teamsync-pdf-viewer] createWebViewer() requires a browser environment.")) : t ? new Promise((n) => {
8090
8246
  let r = u.createRoot(t), { path: i, ...a } = e;
8091
- r.render(/* @__PURE__ */ F(Ln, {
8247
+ r.render(/* @__PURE__ */ F(Xn, {
8092
8248
  ...a,
8093
8249
  style: {
8094
8250
  width: "100%",
@@ -8100,8 +8256,8 @@ function Rn(e, t) {
8100
8256
  }));
8101
8257
  }) : Promise.reject(/* @__PURE__ */ Error("[teamsync-pdf-viewer] createWebViewer() needs a container element."));
8102
8258
  }
8103
- var zn = Rn;
8259
+ var Qn = Zn;
8104
8260
  //#endregion
8105
- export { An as AnnotationManager, Kt as MAX_EXPORT_BYTES, Ln as TeamSyncViewer, Pt as ViewerBus, zn as WebViewer, Mn as WebViewerInstance, Qt as XFDF_NS, yn as annotationToXfdfFragment, xn as annotationsToXfdf, Zt as buildPdfBytes, kt as computeCanvasPixelDiff, Tt as computePageDiffBoxes, Et as computeTextDiff, mt as configurePdfAssets, J as createGeometryResolver, q as createPageGeometry, Rn as createWebViewer, W as extractWordsFromPage, nn as fromPdfDate, Bt as fromPdfPoint, Rt as geometryFromPage, ht as getPdfAssetPaths, gt as isWorkerConfigured, ft as newAnnotationId, Dn as parseXfdf, yt as pdfjsVersion, Nn as printPdfBytes, Gt as quadPointsToRects, Y as rectFromPdf, Vt as rectToPdf, Wt as rectToQuadPoints, et as searchPdfText, Ot as tintCanvas, tn as toPdfDate, zt as toPdfPoint, tt as usePdfSearch };
8261
+ export { Gn as AnnotationManager, Tt as DEFAULT_FALLBACK_DIMS, cn as MAX_EXPORT_BYTES, dt as MAX_SCALE, ut as MIN_SCALE, Xn as TeamSyncViewer, Yt as ViewerBus, Qn as WebViewer, qn as WebViewerInstance, pn as XFDF_NS, Pn as annotationToXfdfFragment, In as annotationsToXfdf, Q as buildPdfBytes, gt as calculateNextZoomIn, _t as calculateNextZoomOut, bt as calculateScrollCompensation, vt as clampScale, Gt as computeCanvasPixelDiff, zt as computePageDiffBoxes, Dt as computeRowLayout, Ht as computeTextDiff, Ot as configurePdfAssets, $t as createGeometryResolver, Qt as createPageGeometry, Zn as createWebViewer, Et as estimatePageDimensions, Rt as extractWordsFromPage, vn as fromPdfDate, tn as fromPdfPoint, J as geometryFromPage, G as getPdfAssetPaths, U as hasDimensionMismatch, kt as isWorkerConfigured, Ct as newAnnotationId, Hn as parseXfdf, Mt as pdfjsVersion, Jn as printPdfBytes, on as quadPointsToRects, Y as rectFromPdf, nn as rectToPdf, an as rectToQuadPoints, tt as searchPdfText, Wt as tintCanvas, _n as toPdfDate, en as toPdfPoint, nt as usePdfSearch };
8106
8262
 
8107
8263
  //# sourceMappingURL=teamsync-pdf-viewer.js.map