@react-pdf-kit/viewer 2.1.0-beta.0 → 2.1.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,16 +1,16 @@
1
1
  import { jsx as a, jsxs as C, Fragment as x } from "react/jsx-runtime";
2
2
  import * as c from "react";
3
3
  import { useMemo as J } from "react";
4
- import { c as Q, a as P, P as D, b as v, d as y, e as X, f as M, g as ee } from "../../../index-c0faa594.js";
5
- import { D as te, u as R } from "../../../index-e3ee9457.js";
4
+ import { c as Q, a as R, P as D, b as v, d as y, e as X, f as M, g as ee } from "../../../index-c0faa594.js";
5
+ import { D as te, u as P } from "../../../index-e3ee9457.js";
6
6
  import { R as oe, h as re, u as ne, F as ie, P as ae } from "../../../Combination-136ff99c.js";
7
7
  import { useLayoutContainer as le } from "../../../contexts/LayoutContainerContext.js";
8
8
  import { CloseIcon as ce } from "../../icons/CloseIcon.js";
9
9
  import { dateFormatter as A } from "../../../utils/dateFormatter.js";
10
10
  import { useDocumentContext as se } from "../../../contexts/RPDocumentContext.js";
11
11
  import { PropertyItem as ue } from "./PropertyItem.js";
12
- import { useOtherToolContext as de } from "../../../contexts/OtherToolContext.js";
13
- import { useLocalizationContext as pe } from "../../../contexts/LocalizationContext.js";
12
+ import { useOtherToolContext as pe } from "../../../contexts/OtherToolContext.js";
13
+ import { useLocalizationContext as de } from "../../../contexts/LocalizationContext.js";
14
14
  import "react-dom";
15
15
  import "../../../utils/hooks/useLoadPdf.js";
16
16
  import "pdfjs-dist";
@@ -32,7 +32,7 @@ var h = "Dialog", [T, tt] = Q(h), [fe, u] = T(h), L = (t) => {
32
32
  defaultOpen: e,
33
33
  onOpenChange: o,
34
34
  modal: l = !0
35
- } = t, s = c.useRef(null), d = c.useRef(null), [p, g] = M({
35
+ } = t, s = c.useRef(null), p = c.useRef(null), [d, g] = M({
36
36
  prop: i,
37
37
  defaultProp: e ?? !1,
38
38
  onChange: o,
@@ -43,11 +43,11 @@ var h = "Dialog", [T, tt] = Q(h), [fe, u] = T(h), L = (t) => {
43
43
  {
44
44
  scope: r,
45
45
  triggerRef: s,
46
- contentRef: d,
47
- contentId: R(),
48
- titleId: R(),
49
- descriptionId: R(),
50
- open: p,
46
+ contentRef: p,
47
+ contentId: P(),
48
+ titleId: P(),
49
+ descriptionId: P(),
50
+ open: d,
51
51
  onOpenChange: g,
52
52
  onOpenToggle: c.useCallback(() => g((_) => !_), [g]),
53
53
  modal: l,
@@ -58,7 +58,7 @@ var h = "Dialog", [T, tt] = Q(h), [fe, u] = T(h), L = (t) => {
58
58
  L.displayName = h;
59
59
  var w = "DialogTrigger", me = c.forwardRef(
60
60
  (t, r) => {
61
- const { __scopeDialog: n, ...i } = t, e = u(w, n), o = P(r, e.triggerRef);
61
+ const { __scopeDialog: n, ...i } = t, e = u(w, n), o = R(r, e.triggerRef);
62
62
  return /* @__PURE__ */ a(
63
63
  D.button,
64
64
  {
@@ -115,7 +115,7 @@ var ve = ee("DialogOverlay.RemoveScroll"), De = c.forwardRef(
115
115
  k.displayName = m;
116
116
  var _e = c.forwardRef(
117
117
  (t, r) => {
118
- const n = u(m, t.__scopeDialog), i = c.useRef(null), e = P(r, n.contentRef, i);
118
+ const n = u(m, t.__scopeDialog), i = c.useRef(null), e = R(r, n.contentRef, i);
119
119
  return c.useEffect(() => {
120
120
  const o = i.current;
121
121
  if (o)
@@ -157,17 +157,17 @@ var _e = c.forwardRef(
157
157
  (l = t.onCloseAutoFocus) == null || l.call(t, o), o.defaultPrevented || (i.current || (s = n.triggerRef.current) == null || s.focus(), o.preventDefault()), i.current = !1, e.current = !1;
158
158
  },
159
159
  onInteractOutside: (o) => {
160
- var d, p;
161
- (d = t.onInteractOutside) == null || d.call(t, o), o.defaultPrevented || (i.current = !0, o.detail.originalEvent.type === "pointerdown" && (e.current = !0));
160
+ var p, d;
161
+ (p = t.onInteractOutside) == null || p.call(t, o), o.defaultPrevented || (i.current = !0, o.detail.originalEvent.type === "pointerdown" && (e.current = !0));
162
162
  const l = o.target;
163
- ((p = n.triggerRef.current) == null ? void 0 : p.contains(l)) && o.preventDefault(), o.detail.originalEvent.type === "focusin" && e.current && o.preventDefault();
163
+ ((d = n.triggerRef.current) == null ? void 0 : d.contains(l)) && o.preventDefault(), o.detail.originalEvent.type === "focusin" && e.current && o.preventDefault();
164
164
  }
165
165
  }
166
166
  );
167
167
  }
168
168
  ), q = c.forwardRef(
169
169
  (t, r) => {
170
- const { __scopeDialog: n, trapFocus: i, onOpenAutoFocus: e, onCloseAutoFocus: o, ...l } = t, s = u(m, n), d = c.useRef(null), p = P(r, d);
170
+ const { __scopeDialog: n, trapFocus: i, onOpenAutoFocus: e, onCloseAutoFocus: o, ...l } = t, s = u(m, n), p = c.useRef(null), d = R(r, p);
171
171
  return ne(), /* @__PURE__ */ C(x, { children: [
172
172
  /* @__PURE__ */ a(
173
173
  ie,
@@ -186,7 +186,7 @@ var _e = c.forwardRef(
186
186
  "aria-labelledby": s.titleId,
187
187
  "data-state": E(s.open),
188
188
  ...l,
189
- ref: p,
189
+ ref: d,
190
190
  onDismiss: () => s.onOpenChange(!1)
191
191
  }
192
192
  )
@@ -194,7 +194,7 @@ var _e = c.forwardRef(
194
194
  ),
195
195
  /* @__PURE__ */ C(x, { children: [
196
196
  /* @__PURE__ */ a(he, { titleId: s.titleId }),
197
- /* @__PURE__ */ a(Pe, { contentRef: d, descriptionId: s.descriptionId })
197
+ /* @__PURE__ */ a(Re, { contentRef: p, descriptionId: s.descriptionId })
198
198
  ] })
199
199
  ] });
200
200
  }
@@ -243,8 +243,8 @@ For more information, see https://radix-ui.com/primitives/docs/components/${r.do
243
243
  return c.useEffect(() => {
244
244
  t && (document.getElementById(t) || console.error(n));
245
245
  }, [n, t]), null;
246
- }, Re = "DialogDescriptionWarning", Pe = ({ contentRef: t, descriptionId: r }) => {
247
- const i = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${V(Re).contentName}}.`;
246
+ }, Pe = "DialogDescriptionWarning", Re = ({ contentRef: t, descriptionId: r }) => {
247
+ const i = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${V(Pe).contentName}}.`;
248
248
  return c.useEffect(() => {
249
249
  var o;
250
250
  const e = (o = t.current) == null ? void 0 : o.getAttribute("aria-describedby");
@@ -260,14 +260,14 @@ const f = {
260
260
  "rp-dialog-close": "_rp-dialog-close_slqo7_47",
261
261
  "rp-properties-divider": "_rp-properties-divider_slqo7_55"
262
262
  }, rt = () => {
263
- const { pdfProperties: t } = se(), { container: r } = le(), { activeDocumentProperties: n, setActiveDocumentProperties: i } = de(), { localeMessages: e } = pe(), o = J(() => {
263
+ const { pdfProperties: t } = se(), { container: r } = le(), { activeDocumentProperties: n, setActiveDocumentProperties: i } = pe(), { localeMessages: e } = de(), o = J(() => {
264
264
  if (!t)
265
265
  return [];
266
266
  const {
267
267
  fileSize: l,
268
268
  filename: s,
269
- title: d,
270
- author: p,
269
+ title: p,
270
+ author: d,
271
271
  subject: g,
272
272
  createdOn: _,
273
273
  creator: H,
@@ -281,8 +281,8 @@ const f = {
281
281
  { label: e == null ? void 0 : e.propertiesFilenameLabel, value: s },
282
282
  { label: e == null ? void 0 : e.propertiesFileSizeLabel, value: l },
283
283
  { separate: !0 },
284
- { label: e == null ? void 0 : e.propertiesTitleLabel, value: d },
285
- { label: e == null ? void 0 : e.propertiesAuthorLabel, value: p },
284
+ { label: e == null ? void 0 : e.propertiesTitleLabel, value: p },
285
+ { label: e == null ? void 0 : e.propertiesAuthorLabel, value: d },
286
286
  { label: e == null ? void 0 : e.propertiesSubjectLabel, value: g },
287
287
  { label: e == null ? void 0 : e.propertiesKeywordLabel, value: K },
288
288
  { label: e == null ? void 0 : e.propertiesCreatorLabel, value: H },
@@ -302,9 +302,17 @@ const f = {
302
302
  }, [t, e]);
303
303
  return /* @__PURE__ */ a(ye, { open: n, onOpenChange: i, children: /* @__PURE__ */ a(Ne, { container: r, children: /* @__PURE__ */ C("div", { className: f["rp-dialog-wrapper"], children: [
304
304
  /* @__PURE__ */ a(Oe, { className: f["rp-dialog-overlay"] }),
305
- /* @__PURE__ */ C(Ee, { className: f["rp-document-dialog"], "aria-labelledby": "document-properties-title", children: [
306
- /* @__PURE__ */ a(Ie, { id: "document-properties-title", className: f["rp-dialog-title"], children: e == null ? void 0 : e.documentPropertiesLabel }),
307
- /* @__PURE__ */ a("div", { className: f["rp-document-properties"], role: "region", "aria-labelledby": "document-properties-title", children: o.map((l, s) => /* @__PURE__ */ a("div", { children: l.separate ? /* @__PURE__ */ a("div", { className: f["rp-properties-divider"], role: "separator", "aria-orientation": "horizontal" }) : /* @__PURE__ */ a(ue, { label: l.label, value: l.value }) }, s)) }),
305
+ /* @__PURE__ */ C(Ee, { className: f["rp-document-dialog"], children: [
306
+ /* @__PURE__ */ a(Ie, { className: f["rp-dialog-title"], children: (e == null ? void 0 : e.documentPropertiesLabel) ?? "Document properties" }),
307
+ /* @__PURE__ */ a(
308
+ "div",
309
+ {
310
+ className: f["rp-document-properties"],
311
+ role: "region",
312
+ "aria-label": (e == null ? void 0 : e.documentPropertiesLabel) ?? "Document properties",
313
+ children: o.map((l, s) => /* @__PURE__ */ a("div", { children: l.separate ? /* @__PURE__ */ a("div", { className: f["rp-properties-divider"], role: "separator", "aria-orientation": "horizontal" }) : /* @__PURE__ */ a(ue, { label: l.label, value: l.value }) }, s))
314
+ }
315
+ ),
308
316
  /* @__PURE__ */ a(xe, { asChild: !0, className: f["rp-dialog-close"], "aria-label": (e == null ? void 0 : e.searchCloseButtonTooltip) || "Close dialog", children: /* @__PURE__ */ a(ce, { "aria-hidden": "true" }) })
309
317
  ] })
310
318
  ] }) }) });
@@ -1,10 +1,10 @@
1
- import { jsxs as l, Fragment as d, jsx as r } from "react/jsx-runtime";
1
+ import { jsxs as h, Fragment as l, jsx as r } from "react/jsx-runtime";
2
2
  import m from "../../ui/RPTooltip.js";
3
3
  import { UIButton as a } from "../../ui/Button.js";
4
- import { ChevronUpIcon as e } from "../../icons/ChevronUpIcon.js";
5
- import { useLocalizationContext as h } from "../../../contexts/LocalizationContext.js";
6
- import { useSearchContext as s } from "../../../contexts/SearchContext.js";
7
- import { c as i } from "../../../SearchTool.module-99f60dc7.js";
4
+ import { ChevronUpIcon as n } from "../../icons/ChevronUpIcon.js";
5
+ import { useLocalizationContext as s } from "../../../contexts/LocalizationContext.js";
6
+ import { useSearchContext as d } from "../../../contexts/SearchContext.js";
7
+ import { c as o } from "../../../SearchTool.module-99f60dc7.js";
8
8
  import "react";
9
9
  import "../../../index-c0faa594.js";
10
10
  import "react-dom";
@@ -50,29 +50,22 @@ import "../../../contexts/SmoothScrollContext.js";
50
50
  import "../../../utils/getScrollDistance.js";
51
51
  import "../../../utils/calculatePage.js";
52
52
  import "../../../utils/getWordPositionInPage.js";
53
- const ht = () => {
54
- const { totalMatches: p, nextMatch: n, prevMatch: c } = s(), { localeMessages: t } = h(), o = !p || p === 0;
55
- return /* @__PURE__ */ l(d, { children: [
53
+ const st = () => {
54
+ const { totalMatches: i, nextMatch: e, prevMatch: c } = d(), { localeMessages: t } = s(), p = !i || i === 0;
55
+ return /* @__PURE__ */ h(l, { children: [
56
56
  /* @__PURE__ */ r(
57
57
  m,
58
58
  {
59
59
  content: t == null ? void 0 : t.searchPrevTooltip,
60
- className: i["rp-search-tool-result-navigator"],
60
+ className: o["rp-search-tool-result-navigator"],
61
61
  children: /* @__PURE__ */ r(
62
62
  a,
63
63
  {
64
64
  tabIndex: 0,
65
65
  onClick: c,
66
66
  "aria-label": t == null ? void 0 : t.searchPrevTooltip,
67
- disabled: o,
68
- "aria-disabled": o,
69
- children: /* @__PURE__ */ r(
70
- e,
71
- {
72
- className: i["rp-search-tool-input-icon"],
73
- "aria-hidden": "true"
74
- }
75
- )
67
+ "aria-disabled": p,
68
+ children: /* @__PURE__ */ r(n, { className: o["rp-search-tool-input-icon"], "aria-hidden": "true" })
76
69
  }
77
70
  )
78
71
  }
@@ -81,20 +74,19 @@ const ht = () => {
81
74
  m,
82
75
  {
83
76
  content: t == null ? void 0 : t.searchNextTooltip,
84
- className: i["rp-search-tool-result-navigator"],
77
+ className: o["rp-search-tool-result-navigator"],
85
78
  children: /* @__PURE__ */ r(
86
79
  a,
87
80
  {
88
81
  tabIndex: 0,
89
- onClick: n,
82
+ onClick: e,
90
83
  "aria-label": t == null ? void 0 : t.searchNextTooltip,
91
- disabled: o,
92
- "aria-disabled": o,
84
+ "aria-disabled": p,
93
85
  children: /* @__PURE__ */ r(
94
- e,
86
+ n,
95
87
  {
96
88
  style: { transform: "rotate(180deg" },
97
- className: i["rp-search-tool-input-icon"],
89
+ className: o["rp-search-tool-input-icon"],
98
90
  "aria-hidden": "true"
99
91
  }
100
92
  )
@@ -105,5 +97,5 @@ const ht = () => {
105
97
  ] });
106
98
  };
107
99
  export {
108
- ht as SearchResultNavigator
100
+ st as SearchResultNavigator
109
101
  };
@@ -1,25 +1,25 @@
1
- import { jsxs as a, jsx as i } from "react/jsx-runtime";
1
+ import { jsxs as c, jsx as i } from "react/jsx-runtime";
2
2
  import { c as u } from "../../clsx-0c6e471a.js";
3
3
  import { withRef as l } from "../../utils/withRef.js";
4
4
  import "react";
5
5
  const t = {
6
- "rp-input": "_rp-input_3rj4v_1",
7
- "rp-input-wrapper": "_rp-input-wrapper_3rj4v_22",
8
- "rp-input-icon": "_rp-input-icon_3rj4v_26"
6
+ "rp-input": "_rp-input_5b7ag_1",
7
+ "rp-input-wrapper": "_rp-input-wrapper_5b7ag_28",
8
+ "rp-input-icon": "_rp-input-icon_5b7ag_32"
9
9
  }, h = l((n, e) => {
10
- const { className: o, icon: p, children: s, ...r } = n, c = r.role || (r.type === "text" || !r.type ? "textbox" : void 0);
11
- return /* @__PURE__ */ a("div", { className: t["rp-input-wrapper"], children: [
10
+ const { className: o, icon: r, children: s, ...p } = n, a = p.role || (p.type === "text" || !p.type ? "textbox" : void 0);
11
+ return /* @__PURE__ */ c("div", { className: t["rp-input-wrapper"], children: [
12
12
  /* @__PURE__ */ i(
13
13
  "input",
14
14
  {
15
- ...r,
16
- role: c,
17
- "data-icon": !!p,
15
+ ...p,
16
+ role: a,
17
+ "data-icon": !!r,
18
18
  ref: e,
19
19
  className: u(o, t["rp-input"], "ignore-hover")
20
20
  }
21
21
  ),
22
- p && /* @__PURE__ */ i("span", { className: t["rp-input-icon"], "aria-hidden": "true", children: p }),
22
+ r && /* @__PURE__ */ i("span", { className: t["rp-input-icon"], "aria-hidden": "true", children: r }),
23
23
  s
24
24
  ] });
25
25
  });
@@ -1,21 +1,21 @@
1
1
  import { getCharacterType as D } from "./charators.js";
2
- function _(r, c, m, i) {
2
+ function _(l, c, m, i) {
3
3
  const s = [];
4
- for (const n of r) {
4
+ for (const n of l) {
5
5
  const o = y(c, n, i);
6
6
  s.push(...R(o, c, m));
7
7
  }
8
8
  return s;
9
9
  }
10
- const L = (r, c) => {
10
+ const L = (l, c) => {
11
11
  const m = ["g"];
12
12
  c.matchCase || m.push("i");
13
- let s = r.replace(/[.^$*+?()[{|\\]/g, (n) => `\\${n}`).trim();
13
+ let s = l.replace(/[.^$*+?()[{|\\]/g, (n) => `\\${n}`).trim();
14
14
  return new RegExp(s, m.join(""));
15
15
  };
16
- function y(r, c, m) {
16
+ function y(l, c, m) {
17
17
  const i = [];
18
- for (const t of r.items)
18
+ for (const t of l.items)
19
19
  if (t.hasEOL)
20
20
  if (t.str.endsWith("-")) {
21
21
  const d = t.str.lastIndexOf("-");
@@ -34,14 +34,14 @@ function y(r, c, m) {
34
34
  m.wholeWords && !W(s, e.index, e[0].length) || o.push([e.index, e[0].length, e[0]]);
35
35
  return o;
36
36
  }
37
- function R(r, c, m) {
37
+ function R(l, c, m) {
38
38
  function i(d) {
39
39
  return d.hasEOL ? d.str.endsWith("-") ? -1 : 1 : 0;
40
40
  }
41
41
  let s = 0, n = 0;
42
42
  const o = c.items, e = o.length - 1, t = [];
43
- for (let d = 0; d < r.length; d++) {
44
- let h = r[d][0];
43
+ for (let d = 0; d < l.length; d++) {
44
+ let h = l[d][0];
45
45
  for (; s !== e && h >= n + o[s].str.length; ) {
46
46
  const x = o[s];
47
47
  n += x.str.length + i(x), s++;
@@ -50,19 +50,19 @@ function R(r, c, m) {
50
50
  idx: s,
51
51
  offset: h - n
52
52
  };
53
- for (h += r[d][1]; s !== e && h > n + o[s].str.length; ) {
53
+ for (h += l[d][1]; s !== e && h > n + o[s].str.length; ) {
54
54
  const x = o[s];
55
55
  n += x.str.length + i(x), s++;
56
56
  }
57
- const l = {
57
+ const r = {
58
58
  idx: s,
59
59
  offset: h - n
60
60
  };
61
61
  t.push({
62
62
  start: g,
63
- end: l,
64
- str: r[d][2],
65
- oIndex: r[d][0],
63
+ end: r,
64
+ str: l[d][2],
65
+ oIndex: l[d][0],
66
66
  pageIndex: m,
67
67
  rect: { left: 0, bottom: 0, width: 0, height: 0 },
68
68
  rects: []
@@ -71,45 +71,45 @@ function R(r, c, m) {
71
71
  for (const d of t) {
72
72
  const h = [];
73
73
  for (let g = d.start.idx; g <= d.end.idx; g++) {
74
- const l = o[g], x = l.transform[4], C = l.transform[5], a = l.str.length > 0 ? l.width / l.str.length : 0, M = g === d.start.idx ? d.start.offset : 0, N = g === d.end.idx ? d.end.offset : l.str.length, f = x + M * a, E = (N - M) * a, u = (c.styles ?? {})[l.fontName], T = (u == null ? void 0 : u.ascent) ?? 1, v = (u == null ? void 0 : u.descent) != null ? Math.abs(u.descent) : 1 - T, b = C - v * l.height;
75
- (E > 0 || l.height > 0) && h.push({
74
+ const r = o[g], x = r.transform[4], C = r.transform[5], a = r.str.length > 0 ? r.width / r.str.length : 0, M = g === d.start.idx ? d.start.offset : 0, N = g === d.end.idx ? d.end.offset : r.str.length, f = x + M * a, E = (N - M) * a, u = (c.styles ?? {})[r.fontName], T = (u == null ? void 0 : u.ascent) ?? 1, v = (u == null ? void 0 : u.descent) != null ? Math.abs(u.descent) : 1 - T, b = C - v * r.height;
75
+ r.height > 0 && r.width > 0 && h.push({
76
76
  left: f,
77
77
  bottom: b,
78
78
  width: E,
79
- height: l.height
79
+ height: r.height
80
80
  });
81
81
  }
82
82
  d.rect = h[0], d.rects = h;
83
83
  }
84
84
  return t;
85
85
  }
86
- function W(r, c, m) {
87
- let i = r.slice(0, c).match(/([^\p{M}])\p{M}*$/u);
86
+ function W(l, c, m) {
87
+ let i = l.slice(0, c).match(/([^\p{M}])\p{M}*$/u);
88
88
  if (i) {
89
- const s = r.charCodeAt(c), n = i[1].charCodeAt(0);
89
+ const s = l.charCodeAt(c), n = i[1].charCodeAt(0);
90
90
  if (D(s) === D(n))
91
91
  return !1;
92
92
  }
93
- if (i = r.slice(c + m).match(/^\p{M}*([^\p{M}])/u), i) {
94
- const s = r.charCodeAt(c + m - 1), n = i[1].charCodeAt(0);
93
+ if (i = l.slice(c + m).match(/^\p{M}*([^\p{M}])/u), i) {
94
+ const s = l.charCodeAt(c + m - 1), n = i[1].charCodeAt(0);
95
95
  if (D(s) === D(n))
96
96
  return !1;
97
97
  }
98
98
  return !0;
99
99
  }
100
- function I(r, c, m) {
100
+ function I(l, c, m) {
101
101
  const i = [];
102
102
  function s(n, o, e = -1, t = -1, d = "") {
103
103
  const h = c.items[n], g = [];
104
- let l = "", x = "", C = "", a = m[n];
104
+ let r = "", x = "", C = "", a = m[n];
105
105
  if (!a)
106
106
  return;
107
107
  if (a.nodeType === Node.TEXT_NODE) {
108
108
  const f = document.createElement("span");
109
109
  a.before(f), f.append(a), m[n] = f, a = f;
110
110
  }
111
- e >= 0 && t >= 0 ? l = h.str.substring(e, t) : e < 0 && t < 0 ? l = h.str : e >= 0 ? l = h.str.substring(e) : t >= 0 && (l = h.str.substring(0, t));
112
- const M = document.createTextNode(l), N = document.createElement("span");
111
+ e >= 0 && t >= 0 ? r = h.str.substring(e, t) : e < 0 && t < 0 ? r = h.str : e >= 0 ? r = h.str.substring(e) : t >= 0 && (r = h.str.substring(0, t));
112
+ const M = document.createTextNode(r), N = document.createElement("span");
113
113
  if (N.className = "highlight appended " + d, N.setAttribute("data-match-index", `${o}`), N.append(M), g.push(N), i.push({ element: N, index: o }), e > 0)
114
114
  if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
115
115
  x = h.str.substring(0, e);
@@ -135,7 +135,7 @@ function I(r, c, m) {
135
135
  }
136
136
  a.replaceChildren(...g);
137
137
  }
138
- for (const [n, o] of r.entries())
138
+ for (const [n, o] of l.entries())
139
139
  if (o.start.idx === o.end.idx)
140
140
  s(o.start.idx, n, o.start.offset, o.end.offset);
141
141
  else
@@ -143,8 +143,8 @@ function I(r, c, m) {
143
143
  e === o.start.idx ? s(e, n, o.start.offset, -1, "begin") : e === o.end.idx ? s(e, n, -1, o.end.offset, "end") : s(e, n, -1, -1, "middle");
144
144
  return i;
145
145
  }
146
- function V(r, c) {
147
- const m = r.items.map((i) => i.str);
146
+ function V(l, c) {
147
+ const m = l.items.map((i) => i.str);
148
148
  for (let i = 0; i < c.length; i++) {
149
149
  const s = c[i];
150
150
  if (s && s.nodeType !== Node.TEXT_NODE) {
@@ -153,19 +153,19 @@ function V(r, c) {
153
153
  }
154
154
  }
155
155
  }
156
- function H(r = {}) {
157
- return { matchCase: !1, wholeWords: !1, ...r };
156
+ function H(l = {}) {
157
+ return { matchCase: !1, wholeWords: !1, ...l };
158
158
  }
159
- function S(r, c, m) {
159
+ function S(l, c, m) {
160
160
  const i = [];
161
161
  function s(n, o, e = -1, t = -1, d) {
162
162
  var f, E;
163
163
  const h = c.items[n], g = [];
164
- let l = "", x = "", C = "", a = m[n];
164
+ let r = "", x = "", C = "", a = m[n];
165
165
  if (!a)
166
166
  return;
167
- e >= 0 && t >= 0 ? l = h.str.substring(e, t) : e < 0 && t < 0 ? l = h.str : e >= 0 ? l = h.str.substring(e) : t >= 0 && (l = h.str.substring(0, t));
168
- const M = document.createTextNode(l), N = document.createElement("span");
167
+ e >= 0 && t >= 0 ? r = h.str.substring(e, t) : e < 0 && t < 0 ? r = h.str : e >= 0 ? r = h.str.substring(e) : t >= 0 && (r = h.str.substring(0, t));
168
+ const M = document.createTextNode(r), N = document.createElement("span");
169
169
  if (N.style.background = d, N.append(M), g.push(N), e > 0)
170
170
  if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
171
171
  x = h.str.substring(0, e);
@@ -205,7 +205,7 @@ function S(r, c, m) {
205
205
  }
206
206
  a.replaceChildren(...g), i.push({ element: N, index: o });
207
207
  }
208
- for (const [n, o] of r.entries()) {
208
+ for (const [n, o] of l.entries()) {
209
209
  const { start: e, end: t, color: d } = o;
210
210
  e.idx === t.idx && s(e.idx, n, e.offset, t.offset, d);
211
211
  }
@@ -1,55 +1,93 @@
1
- import { useState as m, useCallback as r, useEffect as C } from "react";
2
- import { getHighlightOptionsWithDefaults as H, findMatches as M } from "../highlight.js";
1
+ import { useState as f, useCallback as p, useEffect as w } from "react";
2
+ import { getHighlightOptionsWithDefaults as k, findMatches as P } from "../highlight.js";
3
3
  import "../charators.js";
4
- const k = (s) => {
5
- const [n, c] = m(void 0), [f, l] = m([]), u = r(async (t) => {
6
- if (!t)
4
+ const x = (n) => {
5
+ const e = Math.min(...n.map((s) => s.left)), c = Math.max(...n.map((s) => s.left + s.width)), o = Math.min(...n.map((s) => s.bottom)), t = Math.max(...n.map((s) => s.height));
6
+ return { left: e, bottom: o, width: c - e, height: t };
7
+ }, N = (n) => n.flatMap((e) => e.rects ?? (e.rect ? [e.rect] : [])), O = (n) => {
8
+ const e = n.reduce((o, t) => {
9
+ const s = Math.round(t.bottom);
10
+ return o[s] || (o[s] = []), o[s].push(t), o;
11
+ }, {});
12
+ return Object.entries(e).sort((o, t) => Number(t[0]) - Number(o[0])).map(([o, t]) => x(t));
13
+ }, L = (n) => {
14
+ const e = {};
15
+ for (const c of n) {
16
+ const o = c.keyword, t = e[o] ?? [];
17
+ t.push(c), e[o] = t;
18
+ }
19
+ return e;
20
+ }, j = (n, e) => {
21
+ const c = n[0], o = N(n), t = o.length > 0 ? O(o) : c.rect ? [c.rect] : [];
22
+ return {
23
+ ...c,
24
+ pageMatchIdx: e,
25
+ rect: t[0] ?? c.rect,
26
+ rects: t
27
+ };
28
+ }, v = (n) => {
29
+ const e = {};
30
+ for (const t of n) {
31
+ const s = e[t.page] ?? [];
32
+ s.push(t), e[t.page] = s;
33
+ }
34
+ let c = 0;
35
+ const o = [];
36
+ for (const t of Object.values(e)) {
37
+ const s = L(t);
38
+ for (const g of Object.values(s))
39
+ o.push(j(g, c++));
40
+ }
41
+ return o;
42
+ }, K = (n) => {
43
+ const [e, c] = f(void 0), [o, t] = f([]), s = p(async (r) => {
44
+ if (!r)
7
45
  return {};
8
- const i = t.numPages, e = {};
9
- for (let o = 1; o <= i; o++) {
10
- const h = await t.getPage(o);
11
- e[o.toString()] = await h.getTextContent();
46
+ const i = r.numPages, h = {};
47
+ for (let a = 1; a <= i; a++) {
48
+ const u = await r.getPage(a);
49
+ h[a.toString()] = await u.getTextContent();
12
50
  }
13
- return e;
14
- }, []), p = r(async (t) => {
15
- c(t);
16
- }, []), g = r(() => {
17
- l([]), c(void 0);
51
+ return h;
52
+ }, []), g = p(async (r) => {
53
+ c(r);
54
+ }, []), l = p(() => {
55
+ t([]), c(void 0);
18
56
  }, []);
19
- return C(() => {
20
- s && u(s).then((t) => {
57
+ return w(() => {
58
+ n && s(n).then((r) => {
21
59
  let i = [];
22
- for (const { keyword: e, highlightColor: o, options: h } of n) {
23
- if (!e)
60
+ for (const { keyword: h, highlightColor: a, options: u } of e) {
61
+ if (!h)
24
62
  continue;
25
- const y = H(h);
26
- for (const a of Object.keys(t)) {
27
- const b = M(
28
- [e],
29
- t[a],
30
- Number(a) - 1,
31
- y
32
- ).map((w, x) => ({
33
- ...w,
34
- page: Number(a),
35
- pageMatchIdx: x,
36
- color: o,
37
- keyword: e
63
+ const b = k(u);
64
+ for (const m of Object.keys(r)) {
65
+ const d = P(
66
+ [h],
67
+ r[m],
68
+ Number(m) - 1,
69
+ b
70
+ ).map((M, y) => ({
71
+ ...M,
72
+ page: Number(m),
73
+ pageMatchIdx: y,
74
+ color: a,
75
+ keyword: h
38
76
  }));
39
- i = [...i, ...b];
77
+ i = [...i, ...d];
40
78
  }
41
79
  }
42
- l(i);
80
+ t(v(i));
43
81
  }).catch(() => {
44
- g();
82
+ l();
45
83
  });
46
- }, [n, s, g, u]), {
47
- highlight: p,
48
- clear: g,
49
- highlightMatches: f,
50
- highlightKeywords: n
84
+ }, [e, n, l, s]), {
85
+ highlight: g,
86
+ clear: l,
87
+ highlightMatches: o,
88
+ highlightKeywords: e
51
89
  };
52
90
  };
53
91
  export {
54
- k as useHighlight
92
+ K as useHighlight
55
93
  };
@@ -1,6 +1,6 @@
1
1
  import { useState as E, useCallback as h, useEffect as A } from "react";
2
2
  import { appConsole as l } from "../appConsole.js";
3
- const b = /* @__PURE__ */ new Date("2026-02-25T12:07:51.705Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
3
+ const b = /* @__PURE__ */ new Date("2026-03-04T09:04:06.326Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
4
4
  invalidLicense: `You are currently using without a valid license. ${d}`,
5
5
  mismatchedDomain: `Your license key is not valid for the current domain / IP. ${d}`,
6
6
  expired: `Your license key has expired. ${d}`,