@meshagent/meshagent-tailwind 0.47.0 → 0.48.0

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 (79) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/chat/agent-thread.d.ts +24 -24
  3. package/dist/cjs/chat/agent-thread.js +575 -808
  4. package/dist/cjs/chat/chat-bot-view.d.ts +18 -6
  5. package/dist/cjs/chat/chat-bot-view.js +29 -7
  6. package/dist/cjs/chat/chat-feed-widget-view.d.ts +7 -0
  7. package/dist/cjs/chat/chat-feed-widget-view.js +50 -0
  8. package/dist/cjs/chat/chat-feed-widget.d.ts +16 -0
  9. package/dist/cjs/chat/chat-feed-widget.js +51 -0
  10. package/dist/cjs/chat/chat-hooks.d.ts +2 -2
  11. package/dist/cjs/chat/chat-input.d.ts +3 -3
  12. package/dist/cjs/chat/chat-input.js +9 -4
  13. package/dist/cjs/chat/chat-scroller.d.ts +21 -0
  14. package/dist/cjs/chat/chat-scroller.js +139 -0
  15. package/dist/cjs/chat/chat-thread-timeline.d.ts +66 -0
  16. package/dist/cjs/chat/chat-thread-timeline.js +595 -0
  17. package/dist/cjs/chat/dataset-agent-thread.d.ts +16 -4
  18. package/dist/cjs/chat/dataset-agent-thread.js +112 -292
  19. package/dist/cjs/chat/multi-thread-view.d.ts +8 -3
  20. package/dist/cjs/chat/multi-thread-view.js +10 -2
  21. package/dist/cjs/chat/new-chat-thread.d.ts +8 -3
  22. package/dist/cjs/chat/new-chat-thread.js +63 -24
  23. package/dist/cjs/chat/thread-view.d.ts +18 -5
  24. package/dist/cjs/chat/thread-view.js +67 -9
  25. package/dist/cjs/chat/use-chat-virtualizer.d.ts +47 -0
  26. package/dist/cjs/chat/use-chat-virtualizer.js +336 -0
  27. package/dist/cjs/chat/virtualization.d.ts +44 -0
  28. package/dist/cjs/chat/virtualization.js +143 -0
  29. package/dist/cjs/components/ui/button.d.ts +2 -2
  30. package/dist/cjs/components/ui/dialog.d.ts +1 -1
  31. package/dist/cjs/components/ui/dialog.js +11 -1
  32. package/dist/cjs/components/ui/portal-container.d.ts +7 -0
  33. package/dist/cjs/components/ui/portal-container.js +46 -0
  34. package/dist/cjs/file-preview/file-preview.js +1 -1
  35. package/dist/cjs/index.d.ts +3 -0
  36. package/dist/cjs/index.js +4 -0
  37. package/dist/cjs/meetings/meeting-scope.d.ts +2 -1
  38. package/dist/cjs/meetings/meeting-scope.js +1 -0
  39. package/dist/cjs/react-syntax-highlighter.d.js +1 -0
  40. package/dist/esm/chat/agent-thread.d.ts +24 -24
  41. package/dist/esm/chat/agent-thread.js +574 -838
  42. package/dist/esm/chat/chat-bot-view.d.ts +18 -6
  43. package/dist/esm/chat/chat-bot-view.js +29 -7
  44. package/dist/esm/chat/chat-feed-widget-view.d.ts +7 -0
  45. package/dist/esm/chat/chat-feed-widget-view.js +30 -0
  46. package/dist/esm/chat/chat-feed-widget.d.ts +16 -0
  47. package/dist/esm/chat/chat-feed-widget.js +31 -0
  48. package/dist/esm/chat/chat-hooks.d.ts +2 -2
  49. package/dist/esm/chat/chat-input.d.ts +3 -3
  50. package/dist/esm/chat/chat-input.js +9 -4
  51. package/dist/esm/chat/chat-scroller.d.ts +21 -0
  52. package/dist/esm/chat/chat-scroller.js +122 -0
  53. package/dist/esm/chat/chat-thread-timeline.d.ts +66 -0
  54. package/dist/esm/chat/chat-thread-timeline.js +605 -0
  55. package/dist/esm/chat/dataset-agent-thread.d.ts +16 -4
  56. package/dist/esm/chat/dataset-agent-thread.js +114 -307
  57. package/dist/esm/chat/multi-thread-view.d.ts +8 -3
  58. package/dist/esm/chat/multi-thread-view.js +10 -2
  59. package/dist/esm/chat/new-chat-thread.d.ts +8 -3
  60. package/dist/esm/chat/new-chat-thread.js +64 -25
  61. package/dist/esm/chat/thread-view.d.ts +18 -5
  62. package/dist/esm/chat/thread-view.js +67 -9
  63. package/dist/esm/chat/use-chat-virtualizer.d.ts +47 -0
  64. package/dist/esm/chat/use-chat-virtualizer.js +331 -0
  65. package/dist/esm/chat/virtualization.d.ts +44 -0
  66. package/dist/esm/chat/virtualization.js +123 -0
  67. package/dist/esm/components/ui/button.d.ts +2 -2
  68. package/dist/esm/components/ui/dialog.d.ts +1 -1
  69. package/dist/esm/components/ui/dialog.js +11 -1
  70. package/dist/esm/components/ui/portal-container.d.ts +7 -0
  71. package/dist/esm/components/ui/portal-container.js +16 -0
  72. package/dist/esm/file-preview/file-preview.js +1 -1
  73. package/dist/esm/index.d.ts +3 -0
  74. package/dist/esm/index.js +4 -0
  75. package/dist/esm/meetings/meeting-scope.d.ts +2 -1
  76. package/dist/esm/meetings/meeting-scope.js +1 -0
  77. package/dist/esm/react-syntax-highlighter.d.js +0 -0
  78. package/dist/index.css +1 -1
  79. package/package.json +6 -5
@@ -0,0 +1,336 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var use_chat_virtualizer_exports = {};
20
+ __export(use_chat_virtualizer_exports, {
21
+ chatVirtualizerReducer: () => chatVirtualizerReducer,
22
+ clampVisibleRange: () => clampVisibleRange,
23
+ createChatVirtualizerState: () => createChatVirtualizerState,
24
+ getInitialVisibleRange: () => getInitialVisibleRange,
25
+ useChatVirtualizer: () => useChatVirtualizer
26
+ });
27
+ module.exports = __toCommonJS(use_chat_virtualizer_exports);
28
+ var import_react = require("react");
29
+ var import_virtualization = require("./virtualization.js");
30
+ function getInitialVisibleRange(pageCount, overscanPages) {
31
+ if (pageCount === 0) {
32
+ return { first: 0, last: -1 };
33
+ }
34
+ return {
35
+ first: Math.max(0, pageCount - 1 - Math.max(0, overscanPages)),
36
+ last: pageCount - 1
37
+ };
38
+ }
39
+ function clampVisibleRange(range, pageCount) {
40
+ if (pageCount === 0) {
41
+ return { first: 0, last: -1 };
42
+ }
43
+ return {
44
+ first: Math.min(pageCount - 1, Math.max(0, range.first)),
45
+ last: Math.min(pageCount - 1, Math.max(0, range.last))
46
+ };
47
+ }
48
+ function createChatVirtualizerState({
49
+ pageCount,
50
+ overscanPages
51
+ }) {
52
+ return {
53
+ visibleRange: getInitialVisibleRange(pageCount, overscanPages),
54
+ measuredHeights: /* @__PURE__ */ new Map(),
55
+ bottomAdjustment: 0
56
+ };
57
+ }
58
+ function areRangesEqual(firstRange, secondRange) {
59
+ return firstRange.first === secondRange.first && firstRange.last === secondRange.last;
60
+ }
61
+ function pruneMeasuredHeights(measuredHeights, pageCount) {
62
+ let didPrune = false;
63
+ const nextMeasuredHeights = /* @__PURE__ */ new Map();
64
+ for (const [pageIndex, height] of measuredHeights) {
65
+ if (pageIndex >= pageCount) {
66
+ didPrune = true;
67
+ continue;
68
+ }
69
+ nextMeasuredHeights.set(pageIndex, height);
70
+ }
71
+ return didPrune ? nextMeasuredHeights : measuredHeights;
72
+ }
73
+ function chatVirtualizerReducer(state, action) {
74
+ switch (action.type) {
75
+ case "setVisibleRange": {
76
+ if (areRangesEqual(state.visibleRange, action.range)) {
77
+ return state;
78
+ }
79
+ return {
80
+ ...state,
81
+ visibleRange: action.range
82
+ };
83
+ }
84
+ case "syncPageWindow": {
85
+ const visibleRange = state.visibleRange.last === -1 ? getInitialVisibleRange(action.pageCount, action.overscanPages) : clampVisibleRange(state.visibleRange, action.pageCount);
86
+ const measuredHeights = pruneMeasuredHeights(state.measuredHeights, action.pageCount);
87
+ if (areRangesEqual(state.visibleRange, visibleRange) && measuredHeights === state.measuredHeights) {
88
+ return state;
89
+ }
90
+ return {
91
+ ...state,
92
+ visibleRange,
93
+ measuredHeights
94
+ };
95
+ }
96
+ case "measurePage": {
97
+ const roundedHeight = Math.ceil(action.height);
98
+ const previousHeight = state.measuredHeights.get(action.pageIndex) ?? 0;
99
+ if (previousHeight === roundedHeight) {
100
+ return state;
101
+ }
102
+ const heightDelta = roundedHeight - previousHeight;
103
+ const measuredHeights = new Map(state.measuredHeights);
104
+ if (roundedHeight > 0) {
105
+ measuredHeights.set(action.pageIndex, roundedHeight);
106
+ } else {
107
+ measuredHeights.delete(action.pageIndex);
108
+ }
109
+ return {
110
+ ...state,
111
+ measuredHeights,
112
+ bottomAdjustment: state.bottomAdjustment + (action.shouldAdjustBottom ? heightDelta : 0)
113
+ };
114
+ }
115
+ case "clearBottomAdjustment": {
116
+ if (state.bottomAdjustment === 0) {
117
+ return state;
118
+ }
119
+ return {
120
+ ...state,
121
+ bottomAdjustment: 0
122
+ };
123
+ }
124
+ }
125
+ }
126
+ function getMessageSelector(messageId) {
127
+ const escapedMessageId = typeof CSS !== "undefined" && typeof CSS.escape === "function" ? CSS.escape(messageId) : messageId.replace(/"/gu, '\\"');
128
+ return '.chat-scroll__message[data-message-id="' + escapedMessageId + '"]';
129
+ }
130
+ function captureScrollAnchor(scrollElement, runtime) {
131
+ if (!scrollElement || runtime.isAtBottom) {
132
+ runtime.anchor = void 0;
133
+ return void 0;
134
+ }
135
+ const scrollRect = scrollElement.getBoundingClientRect();
136
+ const messageElements = scrollElement.querySelectorAll(
137
+ ".chat-scroll__message[data-message-id]"
138
+ );
139
+ for (let index = 0; index < messageElements.length; index += 1) {
140
+ const messageElement = messageElements.item(index);
141
+ const messageRect = messageElement.getBoundingClientRect();
142
+ if (messageRect.bottom > scrollRect.top) {
143
+ const messageId = messageElement.dataset.messageId;
144
+ const closestPageElement = messageElement.closest(
145
+ ".chat-scroll__page[data-page-index]"
146
+ );
147
+ const pageIndex = closestPageElement instanceof HTMLElement ? Number(closestPageElement.dataset.pageIndex) : Number.NaN;
148
+ if (messageId && Number.isInteger(pageIndex)) {
149
+ const anchor = {
150
+ messageId,
151
+ offsetTop: messageRect.top - scrollRect.top,
152
+ pageIndex
153
+ };
154
+ runtime.anchor = anchor;
155
+ return anchor;
156
+ }
157
+ runtime.anchor = void 0;
158
+ return void 0;
159
+ }
160
+ }
161
+ runtime.anchor = void 0;
162
+ return void 0;
163
+ }
164
+ function restoreScrollAnchor(scrollElement, runtime, bottomAdjustment) {
165
+ const anchor = runtime.anchor;
166
+ if (!anchor || !scrollElement || runtime.isAtBottom) {
167
+ runtime.anchor = void 0;
168
+ return bottomAdjustment !== 0;
169
+ }
170
+ const messageElement = scrollElement.querySelector(
171
+ getMessageSelector(anchor.messageId)
172
+ );
173
+ if (!messageElement) {
174
+ runtime.anchor = void 0;
175
+ return bottomAdjustment !== 0;
176
+ }
177
+ const scrollRect = scrollElement.getBoundingClientRect();
178
+ const messageRect = messageElement.getBoundingClientRect();
179
+ const nextOffsetTop = messageRect.top - scrollRect.top;
180
+ const offsetDelta = nextOffsetTop - anchor.offsetTop;
181
+ if (offsetDelta !== 0) {
182
+ scrollElement.scrollTop += offsetDelta;
183
+ }
184
+ if (bottomAdjustment !== 0) {
185
+ scrollElement.scrollTop += bottomAdjustment;
186
+ }
187
+ runtime.anchor = void 0;
188
+ return bottomAdjustment !== 0;
189
+ }
190
+ function updateVisibleRange(scrollElement, runtime, dispatch) {
191
+ if (!scrollElement) {
192
+ return;
193
+ }
194
+ const nextRange = (0, import_virtualization.getVisiblePageRange)({
195
+ prefixHeights: runtime.prefixHeights,
196
+ scrollTop: scrollElement.scrollTop,
197
+ viewportHeight: scrollElement.clientHeight,
198
+ overscanPages: runtime.overscanPages
199
+ });
200
+ const clampedNextRange = clampVisibleRange(nextRange, runtime.pageCount);
201
+ if (!areRangesEqual(runtime.visibleRange, clampedNextRange)) {
202
+ captureScrollAnchor(scrollElement, runtime);
203
+ }
204
+ dispatch({ type: "setVisibleRange", range: clampedNextRange });
205
+ }
206
+ function useChatVirtualizer({
207
+ messages,
208
+ pageSize,
209
+ overscanPages,
210
+ bottomThresholdPx,
211
+ getMessageId
212
+ }) {
213
+ const scrollRef = (0, import_react.useRef)(null);
214
+ const runtimeRef = (0, import_react.useRef)({
215
+ isAtBottom: true,
216
+ hasMounted: false,
217
+ lastMessageId: void 0,
218
+ anchor: void 0,
219
+ frameId: void 0,
220
+ prefixHeights: [0],
221
+ visibleRange: { first: 0, last: -1 },
222
+ pageCount: 0,
223
+ overscanPages,
224
+ bottomThresholdPx
225
+ });
226
+ const pages = (0, import_react.useMemo)(
227
+ () => (0, import_virtualization.createPages)([...messages].reverse(), pageSize),
228
+ [messages, pageSize]
229
+ );
230
+ const pageCount = pages.length;
231
+ const [state, dispatch] = (0, import_react.useReducer)(
232
+ chatVirtualizerReducer,
233
+ { pageCount, overscanPages },
234
+ createChatVirtualizerState
235
+ );
236
+ const clampedVisibleRange = clampVisibleRange(state.visibleRange, pageCount);
237
+ const pageHeights = (0, import_react.useMemo)(
238
+ () => (0, import_virtualization.buildPageHeights)(pageCount, state.measuredHeights),
239
+ [pageCount, state.measuredHeights]
240
+ );
241
+ const prefixHeights = (0, import_react.useMemo)(() => (0, import_virtualization.buildPrefixHeights)(pageHeights), [pageHeights]);
242
+ const virtualWindowMetrics = (0, import_virtualization.getVirtualWindowMetrics)(prefixHeights, clampedVisibleRange);
243
+ const visiblePages = clampedVisibleRange.last >= clampedVisibleRange.first ? pages.slice(clampedVisibleRange.first, clampedVisibleRange.last + 1) : [];
244
+ const runtime = runtimeRef.current;
245
+ runtime.prefixHeights = prefixHeights;
246
+ runtime.visibleRange = clampedVisibleRange;
247
+ runtime.pageCount = pageCount;
248
+ runtime.overscanPages = overscanPages;
249
+ runtime.bottomThresholdPx = bottomThresholdPx;
250
+ const handleScroll = (0, import_react.useCallback)(() => {
251
+ const scrollElement = scrollRef.current;
252
+ const currentRuntime = runtimeRef.current;
253
+ if (!scrollElement) {
254
+ return;
255
+ }
256
+ currentRuntime.isAtBottom = (0, import_virtualization.isNearBottom)({
257
+ scrollTop: scrollElement.scrollTop,
258
+ scrollHeight: scrollElement.scrollHeight,
259
+ clientHeight: scrollElement.clientHeight,
260
+ thresholdPx: currentRuntime.bottomThresholdPx
261
+ });
262
+ if (currentRuntime.frameId !== void 0) {
263
+ return;
264
+ }
265
+ currentRuntime.frameId = window.requestAnimationFrame(() => {
266
+ currentRuntime.frameId = void 0;
267
+ updateVisibleRange(scrollRef.current, currentRuntime, dispatch);
268
+ });
269
+ }, []);
270
+ const handlePageHeightChange = (0, import_react.useCallback)((pageIndex, height) => {
271
+ const currentRuntime = runtimeRef.current;
272
+ const anchor = captureScrollAnchor(scrollRef.current, currentRuntime);
273
+ const shouldAdjustBottom = anchor ? (0, import_virtualization.shouldAdjustScrollForHeightChange)({
274
+ changedPageIndex: pageIndex,
275
+ firstVisiblePageIndex: anchor.pageIndex,
276
+ isAtBottom: currentRuntime.isAtBottom
277
+ }) : false;
278
+ dispatch({ type: "measurePage", pageIndex, height, shouldAdjustBottom });
279
+ }, []);
280
+ (0, import_react.useLayoutEffect)(() => {
281
+ const currentRuntime = runtimeRef.current;
282
+ const scrollElement = scrollRef.current;
283
+ const shouldClearBottomAdjustment = restoreScrollAnchor(
284
+ scrollElement,
285
+ currentRuntime,
286
+ state.bottomAdjustment
287
+ );
288
+ if (shouldClearBottomAdjustment) {
289
+ dispatch({ type: "clearBottomAdjustment" });
290
+ }
291
+ if (!scrollElement || !currentRuntime.isAtBottom) {
292
+ return;
293
+ }
294
+ scrollElement.scrollTop = scrollElement.scrollHeight;
295
+ updateVisibleRange(scrollElement, currentRuntime, dispatch);
296
+ });
297
+ (0, import_react.useLayoutEffect)(() => {
298
+ const currentRuntime = runtimeRef.current;
299
+ const scrollElement = scrollRef.current;
300
+ const bottomMessage = messages[0];
301
+ const bottomMessageId = bottomMessage ? getMessageId(bottomMessage) : void 0;
302
+ const previousLastMessageId = currentRuntime.lastMessageId;
303
+ dispatch({ type: "syncPageWindow", pageCount, overscanPages });
304
+ currentRuntime.lastMessageId = bottomMessageId;
305
+ if (!scrollElement) {
306
+ return;
307
+ }
308
+ if (!currentRuntime.hasMounted) {
309
+ scrollElement.scrollTop = scrollElement.scrollHeight;
310
+ currentRuntime.isAtBottom = true;
311
+ currentRuntime.hasMounted = true;
312
+ updateVisibleRange(scrollElement, currentRuntime, dispatch);
313
+ return;
314
+ }
315
+ if (previousLastMessageId !== void 0 && previousLastMessageId !== bottomMessageId && currentRuntime.isAtBottom) {
316
+ scrollElement.scrollTop = scrollElement.scrollHeight;
317
+ updateVisibleRange(scrollElement, currentRuntime, dispatch);
318
+ }
319
+ }, [getMessageId, messages, overscanPages, pageCount]);
320
+ (0, import_react.useEffect)(() => {
321
+ return () => {
322
+ const frameId = runtimeRef.current.frameId;
323
+ if (frameId !== void 0) {
324
+ window.cancelAnimationFrame(frameId);
325
+ }
326
+ };
327
+ }, []);
328
+ return {
329
+ scrollRef,
330
+ visiblePages,
331
+ spacerHeight: virtualWindowMetrics.total,
332
+ windowBottom: virtualWindowMetrics.bottom + state.bottomAdjustment,
333
+ handleScroll,
334
+ handlePageHeightChange
335
+ };
336
+ }
@@ -0,0 +1,44 @@
1
+ export type Page<T> = {
2
+ index: number;
3
+ start: number;
4
+ end: number;
5
+ items: T[];
6
+ };
7
+ export type VisiblePageRange = {
8
+ first: number;
9
+ last: number;
10
+ };
11
+ export type SpacerHeights = {
12
+ top: number;
13
+ bottom: number;
14
+ };
15
+ export type VirtualWindowMetrics = {
16
+ total: number;
17
+ bottom: number;
18
+ };
19
+ export declare const DEFAULT_PAGE_SIZE = 25;
20
+ export declare const DEFAULT_OVERSCAN_PAGES = 2;
21
+ export declare function createPages<T>(items: readonly T[], pageSize: number): Page<T>[];
22
+ export declare function buildPageHeights(pageCount: number, measuredHeights: ReadonlyMap<number, number>): number[];
23
+ export declare function buildPrefixHeights(pageHeights: readonly number[]): number[];
24
+ export declare function getTotalHeight(prefixHeights: readonly number[]): number;
25
+ export declare function findPageIndexForOffset(prefixHeights: readonly number[], offset: number): number;
26
+ export declare function getVisiblePageRange(args: {
27
+ prefixHeights: readonly number[];
28
+ scrollTop: number;
29
+ viewportHeight: number;
30
+ overscanPages: number;
31
+ }): VisiblePageRange;
32
+ export declare function getSpacerHeights(prefixHeights: readonly number[], range: VisiblePageRange): SpacerHeights;
33
+ export declare function getVirtualWindowMetrics(prefixHeights: readonly number[], range: VisiblePageRange): VirtualWindowMetrics;
34
+ export declare function isNearBottom(args: {
35
+ scrollTop: number;
36
+ scrollHeight: number;
37
+ clientHeight: number;
38
+ thresholdPx: number;
39
+ }): boolean;
40
+ export declare function shouldAdjustScrollForHeightChange(args: {
41
+ changedPageIndex: number;
42
+ firstVisiblePageIndex: number;
43
+ isAtBottom: boolean;
44
+ }): boolean;
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var virtualization_exports = {};
20
+ __export(virtualization_exports, {
21
+ DEFAULT_OVERSCAN_PAGES: () => DEFAULT_OVERSCAN_PAGES,
22
+ DEFAULT_PAGE_SIZE: () => DEFAULT_PAGE_SIZE,
23
+ buildPageHeights: () => buildPageHeights,
24
+ buildPrefixHeights: () => buildPrefixHeights,
25
+ createPages: () => createPages,
26
+ findPageIndexForOffset: () => findPageIndexForOffset,
27
+ getSpacerHeights: () => getSpacerHeights,
28
+ getTotalHeight: () => getTotalHeight,
29
+ getVirtualWindowMetrics: () => getVirtualWindowMetrics,
30
+ getVisiblePageRange: () => getVisiblePageRange,
31
+ isNearBottom: () => isNearBottom,
32
+ shouldAdjustScrollForHeightChange: () => shouldAdjustScrollForHeightChange
33
+ });
34
+ module.exports = __toCommonJS(virtualization_exports);
35
+ const DEFAULT_PAGE_SIZE = 25;
36
+ const DEFAULT_OVERSCAN_PAGES = 2;
37
+ function createPages(items, pageSize) {
38
+ if (!Number.isInteger(pageSize) || pageSize <= 0) {
39
+ throw new Error("pageSize must be a positive integer.");
40
+ }
41
+ const pages = [];
42
+ for (let start = 0; start < items.length; start += pageSize) {
43
+ const end = Math.min(start + pageSize, items.length);
44
+ pages.push({
45
+ index: pages.length,
46
+ start,
47
+ end,
48
+ items: items.slice(start, end)
49
+ });
50
+ }
51
+ return pages;
52
+ }
53
+ function buildPageHeights(pageCount, measuredHeights) {
54
+ const heights = [];
55
+ for (let index = 0; index < pageCount; index += 1) {
56
+ const measuredHeight = measuredHeights.get(index);
57
+ heights.push(measuredHeight !== void 0 && measuredHeight > 0 ? measuredHeight : 0);
58
+ }
59
+ return heights;
60
+ }
61
+ function buildPrefixHeights(pageHeights) {
62
+ const prefix = [0];
63
+ for (const height of pageHeights) {
64
+ const previousHeight = prefix[prefix.length - 1] ?? 0;
65
+ prefix.push(previousHeight + Math.max(0, height));
66
+ }
67
+ return prefix;
68
+ }
69
+ function getTotalHeight(prefixHeights) {
70
+ return prefixHeights[prefixHeights.length - 1] ?? 0;
71
+ }
72
+ function findPageIndexForOffset(prefixHeights, offset) {
73
+ const pageCount = Math.max(0, prefixHeights.length - 1);
74
+ if (pageCount === 0) {
75
+ return 0;
76
+ }
77
+ const clampedOffset = Math.max(0, offset);
78
+ let low = 0;
79
+ let high = pageCount - 1;
80
+ let result = 0;
81
+ while (low <= high) {
82
+ const middle = Math.floor((low + high) / 2);
83
+ const pageStart = prefixHeights[middle] ?? 0;
84
+ const nextPageStart = prefixHeights[middle + 1] ?? pageStart;
85
+ if (clampedOffset < pageStart) {
86
+ high = middle - 1;
87
+ } else if (clampedOffset >= nextPageStart) {
88
+ low = middle + 1;
89
+ } else {
90
+ return middle;
91
+ }
92
+ result = Math.min(pageCount - 1, Math.max(0, low));
93
+ }
94
+ return Math.min(pageCount - 1, result);
95
+ }
96
+ function getVisiblePageRange(args) {
97
+ const { prefixHeights, scrollTop, viewportHeight, overscanPages } = args;
98
+ const pageCount = Math.max(0, prefixHeights.length - 1);
99
+ if (pageCount === 0) {
100
+ return { first: 0, last: -1 };
101
+ }
102
+ const firstVisible = findPageIndexForOffset(prefixHeights, scrollTop);
103
+ const lastVisible = findPageIndexForOffset(
104
+ prefixHeights,
105
+ scrollTop + Math.max(0, viewportHeight)
106
+ );
107
+ const overscan = Math.max(0, overscanPages);
108
+ return {
109
+ first: Math.max(0, firstVisible - overscan),
110
+ last: Math.min(pageCount - 1, lastVisible + overscan)
111
+ };
112
+ }
113
+ function getSpacerHeights(prefixHeights, range) {
114
+ const pageCount = Math.max(0, prefixHeights.length - 1);
115
+ if (pageCount === 0 || range.last < range.first) {
116
+ return { top: 0, bottom: 0 };
117
+ }
118
+ const totalHeight = getTotalHeight(prefixHeights);
119
+ const top = prefixHeights[range.first] ?? 0;
120
+ const renderedEnd = prefixHeights[range.last + 1] ?? totalHeight;
121
+ return {
122
+ top,
123
+ bottom: Math.max(0, totalHeight - renderedEnd)
124
+ };
125
+ }
126
+ function getVirtualWindowMetrics(prefixHeights, range) {
127
+ const total = getTotalHeight(prefixHeights);
128
+ const pageCount = Math.max(0, prefixHeights.length - 1);
129
+ if (pageCount === 0 || range.last < range.first) {
130
+ return { total, bottom: 0 };
131
+ }
132
+ const renderedEnd = prefixHeights[range.last + 1] ?? total;
133
+ return {
134
+ total,
135
+ bottom: Math.max(0, total - renderedEnd)
136
+ };
137
+ }
138
+ function isNearBottom(args) {
139
+ return args.scrollHeight - args.scrollTop - args.clientHeight <= Math.max(0, args.thresholdPx);
140
+ }
141
+ function shouldAdjustScrollForHeightChange(args) {
142
+ return !args.isAtBottom && args.changedPageIndex <= Math.max(0, args.firstVisiblePageIndex);
143
+ }
@@ -1,8 +1,8 @@
1
1
  import * as React from "react";
2
2
  import { type VariantProps } from "class-variance-authority";
3
3
  declare const buttonVariants: (props?: ({
4
- variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
5
- size?: "sm" | "lg" | "default" | "icon" | null | undefined;
4
+ variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | null | undefined;
5
+ size?: "default" | "sm" | "lg" | "icon" | null | undefined;
6
6
  } & import("class-variance-authority/dist/types.js").ClassProp) | undefined) => string;
7
7
  declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
8
8
  asChild?: boolean;
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import * as DialogPrimitive from "@radix-ui/react-dialog";
3
3
  declare function Dialog({ ...props }: React.ComponentProps<typeof DialogPrimitive.Root>): React.JSX.Element;
4
4
  declare function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>): React.JSX.Element;
5
- declare function DialogPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>): React.JSX.Element;
5
+ declare function DialogPortal({ container, ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>): React.JSX.Element;
6
6
  declare function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>): React.JSX.Element;
7
7
  declare function DialogOverlay({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Overlay>): React.JSX.Element;
8
8
  declare function DialogContent({ className, children, showCloseButton, ...props }: React.ComponentProps<typeof DialogPrimitive.Content> & {
@@ -44,6 +44,7 @@ var import_jsx_runtime = require("react/jsx-runtime");
44
44
  var DialogPrimitive = __toESM(require("@radix-ui/react-dialog"));
45
45
  var import_lucide_react = require("lucide-react");
46
46
  var import_utils = require("../../lib/utils.js");
47
+ var import_portal_container = require("./portal-container.js");
47
48
  function Dialog({
48
49
  ...props
49
50
  }) {
@@ -55,9 +56,18 @@ function DialogTrigger({
55
56
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogPrimitive.Trigger, { "data-slot": "dialog-trigger", ...props });
56
57
  }
57
58
  function DialogPortal({
59
+ container,
58
60
  ...props
59
61
  }) {
60
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
62
+ const defaultContainer = (0, import_portal_container.usePortalContainer)();
63
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
64
+ DialogPrimitive.Portal,
65
+ {
66
+ "data-slot": "dialog-portal",
67
+ container: container ?? defaultContainer ?? void 0,
68
+ ...props
69
+ }
70
+ );
61
71
  }
62
72
  function DialogClose({
63
73
  ...props
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ declare function PortalContainerProvider({ container, children, }: {
3
+ container: HTMLElement | null;
4
+ children: React.ReactNode;
5
+ }): React.JSX.Element;
6
+ declare function usePortalContainer(): HTMLElement | null;
7
+ export { PortalContainerProvider, usePortalContainer };
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var portal_container_exports = {};
30
+ __export(portal_container_exports, {
31
+ PortalContainerProvider: () => PortalContainerProvider,
32
+ usePortalContainer: () => usePortalContainer
33
+ });
34
+ module.exports = __toCommonJS(portal_container_exports);
35
+ var import_jsx_runtime = require("react/jsx-runtime");
36
+ var React = __toESM(require("react"));
37
+ const PortalContainerContext = React.createContext(null);
38
+ function PortalContainerProvider({
39
+ container,
40
+ children
41
+ }) {
42
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PortalContainerContext.Provider, { value: container, children });
43
+ }
44
+ function usePortalContainer() {
45
+ return React.useContext(PortalContainerContext);
46
+ }
@@ -45,7 +45,7 @@ var import_jsx_runtime = require("react/jsx-runtime");
45
45
  var import_react = require("react");
46
46
  var import_lucide_react = require("lucide-react");
47
47
  var import_react_syntax_highlighter = require("react-syntax-highlighter");
48
- var import_prism = require("react-syntax-highlighter/dist/esm/styles/prism");
48
+ var import_prism = require("react-syntax-highlighter/dist/esm/styles/prism/index.js");
49
49
  var import_dialog = require("../components/ui/dialog.js");
50
50
  var import_button = require("../components/ui/button.js");
51
51
  var import_spinner = require("../components/ui/spinner.js");
@@ -1,4 +1,6 @@
1
1
  export * from './chat/chat-bot-view.js';
2
+ export { ChatFeedWidget } from './chat/chat-feed-widget.js';
3
+ export type { ToolCall, ToolCallStatus } from './chat/chat-feed-widget.js';
2
4
  export * from './chat/chat-hooks.js';
3
5
  export * from './chat/chat-input.js';
4
6
  export * from './chat/chat-message.js';
@@ -14,6 +16,7 @@ export * from './chat/agent-thread.js';
14
16
  export * from './chat/new-chat-thread.js';
15
17
  export * from './chat/realtime-audio-output.js';
16
18
  export * from './chat/tool-call-status-accumulator.js';
19
+ export { PortalContainerProvider } from './components/ui/portal-container.js';
17
20
  export { AgentThreadMessageStatusStore, resolveChatThreadStatusFromStore, shouldShowChatThreadStatus, trackAgentThreadStatusMessageInStore } from './chat/agent-thread-message-status-store.js';
18
21
  export * from './file-preview/file-preview.js';
19
22
  export * from './forms/email-address.js';
package/dist/cjs/index.js CHANGED
@@ -20,12 +20,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  var index_exports = {};
21
21
  __export(index_exports, {
22
22
  AgentThreadMessageStatusStore: () => import_agent_thread_message_status_store.AgentThreadMessageStatusStore,
23
+ ChatFeedWidget: () => import_chat_feed_widget.ChatFeedWidget,
24
+ PortalContainerProvider: () => import_portal_container.PortalContainerProvider,
23
25
  resolveChatThreadStatusFromStore: () => import_agent_thread_message_status_store.resolveChatThreadStatusFromStore,
24
26
  shouldShowChatThreadStatus: () => import_agent_thread_message_status_store.shouldShowChatThreadStatus,
25
27
  trackAgentThreadStatusMessageInStore: () => import_agent_thread_message_status_store.trackAgentThreadStatusMessageInStore
26
28
  });
27
29
  module.exports = __toCommonJS(index_exports);
28
30
  __reExport(index_exports, require("./chat/chat-bot-view.js"), module.exports);
31
+ var import_chat_feed_widget = require("./chat/chat-feed-widget.js");
29
32
  __reExport(index_exports, require("./chat/chat-hooks.js"), module.exports);
30
33
  __reExport(index_exports, require("./chat/chat-input.js"), module.exports);
31
34
  __reExport(index_exports, require("./chat/chat-message.js"), module.exports);
@@ -41,6 +44,7 @@ __reExport(index_exports, require("./chat/agent-thread.js"), module.exports);
41
44
  __reExport(index_exports, require("./chat/new-chat-thread.js"), module.exports);
42
45
  __reExport(index_exports, require("./chat/realtime-audio-output.js"), module.exports);
43
46
  __reExport(index_exports, require("./chat/tool-call-status-accumulator.js"), module.exports);
47
+ var import_portal_container = require("./components/ui/portal-container.js");
44
48
  var import_agent_thread_message_status_store = require("./chat/agent-thread-message-status-store.js");
45
49
  __reExport(index_exports, require("./file-preview/file-preview.js"), module.exports);
46
50
  __reExport(index_exports, require("./forms/email-address.js"), module.exports);