@nuraly/lumenui 0.6.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 CHANGED
@@ -174,6 +174,28 @@ Or use our pre-built themes:
174
174
  <link rel="stylesheet" href="node_modules/@nuralyui/themes/carbon.css">
175
175
  ```
176
176
 
177
+ ### Required CSS (CDN consumers)
178
+
179
+ Components rely on theme tokens shipped in `@nuraly/lumenui` at `packages/themes/dist/default.css`. Pin the same `${VERSION}` you use for the JS bundle:
180
+
181
+ ```html
182
+ <link
183
+ rel="stylesheet"
184
+ href="https://cdn.jsdelivr.net/npm/@nuraly/lumenui@${VERSION}/packages/themes/dist/default.css"
185
+ />
186
+ ```
187
+
188
+ Concrete example with the current version:
189
+
190
+ ```html
191
+ <link
192
+ rel="stylesheet"
193
+ href="https://cdn.jsdelivr.net/npm/@nuraly/lumenui@0.7.0/packages/themes/dist/default.css"
194
+ />
195
+ ```
196
+
197
+ The `dist/cdn.js` loader auto-injects this `<link>` (tagged `data-nuralyui-themes`) when no `@nuraly/lumenui` or `@nuralyui/themes` stylesheet is already present. Link your own themes CSS first to override the default (for example to pick `carbon.css`) and the auto-inject is skipped.
198
+
177
199
  ## 🌍 Browser Support
178
200
 
179
201
  | Chrome | Firefox | Safari | Edge |
package/dist/cdn.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";!function(){var e=document.currentScript,t=(e&&e.src?e.src.replace(/\/cdn\.js(?:\?.*)?$/,""):"")+"/nuralyui.bundle.js";if(!document.querySelector('script[type="importmap"][data-nuralyui]')){var r=document.createElement("script");r.type="importmap",r.dataset.nuralyui="",r.textContent=JSON.stringify({imports:{"socket.io-client":"https://esm.sh/socket.io-client@4",mermaid:"https://esm.sh/mermaid@11"}}),document.head.appendChild(r)}var n=document.createElement("link");n.rel="modulepreload",n.href=t,n.crossOrigin="anonymous",document.head.appendChild(n);var c=document.createElement("script");c.type="module",c.src=t,document.head.appendChild(c)}()}();
1
+ !function(){"use strict";!function(){var e=document.currentScript,t=e&&e.src?e.src.replace(/\/cdn\.js(?:\?.*)?$/,""):"",n=t+"/nuralyui.bundle.js";if(!document.querySelector('script[type="importmap"][data-nuralyui]')){var a=document.createElement("script");a.type="importmap",a.dataset.nuralyui="",a.textContent=JSON.stringify({imports:{"socket.io-client":"https://esm.sh/socket.io-client@4",mermaid:"https://esm.sh/mermaid@11"}}),document.head.appendChild(a)}if(document.head&&!document.querySelector("style[data-nuralyui-fouc]")){var r=document.createElement("style");r.setAttribute("data-nuralyui-fouc",""),r.textContent="nr-chatbot:not(:defined), nr-chatbot:not(:defined) > * { visibility: hidden; }",document.head.appendChild(r)}if(document.head&&!document.querySelector("link[data-nuralyui-themes]")){for(var d=document.head.querySelectorAll('link[rel="stylesheet"]'),i=!1,u=0;u<d.length;u++){var c=d[u].getAttribute("href")||"";if(/@nuraly\/lumenui[^\"]*\/packages\/themes\//.test(c)||/@nuralyui\/themes\//.test(c)){i=!0;break}}if(!i&&t){var l=t.replace(/\/dist$/,"")+"/packages/themes/dist/default.css",s=document.createElement("link");s.rel="stylesheet",s.href=l,s.dataset.nuralyuiThemes="",document.head.appendChild(s)}}var o=document.createElement("link");o.rel="modulepreload",o.href=n,o.crossOrigin="anonymous",document.head.appendChild(o);var m=document.createElement("script");m.type="module",m.src=n,document.head.appendChild(m)}()}();
@@ -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
- border-bottom: 1px solid #e0e0e0;
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
- /* Boxed layout with threads: background comes from theme variable with white fallback */
2259
- :host([boxed]) .chat-container--boxed.chat-container--with-threads {
2260
- background-color: #ffffff;
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
- /* Position empty state in the center - moved up */
2303
- position: absolute;
2304
- top: 50%;
2305
- left: 50%;
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: #ffffff;
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 #e0e0e0;
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: #ffffff;
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: #7c3aed;
2738
- color: #ffffff;
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="message"
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="message-content">
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>`:""}
@@ -4197,17 +4186,26 @@ function un(e){if(!e)return"";const t=e instanceof Date?e:new Date(e);if(Number.
4197
4186
  ${i.messages.retryButton}
4198
4187
  </nr-button>`:K}
4199
4188
  </div>
4200
- `}function xn(e,t,i,n,s){return q`
4189
+ `}function xn(e,t,i,n,s,a,o){return q`
4201
4190
  <div class="messages" part="messages">
4202
- ${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`
4203
4201
  <div class="empty-state" part="empty-state">
4204
4202
  <slot name="empty-state">
4205
4203
  <div class="empty-state__content" part="empty-state-content">
4206
- ${e.messages.startConversationLabel}
4204
+ ${i}
4207
4205
  </div>
4208
4206
  </slot>
4209
4207
  </div>
4210
- `}(s):K}
4208
+ `}(s,a):K}
4211
4209
  ${e.map(e=>_n(e,n,s))}
4212
4210
  ${t}
4213
4211
  ${i}
@@ -4682,7 +4680,7 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
4682
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}
4683
4681
  </div>
4684
4682
  </div>
4685
- `}(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)}
4686
4684
  <slot name="messages"></slot>
4687
4685
  </div>
4688
4686
  `:e.suggestions&&e.suggestions.length>0?q`
@@ -4757,11 +4755,13 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
4757
4755
  </div>
4758
4756
  `:K}(e,t)}
4759
4757
 
4760
- <slot name="header"></slot>
4758
+ <div class="chatbot-boxed-area" part="boxed-area">
4759
+ <slot name="header"></slot>
4761
4760
 
4762
- ${jn(e,t)}
4761
+ ${jn(e,t)}
4763
4762
 
4764
- ${En(e.inputBox,t.inputBox)}
4763
+ ${En(e.inputBox,t.inputBox)}
4764
+ </div>
4765
4765
 
4766
4766
  <slot name="footer"></slot>
4767
4767
  </div>
@@ -4887,7 +4887,7 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
4887
4887
  * @license
4888
4888
  * Copyright 2023 Nuraly, Laabidi Aymen
4889
4889
  * SPDX-License-Identifier: MIT
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: ")},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`
4891
4891
  <div
4892
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})}"
4893
4893
  dir=${this.isRTL?"rtl":"ltr"}
@@ -4910,7 +4910,7 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
4910
4910
  <span class="module-display-multiple">
4911
4911
  ${e} ${this.resolvedI18n.modules.modulesSelectedSuffix}
4912
4912
  </span>
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})],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);
4914
4914
  /**
4915
4915
  * @license
4916
4916
  * Copyright 2023 Nuraly, Laabidi Aymen
Binary file