teamsync-pdf-viewer 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/utils/zoomUtils.d.ts +32 -0
- package/dist/teamsync-pdf-viewer.js +764 -709
- package/dist/teamsync-pdf-viewer.js.map +1 -1
- package/package.json +1 -1
|
@@ -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
|
-
|
|
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,
|
|
576
|
+
function Ve({ icon: e, onClick: t, active: n = !1, disabled: r = !1, title: i }) {
|
|
575
577
|
return /* @__PURE__ */ F("button", {
|
|
576
|
-
title:
|
|
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
|
|
596
|
+
!n && !r && (e.currentTarget.style.backgroundColor = "var(--hover-bg)");
|
|
593
597
|
},
|
|
594
598
|
onMouseOut: (e) => {
|
|
595
|
-
n
|
|
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,
|
|
1027
|
-
function
|
|
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
|
-
|
|
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 =
|
|
1055
|
+
Je = Xe(), t(Je);
|
|
1052
1056
|
};
|
|
1053
|
-
return
|
|
1054
|
-
|
|
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 ||
|
|
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),
|
|
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),
|
|
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
|
|
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
|
|
1097
|
+
function et(e, t) {
|
|
1094
1098
|
if (!t) return !1;
|
|
1095
|
-
let n =
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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) => {
|
|
@@ -1672,7 +1676,7 @@ var rt = ({ pdfDoc: e, pageIndex: t, isActive: n, onClick: r, scale: a }) => {
|
|
|
1672
1676
|
})]
|
|
1673
1677
|
});
|
|
1674
1678
|
};
|
|
1675
|
-
function
|
|
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(
|
|
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
|
|
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
|
|
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
|
|
1954
|
+
function ct(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),
|
|
@@ -1971,99 +1975,147 @@ function st(e, t, n, r, i, a, o) {
|
|
|
1971
1975
|
height: r
|
|
1972
1976
|
};
|
|
1973
1977
|
}
|
|
1974
|
-
function
|
|
1978
|
+
function lt(e, t, n) {
|
|
1975
1979
|
let r = (e % 360 + 360) % 360;
|
|
1976
1980
|
if (r === 90) return `translate(${n}, 0) rotate(90)`;
|
|
1977
1981
|
if (r === 180) return `translate(${t}, ${n}) rotate(180)`;
|
|
1978
1982
|
if (r === 270) return `translate(0, ${t}) rotate(270)`;
|
|
1979
1983
|
}
|
|
1980
|
-
function
|
|
1984
|
+
function ut(e) {
|
|
1981
1985
|
return (e % 360 + 360) % 360;
|
|
1982
1986
|
}
|
|
1983
1987
|
//#endregion
|
|
1988
|
+
//#region src/utils/zoomUtils.ts
|
|
1989
|
+
var dt = .1, ft = 10, pt = () => typeof navigator < "u" && (/iPad|iPhone|iPod/.test(navigator.userAgent) || /^((?!chrome|android).)*safari/i.test(navigator.userAgent)), mt = 8192, ht = 4096, H = 16777216;
|
|
1990
|
+
function U(e, t = 10) {
|
|
1991
|
+
return Math.min(t, Math.round((e + (e < 2 ? .25 : e < 5 ? .5 : 1)) * 100) / 100);
|
|
1992
|
+
}
|
|
1993
|
+
function W(e, t = dt) {
|
|
1994
|
+
return Math.max(t, Math.round((e - (e <= 2 ? .25 : e <= 5 ? .5 : 1)) * 100) / 100);
|
|
1995
|
+
}
|
|
1996
|
+
function gt(e, t = dt, n = 10) {
|
|
1997
|
+
return Math.min(n, Math.max(t, Math.round(e * 100) / 100));
|
|
1998
|
+
}
|
|
1999
|
+
function _t(e, t, n, r, i = pt() ? ht : mt, a = H) {
|
|
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
|
+
//#endregion
|
|
1984
2004
|
//#region src/components/PageRenderer.tsx
|
|
1985
|
-
function
|
|
2005
|
+
function vt({ 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
2006
|
let E = s(oe);
|
|
1987
2007
|
E.current = oe;
|
|
1988
|
-
let D = s(null), O = s(null), k = s(null), se = s(null),
|
|
2008
|
+
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
2009
|
i(() => {
|
|
1990
|
-
|
|
1991
|
-
|
|
2010
|
+
A.current = !1;
|
|
2011
|
+
}, [n, t]), i(() => {
|
|
2012
|
+
let e = !1, i = null, o = async () => {
|
|
1992
2013
|
if (!(!D.current || !n)) {
|
|
1993
|
-
|
|
2014
|
+
if (k.current) {
|
|
2015
|
+
try {
|
|
2016
|
+
k.current.cancel();
|
|
2017
|
+
} catch {}
|
|
2018
|
+
k.current = null;
|
|
2019
|
+
}
|
|
1994
2020
|
try {
|
|
1995
2021
|
let i = await n.getPage(t);
|
|
1996
|
-
if (e)
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2022
|
+
if (e) {
|
|
2023
|
+
try {
|
|
2024
|
+
i.cleanup?.();
|
|
2025
|
+
} catch {}
|
|
2026
|
+
return;
|
|
2027
|
+
}
|
|
2028
|
+
se.current = i;
|
|
2029
|
+
let o = window.devicePixelRatio || 1, s = ut(i.rotate + a), c = i.getViewport({
|
|
2030
|
+
scale: 1,
|
|
2031
|
+
rotation: s
|
|
2032
|
+
}), l = _t(r, o, c.width, c.height), u = i.getViewport({
|
|
2033
|
+
scale: l,
|
|
2034
|
+
rotation: s
|
|
2035
|
+
}), d = document.createElement("canvas");
|
|
2036
|
+
d.width = Math.floor(u.width), d.height = Math.floor(u.height);
|
|
2037
|
+
let f = d.getContext("2d");
|
|
2038
|
+
if (!f || e) {
|
|
2039
|
+
d.width = 0, d.height = 0;
|
|
2040
|
+
return;
|
|
2041
|
+
}
|
|
2042
|
+
let p = i.render({
|
|
2043
|
+
canvasContext: f,
|
|
2044
|
+
canvas: d,
|
|
2045
|
+
viewport: u
|
|
2046
|
+
});
|
|
2047
|
+
if (k.current = p, await p.promise, k.current = null, T && T.length > 0) {
|
|
2048
|
+
f.save(), f.setTransform(1, 0, 0, 1, 0, 0);
|
|
2010
2049
|
let e = a % 180 == 0 ? m : h, n = a % 180 == 0 ? h : m;
|
|
2011
2050
|
for (let i of T) if (i.pageIndex === t) {
|
|
2012
|
-
let t =
|
|
2013
|
-
i.status === "applied" || i.status === void 0 ? (
|
|
2051
|
+
let t = ct(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;
|
|
2052
|
+
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
2053
|
}
|
|
2015
|
-
|
|
2054
|
+
f.restore();
|
|
2016
2055
|
}
|
|
2017
|
-
let
|
|
2056
|
+
let g = ie || (w ? {
|
|
2018
2057
|
text: w,
|
|
2019
2058
|
opacity: .15,
|
|
2020
2059
|
size: 24,
|
|
2021
2060
|
mode: "tiled",
|
|
2022
2061
|
color: "#000000"
|
|
2023
2062
|
} : void 0);
|
|
2024
|
-
if (
|
|
2025
|
-
|
|
2026
|
-
let e =
|
|
2027
|
-
|
|
2028
|
-
let
|
|
2029
|
-
if (t === "single")
|
|
2063
|
+
if (g && g.text) {
|
|
2064
|
+
f.save(), f.setTransform(1, 0, 0, 1, 0, 0);
|
|
2065
|
+
let e = g.opacity ?? .15, t = g.mode ?? "tiled", n = t === "single" ? 48 : 18, r = (g.size ?? n) * l, i = g.text;
|
|
2066
|
+
f.fillStyle = g.color ?? "#000000", f.globalAlpha = e, f.font = `600 ${r}px sans-serif`, f.textAlign = "center", f.textBaseline = "middle";
|
|
2067
|
+
let a = d.width, o = d.height;
|
|
2068
|
+
if (t === "single") f.translate(a / 2, o / 2), f.rotate(-Math.PI / 4), f.fillText(i, 0, 0);
|
|
2030
2069
|
else {
|
|
2031
|
-
let e =
|
|
2032
|
-
|
|
2070
|
+
let e = r * i.length * .8 + 100 * l, t = 180 * l, n = Math.sqrt(a * a + o * o);
|
|
2071
|
+
f.translate(a / 2, o / 2), f.rotate(-Math.PI / 4);
|
|
2033
2072
|
for (let r = -n; r < n; r += t) {
|
|
2034
|
-
let
|
|
2035
|
-
for (let t = -n; t < n; t += e)
|
|
2073
|
+
let a = Math.abs(r / t) % 2 * (e / 2);
|
|
2074
|
+
for (let t = -n; t < n; t += e) f.fillText(i, t + a, r);
|
|
2036
2075
|
}
|
|
2037
2076
|
}
|
|
2038
|
-
|
|
2077
|
+
f.restore();
|
|
2039
2078
|
}
|
|
2040
|
-
let
|
|
2041
|
-
if (
|
|
2042
|
-
|
|
2043
|
-
let e =
|
|
2044
|
-
e && e.drawImage(
|
|
2079
|
+
let _ = D.current;
|
|
2080
|
+
if (_ && !e) {
|
|
2081
|
+
_.width = d.width, _.height = d.height;
|
|
2082
|
+
let e = _.getContext("2d");
|
|
2083
|
+
e && e.drawImage(d, 0, 0), A.current = !0, E.current?.(t);
|
|
2045
2084
|
}
|
|
2085
|
+
d.width = 0, d.height = 0;
|
|
2046
2086
|
} catch (e) {
|
|
2047
2087
|
e?.name !== "RenderingCancelledException" && console.error(`Page ${t} render failed:`, e);
|
|
2088
|
+
} finally {
|
|
2089
|
+
if (se.current) {
|
|
2090
|
+
try {
|
|
2091
|
+
se.current.cleanup?.();
|
|
2092
|
+
} catch {}
|
|
2093
|
+
se.current = null;
|
|
2094
|
+
}
|
|
2048
2095
|
}
|
|
2049
2096
|
}
|
|
2050
|
-
},
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2097
|
+
}, s = A.current ? 150 : 0;
|
|
2098
|
+
return i = setTimeout(o, s), () => {
|
|
2099
|
+
if (e = !0, i && clearTimeout(i), k.current) {
|
|
2100
|
+
try {
|
|
2101
|
+
k.current.cancel();
|
|
2102
|
+
} catch {}
|
|
2103
|
+
k.current = null;
|
|
2104
|
+
}
|
|
2105
|
+
if (se.current) {
|
|
2106
|
+
try {
|
|
2107
|
+
se.current.cleanup?.();
|
|
2108
|
+
} catch {}
|
|
2109
|
+
se.current = null;
|
|
2110
|
+
}
|
|
2059
2111
|
};
|
|
2060
2112
|
}, [
|
|
2061
2113
|
t,
|
|
2062
2114
|
n,
|
|
2063
2115
|
r,
|
|
2064
2116
|
a,
|
|
2065
|
-
|
|
2066
|
-
|
|
2117
|
+
m,
|
|
2118
|
+
h,
|
|
2067
2119
|
ie,
|
|
2068
2120
|
w,
|
|
2069
2121
|
T
|
|
@@ -2084,7 +2136,7 @@ function ut({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2084
2136
|
return !0;
|
|
2085
2137
|
}));
|
|
2086
2138
|
}
|
|
2087
|
-
e ||
|
|
2139
|
+
e || le(r);
|
|
2088
2140
|
} catch {}
|
|
2089
2141
|
})(), () => {
|
|
2090
2142
|
e = !0;
|
|
@@ -2095,16 +2147,16 @@ function ut({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2095
2147
|
T
|
|
2096
2148
|
]), i(() => {
|
|
2097
2149
|
let e = O.current;
|
|
2098
|
-
!
|
|
2150
|
+
!ce || !e || (async () => {
|
|
2099
2151
|
try {
|
|
2100
2152
|
let r = await n.getPage(t), i = r.getViewport({
|
|
2101
2153
|
scale: 1,
|
|
2102
|
-
rotation:
|
|
2103
|
-
}), o =
|
|
2154
|
+
rotation: ut(r.rotate + a)
|
|
2155
|
+
}), o = ce;
|
|
2104
2156
|
if (T && T.length > 0) {
|
|
2105
2157
|
let e = T.filter((e) => e.pageIndex === t);
|
|
2106
2158
|
if (e.length > 0) {
|
|
2107
|
-
let t =
|
|
2159
|
+
let t = ce.items.filter((t) => {
|
|
2108
2160
|
if (!t.str || t.str.trim() === "") return !0;
|
|
2109
2161
|
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
2162
|
for (let t of e) {
|
|
@@ -2114,7 +2166,7 @@ function ut({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2114
2166
|
return !0;
|
|
2115
2167
|
});
|
|
2116
2168
|
o = {
|
|
2117
|
-
...
|
|
2169
|
+
...ce,
|
|
2118
2170
|
items: t
|
|
2119
2171
|
};
|
|
2120
2172
|
}
|
|
@@ -2129,13 +2181,13 @@ function ut({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2129
2181
|
}
|
|
2130
2182
|
})();
|
|
2131
2183
|
}, [
|
|
2132
|
-
|
|
2184
|
+
ce,
|
|
2133
2185
|
n,
|
|
2134
2186
|
t,
|
|
2135
2187
|
a,
|
|
2136
2188
|
T
|
|
2137
2189
|
]);
|
|
2138
|
-
let
|
|
2190
|
+
let fe = v.filter((e) => e.pageIndex === t);
|
|
2139
2191
|
return /* @__PURE__ */ I("div", {
|
|
2140
2192
|
id: `pdf-page-${t}`,
|
|
2141
2193
|
className: "pdf-page-container",
|
|
@@ -2146,8 +2198,8 @@ function ut({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2146
2198
|
position: "absolute",
|
|
2147
2199
|
top: `${f}px`,
|
|
2148
2200
|
left: p === void 0 ? "0px" : `${p}px`,
|
|
2149
|
-
width: `${
|
|
2150
|
-
height: `${
|
|
2201
|
+
width: `${ue}px`,
|
|
2202
|
+
height: `${de}px`,
|
|
2151
2203
|
backgroundColor: "#fff",
|
|
2152
2204
|
boxShadow: "0 2px 10px rgba(0,0,0,0.1)",
|
|
2153
2205
|
marginBottom: "16px"
|
|
@@ -2193,7 +2245,7 @@ function ut({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2193
2245
|
children: [
|
|
2194
2246
|
/* @__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
2247
|
b && b.pageIndex === t && b.bounds.map((e, t) => {
|
|
2196
|
-
let o =
|
|
2248
|
+
let o = ct(e.x, i - e.y - e.height, e.width, e.height, a, n, i);
|
|
2197
2249
|
return /* @__PURE__ */ F("div", { style: {
|
|
2198
2250
|
position: "absolute",
|
|
2199
2251
|
left: `${o.x * r}px`,
|
|
@@ -2207,7 +2259,7 @@ function ut({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2207
2259
|
} }, `search-${t}`);
|
|
2208
2260
|
}),
|
|
2209
2261
|
x && x.filter((e) => e.pageIndex === t).map((t, o) => /* @__PURE__ */ F(e.Fragment, { children: t.bounds.map((e, o) => {
|
|
2210
|
-
let s =
|
|
2262
|
+
let s = ct(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
2263
|
return /* @__PURE__ */ F("div", {
|
|
2212
2264
|
style: {
|
|
2213
2265
|
position: "absolute",
|
|
@@ -2248,7 +2300,7 @@ function ut({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2248
2300
|
});
|
|
2249
2301
|
})(),
|
|
2250
2302
|
(() => {
|
|
2251
|
-
let n =
|
|
2303
|
+
let n = lt(a, a % 180 == 0 ? m : h, a % 180 == 0 ? h : m);
|
|
2252
2304
|
return /* @__PURE__ */ F("svg", {
|
|
2253
2305
|
style: {
|
|
2254
2306
|
position: "absolute",
|
|
@@ -2267,7 +2319,7 @@ function ut({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2267
2319
|
onMouseLeave: (e) => C(e, t),
|
|
2268
2320
|
children: /* @__PURE__ */ F("g", {
|
|
2269
2321
|
transform: n,
|
|
2270
|
-
children: /* @__PURE__ */ I(e.Fragment, { children: [
|
|
2322
|
+
children: /* @__PURE__ */ I(e.Fragment, { children: [fe.map((t) => {
|
|
2271
2323
|
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
2324
|
"text",
|
|
2273
2325
|
"note",
|
|
@@ -2643,17 +2695,17 @@ function ut({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2643
2695
|
]
|
|
2644
2696
|
});
|
|
2645
2697
|
}
|
|
2646
|
-
var
|
|
2698
|
+
var yt = e.memo(vt, (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
2699
|
//#endregion
|
|
2648
2700
|
//#region src/annotations/ids.ts
|
|
2649
|
-
function
|
|
2701
|
+
function bt() {
|
|
2650
2702
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
2651
2703
|
let e = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
|
2652
2704
|
return `${e.slice(0, 8)}-${e.slice(8, 12)}-4${e.slice(13, 16)}-a${e.slice(17, 20)}-${e.slice(20, 32)}`;
|
|
2653
2705
|
}
|
|
2654
2706
|
//#endregion
|
|
2655
2707
|
//#region src/utils/findRegexRedactions.ts
|
|
2656
|
-
async function
|
|
2708
|
+
async function xt(e, t) {
|
|
2657
2709
|
let n = [];
|
|
2658
2710
|
if (!e || !t || t.length === 0) return n;
|
|
2659
2711
|
let r = e.numPages, i = t.map((e) => new RegExp(e, e.flags.includes("g") ? e.flags : e.flags + "g"));
|
|
@@ -2702,30 +2754,30 @@ async function pt(e, t) {
|
|
|
2702
2754
|
}
|
|
2703
2755
|
//#endregion
|
|
2704
2756
|
//#region src/core/pdfAssets.ts
|
|
2705
|
-
var
|
|
2706
|
-
function
|
|
2707
|
-
|
|
2708
|
-
...
|
|
2757
|
+
var G = {};
|
|
2758
|
+
function St(e) {
|
|
2759
|
+
G = {
|
|
2760
|
+
...G,
|
|
2709
2761
|
...e
|
|
2710
2762
|
}, e.workerSrc && (L.GlobalWorkerOptions.workerSrc = e.workerSrc);
|
|
2711
2763
|
}
|
|
2712
|
-
function
|
|
2713
|
-
return
|
|
2764
|
+
function Ct() {
|
|
2765
|
+
return G;
|
|
2714
2766
|
}
|
|
2715
|
-
function
|
|
2716
|
-
return !!(
|
|
2767
|
+
function wt() {
|
|
2768
|
+
return !!(G.workerSrc || L.GlobalWorkerOptions.workerSrc);
|
|
2717
2769
|
}
|
|
2718
|
-
function
|
|
2719
|
-
if (!
|
|
2770
|
+
function Tt() {
|
|
2771
|
+
if (!wt()) 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
2772
|
}
|
|
2721
|
-
function
|
|
2773
|
+
function Et() {
|
|
2722
2774
|
let e = {};
|
|
2723
|
-
return
|
|
2775
|
+
return G.cMapUrl && (e.cMapUrl = G.cMapUrl, e.cMapPacked = !0), G.standardFontDataUrl && (e.standardFontDataUrl = G.standardFontDataUrl), G.wasmUrl && (e.wasmUrl = G.wasmUrl), G.iccUrl && (e.iccUrl = G.iccUrl), e;
|
|
2724
2776
|
}
|
|
2725
|
-
var
|
|
2777
|
+
var Dt = L.version;
|
|
2726
2778
|
//#endregion
|
|
2727
2779
|
//#region src/components/DiffHighlightOverlay.tsx
|
|
2728
|
-
function
|
|
2780
|
+
function Ot({ boxes: e, scale: t, colorScheme: n = "all", selectedDiffId: r, onSelectDiff: i }) {
|
|
2729
2781
|
let [a, o] = c(null);
|
|
2730
2782
|
if (!e || e.length === 0) return null;
|
|
2731
2783
|
let s = e.filter((e) => n === "deletions" ? e.type === "deletion" || e.type === "modification" : n !== "additions" || e.type === "addition" || e.type === "modification");
|
|
@@ -2830,7 +2882,7 @@ function bt({ boxes: e, scale: t, colorScheme: n = "all", selectedDiffId: r, onS
|
|
|
2830
2882
|
}
|
|
2831
2883
|
//#endregion
|
|
2832
2884
|
//#region src/components/SideBySideViewer.tsx
|
|
2833
|
-
function
|
|
2885
|
+
function kt({ 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
2886
|
let y = s(null), b = s(null), x = s(!1);
|
|
2835
2887
|
i(() => {
|
|
2836
2888
|
let e = y.current, t = b.current;
|
|
@@ -2936,7 +2988,7 @@ function xt({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
|
|
|
2936
2988
|
height: `${re}px`,
|
|
2937
2989
|
boxShadow: "0 4px 12px rgba(0,0,0,0.15)"
|
|
2938
2990
|
},
|
|
2939
|
-
children: [e && /* @__PURE__ */ F(
|
|
2991
|
+
children: [e && /* @__PURE__ */ F(yt, {
|
|
2940
2992
|
pageNum: n,
|
|
2941
2993
|
pdfDoc: e,
|
|
2942
2994
|
scale: r,
|
|
@@ -2962,7 +3014,7 @@ function xt({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
|
|
|
2962
3014
|
watermark: f,
|
|
2963
3015
|
watermarkText: p,
|
|
2964
3016
|
redactions: m
|
|
2965
|
-
}), /* @__PURE__ */ F(
|
|
3017
|
+
}), /* @__PURE__ */ F(Ot, {
|
|
2966
3018
|
boxes: h,
|
|
2967
3019
|
scale: r,
|
|
2968
3020
|
colorScheme: "deletions",
|
|
@@ -3000,7 +3052,7 @@ function xt({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
|
|
|
3000
3052
|
height: `${w}px`,
|
|
3001
3053
|
boxShadow: "0 4px 12px rgba(0,0,0,0.15)"
|
|
3002
3054
|
},
|
|
3003
|
-
children: [t && /* @__PURE__ */ F(
|
|
3055
|
+
children: [t && /* @__PURE__ */ F(yt, {
|
|
3004
3056
|
pageNum: n,
|
|
3005
3057
|
pdfDoc: t,
|
|
3006
3058
|
scale: r,
|
|
@@ -3026,7 +3078,7 @@ function xt({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
|
|
|
3026
3078
|
watermark: f,
|
|
3027
3079
|
watermarkText: p,
|
|
3028
3080
|
redactions: m
|
|
3029
|
-
}), /* @__PURE__ */ F(
|
|
3081
|
+
}), /* @__PURE__ */ F(Ot, {
|
|
3030
3082
|
boxes: g,
|
|
3031
3083
|
scale: r,
|
|
3032
3084
|
colorScheme: "additions",
|
|
@@ -3039,7 +3091,7 @@ function xt({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
|
|
|
3039
3091
|
}
|
|
3040
3092
|
//#endregion
|
|
3041
3093
|
//#region src/components/CompareToolbar.tsx
|
|
3042
|
-
function
|
|
3094
|
+
function At({ compareState: e, onSetMode: t, onSetColors: n, onToggleCurtain: r, onPrevDiff: i, onNextDiff: a, onExit: o }) {
|
|
3043
3095
|
let { mode: s, colorA: c, colorB: l, showCurtain: u, diffItems: d, currentDiffIndex: f } = e;
|
|
3044
3096
|
return /* @__PURE__ */ I("div", {
|
|
3045
3097
|
style: {
|
|
@@ -3295,7 +3347,7 @@ function St({ compareState: e, onSetMode: t, onSetColors: n, onToggleCurtain: r,
|
|
|
3295
3347
|
}
|
|
3296
3348
|
//#endregion
|
|
3297
3349
|
//#region src/components/DiffSummarySidebar.tsx
|
|
3298
|
-
function
|
|
3350
|
+
function jt({ isOpen: e, diffItems: t, textDiffs: n, currentDiffIndex: r, onSelectDiff: i, onJumpToPage: a }) {
|
|
3299
3351
|
return e ? /* @__PURE__ */ I("div", {
|
|
3300
3352
|
style: {
|
|
3301
3353
|
width: "320px",
|
|
@@ -3526,7 +3578,7 @@ function Ct({ isOpen: e, diffItems: t, textDiffs: n, currentDiffIndex: r, onSele
|
|
|
3526
3578
|
}
|
|
3527
3579
|
//#endregion
|
|
3528
3580
|
//#region src/components/CompareCurtainSlider.tsx
|
|
3529
|
-
function
|
|
3581
|
+
function Mt({ positionPercent: e, onChangePosition: t, containerRef: n }) {
|
|
3530
3582
|
let [r, a] = c(!1), o = s(null);
|
|
3531
3583
|
return i(() => {
|
|
3532
3584
|
let e = (e) => {
|
|
@@ -3583,7 +3635,7 @@ function wt({ positionPercent: e, onChangePosition: t, containerRef: n }) {
|
|
|
3583
3635
|
}
|
|
3584
3636
|
//#endregion
|
|
3585
3637
|
//#region src/utils/pdfDiffEngine.ts
|
|
3586
|
-
async function
|
|
3638
|
+
async function Nt(e) {
|
|
3587
3639
|
let t = e.getViewport({
|
|
3588
3640
|
scale: 1,
|
|
3589
3641
|
rotation: e.rotate
|
|
@@ -3606,8 +3658,8 @@ async function W(e) {
|
|
|
3606
3658
|
}
|
|
3607
3659
|
return r;
|
|
3608
3660
|
}
|
|
3609
|
-
async function
|
|
3610
|
-
let [r, i] = await Promise.all([e.getPage(n), t.getPage(Math.min(n, t.numPages))]), [a, o] = await Promise.all([
|
|
3661
|
+
async function Pt(e, t, n) {
|
|
3662
|
+
let [r, i] = await Promise.all([e.getPage(n), t.getPage(Math.min(n, t.numPages))]), [a, o] = await Promise.all([Nt(r), Nt(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
3663
|
f[1] = 0;
|
|
3612
3664
|
let p = [];
|
|
3613
3665
|
for (let e = 0; e <= d; e++) {
|
|
@@ -3630,7 +3682,7 @@ async function Tt(e, t, n) {
|
|
|
3630
3682
|
e > 0 && (m === i ? (_.push(h - 1), h--) : h === a && (g.push(m - 1), m--));
|
|
3631
3683
|
}
|
|
3632
3684
|
g.reverse(), _.reverse();
|
|
3633
|
-
let v =
|
|
3685
|
+
let v = Ft(g.map((e) => a[e]), n, "deletion"), y = Ft(_.map((e) => o[e]), n, "addition"), b = [];
|
|
3634
3686
|
for (let e of v) b.push({
|
|
3635
3687
|
id: e.id,
|
|
3636
3688
|
pageIndex: n,
|
|
@@ -3657,16 +3709,16 @@ async function Tt(e, t, n) {
|
|
|
3657
3709
|
summary: b
|
|
3658
3710
|
};
|
|
3659
3711
|
}
|
|
3660
|
-
function
|
|
3712
|
+
function Ft(e, t, n) {
|
|
3661
3713
|
if (e.length === 0) return [];
|
|
3662
3714
|
let r = [], i = [e[0]];
|
|
3663
3715
|
for (let a = 1; a < e.length; a++) {
|
|
3664
3716
|
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(
|
|
3717
|
+
c && l ? i.push(s) : (r.push(It(i, t, n, r.length + 1)), i = [s]);
|
|
3666
3718
|
}
|
|
3667
|
-
return i.length > 0 && r.push(
|
|
3719
|
+
return i.length > 0 && r.push(It(i, t, n, r.length + 1)), r;
|
|
3668
3720
|
}
|
|
3669
|
-
function
|
|
3721
|
+
function It(e, t, n, r) {
|
|
3670
3722
|
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
3723
|
return {
|
|
3672
3724
|
id: `diff-box-${t}-${n}-${r}-${Math.round(i)}-${Math.round(a)}`,
|
|
@@ -3679,7 +3731,7 @@ function K(e, t, n, r) {
|
|
|
3679
3731
|
height: s - a + 2
|
|
3680
3732
|
};
|
|
3681
3733
|
}
|
|
3682
|
-
function
|
|
3734
|
+
function Lt(e, t, n) {
|
|
3683
3735
|
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
3736
|
c[1] = 0;
|
|
3685
3737
|
let l = [];
|
|
@@ -3690,7 +3742,7 @@ function Et(e, t, n) {
|
|
|
3690
3742
|
u = t === -e || t !== e && c[t - 1 + s] < c[t + 1 + s] ? c[t + 1 + s] : c[t - 1 + s] + 1;
|
|
3691
3743
|
let d = u - t;
|
|
3692
3744
|
for (; u < a && d < o && r[u] === i[d];) u++, d++;
|
|
3693
|
-
if (c[t + s] = u, u >= a && d >= o) return
|
|
3745
|
+
if (c[t + s] = u, u >= a && d >= o) return Rt(l, r, i, n);
|
|
3694
3746
|
}
|
|
3695
3747
|
}
|
|
3696
3748
|
return [{
|
|
@@ -3703,7 +3755,7 @@ function Et(e, t, n) {
|
|
|
3703
3755
|
pageIndex: n
|
|
3704
3756
|
}];
|
|
3705
3757
|
}
|
|
3706
|
-
function
|
|
3758
|
+
function Rt(e, t, n, r) {
|
|
3707
3759
|
let i = t.length, a = n.length, o = t.length + n.length, s = [];
|
|
3708
3760
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
3709
3761
|
let c = e[r], l = i - a, u;
|
|
@@ -3729,10 +3781,10 @@ function Dt(e, t, n, r) {
|
|
|
3729
3781
|
});
|
|
3730
3782
|
return c;
|
|
3731
3783
|
}
|
|
3732
|
-
function
|
|
3784
|
+
function K(e, t, n, r, i = .75) {
|
|
3733
3785
|
e.save(), e.globalCompositeOperation = "source-atop", e.fillStyle = r, e.globalAlpha = i, e.fillRect(0, 0, t, n), e.restore();
|
|
3734
3786
|
}
|
|
3735
|
-
function
|
|
3787
|
+
function zt(e, t, n, r) {
|
|
3736
3788
|
let i = Math.min(e.width, t.width), a = Math.min(e.height, t.height);
|
|
3737
3789
|
if (i === 0 || a === 0) return [];
|
|
3738
3790
|
let o = e.getContext("2d"), s = t.getContext("2d");
|
|
@@ -3759,8 +3811,8 @@ function kt(e, t, n, r) {
|
|
|
3759
3811
|
}
|
|
3760
3812
|
//#endregion
|
|
3761
3813
|
//#region src/components/DocumentViewer.tsx
|
|
3762
|
-
function
|
|
3763
|
-
let j = s(null), ye = Le(), [M, xe] = c(null), [Se, Ce] = c(null), [N, we] = c(1), [Te, Ee] = c([]), { getCommand: De } =
|
|
3814
|
+
function q({ 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 }) {
|
|
3815
|
+
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
3816
|
isActive: !1,
|
|
3765
3817
|
mode: "overlay",
|
|
3766
3818
|
colorA: "#e11d48",
|
|
@@ -3790,9 +3842,9 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
3790
3842
|
Be.current = g;
|
|
3791
3843
|
let Ve = n(async (e) => {
|
|
3792
3844
|
try {
|
|
3793
|
-
|
|
3845
|
+
Tt(), Be.current && St(Be.current);
|
|
3794
3846
|
let t = typeof e == "string" ? { url: e } : { data: e };
|
|
3795
|
-
h && (t.withCredentials = !0), Object.assign(t,
|
|
3847
|
+
h && (t.withCredentials = !0), Object.assign(t, Et());
|
|
3796
3848
|
let n = await L.getDocument(t).promise;
|
|
3797
3849
|
xe(n), ze.current.onDocumentLoaded?.(n, typeof e == "string" ? e : "documentA.pdf");
|
|
3798
3850
|
} catch (e) {
|
|
@@ -3800,9 +3852,9 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
3800
3852
|
}
|
|
3801
3853
|
}, [h]), V = n(async (e) => {
|
|
3802
3854
|
try {
|
|
3803
|
-
|
|
3855
|
+
Tt(), Be.current && St(Be.current);
|
|
3804
3856
|
let t = typeof e == "string" ? { url: e } : { data: e };
|
|
3805
|
-
h && (t.withCredentials = !0), Object.assign(t,
|
|
3857
|
+
h && (t.withCredentials = !0), Object.assign(t, Et());
|
|
3806
3858
|
let n = await L.getDocument(t).promise;
|
|
3807
3859
|
P(n), z((e) => ({
|
|
3808
3860
|
...e,
|
|
@@ -3825,7 +3877,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
3825
3877
|
try {
|
|
3826
3878
|
let t = Math.min(M.numPages, ke.numPages), n = [], r = {}, i = {};
|
|
3827
3879
|
for (let a = 1; a <= t; a++) {
|
|
3828
|
-
let { diffsA: t, diffsB: o, summary: s } = await
|
|
3880
|
+
let { diffsA: t, diffsB: o, summary: s } = await Pt(M, ke, a);
|
|
3829
3881
|
if (e) return;
|
|
3830
3882
|
r[a] = t, i[a] = o, n = n.concat(s);
|
|
3831
3883
|
}
|
|
@@ -3835,7 +3887,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
3835
3887
|
pageDiffsA: r,
|
|
3836
3888
|
pageDiffsB: i
|
|
3837
3889
|
}));
|
|
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 =
|
|
3890
|
+
let a = await M.getPage(N), o = await ke.getPage(Math.min(N, ke.numPages)), s = await a.getTextContent(), c = await o.getTextContent(), l = Lt(s.items.map((e) => e.str).join(" "), c.items.map((e) => e.str).join(" "), N);
|
|
3839
3891
|
e || Fe(l);
|
|
3840
3892
|
} catch (e) {
|
|
3841
3893
|
console.error("Error computing document diffs:", e);
|
|
@@ -3889,14 +3941,14 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
3889
3941
|
let [Ue, Ge] = c(null), [Ke, qe] = c([]), Je = Ke[0] ?? {
|
|
3890
3942
|
width: 800,
|
|
3891
3943
|
height: 1100
|
|
3892
|
-
},
|
|
3944
|
+
}, Ye = n((e) => Ke[e - 1] ?? Je, [
|
|
3893
3945
|
Ke,
|
|
3894
3946
|
Je.width,
|
|
3895
3947
|
Je.height
|
|
3896
|
-
]), [
|
|
3948
|
+
]), [Xe, Ze] = c({
|
|
3897
3949
|
top: 0,
|
|
3898
3950
|
left: 0
|
|
3899
|
-
}), [
|
|
3951
|
+
}), [$e, tt] = c(!1), it = s(null), ct = o(() => {
|
|
3900
3952
|
let e = [];
|
|
3901
3953
|
if (!M) return e;
|
|
3902
3954
|
if (se === "single") for (let t = 1; t <= M.numPages; t++) e.push([t]);
|
|
@@ -3906,8 +3958,8 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
3906
3958
|
for (let t = 2; t <= M.numPages; t += 2) e.push([t, t + 1].filter((e) => e <= M.numPages));
|
|
3907
3959
|
}
|
|
3908
3960
|
return e;
|
|
3909
|
-
}, [M, se]),
|
|
3910
|
-
let e =
|
|
3961
|
+
}, [M, se]), lt = o(() => {
|
|
3962
|
+
let e = ct.map((e) => Math.max(...e.map((e) => Ye(e).height)) * S + 16), t = [], n = 0;
|
|
3911
3963
|
for (let r of e) t.push(n), n += r;
|
|
3912
3964
|
return {
|
|
3913
3965
|
heights: e,
|
|
@@ -3915,11 +3967,11 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
3915
3967
|
total: n
|
|
3916
3968
|
};
|
|
3917
3969
|
}, [
|
|
3918
|
-
|
|
3970
|
+
ct,
|
|
3919
3971
|
S,
|
|
3920
|
-
|
|
3921
|
-
]),
|
|
3922
|
-
let t =
|
|
3972
|
+
Ye
|
|
3973
|
+
]), dt = n((e) => ct.findIndex((t) => t.includes(e)), [ct]), ft = n((e) => {
|
|
3974
|
+
let t = lt.tops;
|
|
3923
3975
|
if (t.length === 0) return 0;
|
|
3924
3976
|
let n = 0, r = t.length - 1;
|
|
3925
3977
|
for (; n < r;) {
|
|
@@ -3927,30 +3979,30 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
3927
3979
|
t[i] <= e ? n = i : r = i - 1;
|
|
3928
3980
|
}
|
|
3929
3981
|
return n;
|
|
3930
|
-
}, [
|
|
3982
|
+
}, [lt]), pt = n((e, t = {}) => {
|
|
3931
3983
|
let n = M ? Math.max(1, Math.min(e, M.numPages)) : Math.max(1, e);
|
|
3932
3984
|
we(n);
|
|
3933
|
-
let r =
|
|
3985
|
+
let r = dt(n);
|
|
3934
3986
|
r >= 0 && j.current && (t.smooth ? j.current.scrollTo({
|
|
3935
|
-
top:
|
|
3987
|
+
top: lt.tops[r],
|
|
3936
3988
|
behavior: "smooth"
|
|
3937
|
-
}) : j.current.scrollTop =
|
|
3989
|
+
}) : j.current.scrollTop = lt.tops[r]);
|
|
3938
3990
|
}, [
|
|
3939
3991
|
M,
|
|
3940
|
-
|
|
3941
|
-
|
|
3992
|
+
dt,
|
|
3993
|
+
lt
|
|
3942
3994
|
]);
|
|
3943
3995
|
i(() => {
|
|
3944
3996
|
let e = (e) => {
|
|
3945
|
-
e?.page &&
|
|
3997
|
+
e?.page && pt(e.page, { smooth: e.smooth ?? !0 });
|
|
3946
3998
|
}, t = ye.on("action-go-to-page", (t) => e(t)), n = (t) => e(t.detail);
|
|
3947
3999
|
return window.addEventListener("action-go-to-page", n), () => {
|
|
3948
4000
|
t(), window.removeEventListener("action-go-to-page", n);
|
|
3949
4001
|
};
|
|
3950
|
-
}, [ye,
|
|
3951
|
-
let
|
|
3952
|
-
we(e.pageIndex), Ge(e),
|
|
3953
|
-
},
|
|
4002
|
+
}, [ye, pt]);
|
|
4003
|
+
let mt = (e) => {
|
|
4004
|
+
we(e.pageIndex), Ge(e), pt(e.pageIndex);
|
|
4005
|
+
}, ht = n((e, t) => {
|
|
3954
4006
|
let n = t || R.diffItems[e];
|
|
3955
4007
|
if (z((t) => ({
|
|
3956
4008
|
...t,
|
|
@@ -3959,7 +4011,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
3959
4011
|
n.pageIndex && n.pageIndex !== N && we(n.pageIndex);
|
|
3960
4012
|
let r = (n.y ?? 0) * S, i = (n.x ?? 0) * S;
|
|
3961
4013
|
if (j.current) {
|
|
3962
|
-
let e = n.pageIndex || N, t =
|
|
4014
|
+
let e = n.pageIndex || N, t = dt(e), a = O === "continuous" && t >= 0 ? lt.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
4015
|
j.current.scrollTo({
|
|
3964
4016
|
top: c,
|
|
3965
4017
|
left: l,
|
|
@@ -3971,51 +4023,51 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
3971
4023
|
N,
|
|
3972
4024
|
S,
|
|
3973
4025
|
O,
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
]),
|
|
4026
|
+
dt,
|
|
4027
|
+
lt.tops
|
|
4028
|
+
]), H = l(u.subscribe, u.getSnapshot, u.getSnapshot), [U, W] = c("pan");
|
|
3977
4029
|
i(() => {
|
|
3978
|
-
a === "Annotate" ? (
|
|
4030
|
+
a === "Annotate" ? (W("highlight"), vt("#fbc02d"), Dt(.5), Ct(16)) : a === "Shapes" ? (W("rectangle"), Dt(1), Ct(2)) : a === "Fill and Sign" ? W("signature") : a === "View" && W("pan");
|
|
3979
4031
|
}, [a]), i(() => {
|
|
3980
|
-
ye.emit("action-tool-changed", { tool:
|
|
3981
|
-
}, [
|
|
3982
|
-
let [
|
|
4032
|
+
ye.emit("action-tool-changed", { tool: U });
|
|
4033
|
+
}, [U, ye]);
|
|
4034
|
+
let [_t, vt] = c("#d32f2f"), [G, Ct] = c(2), [wt, Dt] = c(.8), [Nt, Ft] = c(!1), [It, Rt] = c(null), [K, zt] = c({
|
|
3983
4035
|
x: 0,
|
|
3984
4036
|
y: 0
|
|
3985
|
-
}), [
|
|
4037
|
+
}), [q, Vt] = c({
|
|
3986
4038
|
x: 0,
|
|
3987
4039
|
y: 0
|
|
3988
|
-
}), [
|
|
3989
|
-
Re("action-set-tool", (e) =>
|
|
3990
|
-
let
|
|
4040
|
+
}), [Ht, Ut] = c([]), [J, Wt] = c(null), [Gt, Kt] = c(""), qt = s(null), [Y, X] = c(null), [Jt, Z] = c(null), [Yt, Xt] = c(!1), Zt = s(!1), Qt = s(null);
|
|
4041
|
+
Re("action-set-tool", (e) => W(e?.tool ?? null));
|
|
4042
|
+
let $t = s({
|
|
3991
4043
|
vx: null,
|
|
3992
4044
|
vy: null
|
|
3993
|
-
}),
|
|
4045
|
+
}), en = s(S);
|
|
3994
4046
|
i(() => {
|
|
3995
|
-
if (
|
|
3996
|
-
let e =
|
|
3997
|
-
|
|
4047
|
+
if (en.current !== S) {
|
|
4048
|
+
let e = en.current, t = S;
|
|
4049
|
+
en.current = S;
|
|
3998
4050
|
let n = j.current;
|
|
3999
4051
|
if (n) {
|
|
4000
4052
|
let r = n.clientWidth, i = n.clientHeight, a = r / 2, o = i / 2;
|
|
4001
|
-
|
|
4053
|
+
$t.current.vx !== null && $t.current.vy !== null && (a = $t.current.vx, o = $t.current.vy, $t.current = {
|
|
4002
4054
|
vx: null,
|
|
4003
4055
|
vy: null
|
|
4004
4056
|
});
|
|
4005
|
-
let s = a + n.scrollLeft, c = o + n.scrollTop, l =
|
|
4057
|
+
let s = a + n.scrollLeft, c = o + n.scrollTop, l = Ye(N).width, u = Math.max(0, r / 2 - l * e / 2);
|
|
4006
4058
|
n.scrollLeft = Math.max(0, r / 2 - l * t / 2) + (s - u) * (t / e) - a, n.scrollTop = t / e * c - o;
|
|
4007
4059
|
}
|
|
4008
4060
|
}
|
|
4009
4061
|
}, [S]), i(() => {
|
|
4010
4062
|
let e = j.current;
|
|
4011
|
-
if (!e
|
|
4063
|
+
if (!e) return;
|
|
4012
4064
|
let t = (t) => {
|
|
4013
4065
|
if (t.metaKey || t.ctrlKey) {
|
|
4014
4066
|
t.preventDefault();
|
|
4015
4067
|
let n = e.getBoundingClientRect(), r = t.clientX, i = t.clientY, a = Math.exp(-t.deltaY * .002);
|
|
4016
4068
|
C((e) => {
|
|
4017
|
-
let t =
|
|
4018
|
-
return t !== e && (
|
|
4069
|
+
let t = gt(e * a);
|
|
4070
|
+
return t !== e && ($t.current = {
|
|
4019
4071
|
vx: r - n.left,
|
|
4020
4072
|
vy: i - n.top
|
|
4021
4073
|
}), t;
|
|
@@ -4028,50 +4080,50 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4028
4080
|
u.commit(e);
|
|
4029
4081
|
}, [u]);
|
|
4030
4082
|
Re("action-commit-digital-signature-local", (e) => {
|
|
4031
|
-
e?.tempAnn && Q([...
|
|
4083
|
+
e?.tempAnn && Q([...H, e.tempAnn]);
|
|
4032
4084
|
});
|
|
4033
|
-
let
|
|
4085
|
+
let tn = n(() => {
|
|
4034
4086
|
u.undo();
|
|
4035
|
-
}, [u]),
|
|
4087
|
+
}, [u]), nn = n(() => {
|
|
4036
4088
|
u.redo();
|
|
4037
4089
|
}, [u]);
|
|
4038
4090
|
Re("viewer-keydown", (e) => {
|
|
4039
4091
|
let t = document.activeElement?.tagName === "TEXTAREA" || document.activeElement?.tagName === "INPUT";
|
|
4040
|
-
if (
|
|
4092
|
+
if (et(e, De("ROTATE_CW"))) {
|
|
4041
4093
|
e.preventDefault(), le((e) => (e + 90) % 360);
|
|
4042
4094
|
return;
|
|
4043
4095
|
}
|
|
4044
|
-
if (
|
|
4096
|
+
if (et(e, De("ROTATE_CCW"))) {
|
|
4045
4097
|
e.preventDefault(), le((e) => (e - 90) % 360);
|
|
4046
4098
|
return;
|
|
4047
4099
|
}
|
|
4048
|
-
if (
|
|
4049
|
-
e.preventDefault(),
|
|
4100
|
+
if (et(e, De("UNDO"))) {
|
|
4101
|
+
e.preventDefault(), tn();
|
|
4050
4102
|
return;
|
|
4051
4103
|
}
|
|
4052
|
-
if (
|
|
4053
|
-
e.preventDefault(),
|
|
4104
|
+
if (et(e, De("REDO"))) {
|
|
4105
|
+
e.preventDefault(), nn();
|
|
4054
4106
|
return;
|
|
4055
4107
|
}
|
|
4056
|
-
if (
|
|
4108
|
+
if (et(e, De("SEARCH"))) {
|
|
4057
4109
|
e.preventDefault(), ye.emit("action-open-search");
|
|
4058
4110
|
return;
|
|
4059
4111
|
}
|
|
4060
|
-
if (
|
|
4112
|
+
if (et(e, De("FILE_PICKER"))) {
|
|
4061
4113
|
e.preventDefault(), ye.emit("action-open-file-picker");
|
|
4062
4114
|
return;
|
|
4063
4115
|
}
|
|
4064
|
-
if (!t && !
|
|
4065
|
-
if (
|
|
4066
|
-
let t =
|
|
4067
|
-
t && (e.preventDefault(),
|
|
4116
|
+
if (!t && !J) {
|
|
4117
|
+
if (et(e, De("COPY")) && Y) {
|
|
4118
|
+
let t = H.find((e) => e.id === Y);
|
|
4119
|
+
t && (e.preventDefault(), Qt.current = t);
|
|
4068
4120
|
return;
|
|
4069
4121
|
}
|
|
4070
|
-
if (
|
|
4122
|
+
if (et(e, De("PASTE")) && Qt.current) {
|
|
4071
4123
|
e.preventDefault();
|
|
4072
|
-
let t =
|
|
4124
|
+
let t = Qt.current, n = {
|
|
4073
4125
|
...t,
|
|
4074
|
-
id:
|
|
4126
|
+
id: bt(),
|
|
4075
4127
|
pageIndex: N,
|
|
4076
4128
|
x: t.x + 20,
|
|
4077
4129
|
y: t.y + 20,
|
|
@@ -4082,63 +4134,63 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4082
4134
|
readOnly: void 0,
|
|
4083
4135
|
xfdfExtras: void 0
|
|
4084
4136
|
};
|
|
4085
|
-
Q([...
|
|
4137
|
+
Q([...H, n]), X(n.id);
|
|
4086
4138
|
return;
|
|
4087
4139
|
}
|
|
4088
|
-
if (
|
|
4089
|
-
e.preventDefault(), Q(
|
|
4140
|
+
if (et(e, De("DELETE")) && Y) {
|
|
4141
|
+
e.preventDefault(), Q(H.filter((e) => e.id !== Y)), X(null);
|
|
4090
4142
|
return;
|
|
4091
4143
|
}
|
|
4092
4144
|
}
|
|
4093
4145
|
}), i(() => {
|
|
4094
|
-
|
|
4095
|
-
|
|
4146
|
+
J && qt.current && setTimeout(() => {
|
|
4147
|
+
qt.current?.focus();
|
|
4096
4148
|
}, 10);
|
|
4097
|
-
}, [
|
|
4098
|
-
ie && ie(
|
|
4099
|
-
}, [
|
|
4100
|
-
let [
|
|
4149
|
+
}, [J]), i(() => {
|
|
4150
|
+
ie && ie(H);
|
|
4151
|
+
}, [H, ie]);
|
|
4152
|
+
let [rn, an] = c([]);
|
|
4101
4153
|
i(() => {
|
|
4102
4154
|
if (M && x && x.length > 0) {
|
|
4103
4155
|
let e = !1;
|
|
4104
|
-
return
|
|
4105
|
-
e ||
|
|
4156
|
+
return xt(M, x).then((t) => {
|
|
4157
|
+
e || an(t);
|
|
4106
4158
|
}), () => {
|
|
4107
4159
|
e = !0;
|
|
4108
4160
|
};
|
|
4109
4161
|
}
|
|
4110
|
-
|
|
4162
|
+
an([]);
|
|
4111
4163
|
}, [M, x]);
|
|
4112
|
-
let [
|
|
4164
|
+
let [on, sn] = c(!1), cn = o(() => [
|
|
4113
4165
|
...v || [],
|
|
4114
|
-
...
|
|
4166
|
+
...rn,
|
|
4115
4167
|
...Te
|
|
4116
4168
|
], [
|
|
4117
4169
|
v,
|
|
4118
|
-
|
|
4170
|
+
rn,
|
|
4119
4171
|
Te
|
|
4120
4172
|
]);
|
|
4121
4173
|
i(() => {
|
|
4122
|
-
ze.current.onRedactionsChange?.(
|
|
4123
|
-
}, [
|
|
4124
|
-
let
|
|
4125
|
-
Ee((e) => e.filter((e) => e.status === "applied")),
|
|
4126
|
-
}, []),
|
|
4127
|
-
Ee((t) => t.filter((t) => t !== e && t.id !== e.id)),
|
|
4128
|
-
}, []), { search:
|
|
4174
|
+
ze.current.onRedactionsChange?.(cn);
|
|
4175
|
+
}, [cn]);
|
|
4176
|
+
let ln = o(() => cn.filter((e) => e.status === "pending").length, [cn]), un = n(() => {
|
|
4177
|
+
Ee((e) => e.filter((e) => e.status === "applied")), an((e) => e.filter((e) => e.status === "applied"));
|
|
4178
|
+
}, []), dn = n((e) => {
|
|
4179
|
+
Ee((t) => t.filter((t) => t !== e && t.id !== e.id)), an((t) => t.filter((t) => t !== e && t.id !== e.id));
|
|
4180
|
+
}, []), { search: fn, searchResults: pn, isSearching: mn, searchProgress: $ } = nt(M, cn);
|
|
4129
4181
|
i(() => {
|
|
4130
|
-
|
|
4131
|
-
}, [
|
|
4132
|
-
let
|
|
4182
|
+
pn.length === 0 && Ge(null);
|
|
4183
|
+
}, [pn]);
|
|
4184
|
+
let hn = s(!1);
|
|
4133
4185
|
i(() => {
|
|
4134
|
-
if (xe(null), Ce(null), we(1), qe([]),
|
|
4186
|
+
if (xe(null), Ce(null), we(1), qe([]), hn.current = !1, !d) return;
|
|
4135
4187
|
let e = d, t = !1, n = null;
|
|
4136
4188
|
return (async () => {
|
|
4137
4189
|
try {
|
|
4138
|
-
Be.current &&
|
|
4190
|
+
Be.current && St(Be.current), Tt(), n = L.getDocument({
|
|
4139
4191
|
url: e,
|
|
4140
4192
|
withCredentials: h,
|
|
4141
|
-
...
|
|
4193
|
+
...Et()
|
|
4142
4194
|
});
|
|
4143
4195
|
let r = await n.promise;
|
|
4144
4196
|
if (t) return;
|
|
@@ -4159,26 +4211,26 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4159
4211
|
p,
|
|
4160
4212
|
h
|
|
4161
4213
|
]);
|
|
4162
|
-
let
|
|
4163
|
-
|
|
4214
|
+
let gn = n((e) => {
|
|
4215
|
+
hn.current || (hn.current = !0, ze.current.onFirstPageRendered?.(e));
|
|
4164
4216
|
}, []);
|
|
4165
4217
|
i(() => {
|
|
4166
4218
|
M && ze.current.onPageChange?.(N, M.numPages);
|
|
4167
4219
|
}, [N, M]);
|
|
4168
|
-
let
|
|
4220
|
+
let _n = s(null), vn = s(void 0);
|
|
4169
4221
|
i(() => {
|
|
4170
4222
|
let e = me ?? pe;
|
|
4171
|
-
if (!M || !e ||
|
|
4172
|
-
let t =
|
|
4173
|
-
|
|
4174
|
-
let n = setTimeout(() =>
|
|
4223
|
+
if (!M || !e || _n.current === M && vn.current === e || Ke.length < Math.min(e, M.numPages)) return;
|
|
4224
|
+
let t = _n.current !== M;
|
|
4225
|
+
_n.current = M, vn.current = e;
|
|
4226
|
+
let n = setTimeout(() => pt(e, { smooth: !t }), 50);
|
|
4175
4227
|
return () => clearTimeout(n);
|
|
4176
4228
|
}, [
|
|
4177
4229
|
M,
|
|
4178
4230
|
me,
|
|
4179
4231
|
pe,
|
|
4180
4232
|
Ke.length,
|
|
4181
|
-
|
|
4233
|
+
pt
|
|
4182
4234
|
]), i(() => {
|
|
4183
4235
|
if (!M) return;
|
|
4184
4236
|
let e = !1, t = M;
|
|
@@ -4194,7 +4246,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4194
4246
|
if (e) return;
|
|
4195
4247
|
let a = i.getViewport({
|
|
4196
4248
|
scale: 1,
|
|
4197
|
-
rotation:
|
|
4249
|
+
rotation: ut(i.rotate + A)
|
|
4198
4250
|
});
|
|
4199
4251
|
n.push({
|
|
4200
4252
|
width: a.width,
|
|
@@ -4206,8 +4258,8 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4206
4258
|
e = !0;
|
|
4207
4259
|
};
|
|
4208
4260
|
}, [M, A]);
|
|
4209
|
-
let
|
|
4210
|
-
let e =
|
|
4261
|
+
let yn = n(() => {
|
|
4262
|
+
let e = Ye(N);
|
|
4211
4263
|
if (!j.current || !e.width) return;
|
|
4212
4264
|
let t = j.current.clientWidth - 48;
|
|
4213
4265
|
if (t > 0 && e.width > 0) {
|
|
@@ -4215,11 +4267,11 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4215
4267
|
C(Math.max(.1, Math.min(32, parseFloat(n.toFixed(2)))));
|
|
4216
4268
|
}
|
|
4217
4269
|
}, [
|
|
4218
|
-
|
|
4270
|
+
Ye,
|
|
4219
4271
|
N,
|
|
4220
4272
|
C
|
|
4221
|
-
]),
|
|
4222
|
-
let e =
|
|
4273
|
+
]), bn = n(() => {
|
|
4274
|
+
let e = Ye(N);
|
|
4223
4275
|
if (!j.current || !e.width || !e.height) return;
|
|
4224
4276
|
let t = j.current.clientWidth - 48, n = j.current.clientHeight - 48;
|
|
4225
4277
|
if (t > 0 && n > 0 && e.width > 0 && e.height > 0) {
|
|
@@ -4227,85 +4279,85 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4227
4279
|
C(Math.max(.1, Math.min(32, parseFloat(Math.min(r, i).toFixed(2)))));
|
|
4228
4280
|
}
|
|
4229
4281
|
}, [
|
|
4230
|
-
|
|
4282
|
+
Ye,
|
|
4231
4283
|
N,
|
|
4232
4284
|
C
|
|
4233
4285
|
]);
|
|
4234
|
-
Re("action-fit-to-width", () =>
|
|
4235
|
-
let
|
|
4236
|
-
let n = e.currentTarget.getBoundingClientRect(), r = (e.clientX - n.left) / S, i = (e.clientY - n.top) / S, a =
|
|
4237
|
-
return
|
|
4238
|
-
},
|
|
4239
|
-
if (!
|
|
4240
|
-
let { x: n, y: r } =
|
|
4241
|
-
if (
|
|
4286
|
+
Re("action-fit-to-width", () => yn()), Re("action-fit-to-page", () => bn());
|
|
4287
|
+
let xn = (e, t) => {
|
|
4288
|
+
let n = e.currentTarget.getBoundingClientRect(), r = (e.clientX - n.left) / S, i = (e.clientY - n.top) / S, a = Ye(t);
|
|
4289
|
+
return ot(r, i, A, A % 180 == 0 ? a.width : a.height, A % 180 == 0 ? a.height : a.width);
|
|
4290
|
+
}, Sn = (e, t) => {
|
|
4291
|
+
if (!U) return;
|
|
4292
|
+
let { x: n, y: r } = xn(e, t);
|
|
4293
|
+
if (U === "text" || U === "note") {
|
|
4242
4294
|
e.preventDefault();
|
|
4243
4295
|
return;
|
|
4244
4296
|
}
|
|
4245
|
-
if (
|
|
4297
|
+
if (U === "eraser") {
|
|
4246
4298
|
Ft(!0);
|
|
4247
4299
|
return;
|
|
4248
4300
|
}
|
|
4249
|
-
|
|
4301
|
+
zt({
|
|
4250
4302
|
x: n,
|
|
4251
4303
|
y: r
|
|
4252
|
-
}),
|
|
4304
|
+
}), Vt({
|
|
4253
4305
|
x: n,
|
|
4254
4306
|
y: r
|
|
4255
|
-
}),
|
|
4307
|
+
}), U === "freehand" ? (Ft(!0), Ut([{
|
|
4256
4308
|
x: n,
|
|
4257
4309
|
y: r
|
|
4258
|
-
}]),
|
|
4310
|
+
}]), Rt(t)) : ([
|
|
4259
4311
|
"rectangle",
|
|
4260
4312
|
"ellipse",
|
|
4261
4313
|
"line",
|
|
4262
4314
|
"arrow",
|
|
4263
4315
|
"highlight",
|
|
4264
4316
|
"redaction"
|
|
4265
|
-
].includes(
|
|
4266
|
-
},
|
|
4267
|
-
if (
|
|
4268
|
-
if (
|
|
4317
|
+
].includes(U) || ["callout", "link"].includes(U)) && (Ft(!0), Rt(t));
|
|
4318
|
+
}, Cn = () => {
|
|
4319
|
+
if (J && Gt.trim()) {
|
|
4320
|
+
if (J.annId) Q(H.map((e) => e.id === J.annId ? {
|
|
4269
4321
|
...e,
|
|
4270
|
-
text:
|
|
4322
|
+
text: Gt
|
|
4271
4323
|
} : e));
|
|
4272
4324
|
else {
|
|
4273
|
-
let e =
|
|
4274
|
-
Q([...
|
|
4325
|
+
let e = bt();
|
|
4326
|
+
Q([...H, {
|
|
4275
4327
|
id: e,
|
|
4276
|
-
type:
|
|
4277
|
-
pageIndex:
|
|
4278
|
-
x:
|
|
4279
|
-
y:
|
|
4280
|
-
width: Math.max(100,
|
|
4328
|
+
type: J.type,
|
|
4329
|
+
pageIndex: J.pageIndex,
|
|
4330
|
+
x: J.x,
|
|
4331
|
+
y: J.y,
|
|
4332
|
+
width: Math.max(100, Gt.length * 8 + 20),
|
|
4281
4333
|
height: 30,
|
|
4282
|
-
text:
|
|
4283
|
-
points:
|
|
4284
|
-
color:
|
|
4285
|
-
strokeWidth:
|
|
4286
|
-
opacity:
|
|
4334
|
+
text: Gt,
|
|
4335
|
+
points: J.points,
|
|
4336
|
+
color: _t,
|
|
4337
|
+
strokeWidth: G,
|
|
4338
|
+
opacity: wt
|
|
4287
4339
|
}]);
|
|
4288
4340
|
}
|
|
4289
4341
|
}
|
|
4290
|
-
|
|
4291
|
-
},
|
|
4292
|
-
if (!
|
|
4293
|
-
let { x: n, y: r } =
|
|
4294
|
-
|
|
4342
|
+
Wt(null), Kt(""), U === "text" && W(null);
|
|
4343
|
+
}, wn = (e, t) => {
|
|
4344
|
+
if (!Nt) return;
|
|
4345
|
+
let { x: n, y: r } = xn(e, t);
|
|
4346
|
+
Vt({
|
|
4295
4347
|
x: n,
|
|
4296
4348
|
y: r
|
|
4297
|
-
}),
|
|
4349
|
+
}), U === "freehand" && Ut((e) => [...e, {
|
|
4298
4350
|
x: n,
|
|
4299
4351
|
y: r
|
|
4300
4352
|
}]);
|
|
4301
|
-
},
|
|
4302
|
-
if (
|
|
4303
|
-
let { x: n, y: r } =
|
|
4304
|
-
if (
|
|
4305
|
-
let e = Math.abs(
|
|
4353
|
+
}, Tn = (e, t) => {
|
|
4354
|
+
if (U === "text" || U === "note" || U === "digital_signature" || U === "link") {
|
|
4355
|
+
let { x: n, y: r } = xn(e, t);
|
|
4356
|
+
if (U === "link") {
|
|
4357
|
+
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
4358
|
(e < 5 || i < 5) && (a = n, o = r, e = 120, i = 35);
|
|
4307
|
-
let s =
|
|
4308
|
-
Q([...
|
|
4359
|
+
let s = bt();
|
|
4360
|
+
Q([...H, {
|
|
4309
4361
|
id: s,
|
|
4310
4362
|
type: "link",
|
|
4311
4363
|
pageIndex: t,
|
|
@@ -4318,53 +4370,53 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4318
4370
|
strokeWidth: 0,
|
|
4319
4371
|
opacity: 1,
|
|
4320
4372
|
text: ""
|
|
4321
|
-
}]), Ft(!1),
|
|
4373
|
+
}]), Ft(!1), Rt(null), Zt.current = !0, X(s), Xt(!0), W(null);
|
|
4322
4374
|
return;
|
|
4323
4375
|
}
|
|
4324
|
-
(
|
|
4376
|
+
(U === "text" || U === "note") && (J && Cn(), Wt({
|
|
4325
4377
|
x: n,
|
|
4326
4378
|
y: r,
|
|
4327
|
-
type:
|
|
4379
|
+
type: U,
|
|
4328
4380
|
pageIndex: t
|
|
4329
|
-
}),
|
|
4381
|
+
}), Kt(""));
|
|
4330
4382
|
return;
|
|
4331
4383
|
}
|
|
4332
|
-
if (
|
|
4333
|
-
if (
|
|
4334
|
-
if (
|
|
4335
|
-
let e =
|
|
4336
|
-
Q([...
|
|
4337
|
-
id:
|
|
4338
|
-
type:
|
|
4384
|
+
if (Nt && (Ft(!1), Rt(null), U)) {
|
|
4385
|
+
if (U === "freehand") {
|
|
4386
|
+
if (Ht.length > 2) {
|
|
4387
|
+
let e = Ht.map((e) => e.x), n = Ht.map((e) => e.y), r = Math.min(...e), i = Math.max(...e), a = Math.min(...n), o = Math.max(...n);
|
|
4388
|
+
Q([...H, {
|
|
4389
|
+
id: bt(),
|
|
4390
|
+
type: U,
|
|
4339
4391
|
pageIndex: t,
|
|
4340
4392
|
x: r,
|
|
4341
4393
|
y: a,
|
|
4342
4394
|
width: i - r,
|
|
4343
4395
|
height: o - a,
|
|
4344
|
-
points: [...
|
|
4345
|
-
strokes: [[...
|
|
4346
|
-
color:
|
|
4347
|
-
strokeWidth:
|
|
4348
|
-
opacity:
|
|
4396
|
+
points: [...Ht],
|
|
4397
|
+
strokes: [[...Ht]],
|
|
4398
|
+
color: _t,
|
|
4399
|
+
strokeWidth: G,
|
|
4400
|
+
opacity: wt
|
|
4349
4401
|
}]);
|
|
4350
4402
|
}
|
|
4351
|
-
|
|
4403
|
+
Ut([]);
|
|
4352
4404
|
} else {
|
|
4353
|
-
let e = Math.abs(
|
|
4405
|
+
let e = Math.abs(q.x - K.x), n = Math.abs(q.y - K.y);
|
|
4354
4406
|
if (e > 5 || n > 5) {
|
|
4355
|
-
let r = Math.min(
|
|
4356
|
-
if ((
|
|
4407
|
+
let r = Math.min(K.x, q.x), i = Math.min(K.y, q.y), a = U === "line" || U === "arrow" || U === "callout" ? [K, q] : void 0;
|
|
4408
|
+
if ((U === "highlight" || U === "redaction") && n < 18 && (n = Math.max(18, n), i = K.y - 9), U === "callout") {
|
|
4357
4409
|
if (ve?.canAddAnnotations === !1) return;
|
|
4358
|
-
|
|
4359
|
-
x:
|
|
4360
|
-
y:
|
|
4410
|
+
Wt({
|
|
4411
|
+
x: q.x,
|
|
4412
|
+
y: q.y,
|
|
4361
4413
|
type: "callout",
|
|
4362
4414
|
points: a,
|
|
4363
4415
|
pageIndex: t
|
|
4364
|
-
}),
|
|
4416
|
+
}), Kt("");
|
|
4365
4417
|
return;
|
|
4366
4418
|
}
|
|
4367
|
-
if (
|
|
4419
|
+
if (U === "redaction") {
|
|
4368
4420
|
if (ve?.canRedact === !1) return;
|
|
4369
4421
|
Ee((a) => [...a, {
|
|
4370
4422
|
id: `manual-${Date.now()}-${Math.random().toString(36).substr(2, 6)}`,
|
|
@@ -4378,34 +4430,34 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4378
4430
|
return;
|
|
4379
4431
|
}
|
|
4380
4432
|
if (ve?.canAddAnnotations === !1) return;
|
|
4381
|
-
Q([...
|
|
4382
|
-
id:
|
|
4383
|
-
type:
|
|
4433
|
+
Q([...H, {
|
|
4434
|
+
id: bt(),
|
|
4435
|
+
type: U,
|
|
4384
4436
|
pageIndex: t,
|
|
4385
4437
|
x: r,
|
|
4386
4438
|
y: i,
|
|
4387
4439
|
width: e,
|
|
4388
4440
|
height: n,
|
|
4389
4441
|
points: a,
|
|
4390
|
-
color:
|
|
4391
|
-
strokeWidth:
|
|
4392
|
-
opacity:
|
|
4442
|
+
color: _t,
|
|
4443
|
+
strokeWidth: G,
|
|
4444
|
+
opacity: wt
|
|
4393
4445
|
}]);
|
|
4394
4446
|
}
|
|
4395
4447
|
}
|
|
4396
4448
|
}
|
|
4397
|
-
},
|
|
4398
|
-
|
|
4399
|
-
},
|
|
4400
|
-
if (t.stopPropagation(),
|
|
4449
|
+
}, En = (e) => {
|
|
4450
|
+
U === "eraser" && Nt && Q(H.filter((t) => t.id !== e));
|
|
4451
|
+
}, Dn = (e, t) => {
|
|
4452
|
+
if (t.stopPropagation(), U === "eraser") {
|
|
4401
4453
|
if (ve?.canDeleteAnnotations === !1) return;
|
|
4402
|
-
Q(
|
|
4403
|
-
} else if (
|
|
4404
|
-
let n =
|
|
4454
|
+
Q(H.filter((t) => t.id !== e)), Y === e && (X(null), Z(null));
|
|
4455
|
+
} else if (U === null || U === "pan") {
|
|
4456
|
+
let n = H.find((t) => t.id === e);
|
|
4405
4457
|
if (n && n.linkUrl && a === "View") {
|
|
4406
4458
|
if (n.linkUrl.startsWith("#page=")) {
|
|
4407
4459
|
let e = parseInt(n.linkUrl.split("=")[1]);
|
|
4408
|
-
|
|
4460
|
+
pt(e);
|
|
4409
4461
|
} else {
|
|
4410
4462
|
let e = n.linkUrl;
|
|
4411
4463
|
/^https?:\/\//i.test(e) || (e = "https://" + e);
|
|
@@ -4416,45 +4468,45 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4416
4468
|
}
|
|
4417
4469
|
if (n && (n.type === "note" || n.type === "callout" || n.type === "text")) {
|
|
4418
4470
|
if (ve?.canEditAnnotations === !1 || !u.canEdit(n)) {
|
|
4419
|
-
|
|
4471
|
+
X(e);
|
|
4420
4472
|
return;
|
|
4421
4473
|
}
|
|
4422
|
-
|
|
4474
|
+
Wt({
|
|
4423
4475
|
x: n.x,
|
|
4424
4476
|
y: n.y,
|
|
4425
4477
|
type: n.type,
|
|
4426
4478
|
annId: n.id,
|
|
4427
4479
|
points: n.points,
|
|
4428
4480
|
pageIndex: n.pageIndex
|
|
4429
|
-
}),
|
|
4481
|
+
}), Kt(n.text || ""), n.color && vt(n.color);
|
|
4430
4482
|
} else if (n && n.type === "link") {
|
|
4431
4483
|
if (ve?.canEditAnnotations === !1 || !u.canEdit(n)) {
|
|
4432
|
-
|
|
4484
|
+
X(e);
|
|
4433
4485
|
return;
|
|
4434
4486
|
}
|
|
4435
|
-
|
|
4487
|
+
Xt(!0);
|
|
4436
4488
|
}
|
|
4437
|
-
|
|
4489
|
+
X(e);
|
|
4438
4490
|
let r = j.current, i = r?.getBoundingClientRect();
|
|
4439
|
-
i && r &&
|
|
4491
|
+
i && r && Z({
|
|
4440
4492
|
top: t.clientY - i.top + r.scrollTop,
|
|
4441
4493
|
left: t.clientX - i.left + r.scrollLeft
|
|
4442
4494
|
});
|
|
4443
4495
|
}
|
|
4444
|
-
},
|
|
4496
|
+
}, On = s(0);
|
|
4445
4497
|
return i(() => {
|
|
4446
4498
|
if (M && j.current && O === "continuous") {
|
|
4447
|
-
let e =
|
|
4499
|
+
let e = Xe.top + j.current.clientHeight / 2, t = Math.max(0, Math.min(ct.length - 1, ft(e))), n = ct[t] ? ct[t][0] : 1;
|
|
4448
4500
|
n !== N && we(n);
|
|
4449
4501
|
}
|
|
4450
4502
|
}, [
|
|
4451
|
-
|
|
4503
|
+
Xe.top,
|
|
4452
4504
|
S,
|
|
4453
4505
|
M,
|
|
4454
4506
|
N,
|
|
4455
|
-
|
|
4507
|
+
ft,
|
|
4456
4508
|
O,
|
|
4457
|
-
|
|
4509
|
+
ct
|
|
4458
4510
|
]), /* @__PURE__ */ I("div", {
|
|
4459
4511
|
style: {
|
|
4460
4512
|
flex: 1,
|
|
@@ -4464,11 +4516,11 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4464
4516
|
overflow: "hidden"
|
|
4465
4517
|
},
|
|
4466
4518
|
children: [
|
|
4467
|
-
_ && /* @__PURE__ */ F(
|
|
4519
|
+
_ && /* @__PURE__ */ F(at, {
|
|
4468
4520
|
isOpen: t,
|
|
4469
4521
|
pdfDoc: M,
|
|
4470
4522
|
pageNum: N,
|
|
4471
|
-
setPageNum: (e) =>
|
|
4523
|
+
setPageNum: (e) => pt(e)
|
|
4472
4524
|
}),
|
|
4473
4525
|
/* @__PURE__ */ I("div", {
|
|
4474
4526
|
style: {
|
|
@@ -4481,7 +4533,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4481
4533
|
overflow: "hidden"
|
|
4482
4534
|
},
|
|
4483
4535
|
children: [
|
|
4484
|
-
R.isActive && /* @__PURE__ */ F(
|
|
4536
|
+
R.isActive && /* @__PURE__ */ F(At, {
|
|
4485
4537
|
compareState: R,
|
|
4486
4538
|
onSetMode: (e) => z((t) => ({
|
|
4487
4539
|
...t,
|
|
@@ -4499,12 +4551,12 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4499
4551
|
onPrevDiff: () => {
|
|
4500
4552
|
if (R.diffItems.length === 0) return;
|
|
4501
4553
|
let e = (R.currentDiffIndex - 1 + R.diffItems.length) % R.diffItems.length;
|
|
4502
|
-
|
|
4554
|
+
ht(e);
|
|
4503
4555
|
},
|
|
4504
4556
|
onNextDiff: () => {
|
|
4505
4557
|
if (R.diffItems.length === 0) return;
|
|
4506
4558
|
let e = (R.currentDiffIndex + 1) % R.diffItems.length;
|
|
4507
|
-
|
|
4559
|
+
ht(e);
|
|
4508
4560
|
},
|
|
4509
4561
|
onExit: () => {
|
|
4510
4562
|
z((e) => ({
|
|
@@ -4524,35 +4576,35 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4524
4576
|
height: "40px"
|
|
4525
4577
|
},
|
|
4526
4578
|
children: [
|
|
4527
|
-
/* @__PURE__ */ F(
|
|
4579
|
+
/* @__PURE__ */ F(Bt, {
|
|
4528
4580
|
icon: /* @__PURE__ */ F(k, { size: 16 }),
|
|
4529
|
-
active:
|
|
4581
|
+
active: U === "highlight",
|
|
4530
4582
|
onClick: () => {
|
|
4531
|
-
|
|
4583
|
+
W("highlight"), vt("#fbc02d"), Dt(.5), Ct(16);
|
|
4532
4584
|
},
|
|
4533
4585
|
label: "Text Highlight"
|
|
4534
4586
|
}),
|
|
4535
|
-
/* @__PURE__ */ F(
|
|
4587
|
+
/* @__PURE__ */ F(Bt, {
|
|
4536
4588
|
icon: /* @__PURE__ */ F(m, { size: 16 }),
|
|
4537
|
-
active:
|
|
4589
|
+
active: U === "freehand",
|
|
4538
4590
|
onClick: () => {
|
|
4539
|
-
|
|
4591
|
+
W("freehand"), vt("#000000"), Dt(1), Ct(2);
|
|
4540
4592
|
},
|
|
4541
4593
|
label: "Marker"
|
|
4542
4594
|
}),
|
|
4543
|
-
/* @__PURE__ */ F(
|
|
4595
|
+
/* @__PURE__ */ F(Bt, {
|
|
4544
4596
|
icon: /* @__PURE__ */ F(Me, { size: 16 }),
|
|
4545
|
-
active:
|
|
4597
|
+
active: U === "text",
|
|
4546
4598
|
onClick: () => {
|
|
4547
|
-
|
|
4599
|
+
W("text"), vt("#000000"), Dt(1);
|
|
4548
4600
|
},
|
|
4549
4601
|
label: "Text"
|
|
4550
4602
|
}),
|
|
4551
|
-
ve?.canRedact !== !1 && /* @__PURE__ */ F(
|
|
4603
|
+
ve?.canRedact !== !1 && /* @__PURE__ */ F(Bt, {
|
|
4552
4604
|
icon: /* @__PURE__ */ F(w, { size: 16 }),
|
|
4553
|
-
active:
|
|
4605
|
+
active: U === "redaction",
|
|
4554
4606
|
onClick: () => {
|
|
4555
|
-
|
|
4607
|
+
W("redaction"), vt("#000000"), Dt(1);
|
|
4556
4608
|
},
|
|
4557
4609
|
label: "Redact"
|
|
4558
4610
|
}),
|
|
@@ -4569,11 +4621,11 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4569
4621
|
borderRight: "1px solid var(--border-color)",
|
|
4570
4622
|
paddingRight: "8px"
|
|
4571
4623
|
},
|
|
4572
|
-
children: /* @__PURE__ */ F(
|
|
4624
|
+
children: /* @__PURE__ */ F(Bt, {
|
|
4573
4625
|
icon: /* @__PURE__ */ F(he, { size: 16 }),
|
|
4574
|
-
active:
|
|
4626
|
+
active: U === "callout",
|
|
4575
4627
|
onClick: () => {
|
|
4576
|
-
|
|
4628
|
+
W("callout"), Dt(1), Ct(2);
|
|
4577
4629
|
},
|
|
4578
4630
|
label: "Callout"
|
|
4579
4631
|
})
|
|
@@ -4583,17 +4635,17 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4583
4635
|
display: "flex",
|
|
4584
4636
|
gap: "4px"
|
|
4585
4637
|
},
|
|
4586
|
-
children: [/* @__PURE__ */ F(
|
|
4638
|
+
children: [/* @__PURE__ */ F(Bt, {
|
|
4587
4639
|
icon: /* @__PURE__ */ F(be, { size: 16 }),
|
|
4588
|
-
active:
|
|
4640
|
+
active: U === "freehand" && wt === 1,
|
|
4589
4641
|
onClick: () => {
|
|
4590
|
-
|
|
4642
|
+
W("freehand"), Dt(1), Ct(2);
|
|
4591
4643
|
},
|
|
4592
4644
|
label: "Freehand"
|
|
4593
|
-
}), ve?.canDeleteAnnotations !== !1 && /* @__PURE__ */ F(
|
|
4645
|
+
}), ve?.canDeleteAnnotations !== !1 && /* @__PURE__ */ F(Bt, {
|
|
4594
4646
|
icon: /* @__PURE__ */ F(re, { size: 16 }),
|
|
4595
|
-
active:
|
|
4596
|
-
onClick: () =>
|
|
4647
|
+
active: U === "eraser",
|
|
4648
|
+
onClick: () => W("eraser"),
|
|
4597
4649
|
label: "Eraser"
|
|
4598
4650
|
})]
|
|
4599
4651
|
}),
|
|
@@ -4609,34 +4661,34 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4609
4661
|
gap: "4px"
|
|
4610
4662
|
},
|
|
4611
4663
|
children: [
|
|
4612
|
-
/* @__PURE__ */ F(
|
|
4664
|
+
/* @__PURE__ */ F(Bt, {
|
|
4613
4665
|
icon: /* @__PURE__ */ F(ge, { size: 16 }),
|
|
4614
|
-
active:
|
|
4615
|
-
onClick: () =>
|
|
4666
|
+
active: U === "line",
|
|
4667
|
+
onClick: () => W("line"),
|
|
4616
4668
|
label: "Line"
|
|
4617
4669
|
}),
|
|
4618
|
-
/* @__PURE__ */ F(
|
|
4670
|
+
/* @__PURE__ */ F(Bt, {
|
|
4619
4671
|
icon: /* @__PURE__ */ F(f, { size: 16 }),
|
|
4620
|
-
active:
|
|
4621
|
-
onClick: () =>
|
|
4672
|
+
active: U === "arrow",
|
|
4673
|
+
onClick: () => W("arrow"),
|
|
4622
4674
|
label: "Arrow"
|
|
4623
4675
|
}),
|
|
4624
|
-
/* @__PURE__ */ F(
|
|
4676
|
+
/* @__PURE__ */ F(Bt, {
|
|
4625
4677
|
icon: /* @__PURE__ */ F(Ae, { size: 16 }),
|
|
4626
|
-
active:
|
|
4627
|
-
onClick: () =>
|
|
4678
|
+
active: U === "rectangle",
|
|
4679
|
+
onClick: () => W("rectangle"),
|
|
4628
4680
|
label: "Rectangle"
|
|
4629
4681
|
}),
|
|
4630
|
-
/* @__PURE__ */ F(
|
|
4682
|
+
/* @__PURE__ */ F(Bt, {
|
|
4631
4683
|
icon: /* @__PURE__ */ F(ee, { size: 16 }),
|
|
4632
|
-
active:
|
|
4633
|
-
onClick: () =>
|
|
4684
|
+
active: U === "ellipse",
|
|
4685
|
+
onClick: () => W("ellipse"),
|
|
4634
4686
|
label: "Ellipse"
|
|
4635
4687
|
}),
|
|
4636
|
-
/* @__PURE__ */ F(
|
|
4688
|
+
/* @__PURE__ */ F(Bt, {
|
|
4637
4689
|
icon: /* @__PURE__ */ F(ce, { size: 16 }),
|
|
4638
|
-
active:
|
|
4639
|
-
onClick: () =>
|
|
4690
|
+
active: U === "link",
|
|
4691
|
+
onClick: () => W("link"),
|
|
4640
4692
|
label: "Link"
|
|
4641
4693
|
})
|
|
4642
4694
|
]
|
|
@@ -4656,7 +4708,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4656
4708
|
"ellipse",
|
|
4657
4709
|
"freehand",
|
|
4658
4710
|
"highlight"
|
|
4659
|
-
].includes(
|
|
4711
|
+
].includes(U || "") && /* @__PURE__ */ I("div", {
|
|
4660
4712
|
style: {
|
|
4661
4713
|
display: "flex",
|
|
4662
4714
|
alignItems: "center",
|
|
@@ -4670,16 +4722,16 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4670
4722
|
color: "#666",
|
|
4671
4723
|
minWidth: "85px"
|
|
4672
4724
|
},
|
|
4673
|
-
children: ["Thickness: ", /* @__PURE__ */ I("strong", { children: [
|
|
4725
|
+
children: ["Thickness: ", /* @__PURE__ */ I("strong", { children: [G, "px"] })]
|
|
4674
4726
|
}), /* @__PURE__ */ F("input", {
|
|
4675
4727
|
type: "range",
|
|
4676
4728
|
min: "1",
|
|
4677
4729
|
max: "24",
|
|
4678
|
-
value: Math.min(24, Math.max(1,
|
|
4730
|
+
value: Math.min(24, Math.max(1, G)),
|
|
4679
4731
|
onMouseDown: (e) => e.stopPropagation(),
|
|
4680
4732
|
onChange: (e) => {
|
|
4681
4733
|
let t = parseInt(e.target.value, 10);
|
|
4682
|
-
|
|
4734
|
+
Ct(t), Y && !J && Q(H.map((e) => e.id === Y ? {
|
|
4683
4735
|
...e,
|
|
4684
4736
|
strokeWidth: t
|
|
4685
4737
|
} : e));
|
|
@@ -4706,7 +4758,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4706
4758
|
].map((e) => /* @__PURE__ */ F("button", {
|
|
4707
4759
|
onMouseDown: (e) => e.preventDefault(),
|
|
4708
4760
|
onClick: () => {
|
|
4709
|
-
|
|
4761
|
+
vt(e), Y && !J && Q(H.map((t) => t.id === Y ? {
|
|
4710
4762
|
...t,
|
|
4711
4763
|
color: e
|
|
4712
4764
|
} : t));
|
|
@@ -4716,14 +4768,14 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4716
4768
|
height: "18px",
|
|
4717
4769
|
borderRadius: "50%",
|
|
4718
4770
|
backgroundColor: e,
|
|
4719
|
-
border:
|
|
4771
|
+
border: _t === e ? "2px solid #000" : "1px solid transparent",
|
|
4720
4772
|
cursor: "pointer",
|
|
4721
4773
|
outline: "none",
|
|
4722
4774
|
padding: 0
|
|
4723
4775
|
}
|
|
4724
4776
|
}, e))
|
|
4725
4777
|
}),
|
|
4726
|
-
|
|
4778
|
+
ln > 0 && /* @__PURE__ */ I("div", {
|
|
4727
4779
|
style: {
|
|
4728
4780
|
display: "flex",
|
|
4729
4781
|
alignItems: "center",
|
|
@@ -4731,7 +4783,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4731
4783
|
marginLeft: "8px"
|
|
4732
4784
|
},
|
|
4733
4785
|
children: [/* @__PURE__ */ I("button", {
|
|
4734
|
-
onClick: () =>
|
|
4786
|
+
onClick: () => sn(!0),
|
|
4735
4787
|
style: {
|
|
4736
4788
|
display: "flex",
|
|
4737
4789
|
alignItems: "center",
|
|
@@ -4750,11 +4802,11 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4750
4802
|
children: [
|
|
4751
4803
|
/* @__PURE__ */ F(Oe, { size: 16 }),
|
|
4752
4804
|
"Apply Redactions (",
|
|
4753
|
-
|
|
4805
|
+
ln,
|
|
4754
4806
|
")"
|
|
4755
4807
|
]
|
|
4756
4808
|
}), /* @__PURE__ */ I("button", {
|
|
4757
|
-
onClick:
|
|
4809
|
+
onClick: un,
|
|
4758
4810
|
style: {
|
|
4759
4811
|
display: "flex",
|
|
4760
4812
|
alignItems: "center",
|
|
@@ -4779,7 +4831,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4779
4831
|
})
|
|
4780
4832
|
]
|
|
4781
4833
|
}),
|
|
4782
|
-
|
|
4834
|
+
on && /* @__PURE__ */ F("div", {
|
|
4783
4835
|
style: {
|
|
4784
4836
|
position: "fixed",
|
|
4785
4837
|
top: 0,
|
|
@@ -4847,7 +4899,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4847
4899
|
},
|
|
4848
4900
|
children: [
|
|
4849
4901
|
"You are about to permanently apply ",
|
|
4850
|
-
/* @__PURE__ */ I("strong", { children: [
|
|
4902
|
+
/* @__PURE__ */ I("strong", { children: [ln, " redaction(s)"] }),
|
|
4851
4903
|
". Marked areas will be blacked out and underlying text will be permanently removed. This action cannot be undone."
|
|
4852
4904
|
]
|
|
4853
4905
|
}),
|
|
@@ -4859,7 +4911,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4859
4911
|
},
|
|
4860
4912
|
children: [
|
|
4861
4913
|
/* @__PURE__ */ F("button", {
|
|
4862
|
-
onClick: () =>
|
|
4914
|
+
onClick: () => sn(!1),
|
|
4863
4915
|
style: {
|
|
4864
4916
|
padding: "8px 14px",
|
|
4865
4917
|
borderRadius: "6px",
|
|
@@ -4874,7 +4926,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4874
4926
|
}),
|
|
4875
4927
|
/* @__PURE__ */ F("button", {
|
|
4876
4928
|
onClick: () => {
|
|
4877
|
-
|
|
4929
|
+
un(), sn(!1);
|
|
4878
4930
|
},
|
|
4879
4931
|
style: {
|
|
4880
4932
|
padding: "8px 14px",
|
|
@@ -4893,10 +4945,10 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4893
4945
|
Ee((e) => e.map((e) => ({
|
|
4894
4946
|
...e,
|
|
4895
4947
|
status: "applied"
|
|
4896
|
-
}))),
|
|
4948
|
+
}))), an((e) => e.map((e) => ({
|
|
4897
4949
|
...e,
|
|
4898
4950
|
status: "applied"
|
|
4899
|
-
}))),
|
|
4951
|
+
}))), sn(!1);
|
|
4900
4952
|
},
|
|
4901
4953
|
style: {
|
|
4902
4954
|
padding: "8px 14px",
|
|
@@ -4927,28 +4979,28 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4927
4979
|
overflow: "hidden",
|
|
4928
4980
|
position: "relative"
|
|
4929
4981
|
},
|
|
4930
|
-
children: [R.isActive && R.mode === "side-by-side" ? /* @__PURE__ */ F(
|
|
4982
|
+
children: [R.isActive && R.mode === "side-by-side" ? /* @__PURE__ */ F(kt, {
|
|
4931
4983
|
pdfDocA: M,
|
|
4932
4984
|
pdfDocB: ke,
|
|
4933
4985
|
pageNum: N,
|
|
4934
4986
|
scale: S,
|
|
4935
4987
|
rotation: A,
|
|
4936
|
-
basePageDims:
|
|
4988
|
+
basePageDims: Ye(N),
|
|
4937
4989
|
activeTab: a,
|
|
4938
|
-
activeTool:
|
|
4939
|
-
annotations:
|
|
4990
|
+
activeTool: U,
|
|
4991
|
+
annotations: H,
|
|
4940
4992
|
permissions: ve,
|
|
4941
4993
|
watermark: ue,
|
|
4942
4994
|
watermarkText: de,
|
|
4943
|
-
redactions:
|
|
4995
|
+
redactions: cn,
|
|
4944
4996
|
diffsA: R.pageDiffsA?.[N] || [],
|
|
4945
4997
|
diffsB: R.pageDiffsB?.[N] || [],
|
|
4946
4998
|
selectedDiffId: R.diffItems[R.currentDiffIndex]?.id,
|
|
4947
4999
|
onSelectDiff: (e) => {
|
|
4948
5000
|
let t = R.diffItems.findIndex((t) => t.id === e);
|
|
4949
|
-
t !== -1 &&
|
|
5001
|
+
t !== -1 && ht(t);
|
|
4950
5002
|
}
|
|
4951
|
-
}) : /* @__PURE__ */ I(Ne, { children: [
|
|
5003
|
+
}) : /* @__PURE__ */ I(Ne, { children: [U === "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
5004
|
className: "pdf-viewer-area",
|
|
4953
5005
|
style: {
|
|
4954
5006
|
flex: 1,
|
|
@@ -4959,28 +5011,28 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4959
5011
|
overflow: "hidden",
|
|
4960
5012
|
position: "relative",
|
|
4961
5013
|
backgroundColor: "var(--bg-color)",
|
|
4962
|
-
cursor:
|
|
5014
|
+
cursor: $e ? "grabbing" : U === "pan" || U === null ? "grab" : U === "eraser" ? "cell" : "crosshair"
|
|
4963
5015
|
},
|
|
4964
5016
|
onMouseMove: (e) => {
|
|
4965
|
-
if (
|
|
4966
|
-
let t = e.clientX -
|
|
4967
|
-
j.current.scrollLeft =
|
|
5017
|
+
if ($e && it.current && j.current) {
|
|
5018
|
+
let t = e.clientX - it.current.x, n = e.clientY - it.current.y;
|
|
5019
|
+
j.current.scrollLeft = it.current.scrollLeft - t, j.current.scrollTop = it.current.scrollTop - n;
|
|
4968
5020
|
}
|
|
4969
5021
|
},
|
|
4970
5022
|
onMouseLeave: () => {
|
|
4971
|
-
|
|
5023
|
+
$e && (tt(!1), it.current = null);
|
|
4972
5024
|
},
|
|
4973
5025
|
children: [
|
|
4974
5026
|
/* @__PURE__ */ F("div", {
|
|
4975
5027
|
ref: j,
|
|
4976
5028
|
onScroll: (e) => {
|
|
4977
|
-
|
|
5029
|
+
Ze({
|
|
4978
5030
|
top: e.currentTarget.scrollTop,
|
|
4979
5031
|
left: e.currentTarget.scrollLeft
|
|
4980
|
-
}),
|
|
5032
|
+
}), On.current = ft(e.currentTarget.scrollTop);
|
|
4981
5033
|
},
|
|
4982
5034
|
onMouseDown: (e) => {
|
|
4983
|
-
(
|
|
5035
|
+
(U === "pan" || U === null) && e.button === 0 && (tt(!0), it.current = {
|
|
4984
5036
|
x: e.clientX,
|
|
4985
5037
|
y: e.clientY,
|
|
4986
5038
|
scrollLeft: e.currentTarget.scrollLeft,
|
|
@@ -4988,7 +5040,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4988
5040
|
});
|
|
4989
5041
|
},
|
|
4990
5042
|
onMouseUp: (e) => {
|
|
4991
|
-
|
|
5043
|
+
$e && (tt(!1), it.current = null);
|
|
4992
5044
|
},
|
|
4993
5045
|
onContextMenu: (e) => {
|
|
4994
5046
|
e.preventDefault(), e.stopPropagation();
|
|
@@ -5001,10 +5053,13 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5001
5053
|
},
|
|
5002
5054
|
children: (() => {
|
|
5003
5055
|
let t = (t, n, r) => {
|
|
5004
|
-
let i = r ?
|
|
5005
|
-
if (r && j.current
|
|
5006
|
-
|
|
5007
|
-
if (
|
|
5056
|
+
let i = r ? lt.tops[n] ?? 0 : 0;
|
|
5057
|
+
if (r && j.current) {
|
|
5058
|
+
let e = S >= 4 ? 1 : S >= 2 ? 2 : 4, t = S >= 4 ? 1 : S >= 2 ? 2 : 5;
|
|
5059
|
+
if (n < On.current - e || n > On.current + t) return null;
|
|
5060
|
+
}
|
|
5061
|
+
let o = Nt && It && U && U !== "eraser" ? (() => {
|
|
5062
|
+
if (U === "freehand") return {
|
|
5008
5063
|
id: "temp-live-drawing",
|
|
5009
5064
|
type: "freehand",
|
|
5010
5065
|
pageIndex: It,
|
|
@@ -5012,14 +5067,14 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5012
5067
|
y: 0,
|
|
5013
5068
|
width: 0,
|
|
5014
5069
|
height: 0,
|
|
5015
|
-
points:
|
|
5016
|
-
color:
|
|
5017
|
-
strokeWidth:
|
|
5018
|
-
opacity:
|
|
5070
|
+
points: Ht,
|
|
5071
|
+
color: _t,
|
|
5072
|
+
strokeWidth: G,
|
|
5073
|
+
opacity: wt
|
|
5019
5074
|
};
|
|
5020
|
-
if (
|
|
5021
|
-
let e = Math.abs(
|
|
5022
|
-
return t < 18 && (t = Math.max(18, t), r =
|
|
5075
|
+
if (U === "highlight") {
|
|
5076
|
+
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);
|
|
5077
|
+
return t < 18 && (t = Math.max(18, t), r = K.y - 9), {
|
|
5023
5078
|
id: "temp-live-drawing",
|
|
5024
5079
|
type: "highlight",
|
|
5025
5080
|
pageIndex: It,
|
|
@@ -5027,14 +5082,14 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5027
5082
|
y: r,
|
|
5028
5083
|
width: e,
|
|
5029
5084
|
height: t,
|
|
5030
|
-
color:
|
|
5031
|
-
strokeWidth:
|
|
5032
|
-
opacity:
|
|
5085
|
+
color: _t,
|
|
5086
|
+
strokeWidth: G,
|
|
5087
|
+
opacity: wt
|
|
5033
5088
|
};
|
|
5034
5089
|
}
|
|
5035
|
-
if (
|
|
5036
|
-
let e = Math.abs(
|
|
5037
|
-
return t < 18 && (t = Math.max(18, t), r =
|
|
5090
|
+
if (U === "redaction") {
|
|
5091
|
+
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);
|
|
5092
|
+
return t < 18 && (t = Math.max(18, t), r = K.y - 9), {
|
|
5038
5093
|
id: "temp-live-drawing",
|
|
5039
5094
|
type: "rectangle",
|
|
5040
5095
|
pageIndex: It,
|
|
@@ -5054,64 +5109,64 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5054
5109
|
"rectangle",
|
|
5055
5110
|
"ellipse",
|
|
5056
5111
|
"link"
|
|
5057
|
-
].includes(
|
|
5058
|
-
let e = Math.abs(
|
|
5112
|
+
].includes(U)) {
|
|
5113
|
+
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
5114
|
return {
|
|
5060
5115
|
id: "temp-live-drawing",
|
|
5061
|
-
type:
|
|
5116
|
+
type: U,
|
|
5062
5117
|
pageIndex: It,
|
|
5063
5118
|
x: n,
|
|
5064
5119
|
y: r,
|
|
5065
5120
|
width: e,
|
|
5066
5121
|
height: t,
|
|
5067
|
-
points:
|
|
5068
|
-
color:
|
|
5069
|
-
strokeWidth:
|
|
5070
|
-
opacity:
|
|
5122
|
+
points: U === "line" || U === "arrow" || U === "callout" ? [K, q] : void 0,
|
|
5123
|
+
color: _t,
|
|
5124
|
+
strokeWidth: G,
|
|
5125
|
+
opacity: wt
|
|
5071
5126
|
};
|
|
5072
5127
|
}
|
|
5073
5128
|
})() : null;
|
|
5074
5129
|
return t.map((n, r) => {
|
|
5075
|
-
let s, c = j.current?.clientWidth || 0, l =
|
|
5130
|
+
let s, c = j.current?.clientWidth || 0, l = Ye(n), u = Ye(t[0]).width * S, d = l.width * S;
|
|
5076
5131
|
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 ? [...
|
|
5132
|
+
let f = o && o.pageIndex === n ? [...H, o] : H;
|
|
5078
5133
|
return /* @__PURE__ */ I(e.Fragment, { children: [
|
|
5079
|
-
/* @__PURE__ */ F(
|
|
5134
|
+
/* @__PURE__ */ F(yt, {
|
|
5080
5135
|
pageNum: n,
|
|
5081
5136
|
pdfDoc: M,
|
|
5082
5137
|
scale: S,
|
|
5083
5138
|
rotation: A,
|
|
5084
5139
|
containerWidth: j.current?.clientWidth || 0,
|
|
5085
5140
|
containerHeight: j.current?.clientHeight || 0,
|
|
5086
|
-
scrollTop:
|
|
5087
|
-
scrollLeft:
|
|
5141
|
+
scrollTop: Xe.top,
|
|
5142
|
+
scrollLeft: Xe.left,
|
|
5088
5143
|
pageTop: i,
|
|
5089
5144
|
pageLeft: s,
|
|
5090
5145
|
basePageWidth: l.width,
|
|
5091
5146
|
basePageHeight: l.height,
|
|
5092
5147
|
activeTab: a,
|
|
5093
|
-
activeTool:
|
|
5148
|
+
activeTool: U,
|
|
5094
5149
|
annotations: f,
|
|
5095
5150
|
transientHighlights: _e?.filter((e) => e.pageIndex === n) || [],
|
|
5096
|
-
selectedAnnotationId:
|
|
5151
|
+
selectedAnnotationId: Y,
|
|
5097
5152
|
activeSearchResult: Ue,
|
|
5098
|
-
onMouseDown:
|
|
5099
|
-
onMouseMove:
|
|
5100
|
-
onMouseUp:
|
|
5101
|
-
onAnnotationClick:
|
|
5102
|
-
onAnnotationMouseEnter:
|
|
5153
|
+
onMouseDown: Sn,
|
|
5154
|
+
onMouseMove: wn,
|
|
5155
|
+
onMouseUp: Tn,
|
|
5156
|
+
onAnnotationClick: Dn,
|
|
5157
|
+
onAnnotationMouseEnter: En,
|
|
5103
5158
|
onClearSelection: () => {
|
|
5104
|
-
if (
|
|
5105
|
-
|
|
5159
|
+
if (Zt.current || Yt) {
|
|
5160
|
+
Zt.current = !1;
|
|
5106
5161
|
return;
|
|
5107
5162
|
}
|
|
5108
|
-
|
|
5163
|
+
X(null), Z(null);
|
|
5109
5164
|
},
|
|
5110
5165
|
watermark: ue,
|
|
5111
5166
|
watermarkText: de,
|
|
5112
|
-
redactions:
|
|
5113
|
-
onDiscardRedaction:
|
|
5114
|
-
onRendered:
|
|
5167
|
+
redactions: cn,
|
|
5168
|
+
onDiscardRedaction: dn,
|
|
5169
|
+
onRendered: gn
|
|
5115
5170
|
}),
|
|
5116
5171
|
R.isActive && R.mode === "overlay" && ke && /* @__PURE__ */ F("div", {
|
|
5117
5172
|
style: {
|
|
@@ -5126,15 +5181,15 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5126
5181
|
zIndex: 12,
|
|
5127
5182
|
filter: "contrast(1.2) brightness(0.95)"
|
|
5128
5183
|
},
|
|
5129
|
-
children: /* @__PURE__ */ F(
|
|
5184
|
+
children: /* @__PURE__ */ F(yt, {
|
|
5130
5185
|
pageNum: n,
|
|
5131
5186
|
pdfDoc: ke,
|
|
5132
5187
|
scale: S,
|
|
5133
5188
|
rotation: A,
|
|
5134
5189
|
containerWidth: j.current?.clientWidth || 0,
|
|
5135
5190
|
containerHeight: j.current?.clientHeight || 0,
|
|
5136
|
-
scrollTop:
|
|
5137
|
-
scrollLeft:
|
|
5191
|
+
scrollTop: Xe.top,
|
|
5192
|
+
scrollLeft: Xe.left,
|
|
5138
5193
|
pageTop: 0,
|
|
5139
5194
|
pageLeft: 0,
|
|
5140
5195
|
basePageWidth: l.width,
|
|
@@ -5162,18 +5217,18 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5162
5217
|
pointerEvents: "none",
|
|
5163
5218
|
zIndex: 16
|
|
5164
5219
|
},
|
|
5165
|
-
children: /* @__PURE__ */ F(
|
|
5220
|
+
children: /* @__PURE__ */ F(Ot, {
|
|
5166
5221
|
boxes: [...R.pageDiffsA?.[n] || [], ...R.pageDiffsB?.[n] || []],
|
|
5167
5222
|
scale: S,
|
|
5168
5223
|
selectedDiffId: R.diffItems[R.currentDiffIndex]?.id,
|
|
5169
5224
|
onSelectDiff: (e) => {
|
|
5170
5225
|
let t = R.diffItems.findIndex((t) => t.id === e);
|
|
5171
|
-
t !== -1 &&
|
|
5226
|
+
t !== -1 && ht(t);
|
|
5172
5227
|
}
|
|
5173
5228
|
})
|
|
5174
5229
|
}),
|
|
5175
|
-
|
|
5176
|
-
let e = A % 180 == 0 ? l.width : l.height, t = A % 180 == 0 ? l.height : l.width, n =
|
|
5230
|
+
J && J.pageIndex === n && (() => {
|
|
5231
|
+
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
5232
|
return /* @__PURE__ */ I("div", {
|
|
5178
5233
|
style: {
|
|
5179
5234
|
position: "absolute",
|
|
@@ -5187,19 +5242,19 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5187
5242
|
flexDirection: "column"
|
|
5188
5243
|
},
|
|
5189
5244
|
children: [/* @__PURE__ */ F("textarea", {
|
|
5190
|
-
ref:
|
|
5191
|
-
value:
|
|
5192
|
-
onChange: (e) =>
|
|
5245
|
+
ref: qt,
|
|
5246
|
+
value: Gt,
|
|
5247
|
+
onChange: (e) => Kt(e.target.value),
|
|
5193
5248
|
onBlur: (e) => {
|
|
5194
|
-
e.currentTarget.parentElement?.contains(e.relatedTarget) ||
|
|
5249
|
+
e.currentTarget.parentElement?.contains(e.relatedTarget) || Cn();
|
|
5195
5250
|
},
|
|
5196
5251
|
onKeyDown: (e) => {
|
|
5197
|
-
e.key === "Enter" && !e.shiftKey && (e.preventDefault(),
|
|
5252
|
+
e.key === "Enter" && !e.shiftKey && (e.preventDefault(), Cn());
|
|
5198
5253
|
},
|
|
5199
5254
|
style: {
|
|
5200
5255
|
backgroundColor: "transparent",
|
|
5201
5256
|
border: "none",
|
|
5202
|
-
color:
|
|
5257
|
+
color: _t,
|
|
5203
5258
|
fontSize: "16px",
|
|
5204
5259
|
fontFamily: "sans-serif",
|
|
5205
5260
|
minWidth: "150px",
|
|
@@ -5208,7 +5263,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5208
5263
|
resize: "both",
|
|
5209
5264
|
padding: "8px"
|
|
5210
5265
|
},
|
|
5211
|
-
placeholder:
|
|
5266
|
+
placeholder: J.type === "note" ? "Note text..." : "Type text...",
|
|
5212
5267
|
autoFocus: !0
|
|
5213
5268
|
}), /* @__PURE__ */ F("div", {
|
|
5214
5269
|
style: {
|
|
@@ -5219,7 +5274,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5219
5274
|
},
|
|
5220
5275
|
children: /* @__PURE__ */ F("button", {
|
|
5221
5276
|
onMouseDown: (e) => {
|
|
5222
|
-
e.preventDefault(),
|
|
5277
|
+
e.preventDefault(), Cn();
|
|
5223
5278
|
},
|
|
5224
5279
|
style: {
|
|
5225
5280
|
padding: "4px 12px",
|
|
@@ -5242,17 +5297,17 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5242
5297
|
style: {
|
|
5243
5298
|
position: "relative",
|
|
5244
5299
|
width: "100%",
|
|
5245
|
-
height: `${
|
|
5300
|
+
height: `${lt.total}px`
|
|
5246
5301
|
},
|
|
5247
|
-
children:
|
|
5302
|
+
children: ct.map((e, n) => t(e, n, !0))
|
|
5248
5303
|
});
|
|
5249
5304
|
{
|
|
5250
|
-
let e = Math.max(0,
|
|
5305
|
+
let e = Math.max(0, ct.findIndex((e) => e.includes(N))), n = ct[e] || [];
|
|
5251
5306
|
return /* @__PURE__ */ F("div", {
|
|
5252
5307
|
style: {
|
|
5253
5308
|
position: "relative",
|
|
5254
5309
|
width: "100%",
|
|
5255
|
-
minHeight: `${
|
|
5310
|
+
minHeight: `${lt.heights[e] ?? 0}px`
|
|
5256
5311
|
},
|
|
5257
5312
|
children: t(n, e, !1)
|
|
5258
5313
|
});
|
|
@@ -5366,7 +5421,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5366
5421
|
},
|
|
5367
5422
|
children: [
|
|
5368
5423
|
/* @__PURE__ */ F("button", {
|
|
5369
|
-
onClick: () =>
|
|
5424
|
+
onClick: () => pt(Math.max(1, N - 1)),
|
|
5370
5425
|
disabled: N <= 1,
|
|
5371
5426
|
style: {
|
|
5372
5427
|
background: "none",
|
|
@@ -5393,7 +5448,7 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5393
5448
|
]
|
|
5394
5449
|
}),
|
|
5395
5450
|
/* @__PURE__ */ F("button", {
|
|
5396
|
-
onClick: () =>
|
|
5451
|
+
onClick: () => pt(Math.min(M.numPages, N + 1)),
|
|
5397
5452
|
disabled: N >= M.numPages,
|
|
5398
5453
|
style: {
|
|
5399
5454
|
background: "none",
|
|
@@ -5407,15 +5462,15 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5407
5462
|
})
|
|
5408
5463
|
]
|
|
5409
5464
|
}),
|
|
5410
|
-
|
|
5411
|
-
annotation:
|
|
5412
|
-
position:
|
|
5465
|
+
Y && Jt && /* @__PURE__ */ F(He, {
|
|
5466
|
+
annotation: H.find((e) => e.id === Y),
|
|
5467
|
+
position: Jt,
|
|
5413
5468
|
onCopy: () => {
|
|
5414
|
-
let e =
|
|
5469
|
+
let e = H.find((e) => e.id === Y);
|
|
5415
5470
|
if (e) {
|
|
5416
5471
|
let t = {
|
|
5417
5472
|
...e,
|
|
5418
|
-
id:
|
|
5473
|
+
id: bt(),
|
|
5419
5474
|
author: void 0,
|
|
5420
5475
|
authorId: void 0,
|
|
5421
5476
|
createdAt: void 0,
|
|
@@ -5425,25 +5480,25 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5425
5480
|
x: e.x + 20,
|
|
5426
5481
|
y: e.y + 20
|
|
5427
5482
|
};
|
|
5428
|
-
Q([...
|
|
5483
|
+
Q([...H, t]);
|
|
5429
5484
|
}
|
|
5430
|
-
|
|
5485
|
+
X(null), Z(null);
|
|
5431
5486
|
},
|
|
5432
5487
|
onDelete: () => {
|
|
5433
|
-
Q(
|
|
5488
|
+
Q(H.filter((e) => e.id !== Y)), X(null), Z(null);
|
|
5434
5489
|
},
|
|
5435
5490
|
onUpdateColor: (e) => {
|
|
5436
|
-
Q(
|
|
5491
|
+
Q(H.map((t) => t.id === Y ? {
|
|
5437
5492
|
...t,
|
|
5438
5493
|
color: e
|
|
5439
5494
|
} : t));
|
|
5440
5495
|
},
|
|
5441
5496
|
onOpenLinkModal: () => {
|
|
5442
|
-
|
|
5497
|
+
Xt(!0), Z(null);
|
|
5443
5498
|
},
|
|
5444
5499
|
permissions: ve
|
|
5445
5500
|
}),
|
|
5446
|
-
R.isActive && R.showCurtain && /* @__PURE__ */ F(
|
|
5501
|
+
R.isActive && R.showCurtain && /* @__PURE__ */ F(Mt, {
|
|
5447
5502
|
positionPercent: R.curtainPosition,
|
|
5448
5503
|
onChangePosition: (e) => z((t) => ({
|
|
5449
5504
|
...t,
|
|
@@ -5452,29 +5507,29 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5452
5507
|
containerRef: j
|
|
5453
5508
|
})
|
|
5454
5509
|
]
|
|
5455
|
-
})] }), R.isActive && /* @__PURE__ */ F(
|
|
5510
|
+
})] }), R.isActive && /* @__PURE__ */ F(jt, {
|
|
5456
5511
|
isOpen: B,
|
|
5457
5512
|
onClose: () => Ie(!1),
|
|
5458
5513
|
diffItems: R.diffItems,
|
|
5459
5514
|
textDiffs: Pe,
|
|
5460
5515
|
currentDiffIndex: R.currentDiffIndex,
|
|
5461
|
-
onSelectDiff: (e, t) =>
|
|
5462
|
-
onJumpToPage: (e) =>
|
|
5516
|
+
onSelectDiff: (e, t) => ht(e, t),
|
|
5517
|
+
onJumpToPage: (e) => pt(e)
|
|
5463
5518
|
})]
|
|
5464
5519
|
})
|
|
5465
5520
|
]
|
|
5466
5521
|
}),
|
|
5467
|
-
|
|
5468
|
-
initialUrl:
|
|
5469
|
-
initialText:
|
|
5470
|
-
showTextInput: !
|
|
5522
|
+
Yt && Y && /* @__PURE__ */ F(We, {
|
|
5523
|
+
initialUrl: H.find((e) => e.id === Y)?.linkUrl || "",
|
|
5524
|
+
initialText: H.find((e) => e.id === Y)?.text || "",
|
|
5525
|
+
showTextInput: !H.find((e) => e.id === Y)?.width || H.find((e) => e.id === Y)?.text === "" || H.find((e) => e.id === Y)?.text !== void 0,
|
|
5471
5526
|
onClose: () => {
|
|
5472
|
-
let e =
|
|
5473
|
-
e && !e.linkUrl && Q(
|
|
5527
|
+
let e = H.find((e) => e.id === Y);
|
|
5528
|
+
e && !e.linkUrl && Q(H.filter((e) => e.id !== Y)), Xt(!1), X(null);
|
|
5474
5529
|
},
|
|
5475
5530
|
onSave: (e, t) => {
|
|
5476
|
-
Q(
|
|
5477
|
-
if (n.id ===
|
|
5531
|
+
Q(H.map((n) => {
|
|
5532
|
+
if (n.id === Y) {
|
|
5478
5533
|
let r = t === void 0 ? n.text : t, i = r ? Math.max(100, r.length * 8 + 20) : n.width;
|
|
5479
5534
|
return {
|
|
5480
5535
|
...n,
|
|
@@ -5484,27 +5539,27 @@ function At({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5484
5539
|
};
|
|
5485
5540
|
}
|
|
5486
5541
|
return n;
|
|
5487
|
-
})),
|
|
5542
|
+
})), Xt(!1), X(null);
|
|
5488
5543
|
}
|
|
5489
5544
|
}),
|
|
5490
|
-
_ && /* @__PURE__ */ F(
|
|
5545
|
+
_ && /* @__PURE__ */ F(rt, {
|
|
5491
5546
|
isOpen: r,
|
|
5492
5547
|
activeTab: te,
|
|
5493
5548
|
setActiveTab: ne,
|
|
5494
|
-
annotations:
|
|
5549
|
+
annotations: H,
|
|
5495
5550
|
setAnnotations: Q,
|
|
5496
|
-
selectedAnnotationId:
|
|
5497
|
-
setSelectedAnnotationId:
|
|
5498
|
-
onSearch:
|
|
5499
|
-
searchResults:
|
|
5500
|
-
isSearching:
|
|
5501
|
-
searchProgress:
|
|
5502
|
-
onResultClick:
|
|
5551
|
+
selectedAnnotationId: Y,
|
|
5552
|
+
setSelectedAnnotationId: X,
|
|
5553
|
+
onSearch: fn,
|
|
5554
|
+
searchResults: pn,
|
|
5555
|
+
isSearching: mn,
|
|
5556
|
+
searchProgress: $,
|
|
5557
|
+
onResultClick: mt
|
|
5503
5558
|
})
|
|
5504
5559
|
]
|
|
5505
5560
|
});
|
|
5506
5561
|
}
|
|
5507
|
-
function
|
|
5562
|
+
function Bt({ icon: e, active: t, onClick: n, label: r }) {
|
|
5508
5563
|
return /* @__PURE__ */ F("button", {
|
|
5509
5564
|
onClick: n,
|
|
5510
5565
|
title: r,
|
|
@@ -5531,8 +5586,8 @@ function jt({ icon: e, active: t, onClick: n, label: r }) {
|
|
|
5531
5586
|
}
|
|
5532
5587
|
//#endregion
|
|
5533
5588
|
//#region src/components/SettingsModal.tsx
|
|
5534
|
-
function
|
|
5535
|
-
let { shortcuts: r, updateShortcut: i, resetShortcuts: a } =
|
|
5589
|
+
function Vt({ onClose: e, watermarkText: t, setWatermarkText: n }) {
|
|
5590
|
+
let { shortcuts: r, updateShortcut: i, resetShortcuts: a } = Qe(), [s, l] = c("Keyboard Shortcuts"), [u, d] = c(null), [f, p] = c(""), m = (e, t) => {
|
|
5536
5591
|
if (e.preventDefault(), e.stopPropagation(), e.key === "Escape") {
|
|
5537
5592
|
d(null);
|
|
5538
5593
|
return;
|
|
@@ -5558,7 +5613,7 @@ function Mt({ onClose: e, watermarkText: t, setWatermarkText: n }) {
|
|
|
5558
5613
|
},
|
|
5559
5614
|
children: "None"
|
|
5560
5615
|
});
|
|
5561
|
-
let t =
|
|
5616
|
+
let t = $e(e), n = typeof navigator < "u" && /mac/i.test(navigator.platform || navigator.userAgent || ""), r = [];
|
|
5562
5617
|
if (t.meta && r.push(n ? "⌘" : "Ctrl"), t.alt && r.push(n ? "⌥" : "Alt"), t.shift && r.push(n ? "⇧" : "Shift"), t.key) {
|
|
5563
5618
|
let e = t.key.toUpperCase();
|
|
5564
5619
|
e === "DELETE" && (e = n ? "⌫ Delete" : "Del"), r.push(e);
|
|
@@ -6060,7 +6115,7 @@ function Mt({ onClose: e, watermarkText: t, setWatermarkText: n }) {
|
|
|
6060
6115
|
}
|
|
6061
6116
|
//#endregion
|
|
6062
6117
|
//#region src/components/AboutModal.tsx
|
|
6063
|
-
function
|
|
6118
|
+
function Ht({ onClose: e }) {
|
|
6064
6119
|
return /* @__PURE__ */ F("div", {
|
|
6065
6120
|
style: {
|
|
6066
6121
|
position: "fixed",
|
|
@@ -6281,7 +6336,7 @@ function Nt({ onClose: e }) {
|
|
|
6281
6336
|
}
|
|
6282
6337
|
//#endregion
|
|
6283
6338
|
//#region src/core/eventBus.ts
|
|
6284
|
-
var
|
|
6339
|
+
var Ut = class {
|
|
6285
6340
|
listeners = /* @__PURE__ */ new Map();
|
|
6286
6341
|
destroyed = !1;
|
|
6287
6342
|
on(e, t) {
|
|
@@ -6323,22 +6378,22 @@ var Pt = class {
|
|
|
6323
6378
|
get isDestroyed() {
|
|
6324
6379
|
return this.destroyed;
|
|
6325
6380
|
}
|
|
6326
|
-
},
|
|
6327
|
-
function
|
|
6381
|
+
}, J = (e) => e === 0 ? 0 : e;
|
|
6382
|
+
function Wt(e, t) {
|
|
6328
6383
|
return {
|
|
6329
|
-
x:
|
|
6330
|
-
y:
|
|
6384
|
+
x: J(e.x * t[0] + e.y * t[2] + t[4]),
|
|
6385
|
+
y: J(e.x * t[1] + e.y * t[3] + t[5])
|
|
6331
6386
|
};
|
|
6332
6387
|
}
|
|
6333
|
-
function
|
|
6388
|
+
function Gt(e, t) {
|
|
6334
6389
|
let n = t[0] * t[3] - t[1] * t[2];
|
|
6335
6390
|
return {
|
|
6336
|
-
x:
|
|
6337
|
-
y:
|
|
6391
|
+
x: J((e.x * t[3] - e.y * t[2] + t[2] * t[5] - t[4] * t[3]) / n),
|
|
6392
|
+
y: J((-e.x * t[1] + e.y * t[0] + t[4] * t[1] - t[5] * t[0]) / n)
|
|
6338
6393
|
};
|
|
6339
6394
|
}
|
|
6340
|
-
function
|
|
6341
|
-
let r =
|
|
6395
|
+
function Kt(e, t, n) {
|
|
6396
|
+
let r = ut(n), [i, a, o, s] = t, c = (o + i) / 2, l = (s + a) / 2, u, d, f, p;
|
|
6342
6397
|
switch (r) {
|
|
6343
6398
|
case 180:
|
|
6344
6399
|
u = -1, d = 0, f = 0, p = 1;
|
|
@@ -6375,33 +6430,33 @@ function q(e, t, n) {
|
|
|
6375
6430
|
transform: v
|
|
6376
6431
|
};
|
|
6377
6432
|
}
|
|
6378
|
-
function
|
|
6433
|
+
function qt(e) {
|
|
6379
6434
|
let t = e.view;
|
|
6380
|
-
return
|
|
6435
|
+
return Kt(e.pageNumber, [
|
|
6381
6436
|
t[0],
|
|
6382
6437
|
t[1],
|
|
6383
6438
|
t[2],
|
|
6384
6439
|
t[3]
|
|
6385
6440
|
], e.rotate);
|
|
6386
6441
|
}
|
|
6387
|
-
function
|
|
6442
|
+
function Y(e) {
|
|
6388
6443
|
let t = /* @__PURE__ */ new Map();
|
|
6389
6444
|
return (n) => {
|
|
6390
6445
|
let r = Math.max(1, Math.min(e.numPages, n)), i = t.get(r);
|
|
6391
|
-
return i || (i = e.getPage(r).then(
|
|
6446
|
+
return i || (i = e.getPage(r).then(qt), t.set(r, i)), i;
|
|
6392
6447
|
};
|
|
6393
6448
|
}
|
|
6394
|
-
function
|
|
6395
|
-
return
|
|
6449
|
+
function X(e, t) {
|
|
6450
|
+
return Gt(t, e.transform);
|
|
6396
6451
|
}
|
|
6397
|
-
function
|
|
6398
|
-
return
|
|
6452
|
+
function Jt(e, t) {
|
|
6453
|
+
return Wt(t, e.transform);
|
|
6399
6454
|
}
|
|
6400
|
-
function
|
|
6401
|
-
let n =
|
|
6455
|
+
function Z(e, t) {
|
|
6456
|
+
let n = X(e, {
|
|
6402
6457
|
x: t.x,
|
|
6403
6458
|
y: t.y
|
|
6404
|
-
}), r =
|
|
6459
|
+
}), r = X(e, {
|
|
6405
6460
|
x: t.x + t.width,
|
|
6406
6461
|
y: t.y + t.height
|
|
6407
6462
|
});
|
|
@@ -6412,11 +6467,11 @@ function Vt(e, t) {
|
|
|
6412
6467
|
Math.max(n.y, r.y)
|
|
6413
6468
|
];
|
|
6414
6469
|
}
|
|
6415
|
-
function
|
|
6416
|
-
let n =
|
|
6470
|
+
function Yt(e, t) {
|
|
6471
|
+
let n = Jt(e, {
|
|
6417
6472
|
x: t[0],
|
|
6418
6473
|
y: t[1]
|
|
6419
|
-
}), r =
|
|
6474
|
+
}), r = Jt(e, {
|
|
6420
6475
|
x: t[2],
|
|
6421
6476
|
y: t[3]
|
|
6422
6477
|
});
|
|
@@ -6427,14 +6482,14 @@ function Y(e, t) {
|
|
|
6427
6482
|
height: Math.abs(r.y - n.y)
|
|
6428
6483
|
};
|
|
6429
6484
|
}
|
|
6430
|
-
function
|
|
6431
|
-
return t.map((t) =>
|
|
6485
|
+
function Xt(e, t) {
|
|
6486
|
+
return t.map((t) => X(e, t));
|
|
6432
6487
|
}
|
|
6433
|
-
function
|
|
6434
|
-
return t.map((t) =>
|
|
6488
|
+
function Zt(e, t) {
|
|
6489
|
+
return t.map((t) => Jt(e, t));
|
|
6435
6490
|
}
|
|
6436
|
-
function
|
|
6437
|
-
let [n, r, i, a] =
|
|
6491
|
+
function Qt(e, t) {
|
|
6492
|
+
let [n, r, i, a] = Z(e, t);
|
|
6438
6493
|
return [
|
|
6439
6494
|
n,
|
|
6440
6495
|
a,
|
|
@@ -6446,7 +6501,7 @@ function Wt(e, t) {
|
|
|
6446
6501
|
r
|
|
6447
6502
|
];
|
|
6448
6503
|
}
|
|
6449
|
-
function
|
|
6504
|
+
function $t(e, t) {
|
|
6450
6505
|
let n = [];
|
|
6451
6506
|
for (let r = 0; r + 7 < t.length; r += 8) {
|
|
6452
6507
|
let i = [
|
|
@@ -6460,7 +6515,7 @@ function Gt(e, t) {
|
|
|
6460
6515
|
t[r + 5],
|
|
6461
6516
|
t[r + 7]
|
|
6462
6517
|
];
|
|
6463
|
-
n.push(
|
|
6518
|
+
n.push(Yt(e, [
|
|
6464
6519
|
Math.min(...i),
|
|
6465
6520
|
Math.min(...a),
|
|
6466
6521
|
Math.max(...i),
|
|
@@ -6469,7 +6524,7 @@ function Gt(e, t) {
|
|
|
6469
6524
|
}
|
|
6470
6525
|
return n;
|
|
6471
6526
|
}
|
|
6472
|
-
function
|
|
6527
|
+
function en(e) {
|
|
6473
6528
|
if (e.length === 0) return {
|
|
6474
6529
|
x: 0,
|
|
6475
6530
|
y: 0,
|
|
@@ -6484,17 +6539,17 @@ function X(e) {
|
|
|
6484
6539
|
height: i - n
|
|
6485
6540
|
};
|
|
6486
6541
|
}
|
|
6487
|
-
var
|
|
6542
|
+
var Q = (e) => (Math.round(e * 1e3) / 1e3).toString(), tn = 524288e3, nn = (e) => {
|
|
6488
6543
|
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
6544
|
return B(n, r, i);
|
|
6490
6545
|
};
|
|
6491
|
-
async function
|
|
6492
|
-
let a =
|
|
6546
|
+
async function rn(e, t, n, r, i) {
|
|
6547
|
+
let a = nn(r.color), o = r.opacity ?? 1, s = r.strokeWidth || 1, [c, l, u, d] = Z(n, {
|
|
6493
6548
|
x: r.x,
|
|
6494
6549
|
y: r.y,
|
|
6495
6550
|
width: r.width,
|
|
6496
6551
|
height: r.height
|
|
6497
|
-
}), f = u - c, p = d - l, m = Fe(n.rotate), h = (e, t, r) =>
|
|
6552
|
+
}), f = u - c, p = d - l, m = Fe(n.rotate), h = (e, t, r) => X(n, {
|
|
6498
6553
|
x: e,
|
|
6499
6554
|
y: t + r
|
|
6500
6555
|
});
|
|
@@ -6533,7 +6588,7 @@ async function Jt(e, t, n, r, i) {
|
|
|
6533
6588
|
height: r.height
|
|
6534
6589
|
}];
|
|
6535
6590
|
for (let r of e) {
|
|
6536
|
-
let [e, i, s, c] =
|
|
6591
|
+
let [e, i, s, c] = Z(n, r);
|
|
6537
6592
|
t.drawRectangle({
|
|
6538
6593
|
x: e,
|
|
6539
6594
|
y: i,
|
|
@@ -6554,7 +6609,7 @@ async function Jt(e, t, n, r, i) {
|
|
|
6554
6609
|
}, {
|
|
6555
6610
|
x: r.x + r.width,
|
|
6556
6611
|
y: r.y + r.height
|
|
6557
|
-
}], [i, c] =
|
|
6612
|
+
}], [i, c] = Xt(n, [e[0], e[1]]);
|
|
6558
6613
|
if (t.drawLine({
|
|
6559
6614
|
start: i,
|
|
6560
6615
|
end: c,
|
|
@@ -6562,7 +6617,7 @@ async function Jt(e, t, n, r, i) {
|
|
|
6562
6617
|
opacity: o,
|
|
6563
6618
|
thickness: s
|
|
6564
6619
|
}), 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] =
|
|
6620
|
+
let r = e[0], i = e[1], l = Math.atan2(i.y - r.y, i.x - r.x), u = 15 + s, [d, f] = Xt(n, [{
|
|
6566
6621
|
x: i.x - u * Math.cos(l - Math.PI / 6),
|
|
6567
6622
|
y: i.y - u * Math.sin(l - Math.PI / 6)
|
|
6568
6623
|
}, {
|
|
@@ -6588,7 +6643,7 @@ async function Jt(e, t, n, r, i) {
|
|
|
6588
6643
|
case "freehand": {
|
|
6589
6644
|
let e = r.strokes && r.strokes.length > 0 ? r.strokes : r.points ? [r.points] : [];
|
|
6590
6645
|
for (let r of e) {
|
|
6591
|
-
let e =
|
|
6646
|
+
let e = Xt(n, r);
|
|
6592
6647
|
for (let n = 1; n < e.length; n++) t.drawLine({
|
|
6593
6648
|
start: e[n - 1],
|
|
6594
6649
|
end: e[n],
|
|
@@ -6614,7 +6669,7 @@ async function Jt(e, t, n, r, i) {
|
|
|
6614
6669
|
return;
|
|
6615
6670
|
}
|
|
6616
6671
|
case "note": {
|
|
6617
|
-
let [e, i, c, l] =
|
|
6672
|
+
let [e, i, c, l] = Z(n, {
|
|
6618
6673
|
x: r.x,
|
|
6619
6674
|
y: r.y,
|
|
6620
6675
|
width: 24,
|
|
@@ -6648,7 +6703,7 @@ async function Jt(e, t, n, r, i) {
|
|
|
6648
6703
|
}, {
|
|
6649
6704
|
x: r.x,
|
|
6650
6705
|
y: r.y
|
|
6651
|
-
}], [i, c] =
|
|
6706
|
+
}], [i, c] = Xt(n, [e[0], e[1]]);
|
|
6652
6707
|
if (t.drawLine({
|
|
6653
6708
|
start: i,
|
|
6654
6709
|
end: c,
|
|
@@ -6656,7 +6711,7 @@ async function Jt(e, t, n, r, i) {
|
|
|
6656
6711
|
opacity: o,
|
|
6657
6712
|
thickness: s
|
|
6658
6713
|
}), r.text) {
|
|
6659
|
-
let i = r.text.length * 8 + 20, [c, l, u, d] =
|
|
6714
|
+
let i = r.text.length * 8 + 20, [c, l, u, d] = Z(n, {
|
|
6660
6715
|
x: e[1].x,
|
|
6661
6716
|
y: e[1].y,
|
|
6662
6717
|
width: i,
|
|
@@ -6749,8 +6804,8 @@ async function Jt(e, t, n, r, i) {
|
|
|
6749
6804
|
default: return;
|
|
6750
6805
|
}
|
|
6751
6806
|
}
|
|
6752
|
-
async function
|
|
6753
|
-
let n =
|
|
6807
|
+
async function an(e, t) {
|
|
6808
|
+
let n = nn(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
6809
|
for (let a of e.getPages()) {
|
|
6755
6810
|
let { width: e, height: c } = a.getSize();
|
|
6756
6811
|
if (t.mode === "single") {
|
|
@@ -6781,10 +6836,10 @@ async function Yt(e, t) {
|
|
|
6781
6836
|
}
|
|
6782
6837
|
}
|
|
6783
6838
|
}
|
|
6784
|
-
async function
|
|
6839
|
+
async function on(e, t) {
|
|
6785
6840
|
let n = await e.save(), r = L.getDocument({
|
|
6786
6841
|
data: n,
|
|
6787
|
-
...
|
|
6842
|
+
...Et()
|
|
6788
6843
|
}), i = await r.promise, a = await z.create();
|
|
6789
6844
|
try {
|
|
6790
6845
|
for (let n = 1; n <= i.numPages; n++) {
|
|
@@ -6821,7 +6876,7 @@ async function Xt(e, t) {
|
|
|
6821
6876
|
}
|
|
6822
6877
|
return a;
|
|
6823
6878
|
}
|
|
6824
|
-
async function
|
|
6879
|
+
async function sn(e, t = {}) {
|
|
6825
6880
|
t.xfdfString && console.warn("[teamsync-pdf-viewer] getFileData({ xfdfString }) is ignored; import the XFDF through annotationManager.importAnnotations() first.");
|
|
6826
6881
|
let n = await e.getSourceBytes(), r = n instanceof Uint8Array ? n : new Uint8Array(n);
|
|
6827
6882
|
if (r.byteLength > 524288e3) {
|
|
@@ -6831,33 +6886,33 @@ async function Zt(e, t = {}) {
|
|
|
6831
6886
|
let i = await z.load(r, { ignoreEncryption: !0 }), a = i.getPages(), o = t.explicitAnnotations || e.annotations, s = e.getPageGeometry, c = null;
|
|
6832
6887
|
!s && o.length > 0 && (c = L.getDocument({
|
|
6833
6888
|
data: r.slice(),
|
|
6834
|
-
...
|
|
6835
|
-
}), s =
|
|
6889
|
+
...Et()
|
|
6890
|
+
}), s = Y(await c.promise));
|
|
6836
6891
|
try {
|
|
6837
6892
|
for (let t of o) {
|
|
6838
6893
|
let n = Math.max(0, Math.min((t.pageIndex || 1) - 1, a.length - 1)), r = await s(n + 1);
|
|
6839
|
-
await
|
|
6894
|
+
await rn(i, a[n], r, t, e.signerName);
|
|
6840
6895
|
}
|
|
6841
6896
|
} finally {
|
|
6842
6897
|
c && await c.destroy().catch(() => {});
|
|
6843
6898
|
}
|
|
6844
|
-
e.watermark?.text && await
|
|
6899
|
+
e.watermark?.text && await an(i, e.watermark);
|
|
6845
6900
|
let l = e.redactions || [];
|
|
6846
|
-
return await (l.length > 0 ? await
|
|
6901
|
+
return await (l.length > 0 ? await on(i, l) : i).save();
|
|
6847
6902
|
}
|
|
6848
6903
|
//#endregion
|
|
6849
6904
|
//#region src/annotations/xfdf.ts
|
|
6850
|
-
var
|
|
6851
|
-
function
|
|
6905
|
+
var cn = "http://ns.adobe.com/xfdf/", ln = "tspdf", un = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
6906
|
+
function dn(e, t = 2) {
|
|
6852
6907
|
return String(e).padStart(t, "0");
|
|
6853
6908
|
}
|
|
6854
|
-
function
|
|
6909
|
+
function fn(e) {
|
|
6855
6910
|
let t = e ? new Date(e) : /* @__PURE__ */ new Date();
|
|
6856
|
-
if (Number.isNaN(t.getTime())) return
|
|
6857
|
-
let n = -t.getTimezoneOffset(), r = n >= 0 ? "+" : "-", i =
|
|
6858
|
-
return `D:${t.getFullYear()}${
|
|
6911
|
+
if (Number.isNaN(t.getTime())) return fn(void 0);
|
|
6912
|
+
let n = -t.getTimezoneOffset(), r = n >= 0 ? "+" : "-", i = dn(Math.floor(Math.abs(n) / 60)), a = dn(Math.abs(n) % 60);
|
|
6913
|
+
return `D:${t.getFullYear()}${dn(t.getMonth() + 1)}${dn(t.getDate())}${dn(t.getHours())}${dn(t.getMinutes())}${dn(t.getSeconds())}${r}${i}'${a}'`;
|
|
6859
6914
|
}
|
|
6860
|
-
function
|
|
6915
|
+
function pn(e) {
|
|
6861
6916
|
if (!e) return;
|
|
6862
6917
|
let t = /^D:(\d{4})(\d{2})?(\d{2})?(\d{2})?(\d{2})?(\d{2})?([+\-Z])?(\d{2})?'?(\d{2})?/.exec(e.trim());
|
|
6863
6918
|
if (!t) {
|
|
@@ -6869,41 +6924,41 @@ function nn(e) {
|
|
|
6869
6924
|
let f = Date.parse(`${n}-${r}-${i}T${a}:${o}:${s}${d}`);
|
|
6870
6925
|
return Number.isNaN(f) ? void 0 : new Date(f).toISOString();
|
|
6871
6926
|
}
|
|
6872
|
-
var
|
|
6927
|
+
var mn = (e) => {
|
|
6873
6928
|
if (!(!e || e === "transparent")) {
|
|
6874
6929
|
if (/^#[0-9a-f]{6}$/i.test(e)) return e.toUpperCase();
|
|
6875
6930
|
if (/^#[0-9a-f]{3}$/i.test(e)) return `#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}`.toUpperCase();
|
|
6876
6931
|
}
|
|
6877
|
-
}, $ = (e, t) => t == null || t === "" ? "" : ` ${e}="${
|
|
6878
|
-
function
|
|
6879
|
-
return `<trn-custom-data bytes="${
|
|
6932
|
+
}, $ = (e, t) => t == null || t === "" ? "" : ` ${e}="${un(String(t))}"`;
|
|
6933
|
+
function hn(e) {
|
|
6934
|
+
return `<trn-custom-data bytes="${un(JSON.stringify({ [ln]: e }))}"/>`;
|
|
6880
6935
|
}
|
|
6881
|
-
function
|
|
6936
|
+
function gn(e) {
|
|
6882
6937
|
let t = Array.from(e.children).find((e) => e.localName === "trn-custom-data");
|
|
6883
6938
|
if (!t) return {};
|
|
6884
6939
|
try {
|
|
6885
|
-
let e = JSON.parse(t.getAttribute("bytes") || "{}")?.[
|
|
6940
|
+
let e = JSON.parse(t.getAttribute("bytes") || "{}")?.[ln];
|
|
6886
6941
|
return e && typeof e == "object" ? e : {};
|
|
6887
6942
|
} catch {
|
|
6888
6943
|
return {};
|
|
6889
6944
|
}
|
|
6890
6945
|
}
|
|
6891
|
-
function
|
|
6892
|
-
return e.map((e) => `${
|
|
6946
|
+
function _n(e) {
|
|
6947
|
+
return e.map((e) => `${Q(e.x)},${Q(e.y)}`).join(";");
|
|
6893
6948
|
}
|
|
6894
|
-
function
|
|
6949
|
+
function vn(e) {
|
|
6895
6950
|
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
6951
|
x: e,
|
|
6897
6952
|
y: t
|
|
6898
6953
|
})) : [];
|
|
6899
6954
|
}
|
|
6900
|
-
function
|
|
6955
|
+
function yn(e) {
|
|
6901
6956
|
return e ? e.split(/[,\s]+/).map(Number).filter((e) => Number.isFinite(e)) : [];
|
|
6902
6957
|
}
|
|
6903
|
-
function
|
|
6904
|
-
return e.map(
|
|
6958
|
+
function bn(e) {
|
|
6959
|
+
return e.map(Q).join(",");
|
|
6905
6960
|
}
|
|
6906
|
-
var
|
|
6961
|
+
var xn = /* @__PURE__ */ new Set([
|
|
6907
6962
|
"page",
|
|
6908
6963
|
"rect",
|
|
6909
6964
|
"color",
|
|
@@ -6925,7 +6980,7 @@ var dn = /* @__PURE__ */ new Set([
|
|
|
6925
6980
|
"IT",
|
|
6926
6981
|
"callout",
|
|
6927
6982
|
"style"
|
|
6928
|
-
]),
|
|
6983
|
+
]), Sn = /* @__PURE__ */ new Set([
|
|
6929
6984
|
"contents",
|
|
6930
6985
|
"contents-richtext",
|
|
6931
6986
|
"inklist",
|
|
@@ -6937,33 +6992,33 @@ var dn = /* @__PURE__ */ new Set([
|
|
|
6937
6992
|
"popup",
|
|
6938
6993
|
"vertices"
|
|
6939
6994
|
]);
|
|
6940
|
-
function
|
|
6941
|
-
let i = r ??
|
|
6995
|
+
function Cn(e, t, n, r) {
|
|
6996
|
+
let i = r ?? Z(t, {
|
|
6942
6997
|
x: e.x,
|
|
6943
6998
|
y: e.y,
|
|
6944
6999
|
width: e.width,
|
|
6945
7000
|
height: e.height
|
|
6946
7001
|
}), 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",
|
|
7002
|
+
return $("page", e.pageIndex - 1) + $("rect", bn(i)) + $("name", e.id) + (n ? $("title", e.author) : "") + $("date", fn(e.modifiedAt ?? a)) + $("creationdate", fn(a)) + $("flags", o) + $("opacity", e.opacity !== void 0 && e.opacity !== 1 ? Q(e.opacity) : void 0);
|
|
6948
7003
|
}
|
|
6949
|
-
function
|
|
7004
|
+
function wn(e) {
|
|
6950
7005
|
let t = e.xfdfExtras?.attrs;
|
|
6951
|
-
return t ? Object.entries(t).filter(([e]) => !
|
|
7006
|
+
return t ? Object.entries(t).filter(([e]) => !xn.has(e)).map(([e, t]) => $(e, t)).join("") : "";
|
|
6952
7007
|
}
|
|
6953
|
-
function
|
|
7008
|
+
function Tn(e) {
|
|
6954
7009
|
return (e.xfdfExtras?.children ?? []).join("");
|
|
6955
7010
|
}
|
|
6956
|
-
function
|
|
7011
|
+
function En(e, t = {}) {
|
|
6957
7012
|
let n = {
|
|
6958
7013
|
type: e.type,
|
|
6959
7014
|
...t
|
|
6960
7015
|
};
|
|
6961
|
-
return e.authorId && (n.authorId = e.authorId), e.strokeWidth !== void 0 && (n.strokeWidth = e.strokeWidth),
|
|
7016
|
+
return e.authorId && (n.authorId = e.authorId), e.strokeWidth !== void 0 && (n.strokeWidth = e.strokeWidth), hn(n);
|
|
6962
7017
|
}
|
|
6963
|
-
var
|
|
6964
|
-
async function
|
|
7018
|
+
var Dn = (e) => e ? `<contents>${un(e)}</contents>` : "", On = (e, t) => `<defaultstyle>font: Helvetica ${t}pt; text-align: left; color: ${mn(e.color) ?? "#000000"}</defaultstyle><defaultappearance>0 0 0 rg /Helv ${t} Tf</defaultappearance>`;
|
|
7019
|
+
async function kn(e, t, n = {}) {
|
|
6965
7020
|
if (e.type === "opaque" && e.rawXfdf) return e.rawXfdf;
|
|
6966
|
-
let r = await t(e.pageIndex), i = n.useDisplayAuthor !== !1, a =
|
|
7021
|
+
let r = await t(e.pageIndex), i = n.useDisplayAuthor !== !1, a = mn(e.color), o = $("color", a) + $("width", e.strokeWidth), s = (t) => Cn(e, r, i, t) + wn(e), c = (t = {}) => En(e, t) + Tn(e);
|
|
6967
7022
|
switch (e.type) {
|
|
6968
7023
|
case "rectangle": return `<square${s()}${o}${$("interior-color", a)} subject="Rectangle">${c()}</square>`;
|
|
6969
7024
|
case "ellipse": return `<circle${s()}${o}${$("interior-color", a)} subject="Ellipse">${c()}</circle>`;
|
|
@@ -6975,17 +7030,17 @@ async function yn(e, t, n = {}) {
|
|
|
6975
7030
|
}, {
|
|
6976
7031
|
x: e.x + e.width,
|
|
6977
7032
|
y: e.y + e.height
|
|
6978
|
-
}], [n, i] =
|
|
7033
|
+
}], [n, i] = Xt(r, [t[0], t[1]]), a = [
|
|
6979
7034
|
Math.min(n.x, i.x),
|
|
6980
7035
|
Math.min(n.y, i.y),
|
|
6981
7036
|
Math.max(n.x, i.x),
|
|
6982
7037
|
Math.max(n.y, i.y)
|
|
6983
7038
|
], l = e.type === "arrow" ? $("head", "OpenArrow") : "";
|
|
6984
|
-
return `<line${s(a)}${o} start="${
|
|
7039
|
+
return `<line${s(a)}${o} start="${Q(n.x)},${Q(n.y)}" end="${Q(i.x)},${Q(i.y)}"${l} subject="${e.type === "arrow" ? "Arrow" : "Line"}">${c()}</line>`;
|
|
6985
7040
|
}
|
|
6986
7041
|
case "freehand": {
|
|
6987
|
-
let t = e.strokes && e.strokes.length > 0 ? e.strokes : e.points ? [e.points] : [], n = t.map((e) => `<gesture>${
|
|
6988
|
-
return `<ink${s(i.length ?
|
|
7042
|
+
let t = e.strokes && e.strokes.length > 0 ? e.strokes : e.points ? [e.points] : [], n = t.map((e) => `<gesture>${_n(Xt(r, e))}</gesture>`).join(""), i = t.flat();
|
|
7043
|
+
return `<ink${s(i.length ? Z(r, An(i, e.strokeWidth)) : void 0)}${o} subject="Free Hand"><inklist>${n}</inklist>${c()}</ink>`;
|
|
6989
7044
|
}
|
|
6990
7045
|
case "highlight": {
|
|
6991
7046
|
let t = e.rects && e.rects.length > 0 ? e.rects : [{
|
|
@@ -6993,10 +7048,10 @@ async function yn(e, t, n = {}) {
|
|
|
6993
7048
|
y: e.y,
|
|
6994
7049
|
width: e.width,
|
|
6995
7050
|
height: e.height
|
|
6996
|
-
}], n = t.flatMap((e) =>
|
|
6997
|
-
return `<highlight${s(
|
|
7051
|
+
}], n = t.flatMap((e) => Qt(r, e)).map(Q).join(",");
|
|
7052
|
+
return `<highlight${s(Z(r, en(t)))}${$("color", a)} coords="${n}" subject="Highlight">${c()}</highlight>`;
|
|
6998
7053
|
}
|
|
6999
|
-
case "text": return `<freetext${s()}${$("color", a)} subject="Free Text">${
|
|
7054
|
+
case "text": return `<freetext${s()}${$("color", a)} subject="Free Text">${Dn(e.text)}${On(e, 16)}${c()}</freetext>`;
|
|
7000
7055
|
case "callout": {
|
|
7001
7056
|
let t = e.points && e.points.length >= 2 ? e.points : [{
|
|
7002
7057
|
x: e.x,
|
|
@@ -7004,7 +7059,7 @@ async function yn(e, t, n = {}) {
|
|
|
7004
7059
|
}, {
|
|
7005
7060
|
x: e.x,
|
|
7006
7061
|
y: e.y
|
|
7007
|
-
}], [n, i] =
|
|
7062
|
+
}], [n, i] = Xt(r, [t[0], t[1]]), a = Z(r, {
|
|
7008
7063
|
x: t[1].x,
|
|
7009
7064
|
y: t[1].y,
|
|
7010
7065
|
width: e.text ? e.text.length * 8 + 20 : 100,
|
|
@@ -7015,19 +7070,19 @@ async function yn(e, t, n = {}) {
|
|
|
7015
7070
|
Math.min(n.y, a[1]),
|
|
7016
7071
|
Math.max(i.x, a[2]),
|
|
7017
7072
|
Math.max(i.y, a[3])
|
|
7018
|
-
])}${o} IT="FreeTextCallout" callout="${
|
|
7073
|
+
])}${o} IT="FreeTextCallout" callout="${Q(n.x)},${Q(n.y)},${Q(i.x)},${Q(i.y)}" subject="Callout">${Dn(e.text)}${On(e, 14)}${c({ box: a })}</freetext>`;
|
|
7019
7074
|
}
|
|
7020
|
-
case "note": return `<text${s(
|
|
7075
|
+
case "note": return `<text${s(Z(r, {
|
|
7021
7076
|
x: e.x,
|
|
7022
7077
|
y: e.y,
|
|
7023
7078
|
width: 24,
|
|
7024
7079
|
height: 24
|
|
7025
|
-
}))}${$("color", a)} icon="Comment" subject="Sticky Note">${
|
|
7080
|
+
}))}${$("color", a)} icon="Comment" subject="Sticky Note">${Dn(e.text)}${c()}</text>`;
|
|
7026
7081
|
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="${
|
|
7028
|
-
return `<link${s()}${$("color", a)} subject="Link">${n}${
|
|
7082
|
+
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="${un(t)}"/></Action></OnActivation>` : "";
|
|
7083
|
+
return `<link${s()}${$("color", a)} subject="Link">${n}${Dn(e.text)}${c()}</link>`;
|
|
7029
7084
|
}
|
|
7030
|
-
case "signature": return `<stamp${s()} subject="Signature">${e.imageUrl ? `<imagedata>${
|
|
7085
|
+
case "signature": return `<stamp${s()} subject="Signature">${e.imageUrl ? `<imagedata>${un(e.imageUrl)}</imagedata>` : ""}${c({
|
|
7031
7086
|
signer: e.signer,
|
|
7032
7087
|
signType: e.signType,
|
|
7033
7088
|
timestamp: e.timestamp
|
|
@@ -7040,7 +7095,7 @@ async function yn(e, t, n = {}) {
|
|
|
7040
7095
|
default: return "";
|
|
7041
7096
|
}
|
|
7042
7097
|
}
|
|
7043
|
-
function
|
|
7098
|
+
function An(e, t = 0) {
|
|
7044
7099
|
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
7100
|
return {
|
|
7046
7101
|
x: a,
|
|
@@ -7049,21 +7104,21 @@ function bn(e, t = 0) {
|
|
|
7049
7104
|
height: Math.max(...r) - o + i
|
|
7050
7105
|
};
|
|
7051
7106
|
}
|
|
7052
|
-
async function
|
|
7107
|
+
async function jn(e, t, n = {}) {
|
|
7053
7108
|
let r = n.annotList ?? e;
|
|
7054
|
-
return `<?xml version="1.0" encoding="UTF-8"?><xfdf xmlns="${
|
|
7109
|
+
return `<?xml version="1.0" encoding="UTF-8"?><xfdf xmlns="${cn}" xml:space="preserve"><annots>${(await Promise.all(r.map((e) => kn(e, t, n)))).filter(Boolean).join("")}</annots></xfdf>`;
|
|
7055
7110
|
}
|
|
7056
|
-
function
|
|
7111
|
+
function Mn(e) {
|
|
7057
7112
|
let t = {};
|
|
7058
|
-
for (let n of Array.from(e.attributes)) !
|
|
7113
|
+
for (let n of Array.from(e.attributes)) !xn.has(n.name) && !n.name.startsWith("xmlns") && (t[n.name] = n.value);
|
|
7059
7114
|
let n = [];
|
|
7060
|
-
for (let t of Array.from(e.children))
|
|
7115
|
+
for (let t of Array.from(e.children)) Sn.has(t.localName) || n.push(new XMLSerializer().serializeToString(t));
|
|
7061
7116
|
let r = Array.from(e.children).find((e) => e.localName === "trn-custom-data");
|
|
7062
7117
|
if (r) try {
|
|
7063
7118
|
let e = JSON.parse(r.getAttribute("bytes") || "{}");
|
|
7064
7119
|
if (e && typeof e == "object") {
|
|
7065
7120
|
let t = { ...e };
|
|
7066
|
-
delete t[
|
|
7121
|
+
delete t[ln], Object.keys(t).length > 0 && n.push(`<trn-custom-data bytes="${un(JSON.stringify(t))}"/>`);
|
|
7067
7122
|
}
|
|
7068
7123
|
} catch {
|
|
7069
7124
|
n.push(new XMLSerializer().serializeToString(r));
|
|
@@ -7071,11 +7126,11 @@ function Sn(e) {
|
|
|
7071
7126
|
let i = {};
|
|
7072
7127
|
return Object.keys(t).length && (i.attrs = t), n.length && (i.children = n), Object.keys(i).length ? i : void 0;
|
|
7073
7128
|
}
|
|
7074
|
-
function
|
|
7129
|
+
function Nn(e, t) {
|
|
7075
7130
|
return Array.from(e.children).find((e) => e.localName === t)?.textContent ?? void 0;
|
|
7076
7131
|
}
|
|
7077
|
-
function
|
|
7078
|
-
let n =
|
|
7132
|
+
function Pn(e, t) {
|
|
7133
|
+
let n = yn(e.getAttribute("rect")), r = n.length === 4 ? Yt(t, [
|
|
7079
7134
|
n[0],
|
|
7080
7135
|
n[1],
|
|
7081
7136
|
n[2],
|
|
@@ -7085,9 +7140,9 @@ function wn(e, t) {
|
|
|
7085
7140
|
y: 0,
|
|
7086
7141
|
width: 0,
|
|
7087
7142
|
height: 0
|
|
7088
|
-
}, i =
|
|
7143
|
+
}, i = gn(e), a = mn(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
7144
|
return {
|
|
7090
|
-
id: e.getAttribute("name") ||
|
|
7145
|
+
id: e.getAttribute("name") || bt(),
|
|
7091
7146
|
pageIndex: (parseInt(e.getAttribute("page") || "0", 10) || 0) + 1,
|
|
7092
7147
|
x: r.x,
|
|
7093
7148
|
y: r.y,
|
|
@@ -7098,14 +7153,14 @@ function wn(e, t) {
|
|
|
7098
7153
|
opacity: s,
|
|
7099
7154
|
author: e.getAttribute("title") || void 0,
|
|
7100
7155
|
authorId: typeof i.authorId == "string" ? i.authorId : void 0,
|
|
7101
|
-
createdAt:
|
|
7102
|
-
modifiedAt:
|
|
7156
|
+
createdAt: pn(e.getAttribute("creationdate")),
|
|
7157
|
+
modifiedAt: pn(e.getAttribute("date")),
|
|
7103
7158
|
readOnly: d || void 0,
|
|
7104
|
-
xfdfExtras:
|
|
7159
|
+
xfdfExtras: Mn(e)
|
|
7105
7160
|
};
|
|
7106
7161
|
}
|
|
7107
|
-
function
|
|
7108
|
-
let n = e.localName.toLowerCase(), r =
|
|
7162
|
+
function Fn(e, t) {
|
|
7163
|
+
let n = e.localName.toLowerCase(), r = gn(e), i = Pn(e, t), a = () => ({
|
|
7109
7164
|
...i,
|
|
7110
7165
|
type: "opaque",
|
|
7111
7166
|
opaqueKind: n,
|
|
@@ -7122,15 +7177,15 @@ function Tn(e, t) {
|
|
|
7122
7177
|
type: "ellipse"
|
|
7123
7178
|
};
|
|
7124
7179
|
case "line": {
|
|
7125
|
-
let n =
|
|
7180
|
+
let n = yn(e.getAttribute("start")), r = yn(e.getAttribute("end")), o = (e.getAttribute("head") || "None").toLowerCase(), s = (e.getAttribute("tail") || "None").toLowerCase();
|
|
7126
7181
|
if (n.length < 2 || r.length < 2) return a();
|
|
7127
|
-
let [c, l] =
|
|
7182
|
+
let [c, l] = Zt(t, [{
|
|
7128
7183
|
x: n[0],
|
|
7129
7184
|
y: n[1]
|
|
7130
7185
|
}, {
|
|
7131
7186
|
x: r[0],
|
|
7132
7187
|
y: r[1]
|
|
7133
|
-
}]), u =
|
|
7188
|
+
}]), u = An([c, l]), d = o !== "none" || s !== "none";
|
|
7134
7189
|
return {
|
|
7135
7190
|
...i,
|
|
7136
7191
|
...u,
|
|
@@ -7139,24 +7194,24 @@ function Tn(e, t) {
|
|
|
7139
7194
|
};
|
|
7140
7195
|
}
|
|
7141
7196
|
case "ink": {
|
|
7142
|
-
let n = Array.from(e.getElementsByTagName("*")).filter((e) => e.localName === "gesture").map((e) =>
|
|
7197
|
+
let n = Array.from(e.getElementsByTagName("*")).filter((e) => e.localName === "gesture").map((e) => Zt(t, vn(e.textContent))).filter((e) => e.length > 0);
|
|
7143
7198
|
if (n.length === 0) return a();
|
|
7144
7199
|
let r = n.flat();
|
|
7145
7200
|
return {
|
|
7146
7201
|
...i,
|
|
7147
|
-
...
|
|
7202
|
+
...An(r),
|
|
7148
7203
|
type: "freehand",
|
|
7149
7204
|
points: n[0],
|
|
7150
7205
|
strokes: n
|
|
7151
7206
|
};
|
|
7152
7207
|
}
|
|
7153
7208
|
case "highlight": {
|
|
7154
|
-
let n =
|
|
7209
|
+
let n = yn(e.getAttribute("coords")), r = n.length >= 8 ? $t(t, n) : [{
|
|
7155
7210
|
x: i.x,
|
|
7156
7211
|
y: i.y,
|
|
7157
7212
|
width: i.width,
|
|
7158
7213
|
height: i.height
|
|
7159
|
-
}], a =
|
|
7214
|
+
}], a = en(r);
|
|
7160
7215
|
return {
|
|
7161
7216
|
...i,
|
|
7162
7217
|
...a,
|
|
@@ -7166,9 +7221,9 @@ function Tn(e, t) {
|
|
|
7166
7221
|
};
|
|
7167
7222
|
}
|
|
7168
7223
|
case "freetext": {
|
|
7169
|
-
let n =
|
|
7224
|
+
let n = Nn(e, "contents") ?? "", a = e.getAttribute("IT") || "", o = yn(e.getAttribute("callout"));
|
|
7170
7225
|
if (a === "FreeTextCallout" || r.type === "callout" || o.length >= 4) {
|
|
7171
|
-
let e = o.length >= 4 ?
|
|
7226
|
+
let e = o.length >= 4 ? Zt(t, [{
|
|
7172
7227
|
x: o[0],
|
|
7173
7228
|
y: o[1]
|
|
7174
7229
|
}, {
|
|
@@ -7203,7 +7258,7 @@ function Tn(e, t) {
|
|
|
7203
7258
|
case "text": return {
|
|
7204
7259
|
...i,
|
|
7205
7260
|
type: "note",
|
|
7206
|
-
text:
|
|
7261
|
+
text: Nn(e, "contents") ?? "",
|
|
7207
7262
|
width: 24,
|
|
7208
7263
|
height: 24
|
|
7209
7264
|
};
|
|
@@ -7213,7 +7268,7 @@ function Tn(e, t) {
|
|
|
7213
7268
|
...i,
|
|
7214
7269
|
type: "link",
|
|
7215
7270
|
linkUrl: r,
|
|
7216
|
-
text:
|
|
7271
|
+
text: Nn(e, "contents") ?? "",
|
|
7217
7272
|
color: "transparent",
|
|
7218
7273
|
strokeWidth: 0,
|
|
7219
7274
|
opacity: 1,
|
|
@@ -7221,7 +7276,7 @@ function Tn(e, t) {
|
|
|
7221
7276
|
};
|
|
7222
7277
|
}
|
|
7223
7278
|
case "stamp": {
|
|
7224
|
-
let t =
|
|
7279
|
+
let t = Nn(e, "imagedata");
|
|
7225
7280
|
return r.type === "digital_signature_placeholder" ? {
|
|
7226
7281
|
...i,
|
|
7227
7282
|
type: "digital_signature_placeholder",
|
|
@@ -7238,7 +7293,7 @@ function Tn(e, t) {
|
|
|
7238
7293
|
default: return a();
|
|
7239
7294
|
}
|
|
7240
7295
|
}
|
|
7241
|
-
function
|
|
7296
|
+
function In(e) {
|
|
7242
7297
|
let t = "", n = 0;
|
|
7243
7298
|
for (;;) {
|
|
7244
7299
|
let r = e.indexOf("<?xml", n);
|
|
@@ -7249,11 +7304,11 @@ function En(e) {
|
|
|
7249
7304
|
}
|
|
7250
7305
|
return t + e.slice(n);
|
|
7251
7306
|
}
|
|
7252
|
-
async function
|
|
7253
|
-
let n =
|
|
7307
|
+
async function Ln(e, t) {
|
|
7308
|
+
let n = In(e).trim();
|
|
7254
7309
|
if (!n) return [];
|
|
7255
7310
|
if (/<!DOCTYPE|<!ENTITY/i.test(n)) throw Error("[teamsync-pdf-viewer] invalid XFDF: DOCTYPE/ENTITY declarations are not allowed");
|
|
7256
|
-
let r = `<xfdf xmlns="${
|
|
7311
|
+
let r = `<xfdf xmlns="${cn}"><annots>${n}</annots></xfdf>`, i = new DOMParser().parseFromString(r, "application/xml"), a = i.getElementsByTagName("parsererror")[0];
|
|
7257
7312
|
if (a) throw Error(`[teamsync-pdf-viewer] invalid XFDF: ${a.textContent?.slice(0, 200)}`);
|
|
7258
7313
|
let o = /* @__PURE__ */ new Set([
|
|
7259
7314
|
"xfdf",
|
|
@@ -7263,14 +7318,14 @@ async function Dn(e, t) {
|
|
|
7263
7318
|
"ids"
|
|
7264
7319
|
]), s = Array.from(i.getElementsByTagName("*")).filter((e) => e.parentElement?.localName === "annots" && !o.has(e.localName)), c = [];
|
|
7265
7320
|
for (let e of s) {
|
|
7266
|
-
let n =
|
|
7321
|
+
let n = Fn(e, await t((parseInt(e.getAttribute("page") || "0", 10) || 0) + 1));
|
|
7267
7322
|
n && c.push(n);
|
|
7268
7323
|
}
|
|
7269
7324
|
return c;
|
|
7270
7325
|
}
|
|
7271
7326
|
//#endregion
|
|
7272
7327
|
//#region src/annotations/AnnotationManager.ts
|
|
7273
|
-
var
|
|
7328
|
+
var Rn = 100, zn = () => (/* @__PURE__ */ new Date()).toISOString(), Bn = class {
|
|
7274
7329
|
list = [];
|
|
7275
7330
|
past = [];
|
|
7276
7331
|
future = [];
|
|
@@ -7281,7 +7336,7 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
|
|
|
7281
7336
|
canEditOthers = !1;
|
|
7282
7337
|
resolver = null;
|
|
7283
7338
|
setDocument(e) {
|
|
7284
|
-
this.resolver = e ?
|
|
7339
|
+
this.resolver = e ? Y(e) : null;
|
|
7285
7340
|
}
|
|
7286
7341
|
hasDocument() {
|
|
7287
7342
|
return this.resolver !== null;
|
|
@@ -7372,7 +7427,7 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
|
|
|
7372
7427
|
addAnnotations(e, t = {}) {
|
|
7373
7428
|
let n = e.map((e) => ({
|
|
7374
7429
|
...e,
|
|
7375
|
-
id: e.id ??
|
|
7430
|
+
id: e.id ?? bt()
|
|
7376
7431
|
}));
|
|
7377
7432
|
return this.commit([...this.list, ...n], t), n.map((e) => this.getAnnotationById(e.id)).filter((e) => !!e);
|
|
7378
7433
|
}
|
|
@@ -7396,7 +7451,7 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
|
|
|
7396
7451
|
});
|
|
7397
7452
|
}
|
|
7398
7453
|
async importAnnotations(e) {
|
|
7399
|
-
let t = await
|
|
7454
|
+
let t = await Ln(e, this.requireResolver());
|
|
7400
7455
|
if (t.length === 0) return [];
|
|
7401
7456
|
let n = new Map(t.map((e) => [e.id, e])), r = this.list.map((e) => n.get(e.id) ?? e);
|
|
7402
7457
|
for (let e of t) this.list.some((t) => t.id === e.id) || r.push(e);
|
|
@@ -7408,7 +7463,7 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
|
|
|
7408
7463
|
}
|
|
7409
7464
|
async exportAnnotations(e = {}) {
|
|
7410
7465
|
let t = this.requireResolver();
|
|
7411
|
-
return e.annotList ? (await Promise.all(e.annotList.map((n) =>
|
|
7466
|
+
return e.annotList ? (await Promise.all(e.annotList.map((n) => kn(n, t, e)))).join("") : jn(this.list, t, e);
|
|
7412
7467
|
}
|
|
7413
7468
|
exportAnnotationsLegacyJson() {
|
|
7414
7469
|
return JSON.stringify(this.list, null, 2);
|
|
@@ -7432,7 +7487,7 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
|
|
|
7432
7487
|
}
|
|
7433
7488
|
let n = r ? t : {
|
|
7434
7489
|
...t,
|
|
7435
|
-
modifiedAt:
|
|
7490
|
+
modifiedAt: zn()
|
|
7436
7491
|
};
|
|
7437
7492
|
c.push(n), l.push({
|
|
7438
7493
|
before: e,
|
|
@@ -7452,7 +7507,7 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
|
|
|
7452
7507
|
added: s,
|
|
7453
7508
|
modified: l,
|
|
7454
7509
|
deleted: u
|
|
7455
|
-
}), this.past.length >
|
|
7510
|
+
}), this.past.length > Rn && this.past.shift(), this.future = []), this.list = d;
|
|
7456
7511
|
for (let e of Array.from(this.listListeners)) try {
|
|
7457
7512
|
e();
|
|
7458
7513
|
} catch (e) {
|
|
@@ -7474,7 +7529,7 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
|
|
|
7474
7529
|
}
|
|
7475
7530
|
stampNew(e, t) {
|
|
7476
7531
|
if (t) return e;
|
|
7477
|
-
let n = e.createdAt ??
|
|
7532
|
+
let n = e.createdAt ?? zn();
|
|
7478
7533
|
return {
|
|
7479
7534
|
...e,
|
|
7480
7535
|
author: e.author ?? this.user.name,
|
|
@@ -7490,16 +7545,16 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
|
|
|
7490
7545
|
console.error("[teamsync-pdf-viewer] annotationChanged listener threw", e);
|
|
7491
7546
|
}
|
|
7492
7547
|
}
|
|
7493
|
-
},
|
|
7548
|
+
}, Vn = () => {
|
|
7494
7549
|
throw Error("[teamsync-pdf-viewer] viewer is not mounted (was destroy() called?)");
|
|
7495
|
-
},
|
|
7550
|
+
}, Hn = class {
|
|
7496
7551
|
bus;
|
|
7497
7552
|
annotationManager;
|
|
7498
7553
|
element = null;
|
|
7499
7554
|
binding = null;
|
|
7500
7555
|
unmountRoot = null;
|
|
7501
7556
|
destroyed = !1;
|
|
7502
|
-
constructor(e, t = new
|
|
7557
|
+
constructor(e, t = new Bn()) {
|
|
7503
7558
|
this.bus = e, this.annotationManager = t;
|
|
7504
7559
|
}
|
|
7505
7560
|
_bind(e, t) {
|
|
@@ -7535,7 +7590,7 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
|
|
|
7535
7590
|
this.bus.off(e, t);
|
|
7536
7591
|
}
|
|
7537
7592
|
loadDocument(e) {
|
|
7538
|
-
let t = this.binding ??
|
|
7593
|
+
let t = this.binding ?? Vn();
|
|
7539
7594
|
return new Promise((n, r) => {
|
|
7540
7595
|
let i = this.bus.on("documentLoaded", (t) => {
|
|
7541
7596
|
t.url === e && (o(), n(t));
|
|
@@ -7573,7 +7628,7 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
|
|
|
7573
7628
|
let t = this.getPdfDocument();
|
|
7574
7629
|
if (!t) return [];
|
|
7575
7630
|
let n = this.binding;
|
|
7576
|
-
return
|
|
7631
|
+
return tt(t, e, n ? n.getRedactions() : []);
|
|
7577
7632
|
}
|
|
7578
7633
|
getTransientHighlights() {
|
|
7579
7634
|
return this.binding?.getTransientHighlights() ?? [];
|
|
@@ -7610,16 +7665,16 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
|
|
|
7610
7665
|
this.bus.emit("action-print");
|
|
7611
7666
|
}
|
|
7612
7667
|
async getFileData(e = {}) {
|
|
7613
|
-
let t = this.binding ??
|
|
7668
|
+
let t = this.binding ?? Vn(), n = t.getPdfDocument(), r = t.getDocumentUrl();
|
|
7614
7669
|
if (!n && !r) throw Error("No document loaded");
|
|
7615
|
-
return
|
|
7670
|
+
return sn({
|
|
7616
7671
|
getSourceBytes: async () => {
|
|
7617
7672
|
if (n) return n.getData();
|
|
7618
7673
|
let e = await fetch(r);
|
|
7619
7674
|
if (!e.ok) throw Error(`Failed to fetch document (${e.status})`);
|
|
7620
7675
|
return e.arrayBuffer();
|
|
7621
7676
|
},
|
|
7622
|
-
getPageGeometry: n ?
|
|
7677
|
+
getPageGeometry: n ? Y(n) : void 0,
|
|
7623
7678
|
annotations: this.annotationManager.getAnnotationsList(),
|
|
7624
7679
|
redactions: t.getRedactions(),
|
|
7625
7680
|
watermark: t.getWatermark(),
|
|
@@ -7678,7 +7733,7 @@ var On = 100, kn = () => (/* @__PURE__ */ new Date()).toISOString(), An = class
|
|
|
7678
7733
|
};
|
|
7679
7734
|
//#endregion
|
|
7680
7735
|
//#region src/core/print.ts
|
|
7681
|
-
async function
|
|
7736
|
+
async function Un(e, t = {}) {
|
|
7682
7737
|
if (typeof document > "u") throw Error("[teamsync-pdf-viewer] printing needs a browser");
|
|
7683
7738
|
let n = new Blob([e], { type: "application/pdf" }), r = URL.createObjectURL(n), i = document.createElement("iframe");
|
|
7684
7739
|
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 +7758,11 @@ async function Nn(e, t = {}) {
|
|
|
7703
7758
|
}
|
|
7704
7759
|
//#endregion
|
|
7705
7760
|
//#region src/components/TeamSyncViewer.tsx
|
|
7706
|
-
var
|
|
7761
|
+
var Wn = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, Gn = e.forwardRef(function(e, t) {
|
|
7707
7762
|
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
7763
|
E.current = e;
|
|
7709
|
-
let D = s(null), O = o(() => new
|
|
7710
|
-
se.current ||= new
|
|
7764
|
+
let D = s(null), O = o(() => new Ut(), []), k = o(() => new Bn(), []), se = s(null);
|
|
7765
|
+
se.current ||= new Hn(O, k);
|
|
7711
7766
|
let A = se.current;
|
|
7712
7767
|
a(t, () => A, [A]);
|
|
7713
7768
|
let ce = r ?? l, [le, ue] = c(ce), [de, fe] = c(0);
|
|
@@ -7811,7 +7866,7 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
|
|
|
7811
7866
|
O.on("action-tool-changed", (e) => O.emit("toolChanged", { tool: e?.tool ?? null })),
|
|
7812
7867
|
O.on("action-print", async () => {
|
|
7813
7868
|
try {
|
|
7814
|
-
await
|
|
7869
|
+
await Un(await A.getFileData(), { title: E.current.fileName });
|
|
7815
7870
|
} catch (e) {
|
|
7816
7871
|
console.error("[teamsync-pdf-viewer] print failed", e), O.emit("action-print-error", { error: e });
|
|
7817
7872
|
}
|
|
@@ -7829,7 +7884,7 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
|
|
|
7829
7884
|
O.on("action-process-digital-signature", async (e) => {
|
|
7830
7885
|
try {
|
|
7831
7886
|
let { pageIndex: t, x: n, y: r, width: i, height: a } = e, o = {
|
|
7832
|
-
id:
|
|
7887
|
+
id: Wn(),
|
|
7833
7888
|
type: "digital_signature_placeholder",
|
|
7834
7889
|
pageIndex: t,
|
|
7835
7890
|
x: n,
|
|
@@ -7907,24 +7962,24 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
|
|
|
7907
7962
|
pageNumber: e,
|
|
7908
7963
|
numPages: t
|
|
7909
7964
|
}), E.current.onPageChange?.(e, t);
|
|
7910
|
-
}, [O]), H = n((e) => {
|
|
7911
|
-
O.emit("annotationsChanged", { annotations: e }), E.current.onAnnotationsChange?.(e);
|
|
7912
7965
|
}, [O]), Ye = n((e) => {
|
|
7966
|
+
O.emit("annotationsChanged", { annotations: e }), E.current.onAnnotationsChange?.(e);
|
|
7967
|
+
}, [O]), Xe = n((e) => {
|
|
7913
7968
|
z.current = e;
|
|
7914
|
-
}, []), { getCommand:
|
|
7969
|
+
}, []), { getCommand: Ze } = Qe(), $e = s(null), tt = n(() => {
|
|
7915
7970
|
w && (j(!0), be("Search"), setTimeout(() => O.emit("action-focus-search"), 50));
|
|
7916
|
-
}, [w, O]),
|
|
7917
|
-
|
|
7971
|
+
}, [w, O]), nt = n(() => {
|
|
7972
|
+
$e.current?.click();
|
|
7918
7973
|
}, []);
|
|
7919
7974
|
return i(() => {
|
|
7920
|
-
let e = O.on("action-open-search",
|
|
7975
|
+
let e = O.on("action-open-search", tt), t = O.on("action-open-file-picker", nt);
|
|
7921
7976
|
return () => {
|
|
7922
7977
|
e(), t();
|
|
7923
7978
|
};
|
|
7924
7979
|
}, [
|
|
7925
7980
|
O,
|
|
7926
|
-
|
|
7927
|
-
|
|
7981
|
+
tt,
|
|
7982
|
+
nt
|
|
7928
7983
|
]), i(() => {
|
|
7929
7984
|
D.current && (document.activeElement === document.body || !document.activeElement) && D.current.focus({ preventScroll: !0 });
|
|
7930
7985
|
}, []), i(() => {
|
|
@@ -7933,12 +7988,12 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
|
|
|
7933
7988
|
if (t?.tagName === "INPUT" || t?.tagName === "TEXTAREA" || t?.isContentEditable) return;
|
|
7934
7989
|
let n = D.current;
|
|
7935
7990
|
if (n && (document.activeElement === document.body || document.activeElement === document.documentElement || document.activeElement === null || n.contains(document.activeElement)) && !n.contains(document.activeElement)) {
|
|
7936
|
-
if (
|
|
7937
|
-
e.preventDefault(),
|
|
7991
|
+
if (et(e, Ze("SEARCH"))) {
|
|
7992
|
+
e.preventDefault(), tt();
|
|
7938
7993
|
return;
|
|
7939
7994
|
}
|
|
7940
|
-
if (
|
|
7941
|
-
e.preventDefault(),
|
|
7995
|
+
if (et(e, Ze("FILE_PICKER"))) {
|
|
7996
|
+
e.preventDefault(), nt();
|
|
7942
7997
|
return;
|
|
7943
7998
|
}
|
|
7944
7999
|
O.emit("viewer-keydown", e);
|
|
@@ -7949,9 +8004,9 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
|
|
|
7949
8004
|
};
|
|
7950
8005
|
}, [
|
|
7951
8006
|
O,
|
|
7952
|
-
|
|
7953
|
-
|
|
7954
|
-
|
|
8007
|
+
Ze,
|
|
8008
|
+
tt,
|
|
8009
|
+
nt
|
|
7955
8010
|
]), /* @__PURE__ */ F(Ie.Provider, {
|
|
7956
8011
|
value: O,
|
|
7957
8012
|
children: /* @__PURE__ */ I("div", {
|
|
@@ -7961,12 +8016,12 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
|
|
|
7961
8016
|
tabIndex: -1,
|
|
7962
8017
|
"data-teamsync-pdf-viewer": "",
|
|
7963
8018
|
onKeyDownCapture: (e) => {
|
|
7964
|
-
if (
|
|
7965
|
-
e.preventDefault(),
|
|
8019
|
+
if (et(e.nativeEvent, Ze("SEARCH"))) {
|
|
8020
|
+
e.preventDefault(), tt();
|
|
7966
8021
|
return;
|
|
7967
8022
|
}
|
|
7968
|
-
if (
|
|
7969
|
-
e.preventDefault(),
|
|
8023
|
+
if (et(e.nativeEvent, Ze("FILE_PICKER"))) {
|
|
8024
|
+
e.preventDefault(), nt();
|
|
7970
8025
|
return;
|
|
7971
8026
|
}
|
|
7972
8027
|
O.emit("viewer-keydown", e.nativeEvent);
|
|
@@ -7989,10 +8044,10 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
|
|
|
7989
8044
|
setRightSidebarOpen: j,
|
|
7990
8045
|
sidebarTab: ye,
|
|
7991
8046
|
scale: M,
|
|
7992
|
-
onZoomIn: () => xe((e) =>
|
|
7993
|
-
onZoomOut: () => xe((e) =>
|
|
7994
|
-
onZoomSet: (e) => xe(
|
|
7995
|
-
onOpenFile:
|
|
8047
|
+
onZoomIn: () => xe((e) => U(e)),
|
|
8048
|
+
onZoomOut: () => xe((e) => W(e)),
|
|
8049
|
+
onZoomSet: (e) => xe(gt(e)),
|
|
8050
|
+
onOpenFile: nt,
|
|
7996
8051
|
onDownload: () => O.emit("action-download"),
|
|
7997
8052
|
onFullScreen: () => {
|
|
7998
8053
|
let e = D.current ?? document.documentElement;
|
|
@@ -8017,7 +8072,7 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
|
|
|
8017
8072
|
permissions: P
|
|
8018
8073
|
}),
|
|
8019
8074
|
/* @__PURE__ */ F("input", {
|
|
8020
|
-
ref:
|
|
8075
|
+
ref: $e,
|
|
8021
8076
|
type: "file",
|
|
8022
8077
|
accept: "application/pdf",
|
|
8023
8078
|
style: { display: "none" },
|
|
@@ -8038,7 +8093,7 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
|
|
|
8038
8093
|
minHeight: 0,
|
|
8039
8094
|
overflow: "hidden"
|
|
8040
8095
|
},
|
|
8041
|
-
children: /* @__PURE__ */ F(
|
|
8096
|
+
children: /* @__PURE__ */ F(q, {
|
|
8042
8097
|
leftSidebarOpen: w && ge,
|
|
8043
8098
|
rightSidebarOpen: w && ve,
|
|
8044
8099
|
sidebarTab: ye,
|
|
@@ -8054,8 +8109,8 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
|
|
|
8054
8109
|
regexRedactions: g,
|
|
8055
8110
|
scale: M,
|
|
8056
8111
|
setScale: xe,
|
|
8057
|
-
onAnnotationsChange:
|
|
8058
|
-
onRedactionsChange:
|
|
8112
|
+
onAnnotationsChange: Ye,
|
|
8113
|
+
onRedactionsChange: Xe,
|
|
8059
8114
|
onDocumentLoaded: Ge,
|
|
8060
8115
|
onLoadError: Ke,
|
|
8061
8116
|
onFirstPageRendered: qe,
|
|
@@ -8073,22 +8128,22 @@ var Pn = .1, Fn = 64, In = () => typeof crypto < "u" && "randomUUID" in crypto ?
|
|
|
8073
8128
|
permissions: P
|
|
8074
8129
|
})
|
|
8075
8130
|
}),
|
|
8076
|
-
Se && /* @__PURE__ */ F(
|
|
8131
|
+
Se && /* @__PURE__ */ F(Vt, {
|
|
8077
8132
|
onClose: () => Ce(!1),
|
|
8078
8133
|
watermarkText: je,
|
|
8079
8134
|
setWatermarkText: Me
|
|
8080
8135
|
}),
|
|
8081
|
-
N && /* @__PURE__ */ F(
|
|
8136
|
+
N && /* @__PURE__ */ F(Ht, { onClose: () => we(!1) })
|
|
8082
8137
|
]
|
|
8083
8138
|
})
|
|
8084
8139
|
});
|
|
8085
8140
|
});
|
|
8086
8141
|
//#endregion
|
|
8087
8142
|
//#region src/core/createWebViewer.tsx
|
|
8088
|
-
function
|
|
8143
|
+
function Kn(e, t) {
|
|
8089
8144
|
return typeof window > "u" || typeof document > "u" ? Promise.reject(/* @__PURE__ */ Error("[teamsync-pdf-viewer] createWebViewer() requires a browser environment.")) : t ? new Promise((n) => {
|
|
8090
8145
|
let r = u.createRoot(t), { path: i, ...a } = e;
|
|
8091
|
-
r.render(/* @__PURE__ */ F(
|
|
8146
|
+
r.render(/* @__PURE__ */ F(Gn, {
|
|
8092
8147
|
...a,
|
|
8093
8148
|
style: {
|
|
8094
8149
|
width: "100%",
|
|
@@ -8100,8 +8155,8 @@ function Rn(e, t) {
|
|
|
8100
8155
|
}));
|
|
8101
8156
|
}) : Promise.reject(/* @__PURE__ */ Error("[teamsync-pdf-viewer] createWebViewer() needs a container element."));
|
|
8102
8157
|
}
|
|
8103
|
-
var
|
|
8158
|
+
var qn = Kn;
|
|
8104
8159
|
//#endregion
|
|
8105
|
-
export {
|
|
8160
|
+
export { Bn as AnnotationManager, tn as MAX_EXPORT_BYTES, ft as MAX_SCALE, dt as MIN_SCALE, Gn as TeamSyncViewer, Ut as ViewerBus, qn as WebViewer, Hn as WebViewerInstance, cn as XFDF_NS, kn as annotationToXfdfFragment, jn as annotationsToXfdf, sn as buildPdfBytes, U as calculateNextZoomIn, W as calculateNextZoomOut, gt as clampScale, zt as computeCanvasPixelDiff, Pt as computePageDiffBoxes, Lt as computeTextDiff, St as configurePdfAssets, Y as createGeometryResolver, Kt as createPageGeometry, Kn as createWebViewer, Nt as extractWordsFromPage, pn as fromPdfDate, Jt as fromPdfPoint, qt as geometryFromPage, Ct as getPdfAssetPaths, wt as isWorkerConfigured, bt as newAnnotationId, Ln as parseXfdf, Dt as pdfjsVersion, Un as printPdfBytes, $t as quadPointsToRects, Yt as rectFromPdf, Z as rectToPdf, Qt as rectToQuadPoints, tt as searchPdfText, K as tintCanvas, fn as toPdfDate, X as toPdfPoint, nt as usePdfSearch };
|
|
8106
8161
|
|
|
8107
8162
|
//# sourceMappingURL=teamsync-pdf-viewer.js.map
|