@progress/kendo-react-conversational-ui 14.5.0-develop.8 → 15.0.0-develop.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/ai-prompt/AIPrompt.d.ts +6 -0
- package/ai-prompt/AIPrompt.js +1 -1
- package/ai-prompt/AIPrompt.mjs +40 -38
- package/ai-prompt/AIPromptContent.js +1 -1
- package/ai-prompt/AIPromptContent.mjs +5 -5
- package/ai-prompt/views/AIPromptOutputView.js +1 -1
- package/ai-prompt/views/AIPromptOutputView.mjs +6 -6
- package/chat/ChatPropsAndState.d.ts +17 -0
- package/chat/components/Chat.js +1 -1
- package/chat/components/Chat.mjs +222 -220
- package/chat/components/ChatMessage.js +1 -1
- package/chat/components/ChatMessage.mjs +133 -117
- package/chat/components/Header.js +1 -1
- package/chat/components/Header.mjs +1 -1
- package/chat/components/NewMessage.js +1 -1
- package/chat/components/NewMessage.mjs +49 -48
- package/chat/components/Notification.js +1 -1
- package/chat/components/Notification.mjs +1 -1
- package/chat/components/elements/FileBox.js +1 -1
- package/chat/components/elements/FileBox.mjs +10 -9
- package/chat/components/elements/PinnedMessage.js +1 -1
- package/chat/components/elements/PinnedMessage.mjs +14 -13
- package/chat/hooks/useEndlessScroll.js +1 -1
- package/chat/hooks/useEndlessScroll.mjs +103 -101
- package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
- package/inline-ai-prompt/InlineAIPrompt.js +1 -1
- package/inline-ai-prompt/InlineAIPrompt.mjs +10 -10
- package/inline-ai-prompt/InlineAIPromptInput.js +1 -1
- package/inline-ai-prompt/InlineAIPromptInput.mjs +1 -1
- package/messages/index.d.ts +5 -0
- package/messages/index.js +1 -1
- package/messages/index.mjs +12 -10
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +17 -12
- package/prompt-box/FileBox.js +1 -1
- package/prompt-box/FileBox.mjs +21 -20
- package/prompt-box/PromptBox.js +1 -1
- package/prompt-box/PromptBox.mjs +148 -150
|
@@ -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-layout"),require("@progress/kendo-react-intl"),require("prop-types"),require("@progress/kendo-react-upload"),require("@progress/kendo-react-animation"),require("@progress/kendo-react-notification"),require("@progress/kendo-react-inputs"),require("@progress/kendo-react-popup")):"function"==typeof define&&define.amd?define(["exports","react","@progress/kendo-react-common","@progress/kendo-react-buttons","@progress/kendo-svg-icons","@progress/kendo-react-layout","@progress/kendo-react-intl","prop-types","@progress/kendo-react-upload","@progress/kendo-react-animation","@progress/kendo-react-notification","@progress/kendo-react-inputs","@progress/kendo-react-popup"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoReactConversationalUi={},e.React,e.KendoReactCommon,e.KendoReactButtons,e.KendoSvgIcons,e.KendoReactLayout,e.KendoReactIntl,e.PropTypes,e.KendoReactUpload,e.KendoReactAnimation,e.KendoReactNotification,e.KendoReactInputs,e.KendoReactPopup)}(this,function(e,t,n,a,l,o,s,r,i,c,u,m,d){"use strict";function g(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var p=g(t);const f="newMessage.sendButton",h="newMessage.optionsButton",v="newMessage.messageInput",k="avatar.alt",b="messageList.ariaLabel",y="aIPrompt.noOutputs",E="aIPrompt.cancel",C="chat.senderDeletedMessage",x="chat.receiverDeletedMessage",I="chat.copyNotification",T="chat.downloadAllFiles",F="chat.closeReply",S="chat.collapseMessage",w="chat.expandMessage",A="chat.removeFile",M="chat.fileActions",R="chat.attachFile",N="chat.downloadAll",B="chat.scrollLeft",L="chat.scrollRight",D="chat.scrollToBottom",P="chat.messageFailed",O="chat.retryMessage",z="chat.stopGenerating",q="promptBox.input",H="promptBox.sendButton",$="promptBox.attachFile",U="promptBox.removeFile",K="promptBox.stopGenerating",V="promptBox.ariaLabel",j={[f]:"Send",[h]:"Options",[v]:"Message",[k]:"Avatar",[b]:"Message list",[E]:"Cancel",[y]:"No output from AI available",[C]:"You removed this message",[x]:"The message was removed by its sender",[I]:"Text copied to clipboard",[T]:"Download all files",[F]:"Close reply",[S]:"Collapse message",[w]:"Expand message",[A]:"Remove file",[M]:"File actions for",[P]:"Failed to send",[O]:"Retry",[z]:"Stop generating",[R]:"Attach file",[N]:"Download all",[B]:"Scroll left",[L]:"Scroll right",[D]:"Scroll to bottom",[q]:"Prompt",[H]:"Send",[$]:"Attach file",[U]:"Remove file",[K]:"Stop generating",[V]:"Prompt box"},W=(e,t)=>e&&t.author&&e.id===t.author.id,G=(e,t)=>{const n=t.toLanguageString("chatSender.deletedMessage",j[C]),a=t.toLanguageString("chatReceiver.deletedMessage",j[x]);return e?n:a},_=(e,t)=>e.find(e=>e.id===t),Y=/(https?:\/\/[^\s]+)/g,X=e=>{if(!e)return[""];const t=e.split(Y),n=[];return t.forEach(e=>{e&&Y.test(e)?(Y.lastIndex=0,n.push(p.createElement("a",{key:e,href:e,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"}},e))):e&&n.push(e)}),n},J=p.createContext(void 0),Q=()=>{const e=t.useContext(J);if(void 0===e)throw new Error("useChatContext must be used within a ChatContext.Provider");return e},Z=e=>{const{files:t,onFileAction:o,onDownload:r,fileActions:i}=e,{messageFilesLayout:c="vertical"}=Q(),u=s.useLocalization(),m=i||[{id:"download",label:"Download",svgIcon:l.downloadLightIcon}],d=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]}`},g=e=>"."+e.split(".").pop()||"",f=e=>m.length>0&&p.createElement(a.DropDownButton,{fillMode:"flat",svgIcon:l.moreVerticalIcon,onClick:e=>{e.syntheticEvent.stopPropagation()},onItemClick:t=>((e,t)=>{var n,a;null==(a=null==(n=e.syntheticEvent)?void 0:n.stopPropagation)||a.call(n),"download"===e.item.id&&(null==r||r([t])),null==o||o(e.item,e,t)})(t,e),items:m.map(e=>({id:e.id,icon:e.icon,text:e.label,svgIcon:e.svgIcon})),"aria-label":`${u.toLanguageString(M,j[M])} ${e.name}`,title:`${u.toLanguageString(M,j[M])} ${e.name}`}),h=p.useCallback(()=>n.classNames({"k-files-wrap":"wrap"===c,"k-files-vertical":"vertical"===c},"k-file-box-wrapper"),[c]);return p.createElement("ul",{className:h()},"horizontal"===c?p.createElement("div",{className:"k-files-scroll"},t.map(e=>p.createElement("li",{key:e.name,className:"k-file-box"},p.createElement(n.IconWrap,{size:"xlarge",...n.getFileExtensionIcon(g(e.name))}),p.createElement("div",{className:"k-file-info"},p.createElement("span",{className:"k-file-name"},e.name),p.createElement("span",{className:"k-file-size"},d(e.size))),f(e)))):t.map(e=>p.createElement("li",{key:e.name,className:"k-file-box"},p.createElement(n.IconWrap,{size:"xlarge",...n.getFileExtensionIcon(g(e.name))}),p.createElement("div",{className:"k-file-info"},p.createElement("span",{className:"k-file-name"},e.name),p.createElement("span",{className:"k-file-size"},d(e.size))),f(e))))},ee=p.forwardRef((e,t)=>{const{item:r,template:i,contentTemplate:c,onRequestSelection:u,tabIndex:m=-1,dateFormat:d="g",selected:g,allowMessageCollapse:f,messageToolbarActions:h,messageContextMenuActions:v,fileActions:k,isSender:b}=e,{setReplyToMessage:y,messages:E,repliedToMessages:C,user:x,onToolbarAction:I,onContextMenuAction:F,onFileAction:A,onDownload:M,onResendMessage:R,setShowCopyNotification:B,statusTemplate:L,timestampVisibility:D="onFocus",onReferencedMessageClick:z}=Q(),[q,H]=p.useState(!1),[$,U]=p.useState(!1),[K,V]=p.useState(!0),[Y,J]=p.useState(!1),ee=s.useLocalization(),te=s.useInternationalization(),ne=p.useRef({left:0,top:0}),ae=p.useCallback(()=>{null!=r&&r.text&&(e=>{navigator.clipboard.writeText(e)})(r.text),B&&(B(!0),setTimeout(()=>{B(!1)},3e3))},[r,B]),le=p.useCallback(e=>{e.stopPropagation(),V(e=>!e)},[]),oe=p.useCallback(()=>{J(!1)},[]),se=p.useCallback(e=>{("Tab"===e.key||"Enter"===e.key||" "===e.key||"ArrowUp"===e.key||"ArrowDown"===e.key)&&J(!0)},[]),re=p.useRef(null);p.useEffect(()=>{g&&re.current&&re.current.focus()},[g]);const ie=p.useCallback(e=>{ne.current={left:e.pageX,top:e.pageY},e.preventDefault(),U(!0),H(!0)},[]),ce=p.useCallback(()=>{U(!1),H(!1)},[]),ue=p.useCallback((e,t)=>e.isDeleted?G(t,ee):e.text?e.text:"",[ee]),me=p.useCallback(e=>{var t;null!=(t=e.item)&&t.text&&("copy"!==e.item.data.id||r.isDeleted?"reply"===e.item.data.id&&y(r):ae(),F&&F(e.item.data,e,r)),U(!1),H(!1)},[r,F,y,ae]),de=p.useCallback(()=>{if(r.replyToId){const e=_(E,r.replyToId)||(C?_(C,r.replyToId):void 0);if(e){const t=t=>{t.preventDefault(),t.stopPropagation(),null==z||z(e.id)};return p.createElement("div",{className:n.classNames("k-message-reference",W(x,e)?"k-message-reference-sender":"k-message-reference-receiver"),onClick:t},p.createElement("div",{className:"k-message-reference-content"},X(ue(e,W(x,e)))))}}return null},[r.replyToId,E,C,x,ue,z]),ge=p.useCallback(()=>{const e=[{id:"reply",label:"Reply",svgIcon:l.undoIcon},{id:"copy",label:"Copy",svgIcon:l.copyIcon}],t=v?[...e.map(e=>v.find(t=>t.id===e.id)||e),...v.filter(t=>!e.some(e=>e.id===t.id))]:e;return p.createElement(o.ContextMenu,{onSelect:me,onClose:ce,vertical:!0,show:q,offset:ne.current},t.map(e=>"delete"!==e.id||b?p.createElement(o.MenuItem,{key:e.id,text:e.label,icon:e.icon,svgIcon:e.svgIcon,data:e}):null))},[v,me,ce,q,b]),pe=p.useCallback(()=>r.files&&r.files.length>1?p.createElement("div",{className:"k-chat-download-button-wrapper"},p.createElement(a.Button,{className:"k-chat-download-button",fillMode:"flat",svgIcon:l.downloadLightIcon,size:"small",onClick:e=>{e.stopPropagation(),M&&M(r.files,r)},"aria-label":ee.toLanguageString(T,j[T])},p.createElement("span",{className:"k-button-text"},ee.toLanguageString(N,j[N])))):null,[r,M,ee]),fe=p.useCallback(()=>{if(r.typing)return p.createElement("div",{className:"k-chat-bubble k-bubble"},p.createElement("div",{className:"k-bubble-content"},p.createElement("div",{className:"k-typing-indicator"},p.createElement("span",null),p.createElement("span",null),p.createElement("span",null))));if(i){const e=i;return p.createElement(p.Fragment,null,p.createElement(e,{item:r}),ge())}return r.text||r.files&&r.files.length>0?p.createElement(p.Fragment,null,p.createElement("div",{className:n.classNames("k-chat-bubble","k-bubble",{"k-bubble-expandable":f,"k-expanded":f&&K,"k-selected":g,"k-active":$}),onClick:()=>u(g?void 0:r.selectionIndex),onContextMenu:ie},p.createElement("div",{className:"k-bubble-content"},c?p.createElement(c,{item:r}):p.createElement(p.Fragment,null,(r.text||r.isDeleted||r.replyToId)&&p.createElement("span",{className:"k-chat-bubble-text"},!r.isDeleted&&de(),X(ue(r,W(x,r)))),r.files&&r.files.length>0&&p.createElement(Z,{files:r.files,message:r,onFileAction:A,onDownload:e=>null==M?void 0:M(e,r),renderInTextarea:!1,fileActions:k}),pe())),f&&p.createElement("span",{className:"k-bubble-expandable-indicator",onClick:le,role:"button","aria-label":K?ee.toLanguageString(S,j[S]):ee.toLanguageString(w,j[w]),tabIndex:0,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),le(e))}},p.createElement(n.IconWrap,{icon:K?l.chevronUpIcon:l.chevronDownIcon,size:"medium"}))),ge()):null},[r,i,c,f,K,g,$,u,ie,de,ue,x,A,k,pe,le,ee,ge,M]),he=p.useCallback(()=>{let e=null;if(r.timestamp){const t="onFocus"===D&&g;"hidden"===D||(e=p.createElement("time",{className:"k-message-time","aria-hidden":!t},te.formatDate(r.timestamp,d)))}return e},[r.timestamp,g,d,D,te]),ve=p.useCallback(()=>{if(!r.status)return null;let e;if(L)e=p.createElement(L,{item:r});else{let t,a,l;if("object"==typeof r.status&&null!==r.status){const e=r.status;t=e.text,a=e.icon,l=e.svgIcon}else t=r.status;let o=null;a?o=p.createElement(n.Icon,{name:a,size:"xsmall"}):l&&(o=p.createElement(n.IconWrap,{icon:l,size:"xsmall"})),e=p.createElement(p.Fragment,null,o,t)}return p.createElement("span",{className:"k-message-status"},e)},[r,L]),ke=p.useCallback(()=>{let e=null;if(r.isFailed){const t=ee.toLanguageString(P,j[P]);e=p.createElement("span",{className:"k-message-failed-content"},p.createElement(n.IconWrap,{icon:l.warningTriangleIcon,size:"xsmall"}),p.createElement("span",{className:"k-message-failed-text"},t))}return e},[r,ee]),be=p.useCallback(()=>{let e=null;if(r.isFailed){const t=ee.toLanguageString(O,j[O]);e=p.createElement(a.Button,{fillMode:"clear",size:"small",className:"k-resend-button",svgIcon:l.arrowRotateCwOutlineIcon,"aria-label":t,title:t,onClick:e=>{e.stopPropagation(),R&&R({message:r,syntheticEvent:e,nativeEvent:e.nativeEvent,target:e.target})}})}return e},[r,ee,R]),ye=p.useCallback(()=>n.classNames({"k-focus":g,"k-message-removed":r.isDeleted,"k-message-failed":r.isFailed},"k-message"),[g,r.isDeleted,r.isFailed]),Ee=p.useCallback(()=>h&&h.length>0&&p.createElement(a.Toolbar,{className:"k-chat-message-toolbar",fillMode:"flat"},h.map(e=>"delete"!==e.id||b?p.createElement(a.Button,{key:e.id,fillMode:"flat",className:"k-toolbar-button",icon:e.icon,svgIcon:e.svgIcon,onClick:t=>{t.stopPropagation(),"copy"!==e.id||r.isDeleted?"reply"===e.id&&y(r):ae(),I&&I(e,t,r)},onMouseDown:e=>e.preventDefault()}):null)),[ae,b,r,h,I,y]);return p.createElement("div",{key:r.id,"data-message-id":r.id,className:ye(),tabIndex:m,onMouseDown:oe,onKeyDown:se,onFocus:e=>{Y&&u(r.selectionIndex)},ref:e=>{re.current=e,"function"==typeof t?t(e):t&&(t.current=e)},onContextMenu:i?ie:void 0},be(),fe(),(r.status||r.timestamp&&"hidden"!==D||r.isFailed)&&p.createElement("div",{className:"k-message-info"},ve(),he(),ke()),Ee())});ee.displayName="ChatMessage";const te=e=>e[e.length-1],ne=e=>(t,n,a)=>{const l=a===e-1;return((e,t)=>{const n=t.timestamp,a=te(e);if(n&&(!a||((e,t)=>e&&t&&(t.getDate()!==e.getDate()||t.getMonth()!==e.getMonth()||t.getFullYear()!==e.getFullYear()))(n,a.timestamp))){const t={type:"date-marker",timestamp:n,trackBy:n.getTime()};e.push(t)}})(t,n),((e,t,n)=>{const a=te(e);let l;t.typing&&!n||(a&&"message-group"===a.type&&(l=a.messages),l&&W(t.author,te(l))?l.push(t):e.push({type:"message-group",messages:[t],author:t.author,timestamp:t.timestamp,trackBy:t}))})(t,n,l),n.attachments&&n.attachments.length>1&&t.push({type:"attachment-group",attachments:n.attachments,attachmentLayout:n.attachmentLayout,timestamp:n.timestamp,trackBy:n}),n.suggestedActions&&l&&t.push({type:"action-group",actions:n.suggestedActions,timestamp:n.timestamp,trackBy:n}),t};const ae=e=>{const{item:t,onActionExecute:a,selected:l}=e,o=p.useRef(null);p.useEffect(()=>{l&&o.current&&o.current.focus()},[l]);const s=p.useCallback(e=>{(e.keyCode===n.Keys.enter||" "===e.key)&&(e.preventDefault(),a(t,e))},[a,t]),r=p.useCallback(()=>n.classNames("k-suggestion k-suggestion-primary",{"k-selected":l},{"k-focus":l}),[l]);return p.createElement("span",{role:"button",className:r(),onClick:e=>a(t,e),ref:o,onKeyDown:s,tabIndex:0,"aria-label":t.title||t.value},t.title||t.value)},le=({visible:e,dir:t,canScrollLeft:n,canScrollRight:o,onScrollLeft:r,onScrollRight:i,children:c})=>{const u=s.useLocalization();if(!e)return c;const m=u.toLanguageString(B,j[B]),d=u.toLanguageString(L,j[L]),g="rtl"!==t?m:d,f="rtl"!==t?d:m;return p.createElement("div",{className:"k-suggestion-scrollwrap"},p.createElement(a.Button,{fillMode:"flat",size:"small",svgIcon:"rtl"===t?l.chevronRightIcon:l.chevronLeftIcon,onClick:r,disabled:!n,"aria-label":g,title:g}),c,p.createElement(a.Button,{fillMode:"flat",size:"small",svgIcon:"rtl"===t?l.chevronLeftIcon:l.chevronRightIcon,onClick:i,disabled:!o,"aria-label":f,title:f}))},oe=100,se=(e,t)=>{const{enabled:n,dir:a,mode:l,itemsDependency:o=[],scrollSpeed:s=oe}=t,[r,i]=p.useState(!1),[c,u]=p.useState(!1),m=p.useCallback(()=>{if(e.current&&n){const{scrollLeft:t,scrollWidth:n,clientWidth:l}=e.current,o="rtl"!==a?t+l>=n-1:l-t>=n-1;i(!(0===t)),u(!o)}},[n,a]),d=p.useCallback(()=>{e.current&&n&&e.current.scrollBy({left:"rtl"!==a?-s:s,behavior:"smooth"})},[n,a,s]),g=p.useCallback(()=>{e.current&&n&&e.current.scrollBy({left:"rtl"!==a?s:-s,behavior:"smooth"})},[n,a,s]);return p.useEffect(()=>{const t=e.current;if(!t||!n)return;m();const a=()=>m();t.addEventListener("scroll",a,{passive:!0});const l=new ResizeObserver(m);return l.observe(t),()=>{t.removeEventListener("scroll",a),l.disconnect()}},[n,m,o.length,l]),p.useLayoutEffect(()=>{n&&m()},[n,a,o]),{canScrollLeft:r,canScrollRight:c,scrollLeft:d,scrollRight:g}},re=e=>{var t,a;const{group:l,onActionExecute:o,selected:s,onRequestSelection:r,quickActionsLayout:i="scroll",dir:c}=e,[u,m]=p.useState(null),d=p.useRef(null),{canScrollLeft:g,canScrollRight:f,scrollLeft:h,scrollRight:v}=se(d,{enabled:"scrollbuttons"===i||"scroll"===i,dir:c,mode:i,itemsDependency:l.actions});p.useEffect(()=>{s||null===u?s&&null===u&&m(0):m(null)},[s,u]);const k=p.useCallback(()=>l.actions?l.actions.length-1:-1,[l.actions]),b=p.useCallback((e,t=0)=>{let n=null;return e?null===u?n=t:u<k()&&(n=u+1):null===u?n=0:u>0&&(n=u-1),null!==n&&m(n),n},[u,k]),y=p.useCallback(()=>{r(l.selectionIndex)},[r,l.selectionIndex]),E=p.useCallback(e=>{let t=null;const a=n.Keys.left,l=n.Keys.right;e.keyCode===a?t=b(!1):e.keyCode===l&&(t=b(!0)),null!==t&&(e.preventDefault(),e.stopPropagation())},[b]),C=p.useCallback(()=>n.classNames("k-suggestion-group",{"k-suggestion-group-scrollable":"scroll"===i,"k-suggestion-group-scrollable-start":f&&("scroll"===i||"scrollbuttons"===i),"k-suggestion-group-scrollable-end":g&&("scroll"===i||"scrollbuttons"===i)}),[i,f,g]),x="scroll"===i||"scrollbuttons"===i,I=p.createElement("div",{className:C(),onClick:y,onKeyDown:E,role:"toolbar",tabIndex:0,"aria-label":"Action group"},x?p.createElement("div",{className:"k-suggestions-scroll",ref:d},null==(t=l.actions)?void 0:t.map((e,t)=>p.createElement(ae,{item:e,onActionExecute:o,selected:t===u,key:e.value}))):null==(a=l.actions)?void 0:a.map((e,t)=>p.createElement(ae,{item:e,onActionExecute:o,selected:t===u,key:e.value})));return p.createElement(le,{visible:"scrollbuttons"===i,dir:c,canScrollLeft:g,canScrollRight:f,onScrollLeft:h,onScrollRight:v},I)},ie=e=>{const{item:t,template:a,tabbable:l,onClick:o,selected:s}=e,r=p.useRef(null);p.useEffect(()=>{s&&r.current&&r.current.focus()},[s]);const i=p.useCallback(()=>{if(void 0!==l)return l?0:-1},[l]),c=p.useCallback(()=>n.classNames({"k-selected":s},{"k-focus":s}),[s]),u=p.useCallback(()=>t.title?p.createElement("h5",{className:"k-card-title"},t.title):null,[t.title]),m=p.useCallback(()=>t.subtitle?p.createElement("h6",{className:"k-card-subtitle"},t.subtitle):null,[t.subtitle]),d=p.useCallback(()=>0===t.contentType.indexOf("image/")?p.createElement("img",{src:t.content,alt:t.title||"Attachment",style:{maxHeight:"200px",height:"auto",maxWidth:"200px",width:"auto"}}):t.content,[t.contentType,t.content,t.title]),g=a;return p.createElement("div",{className:c(),tabIndex:i(),onClick:o,ref:r},a?p.createElement(g,{item:t}):p.createElement("div",{className:"k-card"},p.createElement("div",{className:"k-card-body"},u(),m(),d())))},ce=e=>{const{group:t,itemTemplate:o,selected:s,isLastGroup:r,onRequestSelection:i}=e,[c,u]=p.useState(null);p.useEffect(()=>{s||null===c?s&&null===c&&u(0):u(null)},[s,c]);const m=p.useCallback(e=>"list"!==e.attachmentLayout,[]),d=p.useCallback(()=>t.attachments?t.attachments.length-1:-1,[t.attachments]),g=p.useCallback(()=>t.attachments.length-1,[t.attachments]),f=p.useCallback((e,t=0)=>{let n=null;return e?null===c?n=t:c<d()&&(n=c+1):null===c?n=0:c>0&&(n=c-1),null!==n&&u(n),n},[c,d]),h=p.useCallback(()=>{i(t.selectionIndex)},[i,t.selectionIndex]),v=p.useCallback(e=>{let a,l,o=null;m(t)?(a=n.Keys.left,l=n.Keys.right):(a=n.Keys.up,l=n.Keys.down),e.keyCode===a?o=f(!1):e.keyCode===l&&(o=f(!0)),null!==o&&(e.preventDefault(),e.stopPropagation())},[f,m,t]),k=p.useCallback(e=>{h(),u(e)},[h]),b=p.useCallback(e=>{h(),f(e,1)},[h,f]),y=p.useCallback(()=>{let e=null;return m(t)&&c&&(e=p.createElement(a.Button,{icon:"chevron-left",onClick:()=>b(!1),svgIcon:l.chevronLeftIcon})),e},[m,t,c,b]),E=p.useCallback(()=>{let e=null;return m(t)&&c!==g()&&(e=p.createElement(a.Button,{icon:"chevron-right",onClick:()=>b(!0),svgIcon:l.chevronRightIcon})),e},[m,t,c,g,b]),C=p.useCallback(()=>n.classNames({"k-card-list":t.attachmentLayout,"k-card-deck":m(t)}),[t.attachmentLayout,t,m]),x=m(t),I=p.createElement("div",{className:C(),onKeyDown:x?void 0:v},t.attachments.map((e,t)=>p.createElement(ie,{item:e,template:o,selected:t===c,tabbable:r&&t===c,onClick:()=>k(t),key:e.content})));return x?p.createElement("div",{className:"k-card-deck-scrollwrap",onKeyDown:v},y(),I,E()):I},ue=({item:e,timestampTemplate:t})=>{const n=s.useInternationalization(),a=t;return p.createElement("div",{className:"k-timestamp"},a?p.createElement(a,{item:e}):n.formatDate(e.timestamp,"D"))},me=e=>{const{group:t,user:a,itemTemplate:l,contentTemplate:r,attachmentTemplate:i,onRequestSelection:c,selectedItemIndex:u,isLastGroup:m,message:d,allowMessageCollapse:g,messageToolbarActions:f,messageContextMenuActions:h,fileActions:v,messageWidthMode:b="standard",showAvatar:y=!0,showUsername:E=!0}=e,{userStatusTemplate:C}=Q(),x=s.useLocalization(),I=t.messages.length>0&&W(a,t.messages[0]),{avatarUrl:T,avatarAltText:F,name:S}=t.author,w=p.useMemo(()=>n.classNames("k-message-group",{"k-message-group-sender":I,"k-message-group-receiver":!I,"k-message-group-full-width":"full"===b,"k-no-avatar":!y||!T}),[I,b,y,T]),A=p.useMemo(()=>{const e=t.messages.length-1;return t.messages.map((t,n)=>{const o=[p.createElement(d,{item:t,template:l,contentTemplate:r,selected:t.selectionIndex===u,onRequestSelection:c,tabIndex:n===e&&m?0:-1,key:t.id,allowMessageCollapse:g,messageToolbarActions:f,messageContextMenuActions:h,fileActions:v,isSender:W(a,t)})];return t.attachments&&1===t.attachments.length&&o.push(p.createElement(ie,{item:t.attachments[0],template:i,selected:!1,key:`att-${t.attachments[0].content}`})),o})},[t.messages,d,l,r,u,c,m,g,f,h,v,a,i]),M=void 0!==F?F:x.toLanguageString(k,j[k]);return p.createElement("div",{className:w},(()=>{if(!y||!T)return;const e=p.createElement(o.Avatar,{type:"image"},p.createElement("img",{src:T,alt:M}));if(C){const n=t.messages[t.messages.length-1];return p.createElement("div",{className:"k-chat-user-status-wrapper"},e,p.createElement("div",{className:"k-chat-user-status"},p.createElement(C,{message:"dataItem"in n?n.dataItem:n})))}return e})(),p.createElement("div",{className:"k-message-group-content"},E&&p.createElement("span",{className:"k-message-author"},S),A))},de=e=>{const{suggestions:t,onSuggestionClick:a,suggestionsView:l,suggestionTemplate:o,suggestionsLayout:s,dir:r}=e,i=p.useRef(null),{canScrollLeft:c,canScrollRight:u,scrollLeft:m,scrollRight:d}=se(i,{enabled:"scrollbuttons"===s||"scroll"===s,dir:r,mode:s,itemsDependency:t}),g=p.useCallback((e,t)=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),null==a||a(t))},[a]),f=p.useCallback(()=>t.map(e=>o?p.createElement(o,{key:e.id,suggestion:e,onClick:()=>{null==a||a(e)}}):p.createElement("span",{role:"button",tabIndex:e.disabled?-1:0,"aria-label":e.description,"aria-disabled":e.disabled,onClick:()=>!e.disabled&&(null==a?void 0:a(e)),onKeyDown:t=>!e.disabled&&g(t,e),key:e.id,title:e.description,className:n.classNames("classic"===l?"k-prompt-suggestion":"k-suggestion",{"k-disabled":e.disabled})},e.text)),[t,o,a,l,g]);if(!t||0===t.length)return null;if("classic"===l)return f();const h="scroll"===s||"scrollbuttons"===s,v=p.createElement("div",{role:"group",className:n.classNames("k-suggestion-group",{"k-suggestion-group-scrollable":"scroll"===s,"k-suggestion-group-scrollable-start":u&&("scroll"===s||"scrollbuttons"===s),"k-suggestion-group-scrollable-end":c&&("scroll"===s||"scrollbuttons"===s)})},h?p.createElement("div",{className:"k-suggestions-scroll",ref:i},f()):f());return p.createElement(le,{visible:"scrollbuttons"===s,dir:r,canScrollLeft:c,canScrollRight:u,onScrollLeft:m,onScrollRight:d},v)},ge=p.forwardRef(({onFilesAdd:e,files:t=[],restrictions:n,multiple:l=!0,accept:o,uploadRef:s,onSelectAttachments:r,onRemoveAttachment:c,_registerRemoveCallback:u,...m},d)=>{p.useEffect(()=>(u&&c&&u(c),()=>{u&&c&&u(void 0)}),[c,u]);const g=p.useCallback(t=>{e&&e(t),r&&r({selectedFiles:t.affectedFiles,allFiles:t.newState})},[e,r]);return p.createElement(p.Fragment,null,p.createElement(a.Button,{ref:d,...m}),p.createElement(i.Upload,{ref:s,files:t,onAdd:g,autoUpload:!1,restrictions:n,multiple:l,accept:o,className:"k-hidden"}))});ge.displayName="PromptBoxUploadButton";const pe=p.forwardRef((e,t)=>p.createElement(a.Button,{ref:t,...e}));pe.displayName="PromptBoxActionButton";const fe=p.forwardRef((e,t)=>p.createElement(a.SpeechToTextButton,{ref:t,...e}));fe.displayName="PromptBoxSpeechToTextButton";const he=e=>"."+e.split(".").pop()||"",ve=({files:e,onRemoveFile:t,header:o})=>{const r=s.useLocalization(),i=p.useRef(null),[c,u]=p.useState(!1),[m,d]=p.useState(!1),g=p.useCallback(()=>{const e=i.current;if(!e)return;const{scrollLeft:t,scrollWidth:n,clientWidth:a}=e,l=t+a>=n-1;d(!(0===t)),u(!l)},[]);if(p.useLayoutEffect(()=>{g()},[e,g]),p.useEffect(()=>{const e=i.current;if(!e)return;const t=()=>g(),n=new ResizeObserver(g);return n.observe(e),e.addEventListener("scroll",t,{passive:!0}),()=>{e.removeEventListener("scroll",t),n.disconnect()}},[g,e.length]),0===e.length&&!o)return null;const f=(e=>e?"function"==typeof e?e():e:null)(o),h=e.length>0&&p.createElement("ul",{className:n.classNames("k-file-box-wrapper",{"k-file-box-wrapper-scrollable-start":c,"k-file-box-wrapper-scrollable-end":m})},p.createElement("div",{className:"k-files-scroll",ref:i},e.map(e=>p.createElement("li",{key:e.name,className:"k-file-box"},p.createElement(n.IconWrap,{size:"xlarge",...n.getFileExtensionIcon(he(e.name))}),p.createElement("div",{className:"k-file-info"},p.createElement("span",{className:"k-file-name"},e.name),p.createElement("span",{className:"k-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))),p.createElement(a.Button,{fillMode:"flat",svgIcon:l.xMarkSmOutlineIcon,onClick:n=>{n.stopPropagation(),t(e.name)},"aria-label":`${r.toLanguageString(U,j[U])} ${e.name}`,title:`${r.toLanguageString(U,j[U])} ${e.name}`})))));return p.createElement("div",{className:"k-prompt-box-header"},f,h)},ke=Object.freeze({name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:0,version:"14.5.0-develop.8",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning"}),be="k-prompt-box",ye={mode:"auto",rows:1,defaultValue:"",disabled:!1,readOnly:!1,loading:!1,uploadButtonConfig:!1,speechToTextButtonConfig:!0,actionButtonConfig:!0},Ee=p.forwardRef((e,t)=>{const a=!n.validatePackage(ke,{component:"PromptBox"}),o=n.getLicenseMessage(ke),r=s.useLocalization(),i={...ye,...e},{mode:c=ye.mode,fillMode:u,rows:m=ye.rows,maxTextAreaHeight:d,value:g,defaultValue:f=ye.defaultValue,disabled:h=ye.disabled,readOnly:v=ye.readOnly,placeholder:k,title:b,maxLength:y,inputAttributes:E,topAffix:C,startAffix:x,endAffix:I,header:T,onChange:F,onFocus:S,onBlur:w,onPromptAction:A,attachments:M,loading:R=ye.loading,uploadButtonConfig:N=ye.uploadButtonConfig,speechToTextButtonConfig:B=ye.speechToTextButtonConfig,actionButtonConfig:L=ye.actionButtonConfig,className:D,style:P,...O}=i,z=p.useRef(null),[U,W]=p.useState(f),[G,_]=p.useState([]),[Y,X]=p.useState(!1),J=p.useRef(null),Q=p.useRef(null),Z=p.useRef(0),ee=p.useRef(0),te=p.useRef(!1),ne=p.useRef(0),ae=p.useRef(0),le=p.useCallback((e,t)=>e?"function"==typeof e?e(t):e:null,[]),oe=void 0!==g,se=oe?g:U,re=void 0!==M,ie=re?M:G,ce=p.useMemo(()=>!!(null!=se&&se.trim()||ie.length>0),[se,ie.length]),ue=p.useCallback(()=>{if(!z.current||"single"===c)return;const e=z.current,t=globalThis.getComputedStyle(e),n=Number.parseFloat(t.lineHeight)||20,a=Number.parseFloat(t.paddingTop)||0,l=Number.parseFloat(t.paddingBottom)||0;Z.current=e.offsetHeight||n+a+l,ee.current=n*m+a+l,"auto"===c&&!Y&&(ae.current=e.offsetWidth)},[c,m,Y]),me=p.useCallback(()=>"auto"===c?1:m,[c,m]),de=p.useCallback(e=>{if(d){const t=Number.parseInt(d,10);if(e>t)return t}return Math.max(ee.current,e)},[d]),he=p.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${Z.current}px`;const t=e.scrollHeight,n=de(t);e.style.height=`${n}px`,d&&t>Number.parseInt(d,10)&&(e.style.overflow="")},[de,d]),Ee=p.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${Z.current}px`;const t=e.scrollHeight,n=d?Math.min(t,Number.parseInt(d,10)):t;e.style.height=`${n}px`,d&&t>Number.parseInt(d,10)&&(e.style.overflow="")},[d]),Ce=p.useCallback(e=>{if(ae.current<=0)return!1;const t=e.style.height,n=e.style.width;e.style.overflow="hidden",e.style.width=`${ae.current}px`,e.style.height=`${Z.current}px`;const a=e.scrollWidth<=ae.current&&e.scrollHeight<=Z.current;return e.style.overflow="",e.style.width=n||"",e.style.height=t||"",a},[]),xe=p.useCallback((e,t)=>{if(!te.current){if((e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&!Y)return te.current=!0,void X(!0);if(Y){Ee(e);t<ne.current&&Ce(e)&&(e.style.height="",te.current=!0,X(!1))}}},[Y,Ee,Ce]),Ie=p.useCallback(()=>{var e;if("single"===c||!z.current)return;const t=z.current,n=(null==(e=t.value)?void 0:e.length)||0;"multi"===c?he(t):"auto"===c&&xe(t,n)},[c,he,xe]);p.useEffect(()=>{"single"!==c&&z.current&&ue()},[c,ue]),p.useEffect(()=>{"single"!==c&&z.current&&(ue(),Ie())},[m,c,ue,Ie]),p.useEffect(()=>{if("single"!==c&&z.current){const e=(null==se?void 0:se.length)||0;requestAnimationFrame(()=>{if(z.current){const t=z.current;"multi"===c?he(t):"auto"===c&&xe(t,e),ne.current=e}})}},[se,c,he,xe]),p.useEffect(()=>{"auto"===c&&Y&&z.current&&requestAnimationFrame(()=>{if(z.current){const e=z.current;Ee(e),te.current=!1}})},[Y,c,Ee]),p.useEffect(()=>{if("auto"===c&&z.current){const e=z.current;Y||(e.style.height="",e.style.overflow="",te.current=!1)}},[c,Y]),p.useEffect(()=>{if("single"===c||!z.current)return;const e=z.current;let t;const n=new ResizeObserver(()=>{clearTimeout(t),t=setTimeout(()=>{z.current&&("auto"===c&&!Y&&ue(),Ie())},50)});return n.observe(e),()=>{n.disconnect(),clearTimeout(t)}},[c,Y,ue,Ie]);const Te=p.useCallback(()=>({focus:()=>{var e;return null==(e=z.current)?void 0:e.focus()},blur:()=>{var e;return null==(e=z.current)?void 0:e.blur()},element:z.current,get value(){return se}}),[se]);p.useImperativeHandle(t,Te);const Fe=p.useCallback(e=>{const t=e.target.value;!oe&&!h&&W(t),F&&!h&&n.dispatchEvent(F,e,{...Te(),value:t},{value:t}),"single"!==c&&Ie()},[W,F,h,oe,Te,c,Ie]),Se=p.useCallback(e=>{S&&!h&&n.dispatchEvent(S,e,Te(),void 0)},[S,h,Te]),we=p.useCallback(e=>{w&&!h&&n.dispatchEvent(w,e,Te(),void 0)},[w,h,Te]),Ae=p.useCallback(e=>{e.preventDefault()},[]),Me=p.useCallback(e=>{A&&n.dispatchEvent(A,e,Te(),{value:se,attachments:ie}),oe||W(""),re||_([])},[A,Te,se,ie,oe,re]),Re=p.useCallback(e=>{if("Enter"!==e.key||!e.shiftKey){if("ArrowUp"===e.key||"ArrowDown"===e.key)return void e.stopPropagation();if("Enter"===e.key){if(e.preventDefault(),R)return;ce&&Me(e)}}},[Me,R,ce]),Ne={disabled:h,readOnly:v,placeholder:k,title:b,maxLength:y,"aria-label":r.toLanguageString(q,j[q]),value:se,onKeyDown:Re,...E,onChange:Fe,onFocus:Se,onBlur:we,ref:z},Be=p.useCallback(e=>{var t,a;const{isFinal:l,alternatives:o}=e;if(o.length>0){const e=o[0];if(l){const a=(null==(t=z.current)?void 0:t.value)||"",l=(a?`${a} `:"")+e.transcript;if(oe||W(l),F&&!h){const e={target:z.current,currentTarget:z.current};n.dispatchEvent(F,e,{...Te(),value:l},{value:l})}}}null==(a=z.current)||a.focus()},[oe,F,h,Te]),Le=p.useCallback(()=>{var e,t;null==(t=null==(e=J.current)?void 0:e.actionElement)||t.click()},[]),De=p.useCallback(e=>{var t;const n=Array.from(e.affectedFiles),a="object"==typeof N&&N.onSelectAttachments;re||_(e=>[...e,...n]),a&&a({selectedFiles:e.affectedFiles,allFiles:e.newState}),null==(t=z.current)||t.focus()},[N,re]),Pe=p.useMemo(()=>({uploadButtonProps:{fillMode:"flat",svgIcon:l.paperclipOutlineAltRightIcon,size:"small",rounded:"full",onClick:Le,onFilesAdd:De,files:ie,uploadRef:J,"aria-label":r.toLanguageString($,j[$]),title:r.toLanguageString($,j[$]),_registerRemoveCallback:e=>{Q.current=e}},speechToTextButtonProps:{fillMode:"flat",size:"small",rounded:"full",onResult:Be},actionButtonProps:{rounded:"full",size:"small",svgIcon:R?l.stopSmIcon:l.arrowUpOutlineIcon,className:R?"k-generating":"",onClick:Me,onMouseDown:Ae,disabled:!R&&!ce,"aria-disabled":!R&&!ce,"aria-label":R?r.toLanguageString(K,j[K]):r.toLanguageString(H,j[H]),title:R?r.toLanguageString(K,j[K]):r.toLanguageString(H,j[H]),"aria-live":"polite"}}),[Be,De,ie,Me,Ae,R,Le,r,ce]),Oe=p.useCallback(e=>{re||_(t=>t.filter(t=>t.name!==e));const t="object"==typeof N&&N.onRemoveAttachment;t&&(Q.current=t),Q.current&&Q.current(e)},[N,re]),ze=()=>{const e=!1!==B,t=!1!==L,n=!1!==N,a="object"==typeof B?B:void 0,l="object"==typeof N?N:{},{restrictions:o,multiple:s=!0,accept:r,onSelectAttachments:i,onRemoveAttachment:c,...u}=l,m={restrictions:o,multiple:s,accept:r},d="object"==typeof L?L:void 0;return p.createElement(p.Fragment,null,n&&p.createElement(ge,{...Pe.uploadButtonProps,restrictions:m.restrictions,multiple:m.multiple,accept:m.accept,...u}),e&&p.createElement(fe,{...Pe.speechToTextButtonProps,...a}),t&&p.createElement(pe,{...Pe.actionButtonProps,...d}))},qe="multi"===c||"auto"===c&&Y,He=!1!==N||!1!==B||!1!==L,$e=I||He,Ue=x||I||He;return p.createElement("div",{"aria-label":r.toLanguageString(V,j[V]),...O,className:n.classNames(D,"k-input",be,{[`k-input-${u}`]:u,"k-disabled":h,"k-prompt-box-singleline":"single"===c,"k-prompt-box-multiline":qe}),style:P},p.createElement(ve,{files:ie,onRemoveFile:Oe,header:T}),"single"===c?p.createElement("div",{className:`${be}-content`},x&&p.createElement("div",{className:`${be}-affix`},le(x,Pe)),p.createElement("input",{...Ne,className:n.classNames("k-input-inner",`${be}-input`)}),$e?p.createElement("div",{className:`${be}-affix`},I&&le(I,Pe),ze()):null):p.createElement("div",{className:`${be}-content`},"multi"===c&&C&&p.createElement("div",{className:`${be}-affix`},le(C,Pe)),"auto"===c&&!Y&&x&&p.createElement("div",{className:`${be}-affix`},le(x,Pe)),p.createElement("textarea",{...Ne,className:n.classNames("k-input-inner",`${be}-textarea`),rows:me(),style:d?{maxHeight:d}:{},...qe&&{"aria-multiline":"true"}}),"auto"===c&&!Y&&$e?p.createElement("div",{className:`${be}-affix`},I&&le(I,Pe),ze()):null,qe&&Ue?p.createElement("div",{className:`${be}-affix`},x&&le(x,Pe),(x||I)&&p.createElement("div",{className:"k-spacer"}),I&&le(I,Pe),ze()):null),a&&p.createElement(n.WatermarkOverlay,{message:o}))});Ee.propTypes={value:r.string,defaultValue:r.string,mode:r.oneOf(["single","multi","auto"]),rows:r.number,maxTextAreaHeight:r.string,title:r.string,disabled:r.bool,readOnly:r.bool,placeholder:r.string,maxLength:r.number,inputAttributes:r.object,fillMode:r.oneOf(["solid","flat","outline"]),topAffix:r.oneOfType([r.func,r.element,r.string]),startAffix:r.oneOfType([r.func,r.element,r.string]),endAffix:r.oneOfType([r.func,r.element,r.string]),header:r.oneOfType([r.func,r.element,r.string]),onChange:r.func,onFocus:r.func,onBlur:r.func,loading:r.bool,uploadButtonConfig:r.oneOfType([r.bool,r.object]),speechToTextButtonConfig:r.oneOfType([r.bool,r.object]),actionButtonConfig:r.oneOfType([r.bool,r.object]),attachments:r.array,onPromptAction:r.func,className:r.string,style:r.object},Ee.displayName="KendoPromptBox";const Ce=p.memo(({affixProps:e,uploadConfig:t,localizationService:n,onFilesSelect:a,onFileRemove:l})=>{const o="object"==typeof t?t:{};return!1!==t?p.createElement(ge,{...e.uploadButtonProps,fillMode:"clear","aria-label":n.toLanguageString(R,j[R]),title:n.toLanguageString(R,j[R]),...o,onSelectAttachments:a,onRemoveAttachment:l}):null});Ce.displayName="UploadButtonAffix";const xe=p.forwardRef((e,t)=>{const{onSendMessage:o,isDirectionRightToLeft:r,placeholder:i,MessageBox:c,suggestions:u,onSuggestionClick:m,inputValue:d,onInputValueChange:g,suggestionTemplate:h,sendButtonConfig:k,onInputClick:b,suggestionsLayout:y,dir:E,messageBoxSettings:C,loading:x}=e,{replyToMessage:I,setReplyToMessage:T,user:S,speechToTextConfig:w,uploadConfig:A}=Q(),[M,R]=p.useState(""),[N,B]=p.useState([]),L=p.useRef(null),D=s.useLocalization(),P=void 0!==d,O=P?d:M,q=p.useCallback(()=>{null!==L.current&&L.current.focus()},[]);p.useEffect(()=>{I&&q()},[I,q]);const H=p.useCallback(e=>{if(e.preventDefault(),o){const t={id:"",author:S,text:O||"",timestamp:new Date,replyToId:I?I.id:void 0,files:N.map(e=>({name:e.name,size:e.size,type:e.extension,rawFile:e.getRawFile?e.getRawFile():e}))};T(null),o(t,e),B([]),P||R(""),g&&g(""),q()}},[o,O,S,I,N,T,g,q,P]);p.useImperativeHandle(t,()=>({focusInput:q}),[q]);const $=p.useCallback(e=>{B(t=>t.filter(t=>t.name!==e))},[]),U=p.useCallback((e,t)=>e.isDeleted?G(t,D):e.text,[D]),K=p.useCallback(()=>{if(I){const e=W(S,I);return p.createElement("div",{className:n.classNames("k-message-reference",e?"k-message-reference-sender":"k-message-reference-receiver")},p.createElement("div",{className:"k-message-reference-content"},U(I,e)),p.createElement("span",{className:"k-spacer"}),p.createElement(a.Button,{fillMode:"flat",svgIcon:l.xMarkSmOutlineIcon,onClick:()=>T(null),"aria-label":D.toLanguageString(F,j[F]),title:D.toLanguageString(F,j[F])}))}return null},[I,S,U,T,D]),V=p.useCallback(e=>{try{const t=Array.from(e.allFiles);B(t)}catch{}},[]),_=p.useCallback(e=>{const t=e.value;P||R(t),g&&g(t||"")},[P,g]),Y=p.useCallback(e=>{H(e.syntheticEvent)},[H]),X=p.useCallback(e=>e?"function"==typeof e?e():e:null,[]),J=p.useCallback(e=>p.createElement(p.Fragment,null,p.createElement(Ce,{affixProps:e,uploadConfig:A,localizationService:D,onFilesSelect:V,onFileRemove:$}),X(null==C?void 0:C.startAffix)),[A,D,V,$,null==C?void 0:C.startAffix,X]),Z=p.useCallback(()=>X(null==C?void 0:C.endAffix),[null==C?void 0:C.endAffix,X]),ee=p.useCallback(()=>X(null==C?void 0:C.topAffix),[null==C?void 0:C.topAffix,X]),te=p.useMemo(()=>{const e="object"==typeof k?k:{},t=!1!==k&&{"aria-label":x?D.toLanguageString(z,j[z]):D.toLanguageString(f,j[f]),title:x?D.toLanguageString(z,j[z]):D.toLanguageString(f,j[f]),dir:r?"rtl":void 0,...e};return p.createElement(Ee,{header:K(),ref:L,placeholder:i,value:O,onChange:_,onPromptAction:Y,mode:(null==C?void 0:C.mode)||"multi",rows:(null==C?void 0:C.rows)||2,maxTextAreaHeight:(null==C?void 0:C.maxTextAreaHeight)||"110",loading:x,speechToTextButtonConfig:w,actionButtonConfig:t,attachments:N,startAffix:J,endAffix:null!=C&&C.endAffix?Z:void 0,topAffix:null!=C&&C.topAffix?ee:void 0,inputAttributes:{onClick:b,"aria-label":D.toLanguageString(v,j[v])}})},[i,O,_,Y,C,x,w,k,N,K,J,Z,ee,D,r,b]);return p.createElement("div",{className:"k-message-box-wrapper"},u&&u.length>0&&p.createElement(de,{onSuggestionClick:m,suggestions:u,suggestionTemplate:h,suggestionsLayout:y,dir:E}),c?p.createElement(c,{messageInput:te}):te)});xe.displayName="NewMessage";const Ie=e=>p.createElement(a.Toolbar,{className:"k-chat-header"},e.children),Te=e=>{const{message:t,onUnpin:o,user:r,onReferencedMessageClick:i}=e,c=s.useLocalization(),u=p.useRef(null),m=r&&W(r,t),d=p.useCallback(e=>{e.preventDefault(),e.stopPropagation(),null==i||i(t.id)},[t.id,i]);return p.createElement("div",{ref:u,className:`k-message-reference ${m?"k-message-reference-sender":"k-message-reference-receiver"} k-message-pinned`,onClick:d},p.createElement(n.IconWrap,{icon:l.pinOutlineIcon}),p.createElement("div",{className:"k-message-reference-content"},null!=t&&t.isDeleted?r&&G(W(r,t),c):null==t?void 0:t.text),p.createElement("span",{className:"k-spacer"}),p.createElement(a.Button,{fillMode:"flat",svgIcon:l.xMarkSmOutlineIcon,onClick:e=>{e.stopPropagation(),null==o||o(t)}}))},Fe=e=>{const{show:t,text:n}=e;return p.createElement("div",{style:{position:"absolute",top:"90%",left:"50%",transform:"translate(-50%, -50%)",zIndex:1e3,pointerEvents:t?"auto":"none"}},p.createElement(c.Fade,null,t&&p.createElement(u.Notification,{type:{style:"dark"},closable:!1},p.createElement("span",null,n))))},Se={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",isFailedField:"isFailed"},we=(e,t={})=>{const n={...Se,...t};let a,l;a=e.author&&"object"==typeof e.author?{id:e.author.id||e.author[n.authorIdField]||e[n.authorIdField]||"",name:e.author.name||e.author[n.authorNameField]||e[n.authorNameField],avatarUrl:e.author.avatarUrl||e.author[n.authorImageUrlField]||e[n.authorImageUrlField],avatarAltText:e.author.avatarAltText||e.author[n.authorImageAltTextField]||e[n.authorImageAltTextField]}:{id:e[n.authorIdField]||e.authorId||"",name:e[n.authorNameField]||e.authorName,avatarUrl:e[n.authorImageUrlField]||e.authorImageUrl,avatarAltText:e[n.authorImageAltTextField]||e.authorImageAltText},l=e.timestamp?new Date(e.timestamp):e[n.timestampField]?new Date(e[n.timestampField]):new Date;const o={id:void 0!==e.id?e.id:e[n.idField],text:void 0!==e.text?e.text:e[n.textField]||"",author:a,timestamp:l,status:void 0!==e.status?e.status:e[n.statusField],attachments:void 0!==e.attachments?e.attachments:e[n.attachmentsField],attachmentLayout:e.attachmentLayout||"list",suggestedActions:void 0!==e.suggestedActions?e.suggestedActions:e[n.suggestedActionsField],isPinned:void 0!==e.isPinned?e.isPinned:e[n.isPinnedField]||!1,typing:void 0!==e.typing?e.typing:e[n.typingField],files:void 0!==e.files?e.files:e[n.filesField]||[],isFailed:void 0!==e.isFailed?e.isFailed:e[n.isFailedField]||!1};return e.pinnedAt&&(o.pinnedAt=new Date(e.pinnedAt)),e.pinnedBy&&(o.pinnedBy=e.pinnedBy),void 0!==e.replyToId?o.replyToId=e.replyToId:void 0!==e[n.replyToIdField]&&(o.replyToId=e[n.replyToIdField]),void 0!==e.isDeleted?o.isDeleted=e.isDeleted:void 0!==e[n.isDeletedField]&&(o.isDeleted=e[n.isDeletedField]),{...o,dataItem:e}},Ae=(e,t={})=>Array.isArray(e)?e.map(e=>we(e,t)):[],Me=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),Re=e=>{e.scrollTop=e.scrollHeight-e.clientHeight},Ne=({viewItemsWrapperRef:e,isKeyboardNavigationActiveRef:t,processedMessages:n,authorId:a,autoScrollThreshold:l,isEndless:o=!1,isOnLastBatch:s=!0,skipAutoScrollRef:r})=>{var i;const c=p.useRef(a),u=p.useRef(l),m=p.useRef(o),d=p.useRef(s);p.useEffect(()=>{c.current=a,u.current=l,m.current=o,d.current=s});const g=p.useRef(!1);p.useEffect(()=>{o||!e.current||0===n.length||g.current||(Re(e.current),g.current=!0)},[e,o,n.length]);const f=p.useRef(void 0),h=p.useRef(0),v=p.useRef(!0),k=p.useRef(!0),b=p.useRef(!1),y=p.useRef(null),E=(n.length>0?null==(i=n.at(-1))?void 0:i.id:void 0)!==f.current,C=n.length>h.current;if(E||C){const t=e.current;k.current=!t||(e=>{const{scrollHeight:t,scrollTop:n,clientHeight:a}=e;return!(t>a)||t-n-a<=100})(t)}p.useEffect(()=>{var a,l;const o=n.length,s=o>0?null==(a=n[o-1])?void 0:a.id:void 0,i=f.current,g=h.current,p=v.current;if(f.current=s,h.current=o,v.current=!1,0===o)return;const E=e.current;if(!E||t.current)return;if(p||s===i)return void(!m.current&&(p||o>g)&&(Re(E),b.current=!1,y.current=null));if(m.current&&!d.current)return;if(null!=r&&r.current)return void(r.current=!1);const C=n[o-1];if(void 0!==c.current&&void 0!==(null==(l=null==C?void 0:C.author)?void 0:l.id)&&String(C.author.id)===String(c.current))return E.scrollTo({top:E.scrollHeight-E.clientHeight,behavior:"smooth"}),b.current=!1,void(y.current=null);if(!k.current)return b.current=!1,void(y.current=null);const x=(e=>{const t=e.querySelectorAll(".k-message");return t.length>0?t[t.length-1]:null})(E);if(!x)return;const I=(e=>{const t=e.querySelector(".k-message-pinned");return t?t.offsetHeight:0})(E),T=Math.max(0,E.clientHeight-I),F=((e,t)=>{const n=null!=e?e:"20%";let a;if("number"==typeof n)a=n;else{const e=/^(-?\d+(?:\.\d+)?)%$/.exec(String(n));if(e)a=Number.parseFloat(e[1])/100*t;else{const e=Number.parseFloat(String(n));a=Number.isNaN(e)?.2*t:e}}return Math.min(a,t)})(u.current,T),S=x.getBoundingClientRect().top-E.getBoundingClientRect().top+E.scrollTop,w=Math.max(0,S-F-I),A=Math.max(0,E.scrollHeight-E.clientHeight),M=Math.min(w,A);M>E.scrollTop&&E.scrollTo({top:M,behavior:"smooth"}),y.current=w,b.current=!0},[n,e,t]),p.useEffect(()=>{const n=e.current;if(!n)return;let a=n.querySelectorAll(".k-message").length,l=n.scrollHeight,o=n.scrollTop;const s=()=>{const e=n.scrollTop;b.current&&e<o&&(b.current=!1,y.current=null),o=e},r=new MutationObserver(()=>{if(t.current)return;const e=n.querySelectorAll(".k-message").length,s=n.scrollHeight;if(e===a&&s>l&&b.current){const e=s-n.clientHeight,t=y.current,a=null===t?e:Math.min(e,t);a>n.scrollTop&&(n.scrollTop=a),o=n.scrollTop}a=e,l=s});return r.observe(n,{childList:!0,subtree:!0,characterData:!0}),n.addEventListener("scroll",s,{passive:!0}),()=>{r.disconnect(),n.removeEventListener("scroll",s)}},[e,t])},Be=["allowMessageCollapse","messageWidthMode","showAvatar","showUsername","messageTemplate","messageContentTemplate","messageToolbarActions","messageContextMenuActions","fileActions"];function Le(e,t,n,a,l){const o=((e,t)=>{var n,a;return(null==(n=null==e?void 0:e.author)?void 0:n.id)===t||(null==(a=null==e?void 0:e.author)?void 0:a.id)===String(t)})(e,t)?a:l,s={};return Be.forEach(e=>{var t;s[e]=null!=(t=null==o?void 0:o[e])?t:null==n?void 0:n[e]}),s}const De=({scrollMode:e,processedMessages:t,total:n,pageSize:a=50,startIndex:l,endIndex:o,onLoadMoreMessages:s,onReferencedMessageClick:r,viewItemsWrapperRef:i,authorId:c})=>{const u=p.useRef(!1),m="endless"===e,d=null!=n?n:t.length,g=m&&t.length===d&&!u.current,f=m&&(t.length<d||u.current);f&&(u.current=!0);const[h,v]=p.useState(-1),[k,b]=p.useState(-1),y=p.useRef(h),E=p.useRef(k);y.current=h,E.current=k;const C=p.useRef(!1),x=p.useRef(0),I=p.useRef(0),T=p.useRef(!1),F=p.useRef(d),S=p.useRef(c);S.current=c;const w=p.useRef(!1),A=p.useRef(null),M=p.useRef(!1),R=p.useRef(!1),N=p.useRef(!0),B=p.useRef(d);p.useEffect(()=>{if(g){if(u.current)return void((-1===h||-1===k)&&(v(0),b(t.length)));if(-1===h||-1===k){const e=Math.max(0,t.length-a),n=t.length;v(e),b(n)}else if(k<t.length){const e=F.current;if(E.current>=e)b(t.length);else if(t.length>e&&t.slice(e).some(e=>{var t;return void 0!==(null==(t=e.author)?void 0:t.id)&&String(e.author.id)===String(S.current)})){const e=Math.max(0,t.length-a);v(e),b(t.length),M.current=!0}}F.current=d}},[g,t.length,a,h,k,d]);const L=null!=l?l:0,D=null!=o?o:t.length,P=p.useCallback(()=>{const e=i.current;e&&(x.current=e.scrollHeight,I.current=e.scrollTop)},[i]),O=p.useCallback(e=>{var t,n,a;((e,t,n=0)=>{if(!t)return;const a=t.querySelector(`[data-message-id="${e}"]`);if(!a)return;const l=t.querySelector(".k-message-list");if(l){const e=l.getBoundingClientRect().top,t=a.getBoundingClientRect().top,o=l.scrollTop+(t-e)-n;l.scrollTo({top:o,behavior:"smooth"})}else a.scrollIntoView({behavior:"smooth",block:"start"})})(e,null==(t=i.current)?void 0:t.closest(".k-chat"),(null==(a=null==(n=i.current)?void 0:n.querySelector(".k-message-pinned"))?void 0:a.offsetHeight)||0)},[i]);p.useLayoutEffect(()=>{if(!T.current)return;const e=i.current;if(!e)return void(T.current=!1);const t=e.scrollHeight-x.current;t>0&&(e.scrollTop=I.current+t),T.current=!1,C.current=!1}),p.useLayoutEffect(()=>{if(!M.current)return;const e=i.current;e?k>=t.length&&k>0&&(M.current=!1,e.scrollTop=e.scrollHeight-e.clientHeight):M.current=!1});const z=p.useRef(!1);p.useLayoutEffect(()=>{if(!m||z.current)return;const e=i.current;e&&e.querySelector("[data-message-id]")&&(e.scrollTop=e.scrollHeight-e.clientHeight,z.current=!0)}),p.useEffect(()=>{if(!m)return;const e=i.current;if(!e)return;let n=e.scrollTop;const l=()=>{const{scrollTop:l,scrollHeight:o,clientHeight:r}=e,i=l<n,c=l>n;if(n=l,!C.current){if(i&&l<=100)if(g){const e=y.current;if(e>0){const t=Math.max(0,e-a);T.current=!0,P(),v(t),null==s||s({startIndex:t,endIndex:E.current})}}else if(f&&L>0){C.current=!0;const e=Math.max(0,L-a);T.current=!0,P(),null==s||s({startIndex:e,endIndex:D})}if(c&&o-l-r<=100)if(g){const e=E.current;if(e<t.length){const n=Math.min(t.length,e+a);R.current=!0,b(n),null==s||s({startIndex:y.current,endIndex:n})}}else if(f&&D<d){C.current=!0,R.current=!0;const e=Math.min(d,D+a);null==s||s({startIndex:L,endIndex:e})}}};return e.addEventListener("scroll",l,{passive:!0}),()=>e.removeEventListener("scroll",l)},[m,g,f,i,a,t.length,L,D,d,s]),p.useEffect(()=>{var e;const n=D>=d;if(!f)return B.current=d,void(N.current=n);const a=B.current,l=N.current;if(B.current=d,N.current=n,d>a&&!l&&n){const n=t[t.length-1];void 0!==S.current&&void 0!==(null==(e=null==n?void 0:n.author)?void 0:e.id)&&String(n.author.id)===String(S.current)&&(w.current=!0,R.current=!0)}},[f,d,D,t]),p.useEffect(()=>{!f||!w.current||(w.current=!1,C.current=!1,requestAnimationFrame(()=>{const e=i.current;e&&(e.scrollTop=e.scrollHeight-e.clientHeight)}))},[f,t,i]),p.useEffect(()=>{if(!f||null===A.current)return;const e=A.current,t=i.current;t&&t.querySelector(`[data-message-id="${e}"]`)&&(A.current=null,C.current=!1,requestAnimationFrame(()=>{O(e)}))},[f,t,i,O]),p.useEffect(()=>{f&&C.current&&!T.current&&(C.current=!1)},[f,L,D]);const q=p.useMemo(()=>{if(g){const e=Math.max(0,h),n=Math.min(t.length,k);if(e>=n){const e=Math.max(0,t.length-a);return t.slice(e)}return t.slice(e,n)}return t},[g,t,h,k,a]),H=p.useMemo(()=>!m||(g?k>=t.length:D>=d),[m,g,k,t.length,D,d]),$=p.useCallback(()=>{if(!m||H){const e=i.current;return void(e&&e.scrollTo({top:e.scrollHeight-e.clientHeight,behavior:"smooth"}))}if(!C.current)if(g){const e=Math.max(0,t.length-a);v(e),b(t.length),null==s||s({startIndex:e,endIndex:t.length}),requestAnimationFrame(()=>{const e=i.current;e&&(e.scrollTop=e.scrollHeight-e.clientHeight)})}else if(f){w.current=!0,T.current=!1,C.current=!0;const e=Math.max(0,d-a);null==s||s({startIndex:e,endIndex:d})}},[m,g,f,H,t.length,a,d,s,i]),U=p.useCallback(e=>{if(m){if(g){const n=i.current;if(null==n?void 0:n.querySelector(`[data-message-id="${e}"]`))O(e);else{if(C.current)return;const n=t.findIndex(t=>t.id===e||String(t.id)===String(e));if(n>=0){const l=Math.floor(a/2),o=Math.max(0,n-l),s=Math.min(t.length,o+a);C.current=!0,v(o),b(s),requestAnimationFrame(()=>{requestAnimationFrame(()=>{O(e),C.current=!1})})}}}else if(f){const t=i.current;if(null==t?void 0:t.querySelector(`[data-message-id="${e}"]`))O(e);else{if(C.current)return;A.current=e,T.current=!1,C.current=!0}}}else O(e);null==r||r({id:e})},[m,g,f,i,t,a,r,O]);return{renderedMessages:q,handleScrollToBottom:$,handleReferencedMessageClick:U,isEndless:m,isOnLastBatch:H,skipAutoScrollRef:R}},Pe=p.forwardRef((e,t)=>{const{messages:o=[],messageTemplate:r,messageContentTemplate:i,attachmentTemplate:c,width:u,height:m,onSendMessage:d,onSuggestionClick:g,onInputValueChange:f,onActionExecute:h,dir:v,messageBox:k,placeholder:y,className:E,style:C,message:x=ee,authorId:T,suggestions:F,suggestionTemplate:S,suggestionsLayout:w="scroll",quickActionsLayout:A="scroll",inputValue:M,headerTemplate:R,noDataTemplate:N,timestampTemplate:B,statusTemplate:L,userStatusTemplate:P,allowMessageCollapse:O,messageToolbarActions:z,messageContextMenuActions:q,fileActions:H,onUnpin:$,messageWidthMode:U,showAvatar:K,showUsername:V,timestampVisibility:W,authorMessageSettings:G,receiverMessageSettings:_,onToolbarAction:Y,onContextMenuAction:X,onFileAction:Q,onDownload:Z,speechToTextConfig:te,uploadConfig:ae,sendButtonConfig:le,messageFilesLayout:oe,scrollToBottomButton:se=!0,autoScrollThreshold:ie,textField:de,statusField:ge,authorIdField:pe,authorNameField:fe,authorImageUrlField:he,authorImageAltTextField:ve,idField:be,timestampField:ye,filesField:Ee,attachmentsField:Ce,replyToIdField:Se,isDeletedField:we,isPinnedField:Re,typingField:Be,suggestedActionsField:Pe,isFailedField:Oe,onResendMessage:ze,messageBoxSettings:qe,loading:He,scrollMode:$e,total:Ue,pageSize:Ke,startIndex:Ve,endIndex:je,onLoadMoreMessages:We,pinnedMessages:Ge,repliedToMessages:_e,onReferencedMessageClick:Ye,...Xe}=e,[Je,Qe]=p.useState(null),[Ze,et]=p.useState(!1),[tt,nt]=p.useState(!1),[at,lt]=p.useState(null),[ot,st]=p.useState(null),[rt,it]=p.useState(!1),ct=p.useRef(null),ut=p.useRef(null),mt=p.useRef(null),dt=p.useRef(null),gt=p.useRef(void 0),pt=p.useRef(!1),ft=p.useRef(null),ht=p.useRef(""),vt=p.useMemo(()=>{if(!o||0===o.length)return[];const e={textField:de,statusField:ge,authorIdField:pe,authorNameField:fe,authorImageUrlField:he,authorImageAltTextField:ve,idField:be,timestampField:ye,filesField:Ee,attachmentsField:Ce,replyToIdField:Se,isDeletedField:we,isPinnedField:Re,typingField:Be,suggestedActionsField:Pe,isFailedField:Oe};return!Object.values(e).some(e=>void 0!==e)&&Me(o[0])?o.map(e=>({...e,timestamp:e.timestamp?new Date(e.timestamp):e.timestamp})):Ae(o,e)},[o,de,ge,pe,fe,he,ve,be,ye,Ee,Ce,Se,we,Re,Be,Pe,Oe]);p.useEffect(()=>{if(T===ht.current&&ft.current)st(ft.current);else if(T&&vt.length>0){const e=vt.find(e=>e.author&&(e.author.id===T||e.author.id===String(T))),t=(null==e?void 0:e.author)||{id:T};ft.current=t,ht.current=T,st(t)}},[T,vt]);const{renderedMessages:kt,handleScrollToBottom:bt,handleReferencedMessageClick:yt,isEndless:Et,isOnLastBatch:Ct,skipAutoScrollRef:xt}=De({scrollMode:$e,processedMessages:vt,total:Ue,pageSize:Ke,startIndex:Ve,endIndex:je,onLoadMoreMessages:We,onReferencedMessageClick:Ye,viewItemsWrapperRef:mt,authorId:T}),It=p.useMemo(()=>kt.length>0?(e=>{const t=e.slice().reduce(ne(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})(kt):[],[kt]),Tt=p.useMemo(()=>!n.validatePackage(ke,{component:"Chat"}),[]),Ft=n.getLicenseMessage(ke),St=p.useMemo(()=>{if(Ge)return Ge.find(e=>e.isPinned);const e=vt.find(e=>e.isPinned);return e||void 0},[vt,Ge]),wt=s.useLocalization();Ne({viewItemsWrapperRef:mt,isKeyboardNavigationActiveRef:pt,processedMessages:kt,authorId:T,autoScrollThreshold:ie,isEndless:Et,isOnLastBatch:Ct,skipAutoScrollRef:xt});const At=(({elementRef:e})=>{const[t,n]=p.useState(!1);return p.useEffect(()=>{const t=e.current;if(!t)return;const a=()=>{n(t.scrollHeight>t.clientHeight)};a();const l=new ResizeObserver(a);l.observe(t);const o=new MutationObserver(()=>{requestAnimationFrame(a)});return o.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>{l.disconnect(),o.disconnect()}},[e]),t})({elementRef:mt}),Mt=p.useCallback(()=>{clearTimeout(gt.current)},[]),Rt=p.useCallback(()=>{gt.current=window.setTimeout(()=>{Qe(null)},0)},[]),Nt=p.useCallback(e=>{Qe(e)},[]),Bt=p.useCallback(e=>{let t=null;const a=null!==Je?Je:It.lastSelectionIndex;e.keyCode===n.Keys.up?null===a?t=0:a>0&&(t=a-1):e.keyCode===n.Keys.down?null===a?t=0:a<It.lastSelectionIndex&&(t=a+1):e.keyCode===n.Keys.home?t=0:e.keyCode===n.Keys.end&&(t=It.lastSelectionIndex),null!==t&&(Qe(t),pt.current=!0,e.preventDefault())},[Je,It]),Lt=p.useCallback((e,t,n)=>{var a;if(h&&h({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":d&&d({message:{id:"",author:ot,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==(a=dt.current)||a.focusInput()}},[h,d,ot]),Dt=p.useCallback(()=>n.classNames("k-chat",E,{"k-rtl":Ze}),[E,Ze]),Pt=p.useCallback(()=>{const e=It.length-1;return It.map((t,n)=>{var a,l,o,s,u,m;if("date-marker"===t.type)return p.createElement(ue,{item:t,key:t.trackBy,timestampTemplate:B});if("message-group"===t.type){const o={allowMessageCollapse:O,messageWidthMode:U,showAvatar:K,showUsername:V,messageTemplate:r,messageContentTemplate:i,messageToolbarActions:z,messageContextMenuActions:q,fileActions:H},s=Le(null==(a=null==t?void 0:t.messages)?void 0:a[0],T,o,G,_);return p.createElement(me,{group:t,itemTemplate:s.messageTemplate,contentTemplate:s.messageContentTemplate,attachmentTemplate:c,user:ot,selectedItemIndex:Je,onRequestSelection:Nt,isLastGroup:n===e,key:null!=(l=t.messages[0].id)?l:t.messages[0].selectionIndex,message:x,allowMessageCollapse:s.allowMessageCollapse,messageToolbarActions:s.messageToolbarActions,messageContextMenuActions:s.messageContextMenuActions,fileActions:s.fileActions,messageWidthMode:s.messageWidthMode,showAvatar:s.showAvatar,showUsername:s.showUsername})}return"attachment-group"===t.type?p.createElement(ce,{group:t,itemTemplate:c,onRequestSelection:Nt,selected:t.selectionIndex===Je,isLastGroup:n===e,key:`att-${null!=(s=null==(o=t.trackBy)?void 0:o.id)?s:t.selectionIndex}`}):"action-group"===t.type?p.createElement(re,{group:t,onActionExecute:Lt,onRequestSelection:Nt,selected:t.selectionIndex===Je,key:`act-${null!=(m=null==(u=t.trackBy)?void 0:u.id)?m:t.selectionIndex}`,quickActionsLayout:A,dir:v}):null})},[It,B,r,i,c,ot,Je,Nt,x,O,z,q,H,U,K,V,T,G,_,Lt,A,v]),Ot=p.useCallback(()=>R?"function"==typeof R?R():R:null,[R]),zt=p.useCallback(()=>N?"function"==typeof N?N():N:null,[N]);p.useEffect(()=>{const e=void 0!==v?"rtl"===v:ct.current&&"rtl"===getComputedStyle(ct.current).direction;et(!!e)},[v]),p.useEffect(()=>()=>{clearTimeout(gt.current)},[]),p.useEffect(()=>{if(!se||!mt.current)return;let e,t;const n=()=>{e=void 0;const n=mt.current;if(!n)return;const{scrollHeight:a,scrollTop:l,clientHeight:o}=n;!(a>o)||a-l-o<=100?(void 0!==t&&(clearTimeout(t),t=void 0),it(!1)):null!=t||(t=setTimeout(()=>{t=void 0,it(!0)},300))},a=()=>{void 0===e&&(e=requestAnimationFrame(n))},l=mt.current;l.addEventListener("scroll",a,{passive:!0});const o=new MutationObserver(a);return o.observe(l,{childList:!0,subtree:!0,characterData:!0}),()=>{l.removeEventListener("scroll",a),o.disconnect(),void 0!==e&&cancelAnimationFrame(e),void 0!==t&&clearTimeout(t)}},[se]);const qt=p.useMemo(()=>({replyToMessage:at,setReplyToMessage:lt,messages:vt,repliedToMessages:_e,user:ot,internalScrollContainerRef:ut,messageListScrollContainerRef:mt,onToolbarAction:Y,onContextMenuAction:X,onFileAction:Q,setShowCopyNotification:nt,onDownload:Z,onResendMessage:ze,fileActions:H,speechToTextConfig:te,uploadConfig:ae,statusTemplate:L,userStatusTemplate:P,messageFilesLayout:oe,timestampVisibility:W,onReferencedMessageClick:yt}),[at,lt,vt,_e,ot,Y,X,Q,nt,Z,ze,H,te,ae,L,P,oe,W,yt]);return p.createElement(J.Provider,{value:qt},p.createElement("div",{style:{width:u,height:m,position:"relative",overflow:"hidden",...C},onKeyDown:Bt,className:Dt(),ref:e=>{ct.current=e,ut.current=e,"function"==typeof t?t(e):t&&(t.current=e)},...Xe},void 0!==R&&p.createElement(Ie,null,Ot()),p.createElement("div",{className:"k-message-list",onBlur:Rt,onFocus:Mt,role:"log","aria-label":wt.toLanguageString(b,j[b]),"aria-live":"polite",ref:mt,style:{scrollBehavior:"auto"}},St&&p.createElement(Te,{message:St,onUnpin:$,user:ot,onReferencedMessageClick:yt}),p.createElement("div",{className:n.classNames("k-message-list-content",{"k-message-list-content-empty":0===kt.length})},0===kt.length&&void 0!==N&&zt(),kt.length>0&&Pt()),se&&(rt||!Ct)&&p.createElement("div",{className:"k-chat-scroll-to-bottom-container"},p.createElement(a.FloatingActionButton,{svgIcon:l.arrowDownOutlineIcon,size:"small",themeColor:"light",rounded:"full",onClick:bt,"aria-label":wt.toLanguageString(D,j[D]),title:wt.toLanguageString(D,j[D])}))),At&&p.createElement("div",{className:"k-separator"}),p.createElement(xe,{onSendMessage:(e,t)=>{d&&d({message:e,syntheticEvent:t,nativeEvent:t.nativeEvent,target:t.currentTarget})},onSuggestionClick:e=>{g&&g(e)},isDirectionRightToLeft:Ze,ref:dt,placeholder:y,MessageBox:k,suggestions:F,suggestionTemplate:S,inputValue:M,onInputValueChange:e=>{f&&f(e)},onInputClick:()=>{pt.current=!1},sendButtonConfig:le,suggestionsLayout:w,dir:v,messageBoxSettings:qe,loading:He}),p.createElement(Fe,{show:tt,text:wt.toLanguageString(I,j[I])}),Tt&&p.createElement(n.WatermarkOverlay,{message:Ft})))});Pe.displayName="Chat",Pe.propTypes={messages:r.arrayOf(r.object),user:r.object,messageTemplate:r.any,messageContentTemplate:r.any,attachmentTemplate:r.any,width:r.oneOfType([r.string,r.number]),style:r.object,onSendMessage:r.func,onActionExecute:r.func,dir:r.string,messageBox:r.any,noDataTemplate:r.oneOfType([r.element,r.func]),suggestionsLayout:r.oneOf(["scroll","wrap","scrollbuttons"]),quickActionsLayout:r.oneOf(["scroll","wrap","scrollbuttons"]),userStatusTemplate:r.elementType,messageFilesLayout:r.oneOf(["vertical","wrap","horizontal"]),showAvatar:r.bool,showUsername:r.bool,authorMessageSettings:r.object,receiverMessageSettings:r.object,scrollMode:r.oneOf(["scrollable","endless"]),total:r.number,pageSize:r.number,startIndex:r.number,endIndex:r.number,onLoadMoreMessages:r.func,pinnedMessages:r.arrayOf(r.object),repliedToMessages:r.arrayOf(r.object),onReferencedMessageClick:r.func};const Oe=e=>{const{activeView:t,toolbarItems:n,activeViewChange:l}=e;return p.createElement("div",{className:"k-prompt-header"},p.createElement(a.Toolbar,{keyboardNavigation:!1,role:"toolbar",className:"k-toolbar-flat"},n.map(e=>p.isValidElement(e)?e:p.createElement(a.Button,{key:e.name,className:t===e.name?"k-selected":"",size:"medium",themeColor:"primary",fillMode:"flat",rounded:"full",title:e.buttonText,svgIcon:e.buttonIcon,onClick:()=>(e=>{null==l||l.call(null,e)})(e.name)},e.buttonText))))},ze={name:"Output view",buttonText:"Output",buttonIcon:l.commentIcon},qe={name:"Commands view",buttonIcon:l.moreHorizontalIcon},He={name:"Prompt view",buttonText:"Ask AI",buttonIcon:l.sparklesIcon},$e=p.createContext([{},()=>{}]),Ue=()=>p.useContext($e),Ke=e=>{const{children:t}=e;return p.createElement("div",{className:"k-prompt-footer"},p.createElement("div",{className:"k-actions k-actions-start k-actions-horizontal k-prompt-actions"},t))},Ve=p.forwardRef((e,t)=>{const{children:n,streaming:o,onCancel:r}=e,i=s.useLocalization().toLanguageString(E,j[E]),[c]=Ue(),u=c.activeView===ze.name,m=o&&!u,d=p.useCallback(e=>{"Escape"===e.key&&o&&r&&(e.preventDefault(),r())},[o,r]);return p.createElement("div",{className:"k-prompt-content",ref:t,onKeyDown:d},m&&p.createElement(a.FloatingActionButton,{onClick:r,svgIcon:l.stopSmIcon,icon:"stop-sm",size:"medium",positionMode:"absolute",className:"k-prompt-stop-fab k-generating","aria-label":i,title:i}),p.createElement("div",{className:"k-prompt-view"},n))});Ve.displayName="KendoReactAIPromptContent";const je=e=>{const[t]=Ue();return t.activeView===e.name?e.children:null},We=e=>{const[t,n]=p.useState(!0),{children:o,title:s}=e;return p.createElement("div",{className:"k-prompt-expander"},p.createElement(a.Button,{"aria-controls":e.id,fillMode:"flat",svgIcon:t?l.chevronUpIcon:l.chevronDownIcon,title:s,onClick:()=>n(!t),"aria-expanded":t},s),t&&p.createElement("div",{id:e.id,className:"k-prompt-expander-content"},o))},Ge=e=>null==e?void 0:e.map(e=>p.createElement(o.PanelBarItem,{title:e.text,key:e.id,svgIcon:e.svgIcon,data:e},e.children&&Ge(e.children||[]))),_e=({show:e=!1,anchor:t,onOpen:n,onClose:a,animate:l=!0,appendTo:o,popupOptions:s={},children:r,style:i})=>p.createElement(d.Popup,{show:e,anchor:t,style:i,animate:l,appendTo:o,onOpen:n,onClose:a,...s},r),Ye=({placeholder:e="Ask or generate content with AI...",promptValue:t,onMenuClick:o,promptInput:s=m.TextArea,generateButton:r,enableSpeechToText:i=!1,streaming:c=!1,commands:u,onPromptRequest:d,onPromptCancel:g})=>{const[f,h]=p.useState(t||""),[v,k]=n.useCustomComponent(r),[b,y]=n.useCustomComponent(s),E=s===m.TextArea||b===m.TextArea,C={svgIcon:c?l.stopSmIcon:l.paperPlaneIcon,active:(!!c).toString(),title:"Send Button","aria-label":"Send Button",disabled:!f.trim()&&!c,"aria-disabled":!f.trim()&&!c},x={placeholder:e,className:"!k-flex-row",...E?{autoSize:!0}:{},rows:1},I=u&&u.length>0,T=Object.keys(k).length>0?k:C,F=Object.keys(y).length>0?y:x,S=e=>{const{isFinal:t,alternatives:n}=e;if(t&&n.length>0){const e=n[0].transcript,t=(()=>{const t=f,n=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(n?" ":"")+e})();h(t)}},w=()=>{f.trim()&&d&&d(f.trim())};return p.createElement(b,{value:f,onChange:e=>{const t=e.target.value;h(t)},onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&(e.preventDefault(),w())},prefix:I||i?p.createElement(p.Fragment,null,p.createElement(m.InputPrefix,{className:"!k-align-items-start"},I&&p.createElement(a.Button,{"aria-label":"Commands Button",title:"Commands Button",fillMode:"flat",svgIcon:l.menuIcon,onClick:o}),i&&p.createElement(a.SpeechToTextButton,{fillMode:"flat",..."object"==typeof i?{...i,onResult:i.onResult||S}:{onResult:S}})),p.createElement(m.InputSeparator,null)):void 0,suffix:p.createElement(m.InputSuffix,{className:"!k-align-items-start"},p.createElement(v,{className:n.classNames("k-prompt-send",{"k-generating":c,"k-active":c}),fillMode:"flat",onClick:c?g:w,...T})),...F})};e.AIPrompt=e=>{const t=!n.validatePackage(ke,{component:"AIPrompt"}),a=n.getLicenseMessage(ke),{activeView:l,toolbarItems:o,children:s,onActiveViewChange:r,onPromptRequest:i,onCommandExecute:c,style:u,dir:m,className:d,streaming:g,loading:f,onCancel:h,suggestionsView:v,...k}=e,b=o||[He,ze],[y,E]=p.useState({activeView:l}),C={...y,activeView:l,streaming:g,loading:f,suggestionsView:null!=v?v:"classic",onCancel:h,onActiveViewChange:r,onPromptRequest:i,onCommandExecute:c};return p.createElement($e.Provider,{value:[C,e=>{E(e)}]},p.createElement("div",{className:n.classNames("k-prompt",d),style:u,dir:m,...k},p.createElement(Oe,{activeView:C.activeView,toolbarItems:b,activeViewChange:r}),s,t&&p.createElement(n.WatermarkOverlay,{message:a})))},e.AIPromptCommandsView=e=>{const{commands:t}=e,[n]=Ue();return p.createElement(je,{name:qe.name},p.createElement(Ve,{streaming:n.streaming,onCancel:n.onCancel},p.createElement("div",{className:"k-prompt-view"},p.createElement(o.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:""},Ge(null!=t?t:[])))))},e.AIPromptContent=Ve,e.AIPromptFooter=Ke,e.AIPromptOutputView=e=>{const[t,n]=p.useState(""),r=p.useRef(null),[i]=Ue(),{outputs:c,showOutputRating:u,outputCard:m}=e,{header:d,body:g,actions:f}=m||{},h=s.useLocalization(),v=h.toLanguageString(E,j[E]),k=(e,t)=>{i.onPromptRequest&&i.onPromptRequest.call(null,e.prompt,{...e,ratingType:t,isRetry:!1}),b()},b=()=>{r&&r.current&&r.current.scrollTo({top:0,behavior:"smooth"})},C=p.createElement(o.Card,null,p.createElement(o.CardHeader,null,p.createElement(o.CardTitle,null,p.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}})),p.createElement(o.CardSubtitle,null,p.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),p.createElement(o.CardBody,null,p.createElement("span",{className:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}})),p.createElement(o.CardActions,null,i.streaming&&i.onCancel?p.createElement(a.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",svgIcon:l.stopSmIcon,title:v,onClick:i.onCancel},v):p.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),x=(e,o)=>f?f(e):o&&i.onCancel?p.createElement(a.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",svgIcon:l.stopSmIcon,title:v,onClick:i.onCancel},v):p.createElement(p.Fragment,null,p.createElement(a.Button,{size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:t===e.id?l.checkIcon:l.copyIcon,onClick:()=>(e=>{null!=e&&e.responseContent&&navigator.clipboard.writeText(e.responseContent),n(e.id),setTimeout(()=>{n("")},1e3)})(e)},"Copy"),p.createElement(a.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:l.arrowRotateCwIcon,onClick:()=>(e=>{i.onPromptRequest&&i.onPromptRequest.call(null,e.prompt,{...e,isRetry:!0}),b()})(e)},"Retry"),u&&p.createElement(p.Fragment,null,p.createElement("span",{className:"k-spacer"}),p.createElement(a.Button,{size:"medium",themeColor:"positive"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:l.thumbUpOutlineIcon,onClick:()=>k(e,"positive")}),p.createElement(a.Button,{size:"medium",themeColor:"negative"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:l.thumbDownOutlineIcon,onClick:()=>k(e,"negative")}))),I=null==c?void 0:c.map((e,t)=>{const n=!(!i.streaming||i.loading||0!==t);return p.createElement(o.Card,{key:`${e.id}_${t}`},p.createElement(o.CardHeader,null,d?d(e):p.createElement(p.Fragment,null,e.title&&p.createElement(o.CardTitle,null,e.title),e.subTitle&&p.createElement(o.CardSubtitle,null,e.subTitle))),p.createElement(o.CardBody,null,g?g(e):e.responseContent),p.createElement(o.CardActions,null,x(e,n)))}),T=p.createElement(o.Card,null,p.createElement(o.CardBody,null,h.toLanguageString(y,j[y])));return p.createElement(je,{name:ze.name},p.createElement(Ve,{ref:r,streaming:i.streaming,onCancel:i.onCancel},p.createElement("div",{className:"k-card-list"},i.loading&&C,I,(!I||0===I.length)&&!i.loading&&T)))},e.AIPromptView=e=>{const{promptInput:t=m.TextArea,generateButton:o=a.Button,enableSpeechToText:s=!1,promptValue:r,promptSuggestions:i}=e,[c,u]=p.useState(r||""),[d]=Ue(),[g,f]=n.useCustomComponent(o),[h,v]=n.useCustomComponent(t),k=p.useRef(null);p.useEffect(()=>{var e,t;null!=(t=null==(e=k.current)?void 0:e.element)&&t.current&&requestAnimationFrame(()=>{var e,t;if(null!=(t=null==(e=k.current)?void 0:e.element)&&t.current){const e=k.current.element.current;e.style.height="auto",e.style.height=`${e.scrollHeight}px`}})},[c]);const b={title:"Generate",children:"Generate",svgIcon:l.sparklesIcon},y=Object.keys(f).length>0?f:b,E=Object.keys(v).length>0?v:{placeholder:"Ask or generate content with AI ...",rows:2},C=e=>{const{isFinal:t,alternatives:n}=e;if(t&&n.length>0){const e=n[0].transcript,t=(()=>{const t=c,n=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(n?" ":"")+e})();u(t)}};let x;return s&&(x="object"==typeof s?{...s,onResult:s.onResult||C}:{onResult:C}),p.createElement(je,{name:He.name},p.createElement(Ve,{streaming:d.streaming,onCancel:d.onCancel},p.createElement(h,{ref:k,value:c,flow:"vertical",textareaStyle:{maxHeight:"110px"},autoSize:!0,suffix:s?p.createElement(p.Fragment,null,p.createElement(m.InputSeparator,{orientation:"horizontal"}),p.createElement(m.InputSuffix,{orientation:"horizontal"},p.createElement(a.SpeechToTextButton,{fillMode:"flat",...x}))):void 0,onChange:e=>{u(e.target.value)},...E}),i&&i.length>0&&p.createElement(We,{title:"Prompt Suggestions"},p.createElement(de,{suggestionsView:d.suggestionsView,suggestions:i.map((e,t)=>({id:t,text:e,description:e})),onSuggestionClick:e=>{(e=>{u(e)})(e.text)}}))),p.createElement(Ke,null,p.createElement(g,{themeColor:"primary",fillMode:"solid",rounded:"full",size:"medium",onClick:()=>{d.onPromptRequest&&d.onPromptRequest.call(null,c),u("")},disabled:!c.trim(),...y},y.children)))},e.AIPromptViewRender=je,e.Chat=Pe,e.ChatMessage=ee,e.DEFAULT_FIELD_MAPPING=Se,e.HeroCard=e=>{const{imageUrl:t,imageMaxWidth:n,title:l,subtitle:o,actions:s,onActionExecute:r,altText:i}=e,c=p.useCallback((e,t)=>{null==r||r({action:e,syntheticEvent:t,nativeEvent:t.nativeEvent,target:t.currentTarget})},[r]),u=i||l||"";return p.createElement("div",{className:"k-card"},p.createElement("img",{className:"k-card-image",src:t,style:{maxWidth:n},alt:u}),p.createElement("div",{className:"k-card-body"},l&&p.createElement("h5",{className:"k-card-title"},l),o&&p.createElement("h6",{className:"k-card-subtitle"},o)),p.createElement("div",{className:"k-card-actions k-card-actions-vertical"},s.map((e,t)=>p.createElement("span",{className:"k-card-action",key:`action-${t}-${e.title||e.value||t}`},p.createElement(a.Button,{fillMode:"flat",onClick:t=>c(e,t)},e.title)))))},e.InlineAIPrompt=e=>{const t=!n.validatePackage(ke,{component:"InlineAIPrompt"}),s=n.getLicenseMessage(ke),{outputs:r=[],outputCard:i,promptInput:c=m.TextArea,generateButton:u=a.Button,promptPlaceholder:d="Ask or generate content with AI...",promptValue:g,onPromptRequest:f,onCopy:h,onDiscard:v,outputActions:k,onOutputAction:b,enableSpeechToText:y=!1,streaming:E,onPromptCancel:C,show:x=!1,anchor:I,width:T,height:F,onOpen:S,onClose:w,animate:A=!0,appendTo:M,commands:R,onCommandExecute:N,style:B,className:L,popupOptions:D={},...P}=e,[O,z]=p.useState(""),[q,H]=p.useState(!1),[$,U]=p.useState({left:0,top:0}),K=p.useRef(null),{body:V,actions:j}=i||{},W=k||[{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),z(e.id),setTimeout(()=>z(""),1e3)),null==h||h(e)})(t);break;case"discard":(e=>{null==v||v(e)})(t);break;default:null==b||b(e,t)}},_=p.useCallback(e=>{"Escape"===e.key&&(E&&C?C():!E&&w&&w({target:null}))},[E,C,w]),Y={...B,...T&&{width:T},...F&&{height:F}},X={...T&&{width:T},...F&&{height:F}},J=p.createElement(p.Fragment,null,p.createElement("div",{className:n.classNames("k-prompt",L),style:Y,onKeyDown:_,...P},p.createElement(Ve,{ref:K},r&&r.length>0&&p.createElement("div",{className:"k-card-list"},r.map((e,t)=>p.createElement(o.Card,{key:`${e.id}_${t}`},p.createElement(o.CardBody,null,V?V(e):e.responseContent),p.createElement(o.CardActions,null,j?j(e):p.createElement(p.Fragment,null,W.map(t=>{var n;return t.spacer?p.createElement("span",{key:t.id,className:"k-spacer"}):p.createElement(a.Button,{key:t.id,size:"medium",themeColor:t.themeColor||"primary",fillMode:"flat",rounded:"medium",title:null!=(n=t.title)?n:t.text,svgIcon:"copy"===t.id&&O===e.id?l.checkIcon:t.svgIcon,onClick:()=>G(t,e)},t.text)})))))),p.createElement(Ye,{promptValue:g,placeholder:d,onPromptRequest:f,onMenuClick:e=>{if(!K.current)return;const t=K.current.getBoundingClientRect();U({left:t.left,top:t.bottom}),H(!0)},onPromptCancel:C,promptInput:c,generateButton:u,enableSpeechToText:y,streaming:E,commands:R}))),t&&p.createElement(n.WatermarkOverlay,{message:s}));return p.createElement(p.Fragment,null,p.createElement(_e,{show:x,anchor:I,onOpen:S,onClose:w,animate:A,appendTo:M,popupOptions:D,style:X},J),p.createElement(o.ContextMenu,{show:q,offset:$,onClose:()=>{H(!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})))(R),onSelect:e=>{var t,n;const a=null==(t=e.item)?void 0:t.data;a&&(null==(n=a.children)||!n.length)&&(e=>{H(!1),N&&N(e)})(a)}}))},e.PromptBox=Ee,e.PromptBoxActionButton=pe,e.PromptBoxSpeechToTextButton=fe,e.PromptBoxUploadButton=ge,e.PromptHeader=Oe,e.SuggestionGroup=de,e.commandsViewDefaults=qe,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,isFailedField:e.isFailedField}),e.isStandardMessageFormat=Me,e.mapDataArrayToMessages=Ae,e.mapDataToMessage=we,e.mapMessageToCustomFormat=(e,t={})=>{const n={...Se,...t},a={};return void 0!==e.id&&(a[n.idField]=e.id),void 0!==e.text&&(a[n.textField]=e.text),void 0!==e.status&&(a[n.statusField]=e.status),void 0!==e.isFailed&&(a[n.isFailedField]=e.isFailed),void 0!==e.timestamp&&(a[n.timestampField]=e.timestamp),void 0!==e.attachments&&(a[n.attachmentsField]=e.attachments),void 0!==e.files&&(a[n.filesField]=e.files),void 0!==e.suggestedActions&&(a[n.suggestedActionsField]=e.suggestedActions),void 0!==e.replyToId&&(a[n.replyToIdField]=e.replyToId),void 0!==e.isDeleted&&(a[n.isDeletedField]=e.isDeleted),void 0!==e.isPinned&&(a[n.isPinnedField]=e.isPinned),void 0!==e.typing&&(a[n.typingField]=e.typing),e.author&&(void 0!==e.author.id&&(a[n.authorIdField]=e.author.id),void 0!==e.author.name&&(a[n.authorNameField]=e.author.name),void 0!==e.author.avatarUrl&&(a[n.authorImageUrlField]=e.author.avatarUrl),void 0!==e.author.avatarAltText&&(a[n.authorImageAltTextField]=e.author.avatarAltText)),void 0!==e.pinnedAt&&(a.pinnedAt=e.pinnedAt),void 0!==e.pinnedBy&&(a.pinnedBy=e.pinnedBy),void 0!==e.attachmentLayout&&(a.attachmentLayout=e.attachmentLayout),a},e.outputViewDefaults=ze,e.promptViewDefaults=He});
|
|
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-layout"),require("@progress/kendo-react-intl"),require("prop-types"),require("@progress/kendo-react-upload"),require("@progress/kendo-react-animation"),require("@progress/kendo-react-notification"),require("@progress/kendo-react-inputs"),require("@progress/kendo-react-popup")):"function"==typeof define&&define.amd?define(["exports","react","@progress/kendo-react-common","@progress/kendo-react-buttons","@progress/kendo-svg-icons","@progress/kendo-react-layout","@progress/kendo-react-intl","prop-types","@progress/kendo-react-upload","@progress/kendo-react-animation","@progress/kendo-react-notification","@progress/kendo-react-inputs","@progress/kendo-react-popup"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoReactConversationalUi={},e.React,e.KendoReactCommon,e.KendoReactButtons,e.KendoSvgIcons,e.KendoReactLayout,e.KendoReactIntl,e.PropTypes,e.KendoReactUpload,e.KendoReactAnimation,e.KendoReactNotification,e.KendoReactInputs,e.KendoReactPopup)}(this,function(e,t,n,a,l,s,o,r,i,c,u,m,d){"use strict";function g(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var p=g(t);const f="newMessage.sendButton",h="newMessage.optionsButton",v="newMessage.messageInput",k="avatar.alt",b="messageList.ariaLabel",y="aIPrompt.noOutputs",E="aIPrompt.cancel",C="chat.senderDeletedMessage",x="chat.receiverDeletedMessage",I="chat.copyNotification",T="chat.downloadAllFiles",F="chat.closeReply",w="chat.collapseMessage",S="chat.expandMessage",A="chat.removeFile",M="chat.fileActions",R="chat.attachFile",N="chat.downloadAll",B="chat.scrollLeft",L="chat.scrollRight",D="chat.scrollToBottom",P="chat.messageFailed",z="chat.retryMessage",O="chat.stopGenerating",q="promptBox.input",H="promptBox.sendButton",$="promptBox.attachFile",U="promptBox.removeFile",K="promptBox.stopGenerating",V="promptBox.ariaLabel",W="chat.messageToolbar",j={[f]:"Send",[h]:"Options",[v]:"Message",[k]:"Avatar",[b]:"Message list",[E]:"Cancel",[y]:"No output from AI available",[C]:"You removed this message",[x]:"The message was removed by its sender",[I]:"Text copied to clipboard",[T]:"Download all files",[F]:"Close reply",[w]:"Collapse message",[S]:"Expand message",[A]:"Remove file",[M]:"File actions for",[P]:"Failed to send",[z]:"Retry",[O]:"Stop generating",[R]:"Attach file",[N]:"Download all",[B]:"Scroll left",[L]:"Scroll right",[D]:"Scroll to bottom",[q]:"Prompt",[H]:"Send",[$]:"Attach file",[U]:"Remove file",[K]:"Stop generating",[V]:"Prompt box",[W]:"Toolbar"},G=(e,t)=>e&&t.author&&e.id===t.author.id,_=(e,t)=>{const n=t.toLanguageString("chatSender.deletedMessage",j[C]),a=t.toLanguageString("chatReceiver.deletedMessage",j[x]);return e?n:a},Y=(e,t)=>e.find(e=>e.id===t),X=/(https?:\/\/[^\s]+)/g,J=e=>{if(!e)return[""];const t=e.split(X),n=[];return t.forEach(e=>{e&&X.test(e)?(X.lastIndex=0,n.push(p.createElement("a",{key:e,href:e,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"}},e))):e&&n.push(e)}),n},Q=p.createContext(void 0),Z=()=>{const e=t.useContext(Q);if(void 0===e)throw new Error("useChatContext must be used within a ChatContext.Provider");return e},ee=e=>{const{files:t,onFileAction:s,onDownload:r,fileActions:i}=e,{messageFilesLayout:c="vertical"}=Z(),u=o.useLocalization(),m=i||[{id:"download",label:"Download",svgIcon:l.downloadIcon}],d=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]}`},g=e=>"."+e.split(".").pop()||"",f=e=>m.length>0&&p.createElement(a.DropDownButton,{fillMode:"flat",size:"small",svgIcon:l.moreVerticalIcon,onClick:e=>{e.syntheticEvent.stopPropagation()},onItemClick:t=>((e,t)=>{var n,a;null==(a=null==(n=e.syntheticEvent)?void 0:n.stopPropagation)||a.call(n),"download"===e.item.id&&(null==r||r([t])),null==s||s(e.item,e,t)})(t,e),items:m.map(e=>({id:e.id,icon:e.icon,text:e.label,svgIcon:e.svgIcon})),"aria-label":`${u.toLanguageString(M,j[M])} ${e.name}`,title:`${u.toLanguageString(M,j[M])} ${e.name}`}),h=p.useCallback(()=>n.classNames({"k-files-wrap":"wrap"===c,"k-files-vertical":"vertical"===c},"k-file-box-wrapper"),[c]);return p.createElement("ul",{className:h()},"horizontal"===c?p.createElement("div",{className:"k-files-scroll"},t.map(e=>p.createElement("li",{key:e.name,className:"k-file-box"},p.createElement(n.IconWrap,{size:"xlarge",...n.getFileExtensionIcon(g(e.name))}),p.createElement("div",{className:"k-file-info"},p.createElement("span",{className:"k-file-name"},e.name),p.createElement("span",{className:"k-file-size"},d(e.size))),f(e)))):t.map(e=>p.createElement("li",{key:e.name,className:"k-file-box"},p.createElement(n.IconWrap,{size:"xlarge",...n.getFileExtensionIcon(g(e.name))}),p.createElement("div",{className:"k-file-info"},p.createElement("span",{className:"k-file-name"},e.name),p.createElement("span",{className:"k-file-size"},d(e.size))),f(e))))},te=p.forwardRef((e,t)=>{const{item:r,template:i,contentTemplate:c,onRequestSelection:u,tabIndex:m=-1,dateFormat:d="g",selected:g,allowMessageCollapse:f,messageToolbarActions:h,messageContextMenuActions:v,fileActions:k,isSender:b}=e,{setReplyToMessage:y,messages:E,repliedToMessages:C,user:x,onToolbarAction:I,onContextMenuAction:F,onFileAction:A,onDownload:M,onResendMessage:R,setShowCopyNotification:B,statusTemplate:L,timestampVisibility:D="onFocus",onReferencedMessageClick:O}=Z(),[q,H]=p.useState(!1),[$,U]=p.useState(!1),[K,V]=p.useState(!0),[X,Q]=p.useState(!1),te=o.useLocalization(),ne=o.useInternationalization(),ae=p.useRef({left:0,top:0}),le=p.useCallback(()=>{null!=r&&r.text&&(e=>{navigator.clipboard.writeText(e)})(r.text),B&&(B(!0),setTimeout(()=>{B(!1)},3e3))},[r,B]),se=p.useCallback(e=>{e.stopPropagation(),V(e=>!e)},[]),oe=p.useCallback(()=>{Q(!1)},[]),re=p.useCallback(e=>{("Tab"===e.key||"Enter"===e.key||" "===e.key||"ArrowUp"===e.key||"ArrowDown"===e.key)&&Q(!0)},[]),ie=p.useRef(null);p.useEffect(()=>{g&&ie.current&&ie.current.focus()},[g]);const ce=p.useCallback(e=>{ae.current={left:e.pageX,top:e.pageY},e.preventDefault(),U(!0),H(!0)},[]),ue=p.useCallback(()=>{U(!1),H(!1)},[]),me=p.useCallback((e,t)=>e.isDeleted?_(t,te):e.text?e.text:"",[te]),de=p.useCallback(e=>{var t;null!=(t=e.item)&&t.text&&("copy"!==e.item.data.id||r.isDeleted?"reply"===e.item.data.id&&y(r):le(),F&&F(e.item.data,e,r)),U(!1),H(!1)},[r,F,y,le]),ge=p.useCallback(()=>{if(r.replyToId){const e=Y(E,r.replyToId)||(C?Y(C,r.replyToId):void 0);if(e){const t=t=>{t.preventDefault(),t.stopPropagation(),null==O||O(e.id)};return p.createElement("div",{className:n.classNames("k-message-reference",G(x,e)?"k-message-reference-sender":"k-message-reference-receiver"),onClick:t},p.createElement("div",{className:"k-message-reference-content"},J(me(e,G(x,e)))))}}return null},[r.replyToId,E,C,x,me,O]),pe=p.useCallback(()=>{const e=[{id:"reply",label:"Reply",svgIcon:l.undoIcon},{id:"copy",label:"Copy",svgIcon:l.copyIcon}],t=v?[...e.map(e=>v.find(t=>t.id===e.id)||e),...v.filter(t=>!e.some(e=>e.id===t.id))]:e;return p.createElement(s.ContextMenu,{onSelect:de,onClose:ue,vertical:!0,show:q,offset:ae.current},t.map(e=>"delete"!==e.id||b?p.createElement(s.MenuItem,{key:e.id,text:e.label,icon:e.icon,svgIcon:e.svgIcon,data:e}):null))},[v,de,ue,q,b]),fe=p.useCallback(()=>r.files&&r.files.length>1?p.createElement("div",{className:"k-chat-download-button-wrapper"},p.createElement(a.Button,{className:"k-chat-download-button",fillMode:"flat",svgIcon:l.downloadIcon,size:"small",onClick:e=>{e.stopPropagation(),M&&M(r.files,r)},"aria-label":te.toLanguageString(T,j[T])},p.createElement("span",{className:"k-button-text"},te.toLanguageString(N,j[N])))):null,[r,M,te]),he=p.useCallback(()=>{if(r.typing)return p.createElement("div",{className:"k-chat-bubble k-bubble"},p.createElement("div",{className:"k-bubble-content"},p.createElement("div",{className:"k-typing-indicator"},p.createElement("span",null),p.createElement("span",null),p.createElement("span",null))));if(i){const e=i;return p.createElement(p.Fragment,null,p.createElement(e,{item:r}),pe())}return r.text||r.files&&r.files.length>0?p.createElement(p.Fragment,null,p.createElement("div",{className:n.classNames("k-chat-bubble","k-bubble",{"k-bubble-expandable":f,"k-expanded":f&&K,"k-selected":g,"k-active":$}),onClick:()=>u(g?void 0:r.selectionIndex),onContextMenu:ce},p.createElement("div",{className:"k-bubble-content"},c?p.createElement(c,{item:r}):p.createElement(p.Fragment,null,(r.text||r.isDeleted||r.replyToId)&&p.createElement("span",{className:"k-chat-bubble-text"},!r.isDeleted&&ge(),J(me(r,G(x,r)))),r.files&&r.files.length>0&&p.createElement(ee,{files:r.files,message:r,onFileAction:A,onDownload:e=>null==M?void 0:M(e,r),renderInTextarea:!1,fileActions:k}),fe())),f&&p.createElement("span",{className:"k-bubble-expandable-indicator",onClick:se,role:"button","aria-label":K?te.toLanguageString(w,j[w]):te.toLanguageString(S,j[S]),tabIndex:0,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),se(e))}},p.createElement(n.IconWrap,{icon:K?l.chevronUpIcon:l.chevronDownIcon,size:"medium"}))),pe()):null},[r,i,c,f,K,g,$,u,ce,ge,me,x,A,k,fe,se,te,pe,M]),ve=p.useCallback(()=>{let e=null;return r.timestamp&&("hidden"===D||(e=p.createElement("time",{className:"k-message-time"},ne.formatDate(r.timestamp,d)))),e},[r.timestamp,d,D,ne]),ke=p.useCallback(()=>{if(!r.status)return null;let e;if(L)e=p.createElement(L,{item:r});else{let t,a,l;if("object"==typeof r.status&&null!==r.status){const e=r.status;t=e.text,a=e.icon,l=e.svgIcon}else t=r.status;let s=null;a?s=p.createElement(n.Icon,{name:a,size:"xsmall"}):l&&(s=p.createElement(n.IconWrap,{icon:l,size:"xsmall"})),e=p.createElement(p.Fragment,null,s,t)}return p.createElement("span",{className:"k-message-status"},e)},[r,L]),be=p.useCallback(()=>{let e=null;if(r.isFailed){const t=te.toLanguageString(P,j[P]);e=p.createElement("span",{className:"k-message-failed-content"},p.createElement(n.IconWrap,{icon:l.warningTriangleIcon,size:"xsmall"}),p.createElement("span",{className:"k-message-failed-text"},t))}return e},[r,te]),ye=p.useCallback(()=>{let e=null;if(r.isFailed){const t=te.toLanguageString(z,j[z]);e=p.createElement(a.Button,{fillMode:"clear",size:"xs",className:"k-resend-button",svgIcon:l.arrowRotateCwIcon,"aria-label":t,title:t,onClick:e=>{e.stopPropagation(),R&&R({message:r,syntheticEvent:e,nativeEvent:e.nativeEvent,target:e.target})}})}return e},[r,te,R]),Ee=p.useCallback(()=>n.classNames({"k-focus":g,"k-message-removed":r.isDeleted,"k-message-failed":r.isFailed},"k-message"),[g,r.isDeleted,r.isFailed]),Ce=p.useCallback(()=>h&&h.length>0&&p.createElement(a.Toolbar,{className:"k-chat-message-toolbar",fillMode:"flat",ariaLabel:te.toLanguageString(W,j[W])},h.map(e=>"delete"!==e.id||b?p.createElement(a.Button,{key:e.id,fillMode:"flat",className:"k-toolbar-button",icon:e.icon,svgIcon:e.svgIcon,"aria-label":e.label,onClick:t=>{t.stopPropagation(),"copy"!==e.id||r.isDeleted?"reply"===e.id&&y(r):le(),I&&I(e,t,r)},onMouseDown:e=>e.preventDefault()}):null)),[le,b,r,te,h,I,y]);return p.createElement("div",{key:r.id,"data-message-id":r.id,className:Ee(),tabIndex:m,onMouseDown:oe,onKeyDown:re,onFocus:e=>{X&&u(r.selectionIndex)},ref:e=>{ie.current=e,"function"==typeof t?t(e):t&&(t.current=e)},onContextMenu:i?ce:void 0},ye(),he(),(r.status||r.timestamp&&"hidden"!==D||r.isFailed)&&p.createElement("div",{className:"k-message-info"},ke(),ve(),be()),Ce())});te.displayName="ChatMessage";const ne=e=>e[e.length-1],ae=e=>(t,n,a)=>{const l=a===e-1;return((e,t)=>{const n=t.timestamp,a=ne(e);if(n&&(!a||((e,t)=>e&&t&&(t.getDate()!==e.getDate()||t.getMonth()!==e.getMonth()||t.getFullYear()!==e.getFullYear()))(n,a.timestamp))){const t={type:"date-marker",timestamp:n,trackBy:n.getTime()};e.push(t)}})(t,n),((e,t,n)=>{const a=ne(e);let l;t.typing&&!n||(a&&"message-group"===a.type&&(l=a.messages),l&&G(t.author,ne(l))?l.push(t):e.push({type:"message-group",messages:[t],author:t.author,timestamp:t.timestamp,trackBy:t}))})(t,n,l),n.attachments&&n.attachments.length>1&&t.push({type:"attachment-group",attachments:n.attachments,attachmentLayout:n.attachmentLayout,timestamp:n.timestamp,trackBy:n}),n.suggestedActions&&l&&t.push({type:"action-group",actions:n.suggestedActions,timestamp:n.timestamp,trackBy:n}),t};const le=e=>{const{item:t,onActionExecute:a,selected:l}=e,s=p.useRef(null);p.useEffect(()=>{l&&s.current&&s.current.focus()},[l]);const o=p.useCallback(e=>{(e.keyCode===n.Keys.enter||" "===e.key)&&(e.preventDefault(),a(t,e))},[a,t]),r=p.useCallback(()=>n.classNames("k-suggestion k-suggestion-primary",{"k-selected":l},{"k-focus":l}),[l]);return p.createElement("span",{role:"button",className:r(),onClick:e=>a(t,e),ref:s,onKeyDown:o,tabIndex:0,"aria-label":t.title||t.value},t.title||t.value)},se=({visible:e,dir:t,canScrollLeft:n,canScrollRight:s,onScrollLeft:r,onScrollRight:i,children:c})=>{const u=o.useLocalization();if(!e)return c;const m=u.toLanguageString(B,j[B]),d=u.toLanguageString(L,j[L]),g="rtl"!==t?m:d,f="rtl"!==t?d:m;return p.createElement("div",{className:"k-suggestion-scrollwrap"},p.createElement(a.Button,{fillMode:"flat",size:"small",svgIcon:"rtl"===t?l.chevronRightIcon:l.chevronLeftIcon,onClick:r,disabled:!n,"aria-label":g,title:g}),c,p.createElement(a.Button,{fillMode:"flat",size:"small",svgIcon:"rtl"===t?l.chevronLeftIcon:l.chevronRightIcon,onClick:i,disabled:!s,"aria-label":f,title:f}))},oe=100,re=(e,t)=>{const{enabled:n,dir:a,mode:l,itemsDependency:s=[],scrollSpeed:o=oe}=t,[r,i]=p.useState(!1),[c,u]=p.useState(!1),m=p.useCallback(()=>{if(e.current&&n){const{scrollLeft:t,scrollWidth:n,clientWidth:l}=e.current,s="rtl"!==a?t+l>=n-1:l-t>=n-1;i(!(0===t)),u(!s)}},[n,a]),d=p.useCallback(()=>{e.current&&n&&e.current.scrollBy({left:"rtl"!==a?-o:o,behavior:"smooth"})},[n,a,o]),g=p.useCallback(()=>{e.current&&n&&e.current.scrollBy({left:"rtl"!==a?o:-o,behavior:"smooth"})},[n,a,o]);return p.useEffect(()=>{const t=e.current;if(!t||!n)return;m();const a=()=>m();t.addEventListener("scroll",a,{passive:!0});const l=new ResizeObserver(m);return l.observe(t),()=>{t.removeEventListener("scroll",a),l.disconnect()}},[n,m,s.length,l]),p.useLayoutEffect(()=>{n&&m()},[n,a,s]),{canScrollLeft:r,canScrollRight:c,scrollLeft:d,scrollRight:g}},ie=e=>{var t,a;const{group:l,onActionExecute:s,selected:o,onRequestSelection:r,quickActionsLayout:i="scroll",dir:c}=e,[u,m]=p.useState(null),d=p.useRef(null),{canScrollLeft:g,canScrollRight:f,scrollLeft:h,scrollRight:v}=re(d,{enabled:"scrollbuttons"===i||"scroll"===i,dir:c,mode:i,itemsDependency:l.actions});p.useEffect(()=>{o||null===u?o&&null===u&&m(0):m(null)},[o,u]);const k=p.useCallback(()=>l.actions?l.actions.length-1:-1,[l.actions]),b=p.useCallback((e,t=0)=>{let n=null;return e?null===u?n=t:u<k()&&(n=u+1):null===u?n=0:u>0&&(n=u-1),null!==n&&m(n),n},[u,k]),y=p.useCallback(()=>{r(l.selectionIndex)},[r,l.selectionIndex]),E=p.useCallback(e=>{let t=null;const a=n.Keys.left,l=n.Keys.right;e.keyCode===a?t=b(!1):e.keyCode===l&&(t=b(!0)),null!==t&&(e.preventDefault(),e.stopPropagation())},[b]),C=p.useCallback(()=>n.classNames("k-suggestion-group",{"k-suggestion-group-scrollable":"scroll"===i,"k-suggestion-group-scrollable-start":f&&("scroll"===i||"scrollbuttons"===i),"k-suggestion-group-scrollable-end":g&&("scroll"===i||"scrollbuttons"===i)}),[i,f,g]),x="scroll"===i||"scrollbuttons"===i,I=p.createElement("div",{className:C(),onClick:y,onKeyDown:E,role:"toolbar",tabIndex:0,"aria-label":"Action group"},x?p.createElement("div",{className:"k-suggestions-scroll",ref:d},null==(t=l.actions)?void 0:t.map((e,t)=>p.createElement(le,{item:e,onActionExecute:s,selected:t===u,key:e.value}))):null==(a=l.actions)?void 0:a.map((e,t)=>p.createElement(le,{item:e,onActionExecute:s,selected:t===u,key:e.value})));return p.createElement(se,{visible:"scrollbuttons"===i,dir:c,canScrollLeft:g,canScrollRight:f,onScrollLeft:h,onScrollRight:v},I)},ce=e=>{const{item:t,template:a,tabbable:l,onClick:s,selected:o}=e,r=p.useRef(null);p.useEffect(()=>{o&&r.current&&r.current.focus()},[o]);const i=p.useCallback(()=>{if(void 0!==l)return l?0:-1},[l]),c=p.useCallback(()=>n.classNames({"k-selected":o},{"k-focus":o}),[o]),u=p.useCallback(()=>t.title?p.createElement("h5",{className:"k-card-title"},t.title):null,[t.title]),m=p.useCallback(()=>t.subtitle?p.createElement("h6",{className:"k-card-subtitle"},t.subtitle):null,[t.subtitle]),d=p.useCallback(()=>0===t.contentType.indexOf("image/")?p.createElement("img",{src:t.content,alt:t.title||"Attachment",style:{maxHeight:"200px",height:"auto",maxWidth:"200px",width:"auto"}}):t.content,[t.contentType,t.content,t.title]),g=a;return p.createElement("div",{className:c(),tabIndex:i(),onClick:s,ref:r},a?p.createElement(g,{item:t}):p.createElement("div",{className:"k-card"},p.createElement("div",{className:"k-card-body"},u(),m(),d())))},ue=e=>{const{group:t,itemTemplate:s,selected:o,isLastGroup:r,onRequestSelection:i}=e,[c,u]=p.useState(null);p.useEffect(()=>{o||null===c?o&&null===c&&u(0):u(null)},[o,c]);const m=p.useCallback(e=>"list"!==e.attachmentLayout,[]),d=p.useCallback(()=>t.attachments?t.attachments.length-1:-1,[t.attachments]),g=p.useCallback(()=>t.attachments.length-1,[t.attachments]),f=p.useCallback((e,t=0)=>{let n=null;return e?null===c?n=t:c<d()&&(n=c+1):null===c?n=0:c>0&&(n=c-1),null!==n&&u(n),n},[c,d]),h=p.useCallback(()=>{i(t.selectionIndex)},[i,t.selectionIndex]),v=p.useCallback(e=>{let a,l,s=null;m(t)?(a=n.Keys.left,l=n.Keys.right):(a=n.Keys.up,l=n.Keys.down),e.keyCode===a?s=f(!1):e.keyCode===l&&(s=f(!0)),null!==s&&(e.preventDefault(),e.stopPropagation())},[f,m,t]),k=p.useCallback(e=>{h(),u(e)},[h]),b=p.useCallback(e=>{h(),f(e,1)},[h,f]),y=p.useCallback(()=>{let e=null;return m(t)&&c&&(e=p.createElement(a.Button,{icon:"chevron-left",onClick:()=>b(!1),svgIcon:l.chevronLeftIcon})),e},[m,t,c,b]),E=p.useCallback(()=>{let e=null;return m(t)&&c!==g()&&(e=p.createElement(a.Button,{icon:"chevron-right",onClick:()=>b(!0),svgIcon:l.chevronRightIcon})),e},[m,t,c,g,b]),C=p.useCallback(()=>n.classNames({"k-card-list":t.attachmentLayout,"k-card-deck":m(t)}),[t.attachmentLayout,t,m]),x=m(t),I=p.createElement("div",{className:C(),onKeyDown:x?void 0:v},t.attachments.map((e,t)=>p.createElement(ce,{item:e,template:s,selected:t===c,tabbable:r&&t===c,onClick:()=>k(t),key:e.content})));return x?p.createElement("div",{className:"k-card-deck-scrollwrap",onKeyDown:v},y(),I,E()):I},me=({item:e,timestampTemplate:t})=>{const n=o.useInternationalization(),a=t;return p.createElement("div",{className:"k-timestamp"},a?p.createElement(a,{item:e}):n.formatDate(e.timestamp,"D"))},de=e=>{const{group:t,user:a,itemTemplate:l,contentTemplate:r,attachmentTemplate:i,onRequestSelection:c,selectedItemIndex:u,isLastGroup:m,message:d,allowMessageCollapse:g,messageToolbarActions:f,messageContextMenuActions:h,fileActions:v,messageWidthMode:b="standard",showAvatar:y=!0,showUsername:E=!0}=e,{userStatusTemplate:C}=Z(),x=o.useLocalization(),I=t.messages.length>0&&G(a,t.messages[0]),{avatarUrl:T,avatarAltText:F,name:w}=t.author,S=p.useMemo(()=>n.classNames("k-message-group",{"k-message-group-sender":I,"k-message-group-receiver":!I,"k-message-group-full-width":"full"===b,"k-no-avatar":!y||!T}),[I,b,y,T]),A=p.useMemo(()=>{const e=t.messages.length-1;return t.messages.map((t,n)=>{const s=[p.createElement(d,{item:t,template:l,contentTemplate:r,selected:t.selectionIndex===u,onRequestSelection:c,tabIndex:n===e&&m?0:-1,key:t.id,allowMessageCollapse:g,messageToolbarActions:f,messageContextMenuActions:h,fileActions:v,isSender:G(a,t)})];return t.attachments&&1===t.attachments.length&&s.push(p.createElement(ce,{item:t.attachments[0],template:i,selected:!1,key:`att-${t.attachments[0].content}`})),s})},[t.messages,d,l,r,u,c,m,g,f,h,v,a,i]),M=void 0!==F?F:x.toLanguageString(k,j[k]);return p.createElement("div",{className:S},(()=>{if(!y||!T)return;const e=p.createElement(s.Avatar,{type:"image"},p.createElement("img",{src:T,alt:M}));if(C){const n=t.messages[t.messages.length-1];return p.createElement("div",{className:"k-chat-user-status-wrapper"},e,p.createElement("div",{className:"k-chat-user-status"},p.createElement(C,{message:"dataItem"in n?n.dataItem:n})))}return e})(),p.createElement("div",{className:"k-message-group-content"},E&&p.createElement("span",{className:"k-message-author"},w),A))},ge=e=>{const{suggestions:t,onSuggestionClick:a,suggestionsView:l,suggestionTemplate:s,suggestionsLayout:o,dir:r}=e,i=p.useRef(null),{canScrollLeft:c,canScrollRight:u,scrollLeft:m,scrollRight:d}=re(i,{enabled:"scrollbuttons"===o||"scroll"===o,dir:r,mode:o,itemsDependency:t}),g=p.useCallback((e,t)=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),null==a||a(t))},[a]),f=p.useCallback(()=>t.map(e=>s?p.createElement(s,{key:e.id,suggestion:e,onClick:()=>{null==a||a(e)}}):p.createElement("span",{role:"button",tabIndex:e.disabled?-1:0,"aria-label":e.description,"aria-disabled":e.disabled,onClick:()=>!e.disabled&&(null==a?void 0:a(e)),onKeyDown:t=>!e.disabled&&g(t,e),key:e.id,title:e.description,className:n.classNames("classic"===l?"k-prompt-suggestion":"k-suggestion",{"k-disabled":e.disabled})},e.text)),[t,s,a,l,g]);if(!t||0===t.length)return null;if("classic"===l)return f();const h="scroll"===o||"scrollbuttons"===o,v=p.createElement("div",{role:"group",className:n.classNames("k-suggestion-group",{"k-suggestion-group-scrollable":"scroll"===o,"k-suggestion-group-scrollable-start":u&&("scroll"===o||"scrollbuttons"===o),"k-suggestion-group-scrollable-end":c&&("scroll"===o||"scrollbuttons"===o)})},h?p.createElement("div",{className:"k-suggestions-scroll",ref:i},f()):f());return p.createElement(se,{visible:"scrollbuttons"===o,dir:r,canScrollLeft:c,canScrollRight:u,onScrollLeft:m,onScrollRight:d},v)},pe=p.forwardRef(({onFilesAdd:e,files:t=[],restrictions:n,multiple:l=!0,accept:s,uploadRef:o,onSelectAttachments:r,onRemoveAttachment:c,_registerRemoveCallback:u,...m},d)=>{p.useEffect(()=>(u&&c&&u(c),()=>{u&&c&&u(void 0)}),[c,u]);const g=p.useCallback(t=>{e&&e(t),r&&r({selectedFiles:t.affectedFiles,allFiles:t.newState})},[e,r]);return p.createElement(p.Fragment,null,p.createElement(a.Button,{ref:d,...m}),p.createElement(i.Upload,{ref:o,files:t,onAdd:g,autoUpload:!1,restrictions:n,multiple:l,accept:s,className:"k-hidden"}))});pe.displayName="PromptBoxUploadButton";const fe=p.forwardRef((e,t)=>p.createElement(a.Button,{ref:t,...e}));fe.displayName="PromptBoxActionButton";const he=p.forwardRef((e,t)=>p.createElement(a.SpeechToTextButton,{ref:t,...e}));he.displayName="PromptBoxSpeechToTextButton";const ve=e=>"."+e.split(".").pop()||"",ke=({files:e,onRemoveFile:t,header:s})=>{const r=o.useLocalization(),i=p.useRef(null),[c,u]=p.useState(!1),[m,d]=p.useState(!1),g=p.useCallback(()=>{const e=i.current;if(!e)return;const{scrollLeft:t,scrollWidth:n,clientWidth:a}=e,l=t+a>=n-1;d(!(0===t)),u(!l)},[]);if(p.useLayoutEffect(()=>{g()},[e,g]),p.useEffect(()=>{const e=i.current;if(!e)return;const t=()=>g(),n=new ResizeObserver(g);return n.observe(e),e.addEventListener("scroll",t,{passive:!0}),()=>{e.removeEventListener("scroll",t),n.disconnect()}},[g,e.length]),0===e.length&&!s)return null;const f=(e=>e?"function"==typeof e?e():e:null)(s),h=e.length>0&&p.createElement("ul",{className:n.classNames("k-file-box-wrapper",{"k-file-box-wrapper-scrollable-start":c,"k-file-box-wrapper-scrollable-end":m})},p.createElement("div",{className:"k-files-scroll",ref:i},e.map(e=>p.createElement("li",{key:e.name,className:"k-file-box"},p.createElement(n.IconWrap,{size:"xlarge",...n.getFileExtensionIcon(ve(e.name))}),p.createElement("div",{className:"k-file-info"},p.createElement("span",{className:"k-file-name"},e.name),p.createElement("span",{className:"k-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))),p.createElement(a.Button,{fillMode:"flat",size:"xs",svgIcon:l.xCircleIcon,onClick:n=>{n.stopPropagation(),t(e.name)},"aria-label":`${r.toLanguageString(U,j[U])} ${e.name}`,title:`${r.toLanguageString(U,j[U])} ${e.name}`})))));return p.createElement("div",{className:"k-prompt-box-header"},f,h)},be=Object.freeze({name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:0,version:"15.0.0-develop.1",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning"}),ye="k-prompt-box",Ee={mode:"auto",rows:1,defaultValue:"",disabled:!1,readOnly:!1,loading:!1,uploadButtonConfig:!1,speechToTextButtonConfig:!0,actionButtonConfig:!0},Ce=p.forwardRef((e,t)=>{const a=!n.validatePackage(be,{component:"PromptBox"}),s=n.getLicenseMessage(be),r=o.useLocalization(),i={...Ee,...e},{mode:c=Ee.mode,fillMode:u,rows:m=Ee.rows,maxTextAreaHeight:d,value:g,defaultValue:f=Ee.defaultValue,disabled:h=Ee.disabled,readOnly:v=Ee.readOnly,placeholder:k,title:b,maxLength:y,inputAttributes:E,topAffix:C,startAffix:x,endAffix:I,header:T,onChange:F,onFocus:w,onBlur:S,onPromptAction:A,attachments:M,loading:R=Ee.loading,uploadButtonConfig:N=Ee.uploadButtonConfig,speechToTextButtonConfig:B=Ee.speechToTextButtonConfig,actionButtonConfig:L=Ee.actionButtonConfig,className:D,style:P,...z}=i,O=p.useRef(null),[U,V]=p.useState(f),[W,G]=p.useState([]),[_,Y]=p.useState(!1),X=p.useRef(null),J=p.useRef(null),Q=p.useRef(0),Z=p.useRef(0),ee=p.useRef(!1),te=p.useRef(0),ne=p.useRef(0),ae=p.useCallback((e,t)=>e?"function"==typeof e?e(t):e:null,[]),le=void 0!==g,se=le?g:U,oe=void 0!==M,re=oe?M:W,ie=p.useMemo(()=>!!(null!=se&&se.trim()||re.length>0),[se,re.length]),ce=p.useCallback(()=>{if(!O.current||"single"===c)return;const e=O.current,t=globalThis.getComputedStyle(e),n=Number.parseFloat(t.lineHeight)||20,a=Number.parseFloat(t.paddingTop)||0,l=Number.parseFloat(t.paddingBottom)||0;Q.current=e.offsetHeight||n+a+l,Z.current=n*m+a+l,"auto"===c&&!_&&(ne.current=e.offsetWidth)},[c,m,_]),ue=p.useCallback(()=>"auto"===c?1:m,[c,m]),me=p.useCallback(e=>{if(d){const t=Number.parseInt(d,10);if(e>t)return t}return Math.max(Z.current,e)},[d]),de=p.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${Q.current}px`;const t=e.scrollHeight,n=me(t);e.style.height=`${n}px`,d&&t>Number.parseInt(d,10)&&(e.style.overflow="")},[me,d]),ge=p.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${Q.current}px`;const t=e.scrollHeight,n=d?Math.min(t,Number.parseInt(d,10)):t;e.style.height=`${n}px`,d&&t>Number.parseInt(d,10)&&(e.style.overflow="")},[d]),ve=p.useCallback(e=>{if(ne.current<=0)return!1;const t=e.style.height,n=e.style.width;e.style.overflow="hidden",e.style.width=`${ne.current}px`,e.style.height=`${Q.current}px`;const a=e.scrollWidth<=ne.current&&e.scrollHeight<=Q.current;return e.style.overflow="",e.style.width=n||"",e.style.height=t||"",a},[]),Ce=p.useCallback((e,t)=>{if(!ee.current){if((e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&!_)return ee.current=!0,void Y(!0);if(_){ge(e);t<te.current&&ve(e)&&(e.style.height="",ee.current=!0,Y(!1))}}},[_,ge,ve]),xe=p.useCallback(()=>{var e;if("single"===c||!O.current)return;const t=O.current,n=(null==(e=t.value)?void 0:e.length)||0;"multi"===c?de(t):"auto"===c&&Ce(t,n)},[c,de,Ce]);p.useEffect(()=>{"single"!==c&&O.current&&ce()},[c,ce]),p.useEffect(()=>{"single"!==c&&O.current&&(ce(),xe())},[m,c,ce,xe]),p.useEffect(()=>{if("single"!==c&&O.current){const e=(null==se?void 0:se.length)||0;requestAnimationFrame(()=>{if(O.current){const t=O.current;"multi"===c?de(t):"auto"===c&&Ce(t,e),te.current=e}})}},[se,c,de,Ce]),p.useEffect(()=>{"auto"===c&&_&&O.current&&requestAnimationFrame(()=>{if(O.current){const e=O.current;ge(e),ee.current=!1}})},[_,c,ge]),p.useEffect(()=>{if("auto"===c&&O.current){const e=O.current;_||(e.style.height="",e.style.overflow="",ee.current=!1)}},[c,_]),p.useEffect(()=>{if("single"===c||!O.current)return;const e=O.current;let t;const n=new ResizeObserver(()=>{clearTimeout(t),t=setTimeout(()=>{O.current&&("auto"===c&&!_&&ce(),xe())},50)});return n.observe(e),()=>{n.disconnect(),clearTimeout(t)}},[c,_,ce,xe]);const Ie=p.useCallback(()=>({focus:()=>{var e;return null==(e=O.current)?void 0:e.focus()},blur:()=>{var e;return null==(e=O.current)?void 0:e.blur()},element:O.current,get value(){return se}}),[se]);p.useImperativeHandle(t,Ie);const Te=p.useCallback(e=>{const t=e.target.value;!le&&!h&&V(t),F&&!h&&n.dispatchEvent(F,e,{...Ie(),value:t},{value:t}),"single"!==c&&xe()},[V,F,h,le,Ie,c,xe]),Fe=p.useCallback(e=>{w&&!h&&n.dispatchEvent(w,e,Ie(),void 0)},[w,h,Ie]),we=p.useCallback(e=>{S&&!h&&n.dispatchEvent(S,e,Ie(),void 0)},[S,h,Ie]),Se=p.useCallback(e=>{e.preventDefault()},[]),Ae=p.useCallback(e=>{A&&n.dispatchEvent(A,e,Ie(),{value:se,attachments:re}),le||V(""),oe||G([])},[A,Ie,se,re,le,oe]),Me=p.useCallback(e=>{if("Enter"!==e.key||!e.shiftKey){if("ArrowUp"===e.key||"ArrowDown"===e.key)return void e.stopPropagation();if("Enter"===e.key){if(e.preventDefault(),R)return;ie&&Ae(e)}}},[Ae,R,ie]),Re={disabled:h,readOnly:v,placeholder:k,title:b,maxLength:y,"aria-label":r.toLanguageString(q,j[q]),value:se,onKeyDown:Me,...E,onChange:Te,onFocus:Fe,onBlur:we,ref:O},Ne=p.useCallback(e=>{var t,a;const{isFinal:l,alternatives:s}=e;if(s.length>0){const e=s[0];if(l){const a=(null==(t=O.current)?void 0:t.value)||"",l=(a?`${a} `:"")+e.transcript;if(le||V(l),F&&!h){const e={target:O.current,currentTarget:O.current};n.dispatchEvent(F,e,{...Ie(),value:l},{value:l})}}}null==(a=O.current)||a.focus()},[le,F,h,Ie]),Be=p.useCallback(()=>{var e,t;null==(t=null==(e=X.current)?void 0:e.actionElement)||t.click()},[]),Le=p.useCallback(e=>{var t;const n=Array.from(e.affectedFiles),a="object"==typeof N&&N.onSelectAttachments;oe||G(e=>[...e,...n]),a&&a({selectedFiles:e.affectedFiles,allFiles:e.newState}),null==(t=O.current)||t.focus()},[N,oe]),De=p.useMemo(()=>({uploadButtonProps:{fillMode:"flat",svgIcon:l.paperclipIcon,size:"small",rounded:"full",onClick:Be,onFilesAdd:Le,files:re,uploadRef:X,"aria-label":r.toLanguageString($,j[$]),title:r.toLanguageString($,j[$]),_registerRemoveCallback:e=>{J.current=e}},speechToTextButtonProps:{fillMode:"flat",size:"small",rounded:"full",onResult:Ne},actionButtonProps:{rounded:"full",size:"small",svgIcon:R?l.stopIcon:l.arrowUpIcon,className:R?"k-generating":"",onClick:Ae,onMouseDown:Se,disabled:!R&&!ie,"aria-label":R?r.toLanguageString(K,j[K]):r.toLanguageString(H,j[H]),title:R?r.toLanguageString(K,j[K]):r.toLanguageString(H,j[H]),"aria-live":"polite"}}),[Ne,Le,re,Ae,Se,R,Be,r,ie]),Pe=p.useCallback(e=>{oe||G(t=>t.filter(t=>t.name!==e));const t="object"==typeof N&&N.onRemoveAttachment;t&&(J.current=t),J.current&&J.current(e)},[N,oe]),ze=()=>{const e=!1!==B,t=!1!==L,n=!1!==N,a="object"==typeof B?B:void 0,l="object"==typeof N?N:{},{restrictions:s,multiple:o=!0,accept:r,onSelectAttachments:i,onRemoveAttachment:c,...u}=l,m={restrictions:s,multiple:o,accept:r},d="object"==typeof L?L:void 0;return p.createElement(p.Fragment,null,n&&p.createElement(pe,{...De.uploadButtonProps,restrictions:m.restrictions,multiple:m.multiple,accept:m.accept,...u}),e&&p.createElement(he,{...De.speechToTextButtonProps,...a}),t&&p.createElement(fe,{...De.actionButtonProps,...d}))},Oe="multi"===c||"auto"===c&&_,qe=!1!==N||!1!==B||!1!==L,He=I||qe,$e=x||I||qe;return p.createElement("div",{...z,className:n.classNames(D,"k-input",ye,{[`k-input-${u}`]:u,"k-disabled":h,"k-prompt-box-singleline":"single"===c,"k-prompt-box-multiline":Oe}),style:P},p.createElement(ke,{files:re,onRemoveFile:Pe,header:T}),"single"===c?p.createElement("div",{className:`${ye}-content`},x&&p.createElement("div",{className:`${ye}-affix`},ae(x,De)),p.createElement("input",{...Re,className:n.classNames("k-input-inner",`${ye}-input`)}),He?p.createElement("div",{className:`${ye}-affix`},I&&ae(I,De),ze()):null):p.createElement("div",{className:`${ye}-content`},"multi"===c&&C&&p.createElement("div",{className:`${ye}-affix`},ae(C,De)),"auto"===c&&!_&&x&&p.createElement("div",{className:`${ye}-affix`},ae(x,De)),p.createElement("textarea",{...Re,className:n.classNames("k-input-inner",`${ye}-textarea`),rows:ue(),style:d?{maxHeight:d}:{},"aria-multiline":"true"}),"auto"===c&&!_&&He?p.createElement("div",{className:`${ye}-affix`},I&&ae(I,De),ze()):null,Oe&&$e?p.createElement("div",{className:`${ye}-affix`},x&&ae(x,De),(x||I)&&p.createElement("div",{className:"k-spacer"}),I&&ae(I,De),ze()):null),a&&p.createElement(n.WatermarkOverlay,{message:s}))});Ce.propTypes={value:r.string,defaultValue:r.string,mode:r.oneOf(["single","multi","auto"]),rows:r.number,maxTextAreaHeight:r.string,title:r.string,disabled:r.bool,readOnly:r.bool,placeholder:r.string,maxLength:r.number,inputAttributes:r.object,fillMode:r.oneOf(["solid","flat","outline"]),topAffix:r.oneOfType([r.func,r.element,r.string]),startAffix:r.oneOfType([r.func,r.element,r.string]),endAffix:r.oneOfType([r.func,r.element,r.string]),header:r.oneOfType([r.func,r.element,r.string]),onChange:r.func,onFocus:r.func,onBlur:r.func,loading:r.bool,uploadButtonConfig:r.oneOfType([r.bool,r.object]),speechToTextButtonConfig:r.oneOfType([r.bool,r.object]),actionButtonConfig:r.oneOfType([r.bool,r.object]),attachments:r.array,onPromptAction:r.func,className:r.string,style:r.object},Ce.displayName="KendoPromptBox";const xe=p.memo(({affixProps:e,uploadConfig:t,localizationService:n,onFilesSelect:a,onFileRemove:l})=>{const s="object"==typeof t?t:{};return!1!==t?p.createElement(pe,{...e.uploadButtonProps,fillMode:"clear","aria-label":n.toLanguageString(R,j[R]),title:n.toLanguageString(R,j[R]),...s,onSelectAttachments:a,onRemoveAttachment:l}):null});xe.displayName="UploadButtonAffix";const Ie=p.forwardRef((e,t)=>{const{onSendMessage:s,isDirectionRightToLeft:r,placeholder:i,MessageBox:c,suggestions:u,onSuggestionClick:m,inputValue:d,onInputValueChange:g,suggestionTemplate:h,sendButtonConfig:k,onInputClick:b,suggestionsLayout:y,dir:E,messageBoxSettings:C,loading:x}=e,{replyToMessage:I,setReplyToMessage:T,user:w,speechToTextConfig:S,uploadConfig:A}=Z(),[M,R]=p.useState(""),[N,B]=p.useState([]),L=p.useRef(null),D=o.useLocalization(),P=void 0!==d,z=P?d:M,q=p.useCallback(()=>{null!==L.current&&L.current.focus()},[]);p.useEffect(()=>{I&&q()},[I,q]);const H=p.useCallback(e=>{if(e.preventDefault(),s){const t={id:"",author:w,text:z||"",timestamp:new Date,replyToId:I?I.id:void 0,files:N.map(e=>({name:e.name,size:e.size,type:e.extension,rawFile:e.getRawFile?e.getRawFile():e}))};T(null),s(t,e),B([]),P||R(""),g&&g(""),q()}},[s,z,w,I,N,T,g,q,P]);p.useImperativeHandle(t,()=>({focusInput:q}),[q]);const $=p.useCallback(e=>{B(t=>t.filter(t=>t.name!==e))},[]),U=p.useCallback((e,t)=>e.isDeleted?_(t,D):e.text,[D]),K=p.useCallback(()=>{if(I){const e=G(w,I);return p.createElement("div",{className:n.classNames("k-message-reference",e?"k-message-reference-sender":"k-message-reference-receiver")},p.createElement("div",{className:"k-message-reference-content"},U(I,e)),p.createElement("span",{className:"k-spacer"}),p.createElement(a.Button,{fillMode:"flat",size:"xs",svgIcon:l.xCircleIcon,onClick:()=>T(null),"aria-label":D.toLanguageString(F,j[F]),title:D.toLanguageString(F,j[F])}))}return null},[I,w,U,T,D]),V=p.useCallback(e=>{try{const t=Array.from(e.allFiles);B(t)}catch{}},[]),W=p.useCallback(e=>{const t=e.value;P||R(t),g&&g(t||"")},[P,g]),Y=p.useCallback(e=>{H(e.syntheticEvent)},[H]),X=p.useCallback(e=>e?"function"==typeof e?e():e:null,[]),J=p.useCallback(e=>p.createElement(p.Fragment,null,p.createElement(xe,{affixProps:e,uploadConfig:A,localizationService:D,onFilesSelect:V,onFileRemove:$}),X(null==C?void 0:C.startAffix)),[A,D,V,$,null==C?void 0:C.startAffix,X]),Q=p.useCallback(()=>X(null==C?void 0:C.endAffix),[null==C?void 0:C.endAffix,X]),ee=p.useCallback(()=>X(null==C?void 0:C.topAffix),[null==C?void 0:C.topAffix,X]),te=p.useMemo(()=>{const e="object"==typeof k?k:{},t=!1!==k&&{"aria-label":x?D.toLanguageString(O,j[O]):D.toLanguageString(f,j[f]),title:x?D.toLanguageString(O,j[O]):D.toLanguageString(f,j[f]),dir:r?"rtl":void 0,...e};return p.createElement(Ce,{header:K(),ref:L,placeholder:i,value:z,onChange:W,onPromptAction:Y,mode:(null==C?void 0:C.mode)||"multi",rows:(null==C?void 0:C.rows)||2,maxTextAreaHeight:(null==C?void 0:C.maxTextAreaHeight)||"110",loading:x,speechToTextButtonConfig:S,actionButtonConfig:t,attachments:N,startAffix:J,endAffix:null!=C&&C.endAffix?Q:void 0,topAffix:null!=C&&C.topAffix?ee:void 0,inputAttributes:{onClick:b,"aria-label":D.toLanguageString(v,j[v])}})},[i,z,W,Y,C,x,S,k,N,K,J,Q,ee,D,r,b]);return p.createElement("div",{className:"k-message-box-wrapper"},u&&u.length>0&&p.createElement(ge,{onSuggestionClick:m,suggestions:u,suggestionTemplate:h,suggestionsLayout:y,dir:E}),c?p.createElement(c,{messageInput:te}):te)});Ie.displayName="NewMessage";const Te=e=>p.createElement(a.Toolbar,{className:"k-chat-header",size:"small"},e.children),Fe=e=>{const{message:t,onUnpin:s,user:r,onReferencedMessageClick:i}=e,c=o.useLocalization(),u=p.useRef(null),m=r&&G(r,t),d=p.useCallback(e=>{e.preventDefault(),e.stopPropagation(),null==i||i(t.id)},[t.id,i]);return p.createElement("div",{ref:u,className:`k-message-reference ${m?"k-message-reference-sender":"k-message-reference-receiver"} k-message-pinned`,onClick:d},p.createElement(n.IconWrap,{icon:l.pinIcon}),p.createElement("div",{className:"k-message-reference-content"},null!=t&&t.isDeleted?r&&_(G(r,t),c):null==t?void 0:t.text),p.createElement("span",{className:"k-spacer"}),p.createElement(a.Button,{fillMode:"flat",size:"xs",svgIcon:l.xCircleIcon,onClick:e=>{e.stopPropagation(),null==s||s(t)}}))},we=e=>{const{show:t,text:n}=e;return p.createElement("div",{style:{position:"absolute",top:"90%",left:"50%",transform:"translate(-50%, -50%)",zIndex:1e3,pointerEvents:t?"auto":"none"}},p.createElement(c.Fade,null,t&&p.createElement(u.Notification,{type:{style:"inverse"},closable:!1},p.createElement("span",null,n))))},Se={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",isFailedField:"isFailed"},Ae=(e,t={})=>{const n={...Se,...t};let a,l;a=e.author&&"object"==typeof e.author?{id:e.author.id||e.author[n.authorIdField]||e[n.authorIdField]||"",name:e.author.name||e.author[n.authorNameField]||e[n.authorNameField],avatarUrl:e.author.avatarUrl||e.author[n.authorImageUrlField]||e[n.authorImageUrlField],avatarAltText:e.author.avatarAltText||e.author[n.authorImageAltTextField]||e[n.authorImageAltTextField]}:{id:e[n.authorIdField]||e.authorId||"",name:e[n.authorNameField]||e.authorName,avatarUrl:e[n.authorImageUrlField]||e.authorImageUrl,avatarAltText:e[n.authorImageAltTextField]||e.authorImageAltText},l=e.timestamp?new Date(e.timestamp):e[n.timestampField]?new Date(e[n.timestampField]):new Date;const s={id:void 0!==e.id?e.id:e[n.idField],text:void 0!==e.text?e.text:e[n.textField]||"",author:a,timestamp:l,status:void 0!==e.status?e.status:e[n.statusField],attachments:void 0!==e.attachments?e.attachments:e[n.attachmentsField],attachmentLayout:e.attachmentLayout||"list",suggestedActions:void 0!==e.suggestedActions?e.suggestedActions:e[n.suggestedActionsField],isPinned:void 0!==e.isPinned?e.isPinned:e[n.isPinnedField]||!1,typing:void 0!==e.typing?e.typing:e[n.typingField],files:void 0!==e.files?e.files:e[n.filesField]||[],isFailed:void 0!==e.isFailed?e.isFailed:e[n.isFailedField]||!1};return e.pinnedAt&&(s.pinnedAt=new Date(e.pinnedAt)),e.pinnedBy&&(s.pinnedBy=e.pinnedBy),void 0!==e.replyToId?s.replyToId=e.replyToId:void 0!==e[n.replyToIdField]&&(s.replyToId=e[n.replyToIdField]),void 0!==e.isDeleted?s.isDeleted=e.isDeleted:void 0!==e[n.isDeletedField]&&(s.isDeleted=e[n.isDeletedField]),{...s,dataItem:e}},Me=(e,t={})=>Array.isArray(e)?e.map(e=>Ae(e,t)):[],Re=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),Ne=e=>{e.scrollTop=e.scrollHeight-e.clientHeight},Be=({viewItemsWrapperRef:e,isKeyboardNavigationActiveRef:t,processedMessages:n,authorId:a,autoScrollThreshold:l,isEndless:s=!1,isOnLastBatch:o=!0,skipAutoScrollRef:r})=>{var i;const c=p.useRef(a),u=p.useRef(l),m=p.useRef(s),d=p.useRef(o);p.useEffect(()=>{c.current=a,u.current=l,m.current=s,d.current=o});const g=p.useRef(!1);p.useEffect(()=>{s||!e.current||0===n.length||g.current||(Ne(e.current),g.current=!0)},[e,s,n.length]);const f=p.useRef(void 0),h=p.useRef(0),v=p.useRef(!0),k=p.useRef(!0),b=p.useRef(!1),y=p.useRef(null),E=(n.length>0?null==(i=n.at(-1))?void 0:i.id:void 0)!==f.current,C=n.length>h.current;if(E||C){const t=e.current;k.current=!t||(e=>{const{scrollHeight:t,scrollTop:n,clientHeight:a}=e;return!(t>a)||t-n-a<=100})(t)}p.useEffect(()=>{var a,l;const s=n.length,o=s>0?null==(a=n[s-1])?void 0:a.id:void 0,i=f.current,g=h.current,p=v.current;if(f.current=o,h.current=s,v.current=!1,0===s)return;const E=e.current;if(!E||t.current)return;if(p||o===i)return void(!m.current&&(p||s>g)&&(Ne(E),b.current=!1,y.current=null));if(m.current&&!d.current)return;if(null!=r&&r.current)return void(r.current=!1);const C=n[s-1];if(void 0!==c.current&&void 0!==(null==(l=null==C?void 0:C.author)?void 0:l.id)&&String(C.author.id)===String(c.current))return E.scrollTo({top:E.scrollHeight-E.clientHeight,behavior:"smooth"}),b.current=!1,void(y.current=null);if(!k.current)return b.current=!1,void(y.current=null);const x=(e=>{const t=e.querySelectorAll(".k-message");return t.length>0?t[t.length-1]:null})(E);if(!x)return;const I=(e=>{const t=e.querySelector(".k-message-pinned");return t?t.offsetHeight:0})(E),T=Math.max(0,E.clientHeight-I),F=((e,t)=>{const n=null!=e?e:"20%";let a;if("number"==typeof n)a=n;else{const e=/^(-?\d+(?:\.\d+)?)%$/.exec(String(n));if(e)a=Number.parseFloat(e[1])/100*t;else{const e=Number.parseFloat(String(n));a=Number.isNaN(e)?.2*t:e}}return Math.min(a,t)})(u.current,T),w=x.getBoundingClientRect().top-E.getBoundingClientRect().top+E.scrollTop,S=Math.max(0,w-F-I),A=Math.max(0,E.scrollHeight-E.clientHeight),M=Math.min(S,A);M>E.scrollTop&&E.scrollTo({top:M,behavior:"smooth"}),y.current=S,b.current=!0},[n,e,t]),p.useEffect(()=>{const n=e.current;if(!n)return;let a=n.querySelectorAll(".k-message").length,l=n.scrollHeight,s=n.scrollTop;const o=()=>{const e=n.scrollTop;b.current&&e<s&&(b.current=!1,y.current=null),s=e},r=new MutationObserver(()=>{if(t.current)return;const e=n.querySelectorAll(".k-message").length,o=n.scrollHeight;if(e===a&&o>l&&b.current){const e=o-n.clientHeight,t=y.current,a=null===t?e:Math.min(e,t);a>n.scrollTop&&(n.scrollTop=a),s=n.scrollTop}a=e,l=o});return r.observe(n,{childList:!0,subtree:!0,characterData:!0}),n.addEventListener("scroll",o,{passive:!0}),()=>{r.disconnect(),n.removeEventListener("scroll",o)}},[e,t])},Le=["allowMessageCollapse","messageWidthMode","showAvatar","showUsername","messageTemplate","messageContentTemplate","messageToolbarActions","messageContextMenuActions","fileActions"];function De(e,t,n,a,l){const s=((e,t)=>{var n,a;return(null==(n=null==e?void 0:e.author)?void 0:n.id)===t||(null==(a=null==e?void 0:e.author)?void 0:a.id)===String(t)})(e,t)?a:l,o={};return Le.forEach(e=>{var t;o[e]=null!=(t=null==s?void 0:s[e])?t:null==n?void 0:n[e]}),o}const Pe=({scrollMode:e,processedMessages:t,total:n,pageSize:a=50,startIndex:l,endIndex:s,onLoadMoreMessages:o,onReferencedMessageClick:r,viewItemsWrapperRef:i,authorId:c})=>{const u=p.useRef(!1),m="endless"===e,d=null!=n?n:t.length,g=m&&t.length===d&&!u.current,f=m&&(t.length<d||u.current);f&&(u.current=!0);const[h,v]=p.useState(-1),[k,b]=p.useState(-1),y=p.useRef(h),E=p.useRef(k);y.current=h,E.current=k;const C=p.useRef(!1),x=p.useRef(0),I=p.useRef(0),T=p.useRef(0),F=p.useRef(!1),w=p.useRef(d),S=p.useRef(c);S.current=c;const A=p.useRef(!1),M=p.useRef(null),R=p.useRef(!1),N=p.useRef(!1),B=p.useRef(!0),L=p.useRef(d);p.useEffect(()=>{if(g){if(u.current)return void((-1===h||-1===k)&&(v(0),b(t.length)));if(-1===h||-1===k){const e=Math.max(0,t.length-a),n=t.length;v(e),b(n)}else if(k<t.length){const e=w.current;if(E.current>=e)b(t.length);else if(t.length>e&&t.slice(e).some(e=>{var t;return void 0!==(null==(t=e.author)?void 0:t.id)&&String(e.author.id)===String(S.current)})){const e=Math.max(0,t.length-a);v(e),b(t.length),R.current=!0}}w.current=d}},[g,t.length,a,h,k,d]);const D=null!=l?l:0,P=null!=s?s:t.length,z=p.useCallback(()=>{const e=i.current;e&&(x.current=e.scrollHeight,I.current=e.scrollTop,T.current=e.querySelectorAll("[data-message-id]").length)},[i]),O=p.useCallback(e=>{var t,n,a;((e,t,n=0)=>{if(!t)return;const a=t.querySelector(`[data-message-id="${e}"]`);if(!a)return;const l=t.querySelector(".k-message-list");if(l){const e=l.getBoundingClientRect().top,t=a.getBoundingClientRect().top,s=l.scrollTop+(t-e)-n;l.scrollTo({top:s,behavior:"smooth"})}else a.scrollIntoView({behavior:"smooth",block:"start"})})(e,null==(t=i.current)?void 0:t.closest(".k-chat"),(null==(a=null==(n=i.current)?void 0:n.querySelector(".k-message-pinned"))?void 0:a.offsetHeight)||0)},[i]);p.useLayoutEffect(()=>{if(!F.current)return;const e=i.current;if(!e)return void(F.current=!1);if(e.querySelectorAll("[data-message-id]").length<=T.current)return;const t=e.scrollHeight-x.current;t>0&&(e.scrollTop=I.current+t),F.current=!1,C.current=!1}),p.useLayoutEffect(()=>{if(!R.current)return;const e=i.current;e?k>=t.length&&k>0&&(R.current=!1,e.scrollTop=e.scrollHeight-e.clientHeight):R.current=!1});const q=p.useRef(!1);p.useLayoutEffect(()=>{if(!m||q.current)return;const e=i.current;e&&e.querySelector("[data-message-id]")&&(e.scrollTop=e.scrollHeight-e.clientHeight,q.current=!0)}),p.useEffect(()=>{if(!m)return;const e=i.current;if(!e)return;let n=e.scrollTop;const l=()=>{const{scrollTop:l,scrollHeight:s,clientHeight:r}=e,i=l<n,c=l>n;if(n=l,!C.current){if(i&&l<=100)if(g){const e=y.current;if(e>0){const t=Math.max(0,e-a);F.current=!0,z(),v(t),null==o||o({startIndex:t,endIndex:E.current})}}else if(f&&D>0){C.current=!0;const e=Math.max(0,D-a);F.current=!0,z(),null==o||o({startIndex:e,endIndex:P})}if(c&&s-l-r<=100)if(g){const e=E.current;if(e<t.length){const n=Math.min(t.length,e+a);N.current=!0,b(n),null==o||o({startIndex:y.current,endIndex:n})}}else if(f&&P<d){C.current=!0,N.current=!0;const e=Math.min(d,P+a);null==o||o({startIndex:D,endIndex:e})}}};return e.addEventListener("scroll",l,{passive:!0}),()=>e.removeEventListener("scroll",l)},[m,g,f,i,a,t.length,D,P,d,o]),p.useEffect(()=>{var e;const n=P>=d;if(!f)return L.current=d,void(B.current=n);const a=L.current,l=B.current;if(L.current=d,B.current=n,d>a&&!l&&n){const n=t[t.length-1];void 0!==S.current&&void 0!==(null==(e=null==n?void 0:n.author)?void 0:e.id)&&String(n.author.id)===String(S.current)&&(A.current=!0,N.current=!0)}},[f,d,P,t]),p.useEffect(()=>{!f||!A.current||(A.current=!1,C.current=!1,requestAnimationFrame(()=>{const e=i.current;e&&(e.scrollTop=e.scrollHeight-e.clientHeight)}))},[f,t,i]),p.useEffect(()=>{if(!f||null===M.current)return;const e=M.current,t=i.current;t&&t.querySelector(`[data-message-id="${e}"]`)&&(M.current=null,C.current=!1,requestAnimationFrame(()=>{O(e)}))},[f,t,i,O]),p.useEffect(()=>{f&&C.current&&!F.current&&(C.current=!1)},[f,D,P]);const H=p.useMemo(()=>{if(g){const e=Math.max(0,h),n=Math.min(t.length,k);if(e>=n){const e=Math.max(0,t.length-a);return t.slice(e)}return t.slice(e,n)}return t},[g,t,h,k,a]),$=p.useMemo(()=>!m||(g?k>=t.length:P>=d),[m,g,k,t.length,P,d]),U=p.useCallback(()=>{if(!m||$){const e=i.current;return void(e&&e.scrollTo({top:e.scrollHeight-e.clientHeight,behavior:"smooth"}))}if(!C.current)if(g){const e=Math.max(0,t.length-a);v(e),b(t.length),null==o||o({startIndex:e,endIndex:t.length}),requestAnimationFrame(()=>{const e=i.current;e&&(e.scrollTop=e.scrollHeight-e.clientHeight)})}else if(f){A.current=!0,F.current=!1,C.current=!0;const e=Math.max(0,d-a);null==o||o({startIndex:e,endIndex:d})}},[m,g,f,$,t.length,a,d,o,i]),K=p.useCallback(e=>{if(m){if(g){const n=i.current;if(null==n?void 0:n.querySelector(`[data-message-id="${e}"]`))O(e);else{if(C.current)return;const n=t.findIndex(t=>t.id===e||String(t.id)===String(e));if(n>=0){const l=Math.floor(a/2),s=Math.max(0,n-l),o=Math.min(t.length,s+a);C.current=!0,v(s),b(o),requestAnimationFrame(()=>{requestAnimationFrame(()=>{O(e),C.current=!1})})}}}else if(f){const t=i.current;if(null==t?void 0:t.querySelector(`[data-message-id="${e}"]`))O(e);else{if(C.current)return;M.current=e,F.current=!1,C.current=!0}}}else O(e);null==r||r({id:e})},[m,g,f,i,t,a,r,O]);return{renderedMessages:H,handleScrollToBottom:U,handleReferencedMessageClick:K,isEndless:m,isOnLastBatch:$,skipAutoScrollRef:N}},ze=p.forwardRef((e,t)=>{const{messages:s=[],messageTemplate:r,messageContentTemplate:i,attachmentTemplate:c,width:u,height:m,onSendMessage:d,onSuggestionClick:g,onInputValueChange:f,onActionExecute:h,dir:v,messageBox:k,placeholder:y,className:E,style:C,message:x=te,authorId:T,suggestions:F,suggestionTemplate:w,suggestionsLayout:S="scroll",quickActionsLayout:A="scroll",inputValue:M,headerTemplate:R,noDataTemplate:N,timestampTemplate:B,statusTemplate:L,userStatusTemplate:P,allowMessageCollapse:z,messageToolbarActions:O,messageContextMenuActions:q,fileActions:H,onUnpin:$,messageWidthMode:U,showAvatar:K,showUsername:V,timestampVisibility:W,authorMessageSettings:G,receiverMessageSettings:_,onToolbarAction:Y,onContextMenuAction:X,onFileAction:J,onDownload:Z,speechToTextConfig:ee,uploadConfig:ne,sendButtonConfig:le,messageFilesLayout:se,scrollToBottomButton:oe=!0,autoScrollThreshold:re,textField:ce,statusField:ge,authorIdField:pe,authorNameField:fe,authorImageUrlField:he,authorImageAltTextField:ve,idField:ke,timestampField:ye,filesField:Ee,attachmentsField:Ce,replyToIdField:xe,isDeletedField:Se,isPinnedField:Ae,typingField:Ne,suggestedActionsField:Le,isFailedField:ze,onResendMessage:Oe,messageBoxSettings:qe,loading:He,scrollMode:$e,total:Ue,pageSize:Ke,startIndex:Ve,endIndex:We,onLoadMoreMessages:je,pinnedMessages:Ge,repliedToMessages:_e,onReferencedMessageClick:Ye,...Xe}=e,Je=p.useRef(null);n.useWebMcpRegister("chat",Je,e,e.webMcp);const[Qe,Ze]=p.useState(null),[et,tt]=p.useState(!1),[nt,at]=p.useState(!1),[lt,st]=p.useState(null),[ot,rt]=p.useState(null),[it,ct]=p.useState(!1),ut=p.useRef(null),mt=p.useRef(null),dt=p.useRef(null),gt=p.useRef(null),pt=p.useRef(void 0),ft=p.useRef(!1),ht=p.useRef(null),vt=p.useRef(""),kt=p.useMemo(()=>{if(!s||0===s.length)return[];const e={textField:ce,statusField:ge,authorIdField:pe,authorNameField:fe,authorImageUrlField:he,authorImageAltTextField:ve,idField:ke,timestampField:ye,filesField:Ee,attachmentsField:Ce,replyToIdField:xe,isDeletedField:Se,isPinnedField:Ae,typingField:Ne,suggestedActionsField:Le,isFailedField:ze};return!Object.values(e).some(e=>void 0!==e)&&Re(s[0])?s.map(e=>({...e,timestamp:e.timestamp?new Date(e.timestamp):e.timestamp})):Me(s,e)},[s,ce,ge,pe,fe,he,ve,ke,ye,Ee,Ce,xe,Se,Ae,Ne,Le,ze]);p.useEffect(()=>{if(T===vt.current&&ht.current)rt(ht.current);else if(T&&kt.length>0){const e=kt.find(e=>e.author&&(e.author.id===T||e.author.id===String(T))),t=(null==e?void 0:e.author)||{id:T};ht.current=t,vt.current=T,rt(t)}},[T,kt]);const{renderedMessages:bt,handleScrollToBottom:yt,handleReferencedMessageClick:Et,isEndless:Ct,isOnLastBatch:xt,skipAutoScrollRef:It}=Pe({scrollMode:$e,processedMessages:kt,total:Ue,pageSize:Ke,startIndex:Ve,endIndex:We,onLoadMoreMessages:je,onReferencedMessageClick:Ye,viewItemsWrapperRef:dt,authorId:T}),Tt=p.useMemo(()=>bt.length>0?(e=>{const t=e.slice().reduce(ae(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})(bt):[],[bt]),Ft=p.useMemo(()=>!n.validatePackage(be,{component:"Chat"}),[]),wt=n.getLicenseMessage(be),St=p.useMemo(()=>{if(Ge)return Ge.find(e=>e.isPinned);const e=kt.find(e=>e.isPinned);return e||void 0},[kt,Ge]),At=o.useLocalization();Be({viewItemsWrapperRef:dt,isKeyboardNavigationActiveRef:ft,processedMessages:bt,authorId:T,autoScrollThreshold:re,isEndless:Ct,isOnLastBatch:xt,skipAutoScrollRef:It});const Mt=(({elementRef:e})=>{const[t,n]=p.useState(!1);return p.useEffect(()=>{const t=e.current;if(!t)return;const a=()=>{n(t.scrollHeight>t.clientHeight)};a();const l=new ResizeObserver(a);l.observe(t);const s=new MutationObserver(()=>{requestAnimationFrame(a)});return s.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>{l.disconnect(),s.disconnect()}},[e]),t})({elementRef:dt}),Rt=p.useCallback(()=>{clearTimeout(pt.current)},[]),Nt=p.useCallback(()=>{pt.current=window.setTimeout(()=>{Ze(null)},0)},[]),Bt=p.useCallback(e=>{Ze(e)},[]),Lt=p.useCallback(e=>{let t=null;const a=null!==Qe?Qe:Tt.lastSelectionIndex;e.keyCode===n.Keys.up?null===a?t=0:a>0&&(t=a-1):e.keyCode===n.Keys.down?null===a?t=0:a<Tt.lastSelectionIndex&&(t=a+1):e.keyCode===n.Keys.home?t=0:e.keyCode===n.Keys.end&&(t=Tt.lastSelectionIndex),null!==t&&(Ze(t),ft.current=!0,e.preventDefault())},[Qe,Tt]),Dt=p.useCallback((e,t,n)=>{var a;if(h&&h({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":d&&d({message:{id:"",author:ot,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==(a=gt.current)||a.focusInput()}},[h,d,ot]),Pt=p.useCallback(()=>n.classNames("k-chat",E,{"k-rtl":et}),[E,et]),zt=p.useCallback(()=>{const e=Tt.length-1;return Tt.map((t,n)=>{var a,l,s,o,u,m;if("date-marker"===t.type)return p.createElement(me,{item:t,key:t.trackBy,timestampTemplate:B});if("message-group"===t.type){const s={allowMessageCollapse:z,messageWidthMode:U,showAvatar:K,showUsername:V,messageTemplate:r,messageContentTemplate:i,messageToolbarActions:O,messageContextMenuActions:q,fileActions:H},o=De(null==(a=null==t?void 0:t.messages)?void 0:a[0],T,s,G,_);return p.createElement(de,{group:t,itemTemplate:o.messageTemplate,contentTemplate:o.messageContentTemplate,attachmentTemplate:c,user:ot,selectedItemIndex:Qe,onRequestSelection:Bt,isLastGroup:n===e,key:null!=(l=t.messages[0].id)?l:t.messages[0].selectionIndex,message:x,allowMessageCollapse:o.allowMessageCollapse,messageToolbarActions:o.messageToolbarActions,messageContextMenuActions:o.messageContextMenuActions,fileActions:o.fileActions,messageWidthMode:o.messageWidthMode,showAvatar:o.showAvatar,showUsername:o.showUsername})}return"attachment-group"===t.type?p.createElement(ue,{group:t,itemTemplate:c,onRequestSelection:Bt,selected:t.selectionIndex===Qe,isLastGroup:n===e,key:`att-${null!=(o=null==(s=t.trackBy)?void 0:s.id)?o:t.selectionIndex}`}):"action-group"===t.type?p.createElement(ie,{group:t,onActionExecute:Dt,onRequestSelection:Bt,selected:t.selectionIndex===Qe,key:`act-${null!=(m=null==(u=t.trackBy)?void 0:u.id)?m:t.selectionIndex}`,quickActionsLayout:A,dir:v}):null})},[Tt,B,r,i,c,ot,Qe,Bt,x,z,O,q,H,U,K,V,T,G,_,Dt,A,v]),Ot=p.useCallback(()=>R?"function"==typeof R?R():R:null,[R]),qt=p.useCallback(()=>N?"function"==typeof N?N():N:null,[N]);p.useEffect(()=>{const e=void 0!==v?"rtl"===v:ut.current&&"rtl"===getComputedStyle(ut.current).direction;tt(!!e)},[v]),p.useEffect(()=>()=>{clearTimeout(pt.current)},[]),p.useEffect(()=>{if(!oe||!dt.current)return;let e,t;const n=()=>{e=void 0;const n=dt.current;if(!n)return;const{scrollHeight:a,scrollTop:l,clientHeight:s}=n;!(a>s)||a-l-s<=100?(void 0!==t&&(clearTimeout(t),t=void 0),ct(!1)):null!=t||(t=setTimeout(()=>{t=void 0,ct(!0)},300))},a=()=>{void 0===e&&(e=requestAnimationFrame(n))},l=dt.current;l.addEventListener("scroll",a,{passive:!0});const s=new MutationObserver(a);return s.observe(l,{childList:!0,subtree:!0,characterData:!0}),()=>{l.removeEventListener("scroll",a),s.disconnect(),void 0!==e&&cancelAnimationFrame(e),void 0!==t&&clearTimeout(t)}},[oe]);const Ht=p.useMemo(()=>({replyToMessage:lt,setReplyToMessage:st,messages:kt,repliedToMessages:_e,user:ot,internalScrollContainerRef:mt,messageListScrollContainerRef:dt,onToolbarAction:Y,onContextMenuAction:X,onFileAction:J,setShowCopyNotification:at,onDownload:Z,onResendMessage:Oe,fileActions:H,speechToTextConfig:ee,uploadConfig:ne,statusTemplate:L,userStatusTemplate:P,messageFilesLayout:se,timestampVisibility:W,onReferencedMessageClick:Et}),[lt,st,kt,_e,ot,Y,X,J,at,Z,Oe,H,ee,ne,L,P,se,W,Et]);return p.createElement(Q.Provider,{value:Ht},p.createElement("div",{style:{width:u,height:m,position:"relative",overflow:"hidden",...C},onKeyDown:Lt,className:Pt(),ref:e=>{ut.current=e,mt.current=e,"function"==typeof t?t(e):t&&(t.current=e)},...Xe},void 0!==R&&p.createElement(Te,null,Ot()),p.createElement("div",{className:"k-message-list",onBlur:Nt,onFocus:Rt,role:"log","aria-label":At.toLanguageString(b,j[b]),"aria-live":"polite",ref:dt,style:{scrollBehavior:"auto"}},St&&p.createElement(Fe,{message:St,onUnpin:$,user:ot,onReferencedMessageClick:Et}),p.createElement("div",{className:n.classNames("k-message-list-content",{"k-message-list-content-empty":0===bt.length})},0===bt.length&&void 0!==N&&qt(),bt.length>0&&zt()),oe&&(it||!xt)&&p.createElement("div",{className:"k-chat-scroll-to-bottom-container"},p.createElement(a.FloatingActionButton,{svgIcon:l.arrowDownIcon,size:"small",themeColor:"base",rounded:"full",onClick:yt,"aria-label":At.toLanguageString(D,j[D]),title:At.toLanguageString(D,j[D])}))),Mt&&p.createElement("div",{className:"k-separator"}),p.createElement(Ie,{onSendMessage:(e,t)=>{d&&d({message:e,syntheticEvent:t,nativeEvent:t.nativeEvent,target:t.currentTarget})},onSuggestionClick:e=>{g&&g(e)},isDirectionRightToLeft:et,ref:gt,placeholder:y,MessageBox:k,suggestions:F,suggestionTemplate:w,inputValue:M,onInputValueChange:e=>{f&&f(e)},onInputClick:()=>{ft.current=!1},sendButtonConfig:le,suggestionsLayout:S,dir:v,messageBoxSettings:qe,loading:He}),p.createElement(we,{show:nt,text:At.toLanguageString(I,j[I])}),Ft&&p.createElement(n.WatermarkOverlay,{message:wt})))});ze.displayName="Chat",ze.propTypes={messages:r.arrayOf(r.object),user:r.object,messageTemplate:r.any,messageContentTemplate:r.any,attachmentTemplate:r.any,width:r.oneOfType([r.string,r.number]),style:r.object,onSendMessage:r.func,onActionExecute:r.func,dir:r.string,messageBox:r.any,noDataTemplate:r.oneOfType([r.element,r.func]),suggestionsLayout:r.oneOf(["scroll","wrap","scrollbuttons"]),quickActionsLayout:r.oneOf(["scroll","wrap","scrollbuttons"]),userStatusTemplate:r.elementType,messageFilesLayout:r.oneOf(["vertical","wrap","horizontal"]),showAvatar:r.bool,showUsername:r.bool,authorMessageSettings:r.object,receiverMessageSettings:r.object,scrollMode:r.oneOf(["scrollable","endless"]),total:r.number,pageSize:r.number,startIndex:r.number,endIndex:r.number,onLoadMoreMessages:r.func,pinnedMessages:r.arrayOf(r.object),repliedToMessages:r.arrayOf(r.object),onReferencedMessageClick:r.func};const Oe=e=>{const{activeView:t,toolbarItems:n,activeViewChange:l}=e;return p.createElement("div",{className:"k-prompt-header"},p.createElement(a.Toolbar,{keyboardNavigation:!1,role:"toolbar",className:"k-toolbar-flat"},n.map(e=>p.isValidElement(e)?e:p.createElement(a.Button,{key:e.name,className:t===e.name?"k-selected":"",size:"medium",themeColor:"primary",fillMode:"flat",rounded:"full",title:e.buttonText,svgIcon:e.buttonIcon,onClick:()=>(e=>{null==l||l.call(null,e)})(e.name)},e.buttonText))))},qe={name:"Output view",buttonText:"Output",buttonIcon:l.commentIcon},He={name:"Commands view",buttonIcon:l.moreHorizontalIcon},$e={name:"Prompt view",buttonText:"Ask AI",buttonIcon:l.sparklesIcon},Ue=p.createContext([{},()=>{}]),Ke=()=>p.useContext(Ue),Ve=e=>{const{children:t}=e;return p.createElement("div",{className:"k-prompt-footer"},p.createElement("div",{className:"k-actions k-actions-start k-actions-horizontal k-prompt-actions"},t))},We=p.forwardRef((e,t)=>{const{children:n,streaming:s,onCancel:r}=e,i=o.useLocalization().toLanguageString(E,j[E]),[c]=Ke(),u=c.activeView===qe.name,m=s&&!u,d=p.useCallback(e=>{"Escape"===e.key&&s&&r&&(e.preventDefault(),r())},[s,r]);return p.createElement("div",{className:"k-prompt-content",ref:t,onKeyDown:d},m&&p.createElement(a.FloatingActionButton,{onClick:r,svgIcon:l.stopIcon,icon:"stop",size:"medium",positionMode:"absolute",className:"k-prompt-stop-fab k-generating","aria-label":i,title:i}),p.createElement("div",{className:"k-prompt-view"},n))});We.displayName="KendoReactAIPromptContent";const je=e=>{const[t]=Ke();return t.activeView===e.name?e.children:null},Ge=e=>{const[t,n]=p.useState(!0),{children:s,title:o}=e;return p.createElement("div",{className:"k-prompt-expander"},p.createElement(a.Button,{"aria-controls":e.id,fillMode:"flat",svgIcon:t?l.chevronUpIcon:l.chevronDownIcon,title:o,onClick:()=>n(!t),"aria-expanded":t},o),t&&p.createElement("div",{id:e.id,className:"k-prompt-expander-content"},s))},_e=e=>null==e?void 0:e.map(e=>p.createElement(s.PanelBarItem,{title:e.text,key:e.id,svgIcon:e.svgIcon,data:e},e.children&&_e(e.children||[]))),Ye=({show:e=!1,anchor:t,onOpen:n,onClose:a,animate:l=!0,appendTo:s,popupOptions:o={},children:r,style:i})=>p.createElement(d.Popup,{show:e,anchor:t,style:i,animate:l,appendTo:s,onOpen:n,onClose:a,...o},r),Xe=({placeholder:e="Ask or generate content with AI...",promptValue:t,onMenuClick:s,promptInput:o=m.TextArea,generateButton:r,enableSpeechToText:i=!1,streaming:c=!1,commands:u,onPromptRequest:d,onPromptCancel:g})=>{const[f,h]=p.useState(t||""),[v,k]=n.useCustomComponent(r),[b,y]=n.useCustomComponent(o),E=o===m.TextArea||b===m.TextArea,C={svgIcon:c?l.stopIcon:l.paperPlaneIcon,active:(!!c).toString(),title:"Send Button","aria-label":"Send Button",disabled:!f.trim()&&!c,"aria-disabled":!f.trim()&&!c},x={placeholder:e,className:"!k-flex-row",...E?{autoSize:!0}:{},rows:1},I=u&&u.length>0,T=Object.keys(k).length>0?k:C,F=Object.keys(y).length>0?y:x,w=e=>{const{isFinal:t,alternatives:n}=e;if(t&&n.length>0){const e=n[0].transcript,t=(()=>{const t=f,n=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(n?" ":"")+e})();h(t)}},S=()=>{f.trim()&&d&&d(f.trim())};return p.createElement(b,{value:f,onChange:e=>{const t=e.target.value;h(t)},onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&(e.preventDefault(),S())},prefix:I||i?p.createElement(p.Fragment,null,p.createElement(m.InputPrefix,{className:"!k-align-items-start"},I&&p.createElement(a.Button,{"aria-label":"Commands Button",title:"Commands Button",fillMode:"flat",svgIcon:l.menuIcon,onClick:s}),i&&p.createElement(a.SpeechToTextButton,{fillMode:"flat",..."object"==typeof i?{...i,onResult:i.onResult||w}:{onResult:w}})),p.createElement(m.InputSeparator,null)):void 0,suffix:p.createElement(m.InputSuffix,{className:"!k-align-items-start"},p.createElement(v,{className:n.classNames("k-prompt-send",{"k-generating":c,"k-active":c}),fillMode:"flat",onClick:c?g:S,...T})),...F})};e.AIPrompt=e=>{const t=p.useRef(null);n.useWebMcpRegister("aiprompt",t,e,e.webMcp);const a=!n.validatePackage(be,{component:"AIPrompt"}),l=n.getLicenseMessage(be),{activeView:s,toolbarItems:o,children:r,onActiveViewChange:i,onPromptRequest:c,onCommandExecute:u,style:m,dir:d,className:g,streaming:f,loading:h,onCancel:v,suggestionsView:k,...b}=e,y=o||[$e,qe],[E,C]=p.useState({activeView:s}),x={...E,activeView:s,streaming:f,loading:h,suggestionsView:null!=k?k:"classic",onCancel:v,onActiveViewChange:i,onPromptRequest:c,onCommandExecute:u};return p.createElement(Ue.Provider,{value:[x,e=>{C(e)}]},p.createElement("div",{className:n.classNames("k-prompt",g),style:m,dir:d,...b},p.createElement(Oe,{activeView:x.activeView,toolbarItems:y,activeViewChange:i}),r,a&&p.createElement(n.WatermarkOverlay,{message:l})))},e.AIPromptCommandsView=e=>{const{commands:t}=e,[n]=Ke();return p.createElement(je,{name:He.name},p.createElement(We,{streaming:n.streaming,onCancel:n.onCancel},p.createElement("div",{className:"k-prompt-view"},p.createElement(s.PanelBar,{onSelect:e=>{var t,a,l;const s=null==(a=null==(t=e.target)?void 0:t.props)?void 0:a.data;null!=(l=s.children)&&l.length||n.onCommandExecute&&n.onCommandExecute.call(null,s)},selected:""},_e(null!=t?t:[])))))},e.AIPromptContent=We,e.AIPromptFooter=Ve,e.AIPromptOutputView=e=>{const[t,n]=p.useState(""),r=p.useRef(null),[i]=Ke(),{outputs:c,showOutputRating:u,outputCard:m}=e,{header:d,body:g,actions:f}=m||{},h=o.useLocalization(),v=h.toLanguageString(E,j[E]),k=(e,t)=>{i.onPromptRequest&&i.onPromptRequest.call(null,e.prompt,{...e,ratingType:t,isRetry:!1}),b()},b=()=>{r&&r.current&&r.current.scrollTo({top:0,behavior:"smooth"})},C=p.createElement(s.Card,null,p.createElement(s.CardHeader,null,p.createElement(s.CardTitle,null,p.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}})),p.createElement(s.CardSubtitle,null,p.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),p.createElement(s.CardBody,null,p.createElement("span",{className:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}})),p.createElement(s.CardActions,null,i.streaming&&i.onCancel?p.createElement(a.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",svgIcon:l.stopIcon,title:v,onClick:i.onCancel},v):p.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),x=(e,s)=>f?f(e):s&&i.onCancel?p.createElement(a.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",svgIcon:l.stopIcon,title:v,onClick:i.onCancel},v):p.createElement(p.Fragment,null,p.createElement(a.Button,{size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:t===e.id?l.checkIcon:l.copyIcon,onClick:()=>(e=>{null!=e&&e.responseContent&&navigator.clipboard.writeText(e.responseContent),n(e.id),setTimeout(()=>{n("")},1e3)})(e)},"Copy"),p.createElement(a.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:l.arrowRotateCwIcon,onClick:()=>(e=>{i.onPromptRequest&&i.onPromptRequest.call(null,e.prompt,{...e,isRetry:!0}),b()})(e)},"Retry"),u&&p.createElement(p.Fragment,null,p.createElement("span",{className:"k-spacer"}),p.createElement(a.Button,{size:"medium",themeColor:"positive"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:l.thumbUpIcon,onClick:()=>k(e,"positive")}),p.createElement(a.Button,{size:"medium",themeColor:"negative"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:l.thumbDownIcon,onClick:()=>k(e,"negative")}))),I=null==c?void 0:c.map((e,t)=>{const n=!(!i.streaming||i.loading||0!==t);return p.createElement(s.Card,{key:`${e.id}_${t}`},p.createElement(s.CardHeader,null,d?d(e):p.createElement(p.Fragment,null,e.title&&p.createElement(s.CardTitle,null,e.title),e.subTitle&&p.createElement(s.CardSubtitle,null,e.subTitle))),p.createElement(s.CardBody,null,g?g(e):e.responseContent),p.createElement(s.CardActions,null,x(e,n)))}),T=p.createElement(s.Card,null,p.createElement(s.CardBody,null,h.toLanguageString(y,j[y])));return p.createElement(je,{name:qe.name},p.createElement(We,{ref:r,streaming:i.streaming,onCancel:i.onCancel},p.createElement("div",{className:"k-card-list"},i.loading&&C,I,(!I||0===I.length)&&!i.loading&&T)))},e.AIPromptView=e=>{const{promptInput:t=m.TextArea,generateButton:s=a.Button,enableSpeechToText:o=!1,promptValue:r,promptSuggestions:i}=e,[c,u]=p.useState(r||""),[d]=Ke(),[g,f]=n.useCustomComponent(s),[h,v]=n.useCustomComponent(t),k=p.useRef(null);p.useEffect(()=>{var e,t;null!=(t=null==(e=k.current)?void 0:e.element)&&t.current&&requestAnimationFrame(()=>{var e,t;if(null!=(t=null==(e=k.current)?void 0:e.element)&&t.current){const e=k.current.element.current;e.style.height="auto",e.style.height=`${e.scrollHeight}px`}})},[c]);const b={title:"Generate",children:"Generate",svgIcon:l.sparklesIcon},y=Object.keys(f).length>0?f:b,E=Object.keys(v).length>0?v:{placeholder:"Ask or generate content with AI ...",rows:2},C=e=>{const{isFinal:t,alternatives:n}=e;if(t&&n.length>0){const e=n[0].transcript,t=(()=>{const t=c,n=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(n?" ":"")+e})();u(t)}};let x;return o&&(x="object"==typeof o?{...o,onResult:o.onResult||C}:{onResult:C}),p.createElement(je,{name:$e.name},p.createElement(We,{streaming:d.streaming,onCancel:d.onCancel},p.createElement(h,{ref:k,value:c,flow:"vertical",textareaStyle:{maxHeight:"110px"},autoSize:!0,suffix:o?p.createElement(p.Fragment,null,p.createElement(m.InputSeparator,{orientation:"horizontal"}),p.createElement(m.InputSuffix,{orientation:"horizontal"},p.createElement(a.SpeechToTextButton,{fillMode:"flat",...x}))):void 0,onChange:e=>{u(e.target.value)},...E}),i&&i.length>0&&p.createElement(Ge,{title:"Prompt Suggestions"},p.createElement(ge,{suggestionsView:d.suggestionsView,suggestions:i.map((e,t)=>({id:t,text:e,description:e})),onSuggestionClick:e=>{(e=>{u(e)})(e.text)}}))),p.createElement(Ve,null,p.createElement(g,{themeColor:"primary",fillMode:"solid",rounded:"full",size:"medium",onClick:()=>{d.onPromptRequest&&d.onPromptRequest.call(null,c),u("")},disabled:!c.trim(),...y},y.children)))},e.AIPromptViewRender=je,e.Chat=ze,e.ChatMessage=te,e.DEFAULT_FIELD_MAPPING=Se,e.HeroCard=e=>{const{imageUrl:t,imageMaxWidth:n,title:l,subtitle:s,actions:o,onActionExecute:r,altText:i}=e,c=p.useCallback((e,t)=>{null==r||r({action:e,syntheticEvent:t,nativeEvent:t.nativeEvent,target:t.currentTarget})},[r]),u=i||l||"";return p.createElement("div",{className:"k-card"},p.createElement("img",{className:"k-card-image",src:t,style:{maxWidth:n},alt:u}),p.createElement("div",{className:"k-card-body"},l&&p.createElement("h5",{className:"k-card-title"},l),s&&p.createElement("h6",{className:"k-card-subtitle"},s)),p.createElement("div",{className:"k-card-actions k-card-actions-vertical"},o.map((e,t)=>p.createElement("span",{className:"k-card-action",key:`action-${t}-${e.title||e.value||t}`},p.createElement(a.Button,{fillMode:"flat",onClick:t=>c(e,t)},e.title)))))},e.InlineAIPrompt=e=>{const t=!n.validatePackage(be,{component:"InlineAIPrompt"}),o=n.getLicenseMessage(be),{outputs:r=[],outputCard:i,promptInput:c=m.TextArea,generateButton:u=a.Button,promptPlaceholder:d="Ask or generate content with AI...",promptValue:g,onPromptRequest:f,onCopy:h,onDiscard:v,outputActions:k,onOutputAction:b,enableSpeechToText:y=!1,streaming:E,onPromptCancel:C,show:x=!1,anchor:I,width:T,height:F,onOpen:w,onClose:S,animate:A=!0,appendTo:M,commands:R,onCommandExecute:N,style:B,className:L,popupOptions:D={},...P}=e,[z,O]=p.useState(""),[q,H]=p.useState(!1),[$,U]=p.useState({left:0,top:0}),K=p.useRef(null),{body:V,actions:W}=i||{},j=k||[{id:"copy",text:"Copy",svgIcon:l.copyIcon,themeColor:"primary",title:"Copy"},{id:"discard",text:"Discard",svgIcon:l.cancelIcon,themeColor:"base",title:"Discard"}],G=(e,t)=>{switch(e.id){case"copy":(e=>{e.responseContent&&(navigator.clipboard.writeText(e.responseContent),O(e.id),setTimeout(()=>O(""),1e3)),null==h||h(e)})(t);break;case"discard":(e=>{null==v||v(e)})(t);break;default:null==b||b(e,t)}},_=p.useCallback(e=>{"Escape"===e.key&&(E&&C?C():!E&&S&&S({target:null}))},[E,C,S]),Y={...B,...T&&{width:T},...F&&{height:F}},X={...T&&{width:T},...F&&{height:F}},J=p.createElement(p.Fragment,null,p.createElement("div",{className:n.classNames("k-prompt",L),style:Y,onKeyDown:_,...P},p.createElement(We,{ref:K},r&&r.length>0&&p.createElement("div",{className:"k-card-list"},r.map((e,t)=>p.createElement(s.Card,{key:`${e.id}_${t}`},p.createElement(s.CardBody,null,V?V(e):e.responseContent),p.createElement(s.CardActions,null,W?W(e):p.createElement(p.Fragment,null,j.map(t=>{var n;return t.spacer?p.createElement("span",{key:t.id,className:"k-spacer"}):p.createElement(a.Button,{key:t.id,size:"medium",themeColor:t.themeColor||"primary",fillMode:"flat",rounded:"medium",title:null!=(n=t.title)?n:t.text,svgIcon:"copy"===t.id&&z===e.id?l.checkIcon:t.svgIcon,onClick:()=>G(t,e)},t.text)})))))),p.createElement(Xe,{promptValue:g,placeholder:d,onPromptRequest:f,onMenuClick:e=>{if(!K.current)return;const t=K.current.getBoundingClientRect();U({left:t.left,top:t.bottom}),H(!0)},onPromptCancel:C,promptInput:c,generateButton:u,enableSpeechToText:y,streaming:E,commands:R}))),t&&p.createElement(n.WatermarkOverlay,{message:o}));return p.createElement(p.Fragment,null,p.createElement(Ye,{show:x,anchor:I,onOpen:w,onClose:S,animate:A,appendTo:M,popupOptions:D,style:X},J),p.createElement(s.ContextMenu,{show:q,offset:$,onClose:()=>{H(!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})))(R),onSelect:e=>{var t,n;const a=null==(t=e.item)?void 0:t.data;a&&(null==(n=a.children)||!n.length)&&(e=>{H(!1),N&&N(e)})(a)}}))},e.PromptBox=Ce,e.PromptBoxActionButton=fe,e.PromptBoxSpeechToTextButton=he,e.PromptBoxUploadButton=pe,e.PromptHeader=Oe,e.SuggestionGroup=ge,e.commandsViewDefaults=He,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,isFailedField:e.isFailedField}),e.isStandardMessageFormat=Re,e.mapDataArrayToMessages=Me,e.mapDataToMessage=Ae,e.mapMessageToCustomFormat=(e,t={})=>{const n={...Se,...t},a={};return void 0!==e.id&&(a[n.idField]=e.id),void 0!==e.text&&(a[n.textField]=e.text),void 0!==e.status&&(a[n.statusField]=e.status),void 0!==e.isFailed&&(a[n.isFailedField]=e.isFailed),void 0!==e.timestamp&&(a[n.timestampField]=e.timestamp),void 0!==e.attachments&&(a[n.attachmentsField]=e.attachments),void 0!==e.files&&(a[n.filesField]=e.files),void 0!==e.suggestedActions&&(a[n.suggestedActionsField]=e.suggestedActions),void 0!==e.replyToId&&(a[n.replyToIdField]=e.replyToId),void 0!==e.isDeleted&&(a[n.isDeletedField]=e.isDeleted),void 0!==e.isPinned&&(a[n.isPinnedField]=e.isPinned),void 0!==e.typing&&(a[n.typingField]=e.typing),e.author&&(void 0!==e.author.id&&(a[n.authorIdField]=e.author.id),void 0!==e.author.name&&(a[n.authorNameField]=e.author.name),void 0!==e.author.avatarUrl&&(a[n.authorImageUrlField]=e.author.avatarUrl),void 0!==e.author.avatarAltText&&(a[n.authorImageAltTextField]=e.author.avatarAltText)),void 0!==e.pinnedAt&&(a.pinnedAt=e.pinnedAt),void 0!==e.pinnedBy&&(a.pinnedBy=e.pinnedBy),void 0!==e.attachmentLayout&&(a.attachmentLayout=e.attachmentLayout),a},e.outputViewDefaults=qe,e.promptViewDefaults=$e});
|
|
@@ -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 ie=require("react"),C=require("@progress/kendo-react-layout"),x=require("@progress/kendo-react-buttons"),me=require("@progress/kendo-react-inputs"),b=require("@progress/kendo-svg-icons"),f=require("@progress/kendo-react-common"),S=require("../package-metadata.js"),de=require("./InlineAIPromptPopup.js"),pe=require("./InlineAIPromptInput.js"),ue=require("../ai-prompt/AIPromptContent.js");function Ce(o){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const r in o)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(o,r);Object.defineProperty(c,r,s.get?s:{enumerable:!0,get:()=>o[r]})}}return c.default=o,Object.freeze(c)}const t=Ce(ie),fe=o=>{const c=!f.validatePackage(S.packageMetadata,{component:"InlineAIPrompt"}),r=f.getLicenseMessage(S.packageMetadata),{outputs:s=[],outputCard:w,promptInput:q=me.TextArea,generateButton:R=x.Button,promptPlaceholder:T="Ask or generate content with AI...",promptValue:A,onPromptRequest:B,onCopy:g,onDiscard:I,outputActions:D,onOutputAction:h,enableSpeechToText:N=!1,streaming:i,onPromptCancel:m,show:j=!1,anchor:_,width:d,height:p,onOpen:F,onClose:u,animate:z=!0,appendTo:K,commands:E,onCommandExecute:M,style:W,className:$,popupOptions:V={},...G}=o,[H,P]=t.useState(""),[J,k]=t.useState(!1),[Q,U]=t.useState({left:0,top:0}),y=t.useRef(null),{body:v,actions:O}=w||{},X=[{id:"copy",text:"Copy",svgIcon:b.copyIcon,themeColor:"primary",title:"Copy"},{id:"discard",text:"Discard",svgIcon:b.
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ie=require("react"),C=require("@progress/kendo-react-layout"),x=require("@progress/kendo-react-buttons"),me=require("@progress/kendo-react-inputs"),b=require("@progress/kendo-svg-icons"),f=require("@progress/kendo-react-common"),S=require("../package-metadata.js"),de=require("./InlineAIPromptPopup.js"),pe=require("./InlineAIPromptInput.js"),ue=require("../ai-prompt/AIPromptContent.js");function Ce(o){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const r in o)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(o,r);Object.defineProperty(c,r,s.get?s:{enumerable:!0,get:()=>o[r]})}}return c.default=o,Object.freeze(c)}const t=Ce(ie),fe=o=>{const c=!f.validatePackage(S.packageMetadata,{component:"InlineAIPrompt"}),r=f.getLicenseMessage(S.packageMetadata),{outputs:s=[],outputCard:w,promptInput:q=me.TextArea,generateButton:R=x.Button,promptPlaceholder:T="Ask or generate content with AI...",promptValue:A,onPromptRequest:B,onCopy:g,onDiscard:I,outputActions:D,onOutputAction:h,enableSpeechToText:N=!1,streaming:i,onPromptCancel:m,show:j=!1,anchor:_,width:d,height:p,onOpen:F,onClose:u,animate:z=!0,appendTo:K,commands:E,onCommandExecute:M,style:W,className:$,popupOptions:V={},...G}=o,[H,P]=t.useState(""),[J,k]=t.useState(!1),[Q,U]=t.useState({left:0,top:0}),y=t.useRef(null),{body:v,actions:O}=w||{},X=[{id:"copy",text:"Copy",svgIcon:b.copyIcon,themeColor:"primary",title:"Copy"},{id:"discard",text:"Discard",svgIcon:b.cancelIcon,themeColor:"base",title:"Discard"}],Y=D||X,Z=e=>{e.responseContent&&(navigator.clipboard.writeText(e.responseContent),P(e.id),setTimeout(()=>P(""),1e3)),g==null||g(e)},L=e=>{I==null||I(e)},ee=(e,n)=>{switch(e.id){case"copy":Z(n);break;case"discard":L(n);break;default:h==null||h(e,n);break}},te=e=>{if(!y.current)return;const n=y.current.getBoundingClientRect();U({left:n.left,top:n.bottom}),k(!0)},ne=()=>{k(!1)},ae=e=>{k(!1),M&&M(e)},oe=e=>e==null?void 0:e.map(n=>({text:n.text,svgIcon:n.svgIcon,data:n,items:n.children?n.children.map(a=>({text:a.text,data:a})):void 0})),re=t.useCallback(e=>{e.key==="Escape"&&(i&&m?m():!i&&u&&u({target:null}))},[i,m,u]),se={...W,...d&&{width:d},...p&&{height:p}},ce={...d&&{width:d},...p&&{height:p}},le=t.createElement(t.Fragment,null,t.createElement("div",{className:f.classNames("k-prompt",$),style:se,onKeyDown:re,...G},t.createElement(ue.AIPromptContent,{ref:y},s&&s.length>0&&t.createElement("div",{className:"k-card-list"},s.map((e,n)=>t.createElement(C.Card,{key:`${e.id}_${n}`},t.createElement(C.CardBody,null,v?v(e):e.responseContent),t.createElement(C.CardActions,null,O?O(e):t.createElement(t.Fragment,null,Y.map(a=>{var l;return a.spacer?t.createElement("span",{key:a.id,className:"k-spacer"}):t.createElement(x.Button,{key:a.id,size:"medium",themeColor:a.themeColor||"primary",fillMode:"flat",rounded:"medium",title:(l=a.title)!=null?l:a.text,svgIcon:a.id==="copy"&&H===e.id?b.checkIcon:a.svgIcon,onClick:()=>ee(a,e)},a.text)})))))),t.createElement(pe.InlineAIPromptInput,{promptValue:A,placeholder:T,onPromptRequest:B,onMenuClick:te,onPromptCancel:m,promptInput:q,generateButton:R,enableSpeechToText:N,streaming:i,commands:E}))),c&&t.createElement(f.WatermarkOverlay,{message:r}));return t.createElement(t.Fragment,null,t.createElement(de.InlineAIPromptPopup,{show:j,anchor:_,onOpen:F,onClose:u,animate:z,appendTo:K,popupOptions:V,style:ce},le),t.createElement(C.ContextMenu,{show:J,offset:Q,onClose:ne,items:oe(E),onSelect:e=>{var a,l;const n=(a=e.item)==null?void 0:a.data;n&&!((l=n.children)!=null&&l.length)&&ae(n)}}))};exports.InlineAIPrompt=fe;
|
|
@@ -9,10 +9,10 @@ import * as t from "react";
|
|
|
9
9
|
import { Card as se, CardBody as re, CardActions as le, ContextMenu as ce } from "@progress/kendo-react-layout";
|
|
10
10
|
import { Button as E } from "@progress/kendo-react-buttons";
|
|
11
11
|
import { TextArea as me } from "@progress/kendo-react-inputs";
|
|
12
|
-
import { copyIcon as ie,
|
|
13
|
-
import { validatePackage as fe, getLicenseMessage as Ce, classNames as he, WatermarkOverlay as
|
|
12
|
+
import { copyIcon as ie, cancelIcon as de, checkIcon as pe } from "@progress/kendo-svg-icons";
|
|
13
|
+
import { validatePackage as fe, getLicenseMessage as Ce, classNames as he, WatermarkOverlay as ge } from "@progress/kendo-react-common";
|
|
14
14
|
import { packageMetadata as x } from "../package-metadata.mjs";
|
|
15
|
-
import { InlineAIPromptPopup as
|
|
15
|
+
import { InlineAIPromptPopup as ue } from "./InlineAIPromptPopup.mjs";
|
|
16
16
|
import { InlineAIPromptInput as ke } from "./InlineAIPromptInput.mjs";
|
|
17
17
|
import { AIPromptContent as ye } from "../ai-prompt/AIPromptContent.mjs";
|
|
18
18
|
const Te = (v) => {
|
|
@@ -39,8 +39,8 @@ const Te = (v) => {
|
|
|
39
39
|
onClose: m,
|
|
40
40
|
animate: K = !0,
|
|
41
41
|
appendTo: W,
|
|
42
|
-
commands:
|
|
43
|
-
onCommandExecute:
|
|
42
|
+
commands: g,
|
|
43
|
+
onCommandExecute: u,
|
|
44
44
|
style: $,
|
|
45
45
|
className: q,
|
|
46
46
|
popupOptions: z = {},
|
|
@@ -90,7 +90,7 @@ const Te = (v) => {
|
|
|
90
90
|
}, Z = () => {
|
|
91
91
|
C(!1);
|
|
92
92
|
}, L = (e) => {
|
|
93
|
-
C(!1),
|
|
93
|
+
C(!1), u && u(e);
|
|
94
94
|
}, ee = (e) => e == null ? void 0 : e.map((n) => ({
|
|
95
95
|
text: n.text,
|
|
96
96
|
svgIcon: n.svgIcon,
|
|
@@ -149,12 +149,12 @@ const Te = (v) => {
|
|
|
149
149
|
generateButton: P,
|
|
150
150
|
enableSpeechToText: D,
|
|
151
151
|
streaming: s,
|
|
152
|
-
commands:
|
|
152
|
+
commands: g
|
|
153
153
|
}
|
|
154
154
|
))
|
|
155
|
-
), M && /* @__PURE__ */ t.createElement(
|
|
155
|
+
), M && /* @__PURE__ */ t.createElement(ge, { message: b }));
|
|
156
156
|
return /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement(
|
|
157
|
-
|
|
157
|
+
ue,
|
|
158
158
|
{
|
|
159
159
|
show: N,
|
|
160
160
|
anchor: R,
|
|
@@ -172,7 +172,7 @@ const Te = (v) => {
|
|
|
172
172
|
show: j,
|
|
173
173
|
offset: G,
|
|
174
174
|
onClose: Z,
|
|
175
|
-
items: ee(
|
|
175
|
+
items: ee(g),
|
|
176
176
|
onSelect: (e) => {
|
|
177
177
|
var a, o;
|
|
178
178
|
const n = (a = e.item) == null ? void 0 : a.data;
|
|
@@ -5,5 +5,5 @@
|
|
|
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 q=require("react"),y=require("@progress/kendo-react-buttons"),s=require("@progress/kendo-react-inputs"),f=require("@progress/kendo-svg-icons"),d=require("@progress/kendo-react-common");function V(t){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const l=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(c,a,l.get?l:{enumerable:!0,get:()=>t[a]})}}return c.default=t,Object.freeze(c)}const e=V(q),G=({placeholder:t="Ask or generate content with AI...",promptValue:c,onMenuClick:a,promptInput:l=s.TextArea,generateButton:B,enableSpeechToText:u=!1,streaming:n=!1,commands:p,onPromptRequest:g,onPromptCancel:h})=>{const[r,k]=e.useState(c||""),[x,I]=d.useCustomComponent(B),[P,S]=d.useCustomComponent(l),E=l===s.TextArea||P===s.TextArea,j={svgIcon:n?f.
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react"),y=require("@progress/kendo-react-buttons"),s=require("@progress/kendo-react-inputs"),f=require("@progress/kendo-svg-icons"),d=require("@progress/kendo-react-common");function V(t){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const l=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(c,a,l.get?l:{enumerable:!0,get:()=>t[a]})}}return c.default=t,Object.freeze(c)}const e=V(q),G=({placeholder:t="Ask or generate content with AI...",promptValue:c,onMenuClick:a,promptInput:l=s.TextArea,generateButton:B,enableSpeechToText:u=!1,streaming:n=!1,commands:p,onPromptRequest:g,onPromptCancel:h})=>{const[r,k]=e.useState(c||""),[x,I]=d.useCustomComponent(B),[P,S]=d.useCustomComponent(l),E=l===s.TextArea||P===s.TextArea,j={svgIcon:n?f.stopIcon:f.paperPlaneIcon,active:(!!n).toString(),title:"Send Button","aria-label":"Send Button",disabled:!r.trim()&&!n,"aria-disabled":!r.trim()&&!n},O={placeholder:t,className:"!k-flex-row",...E?{autoSize:!0}:{},rows:1},b=p&&p.length>0,w=Object.keys(I).length>0?I:j,R=Object.keys(S).length>0?S:O,v=o=>{const{isFinal:m,alternatives:C}=o;if(m&&C.length>0){const D=C[0].transcript,M=(()=>{const i=r,T=i&&!i.endsWith(" ")&&!i.endsWith(`
|
|
9
9
|
`);return i+(T?" ":"")+D})();k(M)}},N=o=>{const m=o.target.value;k(m)},A=()=>{r.trim()&&g&&g(r.trim())};return e.createElement(P,{value:r,onChange:N,onKeyDown:o=>{o.key==="Enter"&&!o.shiftKey&&(o.preventDefault(),A())},prefix:b||u?e.createElement(e.Fragment,null,e.createElement(s.InputPrefix,{className:"!k-align-items-start"},b&&e.createElement(y.Button,{"aria-label":"Commands Button",title:"Commands Button",fillMode:"flat",svgIcon:f.menuIcon,onClick:a}),u&&e.createElement(y.SpeechToTextButton,{fillMode:"flat",...typeof u=="object"?{...u,onResult:u.onResult||v}:{onResult:v}})),e.createElement(s.InputSeparator,null)):void 0,suffix:e.createElement(s.InputSuffix,{className:"!k-align-items-start"},e.createElement(x,{className:d.classNames("k-prompt-send",{"k-generating":n,"k-active":n}),fillMode:"flat",onClick:n?h:A,...w})),...R})};exports.InlineAIPromptInput=G;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import * as t from "react";
|
|
9
9
|
import { Button as M, SpeechToTextButton as R } from "@progress/kendo-react-buttons";
|
|
10
10
|
import { TextArea as l, InputSuffix as F, InputPrefix as K, InputSeparator as O } from "@progress/kendo-react-inputs";
|
|
11
|
-
import {
|
|
11
|
+
import { stopIcon as W, paperPlaneIcon as z, menuIcon as T } from "@progress/kendo-svg-icons";
|
|
12
12
|
import { useCustomComponent as B, classNames as $ } from "@progress/kendo-react-common";
|
|
13
13
|
const U = ({
|
|
14
14
|
placeholder: P = "Ask or generate content with AI...",
|
package/messages/index.d.ts
CHANGED
|
@@ -125,6 +125,10 @@ export declare const promptBoxStopGenerating = "promptBox.stopGenerating";
|
|
|
125
125
|
* @hidden
|
|
126
126
|
*/
|
|
127
127
|
export declare const promptBoxAriaLabel = "promptBox.ariaLabel";
|
|
128
|
+
/**
|
|
129
|
+
* @hidden
|
|
130
|
+
*/
|
|
131
|
+
export declare const chatMessageToolbar = "chat.messageToolbar";
|
|
128
132
|
/**
|
|
129
133
|
* @hidden
|
|
130
134
|
*/
|
|
@@ -159,4 +163,5 @@ export declare const messages: {
|
|
|
159
163
|
"promptBox.removeFile": string;
|
|
160
164
|
"promptBox.stopGenerating": string;
|
|
161
165
|
"promptBox.ariaLabel": string;
|
|
166
|
+
"chat.messageToolbar": string;
|
|
162
167
|
};
|
package/messages/index.js
CHANGED
|
@@ -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="newMessage.sendButton",t="newMessage.optionsButton",o="newMessage.messageInput",s="avatar.alt",a="messageList.ariaLabel",l="aIPrompt.noOutputs",n="aIPrompt.cancel",c="chat.senderDeletedMessage",r="chat.receiverDeletedMessage",p="chat.copyNotification",i="chat.downloadAllFiles",g="chat.closeReply",m="chat.collapseMessage",d="chat.expandMessage",h="chat.removeFile",M="chat.fileActions",B="chat.attachFile",u="chat.downloadAll",x="chat.scrollLeft",F="chat.scrollRight",v="chat.scrollToBottom",A="chat.messageFailed",S="chat.retryMessage",f="chat.stopGenerating",w="promptBox.input",
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="newMessage.sendButton",t="newMessage.optionsButton",o="newMessage.messageInput",s="avatar.alt",a="messageList.ariaLabel",l="aIPrompt.noOutputs",n="aIPrompt.cancel",c="chat.senderDeletedMessage",r="chat.receiverDeletedMessage",p="chat.copyNotification",i="chat.downloadAllFiles",g="chat.closeReply",m="chat.collapseMessage",d="chat.expandMessage",h="chat.removeFile",M="chat.fileActions",B="chat.attachFile",u="chat.downloadAll",x="chat.scrollLeft",F="chat.scrollRight",v="chat.scrollToBottom",A="chat.messageFailed",S="chat.retryMessage",f="chat.stopGenerating",w="promptBox.input",b="promptBox.sendButton",y="promptBox.attachFile",R="promptBox.removeFile",I="promptBox.stopGenerating",L="promptBox.ariaLabel",T="chat.messageToolbar",P={[e]:"Send",[t]:"Options",[o]:"Message",[s]:"Avatar",[a]:"Message list",[n]:"Cancel",[l]:"No output from AI available",[c]:"You removed this message",[r]:"The message was removed by its sender",[p]:"Text copied to clipboard",[i]:"Download all files",[g]:"Close reply",[m]:"Collapse message",[d]:"Expand message",[h]:"Remove file",[M]:"File actions for",[A]:"Failed to send",[S]:"Retry",[f]:"Stop generating",[B]:"Attach file",[u]:"Download all",[x]:"Scroll left",[F]:"Scroll right",[v]:"Scroll to bottom",[w]:"Prompt",[b]:"Send",[y]:"Attach file",[R]:"Remove file",[I]:"Stop generating",[L]:"Prompt box",[T]:"Toolbar"};exports.aIPromptCancel=n;exports.aIPromptNoOutputs=l;exports.ariaLabelMessageList=a;exports.attachFile=B;exports.avatarAlt=s;exports.chatCopyNotification=p;exports.chatMessageToolbar=T;exports.chatReceiverDeletedMessage=r;exports.chatSenderDeletedMessage=c;exports.chatStopGenerating=f;exports.closeReply=g;exports.collapseMessage=m;exports.downloadAll=u;exports.downloadAllFiles=i;exports.expandMessage=d;exports.fileActions=M;exports.messageFailed=A;exports.messages=P;exports.newMessageMessageInput=o;exports.newMessageOptionsButton=t;exports.newMessageSendButton=e;exports.promptBoxAriaLabel=L;exports.promptBoxAttachFile=y;exports.promptBoxInput=w;exports.promptBoxRemoveFile=R;exports.promptBoxSendButton=b;exports.promptBoxStopGenerating=I;exports.removeFile=h;exports.retryMessage=S;exports.scrollLeft=x;exports.scrollRight=F;exports.scrollToBottom=v;
|