epochs-pdf 0.1.6 → 0.1.7

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