@langchain/macaw-components 1.7.4 → 1.7.6

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.
@@ -204,11 +204,11 @@ var MARKDOWN_COMPONENTS = {
204
204
  }),
205
205
  th: ({ node: _node, ...props }) => /* @__PURE__ */ jsx("th", {
206
206
  ...props,
207
- className: "border border-default bg-surface-level-2 px-space-2 py-space-1 font-semibold"
207
+ className: "border border-subtle dark:border-muted bg-surface-level-2 px-space-2 py-space-1 font-semibold"
208
208
  }),
209
209
  td: ({ node: _node, ...props }) => /* @__PURE__ */ jsx("td", {
210
210
  ...props,
211
- className: "border border-default px-space-2 py-space-1 align-top"
211
+ className: "border border-subtle dark:border-muted px-space-2 py-space-1 align-top"
212
212
  }),
213
213
  hr: ({ node: _node, ...props }) => /* @__PURE__ */ jsx("hr", {
214
214
  ...props,
@@ -234,10 +234,11 @@ var MARKDOWN_COMPONENTS = {
234
234
  *
235
235
  * Raw HTML is never interpreted. Tags display as text by default; opt in to
236
236
  * XML sections turn custom wrappers into labels and nested blockquotes.
237
- * Content above the shared text length limit renders as plain text,
238
- * truncated behind a Show more toggle unless `fullLength` is set.
237
+ * Content above `maxMarkdownLength` (by default the shared text length limit)
238
+ * renders as plain text, truncated behind a Show more toggle unless
239
+ * `fullLength` is set.
239
240
  */
240
- function MarkdownDisplay({ content, isStreaming = false, xmlTags = "literal", className, fullLength = false, containerHeight, preserveNewlines = false, codeOverflow = "wrap", textColor = "primary", loadImages = false, components, trailingContent, afterContent }) {
241
+ function MarkdownDisplay({ content, isStreaming = false, xmlTags = "literal", className, fullLength = false, containerHeight, maxMarkdownLength = MAX_TEXT_LENGTH, preserveNewlines = false, codeOverflow = "wrap", textColor = "primary", loadImages = false, components, trailingContent, afterContent }) {
241
242
  const markdownComponents = useMemo(() => components ? {
242
243
  ...MARKDOWN_COMPONENTS,
243
244
  ...components
@@ -251,7 +252,7 @@ function MarkdownDisplay({ content, isStreaming = false, xmlTags = "literal", cl
251
252
  trailingContent,
252
253
  codeOverflow
253
254
  ]);
254
- const isPlainText = content.length > MAX_TEXT_LENGTH;
255
+ const isPlainText = content.length > maxMarkdownLength;
255
256
  const markdown = useMemo(() => {
256
257
  if (isPlainText) return content;
257
258
  const prepared = xmlTags === "sections" ? prepareMarkdownXml(content) : content;
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownDisplay.js","names":[],"sources":["../../../src/components/MarkdownDisplay/MarkdownDisplay.tsx"],"sourcesContent":["import {\n createContext,\n isValidElement,\n type ComponentProps,\n type MouseEvent,\n type ReactNode,\n useContext,\n useId,\n useMemo,\n} from 'react';\n\nimport type { Components, ExtraProps } from 'react-markdown';\nimport ReactMarkdown from 'react-markdown';\nimport remarkGfm from 'remark-gfm';\nimport remend from 'remend';\n\nimport { ImageIcon } from '@phosphor-icons/react/dist/ssr/Image';\nimport { WarningCircleIcon } from '@phosphor-icons/react/dist/ssr/WarningCircle';\n\nimport { cn } from '../../utils/cn';\nimport { makeComponentName } from '../../utils/componentUtils';\nimport { Checkbox } from '../Checkbox';\nimport { MAX_TEXT_LENGTH } from '../Code/constants';\nimport { ErrorBoundary } from '../ErrorBoundary';\nimport { Icon } from '../Icon';\nimport { Link } from '../Link';\nimport { Text, type TextProps } from '../Text';\nimport { TextWithLinks } from '../TextWithLinks';\nimport { MarkdownCodeBlock } from './MarkdownCodeBlock';\nimport {\n TRAILING_SLOT_ATTRIBUTE,\n rehypeMarkdownDisplay,\n remarkDisableRawHtml,\n} from './markdownPlugins';\nimport { prepareMarkdownXml } from './prepareMarkdownXml';\n\ntype TextColor = NonNullable<TextProps['color']>;\ntype ListType = 'ordered' | 'unordered';\ntype HeadingVariant = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\ntype HeadingProps = ComponentProps<HeadingVariant> & ExtraProps;\ntype ListItemProps = ComponentProps<'li'> & ExtraProps;\ntype InputProps = ComponentProps<'input'> & ExtraProps;\ntype ImageProps = ComponentProps<'img'> & ExtraProps;\ntype SpanProps = ComponentProps<'span'> & ExtraProps;\n\ninterface MarkdownDisplayContextValue {\n loadImages: boolean;\n trailingContent: ReactNode;\n codeOverflow: 'wrap' | 'scroll';\n}\n\nconst COMPONENT_NAME = makeComponentName('MarkdownDisplay');\nconst PLAIN_TEXT_FALLBACK_MESSAGE =\n 'Shown as plain text because this block is too large for Markdown.';\nconst REMARK_PLUGINS = [remarkGfm, remarkDisableRawHtml];\nconst REHYPE_PLUGINS = [rehypeMarkdownDisplay];\nconst ListTypeContext = createContext<ListType>('unordered');\n/** The id of the enclosing task list item, which names its checkbox. */\nconst TaskItemContext = createContext<string | undefined>(undefined);\nconst MarkdownDisplayContext = createContext<MarkdownDisplayContextValue>({\n loadImages: false,\n trailingContent: null,\n codeOverflow: 'wrap',\n});\n\nconst blockSpacing =\n 'mt-space-4 first:mt-0 [:is(h1,h2,h3,h4,h5,h6)+&]:mt-space-2';\n/** Inline links keep the size and rhythm of the text they sit in. */\nconst inlineLinkClassName =\n 'inline text-[length:inherit] leading-[inherit] tracking-[inherit]';\n\nfunction MarkdownListItem({\n children,\n className,\n id,\n node: _node,\n ...props\n}: ListItemProps) {\n const listType = useContext(ListTypeContext);\n const generatedId = useId();\n const isTask = className?.split(' ').includes('task-list-item') ?? false;\n const hasBullet = listType === 'unordered' && !isTask;\n const itemId = id ?? (isTask ? generatedId : undefined);\n\n return (\n <TaskItemContext.Provider value={isTask ? itemId : undefined}>\n <li\n {...props}\n id={itemId}\n className={cn(\n 'text-sm leading-normal tracking-normal',\n hasBullet && 'relative pl-space-3',\n isTask &&\n 'relative list-none pl-space-5 has-[[data-state=checked]]:text-quaternary has-[[data-state=checked]]:line-through',\n className\n )}\n >\n {children}\n {/* Last so the item's first block keeps its first-child spacing. */}\n {hasBullet && (\n <span\n aria-hidden\n className=\"absolute left-0 top-[0.65em] size-1 rounded-full bg-current\"\n />\n )}\n </li>\n </TaskItemContext.Provider>\n );\n}\n\nfunction MarkdownTaskCheckbox({ checked, type }: InputProps) {\n const taskItemId = useContext(TaskItemContext);\n if (type !== 'checkbox') return null;\n\n const checkboxProps = {\n checked: checked ?? false,\n 'aria-readonly': true,\n tabIndex: -1,\n onClick: (event: MouseEvent<HTMLButtonElement>) => event.preventDefault(),\n size: 'sm',\n className: 'pointer-events-none',\n containerClassName: 'absolute left-0 top-[calc(0.75em_-_0.5rem)]',\n } as const;\n\n return taskItemId ? (\n <Checkbox {...checkboxProps} aria-labelledby={taskItemId} />\n ) : (\n <Checkbox\n {...checkboxProps}\n aria-label={checked ? 'Completed task' : 'Open task'}\n />\n );\n}\n\nfunction MarkdownImage({\n alt = '',\n src,\n className,\n node: _node,\n ...props\n}: ImageProps) {\n const { loadImages } = useContext(MarkdownDisplayContext);\n\n if (typeof src !== 'string' || !src) {\n return <span className=\"text-tertiary\">{alt}</span>;\n }\n\n if (!loadImages) {\n return (\n <Link\n href={src}\n variant=\"body\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n leftDecorator={ImageIcon}\n // Preflight makes SVGs block-level; keep the icon on the text line.\n className={cn(\n inlineLinkClassName,\n '[&>svg]:mr-[2px] [&>svg]:inline [&>svg]:align-[-0.125em]'\n )}\n >\n {alt || src}\n </Link>\n );\n }\n\n return (\n <img\n {...props}\n src={src}\n alt={alt}\n loading=\"lazy\"\n referrerPolicy=\"no-referrer\"\n className={cn(\n blockSpacing,\n 'h-auto max-w-full rounded-md border border-subtle',\n className\n )}\n />\n );\n}\n\nfunction MarkdownSpan({ node: _node, ...props }: SpanProps) {\n const { trailingContent } = useContext(MarkdownDisplayContext);\n if (TRAILING_SLOT_ATTRIBUTE in props) return <>{trailingContent}</>;\n return <span {...props} />;\n}\n\nconst createHeading = (\n variant: HeadingVariant,\n headingClassName: string,\n weight: TextProps['weight'] = 'semibold',\n color?: TextColor\n) =>\n function MarkdownHeading({\n children,\n className,\n color: _color,\n node: _node,\n ...props\n }: HeadingProps) {\n return (\n <Text\n {...props}\n as={variant}\n variant={variant}\n weight={weight}\n color={color}\n className={cn(blockSpacing, headingClassName, className)}\n >\n {children}\n </Text>\n );\n };\n\nconst MARKDOWN_COMPONENTS: Components = {\n pre: function MarkdownPre({ children }) {\n const { codeOverflow } = useContext(MarkdownDisplayContext);\n const child = isValidElement<{\n children?: ReactNode;\n className?: string;\n }>(children)\n ? children\n : undefined;\n const language = child?.props.className?.match(/language-([^\\s]+)/)?.[1];\n const code =\n typeof child?.props.children === 'string'\n ? child.props.children\n : String(child?.props.children ?? '');\n\n return (\n <div\n data-search-block=\"\"\n data-search-code=\"\"\n className={cn('w-full min-w-0', blockSpacing)}\n >\n <MarkdownCodeBlock\n code={code}\n language={language}\n codeOverflow={codeOverflow}\n />\n </div>\n );\n },\n code: ({ children, className, node: _node, ...props }) => (\n <code\n {...props}\n className={cn(\n 'rounded-xs bg-surface-level-3 px-space-1 py-px font-mono text-[length:0.9em] leading-[inherit] tracking-normal text-tertiary',\n className\n )}\n >\n {children}\n </code>\n ),\n a: ({ children, href, className, node: _node, ...props }) => {\n if (!href) return <span>{children}</span>;\n // Fragment links (footnote references and back-references) stay in page.\n const opensNewTab = !href.startsWith('#');\n\n return (\n <Link\n {...props}\n href={href}\n variant=\"body\"\n target={opensNewTab ? '_blank' : undefined}\n rel={opensNewTab ? 'noopener noreferrer' : undefined}\n className={cn(inlineLinkClassName, className)}\n >\n {children}\n </Link>\n );\n },\n h1: createHeading('h1', 'text-xl leading-tight'),\n h2: createHeading('h2', 'text-lg leading-tight'),\n h3: createHeading('h3', 'text-base leading-tight'),\n h4: createHeading('h4', 'text-sm leading-tight', 'semibold', 'quaternary'),\n h5: createHeading('h5', 'text-sm leading-tight', 'semibold', 'secondary'),\n h6: createHeading('h6', 'text-sm leading-tight', 'medium', 'secondary'),\n p: ({ children, className, color: _color, node: _node, ...props }) => (\n <Text\n {...props}\n as=\"p\"\n variant=\"body\"\n className={cn('mt-space-3 first:mt-0', className)}\n >\n {children}\n </Text>\n ),\n blockquote: ({ node: _node, ...props }) => (\n <blockquote\n {...props}\n className={cn(\n blockSpacing,\n 'border-l-4 border-default bg-surface-level-2 py-space-2 pl-space-4 pr-space-3 italic [overflow-wrap:anywhere]'\n )}\n />\n ),\n ul: ({ className, node: _node, ...props }) => (\n <ListTypeContext.Provider value=\"unordered\">\n <ul\n {...props}\n className={cn(\n blockSpacing,\n 'ml-space-3 flex flex-col gap-space-1 [li>&]:mt-space-1',\n className\n )}\n />\n </ListTypeContext.Provider>\n ),\n ol: ({ className, start, style, node, ...props }) => {\n const itemCount =\n node?.children.filter(\n (child) => child.type === 'element' && child.tagName === 'li'\n ).length ?? 0;\n const firstNumber = start ?? 1;\n const lastNumber = firstNumber + Math.max(itemCount - 1, 0);\n const markerDigits = Math.max(\n String(firstNumber).length,\n String(lastNumber).length\n );\n\n return (\n <ListTypeContext.Provider value=\"ordered\">\n <ol\n {...props}\n start={start}\n // Outside markers sit in this padding, so it widens with the\n // longest number instead of letting markers overflow and clip.\n style={{ ...style, paddingInlineStart: `${markerDigits + 1.5}ch` }}\n className={cn(\n blockSpacing,\n 'flex list-outside list-decimal flex-col gap-space-1 [li>&]:mt-space-1',\n className\n )}\n />\n </ListTypeContext.Provider>\n );\n },\n li: MarkdownListItem,\n input: MarkdownTaskCheckbox,\n table: ({ node: _node, ...props }) => (\n <div\n data-search-block=\"\"\n role=\"region\"\n aria-label=\"Table\"\n tabIndex={0}\n className={cn(\n blockSpacing,\n 'w-full overflow-x-auto focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus'\n )}\n >\n <table\n {...props}\n className=\"w-full min-w-max border-collapse text-left text-xs\"\n />\n </div>\n ),\n th: ({ node: _node, ...props }) => (\n <th\n {...props}\n className=\"border border-default bg-surface-level-2 px-space-2 py-space-1 font-semibold\"\n />\n ),\n td: ({ node: _node, ...props }) => (\n <td\n {...props}\n className=\"border border-default px-space-2 py-space-1 align-top\"\n />\n ),\n hr: ({ node: _node, ...props }) => (\n <hr {...props} className={cn(blockSpacing, 'border-default')} />\n ),\n strong: ({ className, node: _node, ...props }) => (\n <strong {...props} className={cn('font-semibold', className)} />\n ),\n em: ({ className, node: _node, ...props }) => (\n <em {...props} className={cn('italic', className)} />\n ),\n del: ({ node: _node, ...props }) => (\n <del {...props} className=\"text-tertiary\" />\n ),\n img: MarkdownImage,\n span: MarkdownSpan,\n};\n\nexport interface MarkdownDisplayProps {\n /** Markdown source to render. */\n content: string;\n /** Render custom XML wrappers as labeled sections, or keep tags literal (default). */\n xmlTags?: 'literal' | 'sections';\n /** Repair unfinished Markdown while content streams; use the original Markdown when false. */\n isStreaming?: boolean;\n className?: string;\n /**\n * Render oversized content in full as linkified, non-virtualized plain text\n * instead of truncating it behind a Show more toggle. Ignores\n * `containerHeight`.\n */\n fullLength?: boolean;\n /**\n * Viewport height for truncated oversized content. When set, that content\n * renders in a virtualized plain-text viewport whose URLs are not\n * linkified.\n */\n containerHeight?: string;\n /** Preserve single newlines visually without changing Markdown parsing. */\n preserveNewlines?: boolean;\n /** Wrap long fenced code lines by default, or scroll them horizontally. */\n codeOverflow?: 'wrap' | 'scroll';\n /** Color applied to text-bearing Markdown elements. */\n textColor?: TextColor;\n /**\n * Load images referenced by the Markdown. Off by default: loading a remote\n * image from untrusted content sends a request, and anything encoded in its\n * URL, without user action. Images otherwise render as links.\n */\n loadImages?: boolean;\n /**\n * Override or extend the default react-markdown component mapping. Keep\n * override components stable across renders; a new component function\n * remounts every element it renders.\n */\n components?: Components;\n /**\n * Content that continues the rendered flow: inline after the final\n * paragraph's text, or after the last block when content ends otherwise.\n */\n trailingContent?: ReactNode;\n /** Content rendered after the Markdown content container. */\n afterContent?: ReactNode;\n}\n\n/**\n * Renders untrusted Markdown with GFM support and Macaw presentation.\n *\n * Raw HTML is never interpreted. Tags display as text by default; opt in to\n * XML sections turn custom wrappers into labels and nested blockquotes.\n * Content above the shared text length limit renders as plain text,\n * truncated behind a Show more toggle unless `fullLength` is set.\n */\nexport function MarkdownDisplay({\n content,\n isStreaming = false,\n xmlTags = 'literal',\n className,\n fullLength = false,\n containerHeight,\n preserveNewlines = false,\n codeOverflow = 'wrap',\n textColor = 'primary',\n loadImages = false,\n components,\n trailingContent,\n afterContent,\n}: MarkdownDisplayProps) {\n const markdownComponents = useMemo(\n () =>\n components\n ? { ...MARKDOWN_COMPONENTS, ...components }\n : MARKDOWN_COMPONENTS,\n [components]\n );\n const contextValue = useMemo(\n () => ({ loadImages, trailingContent, codeOverflow }),\n [loadImages, trailingContent, codeOverflow]\n );\n const isPlainText = content.length > MAX_TEXT_LENGTH;\n const markdown = useMemo(() => {\n if (isPlainText) return content;\n const prepared =\n xmlTags === 'sections' ? prepareMarkdownXml(content) : content;\n return isStreaming\n ? remend(prepared, {\n // Partial destinations must never become clickable links.\n linkMode: 'text-only',\n // HTML is literal text here, and math rendering is unsupported.\n htmlTags: false,\n katex: false,\n })\n : prepared;\n }, [content, isPlainText, isStreaming, xmlTags]);\n\n const plainText = (\n <>\n <TextWithLinks\n text={content}\n fullLength={fullLength}\n containerHeight={containerHeight}\n useRawSpan\n />\n {trailingContent}\n </>\n );\n\n return (\n <div\n data-component={COMPONENT_NAME}\n aria-busy={isStreaming || undefined}\n className={cn('min-w-0 text-sm', className)}\n >\n <Text\n as=\"div\"\n variant=\"body\"\n color={textColor}\n data-search-kind=\"container\"\n className={cn(\n 'min-w-0 break-words',\n preserveNewlines && 'whitespace-pre-wrap'\n )}\n >\n {isPlainText ? (\n <div className=\"relative pr-space-5\">\n <Icon\n data-search-ignore=\"\"\n icon={WarningCircleIcon}\n color=\"warning\"\n size=\"xs\"\n label={PLAIN_TEXT_FALLBACK_MESSAGE}\n role=\"img\"\n tabIndex={0}\n aria-label={PLAIN_TEXT_FALLBACK_MESSAGE}\n className=\"absolute right-0 top-0\"\n />\n {plainText}\n </div>\n ) : (\n <ErrorBoundary resetKey={content} fallback={() => plainText}>\n <MarkdownDisplayContext.Provider value={contextValue}>\n <ReactMarkdown\n remarkPlugins={REMARK_PLUGINS}\n rehypePlugins={REHYPE_PLUGINS}\n components={markdownComponents}\n >\n {markdown}\n </ReactMarkdown>\n </MarkdownDisplayContext.Provider>\n </ErrorBoundary>\n )}\n </Text>\n {afterContent}\n </div>\n );\n}\n\nMarkdownDisplay.displayName = COMPONENT_NAME;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmDA,IAAM,iBAAiB,kBAAkB,iBAAiB;AAC1D,IAAM,8BACJ;AACF,IAAM,iBAAiB,CAAC,WAAW,oBAAoB;AACvD,IAAM,iBAAiB,CAAC,qBAAqB;AAC7C,IAAM,kBAAkB,cAAwB,WAAW;;AAE3D,IAAM,kBAAkB,cAAkC,KAAA,CAAS;AACnE,IAAM,yBAAyB,cAA2C;CACxE,YAAY;CACZ,iBAAiB;CACjB,cAAc;AAChB,CAAC;AAED,IAAM,eACJ;;AAEF,IAAM,sBACJ;AAEF,SAAS,iBAAiB,EACxB,UACA,WACA,IACA,MAAM,OACN,GAAG,SACa;CAChB,MAAM,WAAW,WAAW,eAAe;CAC3C,MAAM,cAAc,MAAM;CAC1B,MAAM,SAAS,WAAW,MAAM,GAAG,CAAC,CAAC,SAAS,gBAAgB,KAAK;CACnE,MAAM,YAAY,aAAa,eAAe,CAAC;CAC/C,MAAM,SAAS,OAAO,SAAS,cAAc,KAAA;CAE7C,OACE,oBAAC,gBAAgB,UAAjB;EAA0B,OAAO,SAAS,SAAS,KAAA;EACjD,UAAA,qBAAC,MAAD;GACE,GAAI;GACJ,IAAI;GACJ,WAAW,GACT,0CACA,aAAa,uBACb,UACE,oHACF,SACF;GATF,UAAA,CAWG,UAEA,aACC,oBAAC,QAAD;IACE,eAAA;IACA,WAAU;GACX,CAAA,CAED;;CACoB,CAAA;AAE9B;AAEA,SAAS,qBAAqB,EAAE,SAAS,QAAoB;CAC3D,MAAM,aAAa,WAAW,eAAe;CAC7C,IAAI,SAAS,YAAY,OAAO;CAEhC,MAAM,gBAAgB;EACpB,SAAS,WAAW;EACpB,iBAAiB;EACjB,UAAU;EACV,UAAU,UA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C1B,WAAW,GAAG,mBAAmB,SAAS;EAH5C,UAAA,CAKE,oBAAC,MAAD;GACE,IAAG;GACH,SAAQ;GACR,OAAO;GACP,oBAAiB;GACjB,WAAW,GACT,uBACA,oBAAoB,qBACtB;GAEC,UAAA,cACC,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,oBAAC,MAAD;KACE,sBAAmB;KACnB,MAAM;KACN,OAAM;KACN,MAAK;KACL,OAAO;KACP,MAAK;KACL,UAAU;KACV,cAAY;KACZ,WAAU;IACX,CAAA,GACA,SACE;GAEL,CAAA,IAAA,oBAAC,eAAD;IAAe,UAAU;IAAS,gBAAgB;IAChD,UAAA,oBAAC,uBAAuB,UAAxB;KAAiC,OAAO;KACtC,UAAA,oBAAC,eAAD;MACE,eAAe;MACf,eAAe;MACf,YAAY;MAEX,UAAA;KACY,CAAA;IACgB,CAAA;GACpB,CAAA;EAEb,CAAA,GACL,YACE;;AAET;AAEA,gBAAgB,cAAc"}
1
+ {"version":3,"file":"MarkdownDisplay.js","names":[],"sources":["../../../src/components/MarkdownDisplay/MarkdownDisplay.tsx"],"sourcesContent":["import {\n createContext,\n isValidElement,\n type ComponentProps,\n type MouseEvent,\n type ReactNode,\n useContext,\n useId,\n useMemo,\n} from 'react';\n\nimport type { Components, ExtraProps } from 'react-markdown';\nimport ReactMarkdown from 'react-markdown';\nimport remarkGfm from 'remark-gfm';\nimport remend from 'remend';\n\nimport { ImageIcon } from '@phosphor-icons/react/dist/ssr/Image';\nimport { WarningCircleIcon } from '@phosphor-icons/react/dist/ssr/WarningCircle';\n\nimport { cn } from '../../utils/cn';\nimport { makeComponentName } from '../../utils/componentUtils';\nimport { Checkbox } from '../Checkbox';\nimport { MAX_TEXT_LENGTH } from '../Code/constants';\nimport { ErrorBoundary } from '../ErrorBoundary';\nimport { Icon } from '../Icon';\nimport { Link } from '../Link';\nimport { Text, type TextProps } from '../Text';\nimport { TextWithLinks } from '../TextWithLinks';\nimport { MarkdownCodeBlock } from './MarkdownCodeBlock';\nimport {\n TRAILING_SLOT_ATTRIBUTE,\n rehypeMarkdownDisplay,\n remarkDisableRawHtml,\n} from './markdownPlugins';\nimport { prepareMarkdownXml } from './prepareMarkdownXml';\n\ntype TextColor = NonNullable<TextProps['color']>;\ntype ListType = 'ordered' | 'unordered';\ntype HeadingVariant = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\ntype HeadingProps = ComponentProps<HeadingVariant> & ExtraProps;\ntype ListItemProps = ComponentProps<'li'> & ExtraProps;\ntype InputProps = ComponentProps<'input'> & ExtraProps;\ntype ImageProps = ComponentProps<'img'> & ExtraProps;\ntype SpanProps = ComponentProps<'span'> & ExtraProps;\n\ninterface MarkdownDisplayContextValue {\n loadImages: boolean;\n trailingContent: ReactNode;\n codeOverflow: 'wrap' | 'scroll';\n}\n\nconst COMPONENT_NAME = makeComponentName('MarkdownDisplay');\nconst PLAIN_TEXT_FALLBACK_MESSAGE =\n 'Shown as plain text because this block is too large for Markdown.';\nconst REMARK_PLUGINS = [remarkGfm, remarkDisableRawHtml];\nconst REHYPE_PLUGINS = [rehypeMarkdownDisplay];\nconst ListTypeContext = createContext<ListType>('unordered');\n/** The id of the enclosing task list item, which names its checkbox. */\nconst TaskItemContext = createContext<string | undefined>(undefined);\nconst MarkdownDisplayContext = createContext<MarkdownDisplayContextValue>({\n loadImages: false,\n trailingContent: null,\n codeOverflow: 'wrap',\n});\n\nconst blockSpacing =\n 'mt-space-4 first:mt-0 [:is(h1,h2,h3,h4,h5,h6)+&]:mt-space-2';\n/** Inline links keep the size and rhythm of the text they sit in. */\nconst inlineLinkClassName =\n 'inline text-[length:inherit] leading-[inherit] tracking-[inherit]';\n\nfunction MarkdownListItem({\n children,\n className,\n id,\n node: _node,\n ...props\n}: ListItemProps) {\n const listType = useContext(ListTypeContext);\n const generatedId = useId();\n const isTask = className?.split(' ').includes('task-list-item') ?? false;\n const hasBullet = listType === 'unordered' && !isTask;\n const itemId = id ?? (isTask ? generatedId : undefined);\n\n return (\n <TaskItemContext.Provider value={isTask ? itemId : undefined}>\n <li\n {...props}\n id={itemId}\n className={cn(\n 'text-sm leading-normal tracking-normal',\n hasBullet && 'relative pl-space-3',\n isTask &&\n 'relative list-none pl-space-5 has-[[data-state=checked]]:text-quaternary has-[[data-state=checked]]:line-through',\n className\n )}\n >\n {children}\n {/* Last so the item's first block keeps its first-child spacing. */}\n {hasBullet && (\n <span\n aria-hidden\n className=\"absolute left-0 top-[0.65em] size-1 rounded-full bg-current\"\n />\n )}\n </li>\n </TaskItemContext.Provider>\n );\n}\n\nfunction MarkdownTaskCheckbox({ checked, type }: InputProps) {\n const taskItemId = useContext(TaskItemContext);\n if (type !== 'checkbox') return null;\n\n const checkboxProps = {\n checked: checked ?? false,\n 'aria-readonly': true,\n tabIndex: -1,\n onClick: (event: MouseEvent<HTMLButtonElement>) => event.preventDefault(),\n size: 'sm',\n className: 'pointer-events-none',\n containerClassName: 'absolute left-0 top-[calc(0.75em_-_0.5rem)]',\n } as const;\n\n return taskItemId ? (\n <Checkbox {...checkboxProps} aria-labelledby={taskItemId} />\n ) : (\n <Checkbox\n {...checkboxProps}\n aria-label={checked ? 'Completed task' : 'Open task'}\n />\n );\n}\n\nfunction MarkdownImage({\n alt = '',\n src,\n className,\n node: _node,\n ...props\n}: ImageProps) {\n const { loadImages } = useContext(MarkdownDisplayContext);\n\n if (typeof src !== 'string' || !src) {\n return <span className=\"text-tertiary\">{alt}</span>;\n }\n\n if (!loadImages) {\n return (\n <Link\n href={src}\n variant=\"body\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n leftDecorator={ImageIcon}\n // Preflight makes SVGs block-level; keep the icon on the text line.\n className={cn(\n inlineLinkClassName,\n '[&>svg]:mr-[2px] [&>svg]:inline [&>svg]:align-[-0.125em]'\n )}\n >\n {alt || src}\n </Link>\n );\n }\n\n return (\n <img\n {...props}\n src={src}\n alt={alt}\n loading=\"lazy\"\n referrerPolicy=\"no-referrer\"\n className={cn(\n blockSpacing,\n 'h-auto max-w-full rounded-md border border-subtle',\n className\n )}\n />\n );\n}\n\nfunction MarkdownSpan({ node: _node, ...props }: SpanProps) {\n const { trailingContent } = useContext(MarkdownDisplayContext);\n if (TRAILING_SLOT_ATTRIBUTE in props) return <>{trailingContent}</>;\n return <span {...props} />;\n}\n\nconst createHeading = (\n variant: HeadingVariant,\n headingClassName: string,\n weight: TextProps['weight'] = 'semibold',\n color?: TextColor\n) =>\n function MarkdownHeading({\n children,\n className,\n color: _color,\n node: _node,\n ...props\n }: HeadingProps) {\n return (\n <Text\n {...props}\n as={variant}\n variant={variant}\n weight={weight}\n color={color}\n className={cn(blockSpacing, headingClassName, className)}\n >\n {children}\n </Text>\n );\n };\n\nconst MARKDOWN_COMPONENTS: Components = {\n pre: function MarkdownPre({ children }) {\n const { codeOverflow } = useContext(MarkdownDisplayContext);\n const child = isValidElement<{\n children?: ReactNode;\n className?: string;\n }>(children)\n ? children\n : undefined;\n const language = child?.props.className?.match(/language-([^\\s]+)/)?.[1];\n const code =\n typeof child?.props.children === 'string'\n ? child.props.children\n : String(child?.props.children ?? '');\n\n return (\n <div\n data-search-block=\"\"\n data-search-code=\"\"\n className={cn('w-full min-w-0', blockSpacing)}\n >\n <MarkdownCodeBlock\n code={code}\n language={language}\n codeOverflow={codeOverflow}\n />\n </div>\n );\n },\n code: ({ children, className, node: _node, ...props }) => (\n <code\n {...props}\n className={cn(\n 'rounded-xs bg-surface-level-3 px-space-1 py-px font-mono text-[length:0.9em] leading-[inherit] tracking-normal text-tertiary',\n className\n )}\n >\n {children}\n </code>\n ),\n a: ({ children, href, className, node: _node, ...props }) => {\n if (!href) return <span>{children}</span>;\n // Fragment links (footnote references and back-references) stay in page.\n const opensNewTab = !href.startsWith('#');\n\n return (\n <Link\n {...props}\n href={href}\n variant=\"body\"\n target={opensNewTab ? '_blank' : undefined}\n rel={opensNewTab ? 'noopener noreferrer' : undefined}\n className={cn(inlineLinkClassName, className)}\n >\n {children}\n </Link>\n );\n },\n h1: createHeading('h1', 'text-xl leading-tight'),\n h2: createHeading('h2', 'text-lg leading-tight'),\n h3: createHeading('h3', 'text-base leading-tight'),\n h4: createHeading('h4', 'text-sm leading-tight', 'semibold', 'quaternary'),\n h5: createHeading('h5', 'text-sm leading-tight', 'semibold', 'secondary'),\n h6: createHeading('h6', 'text-sm leading-tight', 'medium', 'secondary'),\n p: ({ children, className, color: _color, node: _node, ...props }) => (\n <Text\n {...props}\n as=\"p\"\n variant=\"body\"\n className={cn('mt-space-3 first:mt-0', className)}\n >\n {children}\n </Text>\n ),\n blockquote: ({ node: _node, ...props }) => (\n <blockquote\n {...props}\n className={cn(\n blockSpacing,\n 'border-l-4 border-default bg-surface-level-2 py-space-2 pl-space-4 pr-space-3 italic [overflow-wrap:anywhere]'\n )}\n />\n ),\n ul: ({ className, node: _node, ...props }) => (\n <ListTypeContext.Provider value=\"unordered\">\n <ul\n {...props}\n className={cn(\n blockSpacing,\n 'ml-space-3 flex flex-col gap-space-1 [li>&]:mt-space-1',\n className\n )}\n />\n </ListTypeContext.Provider>\n ),\n ol: ({ className, start, style, node, ...props }) => {\n const itemCount =\n node?.children.filter(\n (child) => child.type === 'element' && child.tagName === 'li'\n ).length ?? 0;\n const firstNumber = start ?? 1;\n const lastNumber = firstNumber + Math.max(itemCount - 1, 0);\n const markerDigits = Math.max(\n String(firstNumber).length,\n String(lastNumber).length\n );\n\n return (\n <ListTypeContext.Provider value=\"ordered\">\n <ol\n {...props}\n start={start}\n // Outside markers sit in this padding, so it widens with the\n // longest number instead of letting markers overflow and clip.\n style={{ ...style, paddingInlineStart: `${markerDigits + 1.5}ch` }}\n className={cn(\n blockSpacing,\n 'flex list-outside list-decimal flex-col gap-space-1 [li>&]:mt-space-1',\n className\n )}\n />\n </ListTypeContext.Provider>\n );\n },\n li: MarkdownListItem,\n input: MarkdownTaskCheckbox,\n table: ({ node: _node, ...props }) => (\n <div\n data-search-block=\"\"\n role=\"region\"\n aria-label=\"Table\"\n tabIndex={0}\n className={cn(\n blockSpacing,\n 'w-full overflow-x-auto focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus'\n )}\n >\n <table\n {...props}\n className=\"w-full min-w-max border-collapse text-left text-xs\"\n />\n </div>\n ),\n th: ({ node: _node, ...props }) => (\n <th\n {...props}\n className=\"border border-subtle dark:border-muted bg-surface-level-2 px-space-2 py-space-1 font-semibold\"\n />\n ),\n td: ({ node: _node, ...props }) => (\n <td\n {...props}\n className=\"border border-subtle dark:border-muted px-space-2 py-space-1 align-top\"\n />\n ),\n hr: ({ node: _node, ...props }) => (\n <hr {...props} className={cn(blockSpacing, 'border-default')} />\n ),\n strong: ({ className, node: _node, ...props }) => (\n <strong {...props} className={cn('font-semibold', className)} />\n ),\n em: ({ className, node: _node, ...props }) => (\n <em {...props} className={cn('italic', className)} />\n ),\n del: ({ node: _node, ...props }) => (\n <del {...props} className=\"text-tertiary\" />\n ),\n img: MarkdownImage,\n span: MarkdownSpan,\n};\n\nexport interface MarkdownDisplayProps {\n /** Markdown source to render. */\n content: string;\n /** Render custom XML wrappers as labeled sections, or keep tags literal (default). */\n xmlTags?: 'literal' | 'sections';\n /** Repair unfinished Markdown while content streams; use the original Markdown when false. */\n isStreaming?: boolean;\n className?: string;\n /**\n * Render oversized content in full as linkified, non-virtualized plain text\n * instead of truncating it behind a Show more toggle. Ignores\n * `containerHeight`.\n */\n fullLength?: boolean;\n /**\n * Viewport height for truncated oversized content. When set, that content\n * renders in a virtualized plain-text viewport whose URLs are not\n * linkified.\n */\n containerHeight?: string;\n /**\n * Longest content, in characters, rendered as Markdown; longer content\n * renders as plain text. Defaults to the shared text length limit. Raise it,\n * or pass `Infinity`, only for content of bounded size such as chat answers:\n * parsing cost grows with length, and the default keeps views of large\n * untrusted content responsive.\n */\n maxMarkdownLength?: number;\n /** Preserve single newlines visually without changing Markdown parsing. */\n preserveNewlines?: boolean;\n /** Wrap long fenced code lines by default, or scroll them horizontally. */\n codeOverflow?: 'wrap' | 'scroll';\n /** Color applied to text-bearing Markdown elements. */\n textColor?: TextColor;\n /**\n * Load images referenced by the Markdown. Off by default: loading a remote\n * image from untrusted content sends a request, and anything encoded in its\n * URL, without user action. Images otherwise render as links.\n */\n loadImages?: boolean;\n /**\n * Override or extend the default react-markdown component mapping. Keep\n * override components stable across renders; a new component function\n * remounts every element it renders.\n */\n components?: Components;\n /**\n * Content that continues the rendered flow: inline after the final\n * paragraph's text, or after the last block when content ends otherwise.\n */\n trailingContent?: ReactNode;\n /** Content rendered after the Markdown content container. */\n afterContent?: ReactNode;\n}\n\n/**\n * Renders untrusted Markdown with GFM support and Macaw presentation.\n *\n * Raw HTML is never interpreted. Tags display as text by default; opt in to\n * XML sections turn custom wrappers into labels and nested blockquotes.\n * Content above `maxMarkdownLength` (by default the shared text length limit)\n * renders as plain text, truncated behind a Show more toggle unless\n * `fullLength` is set.\n */\nexport function MarkdownDisplay({\n content,\n isStreaming = false,\n xmlTags = 'literal',\n className,\n fullLength = false,\n containerHeight,\n maxMarkdownLength = MAX_TEXT_LENGTH,\n preserveNewlines = false,\n codeOverflow = 'wrap',\n textColor = 'primary',\n loadImages = false,\n components,\n trailingContent,\n afterContent,\n}: MarkdownDisplayProps) {\n const markdownComponents = useMemo(\n () =>\n components\n ? { ...MARKDOWN_COMPONENTS, ...components }\n : MARKDOWN_COMPONENTS,\n [components]\n );\n const contextValue = useMemo(\n () => ({ loadImages, trailingContent, codeOverflow }),\n [loadImages, trailingContent, codeOverflow]\n );\n const isPlainText = content.length > maxMarkdownLength;\n const markdown = useMemo(() => {\n if (isPlainText) return content;\n const prepared =\n xmlTags === 'sections' ? prepareMarkdownXml(content) : content;\n return isStreaming\n ? remend(prepared, {\n // Partial destinations must never become clickable links.\n linkMode: 'text-only',\n // HTML is literal text here, and math rendering is unsupported.\n htmlTags: false,\n katex: false,\n })\n : prepared;\n }, [content, isPlainText, isStreaming, xmlTags]);\n\n const plainText = (\n <>\n <TextWithLinks\n text={content}\n fullLength={fullLength}\n containerHeight={containerHeight}\n useRawSpan\n />\n {trailingContent}\n </>\n );\n\n return (\n <div\n data-component={COMPONENT_NAME}\n aria-busy={isStreaming || undefined}\n className={cn('min-w-0 text-sm', className)}\n >\n <Text\n as=\"div\"\n variant=\"body\"\n color={textColor}\n data-search-kind=\"container\"\n className={cn(\n 'min-w-0 break-words',\n preserveNewlines && 'whitespace-pre-wrap'\n )}\n >\n {isPlainText ? (\n <div className=\"relative pr-space-5\">\n <Icon\n data-search-ignore=\"\"\n icon={WarningCircleIcon}\n color=\"warning\"\n size=\"xs\"\n label={PLAIN_TEXT_FALLBACK_MESSAGE}\n role=\"img\"\n tabIndex={0}\n aria-label={PLAIN_TEXT_FALLBACK_MESSAGE}\n className=\"absolute right-0 top-0\"\n />\n {plainText}\n </div>\n ) : (\n <ErrorBoundary resetKey={content} fallback={() => plainText}>\n <MarkdownDisplayContext.Provider value={contextValue}>\n <ReactMarkdown\n remarkPlugins={REMARK_PLUGINS}\n rehypePlugins={REHYPE_PLUGINS}\n components={markdownComponents}\n >\n {markdown}\n </ReactMarkdown>\n </MarkdownDisplayContext.Provider>\n </ErrorBoundary>\n )}\n </Text>\n {afterContent}\n </div>\n );\n}\n\nMarkdownDisplay.displayName = COMPONENT_NAME;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmDA,IAAM,iBAAiB,kBAAkB,iBAAiB;AAC1D,IAAM,8BACJ;AACF,IAAM,iBAAiB,CAAC,WAAW,oBAAoB;AACvD,IAAM,iBAAiB,CAAC,qBAAqB;AAC7C,IAAM,kBAAkB,cAAwB,WAAW;;AAE3D,IAAM,kBAAkB,cAAkC,KAAA,CAAS;AACnE,IAAM,yBAAyB,cAA2C;CACxE,YAAY;CACZ,iBAAiB;CACjB,cAAc;AAChB,CAAC;AAED,IAAM,eACJ;;AAEF,IAAM,sBACJ;AAEF,SAAS,iBAAiB,EACxB,UACA,WACA,IACA,MAAM,OACN,GAAG,SACa;CAChB,MAAM,WAAW,WAAW,eAAe;CAC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