@progress/kendo-react-conversational-ui 12.0.0-develop.3 → 12.0.0-develop.4

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.
@@ -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-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.3",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}));
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.4",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}));
@@ -5,4 +5,4 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=Object.freeze({name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate: 1755612916,version:"12.0.0-develop.3",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"});exports.packageMetadata=e;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=Object.freeze({name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate: 1755629704,version:"12.0.0-develop.4",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"});exports.packageMetadata=e;
@@ -10,8 +10,8 @@ const e = Object.freeze({
10
10
  productName: "KendoReact",
11
11
  productCode: "KENDOUIREACT",
12
12
  productCodes: ["KENDOUIREACT"],
13
- publishDate: 1755612916,
14
- version: "12.0.0-develop.3",
13
+ publishDate: 1755629704,
14
+ version: "12.0.0-develop.4",
15
15
  licensingDocsUrl: "https://www.telerik.com/kendo-react-ui/components/my-license/"
16
16
  });
17
17
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@progress/kendo-react-conversational-ui",
3
- "version": "12.0.0-develop.3",
3
+ "version": "12.0.0-develop.4",
4
4
  "description": "React Chat component allows the user to participate in chat sessions with users or chat bots. KendoReact Conversational UI components",
5
5
  "author": "Progress",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -26,11 +26,11 @@
26
26
  "sideEffects": false,
27
27
  "peerDependencies": {
28
28
  "@progress/kendo-licensing": "^1.7.0",
29
- "@progress/kendo-react-buttons": "12.0.0-develop.3",
30
- "@progress/kendo-react-common": "12.0.0-develop.3",
31
- "@progress/kendo-react-intl": "12.0.0-develop.3",
32
- "@progress/kendo-react-inputs": "12.0.0-develop.3",
33
- "@progress/kendo-react-layout": "12.0.0-develop.3",
29
+ "@progress/kendo-react-buttons": "12.0.0-develop.4",
30
+ "@progress/kendo-react-common": "12.0.0-develop.4",
31
+ "@progress/kendo-react-intl": "12.0.0-develop.4",
32
+ "@progress/kendo-react-inputs": "12.0.0-develop.4",
33
+ "@progress/kendo-react-layout": "12.0.0-develop.4",
34
34
  "@progress/kendo-svg-icons": "^4.0.0",
35
35
  "react": "^16.8.2 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc",
36
36
  "react-dom": "^16.8.2 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc"
@@ -59,7 +59,7 @@
59
59
  "package": {
60
60
  "productName": "KendoReact",
61
61
  "productCode": "KENDOUIREACT",
62
- "publishDate": 1755612916,
62
+ "publishDate": 1755629704,
63
63
  "licensingDocsUrl": "https://www.telerik.com/kendo-react-ui/components/my-license/"
64
64
  }
65
65
  },