@progress/kendo-react-conversational-ui 11.4.0 → 12.0.0-develop.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai-prompt/views/AIPromptView.js +2 -2
- package/ai-prompt/views/AIPromptView.mjs +26 -26
- package/chat/components/Action.js +8 -0
- package/chat/components/Action.mjs +37 -0
- package/chat/components/ActionGroup.js +8 -0
- package/chat/components/ActionGroup.mjs +56 -0
- package/chat/components/Attachment.js +8 -0
- package/chat/components/Attachment.mjs +23 -0
- package/chat/components/AttachmentGroup.js +8 -0
- package/chat/components/AttachmentGroup.mjs +66 -0
- package/chat/components/Chat.js +8 -0
- package/chat/components/Chat.mjs +388 -0
- package/chat/components/ChatContext.js +8 -0
- package/{components/base/FocusableUponSelection.mjs → chat/components/ChatContext.mjs} +10 -10
- package/chat/components/ChatMessage.js +8 -0
- package/chat/components/ChatMessage.mjs +284 -0
- package/chat/components/DateMarker.js +8 -0
- package/chat/components/DateMarker.mjs +22 -0
- package/chat/components/Header.js +8 -0
- package/{utils.mjs → chat/components/Header.mjs} +4 -2
- package/chat/components/MessageGroup.js +8 -0
- package/chat/components/MessageGroup.mjs +88 -0
- package/chat/components/NewMessage.js +8 -0
- package/chat/components/NewMessage.mjs +264 -0
- package/chat/components/Notification.js +8 -0
- package/chat/components/Notification.mjs +24 -0
- package/chat/components/SuggestionsGroup.js +1 -1
- package/chat/components/SuggestionsGroup.mjs +40 -23
- package/chat/components/elements/FileBox.js +8 -0
- package/chat/components/elements/FileBox.mjs +69 -0
- package/chat/components/elements/PinnedMessage.js +8 -0
- package/chat/components/elements/PinnedMessage.mjs +46 -0
- package/chat/components/templates/HeroCard.js +8 -0
- package/chat/components/templates/HeroCard.mjs +26 -0
- package/chat/utils/fieldMapping.js +8 -0
- package/chat/utils/fieldMapping.mjs +79 -0
- package/chat/utils.js +8 -0
- package/chat/utils.mjs +65 -0
- package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
- package/index.d.mts +423 -165
- package/index.d.ts +423 -165
- package/index.js +1 -1
- package/index.mjs +34 -27
- package/messages/index.js +1 -1
- package/messages/index.mjs +38 -16
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +7 -7
- package/components/Action.js +0 -8
- package/components/Action.mjs +0 -45
- package/components/ActionGroup.js +0 -8
- package/components/ActionGroup.mjs +0 -36
- package/components/Attachment.js +0 -8
- package/components/Attachment.mjs +0 -50
- package/components/AttachmentGroup.js +0 -8
- package/components/AttachmentGroup.mjs +0 -64
- package/components/Chat.js +0 -8
- package/components/Chat.mjs +0 -214
- package/components/ChatMessage.js +0 -8
- package/components/ChatMessage.mjs +0 -63
- package/components/ChatToolbar.js +0 -8
- package/components/ChatToolbar.mjs +0 -33
- package/components/DateMarker.js +0 -8
- package/components/DateMarker.mjs +0 -19
- package/components/MessageGroup.js +0 -8
- package/components/MessageGroup.mjs +0 -67
- package/components/NewMessage.js +0 -8
- package/components/NewMessage.mjs +0 -106
- package/components/base/FocusableUponSelection.js +0 -8
- package/components/base/SelectableItemsContainer.js +0 -8
- package/components/base/SelectableItemsContainer.mjs +0 -42
- package/components/templates/HeroCard.js +0 -8
- package/components/templates/HeroCard.mjs +0 -44
- package/utils.js +0 -8
- /package/{ViewItem.js → chat/ViewItem.js} +0 -0
- /package/{ViewItem.mjs → chat/ViewItem.mjs} +0 -0
package/chat/utils.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2025 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),n=require("../messages/index.js"),g=(t,e)=>t&&e.author&&t.id===e.author.id,l=(t,e)=>{const o=e.toLanguageString("chatSender.deletedMessage",n.messages[n.chatSenderDeletedMessage]),s=e.toLanguageString("chatReceiver.deletedMessage",n.messages[n.chatReceiverDeletedMessage]);return t?o:s},u=t=>{navigator.clipboard.writeText(t)},h=(t,e)=>t.find(o=>o.id===e),T=(t,e)=>{const o=e?e.querySelector(`[data-message-id="${t}"]`):document.querySelector(`[data-message-id="${t}"]`);if(!o)return;const s=e==null?void 0:e.querySelector(".k-message-list");if(s){const c=s.getBoundingClientRect().top,a=o.getBoundingClientRect().top,d=s.scrollTop+(a-c);s.scrollTo({top:d,behavior:"smooth"})}else o.scrollIntoView({behavior:"smooth",block:"start"})},r=/(https?:\/\/[^\s]+)/g,p=t=>{if(!t)return[""];const e=t.split(r),o=[];return e.forEach(s=>{s&&r.test(s)?(r.lastIndex=0,o.push(i.createElement("a",{key:s,href:s,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"}},s))):s&&o.push(s)}),o};exports.URL_REGEX=r;exports.convertTextToLinkedContent=p;exports.copyToClipboard=u;exports.getDeletedMessageText=l;exports.getMessageById=h;exports.isAuthor=g;exports.scrollToMessageById=T;
|
package/chat/utils.mjs
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2025 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
import i from "react";
|
|
9
|
+
import { messages as n, chatSenderDeletedMessage as l, chatReceiverDeletedMessage as g } from "../messages/index.mjs";
|
|
10
|
+
const m = (t, e) => t && e.author && t.id === e.author.id, p = (t, e) => {
|
|
11
|
+
const s = e.toLanguageString(
|
|
12
|
+
"chatSender.deletedMessage",
|
|
13
|
+
n[l]
|
|
14
|
+
), o = e.toLanguageString(
|
|
15
|
+
"chatReceiver.deletedMessage",
|
|
16
|
+
n[g]
|
|
17
|
+
);
|
|
18
|
+
return t ? s : o;
|
|
19
|
+
}, f = (t) => {
|
|
20
|
+
navigator.clipboard.writeText(t);
|
|
21
|
+
}, T = (t, e) => t.find((s) => s.id === e), M = (t, e) => {
|
|
22
|
+
const s = e ? e.querySelector(`[data-message-id="${t}"]`) : document.querySelector(`[data-message-id="${t}"]`);
|
|
23
|
+
if (!s)
|
|
24
|
+
return;
|
|
25
|
+
const o = e == null ? void 0 : e.querySelector(".k-message-list");
|
|
26
|
+
if (o) {
|
|
27
|
+
const c = o.getBoundingClientRect().top, a = s.getBoundingClientRect().top, d = o.scrollTop + (a - c);
|
|
28
|
+
o.scrollTo({
|
|
29
|
+
top: d,
|
|
30
|
+
behavior: "smooth"
|
|
31
|
+
});
|
|
32
|
+
} else
|
|
33
|
+
s.scrollIntoView({
|
|
34
|
+
behavior: "smooth",
|
|
35
|
+
block: "start"
|
|
36
|
+
});
|
|
37
|
+
}, r = /(https?:\/\/[^\s]+)/g, y = (t) => {
|
|
38
|
+
if (!t)
|
|
39
|
+
return [""];
|
|
40
|
+
const e = t.split(r), s = [];
|
|
41
|
+
return e.forEach((o) => {
|
|
42
|
+
o && r.test(o) ? (r.lastIndex = 0, s.push(
|
|
43
|
+
i.createElement(
|
|
44
|
+
"a",
|
|
45
|
+
{
|
|
46
|
+
key: o,
|
|
47
|
+
href: o,
|
|
48
|
+
target: "_blank",
|
|
49
|
+
rel: "noopener noreferrer",
|
|
50
|
+
style: { color: "inherit", textDecoration: "underline" }
|
|
51
|
+
},
|
|
52
|
+
o
|
|
53
|
+
)
|
|
54
|
+
)) : o && s.push(o);
|
|
55
|
+
}), s;
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
r as URL_REGEX,
|
|
59
|
+
y as convertTextToLinkedContent,
|
|
60
|
+
f as copyToClipboard,
|
|
61
|
+
p as getDeletedMessageText,
|
|
62
|
+
T as getMessageById,
|
|
63
|
+
m as isAuthor,
|
|
64
|
+
M as scrollToMessageById
|
|
65
|
+
};
|
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
13
13
|
*-------------------------------------------------------------------------------------------
|
|
14
14
|
*/
|
|
15
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@progress/kendo-react-common"),require("@progress/kendo-react-intl"),require("prop-types"),require("@progress/kendo-svg-icons"),require("@progress/kendo-react-buttons"),require("@progress/kendo-react-layout"),require("@progress/kendo-react-inputs"),require("@progress/kendo-react-popup")):"function"==typeof define&&define.amd?define(["exports","react","@progress/kendo-react-common","@progress/kendo-react-intl","prop-types","@progress/kendo-svg-icons","@progress/kendo-react-buttons","@progress/kendo-react-layout","@progress/kendo-react-inputs","@progress/kendo-react-popup"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoReactConversationalUi={},e.React,e.KendoReactCommon,e.KendoReactIntl,e.PropTypes,e.KendoSvgIcons,e.KendoReactButtons,e.KendoReactLayout,e.KendoReactInputs,e.KendoReactPopup)}(this,(function(e,t,s,n,o,a,r,i,l,c){"use strict";function p(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:function(){return e[s]}})}})),t.default=e,Object.freeze(t)}var m=p(t);let u=class extends m.Component{componentDidUpdate(e){!e.selected&&this.props.selected&&this.elementToFocus.focus()}};const d=class extends u{render(){return m.createElement("div",{className:this.getClassNames(),tabIndex:this.props.tabIndex,onClick:()=>this.props.onRequestSelection(this.props.item.selectionIndex),onFocus:()=>this.props.onRequestSelection(this.props.item.selectionIndex),ref:e=>{this.elementToFocus=e}},this.getTimestampView(),this.getMainView(),this.getStatusView())}getMainView(){return this.props.item.typing?m.createElement("div",{className:"k-chat-bubble"},m.createElement("div",{className:"k-typing-indicator"},m.createElement("span",null),m.createElement("span",null),m.createElement("span",null))):this.props.template?m.createElement(this.props.template,{item:this.props.item}):this.props.item.text?m.createElement("div",{className:"k-chat-bubble"},this.props.item.text):null}getTimestampView(){let e=null;return this.props.item.timestamp&&(e=m.createElement("time",{className:"k-message-time","aria-hidden":!this.props.selected},n.provideIntlService(this).formatDate(this.props.item.timestamp,this.props.dateFormat))),e}getStatusView(){let e=null;return this.props.item.status&&(e=m.createElement("span",{className:"k-message-status"},this.props.item.status)),e}getClassNames(){return s.classNames({"k-only":this.props.isOnlyItemInGroup},{"k-first":this.props.isFirstItemInGroup&&!this.props.isOnlyItemInGroup},{"k-last":this.props.isLastItemInGroup&&!this.props.isOnlyItemInGroup},{"k-selected":this.props.selected},{"k-focus":this.props.selected},"k-message")}};d.defaultProps={dateFormat:"g",tabIndex:-1};let h=d;n.registerForIntl(h);const g=(e,t)=>e&&t.author&&e.id===t.author.id,k=e=>e[e.length-1],I=e=>(t,s,n)=>{const o=n===e-1;return((e,t)=>{const s=t.timestamp,n=k(e);if(s&&(!n||((e,t)=>e&&t&&(t.getDate()!==e.getDate()||t.getMonth()!==e.getMonth()||t.getFullYear()!==e.getFullYear()))(s,n.timestamp))){const t={type:"date-marker",timestamp:s,trackBy:s.getTime()};e.push(t)}})(t,s),((e,t,s)=>{const n=k(e);let o;t.typing&&!s||(n&&"message-group"===n.type&&(o=n.messages),o&&g(t.author,k(o))?o.push(t):e.push({type:"message-group",messages:[t],author:t.author,timestamp:t.timestamp,trackBy:t}))})(t,s,o),s.attachments&&s.attachments.length>1&&t.push({type:"attachment-group",attachments:s.attachments,attachmentLayout:s.attachmentLayout,timestamp:s.timestamp,trackBy:s}),s.suggestedActions&&o&&t.push({type:"action-group",actions:s.suggestedActions,timestamp:s.timestamp,trackBy:s}),t};let E=class extends u{constructor(){super(...arguments),this.onKeyDown=e=>{e.keyCode===s.Keys.enter&&this.props.onActionExecute(this.props.item,e)}}render(){return m.createElement("span",{role:"button",className:this.getClassNames(),onClick:e=>this.props.onActionExecute(this.props.item,e),ref:e=>{this.elementToFocus=e},onKeyDown:this.onKeyDown,tabIndex:0},this.props.item.title||this.props.item.value)}getClassNames(){return s.classNames("k-quick-reply",{"k-first":this.props.isFirstItemInGroup},{"k-last":this.props.isLastItemInGroup},{"k-selected":this.props.selected},{"k-focus":this.props.selected})}},v=class extends m.Component{constructor(){super(...arguments),this.state={selectedItemIndex:null},this.onRequestContainerSelection=()=>this.props.onRequestSelection(this.props.group.selectionIndex),this.onKeyDown=e=>{let t,n,o=null;this.isKeyboardNavigationLeftRight?(t=s.Keys.left,n=s.Keys.right):(t=s.Keys.up,n=s.Keys.down),e.keyCode===t?o=this.navigate(!1):e.keyCode===n&&(o=this.navigate(!0)),null!==o&&(e.preventDefault(),e.stopPropagation())}}static getDerivedStateFromProps(e,t){return e.selected||null===t.selectedItemIndex?e.selected&&null===t.selectedItemIndex?{selectedItemIndex:0}:null:{selectedItemIndex:null}}navigate(e,t=0){let s=null;const n=this.state.selectedItemIndex;return e?null===n?s=t:n<this.getLastSelectionIndex()&&(s=n+1):null===n?s=0:n>0&&(s=n-1),null!==s&&this.setState({selectedItemIndex:s}),s}get isKeyboardNavigationLeftRight(){return!0}getLastSelectionIndex(){let e=-1;if("action-group"===this.props.group.type){const t=this.props.group;e=t.actions?t.actions.length-1:-1}else if("attachment-group"===this.props.group.type){const t=this.props.group;e=t.attachments?t.attachments.length-1:-1}return e}};class C extends v{constructor(e){super(e)}render(){const e=this.props.group.actions?this.props.group.actions.length-1:0;return m.createElement("div",{className:this.getClassNames(),onClick:this.onRequestContainerSelection,onKeyDown:this.onKeyDown},this.props.group.actions&&this.props.group.actions.map(((t,s)=>m.createElement(E,{item:t,onActionExecute:this.props.onActionExecute,selected:s===this.state.selectedItemIndex,isFirstItemInGroup:0===s,isLastItemInGroup:s===e,key:s}))))}getClassNames(){return s.classNames("k-quick-replies")}}let y=class extends u{render(){return m.createElement("div",{className:this.getClassNames(),tabIndex:this.getTabIndexValue(),onClick:this.props.onClick,ref:e=>{this.elementToFocus=e}},this.props.template?m.createElement(this.props.template,{item:this.props.item}):m.createElement("div",{className:"k-card"},m.createElement("div",{className:"k-card-body"},this.getTitleView(),this.getSubtitleView(),this.getContentView())))}getTabIndexValue(){if(void 0!==this.props.tabbable)return this.props.tabbable?0:-1}getClassNames(){return s.classNames({"k-selected":this.props.selected},{"k-focus":this.props.selected},{"k-first":this.props.isFirstItemInGroup},{"k-last":this.props.isLastItemInGroup})}getTitleView(){return this.props.item.title?m.createElement("h5",{className:"k-card-title"},this.props.item.title):null}getSubtitleView(){return this.props.item.subtitle?m.createElement("h6",{className:"k-card-subtitle"},this.props.item.subtitle):null}getContentView(){return 0===this.props.item.contentType.indexOf("image/")?m.createElement("img",{src:this.props.item.content}):this.props.item.content}};class f extends v{render(){const e=this.isCardDeckLayout(this.props),t=m.createElement("div",{className:this.getClassNames(),onKeyDown:e?void 0:this.onKeyDown},this.props.group.attachments.map(((e,t)=>m.createElement(y,{item:e,template:this.props.itemTemplate,selected:t===this.state.selectedItemIndex,tabbable:this.props.isLastGroup&&t===this.state.selectedItemIndex,isFirstItemInGroup:0===t,isLastItemInGroup:t===this.getLastItemIndex(),onClick:()=>this.onAttachmentClick(t),key:t}))));return e?m.createElement("div",{className:"k-card-deck-scrollwrap",onKeyDown:this.onKeyDown},this.getLeftScrollBtn(),t,this.getRightScrollBtn()):t}get isKeyboardNavigationLeftRight(){return this.isCardDeckLayout(this.props)}getLastItemIndex(){return this.props.group.attachments.length-1}getLeftScrollBtn(){let e=null;return this.isCardDeckLayout(this.props)&&this.state.selectedItemIndex&&(e=m.createElement(r.Button,{icon:"chevron-left",onClick:()=>this.onNavigateBtnClick(!1),svgIcon:a.chevronLeftIcon})),e}getRightScrollBtn(){let e=null;return this.isCardDeckLayout(this.props)&&this.state.selectedItemIndex!==this.getLastItemIndex()&&(e=m.createElement(r.Button,{icon:"chevron-right",onClick:()=>this.onNavigateBtnClick(!0),svgIcon:a.chevronRightIcon})),e}onAttachmentClick(e){this.onRequestContainerSelection(),this.setState({selectedItemIndex:e})}onNavigateBtnClick(e){this.onRequestContainerSelection(),this.navigate(e,1)}isCardDeckLayout(e){return"list"!==e.group.attachmentLayout}getClassNames(){return s.classNames({"k-card-list":this.props.group.attachmentLayout,"k-card-deck":this.isCardDeckLayout(this.props)})}}let b=class extends m.Component{render(){const e=this.props.item;return m.createElement("div",{className:"k-timestamp"},n.provideIntlService(this).formatDate(e.timestamp,"D"))}};n.registerForIntl(b);const w="newMessage.sendButton",x="newMessage.optionsButton",N="newMessage.messageInput",T="avatar.alt",S="messageList.ariaLabel",R="aIPrompt.noOutputs",B="aIPrompt.cancel",D={[w]:"Send",[x]:"Options",[N]:"Message",[T]:"Avatar",[S]:"Message list",[B]:"Cancel",[R]:"No output from AI available"};class L extends m.Component{render(){const{avatarUrl:e,avatarAltText:t,name:s}=this.props.group.author,o=n.provideLocalizationService(this);return m.createElement("div",{className:this.getMsgGroupClassNames()},s&&m.createElement("p",{className:"k-author"},s),e&&m.createElement(i.Avatar,{type:"image"},m.createElement("img",{src:e,alt:void 0!==t?t:o.toLanguageString(T,D[T])})),this.getGroupMessagesView())}getMsgGroupClassNames(){return s.classNames("k-message-group",{"k-no-avatar":!this.props.group.author.avatarUrl,"k-alt":g(this.props.user,this.props.group.messages[0])})}getGroupMessagesView(){const e=this.props.group.messages.length-1;return this.props.group.messages.map(((t,s)=>{const n=[m.createElement(this.props.message,{item:t,template:this.props.itemTemplate,selected:t.selectionIndex===this.props.selectedItemIndex,onRequestSelection:this.props.onRequestSelection,tabIndex:s===e&&this.props.isLastGroup?0:-1,isFirstItemInGroup:0===s,isLastItemInGroup:s===e,isOnlyItemInGroup:0===e,key:s})];return t.attachments&&1===t.attachments.length&&n.push(m.createElement(y,{item:t.attachments[0],template:this.props.attachmentTemplate,selected:!1,key:`att-${s}`})),n}))}}const M=m.forwardRef(((e,t)=>{const{className:n,...o}=e,a=m.useRef(null),i=m.useRef(null);m.useImperativeHandle(i,(()=>({element:a.current,props:e}))),m.useImperativeHandle(t,(()=>i.current));const l=m.useMemo((()=>s.classNames("k-chat-toolbar k-toolbar",n)),[n]);return m.useEffect((()=>{null!==a.current&&s.focusFirstFocusableChild(a.current,[...s.TABBABLE_ELEMENTS])}),[]),m.createElement(r.Toolbar,{id:e.id,ref:e=>{e&&(a.current=e.element)},className:l,...o},m.createElement("div",{className:"k-button-list k-toolbar-group"},e.children))}));M.displayName="KendoReactChatToolbar";class V extends m.Component{constructor(){super(...arguments),this.state={focused:!1},this.inputEl=null,this.toolbarBtnRef=m.createRef(),this.onInputKeyDown=e=>{switch(e.key){case"Enter":return this.sendMessage(e);case"F10":return this.openToolbar(e);default:return}},this.sendMessage=e=>{if(this.props.onMessageSend&&null!==this.inputEl){const t=this.inputEl.value;if(t){const s={author:this.props.user,text:t,timestamp:new Date};this.props.onMessageSend(s,e)}}null!==this.inputEl&&(this.inputEl.value=null)},this.openToolbar=e=>{null!==this.toolbarBtnRef.current&&(e.preventDefault(),this.props.onToolbarActionButtonClick(!this.props.showToolbar,e))}}render(){const e=n.provideLocalizationService(this),t=m.createElement("input",{type:"text",className:this.getClassNames(),placeholder:this.props.placeholder,onKeyDown:this.onInputKeyDown,onFocus:()=>this.setState({focused:!0}),onBlur:()=>this.setState({focused:!1}),ref:e=>{this.inputEl=e},"aria-label":e.toLanguageString(N,D[N])}),s=m.createElement(r.Button,{fillMode:"flat",themeColor:"base",className:"k-chat-send",icon:"paper-plane",svgIcon:a.paperPlaneIcon,onClick:this.sendMessage,"aria-label":e.toLanguageString(w,D[w]),dir:this.props.isDirectionRightToLeft?"rtl":void 0}),o=m.createElement(r.Button,{ref:this.toolbarBtnRef,fillMode:"flat",themeColor:"base",icon:"more-horizontal",svgIcon:a.moreHorizontalIcon,onClick:e=>this.props.onToolbarActionButtonClick(!this.props.showToolbar,e),"aria-label":e.toLanguageString(x,D[x])});return m.createElement(m.Fragment,null,m.createElement("span",{className:"k-message-box k-textbox k-input k-input-md k-rounded-md k-input-solid"},this.props.MessageBox?m.createElement(this.props.MessageBox,{messageInput:t,sendButton:s,toolbarButton:o}):m.createElement(m.Fragment,null,t,m.createElement("span",{className:"k-input-separator k-input-separator-vertical"}),m.createElement("span",{className:"k-input-suffix k-input-suffix-horizontal"},this.props.toolbar&&o,s))),this.props.showToolbar&&m.createElement(M,null,this.props.toolbar))}focusInput(){null!==this.inputEl&&this.inputEl.focus()}getClassNames(){return s.classNames("k-input-inner",{"k-focus":this.state.focused})}}const A=Object.freeze({name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:0,version:"11.4.0",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"}),P=class e extends m.Component{constructor(e){super(e),this.viewItems=[],this.isDirectionRightToLeft=!1,this.scrollToBottomOnLoadingData=!0,this.showLicenseWatermark=!1,this.onFocus=()=>{clearTimeout(this.timeoutIdForChatLosingFocus)},this.onBlur=()=>{this.timeoutIdForChatLosingFocus=window.setTimeout((()=>{this.setState({selectedItemIndex:null})}),0)},this.onSelectionRequested=e=>{this.setState({selectedItemIndex:e})},this.onKeyDown=e=>{let t=null;const n=null!==this.state.selectedItemIndex?this.state.selectedItemIndex:this.viewItems.lastSelectionIndex;e.keyCode===s.Keys.up?null===n?t=0:n>0&&(t=n-1):e.keyCode===s.Keys.down&&(null===n?t=0:n<this.viewItems.lastSelectionIndex&&(t=n+1)),null!==t&&(this.setState({selectedItemIndex:t}),e.preventDefault())},this.onMessageSend=(e,t)=>{s.dispatchEvent(this.props.onMessageSend,t,this,{message:e})},this.onActionExecute=(e,t)=>{if(s.dispatchEvent(this.props.onActionExecute,t,this,{action:e}),!t.isDefaultPrevented()){switch(e.type){case"reply":this.onMessageSend({author:this.props.user,text:e.value,timestamp:new Date},t);break;case"call":window.open("tel:"+e.value);break;case"openUrl":window.open(e.value)}this.newMsgComp.focusInput()}},this.showLicenseWatermark=!s.validatePackage(A,{component:"Chat"}),this.licenseMessage=s.getLicenseMessage(A),this.state={selectedItemIndex:null,isFirstRender:!0}}render(){this.viewItems=this.getViewItemsFromMsgs(this.props.messages),this.isDirectionRightToLeft=this.checkIsDirectionRightToLeft(this.props);const e=n.provideLocalizationService(this);return m.createElement("div",{style:{width:this.props.width,position:"relative"},onKeyDown:this.onKeyDown,className:this.getClassNames(),ref:e=>{this.chatWrapperEl=e}},m.createElement("div",{className:"k-message-list k-avatars",onBlur:this.onBlur,onFocus:this.onFocus,role:"log","aria-label":e.toLanguageString(S,D[S]),"aria-live":"polite",onScroll:e=>{this.scrollToBottomOnLoadingData=e.currentTarget.scrollTop===e.currentTarget.scrollHeight-e.currentTarget.clientHeight},ref:e=>{this.viewItemsWrapperEl=e}},m.createElement("div",{className:"k-message-list-content"},this.renderViewItems())),m.createElement(V,{user:this.props.user,onMessageSend:this.onMessageSend,isDirectionRightToLeft:this.isDirectionRightToLeft,ref:e=>{this.newMsgComp=e},placeholder:this.props.placeholder,MessageBox:this.props.messageBox,toolbar:this.props.toolbar,onToolbarActionButtonClick:this.props.onToolbarActionExecute,showToolbar:this.props.showToolbar}),this.showLicenseWatermark&&m.createElement(s.WatermarkOverlay,{message:this.licenseMessage}))}componentDidMount(){this.setState({isFirstRender:!1},(()=>{this.nextTickId=window.setTimeout((()=>this.scrollViewItemsToBottom()),250)}))}componentWillUnmount(){clearTimeout(this.nextTickId)}componentDidUpdate(e){e.messages.length!==this.props.messages.length&&this.scrollToBottomOnLoadingData&&this.scrollViewItemsToBottom()}getClassNames(){return s.classNames("k-chat",this.props.className,{"k-rtl":this.isDirectionRightToLeft})}checkIsDirectionRightToLeft(e){return!!(void 0!==e.dir?"rtl"===e.dir:this.chatWrapperEl&&"rtl"===getComputedStyle(this.chatWrapperEl).direction)}renderViewItems(){const t=this.viewItems.length-1;return this.viewItems.map(((s,n)=>"date-marker"===s.type?m.createElement(b,{item:s,key:n}):"message-group"===s.type?m.createElement(L,{group:s,itemTemplate:this.props.messageTemplate,attachmentTemplate:this.props.attachmentTemplate,user:this.props.user,selectedItemIndex:this.state.selectedItemIndex,onRequestSelection:this.onSelectionRequested,isLastGroup:n===t,key:n,message:this.props.message||e.defaultProps.message}):"attachment-group"===s.type?m.createElement(f,{group:s,itemTemplate:this.props.attachmentTemplate,onRequestSelection:this.onSelectionRequested,selected:s.selectionIndex===this.state.selectedItemIndex,isLastGroup:n===t,key:n}):"action-group"===s.type?m.createElement(C,{group:s,onActionExecute:this.onActionExecute,onRequestSelection:this.onSelectionRequested,selected:s.selectionIndex===this.state.selectedItemIndex,isLastGroup:n===t,key:n}):void 0))}scrollViewItemsToBottom(){this.viewItemsWrapperEl&&(this.viewItemsWrapperEl.scrollTop=this.viewItemsWrapperEl.scrollHeight-this.viewItemsWrapperEl.clientHeight)}getViewItemsFromMsgs(e){return e.length>0?(e=>{const t=e.slice().reduce(I(e.length),[]);return function(e){let t=0;e.forEach((e=>{"message-group"===e.type?e.messages.forEach((e=>{e.selectionIndex=t++})):("attachment-group"===e.type||"action-group"===e.type)&&(e.selectionIndex=t++)})),e.lastSelectionIndex=t-1}(t),t})(e):[]}};P.propTypes={messages:o.arrayOf(o.object),user:o.object,messageTemplate:o.any,attachmentTemplate:o.any,width:o.oneOfType([o.string,o.number]),onMessageSend:o.func,onActionExecute:o.func,dir:o.string,messageBox:o.any},P.defaultProps={messages:[],dateFormat:"g",message:h};let F=P;const K=e=>{const{suggestions:t,onSuggestionClick:n,suggestionsView:o}=e,a=()=>t.map((e=>m.createElement("span",{role:"button",tabIndex:e.disabled?-1:0,"aria-label":e.description,"aria-disabled":e.disabled,onClick:t=>!e.disabled&&n(t,e),onKeyDown:t=>!e.disabled&&((e,t)=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),n(e,t))})(t,e),key:e.id,title:e.description,className:s.classNames("classic"===o?"k-prompt-suggestion":"k-suggestion",{"k-disabled":e.disabled})},e.text)));return"classic"===o?a():m.createElement("div",{role:"group",className:"k-suggestion-group"},a())};class O extends m.Component{constructor(){super(...arguments),this.onBtnClick=(e,t)=>{s.dispatchEvent(this.props.onActionExecute,t,this,{action:e})}}render(){return m.createElement("div",{className:"k-card"},m.createElement("img",{className:"k-card-image",src:this.props.imageUrl,style:{maxWidth:this.props.imageMaxWidth}}),m.createElement("div",{className:"k-card-body"},this.getTitleView(),this.getSubtitleView()),m.createElement("div",{className:"k-card-actions k-card-actions-vertical"},this.getActionsView()))}getActionsView(){return this.props.actions.map(((e,t)=>m.createElement("span",{className:"k-card-action",key:t},m.createElement(r.Button,{fillMode:"flat",onClick:t=>this.onBtnClick(e,t)},e.title))))}getTitleView(){let e=null;return this.props.title&&(e=m.createElement("h5",{className:"k-card-title"},this.props.title)),e}getSubtitleView(){let e=null;return this.props.subtitle&&(e=m.createElement("h6",{className:"k-card-subtitle"},this.props.subtitle)),e}}const q=e=>{const{activeView:s,toolbarItems:n,activeViewChange:o}=e;return t.createElement("div",{className:"k-prompt-header"},t.createElement(r.Toolbar,{keyboardNavigation:!1,role:"toolbar",className:"k-toolbar-flat"},n.map((e=>t.isValidElement(e)?e:t.createElement(r.Button,{key:e.name,className:s===e.name?"k-selected":"",size:"medium",themeColor:"primary",fillMode:"flat",rounded:"full",title:e.buttonText,svgIcon:e.buttonIcon,onClick:()=>(e=>{null==o||o.call(null,e)})(e.name)},e.buttonText)))))},G={name:"Output view",buttonText:"Output",buttonIcon:a.commentIcon},z={name:"Commands view",buttonIcon:a.moreHorizontalIcon},W={name:"Prompt view",buttonText:"Ask AI",buttonIcon:a.sparklesIcon},j=t.createContext([{},()=>{}]),U=()=>t.useContext(j),H=e=>{const{children:s}=e;return t.createElement("div",{className:"k-prompt-footer"},t.createElement("div",{className:"k-actions k-actions-start k-actions-horizontal k-prompt-actions"},s))},$=t.forwardRef(((e,s)=>{const{children:o,streaming:i,onCancel:l}=e,c=n.useLocalization().toLanguageString(B,D[B]),[p]=U(),m=p.activeView===G.name,u=i&&m,d=t.useCallback((e=>{"Escape"===e.key&&u&&l&&(e.preventDefault(),l())}),[u,l]);return t.createElement("div",{className:"k-prompt-content",ref:s,onKeyDown:d},u&&t.createElement(r.FloatingActionButton,{onClick:l,svgIcon:a.stopSmIcon,icon:"stop-sm",size:"medium",positionMode:"absolute",className:"k-prompt-stop-fab k-generating","aria-label":c,title:c}),t.createElement("div",{className:"k-prompt-view"},o))}));$.displayName="KendoReactAIPromptContent";const _=e=>{const[t]=U();return t.activeView===e.name?e.children:null},Y=e=>{const[s,n]=t.useState(!0),{children:o,title:i}=e;return t.createElement("div",{className:"k-prompt-expander"},t.createElement(r.Button,{"aria-controls":e.id,fillMode:"flat",svgIcon:s?a.chevronUpIcon:a.chevronDownIcon,title:i,onClick:()=>n(!s),"aria-expanded":s},i),s&&t.createElement("div",{id:e.id,className:"k-prompt-expander-content"},o))},J=e=>null==e?void 0:e.map((e=>t.createElement(i.PanelBarItem,{title:e.text,key:e.id,svgIcon:e.svgIcon,data:e},e.children&&J(e.children||[])))),Q=({show:e=!1,anchor:s,onOpen:n,onClose:o,animate:a=!0,appendTo:r,popupOptions:i={},children:l,style:p})=>t.createElement(c.Popup,{show:e,anchor:s,style:p,animate:a,appendTo:r,onOpen:n,onClose:o,...i},l),X=({placeholder:e="Ask or generate content with AI...",promptValue:n,onMenuClick:o,promptInput:i=l.TextArea,generateButton:c,enableSpeechToText:p=!1,streaming:m=!1,commands:u,onPromptRequest:d,onPromptCancel:h})=>{const[g,k]=t.useState(n||""),[I,E]=s.useCustomComponent(c),[v,C]=s.useCustomComponent(i),y={svgIcon:m?a.stopSmIcon:a.paperPlaneIcon,active:(!!m).toString(),title:"Send Button","aria-label":"Send Button",disabled:!g.trim()&&!m,"aria-disabled":!g.trim()&&!m},f={placeholder:e,className:"!k-flex-row",autoSize:!0,rows:1},b=u&&u.length>0,w=Object.keys(E).length>0?E:y,x=Object.keys(C).length>0?C:f,N=e=>{const{isFinal:t,alternatives:s}=e;if(t&&s.length>0){const e=s[0].transcript,t=(()=>{const t=g,s=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(s?" ":"")+e})();k(t)}},T=()=>{g.trim()&&d&&d(g.trim())};return t.createElement(v,{value:g,onChange:e=>{const t=e.target.value;k(t)},onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&(e.preventDefault(),T())},prefix:b||p?t.createElement(t.Fragment,null,t.createElement(l.InputPrefix,{className:"!k-align-items-start"},b&&t.createElement(r.Button,{"aria-label":"Commands Button",title:"Commands Button",fillMode:"flat",svgIcon:a.menuIcon,onClick:o}),p&&t.createElement(r.SpeechToTextButton,{fillMode:"flat",..."object"==typeof p?{...p,onResult:p.onResult||N}:{onResult:N}})),t.createElement(l.InputSeparator,null)):void 0,suffix:t.createElement(l.InputSuffix,{className:"!k-align-items-start"},t.createElement(I,{className:s.classNames("k-prompt-send",{"k-generating":m,"k-active":m}),fillMode:"flat",onClick:m?h:T,...w})),...x})};e.AIPrompt=e=>{const n=!s.validatePackage(A,{component:"AIPrompt"}),o=s.getLicenseMessage(A),{activeView:a,toolbarItems:r,children:i,onActiveViewChange:l,onPromptRequest:c,onCommandExecute:p,style:m,dir:u,className:d,streaming:h,loading:g,onCancel:k,suggestionsView:I,...E}=e,v=r||[W,G],[C,y]=t.useState({activeView:a}),f={...C,activeView:a,streaming:h,loading:g,suggestionsView:null!=I?I:"classic",onCancel:k,onActiveViewChange:l,onPromptRequest:c,onCommandExecute:p};return t.createElement(j.Provider,{value:[f,e=>{y(e)}]},t.createElement("div",{className:s.classNames("k-prompt",d),style:m,dir:u,...E},t.createElement(q,{activeView:f.activeView,toolbarItems:v,activeViewChange:l}),i,n&&t.createElement(s.WatermarkOverlay,{message:o})))},e.AIPromptCommandsView=e=>{const{commands:s}=e,[n]=U();return t.createElement(_,{name:z.name},t.createElement($,{streaming:n.streaming,onCancel:n.onCancel},t.createElement("div",{className:"k-prompt-view"},t.createElement(i.PanelBar,{onSelect:e=>{var t,s,o;const a=null==(s=null==(t=e.target)?void 0:t.props)?void 0:s.data;null!=(o=a.children)&&o.length||n.onCommandExecute&&n.onCommandExecute.call(null,a)},selected:""},J(null!=s?s:[])))))},e.AIPromptContent=$,e.AIPromptFooter=H,e.AIPromptOutputView=e=>{const[s,o]=t.useState(""),l=t.useRef(null),[c]=U(),{outputs:p,showOutputRating:m,outputCard:u}=e,{header:d,body:h,actions:g}=u||{},k=n.useLocalization(),I=(e,t)=>{c.onPromptRequest&&c.onPromptRequest.call(null,e.prompt,{...e,ratingType:t,isRetry:!1}),E()},E=()=>{l&&l.current&&l.current.scrollTo({top:0,behavior:"smooth"})},v=t.createElement(i.Card,null,t.createElement(i.CardHeader,null,t.createElement(i.CardTitle,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}})),t.createElement(i.CardSubtitle,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),t.createElement(i.CardBody,null,t.createElement("span",{className:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}})),t.createElement(i.CardActions,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),C=null==p?void 0:p.map(((e,n)=>t.createElement(i.Card,{key:`${e.id}_${n}`},t.createElement(i.CardHeader,null,d?d(e):t.createElement(t.Fragment,null,e.title&&t.createElement(i.CardTitle,null,e.title),e.subTitle&&t.createElement(i.CardSubtitle,null,e.subTitle))),t.createElement(i.CardBody,null,h?h(e):e.responseContent),t.createElement(i.CardActions,null,g?g(e):t.createElement(t.Fragment,null,t.createElement(r.Button,{size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:s===e.id?a.checkIcon:a.copyIcon,onClick:()=>(e=>{null!=e&&e.responseContent&&navigator.clipboard.writeText(e.responseContent),o(e.id),setTimeout((()=>{o("")}),1e3)})(e)},"Copy"),t.createElement(r.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:a.arrowRotateCwIcon,onClick:()=>(e=>{c.onPromptRequest&&c.onPromptRequest.call(null,e.prompt,{...e,isRetry:!0}),E()})(e)},"Retry"),m&&t.createElement(t.Fragment,null,t.createElement("span",{className:"k-spacer"}),t.createElement(r.Button,{size:"medium",themeColor:"positive"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:a.thumbUpOutlineIcon,onClick:()=>I(e,"positive")}),t.createElement(r.Button,{size:"medium",themeColor:"negative"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:a.thumbDownOutlineIcon,onClick:()=>I(e,"negative")}))))))),y=t.createElement(i.Card,null,t.createElement(i.CardBody,null,k.toLanguageString(R,D[R])));return t.createElement(_,{name:G.name},t.createElement($,{ref:l,streaming:c.streaming,onCancel:c.onCancel},t.createElement("div",{className:"k-card-list"},c.loading&&v,C,(!C||0===C.length)&&!c.loading&&y)))},e.AIPromptView=e=>{const{promptInput:n=l.TextArea,generateButton:o=r.Button,enableSpeechToText:i=!1,promptValue:c,promptSuggestions:p}=e,[m,u]=t.useState(c||""),[d]=U(),[h,g]=s.useCustomComponent(o),[k,I]=s.useCustomComponent(n),E={title:"Generate",children:"Generate",svgIcon:a.sparklesIcon},v=Object.keys(g).length>0?g:E,C=Object.keys(I).length>0?I:{placeholder:"Ask or generate content with AI ...",rows:2},y=e=>{const{isFinal:t,alternatives:s}=e;if(t&&s.length>0){const e=s[0].transcript,t=(()=>{const t=m,s=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(s?" ":"")+e})();u(t)}};let f;return i&&(f="object"==typeof i?{...i,onResult:i.onResult||y}:{onResult:y}),t.createElement(_,{name:W.name},t.createElement($,{streaming:d.streaming,onCancel:d.onCancel},t.createElement(k,{value:m,className:"!k-flex-col",suffix:i?t.createElement(t.Fragment,null,t.createElement(l.InputSeparator,{orientation:"horizontal"}),t.createElement(l.InputSuffix,{orientation:"horizontal"},t.createElement(r.SpeechToTextButton,{fillMode:"flat",...f}))):void 0,onChange:e=>{u(e.target.value)},...C}),p&&p.length>0&&t.createElement(Y,{title:"Prompt Suggestions"},t.createElement(K,{suggestionsView:d.suggestionsView,suggestions:p.map(((e,t)=>({id:t,text:e,description:e}))),onSuggestionClick:(e,t)=>{(e=>{u(e)})(t.text)}}))),t.createElement(H,null,t.createElement(h,{themeColor:"primary",fillMode:"solid",rounded:"full",size:"medium",onClick:()=>{d.onPromptRequest&&d.onPromptRequest.call(null,m),u("")},disabled:!m.trim(),...v},v.children)))},e.AIPromptViewRender=_,e.Chat=F,e.ChatMessage=h,e.HeroCard=O,e.InlineAIPrompt=e=>{const n=!s.validatePackage(A,{component:"InlineAIPrompt"}),o=s.getLicenseMessage(A),{outputs:c=[],outputCard:p,promptInput:m=l.TextArea,generateButton:u=r.Button,promptPlaceholder:d="Ask or generate content with AI...",promptValue:h,onPromptRequest:g,onCopy:k,onDiscard:I,outputActions:E,onOutputAction:v,enableSpeechToText:C=!1,streaming:y,onPromptCancel:f,show:b=!1,anchor:w,width:x,height:N,onOpen:T,onClose:S,animate:R=!0,appendTo:B,commands:D,onCommandExecute:L,style:M,className:V,popupOptions:P={},...F}=e,[K,O]=t.useState(""),[q,G]=t.useState(!1),[z,W]=t.useState({left:0,top:0}),j=t.useRef(null),{body:U,actions:H}=p||{},_=E||[{id:"copy",text:"Copy",svgIcon:a.copyIcon,themeColor:"primary",title:"Copy"},{id:"discard",text:"Discard",svgIcon:a.cancelOutlineIcon,themeColor:"base",title:"Discard"}],Y=(e,t)=>{switch(e.id){case"copy":(e=>{e.responseContent&&(navigator.clipboard.writeText(e.responseContent),O(e.id),setTimeout((()=>O("")),1e3)),null==k||k(e)})(t);break;case"discard":(e=>{null==I||I(e)})(t);break;default:null==v||v(e,t)}},J=t.useCallback((e=>{"Escape"===e.key&&(y&&f?f():!y&&S&&S({target:null}))}),[y,f,S]),Z={...M,...x&&{width:x},...N&&{height:N}},ee={...x&&{width:x},...N&&{height:N}},te=t.createElement(t.Fragment,null,t.createElement("div",{className:s.classNames("k-prompt",V),style:Z,onKeyDown:J,...F},t.createElement($,{ref:j},c&&c.length>0&&t.createElement("div",{className:"k-card-list"},c.map(((e,s)=>t.createElement(i.Card,{key:`${e.id}_${s}`},t.createElement(i.CardBody,null,U?U(e):e.responseContent),t.createElement(i.CardActions,null,H?H(e):t.createElement(t.Fragment,null,_.map((s=>{var n;return s.spacer?t.createElement("span",{key:s.id,className:"k-spacer"}):t.createElement(r.Button,{key:s.id,size:"medium",themeColor:s.themeColor||"primary",fillMode:"flat",rounded:"medium",title:null!=(n=s.title)?n:s.text,svgIcon:"copy"===s.id&&K===e.id?a.checkIcon:s.svgIcon,onClick:()=>Y(s,e)},s.text)})))))))),t.createElement(X,{promptValue:h,placeholder:d,onPromptRequest:g,onMenuClick:e=>{if(!j.current)return;const t=j.current.getBoundingClientRect();W({left:t.left,top:t.bottom}),G(!0)},onPromptCancel:f,promptInput:m,generateButton:u,enableSpeechToText:C,streaming:y,commands:D}))),n&&t.createElement(s.WatermarkOverlay,{message:o}));return t.createElement(t.Fragment,null,t.createElement(Q,{show:b,anchor:w,onOpen:T,onClose:S,animate:R,appendTo:B,popupOptions:P,style:ee},te),t.createElement(i.ContextMenu,{show:q,offset:z,onClose:()=>{G(!1)},items:(e=>null==e?void 0:e.map((e=>({text:e.text,svgIcon:e.svgIcon,data:e,items:e.children?e.children.map((e=>({text:e.text,data:e}))):void 0}))))(D),onSelect:e=>{var t,s;const n=null==(t=e.item)?void 0:t.data;n&&(null==(s=n.children)||!s.length)&&(e=>{G(!1),L&&L(e)})(n)}}))},e.PromptHeader=q,e.SuggestionGroup=K,e.commandsViewDefaults=z,e.outputViewDefaults=G,e.promptViewDefaults=W}));
|
|
15
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@progress/kendo-react-common"),require("@progress/kendo-react-buttons"),require("@progress/kendo-svg-icons"),require("@progress/kendo-react-intl"),require("@progress/kendo-react-layout"),require("prop-types"),require("@progress/kendo-react-upload"),require("@progress/kendo-react-inputs"),require("@progress/kendo-react-animation"),require("@progress/kendo-react-notification"),require("@progress/kendo-react-popup")):"function"==typeof define&&define.amd?define(["exports","react","@progress/kendo-react-common","@progress/kendo-react-buttons","@progress/kendo-svg-icons","@progress/kendo-react-intl","@progress/kendo-react-layout","prop-types","@progress/kendo-react-upload","@progress/kendo-react-inputs","@progress/kendo-react-animation","@progress/kendo-react-notification","@progress/kendo-react-popup"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoReactConversationalUi={},e.React,e.KendoReactCommon,e.KendoReactButtons,e.KendoSvgIcons,e.KendoReactIntl,e.KendoReactLayout,e.PropTypes,e.KendoReactUpload,e.KendoReactInputs,e.KendoReactAnimation,e.KendoReactNotification,e.KendoReactPopup)}(this,(function(e,t,a,n,l,o,s,r,i,c,u,m,d){"use strict";function p(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(a){if("default"!==a){var n=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,n.get?n:{enumerable:!0,get:function(){return e[a]}})}})),t.default=e,Object.freeze(t)}var g=p(t);const h="newMessage.sendButton",k="newMessage.messageInput",f="avatar.alt",v="messageList.ariaLabel",C="aIPrompt.noOutputs",y="aIPrompt.cancel",b="chat.senderDeletedMessage",E="chat.receiverDeletedMessage",I="chat.copyNotification",x="chat.downloadAllFiles",F="chat.closeReply",w="chat.collapseMessage",T="chat.expandMessage",N="chat.removeFile",A="chat.fileActions",S="chat.attachFile",M="chat.downloadAll",D={[h]:"Send","newMessage.optionsButton":"Options",[k]:"Message",[f]:"Avatar",[v]:"Message list",[y]:"Cancel",[C]:"No output from AI available",[b]:"You removed this message",[E]:"The message was removed by its sender",[I]:"Text copied to clipboard",[x]:"Download all files",[F]:"Close reply",[w]:"Collapse message",[T]:"Expand message",[N]:"Remove file",[A]:"File actions for",[S]:"Attach file",[M]:"Download all"},R=(e,t)=>e&&t.author&&e.id===t.author.id,P=(e,t)=>{const a=t.toLanguageString("chatSender.deletedMessage",D[b]),n=t.toLanguageString("chatReceiver.deletedMessage",D[E]);return e?a:n},B=(e,t)=>{const a=t?t.querySelector(`[data-message-id="${e}"]`):document.querySelector(`[data-message-id="${e}"]`);if(!a)return;const n=null==t?void 0:t.querySelector(".k-message-list");if(n){const e=n.getBoundingClientRect().top,t=a.getBoundingClientRect().top,l=n.scrollTop+(t-e);n.scrollTo({top:l,behavior:"smooth"})}else a.scrollIntoView({behavior:"smooth",block:"start"})},L=/(https?:\/\/[^\s]+)/g,K=e=>{if(!e)return[""];const a=e.split(L),n=[];return a.forEach((e=>{e&&L.test(e)?(L.lastIndex=0,n.push(t.createElement("a",{key:e,href:e,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"}},e))):e&&n.push(e)})),n},V=g.createContext(void 0),O=()=>{const e=t.useContext(V);if(void 0===e)throw new Error("useChatContext must be used within a ChatContext.Provider");return e},q=e=>{const{files:t,onFileRemove:s,onFileAction:r,onDownload:i,fileActions:c,renderInTextarea:u=!1}=e,m=o.useLocalization(),d=c||[{id:"download",label:"Download",svgIcon:l.downloadIcon}],p=e=>"."+e.split(".").pop()||"",h=e=>u?g.createElement(n.Button,{fillMode:"flat",themeColor:"base",svgIcon:l.xIcon,onClick:t=>{t.stopPropagation(),null==s||s(e.name)},"aria-label":`${m.toLanguageString(N,D[N])} ${e.name}`}):"uid"in e||!("rawFile"in e)?d.length>0&&g.createElement(n.DropDownButton,{fillMode:"flat",themeColor:"base",svgIcon:l.moreVerticalIcon,onItemClick:t=>((e,t)=>{"download"===e.item.id&&(null==i||i([t])),null==r||r(e.item,e,t)})(t,e),items:d.map((e=>({id:e.id,icon:e.icon,text:e.label,svgIcon:e.svgIcon}))),"aria-label":`${m.toLanguageString(A,D[A])} ${e.name}`}):g.createElement(n.Button,{fillMode:"flat",themeColor:"base",svgIcon:l.xIcon,onClick:t=>{t.stopPropagation(),null==s||s(e.name)},"aria-label":`${m.toLanguageString(N,D[N])} ${e.name}`});return g.createElement("ul",{className:"k-chat-file-wrapper"},t.map((e=>g.createElement("li",{key:e.name,className:"k-chat-file"},g.createElement(a.IconWrap,{size:"xxlarge",...a.getFileExtensionIcon(p(e.name))}),g.createElement("div",{className:"k-chat-file-info"},g.createElement("span",{className:"k-chat-file-name"},e.name),g.createElement("span",{className:"k-chat-file-size"},(e=>{if(null==e)return"";if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,t)).toFixed(2))} ${["B","KB","MB","GB","TB"][t]}`})(e.size))),h(e)))))},z=g.forwardRef(((e,t)=>{const{item:r,template:i,onRequestSelection:c,tabIndex:u=-1,dateFormat:m="g",selected:d,allowMessageCollapse:p,messageToolbarActions:h,messageContextMenuActions:k,isSender:f}=e,{setReplyToMessage:v,messages:C,user:y,internalScrollContainerRef:b,onToolbarAction:E,onContextMenuAction:I,onFileAction:F,onDownload:N,fileActions:A,setShowCopyNotification:S,statusTemplate:L}=O(),[V,z]=g.useState(!1),[U,j]=g.useState(!0),[$,W]=g.useState(!1),H=o.useLocalization(),G=g.useRef({left:0,top:0}),_=g.useCallback((()=>{null!=r&&r.text&&(e=>{navigator.clipboard.writeText(e)})(r.text),S&&(S(!0),setTimeout((()=>{S(!1)}),3e3))}),[r,S]),Y=g.useCallback((e=>{e.stopPropagation(),j((e=>!e))}),[]),X=g.useCallback((()=>{W(!1)}),[]),J=g.useCallback((e=>{("Tab"===e.key||"Enter"===e.key||" "===e.key||"ArrowUp"===e.key||"ArrowDown"===e.key)&&W(!0)}),[]),Q=g.useRef(null);g.useEffect((()=>{d&&Q.current&&Q.current.focus()}),[d]);const Z=g.useCallback((e=>{G.current={left:e.pageX,top:e.pageY},e.preventDefault(),z(!0)}),[]),ee=g.useCallback((()=>{z(!1)}),[]),te=g.useCallback(((e,t)=>!e.isDeleted&&e.text?e.text:P(t,H)),[H]),ae=g.useCallback((e=>{var t;null!=(t=e.item)&&t.text&&("copy"!==e.item.data.id||r.isDeleted?"reply"===e.item.data.id&&v(r):_(),I&&I(e.item.data,e,r)),z(!1)}),[r,I,v,_]),ne=g.useCallback((()=>{if(r.replyToId){const e=((e,t)=>e.find((e=>e.id===t)))(C,r.replyToId);if(e){const t=t=>{t.preventDefault(),t.stopPropagation();const a=null==b?void 0:b.current;B(e.id,a)};return g.createElement("div",{className:a.classNames("k-message-reference",R(y,e)?"k-message-reference-sender":"k-message-reference-receiver"),onClick:t},g.createElement("div",{className:"k-message-reference-content"},K(te(e,R(y,e)))))}}return null}),[r.replyToId,C,y,te,b]),le=g.useCallback((()=>{const e=[{id:"reply",label:"Reply",svgIcon:l.undoIcon},{id:"copy",label:"Copy",svgIcon:l.copyIcon}],t=k?[...e.map((e=>k.find((t=>t.id===e.id))||e)),...k.filter((t=>!e.some((e=>e.id===t.id))))]:e;return g.createElement(s.ContextMenu,{onSelect:ae,onClose:ee,vertical:!0,show:V,offset:G.current},t.map((e=>"delete"!==e.id||f?g.createElement(s.MenuItem,{key:e.id,text:e.label,icon:e.icon,svgIcon:e.svgIcon,data:e}):null)))}),[k,ae,ee,V,f]),oe=g.useCallback((()=>r.files&&r.files.length>1?g.createElement("div",{className:"k-chat-download-button-wrapper"},g.createElement(n.Button,{className:"k-chat-download-button",fillMode:"flat",themeColor:"base",svgIcon:l.downloadIcon,onClick:e=>{e.stopPropagation(),N&&N(r.files,r)},"aria-label":H.toLanguageString(x,D[x])},g.createElement("span",{className:"k-button-text"},H.toLanguageString(M,D[M])))):null),[r,N,H]),se=g.useCallback((()=>{if(r.typing)return g.createElement("div",{className:"k-chat-bubble"},g.createElement("div",{className:"k-typing-indicator"},g.createElement("span",null),g.createElement("span",null),g.createElement("span",null)));if(i){const e=i;return g.createElement(e,{item:r})}return r.text||r.files&&r.files.length>0?g.createElement(g.Fragment,null,g.createElement("div",{className:a.classNames("k-chat-bubble","k-bubble",{"k-bubble-expandable":p,"k-expanded":p&&U,"k-selected":d}),onContextMenu:Z},g.createElement("div",{className:"k-bubble-content",onClick:e=>{e.stopPropagation(),e.preventDefault()}},g.createElement("span",{className:"k-chat-bubble-text"},!r.isDeleted&&ne(),K(te(r,R(y,r)))),r.files&&g.createElement(q,{files:r.files,message:r,onFileAction:F,onDownload:e=>null==N?void 0:N(e,r),renderInTextarea:!1,fileActions:A}),oe()),p&&g.createElement("span",{className:"k-bubble-expandable-indicator",onClick:Y,role:"button","aria-label":U?H.toLanguageString(w,D[w]):H.toLanguageString(T,D[T]),tabIndex:0,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),Y(e))}},g.createElement(a.IconWrap,{icon:U?l.chevronUpIcon:l.chevronDownIcon,size:"medium"}))),le()):null}),[r,i,p,U,d,Z,ne,te,y,F,A,oe,Y,H,le,N]),re=g.useCallback((()=>{let t=null;return r.timestamp&&(t=g.createElement("time",{className:"k-message-time","aria-hidden":!d},o.provideIntlService({props:e}).formatDate(r.timestamp,m))),t}),[r.timestamp,d,m,e]),ie=g.useCallback((()=>{let e=null;return r.status&&d&&(e=L?g.createElement(L,{item:r}):g.createElement("span",{className:"k-message-status"},g.createElement(a.IconWrap,{icon:l.checkCircleIcon,size:"xsmall"}),r.status)),e}),[r,d,L]),ce=g.useCallback((()=>a.classNames({"k-focus":d,"k-message-removed":r.isDeleted},"k-message")),[d,r.isDeleted]),ue=g.useCallback((()=>h&&h.length>0&&g.createElement("div",{className:"k-chat-message-toolbar k-toolbar k-toolbar-md k-toolbar-flat"},h.map((e=>"delete"!==e.id||f?g.createElement(n.Button,{key:e.id,fillMode:"flat",className:"k-toolbar-button",themeColor:"base",icon:e.icon,svgIcon:e.svgIcon,onClick:t=>{t.stopPropagation(),"copy"!==e.id||r.isDeleted?"reply"===e.id&&v(r):_(),E&&E(e,t,r)},onMouseDown:e=>e.preventDefault()}):null)))),[_,f,r,h,E,v]);return g.createElement("div",{"data-message-id":r.id,className:ce(),tabIndex:u,onClick:()=>c(d?void 0:r.selectionIndex),onMouseDown:X,onKeyDown:J,onFocus:e=>{$&&c(r.selectionIndex)},ref:e=>{Q.current=e,"function"==typeof t?t(e):t&&(t.current=e)}},re(),se(),ie(),ue())}));z.displayName="ChatMessage";class U extends g.Component{render(){return g.createElement(z,{...this.props})}}o.registerForIntl(U);const j=e=>e[e.length-1],$=e=>(t,a,n)=>{const l=n===e-1;return((e,t)=>{const a=t.timestamp,n=j(e);if(a&&(!n||((e,t)=>e&&t&&(t.getDate()!==e.getDate()||t.getMonth()!==e.getMonth()||t.getFullYear()!==e.getFullYear()))(a,n.timestamp))){const t={type:"date-marker",timestamp:a,trackBy:a.getTime()};e.push(t)}})(t,a),((e,t,a)=>{const n=j(e);let l;t.typing&&!a||(n&&"message-group"===n.type&&(l=n.messages),l&&R(t.author,j(l))?l.push(t):e.push({type:"message-group",messages:[t],author:t.author,timestamp:t.timestamp,trackBy:t}))})(t,a,l),a.attachments&&a.attachments.length>1&&t.push({type:"attachment-group",attachments:a.attachments,attachmentLayout:a.attachmentLayout,timestamp:a.timestamp,trackBy:a}),a.suggestedActions&&l&&t.push({type:"action-group",actions:a.suggestedActions,timestamp:a.timestamp,trackBy:a}),t};const W=e=>{const t=e.slice().reduce($(e.length),[]);return function(e){let t=0;e.forEach((e=>{"message-group"===e.type?e.messages.forEach((e=>{e.selectionIndex=t++})):("attachment-group"===e.type||"action-group"===e.type)&&(e.selectionIndex=t++)})),e.lastSelectionIndex=t-1}(t),t},H=e=>{const{item:t,onActionExecute:n,selected:l}=e,o=g.useRef(null);g.useEffect((()=>{l&&o.current&&o.current.focus()}),[l]);const s=g.useCallback((e=>{(e.keyCode===a.Keys.enter||" "===e.key)&&(e.preventDefault(),n(t,e))}),[n,t]),r=g.useCallback((()=>a.classNames("k-suggestion k-suggestion-primary",{"k-selected":l},{"k-focus":l})),[l]);return g.createElement("span",{role:"button",className:r(),onClick:e=>n(t,e),ref:o,onKeyDown:s,tabIndex:0,"aria-label":t.title||t.value},t.title||t.value)},G=e=>{var t;const{group:n,onActionExecute:l,selected:o,onRequestSelection:s}=e,[r,i]=g.useState(null);g.useEffect((()=>{o||null===r?o&&null===r&&i(0):i(null)}),[o,r]);const c=g.useCallback((()=>n.actions?n.actions.length-1:-1),[n.actions]),u=g.useCallback(((e,t=0)=>{let a=null;return e?null===r?a=t:r<c()&&(a=r+1):null===r?a=0:r>0&&(a=r-1),null!==a&&i(a),a}),[r,c]),m=g.useCallback((()=>{s(n.selectionIndex)}),[s,n.selectionIndex]),d=g.useCallback((e=>{let t=null;const n=a.Keys.left,l=a.Keys.right;e.keyCode===n?t=u(!1):e.keyCode===l&&(t=u(!0)),null!==t&&(e.preventDefault(),e.stopPropagation())}),[u]),p=g.useCallback((()=>a.classNames("k-suggestion-group")),[]);return g.createElement("div",{className:p(),onClick:m,onKeyDown:d,role:"toolbar",tabIndex:0,"aria-label":"Action group"},null==(t=n.actions)?void 0:t.map(((e,t)=>g.createElement(H,{item:e,onActionExecute:l,selected:t===r,key:e.value}))))},_=e=>{const{item:t,template:n,tabbable:l,onClick:o,selected:s}=e,r=g.useRef(null);g.useEffect((()=>{s&&r.current&&r.current.focus()}),[s]);const i=g.useCallback((()=>{if(void 0!==l)return l?0:-1}),[l]),c=g.useCallback((()=>a.classNames({"k-selected":s},{"k-focus":s})),[s]),u=g.useCallback((()=>t.title?g.createElement("h5",{className:"k-card-title"},t.title):null),[t.title]),m=g.useCallback((()=>t.subtitle?g.createElement("h6",{className:"k-card-subtitle"},t.subtitle):null),[t.subtitle]),d=g.useCallback((()=>0===t.contentType.indexOf("image/")?g.createElement("img",{src:t.content,alt:t.title||"Attachment"}):t.content),[t.contentType,t.content,t.title]),p=n;return g.createElement("div",{className:c(),tabIndex:i(),onClick:o,ref:r},n?g.createElement(p,{item:t}):g.createElement("div",{className:"k-card"},g.createElement("div",{className:"k-card-body"},u(),m(),d())))},Y=e=>{const{group:t,itemTemplate:o,selected:s,isLastGroup:r,onRequestSelection:i}=e,[c,u]=g.useState(null);g.useEffect((()=>{s||null===c?s&&null===c&&u(0):u(null)}),[s,c]);const m=g.useCallback((e=>"list"!==e.attachmentLayout),[]),d=g.useCallback((()=>t.attachments?t.attachments.length-1:-1),[t.attachments]),p=g.useCallback((()=>t.attachments.length-1),[t.attachments]),h=g.useCallback(((e,t=0)=>{let a=null;return e?null===c?a=t:c<d()&&(a=c+1):null===c?a=0:c>0&&(a=c-1),null!==a&&u(a),a}),[c,d]),k=g.useCallback((()=>{i(t.selectionIndex)}),[i,t.selectionIndex]),f=g.useCallback((e=>{let n,l,o=null;m(t)?(n=a.Keys.left,l=a.Keys.right):(n=a.Keys.up,l=a.Keys.down),e.keyCode===n?o=h(!1):e.keyCode===l&&(o=h(!0)),null!==o&&(e.preventDefault(),e.stopPropagation())}),[h,m,t]),v=g.useCallback((e=>{k(),u(e)}),[k]),C=g.useCallback((e=>{k(),h(e,1)}),[k,h]),y=g.useCallback((()=>{let e=null;return m(t)&&c&&(e=g.createElement(n.Button,{icon:"chevron-left",onClick:()=>C(!1),svgIcon:l.chevronLeftIcon})),e}),[m,t,c,C]),b=g.useCallback((()=>{let e=null;return m(t)&&c!==p()&&(e=g.createElement(n.Button,{icon:"chevron-right",onClick:()=>C(!0),svgIcon:l.chevronRightIcon})),e}),[m,t,c,p,C]),E=g.useCallback((()=>a.classNames({"k-card-list":t.attachmentLayout,"k-card-deck":m(t)})),[t.attachmentLayout,t,m]),I=m(t),x=g.createElement("div",{className:E(),onKeyDown:I?void 0:f},t.attachments.map(((e,t)=>g.createElement(_,{item:e,template:o,selected:t===c,tabbable:r&&t===c,onClick:()=>v(t),key:e.content}))));return I?g.createElement("div",{className:"k-card-deck-scrollwrap",onKeyDown:f},y(),x,b()):x},X=({item:e,timestampTemplate:t})=>{const a=t;return g.createElement("div",{className:"k-timestamp"},a?g.createElement(a,{item:e}):o.provideIntlService({props:{item:e}}).formatDate(e.timestamp,"D"))};let J=class extends g.Component{render(){return g.createElement(X,{...this.props})}};o.registerForIntl(J);const Q=e=>{const{group:t,user:n,itemTemplate:l,attachmentTemplate:r,onRequestSelection:i,selectedItemIndex:c,isLastGroup:u,message:m,allowMessageCollapse:d,messageToolbarActions:p,messageContextMenuActions:h,messageWidthMode:k="standard"}=e,v=o.useLocalization(),C=t.messages.length>0&&R(n,t.messages[0]),y=!C,b=g.useMemo((()=>a.classNames("k-message-group",{"k-message-group-sender k-no-avatar":C,"k-message-group-receiver":y,"k-message-group-full-width":"full"===k})),[C,y,k]),E=g.useMemo((()=>{const e=t.messages.length-1;return t.messages.map(((t,a)=>{const o=[g.createElement(m,{item:t,template:l,selected:t.selectionIndex===c,onRequestSelection:i,tabIndex:a===e&&u?0:-1,key:t.id,allowMessageCollapse:d,messageToolbarActions:p,messageContextMenuActions:h,isSender:R(n,t)})];return t.attachments&&1===t.attachments.length&&o.push(g.createElement(_,{item:t.attachments[0],template:r,selected:!1,key:`att-${t.attachments[0].content}`})),o}))}),[t.messages,m,l,c,i,u,d,p,h,n,r]),{avatarUrl:I,avatarAltText:x,name:F}=t.author,w=void 0!==x?x:v.toLanguageString(f,D[f]);return g.createElement("div",{className:b},(()=>{if(y&&I)return g.createElement(s.Avatar,{type:"image"},g.createElement("img",{src:I,alt:w}))})(),g.createElement("div",{className:"k-message-group-content"},g.createElement("span",{className:"k-message-author"},F),E))},Z=e=>{const{suggestions:t,onSuggestionClick:n,suggestionsView:l,suggestionTemplate:o}=e,s=g.useCallback(((e,t)=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),null==n||n(t))}),[n]),r=g.useCallback((()=>t.map((e=>o?g.createElement(o,{key:e.id,suggestion:e,onClick:()=>{null==n||n(e)}}):g.createElement("span",{role:"button",tabIndex:e.disabled?-1:0,"aria-label":e.description,"aria-disabled":e.disabled,onClick:()=>!e.disabled&&(null==n?void 0:n(e)),onKeyDown:t=>!e.disabled&&s(t,e),key:e.id,title:e.description,className:a.classNames("classic"===l?"k-prompt-suggestion":"k-suggestion",{"k-disabled":e.disabled})},e.text)))),[t,o,n,l,s]);return t&&0!==t.length?"classic"===l?r():g.createElement("div",{role:"group",className:"k-suggestion-group"},r()):null},ee=g.forwardRef(((e,t)=>{const{onSendMessage:s,isDirectionRightToLeft:r,placeholder:u,MessageBox:m,suggestions:d,onSuggestionClick:p,inputValue:f,onInputValueChange:v,suggestionTemplate:C,sendButtonConfig:y}=e,{replyToMessage:b,setReplyToMessage:E,user:I,messageListScrollContainerRef:x,speechToTextConfig:w,uploadConfig:T}=O(),[N]=g.useState(!1),[A,M]=g.useState(void 0),[B,L]=g.useState([]),[K,V]=g.useState(!1),z=g.useRef(null),U=g.useRef(null),j=o.useLocalization(),$=g.useCallback((()=>{null!==z.current&&z.current.focus()}),[]);g.useEffect((()=>{void 0!==f&&f!==A&&(M(f),$())}),[f,A,$]),g.useEffect((()=>{b&&$()}),[b,$]),g.useLayoutEffect((()=>{K&&null!=x&&x.current&&(x.current.scrollTop=x.current.scrollHeight-x.current.clientHeight,V(!1))}),[K,x]);const W=g.useCallback((e=>{const t=e.value;M(t),v&&v(t)}),[v]),H=g.useMemo((()=>!!(null!=A&&A.trim()||B.length>0)),[A,B.length]),G=g.useCallback((e=>{if(e.preventDefault(),s){if(H){const t={id:"",author:I,text:A||"",timestamp:new Date,replyToId:b?b.id:void 0,files:B.map((e=>({name:e.name,size:e.size,type:e.extension,rawFile:e.getRawFile?e.getRawFile():e})))};E(null),s(t,e),L([]),M(""),v&&v(""),V(!0)}}}),[s,A,I,b,B,E,v,H]),_=g.useCallback((e=>{if("Enter"!==e.key||!e.shiftKey)switch(e.key){case"Enter":return e.preventDefault(),G(e);case"Escape":z.current&&z.current.blur();break;default:return}}),[G]);g.useImperativeHandle(t,(()=>({focusInput:$})),[$]);const Y=g.useCallback((e=>{L((t=>t.filter((t=>t.name!==e))))}),[]),X=g.useCallback((()=>g.createElement(q,{files:B,onFileRemove:Y,renderInTextarea:!0})),[B,Y]),J=g.useCallback(((e,t)=>e.isDeleted?P(t,j):e.text),[j]),Q=g.useCallback((()=>{if(b){const e=R(I,b);return g.createElement("div",{className:a.classNames("k-message-reference",e?"k-message-reference-sender":"k-message-reference-receiver")},g.createElement("div",{className:"k-message-reference-content"},J(b,e)),g.createElement("span",{className:"k-spacer"}),g.createElement(n.Button,{fillMode:"flat",themeColor:"base",svgIcon:l.xIcon,onClick:()=>E(null),"aria-label":j.toLanguageString(F,D[F])}))}return null}),[b,I,J,E,j]),ee=g.useCallback((e=>{try{const t=Array.from(e.newState);L((e=>[...e,...t])),$()}catch{}}),[$]),te=g.useCallback((()=>{U.current&&U.current.actionElement.click()}),[]),ae=g.useCallback((e=>{}),[]),ne=g.useCallback((e=>{const{isFinal:t,alternatives:a}=e;if(a.length>0){const e=a[0];t&&M((t=>(t?`${t} `:"")+e.transcript))}}),[]),le=g.useCallback((()=>g.createElement(g.Fragment,null,B.length>0&&X(),b&&g.createElement("span",{className:"k-input-prefix k-input-prefix-horizontal"},Q()))),[B.length,b,X,Q]),oe=g.useCallback((e=>{e.preventDefault()}),[]),se=g.useCallback((e=>{"Escape"===e.key&&e.currentTarget.blur()}),[]),re=g.useMemo((()=>g.createElement(n.Button,{rounded:"full",fillMode:"solid",themeColor:"primary",className:"k-chat-send",icon:"paper-plane",svgIcon:l.paperPlaneIcon,onClick:G,onMouseDown:oe,onKeyDown:se,"aria-label":j.toLanguageString(h,D[h]),dir:r?"rtl":void 0,disabled:!H,"aria-disabled":!H,...y})),[G,oe,se,j,r,H,y]),ie=g.useCallback((()=>{const e="object"==typeof w?w:void 0,t="object"==typeof T?T:{},{className:o,...s}=t,r=a.classNames("k-hidden",o);return g.createElement(c.InputSuffix,null,!1!==w&&g.createElement(n.SpeechToTextButton,{fillMode:"clear",themeColor:"base",onError:ae,onResult:ne,...e}),g.createElement(n.Button,{key:"attach-file",fillMode:"clear",themeColor:"base",svgIcon:l.paperclipIcon,onClick:te,"aria-label":j.toLanguageString(S,D[S])}),g.createElement(i.Upload,{ref:U,files:B,onAdd:ee,multiple:!0,autoUpload:!1,...s,className:r}),g.createElement("span",{className:"k-spacer"}),re)}),[w,T,B,ae,ne,te,ee,j,re]),ce=g.useMemo((()=>g.createElement(c.TextArea,{className:a.classNames("k-message-box","!k-flex-col",{"k-focus":N}),resizable:"none",rows:1,placeholder:u,value:A,onChange:W,onKeyDown:_,prefix:le,suffix:ie,ref:z,"aria-label":j.toLanguageString(k,D[k])})),[N,u,A,W,_,le,ie,j]);return g.createElement("div",{className:"k-message-box-wrapper"},d&&d.length>0&&g.createElement(Z,{onSuggestionClick:p,suggestions:d,suggestionTemplate:C}),m?g.createElement(m,{messageInput:ce,sendButton:re}):ce)}));ee.displayName="NewMessage";const te=e=>g.createElement(s.AppBar,{className:"k-chat-header",positionMode:"sticky",themeColor:"light"},e.children),ae=e=>{const{message:t,onUnpin:s,user:r}=e,i=o.useLocalization(),{internalScrollContainerRef:c}=O(),u=g.useCallback((e=>{e.preventDefault(),e.stopPropagation();const a=null==c?void 0:c.current;B(t.id,a)}),[t.id,c]);return g.createElement("div",{className:"k-message-reference k-message-reference-receiver k-message-pinned",onClick:u},g.createElement(a.IconWrap,{size:"xlarge",icon:l.pinIcon}),g.createElement("div",{className:"k-message-reference-content"},null!=t&&t.isDeleted?r&&P(R(r,t),i):null==t?void 0:t.text),g.createElement("span",{className:"k-spacer"}),g.createElement(n.Button,{svgIcon:l.xIcon,onClick:e=>{e.stopPropagation(),null==s||s(t)}}))},ne=e=>{const{show:t,text:a}=e;return g.createElement("div",{style:{position:"absolute",top:"90%",left:"50%",transform:"translate(-50%, -50%)",zIndex:1e3,pointerEvents:t?"auto":"none"}},g.createElement(u.Fade,null,t&&g.createElement(m.Notification,{type:{style:"dark"},closable:!1},g.createElement("span",null,a))))},le=Object.freeze({name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:0,version:"12.0.0-develop.2",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"}),oe={textField:"text",statusField:"status",authorIdField:"authorId",authorNameField:"authorName",authorImageUrlField:"authorImageUrl",authorImageAltTextField:"authorImageAltText",idField:"id",timestampField:"timestamp",filesField:"files",attachmentsField:"attachments",replyToIdField:"replyToId",isDeletedField:"isDeleted",isPinnedField:"isPinned",typingField:"typing",suggestedActionsField:"suggestedActions"},se=(e,t={})=>{const a={...oe,...t};let n;n=e.author&&"object"==typeof e.author?{id:e.author.id||e.author[a.authorIdField]||"",name:e.author.name||e.author[a.authorNameField],avatarUrl:e.author.avatarUrl||e.author[a.authorImageUrlField],avatarAltText:e.author.avatarAltText||e.author[a.authorImageAltTextField]}:{id:e[a.authorIdField]||"",name:e[a.authorNameField],avatarUrl:e[a.authorImageUrlField],avatarAltText:e[a.authorImageAltTextField]};const l={id:e[a.idField],text:e[a.textField]||"",author:n,timestamp:e[a.timestampField]?new Date(e[a.timestampField]):new Date,status:e[a.statusField],attachments:e[a.attachmentsField],attachmentLayout:e.attachmentLayout||"list",suggestedActions:e[a.suggestedActionsField],isPinned:e[a.isPinnedField]||!1,typing:e[a.typingField],files:e[a.filesField]||[]};return e.pinnedAt&&(l.pinnedAt=new Date(e.pinnedAt)),e.pinnedBy&&(l.pinnedBy=e.pinnedBy),e[a.replyToIdField]&&(l.replyToId=e[a.replyToIdField]),e[a.isDeletedField]&&(l.isDeleted=e[a.isDeletedField]),l},re=(e,t={})=>Array.isArray(e)?e.map((e=>se(e,t))):[],ie=e=>e&&void 0!==e.id&&"string"==typeof e.text&&e.author&&"object"==typeof e.author&&void 0!==e.author.id&&(e.timestamp instanceof Date||"string"==typeof e.timestamp||"number"==typeof e.timestamp),ce=g.forwardRef(((e,t)=>{const{messages:n=[],messageTemplate:l,attachmentTemplate:s,width:r,height:i,onSendMessage:c,onSuggestionClick:u,onInputValueChange:m,onActionExecute:d,dir:p,messageBox:h,placeholder:k,className:f,message:C=z,authorId:y,suggestions:b,suggestionTemplate:E,inputValue:x,headerTemplate:F,timestampTemplate:w,statusTemplate:T,allowMessageCollapse:N,messageToolbarActions:A,messageContextMenuActions:S,fileActions:M,onUnpin:R,messageWidthMode:P,onToolbarAction:B,onContextMenuAction:L,onFileAction:K,onDownload:O,speechToTextConfig:q,uploadConfig:U,sendButtonConfig:j,textField:$,statusField:H,authorIdField:_,authorNameField:J,authorImageUrlField:Z,authorImageAltTextField:oe,idField:se,timestampField:ce,filesField:ue,attachmentsField:me,replyToIdField:de,isDeletedField:pe,isPinnedField:ge,typingField:he,suggestedActionsField:ke,...fe}=e,[ve,Ce]=g.useState(null),[ye,be]=g.useState(!1),[Ee,Ie]=g.useState(!1),[xe,Fe]=g.useState(null),[we,Te]=g.useState(null),Ne=g.useRef(null),Ae=g.useRef(null),Se=g.useRef(null),Me=g.useRef(null),De=g.useRef(void 0),Re=g.useRef(void 0),Pe=g.useRef(null),Be=g.useRef(""),Le=g.useMemo((()=>n&&0!==n.length?ie(n[0])?n.map((e=>({...e,timestamp:e.timestamp?new Date(e.timestamp):e.timestamp}))):re(n,{textField:$,statusField:H,authorIdField:_,authorNameField:J,authorImageUrlField:Z,authorImageAltTextField:oe,idField:se,timestampField:ce,filesField:ue,attachmentsField:me,replyToIdField:de,isDeletedField:pe,isPinnedField:ge,typingField:he,suggestedActionsField:ke}):[]),[n,$,H,_,J,Z,oe,se,ce,ue,me,de,pe,ge,he,ke]);g.useEffect((()=>{if(y===Be.current&&Pe.current)Te(Pe.current);else if(y&&Le.length>0){const e=Le.find((e=>e.author&&(e.author.id===y||e.author.id===String(y)))),t=(null==e?void 0:e.author)||{id:y};Pe.current=t,Be.current=y,Te(t)}}),[y,Le]);const Ke=g.useMemo((()=>Le.length>0?W(Le):[]),[Le]),Ve=g.useMemo((()=>!a.validatePackage(le,{component:"Chat"})),[]),Oe=g.useMemo((()=>Le.find((e=>e.isPinned))),[Le]),qe=o.useLocalization(),ze=g.useCallback((()=>{clearTimeout(De.current)}),[]),Ue=g.useCallback((()=>{De.current=window.setTimeout((()=>{Ce(null)}),0)}),[]),je=g.useCallback((e=>{Ce(e)}),[]),$e=g.useCallback((e=>{let t=null;const n=null!==ve?ve:Ke.lastSelectionIndex;e.keyCode===a.Keys.up?null===n?t=0:n>0&&(t=n-1):e.keyCode===a.Keys.down?null===n?t=0:n<Ke.lastSelectionIndex&&(t=n+1):e.keyCode===a.Keys.home?t=0:e.keyCode===a.Keys.end&&(t=Ke.lastSelectionIndex),null!==t&&(Ce(t),e.preventDefault())}),[ve,Ke]),We=g.useCallback((()=>{Se.current&&(Se.current.scrollTop=Se.current.scrollHeight-Se.current.clientHeight)}),[]),He=g.useCallback((()=>{if(!Se.current)return!0;const{scrollTop:e,scrollHeight:t,clientHeight:a}=Se.current;return t-e-a<50}),[]),Ge=g.useCallback((()=>{He()&&requestAnimationFrame((()=>{We()}))}),[He,We]),_e=g.useCallback((()=>{requestAnimationFrame((()=>{We()}))}),[We]),Ye=g.useCallback(((e,t,a)=>{var n;if(d&&d({action:{value:e.value,title:e.title,type:e.type},syntheticEvent:t,nativeEvent:t.nativeEvent,target:t.currentTarget}),!t.isDefaultPrevented()){switch(e.type){case"reply":c&&c({message:{id:"",author:we,text:e.value,timestamp:new Date},syntheticEvent:t,nativeEvent:t.nativeEvent,target:t.currentTarget});break;case"call":window.open("tel:"+e.value);break;case"openUrl":window.open(e.value)}null==(n=Me.current)||n.focusInput()}}),[d,c,we]),Xe=g.useCallback((()=>a.classNames("k-chat",f,{"k-rtl":ye})),[f,ye]),Je=g.useCallback((()=>{const e=Ke.length-1;return Ke.map(((t,a)=>"date-marker"===t.type?g.createElement(X,{item:t,key:t.trackBy,timestampTemplate:w}):"message-group"===t.type?g.createElement(Q,{group:t,itemTemplate:l,attachmentTemplate:s,user:we,selectedItemIndex:ve,onRequestSelection:je,isLastGroup:a===e,key:t.messages[0].selectionIndex,message:C,allowMessageCollapse:N,messageToolbarActions:A,messageContextMenuActions:S,messageWidthMode:P}):"attachment-group"===t.type?g.createElement(Y,{group:t,itemTemplate:s,onRequestSelection:je,selected:t.selectionIndex===ve,isLastGroup:a===e,key:t.selectionIndex}):"action-group"===t.type?g.createElement(G,{group:t,onActionExecute:Ye,onRequestSelection:je,selected:t.selectionIndex===ve,key:t.selectionIndex}):null))}),[Ke,w,l,s,we,ve,je,C,N,A,S,P,Ye]),Qe=g.useCallback((()=>F?"function"==typeof F?F():F:null),[F]);g.useEffect((()=>{const e=void 0!==p?"rtl"===p:Ne.current&&"rtl"===getComputedStyle(Ne.current).direction;be(!!e)}),[p]),g.useEffect((()=>(Re.current=window.setTimeout((()=>We()),250),()=>{clearTimeout(Re.current)})),[We]),g.useEffect((()=>()=>{clearTimeout(De.current),clearTimeout(Re.current)}),[]),g.useEffect((()=>{_e()}),[Le.length,_e]),g.useEffect((()=>{const e=window.setTimeout((()=>{Ge()}),50);return()=>{clearTimeout(e)}}),[Le,Ge]),g.useEffect((()=>{if(b&&b.length>0){const e=window.setTimeout((()=>{Ge()}),100);return()=>{clearTimeout(e)}}}),[b,Ge]);const Ze=g.useMemo((()=>({replyToMessage:xe,setReplyToMessage:Fe,messages:Le,user:we,internalScrollContainerRef:Ae,messageListScrollContainerRef:Se,onToolbarAction:B,onContextMenuAction:L,onFileAction:K,setShowCopyNotification:Ie,onDownload:O,fileActions:M,speechToTextConfig:q,uploadConfig:U,statusTemplate:T})),[xe,Fe,Le,we,B,L,K,Ie,O,M,q,U,T]);return g.createElement(V.Provider,{value:Ze},g.createElement("div",{style:{width:r,height:i,position:"relative",overflow:"hidden"},onKeyDown:$e,className:Xe(),ref:e=>{Ne.current=e,Ae.current=e,"function"==typeof t?t(e):t&&(t.current=e)},...fe},void 0!==F&&g.createElement(te,null,Qe()),Oe&&g.createElement(ae,{message:Oe,onUnpin:R,user:we}),g.createElement("div",{className:"k-message-list k-avatars",onBlur:Ue,onFocus:ze,role:"log","aria-label":qe.toLanguageString(v,D[v]),"aria-live":"polite",ref:Se},g.createElement("div",{className:"k-message-list-content"},Je())),g.createElement(ee,{onSendMessage:(e,t)=>{c&&c({message:e,syntheticEvent:t,nativeEvent:t.nativeEvent,target:t.currentTarget})},onSuggestionClick:e=>{u&&u(e)},isDirectionRightToLeft:ye,ref:Me,placeholder:k,MessageBox:h,suggestions:b,suggestionTemplate:E,inputValue:x,onInputValueChange:e=>{m&&m(e)},sendButtonConfig:j}),Ve&&g.createElement(a.WatermarkOverlay,null),g.createElement(ne,{show:Ee,text:qe.toLanguageString(I,D[I])})))}));ce.displayName="Chat",ce.propTypes={messages:r.arrayOf(r.object),user:r.object,messageTemplate:r.any,attachmentTemplate:r.any,width:r.oneOfType([r.string,r.number]),onSendMessage:r.func,onActionExecute:r.func,dir:r.string,messageBox:r.any};const ue=e=>{const{activeView:a,toolbarItems:l,activeViewChange:o}=e;return t.createElement("div",{className:"k-prompt-header"},t.createElement(n.Toolbar,{keyboardNavigation:!1,role:"toolbar",className:"k-toolbar-flat"},l.map((e=>t.isValidElement(e)?e:t.createElement(n.Button,{key:e.name,className:a===e.name?"k-selected":"",size:"medium",themeColor:"primary",fillMode:"flat",rounded:"full",title:e.buttonText,svgIcon:e.buttonIcon,onClick:()=>(e=>{null==o||o.call(null,e)})(e.name)},e.buttonText)))))},me={name:"Output view",buttonText:"Output",buttonIcon:l.commentIcon},de={name:"Commands view",buttonIcon:l.moreHorizontalIcon},pe={name:"Prompt view",buttonText:"Ask AI",buttonIcon:l.sparklesIcon},ge=t.createContext([{},()=>{}]),he=()=>t.useContext(ge),ke=e=>{const{children:a}=e;return t.createElement("div",{className:"k-prompt-footer"},t.createElement("div",{className:"k-actions k-actions-start k-actions-horizontal k-prompt-actions"},a))},fe=t.forwardRef(((e,a)=>{const{children:s,streaming:r,onCancel:i}=e,c=o.useLocalization().toLanguageString(y,D[y]),[u]=he(),m=u.activeView===me.name,d=r&&m,p=t.useCallback((e=>{"Escape"===e.key&&d&&i&&(e.preventDefault(),i())}),[d,i]);return t.createElement("div",{className:"k-prompt-content",ref:a,onKeyDown:p},d&&t.createElement(n.FloatingActionButton,{onClick:i,svgIcon:l.stopSmIcon,icon:"stop-sm",size:"medium",positionMode:"absolute",className:"k-prompt-stop-fab k-generating","aria-label":c,title:c}),t.createElement("div",{className:"k-prompt-view"},s))}));fe.displayName="KendoReactAIPromptContent";const ve=e=>{const[t]=he();return t.activeView===e.name?e.children:null},Ce=e=>{const[a,o]=t.useState(!0),{children:s,title:r}=e;return t.createElement("div",{className:"k-prompt-expander"},t.createElement(n.Button,{"aria-controls":e.id,fillMode:"flat",svgIcon:a?l.chevronUpIcon:l.chevronDownIcon,title:r,onClick:()=>o(!a),"aria-expanded":a},r),a&&t.createElement("div",{id:e.id,className:"k-prompt-expander-content"},s))},ye=e=>null==e?void 0:e.map((e=>t.createElement(s.PanelBarItem,{title:e.text,key:e.id,svgIcon:e.svgIcon,data:e},e.children&&ye(e.children||[])))),be=({show:e=!1,anchor:a,onOpen:n,onClose:l,animate:o=!0,appendTo:s,popupOptions:r={},children:i,style:c})=>t.createElement(d.Popup,{show:e,anchor:a,style:c,animate:o,appendTo:s,onOpen:n,onClose:l,...r},i),Ee=({placeholder:e="Ask or generate content with AI...",promptValue:o,onMenuClick:s,promptInput:r=c.TextArea,generateButton:i,enableSpeechToText:u=!1,streaming:m=!1,commands:d,onPromptRequest:p,onPromptCancel:g})=>{const[h,k]=t.useState(o||""),[f,v]=a.useCustomComponent(i),[C,y]=a.useCustomComponent(r),b={svgIcon:m?l.stopSmIcon:l.paperPlaneIcon,active:(!!m).toString(),title:"Send Button","aria-label":"Send Button",disabled:!h.trim()&&!m,"aria-disabled":!h.trim()&&!m},E={placeholder:e,className:"!k-flex-row",autoSize:!0,rows:1},I=d&&d.length>0,x=Object.keys(v).length>0?v:b,F=Object.keys(y).length>0?y:E,w=e=>{const{isFinal:t,alternatives:a}=e;if(t&&a.length>0){const e=a[0].transcript,t=(()=>{const t=h,a=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(a?" ":"")+e})();k(t)}},T=()=>{h.trim()&&p&&p(h.trim())};return t.createElement(C,{value:h,onChange:e=>{const t=e.target.value;k(t)},onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&(e.preventDefault(),T())},prefix:I||u?t.createElement(t.Fragment,null,t.createElement(c.InputPrefix,{className:"!k-align-items-start"},I&&t.createElement(n.Button,{"aria-label":"Commands Button",title:"Commands Button",fillMode:"flat",svgIcon:l.menuIcon,onClick:s}),u&&t.createElement(n.SpeechToTextButton,{fillMode:"flat",..."object"==typeof u?{...u,onResult:u.onResult||w}:{onResult:w}})),t.createElement(c.InputSeparator,null)):void 0,suffix:t.createElement(c.InputSuffix,{className:"!k-align-items-start"},t.createElement(f,{className:a.classNames("k-prompt-send",{"k-generating":m,"k-active":m}),fillMode:"flat",onClick:m?g:T,...x})),...F})};e.AIPrompt=e=>{const n=!a.validatePackage(le,{component:"AIPrompt"}),l=a.getLicenseMessage(le),{activeView:o,toolbarItems:s,children:r,onActiveViewChange:i,onPromptRequest:c,onCommandExecute:u,style:m,dir:d,className:p,streaming:g,loading:h,onCancel:k,suggestionsView:f,...v}=e,C=s||[pe,me],[y,b]=t.useState({activeView:o}),E={...y,activeView:o,streaming:g,loading:h,suggestionsView:null!=f?f:"classic",onCancel:k,onActiveViewChange:i,onPromptRequest:c,onCommandExecute:u};return t.createElement(ge.Provider,{value:[E,e=>{b(e)}]},t.createElement("div",{className:a.classNames("k-prompt",p),style:m,dir:d,...v},t.createElement(ue,{activeView:E.activeView,toolbarItems:C,activeViewChange:i}),r,n&&t.createElement(a.WatermarkOverlay,{message:l})))},e.AIPromptCommandsView=e=>{const{commands:a}=e,[n]=he();return t.createElement(ve,{name:de.name},t.createElement(fe,{streaming:n.streaming,onCancel:n.onCancel},t.createElement("div",{className:"k-prompt-view"},t.createElement(s.PanelBar,{onSelect:e=>{var t,a,l;const o=null==(a=null==(t=e.target)?void 0:t.props)?void 0:a.data;null!=(l=o.children)&&l.length||n.onCommandExecute&&n.onCommandExecute.call(null,o)},selected:""},ye(null!=a?a:[])))))},e.AIPromptContent=fe,e.AIPromptFooter=ke,e.AIPromptOutputView=e=>{const[a,r]=t.useState(""),i=t.useRef(null),[c]=he(),{outputs:u,showOutputRating:m,outputCard:d}=e,{header:p,body:g,actions:h}=d||{},k=o.useLocalization(),f=(e,t)=>{c.onPromptRequest&&c.onPromptRequest.call(null,e.prompt,{...e,ratingType:t,isRetry:!1}),v()},v=()=>{i&&i.current&&i.current.scrollTo({top:0,behavior:"smooth"})},y=t.createElement(s.Card,null,t.createElement(s.CardHeader,null,t.createElement(s.CardTitle,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}})),t.createElement(s.CardSubtitle,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),t.createElement(s.CardBody,null,t.createElement("span",{className:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}})),t.createElement(s.CardActions,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),b=null==u?void 0:u.map(((e,o)=>t.createElement(s.Card,{key:`${e.id}_${o}`},t.createElement(s.CardHeader,null,p?p(e):t.createElement(t.Fragment,null,e.title&&t.createElement(s.CardTitle,null,e.title),e.subTitle&&t.createElement(s.CardSubtitle,null,e.subTitle))),t.createElement(s.CardBody,null,g?g(e):e.responseContent),t.createElement(s.CardActions,null,h?h(e):t.createElement(t.Fragment,null,t.createElement(n.Button,{size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:a===e.id?l.checkIcon:l.copyIcon,onClick:()=>(e=>{null!=e&&e.responseContent&&navigator.clipboard.writeText(e.responseContent),r(e.id),setTimeout((()=>{r("")}),1e3)})(e)},"Copy"),t.createElement(n.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:l.arrowRotateCwIcon,onClick:()=>(e=>{c.onPromptRequest&&c.onPromptRequest.call(null,e.prompt,{...e,isRetry:!0}),v()})(e)},"Retry"),m&&t.createElement(t.Fragment,null,t.createElement("span",{className:"k-spacer"}),t.createElement(n.Button,{size:"medium",themeColor:"positive"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:l.thumbUpOutlineIcon,onClick:()=>f(e,"positive")}),t.createElement(n.Button,{size:"medium",themeColor:"negative"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:l.thumbDownOutlineIcon,onClick:()=>f(e,"negative")}))))))),E=t.createElement(s.Card,null,t.createElement(s.CardBody,null,k.toLanguageString(C,D[C])));return t.createElement(ve,{name:me.name},t.createElement(fe,{ref:i,streaming:c.streaming,onCancel:c.onCancel},t.createElement("div",{className:"k-card-list"},c.loading&&y,b,(!b||0===b.length)&&!c.loading&&E)))},e.AIPromptView=e=>{const{promptInput:o=c.TextArea,generateButton:s=n.Button,enableSpeechToText:r=!1,promptValue:i,promptSuggestions:u}=e,[m,d]=t.useState(i||""),[p]=he(),[g,h]=a.useCustomComponent(s),[k,f]=a.useCustomComponent(o),v={title:"Generate",children:"Generate",svgIcon:l.sparklesIcon},C=Object.keys(h).length>0?h:v,y=Object.keys(f).length>0?f:{placeholder:"Ask or generate content with AI ...",rows:2},b=e=>{const{isFinal:t,alternatives:a}=e;if(t&&a.length>0){const e=a[0].transcript,t=(()=>{const t=m,a=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(a?" ":"")+e})();d(t)}};let E;return r&&(E="object"==typeof r?{...r,onResult:r.onResult||b}:{onResult:b}),t.createElement(ve,{name:pe.name},t.createElement(fe,{streaming:p.streaming,onCancel:p.onCancel},t.createElement(k,{value:m,className:"!k-flex-col",suffix:r?t.createElement(t.Fragment,null,t.createElement(c.InputSeparator,{orientation:"horizontal"}),t.createElement(c.InputSuffix,{orientation:"horizontal"},t.createElement(n.SpeechToTextButton,{fillMode:"flat",...E}))):void 0,onChange:e=>{d(e.target.value)},...y}),u&&u.length>0&&t.createElement(Ce,{title:"Prompt Suggestions"},t.createElement(Z,{suggestionsView:p.suggestionsView,suggestions:u.map(((e,t)=>({id:t,text:e,description:e}))),onSuggestionClick:e=>{(e=>{d(e)})(e.text)}}))),t.createElement(ke,null,t.createElement(g,{themeColor:"primary",fillMode:"solid",rounded:"full",size:"medium",onClick:()=>{p.onPromptRequest&&p.onPromptRequest.call(null,m),d("")},disabled:!m.trim(),...C},C.children)))},e.AIPromptViewRender=ve,e.Chat=ce,e.ChatMessage=z,e.DEFAULT_FIELD_MAPPING=oe,e.HeroCard=e=>{const{imageUrl:t,imageMaxWidth:a,title:l,subtitle:o,actions:s,onActionExecute:r,altText:i}=e,c=g.useCallback(((e,t)=>{null==r||r({action:e,syntheticEvent:t,nativeEvent:t.nativeEvent,target:t.currentTarget})}),[r]),u=i||l||"";return g.createElement("div",{className:"k-card"},g.createElement("img",{className:"k-card-image",src:t,style:{maxWidth:a},alt:u}),g.createElement("div",{className:"k-card-body"},l&&g.createElement("h5",{className:"k-card-title"},l),o&&g.createElement("h6",{className:"k-card-subtitle"},o)),g.createElement("div",{className:"k-card-actions k-card-actions-vertical"},s.map(((e,t)=>g.createElement("span",{className:"k-card-action",key:`action-${t}-${e.title||e.value||t}`},g.createElement(n.Button,{fillMode:"flat",onClick:t=>c(e,t)},e.title))))))},e.InlineAIPrompt=e=>{const o=!a.validatePackage(le,{component:"InlineAIPrompt"}),r=a.getLicenseMessage(le),{outputs:i=[],outputCard:u,promptInput:m=c.TextArea,generateButton:d=n.Button,promptPlaceholder:p="Ask or generate content with AI...",promptValue:g,onPromptRequest:h,onCopy:k,onDiscard:f,outputActions:v,onOutputAction:C,enableSpeechToText:y=!1,streaming:b,onPromptCancel:E,show:I=!1,anchor:x,width:F,height:w,onOpen:T,onClose:N,animate:A=!0,appendTo:S,commands:M,onCommandExecute:D,style:R,className:P,popupOptions:B={},...L}=e,[K,V]=t.useState(""),[O,q]=t.useState(!1),[z,U]=t.useState({left:0,top:0}),j=t.useRef(null),{body:$,actions:W}=u||{},H=v||[{id:"copy",text:"Copy",svgIcon:l.copyIcon,themeColor:"primary",title:"Copy"},{id:"discard",text:"Discard",svgIcon:l.cancelOutlineIcon,themeColor:"base",title:"Discard"}],G=(e,t)=>{switch(e.id){case"copy":(e=>{e.responseContent&&(navigator.clipboard.writeText(e.responseContent),V(e.id),setTimeout((()=>V("")),1e3)),null==k||k(e)})(t);break;case"discard":(e=>{null==f||f(e)})(t);break;default:null==C||C(e,t)}},_=t.useCallback((e=>{"Escape"===e.key&&(b&&E?E():!b&&N&&N({target:null}))}),[b,E,N]),Y={...R,...F&&{width:F},...w&&{height:w}},X={...F&&{width:F},...w&&{height:w}},J=t.createElement(t.Fragment,null,t.createElement("div",{className:a.classNames("k-prompt",P),style:Y,onKeyDown:_,...L},t.createElement(fe,{ref:j},i&&i.length>0&&t.createElement("div",{className:"k-card-list"},i.map(((e,a)=>t.createElement(s.Card,{key:`${e.id}_${a}`},t.createElement(s.CardBody,null,$?$(e):e.responseContent),t.createElement(s.CardActions,null,W?W(e):t.createElement(t.Fragment,null,H.map((a=>{var o;return a.spacer?t.createElement("span",{key:a.id,className:"k-spacer"}):t.createElement(n.Button,{key:a.id,size:"medium",themeColor:a.themeColor||"primary",fillMode:"flat",rounded:"medium",title:null!=(o=a.title)?o:a.text,svgIcon:"copy"===a.id&&K===e.id?l.checkIcon:a.svgIcon,onClick:()=>G(a,e)},a.text)})))))))),t.createElement(Ee,{promptValue:g,placeholder:p,onPromptRequest:h,onMenuClick:e=>{if(!j.current)return;const t=j.current.getBoundingClientRect();U({left:t.left,top:t.bottom}),q(!0)},onPromptCancel:E,promptInput:m,generateButton:d,enableSpeechToText:y,streaming:b,commands:M}))),o&&t.createElement(a.WatermarkOverlay,{message:r}));return t.createElement(t.Fragment,null,t.createElement(be,{show:I,anchor:x,onOpen:T,onClose:N,animate:A,appendTo:S,popupOptions:B,style:X},J),t.createElement(s.ContextMenu,{show:O,offset:z,onClose:()=>{q(!1)},items:(e=>null==e?void 0:e.map((e=>({text:e.text,svgIcon:e.svgIcon,data:e,items:e.children?e.children.map((e=>({text:e.text,data:e}))):void 0}))))(M),onSelect:e=>{var t,a;const n=null==(t=e.item)?void 0:t.data;n&&(null==(a=n.children)||!a.length)&&(e=>{q(!1),D&&D(e)})(n)}}))},e.PromptHeader=ue,e.SuggestionGroup=Z,e.commandsViewDefaults=de,e.extractFieldMappingFromProps=e=>({textField:e.textField,statusField:e.statusField,authorIdField:e.authorIdField,authorNameField:e.authorNameField,authorImageUrlField:e.authorImageUrlField,authorImageAltTextField:e.authorImageAltTextField,idField:e.idField,timestampField:e.timestampField,filesField:e.filesField,attachmentsField:e.attachmentsField,replyToIdField:e.replyToIdField,isDeletedField:e.isDeletedField,isPinnedField:e.isPinnedField,typingField:e.typingField,suggestedActionsField:e.suggestedActionsField}),e.isStandardMessageFormat=ie,e.mapDataArrayToMessages=re,e.mapDataToMessage=se,e.mapMessageToCustomFormat=(e,t={})=>{const a={...oe,...t},n={};return void 0!==e.id&&(n[a.idField]=e.id),void 0!==e.text&&(n[a.textField]=e.text),void 0!==e.status&&(n[a.statusField]=e.status),void 0!==e.timestamp&&(n[a.timestampField]=e.timestamp),void 0!==e.attachments&&(n[a.attachmentsField]=e.attachments),void 0!==e.files&&(n[a.filesField]=e.files),void 0!==e.suggestedActions&&(n[a.suggestedActionsField]=e.suggestedActions),void 0!==e.replyToId&&(n[a.replyToIdField]=e.replyToId),void 0!==e.isDeleted&&(n[a.isDeletedField]=e.isDeleted),void 0!==e.isPinned&&(n[a.isPinnedField]=e.isPinned),void 0!==e.typing&&(n[a.typingField]=e.typing),e.author&&(void 0!==e.author.id&&(n[a.authorIdField]=e.author.id),void 0!==e.author.name&&(n[a.authorNameField]=e.author.name),void 0!==e.author.avatarUrl&&(n[a.authorImageUrlField]=e.author.avatarUrl),void 0!==e.author.avatarAltText&&(n[a.authorImageAltTextField]=e.author.avatarAltText)),void 0!==e.pinnedAt&&(n.pinnedAt=e.pinnedAt),void 0!==e.pinnedBy&&(n.pinnedBy=e.pinnedBy),void 0!==e.attachmentLayout&&(n.attachmentLayout=e.attachmentLayout),n},e.outputViewDefaults=me,e.promptViewDefaults=pe}));
|