{"version":3,"file":"useOpenTab.mjs","names":[],"sources":["../../../src/web/stores/useOpenTab.ts"],"sourcesContent":["import { useNavigate } from '@tanstack/react-router';\nimport { useStore } from '@tanstack/react-store';\nimport { useCallback } from 'react';\n\nimport { sessionsStore } from './sessionsStore';\n\n/**\n * Navigation for the focused session, in the shape plugins receive: a tab id\n * opens that plugin tab, null returns to the conversation. A no-op while no\n * session is focused, because there is no page to open a tab on.\n */\nexport function useOpenTab(): (tabId: string | null) => void {\n  const activeId = useStore(sessionsStore, (state) => state.tabOwnerId ?? state.activeId);\n  const navigate = useNavigate();\n  return useCallback(\n    (tabId) => {\n      if (activeId === null) return;\n      void (tabId === null\n        ? navigate({ to: '/session/$sessionId', params: { sessionId: activeId } })\n        : navigate({ to: '/session/$sessionId/$tabId', params: { sessionId: activeId, tabId } }));\n    },\n    [activeId, navigate],\n  );\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,aAA6C;CAC3D,MAAM,WAAW,SAAS,gBAAgB,UAAU,MAAM,cAAc,MAAM,QAAQ;CACtF,MAAM,WAAW,YAAY;CAC7B,OAAO,aACJ,UAAU;EACT,IAAI,aAAa,MAAM;EACvB,UAAgB,OACZ,SAAS;GAAE,IAAI;GAAuB,QAAQ,EAAE,WAAW,SAAS;EAAE,CAAC,IACvE,SAAS;GAAE,IAAI;GAA8B,QAAQ;IAAE,WAAW;IAAU;GAAM;EAAE,CAAC;CAC3F,GACA,CAAC,UAAU,QAAQ,CACrB;AACF"}