@nuraly/lumenui 0.8.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/dist/nuralyui.bundle.js +121 -58
- package/dist/nuralyui.bundle.js.gz +0 -0
- package/dist/src/components/canvas/bundle.js +135 -61
- package/dist/src/components/canvas/bundle.js.gz +0 -0
- package/dist/src/components/chatbot/bundle.js +103 -29
- package/dist/src/components/chatbot/bundle.js.gz +0 -0
- package/dist/src/components/chatbot/chatbot.component.d.ts +13 -0
- package/dist/src/components/chatbot/chatbot.component.js +50 -5
- package/dist/src/components/chatbot/chatbot.style.js +53 -0
- package/dist/src/components/chatbot/chatbot.types.d.ts +2 -0
- package/dist/src/components/chatbot/templates/chatbot-main.template.d.ts +2 -0
- package/dist/src/components/chatbot/templates/chatbot-main.template.js +1 -1
- package/dist/src/components/chatbot/templates/message.template.d.ts +3 -1
- package/dist/src/components/chatbot/templates/message.template.js +45 -12
- package/package.json +1 -1
package/dist/nuralyui.bundle.js
CHANGED
|
@@ -2590,6 +2590,11 @@ class Ai{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
2590
2590
|
justify-content: flex-start; /* Always align messages to top */
|
|
2591
2591
|
}
|
|
2592
2592
|
|
|
2593
|
+
.messages--inverted {
|
|
2594
|
+
flex-direction: column-reverse;
|
|
2595
|
+
justify-content: flex-start;
|
|
2596
|
+
}
|
|
2597
|
+
|
|
2593
2598
|
.empty-state {
|
|
2594
2599
|
display: flex;
|
|
2595
2600
|
flex-direction: column;
|
|
@@ -2730,6 +2735,54 @@ class Ai{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
2730
2735
|
box-shadow: none;
|
|
2731
2736
|
}
|
|
2732
2737
|
|
|
2738
|
+
.message__text-collapsible {
|
|
2739
|
+
position: relative;
|
|
2740
|
+
max-height: var(--chatbot-message-collapsed-height, 200px);
|
|
2741
|
+
overflow: hidden;
|
|
2742
|
+
}
|
|
2743
|
+
|
|
2744
|
+
.message__text-collapsible--expanded {
|
|
2745
|
+
max-height: none;
|
|
2746
|
+
}
|
|
2747
|
+
|
|
2748
|
+
.message__text-collapsible:not(.message__text-collapsible--expanded)::after {
|
|
2749
|
+
content: '';
|
|
2750
|
+
position: absolute;
|
|
2751
|
+
inset: auto 0 0 0;
|
|
2752
|
+
height: 48px;
|
|
2753
|
+
pointer-events: none;
|
|
2754
|
+
background: linear-gradient(
|
|
2755
|
+
to bottom,
|
|
2756
|
+
transparent,
|
|
2757
|
+
var(--nuraly-color-user-bubble-bg, rgb(124, 58, 237))
|
|
2758
|
+
);
|
|
2759
|
+
}
|
|
2760
|
+
|
|
2761
|
+
.message__show-more-toggle {
|
|
2762
|
+
margin-top: 6px;
|
|
2763
|
+
background: transparent;
|
|
2764
|
+
border: 0;
|
|
2765
|
+
padding: 4px 0;
|
|
2766
|
+
font: inherit;
|
|
2767
|
+
font-size: 12px;
|
|
2768
|
+
font-weight: 500;
|
|
2769
|
+
color: inherit;
|
|
2770
|
+
opacity: 0.85;
|
|
2771
|
+
cursor: pointer;
|
|
2772
|
+
text-decoration: underline;
|
|
2773
|
+
text-underline-offset: 2px;
|
|
2774
|
+
}
|
|
2775
|
+
|
|
2776
|
+
.message__show-more-toggle:hover {
|
|
2777
|
+
opacity: 1;
|
|
2778
|
+
}
|
|
2779
|
+
|
|
2780
|
+
.message__show-more-toggle:focus-visible {
|
|
2781
|
+
outline: 1px solid currentColor;
|
|
2782
|
+
outline-offset: 2px;
|
|
2783
|
+
border-radius: 2px;
|
|
2784
|
+
}
|
|
2785
|
+
|
|
2733
2786
|
.message.bot .message__content {
|
|
2734
2787
|
background-color: var(--nuraly-color-bot-bubble-bg, transparent);
|
|
2735
2788
|
color: var(--nuraly-color-bot-bubble-fg, inherit);
|
|
@@ -4076,31 +4129,45 @@ class Ai{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
4076
4129
|
* @license
|
|
4077
4130
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
4078
4131
|
* SPDX-License-Identifier: MIT
|
|
4079
|
-
*/;!function(e){e.User="user",e.Bot="bot",e.System="system"}(Xi||(Xi={})),function(e){e.Dots="dots",e.Spinner="spinner",e.Wave="wave",e.Typing="typing"}(Qi||(Qi={})),function(e){e.Small="small",e.Medium="medium",e.Large="large",e.Full="full"}(en||(en={})),function(e){e.Default="default",e.Minimal="minimal",e.Rounded="rounded",e.ChatGPT="chatgpt"}(tn||(tn={})),function(e){e.Default="default",e.Error="error",e.Success="success",e.Loading="loading",e.Pending="pending"}(nn||(nn={})),function(e){e.Image="image",e.Document="document",e.Audio="audio",e.Video="video",e.Archive="archive",e.Code="code",e.Unknown="unknown"}(sn||(sn={})),function(e){e.Upload="upload",e.Clear="clear",e.Export="export",e.Settings="settings",e.Microphone="microphone",e.Camera="camera",e.Attach="attach"}(an||(an={}));const rn=1e3,ln=100,dn=10485760,cn=5,hn=["image/jpeg","image/png","image/gif","image/webp","application/pdf","text/plain","text/csv","application/json","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],pn={"image/":sn.Image,"audio/":sn.Audio,"video/":sn.Video,"application/pdf":sn.Document,"application/msword":sn.Document,"application/vnd.openxmlformats-officedocument":sn.Document,"text/":sn.Document,"application/zip":sn.Archive,"application/x-rar":sn.Archive,"application/javascript":sn.Code,"text/html":sn.Code,"text/css":sn.Code};
|
|
4132
|
+
*/;!function(e){e.User="user",e.Bot="bot",e.System="system"}(Xi||(Xi={})),function(e){e.Dots="dots",e.Spinner="spinner",e.Wave="wave",e.Typing="typing"}(Qi||(Qi={})),function(e){e.Small="small",e.Medium="medium",e.Large="large",e.Full="full"}(en||(en={})),function(e){e.Default="default",e.Minimal="minimal",e.Rounded="rounded",e.ChatGPT="chatgpt"}(tn||(tn={})),function(e){e.Default="default",e.Error="error",e.Success="success",e.Loading="loading",e.Pending="pending"}(nn||(nn={})),function(e){e.Image="image",e.Document="document",e.Audio="audio",e.Video="video",e.Archive="archive",e.Code="code",e.Unknown="unknown"}(sn||(sn={})),function(e){e.Upload="upload",e.Clear="clear",e.Export="export",e.Settings="settings",e.Microphone="microphone",e.Camera="camera",e.Attach="attach"}(an||(an={}));const rn=1e3,ln=100,dn=10485760,cn=5,hn=["image/jpeg","image/png","image/gif","image/webp","application/pdf","text/plain","text/csv","application/json","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],pn={"image/":sn.Image,"audio/":sn.Audio,"video/":sn.Video,"application/pdf":sn.Document,"application/msword":sn.Document,"application/vnd.openxmlformats-officedocument":sn.Document,"text/":sn.Document,"application/zip":sn.Archive,"application/x-rar":sn.Archive,"application/javascript":sn.Code,"text/html":sn.Code,"text/css":sn.Code},{I:un}=ce,mn=()=>document.createComment(""),fn=(e,t,i)=>{const n=e._$AA.parentNode,s=void 0===t?e._$AB:t._$AA;if(void 0===i){const t=n.insertBefore(mn(),s),a=n.insertBefore(mn(),s);i=new un(t,a,e,e.options)}else{const t=i._$AB.nextSibling,a=i._$AM,o=a!==e;if(o){let t;i._$AQ?.(e),i._$AM=e,void 0!==i._$AP&&(t=e._$AU)!==a._$AU&&i._$AP(t)}if(t!==s||o){let e=i._$AA;for(;e!==t;){const t=e.nextSibling;n.insertBefore(e,s),e=t}}}return i},bn=(e,t,i=e)=>(e._$AI(t,i),e),gn={},vn=e=>{e._$AR(),e._$AA.remove()},yn=(e,t,i)=>{const n=new Map;for(let s=t;s<=i;s++)n.set(e[s],s);return n},_n=Se(class extends Le{constructor(e){if(super(e),e.type!==Me)throw Error("repeat() can only be used in text expressions")}dt(e,t,i){let n;void 0===i?i=t:void 0!==t&&(n=t);const s=[],a=[];let o=0;for(const t of e)s[o]=n?n(t,o):o,a[o]=i(t,o),o++;return{values:a,keys:s}}render(e,t,i){return this.dt(e,t,i).values}update(e,[t,i,n]){const s=(e=>e._$AH)(e),{values:a,keys:o}=this.dt(t,i,n);if(!Array.isArray(s))return this.ut=o,a;const r=this.ut??=[],l=[];let d,c,h=0,p=s.length-1,u=0,m=a.length-1;for(;h<=p&&u<=m;)if(null===s[h])h++;else if(null===s[p])p--;else if(r[h]===o[u])l[u]=bn(s[h],a[u]),h++,u++;else if(r[p]===o[m])l[m]=bn(s[p],a[m]),p--,m--;else if(r[h]===o[m])l[m]=bn(s[h],a[m]),fn(e,l[m+1],s[h]),h++,m--;else if(r[p]===o[u])l[u]=bn(s[p],a[u]),fn(e,s[h],s[p]),p--,u++;else if(void 0===d&&(d=yn(o,u,m),c=yn(r,h,p)),d.has(r[h]))if(d.has(r[p])){const t=c.get(o[u]),i=void 0!==t?s[t]:null;if(null===i){const t=fn(e,s[h]);bn(t,a[u]),l[u]=t}else l[u]=bn(i,a[u]),fn(e,s[h],i),s[t]=null;u++}else vn(s[p]),p--;else vn(s[h]),h++;for(;u<=m;){const t=fn(e,l[m+1]);bn(t,a[u]),l[u++]=t}for(;h<=p;){const e=s[h++];null!==e&&vn(e)}return this.ut=o,((e,t=gn)=>{e._$AH=t})(e,l),J}});
|
|
4080
4133
|
/**
|
|
4081
4134
|
* @license
|
|
4082
4135
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
4083
4136
|
* SPDX-License-Identifier: MIT
|
|
4084
4137
|
*/
|
|
4085
|
-
function
|
|
4138
|
+
function xn(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 s=Object.assign({month:"short",day:"numeric"},n);return t.toLocaleDateString(void 0,s)}function wn(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}const kn={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 $n(e){return kn[e]||e.charAt(0).toUpperCase()+e.slice(1)}function Mn(e){let t=wn(e);return t=t.replaceAll(/```([\s\S]*?)```/g,'<pre class="md-code"><code>$1</code></pre>'),t=t.replaceAll(/`([^`]+)`/g,'<code class="md-inline-code">$1</code>'),t=t.replaceAll(/^###[^\S\n]+(.+)$/gm,"<h3>$1</h3>"),t=t.replaceAll(/^##[^\S\n]+(.+)$/gm,"<h2>$1</h2>"),t=t.replaceAll(/^#[^\S\n]+(.+)$/gm,"<h1>$1</h1>"),t=t.replaceAll(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t=t.replaceAll(/\*([^*]+)\*/g,"<em>$1</em>"),t=t.replaceAll(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'),t=t.replaceAll(/(?:^|\n)-\s+(.+)(?=\n|$)/g,(e,t)=>`\n<ul><li>${t}</li></ul>`),t=t.replaceAll(/<ul>\s*<li>([\s\S]*?)<\/li>\s*<\/ul>\n<ul>/g,"<ul><li>$1</li>"),t=t.split(/\n\n+/).map(e=>/^(<h\d|<pre|<ul|<ol|<blockquote)/.test(e.trim())?e:`<p>${e.replaceAll("\n","<br/>")}</p>`).join("\n"),t}
|
|
4086
4139
|
/**
|
|
4087
4140
|
* @license
|
|
4088
4141
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
4089
4142
|
* SPDX-License-Identifier: MIT
|
|
4090
|
-
*/function
|
|
4091
|
-
<div
|
|
4092
|
-
class="message ${Te(p)}"
|
|
4093
|
-
part=${`message message-${u}`}
|
|
4094
|
-
data-sender="${e.sender}"
|
|
4095
|
-
data-id="${e.id}"
|
|
4096
|
-
>
|
|
4097
|
-
<div class="message__content" part=${`message-content message-content-${u}`}>
|
|
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`
|
|
4143
|
+
*/function Sn(e){return e.startsWith("image/")}function Ln(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 Tn(e,t,i){var n,s,a,o,r,l;const d=null===(n=e.text)||void 0===n?void 0:n.includes("[ERROR_START]"),c={error:!!e.error||d,introduction:!!e.introduction,[e.sender]:!0},h=e.sender,p=null!==(a=null===(s=e.text)||void 0===s?void 0:s.trim())&&void 0!==a?a:"",u=null!==(o=t.collapseThreshold)&&void 0!==o?o:0,m="user"===h&&!d&&u>0&&p.length>u,f=!m||!!(null===(r=t.isExpanded)||void 0===r?void 0:r.call(t,e.id)),b=d?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`
|
|
4099
4144
|
<div class="message__error-container" part="message-error">
|
|
4100
4145
|
${e?q`<div class="message__error-title" part="message-error-title">${e}</div>`:""}
|
|
4101
4146
|
<div class="message__error-description" part="message-error-description">${i}</div>
|
|
4102
4147
|
</div>
|
|
4103
|
-
`}return q`${e}`}(
|
|
4148
|
+
`}return q`${e}`}(p):(null===(l=null==e?void 0:e.metadata)||void 0===l?void 0:l.renderAsHtml)?Jt(p):Jt(p.replaceAll("\n","<br>"));return q`
|
|
4149
|
+
<div
|
|
4150
|
+
class="message ${Te(c)}"
|
|
4151
|
+
part=${`message message-${h}`}
|
|
4152
|
+
data-sender="${e.sender}"
|
|
4153
|
+
data-id="${e.id}"
|
|
4154
|
+
>
|
|
4155
|
+
<div class="message__content" part=${`message-content message-content-${h}`}>
|
|
4156
|
+
${m?q`
|
|
4157
|
+
<div
|
|
4158
|
+
class="message__text-collapsible ${f?"message__text-collapsible--expanded":""}"
|
|
4159
|
+
part="message-text-collapsible"
|
|
4160
|
+
>
|
|
4161
|
+
<div class="message__text-inner">${b}</div>
|
|
4162
|
+
</div>
|
|
4163
|
+
<button
|
|
4164
|
+
class="message__show-more-toggle"
|
|
4165
|
+
part="message-show-more"
|
|
4166
|
+
type="button"
|
|
4167
|
+
data-message-toggle="${e.id}"
|
|
4168
|
+
aria-expanded="${f?"true":"false"}"
|
|
4169
|
+
>${f?i.messages.showLessLabel:i.messages.showMoreLabel}</button>
|
|
4170
|
+
`:b}
|
|
4104
4171
|
</div>
|
|
4105
4172
|
${e.files&&e.files.length>0?q`
|
|
4106
4173
|
<div class="message__attachments" part="message-attachments" role="list" aria-label="${i.messages.attachedFilesLabel}">
|
|
@@ -4119,29 +4186,29 @@ function un(e){if(!e)return"";const t=e instanceof Date?e:new Date(e);if(Number.
|
|
|
4119
4186
|
title="${e.name}"
|
|
4120
4187
|
@click=${()=>{var i;return null===(i=t.onFileClick)||void 0===i?void 0:i.call(t,e)}}
|
|
4121
4188
|
>
|
|
4122
|
-
${
|
|
4189
|
+
${Sn(e.mimeType)&&(e.url||e.previewUrl)?q`
|
|
4123
4190
|
<img
|
|
4124
4191
|
class="file-thumb__image"
|
|
4125
4192
|
src="${e.previewUrl||e.url}"
|
|
4126
4193
|
alt="${e.name}"
|
|
4127
4194
|
/>
|
|
4128
4195
|
`:q`
|
|
4129
|
-
<div class="file-thumb__ext" data-ext="${
|
|
4130
|
-
<span class="file-thumb__ext-label">${
|
|
4196
|
+
<div class="file-thumb__ext" data-ext="${Ln(e.name,e.mimeType)}">
|
|
4197
|
+
<span class="file-thumb__ext-label">${Ln(e.name,e.mimeType)}</span>
|
|
4131
4198
|
</div>
|
|
4132
4199
|
`}
|
|
4133
4200
|
</div>
|
|
4134
4201
|
|
|
4135
4202
|
<div slot="content" class="message-file-preview-content">
|
|
4136
|
-
${
|
|
4203
|
+
${Sn(e.mimeType)&&(e.url||e.previewUrl)?q`
|
|
4137
4204
|
<img
|
|
4138
4205
|
src="${e.previewUrl||e.url}"
|
|
4139
4206
|
alt="${e.name}"
|
|
4140
4207
|
class="message-file-preview-image"
|
|
4141
4208
|
/>
|
|
4142
4209
|
`:q`
|
|
4143
|
-
<div class="file-preview-ext" data-ext="${
|
|
4144
|
-
${
|
|
4210
|
+
<div class="file-preview-ext" data-ext="${Ln(e.name,e.mimeType)}">
|
|
4211
|
+
${Ln(e.name,e.mimeType)}
|
|
4145
4212
|
</div>
|
|
4146
4213
|
`}
|
|
4147
4214
|
<div class="message-file-preview-info">
|
|
@@ -4157,7 +4224,7 @@ function un(e){if(!e)return"";const t=e instanceof Date?e:new Date(e);if(Number.
|
|
|
4157
4224
|
`:K}
|
|
4158
4225
|
<div class="message__footer" part="message-footer">
|
|
4159
4226
|
<div class="message__timestamp" part="message-timestamp">
|
|
4160
|
-
${
|
|
4227
|
+
${xn(e.timestamp)}
|
|
4161
4228
|
</div>
|
|
4162
4229
|
<nr-icon
|
|
4163
4230
|
name="copy"
|
|
@@ -4186,9 +4253,7 @@ function un(e){if(!e)return"";const t=e instanceof Date?e:new Date(e);if(Number.
|
|
|
4186
4253
|
${i.messages.retryButton}
|
|
4187
4254
|
</nr-button>`:K}
|
|
4188
4255
|
</div>
|
|
4189
|
-
`}function
|
|
4190
|
-
<div class="messages" part="messages">
|
|
4191
|
-
${0===e.length?o?function(e){return q`
|
|
4256
|
+
`}function Yn(e,t,i,n,s,a,o,r){const l=0===e.length?o?function(e){return q`
|
|
4192
4257
|
<div class="empty-state empty-state--loading" part="empty-state thread-loading">
|
|
4193
4258
|
<slot name="thread-loading">
|
|
4194
4259
|
<div class="spinner" part="thread-loading-spinner"></div>
|
|
@@ -4205,8 +4270,17 @@ function un(e){if(!e)return"";const t=e instanceof Date?e:new Date(e);if(Number.
|
|
|
4205
4270
|
</div>
|
|
4206
4271
|
</slot>
|
|
4207
4272
|
</div>
|
|
4208
|
-
`}(s,a):K
|
|
4209
|
-
|
|
4273
|
+
`}(s,a):K,d=e=>Tn(e,n,s);if(r){const n=[...e].reverse();return q`
|
|
4274
|
+
<div class="messages messages--inverted" part="messages">
|
|
4275
|
+
${i}
|
|
4276
|
+
${t}
|
|
4277
|
+
${_n(n,e=>e.id,d)}
|
|
4278
|
+
${l}
|
|
4279
|
+
</div>
|
|
4280
|
+
`}return q`
|
|
4281
|
+
<div class="messages" part="messages">
|
|
4282
|
+
${l}
|
|
4283
|
+
${_n(e,e=>e.id,d)}
|
|
4210
4284
|
${t}
|
|
4211
4285
|
${i}
|
|
4212
4286
|
</div>
|
|
@@ -4215,7 +4289,7 @@ function un(e){if(!e)return"";const t=e instanceof Date?e:new Date(e);if(Number.
|
|
|
4215
4289
|
* @license
|
|
4216
4290
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
4217
4291
|
* SPDX-License-Identifier: MIT
|
|
4218
|
-
*/function
|
|
4292
|
+
*/function Cn(e,t,i,n){return t.length>0?q`
|
|
4219
4293
|
<div class="suggestion-container" part="suggestions">
|
|
4220
4294
|
${t.map(e=>function(e,t,i){return q`
|
|
4221
4295
|
<div
|
|
@@ -4233,24 +4307,13 @@ function un(e){if(!e)return"";const t=e instanceof Date?e:new Date(e);if(Number.
|
|
|
4233
4307
|
`}(e,i,n))}
|
|
4234
4308
|
</div>
|
|
4235
4309
|
`:K}
|
|
4236
|
-
/**
|
|
4237
|
-
* @license
|
|
4238
|
-
* Copyright 2020 Google LLC
|
|
4239
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
4240
|
-
*/const{I:kn}=ce,$n=()=>document.createComment(""),Mn=(e,t,i)=>{const n=e._$AA.parentNode,s=void 0===t?e._$AB:t._$AA;if(void 0===i){const t=n.insertBefore($n(),s),a=n.insertBefore($n(),s);i=new kn(t,a,e,e.options)}else{const t=i._$AB.nextSibling,a=i._$AM,o=a!==e;if(o){let t;i._$AQ?.(e),i._$AM=e,void 0!==i._$AP&&(t=e._$AU)!==a._$AU&&i._$AP(t)}if(t!==s||o){let e=i._$AA;for(;e!==t;){const t=e.nextSibling;n.insertBefore(e,s),e=t}}}return i},Sn=(e,t,i=e)=>(e._$AI(t,i),e),Ln={},Tn=e=>{e._$AR(),e._$AA.remove()},Yn=(e,t,i)=>{const n=new Map;for(let s=t;s<=i;s++)n.set(e[s],s);return n},Cn=Se(class extends Le{constructor(e){if(super(e),e.type!==Me)throw Error("repeat() can only be used in text expressions")}dt(e,t,i){let n;void 0===i?i=t:void 0!==t&&(n=t);const s=[],a=[];let o=0;for(const t of e)s[o]=n?n(t,o):o,a[o]=i(t,o),o++;return{values:a,keys:s}}render(e,t,i){return this.dt(e,t,i).values}update(e,[t,i,n]){const s=(e=>e._$AH)(e),{values:a,keys:o}=this.dt(t,i,n);if(!Array.isArray(s))return this.ut=o,a;const r=this.ut??=[],l=[];let d,c,h=0,p=s.length-1,u=0,m=a.length-1;for(;h<=p&&u<=m;)if(null===s[h])h++;else if(null===s[p])p--;else if(r[h]===o[u])l[u]=Sn(s[h],a[u]),h++,u++;else if(r[p]===o[m])l[m]=Sn(s[p],a[m]),p--,m--;else if(r[h]===o[m])l[m]=Sn(s[h],a[m]),Mn(e,l[m+1],s[h]),h++,m--;else if(r[p]===o[u])l[u]=Sn(s[p],a[u]),Mn(e,s[h],s[p]),p--,u++;else if(void 0===d&&(d=Yn(o,u,m),c=Yn(r,h,p)),d.has(r[h]))if(d.has(r[p])){const t=c.get(o[u]),i=void 0!==t?s[t]:null;if(null===i){const t=Mn(e,s[h]);Sn(t,a[u]),l[u]=t}else l[u]=Sn(i,a[u]),Mn(e,s[h],i),s[t]=null;u++}else Tn(s[p]),p--;else Tn(s[h]),h++;for(;u<=m;){const t=Mn(e,l[m+1]);Sn(t,a[u]),l[u++]=t}for(;h<=p;){const e=s[h++];null!==e&&Tn(e)}return this.ut=o,((e,t=Ln)=>{e._$AH=t})(e,l),J}});
|
|
4241
|
-
/**
|
|
4242
|
-
* @license
|
|
4243
|
-
* Copyright 2017 Google LLC
|
|
4244
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
4245
|
-
*/
|
|
4246
4310
|
/**
|
|
4247
4311
|
* @license
|
|
4248
4312
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
4249
4313
|
* SPDX-License-Identifier: MIT
|
|
4250
|
-
*/
|
|
4251
|
-
function Dn(e,t,i,n){const s=(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"},a=e=>e.startsWith("image/");return q`
|
|
4314
|
+
*/function Dn(e,t,i,n){const s=(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"},a=e=>e.startsWith("image/");return q`
|
|
4252
4315
|
<div class="context-tags-row" part="context-tags">
|
|
4253
|
-
${
|
|
4316
|
+
${_n(e,e=>e.id,e=>q`
|
|
4254
4317
|
<nr-dropdown
|
|
4255
4318
|
trigger="hover"
|
|
4256
4319
|
placement="top"
|
|
@@ -4568,7 +4631,7 @@ function Dn(e,t,i,n){const s=(e,t)=>{const i=e.lastIndexOf(".");if(i>=0&&i<e.len
|
|
|
4568
4631
|
<div class="thread-item__preview" part="thread-preview">
|
|
4569
4632
|
${s}
|
|
4570
4633
|
</div>
|
|
4571
|
-
<div class="thread-item__timestamp" part="thread-timestamp">${
|
|
4634
|
+
<div class="thread-item__timestamp" part="thread-timestamp">${xn(e.updatedAt)}</div>
|
|
4572
4635
|
</div>
|
|
4573
4636
|
`}function On(e,t){if(!e.isOpen||!e.file)return K;const i=e.file,n=i.mimeType.startsWith("image/"),s="application/pdf"===i.mimeType||i.name.toLowerCase().endsWith(".pdf");return q`
|
|
4574
4637
|
<nr-modal
|
|
@@ -4625,7 +4688,7 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
4625
4688
|
* @license
|
|
4626
4689
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
4627
4690
|
* SPDX-License-Identifier: MIT
|
|
4628
|
-
*/function In(e,t){var i;if(!e.isOpen||!e.artifact)return K;const n=e.artifact,s
|
|
4691
|
+
*/function In(e,t){var i;if(!e.isOpen||!e.artifact)return K;const n=e.artifact,s=$n(n.language);return q`
|
|
4629
4692
|
<div class="artifact-panel" part="artifact-panel">
|
|
4630
4693
|
<div class="artifact-panel__resize-handle" part="artifact-panel-resize-handle">
|
|
4631
4694
|
<div class="artifact-panel__resize-bar" part="artifact-panel-resize-bar"></div>
|
|
@@ -4656,7 +4719,7 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
4656
4719
|
</div>
|
|
4657
4720
|
</div>
|
|
4658
4721
|
<div class="artifact-panel__content" part="artifact-panel-content">
|
|
4659
|
-
${(null===(i=e.renderContent)||void 0===i?void 0:i.call(e,n))||function(e){switch(e.language){case"json":{let t;try{t=JSON.stringify(JSON.parse(e.content),null,2)}catch(i){t=e.content}return q`<pre class="artifact-panel__code" part="artifact-panel-code"><code>${t}</code></pre>`}case"md":case"markdown":return q`<div class="artifact-panel__rendered-md" part="artifact-panel-md">${Jt(
|
|
4722
|
+
${(null===(i=e.renderContent)||void 0===i?void 0:i.call(e,n))||function(e){switch(e.language){case"json":{let t;try{t=JSON.stringify(JSON.parse(e.content),null,2)}catch(i){t=e.content}return q`<pre class="artifact-panel__code" part="artifact-panel-code"><code>${t}</code></pre>`}case"md":case"markdown":return q`<div class="artifact-panel__rendered-md" part="artifact-panel-md">${Jt(Mn(e.content))}</div>`;case"html":return q`<div class="artifact-panel__rendered-html" part="artifact-panel-html">${Jt(e.content)}</div>`;case"text":case"txt":return q`<div class="artifact-panel__rendered-text" part="artifact-panel-text">${e.content}</div>`;default:return q`<pre class="artifact-panel__code" part="artifact-panel-code"><code>${e.content}</code></pre>`}}(n)}
|
|
4660
4723
|
</div>
|
|
4661
4724
|
</div>
|
|
4662
4725
|
</div>
|
|
@@ -4667,7 +4730,7 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
4667
4730
|
* SPDX-License-Identifier: MIT
|
|
4668
4731
|
*/function jn(e,t){return!1!==e.showMessages?q`
|
|
4669
4732
|
<div class="chatbot-content" part="content">
|
|
4670
|
-
${
|
|
4733
|
+
${Yn(e.messages,Cn(e.chatStarted,e.suggestions,t.suggestion,e.i18n),e.isTyping?function(e,t,i){if(!e)return K;const n=t===Qi.Dots?q`
|
|
4671
4734
|
<div class="dots" part="typing-dots">
|
|
4672
4735
|
<span></span>
|
|
4673
4736
|
<span></span>
|
|
@@ -4680,12 +4743,12 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
4680
4743
|
${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}
|
|
4681
4744
|
</div>
|
|
4682
4745
|
</div>
|
|
4683
|
-
`}(e.isTyping,e.loadingIndicator||Qi.Spinner,e.loadingText):K,t.message,e.i18n,e.welcomeMessage,e.isPendingThread)}
|
|
4746
|
+
`}(e.isTyping,e.loadingIndicator||Qi.Spinner,e.loadingText):K,t.message,e.i18n,e.welcomeMessage,e.isPendingThread,e.invertedScroll)}
|
|
4684
4747
|
<slot name="messages"></slot>
|
|
4685
4748
|
</div>
|
|
4686
4749
|
`:e.suggestions&&e.suggestions.length>0?q`
|
|
4687
4750
|
<div class="input-only-suggestions" part="input-only-suggestions">
|
|
4688
|
-
${
|
|
4751
|
+
${Cn(0,e.suggestions,t.suggestion,e.i18n)}
|
|
4689
4752
|
</div>
|
|
4690
4753
|
`:K}function Pn(e,t){var i;const n=e.enableArtifacts&&(null===(i=e.artifactPanel)||void 0===i?void 0:i.isOpen),s=e.enableFileUpload?t.fileUploadArea:void 0;return q`
|
|
4691
4754
|
<div class="chatbot-container ${Te({"chatbot-container--with-sidebar":e.enableThreads&&e.isThreadSidebarOpen,"chatbot-container--with-artifact-panel":!!n})}" part="container"
|
|
@@ -4708,14 +4771,14 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
4708
4771
|
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"/></svg>
|
|
4709
4772
|
${e.i18n.threads.bookmarksLabel}
|
|
4710
4773
|
</div>
|
|
4711
|
-
${
|
|
4774
|
+
${_n(i,e=>e.id,i=>An(i,e,t))}
|
|
4712
4775
|
</div>
|
|
4713
4776
|
`:K}
|
|
4714
4777
|
${n.length>0||0===i.length?q`
|
|
4715
4778
|
${i.length>0?q`
|
|
4716
4779
|
<div class="thread-section__label" part="thread-section-label">${e.i18n.threads.allConversationsLabel}</div>
|
|
4717
4780
|
`:K}
|
|
4718
|
-
${
|
|
4781
|
+
${_n(n,e=>e.id,i=>An(i,e,t))}
|
|
4719
4782
|
${0===n.length&&0===i.length?q`
|
|
4720
4783
|
<p class="empty-msg" part="thread-empty">${e.i18n.threads.noConversationsLabel}</p>
|
|
4721
4784
|
`:K}
|
|
@@ -4887,7 +4950,7 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
4887
4950
|
* @license
|
|
4888
4951
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
4889
4952
|
* 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: "),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`
|
|
4953
|
+
*/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…"),showMoreLabel:Ci("Show more"),showLessLabel:Ci("Show less")},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._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;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,s;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===(s=this.shadowRoot)||void 0===s||s.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.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);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,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},n={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 q`
|
|
4891
4954
|
<div
|
|
4892
4955
|
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
4956
|
dir=${this.isRTL?"rtl":"ltr"}
|
|
@@ -4910,7 +4973,7 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
4910
4973
|
<span class="module-display-multiple">
|
|
4911
4974
|
${e} ${this.resolvedI18n.modules.modulesSelectedSuffix}
|
|
4912
4975
|
</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,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);
|
|
4976
|
+
`}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),Fn([xe()],Vn.prototype,"_expandedMessageIds",void 0),Fn([_e({type:Number,attribute:"message-collapse-threshold"})],Vn.prototype,"messageCollapseThreshold",void 0),Fn([_e({type:Boolean,attribute:"inverted-scroll",reflect:!0})],Vn.prototype,"invertedScroll",void 0),Vn=Fn([(e,t)=>(e.addInitializer(Ei),e),ge("nr-chatbot")],Vn);
|
|
4914
4977
|
/**
|
|
4915
4978
|
* @license
|
|
4916
4979
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
@@ -26608,7 +26671,7 @@ var Sh=function(e,t,i,n){for(var s,a=arguments.length,o=a<3?t:null===n?n=Object.
|
|
|
26608
26671
|
`}
|
|
26609
26672
|
|
|
26610
26673
|
<div class="dots" part="dots">
|
|
26611
|
-
${
|
|
26674
|
+
${_n(Array.from({length:null===(e=this.displayedElements)||void 0===e?void 0:e.length}),(e,t)=>q`
|
|
26612
26675
|
<span
|
|
26613
26676
|
class="dot ${t===this.currentIndex?"active":""}"
|
|
26614
26677
|
@click="${()=>this.goTo(t)}"
|
|
@@ -26877,7 +26940,7 @@ var Zh=function(e,t,i,n){return new(i||(i=Promise))(function(s,a){function o(e){
|
|
|
26877
26940
|
* @license
|
|
26878
26941
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
26879
26942
|
* SPDX-License-Identifier: MIT
|
|
26880
|
-
*/var Lp=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())})};class Tp extends Sp{constructor(){super(...arguments),this.id="markdown",this.name="Markdown Plugin",this.version="2.0.0",this.htmlTags=[{name:"md",open:"[MD]",close:"[/MD]"}]}onInit(){console.log("[MarkdownPlugin] Initialized")}renderHtmlBlock(e,t){if("md"!==e)return"";const i=this.getStyles();return`${this.getOncePerConversationStyleTag(i)}${
|
|
26943
|
+
*/var Lp=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())})};class Tp extends Sp{constructor(){super(...arguments),this.id="markdown",this.name="Markdown Plugin",this.version="2.0.0",this.htmlTags=[{name:"md",open:"[MD]",close:"[/MD]"}]}onInit(){console.log("[MarkdownPlugin] Initialized")}renderHtmlBlock(e,t){if("md"!==e)return"";const i=this.getStyles();return`${this.getOncePerConversationStyleTag(i)}${Mn(t)}`}afterReceive(e){return Lp(this,void 0,void 0,function*(){return e.includes("[MD]")&&e.includes("[/MD]")?e:Mn(e)})}getStyles(){return"\n .md-code { background: #f6f8fa; padding: 12px; border-radius: 6px; overflow: auto; }\n .md-inline-code { background: rgba(27,31,35,.05); padding: 0 4px; border-radius: 4px; }\n h1, h2, h3 { margin: 0.6em 0 0.4em; font-weight: 600; }\n p { margin: 0.5em 0; }\n ul { margin: 0.5em 0 0.5em 1.2em; }\n a { color: #0b5fff; text-decoration: underline; }\n "}}
|
|
26881
26944
|
/**
|
|
26882
26945
|
* @license
|
|
26883
26946
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
@@ -26892,17 +26955,17 @@ var Zh=function(e,t,i,n){return new(i||(i=Promise))(function(s,a){function o(e){
|
|
|
26892
26955
|
* @license
|
|
26893
26956
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
26894
26957
|
* SPDX-License-Identifier: MIT
|
|
26895
|
-
*/var zp=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())})};class Ep extends Sp{constructor(){super(...arguments),this.id="artifact",this.name="Artifact Plugin",this.version="1.0.0",this.artifacts=new Map}onInit(e){this.controller=e,e&&"function"==typeof e.on&&e.on("processing:end",()=>{var t,i;try{const n=[...(null===(t=e.getMessages)||void 0===t?void 0:t.call(e))||[]].reverse().find(e=>e.sender===Xi.Bot);n&&!(null===(i=n.metadata)||void 0===i?void 0:i.hasArtifacts)&&this.processMessage(n)}catch(e){}})}onMessageReceived(e){return zp(this,void 0,void 0,function*(){e.sender===Xi.Bot&&this.processMessage(e)})}processMessage(e){var t;if(null===(t=e.metadata)||void 0===t?void 0:t.hasArtifacts)return void this.rebuildArtifactsFromMetadata(e);const i=e.text;if(!i)return;const n=/```(\w*)\n([\s\S]*?)```/g;let s;const a=[];let o=0;for(;null!==(s=n.exec(i));){const t=(s[1]||"text").toLowerCase(),i=s[2],n=`artifact-${e.id}-${o}`,r={id:n,language:t,content:i,title:this.extractTitle(i,t,o),messageId:e.id,index:o};a.push(r),this.artifacts.set(n,r),o++}if(0===a.length)return;let r=i,l=0;r=r.replaceAll(n,()=>`\0ARTIFACT_CARD_${a[l++].id}\0`),r=
|
|
26958
|
+
*/var zp=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())})};class Ep extends Sp{constructor(){super(...arguments),this.id="artifact",this.name="Artifact Plugin",this.version="1.0.0",this.artifacts=new Map}onInit(e){this.controller=e,e&&"function"==typeof e.on&&e.on("processing:end",()=>{var t,i;try{const n=[...(null===(t=e.getMessages)||void 0===t?void 0:t.call(e))||[]].reverse().find(e=>e.sender===Xi.Bot);n&&!(null===(i=n.metadata)||void 0===i?void 0:i.hasArtifacts)&&this.processMessage(n)}catch(e){}})}onMessageReceived(e){return zp(this,void 0,void 0,function*(){e.sender===Xi.Bot&&this.processMessage(e)})}processMessage(e){var t;if(null===(t=e.metadata)||void 0===t?void 0:t.hasArtifacts)return void this.rebuildArtifactsFromMetadata(e);const i=e.text;if(!i)return;const n=/```(\w*)\n([\s\S]*?)```/g;let s;const a=[];let o=0;for(;null!==(s=n.exec(i));){const t=(s[1]||"text").toLowerCase(),i=s[2],n=`artifact-${e.id}-${o}`,r={id:n,language:t,content:i,title:this.extractTitle(i,t,o),messageId:e.id,index:o};a.push(r),this.artifacts.set(n,r),o++}if(0===a.length)return;let r=i,l=0;r=r.replaceAll(n,()=>`\0ARTIFACT_CARD_${a[l++].id}\0`),r=Mn(r);for(const e of a)r=r.replace(`\0ARTIFACT_CARD_${e.id}\0`,this.renderPlaceholderCard(e));const d=this.getOncePerConversationStyleTag(this.getStyles());this.controller&&"function"==typeof this.controller.updateMessage&&this.controller.updateMessage(e.id,{text:d+r,metadata:Object.assign(Object.assign({},e.metadata),{renderAsHtml:!0,hasArtifacts:!0,artifactIds:a.map(e=>e.id),artifactOriginalText:i})})}rebuildArtifactsFromMetadata(e){var t,i;const n=null===(t=e.metadata)||void 0===t?void 0:t.artifactIds;if(!(null==n?void 0:n.length))return;if(n.every(e=>this.artifacts.has(e)))return;const s=null===(i=e.metadata)||void 0===i?void 0:i.artifactOriginalText;if(!s)return;const a=/```(\w*)\n([\s\S]*?)```/g;let o,r=0;for(;null!==(o=a.exec(s));){const t=(o[1]||"text").toLowerCase(),i=o[2],n=`artifact-${e.id}-${r}`,s=this.extractTitle(i,t,r);this.artifacts.set(n,{id:n,language:t,content:i,title:s,messageId:e.id,index:r}),r++}}getArtifact(e){return this.artifacts.get(e)}getAllArtifacts(){return Array.from(this.artifacts.values())}getArtifactsForMessage(e){return Array.from(this.artifacts.values()).filter(t=>t.messageId===e)}processNow(e){var t;if(!this.controller||"function"!=typeof this.controller.getMessages)return!1;const i=(this.controller.getMessages()||[]).find(t=>t.id===e);return!(!i||i.sender!==Xi.Bot)&&((null===(t=i.metadata)||void 0===t?void 0:t.hasArtifacts)?(this.rebuildArtifactsFromMetadata(i),!0):(this.processMessage(i),!0))}extractTitle(e,t,i){const n=e.trimStart().split("\n")[0]||"",s=[/^\/\/\s*(.+)/,/^#\s*(.+)/,/^--\s*(.+)/,/^\/\*\s*(.*?)\*\//,/^<!--\s*(.*?)-->/];for(const e of s){const t=e.exec(n);if(null==t?void 0:t[1]){const e=t[1].trim();if(e.length>0&&e.length<=60)return e}}return`${$n(t)} Snippet ${i+1}`}renderPlaceholderCard(e){const t=$n(e.language),i=wn(e.title);return`<div class="nr-artifact-card" data-artifact-id="${e.id}" role="button" tabindex="0" aria-label="View ${i}">\n <nr-icon name="code" size="small" class="nr-artifact-card__icon"></nr-icon>\n <span class="nr-artifact-card__info">\n <span class="nr-artifact-card__title">${i}</span>\n <nr-tag size="small" class="nr-artifact-card__lang">${t}</nr-tag>\n </span>\n <nr-icon name="chevron-right" size="small" class="nr-artifact-card__chevron"></nr-icon>\n</div>`}getStyles(){return"\n .nr-artifact-card {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 14px;\n margin: 8px 0;\n background: #f6f8fa;\n border: 1px solid #d0d7de;\n border-radius: 8px;\n cursor: pointer;\n transition: background 0.15s ease, border-color 0.15s ease;\n user-select: none;\n max-width: 100%;\n }\n .nr-artifact-card:hover {\n background: #eaeef2;\n border-color: #8b949e;\n }\n .nr-artifact-card:focus-visible {\n outline: 2px solid #0b5fff;\n outline-offset: 2px;\n }\n .nr-artifact-card__icon {\n flex-shrink: 0;\n color: #57606a;\n }\n .nr-artifact-card__info {\n display: flex;\n flex-direction: column;\n gap: 4px;\n min-width: 0;\n flex: 1;\n }\n .nr-artifact-card__title {\n font-size: 13px;\n font-weight: 500;\n color: #1f2937;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n line-height: 1.3;\n }\n .nr-artifact-card__lang {\n align-self: flex-start;\n }\n .nr-artifact-card__chevron {\n flex-shrink: 0;\n color: #6c757d;\n }\n "}}
|
|
26896
26959
|
/**
|
|
26897
26960
|
* @license
|
|
26898
26961
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
26899
26962
|
* SPDX-License-Identifier: MIT
|
|
26900
|
-
*/class Ap extends Sp{constructor(){super(...arguments),this.id="json-graph-renderer",this.name="JSON Graph Renderer",this.version="1.0.0"}renderArtifactContent(e){if("json"!==e.language)return"";let t;try{t=JSON.parse(e.content)}catch(e){return""}if(null===t||"object"!=typeof t)return"";const i=Array.isArray(t)?t.map((e,t)=>this.renderNode(String(t),e)):Object.entries(t).map(([e,t])=>this.renderNode(e,t));return`\n <div style="padding:20px;font-family:system-ui,-apple-system,sans-serif;overflow:auto;">\n <div style="\n display:flex;align-items:center;gap:8px;\n margin-bottom:16px;padding-bottom:12px;\n border-bottom:1px solid #e2e8f0;\n ">\n <span style="\n display:inline-flex;align-items:center;justify-content:center;\n width:28px;height:28px;border-radius:6px;\n background:linear-gradient(135deg,#0ea5e9,#8b5cf6);\n color:#fff;font-size:14px;font-weight:700;\n ">{}</span>\n <span style="font-size:15px;font-weight:600;color:#1e293b;">\n JSON Graph View\n </span>\n <span style="\n margin-left:auto;font-size:12px;padding:2px 8px;border-radius:10px;\n background:#f1f5f9;color:#64748b;\n ">${Array.isArray(t)?t.length:Object.keys(t).length} root keys</span>\n </div>\n ${i.join("")}\n </div>\n `}renderNode(e,t,i=0){const n=null!==t&&"object"==typeof t&&!Array.isArray(t),s=Array.isArray(t),a=24*i;if(!n&&!s)return`\n <div style="display:flex;align-items:center;gap:8px;margin-left:${a}px;margin-bottom:6px;">\n <span style="\n display:inline-block;width:8px;height:8px;border-radius:50%;\n background:${this.typeColor(t)};flex-shrink:0;\n "></span>\n <span style="font-weight:600;font-size:13px;color:#334155;">\n ${
|
|
26963
|
+
*/class Ap extends Sp{constructor(){super(...arguments),this.id="json-graph-renderer",this.name="JSON Graph Renderer",this.version="1.0.0"}renderArtifactContent(e){if("json"!==e.language)return"";let t;try{t=JSON.parse(e.content)}catch(e){return""}if(null===t||"object"!=typeof t)return"";const i=Array.isArray(t)?t.map((e,t)=>this.renderNode(String(t),e)):Object.entries(t).map(([e,t])=>this.renderNode(e,t));return`\n <div style="padding:20px;font-family:system-ui,-apple-system,sans-serif;overflow:auto;">\n <div style="\n display:flex;align-items:center;gap:8px;\n margin-bottom:16px;padding-bottom:12px;\n border-bottom:1px solid #e2e8f0;\n ">\n <span style="\n display:inline-flex;align-items:center;justify-content:center;\n width:28px;height:28px;border-radius:6px;\n background:linear-gradient(135deg,#0ea5e9,#8b5cf6);\n color:#fff;font-size:14px;font-weight:700;\n ">{}</span>\n <span style="font-size:15px;font-weight:600;color:#1e293b;">\n JSON Graph View\n </span>\n <span style="\n margin-left:auto;font-size:12px;padding:2px 8px;border-radius:10px;\n background:#f1f5f9;color:#64748b;\n ">${Array.isArray(t)?t.length:Object.keys(t).length} root keys</span>\n </div>\n ${i.join("")}\n </div>\n `}renderNode(e,t,i=0){const n=null!==t&&"object"==typeof t&&!Array.isArray(t),s=Array.isArray(t),a=24*i;if(!n&&!s)return`\n <div style="display:flex;align-items:center;gap:8px;margin-left:${a}px;margin-bottom:6px;">\n <span style="\n display:inline-block;width:8px;height:8px;border-radius:50%;\n background:${this.typeColor(t)};flex-shrink:0;\n "></span>\n <span style="font-weight:600;font-size:13px;color:#334155;">\n ${wn(e)}\n </span>\n <span style="\n font-size:13px;padding:2px 8px;border-radius:4px;\n background:${this.typeBg(t)};color:${this.typeColor(t)};\n border:1px solid ${this.typeColor(t)}20;\n ">${wn(this.formatValue(t))}</span>\n </div>\n `;const o=s?t.map((e,t)=>[String(t),e]):Object.entries(t),r=s?`[ ${o.length} ]`:`{ ${o.length} }`,l=s?"#8b5cf6":"#0ea5e9";return`\n <div style="margin-left:${a}px;margin-bottom:4px;">\n <div style="display:flex;align-items:center;gap:8px;margin-bottom:4px;">\n <span style="\n display:inline-flex;align-items:center;justify-content:center;\n width:20px;height:20px;border-radius:4px;\n background:${l}15;color:${l};font-size:11px;font-weight:700;\n border:1px solid ${l}30;\n ">${s?"[]":"{}"}</span>\n <span style="font-weight:600;font-size:13px;color:#334155;">\n ${wn(e)}\n </span>\n <span style="\n font-size:11px;padding:1px 6px;border-radius:10px;\n background:${l}10;color:${l};font-weight:500;\n ">${r}</span>\n </div>\n <div style="margin-left:9px;padding-left:16px;border-left:2px solid #e2e8f0;">\n ${o.map(([e,t])=>this.renderNode(e,t,0)).join("")}\n </div>\n </div>\n `}typeColor(e){if(null===e)return"#94a3b8";switch(typeof e){case"string":return"#22c55e";case"number":return"#3b82f6";case"boolean":return"#f59e0b";default:return"#94a3b8"}}typeBg(e){if(null===e)return"#f1f5f9";switch(typeof e){case"string":return"#f0fdf4";case"number":return"#eff6ff";case"boolean":return"#fffbeb";default:return"#f1f5f9"}}formatValue(e){return null==e?"null":"string"==typeof e?`"${e}"`:"number"==typeof e||"boolean"==typeof e?String(e):JSON.stringify(e)}}
|
|
26901
26964
|
/**
|
|
26902
26965
|
* @license
|
|
26903
26966
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
26904
26967
|
* SPDX-License-Identifier: MIT
|
|
26905
|
-
*/const Op="nuraly:flow-diagram:split-width",Ip="nuraly:flow-diagram:panel-width",jp="nr-flow-diagram-editor";class Pp extends HTMLElement{connectedCallback(){var e;const t=this.loadPanelWidth(),i=this.closestPanel();i&&(i.style.setProperty("width",`${t}px`),this._panelObserver=new ResizeObserver(()=>{const e=Math.round(i.getBoundingClientRect().width);e>=200&&localStorage.setItem(Ip,String(e))}),this._panelObserver.observe(i));const n=this.attachShadow({mode:"open"}),s=null!==(e=this.getAttribute("content"))&&void 0!==e?e:"",a=this.unescapeHtml(s),o=this.prettyPrint(a);let r=null;try{r=JSON.parse(a)}catch(e){}n.innerHTML=`\n <style>${Pp.styles()}</style>\n ${this.renderHeader(r)}\n <div class="split">\n <div class="editor-pane">\n <textarea class="editor-textarea" spellcheck="false"></textarea>\n </div>\n <div class="resize-handle"><div class="resize-handle-bar"></div></div>\n <div class="diagram-pane">\n ${r?this.renderDiagram(r):'<div class="empty">Invalid JSON</div>'}\n </div>\n </div>\n <div class="error-bar" style="display:none;"></div>\n `;const l=n.querySelector(".editor-textarea");l&&(l.value=o);const d=localStorage.getItem(Op);d&&requestAnimationFrame(()=>{const e=n.querySelector(".editor-pane");e&&(e.style.flex="none",e.style.width=`${d}px`)});const c=n.querySelector(".diagram-pane"),h=n.querySelector(".error-bar");l&&c&&h&&(l.addEventListener("input",()=>{try{const e=JSON.parse(l.value);if(e.Steps&&e.Transitions){c.innerHTML=this.renderDiagram(e);const t=n.querySelector(".header");if(t){const i=document.createElement("template");i.innerHTML=this.renderHeader(e).trim();const n=i.content.firstElementChild;n&&t.replaceWith(n)}}h.style.display="none"}catch(e){h.textContent=`Parse error: ${e.message}`,h.style.display="flex"}}),this.initResize(n))}disconnectedCallback(){var e,t;null===(e=this._panelObserver)||void 0===e||e.disconnect(),null===(t=this.closestPanel())||void 0===t||t.style.removeProperty("width")}loadPanelWidth(){const e=localStorage.getItem(Ip);return e?Math.max(300,Number.parseInt(e,10)):500}closestPanel(){var e,t,i,n;let s=null!==(t=null!==(e=this.parentElement)&&void 0!==e?e:this.getRootNode().host)&&void 0!==t?t:null;for(;s;){if(s instanceof HTMLElement&&s.classList.contains("artifact-panel"))return s;s=null!==(n=null!==(i=s.parentElement)&&void 0!==i?i:s.getRootNode().host)&&void 0!==n?n:null}return null}initResize(e){const t=e.querySelector(".split"),i=e.querySelector(".editor-pane"),n=e.querySelector(".resize-handle");if(!t||!i||!n)return;let s=!1,a=0,o=0;const r=e=>{if(!s)return;const n=e.clientX-a,r=t.getBoundingClientRect().width,l=Math.max(200,Math.min(o+n,r-200));i.style.flex="none",i.style.width=`${l}px`},l=()=>{if(!s)return;s=!1,n.classList.remove("active"),document.body.style.cursor="",document.body.style.userSelect="";const e=Math.round(i.getBoundingClientRect().width);e>=200&&localStorage.setItem(Op,String(e)),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",l)};n.addEventListener("mousedown",e=>{const t=e;t.preventDefault(),s=!0,a=t.clientX,o=i.getBoundingClientRect().width,n.classList.add("active"),document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",r),document.addEventListener("mouseup",l)})}prettyPrint(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch(t){return e}}unescapeHtml(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}renderHeader(e){var t,i;const n=null!==(t=null==e?void 0:e.Name)&&void 0!==t?t:"Workflow",s=(null!==(i=null==e?void 0:e.DocflowTags)&&void 0!==i?i:[]).map(e=>`<span class="tag">${mn(e)}</span>`).join("");return`\n <div class="header">\n <span class="header-icon">⬡</span>\n <span class="header-name">${mn(n)}</span>\n ${s}\n </div>\n `}renderDiagram(e){var t,i;const n=this.buildOrderedSteps(e),s=[];for(let e=0;e<n.length;e++){const a=n[e];s.push("event"===a.type?this.renderEventNode(a.name,null!==(t=a.eventType)&&void 0!==t?t:""):this.renderStepNode(a.name,null!==(i=a.step)&&void 0!==i?i:{})),e<n.length-1&&s.push(this.renderConnector())}return`<div class="diagram">${s.join("")}</div>`}buildOrderedSteps(e){var t,i,n,s;const a=[],o=null===(t=e.Events)||void 0===t?void 0:t.StartEvent,r=null===(i=e.Events)||void 0===i?void 0:i.EndEvent;o&&a.push({type:"event",name:o.Name||"Start",eventType:"start"});const l={};for(const t of Object.values(e.Transitions))l[t.Source]=t;let d=null!==(s=null===(n=l.StartEvent)||void 0===n?void 0:n.Target)&&void 0!==s?s:Object.keys(e.Steps)[0];const c=new Set;for(;d&&e.Steps[d]&&!c.has(d);){c.add(d),a.push({type:"step",name:d,step:e.Steps[d]});const t=l[d];if(!t||"EndEvent"===t.Target)break;d=t.Target}return r&&a.push({type:"event",name:r.Name||"End",eventType:"end"}),a}renderEventNode(e,t){const i="start"===t;return`\n <div class="node event-node ${i?"event-start":"event-end"}">\n <span class="event-icon">${i?"●":"■"}</span>\n <span class="event-label">${mn(e)}</span>\n </div>\n `}renderStepNode(e,t){var i,n,s;const a=null!==(i=t.StepType)&&void 0!==i?i:"",o=null!==(s=null===(n=t.Description)||void 0===n?void 0:n.trim())&&void 0!==s?s:"",r=a?`<span class="step-badge ${"Worker"===a?"badge-worker":"badge-system"}">${mn(a)}</span>`:"",l=o?`<div class="step-desc">${mn(o)}</div>`:"";return`\n <div class="node step-node">\n <div class="step-header">\n <span class="step-name">${mn(e)}</span>\n ${r}\n </div>\n ${l}\n </div>\n `}renderConnector(){return'\n <div class="connector">\n <div class="connector-line"></div>\n <div class="connector-arrow">▼</div>\n </div>\n '}static styles(){return"\n :host {\n display: flex;\n flex-direction: column;\n width: 100%;\n min-width: 480px;\n height: 100%;\n font-family: system-ui, -apple-system, sans-serif;\n color: #1e293b;\n overflow: hidden;\n }\n\n .header {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 12px 16px;\n border-bottom: 1px solid #e2e8f0;\n background: #f8fafc;\n flex-shrink: 0;\n }\n .header-icon { font-size: 18px; color: #6366f1; }\n .header-name { font-weight: 600; font-size: 15px; }\n .tag {\n font-size: 11px;\n padding: 2px 8px;\n border-radius: 10px;\n background: #ede9fe;\n color: #6366f1;\n font-weight: 500;\n }\n\n .split {\n display: flex;\n flex: 1;\n min-height: 0;\n }\n\n .editor-pane {\n flex: 1;\n min-width: 200px;\n display: flex;\n overflow: hidden;\n }\n .editor-textarea {\n flex: 1;\n width: 100%;\n height: 100%;\n border: none;\n outline: none;\n resize: none;\n padding: 12px;\n font-family: 'Fira Code', 'Cascadia Code', Consolas, monospace;\n font-size: 12px;\n line-height: 1.6;\n color: #1e293b;\n background: #ffffff;\n box-sizing: border-box;\n tab-size: 2;\n }\n\n /* ── Resize handle ──────────────────────────────── */\n\n .resize-handle {\n flex-shrink: 0;\n width: 8px;\n cursor: col-resize;\n display: flex;\n align-items: center;\n justify-content: center;\n background: #f1f5f9;\n border-left: 1px solid #e2e8f0;\n border-right: 1px solid #e2e8f0;\n transition: background 0.15s;\n }\n .resize-handle:hover,\n .resize-handle.active { background: #e2e8f0; }\n .resize-handle-bar {\n width: 2px;\n height: 24px;\n border-radius: 1px;\n background: #cbd5e1;\n transition: background 0.15s;\n }\n .resize-handle:hover .resize-handle-bar,\n .resize-handle.active .resize-handle-bar { background: #94a3b8; }\n\n .diagram-pane {\n flex: 1;\n min-width: 200px;\n overflow-y: auto;\n padding: 24px;\n background: #f8fafc;\n }\n\n .diagram {\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n\n .empty {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n color: #94a3b8;\n font-size: 14px;\n }\n\n /* ── Event nodes ──────────────────────────────────── */\n\n .event-node {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 8px 20px;\n border-radius: 20px;\n font-size: 13px;\n font-weight: 600;\n }\n .event-start { background: #ecfdf5; border: 1.5px solid #86efac; color: #166534; }\n .event-start .event-icon { color: #22c55e; font-size: 10px; }\n .event-end { background: #fef2f2; border: 1.5px solid #fca5a5; color: #991b1b; }\n .event-end .event-icon { color: #ef4444; font-size: 10px; }\n\n /* ── Step nodes ───────────────────────────────────── */\n\n .step-node {\n width: 220px;\n padding: 12px 16px;\n border-radius: 8px;\n background: #ffffff;\n border: 1.5px solid #e2e8f0;\n box-shadow: 0 1px 3px rgba(0,0,0,0.06);\n }\n .step-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n }\n .step-name { font-weight: 600; font-size: 13px; color: #1e293b; }\n .step-badge {\n font-size: 10px;\n padding: 2px 6px;\n border-radius: 4px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.02em;\n flex-shrink: 0;\n }\n .badge-worker { background: #dbeafe; color: #1d4ed8; }\n .badge-system { background: #fef3c7; color: #92400e; }\n .step-desc { margin-top: 6px; font-size: 11px; color: #64748b; line-height: 1.4; }\n\n /* ── Connectors ───────────────────────────────────── */\n\n .connector {\n display: flex;\n flex-direction: column;\n align-items: center;\n height: 32px;\n }\n .connector-line { width: 2px; flex: 1; background: #cbd5e1; }\n .connector-arrow { font-size: 8px; color: #cbd5e1; line-height: 1; margin-top: -2px; }\n\n /* ── Error bar ────────────────────────────────────── */\n\n .error-bar {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 8px 16px;\n background: #fef2f2;\n border-top: 1px solid #fecaca;\n color: #dc2626;\n font-size: 12px;\n flex-shrink: 0;\n }\n .error-bar::before { content: '⚠'; }\n "}}class Np extends Sp{constructor(){super(...arguments),this.id="flow-diagram",this.name="Flow Diagram",this.version="1.0.0"}onInit(){customElements.get(jp)||customElements.define(jp,Pp)}renderArtifactContent(e){if("json"!==e.language)return"";let t;try{t=JSON.parse(e.content)}catch(e){return""}return null!==t&&"object"==typeof t&&t.Steps&&"object"==typeof t.Steps&&t.Transitions&&"object"==typeof t.Transitions?`<nr-flow-diagram-editor content="${mn(e.content)}"></nr-flow-diagram-editor>`:""}}
|
|
26968
|
+
*/const Op="nuraly:flow-diagram:split-width",Ip="nuraly:flow-diagram:panel-width",jp="nr-flow-diagram-editor";class Pp extends HTMLElement{connectedCallback(){var e;const t=this.loadPanelWidth(),i=this.closestPanel();i&&(i.style.setProperty("width",`${t}px`),this._panelObserver=new ResizeObserver(()=>{const e=Math.round(i.getBoundingClientRect().width);e>=200&&localStorage.setItem(Ip,String(e))}),this._panelObserver.observe(i));const n=this.attachShadow({mode:"open"}),s=null!==(e=this.getAttribute("content"))&&void 0!==e?e:"",a=this.unescapeHtml(s),o=this.prettyPrint(a);let r=null;try{r=JSON.parse(a)}catch(e){}n.innerHTML=`\n <style>${Pp.styles()}</style>\n ${this.renderHeader(r)}\n <div class="split">\n <div class="editor-pane">\n <textarea class="editor-textarea" spellcheck="false"></textarea>\n </div>\n <div class="resize-handle"><div class="resize-handle-bar"></div></div>\n <div class="diagram-pane">\n ${r?this.renderDiagram(r):'<div class="empty">Invalid JSON</div>'}\n </div>\n </div>\n <div class="error-bar" style="display:none;"></div>\n `;const l=n.querySelector(".editor-textarea");l&&(l.value=o);const d=localStorage.getItem(Op);d&&requestAnimationFrame(()=>{const e=n.querySelector(".editor-pane");e&&(e.style.flex="none",e.style.width=`${d}px`)});const c=n.querySelector(".diagram-pane"),h=n.querySelector(".error-bar");l&&c&&h&&(l.addEventListener("input",()=>{try{const e=JSON.parse(l.value);if(e.Steps&&e.Transitions){c.innerHTML=this.renderDiagram(e);const t=n.querySelector(".header");if(t){const i=document.createElement("template");i.innerHTML=this.renderHeader(e).trim();const n=i.content.firstElementChild;n&&t.replaceWith(n)}}h.style.display="none"}catch(e){h.textContent=`Parse error: ${e.message}`,h.style.display="flex"}}),this.initResize(n))}disconnectedCallback(){var e,t;null===(e=this._panelObserver)||void 0===e||e.disconnect(),null===(t=this.closestPanel())||void 0===t||t.style.removeProperty("width")}loadPanelWidth(){const e=localStorage.getItem(Ip);return e?Math.max(300,Number.parseInt(e,10)):500}closestPanel(){var e,t,i,n;let s=null!==(t=null!==(e=this.parentElement)&&void 0!==e?e:this.getRootNode().host)&&void 0!==t?t:null;for(;s;){if(s instanceof HTMLElement&&s.classList.contains("artifact-panel"))return s;s=null!==(n=null!==(i=s.parentElement)&&void 0!==i?i:s.getRootNode().host)&&void 0!==n?n:null}return null}initResize(e){const t=e.querySelector(".split"),i=e.querySelector(".editor-pane"),n=e.querySelector(".resize-handle");if(!t||!i||!n)return;let s=!1,a=0,o=0;const r=e=>{if(!s)return;const n=e.clientX-a,r=t.getBoundingClientRect().width,l=Math.max(200,Math.min(o+n,r-200));i.style.flex="none",i.style.width=`${l}px`},l=()=>{if(!s)return;s=!1,n.classList.remove("active"),document.body.style.cursor="",document.body.style.userSelect="";const e=Math.round(i.getBoundingClientRect().width);e>=200&&localStorage.setItem(Op,String(e)),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",l)};n.addEventListener("mousedown",e=>{const t=e;t.preventDefault(),s=!0,a=t.clientX,o=i.getBoundingClientRect().width,n.classList.add("active"),document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",r),document.addEventListener("mouseup",l)})}prettyPrint(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch(t){return e}}unescapeHtml(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}renderHeader(e){var t,i;const n=null!==(t=null==e?void 0:e.Name)&&void 0!==t?t:"Workflow",s=(null!==(i=null==e?void 0:e.DocflowTags)&&void 0!==i?i:[]).map(e=>`<span class="tag">${wn(e)}</span>`).join("");return`\n <div class="header">\n <span class="header-icon">⬡</span>\n <span class="header-name">${wn(n)}</span>\n ${s}\n </div>\n `}renderDiagram(e){var t,i;const n=this.buildOrderedSteps(e),s=[];for(let e=0;e<n.length;e++){const a=n[e];s.push("event"===a.type?this.renderEventNode(a.name,null!==(t=a.eventType)&&void 0!==t?t:""):this.renderStepNode(a.name,null!==(i=a.step)&&void 0!==i?i:{})),e<n.length-1&&s.push(this.renderConnector())}return`<div class="diagram">${s.join("")}</div>`}buildOrderedSteps(e){var t,i,n,s;const a=[],o=null===(t=e.Events)||void 0===t?void 0:t.StartEvent,r=null===(i=e.Events)||void 0===i?void 0:i.EndEvent;o&&a.push({type:"event",name:o.Name||"Start",eventType:"start"});const l={};for(const t of Object.values(e.Transitions))l[t.Source]=t;let d=null!==(s=null===(n=l.StartEvent)||void 0===n?void 0:n.Target)&&void 0!==s?s:Object.keys(e.Steps)[0];const c=new Set;for(;d&&e.Steps[d]&&!c.has(d);){c.add(d),a.push({type:"step",name:d,step:e.Steps[d]});const t=l[d];if(!t||"EndEvent"===t.Target)break;d=t.Target}return r&&a.push({type:"event",name:r.Name||"End",eventType:"end"}),a}renderEventNode(e,t){const i="start"===t;return`\n <div class="node event-node ${i?"event-start":"event-end"}">\n <span class="event-icon">${i?"●":"■"}</span>\n <span class="event-label">${wn(e)}</span>\n </div>\n `}renderStepNode(e,t){var i,n,s;const a=null!==(i=t.StepType)&&void 0!==i?i:"",o=null!==(s=null===(n=t.Description)||void 0===n?void 0:n.trim())&&void 0!==s?s:"",r=a?`<span class="step-badge ${"Worker"===a?"badge-worker":"badge-system"}">${wn(a)}</span>`:"",l=o?`<div class="step-desc">${wn(o)}</div>`:"";return`\n <div class="node step-node">\n <div class="step-header">\n <span class="step-name">${wn(e)}</span>\n ${r}\n </div>\n ${l}\n </div>\n `}renderConnector(){return'\n <div class="connector">\n <div class="connector-line"></div>\n <div class="connector-arrow">▼</div>\n </div>\n '}static styles(){return"\n :host {\n display: flex;\n flex-direction: column;\n width: 100%;\n min-width: 480px;\n height: 100%;\n font-family: system-ui, -apple-system, sans-serif;\n color: #1e293b;\n overflow: hidden;\n }\n\n .header {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 12px 16px;\n border-bottom: 1px solid #e2e8f0;\n background: #f8fafc;\n flex-shrink: 0;\n }\n .header-icon { font-size: 18px; color: #6366f1; }\n .header-name { font-weight: 600; font-size: 15px; }\n .tag {\n font-size: 11px;\n padding: 2px 8px;\n border-radius: 10px;\n background: #ede9fe;\n color: #6366f1;\n font-weight: 500;\n }\n\n .split {\n display: flex;\n flex: 1;\n min-height: 0;\n }\n\n .editor-pane {\n flex: 1;\n min-width: 200px;\n display: flex;\n overflow: hidden;\n }\n .editor-textarea {\n flex: 1;\n width: 100%;\n height: 100%;\n border: none;\n outline: none;\n resize: none;\n padding: 12px;\n font-family: 'Fira Code', 'Cascadia Code', Consolas, monospace;\n font-size: 12px;\n line-height: 1.6;\n color: #1e293b;\n background: #ffffff;\n box-sizing: border-box;\n tab-size: 2;\n }\n\n /* ── Resize handle ──────────────────────────────── */\n\n .resize-handle {\n flex-shrink: 0;\n width: 8px;\n cursor: col-resize;\n display: flex;\n align-items: center;\n justify-content: center;\n background: #f1f5f9;\n border-left: 1px solid #e2e8f0;\n border-right: 1px solid #e2e8f0;\n transition: background 0.15s;\n }\n .resize-handle:hover,\n .resize-handle.active { background: #e2e8f0; }\n .resize-handle-bar {\n width: 2px;\n height: 24px;\n border-radius: 1px;\n background: #cbd5e1;\n transition: background 0.15s;\n }\n .resize-handle:hover .resize-handle-bar,\n .resize-handle.active .resize-handle-bar { background: #94a3b8; }\n\n .diagram-pane {\n flex: 1;\n min-width: 200px;\n overflow-y: auto;\n padding: 24px;\n background: #f8fafc;\n }\n\n .diagram {\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n\n .empty {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n color: #94a3b8;\n font-size: 14px;\n }\n\n /* ── Event nodes ──────────────────────────────────── */\n\n .event-node {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 8px 20px;\n border-radius: 20px;\n font-size: 13px;\n font-weight: 600;\n }\n .event-start { background: #ecfdf5; border: 1.5px solid #86efac; color: #166534; }\n .event-start .event-icon { color: #22c55e; font-size: 10px; }\n .event-end { background: #fef2f2; border: 1.5px solid #fca5a5; color: #991b1b; }\n .event-end .event-icon { color: #ef4444; font-size: 10px; }\n\n /* ── Step nodes ───────────────────────────────────── */\n\n .step-node {\n width: 220px;\n padding: 12px 16px;\n border-radius: 8px;\n background: #ffffff;\n border: 1.5px solid #e2e8f0;\n box-shadow: 0 1px 3px rgba(0,0,0,0.06);\n }\n .step-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n }\n .step-name { font-weight: 600; font-size: 13px; color: #1e293b; }\n .step-badge {\n font-size: 10px;\n padding: 2px 6px;\n border-radius: 4px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.02em;\n flex-shrink: 0;\n }\n .badge-worker { background: #dbeafe; color: #1d4ed8; }\n .badge-system { background: #fef3c7; color: #92400e; }\n .step-desc { margin-top: 6px; font-size: 11px; color: #64748b; line-height: 1.4; }\n\n /* ── Connectors ───────────────────────────────────── */\n\n .connector {\n display: flex;\n flex-direction: column;\n align-items: center;\n height: 32px;\n }\n .connector-line { width: 2px; flex: 1; background: #cbd5e1; }\n .connector-arrow { font-size: 8px; color: #cbd5e1; line-height: 1; margin-top: -2px; }\n\n /* ── Error bar ────────────────────────────────────── */\n\n .error-bar {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 8px 16px;\n background: #fef2f2;\n border-top: 1px solid #fecaca;\n color: #dc2626;\n font-size: 12px;\n flex-shrink: 0;\n }\n .error-bar::before { content: '⚠'; }\n "}}class Np extends Sp{constructor(){super(...arguments),this.id="flow-diagram",this.name="Flow Diagram",this.version="1.0.0"}onInit(){customElements.get(jp)||customElements.define(jp,Pp)}renderArtifactContent(e){if("json"!==e.language)return"";let t;try{t=JSON.parse(e.content)}catch(e){return""}return null!==t&&"object"==typeof t&&t.Steps&&"object"==typeof t.Steps&&t.Transitions&&"object"==typeof t.Transitions?`<nr-flow-diagram-editor content="${wn(e.content)}"></nr-flow-diagram-editor>`:""}}
|
|
26906
26969
|
/**
|
|
26907
26970
|
* @license
|
|
26908
26971
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
@@ -29476,7 +29539,7 @@ class ny{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
|
|
|
29476
29539
|
* @license
|
|
29477
29540
|
* Copyright 2021 Google LLC
|
|
29478
29541
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
29479
|
-
*/(this._hostElement,e),this._scrollerController=new sy(this,this._clippingAncestors[0]),this._schedule(this._updateLayout),this._observeAndListen(),this._connected=!0}_observeAndListen(){this._mutationObserver.observe(this._hostElement,{childList:!0}),this._hostElementRO.observe(this._hostElement),this._scrollEventListeners.push(window),window.addEventListener("scroll",this,this._scrollEventListenerOptions),this._clippingAncestors.forEach(e=>{e.addEventListener("scroll",this,this._scrollEventListenerOptions),this._scrollEventListeners.push(e),this._hostElementRO.observe(e)}),this._hostElementRO.observe(this._scrollerController.element),this._children.forEach(e=>this._childrenRO.observe(e)),this._scrollEventListeners.forEach(e=>e.addEventListener("scroll",this,this._scrollEventListenerOptions))}disconnected(){this._scrollEventListeners.forEach(e=>e.removeEventListener("scroll",this,this._scrollEventListenerOptions)),this._scrollEventListeners=[],this._clippingAncestors=[],this._scrollerController?.detach(this),this._scrollerController=null,this._mutationObserver?.disconnect(),this._mutationObserver=null,this._hostElementRO?.disconnect(),this._hostElementRO=null,this._childrenRO?.disconnect(),this._childrenRO=null,this._rejectLayoutCompletePromise("disconnected"),this._connected=!1}_applyVirtualizerStyles(){const e=this._hostElement.style;e.display=e.display||"block",e.position=e.position||"relative",e.contain=e.contain||"size layout",this._isScroller&&(e.overflow=e.overflow||"auto",e.minHeight=e.minHeight||"150px")}_getSizer(){const e=this._hostElement;if(!this._sizer){let t=e.querySelector(`[${ry}]`);t||(t=document.createElement("div"),t.setAttribute(ry,""),e.appendChild(t)),Object.assign(t.style,{position:"absolute",margin:"-2px 0 0 0",padding:0,visibility:"hidden",fontSize:"2px"}),t.textContent=" ",t.setAttribute(ry,""),this._sizer=t}return this._sizer}async updateLayoutConfig(e){await this._layoutInitialized;const t=e.type||ly;if("function"==typeof t&&this._layout instanceof t){const t={...e};return delete t.type,this._layout.config=t,!0}return!1}async _initLayout(e){let t,i;if("function"==typeof e.type){i=e.type;const n={...e};delete n.type,t=n}else t=e;void 0===i&&(ly=i=(await Promise.resolve().then(function(){return n$})).FlowLayout),this._layout=new i(e=>this._handleLayoutMessage(e),t),this._layout.measureChildren&&"function"==typeof this._layout.updateItemSizes&&("function"==typeof this._layout.measureChildren&&(this._measureChildOverride=this._layout.measureChildren),this._measureCallback=this._layout.updateItemSizes.bind(this._layout)),this._layout.listenForChildLoadEvents&&this._hostElement.addEventListener("load",this._loadListener,!0),this._schedule(this._updateLayout)}startBenchmarking(){null===this._benchmarkStart&&(this._benchmarkStart=window.performance.now())}stopBenchmarking(){if(null!==this._benchmarkStart){const e=window.performance.now(),t=e-this._benchmarkStart,i=performance.getEntriesByName("uv-virtualizing","measure").filter(t=>t.startTime>=this._benchmarkStart&&t.startTime<e).reduce((e,t)=>e+t.duration,0);return this._benchmarkStart=null,{timeElapsed:t,virtualizationTime:i}}return null}_measureChildren(){const e={},t=this._children,i=this._measureChildOverride||this._measureChild;for(let n=0;n<t.length;n++){const s=t[n],a=this._first+n;(this._itemsChanged||this._toBeMeasured.has(s))&&(e[a]=i.call(this,s,this._items[a]))}this._childMeasurements=e,this._schedule(this._updateLayout),this._toBeMeasured.clear()}_measureChild(e){const{width:t,height:i}=e.getBoundingClientRect();return Object.assign({width:t,height:i},function(e){const t=window.getComputedStyle(e);return{marginTop:cy(t.marginTop),marginRight:cy(t.marginRight),marginBottom:cy(t.marginBottom),marginLeft:cy(t.marginLeft)}}(e))}async _schedule(e){this._scheduled.has(e)||(this._scheduled.add(e),await Promise.resolve(),this._scheduled.delete(e),e.call(this))}async _updateDOM(e){this._scrollSize=e.scrollSize,this._adjustRange(e.range),this._childrenPos=e.childPositions,this._scrollError=e.scrollError||null;const{_rangeChanged:t,_itemsChanged:i}=this;this._visibilityChanged&&(this._notifyVisibility(),this._visibilityChanged=!1),(t||i)&&(this._notifyRange(),this._rangeChanged=!1),this._finishDOMUpdate()}_finishDOMUpdate(){this._connected&&(this._children.forEach(e=>this._childrenRO.observe(e)),this._checkScrollIntoViewTarget(this._childrenPos),this._positionChildren(this._childrenPos),this._sizeHostElement(this._scrollSize),this._correctScrollError(),this._benchmarkStart&&"mark"in window.performance&&window.performance.mark("uv-end"))}_updateLayout(){this._layout&&this._connected&&(this._layout.items=this._items,this._updateView(),null!==this._childMeasurements&&(this._measureCallback&&this._measureCallback(this._childMeasurements),this._childMeasurements=null),this._layout.reflowIfNeeded(),this._benchmarkStart&&"mark"in window.performance&&window.performance.mark("uv-end"))}_handleScrollEvent(){if(this._benchmarkStart&&"mark"in window.performance){try{window.performance.measure("uv-virtualizing","uv-start","uv-end")}catch(e){console.warn("Error measuring performance data: ",e)}window.performance.mark("uv-start")}!1===this._scrollerController.correctingScrollError&&this._layout?.unpin(),this._schedule(this._updateLayout)}handleEvent(e){if("scroll"===e.type)(e.currentTarget===window||this._clippingAncestors.includes(e.currentTarget))&&this._handleScrollEvent();else console.warn("event not handled",e)}_handleLayoutMessage(e){"stateChanged"===e.type?this._updateDOM(e):"visibilityChanged"===e.type?(this._firstVisible=e.firstVisible,this._lastVisible=e.lastVisible,this._notifyVisibility()):"unpinned"===e.type&&this._hostElement.dispatchEvent(new iy)}get _children(){const e=[];let t=this._hostElement.firstElementChild;for(;t;)t.hasAttribute(ry)||e.push(t),t=t.nextElementSibling;return e}_updateView(){const e=this._hostElement,t=this._scrollerController?.element,i=this._layout;if(e&&t&&i){let n,s,a,o;const r=e.getBoundingClientRect();n=0,s=0,a=window.innerHeight,o=window.innerWidth;const l=this._clippingAncestors.map(e=>e.getBoundingClientRect());l.unshift(r);for(const e of l)n=Math.max(n,e.top),s=Math.max(s,e.left),a=Math.min(a,e.bottom),o=Math.min(o,e.right);const d=t.getBoundingClientRect(),c={left:r.left-d.left,top:r.top-d.top},h={width:t.scrollWidth,height:t.scrollHeight},p=n-r.top+e.scrollTop,u=s-r.left+e.scrollLeft,m=Math.max(0,a-n),f=Math.max(0,o-s);i.viewportSize={width:f,height:m},i.viewportScroll={top:p,left:u},i.totalScrollSize=h,i.offsetWithinScroller=c}}_sizeHostElement(e){const t=82e5,i=e&&null!==e.width?Math.min(t,e.width):0,n=e&&null!==e.height?Math.min(t,e.height):0;if(this._isScroller)this._getSizer().style.transform=`translate(${i}px, ${n}px)`;else{const e=this._hostElement.style;e.minWidth=i?`${i}px`:"100%",e.minHeight=n?`${n}px`:"100%"}}_positionChildren(e){e&&e.forEach(({top:e,left:t,width:i,height:n,xOffset:s,yOffset:a},o)=>{const r=this._children[o-this._first];r&&(r.style.position="absolute",r.style.boxSizing="border-box",r.style.transform=`translate(${t}px, ${e}px)`,void 0!==i&&(r.style.width=i+"px"),void 0!==n&&(r.style.height=n+"px"),r.style.left=void 0===s?null:s+"px",r.style.top=void 0===a?null:a+"px")})}async _adjustRange(e){const{_first:t,_last:i,_firstVisible:n,_lastVisible:s}=this;this._first=e.first,this._last=e.last,this._firstVisible=e.firstVisible,this._lastVisible=e.lastVisible,this._rangeChanged=this._rangeChanged||this._first!==t||this._last!==i,this._visibilityChanged=this._visibilityChanged||this._firstVisible!==n||this._lastVisible!==s}_correctScrollError(){if(this._scrollError){const{scrollTop:e,scrollLeft:t}=this._scrollerController,{top:i,left:n}=this._scrollError;this._scrollError=null,this._scrollerController.correctScrollError({top:e-i,left:t-n})}}element(e){return e===1/0&&(e=this._items.length-1),void 0===this._items?.[e]?void 0:{scrollIntoView:(t={})=>this._scrollElementIntoView({...t,index:e})}}_scrollElementIntoView(e){if(e.index>=this._first&&e.index<=this._last)this._children[e.index-this._first].scrollIntoView(e);else if(e.index=Math.min(e.index,this._items.length-1),"smooth"===e.behavior){const t=this._layout.getScrollIntoViewCoordinates(e),{behavior:i}=e;this._updateScrollIntoViewCoordinates=this._scrollerController.managedScrollTo(Object.assign(t,{behavior:i}),()=>this._layout.getScrollIntoViewCoordinates(e),()=>this._scrollIntoViewTarget=null),this._scrollIntoViewTarget=e}else this._layout.pin=e}_checkScrollIntoViewTarget(e){const{index:t}=this._scrollIntoViewTarget||{};t&&e?.has(t)&&this._updateScrollIntoViewCoordinates(this._layout.getScrollIntoViewCoordinates(this._scrollIntoViewTarget))}_notifyRange(){this._hostElement.dispatchEvent(new ey({first:this._first,last:this._last}))}_notifyVisibility(){this._hostElement.dispatchEvent(new ty({first:this._firstVisible,last:this._lastVisible}))}get layoutComplete(){return this._layoutCompletePromise||(this._layoutCompletePromise=new Promise((e,t)=>{this._layoutCompleteResolver=e,this._layoutCompleteRejecter=t})),this._layoutCompletePromise}_rejectLayoutCompletePromise(e){null!==this._layoutCompleteRejecter&&this._layoutCompleteRejecter(e),this._resetLayoutCompleteState()}_scheduleLayoutComplete(){this._layoutCompletePromise&&null===this._pendingLayoutComplete&&(this._pendingLayoutComplete=requestAnimationFrame(()=>requestAnimationFrame(()=>this._resolveLayoutCompletePromise())))}_resolveLayoutCompletePromise(){null!==this._layoutCompleteResolver&&this._layoutCompleteResolver(),this._resetLayoutCompleteState()}_resetLayoutCompleteState(){this._layoutCompletePromise=null,this._layoutCompleteResolver=null,this._layoutCompleteRejecter=null,this._pendingLayoutComplete=null}_hostElementSizeChanged(){this._schedule(this._updateLayout)}_childLoaded(){}_childrenSizeChanged(e){if(this._layout?.measureChildren){for(const t of e)this._toBeMeasured.set(t.target,t.contentRect);this._measureChildren()}this._scheduleLayoutComplete(),this._itemsChanged=!1,this._rangeChanged=!1}}function cy(e){const t=e?parseFloat(e):NaN;return Number.isNaN(t)?0:t}function hy(e){if(null!==e.assignedSlot)return e.assignedSlot;if(null!==e.parentElement)return e.parentElement;const t=e.parentNode;return t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&t.host||null}const py=e=>e,uy=(e,t)=>q`${t}: ${JSON.stringify(e,null,2)}`;const my=Se(class extends Jr{constructor(e){if(super(e),this._virtualizer=null,this._first=0,this._last=-1,this._renderItem=(e,t)=>uy(e,t+this._first),this._keyFunction=(e,t)=>py(e,this._first),this._items=[],e.type!==Me)throw new Error("The virtualize directive can only be used in child expressions")}render(e){e&&this._setFunctions(e);const t=[];if(this._first>=0&&this._last>=this._first)for(let e=this._first;e<=this._last;e++)t.push(this._items[e]);return Cn(t,this._keyFunction,this._renderItem)}update(e,[t]){this._setFunctions(t);const i=this._items!==t.items;return this._items=t.items||[],this._virtualizer?this._updateVirtualizerConfig(e,t):this._initialize(e,t),i?J:this.render()}async _updateVirtualizerConfig(e,t){if(!await this._virtualizer.updateLayoutConfig(t.layout||{})){const i=e.parentNode;this._makeVirtualizer(i,t)}this._virtualizer.items=this._items}_setFunctions(e){const{renderItem:t,keyFunction:i}=e;t&&(this._renderItem=(e,i)=>t(e,i+this._first)),i&&(this._keyFunction=(e,t)=>i(e,t+this._first))}_makeVirtualizer(e,t){this._virtualizer&&this._virtualizer.disconnected();const{layout:i,scroller:n,items:s}=t;this._virtualizer=new dy({hostElement:e,layout:i,scroller:n}),this._virtualizer.items=s,this._virtualizer.connected()}_initialize(e,t){const i=e.parentNode;i&&1===i.nodeType&&(i.addEventListener("rangeChanged",e=>{this._first=e.first,this._last=e.last,this.setValue(this.render())}),this._makeVirtualizer(i,t))}disconnected(){this._virtualizer?.disconnected()}reconnected(){this._virtualizer?.connected()}});
|
|
29542
|
+
*/(this._hostElement,e),this._scrollerController=new sy(this,this._clippingAncestors[0]),this._schedule(this._updateLayout),this._observeAndListen(),this._connected=!0}_observeAndListen(){this._mutationObserver.observe(this._hostElement,{childList:!0}),this._hostElementRO.observe(this._hostElement),this._scrollEventListeners.push(window),window.addEventListener("scroll",this,this._scrollEventListenerOptions),this._clippingAncestors.forEach(e=>{e.addEventListener("scroll",this,this._scrollEventListenerOptions),this._scrollEventListeners.push(e),this._hostElementRO.observe(e)}),this._hostElementRO.observe(this._scrollerController.element),this._children.forEach(e=>this._childrenRO.observe(e)),this._scrollEventListeners.forEach(e=>e.addEventListener("scroll",this,this._scrollEventListenerOptions))}disconnected(){this._scrollEventListeners.forEach(e=>e.removeEventListener("scroll",this,this._scrollEventListenerOptions)),this._scrollEventListeners=[],this._clippingAncestors=[],this._scrollerController?.detach(this),this._scrollerController=null,this._mutationObserver?.disconnect(),this._mutationObserver=null,this._hostElementRO?.disconnect(),this._hostElementRO=null,this._childrenRO?.disconnect(),this._childrenRO=null,this._rejectLayoutCompletePromise("disconnected"),this._connected=!1}_applyVirtualizerStyles(){const e=this._hostElement.style;e.display=e.display||"block",e.position=e.position||"relative",e.contain=e.contain||"size layout",this._isScroller&&(e.overflow=e.overflow||"auto",e.minHeight=e.minHeight||"150px")}_getSizer(){const e=this._hostElement;if(!this._sizer){let t=e.querySelector(`[${ry}]`);t||(t=document.createElement("div"),t.setAttribute(ry,""),e.appendChild(t)),Object.assign(t.style,{position:"absolute",margin:"-2px 0 0 0",padding:0,visibility:"hidden",fontSize:"2px"}),t.textContent=" ",t.setAttribute(ry,""),this._sizer=t}return this._sizer}async updateLayoutConfig(e){await this._layoutInitialized;const t=e.type||ly;if("function"==typeof t&&this._layout instanceof t){const t={...e};return delete t.type,this._layout.config=t,!0}return!1}async _initLayout(e){let t,i;if("function"==typeof e.type){i=e.type;const n={...e};delete n.type,t=n}else t=e;void 0===i&&(ly=i=(await Promise.resolve().then(function(){return n$})).FlowLayout),this._layout=new i(e=>this._handleLayoutMessage(e),t),this._layout.measureChildren&&"function"==typeof this._layout.updateItemSizes&&("function"==typeof this._layout.measureChildren&&(this._measureChildOverride=this._layout.measureChildren),this._measureCallback=this._layout.updateItemSizes.bind(this._layout)),this._layout.listenForChildLoadEvents&&this._hostElement.addEventListener("load",this._loadListener,!0),this._schedule(this._updateLayout)}startBenchmarking(){null===this._benchmarkStart&&(this._benchmarkStart=window.performance.now())}stopBenchmarking(){if(null!==this._benchmarkStart){const e=window.performance.now(),t=e-this._benchmarkStart,i=performance.getEntriesByName("uv-virtualizing","measure").filter(t=>t.startTime>=this._benchmarkStart&&t.startTime<e).reduce((e,t)=>e+t.duration,0);return this._benchmarkStart=null,{timeElapsed:t,virtualizationTime:i}}return null}_measureChildren(){const e={},t=this._children,i=this._measureChildOverride||this._measureChild;for(let n=0;n<t.length;n++){const s=t[n],a=this._first+n;(this._itemsChanged||this._toBeMeasured.has(s))&&(e[a]=i.call(this,s,this._items[a]))}this._childMeasurements=e,this._schedule(this._updateLayout),this._toBeMeasured.clear()}_measureChild(e){const{width:t,height:i}=e.getBoundingClientRect();return Object.assign({width:t,height:i},function(e){const t=window.getComputedStyle(e);return{marginTop:cy(t.marginTop),marginRight:cy(t.marginRight),marginBottom:cy(t.marginBottom),marginLeft:cy(t.marginLeft)}}(e))}async _schedule(e){this._scheduled.has(e)||(this._scheduled.add(e),await Promise.resolve(),this._scheduled.delete(e),e.call(this))}async _updateDOM(e){this._scrollSize=e.scrollSize,this._adjustRange(e.range),this._childrenPos=e.childPositions,this._scrollError=e.scrollError||null;const{_rangeChanged:t,_itemsChanged:i}=this;this._visibilityChanged&&(this._notifyVisibility(),this._visibilityChanged=!1),(t||i)&&(this._notifyRange(),this._rangeChanged=!1),this._finishDOMUpdate()}_finishDOMUpdate(){this._connected&&(this._children.forEach(e=>this._childrenRO.observe(e)),this._checkScrollIntoViewTarget(this._childrenPos),this._positionChildren(this._childrenPos),this._sizeHostElement(this._scrollSize),this._correctScrollError(),this._benchmarkStart&&"mark"in window.performance&&window.performance.mark("uv-end"))}_updateLayout(){this._layout&&this._connected&&(this._layout.items=this._items,this._updateView(),null!==this._childMeasurements&&(this._measureCallback&&this._measureCallback(this._childMeasurements),this._childMeasurements=null),this._layout.reflowIfNeeded(),this._benchmarkStart&&"mark"in window.performance&&window.performance.mark("uv-end"))}_handleScrollEvent(){if(this._benchmarkStart&&"mark"in window.performance){try{window.performance.measure("uv-virtualizing","uv-start","uv-end")}catch(e){console.warn("Error measuring performance data: ",e)}window.performance.mark("uv-start")}!1===this._scrollerController.correctingScrollError&&this._layout?.unpin(),this._schedule(this._updateLayout)}handleEvent(e){if("scroll"===e.type)(e.currentTarget===window||this._clippingAncestors.includes(e.currentTarget))&&this._handleScrollEvent();else console.warn("event not handled",e)}_handleLayoutMessage(e){"stateChanged"===e.type?this._updateDOM(e):"visibilityChanged"===e.type?(this._firstVisible=e.firstVisible,this._lastVisible=e.lastVisible,this._notifyVisibility()):"unpinned"===e.type&&this._hostElement.dispatchEvent(new iy)}get _children(){const e=[];let t=this._hostElement.firstElementChild;for(;t;)t.hasAttribute(ry)||e.push(t),t=t.nextElementSibling;return e}_updateView(){const e=this._hostElement,t=this._scrollerController?.element,i=this._layout;if(e&&t&&i){let n,s,a,o;const r=e.getBoundingClientRect();n=0,s=0,a=window.innerHeight,o=window.innerWidth;const l=this._clippingAncestors.map(e=>e.getBoundingClientRect());l.unshift(r);for(const e of l)n=Math.max(n,e.top),s=Math.max(s,e.left),a=Math.min(a,e.bottom),o=Math.min(o,e.right);const d=t.getBoundingClientRect(),c={left:r.left-d.left,top:r.top-d.top},h={width:t.scrollWidth,height:t.scrollHeight},p=n-r.top+e.scrollTop,u=s-r.left+e.scrollLeft,m=Math.max(0,a-n),f=Math.max(0,o-s);i.viewportSize={width:f,height:m},i.viewportScroll={top:p,left:u},i.totalScrollSize=h,i.offsetWithinScroller=c}}_sizeHostElement(e){const t=82e5,i=e&&null!==e.width?Math.min(t,e.width):0,n=e&&null!==e.height?Math.min(t,e.height):0;if(this._isScroller)this._getSizer().style.transform=`translate(${i}px, ${n}px)`;else{const e=this._hostElement.style;e.minWidth=i?`${i}px`:"100%",e.minHeight=n?`${n}px`:"100%"}}_positionChildren(e){e&&e.forEach(({top:e,left:t,width:i,height:n,xOffset:s,yOffset:a},o)=>{const r=this._children[o-this._first];r&&(r.style.position="absolute",r.style.boxSizing="border-box",r.style.transform=`translate(${t}px, ${e}px)`,void 0!==i&&(r.style.width=i+"px"),void 0!==n&&(r.style.height=n+"px"),r.style.left=void 0===s?null:s+"px",r.style.top=void 0===a?null:a+"px")})}async _adjustRange(e){const{_first:t,_last:i,_firstVisible:n,_lastVisible:s}=this;this._first=e.first,this._last=e.last,this._firstVisible=e.firstVisible,this._lastVisible=e.lastVisible,this._rangeChanged=this._rangeChanged||this._first!==t||this._last!==i,this._visibilityChanged=this._visibilityChanged||this._firstVisible!==n||this._lastVisible!==s}_correctScrollError(){if(this._scrollError){const{scrollTop:e,scrollLeft:t}=this._scrollerController,{top:i,left:n}=this._scrollError;this._scrollError=null,this._scrollerController.correctScrollError({top:e-i,left:t-n})}}element(e){return e===1/0&&(e=this._items.length-1),void 0===this._items?.[e]?void 0:{scrollIntoView:(t={})=>this._scrollElementIntoView({...t,index:e})}}_scrollElementIntoView(e){if(e.index>=this._first&&e.index<=this._last)this._children[e.index-this._first].scrollIntoView(e);else if(e.index=Math.min(e.index,this._items.length-1),"smooth"===e.behavior){const t=this._layout.getScrollIntoViewCoordinates(e),{behavior:i}=e;this._updateScrollIntoViewCoordinates=this._scrollerController.managedScrollTo(Object.assign(t,{behavior:i}),()=>this._layout.getScrollIntoViewCoordinates(e),()=>this._scrollIntoViewTarget=null),this._scrollIntoViewTarget=e}else this._layout.pin=e}_checkScrollIntoViewTarget(e){const{index:t}=this._scrollIntoViewTarget||{};t&&e?.has(t)&&this._updateScrollIntoViewCoordinates(this._layout.getScrollIntoViewCoordinates(this._scrollIntoViewTarget))}_notifyRange(){this._hostElement.dispatchEvent(new ey({first:this._first,last:this._last}))}_notifyVisibility(){this._hostElement.dispatchEvent(new ty({first:this._firstVisible,last:this._lastVisible}))}get layoutComplete(){return this._layoutCompletePromise||(this._layoutCompletePromise=new Promise((e,t)=>{this._layoutCompleteResolver=e,this._layoutCompleteRejecter=t})),this._layoutCompletePromise}_rejectLayoutCompletePromise(e){null!==this._layoutCompleteRejecter&&this._layoutCompleteRejecter(e),this._resetLayoutCompleteState()}_scheduleLayoutComplete(){this._layoutCompletePromise&&null===this._pendingLayoutComplete&&(this._pendingLayoutComplete=requestAnimationFrame(()=>requestAnimationFrame(()=>this._resolveLayoutCompletePromise())))}_resolveLayoutCompletePromise(){null!==this._layoutCompleteResolver&&this._layoutCompleteResolver(),this._resetLayoutCompleteState()}_resetLayoutCompleteState(){this._layoutCompletePromise=null,this._layoutCompleteResolver=null,this._layoutCompleteRejecter=null,this._pendingLayoutComplete=null}_hostElementSizeChanged(){this._schedule(this._updateLayout)}_childLoaded(){}_childrenSizeChanged(e){if(this._layout?.measureChildren){for(const t of e)this._toBeMeasured.set(t.target,t.contentRect);this._measureChildren()}this._scheduleLayoutComplete(),this._itemsChanged=!1,this._rangeChanged=!1}}function cy(e){const t=e?parseFloat(e):NaN;return Number.isNaN(t)?0:t}function hy(e){if(null!==e.assignedSlot)return e.assignedSlot;if(null!==e.parentElement)return e.parentElement;const t=e.parentNode;return t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&t.host||null}const py=e=>e,uy=(e,t)=>q`${t}: ${JSON.stringify(e,null,2)}`;const my=Se(class extends Jr{constructor(e){if(super(e),this._virtualizer=null,this._first=0,this._last=-1,this._renderItem=(e,t)=>uy(e,t+this._first),this._keyFunction=(e,t)=>py(e,this._first),this._items=[],e.type!==Me)throw new Error("The virtualize directive can only be used in child expressions")}render(e){e&&this._setFunctions(e);const t=[];if(this._first>=0&&this._last>=this._first)for(let e=this._first;e<=this._last;e++)t.push(this._items[e]);return _n(t,this._keyFunction,this._renderItem)}update(e,[t]){this._setFunctions(t);const i=this._items!==t.items;return this._items=t.items||[],this._virtualizer?this._updateVirtualizerConfig(e,t):this._initialize(e,t),i?J:this.render()}async _updateVirtualizerConfig(e,t){if(!await this._virtualizer.updateLayoutConfig(t.layout||{})){const i=e.parentNode;this._makeVirtualizer(i,t)}this._virtualizer.items=this._items}_setFunctions(e){const{renderItem:t,keyFunction:i}=e;t&&(this._renderItem=(e,i)=>t(e,i+this._first)),i&&(this._keyFunction=(e,t)=>i(e,t+this._first))}_makeVirtualizer(e,t){this._virtualizer&&this._virtualizer.disconnected();const{layout:i,scroller:n,items:s}=t;this._virtualizer=new dy({hostElement:e,layout:i,scroller:n}),this._virtualizer.items=s,this._virtualizer.connected()}_initialize(e,t){const i=e.parentNode;i&&1===i.nodeType&&(i.addEventListener("rangeChanged",e=>{this._first=e.first,this._last=e.last,this.setValue(this.render())}),this._makeVirtualizer(i,t))}disconnected(){this._virtualizer?.disconnected()}reconnected(){this._virtualizer?.connected()}});
|
|
29480
29543
|
/**
|
|
29481
29544
|
* @license
|
|
29482
29545
|
* Copyright 2021 Google LLC
|
|
@@ -34144,7 +34207,7 @@ class Ox extends tt{}
|
|
|
34144
34207
|
@nr-change=${e.onCheckAll}
|
|
34145
34208
|
></nr-checkbox>`:K}
|
|
34146
34209
|
</th>`:K}
|
|
34147
|
-
${
|
|
34210
|
+
${_n(e.headers,(t,i)=>{const n=Rx(t),s=e.expandable||e.expansionRenderer||e.selectionMode,a="left"===t.fixed?Hx(e.headers,i,!!s):void 0,o=t.width?"number"==typeof t.width?`${t.width}px`:t.width:void 0;return q`
|
|
34148
34211
|
${e.expandable!==t.key?q`<th
|
|
34149
34212
|
class="${[t.filterable?"filterable":"",n].filter(Boolean).join(" ")}"
|
|
34150
34213
|
style="${void 0!==a?`left: ${a}px;`:""} ${o?`width: ${o}; min-width: ${o};`:""}">
|
|
@@ -34271,7 +34334,7 @@ class Ox extends tt{}
|
|
|
34271
34334
|
</div>
|
|
34272
34335
|
</td>
|
|
34273
34336
|
</tr>
|
|
34274
|
-
`}(e.host):
|
|
34337
|
+
`}(e.host):_n(e.rows,(n,s)=>q`
|
|
34275
34338
|
<tr class="${e.clickable?"clickable":""}" @click=${()=>{var t;return null===(t=e.onRowClick)||void 0===t?void 0:t.call(e,n,s)}}>
|
|
34276
34339
|
${!e.expandable&&!e.expansionRenderer||e.selectionMode?e.selectionMode?Bc(e.selectionMode,[["multiple",()=>q`<td class="${i}" style="${t?"left: 0; width: 50px; min-width: 50px;":""}">
|
|
34277
34340
|
<nr-checkbox
|
|
@@ -34298,7 +34361,7 @@ class Ox extends tt{}
|
|
|
34298
34361
|
<nr-icon name="chevron-down" size="small"></nr-icon>
|
|
34299
34362
|
</td>
|
|
34300
34363
|
`}
|
|
34301
|
-
${
|
|
34364
|
+
${_n(e.headers,(t,i)=>{const a=Rx(t),o=e.expandable||e.expansionRenderer||e.selectionMode,r="left"===t.fixed?Hx(e.headers,i,!!o):void 0,l=t.width?"number"==typeof t.width?`${t.width}px`:t.width:void 0,d=n[t.key],c=t.render?t.render(d,n,s):d;return q`${e.expandable!==t.key?q`<td
|
|
34302
34365
|
class="${a}"
|
|
34303
34366
|
style="${void 0!==r?`left: ${r}px;`:""} ${l?`width: ${l}; min-width: ${l};`:""}">
|
|
34304
34367
|
${c}
|
|
@@ -36966,7 +37029,7 @@ const ek=r`
|
|
|
36966
37029
|
*/
|
|
36967
37030
|
var nk=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};let sk=class extends(je(me)){constructor(){super(...arguments),this.requiredComponents=["nr-icon","nr-button"],this.position="top-right",this.maxToasts=5,this.defaultDuration=5e3,this.animation="fade",this.stack=!0,this.autoDismiss=!0,this.toasts=[],this.timeouts=new Map}show(e){var t,i,n;const s="string"==typeof e?{text:e}:e,a={id:this.generateId(),timestamp:Date.now(),text:s.text,content:s.content,type:s.type||"default",duration:null!==(t=s.duration)&&void 0!==t?t:this.defaultDuration,autoDismiss:null!==(i=s.autoDismiss)&&void 0!==i?i:this.autoDismiss,closable:null===(n=s.closable)||void 0===n||n,icon:s.icon||this.getDefaultIcon(s.type),customClass:s.customClass,button:s.button,onClose:s.onClose,onClick:s.onClick};if(this.stack?this.toasts.length>=this.maxToasts&&this.removeToast(this.toasts[0].id):this.clearAll(),this.toasts=[...this.toasts,a],this.emitToastEvent("nr-toast-show",a,"show"),a.autoDismiss&&a.duration&&a.duration>0){const e=window.setTimeout(()=>{this.removeToast(a.id)},a.duration);this.timeouts.set(a.id,e)}return a.id}success(e,t){return this.show({text:e,type:"success",duration:t})}error(e,t){return this.show({text:e,type:"error",duration:t})}warning(e,t){return this.show({text:e,type:"warning",duration:t})}info(e,t){return this.show({text:e,type:"info",duration:t})}removeToast(e){const t=this.toasts.find(t=>t.id===e);if(!t)return;t.removing=!0,this.requestUpdate();const i=this.timeouts.get(e);i&&(clearTimeout(i),this.timeouts.delete(e)),setTimeout(()=>{var i;this.toasts=this.toasts.filter(t=>t.id!==e),this.emitToastEvent("nr-toast-close",t,"close"),null===(i=t.onClose)||void 0===i||i.call(t)},300)}clearAll(){this.toasts.forEach(e=>{const t=this.timeouts.get(e.id);t&&clearTimeout(t)}),this.timeouts.clear(),this.toasts=[]}handleToastClick(e){var t;this.emitToastEvent("nr-toast-click",e,"click"),null===(t=e.onClick)||void 0===t||t.call(e)}handleCloseClick(e,t){e.stopPropagation(),this.removeToast(t.id)}getDefaultIcon(e){switch(e){case"success":return"check-circle";case"error":return"x-circle";case"warning":return"alert-triangle";case"info":return"info";default:return""}}generateId(){return`toast-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}getAnimationClass(e){const t=e.removing?"out":"in";return`toast--${this.animation}-${t}`}emitToastEvent(e,t,i){this.dispatchEvent(new CustomEvent(e,{detail:{toast:t,action:i},bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.clearAll()}render(){return q`
|
|
36968
37031
|
<div class="toast-container" part="container">
|
|
36969
|
-
${
|
|
37032
|
+
${_n(this.toasts,e=>e.id,e=>this.renderToast(e))}
|
|
36970
37033
|
</div>
|
|
36971
37034
|
`}renderToast(e){const t={toast:!0,[`toast--${e.type}`]:!0,[this.getAnimationClass(e)]:!0,[e.customClass||""]:!!e.customClass};return q`
|
|
36972
37035
|
<div
|