{"version":3,"file":"AIAssistantMessage.mjs","names":[],"sources":["../../../../../src/plugins/AIComponents/Message/AIAssistantMessage.tsx"],"sourcesContent":["import React from 'react';\nimport clsx from 'clsx';\n\nimport { AIMessageParts } from '../MessageParts/AIMessageParts';\nimport type { AIMessagePartData } from '../MessageParts/types';\nimport { StreamingMessage } from '../StreamingMessage/StreamingMessage';\nimport type { AIToolApprover } from '../ToolCalls/AIToolApprover';\nimport { AIMessageAttachment, type AIMessageAttachmentData } from './AIMessageAttachment';\nimport { ThemeScopeProvider, useAIThemeScopeClassName } from '../themeScope';\n\nexport type AIAssistantMessageProps = {\n  /** The answer, in Markdown. */\n  text: string;\n  /**\n   * Who answers tool calls' questions and sign-ins on this device, to ask them. Defaults to the\n   * one of the nearest `AIToolApproverProvider`.\n   */\n  approver?: AIToolApprover;\n  /** What the agent sent with it, such as images and files. */\n  attachments?: AIMessageAttachmentData[];\n  className?: string;\n  /** Whether the agent is still writing it. The text that arrives meanwhile is typed out. */\n  isGenerating?: boolean;\n  /** The steps the agent took, in order, shown before the answer. */\n  parts?: AIMessagePartData[];\n  /** The whole of a reasoning step's thinking, when the app has it. */\n  reasoningText?: (stepId: string) => string | undefined;\n};\n\n/**\n * The agent's reply: its steps (reasoning, tool calls and their questions), then its answer,\n * typed out as it streams in, then what it sent with it. The counterpart of\n * `AIAssistantMessageView`.\n */\nexport const AIAssistantMessage = ({\n  approver,\n  attachments = [],\n  className,\n  isGenerating = false,\n  parts = [],\n  reasoningText,\n  text,\n}: AIAssistantMessageProps) => {\n  const themeScopeClassName = useAIThemeScopeClassName();\n  return (\n    <ThemeScopeProvider>\n      <div\n        aria-busy={isGenerating}\n        className={clsx(\n          themeScopeClassName,\n          'str-chat__ai-assistant-message',\n          isGenerating && 'str-chat__ai-assistant-message--generating',\n          className,\n        )}\n      >\n        {parts.length > 0 && (\n          <AIMessageParts\n            approver={approver}\n            parts={parts}\n            reasoningText={reasoningText}\n          />\n        )}\n        {/* What arrives after mount is typed out; a reply loaded from history shows at once. */}\n        {text !== '' && <StreamingMessage text={text} />}\n        {attachments.length > 0 && (\n          <div className='str-chat__ai-assistant-message__attachments'>\n            {attachments.map((attachment, index) => (\n              <AIMessageAttachment attachment={attachment} key={index} role='assistant' />\n            ))}\n          </div>\n        )}\n      </div>\n    </ThemeScopeProvider>\n  );\n};\n"],"mappings":";;;;;;;;;;;;;;AAkCA,IAAa,sBAAsB,EACjC,UACA,cAAc,CAAC,GACf,WACA,eAAe,OACf,QAAQ,CAAC,GACT,eACA,WAC6B;CAE7B,OACE,oBAAC,oBAAD,EAAA,UACE,qBAAC,OAAD;EACE,aAAW;EACX,WAAW,KALW,yBAMpB,GACA,kCACA,gBAAgB,8CAChB,SACF;YAPF;GASG,MAAM,SAAS,KACd,oBAAC,gBAAD;IACY;IACH;IACQ;GAChB,CAAA;GAGF,SAAS,MAAM,oBAAC,kBAAD,EAAwB,KAAO,CAAA;GAC9C,YAAY,SAAS,KACpB,oBAAC,OAAD;IAAK,WAAU;cACZ,YAAY,KAAK,YAAY,UAC5B,oBAAC,qBAAD;KAAiC;KAAwB,MAAK;IAAa,GAAzB,KAAyB,CAC5E;GACE,CAAA;EAEJ;IACa,CAAA;AAExB"}