@epam/ai-dial-quotations 1.3.0-dev.317 → 1.3.0-dev.321

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.
package/index.d.ts CHANGED
@@ -13,7 +13,7 @@ export type { UseCitationMarkdownComponentsCallbacks } from './hooks/useCitation
13
13
  export { useCitationTagRenderer } from './hooks/useCitationTagRenderer/useCitationTagRenderer';
14
14
  export { gatherSameSourceAnnotations, groupAnnotations, groupAnnotationsByCitId, groupAnnotationsBySource, } from './utils/group-annotations-by-source';
15
15
  export type { AnnotationGroup } from './utils/group-annotations-by-source';
16
- export { annotationHighlightId, annotationHighlightIds, annotationsToPdfHighlights, annotationToOfficeHighlightLocations, getAnnotationPdfPage, isDocxRangeSelector, isExcelRcRangeSelector, isPptxRangeSelector, resolveMessageAnnotations, } from './utils/annotation';
16
+ export { annotationHighlightId, annotationHighlightIds, annotationsToPdfHighlights, annotationToOfficeHighlightLocations, getAnnotationPdfPage, getCitationGroupPage, isDocxRangeSelector, isExcelRcRangeSelector, isPptxRangeSelector, resolveMessageAnnotations, } from './utils/annotation';
17
17
  export type { DocxOfficeHighlightLocation, DocxTableRowOfficeHighlightLocation, ExcelOfficeHighlightLocation, OfficeHighlightLocation, PptxOfficeHighlightLocation, PptxTableRowOfficeHighlightLocation, } from './models/office-highlight';
18
18
  export { injectCitationSentinels, prepareCitationContent, replaceCitTagsWithSourceNames, replaceSentinelsInChildren, stripCitTagsWhileStreaming, } from './utils/citation-injection';
19
19
  export { isReferenceOnlyAttachment, parsePdfPageReference, getReferenceAttachmentGroups, } from './utils/reference-attachment';
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AACtE,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,GACvB,MAA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,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,2BAA2B,EAC3B,mCAAmC,EACnC,4BAA4B,EAC5B,uBAAuB,EACvB,2BAA2B,EAC3B,mCAAmC,GACpC,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,6BAA6B,EAC7B,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,cAAc,oCAAoC,CAAC"}
package/index.js CHANGED
@@ -1,58 +1,58 @@
1
1
  import { MIMEType as e, MarkdownRenderer as t, buildCssVars as n, isAnnotationSelector as r, mergeClasses as i, normalizePersistedHtmlTagAttachmentType as a, normalizeRawAnnotations as o } from "@epam/ai-dial-chat-shared";
2
2
  import { DIAL_KIT_ICON_STROKE as s, DialItemType as c, Dropdown as l, DropdownOverlayRole as u, ElementSize as d, EllipsisTooltip as f, FileIcon as p, GhostIconButton as m, LinkButton as h, NeutralButton as g, PrimaryButton as _ } from "@epam/ai-dial-ui-kit";
3
3
  import { IconChevronLeft as ee, IconChevronRight as v } from "@tabler/icons-react";
4
- import { createContext as y, useCallback as b, useContext as x, useEffect as S, useId as te, useLayoutEffect as C, useMemo as w, useRef as T, useState as E } from "react";
5
- import { Fragment as D, jsx as O, jsxs as k } from "react/jsx-runtime";
4
+ import { createContext as y, useCallback as b, useContext as x, useEffect as te, useId as ne, useLayoutEffect as S, useMemo as C, useRef as re, useState as w } from "react";
5
+ import { Fragment as T, jsx as E, jsxs as D } from "react/jsx-runtime";
6
6
  //#region src/constants/public-class-names.ts
7
- var A = {
7
+ var O = {
8
8
  citationCard: "dial-quotations-citation-card",
9
9
  citationDropdown: "dial-quotations-citation-dropdown",
10
10
  citationMarker: "dial-quotations-citation-marker"
11
- }, ne = (t) => {
11
+ }, ie = (t) => {
12
12
  let n = t.body?.source?.attachment?.type;
13
13
  return n === e.HTML || n === e.XHTML;
14
- }, j = (e) => {
14
+ }, k = (e) => {
15
15
  try {
16
16
  return decodeURIComponent(e);
17
17
  } catch {
18
18
  return e;
19
19
  }
20
- }, M = (e) => {
20
+ }, A = (e) => {
21
21
  try {
22
22
  let t = new URL(e);
23
- return t.pathname.split("/").map((e) => j(e)).filter(Boolean).at(-1) ?? t.hostname;
23
+ return t.pathname.split("/").map((e) => k(e)).filter(Boolean).at(-1) ?? t.hostname;
24
24
  } catch {
25
- return e.split("/").map((e) => j(e)).filter(Boolean).at(-1) ?? e;
25
+ return e.split("/").map((e) => k(e)).filter(Boolean).at(-1) ?? e;
26
26
  }
27
- }, N = /\.([a-z0-9]{1,10})$/i, P = (e) => {
28
- let t = e == null ? null : N.exec(e.trim());
27
+ }, j = /\.([a-z0-9]{1,10})$/i, M = (e) => {
28
+ let t = e == null ? null : j.exec(e.trim());
29
29
  return t == null ? void 0 : `.${t[1].toLowerCase()}`;
30
- }, re = (e) => {
30
+ }, ae = (e) => {
31
31
  let t = e.body?.source?.attachment, n = t?.url;
32
- return (n == null ? void 0 : P(M(n))) ?? P(t?.title);
33
- }, F = (e, t) => e.body?.source?.attachment?.title ?? M(t), I = (e) => {
32
+ return (n == null ? void 0 : M(A(n))) ?? M(t?.title);
33
+ }, N = (e, t) => e.body?.source?.attachment?.title ?? A(t), P = (e) => {
34
34
  let t = e.target?.selector;
35
35
  return t?.type === "html_tag" ? t : void 0;
36
- }, ie = (e) => I(e) != null, L = (e) => {
36
+ }, oe = (e) => P(e) != null, F = (e) => {
37
37
  let t = /* @__PURE__ */ new Map();
38
38
  for (let n of e) {
39
- if (ie(n)) continue;
39
+ if (oe(n)) continue;
40
40
  let e = n.body?.source?.attachment?.url;
41
41
  if (e == null) continue;
42
42
  let r = t.get(e);
43
43
  r ? r.annotations.push(n) : t.set(e, {
44
44
  groupKey: e,
45
45
  sourceUrl: e,
46
- sourceName: F(n, e),
46
+ sourceName: N(n, e),
47
47
  annotations: [n],
48
48
  primaryAnnotation: n
49
49
  });
50
50
  }
51
51
  return Array.from(t.values());
52
- }, R = (e) => {
52
+ }, I = (e) => {
53
53
  let t = /* @__PURE__ */ new Map();
54
54
  for (let n of e) {
55
- let e = I(n)?.id;
55
+ let e = P(n)?.id;
56
56
  if (e == null) continue;
57
57
  let r = n.body?.source?.attachment?.url;
58
58
  if (r == null) continue;
@@ -60,109 +60,109 @@ var A = {
60
60
  i ? i.annotations.push(n) : t.set(e, {
61
61
  groupKey: `cit:${e}`,
62
62
  sourceUrl: r,
63
- sourceName: F(n, r),
63
+ sourceName: N(n, r),
64
64
  annotations: [n],
65
65
  primaryAnnotation: n
66
66
  });
67
67
  }
68
68
  return Array.from(t.values());
69
- }, z = (e) => [...R(e), ...L(e)], B = (e, t) => {
69
+ }, L = (e) => [...I(e), ...F(e)], se = (e, t) => {
70
70
  let n = e.body?.source?.attachment?.url;
71
71
  return n == null || !t.includes(e) ? [e] : t.filter((e) => e.body?.source?.attachment?.url === n);
72
- }, V = {
72
+ }, R = {
73
73
  card: "_card_1kph1_1",
74
74
  quote: "_quote_1kph1_5",
75
75
  title: "_title_1kph1_9",
76
76
  switcher: "_switcher_1kph1_13",
77
77
  sourceName: "_sourceName_1kph1_17"
78
- }, H = ({ group: e, activeIndex: r, onIndexChange: a, onPreview: o, onOpenInBrowser: l, isDownloadEnabled: u = !0, headerIcon: g, labels: y, typography: b, colors: x }) => {
79
- let w = e.annotations.length, D = e.annotations[r] ?? e.primaryAnnotation, j = w > 1, M = o == null || ne(D), N = M ? void 0 : re(D), P = N ?? e.sourceName, F = g ?? (N == null ? void 0 : /* @__PURE__ */ O(p, {
78
+ }, z = ({ group: e, activeIndex: r, onIndexChange: a, onPreview: o, onOpenInBrowser: l, isDownloadEnabled: u = !0, headerIcon: g, labels: y, typography: b, colors: x }) => {
79
+ let C = e.annotations.length, T = e.annotations[r] ?? e.primaryAnnotation, k = C > 1, A = o == null || ie(T), j = A ? void 0 : ae(T), M = j ?? e.sourceName, N = g ?? (j == null ? void 0 : /* @__PURE__ */ E(p, {
80
80
  type: c.File,
81
- name: N,
82
- fileExtension: N,
81
+ name: j,
82
+ fileExtension: j,
83
83
  size: 16,
84
84
  decorative: !0,
85
85
  className: "shrink-0"
86
- })), I = b?.sourceNameClassName ?? "dial-tiny-text", ie = b?.titleClassName ?? "dial-body-semi-text", L = b?.quoteClassName ?? "dial-small-text", R = b?.quoteStrongClassName ?? "dial-small-semi-text", z = b?.switcherClassName ?? "dial-tiny-text", B = n({
86
+ })), P = b?.sourceNameClassName ?? "dial-tiny-text", oe = b?.titleClassName ?? "dial-body-semi-text", F = b?.quoteClassName ?? "dial-small-text", I = b?.quoteStrongClassName ?? "dial-small-semi-text", L = b?.switcherClassName ?? "dial-tiny-text", se = n({
87
87
  "--cc-card-bg": x?.cardBackground,
88
88
  "--cc-quote-text": x?.quoteText,
89
89
  "--cc-title-text": x?.titleText,
90
90
  "--cc-switcher-text": x?.switcherText,
91
91
  "--cc-source-name-text": x?.sourceNameText
92
- }), H = D.body?.quote, U = te(), W = T(null), [G, K] = E(!1), [ae, q] = E(!1);
93
- return S(() => {
94
- K(!1);
95
- }, [r, H]), C(() => {
96
- let e = W.current;
97
- if (!e || G) return;
98
- let t = () => q(e.scrollHeight > e.clientHeight + 1);
92
+ }), z = T.body?.quote, B = ne(), V = re(null), [H, U] = w(!1), [W, G] = w(!1);
93
+ return te(() => {
94
+ U(!1);
95
+ }, [r, z]), S(() => {
96
+ let e = V.current;
97
+ if (!e || H) return;
98
+ let t = () => G(e.scrollHeight > e.clientHeight + 1);
99
99
  t();
100
100
  let n = new ResizeObserver(t);
101
101
  return n.observe(e), () => n.disconnect();
102
- }, [H, G]), /* @__PURE__ */ k("div", {
102
+ }, [z, H]), /* @__PURE__ */ D("div", {
103
103
  role: "dialog",
104
104
  "aria-modal": "true",
105
105
  "aria-label": y.ariaLabel,
106
- style: B,
107
- className: i("flex w-[400px] max-w-full flex-col gap-3 rounded-lg p-4 shadow-lg", V.card, A.citationCard),
106
+ style: se,
107
+ className: i("flex w-[400px] max-w-full flex-col gap-3 rounded-lg p-4 shadow-lg", R.card, O.citationCard),
108
108
  children: [
109
- /* @__PURE__ */ k("div", {
109
+ /* @__PURE__ */ D("div", {
110
110
  className: "flex items-center justify-between gap-2",
111
- children: [/* @__PURE__ */ k("div", {
111
+ children: [/* @__PURE__ */ D("div", {
112
112
  className: "flex min-w-0 items-center gap-1",
113
- children: [F, /* @__PURE__ */ O(f, {
114
- text: P,
115
- className: i(I, "min-w-0", V.sourceName)
113
+ children: [N, /* @__PURE__ */ E(f, {
114
+ text: M,
115
+ className: i(P, "min-w-0", R.sourceName)
116
116
  })]
117
- }), j && /* @__PURE__ */ k("div", {
117
+ }), k && /* @__PURE__ */ D("div", {
118
118
  className: "flex shrink-0 items-center gap-1",
119
119
  children: [
120
- /* @__PURE__ */ O(m, {
121
- icon: /* @__PURE__ */ O(ee, {
120
+ /* @__PURE__ */ E(m, {
121
+ icon: /* @__PURE__ */ E(ee, {
122
122
  size: 14,
123
123
  className: "rtl:scale-x-[-1]",
124
124
  stroke: s
125
125
  }),
126
126
  size: d.Small,
127
127
  "aria-label": y.previousCitation,
128
- onClick: () => a((r - 1 + w) % w)
128
+ onClick: () => a((r - 1 + C) % C)
129
129
  }),
130
- /* @__PURE__ */ O("span", {
131
- className: i(z, V.switcher),
132
- children: y.formatSwitcherText(r + 1, w)
130
+ /* @__PURE__ */ E("span", {
131
+ className: i(L, R.switcher),
132
+ children: y.formatSwitcherText(r + 1, C)
133
133
  }),
134
- /* @__PURE__ */ O(m, {
135
- icon: /* @__PURE__ */ O(v, {
134
+ /* @__PURE__ */ E(m, {
135
+ icon: /* @__PURE__ */ E(v, {
136
136
  size: 14,
137
137
  className: "rtl:scale-x-[-1]",
138
138
  stroke: s
139
139
  }),
140
140
  size: d.Small,
141
141
  "aria-label": y.nextCitation,
142
- onClick: () => a((r + 1) % w)
142
+ onClick: () => a((r + 1) % C)
143
143
  })
144
144
  ]
145
145
  })]
146
146
  }),
147
- (D.body?.title || D.body?.quote || j) && /* @__PURE__ */ k("div", {
147
+ (T.body?.title || T.body?.quote || k) && /* @__PURE__ */ D("div", {
148
148
  className: "flex flex-col gap-3",
149
- children: [D.body?.title && /* @__PURE__ */ O("p", {
150
- className: i(ie, V.title, "wrap-break-word"),
151
- children: D.body.title
152
- }), (H || j) && /* @__PURE__ */ k("div", {
149
+ children: [T.body?.title && /* @__PURE__ */ E("p", {
150
+ className: i(oe, R.title, "wrap-break-word"),
151
+ children: T.body.title
152
+ }), (z || k) && /* @__PURE__ */ D("div", {
153
153
  className: "flex flex-col items-start gap-1",
154
- children: [/* @__PURE__ */ O("div", {
155
- ref: W,
156
- id: U,
157
- tabIndex: G ? 0 : void 0,
158
- className: i(L, V.quote, "w-full wrap-break-word", G ? "max-h-[min(20rem,50vh)] overflow-y-auto" : "line-clamp-6"),
159
- children: H && /* @__PURE__ */ O(t, {
160
- content: H,
154
+ children: [/* @__PURE__ */ E("div", {
155
+ ref: V,
156
+ id: B,
157
+ tabIndex: H ? 0 : void 0,
158
+ className: i(F, R.quote, "w-full wrap-break-word", H ? "max-h-[min(20rem,50vh)] overflow-y-auto" : "line-clamp-6"),
159
+ children: z && /* @__PURE__ */ E(t, {
160
+ content: z,
161
161
  classNames: {
162
- p: i(L, V.quote),
163
- ul: i(L, "ps-[1.5em]"),
164
- ol: L,
165
- strong: R
162
+ p: i(F, R.quote),
163
+ ul: i(F, "ps-[1.5em]"),
164
+ ol: F,
165
+ strong: I
166
166
  },
167
167
  codeBlockCopyLabel: y.codeBlockCopyLabel,
168
168
  codeBlockCopiedLabel: y.codeBlockCopiedLabel,
@@ -170,71 +170,71 @@ var A = {
170
170
  tableScrollRegionAriaLabel: y.tableScrollRegionAriaLabel,
171
171
  mathScrollRegionAriaLabel: y.mathScrollRegionAriaLabel
172
172
  })
173
- }), ae && /* @__PURE__ */ O(h, {
174
- label: G ? y.showLess : y.showMore,
173
+ }), W && /* @__PURE__ */ E(h, {
174
+ label: H ? y.showLess : y.showMore,
175
175
  size: d.Small,
176
- "aria-expanded": G,
177
- "aria-controls": U,
178
- onClick: () => K((e) => !e)
176
+ "aria-expanded": H,
177
+ "aria-controls": B,
178
+ onClick: () => U((e) => !e)
179
179
  })]
180
180
  })]
181
181
  }),
182
- /* @__PURE__ */ k("div", {
182
+ /* @__PURE__ */ D("div", {
183
183
  className: "flex justify-start gap-2",
184
- children: [o && /* @__PURE__ */ O(_, {
184
+ children: [o && /* @__PURE__ */ E(_, {
185
185
  label: y.preview,
186
186
  size: d.Small,
187
- onClick: () => o(D)
188
- }), (M || u) && /* @__PURE__ */ O(_, {
189
- label: M ? y.openInBrowser : y.download,
187
+ onClick: () => o(T)
188
+ }), (A || u) && /* @__PURE__ */ E(_, {
189
+ label: A ? y.openInBrowser : y.download,
190
190
  size: d.Small,
191
- onClick: () => l(D)
191
+ onClick: () => l(T)
192
192
  })]
193
193
  })
194
194
  ]
195
195
  });
196
- }, U = ({ annotationCount: e, onOpen: t, icon: n, labels: r, labelClassName: a = "dial-caption-text", ...o }) => /* @__PURE__ */ O(g, {
196
+ }, B = ({ annotationCount: e, onOpen: t, icon: n, labels: r, labelClassName: a = "dial-caption-text", ...o }) => /* @__PURE__ */ E(g, {
197
197
  size: d.Small,
198
- className: i("max-w-[240px]", A.citationMarker),
198
+ className: i("max-w-[240px]", O.citationMarker),
199
199
  textClassName: "min-w-0 truncate",
200
200
  iconBefore: n,
201
- label: /* @__PURE__ */ O("span", {
201
+ label: /* @__PURE__ */ E("span", {
202
202
  className: a,
203
203
  children: e > 1 ? r.labelWithOverflow : r.label
204
204
  }),
205
205
  "aria-label": r.ariaLabel,
206
206
  ...o,
207
207
  onClick: t
208
- }), W = y(null), G = W.Provider, K = () => {
209
- let e = x(W);
208
+ }), V = y(null), H = V.Provider, U = () => {
209
+ let e = x(V);
210
210
  if (e == null) throw Error("useCitationCardContext must be used within a CitationCardProvider");
211
211
  return e;
212
- }, ae = { trigger: "_trigger_119c8_7" }, q = ({ group: e, onPreview: t, isPreviewable: n, onOpenInBrowser: r, isDownloadEnabled: a = !0, isPreviewOpen: o = !1, previewFilesOnMarkerClick: s = !1, icon: c, headerIcon: d, cardLabels: f, markerLabels: p, cardTypography: m, markerLabelClassName: h }) => {
213
- let g = K(), _ = te(), ee = g.isOpen(_), v = g.getActiveIndex(e.groupKey), y = e.annotations[v] ?? e.primaryAnnotation, x = n?.(y) ?? !0, S = b((e) => {
212
+ }, W = { trigger: "_trigger_119c8_7" }, G = ({ group: e, onPreview: t, isPreviewable: n, onOpenInBrowser: r, isDownloadEnabled: a = !0, isPreviewOpen: o = !1, previewFilesOnMarkerClick: s = !1, icon: c, headerIcon: d, cardLabels: f, markerLabels: p, cardTypography: m, markerLabelClassName: h }) => {
213
+ let g = U(), _ = ne(), ee = g.isOpen(_), v = g.getActiveIndex(e.groupKey), y = e.annotations[v] ?? e.primaryAnnotation, x = n?.(y) ?? !0, te = b((e) => {
214
214
  e || g.closePopup(_);
215
- }, [g, _]), C = w(() => t && x ? (e) => {
215
+ }, [g, _]), S = C(() => t && x ? (e) => {
216
216
  t(e), g.closePopup(_);
217
217
  } : void 0, [
218
218
  t,
219
219
  x,
220
220
  g,
221
221
  _
222
- ]), T = b(() => {
223
- let t = e.annotations.length === 1, n = t && !ne(y);
224
- (o && t || s && n) && C ? C(y) : g.openPopup(_);
222
+ ]), re = b(() => {
223
+ let t = e.annotations.length === 1, n = t && !ie(y);
224
+ (o && t || s && n) && S ? S(y) : g.openPopup(_);
225
225
  }, [
226
226
  o,
227
227
  s,
228
228
  e.annotations.length,
229
- C,
229
+ S,
230
230
  y,
231
231
  g,
232
232
  _
233
- ]), E = b(() => /* @__PURE__ */ O(H, {
233
+ ]), w = b(() => /* @__PURE__ */ E(z, {
234
234
  group: e,
235
235
  activeIndex: v,
236
236
  onIndexChange: (t) => g.setActiveIndex(e.groupKey, t),
237
- onPreview: C,
237
+ onPreview: S,
238
238
  onOpenInBrowser: r,
239
239
  isDownloadEnabled: a,
240
240
  headerIcon: d,
@@ -244,33 +244,33 @@ var A = {
244
244
  e,
245
245
  v,
246
246
  g,
247
- C,
247
+ S,
248
248
  r,
249
249
  a,
250
250
  d,
251
251
  f,
252
252
  m
253
253
  ]);
254
- return /* @__PURE__ */ O(l, {
254
+ return /* @__PURE__ */ E(l, {
255
255
  open: ee,
256
- onOpenChange: S,
256
+ onOpenChange: te,
257
257
  trigger: [],
258
258
  overlayRole: u.None,
259
259
  placement: "bottom-end",
260
260
  matchReferenceWidth: !1,
261
- className: i("ms-1 inline-flex align-middle", ae.trigger),
262
- listClassName: i("p-0! bg-transparent! shadow-none! rounded-none!", A.citationDropdown),
263
- renderOverlay: E,
264
- children: /* @__PURE__ */ O(U, {
261
+ className: i("ms-1 inline-flex align-middle", W.trigger),
262
+ listClassName: i("p-0! bg-transparent! shadow-none! rounded-none!", O.citationDropdown),
263
+ renderOverlay: w,
264
+ children: /* @__PURE__ */ E(B, {
265
265
  sourceName: e.sourceName,
266
266
  annotationCount: e.annotations.length,
267
- onOpen: T,
267
+ onOpen: re,
268
268
  icon: c,
269
269
  labels: p,
270
270
  labelClassName: h
271
271
  })
272
272
  });
273
- }, oe = (e) => {
273
+ }, ce = (e) => {
274
274
  let t = e.trim();
275
275
  if (!t.startsWith("|") || !t.endsWith("|") || /[\r\n]/.test(t)) return;
276
276
  let n = [], r = "";
@@ -279,11 +279,11 @@ var A = {
279
279
  i === "\\" && a != null && /[!-/:-@[-`{-~]/.test(a) ? (r += a, e += 1) : i === "|" ? (n.push(r.trim()), r = "") : r += i;
280
280
  }
281
281
  if (!(r !== "" || n.length < 2 || n.every((e) => e === "" || /^:?-{3,}:?$/.test(e)))) return n;
282
- }, se = (e) => {
282
+ }, le = (e) => {
283
283
  if (e.type !== "docx_text_anchor" && e.type !== "pptx_text_anchor") return;
284
284
  let { text: t, occurrence: n, slide: r } = e;
285
285
  if (typeof t != "string" || typeof n != "number" || !Number.isSafeInteger(n) || n < 1) return;
286
- let i = oe(t);
286
+ let i = ce(t);
287
287
  if (i != null) {
288
288
  if (e.type === "docx_text_anchor") return {
289
289
  type: "docx_text_anchor",
@@ -297,13 +297,32 @@ var A = {
297
297
  slide: r
298
298
  };
299
299
  }
300
- }, ce = {
300
+ }, K = (e) => e.url == null && e.reference_url != null, ue = /^(.*\.pdf)(?:#page=(\d+))?$/i, q = (e) => {
301
+ let t = ue.exec(e);
302
+ return t ? {
303
+ baseUrl: t[1],
304
+ page: t[2] == null ? null : Number(t[2])
305
+ } : null;
306
+ }, de = (t) => F((t ?? []).filter(K).map((t) => {
307
+ let n = t.reference_url, r = q(n) != null;
308
+ return { body: {
309
+ quote: t.data,
310
+ source: {
311
+ type: "attachment",
312
+ attachment: {
313
+ type: r ? e.PDF : t.reference_type ?? t.type ?? "",
314
+ url: n,
315
+ title: t.title
316
+ }
317
+ }
318
+ } };
319
+ })), fe = {
301
320
  backgroundColor: "transparent",
302
321
  borderColor: "var(--stroke-accent, #1D4ED8)",
303
322
  borderWidth: "2px",
304
323
  opacity: .5,
305
324
  hoverOpacity: .5
306
- }, le = (e) => {
325
+ }, pe = (e) => {
307
326
  if (typeof e != "object" || !e) return;
308
327
  let t = e, { lt: n, wh: r } = t;
309
328
  if (Array.isArray(n) && Array.isArray(r) && n.length >= 2 && r.length >= 2) {
@@ -333,7 +352,7 @@ var A = {
333
352
  x2: i,
334
353
  y2: a
335
354
  });
336
- } else t.type === "pdf_region" && (n = le(t.bbox));
355
+ } else t.type === "pdf_region" && (n = pe(t.bbox));
337
356
  if (n == null) return;
338
357
  let i = t.page;
339
358
  if (!(typeof i != "number" || !Number.isInteger(i) || i < 1) && [
@@ -348,29 +367,29 @@ var A = {
348
367
  x2: n.x2,
349
368
  y2: n.y2
350
369
  };
351
- }, ue = (e) => {
370
+ }, me = (e) => {
352
371
  if (!r(e)) return;
353
372
  let t = e;
354
373
  if (t.type !== "pdf_bbox" && t.type !== "pdf_region") return;
355
374
  let n = t.page;
356
375
  return typeof n == "number" && Number.isInteger(n) && n >= 1 ? n : void 0;
357
- }, Y = (e) => typeof e != "object" || !e ? String(e) : Array.isArray(e) ? `[${e.map(Y).join(",")}]` : `{${Object.entries(e).filter(([, e]) => e !== void 0).sort(([e], [t]) => e < t ? -1 : +(e > t)).map(([e, t]) => `${e}=${Y(t)}`).join(",")}}`, de = (e) => {
376
+ }, Y = (e) => typeof e != "object" || !e ? String(e) : Array.isArray(e) ? `[${e.map(Y).join(",")}]` : `{${Object.entries(e).filter(([, e]) => e !== void 0).sort(([e], [t]) => e < t ? -1 : +(e > t)).map(([e, t]) => `${e}=${Y(t)}`).join(",")}}`, he = (e) => {
358
377
  let t = 5381;
359
378
  for (let n = 0; n < e.length; n += 1) t = t * 33 + e.charCodeAt(n) | 0;
360
379
  return (t >>> 0).toString(36);
361
- }, fe = (e) => {
380
+ }, ge = (e) => {
362
381
  let t = e.body?.selector;
363
382
  if (t == null) return;
364
383
  let n = (Array.isArray(t) ? t : [t]).flatMap((e) => {
365
384
  let t = J(e);
366
385
  return t == null ? [] : [t];
367
- }), r = Ee(e);
386
+ }), r = Me(e);
368
387
  if (n.length !== 0 || r.length !== 0) return Y([n, r]);
369
- }, pe = (e) => {
370
- let t = e.target?.selector, n = t?.type === "html_tag" ? t.id : void 0, r = typeof n == "string" ? n : void 0, i = fe(e);
371
- if (r != null || i != null) return de(`${r ?? ""}|${i ?? ""}`);
372
- }, me = (e) => {
373
- let t = ge(e);
388
+ }, _e = (e) => {
389
+ let t = e.target?.selector, n = t?.type === "html_tag" ? t.id : void 0, r = typeof n == "string" ? n : void 0, i = ge(e);
390
+ if (r != null || i != null) return he(`${r ?? ""}|${i ?? ""}`);
391
+ }, ve = (e) => {
392
+ let t = be(e);
374
393
  return e.flatMap((e, n) => {
375
394
  let i = e.body?.selector;
376
395
  if (i == null) return [];
@@ -382,11 +401,11 @@ var A = {
382
401
  return a.length === 0 ? [] : [{
383
402
  id: t[n],
384
403
  bboxes: a,
385
- style: ce
404
+ style: fe
386
405
  }];
387
406
  });
388
- }, he = (e, t) => e.index == null ? pe(e) ?? String(t) : String(e.index), ge = (e) => {
389
- let t = e.map((e, t) => he(e, t)), n = new Set(t), r = /* @__PURE__ */ new Set();
407
+ }, ye = (e, t) => e.index == null ? _e(e) ?? String(t) : String(e.index), be = (e) => {
408
+ let t = e.map((e, t) => ye(e, t)), n = new Set(t), r = /* @__PURE__ */ new Set();
390
409
  return t.map((e) => {
391
410
  if (!r.has(e)) return r.add(e), e;
392
411
  let t = 1;
@@ -394,7 +413,7 @@ var A = {
394
413
  let i = `${e}-${t}`;
395
414
  return n.add(i), r.add(i), i;
396
415
  });
397
- }, _e = (e) => {
416
+ }, xe = (e) => {
398
417
  let t = e.body?.selector;
399
418
  if (t == null) return;
400
419
  let n = Array.isArray(t) ? t : [t];
@@ -404,29 +423,31 @@ var A = {
404
423
  if (t != null) return t.page;
405
424
  }
406
425
  for (let e of n) {
407
- let t = ue(e);
426
+ let t = me(e);
408
427
  if (t != null) return t;
409
428
  }
410
- }, ve = (e) => {
429
+ }, Se = /(?:^|[^\p{L}\p{N}])(?:pages?|pg|pp|p)\s*[.:]?\s*\d+(?![\p{L}\p{N}])|#page=\d/iu, Ce = (e) => {
430
+ if (!Se.test(e.sourceName)) return xe(e.primaryAnnotation) ?? q(e.sourceUrl)?.page ?? void 0;
431
+ }, we = (e) => {
411
432
  let t = e.custom_content?.annotations;
412
433
  if (t?.length) return t.filter((e) => e != null && e.body?.source?.attachment?.url != null).map(a);
413
434
  let n = e.custom_fields;
414
435
  if (typeof n != "object" || !n) return [];
415
436
  let r = n.annotations;
416
437
  return !Array.isArray(r) || r.length === 0 ? [] : o(r, e.custom_content?.attachments ?? []).map(a);
417
- }, ye = (e) => {
438
+ }, Te = (e) => {
418
439
  if (e.type !== "docx_text_range") return !1;
419
440
  let t = e;
420
441
  return typeof t.story == "string" && Array.isArray(t.path) && t.path.every((e) => typeof e == "number") && typeof t.start == "number" && typeof t.end == "number" && typeof t.text == "string";
421
- }, be = (e) => {
442
+ }, Ee = (e) => {
422
443
  if (e.type !== "pptx_text_range") return !1;
423
444
  let t = e;
424
445
  return typeof t.slide == "number" && typeof t.shape_id == "string" && typeof t.start == "number" && typeof t.end == "number" && typeof t.text == "string";
425
- }, xe = (e) => typeof e == "object" && !!e && typeof e.row == "number" && typeof e.col == "number", Se = (e) => {
446
+ }, De = (e) => typeof e == "object" && !!e && typeof e.row == "number" && typeof e.col == "number", Oe = (e) => {
426
447
  if (e.type !== "excel_rc_range") return !1;
427
448
  let t = e;
428
- return typeof t.sheet == "string" && xe(t.start) && (t.end === void 0 || t.end === null || xe(t.end));
429
- }, Ce = (e) => {
449
+ return typeof t.sheet == "string" && De(t.start) && (t.end === void 0 || t.end === null || De(t.end));
450
+ }, ke = (e) => {
430
451
  let { story: t, path: n, start: r, end: i, text: a } = e;
431
452
  if (!(!n.every((e) => Number.isInteger(e)) || !Number.isInteger(r) || !Number.isInteger(i) || r < 0 || i < r)) return {
432
453
  type: "docx_text_range",
@@ -436,7 +457,7 @@ var A = {
436
457
  endExclusive: i,
437
458
  text: a
438
459
  };
439
- }, we = (e) => {
460
+ }, Ae = (e) => {
440
461
  let { slide: t, shape_id: n, start: r, end: i, text: a } = e;
441
462
  if (!(!Number.isInteger(t) || t < 1 || !Number.isInteger(r) || !Number.isInteger(i) || r < 0 || i < r)) return {
442
463
  type: "pptx_text_range",
@@ -446,7 +467,7 @@ var A = {
446
467
  endExclusive: i,
447
468
  text: a
448
469
  };
449
- }, Te = (e) => {
470
+ }, je = (e) => {
450
471
  let { sheet: t, start: n, end: r } = e;
451
472
  if (!(t.length === 0 || !Number.isInteger(n.row) || !Number.isInteger(n.col) || n.row < 1 || n.col < 1)) {
452
473
  if (r == null) return {
@@ -461,30 +482,30 @@ var A = {
461
482
  end: r
462
483
  };
463
484
  }
464
- }, Ee = (e) => {
485
+ }, Me = (e) => {
465
486
  let t = e.body?.selector;
466
487
  return t == null ? [] : (Array.isArray(t) ? t : [t]).flatMap((e) => {
467
488
  if (!r(e)) return [];
468
- if (ye(e)) {
469
- let t = Ce(e);
489
+ if (Te(e)) {
490
+ let t = ke(e);
470
491
  return t ? [t] : [];
471
492
  }
472
- if (be(e)) {
473
- let t = we(e);
493
+ if (Ee(e)) {
494
+ let t = Ae(e);
474
495
  return t ? [t] : [];
475
496
  }
476
- if (Se(e)) {
477
- let t = Te(e);
497
+ if (Oe(e)) {
498
+ let t = je(e);
478
499
  return t ? [t] : [];
479
500
  }
480
- let t = se(e);
501
+ let t = le(e);
481
502
  return t ? [t] : [];
482
503
  });
483
- }, De = (e, t) => w(() => t ? [] : ve(e), [t, e]), Oe = {
504
+ }, Ne = (e, t) => C(() => t ? [] : we(e), [t, e]), Pe = {
484
505
  openOwnerKey: null,
485
506
  activeIndexByGroup: {}
486
- }, ke = () => {
487
- let [e, t] = E(Oe), n = b((e) => {
507
+ }, Fe = () => {
508
+ let [e, t] = w(Pe), n = b((e) => {
488
509
  t((t) => ({
489
510
  ...t,
490
511
  openOwnerKey: e
@@ -503,7 +524,7 @@ var A = {
503
524
  }
504
525
  }));
505
526
  }, []);
506
- return w(() => ({
527
+ return C(() => ({
507
528
  openPopup: n,
508
529
  closePopup: r,
509
530
  setActiveIndex: i,
@@ -515,7 +536,7 @@ var A = {
515
536
  i,
516
537
  e
517
538
  ]);
518
- }, Ae = /⟦C(\d+)⟧/g, je = (e, t) => {
539
+ }, Ie = /⟦C(\d+)⟧/g, Le = (e, t) => {
519
540
  let n = t.map((e, t) => ({
520
541
  g: e,
521
542
  idx: t
@@ -528,26 +549,26 @@ var A = {
528
549
  }).sort((e, t) => t.pos - e.pos), r = e;
529
550
  for (let { idx: e, pos: t } of n) r = `${r.slice(0, t)}⟦C${e}⟧${r.slice(t)}`;
530
551
  return r;
531
- }, Me = /<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>/g, Ne = /^<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>$/, Pe = /<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>|<\/?cit\b[^>]*>|<\/?cit\b[^>]*$/gi, Fe = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), X = (e) => e.replace(Pe, (e) => Ne.test(e) ? e : Fe(e)), Z = (e) => X(e).replace(Me, ""), Ie = (e, t) => e.includes("<cit") ? t ? Z(e) : X(e) : e, Le = (e) => {
552
+ }, Re = /<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>/g, ze = /^<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>$/, Be = /<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>|<\/?cit\b[^>]*>|<\/?cit\b[^>]*$/gi, Ve = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), X = (e) => e.replace(Be, (e) => ze.test(e) ? e : Ve(e)), Z = (e) => X(e).replace(Re, ""), He = (e, t) => e.includes("<cit") ? t ? Z(e) : X(e) : e, Ue = (e) => {
532
553
  let t = e.primaryAnnotation.target?.selector;
533
554
  return t?.type === "html_tag" ? t.id : void 0;
534
555
  }, Q = (e, t = []) => {
535
556
  let n = /* @__PURE__ */ new Map();
536
557
  for (let r of [...t, ...e]) {
537
- let e = Le(r);
558
+ let e = Ue(r);
538
559
  e != null && n.set(e, r);
539
560
  }
540
561
  return n;
541
- }, Re = /<cit\s+data-id=(?:"([^"]+)"|'([^']+)')\s*>\s*<\/cit>/g, ze = (e) => e.replace(/[\\`*_[\]<>|]/g, "\\$&"), Be = (e, t, n = []) => {
562
+ }, We = /<cit\s+data-id=(?:"([^"]+)"|'([^']+)')\s*>\s*<\/cit>/g, Ge = (e) => e.replace(/[\\`*_[\]<>|]/g, "\\$&"), Ke = (e, t, n = [], r = (e) => e.sourceName) => {
542
563
  if (!e.includes("<cit")) return e;
543
- let r = Q(t, n);
544
- return r.size === 0 ? e : e.replace(Re, (e, t, n) => {
545
- let i = r.get(t ?? n ?? "");
546
- return i ? ze(i.sourceName) : e;
564
+ let i = Q(t, n);
565
+ return i.size === 0 ? e : e.replace(We, (e, t, n) => {
566
+ let a = i.get(t ?? n ?? "");
567
+ return a ? Ge(r(a)) : e;
547
568
  });
548
569
  }, $ = (e, t) => {
549
570
  if (typeof e == "string") {
550
- let n = e.split(Ae);
571
+ let n = e.split(Ie);
551
572
  if (n.length === 1) return e;
552
573
  let r = [];
553
574
  return n.forEach((e, n) => {
@@ -558,13 +579,13 @@ var A = {
558
579
  let n = $(e, t);
559
580
  return Array.isArray(n) ? n : [n];
560
581
  }) : e;
561
- }, Ve = (e, t) => /* @__PURE__ */ k(D, { children: [
582
+ }, qe = (e, t) => /* @__PURE__ */ D(T, { children: [
562
583
  e == null ? "<cit>" : `<cit data-id="${e}">`,
563
584
  t,
564
585
  "</cit>"
565
- ] }), He = ({ onPreview: e, isPreviewable: t, onOpenInBrowser: n, isDownloadEnabled: r = !0, isPreviewOpen: i = !1, previewFilesOnMarkerClick: a = !1, buildLabels: o }) => (s) => {
586
+ ] }), Je = ({ onPreview: e, isPreviewable: t, onOpenInBrowser: n, isDownloadEnabled: r = !0, isPreviewOpen: i = !1, previewFilesOnMarkerClick: a = !1, buildLabels: o }) => (s) => {
566
587
  let { cardLabels: c, markerLabels: l } = o(s);
567
- return /* @__PURE__ */ O(q, {
588
+ return /* @__PURE__ */ E(G, {
568
589
  group: s,
569
590
  onPreview: (t) => e(t, s),
570
591
  isPreviewable: t,
@@ -575,16 +596,16 @@ var A = {
575
596
  cardLabels: c,
576
597
  markerLabels: l
577
598
  }, `citation-${s.groupKey}`);
578
- }, Ue = {}, We = [], Ge = (e, t, n, r = !1, a = !1, o = We) => {
579
- let { onPreview: s, isPreviewable: c, onOpenInBrowser: l, isDownloadEnabled: u = !0, isPreviewOpen: d = !1, previewFilesOnMarkerClick: f = !1, paragraphClassName: p = "dial-body-paragraph-text", compactParagraphClassName: m = "dial-small-paragraph-text", buildLabels: h } = n, g = w(() => r ? Z(e) : X(t.length > 0 ? je(e, t) : e), [
599
+ }, Ye = {}, Xe = [], Ze = (e, t, n, r = !1, a = !1, o = Xe) => {
600
+ let { onPreview: s, isPreviewable: c, onOpenInBrowser: l, isDownloadEnabled: u = !0, isPreviewOpen: d = !1, previewFilesOnMarkerClick: f = !1, paragraphClassName: p = "dial-body-paragraph-text", compactParagraphClassName: m = "dial-small-paragraph-text", buildLabels: h } = n, g = C(() => r ? Z(e) : X(t.length > 0 ? Le(e, t) : e), [
580
601
  e,
581
602
  t,
582
603
  r
583
604
  ]), _ = g.includes("<cit");
584
605
  return {
585
606
  processedContent: g,
586
- markdownComponents: w(() => {
587
- let e = Q(t, o), n = He({
607
+ markdownComponents: C(() => {
608
+ let e = Q(t, o), n = Je({
588
609
  onPreview: s,
589
610
  isPreviewable: c,
590
611
  onOpenInBrowser: l,
@@ -597,16 +618,16 @@ var A = {
597
618
  return r ? n(r) : null;
598
619
  }, g = { cit: (t) => {
599
620
  let r = t["data-id"] == null ? void 0 : e.get(t["data-id"]);
600
- return r ? n(r) : Ve(t["data-id"], t.children);
621
+ return r ? n(r) : qe(t["data-id"], t.children);
601
622
  } };
602
- return t.length === 0 && o.length === 0 ? _ ? g : Ue : {
623
+ return t.length === 0 && o.length === 0 ? _ ? g : Ye : {
603
624
  ...g,
604
- p: ({ children: e, ...t }) => /* @__PURE__ */ O("p", {
625
+ p: ({ children: e, ...t }) => /* @__PURE__ */ E("p", {
605
626
  ...t,
606
627
  className: i(a ? m : p, "mb-3 text-pretty wrap-anywhere last:mb-0"),
607
628
  children: $(e, r)
608
629
  }),
609
- li: ({ children: e, ...t }) => /* @__PURE__ */ O("li", {
630
+ li: ({ children: e, ...t }) => /* @__PURE__ */ E("li", {
610
631
  ...t,
611
632
  className: "mb-1.5 last:mb-0",
612
633
  children: $(e, r)
@@ -628,10 +649,10 @@ var A = {
628
649
  _
629
650
  ])
630
651
  };
631
- }, Ke = [], qe = (e, t, n = Ke) => {
652
+ }, Qe = [], $e = (e, t, n = Qe) => {
632
653
  let { onPreview: r, isPreviewable: i, onOpenInBrowser: a, isDownloadEnabled: o, isPreviewOpen: s, previewFilesOnMarkerClick: c, buildLabels: l } = t;
633
- return w(() => {
634
- let t = Q(e, n), u = He({
654
+ return C(() => {
655
+ let t = Q(e, n), u = Je({
635
656
  onPreview: r,
636
657
  isPreviewable: i,
637
658
  onOpenInBrowser: a,
@@ -642,7 +663,7 @@ var A = {
642
663
  });
643
664
  return (e, n) => {
644
665
  let r = e == null ? void 0 : t.get(e);
645
- return r ? u(r) : Ve(e, n);
666
+ return r ? u(r) : qe(e, n);
646
667
  };
647
668
  }, [
648
669
  e,
@@ -655,33 +676,14 @@ var A = {
655
676
  c,
656
677
  l
657
678
  ]);
658
- }, Je = (e) => e.url == null && e.reference_url != null, Ye = /^(.*\.pdf)(?:#page=(\d+))?$/i, Xe = (e) => {
659
- let t = Ye.exec(e);
660
- return t ? {
661
- baseUrl: t[1],
662
- page: t[2] == null ? null : Number(t[2])
663
- } : null;
664
- }, Ze = (t) => L((t ?? []).filter(Je).map((t) => {
665
- let n = t.reference_url, r = Xe(n) != null;
666
- return { body: {
667
- quote: t.data,
668
- source: {
669
- type: "attachment",
670
- attachment: {
671
- type: r ? e.PDF : t.reference_type ?? t.type ?? "",
672
- url: n,
673
- title: t.title
674
- }
675
- }
676
- } };
677
- })), Qe = [], $e = (e) => {
679
+ }, et = [], tt = (e) => {
678
680
  if (typeof e != "object" || !e) return !1;
679
681
  let t = e.target?.selector, n = e.body?.source?.attachment;
680
682
  return t?.type === "html_tag" && typeof t.id == "string" && typeof n?.url == "string" && (n.title == null || typeof n.title == "string");
681
- }, et = (e) => w(() => {
682
- if (!Array.isArray(e)) return Qe;
683
- let t = R(e.filter($e));
684
- return t.length ? t : Qe;
683
+ }, nt = (e) => C(() => {
684
+ if (!Array.isArray(e)) return et;
685
+ let t = I(e.filter(tt));
686
+ return t.length ? t : et;
685
687
  }, [e]);
686
688
  //#endregion
687
- export { H as CitationCard, G as CitationCardProvider, q as CitationDropdown, U as CitationMarker, A as QUOTATIONS_CLASS, he as annotationHighlightId, ge as annotationHighlightIds, Ee as annotationToOfficeHighlightLocations, me as annotationsToPdfHighlights, B as gatherSameSourceAnnotations, _e as getAnnotationPdfPage, Ze as getReferenceAttachmentGroups, z as groupAnnotations, R as groupAnnotationsByCitId, L as groupAnnotationsBySource, je as injectCitationSentinels, ye as isDocxRangeSelector, Se as isExcelRcRangeSelector, be as isPptxRangeSelector, Je as isReferenceOnlyAttachment, Xe as parsePdfPageReference, Ie as prepareCitationContent, Be as replaceCitTagsWithSourceNames, $ as replaceSentinelsInChildren, ve as resolveMessageAnnotations, Z as stripCitTagsWhileStreaming, De as useAnnotations, ke as useCitationCard, K as useCitationCardContext, Ge as useCitationMarkdownComponents, qe as useCitationTagRenderer, et as useHtmlTagAnnotationGroups };
689
+ export { z as CitationCard, H as CitationCardProvider, G as CitationDropdown, B as CitationMarker, O as QUOTATIONS_CLASS, ye as annotationHighlightId, be as annotationHighlightIds, Me as annotationToOfficeHighlightLocations, ve as annotationsToPdfHighlights, se as gatherSameSourceAnnotations, xe as getAnnotationPdfPage, Ce as getCitationGroupPage, de as getReferenceAttachmentGroups, L as groupAnnotations, I as groupAnnotationsByCitId, F as groupAnnotationsBySource, Le as injectCitationSentinels, Te as isDocxRangeSelector, Oe as isExcelRcRangeSelector, Ee as isPptxRangeSelector, K as isReferenceOnlyAttachment, q as parsePdfPageReference, He as prepareCitationContent, Ke as replaceCitTagsWithSourceNames, $ as replaceSentinelsInChildren, we as resolveMessageAnnotations, Z as stripCitTagsWhileStreaming, Ne as useAnnotations, Fe as useCitationCard, U as useCitationCardContext, Ze as useCitationMarkdownComponents, $e as useCitationTagRenderer, nt as useHtmlTagAnnotationGroups };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@epam/ai-dial-quotations",
3
3
  "description": "Citation and annotation components, hooks, and utilities for AI DIAL conversations",
4
- "version": "1.3.0-dev.317",
4
+ "version": "1.3.0-dev.321",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "peerDependencies": {
25
25
  "react": "^19.2.8",
26
- "@epam/ai-dial-chat-shared": "1.3.0-dev.317",
26
+ "@epam/ai-dial-chat-shared": "1.3.0-dev.321",
27
27
  "@epam/ai-dial-ui-kit": "^0.16.0-dev.72"
28
28
  },
29
29
  "repository": {
@@ -1,6 +1,7 @@
1
1
  import { Annotation, AnnotationSelector, DocxRangeSelector, ExcelRcRangeSelector, Message, PptxRangeSelector } from '@epam/ai-dial-chat-shared';
2
2
  import { InputHighlightData } from '@epam/pdf-highlighter-kit';
3
3
  import { OfficeHighlightLocation } from '../models/office-highlight';
4
+ import { AnnotationGroup } from './group-annotations-by-source';
4
5
  /**
5
6
  * Maps a list of annotations to `InputHighlightData` entries for the PDF viewer.
6
7
  * Recognizes `pdf_bbox` selectors and both `pdf_region` coordinate forms
@@ -52,6 +53,8 @@ export declare const annotationHighlightIds: (annotations: Annotation[]) => stri
52
53
  * navigates without a highlight.
53
54
  */
54
55
  export declare const getAnnotationPdfPage: (annotation: Annotation) => number | undefined;
56
+ /** Returns the 1-based PDF page a citation group's marker refers to, or `undefined` when none is known or `sourceName` already mentions a page. */
57
+ export declare const getCitationGroupPage: (group: AnnotationGroup) => number | undefined;
55
58
  /**
56
59
  * Resolves the annotation list for a message regardless of how it was loaded.
57
60
  *
@@ -1 +1 @@
1
- {"version":3,"file":"annotation.d.ts","sourceRoot":"","sources":["../../src/utils/annotation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,kBA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reaming: bool
33
33
  export declare const buildCitGroupsByTagId: (groups: AnnotationGroup[], fallbackGroups?: AnnotationGroup[]) => Map<string, AnnotationGroup>;
34
34
  /**
35
35
  * Returns `content` with every supported `<cit data-id="…"></cit>` element
36
- * that resolves to a group replaced by that group's `sourceName` as plain
37
- * Markdown text — the label its citation marker shows on screen. Unresolved
38
- * tags are left untouched.
36
+ * that resolves to a group replaced by `formatLabel(group)` — by default the
37
+ * group's `sourceName` — as plain Markdown text. Unresolved tags are left
38
+ * untouched.
39
39
  */
40
- export declare const replaceCitTagsWithSourceNames: (content: string, groups: AnnotationGroup[], fallbackGroups?: AnnotationGroup[]) => string;
40
+ export declare const replaceCitTagsWithSourceNames: (content: string, groups: AnnotationGroup[], fallbackGroups?: AnnotationGroup[], formatLabel?: (group: AnnotationGroup) => string) => string;
41
41
  /**
42
42
  * Recursively walks a React child tree and replaces sentinel strings with
43
43
  * the result of `renderMarker(idx)`. Handles string children, arrays, and
@@ -1 +1 @@
1
- {"version":3,"file":"citation-injection.d.ts","sourceRoot":"","sources":["../../src/utils/citation-injection.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAUrE;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,GAClC,SAAS,MAAM,EACf,QAAQ,eAAe,EAAE,KACxB,MAwBF,CAAC;AAmBF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GAAI,SAAS,MAAM,KAAG,MAGxD,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAI,SAAS,MAAM,KAAG,MAE5D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,MAAM,EACf,aAAa,OAAO,KACnB,MAKF,CAAC;AAeF,kKAAkK;AAClK,eAAO,MAAM,qBAAqB,GAChC,QAAQ,eAAe,EAAE,EACzB,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