@epam/ai-dial-quotations 1.2.0-dev.201 → 1.2.0-dev.208

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.
@@ -62,7 +62,11 @@ export interface CitationCardProps {
62
62
  onPreview?: (annotation: Annotation) => void;
63
63
  /** Called when the user clicks the "Open in browser" button, shown for web links and non-previewable sources. */
64
64
  onOpenInBrowser: (annotation: Annotation) => void;
65
- /** Optional icon rendered before the header text (the file extension for a previewable file, otherwise the source name). */
65
+ /**
66
+ * Optional icon rendered before the header text (the file extension for a
67
+ * previewable file, otherwise the source name). When omitted, a previewable
68
+ * file gets the UI kit's `FileIcon` glyph for its extension.
69
+ */
66
70
  headerIcon?: ReactNode;
67
71
  /** User-visible strings. */
68
72
  labels: CitationCardLabels;
@@ -1 +1 @@
1
- {"version":3,"file":"CitationCard.d.ts","sourceRoot":"","sources":["../../../src/components/CitationCard/CitationCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAgB5D,OAAO,EACL,EAAE,EACF,SAAS,EAMV,MAAM,OAAO,CAAC;AAEf,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,yCAAyC,CAAC;AAGjD,+CAA+C;AAC/C,MAAM,WAAW,kBAAkB;IACjC,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,gBAAgB,EAAE,MAAM,CAAC;IACzB,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;IACrB,2GAA2G;IAC3G,kBAAkB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC/D,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,aAAa,EAAE,MAAM,CAAC;IACtB,iFAAiF;IACjF,QAAQ,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,qGAAqG;AACrG,MAAM,WAAW,kBAAkB;IACjC,4DAA4D;IAC5D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,oEAAoE;AACpE,MAAM,WAAW,sBAAsB;IACrC,qFAAqF;IACrF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,sFAAsF;IACtF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gFAAgF;IAChF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iKAAiK;IACjK,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,yFAAyF;IACzF,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,8CAA8C;AAC9C,MAAM,WAAW,iBAAiB;IAChC,wEAAwE;IACxE,KAAK,EAAE,eAAe,CAAC;IACvB,kFAAkF;IAClF,WAAW,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAC7C,iHAAiH;IACjH,eAAe,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAClD,4HAA4H;IAC5H,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,4BAA4B;IAC5B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,2CAA2C;IAC3C,UAAU,CAAC,EAAE,sBAAsB,CAAC;IACpC,gCAAgC;IAChC,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B;AAED,yFAAyF;AACzF,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAwM9C,CAAC"}
1
+ {"version":3,"file":"CitationCard.d.ts","sourceRoot":"","sources":["../../../src/components/CitationCard/CitationCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAkB5D,OAAO,EACL,EAAE,EACF,SAAS,EAMV,MAAM,OAAO,CAAC;AAEf,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,yCAAyC,CAAC;AAGjD,+CAA+C;AAC/C,MAAM,WAAW,kBAAkB;IACjC,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,gBAAgB,EAAE,MAAM,CAAC;IACzB,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;IACrB,2GAA2G;IAC3G,kBAAkB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC/D,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,aAAa,EAAE,MAAM,CAAC;IACtB,iFAAiF;IACjF,QAAQ,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,qGAAqG;AACrG,MAAM,WAAW,kBAAkB;IACjC,4DAA4D;IAC5D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,oEAAoE;AACpE,MAAM,WAAW,sBAAsB;IACrC,qFAAqF;IACrF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,sFAAsF;IACtF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gFAAgF;IAChF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iKAAiK;IACjK,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,yFAAyF;IACzF,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,8CAA8C;AAC9C,MAAM,WAAW,iBAAiB;IAChC,wEAAwE;IACxE,KAAK,EAAE,eAAe,CAAC;IACvB,kFAAkF;IAClF,WAAW,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAC7C,iHAAiH;IACjH,eAAe,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAClD;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,4BAA4B;IAC5B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,2CAA2C;IAC3C,UAAU,CAAC,EAAE,sBAAsB,CAAC;IACpC,gCAAgC;IAChC,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B;AAED,yFAAyF;AACzF,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAqN9C,CAAC"}
package/index.js CHANGED
@@ -1,7 +1,7 @@
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
- import { DIAL_KIT_ICON_STROKE as s, ElementSize as c, EllipsisTooltip as l, GhostIconButton as u, LinkButton as d, NeutralButton as f, PrimaryButton as p, Tooltip as m } from "@epam/ai-dial-ui-kit";
3
- import { IconChevronLeft as ee, IconChevronRight as h } from "@tabler/icons-react";
4
- import { createContext as g, useCallback as _, useContext as v, useEffect as y, useId as b, useLayoutEffect as x, useMemo as S, useRef as C, useState as w } from "react";
2
+ import { DIAL_KIT_ICON_STROKE as s, DialItemType as c, ElementSize as l, EllipsisTooltip as u, FileIcon as d, GhostIconButton as f, LinkButton as p, NeutralButton as m, PrimaryButton as h, Tooltip as g } from "@epam/ai-dial-ui-kit";
3
+ import { IconChevronLeft as _, IconChevronRight as v } from "@tabler/icons-react";
4
+ import { createContext as y, useCallback as b, useContext as x, useEffect as S, useId as ee, useLayoutEffect as te, useMemo as C, useRef as ne, useState as w } from "react";
5
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
7
  var O = {
@@ -24,16 +24,16 @@ var O = {
24
24
  }, j = /\.([a-z0-9]{1,10})$/i, M = (e) => {
25
25
  let t = e == null ? null : j.exec(e.trim());
26
26
  return t == null ? void 0 : `.${t[1].toLowerCase()}`;
27
- }, te = (e) => {
27
+ }, re = (e) => {
28
28
  let t = e.body?.source?.attachment, n = t?.url;
29
29
  return (n == null ? void 0 : M(A(n))) ?? M(t?.title);
30
30
  }, N = (e, t) => e.body?.source?.attachment?.title ?? A(t), P = (e) => {
31
31
  let t = e.target?.selector;
32
32
  return t?.type === "html_tag" ? t : void 0;
33
- }, F = (e) => P(e) != null, I = (e) => {
33
+ }, ie = (e) => P(e) != null, F = (e) => {
34
34
  let t = /* @__PURE__ */ new Map();
35
35
  for (let n of e) {
36
- if (F(n)) continue;
36
+ if (ie(n)) continue;
37
37
  let e = n.body?.source?.attachment?.url;
38
38
  if (e == null) continue;
39
39
  let r = t.get(e);
@@ -46,7 +46,7 @@ var O = {
46
46
  });
47
47
  }
48
48
  return Array.from(t.values());
49
- }, L = (e) => {
49
+ }, I = (e) => {
50
50
  let t = /* @__PURE__ */ new Map();
51
51
  for (let n of e) {
52
52
  let e = P(n)?.id;
@@ -63,72 +63,79 @@ var O = {
63
63
  });
64
64
  }
65
65
  return Array.from(t.values());
66
- }, R = (e) => [...L(e), ...I(e)], z = (e, t) => {
66
+ }, L = (e) => [...I(e), ...F(e)], R = (e, t) => {
67
67
  let n = e.body?.source?.attachment?.url;
68
68
  return n == null || !t.includes(e) ? [e] : t.filter((e) => e.body?.source?.attachment?.url === n);
69
- }, B = {
69
+ }, z = {
70
70
  card: "_card_1kph1_1",
71
71
  quote: "_quote_1kph1_5",
72
72
  title: "_title_1kph1_9",
73
73
  switcher: "_switcher_1kph1_13",
74
74
  sourceName: "_sourceName_1kph1_17"
75
- }, V = ({ group: r, activeIndex: a, onIndexChange: o, onPreview: f, onOpenInBrowser: m, headerIcon: g, labels: _, typography: v, colors: S }) => {
76
- let T = r.annotations.length, k = r.annotations[a] ?? r.primaryAnnotation, A = T > 1, j = k.body?.source?.attachment?.type, M = f == null || j === e.HTML || j === e.XHTML, N = (M ? void 0 : te(k)) ?? r.sourceName, P = v?.sourceNameClassName ?? "dial-tiny-text", F = v?.titleClassName ?? "dial-body-semi-text", I = v?.quoteClassName ?? "dial-small-text", L = v?.quoteStrongClassName ?? "dial-small-semi-text", R = v?.switcherClassName ?? "dial-tiny-text", z = n({
77
- "--cc-card-bg": S?.cardBackground,
78
- "--cc-quote-text": S?.quoteText,
79
- "--cc-title-text": S?.titleText,
80
- "--cc-switcher-text": S?.switcherText,
81
- "--cc-source-name-text": S?.sourceNameText
82
- }), V = k.body?.quote, H = b(), U = C(null), [W, G] = w(!1), [K, q] = w(!1);
83
- return y(() => {
84
- G(!1);
85
- }, [a, V]), x(() => {
86
- let e = U.current;
87
- if (!e || W) return;
88
- let t = () => q(e.scrollHeight > e.clientHeight + 1);
75
+ }, B = ({ group: r, activeIndex: a, onIndexChange: o, onPreview: m, onOpenInBrowser: g, headerIcon: y, labels: b, typography: x, colors: C }) => {
76
+ let T = r.annotations.length, k = r.annotations[a] ?? r.primaryAnnotation, A = T > 1, j = k.body?.source?.attachment?.type, M = m == null || j === e.HTML || j === e.XHTML, N = M ? void 0 : re(k), P = N ?? r.sourceName, ie = y ?? (N == null ? void 0 : /* @__PURE__ */ E(d, {
77
+ type: c.File,
78
+ name: N,
79
+ fileExtension: N,
80
+ size: 16,
81
+ decorative: !0,
82
+ className: "shrink-0"
83
+ })), F = x?.sourceNameClassName ?? "dial-tiny-text", I = x?.titleClassName ?? "dial-body-semi-text", L = x?.quoteClassName ?? "dial-small-text", R = x?.quoteStrongClassName ?? "dial-small-semi-text", B = x?.switcherClassName ?? "dial-tiny-text", V = n({
84
+ "--cc-card-bg": C?.cardBackground,
85
+ "--cc-quote-text": C?.quoteText,
86
+ "--cc-title-text": C?.titleText,
87
+ "--cc-switcher-text": C?.switcherText,
88
+ "--cc-source-name-text": C?.sourceNameText
89
+ }), H = k.body?.quote, U = ee(), W = ne(null), [G, K] = w(!1), [q, J] = w(!1);
90
+ return S(() => {
91
+ K(!1);
92
+ }, [a, H]), te(() => {
93
+ let e = W.current;
94
+ if (!e || G) return;
95
+ let t = () => J(e.scrollHeight > e.clientHeight + 1);
89
96
  t();
90
97
  let n = new ResizeObserver(t);
91
98
  return n.observe(e), () => n.disconnect();
92
- }, [V, W]), /* @__PURE__ */ D("div", {
99
+ }, [H, G]), /* @__PURE__ */ D("div", {
93
100
  role: "dialog",
94
101
  "aria-modal": "true",
95
- "aria-label": _.ariaLabel,
96
- style: z,
97
- className: i("flex w-[400px] flex-col gap-3 rounded-lg p-4 shadow-lg", B.card, O.citationCard),
102
+ "aria-label": b.ariaLabel,
103
+ style: V,
104
+ className: i("flex w-[400px] flex-col gap-3 rounded-lg p-4 shadow-lg", z.card, O.citationCard),
98
105
  children: [
99
106
  /* @__PURE__ */ D("div", {
100
107
  className: "flex items-center justify-between gap-2",
101
108
  children: [/* @__PURE__ */ D("div", {
102
109
  className: "flex min-w-0 items-center gap-1",
103
- children: [g, /* @__PURE__ */ E(l, {
104
- text: N,
105
- className: i(P, "min-w-0", B.sourceName)
110
+ children: [ie, /* @__PURE__ */ E(u, {
111
+ text: P,
112
+ className: i(F, "min-w-0", z.sourceName)
106
113
  })]
107
114
  }), A && /* @__PURE__ */ D("div", {
108
115
  className: "flex shrink-0 items-center gap-1",
109
116
  children: [
110
- /* @__PURE__ */ E(u, {
111
- icon: /* @__PURE__ */ E(ee, {
117
+ /* @__PURE__ */ E(f, {
118
+ icon: /* @__PURE__ */ E(_, {
112
119
  size: 14,
113
120
  className: "rtl:scale-x-[-1]",
114
121
  stroke: s
115
122
  }),
116
- size: c.Small,
117
- "aria-label": _.previousCitation,
123
+ size: l.Small,
124
+ "aria-label": b.previousCitation,
118
125
  onClick: () => o((a - 1 + T) % T)
119
126
  }),
120
127
  /* @__PURE__ */ E("span", {
121
- className: i(R, B.switcher),
122
- children: _.formatSwitcherText(a + 1, T)
128
+ className: i(B, z.switcher),
129
+ children: b.formatSwitcherText(a + 1, T)
123
130
  }),
124
- /* @__PURE__ */ E(u, {
125
- icon: /* @__PURE__ */ E(h, {
131
+ /* @__PURE__ */ E(f, {
132
+ icon: /* @__PURE__ */ E(v, {
126
133
  size: 14,
127
134
  className: "rtl:scale-x-[-1]",
128
135
  stroke: s
129
136
  }),
130
- size: c.Small,
131
- "aria-label": _.nextCitation,
137
+ size: l.Small,
138
+ "aria-label": b.nextCitation,
132
139
  onClick: () => o((a + 1) % T)
133
140
  })
134
141
  ]
@@ -137,49 +144,49 @@ var O = {
137
144
  (k.body?.title || k.body?.quote || A) && /* @__PURE__ */ D("div", {
138
145
  className: "flex flex-col gap-3",
139
146
  children: [k.body?.title && /* @__PURE__ */ E("p", {
140
- className: i(F, B.title, "break-words"),
147
+ className: i(I, z.title, "break-words"),
141
148
  children: k.body.title
142
- }), (V || A) && /* @__PURE__ */ D("div", {
149
+ }), (H || A) && /* @__PURE__ */ D("div", {
143
150
  className: "flex flex-col items-start gap-1",
144
151
  children: [/* @__PURE__ */ E("div", {
145
- ref: U,
146
- id: H,
147
- tabIndex: W ? 0 : void 0,
148
- className: i(I, B.quote, "w-full break-words", W ? "max-h-[min(20rem,50vh)] overflow-y-auto" : "line-clamp-6", A && "min-h-[3lh]"),
149
- children: V && /* @__PURE__ */ E(t, {
150
- content: V,
152
+ ref: W,
153
+ id: U,
154
+ tabIndex: G ? 0 : void 0,
155
+ className: i(L, z.quote, "w-full break-words", G ? "max-h-[min(20rem,50vh)] overflow-y-auto" : "line-clamp-6", A && "min-h-[3lh]"),
156
+ children: H && /* @__PURE__ */ E(t, {
157
+ content: H,
151
158
  classNames: {
152
- p: i(I, B.quote),
153
- ul: i(I, "ps-3"),
154
- ol: i(I, "ps-3"),
155
- strong: L
159
+ p: i(L, z.quote),
160
+ ul: i(L, "ps-3"),
161
+ ol: i(L, "ps-3"),
162
+ strong: R
156
163
  }
157
164
  })
158
- }), K && /* @__PURE__ */ E(d, {
159
- label: W ? _.showLess : _.showMore,
160
- size: c.Small,
161
- "aria-expanded": W,
162
- "aria-controls": H,
163
- onClick: () => G((e) => !e)
165
+ }), q && /* @__PURE__ */ E(p, {
166
+ label: G ? b.showLess : b.showMore,
167
+ size: l.Small,
168
+ "aria-expanded": G,
169
+ "aria-controls": U,
170
+ onClick: () => K((e) => !e)
164
171
  })]
165
172
  })]
166
173
  }),
167
174
  /* @__PURE__ */ D("div", {
168
175
  className: "flex justify-start gap-2",
169
- children: [f && /* @__PURE__ */ E(p, {
170
- label: _.preview,
171
- size: c.Small,
172
- onClick: () => f(k)
173
- }), M && /* @__PURE__ */ E(p, {
174
- label: _.openInBrowser,
175
- size: c.Small,
176
+ children: [m && /* @__PURE__ */ E(h, {
177
+ label: b.preview,
178
+ size: l.Small,
176
179
  onClick: () => m(k)
180
+ }), M && /* @__PURE__ */ E(h, {
181
+ label: b.openInBrowser,
182
+ size: l.Small,
183
+ onClick: () => g(k)
177
184
  })]
178
185
  })
179
186
  ]
180
187
  });
181
- }, H = ({ annotationCount: e, onOpen: t, icon: n, labels: r, labelClassName: a = "dial-caption-text" }) => /* @__PURE__ */ E(f, {
182
- size: c.Small,
188
+ }, V = ({ annotationCount: e, onOpen: t, icon: n, labels: r, labelClassName: a = "dial-caption-text" }) => /* @__PURE__ */ E(m, {
189
+ size: l.Small,
183
190
  className: i("max-w-[240px]", O.citationMarker),
184
191
  textClassName: "min-w-0 truncate",
185
192
  iconBefore: n,
@@ -189,42 +196,42 @@ var O = {
189
196
  }),
190
197
  "aria-label": r.ariaLabel,
191
198
  onClick: t
192
- }), U = g(null), W = U.Provider, G = () => {
193
- let e = v(U);
199
+ }), H = y(null), U = H.Provider, W = () => {
200
+ let e = x(H);
194
201
  if (e == null) throw Error("useCitationCardContext must be used within a CitationCardProvider");
195
202
  return e;
196
- }, K = {
203
+ }, G = {
197
204
  trigger: "_trigger_3ev9j_1",
198
205
  content: "_content_3ev9j_10"
199
- }, q = ({ group: e, onPreview: t, isPreviewable: n, onOpenInBrowser: r, isPreviewOpen: a = !1, icon: o, headerIcon: s, cardLabels: c, markerLabels: l, cardTypography: u, markerLabelClassName: d }) => {
200
- let f = G(), p = b(), ee = f.isOpen(p), h = f.getActiveIndex(e.groupKey), g = e.annotations[h] ?? e.primaryAnnotation, v = n?.(g) ?? !0, y = _((e) => {
206
+ }, K = ({ group: e, onPreview: t, isPreviewable: n, onOpenInBrowser: r, isPreviewOpen: a = !1, icon: o, headerIcon: s, cardLabels: c, markerLabels: l, cardTypography: u, markerLabelClassName: d }) => {
207
+ let f = W(), p = ee(), m = f.isOpen(p), h = f.getActiveIndex(e.groupKey), _ = e.annotations[h] ?? e.primaryAnnotation, v = n?.(_) ?? !0, y = b((e) => {
201
208
  e || f.closePopup(p);
202
- }, [f, p]), x = S(() => t && v ? (e) => {
209
+ }, [f, p]), x = C(() => t && v ? (e) => {
203
210
  t(e), f.closePopup(p);
204
211
  } : void 0, [
205
212
  t,
206
213
  v,
207
214
  f,
208
215
  p
209
- ]), C = _(() => {
216
+ ]), S = b(() => {
210
217
  if (a && x) {
211
- x(g);
218
+ x(_);
212
219
  return;
213
220
  }
214
221
  f.openPopup(p);
215
222
  }, [
216
223
  a,
217
224
  x,
218
- g,
225
+ _,
219
226
  f,
220
227
  p
221
228
  ]);
222
- return /* @__PURE__ */ E(m, {
223
- open: ee,
229
+ return /* @__PURE__ */ E(g, {
230
+ open: m,
224
231
  onOpenChange: y,
225
- triggerClassName: i("ms-1 inline-flex align-middle", K.trigger),
226
- contentClassName: i("!p-0 !bg-transparent !border-0 !shadow-none !max-w-none !rounded-none", K.content, O.citationDropdown),
227
- tooltip: /* @__PURE__ */ E(V, {
232
+ triggerClassName: i("ms-1 inline-flex align-middle", G.trigger),
233
+ contentClassName: i("!p-0 !bg-transparent !border-0 !shadow-none !max-w-none !rounded-none", G.content, O.citationDropdown),
234
+ tooltip: /* @__PURE__ */ E(B, {
228
235
  group: e,
229
236
  activeIndex: h,
230
237
  onIndexChange: (t) => f.setActiveIndex(e.groupKey, t),
@@ -234,16 +241,16 @@ var O = {
234
241
  labels: c,
235
242
  typography: u
236
243
  }),
237
- children: /* @__PURE__ */ E(H, {
244
+ children: /* @__PURE__ */ E(V, {
238
245
  sourceName: e.sourceName,
239
246
  annotationCount: e.annotations.length,
240
- onOpen: C,
247
+ onOpen: S,
241
248
  icon: o,
242
249
  labels: l,
243
250
  labelClassName: d
244
251
  })
245
252
  });
246
- }, ne = (e) => {
253
+ }, q = (e) => {
247
254
  let t = e.trim();
248
255
  if (!t.startsWith("|") || !t.endsWith("|") || /[\r\n]/.test(t)) return;
249
256
  let n = [], r = "";
@@ -252,11 +259,11 @@ var O = {
252
259
  i === "\\" && a != null && /[!-/:-@[-`{-~]/.test(a) ? (r += a, e += 1) : i === "|" ? (n.push(r.trim()), r = "") : r += i;
253
260
  }
254
261
  if (!(r !== "" || n.length < 2 || n.every((e) => e === "" || /^:?-{3,}:?$/.test(e)))) return n;
255
- }, re = (e) => {
262
+ }, J = (e) => {
256
263
  if (e.type !== "docx_text_anchor" && e.type !== "pptx_text_anchor") return;
257
264
  let { text: t, occurrence: n, slide: r } = e;
258
265
  if (typeof t != "string" || typeof n != "number" || !Number.isSafeInteger(n) || n < 1) return;
259
- let i = ne(t);
266
+ let i = q(t);
260
267
  if (i != null) {
261
268
  if (e.type === "docx_text_anchor") return {
262
269
  type: "docx_text_anchor",
@@ -270,13 +277,13 @@ var O = {
270
277
  slide: r
271
278
  };
272
279
  }
273
- }, ie = {
280
+ }, ae = {
274
281
  backgroundColor: "transparent",
275
282
  borderColor: "var(--stroke-accent, #1D4ED8)",
276
283
  borderWidth: "2px",
277
284
  opacity: .5,
278
285
  hoverOpacity: .5
279
- }, ae = (e) => {
286
+ }, oe = (e) => {
280
287
  if (typeof e != "object" || !e) return;
281
288
  let t = e, { lt: n, wh: r } = t;
282
289
  if (Array.isArray(n) && Array.isArray(r) && n.length >= 2 && r.length >= 2) {
@@ -295,7 +302,7 @@ var O = {
295
302
  x2: i + o,
296
303
  y2: a + s
297
304
  };
298
- }, J = (e) => {
305
+ }, Y = (e) => {
299
306
  if (!r(e)) return;
300
307
  let t = e, n;
301
308
  if (t.type === "pdf_bbox") {
@@ -306,7 +313,7 @@ var O = {
306
313
  x2: i,
307
314
  y2: a
308
315
  });
309
- } else t.type === "pdf_region" && (n = ae(t.bbox));
316
+ } else t.type === "pdf_region" && (n = oe(t.bbox));
310
317
  if (n == null) return;
311
318
  let i = t.page;
312
319
  if (!(typeof i != "number" || !Number.isInteger(i) || i < 1) && [
@@ -321,63 +328,63 @@ var O = {
321
328
  x2: n.x2,
322
329
  y2: n.y2
323
330
  };
324
- }, 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(",")}}`, oe = (e) => {
331
+ }, X = (e) => typeof e != "object" || !e ? String(e) : Array.isArray(e) ? `[${e.map(X).join(",")}]` : `{${Object.entries(e).filter(([, e]) => e !== void 0).sort(([e], [t]) => e < t ? -1 : +(e > t)).map(([e, t]) => `${e}=${X(t)}`).join(",")}}`, se = (e) => {
325
332
  let t = 5381;
326
333
  for (let n = 0; n < e.length; n += 1) t = t * 33 + e.charCodeAt(n) | 0;
327
334
  return (t >>> 0).toString(36);
328
- }, se = (e) => {
335
+ }, ce = (e) => {
329
336
  let t = e.body?.selector;
330
337
  if (t == null) return;
331
338
  let n = (Array.isArray(t) ? t : [t]).flatMap((e) => {
332
- let t = J(e);
339
+ let t = Y(e);
333
340
  return t == null ? [] : [t];
334
- }), r = _e(e);
335
- if (!(n.length === 0 && r.length === 0)) return Y([n, r]);
336
- }, ce = (e) => {
337
- let t = e.target?.selector, n = t?.type === "html_tag" ? t.id : void 0, r = typeof n == "string" ? n : void 0, i = se(e);
338
- if (!(r == null && i == null)) return oe(`${r ?? ""}|${i ?? ""}`);
339
- }, le = (e) => e.flatMap((e, t) => {
341
+ }), r = ye(e);
342
+ if (!(n.length === 0 && r.length === 0)) return X([n, r]);
343
+ }, le = (e) => {
344
+ let t = e.target?.selector, n = t?.type === "html_tag" ? t.id : void 0, r = typeof n == "string" ? n : void 0, i = ce(e);
345
+ if (!(r == null && i == null)) return se(`${r ?? ""}|${i ?? ""}`);
346
+ }, ue = (e) => e.flatMap((e, t) => {
340
347
  let n = e.body?.selector;
341
348
  if (n == null) return [];
342
349
  let i = (Array.isArray(n) ? n : [n]).flatMap((e) => {
343
350
  if (!r(e)) return [];
344
- let t = J(e);
351
+ let t = Y(e);
345
352
  return t == null ? [] : [t];
346
353
  });
347
354
  return i.length === 0 ? [] : [{
348
- id: X(e, t),
355
+ id: Z(e, t),
349
356
  bboxes: i,
350
- style: ie
357
+ style: ae
351
358
  }];
352
- }), X = (e, t) => e.index == null ? ce(e) ?? String(t) : String(e.index), ue = (e) => {
359
+ }), Z = (e, t) => e.index == null ? le(e) ?? String(t) : String(e.index), de = (e) => {
353
360
  let t = e.body?.selector;
354
361
  if (t == null) return;
355
362
  let n = Array.isArray(t) ? t : [t];
356
363
  for (let e of n) {
357
364
  if (!r(e)) continue;
358
- let t = J(e);
365
+ let t = Y(e);
359
366
  if (t != null) return t.page;
360
367
  }
361
- }, Z = (e) => {
368
+ }, Q = (e) => {
362
369
  let t = e.custom_content?.annotations;
363
370
  if (t?.length) return t.filter((e) => e != null && e.body?.source?.attachment?.url != null).map(a);
364
371
  let n = e.custom_fields;
365
372
  if (typeof n != "object" || !n) return [];
366
373
  let r = n.annotations;
367
374
  return !Array.isArray(r) || r.length === 0 ? [] : o(r, e.custom_content?.attachments ?? []).map(a);
368
- }, Q = (e) => {
375
+ }, fe = (e) => {
369
376
  if (e.type !== "docx_text_range") return !1;
370
377
  let t = e;
371
378
  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";
372
- }, de = (e) => {
379
+ }, pe = (e) => {
373
380
  if (e.type !== "pptx_text_range") return !1;
374
381
  let t = e;
375
382
  return typeof t.slide == "number" && typeof t.shape_id == "string" && typeof t.start == "number" && typeof t.end == "number" && typeof t.text == "string";
376
- }, fe = (e) => typeof e == "object" && !!e && typeof e.row == "number" && typeof e.col == "number", pe = (e) => {
383
+ }, me = (e) => typeof e == "object" && !!e && typeof e.row == "number" && typeof e.col == "number", he = (e) => {
377
384
  if (e.type !== "excel_rc_range") return !1;
378
385
  let t = e;
379
- return typeof t.sheet == "string" && fe(t.start) && (t.end === void 0 || t.end === null || fe(t.end));
380
- }, me = (e) => {
386
+ return typeof t.sheet == "string" && me(t.start) && (t.end === void 0 || t.end === null || me(t.end));
387
+ }, ge = (e) => {
381
388
  let { story: t, path: n, start: r, end: i, text: a } = e;
382
389
  if (!(!n.every((e) => Number.isInteger(e)) || !Number.isInteger(r) || !Number.isInteger(i) || r < 0 || i < r)) return {
383
390
  type: "docx_text_range",
@@ -387,7 +394,7 @@ var O = {
387
394
  endExclusive: i,
388
395
  text: a
389
396
  };
390
- }, he = (e) => {
397
+ }, _e = (e) => {
391
398
  let { slide: t, shape_id: n, start: r, end: i, text: a } = e;
392
399
  if (!(!Number.isInteger(t) || t < 1 || !Number.isInteger(r) || !Number.isInteger(i) || r < 0 || i < r)) return {
393
400
  type: "pptx_text_range",
@@ -397,7 +404,7 @@ var O = {
397
404
  endExclusive: i,
398
405
  text: a
399
406
  };
400
- }, ge = (e) => {
407
+ }, ve = (e) => {
401
408
  let { sheet: t, start: n, end: r } = e;
402
409
  if (!(t.length === 0 || !Number.isInteger(n.row) || !Number.isInteger(n.col) || n.row < 1 || n.col < 1)) {
403
410
  if (r == null) return {
@@ -412,40 +419,40 @@ var O = {
412
419
  end: r
413
420
  };
414
421
  }
415
- }, _e = (e) => {
422
+ }, ye = (e) => {
416
423
  let t = e.body?.selector;
417
424
  return t == null ? [] : (Array.isArray(t) ? t : [t]).flatMap((e) => {
418
425
  if (!r(e)) return [];
419
- if (Q(e)) {
420
- let t = me(e);
426
+ if (fe(e)) {
427
+ let t = ge(e);
421
428
  return t ? [t] : [];
422
429
  }
423
- if (de(e)) {
424
- let t = he(e);
430
+ if (pe(e)) {
431
+ let t = _e(e);
425
432
  return t ? [t] : [];
426
433
  }
427
- if (pe(e)) {
428
- let t = ge(e);
434
+ if (he(e)) {
435
+ let t = ve(e);
429
436
  return t ? [t] : [];
430
437
  }
431
- let t = re(e);
438
+ let t = J(e);
432
439
  return t ? [t] : [];
433
440
  });
434
- }, ve = (e, t) => S(() => t ? [] : Z(e), [t, e]), ye = {
441
+ }, be = (e, t) => C(() => t ? [] : Q(e), [t, e]), xe = {
435
442
  openOwnerKey: null,
436
443
  activeIndexByGroup: {}
437
- }, be = () => {
438
- let [e, t] = w(ye), n = _((e) => {
444
+ }, Se = () => {
445
+ let [e, t] = w(xe), n = b((e) => {
439
446
  t((t) => ({
440
447
  ...t,
441
448
  openOwnerKey: e
442
449
  }));
443
- }, []), r = _((e) => {
450
+ }, []), r = b((e) => {
444
451
  t((t) => t.openOwnerKey === e ? {
445
452
  ...t,
446
453
  openOwnerKey: null
447
454
  } : t);
448
- }, []), i = _((e, n) => {
455
+ }, []), i = b((e, n) => {
449
456
  t((t) => ({
450
457
  ...t,
451
458
  activeIndexByGroup: {
@@ -454,7 +461,7 @@ var O = {
454
461
  }
455
462
  }));
456
463
  }, []);
457
- return S(() => ({
464
+ return C(() => ({
458
465
  openPopup: n,
459
466
  closePopup: r,
460
467
  setActiveIndex: i,
@@ -466,7 +473,7 @@ var O = {
466
473
  i,
467
474
  e
468
475
  ]);
469
- }, xe = /⟦C(\d+)⟧/g, Se = (e, t) => {
476
+ }, Ce = /⟦C(\d+)⟧/g, we = (e, t) => {
470
477
  let n = t.map((e, t) => ({
471
478
  g: e,
472
479
  idx: t
@@ -479,9 +486,9 @@ var O = {
479
486
  }).sort((e, t) => t.pos - e.pos), r = e;
480
487
  for (let { idx: e, pos: t } of n) r = `${r.slice(0, t)}⟦C${e}⟧${r.slice(t)}`;
481
488
  return r;
482
- }, Ce = /<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>/g, we = /^<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>$/, Te = /<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>|<\/?cit\b[^>]*>|<\/?cit\b[^>]*$/gi, Ee = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), De = (e) => e.replace(Te, (e) => we.test(e) ? e : Ee(e)), Oe = (e) => De(e).replace(Ce, ""), $ = (e, t) => {
489
+ }, Te = /<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>/g, Ee = /^<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>$/, De = /<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>|<\/?cit\b[^>]*>|<\/?cit\b[^>]*$/gi, Oe = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), ke = (e) => e.replace(De, (e) => Ee.test(e) ? e : Oe(e)), Ae = (e) => ke(e).replace(Te, ""), $ = (e, t) => {
483
490
  if (typeof e == "string") {
484
- let n = e.split(xe);
491
+ let n = e.split(Ce);
485
492
  if (n.length === 1) return e;
486
493
  let r = [];
487
494
  return n.forEach((e, n) => {
@@ -492,34 +499,34 @@ var O = {
492
499
  let n = $(e, t);
493
500
  return Array.isArray(n) ? n : [n];
494
501
  }) : e;
495
- }, ke = {}, Ae = [], je = (e) => {
502
+ }, je = {}, Me = [], Ne = (e) => {
496
503
  let t = e.primaryAnnotation.target?.selector;
497
504
  return t?.type === "html_tag" ? t.id : void 0;
498
- }, Me = (e, t) => /* @__PURE__ */ D(T, { children: [
505
+ }, Pe = (e, t) => /* @__PURE__ */ D(T, { children: [
499
506
  e == null ? "<cit>" : `<cit data-id="${e}">`,
500
507
  t,
501
508
  "</cit>"
502
- ] }), Ne = (e, t, n, r = !1, a = !1, o = Ae) => {
503
- let { onPreview: s, isPreviewable: c, onOpenInBrowser: l, isPreviewOpen: u = !1, buildLabels: d } = n, f = S(() => r ? Oe(e) : De(t.length > 0 ? Se(e, t) : e), [
509
+ ] }), Fe = (e, t, n, r = !1, a = !1, o = Me) => {
510
+ let { onPreview: s, isPreviewable: c, onOpenInBrowser: l, isPreviewOpen: u = !1, buildLabels: d } = n, f = C(() => r ? Ae(e) : ke(t.length > 0 ? we(e, t) : e), [
504
511
  e,
505
512
  t,
506
513
  r
507
514
  ]), p = f.includes("<cit");
508
515
  return {
509
516
  processedContent: f,
510
- markdownComponents: S(() => {
517
+ markdownComponents: C(() => {
511
518
  let e = /* @__PURE__ */ new Map();
512
519
  for (let t of o) {
513
- let n = je(t);
520
+ let n = Ne(t);
514
521
  n != null && e.set(n, t);
515
522
  }
516
523
  for (let n of t) {
517
- let t = je(n);
524
+ let t = Ne(n);
518
525
  t != null && e.set(t, n);
519
526
  }
520
527
  let n = (e) => {
521
528
  let { cardLabels: t, markerLabels: n } = d(e);
522
- return /* @__PURE__ */ E(q, {
529
+ return /* @__PURE__ */ E(K, {
523
530
  group: e,
524
531
  onPreview: (t) => s(t, e),
525
532
  isPreviewable: c,
@@ -533,9 +540,9 @@ var O = {
533
540
  return r ? n(r) : null;
534
541
  }, f = { cit: (t) => {
535
542
  let r = t["data-id"] == null ? void 0 : e.get(t["data-id"]);
536
- return r ? n(r) : Me(t["data-id"], t.children);
543
+ return r ? n(r) : Pe(t["data-id"], t.children);
537
544
  } };
538
- return t.length === 0 && o.length === 0 ? p ? f : ke : {
545
+ return t.length === 0 && o.length === 0 ? p ? f : je : {
539
546
  ...f,
540
547
  p: ({ children: e, ...t }) => /* @__PURE__ */ E("p", {
541
548
  ...t,
@@ -560,14 +567,14 @@ var O = {
560
567
  p
561
568
  ])
562
569
  };
563
- }, Pe = (e) => e.url == null && e.reference_url != null, Fe = /^(.*\.pdf)(?:#page=(\d+))?$/i, Ie = (e) => {
564
- let t = Fe.exec(e);
570
+ }, Ie = (e) => e.url == null && e.reference_url != null, Le = /^(.*\.pdf)(?:#page=(\d+))?$/i, Re = (e) => {
571
+ let t = Le.exec(e);
565
572
  return t ? {
566
573
  baseUrl: t[1],
567
574
  page: t[2] == null ? null : Number(t[2])
568
575
  } : null;
569
- }, Le = (t) => I((t ?? []).filter(Pe).map((t) => {
570
- let n = t.reference_url, r = Ie(n) != null;
576
+ }, ze = (t) => F((t ?? []).filter(Ie).map((t) => {
577
+ let n = t.reference_url, r = Re(n) != null;
571
578
  return { body: {
572
579
  quote: t.data,
573
580
  source: {
@@ -581,4 +588,4 @@ var O = {
581
588
  } };
582
589
  }));
583
590
  //#endregion
584
- export { V as CitationCard, W as CitationCardProvider, q as CitationDropdown, H as CitationMarker, O as QUOTATIONS_CLASS, X as annotationHighlightId, _e as annotationToOfficeHighlightLocations, le as annotationsToPdfHighlights, z as gatherSameSourceAnnotations, ue as getAnnotationPdfPage, Le as getReferenceAttachmentGroups, R as groupAnnotations, L as groupAnnotationsByCitId, I as groupAnnotationsBySource, Se as injectCitationSentinels, Q as isDocxRangeSelector, pe as isExcelRcRangeSelector, de as isPptxRangeSelector, Pe as isReferenceOnlyAttachment, Ie as parsePdfPageReference, $ as replaceSentinelsInChildren, Z as resolveMessageAnnotations, Oe as stripCitTagsWhileStreaming, ve as useAnnotations, be as useCitationCard, G as useCitationCardContext, Ne as useCitationMarkdownComponents };
591
+ export { B as CitationCard, U as CitationCardProvider, K as CitationDropdown, V as CitationMarker, O as QUOTATIONS_CLASS, Z as annotationHighlightId, ye as annotationToOfficeHighlightLocations, ue as annotationsToPdfHighlights, R as gatherSameSourceAnnotations, de as getAnnotationPdfPage, ze as getReferenceAttachmentGroups, L as groupAnnotations, I as groupAnnotationsByCitId, F as groupAnnotationsBySource, we as injectCitationSentinels, fe as isDocxRangeSelector, he as isExcelRcRangeSelector, pe as isPptxRangeSelector, Ie as isReferenceOnlyAttachment, Re as parsePdfPageReference, $ as replaceSentinelsInChildren, Q as resolveMessageAnnotations, Ae as stripCitTagsWhileStreaming, be as useAnnotations, Se as useCitationCard, W as useCitationCardContext, Fe as useCitationMarkdownComponents };
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.2.0-dev.201",
4
+ "version": "1.2.0-dev.208",
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.2.0-dev.201",
26
+ "@epam/ai-dial-chat-shared": "1.2.0-dev.208",
27
27
  "@epam/ai-dial-ui-kit": "^0.15.0-dev.23"
28
28
  },
29
29
  "repository": {