epochs-pdf 0.1.7 → 0.1.9

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.
@@ -1,30 +1,30 @@
1
- var Hi = Object.defineProperty;
2
- var ji = (t, e, n) => e in t ? Hi(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var Je = (t, e, n) => ji(t, typeof e != "symbol" ? e + "" : e, n);
4
- import { useRef as xt, useState as z, useEffect as Tt, useMemo as xe, useCallback as K, Fragment as Bi } from "react";
5
- import { jsxs as T, jsx as s, Fragment as Ae } from "react/jsx-runtime";
6
- import * as ke from "pdfjs-dist";
1
+ var ji = Object.defineProperty;
2
+ var Bi = (t, e, n) => e in t ? ji(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var on = (t, e, n) => Bi(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { useRef as xt, useState as O, useEffect as Dt, useMemo as Pe, useCallback as Y, Fragment as Wi } from "react";
5
+ import { jsxs as T, jsx as s, Fragment as je } from "react/jsx-runtime";
6
+ import * as Ie from "pdfjs-dist";
7
7
  import { TextLayer as Oi } from "pdfjs-dist";
8
- const Re = "#ffffff", Dn = [
8
+ const He = "#ffffff", An = [
9
9
  { id: "yellow", label: "Yellow", hex: "#facc15" },
10
10
  { id: "green", label: "Green", hex: "#4ade80" },
11
11
  { id: "pink", label: "Pink", hex: "#f472b6" },
12
12
  { id: "blue", label: "Blue", hex: "#60a5fa" },
13
13
  { id: "orange", label: "Orange", hex: "#fb923c" },
14
14
  { id: "purple", label: "Purple", hex: "#c084fc" }
15
- ], Fn = [
15
+ ], En = [
16
16
  { id: "blue", label: "Blue", hex: "#2563eb" },
17
17
  { id: "red", label: "Red", hex: "#dc2626" },
18
18
  { id: "green", label: "Green", hex: "#16a34a" },
19
19
  { id: "orange", label: "Orange", hex: "#ea580c" },
20
20
  { id: "purple", label: "Purple", hex: "#7c3aed" },
21
21
  { id: "black", label: "Black", hex: "#111827" }
22
- ], Rn = Dn[0].hex, Wi = Fn[0].hex;
23
- An(Rn, "highlight");
24
- function tn() {
22
+ ], Hn = An[0].hex, zi = En[0].hex;
23
+ Un(Hn, "highlight");
24
+ function sn() {
25
25
  return `m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
26
26
  }
27
- function ce(t) {
27
+ function le(t) {
28
28
  const e = t.trim();
29
29
  if (/^#[0-9a-fA-F]{6}$/.test(e)) return e.toLowerCase();
30
30
  if (/^#[0-9a-fA-F]{3}$/.test(e)) {
@@ -33,15 +33,15 @@ function ce(t) {
33
33
  }
34
34
  return e;
35
35
  }
36
- function An(t, e, n = 0.45) {
37
- const i = ce(t);
36
+ function Un(t, e, n = 0.45) {
37
+ const i = le(t);
38
38
  if (e === "underline" || e === "redact") return i;
39
39
  const r = /^#([0-9a-f]{6})$/i.exec(i);
40
40
  if (!r) return `rgba(250, 204, 21, ${n})`;
41
41
  const o = Number.parseInt(r[1], 16), d = o >> 16 & 255, u = o >> 8 & 255, m = o & 255;
42
42
  return `rgba(${d}, ${u}, ${m}, ${n})`;
43
43
  }
44
- function en(t, e) {
44
+ function an(t, e) {
45
45
  const n = window.getSelection();
46
46
  if (!n || n.isCollapsed || n.rangeCount === 0)
47
47
  return null;
@@ -60,7 +60,7 @@ function en(t, e) {
60
60
  h: r.height > 0 ? _.height / r.height * (m / d) : 0
61
61
  })), text: n.toString() };
62
62
  }
63
- function xn(t) {
63
+ function Nn(t) {
64
64
  const n = [...t].sort((i, r) => i.y - r.y || i.x - r.x)[0] ?? { x: 0, y: 0, h: 14 };
65
65
  return {
66
66
  x: n.x,
@@ -68,7 +68,7 @@ function xn(t) {
68
68
  fontSize: Math.max(8, Math.round(n.h * 0.9) || 14)
69
69
  };
70
70
  }
71
- function nn(t, e = 2) {
71
+ function cn(t, e = 2) {
72
72
  return t.map((n) => ({
73
73
  x: Math.max(0, n.x - e),
74
74
  y: Math.max(0, n.y - e),
@@ -76,26 +76,26 @@ function nn(t, e = 2) {
76
76
  h: n.h + e * 2
77
77
  }));
78
78
  }
79
- function En(t, e, n) {
79
+ function jn(t, e, n) {
80
80
  for (const i of e)
81
81
  for (const r of i.rects) {
82
82
  const o = r.x * n, d = r.y * n, u = r.w * n, m = r.h * n;
83
83
  if (i.kind === "highlight")
84
84
  t.save(), t.globalCompositeOperation = "multiply", t.fillStyle = i.color, t.fillRect(o, d, u, m), t.restore();
85
85
  else if (i.kind === "redact")
86
- t.fillStyle = i.color || Re, t.fillRect(o, d, u, m);
86
+ t.fillStyle = i.color || He, t.fillRect(o, d, u, m);
87
87
  else {
88
88
  const g = Math.max(2, n * 1.5);
89
89
  t.fillStyle = i.color, t.fillRect(o, d + m - g, u, g);
90
90
  }
91
91
  }
92
92
  }
93
- function Oe() {
93
+ function Se() {
94
94
  return `s_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
95
95
  }
96
- async function Un(t, e, n) {
96
+ async function Bn(t, e, n) {
97
97
  for (const i of e) {
98
- const r = await Si(i.imageDataUrl);
98
+ const r = await Gi(i.imageDataUrl);
99
99
  t.drawImage(
100
100
  r,
101
101
  i.x * n,
@@ -105,7 +105,7 @@ async function Un(t, e, n) {
105
105
  );
106
106
  }
107
107
  }
108
- function zi(t, e, n, i) {
108
+ function Si(t, e, n, i) {
109
109
  t.save();
110
110
  for (const r of e) {
111
111
  const o = n.has(r.id), d = r.x * i, u = r.y * i, m = r.width * i, g = r.height * i;
@@ -113,7 +113,7 @@ function zi(t, e, n, i) {
113
113
  }
114
114
  t.restore();
115
115
  }
116
- function Si(t) {
116
+ function Gi(t) {
117
117
  return new Promise((e, n) => {
118
118
  const i = new Image();
119
119
  i.onload = () => e(i), i.onerror = () => n(new Error("Failed to load signature image")), i.src = t;
@@ -128,28 +128,28 @@ function Xi(t, e, n = 180, i = 64) {
128
128
  height: Math.max(20, e * r)
129
129
  };
130
130
  }
131
- function He(t, e, n, i) {
131
+ function We(t, e, n, i) {
132
132
  const r = n.getBoundingClientRect(), o = n.clientWidth || r.width, d = n.clientHeight || r.height;
133
133
  return r.width <= 0 || r.height <= 0 || i <= 0 ? { x: 0, y: 0 } : {
134
134
  x: (t - r.left) / r.width * (o / i),
135
135
  y: (e - r.top) / r.height * (d / i)
136
136
  };
137
137
  }
138
- function Ne(t, e) {
138
+ function Ce(t, e) {
139
139
  return {
140
140
  width: t.clientWidth / e,
141
141
  height: t.clientHeight / e
142
142
  };
143
143
  }
144
- function Gi(t, e, n, i) {
144
+ function Vi(t, e, n, i) {
145
145
  const r = n.getBoundingClientRect(), o = n.clientWidth || r.width, d = n.clientHeight || r.height;
146
146
  return r.width <= 0 || r.height <= 0 || i <= 0 ? { dx: 0, dy: 0 } : {
147
147
  dx: t / r.width * (o / i),
148
148
  dy: e / r.height * (d / i)
149
149
  };
150
150
  }
151
- function Mn(t, e, n) {
152
- const i = e.getBoundingClientRect(), { width: r, height: o } = Ne(e, n);
151
+ function Pn(t, e, n) {
152
+ const i = e.getBoundingClientRect(), { width: r, height: o } = Ce(e, n);
153
153
  return i.width <= 0 || i.height <= 0 ? { left: 0, top: 0, right: r, bottom: o } : {
154
154
  left: (t.left - i.left) / i.width * r,
155
155
  top: (t.top - i.top) / i.height * o,
@@ -157,60 +157,60 @@ function Mn(t, e, n) {
157
157
  bottom: (t.bottom - i.top) / i.height * o
158
158
  };
159
159
  }
160
- const ge = 14, pe = "#111827", rn = 24, on = 20;
161
- function We() {
160
+ const we = 14, me = "#111827", ln = 24, dn = 20;
161
+ function Ge() {
162
162
  return `t_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
163
163
  }
164
- function Le(t, e) {
164
+ function Re(t, e) {
165
165
  if (typeof document > "u")
166
166
  return {
167
- width: Math.max(rn, t.length * e * 0.55),
168
- height: Math.max(on, e * 1.25)
167
+ width: Math.max(ln, t.length * e * 0.55),
168
+ height: Math.max(dn, e * 1.25)
169
169
  };
170
170
  const i = document.createElement("canvas").getContext("2d");
171
171
  if (!i)
172
172
  return {
173
- width: Math.max(rn, t.length * e * 0.55),
174
- height: Math.max(on, e * 1.25)
173
+ width: Math.max(ln, t.length * e * 0.55),
174
+ height: Math.max(dn, e * 1.25)
175
175
  };
176
176
  i.font = `${e}px sans-serif`;
177
177
  const r = t.split(`
178
178
  `), o = e * 1.25;
179
- let d = rn;
179
+ let d = ln;
180
180
  for (const u of r)
181
181
  d = Math.max(d, i.measureText(u || " ").width + 4);
182
182
  return {
183
183
  width: d,
184
- height: Math.max(on, r.length * o)
184
+ height: Math.max(dn, r.length * o)
185
185
  };
186
186
  }
187
187
  function qi(t, e, n, i, r) {
188
- var E;
189
- const o = n.getBoundingClientRect(), d = n.clientWidth || o.width, u = n.clientHeight || o.height, m = (I) => o.width > 0 ? (I - o.left) / o.width * (d / r) : 0, g = (I) => o.height > 0 ? (I - o.top) / o.height * (u / r) : 0, _ = (I, et) => {
190
- const at = et === "x" ? o.width : o.height, Y = et === "x" ? d : u;
191
- return at > 0 ? I / at * (Y / r) : 0;
188
+ var A;
189
+ const o = n.getBoundingClientRect(), d = n.clientWidth || o.width, u = n.clientHeight || o.height, m = (C) => o.width > 0 ? (C - o.left) / o.width * (d / r) : 0, g = (C) => o.height > 0 ? (C - o.top) / o.height * (u / r) : 0, _ = (C, nt) => {
190
+ const at = nt === "x" ? o.width : o.height, q = nt === "x" ? d : u;
191
+ return at > 0 ? C / at * (q / r) : 0;
192
192
  };
193
- let w = m(t), b = g(e), x = ge;
194
- const C = Vi(t, e, i);
195
- if (C)
193
+ let y = m(t), b = g(e), x = we;
194
+ const I = Yi(t, e, i);
195
+ if (I)
196
196
  return {
197
- x: m(C.x),
198
- y: g(C.y),
199
- fontSize: Math.max(8, Math.round(_(C.fontSize, "y") * 10) / 10)
197
+ x: m(I.x),
198
+ y: g(I.y),
199
+ fontSize: Math.max(8, Math.round(_(I.fontSize, "y") * 10) / 10)
200
200
  };
201
- const S = document, H = (E = S.caretRangeFromPoint) == null ? void 0 : E.call(S, t, e);
201
+ const S = document, H = (A = S.caretRangeFromPoint) == null ? void 0 : A.call(S, t, e);
202
202
  if (H && i.contains(H.startContainer)) {
203
- const I = H.getClientRects(), et = I.length > 0 ? I[0] : H.getBoundingClientRect();
204
- if (et.height > 0) {
205
- b = g(et.top), x = Ki(H.startContainer, r, n);
206
- const at = m(et.left);
207
- return Math.abs(at - w) < _(8, "x") && (w = at), { x: w, y: b, fontSize: x };
203
+ const C = H.getClientRects(), nt = C.length > 0 ? C[0] : H.getBoundingClientRect();
204
+ if (nt.height > 0) {
205
+ b = g(nt.top), x = Zi(H.startContainer, r, n);
206
+ const at = m(nt.left);
207
+ return Math.abs(at - y) < _(8, "x") && (y = at), { x: y, y: b, fontSize: x };
208
208
  }
209
209
  }
210
- const O = Yi(t, e, i);
211
- return O && (b = g(O.top), x = Math.max(8, Math.round(_(O.height, "y") * 10) / 10)), { x: w, y: b, fontSize: x };
210
+ const W = Ki(t, e, i);
211
+ return W && (b = g(W.top), x = Math.max(8, Math.round(_(W.height, "y") * 10) / 10)), { x: y, y: b, fontSize: x };
212
212
  }
213
- function Vi(t, e, n) {
213
+ function Yi(t, e, n) {
214
214
  var o;
215
215
  const i = Array.from(
216
216
  n.querySelectorAll("span")
@@ -240,7 +240,7 @@ function Vi(t, e, n) {
240
240
  }
241
241
  return null;
242
242
  }
243
- function Yi(t, e, n) {
243
+ function Ki(t, e, n) {
244
244
  var o;
245
245
  const i = Array.from(
246
246
  n.querySelectorAll("span")
@@ -255,11 +255,11 @@ function Yi(t, e, n) {
255
255
  }
256
256
  return r ? { top: r.top, height: r.height } : null;
257
257
  }
258
- function Ki(t, e, n) {
258
+ function Zi(t, e, n) {
259
259
  const i = t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement;
260
- return i ? Zi(i, e, n) : ge;
260
+ return i ? Qi(i, e, n) : we;
261
261
  }
262
- function Zi(t, e, n) {
262
+ function Qi(t, e, n) {
263
263
  const i = t.getBoundingClientRect().height;
264
264
  if (i > 0) {
265
265
  if (n) {
@@ -273,15 +273,15 @@ function Zi(t, e, n) {
273
273
  return Math.max(8, Math.round(i / e * 10) / 10);
274
274
  }
275
275
  const r = window.getComputedStyle(t).fontSize, o = Number.parseFloat(r);
276
- return Number.isFinite(o) && o > 0 ? Math.max(8, Math.round(o / e * 10) / 10) : ge;
276
+ return Number.isFinite(o) && o > 0 ? Math.max(8, Math.round(o / e * 10) / 10) : we;
277
277
  }
278
- function Qi(t, e, n, i) {
278
+ function Ji(t, e, n, i) {
279
279
  for (const r of n)
280
280
  if (r.pageNumber === i && t >= r.x && t <= r.x + r.width && e >= r.y && e <= r.y + r.height)
281
281
  return r;
282
282
  return null;
283
283
  }
284
- function Ji(t, e, n) {
284
+ function tr(t, e, n) {
285
285
  var x;
286
286
  if (!n) return null;
287
287
  const i = document, r = (x = i.caretRangeFromPoint) == null ? void 0 : x.call(i, t, e);
@@ -291,17 +291,17 @@ function Ji(t, e, n) {
291
291
  const d = o.textContent;
292
292
  let u = r.startOffset;
293
293
  u = Math.min(Math.max(0, u), d.length);
294
- const m = (C) => /[\p{L}\p{N}_'-]/u.test(C);
294
+ const m = (I) => /[\p{L}\p{N}_'-]/u.test(I);
295
295
  let g = u, _ = u;
296
296
  for (; g > 0 && m(d[g - 1]); ) g -= 1;
297
297
  for (; _ < d.length && m(d[_]); ) _ += 1;
298
298
  if (g === _) return null;
299
- const w = document.createRange();
300
- w.setStart(o, g), w.setEnd(o, _);
299
+ const y = document.createRange();
300
+ y.setStart(o, g), y.setEnd(o, _);
301
301
  const b = window.getSelection();
302
- return b == null || b.removeAllRanges(), b == null || b.addRange(w), d.slice(g, _);
302
+ return b == null || b.removeAllRanges(), b == null || b.addRange(y), d.slice(g, _);
303
303
  }
304
- function Hn(t, e, n) {
304
+ function Wn(t, e, n) {
305
305
  t.save();
306
306
  for (const i of e) {
307
307
  if (!i.value.trim()) continue;
@@ -315,7 +315,7 @@ function Hn(t, e, n) {
315
315
  }
316
316
  t.restore();
317
317
  }
318
- function tr(t, e, n, i) {
318
+ function er(t, e, n, i) {
319
319
  t.save();
320
320
  for (const r of e) {
321
321
  const o = n.has(r.id), d = r.x * i, u = r.y * i, m = r.width * i, g = r.height * i;
@@ -346,27 +346,27 @@ function Bt({
346
346
  }
347
347
  );
348
348
  }
349
- function er(t) {
349
+ function nr(t) {
350
350
  return /* @__PURE__ */ s(Bt, { ...t, children: /* @__PURE__ */ s("polyline", { points: "15 18 9 12 15 6" }) });
351
351
  }
352
- function nr(t) {
352
+ function ir(t) {
353
353
  return /* @__PURE__ */ s(Bt, { ...t, children: /* @__PURE__ */ s("polyline", { points: "9 18 15 12 9 6" }) });
354
354
  }
355
- function ir(t) {
355
+ function rr(t) {
356
356
  return /* @__PURE__ */ T(Bt, { ...t, children: [
357
357
  /* @__PURE__ */ s("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
358
358
  /* @__PURE__ */ s("polyline", { points: "7 10 12 15 17 10" }),
359
359
  /* @__PURE__ */ s("line", { x1: "12", y1: "15", x2: "12", y2: "3" })
360
360
  ] });
361
361
  }
362
- function rr(t) {
362
+ function or(t) {
363
363
  return /* @__PURE__ */ T(Bt, { ...t, children: [
364
364
  /* @__PURE__ */ s("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }),
365
365
  /* @__PURE__ */ s("polyline", { points: "15 3 21 3 21 9" }),
366
366
  /* @__PURE__ */ s("line", { x1: "10", y1: "14", x2: "21", y2: "3" })
367
367
  ] });
368
368
  }
369
- function or(t) {
369
+ function sr(t) {
370
370
  return /* @__PURE__ */ T(Bt, { ...t, children: [
371
371
  /* @__PURE__ */ s("rect", { x: "3", y: "3", width: "7", height: "7" }),
372
372
  /* @__PURE__ */ s("rect", { x: "14", y: "3", width: "7", height: "7" }),
@@ -374,55 +374,55 @@ function or(t) {
374
374
  /* @__PURE__ */ s("rect", { x: "3", y: "14", width: "7", height: "7" })
375
375
  ] });
376
376
  }
377
- function sr(t) {
377
+ function ar(t) {
378
378
  return /* @__PURE__ */ s(Bt, { ...t, children: /* @__PURE__ */ s("line", { x1: "5", y1: "12", x2: "19", y2: "12" }) });
379
379
  }
380
- function ar(t) {
380
+ function cr(t) {
381
381
  return /* @__PURE__ */ T(Bt, { ...t, children: [
382
382
  /* @__PURE__ */ s("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
383
383
  /* @__PURE__ */ s("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
384
384
  ] });
385
385
  }
386
- function cr(t) {
386
+ function lr(t) {
387
387
  return /* @__PURE__ */ T(Bt, { ...t, children: [
388
388
  /* @__PURE__ */ s("polyline", { points: "6 9 6 2 18 2 18 9" }),
389
389
  /* @__PURE__ */ s("path", { d: "M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2" }),
390
390
  /* @__PURE__ */ s("rect", { x: "6", y: "14", width: "12", height: "8" })
391
391
  ] });
392
392
  }
393
- function lr(t) {
393
+ function dr(t) {
394
394
  return /* @__PURE__ */ T(Bt, { ...t, children: [
395
395
  /* @__PURE__ */ s("polyline", { points: "23 4 23 10 17 10" }),
396
396
  /* @__PURE__ */ s("polyline", { points: "1 20 1 14 7 14" }),
397
397
  /* @__PURE__ */ s("path", { d: "M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15" })
398
398
  ] });
399
399
  }
400
- function dr(t) {
400
+ function hr(t) {
401
401
  return /* @__PURE__ */ T(Bt, { ...t, children: [
402
402
  /* @__PURE__ */ s("polyline", { points: "23 4 23 10 17 10" }),
403
403
  /* @__PURE__ */ s("path", { d: "M20.49 15a9 9 0 1 1-2.12-9.36L23 10" })
404
404
  ] });
405
405
  }
406
- function hr(t) {
406
+ function ur(t) {
407
407
  return /* @__PURE__ */ T(Bt, { ...t, children: [
408
408
  /* @__PURE__ */ s("path", { d: "M12 20h9" }),
409
409
  /* @__PURE__ */ s("path", { d: "M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z" })
410
410
  ] });
411
411
  }
412
- function ur(t) {
412
+ function fr(t) {
413
413
  return /* @__PURE__ */ T(Bt, { ...t, children: [
414
414
  /* @__PURE__ */ s("path", { d: "M6 3v7a6 6 0 0 0 12 0V3" }),
415
415
  /* @__PURE__ */ s("line", { x1: "4", y1: "21", x2: "20", y2: "21" })
416
416
  ] });
417
417
  }
418
- function fr(t) {
418
+ function pr(t) {
419
419
  return /* @__PURE__ */ T(Bt, { ...t, children: [
420
420
  /* @__PURE__ */ s("path", { d: "m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21" }),
421
421
  /* @__PURE__ */ s("path", { d: "M22 21H7" }),
422
422
  /* @__PURE__ */ s("path", { d: "m5 11 9 9" })
423
423
  ] });
424
424
  }
425
- function pr({ size: t = 16, className: e }) {
425
+ function gr({ size: t = 16, className: e }) {
426
426
  return /* @__PURE__ */ s(
427
427
  "svg",
428
428
  {
@@ -440,20 +440,20 @@ function pr({ size: t = 16, className: e }) {
440
440
  }
441
441
  );
442
442
  }
443
- function gr(t) {
443
+ function mr(t) {
444
444
  return /* @__PURE__ */ T(Bt, { ...t, children: [
445
445
  /* @__PURE__ */ s("path", { d: "M12 20h9" }),
446
446
  /* @__PURE__ */ s("path", { d: "M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z" })
447
447
  ] });
448
448
  }
449
- function mr(t) {
449
+ function wr(t) {
450
450
  return /* @__PURE__ */ T(Bt, { ...t, children: [
451
451
  /* @__PURE__ */ s("polyline", { points: "4 7 4 4 20 4 20 7" }),
452
452
  /* @__PURE__ */ s("line", { x1: "9", y1: "20", x2: "15", y2: "20" }),
453
453
  /* @__PURE__ */ s("line", { x1: "12", y1: "4", x2: "12", y2: "20" })
454
454
  ] });
455
455
  }
456
- function wr({
456
+ function yr({
457
457
  pdfDoc: t,
458
458
  pageNumber: e,
459
459
  scale: n,
@@ -465,148 +465,148 @@ function wr({
465
465
  annotations: m = [],
466
466
  onAddAnnotation: g,
467
467
  onRemoveAnnotation: _,
468
- signatures: w = [],
468
+ signatures: y = [],
469
469
  pendingSignature: b = null,
470
470
  onAddSignature: x,
471
- onUpdateSignature: C,
471
+ onUpdateSignature: I,
472
472
  onRemoveSignature: S,
473
473
  onEditSignature: H,
474
- onDuplicateSignature: O,
475
- selectedSignatureId: E = null,
476
- onSelectSignature: I,
477
- signatureFields: et = [],
474
+ onDuplicateSignature: W,
475
+ selectedSignatureId: A = null,
476
+ onSelectSignature: C,
477
+ signatureFields: nt = [],
478
478
  selectedSignatureFieldId: at = null,
479
- onSelectSignatureField: Y,
479
+ onSelectSignatureField: q,
480
480
  hasFixedSignatureFields: pt = !1,
481
481
  onOpenSignaturePad: J,
482
482
  fieldValues: Mt = {},
483
- onFieldValueChange: Z,
484
- onFieldValueCommit: Lt,
485
- pendingFieldValue: _t = null,
486
- onPlaceFieldValue: U,
483
+ onFieldValueChange: K,
484
+ onFieldValueCommit: Et,
485
+ pendingFieldValue: vt = null,
486
+ onPlaceFieldValue: E,
487
487
  texts: ct = [],
488
- onAddText: ft,
488
+ onAddText: ht,
489
489
  onUpdateText: gt,
490
490
  onRemoveText: tt,
491
- selectedTextId: kt = null,
492
- onSelectText: lt,
491
+ selectedTextId: Pt = null,
492
+ onSelectText: ut,
493
493
  textFields: te = [],
494
- selectedTextFieldId: me = null,
495
- onSelectTextField: St,
496
- hasFixedTextFields: Ut = !1,
497
- editingTextId: Dt = null,
498
- onEditingTextIdChange: X
494
+ selectedTextFieldId: ye = null,
495
+ onSelectTextField: Vt,
496
+ hasFixedTextFields: qt = !1,
497
+ editingTextId: Kt = null,
498
+ onEditingTextIdChange: G
499
499
  }) {
500
- const qt = xt(null), Ft = xt(null), wt = xt(null), st = xt(null), Ht = xt(null), nt = xt(null), [yt, Ct] = z(null), ee = xt(null), it = xt(!1);
501
- Tt(() => {
502
- if (!t || !Ft.current || !wt.current || !st.current)
500
+ const $t = xt(null), yt = xt(null), bt = xt(null), it = xt(null), Wt = xt(null), st = xt(null), [mt, It] = O(null), ee = xt(null), dt = xt(!1);
501
+ Dt(() => {
502
+ if (!t || !yt.current || !bt.current || !it.current)
503
503
  return;
504
504
  let a = !1;
505
- const y = Ft.current, v = wt.current, M = st.current, D = y.getContext("2d");
505
+ const w = yt.current, v = bt.current, M = it.current, D = w.getContext("2d");
506
506
  return D ? ((async () => {
507
507
  try {
508
- if (Ht.current) {
508
+ if (Wt.current) {
509
509
  try {
510
- Ht.current.cancel();
510
+ Wt.current.cancel();
511
511
  } catch {
512
512
  }
513
- Ht.current = null;
513
+ Wt.current = null;
514
514
  }
515
- if (nt.current) {
515
+ if (st.current) {
516
516
  try {
517
- nt.current.cancel();
517
+ st.current.cancel();
518
518
  } catch {
519
519
  }
520
- nt.current = null;
520
+ st.current = null;
521
521
  }
522
- const R = await t.getPage(e);
522
+ const F = await t.getPage(e);
523
523
  if (a) return;
524
- const k = R.getViewport({ scale: n, rotation: i }), B = Math.floor(k.width), G = Math.floor(k.height);
525
- y.width = B, y.height = G, M.style.width = `${B}px`, M.style.height = `${G}px`;
526
- const L = R.render({ canvasContext: D, viewport: k });
527
- if (Ht.current = L, await L.promise, a) return;
528
- v.replaceChildren(), v.style.setProperty("--scale-factor", String(k.scale));
529
- const rt = await R.getTextContent();
524
+ const N = F.getViewport({ scale: n, rotation: i }), j = Math.floor(N.width), Z = Math.floor(N.height);
525
+ w.width = j, w.height = Z, M.style.width = `${j}px`, M.style.height = `${Z}px`;
526
+ const R = F.render({ canvasContext: D, viewport: N });
527
+ if (Wt.current = R, await R.promise, a) return;
528
+ v.replaceChildren(), v.style.setProperty("--scale-factor", String(N.scale));
529
+ const lt = await F.getTextContent();
530
530
  if (a) return;
531
- const q = new Oi({
532
- textContentSource: rt,
531
+ const X = new Oi({
532
+ textContentSource: lt,
533
533
  container: v,
534
- viewport: k
534
+ viewport: N
535
535
  });
536
- if (nt.current = q, await q.render(), a) return;
536
+ if (st.current = X, await X.render(), a) return;
537
537
  o == null || o(e);
538
538
  } catch {
539
539
  }
540
540
  })(), () => {
541
- if (a = !0, Ht.current) {
541
+ if (a = !0, Wt.current) {
542
542
  try {
543
- Ht.current.cancel();
543
+ Wt.current.cancel();
544
544
  } catch {
545
545
  }
546
- Ht.current = null;
546
+ Wt.current = null;
547
547
  }
548
- if (nt.current) {
548
+ if (st.current) {
549
549
  try {
550
- nt.current.cancel();
550
+ st.current.cancel();
551
551
  } catch {
552
552
  }
553
- nt.current = null;
553
+ st.current = null;
554
554
  }
555
555
  }) : void 0;
556
- }, [t, e, n, i, o]), Tt(() => {
557
- const a = st.current;
556
+ }, [t, e, n, i, o]), Dt(() => {
557
+ const a = it.current;
558
558
  if (!a) return;
559
- const y = (P) => {
560
- var G;
559
+ const w = (P) => {
560
+ var Z;
561
561
  if (!g) return !1;
562
- const R = P === "redact" ? Re : u;
563
- if (!R) return !1;
564
- const k = en(a, n);
565
- if (!k) return !1;
566
- const B = P === "redact" ? nn(k.rects) : k.rects;
562
+ const F = P === "redact" ? He : u;
563
+ if (!F) return !1;
564
+ const N = an(a, n);
565
+ if (!N) return !1;
566
+ const j = P === "redact" ? cn(N.rects) : N.rects;
567
567
  return g({
568
- id: tn(),
568
+ id: sn(),
569
569
  pageNumber: e,
570
570
  kind: P,
571
- color: R,
572
- rects: B,
573
- text: k.text
574
- }), (G = window.getSelection()) == null || G.removeAllRanges(), !0;
571
+ color: F,
572
+ rects: j,
573
+ text: N.text
574
+ }), (Z = window.getSelection()) == null || Z.removeAllRanges(), !0;
575
575
  }, v = (P) => {
576
- var rt;
577
- if (!g || !ft) return !1;
578
- const R = en(a, n);
579
- if (!R) return !1;
580
- const k = nn(R.rects);
576
+ var lt;
577
+ if (!g || !ht) return !1;
578
+ const F = an(a, n);
579
+ if (!F) return !1;
580
+ const N = cn(F.rects);
581
581
  g({
582
- id: tn(),
582
+ id: sn(),
583
583
  pageNumber: e,
584
584
  kind: "redact",
585
- color: Re,
586
- rects: k,
587
- text: R.text
585
+ color: He,
586
+ rects: N,
587
+ text: F.text
588
588
  });
589
- const B = xn(R.rects), G = Le(P || " ", B.fontSize), L = {
590
- id: We(),
589
+ const j = Nn(F.rects), Z = Re(P || " ", j.fontSize), R = {
590
+ id: Ge(),
591
591
  pageNumber: e,
592
- x: B.x,
593
- y: B.y,
594
- width: G.width,
595
- height: G.height,
592
+ x: j.x,
593
+ y: j.y,
594
+ width: Z.width,
595
+ height: Z.height,
596
596
  value: P,
597
- fontSize: B.fontSize,
598
- color: pe
597
+ fontSize: j.fontSize,
598
+ color: me
599
599
  };
600
- return ft(L), lt == null || lt(L.id), X == null || X(L.id), (rt = window.getSelection()) == null || rt.removeAllRanges(), it.current = !0, window.setTimeout(() => {
601
- it.current = !1;
600
+ return ht(R), ut == null || ut(R.id), G == null || G(R.id), (lt = window.getSelection()) == null || lt.removeAllRanges(), dt.current = !0, window.setTimeout(() => {
601
+ dt.current = !1;
602
602
  }, 0), !0;
603
603
  }, M = () => {
604
604
  if (d === "highlight" || d === "underline") {
605
- y(d);
605
+ w(d);
606
606
  return;
607
607
  }
608
608
  if (d === "erase") {
609
- y("redact");
609
+ w("redact");
610
610
  return;
611
611
  }
612
612
  if (d === "text") {
@@ -614,13 +614,13 @@ function wr({
614
614
  P && !P.isCollapsed && P.toString().trim() && P.anchorNode && a.contains(P.anchorNode) && v(P.toString());
615
615
  }
616
616
  }, D = (P) => {
617
- const R = P.target;
618
- if (R != null && R.closest("[contenteditable='true']") || R != null && R.closest("[contenteditable='']") || R != null && R.isContentEditable)
617
+ const F = P.target;
618
+ if (F != null && F.closest("[contenteditable='true']") || F != null && F.closest("[contenteditable='']") || F != null && F.isContentEditable)
619
619
  return;
620
- const k = window.getSelection(), B = k != null && !k.isCollapsed && k.toString().trim().length > 0 && k.anchorNode != null && a.contains(k.anchorNode);
621
- if (d === "text" && B) {
620
+ const N = window.getSelection(), j = N != null && !N.isCollapsed && N.toString().trim().length > 0 && N.anchorNode != null && a.contains(N.anchorNode);
621
+ if (d === "text" && j) {
622
622
  if (P.key === "Enter" && !P.shiftKey) {
623
- P.preventDefault(), v(k.toString());
623
+ P.preventDefault(), v(N.toString());
624
624
  return;
625
625
  }
626
626
  if (P.key.length === 1 && !P.ctrlKey && !P.metaKey && !P.altKey) {
@@ -628,7 +628,7 @@ function wr({
628
628
  return;
629
629
  }
630
630
  }
631
- d !== "text" && d !== "erase" || P.key !== "Backspace" && P.key !== "Delete" || B && (P.preventDefault(), y("redact"));
631
+ d !== "text" && d !== "erase" || P.key !== "Backspace" && P.key !== "Delete" || j && (P.preventDefault(), w("redact"));
632
632
  };
633
633
  return a.addEventListener("mouseup", M), window.addEventListener("keydown", D), () => {
634
634
  a.removeEventListener("mouseup", M), window.removeEventListener("keydown", D);
@@ -637,225 +637,225 @@ function wr({
637
637
  d,
638
638
  u,
639
639
  g,
640
- ft,
641
- X,
642
- lt,
640
+ ht,
641
+ G,
642
+ ut,
643
643
  e,
644
644
  n
645
- ]), Tt(() => {
646
- if (!yt) return;
647
- let a = 0, y = 0, v = 0, M = 0;
645
+ ]), Dt(() => {
646
+ if (!mt) return;
647
+ let a = 0, w = 0, v = 0, M = 0;
648
648
  const D = () => {
649
- var L;
650
- return (L = qt.current) == null ? void 0 : L.closest(".epochs-pdf-viewer__body");
651
- }, P = (L, rt) => {
652
- if (yt.kind !== "resize" || !C || pt) return;
653
- const q = w.find((bt) => bt.id === yt.id);
654
- if (!q) return;
655
- const ut = st.current, vt = ut ? Ne(ut, n) : { width: 1 / 0, height: 1 / 0 }, { dx: Xt, dy: Nt } = ut ? Gi(
656
- L - yt.startX,
657
- rt - yt.startY,
658
- ut,
649
+ var R;
650
+ return (R = $t.current) == null ? void 0 : R.closest(".epochs-pdf-viewer__body");
651
+ }, P = (R, lt) => {
652
+ if (mt.kind !== "resize" || !I || pt) return;
653
+ const X = y.find((_t) => _t.id === mt.id);
654
+ if (!X) return;
655
+ const et = it.current, ft = et ? Ce(et, n) : { width: 1 / 0, height: 1 / 0 }, { dx: Ft, dy: Rt } = et ? Vi(
656
+ R - mt.startX,
657
+ lt - mt.startY,
658
+ et,
659
659
  n
660
- ) : { dx: 0, dy: 0 }, Rt = vt.width - q.x, At = vt.height - q.y, Zt = Math.min(Rt, Math.max(40, yt.startW + Xt)), It = Math.min(At, Math.max(20, yt.startH + Nt));
661
- C(yt.id, { width: Zt, height: It });
662
- }, R = (L, rt) => {
663
- var Qt;
664
- if (yt.kind !== "signature" || !C || pt) return;
665
- const q = w.find((oe) => oe.id === yt.id);
666
- if (!q) return;
667
- let ut = (Qt = document.elementFromPoint(L, rt)) == null ? void 0 : Qt.closest("[data-page-number]");
668
- if (ut || (ut = Array.from(
660
+ ) : { dx: 0, dy: 0 }, Ht = ft.width - X.x, At = ft.height - X.y, St = Math.min(Ht, Math.max(40, mt.startW + Ft)), Nt = Math.min(At, Math.max(20, mt.startH + Rt));
661
+ I(mt.id, { width: St, height: Nt });
662
+ }, F = (R, lt) => {
663
+ var Ut;
664
+ if (mt.kind !== "signature" || !I || pt) return;
665
+ const X = y.find((Yt) => Yt.id === mt.id);
666
+ if (!X) return;
667
+ let et = (Ut = document.elementFromPoint(R, lt)) == null ? void 0 : Ut.closest("[data-page-number]");
668
+ if (et || (et = Array.from(
669
669
  document.querySelectorAll(".epochs-pdf-viewer__page[data-page-number]")
670
670
  ).find((Gt) => {
671
- const se = Gt.getBoundingClientRect();
672
- return rt >= se.top && rt <= se.bottom;
673
- }) ?? null), ut || (ut = qt.current), !ut) return;
674
- const vt = ut.querySelector(
671
+ const be = Gt.getBoundingClientRect();
672
+ return lt >= be.top && lt <= be.bottom;
673
+ }) ?? null), et || (et = $t.current), !et) return;
674
+ const ft = et.querySelector(
675
675
  ".epochs-pdf-viewer__surface"
676
676
  );
677
- if (!vt) return;
678
- const Xt = Number.parseInt(
679
- ut.getAttribute("data-page-number") || String(q.pageNumber),
677
+ if (!ft) return;
678
+ const Ft = Number.parseInt(
679
+ et.getAttribute("data-page-number") || String(X.pageNumber),
680
680
  10
681
- ), Nt = He(L, rt, vt, n), Rt = Ne(vt, n);
682
- let At = Nt.x - yt.offsetX, Zt = Nt.y - yt.offsetY;
683
- const It = Math.max(0, Rt.width - q.width), bt = Math.max(0, Rt.height - q.height);
684
- At = Math.min(Math.max(0, At), It), Zt = Math.min(Math.max(0, Zt), bt), C(yt.id, {
685
- pageNumber: Xt,
681
+ ), Rt = We(R, lt, ft, n), Ht = Ce(ft, n);
682
+ let At = Rt.x - mt.offsetX, St = Rt.y - mt.offsetY;
683
+ const Nt = Math.max(0, Ht.width - X.width), _t = Math.max(0, Ht.height - X.height);
684
+ At = Math.min(Math.max(0, At), Nt), St = Math.min(Math.max(0, St), _t), I(mt.id, {
685
+ pageNumber: Ft,
686
686
  x: At,
687
- y: Zt
687
+ y: St
688
688
  });
689
- }, k = () => {
689
+ }, N = () => {
690
690
  if (a = 0, !M) return;
691
- const L = D();
692
- if (!L) return;
693
- const rt = L.scrollHeight - L.clientHeight;
694
- if (rt <= 0) return;
695
- const q = 56, ut = L.getBoundingClientRect(), vt = v - ut.top, Xt = ut.bottom - v;
696
- let Nt = 0;
697
- if (M < 0 && vt < q)
698
- Nt = -Math.max(6, (q - vt) / q * 28);
699
- else if (M > 0 && Xt < q)
700
- Nt = Math.max(6, (q - Xt) / q * 28);
691
+ const R = D();
692
+ if (!R) return;
693
+ const lt = R.scrollHeight - R.clientHeight;
694
+ if (lt <= 0) return;
695
+ const X = 56, et = R.getBoundingClientRect(), ft = v - et.top, Ft = et.bottom - v;
696
+ let Rt = 0;
697
+ if (M < 0 && ft < X)
698
+ Rt = -Math.max(6, (X - ft) / X * 28);
699
+ else if (M > 0 && Ft < X)
700
+ Rt = Math.max(6, (X - Ft) / X * 28);
701
701
  else {
702
702
  M = 0;
703
703
  return;
704
704
  }
705
- const Rt = L.scrollTop;
706
- L.scrollTop = Math.min(rt, Math.max(0, Rt + Nt)), L.scrollTop !== Rt && R(y, v), Nt < 0 && L.scrollTop > 0 || Nt > 0 && L.scrollTop < rt ? a = window.requestAnimationFrame(k) : M = 0;
707
- }, B = (L) => {
708
- y = L.clientX, v = L.clientY;
709
- const rt = D();
710
- if (rt) {
711
- const ut = rt.getBoundingClientRect(), vt = L.clientY - ut.top, Xt = ut.bottom - L.clientY;
712
- vt < 56 ? (M = -1, a || (a = window.requestAnimationFrame(k))) : Xt < 56 ? (M = 1, a || (a = window.requestAnimationFrame(k))) : M = 0;
705
+ const Ht = R.scrollTop;
706
+ R.scrollTop = Math.min(lt, Math.max(0, Ht + Rt)), R.scrollTop !== Ht && F(w, v), Rt < 0 && R.scrollTop > 0 || Rt > 0 && R.scrollTop < lt ? a = window.requestAnimationFrame(N) : M = 0;
707
+ }, j = (R) => {
708
+ w = R.clientX, v = R.clientY;
709
+ const lt = D();
710
+ if (lt) {
711
+ const et = lt.getBoundingClientRect(), ft = R.clientY - et.top, Ft = et.bottom - R.clientY;
712
+ ft < 56 ? (M = -1, a || (a = window.requestAnimationFrame(N))) : Ft < 56 ? (M = 1, a || (a = window.requestAnimationFrame(N))) : M = 0;
713
713
  }
714
- yt.kind === "resize" ? P(L.clientX, L.clientY) : R(L.clientX, L.clientY);
715
- }, G = () => {
716
- M = 0, a && (window.cancelAnimationFrame(a), a = 0), Ct(null);
714
+ mt.kind === "resize" ? P(R.clientX, R.clientY) : F(R.clientX, R.clientY);
715
+ }, Z = () => {
716
+ M = 0, a && (window.cancelAnimationFrame(a), a = 0), It(null);
717
717
  };
718
- return window.addEventListener("pointermove", B), window.addEventListener("pointerup", G), window.addEventListener("pointercancel", G), () => {
719
- M = 0, a && window.cancelAnimationFrame(a), window.removeEventListener("pointermove", B), window.removeEventListener("pointerup", G), window.removeEventListener("pointercancel", G);
718
+ return window.addEventListener("pointermove", j), window.addEventListener("pointerup", Z), window.addEventListener("pointercancel", Z), () => {
719
+ M = 0, a && window.cancelAnimationFrame(a), window.removeEventListener("pointermove", j), window.removeEventListener("pointerup", Z), window.removeEventListener("pointercancel", Z);
720
720
  };
721
721
  }, [
722
- yt,
722
+ mt,
723
723
  pt,
724
- C,
724
+ I,
725
725
  n,
726
- w
727
- ]), Tt(() => {
728
- if (!Dt || !ee.current) return;
729
- const a = ee.current, y = ct.find((D) => D.id === Dt);
730
- a.textContent = (y == null ? void 0 : y.value) ?? "", a.focus();
726
+ y
727
+ ]), Dt(() => {
728
+ if (!Kt || !ee.current) return;
729
+ const a = ee.current, w = ct.find((D) => D.id === Kt);
730
+ a.textContent = (w == null ? void 0 : w.value) ?? "", a.focus();
731
731
  const v = document.createRange();
732
732
  v.selectNodeContents(a), v.collapse(!1);
733
733
  const M = window.getSelection();
734
734
  M == null || M.removeAllRanges(), M == null || M.addRange(v);
735
- }, [Dt]);
736
- const re = (a) => {
737
- qt.current = a, r == null || r(a);
738
- }, f = m.filter((a) => a.pageNumber === e), F = w.filter((a) => a.pageNumber === e), A = et.filter((a) => a.pageNumber === e), dt = ct.filter((a) => a.pageNumber === e), ht = (a, y) => {
739
- const v = y.trim();
735
+ }, [Kt]);
736
+ const ne = (a) => {
737
+ $t.current = a, r == null || r(a);
738
+ }, kt = m.filter((a) => a.pageNumber === e), oe = y.filter((a) => a.pageNumber === e), p = nt.filter((a) => a.pageNumber === e), L = ct.filter((a) => a.pageNumber === e), U = (a, w) => {
739
+ const v = w.trim();
740
740
  if (!v) {
741
- tt == null || tt(a.id), X == null || X(null);
741
+ tt == null || tt(a.id), G == null || G(null);
742
742
  return;
743
743
  }
744
- const M = Le(v, a.fontSize);
744
+ const M = Re(v, a.fontSize);
745
745
  gt == null || gt(a.id, {
746
746
  value: v,
747
747
  width: M.width,
748
748
  height: M.height
749
- }), X == null || X(null);
750
- }, Vt = (a, y) => {
751
- if (!ft) return;
752
- const v = st.current, M = wt.current;
749
+ }), G == null || G(null);
750
+ }, rt = (a, w) => {
751
+ if (!ht) return;
752
+ const v = it.current, M = bt.current;
753
753
  if (!v || !M) return;
754
754
  let D = qi(
755
755
  a,
756
- y,
756
+ w,
757
757
  v,
758
758
  M,
759
759
  n
760
- ), P, R = pe;
761
- if (Ut) {
762
- const G = Qi(
760
+ ), P, F = me;
761
+ if (qt) {
762
+ const Z = Ji(
763
763
  D.x,
764
764
  D.y,
765
765
  te,
766
766
  e
767
767
  );
768
- if (!G) return;
769
- const L = ct.find((rt) => rt.fieldId === G.id);
770
- if (L) {
771
- lt == null || lt(L.id), St == null || St(G.id), X == null || X(L.id);
768
+ if (!Z) return;
769
+ const R = ct.find((lt) => lt.fieldId === Z.id);
770
+ if (R) {
771
+ ut == null || ut(R.id), Vt == null || Vt(Z.id), G == null || G(R.id);
772
772
  return;
773
773
  }
774
- P = G.id, D = {
775
- x: G.x,
776
- y: G.y,
777
- fontSize: G.fontSize ?? ge
778
- }, R = G.color ?? pe, St == null || St(G.id);
774
+ P = Z.id, D = {
775
+ x: Z.x,
776
+ y: Z.y,
777
+ fontSize: Z.fontSize ?? we
778
+ }, F = Z.color ?? me, Vt == null || Vt(Z.id);
779
779
  }
780
- const k = Le("", D.fontSize), B = {
781
- id: We(),
780
+ const N = Re("", D.fontSize), j = {
781
+ id: Ge(),
782
782
  fieldId: P,
783
783
  pageNumber: e,
784
784
  x: D.x,
785
785
  y: D.y,
786
- width: k.width,
787
- height: k.height,
786
+ width: N.width,
787
+ height: N.height,
788
788
  value: "",
789
789
  fontSize: D.fontSize,
790
- color: R
790
+ color: F
791
791
  };
792
- ft(B), lt == null || lt(B.id), X == null || X(B.id);
793
- }, Yt = (a) => {
792
+ ht(j), ut == null || ut(j.id), G == null || G(j.id);
793
+ }, Lt = (a) => {
794
794
  var v;
795
795
  if (d !== "text" || a.target.closest(".epochs-pdf-viewer__inline-text"))
796
796
  return;
797
- if (it.current) {
798
- it.current = !1;
797
+ if (dt.current) {
798
+ dt.current = !1;
799
799
  return;
800
800
  }
801
- const y = window.getSelection();
802
- if (!(y && !y.isCollapsed && y.toString().trim())) {
803
- if (a.detail >= 2 && Ji(a.clientX, a.clientY, wt.current)) {
804
- const D = st.current;
805
- if (D && g && ft) {
806
- const P = en(D, n);
801
+ const w = window.getSelection();
802
+ if (!(w && !w.isCollapsed && w.toString().trim())) {
803
+ if (a.detail >= 2 && tr(a.clientX, a.clientY, bt.current)) {
804
+ const D = it.current;
805
+ if (D && g && ht) {
806
+ const P = an(D, n);
807
807
  if (P) {
808
808
  g({
809
- id: tn(),
809
+ id: sn(),
810
810
  pageNumber: e,
811
811
  kind: "redact",
812
- color: Re,
813
- rects: nn(P.rects),
812
+ color: He,
813
+ rects: cn(P.rects),
814
814
  text: P.text
815
815
  });
816
- const R = xn(P.rects), k = Le(P.text || " ", R.fontSize), B = {
817
- id: We(),
816
+ const F = Nn(P.rects), N = Re(P.text || " ", F.fontSize), j = {
817
+ id: Ge(),
818
818
  pageNumber: e,
819
- x: R.x,
820
- y: R.y,
821
- width: k.width,
822
- height: k.height,
819
+ x: F.x,
820
+ y: F.y,
821
+ width: N.width,
822
+ height: N.height,
823
823
  value: P.text,
824
- fontSize: R.fontSize,
825
- color: pe
824
+ fontSize: F.fontSize,
825
+ color: me
826
826
  };
827
- ft(B), lt == null || lt(B.id), X == null || X(B.id), (v = window.getSelection()) == null || v.removeAllRanges(), it.current = !0;
827
+ ht(j), ut == null || ut(j.id), G == null || G(j.id), (v = window.getSelection()) == null || v.removeAllRanges(), dt.current = !0;
828
828
  }
829
829
  }
830
830
  return;
831
831
  }
832
- a.stopPropagation(), Vt(a.clientX, a.clientY);
832
+ a.stopPropagation(), rt(a.clientX, a.clientY);
833
833
  }
834
- }, Kt = (a) => {
835
- const y = a.target;
836
- if (!(y.closest(".epochs-pdf-viewer__signature") || y.closest(".epochs-pdf-viewer__signature-field") || y.closest(".epochs-pdf-viewer__inline-text"))) {
834
+ }, Zt = (a) => {
835
+ const w = a.target;
836
+ if (!(w.closest(".epochs-pdf-viewer__signature") || w.closest(".epochs-pdf-viewer__signature-field") || w.closest(".epochs-pdf-viewer__inline-text"))) {
837
837
  if (d === "text") {
838
- Vt(a.clientX, a.clientY);
838
+ rt(a.clientX, a.clientY);
839
839
  return;
840
840
  }
841
- if (!pt && d === "sign" && _t && U) {
842
- const v = st.current;
841
+ if (!pt && d === "sign" && vt && E) {
842
+ const v = it.current;
843
843
  if (!v) return;
844
- const M = He(a.clientX, a.clientY, v, n);
845
- U(e, Math.max(0, M.x - 75), Math.max(0, M.y - 12));
844
+ const M = We(a.clientX, a.clientY, v, n);
845
+ E(e, Math.max(0, M.x - 75), Math.max(0, M.y - 12));
846
846
  return;
847
847
  }
848
848
  if (!pt && d === "sign" && b && x) {
849
- const v = st.current;
849
+ const v = it.current;
850
850
  if (!v) return;
851
- const M = Ne(v, n), D = He(a.clientX, a.clientY, v, n);
852
- let P = D.x - b.width / 2, R = D.y - b.height / 2;
853
- const k = Math.max(0, M.width - b.width), B = Math.max(0, M.height - b.height);
854
- P = Math.min(Math.max(0, P), k), R = Math.min(Math.max(0, R), B), x({
855
- id: Oe(),
851
+ const M = Ce(v, n), D = We(a.clientX, a.clientY, v, n);
852
+ let P = D.x - b.width / 2, F = D.y - b.height / 2;
853
+ const N = Math.max(0, M.width - b.width), j = Math.max(0, M.height - b.height);
854
+ P = Math.min(Math.max(0, P), N), F = Math.min(Math.max(0, F), j), x({
855
+ id: Se(),
856
856
  pageNumber: e,
857
857
  x: P,
858
- y: R,
858
+ y: F,
859
859
  width: b.width,
860
860
  height: b.height,
861
861
  imageDataUrl: b.imageDataUrl
@@ -863,7 +863,7 @@ function wr({
863
863
  return;
864
864
  }
865
865
  }
866
- }, ne = (a) => Dt === a.id ? /* @__PURE__ */ s(
866
+ }, ie = (a) => Kt === a.id ? /* @__PURE__ */ s(
867
867
  "span",
868
868
  {
869
869
  ref: ee,
@@ -883,7 +883,7 @@ function wr({
883
883
  onClick: (v) => v.stopPropagation(),
884
884
  onPointerDown: (v) => v.stopPropagation(),
885
885
  onInput: (v) => {
886
- const M = v.currentTarget.textContent ?? "", D = Le(M || " ", a.fontSize);
886
+ const M = v.currentTarget.textContent ?? "", D = Re(M || " ", a.fontSize);
887
887
  gt == null || gt(a.id, {
888
888
  value: M,
889
889
  width: D.width,
@@ -891,7 +891,7 @@ function wr({
891
891
  });
892
892
  },
893
893
  onBlur: (v) => {
894
- ht(a, v.currentTarget.textContent ?? "");
894
+ U(a, v.currentTarget.textContent ?? "");
895
895
  },
896
896
  onKeyDown: (v) => {
897
897
  v.stopPropagation(), v.key === "Escape" && (v.preventDefault(), v.currentTarget.blur()), v.key === "Enter" && !v.shiftKey && (v.preventDefault(), v.currentTarget.blur());
@@ -901,7 +901,7 @@ function wr({
901
901
  ) : a.value.trim() ? /* @__PURE__ */ s(
902
902
  "span",
903
903
  {
904
- className: kt === a.id ? "epochs-pdf-viewer__inline-text epochs-pdf-viewer__inline-text--selected" : "epochs-pdf-viewer__inline-text",
904
+ className: Pt === a.id ? "epochs-pdf-viewer__inline-text epochs-pdf-viewer__inline-text--selected" : "epochs-pdf-viewer__inline-text",
905
905
  style: {
906
906
  left: a.x * n,
907
907
  top: a.y * n,
@@ -913,7 +913,7 @@ function wr({
913
913
  tt == null || tt(a.id);
914
914
  return;
915
915
  }
916
- d === "text" && (lt == null || lt(a.id), X == null || X(a.id));
916
+ d === "text" && (ut == null || ut(a.id), G == null || G(a.id));
917
917
  },
918
918
  children: a.value
919
919
  },
@@ -922,27 +922,27 @@ function wr({
922
922
  return /* @__PURE__ */ s(
923
923
  "div",
924
924
  {
925
- ref: re,
925
+ ref: ne,
926
926
  "data-page-number": e,
927
927
  className: "epochs-pdf-viewer__page",
928
928
  children: /* @__PURE__ */ T(
929
929
  "div",
930
930
  {
931
- ref: st,
931
+ ref: it,
932
932
  className: `epochs-pdf-viewer__surface epochs-pdf-viewer__surface--tool-${d}`,
933
- onClick: Kt,
933
+ onClick: Zt,
934
934
  children: [
935
- /* @__PURE__ */ s("canvas", { ref: Ft, className: "epochs-pdf-viewer__canvas" }),
936
- /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__markup-layer", "aria-hidden": "true", children: f.map(
937
- (a) => a.kind === "redact" ? null : a.rects.map((y, v) => a.kind === "highlight" ? /* @__PURE__ */ s(
935
+ /* @__PURE__ */ s("canvas", { ref: yt, className: "epochs-pdf-viewer__canvas" }),
936
+ /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__markup-layer", "aria-hidden": "true", children: kt.map(
937
+ (a) => a.kind === "redact" ? null : a.rects.map((w, v) => a.kind === "highlight" ? /* @__PURE__ */ s(
938
938
  "div",
939
939
  {
940
940
  className: "epochs-pdf-viewer__markup epochs-pdf-viewer__markup--highlight",
941
941
  style: {
942
- left: y.x * n,
943
- top: y.y * n,
944
- width: y.w * n,
945
- height: y.h * n,
942
+ left: w.x * n,
943
+ top: w.y * n,
944
+ width: w.w * n,
945
+ height: w.h * n,
946
946
  background: a.color
947
947
  },
948
948
  onClick: (M) => {
@@ -955,9 +955,9 @@ function wr({
955
955
  {
956
956
  className: "epochs-pdf-viewer__markup epochs-pdf-viewer__markup--underline",
957
957
  style: {
958
- left: y.x * n,
959
- top: (y.y + y.h) * n - Math.max(2, n * 1.5),
960
- width: y.w * n,
958
+ left: w.x * n,
959
+ top: (w.y + w.h) * n - Math.max(2, n * 1.5),
960
+ width: w.w * n,
961
961
  height: Math.max(2, n * 1.5),
962
962
  background: a.color
963
963
  },
@@ -969,8 +969,8 @@ function wr({
969
969
  ))
970
970
  ) }),
971
971
  /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__signature-layer", children: [
972
- A.map((a) => {
973
- const y = a.type ?? "sign", v = Mt[a.id] ?? a.value ?? "", M = y === "date" || y === "text" ? !!v.trim() : F.some((D) => D.fieldId === a.id);
972
+ p.map((a) => {
973
+ const w = a.type ?? "sign", v = Mt[a.id] ?? a.value ?? "", M = w === "date" || w === "text" ? !!v.trim() : oe.some((D) => D.fieldId === a.id);
974
974
  return /* @__PURE__ */ s(
975
975
  "button",
976
976
  {
@@ -984,42 +984,42 @@ function wr({
984
984
  height: a.height * n
985
985
  },
986
986
  onClick: (D) => {
987
- if (D.stopPropagation(), Y == null || Y(a.id), y === "date" || y === "text") {
988
- I == null || I(null), J == null || J(y);
987
+ if (D.stopPropagation(), q == null || q(a.id), w === "date" || w === "text") {
988
+ C == null || C(null), J == null || J(w);
989
989
  return;
990
990
  }
991
- const P = F.find((R) => R.fieldId === a.id);
992
- I == null || I((P == null ? void 0 : P.id) ?? null), P ? H == null || H(P.id) : J == null || J(y);
991
+ const P = oe.find((F) => F.fieldId === a.id);
992
+ C == null || C((P == null ? void 0 : P.id) ?? null), P ? H == null || H(P.id) : J == null || J(w);
993
993
  },
994
- title: M ? "Completed field" : y === "date" ? "Date field" : y === "text" ? "Text field" : "Signature field",
995
- children: y === "date" || y === "text" ? v.trim() ? /* @__PURE__ */ s("span", { className: "epochs-pdf-viewer__signature-field-value", children: v }) : y === "date" ? /* @__PURE__ */ s("span", { children: "Date here" }) : /* @__PURE__ */ s("span", { children: a.placeholder ?? "Enter text" }) : M ? null : /* @__PURE__ */ s("span", { children: "Sign here" })
994
+ title: M ? "Completed field" : w === "date" ? "Date field" : w === "text" ? "Text field" : "Signature field",
995
+ children: w === "date" || w === "text" ? v.trim() ? /* @__PURE__ */ s("span", { className: "epochs-pdf-viewer__signature-field-value", children: v }) : w === "date" ? /* @__PURE__ */ s("span", { children: "Date here" }) : /* @__PURE__ */ s("span", { children: a.placeholder ?? "Enter text" }) : M ? null : /* @__PURE__ */ s("span", { children: "Sign here" })
996
996
  },
997
997
  a.id
998
998
  );
999
999
  }),
1000
- F.map((a) => /* @__PURE__ */ T(
1000
+ oe.map((a) => /* @__PURE__ */ T(
1001
1001
  "div",
1002
1002
  {
1003
- className: E === a.id ? "epochs-pdf-viewer__signature epochs-pdf-viewer__signature--selected" : "epochs-pdf-viewer__signature",
1003
+ className: A === a.id ? "epochs-pdf-viewer__signature epochs-pdf-viewer__signature--selected" : "epochs-pdf-viewer__signature",
1004
1004
  style: {
1005
1005
  left: a.x * n,
1006
1006
  top: a.y * n,
1007
1007
  width: a.width * n,
1008
1008
  height: a.height * n
1009
1009
  },
1010
- onPointerDown: (y) => {
1011
- if (y.stopPropagation(), y.preventDefault(), I == null || I(a.id), d === "erase" && !pt) {
1010
+ onPointerDown: (w) => {
1011
+ if (w.stopPropagation(), w.preventDefault(), C == null || C(a.id), d === "erase" && !pt) {
1012
1012
  S == null || S(a.id);
1013
1013
  return;
1014
1014
  }
1015
1015
  if (pt) {
1016
- Y == null || Y(a.fieldId ?? null), H == null || H(a.id);
1016
+ q == null || q(a.fieldId ?? null), H == null || H(a.id);
1017
1017
  return;
1018
1018
  }
1019
- const v = st.current;
1019
+ const v = it.current;
1020
1020
  if (!v) return;
1021
- const M = He(y.clientX, y.clientY, v, n);
1022
- Ct({
1021
+ const M = We(w.clientX, w.clientY, v, n);
1022
+ It({
1023
1023
  kind: "signature",
1024
1024
  id: a.id,
1025
1025
  offsetX: M.x - a.x,
@@ -1034,16 +1034,16 @@ function wr({
1034
1034
  className: "epochs-pdf-viewer__signature-edit",
1035
1035
  title: "Edit signature",
1036
1036
  "aria-label": "Edit signature",
1037
- onPointerDown: (y) => {
1038
- y.stopPropagation();
1037
+ onPointerDown: (w) => {
1038
+ w.stopPropagation();
1039
1039
  },
1040
- onClick: (y) => {
1041
- y.stopPropagation(), I == null || I(a.id), H == null || H(a.id);
1040
+ onClick: (w) => {
1041
+ w.stopPropagation(), C == null || C(a.id), H == null || H(a.id);
1042
1042
  },
1043
- children: /* @__PURE__ */ s(gr, { size: 12 })
1043
+ children: /* @__PURE__ */ s(mr, { size: 12 })
1044
1044
  }
1045
1045
  ),
1046
- pt ? null : /* @__PURE__ */ T(Ae, { children: [
1046
+ pt ? null : /* @__PURE__ */ T(je, { children: [
1047
1047
  /* @__PURE__ */ s(
1048
1048
  "button",
1049
1049
  {
@@ -1051,11 +1051,11 @@ function wr({
1051
1051
  className: "epochs-pdf-viewer__signature-duplicate",
1052
1052
  title: "Duplicate signature",
1053
1053
  "aria-label": "Duplicate signature",
1054
- onPointerDown: (y) => {
1055
- y.stopPropagation();
1054
+ onPointerDown: (w) => {
1055
+ w.stopPropagation();
1056
1056
  },
1057
- onClick: (y) => {
1058
- y.stopPropagation(), I == null || I(a.id), O == null || O(a.id);
1057
+ onClick: (w) => {
1058
+ w.stopPropagation(), C == null || C(a.id), W == null || W(a.id);
1059
1059
  },
1060
1060
  children: "⧉"
1061
1061
  }
@@ -1067,11 +1067,11 @@ function wr({
1067
1067
  className: "epochs-pdf-viewer__signature-remove",
1068
1068
  title: "Remove signature",
1069
1069
  "aria-label": "Remove signature",
1070
- onPointerDown: (y) => {
1071
- y.stopPropagation();
1070
+ onPointerDown: (w) => {
1071
+ w.stopPropagation();
1072
1072
  },
1073
- onClick: (y) => {
1074
- y.stopPropagation(), S == null || S(a.id);
1073
+ onClick: (w) => {
1074
+ w.stopPropagation(), S == null || S(a.id);
1075
1075
  },
1076
1076
  children: "×"
1077
1077
  }
@@ -1083,12 +1083,12 @@ function wr({
1083
1083
  {
1084
1084
  className: "epochs-pdf-viewer__signature-resize",
1085
1085
  title: "Resize",
1086
- onPointerDown: (y) => {
1087
- y.stopPropagation(), y.preventDefault(), I == null || I(a.id), Ct({
1086
+ onPointerDown: (w) => {
1087
+ w.stopPropagation(), w.preventDefault(), C == null || C(a.id), It({
1088
1088
  kind: "resize",
1089
1089
  id: a.id,
1090
- startX: y.clientX,
1091
- startY: y.clientY,
1090
+ startX: w.clientX,
1091
+ startY: w.clientY,
1092
1092
  startW: a.width,
1093
1093
  startH: a.height
1094
1094
  });
@@ -1101,26 +1101,26 @@ function wr({
1101
1101
  a.id
1102
1102
  ))
1103
1103
  ] }),
1104
- /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__text-layer-overlay", children: dt.map((a) => ne(a)) }),
1104
+ /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__text-layer-overlay", children: L.map((a) => ie(a)) }),
1105
1105
  /* @__PURE__ */ s(
1106
1106
  "div",
1107
1107
  {
1108
- ref: wt,
1108
+ ref: bt,
1109
1109
  className: "textLayer epochs-pdf-viewer__text-layer",
1110
- onClick: Yt
1110
+ onClick: Lt
1111
1111
  }
1112
1112
  ),
1113
- /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__redact-layer", "aria-hidden": "true", children: f.map(
1114
- (a) => a.kind === "redact" ? a.rects.map((y, v) => /* @__PURE__ */ s(
1113
+ /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__redact-layer", "aria-hidden": "true", children: kt.map(
1114
+ (a) => a.kind === "redact" ? a.rects.map((w, v) => /* @__PURE__ */ s(
1115
1115
  "div",
1116
1116
  {
1117
1117
  className: "epochs-pdf-viewer__markup epochs-pdf-viewer__markup--redact",
1118
1118
  style: {
1119
- left: y.x * n,
1120
- top: y.y * n,
1121
- width: y.w * n,
1122
- height: y.h * n,
1123
- background: a.color || Re
1119
+ left: w.x * n,
1120
+ top: w.y * n,
1121
+ width: w.w * n,
1122
+ height: w.h * n,
1123
+ background: a.color || He
1124
1124
  },
1125
1125
  onClick: (M) => {
1126
1126
  d === "erase" && (M.stopPropagation(), _ == null || _(a.id));
@@ -1135,7 +1135,7 @@ function wr({
1135
1135
  }
1136
1136
  );
1137
1137
  }
1138
- function yr({
1138
+ function br({
1139
1139
  pdfDoc: t,
1140
1140
  pageNumber: e,
1141
1141
  isActive: n,
@@ -1148,41 +1148,41 @@ function yr({
1148
1148
  texts: g = [],
1149
1149
  textFields: _ = []
1150
1150
  }) {
1151
- const w = xt(null);
1152
- return Tt(() => {
1153
- if (!t || !w.current) return;
1151
+ const y = xt(null);
1152
+ return Dt(() => {
1153
+ if (!t || !y.current) return;
1154
1154
  let b = !1;
1155
- const x = w.current, C = x.getContext("2d");
1156
- if (!C) return;
1155
+ const x = y.current, I = x.getContext("2d");
1156
+ if (!I) return;
1157
1157
  let S = null;
1158
1158
  return (async () => {
1159
1159
  try {
1160
- const O = await t.getPage(e);
1160
+ const W = await t.getPage(e);
1161
1161
  if (b) return;
1162
- const E = O.getViewport({ scale: 1, rotation: i }), I = o / E.width, et = O.getViewport({ scale: I, rotation: i });
1163
- x.width = Math.floor(et.width), x.height = Math.floor(et.height), S = O.render({ canvasContext: C, viewport: et }), await S.promise;
1164
- const at = d.filter((Z) => Z.pageNumber === e);
1165
- at.length > 0 && En(C, at, I);
1166
- const Y = u.filter((Z) => Z.pageNumber === e), pt = m.filter(
1167
- (Z) => Z.pageNumber === e
1162
+ const A = W.getViewport({ scale: 1, rotation: i }), C = o / A.width, nt = W.getViewport({ scale: C, rotation: i });
1163
+ x.width = Math.floor(nt.width), x.height = Math.floor(nt.height), S = W.render({ canvasContext: I, viewport: nt }), await S.promise;
1164
+ const at = d.filter((K) => K.pageNumber === e);
1165
+ at.length > 0 && jn(I, at, C);
1166
+ const q = u.filter((K) => K.pageNumber === e), pt = m.filter(
1167
+ (K) => K.pageNumber === e
1168
1168
  );
1169
- pt.length > 0 && zi(
1170
- C,
1169
+ pt.length > 0 && Si(
1170
+ I,
1171
1171
  pt,
1172
- new Set(Y.map((Z) => Z.fieldId).filter(Boolean)),
1173
- I
1174
- ), Y.length > 0 && await Un(C, Y, I);
1175
- const J = g.filter((Z) => Z.pageNumber === e), Mt = _.filter(
1176
- (Z) => Z.pageNumber === e
1172
+ new Set(q.map((K) => K.fieldId).filter(Boolean)),
1173
+ C
1174
+ ), q.length > 0 && await Bn(I, q, C);
1175
+ const J = g.filter((K) => K.pageNumber === e), Mt = _.filter(
1176
+ (K) => K.pageNumber === e
1177
1177
  );
1178
- Mt.length > 0 && tr(
1179
- C,
1178
+ Mt.length > 0 && er(
1179
+ I,
1180
1180
  Mt,
1181
1181
  new Set(
1182
- J.filter((Z) => Z.fieldId && Z.value.trim()).map((Z) => Z.fieldId)
1182
+ J.filter((K) => K.fieldId && K.value.trim()).map((K) => K.fieldId)
1183
1183
  ),
1184
- I
1185
- ), J.length > 0 && Hn(C, J, I);
1184
+ C
1185
+ ), J.length > 0 && Wn(I, J, C);
1186
1186
  } catch {
1187
1187
  }
1188
1188
  })(), () => {
@@ -1210,42 +1210,42 @@ function yr({
1210
1210
  className: n ? "epochs-pdf-viewer__thumb epochs-pdf-viewer__thumb--active" : "epochs-pdf-viewer__thumb",
1211
1211
  title: `Page ${e}`,
1212
1212
  children: [
1213
- /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__thumb-frame", children: /* @__PURE__ */ s("canvas", { ref: w }) }),
1213
+ /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__thumb-frame", children: /* @__PURE__ */ s("canvas", { ref: y }) }),
1214
1214
  /* @__PURE__ */ s("span", { className: "epochs-pdf-viewer__thumb-label", children: e })
1215
1215
  ]
1216
1216
  }
1217
1217
  );
1218
1218
  }
1219
- const br = /^(blob:|https?:|data:)/i;
1220
- let jn = !1;
1221
- function kn(t) {
1222
- ke.GlobalWorkerOptions.workerSrc = t, jn = !0;
1219
+ const _r = /^(blob:|https?:|data:)/i;
1220
+ let On = !1;
1221
+ function $n(t) {
1222
+ Ie.GlobalWorkerOptions.workerSrc = t, On = !0;
1223
1223
  }
1224
- function _r(t) {
1224
+ function vr(t) {
1225
1225
  if (t) {
1226
- kn(t);
1226
+ $n(t);
1227
1227
  return;
1228
1228
  }
1229
- jn || ke.GlobalWorkerOptions.workerSrc || kn(
1230
- `https://unpkg.com/pdfjs-dist@${ke.version}/build/pdf.worker.min.mjs`
1229
+ On || Ie.GlobalWorkerOptions.workerSrc || $n(
1230
+ `https://unpkg.com/pdfjs-dist@${Ie.version}/build/pdf.worker.min.mjs`
1231
1231
  );
1232
1232
  }
1233
- function vr(t, e, n = "") {
1233
+ function xr(t, e, n = "") {
1234
1234
  const i = e || t;
1235
1235
  if (!i) return "";
1236
- if (br.test(i)) return i;
1236
+ if (_r.test(i)) return i;
1237
1237
  const r = i.startsWith("/") ? i : `/${i}`;
1238
1238
  return n ? `${n.replace(/\/$/, "")}${r}` : r;
1239
1239
  }
1240
- async function xr(t, e) {
1240
+ async function Mr(t, e) {
1241
1241
  const n = await fetch(t, e);
1242
1242
  if (!n.ok)
1243
1243
  throw new Error(`Failed to fetch PDF (${n.status})`);
1244
1244
  return n.arrayBuffer();
1245
1245
  }
1246
- async function Nn(t, e) {
1246
+ async function In(t, e) {
1247
1247
  if (typeof t == "string")
1248
- return xr(t, e);
1248
+ return Mr(t, e);
1249
1249
  if (t instanceof ArrayBuffer) return t.slice(0);
1250
1250
  if (t instanceof Uint8Array) {
1251
1251
  const n = new Uint8Array(t.byteLength);
@@ -1253,7 +1253,7 @@ async function Nn(t, e) {
1253
1253
  }
1254
1254
  return t.arrayBuffer();
1255
1255
  }
1256
- async function Mr(t, e, n) {
1256
+ async function kr(t, e, n) {
1257
1257
  const {
1258
1258
  scale: i,
1259
1259
  rotation: r,
@@ -1262,35 +1262,35 @@ async function Mr(t, e, n) {
1262
1262
  texts: u = [],
1263
1263
  mimeType: m = "image/jpeg",
1264
1264
  quality: g = 0.92
1265
- } = n, _ = await t.getPage(e), w = _.getViewport({ scale: i, rotation: r }), b = _.getViewport({ scale: 1, rotation: r }), x = document.createElement("canvas"), C = x.getContext("2d", { alpha: !1 });
1266
- if (!C)
1265
+ } = n, _ = await t.getPage(e), y = _.getViewport({ scale: i, rotation: r }), b = _.getViewport({ scale: 1, rotation: r }), x = document.createElement("canvas"), I = x.getContext("2d", { alpha: !1 });
1266
+ if (!I)
1267
1267
  throw new Error("Could not create canvas context");
1268
- const S = Math.floor(w.width), H = Math.floor(w.height);
1269
- x.width = S, x.height = H, C.fillStyle = "#ffffff", C.fillRect(0, 0, S, H), await _.render({ canvasContext: C, viewport: w }).promise;
1270
- const O = o.filter((Y) => Y.pageNumber === e);
1271
- O.length > 0 && En(C, O, i);
1272
- const E = d.filter((Y) => Y.pageNumber === e);
1273
- E.length > 0 && await Un(C, E, i);
1274
- const I = u.filter((Y) => Y.pageNumber === e);
1275
- I.length > 0 && Hn(C, I, i);
1276
- const et = x.toDataURL(m, g), at = kr(et);
1268
+ const S = Math.floor(y.width), H = Math.floor(y.height);
1269
+ x.width = S, x.height = H, I.fillStyle = "#ffffff", I.fillRect(0, 0, S, H), await _.render({ canvasContext: I, viewport: y }).promise;
1270
+ const W = o.filter((q) => q.pageNumber === e);
1271
+ W.length > 0 && jn(I, W, i);
1272
+ const A = d.filter((q) => q.pageNumber === e);
1273
+ A.length > 0 && await Bn(I, A, i);
1274
+ const C = u.filter((q) => q.pageNumber === e);
1275
+ C.length > 0 && Wn(I, C, i);
1276
+ const nt = x.toDataURL(m, g), at = Nr(nt);
1277
1277
  return x.width = 0, x.height = 0, {
1278
1278
  pageNumber: e,
1279
1279
  width: S,
1280
1280
  height: H,
1281
1281
  pageWidth: b.width,
1282
1282
  pageHeight: b.height,
1283
- dataUrl: et,
1283
+ dataUrl: nt,
1284
1284
  jpegBytes: at
1285
1285
  };
1286
1286
  }
1287
- async function Pn(t, e) {
1287
+ async function Cn(t, e) {
1288
1288
  const n = [];
1289
1289
  for (let i = 1; i <= t.numPages; i += 1)
1290
- n.push(await Mr(t, i, e));
1290
+ n.push(await kr(t, i, e));
1291
1291
  return n;
1292
1292
  }
1293
- function kr(t) {
1293
+ function Nr(t) {
1294
1294
  const e = t.split(",")[1] ?? "", n = atob(e), i = new Uint8Array(n.length);
1295
1295
  for (let r = 0; r < n.length; r += 1)
1296
1296
  i[r] = n.charCodeAt(r);
@@ -1299,17 +1299,17 @@ function kr(t) {
1299
1299
  function Jt(t) {
1300
1300
  return new TextEncoder().encode(t);
1301
1301
  }
1302
- function $n(...t) {
1302
+ function Tn(...t) {
1303
1303
  const e = t.reduce((r, o) => r + o.byteLength, 0), n = new Uint8Array(e);
1304
1304
  let i = 0;
1305
1305
  for (const r of t)
1306
1306
  n.set(r, i), i += r.byteLength;
1307
1307
  return n;
1308
1308
  }
1309
- function Nr(t) {
1309
+ function Pr(t) {
1310
1310
  const e = [], n = (b) => (e.push(b), e.length), i = [];
1311
1311
  for (const b of t) {
1312
- const x = $n(
1312
+ const x = Tn(
1313
1313
  Jt(
1314
1314
  `<< /Type /XObject /Subtype /Image /Width ${b.width} /Height ${b.height} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length ${b.jpegBytes.byteLength} >>
1315
1315
  stream
@@ -1318,7 +1318,7 @@ stream
1318
1318
  b.jpegBytes,
1319
1319
  Jt(`
1320
1320
  endstream`)
1321
- ), C = n(x), S = `q
1321
+ ), I = n(x), S = `q
1322
1322
  ${b.pageWidth.toFixed(2)} 0 0 ${b.pageHeight.toFixed(2)} 0 0 cm
1323
1323
  /Im0 Do
1324
1324
  Q`, H = n(
@@ -1326,12 +1326,12 @@ Q`, H = n(
1326
1326
  stream
1327
1327
  ${S}
1328
1328
  endstream`)
1329
- ), O = n(
1329
+ ), W = n(
1330
1330
  Jt(
1331
- `<< /Type /Page /Parent __PAGES__ 0 R /MediaBox [0 0 ${b.pageWidth.toFixed(2)} ${b.pageHeight.toFixed(2)}] /Contents ${H} 0 R /Resources << /XObject << /Im0 ${C} 0 R >> >> >>`
1331
+ `<< /Type /Page /Parent __PAGES__ 0 R /MediaBox [0 0 ${b.pageWidth.toFixed(2)} ${b.pageHeight.toFixed(2)}] /Contents ${H} 0 R /Resources << /XObject << /Im0 ${I} 0 R >> >> >>`
1332
1332
  )
1333
1333
  );
1334
- i.push(O);
1334
+ i.push(W);
1335
1335
  }
1336
1336
  const r = i.map((b) => `${b} 0 R`).join(" "), o = n(
1337
1337
  Jt(`<< /Type /Pages /Kids [${r}] /Count ${i.length} >>`)
@@ -1348,50 +1348,60 @@ endstream`)
1348
1348
  for (let b = 0; b < e.length; b += 1) {
1349
1349
  m.push(g);
1350
1350
  const x = Jt(`${b + 1} 0 obj
1351
- `), C = Jt(`
1351
+ `), I = Jt(`
1352
1352
  endobj
1353
1353
  `);
1354
- u.push(x, e[b], C), g += x.byteLength + e[b].byteLength + C.byteLength;
1354
+ u.push(x, e[b], I), g += x.byteLength + e[b].byteLength + I.byteLength;
1355
1355
  }
1356
1356
  const _ = g;
1357
- let w = `xref
1357
+ let y = `xref
1358
1358
  0 ${e.length + 1}
1359
1359
  `;
1360
- w += `0000000000 65535 f
1360
+ y += `0000000000 65535 f
1361
1361
  `;
1362
1362
  for (let b = 1; b <= e.length; b += 1)
1363
- w += `${String(m[b]).padStart(10, "0")} 00000 n
1363
+ y += `${String(m[b]).padStart(10, "0")} 00000 n
1364
1364
  `;
1365
- return w += `trailer
1365
+ return y += `trailer
1366
1366
  << /Size ${e.length + 1} /Root ${d} 0 R >>
1367
- `, w += `startxref
1367
+ `, y += `startxref
1368
1368
  ${_}
1369
- %%EOF`, u.push(Jt(w)), $n(...u);
1369
+ %%EOF`, u.push(Jt(y)), Tn(...u);
1370
1370
  }
1371
- function sn(t, e) {
1371
+ function hn(t, e) {
1372
1372
  const n = URL.createObjectURL(t), i = document.createElement("a");
1373
1373
  i.href = n, i.download = e, i.click(), URL.revokeObjectURL(n);
1374
1374
  }
1375
- const je = [
1376
- { id: "cursive", label: "Cursive", family: "cursive" },
1377
- { id: "serif", label: "Serif", family: "serif" },
1378
- { id: "sans", label: "Sans", family: "sans-serif" },
1379
- { id: "mono", label: "Mono", family: "monospace" },
1380
- { id: "fantasy", label: "Fantasy", family: "fantasy" }
1381
- ];
1382
- function Pr(t) {
1383
- return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
1384
- }
1385
- function $r(t) {
1386
- const e = new TextEncoder().encode(t);
1387
- let n = "";
1388
- const i = 32768;
1389
- for (let r = 0; r < e.length; r += i)
1390
- n += String.fromCharCode(...e.subarray(r, r + i));
1391
- return `data:image/svg+xml;base64,${btoa(n)}`;
1375
+ const Ue = [
1376
+ { id: "dancing-script", label: "Dancing Script", family: "Dancing Script" },
1377
+ { id: "great-vibes", label: "Great Vibes", family: "Great Vibes" },
1378
+ { id: "pacifico", label: "Pacifico", family: "Pacifico" },
1379
+ { id: "satisfy", label: "Satisfy", family: "Satisfy" },
1380
+ { id: "allura", label: "Allura", family: "Allura" }
1381
+ ], $r = "https://fonts.googleapis.com/css2?family=Allura&family=Dancing+Script:wght@500;600&family=Great+Vibes&family=Pacifico&family=Satisfy&display=swap";
1382
+ let Oe = null;
1383
+ function Ir() {
1384
+ return typeof document > "u" ? Promise.resolve() : Oe || (Oe = new Promise((t) => {
1385
+ var i;
1386
+ if (!document.querySelector(
1387
+ 'link[data-epochs-signature-fonts="true"]'
1388
+ )) {
1389
+ const r = document.createElement("link");
1390
+ r.rel = "stylesheet", r.href = $r, r.dataset.epochsSignatureFonts = "true", document.head.appendChild(r);
1391
+ }
1392
+ const n = () => Promise.all(
1393
+ Ue.map(
1394
+ (r) => document.fonts.load(`48px "${r.family}"`)
1395
+ )
1396
+ ).then(() => {
1397
+ });
1398
+ (i = document.fonts) != null && i.ready ? document.fonts.ready.then(n).then(t).catch(() => t()) : window.setTimeout(() => {
1399
+ n().then(t).catch(() => t());
1400
+ }, 300);
1401
+ }), Oe);
1392
1402
  }
1393
- function Cn(t) {
1394
- return t === "initials" ? 64 : 48;
1403
+ function Dn(t, e) {
1404
+ return t === "initials" ? 72 : e === "Great Vibes" || e === "Allura" ? 56 : e === "Pacifico" ? 44 : 48;
1395
1405
  }
1396
1406
  function Cr({
1397
1407
  open: t,
@@ -1406,150 +1416,163 @@ function Cr({
1406
1416
  rememberedByType: g,
1407
1417
  onRememberFill: _
1408
1418
  }) {
1409
- const w = xt(null), b = xt(!1), x = xt(null), C = xt([]), S = xt([]), H = xt(null), O = r ?? "sign", [E, I] = z(O), [et, at] = z(""), [Y, pt] = z(""), [J, Mt] = z("draw"), [Z, Lt] = z(""), [_t, U] = z(""), [ct, ft] = z(!1), [gt, tt] = z("signature"), [kt, lt] = z("#111827"), [te, me] = z("cursive"), [St, Ut] = z(!1), Dt = je.find((f) => f.id === te) ?? je[0], X = gt === "initials" ? _t.trim() : Z.trim(), qt = X || (gt === "initials" ? "AB" : "Signature");
1410
- if (Tt(() => {
1411
- var A, dt;
1419
+ const y = xt(null), b = xt(!1), x = xt(null), I = xt([]), S = xt([]), H = xt(null), W = r ?? "sign", [A, C] = O(W), [nt, at] = O(""), [q, pt] = O(""), [J, Mt] = O("draw"), [K, Et] = O(""), [vt, E] = O(""), [ct, ht] = O(!1), [gt, tt] = O("signature"), [Pt, ut] = O("#111827"), [te, ye] = O("dancing-script"), [Vt, qt] = O(!1), [Kt, G] = O(!1), $t = Ue.find((p) => p.id === te) ?? Ue[0], yt = gt === "initials" ? vt.trim() : K.trim(), bt = yt || (gt === "initials" ? "AB" : "Signature");
1420
+ if (Dt(() => {
1421
+ var U, rt;
1412
1422
  if (!t) return;
1413
- if (I(O), O === "date") {
1423
+ if (C(W), W === "date") {
1414
1424
  at(
1415
- u || ((A = g == null ? void 0 : g.date) == null ? void 0 : A.value) || (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)
1425
+ u || ((U = g == null ? void 0 : g.date) == null ? void 0 : U.value) || (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)
1416
1426
  );
1417
1427
  return;
1418
1428
  }
1419
- if (O === "text") {
1420
- pt(u || ((dt = g == null ? void 0 : g.text) == null ? void 0 : dt.value) || "");
1429
+ if (W === "text") {
1430
+ pt(u || ((rt = g == null ? void 0 : g.text) == null ? void 0 : rt.value) || "");
1421
1431
  return;
1422
1432
  }
1423
- const f = g == null ? void 0 : g.sign;
1424
- if (!f) {
1425
- Mt("draw"), Lt(""), U(""), ft(!1), tt("signature"), lt("#111827"), me("cursive"), H.current = null, Ut(!1);
1433
+ const p = g == null ? void 0 : g.sign;
1434
+ if (!p) {
1435
+ Mt("draw"), Et(""), E(""), ht(!1), tt("signature"), ut("#111827"), ye("dancing-script"), H.current = null, G(!1);
1426
1436
  return;
1427
1437
  }
1428
- Mt(f.mode), Lt(f.typedName ?? ""), U(f.typedInitials ?? ""), ft(!!f.typedInitials), tt(f.typeKind ?? "signature"), lt(f.inkColor ?? "#111827");
1429
- const F = je.find((ht) => ht.id === f.fontId);
1430
- F && me(F.id), f.mode === "draw" ? (H.current = {
1431
- imageDataUrl: f.imageDataUrl,
1432
- width: f.width,
1433
- height: f.height
1434
- }, Ut(!0)) : (H.current = null, Ut(!1));
1435
- }, [t, O, g, u]), Tt(() => {
1436
- if (!t || E !== "sign") return;
1437
- const f = w.current;
1438
- if (!f) return;
1439
- const F = f.getContext("2d");
1440
- if (!F || (f.width = 560, f.height = 200, F.fillStyle = "#ffffff", F.fillRect(0, 0, f.width, f.height), F.lineCap = "round", F.lineJoin = "round", F.strokeStyle = kt, F.lineWidth = 2.5, x.current = null, b.current = !1, C.current = [], S.current = [], J !== "draw")) return;
1441
- const A = H.current;
1442
- if (!(A != null && A.imageDataUrl)) return;
1443
- const dt = new Image();
1444
- dt.onload = () => {
1445
- const ht = Math.min(
1446
- f.width / Math.max(1, A.width),
1447
- f.height / Math.max(1, A.height),
1438
+ Mt(p.mode), Et(p.typedName ?? ""), E(p.typedInitials ?? ""), ht(!!p.typedInitials), tt(p.typeKind ?? "signature"), ut(p.inkColor ?? "#111827");
1439
+ const L = Ue.find((Lt) => Lt.id === p.fontId);
1440
+ L && ye(L.id), p.mode === "draw" ? (H.current = {
1441
+ imageDataUrl: p.imageDataUrl,
1442
+ width: p.width,
1443
+ height: p.height
1444
+ }, G(!0)) : (H.current = null, G(!1));
1445
+ }, [t, W, g, u]), Dt(() => {
1446
+ if (!t || A !== "sign") return;
1447
+ const p = y.current;
1448
+ if (!p) return;
1449
+ const L = p.getContext("2d");
1450
+ if (!L || (p.width = 560, p.height = 200, L.fillStyle = "#ffffff", L.fillRect(0, 0, p.width, p.height), L.lineCap = "round", L.lineJoin = "round", L.strokeStyle = Pt, L.lineWidth = 2.5, x.current = null, b.current = !1, I.current = [], S.current = [], J !== "draw")) return;
1451
+ const U = H.current;
1452
+ if (!(U != null && U.imageDataUrl)) return;
1453
+ const rt = new Image();
1454
+ rt.onload = () => {
1455
+ const Lt = Math.min(
1456
+ p.width / Math.max(1, U.width),
1457
+ p.height / Math.max(1, U.height),
1448
1458
  1
1449
- ), Vt = A.width * ht, Yt = A.height * ht;
1450
- F.drawImage(dt, (f.width - Vt) / 2, (f.height - Yt) / 2, Vt, Yt);
1451
- }, dt.src = A.imageDataUrl;
1452
- }, [t, E, J]), Tt(() => {
1453
- const f = w.current, F = f == null ? void 0 : f.getContext("2d");
1454
- F && (F.strokeStyle = kt, F.fillStyle = kt);
1455
- }, [kt]), Tt(() => {
1459
+ ), Zt = U.width * Lt, ie = U.height * Lt;
1460
+ L.drawImage(rt, (p.width - Zt) / 2, (p.height - ie) / 2, Zt, ie);
1461
+ }, rt.src = U.imageDataUrl;
1462
+ }, [t, A, J]), Dt(() => {
1463
+ if (!t) return;
1464
+ let p = !1;
1465
+ return qt(!1), Ir().then(() => {
1466
+ p || qt(!0);
1467
+ }), () => {
1468
+ p = !0;
1469
+ };
1470
+ }, [t]), Dt(() => {
1471
+ const p = y.current, L = p == null ? void 0 : p.getContext("2d");
1472
+ L && (L.strokeStyle = Pt, L.fillStyle = Pt);
1473
+ }, [Pt]), Dt(() => {
1456
1474
  if (!t || J !== "type") return;
1457
- const f = w.current, F = f == null ? void 0 : f.getContext("2d");
1458
- if (!f || !F || (F.clearRect(0, 0, f.width, f.height), !X)) return;
1459
- const A = Cn(gt);
1460
- F.fillStyle = kt, F.textAlign = "center", F.textBaseline = "middle", F.font = `${A}px ${Dt.family}`, F.fillText(X, f.width / 2, f.height / 2);
1475
+ const p = y.current, L = p == null ? void 0 : p.getContext("2d");
1476
+ if (!p || !L || (L.fillStyle = "#ffffff", L.fillRect(0, 0, p.width, p.height), !yt)) return;
1477
+ const U = Dn(gt, $t.family);
1478
+ L.fillStyle = Pt, L.textAlign = "center", L.textBaseline = "middle", L.font = `${U}px "${$t.family}", cursive`, L.fillText(yt, p.width / 2, p.height / 2);
1461
1479
  }, [
1462
- X,
1480
+ yt,
1463
1481
  gt,
1464
1482
  J,
1465
- kt,
1483
+ Pt,
1466
1484
  t,
1467
- Dt
1485
+ $t,
1486
+ Vt
1468
1487
  ]), !t) return null;
1469
- const Ft = (f) => {
1470
- const F = w.current, A = F.getBoundingClientRect();
1488
+ const it = (p) => {
1489
+ const L = y.current, U = L.getBoundingClientRect();
1471
1490
  return {
1472
- x: (f.clientX - A.left) / A.width * F.width,
1473
- y: (f.clientY - A.top) / A.height * F.height
1491
+ x: (p.clientX - U.left) / U.width * L.width,
1492
+ y: (p.clientY - U.top) / U.height * L.height
1474
1493
  };
1475
- }, wt = (f) => {
1494
+ }, Wt = (p) => {
1476
1495
  if (J !== "draw") return;
1477
1496
  if (H.current) {
1478
- H.current = null, Ut(!1);
1479
- const A = w.current, dt = A == null ? void 0 : A.getContext("2d");
1480
- A && dt && (dt.fillStyle = "#ffffff", dt.fillRect(0, 0, A.width, A.height), dt.strokeStyle = kt, dt.lineWidth = 2.5, dt.lineCap = "round", dt.lineJoin = "round"), C.current = [];
1497
+ H.current = null, G(!1);
1498
+ const U = y.current, rt = U == null ? void 0 : U.getContext("2d");
1499
+ U && rt && (rt.fillStyle = "#ffffff", rt.fillRect(0, 0, U.width, U.height), rt.strokeStyle = Pt, rt.lineWidth = 2.5, rt.lineCap = "round", rt.lineJoin = "round"), I.current = [];
1481
1500
  }
1482
- f.currentTarget.setPointerCapture(f.pointerId), b.current = !0;
1483
- const F = Ft(f);
1484
- x.current = F, S.current = [F];
1485
- }, st = (f) => {
1501
+ p.currentTarget.setPointerCapture(p.pointerId), b.current = !0;
1502
+ const L = it(p);
1503
+ x.current = L, S.current = [L];
1504
+ }, st = (p) => {
1486
1505
  if (!b.current || J !== "draw") return;
1487
- const F = w.current, A = F == null ? void 0 : F.getContext("2d"), dt = x.current;
1488
- if (!A || !dt) return;
1489
- const ht = Ft(f);
1490
- A.beginPath(), A.moveTo(dt.x, dt.y), A.lineTo(ht.x, ht.y), A.stroke(), x.current = ht, S.current.push(ht);
1491
- }, Ht = () => {
1492
- S.current.length > 1 && C.current.push([...S.current]), S.current = [], b.current = !1, x.current = null;
1493
- }, nt = () => {
1494
- const f = w.current, F = f == null ? void 0 : f.getContext("2d");
1495
- !f || !F || (F.fillStyle = "#ffffff", F.fillRect(0, 0, f.width, f.height), C.current = [], S.current = [], H.current = null, Ut(!1), Lt(""), U(""), ft(!1));
1496
- }, yt = (f) => {
1497
- Lt(f), ct || U(Ir(f));
1498
- }, Ct = () => {
1506
+ const L = y.current, U = L == null ? void 0 : L.getContext("2d"), rt = x.current;
1507
+ if (!U || !rt) return;
1508
+ const Lt = it(p);
1509
+ U.beginPath(), U.moveTo(rt.x, rt.y), U.lineTo(Lt.x, Lt.y), U.stroke(), x.current = Lt, S.current.push(Lt);
1510
+ }, mt = () => {
1511
+ S.current.length > 1 && I.current.push([...S.current]), S.current = [], b.current = !1, x.current = null;
1512
+ }, It = () => {
1513
+ const p = y.current, L = p == null ? void 0 : p.getContext("2d");
1514
+ !p || !L || (L.fillStyle = "#ffffff", L.fillRect(0, 0, p.width, p.height), I.current = [], S.current = [], H.current = null, G(!1), Et(""), E(""), ht(!1));
1515
+ }, ee = (p) => {
1516
+ Et(p), ct || E(Tr(p));
1517
+ }, dt = () => {
1499
1518
  if (J === "draw") {
1500
- const R = C.current, k = H.current;
1501
- if (R.length === 0) {
1502
- if (!k) return;
1519
+ const X = I.current, et = H.current;
1520
+ if (X.length === 0) {
1521
+ if (!et) return;
1503
1522
  _ == null || _("sign", {
1504
1523
  mode: "draw",
1505
- imageDataUrl: k.imageDataUrl,
1506
- width: k.width,
1507
- height: k.height,
1508
- inkColor: kt
1509
- }), n(k.imageDataUrl, k.width, k.height);
1524
+ imageDataUrl: et.imageDataUrl,
1525
+ width: et.width,
1526
+ height: et.height,
1527
+ inkColor: Pt
1528
+ }), n(et.imageDataUrl, et.width, et.height);
1510
1529
  return;
1511
1530
  }
1512
- let B = 1 / 0, G = 1 / 0, L = -1 / 0, rt = -1 / 0;
1513
- for (const se of R)
1514
- for (const Et of se)
1515
- Et.x < B && (B = Et.x), Et.y < G && (G = Et.y), Et.x > L && (L = Et.x), Et.y > rt && (rt = Et.y);
1516
- const q = 8;
1517
- B = Math.max(0, B - q), G = Math.max(0, G - q), L += q, rt += q;
1518
- const ut = L - B, vt = rt - G, Xt = R.map((se) => "M" + se.map((le) => ({ x: le.x - B, y: le.y - G })).map((le) => `${le.x.toFixed(1)},${le.y.toFixed(1)}`).join("L")).join(" "), Nt = Math.max(1, (m == null ? void 0 : m.width) ?? ut), Rt = Math.max(1, (m == null ? void 0 : m.height) ?? vt), At = Math.min(Nt / ut, Rt / vt), Zt = ut * At, It = vt * At, bt = (Nt - Zt) / 2, Qt = (Rt - It) / 2, oe = `<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 ${Nt} ${Rt}"><g transform="translate(${bt.toFixed(2)} ${Qt.toFixed(2)}) scale(${At.toFixed(4)})"><path d="${Xt}" fill="none" stroke="${kt}" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/></g></svg>`, Gt = `data:image/svg+xml;base64,${btoa(oe)}`;
1531
+ let ft = 1 / 0, Ft = 1 / 0, Rt = -1 / 0, Ht = -1 / 0;
1532
+ for (const _e of X)
1533
+ for (const Qt of _e)
1534
+ Qt.x < ft && (ft = Qt.x), Qt.y < Ft && (Ft = Qt.y), Qt.x > Rt && (Rt = Qt.x), Qt.y > Ht && (Ht = Qt.y);
1535
+ const At = 8;
1536
+ ft = Math.max(0, ft - At), Ft = Math.max(0, Ft - At), Rt += At, Ht += At;
1537
+ const St = Rt - ft, Nt = Ht - Ft, _t = X.map((_e) => "M" + _e.map((ae) => ({ x: ae.x - ft, y: ae.y - Ft })).map((ae) => `${ae.x.toFixed(1)},${ae.y.toFixed(1)}`).join("L")).join(" "), Ut = Math.max(1, (m == null ? void 0 : m.width) ?? St), Yt = Math.max(1, (m == null ? void 0 : m.height) ?? Nt), Gt = Math.min(Ut / St, Yt / Nt), be = St * Gt, se = Nt * Gt, Ve = (Ut - be) / 2, de = (Yt - se) / 2, qe = `<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 ${Ut} ${Yt}"><g transform="translate(${Ve.toFixed(2)} ${de.toFixed(2)}) scale(${Gt.toFixed(4)})"><path d="${_t}" fill="none" stroke="${Pt}" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/></g></svg>`, he = `data:image/svg+xml;base64,${btoa(qe)}`;
1519
1538
  _ == null || _("sign", {
1520
1539
  mode: "draw",
1521
- imageDataUrl: Gt,
1522
- width: Nt,
1523
- height: Rt,
1524
- inkColor: kt
1525
- }), n(Gt, Nt, Rt);
1540
+ imageDataUrl: he,
1541
+ width: Ut,
1542
+ height: Yt,
1543
+ inkColor: Pt
1544
+ }), n(he, Ut, Yt);
1526
1545
  return;
1527
1546
  }
1528
- if (!X) return;
1529
- const f = Cn(gt), A = document.createElement("canvas").getContext("2d");
1530
- A.font = `${f}px ${Dt.family}`;
1531
- const dt = A.measureText(X), ht = 8, Vt = Math.ceil(dt.width) + ht * 2, Yt = f + ht * 2, Kt = Math.max(1, (m == null ? void 0 : m.width) ?? Vt), ne = Math.max(1, (m == null ? void 0 : m.height) ?? Yt), a = Math.min(Kt / Vt, ne / Yt), y = Math.max(8, f * a), v = (Kt / 2).toFixed(1), M = (ne / 2).toFixed(1), D = `<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 ${Kt} ${ne}"><text x="${v}" y="${M}" text-anchor="middle" dominant-baseline="central" alignment-baseline="middle" font-family="${Dt.family}" font-size="${y.toFixed(1)}" fill="${kt}">${Pr(X)}</text></svg>`, P = $r(D);
1547
+ if (!yt) return;
1548
+ const p = 3, L = Dn(gt, $t.family), rt = document.createElement("canvas").getContext("2d");
1549
+ rt.font = `${L}px "${$t.family}", cursive`;
1550
+ const Lt = rt.measureText(yt), Zt = 8, ie = Math.ceil(Lt.width) + Zt * 2, a = L + Zt * 2, w = Math.max(1, (m == null ? void 0 : m.width) ?? ie), v = Math.max(1, (m == null ? void 0 : m.height) ?? a), M = Math.min(w / ie, v / a), D = Math.max(8, L * M), P = Math.max(1, Math.round(w * p)), F = Math.max(1, Math.round(v * p)), N = document.createElement("canvas");
1551
+ N.width = P, N.height = F;
1552
+ const j = N.getContext("2d");
1553
+ j.fillStyle = "#ffffff", j.fillRect(0, 0, P, F), j.font = `${D * p}px "${$t.family}", cursive`, j.fillStyle = Pt, j.textAlign = "center", j.textBaseline = "middle", j.fillText(yt, P / 2, F / 2);
1554
+ const Z = N.toDataURL("image/png"), R = `<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 ${w} ${v}"><image href="${Z}" width="${w}" height="${v}" preserveAspectRatio="xMidYMid meet"/></svg>`, lt = `data:image/svg+xml;base64,${btoa(R)}`;
1532
1555
  _ == null || _("sign", {
1533
1556
  mode: "type",
1534
- imageDataUrl: P,
1535
- width: Kt,
1536
- height: ne,
1537
- typedName: Z,
1538
- typedInitials: _t,
1557
+ imageDataUrl: lt,
1558
+ width: w,
1559
+ height: v,
1560
+ typedName: K,
1561
+ typedInitials: vt,
1539
1562
  fontId: te,
1540
- inkColor: kt,
1563
+ inkColor: Pt,
1541
1564
  typeKind: gt
1542
- }), n(P, Kt, ne);
1543
- }, ee = () => {
1544
- if (E !== "date" && E !== "text") return;
1545
- const f = E === "date" ? et : Y.trim();
1546
- f && (_ == null || _(E, { value: f }), i == null || i(f, E));
1547
- }, it = E === "sign";
1565
+ }), n(lt, w, v);
1566
+ }, ne = () => {
1567
+ if (A !== "date" && A !== "text") return;
1568
+ const p = A === "date" ? nt : q.trim();
1569
+ p && (_ == null || _(A, { value: p }), i == null || i(p, A));
1570
+ }, kt = A === "sign";
1548
1571
  return /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__modal", role: "dialog", "aria-modal": "true", children: [
1549
1572
  /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__modal-backdrop", onClick: e }),
1550
1573
  /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__modal-card", children: [
1551
1574
  /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__modal-header", children: [
1552
- /* @__PURE__ */ s("h3", { children: E === "date" ? "Pick a date" : E === "text" ? "Enter text" : "Create e-signature" }),
1575
+ /* @__PURE__ */ s("h3", { children: A === "date" ? "Pick a date" : A === "text" ? "Enter text" : "Create e-signature" }),
1553
1576
  /* @__PURE__ */ s(
1554
1577
  "button",
1555
1578
  {
@@ -1561,19 +1584,19 @@ function Cr({
1561
1584
  }
1562
1585
  )
1563
1586
  ] }),
1564
- o && !r ? /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__field-type-tabs", role: "tablist", children: ["sign", "date", "text"].map((f) => /* @__PURE__ */ s(
1587
+ o && !r ? /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__field-type-tabs", role: "tablist", children: ["sign", "date", "text"].map((p) => /* @__PURE__ */ s(
1565
1588
  "button",
1566
1589
  {
1567
1590
  type: "button",
1568
1591
  role: "tab",
1569
- "aria-selected": E === f,
1570
- className: E === f ? "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text epochs-pdf-viewer__btn--active" : "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
1571
- onClick: () => I(f),
1572
- children: f === "sign" ? "Sign" : f === "date" ? "Date" : "Text"
1592
+ "aria-selected": A === p,
1593
+ className: A === p ? "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text epochs-pdf-viewer__btn--active" : "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
1594
+ onClick: () => C(p),
1595
+ children: p === "sign" ? "Sign" : p === "date" ? "Date" : "Text"
1573
1596
  },
1574
- f
1597
+ p
1575
1598
  )) }) : null,
1576
- it ? /* @__PURE__ */ T(Ae, { children: [
1599
+ kt ? /* @__PURE__ */ T(je, { children: [
1577
1600
  /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__sign-modes", children: [
1578
1601
  /* @__PURE__ */ s(
1579
1602
  "button",
@@ -1581,7 +1604,7 @@ function Cr({
1581
1604
  type: "button",
1582
1605
  className: J === "draw" ? "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text epochs-pdf-viewer__btn--active" : "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
1583
1606
  onClick: () => {
1584
- Mt("draw"), nt();
1607
+ Mt("draw"), It();
1585
1608
  },
1586
1609
  children: "Draw"
1587
1610
  }
@@ -1594,37 +1617,26 @@ function Cr({
1594
1617
  onClick: () => Mt("type"),
1595
1618
  children: "Type"
1596
1619
  }
1597
- ),
1598
- /* @__PURE__ */ T("label", { className: "epochs-pdf-viewer__sign-ink", children: [
1599
- "Ink",
1600
- /* @__PURE__ */ s(
1601
- "input",
1602
- {
1603
- type: "color",
1604
- value: kt,
1605
- onChange: (f) => lt(f.target.value)
1606
- }
1607
- )
1608
- ] })
1620
+ )
1609
1621
  ] }),
1610
- J === "type" ? /* @__PURE__ */ T(Ae, { children: [
1622
+ J === "type" ? /* @__PURE__ */ T(je, { children: [
1611
1623
  /* @__PURE__ */ s(
1612
1624
  "div",
1613
1625
  {
1614
1626
  className: "epochs-pdf-viewer__sign-fonts",
1615
1627
  role: "group",
1616
1628
  "aria-label": "Handwriting style",
1617
- children: je.map((f) => /* @__PURE__ */ s(
1629
+ children: Ue.map((p) => /* @__PURE__ */ s(
1618
1630
  "button",
1619
1631
  {
1620
1632
  type: "button",
1621
- className: te === f.id ? "epochs-pdf-viewer__sign-font epochs-pdf-viewer__sign-font--active" : "epochs-pdf-viewer__sign-font",
1622
- style: { fontFamily: f.family },
1623
- onClick: () => me(f.id),
1624
- title: f.label,
1625
- children: qt
1633
+ className: te === p.id ? "epochs-pdf-viewer__sign-font epochs-pdf-viewer__sign-font--active" : "epochs-pdf-viewer__sign-font",
1634
+ style: { fontFamily: `"${p.family}", cursive` },
1635
+ onClick: () => ye(p.id),
1636
+ title: p.label,
1637
+ children: bt
1626
1638
  },
1627
- f.id
1639
+ p.id
1628
1640
  ))
1629
1641
  }
1630
1642
  ),
@@ -1636,11 +1648,11 @@ function Cr({
1636
1648
  {
1637
1649
  className: "epochs-pdf-viewer__sign-type-input",
1638
1650
  type: "text",
1639
- value: Z,
1640
- onChange: (f) => yt(f.target.value),
1651
+ value: K,
1652
+ onChange: (p) => ee(p.target.value),
1641
1653
  onFocus: () => tt("signature"),
1642
1654
  placeholder: "Type your full name",
1643
- style: { fontFamily: Dt.family },
1655
+ style: { fontFamily: `"${$t.family}", cursive` },
1644
1656
  autoFocus: !0
1645
1657
  }
1646
1658
  )
@@ -1652,14 +1664,14 @@ function Cr({
1652
1664
  {
1653
1665
  className: "epochs-pdf-viewer__sign-type-input",
1654
1666
  type: "text",
1655
- value: _t,
1656
- onChange: (f) => {
1657
- ft(!0), U(f.target.value.toUpperCase());
1667
+ value: vt,
1668
+ onChange: (p) => {
1669
+ ht(!0), E(p.target.value.toUpperCase());
1658
1670
  },
1659
1671
  onFocus: () => tt("initials"),
1660
1672
  placeholder: "e.g. JD",
1661
1673
  maxLength: 4,
1662
- style: { fontFamily: Dt.family }
1674
+ style: { fontFamily: `"${$t.family}", cursive` }
1663
1675
  }
1664
1676
  )
1665
1677
  ] })
@@ -1692,27 +1704,27 @@ function Cr({
1692
1704
  ]
1693
1705
  }
1694
1706
  )
1695
- ] }) : /* @__PURE__ */ s("p", { className: "epochs-pdf-viewer__sign-hint", children: St ? "Previous signature loaded — submit to reuse, or draw a new one" : "Draw your signature below" }),
1707
+ ] }) : /* @__PURE__ */ s("p", { className: "epochs-pdf-viewer__sign-hint", children: Kt ? "Previous signature loaded — submit to reuse, or draw a new one" : "Draw your signature below" }),
1696
1708
  /* @__PURE__ */ s(
1697
1709
  "canvas",
1698
1710
  {
1699
- ref: w,
1711
+ ref: y,
1700
1712
  className: J === "draw" ? "epochs-pdf-viewer__sign-canvas" : "epochs-pdf-viewer__sign-canvas epochs-pdf-viewer__sign-canvas--preview",
1701
- onPointerDown: wt,
1713
+ onPointerDown: Wt,
1702
1714
  onPointerMove: st,
1703
- onPointerUp: Ht,
1704
- onPointerLeave: Ht
1715
+ onPointerUp: mt,
1716
+ onPointerLeave: mt
1705
1717
  }
1706
1718
  )
1707
- ] }) : E === "date" ? /* @__PURE__ */ T("label", { className: "epochs-pdf-viewer__sign-type-field", style: { padding: "1rem" }, children: [
1719
+ ] }) : A === "date" ? /* @__PURE__ */ T("label", { className: "epochs-pdf-viewer__sign-type-field", style: { padding: "1rem" }, children: [
1708
1720
  /* @__PURE__ */ s("span", { children: "Date" }),
1709
1721
  /* @__PURE__ */ s(
1710
1722
  "input",
1711
1723
  {
1712
1724
  className: "epochs-pdf-viewer__sign-type-input",
1713
1725
  type: "date",
1714
- value: et,
1715
- onChange: (f) => at(f.target.value),
1726
+ value: nt,
1727
+ onChange: (p) => at(p.target.value),
1716
1728
  autoFocus: !0
1717
1729
  }
1718
1730
  )
@@ -1723,20 +1735,20 @@ function Cr({
1723
1735
  {
1724
1736
  className: "epochs-pdf-viewer__sign-type-input",
1725
1737
  type: "text",
1726
- value: Y,
1727
- onChange: (f) => pt(f.target.value),
1738
+ value: q,
1739
+ onChange: (p) => pt(p.target.value),
1728
1740
  placeholder: d ?? "Enter text",
1729
1741
  autoFocus: !0
1730
1742
  }
1731
1743
  )
1732
1744
  ] }),
1733
1745
  /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__modal-actions", children: [
1734
- it ? /* @__PURE__ */ s(
1746
+ kt ? /* @__PURE__ */ s(
1735
1747
  "button",
1736
1748
  {
1737
1749
  type: "button",
1738
1750
  className: "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
1739
- onClick: nt,
1751
+ onClick: It,
1740
1752
  children: "Clear"
1741
1753
  }
1742
1754
  ) : null,
@@ -1754,66 +1766,66 @@ function Cr({
1754
1766
  {
1755
1767
  type: "button",
1756
1768
  className: "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text epochs-pdf-viewer__btn--primary",
1757
- onClick: it ? Ct : ee,
1758
- disabled: E === "date" ? !et : E === "text" ? !Y.trim() : !1,
1759
- children: it ? "Use signature" : "Place on page"
1769
+ onClick: kt ? dt : ne,
1770
+ disabled: A === "date" ? !nt : A === "text" ? !q.trim() : !1,
1771
+ children: kt ? "Use signature" : "Place on page"
1760
1772
  }
1761
1773
  )
1762
1774
  ] })
1763
1775
  ] })
1764
1776
  ] });
1765
1777
  }
1766
- function Ir(t) {
1778
+ function Tr(t) {
1767
1779
  const e = t.trim().split(/\s+/).filter(Boolean);
1768
1780
  return e.length === 0 ? "" : e.length === 1 ? e[0].slice(0, 2).toUpperCase() : e.slice(0, 3).map((n) => {
1769
1781
  var i;
1770
1782
  return ((i = n[0]) == null ? void 0 : i.toUpperCase()) ?? "";
1771
1783
  }).join("");
1772
1784
  }
1773
- const ze = "__epochsToolbarToolId";
1774
- function Wt(t, e) {
1785
+ const Xe = "__epochsToolbarToolId";
1786
+ function zt(t, e) {
1775
1787
  const n = (() => null);
1776
- return n.displayName = e, Object.defineProperty(n, ze, {
1788
+ return n.displayName = e, Object.defineProperty(n, Xe, {
1777
1789
  value: t,
1778
1790
  enumerable: !0
1779
1791
  }), n;
1780
1792
  }
1781
- function In(t) {
1782
- return t[ze];
1793
+ function Ln(t) {
1794
+ return t[Xe];
1783
1795
  }
1784
- function Tr(t) {
1785
- return typeof t == "function" && ze in t && typeof t[ze] == "string";
1796
+ function Dr(t) {
1797
+ return typeof t == "function" && Xe in t && typeof t[Xe] == "string";
1786
1798
  }
1787
- const Bn = Wt("thumbnail", "Thumbnail"), On = Wt("navigation", "Navigation"), Wn = Wt("zoom", "Zoom"), zn = Wt("rotate", "Rotate"), Sn = Wt("reload", "Reload"), Xn = Wt("print", "Print"), Gn = Wt("open", "Open"), qn = Wt("download", "Download"), Vn = Wt("highlight", "Highlight"), Yn = Wt("underline", "Underline"), Kn = Wt("signature", "Signature"), Zn = Wt("text", "AddText"), Qn = Wt("erase", "Erase"), Jn = Wt("clear", "Clear"), io = [
1788
- Bn,
1789
- On,
1790
- Wn,
1799
+ const zn = zt("thumbnail", "Thumbnail"), Sn = zt("navigation", "Navigation"), Gn = zt("zoom", "Zoom"), Xn = zt("rotate", "Rotate"), Vn = zt("reload", "Reload"), qn = zt("print", "Print"), Yn = zt("open", "Open"), Kn = zt("download", "Download"), Zn = zt("highlight", "Highlight"), Qn = zt("underline", "Underline"), Jn = zt("signature", "Signature"), ti = zt("text", "AddText"), ei = zt("erase", "Erase"), ni = zt("clear", "Clear"), ro = [
1791
1800
  zn,
1792
- Vn,
1793
- Yn,
1794
- Kn,
1801
+ Sn,
1802
+ Gn,
1803
+ Xn,
1795
1804
  Zn,
1796
1805
  Qn,
1797
1806
  Jn,
1798
- Sn,
1799
- Xn,
1800
- Gn,
1801
- qn
1802
- ], Tn = [
1803
- [Bn, On],
1807
+ ti,
1808
+ ei,
1809
+ ni,
1810
+ Vn,
1811
+ qn,
1812
+ Yn,
1813
+ Kn
1814
+ ], Fn = [
1815
+ [zn, Sn],
1804
1816
  [
1805
- Wn,
1806
- zn,
1807
- Vn,
1808
- Yn,
1809
- Kn,
1817
+ Gn,
1818
+ Xn,
1810
1819
  Zn,
1811
1820
  Qn,
1812
1821
  Jn,
1813
- Sn,
1814
- Xn,
1815
- Gn,
1816
- qn
1822
+ ti,
1823
+ ei,
1824
+ ni,
1825
+ Vn,
1826
+ qn,
1827
+ Yn,
1828
+ Kn
1817
1829
  ]
1818
1830
  ], Lr = [
1819
1831
  "highlight",
@@ -1823,10 +1835,10 @@ const Bn = Wt("thumbnail", "Thumbnail"), On = Wt("navigation", "Navigation"), Wn
1823
1835
  "erase",
1824
1836
  "clear"
1825
1837
  ];
1826
- function Ln(t) {
1838
+ function Rn(t) {
1827
1839
  return Lr.includes(t);
1828
1840
  }
1829
- function Dr(t, e, n) {
1841
+ function Fr(t, e, n) {
1830
1842
  const i = [];
1831
1843
  switch (n != null && n.showMarkupSep && i.push(
1832
1844
  /* @__PURE__ */ s(
@@ -1847,7 +1859,7 @@ function Dr(t, e, n) {
1847
1859
  className: "epochs-pdf-viewer__btn",
1848
1860
  onClick: () => e.setShowThumbnails((r) => !r),
1849
1861
  title: e.showThumbnails ? "Hide thumbnails" : "Show thumbnails",
1850
- children: /* @__PURE__ */ s(or, {})
1862
+ children: /* @__PURE__ */ s(sr, {})
1851
1863
  },
1852
1864
  "thumbnail"
1853
1865
  )
@@ -1863,7 +1875,7 @@ function Dr(t, e, n) {
1863
1875
  onClick: e.handlePrev,
1864
1876
  disabled: !e.canGoPrev || e.status !== "ready",
1865
1877
  title: "Previous page",
1866
- children: /* @__PURE__ */ s(er, {})
1878
+ children: /* @__PURE__ */ s(nr, {})
1867
1879
  },
1868
1880
  "nav-prev"
1869
1881
  ),
@@ -1898,7 +1910,7 @@ function Dr(t, e, n) {
1898
1910
  onClick: e.handleNext,
1899
1911
  disabled: !e.canGoNext || e.status !== "ready",
1900
1912
  title: "Next page",
1901
- children: /* @__PURE__ */ s(nr, {})
1913
+ children: /* @__PURE__ */ s(ir, {})
1902
1914
  },
1903
1915
  "nav-next"
1904
1916
  )
@@ -1914,7 +1926,7 @@ function Dr(t, e, n) {
1914
1926
  onClick: e.handleZoomOut,
1915
1927
  disabled: e.status !== "ready",
1916
1928
  title: "Zoom out",
1917
- children: /* @__PURE__ */ s(sr, {})
1929
+ children: /* @__PURE__ */ s(ar, {})
1918
1930
  },
1919
1931
  "zoom-out"
1920
1932
  ),
@@ -1930,7 +1942,7 @@ function Dr(t, e, n) {
1930
1942
  onClick: e.handleZoomIn,
1931
1943
  disabled: e.status !== "ready",
1932
1944
  title: "Zoom in",
1933
- children: /* @__PURE__ */ s(ar, {})
1945
+ children: /* @__PURE__ */ s(cr, {})
1934
1946
  },
1935
1947
  "zoom-in"
1936
1948
  ),
@@ -1958,7 +1970,7 @@ function Dr(t, e, n) {
1958
1970
  onClick: e.handleRotate,
1959
1971
  disabled: e.status !== "ready",
1960
1972
  title: "Rotate",
1961
- children: /* @__PURE__ */ s(dr, {})
1973
+ children: /* @__PURE__ */ s(hr, {})
1962
1974
  },
1963
1975
  "rotate"
1964
1976
  )
@@ -1974,7 +1986,7 @@ function Dr(t, e, n) {
1974
1986
  onClick: () => e.toggleMarkupTool("highlight"),
1975
1987
  disabled: e.status !== "ready",
1976
1988
  title: "Highlight text — select text to highlight",
1977
- children: /* @__PURE__ */ s(hr, {})
1989
+ children: /* @__PURE__ */ s(ur, {})
1978
1990
  },
1979
1991
  "highlight"
1980
1992
  )
@@ -1990,7 +2002,7 @@ function Dr(t, e, n) {
1990
2002
  onClick: () => e.toggleMarkupTool("underline"),
1991
2003
  disabled: e.status !== "ready",
1992
2004
  title: "Underline text — select text to underline",
1993
- children: /* @__PURE__ */ s(ur, {})
2005
+ children: /* @__PURE__ */ s(fr, {})
1994
2006
  },
1995
2007
  "underline"
1996
2008
  )
@@ -2012,7 +2024,7 @@ function Dr(t, e, n) {
2012
2024
  },
2013
2025
  disabled: e.status !== "ready",
2014
2026
  title: e.hasFixedSignatureFields ? "Create e-signature for a fixed field" : e.pendingSignature ? "Place signature — click on the page, then drag to move" : "Create e-signature",
2015
- children: /* @__PURE__ */ s(pr, {})
2027
+ children: /* @__PURE__ */ s(gr, {})
2016
2028
  },
2017
2029
  "signature"
2018
2030
  )
@@ -2028,7 +2040,7 @@ function Dr(t, e, n) {
2028
2040
  onClick: () => e.toggleMarkupTool("text"),
2029
2041
  disabled: e.status !== "ready",
2030
2042
  title: e.hasFixedTextFields ? "Edit text in predefined areas — click to type" : "Edit PDF text — select words, then change them",
2031
- children: /* @__PURE__ */ s(mr, {})
2043
+ children: /* @__PURE__ */ s(wr, {})
2032
2044
  },
2033
2045
  "text"
2034
2046
  )
@@ -2044,7 +2056,7 @@ function Dr(t, e, n) {
2044
2056
  onClick: () => e.toggleMarkupTool("erase"),
2045
2057
  disabled: e.status !== "ready",
2046
2058
  title: "Remove text — select PDF words to cover them, or click added markup",
2047
- children: /* @__PURE__ */ s(fr, {})
2059
+ children: /* @__PURE__ */ s(pr, {})
2048
2060
  },
2049
2061
  "erase"
2050
2062
  )
@@ -2075,7 +2087,7 @@ function Dr(t, e, n) {
2075
2087
  className: "epochs-pdf-viewer__btn",
2076
2088
  onClick: () => void e.loadDocument(),
2077
2089
  title: "Reload",
2078
- children: /* @__PURE__ */ s(lr, {})
2090
+ children: /* @__PURE__ */ s(dr, {})
2079
2091
  },
2080
2092
  "reload"
2081
2093
  )
@@ -2091,7 +2103,7 @@ function Dr(t, e, n) {
2091
2103
  onClick: () => void e.handlePrint(),
2092
2104
  disabled: e.status !== "ready" || !e.pdfDoc || e.isPrinting,
2093
2105
  title: e.isPrinting ? "Preparing print…" : "Print (includes highlights & underlines)",
2094
- children: /* @__PURE__ */ s(cr, {})
2106
+ children: /* @__PURE__ */ s(lr, {})
2095
2107
  },
2096
2108
  "print"
2097
2109
  )
@@ -2107,7 +2119,7 @@ function Dr(t, e, n) {
2107
2119
  target: "_blank",
2108
2120
  rel: "noopener noreferrer",
2109
2121
  title: "Open in new tab",
2110
- children: /* @__PURE__ */ s(rr, {})
2122
+ children: /* @__PURE__ */ s(or, {})
2111
2123
  },
2112
2124
  "open"
2113
2125
  )
@@ -2123,7 +2135,7 @@ function Dr(t, e, n) {
2123
2135
  onClick: () => void e.handleDownload(),
2124
2136
  disabled: e.status !== "ready" || !e.pdfDoc || e.isDownloading,
2125
2137
  title: e.isDownloading ? "Preparing download…" : e.annotationsLength > 0 || e.signaturesLength > 0 || e.textsLength > 0 ? "Download PDF with markup" : "Download PDF",
2126
- children: /* @__PURE__ */ s(ir, {})
2138
+ children: /* @__PURE__ */ s(rr, {})
2127
2139
  },
2128
2140
  "download"
2129
2141
  )
@@ -2132,7 +2144,7 @@ function Dr(t, e, n) {
2132
2144
  }
2133
2145
  return i.length > 0 ? i : null;
2134
2146
  }
2135
- function Fr(t, e) {
2147
+ function Rr(t, e) {
2136
2148
  const n = [];
2137
2149
  if (t.markupTool === "sign" && t.pendingSignature && !t.hasFixedSignatureFields && e.has("signature") && n.push(
2138
2150
  /* @__PURE__ */ s("span", { className: "epochs-pdf-viewer__markup-hint", children: "Click page to place duplicate/new signature" }, "sign-hint")
@@ -2141,7 +2153,7 @@ function Fr(t, e) {
2141
2153
  ), t.markupTool === "erase" && e.has("erase") && n.push(
2142
2154
  /* @__PURE__ */ s("span", { className: "epochs-pdf-viewer__markup-hint", children: "Select PDF words to remove · click added text/markup to erase" }, "erase-hint")
2143
2155
  ), t.markupTool === "highlight" && e.has("highlight") || t.markupTool === "underline" && e.has("underline")) {
2144
- const i = t.markupTool === "highlight" ? t.highlightHex : t.underlineHex, r = t.markupTool === "highlight" ? t.setHighlightHex : t.setUnderlineHex, o = t.markupTool === "highlight" ? Dn : Fn;
2156
+ const i = t.markupTool === "highlight" ? t.highlightHex : t.underlineHex, r = t.markupTool === "highlight" ? t.setHighlightHex : t.setUnderlineHex, o = t.markupTool === "highlight" ? An : En;
2145
2157
  n.push(
2146
2158
  /* @__PURE__ */ T(
2147
2159
  "div",
@@ -2154,12 +2166,12 @@ function Fr(t, e) {
2154
2166
  "button",
2155
2167
  {
2156
2168
  type: "button",
2157
- className: ce(i) === ce(d.hex) ? "epochs-pdf-viewer__swatch epochs-pdf-viewer__swatch--active" : "epochs-pdf-viewer__swatch",
2169
+ className: le(i) === le(d.hex) ? "epochs-pdf-viewer__swatch epochs-pdf-viewer__swatch--active" : "epochs-pdf-viewer__swatch",
2158
2170
  style: { background: d.hex },
2159
2171
  title: d.label,
2160
2172
  "aria-label": d.label,
2161
- "aria-pressed": ce(i) === ce(d.hex),
2162
- onClick: () => r(ce(d.hex))
2173
+ "aria-pressed": le(i) === le(d.hex),
2174
+ onClick: () => r(le(d.hex))
2163
2175
  },
2164
2176
  d.id
2165
2177
  )),
@@ -2180,8 +2192,8 @@ function Fr(t, e) {
2180
2192
  "input",
2181
2193
  {
2182
2194
  type: "color",
2183
- value: ce(i),
2184
- onChange: (d) => r(ce(d.target.value)),
2195
+ value: le(i),
2196
+ onChange: (d) => r(le(d.target.value)),
2185
2197
  "aria-label": "Custom color"
2186
2198
  }
2187
2199
  )
@@ -2196,16 +2208,16 @@ function Fr(t, e) {
2196
2208
  }
2197
2209
  return n.length > 0 ? n : null;
2198
2210
  }
2199
- function Rr(t, e) {
2211
+ function Ar(t, e) {
2200
2212
  if (!t) return null;
2201
2213
  if (Array.isArray(t)) {
2202
- const o = (d) => (d ?? []).filter(Tr).map(In);
2214
+ const o = (d) => (d ?? []).filter(Dr).map(Ln);
2203
2215
  return {
2204
2216
  left: o(t[0]),
2205
2217
  right: o(t[1])
2206
2218
  };
2207
2219
  }
2208
- const n = e.enableThumbnails, i = (o, d) => o.map(In).filter((u) => d[u] !== !1), r = {
2220
+ const n = e.enableThumbnails, i = (o, d) => o.map(Ln).filter((u) => d[u] !== !1), r = {
2209
2221
  thumbnail: n,
2210
2222
  navigation: e.enableNavigation,
2211
2223
  zoom: e.enableZoom,
@@ -2222,11 +2234,11 @@ function Rr(t, e) {
2222
2234
  clear: e.enableClear
2223
2235
  };
2224
2236
  return {
2225
- left: i(Tn[0], r),
2226
- right: i(Tn[1], r)
2237
+ left: i(Fn[0], r),
2238
+ right: i(Fn[1], r)
2227
2239
  };
2228
2240
  }
2229
- function ro({
2241
+ function oo({
2230
2242
  file: t,
2231
2243
  fileUrl: e,
2232
2244
  baseUrl: n = "",
@@ -2238,78 +2250,78 @@ function ro({
2238
2250
  thumbnailWidth: m = 140,
2239
2251
  maxThumbnails: g = 60,
2240
2252
  className: _,
2241
- workerSrc: w,
2253
+ workerSrc: y,
2242
2254
  enableToolbar: b = !1,
2243
2255
  enableThumbnails: x,
2244
- enableNavigation: C = !0,
2256
+ enableNavigation: I = !0,
2245
2257
  enableZoom: S = !0,
2246
2258
  enableRotate: H = !0,
2247
- enableReload: O = !0,
2248
- enablePrint: E = !0,
2249
- enableOpen: I = !0,
2250
- enableDownload: et = !0,
2259
+ enableReload: W = !0,
2260
+ enablePrint: A = !0,
2261
+ enableOpen: C = !0,
2262
+ enableDownload: nt = !0,
2251
2263
  enableMarkup: at = !0,
2252
- enableHighlight: Y = !0,
2264
+ enableHighlight: q = !0,
2253
2265
  enableUnderline: pt = !0,
2254
2266
  enableSignature: J = !0,
2255
2267
  enableText: Mt = !0,
2256
- enableErase: Z = !0,
2257
- enableClear: Lt = !0,
2258
- signatureFields: _t = [],
2259
- textFields: U = [],
2268
+ enableErase: K = !0,
2269
+ enableClear: Et = !0,
2270
+ signatureFields: vt = [],
2271
+ textFields: E = [],
2260
2272
  onSignatureComplete: ct,
2261
- onSignatureFieldsChange: ft,
2273
+ onSignatureFieldsChange: ht,
2262
2274
  applySignatureToSameTag: gt = !1,
2263
2275
  onFieldValueComplete: tt,
2264
- openSignaturePad: kt = !1,
2265
- onSignaturePadClose: lt,
2276
+ openSignaturePad: Pt = !1,
2277
+ onSignaturePadClose: ut,
2266
2278
  onSubmit: te,
2267
- submitLabel: me = "Submit",
2268
- submitLoading: St = !1
2279
+ submitLabel: ye = "Submit",
2280
+ submitLoading: Vt = !1
2269
2281
  }) {
2270
- var _n, vn;
2271
- const Ut = xt(null), Dt = xt(null), X = xt(/* @__PURE__ */ new Map()), qt = xt(!1), Ft = xe(() => t && typeof t != "string" ? t : null, [t]), wt = xe(() => Ft ? "" : vr(typeof t == "string" ? t : void 0, e, n), [Ft, t, e, n]), [st, Ht] = z("idle"), [nt, yt] = z(null), [Ct, ee] = z(0), [it, re] = z(1), [f, F] = z(d), [A, dt] = z(0), [ht, Vt] = z(null), [Yt, Kt] = z(!1), [ne, a] = z(!1), [y, v] = z(!1), [M, D] = z("none"), [P, R] = z([]), [k, B] = z([]), [G, L] = z([]), [rt, q] = z(!1), [ut, vt] = z(void 0), [Xt, Nt] = z({}), [Rt, At] = z(null), [Zt, It] = z(
2282
+ var Mn, kn;
2283
+ const qt = xt(null), Kt = xt(null), G = xt(/* @__PURE__ */ new Map()), $t = xt(!1), yt = Pe(() => t && typeof t != "string" ? t : null, [t]), bt = Pe(() => yt ? "" : xr(typeof t == "string" ? t : void 0, e, n), [yt, t, e, n]), [it, Wt] = O("idle"), [st, mt] = O(null), [It, ee] = O(0), [dt, ne] = O(1), [kt, oe] = O(d), [p, L] = O(0), [U, rt] = O(null), [Lt, Zt] = O(!1), [ie, a] = O(!1), [w, v] = O(!1), [M, D] = O("none"), [P, F] = O([]), [N, j] = O([]), [Z, R] = O([]), [lt, X] = O(!1), [et, ft] = O(void 0), [Ft, Rt] = O({}), [Ht, At] = O(null), [St, Nt] = O(
2272
2284
  null
2273
- ), [bt, Qt] = z(
2285
+ ), [_t, Ut] = O(
2274
2286
  null
2275
- ), [oe, Gt] = z(null), [se, Et] = z(null), [le, Pe] = z(null), [ai, Ee] = z(null), [ln, ci] = z(Rn), [dn, li] = z(Wi), $e = U.length > 0, [zt, Se] = z({}), [j, Xe] = z(_t), we = xt(j);
2276
- we.current = j, Tt(() => {
2277
- we.current = _t, Xe(_t), Se((c) => {
2287
+ ), [Yt, Gt] = O(null), [be, se] = O(null), [Ve, de] = O(null), [qe, he] = O(null), [_e, Qt] = O(Hn), [ae, di] = O(zi), Te = E.length > 0, [Xt, Ye] = O({}), [B, Ke] = O(vt), ve = xt(B);
2288
+ ve.current = B, Dt(() => {
2289
+ ve.current = vt, Ke(vt), Ye((c) => {
2278
2290
  const h = { ...c };
2279
- for (const l of _t) {
2280
- const p = l.type ?? "sign";
2281
- (p === "date" || p === "text") && l.value != null && l.value !== "" && (h[l.id] = l.value);
2291
+ for (const l of vt) {
2292
+ const f = l.type ?? "sign";
2293
+ (f === "date" || f === "text") && l.value != null && l.value !== "" && (h[l.id] = l.value);
2282
2294
  }
2283
2295
  return h;
2284
2296
  });
2285
- }, [_t]);
2286
- const jt = j.length > 0, Ce = K(
2297
+ }, [vt]);
2298
+ const jt = B.length > 0, De = Y(
2287
2299
  (c, h, l) => {
2288
- var N;
2289
- const p = c.type ?? "sign";
2290
- return p === "date" || p === "text" ? !!((N = l[c.id] ?? c.value) != null && N.trim()) : h.some(($) => $.fieldId === c.id) || !!c.signatureDataUrl;
2300
+ var k;
2301
+ const f = c.type ?? "sign";
2302
+ return f === "date" || f === "text" ? !!((k = l[c.id] ?? c.value) != null && k.trim()) : h.some(($) => $.fieldId === c.id) || !!c.signatureDataUrl;
2291
2303
  },
2292
2304
  []
2293
- ), hn = K(
2305
+ ), pn = Y(
2294
2306
  (c, h) => {
2295
- const l = new Set(c), N = we.current.map(
2307
+ const l = new Set(c), k = ve.current.map(
2296
2308
  ($) => l.has($.id) ? { ...$, value: h } : $
2297
2309
  );
2298
- we.current = N, Xe(N), ft == null || ft(N), Se(($) => {
2299
- const W = { ...$ };
2300
- for (const ot of c) W[ot] = h;
2301
- return W;
2310
+ ve.current = k, Ke(k), ht == null || ht(k), Ye(($) => {
2311
+ const z = { ...$ };
2312
+ for (const ot of c) z[ot] = h;
2313
+ return z;
2302
2314
  });
2303
2315
  for (const $ of c)
2304
2316
  tt == null || tt($, h);
2305
2317
  },
2306
- [tt, ft]
2307
- ), Ie = K(
2318
+ [tt, ht]
2319
+ ), Le = Y(
2308
2320
  (c, h, l) => {
2309
- const p = we.current, N = c == null ? null : Array.isArray(c) ? c : [c], $ = N ? new Set(N) : null, W = $ ? p.map(
2321
+ const f = ve.current, k = c == null ? null : Array.isArray(c) ? c : [c], $ = k ? new Set(k) : null, z = $ ? f.map(
2310
2322
  (ot) => $.has(ot.id) ? { ...ot, signatureDataUrl: h.imageDataUrl } : ot
2311
2323
  ) : [
2312
- ...p,
2324
+ ...f,
2313
2325
  {
2314
2326
  id: h.id,
2315
2327
  pageNumber: h.pageNumber,
@@ -2321,126 +2333,126 @@ function ro({
2321
2333
  signatureDataUrl: h.imageDataUrl
2322
2334
  }
2323
2335
  ];
2324
- if (we.current = W, Xe(W), ft == null || ft(W), !N || N.length === 0) {
2336
+ if (ve.current = z, Ke(z), ht == null || ht(z), !k || k.length === 0) {
2325
2337
  ct == null || ct(void 0, h);
2326
2338
  return;
2327
2339
  }
2328
- for (const ot of N)
2340
+ for (const ot of k)
2329
2341
  ct == null || ct(
2330
2342
  ot,
2331
2343
  (l == null ? void 0 : l.get(ot)) ?? h
2332
2344
  );
2333
2345
  },
2334
- [ct, ft]
2346
+ [ct, ht]
2335
2347
  );
2336
- Tt(() => {
2337
- kt && q(!0);
2338
- }, [kt]);
2339
- const de = xe(
2340
- () => Rr(b, {
2348
+ Dt(() => {
2349
+ Pt && X(!0);
2350
+ }, [Pt]);
2351
+ const ue = Pe(
2352
+ () => Ar(b, {
2341
2353
  enableThumbnails: x,
2342
- enableNavigation: C,
2354
+ enableNavigation: I,
2343
2355
  enableZoom: S,
2344
2356
  enableRotate: H,
2345
- enableReload: O,
2346
- enablePrint: E,
2347
- enableOpen: I,
2348
- enableDownload: et,
2349
- enableHighlight: Y,
2357
+ enableReload: W,
2358
+ enablePrint: A,
2359
+ enableOpen: C,
2360
+ enableDownload: nt,
2361
+ enableHighlight: q,
2350
2362
  enableUnderline: pt,
2351
2363
  enableSignature: J,
2352
2364
  enableText: Mt,
2353
- enableErase: Z,
2354
- enableClear: Lt
2365
+ enableErase: K,
2366
+ enableClear: Et
2355
2367
  }),
2356
2368
  [
2357
2369
  b,
2358
2370
  x,
2359
- C,
2371
+ I,
2360
2372
  S,
2361
2373
  H,
2362
- O,
2363
- E,
2364
- I,
2365
- et,
2366
- Y,
2374
+ W,
2375
+ A,
2376
+ C,
2377
+ nt,
2378
+ q,
2367
2379
  pt,
2368
2380
  J,
2369
2381
  Mt,
2370
- Z,
2371
- Lt
2382
+ K,
2383
+ Et
2372
2384
  ]
2373
- ), he = xe(() => de ? /* @__PURE__ */ new Set([...de.left, ...de.right]) : /* @__PURE__ */ new Set(), [de]);
2374
- Tt(() => {
2375
- if (!he.has("thumbnail")) {
2376
- Kt(!1);
2385
+ ), fe = Pe(() => ue ? /* @__PURE__ */ new Set([...ue.left, ...ue.right]) : /* @__PURE__ */ new Set(), [ue]);
2386
+ Dt(() => {
2387
+ if (!fe.has("thumbnail")) {
2388
+ Zt(!1);
2377
2389
  return;
2378
2390
  }
2379
2391
  const h = window.matchMedia("(max-width: 720px)"), l = () => {
2380
- Kt(h.matches ? !1 : u);
2392
+ Zt(h.matches ? !1 : u);
2381
2393
  };
2382
2394
  return l(), h.addEventListener("change", l), () => h.removeEventListener("change", l);
2383
- }, [he, u]);
2384
- const un = !jt && he.has("highlight"), fn = !jt && he.has("underline"), Ge = he.has("signature") || jt, pn = he.has("text") || $e, gn = !jt && he.has("erase"), Te = K(() => {
2385
- Dt.current && (URL.revokeObjectURL(Dt.current), Dt.current = null);
2386
- }, []), qe = K(async () => {
2387
- if (!(!Ft && !wt)) {
2388
- _r(w), Ht("loading"), yt(null), ee(0), re(1), R([]), B([]), L([]), At(null), It(null), Qt(null), Gt(null), Et(null), Pe(null), Ee(null), D("none");
2395
+ }, [fe, u]);
2396
+ const gn = !jt && fe.has("highlight"), mn = !jt && fe.has("underline"), Ze = fe.has("signature") || jt, wn = fe.has("text") || Te, yn = !jt && fe.has("erase"), Fe = Y(() => {
2397
+ Kt.current && (URL.revokeObjectURL(Kt.current), Kt.current = null);
2398
+ }, []), Qe = Y(async () => {
2399
+ if (!(!yt && !bt)) {
2400
+ vr(y), Wt("loading"), mt(null), ee(0), ne(1), F([]), j([]), R([]), At(null), Nt(null), Ut(null), Gt(null), se(null), de(null), he(null), D("none");
2389
2401
  try {
2390
- const c = Ft ? await Nn(Ft, i) : await Nn(wt, i), h = new Blob([c], { type: "application/pdf" }), l = URL.createObjectURL(h);
2391
- Te(), Dt.current = l, Vt(l);
2392
- const N = await ke.getDocument({
2402
+ const c = yt ? await In(yt, i) : await In(bt, i), h = new Blob([c], { type: "application/pdf" }), l = URL.createObjectURL(h);
2403
+ Fe(), Kt.current = l, rt(l);
2404
+ const k = await Ie.getDocument({
2393
2405
  data: c,
2394
- cMapUrl: `https://unpkg.com/pdfjs-dist@${ke.version}/cmaps/`,
2406
+ cMapUrl: `https://unpkg.com/pdfjs-dist@${Ie.version}/cmaps/`,
2395
2407
  cMapPacked: !0,
2396
- standardFontDataUrl: `https://unpkg.com/pdfjs-dist@${ke.version}/standard_fonts/`
2408
+ standardFontDataUrl: `https://unpkg.com/pdfjs-dist@${Ie.version}/standard_fonts/`
2397
2409
  }).promise;
2398
- yt(N), ee(N.numPages), Ht("ready");
2410
+ mt(k), ee(k.numPages), Wt("ready");
2399
2411
  } catch {
2400
- Ht("error");
2412
+ Wt("error");
2401
2413
  }
2402
2414
  }
2403
2415
  }, [
2404
- Ft,
2405
- wt,
2416
+ yt,
2417
+ bt,
2406
2418
  i,
2407
- Te,
2408
- w
2419
+ Fe,
2420
+ y
2409
2421
  ]);
2410
- Tt(() => {
2411
- if (!Ft && !wt) {
2412
- Ht("idle"), yt(null), ee(0), Vt(null), Te();
2422
+ Dt(() => {
2423
+ if (!yt && !bt) {
2424
+ Wt("idle"), mt(null), ee(0), rt(null), Fe();
2413
2425
  return;
2414
2426
  }
2415
- return qe(), () => {
2416
- Te();
2427
+ return Qe(), () => {
2428
+ Fe();
2417
2429
  };
2418
- }, [Ft, wt, qe, Te]), Tt(() => {
2419
- (M === "highlight" && !un || M === "underline" && !fn || M === "sign" && !Ge || M === "text" && !pn || M === "erase" && !gn) && D("none");
2420
- }, [un, fn, Ge, pn, gn, M]);
2421
- const ye = K(
2430
+ }, [yt, bt, Qe, Fe]), Dt(() => {
2431
+ (M === "highlight" && !gn || M === "underline" && !mn || M === "sign" && !Ze || M === "text" && !wn || M === "erase" && !yn) && D("none");
2432
+ }, [gn, mn, Ze, wn, yn, M]);
2433
+ const xe = Y(
2422
2434
  (c) => {
2423
- const h = Math.max(1, Math.min(Ct || 1, c)), l = X.current.get(h);
2435
+ const h = Math.max(1, Math.min(It || 1, c)), l = G.current.get(h);
2424
2436
  if (!l) {
2425
- re(h);
2437
+ ne(h);
2426
2438
  return;
2427
2439
  }
2428
- qt.current = !0, l.scrollIntoView({ behavior: "smooth", block: "start" }), re(h), window.setTimeout(() => {
2429
- qt.current = !1;
2440
+ $t.current = !0, l.scrollIntoView({ behavior: "smooth", block: "start" }), ne(h), window.setTimeout(() => {
2441
+ $t.current = !1;
2430
2442
  }, 500);
2431
2443
  },
2432
- [Ct]
2433
- ), be = K(
2444
+ [It]
2445
+ ), Me = Y(
2434
2446
  (c) => {
2435
- const h = X.current.get(c.pageNumber);
2436
- h && (qt.current = !0, re(c.pageNumber));
2447
+ const h = G.current.get(c.pageNumber);
2448
+ h && ($t.current = !0, ne(c.pageNumber));
2437
2449
  const l = () => {
2438
- var N;
2439
- const p = (N = Ut.current) == null ? void 0 : N.querySelector(
2450
+ var k;
2451
+ const f = (k = qt.current) == null ? void 0 : k.querySelector(
2440
2452
  `[data-signature-field-id="${CSS.escape(c.id)}"]`
2441
2453
  );
2442
- p ? p.scrollIntoView({ behavior: "smooth", block: "center" }) : h && h.scrollIntoView({ behavior: "smooth", block: "start" }), window.setTimeout(() => {
2443
- qt.current = !1;
2454
+ f ? f.scrollIntoView({ behavior: "smooth", block: "center" }) : h && h.scrollIntoView({ behavior: "smooth", block: "start" }), window.setTimeout(() => {
2455
+ $t.current = !1;
2444
2456
  }, 500);
2445
2457
  };
2446
2458
  window.requestAnimationFrame(() => {
@@ -2449,78 +2461,78 @@ function ro({
2449
2461
  },
2450
2462
  []
2451
2463
  );
2452
- Tt(() => {
2453
- if (st !== "ready" || !Ut.current || !Ct) return;
2454
- const c = Ut.current, h = new IntersectionObserver(
2464
+ Dt(() => {
2465
+ if (it !== "ready" || !qt.current || !It) return;
2466
+ const c = qt.current, h = new IntersectionObserver(
2455
2467
  (l) => {
2456
- if (qt.current) return;
2457
- let p = null;
2458
- for (const N of l) {
2459
- if (!N.isIntersecting) continue;
2468
+ if ($t.current) return;
2469
+ let f = null;
2470
+ for (const k of l) {
2471
+ if (!k.isIntersecting) continue;
2460
2472
  const $ = Number.parseInt(
2461
- N.target.dataset.pageNumber || "0",
2473
+ k.target.dataset.pageNumber || "0",
2462
2474
  10
2463
2475
  );
2464
- $ && (!p || N.intersectionRatio > p.ratio) && (p = { page: $, ratio: N.intersectionRatio });
2476
+ $ && (!f || k.intersectionRatio > f.ratio) && (f = { page: $, ratio: k.intersectionRatio });
2465
2477
  }
2466
- p && re(p.page);
2478
+ f && ne(f.page);
2467
2479
  },
2468
2480
  {
2469
2481
  root: c,
2470
2482
  threshold: [0.25, 0.5, 0.75]
2471
2483
  }
2472
2484
  );
2473
- for (let l = 1; l <= Ct; l += 1) {
2474
- const p = X.current.get(l);
2475
- p && h.observe(p);
2485
+ for (let l = 1; l <= It; l += 1) {
2486
+ const f = G.current.get(l);
2487
+ f && h.observe(f);
2476
2488
  }
2477
2489
  return () => h.disconnect();
2478
- }, [st, Ct]);
2479
- const Ve = it > 1, Ye = Ct ? it < Ct : !1, di = K(() => {
2480
- Ve && ye(it - 1);
2481
- }, [Ve, it, ye]), hi = K(() => {
2482
- Ye && ye(it + 1);
2483
- }, [Ye, it, ye]), ui = K(() => {
2484
- dt((c) => (c + 90) % 360);
2485
- }, []), fi = K(() => {
2486
- F((c) => Math.max(0.25, Math.round((c - 0.1) * 100) / 100));
2487
- }, []), pi = K(() => {
2488
- F((c) => Math.min(5, Math.round((c + 0.1) * 100) / 100));
2489
- }, []), Ke = K(async () => {
2490
- if (!(!nt || !Ut.current))
2490
+ }, [it, It]);
2491
+ const Je = dt > 1, tn = It ? dt < It : !1, hi = Y(() => {
2492
+ Je && xe(dt - 1);
2493
+ }, [Je, dt, xe]), ui = Y(() => {
2494
+ tn && xe(dt + 1);
2495
+ }, [tn, dt, xe]), fi = Y(() => {
2496
+ L((c) => (c + 90) % 360);
2497
+ }, []), pi = Y(() => {
2498
+ oe((c) => Math.max(0.25, Math.round((c - 0.1) * 100) / 100));
2499
+ }, []), gi = Y(() => {
2500
+ oe((c) => Math.min(5, Math.round((c + 0.1) * 100) / 100));
2501
+ }, []), en = Y(async () => {
2502
+ if (!(!st || !qt.current))
2491
2503
  try {
2492
- const h = (await nt.getPage(it)).getViewport({ scale: 1, rotation: A }), p = window.matchMedia("(max-width: 720px)").matches ? 16 : 24, $ = Math.max(
2504
+ const h = (await st.getPage(dt)).getViewport({ scale: 1, rotation: p }), f = window.matchMedia("(max-width: 720px)").matches ? 16 : 24, $ = Math.max(
2493
2505
  0,
2494
- Ut.current.clientWidth - p
2506
+ qt.current.clientWidth - f
2495
2507
  ) / h.width;
2496
- F(Math.max(0.25, Math.min(5, Math.round($ * 100) / 100)));
2508
+ oe(Math.max(0.25, Math.min(5, Math.round($ * 100) / 100)));
2497
2509
  } catch {
2498
2510
  }
2499
- }, [nt, it, A]);
2500
- Tt(() => {
2501
- if (st !== "ready" || !nt || !window.matchMedia("(max-width: 720px)").matches) return;
2511
+ }, [st, dt, p]);
2512
+ Dt(() => {
2513
+ if (it !== "ready" || !st || !window.matchMedia("(max-width: 720px)").matches) return;
2502
2514
  let c = !1;
2503
2515
  const h = () => {
2504
- c || Ke();
2516
+ c || en();
2505
2517
  };
2506
2518
  h();
2507
- const l = Ut.current, p = typeof ResizeObserver < "u" && l ? new ResizeObserver(() => h()) : null;
2508
- p == null || p.observe(l);
2509
- const N = window.matchMedia("(max-width: 720px)"), $ = () => {
2510
- N.matches && h();
2519
+ const l = qt.current, f = typeof ResizeObserver < "u" && l ? new ResizeObserver(() => h()) : null;
2520
+ f == null || f.observe(l);
2521
+ const k = window.matchMedia("(max-width: 720px)"), $ = () => {
2522
+ k.matches && h();
2511
2523
  };
2512
- return N.addEventListener("change", $), () => {
2513
- c = !0, p == null || p.disconnect(), N.removeEventListener("change", $);
2524
+ return k.addEventListener("change", $), () => {
2525
+ c = !0, f == null || f.disconnect(), k.removeEventListener("change", $);
2514
2526
  };
2515
- }, [st, nt, Yt, A, Ke]);
2516
- const mn = xe(() => j.flatMap((c) => {
2527
+ }, [it, st, Lt, p, en]);
2528
+ const bn = Pe(() => B.flatMap((c) => {
2517
2529
  const h = c.type ?? "sign";
2518
2530
  if (h !== "date" && h !== "text") return [];
2519
- const l = (zt[c.id] ?? c.value ?? "").trim();
2531
+ const l = (Xt[c.id] ?? c.value ?? "").trim();
2520
2532
  if (!l) return [];
2521
- const p = Math.max(
2533
+ const f = Math.max(
2522
2534
  10,
2523
- Math.min(ge, c.height * 0.55)
2535
+ Math.min(we, c.height * 0.55)
2524
2536
  );
2525
2537
  return [
2526
2538
  {
@@ -2528,34 +2540,34 @@ function ro({
2528
2540
  pageNumber: c.pageNumber,
2529
2541
  fieldId: c.id,
2530
2542
  x: c.x + 4,
2531
- y: c.y + Math.max(2, (c.height - p) / 2),
2543
+ y: c.y + Math.max(2, (c.height - f) / 2),
2532
2544
  width: Math.max(12, c.width - 8),
2533
- height: Math.max(p * 1.2, c.height - 4),
2545
+ height: Math.max(f * 1.2, c.height - 4),
2534
2546
  value: l,
2535
- fontSize: p,
2536
- color: pe
2547
+ fontSize: f,
2548
+ color: me
2537
2549
  }
2538
2550
  ];
2539
- }), [j, zt]), _e = xe(
2540
- () => [...G, ...mn],
2541
- [G, mn]
2542
- ), gi = K(async () => {
2551
+ }), [B, Xt]), ke = Pe(
2552
+ () => [...Z, ...bn],
2553
+ [Z, bn]
2554
+ ), mi = Y(async () => {
2543
2555
  var c;
2544
- if (!(!nt || st !== "ready")) {
2556
+ if (!(!st || it !== "ready")) {
2545
2557
  a(!0);
2546
2558
  try {
2547
- const h = await Pn(nt, {
2559
+ const h = await Cn(st, {
2548
2560
  scale: 1.5,
2549
- rotation: A,
2561
+ rotation: p,
2550
2562
  annotations: P,
2551
- signatures: k,
2552
- texts: _e,
2563
+ signatures: N,
2564
+ texts: ke,
2553
2565
  mimeType: "image/png"
2554
2566
  }), l = document.createElement("iframe");
2555
2567
  l.style.position = "fixed", l.style.right = "0", l.style.bottom = "0", l.style.width = "0", l.style.height = "0", l.style.border = "0", l.setAttribute("aria-hidden", "true"), document.body.appendChild(l);
2556
- const p = (c = l.contentWindow) == null ? void 0 : c.document;
2557
- if (!p) throw new Error("print iframe not available");
2558
- p.open(), p.write(`<!doctype html>
2568
+ const f = (c = l.contentWindow) == null ? void 0 : c.document;
2569
+ if (!f) throw new Error("print iframe not available");
2570
+ f.open(), f.write(`<!doctype html>
2559
2571
  <html>
2560
2572
  <head>
2561
2573
  <meta charset="utf-8" />
@@ -2569,26 +2581,26 @@ function ro({
2569
2581
  </style>
2570
2582
  </head>
2571
2583
  <body></body>
2572
- </html>`), p.close();
2573
- const N = p.body;
2584
+ </html>`), f.close();
2585
+ const k = f.body;
2574
2586
  for (const $ of h) {
2575
- const W = p.createElement("img");
2576
- W.src = $.dataUrl;
2577
- const ot = p.createElement("div");
2578
- ot.className = "page", ot.appendChild(W), N.appendChild(ot);
2587
+ const z = f.createElement("img");
2588
+ z.src = $.dataUrl;
2589
+ const ot = f.createElement("div");
2590
+ ot.className = "page", ot.appendChild(z), k.appendChild(ot);
2579
2591
  }
2580
2592
  await Promise.all(
2581
- Array.from(N.querySelectorAll("img")).map(
2593
+ Array.from(k.querySelectorAll("img")).map(
2582
2594
  ($) => {
2583
- var W;
2584
- return ((W = $.decode) == null ? void 0 : W.call($).catch(() => {
2595
+ var z;
2596
+ return ((z = $.decode) == null ? void 0 : z.call($).catch(() => {
2585
2597
  })) ?? Promise.resolve();
2586
2598
  }
2587
2599
  )
2588
2600
  ), setTimeout(() => {
2589
- var $, W;
2601
+ var $, z;
2590
2602
  try {
2591
- ($ = l.contentWindow) == null || $.focus(), (W = l.contentWindow) == null || W.print();
2603
+ ($ = l.contentWindow) == null || $.focus(), (z = l.contentWindow) == null || z.print();
2592
2604
  } finally {
2593
2605
  setTimeout(() => {
2594
2606
  try {
@@ -2600,125 +2612,125 @@ function ro({
2600
2612
  }, 50);
2601
2613
  } catch {
2602
2614
  try {
2603
- ht ? window.open(ht, "_blank", "noopener,noreferrer") : wt && window.open(wt, "_blank", "noopener,noreferrer");
2615
+ U ? window.open(U, "_blank", "noopener,noreferrer") : bt && window.open(bt, "_blank", "noopener,noreferrer");
2604
2616
  } catch {
2605
2617
  }
2606
2618
  } finally {
2607
2619
  a(!1);
2608
2620
  }
2609
2621
  }
2610
- }, [nt, st, A, o, ht, wt, P, k, _e]), mi = K(async () => {
2611
- if (!nt || st !== "ready") return;
2622
+ }, [st, it, p, o, U, bt, P, N, ke]), wi = Y(async () => {
2623
+ if (!st || it !== "ready") return;
2612
2624
  const c = `${o.replace(/[^\w.-]+/g, "_") || "document"}.pdf`;
2613
- if (!(P.length > 0 || k.length > 0 || _e.length > 0) && ht) {
2614
- sn(
2615
- await fetch(ht).then((l) => l.blob()),
2625
+ if (!(P.length > 0 || N.length > 0 || ke.length > 0) && U) {
2626
+ hn(
2627
+ await fetch(U).then((l) => l.blob()),
2616
2628
  c
2617
2629
  );
2618
2630
  return;
2619
2631
  }
2620
2632
  v(!0);
2621
2633
  try {
2622
- const l = await Pn(nt, {
2634
+ const l = await Cn(st, {
2623
2635
  scale: 2,
2624
- rotation: A,
2636
+ rotation: p,
2625
2637
  annotations: P,
2626
- signatures: k,
2627
- texts: _e,
2638
+ signatures: N,
2639
+ texts: ke,
2628
2640
  mimeType: "image/jpeg",
2629
2641
  quality: 0.92
2630
- }), p = Nr(l), N = new Uint8Array(p.byteLength);
2631
- N.set(p), sn(
2632
- new Blob([N], { type: "application/pdf" }),
2642
+ }), f = Pr(l), k = new Uint8Array(f.byteLength);
2643
+ k.set(f), hn(
2644
+ new Blob([k], { type: "application/pdf" }),
2633
2645
  c
2634
2646
  );
2635
2647
  } catch {
2636
- ht && sn(
2637
- await fetch(ht).then((l) => l.blob()),
2648
+ U && hn(
2649
+ await fetch(U).then((l) => l.blob()),
2638
2650
  c
2639
2651
  );
2640
2652
  } finally {
2641
2653
  v(!1);
2642
2654
  }
2643
- }, [nt, st, A, o, ht, P, k, _e]), wi = K((c) => {
2655
+ }, [st, it, p, o, U, P, N, ke]), yi = Y((c) => {
2644
2656
  D((h) => h === c ? "none" : c);
2645
- }, []), yi = M === "highlight" || M === "underline" ? An(M === "highlight" ? ln : M === "underline" ? dn : null, M) : void 0, ve = Zt != null ? k.find((c) => c.id === Zt) ?? null : null, bi = K((c) => {
2646
- R((h) => [...h, c]);
2647
- }, []), _i = K((c) => {
2648
- R((h) => h.filter((l) => l.id !== c));
2649
- }, []), vi = K(() => {
2650
- R([]), B([]), L([]), It(null), Et(null), Pe(null), Ee(null);
2651
- }, []), Ue = K(
2657
+ }, []), bi = M === "highlight" || M === "underline" ? Un(M === "highlight" ? _e : M === "underline" ? ae : null, M) : void 0, Ne = St != null ? N.find((c) => c.id === St) ?? null : null, _i = Y((c) => {
2658
+ F((h) => [...h, c]);
2659
+ }, []), vi = Y((c) => {
2660
+ F((h) => h.filter((l) => l.id !== c));
2661
+ }, []), xi = Y(() => {
2662
+ F([]), j([]), R([]), Nt(null), se(null), de(null), he(null);
2663
+ }, []), Be = Y(
2652
2664
  (c, h) => {
2653
- const l = j.findIndex(
2654
- (N) => N.id === c
2655
- ), p = j.slice(l + 1).find((N) => !h.has(N.id)) ?? j.slice(0, Math.max(0, l)).find((N) => !h.has(N.id));
2656
- if (!p) {
2657
- q(!1), Gt(null);
2665
+ const l = B.findIndex(
2666
+ (k) => k.id === c
2667
+ ), f = B.slice(l + 1).find((k) => !h.has(k.id)) ?? B.slice(0, Math.max(0, l)).find((k) => !h.has(k.id));
2668
+ if (!f) {
2669
+ X(!1), Gt(null);
2658
2670
  return;
2659
2671
  }
2660
- Qt(p.id), It(null), Gt(null), vt(p.type ?? "sign"), be(p), window.setTimeout(() => {
2661
- q(!0);
2672
+ Ut(f.id), Nt(null), Gt(null), ft(f.type ?? "sign"), Me(f), window.setTimeout(() => {
2673
+ X(!0);
2662
2674
  }, 350);
2663
2675
  },
2664
- [be, j]
2665
- ), xi = K(
2676
+ [Me, B]
2677
+ ), Mi = Y(
2666
2678
  (c) => {
2667
- vt(c), q(!0);
2679
+ ft(c), X(!0);
2668
2680
  },
2669
2681
  []
2670
- ), Mi = K((c, h) => {
2671
- Se((l) => ({ ...l, [c]: h }));
2672
- }, []), ki = K(
2682
+ ), ki = Y((c, h) => {
2683
+ Ye((l) => ({ ...l, [c]: h }));
2684
+ }, []), Ni = Y(
2673
2685
  (c) => {
2674
- const h = zt[c];
2686
+ const h = Xt[c];
2675
2687
  h && (tt == null || tt(c, h));
2676
- const l = j.findIndex(($) => $.id === c), p = new Set(
2677
- Object.keys(zt).filter(($) => {
2678
- var W;
2679
- return (W = zt[$]) == null ? void 0 : W.trim();
2688
+ const l = B.findIndex(($) => $.id === c), f = new Set(
2689
+ Object.keys(Xt).filter(($) => {
2690
+ var z;
2691
+ return (z = Xt[$]) == null ? void 0 : z.trim();
2680
2692
  })
2681
2693
  );
2682
- p.add(c);
2683
- const N = j.slice(l + 1).find(
2684
- ($) => !p.has($.id) && !k.some((W) => W.fieldId === $.id)
2685
- ) ?? j.slice(0, Math.max(0, l)).find(
2686
- ($) => !p.has($.id) && !k.some((W) => W.fieldId === $.id)
2694
+ f.add(c);
2695
+ const k = B.slice(l + 1).find(
2696
+ ($) => !f.has($.id) && !N.some((z) => z.fieldId === $.id)
2697
+ ) ?? B.slice(0, Math.max(0, l)).find(
2698
+ ($) => !f.has($.id) && !N.some((z) => z.fieldId === $.id)
2687
2699
  );
2688
- N && (Qt(N.id), be(N));
2700
+ k && (Ut(k.id), Me(k));
2689
2701
  },
2690
- [j, zt, k, be, tt]
2691
- ), Ni = K(
2702
+ [B, Xt, N, Me, tt]
2703
+ ), Pi = Y(
2692
2704
  (c, h, l) => {
2693
- var ue;
2694
- const p = Xi(h, l);
2695
- if (oe) {
2696
- B(
2705
+ var pe;
2706
+ const f = Xi(h, l);
2707
+ if (Yt) {
2708
+ j(
2697
2709
  (Q) => Q.map(
2698
- (Pt) => Pt.id === oe ? {
2699
- ...Pt,
2710
+ (Ct) => Ct.id === Yt ? {
2711
+ ...Ct,
2700
2712
  imageDataUrl: c,
2701
- width: Pt.fieldId ? Pt.width : p.width,
2702
- height: Pt.fieldId ? Pt.height : p.height
2703
- } : Pt
2713
+ width: Ct.fieldId ? Ct.width : f.width,
2714
+ height: Ct.fieldId ? Ct.height : f.height
2715
+ } : Ct
2704
2716
  )
2705
- ), At(null), D("none"), q(!1), Gt(null);
2717
+ ), At(null), D("none"), X(!1), Gt(null);
2706
2718
  return;
2707
2719
  }
2708
2720
  if (jt) {
2709
- const Q = j.find(
2710
- (V) => V.id === bt && (V.type ?? "sign") === "sign" && !k.some((ae) => ae.fieldId === V.id)
2711
- ) ?? j.find(
2712
- (V) => (V.type ?? "sign") === "sign" && !k.some((ae) => ae.fieldId === V.id)
2721
+ const Q = B.find(
2722
+ (V) => V.id === _t && (V.type ?? "sign") === "sign" && !N.some((ce) => ce.fieldId === V.id)
2723
+ ) ?? B.find(
2724
+ (V) => (V.type ?? "sign") === "sign" && !N.some((ce) => ce.fieldId === V.id)
2713
2725
  );
2714
2726
  if (!Q) {
2715
- q(!1);
2727
+ X(!1);
2716
2728
  return;
2717
2729
  }
2718
- const Pt = gt && Q.signature_tag ? j.filter(
2719
- (V) => (V.type ?? "sign") === "sign" && V.signature_tag === Q.signature_tag && !k.some((ae) => ae.fieldId === V.id)
2720
- ) : [Q], $t = Pt.map((V) => ({
2721
- id: Oe(),
2730
+ const Ct = gt && Q.signature_tag ? B.filter(
2731
+ (V) => (V.type ?? "sign") === "sign" && V.signature_tag === Q.signature_tag && !N.some((ce) => ce.fieldId === V.id)
2732
+ ) : [Q], Tt = Ct.map((V) => ({
2733
+ id: Se(),
2722
2734
  fieldId: V.id,
2723
2735
  pageNumber: V.pageNumber,
2724
2736
  x: V.x,
@@ -2726,200 +2738,200 @@ function ro({
2726
2738
  width: V.width,
2727
2739
  height: V.height,
2728
2740
  imageDataUrl: c
2729
- })), ie = new Set(Pt.map((V) => V.id));
2730
- B((V) => [
2731
- ...V.filter((ae) => !ae.fieldId || !ie.has(ae.fieldId)),
2732
- ...$t
2741
+ })), re = new Set(Ct.map((V) => V.id));
2742
+ j((V) => [
2743
+ ...V.filter((ce) => !ce.fieldId || !re.has(ce.fieldId)),
2744
+ ...Tt
2733
2745
  ]);
2734
- const fe = new Map(
2735
- $t.map((V) => [V.fieldId, V])
2746
+ const ge = new Map(
2747
+ Tt.map((V) => [V.fieldId, V])
2736
2748
  );
2737
- Ie(
2738
- Pt.map((V) => V.id),
2739
- $t[0],
2740
- fe
2741
- ), At(null), D("none"), It(((ue = $t[0]) == null ? void 0 : ue.id) ?? null);
2742
- const mt = new Set(
2743
- j.filter(
2744
- (V) => Ce(
2749
+ Le(
2750
+ Ct.map((V) => V.id),
2751
+ Tt[0],
2752
+ ge
2753
+ ), At(null), D("none"), Nt(((pe = Tt[0]) == null ? void 0 : pe.id) ?? null);
2754
+ const wt = new Set(
2755
+ B.filter(
2756
+ (V) => De(
2745
2757
  V,
2746
- [...k, ...$t],
2747
- zt
2758
+ [...N, ...Tt],
2759
+ Xt
2748
2760
  )
2749
2761
  ).map((V) => V.id)
2750
2762
  );
2751
- for (const V of ie) mt.add(V);
2752
- Ue(Q.id, mt);
2763
+ for (const V of re) wt.add(V);
2764
+ Be(Q.id, wt);
2753
2765
  return;
2754
2766
  }
2755
- const N = X.current.get(it), $ = N == null ? void 0 : N.querySelector(
2767
+ const k = G.current.get(dt), $ = k == null ? void 0 : k.querySelector(
2756
2768
  ".epochs-pdf-viewer__surface"
2757
2769
  );
2758
- let W = 24, ot = 24;
2770
+ let z = 24, ot = 24;
2759
2771
  if ($) {
2760
- const Q = Ne($, f), Pt = $.closest(".epochs-pdf-viewer__body");
2761
- if (Pt) {
2762
- const $t = Mn(
2763
- Pt.getBoundingClientRect(),
2772
+ const Q = Ce($, kt), Ct = $.closest(".epochs-pdf-viewer__body");
2773
+ if (Ct) {
2774
+ const Tt = Pn(
2775
+ Ct.getBoundingClientRect(),
2764
2776
  $,
2765
- f
2766
- ), ie = Math.max(0, $t.top), fe = Math.min(Q.height, $t.bottom), mt = Math.max(0, $t.left), V = Math.min(Q.width, $t.right);
2767
- W = Math.max(0, (mt + V) / 2 - p.width / 2), ot = Math.max(0, (ie + fe) / 2 - p.height / 2), W = Math.min(W, Math.max(0, Q.width - p.width)), ot = Math.min(ot, Math.max(0, Q.height - p.height));
2777
+ kt
2778
+ ), re = Math.max(0, Tt.top), ge = Math.min(Q.height, Tt.bottom), wt = Math.max(0, Tt.left), V = Math.min(Q.width, Tt.right);
2779
+ z = Math.max(0, (wt + V) / 2 - f.width / 2), ot = Math.max(0, (re + ge) / 2 - f.height / 2), z = Math.min(z, Math.max(0, Q.width - f.width)), ot = Math.min(ot, Math.max(0, Q.height - f.height));
2768
2780
  } else
2769
- W = Math.max(0, (Q.width - p.width) / 2), ot = Math.max(0, (Q.height - p.height) / 2);
2781
+ z = Math.max(0, (Q.width - f.width) / 2), ot = Math.max(0, (Q.height - f.height) / 2);
2770
2782
  }
2771
2783
  const Ot = {
2772
- id: Oe(),
2773
- pageNumber: it,
2774
- x: W,
2784
+ id: Se(),
2785
+ pageNumber: dt,
2786
+ x: z,
2775
2787
  y: ot,
2776
- width: p.width,
2777
- height: p.height,
2788
+ width: f.width,
2789
+ height: f.height,
2778
2790
  imageDataUrl: c
2779
2791
  };
2780
- B((Q) => [...Q, Ot]), Ie(void 0, Ot), It(Ot.id), At(null), D("none"), q(!1), Gt(null);
2792
+ j((Q) => [...Q, Ot]), Le(void 0, Ot), Nt(Ot.id), At(null), D("none"), X(!1), Gt(null);
2781
2793
  },
2782
2794
  [
2783
- Ue,
2795
+ Be,
2784
2796
  gt,
2785
- oe,
2786
- zt,
2797
+ Yt,
2798
+ Xt,
2787
2799
  jt,
2788
- Ce,
2789
- it,
2790
- f,
2791
- bt,
2792
- j,
2793
- k,
2794
- Ie
2800
+ De,
2801
+ dt,
2802
+ kt,
2803
+ _t,
2804
+ B,
2805
+ N,
2806
+ Le
2795
2807
  ]
2796
- ), Pi = K(
2808
+ ), $i = Y(
2797
2809
  (c, h) => {
2798
2810
  if (jt) {
2799
- const Q = j.find(
2800
- (mt) => mt.id === bt && (mt.type ?? "sign") === h
2801
- ) ?? j.find((mt) => (mt.type ?? "sign") === h);
2811
+ const Q = B.find(
2812
+ (wt) => wt.id === _t && (wt.type ?? "sign") === h
2813
+ ) ?? B.find((wt) => (wt.type ?? "sign") === h);
2802
2814
  if (!Q) {
2803
- q(!1);
2815
+ X(!1);
2804
2816
  return;
2805
2817
  }
2806
- const $t = (gt && Q.signature_tag ? j.filter(
2807
- (mt) => (mt.type ?? "sign") === h && mt.signature_tag === Q.signature_tag
2808
- ) : [Q]).map((mt) => mt.id);
2809
- hn($t, c);
2810
- const ie = { ...zt };
2811
- for (const mt of $t) ie[mt] = c;
2812
- const fe = new Set(
2813
- j.filter(
2814
- (mt) => Ce(mt, k, ie)
2815
- ).map((mt) => mt.id)
2818
+ const Tt = (gt && Q.signature_tag ? B.filter(
2819
+ (wt) => (wt.type ?? "sign") === h && wt.signature_tag === Q.signature_tag
2820
+ ) : [Q]).map((wt) => wt.id);
2821
+ pn(Tt, c);
2822
+ const re = { ...Xt };
2823
+ for (const wt of Tt) re[wt] = c;
2824
+ const ge = new Set(
2825
+ B.filter(
2826
+ (wt) => De(wt, N, re)
2827
+ ).map((wt) => wt.id)
2816
2828
  );
2817
- Ue(Q.id, fe);
2829
+ Be(Q.id, ge);
2818
2830
  return;
2819
2831
  }
2820
- const l = ge, p = Math.max(80, c.length * l * 0.55), N = l * 1.25;
2821
- let $ = 24, W = 24;
2822
- const ot = X.current.get(it), Ot = ot == null ? void 0 : ot.querySelector(
2832
+ const l = we, f = Math.max(80, c.length * l * 0.55), k = l * 1.25;
2833
+ let $ = 24, z = 24;
2834
+ const ot = G.current.get(dt), Ot = ot == null ? void 0 : ot.querySelector(
2823
2835
  ".epochs-pdf-viewer__surface"
2824
2836
  );
2825
2837
  if (Ot) {
2826
- const Q = Ne(Ot, f), Pt = Ot.closest(
2838
+ const Q = Ce(Ot, kt), Ct = Ot.closest(
2827
2839
  ".epochs-pdf-viewer__body"
2828
2840
  );
2829
- if (Pt) {
2830
- const $t = Mn(
2831
- Pt.getBoundingClientRect(),
2841
+ if (Ct) {
2842
+ const Tt = Pn(
2843
+ Ct.getBoundingClientRect(),
2832
2844
  Ot,
2833
- f
2834
- ), ie = Math.max(0, $t.top), fe = Math.min(Q.height, $t.bottom), mt = Math.max(0, $t.left), V = Math.min(Q.width, $t.right);
2835
- $ = Math.max(0, (mt + V) / 2 - p / 2), W = Math.max(0, (ie + fe) / 2 - N / 2), $ = Math.min($, Math.max(0, Q.width - p)), W = Math.min(W, Math.max(0, Q.height - N));
2845
+ kt
2846
+ ), re = Math.max(0, Tt.top), ge = Math.min(Q.height, Tt.bottom), wt = Math.max(0, Tt.left), V = Math.min(Q.width, Tt.right);
2847
+ $ = Math.max(0, (wt + V) / 2 - f / 2), z = Math.max(0, (re + ge) / 2 - k / 2), $ = Math.min($, Math.max(0, Q.width - f)), z = Math.min(z, Math.max(0, Q.height - k));
2836
2848
  }
2837
2849
  }
2838
- const ue = {
2839
- id: We(),
2840
- pageNumber: it,
2850
+ const pe = {
2851
+ id: Ge(),
2852
+ pageNumber: dt,
2841
2853
  x: $,
2842
- y: W,
2843
- width: p,
2844
- height: N,
2854
+ y: z,
2855
+ width: f,
2856
+ height: k,
2845
2857
  value: c,
2846
2858
  fontSize: l,
2847
- color: pe
2859
+ color: me
2848
2860
  };
2849
- L((Q) => [...Q, ue]), Et(ue.id), q(!1), D("none");
2861
+ R((Q) => [...Q, pe]), se(pe.id), X(!1), D("none");
2850
2862
  },
2851
2863
  [
2852
- Ue,
2864
+ Be,
2853
2865
  gt,
2854
- zt,
2866
+ Xt,
2855
2867
  jt,
2856
- Ce,
2857
- it,
2858
- f,
2859
- bt,
2860
- j,
2861
- k,
2862
- hn
2868
+ De,
2869
+ dt,
2870
+ kt,
2871
+ _t,
2872
+ B,
2873
+ N,
2874
+ pn
2863
2875
  ]
2864
- ), $i = K((c) => {
2865
- B((h) => [...h, c]), Ie(void 0, c), It(c.id), At(null), D("none");
2866
- }, [Ie]), Ci = K(
2876
+ ), Ii = Y((c) => {
2877
+ j((h) => [...h, c]), Le(void 0, c), Nt(c.id), At(null), D("none");
2878
+ }, [Le]), Ci = Y(
2867
2879
  (c, h) => {
2868
- B(
2869
- (l) => l.map((p) => p.id === c ? { ...p, ...h } : p)
2880
+ j(
2881
+ (l) => l.map((f) => f.id === c ? { ...f, ...h } : f)
2870
2882
  );
2871
2883
  },
2872
2884
  []
2873
- ), Ii = K((c) => {
2874
- const h = k.find((l) => l.id === c);
2875
- B((l) => l.filter((p) => p.id !== c)), It((l) => l === c ? null : l), h != null && h.fieldId && Qt(h.fieldId);
2876
- }, [k]), Ti = K((c) => {
2877
- const h = c ? k.find((Ot) => Ot.id === c) ?? null : ve;
2885
+ ), Ti = Y((c) => {
2886
+ const h = N.find((l) => l.id === c);
2887
+ j((l) => l.filter((f) => f.id !== c)), Nt((l) => l === c ? null : l), h != null && h.fieldId && Ut(h.fieldId);
2888
+ }, [N]), Di = Y((c) => {
2889
+ const h = c ? N.find((Ot) => Ot.id === c) ?? null : Ne;
2878
2890
  if (!h) return;
2879
- const l = X.current.get(h.pageNumber), p = l == null ? void 0 : l.querySelector(
2891
+ const l = G.current.get(h.pageNumber), f = l == null ? void 0 : l.querySelector(
2880
2892
  ".epochs-pdf-viewer__surface"
2881
- ), N = 18;
2882
- let $ = h.x + N, W = h.y + N;
2883
- if (p) {
2884
- const Ot = p.clientWidth / f, ue = p.clientHeight / f;
2893
+ ), k = 18;
2894
+ let $ = h.x + k, z = h.y + k;
2895
+ if (f) {
2896
+ const Ot = f.clientWidth / kt, pe = f.clientHeight / kt;
2885
2897
  $ = Math.min(
2886
2898
  Math.max(0, $),
2887
2899
  Math.max(0, Ot - h.width)
2888
- ), W = Math.min(
2889
- Math.max(0, W),
2890
- Math.max(0, ue - h.height)
2900
+ ), z = Math.min(
2901
+ Math.max(0, z),
2902
+ Math.max(0, pe - h.height)
2891
2903
  );
2892
2904
  }
2893
2905
  const ot = {
2894
2906
  ...h,
2895
- id: Oe(),
2907
+ id: Se(),
2896
2908
  x: $,
2897
- y: W
2909
+ y: z
2898
2910
  };
2899
- B((Ot) => [...Ot, ot]), It(ot.id), At(null), D("none");
2900
- }, [f, ve, k]), Li = K((c) => {
2901
- const h = c ?? (ve == null ? void 0 : ve.id);
2911
+ j((Ot) => [...Ot, ot]), Nt(ot.id), At(null), D("none");
2912
+ }, [kt, Ne, N]), Li = Y((c) => {
2913
+ const h = c ?? (Ne == null ? void 0 : Ne.id);
2902
2914
  if (!h) return;
2903
- const l = k.find((N) => N.id === h), p = l != null && l.fieldId ? j.find((N) => N.id === l.fieldId) : void 0;
2904
- vt((p == null ? void 0 : p.type) ?? "sign"), It(h), Gt(h), q(!0);
2905
- }, [ve, k, j]), Di = K((c) => {
2906
- L((h) => c.fieldId ? [...h.filter((l) => l.fieldId !== c.fieldId), c] : [...h, c]), Et(c.id), c.fieldId && Pe(c.fieldId);
2907
- }, []), Fi = K(
2915
+ const l = N.find((k) => k.id === h), f = l != null && l.fieldId ? B.find((k) => k.id === l.fieldId) : void 0;
2916
+ ft((f == null ? void 0 : f.type) ?? "sign"), Nt(h), Gt(h), X(!0);
2917
+ }, [Ne, N, B]), Fi = Y((c) => {
2918
+ R((h) => c.fieldId ? [...h.filter((l) => l.fieldId !== c.fieldId), c] : [...h, c]), se(c.id), c.fieldId && de(c.fieldId);
2919
+ }, []), Ri = Y(
2908
2920
  (c, h) => {
2909
- L(
2910
- (l) => l.map((p) => p.id === c ? { ...p, ...h } : p)
2921
+ R(
2922
+ (l) => l.map((f) => f.id === c ? { ...f, ...h } : f)
2911
2923
  );
2912
2924
  },
2913
2925
  []
2914
- ), Ri = K((c) => {
2915
- const h = G.find((l) => l.id === c);
2916
- L((l) => l.filter((p) => p.id !== c)), Et((l) => l === c ? null : l), Ee((l) => l === c ? null : l), h != null && h.fieldId && Pe(h.fieldId);
2917
- }, [G]);
2918
- Tt(() => {
2919
- $e && L(
2926
+ ), Ai = Y((c) => {
2927
+ const h = Z.find((l) => l.id === c);
2928
+ R((l) => l.filter((f) => f.id !== c)), se((l) => l === c ? null : l), he((l) => l === c ? null : l), h != null && h.fieldId && de(h.fieldId);
2929
+ }, [Z]);
2930
+ Dt(() => {
2931
+ Te && R(
2920
2932
  (c) => c.map((h) => {
2921
2933
  if (!h.fieldId) return h;
2922
- const l = U.find((p) => p.id === h.fieldId);
2934
+ const l = E.find((f) => f.id === h.fieldId);
2923
2935
  return l ? {
2924
2936
  ...h,
2925
2937
  pageNumber: l.pageNumber,
@@ -2927,32 +2939,32 @@ function ro({
2927
2939
  y: l.y,
2928
2940
  width: l.width,
2929
2941
  height: l.height,
2930
- fontSize: l.fontSize ?? h.fontSize ?? ge,
2931
- color: l.color ?? h.color ?? pe
2942
+ fontSize: l.fontSize ?? h.fontSize ?? we,
2943
+ color: l.color ?? h.color ?? me
2932
2944
  } : h;
2933
2945
  })
2934
2946
  );
2935
- }, [$e, U]);
2936
- const wn = K(
2947
+ }, [Te, E]);
2948
+ const _n = Y(
2937
2949
  (c) => {
2938
- var N;
2939
- if (!j.length) return;
2940
- const h = bt != null ? j.findIndex(($) => $.id === bt) : -1, l = Math.min(
2941
- j.length - 1,
2950
+ var k;
2951
+ if (!B.length) return;
2952
+ const h = _t != null ? B.findIndex(($) => $.id === _t) : -1, l = Math.min(
2953
+ B.length - 1,
2942
2954
  Math.max(0, (h < 0 ? 0 : h) + c)
2943
- ), p = j[l];
2944
- p && (Qt(p.id), It(
2945
- ((N = k.find(($) => $.fieldId === p.id)) == null ? void 0 : N.id) ?? null
2946
- ), be(p));
2955
+ ), f = B[l];
2956
+ f && (Ut(f.id), Nt(
2957
+ ((k = N.find(($) => $.fieldId === f.id)) == null ? void 0 : k.id) ?? null
2958
+ ), Me(f));
2947
2959
  },
2948
2960
  [
2949
- be,
2950
- bt,
2951
- j,
2952
- k
2961
+ Me,
2962
+ _t,
2963
+ B,
2964
+ N
2953
2965
  ]
2954
2966
  );
2955
- if (!Ft && !wt)
2967
+ if (!yt && !bt)
2956
2968
  return /* @__PURE__ */ s(
2957
2969
  "div",
2958
2970
  {
@@ -2961,66 +2973,66 @@ function ro({
2961
2973
  children: "No PDF file provided."
2962
2974
  }
2963
2975
  );
2964
- const Ai = {
2976
+ const Ei = {
2965
2977
  height: r
2966
- }, yn = {
2967
- status: st,
2968
- showThumbnails: Yt,
2969
- setShowThumbnails: Kt,
2970
- canGoPrev: Ve,
2971
- canGoNext: Ye,
2972
- handlePrev: di,
2973
- handleNext: hi,
2974
- pageNumber: it,
2975
- numPages: Ct,
2976
- scrollToPage: ye,
2977
- scale: f,
2978
- handleZoomOut: fi,
2979
- handleZoomIn: pi,
2980
- handleFitWidth: Ke,
2981
- handleRotate: ui,
2978
+ }, vn = {
2979
+ status: it,
2980
+ showThumbnails: Lt,
2981
+ setShowThumbnails: Zt,
2982
+ canGoPrev: Je,
2983
+ canGoNext: tn,
2984
+ handlePrev: hi,
2985
+ handleNext: ui,
2986
+ pageNumber: dt,
2987
+ numPages: It,
2988
+ scrollToPage: xe,
2989
+ scale: kt,
2990
+ handleZoomOut: pi,
2991
+ handleZoomIn: gi,
2992
+ handleFitWidth: en,
2993
+ handleRotate: fi,
2982
2994
  markupTool: M,
2983
- toggleMarkupTool: (c) => wi(c),
2995
+ toggleMarkupTool: (c) => yi(c),
2984
2996
  hasFixedSignatureFields: jt,
2985
- hasFixedTextFields: $e,
2986
- pendingSignature: Rt,
2997
+ hasFixedTextFields: Te,
2998
+ pendingSignature: Ht,
2987
2999
  setMarkupTool: D,
2988
- setSignaturePadOpen: q,
3000
+ setSignaturePadOpen: X,
2989
3001
  annotationsLength: P.length,
2990
- signaturesLength: k.length,
2991
- textsLength: G.length,
2992
- handleClearAnnotations: vi,
2993
- highlightHex: ln,
2994
- underlineHex: dn,
2995
- setHighlightHex: ci,
2996
- setUnderlineHex: li,
2997
- loadDocument: qe,
2998
- handlePrint: gi,
2999
- isPrinting: ne,
3000
- pdfDoc: nt,
3001
- displayUrl: ht,
3002
- resolvedUrl: wt,
3003
- handleDownload: mi,
3004
- isDownloading: y
3005
- }, Ei = (c) => c.filter((h) => !(jt && (h === "highlight" || h === "underline" || h === "erase"))), Ze = bt ? j.findIndex((c) => c.id === bt) : 0, Ui = j.filter(
3006
- (c) => Ce(c, k, zt)
3007
- ).length, Qe = j.length > 0 ? Math.round(Ui / j.length * 100) : 0, bn = (c, h = !1) => {
3008
- const l = Ei(c);
3002
+ signaturesLength: N.length,
3003
+ textsLength: Z.length,
3004
+ handleClearAnnotations: xi,
3005
+ highlightHex: _e,
3006
+ underlineHex: ae,
3007
+ setHighlightHex: Qt,
3008
+ setUnderlineHex: di,
3009
+ loadDocument: Qe,
3010
+ handlePrint: mi,
3011
+ isPrinting: ie,
3012
+ pdfDoc: st,
3013
+ displayUrl: U,
3014
+ resolvedUrl: bt,
3015
+ handleDownload: wi,
3016
+ isDownloading: w
3017
+ }, Hi = (c) => c.filter((h) => !(jt && (h === "highlight" || h === "underline" || h === "erase"))), nn = _t ? B.findIndex((c) => c.id === _t) : 0, Ui = B.filter(
3018
+ (c) => De(c, N, Xt)
3019
+ ).length, rn = B.length > 0 ? Math.round(Ui / B.length * 100) : 0, xn = (c, h = !1) => {
3020
+ const l = Hi(c);
3009
3021
  if (l.length === 0 && !h)
3010
3022
  return /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__toolbar-group" });
3011
3023
  if (l.length === 0)
3012
3024
  return /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__toolbar-group epochs-pdf-viewer__toolbar-group--end" });
3013
- const p = l.map((N, $) => {
3014
- const W = l[$ - 1], ot = Ln(N) && (!W || !Ln(W));
3015
- return /* @__PURE__ */ s(Bi, { children: Dr(N, yn, { showMarkupSep: ot }) }, N);
3025
+ const f = l.map((k, $) => {
3026
+ const z = l[$ - 1], ot = Rn(k) && (!z || !Rn(z));
3027
+ return /* @__PURE__ */ s(Wi, { children: Fr(k, vn, { showMarkupSep: ot }) }, k);
3016
3028
  });
3017
3029
  return /* @__PURE__ */ T(
3018
3030
  "div",
3019
3031
  {
3020
3032
  className: h ? "epochs-pdf-viewer__toolbar-group epochs-pdf-viewer__toolbar-group--end" : "epochs-pdf-viewer__toolbar-group",
3021
3033
  children: [
3022
- p,
3023
- Fr(yn, new Set(l))
3034
+ f,
3035
+ Rr(vn, new Set(l))
3024
3036
  ]
3025
3037
  }
3026
3038
  );
@@ -3029,69 +3041,69 @@ function ro({
3029
3041
  "div",
3030
3042
  {
3031
3043
  "data-testid": "pdf-viewer",
3032
- "data-file-url": wt || void 0,
3044
+ "data-file-url": bt || void 0,
3033
3045
  className: `epochs-pdf-viewer ${_ ?? ""}`.trim(),
3034
- style: Ai,
3046
+ style: Ei,
3035
3047
  children: [
3036
- de ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__toolbar", children: [
3037
- bn(de.left),
3038
- bn(de.right, !0)
3048
+ ue ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__toolbar", children: [
3049
+ xn(ue.left),
3050
+ xn(ue.right, !0)
3039
3051
  ] }) : null,
3040
- Ge || kt || jt ? /* @__PURE__ */ s(
3052
+ Ze || Pt || jt ? /* @__PURE__ */ s(
3041
3053
  Cr,
3042
3054
  {
3043
- open: rt,
3055
+ open: lt,
3044
3056
  onClose: () => {
3045
- q(!1), Gt(null), vt(void 0), lt == null || lt();
3057
+ X(!1), Gt(null), ft(void 0), ut == null || ut();
3046
3058
  },
3047
- onSave: Ni,
3048
- onSaveFieldValue: Pi,
3049
- fieldType: ut,
3059
+ onSave: Pi,
3060
+ onSaveFieldValue: $i,
3061
+ fieldType: et,
3050
3062
  showFieldTypeTabs: !jt,
3051
- textPlaceholder: (_n = j.find((c) => c.id === bt)) == null ? void 0 : _n.placeholder,
3052
- initialFieldValue: bt ? zt[bt] ?? ((vn = j.find((c) => c.id === bt)) == null ? void 0 : vn.value) : void 0,
3063
+ textPlaceholder: (Mn = B.find((c) => c.id === _t)) == null ? void 0 : Mn.placeholder,
3064
+ initialFieldValue: _t ? Xt[_t] ?? ((kn = B.find((c) => c.id === _t)) == null ? void 0 : kn.value) : void 0,
3053
3065
  targetSize: (() => {
3054
- const c = j.find(
3055
- (h) => h.id === bt
3066
+ const c = B.find(
3067
+ (h) => h.id === _t
3056
3068
  );
3057
3069
  if (!(!c || (c.type ?? "sign") !== "sign"))
3058
3070
  return { width: c.width, height: c.height };
3059
3071
  })(),
3060
- rememberedByType: Xt,
3072
+ rememberedByType: Ft,
3061
3073
  onRememberFill: (c, h) => {
3062
- Nt((l) => c === "sign" ? { ...l, sign: h } : c === "date" ? { ...l, date: h } : { ...l, text: h });
3074
+ Rt((l) => c === "sign" ? { ...l, sign: h } : c === "date" ? { ...l, date: h } : { ...l, text: h });
3063
3075
  }
3064
3076
  }
3065
3077
  ) : null,
3066
3078
  /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__content", children: [
3067
- Yt ? /* @__PURE__ */ s(
3079
+ Lt ? /* @__PURE__ */ s(
3068
3080
  "div",
3069
3081
  {
3070
3082
  className: "epochs-pdf-viewer__thumbnails",
3071
3083
  style: { width: m + 24 },
3072
- children: st === "ready" && nt ? /* @__PURE__ */ T(Ae, { children: [
3084
+ children: it === "ready" && st ? /* @__PURE__ */ T(je, { children: [
3073
3085
  Array.from({
3074
- length: Math.min(Ct || 0, g)
3086
+ length: Math.min(It || 0, g)
3075
3087
  }).map((c, h) => {
3076
3088
  const l = h + 1;
3077
3089
  return /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__thumb-wrap", children: /* @__PURE__ */ s(
3078
- yr,
3090
+ br,
3079
3091
  {
3080
- pdfDoc: nt,
3092
+ pdfDoc: st,
3081
3093
  pageNumber: l,
3082
- isActive: l === it,
3083
- rotation: A,
3084
- onSelect: ye,
3094
+ isActive: l === dt,
3095
+ rotation: p,
3096
+ onSelect: xe,
3085
3097
  width: m,
3086
3098
  annotations: P,
3087
- signatures: k,
3088
- signatureFields: j,
3089
- texts: _e,
3090
- textFields: U
3099
+ signatures: N,
3100
+ signatureFields: B,
3101
+ texts: ke,
3102
+ textFields: E
3091
3103
  }
3092
3104
  ) }, l);
3093
3105
  }),
3094
- Ct > g ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__thumb-more", children: [
3106
+ It > g ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__thumb-more", children: [
3095
3107
  "Showing first ",
3096
3108
  g,
3097
3109
  " pages"
@@ -3099,69 +3111,69 @@ function ro({
3099
3111
  ] }) : /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__muted", children: "Thumbnails" })
3100
3112
  }
3101
3113
  ) : null,
3102
- /* @__PURE__ */ T("div", { ref: Ut, className: "epochs-pdf-viewer__body", children: [
3103
- st === "loading" ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__overlay epochs-pdf-viewer__muted", children: [
3114
+ /* @__PURE__ */ T("div", { ref: qt, className: "epochs-pdf-viewer__body", children: [
3115
+ it === "loading" ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__overlay epochs-pdf-viewer__muted", children: [
3104
3116
  "Loading PDF…",
3105
3117
  /* @__PURE__ */ s("span", { className: "epochs-pdf-viewer__spinner" })
3106
3118
  ] }) : null,
3107
- st === "error" ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__overlay epochs-pdf-viewer__error", children: [
3119
+ it === "error" ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__overlay epochs-pdf-viewer__error", children: [
3108
3120
  "Unable to load PDF.",
3109
- wt ? /* @__PURE__ */ s(
3121
+ bt ? /* @__PURE__ */ s(
3110
3122
  "a",
3111
3123
  {
3112
3124
  className: "epochs-pdf-viewer__open-link",
3113
- href: wt,
3125
+ href: bt,
3114
3126
  target: "_blank",
3115
3127
  rel: "noopener noreferrer",
3116
3128
  children: "Open file"
3117
3129
  }
3118
3130
  ) : null
3119
3131
  ] }) : null,
3120
- st === "ready" && nt ? /* @__PURE__ */ s("div", { children: Array.from({ length: Ct }).map((c, h) => {
3132
+ it === "ready" && st ? /* @__PURE__ */ s("div", { children: Array.from({ length: It }).map((c, h) => {
3121
3133
  const l = h + 1;
3122
3134
  return /* @__PURE__ */ s(
3123
- wr,
3135
+ yr,
3124
3136
  {
3125
- pdfDoc: nt,
3137
+ pdfDoc: st,
3126
3138
  pageNumber: l,
3127
- scale: f,
3128
- rotation: A,
3139
+ scale: kt,
3140
+ rotation: p,
3129
3141
  markupTool: at ? M : "none",
3130
- markupColor: yi,
3142
+ markupColor: bi,
3131
3143
  annotations: P,
3132
- onAddAnnotation: bi,
3133
- onRemoveAnnotation: _i,
3134
- signatures: k,
3135
- pendingSignature: Rt,
3136
- onAddSignature: $i,
3144
+ onAddAnnotation: _i,
3145
+ onRemoveAnnotation: vi,
3146
+ signatures: N,
3147
+ pendingSignature: Ht,
3148
+ onAddSignature: Ii,
3137
3149
  onUpdateSignature: Ci,
3138
- onRemoveSignature: Ii,
3150
+ onRemoveSignature: Ti,
3139
3151
  onEditSignature: Li,
3140
- onDuplicateSignature: Ti,
3141
- selectedSignatureId: Zt,
3142
- onSelectSignature: It,
3143
- signatureFields: j,
3144
- selectedSignatureFieldId: bt,
3145
- onSelectSignatureField: Qt,
3152
+ onDuplicateSignature: Di,
3153
+ selectedSignatureId: St,
3154
+ onSelectSignature: Nt,
3155
+ signatureFields: B,
3156
+ selectedSignatureFieldId: _t,
3157
+ onSelectSignatureField: Ut,
3146
3158
  hasFixedSignatureFields: jt,
3147
- onOpenSignaturePad: xi,
3148
- fieldValues: zt,
3149
- onFieldValueChange: Mi,
3150
- onFieldValueCommit: ki,
3151
- texts: G,
3152
- onAddText: Di,
3153
- onUpdateText: Fi,
3154
- onRemoveText: Ri,
3155
- selectedTextId: se,
3156
- onSelectText: Et,
3157
- textFields: U,
3158
- selectedTextFieldId: le,
3159
- onSelectTextField: Pe,
3160
- hasFixedTextFields: $e,
3161
- editingTextId: ai,
3162
- onEditingTextIdChange: Ee,
3163
- pageRef: (p) => {
3164
- p && X.current.set(l, p);
3159
+ onOpenSignaturePad: Mi,
3160
+ fieldValues: Xt,
3161
+ onFieldValueChange: ki,
3162
+ onFieldValueCommit: Ni,
3163
+ texts: Z,
3164
+ onAddText: Fi,
3165
+ onUpdateText: Ri,
3166
+ onRemoveText: Ai,
3167
+ selectedTextId: be,
3168
+ onSelectText: se,
3169
+ textFields: E,
3170
+ selectedTextFieldId: Ve,
3171
+ onSelectTextField: de,
3172
+ hasFixedTextFields: Te,
3173
+ editingTextId: qe,
3174
+ onEditingTextIdChange: he,
3175
+ pageRef: (f) => {
3176
+ f && G.current.set(l, f);
3165
3177
  }
3166
3178
  },
3167
3179
  l
@@ -3170,15 +3182,15 @@ function ro({
3170
3182
  ] })
3171
3183
  ] }),
3172
3184
  jt || te ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__footer", role: "navigation", "aria-label": "Viewer actions", children: [
3173
- jt ? /* @__PURE__ */ T(Ae, { children: [
3185
+ jt ? /* @__PURE__ */ T(je, { children: [
3174
3186
  /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__footer-nav", children: [
3175
3187
  /* @__PURE__ */ s(
3176
3188
  "button",
3177
3189
  {
3178
3190
  type: "button",
3179
3191
  className: "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
3180
- disabled: j.length <= 1 || Ze <= 0,
3181
- onClick: () => wn(-1),
3192
+ disabled: B.length <= 1 || nn <= 0,
3193
+ onClick: () => _n(-1),
3182
3194
  children: "Prev"
3183
3195
  }
3184
3196
  ),
@@ -3187,8 +3199,8 @@ function ro({
3187
3199
  {
3188
3200
  type: "button",
3189
3201
  className: "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
3190
- disabled: j.length <= 1 || Ze >= j.length - 1,
3191
- onClick: () => wn(1),
3202
+ disabled: B.length <= 1 || nn >= B.length - 1,
3203
+ onClick: () => _n(1),
3192
3204
  children: "Next"
3193
3205
  }
3194
3206
  )
@@ -3196,9 +3208,9 @@ function ro({
3196
3208
  /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__footer-center", children: [
3197
3209
  /* @__PURE__ */ T("span", { className: "epochs-pdf-viewer__footer-label", children: [
3198
3210
  "Field ",
3199
- Math.max(1, Ze + 1),
3211
+ Math.max(1, nn + 1),
3200
3212
  " of ",
3201
- j.length
3213
+ B.length
3202
3214
  ] }),
3203
3215
  /* @__PURE__ */ s(
3204
3216
  "div",
@@ -3207,19 +3219,19 @@ function ro({
3207
3219
  role: "progressbar",
3208
3220
  "aria-valuemin": 0,
3209
3221
  "aria-valuemax": 100,
3210
- "aria-valuenow": Qe,
3222
+ "aria-valuenow": rn,
3211
3223
  "aria-label": "Signature progress",
3212
3224
  children: /* @__PURE__ */ s(
3213
3225
  "div",
3214
3226
  {
3215
3227
  className: "epochs-pdf-viewer__footer-progress-bar",
3216
- style: { width: `${Qe}%` }
3228
+ style: { width: `${rn}%` }
3217
3229
  }
3218
3230
  )
3219
3231
  }
3220
3232
  ),
3221
3233
  /* @__PURE__ */ T("span", { className: "epochs-pdf-viewer__footer-percent", children: [
3222
- Qe,
3234
+ rn,
3223
3235
  "%"
3224
3236
  ] })
3225
3237
  ] })
@@ -3230,17 +3242,17 @@ function ro({
3230
3242
  type: "button",
3231
3243
  className: "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text epochs-pdf-viewer__btn--primary",
3232
3244
  onClick: te,
3233
- disabled: St,
3234
- "aria-busy": St || void 0,
3245
+ disabled: Vt,
3246
+ "aria-busy": Vt || void 0,
3235
3247
  children: [
3236
- St ? /* @__PURE__ */ s(
3248
+ Vt ? /* @__PURE__ */ s(
3237
3249
  "span",
3238
3250
  {
3239
3251
  className: "epochs-pdf-viewer__spinner epochs-pdf-viewer__spinner--btn",
3240
3252
  "aria-hidden": "true"
3241
3253
  }
3242
3254
  ) : null,
3243
- me
3255
+ ye
3244
3256
  ]
3245
3257
  }
3246
3258
  ) : null
@@ -3249,30 +3261,30 @@ function ro({
3249
3261
  }
3250
3262
  );
3251
3263
  }
3252
- function Ar(t) {
3264
+ function Er(t) {
3253
3265
  return null;
3254
3266
  }
3255
- Ar.displayName = "Document";
3256
- function Er(t) {
3267
+ Er.displayName = "Document";
3268
+ function Hr(t) {
3257
3269
  return null;
3258
3270
  }
3259
- Er.displayName = "Page";
3271
+ Hr.displayName = "Page";
3260
3272
  function Ur(t) {
3261
3273
  return null;
3262
3274
  }
3263
3275
  Ur.displayName = "View";
3264
- function Hr(t) {
3265
- return null;
3266
- }
3267
- Hr.displayName = "Text";
3268
3276
  function jr(t) {
3269
3277
  return null;
3270
3278
  }
3271
- jr.displayName = "Image";
3279
+ jr.displayName = "Text";
3272
3280
  function Br(t) {
3273
3281
  return null;
3274
3282
  }
3275
- Br.displayName = "Link";
3283
+ Br.displayName = "Image";
3284
+ function Wr(t) {
3285
+ return null;
3286
+ }
3287
+ Wr.displayName = "Link";
3276
3288
  const Or = {
3277
3289
  Document: "DOCUMENT",
3278
3290
  Page: "PAGE",
@@ -3281,7 +3293,7 @@ const Or = {
3281
3293
  Image: "IMAGE",
3282
3294
  Link: "LINK"
3283
3295
  };
3284
- function Wr(t) {
3296
+ function zr(t) {
3285
3297
  if (typeof t == "string") return t;
3286
3298
  if (typeof t == "function") {
3287
3299
  const e = t;
@@ -3289,7 +3301,7 @@ function Wr(t) {
3289
3301
  }
3290
3302
  return null;
3291
3303
  }
3292
- function ti(t) {
3304
+ function ii(t) {
3293
3305
  const e = [], n = (i) => {
3294
3306
  if (!(i == null || typeof i == "boolean")) {
3295
3307
  if (Array.isArray(i)) {
@@ -3301,11 +3313,11 @@ function ti(t) {
3301
3313
  };
3302
3314
  return n(t), e;
3303
3315
  }
3304
- function ei(t) {
3305
- return ti(t).map((e) => typeof e == "string" || typeof e == "number" ? String(e) : e && typeof e == "object" && "props" in e ? ei(e.props.children) : "").join("");
3316
+ function ri(t) {
3317
+ return ii(t).map((e) => typeof e == "string" || typeof e == "number" ? String(e) : e && typeof e == "object" && "props" in e ? ri(e.props.children) : "").join("");
3306
3318
  }
3307
- function ni(t) {
3308
- const e = Wr(t.type), n = e ? Or[e] : void 0;
3319
+ function oi(t) {
3320
+ const e = zr(t.type), n = e ? Or[e] : void 0;
3309
3321
  if (!n)
3310
3322
  throw new Error(
3311
3323
  `[epochs-pdf] Unsupported element "${e ?? "unknown"}". Use Document, Page, View, Text, Image, or Link.`
@@ -3316,27 +3328,27 @@ function ni(t) {
3316
3328
  type: n,
3317
3329
  props: i,
3318
3330
  children: [],
3319
- text: ei(r)
3331
+ text: ri(r)
3320
3332
  };
3321
- const o = ti(r).filter(
3333
+ const o = ii(r).filter(
3322
3334
  (d) => !!d && typeof d == "object" && "type" in d
3323
- ).map(ni);
3335
+ ).map(oi);
3324
3336
  return {
3325
3337
  type: n,
3326
3338
  props: i,
3327
3339
  children: o
3328
3340
  };
3329
3341
  }
3330
- const zr = {
3342
+ const Sr = {
3331
3343
  A4: [595.28, 841.89],
3332
3344
  LETTER: [612, 792],
3333
3345
  LEGAL: [612, 1008]
3334
3346
  };
3335
- function Sr(t = "A4", e = "portrait") {
3336
- const [n, i] = Array.isArray(t) ? t : zr[t];
3347
+ function Gr(t = "A4", e = "portrait") {
3348
+ const [n, i] = Array.isArray(t) ? t : Sr[t];
3337
3349
  return e === "landscape" ? [i, n] : [n, i];
3338
3350
  }
3339
- function ii(t = {}) {
3351
+ function si(t = {}) {
3340
3352
  const e = t.padding ?? 0;
3341
3353
  return {
3342
3354
  top: t.paddingTop ?? e,
@@ -3345,7 +3357,7 @@ function ii(t = {}) {
3345
3357
  left: t.paddingLeft ?? e
3346
3358
  };
3347
3359
  }
3348
- function De(t = {}) {
3360
+ function Ae(t = {}) {
3349
3361
  const e = t.margin ?? 0;
3350
3362
  return {
3351
3363
  top: t.marginTop ?? e,
@@ -3354,7 +3366,7 @@ function De(t = {}) {
3354
3366
  left: t.marginLeft ?? e
3355
3367
  };
3356
3368
  }
3357
- function Be(t) {
3369
+ function ze(t) {
3358
3370
  if (!t) return null;
3359
3371
  const e = t.trim();
3360
3372
  if (e.startsWith("#")) {
@@ -3377,7 +3389,7 @@ function Be(t) {
3377
3389
  Math.min(1, Number(n[3]) / 255)
3378
3390
  ] : null;
3379
3391
  }
3380
- function Me(t, e, n = 0) {
3392
+ function $e(t, e, n = 0) {
3381
3393
  if (t == null) return n;
3382
3394
  if (typeof t == "number") return t;
3383
3395
  if (t.endsWith("%")) {
@@ -3387,19 +3399,19 @@ function Me(t, e, n = 0) {
3387
3399
  const i = Number.parseFloat(t);
3388
3400
  return Number.isFinite(i) ? i : n;
3389
3401
  }
3390
- function an(t) {
3402
+ function un(t) {
3391
3403
  return t === "bold" ? !0 : typeof t == "number" ? t >= 600 : !1;
3392
3404
  }
3393
- const Xr = 12, Gr = 1.4, qr = 0.5;
3394
- function ri(t, e, n) {
3395
- const i = e.fontSize ?? Xr, r = (e.lineHeight ?? Gr) * i, o = i * (an(e.fontWeight) ? 0.55 : qr);
3405
+ const Xr = 12, Vr = 1.4, qr = 0.5;
3406
+ function ai(t, e, n) {
3407
+ const i = e.fontSize ?? Xr, r = (e.lineHeight ?? Vr) * i, o = i * (un(e.fontWeight) ? 0.55 : qr);
3396
3408
  if (!t)
3397
3409
  return { width: 0, height: r, lines: [""] };
3398
3410
  const d = t.split(/\s+/), u = [];
3399
3411
  let m = "";
3400
3412
  for (const _ of d) {
3401
- const w = m ? `${m} ${_}` : _;
3402
- w.length * o <= n || !m ? m = w : (u.push(m), m = _);
3413
+ const y = m ? `${m} ${_}` : _;
3414
+ y.length * o <= n || !m ? m = y : (u.push(m), m = _);
3403
3415
  }
3404
3416
  m && u.push(m);
3405
3417
  const g = Math.max(...u.map((_) => _.length * o), 0);
@@ -3409,13 +3421,13 @@ function ri(t, e, n) {
3409
3421
  lines: u
3410
3422
  };
3411
3423
  }
3412
- function oi(t, e, n, i, r) {
3413
- const o = t.props.style ?? {}, d = De(o), u = ii(o), m = e + d.left, g = n + d.top, _ = Math.max(
3424
+ function ci(t, e, n, i, r) {
3425
+ const o = t.props.style ?? {}, d = Ae(o), u = si(o), m = e + d.left, g = n + d.top, _ = Math.max(
3414
3426
  0,
3415
- Me(o.width, i, i) - d.left - d.right
3416
- ), w = Math.max(0, _ - u.left - u.right);
3427
+ $e(o.width, i, i) - d.left - d.right
3428
+ ), y = Math.max(0, _ - u.left - u.right);
3417
3429
  if (t.type === "TEXT" || t.type === "LINK") {
3418
- const U = ri(t.text ?? "", o, w), ct = Me(o.height, r, U.height + u.top + u.bottom);
3430
+ const E = ai(t.text ?? "", o, y), ct = $e(o.height, r, E.height + u.top + u.bottom);
3419
3431
  return {
3420
3432
  x: m,
3421
3433
  y: g,
@@ -3428,51 +3440,51 @@ function oi(t, e, n, i, r) {
3428
3440
  };
3429
3441
  }
3430
3442
  if (t.type === "IMAGE") {
3431
- const U = Me(o.width, i, Math.min(200, i)), ct = Me(o.height, r, 120);
3443
+ const E = $e(o.width, i, Math.min(200, i)), ct = $e(o.height, r, 120);
3432
3444
  return {
3433
3445
  x: m,
3434
3446
  y: g,
3435
- width: U - d.left - d.right,
3447
+ width: E - d.left - d.right,
3436
3448
  height: ct,
3437
3449
  node: t,
3438
3450
  children: [],
3439
3451
  style: o
3440
3452
  };
3441
3453
  }
3442
- const b = o.flexDirection ?? "column", x = o.gap ?? 0, C = [];
3443
- let S = m + u.left, H = g + u.top, O = 0, E = 0;
3444
- for (let U = 0; U < t.children.length; U++) {
3445
- const ct = t.children[U], ft = b === "row" ? Math.max(0, w - O - (U > 0 ? x : 0)) : w, gt = b === "column" ? Math.max(0, r - (H - n) - d.bottom) : r, tt = oi(ct, S, H, ft, gt);
3446
- C.push(tt), b === "row" ? (O += tt.width + De(ct.props.style ?? {}).left + De(ct.props.style ?? {}).right, U < t.children.length - 1 && (O += x), S = m + u.left + O, E = Math.max(E, tt.height)) : (O += tt.height + De(ct.props.style ?? {}).top + De(ct.props.style ?? {}).bottom, U < t.children.length - 1 && (O += x), H = g + u.top + O, E = Math.max(E, tt.width));
3454
+ const b = o.flexDirection ?? "column", x = o.gap ?? 0, I = [];
3455
+ let S = m + u.left, H = g + u.top, W = 0, A = 0;
3456
+ for (let E = 0; E < t.children.length; E++) {
3457
+ const ct = t.children[E], ht = b === "row" ? Math.max(0, y - W - (E > 0 ? x : 0)) : y, gt = b === "column" ? Math.max(0, r - (H - n) - d.bottom) : r, tt = ci(ct, S, H, ht, gt);
3458
+ I.push(tt), b === "row" ? (W += tt.width + Ae(ct.props.style ?? {}).left + Ae(ct.props.style ?? {}).right, E < t.children.length - 1 && (W += x), S = m + u.left + W, A = Math.max(A, tt.height)) : (W += tt.height + Ae(ct.props.style ?? {}).top + Ae(ct.props.style ?? {}).bottom, E < t.children.length - 1 && (W += x), H = g + u.top + W, A = Math.max(A, tt.width));
3447
3459
  }
3448
- const I = Me(
3460
+ const C = $e(
3449
3461
  o.height,
3450
3462
  r,
3451
- b === "column" ? O + u.top + u.bottom : E + u.top + u.bottom
3452
- ), et = b === "row" ? Me(o.width, i, O + u.left + u.right) : _, at = o.justifyContent ?? "flex-start", Y = o.alignItems ?? "stretch", pt = b === "column" ? I - u.top - u.bottom : et - u.left - u.right, Mt = Math.max(0, pt - O);
3453
- let Z = 0, Lt = x;
3454
- at === "center" && (Z = Mt / 2), at === "flex-end" && (Z = Mt), at === "space-between" && C.length > 1 && (Lt = x + Mt / (C.length - 1)), at === "space-around" && C.length > 0 && (Lt = x + Mt / C.length, Z = Lt / 2);
3455
- let _t = 0;
3456
- for (const U of C)
3457
- b === "column" ? (U.y = g + u.top + Z + _t, Y === "center" ? U.x = m + u.left + Math.max(0, (w - U.width) / 2) : Y === "flex-end" ? U.x = m + u.left + Math.max(0, w - U.width) : Y === "stretch" && U.style.width == null && (U.width = w), _t += U.height + Lt) : (U.x = m + u.left + Z + _t, Y === "center" ? U.y = g + u.top + Math.max(0, (I - u.top - u.bottom - U.height) / 2) : Y === "flex-end" ? U.y = g + u.top + Math.max(0, I - u.top - u.bottom - U.height) : Y === "stretch" && U.style.height == null && (U.height = I - u.top - u.bottom), _t += U.width + Lt);
3463
+ b === "column" ? W + u.top + u.bottom : A + u.top + u.bottom
3464
+ ), nt = b === "row" ? $e(o.width, i, W + u.left + u.right) : _, at = o.justifyContent ?? "flex-start", q = o.alignItems ?? "stretch", pt = b === "column" ? C - u.top - u.bottom : nt - u.left - u.right, Mt = Math.max(0, pt - W);
3465
+ let K = 0, Et = x;
3466
+ at === "center" && (K = Mt / 2), at === "flex-end" && (K = Mt), at === "space-between" && I.length > 1 && (Et = x + Mt / (I.length - 1)), at === "space-around" && I.length > 0 && (Et = x + Mt / I.length, K = Et / 2);
3467
+ let vt = 0;
3468
+ for (const E of I)
3469
+ b === "column" ? (E.y = g + u.top + K + vt, q === "center" ? E.x = m + u.left + Math.max(0, (y - E.width) / 2) : q === "flex-end" ? E.x = m + u.left + Math.max(0, y - E.width) : q === "stretch" && E.style.width == null && (E.width = y), vt += E.height + Et) : (E.x = m + u.left + K + vt, q === "center" ? E.y = g + u.top + Math.max(0, (C - u.top - u.bottom - E.height) / 2) : q === "flex-end" ? E.y = g + u.top + Math.max(0, C - u.top - u.bottom - E.height) : q === "stretch" && E.style.height == null && (E.height = C - u.top - u.bottom), vt += E.width + Et);
3458
3470
  return {
3459
3471
  x: m,
3460
3472
  y: g,
3461
- width: et,
3462
- height: I,
3473
+ width: nt,
3474
+ height: C,
3463
3475
  node: t,
3464
- children: C,
3476
+ children: I,
3465
3477
  style: o
3466
3478
  };
3467
3479
  }
3468
- function Vr(t) {
3480
+ function Yr(t) {
3469
3481
  if (t.type !== "DOCUMENT")
3470
3482
  throw new Error("[epochs-pdf] Root element must be <Document>.");
3471
3483
  const e = [];
3472
3484
  for (const n of t.children) {
3473
3485
  if (n.type !== "PAGE")
3474
3486
  throw new Error("[epochs-pdf] Direct children of <Document> must be <Page>.");
3475
- const i = n.props.size, r = n.props.orientation ?? "portrait", [o, d] = Sr(i, r), u = n.props.style ?? {}, m = ii(u), g = {
3487
+ const i = n.props.size, r = n.props.orientation ?? "portrait", [o, d] = Gr(i, r), u = n.props.style ?? {}, m = si(u), g = {
3476
3488
  type: "VIEW",
3477
3489
  props: {
3478
3490
  style: {
@@ -3486,7 +3498,7 @@ function Vr(t) {
3486
3498
  }
3487
3499
  },
3488
3500
  children: n.children
3489
- }, _ = oi(g, 0, 0, o, d);
3501
+ }, _ = ci(g, 0, 0, o, d);
3490
3502
  e.push({
3491
3503
  width: o,
3492
3504
  height: d,
@@ -3504,44 +3516,44 @@ function Vr(t) {
3504
3516
  pages: e
3505
3517
  };
3506
3518
  }
3507
- function Fe(t) {
3519
+ function Ee(t) {
3508
3520
  return t.replace(/\\/g, "\\\\").replace(/\(/g, "\\(").replace(/\)/g, "\\)").replace(/\r/g, "\\r").replace(/\n/g, "\\n");
3509
3521
  }
3510
- class Yr {
3522
+ class Kr {
3511
3523
  constructor() {
3512
- Je(this, "objects", [null]);
3513
- Je(this, "offsets", [0]);
3524
+ on(this, "objects", [null]);
3525
+ on(this, "offsets", [0]);
3514
3526
  }
3515
3527
  addObject(e) {
3516
3528
  return this.objects.push(e), this.objects.length - 1;
3517
3529
  }
3518
3530
  build(e) {
3519
3531
  const n = this.addObject(
3520
- `<< /Title (${Fe(e.meta.title)}) /Author (${Fe(e.meta.author)}) /Subject (${Fe(e.meta.subject)}) /Creator (${Fe(e.meta.creator)}) /Producer (epochs-pdf) >>`
3532
+ `<< /Title (${Ee(e.meta.title)}) /Author (${Ee(e.meta.author)}) /Subject (${Ee(e.meta.subject)}) /Creator (${Ee(e.meta.creator)}) /Producer (epochs-pdf) >>`
3521
3533
  ), i = this.addObject(
3522
3534
  "<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>"
3523
3535
  ), r = this.addObject(
3524
3536
  "<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold >>"
3525
3537
  ), o = [];
3526
- for (const w of e.pages) {
3538
+ for (const y of e.pages) {
3527
3539
  const b = this.renderPageContent(
3528
- w.boxes,
3529
- w.width,
3530
- w.height,
3531
- w.style
3540
+ y.boxes,
3541
+ y.width,
3542
+ y.height,
3543
+ y.style
3532
3544
  ), x = this.addObject(
3533
3545
  `<< /Length ${b.length} >>
3534
3546
  stream
3535
3547
  ${b}
3536
3548
  endstream`
3537
- ), C = this.addObject("");
3538
- o.push(C), this.objects[C] = `<< /Type /Page /Parent 0 0 R /MediaBox [0 0 ${w.width.toFixed(2)} ${w.height.toFixed(2)}] /Contents ${x} 0 R /Resources << /Font << /F1 ${i} 0 R /F2 ${r} 0 R >> >> >>`;
3549
+ ), I = this.addObject("");
3550
+ o.push(I), this.objects[I] = `<< /Type /Page /Parent 0 0 R /MediaBox [0 0 ${y.width.toFixed(2)} ${y.height.toFixed(2)}] /Contents ${x} 0 R /Resources << /Font << /F1 ${i} 0 R /F2 ${r} 0 R >> >> >>`;
3539
3551
  }
3540
- const d = o.map((w) => `${w} 0 R`).join(" "), u = this.addObject(
3552
+ const d = o.map((y) => `${y} 0 R`).join(" "), u = this.addObject(
3541
3553
  `<< /Type /Pages /Kids [${d}] /Count ${o.length} >>`
3542
3554
  );
3543
- for (const w of o)
3544
- this.objects[w] = this.objects[w].replace(
3555
+ for (const y of o)
3556
+ this.objects[y] = this.objects[y].replace(
3545
3557
  "/Parent 0 0 R",
3546
3558
  `/Parent ${u} 0 R`
3547
3559
  );
@@ -3551,9 +3563,9 @@ endstream`
3551
3563
  let g = `%PDF-1.4
3552
3564
  `;
3553
3565
  this.offsets = [0];
3554
- for (let w = 1; w < this.objects.length; w++)
3555
- this.offsets[w] = g.length, g += `${w} 0 obj
3556
- ${this.objects[w]}
3566
+ for (let y = 1; y < this.objects.length; y++)
3567
+ this.offsets[y] = g.length, g += `${y} 0 obj
3568
+ ${this.objects[y]}
3557
3569
  endobj
3558
3570
  `;
3559
3571
  const _ = g.length;
@@ -3561,8 +3573,8 @@ endobj
3561
3573
  0 ${this.objects.length}
3562
3574
  `, g += `0000000000 65535 f
3563
3575
  `;
3564
- for (let w = 1; w < this.objects.length; w++)
3565
- g += `${String(this.offsets[w]).padStart(10, "0")} 00000 n
3576
+ for (let y = 1; y < this.objects.length; y++)
3577
+ g += `${String(this.offsets[y]).padStart(10, "0")} 00000 n
3566
3578
  `;
3567
3579
  return g += `trailer
3568
3580
  << /Size ${this.objects.length} /Root ${m} 0 R /Info ${n} 0 R >>
@@ -3571,33 +3583,33 @@ ${_}
3571
3583
  %%EOF`, new TextEncoder().encode(g);
3572
3584
  }
3573
3585
  renderPageContent(e, n, i, r) {
3574
- const o = [], d = Be(r.backgroundColor);
3586
+ const o = [], d = ze(r.backgroundColor);
3575
3587
  d && (o.push("q"), o.push(
3576
3588
  `${d[0].toFixed(3)} ${d[1].toFixed(3)} ${d[2].toFixed(3)} rg`
3577
3589
  ), o.push(
3578
3590
  `0 0 ${n.toFixed(2)} ${i.toFixed(2)} re f`
3579
3591
  ), o.push("Q"));
3580
3592
  const u = (m) => {
3581
- const { x: g, y: _, width: w, height: b, style: x, node: C, text: S } = m, H = i - _ - b, O = Be(x.backgroundColor);
3582
- if (O && (o.push("q"), o.push(`${O[0].toFixed(3)} ${O[1].toFixed(3)} ${O[2].toFixed(3)} rg`), o.push(`${g.toFixed(2)} ${H.toFixed(2)} ${w.toFixed(2)} ${b.toFixed(2)} re f`), o.push("Q")), x.borderWidth && x.borderWidth > 0) {
3583
- const E = Be(x.borderColor) ?? [0, 0, 0];
3584
- o.push("q"), o.push(`${x.borderWidth} w`), o.push(`${E[0].toFixed(3)} ${E[1].toFixed(3)} ${E[2].toFixed(3)} RG`), o.push(`${g.toFixed(2)} ${H.toFixed(2)} ${w.toFixed(2)} ${b.toFixed(2)} re S`), o.push("Q");
3593
+ const { x: g, y: _, width: y, height: b, style: x, node: I, text: S } = m, H = i - _ - b, W = ze(x.backgroundColor);
3594
+ if (W && (o.push("q"), o.push(`${W[0].toFixed(3)} ${W[1].toFixed(3)} ${W[2].toFixed(3)} rg`), o.push(`${g.toFixed(2)} ${H.toFixed(2)} ${y.toFixed(2)} ${b.toFixed(2)} re f`), o.push("Q")), x.borderWidth && x.borderWidth > 0) {
3595
+ const A = ze(x.borderColor) ?? [0, 0, 0];
3596
+ o.push("q"), o.push(`${x.borderWidth} w`), o.push(`${A[0].toFixed(3)} ${A[1].toFixed(3)} ${A[2].toFixed(3)} RG`), o.push(`${g.toFixed(2)} ${H.toFixed(2)} ${y.toFixed(2)} ${b.toFixed(2)} re S`), o.push("Q");
3585
3597
  }
3586
- if ((C.type === "TEXT" || C.type === "LINK") && S != null) {
3587
- const E = x.fontSize ?? 12, I = Be(x.color) ?? [0, 0, 0], et = an(x.fontWeight) ? "F2" : "F1", at = x.paddingLeft ?? x.padding ?? 0, Y = x.paddingTop ?? x.padding ?? 0, pt = Math.max(0, w - at - (x.paddingRight ?? x.padding ?? 0)), J = ri(S, x, pt || w), Mt = (x.lineHeight ?? 1.4) * E;
3588
- o.push("q"), o.push("BT"), o.push(`/${et} ${E} Tf`), o.push(`${I[0].toFixed(3)} ${I[1].toFixed(3)} ${I[2].toFixed(3)} rg`), J.lines.forEach((Z, Lt) => {
3589
- let _t = g + at;
3590
- const U = Z.length * E * (an(x.fontWeight) ? 0.55 : 0.5);
3591
- x.textAlign === "center" ? _t = g + (w - U) / 2 : x.textAlign === "right" && (_t = g + w - U - (x.paddingRight ?? x.padding ?? 0));
3592
- const ct = i - _ - Y - E - Lt * Mt;
3593
- o.push(`1 0 0 1 ${_t.toFixed(2)} ${ct.toFixed(2)} Tm`), o.push(`(${Fe(Z)}) Tj`);
3598
+ if ((I.type === "TEXT" || I.type === "LINK") && S != null) {
3599
+ const A = x.fontSize ?? 12, C = ze(x.color) ?? [0, 0, 0], nt = un(x.fontWeight) ? "F2" : "F1", at = x.paddingLeft ?? x.padding ?? 0, q = x.paddingTop ?? x.padding ?? 0, pt = Math.max(0, y - at - (x.paddingRight ?? x.padding ?? 0)), J = ai(S, x, pt || y), Mt = (x.lineHeight ?? 1.4) * A;
3600
+ o.push("q"), o.push("BT"), o.push(`/${nt} ${A} Tf`), o.push(`${C[0].toFixed(3)} ${C[1].toFixed(3)} ${C[2].toFixed(3)} rg`), J.lines.forEach((K, Et) => {
3601
+ let vt = g + at;
3602
+ const E = K.length * A * (un(x.fontWeight) ? 0.55 : 0.5);
3603
+ x.textAlign === "center" ? vt = g + (y - E) / 2 : x.textAlign === "right" && (vt = g + y - E - (x.paddingRight ?? x.padding ?? 0));
3604
+ const ct = i - _ - q - A - Et * Mt;
3605
+ o.push(`1 0 0 1 ${vt.toFixed(2)} ${ct.toFixed(2)} Tm`), o.push(`(${Ee(K)}) Tj`);
3594
3606
  }), o.push("ET"), o.push("Q");
3595
3607
  }
3596
- C.type === "IMAGE" && (o.push("q"), o.push("0.85 0.85 0.85 rg"), o.push(`${g.toFixed(2)} ${H.toFixed(2)} ${w.toFixed(2)} ${b.toFixed(2)} re f`), o.push("0.6 0.6 0.6 RG 1 w"), o.push(`${g.toFixed(2)} ${H.toFixed(2)} ${w.toFixed(2)} ${b.toFixed(2)} re S`), o.push(
3608
+ I.type === "IMAGE" && (o.push("q"), o.push("0.85 0.85 0.85 rg"), o.push(`${g.toFixed(2)} ${H.toFixed(2)} ${y.toFixed(2)} ${b.toFixed(2)} re f`), o.push("0.6 0.6 0.6 RG 1 w"), o.push(`${g.toFixed(2)} ${H.toFixed(2)} ${y.toFixed(2)} ${b.toFixed(2)} re S`), o.push(
3597
3609
  `BT /F1 10 Tf 0.4 0.4 0.4 rg 1 0 0 1 ${(g + 8).toFixed(2)} ${(H + b / 2 - 4).toFixed(2)} Tm (Image) Tj ET`
3598
3610
  ), o.push("Q"));
3599
- for (const E of m.children)
3600
- u(E);
3611
+ for (const A of m.children)
3612
+ u(A);
3601
3613
  };
3602
3614
  for (const m of e)
3603
3615
  u(m);
@@ -3605,69 +3617,69 @@ ${_}
3605
3617
  `);
3606
3618
  }
3607
3619
  }
3608
- function Kr(t) {
3609
- return new Yr().build(t);
3620
+ function Zr(t) {
3621
+ return new Kr().build(t);
3610
3622
  }
3611
- function cn(t) {
3612
- const e = ni(t), n = Vr(e);
3613
- return Kr(n);
3623
+ function fn(t) {
3624
+ const e = oi(t), n = Yr(e);
3625
+ return Zr(n);
3614
3626
  }
3615
- function oo(t) {
3616
- return cn(t);
3627
+ function so(t) {
3628
+ return fn(t);
3617
3629
  }
3618
- function si(t) {
3619
- const e = cn(t), n = new Uint8Array(e.byteLength);
3630
+ function li(t) {
3631
+ const e = fn(t), n = new Uint8Array(e.byteLength);
3620
3632
  return n.set(e), new Blob([n], { type: "application/pdf" });
3621
3633
  }
3622
- function Zr(t) {
3623
- return URL.createObjectURL(si(t));
3634
+ function Qr(t) {
3635
+ return URL.createObjectURL(li(t));
3624
3636
  }
3625
- function so(t, e = "document.pdf") {
3626
- const n = Zr(t), i = document.createElement("a");
3637
+ function ao(t, e = "document.pdf") {
3638
+ const n = Qr(t), i = document.createElement("a");
3627
3639
  i.href = n, i.download = e, i.click(), URL.revokeObjectURL(n);
3628
3640
  }
3629
- async function ao(t) {
3630
- return cn(t);
3631
- }
3632
3641
  async function co(t) {
3633
- return si(t);
3642
+ return fn(t);
3643
+ }
3644
+ async function lo(t) {
3645
+ return li(t);
3634
3646
  }
3635
3647
  export {
3636
- io as ALL_TOOLBAR_TOOLS,
3637
- Zn as AddText,
3638
- Jn as Clear,
3639
- Tn as DEFAULT_TOOLBAR_LAYOUT,
3640
- Ar as Document,
3641
- qn as Download,
3642
- Qn as Erase,
3643
- Dn as HIGHLIGHT_PRESETS,
3644
- Vn as Highlight,
3645
- jr as Image,
3646
- Br as Link,
3647
- On as Navigation,
3648
- Gn as Open,
3649
- zr as PAGE_SIZES,
3650
- Er as Page,
3651
- ro as PdfViewer,
3652
- Xn as Print,
3653
- Sn as Reload,
3654
- zn as Rotate,
3655
- Kn as Signature,
3656
- Hr as Text,
3657
- Bn as Thumbnail,
3658
- Fn as UNDERLINE_PRESETS,
3659
- Yn as Underline,
3648
+ ro as ALL_TOOLBAR_TOOLS,
3649
+ ti as AddText,
3650
+ ni as Clear,
3651
+ Fn as DEFAULT_TOOLBAR_LAYOUT,
3652
+ Er as Document,
3653
+ Kn as Download,
3654
+ ei as Erase,
3655
+ An as HIGHLIGHT_PRESETS,
3656
+ Zn as Highlight,
3657
+ Br as Image,
3658
+ Wr as Link,
3659
+ Sn as Navigation,
3660
+ Yn as Open,
3661
+ Sr as PAGE_SIZES,
3662
+ Hr as Page,
3663
+ oo as PdfViewer,
3664
+ qn as Print,
3665
+ Vn as Reload,
3666
+ Xn as Rotate,
3667
+ Jn as Signature,
3668
+ jr as Text,
3669
+ zn as Thumbnail,
3670
+ En as UNDERLINE_PRESETS,
3671
+ Qn as Underline,
3660
3672
  Ur as View,
3661
- Wn as Zoom,
3662
- ro as default,
3663
- so as download,
3664
- An as hexToMarkupColor,
3665
- oo as pdf,
3666
- co as renderToBlob,
3667
- ao as renderToBuffer,
3668
- Sr as resolvePageSize,
3669
- kn as setPdfWorkerSrc,
3670
- si as toBlob,
3671
- Zr as toUrl
3673
+ Gn as Zoom,
3674
+ oo as default,
3675
+ ao as download,
3676
+ Un as hexToMarkupColor,
3677
+ so as pdf,
3678
+ lo as renderToBlob,
3679
+ co as renderToBuffer,
3680
+ Gr as resolvePageSize,
3681
+ $n as setPdfWorkerSrc,
3682
+ li as toBlob,
3683
+ Qr as toUrl
3672
3684
  };
3673
3685
  //# sourceMappingURL=epochs-pdf.js.map