@nuraly/lumenui 0.6.0 → 0.8.2
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 +167 -104
- package/dist/nuralyui.bundle.js.gz +0 -0
- package/dist/src/components/canvas/bundle.js +138 -64
- package/dist/src/components/canvas/bundle.js.gz +0 -0
- package/dist/src/components/chatbot/bundle.js +161 -87
- package/dist/src/components/chatbot/bundle.js.gz +0 -0
- package/dist/src/components/chatbot/chatbot.component.d.ts +26 -2
- package/dist/src/components/chatbot/chatbot.component.js +131 -15
- package/dist/src/components/chatbot/chatbot.style.js +84 -42
- package/dist/src/components/chatbot/chatbot.types.d.ts +3 -0
- package/dist/src/components/chatbot/templates/chatbot-main.template.d.ts +6 -0
- package/dist/src/components/chatbot/templates/chatbot-main.template.js +6 -4
- package/dist/src/components/chatbot/templates/message.template.d.ts +5 -8
- package/dist/src/components/chatbot/templates/message.template.js +64 -19
- package/package.json +1 -1
- package/packages/themes/dist/default.css +12 -0
|
Binary file
|
|
@@ -1042,10 +1042,10 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
1042
1042
|
display: flex;
|
|
1043
1043
|
width: 100%;
|
|
1044
1044
|
height: 100%;
|
|
1045
|
-
background-color: #ffffff;
|
|
1046
1045
|
border-radius: 8px;
|
|
1047
1046
|
position: relative;
|
|
1048
1047
|
border: 1px solid #e0e0e0;
|
|
1048
|
+
box-sizing: border-box;
|
|
1049
1049
|
}
|
|
1050
1050
|
|
|
1051
1051
|
.chatbot-container {
|
|
@@ -1070,13 +1070,24 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
1070
1070
|
min-width: 0;
|
|
1071
1071
|
}
|
|
1072
1072
|
|
|
1073
|
+
.chatbot-boxed-area {
|
|
1074
|
+
display: flex;
|
|
1075
|
+
flex-direction: column;
|
|
1076
|
+
flex: 1;
|
|
1077
|
+
min-height: 0;
|
|
1078
|
+
min-width: 0;
|
|
1079
|
+
width: 100%;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1073
1082
|
.chatbot-header {
|
|
1074
1083
|
display: flex;
|
|
1075
1084
|
align-items: center;
|
|
1076
1085
|
justify-content: space-between;
|
|
1077
1086
|
gap: 0.5rem;
|
|
1078
1087
|
padding: 0.5rem;
|
|
1079
|
-
|
|
1088
|
+
min-height: 43px;
|
|
1089
|
+
box-sizing: border-box;
|
|
1090
|
+
border-bottom: 1px solid var(--nuraly-color-divider, rgb(224, 224, 224));
|
|
1080
1091
|
}
|
|
1081
1092
|
|
|
1082
1093
|
.chatbot-content {
|
|
@@ -1088,7 +1099,6 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
1088
1099
|
}
|
|
1089
1100
|
|
|
1090
1101
|
:host([boxed]) .chat-container {
|
|
1091
|
-
background-color: #ffffff;
|
|
1092
1102
|
border: none;
|
|
1093
1103
|
border-radius: 0;
|
|
1094
1104
|
}
|
|
@@ -1099,22 +1109,15 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
1099
1109
|
|
|
1100
1110
|
:host([boxed]) .chatbot-main {
|
|
1101
1111
|
width: 100%;
|
|
1102
|
-
max-width: 768px;
|
|
1103
|
-
margin: 0 auto;
|
|
1104
|
-
background-color: #ffffff;
|
|
1105
1112
|
border: none;
|
|
1106
1113
|
border-radius: 0;
|
|
1107
1114
|
box-shadow: none;
|
|
1108
1115
|
height: 100%;
|
|
1109
1116
|
}
|
|
1110
1117
|
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
.chat-container--boxed.chat-container--with-threads .chatbot-main {
|
|
1117
|
-
background-color: #ffffff;
|
|
1118
|
+
:host([boxed]) .chatbot-boxed-area {
|
|
1119
|
+
max-width: 768px;
|
|
1120
|
+
margin: 0 auto;
|
|
1118
1121
|
}
|
|
1119
1122
|
|
|
1120
1123
|
.chat-container--boxed.chat-container--with-threads .chat-box {
|
|
@@ -1130,9 +1133,7 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
1130
1133
|
}
|
|
1131
1134
|
|
|
1132
1135
|
:host([boxed]) .chatbot-header {
|
|
1133
|
-
/* Keep header at the top */
|
|
1134
1136
|
flex: 0 0 auto;
|
|
1135
|
-
border-bottom: none;
|
|
1136
1137
|
}
|
|
1137
1138
|
|
|
1138
1139
|
:host([boxed]) .chatbot-content:has(.empty-state) {
|
|
@@ -1146,24 +1147,15 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
1146
1147
|
min-height: 0;
|
|
1147
1148
|
}
|
|
1148
1149
|
|
|
1149
|
-
:host([boxed]) .chatbot-main:has(.empty-state) {
|
|
1150
|
-
/* Make main container relative for absolute positioning */
|
|
1151
|
-
position: relative;
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
1150
|
:host([boxed]) .empty-state {
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
transform: translate(-50%, calc(-50% - 80px));
|
|
1151
|
+
display: flex;
|
|
1152
|
+
align-items: center;
|
|
1153
|
+
justify-content: center;
|
|
1154
|
+
flex-direction: column;
|
|
1160
1155
|
width: 100%;
|
|
1156
|
+
height: 100%;
|
|
1161
1157
|
max-width: 768px;
|
|
1162
|
-
height: auto;
|
|
1163
1158
|
padding: 0;
|
|
1164
|
-
display: flex;
|
|
1165
|
-
flex-direction: column;
|
|
1166
|
-
align-items: center;
|
|
1167
1159
|
gap: 1.5rem;
|
|
1168
1160
|
}
|
|
1169
1161
|
|
|
@@ -1172,13 +1164,9 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
1172
1164
|
}
|
|
1173
1165
|
|
|
1174
1166
|
:host([boxed]) .chatbot-content:has(.empty-state) + .input-box {
|
|
1175
|
-
/* Position input-box in the middle with empty state - moved up */
|
|
1176
|
-
position: absolute;
|
|
1177
|
-
top: 50%;
|
|
1178
|
-
left: 50%;
|
|
1179
|
-
transform: translate(-50%, calc(-50% + 40px));
|
|
1180
1167
|
width: 100%;
|
|
1181
1168
|
max-width: 768px;
|
|
1169
|
+
margin: 0 auto;
|
|
1182
1170
|
}
|
|
1183
1171
|
|
|
1184
1172
|
:host([boxed]) .suggestion-container {
|
|
@@ -1188,7 +1176,7 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
1188
1176
|
:host([boxed]) .messages {
|
|
1189
1177
|
box-shadow: none;
|
|
1190
1178
|
margin-bottom: 0;
|
|
1191
|
-
background-color:
|
|
1179
|
+
background-color: var(--chatbot-messages-bg, transparent);
|
|
1192
1180
|
align-items: stretch;
|
|
1193
1181
|
width: 98%;
|
|
1194
1182
|
padding: 8px 1.5rem;
|
|
@@ -1232,7 +1220,7 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
1232
1220
|
align-items: center;
|
|
1233
1221
|
justify-content: space-between;
|
|
1234
1222
|
padding: 0.75rem;
|
|
1235
|
-
border-bottom: 1px solid
|
|
1223
|
+
border-bottom: 1px solid var(--nuraly-color-divider, rgb(224, 224, 224));
|
|
1236
1224
|
}
|
|
1237
1225
|
|
|
1238
1226
|
.thread-sidebar__header h3 {
|
|
@@ -1443,17 +1431,23 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
1443
1431
|
|
|
1444
1432
|
.messages {
|
|
1445
1433
|
flex: 1;
|
|
1434
|
+
min-height: 0;
|
|
1446
1435
|
overflow-y: auto;
|
|
1447
1436
|
overflow-x: hidden;
|
|
1448
1437
|
display: flex;
|
|
1449
1438
|
flex-direction: column;
|
|
1450
1439
|
gap: 0;
|
|
1451
|
-
background-color:
|
|
1440
|
+
background-color: var(--chatbot-messages-bg, transparent);
|
|
1452
1441
|
padding: 8px 1rem;
|
|
1453
1442
|
box-sizing: border-box;
|
|
1454
1443
|
justify-content: flex-start; /* Always align messages to top */
|
|
1455
1444
|
}
|
|
1456
1445
|
|
|
1446
|
+
.messages--inverted {
|
|
1447
|
+
flex-direction: column-reverse;
|
|
1448
|
+
justify-content: flex-start;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1457
1451
|
.empty-state {
|
|
1458
1452
|
display: flex;
|
|
1459
1453
|
flex-direction: column;
|
|
@@ -1587,16 +1581,64 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
1587
1581
|
}
|
|
1588
1582
|
|
|
1589
1583
|
.message.user .message__content {
|
|
1590
|
-
background-color:
|
|
1591
|
-
color:
|
|
1584
|
+
background-color: var(--nuraly-color-user-bubble-bg, rgb(124, 58, 237));
|
|
1585
|
+
color: var(--nuraly-color-user-bubble-fg, rgb(255, 255, 255));
|
|
1592
1586
|
border-radius: var(--chatbot-radius, 8px);
|
|
1593
1587
|
border: 0 solid transparent;
|
|
1594
1588
|
box-shadow: none;
|
|
1595
1589
|
}
|
|
1596
1590
|
|
|
1597
|
-
.
|
|
1598
|
-
|
|
1591
|
+
.message__text-collapsible {
|
|
1592
|
+
position: relative;
|
|
1593
|
+
max-height: var(--chatbot-message-collapsed-height, 200px);
|
|
1594
|
+
overflow: hidden;
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
.message__text-collapsible--expanded {
|
|
1598
|
+
max-height: none;
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
.message__text-collapsible:not(.message__text-collapsible--expanded)::after {
|
|
1602
|
+
content: '';
|
|
1603
|
+
position: absolute;
|
|
1604
|
+
inset: auto 0 0 0;
|
|
1605
|
+
height: 48px;
|
|
1606
|
+
pointer-events: none;
|
|
1607
|
+
background: linear-gradient(
|
|
1608
|
+
to bottom,
|
|
1609
|
+
transparent,
|
|
1610
|
+
var(--nuraly-color-user-bubble-bg, rgb(124, 58, 237))
|
|
1611
|
+
);
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
.message__show-more-toggle {
|
|
1615
|
+
margin-top: 6px;
|
|
1616
|
+
background: transparent;
|
|
1617
|
+
border: 0;
|
|
1618
|
+
padding: 4px 0;
|
|
1619
|
+
font: inherit;
|
|
1620
|
+
font-size: 12px;
|
|
1621
|
+
font-weight: 500;
|
|
1599
1622
|
color: inherit;
|
|
1623
|
+
opacity: 0.85;
|
|
1624
|
+
cursor: pointer;
|
|
1625
|
+
text-decoration: underline;
|
|
1626
|
+
text-underline-offset: 2px;
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
.message__show-more-toggle:hover {
|
|
1630
|
+
opacity: 1;
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
.message__show-more-toggle:focus-visible {
|
|
1634
|
+
outline: 1px solid currentColor;
|
|
1635
|
+
outline-offset: 2px;
|
|
1636
|
+
border-radius: 2px;
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
.message.bot .message__content {
|
|
1640
|
+
background-color: var(--nuraly-color-bot-bubble-bg, transparent);
|
|
1641
|
+
color: var(--nuraly-color-bot-bubble-fg, inherit);
|
|
1600
1642
|
border-radius: 0;
|
|
1601
1643
|
border: 0 solid transparent;
|
|
1602
1644
|
box-shadow: none;
|
|
@@ -2641,10 +2683,10 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
2641
2683
|
.artifact-panel {
|
|
2642
2684
|
width: 400px;
|
|
2643
2685
|
min-width: 300px;
|
|
2686
|
+
min-height: 0;
|
|
2644
2687
|
flex-shrink: 0;
|
|
2645
2688
|
display: flex;
|
|
2646
2689
|
flex-direction: row;
|
|
2647
|
-
background-color: #ffffff;
|
|
2648
2690
|
overflow: hidden;
|
|
2649
2691
|
position: relative;
|
|
2650
2692
|
}
|
|
@@ -2946,15 +2988,7 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
2946
2988
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2947
2989
|
* SPDX-License-Identifier: MIT
|
|
2948
2990
|
*/
|
|
2949
|
-
function _t(e){if(!e)return"";const t=e instanceof Date?e:new Date(e);if(Number.isNaN(t.getTime()))return"";const i=new Date,n={hour:"numeric",minute:"2-digit",hour12:!0};if(t.toDateString()===i.toDateString())return t.toLocaleTimeString(void 0,n);const a=Object.assign({month:"short",day:"numeric"},n);return t.toLocaleDateString(void 0,a)}It.Image,It.Audio,It.Video,It.Document,It.Document,It.Document,It.Document,It.Archive,It.Archive,It.Code,It.Code,It.Code;const Rt={javascript:"JavaScript",typescript:"TypeScript",python:"Python",java:"Java",go:"Go",rust:"Rust",c:"C",cpp:"C++",csharp:"C#",ruby:"Ruby",php:"PHP",swift:"Swift",kotlin:"Kotlin",html:"HTML",css:"CSS",scss:"SCSS",sql:"SQL",graphql:"GraphQL",json:"JSON",yaml:"YAML",xml:"XML",toml:"TOML",markdown:"Markdown",md:"Markdown",bash:"Bash",shell:"Shell",sh:"Shell",zsh:"Zsh",dockerfile:"Dockerfile",makefile:"Makefile",text:"Text"};function Nt(e){return e.startsWith("image/")}function Dt(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 Lt(e,t,a){var o,s,r,l,c,d
|
|
2950
|
-
<div
|
|
2951
|
-
class="message ${h(v)}"
|
|
2952
|
-
part="message"
|
|
2953
|
-
data-sender="${e.sender}"
|
|
2954
|
-
data-id="${e.id}"
|
|
2955
|
-
>
|
|
2956
|
-
<div class="message__content" part="message-content">
|
|
2957
|
-
${f?
|
|
2991
|
+
function _t(e){if(!e)return"";const t=e instanceof Date?e:new Date(e);if(Number.isNaN(t.getTime()))return"";const i=new Date,n={hour:"numeric",minute:"2-digit",hour12:!0};if(t.toDateString()===i.toDateString())return t.toLocaleTimeString(void 0,n);const a=Object.assign({month:"short",day:"numeric"},n);return t.toLocaleDateString(void 0,a)}It.Image,It.Audio,It.Video,It.Document,It.Document,It.Document,It.Document,It.Archive,It.Archive,It.Code,It.Code,It.Code;const Rt={javascript:"JavaScript",typescript:"TypeScript",python:"Python",java:"Java",go:"Go",rust:"Rust",c:"C",cpp:"C++",csharp:"C#",ruby:"Ruby",php:"PHP",swift:"Swift",kotlin:"Kotlin",html:"HTML",css:"CSS",scss:"SCSS",sql:"SQL",graphql:"GraphQL",json:"JSON",yaml:"YAML",xml:"XML",toml:"TOML",markdown:"Markdown",md:"Markdown",bash:"Bash",shell:"Shell",sh:"Shell",zsh:"Zsh",dockerfile:"Dockerfile",makefile:"Makefile",text:"Text"};function Nt(e){return e.startsWith("image/")}function Dt(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 Lt(e,t,a){var o,s,r,l,c,d;const p=null===(o=e.text)||void 0===o?void 0:o.includes("[ERROR_START]"),b={error:!!e.error||p,introduction:!!e.introduction,[e.sender]:!0},f=e.sender,v=null!==(r=null===(s=e.text)||void 0===s?void 0:s.trim())&&void 0!==r?r:"",g=null!==(l=t.collapseThreshold)&&void 0!==l?l:0,m="user"===f&&!p&&g>0&&v.length>g,x=!m||!!(null===(c=t.isExpanded)||void 0===c?void 0:c.call(t,e.id)),y=p?
|
|
2958
2992
|
/**
|
|
2959
2993
|
* @license
|
|
2960
2994
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
@@ -2965,7 +2999,29 @@ function(e){const t=e.match(/\[ERROR_START\]\[ERROR_TITLE_START\]([\s\S]*?)\[ERR
|
|
|
2965
2999
|
${e?i`<div class="message__error-title" part="message-error-title">${e}</div>`:""}
|
|
2966
3000
|
<div class="message__error-description" part="message-error-description">${n}</div>
|
|
2967
3001
|
</div>
|
|
2968
|
-
`}return i`${e}`}(
|
|
3002
|
+
`}return i`${e}`}(v):(null===(d=null==e?void 0:e.metadata)||void 0===d?void 0:d.renderAsHtml)?u(v):u(v.replaceAll("\n","<br>"));return i`
|
|
3003
|
+
<div
|
|
3004
|
+
class="message ${h(b)}"
|
|
3005
|
+
part=${`message message-${f}`}
|
|
3006
|
+
data-sender="${e.sender}"
|
|
3007
|
+
data-id="${e.id}"
|
|
3008
|
+
>
|
|
3009
|
+
<div class="message__content" part=${`message-content message-content-${f}`}>
|
|
3010
|
+
${m?i`
|
|
3011
|
+
<div
|
|
3012
|
+
class="message__text-collapsible ${x?"message__text-collapsible--expanded":""}"
|
|
3013
|
+
part="message-text-collapsible"
|
|
3014
|
+
>
|
|
3015
|
+
<div class="message__text-inner">${y}</div>
|
|
3016
|
+
</div>
|
|
3017
|
+
<button
|
|
3018
|
+
class="message__show-more-toggle"
|
|
3019
|
+
part="message-show-more"
|
|
3020
|
+
type="button"
|
|
3021
|
+
data-message-toggle="${e.id}"
|
|
3022
|
+
aria-expanded="${x?"true":"false"}"
|
|
3023
|
+
>${x?a.messages.showLessLabel:a.messages.showMoreLabel}</button>
|
|
3024
|
+
`:y}
|
|
2969
3025
|
</div>
|
|
2970
3026
|
${e.files&&e.files.length>0?i`
|
|
2971
3027
|
<div class="message__attachments" part="message-attachments" role="list" aria-label="${a.messages.attachedFilesLabel}">
|
|
@@ -3051,18 +3107,34 @@ function(e){const t=e.match(/\[ERROR_START\]\[ERROR_TITLE_START\]([\s\S]*?)\[ERR
|
|
|
3051
3107
|
${a.messages.retryButton}
|
|
3052
3108
|
</nr-button>`:n}
|
|
3053
3109
|
</div>
|
|
3054
|
-
`}function jt(e,t,a,o,s){return i`
|
|
3055
|
-
<div class="
|
|
3056
|
-
|
|
3110
|
+
`}function jt(e,t,a,o,s,r,l,c){const d=0===e.length?l?function(e){return i`
|
|
3111
|
+
<div class="empty-state empty-state--loading" part="empty-state thread-loading">
|
|
3112
|
+
<slot name="thread-loading">
|
|
3113
|
+
<div class="spinner" part="thread-loading-spinner"></div>
|
|
3114
|
+
<div class="empty-state__content" part="empty-state-content">
|
|
3115
|
+
${e.messages.loadingConversationLabel}
|
|
3116
|
+
</div>
|
|
3117
|
+
</slot>
|
|
3118
|
+
</div>
|
|
3119
|
+
`}(s):function(e,t){const n=null!=t?t:e.messages.startConversationLabel;return i`
|
|
3057
3120
|
<div class="empty-state" part="empty-state">
|
|
3058
3121
|
<slot name="empty-state">
|
|
3059
3122
|
<div class="empty-state__content" part="empty-state-content">
|
|
3060
|
-
${
|
|
3123
|
+
${n}
|
|
3061
3124
|
</div>
|
|
3062
3125
|
</slot>
|
|
3063
3126
|
</div>
|
|
3064
|
-
`}(s):n
|
|
3065
|
-
|
|
3127
|
+
`}(s,r):n,p=e=>Lt(e,o,s);if(c){const n=[...e].reverse();return i`
|
|
3128
|
+
<div class="messages messages--inverted" part="messages">
|
|
3129
|
+
${a}
|
|
3130
|
+
${t}
|
|
3131
|
+
${b(n,e=>e.id,p)}
|
|
3132
|
+
${d}
|
|
3133
|
+
</div>
|
|
3134
|
+
`}return i`
|
|
3135
|
+
<div class="messages" part="messages">
|
|
3136
|
+
${d}
|
|
3137
|
+
${b(e,e=>e.id,p)}
|
|
3066
3138
|
${t}
|
|
3067
3139
|
${a}
|
|
3068
3140
|
</div>
|
|
@@ -3525,7 +3597,7 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
3525
3597
|
${a?i`<span class="loading-text" part="typing-text">${a.split("").map((e,t)=>i`<span class="loading-text__char" style="animation-delay:${.04*t}s">${" "===e?" ":e}</span>`)}</span>`:n}
|
|
3526
3598
|
</div>
|
|
3527
3599
|
</div>
|
|
3528
|
-
`}(e.isTyping,e.loadingIndicator||Mt.Spinner,e.loadingText):n,t.message,e.i18n)}
|
|
3600
|
+
`}(e.isTyping,e.loadingIndicator||Mt.Spinner,e.loadingText):n,t.message,e.i18n,e.welcomeMessage,e.isPendingThread,e.invertedScroll)}
|
|
3529
3601
|
<slot name="messages"></slot>
|
|
3530
3602
|
</div>
|
|
3531
3603
|
`:e.suggestions&&e.suggestions.length>0?i`
|
|
@@ -3600,11 +3672,13 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
3600
3672
|
</div>
|
|
3601
3673
|
`:n}(e,t)}
|
|
3602
3674
|
|
|
3603
|
-
<
|
|
3675
|
+
<div class="chatbot-boxed-area" part="boxed-area">
|
|
3676
|
+
<slot name="header"></slot>
|
|
3604
3677
|
|
|
3605
|
-
|
|
3678
|
+
${Wt(e,t)}
|
|
3606
3679
|
|
|
3607
|
-
|
|
3680
|
+
${Vt(e.inputBox,t.inputBox)}
|
|
3681
|
+
</div>
|
|
3608
3682
|
|
|
3609
3683
|
<slot name="footer"></slot>
|
|
3610
3684
|
</div>
|
|
@@ -3730,7 +3804,7 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
3730
3804
|
* @license
|
|
3731
3805
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
3732
3806
|
* SPDX-License-Identifier: MIT
|
|
3733
|
-
*/var Xt=function(e,t,i,n){for(var a,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n,r=e.length-1;r>=0;r--)(a=e[r])&&(s=(o<3?a(s):o>3?a(t,i,s):a(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s},Zt=function(e,t,i,n){return new(i||(i=Promise))(function(a,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function r(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};const ei={input:{placeholder:at("Type your message..."),chatInputAriaLabel:at("Chat input"),attachButton:at("Attach"),attachFilesAriaLabel:at("Attach files"),removeFileLabel:at("Remove file"),uploadingLabel:at("Uploading"),uploadingProgress:at("Uploading…"),dropFilesHere:at("Drop files here to upload")},send:{sendButton:at("Send"),stopButton:at("Stop"),sendMessageLabel:at("Send message"),stopQueryLabel:at("Stop query")},audio:{recordSpeechLabel:at("Record speech to text"),sendVoiceMessageLabel:at("Send voice message"),cancelRecordingLabel:at("Cancel recording"),speechToTextLabel:at("Speech to text"),voiceMessageLabel:at("Voice message"),convertToTextLabel:at("Convert to text"),sendAsVoiceMessageLabel:at("Send as voice message")},modules:{moduleSelectionLabel:at("Select Modules"),moduleSearchPlaceholder:at("Search modules..."),moduleSelectAriaLabel:at("Select modules"),modulesSelectedSuffix:at("modules selected")},threads:{conversationsTitle:at("Conversations"),bookmarksLabel:at("Bookmarks"),allConversationsLabel:at("All Conversations"),noConversationsLabel:at("No conversations yet"),newChatTitle:at("New Chat"),newConversationLabel:at("New conversation"),removeBookmarkLabel:at("Remove bookmark"),bookmarkLabel:at("Bookmark"),renameLabel:at("Rename"),deleteLabel:at("Delete"),moreOptionsLabel:at("More options"),showThreadsLabel:at("Show threads"),hideThreadsLabel:at("Hide threads")},messages:{attachedFilesLabel:at("Attached files"),copyMessageLabel:at("Copy message"),retryMessageLabel:at("Retry message"),retryButton:at("Retry"),startConversationLabel:at("Start a conversation"),suggestionPrefix:at("Select suggestion: ")},urlModal:{addUrlTitle:at("Add URL"),urlLabel:at("URL"),urlPlaceholder:at("Enter URL..."),loadFromUrlLabel:at("Load file from URL"),selectedFileLabel:at("Selected file"),loadingFromUrlLabel:at("Loading file from URL..."),cancelButton:at("Cancel"),addButton:at("Add")},artifactPanel:{copyCodeLabel:at("Copy code"),closePanelLabel:at("Close panel")},loading:{agentWorkingLabel:at("Agent is working...")}};let ti=class extends($e(t)){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=Et.Medium,this.variant=At.Default,this.loadingIndicator=Mt.Dots,this.loadingText=at("Agent is working..."),this.disabled=!1,this.placeholder=at("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=at("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 Qt(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,a;const o=e;if("Enter"!==o.key&&" "!==o.key)return;const s=null===(i=(t=o.target).closest)||void 0===i?void 0:i.call(t,"[data-artifact-id]");if(s){o.preventDefault();const e=s.dataset.artifactId;return void(e&&this.handleArtifactClick(e))}const r=null===(a=(n=o.target).closest)||void 0===a?void 0:a.call(n,"[data-selection-value]");if(r){o.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,a,o;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===(a=null==t?void 0:t.metadata)||void 0===a?void 0:a.artifactIds;if(null==i?void 0:i.length){const e=i[i.length-1];if((null===(o=this.selectedArtifact)||void 0===o?void 0:o.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,a,o,s,r,l;const c=this.i18n;return{input:Object.assign(Object.assign({},ei.input),null!==(e=null==c?void 0:c.input)&&void 0!==e?e:{}),send:Object.assign(Object.assign({},ei.send),null!==(t=null==c?void 0:c.send)&&void 0!==t?t:{}),audio:Object.assign(Object.assign({},ei.audio),null!==(i=null==c?void 0:c.audio)&&void 0!==i?i:{}),modules:Object.assign(Object.assign({},ei.modules),null!==(n=null==c?void 0:c.modules)&&void 0!==n?n:{}),threads:Object.assign(Object.assign({},ei.threads),null!==(a=null==c?void 0:c.threads)&&void 0!==a?a:{}),messages:Object.assign(Object.assign({},ei.messages),null!==(o=null==c?void 0:c.messages)&&void 0!==o?o:{}),urlModal:Object.assign(Object.assign({},ei.urlModal),null!==(s=null==c?void 0:c.urlModal)&&void 0!==s?s:{}),artifactPanel:Object.assign(Object.assign({},ei.artifactPanel),null!==(r=null==c?void 0:c.artifactPanel)&&void 0!==r?r:{}),loading:Object.assign(Object.assign({},ei.loading),null!==(l=null==c?void 0:c.loading)&&void 0!==l?l:{})}}render(){var e;const t=this.resolvedI18n,n={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},a={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 i`
|
|
3807
|
+
*/var Xt=function(e,t,i,n){for(var a,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n,r=e.length-1;r>=0;r--)(a=e[r])&&(s=(o<3?a(s):o>3?a(t,i,s):a(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s},Zt=function(e,t,i,n){return new(i||(i=Promise))(function(a,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function r(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};const ei={input:{placeholder:at("Type your message..."),chatInputAriaLabel:at("Chat input"),attachButton:at("Attach"),attachFilesAriaLabel:at("Attach files"),removeFileLabel:at("Remove file"),uploadingLabel:at("Uploading"),uploadingProgress:at("Uploading…"),dropFilesHere:at("Drop files here to upload")},send:{sendButton:at("Send"),stopButton:at("Stop"),sendMessageLabel:at("Send message"),stopQueryLabel:at("Stop query")},audio:{recordSpeechLabel:at("Record speech to text"),sendVoiceMessageLabel:at("Send voice message"),cancelRecordingLabel:at("Cancel recording"),speechToTextLabel:at("Speech to text"),voiceMessageLabel:at("Voice message"),convertToTextLabel:at("Convert to text"),sendAsVoiceMessageLabel:at("Send as voice message")},modules:{moduleSelectionLabel:at("Select Modules"),moduleSearchPlaceholder:at("Search modules..."),moduleSelectAriaLabel:at("Select modules"),modulesSelectedSuffix:at("modules selected")},threads:{conversationsTitle:at("Conversations"),bookmarksLabel:at("Bookmarks"),allConversationsLabel:at("All Conversations"),noConversationsLabel:at("No conversations yet"),newChatTitle:at("New Chat"),newConversationLabel:at("New conversation"),removeBookmarkLabel:at("Remove bookmark"),bookmarkLabel:at("Bookmark"),renameLabel:at("Rename"),deleteLabel:at("Delete"),moreOptionsLabel:at("More options"),showThreadsLabel:at("Show threads"),hideThreadsLabel:at("Hide threads")},messages:{attachedFilesLabel:at("Attached files"),copyMessageLabel:at("Copy message"),retryMessageLabel:at("Retry message"),retryButton:at("Retry"),startConversationLabel:at("Start a conversation"),suggestionPrefix:at("Select suggestion: "),loadingConversationLabel:at("Loading conversation…"),showMoreLabel:at("Show more"),showLessLabel:at("Show less")},urlModal:{addUrlTitle:at("Add URL"),urlLabel:at("URL"),urlPlaceholder:at("Enter URL..."),loadFromUrlLabel:at("Load file from URL"),selectedFileLabel:at("Selected file"),loadingFromUrlLabel:at("Loading file from URL..."),cancelButton:at("Cancel"),addButton:at("Add")},artifactPanel:{copyCodeLabel:at("Copy code"),closePanelLabel:at("Close panel")},loading:{agentWorkingLabel:at("Agent is working...")}};let ti=class extends($e(t)){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=Et.Medium,this.variant=At.Default,this.loadingIndicator=Mt.Dots,this.loadingText=at("Agent is working..."),this.disabled=!1,this.placeholder=at("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=at("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 Qt(this),this._audioMode="message",this._artifactResizeBound=!1,this._expandedMessageIds=new Set,this.messageCollapseThreshold=600,this.invertedScroll=!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;return t.some(e=>"attach"===(null==e?void 0:e.type))?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,a;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("click",e=>{var t,i;const n=null===(i=(t=e.target).closest)||void 0===i?void 0:i.call(t,"[data-message-toggle]");if(n){const e=n.dataset.messageToggle;if(e){const t=new Set(this._expandedMessageIds);t.has(e)?t.delete(e):t.add(e),this._expandedMessageIds=t}}}),null===(a=this.shadowRoot)||void 0===a||a.addEventListener("keydown",e=>{var t,i,n,a;const o=e;if("Enter"!==o.key&&" "!==o.key)return;const s=null===(i=(t=o.target).closest)||void 0===i?void 0:i.call(t,"[data-artifact-id]");if(s){o.preventDefault();const e=s.dataset.artifactId;return void(e&&this.handleArtifactClick(e))}const r=null===(a=(n=o.target).closest)||void 0===a?void 0:a.call(n,"[data-selection-value]");if(r){o.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.invertedScroll&&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);if(null===(e=null==t?void 0:t.threads)||void 0===e?void 0:e.some(e=>e.id===this.activeThreadId)){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,a,o,s,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===(a=e.messages)||void 0===a?void 0:a.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===(o=e.messages)||void 0===o?void 0:o.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===(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,a,o,s,r,l;const c=this.i18n;return{input:Object.assign(Object.assign({},ei.input),null!==(e=null==c?void 0:c.input)&&void 0!==e?e:{}),send:Object.assign(Object.assign({},ei.send),null!==(t=null==c?void 0:c.send)&&void 0!==t?t:{}),audio:Object.assign(Object.assign({},ei.audio),null!==(i=null==c?void 0:c.audio)&&void 0!==i?i:{}),modules:Object.assign(Object.assign({},ei.modules),null!==(n=null==c?void 0:c.modules)&&void 0!==n?n:{}),threads:Object.assign(Object.assign({},ei.threads),null!==(a=null==c?void 0:c.threads)&&void 0!==a?a:{}),messages:Object.assign(Object.assign({},ei.messages),null!==(o=null==c?void 0:c.messages)&&void 0!==o?o:{}),urlModal:Object.assign(Object.assign({},ei.urlModal),null!==(s=null==c?void 0:c.urlModal)&&void 0!==s?s:{}),artifactPanel:Object.assign(Object.assign({},ei.artifactPanel),null!==(r=null==c?void 0:c.artifactPanel)&&void 0!==r?r:{}),loading:Object.assign(Object.assign({},ei.loading),null!==(l=null==c?void 0:c.loading)&&void 0!==l?l:{})}}render(){var e;const t=this.resolvedI18n,n={boxed:this.boxed,showMessages:this.showMessages,welcomeMessage:this.welcomeMessage,isPendingThread:!!this._pendingThreadId,invertedScroll:this.invertedScroll,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},a={message:{onRetry:this.handleRetry.bind(this),onRetryKeydown:()=>{},onCopy:this.handleCopyMessage.bind(this),onCopyKeydown:()=>{},onFileClick:this.handleFilePreview.bind(this),collapseThreshold:this.messageCollapseThreshold,isExpanded:e=>this._expandedMessageIds.has(e)},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 i`
|
|
3734
3808
|
<div
|
|
3735
3809
|
class="chat-container ${h({"chat-container--with-threads":this.showThreads,"chat-container--disabled":this.disabled,"chat-container--focused":this.focused,"chat-container--boxed":this.boxed})}"
|
|
3736
3810
|
dir=${this.isRTL?"rtl":"ltr"}
|
|
@@ -3753,7 +3827,7 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
3753
3827
|
<span class="module-display-multiple">
|
|
3754
3828
|
${e} ${this.resolvedI18n.modules.modulesSelectedSuffix}
|
|
3755
3829
|
</span>
|
|
3756
|
-
`}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 Zt(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=>Zt(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 Zt(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 Zt(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"),a=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".artifact-panel");if(!n||!a)return null===(i=this._artifactResizeCleanup)||void 0===i||i.call(this),void(this._artifactResizeBound=!1);if(this._artifactResizeBound)return;this._artifactResizeBound=!0;let o=!1,s=0,r=0;const l=e=>{if(!o)return;const t=e.clientX-s,i=a.parentElement,n=i?.85*i.getBoundingClientRect().width:1200,l=Number.parseInt(getComputedStyle(a).minWidth,10)||300,c=Math.max(l,Math.min(r-t,n));a.style.width=`${c}px`},c=()=>{o&&(o=!1,n.classList.remove("artifact-panel__resize-handle--active"),document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",c))},d=e=>{e.preventDefault(),o=!0,s=e.clientX,r=a.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",c)};n.addEventListener("mousedown",d),this._artifactResizeCleanup=()=>{n.removeEventListener("mousedown",d),c()}}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 n=e.renderArtifactContent(t);if(n)return i`${u(n)}`};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||Tt.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}};ti.useShadowDom=!0,ti.styles=Pt,Xt([s({type:Array})],ti.prototype,"messages",void 0),Xt([s({type:String})],ti.prototype,"currentInput",void 0),Xt([s({type:Boolean})],ti.prototype,"isBotTyping",void 0),Xt([s({type:Boolean})],ti.prototype,"isQueryRunning",void 0),Xt([s({type:Array})],ti.prototype,"suggestions",void 0),Xt([s({type:Boolean})],ti.prototype,"chatStarted",void 0),Xt([s({type:Boolean})],ti.prototype,"isRTL",void 0),Xt([s({type:String})],ti.prototype,"size",void 0),Xt([s({type:String})],ti.prototype,"variant",void 0),Xt([s({type:String})],ti.prototype,"loadingIndicator",void 0),Xt([s({type:String})],ti.prototype,"loadingText",void 0),Xt([s({type:Boolean})],ti.prototype,"disabled",void 0),Xt([s({type:String})],ti.prototype,"placeholder",void 0),Xt([s({type:Object})],ti.prototype,"i18n",void 0),Xt([s({type:Boolean})],ti.prototype,"showSendButton",void 0),Xt([s({type:Boolean})],ti.prototype,"autoScroll",void 0),Xt([s({type:Boolean})],ti.prototype,"showThreads",void 0),Xt([s({type:Boolean})],ti.prototype,"enableThreadCreation",void 0),Xt([s({type:Array})],ti.prototype,"threads",void 0),Xt([s({type:String})],ti.prototype,"activeThreadId",void 0),Xt([s({type:String})],ti.prototype,"mode",void 0),Xt([s({type:Boolean,reflect:!0})],ti.prototype,"boxed",void 0),Xt([s({type:Boolean})],ti.prototype,"enableUrlSync",void 0),Xt([s({type:Boolean})],ti.prototype,"showMessages",void 0),Xt([s({type:Boolean})],ti.prototype,"enableFileUpload",void 0),Xt([s({type:Array})],ti.prototype,"uploadedFiles",void 0),Xt([s({type:Array})],ti.prototype,"actionButtons",void 0),Xt([s({type:Boolean})],ti.prototype,"enableModuleSelection",void 0),Xt([s({type:Array})],ti.prototype,"modules",void 0),Xt([s({type:Array})],ti.prototype,"selectedModules",void 0),Xt([s({type:String})],ti.prototype,"moduleSelectionLabel",void 0),Xt([s({type:Boolean})],ti.prototype,"enableArtifacts",void 0),Xt([s({type:Boolean,attribute:"show-audio-button"})],ti.prototype,"showAudioButton",void 0),Xt([s({type:Function})],ti.prototype,"onAudioRecorded",void 0),Xt([s({type:Function})],ti.prototype,"renderArtifactContent",void 0),Xt([s({type:Object})],ti.prototype,"controller",void 0),Xt([r()],ti.prototype,"statusText",void 0),Xt([r()],ti.prototype,"focused",void 0),Xt([r()],ti.prototype,"isArtifactPanelOpen",void 0),Xt([r()],ti.prototype,"selectedArtifact",void 0),Xt([r()],ti.prototype,"isThreadSidebarOpen",void 0),Xt([r()],ti.prototype,"_editingThreadId",void 0),Xt([r()],ti.prototype,"isUrlModalOpen",void 0),Xt([r()],ti.prototype,"urlInput",void 0),Xt([r()],ti.prototype,"urlModalError",void 0),Xt([r()],ti.prototype,"isUrlLoading",void 0),Xt([r()],ti.prototype,"selectedUrlFileName",void 0),Xt([r()],ti.prototype,"isFilePreviewModalOpen",void 0),Xt([r()],ti.prototype,"previewFile",void 0),Xt([r()],ti.prototype,"_isDragging",void 0),ti=Xt([(e,t)=>(e.addInitializer(rt),e),l("nr-chatbot")],ti);
|
|
3830
|
+
`}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 Zt(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=>Zt(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 Zt(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 Zt(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"),a=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".artifact-panel");if(!n||!a)return null===(i=this._artifactResizeCleanup)||void 0===i||i.call(this),void(this._artifactResizeBound=!1);if(this._artifactResizeBound)return;this._artifactResizeBound=!0;let o=!1,s=0,r=0;const l=e=>{if(!o)return;const t=e.clientX-s,i=a.parentElement,n=i?.85*i.getBoundingClientRect().width:1200,l=Number.parseInt(getComputedStyle(a).minWidth,10)||300,c=Math.max(l,Math.min(r-t,n));a.style.width=`${c}px`},c=()=>{o&&(o=!1,n.classList.remove("artifact-panel__resize-handle--active"),document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",c))},d=e=>{e.preventDefault(),o=!0,s=e.clientX,r=a.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",c)};n.addEventListener("mousedown",d),this._artifactResizeCleanup=()=>{n.removeEventListener("mousedown",d),c()}}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 n=e.renderArtifactContent(t);if(n)return i`${u(n)}`};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||Tt.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}};ti.useShadowDom=!0,ti.styles=Pt,Xt([s({type:Array})],ti.prototype,"messages",void 0),Xt([s({type:String})],ti.prototype,"currentInput",void 0),Xt([s({type:Boolean})],ti.prototype,"isBotTyping",void 0),Xt([s({type:Boolean})],ti.prototype,"isQueryRunning",void 0),Xt([s({type:Array})],ti.prototype,"suggestions",void 0),Xt([s({type:Boolean})],ti.prototype,"chatStarted",void 0),Xt([s({type:Boolean})],ti.prototype,"isRTL",void 0),Xt([s({type:String})],ti.prototype,"size",void 0),Xt([s({type:String})],ti.prototype,"variant",void 0),Xt([s({type:String})],ti.prototype,"loadingIndicator",void 0),Xt([s({type:String})],ti.prototype,"loadingText",void 0),Xt([s({type:Boolean})],ti.prototype,"disabled",void 0),Xt([s({type:String})],ti.prototype,"placeholder",void 0),Xt([s({type:Object})],ti.prototype,"i18n",void 0),Xt([s({type:Boolean})],ti.prototype,"showSendButton",void 0),Xt([s({type:Boolean})],ti.prototype,"autoScroll",void 0),Xt([s({type:Boolean})],ti.prototype,"showThreads",void 0),Xt([s({type:Boolean})],ti.prototype,"enableThreadCreation",void 0),Xt([s({type:Array})],ti.prototype,"threads",void 0),Xt([s({type:String,attribute:"active-thread-id"})],ti.prototype,"activeThreadId",void 0),Xt([s({type:String})],ti.prototype,"mode",void 0),Xt([s({type:Boolean,reflect:!0})],ti.prototype,"boxed",void 0),Xt([s({type:Boolean})],ti.prototype,"enableUrlSync",void 0),Xt([s({type:Boolean})],ti.prototype,"showMessages",void 0),Xt([s({type:String,attribute:"welcome-message"})],ti.prototype,"welcomeMessage",void 0),Xt([s({type:Boolean})],ti.prototype,"enableFileUpload",void 0),Xt([s({type:Array})],ti.prototype,"uploadedFiles",void 0),Xt([s({type:Array})],ti.prototype,"actionButtons",void 0),Xt([s({type:Boolean})],ti.prototype,"enableModuleSelection",void 0),Xt([s({type:Array})],ti.prototype,"modules",void 0),Xt([s({type:Array})],ti.prototype,"selectedModules",void 0),Xt([s({type:String})],ti.prototype,"moduleSelectionLabel",void 0),Xt([s({type:Boolean})],ti.prototype,"enableArtifacts",void 0),Xt([s({type:Boolean,attribute:"show-audio-button"})],ti.prototype,"showAudioButton",void 0),Xt([s({type:Function})],ti.prototype,"onAudioRecorded",void 0),Xt([s({type:Function})],ti.prototype,"renderArtifactContent",void 0),Xt([s({type:Object})],ti.prototype,"controller",void 0),Xt([r()],ti.prototype,"statusText",void 0),Xt([r()],ti.prototype,"focused",void 0),Xt([r()],ti.prototype,"isArtifactPanelOpen",void 0),Xt([r()],ti.prototype,"selectedArtifact",void 0),Xt([r()],ti.prototype,"isThreadSidebarOpen",void 0),Xt([r()],ti.prototype,"_editingThreadId",void 0),Xt([r()],ti.prototype,"isUrlModalOpen",void 0),Xt([r()],ti.prototype,"urlInput",void 0),Xt([r()],ti.prototype,"urlModalError",void 0),Xt([r()],ti.prototype,"isUrlLoading",void 0),Xt([r()],ti.prototype,"selectedUrlFileName",void 0),Xt([r()],ti.prototype,"isFilePreviewModalOpen",void 0),Xt([r()],ti.prototype,"previewFile",void 0),Xt([r()],ti.prototype,"_isDragging",void 0),Xt([r()],ti.prototype,"_pendingThreadId",void 0),Xt([r()],ti.prototype,"_expandedMessageIds",void 0),Xt([s({type:Number,attribute:"message-collapse-threshold"})],ti.prototype,"messageCollapseThreshold",void 0),Xt([s({type:Boolean,attribute:"inverted-scroll",reflect:!0})],ti.prototype,"invertedScroll",void 0),ti=Xt([(e,t)=>(e.addInitializer(rt),e),l("nr-chatbot")],ti);
|
|
3757
3831
|
/**
|
|
3758
3832
|
* @license
|
|
3759
3833
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
Binary file
|