{"version":3,"file":"mention-chip.cjs","sources":["../../../src/chat-ui/mentions/mention-chip.tsx"],"sourcesContent":["/**\n * Mention chip rendering for message display.\n *\n * Parses [@name](mention://type?...) markdown links and renders them\n * as styled inline chips matching the Olympus mention style.\n * Used in both user messages (inline text) and assistant messages (markdown links).\n */\n\nimport {\n  isValidElement,\n  useContext,\n  useState,\n  type FC,\n  type ReactElement,\n  type ReactNode,\n} from \"react\";\nimport {\n  formatScreenPoint,\n  isScreenPointHref,\n  parseScreenPointHref,\n} from \"@athenaintel/agent-runtime\";\nimport {\n  type AssetReference,\n  decodeFromAssetMentionUri,\n  decodeFromAssetSpacesUrl,\n  encodeToAssetSpacesUrl,\n  formatReferenceAnchor,\n} from \"@athenaintel/references/asset-links\";\nimport {\n  CrosshairIcon,\n  DatabaseIcon,\n  FileCodeIcon,\n  FileIcon,\n  FileTextIcon,\n  FolderIcon,\n  Globe2Icon,\n  HeadphonesIcon,\n  ImageIcon,\n  type LucideIcon,\n  MailIcon,\n  MessageSquareIcon,\n  MonitorIcon,\n  PresentationIcon,\n  SheetIcon,\n  UserIcon,\n  VideoIcon,\n} from \"lucide-react\";\nimport { cn } from \"../../lib/utils\";\nimport { createOlympusAssetUrl } from \"../lib/asset-urls\";\nimport { MentionAuthCtx } from \"./suggestions/data/api-client\";\nimport { assetTypeToThumb } from \"./suggestions/data/sources/asset-type-icons\";\nimport { useMemberAvatarUrl } from \"./use-member-avatar\";\nimport { useMentionAsset } from \"./use-mention-asset\";\n\nconst SPACES_MENTION_PATH = /\\/dashboard\\/spaces\\/?\\?/;\n\nfunction isSpacesMentionUrl(url: string): boolean {\n  return SPACES_MENTION_PATH.test(url);\n}\n\nfunction getSpacesAssetType(url: URL): string | null {\n  const assetType =\n    url.searchParams.get(\"assetType\") ||\n    url.searchParams.get(\"asset_type\") ||\n    url.searchParams.get(\"type\");\n  return assetType === \"sheet\" ? \"spreadsheet\" : assetType;\n}\n\n/**\n * Where in the asset a citation points, as its chip shows it. The anchor is\n * read and labelled by `@athenaintel/references` — the same parser and labels\n * Olympus's mention chips use — so a chip reads `jwt.py:12-25`, `p.5` or\n * `Slide 3` in every Athena chat.\n */\nexport interface MentionChipCitation {\n  /** The anchor type (`page`, `file_line_range`, `slide`, …). */\n  anchorType: string;\n  /** The short label drawn after the name (`p.5`, `jwt.py:12-25`). */\n  label: string;\n  /**\n   * The place spelled out (`Page 5`, `agora/…/jwt.py:12-25`), without the\n   * excerpt: the tooltip when the link carries no excerpt, and part of the\n   * chip's accessible name when it holds a word.\n   */\n  description: string;\n}\n\n/** The citation an asset link's anchor names, or undefined for a plain mention or an anchor nobody can read. */\nfunction citationOf(reference: AssetReference): MentionChipCitation | undefined {\n  const { anchor, meta } = reference;\n  if (!anchor) return undefined;\n  const label = formatReferenceAnchor(anchor, \"short\", meta);\n  if (!label) return undefined;\n  const { excerpt: _excerpt, ...place } = meta ?? {};\n  return {\n    anchorType: anchor.type,\n    label,\n    description: formatReferenceAnchor(anchor, \"long\", place) ?? label,\n  };\n}\n\n/**\n * The chip's icon for an asset type when the host serves no asset-type SVGs.\n * A compact set on purpose: the chip renders in every message (and Olympus's\n * main layout reaches it through the queued-message tray), so it carries a\n * dozen icons rather than the `@` menu's whole map.\n */\nconst ASSET_CHIP_ICONS: Record<string, LucideIcon> = {\n  document: FileTextIcon,\n  word_document: FileTextIcon,\n  markdown: FileTextIcon,\n  txt: FileTextIcon,\n  pdf: FileTextIcon,\n  spreadsheet: SheetIcon,\n  table: SheetIcon,\n  presentation: PresentationIcon,\n  powerpoint_deck: PresentationIcon,\n  presentation_pptx_studio: PresentationIcon,\n  pptx: PresentationIcon,\n  image: ImageIcon,\n  figure: ImageIcon,\n  canvas: ImageIcon,\n  video: VideoIcon,\n  meeting: VideoIcon,\n  video_session: VideoIcon,\n  audio: HeadphonesIcon,\n  voice_memo: HeadphonesIcon,\n  phone_call: HeadphonesIcon,\n  email: MailIcon,\n  email_message: MailIcon,\n  live_email_thread: MailIcon,\n  live_calendar_event: MailIcon,\n  python: FileCodeIcon,\n  javascript: FileCodeIcon,\n  typescript: FileCodeIcon,\n  json: FileCodeIcon,\n  yaml: FileCodeIcon,\n  database: DatabaseIcon,\n  catalog: DatabaseIcon,\n  drive: DatabaseIcon,\n  dataset: DatabaseIcon,\n  semantic_model: DatabaseIcon,\n  query_snippet: DatabaseIcon,\n  folder: FolderIcon,\n  gdrive_folder: FolderIcon,\n  project: FolderIcon,\n  collection: FolderIcon,\n  session: MessageSquareIcon,\n  computer: MonitorIcon,\n  desktop_session: MonitorIcon,\n  user_interface: MonitorIcon,\n  application: MonitorIcon,\n  html: Globe2Icon,\n  web_page: Globe2Icon,\n  browse_session: Globe2Icon,\n};\n\nfunction assetChipIcon(assetType: string | undefined): LucideIcon {\n  return (assetType && ASSET_CHIP_ICONS[assetType.toLowerCase()]) || FileIcon;\n}\n\n/**\n * GitHub's mark (Octicons `mark-github`), drawn by a repository file's\n * citation. Lucide carries no brand icons and an SDK app serves none of\n * Olympus's, so the chip brings its own. Only a GitHub repository catalog\n * serves `file_line_range` anchors (`ASSET_ANCHOR_REGISTRY`; agora's\n * `_CATALOG_ANCHORS_BY_PROVIDER`), so the anchor alone names the provider.\n */\nfunction GitHubMarkIcon({ className }: { className?: string }) {\n  return (\n    <svg\n      viewBox=\"0 0 16 16\"\n      fill=\"currentColor\"\n      aria-hidden=\"true\"\n      className={className}\n      data-chip-icon=\"github\"\n    >\n      <path d=\"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z\" />\n    </svg>\n  );\n}\n\n/** Anchors only a session holds: its messages, blocks and tool calls. */\nconst SESSION_ANCHORS: ReadonlySet<string> = new Set([\n  \"msg\",\n  \"msg_range\",\n  \"msg_block\",\n  \"msg_section\",\n  \"msg_text\",\n  \"tool_call\",\n]);\n\n/** Whether a link names a session (its type, or an anchor only a session holds). */\nfunction isSessionLink(\n  assetType: string | undefined,\n  citation: MentionChipCitation | undefined,\n): boolean {\n  return (\n    assetType?.toLowerCase() === \"session\" ||\n    (citation !== undefined && SESSION_ANCHORS.has(citation.anchorType))\n  );\n}\n\n/** Past this many characters a place may not show whole in the chip, so the tooltip spells it out. */\nconst PLACE_FITS_CHARS = 20;\n\n/** `route.ts:18-24` as the file's name and its lines, so a long name shortens while its lines stay. */\nfunction splitFileLines(label: string): { file: string; lines: string } {\n  const colon = label.lastIndexOf(\":\");\n  return colon > 0\n    ? { file: label.slice(0, colon), lines: label.slice(colon) }\n    : { file: label, lines: \"\" };\n}\n\n/**\n * Whether a name already says where its citation points: the place's label or\n * its spelled-out form, or a name ending in the label (`Q4 report p.5`,\n * `olympus/…/route.ts:18-24`). The chip then draws the place once.\n */\nfunction restatesPlace(name: string, citation: MentionChipCitation): boolean {\n  const said = name.trim().toLowerCase();\n  const label = citation.label.toLowerCase();\n  return said === label || said === citation.description.toLowerCase() || said.endsWith(label);\n}\n\n/**\n * The link's own label when it tells the reader something the chip does not\n * already show: not the place again (a path, `file:lines`), not the asset's\n * name. The tooltip keeps it, since the chip shows the asset and the place.\n */\nfunction informativeLabel({\n  label,\n  shown,\n  citation,\n}: {\n  label: string;\n  shown: readonly (string | null | undefined)[];\n  citation: MentionChipCitation | undefined;\n}): string | null {\n  const trimmed = label.trim();\n  if (!trimmed || !SPEAKABLE.test(trimmed)) return null;\n  if (PLACEHOLDER_LABELS.has(trimmed.toLowerCase())) return null;\n  if (citation && restatesPlace(trimmed, citation)) return null;\n  // Every word of it already shown (`Tesla Q3 report` beside `Tesla Q3\n  // Earnings Report`, `demo-app-monorepo` beside the repository's title).\n  const shownWords = new Set(\n    [...shown, citation?.description].flatMap((text) => (text ? wordsOf(text) : [])),\n  );\n  return wordsOf(trimmed).every((word) => shownWords.has(word)) ? null : trimmed;\n}\n\nfunction wordsOf(text: string): string[] {\n  return text.toLowerCase().match(/[\\p{L}\\p{N}]+/gu) ?? [];\n}\n\n/** A label with a letter or digit in it; `§` or `•` alone says nothing read aloud. */\nconst SPEAKABLE = /[\\p{L}\\p{N}]/u;\n\n/** Labels that name nothing: agora's read_asset citations all read `Citation`. */\nconst PLACEHOLDER_LABELS: ReadonlySet<string> = new Set([\"citation\", \"source\", \"link\", \"here\"]);\n\n/** The asset reference an asset link decodes to, or null when it does not parse. */\nfunction decodeAssetLink(\n  url: URL,\n  decode: (url: URL) => AssetReference,\n): AssetReference | null {\n  try {\n    return decode(url);\n  } catch {\n    return null;\n  }\n}\n\n// ── Mention link component for markdown renderer ──\n\n/**\n * Custom <a> renderer for MarkdownTextPrimitive.\n * Intercepts mention:// links and renders them as chips.\n * Falls through to a normal link for non-mention URLs.\n */\nfunction personEmailForMention(\n  parsed: ReturnType<typeof parseMentionUrl>,\n): string | undefined {\n  if (parsed.type !== \"person\") return undefined;\n  return parsed.email || (parsed.id.includes(\"@\") ? parsed.id : undefined);\n}\n\n/**\n * The text a link's children read as. Markdown can hand a link several children, some of them\n * elements (an escaped `_` or a `*` in a URL splits its text), and stringifying an element gives\n * `[object Object]`.\n */\nfunction textOf(node: ReactNode): string {\n  if (typeof node === \"string\" || typeof node === \"number\") return String(node);\n  if (Array.isArray(node)) return node.map(textOf).join(\"\");\n  if (isValidElement<{ children?: ReactNode }>(node)) return textOf(node.props.children);\n  return \"\";\n}\n\nexport const MentionLink: FC<{\n  href?: string;\n  children?: ReactNode;\n  interactive?: boolean;\n}> = ({ href, children, interactive = true }) => {\n  if (\n    href &&\n    (href.startsWith(\"mention://\") || isSpacesMentionUrl(href))\n  ) {\n    const name = textOf(children).trim().replace(/^@/, \"\");\n\n    const parsed = parseMentionUrl(href);\n\n    return (\n      <MentionChip\n        name={name || parsed.name}\n        type={parsed.type}\n        personEmail={personEmailForMention(parsed)}\n        assetIds={parsed.assetIds}\n        assetType={parsed.assetType}\n        citation={parsed.citation}\n        thumbnailUrl={parsed.thumbnailUrl}\n        sourceHref={isSpacesMentionUrl(href) ? href : parsed.sourceHref}\n        interactive={interactive}\n      />\n    );\n  }\n\n  if (href?.startsWith(\"chrome-extension://\")) {\n    return <span>{children}</span>;\n  }\n\n  if (isScreenPointHref(href)) {\n    return <ScreenPointChip href={href}>{children}</ScreenPointChip>;\n  }\n\n  // Normal link — render as-is\n  return (\n    <a href={href} target=\"_blank\" rel=\"noopener noreferrer\">\n      {children}\n    </a>\n  );\n};\n\n// ── The chip pill ──\n\n/**\n * Olympus's mention pill (`mentionPillClassName`: 20px high, 16px icon, the\n * place in `text-xs`) in the provider's theme tokens, so a dark theme keeps it\n * legible, and `box-border` so its height holds without a host's CSS reset.\n * Every chat chip draws it: an asset or citation chip, a web source, a screen\n * point. Only stock Tailwind sizes: Olympus renders these chips (the queued\n * message tray) with a stylesheet that does not scan this package, so an\n * arbitrary value would reach it unstyled. `not-prose` matters: assistant\n * messages render inside Tailwind Typography's `prose`, whose\n * zero-specificity `img` margins (~1.7em top/bottom) would otherwise inflate\n * the chip's icon into a tall card that breaks the sentence flow around it.\n */\nexport const CHIP_PILL_CLASS =\n  \"not-prose box-border inline-flex h-5 items-center gap-1.5 whitespace-nowrap rounded-md border border-border bg-muted px-1 py-0.5 align-middle font-normal leading-none text-foreground no-underline\";\n/** A chip that opens something. */\nexport const CHIP_LINK_CLASS =\n  \"cursor-pointer transition-colors hover:bg-accent hover:text-accent-foreground hover:no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1\";\nexport const CHIP_ICON_CLASS = \"size-4 shrink-0\";\n\n// ── Inline screen-point chip ──\n\n/**\n * Renders an `athena-point://` link as a non-navigating coordinate chip.\n * Surfaces without screenshot context (extension side panel, SDK consumers)\n * get the label plus the coordinates; malformed points fall back to text.\n */\nexport const ScreenPointChip: FC<{\n  href: string;\n  children?: ReactNode;\n}> = ({ href, children }) => {\n  const parsed = parseScreenPointHref(href);\n  if (!parsed.ok) {\n    return <span>{children}</span>;\n  }\n  const description = formatScreenPoint(parsed.point);\n  return (\n    <span\n      className={cn(CHIP_PILL_CLASS, \"max-w-[260px]\")}\n      title={description}\n      aria-label={description}\n      data-screen-point=\"valid\"\n    >\n      <CrosshairIcon className={CHIP_ICON_CLASS} aria-hidden=\"true\" />\n      <span className=\"min-w-0 max-w-[180px] overflow-hidden text-ellipsis\">\n        {children}\n      </span>\n      <span className=\"shrink-0 text-xs text-muted-foreground\">\n        {parsed.point.x}, {parsed.point.y}\n      </span>\n    </span>\n  );\n};\n\n// ── Inline mention chip ──\n\nexport const MentionChip: FC<{\n  name: string;\n  type?: string;\n  assetIds?: string[];\n  /** The asset's type (`document`, `catalog`, …): picks the icon until (or unless) the asset is looked up. */\n  assetType?: string;\n  /** Where in the asset the link points: its label follows the name. */\n  citation?: MentionChipCitation;\n  personEmail?: string;\n  thumbnailUrl?: string;\n  sourceHref?: string;\n  interactive?: boolean;\n}> = ({\n  name,\n  type,\n  assetIds,\n  assetType,\n  citation,\n  personEmail,\n  thumbnailUrl,\n  sourceHref,\n  interactive = true,\n}) => {\n  const auth = useContext(MentionAuthCtx);\n  const memberAvatarUrl = useMemberAvatarUrl(personEmail);\n  const [erroredAvatarUrl, setErroredAvatarUrl] = useState<string>();\n  const excerpt = sourceHref ? readSourceExcerpt(sourceHref) : null;\n  // A repository file's lines read as the file (`route.ts:18-24`): the chip\n  // opens that file, and every citation in a reply names the same repository,\n  // whatever label the model wrote.\n  const repositoryFile =\n    citation?.anchorType === \"file_line_range\"\n      ? { ...splitFileLines(citation.label), label: citation.label }\n      : null;\n  // The asset as agora has it, read the way Olympus's chips read it: its own\n  // title and type. Until it answers, and for an asset the viewer cannot read,\n  // the link's label and `type=` stand in. Asked only where it changes the\n  // chip: a repository file reads as its file whatever the catalog is called,\n  // and a session's row is too heavy to read for a name.\n  const asset = useMentionAsset(\n    type === \"asset\" &&\n      assetIds?.length === 1 &&\n      !repositoryFile &&\n      !isSessionLink(assetType, citation)\n      ? assetIds[0]\n      : undefined,\n  );\n  const assetTitle = asset?.title || null;\n  const chipName = repositoryFile?.label ?? assetTitle ?? name;\n  // The place follows a name that does not already say it, as `[p.5]`.\n  const placeLabel =\n    citation && !repositoryFile && !restatesPlace(chipName, citation)\n      ? citation.label\n      : null;\n  // The tooltip: what the model called it (when the chip does not show it),\n  // the repository a file is in and the file's whole path, the cited passage.\n  // The place spelled out stands in for a passage the citation does not carry,\n  // and for a place too long to show whole (a long sheet name).\n  const tooltip =\n    citation || excerpt\n      ? tooltipText({\n          lines: [\n            informativeLabel({ label: name, shown: [chipName, assetTitle], citation }),\n            repositoryFile ? assetTitle : null,\n            repositoryFile || !excerpt || (placeLabel?.length ?? 0) > PLACE_FITS_CHARS\n              ? citation?.description\n              : null,\n          ],\n          excerpt,\n        })\n      : null;\n  const assetRootHref =\n    type === \"asset\" && assetIds?.length\n      ? createOlympusAssetUrl({\n          appUrl: auth?.appUrl,\n          backendUrl: auth?.backendUrl,\n          assetIds,\n        })\n      : null;\n  const href = (() => {\n    if (!assetRootHref || !sourceHref) return assetRootHref;\n    try {\n      const source = new URL(sourceHref, \"https://app.athenaintel.com\");\n      const destination = new URL(assetRootHref);\n      for (const [key, value] of source.searchParams) {\n        destination.searchParams.set(key, value);\n      }\n      destination.searchParams.set(\"asset_ids\", assetIds?.join(\",\") ?? \"\");\n      return destination.toString();\n    } catch {\n      return assetRootHref;\n    }\n  })();\n  const className = cn(CHIP_PILL_CLASS, \"max-w-[275px]\", href && CHIP_LINK_CLASS);\n  // A host's asset-type SVG follows the looked-up type, when it serves them.\n  const chipThumbnailUrl = repositoryFile\n    ? undefined\n    : (asset?.assetType && assetTypeToThumb(asset.assetType)) || thumbnailUrl;\n  const AssetIcon = assetChipIcon(asset?.assetType || assetType);\n  const contents = (\n    <>\n      {repositoryFile ? (\n        <GitHubMarkIcon className={CHIP_ICON_CLASS} />\n      ) : chipThumbnailUrl ? (\n        <img\n          src={chipThumbnailUrl}\n          alt=\"\"\n          className={CHIP_ICON_CLASS}\n          draggable={false}\n        />\n      ) : type === \"asset\" || type === \"folder\" ? (\n        // A host that bundles no asset-type SVGs (computer apps, most SDK\n        // apps) still gets the type's icon.\n        <AssetIcon className={CHIP_ICON_CLASS} aria-hidden=\"true\" />\n      ) : type === \"webpage\" ? (\n        <Globe2Icon className={CHIP_ICON_CLASS} aria-hidden=\"true\" />\n      ) : type === \"person\" ? (\n        memberAvatarUrl && erroredAvatarUrl !== memberAvatarUrl ? (\n          <img\n            src={memberAvatarUrl}\n            alt=\"\"\n            className={cn(CHIP_ICON_CLASS, \"rounded-full object-cover\")}\n            draggable={false}\n            onError={() => setErroredAvatarUrl(memberAvatarUrl)}\n          />\n        ) : (\n          <UserIcon className={CHIP_ICON_CLASS} aria-hidden=\"true\" />\n        )\n      ) : null}\n      {repositoryFile ? (\n        <span\n          className=\"flex min-w-0 items-center\"\n          data-citation-anchor=\"file_line_range\"\n        >\n          <span className=\"min-w-0 overflow-hidden text-ellipsis\">\n            {repositoryFile.file}\n          </span>\n          <span className=\"shrink-0 text-muted-foreground\">{repositoryFile.lines}</span>\n        </span>\n      ) : (\n        <span\n          className={cn(\n            \"max-w-[180px] overflow-hidden text-ellipsis\",\n            // A long place may shorten the name, never make it vanish.\n            placeLabel && \"min-w-8\",\n          )}\n        >\n          {chipName}\n        </span>\n      )}\n      {citation && placeLabel && (\n        <>\n          {/* Copied or read as text, the place stays a word apart from the name; a flex row draws no space. */}{\" \"}\n          <span\n            className=\"flex min-w-0 items-center text-xs text-muted-foreground\"\n            data-citation-anchor={citation.anchorType}\n          >\n            [<span className=\"min-w-0 overflow-hidden text-ellipsis\">{placeLabel}</span>]\n          </span>\n        </>\n      )}\n    </>\n  );\n\n  if (href && interactive) {\n    const speakablePlace = citation && SPEAKABLE.test(citation.description);\n    return (\n      <a\n        href={href}\n        target=\"_blank\"\n        rel=\"noopener noreferrer\"\n        className={className}\n        aria-label={\n          repositoryFile && citation\n            ? `Open ${citation.description} in Spaces`\n            : placeLabel && citation && speakablePlace\n              ? `Open ${chipName} at ${citation.description} in Spaces`\n              : `Open ${chipName} in Spaces`\n        }\n        title={tooltip ?? `Open ${chipName} in Spaces`}\n        data-excerpt={excerpt ?? undefined}\n        // The asset without its place: what a click names the opened asset.\n        data-mention-name={repositoryFile ? (assetTitle ?? name) : chipName}\n      >\n        {contents}\n      </a>\n    );\n  }\n\n  return (\n    <span\n      className={className}\n      title={tooltip ?? undefined}\n      data-excerpt={excerpt ?? undefined}\n    >\n      {contents}\n    </span>\n  );\n};\n\n/**\n * A chip's tooltip: the lines that say something, each once, then the cited\n * passage, quoted when it shares the tooltip with other lines.\n */\nfunction tooltipText({\n  lines,\n  excerpt,\n}: {\n  lines: readonly (string | null | undefined)[];\n  excerpt: string | null;\n}): string | null {\n  const kept: string[] = [];\n  for (const line of lines) {\n    const trimmed = line?.trim();\n    if (trimmed && !kept.includes(trimmed)) kept.push(trimmed);\n  }\n  if (excerpt) kept.push(kept.length ? `“${excerpt}”` : excerpt);\n  return kept.length ? kept.join(\"\\n\") : null;\n}\n\n/** The `excerpt` a Spaces citation URL carries, or null. */\nfunction readSourceExcerpt(href: string): string | null {\n  try {\n    const excerpt = new URL(href, \"https://app.athenaintel.com\").searchParams\n      .get(\"excerpt\")\n      ?.trim();\n    return excerpt ? excerpt : null;\n  } catch {\n    return null;\n  }\n}\n\n/**\n * The label an asset citation chip falls back to when the model wrote none\n * (`[](…/spaces/?asset_ids=…&page=5)`): the cited location, else \"Asset\" — a\n * chip must never render as an empty box.\n */\nfunction citationFallbackLabel(params: URLSearchParams): string {\n  const start = params.get(\"start_page\") ?? params.get(\"page\");\n  const end = params.get(\"end_page\");\n  if (start && end && end !== start) return `Pages ${start}–${end}`;\n  if (start) return `Page ${start}`;\n  return \"Asset\";\n}\n\n// ── Parse mention:// URLs ──\n\nexport function parseMentionUrl(url: string): {\n  type: string;\n  name: string;\n  id: string;\n  email?: string;\n  assetIds?: string[];\n  assetType?: string;\n  citation?: MentionChipCitation;\n  /**\n   * For a `mention://asset` citation, the Spaces link to its place (anchor and\n   * excerpt), so the chip opens there; a Spaces mention is its own link.\n   */\n  sourceHref?: string;\n  thumbnailUrl?: string;\n} {\n  try {\n    if (isSpacesMentionUrl(url)) {\n      const parsed = new URL(url, \"https://app.athenaintel.com\");\n      const assetIds = (parsed.searchParams.get(\"asset_ids\") ?? \"\")\n        .split(\",\")\n        .map((id) => id.trim())\n        .filter(Boolean);\n      const id = assetIds[0] ?? \"\";\n      const assetType = getSpacesAssetType(parsed);\n      // A link to several assets names no one place in any of them.\n      const reference =\n        assetIds.length === 1\n          ? decodeAssetLink(parsed, decodeFromAssetSpacesUrl)\n          : null;\n      const citation = reference ? citationOf(reference) : undefined;\n      return {\n        type: \"asset\",\n        name:\n          assetIds.length > 1\n            ? `${assetIds.length} assets`\n            : (citation?.description ??\n              citationFallbackLabel(parsed.searchParams)),\n        id,\n        assetIds,\n        assetType: assetType ?? undefined,\n        citation,\n        thumbnailUrl: assetTypeToThumb(assetType),\n      };\n    }\n    // mention://tool?name=...&description=...\n    // mention://asset?id=...&assetType=project&thumb=../icons/files/ic-project.svg\n    const u = new URL(url);\n    const type = u.hostname || u.pathname.replace(/^\\/\\//, \"\").split(\"?\")[0];\n    const isWebpage = type === \"webpage\";\n    const id = isWebpage\n      ? u.searchParams.get(\"tab_id\") || \"\"\n      : u.searchParams.get(\"id\") || u.searchParams.get(\"name\") || \"\";\n    const name = isWebpage\n      ? u.searchParams.get(\"title\") || \"This webpage\"\n      : u.searchParams.get(\"name\") || id;\n\n    // Get thumbnail: prefer explicit thumb param, then derive from assetType\n    let thumbnailUrl = u.searchParams.get(\"thumb\") || undefined;\n    if (!thumbnailUrl) {\n      const assetType = u.searchParams.get(\"assetType\");\n      if (assetType) {\n        thumbnailUrl = assetTypeToThumb(assetType);\n      } else if (type === \"asset\" || type === \"folder\") {\n        thumbnailUrl = assetTypeToThumb(type === \"folder\" ? \"folder\" : null);\n      }\n    }\n\n    const reference =\n      type === \"asset\" ? decodeAssetLink(u, decodeFromAssetMentionUri) : null;\n\n    return {\n      type,\n      name,\n      id,\n      email: type === \"person\" ? u.searchParams.get(\"email\") || undefined : undefined,\n      assetIds: type === \"asset\" && id ? [id] : undefined,\n      assetType:\n        type === \"asset\" || type === \"folder\"\n          ? u.searchParams.get(\"assetType\") ||\n            reference?.meta?.assetType ||\n            (type === \"folder\" ? \"folder\" : undefined)\n          : undefined,\n      citation: reference ? citationOf(reference) : undefined,\n      sourceHref:\n        reference && (reference.anchor || reference.meta?.excerpt)\n          ? encodeToAssetSpacesUrl(reference)\n          : undefined,\n      thumbnailUrl,\n    };\n  } catch {\n    return { type: \"unknown\", name: \"\", id: \"\" };\n  }\n}\n\nfunction htmlAttribute(attributes: string, name: string): string | null {\n  const escapedName = name.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n  const match = new RegExp(\n    `(?:^|\\\\s)${escapedName}\\\\s*=\\\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\\\s>]+))`,\n    \"i\",\n  ).exec(attributes);\n  return match?.[1] ?? match?.[2] ?? match?.[3] ?? null;\n}\n\nfunction decodeHtmlAttribute(value: string): string {\n  return value\n    .replace(/&amp;/gi, \"&\")\n    .replace(/&quot;/gi, '\"')\n    .replace(/&#39;|&apos;/gi, \"'\")\n    .replace(/&lt;/gi, \"<\")\n    .replace(/&gt;/gi, \">\");\n}\n\n/** Turn complete model-emitted URL citation anchors into safe Markdown links. */\nexport function normalizeAthenaMentionHtml(text: string): string {\n  return text.replace(\n    /<a\\b([^>]*)>([\\s\\S]*?)<\\/a>/gi,\n    (original, attributes: string, rawLabel: string) => {\n      const className = htmlAttribute(attributes, \"class\") ?? \"\";\n      const type = htmlAttribute(attributes, \"data-type\") ?? \"\";\n      if (!className.split(/\\s+/).includes(\"mention\") || type !== \"url\") {\n        return original;\n      }\n\n      const rawUrl =\n        htmlAttribute(attributes, \"data-url\") ??\n        htmlAttribute(attributes, \"href\");\n      if (!rawUrl) return original;\n      const url = decodeHtmlAttribute(rawUrl);\n      let normalizedUrl: string;\n      try {\n        const parsed = new URL(url);\n        if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n          return original;\n        }\n        normalizedUrl = parsed.toString();\n      } catch {\n        return original;\n      }\n\n      const label = decodeHtmlAttribute(rawLabel.replace(/<[^>]*>/g, \"\"))\n        .trim()\n        .replace(/([\\\\[\\]])/g, \"\\\\$1\");\n      return label ? `[${label}](<${normalizedUrl}>)` : original;\n    },\n  );\n}\n// ── Parse mention markdown in plain text ──\n\n// The label may hold balanced brackets one level deep (`[@Plan [Q3]](…)`) or a lone `[`.\nconst MENTION_RE =\n  /\\[@((?:\\[[^[\\]]*\\](?!\\((?:[a-z][a-z0-9+.-]*:\\/\\/|\\/))|[^\\]])*)\\]\\(((?:mention:\\/\\/|(?:https?:\\/\\/[^)\\s]+)?\\/dashboard\\/spaces\\/?\\?)[^)]+)\\)/g;\n\n/**\n * Parse text containing [@name](mention://...) patterns into\n * an array of string segments and MentionChip elements.\n */\nexport function parseMentionsInText(text: string): (string | ReactElement)[] {\n  const parts: (string | ReactElement)[] = [];\n  let lastIndex = 0;\n  let match: RegExpExecArray | null;\n\n  MENTION_RE.lastIndex = 0;\n\n  while ((match = MENTION_RE.exec(text)) !== null) {\n    if (match.index > lastIndex) {\n      parts.push(text.slice(lastIndex, match.index));\n    }\n\n    const name = match[1];\n    const url = match[2];\n    const parsed = parseMentionUrl(url);\n\n    parts.push(\n      <MentionChip\n        key={`mention-${match.index}`}\n        name={name || parsed.name}\n        type={parsed.type}\n        personEmail={personEmailForMention(parsed)}\n        assetIds={parsed.assetIds}\n        assetType={parsed.assetType}\n        citation={parsed.citation}\n        thumbnailUrl={parsed.thumbnailUrl}\n        sourceHref={isSpacesMentionUrl(url) ? url : parsed.sourceHref}\n      />\n    );\n\n    lastIndex = match.index + match[0].length;\n  }\n\n  if (lastIndex < text.length) {\n    parts.push(text.slice(lastIndex));\n  }\n\n  return parts.length > 0 ? parts : [text];\n}\n\n/** The text as a reader sees it: each `[@name](…)` mention becomes `@name`. */\nexport function mentionsToPlainText(text: string): string {\n  return text.replace(MENTION_RE, (_match, name: string, url: string) => {\n    return `@${name || parseMentionUrl(url).name}`;\n  });\n}\n"],"names":["formatReferenceAnchor","FileTextIcon","SheetIcon","PresentationIcon","ImageIcon","VideoIcon","HeadphonesIcon","MailIcon","FileCodeIcon","DatabaseIcon","FolderIcon","MessageSquareIcon","MonitorIcon","Globe2Icon","FileIcon","jsx","isValidElement","isScreenPointHref","parseScreenPointHref","formatScreenPoint","jsxs","cn","CrosshairIcon","useContext","MentionAuthCtx","useMemberAvatarUrl","useState","useMentionAsset","createOlympusAssetUrl","assetTypeToThumb","Fragment","UserIcon","id","reference","decodeFromAssetSpacesUrl","decodeFromAssetMentionUri","encodeToAssetSpacesUrl"],"mappings":";;;;;;;;;;;;;;;AAsDA,MAAM,sBAAsB;AAE5B,SAAS,mBAAmB,KAAsB;AAChD,SAAO,oBAAoB,KAAK,GAAG;AACrC;AAEA,SAAS,mBAAmB,KAAyB;AACnD,QAAM,YACJ,IAAI,aAAa,IAAI,WAAW,KAChC,IAAI,aAAa,IAAI,YAAY,KACjC,IAAI,aAAa,IAAI,MAAM;AAC7B,SAAO,cAAc,UAAU,gBAAgB;AACjD;AAsBA,SAAS,WAAW,WAA4D;AAC9E,QAAM,EAAE,QAAQ,KAAA,IAAS;AACzB,MAAI,CAA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