@epam/ai-dial-chat-hooks 1.2.0-dev.21 → 1.2.0-dev.213

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.
Files changed (89) hide show
  1. package/api-error/api-error.js +5 -4
  2. package/attachment/useAttachmentValidation/useAttachmentValidation.js +26 -19
  3. package/attachments.d.ts +10 -4
  4. package/catalog/catalog-derivations.js +1 -1
  5. package/catalog/deployment-id.js +8 -2
  6. package/catalog/map-deployment-limits-to-input.js +81 -9
  7. package/catalog/map-deployment-to-catalog-item.js +34 -34
  8. package/catalog/map-entity-details-to-catalog.js +7 -0
  9. package/catalog/map-skill-to-catalog-item.js +30 -27
  10. package/catalog/publish.js +6 -5
  11. package/catalog/useApplicationCredentials/useApplicationCredentials.js +39 -0
  12. package/catalog/useSkillDetailsPanelData/useSkillDetailsPanelData.js +39 -39
  13. package/catalog/useSkillItemDetails.js +17 -13
  14. package/catalog.d.ts +116 -20
  15. package/catalog.js +23 -22
  16. package/conversation/conversation-transfer/export-conversation.js +24 -16
  17. package/conversation/conversation-transfer/import-conversation.js +80 -31
  18. package/conversation/conversation-transfer/queue.js +8 -5
  19. package/conversation/create-chat-stream-api.js +85 -49
  20. package/conversation/message-utils.js +44 -2
  21. package/conversation/stage.js +23 -0
  22. package/conversation/useConversationExport/useConversationExport.js +9 -9
  23. package/conversation/useConversationHandlers/useConversationHandlers.js +16 -5
  24. package/conversation/useConversationImport/useConversationImport.js +123 -121
  25. package/conversation/useConversationPanelItems/useConversationPanelItems.js +2 -3
  26. package/conversation/useConversationScroll/useConversationScroll.js +68 -64
  27. package/conversation/useConversationStream/apply-chunk.js +1 -1
  28. package/conversation/useConversationStream/generation-resume.js +104 -63
  29. package/conversation/useConversationStream/useConversationStream.js +181 -110
  30. package/conversation/useMessageSelectionReply/useMessageSelectionReply.js +189 -0
  31. package/conversation-overlay.d.ts +7 -0
  32. package/conversation-overlay.js +2 -0
  33. package/conversation-sources/useConversationSources/useConversationSources.js +31 -24
  34. package/conversation-sources.d.ts +1 -1
  35. package/conversation-transfer.d.ts +2 -1
  36. package/conversation.d.ts +241 -13
  37. package/conversation.js +32 -30
  38. package/file-manager-canvas.d.ts +398 -0
  39. package/file-manager-canvas.js +2 -0
  40. package/file-manager.d.ts +153 -350
  41. package/file-manager.js +25 -24
  42. package/files/attachment-canvas.js +40 -1
  43. package/files/attachment-types.js +14 -13
  44. package/files/dial-file-manager-mapping.util.js +2 -1
  45. package/files/dial-file-manager-path.util.js +23 -1
  46. package/files/dial-file-manager.model.js +23 -19
  47. package/files/dial-file-manager.types.js +3 -3
  48. package/files/useDialFileListing/useDialFileListing.js +157 -145
  49. package/files/useDialFileManager/useDialFileManager.js +132 -128
  50. package/files/useDialFileManagerSections/useDialFileManagerSections.js +155 -0
  51. package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.js +20 -19
  52. package/files/useDialFileMutations/useDialFileMutations.js +33 -32
  53. package/files/useDialFileUploadBatch/useDialFileUploadBatch.js +117 -110
  54. package/files/useFileAttachmentPicker/useFileAttachmentPicker.js +43 -0
  55. package/index.d.ts +1068 -81
  56. package/index.js +136 -122
  57. package/mcp-apps/useMcpAppHostAdapter/useMcpAppHostAdapter.js +7 -5
  58. package/mcp-apps/useMcpAppHostContext/useMcpAppHostContext.js +1 -1
  59. package/mcp-apps/useMcpAppTools/useMcpAppTools.js +1 -1
  60. package/mcp-apps/useOpenMcpAppCanvas/useOpenMcpAppCanvas.js +25 -23
  61. package/mcp-apps.d.ts +8 -6
  62. package/oauth/toolset-id.js +5 -3
  63. package/oauth/useToolsetLogin/useToolsetLogin.js +8 -8
  64. package/oauth.d.ts +32 -0
  65. package/oauth.js +9 -9
  66. package/package.json +36 -21
  67. package/scheduled-task/scheduled-task-description.js +77 -0
  68. package/scheduled-task/scheduled-task-preparation.js +24 -0
  69. package/scheduled-task/scheduled-task-trigger.js +7 -2
  70. package/scheduled-task/scheduled-tasks-api-client.js +19 -0
  71. package/scheduled-task/use-scheduled-task-runs.js +194 -0
  72. package/scheduled-task/use-scheduled-tasks.js +93 -0
  73. package/scheduled-tasks.d.ts +195 -3
  74. package/scheduled-tasks.js +7 -2
  75. package/skill/skill-archive.js +19 -0
  76. package/skill/skill-types.js +8 -7
  77. package/skill/skill.js +42 -27
  78. package/skill/useSkillArchiveImport/useSkillArchiveImport.js +79 -0
  79. package/skill/useSkillEditorLoad.js +29 -28
  80. package/skill/useSkillEditorSubmit.js +108 -84
  81. package/skill/useSkillFileActions.js +70 -58
  82. package/skill-editor.d.ts +133 -3
  83. package/skill-editor.js +9 -8
  84. package/usage/map-usage-data-to-dashboard.js +66 -0
  85. package/usage/map-user-usage-to-model-limits.js +202 -0
  86. package/usage.d.ts +125 -0
  87. package/usage.js +3 -0
  88. package/usePageFileDrag/usePageFileDrag.js +3 -3
  89. package/utils.d.ts +8 -6
@@ -1,20 +1,20 @@
1
1
  import { formatDateYM as e } from "../conversation-transfer/date.js";
2
2
  import { ConversationTransferWarningCode as t } from "../conversation-transfer/types.js";
3
- import { UnsupportedImportFormatError as n, getFolderBreadcrumb as r, parseImportEnvelope as i, planAttachmentUploads as a, rebaseConversationId as o, rewriteAttachmentUrls as s } from "../conversation-transfer/import-conversation.js";
4
- import { createUploadPathAllocator as c } from "../conversation-transfer/build-upload-path.js";
5
- import { runWithConcurrency as l } from "../conversation-transfer/async.js";
6
- import { ConversationTransferKind as u, ConversationTransferPhase as d, buildTransferProgress as f } from "../conversation-transfer/progress.js";
7
- import { useConversationTransferQueue as p } from "../conversation-transfer/queue.js";
8
- import { parseDialArchive as m } from "../conversation-transfer/zip-import.js";
9
- import { ConversationTransferErrorCode as h, ConversationTransferSubjectKind as g, ConversationTransferUnitKind as _, generateUUID as v } from "@epam/ai-dial-chat-shared";
10
- import { useCallback as y } from "react";
3
+ import { UnsupportedImportFormatError as n, dropForeignAttachmentRefs as r, getFolderBreadcrumb as i, parseImportEnvelope as a, planAttachmentUploads as o, rebaseConversationId as s, rewriteAttachmentUrls as c } from "../conversation-transfer/import-conversation.js";
4
+ import { createUploadPathAllocator as l } from "../conversation-transfer/build-upload-path.js";
5
+ import { runWithConcurrency as u } from "../conversation-transfer/async.js";
6
+ import { ConversationTransferKind as d, ConversationTransferPhase as f, buildTransferProgress as p } from "../conversation-transfer/progress.js";
7
+ import { useConversationTransferQueue as m } from "../conversation-transfer/queue.js";
8
+ import { parseDialArchive as h } from "../conversation-transfer/zip-import.js";
9
+ import { ConversationTransferErrorCode as g, ConversationTransferSubjectKind as _, ConversationTransferUnitKind as v, generateUUID as y } from "@epam/ai-dial-chat-shared";
10
+ import { useCallback as b } from "react";
11
11
  //#region src/conversation/useConversationImport/useConversationImport.ts
12
- var b = 5, x = 5, S = (e) => /\.(dial|zip)$/i.test(e.name), C = (e) => new Promise((t, n) => {
12
+ var x = 5, S = 5, C = (e) => /\.(dial|zip)$/i.test(e.name), w = (e) => new Promise((t, n) => {
13
13
  let r = new FileReader();
14
14
  r.onload = () => t(r.result), r.onerror = () => n(r.error), r.readAsText(e);
15
- }), w = async (e) => {
16
- if (S(e)) {
17
- let { envelope: t, attachments: n } = await m(e);
15
+ }), T = async (e) => {
16
+ if (C(e)) {
17
+ let { envelope: t, attachments: n } = await h(e);
18
18
  return {
19
19
  history: t.history,
20
20
  attachments: n,
@@ -22,15 +22,15 @@ var b = 5, x = 5, S = (e) => /\.(dial|zip)$/i.test(e.name), C = (e) => new Promi
22
22
  };
23
23
  }
24
24
  return {
25
- history: i(await C(e)).history,
25
+ history: a(await w(e)).history,
26
26
  attachments: /* @__PURE__ */ new Map(),
27
27
  isArchive: !1
28
28
  };
29
- }, T = async (e, t, n, r, i, o, s, c) => {
30
- let { plan: u, skippedNames: d } = a(e, t, r), f = !1, p = await l(u, b, async (e) => {
29
+ }, E = async (e, t, n, r, i, a, s, c) => {
30
+ let { plan: l, skippedNames: d } = o(e, t, r), f = !1, p = await u(l, x, async (e) => {
31
31
  if (c.aborted || f) return;
32
32
  let t = e.allocated;
33
- for (let a = 0; a <= x; a += 1) try {
33
+ for (let o = 0; o <= S; o += 1) try {
34
34
  let r = new File([new Uint8Array(e.bytes)], t.fileName), a = await i.uploadFile({
35
35
  bucket: n,
36
36
  path: t.path,
@@ -45,11 +45,11 @@ var b = 5, x = 5, S = (e) => /\.(dial|zip)$/i.test(e.name), C = (e) => new Promi
45
45
  };
46
46
  } catch (n) {
47
47
  if (c.aborted) return;
48
- if (o(n)) {
48
+ if (a(n)) {
49
49
  f = !0;
50
50
  return;
51
51
  }
52
- if (!(typeof n == "object" && n && "response" in n && n.response?.status === 409) || a === x) return s(), {
52
+ if (!(typeof n == "object" && n && "response" in n && n.response?.status === 409) || o === S) return s(), {
53
53
  kind: "skipped",
54
54
  name: e.originalFileName
55
55
  };
@@ -69,171 +69,173 @@ var b = 5, x = 5, S = (e) => /\.(dial|zip)$/i.test(e.name), C = (e) => new Promi
69
69
  skippedNames: c.aborted || f ? [] : h,
70
70
  isUnauthorized: !c.aborted && f
71
71
  };
72
- }, E = ({ conversationsApi: i, filesApi: a, bucket: l, onImported: m, classifyTransferError: b = () => ({}), resolveErrorTraceId: x = async () => void 0, onSuccess: S, onWarning: C, onError: E }) => {
73
- let D = p(), O = y(async (n, r, p) => {
74
- if (!l) {
75
- E?.({
72
+ }, D = ({ conversationsApi: a, filesApi: o, bucket: u, onImported: h, classifyTransferError: x = () => ({}), resolveErrorTraceId: S = async () => void 0, onSuccess: C, onWarning: w, onError: D }) => {
73
+ let O = m(), k = b(async (n, i, m) => {
74
+ if (!u) {
75
+ D?.({
76
76
  jobId: n,
77
- code: h.MissingBucket
78
- }), D.failJob(n, h.MissingBucket);
77
+ code: g.MissingBucket
78
+ }), O.failJob(n, g.MissingBucket);
79
79
  return;
80
80
  }
81
- let g = u.Import, v = r.attachments.size, y = 0, w = () => {
82
- y += 1, D.setJobProgress(n, f({
83
- kind: g,
84
- phase: d.Transfer,
85
- completed: y,
86
- total: v
81
+ let _ = d.Import, y = i.attachments.size, b = 0, T = () => {
82
+ b += 1, O.setJobProgress(n, p({
83
+ kind: _,
84
+ phase: f.Transfer,
85
+ completed: b,
86
+ total: y
87
87
  }, {
88
- completed: Math.min(y, v),
89
- total: v,
90
- kind: _.Attachment
88
+ completed: Math.min(b, y),
89
+ total: y,
90
+ kind: v.Attachment
91
91
  }));
92
- }, O = (e) => {
93
- D.setJobProgress(n, f({
94
- kind: g,
95
- phase: d.Finalize,
92
+ }, k = (e) => {
93
+ O.setJobProgress(n, p({
94
+ kind: _,
95
+ phase: f.Finalize,
96
96
  completed: e,
97
- total: r.history.length
97
+ total: i.history.length
98
98
  }, {
99
99
  completed: e,
100
- total: r.history.length,
101
- kind: _.Conversation
100
+ total: i.history.length,
101
+ kind: v.Conversation
102
102
  }));
103
- }, k = [], A = [], j = /* @__PURE__ */ new Set(), M = !1, N, P = /* @__PURE__ */ new Date(), F = (e) => !!b(e).isUnauthorized, I;
104
- if (r.isArchive) {
105
- let t = `uploads/${e(P)}`, r = [];
103
+ }, A = [], j = [], M = /* @__PURE__ */ new Set(), N = !1, P, F = /* @__PURE__ */ new Date(), I = (e) => !!x(e).isUnauthorized, L;
104
+ if (i.isArchive) {
105
+ let t = `uploads/${e(F)}`, r = [];
106
106
  try {
107
- r = (await a.listFiles({
108
- bucket: l,
107
+ r = (await o.listFiles({
108
+ bucket: u,
109
109
  path: t
110
- }, { signal: p })).items.map((e) => e.name);
110
+ }, { signal: m })).items.map((e) => e.name);
111
111
  } catch (e) {
112
- if (p.aborted) return;
113
- if (F(e)) {
114
- E?.({
112
+ if (m.aborted) return;
113
+ if (I(e)) {
114
+ D?.({
115
115
  jobId: n,
116
- code: h.Unauthorized
117
- }), D.failJob(n, h.Unauthorized);
116
+ code: g.Unauthorized
117
+ }), O.failJob(n, g.Unauthorized);
118
118
  return;
119
119
  }
120
120
  console.error("Failed to list the upload folder for attachment name disambiguation", e);
121
121
  }
122
- I = c({
123
- date: P,
122
+ L = l({
123
+ date: F,
124
124
  existingNames: r
125
125
  });
126
126
  }
127
- D.setJobProgress(n, f({
128
- kind: g,
129
- phase: d.Prepare
130
- })), v === 0 && D.setJobProgress(n, f({
131
- kind: g,
132
- phase: d.Transfer
127
+ O.setJobProgress(n, p({
128
+ kind: _,
129
+ phase: f.Prepare
130
+ })), y === 0 && O.setJobProgress(n, p({
131
+ kind: _,
132
+ phase: f.Transfer
133
133
  }));
134
- for (let e of r.history) {
135
- if (p.aborted) return;
136
- if (M) break;
134
+ for (let e of i.history) {
135
+ if (m.aborted) return;
136
+ if (N) break;
137
137
  try {
138
138
  let t = /* @__PURE__ */ new Map();
139
- if (r.isArchive && I) {
140
- let n = await T(e, r.attachments, l, I, a, F, w, p);
141
- if (p.aborted) return;
139
+ if (i.isArchive && L) {
140
+ let n = await E(e, i.attachments, u, L, o, I, T, m);
141
+ if (m.aborted) return;
142
142
  if (n.isUnauthorized) {
143
- M = !0;
143
+ N = !0;
144
144
  break;
145
145
  }
146
- for (let e of n.skippedNames) j.add(e);
146
+ for (let e of n.skippedNames) M.add(e);
147
147
  t = n.targetMap;
148
148
  }
149
- let { conversation: n, subPath: c } = o(s(e, t), l);
150
- if (await i.saveConversation({
151
- path: c,
149
+ let { conversation: n, droppedNames: l } = r(c(e, t), u);
150
+ for (let e of l) M.add(e);
151
+ let { conversation: d, subPath: f } = s(n, u);
152
+ if (await a.saveConversation({
153
+ path: f,
152
154
  saveConversationBodyDto: { conversation: {
153
- ...n,
155
+ ...d,
154
156
  llmNamingDone: !0
155
157
  } }
156
- }, { signal: p }), p.aborted) return;
157
- k.push(n.name);
158
+ }, { signal: m }), m.aborted) return;
159
+ A.push(d.name);
158
160
  } catch (t) {
159
- if (p.aborted) return;
160
- if (F(t)) {
161
- M = !0;
161
+ if (m.aborted) return;
162
+ if (I(t)) {
163
+ N = !0;
162
164
  break;
163
165
  }
164
- A.push(e.name), N === void 0 && (N = await x(t)), console.error("Failed to import a conversation", t);
166
+ j.push(e.name), P === void 0 && (P = await S(t)), console.error("Failed to import a conversation", t);
165
167
  }
166
- O(k.length + A.length);
168
+ k(A.length + j.length);
167
169
  }
168
- if (!p.aborted) {
169
- if (M) {
170
- E?.({
170
+ if (!m.aborted) {
171
+ if (N) {
172
+ D?.({
171
173
  jobId: n,
172
- code: h.Unauthorized
173
- }), D.failJob(n, h.Unauthorized);
174
+ code: g.Unauthorized
175
+ }), O.failJob(n, g.Unauthorized);
174
176
  return;
175
177
  }
176
- if (k.length > 0) {
178
+ if (A.length > 0) {
177
179
  try {
178
- await m?.();
180
+ await h?.();
179
181
  } catch {}
180
- S?.({
182
+ C?.({
181
183
  jobId: n,
182
- titles: k
184
+ titles: A
183
185
  });
184
186
  }
185
- A.length > 0 && E?.({
187
+ j.length > 0 && D?.({
186
188
  jobId: n,
187
- code: h.Unknown,
188
- titles: A,
189
- traceId: N
190
- }), j.size > 0 && C?.({
189
+ code: g.Unknown,
190
+ titles: j,
191
+ traceId: P
192
+ }), M.size > 0 && w?.({
191
193
  jobId: n,
192
194
  code: t.AttachmentSkipped,
193
- names: [...j]
194
- }), A.length > 0 ? D.failJob(n, h.Unknown) : j.size > 0 ? D.warnJob(n, t.AttachmentSkipped) : D.succeedJob(n);
195
+ names: [...M]
196
+ }), j.length > 0 ? O.failJob(n, g.Unknown) : M.size > 0 ? O.warnJob(n, t.AttachmentSkipped, [...M]) : O.succeedJob(n);
195
197
  }
196
198
  }, [
197
- l,
198
- b,
199
- i,
199
+ u,
200
+ x,
200
201
  a,
201
- E,
202
- m,
203
- S,
204
- C,
202
+ o,
205
203
  D,
206
- x
207
- ]), k = y(async (e) => {
204
+ h,
205
+ C,
206
+ w,
207
+ O,
208
+ S
209
+ ]), A = b(async (e) => {
208
210
  let t;
209
211
  try {
210
- t = await w(e);
212
+ t = await T(e);
211
213
  } catch (e) {
212
- E?.({
213
- jobId: v(),
214
- code: h.UnsupportedFormat
214
+ D?.({
215
+ jobId: y(),
216
+ code: g.UnsupportedFormat
215
217
  }), e instanceof n || console.error("Failed to parse import file", e);
216
218
  return;
217
219
  }
218
- let i = t.history.length > 1, a = t.history[0], o = i ? { kind: g.All } : {
219
- kind: g.Single,
220
+ let r = t.history.length > 1, a = t.history[0], o = r ? { kind: _.All } : {
221
+ kind: _.Single,
220
222
  title: a?.name ?? e.name,
221
- sourceBreadcrumb: a ? r(a) : void 0
222
- }, s = D.addJob(o, e.name);
223
- return D.startJob(s, (e) => O(s, t, e));
223
+ sourceBreadcrumb: a ? i(a) : void 0
224
+ }, s = O.addJob(o, e.name);
225
+ return O.startJob(s, (e) => k(s, t, e));
224
226
  }, [
225
- E,
226
227
  D,
227
- O
228
+ O,
229
+ k
228
230
  ]);
229
231
  return {
230
- jobs: D.jobs,
231
- importConversations: k,
232
- cancelJob: D.cancelJob,
233
- dismissJob: D.dismissJob,
234
- retryJob: D.retryJob,
235
- dismissAll: D.dismissAll
232
+ jobs: O.jobs,
233
+ importConversations: A,
234
+ cancelJob: O.cancelJob,
235
+ dismissJob: O.dismissJob,
236
+ retryJob: O.retryJob,
237
+ dismissAll: O.dismissAll
236
238
  };
237
239
  };
238
240
  //#endregion
239
- export { E as useConversationImport };
241
+ export { D as useConversationImport };
@@ -4,7 +4,7 @@ import { getModelIdFromConversationId as n } from "../get-model-id-from-conversa
4
4
  import { FilterTab as r } from "@epam/ai-dial-chat-shared";
5
5
  import { useMemo as i } from "react";
6
6
  //#region src/conversation/useConversationPanelItems/useConversationPanelItems.ts
7
- var a = (e) => e.sharedWithMe ? r.Shared : e.publishedWithMe ? r.Organization : r.MyChats, o = ({ items: r, deployments: o, isDeploymentsLoading: s, toPanelConversationId: c, resolveIconUrl: l, resolveIconTooltip: u, resolveHref: d, resolveTaskBadge: f }) => i(() => r.map((r) => {
7
+ var a = (e) => e.sharedWithMe ? r.Shared : e.publishedWithMe ? r.Organization : r.MyChats, o = ({ items: r, deployments: o, isDeploymentsLoading: s, toPanelConversationId: c, resolveIconUrl: l, resolveIconTooltip: u, resolveHref: d, resolveTaskPresentation: f }) => i(() => r.map((r) => {
8
8
  let i = c(r.id), p = n(r.id), m = p ? t(o, p) : void 0, h = p ? e(p.split("/").pop() ?? p) : "", g = f?.(r);
9
9
  return {
10
10
  id: i,
@@ -16,8 +16,7 @@ var a = (e) => e.sharedWithMe ? r.Shared : e.publishedWithMe ? r.Organization :
16
16
  source: a(r),
17
17
  href: d(i),
18
18
  ...g == null ? {} : {
19
- showTaskBadge: !0,
20
- taskBadgeLabel: g.label,
19
+ leadingIcon: g.leadingIcon,
21
20
  isUnread: g.isUnread
22
21
  }
23
22
  };
@@ -1,121 +1,125 @@
1
1
  import { useCallback as e, useEffect as t, useLayoutEffect as n, useRef as r, useState as i } from "react";
2
2
  //#region src/conversation/useConversationScroll/useConversationScroll.ts
3
3
  var a = 80, o = 1, s = ({ messages: s, isAssistantTyping: c, conversationId: l }) => {
4
- let [u, d] = i(!1), f = r(null), p = r(null), m = r(null), h = r(!1), g = r(!1), _ = r(null), v = r(/* @__PURE__ */ new Map()), y = e((e, t) => {
5
- t ? v.current.set(e, t) : v.current.delete(e);
6
- }, []), b = r(null), x = e((e) => {
7
- b.current = e;
8
- }, []), S = e((e, t) => {
4
+ let [u, d] = i(!1), f = r(null), p = r(null), m = r(null), h = r(!1), g = r(!1), _ = r(null), v = r(!0), y = r(/* @__PURE__ */ new Map()), b = e((e, t) => {
5
+ t ? y.current.set(e, t) : y.current.delete(e);
6
+ }, []), x = r(null), S = e((e) => {
7
+ x.current = e;
8
+ }, []), C = e((e, t) => {
9
9
  let n = f.current;
10
10
  n && n.scrollTo({
11
11
  top: e,
12
12
  behavior: t ? "instant" : "smooth"
13
13
  });
14
- }, []), C = e(() => {
15
- m.current && (m.current.style.height = "0px"), h.current = !1, g.current = !1, _.current = null;
16
14
  }, []), w = e(() => {
15
+ m.current && (m.current.style.height = "0px"), h.current = !1, g.current = !1, _.current = null;
16
+ }, []), T = e(() => {
17
17
  let e = f.current, t = p.current;
18
18
  if (!e || !t) return null;
19
19
  let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
20
20
  return e.scrollTop + (r.bottom - n.top) - e.clientHeight;
21
- }, []), T = e((e = !1) => {
22
- let t = w();
23
- t != null && S(Math.max(t, 0), e);
24
- }, [S, w]), E = e(() => {
21
+ }, []), E = e((e = !1) => {
22
+ let t = T();
23
+ t != null && C(Math.max(t, 0), e);
24
+ }, [C, T]), D = e(() => {
25
25
  let e = f.current, t = p.current;
26
26
  if (!e || !t) return null;
27
27
  let n = e.getBoundingClientRect();
28
28
  return t.getBoundingClientRect().bottom - n.top - e.clientHeight;
29
- }, []), D = e(() => {
29
+ }, []), O = e(() => {
30
30
  if (!g.current) return;
31
- let e = E();
32
- e == null || e < -1 || C();
33
- }, [C, E]), O = e((e) => {
34
- let t = f.current, n = v.current.get(e);
31
+ let e = D();
32
+ e == null || e < -1 || w();
33
+ }, [w, D]), k = e((e) => {
34
+ let t = f.current, n = y.current.get(e);
35
35
  if (!t || !n) return null;
36
36
  let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = t.scrollTop + (i.top - r.top);
37
37
  return Math.max(a, 0);
38
- }, []), k = e((e, t = !1) => {
39
- let n = O(e);
40
- n != null && S(n, t);
41
- }, [O, S]), A = e(() => {
42
- let e = w();
38
+ }, []), A = e((e, t = !1) => {
39
+ let n = k(e);
40
+ n != null && C(n, t);
41
+ }, [k, C]), j = e(() => {
42
+ let e = T();
43
43
  return e == null ? null : Math.max(e, 0);
44
- }, [w]), j = e(() => {
44
+ }, [T]), M = e(() => {
45
45
  if (!h.current) return null;
46
- let e = _.current, t = A();
46
+ let e = _.current, t = j();
47
47
  return e == null || t == null ? null : Math.max(e, t);
48
- }, [A]), M = e(() => {
49
- let e = f.current, t = j();
48
+ }, [j]), N = e(() => {
49
+ let e = f.current, t = M();
50
50
  !e || t == null || e.scrollTop > t + o && (e.scrollTop = t);
51
- }, [j]), N = e((e) => {
52
- let t = m.current, n = A();
51
+ }, [M]), P = e((e) => {
52
+ let t = m.current, n = j();
53
53
  if (!t || n == null) return;
54
54
  let r = Math.max(e - n, 0);
55
55
  t.style.height = `${r}px`, h.current = r > 0, g.current = !1, _.current = r > 0 ? e : null;
56
- }, [A]), P = e((e) => {
57
- let t = O(e);
58
- t != null && (N(t), k(e, !1));
56
+ }, [j]), F = e((e) => {
57
+ let t = k(e);
58
+ t != null && (P(t), A(e, !1));
59
59
  }, [
60
- N,
61
- O,
62
- k
63
- ]), F = e(() => {
64
- let e = E();
65
- e != null && d(e >= a);
66
- }, [E]), I = r(s.length), L = r(null);
60
+ P,
61
+ k,
62
+ A
63
+ ]), I = e(() => {
64
+ let e = D();
65
+ if (e == null) return;
66
+ let t = e < a;
67
+ v.current = t, d(!t);
68
+ }, [D]), L = r(s.length), R = r(null);
67
69
  n(() => {
68
- let e = s.length !== I.current, t = l !== L.current, n = () => {
69
- I.current = s.length, L.current = l;
70
+ let e = s.length !== L.current, t = l !== R.current, n = () => {
71
+ L.current = s.length, R.current = l;
70
72
  };
71
- t && C();
72
- let r = b.current;
73
- if (r != null && v.current.has(r)) {
74
- b.current = null, P(r), n();
73
+ t && w();
74
+ let r = x.current;
75
+ if (r != null && y.current.has(r)) {
76
+ x.current = null, F(r), n();
75
77
  return;
76
78
  }
77
- c || ((e || t) && T(!1), n());
79
+ c || ((e || t) && E(!1), n());
78
80
  }, [
79
81
  s,
80
82
  c,
81
83
  l,
82
- T,
83
- P,
84
- C
84
+ E,
85
+ F,
86
+ w
85
87
  ]), n(() => {
86
- !c && h.current && (g.current = !0, D());
87
- }, [c, D]);
88
- let R = e(() => {
89
- M(), D(), F();
88
+ !c && h.current && (g.current = !0, O());
89
+ }, [c, O]);
90
+ let z = e(() => {
91
+ N(), O(), I();
90
92
  }, [
91
- M,
92
- D,
93
- F
93
+ N,
94
+ O,
95
+ I
94
96
  ]);
95
97
  return t(() => {
96
98
  let e = f.current;
97
- if (e) return e.addEventListener("scroll", R, { passive: !0 }), () => e.removeEventListener("scroll", R);
98
- }, [R]), t(() => {
99
+ if (e) return e.addEventListener("scroll", z, { passive: !0 }), () => e.removeEventListener("scroll", z);
100
+ }, [z]), t(() => {
99
101
  let e = p.current;
100
102
  if (!e) return;
101
103
  let t = new ResizeObserver(() => {
102
- M(), D(), F();
104
+ let e = v.current && !h.current;
105
+ N(), e && E(!0), O(), I();
103
106
  });
104
107
  return t.observe(e), () => t.disconnect();
105
108
  }, [
106
- M,
107
- D,
108
- F
109
+ N,
110
+ O,
111
+ I,
112
+ E
109
113
  ]), {
110
114
  containerRef: f,
111
115
  contentRef: p,
112
116
  spacerRef: m,
113
- setMessageRef: y,
117
+ setMessageRef: b,
114
118
  isScrollButtonVisible: u,
115
119
  scrollToBottom: e(() => {
116
- T(!1);
117
- }, [T]),
118
- armAnchor: x
120
+ E(!1);
121
+ }, [E]),
122
+ armAnchor: S
119
123
  };
120
124
  };
121
125
  //#endregion
@@ -75,4 +75,4 @@ var t = (e) => {
75
75
  });
76
76
  };
77
77
  //#endregion
78
- export { o as applyChunkToMessages };
78
+ export { o as applyChunkToMessages, a as mergeStages };