@nuraly/lumenui 0.5.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/dist/cdn.js +1 -1
- package/dist/nuralyui.bundle.js +106 -97
- package/dist/nuralyui.bundle.js.gz +0 -0
- package/dist/src/components/canvas/bundle.js +149 -140
- package/dist/src/components/canvas/bundle.js.gz +0 -0
- package/dist/src/components/chatbot/bundle.js +120 -111
- package/dist/src/components/chatbot/bundle.js.gz +0 -0
- package/dist/src/components/chatbot/chatbot.component.d.ts +13 -2
- package/dist/src/components/chatbot/chatbot.component.js +81 -10
- package/dist/src/components/chatbot/chatbot.style.js +31 -42
- package/dist/src/components/chatbot/chatbot.types.d.ts +1 -0
- package/dist/src/components/chatbot/templates/artifact-panel.template.js +13 -13
- package/dist/src/components/chatbot/templates/chatbot-main.template.d.ts +4 -0
- package/dist/src/components/chatbot/templates/chatbot-main.template.js +6 -4
- package/dist/src/components/chatbot/templates/file-upload-area.template.js +3 -3
- package/dist/src/components/chatbot/templates/input-box.template.js +21 -14
- package/dist/src/components/chatbot/templates/message.template.d.ts +3 -8
- package/dist/src/components/chatbot/templates/message.template.js +30 -17
- package/dist/src/components/chatbot/templates/thread-sidebar.template.js +12 -11
- package/package.json +1 -1
- package/packages/themes/dist/default.css +12 -0
package/dist/nuralyui.bundle.js
CHANGED
|
@@ -2189,10 +2189,10 @@ class Ai{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
2189
2189
|
display: flex;
|
|
2190
2190
|
width: 100%;
|
|
2191
2191
|
height: 100%;
|
|
2192
|
-
background-color: #ffffff;
|
|
2193
2192
|
border-radius: 8px;
|
|
2194
2193
|
position: relative;
|
|
2195
2194
|
border: 1px solid #e0e0e0;
|
|
2195
|
+
box-sizing: border-box;
|
|
2196
2196
|
}
|
|
2197
2197
|
|
|
2198
2198
|
.chatbot-container {
|
|
@@ -2217,13 +2217,24 @@ class Ai{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
2217
2217
|
min-width: 0;
|
|
2218
2218
|
}
|
|
2219
2219
|
|
|
2220
|
+
.chatbot-boxed-area {
|
|
2221
|
+
display: flex;
|
|
2222
|
+
flex-direction: column;
|
|
2223
|
+
flex: 1;
|
|
2224
|
+
min-height: 0;
|
|
2225
|
+
min-width: 0;
|
|
2226
|
+
width: 100%;
|
|
2227
|
+
}
|
|
2228
|
+
|
|
2220
2229
|
.chatbot-header {
|
|
2221
2230
|
display: flex;
|
|
2222
2231
|
align-items: center;
|
|
2223
2232
|
justify-content: space-between;
|
|
2224
2233
|
gap: 0.5rem;
|
|
2225
2234
|
padding: 0.5rem;
|
|
2226
|
-
|
|
2235
|
+
min-height: 43px;
|
|
2236
|
+
box-sizing: border-box;
|
|
2237
|
+
border-bottom: 1px solid var(--nuraly-color-divider, rgb(224, 224, 224));
|
|
2227
2238
|
}
|
|
2228
2239
|
|
|
2229
2240
|
.chatbot-content {
|
|
@@ -2235,7 +2246,6 @@ class Ai{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
2235
2246
|
}
|
|
2236
2247
|
|
|
2237
2248
|
:host([boxed]) .chat-container {
|
|
2238
|
-
background-color: #ffffff;
|
|
2239
2249
|
border: none;
|
|
2240
2250
|
border-radius: 0;
|
|
2241
2251
|
}
|
|
@@ -2246,22 +2256,15 @@ class Ai{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
2246
2256
|
|
|
2247
2257
|
:host([boxed]) .chatbot-main {
|
|
2248
2258
|
width: 100%;
|
|
2249
|
-
max-width: 768px;
|
|
2250
|
-
margin: 0 auto;
|
|
2251
|
-
background-color: #ffffff;
|
|
2252
2259
|
border: none;
|
|
2253
2260
|
border-radius: 0;
|
|
2254
2261
|
box-shadow: none;
|
|
2255
2262
|
height: 100%;
|
|
2256
2263
|
}
|
|
2257
2264
|
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
}
|
|
2262
|
-
|
|
2263
|
-
.chat-container--boxed.chat-container--with-threads .chatbot-main {
|
|
2264
|
-
background-color: #ffffff;
|
|
2265
|
+
:host([boxed]) .chatbot-boxed-area {
|
|
2266
|
+
max-width: 768px;
|
|
2267
|
+
margin: 0 auto;
|
|
2265
2268
|
}
|
|
2266
2269
|
|
|
2267
2270
|
.chat-container--boxed.chat-container--with-threads .chat-box {
|
|
@@ -2277,9 +2280,7 @@ class Ai{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
2277
2280
|
}
|
|
2278
2281
|
|
|
2279
2282
|
:host([boxed]) .chatbot-header {
|
|
2280
|
-
/* Keep header at the top */
|
|
2281
2283
|
flex: 0 0 auto;
|
|
2282
|
-
border-bottom: none;
|
|
2283
2284
|
}
|
|
2284
2285
|
|
|
2285
2286
|
:host([boxed]) .chatbot-content:has(.empty-state) {
|
|
@@ -2293,24 +2294,15 @@ class Ai{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
2293
2294
|
min-height: 0;
|
|
2294
2295
|
}
|
|
2295
2296
|
|
|
2296
|
-
:host([boxed]) .chatbot-main:has(.empty-state) {
|
|
2297
|
-
/* Make main container relative for absolute positioning */
|
|
2298
|
-
position: relative;
|
|
2299
|
-
}
|
|
2300
|
-
|
|
2301
2297
|
:host([boxed]) .empty-state {
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
transform: translate(-50%, calc(-50% - 80px));
|
|
2298
|
+
display: flex;
|
|
2299
|
+
align-items: center;
|
|
2300
|
+
justify-content: center;
|
|
2301
|
+
flex-direction: column;
|
|
2307
2302
|
width: 100%;
|
|
2303
|
+
height: 100%;
|
|
2308
2304
|
max-width: 768px;
|
|
2309
|
-
height: auto;
|
|
2310
2305
|
padding: 0;
|
|
2311
|
-
display: flex;
|
|
2312
|
-
flex-direction: column;
|
|
2313
|
-
align-items: center;
|
|
2314
2306
|
gap: 1.5rem;
|
|
2315
2307
|
}
|
|
2316
2308
|
|
|
@@ -2319,13 +2311,9 @@ class Ai{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
2319
2311
|
}
|
|
2320
2312
|
|
|
2321
2313
|
:host([boxed]) .chatbot-content:has(.empty-state) + .input-box {
|
|
2322
|
-
/* Position input-box in the middle with empty state - moved up */
|
|
2323
|
-
position: absolute;
|
|
2324
|
-
top: 50%;
|
|
2325
|
-
left: 50%;
|
|
2326
|
-
transform: translate(-50%, calc(-50% + 40px));
|
|
2327
2314
|
width: 100%;
|
|
2328
2315
|
max-width: 768px;
|
|
2316
|
+
margin: 0 auto;
|
|
2329
2317
|
}
|
|
2330
2318
|
|
|
2331
2319
|
:host([boxed]) .suggestion-container {
|
|
@@ -2335,7 +2323,7 @@ class Ai{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
2335
2323
|
:host([boxed]) .messages {
|
|
2336
2324
|
box-shadow: none;
|
|
2337
2325
|
margin-bottom: 0;
|
|
2338
|
-
background-color:
|
|
2326
|
+
background-color: var(--chatbot-messages-bg, transparent);
|
|
2339
2327
|
align-items: stretch;
|
|
2340
2328
|
width: 98%;
|
|
2341
2329
|
padding: 8px 1.5rem;
|
|
@@ -2379,7 +2367,7 @@ class Ai{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
2379
2367
|
align-items: center;
|
|
2380
2368
|
justify-content: space-between;
|
|
2381
2369
|
padding: 0.75rem;
|
|
2382
|
-
border-bottom: 1px solid
|
|
2370
|
+
border-bottom: 1px solid var(--nuraly-color-divider, rgb(224, 224, 224));
|
|
2383
2371
|
}
|
|
2384
2372
|
|
|
2385
2373
|
.thread-sidebar__header h3 {
|
|
@@ -2590,12 +2578,13 @@ class Ai{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
2590
2578
|
|
|
2591
2579
|
.messages {
|
|
2592
2580
|
flex: 1;
|
|
2581
|
+
min-height: 0;
|
|
2593
2582
|
overflow-y: auto;
|
|
2594
2583
|
overflow-x: hidden;
|
|
2595
2584
|
display: flex;
|
|
2596
2585
|
flex-direction: column;
|
|
2597
2586
|
gap: 0;
|
|
2598
|
-
background-color:
|
|
2587
|
+
background-color: var(--chatbot-messages-bg, transparent);
|
|
2599
2588
|
padding: 8px 1rem;
|
|
2600
2589
|
box-sizing: border-box;
|
|
2601
2590
|
justify-content: flex-start; /* Always align messages to top */
|
|
@@ -2734,16 +2723,16 @@ class Ai{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
2734
2723
|
}
|
|
2735
2724
|
|
|
2736
2725
|
.message.user .message__content {
|
|
2737
|
-
background-color:
|
|
2738
|
-
color:
|
|
2726
|
+
background-color: var(--nuraly-color-user-bubble-bg, rgb(124, 58, 237));
|
|
2727
|
+
color: var(--nuraly-color-user-bubble-fg, rgb(255, 255, 255));
|
|
2739
2728
|
border-radius: var(--chatbot-radius, 8px);
|
|
2740
2729
|
border: 0 solid transparent;
|
|
2741
2730
|
box-shadow: none;
|
|
2742
2731
|
}
|
|
2743
2732
|
|
|
2744
2733
|
.message.bot .message__content {
|
|
2745
|
-
background-color: transparent;
|
|
2746
|
-
color: inherit;
|
|
2734
|
+
background-color: var(--nuraly-color-bot-bubble-bg, transparent);
|
|
2735
|
+
color: var(--nuraly-color-bot-bubble-fg, inherit);
|
|
2747
2736
|
border-radius: 0;
|
|
2748
2737
|
border: 0 solid transparent;
|
|
2749
2738
|
box-shadow: none;
|
|
@@ -3788,10 +3777,10 @@ class Ai{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
3788
3777
|
.artifact-panel {
|
|
3789
3778
|
width: 400px;
|
|
3790
3779
|
min-width: 300px;
|
|
3780
|
+
min-height: 0;
|
|
3791
3781
|
flex-shrink: 0;
|
|
3792
3782
|
display: flex;
|
|
3793
3783
|
flex-direction: row;
|
|
3794
|
-
background-color: #ffffff;
|
|
3795
3784
|
overflow: hidden;
|
|
3796
3785
|
position: relative;
|
|
3797
3786
|
}
|
|
@@ -4098,14 +4087,14 @@ function un(e){if(!e)return"";const t=e instanceof Date?e:new Date(e);if(Number.
|
|
|
4098
4087
|
* @license
|
|
4099
4088
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
4100
4089
|
* SPDX-License-Identifier: MIT
|
|
4101
|
-
*/function vn(e){return e.startsWith("image/")}function yn(e,t){const i=e.lastIndexOf(".");if(i>=0&&i<e.length-1)return e.slice(i+1).toUpperCase().slice(0,4);if(t){const e=t.indexOf("/");if(e>=0)return t.slice(e+1).toUpperCase().slice(0,4)}return"FILE"}function _n(e,t,i){var n,s,a,o,r,l,d,c;const h=null===(n=e.text)||void 0===n?void 0:n.includes("[ERROR_START]"),p={error:!!e.error||h,introduction:!!e.introduction,[e.sender]:!0};return q`
|
|
4090
|
+
*/function vn(e){return e.startsWith("image/")}function yn(e,t){const i=e.lastIndexOf(".");if(i>=0&&i<e.length-1)return e.slice(i+1).toUpperCase().slice(0,4);if(t){const e=t.indexOf("/");if(e>=0)return t.slice(e+1).toUpperCase().slice(0,4)}return"FILE"}function _n(e,t,i){var n,s,a,o,r,l,d,c;const h=null===(n=e.text)||void 0===n?void 0:n.includes("[ERROR_START]"),p={error:!!e.error||h,introduction:!!e.introduction,[e.sender]:!0},u=e.sender;return q`
|
|
4102
4091
|
<div
|
|
4103
4092
|
class="message ${Te(p)}"
|
|
4104
|
-
part
|
|
4093
|
+
part=${`message message-${u}`}
|
|
4105
4094
|
data-sender="${e.sender}"
|
|
4106
4095
|
data-id="${e.id}"
|
|
4107
4096
|
>
|
|
4108
|
-
<div class="message__content" part
|
|
4097
|
+
<div class="message__content" part=${`message-content message-content-${u}`}>
|
|
4109
4098
|
${h?function(e){const t=e.match(/\[ERROR_START\]\[ERROR_TITLE_START\]([\s\S]*?)\[ERROR_TITLE_END\]([\s\S]*?)\[ERROR_END\]/);if(t){const e=t[1],i=t[2];return q`
|
|
4110
4099
|
<div class="message__error-container" part="message-error">
|
|
4111
4100
|
${e?q`<div class="message__error-title" part="message-error-title">${e}</div>`:""}
|
|
@@ -4175,6 +4164,7 @@ function un(e){if(!e)return"";const t=e instanceof Date?e:new Date(e);if(Number.
|
|
|
4175
4164
|
size="small"
|
|
4176
4165
|
color="#9ca3af"
|
|
4177
4166
|
class="message__copy"
|
|
4167
|
+
part="message-copy"
|
|
4178
4168
|
@click=${()=>t.onCopy(e)}
|
|
4179
4169
|
@keydown=${i=>t.onCopyKeydown(i,e)}
|
|
4180
4170
|
title="${i.messages.copyMessageLabel}"
|
|
@@ -4196,17 +4186,26 @@ function un(e){if(!e)return"";const t=e instanceof Date?e:new Date(e);if(Number.
|
|
|
4196
4186
|
${i.messages.retryButton}
|
|
4197
4187
|
</nr-button>`:K}
|
|
4198
4188
|
</div>
|
|
4199
|
-
`}function xn(e,t,i,n,s){return q`
|
|
4189
|
+
`}function xn(e,t,i,n,s,a,o){return q`
|
|
4200
4190
|
<div class="messages" part="messages">
|
|
4201
|
-
${0===e.length?function(e){return q`
|
|
4191
|
+
${0===e.length?o?function(e){return q`
|
|
4192
|
+
<div class="empty-state empty-state--loading" part="empty-state thread-loading">
|
|
4193
|
+
<slot name="thread-loading">
|
|
4194
|
+
<div class="spinner" part="thread-loading-spinner"></div>
|
|
4195
|
+
<div class="empty-state__content" part="empty-state-content">
|
|
4196
|
+
${e.messages.loadingConversationLabel}
|
|
4197
|
+
</div>
|
|
4198
|
+
</slot>
|
|
4199
|
+
</div>
|
|
4200
|
+
`}(s):function(e,t){const i=null!=t?t:e.messages.startConversationLabel;return q`
|
|
4202
4201
|
<div class="empty-state" part="empty-state">
|
|
4203
4202
|
<slot name="empty-state">
|
|
4204
|
-
<div class="empty-state__content">
|
|
4205
|
-
${
|
|
4203
|
+
<div class="empty-state__content" part="empty-state-content">
|
|
4204
|
+
${i}
|
|
4206
4205
|
</div>
|
|
4207
4206
|
</slot>
|
|
4208
4207
|
</div>
|
|
4209
|
-
`}(s):K}
|
|
4208
|
+
`}(s,a):K}
|
|
4210
4209
|
${e.map(e=>_n(e,n,s))}
|
|
4211
4210
|
${t}
|
|
4212
4211
|
${i}
|
|
@@ -4261,6 +4260,7 @@ function Dn(e,t,i,n){const s=(e,t)=>{const i=e.lastIndexOf(".");if(i>=0&&i<e.len
|
|
|
4261
4260
|
<div
|
|
4262
4261
|
slot="trigger"
|
|
4263
4262
|
class="file-thumb ${e.isUploading?"file-thumb--uploading":""}"
|
|
4263
|
+
part="file-thumb"
|
|
4264
4264
|
role="button"
|
|
4265
4265
|
tabindex="0"
|
|
4266
4266
|
title="${e.name}"
|
|
@@ -4269,22 +4269,24 @@ function Dn(e,t,i,n){const s=(e,t)=>{const i=e.lastIndexOf(".");if(i>=0&&i<e.len
|
|
|
4269
4269
|
${a(e.mimeType)&&(e.previewUrl||e.url)?q`
|
|
4270
4270
|
<img
|
|
4271
4271
|
class="file-thumb__image"
|
|
4272
|
+
part="file-thumb-image"
|
|
4272
4273
|
src="${e.previewUrl||e.url}"
|
|
4273
4274
|
alt="${e.name}"
|
|
4274
4275
|
/>
|
|
4275
4276
|
`:q`
|
|
4276
|
-
<div class="file-thumb__ext" data-ext="${s(e.name,e.mimeType)}">
|
|
4277
|
-
<span class="file-thumb__ext-label">${s(e.name,e.mimeType)}</span>
|
|
4277
|
+
<div class="file-thumb__ext" part="file-thumb-ext" data-ext="${s(e.name,e.mimeType)}">
|
|
4278
|
+
<span class="file-thumb__ext-label" part="file-thumb-ext-label">${s(e.name,e.mimeType)}</span>
|
|
4278
4279
|
</div>
|
|
4279
4280
|
`}
|
|
4280
4281
|
${e.isUploading?q`
|
|
4281
|
-
<div class="file-thumb__spinner" aria-label="${i.input.uploadingLabel}">
|
|
4282
|
+
<div class="file-thumb__spinner" part="file-thumb-spinner" aria-label="${i.input.uploadingLabel}">
|
|
4282
4283
|
<span class="file-thumb__spinner-ring"></span>
|
|
4283
4284
|
</div>
|
|
4284
4285
|
`:""}
|
|
4285
4286
|
<button
|
|
4286
4287
|
type="button"
|
|
4287
4288
|
class="file-thumb__remove"
|
|
4289
|
+
part="file-thumb-remove"
|
|
4288
4290
|
aria-label="${i.input.removeFileLabel}"
|
|
4289
4291
|
title="${i.input.removeFileLabel}"
|
|
4290
4292
|
@click=${i=>{i.stopPropagation(),t(e.id)}}
|
|
@@ -4320,8 +4322,8 @@ function Dn(e,t,i,n){const s=(e,t)=>{const i=e.lastIndexOf(".");if(i>=0&&i<e.len
|
|
|
4320
4322
|
`)}
|
|
4321
4323
|
</div>
|
|
4322
4324
|
`}function zn(e,t){return q`
|
|
4323
|
-
<div class="action-buttons-row">
|
|
4324
|
-
<div class="action-buttons-left">
|
|
4325
|
+
<div class="action-buttons-row" part="actions">
|
|
4326
|
+
<div class="action-buttons-left" part="actions-left">
|
|
4325
4327
|
${e.enableFileUpload?function(e,t){return q`
|
|
4326
4328
|
<nr-dropdown
|
|
4327
4329
|
.items=${e.fileUploadItems}
|
|
@@ -4369,11 +4371,12 @@ function Dn(e,t,i,n){const s=(e,t)=>{const i=e.lastIndexOf(".");if(i>=0&&i<e.len
|
|
|
4369
4371
|
`}(e,t):K}
|
|
4370
4372
|
</div>
|
|
4371
4373
|
|
|
4372
|
-
<div class="action-buttons-right">
|
|
4374
|
+
<div class="action-buttons-right" part="actions-right">
|
|
4373
4375
|
${e.showAudioButton&&!e.isQueryRunning?q`
|
|
4374
4376
|
<!-- Speech-to-text: mic + keyboard indicator -->
|
|
4375
4377
|
<button
|
|
4376
4378
|
class="audio-mic-btn"
|
|
4379
|
+
part="audio-mic-button audio-mic-transcribe"
|
|
4377
4380
|
title="${e.i18n.audio.recordSpeechLabel}"
|
|
4378
4381
|
?disabled=${e.disabled}
|
|
4379
4382
|
@click=${()=>{var e;return null===(e=t.onAudioStart)||void 0===e?void 0:e.call(t,"transcribe")}}
|
|
@@ -4392,6 +4395,7 @@ function Dn(e,t,i,n){const s=(e,t)=>{const i=e.lastIndexOf(".");if(i>=0&&i<e.len
|
|
|
4392
4395
|
<!-- Voice message: mic + waveform indicator -->
|
|
4393
4396
|
<button
|
|
4394
4397
|
class="audio-mic-btn"
|
|
4398
|
+
part="audio-mic-button audio-mic-voice"
|
|
4395
4399
|
title="${e.i18n.audio.sendVoiceMessageLabel}"
|
|
4396
4400
|
?disabled=${e.disabled}
|
|
4397
4401
|
@click=${()=>{var e;return null===(e=t.onAudioStart)||void 0===e?void 0:e.call(t,"message")}}
|
|
@@ -4433,9 +4437,10 @@ function Dn(e,t,i,n){const s=(e,t)=>{const i=e.lastIndexOf(".");if(i>=0&&i<e.len
|
|
|
4433
4437
|
</svg>`:q`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
|
|
4434
4438
|
<path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/>
|
|
4435
4439
|
</svg>`;return q`
|
|
4436
|
-
<div class="audio-recording-bar">
|
|
4440
|
+
<div class="audio-recording-bar" part="audio-recording-bar">
|
|
4437
4441
|
<button
|
|
4438
4442
|
class="audio-rec-cancel"
|
|
4443
|
+
part="audio-cancel-button"
|
|
4439
4444
|
title="${e.i18n.audio.cancelRecordingLabel}"
|
|
4440
4445
|
@click=${t.onAudioCancel}
|
|
4441
4446
|
aria-label="${e.i18n.audio.cancelRecordingLabel}"
|
|
@@ -4447,22 +4452,23 @@ function Dn(e,t,i,n){const s=(e,t)=>{const i=e.lastIndexOf(".");if(i>=0&&i<e.len
|
|
|
4447
4452
|
</svg>
|
|
4448
4453
|
</button>
|
|
4449
4454
|
|
|
4450
|
-
<div class="audio-rec-indicator">
|
|
4451
|
-
<span class="audio-rec-dot"></span>
|
|
4452
|
-
<div class="audio-rec-wave">
|
|
4455
|
+
<div class="audio-rec-indicator" part="audio-indicator">
|
|
4456
|
+
<span class="audio-rec-dot" part="audio-dot"></span>
|
|
4457
|
+
<div class="audio-rec-wave" part="audio-wave">
|
|
4453
4458
|
${n.map(e=>q`
|
|
4454
|
-
<div class="audio-rec-bar" style=${Be({height:`${Math.round(24*e)}px`})}></div>
|
|
4459
|
+
<div class="audio-rec-bar" part="audio-bar" style=${Be({height:`${Math.round(24*e)}px`})}></div>
|
|
4455
4460
|
`)}
|
|
4456
4461
|
</div>
|
|
4457
|
-
<span class="audio-rec-time">${i}</span>
|
|
4462
|
+
<span class="audio-rec-time" part="audio-time">${i}</span>
|
|
4458
4463
|
</div>
|
|
4459
4464
|
|
|
4460
|
-
<span class="audio-rec-mode-label">
|
|
4465
|
+
<span class="audio-rec-mode-label" part="audio-mode-label">
|
|
4461
4466
|
${s?e.i18n.audio.speechToTextLabel:e.i18n.audio.voiceMessageLabel}
|
|
4462
4467
|
</span>
|
|
4463
4468
|
|
|
4464
4469
|
<button
|
|
4465
4470
|
class="audio-rec-send ${s?"audio-rec-send--transcribe":""}"
|
|
4471
|
+
part="audio-send-button"
|
|
4466
4472
|
title="${a}"
|
|
4467
4473
|
@click=${t.onAudioSend}
|
|
4468
4474
|
aria-label="${a}"
|
|
@@ -4480,7 +4486,7 @@ function Dn(e,t,i,n){const s=(e,t)=>{const i=e.lastIndexOf(".");if(i>=0&&i<e.len
|
|
|
4480
4486
|
${e.uploadedFiles.length>0?Dn(e.uploadedFiles,t.onFileRemove,e.i18n,t.onFileClick):K}
|
|
4481
4487
|
|
|
4482
4488
|
<!-- Input area -->
|
|
4483
|
-
<div class="input-row">
|
|
4489
|
+
<div class="input-row" part="input-row">
|
|
4484
4490
|
<div
|
|
4485
4491
|
class="input-box__input"
|
|
4486
4492
|
part="input"
|
|
@@ -4515,6 +4521,7 @@ function Dn(e,t,i,n){const s=(e,t)=>{const i=e.lastIndexOf(".");if(i>=0&&i<e.len
|
|
|
4515
4521
|
${t.editingThreadId===e.id&&i.onRenameThread?q`
|
|
4516
4522
|
<input
|
|
4517
4523
|
class="thread-item__rename-input"
|
|
4524
|
+
part="thread-rename-input"
|
|
4518
4525
|
type="text"
|
|
4519
4526
|
.value=${e.title||""}
|
|
4520
4527
|
@click=${e=>e.stopPropagation()}
|
|
@@ -4522,9 +4529,9 @@ function Dn(e,t,i,n){const s=(e,t)=>{const i=e.lastIndexOf(".");if(i>=0&&i<e.len
|
|
|
4522
4529
|
@blur=${t=>{const n=t.target.value.trim();n&&n!==e.title?i.onRenameThread(e.id,n):i.onRenameThread(e.id,e.title||"")}}
|
|
4523
4530
|
/>
|
|
4524
4531
|
`:q`
|
|
4525
|
-
<div class="thread-item__title">${e.title||t.i18n.threads.newChatTitle}</div>
|
|
4532
|
+
<div class="thread-item__title" part="thread-title">${e.title||t.i18n.threads.newChatTitle}</div>
|
|
4526
4533
|
`}
|
|
4527
|
-
<div class="thread-item__actions">
|
|
4534
|
+
<div class="thread-item__actions" part="thread-actions">
|
|
4528
4535
|
${i.onBookmarkThread&&e.bookmarked?q`
|
|
4529
4536
|
<button
|
|
4530
4537
|
class="thread-item__action-btn thread-item__bookmark--active"
|
|
@@ -4558,10 +4565,10 @@ function Dn(e,t,i,n){const s=(e,t)=>{const i=e.lastIndexOf(".");if(i>=0&&i<e.len
|
|
|
4558
4565
|
`:""}
|
|
4559
4566
|
</div>
|
|
4560
4567
|
</div>
|
|
4561
|
-
<div class="thread-item__preview">
|
|
4568
|
+
<div class="thread-item__preview" part="thread-preview">
|
|
4562
4569
|
${s}
|
|
4563
4570
|
</div>
|
|
4564
|
-
<div class="thread-item__timestamp">${un(e.updatedAt)}</div>
|
|
4571
|
+
<div class="thread-item__timestamp" part="thread-timestamp">${un(e.updatedAt)}</div>
|
|
4565
4572
|
</div>
|
|
4566
4573
|
`}function On(e,t){if(!e.isOpen||!e.file)return K;const i=e.file,n=i.mimeType.startsWith("image/"),s="application/pdf"===i.mimeType||i.name.toLowerCase().endsWith(".pdf");return q`
|
|
4567
4574
|
<nr-modal
|
|
@@ -4621,15 +4628,15 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
4621
4628
|
*/function In(e,t){var i;if(!e.isOpen||!e.artifact)return K;const n=e.artifact,s=bn(n.language);return q`
|
|
4622
4629
|
<div class="artifact-panel" part="artifact-panel">
|
|
4623
4630
|
<div class="artifact-panel__resize-handle" part="artifact-panel-resize-handle">
|
|
4624
|
-
<div class="artifact-panel__resize-bar"></div>
|
|
4631
|
+
<div class="artifact-panel__resize-bar" part="artifact-panel-resize-bar"></div>
|
|
4625
4632
|
</div>
|
|
4626
|
-
<div class="artifact-panel__body">
|
|
4627
|
-
<div class="artifact-panel__header">
|
|
4628
|
-
<div class="artifact-panel__header-info">
|
|
4629
|
-
<nr-tag size="small" class="artifact-panel__lang-badge">${s}</nr-tag>
|
|
4630
|
-
<span class="artifact-panel__title">${n.title}</span>
|
|
4633
|
+
<div class="artifact-panel__body" part="artifact-panel-body">
|
|
4634
|
+
<div class="artifact-panel__header" part="artifact-panel-header">
|
|
4635
|
+
<div class="artifact-panel__header-info" part="artifact-panel-header-info">
|
|
4636
|
+
<nr-tag size="small" class="artifact-panel__lang-badge" part="artifact-panel-lang">${s}</nr-tag>
|
|
4637
|
+
<span class="artifact-panel__title" part="artifact-panel-title">${n.title}</span>
|
|
4631
4638
|
</div>
|
|
4632
|
-
<div class="artifact-panel__actions">
|
|
4639
|
+
<div class="artifact-panel__actions" part="artifact-panel-actions">
|
|
4633
4640
|
<nr-button
|
|
4634
4641
|
type="text"
|
|
4635
4642
|
size="small"
|
|
@@ -4648,8 +4655,8 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
4648
4655
|
></nr-button>
|
|
4649
4656
|
</div>
|
|
4650
4657
|
</div>
|
|
4651
|
-
<div class="artifact-panel__content">
|
|
4652
|
-
${(null===(i=e.renderContent)||void 0===i?void 0:i.call(e,n))||function(e){switch(e.language){case"json":{let t;try{t=JSON.stringify(JSON.parse(e.content),null,2)}catch(i){t=e.content}return q`<pre class="artifact-panel__code"><code>${t}</code></pre>`}case"md":case"markdown":return q`<div class="artifact-panel__rendered-md">${Jt(gn(e.content))}</div>`;case"html":return q`<div class="artifact-panel__rendered-html">${Jt(e.content)}</div>`;case"text":case"txt":return q`<div class="artifact-panel__rendered-text">${e.content}</div>`;default:return q`<pre class="artifact-panel__code"><code>${e.content}</code></pre>`}}(n)}
|
|
4658
|
+
<div class="artifact-panel__content" part="artifact-panel-content">
|
|
4659
|
+
${(null===(i=e.renderContent)||void 0===i?void 0:i.call(e,n))||function(e){switch(e.language){case"json":{let t;try{t=JSON.stringify(JSON.parse(e.content),null,2)}catch(i){t=e.content}return q`<pre class="artifact-panel__code" part="artifact-panel-code"><code>${t}</code></pre>`}case"md":case"markdown":return q`<div class="artifact-panel__rendered-md" part="artifact-panel-md">${Jt(gn(e.content))}</div>`;case"html":return q`<div class="artifact-panel__rendered-html" part="artifact-panel-html">${Jt(e.content)}</div>`;case"text":case"txt":return q`<div class="artifact-panel__rendered-text" part="artifact-panel-text">${e.content}</div>`;default:return q`<pre class="artifact-panel__code" part="artifact-panel-code"><code>${e.content}</code></pre>`}}(n)}
|
|
4653
4660
|
</div>
|
|
4654
4661
|
</div>
|
|
4655
4662
|
</div>
|
|
@@ -4661,19 +4668,19 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
4661
4668
|
*/function jn(e,t){return!1!==e.showMessages?q`
|
|
4662
4669
|
<div class="chatbot-content" part="content">
|
|
4663
4670
|
${xn(e.messages,wn(e.chatStarted,e.suggestions,t.suggestion,e.i18n),e.isTyping?function(e,t,i){if(!e)return K;const n=t===Qi.Dots?q`
|
|
4664
|
-
<div class="dots">
|
|
4671
|
+
<div class="dots" part="typing-dots">
|
|
4665
4672
|
<span></span>
|
|
4666
4673
|
<span></span>
|
|
4667
4674
|
<span></span>
|
|
4668
4675
|
</div>
|
|
4669
|
-
`:q`<div class="spinner"></div>`;return q`
|
|
4676
|
+
`:q`<div class="spinner" part="typing-spinner"></div>`;return q`
|
|
4670
4677
|
<div class="message bot loading" part="typing-indicator">
|
|
4671
|
-
<div class="message__content">
|
|
4678
|
+
<div class="message__content" part="typing-content">
|
|
4672
4679
|
${n}
|
|
4673
|
-
${i?q`<span class="loading-text">${i.split("").map((e,t)=>q`<span class="loading-text__char" style="animation-delay:${.04*t}s">${" "===e?" ":e}</span>`)}</span>`:K}
|
|
4680
|
+
${i?q`<span class="loading-text" part="typing-text">${i.split("").map((e,t)=>q`<span class="loading-text__char" style="animation-delay:${.04*t}s">${" "===e?" ":e}</span>`)}</span>`:K}
|
|
4674
4681
|
</div>
|
|
4675
4682
|
</div>
|
|
4676
|
-
`}(e.isTyping,e.loadingIndicator||Qi.Spinner,e.loadingText):K,t.message,e.i18n)}
|
|
4683
|
+
`}(e.isTyping,e.loadingIndicator||Qi.Spinner,e.loadingText):K,t.message,e.i18n,e.welcomeMessage,e.isPendingThread)}
|
|
4677
4684
|
<slot name="messages"></slot>
|
|
4678
4685
|
</div>
|
|
4679
4686
|
`:e.suggestions&&e.suggestions.length>0?q`
|
|
@@ -4690,14 +4697,14 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
4690
4697
|
|
|
4691
4698
|
${e.enableThreads&&e.isThreadSidebarOpen&&e.threadSidebar&&t.threadSidebar?function(e,t){const i=e.threads.filter(e=>e.bookmarked),n=e.threads.filter(e=>!e.bookmarked);return q`
|
|
4692
4699
|
<div class="thread-sidebar" part="thread-sidebar">
|
|
4693
|
-
<div class="thread-sidebar__header">
|
|
4694
|
-
<h3>${e.i18n.threads.conversationsTitle}</h3>
|
|
4700
|
+
<div class="thread-sidebar__header" part="thread-sidebar-header">
|
|
4701
|
+
<h3 part="thread-sidebar-title">${e.i18n.threads.conversationsTitle}</h3>
|
|
4695
4702
|
</div>
|
|
4696
4703
|
|
|
4697
|
-
<div class="thread-list">
|
|
4704
|
+
<div class="thread-list" part="thread-list">
|
|
4698
4705
|
${i.length>0?q`
|
|
4699
|
-
<div class="thread-section" part="thread-section-bookmarks">
|
|
4700
|
-
<div class="thread-section__label">
|
|
4706
|
+
<div class="thread-section" part="thread-section thread-section-bookmarks">
|
|
4707
|
+
<div class="thread-section__label" part="thread-section-label">
|
|
4701
4708
|
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"/></svg>
|
|
4702
4709
|
${e.i18n.threads.bookmarksLabel}
|
|
4703
4710
|
</div>
|
|
@@ -4706,11 +4713,11 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
4706
4713
|
`:K}
|
|
4707
4714
|
${n.length>0||0===i.length?q`
|
|
4708
4715
|
${i.length>0?q`
|
|
4709
|
-
<div class="thread-section__label">${e.i18n.threads.allConversationsLabel}</div>
|
|
4716
|
+
<div class="thread-section__label" part="thread-section-label">${e.i18n.threads.allConversationsLabel}</div>
|
|
4710
4717
|
`:K}
|
|
4711
4718
|
${Cn(n,e=>e.id,i=>An(i,e,t))}
|
|
4712
4719
|
${0===n.length&&0===i.length?q`
|
|
4713
|
-
<p class="empty-msg">${e.i18n.threads.noConversationsLabel}</p>
|
|
4720
|
+
<p class="empty-msg" part="thread-empty">${e.i18n.threads.noConversationsLabel}</p>
|
|
4714
4721
|
`:K}
|
|
4715
4722
|
`:K}
|
|
4716
4723
|
</div>
|
|
@@ -4748,11 +4755,13 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
4748
4755
|
</div>
|
|
4749
4756
|
`:K}(e,t)}
|
|
4750
4757
|
|
|
4751
|
-
<
|
|
4758
|
+
<div class="chatbot-boxed-area" part="boxed-area">
|
|
4759
|
+
<slot name="header"></slot>
|
|
4752
4760
|
|
|
4753
|
-
|
|
4761
|
+
${jn(e,t)}
|
|
4754
4762
|
|
|
4755
|
-
|
|
4763
|
+
${En(e.inputBox,t.inputBox)}
|
|
4764
|
+
</div>
|
|
4756
4765
|
|
|
4757
4766
|
<slot name="footer"></slot>
|
|
4758
4767
|
</div>
|
|
@@ -4764,9 +4773,9 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
4764
4773
|
class="file-upload-area ${e.isDragging?"file-upload-area--dragging":""}"
|
|
4765
4774
|
part="file-upload-area"
|
|
4766
4775
|
>
|
|
4767
|
-
<div class="file-upload-area__content">
|
|
4768
|
-
<nr-icon name="upload" size="xlarge"></nr-icon>
|
|
4769
|
-
<div class="file-upload-area__text">
|
|
4776
|
+
<div class="file-upload-area__content" part="file-upload-area-content">
|
|
4777
|
+
<nr-icon name="upload" size="xlarge" part="file-upload-area-icon"></nr-icon>
|
|
4778
|
+
<div class="file-upload-area__text" part="file-upload-area-text">
|
|
4770
4779
|
${e.label}
|
|
4771
4780
|
</div>
|
|
4772
4781
|
</div>
|
|
@@ -4878,7 +4887,7 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
4878
4887
|
* @license
|
|
4879
4888
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
4880
4889
|
* SPDX-License-Identifier: MIT
|
|
4881
|
-
*/var Fn=function(e,t,i,n){for(var s,a=arguments.length,o=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n,r=e.length-1;r>=0;r--)(s=e[r])&&(o=(a<3?s(o):a>3?s(t,i,o):s(t,i))||o);return a>3&&o&&Object.defineProperty(t,i,o),o},Bn=function(e,t,i,n){return new(i||(i=Promise))(function(s,a){function o(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,r)}l((n=n.apply(e,t||[])).next())})};const Un={input:{placeholder:Ci("Type your message..."),chatInputAriaLabel:Ci("Chat input"),attachButton:Ci("Attach"),attachFilesAriaLabel:Ci("Attach files"),removeFileLabel:Ci("Remove file"),uploadingLabel:Ci("Uploading"),uploadingProgress:Ci("Uploading…"),dropFilesHere:Ci("Drop files here to upload")},send:{sendButton:Ci("Send"),stopButton:Ci("Stop"),sendMessageLabel:Ci("Send message"),stopQueryLabel:Ci("Stop query")},audio:{recordSpeechLabel:Ci("Record speech to text"),sendVoiceMessageLabel:Ci("Send voice message"),cancelRecordingLabel:Ci("Cancel recording"),speechToTextLabel:Ci("Speech to text"),voiceMessageLabel:Ci("Voice message"),convertToTextLabel:Ci("Convert to text"),sendAsVoiceMessageLabel:Ci("Send as voice message")},modules:{moduleSelectionLabel:Ci("Select Modules"),moduleSearchPlaceholder:Ci("Search modules..."),moduleSelectAriaLabel:Ci("Select modules"),modulesSelectedSuffix:Ci("modules selected")},threads:{conversationsTitle:Ci("Conversations"),bookmarksLabel:Ci("Bookmarks"),allConversationsLabel:Ci("All Conversations"),noConversationsLabel:Ci("No conversations yet"),newChatTitle:Ci("New Chat"),newConversationLabel:Ci("New conversation"),removeBookmarkLabel:Ci("Remove bookmark"),bookmarkLabel:Ci("Bookmark"),renameLabel:Ci("Rename"),deleteLabel:Ci("Delete"),moreOptionsLabel:Ci("More options"),showThreadsLabel:Ci("Show threads"),hideThreadsLabel:Ci("Hide threads")},messages:{attachedFilesLabel:Ci("Attached files"),copyMessageLabel:Ci("Copy message"),retryMessageLabel:Ci("Retry message"),retryButton:Ci("Retry"),startConversationLabel:Ci("Start a conversation"),suggestionPrefix:Ci("Select suggestion: ")},urlModal:{addUrlTitle:Ci("Add URL"),urlLabel:Ci("URL"),urlPlaceholder:Ci("Enter URL..."),loadFromUrlLabel:Ci("Load file from URL"),selectedFileLabel:Ci("Selected file"),loadingFromUrlLabel:Ci("Loading file from URL..."),cancelButton:Ci("Cancel"),addButton:Ci("Add")},artifactPanel:{copyCodeLabel:Ci("Copy code"),closePanelLabel:Ci("Close panel")},loading:{agentWorkingLabel:Ci("Agent is working...")}};let Vn=class extends(je(me)){constructor(){super(...arguments),this.requiredComponents=["nr-input","nr-button","nr-icon","nr-dropdown","nr-select","nr-modal","nr-popconfirm"],this.messages=[],this.currentInput="",this.isBotTyping=!1,this.isQueryRunning=!1,this.suggestions=[],this.chatStarted=!1,this.isRTL=!1,this.size=en.Medium,this.variant=tn.Default,this.loadingIndicator=Qi.Dots,this.loadingText=Ci("Agent is working..."),this.disabled=!1,this.placeholder=Ci("Type your message..."),this.showSendButton=!0,this.autoScroll=!0,this.showThreads=!1,this.enableThreadCreation=!1,this.threads=[],this.mode="chat",this.boxed=!1,this.enableUrlSync=!1,this.showMessages=!0,this.enableFileUpload=!1,this.uploadedFiles=[],this.actionButtons=[],this.enableModuleSelection=!1,this.modules=[],this.selectedModules=[],this.moduleSelectionLabel=Ci("Select Modules"),this.enableArtifacts=!1,this.showAudioButton=!1,this.focused=!1,this.isArtifactPanelOpen=!1,this.selectedArtifact=null,this.isThreadSidebarOpen=!0,this.isUrlModalOpen=!1,this.urlInput="",this.urlModalError="",this.isUrlLoading=!1,this.selectedUrlFileName="",this.isFilePreviewModalOpen=!1,this.previewFile=null,this._isDragging=!1,this._dragDepth=0,this.controllerUnsubscribes=[],this._audio=new Rn(this),this._audioMode="message",this._artifactResizeBound=!1,this.toggleThreadSidebar=()=>{this.isThreadSidebarOpen=!this.isThreadSidebarOpen}}get moduleSelectOptions(){return this.modules.map(e=>({value:e.id,label:e.name,icon:e.icon,disabled:!1===e.enabled,description:e.description}))}connectedCallback(){super.connectedCallback(),this.controller&&this.setupControllerIntegration(),this.setupUrlSync()}firstUpdated(){var e,t,i,n;null===(e=this.shadowRoot)||void 0===e||e.addEventListener("click",e=>{var t,i;const n=null===(i=(t=e.target).closest)||void 0===i?void 0:i.call(t,"[data-artifact-id]");if(n){const e=n.dataset.artifactId;e&&this.handleArtifactClick(e)}}),null===(t=this.shadowRoot)||void 0===t||t.addEventListener("nr-thread-edit",e=>{const t=e.detail;(null==t?void 0:t.threadId)&&(this._editingThreadId=t.threadId,this.requestUpdate(),this.updateComplete.then(()=>{var e;const t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".thread-item__rename-input");t&&(t.focus(),t.select())}))}),null===(i=this.shadowRoot)||void 0===i||i.addEventListener("click",e=>{var t,i;const n=null===(i=(t=e.target).closest)||void 0===i?void 0:i.call(t,"[data-selection-value]");if(n){const e=n.dataset.selectionValue;e&&this.controller&&this.controller.sendMessage(e)}}),null===(n=this.shadowRoot)||void 0===n||n.addEventListener("keydown",e=>{var t,i,n,s;const a=e;if("Enter"!==a.key&&" "!==a.key)return;const o=null===(i=(t=a.target).closest)||void 0===i?void 0:i.call(t,"[data-artifact-id]");if(o){a.preventDefault();const e=o.dataset.artifactId;return void(e&&this.handleArtifactClick(e))}const r=null===(s=(n=a.target).closest)||void 0===s?void 0:s.call(n,"[data-selection-value]");if(r){a.preventDefault();const e=r.dataset.selectionValue;e&&this.controller&&this.controller.sendMessage(e)}})}disconnectedCallback(){var e;super.disconnectedCallback(),this.controller&&this.cleanupControllerIntegration(),this.teardownUrlSync(),null===(e=this._artifactResizeCleanup)||void 0===e||e.call(this),this._artifactResizeBound=!1}updated(e){if(super.updated(e),e.has("controller")&&(this.cleanupControllerIntegration(),this.controller)){this.setupControllerIntegration();try{const e=this.controller.getState();this.handleControllerStateChange(e)}catch(e){}this.enableUrlSync&&this.handleHashChange()}if(e.has("enableUrlSync")&&(this.enableUrlSync?this.setupUrlSync():this.teardownUrlSync()),this.controller&&!e.has("controller")){if(e.has("messages")||e.has("suggestions")||e.has("threads"))try{const e=this.controller.getState();this.handleControllerStateChange(e)}catch(e){}}e.has("messages")&&this.autoScroll&&this.messages.length>0&&this.scrollToLatestMessage(),this.updateArtifactPanelResize()}scrollToLatestMessage(){requestAnimationFrame(()=>{var e;const t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".messages");t&&(t.scrollTop=t.scrollHeight)})}setupControllerIntegration(){this.controller&&this.controllerUnsubscribes.push(this.controller.on("state:changed",this.handleControllerStateChange.bind(this)),this.controller.on("message:sent",this.handleControllerMessageSent.bind(this)),this.controller.on("message:received",this.handleControllerMessageReceived.bind(this)),this.controller.on("error",this.handleControllerError.bind(this)))}cleanupControllerIntegration(){if(this.controllerUnsubscribes.length)try{this.controllerUnsubscribes.forEach(e=>{try{e()}catch(e){}})}finally{this.controllerUnsubscribes=[]}}setupUrlSync(){this.enableUrlSync&&!this._hashChangeHandler&&(this._hashChangeHandler=this.handleHashChange.bind(this),window.addEventListener("hashchange",this._hashChangeHandler),this.handleHashChange())}teardownUrlSync(){this._hashChangeHandler&&(window.removeEventListener("hashchange",this._hashChangeHandler),this._hashChangeHandler=void 0)}handleHashChange(){const e=window.location.hash.match(/^#conversation\/(.+)$/);if(e){const t=decodeURIComponent(e[1]);t!==this.activeThreadId&&this.controller&&this.controller.switchThread(t)}}handleControllerStateChange(e){var t,i,n,s,a;if(e.messages&&(this.messages=e.messages),e.threads&&(this.threads=e.threads),e.suggestions&&e.suggestions.length>0&&(this.suggestions=e.suggestions),e.currentThreadId&&(this.activeThreadId=e.currentThreadId),this.enableUrlSync&&e.currentThreadId){const t=`#conversation/${encodeURIComponent(e.currentThreadId)}`;window.location.hash!==t&&history.replaceState(null,"",t)}if(this.chatStarted=(null===(t=e.messages)||void 0===t?void 0:t.length)>0,this.isBotTyping=e.isTyping||!1,this.statusText=e.statusText,this.isQueryRunning=e.isProcessing||!1,e.uploadedFiles&&(this.uploadedFiles=e.uploadedFiles),this.enableArtifacts){const t=null===(i=e.messages)||void 0===i?void 0:i.some(e=>{var t,i;return(null===(i=null===(t=e.metadata)||void 0===t?void 0:t.artifactIds)||void 0===i?void 0:i.length)>0});t||(this.isArtifactPanelOpen=!1,this.selectedArtifact=null)}if(this.enableArtifacts&&(null===(n=e.messages)||void 0===n?void 0:n.length)){const t=[...e.messages].reverse().find(e=>"bot"===e.sender),i=null===(s=null==t?void 0:t.metadata)||void 0===s?void 0:s.artifactIds;if(null==i?void 0:i.length){const e=i[i.length-1];if((null===(a=this.selectedArtifact)||void 0===a?void 0:a.id)!==e){const t=this.getArtifactPlugin(),i=null==t?void 0:t.getArtifact(e);i&&(this.selectedArtifact=i,this.isArtifactPanelOpen=!0)}}}}handleControllerMessageSent(e){this.isQueryRunning=!0,this.isBotTyping=!0}handleControllerMessageReceived(e){}handleControllerError(e){this.isQueryRunning=!1,this.isBotTyping=!1,console.error("Controller error:",e.error)}get resolvedI18n(){var e,t,i,n,s,a,o,r,l;const d=this.i18n;return{input:Object.assign(Object.assign({},Un.input),null!==(e=null==d?void 0:d.input)&&void 0!==e?e:{}),send:Object.assign(Object.assign({},Un.send),null!==(t=null==d?void 0:d.send)&&void 0!==t?t:{}),audio:Object.assign(Object.assign({},Un.audio),null!==(i=null==d?void 0:d.audio)&&void 0!==i?i:{}),modules:Object.assign(Object.assign({},Un.modules),null!==(n=null==d?void 0:d.modules)&&void 0!==n?n:{}),threads:Object.assign(Object.assign({},Un.threads),null!==(s=null==d?void 0:d.threads)&&void 0!==s?s:{}),messages:Object.assign(Object.assign({},Un.messages),null!==(a=null==d?void 0:d.messages)&&void 0!==a?a:{}),urlModal:Object.assign(Object.assign({},Un.urlModal),null!==(o=null==d?void 0:d.urlModal)&&void 0!==o?o:{}),artifactPanel:Object.assign(Object.assign({},Un.artifactPanel),null!==(r=null==d?void 0:d.artifactPanel)&&void 0!==r?r:{}),loading:Object.assign(Object.assign({},Un.loading),null!==(l=null==d?void 0:d.loading)&&void 0!==l?l:{})}}render(){var e;const t=this.resolvedI18n,i={boxed:this.boxed,showMessages:this.showMessages,messages:this.messages,isTyping:this.isBotTyping,loadingIndicator:this.loadingIndicator,loadingText:this.statusText||this.loadingText,chatStarted:this.chatStarted,suggestions:this.suggestions,inputBox:{placeholder:this.placeholder,disabled:this.disabled||this.isQueryRunning,currentInput:this.currentInput,uploadedFiles:this.uploadedFiles,isQueryRunning:this.isQueryRunning,showSendButton:this.showSendButton,enableFileUpload:this.enableFileUpload,fileUploadItems:[{id:"upload-file",label:"Upload File",icon:"upload"},{id:"upload-url",label:"Upload from URL",icon:"link"}],enableModuleSelection:this.enableModuleSelection,moduleOptions:this.moduleSelectOptions,selectedModules:this.selectedModules,moduleSelectionLabel:this.moduleSelectionLabel,renderModuleDisplay:this.renderModuleSelectedDisplay.bind(this),showAudioButton:this.showAudioButton,audioRecording:this._audio.state,audioMode:this._audioMode,i18n:t},enableThreads:this.showThreads,enableThreadCreation:this.enableThreadCreation,isThreadSidebarOpen:this.showThreads&&this.isThreadSidebarOpen,threadSidebar:this.showThreads?{threads:this.threads,activeThreadId:this.activeThreadId,editingThreadId:this._editingThreadId,i18n:t}:void 0,enableFileUpload:this.enableFileUpload,isDragging:this._isDragging,i18n:t,enableArtifacts:this.enableArtifacts,artifactPanel:this.enableArtifacts?{artifact:this.selectedArtifact,isOpen:this.isArtifactPanelOpen,renderContent:null!==(e=this.renderArtifactContent)&&void 0!==e?e:this.getPluginArtifactRenderer(),i18n:t}:void 0,urlModal:this.isUrlModalOpen?{isOpen:this.isUrlModalOpen,urlInput:this.urlInput,isLoading:this.isUrlLoading,error:this.urlModalError,selectedFileName:this.selectedUrlFileName,i18n:t}:void 0},n={message:{onRetry:this.handleRetry.bind(this),onRetryKeydown:()=>{},onCopy:this.handleCopyMessage.bind(this),onCopyKeydown:()=>{},onFileClick:this.handleFilePreview.bind(this)},suggestion:{onClick:this.handleSuggestionClick.bind(this),onKeydown:()=>{}},inputBox:{onInput:this.handleContentEditableInput.bind(this),onKeydown:this.handleKeyDown.bind(this),onFocus:this.handleInputFocus.bind(this),onBlur:this.handleInputBlur.bind(this),onSend:this.handleSendMessage.bind(this),onStop:this.handleStopQuery.bind(this),onSendKeydown:()=>{},onFileDropdownClick:this.handleFileDropdownClick.bind(this),onModuleChange:this.handleModuleSelectionChange.bind(this),onFileRemove:this.handleFileRemove.bind(this),onFileClick:this.handleFilePreview.bind(this),onAudioStart:this.handleAudioStart.bind(this),onAudioCancel:this.handleAudioCancel.bind(this),onAudioSend:this.handleAudioSend.bind(this)},threadSidebar:this.showThreads?{onCreateNew:()=>{var e;null===(e=this.controller)||void 0===e||e.createThread("New Chat")},onSelectThread:e=>{var t;this.enableUrlSync&&history.pushState(null,"",`#conversation/${encodeURIComponent(e)}`),null===(t=this.controller)||void 0===t||t.switchThread(e)},onDeleteThread:e=>{var t;null===(t=this.controller)||void 0===t||t.deleteThread(e)},onBookmarkThread:e=>{var t;null===(t=this.controller)||void 0===t||t.bookmarkThread(e)},onRenameThread:(e,t)=>{var i;null===(i=this.controller)||void 0===i||i.renameThread(e,t),this._editingThreadId=void 0}}:void 0,fileUploadArea:{onDragEnter:this.handleDragEnter.bind(this),onDragOver:this.handleDragOver.bind(this),onDragLeave:this.handleDragLeave.bind(this),onDrop:this.handleDrop.bind(this)},urlModal:this.isUrlModalOpen?{onClose:this.handleUrlModalClose.bind(this),onUrlInputChange:this.handleUrlInputChange.bind(this),onUrlInputKeydown:this.handleUrlInputKeydown.bind(this),onConfirm:this.handleUrlConfirm.bind(this),onAttachFile:this.handleUrlAttachFile.bind(this)}:void 0,artifactPanel:this.enableArtifacts?{onClose:this.handleArtifactPanelClose.bind(this),onCopy:this.handleArtifactCopy.bind(this)}:void 0,onToggleThreadSidebar:this.showThreads?this.toggleThreadSidebar.bind(this):void 0};return q`
|
|
4890
|
+
*/var Fn=function(e,t,i,n){for(var s,a=arguments.length,o=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n,r=e.length-1;r>=0;r--)(s=e[r])&&(o=(a<3?s(o):a>3?s(t,i,o):s(t,i))||o);return a>3&&o&&Object.defineProperty(t,i,o),o},Bn=function(e,t,i,n){return new(i||(i=Promise))(function(s,a){function o(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,r)}l((n=n.apply(e,t||[])).next())})};const Un={input:{placeholder:Ci("Type your message..."),chatInputAriaLabel:Ci("Chat input"),attachButton:Ci("Attach"),attachFilesAriaLabel:Ci("Attach files"),removeFileLabel:Ci("Remove file"),uploadingLabel:Ci("Uploading"),uploadingProgress:Ci("Uploading…"),dropFilesHere:Ci("Drop files here to upload")},send:{sendButton:Ci("Send"),stopButton:Ci("Stop"),sendMessageLabel:Ci("Send message"),stopQueryLabel:Ci("Stop query")},audio:{recordSpeechLabel:Ci("Record speech to text"),sendVoiceMessageLabel:Ci("Send voice message"),cancelRecordingLabel:Ci("Cancel recording"),speechToTextLabel:Ci("Speech to text"),voiceMessageLabel:Ci("Voice message"),convertToTextLabel:Ci("Convert to text"),sendAsVoiceMessageLabel:Ci("Send as voice message")},modules:{moduleSelectionLabel:Ci("Select Modules"),moduleSearchPlaceholder:Ci("Search modules..."),moduleSelectAriaLabel:Ci("Select modules"),modulesSelectedSuffix:Ci("modules selected")},threads:{conversationsTitle:Ci("Conversations"),bookmarksLabel:Ci("Bookmarks"),allConversationsLabel:Ci("All Conversations"),noConversationsLabel:Ci("No conversations yet"),newChatTitle:Ci("New Chat"),newConversationLabel:Ci("New conversation"),removeBookmarkLabel:Ci("Remove bookmark"),bookmarkLabel:Ci("Bookmark"),renameLabel:Ci("Rename"),deleteLabel:Ci("Delete"),moreOptionsLabel:Ci("More options"),showThreadsLabel:Ci("Show threads"),hideThreadsLabel:Ci("Hide threads")},messages:{attachedFilesLabel:Ci("Attached files"),copyMessageLabel:Ci("Copy message"),retryMessageLabel:Ci("Retry message"),retryButton:Ci("Retry"),startConversationLabel:Ci("Start a conversation"),suggestionPrefix:Ci("Select suggestion: "),loadingConversationLabel:Ci("Loading conversation…")},urlModal:{addUrlTitle:Ci("Add URL"),urlLabel:Ci("URL"),urlPlaceholder:Ci("Enter URL..."),loadFromUrlLabel:Ci("Load file from URL"),selectedFileLabel:Ci("Selected file"),loadingFromUrlLabel:Ci("Loading file from URL..."),cancelButton:Ci("Cancel"),addButton:Ci("Add")},artifactPanel:{copyCodeLabel:Ci("Copy code"),closePanelLabel:Ci("Close panel")},loading:{agentWorkingLabel:Ci("Agent is working...")}};let Vn=class extends(je(me)){constructor(){super(...arguments),this.requiredComponents=["nr-input","nr-button","nr-icon","nr-dropdown","nr-select","nr-modal","nr-popconfirm"],this.messages=[],this.currentInput="",this.isBotTyping=!1,this.isQueryRunning=!1,this.suggestions=[],this.chatStarted=!1,this.isRTL=!1,this.size=en.Medium,this.variant=tn.Default,this.loadingIndicator=Qi.Dots,this.loadingText=Ci("Agent is working..."),this.disabled=!1,this.placeholder=Ci("Type your message..."),this.showSendButton=!0,this.autoScroll=!0,this.showThreads=!1,this.enableThreadCreation=!1,this.threads=[],this.mode="chat",this.boxed=!1,this.enableUrlSync=!1,this.showMessages=!0,this.enableFileUpload=!1,this.uploadedFiles=[],this.actionButtons=[],this.enableModuleSelection=!1,this.modules=[],this.selectedModules=[],this.moduleSelectionLabel=Ci("Select Modules"),this.enableArtifacts=!1,this.showAudioButton=!1,this.focused=!1,this.isArtifactPanelOpen=!1,this.selectedArtifact=null,this.isThreadSidebarOpen=!0,this.isUrlModalOpen=!1,this.urlInput="",this.urlModalError="",this.isUrlLoading=!1,this.selectedUrlFileName="",this.isFilePreviewModalOpen=!1,this.previewFile=null,this._isDragging=!1,this._dragDepth=0,this.controllerUnsubscribes=[],this._audio=new Rn(this),this._audioMode="message",this._artifactResizeBound=!1,this.toggleThreadSidebar=()=>{this.isThreadSidebarOpen=!this.isThreadSidebarOpen}}get resolvedActionButtons(){var e;const t=null!==(e=this.actionButtons)&&void 0!==e?e:[];if(!this.enableFileUpload)return t;const i=t.some(e=>"attach"===(null==e?void 0:e.type));return i?t:[...t,{type:"attach",enabled:!0}]}get moduleSelectOptions(){return this.modules.map(e=>({value:e.id,label:e.name,icon:e.icon,disabled:!1===e.enabled,description:e.description}))}connectedCallback(){super.connectedCallback(),this.controller&&this.setupControllerIntegration(),this.setupUrlSync()}firstUpdated(){var e,t,i,n;null===(e=this.shadowRoot)||void 0===e||e.addEventListener("click",e=>{var t,i;const n=null===(i=(t=e.target).closest)||void 0===i?void 0:i.call(t,"[data-artifact-id]");if(n){const e=n.dataset.artifactId;e&&this.handleArtifactClick(e)}}),null===(t=this.shadowRoot)||void 0===t||t.addEventListener("nr-thread-edit",e=>{const t=e.detail;(null==t?void 0:t.threadId)&&(this._editingThreadId=t.threadId,this.requestUpdate(),this.updateComplete.then(()=>{var e;const t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".thread-item__rename-input");t&&(t.focus(),t.select())}))}),null===(i=this.shadowRoot)||void 0===i||i.addEventListener("click",e=>{var t,i;const n=null===(i=(t=e.target).closest)||void 0===i?void 0:i.call(t,"[data-selection-value]");if(n){const e=n.dataset.selectionValue;e&&this.controller&&this.controller.sendMessage(e)}}),null===(n=this.shadowRoot)||void 0===n||n.addEventListener("keydown",e=>{var t,i,n,s;const a=e;if("Enter"!==a.key&&" "!==a.key)return;const o=null===(i=(t=a.target).closest)||void 0===i?void 0:i.call(t,"[data-artifact-id]");if(o){a.preventDefault();const e=o.dataset.artifactId;return void(e&&this.handleArtifactClick(e))}const r=null===(s=(n=a.target).closest)||void 0===s?void 0:s.call(n,"[data-selection-value]");if(r){a.preventDefault();const e=r.dataset.selectionValue;e&&this.controller&&this.controller.sendMessage(e)}})}disconnectedCallback(){var e;super.disconnectedCallback(),this.controller&&this.cleanupControllerIntegration(),this.teardownUrlSync(),null===(e=this._artifactResizeCleanup)||void 0===e||e.call(this),this._artifactResizeBound=!1}updated(e){if(super.updated(e),e.has("controller")&&(this.cleanupControllerIntegration(),this.controller)){this.setupControllerIntegration();try{const e=this.controller.getState();this.handleControllerStateChange(e)}catch(e){}this.enableUrlSync&&this.handleHashChange(),this.syncActiveThreadToController()}if(e.has("activeThreadId")&&this.syncActiveThreadToController(),e.has("enableUrlSync")&&(this.enableUrlSync?this.setupUrlSync():this.teardownUrlSync()),this.controller&&!e.has("controller")){if(e.has("messages")||e.has("suggestions")||e.has("threads"))try{const e=this.controller.getState();this.handleControllerStateChange(e)}catch(e){}}e.has("messages")&&this.autoScroll&&this.messages.length>0&&this.scrollToLatestMessage(),this.updateArtifactPanelResize()}scrollToLatestMessage(){requestAnimationFrame(()=>{var e;const t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".messages");t&&(t.scrollTop=t.scrollHeight)})}setupControllerIntegration(){this.controller&&this.controllerUnsubscribes.push(this.controller.on("state:changed",this.handleControllerStateChange.bind(this)),this.controller.on("message:sent",this.handleControllerMessageSent.bind(this)),this.controller.on("message:received",this.handleControllerMessageReceived.bind(this)),this.controller.on("error",this.handleControllerError.bind(this)))}cleanupControllerIntegration(){if(this.controllerUnsubscribes.length)try{this.controllerUnsubscribes.forEach(e=>{try{e()}catch(e){}})}finally{this.controllerUnsubscribes=[]}}setupUrlSync(){this.enableUrlSync&&!this._hashChangeHandler&&(this._hashChangeHandler=this.handleHashChange.bind(this),window.addEventListener("hashchange",this._hashChangeHandler),this.handleHashChange())}teardownUrlSync(){this._hashChangeHandler&&(window.removeEventListener("hashchange",this._hashChangeHandler),this._hashChangeHandler=void 0)}handleHashChange(){const e=window.location.hash.match(/^#conversation\/(.+)$/);if(e){const t=decodeURIComponent(e[1]);t!==this.activeThreadId&&this.controller&&this.controller.switchThread(t)}}syncActiveThreadToController(){var e;if(!this.controller||!this.activeThreadId)return void(this._pendingThreadId=void 0);let t;try{t=this.controller.getState()}catch(e){t=null}if((null==t?void 0:t.currentThreadId)===this.activeThreadId)return void(this._pendingThreadId=void 0);const i=null===(e=null==t?void 0:t.threads)||void 0===e?void 0:e.some(e=>e.id===this.activeThreadId);if(i){this._pendingThreadId=void 0;try{this.controller.switchThread(this.activeThreadId)}catch(e){this._pendingThreadId=this.activeThreadId}}else this._pendingThreadId=this.activeThreadId}handleControllerStateChange(e){var t,i,n,s,a,o,r;if(e.messages&&(this.messages=e.messages),e.threads&&(this.threads=e.threads),e.suggestions&&e.suggestions.length>0&&(this.suggestions=e.suggestions),e.currentThreadId&&e.currentThreadId!==this.activeThreadId&&(this.activeThreadId=e.currentThreadId),this._pendingThreadId&&(null===(t=e.threads)||void 0===t?void 0:t.some(e=>e.id===this._pendingThreadId))){const e=this._pendingThreadId;this._pendingThreadId=void 0;try{null===(i=this.controller)||void 0===i||i.switchThread(e)}catch(t){this._pendingThreadId=e}}if(this.enableUrlSync&&e.currentThreadId){const t=`#conversation/${encodeURIComponent(e.currentThreadId)}`;window.location.hash!==t&&history.replaceState(null,"",t)}if(this.chatStarted=(null===(n=e.messages)||void 0===n?void 0:n.length)>0,this.isBotTyping=e.isTyping||!1,this.statusText=e.statusText,this.isQueryRunning=e.isProcessing||!1,e.uploadedFiles&&(this.uploadedFiles=e.uploadedFiles),this.enableArtifacts){const t=null===(s=e.messages)||void 0===s?void 0:s.some(e=>{var t,i;return(null===(i=null===(t=e.metadata)||void 0===t?void 0:t.artifactIds)||void 0===i?void 0:i.length)>0});t||(this.isArtifactPanelOpen=!1,this.selectedArtifact=null)}if(this.enableArtifacts&&(null===(a=e.messages)||void 0===a?void 0:a.length)){const t=[...e.messages].reverse().find(e=>"bot"===e.sender),i=null===(o=null==t?void 0:t.metadata)||void 0===o?void 0:o.artifactIds;if(null==i?void 0:i.length){const e=i[i.length-1];if((null===(r=this.selectedArtifact)||void 0===r?void 0:r.id)!==e){const t=this.getArtifactPlugin(),i=null==t?void 0:t.getArtifact(e);i&&(this.selectedArtifact=i,this.isArtifactPanelOpen=!0)}}}}handleControllerMessageSent(e){this.isQueryRunning=!0,this.isBotTyping=!0}handleControllerMessageReceived(e){}handleControllerError(e){this.isQueryRunning=!1,this.isBotTyping=!1,console.error("Controller error:",e.error)}get resolvedI18n(){var e,t,i,n,s,a,o,r,l;const d=this.i18n;return{input:Object.assign(Object.assign({},Un.input),null!==(e=null==d?void 0:d.input)&&void 0!==e?e:{}),send:Object.assign(Object.assign({},Un.send),null!==(t=null==d?void 0:d.send)&&void 0!==t?t:{}),audio:Object.assign(Object.assign({},Un.audio),null!==(i=null==d?void 0:d.audio)&&void 0!==i?i:{}),modules:Object.assign(Object.assign({},Un.modules),null!==(n=null==d?void 0:d.modules)&&void 0!==n?n:{}),threads:Object.assign(Object.assign({},Un.threads),null!==(s=null==d?void 0:d.threads)&&void 0!==s?s:{}),messages:Object.assign(Object.assign({},Un.messages),null!==(a=null==d?void 0:d.messages)&&void 0!==a?a:{}),urlModal:Object.assign(Object.assign({},Un.urlModal),null!==(o=null==d?void 0:d.urlModal)&&void 0!==o?o:{}),artifactPanel:Object.assign(Object.assign({},Un.artifactPanel),null!==(r=null==d?void 0:d.artifactPanel)&&void 0!==r?r:{}),loading:Object.assign(Object.assign({},Un.loading),null!==(l=null==d?void 0:d.loading)&&void 0!==l?l:{})}}render(){var e;const t=this.resolvedI18n,i={boxed:this.boxed,showMessages:this.showMessages,welcomeMessage:this.welcomeMessage,isPendingThread:!!this._pendingThreadId,messages:this.messages,isTyping:this.isBotTyping,loadingIndicator:this.loadingIndicator,loadingText:this.statusText||this.loadingText,chatStarted:this.chatStarted,suggestions:this.suggestions,inputBox:{placeholder:this.placeholder,disabled:this.disabled||this.isQueryRunning,currentInput:this.currentInput,uploadedFiles:this.uploadedFiles,isQueryRunning:this.isQueryRunning,showSendButton:this.showSendButton,enableFileUpload:this.resolvedActionButtons.some(e=>"attach"===(null==e?void 0:e.type)&&!1!==(null==e?void 0:e.enabled)),fileUploadItems:[{id:"upload-file",label:"Upload File",icon:"upload"},{id:"upload-url",label:"Upload from URL",icon:"link"}],enableModuleSelection:this.enableModuleSelection,moduleOptions:this.moduleSelectOptions,selectedModules:this.selectedModules,moduleSelectionLabel:this.moduleSelectionLabel,renderModuleDisplay:this.renderModuleSelectedDisplay.bind(this),showAudioButton:this.showAudioButton,audioRecording:this._audio.state,audioMode:this._audioMode,i18n:t},enableThreads:this.showThreads,enableThreadCreation:this.enableThreadCreation,isThreadSidebarOpen:this.showThreads&&this.isThreadSidebarOpen,threadSidebar:this.showThreads?{threads:this.threads,activeThreadId:this.activeThreadId,editingThreadId:this._editingThreadId,i18n:t}:void 0,enableFileUpload:this.enableFileUpload,isDragging:this._isDragging,i18n:t,enableArtifacts:this.enableArtifacts,artifactPanel:this.enableArtifacts?{artifact:this.selectedArtifact,isOpen:this.isArtifactPanelOpen,renderContent:null!==(e=this.renderArtifactContent)&&void 0!==e?e:this.getPluginArtifactRenderer(),i18n:t}:void 0,urlModal:this.isUrlModalOpen?{isOpen:this.isUrlModalOpen,urlInput:this.urlInput,isLoading:this.isUrlLoading,error:this.urlModalError,selectedFileName:this.selectedUrlFileName,i18n:t}:void 0},n={message:{onRetry:this.handleRetry.bind(this),onRetryKeydown:()=>{},onCopy:this.handleCopyMessage.bind(this),onCopyKeydown:()=>{},onFileClick:this.handleFilePreview.bind(this)},suggestion:{onClick:this.handleSuggestionClick.bind(this),onKeydown:()=>{}},inputBox:{onInput:this.handleContentEditableInput.bind(this),onKeydown:this.handleKeyDown.bind(this),onFocus:this.handleInputFocus.bind(this),onBlur:this.handleInputBlur.bind(this),onSend:this.handleSendMessage.bind(this),onStop:this.handleStopQuery.bind(this),onSendKeydown:()=>{},onFileDropdownClick:this.handleFileDropdownClick.bind(this),onModuleChange:this.handleModuleSelectionChange.bind(this),onFileRemove:this.handleFileRemove.bind(this),onFileClick:this.handleFilePreview.bind(this),onAudioStart:this.handleAudioStart.bind(this),onAudioCancel:this.handleAudioCancel.bind(this),onAudioSend:this.handleAudioSend.bind(this)},threadSidebar:this.showThreads?{onCreateNew:()=>{var e;null===(e=this.controller)||void 0===e||e.createThread("New Chat")},onSelectThread:e=>{var t;e!==this.activeThreadId&&(this.enableUrlSync&&history.pushState(null,"",`#conversation/${encodeURIComponent(e)}`),null===(t=this.controller)||void 0===t||t.switchThread(e),this.dispatchEvent(new CustomEvent("nr-thread-change",{detail:{threadId:e},bubbles:!0,composed:!0})))},onDeleteThread:e=>{var t;null===(t=this.controller)||void 0===t||t.deleteThread(e)},onBookmarkThread:e=>{var t;null===(t=this.controller)||void 0===t||t.bookmarkThread(e)},onRenameThread:(e,t)=>{var i;null===(i=this.controller)||void 0===i||i.renameThread(e,t),this._editingThreadId=void 0}}:void 0,fileUploadArea:{onDragEnter:this.handleDragEnter.bind(this),onDragOver:this.handleDragOver.bind(this),onDragLeave:this.handleDragLeave.bind(this),onDrop:this.handleDrop.bind(this)},urlModal:this.isUrlModalOpen?{onClose:this.handleUrlModalClose.bind(this),onUrlInputChange:this.handleUrlInputChange.bind(this),onUrlInputKeydown:this.handleUrlInputKeydown.bind(this),onConfirm:this.handleUrlConfirm.bind(this),onAttachFile:this.handleUrlAttachFile.bind(this)}:void 0,artifactPanel:this.enableArtifacts?{onClose:this.handleArtifactPanelClose.bind(this),onCopy:this.handleArtifactCopy.bind(this)}:void 0,onToggleThreadSidebar:this.showThreads?this.toggleThreadSidebar.bind(this):void 0};return q`
|
|
4882
4891
|
<div
|
|
4883
4892
|
class="chat-container ${Te({"chat-container--with-threads":this.showThreads,"chat-container--disabled":this.disabled,"chat-container--focused":this.focused,"chat-container--boxed":this.boxed})}"
|
|
4884
4893
|
dir=${this.isRTL?"rtl":"ltr"}
|
|
@@ -4901,7 +4910,7 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
4901
4910
|
<span class="module-display-multiple">
|
|
4902
4911
|
${e} ${this.resolvedI18n.modules.modulesSelectedSuffix}
|
|
4903
4912
|
</span>
|
|
4904
|
-
`}handleContentEditableInput(e){const t=e.target.textContent||"";this.currentInput=t,this.dispatchEventWithMetadata("nr-chatbot-input-changed",{metadata:{value:t}})}handleInputFocus(e){this.focused=!0,this.dispatchEventWithMetadata("nr-chatbot-input-focused",{metadata:{event:e}})}handleInputBlur(e){this.focused=!1,this.dispatchEventWithMetadata("nr-chatbot-input-blurred",{metadata:{event:e}})}clearInput(){var e;this.currentInput="";const t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".input-box__input");t&&(t.textContent="")}focusInput(){var e;const t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".input-box__input");t&&t.focus()}handleAudioStart(e){this._audioMode=e,this._audio.start()}handleAudioCancel(){this._audio.cancel()}handleAudioSend(){return Bn(this,void 0,void 0,function*(){var e;const t=yield this._audio.stop();if(!t)return;const i=this._audioMode;null===(e=this.onAudioRecorded)||void 0===e||e.call(this,t.blob,t.mimeType,t.duration,i),this.dispatchEvent(new CustomEvent("nr-chatbot-audio-recorded",{detail:{blob:t.blob,mimeType:t.mimeType,duration:t.duration,mode:i},bubbles:!0,composed:!0}))})}handleKeyDown(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),this.handleSendMessage())}handleSendMessage(){if(!this.currentInput.trim()||this.disabled)return;if(!this.controller)return void console.warn("nr-chatbot: No controller is attached; message will not be sent.");const e=this.uploadedFiles&&this.uploadedFiles.length>0?[...this.uploadedFiles]:void 0;this.controller.sendMessage(this.currentInput.trim(),{files:e,metadata:{selectedModules:this.selectedModules}}),this.clearInput(),this.chatStarted=!0,this.dispatchEventWithMetadata("nr-chatbot-message-sent",{metadata:{text:this.currentInput}})}handleStopQuery(){var e;try{null===(e=this.controller)||void 0===e||e.stop()}catch(e){console.warn("nr-chatbot: stop failed",e)}this.dispatchEventWithMetadata("nr-chatbot-query-stopped",{metadata:{action:"stop"}})}handleRetry(e){e.text&&(this.currentInput=e.text,this.handleSendMessage())}handleCopyMessage(e){const t=e.text;if(!t)return;const i=()=>{this.dispatchEventWithMetadata("nr-chatbot-message-copied",{metadata:{messageId:e.id}})};navigator.clipboard?navigator.clipboard.writeText(t).then(i).catch(()=>{this.copyViaFallback(t,i)}):this.copyViaFallback(t,i)}copyViaFallback(e,t){const i=document.createElement("textarea");i.value=e,i.style.position="fixed",i.style.left="-9999px",i.style.top="-9999px",document.body.appendChild(i),i.focus(),i.select();try{document.execCommand("copy"),t()}catch(e){}i.remove()}handleSuggestionClick(e){this.currentInput=e.text,this.handleSendMessage(),this.dispatchEventWithMetadata("nr-chatbot-suggestion-clicked",{metadata:{suggestion:e}})}handleModuleSelectionChange(e){const t=e.detail.value;this.selectedModules=t,this.dispatchEventWithMetadata("nr-chatbot-modules-selected",{metadata:{modules:t}})}handleFileDropdownClick(e){const t=e.detail.item.id;"upload-file"===t?this.openFileDialog():"upload-url"===t&&this.openUrlModal()}openFileDialog(){const e=document.createElement("input");e.type="file",e.multiple=!0,e.accept="image/*,application/pdf,text/*,video/*,audio/*",e.addEventListener("change",e=>Bn(this,void 0,void 0,function*(){var t;const i=e.target;if(i.files&&i.files.length>0){const e=Array.from(i.files);yield null===(t=this.controller)||void 0===t?void 0:t.uploadFiles(e)}})),e.click()}openUrlModal(){this.isUrlModalOpen=!0,this.urlInput="",this.urlModalError="",this.selectedUrlFileName=""}handleUrlModalClose(){this.isUrlModalOpen=!1,this.urlInput="",this.urlModalError="",this.isUrlLoading=!1,this.selectedUrlFileName=""}handleUrlInputChange(e){const t=e.target;this.urlInput=t.value,this.urlModalError=""}handleUrlInputKeydown(e){"Enter"===e.key&&(e.preventDefault(),this.handleUrlAttachFile())}handleUrlConfirm(){this.handleUrlModalClose()}handleUrlAttachFile(){return Bn(this,void 0,void 0,function*(){if(this.urlInput.trim()){this.isUrlLoading=!0,this.urlModalError="";try{const e=yield fetch(this.urlInput);if(!e.ok)throw new Error(`Failed to fetch file: ${e.statusText}`);const t=yield e.blob(),i=this.urlInput.split("/").pop()||"downloaded-file",n=new File([t],i,{type:t.type});this.selectedUrlFileName=i,this.controller&&(yield this.controller.uploadFiles([n])),this.isUrlLoading=!1,setTimeout(()=>{this.handleUrlModalClose()},1e3)}catch(e){this.isUrlLoading=!1,this.urlModalError=e instanceof Error?e.message:"Failed to load file from URL"}}else this.urlModalError="Please enter a URL"})}handleFileRemove(e){var t;null===(t=this.controller)||void 0===t||t.removeFile(e)}dragHasFiles(e){var t;const i=null===(t=e.dataTransfer)||void 0===t?void 0:t.types;if(!i)return!1;for(let e=0;e<i.length;e++)if("Files"===i[e])return!0;return!1}handleDragEnter(e){this.enableFileUpload&&!this.disabled&&this.dragHasFiles(e)&&(e.preventDefault(),this._dragDepth++,this._isDragging=!0)}handleDragOver(e){this.enableFileUpload&&!this.disabled&&this.dragHasFiles(e)&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"))}handleDragLeave(e){this.enableFileUpload&&!this.disabled&&this.dragHasFiles(e)&&(e.preventDefault(),this._dragDepth=Math.max(0,this._dragDepth-1),0===this._dragDepth&&(this._isDragging=!1))}handleDrop(e){return Bn(this,void 0,void 0,function*(){var t,i;if(!this.enableFileUpload||this.disabled)return;e.preventDefault(),this._dragDepth=0,this._isDragging=!1;const n=null===(t=e.dataTransfer)||void 0===t?void 0:t.files;n&&0!==n.length&&(yield null===(i=this.controller)||void 0===i?void 0:i.uploadFiles(Array.from(n)))})}handleFilePreview(e){this.previewFile=e,this.isFilePreviewModalOpen=!0}handleArtifactClick(e){if(!this.enableArtifacts||!this.controller)return;const t=this.getArtifactPlugin();if(!t)return;const i=t.getArtifact(e);i&&(this.selectedArtifact=i,this.isArtifactPanelOpen=!0)}handleArtifactPanelClose(){this.isArtifactPanelOpen=!1,this.selectedArtifact=null}updateArtifactPanelResize(){var e,t,i;const n=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".artifact-panel__resize-handle"),s=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".artifact-panel");if(!n||!s)return null===(i=this._artifactResizeCleanup)||void 0===i||i.call(this),void(this._artifactResizeBound=!1);if(this._artifactResizeBound)return;this._artifactResizeBound=!0;let a=!1,o=0,r=0;const l=e=>{if(!a)return;const t=e.clientX-o,i=s.parentElement,n=i?.85*i.getBoundingClientRect().width:1200,l=Number.parseInt(getComputedStyle(s).minWidth,10)||300,d=Math.max(l,Math.min(r-t,n));s.style.width=`${d}px`},d=()=>{a&&(a=!1,n.classList.remove("artifact-panel__resize-handle--active"),document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",d))},c=e=>{e.preventDefault(),a=!0,o=e.clientX,r=s.getBoundingClientRect().width,n.classList.add("artifact-panel__resize-handle--active"),document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",l),document.addEventListener("mouseup",d)};n.addEventListener("mousedown",c),this._artifactResizeCleanup=()=>{n.removeEventListener("mousedown",c),d()}}handleArtifactCopy(e){const t=e.content;t&&(navigator.clipboard?navigator.clipboard.writeText(t).catch(()=>{this.copyViaFallback(t,()=>{})}):this.copyViaFallback(t,()=>{}))}getArtifactPlugin(){var e;try{const t=null===(e=this.controller)||void 0===e?void 0:e.plugins;return t&&"function"==typeof t.get?t.get("artifact"):void 0}catch(e){return}}getPluginArtifactRenderer(){var e;try{const t=null===(e=this.controller)||void 0===e?void 0:e.plugins;if(!t||"function"!=typeof t.values)return;for(const e of t.values())if("function"==typeof e.renderArtifactContent)return t=>{const i=e.renderArtifactContent(t);if(i)return q`${Jt(i)}`};return}catch(e){return}}handleFilePreviewModalClose(){this.isFilePreviewModalOpen=!1,this.previewFile=null}addMessage(e){var t;const i=Object.assign({id:e.id||`msg-${Date.now()}`,sender:e.sender||Xi.User,text:e.text||"",timestamp:e.timestamp||(new Date).toISOString()},e);return null===(t=this.controller)||void 0===t||t.addMessage(i),this.chatStarted=!0,i}clearMessages(){this.messages=[],this.chatStarted=!1}};Vn.useShadowDom=!0,Vn.styles=on,Fn([_e({type:Array})],Vn.prototype,"messages",void 0),Fn([_e({type:String})],Vn.prototype,"currentInput",void 0),Fn([_e({type:Boolean})],Vn.prototype,"isBotTyping",void 0),Fn([_e({type:Boolean})],Vn.prototype,"isQueryRunning",void 0),Fn([_e({type:Array})],Vn.prototype,"suggestions",void 0),Fn([_e({type:Boolean})],Vn.prototype,"chatStarted",void 0),Fn([_e({type:Boolean})],Vn.prototype,"isRTL",void 0),Fn([_e({type:String})],Vn.prototype,"size",void 0),Fn([_e({type:String})],Vn.prototype,"variant",void 0),Fn([_e({type:String})],Vn.prototype,"loadingIndicator",void 0),Fn([_e({type:String})],Vn.prototype,"loadingText",void 0),Fn([_e({type:Boolean})],Vn.prototype,"disabled",void 0),Fn([_e({type:String})],Vn.prototype,"placeholder",void 0),Fn([_e({type:Object})],Vn.prototype,"i18n",void 0),Fn([_e({type:Boolean})],Vn.prototype,"showSendButton",void 0),Fn([_e({type:Boolean})],Vn.prototype,"autoScroll",void 0),Fn([_e({type:Boolean})],Vn.prototype,"showThreads",void 0),Fn([_e({type:Boolean})],Vn.prototype,"enableThreadCreation",void 0),Fn([_e({type:Array})],Vn.prototype,"threads",void 0),Fn([_e({type:String})],Vn.prototype,"activeThreadId",void 0),Fn([_e({type:String})],Vn.prototype,"mode",void 0),Fn([_e({type:Boolean,reflect:!0})],Vn.prototype,"boxed",void 0),Fn([_e({type:Boolean})],Vn.prototype,"enableUrlSync",void 0),Fn([_e({type:Boolean})],Vn.prototype,"showMessages",void 0),Fn([_e({type:Boolean})],Vn.prototype,"enableFileUpload",void 0),Fn([_e({type:Array})],Vn.prototype,"uploadedFiles",void 0),Fn([_e({type:Array})],Vn.prototype,"actionButtons",void 0),Fn([_e({type:Boolean})],Vn.prototype,"enableModuleSelection",void 0),Fn([_e({type:Array})],Vn.prototype,"modules",void 0),Fn([_e({type:Array})],Vn.prototype,"selectedModules",void 0),Fn([_e({type:String})],Vn.prototype,"moduleSelectionLabel",void 0),Fn([_e({type:Boolean})],Vn.prototype,"enableArtifacts",void 0),Fn([_e({type:Boolean,attribute:"show-audio-button"})],Vn.prototype,"showAudioButton",void 0),Fn([_e({type:Function})],Vn.prototype,"onAudioRecorded",void 0),Fn([_e({type:Function})],Vn.prototype,"renderArtifactContent",void 0),Fn([_e({type:Object})],Vn.prototype,"controller",void 0),Fn([xe()],Vn.prototype,"statusText",void 0),Fn([xe()],Vn.prototype,"focused",void 0),Fn([xe()],Vn.prototype,"isArtifactPanelOpen",void 0),Fn([xe()],Vn.prototype,"selectedArtifact",void 0),Fn([xe()],Vn.prototype,"isThreadSidebarOpen",void 0),Fn([xe()],Vn.prototype,"_editingThreadId",void 0),Fn([xe()],Vn.prototype,"isUrlModalOpen",void 0),Fn([xe()],Vn.prototype,"urlInput",void 0),Fn([xe()],Vn.prototype,"urlModalError",void 0),Fn([xe()],Vn.prototype,"isUrlLoading",void 0),Fn([xe()],Vn.prototype,"selectedUrlFileName",void 0),Fn([xe()],Vn.prototype,"isFilePreviewModalOpen",void 0),Fn([xe()],Vn.prototype,"previewFile",void 0),Fn([xe()],Vn.prototype,"_isDragging",void 0),Vn=Fn([(e,t)=>(e.addInitializer(Ei),e),ge("nr-chatbot")],Vn);
|
|
4913
|
+
`}handleContentEditableInput(e){const t=e.target.textContent||"";this.currentInput=t,this.dispatchEventWithMetadata("nr-chatbot-input-changed",{metadata:{value:t}})}handleInputFocus(e){this.focused=!0,this.dispatchEventWithMetadata("nr-chatbot-input-focused",{metadata:{event:e}})}handleInputBlur(e){this.focused=!1,this.dispatchEventWithMetadata("nr-chatbot-input-blurred",{metadata:{event:e}})}clearInput(){var e;this.currentInput="";const t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".input-box__input");t&&(t.textContent="")}focusInput(){var e;const t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".input-box__input");t&&t.focus()}handleAudioStart(e){this._audioMode=e,this._audio.start()}handleAudioCancel(){this._audio.cancel()}handleAudioSend(){return Bn(this,void 0,void 0,function*(){var e;const t=yield this._audio.stop();if(!t)return;const i=this._audioMode;null===(e=this.onAudioRecorded)||void 0===e||e.call(this,t.blob,t.mimeType,t.duration,i),this.dispatchEvent(new CustomEvent("nr-chatbot-audio-recorded",{detail:{blob:t.blob,mimeType:t.mimeType,duration:t.duration,mode:i},bubbles:!0,composed:!0}))})}handleKeyDown(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),this.handleSendMessage())}handleSendMessage(){if(!this.currentInput.trim()||this.disabled)return;if(!this.controller)return void console.warn("nr-chatbot: No controller is attached; message will not be sent.");const e=this.uploadedFiles&&this.uploadedFiles.length>0?[...this.uploadedFiles]:void 0;this.controller.sendMessage(this.currentInput.trim(),{files:e,metadata:{selectedModules:this.selectedModules}}),this.clearInput(),this.chatStarted=!0,this.dispatchEventWithMetadata("nr-chatbot-message-sent",{metadata:{text:this.currentInput}})}handleStopQuery(){var e;try{null===(e=this.controller)||void 0===e||e.stop()}catch(e){console.warn("nr-chatbot: stop failed",e)}this.dispatchEventWithMetadata("nr-chatbot-query-stopped",{metadata:{action:"stop"}})}handleRetry(e){e.text&&(this.currentInput=e.text,this.handleSendMessage())}handleCopyMessage(e){const t=e.text;if(!t)return;const i=()=>{this.dispatchEventWithMetadata("nr-chatbot-message-copied",{metadata:{messageId:e.id}})};navigator.clipboard?navigator.clipboard.writeText(t).then(i).catch(()=>{this.copyViaFallback(t,i)}):this.copyViaFallback(t,i)}copyViaFallback(e,t){const i=document.createElement("textarea");i.value=e,i.style.position="fixed",i.style.left="-9999px",i.style.top="-9999px",document.body.appendChild(i),i.focus(),i.select();try{document.execCommand("copy"),t()}catch(e){}i.remove()}handleSuggestionClick(e){this.currentInput=e.text,this.handleSendMessage(),this.dispatchEventWithMetadata("nr-chatbot-suggestion-clicked",{metadata:{suggestion:e}})}handleModuleSelectionChange(e){const t=e.detail.value;this.selectedModules=t,this.dispatchEventWithMetadata("nr-chatbot-modules-selected",{metadata:{modules:t}})}handleFileDropdownClick(e){const t=e.detail.item.id;"upload-file"===t?this.openFileDialog():"upload-url"===t&&this.openUrlModal()}openFileDialog(){const e=document.createElement("input");e.type="file",e.multiple=!0,e.accept="image/*,application/pdf,text/*,video/*,audio/*",e.addEventListener("change",e=>Bn(this,void 0,void 0,function*(){var t;const i=e.target;if(i.files&&i.files.length>0){const e=Array.from(i.files);yield null===(t=this.controller)||void 0===t?void 0:t.uploadFiles(e)}})),e.click()}openUrlModal(){this.isUrlModalOpen=!0,this.urlInput="",this.urlModalError="",this.selectedUrlFileName=""}handleUrlModalClose(){this.isUrlModalOpen=!1,this.urlInput="",this.urlModalError="",this.isUrlLoading=!1,this.selectedUrlFileName=""}handleUrlInputChange(e){const t=e.target;this.urlInput=t.value,this.urlModalError=""}handleUrlInputKeydown(e){"Enter"===e.key&&(e.preventDefault(),this.handleUrlAttachFile())}handleUrlConfirm(){this.handleUrlModalClose()}handleUrlAttachFile(){return Bn(this,void 0,void 0,function*(){if(this.urlInput.trim()){this.isUrlLoading=!0,this.urlModalError="";try{const e=yield fetch(this.urlInput);if(!e.ok)throw new Error(`Failed to fetch file: ${e.statusText}`);const t=yield e.blob(),i=this.urlInput.split("/").pop()||"downloaded-file",n=new File([t],i,{type:t.type});this.selectedUrlFileName=i,this.controller&&(yield this.controller.uploadFiles([n])),this.isUrlLoading=!1,setTimeout(()=>{this.handleUrlModalClose()},1e3)}catch(e){this.isUrlLoading=!1,this.urlModalError=e instanceof Error?e.message:"Failed to load file from URL"}}else this.urlModalError="Please enter a URL"})}handleFileRemove(e){var t;null===(t=this.controller)||void 0===t||t.removeFile(e)}dragHasFiles(e){var t;const i=null===(t=e.dataTransfer)||void 0===t?void 0:t.types;if(!i)return!1;for(let e=0;e<i.length;e++)if("Files"===i[e])return!0;return!1}handleDragEnter(e){this.enableFileUpload&&!this.disabled&&this.dragHasFiles(e)&&(e.preventDefault(),this._dragDepth++,this._isDragging=!0)}handleDragOver(e){this.enableFileUpload&&!this.disabled&&this.dragHasFiles(e)&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"))}handleDragLeave(e){this.enableFileUpload&&!this.disabled&&this.dragHasFiles(e)&&(e.preventDefault(),this._dragDepth=Math.max(0,this._dragDepth-1),0===this._dragDepth&&(this._isDragging=!1))}handleDrop(e){return Bn(this,void 0,void 0,function*(){var t,i;if(!this.enableFileUpload||this.disabled)return;e.preventDefault(),this._dragDepth=0,this._isDragging=!1;const n=null===(t=e.dataTransfer)||void 0===t?void 0:t.files;n&&0!==n.length&&(yield null===(i=this.controller)||void 0===i?void 0:i.uploadFiles(Array.from(n)))})}handleFilePreview(e){this.previewFile=e,this.isFilePreviewModalOpen=!0}handleArtifactClick(e){if(!this.enableArtifacts||!this.controller)return;const t=this.getArtifactPlugin();if(!t)return;const i=t.getArtifact(e);i&&(this.selectedArtifact=i,this.isArtifactPanelOpen=!0)}handleArtifactPanelClose(){this.isArtifactPanelOpen=!1,this.selectedArtifact=null}updateArtifactPanelResize(){var e,t,i;const n=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".artifact-panel__resize-handle"),s=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".artifact-panel");if(!n||!s)return null===(i=this._artifactResizeCleanup)||void 0===i||i.call(this),void(this._artifactResizeBound=!1);if(this._artifactResizeBound)return;this._artifactResizeBound=!0;let a=!1,o=0,r=0;const l=e=>{if(!a)return;const t=e.clientX-o,i=s.parentElement,n=i?.85*i.getBoundingClientRect().width:1200,l=Number.parseInt(getComputedStyle(s).minWidth,10)||300,d=Math.max(l,Math.min(r-t,n));s.style.width=`${d}px`},d=()=>{a&&(a=!1,n.classList.remove("artifact-panel__resize-handle--active"),document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",d))},c=e=>{e.preventDefault(),a=!0,o=e.clientX,r=s.getBoundingClientRect().width,n.classList.add("artifact-panel__resize-handle--active"),document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",l),document.addEventListener("mouseup",d)};n.addEventListener("mousedown",c),this._artifactResizeCleanup=()=>{n.removeEventListener("mousedown",c),d()}}handleArtifactCopy(e){const t=e.content;t&&(navigator.clipboard?navigator.clipboard.writeText(t).catch(()=>{this.copyViaFallback(t,()=>{})}):this.copyViaFallback(t,()=>{}))}getArtifactPlugin(){var e;try{const t=null===(e=this.controller)||void 0===e?void 0:e.plugins;return t&&"function"==typeof t.get?t.get("artifact"):void 0}catch(e){return}}getPluginArtifactRenderer(){var e;try{const t=null===(e=this.controller)||void 0===e?void 0:e.plugins;if(!t||"function"!=typeof t.values)return;for(const e of t.values())if("function"==typeof e.renderArtifactContent)return t=>{const i=e.renderArtifactContent(t);if(i)return q`${Jt(i)}`};return}catch(e){return}}handleFilePreviewModalClose(){this.isFilePreviewModalOpen=!1,this.previewFile=null}addMessage(e){var t;const i=Object.assign({id:e.id||`msg-${Date.now()}`,sender:e.sender||Xi.User,text:e.text||"",timestamp:e.timestamp||(new Date).toISOString()},e);return null===(t=this.controller)||void 0===t||t.addMessage(i),this.chatStarted=!0,i}clearMessages(){this.messages=[],this.chatStarted=!1}};Vn.useShadowDom=!0,Vn.styles=on,Fn([_e({type:Array})],Vn.prototype,"messages",void 0),Fn([_e({type:String})],Vn.prototype,"currentInput",void 0),Fn([_e({type:Boolean})],Vn.prototype,"isBotTyping",void 0),Fn([_e({type:Boolean})],Vn.prototype,"isQueryRunning",void 0),Fn([_e({type:Array})],Vn.prototype,"suggestions",void 0),Fn([_e({type:Boolean})],Vn.prototype,"chatStarted",void 0),Fn([_e({type:Boolean})],Vn.prototype,"isRTL",void 0),Fn([_e({type:String})],Vn.prototype,"size",void 0),Fn([_e({type:String})],Vn.prototype,"variant",void 0),Fn([_e({type:String})],Vn.prototype,"loadingIndicator",void 0),Fn([_e({type:String})],Vn.prototype,"loadingText",void 0),Fn([_e({type:Boolean})],Vn.prototype,"disabled",void 0),Fn([_e({type:String})],Vn.prototype,"placeholder",void 0),Fn([_e({type:Object})],Vn.prototype,"i18n",void 0),Fn([_e({type:Boolean})],Vn.prototype,"showSendButton",void 0),Fn([_e({type:Boolean})],Vn.prototype,"autoScroll",void 0),Fn([_e({type:Boolean})],Vn.prototype,"showThreads",void 0),Fn([_e({type:Boolean})],Vn.prototype,"enableThreadCreation",void 0),Fn([_e({type:Array})],Vn.prototype,"threads",void 0),Fn([_e({type:String,attribute:"active-thread-id"})],Vn.prototype,"activeThreadId",void 0),Fn([_e({type:String})],Vn.prototype,"mode",void 0),Fn([_e({type:Boolean,reflect:!0})],Vn.prototype,"boxed",void 0),Fn([_e({type:Boolean})],Vn.prototype,"enableUrlSync",void 0),Fn([_e({type:Boolean})],Vn.prototype,"showMessages",void 0),Fn([_e({type:String,attribute:"welcome-message"})],Vn.prototype,"welcomeMessage",void 0),Fn([_e({type:Boolean})],Vn.prototype,"enableFileUpload",void 0),Fn([_e({type:Array})],Vn.prototype,"uploadedFiles",void 0),Fn([_e({type:Array})],Vn.prototype,"actionButtons",void 0),Fn([_e({type:Boolean})],Vn.prototype,"enableModuleSelection",void 0),Fn([_e({type:Array})],Vn.prototype,"modules",void 0),Fn([_e({type:Array})],Vn.prototype,"selectedModules",void 0),Fn([_e({type:String})],Vn.prototype,"moduleSelectionLabel",void 0),Fn([_e({type:Boolean})],Vn.prototype,"enableArtifacts",void 0),Fn([_e({type:Boolean,attribute:"show-audio-button"})],Vn.prototype,"showAudioButton",void 0),Fn([_e({type:Function})],Vn.prototype,"onAudioRecorded",void 0),Fn([_e({type:Function})],Vn.prototype,"renderArtifactContent",void 0),Fn([_e({type:Object})],Vn.prototype,"controller",void 0),Fn([xe()],Vn.prototype,"statusText",void 0),Fn([xe()],Vn.prototype,"focused",void 0),Fn([xe()],Vn.prototype,"isArtifactPanelOpen",void 0),Fn([xe()],Vn.prototype,"selectedArtifact",void 0),Fn([xe()],Vn.prototype,"isThreadSidebarOpen",void 0),Fn([xe()],Vn.prototype,"_editingThreadId",void 0),Fn([xe()],Vn.prototype,"isUrlModalOpen",void 0),Fn([xe()],Vn.prototype,"urlInput",void 0),Fn([xe()],Vn.prototype,"urlModalError",void 0),Fn([xe()],Vn.prototype,"isUrlLoading",void 0),Fn([xe()],Vn.prototype,"selectedUrlFileName",void 0),Fn([xe()],Vn.prototype,"isFilePreviewModalOpen",void 0),Fn([xe()],Vn.prototype,"previewFile",void 0),Fn([xe()],Vn.prototype,"_isDragging",void 0),Fn([xe()],Vn.prototype,"_pendingThreadId",void 0),Vn=Fn([(e,t)=>(e.addInitializer(Ei),e),ge("nr-chatbot")],Vn);
|
|
4905
4914
|
/**
|
|
4906
4915
|
* @license
|
|
4907
4916
|
* Copyright 2023 Nuraly, Laabidi Aymen
|