@epam/ai-dial-quotations 1.3.0-dev.142 → 1.3.0-dev.147
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/hooks/citation-rendering.d.ts +8 -0
- package/hooks/citation-rendering.d.ts.map +1 -0
- package/hooks/useCitationMarkdownComponents/useCitationMarkdownComponents.d.ts.map +1 -1
- package/hooks/useCitationTagRenderer/useCitationTagRenderer.d.ts +15 -0
- package/hooks/useCitationTagRenderer/useCitationTagRenderer.d.ts.map +1 -0
- package/index.d.ts +2 -1
- package/index.d.ts.map +1 -1
- package/index.js +221 -186
- package/package.json +2 -2
- package/utils/citation-injection.d.ts +7 -0
- package/utils/citation-injection.d.ts.map +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AnnotationGroup } from '../utils/group-annotations-by-source';
|
|
3
|
+
import { UseCitationMarkdownComponentsCallbacks } from './useCitationMarkdownComponents/useCitationMarkdownComponents';
|
|
4
|
+
/** Renders a `<cit>` element as the literal markup it was written as. */
|
|
5
|
+
export declare const renderCitTagAsText: (dataId: string | undefined, children: ReactNode) => import('react').JSX.Element;
|
|
6
|
+
/** Returns a function that renders a group's `CitationDropdown` with the host's callbacks and labels. */
|
|
7
|
+
export declare const createCitationGroupRenderer: ({ onPreview, isPreviewable, onOpenInBrowser, isDownloadEnabled, isPreviewOpen, previewFilesOnMarkerClick, buildLabels, }: UseCitationMarkdownComponentsCallbacks) => (group: AnnotationGroup) => import('react').JSX.Element;
|
|
8
|
+
//# sourceMappingURL=citation-rendering.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"citation-rendering.d.ts","sourceRoot":"","sources":["../../src/hooks/citation-rendering.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,KAAK,EAAE,sCAAsC,EAAE,MAAM,+DAA+D,CAAC;AAE5H,yEAAyE;AACzE,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,MAAM,GAAG,SAAS,EAC1B,UAAU,SAAS,gCAOpB,CAAC;AAEF,yGAAyG;AACzG,eAAO,MAAM,2BAA2B,GAAI,0HAQzC,sCAAsC,aACX,eAAe,gCAmB5C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCitationMarkdownComponents.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCitationMarkdownComponents/useCitationMarkdownComponents.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;
|
|
1
|
+
{"version":3,"file":"useCitationMarkdownComponents.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCitationMarkdownComponents/useCitationMarkdownComponents.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AACrF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AAQ3F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAM/E,6FAA6F;AAC7F,MAAM,WAAW,sCAAsC;IACrD,4GAA4G;IAC5G,SAAS,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;IAChE,gFAAgF;IAChF,aAAa,CAAC,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC;IAChD,yEAAyE;IACzE,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9C,oGAAoG;IACpG,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,wIAAwI;IACxI,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,sMAAsM;IACtM,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,4FAA4F;IAC5F,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG;QACnC,UAAU,EAAE,kBAAkB,CAAC;QAC/B,YAAY,EAAE,oBAAoB,CAAC;KACpC,CAAC;CACH;AAeD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,6BAA6B,GACxC,SAAS,MAAM,EACf,QAAQ,eAAe,EAAE,EACzB,WAAW,sCAAsC,EACjD,qBAAmB,EACnB,6BAA2B,EAC3B,iBAAgB,eAAe,EAA0B,KACxD;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,UAAU,CAAA;CAkG5D,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AnnotationGroup } from '../../utils/group-annotations-by-source';
|
|
3
|
+
import { UseCitationMarkdownComponentsCallbacks } from '../useCitationMarkdownComponents/useCitationMarkdownComponents';
|
|
4
|
+
/**
|
|
5
|
+
* Returns a renderer for `<cit data-id="…">` elements only — the citation
|
|
6
|
+
* dropdown for a claimed id, the literal markup otherwise.
|
|
7
|
+
*
|
|
8
|
+
* Exists for markdown surfaces other than the message body (e.g. stage
|
|
9
|
+
* content): unlike `useCitationMarkdownComponents` it returns no `p`/`li`
|
|
10
|
+
* overrides, so the surface keeps its own typography, and it never resolves
|
|
11
|
+
* offset-based groups, whose offsets point into the message text. `groups`
|
|
12
|
+
* win over `fallbackGroups` on a colliding id.
|
|
13
|
+
*/
|
|
14
|
+
export declare const useCitationTagRenderer: (groups: AnnotationGroup[], callbacks: UseCitationMarkdownComponentsCallbacks, fallbackGroups?: AnnotationGroup[]) => ((dataId: string | undefined, children: ReactNode) => ReactNode);
|
|
15
|
+
//# sourceMappingURL=useCitationTagRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCitationTagRenderer.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCitationTagRenderer/useCitationTagRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAK/E,OAAO,KAAK,EAAE,sCAAsC,EAAE,MAAM,gEAAgE,CAAC;AAS7H;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,GACjC,QAAQ,eAAe,EAAE,EACzB,WAAW,sCAAsC,EACjD,iBAAgB,eAAe,EAA0B,KACxD,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,SAAS,KAAK,SAAS,CAsCjE,CAAC"}
|
package/index.d.ts
CHANGED
|
@@ -10,11 +10,12 @@ export { useAnnotations } from './utils/useAnnotations';
|
|
|
10
10
|
export { useCitationCard } from './utils/useCitationCard';
|
|
11
11
|
export { useCitationMarkdownComponents } from './hooks/useCitationMarkdownComponents/useCitationMarkdownComponents';
|
|
12
12
|
export type { UseCitationMarkdownComponentsCallbacks } from './hooks/useCitationMarkdownComponents/useCitationMarkdownComponents';
|
|
13
|
+
export { useCitationTagRenderer } from './hooks/useCitationTagRenderer/useCitationTagRenderer';
|
|
13
14
|
export { gatherSameSourceAnnotations, groupAnnotations, groupAnnotationsByCitId, groupAnnotationsBySource, } from './utils/group-annotations-by-source';
|
|
14
15
|
export type { AnnotationGroup } from './utils/group-annotations-by-source';
|
|
15
16
|
export { annotationHighlightId, annotationHighlightIds, annotationsToPdfHighlights, annotationToOfficeHighlightLocations, getAnnotationPdfPage, isDocxRangeSelector, isExcelRcRangeSelector, isPptxRangeSelector, resolveMessageAnnotations, } from './utils/annotation';
|
|
16
17
|
export type { DocxOfficeHighlightLocation, DocxTableRowOfficeHighlightLocation, ExcelOfficeHighlightLocation, OfficeHighlightLocation, PptxOfficeHighlightLocation, PptxTableRowOfficeHighlightLocation, } from './models/office-highlight';
|
|
17
|
-
export { injectCitationSentinels, replaceCitTagsWithSourceNames, replaceSentinelsInChildren, stripCitTagsWhileStreaming, } from './utils/citation-injection';
|
|
18
|
+
export { injectCitationSentinels, prepareCitationContent, replaceCitTagsWithSourceNames, replaceSentinelsInChildren, stripCitTagsWhileStreaming, } from './utils/citation-injection';
|
|
18
19
|
export { isReferenceOnlyAttachment, parsePdfPageReference, getReferenceAttachmentGroups, } from './utils/reference-attachment';
|
|
19
20
|
export type { PdfPageReference } from './utils/reference-attachment';
|
|
20
21
|
export { QUOTATIONS_CLASS } from './constants/public-class-names';
|
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,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,YAAY,EACV,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAClF,YAAY,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AAG5F,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,+BAA+B,CAAC;AACvC,YAAY,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGtE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,qEAAqE,CAAC;AACpH,YAAY,EAAE,sCAAsC,EAAE,MAAM,qEAAqE,CAAC;
|
|
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,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,YAAY,EACV,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAClF,YAAY,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AAG5F,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,+BAA+B,CAAC;AACvC,YAAY,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGtE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,qEAAqE,CAAC;AACpH,YAAY,EAAE,sCAAsC,EAAE,MAAM,qEAAqE,CAAC;AAClI,OAAO,EAAE,sBAAsB,EAAE,MAAM,uDAAuD,CAAC;AAG/F,OAAO,EACL,2BAA2B,EAC3B,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,qCAAqC,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAE3E,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,oCAAoC,EACpC,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"}
|
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, ElementSize as u, EllipsisTooltip as d, FileIcon as f, GhostIconButton as p, LinkButton as m, NeutralButton as h, PrimaryButton as g } from "@epam/ai-dial-ui-kit";
|
|
3
3
|
import { IconChevronLeft as _, IconChevronRight as v } from "@tabler/icons-react";
|
|
4
|
-
import { createContext as y, useCallback as b, useContext as x, useEffect as
|
|
5
|
-
import { Fragment as
|
|
4
|
+
import { createContext as y, useCallback as b, useContext as x, useEffect as ee, useId as te, useLayoutEffect as S, useMemo as C, useRef as ne, 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
|
|
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
|
-
},
|
|
11
|
+
}, k = (t) => {
|
|
12
12
|
let n = t.body?.source?.attachment?.type;
|
|
13
13
|
return n === e.HTML || n === e.XHTML;
|
|
14
|
-
},
|
|
14
|
+
}, A = (e) => {
|
|
15
15
|
try {
|
|
16
16
|
return decodeURIComponent(e);
|
|
17
17
|
} catch {
|
|
18
18
|
return e;
|
|
19
19
|
}
|
|
20
|
-
},
|
|
20
|
+
}, j = (e) => {
|
|
21
21
|
try {
|
|
22
22
|
let t = new URL(e);
|
|
23
|
-
return t.pathname.split("/").map((e) =>
|
|
23
|
+
return t.pathname.split("/").map((e) => A(e)).filter(Boolean).at(-1) ?? t.hostname;
|
|
24
24
|
} catch {
|
|
25
|
-
return e.split("/").map((e) =>
|
|
25
|
+
return e.split("/").map((e) => A(e)).filter(Boolean).at(-1) ?? e;
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
let t = e == null ? null :
|
|
27
|
+
}, M = /\.([a-z0-9]{1,10})$/i, N = (e) => {
|
|
28
|
+
let t = e == null ? null : M.exec(e.trim());
|
|
29
29
|
return t == null ? void 0 : `.${t[1].toLowerCase()}`;
|
|
30
|
-
},
|
|
30
|
+
}, re = (e) => {
|
|
31
31
|
let t = e.body?.source?.attachment, n = t?.url;
|
|
32
|
-
return (n == null ? void 0 :
|
|
33
|
-
},
|
|
32
|
+
return (n == null ? void 0 : N(j(n))) ?? N(t?.title);
|
|
33
|
+
}, P = (e, t) => e.body?.source?.attachment?.title ?? j(t), F = (e) => {
|
|
34
34
|
let t = e.target?.selector;
|
|
35
35
|
return t?.type === "html_tag" ? t : void 0;
|
|
36
|
-
},
|
|
36
|
+
}, ie = (e) => F(e) != null, I = (e) => {
|
|
37
37
|
let t = /* @__PURE__ */ new Map();
|
|
38
38
|
for (let n of e) {
|
|
39
|
-
if (
|
|
39
|
+
if (ie(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:
|
|
46
|
+
sourceName: P(n, e),
|
|
47
47
|
annotations: [n],
|
|
48
48
|
primaryAnnotation: n
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
return Array.from(t.values());
|
|
52
|
-
},
|
|
52
|
+
}, L = (e) => {
|
|
53
53
|
let t = /* @__PURE__ */ new Map();
|
|
54
54
|
for (let n of e) {
|
|
55
|
-
let e =
|
|
55
|
+
let e = F(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:
|
|
63
|
+
sourceName: P(n, r),
|
|
64
64
|
annotations: [n],
|
|
65
65
|
primaryAnnotation: n
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
return Array.from(t.values());
|
|
69
|
-
},
|
|
69
|
+
}, R = (e) => [...L(e), ...I(e)], z = (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
|
-
},
|
|
72
|
+
}, B = {
|
|
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
|
-
},
|
|
79
|
-
let
|
|
78
|
+
}, V = ({ group: e, activeIndex: r, onIndexChange: a, onPreview: o, onOpenInBrowser: l, isDownloadEnabled: h = !0, headerIcon: y, labels: b, typography: x, colors: C }) => {
|
|
79
|
+
let T = e.annotations.length, A = e.annotations[r] ?? e.primaryAnnotation, j = T > 1, M = o == null || k(A), N = M ? void 0 : re(A), P = N ?? e.sourceName, F = y ?? (N == null ? void 0 : /* @__PURE__ */ E(f, {
|
|
80
80
|
type: c.File,
|
|
81
|
-
name:
|
|
82
|
-
fileExtension:
|
|
81
|
+
name: N,
|
|
82
|
+
fileExtension: N,
|
|
83
83
|
size: 16,
|
|
84
84
|
decorative: !0,
|
|
85
85
|
className: "shrink-0"
|
|
86
|
-
})),
|
|
87
|
-
"--cc-card-bg":
|
|
88
|
-
"--cc-quote-text":
|
|
89
|
-
"--cc-title-text":
|
|
90
|
-
"--cc-switcher-text":
|
|
91
|
-
"--cc-source-name-text":
|
|
92
|
-
}),
|
|
93
|
-
return
|
|
94
|
-
|
|
95
|
-
}, [r,
|
|
96
|
-
let e =
|
|
97
|
-
if (!e ||
|
|
98
|
-
let t = () =>
|
|
86
|
+
})), ie = 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", z = x?.switcherClassName ?? "dial-tiny-text", V = n({
|
|
87
|
+
"--cc-card-bg": C?.cardBackground,
|
|
88
|
+
"--cc-quote-text": C?.quoteText,
|
|
89
|
+
"--cc-title-text": C?.titleText,
|
|
90
|
+
"--cc-switcher-text": C?.switcherText,
|
|
91
|
+
"--cc-source-name-text": C?.sourceNameText
|
|
92
|
+
}), H = A.body?.quote, U = te(), W = ne(null), [G, K] = w(!1), [q, ae] = w(!1);
|
|
93
|
+
return ee(() => {
|
|
94
|
+
K(!1);
|
|
95
|
+
}, [r, H]), S(() => {
|
|
96
|
+
let e = W.current;
|
|
97
|
+
if (!e || G) return;
|
|
98
|
+
let t = () => ae(e.scrollHeight > e.clientHeight + 1);
|
|
99
99
|
t();
|
|
100
100
|
let n = new ResizeObserver(t);
|
|
101
101
|
return n.observe(e), () => n.disconnect();
|
|
102
|
-
}, [
|
|
102
|
+
}, [H, G]), /* @__PURE__ */ D("div", {
|
|
103
103
|
role: "dialog",
|
|
104
104
|
"aria-modal": "true",
|
|
105
105
|
"aria-label": b.ariaLabel,
|
|
106
|
-
style:
|
|
107
|
-
className: i("flex w-[400px] max-w-full flex-col gap-3 rounded-lg p-4 shadow-lg",
|
|
106
|
+
style: V,
|
|
107
|
+
className: i("flex w-[400px] max-w-full flex-col gap-3 rounded-lg p-4 shadow-lg", B.card, O.citationCard),
|
|
108
108
|
children: [
|
|
109
|
-
/* @__PURE__ */
|
|
109
|
+
/* @__PURE__ */ D("div", {
|
|
110
110
|
className: "flex items-center justify-between gap-2",
|
|
111
|
-
children: [/* @__PURE__ */
|
|
111
|
+
children: [/* @__PURE__ */ D("div", {
|
|
112
112
|
className: "flex min-w-0 items-center gap-1",
|
|
113
|
-
children: [
|
|
114
|
-
text:
|
|
115
|
-
className: i(
|
|
113
|
+
children: [F, /* @__PURE__ */ E(d, {
|
|
114
|
+
text: P,
|
|
115
|
+
className: i(ie, "min-w-0", B.sourceName)
|
|
116
116
|
})]
|
|
117
|
-
}),
|
|
117
|
+
}), j && /* @__PURE__ */ D("div", {
|
|
118
118
|
className: "flex shrink-0 items-center gap-1",
|
|
119
119
|
children: [
|
|
120
|
-
/* @__PURE__ */
|
|
121
|
-
icon: /* @__PURE__ */
|
|
120
|
+
/* @__PURE__ */ E(p, {
|
|
121
|
+
icon: /* @__PURE__ */ E(_, {
|
|
122
122
|
size: 14,
|
|
123
123
|
className: "rtl:scale-x-[-1]",
|
|
124
124
|
stroke: s
|
|
125
125
|
}),
|
|
126
126
|
size: u.Small,
|
|
127
127
|
"aria-label": b.previousCitation,
|
|
128
|
-
onClick: () => a((r - 1 +
|
|
128
|
+
onClick: () => a((r - 1 + T) % T)
|
|
129
129
|
}),
|
|
130
|
-
/* @__PURE__ */
|
|
131
|
-
className: i(
|
|
132
|
-
children: b.formatSwitcherText(r + 1,
|
|
130
|
+
/* @__PURE__ */ E("span", {
|
|
131
|
+
className: i(z, B.switcher),
|
|
132
|
+
children: b.formatSwitcherText(r + 1, T)
|
|
133
133
|
}),
|
|
134
|
-
/* @__PURE__ */
|
|
135
|
-
icon: /* @__PURE__ */
|
|
134
|
+
/* @__PURE__ */ E(p, {
|
|
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: u.Small,
|
|
141
141
|
"aria-label": b.nextCitation,
|
|
142
|
-
onClick: () => a((r + 1) %
|
|
142
|
+
onClick: () => a((r + 1) % T)
|
|
143
143
|
})
|
|
144
144
|
]
|
|
145
145
|
})]
|
|
146
146
|
}),
|
|
147
|
-
(
|
|
147
|
+
(A.body?.title || A.body?.quote || j) && /* @__PURE__ */ D("div", {
|
|
148
148
|
className: "flex flex-col gap-3",
|
|
149
|
-
children: [
|
|
150
|
-
className: i(
|
|
151
|
-
children:
|
|
152
|
-
}), (
|
|
149
|
+
children: [A.body?.title && /* @__PURE__ */ E("p", {
|
|
150
|
+
className: i(I, B.title, "break-words"),
|
|
151
|
+
children: A.body.title
|
|
152
|
+
}), (H || j) && /* @__PURE__ */ D("div", {
|
|
153
153
|
className: "flex flex-col items-start gap-1",
|
|
154
|
-
children: [/* @__PURE__ */
|
|
155
|
-
ref:
|
|
156
|
-
id:
|
|
157
|
-
tabIndex:
|
|
158
|
-
className: i(
|
|
159
|
-
children:
|
|
160
|
-
content:
|
|
154
|
+
children: [/* @__PURE__ */ E("div", {
|
|
155
|
+
ref: W,
|
|
156
|
+
id: U,
|
|
157
|
+
tabIndex: G ? 0 : void 0,
|
|
158
|
+
className: i(L, B.quote, "w-full break-words", G ? "max-h-[min(20rem,50vh)] overflow-y-auto" : "line-clamp-6"),
|
|
159
|
+
children: H && /* @__PURE__ */ E(t, {
|
|
160
|
+
content: H,
|
|
161
161
|
classNames: {
|
|
162
|
-
p: i(
|
|
163
|
-
ul: i(
|
|
164
|
-
ol:
|
|
165
|
-
strong:
|
|
162
|
+
p: i(L, B.quote),
|
|
163
|
+
ul: i(L, "ps-[1.5em]"),
|
|
164
|
+
ol: L,
|
|
165
|
+
strong: R
|
|
166
166
|
},
|
|
167
167
|
codeBlockCopyLabel: b.codeBlockCopyLabel,
|
|
168
168
|
codeBlockCopiedLabel: b.codeBlockCopiedLabel,
|
|
@@ -170,70 +170,70 @@ var A = {
|
|
|
170
170
|
tableScrollRegionAriaLabel: b.tableScrollRegionAriaLabel,
|
|
171
171
|
mathScrollRegionAriaLabel: b.mathScrollRegionAriaLabel
|
|
172
172
|
})
|
|
173
|
-
}),
|
|
174
|
-
label:
|
|
173
|
+
}), q && /* @__PURE__ */ E(m, {
|
|
174
|
+
label: G ? b.showLess : b.showMore,
|
|
175
175
|
size: u.Small,
|
|
176
|
-
"aria-expanded":
|
|
177
|
-
"aria-controls":
|
|
178
|
-
onClick: () =>
|
|
176
|
+
"aria-expanded": G,
|
|
177
|
+
"aria-controls": U,
|
|
178
|
+
onClick: () => K((e) => !e)
|
|
179
179
|
})]
|
|
180
180
|
})]
|
|
181
181
|
}),
|
|
182
|
-
/* @__PURE__ */
|
|
182
|
+
/* @__PURE__ */ D("div", {
|
|
183
183
|
className: "flex justify-start gap-2",
|
|
184
|
-
children: [o && /* @__PURE__ */
|
|
184
|
+
children: [o && /* @__PURE__ */ E(g, {
|
|
185
185
|
label: b.preview,
|
|
186
186
|
size: u.Small,
|
|
187
|
-
onClick: () => o(
|
|
188
|
-
}), (
|
|
189
|
-
label:
|
|
187
|
+
onClick: () => o(A)
|
|
188
|
+
}), (M || h) && /* @__PURE__ */ E(g, {
|
|
189
|
+
label: M ? b.openInBrowser : b.download,
|
|
190
190
|
size: u.Small,
|
|
191
|
-
onClick: () => l(
|
|
191
|
+
onClick: () => l(A)
|
|
192
192
|
})]
|
|
193
193
|
})
|
|
194
194
|
]
|
|
195
195
|
});
|
|
196
|
-
},
|
|
196
|
+
}, H = ({ annotationCount: e, onOpen: t, icon: n, labels: r, labelClassName: a = "dial-caption-text" }) => /* @__PURE__ */ E(h, {
|
|
197
197
|
size: u.Small,
|
|
198
|
-
className: i("max-w-[240px]",
|
|
198
|
+
className: i("max-w-[240px]", O.citationMarker),
|
|
199
199
|
textClassName: "min-w-0 truncate",
|
|
200
200
|
iconBefore: n,
|
|
201
|
-
label: /* @__PURE__ */
|
|
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
|
onClick: t
|
|
207
|
-
}),
|
|
208
|
-
let e = x(
|
|
207
|
+
}), U = y(null), W = U.Provider, G = () => {
|
|
208
|
+
let e = x(U);
|
|
209
209
|
if (e == null) throw Error("useCitationCardContext must be used within a CitationCardProvider");
|
|
210
210
|
return e;
|
|
211
|
-
},
|
|
212
|
-
let h =
|
|
211
|
+
}, K = { 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: u, cardLabels: d, markerLabels: f, cardTypography: p, markerLabelClassName: m }) => {
|
|
212
|
+
let h = G(), g = te(), _ = h.isOpen(g), v = h.getActiveIndex(e.groupKey), y = e.annotations[v] ?? e.primaryAnnotation, x = n?.(y) ?? !0, ee = b((e) => {
|
|
213
213
|
e || h.closePopup(g);
|
|
214
|
-
}, [h, g]),
|
|
214
|
+
}, [h, g]), S = C(() => t && x ? (e) => {
|
|
215
215
|
t(e), h.closePopup(g);
|
|
216
216
|
} : void 0, [
|
|
217
217
|
t,
|
|
218
218
|
x,
|
|
219
219
|
h,
|
|
220
220
|
g
|
|
221
|
-
]),
|
|
222
|
-
let t = e.annotations.length === 1 && !
|
|
223
|
-
(o || s && t) &&
|
|
221
|
+
]), ne = b(() => {
|
|
222
|
+
let t = e.annotations.length === 1 && !k(y);
|
|
223
|
+
(o || s && t) && S ? S(y) : h.openPopup(g);
|
|
224
224
|
}, [
|
|
225
225
|
o,
|
|
226
226
|
s,
|
|
227
227
|
e.annotations.length,
|
|
228
|
-
|
|
228
|
+
S,
|
|
229
229
|
y,
|
|
230
230
|
h,
|
|
231
231
|
g
|
|
232
|
-
]),
|
|
232
|
+
]), w = b(() => /* @__PURE__ */ E(V, {
|
|
233
233
|
group: e,
|
|
234
234
|
activeIndex: v,
|
|
235
235
|
onIndexChange: (t) => h.setActiveIndex(e.groupKey, t),
|
|
236
|
-
onPreview:
|
|
236
|
+
onPreview: S,
|
|
237
237
|
onOpenInBrowser: r,
|
|
238
238
|
isDownloadEnabled: a,
|
|
239
239
|
headerIcon: u,
|
|
@@ -243,32 +243,32 @@ var A = {
|
|
|
243
243
|
e,
|
|
244
244
|
v,
|
|
245
245
|
h,
|
|
246
|
-
|
|
246
|
+
S,
|
|
247
247
|
r,
|
|
248
248
|
a,
|
|
249
249
|
u,
|
|
250
250
|
d,
|
|
251
251
|
p
|
|
252
252
|
]);
|
|
253
|
-
return /* @__PURE__ */
|
|
253
|
+
return /* @__PURE__ */ E(l, {
|
|
254
254
|
open: _,
|
|
255
|
-
onOpenChange:
|
|
255
|
+
onOpenChange: ee,
|
|
256
256
|
trigger: [],
|
|
257
257
|
placement: "bottom-end",
|
|
258
258
|
matchReferenceWidth: !1,
|
|
259
|
-
className: i("ms-1 inline-flex align-middle",
|
|
260
|
-
listClassName: i("!p-0 !bg-transparent !shadow-none !rounded-none",
|
|
261
|
-
renderOverlay:
|
|
262
|
-
children: /* @__PURE__ */
|
|
259
|
+
className: i("ms-1 inline-flex align-middle", K.trigger),
|
|
260
|
+
listClassName: i("!p-0 !bg-transparent !shadow-none !rounded-none", O.citationDropdown),
|
|
261
|
+
renderOverlay: w,
|
|
262
|
+
children: /* @__PURE__ */ E(H, {
|
|
263
263
|
sourceName: e.sourceName,
|
|
264
264
|
annotationCount: e.annotations.length,
|
|
265
|
-
onOpen:
|
|
265
|
+
onOpen: ne,
|
|
266
266
|
icon: c,
|
|
267
267
|
labels: f,
|
|
268
268
|
labelClassName: m
|
|
269
269
|
})
|
|
270
270
|
});
|
|
271
|
-
},
|
|
271
|
+
}, ae = (e) => {
|
|
272
272
|
let t = e.trim();
|
|
273
273
|
if (!t.startsWith("|") || !t.endsWith("|") || /[\r\n]/.test(t)) return;
|
|
274
274
|
let n = [], r = "";
|
|
@@ -277,11 +277,11 @@ var A = {
|
|
|
277
277
|
i === "\\" && a != null && /[!-/:-@[-`{-~]/.test(a) ? (r += a, e += 1) : i === "|" ? (n.push(r.trim()), r = "") : r += i;
|
|
278
278
|
}
|
|
279
279
|
if (!(r !== "" || n.length < 2 || n.every((e) => e === "" || /^:?-{3,}:?$/.test(e)))) return n;
|
|
280
|
-
},
|
|
280
|
+
}, oe = (e) => {
|
|
281
281
|
if (e.type !== "docx_text_anchor" && e.type !== "pptx_text_anchor") return;
|
|
282
282
|
let { text: t, occurrence: n, slide: r } = e;
|
|
283
283
|
if (typeof t != "string" || typeof n != "number" || !Number.isSafeInteger(n) || n < 1) return;
|
|
284
|
-
let i =
|
|
284
|
+
let i = ae(t);
|
|
285
285
|
if (i != null) {
|
|
286
286
|
if (e.type === "docx_text_anchor") return {
|
|
287
287
|
type: "docx_text_anchor",
|
|
@@ -295,13 +295,13 @@ var A = {
|
|
|
295
295
|
slide: r
|
|
296
296
|
};
|
|
297
297
|
}
|
|
298
|
-
},
|
|
298
|
+
}, se = {
|
|
299
299
|
backgroundColor: "transparent",
|
|
300
300
|
borderColor: "var(--stroke-accent, #1D4ED8)",
|
|
301
301
|
borderWidth: "2px",
|
|
302
302
|
opacity: .5,
|
|
303
303
|
hoverOpacity: .5
|
|
304
|
-
},
|
|
304
|
+
}, ce = (e) => {
|
|
305
305
|
if (typeof e != "object" || !e) return;
|
|
306
306
|
let t = e, { lt: n, wh: r } = t;
|
|
307
307
|
if (Array.isArray(n) && Array.isArray(r) && n.length >= 2 && r.length >= 2) {
|
|
@@ -320,7 +320,7 @@ var A = {
|
|
|
320
320
|
x2: i + o,
|
|
321
321
|
y2: a + s
|
|
322
322
|
};
|
|
323
|
-
},
|
|
323
|
+
}, J = (e) => {
|
|
324
324
|
if (!r(e)) return;
|
|
325
325
|
let t = e, n;
|
|
326
326
|
if (t.type === "pdf_bbox") {
|
|
@@ -331,7 +331,7 @@ var A = {
|
|
|
331
331
|
x2: i,
|
|
332
332
|
y2: a
|
|
333
333
|
});
|
|
334
|
-
} else t.type === "pdf_region" && (n =
|
|
334
|
+
} else t.type === "pdf_region" && (n = ce(t.bbox));
|
|
335
335
|
if (n == null) return;
|
|
336
336
|
let i = t.page;
|
|
337
337
|
if (!(typeof i != "number" || !Number.isInteger(i) || i < 1) && [
|
|
@@ -346,45 +346,45 @@ var A = {
|
|
|
346
346
|
x2: n.x2,
|
|
347
347
|
y2: n.y2
|
|
348
348
|
};
|
|
349
|
-
},
|
|
349
|
+
}, le = (e) => {
|
|
350
350
|
if (!r(e)) return;
|
|
351
351
|
let t = e;
|
|
352
352
|
if (t.type !== "pdf_bbox" && t.type !== "pdf_region") return;
|
|
353
353
|
let n = t.page;
|
|
354
354
|
return typeof n == "number" && Number.isInteger(n) && n >= 1 ? n : void 0;
|
|
355
|
-
},
|
|
355
|
+
}, 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(",")}}`, ue = (e) => {
|
|
356
356
|
let t = 5381;
|
|
357
357
|
for (let n = 0; n < e.length; n += 1) t = t * 33 + e.charCodeAt(n) | 0;
|
|
358
358
|
return (t >>> 0).toString(36);
|
|
359
|
-
},
|
|
359
|
+
}, de = (e) => {
|
|
360
360
|
let t = e.body?.selector;
|
|
361
361
|
if (t == null) return;
|
|
362
362
|
let n = (Array.isArray(t) ? t : [t]).flatMap((e) => {
|
|
363
|
-
let t =
|
|
363
|
+
let t = J(e);
|
|
364
364
|
return t == null ? [] : [t];
|
|
365
|
-
}), r =
|
|
366
|
-
if (n.length !== 0 || r.length !== 0) return
|
|
367
|
-
},
|
|
368
|
-
let t = e.target?.selector, n = t?.type === "html_tag" ? t.id : void 0, r = typeof n == "string" ? n : void 0, i =
|
|
369
|
-
if (r != null || i != null) return
|
|
370
|
-
},
|
|
371
|
-
let t =
|
|
365
|
+
}), r = Te(e);
|
|
366
|
+
if (n.length !== 0 || r.length !== 0) return Y([n, r]);
|
|
367
|
+
}, fe = (e) => {
|
|
368
|
+
let t = e.target?.selector, n = t?.type === "html_tag" ? t.id : void 0, r = typeof n == "string" ? n : void 0, i = de(e);
|
|
369
|
+
if (r != null || i != null) return ue(`${r ?? ""}|${i ?? ""}`);
|
|
370
|
+
}, pe = (e) => {
|
|
371
|
+
let t = he(e);
|
|
372
372
|
return e.flatMap((e, n) => {
|
|
373
373
|
let i = e.body?.selector;
|
|
374
374
|
if (i == null) return [];
|
|
375
375
|
let a = (Array.isArray(i) ? i : [i]).flatMap((e) => {
|
|
376
376
|
if (!r(e)) return [];
|
|
377
|
-
let t =
|
|
377
|
+
let t = J(e);
|
|
378
378
|
return t == null ? [] : [t];
|
|
379
379
|
});
|
|
380
380
|
return a.length === 0 ? [] : [{
|
|
381
381
|
id: t[n],
|
|
382
382
|
bboxes: a,
|
|
383
|
-
style:
|
|
383
|
+
style: se
|
|
384
384
|
}];
|
|
385
385
|
});
|
|
386
|
-
},
|
|
387
|
-
let t = e.map((e, t) =>
|
|
386
|
+
}, me = (e, t) => e.index == null ? fe(e) ?? String(t) : String(e.index), he = (e) => {
|
|
387
|
+
let t = e.map((e, t) => me(e, t)), n = new Set(t), r = /* @__PURE__ */ new Set();
|
|
388
388
|
return t.map((e) => {
|
|
389
389
|
if (!r.has(e)) return r.add(e), e;
|
|
390
390
|
let t = 1;
|
|
@@ -392,39 +392,39 @@ var A = {
|
|
|
392
392
|
let i = `${e}-${t}`;
|
|
393
393
|
return n.add(i), r.add(i), i;
|
|
394
394
|
});
|
|
395
|
-
},
|
|
395
|
+
}, ge = (e) => {
|
|
396
396
|
let t = e.body?.selector;
|
|
397
397
|
if (t == null) return;
|
|
398
398
|
let n = Array.isArray(t) ? t : [t];
|
|
399
399
|
for (let e of n) {
|
|
400
400
|
if (!r(e)) continue;
|
|
401
|
-
let t =
|
|
401
|
+
let t = J(e);
|
|
402
402
|
if (t != null) return t.page;
|
|
403
403
|
}
|
|
404
404
|
for (let e of n) {
|
|
405
|
-
let t =
|
|
405
|
+
let t = le(e);
|
|
406
406
|
if (t != null) return t;
|
|
407
407
|
}
|
|
408
|
-
},
|
|
408
|
+
}, _e = (e) => {
|
|
409
409
|
let t = e.custom_content?.annotations;
|
|
410
410
|
if (t?.length) return t.filter((e) => e != null && e.body?.source?.attachment?.url != null).map(a);
|
|
411
411
|
let n = e.custom_fields;
|
|
412
412
|
if (typeof n != "object" || !n) return [];
|
|
413
413
|
let r = n.annotations;
|
|
414
414
|
return !Array.isArray(r) || r.length === 0 ? [] : o(r, e.custom_content?.attachments ?? []).map(a);
|
|
415
|
-
},
|
|
415
|
+
}, ve = (e) => {
|
|
416
416
|
if (e.type !== "docx_text_range") return !1;
|
|
417
417
|
let t = e;
|
|
418
418
|
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";
|
|
419
|
-
},
|
|
419
|
+
}, ye = (e) => {
|
|
420
420
|
if (e.type !== "pptx_text_range") return !1;
|
|
421
421
|
let t = e;
|
|
422
422
|
return typeof t.slide == "number" && typeof t.shape_id == "string" && typeof t.start == "number" && typeof t.end == "number" && typeof t.text == "string";
|
|
423
|
-
},
|
|
423
|
+
}, be = (e) => typeof e == "object" && !!e && typeof e.row == "number" && typeof e.col == "number", xe = (e) => {
|
|
424
424
|
if (e.type !== "excel_rc_range") return !1;
|
|
425
425
|
let t = e;
|
|
426
|
-
return typeof t.sheet == "string" &&
|
|
427
|
-
},
|
|
426
|
+
return typeof t.sheet == "string" && be(t.start) && (t.end === void 0 || t.end === null || be(t.end));
|
|
427
|
+
}, Se = (e) => {
|
|
428
428
|
let { story: t, path: n, start: r, end: i, text: a } = e;
|
|
429
429
|
if (!(!n.every((e) => Number.isInteger(e)) || !Number.isInteger(r) || !Number.isInteger(i) || r < 0 || i < r)) return {
|
|
430
430
|
type: "docx_text_range",
|
|
@@ -434,7 +434,7 @@ var A = {
|
|
|
434
434
|
endExclusive: i,
|
|
435
435
|
text: a
|
|
436
436
|
};
|
|
437
|
-
},
|
|
437
|
+
}, Ce = (e) => {
|
|
438
438
|
let { slide: t, shape_id: n, start: r, end: i, text: a } = e;
|
|
439
439
|
if (!(!Number.isInteger(t) || t < 1 || !Number.isInteger(r) || !Number.isInteger(i) || r < 0 || i < r)) return {
|
|
440
440
|
type: "pptx_text_range",
|
|
@@ -444,7 +444,7 @@ var A = {
|
|
|
444
444
|
endExclusive: i,
|
|
445
445
|
text: a
|
|
446
446
|
};
|
|
447
|
-
},
|
|
447
|
+
}, we = (e) => {
|
|
448
448
|
let { sheet: t, start: n, end: r } = e;
|
|
449
449
|
if (!(t.length === 0 || !Number.isInteger(n.row) || !Number.isInteger(n.col) || n.row < 1 || n.col < 1)) {
|
|
450
450
|
if (r == null) return {
|
|
@@ -459,30 +459,30 @@ var A = {
|
|
|
459
459
|
end: r
|
|
460
460
|
};
|
|
461
461
|
}
|
|
462
|
-
},
|
|
462
|
+
}, Te = (e) => {
|
|
463
463
|
let t = e.body?.selector;
|
|
464
464
|
return t == null ? [] : (Array.isArray(t) ? t : [t]).flatMap((e) => {
|
|
465
465
|
if (!r(e)) return [];
|
|
466
|
-
if (
|
|
467
|
-
let t =
|
|
466
|
+
if (ve(e)) {
|
|
467
|
+
let t = Se(e);
|
|
468
468
|
return t ? [t] : [];
|
|
469
469
|
}
|
|
470
|
-
if (
|
|
471
|
-
let t =
|
|
470
|
+
if (ye(e)) {
|
|
471
|
+
let t = Ce(e);
|
|
472
472
|
return t ? [t] : [];
|
|
473
473
|
}
|
|
474
|
-
if (
|
|
475
|
-
let t =
|
|
474
|
+
if (xe(e)) {
|
|
475
|
+
let t = we(e);
|
|
476
476
|
return t ? [t] : [];
|
|
477
477
|
}
|
|
478
|
-
let t =
|
|
478
|
+
let t = oe(e);
|
|
479
479
|
return t ? [t] : [];
|
|
480
480
|
});
|
|
481
|
-
},
|
|
481
|
+
}, Ee = (e, t) => C(() => t ? [] : _e(e), [t, e]), De = {
|
|
482
482
|
openOwnerKey: null,
|
|
483
483
|
activeIndexByGroup: {}
|
|
484
|
-
},
|
|
485
|
-
let [e, t] =
|
|
484
|
+
}, Oe = () => {
|
|
485
|
+
let [e, t] = w(De), n = b((e) => {
|
|
486
486
|
t((t) => ({
|
|
487
487
|
...t,
|
|
488
488
|
openOwnerKey: e
|
|
@@ -501,7 +501,7 @@ var A = {
|
|
|
501
501
|
}
|
|
502
502
|
}));
|
|
503
503
|
}, []);
|
|
504
|
-
return
|
|
504
|
+
return C(() => ({
|
|
505
505
|
openPopup: n,
|
|
506
506
|
closePopup: r,
|
|
507
507
|
setActiveIndex: i,
|
|
@@ -513,7 +513,7 @@ var A = {
|
|
|
513
513
|
i,
|
|
514
514
|
e
|
|
515
515
|
]);
|
|
516
|
-
},
|
|
516
|
+
}, ke = /⟦C(\d+)⟧/g, Ae = (e, t) => {
|
|
517
517
|
let n = t.map((e, t) => ({
|
|
518
518
|
g: e,
|
|
519
519
|
idx: t
|
|
@@ -526,26 +526,26 @@ var A = {
|
|
|
526
526
|
}).sort((e, t) => t.pos - e.pos), r = e;
|
|
527
527
|
for (let { idx: e, pos: t } of n) r = `${r.slice(0, t)}⟦C${e}⟧${r.slice(t)}`;
|
|
528
528
|
return r;
|
|
529
|
-
},
|
|
529
|
+
}, je = /<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>/g, Me = /^<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>$/, Ne = /<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>|<\/?cit\b[^>]*>|<\/?cit\b[^>]*$/gi, Pe = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), X = (e) => e.replace(Ne, (e) => Me.test(e) ? e : Pe(e)), Z = (e) => X(e).replace(je, ""), Fe = (e, t) => e.includes("<cit") ? t ? Z(e) : X(e) : e, Ie = (e) => {
|
|
530
530
|
let t = e.primaryAnnotation.target?.selector;
|
|
531
531
|
return t?.type === "html_tag" ? t.id : void 0;
|
|
532
|
-
},
|
|
532
|
+
}, Q = (e, t = []) => {
|
|
533
533
|
let n = /* @__PURE__ */ new Map();
|
|
534
534
|
for (let r of [...t, ...e]) {
|
|
535
|
-
let e =
|
|
535
|
+
let e = Ie(r);
|
|
536
536
|
e != null && n.set(e, r);
|
|
537
537
|
}
|
|
538
538
|
return n;
|
|
539
|
-
},
|
|
539
|
+
}, Le = /<cit\s+data-id=(?:"([^"]+)"|'([^']+)')\s*>\s*<\/cit>/g, Re = (e) => e.replace(/[\\`*_[\]<>|]/g, "\\$&"), ze = (e, t, n = []) => {
|
|
540
540
|
if (!e.includes("<cit")) return e;
|
|
541
|
-
let r =
|
|
542
|
-
return r.size === 0 ? e : e.replace(
|
|
541
|
+
let r = Q(t, n);
|
|
542
|
+
return r.size === 0 ? e : e.replace(Le, (e, t, n) => {
|
|
543
543
|
let i = r.get(t ?? n ?? "");
|
|
544
|
-
return i ?
|
|
544
|
+
return i ? Re(i.sourceName) : e;
|
|
545
545
|
});
|
|
546
546
|
}, $ = (e, t) => {
|
|
547
547
|
if (typeof e == "string") {
|
|
548
|
-
let n = e.split(
|
|
548
|
+
let n = e.split(ke);
|
|
549
549
|
if (n.length === 1) return e;
|
|
550
550
|
let r = [];
|
|
551
551
|
return n.forEach((e, n) => {
|
|
@@ -556,47 +556,55 @@ var A = {
|
|
|
556
556
|
let n = $(e, t);
|
|
557
557
|
return Array.isArray(n) ? n : [n];
|
|
558
558
|
}) : e;
|
|
559
|
-
},
|
|
559
|
+
}, Be = (e, t) => /* @__PURE__ */ D(T, { children: [
|
|
560
560
|
e == null ? "<cit>" : `<cit data-id="${e}">`,
|
|
561
561
|
t,
|
|
562
562
|
"</cit>"
|
|
563
|
-
] }),
|
|
564
|
-
let {
|
|
563
|
+
] }), Ve = ({ onPreview: e, isPreviewable: t, onOpenInBrowser: n, isDownloadEnabled: r = !0, isPreviewOpen: i = !1, previewFilesOnMarkerClick: a = !1, buildLabels: o }) => (s) => {
|
|
564
|
+
let { cardLabels: c, markerLabels: l } = o(s);
|
|
565
|
+
return /* @__PURE__ */ E(q, {
|
|
566
|
+
group: s,
|
|
567
|
+
onPreview: (t) => e(t, s),
|
|
568
|
+
isPreviewable: t,
|
|
569
|
+
onOpenInBrowser: n,
|
|
570
|
+
isDownloadEnabled: r,
|
|
571
|
+
isPreviewOpen: i,
|
|
572
|
+
previewFilesOnMarkerClick: a,
|
|
573
|
+
cardLabels: c,
|
|
574
|
+
markerLabels: l
|
|
575
|
+
}, `citation-${s.groupKey}`);
|
|
576
|
+
}, He = {}, Ue = [], We = (e, t, n, r = !1, a = !1, o = Ue) => {
|
|
577
|
+
let { onPreview: s, isPreviewable: c, onOpenInBrowser: l, isDownloadEnabled: u = !0, isPreviewOpen: d = !1, previewFilesOnMarkerClick: f = !1, buildLabels: p } = n, m = C(() => r ? Z(e) : X(t.length > 0 ? Ae(e, t) : e), [
|
|
565
578
|
e,
|
|
566
579
|
t,
|
|
567
580
|
r
|
|
568
581
|
]), h = m.includes("<cit");
|
|
569
582
|
return {
|
|
570
583
|
processedContent: m,
|
|
571
|
-
markdownComponents:
|
|
572
|
-
let e =
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
previewFilesOnMarkerClick: f,
|
|
582
|
-
cardLabels: t,
|
|
583
|
-
markerLabels: n
|
|
584
|
-
}, `citation-${e.groupKey}`);
|
|
585
|
-
}, r = (e) => {
|
|
584
|
+
markdownComponents: C(() => {
|
|
585
|
+
let e = Q(t, o), n = Ve({
|
|
586
|
+
onPreview: s,
|
|
587
|
+
isPreviewable: c,
|
|
588
|
+
onOpenInBrowser: l,
|
|
589
|
+
isDownloadEnabled: u,
|
|
590
|
+
isPreviewOpen: d,
|
|
591
|
+
previewFilesOnMarkerClick: f,
|
|
592
|
+
buildLabels: p
|
|
593
|
+
}), r = (e) => {
|
|
586
594
|
let r = t[e];
|
|
587
595
|
return r ? n(r) : null;
|
|
588
596
|
}, m = { cit: (t) => {
|
|
589
597
|
let r = t["data-id"] == null ? void 0 : e.get(t["data-id"]);
|
|
590
|
-
return r ? n(r) :
|
|
598
|
+
return r ? n(r) : Be(t["data-id"], t.children);
|
|
591
599
|
} };
|
|
592
|
-
return t.length === 0 && o.length === 0 ? h ? m :
|
|
600
|
+
return t.length === 0 && o.length === 0 ? h ? m : He : {
|
|
593
601
|
...m,
|
|
594
|
-
p: ({ children: e, ...t }) => /* @__PURE__ */
|
|
602
|
+
p: ({ children: e, ...t }) => /* @__PURE__ */ E("p", {
|
|
595
603
|
...t,
|
|
596
604
|
className: i(a ? "dial-small-paragraph-text" : "dial-body-paragraph-text", "mb-3 [text-wrap:pretty] [overflow-wrap:anywhere] last:mb-0"),
|
|
597
605
|
children: $(e, r)
|
|
598
606
|
}),
|
|
599
|
-
li: ({ children: e, ...t }) => /* @__PURE__ */
|
|
607
|
+
li: ({ children: e, ...t }) => /* @__PURE__ */ E("li", {
|
|
600
608
|
...t,
|
|
601
609
|
className: "mb-1.5 last:mb-0",
|
|
602
610
|
children: $(e, r)
|
|
@@ -616,14 +624,41 @@ var A = {
|
|
|
616
624
|
h
|
|
617
625
|
])
|
|
618
626
|
};
|
|
619
|
-
},
|
|
620
|
-
let
|
|
627
|
+
}, Ge = [], Ke = (e, t, n = Ge) => {
|
|
628
|
+
let { onPreview: r, isPreviewable: i, onOpenInBrowser: a, isDownloadEnabled: o, isPreviewOpen: s, previewFilesOnMarkerClick: c, buildLabels: l } = t;
|
|
629
|
+
return C(() => {
|
|
630
|
+
let t = Q(e, n), u = Ve({
|
|
631
|
+
onPreview: r,
|
|
632
|
+
isPreviewable: i,
|
|
633
|
+
onOpenInBrowser: a,
|
|
634
|
+
isDownloadEnabled: o,
|
|
635
|
+
isPreviewOpen: s,
|
|
636
|
+
previewFilesOnMarkerClick: c,
|
|
637
|
+
buildLabels: l
|
|
638
|
+
});
|
|
639
|
+
return (e, n) => {
|
|
640
|
+
let r = e == null ? void 0 : t.get(e);
|
|
641
|
+
return r ? u(r) : Be(e, n);
|
|
642
|
+
};
|
|
643
|
+
}, [
|
|
644
|
+
e,
|
|
645
|
+
n,
|
|
646
|
+
r,
|
|
647
|
+
i,
|
|
648
|
+
a,
|
|
649
|
+
o,
|
|
650
|
+
s,
|
|
651
|
+
c,
|
|
652
|
+
l
|
|
653
|
+
]);
|
|
654
|
+
}, qe = (e) => e.url == null && e.reference_url != null, Je = /^(.*\.pdf)(?:#page=(\d+))?$/i, Ye = (e) => {
|
|
655
|
+
let t = Je.exec(e);
|
|
621
656
|
return t ? {
|
|
622
657
|
baseUrl: t[1],
|
|
623
658
|
page: t[2] == null ? null : Number(t[2])
|
|
624
659
|
} : null;
|
|
625
|
-
},
|
|
626
|
-
let n = t.reference_url, r =
|
|
660
|
+
}, Xe = (t) => I((t ?? []).filter(qe).map((t) => {
|
|
661
|
+
let n = t.reference_url, r = Ye(n) != null;
|
|
627
662
|
return { body: {
|
|
628
663
|
quote: t.data,
|
|
629
664
|
source: {
|
|
@@ -637,4 +672,4 @@ var A = {
|
|
|
637
672
|
} };
|
|
638
673
|
}));
|
|
639
674
|
//#endregion
|
|
640
|
-
export {
|
|
675
|
+
export { V as CitationCard, W as CitationCardProvider, q as CitationDropdown, H as CitationMarker, O as QUOTATIONS_CLASS, me as annotationHighlightId, he as annotationHighlightIds, Te as annotationToOfficeHighlightLocations, pe as annotationsToPdfHighlights, z as gatherSameSourceAnnotations, ge as getAnnotationPdfPage, Xe as getReferenceAttachmentGroups, R as groupAnnotations, L as groupAnnotationsByCitId, I as groupAnnotationsBySource, Ae as injectCitationSentinels, ve as isDocxRangeSelector, xe as isExcelRcRangeSelector, ye as isPptxRangeSelector, qe as isReferenceOnlyAttachment, Ye as parsePdfPageReference, Fe as prepareCitationContent, ze as replaceCitTagsWithSourceNames, $ as replaceSentinelsInChildren, _e as resolveMessageAnnotations, Z as stripCitTagsWhileStreaming, Ee as useAnnotations, Oe as useCitationCard, G as useCitationCardContext, We as useCitationMarkdownComponents, Ke as useCitationTagRenderer };
|
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.
|
|
4
|
+
"version": "1.3.0-dev.147",
|
|
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.
|
|
26
|
+
"@epam/ai-dial-chat-shared": "1.3.0-dev.147",
|
|
27
27
|
"@epam/ai-dial-ui-kit": "^0.16.0-dev.22"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
@@ -22,6 +22,13 @@ export declare const escapeUnsupportedCitTags: (content: string) => string;
|
|
|
22
22
|
* preventing an incomplete opening tag from swallowing the streamed suffix.
|
|
23
23
|
*/
|
|
24
24
|
export declare const stripCitTagsWhileStreaming: (content: string) => string;
|
|
25
|
+
/**
|
|
26
|
+
* Prepares markdown for a surface that renders `<cit>` elements but no
|
|
27
|
+
* offset-based markers (e.g. stage content): hides supported elements while
|
|
28
|
+
* streaming, otherwise escapes every unsupported `cit` shape. Unlike the
|
|
29
|
+
* message body's preparation, it never injects sentinels.
|
|
30
|
+
*/
|
|
31
|
+
export declare const prepareCitationContent: (content: string, isStreaming: boolean) => string;
|
|
25
32
|
/** Returns `html_tag` groups keyed by the `data-id` of the `<cit>` element they resolve; a message's own `groups` win over `fallbackGroups` on a colliding id. */
|
|
26
33
|
export declare const buildCitGroupsByTagId: (groups: AnnotationGroup[], fallbackGroups?: AnnotationGroup[]) => Map<string, AnnotationGroup>;
|
|
27
34
|
/**
|
|
@@ -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,kKAAkK;AAClK,eAAO,MAAM,qBAAqB,GAChC,QAAQ,eAAe,EAAE,EACzB,iBAAgB,eAAe,EAAO,KACrC,GAAG,CAAC,MAAM,EAAE,eAAe,CAQ7B,CAAC;AAUF;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,GACxC,SAAS,MAAM,EACf,QAAQ,eAAe,EAAE,EACzB,iBAAgB,eAAe,EAAO,KACrC,MAqBF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GACrC,UAAU,SAAS,EACnB,cAAc,CAAC,GAAG,EAAE,MAAM,KAAK,SAAS,KACvC,SA0BF,CAAC"}
|
|
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,iBAAgB,eAAe,EAAO,KACrC,GAAG,CAAC,MAAM,EAAE,eAAe,CAQ7B,CAAC;AAUF;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,GACxC,SAAS,MAAM,EACf,QAAQ,eAAe,EAAE,EACzB,iBAAgB,eAAe,EAAO,KACrC,MAqBF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GACrC,UAAU,SAAS,EACnB,cAAc,CAAC,GAAG,EAAE,MAAM,KAAK,SAAS,KACvC,SA0BF,CAAC"}
|