@nuraly/lumenui 0.1.0 → 0.2.1
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 +23024 -17355
- package/dist/nuralyui.bundle.js.gz +0 -0
- package/dist/src/components/alert/alert.component.d.ts +8 -5
- package/dist/src/components/alert/alert.component.js +24 -20
- package/dist/src/components/alert/alert.style.d.ts +0 -7
- package/dist/src/components/alert/alert.style.js +48 -90
- package/dist/src/components/alert/bundle.js +82 -108
- package/dist/src/components/alert/bundle.js.gz +0 -0
- package/dist/src/components/badge/badge.component.d.ts +9 -8
- package/dist/src/components/badge/badge.component.js +17 -14
- package/dist/src/components/badge/badge.style.d.ts +0 -7
- package/dist/src/components/badge/badge.style.js +49 -107
- package/dist/src/components/badge/bundle.js +81 -119
- package/dist/src/components/badge/bundle.js.gz +0 -0
- package/dist/src/components/breadcrumb/breadcrumb.component.d.ts +8 -10
- package/dist/src/components/breadcrumb/breadcrumb.component.js +16 -15
- package/dist/src/components/breadcrumb/breadcrumb.style.d.ts +0 -7
- package/dist/src/components/breadcrumb/breadcrumb.style.js +42 -60
- package/dist/src/components/breadcrumb/bundle.js +96 -93
- package/dist/src/components/breadcrumb/bundle.js.gz +0 -0
- package/dist/src/components/button/bundle.js +221 -470
- package/dist/src/components/button/bundle.js.gz +0 -0
- package/dist/src/components/button/button.component.d.ts +2 -1
- package/dist/src/components/button/button.component.js +6 -6
- package/dist/src/components/button/button.style.d.ts +0 -7
- package/dist/src/components/button/button.style.js +167 -433
- package/dist/src/components/canvas/base-canvas.component.d.ts +2 -1
- package/dist/src/components/canvas/base-canvas.component.js +1 -0
- package/dist/src/components/canvas/bundle.js +16919 -9595
- package/dist/src/components/canvas/bundle.js.gz +0 -0
- package/dist/src/components/canvas/canvas.constants.d.ts +1 -1
- package/dist/src/components/canvas/canvas.constants.js +1 -1
- package/dist/src/components/canvas/chatbot-panel.style.js +31 -31
- package/dist/src/components/canvas/index.d.ts +2 -0
- package/dist/src/components/canvas/index.js +3 -0
- package/dist/src/components/canvas/whiteboard-canvas.component.d.ts +3 -1
- package/dist/src/components/canvas/whiteboard-canvas.component.js +19 -1
- package/dist/src/components/canvas/whiteboard-canvas.style.js +159 -138
- package/dist/src/components/canvas/whiteboard-node.component.d.ts +2 -1
- package/dist/src/components/canvas/whiteboard-node.component.js +2 -1
- package/dist/src/components/canvas/whiteboard-node.style.js +44 -44
- package/dist/src/components/canvas/workflow-canvas-only.d.ts +4 -0
- package/dist/src/components/canvas/workflow-canvas-only.js +5 -0
- package/dist/src/components/canvas/workflow-canvas.component.d.ts +3 -1
- package/dist/src/components/canvas/workflow-canvas.component.js +24 -2
- package/dist/src/components/canvas/workflow-canvas.style.js +776 -648
- package/dist/src/components/canvas/workflow-canvas.types.d.ts +113 -4
- package/dist/src/components/canvas/workflow-canvas.types.js +646 -3
- package/dist/src/components/canvas/workflow-node.component.d.ts +3 -2
- package/dist/src/components/canvas/workflow-node.component.js +5 -5
- package/dist/src/components/canvas/workflow-node.style.js +183 -181
- package/dist/src/components/card/bundle.js +43 -35
- package/dist/src/components/card/bundle.js.gz +0 -0
- package/dist/src/components/card/card.component.d.ts +6 -1
- package/dist/src/components/card/card.component.js +8 -2
- package/dist/src/components/card/card.style.js +26 -30
- package/dist/src/components/carousel/bundle.js +8 -8
- package/dist/src/components/carousel/bundle.js.gz +0 -0
- package/dist/src/components/carousel/carousel.component.d.ts +12 -0
- package/dist/src/components/carousel/carousel.component.js +16 -4
- package/dist/src/components/chatbot/bundle.js +422 -406
- package/dist/src/components/chatbot/bundle.js.gz +0 -0
- package/dist/src/components/chatbot/chatbot.component.d.ts +2 -1
- package/dist/src/components/chatbot/chatbot.component.js +1 -0
- package/dist/src/components/chatbot/chatbot.style.js +277 -277
- package/dist/src/components/checkbox/bundle.js +86 -245
- package/dist/src/components/checkbox/bundle.js.gz +0 -0
- package/dist/src/components/checkbox/checkbox.component.d.ts +5 -2
- package/dist/src/components/checkbox/checkbox.component.js +11 -13
- package/dist/src/components/checkbox/checkbox.style.js +56 -231
- package/dist/src/components/code-editor/bundle.js +151 -25
- package/dist/src/components/code-editor/bundle.js.gz +0 -0
- package/dist/src/components/code-editor/code-editor.component.d.ts +18 -56
- package/dist/src/components/code-editor/code-editor.component.js +141 -394
- package/dist/src/components/code-editor/code-editor.style.js +139 -15
- package/dist/src/components/collapse/bundle.js +97 -84
- package/dist/src/components/collapse/bundle.js.gz +0 -0
- package/dist/src/components/collapse/collapse.component.d.ts +7 -1
- package/dist/src/components/collapse/collapse.component.js +11 -2
- package/dist/src/components/collapse/collapse.style.js +60 -60
- package/dist/src/components/colorpicker/bundle.js +85 -48
- package/dist/src/components/colorpicker/bundle.js.gz +0 -0
- package/dist/src/components/colorpicker/color-holder.component.d.ts +2 -4
- package/dist/src/components/colorpicker/color-holder.component.js +5 -6
- package/dist/src/components/colorpicker/color-holder.style.js +11 -11
- package/dist/src/components/colorpicker/color-picker.component.d.ts +2 -1
- package/dist/src/components/colorpicker/color-picker.component.js +1 -0
- package/dist/src/components/colorpicker/color-picker.style.js +12 -12
- package/dist/src/components/colorpicker/default-color-sets.component.d.ts +2 -2
- package/dist/src/components/colorpicker/default-color-sets.component.js +4 -3
- package/dist/src/components/colorpicker/default-color-sets.style.js +5 -5
- package/dist/src/components/container/bundle.js +24 -14
- package/dist/src/components/container/bundle.js.gz +0 -0
- package/dist/src/components/container/container.component.d.ts +4 -1
- package/dist/src/components/container/container.component.js +7 -5
- package/dist/src/components/container/container.style.js +9 -9
- package/dist/src/components/datepicker/bundle.js +193 -177
- package/dist/src/components/datepicker/bundle.js.gz +0 -0
- package/dist/src/components/datepicker/datepicker.component.d.ts +2 -1
- package/dist/src/components/datepicker/datepicker.component.js +1 -0
- package/dist/src/components/datepicker/datepicker.style.js +65 -65
- package/dist/src/components/datepicker/datepicker.style.variables.js +91 -91
- package/dist/src/components/db-connection-select/bundle.js +7 -6
- package/dist/src/components/db-connection-select/bundle.js.gz +0 -0
- package/dist/src/components/db-connection-select/db-connection-select.component.d.ts +3 -0
- package/dist/src/components/db-connection-select/db-connection-select.component.js +4 -0
- package/dist/src/components/divider/bundle.js +61 -35
- package/dist/src/components/divider/bundle.js.gz +0 -0
- package/dist/src/components/divider/divider.component.d.ts +4 -6
- package/dist/src/components/divider/divider.component.js +10 -14
- package/dist/src/components/divider/divider.style.js +41 -31
- package/dist/src/components/document/bundle.js +50 -48
- package/dist/src/components/document/bundle.js.gz +0 -0
- package/dist/src/components/document/document.component.d.ts +12 -1
- package/dist/src/components/document/document.component.js +18 -6
- package/dist/src/components/document/document.style.js +21 -36
- package/dist/src/components/dropdown/bundle.js +117 -101
- package/dist/src/components/dropdown/bundle.js.gz +0 -0
- package/dist/src/components/dropdown/dropdown.component.d.ts +2 -1
- package/dist/src/components/dropdown/dropdown.component.js +1 -0
- package/dist/src/components/dropdown/dropdown.style.js +68 -68
- package/dist/src/components/file-upload/bundle.js +82 -76
- package/dist/src/components/file-upload/bundle.js.gz +0 -0
- package/dist/src/components/file-upload/file-upload.component.d.ts +2 -1
- package/dist/src/components/file-upload/file-upload.component.js +1 -0
- package/dist/src/components/file-upload/styles.js +59 -59
- package/dist/src/components/flex/bundle.js +18 -8
- package/dist/src/components/flex/bundle.js.gz +0 -0
- package/dist/src/components/flex/flex.component.d.ts +4 -1
- package/dist/src/components/flex/flex.component.js +7 -4
- package/dist/src/components/flex/flex.style.js +2 -2
- package/dist/src/components/form/bundle.js +22 -10
- package/dist/src/components/form/bundle.js.gz +0 -0
- package/dist/src/components/form/form.component.d.ts +4 -1
- package/dist/src/components/form/form.component.js +5 -1
- package/dist/src/components/form/form.style.js +2 -2
- package/dist/src/components/grid/bundle.js +26 -14
- package/dist/src/components/grid/bundle.js.gz +0 -0
- package/dist/src/components/grid/col.component.d.ts +4 -1
- package/dist/src/components/grid/col.component.js +4 -1
- package/dist/src/components/grid/col.style.js +2 -2
- package/dist/src/components/grid/row.component.d.ts +4 -1
- package/dist/src/components/grid/row.component.js +4 -1
- package/dist/src/components/grid/row.style.js +2 -2
- package/dist/src/components/icon/bundle.js +78 -252
- package/dist/src/components/icon/bundle.js.gz +0 -0
- package/dist/src/components/icon/icon-paths.d.ts +2 -0
- package/dist/src/components/icon/icon-paths.js +141 -0
- package/dist/src/components/icon/icon.component.d.ts +10 -12
- package/dist/src/components/icon/icon.component.js +42 -93
- package/dist/src/components/icon/icon.style.js +42 -130
- package/dist/src/components/icon/icon.variables.js +9 -9
- package/dist/src/components/iconpicker/bundle.js +859 -1511
- package/dist/src/components/iconpicker/bundle.js.gz +0 -0
- package/dist/src/components/iconpicker/icon-picker.component.d.ts +2 -1
- package/dist/src/components/iconpicker/icon-picker.component.js +1 -0
- package/dist/src/components/iconpicker/icon-picker.style.js +13 -13
- package/dist/src/components/image/bundle.js +43 -33
- package/dist/src/components/image/bundle.js.gz +0 -0
- package/dist/src/components/image/image.component.d.ts +10 -1
- package/dist/src/components/image/image.component.js +13 -3
- package/dist/src/components/image/image.style.js +19 -26
- package/dist/src/components/input/bundle.js +420 -644
- package/dist/src/components/input/bundle.js.gz +0 -0
- package/dist/src/components/input/input.component.d.ts +16 -3
- package/dist/src/components/input/input.component.js +43 -27
- package/dist/src/components/input/input.style.d.ts +1 -1
- package/dist/src/components/input/input.style.js +331 -634
- package/dist/src/components/kv-secret-select/bundle.js +2 -1
- package/dist/src/components/kv-secret-select/bundle.js.gz +0 -0
- package/dist/src/components/kv-secret-select/kv-secret-select.component.d.ts +3 -0
- package/dist/src/components/kv-secret-select/kv-secret-select.component.js +4 -0
- package/dist/src/components/label/bundle.js +37 -60
- package/dist/src/components/label/bundle.js.gz +0 -0
- package/dist/src/components/label/label.component.d.ts +8 -4
- package/dist/src/components/label/label.component.js +9 -14
- package/dist/src/components/label/label.style.js +17 -25
- package/dist/src/components/label/label.style.variables.js +18 -18
- package/dist/src/components/layout/bundle.js +86 -70
- package/dist/src/components/layout/bundle.js.gz +0 -0
- package/dist/src/components/layout/content.component.d.ts +2 -1
- package/dist/src/components/layout/content.component.js +2 -1
- package/dist/src/components/layout/content.style.js +3 -3
- package/dist/src/components/layout/footer.component.d.ts +2 -1
- package/dist/src/components/layout/footer.component.js +3 -2
- package/dist/src/components/layout/footer.style.js +7 -7
- package/dist/src/components/layout/header.component.d.ts +2 -1
- package/dist/src/components/layout/header.component.js +3 -2
- package/dist/src/components/layout/header.style.js +7 -7
- package/dist/src/components/layout/layout.component.d.ts +4 -7
- package/dist/src/components/layout/layout.component.js +9 -22
- package/dist/src/components/layout/layout.style.js +1 -1
- package/dist/src/components/layout/sider.component.d.ts +3 -1
- package/dist/src/components/layout/sider.component.js +3 -1
- package/dist/src/components/layout/sider.style.js +29 -29
- package/dist/src/components/menu/bundle.js +135 -125
- package/dist/src/components/menu/bundle.js.gz +0 -0
- package/dist/src/components/menu/menu.component.d.ts +2 -1
- package/dist/src/components/menu/menu.component.js +1 -0
- package/dist/src/components/menu/menu.style.js +87 -87
- package/dist/src/components/modal/bundle.js +105 -96
- package/dist/src/components/modal/bundle.js.gz +0 -0
- package/dist/src/components/modal/modal.component.d.ts +2 -1
- package/dist/src/components/modal/modal.component.js +1 -0
- package/dist/src/components/modal/modal.style.js +69 -71
- package/dist/src/components/panel/bundle.js +190 -391
- package/dist/src/components/panel/bundle.js.gz +0 -0
- package/dist/src/components/panel/panel.component.d.ts +2 -1
- package/dist/src/components/panel/panel.component.js +1 -0
- package/dist/src/components/panel/panel.style.js +65 -65
- package/dist/src/components/popconfirm/bundle.js +107 -93
- package/dist/src/components/popconfirm/bundle.js.gz +0 -0
- package/dist/src/components/popconfirm/popconfirm-manager.component.d.ts +2 -1
- package/dist/src/components/popconfirm/popconfirm-manager.component.js +1 -0
- package/dist/src/components/popconfirm/popconfirm-manager.style.js +16 -16
- package/dist/src/components/popconfirm/popconfirm.component.d.ts +2 -1
- package/dist/src/components/popconfirm/popconfirm.component.js +9 -5
- package/dist/src/components/popconfirm/popconfirm.style.js +43 -43
- package/dist/src/components/radio/bundle.js +56 -86
- package/dist/src/components/radio/bundle.js.gz +0 -0
- package/dist/src/components/radio/radio.component.d.ts +8 -2
- package/dist/src/components/radio/radio.component.js +17 -9
- package/dist/src/components/radio/radio.style.js +30 -77
- package/dist/src/components/radio-group/bundle.js +125 -89
- package/dist/src/components/radio-group/bundle.js.gz +0 -0
- package/dist/src/components/radio-group/radio-group.component.d.ts +5 -1
- package/dist/src/components/radio-group/radio-group.component.js +18 -10
- package/dist/src/components/radio-group/radio-group.style.js +44 -44
- package/dist/src/components/select/bundle.js +260 -367
- package/dist/src/components/select/bundle.js.gz +0 -0
- package/dist/src/components/select/select.component.d.ts +12 -17
- package/dist/src/components/select/select.component.js +35 -35
- package/dist/src/components/select/select.style.js +184 -324
- package/dist/src/components/skeleton/bundle.js +82 -162
- package/dist/src/components/skeleton/bundle.js.gz +0 -0
- package/dist/src/components/skeleton/skeleton.component.d.ts +10 -5
- package/dist/src/components/skeleton/skeleton.component.js +20 -7
- package/dist/src/components/skeleton/skeleton.style.js +34 -133
- package/dist/src/components/slider-input/bundle.js +89 -88
- package/dist/src/components/slider-input/bundle.js.gz +0 -0
- package/dist/src/components/slider-input/slider-input.component.d.ts +11 -0
- package/dist/src/components/slider-input/slider-input.component.js +20 -8
- package/dist/src/components/slider-input/slider-input.style.js +47 -47
- package/dist/src/components/slider-input/slider-input.style.variables.js +32 -32
- package/dist/src/components/table/bundle.js +149 -128
- package/dist/src/components/table/bundle.js.gz +0 -0
- package/dist/src/components/table/table.component.d.ts +2 -1
- package/dist/src/components/table/table.component.js +1 -0
- package/dist/src/components/table/table.style.js +79 -79
- package/dist/src/components/tabs/bundle.js +462 -663
- package/dist/src/components/tabs/bundle.js.gz +0 -0
- package/dist/src/components/tabs/tabs.component.d.ts +6 -1
- package/dist/src/components/tabs/tabs.component.js +8 -1
- package/dist/src/components/tabs/tabs.style.js +200 -201
- package/dist/src/components/tag/bundle.js +44 -36
- package/dist/src/components/tag/bundle.js.gz +0 -0
- package/dist/src/components/tag/tag.component.d.ts +7 -6
- package/dist/src/components/tag/tag.component.js +10 -19
- package/dist/src/components/tag/tag.style.js +20 -24
- package/dist/src/components/textarea/bundle.js +131 -94
- package/dist/src/components/textarea/bundle.js.gz +0 -0
- package/dist/src/components/textarea/textarea.component.d.ts +7 -1
- package/dist/src/components/textarea/textarea.component.js +10 -3
- package/dist/src/components/textarea/textarea.style.d.ts +1 -13
- package/dist/src/components/textarea/textarea.style.js +79 -91
- package/dist/src/components/timeline/bundle.js +71 -134
- package/dist/src/components/timeline/bundle.js.gz +0 -0
- package/dist/src/components/timeline/timeline.component.d.ts +9 -6
- package/dist/src/components/timeline/timeline.component.js +16 -13
- package/dist/src/components/timeline/timeline.style.d.ts +0 -7
- package/dist/src/components/timeline/timeline.style.js +41 -122
- package/dist/src/components/timepicker/bundle.js +196 -166
- package/dist/src/components/timepicker/bundle.js.gz +0 -0
- package/dist/src/components/timepicker/timepicker.component.d.ts +2 -1
- package/dist/src/components/timepicker/timepicker.component.js +1 -0
- package/dist/src/components/timepicker/timepicker.style.js +42 -42
- package/dist/src/components/timepicker/timepicker.style.variables.js +91 -91
- package/dist/src/components/toast/bundle.js +97 -81
- package/dist/src/components/toast/bundle.js.gz +0 -0
- package/dist/src/components/toast/toast.component.d.ts +2 -1
- package/dist/src/components/toast/toast.component.js +1 -0
- package/dist/src/components/toast/toast.style.js +62 -62
- package/dist/src/components/tooltips/bundle.js +10 -10
- package/dist/src/components/tooltips/bundle.js.gz +0 -0
- package/dist/src/components/tooltips/tooltips.component.d.ts +8 -0
- package/dist/src/components/tooltips/tooltips.component.js +9 -1
- package/dist/src/components/tooltips/tooltips.style.js +6 -6
- package/dist/src/components/video/bundle.js +47 -36
- package/dist/src/components/video/bundle.js.gz +0 -0
- package/dist/src/components/video/video.component.d.ts +12 -1
- package/dist/src/components/video/video.component.js +18 -6
- package/dist/src/components/video/video.style.js +18 -24
- package/package.json +25 -12
- package/packages/common/dist/VERSIONS.md +2 -2
- package/packages/common/dist/shared/base-mixin.d.ts +21 -19
- package/packages/common/dist/shared/base-mixin.d.ts.map +1 -1
- package/packages/common/dist/shared/base-mixin.js +102 -18
- package/packages/common/dist/shared/base-mixin.js.map +1 -1
- package/packages/common/dist/shared/index.d.ts +1 -0
- package/packages/common/dist/shared/index.d.ts.map +1 -1
- package/packages/common/dist/shared/index.js +2 -0
- package/packages/common/dist/shared/index.js.map +1 -1
- package/packages/common/dist/shared/style-injector.d.ts +11 -0
- package/packages/common/dist/shared/style-injector.d.ts.map +1 -0
- package/packages/common/dist/shared/style-injector.js +53 -0
- package/packages/common/dist/shared/style-injector.js.map +1 -0
- package/packages/common/dist/shared/theme-mixin.d.ts +2 -24
- package/packages/common/dist/shared/theme-mixin.d.ts.map +1 -1
- package/packages/common/dist/shared/theme-mixin.js +5 -38
- package/packages/common/dist/shared/theme-mixin.js.map +1 -1
- package/packages/themes/dist/default.css +0 -10
- package/packages/themes/dist/package.json +1 -1
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import{css as t,nothing as e,html as n,LitElement as i}from"lit";import{property as o,state as
|
|
1
|
+
import{css as t,nothing as e,html as n,LitElement as i}from"lit";import{property as o,state as s,customElement as r}from"lit/decorators.js";import{classMap as a}from"lit/directives/class-map.js";import{unsafeHTML as l}from"lit/directives/unsafe-html.js";import{repeat as d}from"lit/directives/repeat.js";import{io as c}from"socket.io-client";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2021 Google LLC
|
|
5
5
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
-
*/const
|
|
6
|
+
*/const h="lit-localize-status",u=(t,e,n)=>{let i=t[0];for(let o=1;o<t.length;o++)i+=e[n?n[o-1]:o-1],i+=t[o];return i},p=t=>{return"string"!=typeof(e=t)&&"strTag"in e?u(t.strings,t.values):t;var e};
|
|
7
7
|
/**
|
|
8
8
|
* @license
|
|
9
9
|
* Copyright 2021 Google LLC
|
|
10
10
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
-
*/let
|
|
11
|
+
*/let f=p,g=!1;
|
|
12
12
|
/**
|
|
13
13
|
* @license
|
|
14
14
|
* Copyright 2021 Google LLC
|
|
15
15
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
16
|
*/
|
|
17
|
-
class m{constructor(t){this.t=t=>{"ready"===t.detail.status&&this.host.requestUpdate()},this.host=t}hostConnected(){window.addEventListener(
|
|
17
|
+
class m{constructor(t){this.t=t=>{"ready"===t.detail.status&&this.host.requestUpdate()},this.host=t}hostConnected(){window.addEventListener(h,this.t)}hostDisconnected(){window.removeEventListener(h,this.t)}}const v=t=>t.addController(new m(t));
|
|
18
18
|
/**
|
|
19
19
|
* @license
|
|
20
20
|
* Copyright 2020 Google LLC
|
|
21
21
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
22
22
|
*/
|
|
23
|
-
class
|
|
23
|
+
class b{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._resolve=t,this._reject=e})}resolve(t){this.settled=!0,this._resolve(t)}reject(t){this.settled=!0,this._reject(t)}}
|
|
24
24
|
/**
|
|
25
25
|
* @license
|
|
26
26
|
* Copyright 2014 Travis Webb
|
|
27
27
|
* SPDX-License-Identifier: MIT
|
|
28
|
-
*/const
|
|
28
|
+
*/const y=[];for(let t=0;t<256;t++)y[t]=(t>>4&15).toString(16)+(15&t).toString(16);function x(t,e){return(e?"h":"s")+function(t){let e=0,n=8997,i=0,o=33826,s=0,r=40164,a=0,l=52210;for(let d=0;d<t.length;d++)n^=t.charCodeAt(d),e=435*n,i=435*o,s=435*r,a=435*l,s+=n<<8,a+=o<<8,i+=e>>>16,n=65535&e,s+=i>>>16,o=65535&i,l=a+(s>>>16)&65535,r=65535&s;return y[l>>8]+y[255&l]+y[r>>8]+y[255&r]+y[o>>8]+y[255&o]+y[n>>8]+y[255&n]}
|
|
29
29
|
/**
|
|
30
30
|
* @license
|
|
31
31
|
* Copyright 2020 Google LLC
|
|
@@ -35,17 +35,17 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
35
35
|
* @license
|
|
36
36
|
* Copyright 2021 Google LLC
|
|
37
37
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
38
|
-
*/const
|
|
38
|
+
*/const w=new WeakMap,_=new Map;function $(t,e,n){if(t){const i=n?.id??function(t){const e="string"==typeof t?t:t.strings;let n=_.get(e);void 0===n&&(n=x(e,"string"!=typeof t&&!("strTag"in t)),_.set(e,n));return n}
|
|
39
39
|
/**
|
|
40
40
|
* @license
|
|
41
41
|
* Copyright 2021 Google LLC
|
|
42
42
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
43
|
-
*/(e),o=t[i];if(o){if("string"==typeof o)return o;if("strTag"in o)return
|
|
43
|
+
*/(e),o=t[i];if(o){if("string"==typeof o)return o;if("strTag"in o)return u(o.strings,e.values,o.values);{let t=w.get(o);return void 0===t&&(t=o.values,w.set(o,t)),{...o,values:t.map(t=>e.values[t])}}}}return p(e)}function k(t){window.dispatchEvent(new CustomEvent(h,{detail:t}))}let S,P,T,E,M,z="",C=new b;C.resolve();let I=0;const O=t=>(function(t){if(g)throw new Error("lit-localize can only be configured once");f=t,g=!0}((t,e)=>$(M,t,e)),z=P=t.sourceLocale,T=new Set(t.targetLocales),T.add(t.sourceLocale),E=t.loadLocale,{getLocale:R,setLocale:j}),R=()=>z,j=t=>{if(t===(S??z))return C.promise;if(!T||!E)throw new Error("Internal error");if(!T.has(t))throw new Error("Invalid locale code");I++;const e=I;S=t,C.settled&&(C=new b),k({status:"loading",loadingLocale:t});return(t===P?Promise.resolve({templates:void 0}):E(t)).then(n=>{I===e&&(z=t,S=void 0,M=n.templates,k({status:"ready",readyLocale:t}),C.resolve())},n=>{I===e&&(k({status:"error",errorLocale:t,errorMessage:n.toString()}),C.reject(n))}),C.promise};var A=t`
|
|
44
44
|
:host {
|
|
45
45
|
display: block;
|
|
46
46
|
width: 100%;
|
|
47
47
|
height: 100%;
|
|
48
|
-
min-width:
|
|
48
|
+
min-width: 320px;
|
|
49
49
|
box-sizing: border-box;
|
|
50
50
|
overflow: visible;
|
|
51
51
|
|
|
@@ -60,10 +60,10 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
60
60
|
display: flex;
|
|
61
61
|
width: 100%;
|
|
62
62
|
height: 100%;
|
|
63
|
-
background-color:
|
|
64
|
-
border-radius:
|
|
63
|
+
background-color: #ffffff;
|
|
64
|
+
border-radius: 8px;
|
|
65
65
|
position: relative;
|
|
66
|
-
border:
|
|
66
|
+
border: 1px solid #e0e0e0;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
.chatbot-container {
|
|
@@ -71,7 +71,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
71
71
|
flex-direction: column;
|
|
72
72
|
flex: 1;
|
|
73
73
|
min-height: 0;
|
|
74
|
-
min-width:
|
|
74
|
+
min-width: 300px;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
.chatbot-container--with-sidebar,
|
|
@@ -93,7 +93,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
93
93
|
justify-content: space-between;
|
|
94
94
|
gap: 0.5rem;
|
|
95
95
|
padding: 0.5rem;
|
|
96
|
-
border-bottom: 1px solid
|
|
96
|
+
border-bottom: 1px solid #e0e0e0;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
.chatbot-content {
|
|
@@ -105,7 +105,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
:host([boxed]) .chat-container {
|
|
108
|
-
background-color:
|
|
108
|
+
background-color: #ffffff;
|
|
109
109
|
border: none;
|
|
110
110
|
border-radius: 0;
|
|
111
111
|
}
|
|
@@ -116,9 +116,9 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
116
116
|
|
|
117
117
|
:host([boxed]) .chatbot-main {
|
|
118
118
|
width: 100%;
|
|
119
|
-
max-width:
|
|
119
|
+
max-width: 768px;
|
|
120
120
|
margin: 0 auto;
|
|
121
|
-
background-color:
|
|
121
|
+
background-color: #ffffff;
|
|
122
122
|
border: none;
|
|
123
123
|
border-radius: 0;
|
|
124
124
|
box-shadow: none;
|
|
@@ -127,23 +127,23 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
127
127
|
|
|
128
128
|
/* Boxed layout with threads: background comes from theme variable with white fallback */
|
|
129
129
|
:host([boxed]) .chat-container--boxed.chat-container--with-threads {
|
|
130
|
-
background-color:
|
|
130
|
+
background-color: #ffffff;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
.chat-container--boxed.chat-container--with-threads .chatbot-main {
|
|
134
|
-
background-color:
|
|
134
|
+
background-color: #ffffff;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
.chat-container--boxed.chat-container--with-threads .chat-box {
|
|
138
|
-
background-color:
|
|
138
|
+
background-color: #ffffff;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
.chat-container--boxed.chat-container--with-threads .messages {
|
|
142
|
-
background-color:
|
|
142
|
+
background-color: #ffffff;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
.chat-container--boxed.chat-container--with-threads .input-container {
|
|
146
|
-
background-color:
|
|
146
|
+
background-color: #ffffff;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
:host([boxed]) .chatbot-header {
|
|
@@ -175,13 +175,13 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
175
175
|
left: 50%;
|
|
176
176
|
transform: translate(-50%, calc(-50% - 80px));
|
|
177
177
|
width: 100%;
|
|
178
|
-
max-width:
|
|
178
|
+
max-width: 768px;
|
|
179
179
|
height: auto;
|
|
180
180
|
padding: 0;
|
|
181
181
|
display: flex;
|
|
182
182
|
flex-direction: column;
|
|
183
183
|
align-items: center;
|
|
184
|
-
gap:
|
|
184
|
+
gap: 1.5rem;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
:host([boxed]) .empty-state__content {
|
|
@@ -195,7 +195,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
195
195
|
left: 50%;
|
|
196
196
|
transform: translate(-50%, calc(-50% + 40px));
|
|
197
197
|
width: 100%;
|
|
198
|
-
max-width:
|
|
198
|
+
max-width: 768px;
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
:host([boxed]) .suggestion-container {
|
|
@@ -205,38 +205,38 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
205
205
|
:host([boxed]) .messages {
|
|
206
206
|
box-shadow: none;
|
|
207
207
|
margin-bottom: 0;
|
|
208
|
-
background-color:
|
|
208
|
+
background-color: #ffffff;
|
|
209
209
|
align-items: stretch;
|
|
210
210
|
width: 98%;
|
|
211
|
-
padding:
|
|
211
|
+
padding: 8px 1.5rem;
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
:host([boxed]) .input-container {
|
|
215
215
|
box-shadow: none;
|
|
216
216
|
margin: 0;
|
|
217
|
-
background-color:
|
|
217
|
+
background-color: #ffffff;
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
.chat-container--with-threads {
|
|
221
|
-
grid-template-columns:
|
|
221
|
+
grid-template-columns: 240px 1fr;
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
.chat-container--disabled {
|
|
225
|
-
opacity:
|
|
225
|
+
opacity: 0.5;
|
|
226
226
|
pointer-events: none;
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
.chat-container--drag-over {
|
|
230
|
-
background-color:
|
|
231
|
-
border:
|
|
232
|
-
border-radius:
|
|
230
|
+
background-color: #f4f4f4;
|
|
231
|
+
border: 0.25rem dashed #7c3aed;
|
|
232
|
+
border-radius: 8px;
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
.thread-sidebar {
|
|
236
|
-
width:
|
|
236
|
+
width: 260px;
|
|
237
237
|
flex-shrink: 0;
|
|
238
|
-
background-color:
|
|
239
|
-
border-right:
|
|
238
|
+
background-color: #f4f4f4;
|
|
239
|
+
border-right: 1px solid #e0e0e0;
|
|
240
240
|
display: flex;
|
|
241
241
|
flex-direction: column;
|
|
242
242
|
overflow: hidden;
|
|
@@ -248,25 +248,25 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
248
248
|
display: flex;
|
|
249
249
|
align-items: center;
|
|
250
250
|
justify-content: space-between;
|
|
251
|
-
padding:
|
|
252
|
-
border-bottom:
|
|
251
|
+
padding: 0.75rem;
|
|
252
|
+
border-bottom: 1px solid #e0e0e0;
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
.thread-sidebar__header h3 {
|
|
256
256
|
margin: 0;
|
|
257
|
-
font-size:
|
|
258
|
-
font-weight:
|
|
259
|
-
color:
|
|
257
|
+
font-size: 1rem;
|
|
258
|
+
font-weight: 600;
|
|
259
|
+
color: #161616;
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
.thread-list {
|
|
263
263
|
flex: 1;
|
|
264
264
|
overflow-y: auto;
|
|
265
|
-
padding:
|
|
265
|
+
padding: 0.75rem;
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
.thread-section {
|
|
269
|
-
margin-bottom:
|
|
269
|
+
margin-bottom: 8px;
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
.thread-section__label {
|
|
@@ -282,31 +282,31 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
.thread-section__label svg {
|
|
285
|
-
color:
|
|
285
|
+
color: #f59e0b;
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
.thread-item {
|
|
289
|
-
padding:
|
|
290
|
-
border-radius:
|
|
289
|
+
padding: 0.75rem;
|
|
290
|
+
border-radius: 8px;
|
|
291
291
|
cursor: pointer;
|
|
292
|
-
margin-bottom:
|
|
293
|
-
transition: background-color
|
|
294
|
-
border:
|
|
292
|
+
margin-bottom: 0.5rem;
|
|
293
|
+
transition: background-color 0.15s;
|
|
294
|
+
border: 1px solid transparent;
|
|
295
295
|
line-height: 1.6;
|
|
296
296
|
}
|
|
297
297
|
|
|
298
298
|
.thread-item:hover {
|
|
299
|
-
background-color:
|
|
299
|
+
background-color: #f4f4f4;
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
.thread-item--active {
|
|
303
|
-
background-color:
|
|
304
|
-
color:
|
|
305
|
-
border-color:
|
|
303
|
+
background-color: #f4f0fd;
|
|
304
|
+
color: #7c3aed;
|
|
305
|
+
border-color: #7c3aed;
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
.thread-item--active:hover {
|
|
309
|
-
background-color:
|
|
309
|
+
background-color: #f4f0fd;
|
|
310
310
|
opacity: 0.95;
|
|
311
311
|
}
|
|
312
312
|
|
|
@@ -314,12 +314,12 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
314
314
|
display: flex;
|
|
315
315
|
align-items: center;
|
|
316
316
|
gap: 4px;
|
|
317
|
-
margin-bottom:
|
|
317
|
+
margin-bottom: 0.5rem;
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
.thread-item__title {
|
|
321
|
-
font-weight:
|
|
322
|
-
font-size:
|
|
321
|
+
font-weight: 500;
|
|
322
|
+
font-size: 14px;
|
|
323
323
|
white-space: nowrap;
|
|
324
324
|
overflow: hidden;
|
|
325
325
|
text-overflow: ellipsis;
|
|
@@ -347,12 +347,12 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
347
347
|
margin: 0;
|
|
348
348
|
background: none;
|
|
349
349
|
border: none;
|
|
350
|
-
border-radius:
|
|
350
|
+
border-radius: 4px;
|
|
351
351
|
color: rgba(128, 128, 128, 0.6);
|
|
352
352
|
cursor: pointer;
|
|
353
353
|
flex-shrink: 0;
|
|
354
354
|
line-height: 0;
|
|
355
|
-
transition: color
|
|
355
|
+
transition: color 0.15s, background-color 0.15s;
|
|
356
356
|
}
|
|
357
357
|
|
|
358
358
|
.thread-item__action-btn svg {
|
|
@@ -360,7 +360,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
360
360
|
}
|
|
361
361
|
|
|
362
362
|
.thread-item__action-btn:hover {
|
|
363
|
-
color:
|
|
363
|
+
color: #3b82f6;
|
|
364
364
|
background-color: rgba(59, 130, 246, 0.1);
|
|
365
365
|
}
|
|
366
366
|
|
|
@@ -369,7 +369,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
369
369
|
}
|
|
370
370
|
|
|
371
371
|
.thread-item__delete:hover {
|
|
372
|
-
color:
|
|
372
|
+
color: #ef4444;
|
|
373
373
|
background-color: rgba(239, 68, 68, 0.1);
|
|
374
374
|
}
|
|
375
375
|
|
|
@@ -378,40 +378,40 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
378
378
|
}
|
|
379
379
|
|
|
380
380
|
.thread-item--active .thread-item__action-btn:hover {
|
|
381
|
-
color:
|
|
381
|
+
color: #3b82f6;
|
|
382
382
|
background-color: rgba(59, 130, 246, 0.15);
|
|
383
383
|
}
|
|
384
384
|
|
|
385
385
|
.thread-item--active .thread-item__delete:hover {
|
|
386
|
-
color:
|
|
386
|
+
color: #ef4444;
|
|
387
387
|
background-color: rgba(239, 68, 68, 0.15);
|
|
388
388
|
}
|
|
389
389
|
|
|
390
390
|
.thread-item__bookmark--active {
|
|
391
|
-
color:
|
|
391
|
+
color: #f59e0b !important;
|
|
392
392
|
display: flex !important;
|
|
393
393
|
}
|
|
394
394
|
|
|
395
395
|
.thread-item__bookmark--active:hover {
|
|
396
|
-
color:
|
|
396
|
+
color: #d97706 !important;
|
|
397
397
|
background-color: rgba(245, 158, 11, 0.1);
|
|
398
398
|
}
|
|
399
399
|
|
|
400
400
|
.thread-item--active .thread-item__bookmark--active {
|
|
401
|
-
color:
|
|
401
|
+
color: #f59e0b !important;
|
|
402
402
|
}
|
|
403
403
|
|
|
404
404
|
.thread-item__rename-input {
|
|
405
405
|
flex: 1;
|
|
406
406
|
min-width: 0;
|
|
407
407
|
padding: 2px 6px;
|
|
408
|
-
font-size:
|
|
409
|
-
font-weight:
|
|
408
|
+
font-size: 14px;
|
|
409
|
+
font-weight: 500;
|
|
410
410
|
font-family: inherit;
|
|
411
411
|
color: inherit;
|
|
412
412
|
background: rgba(0, 0, 0, 0.2);
|
|
413
|
-
border: 1px solid
|
|
414
|
-
border-radius:
|
|
413
|
+
border: 1px solid #3b82f6;
|
|
414
|
+
border-radius: 4px;
|
|
415
415
|
outline: none;
|
|
416
416
|
line-height: 1.4;
|
|
417
417
|
}
|
|
@@ -421,12 +421,12 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
421
421
|
}
|
|
422
422
|
|
|
423
423
|
.thread-item__preview {
|
|
424
|
-
font-size:
|
|
424
|
+
font-size: 13px;
|
|
425
425
|
color: rgba(128, 128, 128, 0.7);
|
|
426
426
|
white-space: nowrap;
|
|
427
427
|
overflow: hidden;
|
|
428
428
|
text-overflow: ellipsis;
|
|
429
|
-
margin-bottom:
|
|
429
|
+
margin-bottom: 0.5rem;
|
|
430
430
|
line-height: 1.5;
|
|
431
431
|
}
|
|
432
432
|
|
|
@@ -435,7 +435,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
435
435
|
}
|
|
436
436
|
|
|
437
437
|
.thread-item__timestamp {
|
|
438
|
-
font-size:
|
|
438
|
+
font-size: 0.75rem;
|
|
439
439
|
color: rgba(128, 128, 128, 0.6);
|
|
440
440
|
line-height: 1.4;
|
|
441
441
|
}
|
|
@@ -459,8 +459,8 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
459
459
|
display: flex;
|
|
460
460
|
flex-direction: column;
|
|
461
461
|
gap: 0;
|
|
462
|
-
background-color:
|
|
463
|
-
padding:
|
|
462
|
+
background-color: #ffffff;
|
|
463
|
+
padding: 8px 12px;
|
|
464
464
|
justify-content: flex-start; /* Always align messages to top */
|
|
465
465
|
}
|
|
466
466
|
|
|
@@ -471,24 +471,24 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
471
471
|
justify-content: center;
|
|
472
472
|
flex: 1; /* Take full height when empty */
|
|
473
473
|
text-align: center;
|
|
474
|
-
padding:
|
|
474
|
+
padding: 3rem 1.5rem;
|
|
475
475
|
}
|
|
476
476
|
|
|
477
477
|
.empty-state__content {
|
|
478
|
-
color:
|
|
479
|
-
font-size:
|
|
480
|
-
font-weight:
|
|
481
|
-
margin-bottom:
|
|
478
|
+
color: #161616;
|
|
479
|
+
font-size: 2rem;
|
|
480
|
+
font-weight: 600;
|
|
481
|
+
margin-bottom: 3rem;
|
|
482
482
|
letter-spacing: -0.02em;
|
|
483
483
|
}
|
|
484
484
|
|
|
485
485
|
.message {
|
|
486
486
|
display: flex;
|
|
487
487
|
flex-direction: column;
|
|
488
|
-
max-width:
|
|
488
|
+
max-width: 75%;
|
|
489
489
|
word-wrap: break-word;
|
|
490
490
|
word-break: break-word;
|
|
491
|
-
margin-bottom:
|
|
491
|
+
margin-bottom: 0.5rem;
|
|
492
492
|
position: relative;
|
|
493
493
|
min-width: 0;
|
|
494
494
|
flex-shrink: 0;
|
|
@@ -505,27 +505,27 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
505
505
|
}
|
|
506
506
|
|
|
507
507
|
.message__content {
|
|
508
|
-
padding:
|
|
509
|
-
border-radius:
|
|
510
|
-
font-size:
|
|
511
|
-
line-height:
|
|
508
|
+
padding: 8px 12px;
|
|
509
|
+
border-radius: 0;
|
|
510
|
+
font-size: 0.875rem;
|
|
511
|
+
line-height: 1.5;
|
|
512
512
|
position: relative;
|
|
513
|
-
font-weight:
|
|
514
|
-
box-shadow:
|
|
513
|
+
font-weight: 400;
|
|
514
|
+
box-shadow: none;
|
|
515
515
|
box-sizing: border-box;
|
|
516
516
|
overflow-wrap: break-word;
|
|
517
517
|
white-space: normal;
|
|
518
|
-
background-color:
|
|
519
|
-
color:
|
|
520
|
-
border:
|
|
518
|
+
background-color: transparent;
|
|
519
|
+
color: inherit;
|
|
520
|
+
border: 0 solid transparent;
|
|
521
521
|
}
|
|
522
522
|
|
|
523
523
|
/* Message attachments (file tags) */
|
|
524
524
|
.message__attachments {
|
|
525
525
|
display: flex;
|
|
526
526
|
flex-wrap: wrap;
|
|
527
|
-
gap:
|
|
528
|
-
margin-top:
|
|
527
|
+
gap: 0.25rem;
|
|
528
|
+
margin-top: 0.25rem;
|
|
529
529
|
position: relative;
|
|
530
530
|
z-index: 1;
|
|
531
531
|
}
|
|
@@ -541,7 +541,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
541
541
|
}
|
|
542
542
|
|
|
543
543
|
.message__attachment-tag {
|
|
544
|
-
--nuraly-tag-font-size:
|
|
544
|
+
--nuraly-tag-font-size: 0.75rem;
|
|
545
545
|
--nuraly-tag-padding-x: 4px;
|
|
546
546
|
--nuraly-tag-padding-y: 0px;
|
|
547
547
|
cursor: help;
|
|
@@ -552,8 +552,8 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
552
552
|
display: flex;
|
|
553
553
|
flex-direction: column;
|
|
554
554
|
align-items: center;
|
|
555
|
-
gap:
|
|
556
|
-
padding:
|
|
555
|
+
gap: 0.5rem;
|
|
556
|
+
padding: 0.75rem;
|
|
557
557
|
min-width: 200px;
|
|
558
558
|
max-width: 300px;
|
|
559
559
|
}
|
|
@@ -561,12 +561,12 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
561
561
|
.message-file-preview-image {
|
|
562
562
|
max-width: 100%;
|
|
563
563
|
max-height: 200px;
|
|
564
|
-
border-radius:
|
|
564
|
+
border-radius: 8px;
|
|
565
565
|
object-fit: contain;
|
|
566
566
|
}
|
|
567
567
|
|
|
568
568
|
.message-file-preview-icon {
|
|
569
|
-
color:
|
|
569
|
+
color: #6c757d;
|
|
570
570
|
opacity: 0.6;
|
|
571
571
|
}
|
|
572
572
|
|
|
@@ -576,42 +576,42 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
576
576
|
}
|
|
577
577
|
|
|
578
578
|
.message-file-preview-name {
|
|
579
|
-
font-size:
|
|
579
|
+
font-size: 0.875rem;
|
|
580
580
|
font-weight: 500;
|
|
581
|
-
color:
|
|
581
|
+
color: #1f2937;
|
|
582
582
|
white-space: nowrap;
|
|
583
583
|
overflow: hidden;
|
|
584
584
|
text-overflow: ellipsis;
|
|
585
|
-
margin-bottom:
|
|
585
|
+
margin-bottom: 0.25rem;
|
|
586
586
|
}
|
|
587
587
|
|
|
588
588
|
.message-file-preview-details {
|
|
589
|
-
font-size:
|
|
590
|
-
color:
|
|
589
|
+
font-size: 0.75rem;
|
|
590
|
+
color: #6c757d;
|
|
591
591
|
}
|
|
592
592
|
|
|
593
593
|
.message.user .message__content {
|
|
594
|
-
background-color:
|
|
595
|
-
color:
|
|
596
|
-
border-radius: var(--
|
|
597
|
-
border:
|
|
598
|
-
box-shadow:
|
|
594
|
+
background-color: #7c3aed;
|
|
595
|
+
color: #ffffff;
|
|
596
|
+
border-radius: var(--chatbot-radius, 8px);
|
|
597
|
+
border: 0 solid transparent;
|
|
598
|
+
box-shadow: none;
|
|
599
599
|
}
|
|
600
600
|
|
|
601
601
|
.message.bot .message__content {
|
|
602
|
-
background-color:
|
|
603
|
-
color:
|
|
604
|
-
border-radius:
|
|
605
|
-
border:
|
|
606
|
-
box-shadow:
|
|
602
|
+
background-color: transparent;
|
|
603
|
+
color: inherit;
|
|
604
|
+
border-radius: 0;
|
|
605
|
+
border: 0 solid transparent;
|
|
606
|
+
box-shadow: none;
|
|
607
607
|
}
|
|
608
608
|
|
|
609
609
|
.message.error .message__content {
|
|
610
|
-
background-color:
|
|
611
|
-
color:
|
|
612
|
-
border-radius:
|
|
613
|
-
border:
|
|
614
|
-
box-shadow:
|
|
610
|
+
background-color: transparent;
|
|
611
|
+
color: inherit;
|
|
612
|
+
border-radius: 0;
|
|
613
|
+
border: 0 solid transparent;
|
|
614
|
+
box-shadow: none;
|
|
615
615
|
}
|
|
616
616
|
|
|
617
617
|
/* Styled error message container */
|
|
@@ -619,19 +619,19 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
619
619
|
display: flex;
|
|
620
620
|
flex-direction: column;
|
|
621
621
|
gap: 0.5rem;
|
|
622
|
-
border-radius:
|
|
622
|
+
border-radius: 0.75rem;
|
|
623
623
|
}
|
|
624
624
|
|
|
625
625
|
.message__error-title {
|
|
626
626
|
font-weight: 600;
|
|
627
627
|
font-size: 0.875rem;
|
|
628
|
-
color:
|
|
628
|
+
color: #c00;
|
|
629
629
|
margin: 0;
|
|
630
630
|
}
|
|
631
631
|
|
|
632
632
|
.message__error-description {
|
|
633
633
|
font-size: 0.875rem;
|
|
634
|
-
color:
|
|
634
|
+
color: #666;
|
|
635
635
|
margin: 0;
|
|
636
636
|
line-height: 1.5;
|
|
637
637
|
}
|
|
@@ -641,7 +641,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
641
641
|
display: flex;
|
|
642
642
|
align-items: center;
|
|
643
643
|
gap: 0.5rem;
|
|
644
|
-
margin-top:
|
|
644
|
+
margin-top: 0.25rem;
|
|
645
645
|
}
|
|
646
646
|
|
|
647
647
|
.message.user .message__footer {
|
|
@@ -653,12 +653,12 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
653
653
|
}
|
|
654
654
|
|
|
655
655
|
.message__timestamp {
|
|
656
|
-
font-size:
|
|
657
|
-
color:
|
|
658
|
-
font-weight:
|
|
656
|
+
font-size: 0.75rem;
|
|
657
|
+
color: #a8a8a8;
|
|
658
|
+
font-weight: 400;
|
|
659
659
|
opacity: 0;
|
|
660
660
|
visibility: hidden;
|
|
661
|
-
transition: opacity
|
|
661
|
+
transition: opacity 0.15s ease, visibility 0.15s ease;
|
|
662
662
|
}
|
|
663
663
|
|
|
664
664
|
.message__copy {
|
|
@@ -670,8 +670,8 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
670
670
|
pointer-events: auto !important;
|
|
671
671
|
opacity: 0;
|
|
672
672
|
visibility: hidden;
|
|
673
|
-
transition: opacity
|
|
674
|
-
color:
|
|
673
|
+
transition: opacity 0.15s ease, visibility 0.15s ease;
|
|
674
|
+
color: #a8a8a8;
|
|
675
675
|
}
|
|
676
676
|
|
|
677
677
|
.message:hover .message__copy {
|
|
@@ -680,7 +680,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
680
680
|
}
|
|
681
681
|
|
|
682
682
|
.message:hover .message__timestamp {
|
|
683
|
-
opacity:
|
|
683
|
+
opacity: 1;
|
|
684
684
|
visibility: visible;
|
|
685
685
|
}
|
|
686
686
|
|
|
@@ -689,12 +689,12 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
689
689
|
}
|
|
690
690
|
|
|
691
691
|
.message__copy:focus {
|
|
692
|
-
outline: 2px solid
|
|
692
|
+
outline: 2px solid #0066cc;
|
|
693
693
|
outline-offset: 2px;
|
|
694
694
|
}
|
|
695
695
|
|
|
696
696
|
.message__retry {
|
|
697
|
-
margin-top:
|
|
697
|
+
margin-top: 0.5rem;
|
|
698
698
|
align-self: flex-start;
|
|
699
699
|
}
|
|
700
700
|
|
|
@@ -702,19 +702,19 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
702
702
|
display: flex;
|
|
703
703
|
align-items: center;
|
|
704
704
|
gap: var(--chatbot-spacing-sm);
|
|
705
|
-
background-color:
|
|
705
|
+
background-color: transparent;
|
|
706
706
|
/* Set indicator color (affects spinner currentColor) */
|
|
707
|
-
color: var(--chatbot-loading-indicator-color, var(--
|
|
707
|
+
color: var(--chatbot-loading-indicator-color, var(--chatbot-text-secondary));
|
|
708
708
|
}
|
|
709
709
|
|
|
710
710
|
.dots {
|
|
711
711
|
display: flex;
|
|
712
|
-
gap:
|
|
712
|
+
gap: 0.125rem;
|
|
713
713
|
}
|
|
714
714
|
|
|
715
715
|
.dots span {
|
|
716
|
-
width:
|
|
717
|
-
height:
|
|
716
|
+
width: 0.5rem;
|
|
717
|
+
height: 0.5rem;
|
|
718
718
|
background-color: currentColor;
|
|
719
719
|
border-radius: 50%;
|
|
720
720
|
animation: typing-dots 1.4s infinite;
|
|
@@ -786,13 +786,13 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
786
786
|
.suggestion-container {
|
|
787
787
|
display: flex;
|
|
788
788
|
flex-wrap: wrap;
|
|
789
|
-
gap:
|
|
790
|
-
margin-top:
|
|
789
|
+
gap: 0.5rem;
|
|
790
|
+
margin-top: 0.5rem;
|
|
791
791
|
max-width: 100%;
|
|
792
792
|
margin-left: auto;
|
|
793
793
|
margin-right: auto;
|
|
794
794
|
justify-content: center;
|
|
795
|
-
padding: 0
|
|
795
|
+
padding: 0 1rem;
|
|
796
796
|
overflow: hidden;
|
|
797
797
|
box-sizing: border-box;
|
|
798
798
|
}
|
|
@@ -801,16 +801,16 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
801
801
|
display: inline-flex;
|
|
802
802
|
align-items: center;
|
|
803
803
|
justify-content: center;
|
|
804
|
-
padding:
|
|
805
|
-
background-color:
|
|
806
|
-
color:
|
|
807
|
-
border:
|
|
808
|
-
border-radius:
|
|
809
|
-
font-size:
|
|
810
|
-
font-weight:
|
|
811
|
-
line-height:
|
|
804
|
+
padding: 6px 12px;
|
|
805
|
+
background-color: #ffffff;
|
|
806
|
+
color: #161616;
|
|
807
|
+
border: 1px solid #e0e0e0;
|
|
808
|
+
border-radius: 16px;
|
|
809
|
+
font-size: 13px;
|
|
810
|
+
font-weight: 500;
|
|
811
|
+
line-height: 1.3;
|
|
812
812
|
cursor: pointer;
|
|
813
|
-
transition: all
|
|
813
|
+
transition: all 0.2s ease;
|
|
814
814
|
user-select: none;
|
|
815
815
|
white-space: normal;
|
|
816
816
|
word-break: break-word;
|
|
@@ -821,10 +821,10 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
821
821
|
}
|
|
822
822
|
|
|
823
823
|
.suggestion:hover {
|
|
824
|
-
background-color:
|
|
825
|
-
border-color:
|
|
824
|
+
background-color: #f4f4f4;
|
|
825
|
+
border-color: #c6c6c6;
|
|
826
826
|
transform: translateY(-1px);
|
|
827
|
-
box-shadow:
|
|
827
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
|
|
828
828
|
}
|
|
829
829
|
|
|
830
830
|
.suggestion:focus {
|
|
@@ -833,7 +833,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
833
833
|
|
|
834
834
|
.suggestion:active {
|
|
835
835
|
transform: translateY(0);
|
|
836
|
-
background-color:
|
|
836
|
+
background-color: #f4f0fd;
|
|
837
837
|
}
|
|
838
838
|
|
|
839
839
|
.suggestion--disabled {
|
|
@@ -858,7 +858,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
858
858
|
|
|
859
859
|
.input-only-suggestions {
|
|
860
860
|
position: absolute;
|
|
861
|
-
bottom: calc(100% +
|
|
861
|
+
bottom: calc(100% + 0.5rem);
|
|
862
862
|
left: 0;
|
|
863
863
|
right: 0;
|
|
864
864
|
display: flex;
|
|
@@ -872,7 +872,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
872
872
|
flex-direction: row;
|
|
873
873
|
flex-wrap: wrap;
|
|
874
874
|
justify-content: center;
|
|
875
|
-
gap:
|
|
875
|
+
gap: 0.25rem;
|
|
876
876
|
margin: 0;
|
|
877
877
|
padding: 0;
|
|
878
878
|
pointer-events: auto;
|
|
@@ -886,7 +886,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
886
886
|
right: 0;
|
|
887
887
|
bottom: 0;
|
|
888
888
|
background-color: rgba(255, 255, 255, 0.95);
|
|
889
|
-
border:
|
|
889
|
+
border: 0.25rem dashed var(--chatbot-user-message-bg);
|
|
890
890
|
border-radius: var(--chatbot-radius);
|
|
891
891
|
z-index: 10;
|
|
892
892
|
}
|
|
@@ -914,7 +914,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
914
914
|
}
|
|
915
915
|
|
|
916
916
|
.file-upload-area__help {
|
|
917
|
-
font-size:
|
|
917
|
+
font-size: 0.75rem;
|
|
918
918
|
color: var(--chatbot-text-secondary);
|
|
919
919
|
margin: var(--chatbot-spacing-xs) 0;
|
|
920
920
|
}
|
|
@@ -933,14 +933,14 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
933
933
|
gap: var(--chatbot-spacing-sm);
|
|
934
934
|
padding: var(--chatbot-spacing-sm);
|
|
935
935
|
background-color: var(--chatbot-background);
|
|
936
|
-
border:
|
|
936
|
+
border: 1px solid var(--chatbot-border);
|
|
937
937
|
border-radius: var(--chatbot-radius);
|
|
938
|
-
max-width:
|
|
938
|
+
max-width: 200px;
|
|
939
939
|
}
|
|
940
940
|
|
|
941
941
|
.uploaded-file__preview {
|
|
942
|
-
width:
|
|
943
|
-
height:
|
|
942
|
+
width: 32px;
|
|
943
|
+
height: 32px;
|
|
944
944
|
object-fit: cover;
|
|
945
945
|
border-radius: var(--chatbot-spacing-xs);
|
|
946
946
|
}
|
|
@@ -955,7 +955,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
955
955
|
}
|
|
956
956
|
|
|
957
957
|
.uploaded-file__name {
|
|
958
|
-
font-size:
|
|
958
|
+
font-size: 0.75rem;
|
|
959
959
|
font-weight: 500;
|
|
960
960
|
color: var(--chatbot-text-primary);
|
|
961
961
|
white-space: nowrap;
|
|
@@ -964,14 +964,14 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
964
964
|
}
|
|
965
965
|
|
|
966
966
|
.uploaded-file__size {
|
|
967
|
-
font-size:
|
|
967
|
+
font-size: 11px;
|
|
968
968
|
color: var(--chatbot-text-secondary);
|
|
969
969
|
}
|
|
970
970
|
|
|
971
971
|
.uploaded-file__progress {
|
|
972
|
-
height:
|
|
972
|
+
height: 0.125rem;
|
|
973
973
|
background-color: var(--chatbot-border);
|
|
974
|
-
border-radius:
|
|
974
|
+
border-radius: 0.125rem;
|
|
975
975
|
overflow: hidden;
|
|
976
976
|
margin-top: var(--chatbot-spacing-xs);
|
|
977
977
|
}
|
|
@@ -983,7 +983,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
983
983
|
}
|
|
984
984
|
|
|
985
985
|
.uploaded-file__error {
|
|
986
|
-
font-size:
|
|
986
|
+
font-size: 11px;
|
|
987
987
|
color: var(--chatbot-error-text);
|
|
988
988
|
margin-top: var(--chatbot-spacing-xs);
|
|
989
989
|
}
|
|
@@ -995,21 +995,21 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
995
995
|
|
|
996
996
|
|
|
997
997
|
.input-container {
|
|
998
|
-
background-color:
|
|
999
|
-
border:
|
|
1000
|
-
border-radius:
|
|
1001
|
-
transition:
|
|
1002
|
-
box-shadow:
|
|
998
|
+
background-color: #ffffff;
|
|
999
|
+
border: 1px solid #e0e0e0;
|
|
1000
|
+
border-radius: 8px;
|
|
1001
|
+
transition: all 0.2s ease;
|
|
1002
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
1003
1003
|
overflow: visible;
|
|
1004
1004
|
position: relative;
|
|
1005
|
-
min-width:
|
|
1005
|
+
min-width: 280px;
|
|
1006
1006
|
}
|
|
1007
1007
|
|
|
1008
1008
|
.context-tags-row {
|
|
1009
1009
|
display: flex;
|
|
1010
1010
|
flex-wrap: wrap;
|
|
1011
|
-
gap:
|
|
1012
|
-
padding:
|
|
1011
|
+
gap: 0.5rem;
|
|
1012
|
+
padding: 0.75rem 1rem 0 1rem;
|
|
1013
1013
|
position: relative;
|
|
1014
1014
|
z-index: 2;
|
|
1015
1015
|
}
|
|
@@ -1021,8 +1021,8 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1021
1021
|
|
|
1022
1022
|
|
|
1023
1023
|
.context-tag {
|
|
1024
|
-
--nuraly-tag-font-size:
|
|
1025
|
-
--nuraly-tag-padding-x:
|
|
1024
|
+
--nuraly-tag-font-size: 0.75rem;
|
|
1025
|
+
--nuraly-tag-padding-x: 0.5rem;
|
|
1026
1026
|
--nuraly-tag-padding-y: 0;
|
|
1027
1027
|
cursor: help;
|
|
1028
1028
|
}
|
|
@@ -1032,8 +1032,8 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1032
1032
|
display: flex;
|
|
1033
1033
|
flex-direction: column;
|
|
1034
1034
|
align-items: center;
|
|
1035
|
-
gap:
|
|
1036
|
-
padding:
|
|
1035
|
+
gap: 0.5rem;
|
|
1036
|
+
padding: 0.75rem;
|
|
1037
1037
|
min-width: 200px;
|
|
1038
1038
|
max-width: 300px;
|
|
1039
1039
|
}
|
|
@@ -1041,12 +1041,12 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1041
1041
|
.file-preview-image {
|
|
1042
1042
|
max-width: 100%;
|
|
1043
1043
|
max-height: 200px;
|
|
1044
|
-
border-radius:
|
|
1044
|
+
border-radius: 8px;
|
|
1045
1045
|
object-fit: contain;
|
|
1046
1046
|
}
|
|
1047
1047
|
|
|
1048
1048
|
.file-preview-icon {
|
|
1049
|
-
color:
|
|
1049
|
+
color: #6c757d;
|
|
1050
1050
|
opacity: 0.6;
|
|
1051
1051
|
}
|
|
1052
1052
|
|
|
@@ -1056,69 +1056,69 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1056
1056
|
}
|
|
1057
1057
|
|
|
1058
1058
|
.file-preview-name {
|
|
1059
|
-
font-size:
|
|
1059
|
+
font-size: 0.875rem;
|
|
1060
1060
|
font-weight: 500;
|
|
1061
|
-
color:
|
|
1061
|
+
color: #1f2937;
|
|
1062
1062
|
white-space: nowrap;
|
|
1063
1063
|
overflow: hidden;
|
|
1064
1064
|
text-overflow: ellipsis;
|
|
1065
|
-
margin-bottom:
|
|
1065
|
+
margin-bottom: 0.25rem;
|
|
1066
1066
|
}
|
|
1067
1067
|
|
|
1068
1068
|
.file-preview-details {
|
|
1069
|
-
font-size:
|
|
1070
|
-
color:
|
|
1069
|
+
font-size: 0.75rem;
|
|
1070
|
+
color: #6c757d;
|
|
1071
1071
|
}
|
|
1072
1072
|
|
|
1073
1073
|
.input-container:focus-within {
|
|
1074
|
-
border-color:
|
|
1074
|
+
border-color: #7c3aed;
|
|
1075
1075
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
1076
1076
|
}
|
|
1077
1077
|
|
|
1078
1078
|
.input-row {
|
|
1079
1079
|
display: flex;
|
|
1080
1080
|
align-items: flex-start;
|
|
1081
|
-
padding:
|
|
1082
|
-
min-height:
|
|
1081
|
+
padding: 1rem 1rem 0.5rem 1rem;
|
|
1082
|
+
min-height: 1.5rem;
|
|
1083
1083
|
}
|
|
1084
1084
|
|
|
1085
1085
|
.chat-container--boxed .input-box {
|
|
1086
1086
|
background-color: transparent;
|
|
1087
|
-
padding:
|
|
1087
|
+
padding: 1rem 0;
|
|
1088
1088
|
width: 100%;
|
|
1089
1089
|
box-sizing: border-box;
|
|
1090
1090
|
}
|
|
1091
1091
|
|
|
1092
1092
|
.chat-container--boxed .input-container {
|
|
1093
1093
|
width: 100%;
|
|
1094
|
-
max-width:
|
|
1094
|
+
max-width: 768px;
|
|
1095
1095
|
margin-left: auto;
|
|
1096
1096
|
margin-right: auto;
|
|
1097
1097
|
box-sizing: border-box;
|
|
1098
|
-
padding-left:
|
|
1099
|
-
padding-right:
|
|
1098
|
+
padding-left: 1rem;
|
|
1099
|
+
padding-right: 1rem;
|
|
1100
1100
|
}
|
|
1101
1101
|
|
|
1102
1102
|
.chat-container--boxed .messages {
|
|
1103
|
-
max-width:
|
|
1103
|
+
max-width: 768px;
|
|
1104
1104
|
margin-left: auto;
|
|
1105
1105
|
margin-right: auto;
|
|
1106
1106
|
}
|
|
1107
1107
|
|
|
1108
1108
|
:host(:not([boxed])) .input-container {
|
|
1109
|
-
border-radius:
|
|
1110
|
-
margin:
|
|
1109
|
+
border-radius: 12px;
|
|
1110
|
+
margin: 1rem;
|
|
1111
1111
|
box-sizing: border-box;
|
|
1112
|
-
width: calc(100% - 2 *
|
|
1112
|
+
width: calc(100% - 2 * 1rem);
|
|
1113
1113
|
}
|
|
1114
1114
|
|
|
1115
1115
|
:host(:not([boxed])) .action-buttons-row {
|
|
1116
|
-
border-bottom-left-radius:
|
|
1117
|
-
border-bottom-right-radius:
|
|
1116
|
+
border-bottom-left-radius: 12px;
|
|
1117
|
+
border-bottom-right-radius: 12px;
|
|
1118
1118
|
}
|
|
1119
1119
|
|
|
1120
1120
|
:host(:not([boxed])) .messages {
|
|
1121
|
-
padding:
|
|
1121
|
+
padding: 1rem !important;
|
|
1122
1122
|
width: 100%;
|
|
1123
1123
|
box-sizing: border-box;
|
|
1124
1124
|
}
|
|
@@ -1127,25 +1127,25 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1127
1127
|
display: flex;
|
|
1128
1128
|
align-items: center;
|
|
1129
1129
|
justify-content: space-between;
|
|
1130
|
-
gap:
|
|
1131
|
-
padding:
|
|
1130
|
+
gap: 0.75rem;
|
|
1131
|
+
padding: 0.5rem 1rem 1rem 1rem;
|
|
1132
1132
|
background-color: transparent;
|
|
1133
|
-
border-bottom-left-radius:
|
|
1134
|
-
border-bottom-right-radius:
|
|
1135
|
-
min-width:
|
|
1133
|
+
border-bottom-left-radius: 8px;
|
|
1134
|
+
border-bottom-right-radius: 8px;
|
|
1135
|
+
min-width: 240px;
|
|
1136
1136
|
}
|
|
1137
1137
|
|
|
1138
1138
|
.action-buttons-left {
|
|
1139
1139
|
display: flex;
|
|
1140
1140
|
align-items: center;
|
|
1141
|
-
gap:
|
|
1141
|
+
gap: 0.5rem;
|
|
1142
1142
|
}
|
|
1143
1143
|
|
|
1144
1144
|
.action-buttons-right {
|
|
1145
1145
|
display: flex;
|
|
1146
1146
|
align-items: center;
|
|
1147
|
-
gap:
|
|
1148
|
-
min-width: calc(
|
|
1147
|
+
gap: 0.5rem;
|
|
1148
|
+
min-width: calc(40px + 0.5rem);
|
|
1149
1149
|
justify-content: flex-end;
|
|
1150
1150
|
}
|
|
1151
1151
|
|
|
@@ -1157,7 +1157,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1157
1157
|
|
|
1158
1158
|
/* Module select styling */
|
|
1159
1159
|
.module-select {
|
|
1160
|
-
max-width:
|
|
1160
|
+
max-width: 300px;
|
|
1161
1161
|
}
|
|
1162
1162
|
|
|
1163
1163
|
/* Ensure buttons in action row match select height */
|
|
@@ -1166,58 +1166,58 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1166
1166
|
}
|
|
1167
1167
|
|
|
1168
1168
|
.module-display-placeholder {
|
|
1169
|
-
color:
|
|
1170
|
-
font-size:
|
|
1169
|
+
color: #6f6f6f;
|
|
1170
|
+
font-size: 0.875rem; /* 14px */
|
|
1171
1171
|
}
|
|
1172
1172
|
|
|
1173
1173
|
.module-display-single,
|
|
1174
1174
|
.module-display-multiple {
|
|
1175
1175
|
display: flex;
|
|
1176
1176
|
align-items: center;
|
|
1177
|
-
gap:
|
|
1178
|
-
font-size:
|
|
1179
|
-
color:
|
|
1177
|
+
gap: 0.5rem; /* 6px */
|
|
1178
|
+
font-size: 0.875rem; /* 14px */
|
|
1179
|
+
color: inherit;
|
|
1180
1180
|
}
|
|
1181
1181
|
|
|
1182
1182
|
.module-display-single nr-icon {
|
|
1183
|
-
font-size:
|
|
1183
|
+
font-size: 1rem; /* 16px */
|
|
1184
1184
|
}
|
|
1185
1185
|
|
|
1186
1186
|
.module-display-multiple {
|
|
1187
1187
|
font-weight: 500;
|
|
1188
|
-
color:
|
|
1188
|
+
color: #7c3aed;
|
|
1189
1189
|
}
|
|
1190
1190
|
|
|
1191
1191
|
/* Dropdown styling inside chatbot */
|
|
1192
1192
|
.input-box__upload-dropdown {
|
|
1193
1193
|
position: relative;
|
|
1194
|
-
z-index:
|
|
1194
|
+
z-index: 100;
|
|
1195
1195
|
}
|
|
1196
1196
|
|
|
1197
1197
|
.input-box__upload-dropdown ::part(panel) {
|
|
1198
|
-
background-color:
|
|
1199
|
-
border:
|
|
1200
|
-
border-radius:
|
|
1201
|
-
box-shadow:
|
|
1202
|
-
min-width:
|
|
1198
|
+
background-color: #ffffff;
|
|
1199
|
+
border: 1px solid #e0e0e0;
|
|
1200
|
+
border-radius: 8px;
|
|
1201
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
|
|
1202
|
+
min-width: 200px;
|
|
1203
1203
|
position: fixed !important; /* Use fixed positioning to break out of containers */
|
|
1204
|
-
z-index:
|
|
1204
|
+
z-index: 100;
|
|
1205
1205
|
transform: none !important;
|
|
1206
1206
|
}
|
|
1207
1207
|
|
|
1208
1208
|
.input-box__input {
|
|
1209
1209
|
flex: 1;
|
|
1210
1210
|
width: 100%;
|
|
1211
|
-
min-height:
|
|
1212
|
-
max-height:
|
|
1211
|
+
min-height: 1.5rem; /* 24px */
|
|
1212
|
+
max-height: 120px;
|
|
1213
1213
|
overflow-y: auto;
|
|
1214
1214
|
padding: 0;
|
|
1215
1215
|
border: none;
|
|
1216
1216
|
outline: none;
|
|
1217
1217
|
background: transparent;
|
|
1218
|
-
color:
|
|
1219
|
-
font-family:
|
|
1220
|
-
font-size:
|
|
1218
|
+
color: #161616;
|
|
1219
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
1220
|
+
font-size: 0.875rem;
|
|
1221
1221
|
line-height: 1.4;
|
|
1222
1222
|
resize: none;
|
|
1223
1223
|
white-space: pre-wrap;
|
|
@@ -1226,7 +1226,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1226
1226
|
|
|
1227
1227
|
.input-box__input:empty::before {
|
|
1228
1228
|
content: attr(data-placeholder);
|
|
1229
|
-
color:
|
|
1229
|
+
color: #a8a8a8;
|
|
1230
1230
|
pointer-events: none;
|
|
1231
1231
|
}
|
|
1232
1232
|
|
|
@@ -1245,54 +1245,54 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1245
1245
|
.input-box__file-button button,
|
|
1246
1246
|
.input-box__send-button button {
|
|
1247
1247
|
background: transparent !important;
|
|
1248
|
-
border:
|
|
1249
|
-
color:
|
|
1250
|
-
padding:
|
|
1251
|
-
border-radius:
|
|
1252
|
-
font-size:
|
|
1248
|
+
border: 1px solid #e0e0e0 !important;
|
|
1249
|
+
color: #161616 !important;
|
|
1250
|
+
padding: 0.5rem 0.75rem !important; /* 8px 12px */
|
|
1251
|
+
border-radius: 6px !important;
|
|
1252
|
+
font-size: 0.875rem !important; /* 14px */
|
|
1253
1253
|
font-weight: 500 !important;
|
|
1254
1254
|
min-width: auto !important;
|
|
1255
1255
|
height: auto !important;
|
|
1256
|
-
gap:
|
|
1257
|
-
transition:
|
|
1256
|
+
gap: 0.5rem !important; /* 8px */
|
|
1257
|
+
transition: all 0.2s ease !important;
|
|
1258
1258
|
white-space: nowrap !important;
|
|
1259
1259
|
}
|
|
1260
1260
|
|
|
1261
1261
|
/* Send button specific styling for more rounded appearance */
|
|
1262
1262
|
.input-box__send-button button {
|
|
1263
|
-
border-radius:
|
|
1264
|
-
background-color:
|
|
1265
|
-
color:
|
|
1266
|
-
border-color:
|
|
1267
|
-
width:
|
|
1268
|
-
height:
|
|
1269
|
-
min-width:
|
|
1263
|
+
border-radius: 6px !important;
|
|
1264
|
+
background-color: #7c3aed !important;
|
|
1265
|
+
color: #ffffff !important;
|
|
1266
|
+
border-color: #7c3aed !important;
|
|
1267
|
+
width: 40px !important; /* Match other button widths */
|
|
1268
|
+
height: 40px !important; /* Match other button heights */
|
|
1269
|
+
min-width: 40px !important; /* Prevent shrinking */
|
|
1270
1270
|
}
|
|
1271
1271
|
|
|
1272
1272
|
.input-box__file-button:hover button,
|
|
1273
1273
|
.input-box__send-button:hover button {
|
|
1274
|
-
background-color:
|
|
1275
|
-
border-color:
|
|
1274
|
+
background-color: #f4f4f4 !important;
|
|
1275
|
+
border-color: #c6c6c6 !important;
|
|
1276
1276
|
transform: scale(1.05);
|
|
1277
1277
|
}
|
|
1278
1278
|
|
|
1279
1279
|
/* Send button hover specific styling */
|
|
1280
1280
|
.input-box__send-button:hover button {
|
|
1281
|
-
background-color:
|
|
1282
|
-
border-color:
|
|
1281
|
+
background-color: #6d28d9 !important;
|
|
1282
|
+
border-color: #6d28d9 !important;
|
|
1283
1283
|
}
|
|
1284
1284
|
|
|
1285
1285
|
.input-box__file-button:focus-within,
|
|
1286
1286
|
.input-box__send-button:focus-within {
|
|
1287
|
-
outline:
|
|
1288
|
-
outline-offset:
|
|
1287
|
+
outline: 0.25rem solid #7c3aed; /* 2px */
|
|
1288
|
+
outline-offset: 0.25rem; /* 2px */
|
|
1289
1289
|
}
|
|
1290
1290
|
|
|
1291
1291
|
.input-box__send-button[disabled] button,
|
|
1292
1292
|
.input-box__file-button[disabled] button {
|
|
1293
|
-
background-color:
|
|
1294
|
-
color:
|
|
1295
|
-
border-color:
|
|
1293
|
+
background-color: #f4f4f4 !important;
|
|
1294
|
+
color: #c6c6c6 !important;
|
|
1295
|
+
border-color: #e0e0e0 !important;
|
|
1296
1296
|
opacity: 0.6 !important;
|
|
1297
1297
|
cursor: not-allowed !important;
|
|
1298
1298
|
}
|
|
@@ -1310,7 +1310,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1310
1310
|
|
|
1311
1311
|
:host([dir='rtl']) .thread-sidebar {
|
|
1312
1312
|
border-right: none;
|
|
1313
|
-
border-left:
|
|
1313
|
+
border-left: 1px solid var(--chatbot-border);
|
|
1314
1314
|
}
|
|
1315
1315
|
|
|
1316
1316
|
:host([dir='rtl']) .message.user {
|
|
@@ -1322,11 +1322,11 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1322
1322
|
}
|
|
1323
1323
|
|
|
1324
1324
|
:host([dir='rtl']) .message.user .message__content {
|
|
1325
|
-
border-radius:
|
|
1325
|
+
border-radius: 0;
|
|
1326
1326
|
}
|
|
1327
1327
|
|
|
1328
1328
|
:host([dir='rtl']) .message.bot .message__content {
|
|
1329
|
-
border-radius:
|
|
1329
|
+
border-radius: 0;
|
|
1330
1330
|
}
|
|
1331
1331
|
|
|
1332
1332
|
:host([dir='rtl']) .message.user .message__timestamp {
|
|
@@ -1343,13 +1343,13 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1343
1343
|
|
|
1344
1344
|
/* Size variants */
|
|
1345
1345
|
:host([data-size='small']) {
|
|
1346
|
-
--chatbot-spacing-md:
|
|
1347
|
-
font-size:
|
|
1346
|
+
--chatbot-spacing-md: 0.75rem; /* 12px */
|
|
1347
|
+
font-size: 13px;
|
|
1348
1348
|
}
|
|
1349
1349
|
|
|
1350
1350
|
:host([data-size='large']) {
|
|
1351
|
-
--chatbot-spacing-md:
|
|
1352
|
-
font-size:
|
|
1351
|
+
--chatbot-spacing-md: 20px;
|
|
1352
|
+
font-size: 15px;
|
|
1353
1353
|
}
|
|
1354
1354
|
|
|
1355
1355
|
/* Variant styles */
|
|
@@ -1363,7 +1363,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1363
1363
|
|
|
1364
1364
|
/* Mode-specific styles */
|
|
1365
1365
|
:host([data-mode='assistant']) .message.bot .message__content {
|
|
1366
|
-
background: linear-gradient(135deg,
|
|
1366
|
+
background: linear-gradient(135deg, transparent, #f1f1f1);
|
|
1367
1367
|
}
|
|
1368
1368
|
|
|
1369
1369
|
:host([data-mode='assistant']) .suggestion {
|
|
@@ -1378,12 +1378,12 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1378
1378
|
|
|
1379
1379
|
/* Artifact panel */
|
|
1380
1380
|
.artifact-panel {
|
|
1381
|
-
width:
|
|
1382
|
-
min-width:
|
|
1381
|
+
width: 400px;
|
|
1382
|
+
min-width: 300px;
|
|
1383
1383
|
flex-shrink: 0;
|
|
1384
1384
|
display: flex;
|
|
1385
1385
|
flex-direction: row;
|
|
1386
|
-
background-color:
|
|
1386
|
+
background-color: #ffffff;
|
|
1387
1387
|
overflow: hidden;
|
|
1388
1388
|
position: relative;
|
|
1389
1389
|
}
|
|
@@ -1395,24 +1395,24 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1395
1395
|
display: flex;
|
|
1396
1396
|
align-items: center;
|
|
1397
1397
|
justify-content: center;
|
|
1398
|
-
background:
|
|
1398
|
+
background: #e0e0e0;
|
|
1399
1399
|
transition: background 0.15s;
|
|
1400
1400
|
z-index: 1;
|
|
1401
1401
|
}
|
|
1402
1402
|
.artifact-panel__resize-handle:hover,
|
|
1403
1403
|
.artifact-panel__resize-handle--active {
|
|
1404
|
-
background:
|
|
1404
|
+
background: #9ca3af;
|
|
1405
1405
|
}
|
|
1406
1406
|
.artifact-panel__resize-bar {
|
|
1407
1407
|
width: 2px;
|
|
1408
1408
|
height: 24px;
|
|
1409
1409
|
border-radius: 1px;
|
|
1410
|
-
background:
|
|
1410
|
+
background: #9ca3af;
|
|
1411
1411
|
transition: background 0.15s;
|
|
1412
1412
|
}
|
|
1413
1413
|
.artifact-panel__resize-handle:hover .artifact-panel__resize-bar,
|
|
1414
1414
|
.artifact-panel__resize-handle--active .artifact-panel__resize-bar {
|
|
1415
|
-
background:
|
|
1415
|
+
background: #1f2937;
|
|
1416
1416
|
}
|
|
1417
1417
|
|
|
1418
1418
|
.artifact-panel__body {
|
|
@@ -1420,7 +1420,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1420
1420
|
display: flex;
|
|
1421
1421
|
flex-direction: column;
|
|
1422
1422
|
min-width: 0;
|
|
1423
|
-
border-left: 1px solid
|
|
1423
|
+
border-left: 1px solid #e0e0e0;
|
|
1424
1424
|
overflow: hidden;
|
|
1425
1425
|
}
|
|
1426
1426
|
|
|
@@ -1429,7 +1429,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1429
1429
|
align-items: center;
|
|
1430
1430
|
justify-content: space-between;
|
|
1431
1431
|
padding: 12px 16px;
|
|
1432
|
-
border-bottom: 1px solid
|
|
1432
|
+
border-bottom: 1px solid #e0e0e0;
|
|
1433
1433
|
flex-shrink: 0;
|
|
1434
1434
|
}
|
|
1435
1435
|
|
|
@@ -1451,7 +1451,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1451
1451
|
.artifact-panel__title {
|
|
1452
1452
|
font-size: 13px;
|
|
1453
1453
|
font-weight: 500;
|
|
1454
|
-
color:
|
|
1454
|
+
color: #1f2937;
|
|
1455
1455
|
white-space: nowrap;
|
|
1456
1456
|
overflow: hidden;
|
|
1457
1457
|
text-overflow: ellipsis;
|
|
@@ -1473,7 +1473,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1473
1473
|
.artifact-panel__code {
|
|
1474
1474
|
margin: 0;
|
|
1475
1475
|
padding: 16px;
|
|
1476
|
-
background:
|
|
1476
|
+
background: #f6f8fa;
|
|
1477
1477
|
border-radius: 8px;
|
|
1478
1478
|
font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
|
|
1479
1479
|
font-size: 13px;
|
|
@@ -1481,7 +1481,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1481
1481
|
overflow: auto;
|
|
1482
1482
|
white-space: pre-wrap;
|
|
1483
1483
|
word-wrap: break-word;
|
|
1484
|
-
color:
|
|
1484
|
+
color: #1f2937;
|
|
1485
1485
|
tab-size: 2;
|
|
1486
1486
|
}
|
|
1487
1487
|
|
|
@@ -1493,7 +1493,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1493
1493
|
.artifact-panel__rendered-md {
|
|
1494
1494
|
font-size: 14px;
|
|
1495
1495
|
line-height: 1.6;
|
|
1496
|
-
color:
|
|
1496
|
+
color: #1f2937;
|
|
1497
1497
|
}
|
|
1498
1498
|
|
|
1499
1499
|
.artifact-panel__rendered-md h1,
|
|
@@ -1508,7 +1508,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1508
1508
|
}
|
|
1509
1509
|
|
|
1510
1510
|
.artifact-panel__rendered-md pre {
|
|
1511
|
-
background:
|
|
1511
|
+
background: #f6f8fa;
|
|
1512
1512
|
padding: 12px;
|
|
1513
1513
|
border-radius: 6px;
|
|
1514
1514
|
overflow: auto;
|
|
@@ -1517,13 +1517,13 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1517
1517
|
.artifact-panel__rendered-html {
|
|
1518
1518
|
font-size: 14px;
|
|
1519
1519
|
line-height: 1.6;
|
|
1520
|
-
color:
|
|
1520
|
+
color: #1f2937;
|
|
1521
1521
|
}
|
|
1522
1522
|
|
|
1523
1523
|
.artifact-panel__rendered-text {
|
|
1524
1524
|
font-size: 14px;
|
|
1525
1525
|
line-height: 1.6;
|
|
1526
|
-
color:
|
|
1526
|
+
color: #1f2937;
|
|
1527
1527
|
white-space: pre-wrap;
|
|
1528
1528
|
word-wrap: break-word;
|
|
1529
1529
|
font-family: system-ui, -apple-system, sans-serif;
|
|
@@ -1585,22 +1585,22 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1585
1585
|
|
|
1586
1586
|
:host([boxed]) .messages {
|
|
1587
1587
|
width: 100%;
|
|
1588
|
-
padding:
|
|
1588
|
+
padding: 8px 0.75rem;
|
|
1589
1589
|
}
|
|
1590
1590
|
|
|
1591
1591
|
.chat-container--boxed .input-container {
|
|
1592
1592
|
width: 100%;
|
|
1593
|
-
padding-left:
|
|
1594
|
-
padding-right:
|
|
1593
|
+
padding-left: 0.75rem;
|
|
1594
|
+
padding-right: 0.75rem;
|
|
1595
1595
|
}
|
|
1596
1596
|
|
|
1597
1597
|
.chat-container--boxed .input-box {
|
|
1598
|
-
padding:
|
|
1598
|
+
padding: 0.75rem 0;
|
|
1599
1599
|
}
|
|
1600
1600
|
|
|
1601
1601
|
:host([boxed]) .chatbot-content:has(.empty-state) + .input-box {
|
|
1602
1602
|
max-width: 100%;
|
|
1603
|
-
padding: 0
|
|
1603
|
+
padding: 0 0.75rem;
|
|
1604
1604
|
}
|
|
1605
1605
|
}
|
|
1606
1606
|
|
|
@@ -1634,24 +1634,24 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1634
1634
|
|
|
1635
1635
|
/* Boxed mode mobile fixes */
|
|
1636
1636
|
:host([boxed]) .messages {
|
|
1637
|
-
padding:
|
|
1637
|
+
padding: 8px 0.5rem;
|
|
1638
1638
|
}
|
|
1639
1639
|
|
|
1640
1640
|
.chat-container--boxed .input-container {
|
|
1641
|
-
padding-left:
|
|
1642
|
-
padding-right:
|
|
1641
|
+
padding-left: 0.5rem;
|
|
1642
|
+
padding-right: 0.5rem;
|
|
1643
1643
|
}
|
|
1644
1644
|
|
|
1645
1645
|
.chat-container--boxed .input-box {
|
|
1646
|
-
padding:
|
|
1646
|
+
padding: 0.5rem 0;
|
|
1647
1647
|
}
|
|
1648
1648
|
|
|
1649
1649
|
:host([boxed]) .chatbot-content:has(.empty-state) + .input-box {
|
|
1650
|
-
padding: 0
|
|
1650
|
+
padding: 0 0.5rem;
|
|
1651
1651
|
}
|
|
1652
1652
|
|
|
1653
1653
|
.input-row {
|
|
1654
|
-
padding:
|
|
1654
|
+
padding: 0.75rem;
|
|
1655
1655
|
}
|
|
1656
1656
|
}
|
|
1657
1657
|
|
|
@@ -1680,34 +1680,50 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
|
|
|
1680
1680
|
* @license
|
|
1681
1681
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
1682
1682
|
* SPDX-License-Identifier: MIT
|
|
1683
|
-
|
|
1683
|
+
*/;const D=t=>class extends t{constructor(){super(...arguments),this.handleSystemThemeChange=()=>{this.closest("[data-theme]")||document.documentElement.hasAttribute("data-theme")||this.requestUpdate()}}connectedCallback(){super.connectedCallback(),this.setupThemeObserver(),this.setupDesignSystemObserver(),this.setupSystemThemeListener()}disconnectedCallback(){var t,e,n;super.disconnectedCallback(),null===(t=this.themeObserver)||void 0===t||t.disconnect(),null===(e=this.designSystemObserver)||void 0===e||e.disconnect(),null===(n=this.mediaQuery)||void 0===n||n.removeEventListener("change",this.handleSystemThemeChange)}get currentTheme(){var t,e;const n=(null===(t=this.closest("[data-theme]"))||void 0===t?void 0:t.getAttribute("data-theme"))||document.documentElement.getAttribute("data-theme");return n||((null===(e=window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light")}get currentDesignSystem(){var t;const e=(null===(t=this.closest("[design-system]"))||void 0===t?void 0:t.getAttribute("design-system"))||document.documentElement.getAttribute("design-system");return"carbon"===e?e:"default"}setupThemeObserver(){this.themeObserver=new MutationObserver(()=>{this.requestUpdate()}),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})}setupDesignSystemObserver(){this.designSystemObserver=new MutationObserver(()=>{this.requestUpdate()}),this.designSystemObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["design-system"]})}setupSystemThemeListener(){window.matchMedia&&(this.mediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.mediaQuery.addEventListener("change",this.handleSystemThemeChange))}},F=()=>{var t;return void 0!==globalThis.litElementVersions||"undefined"!=typeof process&&"development"===(null===(t=process.env)||void 0===t?void 0:t.NODE_ENV)||"undefined"!=typeof window&&("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname)},N=t=>class extends t{constructor(){super(...arguments),this.requiredComponents=[]}validateDependencies(){if(F())for(const t of this.requiredComponents)if(!this.isComponentAvailable(t))throw new Error(`Required component "${t}" is not registered. Please import and register the component before using ${this.tagName.toLowerCase()}. Example: import '@nuralyui/${t}';`)}validateDependenciesWithHandler(t){if(!F())return!0;let e=!0;for(const n of this.requiredComponents)if(!this.isComponentAvailable(n)){e=!1;const i=new Error(`Required component "${n}" is not registered. Please import and register the component before using ${this.tagName.toLowerCase()}.`);t?t(n,i):console.error(i.message)}return e}isComponentAvailable(t){return!!customElements.get(t)}getMissingDependencies(){return this.requiredComponents.filter(t=>!this.isComponentAvailable(t))}areDependenciesAvailable(){return this.requiredComponents.every(t=>this.isComponentAvailable(t))}addRequiredComponent(t){this.requiredComponents.includes(t)||this.requiredComponents.push(t)}removeRequiredComponent(t){const e=this.requiredComponents.indexOf(t);e>-1&&this.requiredComponents.splice(e,1)}},L=t=>class extends t{dispatchCustomEvent(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))}dispatchEventWithMetadata(t,e){var n;const i=Object.assign(Object.assign({},e),{timestamp:Date.now(),componentName:(null===(n=this.tagName)||void 0===n?void 0:n.toLowerCase())||"unknown"});this.dispatchCustomEvent(t,i)}dispatchInputEvent(t,e){const n=Object.assign({target:e.target||this,value:e.value,originalEvent:e.originalEvent},e);this.dispatchCustomEvent(t,n)}dispatchFocusEvent(t,e){const n=Object.assign({target:e.target||this,value:e.value,focused:e.focused,cursorPosition:e.cursorPosition,selectedText:e.selectedText},e);this.dispatchCustomEvent(t,n)}dispatchValidationEvent(t,e){var n;const i=Object.assign({target:e.target||this,value:e.value,isValid:null!==(n=e.isValid)&&void 0!==n&&n,error:e.error},e);this.dispatchCustomEvent(t,i)}dispatchActionEvent(t,e){const n=Object.assign({target:e.target||this,action:e.action,previousValue:e.previousValue,newValue:e.newValue},e);this.dispatchCustomEvent(t,n)}isReadonlyKeyAllowed(t){if(t.ctrlKey||t.metaKey){return["KeyA","KeyC"].includes(t.code)}return["Tab","Escape","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key)}isActivationKey(t){return"Enter"===t.key||" "===t.key}},B=new Set,U=new Map;
|
|
1684
|
+
/**
|
|
1685
|
+
* @license
|
|
1686
|
+
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
1687
|
+
* SPDX-License-Identifier: MIT
|
|
1688
|
+
*/
|
|
1689
|
+
/**
|
|
1690
|
+
* @license
|
|
1691
|
+
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
1692
|
+
* SPDX-License-Identifier: MIT
|
|
1693
|
+
*/
|
|
1694
|
+
const W=t=>{class e extends t{constructor(){super(...arguments),this.o=null}createRenderRoot(){return this.constructor.useShadowDom?super.createRenderRoot():this}connectedCallback(){const t=this.constructor.useShadowDom;if(!t&&null===this.o)for(this.o=[];this.firstChild;)this.o.push(this.removeChild(this.firstChild));if(super.connectedCallback(),!t){const t=this.constructor,e=this.tagName.toLowerCase(),n=t.styles;if(n){const t=H(n);t&&function(t,e,n){var i;if(!U.has(t)){const n=new CSSStyleSheet;n.replaceSync(e),U.set(t,n)}const o=U.get(t),s=`doc:${t}`;if(B.has(s)||(document.adoptedStyleSheets=[...document.adoptedStyleSheets,o],B.add(s)),n){let e=n;for(;e;){const n=e.getRootNode();if(!(n instanceof ShadowRoot))break;{const s=`shadow:${((null===(i=n.host)||void 0===i?void 0:i.tagName)||"").toLowerCase()}:${t}`;B.has(s)||(n.adoptedStyleSheets=[...n.adoptedStyleSheets,o],B.add(s)),e=n.host}}}}(e,t,this)}}}get lightChildren(){return this.o?this.o.filter(t=>!(t instanceof Element&&t.hasAttribute("slot"))):[]}lightChildrenNamed(t){return this.o?this.o.filter(e=>e instanceof Element&&e.getAttribute("slot")===t):[]}}return e.useShadowDom=!1,e};function H(t){return Array.isArray(t)?t.map(t=>H(t)).filter(Boolean).join("\n"):t&&"string"==typeof t.cssText?t.cssText:"string"==typeof t?t:""}
|
|
1695
|
+
/**
|
|
1696
|
+
* @license
|
|
1697
|
+
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
1698
|
+
* SPDX-License-Identifier: MIT
|
|
1699
|
+
*/var J,q,V,G,K,Y,X;!function(t){t.User="user",t.Bot="bot",t.System="system"}(J||(J={})),function(t){t.Dots="dots",t.Spinner="spinner",t.Wave="wave",t.Typing="typing"}(q||(q={})),function(t){t.Small="small",t.Medium="medium",t.Large="large",t.Full="full"}(V||(V={})),function(t){t.Default="default",t.Minimal="minimal",t.Rounded="rounded",t.ChatGPT="chatgpt"}(G||(G={})),function(t){t.Default="default",t.Error="error",t.Success="success",t.Loading="loading",t.Pending="pending"}(K||(K={})),function(t){t.Image="image",t.Document="document",t.Audio="audio",t.Video="video",t.Archive="archive",t.Code="code",t.Unknown="unknown"}(Y||(Y={})),function(t){t.Upload="upload",t.Clear="clear",t.Export="export",t.Settings="settings",t.Microphone="microphone",t.Camera="camera",t.Attach="attach"}(X||(X={}));const Q="",Z=1e3,tt=100,et=10485760,nt=5,it=["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"],ot={"image/":Y.Image,"audio/":Y.Audio,"video/":Y.Video,"application/pdf":Y.Document,"application/msword":Y.Document,"application/vnd.openxmlformats-officedocument":Y.Document,"text/":Y.Document,"application/zip":Y.Archive,"application/x-rar":Y.Archive,"application/javascript":Y.Code,"text/html":Y.Code,"text/css":Y.Code};
|
|
1684
1700
|
/**
|
|
1685
1701
|
* @license
|
|
1686
1702
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
1687
1703
|
* SPDX-License-Identifier: MIT
|
|
1688
1704
|
*/
|
|
1689
|
-
function
|
|
1705
|
+
function st(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.isNaN(e.getTime()))return"";const n=new Date,i={hour:"numeric",minute:"2-digit",hour12:!0};if(e.toDateString()===n.toDateString())return e.toLocaleTimeString(void 0,i);const o=Object.assign({month:"short",day:"numeric"},i);return e.toLocaleDateString(void 0,o)}function rt(t){return t.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}const at={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 lt(t){return at[t]||t.charAt(0).toUpperCase()+t.slice(1)}function dt(t){let e=rt(t);return e=e.replaceAll(/```([\s\S]*?)```/g,'<pre class="md-code"><code>$1</code></pre>'),e=e.replaceAll(/`([^`]+)`/g,'<code class="md-inline-code">$1</code>'),e=e.replaceAll(/^###[^\S\n]+(.+)$/gm,"<h3>$1</h3>"),e=e.replaceAll(/^##[^\S\n]+(.+)$/gm,"<h2>$1</h2>"),e=e.replaceAll(/^#[^\S\n]+(.+)$/gm,"<h1>$1</h1>"),e=e.replaceAll(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),e=e.replaceAll(/\*([^*]+)\*/g,"<em>$1</em>"),e=e.replaceAll(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'),e=e.replaceAll(/(?:^|\n)-\s+(.+)(?=\n|$)/g,(t,e)=>`\n<ul><li>${e}</li></ul>`),e=e.replaceAll(/<ul>\s*<li>([\s\S]*?)<\/li>\s*<\/ul>\n<ul>/g,"<ul><li>$1</li>"),e=e.split(/\n\n+/).map(t=>/^(<h\d|<pre|<ul|<ol|<blockquote)/.test(t.trim())?t:`<p>${t.replaceAll("\n","<br/>")}</p>`).join("\n"),e}
|
|
1690
1706
|
/**
|
|
1691
1707
|
* @license
|
|
1692
1708
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
1693
1709
|
* SPDX-License-Identifier: MIT
|
|
1694
|
-
*/function
|
|
1710
|
+
*/function ct(t,i){var o,s,r,d,c,h,u,p;const g=null===(o=t.text)||void 0===o?void 0:o.includes("[ERROR_START]"),m={error:!!t.error||g,introduction:!!t.introduction,[t.sender]:!0};return n`
|
|
1695
1711
|
<div
|
|
1696
|
-
class="message ${a(
|
|
1712
|
+
class="message ${a(m)}"
|
|
1697
1713
|
part="message"
|
|
1698
1714
|
data-sender="${t.sender}"
|
|
1699
1715
|
data-id="${t.id}"
|
|
1700
1716
|
>
|
|
1701
1717
|
<div class="message__content" part="message-content">
|
|
1702
|
-
${
|
|
1718
|
+
${g?function(t){const e=t.match(/\[ERROR_START\]\[ERROR_TITLE_START\]([\s\S]*?)\[ERROR_TITLE_END\]([\s\S]*?)\[ERROR_END\]/);if(e){const t=e[1],i=e[2];return n`
|
|
1703
1719
|
<div class="message__error-container" part="message-error">
|
|
1704
1720
|
${t?n`<div class="message__error-title" part="message-error-title">${t}</div>`:""}
|
|
1705
1721
|
<div class="message__error-description" part="message-error-description">${i}</div>
|
|
1706
1722
|
</div>
|
|
1707
|
-
`}return n`${t}`}(null!==(
|
|
1723
|
+
`}return n`${t}`}(null!==(r=null===(s=t.text)||void 0===s?void 0:s.trim())&&void 0!==r?r:""):(null===(d=null==t?void 0:t.metadata)||void 0===d?void 0:d.renderAsHtml)?l(null!==(h=null===(c=t.text)||void 0===c?void 0:c.trim())&&void 0!==h?h:""):l((null!==(p=null===(u=t.text)||void 0===u?void 0:u.trim())&&void 0!==p?p:"").replaceAll("\n","<br>"))}
|
|
1708
1724
|
</div>
|
|
1709
1725
|
${t.files&&t.files.length>0?n`
|
|
1710
|
-
<div class="message__attachments" part="message-attachments" role="list" aria-label="${
|
|
1726
|
+
<div class="message__attachments" part="message-attachments" role="list" aria-label="${f("Attached files")}">
|
|
1711
1727
|
${t.files.map(t=>{return n`
|
|
1712
1728
|
<nr-dropdown
|
|
1713
1729
|
trigger="hover"
|
|
@@ -1750,17 +1766,17 @@ function Q(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.i
|
|
|
1750
1766
|
`:e}
|
|
1751
1767
|
<div class="message__footer" part="message-footer">
|
|
1752
1768
|
<div class="message__timestamp" part="message-timestamp">
|
|
1753
|
-
${
|
|
1769
|
+
${st(t.timestamp)}
|
|
1754
1770
|
</div>
|
|
1755
1771
|
<nr-icon
|
|
1756
1772
|
name="copy"
|
|
1757
1773
|
size="small"
|
|
1758
|
-
color="
|
|
1774
|
+
color="#9ca3af"
|
|
1759
1775
|
class="message__copy"
|
|
1760
1776
|
@click=${()=>i.onCopy(t)}
|
|
1761
1777
|
@keydown=${e=>i.onCopyKeydown(e,t)}
|
|
1762
|
-
title="${
|
|
1763
|
-
aria-label="${
|
|
1778
|
+
title="${f("Copy message")}"
|
|
1779
|
+
aria-label="${f("Copy message")}"
|
|
1764
1780
|
role="button"
|
|
1765
1781
|
tabindex="0"
|
|
1766
1782
|
></nr-icon>
|
|
@@ -1773,23 +1789,23 @@ function Q(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.i
|
|
|
1773
1789
|
part="retry-button"
|
|
1774
1790
|
@click=${()=>i.onRetry(t)}
|
|
1775
1791
|
@keydown=${i.onRetryKeydown}
|
|
1776
|
-
aria-label="${
|
|
1792
|
+
aria-label="${f("Retry message")}"
|
|
1777
1793
|
>
|
|
1778
|
-
${
|
|
1794
|
+
${f("Retry")}
|
|
1779
1795
|
</nr-button>`:e}
|
|
1780
1796
|
</div>
|
|
1781
|
-
`}function
|
|
1797
|
+
`}function ht(t,i,o,s){return n`
|
|
1782
1798
|
<div class="messages" part="messages">
|
|
1783
1799
|
${0===t.length?n`
|
|
1784
1800
|
<div class="empty-state" part="empty-state">
|
|
1785
1801
|
<slot name="empty-state">
|
|
1786
1802
|
<div class="empty-state__content">
|
|
1787
|
-
${
|
|
1803
|
+
${f("Start a conversation")}
|
|
1788
1804
|
</div>
|
|
1789
1805
|
</slot>
|
|
1790
1806
|
</div>
|
|
1791
1807
|
`:e}
|
|
1792
|
-
${t.map(t=>
|
|
1808
|
+
${t.map(t=>ct(t,s))}
|
|
1793
1809
|
${i}
|
|
1794
1810
|
${o}
|
|
1795
1811
|
</div>
|
|
@@ -1798,7 +1814,7 @@ function Q(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.i
|
|
|
1798
1814
|
* @license
|
|
1799
1815
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
1800
1816
|
* SPDX-License-Identifier: MIT
|
|
1801
|
-
*/function
|
|
1817
|
+
*/function ut(t,i,o){return i.length>0?n`
|
|
1802
1818
|
<div class="suggestion-container" part="suggestions">
|
|
1803
1819
|
${i.map(t=>function(t,e){return n`
|
|
1804
1820
|
<div
|
|
@@ -1809,7 +1825,7 @@ function Q(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.i
|
|
|
1809
1825
|
@click=${()=>e.onClick(t)}
|
|
1810
1826
|
@keydown=${e.onKeydown}
|
|
1811
1827
|
data-id="${t.id}"
|
|
1812
|
-
aria-label="${
|
|
1828
|
+
aria-label="${f("Select suggestion: ")}${t.text}"
|
|
1813
1829
|
>
|
|
1814
1830
|
${t.text}
|
|
1815
1831
|
</div>
|
|
@@ -1820,7 +1836,7 @@ function Q(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.i
|
|
|
1820
1836
|
* @license
|
|
1821
1837
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
1822
1838
|
* SPDX-License-Identifier: MIT
|
|
1823
|
-
*/function
|
|
1839
|
+
*/function pt(t,e,i){return n`
|
|
1824
1840
|
<div class="context-tags-row" part="context-tags">
|
|
1825
1841
|
${d(t,t=>t.id,t=>{return n`
|
|
1826
1842
|
<nr-dropdown
|
|
@@ -1863,7 +1879,7 @@ function Q(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.i
|
|
|
1863
1879
|
</nr-dropdown>
|
|
1864
1880
|
`;var o})}
|
|
1865
1881
|
</div>
|
|
1866
|
-
`}function
|
|
1882
|
+
`}function ft(t,i){return n`
|
|
1867
1883
|
<div class="action-buttons-row">
|
|
1868
1884
|
<div class="action-buttons-left">
|
|
1869
1885
|
${t.enableFileUpload?function(t,e){return n`
|
|
@@ -1883,8 +1899,8 @@ function Q(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.i
|
|
|
1883
1899
|
size="small"
|
|
1884
1900
|
.icon=${["upload"]}
|
|
1885
1901
|
?disabled=${t.disabled}
|
|
1886
|
-
aria-label="${
|
|
1887
|
-
title="${
|
|
1902
|
+
aria-label="${f("Attach files")}"
|
|
1903
|
+
title="${f("Attach files")}"
|
|
1888
1904
|
>
|
|
1889
1905
|
Attach
|
|
1890
1906
|
</nr-button>
|
|
@@ -1899,12 +1915,12 @@ function Q(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.i
|
|
|
1899
1915
|
size="small"
|
|
1900
1916
|
?disabled=${t.disabled}
|
|
1901
1917
|
searchable
|
|
1902
|
-
search-placeholder="${
|
|
1918
|
+
search-placeholder="${f("Search modules...")}"
|
|
1903
1919
|
use-custom-selected-display
|
|
1904
1920
|
part="module-select"
|
|
1905
1921
|
class="module-select"
|
|
1906
1922
|
@nr-change=${e.onModuleChange}
|
|
1907
|
-
aria-label="${
|
|
1923
|
+
aria-label="${f("Select modules")}"
|
|
1908
1924
|
>
|
|
1909
1925
|
<span slot="selected-display">
|
|
1910
1926
|
${t.renderModuleDisplay()}
|
|
@@ -1923,10 +1939,10 @@ function Q(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.i
|
|
|
1923
1939
|
.iconRight=${t.isQueryRunning?"square":"arrow-up"}
|
|
1924
1940
|
@click=${t.isQueryRunning?e.onStop:e.onSend}
|
|
1925
1941
|
@keydown=${e.onSendKeydown}
|
|
1926
|
-
aria-label="${t.isQueryRunning?
|
|
1927
|
-
title="${t.isQueryRunning?
|
|
1942
|
+
aria-label="${t.isQueryRunning?f("Stop query"):f("Send message")}"
|
|
1943
|
+
title="${t.isQueryRunning?f("Stop query"):f("Send message")}"
|
|
1928
1944
|
>
|
|
1929
|
-
${t.isQueryRunning?
|
|
1945
|
+
${t.isQueryRunning?f("Stop"):f("Send")}
|
|
1930
1946
|
</nr-button>
|
|
1931
1947
|
`}(t,i):e}
|
|
1932
1948
|
</div>
|
|
@@ -1937,7 +1953,7 @@ function Q(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.i
|
|
|
1937
1953
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
1938
1954
|
* SPDX-License-Identifier: MIT
|
|
1939
1955
|
*/
|
|
1940
|
-
function
|
|
1956
|
+
function gt(t,e,i){const o=t.messages.length>0?t.messages[t.messages.length-1]:null,s=o&&"string"==typeof o.text?o.text:"";return n`
|
|
1941
1957
|
<div
|
|
1942
1958
|
class="thread-item ${a({"thread-item--active":t.id===e.activeThreadId})}"
|
|
1943
1959
|
@click=${()=>i.onSelectThread(t.id)}
|
|
@@ -1954,13 +1970,13 @@ function lt(t,e,i){const o=t.messages.length>0?t.messages[t.messages.length-1]:n
|
|
|
1954
1970
|
@blur=${e=>{const n=e.target.value.trim();n&&n!==t.title?i.onRenameThread(t.id,n):i.onRenameThread(t.id,t.title||"")}}
|
|
1955
1971
|
/>
|
|
1956
1972
|
`:n`
|
|
1957
|
-
<div class="thread-item__title">${t.title||
|
|
1973
|
+
<div class="thread-item__title">${t.title||f("New Chat")}</div>
|
|
1958
1974
|
`}
|
|
1959
1975
|
<div class="thread-item__actions">
|
|
1960
1976
|
${i.onRenameThread&&e.editingThreadId!==t.id?n`
|
|
1961
1977
|
<button
|
|
1962
1978
|
class="thread-item__action-btn"
|
|
1963
|
-
title="${
|
|
1979
|
+
title="${f("Rename conversation")}"
|
|
1964
1980
|
@click=${e=>{e.stopPropagation(),e.target.dispatchEvent(new CustomEvent("nr-thread-edit",{bubbles:!0,composed:!0,detail:{threadId:t.id}}))}}
|
|
1965
1981
|
part="thread-rename"
|
|
1966
1982
|
>
|
|
@@ -1970,7 +1986,7 @@ function lt(t,e,i){const o=t.messages.length>0?t.messages[t.messages.length-1]:n
|
|
|
1970
1986
|
${i.onBookmarkThread?n`
|
|
1971
1987
|
<button
|
|
1972
1988
|
class="thread-item__action-btn ${t.bookmarked?"thread-item__bookmark--active":""}"
|
|
1973
|
-
title="${t.bookmarked?
|
|
1989
|
+
title="${t.bookmarked?f("Remove bookmark"):f("Bookmark conversation")}"
|
|
1974
1990
|
@click=${e=>{e.stopPropagation(),i.onBookmarkThread(t.id)}}
|
|
1975
1991
|
part="thread-bookmark"
|
|
1976
1992
|
>
|
|
@@ -1983,10 +1999,10 @@ function lt(t,e,i){const o=t.messages.length>0?t.messages[t.messages.length-1]:n
|
|
|
1983
1999
|
`:""}
|
|
1984
2000
|
${i.onDeleteThread?n`
|
|
1985
2001
|
<nr-popconfirm
|
|
1986
|
-
title="${
|
|
1987
|
-
description="${
|
|
1988
|
-
ok-text="${
|
|
1989
|
-
cancel-text="${
|
|
2002
|
+
title="${f("Delete this conversation?")}"
|
|
2003
|
+
description="${f("This action cannot be undone.")}"
|
|
2004
|
+
ok-text="${f("Delete")}"
|
|
2005
|
+
cancel-text="${f("Cancel")}"
|
|
1990
2006
|
ok-type="danger"
|
|
1991
2007
|
placement="right"
|
|
1992
2008
|
@click=${t=>t.stopPropagation()}
|
|
@@ -1995,7 +2011,7 @@ function lt(t,e,i){const o=t.messages.length>0?t.messages[t.messages.length-1]:n
|
|
|
1995
2011
|
<button
|
|
1996
2012
|
slot="trigger"
|
|
1997
2013
|
class="thread-item__action-btn thread-item__delete"
|
|
1998
|
-
title="${
|
|
2014
|
+
title="${f("Delete conversation")}"
|
|
1999
2015
|
part="thread-delete"
|
|
2000
2016
|
>
|
|
2001
2017
|
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>
|
|
@@ -2005,11 +2021,11 @@ function lt(t,e,i){const o=t.messages.length>0?t.messages[t.messages.length-1]:n
|
|
|
2005
2021
|
</div>
|
|
2006
2022
|
</div>
|
|
2007
2023
|
<div class="thread-item__preview">
|
|
2008
|
-
${
|
|
2024
|
+
${s}
|
|
2009
2025
|
</div>
|
|
2010
|
-
<div class="thread-item__timestamp">${
|
|
2026
|
+
<div class="thread-item__timestamp">${st(t.updatedAt)}</div>
|
|
2011
2027
|
</div>
|
|
2012
|
-
`}function
|
|
2028
|
+
`}function mt(t,i){if(!t.isOpen||!t.file)return e;const o=t.file,s=o.mimeType.startsWith("image/"),r="application/pdf"===o.mimeType||o.name.toLowerCase().endsWith(".pdf");return n`
|
|
2013
2029
|
<nr-modal
|
|
2014
2030
|
.open=${t.isOpen}
|
|
2015
2031
|
size="large"
|
|
@@ -2017,13 +2033,13 @@ function lt(t,e,i){const o=t.messages.length>0?t.messages[t.messages.length-1]:n
|
|
|
2017
2033
|
@modal-close=${i.onClose}
|
|
2018
2034
|
>
|
|
2019
2035
|
<div style="width: 100%; height: 75vh; display: flex; flex-direction: column; align-items: stretch; justify-content: stretch;">
|
|
2020
|
-
${
|
|
2036
|
+
${s&&(o.url||o.previewUrl)?n`
|
|
2021
2037
|
<img
|
|
2022
2038
|
src="${o.url||o.previewUrl}"
|
|
2023
2039
|
alt="${o.name}"
|
|
2024
2040
|
style="max-width: 100%; max-height: 100%; object-fit: contain; align-self: center;"
|
|
2025
2041
|
/>
|
|
2026
|
-
`:
|
|
2042
|
+
`:r&&o.url?n`
|
|
2027
2043
|
<div style="width: 100%; height: 100%; position: relative;">
|
|
2028
2044
|
<nr-document
|
|
2029
2045
|
.src="${o.url}"
|
|
@@ -2038,7 +2054,7 @@ function lt(t,e,i){const o=t.messages.length>0?t.messages[t.messages.length-1]:n
|
|
|
2038
2054
|
<div style="text-align: center; padding: 2rem; align-self: center;">
|
|
2039
2055
|
<nr-icon name="file" size="xlarge" style="margin-bottom: 1rem;"></nr-icon>
|
|
2040
2056
|
<p style="font-size: 1.1rem; font-weight: 500; margin-bottom: 0.5rem;">${o.name}</p>
|
|
2041
|
-
<p style="color:
|
|
2057
|
+
<p style="color: #9ca3af; margin-bottom: 1.5rem;">
|
|
2042
2058
|
${
|
|
2043
2059
|
/**
|
|
2044
2060
|
* @license
|
|
@@ -2064,7 +2080,7 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2064
2080
|
* @license
|
|
2065
2081
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2066
2082
|
* SPDX-License-Identifier: MIT
|
|
2067
|
-
*/function
|
|
2083
|
+
*/function vt(t,i){var o;if(!t.isOpen||!t.artifact)return e;const s=t.artifact,r=lt(s.language);return n`
|
|
2068
2084
|
<div class="artifact-panel" part="artifact-panel">
|
|
2069
2085
|
<div class="artifact-panel__resize-handle" part="artifact-panel-resize-handle">
|
|
2070
2086
|
<div class="artifact-panel__resize-bar"></div>
|
|
@@ -2072,30 +2088,30 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2072
2088
|
<div class="artifact-panel__body">
|
|
2073
2089
|
<div class="artifact-panel__header">
|
|
2074
2090
|
<div class="artifact-panel__header-info">
|
|
2075
|
-
<nr-tag size="small" class="artifact-panel__lang-badge">${
|
|
2076
|
-
<span class="artifact-panel__title">${
|
|
2091
|
+
<nr-tag size="small" class="artifact-panel__lang-badge">${r}</nr-tag>
|
|
2092
|
+
<span class="artifact-panel__title">${s.title}</span>
|
|
2077
2093
|
</div>
|
|
2078
2094
|
<div class="artifact-panel__actions">
|
|
2079
2095
|
<nr-button
|
|
2080
2096
|
type="text"
|
|
2081
2097
|
size="small"
|
|
2082
2098
|
.icon=${["copy"]}
|
|
2083
|
-
@click=${()=>i.onCopy(
|
|
2084
|
-
title="${
|
|
2085
|
-
aria-label="${
|
|
2099
|
+
@click=${()=>i.onCopy(s)}
|
|
2100
|
+
title="${f("Copy code")}"
|
|
2101
|
+
aria-label="${f("Copy code")}"
|
|
2086
2102
|
></nr-button>
|
|
2087
2103
|
<nr-button
|
|
2088
2104
|
type="text"
|
|
2089
2105
|
size="small"
|
|
2090
2106
|
.icon=${["x"]}
|
|
2091
2107
|
@click=${i.onClose}
|
|
2092
|
-
title="${
|
|
2093
|
-
aria-label="${
|
|
2108
|
+
title="${f("Close panel")}"
|
|
2109
|
+
aria-label="${f("Close panel")}"
|
|
2094
2110
|
></nr-button>
|
|
2095
2111
|
</div>
|
|
2096
2112
|
</div>
|
|
2097
2113
|
<div class="artifact-panel__content">
|
|
2098
|
-
${(null===(o=t.renderContent)||void 0===o?void 0:o.call(t,
|
|
2114
|
+
${(null===(o=t.renderContent)||void 0===o?void 0:o.call(t,s))||function(t){switch(t.language){case"json":{let e;try{e=JSON.stringify(JSON.parse(t.content),null,2)}catch(n){e=t.content}return n`<pre class="artifact-panel__code"><code>${e}</code></pre>`}case"md":case"markdown":return n`<div class="artifact-panel__rendered-md">${l(dt(t.content))}</div>`;case"html":return n`<div class="artifact-panel__rendered-html">${l(t.content)}</div>`;case"text":case"txt":return n`<div class="artifact-panel__rendered-text">${t.content}</div>`;default:return n`<pre class="artifact-panel__code"><code>${t.content}</code></pre>`}}(s)}
|
|
2099
2115
|
</div>
|
|
2100
2116
|
</div>
|
|
2101
2117
|
</div>
|
|
@@ -2104,9 +2120,9 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2104
2120
|
* @license
|
|
2105
2121
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2106
2122
|
* SPDX-License-Identifier: MIT
|
|
2107
|
-
*/function
|
|
2123
|
+
*/function bt(t,i){return!1!==t.showMessages?n`
|
|
2108
2124
|
<div class="chatbot-content" part="content">
|
|
2109
|
-
${
|
|
2125
|
+
${ht(t.messages,ut(t.chatStarted,t.suggestions,i.suggestion),t.isTyping?function(t,i,o){if(!t)return e;const s=i===q.Dots?n`
|
|
2110
2126
|
<div class="dots">
|
|
2111
2127
|
<span></span>
|
|
2112
2128
|
<span></span>
|
|
@@ -2115,24 +2131,24 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2115
2131
|
`:n`<div class="spinner"></div>`;return n`
|
|
2116
2132
|
<div class="message bot loading" part="typing-indicator">
|
|
2117
2133
|
<div class="message__content">
|
|
2118
|
-
${
|
|
2134
|
+
${s}
|
|
2119
2135
|
${o?n`<span class="loading-text">${o.split("").map((t,e)=>n`<span class="loading-text__char" style="animation-delay:${.04*e}s">${" "===t?" ":t}</span>`)}</span>`:e}
|
|
2120
2136
|
</div>
|
|
2121
2137
|
</div>
|
|
2122
|
-
`}(t.isTyping,t.loadingIndicator||
|
|
2138
|
+
`}(t.isTyping,t.loadingIndicator||q.Spinner,t.loadingText):e,i.message)}
|
|
2123
2139
|
<slot name="messages"></slot>
|
|
2124
2140
|
</div>
|
|
2125
2141
|
`:t.suggestions&&t.suggestions.length>0?n`
|
|
2126
2142
|
<div class="input-only-suggestions" part="input-only-suggestions">
|
|
2127
|
-
${
|
|
2143
|
+
${ut(0,t.suggestions,i.suggestion)}
|
|
2128
2144
|
</div>
|
|
2129
|
-
`:e}function
|
|
2130
|
-
<div class="chatbot-container ${a({"chatbot-container--with-sidebar":t.enableThreads&&t.isThreadSidebarOpen,"chatbot-container--with-artifact-panel":!!
|
|
2145
|
+
`:e}function yt(t,i){var o;const s=t.enableArtifacts&&(null===(o=t.artifactPanel)||void 0===o?void 0:o.isOpen);return n`
|
|
2146
|
+
<div class="chatbot-container ${a({"chatbot-container--with-sidebar":t.enableThreads&&t.isThreadSidebarOpen,"chatbot-container--with-artifact-panel":!!s})}" part="container">
|
|
2131
2147
|
|
|
2132
|
-
${t.enableThreads&&t.isThreadSidebarOpen&&t.threadSidebar&&i.threadSidebar?function(t,i){const o=t.threads.filter(t=>t.bookmarked),
|
|
2148
|
+
${t.enableThreads&&t.isThreadSidebarOpen&&t.threadSidebar&&i.threadSidebar?function(t,i){const o=t.threads.filter(t=>t.bookmarked),s=t.threads.filter(t=>!t.bookmarked);return n`
|
|
2133
2149
|
<div class="thread-sidebar" part="thread-sidebar">
|
|
2134
2150
|
<div class="thread-sidebar__header">
|
|
2135
|
-
<h3>${
|
|
2151
|
+
<h3>${f("Conversations")}</h3>
|
|
2136
2152
|
</div>
|
|
2137
2153
|
|
|
2138
2154
|
<div class="thread-list">
|
|
@@ -2140,18 +2156,18 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2140
2156
|
<div class="thread-section" part="thread-section-bookmarks">
|
|
2141
2157
|
<div class="thread-section__label">
|
|
2142
2158
|
<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>
|
|
2143
|
-
${
|
|
2159
|
+
${f("Bookmarks")}
|
|
2144
2160
|
</div>
|
|
2145
|
-
${d(o,t=>t.id,e=>
|
|
2161
|
+
${d(o,t=>t.id,e=>gt(e,t,i))}
|
|
2146
2162
|
</div>
|
|
2147
2163
|
`:e}
|
|
2148
|
-
${
|
|
2164
|
+
${s.length>0||0===o.length?n`
|
|
2149
2165
|
${o.length>0?n`
|
|
2150
|
-
<div class="thread-section__label">${
|
|
2166
|
+
<div class="thread-section__label">${f("All Conversations")}</div>
|
|
2151
2167
|
`:e}
|
|
2152
|
-
${d(
|
|
2153
|
-
${0===
|
|
2154
|
-
<p class="empty-msg">${
|
|
2168
|
+
${d(s,t=>t.id,e=>gt(e,t,i))}
|
|
2169
|
+
${0===s.length&&0===o.length?n`
|
|
2170
|
+
<p class="empty-msg">${f("No conversations yet")}</p>
|
|
2155
2171
|
`:e}
|
|
2156
2172
|
`:e}
|
|
2157
2173
|
</div>
|
|
@@ -2173,8 +2189,8 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2173
2189
|
size="small"
|
|
2174
2190
|
.icon=${["panel-left"]}
|
|
2175
2191
|
@click=${i.onToggleThreadSidebar}
|
|
2176
|
-
title="${
|
|
2177
|
-
aria-label="${
|
|
2192
|
+
title="${f(t.isThreadSidebarOpen?"Hide threads":"Show threads")}"
|
|
2193
|
+
aria-label="${f(t.isThreadSidebarOpen?"Hide threads":"Show threads")}"
|
|
2178
2194
|
></nr-button>
|
|
2179
2195
|
${t.enableThreadCreation&&t.messages.length>0?n`
|
|
2180
2196
|
<nr-button
|
|
@@ -2182,8 +2198,8 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2182
2198
|
size="small"
|
|
2183
2199
|
.icon=${["square-pen"]}
|
|
2184
2200
|
@click=${null===(o=i.threadSidebar)||void 0===o?void 0:o.onCreateNew}
|
|
2185
|
-
title="${
|
|
2186
|
-
aria-label="${
|
|
2201
|
+
title="${f("New conversation")}"
|
|
2202
|
+
aria-label="${f("New conversation")}"
|
|
2187
2203
|
></nr-button>
|
|
2188
2204
|
`:""}
|
|
2189
2205
|
</div>
|
|
@@ -2191,13 +2207,13 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2191
2207
|
|
|
2192
2208
|
<slot name="header"></slot>
|
|
2193
2209
|
|
|
2194
|
-
${
|
|
2210
|
+
${bt(t,i)}
|
|
2195
2211
|
|
|
2196
2212
|
${function(t,i){return n`
|
|
2197
2213
|
<div class="input-box" part="input-box">
|
|
2198
2214
|
<div class="input-container">
|
|
2199
2215
|
<!-- Context tags -->
|
|
2200
|
-
${t.uploadedFiles.length>0?
|
|
2216
|
+
${t.uploadedFiles.length>0?pt(t.uploadedFiles,i.onFileRemove,i.onFileClick):e}
|
|
2201
2217
|
|
|
2202
2218
|
<!-- Input area -->
|
|
2203
2219
|
<div class="input-row">
|
|
@@ -2207,7 +2223,7 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2207
2223
|
contenteditable="true"
|
|
2208
2224
|
role="textbox"
|
|
2209
2225
|
aria-multiline="true"
|
|
2210
|
-
aria-label="${
|
|
2226
|
+
aria-label="${f("Chat input")}"
|
|
2211
2227
|
data-placeholder="${t.placeholder}"
|
|
2212
2228
|
@input=${i.onInput}
|
|
2213
2229
|
@keydown=${i.onKeydown}
|
|
@@ -2217,7 +2233,7 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2217
2233
|
</div>
|
|
2218
2234
|
|
|
2219
2235
|
<!-- Action buttons -->
|
|
2220
|
-
${
|
|
2236
|
+
${ft(t,i)}
|
|
2221
2237
|
</div>
|
|
2222
2238
|
</div>
|
|
2223
2239
|
`}(t.inputBox,i.inputBox)}
|
|
@@ -2225,7 +2241,7 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2225
2241
|
<slot name="footer"></slot>
|
|
2226
2242
|
</div>
|
|
2227
2243
|
|
|
2228
|
-
${
|
|
2244
|
+
${s&&t.artifactPanel&&i.artifactPanel?vt(t.artifactPanel,i.artifactPanel):""}
|
|
2229
2245
|
|
|
2230
2246
|
${t.isDragging?function(t,e){return n`
|
|
2231
2247
|
<div
|
|
@@ -2238,7 +2254,7 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2238
2254
|
<div class="file-upload-area__content">
|
|
2239
2255
|
<div class="file-upload-area__icon">📁</div>
|
|
2240
2256
|
<div class="file-upload-area__text">
|
|
2241
|
-
${
|
|
2257
|
+
${f("Drop files here to upload")}
|
|
2242
2258
|
</div>
|
|
2243
2259
|
</div>
|
|
2244
2260
|
</div>
|
|
@@ -2255,7 +2271,7 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2255
2271
|
@nr-modal-close=${i.onClose}
|
|
2256
2272
|
part="url-modal"
|
|
2257
2273
|
>
|
|
2258
|
-
<div slot="header">${
|
|
2274
|
+
<div slot="header">${f("Add URL")}</div>
|
|
2259
2275
|
|
|
2260
2276
|
<div >
|
|
2261
2277
|
<nr-row gutter="8" align="bottom">
|
|
@@ -2264,12 +2280,12 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2264
2280
|
|
|
2265
2281
|
type="url"
|
|
2266
2282
|
.value=${t.urlInput}
|
|
2267
|
-
placeholder="${
|
|
2283
|
+
placeholder="${f("Enter URL...")}"
|
|
2268
2284
|
?disabled=${t.isLoading}
|
|
2269
2285
|
@nr-input=${i.onUrlInputChange}
|
|
2270
2286
|
@keydown=${i.onUrlInputKeydown}
|
|
2271
2287
|
>
|
|
2272
|
-
<nr-label slot="label">${
|
|
2288
|
+
<nr-label slot="label">${f("URL")}</nr-label>
|
|
2273
2289
|
</nr-input>
|
|
2274
2290
|
</nr-col>
|
|
2275
2291
|
<nr-col span="4" >
|
|
@@ -2279,7 +2295,7 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2279
2295
|
size="small"
|
|
2280
2296
|
?disabled=${t.isLoading}
|
|
2281
2297
|
@click=${i.onAttachFile}
|
|
2282
|
-
title="${
|
|
2298
|
+
title="${f("Load file from URL")}"
|
|
2283
2299
|
style="margin-left: 0.5rem;"
|
|
2284
2300
|
>
|
|
2285
2301
|
</nr-button>
|
|
@@ -2301,7 +2317,7 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2301
2317
|
type="success"
|
|
2302
2318
|
style="margin-top: 1rem;"
|
|
2303
2319
|
>
|
|
2304
|
-
${
|
|
2320
|
+
${f("Selected file")}: ${t.selectedFileName}
|
|
2305
2321
|
</nr-alert>
|
|
2306
2322
|
`:e}
|
|
2307
2323
|
|
|
@@ -2310,7 +2326,7 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2310
2326
|
type="info"
|
|
2311
2327
|
style="margin-top: 1rem;"
|
|
2312
2328
|
>
|
|
2313
|
-
${
|
|
2329
|
+
${f("Loading file from URL...")}
|
|
2314
2330
|
</nr-alert>
|
|
2315
2331
|
`:e}
|
|
2316
2332
|
</div>
|
|
@@ -2322,7 +2338,7 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2322
2338
|
?disabled=${t.isLoading}
|
|
2323
2339
|
@click=${i.onClose}
|
|
2324
2340
|
>
|
|
2325
|
-
${
|
|
2341
|
+
${f("Cancel")}
|
|
2326
2342
|
</nr-button>
|
|
2327
2343
|
<nr-button
|
|
2328
2344
|
type="primary"
|
|
@@ -2331,7 +2347,7 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2331
2347
|
?loading=${t.isLoading}
|
|
2332
2348
|
@click=${i.onConfirm}
|
|
2333
2349
|
>
|
|
2334
|
-
${
|
|
2350
|
+
${f("Add")}
|
|
2335
2351
|
</nr-button>
|
|
2336
2352
|
</div>
|
|
2337
2353
|
</nr-modal>
|
|
@@ -2344,7 +2360,7 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2344
2360
|
* @license
|
|
2345
2361
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2346
2362
|
* SPDX-License-Identifier: MIT
|
|
2347
|
-
*/var pt=function(t,e,n,i){for(var o,r=arguments.length,s=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i,a=t.length-1;a>=0;a--)(o=t[a])&&(s=(r<3?o(s):r>3?o(e,n,s):o(e,n))||s);return r>3&&s&&Object.defineProperty(e,n,s),s},ft=function(t,e,n,i){return new(n||(n=Promise))(function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((i=i.apply(t,e||[])).next())})};let vt=class extends(c(i)){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=N.Medium,this.variant=L.Default,this.loadingIndicator=F.Dots,this.loadingText=v("Agent is working..."),this.disabled=!1,this.placeholder=v("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=v("Select Modules"),this.enableArtifacts=!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.controllerUnsubscribes=[],this._artifactResizeBound=!1,this.toggleThreadSidebar=()=>{this.isThreadSidebarOpen=!this.isThreadSidebarOpen}}get moduleSelectOptions(){return this.modules.map(t=>({value:t.id,label:t.name,icon:t.icon,disabled:!1===t.enabled,description:t.description}))}connectedCallback(){super.connectedCallback(),this.controller&&this.setupControllerIntegration(),this.setupUrlSync()}firstUpdated(){var t,e,n,i;null===(t=this.shadowRoot)||void 0===t||t.addEventListener("click",t=>{var e,n;const i=null===(n=(e=t.target).closest)||void 0===n?void 0:n.call(e,"[data-artifact-id]");if(i){const t=i.dataset.artifactId;t&&this.handleArtifactClick(t)}}),null===(e=this.shadowRoot)||void 0===e||e.addEventListener("nr-thread-edit",t=>{const e=t.detail;(null==e?void 0:e.threadId)&&(this._editingThreadId=e.threadId,this.requestUpdate(),this.updateComplete.then(()=>{var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".thread-item__rename-input");e&&(e.focus(),e.select())}))}),null===(n=this.shadowRoot)||void 0===n||n.addEventListener("click",t=>{var e,n;const i=null===(n=(e=t.target).closest)||void 0===n?void 0:n.call(e,"[data-selection-value]");if(i){const t=i.dataset.selectionValue;t&&this.controller&&this.controller.sendMessage(t)}}),null===(i=this.shadowRoot)||void 0===i||i.addEventListener("keydown",t=>{var e,n,i,o;const r=t;if("Enter"!==r.key&&" "!==r.key)return;const s=null===(n=(e=r.target).closest)||void 0===n?void 0:n.call(e,"[data-artifact-id]");if(s){r.preventDefault();const t=s.dataset.artifactId;return void(t&&this.handleArtifactClick(t))}const a=null===(o=(i=r.target).closest)||void 0===o?void 0:o.call(i,"[data-selection-value]");if(a){r.preventDefault();const t=a.dataset.selectionValue;t&&this.controller&&this.controller.sendMessage(t)}})}disconnectedCallback(){var t;super.disconnectedCallback(),this.controller&&this.cleanupControllerIntegration(),this.teardownUrlSync(),null===(t=this._artifactResizeCleanup)||void 0===t||t.call(this),this._artifactResizeBound=!1}updated(t){if(super.updated(t),t.has("controller")&&(this.cleanupControllerIntegration(),this.controller)){this.setupControllerIntegration();try{const t=this.controller.getState();this.handleControllerStateChange(t)}catch(t){}this.enableUrlSync&&this.handleHashChange()}if(t.has("enableUrlSync")&&(this.enableUrlSync?this.setupUrlSync():this.teardownUrlSync()),this.controller&&!t.has("controller")){if(t.has("messages")||t.has("suggestions")||t.has("threads"))try{const t=this.controller.getState();this.handleControllerStateChange(t)}catch(t){}}t.has("messages")&&this.autoScroll&&this.messages.length>0&&this.scrollToLatestMessage(),this.updateArtifactPanelResize()}scrollToLatestMessage(){requestAnimationFrame(()=>{var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".messages");e&&(e.scrollTop=e.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(t=>{try{t()}catch(t){}})}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 t=window.location.hash.match(/^#conversation\/(.+)$/);if(t){const e=decodeURIComponent(t[1]);e!==this.activeThreadId&&this.controller&&this.controller.switchThread(e)}}handleControllerStateChange(t){var e,n,i,o,r;if(t.messages&&(this.messages=t.messages),t.threads&&(this.threads=t.threads),t.suggestions&&t.suggestions.length>0&&(this.suggestions=t.suggestions),t.currentThreadId&&(this.activeThreadId=t.currentThreadId),this.enableUrlSync&&t.currentThreadId){const e=`#conversation/${encodeURIComponent(t.currentThreadId)}`;window.location.hash!==e&&history.replaceState(null,"",e)}if(this.chatStarted=(null===(e=t.messages)||void 0===e?void 0:e.length)>0,this.isBotTyping=t.isTyping||!1,this.statusText=t.statusText,this.isQueryRunning=t.isProcessing||!1,t.uploadedFiles&&(this.uploadedFiles=t.uploadedFiles),this.enableArtifacts){const e=null===(n=t.messages)||void 0===n?void 0:n.some(t=>{var e,n;return(null===(n=null===(e=t.metadata)||void 0===e?void 0:e.artifactIds)||void 0===n?void 0:n.length)>0});e||(this.isArtifactPanelOpen=!1,this.selectedArtifact=null)}if(this.enableArtifacts&&(null===(i=t.messages)||void 0===i?void 0:i.length)){const e=[...t.messages].reverse().find(t=>"bot"===t.sender),n=null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.artifactIds;if(null==n?void 0:n.length){const t=n[n.length-1];if((null===(r=this.selectedArtifact)||void 0===r?void 0:r.id)!==t){const e=this.getArtifactPlugin(),n=null==e?void 0:e.getArtifact(t);n&&(this.selectedArtifact=n,this.isArtifactPanelOpen=!0)}}}}handleControllerMessageSent(t){this.isQueryRunning=!0,this.isBotTyping=!0}handleControllerMessageReceived(t){}handleControllerError(t){this.isQueryRunning=!1,this.isBotTyping=!1,console.error("Controller error:",t.error)}render(){var t;const e={boxed:this.boxed,showMessages:this.showMessages,messages:this.messages,isTyping:this.isBotTyping,loadingIndicator:this.loadingIndicator,loadingText:this.statusText||this.loadingText,chatStarted:this.chatStarted,suggestions:this.suggestions,inputBox:{placeholder:this.placeholder,disabled:this.disabled||this.isQueryRunning,currentInput:this.currentInput,uploadedFiles:this.uploadedFiles,isQueryRunning:this.isQueryRunning,showSendButton:this.showSendButton,enableFileUpload:this.enableFileUpload,fileUploadItems:[{id:"upload-file",label:"Upload File",icon:"upload"},{id:"upload-url",label:"Upload from URL",icon:"link"}],enableModuleSelection:this.enableModuleSelection,moduleOptions:this.moduleSelectOptions,selectedModules:this.selectedModules,moduleSelectionLabel:this.moduleSelectionLabel,renderModuleDisplay:this.renderModuleSelectedDisplay.bind(this)},enableThreads:this.showThreads,enableThreadCreation:this.enableThreadCreation,isThreadSidebarOpen:this.showThreads&&this.isThreadSidebarOpen,threadSidebar:this.showThreads?{threads:this.threads,activeThreadId:this.activeThreadId,editingThreadId:this._editingThreadId}:void 0,isDragging:!1,enableArtifacts:this.enableArtifacts,artifactPanel:this.enableArtifacts?{artifact:this.selectedArtifact,isOpen:this.isArtifactPanelOpen,renderContent:null!==(t=this.renderArtifactContent)&&void 0!==t?t:this.getPluginArtifactRenderer()}:void 0,urlModal:this.isUrlModalOpen?{isOpen:this.isUrlModalOpen,urlInput:this.urlInput,isLoading:this.isUrlLoading,error:this.urlModalError,selectedFileName:this.selectedUrlFileName}:void 0},i={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)},threadSidebar:this.showThreads?{onCreateNew:()=>{var t;null===(t=this.controller)||void 0===t||t.createThread("New Chat")},onSelectThread:t=>{var e;this.enableUrlSync&&history.pushState(null,"",`#conversation/${encodeURIComponent(t)}`),null===(e=this.controller)||void 0===e||e.switchThread(t)},onDeleteThread:t=>{var e;null===(e=this.controller)||void 0===e||e.deleteThread(t)},onBookmarkThread:t=>{var e;null===(e=this.controller)||void 0===e||e.bookmarkThread(t)},onRenameThread:(t,e)=>{var n;null===(n=this.controller)||void 0===n||n.renameThread(t,e),this._editingThreadId=void 0}}:void 0,fileUploadArea:{onDrop:()=>{},onDragOver:()=>{},onDragLeave:()=>{}},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 n`
|
|
2363
|
+
*/var xt=function(t,e,n,i){for(var o,s=arguments.length,r=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i,a=t.length-1;a>=0;a--)(o=t[a])&&(r=(s<3?o(r):s>3?o(e,n,r):o(e,n))||r);return s>3&&r&&Object.defineProperty(e,n,r),r},wt=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};let _t=class extends((t=>N(D(L(W(t)))))(i)){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=V.Medium,this.variant=G.Default,this.loadingIndicator=q.Dots,this.loadingText=f("Agent is working..."),this.disabled=!1,this.placeholder=f("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=f("Select Modules"),this.enableArtifacts=!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.controllerUnsubscribes=[],this._artifactResizeBound=!1,this.toggleThreadSidebar=()=>{this.isThreadSidebarOpen=!this.isThreadSidebarOpen}}get moduleSelectOptions(){return this.modules.map(t=>({value:t.id,label:t.name,icon:t.icon,disabled:!1===t.enabled,description:t.description}))}connectedCallback(){super.connectedCallback(),this.controller&&this.setupControllerIntegration(),this.setupUrlSync()}firstUpdated(){var t,e,n,i;null===(t=this.shadowRoot)||void 0===t||t.addEventListener("click",t=>{var e,n;const i=null===(n=(e=t.target).closest)||void 0===n?void 0:n.call(e,"[data-artifact-id]");if(i){const t=i.dataset.artifactId;t&&this.handleArtifactClick(t)}}),null===(e=this.shadowRoot)||void 0===e||e.addEventListener("nr-thread-edit",t=>{const e=t.detail;(null==e?void 0:e.threadId)&&(this._editingThreadId=e.threadId,this.requestUpdate(),this.updateComplete.then(()=>{var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".thread-item__rename-input");e&&(e.focus(),e.select())}))}),null===(n=this.shadowRoot)||void 0===n||n.addEventListener("click",t=>{var e,n;const i=null===(n=(e=t.target).closest)||void 0===n?void 0:n.call(e,"[data-selection-value]");if(i){const t=i.dataset.selectionValue;t&&this.controller&&this.controller.sendMessage(t)}}),null===(i=this.shadowRoot)||void 0===i||i.addEventListener("keydown",t=>{var e,n,i,o;const s=t;if("Enter"!==s.key&&" "!==s.key)return;const r=null===(n=(e=s.target).closest)||void 0===n?void 0:n.call(e,"[data-artifact-id]");if(r){s.preventDefault();const t=r.dataset.artifactId;return void(t&&this.handleArtifactClick(t))}const a=null===(o=(i=s.target).closest)||void 0===o?void 0:o.call(i,"[data-selection-value]");if(a){s.preventDefault();const t=a.dataset.selectionValue;t&&this.controller&&this.controller.sendMessage(t)}})}disconnectedCallback(){var t;super.disconnectedCallback(),this.controller&&this.cleanupControllerIntegration(),this.teardownUrlSync(),null===(t=this._artifactResizeCleanup)||void 0===t||t.call(this),this._artifactResizeBound=!1}updated(t){if(super.updated(t),t.has("controller")&&(this.cleanupControllerIntegration(),this.controller)){this.setupControllerIntegration();try{const t=this.controller.getState();this.handleControllerStateChange(t)}catch(t){}this.enableUrlSync&&this.handleHashChange()}if(t.has("enableUrlSync")&&(this.enableUrlSync?this.setupUrlSync():this.teardownUrlSync()),this.controller&&!t.has("controller")){if(t.has("messages")||t.has("suggestions")||t.has("threads"))try{const t=this.controller.getState();this.handleControllerStateChange(t)}catch(t){}}t.has("messages")&&this.autoScroll&&this.messages.length>0&&this.scrollToLatestMessage(),this.updateArtifactPanelResize()}scrollToLatestMessage(){requestAnimationFrame(()=>{var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".messages");e&&(e.scrollTop=e.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(t=>{try{t()}catch(t){}})}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 t=window.location.hash.match(/^#conversation\/(.+)$/);if(t){const e=decodeURIComponent(t[1]);e!==this.activeThreadId&&this.controller&&this.controller.switchThread(e)}}handleControllerStateChange(t){var e,n,i,o,s;if(t.messages&&(this.messages=t.messages),t.threads&&(this.threads=t.threads),t.suggestions&&t.suggestions.length>0&&(this.suggestions=t.suggestions),t.currentThreadId&&(this.activeThreadId=t.currentThreadId),this.enableUrlSync&&t.currentThreadId){const e=`#conversation/${encodeURIComponent(t.currentThreadId)}`;window.location.hash!==e&&history.replaceState(null,"",e)}if(this.chatStarted=(null===(e=t.messages)||void 0===e?void 0:e.length)>0,this.isBotTyping=t.isTyping||!1,this.statusText=t.statusText,this.isQueryRunning=t.isProcessing||!1,t.uploadedFiles&&(this.uploadedFiles=t.uploadedFiles),this.enableArtifacts){const e=null===(n=t.messages)||void 0===n?void 0:n.some(t=>{var e,n;return(null===(n=null===(e=t.metadata)||void 0===e?void 0:e.artifactIds)||void 0===n?void 0:n.length)>0});e||(this.isArtifactPanelOpen=!1,this.selectedArtifact=null)}if(this.enableArtifacts&&(null===(i=t.messages)||void 0===i?void 0:i.length)){const e=[...t.messages].reverse().find(t=>"bot"===t.sender),n=null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.artifactIds;if(null==n?void 0:n.length){const t=n[n.length-1];if((null===(s=this.selectedArtifact)||void 0===s?void 0:s.id)!==t){const e=this.getArtifactPlugin(),n=null==e?void 0:e.getArtifact(t);n&&(this.selectedArtifact=n,this.isArtifactPanelOpen=!0)}}}}handleControllerMessageSent(t){this.isQueryRunning=!0,this.isBotTyping=!0}handleControllerMessageReceived(t){}handleControllerError(t){this.isQueryRunning=!1,this.isBotTyping=!1,console.error("Controller error:",t.error)}render(){var t;const e={boxed:this.boxed,showMessages:this.showMessages,messages:this.messages,isTyping:this.isBotTyping,loadingIndicator:this.loadingIndicator,loadingText:this.statusText||this.loadingText,chatStarted:this.chatStarted,suggestions:this.suggestions,inputBox:{placeholder:this.placeholder,disabled:this.disabled||this.isQueryRunning,currentInput:this.currentInput,uploadedFiles:this.uploadedFiles,isQueryRunning:this.isQueryRunning,showSendButton:this.showSendButton,enableFileUpload:this.enableFileUpload,fileUploadItems:[{id:"upload-file",label:"Upload File",icon:"upload"},{id:"upload-url",label:"Upload from URL",icon:"link"}],enableModuleSelection:this.enableModuleSelection,moduleOptions:this.moduleSelectOptions,selectedModules:this.selectedModules,moduleSelectionLabel:this.moduleSelectionLabel,renderModuleDisplay:this.renderModuleSelectedDisplay.bind(this)},enableThreads:this.showThreads,enableThreadCreation:this.enableThreadCreation,isThreadSidebarOpen:this.showThreads&&this.isThreadSidebarOpen,threadSidebar:this.showThreads?{threads:this.threads,activeThreadId:this.activeThreadId,editingThreadId:this._editingThreadId}:void 0,isDragging:!1,enableArtifacts:this.enableArtifacts,artifactPanel:this.enableArtifacts?{artifact:this.selectedArtifact,isOpen:this.isArtifactPanelOpen,renderContent:null!==(t=this.renderArtifactContent)&&void 0!==t?t:this.getPluginArtifactRenderer()}:void 0,urlModal:this.isUrlModalOpen?{isOpen:this.isUrlModalOpen,urlInput:this.urlInput,isLoading:this.isUrlLoading,error:this.urlModalError,selectedFileName:this.selectedUrlFileName}:void 0},i={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)},threadSidebar:this.showThreads?{onCreateNew:()=>{var t;null===(t=this.controller)||void 0===t||t.createThread("New Chat")},onSelectThread:t=>{var e;this.enableUrlSync&&history.pushState(null,"",`#conversation/${encodeURIComponent(t)}`),null===(e=this.controller)||void 0===e||e.switchThread(t)},onDeleteThread:t=>{var e;null===(e=this.controller)||void 0===e||e.deleteThread(t)},onBookmarkThread:t=>{var e;null===(e=this.controller)||void 0===e||e.bookmarkThread(t)},onRenameThread:(t,e)=>{var n;null===(n=this.controller)||void 0===n||n.renameThread(t,e),this._editingThreadId=void 0}}:void 0,fileUploadArea:{onDrop:()=>{},onDragOver:()=>{},onDragLeave:()=>{}},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 n`
|
|
2348
2364
|
<div
|
|
2349
2365
|
class="chat-container ${a({"chat-container--with-threads":this.showThreads,"chat-container--disabled":this.disabled,"chat-container--focused":this.focused,"chat-container--boxed":this.boxed})}"
|
|
2350
2366
|
dir=${this.isRTL?"rtl":"ltr"}
|
|
@@ -2354,10 +2370,10 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2354
2370
|
data-mode="${this.mode}"
|
|
2355
2371
|
part="chat-container">
|
|
2356
2372
|
|
|
2357
|
-
${
|
|
2373
|
+
${yt(e,i)}
|
|
2358
2374
|
</div>
|
|
2359
2375
|
|
|
2360
|
-
${
|
|
2376
|
+
${mt({isOpen:this.isFilePreviewModalOpen,file:this.previewFile},{onClose:this.handleFilePreviewModalClose.bind(this)})}
|
|
2361
2377
|
`}renderModuleSelectedDisplay(){const t=this.selectedModules.length;if(0===t)return n`<span class="module-display-placeholder">${this.moduleSelectionLabel}</span>`;if(1===t){const t=this.modules.find(t=>t.id===this.selectedModules[0]);return n`
|
|
2362
2378
|
<span class="module-display-single">
|
|
2363
2379
|
${(null==t?void 0:t.icon)?n`<nr-icon name="${t.icon}" size="small"></nr-icon>`:e}
|
|
@@ -2365,163 +2381,163 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
|
|
|
2365
2381
|
</span>
|
|
2366
2382
|
`}return n`
|
|
2367
2383
|
<span class="module-display-multiple">
|
|
2368
|
-
${t} ${
|
|
2384
|
+
${t} ${f("modules selected")}
|
|
2369
2385
|
</span>
|
|
2370
|
-
`}handleContentEditableInput(t){const e=t.target.textContent||"";this.currentInput=e,this.dispatchEventWithMetadata("nr-chatbot-input-changed",{metadata:{value:e}})}handleInputFocus(t){this.focused=!0,this.dispatchEventWithMetadata("nr-chatbot-input-focused",{metadata:{event:t}})}handleInputBlur(t){this.focused=!1,this.dispatchEventWithMetadata("nr-chatbot-input-blurred",{metadata:{event:t}})}clearInput(){var t;this.currentInput="";const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".input-box__input");e&&(e.textContent="")}focusInput(){var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".input-box__input");e&&e.focus()}handleKeyDown(t){"Enter"!==t.key||t.shiftKey||(t.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 t=this.uploadedFiles&&this.uploadedFiles.length>0?[...this.uploadedFiles]:void 0;this.controller.sendMessage(this.currentInput.trim(),{files:t,metadata:{selectedModules:this.selectedModules}}),this.clearInput(),this.chatStarted=!0,this.dispatchEventWithMetadata("nr-chatbot-message-sent",{metadata:{text:this.currentInput}})}handleStopQuery(){var t;try{null===(t=this.controller)||void 0===t||t.stop()}catch(t){console.warn("nr-chatbot: stop failed",t)}this.dispatchEventWithMetadata("nr-chatbot-query-stopped",{metadata:{action:"stop"}})}handleRetry(t){t.text&&(this.currentInput=t.text,this.handleSendMessage())}handleCopyMessage(t){const e=t.text;if(!e)return;const n=()=>{this.dispatchEventWithMetadata("nr-chatbot-message-copied",{metadata:{messageId:t.id}})};navigator.clipboard?navigator.clipboard.writeText(e).then(n).catch(()=>{this.copyViaFallback(e,n)}):this.copyViaFallback(e,n)}copyViaFallback(t,e){const n=document.createElement("textarea");n.value=t,n.style.position="fixed",n.style.left="-9999px",n.style.top="-9999px",document.body.appendChild(n),n.focus(),n.select();try{document.execCommand("copy"),e()}catch(t){}n.remove()}handleSuggestionClick(t){this.currentInput=t.text,this.handleSendMessage(),this.dispatchEventWithMetadata("nr-chatbot-suggestion-clicked",{metadata:{suggestion:t}})}handleModuleSelectionChange(t){const e=t.detail.value;this.selectedModules=e,this.dispatchEventWithMetadata("nr-chatbot-modules-selected",{metadata:{modules:e}})}handleFileDropdownClick(t){const e=t.detail.item.id;"upload-file"===e?this.openFileDialog():"upload-url"===e&&this.openUrlModal()}openFileDialog(){const t=document.createElement("input");t.type="file",t.multiple=!0,t.accept="image/*,application/pdf,text/*,video/*,audio/*",t.addEventListener("change",t=>
|
|
2386
|
+
`}handleContentEditableInput(t){const e=t.target.textContent||"";this.currentInput=e,this.dispatchEventWithMetadata("nr-chatbot-input-changed",{metadata:{value:e}})}handleInputFocus(t){this.focused=!0,this.dispatchEventWithMetadata("nr-chatbot-input-focused",{metadata:{event:t}})}handleInputBlur(t){this.focused=!1,this.dispatchEventWithMetadata("nr-chatbot-input-blurred",{metadata:{event:t}})}clearInput(){var t;this.currentInput="";const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".input-box__input");e&&(e.textContent="")}focusInput(){var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".input-box__input");e&&e.focus()}handleKeyDown(t){"Enter"!==t.key||t.shiftKey||(t.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 t=this.uploadedFiles&&this.uploadedFiles.length>0?[...this.uploadedFiles]:void 0;this.controller.sendMessage(this.currentInput.trim(),{files:t,metadata:{selectedModules:this.selectedModules}}),this.clearInput(),this.chatStarted=!0,this.dispatchEventWithMetadata("nr-chatbot-message-sent",{metadata:{text:this.currentInput}})}handleStopQuery(){var t;try{null===(t=this.controller)||void 0===t||t.stop()}catch(t){console.warn("nr-chatbot: stop failed",t)}this.dispatchEventWithMetadata("nr-chatbot-query-stopped",{metadata:{action:"stop"}})}handleRetry(t){t.text&&(this.currentInput=t.text,this.handleSendMessage())}handleCopyMessage(t){const e=t.text;if(!e)return;const n=()=>{this.dispatchEventWithMetadata("nr-chatbot-message-copied",{metadata:{messageId:t.id}})};navigator.clipboard?navigator.clipboard.writeText(e).then(n).catch(()=>{this.copyViaFallback(e,n)}):this.copyViaFallback(e,n)}copyViaFallback(t,e){const n=document.createElement("textarea");n.value=t,n.style.position="fixed",n.style.left="-9999px",n.style.top="-9999px",document.body.appendChild(n),n.focus(),n.select();try{document.execCommand("copy"),e()}catch(t){}n.remove()}handleSuggestionClick(t){this.currentInput=t.text,this.handleSendMessage(),this.dispatchEventWithMetadata("nr-chatbot-suggestion-clicked",{metadata:{suggestion:t}})}handleModuleSelectionChange(t){const e=t.detail.value;this.selectedModules=e,this.dispatchEventWithMetadata("nr-chatbot-modules-selected",{metadata:{modules:e}})}handleFileDropdownClick(t){const e=t.detail.item.id;"upload-file"===e?this.openFileDialog():"upload-url"===e&&this.openUrlModal()}openFileDialog(){const t=document.createElement("input");t.type="file",t.multiple=!0,t.accept="image/*,application/pdf,text/*,video/*,audio/*",t.addEventListener("change",t=>wt(this,void 0,void 0,function*(){var e;const n=t.target;if(n.files&&n.files.length>0){const t=Array.from(n.files);yield null===(e=this.controller)||void 0===e?void 0:e.uploadFiles(t)}})),t.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(t){const e=t.target;this.urlInput=e.value,this.urlModalError=""}handleUrlInputKeydown(t){"Enter"===t.key&&(t.preventDefault(),this.handleUrlAttachFile())}handleUrlConfirm(){this.handleUrlModalClose()}handleUrlAttachFile(){return wt(this,void 0,void 0,function*(){if(this.urlInput.trim()){this.isUrlLoading=!0,this.urlModalError="";try{const t=yield fetch(this.urlInput);if(!t.ok)throw new Error(`Failed to fetch file: ${t.statusText}`);const e=yield t.blob(),n=this.urlInput.split("/").pop()||"downloaded-file",i=new File([e],n,{type:e.type});this.selectedUrlFileName=n,this.controller&&(yield this.controller.uploadFiles([i])),this.isUrlLoading=!1,setTimeout(()=>{this.handleUrlModalClose()},1e3)}catch(t){this.isUrlLoading=!1,this.urlModalError=t instanceof Error?t.message:"Failed to load file from URL"}}else this.urlModalError="Please enter a URL"})}handleFileRemove(t){var e;null===(e=this.controller)||void 0===e||e.removeFile(t)}handleFilePreview(t){this.previewFile=t,this.isFilePreviewModalOpen=!0}handleArtifactClick(t){if(!this.enableArtifacts||!this.controller)return;const e=this.getArtifactPlugin();if(!e)return;const n=e.getArtifact(t);n&&(this.selectedArtifact=n,this.isArtifactPanelOpen=!0)}handleArtifactPanelClose(){this.isArtifactPanelOpen=!1,this.selectedArtifact=null}updateArtifactPanelResize(){var t,e,n;const i=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".artifact-panel__resize-handle"),o=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".artifact-panel");if(!i||!o)return null===(n=this._artifactResizeCleanup)||void 0===n||n.call(this),void(this._artifactResizeBound=!1);if(this._artifactResizeBound)return;this._artifactResizeBound=!0;let s=!1,r=0,a=0;const l=t=>{if(!s)return;const e=t.clientX-r,n=o.parentElement,i=n?.85*n.getBoundingClientRect().width:1200,l=Number.parseInt(getComputedStyle(o).minWidth,10)||300,d=Math.max(l,Math.min(a-e,i));o.style.width=`${d}px`},d=()=>{s&&(s=!1,i.classList.remove("artifact-panel__resize-handle--active"),document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",d))},c=t=>{t.preventDefault(),s=!0,r=t.clientX,a=o.getBoundingClientRect().width,i.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)};i.addEventListener("mousedown",c),this._artifactResizeCleanup=()=>{i.removeEventListener("mousedown",c),d()}}handleArtifactCopy(t){const e=t.content;e&&(navigator.clipboard?navigator.clipboard.writeText(e).catch(()=>{this.copyViaFallback(e,()=>{})}):this.copyViaFallback(e,()=>{}))}getArtifactPlugin(){var t;try{const e=null===(t=this.controller)||void 0===t?void 0:t.plugins;return e&&"function"==typeof e.get?e.get("artifact"):void 0}catch(t){return}}getPluginArtifactRenderer(){var t;try{const e=null===(t=this.controller)||void 0===t?void 0:t.plugins;if(!e||"function"!=typeof e.values)return;for(const t of e.values())if("function"==typeof t.renderArtifactContent)return e=>{const i=t.renderArtifactContent(e);if(i)return n`${l(i)}`};return}catch(t){return}}handleFilePreviewModalClose(){this.isFilePreviewModalOpen=!1,this.previewFile=null}addMessage(t){var e;const n=Object.assign({id:t.id||`msg-${Date.now()}`,sender:t.sender||J.User,text:t.text||"",timestamp:t.timestamp||(new Date).toISOString()},t);return null===(e=this.controller)||void 0===e||e.addMessage(n),this.chatStarted=!0,n}clearMessages(){this.messages=[],this.chatStarted=!1}};_t.useShadowDom=!0,_t.styles=A,xt([o({type:Array})],_t.prototype,"messages",void 0),xt([o({type:String})],_t.prototype,"currentInput",void 0),xt([o({type:Boolean})],_t.prototype,"isBotTyping",void 0),xt([o({type:Boolean})],_t.prototype,"isQueryRunning",void 0),xt([o({type:Array})],_t.prototype,"suggestions",void 0),xt([o({type:Boolean})],_t.prototype,"chatStarted",void 0),xt([o({type:Boolean})],_t.prototype,"isRTL",void 0),xt([o({type:String})],_t.prototype,"size",void 0),xt([o({type:String})],_t.prototype,"variant",void 0),xt([o({type:String})],_t.prototype,"loadingIndicator",void 0),xt([o({type:String})],_t.prototype,"loadingText",void 0),xt([o({type:Boolean})],_t.prototype,"disabled",void 0),xt([o({type:String})],_t.prototype,"placeholder",void 0),xt([o({type:Boolean})],_t.prototype,"showSendButton",void 0),xt([o({type:Boolean})],_t.prototype,"autoScroll",void 0),xt([o({type:Boolean})],_t.prototype,"showThreads",void 0),xt([o({type:Boolean})],_t.prototype,"enableThreadCreation",void 0),xt([o({type:Array})],_t.prototype,"threads",void 0),xt([o({type:String})],_t.prototype,"activeThreadId",void 0),xt([o({type:String})],_t.prototype,"mode",void 0),xt([o({type:Boolean,reflect:!0})],_t.prototype,"boxed",void 0),xt([o({type:Boolean})],_t.prototype,"enableUrlSync",void 0),xt([o({type:Boolean})],_t.prototype,"showMessages",void 0),xt([o({type:Boolean})],_t.prototype,"enableFileUpload",void 0),xt([o({type:Array})],_t.prototype,"uploadedFiles",void 0),xt([o({type:Array})],_t.prototype,"actionButtons",void 0),xt([o({type:Boolean})],_t.prototype,"enableModuleSelection",void 0),xt([o({type:Array})],_t.prototype,"modules",void 0),xt([o({type:Array})],_t.prototype,"selectedModules",void 0),xt([o({type:String})],_t.prototype,"moduleSelectionLabel",void 0),xt([o({type:Boolean})],_t.prototype,"enableArtifacts",void 0),xt([o({type:Function})],_t.prototype,"renderArtifactContent",void 0),xt([o({type:Object})],_t.prototype,"controller",void 0),xt([s()],_t.prototype,"statusText",void 0),xt([s()],_t.prototype,"focused",void 0),xt([s()],_t.prototype,"isArtifactPanelOpen",void 0),xt([s()],_t.prototype,"selectedArtifact",void 0),xt([s()],_t.prototype,"isThreadSidebarOpen",void 0),xt([s()],_t.prototype,"_editingThreadId",void 0),xt([s()],_t.prototype,"isUrlModalOpen",void 0),xt([s()],_t.prototype,"urlInput",void 0),xt([s()],_t.prototype,"urlModalError",void 0),xt([s()],_t.prototype,"isUrlLoading",void 0),xt([s()],_t.prototype,"selectedUrlFileName",void 0),xt([s()],_t.prototype,"isFilePreviewModalOpen",void 0),xt([s()],_t.prototype,"previewFile",void 0),_t=xt([(t,e)=>(t.addInitializer(v),t),r("nr-chatbot")],_t);
|
|
2371
2387
|
/**
|
|
2372
2388
|
* @license
|
|
2373
2389
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2374
2390
|
* SPDX-License-Identifier: MIT
|
|
2375
2391
|
*/
|
|
2376
|
-
class
|
|
2392
|
+
class $t{constructor(){this.listeners=new Map}on(t,e){return this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(e),()=>{var n,i;null===(n=this.listeners.get(t))||void 0===n||n.delete(e),0===(null===(i=this.listeners.get(t))||void 0===i?void 0:i.size)&&this.listeners.delete(t)}}once(t,e){const n=(...i)=>{e(...i),this.off(t,n)};this.on(t,n)}off(t,e){var n;null===(n=this.listeners.get(t))||void 0===n||n.delete(e)}emit(t,e){const n=this.listeners.get(t);n&&n.forEach(n=>{try{n(e)}catch(e){console.error(`Error in event handler for "${t}":`,e)}})}removeAllListeners(t){t?this.listeners.delete(t):this.listeners.clear()}listenerCount(t){var e;return(null===(e=this.listeners.get(t))||void 0===e?void 0:e.size)||0}eventNames(){return Array.from(this.listeners.keys())}}
|
|
2377
2393
|
/**
|
|
2378
2394
|
* @license
|
|
2379
2395
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2380
2396
|
* SPDX-License-Identifier: MIT
|
|
2381
|
-
*/class
|
|
2397
|
+
*/class kt extends Error{constructor(t){super(t.join(", ")),this.errors=t,this.name="ValidationError"}}
|
|
2382
2398
|
/**
|
|
2383
2399
|
* @license
|
|
2384
2400
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2385
2401
|
* SPDX-License-Identifier: MIT
|
|
2386
|
-
*/class
|
|
2402
|
+
*/class St{constructor(t,e,n,i,o){this.eventBus=e,this.ui=n,this.plugins=i,this.config=o,this.state=t}getState(){return Object.freeze(Object.assign({},this.state))}updateState(t){if(this.state=Object.assign(Object.assign({},this.state),t),this.ui.onStateChange)try{this.ui.onStateChange(this.getState())}catch(t){this.logError("Error in UI state change callback:",t)}this.eventBus.emit("state:changed",this.state),this.plugins.forEach(t=>{if(t.onStateChange)try{t.onStateChange(this.getState())}catch(t){this.logError("Error in plugin state change handler:",t)}})}addMessageToState(t){this.state.messages=[...this.state.messages,t],t.suggestions&&t.suggestions.length>0?this.state.suggestions=[...t.suggestions]:this.state.messages.length>1&&(this.state.suggestions=[]),this.config.maxMessages&&this.state.messages.length>this.config.maxMessages&&(this.state.messages=this.state.messages.slice(-this.config.maxMessages)),this.ui.onStateChange&&this.ui.onStateChange(this.getState()),this.eventBus.emit("state:changed",this.state),this.ui.scrollToBottom&&this.ui.scrollToBottom(),this.eventBus.emit("message:added",t)}updateMessageInState(t,e){this.state.messages=this.state.messages.map(n=>n.id===t?Object.assign(Object.assign({},n),e):n),this.ui.onStateChange&&this.ui.onStateChange(this.getState()),this.eventBus.emit("state:changed",this.state);const n=this.state.messages.find(e=>e.id===t);n&&this.eventBus.emit("message:updated",n)}removeMessageFromState(t){this.state.messages=this.state.messages.filter(e=>e.id!==t),this.ui.onStateChange&&this.ui.onStateChange(this.getState()),this.eventBus.emit("state:changed",this.state),this.eventBus.emit("message:deleted",t)}resetState(t){this.state=Object.assign({},t),this.updateState(this.state)}getMessages(){return[...this.state.messages]}getMessageById(t){return this.state.messages.find(e=>e.id===t)}isTyping(){return this.state.isTyping}isProcessing(){return this.state.isProcessing}setTyping(t){this.updateState({isTyping:t}),t&&this.ui.onTypingStart?this.ui.onTypingStart():!t&&this.ui.onTypingEnd&&this.ui.onTypingEnd()}setProcessing(t){this.updateState({isProcessing:t})}logError(t,e){console.error(`[StateHandler] ${t}`,e)}}
|
|
2387
2403
|
/**
|
|
2388
2404
|
* @license
|
|
2389
2405
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2390
2406
|
* SPDX-License-Identifier: MIT
|
|
2391
|
-
*/class
|
|
2407
|
+
*/class Pt{constructor(t,e,n){this.stateHandler=t,this.eventBus=e,this.plugins=n}createMessage(t){return Object.assign({id:this.generateId("msg"),sender:t.sender||"user",text:t.text||"",timestamp:t.timestamp||(new Date).toISOString()},t)}createUserMessage(t,e){return this.createMessage({sender:"user",text:t,metadata:e})}createBotMessage(t,e){return this.createMessage({sender:"bot",text:t,metadata:e})}addMessage(t){const e=this.createMessage(t);return this.stateHandler.addMessageToState(e),"bot"===e.sender?(this.eventBus.emit("message:received",e),this.plugins.forEach(t=>{t.onMessageReceived&&t.onMessageReceived(e)})):(this.eventBus.emit("message:sent",e),this.plugins.forEach(t=>{t.onMessageSent&&t.onMessageSent(e)})),e}updateMessage(t,e){this.stateHandler.updateMessageInState(t,e)}deleteMessage(t){this.stateHandler.removeMessageFromState(t)}clearMessages(){this.stateHandler.updateState({messages:[]})}getMessages(){return this.stateHandler.getMessages()}getMessageById(t){return this.stateHandler.getMessageById(t)}updateBotMessageText(t,e){const n=this.getMessageById(t);n&&"bot"===n.sender&&this.updateMessage(t,{text:e})}appendToBotMessage(t,e){const n=this.getMessageById(t);n&&"bot"===n.sender&&this.updateMessage(t,{text:n.text+e})}generateId(t){return`${t}_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}}
|
|
2392
2408
|
/**
|
|
2393
2409
|
* @license
|
|
2394
2410
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2395
2411
|
* SPDX-License-Identifier: MIT
|
|
2396
|
-
*/var
|
|
2412
|
+
*/var Tt=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class Et{constructor(t,e,n,i,o){this.stateHandler=t,this.eventBus=e,this.ui=n,this.config=i,this.provider=o}setProvider(t){this.provider=t}createThread(t){return Tt(this,void 0,void 0,function*(){if(!this.config.enableThreads)throw new Error("Threads are not enabled");const e=this.stateHandler.getState(),n={id:this.generateId("thread"),title:t||`Chat ${e.threads.length+1}`,messages:[],createdAt:(new Date).toISOString(),updatedAt:(new Date).toISOString()};if(this.provider&&"function"==typeof this.provider.createConversation)try{const t=yield this.provider.createConversation(n.title);t&&t.id&&(n.id=String(t.id),n.conversationId=t.id)}catch(t){console.error("Error calling provider.createConversation:",t)}return this.stateHandler.updateState({threads:[n,...e.threads],currentThreadId:n.id,messages:[]}),this.eventBus.emit("thread:created",n),this.eventBus.emit("thread:selected",n),this.ui.focusInput&&setTimeout(()=>{this.ui.focusInput()},100),n})}switchThread(t){const e=this.stateHandler.getState(),n=e.threads.find(e=>e.id===t);if(!n)throw new Error(`Thread "${t}" not found`);e.currentThreadId&&this.saveCurrentThread(),this.stateHandler.updateState({currentThreadId:t,messages:[...n.messages]}),this.eventBus.emit("thread:selected",n)}bookmarkThread(t){const e=this.stateHandler.getState(),n=e.threads.find(e=>e.id===t);if(!n)throw new Error(`Thread "${t}" not found`);const i=!n.bookmarked,o=e.threads.map(e=>e.id===t?Object.assign(Object.assign({},e),{bookmarked:i}):e);this.stateHandler.updateState({threads:o}),this.eventBus.emit("thread:bookmarked",{threadId:t,bookmarked:i})}renameThread(t,e){const n=this.stateHandler.getState();if(!n.threads.find(e=>e.id===t))throw new Error(`Thread "${t}" not found`);const i=n.threads.map(n=>n.id===t?Object.assign(Object.assign({},n),{title:e,updatedAt:(new Date).toISOString()}):n);this.stateHandler.updateState({threads:i}),this.eventBus.emit("thread:renamed",{threadId:t,title:e})}deleteThread(t){const e=this.stateHandler.getState(),n=e.threads.filter(e=>e.id!==t);e.currentThreadId===t?n.length>0?(this.stateHandler.updateState({threads:n}),this.switchThread(n[0].id)):this.stateHandler.updateState({threads:n,currentThreadId:void 0,messages:[]}):this.stateHandler.updateState({threads:n}),this.eventBus.emit("thread:deleted",t)}getCurrentThread(){const t=this.stateHandler.getState();return t.threads.find(e=>e.id===t.currentThreadId)}getThreads(){return[...this.stateHandler.getState().threads]}saveCurrentThread(){const t=this.stateHandler.getState();t.currentThreadId&&this.updateThreadMessages(t.currentThreadId)}updateThreadMessages(t){const e=this.stateHandler.getState(),n=e.threads.map(n=>n.id===t?Object.assign(Object.assign({},n),{messages:[...e.messages],updatedAt:(new Date).toISOString()}):n);this.stateHandler.updateState({threads:n})}generateId(t){return`${t}_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}}
|
|
2397
2413
|
/**
|
|
2398
2414
|
* @license
|
|
2399
2415
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2400
2416
|
* SPDX-License-Identifier: MIT
|
|
2401
|
-
*/var
|
|
2417
|
+
*/var Mt=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class zt{constructor(t,e){this.stateHandler=t,this.eventBus=e}addFile(t){const e=this.stateHandler.getState();this.stateHandler.updateState({uploadedFiles:[...e.uploadedFiles,t]}),this.eventBus.emit("file:uploaded",t)}removeFile(t){const e=this.stateHandler.getState();this.stateHandler.updateState({uploadedFiles:e.uploadedFiles.filter(e=>e.id!==t)}),this.eventBus.emit("file:removed",t)}clearFiles(){this.stateHandler.updateState({uploadedFiles:[]})}getUploadedFiles(){return[...this.stateHandler.getState().uploadedFiles]}getFileById(t){return this.stateHandler.getState().uploadedFiles.find(e=>e.id===t)}createChatbotFile(t){return Mt(this,void 0,void 0,function*(){return{id:this.generateId("file"),name:t.name,size:t.size,type:this.determineFileType(t.type),mimeType:t.type,uploadProgress:100}})}determineFileType(t){return t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":t.includes("pdf")?"pdf":t.includes("text/")?"text":"document"}generateId(t){return`${t}_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}}
|
|
2402
2418
|
/**
|
|
2403
2419
|
* @license
|
|
2404
2420
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2405
2421
|
* SPDX-License-Identifier: MIT
|
|
2406
|
-
*/class
|
|
2422
|
+
*/class Ct{constructor(t,e){this.stateHandler=t,this.eventBus=e}setModules(t){this.stateHandler.updateState({modules:t})}selectModules(t){this.stateHandler.updateState({selectedModules:t}),this.eventBus.emit("module:selected",t)}toggleModule(t){const e=this.stateHandler.getState(),n=e.selectedModules.includes(t)?e.selectedModules.filter(e=>e!==t):[...e.selectedModules,t];this.selectModules(n)}getSelectedModules(){const t=this.stateHandler.getState();return(t.modules||[]).filter(e=>t.selectedModules.includes(e.id))}clearSelection(){this.stateHandler.updateState({selectedModules:[]})}}
|
|
2407
2423
|
/**
|
|
2408
2424
|
* @license
|
|
2409
2425
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2410
2426
|
* SPDX-License-Identifier: MIT
|
|
2411
|
-
*/class
|
|
2427
|
+
*/class It{constructor(t){this.stateHandler=t}setSuggestions(t){this.stateHandler.updateState({suggestions:t})}clearSuggestions(){this.stateHandler.updateState({suggestions:[]})}getSuggestions(){return[...this.stateHandler.getState().suggestions]}removeSuggestion(t){const e=this.stateHandler.getState();this.stateHandler.updateState({suggestions:e.suggestions.filter(e=>e.id!==t)})}}
|
|
2412
2428
|
/**
|
|
2413
2429
|
* @license
|
|
2414
2430
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2415
2431
|
* SPDX-License-Identifier: MIT
|
|
2416
|
-
*/var
|
|
2432
|
+
*/var Ot=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class Rt{constructor(t,e,n,i,o,s,r){this.stateHandler=e,this.messageHandler=n,this.fileHandler=i,this.eventBus=o,this.ui=s,this.plugins=r,this.cancelRequested=!1,this.provider=t}setProvider(t){this.provider=t}stopCurrentProcessing(){this.cancelRequested=!0,this.eventBus.emit("processing:stopped")}hasProvider(){return!!this.provider&&this.provider.isConnected()}processMessage(t){return Ot(this,void 0,void 0,function*(){if(this.provider){if(!this.provider.isConnected()){this.log("Provider not connected, attempting to connect...");try{yield this.provider.connect({})}catch(t){this.logError("Failed to auto-connect provider:",t)}if(!this.provider.isConnected())return void this.log("Provider is still not connected after attempt; aborting processing")}try{this.cancelRequested=!1,this.ui.onProcessingStart&&this.ui.onProcessingStart(),this.ui.onTypingStart&&this.ui.onTypingStart(),this.stateHandler.setTyping(!0),this.stateHandler.setProcessing(!0),this.eventBus.emit("processing:start");const e=this.buildContext(),n=this.provider.sendMessage(t.text,e);yield this.processStream(n)}catch(t){throw this.logError("Provider error:",t),this.eventBus.emit("error",t),t}finally{this.ui.onProcessingEnd&&this.ui.onProcessingEnd(),this.ui.onTypingEnd&&this.ui.onTypingEnd(),this.stateHandler.updateState({statusText:void 0}),this.stateHandler.setTyping(!1),this.stateHandler.setProcessing(!1),this.eventBus.emit("processing:end"),this.fileHandler.clearFiles()}}else this.log("No provider configured")})}processStream(t){return Ot(this,void 0,void 0,function*(){var e;let n=null;const i=Array.from(this.plugins.values()).filter(t=>Array.isArray(t.htmlTags)),o=[];let s="",r="",a=0;if(i.length>0)for(const t of i)for(const e of t.htmlTags)a=Math.max(a,e.open.length,e.close.length);try{let l=!1;for(;!l&&!this.cancelRequested;){const d=yield t.next();if(l=d.done||!1,l||!d.value)break;const c=String(d.value),h=c.startsWith(r)?c.slice(r.length):c;r=c,s+=h;let u="",p=!1;for(;s.length;){const t=o[o.length-1];if(t){const e=t.buffer+s,i=e.indexOf(t.close);if(-1===i){t.buffer=e,s="";break}const r=e.slice(0,i),a="function"==typeof t.plugin.renderHtmlBlock?t.plugin.renderHtmlBlock(t.name,r):"";if(a)if(t.hasPlaceholder&&n){const t=/<div data-placeholder-id="[^"]*">[\s\S]*?<\/div>/;t.test(n.text)?(n.text=n.text.replace(t,a),this.messageHandler.updateMessage(n.id,{text:n.text})):(u+=a,p=!0)}else u+=a,p=!0;o.pop(),s=e.slice(i+t.close.length);continue}if(0===i.length){u+=s,s="";break}let e=null;for(const t of i)for(const n of t.htmlTags){const i=s.indexOf(n.open);-1!==i&&(!e||i<e.idx)&&(e={idx:i,plugin:t,name:n.name,open:n.open,close:n.close})}if(!e){if(a>0&&s.length>a-1){const t=s.length-(a-1);u+=s.slice(0,t),s=s.slice(t)}break}{u+=s.slice(0,e.idx);let t=!1;if("function"==typeof e.plugin.renderHtmlBlockPlaceholder){const n=e.plugin.renderHtmlBlockPlaceholder(e.name);n&&(u+=n,p=!0,t=!0)}o.push({plugin:e.plugin,name:e.name,open:e.open,close:e.close,buffer:"",hasPlaceholder:t}),s=s.slice(e.idx+e.open.length)}}if(u)for(const t of this.plugins.values()){!(Array.isArray(t.htmlTags)&&t.htmlTags.length>0)&&t.afterReceive&&(u=yield t.afterReceive(u))}const f=p||/<\w+[^>]*>/.test(u);n?u&&(this.messageHandler.appendToBotMessage(n.id,u),n.text+=u,f&&!(null===(e=n.metadata)||void 0===e?void 0:e.renderAsHtml)&&this.messageHandler.updateMessage(n.id,{metadata:Object.assign(Object.assign({},n.metadata||{}),{renderAsHtml:!0})})):(n=this.messageHandler.createBotMessage(u,f?{renderAsHtml:!0}:void 0),this.stateHandler.addMessageToState(n),this.ui.onTypingEnd&&this.ui.onTypingEnd(),this.stateHandler.setTyping(!1))}if(!this.cancelRequested&&n&&(s&&this.messageHandler.appendToBotMessage(n.id,s),o.length>0)){const t=o.map(t=>t.open+t.buffer).join("");t&&this.messageHandler.appendToBotMessage(n.id,t)}}catch(t){throw this.logError("Error processing stream:",t),t}})}buildContext(){const t=this.stateHandler.getState(),e=t.currentThreadId?t.threads.find(e=>e.id===t.currentThreadId):void 0;return console.log("[ProviderService] buildContext state.uploadedFiles:",t.uploadedFiles),{messages:t.messages,metadata:t.metadata,selectedModules:t.selectedModules,currentThread:e,uploadedFiles:t.uploadedFiles}}uploadFileToProvider(t){return Ot(this,void 0,void 0,function*(){var e,n;if(!(null===(n=null===(e=this.provider)||void 0===e?void 0:e.capabilities)||void 0===n?void 0:n.fileUpload)||!this.provider.uploadFile)throw new Error("Provider does not support file upload");const i=this.buildContext();return yield this.provider.uploadFile(t,i)})}getCapabilities(){var t;return(null===(t=this.provider)||void 0===t?void 0:t.capabilities)||{streaming:!1,fileUpload:!1,contextWindow:0}}log(t,...e){console.log(`[ProviderService] ${t}`,...e)}logError(t,e){console.error(`[ProviderService] ${t}`,e)}}
|
|
2417
2433
|
/**
|
|
2418
2434
|
* @license
|
|
2419
2435
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2420
2436
|
* SPDX-License-Identifier: MIT
|
|
2421
|
-
*/var
|
|
2437
|
+
*/var jt=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class At{constructor(t){this.validators=[],this.validators=t.validators||[]}validateMessage(t){return jt(this,void 0,void 0,function*(){const e=[],n=[];t.trim()||e.push("Message cannot be empty");for(const i of this.validators)try{(yield i.validator(t))||(e.push(i.errorMessage),i.warningMessage&&n.push(i.warningMessage))}catch(t){this.logError("Validation error:",t),e.push("Validation failed")}return{isValid:0===e.length,errors:e,warnings:n}})}validateFile(t,e){const n=[],i=(null==e?void 0:e.maxFileSize)||10485760;if(t.size>i&&n.push(`File size exceeds maximum allowed (${this.formatFileSize(i)})`),(null==e?void 0:e.allowedTypes)&&e.allowedTypes.length>0){e.allowedTypes.some(e=>e.startsWith(".")?t.name.toLowerCase().endsWith(e.toLowerCase()):t.type.includes(e))||n.push(`File type not allowed. Allowed types: ${e.allowedTypes.join(", ")}`)}return{isValid:0===n.length,errors:n,warnings:[]}}addValidator(t){this.validators.push(t)}removeValidator(t){this.validators=this.validators.filter(e=>e.id!==t)}clearValidators(){this.validators=[]}getValidators(){return[...this.validators]}formatFileSize(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(1024));return Math.round(t/Math.pow(1024,e)*100)/100+" "+["Bytes","KB","MB","GB"][e]}logError(t,e){console.error(`[ValidationService] ${t}`,e)}}
|
|
2422
2438
|
/**
|
|
2423
2439
|
* @license
|
|
2424
2440
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2425
2441
|
* SPDX-License-Identifier: MIT
|
|
2426
|
-
*/var
|
|
2442
|
+
*/var Dt=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class Ft{constructor(t,e,n){this.stateHandler=e,this.config=n,this.storage=t,this.setupAutoSave()}setStorage(t){this.storage=t,this.setupAutoSave()}saveState(){return Dt(this,arguments,void 0,function*(t="chatbot-state"){if(!this.storage)throw new Error("No storage configured");try{const e=this.stateHandler.getState();yield this.storage.save(t,e),this.log("State saved to storage")}catch(t){throw this.logError("Error saving to storage:",t),t}})}loadState(){return Dt(this,arguments,void 0,function*(t="chatbot-state"){if(!this.storage)throw new Error("No storage configured");try{const e=yield this.storage.load(t);e&&(this.stateHandler.updateState(e),this.log("State loaded from storage"))}catch(t){throw this.logError("Error loading from storage:",t),t}})}clearStorage(){return Dt(this,void 0,void 0,function*(){if(!this.storage)throw new Error("No storage configured");try{yield this.storage.clear(),this.log("Storage cleared")}catch(t){throw this.logError("Error clearing storage:",t),t}})}setupAutoSave(){this.autoSaveTimer&&clearInterval(this.autoSaveTimer),this.config.autoSaveInterval&&this.storage&&(this.autoSaveTimer=setInterval(()=>{this.saveState().catch(t=>{this.logError("Auto-save failed:",t)})},this.config.autoSaveInterval))}stopAutoSave(){this.autoSaveTimer&&(clearInterval(this.autoSaveTimer),this.autoSaveTimer=void 0)}startAutoSave(t){this.config.autoSaveInterval=t,this.setupAutoSave()}hasStorage(){return!!this.storage}destroy(){this.stopAutoSave()}log(t){console.log(`[StorageService] ${t}`)}logError(t,e){console.error(`[StorageService] ${t}`,e)}}
|
|
2427
2443
|
/**
|
|
2428
2444
|
* @license
|
|
2429
2445
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2430
2446
|
* SPDX-License-Identifier: MIT
|
|
2431
|
-
*/var
|
|
2447
|
+
*/var Nt=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class Lt{constructor(t){this.plugins=new Map,t&&t.forEach(t=>this.registerPlugin(t))}registerPlugin(t,e){if(this.plugins.has(t.id))this.log(`Plugin "${t.id}" is already registered, skipping`);else if(this.plugins.set(t.id,t),this.log(`Registered plugin: ${t.name} v${t.version}`),t.onInit&&e)try{t.onInit(e)}catch(e){this.logError(`Error initializing plugin "${t.id}":`,e)}}unregisterPlugin(t){const e=this.plugins.get(t);if(e&&e.onDestroy)try{e.onDestroy()}catch(e){this.logError(`Error destroying plugin "${t}":`,e)}this.plugins.delete(t),this.log(`Unregistered plugin: ${t}`)}getPlugin(t){return this.plugins.get(t)}getAllPlugins(){return Array.from(this.plugins.values())}hasPlugin(t){return this.plugins.has(t)}getPluginsMap(){return this.plugins}executeHook(t,...e){return Nt(this,void 0,void 0,function*(){for(const n of this.plugins.values()){const i=n[t];if("function"==typeof i)try{yield i(...e)}catch(e){this.logError(`Error executing hook "${String(t)}" on plugin "${n.id}":`,e)}}})}clearPlugins(){this.plugins.forEach((t,e)=>{this.unregisterPlugin(e)}),this.plugins.clear()}getPluginCount(){return this.plugins.size}log(t){console.log(`[PluginService] ${t}`)}logError(t,e){console.error(`[PluginService] ${t}`,e)}}const Bt=["ar","fr"],Ut="__nuraly_localization__";!function(){if(globalThis[Ut])return globalThis[Ut];const t=O({sourceLocale:"en",targetLocales:Bt,loadLocale:t=>import(`../../locales/generated/${t}.js`)});globalThis[Ut]=t}();
|
|
2432
2448
|
/**
|
|
2433
2449
|
* @license
|
|
2434
2450
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2435
2451
|
* SPDX-License-Identifier: MIT
|
|
2436
2452
|
*/
|
|
2437
|
-
var At=function(t,e,n,i){return new(n||(n=Promise))(function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((i=i.apply(t,e||[])).next())})};class Dt{constructor(t={}){this.plugins=new Map,this.config=t,this.ui=t.ui||{},this.eventBus=new gt,this.pluginService=new Ot,this.plugins=this.pluginService.getPluginsMap(),t.plugins&&t.plugins.forEach(t=>this.pluginService.registerPlugin(t,this));const e=this.initializeState(t);if(this.stateHandler=new bt(e,this.eventBus,this.ui,this.plugins,this.config),this.messageHandler=new yt(this.stateHandler,this.eventBus,this.plugins),this.threadHandler=new wt(this.stateHandler,this.eventBus,this.ui,this.config,t.provider),this.fileHandler=new $t(this.stateHandler,this.eventBus),this.moduleHandler=new kt(this.stateHandler,this.eventBus),this.suggestionHandler=new St(this.stateHandler),this.providerService=new Pt(t.provider,this.stateHandler,this.messageHandler,this.fileHandler,this.eventBus,this.ui,this.plugins),this.validationService=new Mt(this.config),this.storageService=new Ct(t.storage,this.stateHandler,this.config),t.provider){const e=t.provider;queueMicrotask(()=>{this.initializeProvider(e)})}this.setupLifecycleHooks()}initializeProvider(t){return At(this,void 0,void 0,function*(){try{t.isConnected()||(yield t.connect({})),yield this.autoLoadConversations(t)}catch(t){this.logError("Failed to connect provider:",t)}})}initializeState(t){const e=t.initialMessages?t.initialMessages.map(t=>this.processMessageThroughPlugins(t)):[];return{messages:e,threads:t.initialThreads||[],modules:t.enableModules?[]:void 0,selectedModules:[],uploadedFiles:[],suggestions:t.initialSuggestions||[],isTyping:!1,isProcessing:!1,currentThreadId:void 0,metadata:t.metadata||{}}}processMessageThroughPlugins(t){if(!t.text||"string"!=typeof t.text)return t;const e=Array.from(this.plugins.values()).filter(t=>Array.isArray(t.htmlTags)&&t.htmlTags.length>0);if(0===e.length)return t;let n=t.text,i=!1;for(const t of e){const e=t.htmlTags;for(const o of e){const e=o.open,r=o.close;let s=0;for(;;){const a=n.indexOf(e,s);if(-1===a)break;const l=a+e.length,c=n.indexOf(r,l);if(-1===c){s=l;continue}const d=n.substring(l,c);let h="";if("function"==typeof t.renderHtmlBlock)try{h=t.renderHtmlBlock(o.name,d)}catch(e){console.error(`[ChatbotCore] Error rendering HTML block for plugin ${t.id}:`,e)}h?(n=n.substring(0,a)+h+n.substring(c+r.length),i=!0,s=a+h.length):s=c+r.length}}}return i?Object.assign(Object.assign({},t),{text:n,metadata:Object.assign(Object.assign({},t.metadata),{renderAsHtml:!0})}):t}processRestoredMessagesForPlugins(){const t=this.stateHandler.getState();if(t.messages&&0!==t.messages.length)for(const e of t.messages)"bot"===e.sender&&this.plugins.forEach(t=>{if(t.onMessageReceived)try{t.onMessageReceived(e)}catch(t){}})}setupLifecycleHooks(){this.onBeforeInit(),this.onReady().catch(t=>{this.logError("Error during initialization:",t)})}onBeforeInit(){this.log("Initializing chatbot controller...")}onReady(){return At(this,void 0,void 0,function*(){this.log("Chatbot controller ready");try{const t=this.stateHandler.getState(),e=t.messages&&t.messages.length>0?t.messages[0]:void 0;e&&"bot"===e.sender&&e.introduction&&Array.isArray(e.suggestions)&&e.suggestions.length>0&&this.suggestionHandler.setSuggestions(e.suggestions)}catch(t){this.logError("Error initializing suggestions from initial messages:",t)}this.processRestoredMessagesForPlugins(),this.ui.onStateChange&&this.ui.onStateChange(this.getState()),this.emit("ready",this.stateHandler.getState())})}onDestroy(){this.log("Destroying chatbot controller..."),this.storageService.stopAutoSave(),this.pluginService.clearPlugins(),this.eventBus.removeAllListeners()}updateState(t){this.stateHandler.updateState(t)}sendMessage(t){return At(this,arguments,void 0,function*(t,e={}){this.log("Sending message:",t);try{const n=this.stateHandler.getState();this.config.enableThreads&&!n.currentThreadId&&(yield this.threadHandler.createThread("New Chat"));const i=yield this.beforeMessageSent(t,e);if(!e.skipValidation){const t=yield this.validationService.validateMessage(i);if(!t.isValid){const e=new mt(t.errors);throw this.handleValidationError(e),e}}const o=this.messageHandler.createUserMessage(i,e.metadata);e.files&&(o.files=e.files),this.messageHandler.addMessage(o);const r=this.stateHandler.getState();return(e.threadId||r.currentThreadId)&&this.threadHandler.updateThreadMessages(e.threadId||r.currentThreadId),yield this.afterMessageSent(o),this.providerService.processMessage(o).catch(t=>{this.logError("Error processing with provider:",t)}),o}catch(t){throw this.handleError(t),t}})}stop(){this.providerService.stopCurrentProcessing()}addMessage(t){const e=this.messageHandler.createMessage(t),n="bot"===e.sender?this.processMessageThroughPlugins(e):e;return this.messageHandler.addMessage(n),n}updateMessage(t,e){this.messageHandler.updateMessage(t,e)}deleteMessage(t){this.messageHandler.deleteMessage(t)}clearMessages(){this.updateState({messages:[]})}getMessages(){return this.stateHandler.getState().messages}uploadFiles(t){return At(this,void 0,void 0,function*(){if(!this.config.enableFileUpload)throw new Error("File upload is not enabled");let e=t;if(!e&&this.ui.openFileDialog&&(e=yield this.ui.openFileDialog()),!e||0===e.length)return[];const n=[];for(const t of e)try{const e=yield this.validationService.validateFile(t,{maxFileSize:this.config.maxFileSize,allowedTypes:this.config.allowedFileTypes});if(!e.isValid){this.ui.showNotification&&this.ui.showNotification(e.errors[0]||"File validation failed","error");continue}const i=yield this.fileHandler.createChatbotFile(t),o=yield this.providerService.uploadFileToProvider(t);o&&Object.assign(i,o),n.push(i),this.fileHandler.addFile(i),this.ui.showFilePreview&&this.ui.showFilePreview(i)}catch(e){this.logError("Error uploading file:",e),this.ui.showNotification&&this.ui.showNotification(`Failed to upload ${t.name}`,"error")}return n})}removeFile(t){this.fileHandler.removeFile(t)}clearFiles(){this.fileHandler.clearFiles()}getUploadedFiles(){return this.stateHandler.getState().uploadedFiles}createThread(t){return At(this,void 0,void 0,function*(){return yield this.threadHandler.createThread(t)})}switchThread(t){this.threadHandler.switchThread(t),this.processRestoredMessagesForPlugins()}deleteThread(t){this.threadHandler.deleteThread(t)}renameThread(t,e){this.threadHandler.renameThread(t,e)}bookmarkThread(t){this.threadHandler.bookmarkThread(t)}getCurrentThread(){const t=this.stateHandler.getState();return t.threads.find(e=>e.id===t.currentThreadId)}getThreads(){return this.stateHandler.getState().threads}setModules(t){this.moduleHandler.setModules(t)}selectModules(t){this.moduleHandler.selectModules(t)}toggleModule(t){this.moduleHandler.toggleModule(t)}getSelectedModules(){return this.moduleHandler.getSelectedModules()}setSuggestions(t){this.suggestionHandler.setSuggestions(t)}clearSuggestions(){this.suggestionHandler.clearSuggestions()}beforeMessageSent(t,e){return At(this,void 0,void 0,function*(){let e=t;for(const t of this.plugins.values())t.beforeSend&&(e=yield t.beforeSend(e));return e})}afterMessageSent(t){return At(this,void 0,void 0,function*(){this.log("Message sent:",t)})}beforeProviderCall(t){return At(this,void 0,void 0,function*(){this.log("Calling provider for message:",t.id)})}afterProviderCall(){return At(this,void 0,void 0,function*(){this.log("Provider call completed")})}handleProviderError(t){return At(this,void 0,void 0,function*(){this.logError("Provider error:",t);const e=this.messageHandler.createMessage({sender:D.Bot,text:"Sorry, there was an error processing your request.",state:B.Error,timestamp:(new Date).toISOString()});this.messageHandler.addMessage(e),this.ui.showNotification&&this.ui.showNotification("Failed to process message","error"),this.emit("provider:error",t),yield this.pluginService.executeHook("onError",t)})}handleValidationError(t){this.logError("Validation error:",t),this.ui.showNotification&&this.ui.showNotification(t.errors[0],"error"),this.emit("validation:error",t)}handleError(t){this.logError("Error:",t),this.emit("error",t),this.plugins.forEach(e=>{e.onError&&e.onError(t)})}registerPlugin(t){this.pluginService.registerPlugin(t,this)}unregisterPlugin(t){this.pluginService.unregisterPlugin(t)}getPlugin(t){return this.pluginService.getPlugin(t)}setProvider(t){this.providerService.setProvider(t),t.isConnected()?(this.autoLoadConversations(t).catch(t=>{this.logError("Failed to auto-load conversations:",t)}),this.emit("provider:connected",t.id)):t.connect({}).then(()=>At(this,void 0,void 0,function*(){yield this.autoLoadConversations(t),this.emit("provider:connected",t.id)})).catch(t=>{this.logError("Failed to connect provider:",t)})}setStorage(t){this.storageService.setStorage(t)}saveToStorage(){return At(this,arguments,void 0,function*(t="chatbot-state"){yield this.storageService.saveState(t)})}loadFromStorage(){return At(this,arguments,void 0,function*(t="chatbot-state"){yield this.storageService.loadState(t);const e=this.stateHandler.getState();if(e.messages&&e.messages.length>0){const t=e.messages.map(t=>this.processMessageThroughPlugins(t));this.stateHandler.updateState({messages:t}),this.processRestoredMessagesForPlugins()}})}on(t,e){return this.eventBus.on(t,e)}emit(t,e){this.eventBus.emit(t,e)}getState(){return this.stateHandler.getState()}setState(t){t.messages&&Array.isArray(t.messages)&&(t.messages=t.messages.map(t=>this.processMessageThroughPlugins(t))),t.threads&&Array.isArray(t.threads)&&(t.threads=t.threads.map(t=>Object.assign(Object.assign({},t),{messages:t.messages.map(t=>this.processMessageThroughPlugins(t))}))),this.updateState(t),t.messages&&this.processRestoredMessagesForPlugins()}loadConversations(t){const e=t.map(t=>Object.assign(Object.assign({},t),{messages:t.messages.map(t=>this.processMessageThroughPlugins(t))}));this.updateState({threads:e,currentThreadId:e.length>0?e[0].id:void 0,messages:e.length>0?e[0].messages:[]}),this.processRestoredMessagesForPlugins()}autoLoadConversations(t){return At(this,void 0,void 0,function*(){if(t&&"function"==typeof t.loadConversations)try{this.log("Auto-loading conversations from provider...");const e=yield t.loadConversations();if(Array.isArray(e)&&e.length>0){this.log(`Loaded ${e.length} conversation summaries`);const n=[];if("function"==typeof t.loadConversation)for(const i of e)try{const e=yield t.loadConversation(i.id);if(e){const t={id:e.id,title:e.title,messages:e.messages||[],createdAt:e.createdAt,updatedAt:e.updatedAt};n.push(t)}}catch(t){this.logError(`Failed to load conversation ${i.id}:`,t)}else for(const t of e){const e={id:t.id,title:t.title,messages:[],createdAt:t.createdAt,updatedAt:t.updatedAt};n.push(e)}n.length>0&&(this.log(`Successfully loaded ${n.length} conversations`),this.loadConversations(n))}else this.log("No conversations to load from provider")}catch(t){this.logError("Failed to auto-load conversations from provider:",t)}})}setUICallbacks(t){this.ui=Object.assign(Object.assign({},this.ui),t)}getConfig(){return Object.freeze(Object.assign({},this.config))}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}setTyping(t){this.updateState({isTyping:t}),this.emit(t?"typing:start":"typing:end")}setStatusText(t){this.updateState({statusText:t})}clearStatusText(){this.updateState({statusText:void 0})}getContext(){const t=this.stateHandler.getState();return{messages:t.messages,currentThread:this.getCurrentThread(),selectedModules:t.selectedModules,metadata:t.metadata,uploadedFiles:t.uploadedFiles}}destroy(){this.onDestroy()}generateId(t){return`${t}_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}formatFileSize(t){return t<1024?`${t} B`:t<1048576?`${(t/1024).toFixed(2)} KB`:`${(t/1048576).toFixed(2)} MB`}log(...t){this.config.debug&&console.log("[ChatbotCore]",...t)}logError(...t){console.error("[ChatbotCore]",...t)}}
|
|
2453
|
+
var Wt=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class Ht{constructor(t={}){this.plugins=new Map,this.config=t,this.ui=t.ui||{},this.eventBus=new $t,this.pluginService=new Lt,this.plugins=this.pluginService.getPluginsMap(),t.plugins&&t.plugins.forEach(t=>this.pluginService.registerPlugin(t,this));const e=this.initializeState(t);if(this.stateHandler=new St(e,this.eventBus,this.ui,this.plugins,this.config),this.messageHandler=new Pt(this.stateHandler,this.eventBus,this.plugins),this.threadHandler=new Et(this.stateHandler,this.eventBus,this.ui,this.config,t.provider),this.fileHandler=new zt(this.stateHandler,this.eventBus),this.moduleHandler=new Ct(this.stateHandler,this.eventBus),this.suggestionHandler=new It(this.stateHandler),this.providerService=new Rt(t.provider,this.stateHandler,this.messageHandler,this.fileHandler,this.eventBus,this.ui,this.plugins),this.validationService=new At(this.config),this.storageService=new Ft(t.storage,this.stateHandler,this.config),t.provider){const e=t.provider;queueMicrotask(()=>{this.initializeProvider(e)})}this.setupLifecycleHooks()}initializeProvider(t){return Wt(this,void 0,void 0,function*(){try{t.isConnected()||(yield t.connect({})),yield this.autoLoadConversations(t)}catch(t){this.logError("Failed to connect provider:",t)}})}initializeState(t){const e=t.initialMessages?t.initialMessages.map(t=>this.processMessageThroughPlugins(t)):[];return{messages:e,threads:t.initialThreads||[],modules:t.enableModules?[]:void 0,selectedModules:[],uploadedFiles:[],suggestions:t.initialSuggestions||[],isTyping:!1,isProcessing:!1,currentThreadId:void 0,metadata:t.metadata||{}}}processMessageThroughPlugins(t){if(!t.text||"string"!=typeof t.text)return t;const e=Array.from(this.plugins.values()).filter(t=>Array.isArray(t.htmlTags)&&t.htmlTags.length>0);if(0===e.length)return t;let n=t.text,i=!1;for(const t of e){const e=t.htmlTags;for(const o of e){const e=o.open,s=o.close;let r=0;for(;;){const a=n.indexOf(e,r);if(-1===a)break;const l=a+e.length,d=n.indexOf(s,l);if(-1===d){r=l;continue}const c=n.substring(l,d);let h="";if("function"==typeof t.renderHtmlBlock)try{h=t.renderHtmlBlock(o.name,c)}catch(e){console.error(`[ChatbotCore] Error rendering HTML block for plugin ${t.id}:`,e)}h?(n=n.substring(0,a)+h+n.substring(d+s.length),i=!0,r=a+h.length):r=d+s.length}}}return i?Object.assign(Object.assign({},t),{text:n,metadata:Object.assign(Object.assign({},t.metadata),{renderAsHtml:!0})}):t}processRestoredMessagesForPlugins(){const t=this.stateHandler.getState();if(t.messages&&0!==t.messages.length)for(const e of t.messages)"bot"===e.sender&&this.plugins.forEach(t=>{if(t.onMessageReceived)try{t.onMessageReceived(e)}catch(t){}})}setupLifecycleHooks(){this.onBeforeInit(),this.onReady().catch(t=>{this.logError("Error during initialization:",t)})}onBeforeInit(){this.log("Initializing chatbot controller...")}onReady(){return Wt(this,void 0,void 0,function*(){this.log("Chatbot controller ready");try{const t=this.stateHandler.getState(),e=t.messages&&t.messages.length>0?t.messages[0]:void 0;e&&"bot"===e.sender&&e.introduction&&Array.isArray(e.suggestions)&&e.suggestions.length>0&&this.suggestionHandler.setSuggestions(e.suggestions)}catch(t){this.logError("Error initializing suggestions from initial messages:",t)}this.processRestoredMessagesForPlugins(),this.ui.onStateChange&&this.ui.onStateChange(this.getState()),this.emit("ready",this.stateHandler.getState())})}onDestroy(){this.log("Destroying chatbot controller..."),this.storageService.stopAutoSave(),this.pluginService.clearPlugins(),this.eventBus.removeAllListeners()}updateState(t){this.stateHandler.updateState(t)}sendMessage(t){return Wt(this,arguments,void 0,function*(t,e={}){this.log("Sending message:",t);try{const n=this.stateHandler.getState();this.config.enableThreads&&!n.currentThreadId&&(yield this.threadHandler.createThread("New Chat"));const i=yield this.beforeMessageSent(t,e);if(!e.skipValidation){const t=yield this.validationService.validateMessage(i);if(!t.isValid){const e=new kt(t.errors);throw this.handleValidationError(e),e}}const o=this.messageHandler.createUserMessage(i,e.metadata);e.files&&(o.files=e.files),this.messageHandler.addMessage(o);const s=this.stateHandler.getState();return(e.threadId||s.currentThreadId)&&this.threadHandler.updateThreadMessages(e.threadId||s.currentThreadId),yield this.afterMessageSent(o),this.providerService.processMessage(o).catch(t=>{this.logError("Error processing with provider:",t)}),o}catch(t){throw this.handleError(t),t}})}stop(){this.providerService.stopCurrentProcessing()}addMessage(t){const e=this.messageHandler.createMessage(t),n="bot"===e.sender?this.processMessageThroughPlugins(e):e;return this.messageHandler.addMessage(n),n}updateMessage(t,e){this.messageHandler.updateMessage(t,e)}deleteMessage(t){this.messageHandler.deleteMessage(t)}clearMessages(){this.updateState({messages:[]})}getMessages(){return this.stateHandler.getState().messages}uploadFiles(t){return Wt(this,void 0,void 0,function*(){if(!this.config.enableFileUpload)throw new Error("File upload is not enabled");let e=t;if(!e&&this.ui.openFileDialog&&(e=yield this.ui.openFileDialog()),!e||0===e.length)return[];const n=[];for(const t of e)try{const e=yield this.validationService.validateFile(t,{maxFileSize:this.config.maxFileSize,allowedTypes:this.config.allowedFileTypes});if(!e.isValid){this.ui.showNotification&&this.ui.showNotification(e.errors[0]||"File validation failed","error");continue}const i=yield this.fileHandler.createChatbotFile(t),o=yield this.providerService.uploadFileToProvider(t);o&&Object.assign(i,o),n.push(i),this.fileHandler.addFile(i),this.ui.showFilePreview&&this.ui.showFilePreview(i)}catch(e){this.logError("Error uploading file:",e),this.ui.showNotification&&this.ui.showNotification(`Failed to upload ${t.name}`,"error")}return n})}removeFile(t){this.fileHandler.removeFile(t)}clearFiles(){this.fileHandler.clearFiles()}getUploadedFiles(){return this.stateHandler.getState().uploadedFiles}createThread(t){return Wt(this,void 0,void 0,function*(){return yield this.threadHandler.createThread(t)})}switchThread(t){this.threadHandler.switchThread(t),this.processRestoredMessagesForPlugins()}deleteThread(t){this.threadHandler.deleteThread(t)}renameThread(t,e){this.threadHandler.renameThread(t,e)}bookmarkThread(t){this.threadHandler.bookmarkThread(t)}getCurrentThread(){const t=this.stateHandler.getState();return t.threads.find(e=>e.id===t.currentThreadId)}getThreads(){return this.stateHandler.getState().threads}setModules(t){this.moduleHandler.setModules(t)}selectModules(t){this.moduleHandler.selectModules(t)}toggleModule(t){this.moduleHandler.toggleModule(t)}getSelectedModules(){return this.moduleHandler.getSelectedModules()}setSuggestions(t){this.suggestionHandler.setSuggestions(t)}clearSuggestions(){this.suggestionHandler.clearSuggestions()}beforeMessageSent(t,e){return Wt(this,void 0,void 0,function*(){let e=t;for(const t of this.plugins.values())t.beforeSend&&(e=yield t.beforeSend(e));return e})}afterMessageSent(t){return Wt(this,void 0,void 0,function*(){this.log("Message sent:",t)})}beforeProviderCall(t){return Wt(this,void 0,void 0,function*(){this.log("Calling provider for message:",t.id)})}afterProviderCall(){return Wt(this,void 0,void 0,function*(){this.log("Provider call completed")})}handleProviderError(t){return Wt(this,void 0,void 0,function*(){this.logError("Provider error:",t);const e=this.messageHandler.createMessage({sender:J.Bot,text:"Sorry, there was an error processing your request.",state:K.Error,timestamp:(new Date).toISOString()});this.messageHandler.addMessage(e),this.ui.showNotification&&this.ui.showNotification("Failed to process message","error"),this.emit("provider:error",t),yield this.pluginService.executeHook("onError",t)})}handleValidationError(t){this.logError("Validation error:",t),this.ui.showNotification&&this.ui.showNotification(t.errors[0],"error"),this.emit("validation:error",t)}handleError(t){this.logError("Error:",t),this.emit("error",t),this.plugins.forEach(e=>{e.onError&&e.onError(t)})}registerPlugin(t){this.pluginService.registerPlugin(t,this)}unregisterPlugin(t){this.pluginService.unregisterPlugin(t)}getPlugin(t){return this.pluginService.getPlugin(t)}setProvider(t){this.providerService.setProvider(t),t.isConnected()?(this.autoLoadConversations(t).catch(t=>{this.logError("Failed to auto-load conversations:",t)}),this.emit("provider:connected",t.id)):t.connect({}).then(()=>Wt(this,void 0,void 0,function*(){yield this.autoLoadConversations(t),this.emit("provider:connected",t.id)})).catch(t=>{this.logError("Failed to connect provider:",t)})}setStorage(t){this.storageService.setStorage(t)}saveToStorage(){return Wt(this,arguments,void 0,function*(t="chatbot-state"){yield this.storageService.saveState(t)})}loadFromStorage(){return Wt(this,arguments,void 0,function*(t="chatbot-state"){yield this.storageService.loadState(t);const e=this.stateHandler.getState();if(e.messages&&e.messages.length>0){const t=e.messages.map(t=>this.processMessageThroughPlugins(t));this.stateHandler.updateState({messages:t}),this.processRestoredMessagesForPlugins()}})}on(t,e){return this.eventBus.on(t,e)}emit(t,e){this.eventBus.emit(t,e)}getState(){return this.stateHandler.getState()}setState(t){t.messages&&Array.isArray(t.messages)&&(t.messages=t.messages.map(t=>this.processMessageThroughPlugins(t))),t.threads&&Array.isArray(t.threads)&&(t.threads=t.threads.map(t=>Object.assign(Object.assign({},t),{messages:t.messages.map(t=>this.processMessageThroughPlugins(t))}))),this.updateState(t),t.messages&&this.processRestoredMessagesForPlugins()}loadConversations(t){const e=t.map(t=>Object.assign(Object.assign({},t),{messages:t.messages.map(t=>this.processMessageThroughPlugins(t))}));this.updateState({threads:e,currentThreadId:e.length>0?e[0].id:void 0,messages:e.length>0?e[0].messages:[]}),this.processRestoredMessagesForPlugins()}autoLoadConversations(t){return Wt(this,void 0,void 0,function*(){if(t&&"function"==typeof t.loadConversations)try{this.log("Auto-loading conversations from provider...");const e=yield t.loadConversations();if(Array.isArray(e)&&e.length>0){this.log(`Loaded ${e.length} conversation summaries`);const n=[];if("function"==typeof t.loadConversation)for(const i of e)try{const e=yield t.loadConversation(i.id);if(e){const t={id:e.id,title:e.title,messages:e.messages||[],createdAt:e.createdAt,updatedAt:e.updatedAt};n.push(t)}}catch(t){this.logError(`Failed to load conversation ${i.id}:`,t)}else for(const t of e){const e={id:t.id,title:t.title,messages:[],createdAt:t.createdAt,updatedAt:t.updatedAt};n.push(e)}n.length>0&&(this.log(`Successfully loaded ${n.length} conversations`),this.loadConversations(n))}else this.log("No conversations to load from provider")}catch(t){this.logError("Failed to auto-load conversations from provider:",t)}})}setUICallbacks(t){this.ui=Object.assign(Object.assign({},this.ui),t)}getConfig(){return Object.freeze(Object.assign({},this.config))}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}setTyping(t){this.updateState({isTyping:t}),this.emit(t?"typing:start":"typing:end")}setStatusText(t){this.updateState({statusText:t})}clearStatusText(){this.updateState({statusText:void 0})}getContext(){const t=this.stateHandler.getState();return{messages:t.messages,currentThread:this.getCurrentThread(),selectedModules:t.selectedModules,metadata:t.metadata,uploadedFiles:t.uploadedFiles}}destroy(){this.onDestroy()}generateId(t){return`${t}_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}formatFileSize(t){return t<1024?`${t} B`:t<1048576?`${(t/1024).toFixed(2)} KB`:`${(t/1048576).toFixed(2)} MB`}log(...t){this.config.debug&&console.log("[ChatbotCore]",...t)}logError(...t){console.error("[ChatbotCore]",...t)}}
|
|
2438
2454
|
/**
|
|
2439
2455
|
* @license
|
|
2440
2456
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2441
2457
|
* SPDX-License-Identifier: MIT
|
|
2442
|
-
*/var
|
|
2458
|
+
*/var Jt=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})},qt=function(t){return this instanceof qt?(this.v=t,this):new qt(t)},Vt=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,o=n.apply(t,e||[]),s=[];return i=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),r("next"),r("throw"),r("return",function(t){return function(e){return Promise.resolve(e).then(t,d)}}),i[Symbol.asyncIterator]=function(){return this},i;function r(t,e){o[t]&&(i[t]=function(e){return new Promise(function(n,i){s.push([t,e,n,i])>1||a(t,e)})},e&&(i[t]=e(i[t])))}function a(t,e){try{(n=o[t](e)).value instanceof qt?Promise.resolve(n.value.v).then(l,d):c(s[0][2],n)}catch(t){c(s[0][3],t)}var n}function l(t){a("next",t)}function d(t){a("throw",t)}function c(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}};class Gt{constructor(){this.id="openai",this.name="OpenAI",this.capabilities={streaming:!0,fileUpload:!0,modules:!0,functions:!0,imageGeneration:!0},this.apiKey="",this.apiUrl="https://api.openai.com/v1",this.model="gpt-4",this.temperature=.7,this.connected=!1}connect(t){return Jt(this,void 0,void 0,function*(){var e;if(!t.apiKey)throw new Error("OpenAI API key is required");this.apiKey=t.apiKey,this.apiUrl=t.apiUrl||this.apiUrl,this.model=t.model||this.model,this.temperature=null!==(e=t.temperature)&&void 0!==e?e:this.temperature,this.maxTokens=t.maxTokens;try{const t=yield fetch(`${this.apiUrl}/models`,{headers:{Authorization:`Bearer ${this.apiKey}`}});if(!t.ok)throw new Error(`OpenAI connection failed: ${t.statusText}`);this.connected=!0,console.log("[OpenAIProvider] Connected successfully")}catch(t){throw this.connected=!1,t}})}disconnect(){return Jt(this,void 0,void 0,function*(){this.connected=!1,console.log("[OpenAIProvider] Disconnected")})}isConnected(){return this.connected}sendMessage(t,e){return Vt(this,arguments,function*(){var n,i,o;if(!this.connected)throw new Error("Provider not connected");const s=this.buildMessages(t,e),r=yield qt(fetch(`${this.apiUrl}/chat/completions`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({model:this.model,messages:s,temperature:this.temperature,max_tokens:this.maxTokens,stream:!0})}));if(!r.ok)throw new Error(`OpenAI API error: ${r.statusText}`);if(!r.body)throw new Error("Response body is null");const a=r.body.getReader(),l=new TextDecoder;let d="";try{for(;;){const{done:t,value:e}=yield qt(a.read());if(t)break;d+=l.decode(e,{stream:!0});const s=d.split("\n");d=s.pop()||"";for(const t of s)if(""!==t.trim()&&"data: [DONE]"!==t.trim()&&t.startsWith("data: ")){const e=t.slice(6);try{const t=null===(o=null===(i=null===(n=JSON.parse(e).choices)||void 0===n?void 0:n[0])||void 0===i?void 0:i.delta)||void 0===o?void 0:o.content;t&&(yield yield qt(t))}catch(t){console.error("Error parsing SSE data:",t)}}}}finally{a.releaseLock()}})}getAvailableModules(){return Jt(this,void 0,void 0,function*(){return[{id:"web-search",name:"Web Search",description:"Search the web for information",icon:"search",enabled:!0},{id:"code-interpreter",name:"Code Interpreter",description:"Execute Python code",icon:"code",enabled:!0},{id:"dalle",name:"DALL-E",description:"Generate images",icon:"image",enabled:!0}]})}callModule(t,e){return Jt(this,void 0,void 0,function*(){return console.log(`[OpenAIProvider] Calling module: ${t}`,e),{success:!0,result:"Module executed"}})}uploadFile(t){return Jt(this,void 0,void 0,function*(){const e=new FormData;e.append("file",t),e.append("purpose","assistants");const n=yield fetch(`${this.apiUrl}/files`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:e});if(!n.ok)throw new Error(`File upload failed: ${n.statusText}`);const i=yield n.json();return{id:i.id,name:t.name,size:t.size,type:this.determineFileType(t.type),mimeType:t.type,url:i.url}})}onError(t){console.error("[OpenAIProvider] Error:",t)}buildMessages(t,e){const n=[],i=e.messages.slice(-10);for(const t of i)n.push({role:"user"===t.sender?"user":"assistant",content:t.text});return n.find(e=>"user"===e.role&&e.content===t)||n.push({role:"user",content:t}),n}determineFileType(t){return t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":"document"}}
|
|
2443
2459
|
/**
|
|
2444
2460
|
* @license
|
|
2445
2461
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2446
2462
|
* SPDX-License-Identifier: MIT
|
|
2447
|
-
*/var
|
|
2463
|
+
*/var Kt=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})},Yt=function(t){return this instanceof Yt?(this.v=t,this):new Yt(t)},Xt=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,o=n.apply(t,e||[]),s=[];return i=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),r("next"),r("throw"),r("return",function(t){return function(e){return Promise.resolve(e).then(t,d)}}),i[Symbol.asyncIterator]=function(){return this},i;function r(t,e){o[t]&&(i[t]=function(e){return new Promise(function(n,i){s.push([t,e,n,i])>1||a(t,e)})},e&&(i[t]=e(i[t])))}function a(t,e){try{(n=o[t](e)).value instanceof Yt?Promise.resolve(n.value.v).then(l,d):c(s[0][2],n)}catch(t){c(s[0][3],t)}var n}function l(t){a("next",t)}function d(t){a("throw",t)}function c(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}};class Qt{constructor(){this.id="custom-api",this.name="Custom API",this.capabilities={streaming:!0,fileUpload:!1,modules:!1,functions:!1},this.apiUrl="",this.headers={},this.connected=!1}connect(t){return Kt(this,void 0,void 0,function*(){if(!t.apiUrl)throw new Error("API URL is required");this.apiUrl=t.apiUrl,this.headers=Object.assign({},t.headers),this.headers["Content-Type"]||(this.headers["Content-Type"]="application/json"),t.apiKey&&(this.headers.Authorization=`Bearer ${t.apiKey}`),this.connected=!0,console.log("[CustomAPIProvider] Connected")})}disconnect(){return Kt(this,void 0,void 0,function*(){this.connected=!1,console.log("[CustomAPIProvider] Disconnected")})}isConnected(){return this.connected}sendMessage(t,e){return Xt(this,arguments,function*(){var n;if(!this.connected)return yield yield Yt(this.formatError("Provider not connected","Please check your connection settings.")),yield Yt(void 0);try{const i=this.buildPayload(t,e);let o,s;if(!(null===(n=this.headers["Content-Type"])||void 0===n?void 0:n.includes("multipart/form-data"))||"object"!=typeof i||i instanceof FormData)i instanceof FormData?(o=i,s=Object.assign({},this.headers),delete s["Content-Type"]):(o=JSON.stringify(i),s=this.headers);else{const t=new FormData;for(const[e,n]of Object.entries(i))null!=n&&t.append(e,"object"==typeof n?JSON.stringify(n):String(n));o=t,s=Object.assign({},this.headers),delete s["Content-Type"]}const r=yield Yt(fetch(this.apiUrl,{method:"POST",headers:s,body:o}));if(!r.ok){const t=yield Yt(r.text().catch(()=>r.statusText));return yield yield Yt(this.formatError(`${r.status} ${r.statusText}`,t||"The server returned an error. Please try again.")),yield Yt(void 0)}if(!r.body)return yield yield Yt(this.formatError("Response Error","The server response body is empty.")),yield Yt(void 0);const a=r.headers.get("content-type");if((null==a?void 0:a.includes("text/event-stream"))||(null==a?void 0:a.includes("stream"))||(null==a?void 0:a.includes("text/plain"))){const t=this.handleStreamResponse(r);let e=yield Yt(t.next());for(;!e.done;)yield yield Yt(e.value),e=yield Yt(t.next())}else try{const t=yield Yt(r.json());yield yield Yt(this.extractMessage(t))}catch(t){yield yield Yt(this.formatError("Parse Error","Failed to parse the server response."))}}catch(t){const e=t instanceof Error?t.message:String(t);yield yield Yt(this.formatError("Network Error",e)),this.onError(t instanceof Error?t:new Error(String(t)))}})}handleStreamResponse(t){return Xt(this,arguments,function*(){const e=t.body.getReader(),n=new TextDecoder;let i="";try{for(;;){const{done:t,value:o}=yield Yt(e.read());if(t)break;i+=n.decode(o,{stream:!0}),yield yield Yt(i)}i.length>0&&(yield yield Yt(i))}catch(t){const e=t instanceof Error?t.message:String(t);yield yield Yt("\n\n"+this.formatError("Streaming Error",e)),this.onError(t instanceof Error?t:new Error(String(t)))}finally{e.releaseLock()}})}buildPayload(t,e){return{userMessage:t,variables:e.metadata||{},stream:!0}}extractMessage(t){return t.message||t.text||t.response||JSON.stringify(t)}formatError(t,e){return`[ERROR_START][ERROR_TITLE_START]${t}[ERROR_TITLE_END]${e}[ERROR_END]`}onError(t){console.error("[CustomAPIProvider] Error:",t)}}
|
|
2448
2464
|
/**
|
|
2449
2465
|
* @license
|
|
2450
2466
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2451
2467
|
* SPDX-License-Identifier: MIT
|
|
2452
|
-
*/var
|
|
2468
|
+
*/var Zt=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})},te=function(t){return this instanceof te?(this.v=t,this):new te(t)},ee=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t="function"==typeof __values?__values(t):t[Symbol.iterator](),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(n){e[n]=t[n]&&function(e){return new Promise(function(i,o){(function(t,e,n,i){Promise.resolve(i).then(function(e){t({value:e,done:n})},e)})(i,o,(e=t[n](e)).done,e.value)})}}},ne=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,o=n.apply(t,e||[]),s=[];return i=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),r("next"),r("throw"),r("return",function(t){return function(e){return Promise.resolve(e).then(t,d)}}),i[Symbol.asyncIterator]=function(){return this},i;function r(t,e){o[t]&&(i[t]=function(e){return new Promise(function(n,i){s.push([t,e,n,i])>1||a(t,e)})},e&&(i[t]=e(i[t])))}function a(t,e){try{(n=o[t](e)).value instanceof te?Promise.resolve(n.value.v).then(l,d):c(s[0][2],n)}catch(t){c(s[0][3],t)}var n}function l(t){a("next",t)}function d(t){a("throw",t)}function c(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}};const ie=["That's an interesting question! Let me think about that...","I understand what you're asking. Here's what I think:","Great point! Based on what you've told me, I would suggest:","I'd be happy to help with that. Let me explain:","That's a common question. The answer is:","I see where you're coming from. Let me clarify:","Excellent question! Here's my perspective:","I can definitely help you with that. Consider this:"],oe={hello:["Hello! 👋 How can I help you today?","Hi there! What can I do for you?","Hey! Great to see you. What's on your mind?"],help:["I'm here to help! You can ask me anything. Try asking about features, getting started, or technical questions.","I can assist with various topics. What do you need help with?","Sure! I'm ready to help. What would you like to know?"],bye:["Goodbye! Feel free to come back anytime! 👋","See you later! Have a great day!","Bye! It was nice chatting with you!"],thanks:["You're welcome! Happy to help! 😊","Glad I could help!","Anytime! That's what I'm here for!"],how:["Great question! Here's how it works: First, you need to understand the basics. Then, you can dive deeper into the specifics.","Let me explain the process step by step...","That's actually quite straightforward. Let me break it down for you:"],what:["Good question! Let me explain what that means...","That refers to a concept that's important to understand. Here's the breakdown:","Interesting topic! Here's what you need to know:"],why:["That's because of several factors. Let me explain the reasoning:","Great question! The main reason is that it provides better functionality and user experience.","There are multiple reasons for this. The primary one is:"]};class se{constructor(t={}){var e,n,i,o,s,r,a,l,d,c,h,u;this.id="mock-provider",this.name="Mock Provider",this.capabilities={streaming:!0,fileUpload:!0,modules:!1,functions:!0},this.messageCount=0,this.connected=!1,this.config={delay:null!==(e=t.delay)&&void 0!==e?e:800,streaming:null!==(n=t.streaming)&&void 0!==n&&n,streamingSpeed:null!==(i=t.streamingSpeed)&&void 0!==i?i:3,streamingInterval:null!==(o=t.streamingInterval)&&void 0!==o?o:50,contextualResponses:null===(s=t.contextualResponses)||void 0===s||s,echoMode:null!==(r=t.echoMode)&&void 0!==r&&r,customResponses:null!==(a=t.customResponses)&&void 0!==a?a:[],errorRate:null!==(l=t.errorRate)&&void 0!==l?l:0,useHistory:null===(d=t.useHistory)||void 0===d||d,simulateToolCalls:null!==(c=t.simulateToolCalls)&&void 0!==c&&c,toolCallNames:null!==(h=t.toolCallNames)&&void 0!==h?h:["search_web","get_weather","run_code"],toolCallDelay:null!==(u=t.toolCallDelay)&&void 0!==u?u:1500}}connect(t){return Zt(this,void 0,void 0,function*(){yield this.delay(100),this.connected=!0,console.log("🤖 Mock Provider connected")})}disconnect(){return Zt(this,void 0,void 0,function*(){this.connected=!1,console.log("🤖 Mock Provider disconnected")})}isConnected(){return this.connected}sendMessage(t,e){return ne(this,arguments,function*(){var n,i,o,s,r,a;if(this.messageCount++,Math.random()<this.config.errorRate)throw yield te(this.delay(this.config.delay/2)),new Error("Simulated API error for testing");if(yield te(this.delay(this.config.delay)),this.config.simulateToolCalls){const t=this.config.toolCallNames,e=1+Math.floor(Math.random()*Math.min(t.length,3));for(let n=0;n<e;n++){const e=t[n%t.length];null===(r=this.onToolCall)||void 0===r||r.call(this,e),yield te(this.delay(this.config.toolCallDelay)),null===(a=this.onToolCallEnd)||void 0===a||a.call(this)}}const l=this.generateResponse(t,e);if(this.config.streaming)try{for(var d,c=!0,h=ee(this.streamResponse(l));!(n=(d=yield te(h.next())).done);c=!0){s=d.value,c=!1;const t=s;yield yield te(t)}}catch(t){i={error:t}}finally{try{c||n||!(o=h.return)||(yield te(o.call(h)))}finally{if(i)throw i.error}}else yield yield te(l)})}uploadFile(t){return Zt(this,void 0,void 0,function*(){if(yield this.delay(this.config.delay),Math.random()<this.config.errorRate)throw new Error("Simulated file upload error for testing");const e=t.type||"application/octet-stream",n=this.determineFileType(e),i=`mock-file-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;console.log(`📎 Mock Provider: File uploaded - ${t.name} (${t.size} bytes) - ID: ${i}`);return{id:i,name:t.name,size:t.size,type:n,mimeType:e,url:URL.createObjectURL(t),previewUrl:"image"===n?URL.createObjectURL(t):void 0,uploadProgress:100,metadata:{provider:"mock",uploadedAt:(new Date).toISOString()}}})}determineFileType(t){return t.startsWith("image/")?Y.Image:t.startsWith("video/")?Y.Video:t.startsWith("audio/")?Y.Audio:t.startsWith("application/pdf")||t.includes("document")||t.includes("text")?Y.Document:t.includes("zip")||t.includes("rar")||t.includes("tar")?Y.Archive:t.includes("javascript")||t.includes("json")||t.includes("xml")?Y.Code:Y.Unknown}generateResponse(t,e){var n,i;const o=(null==e?void 0:e.messages)||[],s=null===(n=[...o].map((t,e)=>({m:t,i:e})).reverse().find(({m:t})=>"user"===t.sender&&!!t.text))||void 0===n?void 0:n.i,r="number"==typeof s&&(null===(i=o[s])||void 0===i?void 0:i.text)?o[s].text:t;if(this.config.echoMode)return`You said: "${r}"`;if(this.config.customResponses.length>0){const t=(this.messageCount-1)%this.config.customResponses.length;return this.config.customResponses[t]}if(this.config.contextualResponses){const t=this.getContextualResponse(r);if(t)return t}if(this.config.useHistory&&o.length>0&&"number"==typeof s){const t=[...o].slice(0,s).reverse().find(t=>"user"===t.sender&&!!t.text);return t&&t.text?`Great point about "${String(r).substring(0,60)}". Considering your earlier message about "${String(t.text).substring(0,30)}...", ${this.getRandomResponse()}`:`Regarding "${String(r).substring(0,60)}", ${this.getRandomResponse()}`}return`Regarding "${String(r).substring(0,60)}", ${this.getRandomResponse()}`}getContextualResponse(t){const e=t.toLowerCase();for(const[t,n]of Object.entries(oe))if(e.includes(t)){return n[Math.floor(Math.random()*n.length)]}return null}getRandomResponse(){const t=Math.floor(Math.random()*ie.length);return ie[t]}streamResponse(t){return ne(this,arguments,function*(){let e="";const n=t.split(" ");for(let t=0;t<n.length;t++){e+=(t>0?" ":"")+n[t],yield yield te(e),t<n.length-1&&(yield te(this.delay(this.config.streamingInterval)))}})}delay(t){return new Promise(e=>setTimeout(e,t))}reset(){this.messageCount=0}updateConfig(t){Object.assign(this.config,t)}getConfig(){return Object.assign({},this.config)}}const re={fast:()=>new se({delay:300,streaming:!1,contextualResponses:!0}),realistic:()=>new se({delay:1200,streaming:!0,streamingInterval:50,contextualResponses:!0,useHistory:!0}),slow:()=>new se({delay:3e3,streaming:!1}),echo:()=>new se({delay:500,echoMode:!0}),streaming:()=>new se({delay:800,streaming:!0,streamingSpeed:2,streamingInterval:30}),unreliable:()=>new se({delay:1e3,errorRate:.3}),custom:t=>new se({delay:800,customResponses:t})};
|
|
2453
2469
|
/**
|
|
2454
2470
|
* @license
|
|
2455
2471
|
* Copyright 2024 Nuraly, Laabidi Aymen
|
|
2456
2472
|
* SPDX-License-Identifier: MIT
|
|
2457
|
-
*/var
|
|
2473
|
+
*/var ae=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})},le=function(t){return this instanceof le?(this.v=t,this):new le(t)},de=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,o=n.apply(t,e||[]),s=[];return i=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),r("next"),r("throw"),r("return",function(t){return function(e){return Promise.resolve(e).then(t,d)}}),i[Symbol.asyncIterator]=function(){return this},i;function r(t,e){o[t]&&(i[t]=function(e){return new Promise(function(n,i){s.push([t,e,n,i])>1||a(t,e)})},e&&(i[t]=e(i[t])))}function a(t,e){try{(n=o[t](e)).value instanceof le?Promise.resolve(n.value.v).then(l,d):c(s[0][2],n)}catch(t){c(s[0][3],t)}var n}function l(t){a("next",t)}function d(t){a("throw",t)}function c(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}};const ce={send:"message:send",response:"message:response",stream:"message:stream",error:"message:error",typingStart:"typing:start",typingEnd:"typing:end",toolCall:"tool:call",toolCallEnd:"tool:end"};class he{constructor(){this.id="socket",this.name="Socket.io Provider",this.capabilities={streaming:!0,fileUpload:!1,modules:!1,functions:!1},this.socket=null,this.config=null,this.connected=!1,this.responseResolvers=new Map}connect(t){return ae(this,void 0,void 0,function*(){var e,n,i;if(!t.url)throw new Error("Socket URL is required");this.config=Object.assign(Object.assign({},t),{events:Object.assign(Object.assign({},ce),t.events),autoReconnect:null===(e=t.autoReconnect)||void 0===e||e,reconnectionAttempts:null!==(n=t.reconnectionAttempts)&&void 0!==n?n:5,responseTimeout:null!==(i=t.responseTimeout)&&void 0!==i?i:3e4});const o=t.namespace?`${t.url}${t.namespace}`:t.url;return this.socket=c(o,{path:t.path||"/socket.io",transports:["websocket","polling"],autoConnect:!0,reconnection:this.config.autoReconnect,reconnectionAttempts:this.config.reconnectionAttempts,extraHeaders:t.headers}),new Promise((t,e)=>{const n=setTimeout(()=>{e(new Error("Socket connection timeout"))},1e4);this.socket.on("connect",()=>{clearTimeout(n),this.connected=!0,console.log("[SocketProvider] Connected:",this.socket.id),t()}),this.socket.on("connect_error",t=>{clearTimeout(n),console.error("[SocketProvider] Connection error:",t),e(t)}),this.socket.on("disconnect",t=>{this.connected=!1,console.log("[SocketProvider] Disconnected:",t)}),this.setupEventListeners()})})}setupEventListeners(){if(!this.socket||!this.config)return;const t=this.config.events;this.socket.on(t.response,t=>{console.log("[SocketProvider] Response received:",t);const e=this.extractMessageId(t),n=this.responseResolvers.get(e)||this.getLatestResolver();if(n){const i=this.extractMessage(t);n.resolve(i),this.responseResolvers.delete(e)}}),t.stream&&this.socket.on(t.stream,t=>{console.log("[SocketProvider] Stream chunk:",t);const e=this.extractMessageId(t),n=this.responseResolvers.get(e)||this.getLatestResolver();if(n){n.isStreaming=!0;const e=this.extractMessage(t);n.chunks.push(e)}}),t.error&&this.socket.on(t.error,t=>{console.error("[SocketProvider] Error event:",t);const e=this.extractMessageId(t),n=this.responseResolvers.get(e)||this.getLatestResolver();if(n){const i=t.error||t.message||"Unknown error";n.reject(new Error(i)),this.responseResolvers.delete(e)}}),t.toolCall&&this.socket.on(t.toolCall,t=>{var e;const n=t.name||t.toolName||t.function||"unknown";null===(e=this.onToolCall)||void 0===e||e.call(this,n)}),t.toolCallEnd&&this.socket.on(t.toolCallEnd,()=>{var t;null===(t=this.onToolCallEnd)||void 0===t||t.call(this)})}getLatestResolver(){const t=Array.from(this.responseResolvers.keys());return t.length>0?this.responseResolvers.get(t[t.length-1]):null}extractMessageId(t){return t.messageId||t.id||t.executionId||"default"}extractMessage(t){var e,n,i;return(null===(e=this.config)||void 0===e?void 0:e.extractMessage)?this.config.extractMessage(t):"string"==typeof t?t:t.message?t.message:t.text?t.text:t.response?t.response:t.content?t.content:(null===(n=t.data)||void 0===n?void 0:n.message)?t.data.message:(null===(i=t.data)||void 0===i?void 0:i.output)?JSON.stringify(t.data.output):JSON.stringify(t)}disconnect(){return ae(this,void 0,void 0,function*(){this.socket&&(this.socket.disconnect(),this.socket=null),this.connected=!1,this.responseResolvers.clear(),console.log("[SocketProvider] Disconnected")})}isConnected(){var t;return this.connected&&!0===(null===(t=this.socket)||void 0===t?void 0:t.connected)}sendMessage(t,e){return de(this,arguments,function*(){if(!this.connected||!this.socket||!this.config)return yield yield le(this.formatError("Not Connected","Socket is not connected. Please check your connection.")),yield le(void 0);const n=`msg_${Date.now()}_${crypto.randomUUID().slice(0,9)}`,i=this.buildPayload(t,e,n);try{const t=new Promise((t,e)=>{this.responseResolvers.set(n,{resolve:t,reject:e,chunks:[],isStreaming:!1}),setTimeout(()=>{const i=this.responseResolvers.get(n);i&&(i.chunks.length>0?t(i.chunks.join("")):e(new Error("Response timeout")),this.responseResolvers.delete(n))},this.config.responseTimeout)});if(console.log("[SocketProvider] Sending message:",this.config.events.send,i),this.socket.emit(this.config.events.send,i),this.config.events.stream){const e=this.responseResolvers.get(n);let i=0;const o=setInterval(()=>{e&&e.chunks.length>i&&(i=e.chunks.length)},50);try{const e=yield le(t);clearInterval(o),yield yield le(e)}catch(t){throw clearInterval(o),t}}else{const e=yield le(t);yield yield le(e)}}catch(t){const e=t instanceof Error?t.message:String(t);yield yield le(this.formatError("Socket Error",e)),this.onError(t instanceof Error?t:new Error(String(t)))}})}buildPayload(t,e,n){var i,o,s;if(null===(i=this.config)||void 0===i?void 0:i.buildPayload){const i=this.config.buildPayload(t,e);return Object.assign(Object.assign({},i),{messageId:n})}return{messageId:n,message:t,text:t,threadId:null===(o=e.currentThread)||void 0===o?void 0:o.id,modules:e.selectedModules,metadata:e.metadata,files:null===(s=e.uploadedFiles)||void 0===s?void 0:s.map(t=>({id:t.id,name:t.name,type:t.type,url:t.url}))}}emit(t,e){this.socket&&this.connected&&this.socket.emit(t,e)}on(t,e){this.socket&&this.socket.on(t,e)}off(t,e){this.socket&&this.socket.off(t,e)}getSocket(){return this.socket}formatError(t,e){return`[ERROR_START][ERROR_TITLE_START]${t}[ERROR_TITLE_END]${e}[ERROR_END]`}onError(t){console.error("[SocketProvider] Error:",t)}}
|
|
2458
2474
|
/**
|
|
2459
2475
|
* @license
|
|
2460
2476
|
* Copyright 2024 Nuraly, Laabidi Aymen
|
|
2461
2477
|
* SPDX-License-Identifier: MIT
|
|
2462
|
-
*/var re=function(t,e,n,i){return new(n||(n=Promise))(function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((i=i.apply(t,e||[])).next())})},se=function(t){return this instanceof se?(this.v=t,this):new se(t)},ae=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,o=n.apply(t,e||[]),r=[];return i=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",function(t){return function(e){return Promise.resolve(e).then(t,c)}}),i[Symbol.asyncIterator]=function(){return this},i;function s(t,e){o[t]&&(i[t]=function(e){return new Promise(function(n,i){r.push([t,e,n,i])>1||a(t,e)})},e&&(i[t]=e(i[t])))}function a(t,e){try{(n=o[t](e)).value instanceof se?Promise.resolve(n.value.v).then(l,c):d(r[0][2],n)}catch(t){d(r[0][3],t)}var n}function l(t){a("next",t)}function c(t){a("throw",t)}function d(t,e){t(e),r.shift(),r.length&&a(r[0][0],r[0][1])}};class le{constructor(){this.id="workflow-socket",this.name="Workflow Socket Provider",this.capabilities={streaming:!0,fileUpload:!0,modules:!0,functions:!1},this.socket=null,this.config=null,this.connected=!1,this.sessionId=`session_${Date.now()}_${Math.random().toString(36).substring(2,11)}`,this.activeExecutions=new Map}connect(t){return re(this,void 0,void 0,function*(){if(!t.workflowId)throw new Error("Workflow ID is required");return this.config=Object.assign({socketUrl:t.socketUrl||("undefined"!=typeof window?window.location.origin:"http://localhost:8000"),socketPath:t.socketPath||"/socket.io/workflow",triggerEndpoint:t.triggerEndpoint||"/api/v1/workflows/{workflowId}/trigger/chat",responseTimeout:t.responseTimeout||6e4},t),this.socket=h(this.config.socketUrl,{path:this.config.socketPath,transports:["websocket","polling"],autoConnect:!0,reconnection:!0,reconnectionAttempts:5}),new Promise((t,e)=>{const n=setTimeout(()=>{e(new Error("Socket connection timeout"))},1e4);this.socket.on("connect",()=>{clearTimeout(n),this.connected=!0,console.log("[WorkflowSocketProvider] Connected:",this.socket.id),t()}),this.socket.on("connect_error",t=>{clearTimeout(n),console.error("[WorkflowSocketProvider] Connection error:",t),e(t)}),this.socket.on("disconnect",t=>{this.connected=!1,console.log("[WorkflowSocketProvider] Disconnected:",t)}),this.setupEventListeners()})})}subscribeToWorkflow(t){this.socket&&(this.socket.emit("subscribe:workflow",{workflowId:t}),console.log("[WorkflowSocketProvider] Subscribed to workflow:",t))}subscribeToExecution(t){this.socket&&(this.socket.emit("subscribe:execution",{executionId:t}),console.log("[WorkflowSocketProvider] Subscribed to execution:",t))}setupEventListeners(){this.socket&&(this.socket.on("chat:message",t=>{var e,n,i,o;console.log("[WorkflowSocketProvider] Chat message received:",t);const r=t.executionId||(null===(e=t.data)||void 0===e?void 0:e.executionId),s=(null===(n=t.data)||void 0===n?void 0:n.message)||t.message;if(r&&s){let t=this.activeExecutions.get(r);if(!t)return void(null===(o=null===(i=this.config)||void 0===i?void 0:i.onMessage)||void 0===o||o.call(i,s));t.completed||t.messages.push(s)}}),this.socket.on("execution:started",t=>{console.log("[WorkflowSocketProvider] Execution started:",t)}),this.socket.on("execution:completed",t=>{var e,n,i;console.log("[WorkflowSocketProvider] Execution completed:",t);const o=t.executionId||(null===(e=t.data)||void 0===e?void 0:e.executionId);if(o){const e=this.activeExecutions.get(o);if(e&&!e.completed){e.completed=!0;let r="";if(null===(n=this.config)||void 0===n?void 0:n.extractResponse)r=this.config.extractResponse(t);else if(e.messages.length>0)r=e.messages.join("\n\n");else if(null===(i=t.data)||void 0===i?void 0:i.outputData)try{const e="string"==typeof t.data.outputData?JSON.parse(t.data.outputData):t.data.outputData;r=e.response||e.message||e.result||JSON.stringify(e)}catch(e){r=t.data.outputData}e.resolve(r||"Workflow completed"),this.activeExecutions.delete(o)}}}),this.socket.on("execution:failed",t=>{var e,n,i;console.error("[WorkflowSocketProvider] Execution failed:",t);const o=t.executionId||(null===(e=t.data)||void 0===e?void 0:e.executionId),r=(null===(n=t.data)||void 0===n?void 0:n.errorMessage)||(null===(i=t.data)||void 0===i?void 0:i.error)||"Workflow execution failed";if(o){const t=this.activeExecutions.get(o);t&&!t.completed&&(t.completed=!0,t.reject(new Error(r)),this.activeExecutions.delete(o))}}),this.socket.on("execution:node-started",t=>{var e,n;const i=null===(e=t.data)||void 0===e?void 0:e.nodeName;console.log("[WorkflowSocketProvider] Node started:",i),i&&(null===(n=this.onNodeStarted)||void 0===n||n.call(this,i))}),this.socket.on("execution:node-completed",t=>{var e,n;const i=null===(e=t.data)||void 0===e?void 0:e.nodeName;console.log("[WorkflowSocketProvider] Node completed:",i),i&&(null===(n=this.onNodeCompleted)||void 0===n||n.call(this,i))}))}disconnect(){return re(this,void 0,void 0,function*(){var t;this.socket&&((null===(t=this.config)||void 0===t?void 0:t.workflowId)&&this.socket.emit("unsubscribe:workflow",{workflowId:this.config.workflowId}),this.socket.disconnect(),this.socket=null),this.connected=!1,this.activeExecutions.clear(),console.log("[WorkflowSocketProvider] Disconnected")})}isConnected(){var t;return this.connected&&!0===(null===(t=this.socket)||void 0===t?void 0:t.connected)}sendMessage(t,e){return ae(this,arguments,function*(){var n,i;if(!this.connected||!this.socket||!this.config)return yield yield se(this.formatError("Not Connected","Socket is not connected. Please check your connection.")),yield se(void 0);try{const o=this.buildInput(t,e),r=this.config.triggerEndpoint.replace("{workflowId}",this.config.workflowId),s=`${this.config.socketUrl}${r}`;console.log("[WorkflowSocketProvider] Triggering workflow:",s,o);const a=yield se(fetch(s,{method:"POST",headers:Object.assign({"Content-Type":"application/json"},this.config.headers),body:JSON.stringify(o)}));if(!a.ok){const t=yield se(a.text().catch(()=>a.statusText));return yield yield se(this.formatError(`${a.status} ${a.statusText}`,t)),yield se(void 0)}const l=a.headers.get("X-Execution-Id")||(null===(n=yield se(a.json().catch(()=>({}))))||void 0===n?void 0:n.executionId);if(!l)return yield yield se(this.formatError("Execution Error","No execution ID received from server")),yield se(void 0);console.log("[WorkflowSocketProvider] Execution started:",l),(null===(i=this.config)||void 0===i?void 0:i.onExecutionStart)&&this.config.onExecutionStart(l,this.config.workflowId),this.subscribeToExecution(l);const c=new Promise((t,e)=>{this.activeExecutions.set(l,{messages:[],resolve:t,reject:e,completed:!1}),setTimeout(()=>{const n=this.activeExecutions.get(l);n&&!n.completed&&(n.completed=!0,n.messages.length>0?t(n.messages.join("\n\n")):e(new Error("Execution timeout")),this.activeExecutions.delete(l))},this.config.responseTimeout)}),d=this.activeExecutions.get(l);let h=0;const u=setInterval(()=>{d.messages.length>h&&(h=d.messages.length)},100);try{for(;!d.completed;){if(d.messages.length>0){const t=d.messages.join("\n\n");yield yield se(t)}yield se(new Promise(t=>setTimeout(t,200)))}clearInterval(u);const t=yield se(c);yield yield se(t)}catch(t){throw clearInterval(u),t}}catch(t){const e=t instanceof Error?t.message:String(t);yield yield se(this.formatError("Workflow Error",e)),this.onError(t instanceof Error?t:new Error(String(t)))}})}buildInput(t,e){var n,i,o;if(null===(n=this.config)||void 0===n?void 0:n.buildInput)return this.config.buildInput(t,e);console.log("[WorkflowSocketProvider] buildInput context.uploadedFiles:",e.uploadedFiles);const r=(null===(i=e.currentThread)||void 0===i?void 0:i.id)||this.sessionId,s={message:t,threadId:r,modules:e.selectedModules,metadata:e.metadata,files:(null===(o=e.uploadedFiles)||void 0===o?void 0:o.map(t=>{var e;return{id:t.id,name:t.name,type:t.type,mimeType:t.mimeType,url:t.url,base64:null===(e=t.metadata)||void 0===e?void 0:e.base64}}))||[]};return console.log("[WorkflowSocketProvider] buildInput threadId:",r,"files count:",s.files.length),s}setWorkflowId(t){this.config&&(this.socket&&this.config.workflowId&&this.socket.emit("unsubscribe:workflow",{workflowId:this.config.workflowId}),this.config.workflowId=t,this.socket&&this.connected&&this.subscribeToWorkflow(t))}getSocket(){return this.socket}uploadFile(t){return re(this,void 0,void 0,function*(){const e=`file-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,n=URL.createObjectURL(t),i=yield this.fileToBase64(t),o=t.type||"application/octet-stream",r=this.determineFileType(o);return console.log(`[WorkflowSocketProvider] File prepared: ${t.name} (${t.size} bytes)`),{id:e,name:t.name,size:t.size,type:r,mimeType:o,url:n,previewUrl:r===U.Image?n:void 0,uploadProgress:100,metadata:{provider:"workflow-socket",uploadedAt:(new Date).toISOString(),base64:i}}})}fileToBase64(t){return new Promise((e,n)=>{const i=new FileReader;i.onload=()=>{const t=i.result,n=t.split(",")[1]||t;e(n)},i.onerror=n,i.readAsDataURL(t)})}determineFileType(t){return t.startsWith("image/")?U.Image:t.startsWith("video/")?U.Video:t.startsWith("audio/")?U.Audio:t.startsWith("application/pdf")||t.includes("document")||t.startsWith("text/")?U.Document:t.includes("zip")||t.includes("rar")||t.includes("tar")?U.Archive:t.includes("javascript")||t.includes("json")||t.includes("xml")?U.Code:U.Unknown}formatError(t,e){return`[ERROR_START][ERROR_TITLE_START]${t}[ERROR_TITLE_END]${e}[ERROR_END]`}onError(t){console.error("[WorkflowSocketProvider] Error:",t)}}
|
|
2478
|
+
*/var ue=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})},pe=function(t){return this instanceof pe?(this.v=t,this):new pe(t)},fe=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,o=n.apply(t,e||[]),s=[];return i=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),r("next"),r("throw"),r("return",function(t){return function(e){return Promise.resolve(e).then(t,d)}}),i[Symbol.asyncIterator]=function(){return this},i;function r(t,e){o[t]&&(i[t]=function(e){return new Promise(function(n,i){s.push([t,e,n,i])>1||a(t,e)})},e&&(i[t]=e(i[t])))}function a(t,e){try{(n=o[t](e)).value instanceof pe?Promise.resolve(n.value.v).then(l,d):c(s[0][2],n)}catch(t){c(s[0][3],t)}var n}function l(t){a("next",t)}function d(t){a("throw",t)}function c(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}};class ge{constructor(){this.id="workflow-socket",this.name="Workflow Socket Provider",this.capabilities={streaming:!0,fileUpload:!0,modules:!0,functions:!1},this.socket=null,this.config=null,this.connected=!1,this.sessionId=`session_${Date.now()}_${Math.random().toString(36).substring(2,11)}`,this.activeExecutions=new Map}connect(t){return ue(this,void 0,void 0,function*(){if(!t.workflowId)throw new Error("Workflow ID is required");this.config=Object.assign({socketUrl:t.socketUrl||("undefined"!=typeof window?window.location.origin:"http://localhost:8000"),socketPath:t.socketPath||"/__nk_socketio/",triggerEndpoint:t.triggerEndpoint||"/api/v1/workflows/{workflowId}/trigger/chat",responseTimeout:t.responseTimeout||6e4},t);const e=`${this.config.socketUrl}/nk/apps/workflows/socket`;return this.socket=c(e,{path:this.config.socketPath,query:{l:JSON.stringify({workflowId:this.config.workflowId})},transports:["websocket","polling"],autoConnect:!0,reconnection:!0,reconnectionAttempts:5}),new Promise((t,e)=>{const n=setTimeout(()=>{e(new Error("Socket connection timeout"))},1e4);this.socket.on("connect",()=>{clearTimeout(n),this.connected=!0,console.log("[WorkflowSocketProvider] Connected:",this.socket.id),this.subscribeToWorkflow(this.config.workflowId),t()}),this.socket.on("connect_error",t=>{clearTimeout(n),console.error("[WorkflowSocketProvider] Connection error:",t),e(t)}),this.socket.on("disconnect",t=>{this.connected=!1,console.log("[WorkflowSocketProvider] Disconnected:",t)}),this.setupEventListeners()})})}subscribeToWorkflow(t){this.socket&&(this.socket.emit("nk:subscribe:workflow",{workflowId:t}),console.log("[WorkflowSocketProvider] Subscribed to workflow:",t))}subscribeToExecution(t){this.socket&&(this.socket.emit("nk:subscribe:execution",{executionId:t}),console.log("[WorkflowSocketProvider] Subscribed to execution:",t))}setupEventListeners(){this.socket&&(this.socket.onAny((t,...e)=>{console.log("[WorkflowSocketProvider] RAW event:",t,e[0])}),this.socket.on("nk:data",t=>{(null==t?void 0:t.event)&&t.data&&this._handleEvent(t.event,t.data)}),this.socket.on("execution:chat-message",t=>this._handleEvent("execution:chat-message",t)),this.socket.on("execution:started",t=>this._handleEvent("execution:started",t)),this.socket.on("execution:completed",t=>this._handleEvent("execution:completed",t)),this.socket.on("execution:failed",t=>this._handleEvent("execution:failed",t)),this.socket.on("execution:node-started",t=>this._handleEvent("execution:node-started",t)),this.socket.on("execution:node-completed",t=>this._handleEvent("execution:node-completed",t)))}_handleEvent(t,e){var n,i,o,s,r;switch(t){case"execution:chat-message":{const t=e.executionId,o=e.message;if(console.log("[WorkflowSocketProvider] Chat message received:",t,o),!t||!o)return;const s=this.activeExecutions.get(t);if(!s)return void(null===(i=null===(n=this.config)||void 0===n?void 0:n.onMessage)||void 0===i||i.call(n,o));s.completed||s.messages.push(o);break}case"execution:started":console.log("[WorkflowSocketProvider] Execution started (event):",e.executionId);break;case"execution:completed":{const t=e.executionId;if(console.log("[WorkflowSocketProvider] Execution completed:",t),!t)return;const n=this.activeExecutions.get(t);if(!n||n.completed)return;n.completed=!0;let i="";if(null===(o=this.config)||void 0===o?void 0:o.extractResponse)i=this.config.extractResponse(e);else if(n.messages.length>0)i=n.messages.join("\n\n");else if(e.outputData)try{const t="string"==typeof e.outputData?JSON.parse(e.outputData):e.outputData;i=t.response||t.message||t.result||JSON.stringify(t)}catch(t){i=e.outputData}n.resolve(i||"Workflow completed"),this.activeExecutions.delete(t);break}case"execution:failed":{const t=e.executionId,n=e.errorMessage||e.error||"Workflow execution failed";if(console.error("[WorkflowSocketProvider] Execution failed:",t,n),!t)return;const i=this.activeExecutions.get(t);if(!i||i.completed)return;i.completed=!0,i.reject(new Error(n)),this.activeExecutions.delete(t);break}case"execution:node-started":console.log("[WorkflowSocketProvider] Node started:",e.nodeName),e.nodeName&&(null===(s=this.onNodeStarted)||void 0===s||s.call(this,e.nodeName));break;case"execution:node-completed":console.log("[WorkflowSocketProvider] Node completed:",e.nodeName),e.nodeName&&(null===(r=this.onNodeCompleted)||void 0===r||r.call(this,e.nodeName))}}disconnect(){return ue(this,void 0,void 0,function*(){var t;this.socket&&((null===(t=this.config)||void 0===t?void 0:t.workflowId)&&this.socket.emit("nk:unsubscribe:workflow",{workflowId:this.config.workflowId}),this.socket.disconnect(),this.socket=null),this.connected=!1,this.activeExecutions.clear(),console.log("[WorkflowSocketProvider] Disconnected")})}isConnected(){var t;return this.connected&&!0===(null===(t=this.socket)||void 0===t?void 0:t.connected)}sendMessage(t,e){return fe(this,arguments,function*(){var n,i;if(!this.connected||!this.socket||!this.config)return yield yield pe(this.formatError("Not Connected","Socket is not connected. Please check your connection.")),yield pe(void 0);try{const o=this.buildInput(t,e),s=this.config.triggerEndpoint.replace("{workflowId}",this.config.workflowId),r=`${this.config.socketUrl}${s}`;console.log("[WorkflowSocketProvider] Triggering workflow:",r,o);const a=yield pe(fetch(r,{method:"POST",headers:Object.assign({"Content-Type":"application/json"},this.config.headers),body:JSON.stringify(o)}));if(!a.ok){const t=yield pe(a.text().catch(()=>a.statusText));return yield yield pe(this.formatError(`${a.status} ${a.statusText}`,t)),yield pe(void 0)}const l=a.headers.get("X-Execution-Id")||(null===(n=yield pe(a.json().catch(()=>({}))))||void 0===n?void 0:n.executionId);if(!l)return yield yield pe(this.formatError("Execution Error","No execution ID received from server")),yield pe(void 0);console.log("[WorkflowSocketProvider] Execution started:",l),(null===(i=this.config)||void 0===i?void 0:i.onExecutionStart)&&this.config.onExecutionStart(l,this.config.workflowId),this.subscribeToExecution(l);const d=new Promise((t,e)=>{this.activeExecutions.set(l,{messages:[],resolve:t,reject:e,completed:!1}),setTimeout(()=>{const n=this.activeExecutions.get(l);n&&!n.completed&&(n.completed=!0,n.messages.length>0?t(n.messages.join("\n\n")):e(new Error("Execution timeout")),this.activeExecutions.delete(l))},this.config.responseTimeout)}),c=this.activeExecutions.get(l);let h=0;const u=setInterval(()=>{c.messages.length>h&&(h=c.messages.length)},100);try{for(;!c.completed;){if(c.messages.length>0){const t=c.messages.join("\n\n");yield yield pe(t)}yield pe(new Promise(t=>setTimeout(t,200)))}clearInterval(u);const t=yield pe(d);yield yield pe(t)}catch(t){throw clearInterval(u),t}}catch(t){const e=t instanceof Error?t.message:String(t);yield yield pe(this.formatError("Workflow Error",e)),this.onError(t instanceof Error?t:new Error(String(t)))}})}buildInput(t,e){var n,i,o;if(null===(n=this.config)||void 0===n?void 0:n.buildInput)return this.config.buildInput(t,e);console.log("[WorkflowSocketProvider] buildInput context.uploadedFiles:",e.uploadedFiles);const s=(null===(i=e.currentThread)||void 0===i?void 0:i.id)||this.sessionId,r={message:t,threadId:s,modules:e.selectedModules,metadata:e.metadata,files:(null===(o=e.uploadedFiles)||void 0===o?void 0:o.map(t=>{var e;return{id:t.id,name:t.name,type:t.type,mimeType:t.mimeType,url:t.url,base64:null===(e=t.metadata)||void 0===e?void 0:e.base64}}))||[]};return console.log("[WorkflowSocketProvider] buildInput threadId:",s,"files count:",r.files.length),r}setWorkflowId(t){this.config&&(this.socket&&this.config.workflowId&&this.socket.emit("nk:unsubscribe:workflow",{workflowId:this.config.workflowId}),this.config.workflowId=t,this.socket&&this.connected&&this.subscribeToWorkflow(t))}getSocket(){return this.socket}uploadFile(t){return ue(this,void 0,void 0,function*(){const e=`file-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,n=URL.createObjectURL(t),i=yield this.fileToBase64(t),o=t.type||"application/octet-stream",s=this.determineFileType(o);return console.log(`[WorkflowSocketProvider] File prepared: ${t.name} (${t.size} bytes)`),{id:e,name:t.name,size:t.size,type:s,mimeType:o,url:n,previewUrl:s===Y.Image?n:void 0,uploadProgress:100,metadata:{provider:"workflow-socket",uploadedAt:(new Date).toISOString(),base64:i}}})}fileToBase64(t){return new Promise((e,n)=>{const i=new FileReader;i.onload=()=>{const t=i.result,n=t.split(",")[1]||t;e(n)},i.onerror=n,i.readAsDataURL(t)})}determineFileType(t){return t.startsWith("image/")?Y.Image:t.startsWith("video/")?Y.Video:t.startsWith("audio/")?Y.Audio:t.startsWith("application/pdf")||t.includes("document")||t.startsWith("text/")?Y.Document:t.includes("zip")||t.includes("rar")||t.includes("tar")?Y.Archive:t.includes("javascript")||t.includes("json")||t.includes("xml")?Y.Code:Y.Unknown}formatError(t,e){return`[ERROR_START][ERROR_TITLE_START]${t}[ERROR_TITLE_END]${e}[ERROR_END]`}onError(t){console.error("[WorkflowSocketProvider] Error:",t)}}
|
|
2463
2479
|
/**
|
|
2464
2480
|
* @license
|
|
2465
2481
|
* Copyright 2024 Nuraly, Laabidi Aymen
|
|
2466
2482
|
* SPDX-License-Identifier: MIT
|
|
2467
|
-
*/var ce=function(t,e,n,i){return new(n||(n=Promise))(function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((i=i.apply(t,e||[])).next())})},de=function(t){return this instanceof de?(this.v=t,this):new de(t)},he=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,o=n.apply(t,e||[]),r=[];return i=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",function(t){return function(e){return Promise.resolve(e).then(t,c)}}),i[Symbol.asyncIterator]=function(){return this},i;function s(t,e){o[t]&&(i[t]=function(e){return new Promise(function(n,i){r.push([t,e,n,i])>1||a(t,e)})},e&&(i[t]=e(i[t])))}function a(t,e){try{(n=o[t](e)).value instanceof de?Promise.resolve(n.value.v).then(l,c):d(r[0][2],n)}catch(t){d(r[0][3],t)}var n}function l(t){a("next",t)}function c(t){a("throw",t)}function d(t,e){t(e),r.shift(),r.length&&a(r[0][0],r[0][1])}};const ue={send:"message:send",response:"message:response",stream:"message:stream",error:"message:error",typingStart:"typing:start",typingEnd:"typing:end",ping:"ping",pong:"pong",toolCall:"tool:call",toolCallEnd:"tool:end"};class pe{constructor(){this.id="native-websocket",this.name="Native WebSocket Provider",this.capabilities={streaming:!0,fileUpload:!1,modules:!1,functions:!1},this.ws=null,this.config=null,this.connected=!1,this.responseResolvers=new Map,this.reconnectAttempt=0,this.reconnectTimer=null,this.heartbeatTimer=null,this.pongTimer=null,this.intentionalClose=!1,this.messageListeners=new Map}connect(t){return ce(this,void 0,void 0,function*(){var e,n,i,o,r,s,a,l,c,d;if(!t.url)throw new Error("WebSocket URL is required");return this.config=Object.assign(Object.assign({},t),{messageTypes:Object.assign(Object.assign({},ue),t.messageTypes),typeField:null!==(e=t.typeField)&&void 0!==e?e:"type",autoReconnect:null===(n=t.autoReconnect)||void 0===n||n,maxReconnectAttempts:null!==(i=t.maxReconnectAttempts)&&void 0!==i?i:5,reconnectBaseDelay:null!==(o=t.reconnectBaseDelay)&&void 0!==o?o:1e3,reconnectMaxDelay:null!==(r=t.reconnectMaxDelay)&&void 0!==r?r:3e4,connectionTimeout:null!==(s=t.connectionTimeout)&&void 0!==s?s:1e4,responseTimeout:null!==(a=t.responseTimeout)&&void 0!==a?a:3e4,enableHeartbeat:null===(l=t.enableHeartbeat)||void 0===l||l,heartbeatInterval:null!==(c=t.heartbeatInterval)&&void 0!==c?c:3e4,heartbeatTimeout:null!==(d=t.heartbeatTimeout)&&void 0!==d?d:1e4}),this.intentionalClose=!1,this.reconnectAttempt=0,this.createConnection()})}createConnection(){return new Promise((t,e)=>{const n=this.config;if(!n)return void e(new Error("Provider not configured"));const i=this.buildUrl();try{this.ws=n.protocols?new WebSocket(i,n.protocols):new WebSocket(i)}catch(t){return void e(new Error(`Failed to create WebSocket: ${t instanceof Error?t.message:String(t)}`))}const o=setTimeout(()=>{this.ws&&this.ws.readyState!==WebSocket.OPEN&&(this.ws.close(),e(new Error("WebSocket connection timeout")))},n.connectionTimeout);this.ws.onopen=()=>{var e,n;clearTimeout(o),this.connected=!0,this.reconnectAttempt=0,console.log("[NativeWebSocketProvider] Connected"),null===(n=null===(e=this.config)||void 0===e?void 0:e.onConnectionChange)||void 0===n||n.call(e,!0),this.startHeartbeat(),t()},this.ws.onclose=t=>{var n,i;clearTimeout(o);const r=this.connected;this.connected=!1,this.stopHeartbeat(),console.log("[NativeWebSocketProvider] Disconnected:",t.code,t.reason),r&&(null===(i=null===(n=this.config)||void 0===n?void 0:n.onConnectionChange)||void 0===i||i.call(n,!1));for(const[t,e]of this.responseResolvers)e.chunks.length>0?e.resolve(e.chunks.join("")):e.reject(new Error("WebSocket connection closed")),this.responseResolvers.delete(t);!this.intentionalClose&&r?this.attemptReconnect():r||e(new Error(`WebSocket connection failed (code: ${t.code})`))},this.ws.onerror=t=>{console.error("[NativeWebSocketProvider] Error:",t)},this.ws.onmessage=t=>{this.handleMessage(t)}})}buildUrl(){const t=this.config;if(!t)return"";let e=t.url;const n=t.queryParams;if(n&&Object.keys(n).length>0){const t=e.includes("?")?"&":"?";e=`${e}${t}${Object.entries(n).map(([t,e])=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join("&")}`}return e}handleMessage(t){var e,n,i;if(!this.config)return;const o=this.parseMessageData(t.data);if(!o)return;const r=o[null!==(e=this.config.typeField)&&void 0!==e?e:"type"],s=this.config.messageTypes;if(r!==s.pong)if(r!==s.ping){if(r===s.toolCall){const t=o.name||o.toolName||o.function||"unknown";return null===(n=this.onToolCall)||void 0===n||n.call(this,t),void this.dispatchToListeners(r,o)}if(r===s.toolCallEnd)return null===(i=this.onToolCallEnd)||void 0===i||i.call(this),void this.dispatchToListeners(r,o);this.dispatchToListeners(r,o),r!==s.response?r!==s.stream?r===s.error&&this.handleErrorMessage(o):this.handleStreamMessage(o):this.handleResponseMessage(o)}else this.send(s.pong,{timestamp:Date.now()});else this.handlePong()}parseMessageData(t){try{return"string"==typeof t?JSON.parse(t):t}catch(e){return console.warn("[NativeWebSocketProvider] Non-JSON message received:",t),null}}dispatchToListeners(t,e){if(!t)return;const n=this.messageListeners.get(t);if(n)for(const t of n)try{t(e)}catch(t){console.error("[NativeWebSocketProvider] Listener error:",t)}}handleResponseMessage(t){const e=this.extractMessageId(t),n=this.responseResolvers.get(e)||this.getLatestResolver();if(n){const i=this.extractMessageContent(t);n.resolve(i),this.responseResolvers.delete(e)}}handleStreamMessage(t){const e=this.extractMessageId(t),n=this.responseResolvers.get(e)||this.getLatestResolver();if(n){n.isStreaming=!0;const e=this.extractMessageContent(t);n.chunks.push(e)}}handleErrorMessage(t){const e=this.extractMessageId(t),n=this.responseResolvers.get(e)||this.getLatestResolver();if(n){const i=t.error||t.message||"Unknown error";n.reject(new Error(i)),this.responseResolvers.delete(e)}}getLatestResolver(){const t=Array.from(this.responseResolvers.keys()).at(-1);return void 0!==t?this.responseResolvers.get(t):null}extractMessageId(t){return t.messageId||t.id||t.executionId||"default"}extractMessageContent(t){var e,n,i;return(null===(e=this.config)||void 0===e?void 0:e.extractMessage)?this.config.extractMessage(t):"string"==typeof t?t:t.message?t.message:t.text?t.text:t.response?t.response:t.content?t.content:(null===(n=t.data)||void 0===n?void 0:n.message)?t.data.message:(null===(i=t.data)||void 0===i?void 0:i.output)?JSON.stringify(t.data.output):JSON.stringify(t)}startHeartbeat(){var t;if(!(null===(t=this.config)||void 0===t?void 0:t.enableHeartbeat))return;this.stopHeartbeat();const e=this.config.messageTypes;this.heartbeatTimer=setInterval(()=>{var t,n,i;this.connected&&(null===(t=this.ws)||void 0===t?void 0:t.readyState)===WebSocket.OPEN&&(this.send(e.ping,{timestamp:Date.now()}),this.pongTimer=setTimeout(()=>{var t;console.warn("[NativeWebSocketProvider] Heartbeat timeout — closing connection"),null===(t=this.ws)||void 0===t||t.close(4e3,"Heartbeat timeout")},null!==(i=null===(n=this.config)||void 0===n?void 0:n.heartbeatTimeout)&&void 0!==i?i:1e4))},this.config.heartbeatInterval)}handlePong(){this.pongTimer&&(clearTimeout(this.pongTimer),this.pongTimer=null)}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.pongTimer&&(clearTimeout(this.pongTimer),this.pongTimer=null)}attemptReconnect(){var t,e,n,i,o,r;if(!(null===(t=this.config)||void 0===t?void 0:t.autoReconnect))return;const s=null!==(e=this.config.maxReconnectAttempts)&&void 0!==e?e:5;if(this.reconnectAttempt>=s)return void console.error("[NativeWebSocketProvider] Max reconnection attempts reached");this.reconnectAttempt++;const a=null!==(n=this.config.reconnectBaseDelay)&&void 0!==n?n:1e3,l=null!==(i=this.config.reconnectMaxDelay)&&void 0!==i?i:3e4,c=Math.min(a*Math.pow(2,this.reconnectAttempt-1)+Math.random()*a,l);console.log(`[NativeWebSocketProvider] Reconnecting in ${Math.round(c)}ms (attempt ${this.reconnectAttempt}/${s})`),null===(r=(o=this.config).onReconnectAttempt)||void 0===r||r.call(o,this.reconnectAttempt,s),this.reconnectTimer=setTimeout(()=>ce(this,void 0,void 0,function*(){try{yield this.createConnection(),console.log("[NativeWebSocketProvider] Reconnected successfully")}catch(t){}}),c)}disconnect(){return ce(this,void 0,void 0,function*(){this.intentionalClose=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.stopHeartbeat(),this.ws&&(this.ws.close(1e3,"Client disconnect"),this.ws=null),this.connected=!1,this.responseResolvers.clear(),this.messageListeners.clear(),console.log("[NativeWebSocketProvider] Disconnected")})}isConnected(){var t;return this.connected&&(null===(t=this.ws)||void 0===t?void 0:t.readyState)===WebSocket.OPEN}sendMessage(t,e){return he(this,arguments,function*(){if(!this.connected||!this.ws||!this.config)return yield yield de(this.formatError("Not Connected","WebSocket is not connected. Please check your connection.")),yield de(void 0);const n=`msg_${Date.now()}_${crypto.randomUUID().slice(0,9)}`,i=this.buildPayload(t,e,n);try{const t=new Promise((t,e)=>{var i,o;this.responseResolvers.set(n,{resolve:t,reject:e,chunks:[],isStreaming:!1}),setTimeout(()=>{const i=this.responseResolvers.get(n);i&&(i.chunks.length>0?t(i.chunks.join("")):e(new Error("Response timeout")),this.responseResolvers.delete(n))},null!==(o=null===(i=this.config)||void 0===i?void 0:i.responseTimeout)&&void 0!==o?o:3e4)}),e=this.config.messageTypes;if(this.send(e.send,Object.assign(Object.assign({},i),{messageId:n})),this.config.messageTypes.stream){const e=this.responseResolvers.get(n);let i=0;const o=setInterval(()=>{e&&e.chunks.length>i&&(i=e.chunks.length)},50);try{const e=yield de(t);clearInterval(o),yield yield de(e)}catch(t){throw clearInterval(o),t}}else{const e=yield de(t);yield yield de(e)}}catch(t){const e=t instanceof Error?t.message:String(t);yield yield de(this.formatError("WebSocket Error",e)),this.onError(t instanceof Error?t:new Error(String(t)))}})}send(t,e){var n;if(this.ws&&this.ws.readyState===WebSocket.OPEN&&this.config){const i=null!==(n=this.config.typeField)&&void 0!==n?n:"type",o=Object.assign({[i]:t},e);this.ws.send(JSON.stringify(o))}}onMessage(t,e){var n;return this.messageListeners.has(t)||this.messageListeners.set(t,new Set),null===(n=this.messageListeners.get(t))||void 0===n||n.add(e),()=>{const n=this.messageListeners.get(t);n&&(n.delete(e),0===n.size&&this.messageListeners.delete(t))}}getWebSocket(){return this.ws}buildPayload(t,e,n){var i,o,r;if(null===(i=this.config)||void 0===i?void 0:i.buildPayload){const i=this.config.buildPayload(t,e);return Object.assign(Object.assign({},i),{messageId:n})}return{messageId:n,message:t,text:t,threadId:null===(o=e.currentThread)||void 0===o?void 0:o.id,modules:e.selectedModules,metadata:e.metadata,files:null===(r=e.uploadedFiles)||void 0===r?void 0:r.map(t=>({id:t.id,name:t.name,type:t.type,url:t.url}))}}formatError(t,e){return`[ERROR_START][ERROR_TITLE_START]${t}[ERROR_TITLE_END]${e}[ERROR_END]`}onError(t){console.error("[NativeWebSocketProvider] Error:",t)}}
|
|
2483
|
+
*/var me=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})},ve=function(t){return this instanceof ve?(this.v=t,this):new ve(t)},be=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,o=n.apply(t,e||[]),s=[];return i=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),r("next"),r("throw"),r("return",function(t){return function(e){return Promise.resolve(e).then(t,d)}}),i[Symbol.asyncIterator]=function(){return this},i;function r(t,e){o[t]&&(i[t]=function(e){return new Promise(function(n,i){s.push([t,e,n,i])>1||a(t,e)})},e&&(i[t]=e(i[t])))}function a(t,e){try{(n=o[t](e)).value instanceof ve?Promise.resolve(n.value.v).then(l,d):c(s[0][2],n)}catch(t){c(s[0][3],t)}var n}function l(t){a("next",t)}function d(t){a("throw",t)}function c(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}};const ye={send:"message:send",response:"message:response",stream:"message:stream",error:"message:error",typingStart:"typing:start",typingEnd:"typing:end",ping:"ping",pong:"pong",toolCall:"tool:call",toolCallEnd:"tool:end"};class xe{constructor(){this.id="native-websocket",this.name="Native WebSocket Provider",this.capabilities={streaming:!0,fileUpload:!1,modules:!1,functions:!1},this.ws=null,this.config=null,this.connected=!1,this.responseResolvers=new Map,this.reconnectAttempt=0,this.reconnectTimer=null,this.heartbeatTimer=null,this.pongTimer=null,this.intentionalClose=!1,this.messageListeners=new Map}connect(t){return me(this,void 0,void 0,function*(){var e,n,i,o,s,r,a,l,d,c;if(!t.url)throw new Error("WebSocket URL is required");return this.config=Object.assign(Object.assign({},t),{messageTypes:Object.assign(Object.assign({},ye),t.messageTypes),typeField:null!==(e=t.typeField)&&void 0!==e?e:"type",autoReconnect:null===(n=t.autoReconnect)||void 0===n||n,maxReconnectAttempts:null!==(i=t.maxReconnectAttempts)&&void 0!==i?i:5,reconnectBaseDelay:null!==(o=t.reconnectBaseDelay)&&void 0!==o?o:1e3,reconnectMaxDelay:null!==(s=t.reconnectMaxDelay)&&void 0!==s?s:3e4,connectionTimeout:null!==(r=t.connectionTimeout)&&void 0!==r?r:1e4,responseTimeout:null!==(a=t.responseTimeout)&&void 0!==a?a:3e4,enableHeartbeat:null===(l=t.enableHeartbeat)||void 0===l||l,heartbeatInterval:null!==(d=t.heartbeatInterval)&&void 0!==d?d:3e4,heartbeatTimeout:null!==(c=t.heartbeatTimeout)&&void 0!==c?c:1e4}),this.intentionalClose=!1,this.reconnectAttempt=0,this.createConnection()})}createConnection(){return new Promise((t,e)=>{const n=this.config;if(!n)return void e(new Error("Provider not configured"));const i=this.buildUrl();try{this.ws=n.protocols?new WebSocket(i,n.protocols):new WebSocket(i)}catch(t){return void e(new Error(`Failed to create WebSocket: ${t instanceof Error?t.message:String(t)}`))}const o=setTimeout(()=>{this.ws&&this.ws.readyState!==WebSocket.OPEN&&(this.ws.close(),e(new Error("WebSocket connection timeout")))},n.connectionTimeout);this.ws.onopen=()=>{var e,n;clearTimeout(o),this.connected=!0,this.reconnectAttempt=0,console.log("[NativeWebSocketProvider] Connected"),null===(n=null===(e=this.config)||void 0===e?void 0:e.onConnectionChange)||void 0===n||n.call(e,!0),this.startHeartbeat(),t()},this.ws.onclose=t=>{var n,i;clearTimeout(o);const s=this.connected;this.connected=!1,this.stopHeartbeat(),console.log("[NativeWebSocketProvider] Disconnected:",t.code,t.reason),s&&(null===(i=null===(n=this.config)||void 0===n?void 0:n.onConnectionChange)||void 0===i||i.call(n,!1));for(const[t,e]of this.responseResolvers)e.chunks.length>0?e.resolve(e.chunks.join("")):e.reject(new Error("WebSocket connection closed")),this.responseResolvers.delete(t);!this.intentionalClose&&s?this.attemptReconnect():s||e(new Error(`WebSocket connection failed (code: ${t.code})`))},this.ws.onerror=t=>{console.error("[NativeWebSocketProvider] Error:",t)},this.ws.onmessage=t=>{this.handleMessage(t)}})}buildUrl(){const t=this.config;if(!t)return"";let e=t.url;const n=t.queryParams;if(n&&Object.keys(n).length>0){const t=e.includes("?")?"&":"?";e=`${e}${t}${Object.entries(n).map(([t,e])=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join("&")}`}return e}handleMessage(t){var e,n,i;if(!this.config)return;const o=this.parseMessageData(t.data);if(!o)return;const s=o[null!==(e=this.config.typeField)&&void 0!==e?e:"type"],r=this.config.messageTypes;if(s!==r.pong)if(s!==r.ping){if(s===r.toolCall){const t=o.name||o.toolName||o.function||"unknown";return null===(n=this.onToolCall)||void 0===n||n.call(this,t),void this.dispatchToListeners(s,o)}if(s===r.toolCallEnd)return null===(i=this.onToolCallEnd)||void 0===i||i.call(this),void this.dispatchToListeners(s,o);this.dispatchToListeners(s,o),s!==r.response?s!==r.stream?s===r.error&&this.handleErrorMessage(o):this.handleStreamMessage(o):this.handleResponseMessage(o)}else this.send(r.pong,{timestamp:Date.now()});else this.handlePong()}parseMessageData(t){try{return"string"==typeof t?JSON.parse(t):t}catch(e){return console.warn("[NativeWebSocketProvider] Non-JSON message received:",t),null}}dispatchToListeners(t,e){if(!t)return;const n=this.messageListeners.get(t);if(n)for(const t of n)try{t(e)}catch(t){console.error("[NativeWebSocketProvider] Listener error:",t)}}handleResponseMessage(t){const e=this.extractMessageId(t),n=this.responseResolvers.get(e)||this.getLatestResolver();if(n){const i=this.extractMessageContent(t);n.resolve(i),this.responseResolvers.delete(e)}}handleStreamMessage(t){const e=this.extractMessageId(t),n=this.responseResolvers.get(e)||this.getLatestResolver();if(n){n.isStreaming=!0;const e=this.extractMessageContent(t);n.chunks.push(e)}}handleErrorMessage(t){const e=this.extractMessageId(t),n=this.responseResolvers.get(e)||this.getLatestResolver();if(n){const i=t.error||t.message||"Unknown error";n.reject(new Error(i)),this.responseResolvers.delete(e)}}getLatestResolver(){const t=Array.from(this.responseResolvers.keys()).at(-1);return void 0!==t?this.responseResolvers.get(t):null}extractMessageId(t){return t.messageId||t.id||t.executionId||"default"}extractMessageContent(t){var e,n,i;return(null===(e=this.config)||void 0===e?void 0:e.extractMessage)?this.config.extractMessage(t):"string"==typeof t?t:t.message?t.message:t.text?t.text:t.response?t.response:t.content?t.content:(null===(n=t.data)||void 0===n?void 0:n.message)?t.data.message:(null===(i=t.data)||void 0===i?void 0:i.output)?JSON.stringify(t.data.output):JSON.stringify(t)}startHeartbeat(){var t;if(!(null===(t=this.config)||void 0===t?void 0:t.enableHeartbeat))return;this.stopHeartbeat();const e=this.config.messageTypes;this.heartbeatTimer=setInterval(()=>{var t,n,i;this.connected&&(null===(t=this.ws)||void 0===t?void 0:t.readyState)===WebSocket.OPEN&&(this.send(e.ping,{timestamp:Date.now()}),this.pongTimer=setTimeout(()=>{var t;console.warn("[NativeWebSocketProvider] Heartbeat timeout — closing connection"),null===(t=this.ws)||void 0===t||t.close(4e3,"Heartbeat timeout")},null!==(i=null===(n=this.config)||void 0===n?void 0:n.heartbeatTimeout)&&void 0!==i?i:1e4))},this.config.heartbeatInterval)}handlePong(){this.pongTimer&&(clearTimeout(this.pongTimer),this.pongTimer=null)}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.pongTimer&&(clearTimeout(this.pongTimer),this.pongTimer=null)}attemptReconnect(){var t,e,n,i,o,s;if(!(null===(t=this.config)||void 0===t?void 0:t.autoReconnect))return;const r=null!==(e=this.config.maxReconnectAttempts)&&void 0!==e?e:5;if(this.reconnectAttempt>=r)return void console.error("[NativeWebSocketProvider] Max reconnection attempts reached");this.reconnectAttempt++;const a=null!==(n=this.config.reconnectBaseDelay)&&void 0!==n?n:1e3,l=null!==(i=this.config.reconnectMaxDelay)&&void 0!==i?i:3e4,d=Math.min(a*Math.pow(2,this.reconnectAttempt-1)+Math.random()*a,l);console.log(`[NativeWebSocketProvider] Reconnecting in ${Math.round(d)}ms (attempt ${this.reconnectAttempt}/${r})`),null===(s=(o=this.config).onReconnectAttempt)||void 0===s||s.call(o,this.reconnectAttempt,r),this.reconnectTimer=setTimeout(()=>me(this,void 0,void 0,function*(){try{yield this.createConnection(),console.log("[NativeWebSocketProvider] Reconnected successfully")}catch(t){}}),d)}disconnect(){return me(this,void 0,void 0,function*(){this.intentionalClose=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.stopHeartbeat(),this.ws&&(this.ws.close(1e3,"Client disconnect"),this.ws=null),this.connected=!1,this.responseResolvers.clear(),this.messageListeners.clear(),console.log("[NativeWebSocketProvider] Disconnected")})}isConnected(){var t;return this.connected&&(null===(t=this.ws)||void 0===t?void 0:t.readyState)===WebSocket.OPEN}sendMessage(t,e){return be(this,arguments,function*(){if(!this.connected||!this.ws||!this.config)return yield yield ve(this.formatError("Not Connected","WebSocket is not connected. Please check your connection.")),yield ve(void 0);const n=`msg_${Date.now()}_${crypto.randomUUID().slice(0,9)}`,i=this.buildPayload(t,e,n);try{const t=new Promise((t,e)=>{var i,o;this.responseResolvers.set(n,{resolve:t,reject:e,chunks:[],isStreaming:!1}),setTimeout(()=>{const i=this.responseResolvers.get(n);i&&(i.chunks.length>0?t(i.chunks.join("")):e(new Error("Response timeout")),this.responseResolvers.delete(n))},null!==(o=null===(i=this.config)||void 0===i?void 0:i.responseTimeout)&&void 0!==o?o:3e4)}),e=this.config.messageTypes;if(this.send(e.send,Object.assign(Object.assign({},i),{messageId:n})),this.config.messageTypes.stream){const e=this.responseResolvers.get(n);let i=0;const o=setInterval(()=>{e&&e.chunks.length>i&&(i=e.chunks.length)},50);try{const e=yield ve(t);clearInterval(o),yield yield ve(e)}catch(t){throw clearInterval(o),t}}else{const e=yield ve(t);yield yield ve(e)}}catch(t){const e=t instanceof Error?t.message:String(t);yield yield ve(this.formatError("WebSocket Error",e)),this.onError(t instanceof Error?t:new Error(String(t)))}})}send(t,e){var n;if(this.ws&&this.ws.readyState===WebSocket.OPEN&&this.config){const i=null!==(n=this.config.typeField)&&void 0!==n?n:"type",o=Object.assign({[i]:t},e);this.ws.send(JSON.stringify(o))}}onMessage(t,e){var n;return this.messageListeners.has(t)||this.messageListeners.set(t,new Set),null===(n=this.messageListeners.get(t))||void 0===n||n.add(e),()=>{const n=this.messageListeners.get(t);n&&(n.delete(e),0===n.size&&this.messageListeners.delete(t))}}getWebSocket(){return this.ws}buildPayload(t,e,n){var i,o,s;if(null===(i=this.config)||void 0===i?void 0:i.buildPayload){const i=this.config.buildPayload(t,e);return Object.assign(Object.assign({},i),{messageId:n})}return{messageId:n,message:t,text:t,threadId:null===(o=e.currentThread)||void 0===o?void 0:o.id,modules:e.selectedModules,metadata:e.metadata,files:null===(s=e.uploadedFiles)||void 0===s?void 0:s.map(t=>({id:t.id,name:t.name,type:t.type,url:t.url}))}}formatError(t,e){return`[ERROR_START][ERROR_TITLE_START]${t}[ERROR_TITLE_END]${e}[ERROR_END]`}onError(t){console.error("[NativeWebSocketProvider] Error:",t)}}
|
|
2468
2484
|
/**
|
|
2469
2485
|
* @license
|
|
2470
2486
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2471
2487
|
* SPDX-License-Identifier: MIT
|
|
2472
|
-
*/var
|
|
2488
|
+
*/var we=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class _e{constructor(t,e={}){this.id="persistence",this.name="Persistence Plugin",this.version="1.0.0",this.storage=t,this.storageKey=e.storageKey||"chatbot-state",e.autoSaveInterval&&(this.autoSaveInterval=setInterval(()=>{this.saveState()},e.autoSaveInterval))}onInit(t){this.controller=t,this.loadState(),console.log("[PersistencePlugin] Initialized")}onDestroy(){this.autoSaveInterval&&clearInterval(this.autoSaveInterval),this.saveState(),console.log("[PersistencePlugin] Destroyed")}onStateChange(){this.saveState()}saveState(){return we(this,void 0,void 0,function*(){if(this.controller)try{const t=this.controller.getState();yield this.storage.save(this.storageKey,t),console.log("[PersistencePlugin] State saved")}catch(t){console.error("[PersistencePlugin] Error saving state:",t)}})}loadState(){return we(this,void 0,void 0,function*(){if(this.controller)try{const t=yield this.storage.load(this.storageKey);t&&(this.controller.setState(t),console.log("[PersistencePlugin] State loaded"))}catch(t){console.error("[PersistencePlugin] Error loading state:",t)}})}clearStorage(){return we(this,void 0,void 0,function*(){try{yield this.storage.remove(this.storageKey),console.log("[PersistencePlugin] Storage cleared")}catch(t){console.error("[PersistencePlugin] Error clearing storage:",t)}})}}
|
|
2473
2489
|
/**
|
|
2474
2490
|
* @license
|
|
2475
2491
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2476
2492
|
* SPDX-License-Identifier: MIT
|
|
2477
|
-
*/class
|
|
2493
|
+
*/class $e{constructor(t){this.id="analytics",this.name="Analytics Plugin",this.version="1.0.0",this.trackEvent=t}onInit(){this.trackEvent("chatbot:initialized",{timestamp:(new Date).toISOString()}),console.log("[AnalyticsPlugin] Initialized")}onDestroy(){this.trackEvent("chatbot:destroyed",{timestamp:(new Date).toISOString()}),console.log("[AnalyticsPlugin] Destroyed")}onMessageSent(t){this.trackEvent("chatbot:message:sent",{messageId:t.id,messageLength:t.text.length,hasFiles:!!t.files&&t.files.length>0,timestamp:t.timestamp})}onMessageReceived(t){this.trackEvent("chatbot:message:received",{messageId:t.id,messageLength:t.text.length,sender:t.sender,timestamp:t.timestamp})}onError(t){this.trackEvent("chatbot:error",{error:t.message,stack:t.stack,timestamp:(new Date).toISOString()})}}
|
|
2478
2494
|
/**
|
|
2479
2495
|
* @license
|
|
2480
2496
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2481
2497
|
* SPDX-License-Identifier: MIT
|
|
2482
|
-
*/class
|
|
2498
|
+
*/class ke{constructor(){this._stylesInjected=!1}getOncePerConversationStyleTag(t,e="nr-chatbot"){var n;const i=`data-plugin-styles-${this.id}`;let o=!1;try{const t=document.querySelector(e);o=!!(null===(n=null==t?void 0:t.shadowRoot)||void 0===n?void 0:n.querySelector(`style[${i}]`))}catch(t){}return this._stylesInjected||o?"":(this._stylesInjected=!0,`<style ${i}="true">${t}</style>`)}onStateChange(t){try{const e=null==t?void 0:t.currentThreadId;e!==this._lastThreadId&&(this._lastThreadId=e,this._stylesInjected=!1)}catch(t){}}}
|
|
2483
2499
|
/**
|
|
2484
2500
|
* @license
|
|
2485
2501
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2486
2502
|
* SPDX-License-Identifier: MIT
|
|
2487
|
-
*/var
|
|
2503
|
+
*/var Se=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class Pe extends ke{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(t,e){if("md"!==t)return"";const n=this.getStyles();return`${this.getOncePerConversationStyleTag(n)}${dt(e)}`}afterReceive(t){return Se(this,void 0,void 0,function*(){return t.includes("[MD]")&&t.includes("[/MD]")?t:dt(t)})}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 @media (prefers-color-scheme: dark) {\n .md-code { background: #0f1115; color: #eaeef2; }\n .md-inline-code { background: rgba(255,255,255,.08); }\n }\n "}}
|
|
2488
2504
|
/**
|
|
2489
2505
|
* @license
|
|
2490
2506
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2491
2507
|
* SPDX-License-Identifier: MIT
|
|
2492
|
-
*/var xe=function(t,e,n,i){return new(n||(n=Promise))(function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((i=i.apply(t,e||[])).next())})};class we extends me{constructor(){super(...arguments),this.id="flight-card",this.name="Flight Card Plugin",this.version="1.0.0",this.htmlTags=[{name:"flight",open:"[FLIGHT]",close:"[/FLIGHT]"}],this.cssPrefix="nr-flight-card"}renderHtmlBlockPlaceholder(t){if("flight"!==t.toLowerCase())return"";return`<div data-placeholder-id="${`flight-skeleton-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}"><nr-skeleton \n active \n style="min-width: 400px; max-width: 600px; margin: 16px 0;"\n ></nr-skeleton></div>`}onInit(){console.log("[FlightCardPlugin] Initialized")}afterReceive(t){return xe(this,void 0,void 0,function*(){try{const e=JSON.parse(t);if("flight"===e.type||this.isFlightData(e))return this.renderFlightCard(e)}catch(t){}const e=/\[FLIGHT\]([\s\S]*?)\[\/FLIGHT\]/g;let n,i=t;for(;null!==(n=e.exec(t));)try{const t=JSON.parse(n[1]),e=this.renderFlightCard(t);i=i.replace(n[0],e)}catch(t){console.warn("[FlightCardPlugin] Failed to parse flight data:",t)}return i})}renderHtmlBlock(t,e){if("flight"!==t.toLowerCase())return"";try{const t=JSON.parse(e);return this.renderFlightCard(t)}catch(t){return console.warn("[FlightCardPlugin] renderHtmlBlock parse error:",t),""}}isFlightData(t){return t&&"object"==typeof t&&t.origin&&t.destination&&t.departureTime}renderFlightCard(t){const{origin:e,destination:n,departureTime:i,arrivalTime:o,departureDate:r,arrivalDate:s,terminal:a,gate:l,arrivalTerminal:c,arrivalGate:d,duration:h,flightNumber:u,airline:p,status:f,updated:v,source:g}=t;return`\n ${this.getOncePerConversationStyleTag(this.getStyles())}\n <div class="${this.cssPrefix}" data-nr-flight-card="true">\n <div class="${this.cssPrefix}__header">\n <div class="${this.cssPrefix}__route">\n <span class="${this.cssPrefix}__airport-code">${this.escapeHtml(e)}</span>\n <div class="${this.cssPrefix}__flight-line">\n <svg class="${this.cssPrefix}__plane-icon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M21 16v-2l-8-5V3.5c0-.83-.67-1.5-1.5-1.5S10 2.67 10 3.5V9l-8 5v2l8-2.5V19l-2 1.5V22l3.5-1 3.5 1v-1.5L13 19v-5.5l8 2.5z" fill="currentColor"/>\n </svg>\n ${h?`<span class="${this.cssPrefix}__duration">${this.escapeHtml(h)}</span>`:""}\n </div>\n <span class="${this.cssPrefix}__airport-code">${this.escapeHtml(n)}</span>\n </div>\n ${u||p?`\n <div class="${this.cssPrefix}__flight-info">\n ${p?`<span class="${this.cssPrefix}__airline">${this.escapeHtml(p)}</span>`:""}\n ${u?`<span class="${this.cssPrefix}__flight-number">${this.escapeHtml(u)}</span>`:""}\n </div>\n `:""}\n </div>\n\n <div class="${this.cssPrefix}__details">\n <div class="${this.cssPrefix}__section ${this.cssPrefix}__section--departure">\n <div class="${this.cssPrefix}__label">Infos sur l'aéroport</div>\n <div class="${this.cssPrefix}__location">\n <span class="${this.cssPrefix}__city">${this.getCityName(e)}</span>\n <span class="${this.cssPrefix}__date">${r?this.escapeHtml(r):""}</span>\n </div>\n <div class="${this.cssPrefix}__time-group">\n <div class="${this.cssPrefix}__time-label">Heure de départ prévue</div>\n <div class="${this.cssPrefix}__time-value">${this.escapeHtml(i)}</div>\n </div>\n <div class="${this.cssPrefix}__terminal-gate">\n ${a?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Terminal</span>\n <span class="${this.cssPrefix}__info-value">${this.escapeHtml(a)}</span>\n </div>\n `:""}\n ${l?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Porte</span>\n <span class="${this.cssPrefix}__info-value">${this.escapeHtml(l)}</span>\n </div>\n `:void 0===l?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Porte</span>\n <span class="${this.cssPrefix}__info-value">-</span>\n </div>\n `:""}\n </div>\n </div>\n\n <div class="${this.cssPrefix}__divider"></div>\n\n <div class="${this.cssPrefix}__section ${this.cssPrefix}__section--arrival">\n <div class="${this.cssPrefix}__label">Infos sur l'aéroport</div>\n <div class="${this.cssPrefix}__location">\n <span class="${this.cssPrefix}__city">${this.getCityName(n)}</span>\n <span class="${this.cssPrefix}__date">${s?this.escapeHtml(s):""}</span>\n </div>\n <div class="${this.cssPrefix}__time-group">\n <div class="${this.cssPrefix}__time-label">Heure d'arrivée prévue</div>\n <div class="${this.cssPrefix}__time-value">${this.escapeHtml(o)}</div>\n </div>\n <div class="${this.cssPrefix}__terminal-gate">\n ${c?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Terminal</span>\n <span class="${this.cssPrefix}__info-value">${this.escapeHtml(c)}</span>\n </div>\n `:""}\n ${d?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Porte</span>\n <span class="${this.cssPrefix}__info-value">${this.escapeHtml(d)}</span>\n </div>\n `:void 0===d?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Porte</span>\n <span class="${this.cssPrefix}__info-value">-</span>\n </div>\n `:""}\n </div>\n </div>\n </div>\n\n ${v||g||f?`\n <div class="${this.cssPrefix}__footer">\n ${v?`<span class="${this.cssPrefix}__updated">${this.escapeHtml(v)}</span>`:""}\n ${g?`<span class="${this.cssPrefix}__source">Source : ${this.escapeHtml(g)}</span>`:""}\n ${f?`<span class="${this.cssPrefix}__status">${this.escapeHtml(f)}</span>`:""}\n </div>\n `:""}\n </div>\n `}getCityName(t){return{JED:"Djeddah",TUN:"Tunis",CDG:"Paris",LHR:"London",JFK:"New York",DXB:"Dubai",LAX:"Los Angeles",ORD:"Chicago",ATL:"Atlanta",DFW:"Dallas",DEN:"Denver",SFO:"San Francisco",SEA:"Seattle",LAS:"Las Vegas",MCO:"Orlando",MIA:"Miami",IAH:"Houston",PHX:"Phoenix",BOS:"Boston",MSP:"Minneapolis",DTW:"Detroit",FLL:"Fort Lauderdale",PHL:"Philadelphia",LGA:"New York",BWI:"Baltimore",SLC:"Salt Lake City",SAN:"San Diego",DCA:"Washington",TPA:"Tampa",PDX:"Portland",STL:"St. Louis"}[t.toUpperCase()]||t}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}getStyles(){return`\n .${this.cssPrefix} {\n background: #ffffff;\n border-radius: 12px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n padding: 24px;\n margin: 16px 0;\n font-family: system-ui, -apple-system, sans-serif;\n max-width: 600px;\n }\n\n .${this.cssPrefix}__header {\n margin-bottom: 24px;\n }\n\n .${this.cssPrefix}__route {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n margin-bottom: 8px;\n }\n\n .${this.cssPrefix}__airport-code {\n font-size: 32px;\n font-weight: 700;\n color: #1a1a1a;\n letter-spacing: 0.5px;\n }\n\n .${this.cssPrefix}__flight-line {\n flex: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n position: relative;\n padding: 0 16px;\n }\n\n .${this.cssPrefix}__flight-line::before {\n content: '';\n position: absolute;\n top: 50%;\n left: 0;\n right: 0;\n height: 2px;\n background: linear-gradient(to right, #e0e0e0 0%, #e0e0e0 100%);\n z-index: 0;\n }\n\n .${this.cssPrefix}__plane-icon {\n width: 24px;\n height: 24px;\n color: #666;\n background: white;\n padding: 4px;\n position: relative;\n z-index: 1;\n transform: rotate(90deg);\n }\n\n .${this.cssPrefix}__duration {\n position: absolute;\n top: -24px;\n background: white;\n padding: 2px 8px;\n font-size: 13px;\n color: #666;\n white-space: nowrap;\n }\n\n .${this.cssPrefix}__flight-info {\n display: flex;\n gap: 8px;\n align-items: center;\n font-size: 14px;\n color: #666;\n }\n\n .${this.cssPrefix}__airline {\n font-weight: 500;\n }\n\n .${this.cssPrefix}__flight-number {\n color: #999;\n }\n\n .${this.cssPrefix}__details {\n display: grid;\n grid-template-columns: 1fr auto 1fr;\n gap: 24px;\n }\n\n .${this.cssPrefix}__divider {\n width: 1px;\n background: #e0e0e0;\n }\n\n .${this.cssPrefix}__section {\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n\n .${this.cssPrefix}__label {\n font-size: 12px;\n color: #999;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n font-weight: 500;\n text-decoration: underline;\n }\n\n .${this.cssPrefix}__location {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .${this.cssPrefix}__city {\n font-size: 16px;\n font-weight: 600;\n color: #1a1a1a;\n }\n\n .${this.cssPrefix}__date {\n font-size: 13px;\n color: #666;\n }\n\n .${this.cssPrefix}__time-group {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .${this.cssPrefix}__time-label {\n font-size: 12px;\n color: #666;\n }\n\n .${this.cssPrefix}__time-value {\n font-size: 24px;\n font-weight: 700;\n color: #2d6a3e;\n }\n\n .${this.cssPrefix}__terminal-gate {\n display: flex;\n gap: 16px;\n }\n\n .${this.cssPrefix}__info-item {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .${this.cssPrefix}__info-label {\n font-size: 11px;\n color: #999;\n }\n\n .${this.cssPrefix}__info-value {\n font-size: 18px;\n font-weight: 600;\n color: #1a1a1a;\n }\n\n .${this.cssPrefix}__footer {\n margin-top: 16px;\n padding-top: 16px;\n border-top: 1px solid #e0e0e0;\n display: flex;\n justify-content: space-between;\n align-items: center;\n font-size: 12px;\n color: #666;\n gap: 12px;\n }\n\n .${this.cssPrefix}__updated {\n color: #999;\n }\n\n .${this.cssPrefix}__source {\n color: #666;\n }\n\n .${this.cssPrefix}__source::before {\n content: '';\n display: inline-block;\n width: 4px;\n height: 4px;\n background: #666;\n border-radius: 50%;\n margin-right: 8px;\n vertical-align: middle;\n }\n\n .${this.cssPrefix}__status {\n padding: 4px 8px;\n background: #e8f5e9;\n color: #2d6a3e;\n border-radius: 4px;\n font-weight: 500;\n }\n\n /* Share button styling */\n .${this.cssPrefix}__footer button {\n background: none;\n border: none;\n color: #666;\n cursor: pointer;\n padding: 4px;\n display: flex;\n align-items: center;\n gap: 4px;\n }\n\n .${this.cssPrefix}__footer button:hover {\n color: #1a1a1a;\n }\n\n /* Dark mode support */\n @media (prefers-color-scheme: dark) {\n .${this.cssPrefix} {\n background: #2a2a2a;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);\n }\n\n .${this.cssPrefix}__airport-code,\n .${this.cssPrefix}__city,\n .${this.cssPrefix}__info-value {\n color: #ffffff;\n }\n\n .${this.cssPrefix}__flight-line::before {\n background: linear-gradient(to right, #444 0%, #444 100%);\n }\n\n .${this.cssPrefix}__plane-icon {\n background: #2a2a2a;\n color: #999;\n }\n\n .${this.cssPrefix}__duration {\n background: #2a2a2a;\n }\n\n .${this.cssPrefix}__divider {\n background: #444;\n }\n\n .${this.cssPrefix}__footer {\n border-top-color: #444;\n }\n }\n\n /* Responsive design */\n @media (max-width: 640px) {\n .${this.cssPrefix} {\n padding: 16px;\n }\n\n .${this.cssPrefix}__details {\n grid-template-columns: 1fr;\n gap: 16px;\n }\n\n .${this.cssPrefix}__divider {\n height: 1px;\n width: 100%;\n }\n\n .${this.cssPrefix}__airport-code {\n font-size: 24px;\n }\n\n .${this.cssPrefix}__time-value {\n font-size: 20px;\n }\n\n .${this.cssPrefix}__footer {\n flex-direction: column;\n align-items: flex-start;\n }\n }\n `}}
|
|
2508
|
+
*/var Te=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class Ee extends ke{constructor(){super(...arguments),this.id="flight-card",this.name="Flight Card Plugin",this.version="1.0.0",this.htmlTags=[{name:"flight",open:"[FLIGHT]",close:"[/FLIGHT]"}],this.cssPrefix="nr-flight-card"}renderHtmlBlockPlaceholder(t){if("flight"!==t.toLowerCase())return"";return`<div data-placeholder-id="${`flight-skeleton-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}"><nr-skeleton \n active \n style="min-width: 400px; max-width: 600px; margin: 16px 0;"\n ></nr-skeleton></div>`}onInit(){console.log("[FlightCardPlugin] Initialized")}afterReceive(t){return Te(this,void 0,void 0,function*(){try{const e=JSON.parse(t);if("flight"===e.type||this.isFlightData(e))return this.renderFlightCard(e)}catch(t){}const e=/\[FLIGHT\]([\s\S]*?)\[\/FLIGHT\]/g;let n,i=t;for(;null!==(n=e.exec(t));)try{const t=JSON.parse(n[1]),e=this.renderFlightCard(t);i=i.replace(n[0],e)}catch(t){console.warn("[FlightCardPlugin] Failed to parse flight data:",t)}return i})}renderHtmlBlock(t,e){if("flight"!==t.toLowerCase())return"";try{const t=JSON.parse(e);return this.renderFlightCard(t)}catch(t){return console.warn("[FlightCardPlugin] renderHtmlBlock parse error:",t),""}}isFlightData(t){return t&&"object"==typeof t&&t.origin&&t.destination&&t.departureTime}renderFlightCard(t){const{origin:e,destination:n,departureTime:i,arrivalTime:o,departureDate:s,arrivalDate:r,terminal:a,gate:l,arrivalTerminal:d,arrivalGate:c,duration:h,flightNumber:u,airline:p,status:f,updated:g,source:m}=t;return`\n ${this.getOncePerConversationStyleTag(this.getStyles())}\n <div class="${this.cssPrefix}" data-nr-flight-card="true">\n <div class="${this.cssPrefix}__header">\n <div class="${this.cssPrefix}__route">\n <span class="${this.cssPrefix}__airport-code">${this.escapeHtml(e)}</span>\n <div class="${this.cssPrefix}__flight-line">\n <svg class="${this.cssPrefix}__plane-icon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M21 16v-2l-8-5V3.5c0-.83-.67-1.5-1.5-1.5S10 2.67 10 3.5V9l-8 5v2l8-2.5V19l-2 1.5V22l3.5-1 3.5 1v-1.5L13 19v-5.5l8 2.5z" fill="currentColor"/>\n </svg>\n ${h?`<span class="${this.cssPrefix}__duration">${this.escapeHtml(h)}</span>`:""}\n </div>\n <span class="${this.cssPrefix}__airport-code">${this.escapeHtml(n)}</span>\n </div>\n ${u||p?`\n <div class="${this.cssPrefix}__flight-info">\n ${p?`<span class="${this.cssPrefix}__airline">${this.escapeHtml(p)}</span>`:""}\n ${u?`<span class="${this.cssPrefix}__flight-number">${this.escapeHtml(u)}</span>`:""}\n </div>\n `:""}\n </div>\n\n <div class="${this.cssPrefix}__details">\n <div class="${this.cssPrefix}__section ${this.cssPrefix}__section--departure">\n <div class="${this.cssPrefix}__label">Infos sur l'aéroport</div>\n <div class="${this.cssPrefix}__location">\n <span class="${this.cssPrefix}__city">${this.getCityName(e)}</span>\n <span class="${this.cssPrefix}__date">${s?this.escapeHtml(s):""}</span>\n </div>\n <div class="${this.cssPrefix}__time-group">\n <div class="${this.cssPrefix}__time-label">Heure de départ prévue</div>\n <div class="${this.cssPrefix}__time-value">${this.escapeHtml(i)}</div>\n </div>\n <div class="${this.cssPrefix}__terminal-gate">\n ${a?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Terminal</span>\n <span class="${this.cssPrefix}__info-value">${this.escapeHtml(a)}</span>\n </div>\n `:""}\n ${l?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Porte</span>\n <span class="${this.cssPrefix}__info-value">${this.escapeHtml(l)}</span>\n </div>\n `:void 0===l?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Porte</span>\n <span class="${this.cssPrefix}__info-value">-</span>\n </div>\n `:""}\n </div>\n </div>\n\n <div class="${this.cssPrefix}__divider"></div>\n\n <div class="${this.cssPrefix}__section ${this.cssPrefix}__section--arrival">\n <div class="${this.cssPrefix}__label">Infos sur l'aéroport</div>\n <div class="${this.cssPrefix}__location">\n <span class="${this.cssPrefix}__city">${this.getCityName(n)}</span>\n <span class="${this.cssPrefix}__date">${r?this.escapeHtml(r):""}</span>\n </div>\n <div class="${this.cssPrefix}__time-group">\n <div class="${this.cssPrefix}__time-label">Heure d'arrivée prévue</div>\n <div class="${this.cssPrefix}__time-value">${this.escapeHtml(o)}</div>\n </div>\n <div class="${this.cssPrefix}__terminal-gate">\n ${d?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Terminal</span>\n <span class="${this.cssPrefix}__info-value">${this.escapeHtml(d)}</span>\n </div>\n `:""}\n ${c?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Porte</span>\n <span class="${this.cssPrefix}__info-value">${this.escapeHtml(c)}</span>\n </div>\n `:void 0===c?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Porte</span>\n <span class="${this.cssPrefix}__info-value">-</span>\n </div>\n `:""}\n </div>\n </div>\n </div>\n\n ${g||m||f?`\n <div class="${this.cssPrefix}__footer">\n ${g?`<span class="${this.cssPrefix}__updated">${this.escapeHtml(g)}</span>`:""}\n ${m?`<span class="${this.cssPrefix}__source">Source : ${this.escapeHtml(m)}</span>`:""}\n ${f?`<span class="${this.cssPrefix}__status">${this.escapeHtml(f)}</span>`:""}\n </div>\n `:""}\n </div>\n `}getCityName(t){return{JED:"Djeddah",TUN:"Tunis",CDG:"Paris",LHR:"London",JFK:"New York",DXB:"Dubai",LAX:"Los Angeles",ORD:"Chicago",ATL:"Atlanta",DFW:"Dallas",DEN:"Denver",SFO:"San Francisco",SEA:"Seattle",LAS:"Las Vegas",MCO:"Orlando",MIA:"Miami",IAH:"Houston",PHX:"Phoenix",BOS:"Boston",MSP:"Minneapolis",DTW:"Detroit",FLL:"Fort Lauderdale",PHL:"Philadelphia",LGA:"New York",BWI:"Baltimore",SLC:"Salt Lake City",SAN:"San Diego",DCA:"Washington",TPA:"Tampa",PDX:"Portland",STL:"St. Louis"}[t.toUpperCase()]||t}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}getStyles(){return`\n .${this.cssPrefix} {\n background: #ffffff;\n border-radius: 12px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n padding: 24px;\n margin: 16px 0;\n font-family: system-ui, -apple-system, sans-serif;\n max-width: 600px;\n }\n\n .${this.cssPrefix}__header {\n margin-bottom: 24px;\n }\n\n .${this.cssPrefix}__route {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n margin-bottom: 8px;\n }\n\n .${this.cssPrefix}__airport-code {\n font-size: 32px;\n font-weight: 700;\n color: #1a1a1a;\n letter-spacing: 0.5px;\n }\n\n .${this.cssPrefix}__flight-line {\n flex: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n position: relative;\n padding: 0 16px;\n }\n\n .${this.cssPrefix}__flight-line::before {\n content: '';\n position: absolute;\n top: 50%;\n left: 0;\n right: 0;\n height: 2px;\n background: linear-gradient(to right, #e0e0e0 0%, #e0e0e0 100%);\n z-index: 0;\n }\n\n .${this.cssPrefix}__plane-icon {\n width: 24px;\n height: 24px;\n color: #666;\n background: white;\n padding: 4px;\n position: relative;\n z-index: 1;\n transform: rotate(90deg);\n }\n\n .${this.cssPrefix}__duration {\n position: absolute;\n top: -24px;\n background: white;\n padding: 2px 8px;\n font-size: 13px;\n color: #666;\n white-space: nowrap;\n }\n\n .${this.cssPrefix}__flight-info {\n display: flex;\n gap: 8px;\n align-items: center;\n font-size: 14px;\n color: #666;\n }\n\n .${this.cssPrefix}__airline {\n font-weight: 500;\n }\n\n .${this.cssPrefix}__flight-number {\n color: #999;\n }\n\n .${this.cssPrefix}__details {\n display: grid;\n grid-template-columns: 1fr auto 1fr;\n gap: 24px;\n }\n\n .${this.cssPrefix}__divider {\n width: 1px;\n background: #e0e0e0;\n }\n\n .${this.cssPrefix}__section {\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n\n .${this.cssPrefix}__label {\n font-size: 12px;\n color: #999;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n font-weight: 500;\n text-decoration: underline;\n }\n\n .${this.cssPrefix}__location {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .${this.cssPrefix}__city {\n font-size: 16px;\n font-weight: 600;\n color: #1a1a1a;\n }\n\n .${this.cssPrefix}__date {\n font-size: 13px;\n color: #666;\n }\n\n .${this.cssPrefix}__time-group {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .${this.cssPrefix}__time-label {\n font-size: 12px;\n color: #666;\n }\n\n .${this.cssPrefix}__time-value {\n font-size: 24px;\n font-weight: 700;\n color: #2d6a3e;\n }\n\n .${this.cssPrefix}__terminal-gate {\n display: flex;\n gap: 16px;\n }\n\n .${this.cssPrefix}__info-item {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .${this.cssPrefix}__info-label {\n font-size: 11px;\n color: #999;\n }\n\n .${this.cssPrefix}__info-value {\n font-size: 18px;\n font-weight: 600;\n color: #1a1a1a;\n }\n\n .${this.cssPrefix}__footer {\n margin-top: 16px;\n padding-top: 16px;\n border-top: 1px solid #e0e0e0;\n display: flex;\n justify-content: space-between;\n align-items: center;\n font-size: 12px;\n color: #666;\n gap: 12px;\n }\n\n .${this.cssPrefix}__updated {\n color: #999;\n }\n\n .${this.cssPrefix}__source {\n color: #666;\n }\n\n .${this.cssPrefix}__source::before {\n content: '';\n display: inline-block;\n width: 4px;\n height: 4px;\n background: #666;\n border-radius: 50%;\n margin-right: 8px;\n vertical-align: middle;\n }\n\n .${this.cssPrefix}__status {\n padding: 4px 8px;\n background: #e8f5e9;\n color: #2d6a3e;\n border-radius: 4px;\n font-weight: 500;\n }\n\n /* Share button styling */\n .${this.cssPrefix}__footer button {\n background: none;\n border: none;\n color: #666;\n cursor: pointer;\n padding: 4px;\n display: flex;\n align-items: center;\n gap: 4px;\n }\n\n .${this.cssPrefix}__footer button:hover {\n color: #1a1a1a;\n }\n\n /* Dark mode support */\n @media (prefers-color-scheme: dark) {\n .${this.cssPrefix} {\n background: #2a2a2a;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);\n }\n\n .${this.cssPrefix}__airport-code,\n .${this.cssPrefix}__city,\n .${this.cssPrefix}__info-value {\n color: #ffffff;\n }\n\n .${this.cssPrefix}__flight-line::before {\n background: linear-gradient(to right, #444 0%, #444 100%);\n }\n\n .${this.cssPrefix}__plane-icon {\n background: #2a2a2a;\n color: #999;\n }\n\n .${this.cssPrefix}__duration {\n background: #2a2a2a;\n }\n\n .${this.cssPrefix}__divider {\n background: #444;\n }\n\n .${this.cssPrefix}__footer {\n border-top-color: #444;\n }\n }\n\n /* Responsive design */\n @media (max-width: 640px) {\n .${this.cssPrefix} {\n padding: 16px;\n }\n\n .${this.cssPrefix}__details {\n grid-template-columns: 1fr;\n gap: 16px;\n }\n\n .${this.cssPrefix}__divider {\n height: 1px;\n width: 100%;\n }\n\n .${this.cssPrefix}__airport-code {\n font-size: 24px;\n }\n\n .${this.cssPrefix}__time-value {\n font-size: 20px;\n }\n\n .${this.cssPrefix}__footer {\n flex-direction: column;\n align-items: flex-start;\n }\n }\n `}}
|
|
2493
2509
|
/**
|
|
2494
2510
|
* @license
|
|
2495
2511
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2496
2512
|
* SPDX-License-Identifier: MIT
|
|
2497
|
-
*/class _e extends me{constructor(){super(...arguments),this.id="print-job-card",this.name="Print Job Card Plugin",this.version="1.0.0",this.htmlTags=[{name:"printjob",open:"[PRINTJOB]",close:"[/PRINTJOB]"}],this.cssPrefix="nr-print-job-card"}renderHtmlBlockPlaceholder(t){if("printjob"!==t.toLowerCase())return"";return`<div data-placeholder-id="${`printjob-skeleton-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}"><nr-skeleton \n active \n avatar\n paragraph='{"rows":3}'\n style="min-width: 350px; max-width: 500px; margin: 8px 0;"\n ></nr-skeleton></div>`}onInit(){console.log("[PrintJobCardPlugin] Initialized")}renderHtmlBlock(t,e){if("printjob"!==t.toLowerCase())return"";try{const t=JSON.parse(e);return this.renderPrintJobCard(t)}catch(t){return console.warn("[PrintJobCardPlugin] renderHtmlBlock parse error:",t),""}}renderPrintJobCard(t){const e=this.getStatusIcon(t.status),n=t.pagesPrinted&&t.totalPages?Math.round(t.pagesPrinted/t.totalPages*100):0;return`\n ${this.getOncePerConversationStyleTag(this.getStyles())}\n <div class="${this.cssPrefix}" data-nr-print-job-card="true">\n <div class="${this.cssPrefix}__header">\n <div class="${this.cssPrefix}__printer-icon">\n 🖨️\n </div>\n <div class="${this.cssPrefix}__header-content">\n <div class="${this.cssPrefix}__title">${this.escapeHtml(t.documentName)}</div>\n <div class="${this.cssPrefix}__subtitle">${this.escapeHtml(t.printerName)}</div>\n </div>\n <div class="${this.cssPrefix}__job-id">#${this.escapeHtml(t.jobId)}</div>\n </div>\n\n <div class="${this.cssPrefix}__status-row">\n <span class="${this.cssPrefix}__status-badge ${this.cssPrefix}__status-badge--${t.status}">\n ${e} ${this.formatStatus(t.status)}\n </span>\n ${t.priority&&"normal"!==t.priority?`\n <span class="${this.cssPrefix}__priority-badge ${this.cssPrefix}__priority-badge--${t.priority}">\n ${"high"===t.priority?"⚡":"🔽"} ${this.capitalize(t.priority)} Priority\n </span>\n `:""}\n </div>\n\n ${"printing"===t.status&&t.pagesPrinted&&t.totalPages?`\n <div class="${this.cssPrefix}__progress">\n <div class="${this.cssPrefix}__progress-bar">\n <div class="${this.cssPrefix}__progress-fill" style="width: ${n}%"></div>\n </div>\n <div class="${this.cssPrefix}__progress-text">\n ${t.pagesPrinted} / ${t.totalPages} pages (${n}%)\n </div>\n </div>\n `:""}\n\n ${"error"===t.status&&t.errorMessage?`\n <div class="${this.cssPrefix}__error-message">\n ⚠️ ${this.escapeHtml(t.errorMessage)}\n </div>\n `:""}\n\n <div class="${this.cssPrefix}__details">\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">Pages:</span>\n <span class="${this.cssPrefix}__detail-value">${t.totalPages}</span>\n </div>\n ${t.copies&&t.copies>1?`\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">Copies:</span>\n <span class="${this.cssPrefix}__detail-value">${t.copies}</span>\n </div>\n `:""}\n ${t.colorMode?`\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">Color Mode:</span>\n <span class="${this.cssPrefix}__detail-value">${this.capitalize(t.colorMode)}</span>\n </div>\n `:""}\n ${t.paperSize?`\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">Paper Size:</span>\n <span class="${this.cssPrefix}__detail-value">${t.paperSize}</span>\n </div>\n `:""}\n ${t.userName?`\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">User:</span>\n <span class="${this.cssPrefix}__detail-value">${this.escapeHtml(t.userName)}</span>\n </div>\n `:""}\n ${t.estimatedTime&&"printing"===t.status?`\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">Est. Time:</span>\n <span class="${this.cssPrefix}__detail-value">${t.estimatedTime}</span>\n </div>\n `:""}\n </div>\n\n <div class="${this.cssPrefix}__footer">\n <span class="${this.cssPrefix}__timestamp">\n 📅 Submitted: ${this.formatTimestamp(t.submittedAt)}\n </span>\n ${t.completedAt?`\n <span class="${this.cssPrefix}__timestamp">\n ✅ Completed: ${this.formatTimestamp(t.completedAt)}\n </span>\n `:""}\n </div>\n </div>\n `}getStatusColor(t){return{queued:"#ffa726",printing:"#42a5f5",completed:"#66bb6a",paused:"#ffb74d",error:"#ef5350",cancelled:"#78909c"}[t]||"#999"}getStatusIcon(t){return{queued:"⏳",printing:"🔄",completed:"✅",paused:"⏸️",error:"❌",cancelled:"🚫"}[t]||"📄"}formatStatus(t){return t.charAt(0).toUpperCase()+t.slice(1)}capitalize(t){return t.charAt(0).toUpperCase()+t.slice(1)}formatTimestamp(t){try{return new Date(t).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch(e){return t}}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}getStyles(){return`\n .${this.cssPrefix} {\n background: #ffffff;\n border-radius: 12px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n padding: 20px;\n margin: 12px 0;\n font-family: system-ui, -apple-system, sans-serif;\n max-width: 500px;\n border-left: 4px solid #42a5f5;\n }\n\n .${this.cssPrefix}__header {\n display: flex;\n align-items: flex-start;\n gap: 12px;\n margin-bottom: 16px;\n }\n\n .${this.cssPrefix}__printer-icon {\n font-size: 32px;\n line-height: 1;\n flex-shrink: 0;\n }\n\n .${this.cssPrefix}__header-content {\n flex: 1;\n min-width: 0;\n }\n\n .${this.cssPrefix}__title {\n font-size: 16px;\n font-weight: 600;\n color: #1a1a1a;\n margin-bottom: 4px;\n word-break: break-word;\n }\n\n .${this.cssPrefix}__subtitle {\n font-size: 13px;\n color: #666;\n }\n\n .${this.cssPrefix}__job-id {\n font-size: 12px;\n color: #999;\n font-family: 'Monaco', 'Courier New', monospace;\n background: #f5f5f5;\n padding: 4px 8px;\n border-radius: 4px;\n flex-shrink: 0;\n }\n\n .${this.cssPrefix}__status-row {\n display: flex;\n gap: 8px;\n flex-wrap: wrap;\n margin-bottom: 16px;\n }\n\n .${this.cssPrefix}__status-badge {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 6px 12px;\n border-radius: 6px;\n font-size: 13px;\n font-weight: 500;\n }\n\n .${this.cssPrefix}__status-badge--queued {\n background: #fff3e0;\n color: #e65100;\n }\n\n .${this.cssPrefix}__status-badge--printing {\n background: #e3f2fd;\n color: #0d47a1;\n }\n\n .${this.cssPrefix}__status-badge--completed {\n background: #e8f5e9;\n color: #1b5e20;\n }\n\n .${this.cssPrefix}__status-badge--paused {\n background: #fff3e0;\n color: #e65100;\n }\n\n .${this.cssPrefix}__status-badge--error {\n background: #ffebee;\n color: #b71c1c;\n }\n\n .${this.cssPrefix}__status-badge--cancelled {\n background: #f5f5f5;\n color: #616161;\n }\n\n .${this.cssPrefix}__priority-badge {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 6px 12px;\n border-radius: 6px;\n font-size: 12px;\n font-weight: 500;\n }\n\n .${this.cssPrefix}__priority-badge--high {\n background: #fff3e0;\n color: #e65100;\n }\n\n .${this.cssPrefix}__priority-badge--low {\n background: #f5f5f5;\n color: #666;\n }\n\n .${this.cssPrefix}__progress {\n margin-bottom: 16px;\n }\n\n .${this.cssPrefix}__progress-bar {\n width: 100%;\n height: 8px;\n background: #e0e0e0;\n border-radius: 4px;\n overflow: hidden;\n margin-bottom: 8px;\n }\n\n .${this.cssPrefix}__progress-fill {\n height: 100%;\n background: linear-gradient(90deg, #42a5f5 0%, #1976d2 100%);\n transition: width 0.3s ease;\n border-radius: 4px;\n }\n\n .${this.cssPrefix}__progress-text {\n font-size: 13px;\n color: #666;\n text-align: center;\n }\n\n .${this.cssPrefix}__error-message {\n background: #ffebee;\n border-left: 3px solid #ef5350;\n padding: 12px;\n margin-bottom: 16px;\n border-radius: 4px;\n font-size: 13px;\n color: #b71c1c;\n }\n\n .${this.cssPrefix}__details {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n gap: 12px;\n margin-bottom: 16px;\n padding: 16px;\n background: #f9f9f9;\n border-radius: 8px;\n }\n\n .${this.cssPrefix}__detail-row {\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 8px;\n }\n\n .${this.cssPrefix}__detail-label {\n font-size: 12px;\n color: #666;\n }\n\n .${this.cssPrefix}__detail-value {\n font-size: 13px;\n font-weight: 600;\n color: #1a1a1a;\n }\n\n .${this.cssPrefix}__footer {\n display: flex;\n flex-direction: column;\n gap: 4px;\n padding-top: 12px;\n border-top: 1px solid #e0e0e0;\n }\n\n .${this.cssPrefix}__timestamp {\n font-size: 11px;\n color: #999;\n }\n\n /* Dark mode support */\n @media (prefers-color-scheme: dark) {\n .${this.cssPrefix} {\n background: #2a2a2a;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);\n border-left-color: #42a5f5;\n }\n\n .${this.cssPrefix}__title,\n .${this.cssPrefix}__detail-value {\n color: #ffffff;\n }\n\n .${this.cssPrefix}__subtitle,\n .${this.cssPrefix}__detail-label {\n color: #b0b0b0;\n }\n\n .${this.cssPrefix}__job-id {\n background: #3a3a3a;\n color: #b0b0b0;\n }\n\n .${this.cssPrefix}__details {\n background: #333;\n }\n\n .${this.cssPrefix}__progress-bar {\n background: #444;\n }\n\n .${this.cssPrefix}__footer {\n border-top-color: #444;\n }\n }\n\n /* Responsive design */\n @media (max-width: 480px) {\n .${this.cssPrefix} {\n padding: 16px;\n }\n\n .${this.cssPrefix}__details {\n grid-template-columns: 1fr;\n }\n\n .${this.cssPrefix}__header {\n flex-wrap: wrap;\n }\n\n .${this.cssPrefix}__job-id {\n order: -1;\n width: 100%;\n }\n }\n `}}
|
|
2513
|
+
*/class Me extends ke{constructor(){super(...arguments),this.id="print-job-card",this.name="Print Job Card Plugin",this.version="1.0.0",this.htmlTags=[{name:"printjob",open:"[PRINTJOB]",close:"[/PRINTJOB]"}],this.cssPrefix="nr-print-job-card"}renderHtmlBlockPlaceholder(t){if("printjob"!==t.toLowerCase())return"";return`<div data-placeholder-id="${`printjob-skeleton-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}"><nr-skeleton \n active \n avatar\n paragraph='{"rows":3}'\n style="min-width: 350px; max-width: 500px; margin: 8px 0;"\n ></nr-skeleton></div>`}onInit(){console.log("[PrintJobCardPlugin] Initialized")}renderHtmlBlock(t,e){if("printjob"!==t.toLowerCase())return"";try{const t=JSON.parse(e);return this.renderPrintJobCard(t)}catch(t){return console.warn("[PrintJobCardPlugin] renderHtmlBlock parse error:",t),""}}renderPrintJobCard(t){const e=this.getStatusIcon(t.status),n=t.pagesPrinted&&t.totalPages?Math.round(t.pagesPrinted/t.totalPages*100):0;return`\n ${this.getOncePerConversationStyleTag(this.getStyles())}\n <div class="${this.cssPrefix}" data-nr-print-job-card="true">\n <div class="${this.cssPrefix}__header">\n <div class="${this.cssPrefix}__printer-icon">\n 🖨️\n </div>\n <div class="${this.cssPrefix}__header-content">\n <div class="${this.cssPrefix}__title">${this.escapeHtml(t.documentName)}</div>\n <div class="${this.cssPrefix}__subtitle">${this.escapeHtml(t.printerName)}</div>\n </div>\n <div class="${this.cssPrefix}__job-id">#${this.escapeHtml(t.jobId)}</div>\n </div>\n\n <div class="${this.cssPrefix}__status-row">\n <span class="${this.cssPrefix}__status-badge ${this.cssPrefix}__status-badge--${t.status}">\n ${e} ${this.formatStatus(t.status)}\n </span>\n ${t.priority&&"normal"!==t.priority?`\n <span class="${this.cssPrefix}__priority-badge ${this.cssPrefix}__priority-badge--${t.priority}">\n ${"high"===t.priority?"⚡":"🔽"} ${this.capitalize(t.priority)} Priority\n </span>\n `:""}\n </div>\n\n ${"printing"===t.status&&t.pagesPrinted&&t.totalPages?`\n <div class="${this.cssPrefix}__progress">\n <div class="${this.cssPrefix}__progress-bar">\n <div class="${this.cssPrefix}__progress-fill" style="width: ${n}%"></div>\n </div>\n <div class="${this.cssPrefix}__progress-text">\n ${t.pagesPrinted} / ${t.totalPages} pages (${n}%)\n </div>\n </div>\n `:""}\n\n ${"error"===t.status&&t.errorMessage?`\n <div class="${this.cssPrefix}__error-message">\n ⚠️ ${this.escapeHtml(t.errorMessage)}\n </div>\n `:""}\n\n <div class="${this.cssPrefix}__details">\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">Pages:</span>\n <span class="${this.cssPrefix}__detail-value">${t.totalPages}</span>\n </div>\n ${t.copies&&t.copies>1?`\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">Copies:</span>\n <span class="${this.cssPrefix}__detail-value">${t.copies}</span>\n </div>\n `:""}\n ${t.colorMode?`\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">Color Mode:</span>\n <span class="${this.cssPrefix}__detail-value">${this.capitalize(t.colorMode)}</span>\n </div>\n `:""}\n ${t.paperSize?`\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">Paper Size:</span>\n <span class="${this.cssPrefix}__detail-value">${t.paperSize}</span>\n </div>\n `:""}\n ${t.userName?`\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">User:</span>\n <span class="${this.cssPrefix}__detail-value">${this.escapeHtml(t.userName)}</span>\n </div>\n `:""}\n ${t.estimatedTime&&"printing"===t.status?`\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">Est. Time:</span>\n <span class="${this.cssPrefix}__detail-value">${t.estimatedTime}</span>\n </div>\n `:""}\n </div>\n\n <div class="${this.cssPrefix}__footer">\n <span class="${this.cssPrefix}__timestamp">\n 📅 Submitted: ${this.formatTimestamp(t.submittedAt)}\n </span>\n ${t.completedAt?`\n <span class="${this.cssPrefix}__timestamp">\n ✅ Completed: ${this.formatTimestamp(t.completedAt)}\n </span>\n `:""}\n </div>\n </div>\n `}getStatusColor(t){return{queued:"#ffa726",printing:"#42a5f5",completed:"#66bb6a",paused:"#ffb74d",error:"#ef5350",cancelled:"#78909c"}[t]||"#999"}getStatusIcon(t){return{queued:"⏳",printing:"🔄",completed:"✅",paused:"⏸️",error:"❌",cancelled:"🚫"}[t]||"📄"}formatStatus(t){return t.charAt(0).toUpperCase()+t.slice(1)}capitalize(t){return t.charAt(0).toUpperCase()+t.slice(1)}formatTimestamp(t){try{return new Date(t).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch(e){return t}}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}getStyles(){return`\n .${this.cssPrefix} {\n background: #ffffff;\n border-radius: 12px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n padding: 20px;\n margin: 12px 0;\n font-family: system-ui, -apple-system, sans-serif;\n max-width: 500px;\n border-left: 4px solid #42a5f5;\n }\n\n .${this.cssPrefix}__header {\n display: flex;\n align-items: flex-start;\n gap: 12px;\n margin-bottom: 16px;\n }\n\n .${this.cssPrefix}__printer-icon {\n font-size: 32px;\n line-height: 1;\n flex-shrink: 0;\n }\n\n .${this.cssPrefix}__header-content {\n flex: 1;\n min-width: 0;\n }\n\n .${this.cssPrefix}__title {\n font-size: 16px;\n font-weight: 600;\n color: #1a1a1a;\n margin-bottom: 4px;\n word-break: break-word;\n }\n\n .${this.cssPrefix}__subtitle {\n font-size: 13px;\n color: #666;\n }\n\n .${this.cssPrefix}__job-id {\n font-size: 12px;\n color: #999;\n font-family: 'Monaco', 'Courier New', monospace;\n background: #f5f5f5;\n padding: 4px 8px;\n border-radius: 4px;\n flex-shrink: 0;\n }\n\n .${this.cssPrefix}__status-row {\n display: flex;\n gap: 8px;\n flex-wrap: wrap;\n margin-bottom: 16px;\n }\n\n .${this.cssPrefix}__status-badge {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 6px 12px;\n border-radius: 6px;\n font-size: 13px;\n font-weight: 500;\n }\n\n .${this.cssPrefix}__status-badge--queued {\n background: #fff3e0;\n color: #e65100;\n }\n\n .${this.cssPrefix}__status-badge--printing {\n background: #e3f2fd;\n color: #0d47a1;\n }\n\n .${this.cssPrefix}__status-badge--completed {\n background: #e8f5e9;\n color: #1b5e20;\n }\n\n .${this.cssPrefix}__status-badge--paused {\n background: #fff3e0;\n color: #e65100;\n }\n\n .${this.cssPrefix}__status-badge--error {\n background: #ffebee;\n color: #b71c1c;\n }\n\n .${this.cssPrefix}__status-badge--cancelled {\n background: #f5f5f5;\n color: #616161;\n }\n\n .${this.cssPrefix}__priority-badge {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 6px 12px;\n border-radius: 6px;\n font-size: 12px;\n font-weight: 500;\n }\n\n .${this.cssPrefix}__priority-badge--high {\n background: #fff3e0;\n color: #e65100;\n }\n\n .${this.cssPrefix}__priority-badge--low {\n background: #f5f5f5;\n color: #666;\n }\n\n .${this.cssPrefix}__progress {\n margin-bottom: 16px;\n }\n\n .${this.cssPrefix}__progress-bar {\n width: 100%;\n height: 8px;\n background: #e0e0e0;\n border-radius: 4px;\n overflow: hidden;\n margin-bottom: 8px;\n }\n\n .${this.cssPrefix}__progress-fill {\n height: 100%;\n background: linear-gradient(90deg, #42a5f5 0%, #1976d2 100%);\n transition: width 0.3s ease;\n border-radius: 4px;\n }\n\n .${this.cssPrefix}__progress-text {\n font-size: 13px;\n color: #666;\n text-align: center;\n }\n\n .${this.cssPrefix}__error-message {\n background: #ffebee;\n border-left: 3px solid #ef5350;\n padding: 12px;\n margin-bottom: 16px;\n border-radius: 4px;\n font-size: 13px;\n color: #b71c1c;\n }\n\n .${this.cssPrefix}__details {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n gap: 12px;\n margin-bottom: 16px;\n padding: 16px;\n background: #f9f9f9;\n border-radius: 8px;\n }\n\n .${this.cssPrefix}__detail-row {\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 8px;\n }\n\n .${this.cssPrefix}__detail-label {\n font-size: 12px;\n color: #666;\n }\n\n .${this.cssPrefix}__detail-value {\n font-size: 13px;\n font-weight: 600;\n color: #1a1a1a;\n }\n\n .${this.cssPrefix}__footer {\n display: flex;\n flex-direction: column;\n gap: 4px;\n padding-top: 12px;\n border-top: 1px solid #e0e0e0;\n }\n\n .${this.cssPrefix}__timestamp {\n font-size: 11px;\n color: #999;\n }\n\n /* Dark mode support */\n @media (prefers-color-scheme: dark) {\n .${this.cssPrefix} {\n background: #2a2a2a;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);\n border-left-color: #42a5f5;\n }\n\n .${this.cssPrefix}__title,\n .${this.cssPrefix}__detail-value {\n color: #ffffff;\n }\n\n .${this.cssPrefix}__subtitle,\n .${this.cssPrefix}__detail-label {\n color: #b0b0b0;\n }\n\n .${this.cssPrefix}__job-id {\n background: #3a3a3a;\n color: #b0b0b0;\n }\n\n .${this.cssPrefix}__details {\n background: #333;\n }\n\n .${this.cssPrefix}__progress-bar {\n background: #444;\n }\n\n .${this.cssPrefix}__footer {\n border-top-color: #444;\n }\n }\n\n /* Responsive design */\n @media (max-width: 480px) {\n .${this.cssPrefix} {\n padding: 16px;\n }\n\n .${this.cssPrefix}__details {\n grid-template-columns: 1fr;\n }\n\n .${this.cssPrefix}__header {\n flex-wrap: wrap;\n }\n\n .${this.cssPrefix}__job-id {\n order: -1;\n width: 100%;\n }\n }\n `}}
|
|
2498
2514
|
/**
|
|
2499
2515
|
* @license
|
|
2500
2516
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2501
2517
|
* SPDX-License-Identifier: MIT
|
|
2502
|
-
*/var
|
|
2518
|
+
*/var ze=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class Ce extends ke{constructor(){super(...arguments),this.id="artifact",this.name="Artifact Plugin",this.version="1.0.0",this.artifacts=new Map}onInit(t){this.controller=t,t&&"function"==typeof t.on&&t.on("processing:end",()=>{var e,n;try{const i=[...(null===(e=t.getMessages)||void 0===e?void 0:e.call(t))||[]].reverse().find(t=>t.sender===J.Bot);i&&!(null===(n=i.metadata)||void 0===n?void 0:n.hasArtifacts)&&this.processMessage(i)}catch(t){}})}onMessageReceived(t){return ze(this,void 0,void 0,function*(){t.sender===J.Bot&&this.processMessage(t)})}processMessage(t){var e;if(null===(e=t.metadata)||void 0===e?void 0:e.hasArtifacts)return void this.rebuildArtifactsFromMetadata(t);const n=t.text;if(!n)return;const i=/```(\w*)\n([\s\S]*?)```/g;let o;const s=[];let r=0;for(;null!==(o=i.exec(n));){const e=(o[1]||"text").toLowerCase(),n=o[2],i=`artifact-${t.id}-${r}`,a={id:i,language:e,content:n,title:this.extractTitle(n,e,r),messageId:t.id,index:r};s.push(a),this.artifacts.set(i,a),r++}if(0===s.length)return;let a=n,l=0;a=a.replaceAll(i,()=>`\0ARTIFACT_CARD_${s[l++].id}\0`),a=dt(a);for(const t of s)a=a.replace(`\0ARTIFACT_CARD_${t.id}\0`,this.renderPlaceholderCard(t));const d=this.getOncePerConversationStyleTag(this.getStyles());this.controller&&"function"==typeof this.controller.updateMessage&&this.controller.updateMessage(t.id,{text:d+a,metadata:Object.assign(Object.assign({},t.metadata),{renderAsHtml:!0,hasArtifacts:!0,artifactIds:s.map(t=>t.id),artifactOriginalText:n})})}rebuildArtifactsFromMetadata(t){var e,n;const i=null===(e=t.metadata)||void 0===e?void 0:e.artifactIds;if(!(null==i?void 0:i.length))return;if(i.every(t=>this.artifacts.has(t)))return;const o=null===(n=t.metadata)||void 0===n?void 0:n.artifactOriginalText;if(!o)return;const s=/```(\w*)\n([\s\S]*?)```/g;let r,a=0;for(;null!==(r=s.exec(o));){const e=(r[1]||"text").toLowerCase(),n=r[2],i=`artifact-${t.id}-${a}`,o=this.extractTitle(n,e,a);this.artifacts.set(i,{id:i,language:e,content:n,title:o,messageId:t.id,index:a}),a++}}getArtifact(t){return this.artifacts.get(t)}getAllArtifacts(){return Array.from(this.artifacts.values())}getArtifactsForMessage(t){return Array.from(this.artifacts.values()).filter(e=>e.messageId===t)}extractTitle(t,e,n){const i=t.trimStart().split("\n")[0]||"",o=[/^\/\/\s*(.+)/,/^#\s*(.+)/,/^--\s*(.+)/,/^\/\*\s*(.*?)\*\//,/^<!--\s*(.*?)-->/];for(const t of o){const e=t.exec(i);if(null==e?void 0:e[1]){const t=e[1].trim();if(t.length>0&&t.length<=60)return t}}return`${lt(e)} Snippet ${n+1}`}renderPlaceholderCard(t){const e=lt(t.language),n=rt(t.title);return`<div class="nr-artifact-card" data-artifact-id="${t.id}" role="button" tabindex="0" aria-label="View ${n}">\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">${n}</span>\n <nr-tag size="small" class="nr-artifact-card__lang">${e}</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 @media (prefers-color-scheme: dark) {\n .nr-artifact-card {\n background: #161b22;\n border-color: #30363d;\n }\n .nr-artifact-card:hover {\n background: #1c2128;\n border-color: #484f58;\n }\n .nr-artifact-card__icon {\n color: #c9d1d9;\n }\n .nr-artifact-card__title {\n color: #c9d1d9;\n }\n .nr-artifact-card__chevron {\n color: #8b949e;\n }\n }\n "}}
|
|
2503
2519
|
/**
|
|
2504
2520
|
* @license
|
|
2505
2521
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2506
2522
|
* SPDX-License-Identifier: MIT
|
|
2507
|
-
*/class
|
|
2523
|
+
*/class Ie extends ke{constructor(){super(...arguments),this.id="json-graph-renderer",this.name="JSON Graph Renderer",this.version="1.0.0"}renderArtifactContent(t){if("json"!==t.language)return"";let e;try{e=JSON.parse(t.content)}catch(t){return""}if(null===e||"object"!=typeof e)return"";const n=Array.isArray(e)?e.map((t,e)=>this.renderNode(String(e),t)):Object.entries(e).map(([t,e])=>this.renderNode(t,e));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(e)?e.length:Object.keys(e).length} root keys</span>\n </div>\n ${n.join("")}\n </div>\n `}renderNode(t,e,n=0){const i=null!==e&&"object"==typeof e&&!Array.isArray(e),o=Array.isArray(e),s=24*n;if(!i&&!o)return`\n <div style="display:flex;align-items:center;gap:8px;margin-left:${s}px;margin-bottom:6px;">\n <span style="\n display:inline-block;width:8px;height:8px;border-radius:50%;\n background:${this.typeColor(e)};flex-shrink:0;\n "></span>\n <span style="font-weight:600;font-size:13px;color:#334155;">\n ${rt(t)}\n </span>\n <span style="\n font-size:13px;padding:2px 8px;border-radius:4px;\n background:${this.typeBg(e)};color:${this.typeColor(e)};\n border:1px solid ${this.typeColor(e)}20;\n ">${rt(this.formatValue(e))}</span>\n </div>\n `;const r=o?e.map((t,e)=>[String(e),t]):Object.entries(e),a=o?`[ ${r.length} ]`:`{ ${r.length} }`,l=o?"#8b5cf6":"#0ea5e9";return`\n <div style="margin-left:${s}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 ">${o?"[]":"{}"}</span>\n <span style="font-weight:600;font-size:13px;color:#334155;">\n ${rt(t)}\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 ">${a}</span>\n </div>\n <div style="margin-left:9px;padding-left:16px;border-left:2px solid #e2e8f0;">\n ${r.map(([t,e])=>this.renderNode(t,e,0)).join("")}\n </div>\n </div>\n `}typeColor(t){if(null===t)return"#94a3b8";switch(typeof t){case"string":return"#22c55e";case"number":return"#3b82f6";case"boolean":return"#f59e0b";default:return"#94a3b8"}}typeBg(t){if(null===t)return"#f1f5f9";switch(typeof t){case"string":return"#f0fdf4";case"number":return"#eff6ff";case"boolean":return"#fffbeb";default:return"#f1f5f9"}}formatValue(t){return null==t?"null":"string"==typeof t?`"${t}"`:"number"==typeof t||"boolean"==typeof t?String(t):JSON.stringify(t)}}
|
|
2508
2524
|
/**
|
|
2509
2525
|
* @license
|
|
2510
2526
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2511
2527
|
* SPDX-License-Identifier: MIT
|
|
2512
|
-
*/const ze="nuraly:flow-diagram:split-width",Pe="nuraly:flow-diagram:panel-width",Te="nr-flow-diagram-editor";class Me extends HTMLElement{connectedCallback(){var t;const e=this.loadPanelWidth(),n=this.closestPanel();n&&(n.style.setProperty("width",`${e}px`),this._panelObserver=new ResizeObserver(()=>{const t=Math.round(n.getBoundingClientRect().width);t>=200&&localStorage.setItem(Pe,String(t))}),this._panelObserver.observe(n));const i=this.attachShadow({mode:"open"}),o=null!==(t=this.getAttribute("content"))&&void 0!==t?t:"",r=this.unescapeHtml(o),s=this.prettyPrint(r);let a=null;try{a=JSON.parse(r)}catch(t){}i.innerHTML=`\n <style>${Me.styles()}</style>\n ${this.renderHeader(a)}\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 ${a?this.renderDiagram(a):'<div class="empty">Invalid JSON</div>'}\n </div>\n </div>\n <div class="error-bar" style="display:none;"></div>\n `;const l=i.querySelector(".editor-textarea");l&&(l.value=s);const c=localStorage.getItem(ze);c&&requestAnimationFrame(()=>{const t=i.querySelector(".editor-pane");t&&(t.style.flex="none",t.style.width=`${c}px`)});const d=i.querySelector(".diagram-pane"),h=i.querySelector(".error-bar");l&&d&&h&&(l.addEventListener("input",()=>{try{const t=JSON.parse(l.value);if(t.Steps&&t.Transitions){d.innerHTML=this.renderDiagram(t);const e=i.querySelector(".header");if(e){const n=document.createElement("template");n.innerHTML=this.renderHeader(t).trim();const i=n.content.firstElementChild;i&&e.replaceWith(i)}}h.style.display="none"}catch(t){h.textContent=`Parse error: ${t.message}`,h.style.display="flex"}}),this.initResize(i))}disconnectedCallback(){var t,e;null===(t=this._panelObserver)||void 0===t||t.disconnect(),null===(e=this.closestPanel())||void 0===e||e.style.removeProperty("width")}loadPanelWidth(){const t=localStorage.getItem(Pe);return t?Math.max(300,Number.parseInt(t,10)):500}closestPanel(){var t,e,n,i;let o=null!==(e=null!==(t=this.parentElement)&&void 0!==t?t:this.getRootNode().host)&&void 0!==e?e:null;for(;o;){if(o instanceof HTMLElement&&o.classList.contains("artifact-panel"))return o;o=null!==(i=null!==(n=o.parentElement)&&void 0!==n?n:o.getRootNode().host)&&void 0!==i?i:null}return null}initResize(t){const e=t.querySelector(".split"),n=t.querySelector(".editor-pane"),i=t.querySelector(".resize-handle");if(!e||!n||!i)return;let o=!1,r=0,s=0;const a=t=>{if(!o)return;const i=t.clientX-r,a=e.getBoundingClientRect().width,l=Math.max(200,Math.min(s+i,a-200));n.style.flex="none",n.style.width=`${l}px`},l=()=>{if(!o)return;o=!1,i.classList.remove("active"),document.body.style.cursor="",document.body.style.userSelect="";const t=Math.round(n.getBoundingClientRect().width);t>=200&&localStorage.setItem(ze,String(t)),document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",l)};i.addEventListener("mousedown",t=>{const e=t;e.preventDefault(),o=!0,r=e.clientX,s=n.getBoundingClientRect().width,i.classList.add("active"),document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",a),document.addEventListener("mouseup",l)})}prettyPrint(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch(e){return t}}unescapeHtml(t){const e=document.createElement("textarea");return e.innerHTML=t,e.value}renderHeader(t){var e,n;const i=null!==(e=null==t?void 0:t.Name)&&void 0!==e?e:"Workflow",o=(null!==(n=null==t?void 0:t.DocflowTags)&&void 0!==n?n:[]).map(t=>`<span class="tag">${Z(t)}</span>`).join("");return`\n <div class="header">\n <span class="header-icon">⬡</span>\n <span class="header-name">${Z(i)}</span>\n ${o}\n </div>\n `}renderDiagram(t){var e,n;const i=this.buildOrderedSteps(t),o=[];for(let t=0;t<i.length;t++){const r=i[t];o.push("event"===r.type?this.renderEventNode(r.name,null!==(e=r.eventType)&&void 0!==e?e:""):this.renderStepNode(r.name,null!==(n=r.step)&&void 0!==n?n:{})),t<i.length-1&&o.push(this.renderConnector())}return`<div class="diagram">${o.join("")}</div>`}buildOrderedSteps(t){var e,n,i,o;const r=[],s=null===(e=t.Events)||void 0===e?void 0:e.StartEvent,a=null===(n=t.Events)||void 0===n?void 0:n.EndEvent;s&&r.push({type:"event",name:s.Name||"Start",eventType:"start"});const l={};for(const e of Object.values(t.Transitions))l[e.Source]=e;let c=null!==(o=null===(i=l.StartEvent)||void 0===i?void 0:i.Target)&&void 0!==o?o:Object.keys(t.Steps)[0];const d=new Set;for(;c&&t.Steps[c]&&!d.has(c);){d.add(c),r.push({type:"step",name:c,step:t.Steps[c]});const e=l[c];if(!e||"EndEvent"===e.Target)break;c=e.Target}return a&&r.push({type:"event",name:a.Name||"End",eventType:"end"}),r}renderEventNode(t,e){const n="start"===e;return`\n <div class="node event-node ${n?"event-start":"event-end"}">\n <span class="event-icon">${n?"●":"■"}</span>\n <span class="event-label">${Z(t)}</span>\n </div>\n `}renderStepNode(t,e){var n,i,o;const r=null!==(n=e.StepType)&&void 0!==n?n:"",s=null!==(o=null===(i=e.Description)||void 0===i?void 0:i.trim())&&void 0!==o?o:"",a=r?`<span class="step-badge ${"Worker"===r?"badge-worker":"badge-system"}">${Z(r)}</span>`:"",l=s?`<div class="step-desc">${Z(s)}</div>`:"";return`\n <div class="node step-node">\n <div class="step-header">\n <span class="step-name">${Z(t)}</span>\n ${a}\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 Ee extends me{constructor(){super(...arguments),this.id="flow-diagram",this.name="Flow Diagram",this.version="1.0.0"}onInit(){customElements.get(Te)||customElements.define(Te,Me)}renderArtifactContent(t){if("json"!==t.language)return"";let e;try{e=JSON.parse(t.content)}catch(t){return""}return null!==e&&"object"==typeof e&&e.Steps&&"object"==typeof e.Steps&&e.Transitions&&"object"==typeof e.Transitions?`<nr-flow-diagram-editor content="${Z(t.content)}"></nr-flow-diagram-editor>`:""}}
|
|
2528
|
+
*/const Oe="nuraly:flow-diagram:split-width",Re="nuraly:flow-diagram:panel-width",je="nr-flow-diagram-editor";class Ae extends HTMLElement{connectedCallback(){var t;const e=this.loadPanelWidth(),n=this.closestPanel();n&&(n.style.setProperty("width",`${e}px`),this._panelObserver=new ResizeObserver(()=>{const t=Math.round(n.getBoundingClientRect().width);t>=200&&localStorage.setItem(Re,String(t))}),this._panelObserver.observe(n));const i=this.attachShadow({mode:"open"}),o=null!==(t=this.getAttribute("content"))&&void 0!==t?t:"",s=this.unescapeHtml(o),r=this.prettyPrint(s);let a=null;try{a=JSON.parse(s)}catch(t){}i.innerHTML=`\n <style>${Ae.styles()}</style>\n ${this.renderHeader(a)}\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 ${a?this.renderDiagram(a):'<div class="empty">Invalid JSON</div>'}\n </div>\n </div>\n <div class="error-bar" style="display:none;"></div>\n `;const l=i.querySelector(".editor-textarea");l&&(l.value=r);const d=localStorage.getItem(Oe);d&&requestAnimationFrame(()=>{const t=i.querySelector(".editor-pane");t&&(t.style.flex="none",t.style.width=`${d}px`)});const c=i.querySelector(".diagram-pane"),h=i.querySelector(".error-bar");l&&c&&h&&(l.addEventListener("input",()=>{try{const t=JSON.parse(l.value);if(t.Steps&&t.Transitions){c.innerHTML=this.renderDiagram(t);const e=i.querySelector(".header");if(e){const n=document.createElement("template");n.innerHTML=this.renderHeader(t).trim();const i=n.content.firstElementChild;i&&e.replaceWith(i)}}h.style.display="none"}catch(t){h.textContent=`Parse error: ${t.message}`,h.style.display="flex"}}),this.initResize(i))}disconnectedCallback(){var t,e;null===(t=this._panelObserver)||void 0===t||t.disconnect(),null===(e=this.closestPanel())||void 0===e||e.style.removeProperty("width")}loadPanelWidth(){const t=localStorage.getItem(Re);return t?Math.max(300,Number.parseInt(t,10)):500}closestPanel(){var t,e,n,i;let o=null!==(e=null!==(t=this.parentElement)&&void 0!==t?t:this.getRootNode().host)&&void 0!==e?e:null;for(;o;){if(o instanceof HTMLElement&&o.classList.contains("artifact-panel"))return o;o=null!==(i=null!==(n=o.parentElement)&&void 0!==n?n:o.getRootNode().host)&&void 0!==i?i:null}return null}initResize(t){const e=t.querySelector(".split"),n=t.querySelector(".editor-pane"),i=t.querySelector(".resize-handle");if(!e||!n||!i)return;let o=!1,s=0,r=0;const a=t=>{if(!o)return;const i=t.clientX-s,a=e.getBoundingClientRect().width,l=Math.max(200,Math.min(r+i,a-200));n.style.flex="none",n.style.width=`${l}px`},l=()=>{if(!o)return;o=!1,i.classList.remove("active"),document.body.style.cursor="",document.body.style.userSelect="";const t=Math.round(n.getBoundingClientRect().width);t>=200&&localStorage.setItem(Oe,String(t)),document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",l)};i.addEventListener("mousedown",t=>{const e=t;e.preventDefault(),o=!0,s=e.clientX,r=n.getBoundingClientRect().width,i.classList.add("active"),document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",a),document.addEventListener("mouseup",l)})}prettyPrint(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch(e){return t}}unescapeHtml(t){const e=document.createElement("textarea");return e.innerHTML=t,e.value}renderHeader(t){var e,n;const i=null!==(e=null==t?void 0:t.Name)&&void 0!==e?e:"Workflow",o=(null!==(n=null==t?void 0:t.DocflowTags)&&void 0!==n?n:[]).map(t=>`<span class="tag">${rt(t)}</span>`).join("");return`\n <div class="header">\n <span class="header-icon">⬡</span>\n <span class="header-name">${rt(i)}</span>\n ${o}\n </div>\n `}renderDiagram(t){var e,n;const i=this.buildOrderedSteps(t),o=[];for(let t=0;t<i.length;t++){const s=i[t];o.push("event"===s.type?this.renderEventNode(s.name,null!==(e=s.eventType)&&void 0!==e?e:""):this.renderStepNode(s.name,null!==(n=s.step)&&void 0!==n?n:{})),t<i.length-1&&o.push(this.renderConnector())}return`<div class="diagram">${o.join("")}</div>`}buildOrderedSteps(t){var e,n,i,o;const s=[],r=null===(e=t.Events)||void 0===e?void 0:e.StartEvent,a=null===(n=t.Events)||void 0===n?void 0:n.EndEvent;r&&s.push({type:"event",name:r.Name||"Start",eventType:"start"});const l={};for(const e of Object.values(t.Transitions))l[e.Source]=e;let d=null!==(o=null===(i=l.StartEvent)||void 0===i?void 0:i.Target)&&void 0!==o?o:Object.keys(t.Steps)[0];const c=new Set;for(;d&&t.Steps[d]&&!c.has(d);){c.add(d),s.push({type:"step",name:d,step:t.Steps[d]});const e=l[d];if(!e||"EndEvent"===e.Target)break;d=e.Target}return a&&s.push({type:"event",name:a.Name||"End",eventType:"end"}),s}renderEventNode(t,e){const n="start"===e;return`\n <div class="node event-node ${n?"event-start":"event-end"}">\n <span class="event-icon">${n?"●":"■"}</span>\n <span class="event-label">${rt(t)}</span>\n </div>\n `}renderStepNode(t,e){var n,i,o;const s=null!==(n=e.StepType)&&void 0!==n?n:"",r=null!==(o=null===(i=e.Description)||void 0===i?void 0:i.trim())&&void 0!==o?o:"",a=s?`<span class="step-badge ${"Worker"===s?"badge-worker":"badge-system"}">${rt(s)}</span>`:"",l=r?`<div class="step-desc">${rt(r)}</div>`:"";return`\n <div class="node step-node">\n <div class="step-header">\n <span class="step-name">${rt(t)}</span>\n ${a}\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 De extends ke{constructor(){super(...arguments),this.id="flow-diagram",this.name="Flow Diagram",this.version="1.0.0"}onInit(){customElements.get(je)||customElements.define(je,Ae)}renderArtifactContent(t){if("json"!==t.language)return"";let e;try{e=JSON.parse(t.content)}catch(t){return""}return null!==e&&"object"==typeof e&&e.Steps&&"object"==typeof e.Steps&&e.Transitions&&"object"==typeof e.Transitions?`<nr-flow-diagram-editor content="${rt(t.content)}"></nr-flow-diagram-editor>`:""}}
|
|
2513
2529
|
/**
|
|
2514
2530
|
* @license
|
|
2515
2531
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2516
2532
|
* SPDX-License-Identifier: MIT
|
|
2517
|
-
*/var
|
|
2533
|
+
*/var Fe=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class Ne extends ke{constructor(){super(...arguments),this.id="selection-card",this.name="Selection Card Plugin",this.version="1.0.0",this.htmlTags=[{name:"selection",open:"[SELECTION]",close:"[/SELECTION]"}],this.cssPrefix="nr-selection-card"}renderHtmlBlockPlaceholder(t){if("selection"!==t.toLowerCase())return"";return`<div data-placeholder-id="${`selection-skeleton-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}"><nr-skeleton\n active\n style="min-width: 300px; max-width: 500px; height: 80px; margin: 16px 0;"\n ></nr-skeleton></div>`}onInit(){console.log("[SelectionCardPlugin] Initialized")}afterReceive(t){return Fe(this,void 0,void 0,function*(){try{const e=JSON.parse(t);if("selection"===e.type||this.isSelectionData(e))return this.renderSelectionCard(e)}catch(t){}const e=/\[SELECTION\]([\s\S]*?)\[\/SELECTION\]/g;let n,i=t;for(;null!==(n=e.exec(t));)try{const t=JSON.parse(n[1]),e=this.renderSelectionCard(t);i=i.replace(n[0],e)}catch(t){console.warn("[SelectionCardPlugin] Failed to parse selection data:",t)}return i})}renderHtmlBlock(t,e){if("selection"!==t.toLowerCase())return"";try{const t=JSON.parse(e);return this.renderSelectionCard(t)}catch(t){return console.warn("[SelectionCardPlugin] renderHtmlBlock parse error:",t),""}}isSelectionData(t){return t&&"object"==typeof t&&Array.isArray(t.options)&&t.options.length>0&&t.options[0].label&&t.options[0].value}renderSelectionCard(t){const{title:e,options:n,columns:i=1}=t,o=this.getOncePerConversationStyleTag(this.getStyles()),s=n.map(t=>{const e=t.disabled?'aria-disabled="true"':"",n=t.disabled?`${this.cssPrefix}__option--disabled`:"",i=t.disabled?"-1":"0",o=t.disabled?"":`data-selection-value="${this.escapeHtml(t.value)}"`;return`\n <div class="${this.cssPrefix}__option ${n}"\n ${o}\n role="button"\n tabindex="${i}"\n ${e}>\n ${t.icon?`<nr-icon class="${this.cssPrefix}__option-icon" name="${this.escapeHtml(t.icon)}" size="small"></nr-icon>`:""}\n <div class="${this.cssPrefix}__option-content">\n <span class="${this.cssPrefix}__option-label">${this.escapeHtml(t.label)}</span>\n ${t.description?`<span class="${this.cssPrefix}__option-description">${this.escapeHtml(t.description)}</span>`:""}\n </div>\n </div>\n `}).join("");return`\n ${o}\n <div class="${this.cssPrefix}" data-nr-selection-card="true">\n ${e?`<div class="${this.cssPrefix}__title">${this.escapeHtml(e)}</div>`:""}\n <div class="${this.cssPrefix}__grid ${this.cssPrefix}__grid--cols-${i}">\n ${s}\n </div>\n </div>\n `}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}getStyles(){return`\n .${this.cssPrefix} {\n margin: 12px 0;\n max-width: 500px;\n font-family: system-ui, -apple-system, sans-serif;\n }\n\n .${this.cssPrefix}__title {\n font-size: 14px;\n font-weight: 600;\n color: #1a1a1a;\n margin-bottom: 10px;\n }\n\n .${this.cssPrefix}__grid {\n display: grid;\n gap: 8px;\n }\n\n .${this.cssPrefix}__grid--cols-1 {\n grid-template-columns: 1fr;\n }\n\n .${this.cssPrefix}__grid--cols-2 {\n grid-template-columns: 1fr 1fr;\n }\n\n .${this.cssPrefix}__grid--cols-3 {\n grid-template-columns: 1fr 1fr 1fr;\n }\n\n .${this.cssPrefix}__option {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 12px 16px;\n background: #ffffff;\n border: 1px solid #e0e0e0;\n border-radius: 10px;\n cursor: pointer;\n transition: all 0.15s ease;\n user-select: none;\n -webkit-user-select: none;\n }\n\n .${this.cssPrefix}__option:hover {\n border-color: #4f8cff;\n background: #f0f6ff;\n box-shadow: 0 1px 4px rgba(79, 140, 255, 0.12);\n }\n\n .${this.cssPrefix}__option:focus-visible {\n outline: 2px solid #4f8cff;\n outline-offset: 2px;\n }\n\n .${this.cssPrefix}__option:active:not([aria-disabled="true"]) {\n transform: scale(0.98);\n background: #dfeaff;\n }\n\n .${this.cssPrefix}__option--disabled {\n opacity: 0.5;\n cursor: not-allowed;\n pointer-events: none;\n }\n\n .${this.cssPrefix}__option-icon {\n flex-shrink: 0;\n color: #555;\n }\n\n .${this.cssPrefix}__option-content {\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 0;\n }\n\n .${this.cssPrefix}__option-label {\n font-size: 14px;\n font-weight: 500;\n color: #1a1a1a;\n line-height: 1.3;\n }\n\n .${this.cssPrefix}__option-description {\n font-size: 12px;\n color: #666;\n line-height: 1.3;\n }\n\n /* Dark mode support */\n @media (prefers-color-scheme: dark) {\n .${this.cssPrefix}__title {\n color: #ffffff;\n }\n\n .${this.cssPrefix}__option {\n background: #2a2a2a;\n border-color: #444;\n }\n\n .${this.cssPrefix}__option:hover {\n border-color: #5a9aff;\n background: #1e2d44;\n box-shadow: 0 1px 4px rgba(90, 154, 255, 0.15);\n }\n\n .${this.cssPrefix}__option:active:not([aria-disabled="true"]) {\n background: #1a2638;\n }\n\n .${this.cssPrefix}__option-icon {\n color: #aaa;\n }\n\n .${this.cssPrefix}__option-label {\n color: #ffffff;\n }\n\n .${this.cssPrefix}__option-description {\n color: #999;\n }\n }\n\n /* Responsive: force single column on mobile */\n @media (max-width: 480px) {\n .${this.cssPrefix}__grid--cols-2,\n .${this.cssPrefix}__grid--cols-3 {\n grid-template-columns: 1fr;\n }\n }\n `}}
|
|
2518
2534
|
/**
|
|
2519
2535
|
* @license
|
|
2520
2536
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2521
2537
|
* SPDX-License-Identifier: MIT
|
|
2522
|
-
*/var
|
|
2538
|
+
*/var Le=function(t,e,n,i){return new(n||(n=Promise))(function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,a)}l((i=i.apply(t,e||[])).next())})};class Be{constructor(){this.store=new Map}save(t,e){return Le(this,void 0,void 0,function*(){this.store.set(t,JSON.parse(JSON.stringify(e)))})}load(t){return Le(this,void 0,void 0,function*(){const e=this.store.get(t);return e?JSON.parse(JSON.stringify(e)):null})}remove(t){return Le(this,void 0,void 0,function*(){this.store.delete(t)})}clear(){return Le(this,void 0,void 0,function*(){this.store.clear()})}has(t){return Le(this,void 0,void 0,function*(){return this.store.has(t)})}}class Ue{save(t,e){return Le(this,void 0,void 0,function*(){try{localStorage.setItem(t,JSON.stringify(e))}catch(t){throw console.error("[LocalStorage] Save error:",t),new Error(`Failed to save to localStorage: ${t}`)}})}load(t){return Le(this,void 0,void 0,function*(){try{const e=localStorage.getItem(t);return e?JSON.parse(e):null}catch(t){return console.error("[LocalStorage] Load error:",t),null}})}remove(t){return Le(this,void 0,void 0,function*(){localStorage.removeItem(t)})}clear(){return Le(this,void 0,void 0,function*(){Object.keys(localStorage).filter(t=>t.startsWith("chatbot-")).forEach(t=>{localStorage.removeItem(t)})})}has(t){return Le(this,void 0,void 0,function*(){return null!==localStorage.getItem(t)})}}class We{constructor(t="chatbot-db",e="chatbot-store"){this.dbName=t,this.storeName=e}getDB(){return Le(this,void 0,void 0,function*(){return this.db?this.db:new Promise((t,e)=>{const n=indexedDB.open(this.dbName,1);n.onerror=()=>e(n.error),n.onsuccess=()=>{this.db=n.result,t(this.db)},n.onupgradeneeded=t=>{const e=t.target.result;e.objectStoreNames.contains(this.storeName)||e.createObjectStore(this.storeName)}})})}save(t,e){return Le(this,void 0,void 0,function*(){const n=yield this.getDB();return new Promise((i,o)=>{const s=n.transaction([this.storeName],"readwrite").objectStore(this.storeName).put(e,t);s.onerror=()=>o(s.error),s.onsuccess=()=>i()})})}load(t){return Le(this,void 0,void 0,function*(){const e=yield this.getDB();return new Promise((n,i)=>{const o=e.transaction([this.storeName],"readonly").objectStore(this.storeName).get(t);o.onerror=()=>i(o.error),o.onsuccess=()=>n(o.result||null)})})}remove(t){return Le(this,void 0,void 0,function*(){const e=yield this.getDB();return new Promise((n,i)=>{const o=e.transaction([this.storeName],"readwrite").objectStore(this.storeName).delete(t);o.onerror=()=>i(o.error),o.onsuccess=()=>n()})})}clear(){return Le(this,void 0,void 0,function*(){const t=yield this.getDB();return new Promise((e,n)=>{const i=t.transaction([this.storeName],"readwrite").objectStore(this.storeName).clear();i.onerror=()=>n(i.error),i.onsuccess=()=>e()})})}has(t){return Le(this,void 0,void 0,function*(){return null!==(yield this.load(t))})}}
|
|
2523
2539
|
/**
|
|
2524
2540
|
* @license
|
|
2525
2541
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2526
2542
|
* SPDX-License-Identifier: MIT
|
|
2527
|
-
*/class
|
|
2543
|
+
*/class He{constructor(t){this.host=t,t.addController(this)}hostConnected(){}hostDisconnected(){}handleMessagesUpdate(){var t;if(!this.host.autoScroll)return;(null===(t=this.host.shadowRoot)||void 0===t?void 0:t.querySelector(".messages"))&&this.scrollToBottom()}scrollToBottom(){var t;const e=null===(t=this.host.shadowRoot)||void 0===t?void 0:t.querySelector(".messages");e&&requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight})}}export{$e as AnalyticsPlugin,Ce as ArtifactPlugin,ke as ChatPluginBase,X as ChatbotActionType,Ht as ChatbotCoreController,Y as ChatbotFileType,q as ChatbotLoadingType,K as ChatbotMessageState,He as ChatbotScrollController,J as ChatbotSender,V as ChatbotSize,G as ChatbotVariant,Qt as CustomAPIProvider,it as DEFAULT_ALLOWED_FILE_TYPES,nt as DEFAULT_MAX_FILES,et as DEFAULT_MAX_FILE_SIZE,tt as DEFAULT_MAX_MESSAGES,Z as DEFAULT_TYPING_DELAY,Q as EMPTY_STRING,$t as EventBus,ot as FILE_TYPE_MAPPINGS,zt as FileHandler,Ee as FlightCardPlugin,De as FlowDiagramPlugin,We as IndexedDBStorage,Ie as JsonGraphRendererPlugin,Ue as LocalStorageAdapter,Pe as MarkdownPlugin,Be as MemoryStorage,Pt as MessageHandler,se as MockProvider,re as MockProviders,Ct as ModuleHandler,xe as NativeWebSocketProvider,_t as NrChatbotElement,Gt as OpenAIProvider,_e as PersistencePlugin,Lt as PluginService,Me as PrintJobCardPlugin,Rt as ProviderService,Ne as SelectionCardPlugin,he as SocketProvider,St as StateHandler,Ft as StorageService,It as SuggestionHandler,Et as ThreadHandler,kt as ValidationError,At as ValidationService,ge as WorkflowSocketProvider};
|