@nocobase/plugin-ai 2.1.0-beta.2 → 2.1.0-beta.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/LICENSE +201 -0
- package/README.md +99 -1
- package/dist/client/2793ab2b95a86390.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +13 -13
- package/dist/node_modules/@langchain/anthropic/package.json +1 -1
- package/dist/node_modules/@langchain/core/package.json +1 -1
- package/dist/node_modules/@langchain/deepseek/package.json +1 -1
- package/dist/node_modules/@langchain/google-genai/package.json +1 -1
- package/dist/node_modules/@langchain/langgraph/package.json +1 -1
- package/dist/node_modules/@langchain/langgraph-checkpoint/package.json +1 -1
- package/dist/node_modules/@langchain/ollama/package.json +1 -1
- package/dist/node_modules/@langchain/openai/package.json +1 -1
- package/dist/node_modules/fast-glob/package.json +1 -1
- package/dist/node_modules/flexsearch/package.json +1 -1
- package/dist/node_modules/fs-extra/package.json +1 -1
- package/dist/node_modules/langchain/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/ai-employees/ai-employee.d.ts +1 -1
- package/dist/server/ai-employees/ai-employee.js +51 -56
- package/dist/server/collections/lc-checkpoint-blobs.js +2 -1
- package/dist/server/collections/lc-checkpoint-writes.js +1 -0
- package/dist/server/llm-providers/openai/completions.js +1 -1
- package/dist/server/llm-providers/provider.d.ts +1 -0
- package/dist/server/llm-providers/provider.js +9 -3
- package/dist/server/migrations/20250517214622-init-settings.js +1 -1
- package/dist/server/migrations/20250923221107-setup-build-in.js +1 -1
- package/dist/server/migrations/20260107000000-reset-builtin-about.js +1 -1
- package/dist/server/migrations/20260131000000-add-model-options.js +1 -1
- package/dist/server/migrations/20260225220347-alter-checkpoint-blob-field.d.ts +15 -0
- package/dist/server/migrations/20260225220347-alter-checkpoint-blob-field.js +63 -0
- package/dist/server/plugin.js +1 -0
- package/dist/server/resource/aiConversations.js +16 -1
- package/package.json +2 -2
- package/LICENSE.txt +0 -172
- package/dist/client/66c939b3395bb7c4.js +0 -10
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1 +1,99 @@
|
|
|
1
|
-
#
|
|
1
|
+
# NocoBase
|
|
2
|
+
|
|
3
|
+
<video width="100%" controls>
|
|
4
|
+
<source src="https://github.com/user-attachments/assets/4d11a87b-00e2-48f3-9bf7-389d21072d13" type="video/mp4">
|
|
5
|
+
</video>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://trendshift.io/repositories/4112" target="_blank"><img src="https://trendshift.io/api/badge/repositories/4112" alt="nocobase%2Fnocobase | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
|
9
|
+
<a href="https://www.producthunt.com/posts/nocobase?embed=true&utm_source=badge-top-post-topic-badge&utm_medium=badge&utm_souce=badge-nocobase" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/top-post-topic-badge.svg?post_id=456520&theme=light&period=weekly&topic_id=267" alt="NocoBase - Scalability-first, open-source no-code platform | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
## What is NocoBase
|
|
13
|
+
|
|
14
|
+
NocoBase is the most extensible AI-powered no-code platform.
|
|
15
|
+
Total control. Infinite extensibility. AI collaboration.
|
|
16
|
+
Enable your team to adapt quickly and cut costs dramatically.
|
|
17
|
+
No years of development. No millions wasted.
|
|
18
|
+
Deploy NocoBase in minutes — and take control of everything.
|
|
19
|
+
|
|
20
|
+
Homepage:
|
|
21
|
+
https://www.nocobase.com/
|
|
22
|
+
|
|
23
|
+
Online Demo:
|
|
24
|
+
https://demo.nocobase.com/new
|
|
25
|
+
|
|
26
|
+
Documents:
|
|
27
|
+
https://docs.nocobase.com/
|
|
28
|
+
|
|
29
|
+
Forum:
|
|
30
|
+
https://forum.nocobase.com/
|
|
31
|
+
|
|
32
|
+
Use Cases:
|
|
33
|
+
https://www.nocobase.com/en/blog/tags/customer-stories
|
|
34
|
+
|
|
35
|
+
## Release Notes
|
|
36
|
+
|
|
37
|
+
Our [blog](https://www.nocobase.com/en/blog/timeline) is regularly updated with release notes and provides a weekly summary.
|
|
38
|
+
|
|
39
|
+
## Distinctive features
|
|
40
|
+
|
|
41
|
+
### 1. Data model-driven, not form/table–driven
|
|
42
|
+
|
|
43
|
+
Instead of being constrained by forms or tables, NocoBase adopts a data model–driven approach, separating data structure from user interface to unlock unlimited possibilities.
|
|
44
|
+
|
|
45
|
+
- UI and data structure are fully decoupled
|
|
46
|
+
- Multiple blocks and actions can be created for the same table or record in any quantity or form
|
|
47
|
+
- Supports the main database, external databases, and third-party APIs as data sources
|
|
48
|
+
|
|
49
|
+

|
|
50
|
+
|
|
51
|
+
### 2. AI employees, integrated into your business systems
|
|
52
|
+
Unlike standalone AI demos, NocoBase allows you to embed AI capabilities seamlessly into your interfaces, workflows, and data context, making AI truly useful in real business scenarios.
|
|
53
|
+
|
|
54
|
+
- Define AI employees for roles such as translator, analyst, researcher, or assistant
|
|
55
|
+
- Seamless AI–human collaboration in interfaces and workflows
|
|
56
|
+
- Ensure AI usage is secure, transparent, and customizable for your business needs
|
|
57
|
+
|
|
58
|
+

|
|
59
|
+
|
|
60
|
+
### 3. What you see is what you get, incredibly easy to use
|
|
61
|
+
|
|
62
|
+
While enabling the development of complex business systems, NocoBase keeps the experience simple and intuitive.
|
|
63
|
+
|
|
64
|
+
- One-click switch between usage mode and configuration mode
|
|
65
|
+
- Pages serve as a canvas to arrange blocks and actions, similar to Notion
|
|
66
|
+
- Configuration mode is designed for ordinary users, not just programmers
|
|
67
|
+
|
|
68
|
+

|
|
69
|
+
|
|
70
|
+
### 4. Everything is a plugin, designed for extension
|
|
71
|
+
Adding more no-code features will never cover every business case. NocoBase is built for extension through its plugin-based microkernel architecture.
|
|
72
|
+
|
|
73
|
+
- All functionalities are plugins, similar to WordPress
|
|
74
|
+
- Plugins are ready to use upon installation
|
|
75
|
+
- Pages, blocks, actions, APIs, and data sources can all be extended through custom plugins
|
|
76
|
+
|
|
77
|
+

|
|
78
|
+
|
|
79
|
+
## Installation
|
|
80
|
+
|
|
81
|
+
NocoBase supports three installation methods:
|
|
82
|
+
|
|
83
|
+
- <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/docker-compose">Installing With Docker (👍Recommended)</a>
|
|
84
|
+
|
|
85
|
+
Suitable for no-code scenarios, no code to write. When upgrading, just download the latest image and reboot.
|
|
86
|
+
|
|
87
|
+
- <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/create-nocobase-app">Installing from create-nocobase-app CLI</a>
|
|
88
|
+
|
|
89
|
+
The business code of the project is completely independent and supports low-code development.
|
|
90
|
+
|
|
91
|
+
- <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/git-clone">Installing from Git source code</a>
|
|
92
|
+
|
|
93
|
+
If you want to experience the latest unreleased version, or want to participate in the contribution, you need to make changes and debug on the source code, it is recommended to choose this installation method, which requires a high level of development skills, and if the code has been updated, you can git pull the latest code.
|
|
94
|
+
|
|
95
|
+
## How NocoBase works
|
|
96
|
+
|
|
97
|
+
<video width="100%" controls>
|
|
98
|
+
<source src="https://github.com/user-attachments/assets/8d183b44-9bb5-4792-b08f-bc08fe8dfaaf" type="video/mp4">
|
|
99
|
+
</video>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_ai=self.webpackChunk_nocobase_plugin_ai||[]).push([["107"],{3973:function(e,t,n){n.r(t),n.d(t,{AIEmployeesProvider:function(){return tH}});var r=n(8156),o=n.n(r),l=n(5997),a=n(3772),i=(0,r.createContext)({}),u=function(e){var t=(0,a.useAPIClient)(),n=(0,a.useRequest)(function(){return t.resource("aiSettings").publicGet().then(function(e){var t;return null==e||null==(t=e.data)?void 0:t.data})}).data;return o().createElement(i.Provider,{value:n},e.children)},c=n(2721),s=n(482),f=n(5441),p=n(4964),m=n(3990),d=n(3505),y=n(8875),v=n(8520),b=n(4241),h=n(5708),g=n(679),E=n(9039),O=n(5940),w=n(3972);function x(e,t,n,r,o,l,a){try{var i=e[l](a),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}function S(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function a(e){x(l,r,o,a,i,"next",e)}function i(e){x(l,r,o,a,i,"throw",e)}a(void 0)})}}function j(e,t){var n,r,o,l,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return l={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function i(l){return function(i){var u=[l,i];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function C(){var e,t,n=(e=["\n .ant-conversations-item {\n .ant-conversations-label {\n display: block !important;\n overflow: hidden !important;\n text-overflow: ellipsis !important;\n white-space: nowrap !important;\n max-width: calc(100% - 30px);\n }\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return C=function(){return n},n}var k=function(){var e=(0,a.useActionContext)().setVisible,t=(0,d.useForm)();return{onClick:function(){e(!1),t.reset()}}},P=function(e){var t=(0,a.useActionContext)().setVisible,n=(0,a.useAPIClient)(),r=(0,d.useForm)(),o=(0,v.D)().conversationsService;return{onClick:S(function(){return j(this,function(l){switch(l.label){case 0:return[4,r.submit()];case 1:return l.sent(),[4,n.resource("aiConversations").update({filterByTk:e,values:{title:r.values.title}})];case 2:return l.sent(),t(!1),r.reset(),o.run(),[2]}})})}},A=function(e){var t,n,r,l=e.conversation,i=(0,m.NT)();return o().createElement(a.SchemaComponent,{scope:{useCloseActionProps:k,useSubmitActionProps:function(){return P(l.key)}},schema:{name:"rename",type:"void","x-component":"Action","x-component-props":{component:function(e){return o().createElement("div",e,i("Rename"))}},title:i("Rename"),properties:(t={},n=(0,y.uid)(),r={type:"void","x-component":"Action.Modal","x-component-props":{styles:{mask:{zIndex:1100},wrapper:{zIndex:1100}}},title:i("Rename conversation"),"x-decorator":"FormV2",properties:{title:{type:"string",title:i("Title"),required:!0,"x-decorator":"FormItem","x-component":"Input",default:l.title||""},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{close:{title:i("Cancel"),"x-component":"Action","x-use-component-props":"useCloseActionProps"},submit:{title:i("Submit"),"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useSubmitActionProps"}}}}},n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t)}})},T=(0,r.memo)(function(){var e,t=(0,m.NT)(),n=(0,a.useAPIClient)(),l=c.App.useApp(),i=l.modal,u=l.message,d=(0,w.S)().aiEmployeesMap,y=O.h.use.currentEmployee(),x=O.h.use.setCurrentEmployee(),k=O.h.use.setShowConversations(),P=O.h.use.setModel(),T=O.h.use.expanded(),I=b.U.use.currentConversation(),z=b.U.use.setCurrentConversation(),M=b.U.use.conversations(),D=b.U.use.keyword(),B=b.U.use.setKeyword(),N=h.h.use.setMessages(),R=(0,g.z)().messagesService,F=(0,v.D)(),L=F.conversationsService,U=F.lastConversationRef,_=L.loading,H=(0,E.W)(),$=H.startNewConversation,W=H.clear,q=(0,r.useMemo)(function(){var e=M.map(function(e){var n=e.title||t("New conversation");return{key:e.sessionId,title:n,timestamp:new Date(e.updatedAt).getTime(),label:n}});return _&&e.push({key:"loading",label:o().createElement(c.Spin,{style:{display:"block",margin:"8px auto"}})}),e},[M,_]),V=(0,r.useRef)(null);(0,r.useEffect)(function(){if(V.current&&M.length){var e=V.current.querySelector(".ant-conversations-item:last-child");e&&U(e)}},[M,U]);var Y=(e=S(function(e){return j(this,function(r){switch(r.label){case 0:return[4,n.resource("aiConversations").destroy({filterByTk:e})];case 1:return r.sent(),u.success(t("Deleted successfully")),L.run(),y&&$(),[2]}})}),function(t){return e.apply(this,arguments)});return o().createElement("div",{style:{display:"flex",flexDirection:"column",height:"100%"}},o().createElement("div",{style:{padding:"8px 12px",flexShrink:0}},o().createElement(c.Input.Search,{value:D,onChange:function(e){B(e.target.value)},placeholder:t("Search"),onSearch:function(e){return L.run(1,e)},onClear:function(){return L.run(1)},allowClear:!0})),o().createElement("div",{ref:V,style:{flex:1,minHeight:0,overflowY:"auto",overflowX:"hidden"}},M&&M.length?o().createElement(f.Z,{className:(0,p.css)(C()),activeKey:I,onActiveChange:function(e){if(e!==I){z(e);var t,n=M.find(function(t){return t.sessionId===e});x(d[null==n||null==(t=n.aiEmployee)?void 0:t.username]),N([]),W(),P(null),R.run(e),T||k(!1)}},items:q,menu:function(e){return{items:[{label:o().createElement(A,{conversation:e}),key:"rename",icon:o().createElement(s.EditOutlined,null)},{label:t("Delete"),key:"delete",icon:o().createElement(s.DeleteOutlined,null)}],onClick:function(n){var r=n.key;n.domEvent.stopPropagation(),"delete"===r&&i.confirm({title:t("Delete conversation"),content:t("Are you sure you want to delete it?"),onOk:function(){return Y(e.key)}})}}}}):o().createElement(c.Empty,{image:c.Empty.PRESENTED_IMAGE_SIMPLE})))}),I=n(1e3),z=n(8731);function M(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function D(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}var B=function(){var e=(0,m.NT)(),t=(0,a.useToken)().token,n=O.h.use.roles(),l=h.h.use.messages(),i=z.Y.use.updateTools(),u=(0,g.z)(),s=u.messagesService,f=u.lastMessageRef;(0,r.useEffect)(function(){i(l)},[l,i]);var p=(0,r.useRef)(null);return(0,r.useEffect)(function(){if(p.current){var e=p.current,t=new ResizeObserver(function(){e.scrollTop=e.scrollHeight});return t.observe(e),function(){return t.disconnect()}}},[l]),o().createElement(c.Layout.Content,{ref:p,style:{margin:"16px 0",overflow:"auto",position:"relative"}},s.loading&&o().createElement(c.Spin,{style:{display:"block",margin:"8px auto"}}),(null==l?void 0:l.length)?o().createElement("div",null,l.map(function(e,t){var r,l=n[e.role];return l?0===t&&(null==(r=e.content)?void 0:r.type)!=="greeting"?o().createElement("div",{key:e.key,ref:f},o().createElement(I.Z,D(M({},l),{loading:e.loading,content:e.content}))):o().createElement(I.Z,D(M({},l),{key:e.key,loading:e.loading,content:e.content})):null})):o().createElement("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:t.colorTextDescription}},e("Work with your AI crew")))},N=n(2634),R=n(1707),F=n(3183),L=n.n(F);function U(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}var _=function(){var e,t,n,o,l,u,c,s,f,p,m,d,y=h.h.use.setAttachments(),v={action:"aiFiles:create",onChange:function(e){y(e.fileList.map(function(e){if("done"===e.status){var t,n,r;return(null==e||null==(t=e.response)?void 0:t.data)?(n=U({},e.response.data),r=r={status:e.status},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n):e}return e}))}},b=(e=(0,a.useAPIClient)(),U({customRequest:function(t){var n=t.action,r=t.data,o=t.file,l=t.filename,a=t.headers,i=t.onError,u=(t.onProgress,t.onSuccess),c=t.withCredentials,s=new FormData;return r&&Object.keys(r).forEach(function(e){s.append(e,r[e])}),s.append(l,o),e.axios.post(n,s,{withCredentials:c,headers:a}).then(function(e){u(e.data,o)}).catch(function(e){return i(Error(e.message))}).finally(function(){}),{abort:function(){console.log("upload progress is aborted.")}}}},v)),g=(t=(0,r.useContext)(i).storage,n=(0,a.usePlugin)(L()),o=null!=t?t:"",l="storages:getBasicInfo/".concat(o),c=(u=(0,a.useRequest)({url:l},{refreshDeps:[o],cacheKey:l})).loading,s=u.data,f=!c&&(null==s?void 0:s.data)||null,d=(null==(m=null==(p=n.getStorageType(t))?void 0:p.useUploadProps)?void 0:m(U({storage:f,rules:f.rules},v)))||{},U({rules:null==f?void 0:f.rules},d));return U({},b,v,g)};function H(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}var $=function(){var e=(0,m.NT)(),t=_(),n=O.h.use.chatBoxRef(),l=O.h.use.currentEmployee(),a=h.h.use.attachments(),i=(0,r.useMemo)(function(){return null==a?void 0:a.map(function(e,t){var n;return H({uid:t.toString(),name:e.filename,status:null!=(n=e.status)?n:"done",url:e.url,size:e.size,thumbUrl:e.preview},e)})},[a]);return l?o().createElement(R.Z,H({getDropContainer:function(){return n.current},styles:{placeholder:{opacity:.8}},placeholder:{icon:o().createElement(s.PaperClipOutlined,null),title:e("Drag & Drop files here")},items:i},t),o().createElement(c.Tooltip,{title:e("Upload files"),arrow:!1},o().createElement(c.Button,{type:"text",icon:o().createElement(s.PaperClipOutlined,null)}))):o().createElement(c.Button,{type:"text",icon:o().createElement(s.PaperClipOutlined,null),disabled:!0})},W=n(7928),q=n(467),V=n.n(q),Y=n(2667),X=n(4102),G=n(3715),K=(0,Y.observer)(function(){var e,t,n=(0,m.NT)(),l=b.U.use.webSearch(),a=b.U.use.setWebSearch(),i=O.h.use.currentEmployee(),u=O.h.use.model(),f=(0,X.j)().services,p=(0,G.zC)(f,u),d=null!=(e=null==p?void 0:p.supportWebSearch)&&e,y=null!=(t=null==p?void 0:p.isToolConflict)&&t;(0,r.useEffect)(function(){!d&&l&&a(!1)},[d,l,a]);var v=function(){d&&a(!l)};if(!i)return o().createElement(c.Button,{type:"text",icon:o().createElement(s.GlobalOutlined,null),disabled:!0});var h=n("Disable search"),g=n("Web search not supported"),E=y?o().createElement("div",null,o().createElement("div",null,n("Enable search")),o().createElement("div",{style:{marginTop:4}},n("Search disables tools"))):n("Enable search");return l?o().createElement(c.Tooltip,{title:h,arrow:!1},o().createElement(c.Button,{color:"primary",variant:"filled",icon:o().createElement(s.GlobalOutlined,null),onClick:v})):o().createElement(c.Tooltip,{title:d?E:g,arrow:!1},o().createElement(c.Button,{type:"text",icon:o().createElement(s.GlobalOutlined,null),onClick:v,disabled:!d}))},{displayName:"SearchSwitch"}),Z=n(8563),J=n(4627),Q=n(4153),ee=n(611),et=n(392);function en(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function er(e,t,n,r,o,l,a){try{var i=e[l](a),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}function eo(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return en(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return en(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var el=(0,d.observer)(function(){var e=(0,d.useForm)(),t=(0,Q.useProviderSettingsForm)(e.values.provider);return t?o().createElement(t,null):null},{displayName:"ModalSettings"}),ea=function(){return{form:(0,r.useMemo)(function(){return(0,Z.createForm)({initialValues:{name:"v_".concat((0,y.uid)())}})},[])}},ei=function(){var e=(0,a.useActionContext)().setVisible;return{type:"default",onClick:function(){e(!1)}}},eu={type:"void",properties:{form:{type:"void","x-decorator":"FormV2","x-use-decorator-props":"useCreateFormProps",properties:{provider:{type:"string","x-decorator":"FormItem",title:'{{ t("Provider") }}',"x-component":"ProviderSelect",required:!0},title:{type:"string","x-decorator":"FormItem",title:'{{ t("Title") }}',"x-component":"Input","x-reactions":{dependencies:["provider"],when:"{{!$self.modified}}",fulfill:{state:{value:"{{$getProviderLabel($deps[0])}}"},schema:{"x-visible":"{{!!$deps[0]}}"}}}},options:{type:"object","x-component":"ModalSettings","x-reactions":{dependencies:["provider"],fulfill:{schema:{"x-visible":"{{!!$deps[0]}}"}}}},"options.baseURL":{type:"string","x-decorator":"FormItem",title:'{{ t("Base URL") }}',"x-component":"Input","x-component-props":{placeholder:'{{ t("Base URL is optional, leave blank to use default (recommended)") }}'},"x-reactions":{dependencies:["provider"],fulfill:{schema:{"x-visible":"{{!!$deps[0]}}"}}}},enabledModels:{type:"object","x-decorator":"FormItem",title:'{{ t("Enabled Models") }}',"x-component":"EnabledModelsSelect","x-reactions":{dependencies:["provider"],fulfill:{schema:{"x-visible":"{{!!$deps[0]}}"}}}},footer:{type:"void","x-component":"Space","x-component-props":{style:{display:"flex",justifyContent:"flex-end"}},properties:{testFlight:{type:"void","x-component":"LLMTestFlight","x-reactions":{dependencies:["provider"],fulfill:{schema:{"x-visible":"{{!!$deps[0]}}"}}}},cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useModalCreateActionProps"}}}}}}},ec=function(e){var t=e.open,n=e.onClose,l=e.onSuccess,i=(0,m.NT)(),u=(0,a.useAPIClient)(),s=eo((0,r.useState)([]),2),f=s[0],p=s[1],y=eo((0,r.useState)(0),2),v=y[0],b=y[1];return(0,a.useRequest)(function(){return u.resource("ai").listLLMProviders().then(function(e){var t;return((null==e||null==(t=e.data)?void 0:t.data)||[]).map(function(e){return{key:e.name,label:d.Schema.compile(e.title||e.name,{t:i}),value:e.name,supportedModel:e.supportedModel}})})},{onSuccess:function(e){p(e)}}),o().createElement(J.Y1.Provider,{value:{providers:f}},o().createElement(a.ActionContextProvider,{value:{visible:t,setVisible:function(e){e||(n(),b(function(e){return e+1}))}}},o().createElement(c.Modal,{title:i("Add LLM service"),open:t,onCancel:n,footer:null,destroyOnClose:!0,width:600},o().createElement(a.SchemaComponent,{key:v,schema:eu,components:{ProviderSelect:Q.ProviderSelect,ModalSettings:el,LLMTestFlight:ee.w,EnabledModelsSelect:et.YX},scope:{useCreateFormProps:ea,useCancelActionProps:ei,useModalCreateActionProps:function(){var e=(0,a.useActionContext)().setVisible,t=c.App.useApp().message,n=(0,d.useForm)(),r=(0,a.useAPIClient)(),o=(0,m.NT)();return{type:"primary",onClick:function(){var a;return(a=function(){var a;return function(e,t){var n,r,o,l,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return l={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function i(l){return function(i){var u=[l,i];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(i){switch(i.label){case 0:return[4,n.submit()];case 1:return i.sent(),a=n.values,[4,r.resource("llmServices").create({values:a})];case 2:return i.sent(),t.success(o("Saved successfully")),e(!1),l(),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var o=a.apply(e,t);function l(e){er(o,n,r,l,i,"next",e)}function i(e){er(o,n,r,l,i,"throw",e)}l(void 0)})})()}}},$getProviderLabel:function(e){var t=f.find(function(t){return t.value===e});return(null==t?void 0:t.label)||e},providers:f}}))))},es=n(929);function ef(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ep(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ef(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ef(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var em=(0,Y.observer)(function(){var e=(0,m.NT)(),t=(0,a.useApp)(),n=(0,a.useAPIClient)(),l=(0,a.useToken)().token,i=c.App.useApp().message,u=ep((0,r.useState)(!1),2),f=u[0],p=u[1],d=O.h.use.currentEmployee(),y=null==d?void 0:d.username,v=O.h.use.model(),b=O.h.use.setModel(),h=t.pluginSettingsManager.has("ai.llm-services"),g=ep((0,r.useState)(!1),2),E=g[0],w=g[1],x=(0,X.j)(),S=x.repo,j=x.services,C=x.loading,k=x.allModelsWithLabel,P=x.allModels;(0,r.useEffect)(function(){if(y&&P.length){var e=(0,es.QU)(n,y,P,v);(0,es.ff)(e,v)||b(e)}},[n,y,P,v,b]);var A=(0,r.useMemo)(function(){return(0,es.Pu)(v,P)?v:P.length?{llmService:P[0].llmService,model:P[0].model}:void 0},[v,P]),T=(0,r.useMemo)(function(){if(A){var e=k.find(function(e){return e.llmService===A.llmService&&e.model===A.model});return(null==e?void 0:e.label)||A.model}},[A,k]),I=function(e,t){var r=k.find(function(n){return n.llmService===e&&n.value===t});if(r&&(b({llmService:r.llmService,model:r.model}),d))try{null==n||n.storage.setItem(es.kX+d.username,"".concat(r.llmService,":").concat(r.model))}catch(e){console.log(e)}};if(!d)return null;if(C&&!j.length)return o().createElement(c.Spin,{size:"small"});var z=P.length>0,M=[];j.forEach(function(e,t){t>0&&M.push({type:"divider",key:"divider-".concat(t)}),M.push({key:"group-".concat(e.llmService),label:o().createElement(c.Typography.Text,{type:"secondary",style:{fontSize:12}},e.llmServiceTitle),disabled:!0,style:{cursor:"default",padding:"4px 12px",height:"auto",minHeight:0}}),e.enabledModels.forEach(function(t){var n=A&&A.llmService===e.llmService&&A.model===t.value;M.push({key:"".concat(e.llmService,":").concat(t.value),label:o().createElement("span",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8}},o().createElement("span",null,t.label),n&&o().createElement(s.CheckOutlined,{style:{fontSize:12,color:l.colorPrimary}})),onClick:function(){return I(e.llmService,t.value)}})})}),z||M.push({key:"empty-placeholder",label:o().createElement(c.Typography.Text,{type:"secondary",style:{fontSize:12}},e("No LLM services enabled yet")),disabled:!0,style:{cursor:"default",padding:"16px 12px",height:"auto",minHeight:0}}),M.length>0&&M.push({type:"divider",key:"divider-add"}),M.push({key:"add-model",icon:o().createElement(s.PlusOutlined,null),label:e("Add LLM service"),onClick:function(){h?w(!0):i.warning(e("Please contact the administrator to configure models"))}});var D=o().createElement("span",{onClick:function(e){e.stopPropagation()},style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:12,backgroundColor:l.colorFillTertiary,borderRadius:6,height:28,padding:"0 8px",cursor:"pointer",minWidth:z?"auto":void 0,userSelect:"none"}},o().createElement("span",{style:{color:z?l.colorText:l.colorError,display:"inline-block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:88}},z?T:e("No model available")),o().createElement(s.DownOutlined,{style:{fontSize:10,color:z?l.colorTextSecondary:l.colorError}}));return o().createElement(o().Fragment,null,o().createElement(c.Dropdown,{menu:{items:M,style:{maxHeight:400,overflow:"auto"}},trigger:["hover"],open:f,onOpenChange:p,overlayStyle:{zIndex:1200}},D),h&&o().createElement(ec,{open:E,onClose:function(){return w(!1)},onSuccess:function(){return S.refresh()}}))},{displayName:"ModelSwitcher"}),ed=n(7437),ey=n(7097);function ev(){var e,t,n=(e=["\n .ant-attachment-list-card .ant-image img {\n height: 60px;\n width: 60px;\n object-fit: cover;\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return ev=function(){return n},n}n(8456);var eb=function(){var e=h.h.use.attachments(),t=h.h.use.removeAttachment(),n=(0,r.useMemo)(function(){return null==e?void 0:e.map(function(e){var t;return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({uid:e.uid||e.filename,name:e.filename||e.name,status:null!=(t=e.status)?t:"done",url:e.url,size:e.size,thumbUrl:e.preview},e)})},[e]);if(!(null==n?void 0:n.length))return null;var l=(0,p.css)(ev());return o().createElement("div",{className:l,style:{display:"flex",flexWrap:"wrap",gap:8,marginTop:4}},n.map(function(e){return o().createElement(R.Z.FileCard,{key:e.uid,item:e,onRemove:function(e){return t(e.name)}})}))},eh=n(8495);function eg(){var e,t,n=(e=["\n display: flex;\n justify-content: flex-start;\n flex-wrap: wrap;\n gap: 2px 0;\n margin-top: 4px;\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return eg=function(){return n},n}var eE=function(){var e=h.h.use.contextItems(),t=h.h.use.removeContextItem();return(null==e?void 0:e.length)?o().createElement("div",{className:(0,p.css)(eg())},e.map(function(e){return o().createElement(eh.P,{within:"sender",key:"".concat(e.type,":").concat(e.uid),item:e,closable:!0,onRemove:t})})):null},eO=function(){var e=(0,m.NT)(),t=(0,a.useToken)().token,n=O.h.use.setSenderValue(),r=b.U.use.currentConversation(),l=h.h.use.setMessages(),i=(0,g.z)(),u=i.messagesService,f=i.finishEditingMessage;return o().createElement(c.Alert,{style:{background:t.colorBgContainer,borderColor:t.colorBorderSecondary,color:t.colorText},icon:o().createElement(s.EditOutlined,{style:{color:t.colorText}}),message:e("Editing message for AI employee"),type:"info",showIcon:!0,closable:!0,onClose:function(){f(),n(""),l([]),u.run(r)}})};function ew(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var ex=function(){var e,t=(0,m.NT)(),n=(e=(0,r.useState)(!1),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,2)||function(e,t){if(e){if("string"==typeof e)return ew(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ew(e,t)}}(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),l=n[0],i=n[1],u=(0,w.S)().aiEmployees,f=O.h.use.currentEmployee(),p=(0,E.W)().switchAIEmployee,d=(0,a.useToken)().token,y=(0,r.useMemo)(function(){return u.length?u.map(function(e){var t=(null==f?void 0:f.username)===e.username;return{key:e.username,label:o().createElement("span",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8}},o().createElement(ed.B,{aiEmployee:e}),t&&o().createElement(s.CheckOutlined,{style:{fontSize:12,color:d.colorPrimary}})),onClick:function(){return p(e)}}}):[{key:"empty",label:o().createElement("span",{style:{fontSize:12,color:d.colorTextSecondary}},t("Please choose an AI employee")),disabled:!0,style:{cursor:"default",padding:"16px 12px",height:"auto",minHeight:0}}]},[u,null==f?void 0:f.username,p,t,d.colorPrimary,d.colorTextSecondary]),v=u.length>0,b=f?f.nickname:"".concat(t("Select an")," ").concat(t("AI employee")),h=o().createElement("span",{onClick:function(e){return e.stopPropagation()},style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:12,backgroundColor:d.colorFillTertiary,borderRadius:6,height:28,padding:"0 8px",cursor:"pointer",userSelect:"none"}},f?o().createElement(c.Avatar,{shape:"circle",size:20,src:(0,ey.a)(f.avatar)}):null,o().createElement("span",{style:{color:v?d.colorText:d.colorError,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:160}},b),o().createElement(s.DownOutlined,{style:{fontSize:10,color:v?d.colorTextSecondary:d.colorError}}));return o().createElement(c.Dropdown,{menu:{items:y,style:{maxHeight:400,overflow:"auto"}},trigger:["hover"],open:l,onOpenChange:i,overlayStyle:{zIndex:1200}},h)},eS=function(e){var t,n,l=e.components,a=e.handleSubmit,i=l.SendButton,u=l.LoadingButton,s=(0,r.useRef)(null),f=null==(t=(n=O.h.use).currentEmployee)?void 0:t.call(n),p=h.h.use.responseLoading(),m=h.h.use.addContextItems(),d=h.h.use.removeContextItem(),y=O.h.use.senderValue(),v=h.h.use.contextItems(),b=O.h.use.senderRef();return(0,r.useEffect)(function(){var e;(null==b||null==(e=b.current)?void 0:e.nativeElement)&&(b.current.nativeElement.onkeydown=function(e){if("Enter"===e.key&&!e.shiftKey&&(e.preventDefault(),V().isEmpty(y)&&v.length)){var t;null==(t=s.current)||t.click()}})},[b,y,v]),o().createElement(c.Flex,{justify:"space-between",align:"center"},o().createElement(c.Flex,{gap:"middle",align:"center"},o().createElement(W.u,{onAdd:m,onRemove:d,disabled:!f,ignore:function(e){return"flow-model.variable"===e}}),o().createElement($,null),o().createElement(K,null),o().createElement(ex,null),o().createElement(em,null)),o().createElement(c.Flex,{align:"center",gap:"middle"},p?o().createElement(u,{type:"default"}):o().createElement(i,{ref:s,type:"primary",disabled:!1,onClick:function(){V().isEmpty(y)&&v.length&&a("")}})))},ej=function(){var e=O.h.use.currentEmployee(),t=O.h.use.isEditingMessage(),n=h.h.use.contextItems(),r=h.h.use.attachments(),l=!!(null==n?void 0:n.length),a=!!(null==r?void 0:r.length);return t||e&&(l||a)?o().createElement("div",{style:{padding:"8px 8px 0 8px"}},t?o().createElement("div",null,o().createElement(eO,null)):null,e?o().createElement(eE,null):null,e?o().createElement(eb,null):null):null};function eC(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ek(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function eP(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function eA(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,t)||eT(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eT(e,t){if(e){if("string"==typeof e)return eC(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eC(e,t)}}function eI(){var e,t,n=(e=["\n .ant-sender-content {\n padding: 16px;\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return eI=function(){return n},n}var ez=function(){var e=O.h.use.currentEmployee(),t=O.h.use.isEditingMessage(),n=O.h.use.editingMessageId(),r=b.U.use.currentConversation(),o=b.U.use.webSearch(),l=h.h.use.attachments(),a=h.h.use.contextItems(),i=h.h.use.systemMessage(),u=h.h.use.skillSettings(),c=(0,g.z)().finishEditingMessage,s=(0,E.W)().send;return[function(f){s({sessionId:r,aiEmployee:e,systemMessage:i,messages:[{type:"text",content:f}],attachments:l.filter(function(e){return"done"===e.status}),workContext:a,editingMessageId:t?n:void 0,skillSettings:u,webSearch:o}),t&&c()}]},eM=function(){var e=(0,m.NT)(),t=(0,p.css)(eI()),n=eA(ez(),1)[0],l=(0,r.useRef)(null),a=O.h.use.senderValue(),i=O.h.use.setSenderValue(),u=O.h.use.currentEmployee(),c=O.h.use.setSenderRef(),s=h.h.use.setAttachments(),f=_(),d=h.h.use.responseLoading(),y=(0,g.z)().cancelRequest,v=eA((0,r.useState)(a),2),b=v[0],E=v[1];return(0,r.useEffect)(function(){c(l)},[]),(0,r.useEffect)(function(){b!==a&&i(b)},[b]),(0,r.useEffect)(function(){E(a)},[a]),o().createElement("div",{style:{margin:"8px 16px"}},o().createElement(N.Z,{className:t,value:b,ref:l,onChange:function(e){E(e)},onPaste:function(e){for(var t=e.clipboardData.items,n=null,r=0;r<t.length;r++)if("file"===t[r].kind){n=t[r].getAsFile();break}if(n){e.preventDefault();var o=Date.now().toString(),l=n,a={uid:o,name:l.name,status:"uploading",originFileObj:l,percent:0,type:l.type,size:l.size};s(function(e){return((function(e){if(Array.isArray(e))return eC(e)})(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||eT(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat([a])});var i=f.customRequest,u=f.data,c=f.headers,p=f.action;i&&i({file:l,filename:"file",data:u,headers:c,action:p,onProgress:function(e){var t=e.percent;s(function(e){return e.map(function(e){return e.uid===o?eP(ek({},e),{percent:t}):e})})},onSuccess:function(e,t){var n=null==e?void 0:e.data;s(function(t){return t.map(function(t){return t.uid===o?eP(ek(eP(ek({},t),{status:"done",response:e}),n),{url:(null==n?void 0:n.url)||t.url}):t})})},onError:function(e){s(function(t){return t.map(function(t){return t.uid===o?eP(ek({},t),{status:"error",error:e}):t})})}})}},onSubmit:n,onCancel:y,header:o().createElement(ej,null),loading:d,footer:function(e){var t=e.components;return o().createElement(eS,{components:t,handleSubmit:n})},disabled:!u,placeholder:e("Enter your question"),actions:!1,autoSize:{minRows:2,maxRows:8}}))};function eD(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eB(e,t,n,r,o,l,a){try{var i=e[l](a),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}function eN(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function eR(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function eF(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return eD(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eD(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var eL=function(){var e,t,n,l=(0,m.NT)(),i=(0,a.useToken)().token,u=(0,a.useMobileLayout)().isMobileLayout,f=c.App.useApp().message,p=(0,a.useAPIClient)(),d=O.h.use.currentEmployee(),y=O.h.use.setCurrentEmployee(),v=(0,w.S)().refresh,b=eF((0,r.useState)(!1),2),h=b[0],g=b[1],E=eF((0,r.useState)(!1),2),x=E[0],S=E[1],j=eF((0,r.useState)(!1),2),C=j[0],k=j[1],P=eF((0,r.useState)(""),2),A=P[0],T=P[1],I=u?x:h;(0,r.useEffect)(function(){if(I){var e,t;T(null!=(t=null==d||null==(e=d.userConfig)?void 0:e.prompt)?t:"")}},[I,null==d||null==(n=d.userConfig)?void 0:n.prompt]);var z=function(){if(u)return void S(!1);g(!1)},M=(e=function(){var e;return function(e,t){var n,r,o,l,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return l={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function i(l){return function(i){var u=[l,i];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(t){switch(t.label){case 0:if(!d)return[2];k(!0),t.label=1;case 1:return t.trys.push([1,4,5,6]),[4,p.resource("aiEmployees").updateUserPrompt({values:{aiEmployee:d.username,prompt:A}})];case 2:return t.sent(),[4,v()];case 3:return t.sent(),y(function(e){return eR(eN({},e),{userConfig:eR(eN({},e.userConfig),{prompt:A})})}),f.success(l("Saved successfully")),z(),[3,6];case 4:return e=t.sent(),f.error((null==e?void 0:e.message)||l("Request failed")),[3,6];case 5:return k(!1),[7];case 6:return[2]}})},t=function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function a(e){eB(l,r,o,a,i,"next",e)}function i(e){eB(l,r,o,a,i,"throw",e)}a(void 0)})},function(){return t.apply(this,arguments)}),D=o().createElement(c.Card,{variant:"borderless",size:"small",styles:{body:{width:u?"auto":"420px",maxWidth:"calc(100vw - 32px)",padding:"16px"}}},o().createElement(c.Typography.Title,{level:5,style:{margin:0,marginBottom:12,fontSize:i.fontSizeLG,fontWeight:500}},l("Personalized prompt")),o().createElement(c.Typography.Paragraph,{style:{marginBottom:12,color:i.colorTextSecondary}},l("Personalized prompt description")),o().createElement(c.Input.TextArea,{value:A,onChange:function(e){return T(e.target.value)},autoSize:{minRows:4,maxRows:8},placeholder:l("Personalized prompt")}),o().createElement("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:12}},o().createElement(c.Space,null,o().createElement(c.Button,{onClick:z},l("Cancel")),o().createElement(c.Button,{type:"primary",loading:C,onClick:M},l("Submit")))));return o().createElement(o().Fragment,null,u?o().createElement(c.Tooltip,{arrow:!1,title:l("Personalized prompt")},o().createElement(c.Button,{icon:o().createElement(s.InfoCircleOutlined,null),type:"text",onClick:function(){return S(!0)}})):o().createElement(c.Tooltip,{arrow:!1,title:l("Personalized prompt")},o().createElement(c.Popover,{zIndex:1101,placement:"bottomRight",open:h,onOpenChange:g,trigger:"click",styles:{body:{padding:0,marginRight:"8px"}},arrow:!1,content:D},o().createElement(c.Button,{icon:o().createElement(s.InfoCircleOutlined,null),type:"text"}))),o().createElement(c.Modal,{open:u&&x,onCancel:z,footer:null,centered:!0,width:"calc(100vw - 32px)",styles:{body:{padding:0}},destroyOnClose:!0},D))},eU=n(9557),e_=n(1863);function eH(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function e$(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function eW(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function eq(e){return function(e){if(Array.isArray(e))return eH(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||eV(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eV(e,t){if(e){if("string"==typeof e)return eH(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eH(e,t)}}function eY(){var e,t,n=(e=["\n width: 350px;\n margin-bottom: -1em;\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return eY=function(){return n},n}var eX=c.Layout.Header,eG=c.Layout.Content,eK=c.Typography.Title,eZ=function(){var e=(0,m.NT)(),t=(0,a.useToken)().token,n=O.h.use.setShowCodeHistory();return o().createElement(c.Layout,{style:{padding:"0 16px 16px",height:"100%"}},o().createElement(eX,{style:{backgroundColor:t.colorBgContainer,height:"48px",lineHeight:"48px",padding:0,borderBottom:"1px solid ".concat(t.colorBorder)}},o().createElement(c.Flex,{style:{height:"100%"},justify:"flex-start",align:"center",gap:"middle"},o().createElement(c.Button,{icon:o().createElement(s.LeftOutlined,null),type:"text",onClick:function(){n(!1)}}),o().createElement(eK,{level:5,style:{margin:0}},e("Code history")))),o().createElement(eG,null,o().createElement(eJ,null)))},eJ=function(){var e,t="javascript",n="code-editor",l=O.h.use.currentEmployee(),a=h.h.use.messages(),i=(e=(0,r.useState)([]),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,2)||eV(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),u=i[0],s=i[1];return(0,r.useEffect)(function(){if(l&&(null==a?void 0:a.length)){var e=RegExp("```"+t+"([\\s\\S]*?)```","s"),r=a.filter(function(e){return"user"===e.role}).filter(function(e){var t,n;return(null==(n=e.content)||null==(t=n.workContext)?void 0:t.length)!==0}).filter(function(e){return e.content.workContext.some(function(e){return e.type===n})}).flatMap(function(e){return e.content.workContext.map(function(t){return{message:e,workContext:t}})}).filter(function(e){return e.workContext.type===n}),o=a.filter(function(e){return e.role===l.username}).filter(function(e){var t;return(null==(t=e.content)?void 0:t.type)==="text"}).filter(function(t){return e.test(t.content.content)}).map(function(r){var o=e.exec(r.content.content);return{message:r,workContext:{type:n,uid:r.key,content:{language:t,code:o[1]}}}}),i=eq(r).concat(eq(o));i.sort(function(e,t){return Number(e.message.key)-Number(t.message.key)}),s(i)}},[a,l]),o().createElement(c.List,{style:{height:"100%",overflowY:"auto"},dataSource:u,renderItem:function(e,t){return o().createElement(c.List.Item,{key:t},o().createElement(eQ,e))}})},eQ=function(e){var t=e.message,n=e.workContext,r=O.h.use.currentEmployee(),l=n.content,i={size:33,shape:"circle",style:{border:"1px solid #eee"}};return o().createElement(c.Flex,{justify:"space-around",style:{width:"100%"}},"user"===t.role?o().createElement(c.Avatar,eW(e$({},i),{icon:o().createElement(s.UserOutlined,null)})):o().createElement(c.Avatar,eW(e$({},i),{src:(0,ey.a)(r.avatar)})),o().createElement("div",{className:(0,a.css)(eY())},o().createElement(e_.un,{className:"language-".concat(l.language)},l.code)))},e0=n(8003);function e1(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var e2=c.Layout.Header,e8=c.Layout.Footer,e3=c.Layout.Sider,e4=c.Typography.Text,e5=function(){var e=(0,r.useRef)(null),t=O.h.use.setChatBoxRef(),n=O.h.use.setOpen(),l=O.h.use.currentEmployee(),i=O.h.use.expanded(),u=O.h.use.setExpanded(),f=O.h.use.setMinimize(),p=O.h.use.showConversations(),d=O.h.use.setShowConversations(),y=O.h.use.setShowCodeHistory(),v=O.h.use.showDebugPanel(),b=O.h.use.setShowDebugPanel(),h=(0,E.W)().startNewConversation,g=(0,a.useToken)().token,w=(0,m.NT)();(0,r.useEffect)(function(){t(e)},[]);var x=(0,a.useMobileLayout)().isMobileLayout;return o().createElement(c.Layout,{style:{height:"100%",position:"relative"},ref:e},p&&!i&&o().createElement(o().Fragment,null,o().createElement("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:10,cursor:"pointer"},onClick:function(){return d(!1)}}),o().createElement("div",{style:{position:"absolute",top:0,left:0,width:"300px",height:"100%",backgroundColor:g.colorBgContainer,zIndex:11,borderRight:"1px solid ".concat(g.colorBorder),overflow:"hidden"}},o().createElement(T,null))),p&&i&&o().createElement(e3,{width:300,style:{backgroundColor:g.colorBgContainer,borderRight:"1px solid ".concat(g.colorBorder),overflow:"hidden"}},o().createElement(T,null)),o().createElement(c.Layout,null,o().createElement(e2,{style:{backgroundColor:g.colorBgContainer,height:"48px",lineHeight:"48px",padding:"0 16px",borderBottom:"1px solid ".concat(g.colorBorder),display:"flex",alignItems:"center",justifyContent:"space-between"}},o().createElement("div",null,o().createElement(c.Button,{icon:p?o().createElement(s.MenuFoldOutlined,null):o().createElement(s.MenuUnfoldOutlined,null),type:"text",onClick:function(e){e.stopPropagation(),d(!p)}})),o().createElement("div",null,l?o().createElement(o().Fragment,null,o().createElement(c.Tooltip,{arrow:!1,title:w("New conversation")},o().createElement(c.Button,{icon:o().createElement(s.PlusCircleOutlined,null),type:"text",onClick:h})),o().createElement(eL,null),(0,e0.pN)(l)&&o().createElement(c.Tooltip,{arrow:!1,title:w("Code history")},o().createElement(c.Button,{icon:o().createElement(s.CodeOutlined,null),type:"text",onClick:function(){y(!0)}})),!i&&o().createElement(c.Tooltip,{arrow:!1,title:w("Debug Panel")},o().createElement(c.Button,{icon:o().createElement(s.BugOutlined,null),type:"text",onClick:function(){return b(!v)}})),o().createElement(c.Divider,{type:"vertical"})):null,x?o().createElement(c.Button,{icon:o().createElement(s.CompressOutlined,null),type:"text",onClick:function(){f(!0)}}):o().createElement(c.Button,{icon:i?o().createElement(s.FullscreenExitOutlined,null):o().createElement(s.FullscreenOutlined,null),type:"text",onClick:function(){i||b(!1),u(!i)}}),o().createElement(c.Tooltip,{arrow:!1,title:w("Collapse panel")},o().createElement(c.Button,{icon:o().createElement(s.CloseOutlined,null),type:"text",onClick:function(){return n(!1)}})))),o().createElement(B,null),o().createElement(e8,{style:{backgroundColor:g.colorBgContainer,padding:0}},o().createElement(eM,null),o().createElement("div",{style:{textAlign:"center",margin:"10px 0",fontSize:g.fontSizeSM,color:g.colorTextTertiary}},w("AI disclaimer")))))},e6=(0,Y.observer)(function(){return o().createElement(c.Card,{style:{position:"fixed",transform:"translate(-50%, -50%)",left:"50%",top:"50%",width:"95%",height:"95%",zIndex:eU.t.shouldHide?-1:1100},styles:{body:{height:"100%",padding:0}}},o().createElement(e5,null))}),e7=(0,Y.observer)(function(e){var t=e.minimize;return o().createElement("div",{style:{position:"fixed",left:"0",top:"0",width:"100%",height:"100%",zIndex:eU.t.shouldHide?-1:1100,backgroundColor:"white",display:t?"none":"block"}},o().createElement(e5,null),o().createElement(e9,null))}),e9=function(){var e,t=O.h.use.currentEmployee(),n=O.h.use.minimize(),l=O.h.use.setMinimize(),a=O.h.use.setOpen(),i=(0,m.NT)(),u=(e=c.notification.useNotification(),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,2)||function(e,t){if(e){if("string"==typeof e)return e1(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e1(e,t)}}(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),f=u[0],p=u[1],d=(0,r.useRef)("ai-chat-box-minimize--control-".concat(new Date().getTime())),y=null==t?void 0:t.avatar;return(0,r.useEffect)(function(){return!0===n&&y?f.open({key:d.current,closeIcon:!1,message:o().createElement(c.Flex,{justify:"space-between",align:"center"},o().createElement(c.Avatar,{shape:"circle",size:35,src:(0,ey.a)(y)}),o().createElement(e4,{ellipsis:!0},i("Conversation")),o().createElement(c.Button,{type:"text",icon:o().createElement(s.CloseOutlined,null),onClick:function(e){e.stopPropagation(),a(!1),l(!1)}})),duration:0,placement:"top",style:{width:200},onClick:function(){l(!1)}}):f.destroy(d.current),function(){f.destroy(d.current)}},[f,y,n,l,a,i]),o().createElement(o().Fragment,null,p)},te=function(){var e=O.h.use.expanded(),t=O.h.use.minimize(),n=O.h.use.showCodeHistory();return(0,a.useMobileLayout)().isMobileLayout?o().createElement(e7,{minimize:t}):e?o().createElement(e6,null):o().createElement("div",{style:{position:"fixed",transform:"translateX(0px) !important",right:"-450px",zIndex:1,top:0,width:"450px",height:"100vh",overflow:"hidden",borderInlineStart:"1px solid rgba(5, 5, 5, 0.06)"}},n?o().createElement(eZ,null):o().createElement(e5,null))},tt=n(1272),tn=n.p+"f0053e745af0ad03.svg";function tr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function to(){var e,t,n=(e=["\n z-index: 1050;\n position: fixed;\n bottom: 42px;\n inset-inline-end: -8px;\n padding: 9px 22px 9px 10px;\n border-radius: 31px 0 0 31px;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n\n opacity: 0.7;\n background: ",";\n box-shadow: ",";\n transform: translateX(0);\n will-change: transform;\n transition:\n transform 0.6s cubic-bezier(0.22, 1, 0.36, 1),\n opacity 0.2s ease;\n &:hover {\n opacity: 1;\n transform: translateX(-8px);\n }\n\n ","\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return to=function(){return n},n}var tl=(0,Y.observer)(function(){var e,t,n=(0,Y.useFlowContext)(),l=(0,a.useMobileLayout)().isMobileLayout,i=(null==n||null==(t=n.pageInfo)?void 0:t.version)==="v1",u=(0,a.useToken)().token,s=(0,w.S)().aiEmployees,f=(e=(0,r.useState)(!1),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,2)||function(e,t){if(e){if("string"==typeof e)return tr(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return tr(e,t)}}(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),m=f[0],d=f[1],y=O.h.use.open(),v=O.h.use.setOpen();O.h.use.currentEmployee();var h=(0,E.W)().switchAIEmployee,g=b.U.use.setWebSearch(),x=(0,r.useMemo)(function(){return null==s?void 0:s.filter(function(e){return!(0,e0.D1)(e)}).map(function(e){return{key:e.username,label:o().createElement(ed.B,{aiEmployee:e,onClick:function(){g(!0),v(!0),h(e)}})}})},[s]);if(y||!(null==s?void 0:s.length)||i)return null;var S=u.boxShadowSecondary||u.boxShadow;return!l&&o().createElement(c.Dropdown,{menu:{items:x},placement:"topRight",trigger:["hover"],align:{offset:[-16,-6]},open:m,onOpenChange:function(e){return d(e)}},o().createElement("div",{onClick:function(){d(!1),v(!0)},className:(0,p.css)(to(),u.colorBgElevated,S,m?"\n opacity: 1;\n transform: translateX(-8px);\n ":"")},o().createElement(c.Avatar,{src:tn,size:42,shape:"square"})))}),ta=n(4822);function ti(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){ti(e,t,n[t])})}return e}var tc=function(){var e=(0,w.S)().aiEmployees,t=O.h.use.open(),n=O.h.use.senderRef(),o=O.h.use.currentEmployee(),l=O.h.use.setRoles(),i=(0,v.D)().conversationsService,u=(0,a.useTools)().refresh;(0,r.useEffect)(function(){if(!e)return void l(function(e){return tu({},e,ta.O)});var t=e.reduce(function(e,t){var n,r;return n=tu({},e),r=null!=(r=ti({},t.username,(0,ta.D)(t)))?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n},{});l(function(e){return tu({},e,ta.O,t)})},[e]),(0,r.useEffect)(function(){var e;null==n||null==(e=n.current)||e.focus()},[o]),(0,r.useEffect)(function(){if(t){var e;i.run(),null==n||null==(e=n.current)||e.focus(),u()}},[t]),(0,r.useEffect)(function(){o&&t&&i.run()},[null==o?void 0:o.username])},ts=n(5451);function tf(e,t,n,r,o,l,a){try{var i=e[l](a),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}function tp(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function a(e){tf(l,r,o,a,i,"next",e)}function i(e){tf(l,r,o,a,i,"throw",e)}a(void 0)})}}function tm(e,t){var n,r,o,l,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return l={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function i(l){return function(i){var u=[l,i];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var td=function(e){return{onOk:tp(function(){return tm(this,function(e){return[2]})})}},ty=function(){var e,t,n,l,i=(0,m.NT)(),u=(0,a.useTools)().tools,s=(0,a.toToolsMap)(u),f=z.Y.use.openToolModal(),p=z.Y.use.setOpenToolModal(),y=z.Y.use.activeTool(),v=z.Y.use.setActiveTool(),h=z.Y.use.activeMessageId(),E=z.Y.use.setActiveMessageId(),O=z.Y.use.toolsByName(),w=b.U.use.currentConversation(),x=(0,g.z)(),S=x.updateToolArgs,j=x.messagesService,C=s.get(null==y?void 0:y.name),k=null==C||null==(t=C.ui)?void 0:t.modal,P=(null==C||null==(l=C.ui)||null==(n=l.modal)?void 0:n.useOnOk)||td,A=null==k?void 0:k.Component,T=z.Y.use.adjustArgs(),I=P((0,(0,ts.e)({messageId:h}).getDecisionActions)(y),T).onOk,M=O[null==y?void 0:y.name]||[],D=M.map(function(e,t){return{key:e.id,value:e.id,label:"Version ".concat(t+1)}}),B=(0,r.useCallback)((e=tp(function(e){return tm(this,function(t){switch(t.label){case 0:if(!y||!w||!h)return[2];return[4,S({sessionId:w,messageId:h,tool:{id:y.id,args:e}})];case 1:var n,r;return t.sent(),c.message.success(i("Saved successfully")),v((n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},y),r=r={args:e},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n)),[2]}})}),function(t){return e.apply(this,arguments)}),[j,h,y,w,S]);return o().createElement(c.Modal,{title:o().createElement(o().Fragment,null,(null==k?void 0:k.title)?d.Schema.compile(k.title,{t:i}):"",D.length>1&&o().createElement(c.Select,{options:D,value:null==y?void 0:y.id,style:{marginLeft:"8px"},onChange:function(e){var t=M.find(function(t){return t.id===e});E((null==t?void 0:t.messageId)||""),v(t)}})),open:f,width:"90%",onCancel:function(){p(!1),v(null)},okText:(null==k?void 0:k.okText)?d.Schema.compile(k.okText,{t:i}):i("Submit"),onOk:tp(function(){return tm(this,function(e){switch(e.label){case 0:return[4,null==I?void 0:I()];case 1:return e.sent(),p(!1),[2]}})}),okButtonProps:{disabled:!["init","interrupted","pending"].includes(y.invokeStatus)},footer:function(e,t){var n=t.OkBtn;return o().createElement(o().Fragment,null,o().createElement(n,null))}},A?o().createElement(A,{tool:y,saveToolArgs:B}):null)},tv=n(8087),tb=n(7271);function th(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var tg=(0,r.forwardRef)(function(e,t){var n,l=e.data,a=e.itemKey,i=e.itemHeight,u=e.children,c=(0,r.useRef)(null),s=(0,r.useRef)(null),f=(n=(0,r.useState)(400),function(e){if(Array.isArray(e))return e}(n)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(n,2)||function(e,t){if(e){if("string"==typeof e)return th(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return th(e,t)}}(n,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),p=f[0],m=f[1];return(0,r.useEffect)(function(){var e=c.current;if(e){var t=new ResizeObserver(function(e){var t=!0,n=!1,r=void 0;try{for(var o,l=e[Symbol.iterator]();!(t=(o=l.next()).done);t=!0){var a=o.value;m(a.contentRect.height)}}catch(e){n=!0,r=e}finally{try{t||null==l.return||l.return()}finally{if(n)throw r}}});return t.observe(e),m(e.clientHeight),function(){return t.disconnect()}}},[]),(0,r.useImperativeHandle)(t,function(){return{scrollTo:function(e){var t;null==(t=s.current)||t.scrollTo(e)}}}),o().createElement("div",{ref:c,style:{flex:1,overflow:"hidden"}},o().createElement(tb.Z,{ref:s,data:l,itemKey:a,height:p,itemHeight:void 0===i?48:i,fullHeight:!1},u))});function tE(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function tO(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,t)||tS(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tw(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function tx(e){return function(e){if(Array.isArray(e))return tE(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||tS(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tS(e,t){if(e){if("string"==typeof e)return tE(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return tE(e,t)}}function tj(){var e=tw(["\n padding: 8px 12px;\n border-bottom: 1px solid ",";\n &:hover {\n background-color: ",";\n }\n "]);return tj=function(){return e},e}function tC(){var e=tw(["\n display: flex;\n align-items: center;\n gap: 8px;\n cursor: pointer;\n "]);return tC=function(){return e},e}function tk(){var e=tw(["\n color: ",";\n "]);return tk=function(){return e},e}function tP(){var e=tw(["\n margin: 8px 0 0 18px;\n padding: 8px;\n background-color: ",";\n border-radius: 4px;\n font-size: 12px;\n overflow-x: auto;\n max-height: 300px;\n overflow-y: auto;\n "]);return tP=function(){return e},e}function tA(){var e=tw(["\n display: flex;\n flex-direction: column;\n height: 100%;\n "]);return tA=function(){return e},e}function tT(){var e=tw(["\n padding: 12px;\n border-bottom: 1px solid ",";\n display: flex;\n gap: 8px;\n "]);return tT=function(){return e},e}var tI=c.Typography.Text,tz=c.Input.Search,tM={request:"blue",stream_text:"green",stream_search:"cyan",stream_start:"geekblue",stream_tools:"orange",stream_delta:"lime",stream_error:"volcano",tool_call:"gold",tool_result:"purple",error:"red"},tD=[{value:"all",label:"All"},{value:"request",label:"Request"},{value:"stream_text",label:"Stream Text"},{value:"stream_search",label:"Stream Search"},{value:"stream_start",label:"Stream Start"},{value:"stream_tools",label:"Stream Tools"},{value:"stream_delta",label:"Stream Delta"},{value:"stream_error",label:"Stream Error"},{value:"tool_call",label:"Tool Call"},{value:"tool_result",label:"Tool Result"},{value:"error",label:"Error"}],tB=function(e){var t=e.log,n=e.expanded,r=e.onToggleExpand,l=(0,a.useToken)().token,i=function(){try{navigator.clipboard.writeText(JSON.stringify(t.data,null,2)),c.message.success("Copied to clipboard")}catch(e){c.message.error("Failed to copy")}};return o().createElement("div",{className:(0,p.css)(tj(),l.colorBorderSecondary,l.colorFillQuaternary)},o().createElement("div",{className:(0,p.css)(tC()),onClick:r},n?o().createElement(s.DownOutlined,{style:{fontSize:10}}):o().createElement(s.RightOutlined,{style:{fontSize:10}}),o().createElement(tI,{type:"secondary",style:{fontFamily:"monospace",fontSize:12}},new Date(t.time).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3})),o().createElement(c.Tag,{color:tM[t.type],style:{margin:0}},t.type),o().createElement(tI,{ellipsis:!0,style:{flex:1,fontFamily:"monospace",fontSize:12},className:(0,p.css)(tk(),l.colorTextSecondary)},function(e){try{var t=JSON.stringify(e);return t.length>100?t.slice(0,100)+"...":t}catch(e){return"[Unable to stringify]"}}(t.data)),o().createElement(c.Tooltip,{title:"Copy"},o().createElement(c.Button,{type:"text",size:"small",icon:o().createElement(s.CopyOutlined,null),onClick:function(e){e.stopPropagation(),i()}}))),n&&o().createElement("pre",{className:(0,p.css)(tP(),l.colorFillSecondary)},JSON.stringify(t.data,null,2)))},tN=function(){var e=O.h.use.showDebugPanel(),t=O.h.use.setShowDebugPanel(),n=b.U.use.currentConversation(),l=tO((0,r.useState)([]),2),i=l[0],u=l[1],f=tO((0,r.useState)("all"),2),d=f[0],y=f[1],v=tO((0,r.useState)(""),2),h=v[0],g=v[1],E=tO((0,r.useState)(new Set),2),w=E[0],x=E[1],S=(0,r.useRef)(null),j=(0,m.NT)(),C=(0,a.useToken)().token;(0,r.useEffect)(function(){if(!n)return void u([]);var e=tv._.getSession(n);return e?u(tx(e.logs)):u([]),tv._.subscribe(function(e,t){t===n&&u(function(t){return tx(t).concat([e])})})},[n]);var k=(0,r.useMemo)(function(){return i.filter(function(e){if("all"!==d&&e.type!==d)return!1;if(h){var t=h.toLowerCase();return JSON.stringify(e.data).toLowerCase().includes(t)}return!0})},[i,d,h]);(0,r.useEffect)(function(){k.length>0&&requestAnimationFrame(function(){var e;null==(e=S.current)||e.scrollTo({index:k.length-1,align:"bottom"})})},[i]);var P=(0,r.useCallback)(function(e){x(function(t){var n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),A=(0,r.useCallback)(function(e){return w.has(e.id)?"".concat(e.id,"-e"):e.id},[w]);return o().createElement(c.Drawer,{title:o().createElement(c.Space,null,o().createElement("span",null,j("Debug Panel")),n&&o().createElement(tI,{type:"secondary",style:{fontSize:12}},"(",i.length," logs)")),placement:"right",width:500,open:e,onClose:function(){return t(!1)},styles:{body:{padding:0,overflow:"hidden"}},extra:o().createElement(c.Button,{icon:o().createElement(s.DownloadOutlined,null),size:"small",onClick:function(){if(n&&0!==i.length){var e=tv._.getSession(n),t=new Blob([JSON.stringify({sessionId:n,employeeId:null==e?void 0:e.employeeId,employeeName:null==e?void 0:e.employeeName,exportedAt:new Date().toISOString(),logs:i},null,2)],{type:"application/json"}),r=URL.createObjectURL(t),o=document.createElement("a");o.href=r;var l=(null==e?void 0:e.employeeName)||"unknown";o.download="ai-chat-log-".concat(l,"-").concat(new Date().toISOString().slice(0,16).replace("T","_"),".json"),o.click(),URL.revokeObjectURL(r)}},disabled:0===i.length},j("Export"))},o().createElement("div",{className:(0,p.css)(tA())},o().createElement("div",{className:(0,p.css)(tT(),C.colorBorder)},o().createElement(c.Select,{value:d,onChange:y,options:tD,style:{width:120},size:"small"}),o().createElement(tz,{placeholder:j("Search logs..."),value:h,onChange:function(e){return g(e.target.value)},allowClear:!0,size:"small",style:{flex:1}})),n?0===k.length?o().createElement(c.Empty,{description:j("No logs"),style:{marginTop:100}}):o().createElement(tg,{ref:S,data:k,itemKey:A,itemHeight:40},function(e){return o().createElement(tB,{log:e,expanded:w.has(e.id),onToggleExpand:function(){return P(e.id)}})}):o().createElement(c.Empty,{description:j("No conversation selected"),style:{marginTop:100}})))},tR=function(e){var t=O.h.use.open(),n=O.h.use.expanded(),r=z.Y.use.activeTool(),l=O.h.use.showDebugPanel(),i=(0,a.useMobileLayout)().isMobileLayout;return tc(),o().createElement(o().Fragment,null,e.children,o().createElement(tl,null),!t||n||i?null:o().createElement(tt.q,null,o().createElement("style",{type:"text/css"},"\nhtml {\n padding-left: 450px;\n}\nhtml body {\n position: relative;\n overflow: hidden;\n transform: translateX(-450px);\n}\n.ant-dropdown-placement-topLeft {\n transform: translateX(450px) !important;\n}\n.ant-dropdown-placement-bottomLeft {\n transform: translateX(450px) !important;\n}\n.ant-dropdown-menu-submenu-placement-rightTop {\n transform: translateX(450px) !important;\n}\n.ant-dropdown-menu-submenu-placement-rightBottom {\n transform: translateX(450px) !important;\n}\n")),t?o().createElement(te,null):null,r&&o().createElement(ty,null),l&&o().createElement(tN,null))},tF=n(9382),tL=(0,Y.observer)(function(){return tF.n.selectable&&o().createElement(tt.q,null,o().createElement("style",{type:"text/css"},"\n.ai-selectable {\n position: relative;\n transition: all 0.3s ease;\n &:hover {\n cursor: grab;\n }\n &::after {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 210, 255, 0.2);\n opacity: 0;\n transition: opacity 0.3s ease;\n z-index: 100;\n }\n\n &:hover::after {\n opacity: 1;\n }\n}\n"))});function tU(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var t_=(0,Y.observer)(function(){var e,t=(0,m.NT)(),n=c.theme.useToken().token,l=(e=c.notification.useNotification(),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,2)||function(e,t){if(e){if("string"==typeof e)return tU(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return tU(e,t)}}(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),a=l[0],i=l[1],u=(0,r.useRef)("ai-selection-control-".concat(new Date().getTime())),f=tF.n.selectable;return(0,r.useEffect)(function(){return""!==f?a.open({key:u.current,closeIcon:!1,message:o().createElement(c.Flex,{justify:"space-between",align:"center",style:{width:"100%"}},o().createElement("span",{style:{fontWeight:500,fontSize:13,color:n.colorTextSecondary,lineHeight:1.2}},t("Picking block")),o().createElement(c.Button,{type:"text",size:"small",icon:o().createElement(s.StopOutlined,null),style:{color:n.colorError,fontSize:13,lineHeight:1.2},"aria-label":t("Cancel"),onClick:function(){tF.n.stopSelect(),eU.t.resume()}})),duration:0,placement:"bottom",style:{width:180,padding:"7px 12px 5px 12px",background:n.colorBgContainer,border:"1px solid ".concat(n.colorBorder),boxShadow:n.boxShadowSecondary,borderRadius:6}}):a.destroy(u.current),function(){a.destroy(u.current)}},[a,f,t,n]),o().createElement(o().Fragment,null,i)}),tH=function(e){var t,n=(0,a.useApp)().aiManager.toolsManager,i=(0,r.useContext)(a.CurrentUserContext);return(null==i||null==(t=i.data)?void 0:t.data)?o().createElement(l.K$,null,o().createElement(u,null,o().createElement(a.ToolsProvider,{toolsManager:n},o().createElement(tR,null,e.children),o().createElement(tL,null),o().createElement(t_,null)))):o().createElement(o().Fragment,null,e.children)}},1863:function(e,t,n){n.d(t,{EK:function(){return k},un:function(){return C},ws:function(){return j}});var r=n(8156),o=n.n(r),l=n(2721),a=n(482),i=n(3772),u=n(3990),c=n(8003),s=n(2667),f=n(5708),p=n(3581);function m(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function d(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function y(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},l=Object.keys(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++)n=l[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var v=(0,i.lazy)(function(){return p("imported_1na2390_component",Promise.all([n.e("204"),n.e("124")]).then(n.bind(n,3770)))},"CodeHighlight").CodeHighlight,b=function(e){var t=e.language,n=e.value,r=e.height,l=e.scrollToBottom,a=y(e,["language","value","height","scrollToBottom"]);return o().createElement(v,d(m({},a),{language:t,value:n,height:r,scrollToBottom:l}))},h=function(e){var t=(0,s.useFlowContext)(),n=(0,u.NT)(),r=e.children,i=e.className,c=(e.node,e.message),p=y(e,["children","className","node","message"]),v=/language-(\w+)/.exec(i||""),h=v?v[1]:"",E=String(r).replace(/<!--[\s\S]*?-->/g,"").replace(/\n$/,""),O=l.App.useApp().message,w=!0;(null==c?void 0:c.type)==="text"&&(w=RegExp("```"+h+"[\\s\\S]*?```","s").test(c.content));var x=f.h.use.editorRef()[f.h.use.currentEditorRefUid()];return v?o().createElement(l.Card,{type:"inner",size:"small",title:o().createElement(l.Space,{style:{margin:"0 8px"},size:"middle"},o().createElement(a.CodeOutlined,null),o().createElement("span",null,h)),extra:o().createElement(o().Fragment,null,o().createElement(l.Tooltip,{title:n("Copy")},o().createElement(l.Button,{type:"text",icon:o().createElement(a.CopyOutlined,null),onClick:function(){navigator.clipboard.writeText(E),O.success(n("Copied"))}})),o().createElement(l.Divider,{type:"vertical"}),o().createElement(l.Tooltip,{title:n("Expand")},o().createElement(l.Button,{type:"text",icon:o().createElement(a.ExpandOutlined,null),onClick:function(){t.viewer.dialog({width:"80%",zIndex:6e3,content:o().createElement(g,d(m({},p),{language:h,value:E,height:"75vh"}))})}}))),styles:{header:{padding:0},body:{padding:0}},actions:x?[o().createElement(l.Button,{key:"accept",type:"link",onClick:function(e){e.stopPropagation(),null==x||x.write(E),t.message.info(n("Applied"))},disabled:!w},n("Apply to editor"))]:[]},o().createElement(b,d(m({},p),{language:h,value:E,scrollToBottom:!w}))):o().createElement(l.Typography.Text,d(m({code:!0},p),{className:i}),r)},g=function(e){var t=e.language,n=e.value,r=y(e,["language","value"]),i=(0,s.useFlowViewContext)(),u=i.view.Header,c=o().createElement(l.Button,{type:"text",icon:o().createElement(a.CloseOutlined,null),onClick:function(){i.view.close()}});return o().createElement("div",{style:{borderRadius:8}},o().createElement(u,{title:o().createElement(o().Fragment,null,o().createElement(l.Space,null,c,o().createElement("span",null,t)))}),o().createElement(b,d(m({},r),{language:t,value:n})))},E=n(3581);function O(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function w(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function x(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},l=Object.keys(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++)n=l[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var S=(0,i.lazy)(function(){return E("imported_1na2390_component",Promise.all([n.e("204"),n.e("124")]).then(n.bind(n,3770)))},"CodeHighlight").CodeHighlight,j=function(e){var t=e.language,n=e.value,r=x(e,["language","value"]);return o().createElement(S,w(O({},r),{language:t,value:n}))},C=function(e){var t=e.children,n=e.className,r=(e.node,e.message,x(e,["children","className","node","message"])),c=/language-(\w+)/.exec(n||""),s=c?c[1]:"",f=(0,i.useToken)().token,p=(0,u.NT)(),m=String(t).replace(/\n$/,""),d=l.App.useApp().message;return c?o().createElement(l.Card,{size:"small",title:s,styles:{title:{fontSize:f.fontSize,fontWeight:400},body:{width:"100%",fontSize:f.fontSizeSM}},extra:o().createElement(l.Button,{variant:"link",color:"default",size:"small",onClick:function(){navigator.clipboard.writeText(m),d.success(p("Copied"))},icon:o().createElement(a.CopyOutlined,null)})},o().createElement(j,w(O({},r),{language:s,value:m}))):o().createElement(l.Typography.Text,w(O({code:!0},r),{className:n}),t)},k=function(e){var t=e.className,n=/language-(\w+)/.exec(t||""),r=n?n[1]:"";return f.h.use.editorRef()[f.h.use.currentEditorRefUid()]&&(0,c.p0)(r)?o().createElement(h,e):o().createElement(C,e)}}}]);
|