@infinilabs/chat-message 0.0.4 → 0.0.5
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/README.md +39 -23
- package/dist/ChatMessage.cjs +12 -12
- package/dist/ChatMessage.iife.js +12 -12
- package/dist/ChatMessage.js +951 -3759
- package/dist/ChatMessage.umd.cjs +12 -12
- package/dist/components/SessionFiles/components/Icon.d.ts +3 -0
- package/dist/components/SessionFiles/index.d.ts +2 -0
- package/dist/components/index.d.ts +7 -0
- package/dist/utils/platformAdapter.d.ts +8 -1
- package/package.json +8 -1
package/README.md
CHANGED
|
@@ -50,44 +50,60 @@ import { ChatMessage, ChatMessageRef, IChatMessage } from '@infinilabs/chat-mess
|
|
|
50
50
|
function App() {
|
|
51
51
|
const chatRef = useRef<ChatMessageRef>(null);
|
|
52
52
|
|
|
53
|
-
// Initial empty message structure
|
|
54
53
|
const message: IChatMessage = {
|
|
55
54
|
_id: 'streaming-msg',
|
|
56
|
-
_source: {
|
|
57
|
-
type: 'assistant',
|
|
58
|
-
message: '',
|
|
59
|
-
details: []
|
|
60
|
-
}
|
|
55
|
+
_source: { type: 'assistant', message: '', details: [] }
|
|
61
56
|
};
|
|
62
57
|
|
|
63
58
|
const handleStream = async () => {
|
|
64
|
-
// 1. Reset component state for new stream
|
|
65
59
|
chatRef.current?.reset();
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
// Example: Thinking chunk
|
|
69
|
-
chatRef.current?.addChunk({
|
|
70
|
-
chunk_type: 'think',
|
|
71
|
-
message_chunk: 'Thinking process...'
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
// Example: Response chunk
|
|
75
|
-
chatRef.current?.addChunk({
|
|
76
|
-
chunk_type: 'response',
|
|
77
|
-
message_chunk: 'Hello world!'
|
|
78
|
-
});
|
|
60
|
+
chatRef.current?.addChunk({ chunk_type: 'think', message_chunk: '...' });
|
|
61
|
+
chatRef.current?.addChunk({ chunk_type: 'response', message_chunk: 'Hello world!' });
|
|
79
62
|
};
|
|
80
63
|
|
|
81
64
|
return (
|
|
82
|
-
<ChatMessage
|
|
65
|
+
<ChatMessage
|
|
83
66
|
ref={chatRef}
|
|
84
|
-
message={message}
|
|
85
|
-
isTyping
|
|
67
|
+
message={message}
|
|
68
|
+
isTyping
|
|
86
69
|
/>
|
|
87
70
|
);
|
|
88
71
|
}
|
|
89
72
|
```
|
|
90
73
|
|
|
74
|
+
### List Rendering with Streaming (Recommended)
|
|
75
|
+
|
|
76
|
+
When rendering a list of messages, attach the `ref` only to the last assistant message while streaming, and pass `isTyping` to that active message.
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import { useRef } from 'react';
|
|
80
|
+
import { ChatMessage, ChatMessageRef } from '@infinilabs/chat-message';
|
|
81
|
+
|
|
82
|
+
function MessagesList({ messages, isTyping, locale, theme }) {
|
|
83
|
+
const activeMessageRef = useRef<ChatMessageRef>(null);
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<div>
|
|
87
|
+
{messages.map((msg, index) => {
|
|
88
|
+
const isLast = index === messages.length - 1;
|
|
89
|
+
const isAssistant = msg._source.type === 'assistant';
|
|
90
|
+
const shouldAttachRef = isLast && isAssistant && isTyping;
|
|
91
|
+
return (
|
|
92
|
+
<ChatMessage
|
|
93
|
+
key={msg._id}
|
|
94
|
+
ref={shouldAttachRef ? activeMessageRef : null}
|
|
95
|
+
message={msg}
|
|
96
|
+
locale={locale}
|
|
97
|
+
theme={theme}
|
|
98
|
+
isTyping={shouldAttachRef}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
})}
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
91
107
|
## Props
|
|
92
108
|
|
|
93
109
|
| Prop | Type | Default | Description |
|
package/dist/ChatMessage.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),Y=require("react-i18next"),he=require("clsx"),vt=require("i18next"),N=require("lucide-react"),Ge=require("@ant-design/x-markdown"),Fe=require("zustand"),jt=require("ahooks"),_t=require("@infinilabs/attachments");var ye={exports:{}},de={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var Ve;function bt(){if(Ve)return de;Ve=1;var r=i,n=Symbol.for("react.element"),d=Symbol.for("react.fragment"),f=Object.prototype.hasOwnProperty,c=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,_={key:!0,ref:!0,__self:!0,__source:!0};function y(p,l,g){var o,j={},m=null,b=null;g!==void 0&&(m=""+g),l.key!==void 0&&(m=""+l.key),l.ref!==void 0&&(b=l.ref);for(o in l)f.call(l,o)&&!_.hasOwnProperty(o)&&(j[o]=l[o]);if(p&&p.defaultProps)for(o in l=p.defaultProps,l)j[o]===void 0&&(j[o]=l[o]);return{$$typeof:n,type:p,key:m,ref:b,props:j,_owner:c.current}}return de.Fragment=d,de.jsx=y,de.jsxs=y,de}var fe={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,19 +14,19 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
`+
|
|
19
|
-
`),
|
|
20
|
-
`),
|
|
21
|
-
`+S
|
|
17
|
+
*/var Ke;function wt(){return Ke||(Ke=1,process.env.NODE_ENV!=="production"&&(function(){var r=i,n=Symbol.for("react.element"),d=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),c=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),y=Symbol.for("react.provider"),p=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),o=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),b=Symbol.for("react.offscreen"),I=Symbol.iterator,U="@@iterator";function w(e){if(e===null||typeof e!="object")return null;var s=I&&e[I]||e[U];return typeof s=="function"?s:null}var x=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function R(e){{for(var s=arguments.length,a=new Array(s>1?s-1:0),u=1;u<s;u++)a[u-1]=arguments[u];re("error",e,a)}}function re(e,s,a){{var u=x.ReactDebugCurrentFrame,E=u.getStackAddendum();E!==""&&(s+="%s",a=a.concat([E]));var C=a.map(function(v){return String(v)});C.unshift("Warning: "+s),Function.prototype.apply.call(console[e],console,C)}}var ne=!1,V=!1,ae=!1,X=!1,K=!1,P;P=Symbol.for("react.module.reference");function ie(e){return!!(typeof e=="string"||typeof e=="function"||e===f||e===_||K||e===c||e===g||e===o||X||e===b||ne||V||ae||typeof e=="object"&&e!==null&&(e.$$typeof===m||e.$$typeof===j||e.$$typeof===y||e.$$typeof===p||e.$$typeof===l||e.$$typeof===P||e.getModuleId!==void 0))}function je(e,s,a){var u=e.displayName;if(u)return u;var E=s.displayName||s.name||"";return E!==""?a+"("+E+")":a}function xe(e){return e.displayName||"Context"}function q(e){if(e==null)return null;if(typeof e.tag=="number"&&R("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case f:return"Fragment";case d:return"Portal";case _:return"Profiler";case c:return"StrictMode";case g:return"Suspense";case o:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case p:var s=e;return xe(s)+".Consumer";case y:var a=e;return xe(a._context)+".Provider";case l:return je(e,e.render,"ForwardRef");case j:var u=e.displayName||null;return u!==null?u:q(e.type)||"Memo";case m:{var E=e,C=E._payload,v=E._init;try{return q(v(C))}catch{return null}}}return null}var D=Object.assign,z=0,me,H,F,pe,B,oe,G;function $(){}$.__reactDisabledLog=!0;function ce(){{if(z===0){me=console.log,H=console.info,F=console.warn,pe=console.error,B=console.group,oe=console.groupCollapsed,G=console.groupEnd;var e={configurable:!0,enumerable:!0,value:$,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}z++}}function le(){{if(z--,z===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:D({},e,{value:me}),info:D({},e,{value:H}),warn:D({},e,{value:F}),error:D({},e,{value:pe}),group:D({},e,{value:B}),groupCollapsed:D({},e,{value:oe}),groupEnd:D({},e,{value:G})})}z<0&&R("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var J=x.ReactCurrentDispatcher,ue;function W(e,s,a){{if(ue===void 0)try{throw Error()}catch(E){var u=E.stack.trim().match(/\n( *(at )?)/);ue=u&&u[1]||""}return`
|
|
18
|
+
`+ue+e}}var Z=!1,ee;{var _e=typeof WeakMap=="function"?WeakMap:Map;ee=new _e}function ge(e,s){if(!e||Z)return"";{var a=ee.get(e);if(a!==void 0)return a}var u;Z=!0;var E=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var C;C=J.current,J.current=null,ce();try{if(s){var v=function(){throw Error()};if(Object.defineProperty(v.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(v,[])}catch(O){u=O}Reflect.construct(e,[],v)}else{try{v.call()}catch(O){u=O}e.call(v.prototype)}}else{try{throw Error()}catch(O){u=O}e()}}catch(O){if(O&&u&&typeof O.stack=="string"){for(var k=O.stack.split(`
|
|
19
|
+
`),A=u.stack.split(`
|
|
20
|
+
`),S=k.length-1,T=A.length-1;S>=1&&T>=0&&k[S]!==A[T];)T--;for(;S>=1&&T>=0;S--,T--)if(k[S]!==A[T]){if(S!==1||T!==1)do if(S--,T--,T<0||k[S]!==A[T]){var L=`
|
|
21
|
+
`+k[S].replace(" at new "," at ");return e.displayName&&L.includes("<anonymous>")&&(L=L.replace("<anonymous>",e.displayName)),typeof e=="function"&&ee.set(e,L),L}while(S>=1&&T>=0);break}}}finally{Z=!1,J.current=C,le(),Error.prepareStackTrace=E}var se=e?e.displayName||e.name:"",Q=se?W(se):"";return typeof e=="function"&&ee.set(e,Q),Q}function be(e,s,a){return ge(e,!1)}function we(e){var s=e.prototype;return!!(s&&s.isReactComponent)}function h(e,s,a){if(e==null)return"";if(typeof e=="function")return ge(e,we(e));if(typeof e=="string")return W(e);switch(e){case g:return W("Suspense");case o:return W("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case l:return be(e.render);case j:return h(e.type,s,a);case m:{var u=e,E=u._payload,C=u._init;try{return h(C(E),s,a)}catch{}}}return""}var M=Object.prototype.hasOwnProperty,Ae={},Oe=x.ReactDebugCurrentFrame;function ke(e){if(e){var s=e._owner,a=h(e.type,e._source,s?s.type:null);Oe.setExtraStackFrame(a)}else Oe.setExtraStackFrame(null)}function He(e,s,a,u,E){{var C=Function.call.bind(M);for(var v in e)if(C(e,v)){var k=void 0;try{if(typeof e[v]!="function"){var A=Error((u||"React class")+": "+a+" type `"+v+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[v]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw A.name="Invariant Violation",A}k=e[v](s,v,u,a,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(S){k=S}k&&!(k instanceof Error)&&(ke(E),R("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",u||"React class",a,v,typeof k),ke(null)),k instanceof Error&&!(k.message in Ae)&&(Ae[k.message]=!0,ke(E),R("Failed %s type: %s",a,k.message),ke(null))}}}var Ze=Array.isArray;function Ee(e){return Ze(e)}function et(e){{var s=typeof Symbol=="function"&&Symbol.toStringTag,a=s&&e[Symbol.toStringTag]||e.constructor.name||"Object";return a}}function tt(e){try{return Pe(e),!1}catch{return!0}}function Pe(e){return""+e}function Le(e){if(tt(e))return R("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",et(e)),Pe(e)}var Ie=x.ReactCurrentOwner,st={key:!0,ref:!0,__self:!0,__source:!0},$e,We;function rt(e){if(M.call(e,"ref")){var s=Object.getOwnPropertyDescriptor(e,"ref").get;if(s&&s.isReactWarning)return!1}return e.ref!==void 0}function nt(e){if(M.call(e,"key")){var s=Object.getOwnPropertyDescriptor(e,"key").get;if(s&&s.isReactWarning)return!1}return e.key!==void 0}function at(e,s){typeof e.ref=="string"&&Ie.current}function it(e,s){{var a=function(){$e||($e=!0,R("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",s))};a.isReactWarning=!0,Object.defineProperty(e,"key",{get:a,configurable:!0})}}function ot(e,s){{var a=function(){We||(We=!0,R("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",s))};a.isReactWarning=!0,Object.defineProperty(e,"ref",{get:a,configurable:!0})}}var ct=function(e,s,a,u,E,C,v){var k={$$typeof:n,type:e,key:s,ref:a,props:v,_owner:C};return k._store={},Object.defineProperty(k._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(k,"_self",{configurable:!1,enumerable:!1,writable:!1,value:u}),Object.defineProperty(k,"_source",{configurable:!1,enumerable:!1,writable:!1,value:E}),Object.freeze&&(Object.freeze(k.props),Object.freeze(k)),k};function lt(e,s,a,u,E){{var C,v={},k=null,A=null;a!==void 0&&(Le(a),k=""+a),nt(s)&&(Le(s.key),k=""+s.key),rt(s)&&(A=s.ref,at(s,E));for(C in s)M.call(s,C)&&!st.hasOwnProperty(C)&&(v[C]=s[C]);if(e&&e.defaultProps){var S=e.defaultProps;for(C in S)v[C]===void 0&&(v[C]=S[C])}if(k||A){var T=typeof e=="function"?e.displayName||e.name||"Unknown":e;k&&it(v,T),A&&ot(v,T)}return ct(e,k,A,E,u,Ie.current,v)}}var Ne=x.ReactCurrentOwner,Me=x.ReactDebugCurrentFrame;function te(e){if(e){var s=e._owner,a=h(e.type,e._source,s?s.type:null);Me.setExtraStackFrame(a)}else Me.setExtraStackFrame(null)}var Ce;Ce=!1;function Re(e){return typeof e=="object"&&e!==null&&e.$$typeof===n}function qe(){{if(Ne.current){var e=q(Ne.current.type);if(e)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function ut(e){return""}var Ue={};function dt(e){{var s=qe();if(!s){var a=typeof e=="string"?e:e.displayName||e.name;a&&(s=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+
|
|
25
|
+
Check the top-level render call using <`+a+">.")}return s}}function De(e,s){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var a=dt(s);if(Ue[a])return;Ue[a]=!0;var u="";e&&e._owner&&e._owner!==Ne.current&&(u=" It was passed a child from "+q(e._owner.type)+"."),te(e),R('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',a,u),te(null)}}function Be(e,s){{if(typeof e!="object")return;if(Ee(e))for(var a=0;a<e.length;a++){var u=e[a];Re(u)&&De(u,s)}else if(Re(e))e._store&&(e._store.validated=!0);else if(e){var E=w(e);if(typeof E=="function"&&E!==e.entries)for(var C=E.call(e),v;!(v=C.next()).done;)Re(v.value)&&De(v.value,s)}}}function ft(e){{var s=e.type;if(s==null||typeof s=="string")return;var a;if(typeof s=="function")a=s.propTypes;else if(typeof s=="object"&&(s.$$typeof===l||s.$$typeof===j))a=s.propTypes;else return;if(a){var u=q(s);He(a,e.props,"prop",u,e)}else if(s.PropTypes!==void 0&&!Ce){Ce=!0;var E=q(s);R("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",E||"Unknown")}typeof s.getDefaultProps=="function"&&!s.getDefaultProps.isReactClassApproved&&R("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ht(e){{for(var s=Object.keys(e.props),a=0;a<s.length;a++){var u=s[a];if(u!=="children"&&u!=="key"){te(e),R("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",u),te(null);break}}e.ref!==null&&(te(e),R("Invalid attribute `ref` supplied to `React.Fragment`."),te(null))}}var Ye={};function Je(e,s,a,u,E,C){{var v=ie(e);if(!v){var k="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(k+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var A=ut();A?k+=A:k+=qe();var S;e===null?S="null":Ee(e)?S="array":e!==void 0&&e.$$typeof===n?(S="<"+(q(e.type)||"Unknown")+" />",k=" Did you accidentally export a JSX literal instead of a component?"):S=typeof e,R("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",S,k)}var T=lt(e,s,a,E,C);if(T==null)return T;if(v){var L=s.children;if(L!==void 0)if(u)if(Ee(L)){for(var se=0;se<L.length;se++)Be(L[se],e);Object.freeze&&Object.freeze(L)}else R("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Be(L,e)}if(M.call(s,"key")){var Q=q(e),O=Object.keys(s).filter(function(yt){return yt!=="key"}),Se=O.length>0?"{key: someKey, "+O.join(": ..., ")+": ...}":"{key: someKey}";if(!Ye[Q+Se]){var kt=O.length>0?"{"+O.join(": ..., ")+": ...}":"{}";R(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,qe,be,ar,be),it[be+qe]=!0}}return r===o?tr(W):er(W),W}}function rr(r,l,p){return lt(r,l,p,!0)}function sr(r,l,p){return lt(r,l,p,!1)}var nr=sr,or=rr;Se.Fragment=o,Se.jsx=nr,Se.jsxs=or})()),Se}var ut;function fr(){return ut||(ut=1,process.env.NODE_ENV==="production"?Oe.exports=dr():Oe.exports=ur()),Oe.exports}var t=fr();const mr={en:{translation:{assistant:{message:{logo:"Coco AI Logo",aiName:"Coco AI",thinkingButton:"View thinking process",steps:{query_intent:"Understand the query",tools:"Call LLM Tools",source_zero:"Searching for relevant documents",fetch_source:"Retrieve {{count}} documents",pick_source:"Intelligent pick {{count}} results",pick_source_start:"Intelligently pre-selecting",deep_read:"Deep reading",think:"AI is thinking...",thoughtTime:"Thought for a few seconds",keywords:"Keywords",questionType:"Query Type",userIntent:"User Intent",relatedQuestions:"Query",suggestion:"Suggestion",informationSeeking:"Information Seeking"}}}}},zh:{translation:{assistant:{message:{logo:"Coco AI 图标",aiName:"Coco AI",thinkingButton:"查看思考过程",steps:{query_intent:"理解查询",tools:"调用大模型工具",source_zero:"正在搜索相关文档",fetch_source:"检索 {{count}} 份文档",pick_source:"智能预选 {{count}} 个结果",pick_source_start:"正在智能预选",deep_read:"深度阅读",think:"AI 正在思考...",thoughtTime:"思考了数秒",keywords:"关键词",questionType:"查询类型",userIntent:"用户意图",relatedQuestions:"查询",suggestion:"建议",informationSeeking:"信息查询"}}}}}},kt=lr.createInstance();kt.use(ae.initReactI18next).init({resources:mr,lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1},react:{useSuspense:!1}});const pr="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%3e%3ccircle%20cx='50'%20cy='50'%20r='40'%20stroke='black'%20stroke-width='3'%20fill='red'%20/%3e%3c/svg%3e";function Le({size:e=18,children:s,className:n,title:o,onClick:a,action:d=!1,...c}){const f=i=>{a?.(i)};return t.jsx("i",{style:{width:e,height:e},title:o,onClick:f,className:ue("inline-flex items-center justify-center rounded-sm p-[2px] transition-all",{"cursor-pointer":d},n),children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",style:{width:"100%",height:"100%"},...c,children:s})})}function hr(e){return t.jsx(Le,{...e,viewBox:"0 0 16 16",children:t.jsx("g",{id:"Understand",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsxs("g",{id:"编组",transform:"translate(0.5, 0.5)",stroke:"currentColor",strokeWidth:"1.25",children:[t.jsx("path",{d:"M7.44444444,3 C9.89904333,3 11.8888889,4.95366655 11.8888889,7.36363636 C11.8888889,9.06711551 10.8946979,10.5426108 9.44492275,11.2613085 L9.44444444,12.2727273 C9.44444444,13.3772968 8.54901394,14.2727273 7.44444444,14.2727273 C6.33987494,14.2727273 5.44444444,13.3772968 5.44444444,12.2727273 L5.44396614,11.2613085 C3.99419095,10.5426108 3,9.06711551 3,7.36363636 C3,4.95366655 4.98984556,3 7.44444444,3 Z",id:"形状结合"}),t.jsx("line",{x1:"5.5",y1:"11.2156017",x2:"9.5",y2:"11.2156017",id:"路径-11"}),t.jsx("line",{x1:"7.44444444",y1:"10.6363636",x2:"7.44444444",y2:"8.45454545",id:"路径-12"}),t.jsx("line",{x1:"7.44444444",y1:"0.818181818",x2:"7.44444444",y2:"0.272727273",id:"路径-12备份"}),t.jsx("line",{x1:"12.352383",y1:"2.81770629",x2:"12.3574335",y2:"2.26720124",id:"路径-12备份",transform:"translate(12.3549, 2.5425) rotate(45) translate(-12.3549, -2.5425)"}),t.jsx("line",{x1:"14.3888889",y1:"7.64141414",x2:"14.3888889",y2:"7.08585859",id:"路径-12备份",transform:"translate(14.3889, 7.3636) rotate(90) translate(-14.3889, -7.3636)"}),t.jsx("line",{x1:"12.3574335",y1:"12.4600715",x2:"12.352383",y2:"11.9095664",id:"路径-12备份",transform:"translate(12.3549, 12.1848) rotate(135) translate(-12.3549, -12.1848)"}),t.jsx("line",{x1:"2.53145543",y1:"12.4600715",x2:"2.53650594",y2:"11.9095664",id:"路径-12备份",transform:"translate(2.534, 12.1848) rotate(225) translate(-2.534, -12.1848)"}),t.jsx("line",{x1:"0.5",y1:"7.64141414",x2:"0.5",y2:"7.08585859",id:"路径-12备份",transform:"translate(0.5, 7.3636) rotate(270) translate(-0.5, -7.3636)"}),t.jsx("line",{x1:"2.53650594",y1:"2.81770629",x2:"2.53145543",y2:"2.26720124",id:"路径-12备份",transform:"translate(2.534, 2.5425) rotate(315) translate(-2.534, -2.5425)"}),t.jsx("polyline",{id:"路径-15",transform:"translate(7.4398, 6.7308) rotate(-45) translate(-7.4398, -6.7308)",points:"6.33632897 5.60310185 6.3568375 7.83853192 8.5432888 7.85859111"})]})})})}const xr=({Detail:e,ChunkData:s,getSuggestion:n,loading:o})=>{const{t:a}=ae.useTranslation(),[d,c]=h.useState(!1),[f,i]=h.useState(null);return h.useEffect(()=>{e?.payload&&(i(e?.payload),e?.payload?.suggestion&&n&&n(e?.payload?.suggestion))},[e?.payload,n]),h.useEffect(()=>{if(s?.message_chunk&&!o)try{const u=s.message_chunk.replace(/^"|"$/g,"").match(/<JSON>([\s\S]*?)<\/JSON>/g);if(u){const b=u[u.length-1].replace(/<JSON>|<\/JSON>/g,""),N=JSON.parse(b);N?.suggestion&&n&&n(N?.suggestion),i(N)}}catch(m){console.error("Failed to process message chunk in QueryIntent:",m)}},[s?.message_chunk,o,n]),!s&&!e?null:t.jsxs("div",{className:"space-y-2 mb-3 w-full",children:[t.jsxs("button",{onClick:()=>c(m=>!m),className:"inline-flex items-center gap-2 px-2 py-1 rounded-xl transition-colors border border-[#E6E6E6] dark:border-[#272626]",children:[o?t.jsxs(t.Fragment,{children:[t.jsx(T.Loader,{className:"w-4 h-4 animate-spin text-[#1990FF]"}),t.jsx("span",{className:"text-xs text-[#999999] italic",children:a(`assistant.message.steps.${s?.chunk_type||e.type}`)})]}):t.jsxs(t.Fragment,{children:[t.jsx(hr,{className:"w-4 h-4 text-[#38C200]"}),t.jsx("span",{className:"text-xs text-[#999999]",children:a(`assistant.message.steps.${s?.chunk_type||e.type}`)})]}),d?t.jsx(T.ChevronUp,{className:"w-4 h-4"}):t.jsx(T.ChevronDown,{className:"w-4 h-4"})]}),d&&t.jsx("div",{className:"pl-2 border-l-2 border-[#e5e5e5] dark:border-[#4e4e56]",children:t.jsx("div",{className:"text-[#8b8b8b] dark:text-[#a6a6a6] space-y-2",children:t.jsxs("div",{className:"mb-4 space-y-2 text-xs",children:[f?.keyword?t.jsxs("div",{className:"flex gap-1",children:[t.jsxs("span",{className:"text-[#999999]",children:["- ",a("assistant.message.steps.keywords"),":"]}),t.jsx("div",{className:"flex flex-wrap gap-1",children:f?.keyword?.map((m,u)=>t.jsxs("span",{className:"text-[#333333] dark:text-[#D8D8D8]",children:[m,u<2&&"、"]},m+u))})]}):null,f?.category?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsxs("span",{className:"text-[#999999]",children:["- ",a("assistant.message.steps.questionType"),":"]}),t.jsx("span",{className:"text-[#333333] dark:text-[#D8D8D8]",children:f?.category})]}):null,f?.intent?t.jsxs("div",{className:"flex items-start gap-1",children:[t.jsxs("span",{className:"text-[#999999]",children:["- ",a("assistant.message.steps.userIntent"),":"]}),t.jsx("div",{className:"flex-1 text-[#333333] dark:text-[#D8D8D8]",children:f?.intent})]}):null,f?.query?t.jsxs("div",{className:"flex items-start gap-1",children:[t.jsxs("span",{className:"text-[#999999]",children:["- ",a("assistant.message.steps.relatedQuestions"),":"]}),t.jsx("div",{className:"flex-1 flex flex-col text-[#333333] dark:text-[#D8D8D8]",children:f?.query?.map((m,u)=>t.jsxs("span",{children:["- ",m]},m+u))})]}):null]})})})]})},gr=({Detail:e,ChunkData:s,loading:n})=>{const{t:o}=ae.useTranslation(),[a,d]=h.useState(!1),[c,f]=h.useState("");return h.useEffect(()=>{e?.description&&f(e?.description)},[e?.description]),h.useEffect(()=>{s?.message_chunk&&f(s?.message_chunk)},[s?.message_chunk,c]),!s&&!e?null:t.jsxs("div",{className:"space-y-2 mb-3 w-full",children:[t.jsxs("button",{onClick:()=>d(i=>!i),className:"inline-flex items-center gap-2 px-2 py-1 rounded-xl transition-colors border border-[#E6E6E6] dark:border-[#272626]",children:[n?t.jsxs(t.Fragment,{children:[t.jsx(T.Loader,{className:"w-4 h-4 animate-spin text-[#1990FF]"}),t.jsx("span",{className:"text-xs text-[#999999] italic",children:o(`assistant.message.steps.${s?.chunk_type}`)})]}):t.jsxs(t.Fragment,{children:[t.jsx(T.Hammer,{className:"w-4 h-4 text-[#38C200]"}),t.jsx("span",{className:"text-xs text-[#999999]",children:o(`assistant.message.steps.${s?.chunk_type}`)})]}),a?t.jsx(T.ChevronUp,{className:"w-4 h-4"}):t.jsx(T.ChevronDown,{className:"w-4 h-4"})]}),a&&t.jsx("div",{className:"pl-2 border-l-2 border-[#e5e5e5] dark:border-[#4e4e56]",children:t.jsx("div",{className:"text-[#8b8b8b] dark:text-[#a6a6a6] space-y-2",children:t.jsx(gt.XMarkdown,{content:c||""})})})]})},yt=async e=>{navigator.clipboard?await navigator.clipboard.writeText(e):console.log("Clipboard not available",e)},br=e=>{window.open(e,"_blank")},kr=e=>e+" B";function yr(e){return t.jsx(Le,{...e,viewBox:"0 0 16 16",children:t.jsxs("g",{id:"Retrieve",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"10.8977456",y1:"14.5",x2:"14",y2:"10.9204757",id:"路径",stroke:"currentColor",strokeWidth:"1.25",transform:"translate(12.4489, 12.7102) scale(-1, 1) translate(-12.4489, -12.7102)"}),t.jsx("circle",{id:"椭圆形",stroke:"currentColor",strokeWidth:"1.25",transform:"translate(7.5, 7) scale(-1, 1) translate(-7.5, -7)",cx:"7.5",cy:"7",r:"5"})]})})}const vr=({Detail:e,ChunkData:s,loading:n,formatUrl:o})=>{const{t:a}=ae.useTranslation(),[d,c]=h.useState(!1),[f,i]=h.useState(0),[m,u]=h.useState([]);h.useEffect(()=>{e?.payload&&(u(e?.payload),i(e?.payload.length))},[e?.payload]),h.useEffect(()=>{if(s?.message_chunk&&!n)try{const b=s.message_chunk.match(/<Payload total=(\d+)>/);b&&i(Number(b[1]));const N=s.message_chunk.match(/\[([\s\S]*)\]/);if(N){const I=JSON.parse(N[0]);u(I)}}catch(b){console.error("Failed to parse fetch source data:",b)}},[s?.message_chunk,n]);const v=b=>()=>{const N=o&&o(b)||b.url;N&&br(N)};return!s&&!e?null:t.jsxs("div",{className:`mt-2 mb-2 max-w-full w-full md:w-[610px] ${d?"rounded-lg overflow-hidden border border-[#E6E6E6] dark:border-[#272626]":""}`,children:[t.jsxs("button",{onClick:()=>c(b=>!b),className:`inline-flex justify-between items-center gap-2 px-2 py-1 rounded-xl transition-colors whitespace-nowrap ${d?"w-full":"border border-[#E6E6E6] dark:border-[#272626]"}`,children:[t.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[t.jsx(yr,{className:"w-4 h-4 text-[#38C200] shrink-0"}),t.jsx("span",{className:"text-xs text-[#999999]",children:a(`assistant.message.steps.${s?.chunk_type||e.type}`,{count:Number(f)})})]}),d?t.jsx(T.ChevronUp,{className:"w-4 h-4 text-[#999999]"}):t.jsx(T.ChevronDown,{className:"w-4 h-4 text-[#999999]"})]}),d&&t.jsx(t.Fragment,{children:m?.map((b,N)=>t.jsx("div",{onClick:v(b),className:"group flex items-center p-2 hover:bg-[#F7F7F7] dark:hover:bg-[#2C2C2C] border-b border-[#E6E6E6] dark:border-[#272626] last:border-b-0 cursor-pointer transition-colors",children:t.jsxs("div",{className:"w-full flex items-center gap-2",children:[t.jsxs("div",{className:"w-[75%] mobile:w-full flex items-center gap-1",children:[t.jsx(T.Globe,{className:"w-3 h-3 shrink-0"}),t.jsx("div",{className:"text-xs text-[#333333] dark:text-[#D8D8D8] truncate font-normal group-hover:text-[#0072FF] dark:group-hover:text-[#0072FF]",children:b.title||b.category})]}),t.jsxs("div",{className:"flex-1 mobile:hidden flex items-center justify-end gap-2",children:[t.jsx("span",{className:"text-xs text-[#999999] dark:text-[#999999] truncate",children:b.source?.name||b?.category}),t.jsx(T.SquareArrowOutUpRight,{className:"w-3 h-3 text-[#999999] dark:text-[#999999] shrink-0"})]})]})},N))})]})};function wr(e){return t.jsx(Le,{...e,viewBox:"0 0 16 16",children:t.jsx("g",{id:"selection",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:t.jsxs("g",{id:"编组",transform:"translate(1.4813, 1)",stroke:"currentColor",strokeWidth:"1.25",children:[t.jsx("line",{x1:"6.7986538",y1:"2.8",x2:"6.7986538",y2:"2.07241631e-17",id:"路径",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("circle",{id:"椭圆形",fill:"#000000",cx:"6.7986538",cy:"6.72",r:"1"}),t.jsx("line",{x1:"2.17440858e-17",y1:"13.5186538",x2:"4.62042688",y2:"8.89822692",id:"路径",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("line",{x1:"10.1008425",y1:"4.16781133",x2:"10.1008425",y2:"2.66781133",id:"路径",strokeLinecap:"round",strokeLinejoin:"round",transform:"translate(10.1008, 3.4178) rotate(45) translate(-10.1008, -3.4178)"}),t.jsx("line",{x1:"12.1186538",y1:"8.12",x2:"12.1186538",y2:"5.32",id:"路径",strokeLinecap:"round",strokeLinejoin:"round",transform:"translate(12.1187, 6.72) rotate(90) translate(-12.1187, -6.72)"}),t.jsx("line",{x1:"10.1008425",y1:"10.7721887",x2:"10.1008425",y2:"9.27218867",id:"路径",strokeLinecap:"round",strokeLinejoin:"round",transform:"translate(10.1008, 10.0222) rotate(135) translate(-10.1008, -10.0222)"}),t.jsx("line",{x1:"6.7986538",y1:"13.44",x2:"6.7986538",y2:"10.64",id:"路径",strokeLinecap:"round",strokeLinejoin:"round",transform:"translate(6.7987, 12.04) rotate(180) translate(-6.7987, -12.04)"}),t.jsx("line",{x1:"1.4786538",y1:"8.12",x2:"1.4786538",y2:"5.32",id:"路径",strokeLinecap:"round",strokeLinejoin:"round",transform:"translate(1.4787, 6.72) rotate(270) translate(-1.4787, -6.72)"}),t.jsx("line",{x1:"3.49646513",y1:"4.16781133",x2:"3.49646513",y2:"2.66781133",id:"路径",strokeLinecap:"round",strokeLinejoin:"round",transform:"translate(3.4965, 3.4178) rotate(315) translate(-3.4965, -3.4178)"})]})})})}const jr=({Detail:e,ChunkData:s,loading:n})=>{const{t:o}=ae.useTranslation(),[a,d]=h.useState(!1),[c,f]=h.useState([]);return h.useEffect(()=>{e?.payload&&f(e?.payload)},[e?.payload]),h.useEffect(()=>{if(s?.message_chunk&&!n)try{const m=s.message_chunk.replace(/^"|"$/g,"").match(/<JSON>([\s\S]*?)<\/JSON>/g);if(m)for(let u=m.length-1;u>=0;u--)try{const v=m[u].replace(/<JSON>|<\/JSON>|<think>|<\/think>/g,""),b=JSON.parse(v.trim());if(Array.isArray(b)&&b.every(N=>N.id&&N.title&&N.explain)){f(b);break}}catch{continue}}catch(i){console.error("Failed to parse pick source data:",i)}},[s?.message_chunk,n]),!s&&!e?null:t.jsxs("div",{className:"space-y-2 mb-3 w-full",children:[t.jsxs("button",{onClick:()=>d(i=>!i),className:"inline-flex items-center gap-2 px-2 py-1 rounded-xl transition-colors border border-[#E6E6E6] dark:border-[#272626]",children:[n?t.jsxs(t.Fragment,{children:[t.jsx(T.Loader,{className:"w-4 h-4 animate-spin text-[#1990FF]"}),t.jsx("span",{className:"text-xs text-[#999999] italic",children:o("assistant.message.steps.pick_source_start")})]}):t.jsxs(t.Fragment,{children:[t.jsx(wr,{className:"w-4 h-4 text-[#38C200]"}),t.jsx("span",{className:"text-xs text-[#999999]",children:o(`assistant.message.steps.${s?.chunk_type||e.type}`,{count:c?.length})})]}),a?t.jsx(T.ChevronUp,{className:"w-4 h-4"}):t.jsx(T.ChevronDown,{className:"w-4 h-4"})]}),a&&t.jsx("div",{className:"pl-2 border-l-2 border-[#e5e5e5] dark:border-[#4e4e56]",children:t.jsx("div",{className:"text-[#8b8b8b] dark:text-[#a6a6a6] space-y-2",children:t.jsx("div",{className:"mb-4 space-y-3 text-xs",children:c?.map(i=>t.jsx("div",{className:"p-3 rounded-lg border border-[#E6E6E6] dark:border-[#272626] bg-white dark:bg-[#1E1E1E] hover:bg-gray-50 dark:hover:bg-[#2C2C2C] transition-colors",children:t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("div",{className:"text-sm font-medium text-[#333333] dark:text-[#D8D8D8]",children:i.title}),t.jsx("div",{className:"text-xs text-[#666666] dark:text-[#A3A3A3] line-clamp-2",children:i.explain})]})},i.id))})})})]})};function _r(e){return t.jsx(Le,{...e,viewBox:"0 0 16 16",children:t.jsxs("g",{id:"deading",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:[t.jsx("circle",{id:"椭圆形",stroke:"currentColor",strokeWidth:"1.25",cx:"8",cy:"3",r:"1.375"}),t.jsx("circle",{id:"椭圆形备份-2",stroke:"currentColor",strokeWidth:"1.25",cx:"3",cy:"5",r:"1.375"}),t.jsx("circle",{id:"椭圆形备份-4",stroke:"currentColor",strokeWidth:"1.25",cx:"13",cy:"5",r:"1.375"}),t.jsx("circle",{id:"椭圆形备份",stroke:"currentColor",strokeWidth:"1.25",cx:"8",cy:"13",r:"1.375"}),t.jsx("circle",{id:"椭圆形备份-3",stroke:"currentColor",strokeWidth:"1.25",cx:"3",cy:"11",r:"1.375"}),t.jsx("circle",{id:"椭圆形备份-5",stroke:"currentColor",strokeWidth:"1.25",cx:"13",cy:"11",r:"1.375"}),t.jsx("path",{d:"M8.0070039,4.03345364 L8.0070039,8.50590493 L4.1923477,10.2855921",id:"路径-13",stroke:"currentColor",strokeWidth:"1.25"}),t.jsx("line",{x1:"11.7924093",y1:"8.47550067",x2:"8",y2:"10.2754456",id:"路径-13备份",stroke:"currentColor",strokeWidth:"1.25",transform:"translate(9.8962, 9.3755) scale(-1, 1) translate(-9.8962, -9.3755)"}),t.jsx("path",{d:"M4.17568738,4.53038288 L6.65384701,3.54050563 M9.35480875,3.53987819 L11.7283558,4.49062879",id:"形状",stroke:"currentColor",strokeWidth:"1.25"}),t.jsx("line",{x1:"3",y1:"6.06946104",x2:"3",y2:"9.97988046",id:"路径-14",stroke:"currentColor",strokeWidth:"1.25"}),t.jsx("line",{x1:"13",y1:"6.06946104",x2:"13",y2:"9.97988046",id:"路径-14备份",stroke:"currentColor",strokeWidth:"1.25"})]})})}const Cr=({Detail:e,ChunkData:s,loading:n})=>{const{t:o}=ae.useTranslation(),[a,d]=h.useState(!1),[c,f]=h.useState([]),[i,m]=h.useState("");return h.useEffect(()=>{e?.description&&m(e?.description)},[e?.description]),h.useEffect(()=>{if(s?.message_chunk)try{if(s.message_chunk.includes("&")){const u=s.message_chunk.split("&").filter(Boolean);f(u)}else f([s.message_chunk])}catch(u){console.error("Failed to parse query data:",u)}},[s?.message_chunk]),!s&&!e?null:t.jsxs("div",{className:"space-y-2 mb-3 w-full",children:[t.jsxs("button",{onClick:()=>d(u=>!u),className:"inline-flex items-center gap-2 px-2 py-1 rounded-xl transition-colors border border-[#E6E6E6] dark:border-[#272626]",children:[n?t.jsxs(t.Fragment,{children:[t.jsx(T.Loader,{className:"w-4 h-4 animate-spin text-[#1990FF]"}),t.jsx("span",{className:"text-xs text-[#999999] italic",children:o(`assistant.message.steps.${s?.chunk_type||e?.type}`)})]}):t.jsxs(t.Fragment,{children:[t.jsx(_r,{className:"w-4 h-4 text-[#38C200]"}),t.jsx("span",{className:"text-xs text-[#999999]",children:o(`assistant.message.steps.${s?.chunk_type||e?.type}`,{count:Number(c.length)})})]}),a?t.jsx(T.ChevronUp,{className:"w-4 h-4"}):t.jsx(T.ChevronDown,{className:"w-4 h-4"})]}),a&&t.jsx("div",{className:"pl-2 border-l-2 border-[#e5e5e5] dark:border-[#4e4e56]",children:t.jsx("div",{className:"text-[#8b8b8b] dark:text-[#a6a6a6] space-y-2",children:t.jsxs("div",{className:"mb-4 space-y-3 text-xs",children:[c?.map(u=>t.jsx("div",{className:"flex flex-col gap-2",children:t.jsxs("div",{className:"text-xs text-[#999999] dark:text-[#808080]",children:["- ",u]})},u)),i?.split(`
|
|
31
|
-
`).map((
|
|
32
|
-
`).map((i,m)=>i.trim()&&t.jsx("p",{className:"text-sm",children:i},m))})})]})},Er=Ge.create(e=>({synthesizeItem:null,setSynthesizeItem:s=>e({synthesizeItem:s}),uploadAttachments:[],setUploadAttachments:s=>e({uploadAttachments:s})})),Sr=["timedout","error"],Rr=({id:e,content:s,question:n,actionClassName:o,actionIconSize:a,copyButtonId:d,onResend:c})=>{const[f,i]=h.useState(!1),[m,u]=h.useState(!1),[v,b]=h.useState(!1),[N,I]=h.useState(!1),[q,C]=h.useState(!1),y=Sr.includes(e),{synthesizeItem:F,setSynthesizeItem:Q}=Er(),ee=async()=>{try{await yt(s),i(!0);const z=setTimeout(()=>{i(!1),clearTimeout(z)},2e3)}catch(z){console.error("copy error:",z)}},te=()=>{u(!m),b(!1)},H=()=>{b(!v),u(!1)},ne=async()=>Q({id:e,content:s}),w=()=>{if(c){C(!0),c();const z=setTimeout(()=>{C(!1),clearTimeout(z)},1e3)}};return t.jsxs("div",{className:ue("flex items-center gap-1 mt-2",o),children:[!y&&t.jsx("button",{id:d,onClick:ee,className:"p-1 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg transition-colors",children:f?t.jsx(T.Check,{className:"w-4 h-4 text-[#38C200] dark:text-[#38C200]",style:{width:a,height:a}}):t.jsx(T.Copy,{className:"w-4 h-4 text-[#666666] dark:text-[#A3A3A3]",style:{width:a,height:a}})}),!y&&t.jsx("button",{onClick:te,className:`p-1 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg transition-colors ${m?"animate-shake":""}`,children:t.jsx(T.ThumbsUp,{className:`w-4 h-4 ${m?"text-[#1990FF] dark:text-[#1990FF]":"text-[#666666] dark:text-[#A3A3A3]"}`,style:{width:a,height:a}})}),!y&&t.jsx("button",{onClick:H,className:`p-1 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg transition-colors ${v?"animate-shake":""}`,children:t.jsx(T.ThumbsDown,{className:`w-4 h-4 ${v?"text-[#1990FF] dark:text-[#1990FF]":"text-[#666666] dark:text-[#A3A3A3]"}`,style:{width:a,height:a}})}),!y&&t.jsx(t.Fragment,{children:t.jsx("button",{onClick:ne,className:"p-1 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg transition-colors",children:t.jsx(T.Volume2,{className:`w-4 h-4 ${N||F?.id===e?"text-[#1990FF] dark:text-[#1990FF]":"text-[#666666] dark:text-[#A3A3A3]"}`,style:{width:a,height:a}})})}),n&&t.jsx("button",{onClick:w,className:`p-1 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg transition-colors ${q?"animate-spin":""}`,children:t.jsx(T.RotateCcw,{className:`w-4 h-4 ${q?"text-[#1990FF] dark:text-[#1990FF]":"text-[#666666] dark:text-[#A3A3A3]"}`,style:{width:a,height:a}})})]})};function Tr({suggestions:e,onSelect:s}){return!e||e.length===0?null:t.jsx("div",{className:"mt-4 flex flex-col gap-2",children:e.map((n,o)=>t.jsxs("button",{onClick:()=>s(n),className:"text-left inline-flex items-center px-3 py-1.5 rounded-full bg-white dark:bg-[#202126] border border-[#E4E5EF] dark:border-[#272626] text-sm text-[#666666] dark:text-[#A3A3A3] hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors w-fit max-w-full break-words whitespace-pre-wrap",children:[t.jsx("span",{className:"break-all",children:n}),t.jsx(T.MoveRight,{className:"w-3 h-3 ml-1.5 shrink-0"})]},o))})}const Ar=({textToCopy:e})=>{const[s,n]=h.useState(!1),o=async()=>{try{await yt(e),n(!0);const a=setTimeout(()=>{n(!1),clearTimeout(a)},2e3)}catch(a){console.error("copy error:",a)}};return t.jsx("button",{className:"p-1 bg-gray-200 dark:bg-gray-700 rounded",onClick:o,children:s?t.jsx(T.Check,{className:"w-4 h-4 text-[#38C200] dark:text-[#38C200]"}):t.jsx(T.Copy,{className:"w-4 h-4 text-gray-600 dark:text-gray-300"})})},vt={commands:async(e,s)=>(console.log(`Mock command: ${e}`,s),{hits:{hits:[]}}),invokeBackend:async(e,s)=>{console.log(`Mock invokeBackend: ${e}`,s)}},Ue=Ge.create(e=>({currentAssistant:{},assistantList:[],currentService:{id:"mock-service-id"},setAssistant:s=>e({currentAssistant:s})})),wt=Ye.forwardRef(({className:e,...s},n)=>t.jsx("div",{ref:n,className:ue("relative inline-block",e),...s}));wt.displayName="Popover";const jt=Ye.forwardRef(({className:e,...s},n)=>t.jsx("div",{ref:n,className:ue("inline-block cursor-pointer",e),...s}));jt.displayName="PopoverTrigger";const _t=Ye.forwardRef(({className:e,side:s="bottom",...n},o)=>t.jsx("div",{ref:o,className:ue("absolute z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none",{"bottom-full mb-2":s==="top","top-full mt-2":s==="bottom","right-full mr-2":s==="left","left-full ml-2":s==="right"},e),...n}));_t.displayName="PopoverContent";const Or=e=>{const{content:s,children:n,className:o}=e,[a,{setTrue:d,setFalse:c}]=bt.useBoolean(!1);return t.jsxs(wt,{children:[t.jsx(jt,{onMouseOver:d,onMouseOut:c,children:n}),t.jsx(_t,{side:"top",className:ue("z-1000 p-2 rounded-md text-xs text-white bg-black/75 hidden",{block:a},o),children:s})]})},Ct=({name:e,className:s,style:n,...o})=>t.jsx("svg",{className:`icon dark:drop-shadow-[0_0_6px_rgb(255,255,255)] ${s||""}`,style:n,...o,children:t.jsx("use",{xlinkHref:`#${e}`})}),Fr=(e,s)=>{const n=new Array(e.length+s.length);for(let o=0;o<e.length;o++)n[o]=e[o];for(let o=0;o<s.length;o++)n[e.length+o]=s[o];return n},Pr=(e,s)=>({classGroupId:e,validator:s}),Nt=(e=new Map,s=null,n)=>({nextPart:e,validators:s,classGroupId:n}),Ie="-",ft=[],Ir="arbitrary..",Lr=e=>{const s=zr(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:c=>{if(c.startsWith("[")&&c.endsWith("]"))return Mr(c);const f=c.split(Ie),i=f[0]===""&&f.length>1?1:0;return Et(f,i,s)},getConflictingClassGroupIds:(c,f)=>{if(f){const i=o[c],m=n[c];return i?m?Fr(m,i):i:m||ft}return n[c]||ft}}},Et=(e,s,n)=>{if(e.length-s===0)return n.classGroupId;const a=e[s],d=n.nextPart.get(a);if(d){const m=Et(e,s+1,d);if(m)return m}const c=n.validators;if(c===null)return;const f=s===0?e.join(Ie):e.slice(s).join(Ie),i=c.length;for(let m=0;m<i;m++){const u=c[m];if(u.validator(f))return u.classGroupId}},Mr=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const s=e.slice(1,-1),n=s.indexOf(":"),o=s.slice(0,n);return o?Ir+o:void 0})(),zr=e=>{const{theme:s,classGroups:n}=e;return $r(n,s)},$r=(e,s)=>{const n=Nt();for(const o in e){const a=e[o];Je(a,n,o,s)}return n},Je=(e,s,n,o)=>{const a=e.length;for(let d=0;d<a;d++){const c=e[d];Wr(c,s,n,o)}},Wr=(e,s,n,o)=>{if(typeof e=="string"){qr(e,s,n);return}if(typeof e=="function"){Dr(e,s,n,o);return}Br(e,s,n,o)},qr=(e,s,n)=>{const o=e===""?s:St(s,e);o.classGroupId=n},Dr=(e,s,n,o)=>{if(Ur(e)){Je(e(o),s,n,o);return}s.validators===null&&(s.validators=[]),s.validators.push(Pr(n,e))},Br=(e,s,n,o)=>{const a=Object.entries(e),d=a.length;for(let c=0;c<d;c++){const[f,i]=a[c];Je(i,St(s,f),n,o)}},St=(e,s)=>{let n=e;const o=s.split(Ie),a=o.length;for(let d=0;d<a;d++){const c=o[d];let f=n.nextPart.get(c);f||(f=Nt(),n.nextPart.set(c,f)),n=f}return n},Ur=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Vr=e=>{if(e<1)return{get:()=>{},set:()=>{}};let s=0,n=Object.create(null),o=Object.create(null);const a=(d,c)=>{n[d]=c,s++,s>e&&(s=0,o=n,n=Object.create(null))};return{get(d){let c=n[d];if(c!==void 0)return c;if((c=o[d])!==void 0)return a(d,c),c},set(d,c){d in n?n[d]=c:a(d,c)}}},Ve="!",mt=":",Gr=[],pt=(e,s,n,o,a)=>({modifiers:e,hasImportantModifier:s,baseClassName:n,maybePostfixModifierPosition:o,isExternal:a}),Yr=e=>{const{prefix:s,experimentalParseClassName:n}=e;let o=a=>{const d=[];let c=0,f=0,i=0,m;const u=a.length;for(let q=0;q<u;q++){const C=a[q];if(c===0&&f===0){if(C===mt){d.push(a.slice(i,q)),i=q+1;continue}if(C==="/"){m=q;continue}}C==="["?c++:C==="]"?c--:C==="("?f++:C===")"&&f--}const v=d.length===0?a:a.slice(i);let b=v,N=!1;v.endsWith(Ve)?(b=v.slice(0,-1),N=!0):v.startsWith(Ve)&&(b=v.slice(1),N=!0);const I=m&&m>i?m-i:void 0;return pt(d,N,b,I)};if(s){const a=s+mt,d=o;o=c=>c.startsWith(a)?d(c.slice(a.length)):pt(Gr,!1,c,void 0,!0)}if(n){const a=o;o=d=>n({className:d,parseClassName:a})}return o},Jr=e=>{const s=new Map;return e.orderSensitiveModifiers.forEach((n,o)=>{s.set(n,1e6+o)}),n=>{const o=[];let a=[];for(let d=0;d<n.length;d++){const c=n[d],f=c[0]==="[",i=s.has(c);f||i?(a.length>0&&(a.sort(),o.push(...a),a=[]),o.push(c)):a.push(c)}return a.length>0&&(a.sort(),o.push(...a)),o}},Xr=e=>({cache:Vr(e.cacheSize),parseClassName:Yr(e),sortModifiers:Jr(e),...Lr(e)}),Kr=/\s+/,Qr=(e,s)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:a,sortModifiers:d}=s,c=[],f=e.trim().split(Kr);let i="";for(let m=f.length-1;m>=0;m-=1){const u=f[m],{isExternal:v,modifiers:b,hasImportantModifier:N,baseClassName:I,maybePostfixModifierPosition:q}=n(u);if(v){i=u+(i.length>0?" "+i:i);continue}let C=!!q,y=o(C?I.substring(0,q):I);if(!y){if(!C){i=u+(i.length>0?" "+i:i);continue}if(y=o(I),!y){i=u+(i.length>0?" "+i:i);continue}C=!1}const F=b.length===0?"":b.length===1?b[0]:d(b).join(":"),Q=N?F+Ve:F,ee=Q+y;if(c.indexOf(ee)>-1)continue;c.push(ee);const te=a(y,C);for(let H=0;H<te.length;++H){const ne=te[H];c.push(Q+ne)}i=u+(i.length>0?" "+i:i)}return i},Hr=(...e)=>{let s=0,n,o,a="";for(;s<e.length;)(n=e[s++])&&(o=Rt(n))&&(a&&(a+=" "),a+=o);return a},Rt=e=>{if(typeof e=="string")return e;let s,n="";for(let o=0;o<e.length;o++)e[o]&&(s=Rt(e[o]))&&(n&&(n+=" "),n+=s);return n},Zr=(e,...s)=>{let n,o,a,d;const c=i=>{const m=s.reduce((u,v)=>v(u),e());return n=Xr(m),o=n.cache.get,a=n.cache.set,d=f,f(i)},f=i=>{const m=o(i);if(m)return m;const u=Qr(i,n);return a(i,u),u};return d=c,(...i)=>d(Hr(...i))},es=[],D=e=>{const s=n=>n[e]||es;return s.isThemeGetter=!0,s},Tt=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,At=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ts=/^\d+\/\d+$/,rs=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ss=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,ns=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,os=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,as=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,we=e=>ts.test(e),E=e=>!!e&&!Number.isNaN(Number(e)),he=e=>!!e&&Number.isInteger(Number(e)),De=e=>e.endsWith("%")&&E(e.slice(0,-1)),de=e=>rs.test(e),is=()=>!0,ls=e=>ss.test(e)&&!ns.test(e),Ot=()=>!1,cs=e=>os.test(e),ds=e=>as.test(e),us=e=>!x(e)&&!g(e),fs=e=>je(e,It,Ot),x=e=>Tt.test(e),ke=e=>je(e,Lt,ls),Be=e=>je(e,gs,E),ht=e=>je(e,Ft,Ot),ms=e=>je(e,Pt,ds),Fe=e=>je(e,Mt,cs),g=e=>At.test(e),Re=e=>_e(e,Lt),ps=e=>_e(e,bs),xt=e=>_e(e,Ft),hs=e=>_e(e,It),xs=e=>_e(e,Pt),Pe=e=>_e(e,Mt,!0),je=(e,s,n)=>{const o=Tt.exec(e);return o?o[1]?s(o[1]):n(o[2]):!1},_e=(e,s,n=!1)=>{const o=At.exec(e);return o?o[1]?s(o[1]):n:!1},Ft=e=>e==="position"||e==="percentage",Pt=e=>e==="image"||e==="url",It=e=>e==="length"||e==="size"||e==="bg-size",Lt=e=>e==="length",gs=e=>e==="number",bs=e=>e==="family-name",Mt=e=>e==="shadow",ks=()=>{const e=D("color"),s=D("font"),n=D("text"),o=D("font-weight"),a=D("tracking"),d=D("leading"),c=D("breakpoint"),f=D("container"),i=D("spacing"),m=D("radius"),u=D("shadow"),v=D("inset-shadow"),b=D("text-shadow"),N=D("drop-shadow"),I=D("blur"),q=D("perspective"),C=D("aspect"),y=D("ease"),F=D("animate"),Q=()=>["auto","avoid","all","avoid-page","page","left","right","column"],ee=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],te=()=>[...ee(),g,x],H=()=>["auto","hidden","clip","visible","scroll"],ne=()=>["auto","contain","none"],w=()=>[g,x,i],z=()=>[we,"full","auto",...w()],fe=()=>[he,"none","subgrid",g,x],Z=()=>["auto",{span:["full",he,g,x]},he,g,x],ie=()=>[he,"auto",g,x],B=()=>["auto","min","max","fr",g,x],Y=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],U=()=>["start","end","center","stretch","center-safe","end-safe"],L=()=>["auto",...w()],J=()=>[we,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...w()],k=()=>[e,g,x],oe=()=>[...ee(),xt,ht,{position:[g,x]}],xe=()=>["no-repeat",{repeat:["","x","y","space","round"]}],re=()=>["auto","cover","contain",hs,fs,{size:[g,x]}],le=()=>[De,Re,ke],$=()=>["","none","full",m,g,x],V=()=>["",E,Re,ke],me=()=>["solid","dashed","dotted","double"],pe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],P=()=>[E,De,xt,ht],j=()=>["","none",I,g,x],X=()=>["none",E,g,x],ce=()=>["none",E,g,x],Ce=()=>[E,g,x],ge=()=>[we,"full",...w()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[de],breakpoint:[de],color:[is],container:[de],"drop-shadow":[de],ease:["in","out","in-out"],font:[us],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[de],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[de],shadow:[de],spacing:["px",E],text:[de],"text-shadow":[de],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",we,x,g,C]}],container:["container"],columns:[{columns:[E,x,g,f]}],"break-after":[{"break-after":Q()}],"break-before":[{"break-before":Q()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:te()}],overflow:[{overflow:H()}],"overflow-x":[{"overflow-x":H()}],"overflow-y":[{"overflow-y":H()}],overscroll:[{overscroll:ne()}],"overscroll-x":[{"overscroll-x":ne()}],"overscroll-y":[{"overscroll-y":ne()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:z()}],"inset-x":[{"inset-x":z()}],"inset-y":[{"inset-y":z()}],start:[{start:z()}],end:[{end:z()}],top:[{top:z()}],right:[{right:z()}],bottom:[{bottom:z()}],left:[{left:z()}],visibility:["visible","invisible","collapse"],z:[{z:[he,"auto",g,x]}],basis:[{basis:[we,"full","auto",f,...w()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[E,we,"auto","initial","none",x]}],grow:[{grow:["",E,g,x]}],shrink:[{shrink:["",E,g,x]}],order:[{order:[he,"first","last","none",g,x]}],"grid-cols":[{"grid-cols":fe()}],"col-start-end":[{col:Z()}],"col-start":[{"col-start":ie()}],"col-end":[{"col-end":ie()}],"grid-rows":[{"grid-rows":fe()}],"row-start-end":[{row:Z()}],"row-start":[{"row-start":ie()}],"row-end":[{"row-end":ie()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":B()}],"auto-rows":[{"auto-rows":B()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...Y(),"normal"]}],"justify-items":[{"justify-items":[...U(),"normal"]}],"justify-self":[{"justify-self":["auto",...U()]}],"align-content":[{content:["normal",...Y()]}],"align-items":[{items:[...U(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...U(),{baseline:["","last"]}]}],"place-content":[{"place-content":Y()}],"place-items":[{"place-items":[...U(),"baseline"]}],"place-self":[{"place-self":["auto",...U()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:L()}],mx:[{mx:L()}],my:[{my:L()}],ms:[{ms:L()}],me:[{me:L()}],mt:[{mt:L()}],mr:[{mr:L()}],mb:[{mb:L()}],ml:[{ml:L()}],"space-x":[{"space-x":w()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":w()}],"space-y-reverse":["space-y-reverse"],size:[{size:J()}],w:[{w:[f,"screen",...J()]}],"min-w":[{"min-w":[f,"screen","none",...J()]}],"max-w":[{"max-w":[f,"screen","none","prose",{screen:[c]},...J()]}],h:[{h:["screen","lh",...J()]}],"min-h":[{"min-h":["screen","lh","none",...J()]}],"max-h":[{"max-h":["screen","lh",...J()]}],"font-size":[{text:["base",n,Re,ke]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[o,g,Be]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",De,x]}],"font-family":[{font:[ps,x,s]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[a,g,x]}],"line-clamp":[{"line-clamp":[E,"none",g,Be]}],leading:[{leading:[d,...w()]}],"list-image":[{"list-image":["none",g,x]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",g,x]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:k()}],"text-color":[{text:k()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...me(),"wavy"]}],"text-decoration-thickness":[{decoration:[E,"from-font","auto",g,ke]}],"text-decoration-color":[{decoration:k()}],"underline-offset":[{"underline-offset":[E,"auto",g,x]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:w()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",g,x]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",g,x]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:oe()}],"bg-repeat":[{bg:xe()}],"bg-size":[{bg:re()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},he,g,x],radial:["",g,x],conic:[he,g,x]},xs,ms]}],"bg-color":[{bg:k()}],"gradient-from-pos":[{from:le()}],"gradient-via-pos":[{via:le()}],"gradient-to-pos":[{to:le()}],"gradient-from":[{from:k()}],"gradient-via":[{via:k()}],"gradient-to":[{to:k()}],rounded:[{rounded:$()}],"rounded-s":[{"rounded-s":$()}],"rounded-e":[{"rounded-e":$()}],"rounded-t":[{"rounded-t":$()}],"rounded-r":[{"rounded-r":$()}],"rounded-b":[{"rounded-b":$()}],"rounded-l":[{"rounded-l":$()}],"rounded-ss":[{"rounded-ss":$()}],"rounded-se":[{"rounded-se":$()}],"rounded-ee":[{"rounded-ee":$()}],"rounded-es":[{"rounded-es":$()}],"rounded-tl":[{"rounded-tl":$()}],"rounded-tr":[{"rounded-tr":$()}],"rounded-br":[{"rounded-br":$()}],"rounded-bl":[{"rounded-bl":$()}],"border-w":[{border:V()}],"border-w-x":[{"border-x":V()}],"border-w-y":[{"border-y":V()}],"border-w-s":[{"border-s":V()}],"border-w-e":[{"border-e":V()}],"border-w-t":[{"border-t":V()}],"border-w-r":[{"border-r":V()}],"border-w-b":[{"border-b":V()}],"border-w-l":[{"border-l":V()}],"divide-x":[{"divide-x":V()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":V()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...me(),"hidden","none"]}],"divide-style":[{divide:[...me(),"hidden","none"]}],"border-color":[{border:k()}],"border-color-x":[{"border-x":k()}],"border-color-y":[{"border-y":k()}],"border-color-s":[{"border-s":k()}],"border-color-e":[{"border-e":k()}],"border-color-t":[{"border-t":k()}],"border-color-r":[{"border-r":k()}],"border-color-b":[{"border-b":k()}],"border-color-l":[{"border-l":k()}],"divide-color":[{divide:k()}],"outline-style":[{outline:[...me(),"none","hidden"]}],"outline-offset":[{"outline-offset":[E,g,x]}],"outline-w":[{outline:["",E,Re,ke]}],"outline-color":[{outline:k()}],shadow:[{shadow:["","none",u,Pe,Fe]}],"shadow-color":[{shadow:k()}],"inset-shadow":[{"inset-shadow":["none",v,Pe,Fe]}],"inset-shadow-color":[{"inset-shadow":k()}],"ring-w":[{ring:V()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:k()}],"ring-offset-w":[{"ring-offset":[E,ke]}],"ring-offset-color":[{"ring-offset":k()}],"inset-ring-w":[{"inset-ring":V()}],"inset-ring-color":[{"inset-ring":k()}],"text-shadow":[{"text-shadow":["none",b,Pe,Fe]}],"text-shadow-color":[{"text-shadow":k()}],opacity:[{opacity:[E,g,x]}],"mix-blend":[{"mix-blend":[...pe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":pe()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[E]}],"mask-image-linear-from-pos":[{"mask-linear-from":P()}],"mask-image-linear-to-pos":[{"mask-linear-to":P()}],"mask-image-linear-from-color":[{"mask-linear-from":k()}],"mask-image-linear-to-color":[{"mask-linear-to":k()}],"mask-image-t-from-pos":[{"mask-t-from":P()}],"mask-image-t-to-pos":[{"mask-t-to":P()}],"mask-image-t-from-color":[{"mask-t-from":k()}],"mask-image-t-to-color":[{"mask-t-to":k()}],"mask-image-r-from-pos":[{"mask-r-from":P()}],"mask-image-r-to-pos":[{"mask-r-to":P()}],"mask-image-r-from-color":[{"mask-r-from":k()}],"mask-image-r-to-color":[{"mask-r-to":k()}],"mask-image-b-from-pos":[{"mask-b-from":P()}],"mask-image-b-to-pos":[{"mask-b-to":P()}],"mask-image-b-from-color":[{"mask-b-from":k()}],"mask-image-b-to-color":[{"mask-b-to":k()}],"mask-image-l-from-pos":[{"mask-l-from":P()}],"mask-image-l-to-pos":[{"mask-l-to":P()}],"mask-image-l-from-color":[{"mask-l-from":k()}],"mask-image-l-to-color":[{"mask-l-to":k()}],"mask-image-x-from-pos":[{"mask-x-from":P()}],"mask-image-x-to-pos":[{"mask-x-to":P()}],"mask-image-x-from-color":[{"mask-x-from":k()}],"mask-image-x-to-color":[{"mask-x-to":k()}],"mask-image-y-from-pos":[{"mask-y-from":P()}],"mask-image-y-to-pos":[{"mask-y-to":P()}],"mask-image-y-from-color":[{"mask-y-from":k()}],"mask-image-y-to-color":[{"mask-y-to":k()}],"mask-image-radial":[{"mask-radial":[g,x]}],"mask-image-radial-from-pos":[{"mask-radial-from":P()}],"mask-image-radial-to-pos":[{"mask-radial-to":P()}],"mask-image-radial-from-color":[{"mask-radial-from":k()}],"mask-image-radial-to-color":[{"mask-radial-to":k()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":ee()}],"mask-image-conic-pos":[{"mask-conic":[E]}],"mask-image-conic-from-pos":[{"mask-conic-from":P()}],"mask-image-conic-to-pos":[{"mask-conic-to":P()}],"mask-image-conic-from-color":[{"mask-conic-from":k()}],"mask-image-conic-to-color":[{"mask-conic-to":k()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:oe()}],"mask-repeat":[{mask:xe()}],"mask-size":[{mask:re()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",g,x]}],filter:[{filter:["","none",g,x]}],blur:[{blur:j()}],brightness:[{brightness:[E,g,x]}],contrast:[{contrast:[E,g,x]}],"drop-shadow":[{"drop-shadow":["","none",N,Pe,Fe]}],"drop-shadow-color":[{"drop-shadow":k()}],grayscale:[{grayscale:["",E,g,x]}],"hue-rotate":[{"hue-rotate":[E,g,x]}],invert:[{invert:["",E,g,x]}],saturate:[{saturate:[E,g,x]}],sepia:[{sepia:["",E,g,x]}],"backdrop-filter":[{"backdrop-filter":["","none",g,x]}],"backdrop-blur":[{"backdrop-blur":j()}],"backdrop-brightness":[{"backdrop-brightness":[E,g,x]}],"backdrop-contrast":[{"backdrop-contrast":[E,g,x]}],"backdrop-grayscale":[{"backdrop-grayscale":["",E,g,x]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[E,g,x]}],"backdrop-invert":[{"backdrop-invert":["",E,g,x]}],"backdrop-opacity":[{"backdrop-opacity":[E,g,x]}],"backdrop-saturate":[{"backdrop-saturate":[E,g,x]}],"backdrop-sepia":[{"backdrop-sepia":["",E,g,x]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",g,x]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[E,"initial",g,x]}],ease:[{ease:["linear","initial",y,g,x]}],delay:[{delay:[E,g,x]}],animate:[{animate:["none",F,g,x]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[q,g,x]}],"perspective-origin":[{"perspective-origin":te()}],rotate:[{rotate:X()}],"rotate-x":[{"rotate-x":X()}],"rotate-y":[{"rotate-y":X()}],"rotate-z":[{"rotate-z":X()}],scale:[{scale:ce()}],"scale-x":[{"scale-x":ce()}],"scale-y":[{"scale-y":ce()}],"scale-z":[{"scale-z":ce()}],"scale-3d":["scale-3d"],skew:[{skew:Ce()}],"skew-x":[{"skew-x":Ce()}],"skew-y":[{"skew-y":Ce()}],transform:[{transform:[g,x,"","none","gpu","cpu"]}],"transform-origin":[{origin:te()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ge()}],"translate-x":[{"translate-x":ge()}],"translate-y":[{"translate-y":ge()}],"translate-z":[{"translate-z":ge()}],"translate-none":["translate-none"],accent:[{accent:k()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:k()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",g,x]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",g,x]}],fill:[{fill:["none",...k()]}],"stroke-w":[{stroke:[E,Re,ke,Be]}],stroke:[{stroke:["none",...k()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},ys=Zr(ks),vs=e=>{const{path:s,className:n}=e,[o,a]=h.useState("");return h.useEffect(()=>{vt.invokeBackend("get_file_icon",{path:s}).then(d=>{d&&a(d)})},[s]),t.jsx(Ct,{name:o,className:ys("min-w-8 h-8",n)})},ws=e=>{const{id:s,name:n,path:o,extname:a,size:d,uploaded:c,attachmentId:f,uploadFailed:i,failedMessage:m,deletable:u,onDelete:v}=e,{t:b}=ae.useTranslation();return t.jsx("div",{className:"w-1/3 px-1",children:t.jsxs("div",{className:"relative group flex items-center gap-1 p-1 rounded-[4px] bg-[#dedede] dark:bg-[#202126]",children:[(i||f)&&u&&t.jsx("div",{className:"absolute flex justify-center items-center size-[14px] bg-red-600 top-0 right-0 rounded-full cursor-pointer translate-x-[5px] -translate-y-[5px] transition opacity-0 group-hover:opacity-100 ",onClick:()=>{v?.(s)},children:t.jsx(T.X,{className:"size-[10px] text-white"})}),t.jsx(vs,{path:o}),t.jsxs("div",{className:"flex flex-col justify-between overflow-hidden",children:[t.jsx("div",{className:"truncate text-sm text-[#333333] dark:text-[#D8D8D8]",children:n}),t.jsx("div",{className:"text-xs",children:i&&m?t.jsx(Or,{content:m,children:t.jsx("span",{className:"text-red-500",children:"Upload Failed"})}):t.jsx("div",{className:"text-[#999]",children:c?t.jsxs("div",{className:"flex gap-2",children:[a&&t.jsx("span",{children:a}),t.jsx("span",{children:kr(d)})]}):t.jsx("span",{children:b("assistant.fileList.uploading")})})})]})]})},s)},js=Ge.create(()=>({addError:e=>console.error(e)})),_s=e=>{const{message:s,attachments:n}=e,[o,a]=h.useState(!1),{currentService:d}=Ue(),[c,f]=h.useState([]),{addError:i}=js(),m=u=>{if(typeof window<"u"&&typeof document<"u"){const v=window.getSelection(),b=document.createRange();if(u.currentTarget&&v&&b)try{b.selectNodeContents(u.currentTarget),v.removeAllRanges(),v.addRange(b)}catch(N){console.error("Selection failed:",N)}}};return bt.useAsyncEffect(async()=>{try{if(n.length===0)return;const u=await vt.commands("get_attachment_by_ids",{serverId:d.id,attachments:n});f(u?.hits?.hits)}catch(u){i(String(u))}},[n]),t.jsxs(t.Fragment,{children:[s&&t.jsxs("div",{className:"flex gap-1 items-center justify-end",onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[t.jsx("div",{className:ue("size-6 transition",{"opacity-0":!o}),children:t.jsx(Ar,{textToCopy:s})}),t.jsx("div",{className:"max-w-[85%] overflow-auto text-left px-3 py-2 bg-white dark:bg-[#202126] rounded-xl border border-black/12 dark:border-black/15 font-normal text-sm text-[#333333] dark:text-[#D8D8D8] cursor-pointer user-select-text whitespace-pre-wrap",onDoubleClick:m,children:s})]}),c&&t.jsx("div",{className:ue("flex justify-end flex-wrap gap-y-2 w-full",{"mt-3":s}),children:c.map(u=>{const{id:v,name:b,size:N,icon:I}=u._source;return h.createElement(ws,{...u._source,key:v,uploading:!1,uploaded:!0,id:v,extname:I,attachmentId:v,name:b,path:b,size:N,deletable:!1})})})]})};function Cs(){const[e,s]=h.useState(),[n,o]=h.useState(),[a,d]=h.useState(),[c,f]=h.useState(),[i,m]=h.useState(),[u,v]=h.useState(),[b,N]=h.useState(),I={deal_query_intent:h.useCallback(C=>{s(y=>y?{...y,message_chunk:(y.message_chunk||"")+(C.message_chunk||"")}:C)},[]),deal_tools:h.useCallback(C=>{o(y=>y?{...y,message_chunk:(y.message_chunk||"")+(C.message_chunk||"")}:C)},[]),deal_fetch_source:h.useCallback(C=>{d(y=>y?{...y,message_chunk:(y.message_chunk||"")+(C.message_chunk||"")}:C)},[]),deal_pick_source:h.useCallback(C=>{f(y=>y?{...y,message_chunk:(y.message_chunk||"")+(C.message_chunk||"")}:C)},[]),deal_deep_read:h.useCallback(C=>{m(y=>y?{...y,message_chunk:(y.message_chunk||"")+"&"+(C.message_chunk||"")}:C)},[]),deal_think:h.useCallback(C=>{v(y=>y?{...y,message_chunk:(y.message_chunk||"")+(C.message_chunk||"")}:C)},[]),deal_response:h.useCallback(C=>{N(y=>y?{...y,message_chunk:(y.message_chunk||"")+(C.message_chunk||"")}:C)},[])};return{data:{query_intent:e,tools:n,fetch_source:a,pick_source:c,deep_read:i,think:u,response:b},handlers:I,clearAllChunkData:()=>new Promise(C=>{s(void 0),o(void 0),d(void 0),f(void 0),m(void 0),v(void 0),N(void 0),setTimeout(C,0)})}}function Ns(e){if(e)return e==="light"?"light":e==="dark"||typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}const Es=h.memo(h.forwardRef(function({message:s,isTyping:n,onResend:o,hide_assistant:a=!1,rootClassName:d,actionClassName:c,actionIconSize:f,copyButtonId:i,formatUrl:m,theme:u,locale:v},b){const{t:N,i18n:I}=ae.useTranslation(),q=Ns(u),C=Ue(j=>j.currentAssistant),y=Ue(j=>j.assistantList),[F,Q]=h.useState({}),{data:{query_intent:ee,tools:te,fetch_source:H,pick_source:ne,deep_read:w,think:z,response:fe},handlers:Z,clearAllChunkData:ie}=Cs(),[B,Y]=h.useState({query_intent:!1,tools:!1,fetch_source:!1,pick_source:!1,deep_read:!1,think:!1,response:!1}),U=h.useRef(!1);h.useImperativeHandle(b,()=>({addChunk:j=>{if(Y(()=>({query_intent:!1,tools:!1,fetch_source:!1,pick_source:!1,deep_read:!1,think:!1,response:!1,[j.chunk_type||""]:!0})),j.chunk_type==="query_intent")Z.deal_query_intent(j);else if(j.chunk_type==="tools")Z.deal_tools(j);else if(j.chunk_type==="fetch_source")Z.deal_fetch_source(j);else if(j.chunk_type==="pick_source")Z.deal_pick_source(j);else if(j.chunk_type==="deep_read")Z.deal_deep_read(j);else if(j.chunk_type==="think")Z.deal_think(j);else if(j.chunk_type==="response"){const X=j.message_chunk;if(typeof X=="string"){if(X.includes("<think>")||X.includes("<think>")){U.current=!0;return}else if(X.includes("</think>")||X.includes("</think>")){U.current=!1;return}U.current?Z.deal_think({...j,chunk_type:"think"}):Z.deal_response(j)}}},reset:()=>{ie(),Y({query_intent:!1,tools:!1,fetch_source:!1,pick_source:!1,deep_read:!1,think:!1,response:!1}),U.current=!1}}));const L=s?._source?.type==="assistant",J=s?._source?.assistant_id,k=s?._source?.assistant_item;h.useEffect(()=>{v&&I.language!==v&&I.changeLanguage(v)},[v,I]),h.useEffect(()=>{if(k){Q(k);return}if(L&&J&&Array.isArray(y)){Q(y.find(j=>j._id===J)??{});return}Q(C)},[L,k,J,y,C]);const oe=s?._source?.message||"",xe=s?._source?.attachments??[],re=s?._source?.details||[],le=s?._source?.question||"",$=n===!1&&(oe||fe?.message_chunk),[V,me]=h.useState([]),pe=j=>{me(j)},P=()=>L?t.jsxs(t.Fragment,{children:[t.jsx(xr,{Detail:re.find(j=>j.type==="query_intent"),ChunkData:ee,getSuggestion:pe,loading:B?.query_intent}),t.jsx(gr,{Detail:re.find(j=>j.type==="tools"),ChunkData:te,loading:B?.tools}),t.jsx(vr,{Detail:re.find(j=>j.type==="fetch_source"),ChunkData:H,loading:B?.fetch_source,formatUrl:m}),t.jsx(jr,{Detail:re.find(j=>j.type==="pick_source"),ChunkData:ne,loading:B?.pick_source}),t.jsx(Cr,{Detail:re.find(j=>j.type==="deep_read"),ChunkData:w,loading:B?.deep_read}),t.jsx(Nr,{Detail:re.find(j=>j.type==="think"),ChunkData:z,loading:B?.think}),t.jsx(gt.XMarkdown,{content:oe||fe?.message_chunk||""}),n&&t.jsx("div",{className:"inline-block w-1.5 h-5 ml-0.5 -mb-0.5 bg-[#666666] dark:bg-[#A3A3A3] rounded-sm animate-typing"}),$&&t.jsx(Rr,{id:s._id??"",content:oe||fe?.message_chunk||"",question:le,actionClassName:c,actionIconSize:f,copyButtonId:i,onResend:()=>{o&&o(le)}}),!n&&t.jsx(Tr,{suggestions:V,onSelect:j=>o&&o(j)})]}):t.jsx(_s,{message:oe,attachments:xe});return t.jsx("div",{className:ue("w-full py-8 flex",[L?"justify-start":"justify-end"],q==="dark"&&"dark",d),children:t.jsx("div",{className:`w-full px-4 flex gap-4 ${L?"w-full":"flex-row-reverse"}`,children:t.jsxs("div",{className:`w-full space-y-2 ${L?"text-left":"text-right"}`,children:[!a&&t.jsxs("div",{className:"w-full flex items-center gap-1 font-semibold text-sm text-[#333] dark:text-[#d8d8d8]",children:[L?t.jsx("div",{className:"w-6 h-6 flex justify-center items-center rounded-full bg-white border border-[#E6E6E6]",children:F?._source?.icon?.startsWith("font_")?t.jsx(Ct,{name:F._source.icon,className:"w-4 h-4"}):t.jsx("img",{src:pr,className:"w-4 h-4",alt:N("assistant.message.logo")})}):null,L?F?._source?.name||"Coco AI":""]}),t.jsx("div",{className:"w-full prose dark:prose-invert prose-sm max-w-none",children:t.jsx("div",{className:"w-full pl-7 text-[#333] dark:text-[#d8d8d8] leading-relaxed",children:P()})})]})})})})),Ss=h.memo(h.forwardRef((e,s)=>t.jsx(ae.I18nextProvider,{i18n:kt,children:t.jsx(Es,{...e,ref:s})})));exports.ChatMessage=Ss;
|
|
30
|
+
<%s key={someKey} {...props} />`,Se,Q,kt,Q),Ye[Q+Se]=!0}}return e===f?ht(T):ft(T),T}}function xt(e,s,a){return Je(e,s,a,!0)}function mt(e,s,a){return Je(e,s,a,!1)}var pt=mt,gt=xt;fe.Fragment=f,fe.jsx=pt,fe.jsxs=gt})()),fe}var ze;function Et(){return ze||(ze=1,process.env.NODE_ENV==="production"?ye.exports=bt():ye.exports=wt()),ye.exports}var t=Et();const Nt={en:{translation:{assistant:{message:{logo:"Coco AI Logo",aiName:"Coco AI",thinkingButton:"View thinking process",steps:{query_intent:"Understand the query",tools:"Call LLM Tools",source_zero:"Searching for relevant documents",fetch_source:"Retrieve {{count}} documents",pick_source:"Intelligent pick {{count}} results",pick_source_start:"Intelligently pre-selecting",deep_read:"Deep reading",think:"AI is thinking...",thoughtTime:"Thought for a few seconds",keywords:"Keywords",questionType:"Query Type",userIntent:"User Intent",relatedQuestions:"Query",suggestion:"Suggestion",informationSeeking:"Information Seeking"}}},sessionFiles:{labels:{all:"All"},modal:{title:"Files in the conversation",description:"Only the selected files will participate in the current conversation."}}}},zh:{translation:{assistant:{message:{logo:"Coco AI 图标",aiName:"Coco AI",thinkingButton:"查看思考过程",steps:{query_intent:"理解查询",tools:"调用大模型工具",source_zero:"正在搜索相关文档",fetch_source:"检索 {{count}} 份文档",pick_source:"智能预选 {{count}} 个结果",pick_source_start:"正在智能预选",deep_read:"深度阅读",think:"AI 正在思考...",thoughtTime:"思考了数秒",keywords:"关键词",questionType:"查询类型",userIntent:"用户意图",relatedQuestions:"查询",suggestion:"建议",informationSeeking:"信息查询"}}},sessionFiles:{labels:{all:"全部"},modal:{title:"会话中的文件",description:"只有选定的文件才会参与当前会话。"}}}}},Qe=vt.createInstance();Qe.use(Y.initReactI18next).init({resources:Nt,lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1},react:{useSuspense:!1}});const Ct="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%3e%3ccircle%20cx='50'%20cy='50'%20r='40'%20stroke='black'%20stroke-width='3'%20fill='red'%20/%3e%3c/svg%3e";function ve({size:r=18,children:n,className:d,title:f,onClick:c,action:_=!1,...y}){const p=l=>{c?.(l)};return t.jsx("i",{style:{width:r,height:r},title:f,onClick:p,className:he("inline-flex items-center justify-center rounded-sm p-[2px] transition-all",{"cursor-pointer":_},d),children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",style:{width:"100%",height:"100%"},...y,children:n})})}function Rt(r){return t.jsx(ve,{...r,viewBox:"0 0 16 16",children:t.jsx("g",{id:"Understand",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsxs("g",{id:"编组",transform:"translate(0.5, 0.5)",stroke:"currentColor",strokeWidth:"1.25",children:[t.jsx("path",{d:"M7.44444444,3 C9.89904333,3 11.8888889,4.95366655 11.8888889,7.36363636 C11.8888889,9.06711551 10.8946979,10.5426108 9.44492275,11.2613085 L9.44444444,12.2727273 C9.44444444,13.3772968 8.54901394,14.2727273 7.44444444,14.2727273 C6.33987494,14.2727273 5.44444444,13.3772968 5.44444444,12.2727273 L5.44396614,11.2613085 C3.99419095,10.5426108 3,9.06711551 3,7.36363636 C3,4.95366655 4.98984556,3 7.44444444,3 Z",id:"形状结合"}),t.jsx("line",{x1:"5.5",y1:"11.2156017",x2:"9.5",y2:"11.2156017",id:"路径-11"}),t.jsx("line",{x1:"7.44444444",y1:"10.6363636",x2:"7.44444444",y2:"8.45454545",id:"路径-12"}),t.jsx("line",{x1:"7.44444444",y1:"0.818181818",x2:"7.44444444",y2:"0.272727273",id:"路径-12备份"}),t.jsx("line",{x1:"12.352383",y1:"2.81770629",x2:"12.3574335",y2:"2.26720124",id:"路径-12备份",transform:"translate(12.3549, 2.5425) rotate(45) translate(-12.3549, -2.5425)"}),t.jsx("line",{x1:"14.3888889",y1:"7.64141414",x2:"14.3888889",y2:"7.08585859",id:"路径-12备份",transform:"translate(14.3889, 7.3636) rotate(90) translate(-14.3889, -7.3636)"}),t.jsx("line",{x1:"12.3574335",y1:"12.4600715",x2:"12.352383",y2:"11.9095664",id:"路径-12备份",transform:"translate(12.3549, 12.1848) rotate(135) translate(-12.3549, -12.1848)"}),t.jsx("line",{x1:"2.53145543",y1:"12.4600715",x2:"2.53650594",y2:"11.9095664",id:"路径-12备份",transform:"translate(2.534, 12.1848) rotate(225) translate(-2.534, -12.1848)"}),t.jsx("line",{x1:"0.5",y1:"7.64141414",x2:"0.5",y2:"7.08585859",id:"路径-12备份",transform:"translate(0.5, 7.3636) rotate(270) translate(-0.5, -7.3636)"}),t.jsx("line",{x1:"2.53650594",y1:"2.81770629",x2:"2.53145543",y2:"2.26720124",id:"路径-12备份",transform:"translate(2.534, 2.5425) rotate(315) translate(-2.534, -2.5425)"}),t.jsx("polyline",{id:"路径-15",transform:"translate(7.4398, 6.7308) rotate(-45) translate(-7.4398, -6.7308)",points:"6.33632897 5.60310185 6.3568375 7.83853192 8.5432888 7.85859111"})]})})})}const St=({Detail:r,ChunkData:n,getSuggestion:d,loading:f})=>{const{t:c}=Y.useTranslation(),[_,y]=i.useState(!1),[p,l]=i.useState(null);return i.useEffect(()=>{r?.payload&&(l(r?.payload),r?.payload?.suggestion&&d&&d(r?.payload?.suggestion))},[r?.payload,d]),i.useEffect(()=>{if(n?.message_chunk&&!f)try{const o=n.message_chunk.replace(/^"|"$/g,"").match(/<JSON>([\s\S]*?)<\/JSON>/g);if(o){const m=o[o.length-1].replace(/<JSON>|<\/JSON>/g,""),b=JSON.parse(m);b?.suggestion&&d&&d(b?.suggestion),l(b)}}catch(g){console.error("Failed to process message chunk in QueryIntent:",g)}},[n?.message_chunk,f,d]),!n&&!r?null:t.jsxs("div",{className:"space-y-2 mb-3 w-full",children:[t.jsxs("button",{onClick:()=>y(g=>!g),className:"inline-flex items-center gap-2 px-2 py-1 rounded-xl transition-colors border border-[#E6E6E6] dark:border-[#272626]",children:[f?t.jsxs(t.Fragment,{children:[t.jsx(N.Loader,{className:"w-4 h-4 animate-spin text-[#1990FF]"}),t.jsx("span",{className:"text-xs text-[#999999] italic",children:c(`assistant.message.steps.${n?.chunk_type||r.type}`)})]}):t.jsxs(t.Fragment,{children:[t.jsx(Rt,{className:"w-4 h-4 text-[#38C200]"}),t.jsx("span",{className:"text-xs text-[#999999]",children:c(`assistant.message.steps.${n?.chunk_type||r.type}`)})]}),_?t.jsx(N.ChevronUp,{className:"w-4 h-4"}):t.jsx(N.ChevronDown,{className:"w-4 h-4"})]}),_&&t.jsx("div",{className:"pl-2 border-l-2 border-[#e5e5e5] dark:border-[#4e4e56]",children:t.jsx("div",{className:"text-[#8b8b8b] dark:text-[#a6a6a6] space-y-2",children:t.jsxs("div",{className:"mb-4 space-y-2 text-xs",children:[p?.keyword?t.jsxs("div",{className:"flex gap-1",children:[t.jsxs("span",{className:"text-[#999999]",children:["- ",c("assistant.message.steps.keywords"),":"]}),t.jsx("div",{className:"flex flex-wrap gap-1",children:p?.keyword?.map((g,o)=>t.jsxs("span",{className:"text-[#333333] dark:text-[#D8D8D8]",children:[g,o<2&&"、"]},g+o))})]}):null,p?.category?t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsxs("span",{className:"text-[#999999]",children:["- ",c("assistant.message.steps.questionType"),":"]}),t.jsx("span",{className:"text-[#333333] dark:text-[#D8D8D8]",children:p?.category})]}):null,p?.intent?t.jsxs("div",{className:"flex items-start gap-1",children:[t.jsxs("span",{className:"text-[#999999]",children:["- ",c("assistant.message.steps.userIntent"),":"]}),t.jsx("div",{className:"flex-1 text-[#333333] dark:text-[#D8D8D8]",children:p?.intent})]}):null,p?.query?t.jsxs("div",{className:"flex items-start gap-1",children:[t.jsxs("span",{className:"text-[#999999]",children:["- ",c("assistant.message.steps.relatedQuestions"),":"]}),t.jsx("div",{className:"flex-1 flex flex-col text-[#333333] dark:text-[#D8D8D8]",children:p?.query?.map((g,o)=>t.jsxs("span",{children:["- ",g]},g+o))})]}):null]})})})]})},Tt=({Detail:r,ChunkData:n,loading:d})=>{const{t:f}=Y.useTranslation(),[c,_]=i.useState(!1),[y,p]=i.useState("");return i.useEffect(()=>{r?.description&&p(r?.description)},[r?.description]),i.useEffect(()=>{n?.message_chunk&&p(n?.message_chunk)},[n?.message_chunk,y]),!n&&!r?null:t.jsxs("div",{className:"space-y-2 mb-3 w-full",children:[t.jsxs("button",{onClick:()=>_(l=>!l),className:"inline-flex items-center gap-2 px-2 py-1 rounded-xl transition-colors border border-[#E6E6E6] dark:border-[#272626]",children:[d?t.jsxs(t.Fragment,{children:[t.jsx(N.Loader,{className:"w-4 h-4 animate-spin text-[#1990FF]"}),t.jsx("span",{className:"text-xs text-[#999999] italic",children:f(`assistant.message.steps.${n?.chunk_type}`)})]}):t.jsxs(t.Fragment,{children:[t.jsx(N.Hammer,{className:"w-4 h-4 text-[#38C200]"}),t.jsx("span",{className:"text-xs text-[#999999]",children:f(`assistant.message.steps.${n?.chunk_type}`)})]}),c?t.jsx(N.ChevronUp,{className:"w-4 h-4"}):t.jsx(N.ChevronDown,{className:"w-4 h-4"})]}),c&&t.jsx("div",{className:"pl-2 border-l-2 border-[#e5e5e5] dark:border-[#4e4e56]",children:t.jsx("div",{className:"text-[#8b8b8b] dark:text-[#a6a6a6] space-y-2",children:t.jsx(Ge.XMarkdown,{content:y||""})})})]})},Xe=async r=>{navigator.clipboard?await navigator.clipboard.writeText(r):console.log("Clipboard not available",r)},Ft=r=>{window.open(r,"_blank")};function At(r){return t.jsx(ve,{...r,viewBox:"0 0 16 16",children:t.jsxs("g",{id:"Retrieve",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"10.8977456",y1:"14.5",x2:"14",y2:"10.9204757",id:"路径",stroke:"currentColor",strokeWidth:"1.25",transform:"translate(12.4489, 12.7102) scale(-1, 1) translate(-12.4489, -12.7102)"}),t.jsx("circle",{id:"椭圆形",stroke:"currentColor",strokeWidth:"1.25",transform:"translate(7.5, 7) scale(-1, 1) translate(-7.5, -7)",cx:"7.5",cy:"7",r:"5"})]})})}const Ot=({Detail:r,ChunkData:n,loading:d,formatUrl:f})=>{const{t:c}=Y.useTranslation(),[_,y]=i.useState(!1),[p,l]=i.useState(0),[g,o]=i.useState([]);i.useEffect(()=>{r?.payload&&(o(r?.payload),l(r?.payload.length))},[r?.payload]),i.useEffect(()=>{if(n?.message_chunk&&!d)try{const m=n.message_chunk.match(/<Payload total=(\d+)>/);m&&l(Number(m[1]));const b=n.message_chunk.match(/\[([\s\S]*)\]/);if(b){const I=JSON.parse(b[0]);o(I)}}catch(m){console.error("Failed to parse fetch source data:",m)}},[n?.message_chunk,d]);const j=m=>()=>{const b=f&&f(m)||m.url;b&&Ft(b)};return!n&&!r?null:t.jsxs("div",{className:`mt-2 mb-2 max-w-full w-full md:w-[610px] ${_?"rounded-lg overflow-hidden border border-[#E6E6E6] dark:border-[#272626]":""}`,children:[t.jsxs("button",{onClick:()=>y(m=>!m),className:`inline-flex justify-between items-center gap-2 px-2 py-1 rounded-xl transition-colors whitespace-nowrap ${_?"w-full":"border border-[#E6E6E6] dark:border-[#272626]"}`,children:[t.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[t.jsx(At,{className:"w-4 h-4 text-[#38C200] shrink-0"}),t.jsx("span",{className:"text-xs text-[#999999]",children:c(`assistant.message.steps.${n?.chunk_type||r.type}`,{count:Number(p)})})]}),_?t.jsx(N.ChevronUp,{className:"w-4 h-4 text-[#999999]"}):t.jsx(N.ChevronDown,{className:"w-4 h-4 text-[#999999]"})]}),_&&t.jsx(t.Fragment,{children:g?.map((m,b)=>t.jsx("div",{onClick:j(m),className:"group flex items-center p-2 hover:bg-[#F7F7F7] dark:hover:bg-[#2C2C2C] border-b border-[#E6E6E6] dark:border-[#272626] last:border-b-0 cursor-pointer transition-colors",children:t.jsxs("div",{className:"w-full flex items-center gap-2",children:[t.jsxs("div",{className:"w-[75%] mobile:w-full flex items-center gap-1",children:[t.jsx(N.Globe,{className:"w-3 h-3 shrink-0"}),t.jsx("div",{className:"text-xs text-[#333333] dark:text-[#D8D8D8] truncate font-normal group-hover:text-[#0072FF] dark:group-hover:text-[#0072FF]",children:m.title||m.category})]}),t.jsxs("div",{className:"flex-1 mobile:hidden flex items-center justify-end gap-2",children:[t.jsx("span",{className:"text-xs text-[#999999] dark:text-[#999999] truncate",children:m.source?.name||m?.category}),t.jsx(N.SquareArrowOutUpRight,{className:"w-3 h-3 text-[#999999] dark:text-[#999999] shrink-0"})]})]})},b))})]})};function Pt(r){return t.jsx(ve,{...r,viewBox:"0 0 16 16",children:t.jsx("g",{id:"selection",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:t.jsxs("g",{id:"编组",transform:"translate(1.4813, 1)",stroke:"currentColor",strokeWidth:"1.25",children:[t.jsx("line",{x1:"6.7986538",y1:"2.8",x2:"6.7986538",y2:"2.07241631e-17",id:"路径",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("circle",{id:"椭圆形",fill:"#000000",cx:"6.7986538",cy:"6.72",r:"1"}),t.jsx("line",{x1:"2.17440858e-17",y1:"13.5186538",x2:"4.62042688",y2:"8.89822692",id:"路径",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("line",{x1:"10.1008425",y1:"4.16781133",x2:"10.1008425",y2:"2.66781133",id:"路径",strokeLinecap:"round",strokeLinejoin:"round",transform:"translate(10.1008, 3.4178) rotate(45) translate(-10.1008, -3.4178)"}),t.jsx("line",{x1:"12.1186538",y1:"8.12",x2:"12.1186538",y2:"5.32",id:"路径",strokeLinecap:"round",strokeLinejoin:"round",transform:"translate(12.1187, 6.72) rotate(90) translate(-12.1187, -6.72)"}),t.jsx("line",{x1:"10.1008425",y1:"10.7721887",x2:"10.1008425",y2:"9.27218867",id:"路径",strokeLinecap:"round",strokeLinejoin:"round",transform:"translate(10.1008, 10.0222) rotate(135) translate(-10.1008, -10.0222)"}),t.jsx("line",{x1:"6.7986538",y1:"13.44",x2:"6.7986538",y2:"10.64",id:"路径",strokeLinecap:"round",strokeLinejoin:"round",transform:"translate(6.7987, 12.04) rotate(180) translate(-6.7987, -12.04)"}),t.jsx("line",{x1:"1.4786538",y1:"8.12",x2:"1.4786538",y2:"5.32",id:"路径",strokeLinecap:"round",strokeLinejoin:"round",transform:"translate(1.4787, 6.72) rotate(270) translate(-1.4787, -6.72)"}),t.jsx("line",{x1:"3.49646513",y1:"4.16781133",x2:"3.49646513",y2:"2.66781133",id:"路径",strokeLinecap:"round",strokeLinejoin:"round",transform:"translate(3.4965, 3.4178) rotate(315) translate(-3.4965, -3.4178)"})]})})})}const Lt=({Detail:r,ChunkData:n,loading:d})=>{const{t:f}=Y.useTranslation(),[c,_]=i.useState(!1),[y,p]=i.useState([]);return i.useEffect(()=>{r?.payload&&p(r?.payload)},[r?.payload]),i.useEffect(()=>{if(n?.message_chunk&&!d)try{const g=n.message_chunk.replace(/^"|"$/g,"").match(/<JSON>([\s\S]*?)<\/JSON>/g);if(g)for(let o=g.length-1;o>=0;o--)try{const j=g[o].replace(/<JSON>|<\/JSON>|<think>|<\/think>/g,""),m=JSON.parse(j.trim());if(Array.isArray(m)&&m.every(b=>b.id&&b.title&&b.explain)){p(m);break}}catch{continue}}catch(l){console.error("Failed to parse pick source data:",l)}},[n?.message_chunk,d]),!n&&!r?null:t.jsxs("div",{className:"space-y-2 mb-3 w-full",children:[t.jsxs("button",{onClick:()=>_(l=>!l),className:"inline-flex items-center gap-2 px-2 py-1 rounded-xl transition-colors border border-[#E6E6E6] dark:border-[#272626]",children:[d?t.jsxs(t.Fragment,{children:[t.jsx(N.Loader,{className:"w-4 h-4 animate-spin text-[#1990FF]"}),t.jsx("span",{className:"text-xs text-[#999999] italic",children:f("assistant.message.steps.pick_source_start")})]}):t.jsxs(t.Fragment,{children:[t.jsx(Pt,{className:"w-4 h-4 text-[#38C200]"}),t.jsx("span",{className:"text-xs text-[#999999]",children:f(`assistant.message.steps.${n?.chunk_type||r.type}`,{count:y?.length})})]}),c?t.jsx(N.ChevronUp,{className:"w-4 h-4"}):t.jsx(N.ChevronDown,{className:"w-4 h-4"})]}),c&&t.jsx("div",{className:"pl-2 border-l-2 border-[#e5e5e5] dark:border-[#4e4e56]",children:t.jsx("div",{className:"text-[#8b8b8b] dark:text-[#a6a6a6] space-y-2",children:t.jsx("div",{className:"mb-4 space-y-3 text-xs",children:y?.map(l=>t.jsx("div",{className:"p-3 rounded-lg border border-[#E6E6E6] dark:border-[#272626] bg-white dark:bg-[#1E1E1E] hover:bg-gray-50 dark:hover:bg-[#2C2C2C] transition-colors",children:t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("div",{className:"text-sm font-medium text-[#333333] dark:text-[#D8D8D8]",children:l.title}),t.jsx("div",{className:"text-xs text-[#666666] dark:text-[#A3A3A3] line-clamp-2",children:l.explain})]})},l.id))})})})]})};function It(r){return t.jsx(ve,{...r,viewBox:"0 0 16 16",children:t.jsxs("g",{id:"deading",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:[t.jsx("circle",{id:"椭圆形",stroke:"currentColor",strokeWidth:"1.25",cx:"8",cy:"3",r:"1.375"}),t.jsx("circle",{id:"椭圆形备份-2",stroke:"currentColor",strokeWidth:"1.25",cx:"3",cy:"5",r:"1.375"}),t.jsx("circle",{id:"椭圆形备份-4",stroke:"currentColor",strokeWidth:"1.25",cx:"13",cy:"5",r:"1.375"}),t.jsx("circle",{id:"椭圆形备份",stroke:"currentColor",strokeWidth:"1.25",cx:"8",cy:"13",r:"1.375"}),t.jsx("circle",{id:"椭圆形备份-3",stroke:"currentColor",strokeWidth:"1.25",cx:"3",cy:"11",r:"1.375"}),t.jsx("circle",{id:"椭圆形备份-5",stroke:"currentColor",strokeWidth:"1.25",cx:"13",cy:"11",r:"1.375"}),t.jsx("path",{d:"M8.0070039,4.03345364 L8.0070039,8.50590493 L4.1923477,10.2855921",id:"路径-13",stroke:"currentColor",strokeWidth:"1.25"}),t.jsx("line",{x1:"11.7924093",y1:"8.47550067",x2:"8",y2:"10.2754456",id:"路径-13备份",stroke:"currentColor",strokeWidth:"1.25",transform:"translate(9.8962, 9.3755) scale(-1, 1) translate(-9.8962, -9.3755)"}),t.jsx("path",{d:"M4.17568738,4.53038288 L6.65384701,3.54050563 M9.35480875,3.53987819 L11.7283558,4.49062879",id:"形状",stroke:"currentColor",strokeWidth:"1.25"}),t.jsx("line",{x1:"3",y1:"6.06946104",x2:"3",y2:"9.97988046",id:"路径-14",stroke:"currentColor",strokeWidth:"1.25"}),t.jsx("line",{x1:"13",y1:"6.06946104",x2:"13",y2:"9.97988046",id:"路径-14备份",stroke:"currentColor",strokeWidth:"1.25"})]})})}const $t=({Detail:r,ChunkData:n,loading:d})=>{const{t:f}=Y.useTranslation(),[c,_]=i.useState(!1),[y,p]=i.useState([]),[l,g]=i.useState("");return i.useEffect(()=>{r?.description&&g(r?.description)},[r?.description]),i.useEffect(()=>{if(n?.message_chunk)try{if(n.message_chunk.includes("&")){const o=n.message_chunk.split("&").filter(Boolean);p(o)}else p([n.message_chunk])}catch(o){console.error("Failed to parse query data:",o)}},[n?.message_chunk]),!n&&!r?null:t.jsxs("div",{className:"space-y-2 mb-3 w-full",children:[t.jsxs("button",{onClick:()=>_(o=>!o),className:"inline-flex items-center gap-2 px-2 py-1 rounded-xl transition-colors border border-[#E6E6E6] dark:border-[#272626]",children:[d?t.jsxs(t.Fragment,{children:[t.jsx(N.Loader,{className:"w-4 h-4 animate-spin text-[#1990FF]"}),t.jsx("span",{className:"text-xs text-[#999999] italic",children:f(`assistant.message.steps.${n?.chunk_type||r?.type}`)})]}):t.jsxs(t.Fragment,{children:[t.jsx(It,{className:"w-4 h-4 text-[#38C200]"}),t.jsx("span",{className:"text-xs text-[#999999]",children:f(`assistant.message.steps.${n?.chunk_type||r?.type}`,{count:Number(y.length)})})]}),c?t.jsx(N.ChevronUp,{className:"w-4 h-4"}):t.jsx(N.ChevronDown,{className:"w-4 h-4"})]}),c&&t.jsx("div",{className:"pl-2 border-l-2 border-[#e5e5e5] dark:border-[#4e4e56]",children:t.jsx("div",{className:"text-[#8b8b8b] dark:text-[#a6a6a6] space-y-2",children:t.jsxs("div",{className:"mb-4 space-y-3 text-xs",children:[y?.map(o=>t.jsx("div",{className:"flex flex-col gap-2",children:t.jsxs("div",{className:"text-xs text-[#999999] dark:text-[#808080]",children:["- ",o]})},o)),l?.split(`
|
|
31
|
+
`).map((o,j)=>o.trim()&&t.jsx("p",{className:"text-sm",children:o},j))]})})})]})},Wt=({Detail:r,ChunkData:n,loading:d})=>{const{t:f}=Y.useTranslation(),[c,_]=i.useState(!0),[y,p]=i.useState("");return i.useEffect(()=>{r?.description&&p(r?.description)},[r?.description]),i.useEffect(()=>{n?.message_chunk&&p(n?.message_chunk)},[n?.message_chunk,y]),!n&&!r?null:t.jsxs("div",{className:"space-y-2 mb-3 w-full",children:[t.jsxs("button",{onClick:()=>_(l=>!l),className:"inline-flex items-center gap-2 px-2 py-1 rounded-xl transition-colors border border-[#E6E6E6] dark:border-[#272626]",children:[d?t.jsxs(t.Fragment,{children:[t.jsx(N.Loader,{className:"w-4 h-4 animate-spin text-[#1990FF]"}),t.jsx("span",{className:"text-xs text-[#999999] italic",children:f(`assistant.message.steps.${n?.chunk_type}`)})]}):t.jsxs(t.Fragment,{children:[t.jsx(N.Brain,{className:"w-4 h-4 text-[#38C200]"}),t.jsx("span",{className:"text-xs text-[#999999]",children:f("assistant.message.steps.thoughtTime")})]}),c?t.jsx(N.ChevronUp,{className:"w-4 h-4"}):t.jsx(N.ChevronDown,{className:"w-4 h-4"})]}),c&&t.jsx("div",{className:"pl-2 border-l-2 border-[#e5e5e5] dark:border-[#4e4e56]",children:t.jsx("div",{className:"text-[#8b8b8b] dark:text-[#a6a6a6] space-y-2",children:y?.split(`
|
|
32
|
+
`).map((l,g)=>l.trim()&&t.jsx("p",{className:"text-sm",children:l},g))})})]})},Mt=Fe.create(r=>({synthesizeItem:null,setSynthesizeItem:n=>r({synthesizeItem:n}),uploadAttachments:[],setUploadAttachments:n=>r({uploadAttachments:n})})),qt=["timedout","error"],Ut=({id:r,content:n,question:d,actionClassName:f,actionIconSize:c,copyButtonId:_,onResend:y})=>{const[p,l]=i.useState(!1),[g,o]=i.useState(!1),[j,m]=i.useState(!1),[b,I]=i.useState(!1),[U,w]=i.useState(!1),x=qt.includes(r),{synthesizeItem:R,setSynthesizeItem:re}=Mt(),ne=async()=>{try{await Xe(n),l(!0);const P=setTimeout(()=>{l(!1),clearTimeout(P)},2e3)}catch(P){console.error("copy error:",P)}},V=()=>{o(!g),m(!1)},ae=()=>{m(!j),o(!1)},X=async()=>re({id:r,content:n}),K=()=>{if(y){w(!0),y();const P=setTimeout(()=>{w(!1),clearTimeout(P)},1e3)}};return t.jsxs("div",{className:he("flex items-center gap-1 mt-2",f),children:[!x&&t.jsx("button",{id:_,onClick:ne,className:"p-1 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg transition-colors",children:p?t.jsx(N.Check,{className:"w-4 h-4 text-[#38C200] dark:text-[#38C200]",style:{width:c,height:c}}):t.jsx(N.Copy,{className:"w-4 h-4 text-[#666666] dark:text-[#A3A3A3]",style:{width:c,height:c}})}),!x&&t.jsx("button",{onClick:V,className:`p-1 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg transition-colors ${g?"animate-shake":""}`,children:t.jsx(N.ThumbsUp,{className:`w-4 h-4 ${g?"text-[#1990FF] dark:text-[#1990FF]":"text-[#666666] dark:text-[#A3A3A3]"}`,style:{width:c,height:c}})}),!x&&t.jsx("button",{onClick:ae,className:`p-1 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg transition-colors ${j?"animate-shake":""}`,children:t.jsx(N.ThumbsDown,{className:`w-4 h-4 ${j?"text-[#1990FF] dark:text-[#1990FF]":"text-[#666666] dark:text-[#A3A3A3]"}`,style:{width:c,height:c}})}),!x&&t.jsx(t.Fragment,{children:t.jsx("button",{onClick:X,className:"p-1 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg transition-colors",children:t.jsx(N.Volume2,{className:`w-4 h-4 ${b||R?.id===r?"text-[#1990FF] dark:text-[#1990FF]":"text-[#666666] dark:text-[#A3A3A3]"}`,style:{width:c,height:c}})})}),d&&t.jsx("button",{onClick:K,className:`p-1 hover:bg-black/5 dark:hover:bg-white/5 rounded-lg transition-colors ${U?"animate-spin":""}`,children:t.jsx(N.RotateCcw,{className:`w-4 h-4 ${U?"text-[#1990FF] dark:text-[#1990FF]":"text-[#666666] dark:text-[#A3A3A3]"}`,style:{width:c,height:c}})})]})};function Dt({suggestions:r,onSelect:n}){return!r||r.length===0?null:t.jsx("div",{className:"mt-4 flex flex-col gap-2",children:r.map((d,f)=>t.jsxs("button",{onClick:()=>n(d),className:"text-left inline-flex items-center px-3 py-1.5 rounded-full bg-white dark:bg-[#202126] border border-[#E4E5EF] dark:border-[#272626] text-sm text-[#666666] dark:text-[#A3A3A3] hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors w-fit max-w-full break-words whitespace-pre-wrap",children:[t.jsx("span",{className:"break-all",children:d}),t.jsx(N.MoveRight,{className:"w-3 h-3 ml-1.5 shrink-0"})]},f))})}const Bt=({textToCopy:r})=>{const[n,d]=i.useState(!1),f=async()=>{try{await Xe(r),d(!0);const c=setTimeout(()=>{d(!1),clearTimeout(c)},2e3)}catch(c){console.error("copy error:",c)}};return t.jsx("button",{className:"p-1 bg-gray-200 dark:bg-gray-700 rounded",onClick:f,children:n?t.jsx(N.Check,{className:"w-4 h-4 text-[#38C200] dark:text-[#38C200]"}):t.jsx(N.Copy,{className:"w-4 h-4 text-gray-600 dark:text-gray-300"})})},Yt={commands:async(r,n)=>(console.log(`Mock command: ${r}`,n),r==="get_attachment_by_ids"?{hits:{hits:[{_source:{id:"1",name:"测试文件1.txt",icon:"txt",size:"4kb"}},{_source:{id:"2",name:"测试文件2.pdf",icon:"pdf",size:"982kb"}},{_source:{id:"3",name:"测试文件3.md",icon:"md",size:"12kb"}}]}}:{hits:{hits:[]}}),invokeBackend:async(r,n)=>{console.log(`Mock invokeBackend: ${r}`,n)}},Te=Fe.create(r=>({currentAssistant:{},assistantList:[],currentService:{id:"mock-service-id"},setAssistant:n=>r({currentAssistant:n})})),Jt=Fe.create(()=>({addError:r=>console.error(r)})),Vt=r=>{const{message:n,attachments:d}=r,[f,c]=i.useState(!1),{currentService:_}=Te(),[y,p]=i.useState([]),{addError:l}=Jt(),g=o=>{if(typeof window<"u"&&typeof document<"u"){const j=window.getSelection(),m=document.createRange();if(o.currentTarget&&j&&m)try{m.selectNodeContents(o.currentTarget),j.removeAllRanges(),j.addRange(m)}catch(b){console.error("Selection failed:",b)}}};return jt.useAsyncEffect(async()=>{try{if(d.length===0)return;const o=await Yt.commands("get_attachment_by_ids",{serverId:_.id,attachments:d});p(o?.hits?.hits)}catch(o){l(String(o))}},[d]),t.jsxs(t.Fragment,{children:[n&&t.jsxs("div",{className:"flex gap-1 items-center justify-end",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[t.jsx("div",{className:he("size-6 transition",{"opacity-0":!f}),children:t.jsx(Bt,{textToCopy:n})}),t.jsx("div",{className:"max-w-[85%] overflow-auto text-left px-3 py-2 bg-white dark:bg-[#202126] rounded-xl border border-black/12 dark:border-black/15 font-normal text-sm text-[#333333] dark:text-[#D8D8D8] cursor-pointer user-select-text whitespace-pre-wrap",onDoubleClick:g,children:n})]}),y&&y.length>0&&t.jsx("div",{className:he("w-full",{"mt-3":n}),children:t.jsx(_t.Attachments,{data:y.map(o=>({id:o._source.id,filename:o._source.name,extname:o._source.icon,size:o._source.size,status:"uploaded"})),className:"text-left"})})]})},Kt=({name:r,className:n,style:d,...f})=>t.jsx("svg",{className:`icon dark:drop-shadow-[0_0_6px_rgb(255,255,255)] ${n||""}`,style:d,...f,children:t.jsx("use",{xlinkHref:`#${r}`})});function zt(){const[r,n]=i.useState(),[d,f]=i.useState(),[c,_]=i.useState(),[y,p]=i.useState(),[l,g]=i.useState(),[o,j]=i.useState(),[m,b]=i.useState(),I={deal_query_intent:i.useCallback(w=>{n(x=>x?{...x,message_chunk:(x.message_chunk||"")+(w.message_chunk||"")}:w)},[]),deal_tools:i.useCallback(w=>{f(x=>x?{...x,message_chunk:(x.message_chunk||"")+(w.message_chunk||"")}:w)},[]),deal_fetch_source:i.useCallback(w=>{_(x=>x?{...x,message_chunk:(x.message_chunk||"")+(w.message_chunk||"")}:w)},[]),deal_pick_source:i.useCallback(w=>{p(x=>x?{...x,message_chunk:(x.message_chunk||"")+(w.message_chunk||"")}:w)},[]),deal_deep_read:i.useCallback(w=>{g(x=>x?{...x,message_chunk:(x.message_chunk||"")+"&"+(w.message_chunk||"")}:w)},[]),deal_think:i.useCallback(w=>{j(x=>x?{...x,message_chunk:(x.message_chunk||"")+(w.message_chunk||"")}:w)},[]),deal_response:i.useCallback(w=>{b(x=>x?{...x,message_chunk:(x.message_chunk||"")+(w.message_chunk||"")}:w)},[])};return{data:{query_intent:r,tools:d,fetch_source:c,pick_source:y,deep_read:l,think:o,response:m},handlers:I,clearAllChunkData:()=>new Promise(w=>{n(void 0),f(void 0),_(void 0),p(void 0),g(void 0),j(void 0),b(void 0),setTimeout(w,0)})}}function Gt(r){if(r)return r==="light"?"light":r==="dark"||typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}const Qt=i.memo(i.forwardRef(function({message:n,isTyping:d,onResend:f,hide_assistant:c=!1,rootClassName:_,actionClassName:y,actionIconSize:p,copyButtonId:l,formatUrl:g,theme:o,locale:j,query_intent:m,tools:b,fetch_source:I,pick_source:U,deep_read:w,think:x,response:R},re){const{t:ne,i18n:V}=Y.useTranslation(),ae=Gt(o),X=Te(h=>h.currentAssistant),K=Te(h=>h.assistantList),[P,ie]=i.useState({}),{data:{query_intent:je,tools:xe,fetch_source:q,pick_source:D,deep_read:z,think:me,response:H},handlers:F,clearAllChunkData:pe}=zt();i.useEffect(()=>{m&&F.deal_query_intent(m)},[m]),i.useEffect(()=>{b&&F.deal_tools(b)},[b]),i.useEffect(()=>{I&&F.deal_fetch_source(I)},[I]),i.useEffect(()=>{U&&F.deal_pick_source(U)},[U]),i.useEffect(()=>{w&&F.deal_deep_read(w)},[w]),i.useEffect(()=>{x&&F.deal_think(x)},[x]),i.useEffect(()=>{R&&F.deal_response(R)},[R]);const[B,oe]=i.useState({query_intent:!1,tools:!1,fetch_source:!1,pick_source:!1,deep_read:!1,think:!1,response:!1}),G=i.useRef(!1);i.useImperativeHandle(re,()=>({addChunk:h=>{if(oe(()=>({query_intent:!1,tools:!1,fetch_source:!1,pick_source:!1,deep_read:!1,think:!1,response:!1,[h.chunk_type||""]:!0})),h.chunk_type==="query_intent")F.deal_query_intent(h);else if(h.chunk_type==="tools")F.deal_tools(h);else if(h.chunk_type==="fetch_source")F.deal_fetch_source(h);else if(h.chunk_type==="pick_source")F.deal_pick_source(h);else if(h.chunk_type==="deep_read")F.deal_deep_read(h);else if(h.chunk_type==="think")F.deal_think(h);else if(h.chunk_type==="response"){const M=h.message_chunk;if(typeof M=="string"){if(M.includes("<think>")||M.includes("<think>")){G.current=!0;return}else if(M.includes("</think>")||M.includes("</think>")){G.current=!1;return}G.current?F.deal_think({...h,chunk_type:"think"}):F.deal_response(h)}}},reset:()=>{pe(),oe({query_intent:!1,tools:!1,fetch_source:!1,pick_source:!1,deep_read:!1,think:!1,response:!1}),G.current=!1}}));const $=n?._source?.type==="assistant",ce=n?._source?.assistant_id,le=n?._source?.assistant_item;i.useEffect(()=>{j&&V.language!==j&&V.changeLanguage(j)},[j,V]),i.useEffect(()=>{if(le){ie(le);return}if($&&ce&&Array.isArray(K)){ie(K.find(h=>h._id===ce)??{});return}ie(X)},[$,le,ce,K,X]);const J=n?._source?.message||"",ue=n?._source?.attachments??[],W=n?._source?.details||[],Z=n?._source?.question||"",ee=d===!1&&(J||H?.message_chunk),[_e,ge]=i.useState([]),be=h=>{ge(h)},we=()=>$?t.jsxs(t.Fragment,{children:[t.jsx(St,{Detail:W.find(h=>h.type==="query_intent"),ChunkData:je,getSuggestion:be,loading:B?.query_intent}),t.jsx(Tt,{Detail:W.find(h=>h.type==="tools"),ChunkData:xe,loading:B?.tools}),t.jsx(Ot,{Detail:W.find(h=>h.type==="fetch_source"),ChunkData:q,loading:B?.fetch_source,formatUrl:g}),t.jsx(Lt,{Detail:W.find(h=>h.type==="pick_source"),ChunkData:D,loading:B?.pick_source}),t.jsx($t,{Detail:W.find(h=>h.type==="deep_read"),ChunkData:z,loading:B?.deep_read}),t.jsx(Wt,{Detail:W.find(h=>h.type==="think"),ChunkData:me,loading:B?.think}),t.jsx(Ge.XMarkdown,{content:J||H?.message_chunk||""}),d&&t.jsx("div",{className:"inline-block w-1.5 h-5 ml-0.5 -mb-0.5 bg-[#666666] dark:bg-[#A3A3A3] rounded-sm animate-typing"}),ee&&t.jsx(Ut,{id:n._id??"",content:J||H?.message_chunk||"",question:Z,actionClassName:y,actionIconSize:p,copyButtonId:l,onResend:()=>{f&&f(Z)}}),!d&&t.jsx(Dt,{suggestions:_e,onSelect:h=>f&&f(h)})]}):t.jsx(Vt,{message:J,attachments:ue});return t.jsx("div",{className:he("w-full py-8 flex",[$?"justify-start":"justify-end"],ae==="dark"&&"dark",_),children:t.jsx("div",{className:`w-full px-4 flex gap-4 ${$?"w-full":"flex-row-reverse"}`,children:t.jsxs("div",{className:`w-full space-y-2 ${$?"text-left":"text-right"}`,children:[!c&&t.jsxs("div",{className:"w-full flex items-center gap-1 font-semibold text-sm text-[#333] dark:text-[#d8d8d8]",children:[$?t.jsx("div",{className:"w-6 h-6 flex justify-center items-center rounded-full bg-white border border-[#E6E6E6]",children:P?._source?.icon?.startsWith("font_")?t.jsx(Kt,{name:P._source.icon,className:"w-4 h-4"}):t.jsx("img",{src:Ct,className:"w-4 h-4",alt:ne("assistant.message.logo")})}):null,$?P?._source?.name||"Coco AI":""]}),t.jsx("div",{className:"w-full prose dark:prose-invert prose-sm max-w-none",children:t.jsx("div",{className:"w-full pl-7 text-[#333] dark:text-[#d8d8d8] leading-relaxed",children:we()})})]})})})})),Xt=i.memo(i.forwardRef((r,n)=>t.jsx(Y.I18nextProvider,{i18n:Qe,children:t.jsx(Qt,{...r,ref:n})})));exports.ChatMessage=Xt;
|