@droppii-org/chat-sdk 0.1.71 → 0.1.72

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 (73) hide show
  1. package/dist/components/conversation-detail/ConversationDetailInput.d.ts +3 -1
  2. package/dist/components/conversation-detail/ConversationDetailInput.d.ts.map +1 -1
  3. package/dist/components/conversation-detail/ConversationDetailInput.js +2 -2
  4. package/dist/components/conversation-detail/ConversationMoreOptionPanel.d.ts +2 -1
  5. package/dist/components/conversation-detail/ConversationMoreOptionPanel.d.ts.map +1 -1
  6. package/dist/components/conversation-detail/ConversationMoreOptionPanel.js +9 -5
  7. package/dist/components/conversation-detail/bot/BotButtonMessage.d.ts.map +1 -1
  8. package/dist/components/conversation-detail/bot/BotButtonMessage.js +6 -4
  9. package/dist/components/message/item/TextMessage.d.ts.map +1 -1
  10. package/dist/components/message/item/TextMessage.js +0 -6
  11. package/dist/components/message/item/index.d.ts.map +1 -1
  12. package/dist/components/message/item/index.js +2 -8
  13. package/dist/components/message/item/renderMessageContent.d.ts.map +1 -1
  14. package/dist/components/message/item/renderMessageContent.js +3 -0
  15. package/dist/components/message/reply/ReplyQuoteContent.d.ts.map +1 -1
  16. package/dist/components/message/reply/ReplyQuoteContent.js +1 -1
  17. package/dist/constants/botFlow.d.ts +2 -0
  18. package/dist/constants/botFlow.d.ts.map +1 -1
  19. package/dist/constants/botFlow.js +2 -0
  20. package/dist/constants/moreOption.d.ts +11 -0
  21. package/dist/constants/moreOption.d.ts.map +1 -1
  22. package/dist/constants/moreOption.js +14 -0
  23. package/dist/context/ChatContext.d.ts +1 -1
  24. package/dist/context/ChatContext.d.ts.map +1 -1
  25. package/dist/context/ChatContext.js +2 -1
  26. package/dist/hooks/conversation/useBotConversationDetail.d.ts +1 -0
  27. package/dist/hooks/conversation/useBotConversationDetail.d.ts.map +1 -1
  28. package/dist/hooks/conversation/useBotConversationDetail.js +5 -4
  29. package/dist/hooks/conversation/useBotMainMenu.d.ts +4 -0
  30. package/dist/hooks/conversation/useBotMainMenu.d.ts.map +1 -0
  31. package/dist/hooks/conversation/useBotMainMenu.js +16 -0
  32. package/dist/hooks/conversation/useResolveConversation.d.ts +11 -0
  33. package/dist/hooks/conversation/useResolveConversation.d.ts.map +1 -0
  34. package/dist/hooks/conversation/useResolveConversation.js +90 -0
  35. package/dist/hooks/conversation/useSwitchToCsTeam.d.ts +6 -0
  36. package/dist/hooks/conversation/useSwitchToCsTeam.d.ts.map +1 -0
  37. package/dist/hooks/conversation/useSwitchToCsTeam.js +41 -0
  38. package/dist/hooks/message/useMessage.d.ts +1 -0
  39. package/dist/hooks/message/useMessage.d.ts.map +1 -1
  40. package/dist/hooks/message/useMessage.js +12 -0
  41. package/dist/hooks/message/useSendMessage.d.ts +9 -2
  42. package/dist/hooks/message/useSendMessage.d.ts.map +1 -1
  43. package/dist/hooks/message/useSendMessage.js +50 -4
  44. package/dist/index.d.ts +14 -1
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +11 -0
  47. package/dist/locales/vi/common.json +2 -0
  48. package/dist/locales/vi/conversation-inbox.json +1 -0
  49. package/dist/screens/conversation-detail/index.d.ts +3 -2
  50. package/dist/screens/conversation-detail/index.d.ts.map +1 -1
  51. package/dist/screens/conversation-detail/index.js +15 -1
  52. package/dist/screens/conversation-inbox/index.d.ts +3 -1
  53. package/dist/screens/conversation-inbox/index.d.ts.map +1 -1
  54. package/dist/screens/conversation-inbox/index.js +2 -2
  55. package/dist/services/query.d.ts +2 -0
  56. package/dist/services/query.d.ts.map +1 -1
  57. package/dist/services/query.js +2 -0
  58. package/dist/services/routes.d.ts +2 -0
  59. package/dist/services/routes.d.ts.map +1 -1
  60. package/dist/services/routes.js +2 -0
  61. package/dist/tsconfig.tsbuildinfo +1 -1
  62. package/dist/types/chat.d.ts +5 -2
  63. package/dist/types/chat.d.ts.map +1 -1
  64. package/dist/types/chat.js +4 -4
  65. package/dist/types/conversation.d.ts +4 -0
  66. package/dist/types/conversation.d.ts.map +1 -1
  67. package/dist/utils/botFlow.d.ts +7 -0
  68. package/dist/utils/botFlow.d.ts.map +1 -0
  69. package/dist/utils/botFlow.js +9 -0
  70. package/dist/utils/common.d.ts +3 -0
  71. package/dist/utils/common.d.ts.map +1 -1
  72. package/dist/utils/common.js +16 -2
  73. package/package.json +1 -1
@@ -1,8 +1,10 @@
1
+ import type { MoreOptionConfig } from "../../constants/moreOption";
1
2
  export interface ConversationDetailInputProps {
2
3
  placeholder?: string;
3
4
  onSendMessage?: (text: string) => void;
4
5
  onInputChange?: (value: string) => void;
6
+ moreOptions?: MoreOptionConfig[];
5
7
  }
6
- declare const ConversationDetailInput: ({ placeholder, onSendMessage, onInputChange, }: ConversationDetailInputProps) => import("react/jsx-runtime").JSX.Element;
8
+ declare const ConversationDetailInput: ({ placeholder, onSendMessage, onInputChange, moreOptions, }: ConversationDetailInputProps) => import("react/jsx-runtime").JSX.Element;
7
9
  export default ConversationDetailInput;
8
10
  //# sourceMappingURL=ConversationDetailInput.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConversationDetailInput.d.ts","sourceRoot":"","sources":["../../../src/components/conversation-detail/ConversationDetailInput.tsx"],"names":[],"mappings":"AA+BA,MAAM,WAAW,4BAA4B;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED,QAAA,MAAM,uBAAuB,GAAI,gDAI9B,4BAA4B,4CA6Y9B,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
1
+ {"version":3,"file":"ConversationDetailInput.d.ts","sourceRoot":"","sources":["../../../src/components/conversation-detail/ConversationDetailInput.tsx"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAK/D,MAAM,WAAW,4BAA4B;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,WAAW,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAClC;AAED,QAAA,MAAM,uBAAuB,GAAI,6DAK9B,4BAA4B,4CA8Y9B,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
@@ -20,7 +20,7 @@ import { ReplyPreviewBar } from "../../components/message/reply/ReplyPreviewBar"
20
20
  import ConversationMoreOptionPanel from "./ConversationMoreOptionPanel";
21
21
  const MAX_LINES = 5;
22
22
  const CONTAINER_MIN_HEIGHT = 48;
23
- const ConversationDetailInput = ({ placeholder, onSendMessage, onInputChange, }) => {
23
+ const ConversationDetailInput = ({ placeholder, onSendMessage, onInputChange, moreOptions, }) => {
24
24
  const { t } = useTranslation("conversation-inbox");
25
25
  const { t: tCommon } = useTranslation("common");
26
26
  const conversationData = useConversationStore((state) => state.conversationData);
@@ -254,6 +254,6 @@ const ConversationDetailInput = ({ placeholder, onSendMessage, onInputChange, })
254
254
  };
255
255
  return (_jsxs("div", { ref: containerRef, "data-testid": "conversation-detail-input", className: "flex w-full shrink-0 flex-col bg-chat-bubble-neutral/[0.05]", children: [_jsx("input", { ref: mediaInputRef, type: "file", accept: "image/jpeg,image/png,image/jpg,video/*", multiple: true, className: "hidden", onChange: handleMediaInputChange }), _jsx("input", { ref: documentInputRef, type: "file", accept: ".pdf,.doc,.docx", multiple: true, className: "hidden", onChange: handleDocumentInputChange }), _jsx(ReplyPreviewBar, {}), listUploadFiles.length > 0 && (_jsx(FilePreviewList, { files: listUploadFiles, onRemove: (file) => handleRemoveFile(file.uid), onVideoReady: () => setIsVideoLoading(false) })), showLinkPreview && previewUrl && (_jsx(LinkInputPreview, { url: previewUrl, onRemove: () => setPreviewDismissed(true) })), _jsxs("div", { className: "flex items-end gap-3 px-3 py-2", children: [_jsx("div", { className: "flex shrink-0 items-center", children: _jsx("button", { type: "button", onClick: handleToggleMoreOption, "aria-label": t("thread_detail.more_option.toggle"), "aria-expanded": isMoreOptionOpen, "data-testid": "conversation-detail-more-option-toggle", className: "flex py-3 items-center justify-center rounded-full", children: isMoreOptionOpen ? (_jsx(Icon, { icon: "close-circle-b", size: 24, className: "text-primary-400" })) : (_jsx(Icon, { icon: "plus-circle-o", size: 24, className: "text-gray-900" })) }) }), _jsx("div", { className: clsx("flex min-w-0 flex-1 overflow-hidden rounded-xl border bg-white transition-shadow", isFocused
256
256
  ? "border-primary-200 shadow-primary-focus"
257
- : "border-gray-50"), style: { minHeight: CONTAINER_MIN_HEIGHT }, children: _jsx("div", { className: "flex min-w-0 flex-[1_0_0] items-center gap-2 self-stretch px-3 py-1", children: _jsx("textarea", { ref: textareaRef, value: value, rows: 1, onChange: (event) => handleChange(event.target.value), onFocus: handleFocus, onBlur: handleBlur, onKeyDown: handleKeyDown, placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : t("thread_detail.input_placeholder"), "data-testid": "conversation-detail-message-input", className: "conversation-message-input-scrollbar min-h-0 min-w-0 flex-1 resize-none appearance-none border-0 bg-transparent p-0 text-[16px] leading-[1.6] tracking-[0.16px] text-black outline-none ring-0 placeholder:text-gray-400 focus:border-0 focus:outline-none focus:ring-0" }) }) }), _jsx("div", { className: "flex shrink-0 items-center pb-1", children: _jsx("button", { type: "button", onClick: () => void handleSend(), disabled: !canSend, "data-testid": "conversation-detail-send", className: clsx("flex h-10 w-10 items-center justify-center rounded-full", canSend ? "bg-chat-send" : "bg-chat-send opacity-25"), children: _jsx(Icon, { icon: "send-b", size: 20, className: "text-white" }) }) })] }), isMoreOptionOpen && (_jsx(ConversationMoreOptionPanel, { disabled: !isConversationReady, onTriggerMediaInput: () => { var _a; return (_a = mediaInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, onTriggerDocumentInput: () => { var _a; return (_a = documentInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); } }))] }));
257
+ : "border-gray-50"), style: { minHeight: CONTAINER_MIN_HEIGHT }, children: _jsx("div", { className: "flex min-w-0 flex-[1_0_0] items-center gap-2 self-stretch px-3 py-1", children: _jsx("textarea", { ref: textareaRef, value: value, rows: 1, onChange: (event) => handleChange(event.target.value), onFocus: handleFocus, onBlur: handleBlur, onKeyDown: handleKeyDown, placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : t("thread_detail.input_placeholder"), "data-testid": "conversation-detail-message-input", className: "conversation-message-input-scrollbar min-h-0 min-w-0 flex-1 resize-none appearance-none border-0 bg-transparent p-0 text-[16px] leading-[1.6] tracking-[0.16px] text-black outline-none ring-0 placeholder:text-gray-400 focus:border-0 focus:outline-none focus:ring-0" }) }) }), _jsx("div", { className: "flex shrink-0 items-center pb-1", children: _jsx("button", { type: "button", onClick: () => void handleSend(), disabled: !canSend, "data-testid": "conversation-detail-send", className: clsx("flex h-10 w-10 items-center justify-center rounded-full", canSend ? "bg-chat-send" : "bg-chat-send opacity-25"), children: _jsx(Icon, { icon: "send-b", size: 20, className: "text-white" }) }) })] }), isMoreOptionOpen && (_jsx(ConversationMoreOptionPanel, { disabled: !isConversationReady, options: moreOptions, onTriggerMediaInput: () => { var _a; return (_a = mediaInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, onTriggerDocumentInput: () => { var _a; return (_a = documentInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); } }))] }));
258
258
  };
259
259
  export default ConversationDetailInput;
@@ -1,10 +1,11 @@
1
1
  import { MoreOptionConfig } from "../../constants/moreOption";
2
2
  export interface ConversationMoreOptionPanelProps {
3
3
  disabled?: boolean;
4
+ options?: MoreOptionConfig[];
4
5
  onSelectOption?: (option: MoreOptionConfig) => void;
5
6
  onTriggerMediaInput?: () => void;
6
7
  onTriggerDocumentInput?: () => void;
7
8
  }
8
- declare const ConversationMoreOptionPanel: ({ disabled, onSelectOption, onTriggerMediaInput, onTriggerDocumentInput, }: ConversationMoreOptionPanelProps) => import("react/jsx-runtime").JSX.Element;
9
+ declare const ConversationMoreOptionPanel: ({ disabled, options, onSelectOption, onTriggerMediaInput, onTriggerDocumentInput, }: ConversationMoreOptionPanelProps) => import("react/jsx-runtime").JSX.Element;
9
10
  export default ConversationMoreOptionPanel;
10
11
  //# sourceMappingURL=ConversationMoreOptionPanel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConversationMoreOptionPanel.d.ts","sourceRoot":"","sources":["../../../src/components/conversation-detail/ConversationMoreOptionPanel.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAGhC,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACpD,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,sBAAsB,CAAC,EAAE,MAAM,IAAI,CAAC;CACrC;AAED,QAAA,MAAM,2BAA2B,GAAI,4EAKlC,gCAAgC,4CA8BlC,CAAC;AAEF,eAAe,2BAA2B,CAAC"}
1
+ {"version":3,"file":"ConversationMoreOptionPanel.d.ts","sourceRoot":"","sources":["../../../src/components/conversation-detail/ConversationMoreOptionPanel.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,gBAAgB,EAEjB,MAAM,wBAAwB,CAAC;AAGhC,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC7B,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACpD,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,sBAAsB,CAAC,EAAE,MAAM,IAAI,CAAC;CACrC;AAED,QAAA,MAAM,2BAA2B,GAAI,qFAMlC,gCAAgC,4CAkClC,CAAC;AAEF,eAAe,2BAA2B,CAAC"}
@@ -1,20 +1,24 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { useCallback } from "react";
4
- import { MORE_OPTIONS, } from "../../constants/moreOption";
4
+ import { MORE_OPTIONS, MoreOptionKey, } from "../../constants/moreOption";
5
5
  import ConversationMoreOptionItem from "./ConversationMoreOptionItem";
6
- const ConversationMoreOptionPanel = ({ disabled = false, onSelectOption, onTriggerMediaInput, onTriggerDocumentInput, }) => {
6
+ const ConversationMoreOptionPanel = ({ disabled = false, options = MORE_OPTIONS, onSelectOption, onTriggerMediaInput, onTriggerDocumentInput, }) => {
7
7
  const handleSelectOption = useCallback((option) => {
8
- if (option.labelKey === "thread_detail.more_option.media") {
8
+ if (option.key === MoreOptionKey.Media) {
9
9
  onTriggerMediaInput === null || onTriggerMediaInput === void 0 ? void 0 : onTriggerMediaInput();
10
10
  return;
11
11
  }
12
- if (option.labelKey === "thread_detail.more_option.document") {
12
+ if (option.key === MoreOptionKey.Document) {
13
13
  onTriggerDocumentInput === null || onTriggerDocumentInput === void 0 ? void 0 : onTriggerDocumentInput();
14
14
  return;
15
15
  }
16
+ if (option.onSelect) {
17
+ option.onSelect();
18
+ return;
19
+ }
16
20
  onSelectOption === null || onSelectOption === void 0 ? void 0 : onSelectOption(option);
17
21
  }, [onSelectOption, onTriggerMediaInput, onTriggerDocumentInput]);
18
- return (_jsx("div", { "data-testid": "conversation-more-option-panel", className: "grid grid-cols-4 gap-y-5 bg-white py-5", children: MORE_OPTIONS.map((option) => (_jsx(ConversationMoreOptionItem, { option: Object.assign(Object.assign({}, option), { enabled: option.enabled && !disabled }), onSelect: handleSelectOption }, option.labelKey))) }));
22
+ return (_jsx("div", { "data-testid": "conversation-more-option-panel", className: "grid grid-cols-4 gap-y-5 bg-white py-5", children: options.map((option) => (_jsx(ConversationMoreOptionItem, { option: Object.assign(Object.assign({}, option), { enabled: option.enabled && !disabled }), onSelect: handleSelectOption }, option.key))) }));
19
23
  };
20
24
  export default ConversationMoreOptionPanel;
@@ -1 +1 @@
1
- {"version":3,"file":"BotButtonMessage.d.ts","sourceRoot":"","sources":["../../../../src/components/conversation-detail/bot/BotButtonMessage.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAI5D,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,QAAA,MAAM,gBAAgB,GAAI,6CAKvB,qBAAqB,mDA4EvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"BotButtonMessage.d.ts","sourceRoot":"","sources":["../../../../src/components/conversation-detail/bot/BotButtonMessage.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAI5D,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,QAAA,MAAM,gBAAgB,GAAI,6CAKvB,qBAAqB,mDA8EvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -5,12 +5,14 @@ import { useTranslation } from "react-i18next";
5
5
  import { Icon } from "../../../components/icon";
6
6
  import MessageBubble from "../../../components/message/item/MessageBubble";
7
7
  import { BOT_BUTTON_MENU_THRESHOLD, BOT_DEFAULT_BUTTON_ID, } from "../../../constants/botFlow";
8
+ import { filterVisibleBotButtons } from "../../../utils/botFlow";
8
9
  const CHEVRON_SIZE = 20;
9
10
  const BotButtonMessage = ({ buttons, disabled, onSelect, onRestart, }) => {
10
11
  const { t } = useTranslation("conversation-inbox");
11
- if (buttons.length === 0)
12
+ const visibleButtons = filterVisibleBotButtons(buttons);
13
+ if (visibleButtons.length === 0)
12
14
  return null;
13
- const isMenuStyle = buttons.length > BOT_BUTTON_MENU_THRESHOLD;
15
+ const isMenuStyle = visibleButtons.length > BOT_BUTTON_MENU_THRESHOLD;
14
16
  const handleSelect = (actionId) => {
15
17
  if (disabled)
16
18
  return;
@@ -20,9 +22,9 @@ const BotButtonMessage = ({ buttons, disabled, onSelect, onRestart, }) => {
20
22
  }
21
23
  onSelect(actionId);
22
24
  };
23
- const optionsNode = isMenuStyle ? (_jsx("div", { className: "flex flex-col overflow-hidden rounded-xl bg-white", children: buttons.map((option, index) => (_jsxs("button", { type: "button", disabled: disabled, onClick: () => handleSelect(option.id), className: clsx("flex items-center gap-4 px-3 py-2 text-left transition-colors", index !== buttons.length - 1 && "border-b border-gray-25", disabled && "cursor-not-allowed opacity-60"), children: [_jsx("span", { className: "flex-1 text-[16px] font-medium leading-[1.6] text-gray-900", children: option.id === BOT_DEFAULT_BUTTON_ID
25
+ const optionsNode = isMenuStyle ? (_jsx("div", { className: "flex flex-col overflow-hidden rounded-xl bg-white", children: visibleButtons.map((option, index) => (_jsxs("button", { type: "button", disabled: disabled, onClick: () => handleSelect(option.id), className: clsx("flex items-center gap-4 px-3 py-2 text-left transition-colors", index !== visibleButtons.length - 1 && "border-b border-gray-25", disabled && "cursor-not-allowed opacity-60"), children: [_jsx("span", { className: "flex-1 text-[16px] font-medium leading-[1.6] text-gray-900", children: option.id === BOT_DEFAULT_BUTTON_ID
24
26
  ? t("thread_detail.bot.restart")
25
- : option.label }), _jsx(Icon, { icon: "angle-right-o", size: CHEVRON_SIZE, className: "text-gray-900" })] }, option.id))) })) : (_jsx("div", { className: "flex flex-col gap-2", children: buttons.map((option) => (_jsx("button", { type: "button", disabled: disabled, onClick: () => handleSelect(option.id), className: clsx("flex flex-1 items-center justify-center gap-2 rounded-lg border border-primary-400 bg-primary-25 px-3 py-2", "text-center text-[14px] font-[510] leading-[160%] text-primary-400 transition-colors", disabled && "cursor-not-allowed opacity-60"), children: _jsx("span", { children: option.id === BOT_DEFAULT_BUTTON_ID
27
+ : option.label }), _jsx(Icon, { icon: "angle-right-o", size: CHEVRON_SIZE, className: "text-gray-900" })] }, option.id))) })) : (_jsx("div", { className: "flex flex-col gap-2", children: visibleButtons.map((option) => (_jsx("button", { type: "button", disabled: disabled, onClick: () => handleSelect(option.id), className: clsx("flex flex-1 items-center justify-center gap-2 rounded-lg border border-primary-400 bg-primary-25 px-3 py-2", "text-center text-[14px] font-[510] leading-[160%] text-primary-400 transition-colors", disabled && "cursor-not-allowed opacity-60"), children: _jsx("span", { children: option.id === BOT_DEFAULT_BUTTON_ID
26
28
  ? t("thread_detail.bot.restart")
27
29
  : option.label }) }, option.id))) }));
28
30
  return (_jsx("div", { className: "flex min-w-0 flex-col gap-2 px-3 py-1 sm:px-4", children: _jsx("div", { className: "flex min-w-0 items-end justify-start pl-3 pr-12", children: _jsx("div", { className: "flex min-w-0 max-w-[75%] flex-col items-start", children: _jsx(MessageBubble, { isMine: false, content: optionsNode }) }) }) }));
@@ -1 +1 @@
1
- {"version":3,"file":"TextMessage.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/TextMessage.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAe,MAAM,yBAAyB,CAAC;AAQnE,UAAU,oBAAoB;IAC5B,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,QAAA,MAAM,eAAe,GAAI,OAAO,oBAAoB,mDAqDnD,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"TextMessage.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/TextMessage.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAOtD,UAAU,oBAAoB;IAC5B,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,QAAA,MAAM,eAAe,GAAI,OAAO,oBAAoB,mDAgDnD,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1,8 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import clsx from "clsx";
4
- import { MessageType } from "@openim/wasm-client-sdk";
5
- import useAuthStore from "../../../store/auth";
6
4
  import { htmlHasFormatting, sanitizeHtml, stripHtml } from "../../../utils/common";
7
5
  import { extractLinkUrls } from "../../../utils/link";
8
6
  import LinkText from "./LinkText";
@@ -10,7 +8,6 @@ import { MESSAGE_TEXT_CLASS } from "./textStyle";
10
8
  const TextMessageItem = (props) => {
11
9
  var _a, _b, _c, _d;
12
10
  const { message } = props;
13
- const isCrm = useAuthStore((state) => state.isCrm);
14
11
  let extendMessageInfo = null;
15
12
  try {
16
13
  extendMessageInfo = JSON.parse((message === null || message === void 0 ? void 0 : message.ex) || "{}");
@@ -19,9 +16,6 @@ const TextMessageItem = (props) => {
19
16
  extendMessageInfo = {};
20
17
  console.error("Failed to parse extendMessageInfo", error);
21
18
  }
22
- if ((message === null || message === void 0 ? void 0 : message.contentType) === MessageType.CustomMessage && !isCrm) {
23
- return null;
24
- }
25
19
  const richHtmlContent = ((_b = (_a = extendMessageInfo === null || extendMessageInfo === void 0 ? void 0 : extendMessageInfo.messageInfo) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.content) || "";
26
20
  if (richHtmlContent && htmlHasFormatting(richHtmlContent)) {
27
21
  const sanitizedContent = sanitizeHtml(richHtmlContent);
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,WAAW,IAAI,eAAe,EAG/B,MAAM,yBAAyB,CAAC;AAiCjC,UAAU,gBAAgB;IACxB,OAAO,EAAE,eAAe,CAAC;IACzB,WAAW,EAAE,eAAe,EAAE,CAAC;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,uBAAuB,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,eAAe,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IACpD,mBAAmB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IAClD,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IACpD,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAeD,QAAA,MAAM,WAAW,GAAI,qMAalB,gBAAgB,mDAuRlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,WAAW,IAAI,eAAe,EAG/B,MAAM,yBAAyB,CAAC;AAiCjC,UAAU,gBAAgB;IACxB,OAAO,EAAE,eAAe,CAAC;IACzB,WAAW,EAAE,eAAe,EAAE,CAAC;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,uBAAuB,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,eAAe,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IACpD,mBAAmB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IAClD,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IACpD,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAeD,QAAA,MAAM,WAAW,GAAI,qMAalB,gBAAgB,mDA8QlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -6,7 +6,7 @@ import { Dropdown, message as toastMessage } from "antd";
6
6
  import { MessageStatus, MessageType, } from "@openim/wasm-client-sdk";
7
7
  import MessageBubble from "./MessageBubble";
8
8
  import { renderBubbleContent } from "./renderMessageContent";
9
- import { getVisibleNeighbor, visibleTypeMessage, } from "../../../hooks/message/useMessage";
9
+ import { getVisibleNeighbor, isMessageHiddenForViewer, } from "../../../hooks/message/useMessage";
10
10
  import { MSG_ITEM_CONTENT_PREFIX, MSG_ITEM_PREFIX } from "../../../constants";
11
11
  import { formatTimestamp } from "../../../utils/common";
12
12
  import useAuthStore from "../../../store/auth";
@@ -127,13 +127,7 @@ const MessageItem = ({ message, allMessages, isGroupChat = false, forceHideTip =
127
127
  const showAvatar = showPeerInfo && !isMine && !nextSameUser;
128
128
  const showSenderName = showPeerInfo && !isMine && !prevSameUser;
129
129
  const showTip = forceHideTip ? false : !nextSameUser;
130
- if (!isCrm && isInternalMessage) {
131
- return null;
132
- }
133
- if ((!isCrm &&
134
- (MessageType.CustomMessage === (message === null || message === void 0 ? void 0 : message.contentType) ||
135
- isSystemLogMessage)) ||
136
- !visibleTypeMessage.includes(message === null || message === void 0 ? void 0 : message.contentType)) {
130
+ if (isMessageHiddenForViewer(message, isCrm)) {
137
131
  return null;
138
132
  }
139
133
  const messageContainerProps = {
@@ -1 +1 @@
1
- {"version":3,"file":"renderMessageContent.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/renderMessageContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,eAAe,EAAe,MAAM,yBAAyB,CAAC;AAWtF,eAAO,MAAM,mBAAmB,GAAI,SAAS,eAAe,4CAuB3D,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,SAAS,eAAe,EACxB,sBAAsB,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,4CAwBpD,CAAC"}
1
+ {"version":3,"file":"renderMessageContent.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/renderMessageContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,eAAe,EAAe,MAAM,yBAAyB,CAAC;AAYtF,eAAO,MAAM,mBAAmB,GAAI,SAAS,eAAe,4CAyB3D,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,SAAS,eAAe,EACxB,sBAAsB,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,4CAwBpD,CAAC"}
@@ -9,6 +9,7 @@ import UrlTextMessageItem from "./UrlTextMessage";
9
9
  import RevokeMessageItem from "./RevokeMessage";
10
10
  import QuoteMessageItem from "./QuoteMessage";
11
11
  import SystemLogMessageItem from "./SystemLogMessage";
12
+ import CustomMessageItem from "./CustomMessage";
12
13
  export const renderMessageByType = (message) => {
13
14
  switch (message === null || message === void 0 ? void 0 : message.contentType) {
14
15
  case MessageType.TextMessage:
@@ -28,6 +29,8 @@ export const renderMessageByType = (message) => {
28
29
  return _jsx(SystemLogMessageItem, { message: message });
29
30
  case MessageType.RevokeMessage:
30
31
  return _jsx(RevokeMessageItem, {});
32
+ case MessageType.CustomMessage:
33
+ return _jsx(CustomMessageItem, { message: message });
31
34
  default:
32
35
  return _jsx(TextMessageItem, { message: message });
33
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ReplyQuoteContent.d.ts","sourceRoot":"","sources":["../../../../src/components/message/reply/ReplyQuoteContent.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AASnE,eAAO,MAAM,oBAAoB,GAAI,aAAa,WAAW,YACb,CAAC;AAEjD,UAAU,sBAAsB;IAC9B,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,iBAAiB,GAAI,qBAG/B,sBAAsB,4CA0BxB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"ReplyQuoteContent.d.ts","sourceRoot":"","sources":["../../../../src/components/message/reply/ReplyQuoteContent.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AASnE,eAAO,MAAM,oBAAoB,GAAI,aAAa,WAAW,YACb,CAAC;AAEjD,UAAU,sBAAsB;IAC9B,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,iBAAiB,GAAI,qBAG/B,sBAAsB,4CA2BxB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -15,6 +15,6 @@ export const ReplyQuoteContent = ({ message, title = "", }) => {
15
15
  return (_jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-0.5 pr-2 self-stretch", children: [_jsx("div", { className: "w-[3px] shrink-0 self-stretch rounded bg-gray-cool-200" }), hasMedia && _jsx(ReplyPreviewMedia, { message: message }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col justify-center py-1 pl-2", children: [_jsx("p", { className: "truncate text-[14px] font-medium leading-[160%] text-gray-900", children: title }), _jsx("p", { className: "truncate text-[13px] leading-[160%] text-gray-400", children: generateContentBasedOnMessageType(message.contentType, ((_a = message.textElem) === null || _a === void 0 ? void 0 : _a.content) || ((_b = message.quoteElem) === null || _b === void 0 ? void 0 : _b.text), t, {
16
16
  duration: (_c = message.videoElem) === null || _c === void 0 ? void 0 : _c.duration,
17
17
  fileName: (_d = message.fileElem) === null || _d === void 0 ? void 0 : _d.fileName,
18
- }) })] })] }));
18
+ }, message.customElem) })] })] }));
19
19
  };
20
20
  export default ReplyQuoteContent;
@@ -1,3 +1,5 @@
1
1
  export declare const BOT_DEFAULT_BUTTON_ID = "default-item-button";
2
2
  export declare const BOT_BUTTON_MENU_THRESHOLD = 3;
3
+ export declare const BOT_HIDDEN_COMMAND_PREFIX = "context:";
4
+ export declare const BOT_COMMAND_CHAT_WITH_CS = "context:chat_with_cs";
3
5
  //# sourceMappingURL=botFlow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"botFlow.d.ts","sourceRoot":"","sources":["../../src/constants/botFlow.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,wBAAwB,CAAC;AAE3D,eAAO,MAAM,yBAAyB,IAAI,CAAC"}
1
+ {"version":3,"file":"botFlow.d.ts","sourceRoot":"","sources":["../../src/constants/botFlow.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,wBAAwB,CAAC;AAE3D,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C,eAAO,MAAM,yBAAyB,aAAa,CAAC;AAEpD,eAAO,MAAM,wBAAwB,yBAAyB,CAAC"}
@@ -1,2 +1,4 @@
1
1
  export const BOT_DEFAULT_BUTTON_ID = "default-item-button";
2
2
  export const BOT_BUTTON_MENU_THRESHOLD = 3;
3
+ export const BOT_HIDDEN_COMMAND_PREFIX = "context:";
4
+ export const BOT_COMMAND_CHAT_WITH_CS = "context:chat_with_cs";
@@ -1,7 +1,18 @@
1
+ export declare const MoreOptionKey: {
2
+ readonly Media: "media";
3
+ readonly Camera: "camera";
4
+ readonly Document: "document";
5
+ readonly Order: "order";
6
+ readonly Product: "product";
7
+ readonly Appointment: "appointment";
8
+ };
9
+ export type MoreOptionKey = (typeof MoreOptionKey)[keyof typeof MoreOptionKey];
1
10
  export interface MoreOptionConfig {
11
+ key: string;
2
12
  icon: string;
3
13
  labelKey: string;
4
14
  enabled: boolean;
15
+ onSelect?: () => void;
5
16
  }
6
17
  export declare const DEFAULT_MORE_OPTIONS: MoreOptionConfig[];
7
18
  export declare function createMoreOptions(extraOptions?: MoreOptionConfig[]): MoreOptionConfig[];
@@ -1 +1 @@
1
- {"version":3,"file":"moreOption.d.ts","sourceRoot":"","sources":["../../src/constants/moreOption.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,eAAO,MAAM,oBAAoB,EAAE,gBAAgB,EAgBlD,CAAC;AAEF,wBAAgB,iBAAiB,CAC/B,YAAY,GAAE,gBAAgB,EAAO,GACpC,gBAAgB,EAAE,CAEpB;AAED,eAAO,MAAM,YAAY,EAAE,gBAAgB,EAgBzC,CAAC"}
1
+ {"version":3,"file":"moreOption.d.ts","sourceRoot":"","sources":["../../src/constants/moreOption.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;;;;;;CAOhB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE/E,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,eAAO,MAAM,oBAAoB,EAAE,gBAAgB,EAmBlD,CAAC;AAEF,wBAAgB,iBAAiB,CAC/B,YAAY,GAAE,gBAAgB,EAAO,GACpC,gBAAgB,EAAE,CAEpB;AAED,eAAO,MAAM,YAAY,EAAE,gBAAgB,EAmBzC,CAAC"}
@@ -1,15 +1,26 @@
1
+ export const MoreOptionKey = {
2
+ Media: "media",
3
+ Camera: "camera",
4
+ Document: "document",
5
+ Order: "order",
6
+ Product: "product",
7
+ Appointment: "appointment",
8
+ };
1
9
  export const DEFAULT_MORE_OPTIONS = [
2
10
  {
11
+ key: MoreOptionKey.Media,
3
12
  icon: "image-02-o",
4
13
  labelKey: "thread_detail.more_option.media",
5
14
  enabled: true,
6
15
  },
7
16
  {
17
+ key: MoreOptionKey.Camera,
8
18
  icon: "camera-o",
9
19
  labelKey: "thread_detail.more_option.camera",
10
20
  enabled: false,
11
21
  },
12
22
  {
23
+ key: MoreOptionKey.Document,
13
24
  icon: "paperclip-o",
14
25
  labelKey: "thread_detail.more_option.document",
15
26
  enabled: true,
@@ -20,16 +31,19 @@ export function createMoreOptions(extraOptions = []) {
20
31
  }
21
32
  export const MORE_OPTIONS = createMoreOptions([
22
33
  {
34
+ key: MoreOptionKey.Order,
23
35
  icon: "receipt-o",
24
36
  labelKey: "thread_detail.more_option.order",
25
37
  enabled: false,
26
38
  },
27
39
  {
40
+ key: MoreOptionKey.Product,
28
41
  icon: "shopping-basket-o",
29
42
  labelKey: "thread_detail.more_option.product",
30
43
  enabled: false,
31
44
  },
32
45
  {
46
+ key: MoreOptionKey.Appointment,
33
47
  icon: "calendar-active-o",
34
48
  labelKey: "thread_detail.more_option.appointment",
35
49
  enabled: false,
@@ -2,5 +2,5 @@ import "../styles/global.css";
2
2
  import { ChatContextType, ChatProviderProps } from "../types/chat";
3
3
  export declare const ChatContext: import("react").Context<ChatContextType>;
4
4
  export declare const useChatContext: () => ChatContextType;
5
- export declare const ChatProvider: ({ children, config }: ChatProviderProps) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const ChatProvider: ({ children, config, renderCustomMessage, }: ChatProviderProps) => import("react/jsx-runtime").JSX.Element;
6
6
  //# sourceMappingURL=ChatContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChatContext.d.ts","sourceRoot":"","sources":["../../src/context/ChatContext.tsx"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,CAAC;AAG9B,OAAO,EACL,eAAe,EACf,iBAAiB,EAGlB,MAAM,cAAc,CAAC;AAStB,eAAO,MAAM,WAAW,0CAOtB,CAAC;AAEH,eAAO,MAAM,cAAc,uBAAgC,CAAC;AAE5D,eAAO,MAAM,YAAY,GAAI,sBAAsB,iBAAiB,4CAqGnE,CAAC"}
1
+ {"version":3,"file":"ChatContext.d.ts","sourceRoot":"","sources":["../../src/context/ChatContext.tsx"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,CAAC;AAG9B,OAAO,EACL,eAAe,EACf,iBAAiB,EAGlB,MAAM,cAAc,CAAC;AAStB,eAAO,MAAM,WAAW,0CAOtB,CAAC;AAEH,eAAO,MAAM,cAAc,uBAAgC,CAAC;AAE5D,eAAO,MAAM,YAAY,GAAI,4CAI1B,iBAAiB,4CAsGnB,CAAC"}
@@ -18,7 +18,7 @@ export const ChatContext = createContext({
18
18
  updateSyncStatus: () => { },
19
19
  });
20
20
  export const useChatContext = () => useContext(ChatContext);
21
- export const ChatProvider = ({ children, config }) => {
21
+ export const ChatProvider = ({ children, config, renderCustomMessage, }) => {
22
22
  const [connectStatus, setConnectStatus] = useState(ConnectStatus.Disconnected);
23
23
  const [syncStatus, setSyncStatus] = useState(SyncStatus.Success);
24
24
  const [user, setUser] = useState(null);
@@ -91,5 +91,6 @@ export const ChatProvider = ({ children, config }) => {
91
91
  getSelfUserInfo,
92
92
  updateConnectStatus,
93
93
  updateSyncStatus,
94
+ renderCustomMessage,
94
95
  }, children: _jsx(ConfigProvider, { getPopupContainer: (triggerNode) => document.body, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(MainLayout, { children: children }) }) }) }));
95
96
  };
@@ -1,3 +1,4 @@
1
1
  import type { BotConversationDetail } from "../../types/conversation";
2
+ export declare const fetchBotConversationDetail: (conversationId: string) => Promise<BotConversationDetail>;
2
3
  export declare const useBotConversationDetail: (conversationId: string, enabled: boolean) => import("@tanstack/react-query").UseQueryResult<BotConversationDetail, Error>;
3
4
  //# sourceMappingURL=useBotConversationDetail.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useBotConversationDetail.d.ts","sourceRoot":"","sources":["../../../src/hooks/conversation/useBotConversationDetail.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAElE,eAAO,MAAM,wBAAwB,GACnC,gBAAgB,MAAM,EACtB,SAAS,OAAO,iFAejB,CAAC"}
1
+ {"version":3,"file":"useBotConversationDetail.d.ts","sourceRoot":"","sources":["../../../src/hooks/conversation/useBotConversationDetail.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAElE,eAAO,MAAM,0BAA0B,GACrC,gBAAgB,MAAM,KACrB,OAAO,CAAC,qBAAqB,CAK/B,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,gBAAgB,MAAM,EACtB,SAAS,OAAO,iFAUjB,CAAC"}
@@ -3,13 +3,14 @@ import { useQuery } from "@tanstack/react-query";
3
3
  import { apiInstance } from "../../services/api";
4
4
  import { ENDPOINTS } from "../../services/routes";
5
5
  import { QUERY_KEYS } from "../../services/query";
6
+ export const fetchBotConversationDetail = async (conversationId) => {
7
+ const res = await apiInstance.get(ENDPOINTS.chatService.getConversationDetail(conversationId));
8
+ return res.data.data;
9
+ };
6
10
  export const useBotConversationDetail = (conversationId, enabled) => {
7
11
  return useQuery({
8
12
  queryKey: [QUERY_KEYS.GET_CONVERSATION_DETAIL, conversationId],
9
- queryFn: async () => {
10
- const res = await apiInstance.get(ENDPOINTS.chatService.getConversationDetail(conversationId));
11
- return res.data.data;
12
- },
13
+ queryFn: () => fetchBotConversationDetail(conversationId),
13
14
  enabled: enabled && !!conversationId,
14
15
  staleTime: 0,
15
16
  refetchOnWindowFocus: false,
@@ -0,0 +1,4 @@
1
+ import type { BotMainMenuItem } from "../../types/conversation";
2
+ export declare const fetchBotMainMenu: (conversationId: string) => Promise<BotMainMenuItem[]>;
3
+ export declare const useBotMainMenu: (conversationId: string, enabled: boolean) => import("@tanstack/react-query").UseQueryResult<BotMainMenuItem[], Error>;
4
+ //# sourceMappingURL=useBotMainMenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBotMainMenu.d.ts","sourceRoot":"","sources":["../../../src/hooks/conversation/useBotMainMenu.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,eAAO,MAAM,gBAAgB,GAC3B,gBAAgB,MAAM,KACrB,OAAO,CAAC,eAAe,EAAE,CAK3B,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,gBAAgB,MAAM,EAAE,SAAS,OAAO,6EAMtE,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { apiInstance } from "../../services/api";
4
+ import { ENDPOINTS } from "../../services/routes";
5
+ import { QUERY_KEYS } from "../../services/query";
6
+ export const fetchBotMainMenu = async (conversationId) => {
7
+ const res = await apiInstance.get(ENDPOINTS.chatService.getBotMainMenu(conversationId));
8
+ return res.data.data || [];
9
+ };
10
+ export const useBotMainMenu = (conversationId, enabled) => {
11
+ return useQuery({
12
+ queryKey: [QUERY_KEYS.GET_BOT_MAIN_MENU, conversationId],
13
+ queryFn: () => fetchBotMainMenu(conversationId),
14
+ enabled: enabled && !!conversationId,
15
+ });
16
+ };
@@ -0,0 +1,11 @@
1
+ export interface UseResolveConversationParams {
2
+ conversationId?: string;
3
+ userId?: string;
4
+ groupId?: string;
5
+ botId?: string;
6
+ }
7
+ export declare const useResolveConversation: ({ conversationId, userId, groupId, botId, }: UseResolveConversationParams) => {
8
+ isResolving: boolean;
9
+ error: Error | null;
10
+ };
11
+ //# sourceMappingURL=useResolveConversation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useResolveConversation.d.ts","sourceRoot":"","sources":["../../../src/hooks/conversation/useResolveConversation.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,4BAA4B;IAC3C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAOD,eAAO,MAAM,sBAAsB,GAAI,6CAKpC,4BAA4B;;;CAmG9B,CAAC"}
@@ -0,0 +1,90 @@
1
+ "use client";
2
+ import { useEffect, useState } from "react";
3
+ import { SessionType } from "@openim/wasm-client-sdk";
4
+ import { DChatSDK } from "../../constants/sdk";
5
+ import { apiInstance } from "../../services/api";
6
+ import { ENDPOINTS } from "../../services/routes";
7
+ import useConversationStore from "../../store/conversation";
8
+ import { resolveConversationBotId } from "../../utils/conversation";
9
+ export const useResolveConversation = ({ conversationId, userId, groupId, botId, }) => {
10
+ const [isResolving, setIsResolving] = useState(false);
11
+ const [error, setError] = useState(null);
12
+ const conversationData = useConversationStore((state) => state.conversationData);
13
+ const setConversationData = useConversationStore((state) => state.setConversationData);
14
+ const setSelectedConversationId = useConversationStore((state) => state.setSelectedConversationId);
15
+ const hasTarget = !!(conversationId || userId || groupId || botId);
16
+ const matchesConversationId = !!conversationId && (conversationData === null || conversationData === void 0 ? void 0 : conversationData.conversationID) === conversationId;
17
+ const matchesUserId = !!userId && (conversationData === null || conversationData === void 0 ? void 0 : conversationData.userID) === userId;
18
+ const matchesGroupId = !!groupId && (conversationData === null || conversationData === void 0 ? void 0 : conversationData.groupID) === groupId;
19
+ const matchesBotId = !!botId &&
20
+ !!conversationData &&
21
+ resolveConversationBotId(conversationData) === botId;
22
+ const isAlreadyResolved = matchesConversationId || matchesUserId || matchesGroupId || matchesBotId;
23
+ useEffect(() => {
24
+ if (!hasTarget || isAlreadyResolved)
25
+ return;
26
+ let cancelled = false;
27
+ setIsResolving(true);
28
+ setError(null);
29
+ const resolve = async () => {
30
+ var _a, _b;
31
+ try {
32
+ let resolved = null;
33
+ if (conversationId) {
34
+ const { data } = await DChatSDK.getMultipleConversation([conversationId]);
35
+ resolved = (_a = data === null || data === void 0 ? void 0 : data[0]) !== null && _a !== void 0 ? _a : null;
36
+ }
37
+ else if (userId || groupId) {
38
+ const { data } = await DChatSDK.getOneConversation({
39
+ sourceID: (userId || groupId),
40
+ sessionType: userId ? SessionType.Single : SessionType.Group,
41
+ });
42
+ resolved = data;
43
+ }
44
+ else if (botId) {
45
+ const { data: botConversationResponse } = await apiInstance.get(ENDPOINTS.chatService.getConversationByBotId(botId));
46
+ const resolvedGroupId = (_b = botConversationResponse.data) === null || _b === void 0 ? void 0 : _b.groupId;
47
+ if (!resolvedGroupId) {
48
+ throw new Error("Missing groupId from get-or-create bot conversation response");
49
+ }
50
+ const { data: conversation } = await DChatSDK.getOneConversation({
51
+ sourceID: resolvedGroupId,
52
+ sessionType: SessionType.Group,
53
+ });
54
+ resolved = conversation;
55
+ }
56
+ if (cancelled)
57
+ return;
58
+ if (!resolved) {
59
+ throw new Error("Conversation not found");
60
+ }
61
+ setConversationData(resolved);
62
+ setSelectedConversationId(resolved.conversationID);
63
+ }
64
+ catch (err) {
65
+ if (cancelled)
66
+ return;
67
+ console.error("useResolveConversation", err);
68
+ setError(err instanceof Error ? err : new Error("Failed to resolve conversation"));
69
+ }
70
+ finally {
71
+ if (!cancelled)
72
+ setIsResolving(false);
73
+ }
74
+ };
75
+ void resolve();
76
+ return () => {
77
+ cancelled = true;
78
+ };
79
+ }, [
80
+ conversationId,
81
+ userId,
82
+ groupId,
83
+ botId,
84
+ hasTarget,
85
+ isAlreadyResolved,
86
+ setConversationData,
87
+ setSelectedConversationId,
88
+ ]);
89
+ return { isResolving, error };
90
+ };
@@ -0,0 +1,6 @@
1
+ export type SwitchToCsTeamResult = "already_in_cs" | "switched" | "failed";
2
+ export declare const useSwitchToCsTeam: () => {
3
+ switchToCsTeam: (conversationId: string) => Promise<SwitchToCsTeamResult>;
4
+ isPending: boolean;
5
+ };
6
+ //# sourceMappingURL=useSwitchToCsTeam.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSwitchToCsTeam.d.ts","sourceRoot":"","sources":["../../../src/hooks/conversation/useSwitchToCsTeam.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,oBAAoB,GAAG,eAAe,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE3E,eAAO,MAAM,iBAAiB;qCAKH,MAAM,KAAG,OAAO,CAAC,oBAAoB,CAAC;;CAuChE,CAAC"}
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ import { useCallback } from "react";
3
+ import { useQueryClient } from "@tanstack/react-query";
4
+ import { QUERY_KEYS } from "../../services/query";
5
+ import { BOT_COMMAND_CHAT_WITH_CS } from "../../constants/botFlow";
6
+ import { isInCsSession, findMainMenuAction } from "../../utils/botFlow";
7
+ import { fetchBotConversationDetail } from "./useBotConversationDetail";
8
+ import { fetchBotMainMenu } from "./useBotMainMenu";
9
+ import { useRunBotFlow } from "./useRunBotFlow";
10
+ export const useSwitchToCsTeam = () => {
11
+ const queryClient = useQueryClient();
12
+ const { mutateAsync: runBotFlow, isPending } = useRunBotFlow();
13
+ const switchToCsTeam = useCallback(async (conversationId) => {
14
+ try {
15
+ const detail = await fetchBotConversationDetail(conversationId);
16
+ if (isInCsSession(detail)) {
17
+ return "already_in_cs";
18
+ }
19
+ const mainMenu = await fetchBotMainMenu(conversationId);
20
+ const chatWithCsAction = findMainMenuAction(mainMenu, BOT_COMMAND_CHAT_WITH_CS);
21
+ if (!chatWithCsAction) {
22
+ return "failed";
23
+ }
24
+ await runBotFlow({
25
+ conversationId,
26
+ groupId: "",
27
+ childId: "",
28
+ actionId: chatWithCsAction.id,
29
+ });
30
+ await queryClient.invalidateQueries({
31
+ queryKey: [QUERY_KEYS.GET_CONVERSATION_DETAIL, conversationId],
32
+ });
33
+ return "switched";
34
+ }
35
+ catch (error) {
36
+ console.error("switchToCsTeam", error);
37
+ return "failed";
38
+ }
39
+ }, [runBotFlow, queryClient]);
40
+ return { switchToCsTeam, isPending };
41
+ };
@@ -1,5 +1,6 @@
1
1
  import { MessageItem, MessageType } from "@openim/wasm-client-sdk";
2
2
  export declare const visibleTypeMessage: MessageType[];
3
+ export declare const isMessageHiddenForViewer: (message: MessageItem, isCrm: boolean) => boolean;
3
4
  export declare const useMessage: (conversationId?: string, searchClientMsgID?: string, enabled?: boolean, useAppHistory?: boolean) => {
4
5
  loadState: {
5
6
  initLoading: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"useMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useMessage.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,WAAW,EACX,WAAW,EAEZ,MAAM,yBAAyB,CAAC;AAUjC,eAAO,MAAM,kBAAkB,eAgB9B,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,iBAAiB,MAAM,EACvB,oBAAoB,MAAM,EAC1B,iBAAc,EACd,uBAAqB;;;;;qBAeA,WAAW,EAAE;;;;;;qBAAb,WAAW,EAAE;;;;;;CAiSnC,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,SAAS,WAAW,SACpB,CAAC;AAChC,eAAO,MAAM,gBAAgB,GAAI,SAAS,WAAW,SACpB,CAAC;AAClC,eAAO,MAAM,gBAAgB,GAAI,aAAa,MAAM,SACf,CAAC;AAEtC,eAAO,MAAM,kBAAkB,GAC7B,aAAa,WAAW,EAAE,EAC1B,SAAS,WAAW,EACpB,WAAW,MAAM,GAAG,MAAM,KACzB,WAAW,GAAG,SAkBhB,CAAC"}
1
+ {"version":3,"file":"useMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useMessage.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,WAAW,EACX,WAAW,EAEZ,MAAM,yBAAyB,CAAC;AAYjC,eAAO,MAAM,kBAAkB,eAgB9B,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,SAAS,WAAW,EACpB,OAAO,OAAO,KACb,OAWF,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,iBAAiB,MAAM,EACvB,oBAAoB,MAAM,EAC1B,iBAAc,EACd,uBAAqB;;;;;qBAeA,WAAW,EAAE;;;;;;qBAAb,WAAW,EAAE;;;;;;CAiSnC,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,SAAS,WAAW,SACpB,CAAC;AAChC,eAAO,MAAM,gBAAgB,GAAI,SAAS,WAAW,SACpB,CAAC;AAClC,eAAO,MAAM,gBAAgB,GAAI,aAAa,MAAM,SACf,CAAC;AAEtC,eAAO,MAAM,kBAAkB,GAC7B,aAAa,WAAW,EAAE,EAC1B,SAAS,WAAW,EACpB,WAAW,MAAM,GAAG,MAAM,KACzB,WAAW,GAAG,SAkBhB,CAAC"}