@epam/ai-dial-chat-shared 1.1.0-dev.467 → 1.1.0-dev.471
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/file-manager/FileManagerAttachModal/FileManagerAttachModal.js +24 -9
- package/file-manager.d.ts +36 -6
- package/index.d.ts +54 -121
- package/index.js +55 -56
- package/package.json +12 -45
- package/utils/annotation.js +120 -0
|
@@ -15,7 +15,22 @@ var d = a(({ isOpen: a, onClose: d, onAttach: f, onSkippedUnsupportedFiles: p, o
|
|
|
15
15
|
return t(F), L?.forEach((t) => {
|
|
16
16
|
e.set(t.path, t), t.id && e.set(t.id, t);
|
|
17
17
|
}), e;
|
|
18
|
-
}, [F, L]), z = s(() => Array.from(C).map((e) => R.get(e)).filter((e) => e != null), [R, C]), B = o(() => {
|
|
18
|
+
}, [F, L]), z = s(() => Array.from(C).map((e) => R.get(e)).filter((e) => e != null), [R, C]), B = o((e) => {
|
|
19
|
+
if (A == null) {
|
|
20
|
+
w(new Set(e));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
let t = /* @__PURE__ */ new Set();
|
|
24
|
+
for (let n of e) {
|
|
25
|
+
let e = R.get(n);
|
|
26
|
+
e != null && A({ data: e }) && t.add(n);
|
|
27
|
+
}
|
|
28
|
+
w(t);
|
|
29
|
+
}, [
|
|
30
|
+
R,
|
|
31
|
+
A,
|
|
32
|
+
w
|
|
33
|
+
]), V = o(() => {
|
|
19
34
|
let t = [], n = [];
|
|
20
35
|
for (let r of z) e(r.path) || (r.nodeType === u.FOLDER ? t.push(r.path) : n.push(r));
|
|
21
36
|
let r = t.filter((e) => !t.some((t) => t !== e && e.startsWith(`${t}/`))), i = n.filter((t) => !(e(t.path) || E != null && t.contentType != null && !E(t.contentType))), a = i.filter((e) => !r.some((t) => e.path.startsWith(`${t}/`)));
|
|
@@ -44,38 +59,38 @@ var d = a(({ isOpen: a, onClose: d, onAttach: f, onSkippedUnsupportedFiles: p, o
|
|
|
44
59
|
k,
|
|
45
60
|
R,
|
|
46
61
|
T
|
|
47
|
-
]), { title:
|
|
62
|
+
]), { title: H, attachLabel: U, headerDescription: W, ...G } = b;
|
|
48
63
|
return /* @__PURE__ */ c(n, {
|
|
49
64
|
open: a,
|
|
50
65
|
header: /* @__PURE__ */ l("div", {
|
|
51
66
|
className: "flex flex-col gap-1",
|
|
52
|
-
children: [/* @__PURE__ */ c("span", { children:
|
|
67
|
+
children: [/* @__PURE__ */ c("span", { children: H }), W != null && /* @__PURE__ */ c("p", {
|
|
53
68
|
className: "dial-small-text text-start",
|
|
54
|
-
children:
|
|
69
|
+
children: W
|
|
55
70
|
})]
|
|
56
71
|
}),
|
|
57
|
-
ariaLabel:
|
|
72
|
+
ariaLabel: H,
|
|
58
73
|
size: r.Lg,
|
|
59
74
|
className: "flex !h-[min(800px,100dvh)] w-full flex-col !bg-layer-sunken",
|
|
60
75
|
onClose: d,
|
|
61
76
|
footer: /* @__PURE__ */ c("div", {
|
|
62
77
|
className: "flex justify-end px-6 py-4",
|
|
63
78
|
children: /* @__PURE__ */ c(i, {
|
|
64
|
-
label:
|
|
79
|
+
label: U,
|
|
65
80
|
disabled: z.length === 0 || I || g,
|
|
66
|
-
onClick:
|
|
81
|
+
onClick: V
|
|
67
82
|
})
|
|
68
83
|
}),
|
|
69
84
|
children: /* @__PURE__ */ c("div", {
|
|
70
85
|
className: "flex min-h-0 flex-col",
|
|
71
86
|
children: /* @__PURE__ */ c(t, {
|
|
72
87
|
controller: h,
|
|
73
|
-
labels:
|
|
88
|
+
labels: G,
|
|
74
89
|
activeTab: _,
|
|
75
90
|
tabs: v,
|
|
76
91
|
onTabChange: y,
|
|
77
92
|
selectedPaths: C,
|
|
78
|
-
onSelectedPathsChange:
|
|
93
|
+
onSelectedPathsChange: B,
|
|
79
94
|
variant: x,
|
|
80
95
|
actionProfile: S,
|
|
81
96
|
autoSelectUploadedItems: P,
|
package/file-manager.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { DialFileAcceptType } from '@epam/ai-dial-react-file-manager';
|
|
|
6
6
|
import { DialFileManager } from '@epam/ai-dial-react-file-manager';
|
|
7
7
|
import { DialFileManagerActions } from '@epam/ai-dial-react-file-manager';
|
|
8
8
|
import { DialFileManagerTabs } from '@epam/ai-dial-react-file-manager';
|
|
9
|
+
import { DialFileNodeType } from '@epam/ai-dial-react-file-manager';
|
|
9
10
|
import { DialUploadFileItem } from '@epam/ai-dial-react-file-manager';
|
|
10
11
|
import { FC } from 'react';
|
|
11
12
|
import { FileManagerColumnKey } from '@epam/ai-dial-react-file-manager';
|
|
@@ -191,9 +192,9 @@ export declare interface DialFileManagerShellProps {
|
|
|
191
192
|
allowedFileTypes?: DialFileAcceptType[];
|
|
192
193
|
/** Maximum file size in bytes for selectable files. */
|
|
193
194
|
maxSelectableFileSize?: number;
|
|
194
|
-
/** Custom row-selectability predicate. */
|
|
195
|
+
/** Custom row-selectability predicate, forwarded to the grid's row selection. */
|
|
195
196
|
isRowSelectable?: (node: {
|
|
196
|
-
data?:
|
|
197
|
+
data?: FileManagerSelectableNode | null;
|
|
197
198
|
}) => boolean;
|
|
198
199
|
/** Returns a tooltip for disabled rows, or undefined for enabled rows. */
|
|
199
200
|
getDisabledTooltip?: (row: FileManagerGridRow) => string | undefined;
|
|
@@ -222,8 +223,15 @@ declare interface EmptyStateCopy {
|
|
|
222
223
|
/** File-manager modal with Popup chrome and an Attach footer. Selection and tab state are controlled by the host. */
|
|
223
224
|
export declare const FileManagerAttachModal: FC<FileManagerAttachModalProps>;
|
|
224
225
|
|
|
225
|
-
/**
|
|
226
|
-
|
|
226
|
+
/**
|
|
227
|
+
* Labels for `FileManagerAttachModal`. Extends the shell labels with
|
|
228
|
+
* attach-specific strings.
|
|
229
|
+
*
|
|
230
|
+
* Declared here rather than beside the component so a host can type its label
|
|
231
|
+
* object from this package's root entry without reaching the `./file-manager`
|
|
232
|
+
* entry, which is the one that pulls in the grid.
|
|
233
|
+
*/
|
|
234
|
+
declare interface FileManagerAttachModalLabels extends DialFileManagerShellLabels {
|
|
227
235
|
/** Title displayed in the Popup header. */
|
|
228
236
|
title: string;
|
|
229
237
|
/** Label for the primary Attach button. */
|
|
@@ -290,9 +298,15 @@ export declare interface FileManagerAttachModalProps {
|
|
|
290
298
|
maximumAttachmentsAmount?: number;
|
|
291
299
|
/** Count of attachments already present before this modal opens. Defaults to `0`. */
|
|
292
300
|
existingAttachmentsAmount?: number;
|
|
293
|
-
/**
|
|
301
|
+
/**
|
|
302
|
+
* Row selectability predicate forwarded to the grid and re-applied to every
|
|
303
|
+
* selection change, so items that were not clicked manually (e.g. the file
|
|
304
|
+
* manager's auto-select of newly created items) cannot enter selection
|
|
305
|
+
* unless manually selectable. Paths resolving to no listed node are dropped.
|
|
306
|
+
* When absent, selection changes are forwarded unfiltered.
|
|
307
|
+
*/
|
|
294
308
|
isRowSelectable?: (node: {
|
|
295
|
-
data?:
|
|
309
|
+
data?: FileManagerSelectableNode | null;
|
|
296
310
|
}) => boolean;
|
|
297
311
|
/** Returns a tooltip for disabled rows; forwarded to the grid. */
|
|
298
312
|
getDisabledTooltip?: (row: FileManagerGridRow) => string | undefined;
|
|
@@ -418,6 +432,22 @@ declare interface FileManagerController {
|
|
|
418
432
|
clearMetadata: () => void;
|
|
419
433
|
}
|
|
420
434
|
|
|
435
|
+
/**
|
|
436
|
+
* Minimal node shape file-manager selection predicates are evaluated against.
|
|
437
|
+
* Satisfied by both grid rows and `DialFile` controller items, so one
|
|
438
|
+
* predicate can gate manual grid clicks and programmatic selection changes.
|
|
439
|
+
*/
|
|
440
|
+
declare interface FileManagerSelectableNode {
|
|
441
|
+
/** Virtual path of the node. */
|
|
442
|
+
path: string;
|
|
443
|
+
/** Distinguishes folders from files. */
|
|
444
|
+
nodeType: DialFileNodeType;
|
|
445
|
+
/** MIME type of a file node, when known. */
|
|
446
|
+
contentType?: string;
|
|
447
|
+
/** Size in bytes of a file node, when known. */
|
|
448
|
+
contentLength?: number;
|
|
449
|
+
}
|
|
450
|
+
|
|
421
451
|
/** State of an in-progress or just-settled upload batch, as returned by `useDialFileUploadBatch`. */
|
|
422
452
|
declare interface FileUploadBatchState {
|
|
423
453
|
/** Individual file entries in this batch. */
|
package/index.d.ts
CHANGED
|
@@ -6,10 +6,10 @@ import { DIAL_ICON_SIZE } from '@epam/ai-dial-ui-kit';
|
|
|
6
6
|
import { DialCopiedItem } from '@epam/ai-dial-react-file-manager';
|
|
7
7
|
import { DialDeletedItem } from '@epam/ai-dial-react-file-manager';
|
|
8
8
|
import { DialFile } from '@epam/ai-dial-react-file-manager';
|
|
9
|
-
import { DialFileAcceptType } from '@epam/ai-dial-react-file-manager';
|
|
10
9
|
import { DialFileManager } from '@epam/ai-dial-react-file-manager';
|
|
11
10
|
import { DialFileManagerActions } from '@epam/ai-dial-react-file-manager';
|
|
12
11
|
import { DialFileManagerTabs } from '@epam/ai-dial-react-file-manager';
|
|
12
|
+
import { DialFileNodeType } from '@epam/ai-dial-react-file-manager';
|
|
13
13
|
import { DialUploadFileItem } from '@epam/ai-dial-react-file-manager';
|
|
14
14
|
import { ElementSize } from '@epam/ai-dial-ui-kit';
|
|
15
15
|
import { FC } from 'react';
|
|
@@ -20,7 +20,6 @@ import { IRowNode } from 'ag-grid-community';
|
|
|
20
20
|
import { Options } from 'react-markdown';
|
|
21
21
|
import { ReactNode } from 'react';
|
|
22
22
|
import { RefObject } from 'react';
|
|
23
|
-
import { ToolbarOptions } from '@epam/ai-dial-react-file-manager';
|
|
24
23
|
|
|
25
24
|
/** A single annotation attached to an assistant message, optionally citing a source document. */
|
|
26
25
|
export declare interface Annotation {
|
|
@@ -596,13 +595,6 @@ declare type DialFileManagerComponentProps = ComponentProps<typeof DialFileManag
|
|
|
596
595
|
/** Configuration for the destination-folder picker popup. */
|
|
597
596
|
export declare type DialFileManagerDestinationFolderPopupOptions = NonNullable<DialFileManagerComponentProps['destinationFolderPopupOptions']>;
|
|
598
597
|
|
|
599
|
-
/**
|
|
600
|
-
* Renders the DialFileManager grid/tree/toolbar and its operation overlays
|
|
601
|
-
* from a `FileManagerController`. Does not own popup chrome, an attach footer,
|
|
602
|
-
* or any attach-only selection constraints — those are host-owned.
|
|
603
|
-
*/
|
|
604
|
-
export declare const DialFileManagerShell: FC<DialFileManagerShellProps>;
|
|
605
|
-
|
|
606
598
|
/**
|
|
607
599
|
* Pre-translated strings and resolved renderers the shell renders as-is.
|
|
608
600
|
* The shell never calls `useTranslation` — every host (the attach modal
|
|
@@ -723,42 +715,6 @@ export declare interface DialFileManagerShellLabels {
|
|
|
723
715
|
metadataAuthorLabel: string;
|
|
724
716
|
}
|
|
725
717
|
|
|
726
|
-
/** Props for the shared file-manager shell component. */
|
|
727
|
-
export declare interface DialFileManagerShellProps {
|
|
728
|
-
/** Structural view contract containing all controller state and callbacks. */
|
|
729
|
-
controller: FileManagerController;
|
|
730
|
-
/** Pre-translated labels the shell renders as-is. */
|
|
731
|
-
labels: DialFileManagerShellLabels;
|
|
732
|
-
/** Currently active tab. */
|
|
733
|
-
activeTab: DialFileManagerTabs;
|
|
734
|
-
/** Tab configuration for the toolbar. */
|
|
735
|
-
tabs: ToolbarOptions['tabs'];
|
|
736
|
-
/** Called when the user switches tabs. */
|
|
737
|
-
onTabChange: (tab: DialFileManagerTabs) => void;
|
|
738
|
-
/** Set of currently selected file/folder virtual paths. */
|
|
739
|
-
selectedPaths: Set<string>;
|
|
740
|
-
/** Called when the selection changes. */
|
|
741
|
-
onSelectedPathsChange: (paths: Set<string>) => void;
|
|
742
|
-
/** Host driving this shell instance — gates the upload-archive toolbar entry (standalone-only). */
|
|
743
|
-
variant: DialFileManagerVariant;
|
|
744
|
-
/** Action-set gate for the upload-archive toolbar entry (Full-only). */
|
|
745
|
-
actionProfile: DialFileManagerActionProfile;
|
|
746
|
-
/** Whether to auto-select items after upload completes. Defaults to `false`. */
|
|
747
|
-
autoSelectUploadedItems?: boolean;
|
|
748
|
-
/** MIME type filters for selectable files. */
|
|
749
|
-
allowedFileTypes?: DialFileAcceptType[];
|
|
750
|
-
/** Maximum file size in bytes for selectable files. */
|
|
751
|
-
maxSelectableFileSize?: number;
|
|
752
|
-
/** Custom row-selectability predicate. */
|
|
753
|
-
isRowSelectable?: (node: {
|
|
754
|
-
data?: FileManagerGridRow | null;
|
|
755
|
-
}) => boolean;
|
|
756
|
-
/** Returns a tooltip for disabled rows, or undefined for enabled rows. */
|
|
757
|
-
getDisabledTooltip?: (row: FileManagerGridRow) => string | undefined;
|
|
758
|
-
/** Tooltip shown on files with an unsupported type. */
|
|
759
|
-
unsupportedFileTypeTooltip?: string;
|
|
760
|
-
}
|
|
761
|
-
|
|
762
718
|
/**
|
|
763
719
|
* Identifies which host is driving `useDialFileManager` / `DialFileManagerShell`.
|
|
764
720
|
* `FolderPicker` is a reserved value with no implemented UI yet (#7503+).
|
|
@@ -1002,10 +958,14 @@ export declare enum FileExtension {
|
|
|
1002
958
|
JSON = "json"
|
|
1003
959
|
}
|
|
1004
960
|
|
|
1005
|
-
/**
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
961
|
+
/**
|
|
962
|
+
* Labels for `FileManagerAttachModal`. Extends the shell labels with
|
|
963
|
+
* attach-specific strings.
|
|
964
|
+
*
|
|
965
|
+
* Declared here rather than beside the component so a host can type its label
|
|
966
|
+
* object from this package's root entry without reaching the `./file-manager`
|
|
967
|
+
* entry, which is the one that pulls in the grid.
|
|
968
|
+
*/
|
|
1009
969
|
export declare interface FileManagerAttachModalLabels extends DialFileManagerShellLabels {
|
|
1010
970
|
/** Title displayed in the Popup header. */
|
|
1011
971
|
title: string;
|
|
@@ -1015,78 +975,6 @@ export declare interface FileManagerAttachModalLabels extends DialFileManagerShe
|
|
|
1015
975
|
headerDescription?: string | null;
|
|
1016
976
|
}
|
|
1017
977
|
|
|
1018
|
-
/** Props accepted by `FileManagerAttachModal`. */
|
|
1019
|
-
export declare interface FileManagerAttachModalProps {
|
|
1020
|
-
/** Whether the modal is open. */
|
|
1021
|
-
isOpen: boolean;
|
|
1022
|
-
/** Called when the modal requests to be closed. */
|
|
1023
|
-
onClose: () => void;
|
|
1024
|
-
/** Called with the confirmed selection when the user presses Attach. */
|
|
1025
|
-
onAttach: (result: AttachResult) => void;
|
|
1026
|
-
/** Called when one or more selected files were filtered out due to an unsupported type. */
|
|
1027
|
-
onSkippedUnsupportedFiles?: () => void;
|
|
1028
|
-
/** Called when the total attachment count would exceed the limit. */
|
|
1029
|
-
onCountLimitExceeded?: (totalCount: number, limit: number) => void;
|
|
1030
|
-
/** Live file-manager state driving the grid. */
|
|
1031
|
-
controller: FileManagerController;
|
|
1032
|
-
/**
|
|
1033
|
-
* True while any mutating operation is in progress (upload, delete, rename, etc.).
|
|
1034
|
-
* Disables the Attach button alongside `isLoading`.
|
|
1035
|
-
*/
|
|
1036
|
-
isAnyOperationInProgress: boolean;
|
|
1037
|
-
/** Currently active tab. */
|
|
1038
|
-
activeTab: DialFileManagerTabs;
|
|
1039
|
-
/** Tab configuration for the toolbar. */
|
|
1040
|
-
tabs: ToolbarOptions['tabs'];
|
|
1041
|
-
/**
|
|
1042
|
-
* Called when the user switches tabs.
|
|
1043
|
-
* The host is responsible for resetting `selectedPaths` to an empty set.
|
|
1044
|
-
*/
|
|
1045
|
-
onTabChange: (tab: DialFileManagerTabs) => void;
|
|
1046
|
-
/** All user-visible strings. */
|
|
1047
|
-
labels: FileManagerAttachModalLabels;
|
|
1048
|
-
/** File-manager variant (controls which toolbar entries are shown). */
|
|
1049
|
-
variant: DialFileManagerVariant;
|
|
1050
|
-
/** Action profile controlling toolbar entry visibility. */
|
|
1051
|
-
actionProfile: DialFileManagerActionProfile;
|
|
1052
|
-
/**
|
|
1053
|
-
* Current set of selected virtual paths, managed by the host.
|
|
1054
|
-
* The host must reset this to an empty set when the active tab changes.
|
|
1055
|
-
*/
|
|
1056
|
-
selectedPaths: Set<string>;
|
|
1057
|
-
/** Called when the user changes the grid selection. */
|
|
1058
|
-
onSelectedPathsChange: (paths: Set<string>) => void;
|
|
1059
|
-
/**
|
|
1060
|
-
* Resolves a folder `DialFile` to its DIAL Core path string for inclusion in
|
|
1061
|
-
* `AttachResult.folderPaths`. Return `null` to skip the folder.
|
|
1062
|
-
* Path normalization and bucket resolution are the host's responsibility.
|
|
1063
|
-
*/
|
|
1064
|
-
resolveFolderPath: (file: DialFile) => string | null;
|
|
1065
|
-
/**
|
|
1066
|
-
* Returns `false` for file content-types that must be filtered out on attach.
|
|
1067
|
-
* When absent, all content types are accepted.
|
|
1068
|
-
*/
|
|
1069
|
-
isFileTypeAllowed?: (contentType: string) => boolean;
|
|
1070
|
-
/** Maximum size in bytes a selectable file may have. */
|
|
1071
|
-
maxSelectableFileSize?: number;
|
|
1072
|
-
/** Maximum total attachments (already-attached plus newly selected). */
|
|
1073
|
-
maximumAttachmentsAmount?: number;
|
|
1074
|
-
/** Count of attachments already present before this modal opens. Defaults to `0`. */
|
|
1075
|
-
existingAttachmentsAmount?: number;
|
|
1076
|
-
/** Row selectability predicate forwarded to the grid. */
|
|
1077
|
-
isRowSelectable?: (node: {
|
|
1078
|
-
data?: FileManagerGridRow | null;
|
|
1079
|
-
}) => boolean;
|
|
1080
|
-
/** Returns a tooltip for disabled rows; forwarded to the grid. */
|
|
1081
|
-
getDisabledTooltip?: (row: FileManagerGridRow) => string | undefined;
|
|
1082
|
-
/** Tooltip shown on files with an unsupported type; forwarded to the grid. */
|
|
1083
|
-
unsupportedFileTypeTooltip?: string;
|
|
1084
|
-
/** Accepted file types for the upload file input. */
|
|
1085
|
-
allowedFileTypes?: DialFileAcceptType[];
|
|
1086
|
-
/** Whether to auto-select items immediately after upload. Defaults to `false`. */
|
|
1087
|
-
autoSelectUploadedItems?: boolean;
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
978
|
/**
|
|
1091
979
|
* Structural view contract consumed by `DialFileManagerShell`. Contains exactly
|
|
1092
980
|
* the fields of `UseDialFileManagerResult` that the shell reads, with the same
|
|
@@ -1201,6 +1089,22 @@ export declare interface FileManagerController {
|
|
|
1201
1089
|
clearMetadata: () => void;
|
|
1202
1090
|
}
|
|
1203
1091
|
|
|
1092
|
+
/**
|
|
1093
|
+
* Minimal node shape file-manager selection predicates are evaluated against.
|
|
1094
|
+
* Satisfied by both grid rows and `DialFile` controller items, so one
|
|
1095
|
+
* predicate can gate manual grid clicks and programmatic selection changes.
|
|
1096
|
+
*/
|
|
1097
|
+
export declare interface FileManagerSelectableNode {
|
|
1098
|
+
/** Virtual path of the node. */
|
|
1099
|
+
path: string;
|
|
1100
|
+
/** Distinguishes folders from files. */
|
|
1101
|
+
nodeType: DialFileNodeType;
|
|
1102
|
+
/** MIME type of a file node, when known. */
|
|
1103
|
+
contentType?: string;
|
|
1104
|
+
/** Size in bytes of a file node, when known. */
|
|
1105
|
+
contentLength?: number;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1204
1108
|
/** State of an in-progress or just-settled upload batch, as returned by `useDialFileUploadBatch`. */
|
|
1205
1109
|
export declare interface FileUploadBatchState {
|
|
1206
1110
|
/** Individual file entries in this batch. */
|
|
@@ -1328,6 +1232,9 @@ export declare interface InitialsAvatarProps {
|
|
|
1328
1232
|
textClassName?: string;
|
|
1329
1233
|
}
|
|
1330
1234
|
|
|
1235
|
+
/** Returns whether `value` is shaped like an annotation selector. */
|
|
1236
|
+
export declare const isAnnotationSelector: (value: unknown) => value is AnnotationSelector;
|
|
1237
|
+
|
|
1331
1238
|
/** Returns `true` when `types` contains a wildcard or any audio MIME type; `false` otherwise. */
|
|
1332
1239
|
export declare const isAudioTranscriptionSupported: (types?: string[]) => boolean;
|
|
1333
1240
|
|
|
@@ -1911,6 +1818,32 @@ export declare const MOBILE_MAX_WIDTH_PX: number;
|
|
|
1911
1818
|
/** `matchMedia` query matching the mobile/tablet band (up to 1279px). */
|
|
1912
1819
|
export declare const MOBILE_MEDIA_QUERY = "(max-width: 1279px)";
|
|
1913
1820
|
|
|
1821
|
+
/**
|
|
1822
|
+
* Repairs persisted `html_tag` annotations created by older normalizers that
|
|
1823
|
+
* defaulted every non-HTML source to PDF. An explicit, recognized file
|
|
1824
|
+
* extension is more reliable than that historical fallback; opaque URLs keep
|
|
1825
|
+
* their stored type so genuine PDF citations without an extension still work.
|
|
1826
|
+
*/
|
|
1827
|
+
export declare const normalizePersistedHtmlTagAttachmentType: (annotation: Annotation) => Annotation;
|
|
1828
|
+
|
|
1829
|
+
/**
|
|
1830
|
+
* Normalizes raw annotations from the API wire format (stored in
|
|
1831
|
+
* `message.custom_fields.annotations`) to the internal `Annotation` model.
|
|
1832
|
+
*
|
|
1833
|
+
* Recognizes two wire shapes:
|
|
1834
|
+
* - `target.source.attachment_index` (integer) + a `pdf_region` selector
|
|
1835
|
+
* with `{ left, top, width, height }` coordinates, resolved against
|
|
1836
|
+
* `attachments` and converted to `body.source.attachment.url` + a
|
|
1837
|
+
* `pdf_bbox` selector with `{ x1, y1, x2, y2 }` coordinates.
|
|
1838
|
+
* - `target.selector` of type `html_tag` (`{ tag, id }`) with a flat
|
|
1839
|
+
* `body.source = { type: 'attachment', url }` — normalized to
|
|
1840
|
+
* `body.source.attachment.url`/`.title` directly, with no attachment-list
|
|
1841
|
+
* lookup, preserving optional indexes and document selectors.
|
|
1842
|
+
*
|
|
1843
|
+
* Annotations matching neither shape are omitted from the result.
|
|
1844
|
+
*/
|
|
1845
|
+
export declare const normalizeRawAnnotations: (rawAnnotations: unknown[], attachments: MessageAttachment[]) => Annotation[];
|
|
1846
|
+
|
|
1914
1847
|
/** A single OpenAI-style tool-call request, present on a `ToolExecutionHistoryMessage` with `role: 'assistant'`. */
|
|
1915
1848
|
export declare interface OpenAiToolCall {
|
|
1916
1849
|
/** Correlates this call to its result message via that message's `tool_call_id`. */
|
package/index.js
CHANGED
|
@@ -7,59 +7,58 @@ import { AttachmentErrorReason as f, AttachmentType as p } from "./types/attachm
|
|
|
7
7
|
import { CatalogEntityType as m } from "./types/entity-type.js";
|
|
8
8
|
import { FileExtension as h, MIMEType as g } from "./types/mime-type.js";
|
|
9
9
|
import { CodeBlockTheme as _ } from "./types/code-editor.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
import {
|
|
61
|
-
import {
|
|
62
|
-
import {
|
|
63
|
-
import {
|
|
64
|
-
|
|
65
|
-
export { f as AttachmentErrorReason, p as AttachmentType, oe as BASE_LG_ICON_PROPS, se as BASE_MD_ICON_PROPS, Ue as COMPACT_MARKDOWN_CLASS_NAMES, m as CatalogEntityType, _ as CodeBlockTheme, e as ConversationTransferErrorCode, t as ConversationTransferJobStatus, n as ConversationTransferSubjectKind, r as ConversationTransferUnitKind, i as ConversationTransferWarningCode, we as CopyButton, Te as CopyIconButton, We as DEFAULT_MARKDOWN_CLASS_NAMES, Ie as DEFAULT_MARKDOWN_TABLE_DOWNLOAD_FILENAME, ge as DESKTOP_BREAKPOINT_PX, _e as DESKTOP_MEDIA_QUERY, Ce as DeploymentIcon, Xe as DialFileManagerActionProfile, it as DialFileManagerShell, Ze as DialFileManagerVariant, X as ENTITY_TYPE_BG_COLOR, Z as ENTITY_TYPE_COLOR, Ae as EntityHeader, Oe as EntityTypeLabel, ke as FeaturedChip, h as FileExtension, at as FileManagerAttachModal, et as FileUploadStatus, a as FilterTab, ce as HIDDEN_FILE, Se as InitialsAvatar, De as ItemHeader, ue as MARKDOWN_EDITOR_MAX_HEIGHT_CLASS_NAME, pe as MARKDOWN_EDITOR_PREVIEW_LIST_CLASS_NAME, Le as MARKDOWN_TABLE_CSV_MIME_TYPE, Ge as MDMessageViewer, g as MIMEType, j as MIME_TYPE_AUDIO_PREFIX, M as MIME_TYPE_EXT_MAP, N as MIME_TYPE_WILDCARD, ve as MOBILE_MAX_WIDTH_PX, ye as MOBILE_MEDIA_QUERY, Fe as MarkdownCodeBlock, Ve as MarkdownRenderer, Be as MarkdownTable, Re as MarkdownTableCopyFormat, Ke as MarkdownWithPlaceholders, o as MessageRating, s as MessageRole, nt as OperationLoaderModal, v as PROHIBITED_CONVERSATION_NAME_CHARS_RE, Q as PROMPT_PARAM_DEFAULT_SEPARATOR, $ as PROMPT_PARAM_PATTERN, ee as PROMPT_VARIABLE_CLASS_NAME, Ee as PanelEmptyState, de as RESIZABLE_FIELD_MAX_HEIGHT_CSS_VARIABLE, fe as RESIZABLE_TEXTAREA_CLASS_NAME, c as RequestStatus, je as ResourceSummary, d as ResponseFormat, me as SELECT_LIST_MAX_HEIGHT_CLASS_NAME, he as SELECT_LIST_MAX_HEIGHT_PX, l as StageStatus, u as StatusEvent, le as TAG_INPUT_TAG_CLASS_NAME, Me as TableHeader, rt as UploadProgressModal, U as base64ToBlob, w as buildCssVars, te as buildPromptParamDefaults, F as copyMarkdownAsRichText, I as copyToClipboard, He as defaultMarkdownComponents, W as downloadTextFile, G as ensureDownloadFilename, xe as extractInitials, ne as extractPromptParams, B as formatCost, z as formatFileSize, R as formatLastUsed, V as formatPrice, H as formatUnitPrice, ae as generateUUID, E as getAttachmentTypeFromMime, K as getFileExtensionForLanguage, Qe as getParentFolderPath, y as getUtf8ByteLength, D as inferMimeTypeFromPath, P as isAudioTranscriptionSupported, $e as isHiddenPath, T as isStatusMessage, L as markdownToRichTextHtml, C as mergeClasses, k as messageAttachmentToDisplayAttachment, A as messageAttachmentsToDisplayAttachments, be as pickAvatarColor, re as rehypePromptVariables, ie as resolvePromptParams, Pe as restrainedSyntaxTheme, b as sanitizeConversationName, ze as serializeMarkdownTableRows, x as stripTrailingDots, O as stripUrlQueryAndFragment, q as triggerAnchorDownload, J as triggerBlobDownload, S as truncateToUtf8Bytes, Y as tryBase64ToBytes, Je as useAvailableHeightCap, Ne as useCodeCopy, qe as useCollapsedText, tt as useGridEditingScroll, Ye as useIsMobile };
|
|
10
|
+
import { getAttachmentTypeFromMime as v, inferMimeTypeFromPath as y, stripUrlQueryAndFragment as b } from "./utils/mime-type.js";
|
|
11
|
+
import { isAnnotationSelector as x, normalizePersistedHtmlTagAttachmentType as S, normalizeRawAnnotations as C } from "./utils/annotation.js";
|
|
12
|
+
import { PROHIBITED_CONVERSATION_NAME_CHARS_RE as w, getUtf8ByteLength as T, sanitizeConversationName as E, stripTrailingDots as D, truncateToUtf8Bytes as O } from "./utils/string-utils.js";
|
|
13
|
+
import { mergeClasses as k } from "./utils/merge-class.js";
|
|
14
|
+
import { buildCssVars as A } from "./utils/build-css-vars.js";
|
|
15
|
+
import { isStatusMessage as j } from "./utils/message.js";
|
|
16
|
+
import { messageAttachmentToDisplayAttachment as M, messageAttachmentsToDisplayAttachments as N } from "./utils/message-attachment-to-display.js";
|
|
17
|
+
import { MIME_TYPE_AUDIO_PREFIX as P, MIME_TYPE_EXT_MAP as F, MIME_TYPE_WILDCARD as I } from "./constants/mime-types.js";
|
|
18
|
+
import { isAudioTranscriptionSupported as L } from "./utils/is-audio-transcription-supported.js";
|
|
19
|
+
import { copyMarkdownAsRichText as R, copyToClipboard as z, markdownToRichTextHtml as B } from "./utils/copy-to-clipboard.js";
|
|
20
|
+
import { formatLastUsed as V } from "./utils/format-last-used.js";
|
|
21
|
+
import { formatFileSize as H } from "./utils/format-file-size.js";
|
|
22
|
+
import { formatCost as U, formatPrice as W, formatUnitPrice as G } from "./utils/format-price.js";
|
|
23
|
+
import { base64ToBlob as K, downloadTextFile as q, ensureDownloadFilename as J, getFileExtensionForLanguage as Y, triggerAnchorDownload as X, triggerBlobDownload as Z, tryBase64ToBytes as Q } from "./utils/file-download.js";
|
|
24
|
+
import { ENTITY_TYPE_BG_COLOR as $, ENTITY_TYPE_COLOR as ee } from "./constants/entity-colors.js";
|
|
25
|
+
import { PROMPT_PARAM_DEFAULT_SEPARATOR as te, PROMPT_PARAM_PATTERN as ne, PROMPT_VARIABLE_CLASS_NAME as re, buildPromptParamDefaults as ie, extractPromptParams as ae, rehypePromptVariables as oe, resolvePromptParams as se } from "./utils/prompt-variables.js";
|
|
26
|
+
import { generateUUID as ce } from "./utils/generate-uuid.js";
|
|
27
|
+
import { BASE_LG_ICON_PROPS as le, BASE_MD_ICON_PROPS as ue } from "./constants/icon.js";
|
|
28
|
+
import { HIDDEN_FILE as de } from "./constants/dial.js";
|
|
29
|
+
import { TAG_INPUT_TAG_CLASS_NAME as fe } from "./constants/tag-input.js";
|
|
30
|
+
import { MARKDOWN_EDITOR_MAX_HEIGHT_CLASS_NAME as pe, RESIZABLE_FIELD_MAX_HEIGHT_CSS_VARIABLE as me, RESIZABLE_TEXTAREA_CLASS_NAME as he } from "./constants/resizable-fields.js";
|
|
31
|
+
import { MARKDOWN_EDITOR_PREVIEW_LIST_CLASS_NAME as ge } from "./constants/markdown-editor.js";
|
|
32
|
+
import { SELECT_LIST_MAX_HEIGHT_CLASS_NAME as _e, SELECT_LIST_MAX_HEIGHT_PX as ve } from "./constants/select-list.js";
|
|
33
|
+
import { DESKTOP_BREAKPOINT_PX as ye, DESKTOP_MEDIA_QUERY as be, MOBILE_MAX_WIDTH_PX as xe, MOBILE_MEDIA_QUERY as Se } from "./constants/breakpoint.js";
|
|
34
|
+
import { pickAvatarColor as Ce } from "./utils/avatar-color.js";
|
|
35
|
+
import { extractInitials as we } from "./utils/initials.js";
|
|
36
|
+
import { InitialsAvatar as Te } from "./components/InitialsAvatar/InitialsAvatar.js";
|
|
37
|
+
import { DeploymentIcon as Ee } from "./components/DeploymentIcon/DeploymentIcon.js";
|
|
38
|
+
import { CopyButton as De, CopyIconButton as Oe } from "./components/CopyButton/CopyButton.js";
|
|
39
|
+
import { PanelEmptyState as ke } from "./components/PanelEmptyState/PanelEmptyState.js";
|
|
40
|
+
import { ItemHeader as Ae } from "./components/ItemHeader/ItemHeader.js";
|
|
41
|
+
import { EntityTypeLabel as je } from "./components/EntityTypeLabel/EntityTypeLabel.js";
|
|
42
|
+
import { FeaturedChip as Me } from "./components/FeaturedChip/FeaturedChip.js";
|
|
43
|
+
import { EntityHeader as Ne } from "./components/EntityHeader/EntityHeader.js";
|
|
44
|
+
import { ResourceSummary as Pe } from "./components/ResourceSummary/ResourceSummary.js";
|
|
45
|
+
import { TableHeader as Fe } from "./components/MarkdownRenderer/Table/TableHeader.js";
|
|
46
|
+
import { useCodeCopy as Ie } from "./hooks/useCodeCopy.js";
|
|
47
|
+
import { restrainedSyntaxTheme as Le } from "./components/MarkdownRenderer/CodeBlock/syntax-theme.js";
|
|
48
|
+
import { MarkdownCodeBlock as Re } from "./components/MarkdownRenderer/CodeBlock/CodeBlock.js";
|
|
49
|
+
import { DEFAULT_MARKDOWN_TABLE_DOWNLOAD_FILENAME as ze, MARKDOWN_TABLE_CSV_MIME_TYPE as Be, MarkdownTableCopyFormat as Ve, serializeMarkdownTableRows as He } from "./components/MarkdownRenderer/Table/table-serialization.js";
|
|
50
|
+
import { MarkdownTable as Ue } from "./components/MarkdownRenderer/Table/MarkdownTable.js";
|
|
51
|
+
import { MarkdownRenderer as We, defaultMarkdownComponents as Ge } from "./components/MarkdownRenderer/MarkdownRenderer.js";
|
|
52
|
+
import { COMPACT_MARKDOWN_CLASS_NAMES as Ke, DEFAULT_MARKDOWN_CLASS_NAMES as qe } from "./components/MarkdownRenderer/markdown-class-names.js";
|
|
53
|
+
import { MDMessageViewer as Je } from "./components/MarkdownRenderer/MDMessageViewer.js";
|
|
54
|
+
import { MarkdownWithPlaceholders as Ye } from "./components/MarkdownWithPlaceholders/MarkdownWithPlaceholders.js";
|
|
55
|
+
import { useCollapsedText as Xe } from "./hooks/useCollapsedText.js";
|
|
56
|
+
import { useAvailableHeightCap as Ze } from "./hooks/useAvailableHeightCap.js";
|
|
57
|
+
import { useIsMobile as Qe } from "./hooks/useIsMobile.js";
|
|
58
|
+
import { DialFileManagerActionProfile as $e, DialFileManagerVariant as et } from "./file-manager/file-manager-variant.js";
|
|
59
|
+
import { getParentFolderPath as tt, isHiddenPath as nt } from "./file-manager/path.js";
|
|
60
|
+
import { FileUploadStatus as rt } from "./file-manager/upload-batch.js";
|
|
61
|
+
import { useGridEditingScroll as it } from "./file-manager/useGridEditingScroll/useGridEditingScroll.js";
|
|
62
|
+
import { OperationLoaderModal as at } from "./file-manager/OperationLoaderModal/OperationLoaderModal.js";
|
|
63
|
+
import { UploadProgressModal as ot } from "./file-manager/UploadProgressModal/UploadProgressModal.js";
|
|
64
|
+
export { f as AttachmentErrorReason, p as AttachmentType, le as BASE_LG_ICON_PROPS, ue as BASE_MD_ICON_PROPS, Ke as COMPACT_MARKDOWN_CLASS_NAMES, m as CatalogEntityType, _ as CodeBlockTheme, e as ConversationTransferErrorCode, t as ConversationTransferJobStatus, n as ConversationTransferSubjectKind, r as ConversationTransferUnitKind, i as ConversationTransferWarningCode, De as CopyButton, Oe as CopyIconButton, qe as DEFAULT_MARKDOWN_CLASS_NAMES, ze as DEFAULT_MARKDOWN_TABLE_DOWNLOAD_FILENAME, ye as DESKTOP_BREAKPOINT_PX, be as DESKTOP_MEDIA_QUERY, Ee as DeploymentIcon, $e as DialFileManagerActionProfile, et as DialFileManagerVariant, $ as ENTITY_TYPE_BG_COLOR, ee as ENTITY_TYPE_COLOR, Ne as EntityHeader, je as EntityTypeLabel, Me as FeaturedChip, h as FileExtension, rt as FileUploadStatus, a as FilterTab, de as HIDDEN_FILE, Te as InitialsAvatar, Ae as ItemHeader, pe as MARKDOWN_EDITOR_MAX_HEIGHT_CLASS_NAME, ge as MARKDOWN_EDITOR_PREVIEW_LIST_CLASS_NAME, Be as MARKDOWN_TABLE_CSV_MIME_TYPE, Je as MDMessageViewer, g as MIMEType, P as MIME_TYPE_AUDIO_PREFIX, F as MIME_TYPE_EXT_MAP, I as MIME_TYPE_WILDCARD, xe as MOBILE_MAX_WIDTH_PX, Se as MOBILE_MEDIA_QUERY, Re as MarkdownCodeBlock, We as MarkdownRenderer, Ue as MarkdownTable, Ve as MarkdownTableCopyFormat, Ye as MarkdownWithPlaceholders, o as MessageRating, s as MessageRole, at as OperationLoaderModal, w as PROHIBITED_CONVERSATION_NAME_CHARS_RE, te as PROMPT_PARAM_DEFAULT_SEPARATOR, ne as PROMPT_PARAM_PATTERN, re as PROMPT_VARIABLE_CLASS_NAME, ke as PanelEmptyState, me as RESIZABLE_FIELD_MAX_HEIGHT_CSS_VARIABLE, he as RESIZABLE_TEXTAREA_CLASS_NAME, c as RequestStatus, Pe as ResourceSummary, d as ResponseFormat, _e as SELECT_LIST_MAX_HEIGHT_CLASS_NAME, ve as SELECT_LIST_MAX_HEIGHT_PX, l as StageStatus, u as StatusEvent, fe as TAG_INPUT_TAG_CLASS_NAME, Fe as TableHeader, ot as UploadProgressModal, K as base64ToBlob, A as buildCssVars, ie as buildPromptParamDefaults, R as copyMarkdownAsRichText, z as copyToClipboard, Ge as defaultMarkdownComponents, q as downloadTextFile, J as ensureDownloadFilename, we as extractInitials, ae as extractPromptParams, U as formatCost, H as formatFileSize, V as formatLastUsed, W as formatPrice, G as formatUnitPrice, ce as generateUUID, v as getAttachmentTypeFromMime, Y as getFileExtensionForLanguage, tt as getParentFolderPath, T as getUtf8ByteLength, y as inferMimeTypeFromPath, x as isAnnotationSelector, L as isAudioTranscriptionSupported, nt as isHiddenPath, j as isStatusMessage, B as markdownToRichTextHtml, k as mergeClasses, M as messageAttachmentToDisplayAttachment, N as messageAttachmentsToDisplayAttachments, S as normalizePersistedHtmlTagAttachmentType, C as normalizeRawAnnotations, Ce as pickAvatarColor, oe as rehypePromptVariables, se as resolvePromptParams, Le as restrainedSyntaxTheme, E as sanitizeConversationName, He as serializeMarkdownTableRows, D as stripTrailingDots, b as stripUrlQueryAndFragment, X as triggerAnchorDownload, Z as triggerBlobDownload, O as truncateToUtf8Bytes, Q as tryBase64ToBytes, Ze as useAvailableHeightCap, Ie as useCodeCopy, Xe as useCollapsedText, it as useGridEditingScroll, Qe as useIsMobile };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epam/ai-dial-chat-shared",
|
|
3
3
|
"description": "Shared domain models, utilities, and UI components for AI DIAL Chat libraries",
|
|
4
|
-
"version": "1.1.0-dev.
|
|
4
|
+
"version": "1.1.0-dev.471",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": [
|
|
@@ -32,54 +32,11 @@
|
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": "^19.2.6",
|
|
35
|
-
"@tabler/icons-react": "^3.44.0",
|
|
36
|
-
"react-syntax-highlighter": "^16.1.1",
|
|
37
|
-
"react-markdown": "^10.1.0",
|
|
38
|
-
"remark-breaks": "^4.0.0",
|
|
39
|
-
"remark-gfm": "^4.0.1",
|
|
40
|
-
"remark-math": "^6.0.0",
|
|
41
|
-
"rehype-katex": "^7.0.1",
|
|
42
|
-
"rehype-raw": "^7.0.0",
|
|
43
|
-
"rehype-sanitize": "^6.0.0",
|
|
44
|
-
"katex": "^0.16.22",
|
|
45
35
|
"@epam/ai-dial-ui-kit": "^0.14.0-dev.15",
|
|
46
|
-
"@epam/ai-dial-react-file-manager": "
|
|
36
|
+
"@epam/ai-dial-react-file-manager": "^0.2.0-dev.10",
|
|
47
37
|
"ag-grid-community": "^35.3.0"
|
|
48
38
|
},
|
|
49
39
|
"peerDependenciesMeta": {
|
|
50
|
-
"@tabler/icons-react": {
|
|
51
|
-
"optional": true
|
|
52
|
-
},
|
|
53
|
-
"react-syntax-highlighter": {
|
|
54
|
-
"optional": true
|
|
55
|
-
},
|
|
56
|
-
"react-markdown": {
|
|
57
|
-
"optional": true
|
|
58
|
-
},
|
|
59
|
-
"remark-breaks": {
|
|
60
|
-
"optional": true
|
|
61
|
-
},
|
|
62
|
-
"remark-gfm": {
|
|
63
|
-
"optional": true
|
|
64
|
-
},
|
|
65
|
-
"remark-math": {
|
|
66
|
-
"optional": true
|
|
67
|
-
},
|
|
68
|
-
"rehype-katex": {
|
|
69
|
-
"optional": true
|
|
70
|
-
},
|
|
71
|
-
"rehype-raw": {
|
|
72
|
-
"optional": true
|
|
73
|
-
},
|
|
74
|
-
"rehype-sanitize": {
|
|
75
|
-
"optional": true
|
|
76
|
-
},
|
|
77
|
-
"katex": {
|
|
78
|
-
"optional": true
|
|
79
|
-
},
|
|
80
|
-
"@epam/ai-dial-ui-kit": {
|
|
81
|
-
"optional": true
|
|
82
|
-
},
|
|
83
40
|
"@epam/ai-dial-react-file-manager": {
|
|
84
41
|
"optional": true
|
|
85
42
|
},
|
|
@@ -88,9 +45,19 @@
|
|
|
88
45
|
}
|
|
89
46
|
},
|
|
90
47
|
"dependencies": {
|
|
48
|
+
"@tabler/icons-react": "^3.44.0",
|
|
91
49
|
"classnames": "2.5.1",
|
|
92
50
|
"dompurify": "3.4.15",
|
|
51
|
+
"katex": "^0.16.22",
|
|
52
|
+
"react-markdown": "^10.1.0",
|
|
53
|
+
"react-syntax-highlighter": "^16.1.1",
|
|
54
|
+
"rehype-katex": "^7.0.1",
|
|
55
|
+
"rehype-raw": "^7.0.0",
|
|
56
|
+
"rehype-sanitize": "^6.0.0",
|
|
93
57
|
"rehype-stringify": "^10.0.1",
|
|
58
|
+
"remark-breaks": "^4.0.0",
|
|
59
|
+
"remark-gfm": "^4.0.1",
|
|
60
|
+
"remark-math": "^6.0.0",
|
|
94
61
|
"remark-parse": "^11.0.0",
|
|
95
62
|
"remark-rehype": "^11.1.2",
|
|
96
63
|
"tailwind-merge": "^3.6.0",
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { MIMEType as e } from "../types/mime-type.js";
|
|
2
|
+
import { inferMimeTypeFromPath as t } from "./mime-type.js";
|
|
3
|
+
//#region src/utils/annotation.ts
|
|
4
|
+
var n = {
|
|
5
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
6
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
7
|
+
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
|
8
|
+
}, r = (e) => {
|
|
9
|
+
let r = t(e);
|
|
10
|
+
if (r != null) return r;
|
|
11
|
+
let i = e.split(/[?#]/)[0], a = i.lastIndexOf(".");
|
|
12
|
+
if (a !== -1) return n[i.slice(a + 1).toLowerCase()];
|
|
13
|
+
}, i = (e) => typeof e == "object" && !!e && !Array.isArray(e) && "type" in e && typeof e.type == "string", a = (e) => Array.isArray(e) ? e.filter(i) : i(e) ? e : void 0, o = (e) => typeof e == "number" ? e : null, s = (e) => {
|
|
14
|
+
if (typeof e != "object" || !e) return null;
|
|
15
|
+
let t = e;
|
|
16
|
+
if (t.type !== "pdf_region") return null;
|
|
17
|
+
let n = t.bbox;
|
|
18
|
+
if (typeof n != "object" || !n) return null;
|
|
19
|
+
let r = n, i = o(r.left), a = o(r.top), s = o(r.width), c = o(r.height);
|
|
20
|
+
return i === null || a === null || s === null || c === null ? null : {
|
|
21
|
+
type: "pdf_bbox",
|
|
22
|
+
page: o(t.page) ?? 1,
|
|
23
|
+
x1: i,
|
|
24
|
+
y1: a,
|
|
25
|
+
x2: i + s,
|
|
26
|
+
y2: a + c
|
|
27
|
+
};
|
|
28
|
+
}, c = (t, n) => {
|
|
29
|
+
let r = t.target;
|
|
30
|
+
if (typeof r != "object" || !r) return null;
|
|
31
|
+
let i = r, a = i.source;
|
|
32
|
+
if (typeof a != "object" || !a) return null;
|
|
33
|
+
let c = o(a.attachment_index);
|
|
34
|
+
if (c === null) return null;
|
|
35
|
+
let l = n.find((e) => e.index === c);
|
|
36
|
+
if (l?.url == null) return null;
|
|
37
|
+
let u = s(i.selector);
|
|
38
|
+
if (u === null) return null;
|
|
39
|
+
let d = t.body, f = typeof d == "object" && d ? d : {}, p = typeof f.title == "string" ? f.title : void 0, m = typeof f.quote == "string" ? f.quote : void 0;
|
|
40
|
+
return {
|
|
41
|
+
index: o(t.index) ?? void 0,
|
|
42
|
+
body: {
|
|
43
|
+
title: p,
|
|
44
|
+
quote: m,
|
|
45
|
+
source: {
|
|
46
|
+
type: "attachment",
|
|
47
|
+
attachment: {
|
|
48
|
+
type: l.type ?? e.PDF,
|
|
49
|
+
url: l.url,
|
|
50
|
+
title: l.title
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
selector: u
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}, l = (t) => {
|
|
57
|
+
let n = t.target;
|
|
58
|
+
if (typeof n != "object" || !n) return null;
|
|
59
|
+
let i = n.selector;
|
|
60
|
+
if (typeof i != "object" || !i) return null;
|
|
61
|
+
let s = i;
|
|
62
|
+
if (s.type !== "html_tag" || typeof s.tag != "string" || typeof s.id != "string") return null;
|
|
63
|
+
let c = {
|
|
64
|
+
type: "html_tag",
|
|
65
|
+
tag: s.tag,
|
|
66
|
+
id: s.id
|
|
67
|
+
}, l = t.body;
|
|
68
|
+
if (typeof l != "object" || !l) return null;
|
|
69
|
+
let u = l, d = u.source;
|
|
70
|
+
if (typeof d != "object" || !d) return null;
|
|
71
|
+
let f = d;
|
|
72
|
+
if (f.type !== "attachment") return null;
|
|
73
|
+
let p = f.url;
|
|
74
|
+
if (typeof p != "string") return null;
|
|
75
|
+
let m = typeof u.title == "string" ? u.title : void 0, h = typeof u.quote == "string" ? u.quote : void 0, g = a(u.selector);
|
|
76
|
+
return {
|
|
77
|
+
index: o(t.index) ?? void 0,
|
|
78
|
+
target: { selector: c },
|
|
79
|
+
body: {
|
|
80
|
+
title: m,
|
|
81
|
+
quote: h,
|
|
82
|
+
...g === void 0 ? {} : { selector: g },
|
|
83
|
+
source: {
|
|
84
|
+
type: "attachment",
|
|
85
|
+
attachment: {
|
|
86
|
+
type: r(p) ?? e.PDF,
|
|
87
|
+
url: p,
|
|
88
|
+
title: m
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}, u = (e) => {
|
|
94
|
+
if (e.target?.selector?.type !== "html_tag") return e;
|
|
95
|
+
let t = e.body?.source?.attachment;
|
|
96
|
+
if (t?.url == null) return e;
|
|
97
|
+
let n = r(t.url);
|
|
98
|
+
return n == null || n === t.type ? e : {
|
|
99
|
+
...e,
|
|
100
|
+
body: {
|
|
101
|
+
...e.body,
|
|
102
|
+
source: {
|
|
103
|
+
...e.body?.source,
|
|
104
|
+
type: "attachment",
|
|
105
|
+
attachment: {
|
|
106
|
+
...t,
|
|
107
|
+
type: n
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}, d = (e, t) => e.flatMap((e) => {
|
|
113
|
+
if (typeof e != "object" || !e) return [];
|
|
114
|
+
let n = e, r = l(n);
|
|
115
|
+
if (r) return [r];
|
|
116
|
+
let i = c(n, t);
|
|
117
|
+
return i ? [i] : [];
|
|
118
|
+
});
|
|
119
|
+
//#endregion
|
|
120
|
+
export { i as isAnnotationSelector, u as normalizePersistedHtmlTagAttachmentType, d as normalizeRawAnnotations };
|