{"version":3,"file":"ConversationAside.cjs","names":["useT","useToolPrompt","useState","useRef","focusPrompt","Button","MessageIcon","CloseIcon"],"sources":["../../../src/web/components/ConversationAside.tsx"],"sourcesContent":["import { useT } from '@agimon-ai/po-core/web';\nimport { Button, CloseIcon, MessageIcon } from '@agimon-ai/po-web-components';\nimport { type ReactNode, useEffect, useRef, useState } from 'react';\n\nimport { focusPrompt } from '../lib/promptFocus';\nimport { useToolPrompt } from '../stores/useToolPrompt';\n\n/**\n * Wraps a file canvas whose conversation sits beside it rather than below.\n * While the conversation is off screen an \"Ask Po\" cue floats at the canvas's\n * bottom right, rose while Po waits on a question. Wide, the cue asks the host\n * to show its rail; narrow, it opens a sheet over the lower canvas holding\n * `conversation`, which mounts only while the sheet is open so one prompt is\n * mounted at a time. Open state is local: key this on the tab id.\n */\nexport function ConversationAside({\n  children,\n  narrow,\n  conversationShown,\n  onOpenRail,\n  conversation,\n}: {\n  children: ReactNode;\n  narrow: boolean;\n  /** The host is already showing the conversation, so the cue stays out of the way. */\n  conversationShown: boolean;\n  onOpenRail: () => void;\n  conversation: ReactNode;\n}) {\n  const t = useT();\n  const asking = useToolPrompt() !== null;\n  const [open, setOpen] = useState(false);\n  const sheetOpen = narrow && open;\n  const cueRef = useRef<HTMLButtonElement>(null);\n  const wasOpen = useRef(false);\n\n  // The cue unmounts behind the sheet, so focus goes back to it once it returns.\n  useEffect(() => {\n    if (wasOpen.current && !sheetOpen) cueRef.current?.focus();\n    wasOpen.current = sheetOpen;\n  }, [sheetOpen]);\n\n  const ask = () => {\n    if (narrow) setOpen(true);\n    else onOpenRail();\n    // The prompt mounts with the rail or sheet, a frame after this click.\n    requestAnimationFrame(() => focusPrompt());\n  };\n\n  return (\n    <div className=\"relative flex min-h-0 flex-1 flex-col\">\n      {children}\n      {!conversationShown && !sheetOpen ? (\n        <Button\n          ref={cueRef}\n          data-testid=\"ask-po\"\n          variant={asking ? 'secondary' : 'outline'}\n          size=\"md\"\n          aria-label={\n            asking\n              ? t('webDashboard.conversationAside.askingLabel', 'Po is asking you something. Open the conversation')\n              : t('webDashboard.conversationAside.askLabel', 'Ask Po about this file')\n          }\n          className={`absolute right-4 bottom-14 z-10 gap-2 rounded-full shadow-lg ${asking ? '' : 'bg-po-panel text-po-hi'}`}\n          onClick={ask}\n        >\n          <MessageIcon aria-hidden className=\"size-4\" />\n          {asking\n            ? t('webDashboard.conversationAside.asking', 'Po is asking')\n            : t('webDashboard.conversationAside.ask', 'Ask Po')}\n        </Button>\n      ) : null}\n      {sheetOpen ? (\n        <section\n          role=\"dialog\"\n          aria-modal=\"false\"\n          aria-label={t('webDashboard.conversationAside.conversation', 'Conversation')}\n          data-testid=\"conversation-sheet\"\n          // Over a person's backdrop the content region clears every .bg-po-bg, which would let the canvas\n          // show through; as its own region the sheet gets the backdrop wash and blur like the Activity overlay.\n          data-po-region=\"activity\"\n          onKeyDown={(event) => {\n            if (event.key !== 'Escape' || event.defaultPrevented) return;\n            event.preventDefault();\n            setOpen(false);\n          }}\n          // ponytail: bg-po-bg/100 is the same colour under a class name the backdrop rule does not clear.\n          className=\"absolute inset-x-0 bottom-0 z-20 flex h-[60%] flex-col overflow-hidden rounded-t-2xl border-t border-po-border-soft bg-po-bg/100 shadow-2xl\"\n        >\n          <span aria-hidden className=\"mx-auto mt-2 h-1 w-10 shrink-0 rounded-full bg-po-border\" />\n          <header className=\"flex h-11 shrink-0 items-center gap-2 pr-2 pl-5\">\n            <span className=\"min-w-0 flex-1 truncate text-base font-semibold text-po-hi\">\n              {t('webDashboard.conversationAside.conversation', 'Conversation')}\n            </span>\n            <Button\n              variant=\"ghost\"\n              size=\"icon-md\"\n              aria-label={t('webDashboard.conversationAside.close', 'Close conversation')}\n              className=\"text-po-dim\"\n              onClick={() => setOpen(false)}\n            >\n              <CloseIcon aria-hidden className=\"size-4\" />\n            </Button>\n          </header>\n          {conversation}\n        </section>\n      ) : null}\n    </div>\n  );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAgB,k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