teamsync-pdf-viewer 1.5.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1142,19 +1142,85 @@ function gt(e, t) {
|
|
|
1142
1142
|
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}`);
|
|
1143
1143
|
}
|
|
1144
1144
|
//#endregion
|
|
1145
|
+
//#region src/utils/pageText.ts
|
|
1146
|
+
function _t(e) {
|
|
1147
|
+
return e.replace(/\s+/g, " ").trim();
|
|
1148
|
+
}
|
|
1149
|
+
function vt(e) {
|
|
1150
|
+
let t = "", n = [], r = [];
|
|
1151
|
+
e.forEach((e, i) => {
|
|
1152
|
+
let a = e.str ?? "";
|
|
1153
|
+
for (let e = 0; e < a.length; e++) n.push(i), r.push(e);
|
|
1154
|
+
t += a, e.hasEOL ? (t += "\n", n.push(-1), r.push(-1)) : (t += " ", n.push(-1), r.push(-1));
|
|
1155
|
+
});
|
|
1156
|
+
let i = "", a = [], o = 0;
|
|
1157
|
+
for (; o < t.length;) {
|
|
1158
|
+
let e = t[o];
|
|
1159
|
+
if (/\s/.test(e)) {
|
|
1160
|
+
let e = o;
|
|
1161
|
+
for (; o < t.length && /\s/.test(t[o]);) o++;
|
|
1162
|
+
i += " ", a.push(e);
|
|
1163
|
+
} else i += e, a.push(o), o++;
|
|
1164
|
+
}
|
|
1165
|
+
return {
|
|
1166
|
+
fullText: t,
|
|
1167
|
+
itemIndices: n,
|
|
1168
|
+
charIndices: r,
|
|
1169
|
+
normText: i,
|
|
1170
|
+
normToRaw: a
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
function yt(e, t, n, r) {
|
|
1174
|
+
let { itemIndices: i, charIndices: a } = t, o = /* @__PURE__ */ new Map();
|
|
1175
|
+
for (let e = n; e < r; e++) {
|
|
1176
|
+
let t = i[e], n = a[e];
|
|
1177
|
+
if (t !== void 0 && t !== -1) {
|
|
1178
|
+
let e = o.get(t);
|
|
1179
|
+
e ? (e.min = Math.min(e.min, n), e.max = Math.max(e.max, n)) : o.set(t, {
|
|
1180
|
+
min: n,
|
|
1181
|
+
max: n
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
let s = [];
|
|
1186
|
+
return o.forEach((t, n) => {
|
|
1187
|
+
let r = e[n];
|
|
1188
|
+
if (!r || !r.transform) return;
|
|
1189
|
+
let i = r.transform[4], a = r.transform[5], o = r.width, c = r.height || Math.abs(r.transform[3]), l = (r.str ?? "").length;
|
|
1190
|
+
if (l > 0) {
|
|
1191
|
+
let e = o / l, n = i + t.min * e, r = (t.max - t.min + 1) * e;
|
|
1192
|
+
s.push({
|
|
1193
|
+
x: n,
|
|
1194
|
+
y: a,
|
|
1195
|
+
width: r,
|
|
1196
|
+
height: c
|
|
1197
|
+
});
|
|
1198
|
+
} else s.push({
|
|
1199
|
+
x: i,
|
|
1200
|
+
y: a,
|
|
1201
|
+
width: o,
|
|
1202
|
+
height: c
|
|
1203
|
+
});
|
|
1204
|
+
}), s;
|
|
1205
|
+
}
|
|
1206
|
+
//#endregion
|
|
1145
1207
|
//#region src/hooks/usePdfSearch.ts
|
|
1146
|
-
async function
|
|
1208
|
+
async function bt(e, t, n = [], r, i) {
|
|
1147
1209
|
if (!e || !t.trim()) return [];
|
|
1148
|
-
let
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1210
|
+
let a = [], o = _t(t).toLowerCase();
|
|
1211
|
+
if (!o) return [];
|
|
1212
|
+
let s = e.numPages, c;
|
|
1213
|
+
if (i !== void 0) {
|
|
1214
|
+
if (c = Array.from(new Set(i)).filter((e) => Number.isInteger(e) && e >= 1 && e <= s).sort((e, t) => e - t), c.length === 0) return r?.(100), [];
|
|
1215
|
+
} else c = Array.from({ length: s }, (e, t) => t + 1);
|
|
1216
|
+
for (let t = 0; t < c.length; t += 10) {
|
|
1217
|
+
let i = c.slice(t, t + 10), s = i.map((t) => (async () => {
|
|
1218
|
+
let r = await e.getPage(t), i = (await r.getTextContent()).items;
|
|
1153
1219
|
if (n && n.length > 0) {
|
|
1154
|
-
let e = n.filter((e) => e.pageIndex ===
|
|
1220
|
+
let e = n.filter((e) => e.pageIndex === t);
|
|
1155
1221
|
if (e.length > 0) {
|
|
1156
|
-
let t =
|
|
1157
|
-
|
|
1222
|
+
let t = r.getViewport({ scale: 1 });
|
|
1223
|
+
i = i.filter((n) => {
|
|
1158
1224
|
if (!n.str || n.str.trim() === "") return !0;
|
|
1159
1225
|
let r = n.transform[4], i = n.transform[5], a = n.width, o = n.height || Math.abs(n.transform[3]), s = t.height - i - o;
|
|
1160
1226
|
for (let t of e) {
|
|
@@ -1165,62 +1231,25 @@ async function _t(e, t, n = [], r) {
|
|
|
1165
1231
|
});
|
|
1166
1232
|
}
|
|
1167
1233
|
}
|
|
1168
|
-
let s =
|
|
1169
|
-
|
|
1170
|
-
let n = e.
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
for (let e = d; e < d + t.length; e++) {
|
|
1180
|
-
let t = c[e], n = l[e];
|
|
1181
|
-
if (t !== void 0 && t !== -1) {
|
|
1182
|
-
let e = a.get(t);
|
|
1183
|
-
e ? (e.min = Math.min(e.min, n), e.max = Math.max(e.max, n)) : a.set(t, {
|
|
1184
|
-
min: n,
|
|
1185
|
-
max: n
|
|
1186
|
-
});
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
let u = [];
|
|
1190
|
-
a.forEach((e, t) => {
|
|
1191
|
-
let n = o[t];
|
|
1192
|
-
if (!n || !n.transform) return;
|
|
1193
|
-
let r = n.transform[4], i = n.transform[5], a = n.width, s = n.height || Math.abs(n.transform[3]), c = n.str.length;
|
|
1194
|
-
if (c > 0) {
|
|
1195
|
-
let t = a / c, n = r + e.min * t, o = (e.max - e.min + 1) * t;
|
|
1196
|
-
u.push({
|
|
1197
|
-
x: n,
|
|
1198
|
-
y: i,
|
|
1199
|
-
width: o,
|
|
1200
|
-
height: s
|
|
1201
|
-
});
|
|
1202
|
-
} else u.push({
|
|
1203
|
-
x: r,
|
|
1204
|
-
y: i,
|
|
1205
|
-
width: a,
|
|
1206
|
-
height: s
|
|
1207
|
-
});
|
|
1208
|
-
}), f.push({
|
|
1209
|
-
id: `p${r}-idx${d}`,
|
|
1210
|
-
pageIndex: r,
|
|
1211
|
-
snippet: i,
|
|
1212
|
-
matchStartIndex: d - e,
|
|
1213
|
-
matchLength: t.length,
|
|
1214
|
-
bounds: u
|
|
1215
|
-
}), d += t.length;
|
|
1234
|
+
let a = vt(i), { fullText: s, normText: c, normToRaw: l } = a, u = c.toLowerCase(), d = 0, f = [];
|
|
1235
|
+
for (; (d = u.indexOf(o, d)) !== -1;) {
|
|
1236
|
+
let e = l[d], n = l[d + o.length - 1] + 1, r = Math.max(0, e - 30), c = Math.min(s.length, n + 30), u = s.substring(r, c).replace(/\n/g, " "), p = yt(i, a, e, n);
|
|
1237
|
+
f.push({
|
|
1238
|
+
id: `p${t}-idx${e}`,
|
|
1239
|
+
pageIndex: t,
|
|
1240
|
+
snippet: u,
|
|
1241
|
+
matchStartIndex: e - r,
|
|
1242
|
+
matchLength: n - e,
|
|
1243
|
+
bounds: p
|
|
1244
|
+
}), d += o.length;
|
|
1216
1245
|
}
|
|
1217
|
-
return
|
|
1246
|
+
return r.cleanup?.(), f;
|
|
1218
1247
|
})());
|
|
1219
|
-
(await Promise.all(
|
|
1248
|
+
(await Promise.all(s)).forEach((e) => a.push(...e)), r?.(Math.round((t + i.length) / c.length * 100)), await new Promise((e) => setTimeout(e, 10));
|
|
1220
1249
|
}
|
|
1221
|
-
return
|
|
1250
|
+
return a.sort((e, t) => e.pageIndex - t.pageIndex), a;
|
|
1222
1251
|
}
|
|
1223
|
-
function
|
|
1252
|
+
function xt(e, t = []) {
|
|
1224
1253
|
let [r, i] = c(!1), [a, o] = c([]), [s, l] = c(0);
|
|
1225
1254
|
return {
|
|
1226
1255
|
search: n(async (n) => {
|
|
@@ -1230,7 +1259,7 @@ function vt(e, t = []) {
|
|
|
1230
1259
|
}
|
|
1231
1260
|
i(!0), l(0);
|
|
1232
1261
|
try {
|
|
1233
|
-
let r = await
|
|
1262
|
+
let r = await bt(e, n, t, (e) => l(e));
|
|
1234
1263
|
o(r);
|
|
1235
1264
|
} catch (e) {
|
|
1236
1265
|
console.error("Search error:", e);
|
|
@@ -1246,7 +1275,7 @@ function vt(e, t = []) {
|
|
|
1246
1275
|
}
|
|
1247
1276
|
//#endregion
|
|
1248
1277
|
//#region src/components/Sidebar.tsx
|
|
1249
|
-
function
|
|
1278
|
+
function St({ isOpen: e, annotations: t, setAnnotations: n, selectedAnnotationId: r, setSelectedAnnotationId: a, onSearch: o, searchResults: l, isSearching: u, searchProgress: d, onResultClick: f, activeTab: p, setActiveTab: m }) {
|
|
1250
1279
|
let [h, g] = c(""), [_, v] = c(320), [y, b] = c(!1), x = s(null);
|
|
1251
1280
|
i(() => {
|
|
1252
1281
|
let e = (e) => {
|
|
@@ -1627,7 +1656,7 @@ function yt({ isOpen: e, annotations: t, setAnnotations: n, selectedAnnotationId
|
|
|
1627
1656
|
}
|
|
1628
1657
|
//#endregion
|
|
1629
1658
|
//#region src/components/LeftSidebar.tsx
|
|
1630
|
-
var
|
|
1659
|
+
var Ct = ({ pdfDoc: e, pageIndex: t, isActive: n, onClick: r, scale: a }) => {
|
|
1631
1660
|
let o = s(null), l = s(null), [u, d] = c(!1), [f, p] = c(.77);
|
|
1632
1661
|
i(() => {
|
|
1633
1662
|
let e = new IntersectionObserver((e) => {
|
|
@@ -1716,7 +1745,7 @@ var bt = ({ pdfDoc: e, pageIndex: t, isActive: n, onClick: r, scale: a }) => {
|
|
|
1716
1745
|
})]
|
|
1717
1746
|
});
|
|
1718
1747
|
};
|
|
1719
|
-
function
|
|
1748
|
+
function wt({ isOpen: e, pdfDoc: t, pageNum: n, setPageNum: r }) {
|
|
1720
1749
|
let [a, o] = c("Thumbnails"), [s, l] = c(250), [u, d] = c(!1), [f, m] = c(30), h = .1 + f / 100 * .3;
|
|
1721
1750
|
i(() => {
|
|
1722
1751
|
let e = (e) => {
|
|
@@ -1867,7 +1896,7 @@ function xt({ isOpen: e, pdfDoc: t, pageNum: n, setPageNum: r }) {
|
|
|
1867
1896
|
padding: "8px 0",
|
|
1868
1897
|
backgroundColor: "#f1f1f1"
|
|
1869
1898
|
},
|
|
1870
|
-
children: [t && v.map((e) => /* @__PURE__ */ I(
|
|
1899
|
+
children: [t && v.map((e) => /* @__PURE__ */ I(Ct, {
|
|
1871
1900
|
pdfDoc: t,
|
|
1872
1901
|
pageIndex: e,
|
|
1873
1902
|
isActive: e === n,
|
|
@@ -1959,7 +1988,7 @@ function xt({ isOpen: e, pdfDoc: t, pageNum: n, setPageNum: r }) {
|
|
|
1959
1988
|
}
|
|
1960
1989
|
//#endregion
|
|
1961
1990
|
//#region src/utils/rotationUtils.ts
|
|
1962
|
-
function
|
|
1991
|
+
function Tt(e, t, n, r, i) {
|
|
1963
1992
|
let a = (n % 360 + 360) % 360;
|
|
1964
1993
|
return a === 90 ? {
|
|
1965
1994
|
x: t,
|
|
@@ -1975,7 +2004,7 @@ function St(e, t, n, r, i) {
|
|
|
1975
2004
|
y: t
|
|
1976
2005
|
};
|
|
1977
2006
|
}
|
|
1978
|
-
function
|
|
2007
|
+
function Et(e, t, n, r, i) {
|
|
1979
2008
|
let a = (n % 360 + 360) % 360;
|
|
1980
2009
|
return a === 90 ? {
|
|
1981
2010
|
x: i - t,
|
|
@@ -1991,7 +2020,7 @@ function Ct(e, t, n, r, i) {
|
|
|
1991
2020
|
y: t
|
|
1992
2021
|
};
|
|
1993
2022
|
}
|
|
1994
|
-
function
|
|
2023
|
+
function Dt(e, t, n, r, i, a, o) {
|
|
1995
2024
|
let s = (i % 360 + 360) % 360;
|
|
1996
2025
|
return s === 90 ? {
|
|
1997
2026
|
x: o - (t + r),
|
|
@@ -2015,18 +2044,18 @@ function wt(e, t, n, r, i, a, o) {
|
|
|
2015
2044
|
height: r
|
|
2016
2045
|
};
|
|
2017
2046
|
}
|
|
2018
|
-
function
|
|
2047
|
+
function Ot(e, t, n) {
|
|
2019
2048
|
let r = (e % 360 + 360) % 360;
|
|
2020
2049
|
if (r === 90) return `translate(${n}, 0) rotate(90)`;
|
|
2021
2050
|
if (r === 180) return `translate(${t}, ${n}) rotate(180)`;
|
|
2022
2051
|
if (r === 270) return `translate(0, ${t}) rotate(270)`;
|
|
2023
2052
|
}
|
|
2024
|
-
function
|
|
2053
|
+
function kt(e) {
|
|
2025
2054
|
return (e % 360 + 360) % 360;
|
|
2026
2055
|
}
|
|
2027
2056
|
//#endregion
|
|
2028
2057
|
//#region src/components/PageRenderer.tsx
|
|
2029
|
-
function
|
|
2058
|
+
function At({ 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: te, onAnnotationClick: ne, onAnnotationDoubleClick: re, onStartResize: ie, onStartMove: ae, onAnnotationMouseEnter: oe, onClearSelection: se, watermark: ce, watermarkText: le, redactions: C, onDiscardRedaction: ue, onRendered: de, hideAnnotationsUntilPageRendered: fe = !0 }) {
|
|
2030
2059
|
let w = s(de);
|
|
2031
2060
|
i(() => {
|
|
2032
2061
|
w.current = de;
|
|
@@ -2065,7 +2094,7 @@ function Dt({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2065
2094
|
return;
|
|
2066
2095
|
}
|
|
2067
2096
|
i = o, O.current = o;
|
|
2068
|
-
let s = Math.min(window.devicePixelRatio || 1, 2), c =
|
|
2097
|
+
let s = Math.min(window.devicePixelRatio || 1, 2), c = kt(o.rotate + a), l = o.getViewport({
|
|
2069
2098
|
scale: 1,
|
|
2070
2099
|
rotation: c
|
|
2071
2100
|
}), u = et(r, s, l.width, l.height), d = o.getViewport({
|
|
@@ -2090,7 +2119,7 @@ function Dt({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2090
2119
|
p.save(), p.setTransform(1, 0, 0, 1, 0, 0);
|
|
2091
2120
|
let e = a % 180 == 0 ? m : h, n = a % 180 == 0 ? h : m;
|
|
2092
2121
|
for (let i of C) if (i.pageIndex === t) {
|
|
2093
|
-
let t =
|
|
2122
|
+
let t = Dt(i.x, i.y, i.width, i.height, a, e, n), o = t.x * u, s = t.y * u, c = t.width * u, l = t.height * u;
|
|
2094
2123
|
i.status === "applied" || i.status === void 0 ? (p.fillStyle = "#000000", p.fillRect(Math.floor(o), Math.floor(s), Math.ceil(c), Math.ceil(l))) : (p.fillStyle = "rgba(0, 0, 0, 0.45)", p.fillRect(Math.floor(o), Math.floor(s), Math.ceil(c), Math.ceil(l)), p.lineWidth = Math.max(1, u / (r || 1) * 2), p.strokeStyle = "#dc2626", p.strokeRect(Math.floor(o), Math.floor(s), Math.ceil(c), Math.ceil(l)));
|
|
2095
2124
|
}
|
|
2096
2125
|
p.restore();
|
|
@@ -2194,7 +2223,7 @@ function Dt({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2194
2223
|
if (r) return;
|
|
2195
2224
|
let o = i.getViewport({
|
|
2196
2225
|
scale: 1,
|
|
2197
|
-
rotation:
|
|
2226
|
+
rotation: kt(i.rotate + a)
|
|
2198
2227
|
}), s = he;
|
|
2199
2228
|
if (C && C.length > 0) {
|
|
2200
2229
|
let e = C.filter((e) => e.pageIndex === t);
|
|
@@ -2295,7 +2324,7 @@ function Dt({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2295
2324
|
children: [
|
|
2296
2325
|
/* @__PURE__ */ I("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 " }),
|
|
2297
2326
|
b && b.pageIndex === t && b.bounds.map((e, t) => {
|
|
2298
|
-
let o =
|
|
2327
|
+
let o = Dt(e.x, i - e.y - e.height, e.width, e.height, a, n, i);
|
|
2299
2328
|
return /* @__PURE__ */ I("div", { style: {
|
|
2300
2329
|
position: "absolute",
|
|
2301
2330
|
left: `${o.x * r}px`,
|
|
@@ -2309,7 +2338,7 @@ function Dt({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2309
2338
|
} }, `search-${t}`);
|
|
2310
2339
|
}),
|
|
2311
2340
|
x && x.filter((e) => e.pageIndex === t).map((t, o) => /* @__PURE__ */ I(e.Fragment, { children: t.bounds.map((e, o) => {
|
|
2312
|
-
let s =
|
|
2341
|
+
let s = Dt(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)";
|
|
2313
2342
|
return /* @__PURE__ */ I("div", {
|
|
2314
2343
|
style: {
|
|
2315
2344
|
position: "absolute",
|
|
@@ -2350,7 +2379,7 @@ function Dt({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2350
2379
|
});
|
|
2351
2380
|
})(),
|
|
2352
2381
|
(() => {
|
|
2353
|
-
let n =
|
|
2382
|
+
let n = Ot(a, a % 180 == 0 ? m : h, a % 180 == 0 ? h : m);
|
|
2354
2383
|
return /* @__PURE__ */ I("svg", {
|
|
2355
2384
|
style: {
|
|
2356
2385
|
position: "absolute",
|
|
@@ -2925,17 +2954,17 @@ function Dt({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2925
2954
|
]
|
|
2926
2955
|
});
|
|
2927
2956
|
}
|
|
2928
|
-
var
|
|
2957
|
+
var jt = e.memo(At, (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 && e.hideAnnotationsUntilPageRendered === t.hideAnnotationsUntilPageRendered);
|
|
2929
2958
|
//#endregion
|
|
2930
2959
|
//#region src/annotations/ids.ts
|
|
2931
|
-
function
|
|
2960
|
+
function Mt() {
|
|
2932
2961
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
2933
2962
|
let e = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
|
2934
2963
|
return `${e.slice(0, 8)}-${e.slice(8, 12)}-4${e.slice(13, 16)}-a${e.slice(17, 20)}-${e.slice(20, 32)}`;
|
|
2935
2964
|
}
|
|
2936
2965
|
//#endregion
|
|
2937
2966
|
//#region src/utils/clipboardUtils.ts
|
|
2938
|
-
async function
|
|
2967
|
+
async function Nt(e) {
|
|
2939
2968
|
if (!e) return !1;
|
|
2940
2969
|
if (typeof navigator < "u" && navigator.clipboard && typeof navigator.clipboard.writeText == "function") try {
|
|
2941
2970
|
return await navigator.clipboard.writeText(e), !0;
|
|
@@ -2952,7 +2981,7 @@ async function At(e) {
|
|
|
2952
2981
|
}
|
|
2953
2982
|
//#endregion
|
|
2954
2983
|
//#region src/components/TextSelectionTooltip.tsx
|
|
2955
|
-
var
|
|
2984
|
+
var Pt = ({ containerRef: e, onCopy: t, onAnnotateSelection: r }) => {
|
|
2956
2985
|
let [a, o] = c(""), [l, u] = c(null), [d, f] = c(!1), p = s(null), m = n(() => {
|
|
2957
2986
|
if (typeof window > "u") return;
|
|
2958
2987
|
let t = window.getSelection();
|
|
@@ -3017,7 +3046,7 @@ var jt = ({ containerRef: e, onCopy: t, onAnnotateSelection: r }) => {
|
|
|
3017
3046
|
/* @__PURE__ */ I("style", { children: "\n @keyframes tspdf-fade-in {\n from { opacity: 0; transform: translate(-50%, 4px); }\n to { opacity: 1; transform: translate(-50%, 0); }\n }\n " }),
|
|
3018
3047
|
/* @__PURE__ */ L("button", {
|
|
3019
3048
|
onClick: async (e) => {
|
|
3020
|
-
e.preventDefault(), e.stopPropagation(), a && await
|
|
3049
|
+
e.preventDefault(), e.stopPropagation(), a && await Nt(a) && (f(!0), t?.(a), p.current && clearTimeout(p.current), p.current = setTimeout(() => {
|
|
3021
3050
|
f(!1);
|
|
3022
3051
|
}, 1500));
|
|
3023
3052
|
},
|
|
@@ -3182,42 +3211,39 @@ var jt = ({ containerRef: e, onCopy: t, onAnnotateSelection: r }) => {
|
|
|
3182
3211
|
};
|
|
3183
3212
|
//#endregion
|
|
3184
3213
|
//#region src/utils/findRegexRedactions.ts
|
|
3185
|
-
async function
|
|
3214
|
+
async function Ft(e, t) {
|
|
3186
3215
|
let n = [];
|
|
3187
3216
|
if (!e || !t || t.length === 0) return n;
|
|
3188
3217
|
let r = e.numPages, i = t.map((e) => new RegExp(e, e.flags.includes("g") ? e.flags : e.flags + "g"));
|
|
3189
3218
|
for (let t = 1; t <= r; t++) try {
|
|
3190
|
-
let r = await e.getPage(t), a = (await r.getTextContent()).items,
|
|
3191
|
-
a.forEach((e, t) => {
|
|
3192
|
-
let n = e.str;
|
|
3193
|
-
for (let e = 0; e < n.length; e++) s.push(t), c.push(e);
|
|
3194
|
-
o += n, e.hasEOL ? (o += "\n", s.push(-1), c.push(-1)) : (o += " ", s.push(-1), c.push(-1));
|
|
3195
|
-
});
|
|
3219
|
+
let r = await e.getPage(t), a = r.getViewport({ scale: 1 }), o = (await r.getTextContent()).items, { fullText: s, itemIndices: c, charIndices: l } = vt(o);
|
|
3196
3220
|
for (let e of i) {
|
|
3197
3221
|
e.lastIndex = 0;
|
|
3198
|
-
let
|
|
3199
|
-
for (let e of
|
|
3222
|
+
let r = [...s.matchAll(e)];
|
|
3223
|
+
for (let e of r) {
|
|
3200
3224
|
if (e.index === void 0) continue;
|
|
3201
|
-
let
|
|
3202
|
-
for (let e =
|
|
3203
|
-
let t =
|
|
3225
|
+
let r = e.index, i = e[0].length, s = /* @__PURE__ */ new Map();
|
|
3226
|
+
for (let e = r; e < r + i; e++) {
|
|
3227
|
+
let t = c[e], n = l[e];
|
|
3204
3228
|
if (t !== void 0 && t !== -1) {
|
|
3205
|
-
let e =
|
|
3206
|
-
e ? (e.min = Math.min(e.min, n), e.max = Math.max(e.max, n)) :
|
|
3229
|
+
let e = s.get(t);
|
|
3230
|
+
e ? (e.min = Math.min(e.min, n), e.max = Math.max(e.max, n)) : s.set(t, {
|
|
3207
3231
|
min: n,
|
|
3208
3232
|
max: n
|
|
3209
3233
|
});
|
|
3210
3234
|
}
|
|
3211
3235
|
}
|
|
3212
|
-
|
|
3213
|
-
let
|
|
3236
|
+
s.forEach((e, r) => {
|
|
3237
|
+
let i = o[r];
|
|
3238
|
+
if (!i || !i.transform) return;
|
|
3239
|
+
let s = i.transform[4], c = i.transform[5], l = Math.abs(i.transform[3]), u = (i.str ?? "").length, d = u > 0 ? i.width / u : i.width, f = s + e.min * d, p = (e.max - e.min + 1) * d, m = i.height || l, h = a.height - c - m;
|
|
3214
3240
|
n.push({
|
|
3215
3241
|
id: `regex-${t}-${Math.random().toString(36).substr(2, 9)}`,
|
|
3216
3242
|
pageIndex: t,
|
|
3217
|
-
x:
|
|
3218
|
-
y:
|
|
3219
|
-
width:
|
|
3220
|
-
height:
|
|
3243
|
+
x: f - 2,
|
|
3244
|
+
y: h - 2,
|
|
3245
|
+
width: p + 4,
|
|
3246
|
+
height: m + 4,
|
|
3221
3247
|
status: "pending"
|
|
3222
3248
|
});
|
|
3223
3249
|
});
|
|
@@ -3231,11 +3257,11 @@ async function Mt(e, t) {
|
|
|
3231
3257
|
}
|
|
3232
3258
|
//#endregion
|
|
3233
3259
|
//#region src/utils/layoutUtils.ts
|
|
3234
|
-
var
|
|
3260
|
+
var It = {
|
|
3235
3261
|
width: 612,
|
|
3236
3262
|
height: 792
|
|
3237
3263
|
};
|
|
3238
|
-
function
|
|
3264
|
+
function Lt(e, t = It) {
|
|
3239
3265
|
if (e <= 0) return [];
|
|
3240
3266
|
let n = {
|
|
3241
3267
|
width: t.width,
|
|
@@ -3243,7 +3269,7 @@ function Pt(e, t = Nt) {
|
|
|
3243
3269
|
};
|
|
3244
3270
|
return Array.from({ length: e }, () => ({ ...n }));
|
|
3245
3271
|
}
|
|
3246
|
-
function
|
|
3272
|
+
function Rt(e, t, n, r = 16) {
|
|
3247
3273
|
let i = e.map((e) => e.length === 0 ? r : Math.max(...e.map((e) => t(e).height)) * n + r), a = [], o = 0;
|
|
3248
3274
|
for (let e of i) a.push(o), o += e;
|
|
3249
3275
|
return {
|
|
@@ -3252,7 +3278,7 @@ function Ft(e, t, n, r = 16) {
|
|
|
3252
3278
|
total: o
|
|
3253
3279
|
};
|
|
3254
3280
|
}
|
|
3255
|
-
function
|
|
3281
|
+
function U(e, t, n = .5) {
|
|
3256
3282
|
if (e.length !== t.length) return !0;
|
|
3257
3283
|
for (let r = 0; r < e.length; r++) {
|
|
3258
3284
|
let i = e[r], a = t[r];
|
|
@@ -3262,30 +3288,30 @@ function It(e, t, n = .5) {
|
|
|
3262
3288
|
}
|
|
3263
3289
|
//#endregion
|
|
3264
3290
|
//#region src/core/pdfAssets.ts
|
|
3265
|
-
var
|
|
3266
|
-
function
|
|
3267
|
-
|
|
3268
|
-
...
|
|
3291
|
+
var W = {};
|
|
3292
|
+
function zt(e) {
|
|
3293
|
+
W = {
|
|
3294
|
+
...W,
|
|
3269
3295
|
...e
|
|
3270
3296
|
}, e.workerSrc && (Re.GlobalWorkerOptions.workerSrc = e.workerSrc);
|
|
3271
3297
|
}
|
|
3272
|
-
function
|
|
3273
|
-
return
|
|
3274
|
-
}
|
|
3275
|
-
function U() {
|
|
3276
|
-
return !!(Lt.workerSrc || Re.GlobalWorkerOptions.workerSrc);
|
|
3298
|
+
function G() {
|
|
3299
|
+
return W;
|
|
3277
3300
|
}
|
|
3278
3301
|
function Bt() {
|
|
3279
|
-
|
|
3302
|
+
return !!(W.workerSrc || Re.GlobalWorkerOptions.workerSrc);
|
|
3280
3303
|
}
|
|
3281
3304
|
function Vt() {
|
|
3305
|
+
if (!Bt()) 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>.");
|
|
3306
|
+
}
|
|
3307
|
+
function Ht() {
|
|
3282
3308
|
let e = {};
|
|
3283
|
-
return
|
|
3309
|
+
return W.cMapUrl && (e.cMapUrl = W.cMapUrl, e.cMapPacked = !0), W.standardFontDataUrl && (e.standardFontDataUrl = W.standardFontDataUrl), W.wasmUrl && (e.wasmUrl = W.wasmUrl), W.iccUrl && (e.iccUrl = W.iccUrl), e;
|
|
3284
3310
|
}
|
|
3285
|
-
var
|
|
3311
|
+
var Ut = Re.version;
|
|
3286
3312
|
//#endregion
|
|
3287
3313
|
//#region src/components/DiffHighlightOverlay.tsx
|
|
3288
|
-
function
|
|
3314
|
+
function Wt({ boxes: e, scale: t, colorScheme: n = "all", selectedDiffId: r, onSelectDiff: i }) {
|
|
3289
3315
|
let [a, o] = c(null);
|
|
3290
3316
|
if (!e || e.length === 0) return null;
|
|
3291
3317
|
let s = e.filter((e) => n === "deletions" ? e.type === "deletion" || e.type === "modification" : n !== "additions" || e.type === "addition" || e.type === "modification");
|
|
@@ -3390,7 +3416,7 @@ function Ht({ boxes: e, scale: t, colorScheme: n = "all", selectedDiffId: r, onS
|
|
|
3390
3416
|
}
|
|
3391
3417
|
//#endregion
|
|
3392
3418
|
//#region src/components/SideBySideViewer.tsx
|
|
3393
|
-
function
|
|
3419
|
+
function Gt({ 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, hideAnnotationsUntilPageRendered: y = !0 }) {
|
|
3394
3420
|
let b = s(null), x = s(null), ee = s(!1);
|
|
3395
3421
|
i(() => {
|
|
3396
3422
|
let e = b.current, t = x.current;
|
|
@@ -3496,7 +3522,7 @@ function Ut({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
|
|
|
3496
3522
|
height: `${ae}px`,
|
|
3497
3523
|
boxShadow: "0 4px 12px rgba(0,0,0,0.15)"
|
|
3498
3524
|
},
|
|
3499
|
-
children: [e && /* @__PURE__ */ I(
|
|
3525
|
+
children: [e && /* @__PURE__ */ I(jt, {
|
|
3500
3526
|
pageNum: n,
|
|
3501
3527
|
pdfDoc: e,
|
|
3502
3528
|
scale: r,
|
|
@@ -3523,7 +3549,7 @@ function Ut({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
|
|
|
3523
3549
|
watermarkText: p,
|
|
3524
3550
|
redactions: m,
|
|
3525
3551
|
hideAnnotationsUntilPageRendered: y
|
|
3526
|
-
}), /* @__PURE__ */ I(
|
|
3552
|
+
}), /* @__PURE__ */ I(Wt, {
|
|
3527
3553
|
boxes: h,
|
|
3528
3554
|
scale: r,
|
|
3529
3555
|
colorScheme: "deletions",
|
|
@@ -3561,7 +3587,7 @@ function Ut({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
|
|
|
3561
3587
|
height: `${se}px`,
|
|
3562
3588
|
boxShadow: "0 4px 12px rgba(0,0,0,0.15)"
|
|
3563
3589
|
},
|
|
3564
|
-
children: [t && /* @__PURE__ */ I(
|
|
3590
|
+
children: [t && /* @__PURE__ */ I(jt, {
|
|
3565
3591
|
pageNum: n,
|
|
3566
3592
|
pdfDoc: t,
|
|
3567
3593
|
scale: r,
|
|
@@ -3588,7 +3614,7 @@ function Ut({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
|
|
|
3588
3614
|
watermarkText: p,
|
|
3589
3615
|
redactions: m,
|
|
3590
3616
|
hideAnnotationsUntilPageRendered: y
|
|
3591
|
-
}), /* @__PURE__ */ I(
|
|
3617
|
+
}), /* @__PURE__ */ I(Wt, {
|
|
3592
3618
|
boxes: g,
|
|
3593
3619
|
scale: r,
|
|
3594
3620
|
colorScheme: "additions",
|
|
@@ -3601,7 +3627,7 @@ function Ut({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
|
|
|
3601
3627
|
}
|
|
3602
3628
|
//#endregion
|
|
3603
3629
|
//#region src/components/CompareToolbar.tsx
|
|
3604
|
-
function
|
|
3630
|
+
function Kt({ compareState: e, onSetMode: t, onSetColors: n, onToggleCurtain: r, onPrevDiff: i, onNextDiff: a, onExit: o }) {
|
|
3605
3631
|
let { mode: s, colorA: c, colorB: l, showCurtain: u, diffItems: d, currentDiffIndex: f } = e;
|
|
3606
3632
|
return /* @__PURE__ */ L("div", {
|
|
3607
3633
|
style: {
|
|
@@ -3857,7 +3883,7 @@ function Wt({ compareState: e, onSetMode: t, onSetColors: n, onToggleCurtain: r,
|
|
|
3857
3883
|
}
|
|
3858
3884
|
//#endregion
|
|
3859
3885
|
//#region src/components/DiffSummarySidebar.tsx
|
|
3860
|
-
function
|
|
3886
|
+
function qt({ isOpen: e, diffItems: t, textDiffs: n, currentDiffIndex: r, onSelectDiff: i, onJumpToPage: a }) {
|
|
3861
3887
|
return e ? /* @__PURE__ */ L("div", {
|
|
3862
3888
|
style: {
|
|
3863
3889
|
width: "320px",
|
|
@@ -4088,7 +4114,7 @@ function Gt({ isOpen: e, diffItems: t, textDiffs: n, currentDiffIndex: r, onSele
|
|
|
4088
4114
|
}
|
|
4089
4115
|
//#endregion
|
|
4090
4116
|
//#region src/components/CompareCurtainSlider.tsx
|
|
4091
|
-
function
|
|
4117
|
+
function Jt({ positionPercent: e, onChangePosition: t, containerRef: n }) {
|
|
4092
4118
|
let [r, a] = c(!1), o = s(null);
|
|
4093
4119
|
return i(() => {
|
|
4094
4120
|
let e = (e) => {
|
|
@@ -4145,7 +4171,7 @@ function Kt({ positionPercent: e, onChangePosition: t, containerRef: n }) {
|
|
|
4145
4171
|
}
|
|
4146
4172
|
//#endregion
|
|
4147
4173
|
//#region src/utils/pdfDiffEngine.ts
|
|
4148
|
-
async function
|
|
4174
|
+
async function Yt(e) {
|
|
4149
4175
|
let t = e.getViewport({
|
|
4150
4176
|
scale: 1,
|
|
4151
4177
|
rotation: e.rotate
|
|
@@ -4168,8 +4194,8 @@ async function G(e) {
|
|
|
4168
4194
|
}
|
|
4169
4195
|
return r;
|
|
4170
4196
|
}
|
|
4171
|
-
async function
|
|
4172
|
-
let [r, i] = await Promise.all([e.getPage(n), t.getPage(Math.min(n, t.numPages))]), [a, o] = await Promise.all([
|
|
4197
|
+
async function Xt(e, t, n) {
|
|
4198
|
+
let [r, i] = await Promise.all([e.getPage(n), t.getPage(Math.min(n, t.numPages))]), [a, o] = await Promise.all([Yt(r), Yt(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);
|
|
4173
4199
|
f[1] = 0;
|
|
4174
4200
|
let p = [];
|
|
4175
4201
|
for (let e = 0; e <= d; e++) {
|
|
@@ -4192,7 +4218,7 @@ async function qt(e, t, n) {
|
|
|
4192
4218
|
e > 0 && (m === i ? (_.push(h - 1), h--) : h === a && (g.push(m - 1), m--));
|
|
4193
4219
|
}
|
|
4194
4220
|
g.reverse(), _.reverse();
|
|
4195
|
-
let v =
|
|
4221
|
+
let v = Zt(g.map((e) => a[e]), n, "deletion"), y = Zt(_.map((e) => o[e]), n, "addition"), b = [];
|
|
4196
4222
|
for (let e of v) b.push({
|
|
4197
4223
|
id: e.id,
|
|
4198
4224
|
pageIndex: n,
|
|
@@ -4219,16 +4245,16 @@ async function qt(e, t, n) {
|
|
|
4219
4245
|
summary: b
|
|
4220
4246
|
};
|
|
4221
4247
|
}
|
|
4222
|
-
function
|
|
4248
|
+
function Zt(e, t, n) {
|
|
4223
4249
|
if (e.length === 0) return [];
|
|
4224
4250
|
let r = [], i = [e[0]];
|
|
4225
4251
|
for (let a = 1; a < e.length; a++) {
|
|
4226
4252
|
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;
|
|
4227
|
-
c && l ? i.push(s) : (r.push(
|
|
4253
|
+
c && l ? i.push(s) : (r.push(Qt(i, t, n, r.length + 1)), i = [s]);
|
|
4228
4254
|
}
|
|
4229
|
-
return i.length > 0 && r.push(
|
|
4255
|
+
return i.length > 0 && r.push(Qt(i, t, n, r.length + 1)), r;
|
|
4230
4256
|
}
|
|
4231
|
-
function
|
|
4257
|
+
function Qt(e, t, n, r) {
|
|
4232
4258
|
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(" ");
|
|
4233
4259
|
return {
|
|
4234
4260
|
id: `diff-box-${t}-${n}-${r}-${Math.round(i)}-${Math.round(a)}`,
|
|
@@ -4241,7 +4267,7 @@ function Yt(e, t, n, r) {
|
|
|
4241
4267
|
height: s - a + 2
|
|
4242
4268
|
};
|
|
4243
4269
|
}
|
|
4244
|
-
function
|
|
4270
|
+
function $t(e, t, n) {
|
|
4245
4271
|
let r = e.split(/(\s+)/), i = t.split(/(\s+)/), a = r.length, o = i.length, s = a + o, c = new Int32Array(2 * s + 1);
|
|
4246
4272
|
c[1] = 0;
|
|
4247
4273
|
let l = [];
|
|
@@ -4252,7 +4278,7 @@ function Xt(e, t, n) {
|
|
|
4252
4278
|
u = t === -e || t !== e && c[t - 1 + s] < c[t + 1 + s] ? c[t + 1 + s] : c[t - 1 + s] + 1;
|
|
4253
4279
|
let d = u - t;
|
|
4254
4280
|
for (; u < a && d < o && r[u] === i[d];) u++, d++;
|
|
4255
|
-
if (c[t + s] = u, u >= a && d >= o) return
|
|
4281
|
+
if (c[t + s] = u, u >= a && d >= o) return en(l, r, i, n);
|
|
4256
4282
|
}
|
|
4257
4283
|
}
|
|
4258
4284
|
return [{
|
|
@@ -4265,7 +4291,7 @@ function Xt(e, t, n) {
|
|
|
4265
4291
|
pageIndex: n
|
|
4266
4292
|
}];
|
|
4267
4293
|
}
|
|
4268
|
-
function
|
|
4294
|
+
function en(e, t, n, r) {
|
|
4269
4295
|
let i = t.length, a = n.length, o = t.length + n.length, s = [];
|
|
4270
4296
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
4271
4297
|
let c = e[r], l = i - a, u;
|
|
@@ -4291,10 +4317,10 @@ function Zt(e, t, n, r) {
|
|
|
4291
4317
|
});
|
|
4292
4318
|
return c;
|
|
4293
4319
|
}
|
|
4294
|
-
function
|
|
4320
|
+
function tn(e, t, n, r, i = .75) {
|
|
4295
4321
|
e.save(), e.globalCompositeOperation = "source-atop", e.fillStyle = r, e.globalAlpha = i, e.fillRect(0, 0, t, n), e.restore();
|
|
4296
4322
|
}
|
|
4297
|
-
function
|
|
4323
|
+
function nn(e, t, n, r) {
|
|
4298
4324
|
let i = Math.min(e.width, t.width), a = Math.min(e.height, t.height);
|
|
4299
4325
|
if (i === 0 || a === 0) return [];
|
|
4300
4326
|
let o = e.getContext("2d"), s = t.getContext("2d");
|
|
@@ -4321,7 +4347,7 @@ function $t(e, t, n, r) {
|
|
|
4321
4347
|
}
|
|
4322
4348
|
//#endregion
|
|
4323
4349
|
//#region src/components/DocumentViewer.tsx
|
|
4324
|
-
function
|
|
4350
|
+
function rn({ 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: te, sidebarTab: ne, setSidebarTab: re, onAnnotationsChange: ae, onRedactionsChange: se, onRedactionsApplied: ce, onDocumentLoaded: le, onLoadError: C, onFirstPageRendered: ue, onPageRendered: de, onPageChange: w, pageTransition: T, pageLayout: D, rotation: O, setRotation: k, watermark: pe, watermarkText: me, enableAnnotations: he, initialPage: ve, page: ye, transientHighlights: be, permissions: A, hideAnnotationsUntilPageRendered: xe = !0, enableTextSelection: Ce = !0, defaultTool: we = "select", showSelectionTooltip: Te = !0 }) {
|
|
4325
4351
|
let j = s(null), M = Ue(), [N, De] = c(null), [Oe, ke] = c(null), [P, F] = c(1), [ze, Be] = c([]), { getCommand: Ve } = mt(), [He, R] = c(null), [z, B] = c({
|
|
4326
4352
|
isActive: !1,
|
|
4327
4353
|
mode: "overlay",
|
|
@@ -4356,9 +4382,9 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4356
4382
|
Xe.current = g;
|
|
4357
4383
|
let Ze = n(async (e) => {
|
|
4358
4384
|
try {
|
|
4359
|
-
|
|
4385
|
+
Vt(), Xe.current && zt(Xe.current);
|
|
4360
4386
|
let t = typeof e == "string" ? { url: e } : { data: e };
|
|
4361
|
-
h && (t.withCredentials = !0), Object.assign(t,
|
|
4387
|
+
h && (t.withCredentials = !0), Object.assign(t, Ht());
|
|
4362
4388
|
let n = await Re.getDocument(t).promise;
|
|
4363
4389
|
De(n), Ye.current.onDocumentLoaded?.(n, typeof e == "string" ? e : "documentA.pdf");
|
|
4364
4390
|
} catch (e) {
|
|
@@ -4366,9 +4392,9 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4366
4392
|
}
|
|
4367
4393
|
}, [h]), Qe = n(async (e) => {
|
|
4368
4394
|
try {
|
|
4369
|
-
|
|
4395
|
+
Vt(), Xe.current && zt(Xe.current);
|
|
4370
4396
|
let t = typeof e == "string" ? { url: e } : { data: e };
|
|
4371
|
-
h && (t.withCredentials = !0), Object.assign(t,
|
|
4397
|
+
h && (t.withCredentials = !0), Object.assign(t, Ht());
|
|
4372
4398
|
let n = await Re.getDocument(t).promise;
|
|
4373
4399
|
R(n), B((e) => ({
|
|
4374
4400
|
...e,
|
|
@@ -4391,7 +4417,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4391
4417
|
try {
|
|
4392
4418
|
let t = Math.min(N.numPages, He.numPages), n = [], r = {}, i = {};
|
|
4393
4419
|
for (let a = 1; a <= t; a++) {
|
|
4394
|
-
let { diffsA: t, diffsB: o, summary: s } = await
|
|
4420
|
+
let { diffsA: t, diffsB: o, summary: s } = await Xt(N, He, a);
|
|
4395
4421
|
if (e) return;
|
|
4396
4422
|
r[a] = t, i[a] = o, n = n.concat(s);
|
|
4397
4423
|
}
|
|
@@ -4401,7 +4427,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4401
4427
|
pageDiffsA: r,
|
|
4402
4428
|
pageDiffsB: i
|
|
4403
4429
|
}));
|
|
4404
|
-
let a = await N.getPage(P), o = await He.getPage(Math.min(P, He.numPages)), s = await a.getTextContent(), c = await o.getTextContent(), l =
|
|
4430
|
+
let a = await N.getPage(P), o = await He.getPage(Math.min(P, He.numPages)), s = await a.getTextContent(), c = await o.getTextContent(), l = $t(s.items.map((e) => e.str).join(" "), c.items.map((e) => e.str).join(" "), P);
|
|
4405
4431
|
e || Ke(l);
|
|
4406
4432
|
} catch (e) {
|
|
4407
4433
|
console.error("Error computing document diffs:", e);
|
|
@@ -4452,7 +4478,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4452
4478
|
Ze,
|
|
4453
4479
|
Qe
|
|
4454
4480
|
]);
|
|
4455
|
-
let [et, nt] = c(null), [rt, it] = c([]), V = rt[0] ??
|
|
4481
|
+
let [et, nt] = c(null), [rt, it] = c([]), V = rt[0] ?? It, H = n((e) => rt[e - 1] ?? V, [
|
|
4456
4482
|
rt,
|
|
4457
4483
|
V.width,
|
|
4458
4484
|
V.height
|
|
@@ -4469,7 +4495,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4469
4495
|
for (let t = 2; t <= N.numPages; t += 2) e.push([t, t + 1].filter((e) => e <= N.numPages));
|
|
4470
4496
|
}
|
|
4471
4497
|
return e;
|
|
4472
|
-
}, [N, D]), pt = o(() =>
|
|
4498
|
+
}, [N, D]), pt = o(() => Rt(ft, H, S, 16), [
|
|
4473
4499
|
ft,
|
|
4474
4500
|
S,
|
|
4475
4501
|
H
|
|
@@ -4477,11 +4503,11 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4477
4503
|
ht.current = ft;
|
|
4478
4504
|
let _t = s(S);
|
|
4479
4505
|
_t.current = S;
|
|
4480
|
-
let
|
|
4481
|
-
|
|
4482
|
-
let
|
|
4483
|
-
|
|
4484
|
-
let
|
|
4506
|
+
let vt = s(pt);
|
|
4507
|
+
vt.current = pt;
|
|
4508
|
+
let yt = s(T);
|
|
4509
|
+
yt.current = T;
|
|
4510
|
+
let bt = s(0), Ct = n((e) => ft.findIndex((t) => t.includes(e)), [ft]), Dt = n((e) => {
|
|
4485
4511
|
let t = pt.tops;
|
|
4486
4512
|
if (t.length === 0) return 0;
|
|
4487
4513
|
let n = 0, r = t.length - 1;
|
|
@@ -4490,30 +4516,30 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4490
4516
|
t[i] <= e ? n = i : r = i - 1;
|
|
4491
4517
|
}
|
|
4492
4518
|
return n;
|
|
4493
|
-
}, [pt]),
|
|
4519
|
+
}, [pt]), Ot = n((e, t = {}) => {
|
|
4494
4520
|
let n = N ? Math.max(1, Math.min(e, N.numPages)) : Math.max(1, e);
|
|
4495
4521
|
F(n);
|
|
4496
|
-
let r =
|
|
4522
|
+
let r = Ct(n);
|
|
4497
4523
|
r >= 0 && j.current && (t.smooth ? j.current.scrollTo({
|
|
4498
4524
|
top: pt.tops[r],
|
|
4499
4525
|
behavior: "smooth"
|
|
4500
4526
|
}) : j.current.scrollTop = pt.tops[r]);
|
|
4501
4527
|
}, [
|
|
4502
4528
|
N,
|
|
4503
|
-
|
|
4529
|
+
Ct,
|
|
4504
4530
|
pt
|
|
4505
4531
|
]);
|
|
4506
4532
|
i(() => {
|
|
4507
4533
|
let e = (e) => {
|
|
4508
|
-
e?.page &&
|
|
4534
|
+
e?.page && Ot(e.page, { smooth: e.smooth ?? !0 });
|
|
4509
4535
|
}, t = M.on("action-go-to-page", (t) => e(t)), n = (t) => e(t.detail);
|
|
4510
4536
|
return window.addEventListener("action-go-to-page", n), () => {
|
|
4511
4537
|
t(), window.removeEventListener("action-go-to-page", n);
|
|
4512
4538
|
};
|
|
4513
|
-
}, [M,
|
|
4514
|
-
let
|
|
4515
|
-
F(e.pageIndex), nt(e),
|
|
4516
|
-
},
|
|
4539
|
+
}, [M, Ot]);
|
|
4540
|
+
let At = (e) => {
|
|
4541
|
+
F(e.pageIndex), nt(e), Ot(e.pageIndex);
|
|
4542
|
+
}, Nt = n((e, t) => {
|
|
4517
4543
|
let n = t || z.diffItems[e];
|
|
4518
4544
|
if (B((t) => ({
|
|
4519
4545
|
...t,
|
|
@@ -4522,7 +4548,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4522
4548
|
n.pageIndex && n.pageIndex !== P && F(n.pageIndex);
|
|
4523
4549
|
let r = (n.y ?? 0) * S, i = (n.x ?? 0) * S;
|
|
4524
4550
|
if (j.current) {
|
|
4525
|
-
let e = n.pageIndex || P, t =
|
|
4551
|
+
let e = n.pageIndex || P, t = Ct(e), a = T === "continuous" && t >= 0 ? pt.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);
|
|
4526
4552
|
j.current.scrollTo({
|
|
4527
4553
|
top: c,
|
|
4528
4554
|
left: l,
|
|
@@ -4534,21 +4560,21 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4534
4560
|
P,
|
|
4535
4561
|
S,
|
|
4536
4562
|
T,
|
|
4537
|
-
|
|
4563
|
+
Ct,
|
|
4538
4564
|
pt.tops
|
|
4539
4565
|
]), U = l(u.subscribe, u.getSnapshot, u.getSnapshot), [W, G] = c(we);
|
|
4540
4566
|
i(() => {
|
|
4541
|
-
a === "Annotate" ? (G("highlight"),
|
|
4567
|
+
a === "Annotate" ? (G("highlight"), Ut("#fbc02d"), en(.5), Zt(16)) : a === "Shapes" ? (G("rectangle"), en(1), Zt(2)) : a === "Fill and Sign" ? G("signature") : a === "View" && G(we);
|
|
4542
4568
|
}, [a, we]), i(() => {
|
|
4543
4569
|
M.emit("action-tool-changed", { tool: W });
|
|
4544
4570
|
}, [W, M]);
|
|
4545
|
-
let [
|
|
4571
|
+
let [Bt, Ut] = c("#d32f2f"), [Yt, Zt] = c(2), [Qt, en] = c(.8), [tn, nn] = c(!1), [rn, on] = c(null), [q, sn] = c({
|
|
4546
4572
|
x: 0,
|
|
4547
4573
|
y: 0
|
|
4548
|
-
}), [
|
|
4574
|
+
}), [J, cn] = c({
|
|
4549
4575
|
x: 0,
|
|
4550
4576
|
y: 0
|
|
4551
|
-
}), [
|
|
4577
|
+
}), [ln, un] = c([]), [Y, dn] = c(null), [fn, pn] = c(""), mn = s(null), [X, Z] = c(null), [hn, gn] = c(null), [_n, vn] = c(!1), yn = s(!1), bn = s(null);
|
|
4552
4578
|
We("action-set-tool", (e) => G(e?.tool ?? null)), i(() => {
|
|
4553
4579
|
let e = () => {
|
|
4554
4580
|
let e = typeof window < "u" ? window.getSelection()?.toString() ?? "" : "";
|
|
@@ -4585,7 +4611,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4585
4611
|
vx: null,
|
|
4586
4612
|
vy: null
|
|
4587
4613
|
}, r && P > 1 && T === "continuous") {
|
|
4588
|
-
let e =
|
|
4614
|
+
let e = Ct(P);
|
|
4589
4615
|
e >= 0 && (n.scrollTop = pt.tops[e] ?? 0), n.scrollLeft = 0;
|
|
4590
4616
|
} else n.scrollLeft = i.scrollLeft, n.scrollTop = i.scrollTop;
|
|
4591
4617
|
}
|
|
@@ -4617,8 +4643,8 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4617
4643
|
u.undo();
|
|
4618
4644
|
}, [u]), En = n(() => {
|
|
4619
4645
|
u.redo();
|
|
4620
|
-
}, [u]), [Dn, On] = c(null), [kn,
|
|
4621
|
-
|
|
4646
|
+
}, [u]), [Dn, On] = c(null), [kn, An] = c(null), jn = s(null), Mn = s(null), $ = s(null);
|
|
4647
|
+
$.current = Dn;
|
|
4622
4648
|
let Nn = s(null);
|
|
4623
4649
|
Nn.current = kn;
|
|
4624
4650
|
let Pn = n((e, t, n, r) => {
|
|
@@ -4629,7 +4655,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4629
4655
|
width: i.width && i.width > 0 ? i.width : 180,
|
|
4630
4656
|
height: i.height && i.height > 0 ? i.height : 40
|
|
4631
4657
|
};
|
|
4632
|
-
|
|
4658
|
+
jn.current = {
|
|
4633
4659
|
annId: e,
|
|
4634
4660
|
handle: t,
|
|
4635
4661
|
startX: n.clientX,
|
|
@@ -4643,13 +4669,13 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4643
4669
|
A
|
|
4644
4670
|
]), Fn = n((e, t, n) => {
|
|
4645
4671
|
let r = U.find((t) => t.id === e);
|
|
4646
|
-
!r || A?.canEditAnnotations === !1 || !u.canEdit(r) || (
|
|
4672
|
+
!r || A?.canEditAnnotations === !1 || !u.canEdit(r) || (Mn.current = {
|
|
4647
4673
|
annId: e,
|
|
4648
4674
|
startX: t.clientX,
|
|
4649
4675
|
startY: t.clientY,
|
|
4650
4676
|
initialAnn: { ...r },
|
|
4651
4677
|
pageIndex: n
|
|
4652
|
-
},
|
|
4678
|
+
}, An({ ...r }));
|
|
4653
4679
|
}, [
|
|
4654
4680
|
U,
|
|
4655
4681
|
u,
|
|
@@ -4659,17 +4685,17 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4659
4685
|
let n = U.find((t) => t.id === e);
|
|
4660
4686
|
if (n && (n.type === "text" || n.type === "note" || n.type === "callout")) {
|
|
4661
4687
|
if (A?.canEditAnnotations === !1 || !u.canEdit(n)) {
|
|
4662
|
-
|
|
4688
|
+
Z(e);
|
|
4663
4689
|
return;
|
|
4664
4690
|
}
|
|
4665
|
-
|
|
4691
|
+
dn({
|
|
4666
4692
|
x: n.x,
|
|
4667
4693
|
y: n.y,
|
|
4668
4694
|
type: n.type,
|
|
4669
4695
|
annId: n.id,
|
|
4670
4696
|
points: n.points,
|
|
4671
4697
|
pageIndex: n.pageIndex
|
|
4672
|
-
}),
|
|
4698
|
+
}), pn(n.text || ""), n.color && Ut(n.color), Z(e);
|
|
4673
4699
|
}
|
|
4674
4700
|
}, [
|
|
4675
4701
|
U,
|
|
@@ -4678,8 +4704,8 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4678
4704
|
]);
|
|
4679
4705
|
i(() => {
|
|
4680
4706
|
let e = (e) => {
|
|
4681
|
-
if (
|
|
4682
|
-
let { handle: t, startX: n, startY: r, initialAnn: i } =
|
|
4707
|
+
if (jn.current) {
|
|
4708
|
+
let { handle: t, startX: n, startY: r, initialAnn: i } = jn.current, a = (e.clientX - n) / S, o = (e.clientY - r) / S;
|
|
4683
4709
|
if (O === 90) {
|
|
4684
4710
|
let e = a;
|
|
4685
4711
|
a = o, o = -e;
|
|
@@ -4696,8 +4722,8 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4696
4722
|
width: s,
|
|
4697
4723
|
height: c
|
|
4698
4724
|
});
|
|
4699
|
-
} else if (
|
|
4700
|
-
let { startX: t, startY: n, initialAnn: r } =
|
|
4725
|
+
} else if (Mn.current) {
|
|
4726
|
+
let { startX: t, startY: n, initialAnn: r } = Mn.current, i = (e.clientX - t) / S, a = (e.clientY - n) / S;
|
|
4701
4727
|
if (O === 90) {
|
|
4702
4728
|
let e = i;
|
|
4703
4729
|
i = a, a = -e;
|
|
@@ -4706,26 +4732,26 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4706
4732
|
let e = i;
|
|
4707
4733
|
i = -a, a = e;
|
|
4708
4734
|
}
|
|
4709
|
-
|
|
4735
|
+
An({
|
|
4710
4736
|
...r,
|
|
4711
4737
|
x: Math.max(0, r.x + i),
|
|
4712
4738
|
y: Math.max(0, r.y + a)
|
|
4713
4739
|
});
|
|
4714
4740
|
}
|
|
4715
4741
|
}, t = () => {
|
|
4716
|
-
if (
|
|
4717
|
-
if (
|
|
4718
|
-
let e =
|
|
4742
|
+
if (jn.current) {
|
|
4743
|
+
if ($.current) {
|
|
4744
|
+
let e = $.current;
|
|
4719
4745
|
Q(U.map((t) => t.id === e.id ? e : t));
|
|
4720
4746
|
}
|
|
4721
|
-
|
|
4747
|
+
jn.current = null, On(null);
|
|
4722
4748
|
}
|
|
4723
|
-
if (
|
|
4749
|
+
if (Mn.current) {
|
|
4724
4750
|
if (Nn.current) {
|
|
4725
4751
|
let e = Nn.current;
|
|
4726
4752
|
Q(U.map((t) => t.id === e.id ? e : t));
|
|
4727
4753
|
}
|
|
4728
|
-
|
|
4754
|
+
Mn.current = null, An(null);
|
|
4729
4755
|
}
|
|
4730
4756
|
};
|
|
4731
4757
|
return window.addEventListener("mousemove", e), window.addEventListener("mouseup", t), () => {
|
|
@@ -4749,7 +4775,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4749
4775
|
let a = i.getAttribute("data-page-number") || i.id.replace("pdf-page-", ""), o = parseInt(a, 10);
|
|
4750
4776
|
if (!o) return;
|
|
4751
4777
|
let s = i.getBoundingClientRect(), c = H(o), l = O % 180 == 0 ? c.width : c.height, u = O % 180 == 0 ? c.height : c.width, d = r.map((e) => {
|
|
4752
|
-
let t = (e.left - s.left) / S, n = (e.top - s.top) / S, r = e.width / S, i = e.height / S, a =
|
|
4778
|
+
let t = (e.left - s.left) / S, n = (e.top - s.top) / S, r = e.width / S, i = e.height / S, a = Tt(t, n, O, l, u), o = Tt(t + r, n + i, O, l, u);
|
|
4753
4779
|
return {
|
|
4754
4780
|
x: Math.min(a.x, o.x),
|
|
4755
4781
|
y: Math.min(a.y, o.y),
|
|
@@ -4758,7 +4784,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4758
4784
|
};
|
|
4759
4785
|
}).filter((e) => e.width > 2 && e.height > 2);
|
|
4760
4786
|
if (d.length === 0) return;
|
|
4761
|
-
let f = Math.min(...d.map((e) => e.x)), p = Math.min(...d.map((e) => e.y)), m = Math.max(...d.map((e) => e.x + e.width)), h = Math.max(...d.map((e) => e.y + e.height)), g = e === "highlight" ? "#fbc02d" : e === "squiggly" ? "#388e3c" :
|
|
4787
|
+
let f = Math.min(...d.map((e) => e.x)), p = Math.min(...d.map((e) => e.y)), m = Math.max(...d.map((e) => e.x + e.width)), h = Math.max(...d.map((e) => e.y + e.height)), g = e === "highlight" ? "#fbc02d" : e === "squiggly" ? "#388e3c" : Bt || "#d32f2f", _ = e === "highlight" ? .5 : 1, v = e === "squiggly" ? 1.5 : 2, y = Mt();
|
|
4762
4788
|
Q([...U, {
|
|
4763
4789
|
id: y,
|
|
4764
4790
|
type: e,
|
|
@@ -4775,7 +4801,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4775
4801
|
}, [
|
|
4776
4802
|
U,
|
|
4777
4803
|
Q,
|
|
4778
|
-
|
|
4804
|
+
Bt,
|
|
4779
4805
|
H,
|
|
4780
4806
|
A,
|
|
4781
4807
|
O,
|
|
@@ -4807,15 +4833,15 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4807
4833
|
e.preventDefault(), M.emit("action-open-file-picker");
|
|
4808
4834
|
return;
|
|
4809
4835
|
}
|
|
4810
|
-
if (!t && !
|
|
4836
|
+
if (!t && !Y) {
|
|
4811
4837
|
if (gt(e, Ve("COPY"))) {
|
|
4812
4838
|
let t = typeof window < "u" ? window.getSelection()?.toString() : "";
|
|
4813
4839
|
if (t && t.length > 0) {
|
|
4814
4840
|
M.emit("action-text-copied", { text: t });
|
|
4815
4841
|
return;
|
|
4816
4842
|
}
|
|
4817
|
-
if (
|
|
4818
|
-
let t = U.find((e) => e.id ===
|
|
4843
|
+
if (X) {
|
|
4844
|
+
let t = U.find((e) => e.id === X);
|
|
4819
4845
|
t && (e.preventDefault(), bn.current = t);
|
|
4820
4846
|
return;
|
|
4821
4847
|
}
|
|
@@ -4824,7 +4850,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4824
4850
|
e.preventDefault();
|
|
4825
4851
|
let t = bn.current, n = {
|
|
4826
4852
|
...t,
|
|
4827
|
-
id:
|
|
4853
|
+
id: Mt(),
|
|
4828
4854
|
pageIndex: P,
|
|
4829
4855
|
x: t.x + 20,
|
|
4830
4856
|
y: t.y + 20,
|
|
@@ -4835,40 +4861,40 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4835
4861
|
readOnly: void 0,
|
|
4836
4862
|
xfdfExtras: void 0
|
|
4837
4863
|
};
|
|
4838
|
-
Q([...U, n]),
|
|
4864
|
+
Q([...U, n]), Z(n.id);
|
|
4839
4865
|
return;
|
|
4840
4866
|
}
|
|
4841
|
-
if (gt(e, Ve("DELETE")) &&
|
|
4842
|
-
e.preventDefault(), Q(U.filter((e) => e.id !==
|
|
4867
|
+
if (gt(e, Ve("DELETE")) && X) {
|
|
4868
|
+
e.preventDefault(), Q(U.filter((e) => e.id !== X)), Z(null);
|
|
4843
4869
|
return;
|
|
4844
4870
|
}
|
|
4845
|
-
if (e.key === "Enter" &&
|
|
4846
|
-
let t = U.find((e) => e.id ===
|
|
4871
|
+
if (e.key === "Enter" && X && !Y) {
|
|
4872
|
+
let t = U.find((e) => e.id === X);
|
|
4847
4873
|
if (t && (t.type === "text" || t.type === "note" || t.type === "callout")) {
|
|
4848
|
-
e.preventDefault(),
|
|
4874
|
+
e.preventDefault(), dn({
|
|
4849
4875
|
x: t.x,
|
|
4850
4876
|
y: t.y,
|
|
4851
4877
|
type: t.type,
|
|
4852
4878
|
annId: t.id,
|
|
4853
4879
|
points: t.points,
|
|
4854
4880
|
pageIndex: t.pageIndex
|
|
4855
|
-
}),
|
|
4881
|
+
}), pn(t.text || ""), t.color && Ut(t.color);
|
|
4856
4882
|
return;
|
|
4857
4883
|
}
|
|
4858
4884
|
}
|
|
4859
4885
|
}
|
|
4860
4886
|
}), i(() => {
|
|
4861
|
-
|
|
4862
|
-
|
|
4887
|
+
Y && mn.current && setTimeout(() => {
|
|
4888
|
+
mn.current?.focus();
|
|
4863
4889
|
}, 10);
|
|
4864
|
-
}, [
|
|
4890
|
+
}, [Y]), i(() => {
|
|
4865
4891
|
ae && ae(U);
|
|
4866
4892
|
}, [U, ae]);
|
|
4867
4893
|
let [Rn, zn] = c([]);
|
|
4868
4894
|
i(() => {
|
|
4869
4895
|
if (N && x && x.length > 0) {
|
|
4870
4896
|
let e = !1;
|
|
4871
|
-
return
|
|
4897
|
+
return Ft(N, x).then((t) => {
|
|
4872
4898
|
e || zn(t);
|
|
4873
4899
|
}), () => {
|
|
4874
4900
|
e = !0;
|
|
@@ -4892,7 +4918,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4892
4918
|
Be((e) => e.filter((e) => e.status === "applied")), zn((e) => e.filter((e) => e.status === "applied"));
|
|
4893
4919
|
}, []), Gn = n((e) => {
|
|
4894
4920
|
Be((t) => t.filter((t) => t !== e && t.id !== e.id)), zn((t) => t.filter((t) => t !== e && t.id !== e.id));
|
|
4895
|
-
}, []), { search: Kn, searchResults: qn, isSearching: Jn, searchProgress: Yn } =
|
|
4921
|
+
}, []), { search: Kn, searchResults: qn, isSearching: Jn, searchProgress: Yn } = xt(N, Hn);
|
|
4896
4922
|
i(() => {
|
|
4897
4923
|
qn.length === 0 && nt(null);
|
|
4898
4924
|
}, [qn]);
|
|
@@ -4902,10 +4928,10 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4902
4928
|
let e = d, t = !1, n = null;
|
|
4903
4929
|
return (async () => {
|
|
4904
4930
|
try {
|
|
4905
|
-
Xe.current &&
|
|
4931
|
+
Xe.current && zt(Xe.current), Vt(), n = Re.getDocument({
|
|
4906
4932
|
url: e,
|
|
4907
4933
|
withCredentials: h,
|
|
4908
|
-
...
|
|
4934
|
+
...Ht()
|
|
4909
4935
|
});
|
|
4910
4936
|
let r = await n.promise;
|
|
4911
4937
|
if (t) return;
|
|
@@ -4914,9 +4940,9 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4914
4940
|
if (!t) {
|
|
4915
4941
|
let t = e.getViewport({
|
|
4916
4942
|
scale: 1,
|
|
4917
|
-
rotation:
|
|
4943
|
+
rotation: kt(e.rotate + O)
|
|
4918
4944
|
});
|
|
4919
|
-
it(
|
|
4945
|
+
it(Lt(r.numPages, {
|
|
4920
4946
|
width: t.width,
|
|
4921
4947
|
height: t.height
|
|
4922
4948
|
}));
|
|
@@ -4953,14 +4979,14 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4953
4979
|
if (!N || !e || Qn.current === N && $n.current === e || rt.length < Math.min(e, N.numPages)) return;
|
|
4954
4980
|
let t = Qn.current !== N;
|
|
4955
4981
|
Qn.current = N, $n.current = e;
|
|
4956
|
-
let n = setTimeout(() =>
|
|
4982
|
+
let n = setTimeout(() => Ot(e, { smooth: !t }), 50);
|
|
4957
4983
|
return () => clearTimeout(n);
|
|
4958
4984
|
}, [
|
|
4959
4985
|
N,
|
|
4960
4986
|
ye,
|
|
4961
4987
|
ve,
|
|
4962
4988
|
rt.length,
|
|
4963
|
-
|
|
4989
|
+
Ot
|
|
4964
4990
|
]), i(() => {
|
|
4965
4991
|
if (!N) return;
|
|
4966
4992
|
let e = !1, t = N;
|
|
@@ -4974,13 +5000,13 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4974
5000
|
if (e) return;
|
|
4975
5001
|
let r = n.getViewport({
|
|
4976
5002
|
scale: 1,
|
|
4977
|
-
rotation:
|
|
5003
|
+
rotation: kt(n.rotate + O)
|
|
4978
5004
|
}), i = {
|
|
4979
5005
|
width: r.width,
|
|
4980
5006
|
height: r.height
|
|
4981
5007
|
};
|
|
4982
|
-
if (it((e) => e.length === t.numPages && Math.abs((e[0]?.width ?? 0) - i.width) <= .5 && Math.abs((e[0]?.height ?? 0) - i.height) <= .5 ? e :
|
|
4983
|
-
let a =
|
|
5008
|
+
if (it((e) => e.length === t.numPages && Math.abs((e[0]?.width ?? 0) - i.width) <= .5 && Math.abs((e[0]?.height ?? 0) - i.height) <= .5 ? e : Lt(t.numPages, i)), t.numPages <= 1) return;
|
|
5009
|
+
let a = Lt(t.numPages, i), o = !1;
|
|
4984
5010
|
for (let n = 2; n <= t.numPages; n += 25) {
|
|
4985
5011
|
if (e) return;
|
|
4986
5012
|
let r = Math.min(t.numPages, n + 25 - 1), s = [];
|
|
@@ -4992,7 +5018,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4992
5018
|
if (e) return;
|
|
4993
5019
|
let s = r.getViewport({
|
|
4994
5020
|
scale: 1,
|
|
4995
|
-
rotation:
|
|
5021
|
+
rotation: kt(r.rotate + O)
|
|
4996
5022
|
});
|
|
4997
5023
|
(Math.abs(s.width - i.width) > .5 || Math.abs(s.height - i.height) > .5) && (o = !0), a[n - 1] = {
|
|
4998
5024
|
width: s.width,
|
|
@@ -5005,8 +5031,8 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5005
5031
|
}
|
|
5006
5032
|
if (!e && o) {
|
|
5007
5033
|
let e = j.current;
|
|
5008
|
-
if (e && e.scrollTop > 0 &&
|
|
5009
|
-
let t =
|
|
5034
|
+
if (e && e.scrollTop > 0 && yt.current === "continuous") {
|
|
5035
|
+
let t = bt.current, n = Rt(ht.current, (e) => a[e - 1] ?? i, _t.current, 16), r = vt.current.tops[t] ?? 0, o = (n.tops[t] ?? 0) - r;
|
|
5010
5036
|
o !== 0 && (e.scrollTop += o);
|
|
5011
5037
|
}
|
|
5012
5038
|
it(a);
|
|
@@ -5043,7 +5069,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5043
5069
|
We("action-fit-to-width", () => er()), We("action-fit-to-page", () => tr());
|
|
5044
5070
|
let nr = (e, t) => {
|
|
5045
5071
|
let n = e.currentTarget.getBoundingClientRect(), r = (e.clientX - n.left) / S, i = (e.clientY - n.top) / S, a = H(t);
|
|
5046
|
-
return
|
|
5072
|
+
return Tt(r, i, O, O % 180 == 0 ? a.width : a.height, O % 180 == 0 ? a.height : a.width);
|
|
5047
5073
|
}, rr = (e, t) => {
|
|
5048
5074
|
if (!W) return;
|
|
5049
5075
|
let { x: n, y: r } = nr(e, t);
|
|
@@ -5052,19 +5078,19 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5052
5078
|
return;
|
|
5053
5079
|
}
|
|
5054
5080
|
if (W === "eraser") {
|
|
5055
|
-
|
|
5081
|
+
nn(!0);
|
|
5056
5082
|
return;
|
|
5057
5083
|
}
|
|
5058
|
-
|
|
5084
|
+
sn({
|
|
5059
5085
|
x: n,
|
|
5060
5086
|
y: r
|
|
5061
|
-
}),
|
|
5087
|
+
}), cn({
|
|
5062
5088
|
x: n,
|
|
5063
5089
|
y: r
|
|
5064
|
-
}), W === "freehand" ? (
|
|
5090
|
+
}), W === "freehand" ? (nn(!0), un([{
|
|
5065
5091
|
x: n,
|
|
5066
5092
|
y: r
|
|
5067
|
-
}]),
|
|
5093
|
+
}]), on(t)) : ([
|
|
5068
5094
|
"rectangle",
|
|
5069
5095
|
"ellipse",
|
|
5070
5096
|
"line",
|
|
@@ -5074,39 +5100,39 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5074
5100
|
"strikeout",
|
|
5075
5101
|
"squiggly",
|
|
5076
5102
|
"redaction"
|
|
5077
|
-
].includes(W) || ["callout", "link"].includes(W)) && (
|
|
5103
|
+
].includes(W) || ["callout", "link"].includes(W)) && (nn(!0), on(t));
|
|
5078
5104
|
}, ir = () => {
|
|
5079
|
-
if (
|
|
5080
|
-
if (
|
|
5105
|
+
if (Y && fn.trim()) {
|
|
5106
|
+
if (Y.annId) Q(U.map((e) => e.id === Y.annId ? {
|
|
5081
5107
|
...e,
|
|
5082
|
-
text:
|
|
5108
|
+
text: fn
|
|
5083
5109
|
} : e));
|
|
5084
5110
|
else {
|
|
5085
|
-
let e =
|
|
5111
|
+
let e = Mt(), t = Math.max(160, Math.min(320, fn.length * 9 + 20)), n = fn.split("\n").length, r = Math.max(36, n * 22);
|
|
5086
5112
|
Q([...U, {
|
|
5087
5113
|
id: e,
|
|
5088
|
-
type:
|
|
5089
|
-
pageIndex:
|
|
5090
|
-
x:
|
|
5091
|
-
y:
|
|
5114
|
+
type: Y.type,
|
|
5115
|
+
pageIndex: Y.pageIndex,
|
|
5116
|
+
x: Y.x,
|
|
5117
|
+
y: Y.y,
|
|
5092
5118
|
width: t,
|
|
5093
5119
|
height: r,
|
|
5094
|
-
text:
|
|
5095
|
-
points:
|
|
5096
|
-
color:
|
|
5097
|
-
strokeWidth:
|
|
5098
|
-
opacity:
|
|
5120
|
+
text: fn,
|
|
5121
|
+
points: Y.points,
|
|
5122
|
+
color: Bt,
|
|
5123
|
+
strokeWidth: Yt,
|
|
5124
|
+
opacity: Qt
|
|
5099
5125
|
}]);
|
|
5100
5126
|
}
|
|
5101
5127
|
}
|
|
5102
|
-
|
|
5128
|
+
dn(null), pn(""), W === "text" && G(null);
|
|
5103
5129
|
}, ar = (e, t) => {
|
|
5104
|
-
if (!
|
|
5130
|
+
if (!tn) return;
|
|
5105
5131
|
let { x: n, y: r } = nr(e, t);
|
|
5106
|
-
|
|
5132
|
+
cn({
|
|
5107
5133
|
x: n,
|
|
5108
5134
|
y: r
|
|
5109
|
-
}), W === "freehand" &&
|
|
5135
|
+
}), W === "freehand" && un((e) => [...e, {
|
|
5110
5136
|
x: n,
|
|
5111
5137
|
y: r
|
|
5112
5138
|
}]);
|
|
@@ -5115,7 +5141,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5115
5141
|
if (W === "link") {
|
|
5116
5142
|
let { x: n, y: r } = nr(e, t);
|
|
5117
5143
|
if (A?.canAddAnnotations === !1) return;
|
|
5118
|
-
let i =
|
|
5144
|
+
let i = Mt(), a = {
|
|
5119
5145
|
id: i,
|
|
5120
5146
|
type: "link",
|
|
5121
5147
|
pageIndex: t,
|
|
@@ -5130,60 +5156,60 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5130
5156
|
opacity: 1,
|
|
5131
5157
|
points: []
|
|
5132
5158
|
};
|
|
5133
|
-
Q([...U, a]),
|
|
5159
|
+
Q([...U, a]), Z(i), vn(!0), G(null);
|
|
5134
5160
|
return;
|
|
5135
5161
|
}
|
|
5136
5162
|
if (W === "text" || W === "note") {
|
|
5137
5163
|
let { x: n, y: r } = nr(e, t);
|
|
5138
5164
|
if (A?.canAddAnnotations === !1) return;
|
|
5139
|
-
|
|
5165
|
+
Y && ir(), dn({
|
|
5140
5166
|
x: n,
|
|
5141
5167
|
y: r,
|
|
5142
5168
|
type: W,
|
|
5143
5169
|
pageIndex: t
|
|
5144
|
-
}),
|
|
5170
|
+
}), pn("");
|
|
5145
5171
|
}
|
|
5146
5172
|
return;
|
|
5147
5173
|
}
|
|
5148
|
-
if (
|
|
5174
|
+
if (tn && (nn(!1), on(null), W)) {
|
|
5149
5175
|
if (W === "freehand") {
|
|
5150
|
-
if (
|
|
5151
|
-
let e =
|
|
5176
|
+
if (ln.length > 2) {
|
|
5177
|
+
let e = ln.map((e) => e.x), n = ln.map((e) => e.y), r = Math.min(...e), i = Math.max(...e), a = Math.min(...n), o = Math.max(...n);
|
|
5152
5178
|
Q([...U, {
|
|
5153
|
-
id:
|
|
5179
|
+
id: Mt(),
|
|
5154
5180
|
type: W,
|
|
5155
5181
|
pageIndex: t,
|
|
5156
5182
|
x: r,
|
|
5157
5183
|
y: a,
|
|
5158
5184
|
width: i - r,
|
|
5159
5185
|
height: o - a,
|
|
5160
|
-
points: [...
|
|
5161
|
-
strokes: [[...
|
|
5162
|
-
color:
|
|
5163
|
-
strokeWidth:
|
|
5164
|
-
opacity:
|
|
5186
|
+
points: [...ln],
|
|
5187
|
+
strokes: [[...ln]],
|
|
5188
|
+
color: Bt,
|
|
5189
|
+
strokeWidth: Yt,
|
|
5190
|
+
opacity: Qt
|
|
5165
5191
|
}]);
|
|
5166
5192
|
}
|
|
5167
|
-
|
|
5193
|
+
un([]);
|
|
5168
5194
|
} else {
|
|
5169
|
-
let e = Math.abs(
|
|
5195
|
+
let e = Math.abs(J.x - q.x), n = Math.abs(J.y - q.y);
|
|
5170
5196
|
if (e > 5 || n > 5) {
|
|
5171
|
-
let r = Math.min(
|
|
5197
|
+
let r = Math.min(q.x, J.x), i = Math.min(q.y, J.y), a = W === "line" || W === "arrow" || W === "callout" ? [q, J] : void 0;
|
|
5172
5198
|
if ([
|
|
5173
5199
|
"highlight",
|
|
5174
5200
|
"underline",
|
|
5175
5201
|
"strikeout",
|
|
5176
5202
|
"squiggly",
|
|
5177
5203
|
"redaction"
|
|
5178
|
-
].includes(W) && n < 18 && (n = Math.max(18, n), i =
|
|
5204
|
+
].includes(W) && n < 18 && (n = Math.max(18, n), i = q.y - 9), W === "callout") {
|
|
5179
5205
|
if (A?.canAddAnnotations === !1) return;
|
|
5180
|
-
|
|
5181
|
-
x:
|
|
5182
|
-
y:
|
|
5206
|
+
dn({
|
|
5207
|
+
x: J.x,
|
|
5208
|
+
y: J.y,
|
|
5183
5209
|
type: "callout",
|
|
5184
5210
|
points: a,
|
|
5185
5211
|
pageIndex: t
|
|
5186
|
-
}),
|
|
5212
|
+
}), pn("");
|
|
5187
5213
|
return;
|
|
5188
5214
|
}
|
|
5189
5215
|
if (W === "redaction") {
|
|
@@ -5201,7 +5227,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5201
5227
|
}
|
|
5202
5228
|
if (A?.canAddAnnotations === !1) return;
|
|
5203
5229
|
Q([...U, {
|
|
5204
|
-
id:
|
|
5230
|
+
id: Mt(),
|
|
5205
5231
|
type: W,
|
|
5206
5232
|
pageIndex: t,
|
|
5207
5233
|
x: r,
|
|
@@ -5209,25 +5235,25 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5209
5235
|
width: e,
|
|
5210
5236
|
height: n,
|
|
5211
5237
|
points: a,
|
|
5212
|
-
color:
|
|
5213
|
-
strokeWidth:
|
|
5214
|
-
opacity:
|
|
5238
|
+
color: Bt,
|
|
5239
|
+
strokeWidth: Yt,
|
|
5240
|
+
opacity: Qt
|
|
5215
5241
|
}]);
|
|
5216
5242
|
}
|
|
5217
5243
|
}
|
|
5218
5244
|
}
|
|
5219
5245
|
}, sr = (e) => {
|
|
5220
|
-
W === "eraser" &&
|
|
5246
|
+
W === "eraser" && tn && Q(U.filter((t) => t.id !== e));
|
|
5221
5247
|
}, cr = (e, t) => {
|
|
5222
5248
|
if (t.stopPropagation(), W === "eraser") {
|
|
5223
5249
|
if (A?.canDeleteAnnotations === !1) return;
|
|
5224
|
-
Q(U.filter((t) => t.id !== e)),
|
|
5250
|
+
Q(U.filter((t) => t.id !== e)), X === e && (Z(null), gn(null));
|
|
5225
5251
|
} else if (W === null || W === "pan" || W === "select") {
|
|
5226
5252
|
let n = U.find((t) => t.id === e);
|
|
5227
5253
|
if (n && n.linkUrl && a === "View") {
|
|
5228
5254
|
if (n.linkUrl.startsWith("#page=")) {
|
|
5229
5255
|
let e = parseInt(n.linkUrl.split("=")[1]);
|
|
5230
|
-
|
|
5256
|
+
Ot(e);
|
|
5231
5257
|
} else {
|
|
5232
5258
|
let e = n.linkUrl;
|
|
5233
5259
|
/^https?:\/\//i.test(e) || (e = "https://" + e);
|
|
@@ -5238,28 +5264,28 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5238
5264
|
}
|
|
5239
5265
|
if (n && (n.type === "note" || n.type === "callout")) {
|
|
5240
5266
|
if (A?.canEditAnnotations === !1 || !u.canEdit(n)) {
|
|
5241
|
-
|
|
5267
|
+
Z(e);
|
|
5242
5268
|
return;
|
|
5243
5269
|
}
|
|
5244
|
-
|
|
5270
|
+
dn({
|
|
5245
5271
|
x: n.x,
|
|
5246
5272
|
y: n.y,
|
|
5247
5273
|
type: n.type,
|
|
5248
5274
|
annId: n.id,
|
|
5249
5275
|
points: n.points,
|
|
5250
5276
|
pageIndex: n.pageIndex
|
|
5251
|
-
}),
|
|
5252
|
-
} else if (n && n.type === "text")
|
|
5277
|
+
}), pn(n.text || ""), n.color && Ut(n.color);
|
|
5278
|
+
} else if (n && n.type === "text") Z(e);
|
|
5253
5279
|
else if (n && n.type === "link") {
|
|
5254
5280
|
if (A?.canEditAnnotations === !1 || !u.canEdit(n)) {
|
|
5255
|
-
|
|
5281
|
+
Z(e);
|
|
5256
5282
|
return;
|
|
5257
5283
|
}
|
|
5258
5284
|
vn(!0);
|
|
5259
5285
|
}
|
|
5260
|
-
|
|
5286
|
+
Z(e);
|
|
5261
5287
|
let r = j.current, i = r?.getBoundingClientRect();
|
|
5262
|
-
i && r &&
|
|
5288
|
+
i && r && gn({
|
|
5263
5289
|
top: t.clientY - i.top + r.scrollTop,
|
|
5264
5290
|
left: t.clientX - i.left + r.scrollLeft
|
|
5265
5291
|
});
|
|
@@ -5267,7 +5293,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5267
5293
|
};
|
|
5268
5294
|
return i(() => {
|
|
5269
5295
|
if (N && j.current && T === "continuous") {
|
|
5270
|
-
let e = st.top + j.current.clientHeight / 2, t = Math.max(0, Math.min(ft.length - 1,
|
|
5296
|
+
let e = st.top + j.current.clientHeight / 2, t = Math.max(0, Math.min(ft.length - 1, Dt(e))), n = ft[t] ? ft[t][0] : 1;
|
|
5271
5297
|
n !== P && F(n);
|
|
5272
5298
|
}
|
|
5273
5299
|
}, [
|
|
@@ -5275,7 +5301,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5275
5301
|
S,
|
|
5276
5302
|
N,
|
|
5277
5303
|
P,
|
|
5278
|
-
|
|
5304
|
+
Dt,
|
|
5279
5305
|
T,
|
|
5280
5306
|
ft
|
|
5281
5307
|
]), /* @__PURE__ */ L("div", {
|
|
@@ -5287,11 +5313,11 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5287
5313
|
overflow: "hidden"
|
|
5288
5314
|
},
|
|
5289
5315
|
children: [
|
|
5290
|
-
_ && /* @__PURE__ */ I(
|
|
5316
|
+
_ && /* @__PURE__ */ I(wt, {
|
|
5291
5317
|
isOpen: t,
|
|
5292
5318
|
pdfDoc: N,
|
|
5293
5319
|
pageNum: P,
|
|
5294
|
-
setPageNum: (e) =>
|
|
5320
|
+
setPageNum: (e) => Ot(e)
|
|
5295
5321
|
}),
|
|
5296
5322
|
/* @__PURE__ */ L("div", {
|
|
5297
5323
|
style: {
|
|
@@ -5304,7 +5330,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5304
5330
|
overflow: "hidden"
|
|
5305
5331
|
},
|
|
5306
5332
|
children: [
|
|
5307
|
-
z.isActive && /* @__PURE__ */ I(
|
|
5333
|
+
z.isActive && /* @__PURE__ */ I(Kt, {
|
|
5308
5334
|
compareState: z,
|
|
5309
5335
|
onSetMode: (e) => B((t) => ({
|
|
5310
5336
|
...t,
|
|
@@ -5322,12 +5348,12 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5322
5348
|
onPrevDiff: () => {
|
|
5323
5349
|
if (z.diffItems.length === 0) return;
|
|
5324
5350
|
let e = (z.currentDiffIndex - 1 + z.diffItems.length) % z.diffItems.length;
|
|
5325
|
-
|
|
5351
|
+
Nt(e);
|
|
5326
5352
|
},
|
|
5327
5353
|
onNextDiff: () => {
|
|
5328
5354
|
if (z.diffItems.length === 0) return;
|
|
5329
5355
|
let e = (z.currentDiffIndex + 1) % z.diffItems.length;
|
|
5330
|
-
|
|
5356
|
+
Nt(e);
|
|
5331
5357
|
},
|
|
5332
5358
|
onExit: () => {
|
|
5333
5359
|
B((e) => ({
|
|
@@ -5347,13 +5373,13 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5347
5373
|
height: "40px"
|
|
5348
5374
|
},
|
|
5349
5375
|
children: [
|
|
5350
|
-
/* @__PURE__ */ I(
|
|
5376
|
+
/* @__PURE__ */ I(K, {
|
|
5351
5377
|
icon: /* @__PURE__ */ I(Ie, { size: 16 }),
|
|
5352
5378
|
disabled: !u.canUndo,
|
|
5353
5379
|
onClick: Tn,
|
|
5354
5380
|
label: "Undo"
|
|
5355
5381
|
}),
|
|
5356
|
-
/* @__PURE__ */ I(
|
|
5382
|
+
/* @__PURE__ */ I(K, {
|
|
5357
5383
|
icon: /* @__PURE__ */ I(Ee, { size: 16 }),
|
|
5358
5384
|
disabled: !u.canRedo,
|
|
5359
5385
|
onClick: En,
|
|
@@ -5365,59 +5391,59 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5365
5391
|
backgroundColor: "var(--border-color)",
|
|
5366
5392
|
margin: "0 4px"
|
|
5367
5393
|
} }),
|
|
5368
|
-
/* @__PURE__ */ I(
|
|
5394
|
+
/* @__PURE__ */ I(K, {
|
|
5369
5395
|
icon: /* @__PURE__ */ I(fe, { size: 16 }),
|
|
5370
5396
|
active: W === "highlight",
|
|
5371
5397
|
onClick: () => {
|
|
5372
|
-
G("highlight"),
|
|
5398
|
+
G("highlight"), Ut("#fbc02d"), en(.5), Zt(16);
|
|
5373
5399
|
},
|
|
5374
5400
|
label: "Text Highlight"
|
|
5375
5401
|
}),
|
|
5376
|
-
/* @__PURE__ */ I(
|
|
5402
|
+
/* @__PURE__ */ I(K, {
|
|
5377
5403
|
icon: /* @__PURE__ */ I(Fe, { size: 16 }),
|
|
5378
5404
|
active: W === "underline",
|
|
5379
5405
|
onClick: () => {
|
|
5380
|
-
G("underline"),
|
|
5406
|
+
G("underline"), Ut("#d32f2f"), en(1), Zt(2);
|
|
5381
5407
|
},
|
|
5382
5408
|
label: "Underline"
|
|
5383
5409
|
}),
|
|
5384
|
-
/* @__PURE__ */ I(
|
|
5410
|
+
/* @__PURE__ */ I(K, {
|
|
5385
5411
|
icon: /* @__PURE__ */ I(Me, { size: 16 }),
|
|
5386
5412
|
active: W === "strikeout",
|
|
5387
5413
|
onClick: () => {
|
|
5388
|
-
G("strikeout"),
|
|
5414
|
+
G("strikeout"), Ut("#d32f2f"), en(1), Zt(2);
|
|
5389
5415
|
},
|
|
5390
5416
|
label: "Strikeout"
|
|
5391
5417
|
}),
|
|
5392
|
-
/* @__PURE__ */ I(
|
|
5393
|
-
icon: /* @__PURE__ */ I(
|
|
5418
|
+
/* @__PURE__ */ I(K, {
|
|
5419
|
+
icon: /* @__PURE__ */ I(an, { size: 16 }),
|
|
5394
5420
|
active: W === "squiggly",
|
|
5395
5421
|
onClick: () => {
|
|
5396
|
-
G("squiggly"),
|
|
5422
|
+
G("squiggly"), Ut("#388e3c"), en(1), Zt(1.5);
|
|
5397
5423
|
},
|
|
5398
5424
|
label: "Squiggly"
|
|
5399
5425
|
}),
|
|
5400
|
-
/* @__PURE__ */ I(
|
|
5426
|
+
/* @__PURE__ */ I(K, {
|
|
5401
5427
|
icon: /* @__PURE__ */ I(m, { size: 16 }),
|
|
5402
5428
|
active: W === "freehand",
|
|
5403
5429
|
onClick: () => {
|
|
5404
|
-
G("freehand"),
|
|
5430
|
+
G("freehand"), Ut("#000000"), en(1), Zt(2);
|
|
5405
5431
|
},
|
|
5406
5432
|
label: "Marker"
|
|
5407
5433
|
}),
|
|
5408
|
-
/* @__PURE__ */ I(
|
|
5434
|
+
/* @__PURE__ */ I(K, {
|
|
5409
5435
|
icon: /* @__PURE__ */ I(Pe, { size: 16 }),
|
|
5410
5436
|
active: W === "text",
|
|
5411
5437
|
onClick: () => {
|
|
5412
|
-
G("text"),
|
|
5438
|
+
G("text"), Ut("#000000"), en(1);
|
|
5413
5439
|
},
|
|
5414
5440
|
label: "Text"
|
|
5415
5441
|
}),
|
|
5416
|
-
A?.canRedact !== !1 && /* @__PURE__ */ I(
|
|
5442
|
+
A?.canRedact !== !1 && /* @__PURE__ */ I(K, {
|
|
5417
5443
|
icon: /* @__PURE__ */ I(oe, { size: 16 }),
|
|
5418
5444
|
active: W === "redaction",
|
|
5419
5445
|
onClick: () => {
|
|
5420
|
-
G("redaction"),
|
|
5446
|
+
G("redaction"), Ut("#000000"), en(1);
|
|
5421
5447
|
},
|
|
5422
5448
|
label: "Redact"
|
|
5423
5449
|
}),
|
|
@@ -5434,11 +5460,11 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5434
5460
|
borderRight: "1px solid var(--border-color)",
|
|
5435
5461
|
paddingRight: "8px"
|
|
5436
5462
|
},
|
|
5437
|
-
children: /* @__PURE__ */ I(
|
|
5463
|
+
children: /* @__PURE__ */ I(K, {
|
|
5438
5464
|
icon: /* @__PURE__ */ I(ge, { size: 16 }),
|
|
5439
5465
|
active: W === "callout",
|
|
5440
5466
|
onClick: () => {
|
|
5441
|
-
G("callout"), en(1),
|
|
5467
|
+
G("callout"), en(1), Zt(2);
|
|
5442
5468
|
},
|
|
5443
5469
|
label: "Callout"
|
|
5444
5470
|
})
|
|
@@ -5448,14 +5474,14 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5448
5474
|
display: "flex",
|
|
5449
5475
|
gap: "4px"
|
|
5450
5476
|
},
|
|
5451
|
-
children: [/* @__PURE__ */ I(
|
|
5477
|
+
children: [/* @__PURE__ */ I(K, {
|
|
5452
5478
|
icon: /* @__PURE__ */ I(Se, { size: 16 }),
|
|
5453
|
-
active: W === "freehand" &&
|
|
5479
|
+
active: W === "freehand" && Qt === 1,
|
|
5454
5480
|
onClick: () => {
|
|
5455
|
-
G("freehand"), en(1),
|
|
5481
|
+
G("freehand"), en(1), Zt(2);
|
|
5456
5482
|
},
|
|
5457
5483
|
label: "Freehand"
|
|
5458
|
-
}), A?.canDeleteAnnotations !== !1 && /* @__PURE__ */ I(
|
|
5484
|
+
}), A?.canDeleteAnnotations !== !1 && /* @__PURE__ */ I(K, {
|
|
5459
5485
|
icon: /* @__PURE__ */ I(ie, { size: 16 }),
|
|
5460
5486
|
active: W === "eraser",
|
|
5461
5487
|
onClick: () => G("eraser"),
|
|
@@ -5474,31 +5500,31 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5474
5500
|
gap: "4px"
|
|
5475
5501
|
},
|
|
5476
5502
|
children: [
|
|
5477
|
-
/* @__PURE__ */ I(
|
|
5503
|
+
/* @__PURE__ */ I(K, {
|
|
5478
5504
|
icon: /* @__PURE__ */ I(_e, { size: 16 }),
|
|
5479
5505
|
active: W === "line",
|
|
5480
5506
|
onClick: () => G("line"),
|
|
5481
5507
|
label: "Line"
|
|
5482
5508
|
}),
|
|
5483
|
-
/* @__PURE__ */ I(
|
|
5509
|
+
/* @__PURE__ */ I(K, {
|
|
5484
5510
|
icon: /* @__PURE__ */ I(f, { size: 16 }),
|
|
5485
5511
|
active: W === "arrow",
|
|
5486
5512
|
onClick: () => G("arrow"),
|
|
5487
5513
|
label: "Arrow"
|
|
5488
5514
|
}),
|
|
5489
|
-
/* @__PURE__ */ I(
|
|
5515
|
+
/* @__PURE__ */ I(K, {
|
|
5490
5516
|
icon: /* @__PURE__ */ I(je, { size: 16 }),
|
|
5491
5517
|
active: W === "rectangle",
|
|
5492
5518
|
onClick: () => G("rectangle"),
|
|
5493
5519
|
label: "Rectangle"
|
|
5494
5520
|
}),
|
|
5495
|
-
/* @__PURE__ */ I(
|
|
5521
|
+
/* @__PURE__ */ I(K, {
|
|
5496
5522
|
icon: /* @__PURE__ */ I(ee, { size: 16 }),
|
|
5497
5523
|
active: W === "ellipse",
|
|
5498
5524
|
onClick: () => G("ellipse"),
|
|
5499
5525
|
label: "Ellipse"
|
|
5500
5526
|
}),
|
|
5501
|
-
/* @__PURE__ */ I(
|
|
5527
|
+
/* @__PURE__ */ I(K, {
|
|
5502
5528
|
icon: /* @__PURE__ */ I(E, { size: 16 }),
|
|
5503
5529
|
active: W === "link",
|
|
5504
5530
|
onClick: () => G("link"),
|
|
@@ -5538,16 +5564,16 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5538
5564
|
color: "#666",
|
|
5539
5565
|
minWidth: "85px"
|
|
5540
5566
|
},
|
|
5541
|
-
children: ["Thickness: ", /* @__PURE__ */ L("strong", { children: [
|
|
5567
|
+
children: ["Thickness: ", /* @__PURE__ */ L("strong", { children: [Yt, "px"] })]
|
|
5542
5568
|
}), /* @__PURE__ */ I("input", {
|
|
5543
5569
|
type: "range",
|
|
5544
5570
|
min: "1",
|
|
5545
5571
|
max: "24",
|
|
5546
|
-
value: Math.min(24, Math.max(1,
|
|
5572
|
+
value: Math.min(24, Math.max(1, Yt)),
|
|
5547
5573
|
onMouseDown: (e) => e.stopPropagation(),
|
|
5548
5574
|
onChange: (e) => {
|
|
5549
5575
|
let t = parseInt(e.target.value, 10);
|
|
5550
|
-
|
|
5576
|
+
Zt(t), X && !Y && Q(U.map((e) => e.id === X ? {
|
|
5551
5577
|
...e,
|
|
5552
5578
|
strokeWidth: t
|
|
5553
5579
|
} : e));
|
|
@@ -5574,7 +5600,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5574
5600
|
].map((e) => /* @__PURE__ */ I("button", {
|
|
5575
5601
|
onMouseDown: (e) => e.preventDefault(),
|
|
5576
5602
|
onClick: () => {
|
|
5577
|
-
|
|
5603
|
+
Ut(e), X && !Y && Q(U.map((t) => t.id === X ? {
|
|
5578
5604
|
...t,
|
|
5579
5605
|
color: e
|
|
5580
5606
|
} : t));
|
|
@@ -5584,7 +5610,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5584
5610
|
height: "18px",
|
|
5585
5611
|
borderRadius: "50%",
|
|
5586
5612
|
backgroundColor: e,
|
|
5587
|
-
border:
|
|
5613
|
+
border: Bt === e ? "2px solid #000" : "1px solid transparent",
|
|
5588
5614
|
cursor: "pointer",
|
|
5589
5615
|
outline: "none",
|
|
5590
5616
|
padding: 0
|
|
@@ -5803,7 +5829,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5803
5829
|
overflow: "hidden",
|
|
5804
5830
|
position: "relative"
|
|
5805
5831
|
},
|
|
5806
|
-
children: [z.isActive && z.mode === "side-by-side" ? /* @__PURE__ */ I(
|
|
5832
|
+
children: [z.isActive && z.mode === "side-by-side" ? /* @__PURE__ */ I(Gt, {
|
|
5807
5833
|
pdfDocA: N,
|
|
5808
5834
|
pdfDocB: He,
|
|
5809
5835
|
pageNum: P,
|
|
@@ -5822,7 +5848,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5822
5848
|
selectedDiffId: z.diffItems[z.currentDiffIndex]?.id,
|
|
5823
5849
|
onSelectDiff: (e) => {
|
|
5824
5850
|
let t = z.diffItems.findIndex((t) => t.id === e);
|
|
5825
|
-
t !== -1 &&
|
|
5851
|
+
t !== -1 && Nt(t);
|
|
5826
5852
|
}
|
|
5827
5853
|
}) : /* @__PURE__ */ L(Le, { children: [W === "highlight" && /* @__PURE__ */ I("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__ */ L("div", {
|
|
5828
5854
|
className: "pdf-viewer-area",
|
|
@@ -5853,7 +5879,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5853
5879
|
ct({
|
|
5854
5880
|
top: e.currentTarget.scrollTop,
|
|
5855
5881
|
left: e.currentTarget.scrollLeft
|
|
5856
|
-
}),
|
|
5882
|
+
}), bt.current = Dt(e.currentTarget.scrollTop);
|
|
5857
5883
|
},
|
|
5858
5884
|
onMouseDown: (e) => {
|
|
5859
5885
|
W === "pan" && e.button === 0 && (ut(!0), dt.current = {
|
|
@@ -5880,21 +5906,21 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5880
5906
|
let i = r ? pt.tops[n] ?? 0 : 0;
|
|
5881
5907
|
if (r && j.current) {
|
|
5882
5908
|
let e = S >= 4 ? 1 : S >= 2 ? 2 : 4, t = S >= 4 ? 1 : S >= 2 ? 2 : 5;
|
|
5883
|
-
if (n <
|
|
5909
|
+
if (n < bt.current - e || n > bt.current + t) return null;
|
|
5884
5910
|
}
|
|
5885
|
-
let o =
|
|
5911
|
+
let o = tn && rn && W && W !== "eraser" ? (() => {
|
|
5886
5912
|
if (W === "freehand") return {
|
|
5887
5913
|
id: "temp-live-drawing",
|
|
5888
5914
|
type: "freehand",
|
|
5889
|
-
pageIndex:
|
|
5915
|
+
pageIndex: rn,
|
|
5890
5916
|
x: 0,
|
|
5891
5917
|
y: 0,
|
|
5892
5918
|
width: 0,
|
|
5893
5919
|
height: 0,
|
|
5894
|
-
points:
|
|
5895
|
-
color:
|
|
5896
|
-
strokeWidth:
|
|
5897
|
-
opacity:
|
|
5920
|
+
points: ln,
|
|
5921
|
+
color: Bt,
|
|
5922
|
+
strokeWidth: Yt,
|
|
5923
|
+
opacity: Qt
|
|
5898
5924
|
};
|
|
5899
5925
|
if ([
|
|
5900
5926
|
"highlight",
|
|
@@ -5902,26 +5928,26 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5902
5928
|
"strikeout",
|
|
5903
5929
|
"squiggly"
|
|
5904
5930
|
].includes(W)) {
|
|
5905
|
-
let e = Math.abs(
|
|
5906
|
-
return t < 18 && (t = Math.max(18, t), r =
|
|
5931
|
+
let e = Math.abs(J.x - q.x), t = Math.abs(J.y - q.y), n = Math.min(q.x, J.x), r = Math.min(q.y, J.y);
|
|
5932
|
+
return t < 18 && (t = Math.max(18, t), r = q.y - 9), {
|
|
5907
5933
|
id: "temp-live-drawing",
|
|
5908
5934
|
type: W,
|
|
5909
|
-
pageIndex:
|
|
5935
|
+
pageIndex: rn,
|
|
5910
5936
|
x: n,
|
|
5911
5937
|
y: r,
|
|
5912
5938
|
width: e,
|
|
5913
5939
|
height: t,
|
|
5914
|
-
color:
|
|
5915
|
-
strokeWidth:
|
|
5916
|
-
opacity: W === "highlight" ?
|
|
5940
|
+
color: Bt,
|
|
5941
|
+
strokeWidth: Yt,
|
|
5942
|
+
opacity: W === "highlight" ? Qt : 1
|
|
5917
5943
|
};
|
|
5918
5944
|
}
|
|
5919
5945
|
if (W === "redaction") {
|
|
5920
|
-
let e = Math.abs(
|
|
5921
|
-
return t < 18 && (t = Math.max(18, t), r =
|
|
5946
|
+
let e = Math.abs(J.x - q.x), t = Math.abs(J.y - q.y), n = Math.min(q.x, J.x), r = Math.min(q.y, J.y);
|
|
5947
|
+
return t < 18 && (t = Math.max(18, t), r = q.y - 9), {
|
|
5922
5948
|
id: "temp-live-drawing",
|
|
5923
5949
|
type: "rectangle",
|
|
5924
|
-
pageIndex:
|
|
5950
|
+
pageIndex: rn,
|
|
5925
5951
|
x: n,
|
|
5926
5952
|
y: r,
|
|
5927
5953
|
width: e,
|
|
@@ -5939,19 +5965,19 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5939
5965
|
"ellipse",
|
|
5940
5966
|
"link"
|
|
5941
5967
|
].includes(W)) {
|
|
5942
|
-
let e = Math.abs(
|
|
5968
|
+
let e = Math.abs(J.x - q.x), t = Math.abs(J.y - q.y), n = Math.min(q.x, J.x), r = Math.min(q.y, J.y);
|
|
5943
5969
|
return {
|
|
5944
5970
|
id: "temp-live-drawing",
|
|
5945
5971
|
type: W,
|
|
5946
|
-
pageIndex:
|
|
5972
|
+
pageIndex: rn,
|
|
5947
5973
|
x: n,
|
|
5948
5974
|
y: r,
|
|
5949
5975
|
width: e,
|
|
5950
5976
|
height: t,
|
|
5951
|
-
points: W === "line" || W === "arrow" || W === "callout" ? [
|
|
5952
|
-
color:
|
|
5953
|
-
strokeWidth:
|
|
5954
|
-
opacity:
|
|
5977
|
+
points: W === "line" || W === "arrow" || W === "callout" ? [q, J] : void 0,
|
|
5978
|
+
color: Bt,
|
|
5979
|
+
strokeWidth: Yt,
|
|
5980
|
+
opacity: Qt
|
|
5955
5981
|
};
|
|
5956
5982
|
}
|
|
5957
5983
|
})() : null;
|
|
@@ -5960,7 +5986,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5960
5986
|
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);
|
|
5961
5987
|
let f = U.map((e) => Dn && e.id === Dn.id ? Dn : kn && e.id === kn.id ? kn : e), p = o && o.pageIndex === n ? [...f, o] : f;
|
|
5962
5988
|
return /* @__PURE__ */ L(e.Fragment, { children: [
|
|
5963
|
-
/* @__PURE__ */ I(
|
|
5989
|
+
/* @__PURE__ */ I(jt, {
|
|
5964
5990
|
pageNum: n,
|
|
5965
5991
|
pdfDoc: N,
|
|
5966
5992
|
scale: S,
|
|
@@ -5977,7 +6003,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5977
6003
|
activeTool: W,
|
|
5978
6004
|
annotations: p,
|
|
5979
6005
|
transientHighlights: be?.filter((e) => e.pageIndex === n) || [],
|
|
5980
|
-
selectedAnnotationId:
|
|
6006
|
+
selectedAnnotationId: X,
|
|
5981
6007
|
activeSearchResult: et,
|
|
5982
6008
|
onMouseDown: rr,
|
|
5983
6009
|
onMouseMove: ar,
|
|
@@ -5992,7 +6018,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5992
6018
|
yn.current = !1;
|
|
5993
6019
|
return;
|
|
5994
6020
|
}
|
|
5995
|
-
|
|
6021
|
+
Z(null), gn(null);
|
|
5996
6022
|
},
|
|
5997
6023
|
watermark: pe,
|
|
5998
6024
|
watermarkText: me,
|
|
@@ -6014,7 +6040,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
6014
6040
|
zIndex: 12,
|
|
6015
6041
|
filter: "contrast(1.2) brightness(0.95)"
|
|
6016
6042
|
},
|
|
6017
|
-
children: /* @__PURE__ */ I(
|
|
6043
|
+
children: /* @__PURE__ */ I(jt, {
|
|
6018
6044
|
pageNum: n,
|
|
6019
6045
|
pdfDoc: He,
|
|
6020
6046
|
scale: S,
|
|
@@ -6050,18 +6076,18 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
6050
6076
|
pointerEvents: "none",
|
|
6051
6077
|
zIndex: 16
|
|
6052
6078
|
},
|
|
6053
|
-
children: /* @__PURE__ */ I(
|
|
6079
|
+
children: /* @__PURE__ */ I(Wt, {
|
|
6054
6080
|
boxes: [...z.pageDiffsA?.[n] || [], ...z.pageDiffsB?.[n] || []],
|
|
6055
6081
|
scale: S,
|
|
6056
6082
|
selectedDiffId: z.diffItems[z.currentDiffIndex]?.id,
|
|
6057
6083
|
onSelectDiff: (e) => {
|
|
6058
6084
|
let t = z.diffItems.findIndex((t) => t.id === e);
|
|
6059
|
-
t !== -1 &&
|
|
6085
|
+
t !== -1 && Nt(t);
|
|
6060
6086
|
}
|
|
6061
6087
|
})
|
|
6062
6088
|
}),
|
|
6063
|
-
|
|
6064
|
-
let e = O % 180 == 0 ? l.width : l.height, t = O % 180 == 0 ? l.height : l.width, n =
|
|
6089
|
+
Y && Y.pageIndex === n && (() => {
|
|
6090
|
+
let e = O % 180 == 0 ? l.width : l.height, t = O % 180 == 0 ? l.height : l.width, n = Et(Y.x, Y.y, O, e, t);
|
|
6065
6091
|
return /* @__PURE__ */ L("div", {
|
|
6066
6092
|
style: {
|
|
6067
6093
|
position: "absolute",
|
|
@@ -6075,9 +6101,9 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
6075
6101
|
flexDirection: "column"
|
|
6076
6102
|
},
|
|
6077
6103
|
children: [/* @__PURE__ */ I("textarea", {
|
|
6078
|
-
ref:
|
|
6079
|
-
value:
|
|
6080
|
-
onChange: (e) =>
|
|
6104
|
+
ref: mn,
|
|
6105
|
+
value: fn,
|
|
6106
|
+
onChange: (e) => pn(e.target.value),
|
|
6081
6107
|
onBlur: (e) => {
|
|
6082
6108
|
e.currentTarget.parentElement?.contains(e.relatedTarget) || ir();
|
|
6083
6109
|
},
|
|
@@ -6087,7 +6113,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
6087
6113
|
style: {
|
|
6088
6114
|
backgroundColor: "transparent",
|
|
6089
6115
|
border: "none",
|
|
6090
|
-
color:
|
|
6116
|
+
color: Bt,
|
|
6091
6117
|
fontSize: "16px",
|
|
6092
6118
|
fontFamily: "sans-serif",
|
|
6093
6119
|
minWidth: "150px",
|
|
@@ -6096,7 +6122,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
6096
6122
|
resize: "both",
|
|
6097
6123
|
padding: "8px"
|
|
6098
6124
|
},
|
|
6099
|
-
placeholder:
|
|
6125
|
+
placeholder: Y.type === "note" ? "Note text..." : "Type text...",
|
|
6100
6126
|
autoFocus: !0
|
|
6101
6127
|
}), /* @__PURE__ */ I("div", {
|
|
6102
6128
|
style: {
|
|
@@ -6254,7 +6280,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
6254
6280
|
},
|
|
6255
6281
|
children: [
|
|
6256
6282
|
/* @__PURE__ */ I("button", {
|
|
6257
|
-
onClick: () =>
|
|
6283
|
+
onClick: () => Ot(Math.max(1, P - 1)),
|
|
6258
6284
|
disabled: P <= 1,
|
|
6259
6285
|
style: {
|
|
6260
6286
|
background: "none",
|
|
@@ -6281,7 +6307,7 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
6281
6307
|
]
|
|
6282
6308
|
}),
|
|
6283
6309
|
/* @__PURE__ */ I("button", {
|
|
6284
|
-
onClick: () =>
|
|
6310
|
+
onClick: () => Ot(Math.min(N.numPages, P + 1)),
|
|
6285
6311
|
disabled: P >= N.numPages,
|
|
6286
6312
|
style: {
|
|
6287
6313
|
background: "none",
|
|
@@ -6295,15 +6321,15 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
6295
6321
|
})
|
|
6296
6322
|
]
|
|
6297
6323
|
}),
|
|
6298
|
-
|
|
6299
|
-
annotation: U.find((e) => e.id ===
|
|
6300
|
-
position:
|
|
6324
|
+
X && hn && /* @__PURE__ */ I(at, {
|
|
6325
|
+
annotation: U.find((e) => e.id === X),
|
|
6326
|
+
position: hn,
|
|
6301
6327
|
onCopy: () => {
|
|
6302
|
-
let e = U.find((e) => e.id ===
|
|
6328
|
+
let e = U.find((e) => e.id === X);
|
|
6303
6329
|
if (e) {
|
|
6304
6330
|
let t = {
|
|
6305
6331
|
...e,
|
|
6306
|
-
id:
|
|
6332
|
+
id: Mt(),
|
|
6307
6333
|
author: void 0,
|
|
6308
6334
|
authorId: void 0,
|
|
6309
6335
|
createdAt: void 0,
|
|
@@ -6315,23 +6341,23 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
6315
6341
|
};
|
|
6316
6342
|
Q([...U, t]);
|
|
6317
6343
|
}
|
|
6318
|
-
|
|
6344
|
+
Z(null), gn(null);
|
|
6319
6345
|
},
|
|
6320
6346
|
onDelete: () => {
|
|
6321
|
-
Q(U.filter((e) => e.id !==
|
|
6347
|
+
Q(U.filter((e) => e.id !== X)), Z(null), gn(null);
|
|
6322
6348
|
},
|
|
6323
6349
|
onUpdateColor: (e) => {
|
|
6324
|
-
Q(U.map((t) => t.id ===
|
|
6350
|
+
Q(U.map((t) => t.id === X ? {
|
|
6325
6351
|
...t,
|
|
6326
6352
|
color: e
|
|
6327
6353
|
} : t));
|
|
6328
6354
|
},
|
|
6329
6355
|
onOpenLinkModal: () => {
|
|
6330
|
-
vn(!0),
|
|
6356
|
+
vn(!0), gn(null);
|
|
6331
6357
|
},
|
|
6332
6358
|
permissions: A
|
|
6333
6359
|
}),
|
|
6334
|
-
z.isActive && z.showCurtain && /* @__PURE__ */ I(
|
|
6360
|
+
z.isActive && z.showCurtain && /* @__PURE__ */ I(Jt, {
|
|
6335
6361
|
positionPercent: z.curtainPosition,
|
|
6336
6362
|
onChangePosition: (e) => B((t) => ({
|
|
6337
6363
|
...t,
|
|
@@ -6339,35 +6365,35 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
6339
6365
|
})),
|
|
6340
6366
|
containerRef: j
|
|
6341
6367
|
}),
|
|
6342
|
-
Ce !== !1 && Te !== !1 && /* @__PURE__ */ I(
|
|
6368
|
+
Ce !== !1 && Te !== !1 && /* @__PURE__ */ I(Pt, {
|
|
6343
6369
|
containerRef: j,
|
|
6344
6370
|
onCopy: (e) => M.emit("action-text-copied", { text: e }),
|
|
6345
6371
|
onAnnotateSelection: Ln
|
|
6346
6372
|
})
|
|
6347
6373
|
]
|
|
6348
|
-
})] }), z.isActive && /* @__PURE__ */ I(
|
|
6374
|
+
})] }), z.isActive && /* @__PURE__ */ I(qt, {
|
|
6349
6375
|
isOpen: qe,
|
|
6350
6376
|
onClose: () => Je(!1),
|
|
6351
6377
|
diffItems: z.diffItems,
|
|
6352
6378
|
textDiffs: Ge,
|
|
6353
6379
|
currentDiffIndex: z.currentDiffIndex,
|
|
6354
|
-
onSelectDiff: (e, t) =>
|
|
6355
|
-
onJumpToPage: (e) =>
|
|
6380
|
+
onSelectDiff: (e, t) => Nt(e, t),
|
|
6381
|
+
onJumpToPage: (e) => Ot(e)
|
|
6356
6382
|
})]
|
|
6357
6383
|
})
|
|
6358
6384
|
]
|
|
6359
6385
|
}),
|
|
6360
|
-
_n &&
|
|
6361
|
-
initialUrl: U.find((e) => e.id ===
|
|
6362
|
-
initialText: U.find((e) => e.id ===
|
|
6363
|
-
showTextInput: !U.find((e) => e.id ===
|
|
6386
|
+
_n && X && /* @__PURE__ */ I(ot, {
|
|
6387
|
+
initialUrl: U.find((e) => e.id === X)?.linkUrl || "",
|
|
6388
|
+
initialText: U.find((e) => e.id === X)?.text || "",
|
|
6389
|
+
showTextInput: !U.find((e) => e.id === X)?.width || U.find((e) => e.id === X)?.text === "" || U.find((e) => e.id === X)?.text !== void 0,
|
|
6364
6390
|
onClose: () => {
|
|
6365
|
-
let e = U.find((e) => e.id ===
|
|
6366
|
-
e && !e.linkUrl && Q(U.filter((e) => e.id !==
|
|
6391
|
+
let e = U.find((e) => e.id === X);
|
|
6392
|
+
e && !e.linkUrl && Q(U.filter((e) => e.id !== X)), vn(!1), Z(null);
|
|
6367
6393
|
},
|
|
6368
6394
|
onSave: (e, t) => {
|
|
6369
6395
|
Q(U.map((n) => {
|
|
6370
|
-
if (n.id ===
|
|
6396
|
+
if (n.id === X) {
|
|
6371
6397
|
let r = t === void 0 ? n.text : t, i = r ? Math.max(100, r.length * 8 + 20) : n.width;
|
|
6372
6398
|
return {
|
|
6373
6399
|
...n,
|
|
@@ -6377,27 +6403,27 @@ function en({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
6377
6403
|
};
|
|
6378
6404
|
}
|
|
6379
6405
|
return n;
|
|
6380
|
-
})), vn(!1),
|
|
6406
|
+
})), vn(!1), Z(null);
|
|
6381
6407
|
}
|
|
6382
6408
|
}),
|
|
6383
|
-
_ && /* @__PURE__ */ I(
|
|
6409
|
+
_ && /* @__PURE__ */ I(St, {
|
|
6384
6410
|
isOpen: r,
|
|
6385
6411
|
activeTab: ne,
|
|
6386
6412
|
setActiveTab: re,
|
|
6387
6413
|
annotations: U,
|
|
6388
6414
|
setAnnotations: Q,
|
|
6389
|
-
selectedAnnotationId:
|
|
6390
|
-
setSelectedAnnotationId:
|
|
6415
|
+
selectedAnnotationId: X,
|
|
6416
|
+
setSelectedAnnotationId: Z,
|
|
6391
6417
|
onSearch: Kn,
|
|
6392
6418
|
searchResults: qn,
|
|
6393
6419
|
isSearching: Jn,
|
|
6394
6420
|
searchProgress: Yn,
|
|
6395
|
-
onResultClick:
|
|
6421
|
+
onResultClick: At
|
|
6396
6422
|
})
|
|
6397
6423
|
]
|
|
6398
6424
|
});
|
|
6399
6425
|
}
|
|
6400
|
-
function
|
|
6426
|
+
function K({ icon: e, active: t, onClick: n, label: r, disabled: i }) {
|
|
6401
6427
|
return /* @__PURE__ */ I("button", {
|
|
6402
6428
|
onClick: i ? void 0 : n,
|
|
6403
6429
|
title: r,
|
|
@@ -6425,7 +6451,7 @@ function tn({ icon: e, active: t, onClick: n, label: r, disabled: i }) {
|
|
|
6425
6451
|
children: e
|
|
6426
6452
|
});
|
|
6427
6453
|
}
|
|
6428
|
-
function
|
|
6454
|
+
function an({ size: e = 16 }) {
|
|
6429
6455
|
return /* @__PURE__ */ L("svg", {
|
|
6430
6456
|
width: e,
|
|
6431
6457
|
height: e,
|
|
@@ -6440,7 +6466,7 @@ function nn({ size: e = 16 }) {
|
|
|
6440
6466
|
}
|
|
6441
6467
|
//#endregion
|
|
6442
6468
|
//#region src/components/SettingsModal.tsx
|
|
6443
|
-
function
|
|
6469
|
+
function on({ onClose: e, watermarkText: t, setWatermarkText: n }) {
|
|
6444
6470
|
let { shortcuts: r, updateShortcut: i, resetShortcuts: a } = mt(), [s, l] = c("Keyboard Shortcuts"), [u, d] = c(null), [f, p] = c(""), m = (e, t) => {
|
|
6445
6471
|
if (e.preventDefault(), e.stopPropagation(), e.key === "Escape") {
|
|
6446
6472
|
d(null);
|
|
@@ -6969,7 +6995,7 @@ function rn({ onClose: e, watermarkText: t, setWatermarkText: n }) {
|
|
|
6969
6995
|
}
|
|
6970
6996
|
//#endregion
|
|
6971
6997
|
//#region src/components/AboutModal.tsx
|
|
6972
|
-
function
|
|
6998
|
+
function q({ onClose: e }) {
|
|
6973
6999
|
return /* @__PURE__ */ I("div", {
|
|
6974
7000
|
style: {
|
|
6975
7001
|
position: "fixed",
|
|
@@ -7190,7 +7216,7 @@ function an({ onClose: e }) {
|
|
|
7190
7216
|
}
|
|
7191
7217
|
//#endregion
|
|
7192
7218
|
//#region src/core/eventBus.ts
|
|
7193
|
-
var
|
|
7219
|
+
var sn = class {
|
|
7194
7220
|
listeners = /* @__PURE__ */ new Map();
|
|
7195
7221
|
destroyed = !1;
|
|
7196
7222
|
on(e, t) {
|
|
@@ -7232,22 +7258,22 @@ var on = class {
|
|
|
7232
7258
|
get isDestroyed() {
|
|
7233
7259
|
return this.destroyed;
|
|
7234
7260
|
}
|
|
7235
|
-
},
|
|
7236
|
-
function
|
|
7261
|
+
}, J = (e) => e === 0 ? 0 : e;
|
|
7262
|
+
function cn(e, t) {
|
|
7237
7263
|
return {
|
|
7238
|
-
x:
|
|
7239
|
-
y:
|
|
7264
|
+
x: J(e.x * t[0] + e.y * t[2] + t[4]),
|
|
7265
|
+
y: J(e.x * t[1] + e.y * t[3] + t[5])
|
|
7240
7266
|
};
|
|
7241
7267
|
}
|
|
7242
|
-
function
|
|
7268
|
+
function ln(e, t) {
|
|
7243
7269
|
let n = t[0] * t[3] - t[1] * t[2];
|
|
7244
7270
|
return {
|
|
7245
|
-
x:
|
|
7246
|
-
y:
|
|
7271
|
+
x: J((e.x * t[3] - e.y * t[2] + t[2] * t[5] - t[4] * t[3]) / n),
|
|
7272
|
+
y: J((-e.x * t[1] + e.y * t[0] + t[4] * t[1] - t[5] * t[0]) / n)
|
|
7247
7273
|
};
|
|
7248
7274
|
}
|
|
7249
|
-
function
|
|
7250
|
-
let r =
|
|
7275
|
+
function un(e, t, n) {
|
|
7276
|
+
let r = kt(n), [i, a, o, s] = t, c = (o + i) / 2, l = (s + a) / 2, u, d, f, p;
|
|
7251
7277
|
switch (r) {
|
|
7252
7278
|
case 180:
|
|
7253
7279
|
u = -1, d = 0, f = 0, p = 1;
|
|
@@ -7284,33 +7310,33 @@ function q(e, t, n) {
|
|
|
7284
7310
|
transform: v
|
|
7285
7311
|
};
|
|
7286
7312
|
}
|
|
7287
|
-
function
|
|
7313
|
+
function Y(e) {
|
|
7288
7314
|
let t = e.view;
|
|
7289
|
-
return
|
|
7315
|
+
return un(e.pageNumber, [
|
|
7290
7316
|
t[0],
|
|
7291
7317
|
t[1],
|
|
7292
7318
|
t[2],
|
|
7293
7319
|
t[3]
|
|
7294
7320
|
], e.rotate);
|
|
7295
7321
|
}
|
|
7296
|
-
function
|
|
7322
|
+
function dn(e) {
|
|
7297
7323
|
let t = /* @__PURE__ */ new Map();
|
|
7298
7324
|
return (n) => {
|
|
7299
7325
|
let r = Math.max(1, Math.min(e.numPages, n)), i = t.get(r);
|
|
7300
|
-
return i || (i = e.getPage(r).then(
|
|
7326
|
+
return i || (i = e.getPage(r).then(Y), t.set(r, i)), i;
|
|
7301
7327
|
};
|
|
7302
7328
|
}
|
|
7303
|
-
function
|
|
7304
|
-
return
|
|
7329
|
+
function fn(e, t) {
|
|
7330
|
+
return ln(t, e.transform);
|
|
7305
7331
|
}
|
|
7306
|
-
function
|
|
7307
|
-
return
|
|
7332
|
+
function pn(e, t) {
|
|
7333
|
+
return cn(t, e.transform);
|
|
7308
7334
|
}
|
|
7309
|
-
function
|
|
7310
|
-
let n =
|
|
7335
|
+
function mn(e, t) {
|
|
7336
|
+
let n = fn(e, {
|
|
7311
7337
|
x: t.x,
|
|
7312
7338
|
y: t.y
|
|
7313
|
-
}), r =
|
|
7339
|
+
}), r = fn(e, {
|
|
7314
7340
|
x: t.x + t.width,
|
|
7315
7341
|
y: t.y + t.height
|
|
7316
7342
|
});
|
|
@@ -7321,11 +7347,11 @@ function fn(e, t) {
|
|
|
7321
7347
|
Math.max(n.y, r.y)
|
|
7322
7348
|
];
|
|
7323
7349
|
}
|
|
7324
|
-
function
|
|
7325
|
-
let n =
|
|
7350
|
+
function X(e, t) {
|
|
7351
|
+
let n = pn(e, {
|
|
7326
7352
|
x: t[0],
|
|
7327
7353
|
y: t[1]
|
|
7328
|
-
}), r =
|
|
7354
|
+
}), r = pn(e, {
|
|
7329
7355
|
x: t[2],
|
|
7330
7356
|
y: t[3]
|
|
7331
7357
|
});
|
|
@@ -7336,14 +7362,14 @@ function pn(e, t) {
|
|
|
7336
7362
|
height: Math.abs(r.y - n.y)
|
|
7337
7363
|
};
|
|
7338
7364
|
}
|
|
7339
|
-
function
|
|
7340
|
-
return t.map((t) =>
|
|
7365
|
+
function Z(e, t) {
|
|
7366
|
+
return t.map((t) => fn(e, t));
|
|
7341
7367
|
}
|
|
7342
7368
|
function hn(e, t) {
|
|
7343
|
-
return t.map((t) =>
|
|
7369
|
+
return t.map((t) => pn(e, t));
|
|
7344
7370
|
}
|
|
7345
|
-
function
|
|
7346
|
-
let [n, r, i, a] =
|
|
7371
|
+
function gn(e, t) {
|
|
7372
|
+
let [n, r, i, a] = mn(e, t);
|
|
7347
7373
|
return [
|
|
7348
7374
|
n,
|
|
7349
7375
|
a,
|
|
@@ -7355,7 +7381,7 @@ function Y(e, t) {
|
|
|
7355
7381
|
r
|
|
7356
7382
|
];
|
|
7357
7383
|
}
|
|
7358
|
-
function
|
|
7384
|
+
function _n(e, t) {
|
|
7359
7385
|
let n = [];
|
|
7360
7386
|
for (let r = 0; r + 7 < t.length; r += 8) {
|
|
7361
7387
|
let i = [
|
|
@@ -7369,7 +7395,7 @@ function X(e, t) {
|
|
|
7369
7395
|
t[r + 5],
|
|
7370
7396
|
t[r + 7]
|
|
7371
7397
|
];
|
|
7372
|
-
n.push(
|
|
7398
|
+
n.push(X(e, [
|
|
7373
7399
|
Math.min(...i),
|
|
7374
7400
|
Math.min(...a),
|
|
7375
7401
|
Math.max(...i),
|
|
@@ -7378,7 +7404,7 @@ function X(e, t) {
|
|
|
7378
7404
|
}
|
|
7379
7405
|
return n;
|
|
7380
7406
|
}
|
|
7381
|
-
function
|
|
7407
|
+
function vn(e) {
|
|
7382
7408
|
if (e.length === 0) return {
|
|
7383
7409
|
x: 0,
|
|
7384
7410
|
y: 0,
|
|
@@ -7393,11 +7419,11 @@ function gn(e) {
|
|
|
7393
7419
|
height: i - n
|
|
7394
7420
|
};
|
|
7395
7421
|
}
|
|
7396
|
-
var
|
|
7422
|
+
var yn = (e) => (Math.round(e * 1e3) / 1e3).toString(), bn = 524288e3, xn = (e) => {
|
|
7397
7423
|
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;
|
|
7398
7424
|
return R(n, r, i);
|
|
7399
7425
|
};
|
|
7400
|
-
function
|
|
7426
|
+
function Sn(e, t, n) {
|
|
7401
7427
|
let r = n * .55, i = Math.max(1, Math.floor(t / r)), a = e.split("\n"), o = [];
|
|
7402
7428
|
for (let e of a) {
|
|
7403
7429
|
if (!e) {
|
|
@@ -7410,13 +7436,13 @@ function yn(e, t, n) {
|
|
|
7410
7436
|
}
|
|
7411
7437
|
return o;
|
|
7412
7438
|
}
|
|
7413
|
-
async function
|
|
7414
|
-
let a =
|
|
7439
|
+
async function Cn(e, t, n, r, i) {
|
|
7440
|
+
let a = xn(r.color), o = r.opacity ?? 1, s = r.strokeWidth || 1, [c, l, u, d] = mn(n, {
|
|
7415
7441
|
x: r.x,
|
|
7416
7442
|
y: r.y,
|
|
7417
7443
|
width: r.width,
|
|
7418
7444
|
height: r.height
|
|
7419
|
-
}), f = u - c, p = d - l, m = He(n.rotate), h = (e, t, r) =>
|
|
7445
|
+
}), f = u - c, p = d - l, m = He(n.rotate), h = (e, t, r) => fn(n, {
|
|
7420
7446
|
x: e,
|
|
7421
7447
|
y: t + r
|
|
7422
7448
|
});
|
|
@@ -7455,7 +7481,7 @@ async function bn(e, t, n, r, i) {
|
|
|
7455
7481
|
height: r.height
|
|
7456
7482
|
}];
|
|
7457
7483
|
for (let r of e) {
|
|
7458
|
-
let [e, i, s, c] =
|
|
7484
|
+
let [e, i, s, c] = mn(n, r);
|
|
7459
7485
|
t.drawRectangle({
|
|
7460
7486
|
x: e,
|
|
7461
7487
|
y: i,
|
|
@@ -7476,7 +7502,7 @@ async function bn(e, t, n, r, i) {
|
|
|
7476
7502
|
height: r.height
|
|
7477
7503
|
}];
|
|
7478
7504
|
for (let r of e) {
|
|
7479
|
-
let [e, i] =
|
|
7505
|
+
let [e, i] = Z(n, [{
|
|
7480
7506
|
x: r.x,
|
|
7481
7507
|
y: r.y + r.height - 1.5
|
|
7482
7508
|
}, {
|
|
@@ -7501,7 +7527,7 @@ async function bn(e, t, n, r, i) {
|
|
|
7501
7527
|
height: r.height
|
|
7502
7528
|
}];
|
|
7503
7529
|
for (let r of e) {
|
|
7504
|
-
let [e, i] =
|
|
7530
|
+
let [e, i] = Z(n, [{
|
|
7505
7531
|
x: r.x,
|
|
7506
7532
|
y: r.y + r.height / 2
|
|
7507
7533
|
}, {
|
|
@@ -7532,7 +7558,7 @@ async function bn(e, t, n, r, i) {
|
|
|
7532
7558
|
y: r.y + r.height - (i ? 3 : 1)
|
|
7533
7559
|
}), i = !i;
|
|
7534
7560
|
if (e.length >= 2) {
|
|
7535
|
-
let r =
|
|
7561
|
+
let r = Z(n, e);
|
|
7536
7562
|
for (let e = 1; e < r.length; e++) t.drawLine({
|
|
7537
7563
|
start: r[e - 1],
|
|
7538
7564
|
end: r[e],
|
|
@@ -7552,7 +7578,7 @@ async function bn(e, t, n, r, i) {
|
|
|
7552
7578
|
}, {
|
|
7553
7579
|
x: r.x + r.width,
|
|
7554
7580
|
y: r.y + r.height
|
|
7555
|
-
}], [i, c] =
|
|
7581
|
+
}], [i, c] = Z(n, [e[0], e[1]]);
|
|
7556
7582
|
if (t.drawLine({
|
|
7557
7583
|
start: i,
|
|
7558
7584
|
end: c,
|
|
@@ -7560,7 +7586,7 @@ async function bn(e, t, n, r, i) {
|
|
|
7560
7586
|
opacity: o,
|
|
7561
7587
|
thickness: s
|
|
7562
7588
|
}), r.type === "arrow") {
|
|
7563
|
-
let r = e[0], i = e[1], l = Math.atan2(i.y - r.y, i.x - r.x), u = 15 + s, [d, f] =
|
|
7589
|
+
let r = e[0], i = e[1], l = Math.atan2(i.y - r.y, i.x - r.x), u = 15 + s, [d, f] = Z(n, [{
|
|
7564
7590
|
x: i.x - u * Math.cos(l - Math.PI / 6),
|
|
7565
7591
|
y: i.y - u * Math.sin(l - Math.PI / 6)
|
|
7566
7592
|
}, {
|
|
@@ -7586,7 +7612,7 @@ async function bn(e, t, n, r, i) {
|
|
|
7586
7612
|
case "freehand": {
|
|
7587
7613
|
let e = r.strokes && r.strokes.length > 0 ? r.strokes : r.points ? [r.points] : [];
|
|
7588
7614
|
for (let r of e) {
|
|
7589
|
-
let e =
|
|
7615
|
+
let e = Z(n, r);
|
|
7590
7616
|
for (let n = 1; n < e.length; n++) t.drawLine({
|
|
7591
7617
|
start: e[n - 1],
|
|
7592
7618
|
end: e[n],
|
|
@@ -7600,7 +7626,7 @@ async function bn(e, t, n, r, i) {
|
|
|
7600
7626
|
}
|
|
7601
7627
|
case "text": {
|
|
7602
7628
|
if (!r.text) return;
|
|
7603
|
-
let e = r.width && r.width > 0 ? r.width : 200, n =
|
|
7629
|
+
let e = r.width && r.width > 0 ? r.width : 200, n = Sn(r.text, e, 16);
|
|
7604
7630
|
for (let e = 0; e < n.length; e++) {
|
|
7605
7631
|
if (!n[e]) continue;
|
|
7606
7632
|
let i = h(r.x, r.y + e * 20, 16);
|
|
@@ -7616,7 +7642,7 @@ async function bn(e, t, n, r, i) {
|
|
|
7616
7642
|
return;
|
|
7617
7643
|
}
|
|
7618
7644
|
case "note": {
|
|
7619
|
-
let [e, i, c, l] =
|
|
7645
|
+
let [e, i, c, l] = mn(n, {
|
|
7620
7646
|
x: r.x,
|
|
7621
7647
|
y: r.y,
|
|
7622
7648
|
width: 24,
|
|
@@ -7650,7 +7676,7 @@ async function bn(e, t, n, r, i) {
|
|
|
7650
7676
|
}, {
|
|
7651
7677
|
x: r.x,
|
|
7652
7678
|
y: r.y
|
|
7653
|
-
}], [i, c] =
|
|
7679
|
+
}], [i, c] = Z(n, [e[0], e[1]]);
|
|
7654
7680
|
if (t.drawLine({
|
|
7655
7681
|
start: i,
|
|
7656
7682
|
end: c,
|
|
@@ -7658,7 +7684,7 @@ async function bn(e, t, n, r, i) {
|
|
|
7658
7684
|
opacity: o,
|
|
7659
7685
|
thickness: s
|
|
7660
7686
|
}), r.text) {
|
|
7661
|
-
let i = r.text.length * 8 + 20, [c, l, u, d] =
|
|
7687
|
+
let i = r.text.length * 8 + 20, [c, l, u, d] = mn(n, {
|
|
7662
7688
|
x: e[1].x,
|
|
7663
7689
|
y: e[1].y,
|
|
7664
7690
|
width: i,
|
|
@@ -7751,8 +7777,8 @@ async function bn(e, t, n, r, i) {
|
|
|
7751
7777
|
default: return;
|
|
7752
7778
|
}
|
|
7753
7779
|
}
|
|
7754
|
-
async function
|
|
7755
|
-
let n =
|
|
7780
|
+
async function wn(e, t) {
|
|
7781
|
+
let n = xn(t.color || "#737373"), r = t.opacity ?? .08, i = await e.embedFont(Ve.Helvetica), a = -Math.PI / 4, o = Math.cos(a), s = Math.sin(a);
|
|
7756
7782
|
for (let a of e.getPages()) {
|
|
7757
7783
|
let { width: e, height: c } = a.getSize();
|
|
7758
7784
|
if (t.mode === "single") {
|
|
@@ -7783,10 +7809,10 @@ async function xn(e, t) {
|
|
|
7783
7809
|
}
|
|
7784
7810
|
}
|
|
7785
7811
|
}
|
|
7786
|
-
async function
|
|
7812
|
+
async function Q(e, t) {
|
|
7787
7813
|
let n = await e.save(), r = Re.getDocument({
|
|
7788
7814
|
data: n,
|
|
7789
|
-
...
|
|
7815
|
+
...Ht()
|
|
7790
7816
|
}), i = await r.promise, a = await Be.create();
|
|
7791
7817
|
try {
|
|
7792
7818
|
for (let n = 1; n <= i.numPages; n++) {
|
|
@@ -7823,7 +7849,7 @@ async function Sn(e, t) {
|
|
|
7823
7849
|
}
|
|
7824
7850
|
return a;
|
|
7825
7851
|
}
|
|
7826
|
-
async function
|
|
7852
|
+
async function Tn(e, t = {}) {
|
|
7827
7853
|
t.xfdfString && console.warn("[teamsync-pdf-viewer] getFileData({ xfdfString }) is ignored; import the XFDF through annotationManager.importAnnotations() first.");
|
|
7828
7854
|
let n = await e.getSourceBytes(), r = n instanceof Uint8Array ? n : new Uint8Array(n);
|
|
7829
7855
|
if (r.byteLength > 524288e3) {
|
|
@@ -7833,33 +7859,33 @@ async function Cn(e, t = {}) {
|
|
|
7833
7859
|
let i = await Be.load(r, { ignoreEncryption: !0 }), a = i.getPages(), o = t.explicitAnnotations || e.annotations, s = e.getPageGeometry, c = null;
|
|
7834
7860
|
!s && o.length > 0 && (c = Re.getDocument({
|
|
7835
7861
|
data: r.slice(),
|
|
7836
|
-
...
|
|
7837
|
-
}), s =
|
|
7862
|
+
...Ht()
|
|
7863
|
+
}), s = dn(await c.promise));
|
|
7838
7864
|
try {
|
|
7839
7865
|
for (let t of o) {
|
|
7840
7866
|
let n = Math.max(0, Math.min((t.pageIndex || 1) - 1, a.length - 1)), r = await s(n + 1);
|
|
7841
|
-
await
|
|
7867
|
+
await Cn(i, a[n], r, t, e.signerName);
|
|
7842
7868
|
}
|
|
7843
7869
|
} finally {
|
|
7844
7870
|
c && await c.destroy().catch(() => {});
|
|
7845
7871
|
}
|
|
7846
|
-
e.watermark?.text && await
|
|
7872
|
+
e.watermark?.text && await wn(i, e.watermark);
|
|
7847
7873
|
let l = e.redactions || [];
|
|
7848
|
-
return await (l.length > 0 ? await
|
|
7874
|
+
return await (l.length > 0 ? await Q(i, l) : i).save();
|
|
7849
7875
|
}
|
|
7850
7876
|
//#endregion
|
|
7851
7877
|
//#region src/annotations/xfdf.ts
|
|
7852
|
-
var
|
|
7853
|
-
function
|
|
7878
|
+
var En = "http://ns.adobe.com/xfdf/", Dn = "tspdf", On = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
7879
|
+
function kn(e, t = 2) {
|
|
7854
7880
|
return String(e).padStart(t, "0");
|
|
7855
7881
|
}
|
|
7856
|
-
function
|
|
7882
|
+
function An(e) {
|
|
7857
7883
|
let t = e ? new Date(e) : /* @__PURE__ */ new Date();
|
|
7858
|
-
if (Number.isNaN(t.getTime())) return
|
|
7859
|
-
let n = -t.getTimezoneOffset(), r = n >= 0 ? "+" : "-", i =
|
|
7860
|
-
return `D:${t.getFullYear()}${
|
|
7884
|
+
if (Number.isNaN(t.getTime())) return An(void 0);
|
|
7885
|
+
let n = -t.getTimezoneOffset(), r = n >= 0 ? "+" : "-", i = kn(Math.floor(Math.abs(n) / 60)), a = kn(Math.abs(n) % 60);
|
|
7886
|
+
return `D:${t.getFullYear()}${kn(t.getMonth() + 1)}${kn(t.getDate())}${kn(t.getHours())}${kn(t.getMinutes())}${kn(t.getSeconds())}${r}${i}'${a}'`;
|
|
7861
7887
|
}
|
|
7862
|
-
function
|
|
7888
|
+
function jn(e) {
|
|
7863
7889
|
if (!e) return;
|
|
7864
7890
|
let t = /^D:(\d{4})(\d{2})?(\d{2})?(\d{2})?(\d{2})?(\d{2})?([+\-Z])?(\d{2})?'?(\d{2})?/.exec(e.trim());
|
|
7865
7891
|
if (!t) {
|
|
@@ -7871,41 +7897,41 @@ function On(e) {
|
|
|
7871
7897
|
let f = Date.parse(`${n}-${r}-${i}T${a}:${o}:${s}${d}`);
|
|
7872
7898
|
return Number.isNaN(f) ? void 0 : new Date(f).toISOString();
|
|
7873
7899
|
}
|
|
7874
|
-
var
|
|
7900
|
+
var Mn = (e) => {
|
|
7875
7901
|
if (!(!e || e === "transparent")) {
|
|
7876
7902
|
if (/^#[0-9a-f]{6}$/i.test(e)) return e.toUpperCase();
|
|
7877
7903
|
if (/^#[0-9a-f]{3}$/i.test(e)) return `#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}`.toUpperCase();
|
|
7878
7904
|
}
|
|
7879
|
-
}, $ = (e, t) => t == null || t === "" ? "" : ` ${e}="${
|
|
7880
|
-
function
|
|
7881
|
-
return `<trn-custom-data bytes="${
|
|
7905
|
+
}, $ = (e, t) => t == null || t === "" ? "" : ` ${e}="${On(String(t))}"`;
|
|
7906
|
+
function Nn(e) {
|
|
7907
|
+
return `<trn-custom-data bytes="${On(JSON.stringify({ [Dn]: e }))}"/>`;
|
|
7882
7908
|
}
|
|
7883
|
-
function
|
|
7909
|
+
function Pn(e) {
|
|
7884
7910
|
let t = Array.from(e.children).find((e) => e.localName === "trn-custom-data");
|
|
7885
7911
|
if (!t) return {};
|
|
7886
7912
|
try {
|
|
7887
|
-
let e = JSON.parse(t.getAttribute("bytes") || "{}")?.[
|
|
7913
|
+
let e = JSON.parse(t.getAttribute("bytes") || "{}")?.[Dn];
|
|
7888
7914
|
return e && typeof e == "object" ? e : {};
|
|
7889
7915
|
} catch {
|
|
7890
7916
|
return {};
|
|
7891
7917
|
}
|
|
7892
7918
|
}
|
|
7893
|
-
function
|
|
7894
|
-
return e.map((e) => `${
|
|
7919
|
+
function Fn(e) {
|
|
7920
|
+
return e.map((e) => `${yn(e.x)},${yn(e.y)}`).join(";");
|
|
7895
7921
|
}
|
|
7896
|
-
function
|
|
7922
|
+
function In(e) {
|
|
7897
7923
|
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]) => ({
|
|
7898
7924
|
x: e,
|
|
7899
7925
|
y: t
|
|
7900
7926
|
})) : [];
|
|
7901
7927
|
}
|
|
7902
|
-
function
|
|
7928
|
+
function Ln(e) {
|
|
7903
7929
|
return e ? e.split(/[,\s]+/).map(Number).filter((e) => Number.isFinite(e)) : [];
|
|
7904
7930
|
}
|
|
7905
|
-
function
|
|
7906
|
-
return e.map(
|
|
7931
|
+
function Rn(e) {
|
|
7932
|
+
return e.map(yn).join(",");
|
|
7907
7933
|
}
|
|
7908
|
-
var
|
|
7934
|
+
var zn = /* @__PURE__ */ new Set([
|
|
7909
7935
|
"page",
|
|
7910
7936
|
"rect",
|
|
7911
7937
|
"color",
|
|
@@ -7927,7 +7953,7 @@ var In = /* @__PURE__ */ new Set([
|
|
|
7927
7953
|
"IT",
|
|
7928
7954
|
"callout",
|
|
7929
7955
|
"style"
|
|
7930
|
-
]),
|
|
7956
|
+
]), Bn = /* @__PURE__ */ new Set([
|
|
7931
7957
|
"contents",
|
|
7932
7958
|
"contents-richtext",
|
|
7933
7959
|
"inklist",
|
|
@@ -7939,33 +7965,33 @@ var In = /* @__PURE__ */ new Set([
|
|
|
7939
7965
|
"popup",
|
|
7940
7966
|
"vertices"
|
|
7941
7967
|
]);
|
|
7942
|
-
function
|
|
7943
|
-
let i = r ??
|
|
7968
|
+
function Vn(e, t, n, r) {
|
|
7969
|
+
let i = r ?? mn(t, {
|
|
7944
7970
|
x: e.x,
|
|
7945
7971
|
y: e.y,
|
|
7946
7972
|
width: e.width,
|
|
7947
7973
|
height: e.height
|
|
7948
7974
|
}), a = e.createdAt ?? (e.timestamp ? new Date(e.timestamp).toISOString() : void 0), o = ["print", ...e.readOnly ? ["readonly", "locked"] : []].join(",");
|
|
7949
|
-
return $("page", e.pageIndex - 1) + $("rect",
|
|
7975
|
+
return $("page", e.pageIndex - 1) + $("rect", Rn(i)) + $("name", e.id) + (n ? $("title", e.author) : "") + $("date", An(e.modifiedAt ?? a)) + $("creationdate", An(a)) + $("flags", o) + $("opacity", e.opacity !== void 0 && e.opacity !== 1 ? yn(e.opacity) : void 0);
|
|
7950
7976
|
}
|
|
7951
|
-
function
|
|
7977
|
+
function Hn(e) {
|
|
7952
7978
|
let t = e.xfdfExtras?.attrs;
|
|
7953
|
-
return t ? Object.entries(t).filter(([e]) => !
|
|
7979
|
+
return t ? Object.entries(t).filter(([e]) => !zn.has(e)).map(([e, t]) => $(e, t)).join("") : "";
|
|
7954
7980
|
}
|
|
7955
|
-
function
|
|
7981
|
+
function Un(e) {
|
|
7956
7982
|
return (e.xfdfExtras?.children ?? []).join("");
|
|
7957
7983
|
}
|
|
7958
|
-
function
|
|
7984
|
+
function Wn(e, t = {}) {
|
|
7959
7985
|
let n = {
|
|
7960
7986
|
type: e.type,
|
|
7961
7987
|
...t
|
|
7962
7988
|
};
|
|
7963
|
-
return e.authorId && (n.authorId = e.authorId), e.strokeWidth !== void 0 && (n.strokeWidth = e.strokeWidth),
|
|
7989
|
+
return e.authorId && (n.authorId = e.authorId), e.strokeWidth !== void 0 && (n.strokeWidth = e.strokeWidth), Nn(n);
|
|
7964
7990
|
}
|
|
7965
|
-
var
|
|
7966
|
-
async function
|
|
7991
|
+
var Gn = (e) => e ? `<contents>${On(e)}</contents>` : "", Kn = (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>`;
|
|
7992
|
+
async function qn(e, t, n = {}) {
|
|
7967
7993
|
if (e.type === "opaque" && e.rawXfdf) return e.rawXfdf;
|
|
7968
|
-
let r = await t(e.pageIndex), i = n.useDisplayAuthor !== !1, a =
|
|
7994
|
+
let r = await t(e.pageIndex), i = n.useDisplayAuthor !== !1, a = Mn(e.color), o = $("color", a) + $("width", e.strokeWidth), s = (t) => Vn(e, r, i, t) + Hn(e), c = (t = {}) => Wn(e, t) + Un(e);
|
|
7969
7995
|
switch (e.type) {
|
|
7970
7996
|
case "rectangle": return `<square${s()}${o}${$("interior-color", a)} subject="Rectangle">${c()}</square>`;
|
|
7971
7997
|
case "ellipse": return `<circle${s()}${o}${$("interior-color", a)} subject="Ellipse">${c()}</circle>`;
|
|
@@ -7977,17 +8003,17 @@ async function Wn(e, t, n = {}) {
|
|
|
7977
8003
|
}, {
|
|
7978
8004
|
x: e.x + e.width,
|
|
7979
8005
|
y: e.y + e.height
|
|
7980
|
-
}], [n, i] =
|
|
8006
|
+
}], [n, i] = Z(r, [t[0], t[1]]), a = [
|
|
7981
8007
|
Math.min(n.x, i.x),
|
|
7982
8008
|
Math.min(n.y, i.y),
|
|
7983
8009
|
Math.max(n.x, i.x),
|
|
7984
8010
|
Math.max(n.y, i.y)
|
|
7985
8011
|
], l = e.type === "arrow" ? $("head", "OpenArrow") : "";
|
|
7986
|
-
return `<line${s(a)}${o} start="${
|
|
8012
|
+
return `<line${s(a)}${o} start="${yn(n.x)},${yn(n.y)}" end="${yn(i.x)},${yn(i.y)}"${l} subject="${e.type === "arrow" ? "Arrow" : "Line"}">${c()}</line>`;
|
|
7987
8013
|
}
|
|
7988
8014
|
case "freehand": {
|
|
7989
|
-
let t = e.strokes && e.strokes.length > 0 ? e.strokes : e.points ? [e.points] : [], n = t.map((e) => `<gesture>${
|
|
7990
|
-
return `<ink${s(i.length ?
|
|
8015
|
+
let t = e.strokes && e.strokes.length > 0 ? e.strokes : e.points ? [e.points] : [], n = t.map((e) => `<gesture>${Fn(Z(r, e))}</gesture>`).join(""), i = t.flat();
|
|
8016
|
+
return `<ink${s(i.length ? mn(r, Jn(i, e.strokeWidth)) : void 0)}${o} subject="Free Hand"><inklist>${n}</inklist>${c()}</ink>`;
|
|
7991
8017
|
}
|
|
7992
8018
|
case "highlight":
|
|
7993
8019
|
case "underline":
|
|
@@ -7998,10 +8024,10 @@ async function Wn(e, t, n = {}) {
|
|
|
7998
8024
|
y: e.y,
|
|
7999
8025
|
width: e.width,
|
|
8000
8026
|
height: e.height
|
|
8001
|
-
}], n = t.flatMap((e) =>
|
|
8027
|
+
}], n = t.flatMap((e) => gn(r, e)).map(yn).join(","), i = mn(r, vn(t)), o = e.type, l = e.type === "highlight" ? "Highlight" : e.type === "underline" ? "Underline" : e.type === "strikeout" ? "StrikeOut" : "Squiggly";
|
|
8002
8028
|
return `<${o}${s(i)}${$("color", a)} coords="${n}" subject="${l}">${c()}</${o}>`;
|
|
8003
8029
|
}
|
|
8004
|
-
case "text": return `<freetext${s()}${$("color", a)} subject="Free Text">${
|
|
8030
|
+
case "text": return `<freetext${s()}${$("color", a)} subject="Free Text">${Gn(e.text)}${Kn(e, 16)}${c()}</freetext>`;
|
|
8005
8031
|
case "callout": {
|
|
8006
8032
|
let t = e.points && e.points.length >= 2 ? e.points : [{
|
|
8007
8033
|
x: e.x,
|
|
@@ -8009,7 +8035,7 @@ async function Wn(e, t, n = {}) {
|
|
|
8009
8035
|
}, {
|
|
8010
8036
|
x: e.x,
|
|
8011
8037
|
y: e.y
|
|
8012
|
-
}], [n, i] =
|
|
8038
|
+
}], [n, i] = Z(r, [t[0], t[1]]), a = mn(r, {
|
|
8013
8039
|
x: t[1].x,
|
|
8014
8040
|
y: t[1].y,
|
|
8015
8041
|
width: e.text ? e.text.length * 8 + 20 : 100,
|
|
@@ -8020,19 +8046,19 @@ async function Wn(e, t, n = {}) {
|
|
|
8020
8046
|
Math.min(n.y, a[1]),
|
|
8021
8047
|
Math.max(i.x, a[2]),
|
|
8022
8048
|
Math.max(i.y, a[3])
|
|
8023
|
-
])}${o} IT="FreeTextCallout" callout="${
|
|
8049
|
+
])}${o} IT="FreeTextCallout" callout="${yn(n.x)},${yn(n.y)},${yn(i.x)},${yn(i.y)}" subject="Callout">${Gn(e.text)}${Kn(e, 14)}${c({ box: a })}</freetext>`;
|
|
8024
8050
|
}
|
|
8025
|
-
case "note": return `<text${s(
|
|
8051
|
+
case "note": return `<text${s(mn(r, {
|
|
8026
8052
|
x: e.x,
|
|
8027
8053
|
y: e.y,
|
|
8028
8054
|
width: 24,
|
|
8029
8055
|
height: 24
|
|
8030
|
-
}))}${$("color", a)} icon="Comment" subject="Sticky Note">${
|
|
8056
|
+
}))}${$("color", a)} icon="Comment" subject="Sticky Note">${Gn(e.text)}${c()}</text>`;
|
|
8031
8057
|
case "link": {
|
|
8032
|
-
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="${
|
|
8033
|
-
return `<link${s()}${$("color", a)} subject="Link">${n}${
|
|
8058
|
+
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="${On(t)}"/></Action></OnActivation>` : "";
|
|
8059
|
+
return `<link${s()}${$("color", a)} subject="Link">${n}${Gn(e.text)}${c()}</link>`;
|
|
8034
8060
|
}
|
|
8035
|
-
case "signature": return `<stamp${s()} subject="Signature">${e.imageUrl ? `<imagedata>${
|
|
8061
|
+
case "signature": return `<stamp${s()} subject="Signature">${e.imageUrl ? `<imagedata>${On(e.imageUrl)}</imagedata>` : ""}${c({
|
|
8036
8062
|
signer: e.signer,
|
|
8037
8063
|
signType: e.signType,
|
|
8038
8064
|
timestamp: e.timestamp
|
|
@@ -8045,7 +8071,7 @@ async function Wn(e, t, n = {}) {
|
|
|
8045
8071
|
default: return "";
|
|
8046
8072
|
}
|
|
8047
8073
|
}
|
|
8048
|
-
function
|
|
8074
|
+
function Jn(e, t = 0) {
|
|
8049
8075
|
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;
|
|
8050
8076
|
return {
|
|
8051
8077
|
x: a,
|
|
@@ -8054,21 +8080,21 @@ function Gn(e, t = 0) {
|
|
|
8054
8080
|
height: Math.max(...r) - o + i
|
|
8055
8081
|
};
|
|
8056
8082
|
}
|
|
8057
|
-
async function
|
|
8083
|
+
async function Yn(e, t, n = {}) {
|
|
8058
8084
|
let r = n.annotList ?? e;
|
|
8059
|
-
return `<?xml version="1.0" encoding="UTF-8"?><xfdf xmlns="${
|
|
8085
|
+
return `<?xml version="1.0" encoding="UTF-8"?><xfdf xmlns="${En}" xml:space="preserve"><annots>${(await Promise.all(r.map((e) => qn(e, t, n)))).filter(Boolean).join("")}</annots></xfdf>`;
|
|
8060
8086
|
}
|
|
8061
|
-
function
|
|
8087
|
+
function Xn(e) {
|
|
8062
8088
|
let t = {};
|
|
8063
|
-
for (let n of Array.from(e.attributes)) !
|
|
8089
|
+
for (let n of Array.from(e.attributes)) !zn.has(n.name) && !n.name.startsWith("xmlns") && (t[n.name] = n.value);
|
|
8064
8090
|
let n = [];
|
|
8065
|
-
for (let t of Array.from(e.children))
|
|
8091
|
+
for (let t of Array.from(e.children)) Bn.has(t.localName) || n.push(new XMLSerializer().serializeToString(t));
|
|
8066
8092
|
let r = Array.from(e.children).find((e) => e.localName === "trn-custom-data");
|
|
8067
8093
|
if (r) try {
|
|
8068
8094
|
let e = JSON.parse(r.getAttribute("bytes") || "{}");
|
|
8069
8095
|
if (e && typeof e == "object") {
|
|
8070
8096
|
let t = { ...e };
|
|
8071
|
-
delete t[
|
|
8097
|
+
delete t[Dn], Object.keys(t).length > 0 && n.push(`<trn-custom-data bytes="${On(JSON.stringify(t))}"/>`);
|
|
8072
8098
|
}
|
|
8073
8099
|
} catch {
|
|
8074
8100
|
n.push(new XMLSerializer().serializeToString(r));
|
|
@@ -8076,11 +8102,11 @@ function qn(e) {
|
|
|
8076
8102
|
let i = {};
|
|
8077
8103
|
return Object.keys(t).length && (i.attrs = t), n.length && (i.children = n), Object.keys(i).length ? i : void 0;
|
|
8078
8104
|
}
|
|
8079
|
-
function
|
|
8105
|
+
function Zn(e, t) {
|
|
8080
8106
|
return Array.from(e.children).find((e) => e.localName === t)?.textContent ?? void 0;
|
|
8081
8107
|
}
|
|
8082
|
-
function
|
|
8083
|
-
let n =
|
|
8108
|
+
function Qn(e, t) {
|
|
8109
|
+
let n = Ln(e.getAttribute("rect")), r = n.length === 4 ? X(t, [
|
|
8084
8110
|
n[0],
|
|
8085
8111
|
n[1],
|
|
8086
8112
|
n[2],
|
|
@@ -8090,9 +8116,9 @@ function Yn(e, t) {
|
|
|
8090
8116
|
y: 0,
|
|
8091
8117
|
width: 0,
|
|
8092
8118
|
height: 0
|
|
8093
|
-
}, i =
|
|
8119
|
+
}, i = Pn(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");
|
|
8094
8120
|
return {
|
|
8095
|
-
id: e.getAttribute("name") ||
|
|
8121
|
+
id: e.getAttribute("name") || Mt(),
|
|
8096
8122
|
pageIndex: (parseInt(e.getAttribute("page") || "0", 10) || 0) + 1,
|
|
8097
8123
|
x: r.x,
|
|
8098
8124
|
y: r.y,
|
|
@@ -8103,14 +8129,14 @@ function Yn(e, t) {
|
|
|
8103
8129
|
opacity: s,
|
|
8104
8130
|
author: e.getAttribute("title") || void 0,
|
|
8105
8131
|
authorId: typeof i.authorId == "string" ? i.authorId : void 0,
|
|
8106
|
-
createdAt:
|
|
8107
|
-
modifiedAt:
|
|
8132
|
+
createdAt: jn(e.getAttribute("creationdate")),
|
|
8133
|
+
modifiedAt: jn(e.getAttribute("date")),
|
|
8108
8134
|
readOnly: d || void 0,
|
|
8109
|
-
xfdfExtras:
|
|
8135
|
+
xfdfExtras: Xn(e)
|
|
8110
8136
|
};
|
|
8111
8137
|
}
|
|
8112
|
-
function
|
|
8113
|
-
let n = e.localName.toLowerCase(), r =
|
|
8138
|
+
function $n(e, t) {
|
|
8139
|
+
let n = e.localName.toLowerCase(), r = Pn(e), i = Qn(e, t), a = () => ({
|
|
8114
8140
|
...i,
|
|
8115
8141
|
type: "opaque",
|
|
8116
8142
|
opaqueKind: n,
|
|
@@ -8127,7 +8153,7 @@ function Xn(e, t) {
|
|
|
8127
8153
|
type: "ellipse"
|
|
8128
8154
|
};
|
|
8129
8155
|
case "line": {
|
|
8130
|
-
let n =
|
|
8156
|
+
let n = Ln(e.getAttribute("start")), r = Ln(e.getAttribute("end")), o = (e.getAttribute("head") || "None").toLowerCase(), s = (e.getAttribute("tail") || "None").toLowerCase();
|
|
8131
8157
|
if (n.length < 2 || r.length < 2) return a();
|
|
8132
8158
|
let [c, l] = hn(t, [{
|
|
8133
8159
|
x: n[0],
|
|
@@ -8135,7 +8161,7 @@ function Xn(e, t) {
|
|
|
8135
8161
|
}, {
|
|
8136
8162
|
x: r[0],
|
|
8137
8163
|
y: r[1]
|
|
8138
|
-
}]), u =
|
|
8164
|
+
}]), u = Jn([c, l]), d = o !== "none" || s !== "none";
|
|
8139
8165
|
return {
|
|
8140
8166
|
...i,
|
|
8141
8167
|
...u,
|
|
@@ -8144,12 +8170,12 @@ function Xn(e, t) {
|
|
|
8144
8170
|
};
|
|
8145
8171
|
}
|
|
8146
8172
|
case "ink": {
|
|
8147
|
-
let n = Array.from(e.getElementsByTagName("*")).filter((e) => e.localName === "gesture").map((e) => hn(t,
|
|
8173
|
+
let n = Array.from(e.getElementsByTagName("*")).filter((e) => e.localName === "gesture").map((e) => hn(t, In(e.textContent))).filter((e) => e.length > 0);
|
|
8148
8174
|
if (n.length === 0) return a();
|
|
8149
8175
|
let r = n.flat();
|
|
8150
8176
|
return {
|
|
8151
8177
|
...i,
|
|
8152
|
-
...
|
|
8178
|
+
...Jn(r),
|
|
8153
8179
|
type: "freehand",
|
|
8154
8180
|
points: n[0],
|
|
8155
8181
|
strokes: n
|
|
@@ -8159,12 +8185,12 @@ function Xn(e, t) {
|
|
|
8159
8185
|
case "underline":
|
|
8160
8186
|
case "strikeout":
|
|
8161
8187
|
case "squiggly": {
|
|
8162
|
-
let r =
|
|
8188
|
+
let r = Ln(e.getAttribute("coords")), a = r.length >= 8 ? _n(t, r) : [{
|
|
8163
8189
|
x: i.x,
|
|
8164
8190
|
y: i.y,
|
|
8165
8191
|
width: i.width,
|
|
8166
8192
|
height: i.height
|
|
8167
|
-
}], o =
|
|
8193
|
+
}], o = vn(a), s = n, c = s === "highlight" ? .5 : 1;
|
|
8168
8194
|
return {
|
|
8169
8195
|
...i,
|
|
8170
8196
|
...o,
|
|
@@ -8174,7 +8200,7 @@ function Xn(e, t) {
|
|
|
8174
8200
|
};
|
|
8175
8201
|
}
|
|
8176
8202
|
case "freetext": {
|
|
8177
|
-
let n =
|
|
8203
|
+
let n = Zn(e, "contents") ?? "", a = e.getAttribute("IT") || "", o = Ln(e.getAttribute("callout"));
|
|
8178
8204
|
if (a === "FreeTextCallout" || r.type === "callout" || o.length >= 4) {
|
|
8179
8205
|
let e = o.length >= 4 ? hn(t, [{
|
|
8180
8206
|
x: o[0],
|
|
@@ -8211,7 +8237,7 @@ function Xn(e, t) {
|
|
|
8211
8237
|
case "text": return {
|
|
8212
8238
|
...i,
|
|
8213
8239
|
type: "note",
|
|
8214
|
-
text:
|
|
8240
|
+
text: Zn(e, "contents") ?? "",
|
|
8215
8241
|
width: 24,
|
|
8216
8242
|
height: 24
|
|
8217
8243
|
};
|
|
@@ -8221,7 +8247,7 @@ function Xn(e, t) {
|
|
|
8221
8247
|
...i,
|
|
8222
8248
|
type: "link",
|
|
8223
8249
|
linkUrl: r,
|
|
8224
|
-
text:
|
|
8250
|
+
text: Zn(e, "contents") ?? "",
|
|
8225
8251
|
color: "transparent",
|
|
8226
8252
|
strokeWidth: 0,
|
|
8227
8253
|
opacity: 1,
|
|
@@ -8229,7 +8255,7 @@ function Xn(e, t) {
|
|
|
8229
8255
|
};
|
|
8230
8256
|
}
|
|
8231
8257
|
case "stamp": {
|
|
8232
|
-
let t =
|
|
8258
|
+
let t = Zn(e, "imagedata");
|
|
8233
8259
|
return r.type === "digital_signature_placeholder" ? {
|
|
8234
8260
|
...i,
|
|
8235
8261
|
type: "digital_signature_placeholder",
|
|
@@ -8246,7 +8272,7 @@ function Xn(e, t) {
|
|
|
8246
8272
|
default: return a();
|
|
8247
8273
|
}
|
|
8248
8274
|
}
|
|
8249
|
-
function
|
|
8275
|
+
function er(e) {
|
|
8250
8276
|
let t = "", n = 0;
|
|
8251
8277
|
for (;;) {
|
|
8252
8278
|
let r = e.indexOf("<?xml", n);
|
|
@@ -8257,11 +8283,11 @@ function Zn(e) {
|
|
|
8257
8283
|
}
|
|
8258
8284
|
return t + e.slice(n);
|
|
8259
8285
|
}
|
|
8260
|
-
async function
|
|
8261
|
-
let n =
|
|
8286
|
+
async function tr(e, t) {
|
|
8287
|
+
let n = er(e).trim();
|
|
8262
8288
|
if (!n) return [];
|
|
8263
8289
|
if (/<!DOCTYPE|<!ENTITY/i.test(n)) throw Error("[teamsync-pdf-viewer] invalid XFDF: DOCTYPE/ENTITY declarations are not allowed");
|
|
8264
|
-
let r = `<xfdf xmlns="${
|
|
8290
|
+
let r = `<xfdf xmlns="${En}"><annots>${n}</annots></xfdf>`, i = new DOMParser().parseFromString(r, "application/xml"), a = i.getElementsByTagName("parsererror")[0];
|
|
8265
8291
|
if (a) throw Error(`[teamsync-pdf-viewer] invalid XFDF: ${a.textContent?.slice(0, 200)}`);
|
|
8266
8292
|
let o = /* @__PURE__ */ new Set([
|
|
8267
8293
|
"xfdf",
|
|
@@ -8271,14 +8297,14 @@ async function Qn(e, t) {
|
|
|
8271
8297
|
"ids"
|
|
8272
8298
|
]), s = Array.from(i.getElementsByTagName("*")).filter((e) => e.parentElement?.localName === "annots" && !o.has(e.localName)), c = [];
|
|
8273
8299
|
for (let e of s) {
|
|
8274
|
-
let n =
|
|
8300
|
+
let n = $n(e, await t((parseInt(e.getAttribute("page") || "0", 10) || 0) + 1));
|
|
8275
8301
|
n && c.push(n);
|
|
8276
8302
|
}
|
|
8277
8303
|
return c;
|
|
8278
8304
|
}
|
|
8279
8305
|
//#endregion
|
|
8280
8306
|
//#region src/annotations/AnnotationManager.ts
|
|
8281
|
-
var
|
|
8307
|
+
var nr = 100, rr = () => (/* @__PURE__ */ new Date()).toISOString(), ir = class {
|
|
8282
8308
|
list = [];
|
|
8283
8309
|
past = [];
|
|
8284
8310
|
future = [];
|
|
@@ -8289,7 +8315,7 @@ var $n = 100, er = () => (/* @__PURE__ */ new Date()).toISOString(), tr = class
|
|
|
8289
8315
|
canEditOthers = !1;
|
|
8290
8316
|
resolver = null;
|
|
8291
8317
|
setDocument(e) {
|
|
8292
|
-
this.resolver = e ?
|
|
8318
|
+
this.resolver = e ? dn(e) : null;
|
|
8293
8319
|
}
|
|
8294
8320
|
hasDocument() {
|
|
8295
8321
|
return this.resolver !== null;
|
|
@@ -8380,7 +8406,7 @@ var $n = 100, er = () => (/* @__PURE__ */ new Date()).toISOString(), tr = class
|
|
|
8380
8406
|
addAnnotations(e, t = {}) {
|
|
8381
8407
|
let n = e.map((e) => ({
|
|
8382
8408
|
...e,
|
|
8383
|
-
id: e.id ??
|
|
8409
|
+
id: e.id ?? Mt()
|
|
8384
8410
|
}));
|
|
8385
8411
|
return this.commit([...this.list, ...n], t), n.map((e) => this.getAnnotationById(e.id)).filter((e) => !!e);
|
|
8386
8412
|
}
|
|
@@ -8404,7 +8430,7 @@ var $n = 100, er = () => (/* @__PURE__ */ new Date()).toISOString(), tr = class
|
|
|
8404
8430
|
});
|
|
8405
8431
|
}
|
|
8406
8432
|
async importAnnotations(e) {
|
|
8407
|
-
let t = await
|
|
8433
|
+
let t = await tr(e, this.requireResolver());
|
|
8408
8434
|
if (t.length === 0) return [];
|
|
8409
8435
|
let n = new Map(t.map((e) => [e.id, e])), r = this.list.map((e) => n.get(e.id) ?? e);
|
|
8410
8436
|
for (let e of t) this.list.some((t) => t.id === e.id) || r.push(e);
|
|
@@ -8416,7 +8442,7 @@ var $n = 100, er = () => (/* @__PURE__ */ new Date()).toISOString(), tr = class
|
|
|
8416
8442
|
}
|
|
8417
8443
|
async exportAnnotations(e = {}) {
|
|
8418
8444
|
let t = this.requireResolver();
|
|
8419
|
-
return e.annotList ? (await Promise.all(e.annotList.map((n) =>
|
|
8445
|
+
return e.annotList ? (await Promise.all(e.annotList.map((n) => qn(n, t, e)))).join("") : Yn(this.list, t, e);
|
|
8420
8446
|
}
|
|
8421
8447
|
exportAnnotationsLegacyJson() {
|
|
8422
8448
|
return JSON.stringify(this.list, null, 2);
|
|
@@ -8440,7 +8466,7 @@ var $n = 100, er = () => (/* @__PURE__ */ new Date()).toISOString(), tr = class
|
|
|
8440
8466
|
}
|
|
8441
8467
|
let n = r ? t : {
|
|
8442
8468
|
...t,
|
|
8443
|
-
modifiedAt:
|
|
8469
|
+
modifiedAt: rr()
|
|
8444
8470
|
};
|
|
8445
8471
|
c.push(n), l.push({
|
|
8446
8472
|
before: e,
|
|
@@ -8460,7 +8486,7 @@ var $n = 100, er = () => (/* @__PURE__ */ new Date()).toISOString(), tr = class
|
|
|
8460
8486
|
added: s,
|
|
8461
8487
|
modified: l,
|
|
8462
8488
|
deleted: u
|
|
8463
|
-
}), this.past.length >
|
|
8489
|
+
}), this.past.length > nr && this.past.shift(), this.future = []), this.list = d;
|
|
8464
8490
|
for (let e of Array.from(this.listListeners)) try {
|
|
8465
8491
|
e();
|
|
8466
8492
|
} catch (e) {
|
|
@@ -8482,7 +8508,7 @@ var $n = 100, er = () => (/* @__PURE__ */ new Date()).toISOString(), tr = class
|
|
|
8482
8508
|
}
|
|
8483
8509
|
stampNew(e, t) {
|
|
8484
8510
|
if (t) return e;
|
|
8485
|
-
let n = e.createdAt ??
|
|
8511
|
+
let n = e.createdAt ?? rr();
|
|
8486
8512
|
return {
|
|
8487
8513
|
...e,
|
|
8488
8514
|
author: e.author ?? this.user.name,
|
|
@@ -8498,16 +8524,16 @@ var $n = 100, er = () => (/* @__PURE__ */ new Date()).toISOString(), tr = class
|
|
|
8498
8524
|
console.error("[teamsync-pdf-viewer] annotationChanged listener threw", e);
|
|
8499
8525
|
}
|
|
8500
8526
|
}
|
|
8501
|
-
},
|
|
8527
|
+
}, ar = () => {
|
|
8502
8528
|
throw Error("[teamsync-pdf-viewer] viewer is not mounted (was destroy() called?)");
|
|
8503
|
-
},
|
|
8529
|
+
}, or = class {
|
|
8504
8530
|
bus;
|
|
8505
8531
|
annotationManager;
|
|
8506
8532
|
element = null;
|
|
8507
8533
|
binding = null;
|
|
8508
8534
|
unmountRoot = null;
|
|
8509
8535
|
destroyed = !1;
|
|
8510
|
-
constructor(e, t = new
|
|
8536
|
+
constructor(e, t = new ir()) {
|
|
8511
8537
|
this.bus = e, this.annotationManager = t;
|
|
8512
8538
|
}
|
|
8513
8539
|
_bind(e, t) {
|
|
@@ -8543,7 +8569,7 @@ var $n = 100, er = () => (/* @__PURE__ */ new Date()).toISOString(), tr = class
|
|
|
8543
8569
|
this.bus.off(e, t);
|
|
8544
8570
|
}
|
|
8545
8571
|
loadDocument(e) {
|
|
8546
|
-
let t = this.binding ??
|
|
8572
|
+
let t = this.binding ?? ar();
|
|
8547
8573
|
return new Promise((n, r) => {
|
|
8548
8574
|
let i = this.bus.on("documentLoaded", (t) => {
|
|
8549
8575
|
t.url === e && (o(), n(t));
|
|
@@ -8577,11 +8603,11 @@ var $n = 100, er = () => (/* @__PURE__ */ new Date()).toISOString(), tr = class
|
|
|
8577
8603
|
setCurrentPage(e) {
|
|
8578
8604
|
this.goToPage(e);
|
|
8579
8605
|
}
|
|
8580
|
-
async searchText(e) {
|
|
8581
|
-
let
|
|
8582
|
-
if (!
|
|
8583
|
-
let
|
|
8584
|
-
return
|
|
8606
|
+
async searchText(e, t = {}) {
|
|
8607
|
+
let n = this.getPdfDocument();
|
|
8608
|
+
if (!n) return [];
|
|
8609
|
+
let r = this.binding;
|
|
8610
|
+
return bt(n, e, r ? r.getRedactions() : [], void 0, t.pages);
|
|
8585
8611
|
}
|
|
8586
8612
|
getTransientHighlights() {
|
|
8587
8613
|
return this.binding?.getTransientHighlights() ?? [];
|
|
@@ -8598,18 +8624,20 @@ var $n = 100, er = () => (/* @__PURE__ */ new Date()).toISOString(), tr = class
|
|
|
8598
8624
|
this.setTransientHighlights([]);
|
|
8599
8625
|
}
|
|
8600
8626
|
async highlightSnippet(e, t = {}) {
|
|
8601
|
-
let n =
|
|
8602
|
-
|
|
8603
|
-
let i =
|
|
8604
|
-
|
|
8605
|
-
|
|
8606
|
-
|
|
8627
|
+
let n = {};
|
|
8628
|
+
t.scope === "page" && t.pageIndex && (n.pages = [t.pageIndex]);
|
|
8629
|
+
let r = await this.searchText(e, n), i = r[0];
|
|
8630
|
+
if (t.pageIndex && (i = r.find((e) => e.pageIndex === t.pageIndex) || i), !i) return null;
|
|
8631
|
+
let a = {
|
|
8632
|
+
id: i.id,
|
|
8633
|
+
pageIndex: i.pageIndex,
|
|
8634
|
+
bounds: i.bounds,
|
|
8607
8635
|
color: t.color || "rgba(250, 204, 21, 0.45)",
|
|
8608
8636
|
borderColor: "rgba(234, 179, 8, 0.85)",
|
|
8609
8637
|
pulse: t.pulse !== !1,
|
|
8610
|
-
tooltip: t.tooltip ||
|
|
8638
|
+
tooltip: t.tooltip || i.snippet
|
|
8611
8639
|
};
|
|
8612
|
-
return this.setTransientHighlights([
|
|
8640
|
+
return this.setTransientHighlights([a]), t.scrollTo !== !1 && this.goToPage(i.pageIndex, { smooth: !0 }), i;
|
|
8613
8641
|
}
|
|
8614
8642
|
getAnnotations() {
|
|
8615
8643
|
return this.annotationManager.getAnnotationsList();
|
|
@@ -8621,16 +8649,16 @@ var $n = 100, er = () => (/* @__PURE__ */ new Date()).toISOString(), tr = class
|
|
|
8621
8649
|
this.bus.emit("action-print");
|
|
8622
8650
|
}
|
|
8623
8651
|
async getFileData(e = {}) {
|
|
8624
|
-
let t = this.binding ??
|
|
8652
|
+
let t = this.binding ?? ar(), n = t.getPdfDocument(), r = t.getDocumentUrl();
|
|
8625
8653
|
if (!n && !r) throw Error("No document loaded");
|
|
8626
|
-
return
|
|
8654
|
+
return Tn({
|
|
8627
8655
|
getSourceBytes: async () => {
|
|
8628
8656
|
if (n) return n.getData();
|
|
8629
8657
|
let e = await fetch(r);
|
|
8630
8658
|
if (!e.ok) throw Error(`Failed to fetch document (${e.status})`);
|
|
8631
8659
|
return e.arrayBuffer();
|
|
8632
8660
|
},
|
|
8633
|
-
getPageGeometry: n ?
|
|
8661
|
+
getPageGeometry: n ? dn(n) : void 0,
|
|
8634
8662
|
annotations: this.annotationManager.getAnnotationsList(),
|
|
8635
8663
|
redactions: t.getRedactions(),
|
|
8636
8664
|
watermark: t.getWatermark(),
|
|
@@ -8645,7 +8673,7 @@ var $n = 100, er = () => (/* @__PURE__ */ new Date()).toISOString(), tr = class
|
|
|
8645
8673
|
async copySelectedText() {
|
|
8646
8674
|
let e = this.getSelectedText();
|
|
8647
8675
|
if (!e) return !1;
|
|
8648
|
-
let t = await
|
|
8676
|
+
let t = await Nt(e);
|
|
8649
8677
|
return t && this.bus.emit("textCopied", { text: e }), t;
|
|
8650
8678
|
}
|
|
8651
8679
|
UI = {
|
|
@@ -8705,7 +8733,7 @@ var $n = 100, er = () => (/* @__PURE__ */ new Date()).toISOString(), tr = class
|
|
|
8705
8733
|
};
|
|
8706
8734
|
//#endregion
|
|
8707
8735
|
//#region src/core/print.ts
|
|
8708
|
-
async function
|
|
8736
|
+
async function sr(e, t = {}) {
|
|
8709
8737
|
if (typeof document > "u") throw Error("[teamsync-pdf-viewer] printing needs a browser");
|
|
8710
8738
|
let n = new Blob([e], { type: "application/pdf" }), r = URL.createObjectURL(n), i = document.createElement("iframe");
|
|
8711
8739
|
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) => {
|
|
@@ -8730,11 +8758,11 @@ async function ir(e, t = {}) {
|
|
|
8730
8758
|
}
|
|
8731
8759
|
//#endregion
|
|
8732
8760
|
//#region src/components/TeamSyncViewer.tsx
|
|
8733
|
-
var
|
|
8761
|
+
var cr = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, lr = e.forwardRef(function(e, t) {
|
|
8734
8762
|
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: te, readOnly: ne = !1, assets: re, withCredentials: ie = !1, toolbar: ae = !0, sidebars: oe = !0, leftPanelOpen: se = !0, className: ce, style: le, hideAnnotationsUntilPageRendered: C = !0, enableTextSelection: ue = !0, defaultTool: de = "select", showSelectionTooltip: fe = !0 } = e, w = s(e);
|
|
8735
8763
|
w.current = e;
|
|
8736
|
-
let T = s(null), E = o(() => new
|
|
8737
|
-
O.current ||= new
|
|
8764
|
+
let T = s(null), E = o(() => new sn(), []), D = o(() => new ir(), []), O = s(null);
|
|
8765
|
+
O.current ||= new or(E, D);
|
|
8738
8766
|
let k = O.current;
|
|
8739
8767
|
a(t, () => k, [k]);
|
|
8740
8768
|
let pe = r ?? l, [me, he] = c(pe), [ge, _e] = c(0);
|
|
@@ -8838,7 +8866,7 @@ var ar = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID
|
|
|
8838
8866
|
E.on("action-tool-changed", (e) => E.emit("toolChanged", { tool: e?.tool ?? null })),
|
|
8839
8867
|
E.on("action-print", async () => {
|
|
8840
8868
|
try {
|
|
8841
|
-
await
|
|
8869
|
+
await sr(await k.getFileData(), { title: w.current.fileName });
|
|
8842
8870
|
} catch (e) {
|
|
8843
8871
|
console.error("[teamsync-pdf-viewer] print failed", e), E.emit("action-print-error", { error: e });
|
|
8844
8872
|
}
|
|
@@ -8856,7 +8884,7 @@ var ar = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID
|
|
|
8856
8884
|
E.on("action-process-digital-signature", async (e) => {
|
|
8857
8885
|
try {
|
|
8858
8886
|
let { pageIndex: t, x: n, y: r, width: i, height: a } = e, o = {
|
|
8859
|
-
id:
|
|
8887
|
+
id: cr(),
|
|
8860
8888
|
type: "digital_signature_placeholder",
|
|
8861
8889
|
pageIndex: t,
|
|
8862
8890
|
x: n,
|
|
@@ -9082,7 +9110,7 @@ var ar = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID
|
|
|
9082
9110
|
minHeight: 0,
|
|
9083
9111
|
overflow: "hidden"
|
|
9084
9112
|
},
|
|
9085
|
-
children: /* @__PURE__ */ I(
|
|
9113
|
+
children: /* @__PURE__ */ I(rn, {
|
|
9086
9114
|
leftSidebarOpen: oe && A,
|
|
9087
9115
|
rightSidebarOpen: oe && Se,
|
|
9088
9116
|
sidebarTab: we,
|
|
@@ -9123,22 +9151,22 @@ var ar = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID
|
|
|
9123
9151
|
showSelectionTooltip: fe
|
|
9124
9152
|
})
|
|
9125
9153
|
}),
|
|
9126
|
-
M && /* @__PURE__ */ I(
|
|
9154
|
+
M && /* @__PURE__ */ I(on, {
|
|
9127
9155
|
onClose: () => N(!1),
|
|
9128
9156
|
watermarkText: Pe,
|
|
9129
9157
|
setWatermarkText: Fe
|
|
9130
9158
|
}),
|
|
9131
|
-
De && /* @__PURE__ */ I(
|
|
9159
|
+
De && /* @__PURE__ */ I(q, { onClose: () => Oe(!1) })
|
|
9132
9160
|
]
|
|
9133
9161
|
})
|
|
9134
9162
|
});
|
|
9135
9163
|
});
|
|
9136
9164
|
//#endregion
|
|
9137
9165
|
//#region src/core/createWebViewer.tsx
|
|
9138
|
-
function
|
|
9166
|
+
function ur(e, t) {
|
|
9139
9167
|
return typeof window > "u" || typeof document > "u" ? Promise.reject(/* @__PURE__ */ Error("[teamsync-pdf-viewer] createWebViewer() requires a browser environment.")) : t ? new Promise((n) => {
|
|
9140
9168
|
let r = u.createRoot(t), { path: i, ...a } = e;
|
|
9141
|
-
r.render(/* @__PURE__ */ I(
|
|
9169
|
+
r.render(/* @__PURE__ */ I(lr, {
|
|
9142
9170
|
...a,
|
|
9143
9171
|
style: {
|
|
9144
9172
|
width: "100%",
|
|
@@ -9150,8 +9178,8 @@ function sr(e, t) {
|
|
|
9150
9178
|
}));
|
|
9151
9179
|
}) : Promise.reject(/* @__PURE__ */ Error("[teamsync-pdf-viewer] createWebViewer() needs a container element."));
|
|
9152
9180
|
}
|
|
9153
|
-
var
|
|
9181
|
+
var dr = ur;
|
|
9154
9182
|
//#endregion
|
|
9155
|
-
export {
|
|
9183
|
+
export { ir as AnnotationManager, It as DEFAULT_FALLBACK_DIMS, bn as MAX_EXPORT_BYTES, Ge as MAX_SCALE, B as MIN_SCALE, lr as TeamSyncViewer, Pt as TextSelectionTooltip, sn as ViewerBus, dr as WebViewer, or as WebViewerInstance, En as XFDF_NS, qn as annotationToXfdfFragment, Yn as annotationsToXfdf, Tn as buildPdfBytes, Ze as calculateNextZoomIn, Qe as calculateNextZoomOut, tt as calculateScrollCompensation, $e as clampScale, nn as computeCanvasPixelDiff, Xt as computePageDiffBoxes, Rt as computeRowLayout, $t as computeTextDiff, zt as configurePdfAssets, Nt as copyTextToClipboard, dn as createGeometryResolver, un as createPageGeometry, ur as createWebViewer, Lt as estimatePageDimensions, Yt as extractWordsFromPage, jn as fromPdfDate, pn as fromPdfPoint, Y as geometryFromPage, G as getPdfAssetPaths, U as hasDimensionMismatch, Bt as isWorkerConfigured, Mt as newAnnotationId, tr as parseXfdf, Ut as pdfjsVersion, sr as printPdfBytes, _n as quadPointsToRects, X as rectFromPdf, mn as rectToPdf, gn as rectToQuadPoints, bt as searchPdfText, tn as tintCanvas, An as toPdfDate, fn as toPdfPoint, xt as usePdfSearch };
|
|
9156
9184
|
|
|
9157
9185
|
//# sourceMappingURL=teamsync-pdf-viewer.js.map
|