@epam/ai-dial-attachment-canvas 1.1.0-dev.447 → 1.1.0-dev.456

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.
@@ -0,0 +1,260 @@
1
+ import "./PdfContent.css";
2
+ import { a as e, n as t, r as n } from "./LazyContentBoundary-CL7J_W9c.js";
3
+ import { mergeClasses as r } from "@epam/ai-dial-chat-shared";
4
+ import { DIAL_ICON_SIZE as i, DIAL_KIT_ICON_STROKE as a, Dropdown as o, ElementSize as s, FabButton as c, Input as ee } from "@epam/ai-dial-ui-kit";
5
+ import { IconMenu2 as te, IconX as ne } from "@tabler/icons-react";
6
+ import { useCallback as l, useEffect as u, useId as re, useRef as d, useState as f } from "react";
7
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
8
+ import { DocumentPreview as ie, PageThumbnail as ae } from "@epam/ai-dial-react-pdf-highlighter";
9
+ var oe = { viewer: "_viewer_1gfxm_1" }, h = null, g = (e) => (h ||= new Promise((t, n) => {
10
+ try {
11
+ t(e());
12
+ } catch (e) {
13
+ n(e);
14
+ }
15
+ }).catch((e) => {
16
+ throw h = null, e;
17
+ }), h), se = 15, _ = 3, ce = 172, le = 400, v = 150, ue = 60, y = ({ url: h, highlights: y, selectedHighlightId: b, selectedPageNumber: x, loadPdf: de, configurePdfWorker: S, hideHeader: fe = !1, labels: { thumbnailsLabel: pe = "Thumbnails", showThumbnailsLabel: me = "Show thumbnails", hideThumbnailsLabel: he = "Hide thumbnails", pageNumberLabel: ge = "Page number", loadingLabel: _e = "Loading…", errorLabel: ve = "Failed to load content", retryLabel: ye = "Retry" } = {} }) => {
18
+ let [C, w] = f(() => S ? "preparing" : "ready"), [T, be] = f(0);
19
+ u(() => {
20
+ if (!S) return;
21
+ w("preparing");
22
+ let e = !1;
23
+ return g(S).then(() => {
24
+ e || w("ready");
25
+ }).catch(() => {
26
+ e || w("error");
27
+ }), () => {
28
+ e = !0;
29
+ };
30
+ }, [S, T]);
31
+ let xe = l(() => {
32
+ be((e) => e + 1);
33
+ }, []), E = re(), [D, Se] = f(0), [O, k] = f(/* @__PURE__ */ new Map()), [A, j] = f(!1), [M, N] = f(() => x ?? (b ? y.find((e) => e.id === b)?.bboxes[0]?.page ?? 1 : 1)), P = d(null), F = d(null), [Ce, I] = f([]), [L, we] = f(ce), [R, Te] = f(le), [z, B] = f(0), V = d(!1), H = d(0), U = d(null);
34
+ u(() => {
35
+ if (x != null) {
36
+ N(x);
37
+ return;
38
+ }
39
+ if (!b) return;
40
+ let e = y.find((e) => e.id === b)?.bboxes[0]?.page;
41
+ e != null && N(e);
42
+ }, [
43
+ x,
44
+ b,
45
+ y
46
+ ]), u(() => {
47
+ let e = F.current;
48
+ if (!A || !e) return;
49
+ let t = new ResizeObserver((e) => {
50
+ let t = e[0]?.contentRect.height;
51
+ t && Te(t);
52
+ });
53
+ return t.observe(e), () => t.disconnect();
54
+ }, [A]);
55
+ let Ee = l((e) => {
56
+ if (!e || V.current) return;
57
+ let t = e.getBoundingClientRect().height;
58
+ t > 0 && (V.current = !0, we(t));
59
+ }, []), De = l((e) => {
60
+ H.current = e.currentTarget.scrollTop, U.current ??= requestAnimationFrame(() => {
61
+ U.current = null, B(H.current);
62
+ });
63
+ }, []);
64
+ u(() => () => {
65
+ U.current != null && cancelAnimationFrame(U.current);
66
+ }, []);
67
+ let W = l((e) => {
68
+ if (D === 0) return;
69
+ let t = Math.max(0, (M - 1) * L - e.clientHeight / 2 + L / 2);
70
+ H.current = t, B(t), e.scrollTop = t;
71
+ }, [
72
+ M,
73
+ D,
74
+ L
75
+ ]), Oe = l((e) => {
76
+ F.current = e, e && W(e);
77
+ }, [W]);
78
+ u(() => {
79
+ let e = F.current;
80
+ e && W(e);
81
+ }, [W]);
82
+ let G = Math.max(0, Math.floor(z / L) - _), ke = Math.ceil(R / L) + _ * 2, K = Math.min(D - 1, G + ke);
83
+ u(() => {
84
+ if (D === 0) return;
85
+ let e = Math.min(D, se);
86
+ I(Array.from({ length: e }, (e, t) => t + 1));
87
+ }, [D]), u(() => {
88
+ if (!A || D === 0) return;
89
+ let e = setTimeout(() => {
90
+ I((e) => {
91
+ let t = new Set(e), n = !1;
92
+ for (let e = G + 1; e <= K + 1; e++) t.has(e) || (t.add(e), n = !0);
93
+ return n ? Array.from(t).sort((e, t) => e - t) : e;
94
+ });
95
+ }, v);
96
+ return () => clearTimeout(e);
97
+ }, [
98
+ A,
99
+ G,
100
+ K,
101
+ D
102
+ ]), u(() => {
103
+ if (D === 0) return;
104
+ let e = setTimeout(() => {
105
+ let e = Math.ceil(R / L / 2) + _, t = Math.max(0, M - 1 - e), n = Math.min(D - 1, M - 1 + e);
106
+ I((e) => {
107
+ let r = new Set(e), i = !1;
108
+ for (let e = t + 1; e <= n + 1; e++) r.has(e) || (r.add(e), i = !0);
109
+ return i ? Array.from(r).sort((e, t) => e - t) : e;
110
+ });
111
+ }, v);
112
+ return () => clearTimeout(e);
113
+ }, [
114
+ M,
115
+ D,
116
+ R,
117
+ L
118
+ ]);
119
+ let Ae = l((e) => {
120
+ k((t) => new Map([...t, ...e]));
121
+ }, []), [q, je] = f(!1), Me = l((e) => {
122
+ P.current = e, je(!0);
123
+ }, []), J = d(null);
124
+ u(() => {
125
+ if (!q) return;
126
+ let e = J.current, t = e?.querySelector(".pdf-container"), n = e?.querySelector(".pdf-highlight-viewer");
127
+ if (!t || !n) return;
128
+ let r = () => {
129
+ let e = n.scrollWidth - n.clientWidth;
130
+ e > 0 && (n.scrollLeft = e / 2);
131
+ };
132
+ r();
133
+ let i = new ResizeObserver(r);
134
+ i.observe(t), i.observe(n);
135
+ let a = P.current?.getZoom(), o = 0, s, c = () => {
136
+ let e = P.current?.getZoom();
137
+ e !== a && (a = e, o = ue), o > 0 && (r(), --o), s = requestAnimationFrame(c);
138
+ };
139
+ return s = requestAnimationFrame(c), () => {
140
+ cancelAnimationFrame(s), i.disconnect();
141
+ };
142
+ }, [q]), u(() => {
143
+ if (!q || b || x != null) return;
144
+ let e = requestAnimationFrame(() => {
145
+ P.current?.navigateToPage(1);
146
+ });
147
+ return () => cancelAnimationFrame(e);
148
+ }, [
149
+ q,
150
+ b,
151
+ x
152
+ ]);
153
+ let Y = l((e) => {
154
+ N(e), P.current?.navigateToPage(e);
155
+ }, []), Ne = l((e) => {
156
+ N(e);
157
+ }, []), [X, Z] = f(() => String(M));
158
+ u(() => {
159
+ Z(String(M));
160
+ }, [M]);
161
+ let Q = l((e) => {
162
+ let t = Number(e);
163
+ Number.isInteger(t) && t >= 1 && t <= D ? Y(t) : Z(String(M));
164
+ }, [
165
+ D,
166
+ M,
167
+ Y
168
+ ]);
169
+ if (!h) return null;
170
+ if (C === "preparing") return /* @__PURE__ */ p(n, { loadingLabel: _e });
171
+ if (C === "error") return /* @__PURE__ */ p(t, {
172
+ errorLabel: ve,
173
+ retryLabel: ye,
174
+ onRetry: xe
175
+ });
176
+ let $ = [];
177
+ for (let e = G + 1; e <= K + 1 && e <= D; e++) $.push(/* @__PURE__ */ p("div", {
178
+ ref: e === G + 1 ? Ee : void 0,
179
+ children: /* @__PURE__ */ p(ae, {
180
+ pageNum: e,
181
+ onSelectPage: Y,
182
+ isSelected: M === e,
183
+ isLoading: !O.has(e),
184
+ thumbnailUrl: O.get(e) ?? null
185
+ })
186
+ }, e));
187
+ let Pe = G * L, Fe = Math.max(0, D - K - 1) * L;
188
+ return /* @__PURE__ */ m("div", {
189
+ className: "relative flex h-full overflow-hidden",
190
+ children: [D > 0 && /* @__PURE__ */ p("div", {
191
+ className: "absolute start-3 top-3 z-10",
192
+ children: /* @__PURE__ */ p(o, {
193
+ open: A,
194
+ onOpenChange: j,
195
+ placement: "bottom-start",
196
+ matchReferenceWidth: !1,
197
+ renderOverlay: () => /* @__PURE__ */ m("div", {
198
+ className: "flex w-36 flex-col",
199
+ children: [/* @__PURE__ */ p("div", {
200
+ className: "shrink-0 p-1",
201
+ children: /* @__PURE__ */ p(ee, {
202
+ size: s.Small,
203
+ "aria-label": ge,
204
+ value: X,
205
+ postfix: `/ ${D}`,
206
+ inputMode: "numeric",
207
+ onChange: (e) => Z(e ?? ""),
208
+ onBlur: () => Q(X),
209
+ onKeyDown: (e) => {
210
+ e.key === "Enter" && Q(X);
211
+ }
212
+ })
213
+ }), /* @__PURE__ */ m("div", {
214
+ ref: Oe,
215
+ id: E,
216
+ role: "region",
217
+ "aria-label": pe,
218
+ onScroll: De,
219
+ className: "max-h-[70vh] min-h-0 overflow-y-auto overflow-x-hidden p-1 [scrollbar-gutter:stable]",
220
+ children: [
221
+ /* @__PURE__ */ p("div", { style: { height: Pe } }),
222
+ $,
223
+ /* @__PURE__ */ p("div", { style: { height: Fe } })
224
+ ]
225
+ })]
226
+ }),
227
+ children: /* @__PURE__ */ p(c, {
228
+ icon: p(A ? ne : te, {
229
+ size: i.LG,
230
+ stroke: a,
231
+ "aria-hidden": !0
232
+ }),
233
+ "aria-label": A ? he : me,
234
+ "aria-expanded": A,
235
+ "aria-controls": A ? E : void 0
236
+ })
237
+ })
238
+ }), /* @__PURE__ */ p("div", {
239
+ ref: J,
240
+ className: r("min-w-0 flex-1 overflow-hidden", oe.viewer),
241
+ children: /* @__PURE__ */ p(ie, {
242
+ fileUrl: h,
243
+ loadFileCb: de ?? e,
244
+ highlights: y,
245
+ selectedHighlightId: b,
246
+ selectedPageNumber: x,
247
+ showOccurrences: !1,
248
+ onTotalPagesChange: Se,
249
+ thumbnailPageNumbers: Ce,
250
+ onThumbnailsLoaded: Ae,
251
+ onViewerReady: Me,
252
+ onCurrentPageChange: Ne,
253
+ viewerOptions: { enableVirtualScrolling: !0 },
254
+ containerClassName: fe ? "[&>div:first-child]:hidden" : void 0
255
+ })
256
+ })]
257
+ });
258
+ };
259
+ //#endregion
260
+ export { y as PdfContent };
@@ -1 +1 @@
1
- {"version":3,"file":"PdfContent.d.ts","sourceRoot":"","sources":["../../../src/components/PdfContent/PdfContent.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MA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AAyF;IACzF,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B;AAED,8GAA8G;AAC9G,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAogB1C,CAAC"}
package/index.js CHANGED
@@ -521,7 +521,7 @@ var V = {
521
521
  jsonExpandIcon: "_jsonExpandIcon_13ogb_54",
522
522
  jsonCollapseIcon: "_jsonCollapseIcon_13ogb_67",
523
523
  jsonCollapsedContent: "_jsonCollapsedContent_13ogb_84"
524
- }, ye = () => oe(async () => ({ default: (await import("./PdfContent-solOLCRi.js")).PdfContent })), be = ({ url: e, fileName: t, loadErrorLabel: n }) => {
524
+ }, ye = () => oe(async () => ({ default: (await import("./PdfContent-DhfjgYL-.js")).PdfContent })), be = ({ url: e, fileName: t, loadErrorLabel: n }) => {
525
525
  let [r, i] = F(!1);
526
526
  return M(() => {
527
527
  i(!1);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@epam/ai-dial-attachment-canvas",
3
3
  "description": "Canvas viewer for rendering attachment content — images, PDFs, Office documents, CSV, JSON, markdown, and plain text",
4
- "version": "1.1.0-dev.447",
4
+ "version": "1.1.0-dev.456",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -17,10 +17,10 @@
17
17
  }
18
18
  },
19
19
  "peerDependencies": {
20
- "@epam/ai-dial-chat-shared": "1.1.0-dev.447",
21
- "@epam/ai-dial-react-pdf-highlighter": "0.2.0-dev.29",
20
+ "@epam/ai-dial-chat-shared": "1.1.0-dev.456",
21
+ "@epam/ai-dial-react-pdf-highlighter": "0.2.0-dev.38",
22
22
  "@epam/ai-dial-shared": "0.48.0",
23
- "@epam/ai-dial-sidebar": "1.1.0-dev.447",
23
+ "@epam/ai-dial-sidebar": "1.1.0-dev.456",
24
24
  "@epam/ai-dial-visualizer-connector": "0.48.0",
25
25
  "@epam/ai-dial-ui-kit": "^0.14.0-dev.15",
26
26
  "@epam/pdf-highlighter-kit": "^0.0.18",
@@ -1,239 +0,0 @@
1
- import "./PdfContent.css";
2
- import { a as e, n as t, r as n } from "./LazyContentBoundary-CL7J_W9c.js";
3
- import { mergeClasses as r } from "@epam/ai-dial-chat-shared";
4
- import { DIAL_ICON_SIZE as i, DIAL_KIT_ICON_STROKE as a, Dropdown as o, ElementSize as s, FabButton as c, Input as l } from "@epam/ai-dial-ui-kit";
5
- import { IconMenu2 as ee, IconX as te } from "@tabler/icons-react";
6
- import { useCallback as u, useEffect as d, useId as ne, useRef as f, useState as p } from "react";
7
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
8
- import { DocumentPreview as re, PageThumbnail as ie } from "@epam/ai-dial-react-pdf-highlighter";
9
- var ae = { viewer: "_viewer_1gfxm_1" }, g = null, _ = (e) => (g ||= new Promise((t, n) => {
10
- try {
11
- t(e());
12
- } catch (e) {
13
- n(e);
14
- }
15
- }).catch((e) => {
16
- throw g = null, e;
17
- }), g), v = 15, y = 3, b = 172, oe = 400, se = 150, ce = 60, x = ({ url: g, highlights: x, selectedHighlightId: S, selectedPageNumber: C, loadPdf: le, configurePdfWorker: w, hideHeader: ue = !1, labels: { thumbnailsLabel: de = "Thumbnails", showThumbnailsLabel: fe = "Show thumbnails", hideThumbnailsLabel: pe = "Hide thumbnails", pageNumberLabel: me = "Page number", loadingLabel: he = "Loading…", errorLabel: ge = "Failed to load content", retryLabel: _e = "Retry" } = {} }) => {
18
- let [T, E] = p(() => w ? "preparing" : "ready"), [ve, ye] = p(0);
19
- d(() => {
20
- if (!w) return;
21
- E("preparing");
22
- let e = !1;
23
- return _(w).then(() => {
24
- e || E("ready");
25
- }).catch(() => {
26
- e || E("error");
27
- }), () => {
28
- e = !0;
29
- };
30
- }, [w, ve]);
31
- let D = u(() => {
32
- ye((e) => e + 1);
33
- }, []), O = ne(), [k, A] = p(0), [j, M] = p(/* @__PURE__ */ new Map()), [N, P] = p(!1), [F, I] = p(() => C ?? (S ? x.find((e) => e.id === S)?.bboxes[0]?.page ?? 1 : 1)), L = f(null), R = f(null), [be, z] = p([]), [B, xe] = p(b), [Se, Ce] = p(oe), [we, Te] = p(0), V = f(!1), H = f(0), U = f(null);
34
- d(() => {
35
- if (C != null) {
36
- I(C);
37
- return;
38
- }
39
- if (!S) return;
40
- let e = x.find((e) => e.id === S)?.bboxes[0]?.page;
41
- e != null && I(e);
42
- }, [
43
- C,
44
- S,
45
- x
46
- ]), d(() => {
47
- let e = R.current;
48
- if (!N || !e) return;
49
- let t = new ResizeObserver((e) => {
50
- let t = e[0]?.contentRect.height;
51
- t && Ce(t);
52
- });
53
- return t.observe(e), () => t.disconnect();
54
- }, [N]);
55
- let Ee = u((e) => {
56
- if (!e || V.current) return;
57
- let t = e.getBoundingClientRect().height;
58
- t > 0 && (V.current = !0, xe(t));
59
- }, []), De = u((e) => {
60
- H.current = e.currentTarget.scrollTop, U.current ??= requestAnimationFrame(() => {
61
- U.current = null, Te(H.current);
62
- });
63
- }, []);
64
- d(() => () => {
65
- U.current != null && cancelAnimationFrame(U.current);
66
- }, []), d(() => {
67
- let e = R.current;
68
- if (!e || k === 0) return;
69
- let t = (F - 1) * B - e.clientHeight / 2 + B / 2;
70
- e.scrollTo({
71
- top: Math.max(0, t),
72
- behavior: "smooth"
73
- });
74
- }, [
75
- F,
76
- k,
77
- N,
78
- B
79
- ]);
80
- let W = Math.max(0, Math.floor(we / B) - y), Oe = Math.ceil(Se / B) + y * 2, G = Math.min(k - 1, W + Oe);
81
- d(() => {
82
- if (k === 0) return;
83
- let e = Math.min(k, v);
84
- z(Array.from({ length: e }, (e, t) => t + 1));
85
- }, [k]), d(() => {
86
- if (!N || k === 0) return;
87
- let e = setTimeout(() => {
88
- z((e) => {
89
- let t = new Set(e), n = !1;
90
- for (let e = W + 1; e <= G + 1; e++) t.has(e) || (t.add(e), n = !0);
91
- return n ? Array.from(t).sort((e, t) => e - t) : e;
92
- });
93
- }, se);
94
- return () => clearTimeout(e);
95
- }, [
96
- N,
97
- W,
98
- G,
99
- k
100
- ]);
101
- let ke = u((e) => {
102
- M((t) => new Map([...t, ...e]));
103
- }, []), [K, q] = p(!1), Ae = u((e) => {
104
- L.current = e, q(!0);
105
- }, []), J = f(null);
106
- d(() => {
107
- if (!K) return;
108
- let e = J.current, t = e?.querySelector(".pdf-container"), n = e?.querySelector(".pdf-highlight-viewer");
109
- if (!t || !n) return;
110
- let r = () => {
111
- let e = n.scrollWidth - n.clientWidth;
112
- e > 0 && (n.scrollLeft = e / 2);
113
- };
114
- r();
115
- let i = new ResizeObserver(r);
116
- i.observe(t), i.observe(n);
117
- let a = L.current?.getZoom(), o = 0, s, c = () => {
118
- let e = L.current?.getZoom();
119
- e !== a && (a = e, o = ce), o > 0 && (r(), --o), s = requestAnimationFrame(c);
120
- };
121
- return s = requestAnimationFrame(c), () => {
122
- cancelAnimationFrame(s), i.disconnect();
123
- };
124
- }, [K]), d(() => {
125
- if (!K || S || C != null) return;
126
- let e = requestAnimationFrame(() => {
127
- L.current?.navigateToPage(1);
128
- });
129
- return () => cancelAnimationFrame(e);
130
- }, [
131
- K,
132
- S,
133
- C
134
- ]);
135
- let Y = u((e) => {
136
- I(e), L.current?.navigateToPage(e);
137
- }, []), [X, Z] = p(() => String(F));
138
- d(() => {
139
- Z(String(F));
140
- }, [F]);
141
- let Q = u((e) => {
142
- let t = Number(e);
143
- Number.isInteger(t) && t >= 1 && t <= k ? Y(t) : Z(String(F));
144
- }, [
145
- k,
146
- F,
147
- Y
148
- ]);
149
- if (!g) return null;
150
- if (T === "preparing") return /* @__PURE__ */ m(n, { loadingLabel: he });
151
- if (T === "error") return /* @__PURE__ */ m(t, {
152
- errorLabel: ge,
153
- retryLabel: _e,
154
- onRetry: D
155
- });
156
- let $ = [];
157
- for (let e = W + 1; e <= G + 1 && e <= k; e++) $.push(/* @__PURE__ */ m("div", {
158
- ref: e === W + 1 ? Ee : void 0,
159
- children: /* @__PURE__ */ m(ie, {
160
- pageNum: e,
161
- onSelectPage: Y,
162
- isSelected: F === e,
163
- isLoading: !j.has(e),
164
- thumbnailUrl: j.get(e) ?? null
165
- })
166
- }, e));
167
- let je = W * B, Me = Math.max(0, k - G - 1) * B;
168
- return /* @__PURE__ */ h("div", {
169
- className: "relative flex h-full overflow-hidden",
170
- children: [k > 0 && /* @__PURE__ */ m("div", {
171
- className: "absolute start-3 top-3 z-10",
172
- children: /* @__PURE__ */ m(o, {
173
- open: N,
174
- onOpenChange: P,
175
- placement: "bottom-start",
176
- matchReferenceWidth: !1,
177
- renderOverlay: () => /* @__PURE__ */ h("div", {
178
- className: "flex w-36 flex-col",
179
- children: [/* @__PURE__ */ m("div", {
180
- className: "shrink-0 p-1",
181
- children: /* @__PURE__ */ m(l, {
182
- size: s.Small,
183
- "aria-label": me,
184
- value: X,
185
- postfix: `/ ${k}`,
186
- inputMode: "numeric",
187
- onChange: (e) => Z(e ?? ""),
188
- onBlur: () => Q(X),
189
- onKeyDown: (e) => {
190
- e.key === "Enter" && Q(X);
191
- }
192
- })
193
- }), /* @__PURE__ */ h("div", {
194
- ref: R,
195
- id: O,
196
- role: "region",
197
- "aria-label": de,
198
- onScroll: De,
199
- className: "max-h-[70vh] min-h-0 overflow-y-auto overflow-x-hidden p-1 [scrollbar-gutter:stable]",
200
- children: [
201
- /* @__PURE__ */ m("div", { style: { height: je } }),
202
- $,
203
- /* @__PURE__ */ m("div", { style: { height: Me } })
204
- ]
205
- })]
206
- }),
207
- children: /* @__PURE__ */ m(c, {
208
- icon: m(N ? te : ee, {
209
- size: i.LG,
210
- stroke: a,
211
- "aria-hidden": !0
212
- }),
213
- "aria-label": N ? pe : fe,
214
- "aria-expanded": N,
215
- "aria-controls": N ? O : void 0
216
- })
217
- })
218
- }), /* @__PURE__ */ m("div", {
219
- ref: J,
220
- className: r("min-w-0 flex-1 overflow-hidden", ae.viewer),
221
- children: /* @__PURE__ */ m(re, {
222
- fileUrl: g,
223
- loadFileCb: le ?? e,
224
- highlights: x,
225
- selectedHighlightId: S,
226
- selectedPageNumber: C,
227
- showOccurrences: !1,
228
- onTotalPagesChange: A,
229
- thumbnailPageNumbers: be,
230
- onThumbnailsLoaded: ke,
231
- onViewerReady: Ae,
232
- viewerOptions: { enableVirtualScrolling: !0 },
233
- containerClassName: ue ? "[&>div:first-child]:hidden" : void 0
234
- })
235
- })]
236
- });
237
- };
238
- //#endregion
239
- export { x as PdfContent };