@zero-library/chat-agent 2.3.5 → 2.3.7

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/dist/index.esm.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { createSecureManager, createTokenManager, useRefState, useDebounce, useSyncInput, markdownToText, RenderWrapper, shouldRender, isFunction, useDeepEffect, useWebSocket, downloadFile, FilePreview, MarkdownEditor, isObject, isNullOrUnDef, isNumber, getFileSuffixName, isBoolean, UserAvatar, htmlToMarkdown, copyText, deepCopy, transforms, deepMerge, createRequest, HttpStatus, isArray, isString, isEmptyObj, RenderMarkdown, transform, emit, buildUrlParams, getWebSocketUrl, useCreateValtioContext, FileIcon, isExternal, LazyComponent } from '@zero-library/common';
2
- import { App, Badge, Button, Flex, Typography, Spin, Splitter, Tag, Popover, List, Avatar, Space, Input, Popconfirm, message, Empty, Tooltip, Form, Modal, AutoComplete, Row, Col, Collapse, Skeleton, Alert, Drawer } from 'antd';
2
+ import { App, Badge, Button, Flex, Typography, Spin, Splitter, Tag, Avatar, Space, Popover, Drawer, Input, Tabs, Popconfirm, message, Empty, Tooltip, Form, Modal, AutoComplete, Row, Col, Collapse, Skeleton, Alert } from 'antd';
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import { forwardRef, useRef, useEffect, useImperativeHandle, useMemo, useState } from 'react';
5
5
  import { useSnapshot, proxy } from 'valtio';
6
6
  import { CloudUploadOutlined, PaperClipOutlined, EnterOutlined, CloseOutlined, FileSearchOutlined, UserSwitchOutlined, PlusOutlined, CommentOutlined, OpenAIOutlined, CopyOutlined, LikeOutlined, DislikeOutlined, SearchOutlined, PushpinOutlined, EditOutlined, DeleteOutlined, StarFilled, StarOutlined, RedoOutlined, SignatureOutlined, PlayCircleOutlined, DotChartOutlined } from '@ant-design/icons';
7
- import classNames12 from 'classnames';
7
+ import classNames11 from 'classnames';
8
8
  import { Attachments, Sender, Suggestion, XProvider, Prompts, Bubble, Conversations, Welcome } from '@ant-design/x';
9
9
  import dayjs from 'dayjs';
10
10
  import InfiniteScroll from 'react-infinite-scroll-component';
@@ -303,7 +303,7 @@ var init_Charts = __esm({
303
303
  );
304
304
  Charts_default = ({ data, loading }) => {
305
305
  const { type, config } = data;
306
- return /* @__PURE__ */ jsx("div", { className: classNames12(styles_module_default.chart, "scroll-fade-in"), children: loading ? (
306
+ return /* @__PURE__ */ jsx("div", { className: classNames11(styles_module_default.chart, "scroll-fade-in"), children: loading ? (
307
307
  // Antd 骨架屏
308
308
  /* @__PURE__ */ jsx(Skeleton.Node, { active: true, className: styles_module_default.chartSkeleton, children: /* @__PURE__ */ jsx(DotChartOutlined, { className: styles_module_default.chartSkeletonIcon }) })
309
309
  ) : /* @__PURE__ */ jsx(
@@ -1300,15 +1300,13 @@ var MessageRender_default = ({ message: message2, placement, onFilePreview, cust
1300
1300
  onFilePreview?.(file);
1301
1301
  }
1302
1302
  };
1303
- const mergedCustomComponents = useMemo(() => {
1304
- return { ...customComponents, ...propsCustomComponents };
1305
- }, [propsCustomComponents]);
1303
+ const mergedCustomComponents = { ...customComponents, ...propsCustomComponents };
1306
1304
  return /* @__PURE__ */ jsx(Flex, { vertical: true, children: !(msgContent || message2.msgFiles.length) ? /* @__PURE__ */ jsx(Typography, { children: /* @__PURE__ */ jsx(Spin, { size: "small" }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1307
1305
  msgContent && /* @__PURE__ */ jsx(
1308
1306
  Bubble,
1309
1307
  {
1310
1308
  placement,
1311
- className: classNames12({ [styles_module_default2.loadingMessage]: message2.type }),
1309
+ className: classNames11({ [styles_module_default2.loadingMessage]: message2.type }),
1312
1310
  content: /* @__PURE__ */ jsx(RenderMarkdown, { content: replaceMarkdownTags(msgContent), customComponents: mergedCustomComponents, message: message2 })
1313
1311
  }
1314
1312
  ),
@@ -1391,10 +1389,6 @@ var styles_module_default3 = {
1391
1389
  chatWelcomeWrap: "styles_module_chatWelcomeWrap",
1392
1390
  chatWelcome: "styles_module_chatWelcome",
1393
1391
  chatWelcomePrompts: "styles_module_chatWelcomePrompts",
1394
- nsSenderListTitle: "styles_module_nsSenderListTitle",
1395
- nsSenderList: "styles_module_nsSenderList",
1396
- nsSenderListItem: "styles_module_nsSenderListItem",
1397
- nsSenderListFooter: "styles_module_nsSenderListFooter",
1398
1392
  nsChatUserName: "styles_module_nsChatUserName",
1399
1393
  nsSenderReferenceHeaderTitle: "styles_module_nsSenderReferenceHeaderTitle",
1400
1394
  nsSenderReferenceHeaderContent: "styles_module_nsSenderReferenceHeaderContent",
@@ -1415,7 +1409,7 @@ var WelcomeItem_default = ({ icon = true, title = true, description = true, prom
1415
1409
  /* @__PURE__ */ jsx(
1416
1410
  Welcome,
1417
1411
  {
1418
- className: classNames12(styles_module_default3.chatWelcome, "p-t-32"),
1412
+ className: classNames11(styles_module_default3.chatWelcome, "p-t-32"),
1419
1413
  variant: "borderless",
1420
1414
  icon: /* @__PURE__ */ jsx(RenderWrapper, { control: icon, DefaultComponent: /* @__PURE__ */ jsx(Avatar, { shape: "square", size: 58, src: receiverState.active.logo }) }),
1421
1415
  title: /* @__PURE__ */ jsx(RenderWrapper, { control: title, DefaultComponent: `\u4F60\u597D\uFF0C\u6211\u662F${receiverState.active.name || ""}` }),
@@ -1444,7 +1438,7 @@ var WelcomeItem_default = ({ icon = true, title = true, description = true, prom
1444
1438
  label: "\u{1F914} \u63A8\u8350\u95EE\u9898:",
1445
1439
  children: receiverState?.recommendQuestions.map((question) => ({
1446
1440
  key: question,
1447
- description: /* @__PURE__ */ jsx("span", { className: classNames12(styles_module_default3.chatWelcomePrompts, "text-ellipsis"), children: question })
1441
+ description: /* @__PURE__ */ jsx("span", { className: classNames11(styles_module_default3.chatWelcomePrompts, "text-ellipsis"), children: question })
1448
1442
  }))
1449
1443
  }
1450
1444
  ]
@@ -1682,7 +1676,7 @@ var BubbleListItems_default = ({
1682
1676
  autoScroll: false,
1683
1677
  ref: listRef,
1684
1678
  items: bubbleListItems,
1685
- className: classNames12(styles_module_default3.nsBubbleList, "height-full", "scroll-fade-in", "zero-chat-bubbles"),
1679
+ className: classNames11(styles_module_default3.nsBubbleList, "height-full", "scroll-fade-in", "zero-chat-bubbles"),
1686
1680
  onScroll: handleScroll
1687
1681
  },
1688
1682
  conversationState.active.id
@@ -1717,7 +1711,7 @@ var CharacterList_default = () => {
1717
1711
  /* @__PURE__ */ jsx(
1718
1712
  Avatar,
1719
1713
  {
1720
- className: classNames12(styles_module_default3.nsAvatarListItemIcon, "cursor-pointer", {
1714
+ className: classNames11(styles_module_default3.nsAvatarListItemIcon, "cursor-pointer", {
1721
1715
  [styles_module_default3.nsAvatarListItemIconActive]: activeCharacter.id === item.id
1722
1716
  }),
1723
1717
  size: 50,
@@ -1754,14 +1748,14 @@ var ConversationFavoritesList_default = () => {
1754
1748
  chatStore.getConversationFavorite();
1755
1749
  }, 300);
1756
1750
  const renderFavoriteList = useMemo(() => {
1757
- return /* @__PURE__ */ jsx("div", { className: classNames12("height-full", "scroll-fade-in"), children: favoriteState.list.items.length ? favoriteState.list.items.map((item) => /* @__PURE__ */ jsxs(
1751
+ return /* @__PURE__ */ jsx("div", { className: classNames11("height-full", "scroll-fade-in"), children: favoriteState.list.items.length ? favoriteState.list.items.map((item) => /* @__PURE__ */ jsxs(
1758
1752
  "div",
1759
1753
  {
1760
- className: classNames12(styles_module_default3.favoriteCard, { [styles_module_default3.favoriteCardActive]: conversationState.active.id === item.id }),
1754
+ className: classNames11(styles_module_default3.favoriteCard, { [styles_module_default3.favoriteCardActive]: conversationState.active.id === item.id }),
1761
1755
  onClick: () => chatStore.switchConversation(item.id),
1762
1756
  children: [
1763
1757
  /* @__PURE__ */ jsxs(Flex, { gap: 8, align: "center", children: [
1764
- /* @__PURE__ */ jsx(Flex, { flex: 1, className: classNames12(styles_module_default3.favoriteCardTitle, "text-ellipsis"), children: item.title }),
1758
+ /* @__PURE__ */ jsx(Flex, { flex: 1, className: classNames11(styles_module_default3.favoriteCardTitle, "text-ellipsis"), children: item.title }),
1765
1759
  /* @__PURE__ */ jsx(Flex, { gap: 8, align: "center", className: styles_module_default3.favoriteCardActions, children: /* @__PURE__ */ jsx(
1766
1760
  Popconfirm,
1767
1761
  {
@@ -1773,6 +1767,7 @@ var ConversationFavoritesList_default = () => {
1773
1767
  e.stopPropagation();
1774
1768
  chatStore.collectConversation(item.id, false);
1775
1769
  },
1770
+ onCancel: (e) => e.stopPropagation(),
1776
1771
  children: /* @__PURE__ */ jsx(
1777
1772
  Button,
1778
1773
  {
@@ -1888,7 +1883,7 @@ var ChatHeader_default = ({
1888
1883
  const chatStore = useChatStore();
1889
1884
  const receiverState = useSnapshot(chatStore.receiver);
1890
1885
  const configState = useSnapshot(chatStore.config);
1891
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", className: classNames12(styles_module_default3.nsChatHeader, "zero-chat-header"), children: [
1886
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", className: classNames11(styles_module_default3.nsChatHeader, "zero-chat-header"), children: [
1892
1887
  /* @__PURE__ */ jsxs(Flex, { gap: 4, align: "center", children: [
1893
1888
  /* @__PURE__ */ jsx(RenderWrapper, { control: avatar, DefaultComponent: /* @__PURE__ */ jsx(Avatar, { size: 22, src: receiverState.active.logo, alt: receiverState.active.name }) }),
1894
1889
  /* @__PURE__ */ jsx(RenderWrapper, { control: title, DefaultComponent: /* @__PURE__ */ jsx("div", { className: styles_module_default3.nsChatTitle, children: receiverState.active.name }) }),
@@ -2170,7 +2165,7 @@ init_Context();
2170
2165
  // src/ui/common/FeaturesRenderer.tsx
2171
2166
  init_Context();
2172
2167
 
2173
- // src/ui/common/QuickAsk/QuickAskPanel.tsx
2168
+ // src/ui/common/QuickAsk/QuickAskPanelDrawer.tsx
2174
2169
  init_Context();
2175
2170
 
2176
2171
  // src/ui/common/QuickAsk/QuickAskEditModal.tsx
@@ -2273,7 +2268,8 @@ var styles_module_default4 = {
2273
2268
  quickAskItemHeaderActions: "styles_module_quickAskItemHeaderActions",
2274
2269
  quickAskItemBody: "styles_module_quickAskItemBody"
2275
2270
  };
2276
- var QuickAskPanel_default = () => {
2271
+ var ALL = "all";
2272
+ var QuickAskPanelDrawer_default = ({ open, onClose }) => {
2277
2273
  const { message: message2 } = App.useApp();
2278
2274
  const chatStore = useChatStore();
2279
2275
  const configState = useSnapshot(chatStore.config);
@@ -2294,6 +2290,19 @@ var QuickAskPanel_default = () => {
2294
2290
  } catch (err) {
2295
2291
  }
2296
2292
  };
2293
+ const tabsItems = useMemo(
2294
+ () => [
2295
+ {
2296
+ key: ALL,
2297
+ label: "\u5168\u90E8"
2298
+ },
2299
+ ...categories.map((item) => ({
2300
+ key: item.id,
2301
+ label: item.labelName
2302
+ }))
2303
+ ],
2304
+ [categories]
2305
+ );
2297
2306
  const [loading, setLoading] = useState(false);
2298
2307
  const fetchItems = useDebounce(async () => {
2299
2308
  try {
@@ -2349,153 +2358,158 @@ var QuickAskPanel_default = () => {
2349
2358
  } catch (err) {
2350
2359
  }
2351
2360
  };
2352
- return /* @__PURE__ */ jsxs(Flex, { vertical: true, className: styles_module_default4.quickAskPanel, children: [
2353
- /* @__PURE__ */ jsx(Flex, { justify: "space-between", align: "center", children: /* @__PURE__ */ jsx(Typography.Title, { level: 5, children: "\u5FEB\u901F\u63D0\u95EE" }) }),
2354
- /* @__PURE__ */ jsxs(Flex, { gap: 8, className: "m-b-16 m-t-16", children: [
2355
- !searchExpanded && /* @__PURE__ */ jsx(
2356
- Button,
2357
- {
2358
- type: "dashed",
2359
- block: true,
2360
- icon: /* @__PURE__ */ jsx(PlusOutlined, {}),
2361
- className: "flex-1",
2362
- onClick: () => {
2363
- setEditingItem(null);
2364
- setEditModalOpen(true);
2365
- },
2366
- children: "\u65B0\u589E\u5FEB\u901F\u63D0\u95EE"
2367
- }
2368
- ),
2369
- searchExpanded ? /* @__PURE__ */ jsx(
2370
- Input,
2371
- {
2372
- autoFocus: true,
2373
- placeholder: "\u8F93\u5165\u95EE\u9898\u540D\u79F0\u6216\u5185\u5BB9\u68C0\u7D22",
2374
- prefix: /* @__PURE__ */ jsx(SearchOutlined, {}),
2375
- value: searchText,
2376
- onChange: (e) => {
2377
- setSearchText(e.target.value);
2378
- fetchItems();
2379
- },
2380
- className: "flex-1",
2381
- allowClear: true,
2382
- onBlur: () => setSearchExpanded(false)
2383
- }
2384
- ) : /* @__PURE__ */ jsx(Button, { icon: /* @__PURE__ */ jsx(SearchOutlined, {}), onClick: () => setSearchExpanded(true) })
2385
- ] }),
2386
- /* @__PURE__ */ jsxs(Flex, { align: "center", className: classNames12("scroll-fade-in", "m-b-16", styles_module_default4.tagContainer), children: [
2387
- /* @__PURE__ */ jsx(
2388
- Tag,
2389
- {
2390
- color: !activeTab.id ? "processing" : "default",
2391
- className: "cursor-pointer",
2392
- bordered: false,
2393
- onClick: () => {
2394
- setActiveTab({});
2395
- fetchItems();
2396
- },
2397
- children: "\u5168\u90E8"
2398
- }
2399
- ),
2400
- categories.map((c) => /* @__PURE__ */ jsx(
2401
- Tag,
2402
- {
2403
- color: activeTab.id === c.id ? "processing" : "default",
2404
- className: "cursor-pointer",
2405
- bordered: false,
2406
- onClick: () => {
2407
- setActiveTab(c);
2408
- fetchItems();
2409
- },
2410
- children: c.labelName
2411
- },
2412
- c.id
2413
- ))
2414
- ] }),
2415
- /* @__PURE__ */ jsx(Flex, { vertical: true, className: "flex-1", children: /* @__PURE__ */ jsx(Spin, { spinning: loading, wrapperClassName: "full-spin", tip: "\u52A0\u8F7D\u4E2D...", children: /* @__PURE__ */ jsx(Flex, { vertical: true, gap: 8, className: "height-full scroll-fade-in", children: items.map((item) => /* @__PURE__ */ jsxs(
2416
- "div",
2361
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2362
+ /* @__PURE__ */ jsx(
2363
+ Drawer,
2417
2364
  {
2418
- className: styles_module_default4.quickAskItem,
2419
- onClick: () => {
2420
- chatStore.setContent(item.content);
2421
- chatStore.setContentParams({
2422
- use_template: 1
2423
- });
2424
- },
2425
- children: [
2426
- /* @__PURE__ */ jsxs(Flex, { gap: 8, justify: "space-between", align: "center", className: styles_module_default4.quickAskItemHeader, children: [
2427
- /* @__PURE__ */ jsx("div", { className: classNames12("flex-1 text-ellipsis", styles_module_default4.quickAskItemTitle), children: item.title }),
2428
- /* @__PURE__ */ jsxs(Space, { size: 4, className: styles_module_default4.quickAskItemHeaderActions, children: [
2429
- /* @__PURE__ */ jsx(
2365
+ className: classNames11("no-padding-drawer"),
2366
+ width: 360,
2367
+ open,
2368
+ title: "\u5FEB\u901F\u63D0\u95EE",
2369
+ closable: { placement: "end" },
2370
+ onClose,
2371
+ placement: "right",
2372
+ mask: false,
2373
+ children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className: styles_module_default4.quickAskPanel, children: [
2374
+ /* @__PURE__ */ jsxs(Flex, { gap: 12, className: "p-16", vertical: true, children: [
2375
+ /* @__PURE__ */ jsxs(Flex, { gap: 8, children: [
2376
+ !searchExpanded && /* @__PURE__ */ jsx(
2430
2377
  Button,
2431
2378
  {
2432
- type: "primary",
2433
- size: "small",
2434
- icon: /* @__PURE__ */ jsx(PushpinOutlined, { rotate: item.isTop ? -45 : 0 }),
2435
- title: item.isTop ? "\u53D6\u6D88\u7F6E\u9876" : "\u7F6E\u9876",
2436
- onClick: (e) => {
2437
- e.stopPropagation();
2438
- handleTop(item);
2439
- }
2440
- },
2441
- "top"
2442
- ),
2443
- /* @__PURE__ */ jsx(
2444
- Button,
2445
- {
2446
- type: "primary",
2447
- size: "small",
2448
- icon: /* @__PURE__ */ jsx(CopyOutlined, {}),
2449
- title: "\u590D\u5236",
2450
- onClick: (e) => {
2451
- e.stopPropagation();
2452
- setEditingItem({
2453
- title: item.title,
2454
- labelName: item.labelName,
2455
- content: item.content
2456
- });
2379
+ type: "dashed",
2380
+ block: true,
2381
+ icon: /* @__PURE__ */ jsx(PlusOutlined, {}),
2382
+ className: "flex-1",
2383
+ onClick: () => {
2384
+ setEditingItem(null);
2457
2385
  setEditModalOpen(true);
2458
- }
2459
- },
2460
- "copy"
2461
- ),
2462
- /* @__PURE__ */ jsx(
2463
- Button,
2464
- {
2465
- type: "primary",
2466
- size: "small",
2467
- icon: /* @__PURE__ */ jsx(EditOutlined, {}),
2468
- title: "\u7F16\u8F91",
2469
- onClick: (e) => {
2470
- e.stopPropagation();
2471
- setEditingItem(item);
2472
- setEditModalOpen(true);
2473
- }
2474
- },
2475
- "edit"
2386
+ },
2387
+ children: "\u65B0\u589E\u5FEB\u901F\u63D0\u95EE"
2388
+ }
2476
2389
  ),
2477
- item.canDelete && /* @__PURE__ */ jsx(
2478
- Popconfirm,
2390
+ searchExpanded ? /* @__PURE__ */ jsx(
2391
+ Input,
2479
2392
  {
2480
- title: "\u63D0\u793A",
2481
- okText: "\u786E\u5B9A",
2482
- cancelText: "\u53D6\u6D88",
2483
- description: "\u786E\u8BA4\u5220\u9664\u95EE\u9898\u5417?",
2484
- onConfirm: (e) => {
2485
- e.stopPropagation();
2486
- handleDelete(item.id);
2393
+ autoFocus: true,
2394
+ placeholder: "\u8F93\u5165\u95EE\u9898\u540D\u79F0\u6216\u5185\u5BB9\u68C0\u7D22",
2395
+ prefix: /* @__PURE__ */ jsx(SearchOutlined, {}),
2396
+ value: searchText,
2397
+ onChange: (e) => {
2398
+ setSearchText(e.target.value);
2399
+ fetchItems();
2487
2400
  },
2488
- children: /* @__PURE__ */ jsx(Button, { type: "primary", size: "small", icon: /* @__PURE__ */ jsx(DeleteOutlined, {}), title: "\u5220\u9664", onClick: (e) => e.stopPropagation() })
2401
+ className: "flex-1",
2402
+ allowClear: true,
2403
+ onBlur: () => setSearchExpanded(false)
2404
+ }
2405
+ ) : /* @__PURE__ */ jsx(Button, { icon: /* @__PURE__ */ jsx(SearchOutlined, {}), onClick: () => setSearchExpanded(true) })
2406
+ ] }),
2407
+ /* @__PURE__ */ jsx(
2408
+ Tabs,
2409
+ {
2410
+ className: styles_module_default4.tagContainer,
2411
+ activeKey: activeTab.id ? activeTab.id : ALL,
2412
+ onChange: (key) => {
2413
+ setActiveTab(key === ALL ? {} : categories.find((c) => c.id === key));
2414
+ fetchItems();
2489
2415
  },
2490
- "delete"
2491
- )
2492
- ] })
2416
+ tabPosition: "top",
2417
+ items: tabsItems,
2418
+ size: "small"
2419
+ }
2420
+ )
2493
2421
  ] }),
2494
- /* @__PURE__ */ jsx("div", { className: classNames12(styles_module_default4.quickAskItemBody), children: /* @__PURE__ */ jsx("div", { className: "text-ellipsis-3", children: item.content }) })
2495
- ]
2496
- },
2497
- item.id
2498
- )) }) }) }),
2422
+ /* @__PURE__ */ jsx(Flex, { vertical: true, className: "flex-1", children: /* @__PURE__ */ jsx(Spin, { spinning: loading, wrapperClassName: "full-spin", tip: "\u52A0\u8F7D\u4E2D...", children: /* @__PURE__ */ jsx(Flex, { vertical: true, gap: 8, className: "height-full scroll-fade-in p-16 p-t-8", children: items.map((item) => /* @__PURE__ */ jsxs(
2423
+ "div",
2424
+ {
2425
+ className: styles_module_default4.quickAskItem,
2426
+ onClick: () => {
2427
+ chatStore.setContent(item.content);
2428
+ chatStore.setContentParams({
2429
+ use_template: 1
2430
+ });
2431
+ onClose();
2432
+ },
2433
+ children: [
2434
+ /* @__PURE__ */ jsxs(Flex, { gap: 8, justify: "space-between", align: "center", className: styles_module_default4.quickAskItemHeader, children: [
2435
+ /* @__PURE__ */ jsx("div", { className: classNames11("flex-1 text-ellipsis", styles_module_default4.quickAskItemTitle), children: item.title }),
2436
+ /* @__PURE__ */ jsxs(Space, { size: 4, className: styles_module_default4.quickAskItemHeaderActions, children: [
2437
+ /* @__PURE__ */ jsx(
2438
+ Button,
2439
+ {
2440
+ type: "primary",
2441
+ size: "small",
2442
+ icon: /* @__PURE__ */ jsx(PushpinOutlined, { rotate: item.isTop ? -45 : 0 }),
2443
+ title: item.isTop ? "\u53D6\u6D88\u7F6E\u9876" : "\u7F6E\u9876",
2444
+ onClick: (e) => {
2445
+ e.stopPropagation();
2446
+ handleTop(item);
2447
+ }
2448
+ },
2449
+ "top"
2450
+ ),
2451
+ /* @__PURE__ */ jsx(
2452
+ Button,
2453
+ {
2454
+ type: "primary",
2455
+ size: "small",
2456
+ icon: /* @__PURE__ */ jsx(CopyOutlined, {}),
2457
+ title: "\u590D\u5236",
2458
+ onClick: (e) => {
2459
+ e.stopPropagation();
2460
+ setEditingItem({
2461
+ title: item.title,
2462
+ labelName: item.labelName,
2463
+ content: item.content
2464
+ });
2465
+ setEditModalOpen(true);
2466
+ }
2467
+ },
2468
+ "copy"
2469
+ ),
2470
+ /* @__PURE__ */ jsx(
2471
+ Button,
2472
+ {
2473
+ type: "primary",
2474
+ size: "small",
2475
+ icon: /* @__PURE__ */ jsx(EditOutlined, {}),
2476
+ title: "\u7F16\u8F91",
2477
+ onClick: (e) => {
2478
+ e.stopPropagation();
2479
+ setEditingItem(item);
2480
+ setEditModalOpen(true);
2481
+ }
2482
+ },
2483
+ "edit"
2484
+ ),
2485
+ item.canDelete && /* @__PURE__ */ jsx(
2486
+ Popconfirm,
2487
+ {
2488
+ title: "\u63D0\u793A",
2489
+ okText: "\u786E\u5B9A",
2490
+ cancelText: "\u53D6\u6D88",
2491
+ description: "\u786E\u8BA4\u5220\u9664\u95EE\u9898\u5417?",
2492
+ onConfirm: (e) => {
2493
+ e.stopPropagation();
2494
+ handleDelete(item.id);
2495
+ },
2496
+ onCancel: (e) => {
2497
+ e.stopPropagation();
2498
+ },
2499
+ children: /* @__PURE__ */ jsx(Button, { type: "primary", size: "small", icon: /* @__PURE__ */ jsx(DeleteOutlined, {}), title: "\u5220\u9664", onClick: (e) => e.stopPropagation() })
2500
+ },
2501
+ "delete"
2502
+ )
2503
+ ] })
2504
+ ] }),
2505
+ /* @__PURE__ */ jsx("div", { className: classNames11(styles_module_default4.quickAskItemBody), children: /* @__PURE__ */ jsx("div", { className: "text-ellipsis-3", children: item.content }) })
2506
+ ]
2507
+ },
2508
+ item.id
2509
+ )) }) }) })
2510
+ ] })
2511
+ }
2512
+ ),
2499
2513
  editModalOpen && /* @__PURE__ */ jsx(
2500
2514
  QuickAskEditModal_default,
2501
2515
  {
@@ -2513,6 +2527,7 @@ var FeaturesRenderer_default = () => {
2513
2527
  const chatStore = useChatStore();
2514
2528
  const receiverState = useSnapshot(chatStore.receiver);
2515
2529
  const conversationState = useSnapshot(chatStore.conversation);
2530
+ const [quickAskOpen, setQuickAskOpen] = useState(false);
2516
2531
  const chatMessage = useMemo(
2517
2532
  () => conversationState.messages[conversationState.active.id] || {},
2518
2533
  [conversationState.messages[conversationState.active.id]]
@@ -2543,66 +2558,14 @@ var FeaturesRenderer_default = () => {
2543
2558
  children: "\u5411\u4E13\u5BB6\u54A8\u8BE2"
2544
2559
  }
2545
2560
  ),
2546
- receiverState.active.feature?.quickAsk && /* @__PURE__ */ jsx(
2547
- Popover,
2548
- {
2549
- trigger: "click",
2550
- placement: "topLeft",
2551
- content: /* @__PURE__ */ jsx(QuickAskPanel_default, {}),
2552
- children: /* @__PURE__ */ jsx(
2553
- Button,
2554
- {
2555
- size: "small",
2556
- color: "primary",
2557
- variant: "filled",
2558
- children: "\u5FEB\u901F\u63D0\u95EE"
2559
- }
2560
- )
2561
- }
2562
- )
2561
+ receiverState.active.feature?.quickAsk && /* @__PURE__ */ jsxs(Fragment, { children: [
2562
+ /* @__PURE__ */ jsx(Button, { size: "small", color: "primary", variant: "filled", onClick: () => setQuickAskOpen(true), children: "\u5FEB\u901F\u63D0\u95EE" }),
2563
+ quickAskOpen && /* @__PURE__ */ jsx(QuickAskPanelDrawer_default, { open: quickAskOpen, onClose: () => setQuickAskOpen(false) })
2564
+ ] })
2563
2565
  ] });
2564
2566
  };
2565
-
2566
- // src/ui/common/SenderPromptsItems.tsx
2567
- init_Context();
2568
- var SenderPromptsItems_default = () => {
2569
- const chatStore = useChatStore();
2570
- const receiverState = useSnapshot(chatStore.receiver);
2571
- const component = useMemo(
2572
- () => receiverState.active.config?.labels?.length > 0 && /* @__PURE__ */ jsxs(Flex, { gap: 4, wrap: true, children: [
2573
- /* @__PURE__ */ jsx(Button, { disabled: true, color: "default", variant: "text", children: "\u968F\u4FBF\u804A\u804A" }),
2574
- receiverState.active.config.labels.slice(0, 6).map((question) => /* @__PURE__ */ jsx(
2575
- Popover,
2576
- {
2577
- content: /* @__PURE__ */ jsx(
2578
- List,
2579
- {
2580
- itemLayout: "horizontal",
2581
- split: false,
2582
- className: styles_module_default3.nsSenderList,
2583
- dataSource: question.items,
2584
- renderItem: (item) => /* @__PURE__ */ jsx(List.Item, { onClick: () => chatStore.sendMessage(item.question), className: styles_module_default3.nsSenderListItem, children: /* @__PURE__ */ jsx("div", { className: "text-ellipsis", children: item.question }) }),
2585
- footer: /* @__PURE__ */ jsx(Flex, { justify: "end", className: styles_module_default3.nsSenderListFooter, children: "(\u60A8\u53EF\u70B9\u51FB\u4EE5\u4E0A\u95EE\u9898\u5F00\u542FAI\u4F53\u9A8C)" })
2586
- }
2587
- ),
2588
- title: /* @__PURE__ */ jsx(
2589
- "div",
2590
- {
2591
- className: classNames12(styles_module_default3.nsSenderListTitle, "text-ellipsis"),
2592
- children: `${receiverState.active.name}\u5F00\u59CB\u5173\u6CE8${question.name}\u5185\u5BB9\uFF01`
2593
- }
2594
- ),
2595
- children: /* @__PURE__ */ jsx(Button, { color: "default", variant: "filled", children: question.name })
2596
- },
2597
- question.id
2598
- ))
2599
- ] }),
2600
- [receiverState.active.config?.labels]
2601
- );
2602
- return component;
2603
- };
2604
2567
  var ChatSender_default2 = forwardRef(
2605
- ({ placeholder, extraBtn = false, referencesBtn = false, sendBtnProps, footerBelow = false, prompts = true }, ref) => {
2568
+ ({ placeholder, extraBtn = false, referencesBtn = false, sendBtnProps, footerBelow = false }, ref) => {
2606
2569
  const chatStore = useChatStore();
2607
2570
  const configState = useSnapshot(chatStore.config);
2608
2571
  const receiverState = useSnapshot(chatStore.receiver);
@@ -2622,61 +2585,58 @@ var ChatSender_default2 = forwardRef(
2622
2585
  chatStore.setContent(con);
2623
2586
  chatStore.sendMessage();
2624
2587
  };
2625
- return /* @__PURE__ */ jsxs(Flex, { vertical: true, gap: 8, className: "zero-chat-sender", children: [
2626
- /* @__PURE__ */ jsx(RenderWrapper, { control: prompts, DefaultComponent: SenderPromptsItems_default }),
2627
- /* @__PURE__ */ jsx(
2628
- ChatSender_default,
2629
- {
2630
- ref,
2631
- placeholder,
2632
- content: chatMessage.content,
2633
- fileList: chatMessage.files,
2634
- headerOpen: chatMessage.headerOpen,
2635
- loading: chatMessage.loading,
2636
- onContentChange: chatStore.setContent,
2637
- onFileListChange: chatStore.setFileList,
2638
- onHeaderOpenChange: chatStore.setHeaderOpen,
2639
- onSend: () => chatStore.sendMessage(),
2640
- onCancel: chatStore.cancelReceive,
2641
- onFocus: chatStore.config.hooks?.onSenderFocus,
2642
- fileUpload: {
2643
- request: configState.services.request?.fileUpload,
2644
- config: receiverState.active.config?.fileUpload
2645
- },
2646
- sendBtnProps: isFunction(sendBtnProps) ? sendBtnProps() : {},
2647
- extraFooterBelow: /* @__PURE__ */ jsx(RenderWrapper, { control: footerBelow }),
2648
- extraFooter: /* @__PURE__ */ jsxs(Fragment, { children: [
2649
- /* @__PURE__ */ jsx(FeaturesRenderer_default, {}),
2650
- /* @__PURE__ */ jsx(RenderWrapper, { control: extraBtn })
2651
- ] }),
2652
- extraHeader: /* @__PURE__ */ jsx(
2653
- Sender.Header,
2654
- {
2655
- title: /* @__PURE__ */ jsxs(Flex, { gap: 4, children: [
2656
- /* @__PURE__ */ jsx(EnterOutlined, {}),
2657
- /* @__PURE__ */ jsx(Typography.Text, { type: "secondary", ellipsis: true, children: referenceContent })
2658
- ] }),
2659
- open: !!referenceContent,
2660
- onOpenChange: () => chatStore.setReferences(),
2661
- classNames: {
2662
- header: styles_module_default3.nsSenderReferenceHeaderTitle,
2663
- content: shouldRender(referencesBtn) ? "" : styles_module_default3.nsSenderReferenceHeaderContent
2664
- },
2665
- children: /* @__PURE__ */ jsx(
2666
- RenderWrapper,
2667
- {
2668
- control: referencesBtn,
2669
- DefaultComponent: /* @__PURE__ */ jsx(Flex, { gap: 8, children: ["\u6DF1\u5EA6\u89E3\u8BFB", "\u6982\u8981\u89E3\u8BFB"].map((con) => /* @__PURE__ */ jsxs(Button, { color: "primary", variant: "filled", onClick: () => referenceHandle(con), children: [
2670
- con,
2671
- " \u2192"
2672
- ] }, con)) })
2673
- }
2674
- )
2675
- }
2676
- )
2677
- }
2678
- )
2679
- ] });
2588
+ return /* @__PURE__ */ jsx(Flex, { vertical: true, gap: 8, className: "zero-chat-sender", children: /* @__PURE__ */ jsx(
2589
+ ChatSender_default,
2590
+ {
2591
+ ref,
2592
+ placeholder,
2593
+ content: chatMessage.content,
2594
+ fileList: chatMessage.files,
2595
+ headerOpen: chatMessage.headerOpen,
2596
+ loading: chatMessage.loading,
2597
+ onContentChange: chatStore.setContent,
2598
+ onFileListChange: chatStore.setFileList,
2599
+ onHeaderOpenChange: chatStore.setHeaderOpen,
2600
+ onSend: () => chatStore.sendMessage(),
2601
+ onCancel: chatStore.cancelReceive,
2602
+ onFocus: chatStore.config.hooks?.onSenderFocus,
2603
+ fileUpload: {
2604
+ request: configState.services.request?.fileUpload,
2605
+ config: receiverState.active.config?.fileUpload
2606
+ },
2607
+ sendBtnProps: isFunction(sendBtnProps) ? sendBtnProps() : {},
2608
+ extraFooterBelow: /* @__PURE__ */ jsx(RenderWrapper, { control: footerBelow }),
2609
+ extraFooter: /* @__PURE__ */ jsxs(Fragment, { children: [
2610
+ /* @__PURE__ */ jsx(FeaturesRenderer_default, {}),
2611
+ /* @__PURE__ */ jsx(RenderWrapper, { control: extraBtn })
2612
+ ] }),
2613
+ extraHeader: /* @__PURE__ */ jsx(
2614
+ Sender.Header,
2615
+ {
2616
+ title: /* @__PURE__ */ jsxs(Flex, { gap: 4, children: [
2617
+ /* @__PURE__ */ jsx(EnterOutlined, {}),
2618
+ /* @__PURE__ */ jsx(Typography.Text, { type: "secondary", ellipsis: true, children: referenceContent })
2619
+ ] }),
2620
+ open: !!referenceContent,
2621
+ onOpenChange: () => chatStore.setReferences(),
2622
+ classNames: {
2623
+ header: styles_module_default3.nsSenderReferenceHeaderTitle,
2624
+ content: shouldRender(referencesBtn) ? "" : styles_module_default3.nsSenderReferenceHeaderContent
2625
+ },
2626
+ children: /* @__PURE__ */ jsx(
2627
+ RenderWrapper,
2628
+ {
2629
+ control: referencesBtn,
2630
+ DefaultComponent: /* @__PURE__ */ jsx(Flex, { gap: 8, children: ["\u6DF1\u5EA6\u89E3\u8BFB", "\u6982\u8981\u89E3\u8BFB"].map((con) => /* @__PURE__ */ jsxs(Button, { color: "primary", variant: "filled", onClick: () => referenceHandle(con), children: [
2631
+ con,
2632
+ " \u2192"
2633
+ ] }, con)) })
2634
+ }
2635
+ )
2636
+ }
2637
+ )
2638
+ }
2639
+ ) });
2680
2640
  }
2681
2641
  );
2682
2642
 
@@ -2692,7 +2652,7 @@ var ConversationListHeader_default = ({ title = true, avatar = true, newConversa
2692
2652
  RenderWrapper,
2693
2653
  {
2694
2654
  control: title,
2695
- DefaultComponent: /* @__PURE__ */ jsx("span", { className: classNames12(styles_module_default3.nsChatUserName, "flex-1 text-ellipsis"), children: receiverState.active.name })
2655
+ DefaultComponent: /* @__PURE__ */ jsx("span", { className: classNames11(styles_module_default3.nsChatUserName, "flex-1 text-ellipsis"), children: receiverState.active.name })
2696
2656
  }
2697
2657
  ),
2698
2658
  /* @__PURE__ */ jsx(RenderWrapper, { control: conversationListFavoriteBtn, DefaultComponent: /* @__PURE__ */ jsx(ConversationFavoritesList_default, {}) })
@@ -2708,7 +2668,7 @@ var ConversationListHeader_default = ({ title = true, avatar = true, newConversa
2708
2668
  type: "primary",
2709
2669
  shape: "round",
2710
2670
  onClick: () => chatStore.createConversation(),
2711
- className: classNames12("m-t-16"),
2671
+ className: classNames11("m-t-16"),
2712
2672
  icon: /* @__PURE__ */ jsx(PlusOutlined, {}),
2713
2673
  children: "\u65B0\u5EFA\u4F1A\u8BDD"
2714
2674
  }
@@ -2718,7 +2678,7 @@ var ConversationListHeader_default = ({ title = true, avatar = true, newConversa
2718
2678
  ] });
2719
2679
  };
2720
2680
  var ConversationListPanel_default = ({ header }) => {
2721
- return /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames12("height-full", "zero-chat-conversations", styles_module_default3.nsConversationListPanel), children: [
2681
+ return /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames11("height-full", "zero-chat-conversations", styles_module_default3.nsConversationListPanel), children: [
2722
2682
  /* @__PURE__ */ jsx(RenderWrapper, { control: header, DefaultComponent: ConversationListHeader_default }),
2723
2683
  /* @__PURE__ */ jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsx(ConversationList_default, {}) })
2724
2684
  ] });
@@ -2812,7 +2772,7 @@ var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, conf
2812
2772
  useEffect(() => {
2813
2773
  configState.hooks?.onBeforeInit?.();
2814
2774
  }, []);
2815
- return /* @__PURE__ */ jsx(XProvider, { theme: { cssVar: true, ...theme }, children: /* @__PURE__ */ jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsx(Spin, { spinning: receiverState.loading, wrapperClassName: "full-spin", children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames12(styles_module_default5.nsChatLayout, "zero-chat-layout", "height-full"), children: [
2775
+ return /* @__PURE__ */ jsx(XProvider, { theme: { cssVar: true, ...theme }, children: /* @__PURE__ */ jsx(ChatProvider, { store: chatStore, children: /* @__PURE__ */ jsx(Spin, { spinning: receiverState.loading, wrapperClassName: "full-spin", children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames11(styles_module_default5.nsChatLayout, "zero-chat-layout", "height-full"), children: [
2816
2776
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.globalHeader, DefaultComponent: ChatHeader_default }),
2817
2777
  /* @__PURE__ */ jsxs(Flex, { className: "full-scroll", children: [
2818
2778
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.leftPanel }),
@@ -2821,7 +2781,7 @@ var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, conf
2821
2781
  /* @__PURE__ */ jsx(Splitter.Panel, { collapsible: false, min: 600, size: sizes[0], children: hasPreView && /* @__PURE__ */ jsxs(Fragment, { children: [
2822
2782
  configState.preview.file.fileUrl && /* @__PURE__ */ jsxs(Flex, { vertical: true, className: "height-full", children: [
2823
2783
  /* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", gap: 16, className: styles_module_default5.nsPreviewHeader, children: [
2824
- /* @__PURE__ */ jsx("div", { className: classNames12(styles_module_default5.nsPreviewHeaderTitle, "text-ellipsis"), title: configState.preview.file.fileName, children: configState.preview.file.fileName }),
2784
+ /* @__PURE__ */ jsx("div", { className: classNames11(styles_module_default5.nsPreviewHeaderTitle, "text-ellipsis"), title: configState.preview.file.fileName, children: configState.preview.file.fileName }),
2825
2785
  /* @__PURE__ */ jsxs(Flex, { gap: 8, justify: "center", align: "center", children: [
2826
2786
  /* @__PURE__ */ jsx(
2827
2787
  Button,
@@ -2865,15 +2825,15 @@ var layouts_default = forwardRef(({ theme, params, userInfo, hooks, layout, conf
2865
2825
  }
2866
2826
  )
2867
2827
  ] }) }),
2868
- /* @__PURE__ */ jsx(Splitter.Panel, { collapsible: false, max: 800, min: 400, size: sizes[1], children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames12("height-full"), children: [
2828
+ /* @__PURE__ */ jsx(Splitter.Panel, { collapsible: false, max: 800, min: 400, size: sizes[1], children: /* @__PURE__ */ jsxs(Flex, { vertical: true, className: classNames11("height-full"), children: [
2869
2829
  /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.chatHeader, DefaultComponent: ChatHeader_default }),
2870
- /* @__PURE__ */ jsx(Flex, { vertical: true, className: classNames12("full-scroll"), children: /* @__PURE__ */ jsxs(
2830
+ /* @__PURE__ */ jsx(Flex, { vertical: true, className: classNames11("full-scroll"), children: /* @__PURE__ */ jsxs(
2871
2831
  Flex,
2872
2832
  {
2873
2833
  justify: "center",
2874
2834
  vertical: true,
2875
2835
  gap: 24,
2876
- className: classNames12("height-full", styles_module_default5.nsChatBody, "zero-chat-body", styles_module_default5.nsBodyWidth),
2836
+ className: classNames11("height-full", styles_module_default5.nsChatBody, "zero-chat-body", styles_module_default5.nsBodyWidth),
2877
2837
  children: [
2878
2838
  shouldRender(configState.layout.messageList) && /* @__PURE__ */ jsx("div", { className: "full-scroll", children: /* @__PURE__ */ jsx(RenderWrapper, { control: configState.layout.messageList, DefaultComponent: BubbleListItems_default }) }),
2879
2839
  /* @__PURE__ */ jsxs(Flex, { vertical: true, gap: 8, children: [