@inkeep/agents-ui 0.17.3 → 0.17.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/primitives/providers/base-events-provider.cjs +1 -1
- package/dist/primitives/providers/base-events-provider.js +1 -1
- package/dist/primitives/providers/chat-base-events-provider.cjs +1 -1
- package/dist/primitives/providers/chat-base-events-provider.js +1 -1
- package/dist/react/embedded-chat.cjs +1 -1
- package/dist/react/embedded-chat.js +249 -245
- package/dist/styled/components/message.cjs +1 -1
- package/dist/styled/components/message.js +27 -13
- package/dist/types/config/components.d.ts +3 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),t=require("react"),p=require("./config-provider.cjs"),n=t.createContext(void 0),g=({children:e})=>{const{baseSettings:s,componentType:o}=p.useInkeepConfig(),{tags:r,analyticsProperties:i}=s,c="0.17.
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),t=require("react"),p=require("./config-provider.cjs"),n=t.createContext(void 0),g=({children:e})=>{const{baseSettings:s,componentType:o}=p.useInkeepConfig(),{tags:r,analyticsProperties:i}=s,c="0.17.4",a=t.useMemo(()=>({widgetLibraryVersion:c,componentType:o,tags:r}),[o,r,c]),v={logEvent:t.useCallback(async u=>{const E={...a,...u.properties,...i},d={eventName:u.eventName,properties:E};return s.onEvent?.(d)},[s,a,i])};return l.jsx(n.Provider,{value:v,children:e})},m=()=>{const e=t.useContext(n);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsContext=n;exports.BaseEventsProvider=g;exports.useBaseEvents=m;
|
|
@@ -3,7 +3,7 @@ import { jsx as u } from "react/jsx-runtime";
|
|
|
3
3
|
import { createContext as E, useMemo as d, useCallback as l, useContext as g } from "react";
|
|
4
4
|
import { useInkeepConfig as x } from "./config-provider.js";
|
|
5
5
|
const c = E(void 0), b = ({ children: e }) => {
|
|
6
|
-
const { baseSettings: t, componentType: o } = x(), { tags: s, analyticsProperties: n } = t, r = "0.17.
|
|
6
|
+
const { baseSettings: t, componentType: o } = x(), { tags: s, analyticsProperties: n } = t, r = "0.17.4", i = d(
|
|
7
7
|
() => ({
|
|
8
8
|
widgetLibraryVersion: r,
|
|
9
9
|
componentType: o,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("react/jsx-runtime"),u=require("react"),B=require("./config-provider.cjs"),O=require("./chat-auth-provider.cjs"),U=require("../hooks/use-events-api.cjs"),x=require("./base-events-provider.cjs"),M=({children:g})=>{const{baseSettings:n,aiChatSettings:h,componentType:i}=B.useInkeepConfig(),{tags:t,analyticsProperties:r,privacyPreferences:y,userProperties:o}=n,c="0.17.
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("react/jsx-runtime"),u=require("react"),B=require("./config-provider.cjs"),O=require("./chat-auth-provider.cjs"),U=require("../hooks/use-events-api.cjs"),x=require("./base-events-provider.cjs"),M=({children:g})=>{const{baseSettings:n,aiChatSettings:h,componentType:i}=B.useInkeepConfig(),{tags:t,analyticsProperties:r,privacyPreferences:y,userProperties:o}=n,c="0.17.4",a=u.useMemo(()=>({widgetLibraryVersion:c,componentType:i}),[i,c]),{effectiveAuthToken:b,applicableRefreshSession:f,getCaptchaHeader:E,invalidateCaptcha:P}=O.useChatAuth(),{baseUrl:m,appId:A,analyticsApiBaseUrl:C,headers:I}=h,p=y?.optOutAllAnalytics??!1,{logEvent:l}=U.useEventsApi({baseUrl:C??m,appId:A,authToken:b,getCaptchaHeader:E,invalidateCaptcha:P,refreshSession:f,headers:I}),k={logEvent:u.useCallback(async s=>{const q={eventName:s.eventName,properties:{...a,...t?{tags:t}:{},...s.properties,...r}};if(!p){const e=s.properties??{},v=typeof e.conversationId=="string"?e.conversationId:void 0,d=typeof e.messageId=="string"?e.messageId:void 0,S=!!o&&Object.keys(o).length>0,w={...t?{tags:t}:{},...r??{}},T={...a,...s.properties};l({body:{type:s.eventName,...v?{conversationId:v}:{},...d?{messageId:d}:{},...S?{userProperties:o}:{},properties:w,metadata:T}})}try{return await n.onEvent?.(q)}catch(e){console.warn("[events] onEvent callback threw",e)}},[n,a,t,r,l,p,o])};return j.jsx(x.BaseEventsContext.Provider,{value:k,children:g})};exports.ChatBaseEventsProvider=M;
|
|
@@ -6,7 +6,7 @@ import { useChatAuth as O } from "./chat-auth-provider.js";
|
|
|
6
6
|
import { useEventsApi as j } from "../hooks/use-events-api.js";
|
|
7
7
|
import { BaseEventsContext as M } from "./base-events-provider.js";
|
|
8
8
|
const F = ({ children: m }) => {
|
|
9
|
-
const { baseSettings: r, aiChatSettings: g, componentType: i } = N(), { tags: t, analyticsProperties: n, privacyPreferences: f, userProperties: o } = r, c = "0.17.
|
|
9
|
+
const { baseSettings: r, aiChatSettings: g, componentType: i } = N(), { tags: t, analyticsProperties: n, privacyPreferences: f, userProperties: o } = r, c = "0.17.4", a = x(
|
|
10
10
|
() => ({
|
|
11
11
|
widgetLibraryVersion: c,
|
|
12
12
|
componentType: i
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("react"),s=require("../styled/components/embedded-chat.cjs"),a=require("../styled/components/chat-history.cjs"),C=require("../styled/components/modal.cjs"),A=require("../styled/components/shadow.cjs"),I=require("../styled/components/message.cjs"),H=require("../primitives/providers/chat-auth-provider.cjs"),w=require("../primitives/providers/chat-base-events-provider.cjs"),k=require("../primitives/providers/chat-history-provider.cjs"),b=require("../primitives/providers/config-provider.cjs"),P=require("../primitives/providers/root-provider.cjs"),f=require("../primitives/providers/widget-provider.cjs"),M=require("../primitives/components/embedded-chat/chat-provider.cjs"),B=require("../primitives/components/modal/modal-provider.cjs"),p=require("../primitives/utils/misc.cjs"),E=require("../primitives/atoms/portal-with-theme.cjs"),q=require("../primitives/atoms/error-boundary.cjs"),L=require("./modal.cjs"),D=require("../primitives/providers/image-preview-provider.cjs"),W=require("./widget-toggle.cjs"),y=require("../primitives/components/embedded-chat/file-upload-input.cjs"),i=require("../styled/components/embedded-chat/file-upload-input.cjs"),m=require("../styled/components/embedded-chat/image-preview-modal.cjs");function N(r){const{baseSettings:t,aiChatSettings:n}=r;return e.jsx(q.ErrorBoundary,{children:e.jsx(A.Shadow,{wrapperStyles:{height:"inherit",width:"inherit"},children:e.jsx(P.RootProvider,{config:{baseSettings:t,aiChatSettings:n},componentType:b.WebWidgetInteractionType.EmbeddedChat,children:e.jsx(v,{...r})})})})}function T(r){const{children:t,onToggleView:n,isHidden:o,shouldAutoFocusInput:d=!n}=r;return e.jsx(H.ChatAuthProvider,{children:e.jsx(w.ChatBaseEventsProvider,{children:e.jsx(s.Provider,{isHidden:o,shouldAutoFocusInput:d,children:t})})})}function v(r){return e.jsx(T,{...r,children:e.jsx(S,{...r})})}function S(r){const{onToggleView:t,variant:n,header:o=V}=r,d=B.useModal(),l=f.useWidget(),x=d&&!l?L.ModalContent:g.Fragment;return e.jsx(D.ImagePreviewProvider,{children:e.jsx(x,{children:e.jsxs(s.Wrapper,{variant:n??(t?"no-shadow":"container-with-shadow"),"data-composite":p.dataAttr(!!r.onToggleView||d?.isOpen),children:[e.jsx(J,{}),e.jsxs(s.Root,{children:[o&&e.jsx(o,{...r}),e.jsx($,{}),e.jsx(K,{})]}),e.jsx(X,{}),e.jsx(Q,{}),e.jsx(Y,{})]})})})}const V=r=>{const{onToggleView:t,askAILabel:n,searchLabel:o}=r,{aiChatSettings:d}=b.useInkeepConfig(),l=d.isChatHistoryButtonVisible,x=!!t||l;return e.jsx(s.Header,{"data-show-toolbar":p.dataAttr(x),children:x?e.jsxs(s.HeaderToolbar,{"data-show-widget-toggle":p.dataAttr(!!t),children:[e.jsx(s.HeaderToolbarWrapper,{children:l&&e.jsx(s.ChatHistoryTrigger,{})}),t&&e.jsx(W.WidgetToggle,{onToggleView:t,askAILabel:n,searchLabel:o,view:"chat"}),e.jsx(C.Close,{})]}):e.jsx(C.Close,{})})};function $(){const{isSessionLoading:r}=M.useChat();return e.jsx(s.Content,{children:e.jsxs(s.ContentScrollArea,{children:[e.jsx(s.ContentScrollAreaViewport,{children:r?e.jsx(s.MessagesSessionLoading,{}):e.jsx(R,{})}),e.jsx(s.ContentScrollAreaScrollbar,{children:e.jsx(s.ContentScrollAreaThumb,{})}),e.jsx(s.ContentScrollAreaCorner,{})]})})}function R(){const{aiChatSettings:{components:r}}=b.useInkeepConfig();return e.jsx(s.Messages,{children:({messages:t,isLoading:n,isStreaming:o})=>{const d=t.at(-1),l=(c,h)=>{const j=r?.[c];if(!j)return console.warn(`Component "${c}" not found in components config`),null;try{if(typeof j=="function"&&j.length<=1)return g.createElement(j,h);const u=j(h,document.createElement("div"),null);return g.isValidElement(u)||typeof u=="string"?u:null}catch(u){return console.error(`🔍 [renderComponent] Error rendering component "${c}":`,u),null}},x=c=>e.jsx(s.Markdown,{text:c});return e.jsxs(e.Fragment,{children:[e.jsx(_,{}),t.map(c=>{const h=d?.id===c.id;return e.jsxs(s.MessageWrapper,{message:c,children:[e.jsx(F,{}),e.jsxs(s.MessageContentWrapper,{children:[e.jsx(s.MessageContent,{children:r?.IkpMessage?e.jsx(s.DynamicComponent,{name:"IkpMessage",props:{message:c,renderComponent:l,renderMarkdown:x},componentDef:r.IkpMessage}):e.jsxs(e.Fragment,{children:[e.jsx(I.EmbeddedChatMessagePart,{isLast:h}),(!o||!h)&&e.jsx(G,{})]})}),e.jsx(O,{}),e.jsx(U,{})]})]},c.id)}),n&&d?.role==="user"&&d?.parts.length&&e.jsxs(s.MessageWrapper,{message:{id:"___loader___",role:"assistant",parts:[{type:"text",text:"Thinking..."}]},children:[e.jsx(F,{}),e.jsx(s.MessageLoading,{})]})]})}})}function _(){return e.jsxs(s.IntroMessageWrapper,{children:[e.jsxs(s.MessageHeader,{children:[e.jsx(s.MessageAvatar,{children:e.jsx(s.MessageAvatarContent,{children:e.jsx(s.MessageAvatarImage,{})})}),e.jsx(s.MessageName,{})]}),e.jsxs(s.MessageContentWrapper,{children:[e.jsx(s.MessageContent,{children:e.jsx(I.EmbeddedChatMessagePart,{isLast:!1})}),e.jsxs(s.Disclaimer,{children:[e.jsx(s.DisclaimerLabel,{}),e.jsx(s.DisclaimerTrigger,{}),e.jsxs(s.DisclaimerContent,{children:[e.jsx(s.DisclaimerText,{}),e.jsx(s.DisclaimerArrow,{})]})]}),e.jsxs(s.ExampleQuestions,{children:[e.jsx(s.ExampleQuestionsLabel,{}),e.jsx(s.ExampleQuestionsList,{children:r=>r.map(t=>e.jsx(s.ExampleQuestion,{children:e.jsx(s.ExampleQuestionButton,{question:t})},typeof t=="object"?t.label:t))})]})]})]})}function F(){return e.jsxs(s.MessageHeader,{children:[e.jsx(s.MessageAvatar,{children:e.jsx(s.MessageAvatarContent,{children:e.jsx(s.MessageAvatarImage,{})})}),e.jsx(s.MessageName,{})]})}function Q(){return e.jsx(E.PortalWithTheme,{children:e.jsx(m.EmbeddedChatImagePreviewModal,{children:e.jsx(m.EmbeddedChatImagePreviewModalOverlay,{children:e.jsxs(m.EmbeddedChatImagePreviewModalContent,{children:[e.jsx(m.EmbeddedChatImagePreviewModalClose,{}),e.jsx(m.EmbeddedChatImagePreviewModalImage,{}),e.jsx(m.EmbeddedChatImagePreviewModalFooter,{children:e.jsx(m.EmbeddedChatImagePreviewModalFileName,{})})]})})})})}function O(){return e.jsx(i.EmbeddedChatMessageFiles,{children:r=>r.map((t,n)=>{const o=t.url,d=t.mediaType??"",l=d.split("/").pop(),x=t.filename??(l?`untitled.${l}`:"untitled"),c=y.isImageMimeType(d);return e.jsxs(i.EmbeddedChatMessageFile,{url:o,name:x,mediaType:d,children:[c?e.jsx(i.EmbeddedChatFileThumbnail,{}):e.jsx(i.EmbeddedChatFileTypeIcon,{}),e.jsx(i.EmbeddedChatFileName,{})]},o||n)})})}function U(){return e.jsxs(s.MessageToolbar,{children:[e.jsx(s.MessageCustomActions,{children:r=>r.map((t,n)=>e.jsx(s.MessageCustomAction,{action:t},`action-${n}`))}),e.jsx(s.MessageAction,{action:"copy"}),e.jsx(s.MessageAction,{action:"upvote"}),e.jsx(s.MessageAction,{action:"downvote"})]})}function G(){return e.jsxs(s.MessageSources,{children:[e.jsx(s.MessageSourcesHeader,{}),e.jsx(s.MessageSourcesList,{children:r=>r.map((t,n)=>e.jsxs(s.MessageSourceItem,{href:t.url,source:t,children:[e.jsx(s.MessageSourceItemBreadcrumbs,{children:t.breadcrumbs?.map(o=>e.jsxs(g.Fragment,{children:[o,e.jsx(s.MessageSourceItemBreadcrumbIcon,{})]},o))}),e.jsx(s.MessageSourceItemIcon,{}),e.jsx(s.MessageSourceItemTitle,{}),e.jsx(s.MessageSourceItemTag,{}),e.jsx(s.MessageSourceItemDescription,{children:o=>o.map((d,l)=>e.jsx(s.MessageSourceItemDescriptionPart,{descriptionPart:d},`part-${l}`))}),e.jsx(s.MessageSourceItemIndicator,{})]},n))})]})}function K(){return e.jsxs(s.Footer,{children:[e.jsx(i.EmbeddedChatInputNotification,{children:e.jsxs(i.EmbeddedChatInputNotificationContent,{children:[e.jsxs(i.EmbeddedChatInputNotificationHeader,{children:[e.jsx(i.EmbeddedChatInputNotificationTitle,{}),e.jsx(i.EmbeddedChatInputNotificationClose,{})]}),e.jsx(i.EmbeddedChatInputNotificationMessage,{})]})}),e.jsx(Z,{}),e.jsx(z,{})]})}function Z(){return e.jsxs(s.InputFieldset,{children:[e.jsx(i.EmbeddedChatFileInput,{}),e.jsx(i.EmbeddedChatDropZone,{children:"Drop files here to add to chat"}),e.jsx(i.EmbeddedChatFileList,{children:r=>r.map((t,n)=>{const o=y.isImageMimeType(t.type);return e.jsxs(i.EmbeddedChatFileItem,{file:t,children:[o?e.jsxs(i.EmbeddedChatFilePreviewTrigger,{children:[e.jsx(i.EmbeddedChatFileThumbnail,{}),e.jsx(i.EmbeddedChatFileName,{})]}):e.jsxs(i.EmbeddedChatFileContent,{children:[e.jsx(i.EmbeddedChatFileTypeIcon,{}),e.jsx(i.EmbeddedChatFileName,{})]}),e.jsx(i.EmbeddedChatFileRemove,{})]},`${t.name}-${t.lastModified}-${n}`)})}),e.jsxs(s.InputGroup,{children:[e.jsx(i.EmbeddedChatFileUploadButton,{}),e.jsx(s.Input,{}),e.jsx(s.SendButton,{children:e.jsx(s.SendButtonIcon,{})})]})]})}function z(){return e.jsxs(s.ActionBar,{children:[e.jsxs(s.TaglineContainer,{children:[e.jsx(s.TaglineText,{}),e.jsx(s.TaglineLogo,{})]}),e.jsxs(s.Actions,{children:[e.jsx(s.HelpActions,{children:({pinned:r,unpinned:t})=>e.jsxs(e.Fragment,{children:[r.map(n=>e.jsx(s.HelpAction,{action:n},n.name)),t.length>0&&e.jsx(s.HelpActionsTrigger,{}),e.jsxs(s.HelpActionsMenu,{children:[e.jsx(s.HelpActionsMenuArrow,{}),t.map(n=>e.jsxs(s.HelpActionsMenuItem,{action:n,children:[e.jsx(s.HelpActionsMenuItemIcon,{action:n}),n.name]},n.name))]})]})}),e.jsxs(s.ChatAction,{action:"copy",children:[e.jsx(s.ChatActionLabel,{action:"copy"}),e.jsx(s.ChatActionFeedback,{action:"copy"})]}),e.jsx(s.ChatAction,{action:"clear"}),e.jsx(s.ChatAction,{action:"stop"})]})]})}function J(){const{sessions:r}=k.useChatHistory(),{conversationId:t}=M.useChat();return e.jsxs(a.EmbeddedChatHistoryRoot,{children:[e.jsxs(a.EmbeddedChatHistoryHeader,{children:[e.jsxs(a.EmbeddedChatHistoryBackButton,{children:[e.jsx(a.EmbeddedChatHistoryBackButtonIcon,{iconKey:"backToChat"}),"Back to chat"]}),e.jsx(a.EmbeddedChatHistoryTitle,{}),e.jsx(C.Close,{})]}),e.jsxs(a.EmbeddedChatHistoryList,{children:[r.map(n=>e.jsxs(a.EmbeddedChatHistoryItem,{sessionId:n.id,"data-active":p.dataAttr(n.id===t),children:[e.jsx(a.EmbeddedChatHistoryItemTitle,{children:n.title}),e.jsx(a.EmbeddedChatHistoryItemDate,{children:a.formatSessionDate(n.updatedAt)})]},n.id)),e.jsx(a.EmbeddedChatHistoryEmptyState,{}),e.jsx(a.EmbeddedChatHistoryLoadingState,{})]}),e.jsx(a.EmbeddedChatHistoryFooter,{children:e.jsx(a.EmbeddedChatHistoryNewConversationButton,{})})]})}function X(){return e.jsx(E.PortalWithTheme,{children:e.jsx(s.FeedbackModal,{children:e.jsx(s.FeedbackModalOverlay,{children:e.jsxs(s.FeedbackModalContent,{children:[e.jsx(s.FeedbackModalHeader,{}),e.jsx(s.FeedbackModalClose,{}),e.jsx(s.FeedbackModalBody,{children:e.jsxs(s.FeedbackForm,{children:[e.jsxs(s.FeedbackField,{children:[e.jsx(s.FeedbackItemLabel,{}),e.jsx(s.FeedbackItemDescription,{})]}),e.jsx(s.FeedbackSubmitButton,{})]})})]})})})})}function Y(){return e.jsxs(s.FormWrapper,{children:[e.jsx(s.FormClose,{}),e.jsxs(s.Form,{children:[e.jsxs(s.FormHeader,{children:[e.jsx(s.FormHeading,{}),e.jsx(s.FormDescription,{})]}),e.jsx(s.FormContent,{children:r=>e.jsxs(e.Fragment,{children:[r.map((t,n)=>e.jsxs(s.FormField,{field:t,autoFocus:n===0,children:[e.jsx(s.FormFieldLabel,{}),t.inputType==="text"&&e.jsx(s.FormFieldText,{}),t.inputType==="email"&&e.jsx(s.FormFieldEmail,{}),t.inputType==="file"&&e.jsx(s.FormFieldFile,{}),t.inputType==="textarea"&&e.jsx(s.FormFieldTextArea,{}),t.inputType==="checkbox"&&e.jsx(s.FormFieldCheckbox,{children:e.jsx(s.FormFieldCheckboxIndicator,{})}),t.inputType==="select"&&e.jsxs(s.FormFieldSelect,{children:[e.jsxs(s.FormFieldSelectTrigger,{children:[e.jsx(s.FormFieldSelectValue,{}),e.jsx(s.FormFieldSelectIcon,{})]}),e.jsx(s.FormFieldSelectContent,{children:e.jsx(s.FormFieldSelectViewport,{children:t.items.map(o=>e.jsxs(s.FormFieldSelectItem,{value:o.value,children:[e.jsx(s.FormFieldSelectItemText,{children:o.label}),e.jsx(s.FormFieldSelectItemIndicator,{})]},o.value))})})]}),t.inputType==="combobox"&&e.jsxs(s.FormFieldCombobox,{children:[e.jsxs(s.FormFieldComboboxControl,{children:["multiple"in t&&t.multiple&&e.jsx(s.FormFieldComboboxSelectedTags,{}),e.jsx(s.FormFieldComboboxInput,{}),e.jsx(s.FormFieldComboboxTrigger,{})]}),e.jsx(s.FormFieldComboboxPositioner,{children:e.jsx(s.FormFieldComboboxContent,{children:e.jsx(s.FormFieldComboboxList,{children:e.jsx(s.FormFieldComboboxListItems,{children:o=>o.length===0?e.jsx(s.FormFieldComboboxListEmpty,{}):o.map(d=>e.jsxs(s.FormFieldComboboxItem,{item:d,children:[e.jsx(s.FormFieldComboboxItemText,{children:d.label}),e.jsx(s.FormFieldComboboxItemIndicator,{})]},d.value))})})})})]}),e.jsx(s.FormFieldDescription,{}),e.jsx(s.FormFieldError,{})]},t.name)),e.jsx(s.FormError,{})]})}),e.jsxs(s.FormFooter,{children:[e.jsx(s.FormCancel,{}),e.jsx(s.FormSubmit,{})]})]}),e.jsxs(s.FormSuccess,{children:[e.jsx(s.FormSuccessHeading,{}),e.jsx(s.FormSuccessMessage,{}),e.jsx(s.FormSuccessButton,{})]})]})}exports.InkeepEmbeddedChat=N;exports.InkeepEmbeddedChatImpl=v;exports.InkeepEmbeddedChatImplContent=S;exports.InkeepEmbeddedChatProvider=T;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),s=require("../styled/components/embedded-chat.cjs"),a=require("../styled/components/chat-history.cjs"),b=require("../styled/components/modal.cjs"),w=require("../styled/components/shadow.cjs"),E=require("../styled/components/message.cjs"),k=require("../primitives/providers/chat-auth-provider.cjs"),P=require("../primitives/providers/chat-base-events-provider.cjs"),f=require("../primitives/providers/chat-history-provider.cjs"),F=require("../primitives/providers/config-provider.cjs"),B=require("../primitives/providers/root-provider.cjs"),q=require("../primitives/providers/widget-provider.cjs"),y=require("../primitives/components/embedded-chat/chat-provider.cjs"),L=require("../primitives/components/modal/modal-provider.cjs"),g=require("../primitives/utils/misc.cjs"),T=require("../primitives/atoms/portal-with-theme.cjs"),D=require("../primitives/atoms/error-boundary.cjs"),W=require("./modal.cjs"),N=require("../primitives/providers/image-preview-provider.cjs"),V=require("./widget-toggle.cjs"),v=require("../primitives/components/embedded-chat/file-upload-input.cjs"),i=require("../styled/components/embedded-chat/file-upload-input.cjs"),m=require("../styled/components/embedded-chat/image-preview-modal.cjs");function R(r){const{baseSettings:t,aiChatSettings:n}=r;return e.jsx(D.ErrorBoundary,{children:e.jsx(w.Shadow,{wrapperStyles:{height:"inherit",width:"inherit"},children:e.jsx(B.RootProvider,{config:{baseSettings:t,aiChatSettings:n},componentType:F.WebWidgetInteractionType.EmbeddedChat,children:e.jsx(A,{...r})})})})}function S(r){const{children:t,onToggleView:n,isHidden:o,shouldAutoFocusInput:d=!n}=r;return e.jsx(k.ChatAuthProvider,{children:e.jsx(P.ChatBaseEventsProvider,{children:e.jsx(s.Provider,{isHidden:o,shouldAutoFocusInput:d,children:t})})})}function A(r){return e.jsx(S,{...r,children:e.jsx(H,{...r})})}function H(r){const{onToggleView:t,variant:n,header:o=$}=r,d=L.useModal(),c=q.useWidget(),x=d&&!c?W.ModalContent:p.Fragment;return e.jsx(N.ImagePreviewProvider,{children:e.jsx(x,{children:e.jsxs(s.Wrapper,{variant:n??(t?"no-shadow":"container-with-shadow"),"data-composite":g.dataAttr(!!r.onToggleView||d?.isOpen),children:[e.jsx(Y,{}),e.jsxs(s.Root,{children:[o&&e.jsx(o,{...r}),e.jsx(_,{}),e.jsx(z,{})]}),e.jsx(ee,{}),e.jsx(U,{}),e.jsx(se,{})]})})})}const $=r=>{const{onToggleView:t,askAILabel:n,searchLabel:o}=r,{aiChatSettings:d}=F.useInkeepConfig(),c=d.isChatHistoryButtonVisible,x=!!t||c;return e.jsx(s.Header,{"data-show-toolbar":g.dataAttr(x),children:x?e.jsxs(s.HeaderToolbar,{"data-show-widget-toggle":g.dataAttr(!!t),children:[e.jsx(s.HeaderToolbarWrapper,{children:c&&e.jsx(s.ChatHistoryTrigger,{})}),t&&e.jsx(V.WidgetToggle,{onToggleView:t,askAILabel:n,searchLabel:o,view:"chat"}),e.jsx(b.Close,{})]}):e.jsx(b.Close,{})})};function _(){const{isSessionLoading:r}=y.useChat();return e.jsx(s.Content,{children:e.jsxs(s.ContentScrollArea,{children:[e.jsx(s.ContentScrollAreaViewport,{children:r?e.jsx(s.MessagesSessionLoading,{}):e.jsx(Q,{})}),e.jsx(s.ContentScrollAreaScrollbar,{children:e.jsx(s.ContentScrollAreaThumb,{})}),e.jsx(s.ContentScrollAreaCorner,{})]})})}function Q(){const{aiChatSettings:{components:r}}=F.useInkeepConfig();return e.jsx(s.Messages,{children:({messages:t,isLoading:n,isStreaming:o})=>{const d=t.at(-1),c=l=>(h,C)=>{const j=r?.[h];if(!j)return console.warn(`Component "${h}" not found in components config`),null;const I={...C,messageId:l.id};try{if(typeof j=="function"&&j.length<=1)return p.createElement(j,I);const u=j(I,document.createElement("div"),null);return p.isValidElement(u)||typeof u=="string"?u:null}catch(u){return console.error(`🔍 [renderComponent] Error rendering component "${h}":`,u),null}},x=l=>e.jsx(s.Markdown,{text:l});return e.jsxs(e.Fragment,{children:[e.jsx(O,{}),t.map(l=>{const h=d?.id===l.id,C=c(l);return e.jsxs(s.MessageWrapper,{message:l,children:[e.jsx(M,{}),e.jsxs(s.MessageContentWrapper,{children:[e.jsx(s.MessageContent,{children:r?.IkpMessage?e.jsx(s.DynamicComponent,{name:"IkpMessage",props:{message:l,renderComponent:C,renderMarkdown:x},componentDef:r.IkpMessage}):e.jsxs(e.Fragment,{children:[e.jsx(E.EmbeddedChatMessagePart,{isLast:h}),(!o||!h)&&e.jsx(Z,{})]})}),e.jsx(G,{}),e.jsx(K,{})]})]},l.id)}),n&&d?.role==="user"&&d?.parts.length&&e.jsxs(s.MessageWrapper,{message:{id:"___loader___",role:"assistant",parts:[{type:"text",text:"Thinking..."}]},children:[e.jsx(M,{}),e.jsx(s.MessageLoading,{})]})]})}})}function O(){return e.jsxs(s.IntroMessageWrapper,{children:[e.jsxs(s.MessageHeader,{children:[e.jsx(s.MessageAvatar,{children:e.jsx(s.MessageAvatarContent,{children:e.jsx(s.MessageAvatarImage,{})})}),e.jsx(s.MessageName,{})]}),e.jsxs(s.MessageContentWrapper,{children:[e.jsx(s.MessageContent,{children:e.jsx(E.EmbeddedChatMessagePart,{isLast:!1})}),e.jsxs(s.Disclaimer,{children:[e.jsx(s.DisclaimerLabel,{}),e.jsx(s.DisclaimerTrigger,{}),e.jsxs(s.DisclaimerContent,{children:[e.jsx(s.DisclaimerText,{}),e.jsx(s.DisclaimerArrow,{})]})]}),e.jsxs(s.ExampleQuestions,{children:[e.jsx(s.ExampleQuestionsLabel,{}),e.jsx(s.ExampleQuestionsList,{children:r=>r.map(t=>e.jsx(s.ExampleQuestion,{children:e.jsx(s.ExampleQuestionButton,{question:t})},typeof t=="object"?t.label:t))})]})]})]})}function M(){return e.jsxs(s.MessageHeader,{children:[e.jsx(s.MessageAvatar,{children:e.jsx(s.MessageAvatarContent,{children:e.jsx(s.MessageAvatarImage,{})})}),e.jsx(s.MessageName,{})]})}function U(){return e.jsx(T.PortalWithTheme,{children:e.jsx(m.EmbeddedChatImagePreviewModal,{children:e.jsx(m.EmbeddedChatImagePreviewModalOverlay,{children:e.jsxs(m.EmbeddedChatImagePreviewModalContent,{children:[e.jsx(m.EmbeddedChatImagePreviewModalClose,{}),e.jsx(m.EmbeddedChatImagePreviewModalImage,{}),e.jsx(m.EmbeddedChatImagePreviewModalFooter,{children:e.jsx(m.EmbeddedChatImagePreviewModalFileName,{})})]})})})})}function G(){return e.jsx(i.EmbeddedChatMessageFiles,{children:r=>r.map((t,n)=>{const o=t.url,d=t.mediaType??"",c=d.split("/").pop(),x=t.filename??(c?`untitled.${c}`:"untitled"),l=v.isImageMimeType(d);return e.jsxs(i.EmbeddedChatMessageFile,{url:o,name:x,mediaType:d,children:[l?e.jsx(i.EmbeddedChatFileThumbnail,{}):e.jsx(i.EmbeddedChatFileTypeIcon,{}),e.jsx(i.EmbeddedChatFileName,{})]},o||n)})})}function K(){return e.jsxs(s.MessageToolbar,{children:[e.jsx(s.MessageCustomActions,{children:r=>r.map((t,n)=>e.jsx(s.MessageCustomAction,{action:t},`action-${n}`))}),e.jsx(s.MessageAction,{action:"copy"}),e.jsx(s.MessageAction,{action:"upvote"}),e.jsx(s.MessageAction,{action:"downvote"})]})}function Z(){return e.jsxs(s.MessageSources,{children:[e.jsx(s.MessageSourcesHeader,{}),e.jsx(s.MessageSourcesList,{children:r=>r.map((t,n)=>e.jsxs(s.MessageSourceItem,{href:t.url,source:t,children:[e.jsx(s.MessageSourceItemBreadcrumbs,{children:t.breadcrumbs?.map(o=>e.jsxs(p.Fragment,{children:[o,e.jsx(s.MessageSourceItemBreadcrumbIcon,{})]},o))}),e.jsx(s.MessageSourceItemIcon,{}),e.jsx(s.MessageSourceItemTitle,{}),e.jsx(s.MessageSourceItemTag,{}),e.jsx(s.MessageSourceItemDescription,{children:o=>o.map((d,c)=>e.jsx(s.MessageSourceItemDescriptionPart,{descriptionPart:d},`part-${c}`))}),e.jsx(s.MessageSourceItemIndicator,{})]},n))})]})}function z(){return e.jsxs(s.Footer,{children:[e.jsx(i.EmbeddedChatInputNotification,{children:e.jsxs(i.EmbeddedChatInputNotificationContent,{children:[e.jsxs(i.EmbeddedChatInputNotificationHeader,{children:[e.jsx(i.EmbeddedChatInputNotificationTitle,{}),e.jsx(i.EmbeddedChatInputNotificationClose,{})]}),e.jsx(i.EmbeddedChatInputNotificationMessage,{})]})}),e.jsx(J,{}),e.jsx(X,{})]})}function J(){return e.jsxs(s.InputFieldset,{children:[e.jsx(i.EmbeddedChatFileInput,{}),e.jsx(i.EmbeddedChatDropZone,{children:"Drop files here to add to chat"}),e.jsx(i.EmbeddedChatFileList,{children:r=>r.map((t,n)=>{const o=v.isImageMimeType(t.type);return e.jsxs(i.EmbeddedChatFileItem,{file:t,children:[o?e.jsxs(i.EmbeddedChatFilePreviewTrigger,{children:[e.jsx(i.EmbeddedChatFileThumbnail,{}),e.jsx(i.EmbeddedChatFileName,{})]}):e.jsxs(i.EmbeddedChatFileContent,{children:[e.jsx(i.EmbeddedChatFileTypeIcon,{}),e.jsx(i.EmbeddedChatFileName,{})]}),e.jsx(i.EmbeddedChatFileRemove,{})]},`${t.name}-${t.lastModified}-${n}`)})}),e.jsxs(s.InputGroup,{children:[e.jsx(i.EmbeddedChatFileUploadButton,{}),e.jsx(s.Input,{}),e.jsx(s.SendButton,{children:e.jsx(s.SendButtonIcon,{})})]})]})}function X(){return e.jsxs(s.ActionBar,{children:[e.jsxs(s.TaglineContainer,{children:[e.jsx(s.TaglineText,{}),e.jsx(s.TaglineLogo,{})]}),e.jsxs(s.Actions,{children:[e.jsx(s.HelpActions,{children:({pinned:r,unpinned:t})=>e.jsxs(e.Fragment,{children:[r.map(n=>e.jsx(s.HelpAction,{action:n},n.name)),t.length>0&&e.jsx(s.HelpActionsTrigger,{}),e.jsxs(s.HelpActionsMenu,{children:[e.jsx(s.HelpActionsMenuArrow,{}),t.map(n=>e.jsxs(s.HelpActionsMenuItem,{action:n,children:[e.jsx(s.HelpActionsMenuItemIcon,{action:n}),n.name]},n.name))]})]})}),e.jsxs(s.ChatAction,{action:"copy",children:[e.jsx(s.ChatActionLabel,{action:"copy"}),e.jsx(s.ChatActionFeedback,{action:"copy"})]}),e.jsx(s.ChatAction,{action:"clear"}),e.jsx(s.ChatAction,{action:"stop"})]})]})}function Y(){const{sessions:r}=f.useChatHistory(),{conversationId:t}=y.useChat();return e.jsxs(a.EmbeddedChatHistoryRoot,{children:[e.jsxs(a.EmbeddedChatHistoryHeader,{children:[e.jsxs(a.EmbeddedChatHistoryBackButton,{children:[e.jsx(a.EmbeddedChatHistoryBackButtonIcon,{iconKey:"backToChat"}),"Back to chat"]}),e.jsx(a.EmbeddedChatHistoryTitle,{}),e.jsx(b.Close,{})]}),e.jsxs(a.EmbeddedChatHistoryList,{children:[r.map(n=>e.jsxs(a.EmbeddedChatHistoryItem,{sessionId:n.id,"data-active":g.dataAttr(n.id===t),children:[e.jsx(a.EmbeddedChatHistoryItemTitle,{children:n.title}),e.jsx(a.EmbeddedChatHistoryItemDate,{children:a.formatSessionDate(n.updatedAt)})]},n.id)),e.jsx(a.EmbeddedChatHistoryEmptyState,{}),e.jsx(a.EmbeddedChatHistoryLoadingState,{})]}),e.jsx(a.EmbeddedChatHistoryFooter,{children:e.jsx(a.EmbeddedChatHistoryNewConversationButton,{})})]})}function ee(){return e.jsx(T.PortalWithTheme,{children:e.jsx(s.FeedbackModal,{children:e.jsx(s.FeedbackModalOverlay,{children:e.jsxs(s.FeedbackModalContent,{children:[e.jsx(s.FeedbackModalHeader,{}),e.jsx(s.FeedbackModalClose,{}),e.jsx(s.FeedbackModalBody,{children:e.jsxs(s.FeedbackForm,{children:[e.jsxs(s.FeedbackField,{children:[e.jsx(s.FeedbackItemLabel,{}),e.jsx(s.FeedbackItemDescription,{})]}),e.jsx(s.FeedbackSubmitButton,{})]})})]})})})})}function se(){return e.jsxs(s.FormWrapper,{children:[e.jsx(s.FormClose,{}),e.jsxs(s.Form,{children:[e.jsxs(s.FormHeader,{children:[e.jsx(s.FormHeading,{}),e.jsx(s.FormDescription,{})]}),e.jsx(s.FormContent,{children:r=>e.jsxs(e.Fragment,{children:[r.map((t,n)=>e.jsxs(s.FormField,{field:t,autoFocus:n===0,children:[e.jsx(s.FormFieldLabel,{}),t.inputType==="text"&&e.jsx(s.FormFieldText,{}),t.inputType==="email"&&e.jsx(s.FormFieldEmail,{}),t.inputType==="file"&&e.jsx(s.FormFieldFile,{}),t.inputType==="textarea"&&e.jsx(s.FormFieldTextArea,{}),t.inputType==="checkbox"&&e.jsx(s.FormFieldCheckbox,{children:e.jsx(s.FormFieldCheckboxIndicator,{})}),t.inputType==="select"&&e.jsxs(s.FormFieldSelect,{children:[e.jsxs(s.FormFieldSelectTrigger,{children:[e.jsx(s.FormFieldSelectValue,{}),e.jsx(s.FormFieldSelectIcon,{})]}),e.jsx(s.FormFieldSelectContent,{children:e.jsx(s.FormFieldSelectViewport,{children:t.items.map(o=>e.jsxs(s.FormFieldSelectItem,{value:o.value,children:[e.jsx(s.FormFieldSelectItemText,{children:o.label}),e.jsx(s.FormFieldSelectItemIndicator,{})]},o.value))})})]}),t.inputType==="combobox"&&e.jsxs(s.FormFieldCombobox,{children:[e.jsxs(s.FormFieldComboboxControl,{children:["multiple"in t&&t.multiple&&e.jsx(s.FormFieldComboboxSelectedTags,{}),e.jsx(s.FormFieldComboboxInput,{}),e.jsx(s.FormFieldComboboxTrigger,{})]}),e.jsx(s.FormFieldComboboxPositioner,{children:e.jsx(s.FormFieldComboboxContent,{children:e.jsx(s.FormFieldComboboxList,{children:e.jsx(s.FormFieldComboboxListItems,{children:o=>o.length===0?e.jsx(s.FormFieldComboboxListEmpty,{}):o.map(d=>e.jsxs(s.FormFieldComboboxItem,{item:d,children:[e.jsx(s.FormFieldComboboxItemText,{children:d.label}),e.jsx(s.FormFieldComboboxItemIndicator,{})]},d.value))})})})})]}),e.jsx(s.FormFieldDescription,{}),e.jsx(s.FormFieldError,{})]},t.name)),e.jsx(s.FormError,{})]})}),e.jsxs(s.FormFooter,{children:[e.jsx(s.FormCancel,{}),e.jsx(s.FormSubmit,{})]})]}),e.jsxs(s.FormSuccess,{children:[e.jsx(s.FormSuccessHeading,{}),e.jsx(s.FormSuccessMessage,{}),e.jsx(s.FormSuccessButton,{})]})]})}exports.InkeepEmbeddedChat=R;exports.InkeepEmbeddedChatImpl=A;exports.InkeepEmbeddedChatImplContent=H;exports.InkeepEmbeddedChatProvider=S;
|
|
@@ -1,85 +1,85 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as e, jsxs as d, Fragment as b } from "react/jsx-runtime";
|
|
3
|
-
import
|
|
4
|
-
import { Wrapper as
|
|
5
|
-
import { EmbeddedChatHistoryRoot as
|
|
3
|
+
import M, { Fragment as x } from "react";
|
|
4
|
+
import { Wrapper as Q, Root as $, Provider as _, Header as R, HeaderToolbar as O, HeaderToolbarWrapper as j, ChatHistoryTrigger as G, Content as U, ContentScrollArea as K, ContentScrollAreaViewport as Z, MessagesSessionLoading as z, ContentScrollAreaScrollbar as J, ContentScrollAreaThumb as X, ContentScrollAreaCorner as Y, Footer as q, FeedbackModal as ee, FeedbackModalOverlay as de, FeedbackModalContent as te, FeedbackModalHeader as ae, FeedbackModalClose as oe, FeedbackModalBody as re, FeedbackForm as ne, FeedbackField as ie, FeedbackItemLabel as me, FeedbackItemDescription as se, FeedbackSubmitButton as le, FormWrapper as ce, FormClose as he, Form as be, FormHeader as Ce, FormHeading as Fe, FormDescription as Ee, FormContent as pe, FormField as ue, FormFieldLabel as ge, FormFieldText as Ie, FormFieldEmail as Me, FormFieldFile as Se, FormFieldTextArea as Te, FormFieldCheckbox as xe, FormFieldCheckboxIndicator as Ae, FormFieldSelect as He, FormFieldSelectTrigger as fe, FormFieldSelectValue as ye, FormFieldSelectIcon as ke, FormFieldSelectContent as ve, FormFieldSelectViewport as we, FormFieldSelectItem as Le, FormFieldSelectItemText as Be, FormFieldSelectItemIndicator as De, FormFieldCombobox as Pe, FormFieldComboboxControl as We, FormFieldComboboxSelectedTags as Ve, FormFieldComboboxInput as Ne, FormFieldComboboxTrigger as Qe, FormFieldComboboxPositioner as $e, FormFieldComboboxContent as _e, FormFieldComboboxList as Re, FormFieldComboboxListItems as Oe, FormFieldComboboxListEmpty as je, FormFieldComboboxItem as Ge, FormFieldComboboxItemText as Ue, FormFieldComboboxItemIndicator as Ke, FormFieldDescription as Ze, FormFieldError as ze, FormError as Je, FormFooter as Xe, FormCancel as Ye, FormSubmit as qe, FormSuccess as ed, FormSuccessHeading as dd, FormSuccessMessage as td, FormSuccessButton as ad, Messages as od, MessageWrapper as S, MessageContentWrapper as A, MessageContent as H, DynamicComponent as rd, MessageLoading as nd, InputFieldset as id, InputGroup as md, Input as sd, SendButton as ld, SendButtonIcon as cd, ActionBar as hd, TaglineContainer as bd, TaglineText as Cd, TaglineLogo as Fd, Actions as Ed, HelpActions as pd, HelpAction as ud, HelpActionsTrigger as gd, HelpActionsMenu as Id, HelpActionsMenuArrow as Md, HelpActionsMenuItem as Sd, HelpActionsMenuItemIcon as Td, ChatAction as E, ChatActionLabel as xd, ChatActionFeedback as Ad, IntroMessageWrapper as Hd, MessageHeader as f, MessageAvatar as y, MessageAvatarContent as k, MessageAvatarImage as v, MessageName as w, Disclaimer as fd, DisclaimerLabel as yd, DisclaimerTrigger as kd, DisclaimerContent as vd, DisclaimerText as wd, DisclaimerArrow as Ld, ExampleQuestions as Bd, ExampleQuestionsLabel as Dd, ExampleQuestionsList as Pd, ExampleQuestion as Wd, ExampleQuestionButton as Vd, Markdown as Nd, MessageSources as Qd, MessageSourcesHeader as $d, MessageSourcesList as _d, MessageSourceItem as Rd, MessageSourceItemBreadcrumbs as Od, MessageSourceItemBreadcrumbIcon as jd, MessageSourceItemIcon as Gd, MessageSourceItemTitle as Ud, MessageSourceItemTag as Kd, MessageSourceItemDescription as Zd, MessageSourceItemDescriptionPart as zd, MessageSourceItemIndicator as Jd, MessageToolbar as Xd, MessageCustomActions as Yd, MessageCustomAction as qd, MessageAction as p } from "../styled/components/embedded-chat.js";
|
|
5
|
+
import { EmbeddedChatHistoryRoot as et, EmbeddedChatHistoryHeader as dt, EmbeddedChatHistoryBackButton as tt, EmbeddedChatHistoryBackButtonIcon as at, EmbeddedChatHistoryTitle as ot, EmbeddedChatHistoryList as rt, EmbeddedChatHistoryItem as nt, EmbeddedChatHistoryItemTitle as it, EmbeddedChatHistoryItemDate as mt, formatSessionDate as st, EmbeddedChatHistoryEmptyState as lt, EmbeddedChatHistoryLoadingState as ct, EmbeddedChatHistoryFooter as ht, EmbeddedChatHistoryNewConversationButton as bt } from "../styled/components/chat-history.js";
|
|
6
6
|
import { Close as u } from "../styled/components/modal.js";
|
|
7
|
-
import { Shadow as
|
|
8
|
-
import { EmbeddedChatMessagePart as
|
|
9
|
-
import { ChatAuthProvider as
|
|
10
|
-
import { ChatBaseEventsProvider as
|
|
11
|
-
import { useChatHistory as
|
|
12
|
-
import { WebWidgetInteractionType as
|
|
13
|
-
import { RootProvider as
|
|
14
|
-
import { useWidget as
|
|
15
|
-
import { useChat as
|
|
16
|
-
import { useModal as
|
|
7
|
+
import { Shadow as Ct } from "../styled/components/shadow.js";
|
|
8
|
+
import { EmbeddedChatMessagePart as L } from "../styled/components/message.js";
|
|
9
|
+
import { ChatAuthProvider as Ft } from "../primitives/providers/chat-auth-provider.js";
|
|
10
|
+
import { ChatBaseEventsProvider as Et } from "../primitives/providers/chat-base-events-provider.js";
|
|
11
|
+
import { useChatHistory as pt } from "../primitives/providers/chat-history-provider.js";
|
|
12
|
+
import { WebWidgetInteractionType as ut, useInkeepConfig as B } from "../primitives/providers/config-provider.js";
|
|
13
|
+
import { RootProvider as gt } from "../primitives/providers/root-provider.js";
|
|
14
|
+
import { useWidget as It } from "../primitives/providers/widget-provider.js";
|
|
15
|
+
import { useChat as D } from "../primitives/components/embedded-chat/chat-provider.js";
|
|
16
|
+
import { useModal as Mt } from "../primitives/components/modal/modal-provider.js";
|
|
17
17
|
import { dataAttr as C } from "../primitives/utils/misc.js";
|
|
18
|
-
import { PortalWithTheme as
|
|
19
|
-
import { ErrorBoundary as
|
|
20
|
-
import { ModalContent as
|
|
21
|
-
import { ImagePreviewProvider as
|
|
22
|
-
import { WidgetToggle as
|
|
23
|
-
import { isImageMimeType as
|
|
24
|
-
import { EmbeddedChatInputNotification as
|
|
25
|
-
import { EmbeddedChatImagePreviewModal as
|
|
26
|
-
function
|
|
18
|
+
import { PortalWithTheme as P } from "../primitives/atoms/portal-with-theme.js";
|
|
19
|
+
import { ErrorBoundary as St } from "../primitives/atoms/error-boundary.js";
|
|
20
|
+
import { ModalContent as Tt } from "./modal.js";
|
|
21
|
+
import { ImagePreviewProvider as xt } from "../primitives/providers/image-preview-provider.js";
|
|
22
|
+
import { WidgetToggle as At } from "./widget-toggle.js";
|
|
23
|
+
import { isImageMimeType as W } from "../primitives/components/embedded-chat/file-upload-input.js";
|
|
24
|
+
import { EmbeddedChatInputNotification as Ht, EmbeddedChatInputNotificationContent as ft, EmbeddedChatInputNotificationHeader as yt, EmbeddedChatInputNotificationTitle as kt, EmbeddedChatInputNotificationClose as vt, EmbeddedChatInputNotificationMessage as wt, EmbeddedChatFileInput as Lt, EmbeddedChatDropZone as Bt, EmbeddedChatFileList as Dt, EmbeddedChatFileItem as Pt, EmbeddedChatFilePreviewTrigger as Wt, EmbeddedChatFileThumbnail as V, EmbeddedChatFileName as g, EmbeddedChatFileContent as Vt, EmbeddedChatFileTypeIcon as N, EmbeddedChatFileRemove as Nt, EmbeddedChatFileUploadButton as Qt, EmbeddedChatMessageFiles as $t, EmbeddedChatMessageFile as _t } from "../styled/components/embedded-chat/file-upload-input.js";
|
|
25
|
+
import { EmbeddedChatImagePreviewModal as Rt, EmbeddedChatImagePreviewModalOverlay as Ot, EmbeddedChatImagePreviewModalContent as jt, EmbeddedChatImagePreviewModalClose as Gt, EmbeddedChatImagePreviewModalImage as Ut, EmbeddedChatImagePreviewModalFooter as Kt, EmbeddedChatImagePreviewModalFileName as Zt } from "../styled/components/embedded-chat/image-preview-modal.js";
|
|
26
|
+
function Wa(a) {
|
|
27
27
|
const { baseSettings: t, aiChatSettings: o } = a;
|
|
28
|
-
return /* @__PURE__ */ e(
|
|
29
|
-
|
|
28
|
+
return /* @__PURE__ */ e(St, { children: /* @__PURE__ */ e(
|
|
29
|
+
Ct,
|
|
30
30
|
{
|
|
31
31
|
wrapperStyles: {
|
|
32
32
|
height: "inherit",
|
|
33
33
|
width: "inherit"
|
|
34
34
|
},
|
|
35
35
|
children: /* @__PURE__ */ e(
|
|
36
|
-
|
|
36
|
+
gt,
|
|
37
37
|
{
|
|
38
38
|
config: {
|
|
39
39
|
baseSettings: t,
|
|
40
40
|
aiChatSettings: o
|
|
41
41
|
},
|
|
42
|
-
componentType:
|
|
43
|
-
children: /* @__PURE__ */ e(
|
|
42
|
+
componentType: ut.EmbeddedChat,
|
|
43
|
+
children: /* @__PURE__ */ e(Jt, { ...a })
|
|
44
44
|
}
|
|
45
45
|
)
|
|
46
46
|
}
|
|
47
47
|
) });
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function zt(a) {
|
|
50
50
|
const { children: t, onToggleView: o, isHidden: r, shouldAutoFocusInput: n = !o } = a;
|
|
51
|
-
return /* @__PURE__ */ e(
|
|
51
|
+
return /* @__PURE__ */ e(Ft, { children: /* @__PURE__ */ e(Et, { children: /* @__PURE__ */ e(_, { isHidden: r, shouldAutoFocusInput: n, children: t }) }) });
|
|
52
52
|
}
|
|
53
|
-
function
|
|
54
|
-
return /* @__PURE__ */ e(
|
|
53
|
+
function Jt(a) {
|
|
54
|
+
return /* @__PURE__ */ e(zt, { ...a, children: /* @__PURE__ */ e(Xt, { ...a }) });
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
const { onToggleView: t, variant: o, header: r =
|
|
58
|
-
return /* @__PURE__ */ e(
|
|
59
|
-
|
|
56
|
+
function Xt(a) {
|
|
57
|
+
const { onToggleView: t, variant: o, header: r = Yt } = a, n = Mt(), i = It();
|
|
58
|
+
return /* @__PURE__ */ e(xt, { children: /* @__PURE__ */ e(n && !i ? Tt : x, { children: /* @__PURE__ */ d(
|
|
59
|
+
Q,
|
|
60
60
|
{
|
|
61
61
|
variant: o ?? (t ? "no-shadow" : "container-with-shadow"),
|
|
62
62
|
"data-composite": C(!!a.onToggleView || n?.isOpen),
|
|
63
63
|
children: [
|
|
64
|
-
/* @__PURE__ */ e(
|
|
65
|
-
/* @__PURE__ */ d(
|
|
64
|
+
/* @__PURE__ */ e(sa, {}),
|
|
65
|
+
/* @__PURE__ */ d($, { children: [
|
|
66
66
|
r && /* @__PURE__ */ e(r, { ...a }),
|
|
67
|
-
/* @__PURE__ */ e(
|
|
68
|
-
/* @__PURE__ */ e(
|
|
67
|
+
/* @__PURE__ */ e(qt, {}),
|
|
68
|
+
/* @__PURE__ */ e(na, {})
|
|
69
69
|
] }),
|
|
70
|
-
/* @__PURE__ */ e(
|
|
71
|
-
/* @__PURE__ */ e(
|
|
72
|
-
/* @__PURE__ */ e(
|
|
70
|
+
/* @__PURE__ */ e(la, {}),
|
|
71
|
+
/* @__PURE__ */ e(ta, {}),
|
|
72
|
+
/* @__PURE__ */ e(ca, {})
|
|
73
73
|
]
|
|
74
74
|
}
|
|
75
75
|
) }) });
|
|
76
76
|
}
|
|
77
|
-
const
|
|
78
|
-
const { onToggleView: t, askAILabel: o, searchLabel: r } = a, { aiChatSettings: n } =
|
|
79
|
-
return /* @__PURE__ */ e(
|
|
80
|
-
/* @__PURE__ */ e(
|
|
77
|
+
const Yt = (a) => {
|
|
78
|
+
const { onToggleView: t, askAILabel: o, searchLabel: r } = a, { aiChatSettings: n } = B(), i = n.isChatHistoryButtonVisible, s = !!t || i;
|
|
79
|
+
return /* @__PURE__ */ e(R, { "data-show-toolbar": C(s), children: s ? /* @__PURE__ */ d(O, { "data-show-widget-toggle": C(!!t), children: [
|
|
80
|
+
/* @__PURE__ */ e(j, { children: i && /* @__PURE__ */ e(G, {}) }),
|
|
81
81
|
t && /* @__PURE__ */ e(
|
|
82
|
-
|
|
82
|
+
At,
|
|
83
83
|
{
|
|
84
84
|
onToggleView: t,
|
|
85
85
|
askAILabel: o,
|
|
@@ -90,57 +90,61 @@ const Jt = (a) => {
|
|
|
90
90
|
/* @__PURE__ */ e(u, {})
|
|
91
91
|
] }) : /* @__PURE__ */ e(u, {}) });
|
|
92
92
|
};
|
|
93
|
-
function
|
|
94
|
-
const { isSessionLoading: a } =
|
|
95
|
-
return /* @__PURE__ */ e(
|
|
96
|
-
/* @__PURE__ */ e(
|
|
97
|
-
/* @__PURE__ */ e(
|
|
98
|
-
/* @__PURE__ */ e(
|
|
93
|
+
function qt() {
|
|
94
|
+
const { isSessionLoading: a } = D();
|
|
95
|
+
return /* @__PURE__ */ e(U, { children: /* @__PURE__ */ d(K, { children: [
|
|
96
|
+
/* @__PURE__ */ e(Z, { children: a ? /* @__PURE__ */ e(z, {}) : /* @__PURE__ */ e(ea, {}) }),
|
|
97
|
+
/* @__PURE__ */ e(J, { children: /* @__PURE__ */ e(X, {}) }),
|
|
98
|
+
/* @__PURE__ */ e(Y, {})
|
|
99
99
|
] }) });
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function ea() {
|
|
102
102
|
const {
|
|
103
103
|
aiChatSettings: { components: a }
|
|
104
|
-
} =
|
|
105
|
-
return /* @__PURE__ */ e(
|
|
106
|
-
const n = t.at(-1),
|
|
107
|
-
const c = a?.[
|
|
104
|
+
} = B();
|
|
105
|
+
return /* @__PURE__ */ e(od, { children: ({ messages: t, isLoading: o, isStreaming: r }) => {
|
|
106
|
+
const n = t.at(-1), i = (m) => (l, F) => {
|
|
107
|
+
const c = a?.[l];
|
|
108
108
|
if (!c)
|
|
109
|
-
return console.warn(`Component "${
|
|
109
|
+
return console.warn(`Component "${l}" not found in components config`), null;
|
|
110
|
+
const I = { ...F, messageId: m.id };
|
|
110
111
|
try {
|
|
111
112
|
if (typeof c == "function" && c.length <= 1)
|
|
112
|
-
return
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
return M.createElement(
|
|
114
|
+
c,
|
|
115
|
+
I
|
|
116
|
+
);
|
|
117
|
+
const h = c(I, document.createElement("div"), null);
|
|
118
|
+
return M.isValidElement(h) || typeof h == "string" ? h : null;
|
|
115
119
|
} catch (h) {
|
|
116
|
-
return console.error(`🔍 [renderComponent] Error rendering component "${
|
|
120
|
+
return console.error(`🔍 [renderComponent] Error rendering component "${l}":`, h), null;
|
|
117
121
|
}
|
|
118
|
-
}, s = (
|
|
122
|
+
}, s = (m) => /* @__PURE__ */ e(Nd, { text: m });
|
|
119
123
|
return /* @__PURE__ */ d(b, { children: [
|
|
120
|
-
/* @__PURE__ */ e(
|
|
121
|
-
t.map((
|
|
122
|
-
const l = n?.id ===
|
|
123
|
-
return /* @__PURE__ */ d(
|
|
124
|
-
/* @__PURE__ */ e(
|
|
125
|
-
/* @__PURE__ */ d(
|
|
126
|
-
/* @__PURE__ */ e(
|
|
127
|
-
|
|
124
|
+
/* @__PURE__ */ e(da, {}),
|
|
125
|
+
t.map((m) => {
|
|
126
|
+
const l = n?.id === m.id, F = i(m);
|
|
127
|
+
return /* @__PURE__ */ d(S, { message: m, children: [
|
|
128
|
+
/* @__PURE__ */ e(T, {}),
|
|
129
|
+
/* @__PURE__ */ d(A, { children: [
|
|
130
|
+
/* @__PURE__ */ e(H, { children: a?.IkpMessage ? /* @__PURE__ */ e(
|
|
131
|
+
rd,
|
|
128
132
|
{
|
|
129
133
|
name: "IkpMessage",
|
|
130
|
-
props: { message:
|
|
134
|
+
props: { message: m, renderComponent: F, renderMarkdown: s },
|
|
131
135
|
componentDef: a.IkpMessage
|
|
132
136
|
}
|
|
133
137
|
) : /* @__PURE__ */ d(b, { children: [
|
|
134
|
-
/* @__PURE__ */ e(
|
|
135
|
-
(!r || !l) && /* @__PURE__ */ e(
|
|
138
|
+
/* @__PURE__ */ e(L, { isLast: l }),
|
|
139
|
+
(!r || !l) && /* @__PURE__ */ e(ra, {})
|
|
136
140
|
] }) }),
|
|
137
|
-
/* @__PURE__ */ e(
|
|
138
|
-
/* @__PURE__ */ e(
|
|
141
|
+
/* @__PURE__ */ e(aa, {}),
|
|
142
|
+
/* @__PURE__ */ e(oa, {})
|
|
139
143
|
] })
|
|
140
|
-
] },
|
|
144
|
+
] }, m.id);
|
|
141
145
|
}),
|
|
142
146
|
o && n?.role === "user" && n?.parts.length && /* @__PURE__ */ d(
|
|
143
|
-
|
|
147
|
+
S,
|
|
144
148
|
{
|
|
145
149
|
message: {
|
|
146
150
|
id: "___loader___",
|
|
@@ -148,36 +152,36 @@ function Yt() {
|
|
|
148
152
|
parts: [{ type: "text", text: "Thinking..." }]
|
|
149
153
|
},
|
|
150
154
|
children: [
|
|
151
|
-
/* @__PURE__ */ e(
|
|
152
|
-
/* @__PURE__ */ e(
|
|
155
|
+
/* @__PURE__ */ e(T, {}),
|
|
156
|
+
/* @__PURE__ */ e(nd, {})
|
|
153
157
|
]
|
|
154
158
|
}
|
|
155
159
|
)
|
|
156
160
|
] });
|
|
157
161
|
} });
|
|
158
162
|
}
|
|
159
|
-
function
|
|
160
|
-
return /* @__PURE__ */ d(
|
|
161
|
-
/* @__PURE__ */ d(
|
|
162
|
-
/* @__PURE__ */ e(
|
|
163
|
-
/* @__PURE__ */ e(
|
|
163
|
+
function da() {
|
|
164
|
+
return /* @__PURE__ */ d(Hd, { children: [
|
|
165
|
+
/* @__PURE__ */ d(f, { children: [
|
|
166
|
+
/* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(k, { children: /* @__PURE__ */ e(v, {}) }) }),
|
|
167
|
+
/* @__PURE__ */ e(w, {})
|
|
164
168
|
] }),
|
|
165
|
-
/* @__PURE__ */ d(
|
|
166
|
-
/* @__PURE__ */ e(
|
|
167
|
-
/* @__PURE__ */ d(
|
|
168
|
-
/* @__PURE__ */ e(
|
|
169
|
-
/* @__PURE__ */ e(
|
|
170
|
-
/* @__PURE__ */ d(
|
|
171
|
-
/* @__PURE__ */ e(
|
|
172
|
-
/* @__PURE__ */ e(
|
|
169
|
+
/* @__PURE__ */ d(A, { children: [
|
|
170
|
+
/* @__PURE__ */ e(H, { children: /* @__PURE__ */ e(L, { isLast: !1 }) }),
|
|
171
|
+
/* @__PURE__ */ d(fd, { children: [
|
|
172
|
+
/* @__PURE__ */ e(yd, {}),
|
|
173
|
+
/* @__PURE__ */ e(kd, {}),
|
|
174
|
+
/* @__PURE__ */ d(vd, { children: [
|
|
175
|
+
/* @__PURE__ */ e(wd, {}),
|
|
176
|
+
/* @__PURE__ */ e(Ld, {})
|
|
173
177
|
] })
|
|
174
178
|
] }),
|
|
175
|
-
/* @__PURE__ */ d(
|
|
176
|
-
/* @__PURE__ */ e(
|
|
177
|
-
/* @__PURE__ */ e(
|
|
178
|
-
|
|
179
|
+
/* @__PURE__ */ d(Bd, { children: [
|
|
180
|
+
/* @__PURE__ */ e(Dd, {}),
|
|
181
|
+
/* @__PURE__ */ e(Pd, { children: (a) => a.map((t) => /* @__PURE__ */ e(
|
|
182
|
+
Wd,
|
|
179
183
|
{
|
|
180
|
-
children: /* @__PURE__ */ e(
|
|
184
|
+
children: /* @__PURE__ */ e(Vd, { question: t })
|
|
181
185
|
},
|
|
182
186
|
typeof t == "object" ? t.label : t
|
|
183
187
|
)) })
|
|
@@ -185,229 +189,229 @@ function qt() {
|
|
|
185
189
|
] })
|
|
186
190
|
] });
|
|
187
191
|
}
|
|
188
|
-
function
|
|
189
|
-
return /* @__PURE__ */ d(
|
|
190
|
-
/* @__PURE__ */ e(
|
|
191
|
-
/* @__PURE__ */ e(
|
|
192
|
+
function T() {
|
|
193
|
+
return /* @__PURE__ */ d(f, { children: [
|
|
194
|
+
/* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(k, { children: /* @__PURE__ */ e(v, {}) }) }),
|
|
195
|
+
/* @__PURE__ */ e(w, {})
|
|
192
196
|
] });
|
|
193
197
|
}
|
|
194
|
-
function
|
|
195
|
-
return /* @__PURE__ */ e(
|
|
196
|
-
/* @__PURE__ */ e(
|
|
197
|
-
/* @__PURE__ */ e(
|
|
198
|
-
/* @__PURE__ */ e(
|
|
198
|
+
function ta() {
|
|
199
|
+
return /* @__PURE__ */ e(P, { children: /* @__PURE__ */ e(Rt, { children: /* @__PURE__ */ e(Ot, { children: /* @__PURE__ */ d(jt, { children: [
|
|
200
|
+
/* @__PURE__ */ e(Gt, {}),
|
|
201
|
+
/* @__PURE__ */ e(Ut, {}),
|
|
202
|
+
/* @__PURE__ */ e(Kt, { children: /* @__PURE__ */ e(Zt, {}) })
|
|
199
203
|
] }) }) }) });
|
|
200
204
|
}
|
|
201
|
-
function
|
|
202
|
-
return /* @__PURE__ */ e(
|
|
203
|
-
const r = t.url, n = t.mediaType ?? "",
|
|
204
|
-
return /* @__PURE__ */ d(
|
|
205
|
-
|
|
206
|
-
/* @__PURE__ */ e(
|
|
205
|
+
function aa() {
|
|
206
|
+
return /* @__PURE__ */ e($t, { children: (a) => a.map((t, o) => {
|
|
207
|
+
const r = t.url, n = t.mediaType ?? "", i = n.split("/").pop(), s = t.filename ?? (i ? `untitled.${i}` : "untitled"), m = W(n);
|
|
208
|
+
return /* @__PURE__ */ d(_t, { url: r, name: s, mediaType: n, children: [
|
|
209
|
+
m ? /* @__PURE__ */ e(V, {}) : /* @__PURE__ */ e(N, {}),
|
|
210
|
+
/* @__PURE__ */ e(g, {})
|
|
207
211
|
] }, r || o);
|
|
208
212
|
}) });
|
|
209
213
|
}
|
|
210
|
-
function
|
|
211
|
-
return /* @__PURE__ */ d(
|
|
212
|
-
/* @__PURE__ */ e(
|
|
213
|
-
/* @__PURE__ */ e(
|
|
214
|
-
/* @__PURE__ */ e(
|
|
215
|
-
/* @__PURE__ */ e(
|
|
214
|
+
function oa() {
|
|
215
|
+
return /* @__PURE__ */ d(Xd, { children: [
|
|
216
|
+
/* @__PURE__ */ e(Yd, { children: (a) => a.map((t, o) => /* @__PURE__ */ e(qd, { action: t }, `action-${o}`)) }),
|
|
217
|
+
/* @__PURE__ */ e(p, { action: "copy" }),
|
|
218
|
+
/* @__PURE__ */ e(p, { action: "upvote" }),
|
|
219
|
+
/* @__PURE__ */ e(p, { action: "downvote" })
|
|
216
220
|
] });
|
|
217
221
|
}
|
|
218
|
-
function
|
|
219
|
-
return /* @__PURE__ */ d(
|
|
220
|
-
/* @__PURE__ */ e(
|
|
221
|
-
/* @__PURE__ */ e(
|
|
222
|
-
/* @__PURE__ */ e(
|
|
222
|
+
function ra() {
|
|
223
|
+
return /* @__PURE__ */ d(Qd, { children: [
|
|
224
|
+
/* @__PURE__ */ e($d, {}),
|
|
225
|
+
/* @__PURE__ */ e(_d, { children: (a) => a.map((t, o) => /* @__PURE__ */ d(Rd, { href: t.url, source: t, children: [
|
|
226
|
+
/* @__PURE__ */ e(Od, { children: t.breadcrumbs?.map((r) => /* @__PURE__ */ d(x, { children: [
|
|
223
227
|
r,
|
|
224
|
-
/* @__PURE__ */ e(
|
|
228
|
+
/* @__PURE__ */ e(jd, {})
|
|
225
229
|
] }, r)) }),
|
|
226
|
-
/* @__PURE__ */ e(Od, {}),
|
|
227
|
-
/* @__PURE__ */ e(jd, {}),
|
|
228
230
|
/* @__PURE__ */ e(Gd, {}),
|
|
229
|
-
/* @__PURE__ */ e(Ud, {
|
|
230
|
-
|
|
231
|
+
/* @__PURE__ */ e(Ud, {}),
|
|
232
|
+
/* @__PURE__ */ e(Kd, {}),
|
|
233
|
+
/* @__PURE__ */ e(Zd, { children: (r) => r.map((n, i) => /* @__PURE__ */ e(
|
|
234
|
+
zd,
|
|
231
235
|
{
|
|
232
236
|
descriptionPart: n
|
|
233
237
|
},
|
|
234
|
-
`part-${
|
|
238
|
+
`part-${i}`
|
|
235
239
|
)) }),
|
|
236
|
-
/* @__PURE__ */ e(
|
|
240
|
+
/* @__PURE__ */ e(Jd, {})
|
|
237
241
|
] }, o)) })
|
|
238
242
|
] });
|
|
239
243
|
}
|
|
240
|
-
function
|
|
241
|
-
return /* @__PURE__ */ d(
|
|
242
|
-
/* @__PURE__ */ e(
|
|
243
|
-
/* @__PURE__ */ d(
|
|
244
|
-
/* @__PURE__ */ e(
|
|
245
|
-
/* @__PURE__ */ e(
|
|
244
|
+
function na() {
|
|
245
|
+
return /* @__PURE__ */ d(q, { children: [
|
|
246
|
+
/* @__PURE__ */ e(Ht, { children: /* @__PURE__ */ d(ft, { children: [
|
|
247
|
+
/* @__PURE__ */ d(yt, { children: [
|
|
248
|
+
/* @__PURE__ */ e(kt, {}),
|
|
249
|
+
/* @__PURE__ */ e(vt, {})
|
|
246
250
|
] }),
|
|
247
|
-
/* @__PURE__ */ e(
|
|
251
|
+
/* @__PURE__ */ e(wt, {})
|
|
248
252
|
] }) }),
|
|
249
|
-
/* @__PURE__ */ e(
|
|
250
|
-
/* @__PURE__ */ e(
|
|
253
|
+
/* @__PURE__ */ e(ia, {}),
|
|
254
|
+
/* @__PURE__ */ e(ma, {})
|
|
251
255
|
] });
|
|
252
256
|
}
|
|
253
|
-
function
|
|
254
|
-
return /* @__PURE__ */ d(
|
|
255
|
-
/* @__PURE__ */ e(
|
|
256
|
-
/* @__PURE__ */ e(
|
|
257
|
-
/* @__PURE__ */ e(
|
|
258
|
-
const r =
|
|
259
|
-
return /* @__PURE__ */ d(
|
|
260
|
-
r ? /* @__PURE__ */ d(
|
|
261
|
-
/* @__PURE__ */ e(
|
|
262
|
-
/* @__PURE__ */ e(
|
|
263
|
-
] }) : /* @__PURE__ */ d(
|
|
264
|
-
/* @__PURE__ */ e(
|
|
265
|
-
/* @__PURE__ */ e(
|
|
257
|
+
function ia() {
|
|
258
|
+
return /* @__PURE__ */ d(id, { children: [
|
|
259
|
+
/* @__PURE__ */ e(Lt, {}),
|
|
260
|
+
/* @__PURE__ */ e(Bt, { children: "Drop files here to add to chat" }),
|
|
261
|
+
/* @__PURE__ */ e(Dt, { children: (a) => a.map((t, o) => {
|
|
262
|
+
const r = W(t.type);
|
|
263
|
+
return /* @__PURE__ */ d(Pt, { file: t, children: [
|
|
264
|
+
r ? /* @__PURE__ */ d(Wt, { children: [
|
|
265
|
+
/* @__PURE__ */ e(V, {}),
|
|
266
|
+
/* @__PURE__ */ e(g, {})
|
|
267
|
+
] }) : /* @__PURE__ */ d(Vt, { children: [
|
|
268
|
+
/* @__PURE__ */ e(N, {}),
|
|
269
|
+
/* @__PURE__ */ e(g, {})
|
|
266
270
|
] }),
|
|
267
|
-
/* @__PURE__ */ e(
|
|
271
|
+
/* @__PURE__ */ e(Nt, {})
|
|
268
272
|
] }, `${t.name}-${t.lastModified}-${o}`);
|
|
269
273
|
}) }),
|
|
270
|
-
/* @__PURE__ */ d(
|
|
271
|
-
/* @__PURE__ */ e(
|
|
272
|
-
/* @__PURE__ */ e(
|
|
273
|
-
/* @__PURE__ */ e(
|
|
274
|
+
/* @__PURE__ */ d(md, { children: [
|
|
275
|
+
/* @__PURE__ */ e(Qt, {}),
|
|
276
|
+
/* @__PURE__ */ e(sd, {}),
|
|
277
|
+
/* @__PURE__ */ e(ld, { children: /* @__PURE__ */ e(cd, {}) })
|
|
274
278
|
] })
|
|
275
279
|
] });
|
|
276
280
|
}
|
|
277
|
-
function
|
|
278
|
-
return /* @__PURE__ */ d(
|
|
279
|
-
/* @__PURE__ */ d(
|
|
280
|
-
/* @__PURE__ */ e(
|
|
281
|
-
/* @__PURE__ */ e(
|
|
281
|
+
function ma() {
|
|
282
|
+
return /* @__PURE__ */ d(hd, { children: [
|
|
283
|
+
/* @__PURE__ */ d(bd, { children: [
|
|
284
|
+
/* @__PURE__ */ e(Cd, {}),
|
|
285
|
+
/* @__PURE__ */ e(Fd, {})
|
|
282
286
|
] }),
|
|
283
|
-
/* @__PURE__ */ d(
|
|
284
|
-
/* @__PURE__ */ e(
|
|
285
|
-
a.map((o) => /* @__PURE__ */ e(
|
|
286
|
-
t.length > 0 && /* @__PURE__ */ e(
|
|
287
|
-
/* @__PURE__ */ d(
|
|
288
|
-
/* @__PURE__ */ e(
|
|
289
|
-
t.map((o) => /* @__PURE__ */ d(
|
|
290
|
-
/* @__PURE__ */ e(
|
|
287
|
+
/* @__PURE__ */ d(Ed, { children: [
|
|
288
|
+
/* @__PURE__ */ e(pd, { children: ({ pinned: a, unpinned: t }) => /* @__PURE__ */ d(b, { children: [
|
|
289
|
+
a.map((o) => /* @__PURE__ */ e(ud, { action: o }, o.name)),
|
|
290
|
+
t.length > 0 && /* @__PURE__ */ e(gd, {}),
|
|
291
|
+
/* @__PURE__ */ d(Id, { children: [
|
|
292
|
+
/* @__PURE__ */ e(Md, {}),
|
|
293
|
+
t.map((o) => /* @__PURE__ */ d(Sd, { action: o, children: [
|
|
294
|
+
/* @__PURE__ */ e(Td, { action: o }),
|
|
291
295
|
o.name
|
|
292
296
|
] }, o.name))
|
|
293
297
|
] })
|
|
294
298
|
] }) }),
|
|
295
|
-
/* @__PURE__ */ d(
|
|
296
|
-
/* @__PURE__ */ e(
|
|
297
|
-
/* @__PURE__ */ e(
|
|
299
|
+
/* @__PURE__ */ d(E, { action: "copy", children: [
|
|
300
|
+
/* @__PURE__ */ e(xd, { action: "copy" }),
|
|
301
|
+
/* @__PURE__ */ e(Ad, { action: "copy" })
|
|
298
302
|
] }),
|
|
299
|
-
/* @__PURE__ */ e(
|
|
300
|
-
/* @__PURE__ */ e(
|
|
303
|
+
/* @__PURE__ */ e(E, { action: "clear" }),
|
|
304
|
+
/* @__PURE__ */ e(E, { action: "stop" })
|
|
301
305
|
] })
|
|
302
306
|
] });
|
|
303
307
|
}
|
|
304
|
-
function
|
|
305
|
-
const { sessions: a } =
|
|
306
|
-
return /* @__PURE__ */ d(
|
|
307
|
-
/* @__PURE__ */ d(
|
|
308
|
-
/* @__PURE__ */ d(
|
|
309
|
-
/* @__PURE__ */ e(
|
|
308
|
+
function sa() {
|
|
309
|
+
const { sessions: a } = pt(), { conversationId: t } = D();
|
|
310
|
+
return /* @__PURE__ */ d(et, { children: [
|
|
311
|
+
/* @__PURE__ */ d(dt, { children: [
|
|
312
|
+
/* @__PURE__ */ d(tt, { children: [
|
|
313
|
+
/* @__PURE__ */ e(at, { iconKey: "backToChat" }),
|
|
310
314
|
"Back to chat"
|
|
311
315
|
] }),
|
|
312
|
-
/* @__PURE__ */ e(
|
|
316
|
+
/* @__PURE__ */ e(ot, {}),
|
|
313
317
|
/* @__PURE__ */ e(u, {})
|
|
314
318
|
] }),
|
|
315
|
-
/* @__PURE__ */ d(
|
|
319
|
+
/* @__PURE__ */ d(rt, { children: [
|
|
316
320
|
a.map((o) => /* @__PURE__ */ d(
|
|
317
|
-
|
|
321
|
+
nt,
|
|
318
322
|
{
|
|
319
323
|
sessionId: o.id,
|
|
320
324
|
"data-active": C(o.id === t),
|
|
321
325
|
children: [
|
|
322
|
-
/* @__PURE__ */ e(
|
|
323
|
-
/* @__PURE__ */ e(
|
|
326
|
+
/* @__PURE__ */ e(it, { children: o.title }),
|
|
327
|
+
/* @__PURE__ */ e(mt, { children: st(o.updatedAt) })
|
|
324
328
|
]
|
|
325
329
|
},
|
|
326
330
|
o.id
|
|
327
331
|
)),
|
|
328
|
-
/* @__PURE__ */ e(
|
|
329
|
-
/* @__PURE__ */ e(
|
|
332
|
+
/* @__PURE__ */ e(lt, {}),
|
|
333
|
+
/* @__PURE__ */ e(ct, {})
|
|
330
334
|
] }),
|
|
331
|
-
/* @__PURE__ */ e(
|
|
335
|
+
/* @__PURE__ */ e(ht, { children: /* @__PURE__ */ e(bt, {}) })
|
|
332
336
|
] });
|
|
333
337
|
}
|
|
334
|
-
function
|
|
335
|
-
return /* @__PURE__ */ e(
|
|
336
|
-
/* @__PURE__ */ e(
|
|
337
|
-
/* @__PURE__ */ e(
|
|
338
|
-
/* @__PURE__ */ e(
|
|
339
|
-
/* @__PURE__ */ d(
|
|
340
|
-
/* @__PURE__ */ e(
|
|
341
|
-
/* @__PURE__ */ e(
|
|
338
|
+
function la() {
|
|
339
|
+
return /* @__PURE__ */ e(P, { children: /* @__PURE__ */ e(ee, { children: /* @__PURE__ */ e(de, { children: /* @__PURE__ */ d(te, { children: [
|
|
340
|
+
/* @__PURE__ */ e(ae, {}),
|
|
341
|
+
/* @__PURE__ */ e(oe, {}),
|
|
342
|
+
/* @__PURE__ */ e(re, { children: /* @__PURE__ */ d(ne, { children: [
|
|
343
|
+
/* @__PURE__ */ d(ie, { children: [
|
|
344
|
+
/* @__PURE__ */ e(me, {}),
|
|
345
|
+
/* @__PURE__ */ e(se, {})
|
|
342
346
|
] }),
|
|
343
|
-
/* @__PURE__ */ e(
|
|
347
|
+
/* @__PURE__ */ e(le, {})
|
|
344
348
|
] }) })
|
|
345
349
|
] }) }) }) });
|
|
346
350
|
}
|
|
347
|
-
function
|
|
348
|
-
return /* @__PURE__ */ d(
|
|
349
|
-
/* @__PURE__ */ e(
|
|
350
|
-
/* @__PURE__ */ d(
|
|
351
|
-
/* @__PURE__ */ d(
|
|
352
|
-
/* @__PURE__ */ e(
|
|
353
|
-
/* @__PURE__ */ e(
|
|
351
|
+
function ca() {
|
|
352
|
+
return /* @__PURE__ */ d(ce, { children: [
|
|
353
|
+
/* @__PURE__ */ e(he, {}),
|
|
354
|
+
/* @__PURE__ */ d(be, { children: [
|
|
355
|
+
/* @__PURE__ */ d(Ce, { children: [
|
|
356
|
+
/* @__PURE__ */ e(Fe, {}),
|
|
357
|
+
/* @__PURE__ */ e(Ee, {})
|
|
354
358
|
] }),
|
|
355
|
-
/* @__PURE__ */ e(
|
|
356
|
-
a.map((t, o) => /* @__PURE__ */ d(
|
|
357
|
-
/* @__PURE__ */ e(
|
|
358
|
-
t.inputType === "text" && /* @__PURE__ */ e(
|
|
359
|
-
t.inputType === "email" && /* @__PURE__ */ e(
|
|
360
|
-
t.inputType === "file" && /* @__PURE__ */ e(
|
|
361
|
-
t.inputType === "textarea" && /* @__PURE__ */ e(
|
|
362
|
-
t.inputType === "checkbox" && /* @__PURE__ */ e(
|
|
363
|
-
t.inputType === "select" && /* @__PURE__ */ d(
|
|
364
|
-
/* @__PURE__ */ d(
|
|
365
|
-
/* @__PURE__ */ e(
|
|
366
|
-
/* @__PURE__ */ e(
|
|
359
|
+
/* @__PURE__ */ e(pe, { children: (a) => /* @__PURE__ */ d(b, { children: [
|
|
360
|
+
a.map((t, o) => /* @__PURE__ */ d(ue, { field: t, autoFocus: o === 0, children: [
|
|
361
|
+
/* @__PURE__ */ e(ge, {}),
|
|
362
|
+
t.inputType === "text" && /* @__PURE__ */ e(Ie, {}),
|
|
363
|
+
t.inputType === "email" && /* @__PURE__ */ e(Me, {}),
|
|
364
|
+
t.inputType === "file" && /* @__PURE__ */ e(Se, {}),
|
|
365
|
+
t.inputType === "textarea" && /* @__PURE__ */ e(Te, {}),
|
|
366
|
+
t.inputType === "checkbox" && /* @__PURE__ */ e(xe, { children: /* @__PURE__ */ e(Ae, {}) }),
|
|
367
|
+
t.inputType === "select" && /* @__PURE__ */ d(He, { children: [
|
|
368
|
+
/* @__PURE__ */ d(fe, { children: [
|
|
369
|
+
/* @__PURE__ */ e(ye, {}),
|
|
370
|
+
/* @__PURE__ */ e(ke, {})
|
|
367
371
|
] }),
|
|
368
|
-
/* @__PURE__ */ e(
|
|
369
|
-
/* @__PURE__ */ e(
|
|
370
|
-
/* @__PURE__ */ e(
|
|
372
|
+
/* @__PURE__ */ e(ve, { children: /* @__PURE__ */ e(we, { children: t.items.map((r) => /* @__PURE__ */ d(Le, { value: r.value, children: [
|
|
373
|
+
/* @__PURE__ */ e(Be, { children: r.label }),
|
|
374
|
+
/* @__PURE__ */ e(De, {})
|
|
371
375
|
] }, r.value)) }) })
|
|
372
376
|
] }),
|
|
373
|
-
t.inputType === "combobox" && /* @__PURE__ */ d(
|
|
374
|
-
/* @__PURE__ */ d(
|
|
375
|
-
"multiple" in t && t.multiple && /* @__PURE__ */ e(
|
|
376
|
-
/* @__PURE__ */ e(
|
|
377
|
-
/* @__PURE__ */ e(
|
|
377
|
+
t.inputType === "combobox" && /* @__PURE__ */ d(Pe, { children: [
|
|
378
|
+
/* @__PURE__ */ d(We, { children: [
|
|
379
|
+
"multiple" in t && t.multiple && /* @__PURE__ */ e(Ve, {}),
|
|
380
|
+
/* @__PURE__ */ e(Ne, {}),
|
|
381
|
+
/* @__PURE__ */ e(Qe, {})
|
|
378
382
|
] }),
|
|
379
|
-
/* @__PURE__ */ e(
|
|
380
|
-
|
|
383
|
+
/* @__PURE__ */ e($e, { children: /* @__PURE__ */ e(_e, { children: /* @__PURE__ */ e(Re, { children: /* @__PURE__ */ e(Oe, { children: (r) => r.length === 0 ? /* @__PURE__ */ e(je, {}) : r.map((n) => /* @__PURE__ */ d(
|
|
384
|
+
Ge,
|
|
381
385
|
{
|
|
382
386
|
item: n,
|
|
383
387
|
children: [
|
|
384
|
-
/* @__PURE__ */ e(
|
|
385
|
-
/* @__PURE__ */ e(
|
|
388
|
+
/* @__PURE__ */ e(Ue, { children: n.label }),
|
|
389
|
+
/* @__PURE__ */ e(Ke, {})
|
|
386
390
|
]
|
|
387
391
|
},
|
|
388
392
|
n.value
|
|
389
393
|
)) }) }) }) })
|
|
390
394
|
] }),
|
|
391
|
-
/* @__PURE__ */ e(
|
|
392
|
-
/* @__PURE__ */ e(
|
|
395
|
+
/* @__PURE__ */ e(Ze, {}),
|
|
396
|
+
/* @__PURE__ */ e(ze, {})
|
|
393
397
|
] }, t.name)),
|
|
394
|
-
/* @__PURE__ */ e(
|
|
398
|
+
/* @__PURE__ */ e(Je, {})
|
|
395
399
|
] }) }),
|
|
396
|
-
/* @__PURE__ */ d(
|
|
397
|
-
/* @__PURE__ */ e(
|
|
398
|
-
/* @__PURE__ */ e(
|
|
400
|
+
/* @__PURE__ */ d(Xe, { children: [
|
|
401
|
+
/* @__PURE__ */ e(Ye, {}),
|
|
402
|
+
/* @__PURE__ */ e(qe, {})
|
|
399
403
|
] })
|
|
400
404
|
] }),
|
|
401
|
-
/* @__PURE__ */ d(
|
|
402
|
-
/* @__PURE__ */ e(
|
|
403
|
-
/* @__PURE__ */ e(
|
|
404
|
-
/* @__PURE__ */ e(
|
|
405
|
+
/* @__PURE__ */ d(ed, { children: [
|
|
406
|
+
/* @__PURE__ */ e(dd, {}),
|
|
407
|
+
/* @__PURE__ */ e(td, {}),
|
|
408
|
+
/* @__PURE__ */ e(ad, {})
|
|
405
409
|
] })
|
|
406
410
|
] });
|
|
407
411
|
}
|
|
408
412
|
export {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
+
Wa as InkeepEmbeddedChat,
|
|
414
|
+
Jt as InkeepEmbeddedChatImpl,
|
|
415
|
+
Xt as InkeepEmbeddedChatImplContent,
|
|
416
|
+
zt as InkeepEmbeddedChatProvider
|
|
413
417
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),ae=require("../../primitives/providers/base-events-provider.cjs"),re=require("../../primitives/providers/config-provider.cjs"),se=require("../../primitives/providers/message-provider.cjs"),C=require("../../primitives/components/embedded-chat.cjs"),ne=require("../../primitives/components/embedded-chat/chat-provider.cjs"),oe=require("../../primitives/utils/misc.cjs"),ie=require("merge-anything"),b=require("../utils.cjs"),le=require("./ui/markdown-styles.cjs"),de=require("../../primitives/components/embedded-chat/use-stream-processor.cjs"),ce=require("./data-summary-group.cjs"),o=require("react"),T=require("./embedded-chat.cjs"),c=require("lucide-react"),V=require("./ui/recipes/button.cjs"),pe={"input-streaming":"Pending","input-available":"Running","approval-requested":"Awaiting Approval","approval-responded":"Responded","output-available":"Completed","output-error":"Error","output-denied":"Denied"};function ue(t){if(!t||typeof t!="object")return!1;const a=t;return typeof a.type=="string"&&a.type.startsWith("tool-")}const me=t=>{if(!t||typeof t!="object"||!("status"in t))return;const a=t.status;return typeof a=="string"?a:void 0},xe=()=>e.jsx("div",{className:"flex space-x-1",children:[0,1,2].map(t=>e.jsx("span",{className:"animate-bounce-dot opacity-30",style:{animationDelay:`${t*.2}s`},children:"."},t))}),B=({name:t,Icon:a,props:l,componentType:n})=>e.jsxs("div",{className:"border rounded-lg bg-gray-50 dark:bg-gray-dark-800 mb-3",children:[e.jsxs("div",{className:"flex justify-between px-4 py-2 text-xs",children:[e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(a,{className:"w-3 h-3 text-gray-600 dark:text-white-alpha-600"}),e.jsx("span",{children:t})]}),e.jsx("div",{className:"flex items-center px-1.5 py-0.5 rounded-md text-2xs uppercase tracking-wider bg-gray-200 dark:bg-white-alpha-200 font-medium text-gray-700 dark:text-white-alpha-700 font-mono",children:n})]}),e.jsx("div",{className:"px-4 py-2",children:e.jsx(K,{value:l})})]}),he=({name:t,props:a})=>e.jsx(B,{name:t,Icon:c.ComponentIcon,props:a,componentType:"component"}),fe=({name:t,props:a})=>e.jsx(B,{name:t,Icon:c.Library,props:a,componentType:"artifact"}),ge=({tool:t,componentDef:a,renderText:l,approvalId:n,messagePartsLength:x,setApprovalDelayPending:r,addToolApprovalResponse:u,sendMessage:i,conversationId:g})=>{const d=o.useRef(i);d.current=i;const m=o.useRef(u);m.current=u;const p=o.useRef(r);p.current=r;const h=o.useCallback(async(E=!0)=>{n&&(p.current({partCount:x}),m.current({id:n,approved:E}),await d.current(void 0,{body:{conversationId:g}}))},[n,x,g]),k=o.useMemo(()=>({tool:t,approve:h,renderMarkdown:l}),[t]),A=a?T.DynamicComponent:W;return e.jsx(A,{name:t.type,props:k,componentDef:a})};function F(t){return t===null?e.jsx("span",{className:"text-gray-500 dark:text-white-alpha-500 font-mono font-medium text-1xs",children:"null"}):t===void 0?e.jsx("span",{className:"text-gray-400 dark:text-white-alpha-400 italic text-xs font-medium",children:"undefined"}):typeof t=="boolean"?e.jsx("span",{className:b.cn("inline-flex font-mono font-semibold items-center px-1 py-0.5 text-1xs rounded-md border",t?"bg-inkeep-expanded-primary-50 border-inkeep-expanded-primary-200 text-inkeep-expanded-primary-600 dark:bg-inkeep-expanded-primary-950 dark:border-inkeep-expanded-primary-600 dark:text-inkeep-expanded-primary-200":"bg-gray-100 dark:bg-white-alpha-50 text-gray-700 dark:text-white-alpha-700"),children:t?"true":"false"}):typeof t=="number"?e.jsx("span",{className:"tabular-nums font-medium text-inkeep-expanded-primary-600 dark:text-inkeep-expanded-primary-200",children:String(t)}):typeof t=="string"?e.jsx("span",{className:"text-gray-800 dark:text-white-alpha-800 break-words",children:t}):e.jsx("span",{children:String(t)})}const G=({name:t,value:a,isArrayIndex:l,depth:n=0})=>{const[x,r]=o.useState(n<1),u=a!==null&&typeof a=="object"&&!Array.isArray(a),i=Array.isArray(a);if(!(u||i))return e.jsxs("div",{className:"flex items-baseline gap-2 py-1 text-xs",children:[e.jsx("span",{className:b.cn("font-medium shrink-0",l?"text-gray-300 dark:text-white-alpha-300":"text-gray-500 dark:text-white-alpha-500"),children:l?"—":t}),e.jsx("span",{className:"min-w-0",children:F(a)})]});const d=i?a.map((p,h)=>[String(h),p]):Object.entries(a);return d.length===0?e.jsxs("div",{className:"flex items-baseline gap-2 py-1 text-xs",children:[e.jsx("span",{className:"font-medium text-gray-500 dark:text-white-alpha-500 shrink-0",children:t}),e.jsx("span",{className:"text-gray-400 dark:text-white-alpha-400 italic",children:i?"empty list":"empty"})]}):e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:p=>{p.stopPropagation(),r(!x)},className:"flex items-center gap-1.5 py-1 text-xs hover:bg-gray-50 dark:hover:bg-white-alpha-50 -mx-1.5 px-1.5 rounded transition-colors w-full text-left",children:[e.jsx(c.ChevronDown,{className:b.cn("h-3.5 w-3.5 text-gray-400 dark:text-white-alpha-400 shrink-0 transition-transform",!x&&"-rotate-90")}),e.jsx("span",{className:"font-medium text-gray-500 dark:text-white-alpha-500",children:t}),!x&&e.jsx("span",{className:"text-gray-400 dark:text-white-alpha-400 text-1xs ml-1",children:i?`${d.length} item${d.length!==1?"s":""}`:`${d.length} field${d.length!==1?"s":""}`})]}),x&&e.jsx("div",{className:"border-l-2 border-gray-200 dark:border-white-alpha-200 ml-1.5 pl-3",children:d.map(([p,h])=>e.jsx(G,{name:p,value:h,isArrayIndex:i,depth:n+1},p))})]})},K=({value:t})=>{if(t==null||typeof t!="object")return e.jsx("span",{className:"text-xs",children:F(t)});const a=Array.isArray(t)?t.map((l,n)=>[String(n),l]):Object.entries(t);return a.length===0?e.jsx("div",{className:"text-xs text-gray-400 dark:text-white-alpha-400 italic",children:"No arguments"}):e.jsx("div",{className:"space-y-1",children:a.map(([l,n])=>e.jsx(G,{name:l,value:n,isArrayIndex:Array.isArray(t)},l))})},W=({props:t})=>{const{tool:a,approve:l}=t,n=a.type,x=n.startsWith("tool-")?n.slice(5):n,r=a.state,u=a.approval?.id,i=!!u,g=r==="approval-requested",d=me(a.output),[m,p]=o.useState(i),h=r?pe[r]??r:"tool";o.useEffect(()=>{g&&p(!0)},[g]);const k=()=>{switch(r){case"input-streaming":return e.jsx(c.Circle,{className:"w-3 h-3"});case"input-available":return e.jsx(c.Loader2,{className:"w-3 h-3 animate-spin"});case"approval-requested":return e.jsx(c.Clock,{className:"w-3 h-3"});case"approval-responded":return e.jsx(c.CheckCircle,{className:"w-3 h-3"});case"output-available":return e.jsx(c.CheckCircle,{className:"w-3 h-3"});case"output-error":return e.jsx(c.TriangleAlert,{className:"w-3 h-3"});case"output-denied":return e.jsx(c.XCircle,{className:"w-3 h-3"});default:return null}};return e.jsxs("div",{className:"border rounded-lg mb-3 overflow-hidden",children:[e.jsxs("button",{type:"button",className:"inline-flex items-center group gap-2 text-xs text-gray-700 dark:text-white-alpha-700 hover:text-gray-800 dark:hover:text-white-alpha-800 transition-colors cursor-pointer w-full justify-between px-4 py-2 data-[expanded=true]:border-b",onClick:()=>p(!m),"aria-expanded":m,"data-expanded":m,children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(c.Hammer,{className:"w-3 h-3 text-gray-600 dark:text-white-alpha-600"}),e.jsx("span",{children:x})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-1.5 py-0.5 rounded-md text-2xs uppercase tracking-wider bg-gray-100 dark:bg-white-alpha-100 font-medium text-gray-700 dark:text-white-alpha-700 font-mono",children:[k(),h]}),e.jsx(c.ChevronDown,{className:"w-3.5 h-3.5 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 transform rotate-0 group-data-[expanded=true]:rotate-180"})]})]}),e.jsxs("div",{"data-expanded":m,className:b.cn("overflow-hidden transition-all duration-300 ease-in-out data-[expanded=true]:opacity-100 data-[expanded=false]:max-h-0 data-[expanded=false]:opacity-0 max-w-full"),children:[e.jsx("div",{"data-expanded":m,className:b.cn("relative",'before:content-[""] before:absolute before:inset-x-0 before:top-0 before:h-3 before:pointer-events-none before:z-10','after:content-[""] after:absolute after:inset-x-0 after:bottom-0 after:h-3 after:pointer-events-none after:z-10',"before:bg-[linear-gradient(white,_transparent)] after:bg-[linear-gradient(transparent,_white)]","dark:before:bg-[linear-gradient(var(--ikp-color-gray-dark-950),_transparent)] dark:after:bg-[linear-gradient(transparent,_var(--ikp-color-gray-dark-950))]","data-[expanded=false]:before:opacity-0 data-[expanded=false]:after:opacity-0"),children:e.jsx("div",{"data-expanded":m,className:b.cn("[scrollbar-width:thin] px-4","data-[expanded=true]:max-h-48 data-[expanded=true]:overflow-y-auto"),children:a.input!=null&&e.jsx("div",{className:"text-xs py-2",children:e.jsx(K,{value:a.input})})})}),g&&u&&e.jsxs("div",{className:"flex justify-end gap-2 pt-1 pb-3 px-4",children:[e.jsx("button",{type:"button",className:b.cn(V.button({size:"xs",variant:"outline"}),"px-2 py-1 rounded-md text-xs text-gray-700 dark:text-white-alpha-700"),onClick:()=>l(!1),children:"Deny"}),e.jsxs("button",{type:"button",className:b.cn(V.button({size:"xs",variant:"primaryFilled"}),"px-2 py-1 rounded-md text-xs gap-1"),onClick:()=>l(!0),children:[e.jsx(c.Check,{className:"w-3 h-3"}),"Approve"]})]}),r==="output-available"&&d&&a.output!=null&&e.jsxs("div",{className:"flex justify-end items-center gap-1 whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 capitalize pb-3 px-4",children:[d==="approved"&&e.jsx(c.Check,{className:"w-3 h-3"}),d]}),r==="output-denied"&&e.jsxs("div",{className:"flex justify-end items-center gap-1 whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 capitalize pb-3 px-4",children:[e.jsx(c.X,{className:"w-3 h-3"}),h]})]})]})},ye=({className:t,componentStyles:a,children:l,isLast:n,...x})=>{const{message:r}=se.useMessage(),{logEvent:u}=ae.useBaseEvents(),{conversationId:i,isStreaming:g,isLoading:d,setError:m,addToolApprovalResponse:p,sendMessage:h}=ne.useChat(),{aiChatSettings:{components:k,artifacts:A,headers:E}}=re.useInkeepConfig(),X=E?.["x-emit-operations"]==="true",$=r.role==="user",q=(g||d)&&n&&r.role==="assistant",{processedParts:H,summaryTimings:J,shouldShowInitialLoading:Q,shouldShowStreamDelayLoading:Y}=de.useStreamProcessor(r.parts,q,m),[S,L]=o.useState(null),[Z,M]=o.useState(!1),y=o.useRef(null);o.useEffect(()=>{if(!S){M(!1),y.current&&(clearTimeout(y.current),y.current=null);return}return M(!1),y.current&&clearTimeout(y.current),y.current=window.setTimeout(()=>{M(!0)},1e3),()=>{y.current&&(clearTimeout(y.current),y.current=null)}},[S]),o.useEffect(()=>{S&&(!n||r.parts.length>S.partCount||!q)&&L(null)},[S,n,r.parts.length,q]);const _=o.useMemo(()=>r.parts.filter(oe.isCitationArtifact),[r.parts]),O=o.useMemo(()=>ie.merge(le.markdownStyles,a??{}),[a]),z=o.useCallback((s,f)=>{u({eventName:"assistant_message_inline_link_opened",properties:{conversationId:i,messageId:r.id,title:f?.toString(),url:s}})},[u,i,r.id]),U=o.useCallback((s,f)=>{u({eventName:"assistant_code_block_copied",properties:{conversationId:i,messageId:r.id,language:s,code:f}})},[u,i,r.id]),R=o.useCallback(s=>e.jsx(C.EmbeddedChatPrimitiveMarkdown,{text:s,componentStyles:O,onLinkClick:z,onCodeCopy:U,artifacts:_}),[O,z,U,_]),ee=o.useMemo(()=>b.cn("data-[role=user]:whitespace-pre-wrap mb-3 data-[role=user]:mb-0 [&[data-role=user]>p]:mb-0 max-w-full",t),[t]),te=!$||r.parts.some(s=>s.type==="text"&&s.text?.trim());return e.jsxs(e.Fragment,{children:[!te&&e.jsx("span",{className:"text-gray-500 dark:text-white-alpha-500",children:"No message content"}),H.map((s,f)=>{const v={"data-role":r.role,"data-type":s?.type==="data-component"?s.data.type:s?.type,...x,className:ee};switch(s?.type){case"text":return e.jsx(C.PrimitiveMessagePart,{...v,children:$?s.text:R(s.text||"")},f);case"data-component":{const{type:w}=s.data;switch(w){case"text":return e.jsx("div",{...v,children:R(s.data.text||"")},f);default:{const N=s.data,{name:j,props:D}=N,P=k?.[j],I=P?T.DynamicComponent:he;return e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(I,{name:j,props:D,componentDef:P})},`${j}-${f}`)}}}case"data-artifact":{const w=s.data,{name:N,type:j,artifactSummary:D}=w;if(j==="citation"&&!D?.url)return null;const P=A?.[j],I=P?T.DynamicComponent:fe;return e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(I,{name:j,props:D,componentDef:P})},`${N}-${f}`)}case"summary-group":{const w=J.get(s.groupKey)||{isCompleted:!1};return e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(ce.DataSummaryGroup,{summaries:s.summaries||[],isCompleted:w.isCompleted})},`${s.groupKey}-${f}`)}default:{if(!ue(s))return null;const w=s,N=s.approval?.id;return X||N?e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(ge,{tool:w,componentDef:k?.IkpTool,renderText:R,approvalId:N,messagePartsLength:r.parts.length,setApprovalDelayPending:L,addToolApprovalResponse:p,sendMessage:h,conversationId:i})},s.toolCallId??`${s.type}-${f}`):null}}}),Q&&e.jsx(T.MessageLoading,{}),(Y||Z)&&e.jsx(xe,{})]})};exports.DefaultToolComponent=W;exports.EmbeddedChatMessagePart=ye;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),ae=require("../../primitives/providers/base-events-provider.cjs"),se=require("../../primitives/providers/config-provider.cjs"),re=require("../../primitives/providers/message-provider.cjs"),C=require("../../primitives/components/embedded-chat.cjs"),ne=require("../../primitives/components/embedded-chat/chat-provider.cjs"),oe=require("../../primitives/utils/misc.cjs"),ie=require("merge-anything"),b=require("../utils.cjs"),le=require("./ui/markdown-styles.cjs"),de=require("../../primitives/components/embedded-chat/use-stream-processor.cjs"),ce=require("./data-summary-group.cjs"),o=require("react"),T=require("./embedded-chat.cjs"),c=require("lucide-react"),V=require("./ui/recipes/button.cjs"),pe={"input-streaming":"Pending","input-available":"Running","approval-requested":"Awaiting Approval","approval-responded":"Responded","output-available":"Completed","output-error":"Error","output-denied":"Denied"};function ue(t){if(!t||typeof t!="object")return!1;const a=t;return typeof a.type=="string"&&a.type.startsWith("tool-")}const me=t=>{if(!t||typeof t!="object"||!("status"in t))return;const a=t.status;return typeof a=="string"?a:void 0},xe=()=>e.jsx("div",{className:"flex space-x-1",children:[0,1,2].map(t=>e.jsx("span",{className:"animate-bounce-dot opacity-30",style:{animationDelay:`${t*.2}s`},children:"."},t))}),B=({name:t,Icon:a,props:l,componentType:n})=>e.jsxs("div",{className:"border rounded-lg bg-gray-50 dark:bg-gray-dark-800 mb-3",children:[e.jsxs("div",{className:"flex justify-between px-4 py-2 text-xs",children:[e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(a,{className:"w-3 h-3 text-gray-600 dark:text-white-alpha-600"}),e.jsx("span",{children:t})]}),e.jsx("div",{className:"flex items-center px-1.5 py-0.5 rounded-md text-2xs uppercase tracking-wider bg-gray-200 dark:bg-white-alpha-200 font-medium text-gray-700 dark:text-white-alpha-700 font-mono",children:n})]}),e.jsx("div",{className:"px-4 py-2",children:e.jsx(K,{value:l})})]}),he=({name:t,props:a})=>e.jsx(B,{name:t,Icon:c.ComponentIcon,props:a,componentType:"component"}),fe=({name:t,props:a})=>e.jsx(B,{name:t,Icon:c.Library,props:a,componentType:"artifact"}),ge=({tool:t,componentDef:a,renderText:l,approvalId:n,messagePartsLength:x,setApprovalDelayPending:s,addToolApprovalResponse:u,sendMessage:i,conversationId:g})=>{const d=o.useRef(i);d.current=i;const m=o.useRef(u);m.current=u;const p=o.useRef(s);p.current=s;const h=o.useCallback(async(E=!0)=>{n&&(p.current({partCount:x}),m.current({id:n,approved:E}),await d.current(void 0,{body:{conversationId:g}}))},[n,x,g]),k=o.useMemo(()=>({tool:t,approve:h,renderMarkdown:l}),[t]),A=a?T.DynamicComponent:W;return e.jsx(A,{name:t.type,props:k,componentDef:a})};function F(t){return t===null?e.jsx("span",{className:"text-gray-500 dark:text-white-alpha-500 font-mono font-medium text-1xs",children:"null"}):t===void 0?e.jsx("span",{className:"text-gray-400 dark:text-white-alpha-400 italic text-xs font-medium",children:"undefined"}):typeof t=="boolean"?e.jsx("span",{className:b.cn("inline-flex font-mono font-semibold items-center px-1 py-0.5 text-1xs rounded-md border",t?"bg-inkeep-expanded-primary-50 border-inkeep-expanded-primary-200 text-inkeep-expanded-primary-600 dark:bg-inkeep-expanded-primary-950 dark:border-inkeep-expanded-primary-600 dark:text-inkeep-expanded-primary-200":"bg-gray-100 dark:bg-white-alpha-50 text-gray-700 dark:text-white-alpha-700"),children:t?"true":"false"}):typeof t=="number"?e.jsx("span",{className:"tabular-nums font-medium text-inkeep-expanded-primary-600 dark:text-inkeep-expanded-primary-200",children:String(t)}):typeof t=="string"?e.jsx("span",{className:"text-gray-800 dark:text-white-alpha-800 break-words",children:t}):e.jsx("span",{children:String(t)})}const G=({name:t,value:a,isArrayIndex:l,depth:n=0})=>{const[x,s]=o.useState(n<1),u=a!==null&&typeof a=="object"&&!Array.isArray(a),i=Array.isArray(a);if(!(u||i))return e.jsxs("div",{className:"flex items-baseline gap-2 py-1 text-xs",children:[e.jsx("span",{className:b.cn("font-medium shrink-0",l?"text-gray-300 dark:text-white-alpha-300":"text-gray-500 dark:text-white-alpha-500"),children:l?"—":t}),e.jsx("span",{className:"min-w-0",children:F(a)})]});const d=i?a.map((p,h)=>[String(h),p]):Object.entries(a);return d.length===0?e.jsxs("div",{className:"flex items-baseline gap-2 py-1 text-xs",children:[e.jsx("span",{className:"font-medium text-gray-500 dark:text-white-alpha-500 shrink-0",children:t}),e.jsx("span",{className:"text-gray-400 dark:text-white-alpha-400 italic",children:i?"empty list":"empty"})]}):e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:p=>{p.stopPropagation(),s(!x)},className:"flex items-center gap-1.5 py-1 text-xs hover:bg-gray-50 dark:hover:bg-white-alpha-50 -mx-1.5 px-1.5 rounded transition-colors w-full text-left",children:[e.jsx(c.ChevronDown,{className:b.cn("h-3.5 w-3.5 text-gray-400 dark:text-white-alpha-400 shrink-0 transition-transform",!x&&"-rotate-90")}),e.jsx("span",{className:"font-medium text-gray-500 dark:text-white-alpha-500",children:t}),!x&&e.jsx("span",{className:"text-gray-400 dark:text-white-alpha-400 text-1xs ml-1",children:i?`${d.length} item${d.length!==1?"s":""}`:`${d.length} field${d.length!==1?"s":""}`})]}),x&&e.jsx("div",{className:"border-l-2 border-gray-200 dark:border-white-alpha-200 ml-1.5 pl-3",children:d.map(([p,h])=>e.jsx(G,{name:p,value:h,isArrayIndex:i,depth:n+1},p))})]})},K=({value:t})=>{if(t==null||typeof t!="object")return e.jsx("span",{className:"text-xs",children:F(t)});const a=Array.isArray(t)?t.map((l,n)=>[String(n),l]):Object.entries(t);return a.length===0?e.jsx("div",{className:"text-xs text-gray-400 dark:text-white-alpha-400 italic",children:"No arguments"}):e.jsx("div",{className:"space-y-1",children:a.map(([l,n])=>e.jsx(G,{name:l,value:n,isArrayIndex:Array.isArray(t)},l))})},W=({props:t})=>{const{tool:a,approve:l}=t,n=a.type,x=n.startsWith("tool-")?n.slice(5):n,s=a.state,u=a.approval?.id,i=!!u,g=s==="approval-requested",d=me(a.output),[m,p]=o.useState(i),h=s?pe[s]??s:"tool";o.useEffect(()=>{g&&p(!0)},[g]);const k=()=>{switch(s){case"input-streaming":return e.jsx(c.Circle,{className:"w-3 h-3"});case"input-available":return e.jsx(c.Loader2,{className:"w-3 h-3 animate-spin"});case"approval-requested":return e.jsx(c.Clock,{className:"w-3 h-3"});case"approval-responded":return e.jsx(c.CheckCircle,{className:"w-3 h-3"});case"output-available":return e.jsx(c.CheckCircle,{className:"w-3 h-3"});case"output-error":return e.jsx(c.TriangleAlert,{className:"w-3 h-3"});case"output-denied":return e.jsx(c.XCircle,{className:"w-3 h-3"});default:return null}};return e.jsxs("div",{className:"border rounded-lg mb-3 overflow-hidden",children:[e.jsxs("button",{type:"button",className:"inline-flex items-center group gap-2 text-xs text-gray-700 dark:text-white-alpha-700 hover:text-gray-800 dark:hover:text-white-alpha-800 transition-colors cursor-pointer w-full justify-between px-4 py-2 data-[expanded=true]:border-b",onClick:()=>p(!m),"aria-expanded":m,"data-expanded":m,children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(c.Hammer,{className:"w-3 h-3 text-gray-600 dark:text-white-alpha-600"}),e.jsx("span",{children:x})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-1.5 py-0.5 rounded-md text-2xs uppercase tracking-wider bg-gray-100 dark:bg-white-alpha-100 font-medium text-gray-700 dark:text-white-alpha-700 font-mono",children:[k(),h]}),e.jsx(c.ChevronDown,{className:"w-3.5 h-3.5 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 transform rotate-0 group-data-[expanded=true]:rotate-180"})]})]}),e.jsxs("div",{"data-expanded":m,className:b.cn("overflow-hidden transition-all duration-300 ease-in-out data-[expanded=true]:opacity-100 data-[expanded=false]:max-h-0 data-[expanded=false]:opacity-0 max-w-full"),children:[e.jsx("div",{"data-expanded":m,className:b.cn("relative",'before:content-[""] before:absolute before:inset-x-0 before:top-0 before:h-3 before:pointer-events-none before:z-10','after:content-[""] after:absolute after:inset-x-0 after:bottom-0 after:h-3 after:pointer-events-none after:z-10',"before:bg-[linear-gradient(white,_transparent)] after:bg-[linear-gradient(transparent,_white)]","dark:before:bg-[linear-gradient(var(--ikp-color-gray-dark-950),_transparent)] dark:after:bg-[linear-gradient(transparent,_var(--ikp-color-gray-dark-950))]","data-[expanded=false]:before:opacity-0 data-[expanded=false]:after:opacity-0"),children:e.jsx("div",{"data-expanded":m,className:b.cn("[scrollbar-width:thin] px-4","data-[expanded=true]:max-h-48 data-[expanded=true]:overflow-y-auto"),children:a.input!=null&&e.jsx("div",{className:"text-xs py-2",children:e.jsx(K,{value:a.input})})})}),g&&u&&e.jsxs("div",{className:"flex justify-end gap-2 pt-1 pb-3 px-4",children:[e.jsx("button",{type:"button",className:b.cn(V.button({size:"xs",variant:"outline"}),"px-2 py-1 rounded-md text-xs text-gray-700 dark:text-white-alpha-700"),onClick:()=>l(!1),children:"Deny"}),e.jsxs("button",{type:"button",className:b.cn(V.button({size:"xs",variant:"primaryFilled"}),"px-2 py-1 rounded-md text-xs gap-1"),onClick:()=>l(!0),children:[e.jsx(c.Check,{className:"w-3 h-3"}),"Approve"]})]}),s==="output-available"&&d&&a.output!=null&&e.jsxs("div",{className:"flex justify-end items-center gap-1 whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 capitalize pb-3 px-4",children:[d==="approved"&&e.jsx(c.Check,{className:"w-3 h-3"}),d]}),s==="output-denied"&&e.jsxs("div",{className:"flex justify-end items-center gap-1 whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 capitalize pb-3 px-4",children:[e.jsx(c.X,{className:"w-3 h-3"}),h]})]})]})},ye=({className:t,componentStyles:a,children:l,isLast:n,...x})=>{const{message:s}=re.useMessage(),{logEvent:u}=ae.useBaseEvents(),{conversationId:i,isStreaming:g,isLoading:d,setError:m,addToolApprovalResponse:p,sendMessage:h}=ne.useChat(),{aiChatSettings:{components:k,artifacts:A,headers:E}}=se.useInkeepConfig(),X=E?.["x-emit-operations"]==="true",$=s.role==="user",q=(g||d)&&n&&s.role==="assistant",{processedParts:H,summaryTimings:J,shouldShowInitialLoading:Q,shouldShowStreamDelayLoading:Y}=de.useStreamProcessor(s.parts,q,m),[S,L]=o.useState(null),[Z,M]=o.useState(!1),y=o.useRef(null);o.useEffect(()=>{if(!S){M(!1),y.current&&(clearTimeout(y.current),y.current=null);return}return M(!1),y.current&&clearTimeout(y.current),y.current=window.setTimeout(()=>{M(!0)},1e3),()=>{y.current&&(clearTimeout(y.current),y.current=null)}},[S]),o.useEffect(()=>{S&&(!n||s.parts.length>S.partCount||!q)&&L(null)},[S,n,s.parts.length,q]);const _=o.useMemo(()=>s.parts.filter(oe.isCitationArtifact),[s.parts]),O=o.useMemo(()=>ie.merge(le.markdownStyles,a??{}),[a]),z=o.useCallback((r,f)=>{u({eventName:"assistant_message_inline_link_opened",properties:{conversationId:i,messageId:s.id,title:f?.toString(),url:r}})},[u,i,s.id]),U=o.useCallback((r,f)=>{u({eventName:"assistant_code_block_copied",properties:{conversationId:i,messageId:s.id,language:r,code:f}})},[u,i,s.id]),I=o.useCallback(r=>e.jsx(C.EmbeddedChatPrimitiveMarkdown,{text:r,componentStyles:O,onLinkClick:z,onCodeCopy:U,artifacts:_}),[O,z,U,_]),ee=o.useMemo(()=>b.cn("data-[role=user]:whitespace-pre-wrap mb-3 data-[role=user]:mb-0 [&[data-role=user]>p]:mb-0 max-w-full",t),[t]),te=!$||s.parts.some(r=>r.type==="text"&&r.text?.trim());return e.jsxs(e.Fragment,{children:[!te&&e.jsx("span",{className:"text-gray-500 dark:text-white-alpha-500",children:"No message content"}),H.map((r,f)=>{const v={"data-role":s.role,"data-type":r?.type==="data-component"?r.data.type:r?.type,...x,className:ee};switch(r?.type){case"text":return e.jsx(C.PrimitiveMessagePart,{...v,children:$?r.text:I(r.text||"")},f);case"data-component":{const{type:w}=r.data;switch(w){case"text":return e.jsx("div",{...v,children:I(r.data.text||"")},f);default:{const N=r.data,{name:j,props:D}=N,P=k?.[j],R=P?T.DynamicComponent:he;return e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(R,{name:j,props:{...D,messageId:s.id},componentDef:P})},`${j}-${f}`)}}}case"data-artifact":{const w=r.data,{name:N,type:j,artifactSummary:D}=w;if(j==="citation"&&!D?.url)return null;const P=A?.[j],R=P?T.DynamicComponent:fe;return e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(R,{name:j,props:{...D,messageId:s.id},componentDef:P})},`${N}-${f}`)}case"summary-group":{const w=J.get(r.groupKey)||{isCompleted:!1};return e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(ce.DataSummaryGroup,{summaries:r.summaries||[],isCompleted:w.isCompleted})},`${r.groupKey}-${f}`)}default:{if(!ue(r))return null;const w=r,N=r.approval?.id;return X||N?e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(ge,{tool:w,componentDef:k?.IkpTool,renderText:I,approvalId:N,messagePartsLength:s.parts.length,setApprovalDelayPending:L,addToolApprovalResponse:p,sendMessage:h,conversationId:i})},r.toolCallId??`${r.type}-${f}`):null}}}),Q&&e.jsx(T.MessageLoading,{}),(Y||Z)&&e.jsx(xe,{})]})};exports.DefaultToolComponent=W;exports.EmbeddedChatMessagePart=ye;
|
|
@@ -11,7 +11,7 @@ import { cn as y } from "../utils.js";
|
|
|
11
11
|
import { markdownStyles as fe } from "./ui/markdown-styles.js";
|
|
12
12
|
import { useStreamProcessor as ge } from "../../primitives/components/embedded-chat/use-stream-processor.js";
|
|
13
13
|
import { DataSummaryGroup as ye } from "./data-summary-group.js";
|
|
14
|
-
import { useState as
|
|
14
|
+
import { useState as P, useEffect as M, useRef as A, useMemo as E, useCallback as I } from "react";
|
|
15
15
|
import { DynamicComponent as R, MessageLoading as be } from "./embedded-chat.js";
|
|
16
16
|
import { Hammer as we, ChevronDown as G, Check as K, X as ke, XCircle as Ne, TriangleAlert as ve, CheckCircle as W, Clock as Ce, Loader2 as De, Circle as Se, Library as Te, ComponentIcon as Ae } from "lucide-react";
|
|
17
17
|
import { button as X } from "./ui/recipes/button.js";
|
|
@@ -24,12 +24,12 @@ const Ee = {
|
|
|
24
24
|
"output-error": "Error",
|
|
25
25
|
"output-denied": "Denied"
|
|
26
26
|
};
|
|
27
|
-
function
|
|
27
|
+
function Ie(t) {
|
|
28
28
|
if (!t || typeof t != "object") return !1;
|
|
29
29
|
const a = t;
|
|
30
30
|
return typeof a.type == "string" && a.type.startsWith("tool-");
|
|
31
31
|
}
|
|
32
|
-
const
|
|
32
|
+
const Pe = (t) => {
|
|
33
33
|
if (!t || typeof t != "object" || !("status" in t)) return;
|
|
34
34
|
const a = t.status;
|
|
35
35
|
return typeof a == "string" ? a : void 0;
|
|
@@ -69,7 +69,7 @@ const Ie = (t) => {
|
|
|
69
69
|
m.current = c;
|
|
70
70
|
const p = A(r);
|
|
71
71
|
p.current = r;
|
|
72
|
-
const h =
|
|
72
|
+
const h = I(
|
|
73
73
|
async (j = !0) => {
|
|
74
74
|
s && (p.current({ partCount: u }), m.current({ id: s, approved: j }), await d.current(void 0, { body: { conversationId: f } }));
|
|
75
75
|
},
|
|
@@ -95,7 +95,7 @@ const Q = ({
|
|
|
95
95
|
isArrayIndex: l,
|
|
96
96
|
depth: s = 0
|
|
97
97
|
}) => {
|
|
98
|
-
const [u, r] =
|
|
98
|
+
const [u, r] = P(s < 1), c = a !== null && typeof a == "object" && !Array.isArray(a), i = Array.isArray(a);
|
|
99
99
|
if (!(c || i))
|
|
100
100
|
return /* @__PURE__ */ o("div", { className: "flex items-baseline gap-2 py-1 text-xs", children: [
|
|
101
101
|
/* @__PURE__ */ e(
|
|
@@ -146,7 +146,7 @@ const Q = ({
|
|
|
146
146
|
const a = Array.isArray(t) ? t.map((l, s) => [String(s), l]) : Object.entries(t);
|
|
147
147
|
return a.length === 0 ? /* @__PURE__ */ e("div", { className: "text-xs text-gray-400 dark:text-white-alpha-400 italic", children: "No arguments" }) : /* @__PURE__ */ e("div", { className: "space-y-1", children: a.map(([l, s]) => /* @__PURE__ */ e(Q, { name: l, value: s, isArrayIndex: Array.isArray(t) }, l)) });
|
|
148
148
|
}, Me = ({ props: t }) => {
|
|
149
|
-
const { tool: a, approve: l } = t, s = a.type, u = s.startsWith("tool-") ? s.slice(5) : s, r = a.state, c = a.approval?.id, i = !!c, f = r === "approval-requested", d =
|
|
149
|
+
const { tool: a, approve: l } = t, s = a.type, u = s.startsWith("tool-") ? s.slice(5) : s, r = a.state, c = a.approval?.id, i = !!c, f = r === "approval-requested", d = Pe(a.output), [m, p] = P(i), h = r ? Ee[r] ?? r : "tool";
|
|
150
150
|
return M(() => {
|
|
151
151
|
f && p(!0);
|
|
152
152
|
}, [f]), /* @__PURE__ */ o("div", { className: "border rounded-lg mb-3 overflow-hidden", children: [
|
|
@@ -275,7 +275,7 @@ const Q = ({
|
|
|
275
275
|
}) => {
|
|
276
276
|
const { message: r } = ce(), { logEvent: c } = de(), { conversationId: i, isStreaming: f, isLoading: d, setError: m, addToolApprovalResponse: p, sendMessage: h } = ue(), {
|
|
277
277
|
aiChatSettings: { components: v, artifacts: O, headers: j }
|
|
278
|
-
} = pe(), Z = j?.["x-emit-operations"] === "true", z = r.role === "user", L = (f || d) && s && r.role === "assistant", { processedParts: ee, summaryTimings: te, shouldShowInitialLoading: ae, shouldShowStreamDelayLoading: re } = ge(r.parts, L, m), [C, q] =
|
|
278
|
+
} = pe(), Z = j?.["x-emit-operations"] === "true", z = r.role === "user", L = (f || d) && s && r.role === "assistant", { processedParts: ee, summaryTimings: te, shouldShowInitialLoading: ae, shouldShowStreamDelayLoading: re } = ge(r.parts, L, m), [C, q] = P(null), [ne, _] = P(!1), g = A(null);
|
|
279
279
|
M(() => {
|
|
280
280
|
if (!C) {
|
|
281
281
|
_(!1), g.current && (clearTimeout(g.current), g.current = null);
|
|
@@ -292,7 +292,7 @@ const Q = ({
|
|
|
292
292
|
const U = E(() => r.parts.filter(he), [r.parts]), V = E(
|
|
293
293
|
() => xe(fe, a ?? {}),
|
|
294
294
|
[a]
|
|
295
|
-
), B =
|
|
295
|
+
), B = I(
|
|
296
296
|
(n, x) => {
|
|
297
297
|
c({
|
|
298
298
|
eventName: "assistant_message_inline_link_opened",
|
|
@@ -305,7 +305,7 @@ const Q = ({
|
|
|
305
305
|
});
|
|
306
306
|
},
|
|
307
307
|
[c, i, r.id]
|
|
308
|
-
), F =
|
|
308
|
+
), F = I(
|
|
309
309
|
(n, x) => {
|
|
310
310
|
c({
|
|
311
311
|
eventName: "assistant_code_block_copied",
|
|
@@ -318,7 +318,7 @@ const Q = ({
|
|
|
318
318
|
});
|
|
319
319
|
},
|
|
320
320
|
[c, i, r.id]
|
|
321
|
-
), $ =
|
|
321
|
+
), $ = I(
|
|
322
322
|
(n) => /* @__PURE__ */ e(
|
|
323
323
|
me,
|
|
324
324
|
{
|
|
@@ -358,7 +358,14 @@ const Q = ({
|
|
|
358
358
|
return /* @__PURE__ */ e("div", { ...k, children: $(n.data.text || "") }, x);
|
|
359
359
|
default: {
|
|
360
360
|
const N = n.data, { name: b, props: T } = N, D = v?.[b];
|
|
361
|
-
return /* @__PURE__ */ e(S, { ...k, children: /* @__PURE__ */ e(
|
|
361
|
+
return /* @__PURE__ */ e(S, { ...k, children: /* @__PURE__ */ e(
|
|
362
|
+
D ? R : Le,
|
|
363
|
+
{
|
|
364
|
+
name: b,
|
|
365
|
+
props: { ...T, messageId: r.id },
|
|
366
|
+
componentDef: D
|
|
367
|
+
}
|
|
368
|
+
) }, `${b}-${x}`);
|
|
362
369
|
}
|
|
363
370
|
}
|
|
364
371
|
}
|
|
@@ -366,7 +373,14 @@ const Q = ({
|
|
|
366
373
|
const w = n.data, { name: N, type: b, artifactSummary: T } = w;
|
|
367
374
|
if (b === "citation" && !T?.url) return null;
|
|
368
375
|
const D = O?.[b];
|
|
369
|
-
return /* @__PURE__ */ e(S, { ...k, children: /* @__PURE__ */ e(
|
|
376
|
+
return /* @__PURE__ */ e(S, { ...k, children: /* @__PURE__ */ e(
|
|
377
|
+
D ? R : _e,
|
|
378
|
+
{
|
|
379
|
+
name: b,
|
|
380
|
+
props: { ...T, messageId: r.id },
|
|
381
|
+
componentDef: D
|
|
382
|
+
}
|
|
383
|
+
) }, `${N}-${x}`);
|
|
370
384
|
}
|
|
371
385
|
case "summary-group": {
|
|
372
386
|
const w = te.get(n.groupKey) || {
|
|
@@ -381,7 +395,7 @@ const Q = ({
|
|
|
381
395
|
) }, `${n.groupKey}-${x}`);
|
|
382
396
|
}
|
|
383
397
|
default: {
|
|
384
|
-
if (!
|
|
398
|
+
if (!Ie(n))
|
|
385
399
|
return null;
|
|
386
400
|
const w = n, N = n.approval?.id;
|
|
387
401
|
return Z || N ? /* @__PURE__ */ e(S, { ...k, children: /* @__PURE__ */ e(
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ToolUIPart } from 'ai';
|
|
2
2
|
import { Message } from '../message';
|
|
3
3
|
export type ComponentsConfig<A extends Record<string, unknown>> = {
|
|
4
|
-
[K in keyof A]: (props: A[K]
|
|
4
|
+
[K in keyof A]: (props: A[K] & {
|
|
5
|
+
messageId: string;
|
|
6
|
+
}, target: HTMLElement, context: null) => void | React.ReactNode;
|
|
5
7
|
} & {
|
|
6
8
|
IkpMessage?(props: {
|
|
7
9
|
message: Message;
|