{"version":3,"file":"SessionMention.cjs","names":["useT","useNavigate","useStore","sessionsStore","resolveSessionReference","mentionableSessions","splitHostId","defaultHostId","qualifyHostId","Button","MessageIcon"],"sources":["../../../../src/web/features/session/SessionMention.tsx"],"sourcesContent":["import { useT } from '@agimon-ai/po-core/web';\nimport { Button, MessageIcon, type ReferenceRenderer } from '@agimon-ai/po-web-components';\nimport { useNavigate } from '@tanstack/react-router';\nimport { useStore } from '@tanstack/react-store';\n\nimport { defaultHostId, qualifyHostId, splitHostId } from '../../lib/hostIdentity';\nimport { resolveSessionReference, SESSION_REFERENCE_SCHEME } from '../../lib/sessionMentions';\nimport { mentionableSessions, sessionsStore } from '../../stores/sessionsStore';\n\nconst NO_WORKSPACES = {};\n\n/**\n * An `@session:<token>` in a message from `senderId`: the session it named on the sender's computer as a chip that\n * opens it, or the plain token once that session is gone.\n */\nfunction SessionMention({ reference, senderId }: { reference: string; senderId: string | null }) {\n  const t = useT();\n  const navigate = useNavigate();\n  const target = useStore(sessionsStore, (state) => {\n    const resolved = resolveSessionReference(reference, mentionableSessions(state, NO_WORKSPACES, senderId, 0));\n    const hostId = (senderId === null ? undefined : splitHostId(senderId)?.hostId) ?? defaultHostId();\n    // A single-host page keys its sessions by their bare id.\n    if (resolved === undefined) return null;\n    return hostId === undefined ? resolved.id : qualifyHostId(hostId, resolved.id);\n  });\n  const name = useStore(sessionsStore, (state) => (target === null ? null : state.byId[target]?.summary.name));\n  if (target === null || name == null) return <>@{reference}</>;\n  const label = name.trim() || t('webDashboard.session.untitled', 'Untitled');\n  return (\n    <Button\n      variant=\"subtle\"\n      size=\"xs\"\n      data-testid=\"session-mention\"\n      title={t('webDashboard.session.openSession', 'Open {label}', { label })}\n      onClick={() => void navigate({ to: '/session/$sessionId', params: { sessionId: target } })}\n      className=\"mx-0.5 inline-flex h-auto translate-y-px items-center gap-1 rounded-md border border-po-border px-1.5 py-px align-baseline font-medium text-po-hi hover:border-po-blue/50 hover:bg-po-panel\"\n    >\n      <MessageIcon aria-hidden className=\"size-3 text-po-dim\" />\n      {label}\n    </Button>\n  );\n}\n\n/** Draws session references in `senderId`'s messages as chips and leaves every other scheme to the Markdown's text. */\nexport function sessionReferenceRenderer(senderId: string | null): ReferenceRenderer {\n  return (reference) =>\n    reference.startsWith(SESSION_REFERENCE_SCHEME) ? (\n      <SessionMention reference={reference} senderId={senderId} />\n    ) : undefined;\n}\n"],"mappings":";;;;;;;;;AASA,MAAM,gBAAgB,CAAC;;;;;AAMvB,SAAS,eAAe,EAAE,WAAW,YAA4D;CAC/F,MAAM,KAAA,GAAIA,uBAAAA,KAAAA,CAAK;CACf,MAAM,YAAA,GAAWC,uBAAAA,YAAAA,CAAY;CAC7B,MAAM,UAAA,GAASC,sBAAAA,SAAAA,CAASC,sBAAAA,gBAAgB,UAAU;EAChD,MAAM,WAAWC,wBAAAA,wBAAwB,WAAWC,sBAAAA,oBAAoB,OAAO,eAAe,UAAU,CAAC,CAAC;EAC1G,MAAM,UAAU,aAAa,OAAO,KAAA,IAAYC,qBAAAA,YAAY,QAAQ,CAAC,EAAE,WAAWC,qBAAAA,cAAc;EAEhG,IAAI,aAAa,KAAA,GAAW,OAAO;EACnC,OAAO,WAAW,KAAA,IAAY,SAAS,KAAKC,qBAAAA,cAAc,QAAQ,SAAS,EAAE;CAC/E,CAAC;CACD,MAAM,QAAA,GAAON,sBAAAA,SAAAA,CAASC,sBAAAA,gBAAgB,UAAW,WAAW,OAAO,OAAO,MAAM,KAAK,OAAO,EAAE,QAAQ,IAAK;CAC3G,IAAI,WAAW,QAAQ,QAAQ,MAAM,OAAO,iBAAA,GAAA,kBAAA,KAAA,CAAA,kBAAA,UAAA,EAAA,UAAA,CAAE,KAAE,SAAY,EAAA,CAAA;CAC5D,MAAM,QAAQ,KAAK,KAAK,KAAK,EAAE,iCAAiC,UAAU;CAC1E,OACE,iBAAA,GAAA,kBAAA,KAAA,CAACM,6BAAAA,QAAD;EACE,SAAQ;EACR,MAAK;EACL,eAAY;EACZ,OA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