@epam/ai-dial-quotations 1.2.0-dev.99 → 1.3.0-dev.5
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/components/CitationCard/CitationCard.d.ts +21 -1
- package/components/CitationCard/CitationCard.d.ts.map +1 -1
- package/components/CitationDropdown/CitationDropdown.d.ts +5 -1
- package/components/CitationDropdown/CitationDropdown.d.ts.map +1 -1
- package/hooks/useCitationMarkdownComponents/useCitationMarkdownComponents.d.ts +11 -1
- package/hooks/useCitationMarkdownComponents/useCitationMarkdownComponents.d.ts.map +1 -1
- package/index.css +2 -2
- package/index.d.ts +2 -2
- package/index.d.ts.map +1 -1
- package/index.js +331 -230
- package/models/office-highlight.d.ts +2 -2
- package/package.json +3 -3
- package/utils/annotation.d.ts +24 -13
- package/utils/annotation.d.ts.map +1 -1
- package/utils/citation-injection.d.ts +9 -0
- package/utils/citation-injection.d.ts.map +1 -1
- package/utils/group-annotations-by-source.d.ts +3 -1
- package/utils/group-annotations-by-source.d.ts.map +1 -1
|
@@ -17,6 +17,20 @@ export interface CitationCardLabels {
|
|
|
17
17
|
openInBrowser: string;
|
|
18
18
|
/** Label for the "Download" button. */
|
|
19
19
|
download: string;
|
|
20
|
+
/** Label for the toggle that expands a quote cut off at the collapsed height. */
|
|
21
|
+
showMore: string;
|
|
22
|
+
/** Label for the toggle that collapses an expanded quote. */
|
|
23
|
+
showLess: string;
|
|
24
|
+
/** Accessible label for the copy button on a fenced code block inside the quote. Defaults to `'Copy code'`. */
|
|
25
|
+
codeBlockCopyLabel?: string;
|
|
26
|
+
/** Status announced after a fenced code block inside the quote has been copied. Defaults to `'Copied!'`. */
|
|
27
|
+
codeBlockCopiedLabel?: string;
|
|
28
|
+
/** Accessible label for the download button on a fenced code block inside the quote. Defaults to `'Download code'`. */
|
|
29
|
+
codeBlockDownloadLabel?: string;
|
|
30
|
+
/** Accessible label for a table's horizontally scrollable region inside the quote. Defaults to `'Scrollable table'`. */
|
|
31
|
+
tableScrollRegionAriaLabel?: string;
|
|
32
|
+
/** Accessible label for a block formula's horizontally scrollable region inside the quote. Defaults to `'Scrollable formula'`. */
|
|
33
|
+
mathScrollRegionAriaLabel?: string;
|
|
20
34
|
}
|
|
21
35
|
/** Color overrides for `CitationCard`, applied as CSS custom properties with app theme fallbacks. */
|
|
22
36
|
export interface CitationCardColors {
|
|
@@ -60,7 +74,13 @@ export interface CitationCardProps {
|
|
|
60
74
|
onPreview?: (annotation: Annotation) => void;
|
|
61
75
|
/** Called when the user clicks the "Open in browser"/"Download" button. */
|
|
62
76
|
onOpenInBrowser: (annotation: Annotation) => void;
|
|
63
|
-
/**
|
|
77
|
+
/** Whether a previewable file shows the "Download" button. Web links keep "Open in browser" regardless. Defaults to `true`. */
|
|
78
|
+
isDownloadEnabled?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Optional icon rendered before the header text (the file extension for a
|
|
81
|
+
* previewable file, otherwise the source name). When omitted, a previewable
|
|
82
|
+
* file gets the UI kit's `FileIcon` glyph for its extension.
|
|
83
|
+
*/
|
|
64
84
|
headerIcon?: ReactNode;
|
|
65
85
|
/** User-visible strings. */
|
|
66
86
|
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;
|
|
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,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,QAAQ,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;IACjB,+GAA+G;IAC/G,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,4GAA4G;IAC5G,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,uHAAuH;IACvH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,wHAAwH;IACxH,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,kIAAkI;IAClI,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACpC;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,2EAA2E;IAC3E,eAAe,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAClD,+HAA+H;IAC/H,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;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,CA4N9C,CAAC"}
|
|
@@ -16,6 +16,10 @@ export interface CitationDropdownProps {
|
|
|
16
16
|
isPreviewable?: (annotation: Annotation) => boolean;
|
|
17
17
|
/** Called when the user clicks "Open in browser" for an annotation. */
|
|
18
18
|
onOpenInBrowser: (annotation: Annotation) => void;
|
|
19
|
+
/** Whether the card shows the "Download" button for a previewable file. Defaults to `true`. */
|
|
20
|
+
isDownloadEnabled?: boolean;
|
|
21
|
+
/** Whether the host's preview panel is open; a marker click then previews the active annotation directly instead of showing the card. Defaults to `false`. */
|
|
22
|
+
isPreviewOpen?: boolean;
|
|
19
23
|
/** Optional icon rendered before the marker's label. */
|
|
20
24
|
icon?: ReactNode;
|
|
21
25
|
/** Optional icon rendered in the card header. When absent, no header icon is shown. */
|
|
@@ -29,6 +33,6 @@ export interface CitationDropdownProps {
|
|
|
29
33
|
/** Typography class forwarded to the marker's label text. Defaults to `'dial-caption-text'`. */
|
|
30
34
|
markerLabelClassName?: string;
|
|
31
35
|
}
|
|
32
|
-
/** Combines `CitationMarker` and `CitationCard` into a
|
|
36
|
+
/** Combines `CitationMarker` and `CitationCard` into a click-opened popover. Requires a `CitationCardProvider` ancestor. */
|
|
33
37
|
export declare const CitationDropdown: FC<CitationDropdownProps>;
|
|
34
38
|
//# sourceMappingURL=CitationDropdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CitationDropdown.d.ts","sourceRoot":"","sources":["../../../src/components/CitationDropdown/CitationDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAG5D,OAAO,EAAE,EAAE,EAAE,SAAS,EAA+B,MAAM,OAAO,CAAC;AAGnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,kCAAkC,CAAC;AAG1C,kDAAkD;AAClD,MAAM,WAAW,qBAAqB;IACpC,kEAAkE;IAClE,KAAK,EAAE,eAAe,CAAC;IACvB;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAC7C,qHAAqH;IACrH,aAAa,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,CAAC;IACpD,uEAAuE;IACvE,eAAe,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAClD,wDAAwD;IACxD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,uFAAuF;IACvF,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,+CAA+C;IAC/C,UAAU,EAAE,kBAAkB,CAAC;IAC/B,yDAAyD;IACzD,YAAY,EAAE,oBAAoB,CAAC;IACnC,2DAA2D;IAC3D,cAAc,CAAC,EAAE,sBAAsB,CAAC;IACxC,gGAAgG;IAChG,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,
|
|
1
|
+
{"version":3,"file":"CitationDropdown.d.ts","sourceRoot":"","sources":["../../../src/components/CitationDropdown/CitationDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAG5D,OAAO,EAAE,EAAE,EAAE,SAAS,EAA+B,MAAM,OAAO,CAAC;AAGnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,kCAAkC,CAAC;AAG1C,kDAAkD;AAClD,MAAM,WAAW,qBAAqB;IACpC,kEAAkE;IAClE,KAAK,EAAE,eAAe,CAAC;IACvB;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAC7C,qHAAqH;IACrH,aAAa,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,CAAC;IACpD,uEAAuE;IACvE,eAAe,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAClD,+FAA+F;IAC/F,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,8JAA8J;IAC9J,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,wDAAwD;IACxD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,uFAAuF;IACvF,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,+CAA+C;IAC/C,UAAU,EAAE,kBAAkB,CAAC;IAC/B,yDAAyD;IACzD,YAAY,EAAE,oBAAoB,CAAC;IACnC,2DAA2D;IAC3D,cAAc,CAAC,EAAE,sBAAsB,CAAC;IACxC,gGAAgG;IAChG,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,4HAA4H;AAC5H,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CA4GtD,CAAC"}
|
|
@@ -11,6 +11,10 @@ export interface UseCitationMarkdownComponentsCallbacks {
|
|
|
11
11
|
isPreviewable?(annotation: Annotation): boolean;
|
|
12
12
|
/** Called when a citation marker's open-in-browser action is invoked. */
|
|
13
13
|
onOpenInBrowser(annotation: Annotation): void;
|
|
14
|
+
/** Whether citation cards show the "Download" button for a previewable file. Defaults to `true`. */
|
|
15
|
+
isDownloadEnabled?: boolean;
|
|
16
|
+
/** Whether the host's preview panel is open; a marker click then previews directly instead of showing the card. Defaults to `false`. */
|
|
17
|
+
isPreviewOpen?: boolean;
|
|
14
18
|
/** Builds the translated label bundles used by a given citation group's card and marker. */
|
|
15
19
|
buildLabels(group: AnnotationGroup): {
|
|
16
20
|
cardLabels: CitationCardLabels;
|
|
@@ -42,8 +46,14 @@ export interface UseCitationMarkdownComponentsCallbacks {
|
|
|
42
46
|
* `isCompactTypography` drops the paragraph class one type-scale step, matching
|
|
43
47
|
* `COMPACT_MARKDOWN_CLASS_NAMES` so cited and uncited paragraphs stay the same
|
|
44
48
|
* size.
|
|
49
|
+
*
|
|
50
|
+
* `fallbackGroups` is an optional pool of groups that do not belong to this
|
|
51
|
+
* message, consulted only to resolve a `<cit data-id="…">` element the
|
|
52
|
+
* message's own `groups` do not cover. It never affects sentinel injection or
|
|
53
|
+
* `processedContent`, so a foreign group cannot shift a marker position in
|
|
54
|
+
* this message's text; a colliding id is always resolved from `groups`.
|
|
45
55
|
*/
|
|
46
|
-
export declare const useCitationMarkdownComponents: (content: string, groups: AnnotationGroup[], callbacks: UseCitationMarkdownComponentsCallbacks, isStreaming?: boolean, isCompactTypography?: boolean) => {
|
|
56
|
+
export declare const useCitationMarkdownComponents: (content: string, groups: AnnotationGroup[], callbacks: UseCitationMarkdownComponentsCallbacks, isStreaming?: boolean, isCompactTypography?: boolean, fallbackGroups?: AnnotationGroup[]) => {
|
|
47
57
|
processedContent: string;
|
|
48
58
|
markdownComponents: Components;
|
|
49
59
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCitationMarkdownComponents.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCitationMarkdownComponents/useCitationMarkdownComponents.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
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;AAErF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AAQ3F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAE/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,4FAA4F;IAC5F,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG;QACnC,UAAU,EAAE,kBAAkB,CAAC;QAC/B,YAAY,EAAE,oBAAoB,CAAC;KACpC,CAAC;CACH;AA0BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;CAwG5D,CAAC"}
|
package/index.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
._card_1kph1_1{background:var(--cc-card-bg,var(--bg-layer-raised,#fcfcfc))}._quote_1kph1_5{color:var(--cc-quote-text,var(--text-secondary,#57647a))}._title_1kph1_9{color:var(--cc-title-text,var(--text-primary,#161b2d))}._switcher_1kph1_13{color:var(--cc-switcher-text,var(--text-secondary,#57647a))}._sourceName_1kph1_17{color:var(--cc-source-name-text,var(--text-primary,#161b2d))}.
|
|
2
|
-
/*$vite$:1*/.visible{visibility:visible}.collapse{visibility:collapse}.fixed{position:fixed}.absolute{position:absolute}.mb-1
|
|
1
|
+
._card_1kph1_1{background:var(--cc-card-bg,var(--bg-layer-raised,#fcfcfc))}._quote_1kph1_5{color:var(--cc-quote-text,var(--text-secondary,#57647a))}._title_1kph1_9{color:var(--cc-title-text,var(--text-primary,#161b2d))}._switcher_1kph1_13{color:var(--cc-switcher-text,var(--text-secondary,#57647a))}._sourceName_1kph1_17{color:var(--cc-source-name-text,var(--text-primary,#161b2d))}td ._trigger_1ud83_1,th ._trigger_1ud83_1{max-width:100%;margin-inline-start:0}td ._trigger_1ud83_1>*,th ._trigger_1ud83_1>*{min-width:0;max-width:100%}
|
|
2
|
+
/*$vite$:1*/.visible{visibility:visible}.collapse{visibility:collapse}.fixed{position:fixed}.absolute{position:absolute}.mb-1\.5{margin-bottom:.375rem}.mb-3{margin-bottom:.75rem}.ms-1{margin-inline-start:.25rem}.line-clamp-6{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:6}.block{display:block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.table-cell{display:table-cell}.table-row{display:table-row}.hidden{display:none}.max-h-\[min\(20rem\2c 50vh\)\]{max-height:min(20rem,50vh)}.w-\[400px\]{width:400px}.w-full{width:100%}.min-w-0{min-width:0}.max-w-\[240px\]{max-width:240px}.max-w-full{max-width:100%}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.resize{resize:both}.flex-col{flex-direction:column}.items-start{align-items:flex-start}.items-center{align-items:center}.justify-start{justify-content:flex-start}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.break-words{overflow-wrap:break-word}.\!rounded-none{border-radius:0!important}.rounded-lg{border-radius:.5rem}.\!bg-transparent{background-color:transparent!important}.\!p-0{padding:0!important}.p-4{padding:1rem}.ps-\[1\.5em\]{padding-inline-start:1.5em}.align-middle{vertical-align:middle}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.\!shadow-none{--tw-shadow:0 0 #0000!important;--tw-shadow-colored:0 0 #0000!important;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)!important}.shadow-lg{--tw-shadow:0 8px 44px 0 var(--shadow-lg,#2764d914);--tw-shadow-colored:0 8px 44px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.\[overflow-wrap\:anywhere\]{overflow-wrap:anywhere}.\[text-wrap\:pretty\]{text-wrap:pretty}.last\:mb-0:last-child{margin-bottom:0}.rtl\:scale-x-\[-1\]:where([dir=rtl],[dir=rtl] *){--tw-scale-x:-1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}
|
package/index.d.ts
CHANGED
|
@@ -12,9 +12,9 @@ export { useCitationMarkdownComponents } from './hooks/useCitationMarkdownCompon
|
|
|
12
12
|
export type { UseCitationMarkdownComponentsCallbacks } from './hooks/useCitationMarkdownComponents/useCitationMarkdownComponents';
|
|
13
13
|
export { gatherSameSourceAnnotations, groupAnnotations, groupAnnotationsByCitId, groupAnnotationsBySource, } from './utils/group-annotations-by-source';
|
|
14
14
|
export type { AnnotationGroup } from './utils/group-annotations-by-source';
|
|
15
|
-
export { annotationHighlightId, annotationsToPdfHighlights, annotationToOfficeHighlightLocations, getAnnotationPdfPage, isDocxRangeSelector, isExcelRcRangeSelector, isPptxRangeSelector, resolveMessageAnnotations, } from './utils/annotation';
|
|
15
|
+
export { annotationHighlightId, annotationHighlightIds, annotationsToPdfHighlights, annotationToOfficeHighlightLocations, getAnnotationPdfPage, isDocxRangeSelector, isExcelRcRangeSelector, isPptxRangeSelector, resolveMessageAnnotations, } from './utils/annotation';
|
|
16
16
|
export type { DocxOfficeHighlightLocation, DocxTableRowOfficeHighlightLocation, ExcelOfficeHighlightLocation, OfficeHighlightLocation, PptxOfficeHighlightLocation, PptxTableRowOfficeHighlightLocation, } from './models/office-highlight';
|
|
17
|
-
export { injectCitationSentinels, replaceSentinelsInChildren, stripCitTagsWhileStreaming, } from './utils/citation-injection';
|
|
17
|
+
export { injectCitationSentinels, replaceCitTagsWithSourceNames, replaceSentinelsInChildren, stripCitTagsWhileStreaming, } from './utils/citation-injection';
|
|
18
18
|
export { isReferenceOnlyAttachment, parsePdfPageReference, getReferenceAttachmentGroups, } from './utils/reference-attachment';
|
|
19
19
|
export type { PdfPageReference } from './utils/reference-attachment';
|
|
20
20
|
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;AAGlI,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,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,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"}
|
|
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;AAGlI,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,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,155 +1,272 @@
|
|
|
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,
|
|
3
|
-
import { IconChevronLeft as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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
|
+
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
|
+
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 = (e) => {
|
|
12
|
+
try {
|
|
13
|
+
return decodeURIComponent(e);
|
|
14
|
+
} catch {
|
|
15
|
+
return e;
|
|
16
|
+
}
|
|
17
|
+
}, A = (e) => {
|
|
18
|
+
try {
|
|
19
|
+
let t = new URL(e);
|
|
20
|
+
return t.pathname.split("/").map((e) => k(e)).filter(Boolean).at(-1) ?? t.hostname;
|
|
21
|
+
} catch {
|
|
22
|
+
return e.split("/").map((e) => k(e)).filter(Boolean).at(-1) ?? e;
|
|
23
|
+
}
|
|
24
|
+
}, j = /\.([a-z0-9]{1,10})$/i, M = (e) => {
|
|
25
|
+
let t = e == null ? null : j.exec(e.trim());
|
|
26
|
+
return t == null ? void 0 : `.${t[1].toLowerCase()}`;
|
|
27
|
+
}, re = (e) => {
|
|
28
|
+
let t = e.body?.source?.attachment, n = t?.url;
|
|
29
|
+
return (n == null ? void 0 : M(A(n))) ?? M(t?.title);
|
|
30
|
+
}, N = (e, t) => e.body?.source?.attachment?.title ?? A(t), P = (e) => {
|
|
31
|
+
let t = e.target?.selector;
|
|
32
|
+
return t?.type === "html_tag" ? t : void 0;
|
|
33
|
+
}, F = (e) => P(e) != null, I = (e) => {
|
|
34
|
+
let t = /* @__PURE__ */ new Map();
|
|
35
|
+
for (let n of e) {
|
|
36
|
+
if (F(n)) continue;
|
|
37
|
+
let e = n.body?.source?.attachment?.url;
|
|
38
|
+
if (e == null) continue;
|
|
39
|
+
let r = t.get(e);
|
|
40
|
+
r ? r.annotations.push(n) : t.set(e, {
|
|
41
|
+
groupKey: e,
|
|
42
|
+
sourceUrl: e,
|
|
43
|
+
sourceName: N(n, e),
|
|
44
|
+
annotations: [n],
|
|
45
|
+
primaryAnnotation: n
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return Array.from(t.values());
|
|
49
|
+
}, L = (e) => {
|
|
50
|
+
let t = /* @__PURE__ */ new Map();
|
|
51
|
+
for (let n of e) {
|
|
52
|
+
let e = P(n)?.id;
|
|
53
|
+
if (e == null) continue;
|
|
54
|
+
let r = n.body?.source?.attachment?.url;
|
|
55
|
+
if (r == null) continue;
|
|
56
|
+
let i = t.get(e);
|
|
57
|
+
i ? i.annotations.push(n) : t.set(e, {
|
|
58
|
+
groupKey: `cit:${e}`,
|
|
59
|
+
sourceUrl: r,
|
|
60
|
+
sourceName: N(n, r),
|
|
61
|
+
annotations: [n],
|
|
62
|
+
primaryAnnotation: n
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return Array.from(t.values());
|
|
66
|
+
}, ie = (e) => [...L(e), ...I(e)], R = (e, t) => {
|
|
67
|
+
let n = e.body?.source?.attachment?.url;
|
|
68
|
+
return n == null || !t.includes(e) ? [e] : t.filter((e) => e.body?.source?.attachment?.url === n);
|
|
69
|
+
}, z = {
|
|
12
70
|
card: "_card_1kph1_1",
|
|
13
71
|
quote: "_quote_1kph1_5",
|
|
14
72
|
title: "_title_1kph1_9",
|
|
15
73
|
switcher: "_switcher_1kph1_13",
|
|
16
74
|
sourceName: "_sourceName_1kph1_17"
|
|
17
|
-
},
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
75
|
+
}, B = ({ group: r, activeIndex: a, onIndexChange: o, onPreview: l, onOpenInBrowser: h, isDownloadEnabled: y = !0, headerIcon: b, labels: x, typography: C, colors: T }) => {
|
|
76
|
+
let k = r.annotations.length, A = r.annotations[a] ?? r.primaryAnnotation, j = k > 1, M = A.body?.source?.attachment?.type, N = l == null || M === e.HTML || M === e.XHTML, P = N ? void 0 : re(A), F = P ?? r.sourceName, I = b ?? (P == null ? void 0 : /* @__PURE__ */ E(f, {
|
|
77
|
+
type: c.File,
|
|
78
|
+
name: P,
|
|
79
|
+
fileExtension: P,
|
|
80
|
+
size: 16,
|
|
81
|
+
decorative: !0,
|
|
82
|
+
className: "shrink-0"
|
|
83
|
+
})), L = C?.sourceNameClassName ?? "dial-tiny-text", ie = C?.titleClassName ?? "dial-body-semi-text", R = C?.quoteClassName ?? "dial-small-text", B = C?.quoteStrongClassName ?? "dial-small-semi-text", V = C?.switcherClassName ?? "dial-tiny-text", H = n({
|
|
84
|
+
"--cc-card-bg": T?.cardBackground,
|
|
85
|
+
"--cc-quote-text": T?.quoteText,
|
|
86
|
+
"--cc-title-text": T?.titleText,
|
|
87
|
+
"--cc-switcher-text": T?.switcherText,
|
|
88
|
+
"--cc-source-name-text": T?.sourceNameText
|
|
89
|
+
}), U = A.body?.quote, W = ee(), G = ne(null), [K, q] = w(!1), [J, Y] = w(!1);
|
|
90
|
+
return S(() => {
|
|
91
|
+
q(!1);
|
|
92
|
+
}, [a, U]), te(() => {
|
|
93
|
+
let e = G.current;
|
|
94
|
+
if (!e || K) return;
|
|
95
|
+
let t = () => Y(e.scrollHeight > e.clientHeight + 1);
|
|
96
|
+
t();
|
|
97
|
+
let n = new ResizeObserver(t);
|
|
98
|
+
return n.observe(e), () => n.disconnect();
|
|
99
|
+
}, [U, K]), /* @__PURE__ */ D("div", {
|
|
26
100
|
role: "dialog",
|
|
27
101
|
"aria-modal": "true",
|
|
28
|
-
"aria-label":
|
|
29
|
-
style:
|
|
30
|
-
className: i("flex w-[400px] flex-col gap-3 rounded-lg p-4 shadow-lg",
|
|
102
|
+
"aria-label": x.ariaLabel,
|
|
103
|
+
style: H,
|
|
104
|
+
className: i("flex w-[400px] max-w-full flex-col gap-3 rounded-lg p-4 shadow-lg", z.card, O.citationCard),
|
|
31
105
|
children: [
|
|
32
|
-
/* @__PURE__ */
|
|
106
|
+
/* @__PURE__ */ D("div", {
|
|
33
107
|
className: "flex items-center justify-between gap-2",
|
|
34
|
-
children: [/* @__PURE__ */
|
|
108
|
+
children: [/* @__PURE__ */ D("div", {
|
|
35
109
|
className: "flex min-w-0 items-center gap-1",
|
|
36
|
-
children: [
|
|
37
|
-
text:
|
|
38
|
-
className: i(
|
|
110
|
+
children: [I, /* @__PURE__ */ E(d, {
|
|
111
|
+
text: F,
|
|
112
|
+
className: i(L, "min-w-0", z.sourceName)
|
|
39
113
|
})]
|
|
40
|
-
}),
|
|
114
|
+
}), j && /* @__PURE__ */ D("div", {
|
|
41
115
|
className: "flex shrink-0 items-center gap-1",
|
|
42
116
|
children: [
|
|
43
|
-
/* @__PURE__ */
|
|
44
|
-
icon: /* @__PURE__ */ _
|
|
117
|
+
/* @__PURE__ */ E(p, {
|
|
118
|
+
icon: /* @__PURE__ */ E(_, {
|
|
45
119
|
size: 14,
|
|
46
120
|
className: "rtl:scale-x-[-1]",
|
|
47
121
|
stroke: s
|
|
48
122
|
}),
|
|
49
|
-
size:
|
|
50
|
-
"aria-label":
|
|
51
|
-
onClick: () => o((a - 1 +
|
|
123
|
+
size: u.Small,
|
|
124
|
+
"aria-label": x.previousCitation,
|
|
125
|
+
onClick: () => o((a - 1 + k) % k)
|
|
52
126
|
}),
|
|
53
|
-
/* @__PURE__ */
|
|
54
|
-
className: i(
|
|
55
|
-
children:
|
|
127
|
+
/* @__PURE__ */ E("span", {
|
|
128
|
+
className: i(V, z.switcher),
|
|
129
|
+
children: x.formatSwitcherText(a + 1, k)
|
|
56
130
|
}),
|
|
57
|
-
/* @__PURE__ */
|
|
58
|
-
icon: /* @__PURE__ */
|
|
131
|
+
/* @__PURE__ */ E(p, {
|
|
132
|
+
icon: /* @__PURE__ */ E(v, {
|
|
59
133
|
size: 14,
|
|
60
134
|
className: "rtl:scale-x-[-1]",
|
|
61
135
|
stroke: s
|
|
62
136
|
}),
|
|
63
|
-
size:
|
|
64
|
-
"aria-label":
|
|
65
|
-
onClick: () => o((a + 1) %
|
|
137
|
+
size: u.Small,
|
|
138
|
+
"aria-label": x.nextCitation,
|
|
139
|
+
onClick: () => o((a + 1) % k)
|
|
66
140
|
})
|
|
67
141
|
]
|
|
68
142
|
})]
|
|
69
143
|
}),
|
|
70
|
-
(
|
|
144
|
+
(A.body?.title || A.body?.quote || j) && /* @__PURE__ */ D("div", {
|
|
71
145
|
className: "flex flex-col gap-3",
|
|
72
|
-
children: [
|
|
73
|
-
className: i(
|
|
74
|
-
children:
|
|
75
|
-
}), (
|
|
76
|
-
className:
|
|
77
|
-
children:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
146
|
+
children: [A.body?.title && /* @__PURE__ */ E("p", {
|
|
147
|
+
className: i(ie, z.title, "break-words"),
|
|
148
|
+
children: A.body.title
|
|
149
|
+
}), (U || j) && /* @__PURE__ */ D("div", {
|
|
150
|
+
className: "flex flex-col items-start gap-1",
|
|
151
|
+
children: [/* @__PURE__ */ E("div", {
|
|
152
|
+
ref: G,
|
|
153
|
+
id: W,
|
|
154
|
+
tabIndex: K ? 0 : void 0,
|
|
155
|
+
className: i(R, z.quote, "w-full break-words", K ? "max-h-[min(20rem,50vh)] overflow-y-auto" : "line-clamp-6"),
|
|
156
|
+
children: U && /* @__PURE__ */ E(t, {
|
|
157
|
+
content: U,
|
|
158
|
+
classNames: {
|
|
159
|
+
p: i(R, z.quote),
|
|
160
|
+
ul: i(R, "ps-[1.5em]"),
|
|
161
|
+
ol: R,
|
|
162
|
+
strong: B
|
|
163
|
+
},
|
|
164
|
+
codeBlockCopyLabel: x.codeBlockCopyLabel,
|
|
165
|
+
codeBlockCopiedLabel: x.codeBlockCopiedLabel,
|
|
166
|
+
codeBlockDownloadLabel: x.codeBlockDownloadLabel,
|
|
167
|
+
tableScrollRegionAriaLabel: x.tableScrollRegionAriaLabel,
|
|
168
|
+
mathScrollRegionAriaLabel: x.mathScrollRegionAriaLabel
|
|
169
|
+
})
|
|
170
|
+
}), J && /* @__PURE__ */ E(m, {
|
|
171
|
+
label: K ? x.showLess : x.showMore,
|
|
172
|
+
size: u.Small,
|
|
173
|
+
"aria-expanded": K,
|
|
174
|
+
"aria-controls": W,
|
|
175
|
+
onClick: () => q((e) => !e)
|
|
176
|
+
})]
|
|
86
177
|
})]
|
|
87
178
|
}),
|
|
88
|
-
/* @__PURE__ */
|
|
179
|
+
/* @__PURE__ */ D("div", {
|
|
89
180
|
className: "flex justify-start gap-2",
|
|
90
|
-
children: [
|
|
91
|
-
label:
|
|
92
|
-
size:
|
|
93
|
-
onClick: () =>
|
|
94
|
-
}), /* @__PURE__ */
|
|
95
|
-
label:
|
|
96
|
-
size:
|
|
97
|
-
onClick: () =>
|
|
181
|
+
children: [l && /* @__PURE__ */ E(g, {
|
|
182
|
+
label: x.preview,
|
|
183
|
+
size: u.Small,
|
|
184
|
+
onClick: () => l(A)
|
|
185
|
+
}), (N || y) && /* @__PURE__ */ E(g, {
|
|
186
|
+
label: N ? x.openInBrowser : x.download,
|
|
187
|
+
size: u.Small,
|
|
188
|
+
onClick: () => h(A)
|
|
98
189
|
})]
|
|
99
190
|
})
|
|
100
191
|
]
|
|
101
192
|
});
|
|
102
|
-
},
|
|
103
|
-
size:
|
|
104
|
-
className: i("max-w-[240px]",
|
|
193
|
+
}, V = ({ annotationCount: e, onOpen: t, icon: n, labels: r, labelClassName: a = "dial-caption-text" }) => /* @__PURE__ */ E(h, {
|
|
194
|
+
size: u.Small,
|
|
195
|
+
className: i("max-w-[240px]", O.citationMarker),
|
|
105
196
|
textClassName: "min-w-0 truncate",
|
|
106
197
|
iconBefore: n,
|
|
107
|
-
label: /* @__PURE__ */
|
|
198
|
+
label: /* @__PURE__ */ E("span", {
|
|
108
199
|
className: a,
|
|
109
200
|
children: e > 1 ? r.labelWithOverflow : r.label
|
|
110
201
|
}),
|
|
111
202
|
"aria-label": r.ariaLabel,
|
|
112
203
|
onClick: t
|
|
113
|
-
}),
|
|
114
|
-
let e = x(
|
|
204
|
+
}), H = y(null), U = H.Provider, W = () => {
|
|
205
|
+
let e = x(H);
|
|
115
206
|
if (e == null) throw Error("useCitationCardContext must be used within a CitationCardProvider");
|
|
116
207
|
return e;
|
|
117
|
-
},
|
|
118
|
-
let
|
|
119
|
-
e ||
|
|
120
|
-
}, [
|
|
121
|
-
t(e),
|
|
208
|
+
}, G = { trigger: "_trigger_1ud83_1" }, K = ({ group: e, onPreview: t, isPreviewable: n, onOpenInBrowser: r, isDownloadEnabled: a = !0, isPreviewOpen: o = !1, icon: s, headerIcon: c, cardLabels: u, markerLabels: d, cardTypography: f, markerLabelClassName: p }) => {
|
|
209
|
+
let m = W(), h = ee(), g = m.isOpen(h), _ = m.getActiveIndex(e.groupKey), v = e.annotations[_] ?? e.primaryAnnotation, y = n?.(v) ?? !0, x = b((e) => {
|
|
210
|
+
e || m.closePopup(h);
|
|
211
|
+
}, [m, h]), S = C(() => t && y ? (e) => {
|
|
212
|
+
t(e), m.closePopup(h);
|
|
122
213
|
} : void 0, [
|
|
123
214
|
t,
|
|
215
|
+
y,
|
|
216
|
+
m,
|
|
217
|
+
h
|
|
218
|
+
]), te = b(() => {
|
|
219
|
+
if (o && S) {
|
|
220
|
+
S(v);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
m.openPopup(h);
|
|
224
|
+
}, [
|
|
225
|
+
o,
|
|
226
|
+
S,
|
|
124
227
|
v,
|
|
125
|
-
|
|
228
|
+
m,
|
|
229
|
+
h
|
|
230
|
+
]), ne = b(() => /* @__PURE__ */ E(B, {
|
|
231
|
+
group: e,
|
|
232
|
+
activeIndex: _,
|
|
233
|
+
onIndexChange: (t) => m.setActiveIndex(e.groupKey, t),
|
|
234
|
+
onPreview: S,
|
|
235
|
+
onOpenInBrowser: r,
|
|
236
|
+
isDownloadEnabled: a,
|
|
237
|
+
headerIcon: c,
|
|
238
|
+
labels: u,
|
|
239
|
+
typography: f
|
|
240
|
+
}), [
|
|
241
|
+
e,
|
|
242
|
+
_,
|
|
243
|
+
m,
|
|
244
|
+
S,
|
|
245
|
+
r,
|
|
246
|
+
a,
|
|
247
|
+
c,
|
|
248
|
+
u,
|
|
126
249
|
f
|
|
127
250
|
]);
|
|
128
|
-
return /* @__PURE__ */
|
|
129
|
-
open:
|
|
130
|
-
onOpenChange:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
onOpenInBrowser: r,
|
|
139
|
-
headerIcon: o,
|
|
140
|
-
labels: s,
|
|
141
|
-
typography: l
|
|
142
|
-
}),
|
|
143
|
-
children: /* @__PURE__ */ _(O, {
|
|
251
|
+
return /* @__PURE__ */ E(l, {
|
|
252
|
+
open: g,
|
|
253
|
+
onOpenChange: x,
|
|
254
|
+
trigger: [],
|
|
255
|
+
placement: "bottom-end",
|
|
256
|
+
matchReferenceWidth: !1,
|
|
257
|
+
className: i("ms-1 inline-flex align-middle", G.trigger),
|
|
258
|
+
listClassName: i("!p-0 !bg-transparent !shadow-none !rounded-none", O.citationDropdown),
|
|
259
|
+
renderOverlay: ne,
|
|
260
|
+
children: /* @__PURE__ */ E(V, {
|
|
144
261
|
sourceName: e.sourceName,
|
|
145
262
|
annotationCount: e.annotations.length,
|
|
146
|
-
onOpen:
|
|
147
|
-
icon:
|
|
148
|
-
labels:
|
|
149
|
-
labelClassName:
|
|
263
|
+
onOpen: te,
|
|
264
|
+
icon: s,
|
|
265
|
+
labels: d,
|
|
266
|
+
labelClassName: p
|
|
150
267
|
})
|
|
151
268
|
});
|
|
152
|
-
},
|
|
269
|
+
}, q = (e) => {
|
|
153
270
|
let t = e.trim();
|
|
154
271
|
if (!t.startsWith("|") || !t.endsWith("|") || /[\r\n]/.test(t)) return;
|
|
155
272
|
let n = [], r = "";
|
|
@@ -158,11 +275,11 @@ var T = {
|
|
|
158
275
|
i === "\\" && a != null && /[!-/:-@[-`{-~]/.test(a) ? (r += a, e += 1) : i === "|" ? (n.push(r.trim()), r = "") : r += i;
|
|
159
276
|
}
|
|
160
277
|
if (!(r !== "" || n.length < 2 || n.every((e) => e === "" || /^:?-{3,}:?$/.test(e)))) return n;
|
|
161
|
-
},
|
|
278
|
+
}, J = (e) => {
|
|
162
279
|
if (e.type !== "docx_text_anchor" && e.type !== "pptx_text_anchor") return;
|
|
163
280
|
let { text: t, occurrence: n, slide: r } = e;
|
|
164
281
|
if (typeof t != "string" || typeof n != "number" || !Number.isSafeInteger(n) || n < 1) return;
|
|
165
|
-
let i =
|
|
282
|
+
let i = q(t);
|
|
166
283
|
if (i != null) {
|
|
167
284
|
if (e.type === "docx_text_anchor") return {
|
|
168
285
|
type: "docx_text_anchor",
|
|
@@ -176,13 +293,13 @@ var T = {
|
|
|
176
293
|
slide: r
|
|
177
294
|
};
|
|
178
295
|
}
|
|
179
|
-
},
|
|
296
|
+
}, Y = {
|
|
180
297
|
backgroundColor: "transparent",
|
|
181
298
|
borderColor: "var(--stroke-accent, #1D4ED8)",
|
|
182
299
|
borderWidth: "2px",
|
|
183
300
|
opacity: .5,
|
|
184
301
|
hoverOpacity: .5
|
|
185
|
-
},
|
|
302
|
+
}, ae = (e) => {
|
|
186
303
|
if (typeof e != "object" || !e) return;
|
|
187
304
|
let t = e, { lt: n, wh: r } = t;
|
|
188
305
|
if (Array.isArray(n) && Array.isArray(r) && n.length >= 2 && r.length >= 2) {
|
|
@@ -201,7 +318,7 @@ var T = {
|
|
|
201
318
|
x2: i + o,
|
|
202
319
|
y2: a + s
|
|
203
320
|
};
|
|
204
|
-
},
|
|
321
|
+
}, X = (e) => {
|
|
205
322
|
if (!r(e)) return;
|
|
206
323
|
let t = e, n;
|
|
207
324
|
if (t.type === "pdf_bbox") {
|
|
@@ -212,7 +329,7 @@ var T = {
|
|
|
212
329
|
x2: i,
|
|
213
330
|
y2: a
|
|
214
331
|
});
|
|
215
|
-
} else t.type === "pdf_region" && (n =
|
|
332
|
+
} else t.type === "pdf_region" && (n = ae(t.bbox));
|
|
216
333
|
if (n == null) return;
|
|
217
334
|
let i = t.page;
|
|
218
335
|
if (!(typeof i != "number" || !Number.isInteger(i) || i < 1) && [
|
|
@@ -227,63 +344,85 @@ var T = {
|
|
|
227
344
|
x2: n.x2,
|
|
228
345
|
y2: n.y2
|
|
229
346
|
};
|
|
230
|
-
},
|
|
347
|
+
}, oe = (e) => {
|
|
348
|
+
if (!r(e)) return;
|
|
349
|
+
let t = e;
|
|
350
|
+
if (t.type !== "pdf_bbox" && t.type !== "pdf_region") return;
|
|
351
|
+
let n = t.page;
|
|
352
|
+
return typeof n == "number" && Number.isInteger(n) && n >= 1 ? n : void 0;
|
|
353
|
+
}, Z = (e) => typeof e != "object" || !e ? String(e) : Array.isArray(e) ? `[${e.map(Z).join(",")}]` : `{${Object.entries(e).filter(([, e]) => e !== void 0).sort(([e], [t]) => e < t ? -1 : +(e > t)).map(([e, t]) => `${e}=${Z(t)}`).join(",")}}`, se = (e) => {
|
|
231
354
|
let t = 5381;
|
|
232
355
|
for (let n = 0; n < e.length; n += 1) t = t * 33 + e.charCodeAt(n) | 0;
|
|
233
356
|
return (t >>> 0).toString(36);
|
|
234
|
-
},
|
|
357
|
+
}, ce = (e) => {
|
|
235
358
|
let t = e.body?.selector;
|
|
236
359
|
if (t == null) return;
|
|
237
360
|
let n = (Array.isArray(t) ? t : [t]).flatMap((e) => {
|
|
238
|
-
let t =
|
|
239
|
-
return t == null ? [] : [t];
|
|
240
|
-
}), r = U(e);
|
|
241
|
-
if (!(n.length === 0 && r.length === 0)) return I([n, r]);
|
|
242
|
-
}, ae = (e) => {
|
|
243
|
-
let t = e.target?.selector, n = t?.type === "html_tag" ? t.id : void 0, r = typeof n == "string" ? n : void 0, i = ie(e);
|
|
244
|
-
if (!(r == null && i == null)) return re(`${r ?? ""}|${i ?? ""}`);
|
|
245
|
-
}, oe = (e) => e.flatMap((e, t) => {
|
|
246
|
-
let n = e.body?.selector;
|
|
247
|
-
if (n == null) return [];
|
|
248
|
-
let i = (Array.isArray(n) ? n : [n]).flatMap((e) => {
|
|
249
|
-
if (!r(e)) return [];
|
|
250
|
-
let t = F(e);
|
|
361
|
+
let t = X(e);
|
|
251
362
|
return t == null ? [] : [t];
|
|
363
|
+
}), r = xe(e);
|
|
364
|
+
if (!(n.length === 0 && r.length === 0)) return Z([n, r]);
|
|
365
|
+
}, le = (e) => {
|
|
366
|
+
let t = e.target?.selector, n = t?.type === "html_tag" ? t.id : void 0, r = typeof n == "string" ? n : void 0, i = ce(e);
|
|
367
|
+
if (!(r == null && i == null)) return se(`${r ?? ""}|${i ?? ""}`);
|
|
368
|
+
}, ue = (e) => {
|
|
369
|
+
let t = fe(e);
|
|
370
|
+
return e.flatMap((e, n) => {
|
|
371
|
+
let i = e.body?.selector;
|
|
372
|
+
if (i == null) return [];
|
|
373
|
+
let a = (Array.isArray(i) ? i : [i]).flatMap((e) => {
|
|
374
|
+
if (!r(e)) return [];
|
|
375
|
+
let t = X(e);
|
|
376
|
+
return t == null ? [] : [t];
|
|
377
|
+
});
|
|
378
|
+
return a.length === 0 ? [] : [{
|
|
379
|
+
id: t[n],
|
|
380
|
+
bboxes: a,
|
|
381
|
+
style: Y
|
|
382
|
+
}];
|
|
383
|
+
});
|
|
384
|
+
}, de = (e, t) => e.index == null ? le(e) ?? String(t) : String(e.index), fe = (e) => {
|
|
385
|
+
let t = e.map((e, t) => de(e, t)), n = new Set(t), r = /* @__PURE__ */ new Set();
|
|
386
|
+
return t.map((e) => {
|
|
387
|
+
if (!r.has(e)) return r.add(e), e;
|
|
388
|
+
let t = 1;
|
|
389
|
+
for (; n.has(`${e}-${t}`);) t += 1;
|
|
390
|
+
let i = `${e}-${t}`;
|
|
391
|
+
return n.add(i), r.add(i), i;
|
|
252
392
|
});
|
|
253
|
-
|
|
254
|
-
id: L(e, t),
|
|
255
|
-
bboxes: i,
|
|
256
|
-
style: te
|
|
257
|
-
}];
|
|
258
|
-
}), L = (e, t) => e.index == null ? ae(e) ?? String(t) : String(e.index), se = (e) => {
|
|
393
|
+
}, pe = (e) => {
|
|
259
394
|
let t = e.body?.selector;
|
|
260
395
|
if (t == null) return;
|
|
261
396
|
let n = Array.isArray(t) ? t : [t];
|
|
262
397
|
for (let e of n) {
|
|
263
398
|
if (!r(e)) continue;
|
|
264
|
-
let t =
|
|
399
|
+
let t = X(e);
|
|
265
400
|
if (t != null) return t.page;
|
|
266
401
|
}
|
|
267
|
-
|
|
402
|
+
for (let e of n) {
|
|
403
|
+
let t = oe(e);
|
|
404
|
+
if (t != null) return t;
|
|
405
|
+
}
|
|
406
|
+
}, me = (e) => {
|
|
268
407
|
let t = e.custom_content?.annotations;
|
|
269
408
|
if (t?.length) return t.filter((e) => e != null && e.body?.source?.attachment?.url != null).map(a);
|
|
270
409
|
let n = e.custom_fields;
|
|
271
410
|
if (typeof n != "object" || !n) return [];
|
|
272
411
|
let r = n.annotations;
|
|
273
412
|
return !Array.isArray(r) || r.length === 0 ? [] : o(r, e.custom_content?.attachments ?? []).map(a);
|
|
274
|
-
},
|
|
413
|
+
}, he = (e) => {
|
|
275
414
|
if (e.type !== "docx_text_range") return !1;
|
|
276
415
|
let t = e;
|
|
277
416
|
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";
|
|
278
|
-
},
|
|
417
|
+
}, ge = (e) => {
|
|
279
418
|
if (e.type !== "pptx_text_range") return !1;
|
|
280
419
|
let t = e;
|
|
281
420
|
return typeof t.slide == "number" && typeof t.shape_id == "string" && typeof t.start == "number" && typeof t.end == "number" && typeof t.text == "string";
|
|
282
|
-
},
|
|
421
|
+
}, Q = (e) => typeof e == "object" && !!e && typeof e.row == "number" && typeof e.col == "number", _e = (e) => {
|
|
283
422
|
if (e.type !== "excel_rc_range") return !1;
|
|
284
423
|
let t = e;
|
|
285
|
-
return typeof t.sheet == "string" &&
|
|
286
|
-
},
|
|
424
|
+
return typeof t.sheet == "string" && Q(t.start) && (t.end === void 0 || t.end === null || Q(t.end));
|
|
425
|
+
}, ve = (e) => {
|
|
287
426
|
let { story: t, path: n, start: r, end: i, text: a } = e;
|
|
288
427
|
if (!(!n.every((e) => Number.isInteger(e)) || !Number.isInteger(r) || !Number.isInteger(i) || r < 0 || i < r)) return {
|
|
289
428
|
type: "docx_text_range",
|
|
@@ -293,7 +432,7 @@ var T = {
|
|
|
293
432
|
endExclusive: i,
|
|
294
433
|
text: a
|
|
295
434
|
};
|
|
296
|
-
},
|
|
435
|
+
}, ye = (e) => {
|
|
297
436
|
let { slide: t, shape_id: n, start: r, end: i, text: a } = e;
|
|
298
437
|
if (!(!Number.isInteger(t) || t < 1 || !Number.isInteger(r) || !Number.isInteger(i) || r < 0 || i < r)) return {
|
|
299
438
|
type: "pptx_text_range",
|
|
@@ -303,7 +442,7 @@ var T = {
|
|
|
303
442
|
endExclusive: i,
|
|
304
443
|
text: a
|
|
305
444
|
};
|
|
306
|
-
},
|
|
445
|
+
}, be = (e) => {
|
|
307
446
|
let { sheet: t, start: n, end: r } = e;
|
|
308
447
|
if (!(t.length === 0 || !Number.isInteger(n.row) || !Number.isInteger(n.col) || n.row < 1 || n.col < 1)) {
|
|
309
448
|
if (r == null) return {
|
|
@@ -318,30 +457,30 @@ var T = {
|
|
|
318
457
|
end: r
|
|
319
458
|
};
|
|
320
459
|
}
|
|
321
|
-
},
|
|
460
|
+
}, xe = (e) => {
|
|
322
461
|
let t = e.body?.selector;
|
|
323
462
|
return t == null ? [] : (Array.isArray(t) ? t : [t]).flatMap((e) => {
|
|
324
463
|
if (!r(e)) return [];
|
|
325
|
-
if (
|
|
326
|
-
let t =
|
|
464
|
+
if (he(e)) {
|
|
465
|
+
let t = ve(e);
|
|
327
466
|
return t ? [t] : [];
|
|
328
467
|
}
|
|
329
|
-
if (
|
|
330
|
-
let t =
|
|
468
|
+
if (ge(e)) {
|
|
469
|
+
let t = ye(e);
|
|
331
470
|
return t ? [t] : [];
|
|
332
471
|
}
|
|
333
|
-
if (
|
|
334
|
-
let t =
|
|
472
|
+
if (_e(e)) {
|
|
473
|
+
let t = be(e);
|
|
335
474
|
return t ? [t] : [];
|
|
336
475
|
}
|
|
337
|
-
let t =
|
|
476
|
+
let t = J(e);
|
|
338
477
|
return t ? [t] : [];
|
|
339
478
|
});
|
|
340
|
-
},
|
|
479
|
+
}, Se = (e, t) => C(() => t ? [] : me(e), [t, e]), Ce = {
|
|
341
480
|
openOwnerKey: null,
|
|
342
481
|
activeIndexByGroup: {}
|
|
343
|
-
},
|
|
344
|
-
let [e, t] = w(
|
|
482
|
+
}, we = () => {
|
|
483
|
+
let [e, t] = w(Ce), n = b((e) => {
|
|
345
484
|
t((t) => ({
|
|
346
485
|
...t,
|
|
347
486
|
openOwnerKey: e
|
|
@@ -372,7 +511,7 @@ var T = {
|
|
|
372
511
|
i,
|
|
373
512
|
e
|
|
374
513
|
]);
|
|
375
|
-
},
|
|
514
|
+
}, Te = /⟦C(\d+)⟧/g, Ee = (e, t) => {
|
|
376
515
|
let n = t.map((e, t) => ({
|
|
377
516
|
g: e,
|
|
378
517
|
idx: t
|
|
@@ -385,9 +524,26 @@ var T = {
|
|
|
385
524
|
}).sort((e, t) => t.pos - e.pos), r = e;
|
|
386
525
|
for (let { idx: e, pos: t } of n) r = `${r.slice(0, t)}⟦C${e}⟧${r.slice(t)}`;
|
|
387
526
|
return r;
|
|
388
|
-
},
|
|
527
|
+
}, De = /<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>/g, Oe = /^<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>$/, ke = /<cit\s+data-id=(?:"[^"]+"|'[^']+')\s*>\s*<\/cit>|<\/?cit\b[^>]*>|<\/?cit\b[^>]*$/gi, Ae = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), je = (e) => e.replace(ke, (e) => Oe.test(e) ? e : Ae(e)), Me = (e) => je(e).replace(De, ""), Ne = (e) => {
|
|
528
|
+
let t = e.primaryAnnotation.target?.selector;
|
|
529
|
+
return t?.type === "html_tag" ? t.id : void 0;
|
|
530
|
+
}, Pe = (e, t = []) => {
|
|
531
|
+
let n = /* @__PURE__ */ new Map();
|
|
532
|
+
for (let r of [...t, ...e]) {
|
|
533
|
+
let e = Ne(r);
|
|
534
|
+
e != null && n.set(e, r);
|
|
535
|
+
}
|
|
536
|
+
return n;
|
|
537
|
+
}, Fe = /<cit\s+data-id=(?:"([^"]+)"|'([^']+)')\s*>\s*<\/cit>/g, Ie = (e) => e.replace(/[\\`*_[\]<>|]/g, "\\$&"), Le = (e, t, n = []) => {
|
|
538
|
+
if (!e.includes("<cit")) return e;
|
|
539
|
+
let r = Pe(t, n);
|
|
540
|
+
return r.size === 0 ? e : e.replace(Fe, (e, t, n) => {
|
|
541
|
+
let i = r.get(t ?? n ?? "");
|
|
542
|
+
return i ? Ie(i.sourceName) : e;
|
|
543
|
+
});
|
|
544
|
+
}, $ = (e, t) => {
|
|
389
545
|
if (typeof e == "string") {
|
|
390
|
-
let n = e.split(
|
|
546
|
+
let n = e.split(Te);
|
|
391
547
|
if (n.length === 1) return e;
|
|
392
548
|
let r = [];
|
|
393
549
|
return n.forEach((e, n) => {
|
|
@@ -395,58 +551,52 @@ var T = {
|
|
|
395
551
|
}), r;
|
|
396
552
|
}
|
|
397
553
|
return Array.isArray(e) ? e.flatMap((e) => {
|
|
398
|
-
let n =
|
|
554
|
+
let n = $(e, t);
|
|
399
555
|
return Array.isArray(n) ? n : [n];
|
|
400
556
|
}) : e;
|
|
401
|
-
},
|
|
402
|
-
let t = e.primaryAnnotation.target?.selector;
|
|
403
|
-
return t?.type === "html_tag" ? t.id : void 0;
|
|
404
|
-
}, be = (e, t) => /* @__PURE__ */ v(g, { children: [
|
|
557
|
+
}, Re = {}, ze = [], Be = (e, t) => /* @__PURE__ */ D(T, { children: [
|
|
405
558
|
e == null ? "<cit>" : `<cit data-id="${e}">`,
|
|
406
559
|
t,
|
|
407
560
|
"</cit>"
|
|
408
|
-
] }),
|
|
409
|
-
let { onPreview:
|
|
561
|
+
] }), Ve = (e, t, n, r = !1, a = !1, o = ze) => {
|
|
562
|
+
let { onPreview: s, isPreviewable: c, onOpenInBrowser: l, isDownloadEnabled: u = !0, isPreviewOpen: d = !1, buildLabels: f } = n, p = C(() => r ? Me(e) : je(t.length > 0 ? Ee(e, t) : e), [
|
|
410
563
|
e,
|
|
411
564
|
t,
|
|
412
565
|
r
|
|
413
|
-
]),
|
|
566
|
+
]), m = p.includes("<cit");
|
|
414
567
|
return {
|
|
415
|
-
processedContent:
|
|
568
|
+
processedContent: p,
|
|
416
569
|
markdownComponents: C(() => {
|
|
417
|
-
let e =
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
t != null && e.set(t, n);
|
|
421
|
-
}
|
|
422
|
-
let n = (e) => {
|
|
423
|
-
let { cardLabels: t, markerLabels: n } = l(e);
|
|
424
|
-
return /* @__PURE__ */ _(N, {
|
|
570
|
+
let e = Pe(t, o), n = (e) => {
|
|
571
|
+
let { cardLabels: t, markerLabels: n } = f(e);
|
|
572
|
+
return /* @__PURE__ */ E(K, {
|
|
425
573
|
group: e,
|
|
426
|
-
onPreview: (t) =>
|
|
427
|
-
isPreviewable:
|
|
428
|
-
onOpenInBrowser:
|
|
574
|
+
onPreview: (t) => s(t, e),
|
|
575
|
+
isPreviewable: c,
|
|
576
|
+
onOpenInBrowser: l,
|
|
577
|
+
isDownloadEnabled: u,
|
|
578
|
+
isPreviewOpen: d,
|
|
429
579
|
cardLabels: t,
|
|
430
580
|
markerLabels: n
|
|
431
581
|
}, `citation-${e.groupKey}`);
|
|
432
582
|
}, r = (e) => {
|
|
433
583
|
let r = t[e];
|
|
434
584
|
return r ? n(r) : null;
|
|
435
|
-
},
|
|
585
|
+
}, p = { cit: (t) => {
|
|
436
586
|
let r = t["data-id"] == null ? void 0 : e.get(t["data-id"]);
|
|
437
|
-
return r ? n(r) :
|
|
587
|
+
return r ? n(r) : Be(t["data-id"], t.children);
|
|
438
588
|
} };
|
|
439
|
-
return t.length === 0 ?
|
|
440
|
-
...
|
|
441
|
-
p: ({ children: e, ...t }) => /* @__PURE__ */
|
|
589
|
+
return t.length === 0 && o.length === 0 ? m ? p : Re : {
|
|
590
|
+
...p,
|
|
591
|
+
p: ({ children: e, ...t }) => /* @__PURE__ */ E("p", {
|
|
442
592
|
...t,
|
|
443
593
|
className: i(a ? "dial-small-paragraph-text" : "dial-body-paragraph-text", "mb-3 [overflow-wrap:anywhere] [text-wrap:pretty] last:mb-0"),
|
|
444
|
-
children:
|
|
594
|
+
children: $(e, r)
|
|
445
595
|
}),
|
|
446
|
-
li: ({ children: e, ...t }) => /* @__PURE__ */
|
|
596
|
+
li: ({ children: e, ...t }) => /* @__PURE__ */ E("li", {
|
|
447
597
|
...t,
|
|
448
598
|
className: "mb-1.5 last:mb-0",
|
|
449
|
-
children:
|
|
599
|
+
children: $(e, r)
|
|
450
600
|
})
|
|
451
601
|
};
|
|
452
602
|
}, [
|
|
@@ -455,70 +605,21 @@ var T = {
|
|
|
455
605
|
s,
|
|
456
606
|
c,
|
|
457
607
|
l,
|
|
608
|
+
u,
|
|
609
|
+
d,
|
|
610
|
+
f,
|
|
458
611
|
a,
|
|
459
|
-
|
|
612
|
+
m
|
|
460
613
|
])
|
|
461
614
|
};
|
|
462
|
-
},
|
|
463
|
-
|
|
464
|
-
return decodeURIComponent(e);
|
|
465
|
-
} catch {
|
|
466
|
-
return e;
|
|
467
|
-
}
|
|
468
|
-
}, Se = (e) => {
|
|
469
|
-
try {
|
|
470
|
-
let t = new URL(e);
|
|
471
|
-
return t.pathname.split("/").map((e) => J(e)).filter(Boolean).at(-1) ?? t.hostname;
|
|
472
|
-
} catch {
|
|
473
|
-
return e.split("/").map((e) => J(e)).filter(Boolean).at(-1) ?? e;
|
|
474
|
-
}
|
|
475
|
-
}, Y = (e, t) => e.body?.source?.attachment?.title ?? Se(t), X = (e) => {
|
|
476
|
-
let t = e.target?.selector;
|
|
477
|
-
return t?.type === "html_tag" ? t : void 0;
|
|
478
|
-
}, Ce = (e) => X(e) != null, Z = (e) => {
|
|
479
|
-
let t = /* @__PURE__ */ new Map();
|
|
480
|
-
for (let n of e) {
|
|
481
|
-
if (Ce(n)) continue;
|
|
482
|
-
let e = n.body?.source?.attachment?.url;
|
|
483
|
-
if (e == null) continue;
|
|
484
|
-
let r = t.get(e);
|
|
485
|
-
r ? r.annotations.push(n) : t.set(e, {
|
|
486
|
-
groupKey: e,
|
|
487
|
-
sourceUrl: e,
|
|
488
|
-
sourceName: Y(n, e),
|
|
489
|
-
annotations: [n],
|
|
490
|
-
primaryAnnotation: n
|
|
491
|
-
});
|
|
492
|
-
}
|
|
493
|
-
return Array.from(t.values());
|
|
494
|
-
}, Q = (e) => {
|
|
495
|
-
let t = /* @__PURE__ */ new Map();
|
|
496
|
-
for (let n of e) {
|
|
497
|
-
let e = X(n)?.id;
|
|
498
|
-
if (e == null) continue;
|
|
499
|
-
let r = n.body?.source?.attachment?.url;
|
|
500
|
-
if (r == null) continue;
|
|
501
|
-
let i = t.get(e);
|
|
502
|
-
i ? i.annotations.push(n) : t.set(e, {
|
|
503
|
-
groupKey: `cit:${e}`,
|
|
504
|
-
sourceUrl: r,
|
|
505
|
-
sourceName: Y(n, r),
|
|
506
|
-
annotations: [n],
|
|
507
|
-
primaryAnnotation: n
|
|
508
|
-
});
|
|
509
|
-
}
|
|
510
|
-
return Array.from(t.values());
|
|
511
|
-
}, we = (e) => [...Q(e), ...Z(e)], Te = (e, t) => {
|
|
512
|
-
let n = e.body?.source?.attachment?.url;
|
|
513
|
-
return n == null || !t.includes(e) ? [e] : t.filter((e) => e.body?.source?.attachment?.url === n);
|
|
514
|
-
}, Ee = (e) => e.url == null && e.reference_url != null, De = /^(.*\.pdf)(?:#page=(\d+))?$/i, $ = (e) => {
|
|
515
|
-
let t = De.exec(e);
|
|
615
|
+
}, He = (e) => e.url == null && e.reference_url != null, Ue = /^(.*\.pdf)(?:#page=(\d+))?$/i, We = (e) => {
|
|
616
|
+
let t = Ue.exec(e);
|
|
516
617
|
return t ? {
|
|
517
618
|
baseUrl: t[1],
|
|
518
619
|
page: t[2] == null ? null : Number(t[2])
|
|
519
620
|
} : null;
|
|
520
|
-
},
|
|
521
|
-
let n = t.reference_url, r =
|
|
621
|
+
}, Ge = (t) => I((t ?? []).filter(He).map((t) => {
|
|
622
|
+
let n = t.reference_url, r = We(n) != null;
|
|
522
623
|
return { body: {
|
|
523
624
|
quote: t.data,
|
|
524
625
|
source: {
|
|
@@ -532,4 +633,4 @@ var T = {
|
|
|
532
633
|
} };
|
|
533
634
|
}));
|
|
534
635
|
//#endregion
|
|
535
|
-
export {
|
|
636
|
+
export { B as CitationCard, U as CitationCardProvider, K as CitationDropdown, V as CitationMarker, O as QUOTATIONS_CLASS, de as annotationHighlightId, fe as annotationHighlightIds, xe as annotationToOfficeHighlightLocations, ue as annotationsToPdfHighlights, R as gatherSameSourceAnnotations, pe as getAnnotationPdfPage, Ge as getReferenceAttachmentGroups, ie as groupAnnotations, L as groupAnnotationsByCitId, I as groupAnnotationsBySource, Ee as injectCitationSentinels, he as isDocxRangeSelector, _e as isExcelRcRangeSelector, ge as isPptxRangeSelector, He as isReferenceOnlyAttachment, We as parsePdfPageReference, Le as replaceCitTagsWithSourceNames, $ as replaceSentinelsInChildren, me as resolveMessageAnnotations, Me as stripCitTagsWhileStreaming, Se as useAnnotations, we as useCitationCard, W as useCitationCardContext, Ve as useCitationMarkdownComponents };
|
|
@@ -3,7 +3,7 @@ import { ExcelCellAddress } from '@epam/ai-dial-chat-shared';
|
|
|
3
3
|
* A validated, normalised DOCX character-range location. `endExclusive` is
|
|
4
4
|
* the wire's `end` copied through unchanged — confirmed exclusive on the
|
|
5
5
|
* wire, unlike `TextCharacterRangeSelector`'s inclusive `end` (see the
|
|
6
|
-
* `annotation.ts` normaliser and `design.md` D3 for the evidence).
|
|
6
|
+
* `annotation.ts` normaliser and `openspec/changes/archive/2026-09-10-highlight-office-document-annotations/design.md` D3 for the evidence).
|
|
7
7
|
*/
|
|
8
8
|
export interface DocxOfficeHighlightLocation {
|
|
9
9
|
/** Discriminates this location within `OfficeHighlightLocation`. Mirrors the wire selector's `type`. */
|
|
@@ -22,7 +22,7 @@ export interface DocxOfficeHighlightLocation {
|
|
|
22
22
|
/**
|
|
23
23
|
* A validated, normalised PPTX character-range location. `endExclusive` is
|
|
24
24
|
* the wire's `end` copied through unchanged — confirmed exclusive on the
|
|
25
|
-
* wire (see `design.md` D3).
|
|
25
|
+
* wire (see `openspec/changes/archive/2026-09-10-highlight-office-document-annotations/design.md` D3).
|
|
26
26
|
*/
|
|
27
27
|
export interface PptxOfficeHighlightLocation {
|
|
28
28
|
/** Discriminates this location within `OfficeHighlightLocation`. Mirrors the wire selector's `type`. */
|
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.
|
|
4
|
+
"version": "1.3.0-dev.5",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"react": "^19.2.8",
|
|
26
|
-
"@epam/ai-dial-chat-shared": "1.
|
|
27
|
-
"@epam/ai-dial-ui-kit": "^0.15.0
|
|
26
|
+
"@epam/ai-dial-chat-shared": "1.3.0-dev.5",
|
|
27
|
+
"@epam/ai-dial-ui-kit": "^0.15.0"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|
package/utils/annotation.d.ts
CHANGED
|
@@ -5,19 +5,21 @@ import { OfficeHighlightLocation } from '../models/office-highlight';
|
|
|
5
5
|
* Maps a list of annotations to `InputHighlightData` entries for the PDF viewer.
|
|
6
6
|
* Recognizes `pdf_bbox` selectors and both `pdf_region` coordinate forms
|
|
7
7
|
* (`lt`/`wh` and legacy `left`/`top`/`width`/`height`); annotations whose
|
|
8
|
-
* `body.selector` contains none of these are skipped.
|
|
9
|
-
* from `
|
|
10
|
-
*
|
|
8
|
+
* `body.selector` contains none of these are skipped. Each highlight `id` is
|
|
9
|
+
* the entry's id from `annotationHighlightIds(annotations)`, unique within
|
|
10
|
+
* this input list.
|
|
11
11
|
*/
|
|
12
12
|
export declare const annotationsToPdfHighlights: (annotations: Annotation[]) => InputHighlightData[];
|
|
13
13
|
/**
|
|
14
|
-
* Returns a stable string ID for a given annotation
|
|
15
|
-
* `
|
|
16
|
-
*
|
|
14
|
+
* Returns a stable string ID for a given annotation — the id
|
|
15
|
+
* `annotationHighlightIds` (and so `annotationsToPdfHighlights` and the Office
|
|
16
|
+
* highlight path) assigns it whenever no earlier entry of the same list
|
|
17
|
+
* already holds that id.
|
|
17
18
|
*
|
|
18
19
|
* Resolved in order:
|
|
19
|
-
* 1. `annotation.index` when the wire supplied one —
|
|
20
|
-
*
|
|
20
|
+
* 1. `annotation.index` when the wire supplied one — short, but not guaranteed
|
|
21
|
+
* unique: a payload may repeat an `index`, which `annotationHighlightIds`
|
|
22
|
+
* disambiguates.
|
|
21
23
|
* 2. Otherwise an id derived from the annotation's own identity: its `cit` tag
|
|
22
24
|
* id plus a digest of its selectors. Two annotations differing in either
|
|
23
25
|
* part get different ids; two agreeing in both describe the same cited
|
|
@@ -30,15 +32,24 @@ export declare const annotationsToPdfHighlights: (annotations: Annotation[]) =>
|
|
|
30
32
|
* unique beyond the list it came from, which is why it is the last resort — a
|
|
31
33
|
* caller gathering one citation group at a time would otherwise give every
|
|
32
34
|
* single-annotation group the same id, and the canvas could not tell two
|
|
33
|
-
* citations of one document apart (
|
|
35
|
+
* citations of one document apart ([#8907](https://github.com/epam/ai-dial-chat/issues/8907)). Ids are never persisted and
|
|
34
36
|
* never sent over the wire.
|
|
35
37
|
*/
|
|
36
38
|
export declare const annotationHighlightId: (annotation: Annotation, fallbackIndex: number) => string;
|
|
37
39
|
/**
|
|
38
|
-
* Returns
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
|
|
40
|
+
* Returns one highlight id per entry of `annotations`, unique within the list:
|
|
41
|
+
* the entry's `annotationHighlightId` when no earlier entry holds it, otherwise
|
|
42
|
+
* that id with a `-<n>` suffix no other entry's id uses.
|
|
43
|
+
*/
|
|
44
|
+
export declare const annotationHighlightIds: (annotations: Annotation[]) => string[];
|
|
45
|
+
/**
|
|
46
|
+
* Returns the PDF page to open for the annotation, or `undefined` when none
|
|
47
|
+
* exists. Recognizes `pdf_bbox` selectors and both `pdf_region` coordinate
|
|
48
|
+
* forms. The first selector whose geometry validates wins (see
|
|
49
|
+
* `readPdfSelectorBox`), so the page matches the selected highlight; when no
|
|
50
|
+
* selector has valid geometry, the first `pdf_bbox`/`pdf_region` selector
|
|
51
|
+
* with a positive integer `page` is used, so a page-only selector still
|
|
52
|
+
* navigates without a highlight.
|
|
42
53
|
*/
|
|
43
54
|
export declare const getAnnotationPdfPage: (annotation: Annotation) => number | undefined;
|
|
44
55
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotation.d.ts","sourceRoot":"","sources":["../../src/utils/annotation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,OAAO,EACP,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAMnC,OAAO,KAAK,EAGV,kBAAkB,EACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"annotation.d.ts","sourceRoot":"","sources":["../../src/utils/annotation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,OAAO,EACP,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAMnC,OAAO,KAAK,EAGV,kBAAkB,EACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAmM1E;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,GACrC,aAAa,UAAU,EAAE,KACxB,kBAAkB,EAsBpB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,qBAAqB,GAChC,YAAY,UAAU,EACtB,eAAe,MAAM,KACpB,MAG+D,CAAC;AAEnE;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAAI,aAAa,UAAU,EAAE,KAAG,MAAM,EAqBxE,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,GAC/B,YAAY,UAAU,KACrB,MAAM,GAAG,SAeX,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,GAAI,SAAS,OAAO,KAAG,UAAU,EAoBtE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAC9B,UAAU,kBAAkB,KAC3B,QAAQ,IAAI,iBAWd,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAC9B,UAAU,kBAAkB,KAC3B,QAAQ,IAAI,iBAUd,CAAC;AAUF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GACjC,UAAU,kBAAkB,KAC3B,QAAQ,IAAI,oBAQd,CAAC;AA8FF;;;;GAIG;AACH,eAAO,MAAM,oCAAoC,GAC/C,YAAY,UAAU,KACrB,uBAAuB,EAuBzB,CAAC"}
|
|
@@ -22,6 +22,15 @@ 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
|
+
/** 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
|
+
export declare const buildCitGroupsByTagId: (groups: AnnotationGroup[], fallbackGroups?: AnnotationGroup[]) => Map<string, AnnotationGroup>;
|
|
27
|
+
/**
|
|
28
|
+
* Returns `content` with every supported `<cit data-id="…"></cit>` element
|
|
29
|
+
* that resolves to a group replaced by that group's `sourceName` as plain
|
|
30
|
+
* Markdown text — the label its citation marker shows on screen. Unresolved
|
|
31
|
+
* tags are left untouched.
|
|
32
|
+
*/
|
|
33
|
+
export declare const replaceCitTagsWithSourceNames: (content: string, groups: AnnotationGroup[], fallbackGroups?: AnnotationGroup[]) => string;
|
|
25
34
|
/**
|
|
26
35
|
* Recursively walks a React child tree and replaces sentinel strings with
|
|
27
36
|
* 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":"
|
|
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"}
|
|
@@ -8,7 +8,7 @@ export interface AnnotationGroup {
|
|
|
8
8
|
* cit ids citing the same document never share popup state.
|
|
9
9
|
*/
|
|
10
10
|
groupKey: string;
|
|
11
|
-
/** The cited attachment's URL — used for Preview/
|
|
11
|
+
/** The cited attachment's URL — used for Preview/Open in browser. */
|
|
12
12
|
sourceUrl: string;
|
|
13
13
|
/**
|
|
14
14
|
* Human-readable name derived from the URL: the last non-empty path segment
|
|
@@ -20,6 +20,8 @@ export interface AnnotationGroup {
|
|
|
20
20
|
/** The first annotation in the group — used for the inline citation marker position. */
|
|
21
21
|
primaryAnnotation: Annotation;
|
|
22
22
|
}
|
|
23
|
+
/** Returns the cited file's extension with a leading dot (e.g. `'.pdf'`), read from its URL and then its title, or `undefined` when neither carries one. */
|
|
24
|
+
export declare const getSourceFileExtension: (annotation: Annotation) => string | undefined;
|
|
23
25
|
/**
|
|
24
26
|
* Groups annotations by their source attachment URL. Annotations without a
|
|
25
27
|
* `body.source.attachment.url` are excluded, as are `html_tag`-selector
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-annotations-by-source.d.ts","sourceRoot":"","sources":["../../src/utils/group-annotations-by-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAmB,MAAM,2BAA2B,CAAC;AAE7E,uEAAuE;AACvE,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,
|
|
1
|
+
{"version":3,"file":"group-annotations-by-source.d.ts","sourceRoot":"","sources":["../../src/utils/group-annotations-by-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAmB,MAAM,2BAA2B,CAAC;AAE7E,uEAAuE;AACvE,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,wFAAwF;IACxF,iBAAiB,EAAE,UAAU,CAAC;CAC/B;AAkCD,4JAA4J;AAC5J,eAAO,MAAM,sBAAsB,GACjC,YAAY,UAAU,KACrB,MAAM,GAAG,SAOX,CAAC;AAyBF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GACnC,aAAa,UAAU,EAAE,KACxB,eAAe,EAuBjB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAClC,aAAa,UAAU,EAAE,KACxB,eAAe,EAwBjB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAC3B,aAAa,UAAU,EAAE,KACxB,eAAe,EAGjB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,GACtC,SAAS,UAAU,EACnB,aAAa,UAAU,EAAE,KACxB,UAAU,EAKZ,CAAC"}
|