@burdenoff/microfe-theculturepost 2026.1203.1 → 2026.1203.2

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.
Files changed (42) hide show
  1. package/dist/theculturepost/TheCulturePostRoutes.js +12 -4
  2. package/dist/theculturepost/TheCulturePostRoutes.js.map +1 -1
  3. package/dist/theculturepost/components/AiContextPanel.js +20 -2
  4. package/dist/theculturepost/components/AiContextPanel.js.map +1 -1
  5. package/dist/theculturepost/components/FollowButton.d.ts +8 -0
  6. package/dist/theculturepost/components/FollowButton.js +41 -0
  7. package/dist/theculturepost/components/FollowButton.js.map +1 -0
  8. package/dist/theculturepost/components/ReaderContextDrawer.d.ts +15 -0
  9. package/dist/theculturepost/components/ReaderContextDrawer.js +223 -0
  10. package/dist/theculturepost/components/ReaderContextDrawer.js.map +1 -0
  11. package/dist/theculturepost/components/SourceHealthAndReputation.d.ts +10 -0
  12. package/dist/theculturepost/components/SourceHealthAndReputation.js +41 -0
  13. package/dist/theculturepost/components/SourceHealthAndReputation.js.map +1 -0
  14. package/dist/theculturepost/components/index.js +3 -3
  15. package/dist/theculturepost/hooks/index.js +7 -7
  16. package/dist/theculturepost/hooks/useTcpApi.d.ts +63 -1
  17. package/dist/theculturepost/hooks/useTcpApi.js +298 -49
  18. package/dist/theculturepost/hooks/useTcpApi.js.map +1 -1
  19. package/dist/theculturepost/pages/archive/ArchiveItemDetailPage.js +159 -139
  20. package/dist/theculturepost/pages/archive/ArchiveItemDetailPage.js.map +1 -1
  21. package/dist/theculturepost/pages/archive/ArchivePage.js +171 -135
  22. package/dist/theculturepost/pages/archive/ArchivePage.js.map +1 -1
  23. package/dist/theculturepost/pages/curriculum/CurriculumPage.d.ts +10 -0
  24. package/dist/theculturepost/pages/curriculum/CurriculumPage.js +401 -0
  25. package/dist/theculturepost/pages/curriculum/CurriculumPage.js.map +1 -0
  26. package/dist/theculturepost/pages/governance/AiOpsPanel.d.ts +13 -0
  27. package/dist/theculturepost/pages/governance/AiOpsPanel.js +369 -0
  28. package/dist/theculturepost/pages/governance/AiOpsPanel.js.map +1 -0
  29. package/dist/theculturepost/pages/governance/GovernancePage.d.ts +1 -1
  30. package/dist/theculturepost/pages/governance/GovernancePage.js +107 -95
  31. package/dist/theculturepost/pages/governance/GovernancePage.js.map +1 -1
  32. package/dist/theculturepost/pages/stories/StoriesPage.js +113 -74
  33. package/dist/theculturepost/pages/stories/StoriesPage.js.map +1 -1
  34. package/dist/theculturepost/pages/stories/StoryDetailPage.js +284 -268
  35. package/dist/theculturepost/pages/stories/StoryDetailPage.js.map +1 -1
  36. package/dist/theculturepost/pages/studio/ContributorStudioPage.d.ts +12 -0
  37. package/dist/theculturepost/pages/studio/ContributorStudioPage.js +463 -0
  38. package/dist/theculturepost/pages/studio/ContributorStudioPage.js.map +1 -0
  39. package/dist/theculturepost/pages/topics/TopicDetailPage.js +65 -54
  40. package/dist/theculturepost/pages/topics/TopicDetailPage.js.map +1 -1
  41. package/dist/theculturepost/types/index.d.ts +227 -2
  42. package/package.json +2 -2
@@ -38,17 +38,17 @@ function h(e, t) {
38
38
  children: e
39
39
  });
40
40
  }
41
- var g = i(() => import("./pages/stories/StoriesPage.js").then((e) => ({ default: e.StoriesPage }))), _ = i(() => import("./pages/stories/StoryDetailPage.js").then((e) => ({ default: e.StoryDetailPage }))), v = i(() => import("./pages/stories/StoryCitationsPage.js").then((e) => ({ default: e.StoryCitationsPage }))), y = i(() => import("./pages/stories/SavedStoriesPage.js").then((e) => ({ default: e.SavedStoriesPage }))), b = i(() => import("./pages/topics/TopicsPage.js").then((e) => ({ default: e.TopicsPage }))), x = i(() => import("./pages/topics/TopicDetailPage.js").then((e) => ({ default: e.TopicDetailPage }))), S = i(() => import("./pages/discussions/DiscussionsPage.js").then((e) => ({ default: e.DiscussionsPage }))), C = i(() => import("./pages/discussions/DiscussionDetailPage.js").then((e) => ({ default: e.DiscussionDetailPage }))), w = i(() => import("./pages/timeline/TimelinePage.js").then((e) => ({ default: e.TimelinePage }))), T = i(() => import("./pages/governance/GovernancePage.js").then((e) => ({ default: e.GovernancePage }))), E = i(() => import("./pages/archive/ArchivePage.js").then((e) => ({ default: e.ArchivePage }))), D = i(() => import("./pages/archive/CollectionDetailPage.js").then((e) => ({ default: e.CollectionDetailPage }))), O = i(() => import("./pages/archive/ArchiveItemDetailPage.js").then((e) => ({ default: e.ArchiveItemDetailPage }))), k = () => /* @__PURE__ */ u("div", {
41
+ var g = i(() => import("./pages/stories/StoriesPage.js").then((e) => ({ default: e.StoriesPage }))), _ = i(() => import("./pages/stories/StoryDetailPage.js").then((e) => ({ default: e.StoryDetailPage }))), v = i(() => import("./pages/stories/StoryCitationsPage.js").then((e) => ({ default: e.StoryCitationsPage }))), y = i(() => import("./pages/stories/SavedStoriesPage.js").then((e) => ({ default: e.SavedStoriesPage }))), b = i(() => import("./pages/topics/TopicsPage.js").then((e) => ({ default: e.TopicsPage }))), x = i(() => import("./pages/topics/TopicDetailPage.js").then((e) => ({ default: e.TopicDetailPage }))), S = i(() => import("./pages/discussions/DiscussionsPage.js").then((e) => ({ default: e.DiscussionsPage }))), C = i(() => import("./pages/discussions/DiscussionDetailPage.js").then((e) => ({ default: e.DiscussionDetailPage }))), w = i(() => import("./pages/timeline/TimelinePage.js").then((e) => ({ default: e.TimelinePage }))), T = i(() => import("./pages/governance/GovernancePage.js").then((e) => ({ default: e.GovernancePage }))), E = i(() => import("./pages/archive/ArchivePage.js").then((e) => ({ default: e.ArchivePage }))), D = i(() => import("./pages/archive/CollectionDetailPage.js").then((e) => ({ default: e.CollectionDetailPage }))), O = i(() => import("./pages/archive/ArchiveItemDetailPage.js").then((e) => ({ default: e.ArchiveItemDetailPage }))), k = i(() => import("./pages/studio/ContributorStudioPage.js").then((e) => ({ default: e.ContributorStudioPage }))), A = i(() => import("./pages/curriculum/CurriculumPage.js").then((e) => ({ default: e.CurriculumPage }))), j = () => /* @__PURE__ */ u("div", {
42
42
  className: "flex min-h-[400px] items-center justify-center",
43
43
  children: /* @__PURE__ */ u(f, { size: "lg" })
44
- }), A = () => {
44
+ }), M = () => {
45
45
  let { basePath: i, isStandalone: a } = e(), f = l();
46
46
  t();
47
47
  let m = i === "/" ? "" : (i ?? "").replace(/\/$/, "");
48
48
  return m && !a && !(f.pathname === m || f.pathname.startsWith(m + "/")) ? null : /* @__PURE__ */ u("div", {
49
49
  className: "flex min-h-full flex-col",
50
50
  children: /* @__PURE__ */ u(r, {
51
- fallback: /* @__PURE__ */ u(k, {}),
51
+ fallback: /* @__PURE__ */ u(j, {}),
52
52
  children: /* @__PURE__ */ d(c, { children: [
53
53
  /* @__PURE__ */ u(s, {
54
54
  index: !0,
@@ -118,6 +118,14 @@ var g = i(() => import("./pages/stories/StoriesPage.js").then((e) => ({ default:
118
118
  path: "archive/items/:id",
119
119
  element: h(/* @__PURE__ */ u(O, {}), p.archive)
120
120
  }),
121
+ /* @__PURE__ */ u(s, {
122
+ path: "studio",
123
+ element: h(/* @__PURE__ */ u(k, {}), p.stories)
124
+ }),
125
+ /* @__PURE__ */ u(s, {
126
+ path: "curriculum",
127
+ element: h(/* @__PURE__ */ u(A, {}), p.archive)
128
+ }),
121
129
  /* @__PURE__ */ u(s, {
122
130
  path: "*",
123
131
  element: /* @__PURE__ */ u(o, {
@@ -129,6 +137,6 @@ var g = i(() => import("./pages/stories/StoriesPage.js").then((e) => ({ default:
129
137
  })
130
138
  });
131
139
  };
132
- export { A as TheCulturePostRoutes };
140
+ export { M as TheCulturePostRoutes };
133
141
 
134
142
  //# sourceMappingURL=TheCulturePostRoutes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TheCulturePostRoutes.js","names":["FEATURE","FeatureDisabledFallback","gated","FeatureGate","element","StoriesPage","lazy","m","StoryDetailPage","StoryCitationsPage","SavedStoriesPage","TopicsPage","TopicDetailPage","DiscussionsPage","DiscussionDetailPage","TimelinePage","GovernancePage","ArchivePage","CollectionDetailPage","ArchiveItemDetailPage","PageLoader","Spinner","TheCulturePostRoutes","useTheCulturePost","location","useLocation","normalizedBasePath","basePath","isStandalone","Suspense","Routes","Route","HomePage","Navigate"],"sources":["../../src/theculturepost/TheCulturePostRoutes.tsx"],"sourcesContent":["/**\n * TheCulturePost Routes\n * @module theculturepost\n *\n * Domain routes. The editorial home page is eager-loaded (primary landing); all\n * other pages are lazy-loaded. Every route maps to a real `tcp*` backend\n * capability.\n */\n\nimport { type FC, lazy, Suspense, type ReactElement } from 'react';\nimport { Routes, Route, Navigate, useLocation } from 'react-router';\nimport { Spinner } from '@burdenoff/fe-libs/ui';\nimport { FeatureGate } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { useTheCulturePost } from './context/TheCulturePostContext';\nimport { usePageAnalytics } from './hooks/usePageAnalytics';\n\nconst FEATURE = {\n home: 'theculturepost.home',\n overview: 'theculturepost.overview',\n admin: 'theculturepost.admin',\n stories: 'theculturepost.stories',\n topics: 'theculturepost.topics',\n timeline: 'theculturepost.timeline',\n discussions: 'theculturepost.discussions',\n archive: 'theculturepost.archive',\n saved: 'theculturepost.saved',\n} as const;\n\nfunction FeatureDisabledFallback(): ReactElement {\n return (\n <div className=\"flex min-h-[400px] flex-col items-center justify-center gap-3 text-text-secondary\">\n <span className=\"text-lg font-semibold text-text-primary\">Feature unavailable</span>\n <span className=\"text-sm\">This page is disabled in your workspace.</span>\n </div>\n );\n}\n\nfunction gated(element: ReactElement, flag: string): ReactElement {\n return (\n <FeatureGate flag={flag} defaultValue fallback={<FeatureDisabledFallback />}>\n {element}\n </FeatureGate>\n );\n}\n\n// Eager — primary landing\nimport { HomePage } from './pages/HomePage';\n\n// Stories\nconst StoriesPage = lazy(() =>\n import('./pages/stories/StoriesPage').then((m) => ({ default: m.StoriesPage }))\n);\nconst StoryDetailPage = lazy(() =>\n import('./pages/stories/StoryDetailPage').then((m) => ({ default: m.StoryDetailPage }))\n);\nconst StoryCitationsPage = lazy(() =>\n import('./pages/stories/StoryCitationsPage').then((m) => ({ default: m.StoryCitationsPage }))\n);\nconst SavedStoriesPage = lazy(() =>\n import('./pages/stories/SavedStoriesPage').then((m) => ({ default: m.SavedStoriesPage }))\n);\n\n// Topics\nconst TopicsPage = lazy(() =>\n import('./pages/topics/TopicsPage').then((m) => ({ default: m.TopicsPage }))\n);\nconst TopicDetailPage = lazy(() =>\n import('./pages/topics/TopicDetailPage').then((m) => ({ default: m.TopicDetailPage }))\n);\n\n// Discussions\nconst DiscussionsPage = lazy(() =>\n import('./pages/discussions/DiscussionsPage').then((m) => ({ default: m.DiscussionsPage }))\n);\nconst DiscussionDetailPage = lazy(() =>\n import('./pages/discussions/DiscussionDetailPage').then((m) => ({\n default: m.DiscussionDetailPage,\n }))\n);\n\n// Timeline\nconst TimelinePage = lazy(() =>\n import('./pages/timeline/TimelinePage').then((m) => ({ default: m.TimelinePage }))\n);\n\n// Governance / Overview\nconst GovernancePage = lazy(() =>\n import('./pages/governance/GovernancePage').then((m) => ({ default: m.GovernancePage }))\n);\n\n// Archive\nconst ArchivePage = lazy(() =>\n import('./pages/archive/ArchivePage').then((m) => ({ default: m.ArchivePage }))\n);\nconst CollectionDetailPage = lazy(() =>\n import('./pages/archive/CollectionDetailPage').then((m) => ({ default: m.CollectionDetailPage }))\n);\nconst ArchiveItemDetailPage = lazy(() =>\n import('./pages/archive/ArchiveItemDetailPage').then((m) => ({\n default: m.ArchiveItemDetailPage,\n }))\n);\n\nconst PageLoader: FC = () => (\n <div className=\"flex min-h-[400px] items-center justify-center\">\n <Spinner size=\"lg\" />\n </div>\n);\n\nexport const TheCulturePostRoutes: FC = () => {\n const { basePath, isStandalone } = useTheCulturePost();\n const location = useLocation();\n\n usePageAnalytics();\n\n const normalizedBasePath = basePath === '/' ? '' : (basePath ?? '').replace(/\\/$/, '');\n\n // Guard: only render if the current path matches basePath (integrated mode).\n if (normalizedBasePath && !isStandalone) {\n const pathMatches =\n location.pathname === normalizedBasePath ||\n location.pathname.startsWith(normalizedBasePath + '/');\n if (!pathMatches) {\n return null;\n }\n }\n\n return (\n <div className=\"flex min-h-full flex-col\">\n <Suspense fallback={<PageLoader />}>\n <Routes>\n <Route index element={gated(<HomePage />, FEATURE.home)} />\n\n <Route path=\"overview\" element={gated(<GovernancePage />, FEATURE.overview)} />\n <Route path=\"overview/:tab\" element={gated(<GovernancePage />, FEATURE.overview)} />\n <Route\n path=\"admin\"\n element={gated(<GovernancePage defaultTab=\"review\" />, FEATURE.admin)}\n />\n <Route path=\"admin/:tab\" element={gated(<GovernancePage />, FEATURE.admin)} />\n\n <Route path=\"stories\" element={gated(<StoriesPage />, FEATURE.stories)} />\n <Route path=\"stories/:id\" element={gated(<StoryDetailPage />, FEATURE.stories)} />\n <Route\n path=\"stories/:id/citations\"\n element={gated(<StoryCitationsPage />, FEATURE.stories)}\n />\n\n <Route path=\"saved\" element={gated(<SavedStoriesPage />, FEATURE.saved)} />\n\n <Route path=\"topics\" element={gated(<TopicsPage />, FEATURE.topics)} />\n <Route path=\"topics/:id\" element={gated(<TopicDetailPage />, FEATURE.topics)} />\n\n <Route path=\"timeline\" element={gated(<TimelinePage />, FEATURE.timeline)} />\n\n <Route path=\"discussions\" element={gated(<DiscussionsPage />, FEATURE.discussions)} />\n <Route\n path=\"discussions/:id\"\n element={gated(<DiscussionDetailPage />, FEATURE.discussions)}\n />\n\n <Route path=\"archive\" element={gated(<ArchivePage />, FEATURE.archive)} />\n <Route\n path=\"archive/collections/:id\"\n element={gated(<CollectionDetailPage />, FEATURE.archive)}\n />\n <Route\n path=\"archive/items/:id\"\n element={gated(<ArchiveItemDetailPage />, FEATURE.archive)}\n />\n\n <Route path=\"*\" element={<Navigate to=\"\" replace />} />\n </Routes>\n </Suspense>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;AAgBA,IAAMA,IAAU;CACd,MAAM;CACN,UAAU;CACV,OAAO;CACP,SAAS;CACT,QAAQ;CACR,UAAU;CACV,aAAa;CACb,SAAS;CACT,OAAO;AACT;AAEA,SAASC,IAAwC;CAC/C,OACE,kBAAC,OAAD;EAAK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AAA;IACzE,kBAAC+B,GAAD;KACE,MAAK;KACL,SAAS7B,EAAM,kBAACgB,GAAD,CAAuB,CAAA,GAAGlB,EAAQ,OAAO;IACzD,CAAA;IACD,kBAAC+B,GAAD;KACE,MAAK;KACL,SAAS7B,EAAM,kBAACiB,GAAD,CAAwB,CAAA,GAAGnB,EAAQ,OAAO;IAC1D,CAAA;IAED,kBAAC+B,GAAD;KAAO,MAAK;KAAI,SAAS,kBAACE,GAAD;MAAU,IAAG;MAAG,SAAA;KAAS,CAAA;IAAI,CAAA;GAChD,EAAA,CAAA;EACA,CAAA;CACP,CAAA;AAET"}
1
+ {"version":3,"file":"TheCulturePostRoutes.js","names":["FEATURE","FeatureDisabledFallback","gated","FeatureGate","element","StoriesPage","lazy","m","StoryDetailPage","StoryCitationsPage","SavedStoriesPage","TopicsPage","TopicDetailPage","DiscussionsPage","DiscussionDetailPage","TimelinePage","GovernancePage","ArchivePage","CollectionDetailPage","ArchiveItemDetailPage","ContributorStudioPage","CurriculumPage","PageLoader","Spinner","TheCulturePostRoutes","useTheCulturePost","location","useLocation","normalizedBasePath","basePath","isStandalone","Suspense","Routes","Route","HomePage","Navigate"],"sources":["../../src/theculturepost/TheCulturePostRoutes.tsx"],"sourcesContent":["/**\n * TheCulturePost Routes\n * @module theculturepost\n *\n * Domain routes. The editorial home page is eager-loaded (primary landing); all\n * other pages are lazy-loaded. Every route maps to a real `tcp*` backend\n * capability.\n */\n\nimport { type FC, lazy, Suspense, type ReactElement } from 'react';\nimport { Routes, Route, Navigate, useLocation } from 'react-router';\nimport { Spinner } from '@burdenoff/fe-libs/ui';\nimport { FeatureGate } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { useTheCulturePost } from './context/TheCulturePostContext';\nimport { usePageAnalytics } from './hooks/usePageAnalytics';\n\nconst FEATURE = {\n home: 'theculturepost.home',\n overview: 'theculturepost.overview',\n admin: 'theculturepost.admin',\n stories: 'theculturepost.stories',\n topics: 'theculturepost.topics',\n timeline: 'theculturepost.timeline',\n discussions: 'theculturepost.discussions',\n archive: 'theculturepost.archive',\n saved: 'theculturepost.saved',\n} as const;\n\nfunction FeatureDisabledFallback(): ReactElement {\n return (\n <div className=\"flex min-h-[400px] flex-col items-center justify-center gap-3 text-text-secondary\">\n <span className=\"text-lg font-semibold text-text-primary\">Feature unavailable</span>\n <span className=\"text-sm\">This page is disabled in your workspace.</span>\n </div>\n );\n}\n\nfunction gated(element: ReactElement, flag: string): ReactElement {\n return (\n <FeatureGate flag={flag} defaultValue fallback={<FeatureDisabledFallback />}>\n {element}\n </FeatureGate>\n );\n}\n\n// Eager — primary landing\nimport { HomePage } from './pages/HomePage';\n\n// Stories\nconst StoriesPage = lazy(() =>\n import('./pages/stories/StoriesPage').then((m) => ({ default: m.StoriesPage }))\n);\nconst StoryDetailPage = lazy(() =>\n import('./pages/stories/StoryDetailPage').then((m) => ({ default: m.StoryDetailPage }))\n);\nconst StoryCitationsPage = lazy(() =>\n import('./pages/stories/StoryCitationsPage').then((m) => ({ default: m.StoryCitationsPage }))\n);\nconst SavedStoriesPage = lazy(() =>\n import('./pages/stories/SavedStoriesPage').then((m) => ({ default: m.SavedStoriesPage }))\n);\n\n// Topics\nconst TopicsPage = lazy(() =>\n import('./pages/topics/TopicsPage').then((m) => ({ default: m.TopicsPage }))\n);\nconst TopicDetailPage = lazy(() =>\n import('./pages/topics/TopicDetailPage').then((m) => ({ default: m.TopicDetailPage }))\n);\n\n// Discussions\nconst DiscussionsPage = lazy(() =>\n import('./pages/discussions/DiscussionsPage').then((m) => ({ default: m.DiscussionsPage }))\n);\nconst DiscussionDetailPage = lazy(() =>\n import('./pages/discussions/DiscussionDetailPage').then((m) => ({\n default: m.DiscussionDetailPage,\n }))\n);\n\n// Timeline\nconst TimelinePage = lazy(() =>\n import('./pages/timeline/TimelinePage').then((m) => ({ default: m.TimelinePage }))\n);\n\n// Governance / Overview\nconst GovernancePage = lazy(() =>\n import('./pages/governance/GovernancePage').then((m) => ({ default: m.GovernancePage }))\n);\n\n// Archive\nconst ArchivePage = lazy(() =>\n import('./pages/archive/ArchivePage').then((m) => ({ default: m.ArchivePage }))\n);\nconst CollectionDetailPage = lazy(() =>\n import('./pages/archive/CollectionDetailPage').then((m) => ({ default: m.CollectionDetailPage }))\n);\nconst ArchiveItemDetailPage = lazy(() =>\n import('./pages/archive/ArchiveItemDetailPage').then((m) => ({\n default: m.ArchiveItemDetailPage,\n }))\n);\n\n// Contributor Studio (BOFF-5844) & Classroom / Curriculum (BOFF-5845)\nconst ContributorStudioPage = lazy(() =>\n import('./pages/studio/ContributorStudioPage').then((m) => ({\n default: m.ContributorStudioPage,\n }))\n);\nconst CurriculumPage = lazy(() =>\n import('./pages/curriculum/CurriculumPage').then((m) => ({\n default: m.CurriculumPage,\n }))\n);\n\nconst PageLoader: FC = () => (\n <div className=\"flex min-h-[400px] items-center justify-center\">\n <Spinner size=\"lg\" />\n </div>\n);\n\nexport const TheCulturePostRoutes: FC = () => {\n const { basePath, isStandalone } = useTheCulturePost();\n const location = useLocation();\n\n usePageAnalytics();\n\n const normalizedBasePath = basePath === '/' ? '' : (basePath ?? '').replace(/\\/$/, '');\n\n // Guard: only render if the current path matches basePath (integrated mode).\n if (normalizedBasePath && !isStandalone) {\n const pathMatches =\n location.pathname === normalizedBasePath ||\n location.pathname.startsWith(normalizedBasePath + '/');\n if (!pathMatches) {\n return null;\n }\n }\n\n return (\n <div className=\"flex min-h-full flex-col\">\n <Suspense fallback={<PageLoader />}>\n <Routes>\n <Route index element={gated(<HomePage />, FEATURE.home)} />\n\n <Route path=\"overview\" element={gated(<GovernancePage />, FEATURE.overview)} />\n <Route path=\"overview/:tab\" element={gated(<GovernancePage />, FEATURE.overview)} />\n <Route\n path=\"admin\"\n element={gated(<GovernancePage defaultTab=\"review\" />, FEATURE.admin)}\n />\n <Route path=\"admin/:tab\" element={gated(<GovernancePage />, FEATURE.admin)} />\n\n <Route path=\"stories\" element={gated(<StoriesPage />, FEATURE.stories)} />\n <Route path=\"stories/:id\" element={gated(<StoryDetailPage />, FEATURE.stories)} />\n <Route\n path=\"stories/:id/citations\"\n element={gated(<StoryCitationsPage />, FEATURE.stories)}\n />\n\n <Route path=\"saved\" element={gated(<SavedStoriesPage />, FEATURE.saved)} />\n\n <Route path=\"topics\" element={gated(<TopicsPage />, FEATURE.topics)} />\n <Route path=\"topics/:id\" element={gated(<TopicDetailPage />, FEATURE.topics)} />\n\n <Route path=\"timeline\" element={gated(<TimelinePage />, FEATURE.timeline)} />\n\n <Route path=\"discussions\" element={gated(<DiscussionsPage />, FEATURE.discussions)} />\n <Route\n path=\"discussions/:id\"\n element={gated(<DiscussionDetailPage />, FEATURE.discussions)}\n />\n\n <Route path=\"archive\" element={gated(<ArchivePage />, FEATURE.archive)} />\n <Route\n path=\"archive/collections/:id\"\n element={gated(<CollectionDetailPage />, FEATURE.archive)}\n />\n <Route\n path=\"archive/items/:id\"\n element={gated(<ArchiveItemDetailPage />, FEATURE.archive)}\n />\n\n <Route path=\"studio\" element={gated(<ContributorStudioPage />, FEATURE.stories)} />\n <Route path=\"curriculum\" element={gated(<CurriculumPage />, FEATURE.archive)} />\n\n <Route path=\"*\" element={<Navigate to=\"\" replace />} />\n </Routes>\n </Suspense>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;AAgBA,IAAMA,IAAU;CACd,MAAM;CACN,UAAU;CACV,OAAO;CACP,SAAS;CACT,QAAQ;CACR,UAAU;CACV,aAAa;CACb,SAAS;CACT,OAAO;AACT;AAEA,SAASC,IAAwC;CAC/C,OACE,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAAC,QAAD;GAAM,WAAU;GAA0C,UAAA;EAAyB,CAAA,GACnF,kBAAC,QAAD;GAAM,WAAU;GAAU,UAAA;EAA8C,CAAA,CACrE;;AAET;AAEA,SAASC,EAAM,GAAuB,GAA4B;CAChE,OACE,kBAACC,GAAD;EAAmB;EAAM,cAAA;EAAa,UAAU,kBAACF,GAAD,CAA0B,CAAA;EACvE,UAA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ACzD,CAAA;IACD,kBAACiC,GAAD;KACE,MAAK;KACL,SAAS/B,EAAM,kBAACiB,GAAD,CAAwB,CAAA,GAAGnB,EAAQ,OAAO;IAC1D,CAAA;IAED,kBAACiC,GAAD;KAAO,MAAK;KAAS,SAAS/B,EAAM,kBAACkB,GAAD,CAAwB,CAAA,GAAGpB,EAAQ,OAAO;IAAI,CAAA;IAClF,kBAACiC,GAAD;KAAO,MAAK;KAAa,SAAS/B,EAAM,kBAACmB,GAAD,CAAiB,CAAA,GAAGrB,EAAQ,OAAO;IAAI,CAAA;IAE/E,kBAACiC,GAAD;KAAO,MAAK;KAAI,SAAS,kBAACE,GAAD;MAAU,IAAG;MAAG,SAAA;KAAS,CAAA;IAAI,CAAA;GAChD,EAAA,CAAA;EACA,CAAA;CACP,CAAA;AAET"}
@@ -19,12 +19,30 @@ var N = {
19
19
  SUMMARIZE_EVIDENCE: "Summarise evidence",
20
20
  DRAFT_FRAMING_PROMPT: "Draft framing",
21
21
  SUGGEST_RELATED_TRADITIONS: "Find related traditions",
22
- TRANSCRIBE_ORAL_HISTORY: "Clean up transcript"
22
+ TRANSCRIBE_ORAL_HISTORY: "Clean up transcript",
23
+ VERIFY_CITATION: "Verify citation proposal",
24
+ ASSESS_SOURCE_HEALTH: "Assess source health",
25
+ SENSITIVITY_FRAMING: "Sensitivity framing review",
26
+ EXPLAIN_TERM: "Explain term",
27
+ TRANSLATE_STORY: "Translate story draft",
28
+ EDITORIAL_SWEEP: "Editorial sweep",
29
+ ANALYZE_ARCHIVE_IMAGE: "Analyze archive image",
30
+ GENERATE_SUBTITLES: "Generate subtitles",
31
+ SPEECH_TO_TEXT: "Speech-to-text transcript"
23
32
  }, P = {
24
33
  SUMMARIZE_EVIDENCE: "What do the cited sources say about this story’s central claims?",
25
34
  DRAFT_FRAMING_PROMPT: "Draft a short framing question that an editor could put to the cited sources.",
26
35
  SUGGEST_RELATED_TRADITIONS: "Which traditions or practices in this collection relate to each other, and why?",
27
- TRANSCRIBE_ORAL_HISTORY: "Clean up and format this transcript: fix punctuation and paragraph breaks, and mark speaker turns — do not add any content that is not in the original."
36
+ TRANSCRIBE_ORAL_HISTORY: "Clean up and format this transcript: fix punctuation and paragraph breaks, and mark speaker turns — do not add any content that is not in the original.",
37
+ VERIFY_CITATION: "Propose a verification status grounded strictly in this citation and excerpt.",
38
+ ASSESS_SOURCE_HEALTH: "Assess reachability and strength of all citations on this story.",
39
+ SENSITIVITY_FRAMING: "Flag any framing concerns with respectful reframing suggestions.",
40
+ EXPLAIN_TERM: "Explain this term using only eligible workspace sources, or abstain.",
41
+ TRANSLATE_STORY: "Draft a reviewable translation of this story into the requested locale.",
42
+ EDITORIAL_SWEEP: "Run scheduled source-health, review-queue, and embargo watch sweep.",
43
+ ANALYZE_ARCHIVE_IMAGE: "Propose respectful archival description and candidate tags for this image.",
44
+ GENERATE_SUBTITLES: "Draft WebVTT subtitles from consented oral history testimony.",
45
+ SPEECH_TO_TEXT: "Draft speech-to-text transcript proposal for editorial review."
28
46
  }, F = {
29
47
  CITATION: "Citation",
30
48
  ARCHIVE_ITEM: "Artifact",
@@ -1 +1 @@
1
- {"version":3,"file":"AiContextPanel.js","names":["_Fragment","Fragment$1","AI_USE_CASE_LABELS","DEFAULT_PROMPTS","GROUNDING_KIND_LABELS","GenerateAiContextDialog","generate","useTcpGenerateAiContext","prompt","setPrompt","useState","useCase","run","setRun","reset","nextOpen","onOpenChange","submit","input","storyId","collectionId","oralHistoryId","created","onGenerated","error","describeError","statusNote","ResponsiveDialog","ResponsiveDialogContent","ResponsiveDialogHeader","ResponsiveDialogTitle","ResponsiveDialogDescription","AiRunCard","Label","Textarea","event","ResponsiveDialogFooter","Button","Sparkles","UNCERTAINTY_BADGE","review","useTcpReviewAiContext","notes","setNotes","expanded","setExpanded","defaultExpanded","decide","updated","onReviewed","notify","approved","GlassCard","StatusBadge","formatEnumLabel","formatRelativeTime","value","ref","canReview","isReviewableAiRun","Check","X","AiContextSection","useTheCulturePost","permissions","useSafePermissions","resolveAiContextPermissions","workspaceId","activeUseCase","setActiveUseCase","listable","canRead","runsQuery","useTcpAiContextRuns","canCreate","runs","pendingCount","FeatureGate","className","title","description","useCases","LoadingView","ErrorView","EmptyState","open","AiReviewQueue","AiReviewQueueContent","items"],"sources":["../../../src/theculturepost/components/AiContextPanel.tsx"],"sourcesContent":["/**\n * AiContextPanel — in-app UI for the citation-grounded AI context layer.\n * @module theculturepost/components\n *\n * Surfaces the `tcpGenerateAiContext` / `tcpReviewAiContext` / `tcpAiContextRuns`\n * operations (BOFF-4127) so editors can generate, review and adopt\n * citation-grounded answers without leaving the story, collection or oral\n * history screen (BOFF-5805).\n *\n * Floors stay server-side: generation is feature-flagged, grounding only ever\n * reads PUBLIC/COMMUNITY sources, and every run lands PENDING until a human\n * approves or rejects it. This UI only calls those operations and renders\n * their results — RBAC and access-tier denials surface as errors.\n */\n\nimport { useState } from 'react';\nimport { Check, Sparkles, X } from 'lucide-react';\nimport { FeatureGate } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { useSafePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport {\n Button,\n GlassCard,\n Label,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n Textarea,\n} from '@burdenoff/fe-libs/ui';\nimport { StatusBadge } from './StatusBadge';\nimport { EmptyState } from './EmptyState';\nimport { LoadingView, ErrorView } from './StateViews';\nimport { useTheCulturePost } from '../context';\nimport { useTcpAiContextRuns, useTcpGenerateAiContext, useTcpReviewAiContext } from '../hooks';\nimport { notify, describeError } from '../lib/toast';\nimport { isReviewableAiRun, resolveAiContextPermissions } from '../utils/aiContextPermissions';\nimport { formatEnumLabel, formatRelativeTime } from '../utils/formatters';\nimport type {\n TcpAgentRun,\n TcpAiGroundingKind,\n TcpAiUseCase,\n TcpGenerateAiContextInput,\n} from '../types';\n\n// ============================================================================\n// Per-use-case presentation metadata (labels + default prompts)\n// ============================================================================\n\nexport const AI_USE_CASE_LABELS: Record<TcpAiUseCase, string> = {\n SUMMARIZE_EVIDENCE: 'Summarise evidence',\n DRAFT_FRAMING_PROMPT: 'Draft framing',\n SUGGEST_RELATED_TRADITIONS: 'Find related traditions',\n TRANSCRIBE_ORAL_HISTORY: 'Clean up transcript',\n};\n\nconst DEFAULT_PROMPTS: Record<TcpAiUseCase, string> = {\n SUMMARIZE_EVIDENCE: 'What do the cited sources say about this story’s central claims?',\n DRAFT_FRAMING_PROMPT:\n 'Draft a short framing question that an editor could put to the cited sources.',\n SUGGEST_RELATED_TRADITIONS:\n 'Which traditions or practices in this collection relate to each other, and why?',\n TRANSCRIBE_ORAL_HISTORY:\n 'Clean up and format this transcript: fix punctuation and paragraph breaks, and mark speaker turns — do not add any content that is not in the original.',\n};\n\nconst GROUNDING_KIND_LABELS: Record<TcpAiGroundingKind, string> = {\n CITATION: 'Citation',\n ARCHIVE_ITEM: 'Artifact',\n ORAL_HISTORY: 'Oral history',\n};\n\n// ============================================================================\n// Generate dialog\n// ============================================================================\n\nexport interface GenerateAiContextDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Preselected use case. Locked to this single action. */\n useCase: TcpAiUseCase;\n /** Exactly one grounding scope, matching the svc input contract. */\n storyId?: string;\n collectionId?: string;\n oralHistoryId?: string;\n /** Whether the caller holds `theculturepost-ai-context:update` to review inline. */\n canReview?: boolean;\n onGenerated?: (run: TcpAgentRun) => void;\n}\n\nexport function GenerateAiContextDialog({\n open,\n onOpenChange,\n useCase,\n storyId,\n collectionId,\n oralHistoryId,\n canReview = true,\n onGenerated,\n}: GenerateAiContextDialogProps) {\n const generate = useTcpGenerateAiContext();\n const [prompt, setPrompt] = useState(() => DEFAULT_PROMPTS[useCase]);\n const [run, setRun] = useState<TcpAgentRun | null>(null);\n\n const reset = (nextOpen: boolean) => {\n if (!nextOpen) {\n setPrompt(DEFAULT_PROMPTS[useCase]);\n setRun(null);\n generate.reset();\n }\n onOpenChange(nextOpen);\n };\n\n const submit = async () => {\n const input: TcpGenerateAiContextInput = {\n useCase,\n prompt: prompt.trim(),\n storyId: storyId ?? null,\n collectionId: collectionId ?? null,\n oralHistoryId: oralHistoryId ?? null,\n };\n try {\n const created = await generate.mutateAsync(input);\n setRun(created);\n onGenerated?.(created);\n } catch (error) {\n notify.error('Generation failed', describeError(error));\n }\n };\n\n const statusNote =\n run?.reviewStatus === 'APPROVED'\n ? 'Run approved — recorded in the editorial log.'\n : run?.reviewStatus === 'REJECTED'\n ? 'Run rejected — kept on record.'\n : 'Run created — it is awaiting editorial review.';\n\n return (\n <ResponsiveDialog open={open} onOpenChange={reset}>\n <ResponsiveDialogContent className=\"sm:max-w-xl\">\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>{AI_USE_CASE_LABELS[useCase]}</ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n Runs on this product’s AI answer only from sources you can read (PUBLIC/COMMUNITY).\n Every run starts as pending editorial review — nothing is adopted automatically.\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n\n {run ? (\n <div className=\"flex flex-col gap-4\">\n <p className=\"text-sm text-text-secondary\">{statusNote}</p>\n <AiRunCard run={run} canReview={canReview} defaultExpanded onReviewed={setRun} />\n </div>\n ) : (\n <div className=\"flex flex-col gap-2\">\n <Label htmlFor=\"ai-context-prompt\">Your question or instruction</Label>\n <Textarea\n id=\"ai-context-prompt\"\n value={prompt}\n onChange={(event) => setPrompt(event.target.value)}\n rows={4}\n disabled={generate.isPending}\n />\n <p className=\"text-xs text-text-tertiary\">\n Combined server-side with the grounded sources — never sent to the model alone.\n </p>\n </div>\n )}\n\n <ResponsiveDialogFooter>\n {run ? (\n <Button onClick={() => reset(false)}>Done</Button>\n ) : (\n <>\n <Button variant=\"outline\" onClick={() => reset(false)} disabled={generate.isPending}>\n Cancel\n </Button>\n <Button onClick={submit} disabled={generate.isPending || !prompt.trim()}>\n <Sparkles className=\"mr-1.5 h-4 w-4\" aria-hidden=\"true\" />\n {generate.isPending ? 'Generating…' : 'Generate'}\n </Button>\n </>\n )}\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n );\n}\n\n// ============================================================================\n// Run card (list item + inline review)\n// ============================================================================\n\nconst UNCERTAINTY_BADGE: Record<string, 'success' | 'warning' | 'destructive'> = {\n LOW: 'success',\n MEDIUM: 'warning',\n HIGH: 'destructive',\n};\n\nexport interface AiRunCardProps {\n run: TcpAgentRun;\n canReview?: boolean;\n defaultExpanded?: boolean;\n onReviewed?: (updated: TcpAgentRun) => void;\n}\n\nexport function AiRunCard({\n run,\n canReview = true,\n defaultExpanded = false,\n onReviewed,\n}: AiRunCardProps) {\n const review = useTcpReviewAiContext();\n const [notes, setNotes] = useState('');\n const [expanded, setExpanded] = useState(defaultExpanded);\n\n const decide = async (approved: boolean) => {\n try {\n const updated = await review.mutateAsync({\n id: run.id,\n approved,\n reviewNotes: notes.trim() || undefined,\n });\n onReviewed?.(updated);\n notify.success(\n approved ? 'AI answer approved' : 'AI answer rejected',\n approved ? 'It is now marked as reviewed.' : 'The run stays on record as rejected.'\n );\n } catch (error) {\n notify.error('Review failed', describeError(error));\n }\n };\n\n return (\n <GlassCard treatment=\"plain\" className=\"flex flex-col gap-3 p-4\">\n <div className=\"flex flex-wrap items-center gap-1.5\">\n <StatusBadge status={run.useCase} />\n {run.status === 'FAILED' ? (\n <StatusBadge status=\"FAILED\" />\n ) : (\n <StatusBadge status={run.reviewStatus} />\n )}\n {run.uncertainty && (\n <span\n className={`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${\n UNCERTAINTY_BADGE[run.uncertainty] === 'success'\n ? 'bg-status-success-bg-subtle text-status-success-text'\n : UNCERTAINTY_BADGE[run.uncertainty] === 'destructive'\n ? 'bg-status-error-bg-subtle text-status-error-text'\n : 'bg-status-warning-bg-subtle text-status-warning-text'\n }`}\n >\n Uncertainty: {formatEnumLabel(run.uncertainty)}\n </span>\n )}\n <span className=\"ml-auto text-xs text-text-tertiary\">\n {formatRelativeTime(run.createdAt)}\n </span>\n </div>\n\n <p className=\"text-sm text-text-secondary\">\n <span className=\"font-medium text-text-primary\">Prompt: </span>\n {run.promptSummary}\n </p>\n\n {run.error && (\n <p className=\"rounded-lg bg-status-error-bg-subtle p-2 text-xs text-status-error-text\">\n {run.error}\n </p>\n )}\n\n {run.content && (\n <div>\n <button\n type=\"button\"\n onClick={() => setExpanded((value) => !value)}\n className=\"text-xs font-medium text-text-secondary underline-offset-2 hover:underline\"\n >\n {expanded ? 'Hide answer' : 'Show answer'}\n </button>\n {expanded && (\n <p className=\"mt-2 whitespace-pre-wrap rounded-lg bg-bg-sunken p-3 text-sm text-text-primary\">\n {run.content}\n </p>\n )}\n </div>\n )}\n\n {run.groundingRefs.length > 0 && (\n <div className=\"flex flex-col gap-1.5\">\n <p className=\"text-xs font-medium text-text-tertiary\">\n Grounded in ({run.groundingRefs.length} sources)\n </p>\n <ul className=\"flex flex-wrap gap-1.5\">\n {run.groundingRefs.map((ref) => (\n <li\n key={`${ref.kind}-${ref.refId}`}\n className=\"inline-flex max-w-full items-center gap-1 rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs text-text-secondary\"\n title={ref.title}\n >\n <span className=\"shrink-0 font-medium\">\n {GROUNDING_KIND_LABELS[ref.kind] ?? formatEnumLabel(ref.kind)}\n </span>\n <span className=\"truncate\">{ref.title}</span>\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {run.reviewStatus !== 'PENDING' && (run.reviewNotes || run.reviewedAt) && (\n <p className=\"text-xs text-text-tertiary\">\n {run.reviewStatus === 'APPROVED' ? 'Approved' : 'Rejected'}\n {run.reviewNotes ? ` — ${run.reviewNotes}` : ''}\n </p>\n )}\n\n {canReview && isReviewableAiRun(run) && (\n <div className=\"flex flex-col gap-2 border-t border-border-seam pt-3\">\n <Textarea\n value={notes}\n onChange={(event) => setNotes(event.target.value)}\n rows={2}\n placeholder=\"Review notes (optional)\"\n disabled={review.isPending}\n />\n <div className=\"flex gap-2\">\n <Button\n size=\"sm\"\n onClick={() => decide(true)}\n disabled={review.isPending}\n aria-label=\"Approve AI answer\"\n >\n <Check className=\"mr-1.5 h-4 w-4\" aria-hidden=\"true\" /> Approve\n </Button>\n <Button\n size=\"sm\"\n variant=\"outline\"\n onClick={() => decide(false)}\n disabled={review.isPending}\n aria-label=\"Reject AI answer\"\n >\n <X className=\"mr-1.5 h-4 w-4\" aria-hidden=\"true\" /> Reject\n </Button>\n </div>\n </div>\n )}\n </GlassCard>\n );\n}\n\n// ============================================================================\n// Section: action buttons + run list for one grounding scope\n// ============================================================================\n\nexport interface AiContextSectionProps {\n /** Story-scoped use cases (SUMMARIZE_EVIDENCE, DRAFT_FRAMING_PROMPT). */\n storyId?: string;\n /** Collection-scoped use cases (SUGGEST_RELATED_TRADITIONS). */\n collectionId?: string;\n /** Oral-history use case (TRANSCRIBE_ORAL_HISTORY) — action only, no run list\n * filter exists for oral histories server-side. */\n oralHistoryId?: string;\n useCases: TcpAiUseCase[];\n title?: string;\n description?: string;\n className?: string;\n}\n\nexport function AiContextSection({\n storyId,\n collectionId,\n oralHistoryId,\n useCases,\n title = 'AI assistant',\n description = 'Citation-grounded answers from sources you can read. Every answer waits for editorial review before adoption.',\n className,\n}: AiContextSectionProps) {\n const { workspaceId } = useTheCulturePost();\n const permissions = useSafePermissions();\n const { canRead, canCreate, canReview } = resolveAiContextPermissions(permissions, workspaceId);\n const [activeUseCase, setActiveUseCase] = useState<TcpAiUseCase | null>(null);\n // Runs are listable per story or collection; the svc has no oralHistoryId filter.\n const listable = Boolean(storyId || collectionId) && canRead;\n const runsQuery = useTcpAiContextRuns({\n storyId,\n collectionId,\n pagination: { limit: 10 },\n enabled: listable,\n });\n\n if (!canRead && !canCreate) {\n return null;\n }\n\n const runs = listable ? (runsQuery.data?.items ?? []) : [];\n const pendingCount = runs.filter(isReviewableAiRun).length;\n\n return (\n <FeatureGate flag=\"theculturepost.ai-context\" defaultValue fallback={null}>\n <GlassCard treatment=\"plain\" className={`flex flex-col gap-4 p-5 sm:p-6 ${className ?? ''}`}>\n <div className=\"flex flex-wrap items-start justify-between gap-3\">\n <div>\n <h2 className=\"flex items-center gap-2 font-display text-xl font-semibold text-text-primary\">\n <Sparkles className=\"h-5 w-5 text-accent\" aria-hidden=\"true\" /> {title}\n {pendingCount > 0 && (\n <span className=\"rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-xs font-medium text-status-warning-text\">\n {pendingCount} pending\n </span>\n )}\n </h2>\n <p className=\"mt-1 text-sm text-text-secondary\">{description}</p>\n </div>\n {canCreate && (\n <div className=\"flex flex-wrap gap-2\">\n {useCases.map((useCase) => (\n <Button key={useCase} variant=\"outline\" onClick={() => setActiveUseCase(useCase)}>\n <Sparkles className=\"mr-1.5 h-4 w-4\" aria-hidden=\"true\" />\n {AI_USE_CASE_LABELS[useCase]}\n </Button>\n ))}\n </div>\n )}\n </div>\n\n {listable &&\n (runsQuery.isLoading ? (\n <LoadingView label=\"Loading AI runs…\" />\n ) : runsQuery.isError ? (\n <ErrorView title=\"Could not load AI runs\" onRetry={() => runsQuery.refetch()} />\n ) : runs.length === 0 ? (\n <EmptyState\n icon={<Sparkles className=\"h-9 w-9\" />}\n title=\"No AI runs yet\"\n description={\n canCreate\n ? 'Run one of the actions above to draft a citation-grounded answer.'\n : 'No citation-grounded AI runs have been created for this scope yet.'\n }\n />\n ) : (\n <div className=\"flex flex-col gap-3\">\n {runs.map((run) => (\n <AiRunCard key={run.id} run={run} canReview={canReview} />\n ))}\n </div>\n ))}\n\n {activeUseCase && (\n <GenerateAiContextDialog\n open\n onOpenChange={(open) => {\n if (!open) setActiveUseCase(null);\n }}\n useCase={activeUseCase}\n storyId={storyId}\n collectionId={collectionId}\n oralHistoryId={oralHistoryId}\n canReview={canReview}\n />\n )}\n </GlassCard>\n </FeatureGate>\n );\n}\n\n// ============================================================================\n// Editorial review queue (workspace-wide, StoriesPage overview)\n// ============================================================================\n\nexport function AiReviewQueue({ className }: { className?: string }) {\n const { workspaceId } = useTheCulturePost();\n const permissions = useSafePermissions();\n const { canRead, canReview } = resolveAiContextPermissions(permissions, workspaceId);\n\n if (!canRead) {\n return null;\n }\n\n return (\n <FeatureGate flag=\"theculturepost.ai-context\" defaultValue fallback={null}>\n <AiReviewQueueContent className={className} canReview={canReview} />\n </FeatureGate>\n );\n}\n\nfunction AiReviewQueueContent({\n className,\n canReview,\n}: {\n className?: string;\n canReview: boolean;\n}) {\n const runsQuery = useTcpAiContextRuns({ pagination: { limit: 50 } });\n const items = (runsQuery.data?.items ?? []).filter(isReviewableAiRun);\n\n if (runsQuery.isLoading) {\n return <LoadingView label=\"Loading AI review queue…\" />;\n }\n if (runsQuery.isError) {\n return (\n <ErrorView title=\"Could not load the AI review queue\" onRetry={() => runsQuery.refetch()} />\n );\n }\n if (items.length === 0) {\n return null;\n }\n\n return (\n <GlassCard treatment=\"plain\" className={`flex flex-col gap-3 p-5 sm:p-6 ${className ?? ''}`}>\n <h2 className=\"flex items-center gap-2 font-display text-xl font-semibold text-text-primary\">\n <Sparkles className=\"h-5 w-5 text-accent\" aria-hidden=\"true\" /> AI review queue\n <span className=\"rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-xs font-medium text-status-warning-text\">\n {items.length} pending\n </span>\n </h2>\n <p className=\"text-sm text-text-secondary\">\n Generated answers awaiting an editorial decision, newest first. Approve or reject them here,\n or in place on the story or collection they belong to.\n </p>\n <div className=\"flex flex-col gap-3\">\n {items.slice(0, 5).map((run) => (\n <AiRunCard key={run.id} run={run} canReview={canReview} />\n ))}\n {items.length > 5 && (\n <p className=\"text-xs text-text-tertiary\">\n {items.length - 5} more pending — open the story or collection they belong to review\n them in place.\n </p>\n )}\n </div>\n </GlassCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkDA,IAAaE,IAAmD;CAC9D,oBAAoB;CACpB,sBAAsB;CACtB,4BAA4B;CAC5B,yBAAyB;AAC3B,GAEMC,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,OAAM;EAAqC,eAAeX,EAAU,QAAQ;CAAI,CAAA,IAG3FgB,EAAM,WAAW,IACZ,OAIP,kBAACpC,GAAD;EAAW,WAAU;EAAQ,WAAW,kCAAkC0B,KAAa;EAAvF,UAAA;GACE,kBAAC,MAAD;IAAI,WAAU;IAAd,UAAA;KACE,kBAACxC,GAAD;MAAU,WAAU;MAAsB,eAAY;KAAQ,CAAA;KAAC;KAC/D,kBAAC,QAAD;MAAM,WAAU;MAAhB,UAAA,CACGkD,EAAM,QAAO,UACV;;IACJ;;GACJ,kBAAC,KAAD;IAAG,WAAU;IAA8B,UAAA;GAGxC,CAAA;GACH,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACGA,EAAM,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,MACtB,kBAACxD,GAAD;KAA6B;KAAgB;IAAY,GAAzCpB,EAAI,EAAqC,CAC1D,GACA4E,EAAM,SAAS,KACd,kBAAC,KAAD;KAAG,WAAU;KAAb,UAAA,CACGA,EAAM,SAAS,GAAE,mFAEjB;IAEF,CAAA,CAAA;;EACI;;AAEf"}
1
+ {"version":3,"file":"AiContextPanel.js","names":["_Fragment","Fragment$1","AI_USE_CASE_LABELS","DEFAULT_PROMPTS","GROUNDING_KIND_LABELS","GenerateAiContextDialog","generate","useTcpGenerateAiContext","prompt","setPrompt","useState","useCase","run","setRun","reset","nextOpen","onOpenChange","submit","input","storyId","collectionId","oralHistoryId","created","onGenerated","error","describeError","statusNote","ResponsiveDialog","ResponsiveDialogContent","ResponsiveDialogHeader","ResponsiveDialogTitle","ResponsiveDialogDescription","AiRunCard","Label","Textarea","event","ResponsiveDialogFooter","Button","Sparkles","UNCERTAINTY_BADGE","review","useTcpReviewAiContext","notes","setNotes","expanded","setExpanded","defaultExpanded","decide","updated","onReviewed","notify","approved","GlassCard","StatusBadge","formatEnumLabel","formatRelativeTime","value","ref","canReview","isReviewableAiRun","Check","X","AiContextSection","useTheCulturePost","permissions","useSafePermissions","resolveAiContextPermissions","workspaceId","activeUseCase","setActiveUseCase","listable","canRead","runsQuery","useTcpAiContextRuns","canCreate","runs","pendingCount","FeatureGate","className","title","description","useCases","LoadingView","ErrorView","EmptyState","open","AiReviewQueue","AiReviewQueueContent","items"],"sources":["../../../src/theculturepost/components/AiContextPanel.tsx"],"sourcesContent":["/**\n * AiContextPanel — in-app UI for the citation-grounded AI context layer.\n * @module theculturepost/components\n *\n * Surfaces the `tcpGenerateAiContext` / `tcpReviewAiContext` / `tcpAiContextRuns`\n * operations (BOFF-4127) so editors can generate, review and adopt\n * citation-grounded answers without leaving the story, collection or oral\n * history screen (BOFF-5805).\n *\n * Floors stay server-side: generation is feature-flagged, grounding only ever\n * reads PUBLIC/COMMUNITY sources, and every run lands PENDING until a human\n * approves or rejects it. This UI only calls those operations and renders\n * their results — RBAC and access-tier denials surface as errors.\n */\n\nimport { useState } from 'react';\nimport { Check, Sparkles, X } from 'lucide-react';\nimport { FeatureGate } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { useSafePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport {\n Button,\n GlassCard,\n Label,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n Textarea,\n} from '@burdenoff/fe-libs/ui';\nimport { StatusBadge } from './StatusBadge';\nimport { EmptyState } from './EmptyState';\nimport { LoadingView, ErrorView } from './StateViews';\nimport { useTheCulturePost } from '../context';\nimport { useTcpAiContextRuns, useTcpGenerateAiContext, useTcpReviewAiContext } from '../hooks';\nimport { notify, describeError } from '../lib/toast';\nimport { isReviewableAiRun, resolveAiContextPermissions } from '../utils/aiContextPermissions';\nimport { formatEnumLabel, formatRelativeTime } from '../utils/formatters';\nimport type {\n TcpAgentRun,\n TcpAiGroundingKind,\n TcpAiUseCase,\n TcpGenerateAiContextInput,\n} from '../types';\n\n// ============================================================================\n// Per-use-case presentation metadata (labels + default prompts)\n// ============================================================================\n\nexport const AI_USE_CASE_LABELS: Record<TcpAiUseCase, string> = {\n SUMMARIZE_EVIDENCE: 'Summarise evidence',\n DRAFT_FRAMING_PROMPT: 'Draft framing',\n SUGGEST_RELATED_TRADITIONS: 'Find related traditions',\n TRANSCRIBE_ORAL_HISTORY: 'Clean up transcript',\n VERIFY_CITATION: 'Verify citation proposal',\n ASSESS_SOURCE_HEALTH: 'Assess source health',\n SENSITIVITY_FRAMING: 'Sensitivity framing review',\n EXPLAIN_TERM: 'Explain term',\n TRANSLATE_STORY: 'Translate story draft',\n EDITORIAL_SWEEP: 'Editorial sweep',\n ANALYZE_ARCHIVE_IMAGE: 'Analyze archive image',\n GENERATE_SUBTITLES: 'Generate subtitles',\n SPEECH_TO_TEXT: 'Speech-to-text transcript',\n};\n\nconst DEFAULT_PROMPTS: Record<TcpAiUseCase, string> = {\n SUMMARIZE_EVIDENCE: 'What do the cited sources say about this story’s central claims?',\n DRAFT_FRAMING_PROMPT:\n 'Draft a short framing question that an editor could put to the cited sources.',\n SUGGEST_RELATED_TRADITIONS:\n 'Which traditions or practices in this collection relate to each other, and why?',\n TRANSCRIBE_ORAL_HISTORY:\n 'Clean up and format this transcript: fix punctuation and paragraph breaks, and mark speaker turns — do not add any content that is not in the original.',\n VERIFY_CITATION: 'Propose a verification status grounded strictly in this citation and excerpt.',\n ASSESS_SOURCE_HEALTH: 'Assess reachability and strength of all citations on this story.',\n SENSITIVITY_FRAMING: 'Flag any framing concerns with respectful reframing suggestions.',\n EXPLAIN_TERM: 'Explain this term using only eligible workspace sources, or abstain.',\n TRANSLATE_STORY: 'Draft a reviewable translation of this story into the requested locale.',\n EDITORIAL_SWEEP: 'Run scheduled source-health, review-queue, and embargo watch sweep.',\n ANALYZE_ARCHIVE_IMAGE:\n 'Propose respectful archival description and candidate tags for this image.',\n GENERATE_SUBTITLES: 'Draft WebVTT subtitles from consented oral history testimony.',\n SPEECH_TO_TEXT: 'Draft speech-to-text transcript proposal for editorial review.',\n};\n\nconst GROUNDING_KIND_LABELS: Record<TcpAiGroundingKind, string> = {\n CITATION: 'Citation',\n ARCHIVE_ITEM: 'Artifact',\n ORAL_HISTORY: 'Oral history',\n};\n\n// ============================================================================\n// Generate dialog\n// ============================================================================\n\nexport interface GenerateAiContextDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Preselected use case. Locked to this single action. */\n useCase: TcpAiUseCase;\n /** Exactly one grounding scope, matching the svc input contract. */\n storyId?: string;\n collectionId?: string;\n oralHistoryId?: string;\n /** Whether the caller holds `theculturepost-ai-context:update` to review inline. */\n canReview?: boolean;\n onGenerated?: (run: TcpAgentRun) => void;\n}\n\nexport function GenerateAiContextDialog({\n open,\n onOpenChange,\n useCase,\n storyId,\n collectionId,\n oralHistoryId,\n canReview = true,\n onGenerated,\n}: GenerateAiContextDialogProps) {\n const generate = useTcpGenerateAiContext();\n const [prompt, setPrompt] = useState(() => DEFAULT_PROMPTS[useCase]);\n const [run, setRun] = useState<TcpAgentRun | null>(null);\n\n const reset = (nextOpen: boolean) => {\n if (!nextOpen) {\n setPrompt(DEFAULT_PROMPTS[useCase]);\n setRun(null);\n generate.reset();\n }\n onOpenChange(nextOpen);\n };\n\n const submit = async () => {\n const input: TcpGenerateAiContextInput = {\n useCase,\n prompt: prompt.trim(),\n storyId: storyId ?? null,\n collectionId: collectionId ?? null,\n oralHistoryId: oralHistoryId ?? null,\n };\n try {\n const created = await generate.mutateAsync(input);\n setRun(created);\n onGenerated?.(created);\n } catch (error) {\n notify.error('Generation failed', describeError(error));\n }\n };\n\n const statusNote =\n run?.reviewStatus === 'APPROVED'\n ? 'Run approved — recorded in the editorial log.'\n : run?.reviewStatus === 'REJECTED'\n ? 'Run rejected — kept on record.'\n : 'Run created — it is awaiting editorial review.';\n\n return (\n <ResponsiveDialog open={open} onOpenChange={reset}>\n <ResponsiveDialogContent className=\"sm:max-w-xl\">\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>{AI_USE_CASE_LABELS[useCase]}</ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n Runs on this product’s AI answer only from sources you can read (PUBLIC/COMMUNITY).\n Every run starts as pending editorial review — nothing is adopted automatically.\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n\n {run ? (\n <div className=\"flex flex-col gap-4\">\n <p className=\"text-sm text-text-secondary\">{statusNote}</p>\n <AiRunCard run={run} canReview={canReview} defaultExpanded onReviewed={setRun} />\n </div>\n ) : (\n <div className=\"flex flex-col gap-2\">\n <Label htmlFor=\"ai-context-prompt\">Your question or instruction</Label>\n <Textarea\n id=\"ai-context-prompt\"\n value={prompt}\n onChange={(event) => setPrompt(event.target.value)}\n rows={4}\n disabled={generate.isPending}\n />\n <p className=\"text-xs text-text-tertiary\">\n Combined server-side with the grounded sources — never sent to the model alone.\n </p>\n </div>\n )}\n\n <ResponsiveDialogFooter>\n {run ? (\n <Button onClick={() => reset(false)}>Done</Button>\n ) : (\n <>\n <Button variant=\"outline\" onClick={() => reset(false)} disabled={generate.isPending}>\n Cancel\n </Button>\n <Button onClick={submit} disabled={generate.isPending || !prompt.trim()}>\n <Sparkles className=\"mr-1.5 h-4 w-4\" aria-hidden=\"true\" />\n {generate.isPending ? 'Generating…' : 'Generate'}\n </Button>\n </>\n )}\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n );\n}\n\n// ============================================================================\n// Run card (list item + inline review)\n// ============================================================================\n\nconst UNCERTAINTY_BADGE: Record<string, 'success' | 'warning' | 'destructive'> = {\n LOW: 'success',\n MEDIUM: 'warning',\n HIGH: 'destructive',\n};\n\nexport interface AiRunCardProps {\n run: TcpAgentRun;\n canReview?: boolean;\n defaultExpanded?: boolean;\n onReviewed?: (updated: TcpAgentRun) => void;\n}\n\nexport function AiRunCard({\n run,\n canReview = true,\n defaultExpanded = false,\n onReviewed,\n}: AiRunCardProps) {\n const review = useTcpReviewAiContext();\n const [notes, setNotes] = useState('');\n const [expanded, setExpanded] = useState(defaultExpanded);\n\n const decide = async (approved: boolean) => {\n try {\n const updated = await review.mutateAsync({\n id: run.id,\n approved,\n reviewNotes: notes.trim() || undefined,\n });\n onReviewed?.(updated);\n notify.success(\n approved ? 'AI answer approved' : 'AI answer rejected',\n approved ? 'It is now marked as reviewed.' : 'The run stays on record as rejected.'\n );\n } catch (error) {\n notify.error('Review failed', describeError(error));\n }\n };\n\n return (\n <GlassCard treatment=\"plain\" className=\"flex flex-col gap-3 p-4\">\n <div className=\"flex flex-wrap items-center gap-1.5\">\n <StatusBadge status={run.useCase} />\n {run.status === 'FAILED' ? (\n <StatusBadge status=\"FAILED\" />\n ) : (\n <StatusBadge status={run.reviewStatus} />\n )}\n {run.uncertainty && (\n <span\n className={`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${\n UNCERTAINTY_BADGE[run.uncertainty] === 'success'\n ? 'bg-status-success-bg-subtle text-status-success-text'\n : UNCERTAINTY_BADGE[run.uncertainty] === 'destructive'\n ? 'bg-status-error-bg-subtle text-status-error-text'\n : 'bg-status-warning-bg-subtle text-status-warning-text'\n }`}\n >\n Uncertainty: {formatEnumLabel(run.uncertainty)}\n </span>\n )}\n <span className=\"ml-auto text-xs text-text-tertiary\">\n {formatRelativeTime(run.createdAt)}\n </span>\n </div>\n\n <p className=\"text-sm text-text-secondary\">\n <span className=\"font-medium text-text-primary\">Prompt: </span>\n {run.promptSummary}\n </p>\n\n {run.error && (\n <p className=\"rounded-lg bg-status-error-bg-subtle p-2 text-xs text-status-error-text\">\n {run.error}\n </p>\n )}\n\n {run.content && (\n <div>\n <button\n type=\"button\"\n onClick={() => setExpanded((value) => !value)}\n className=\"text-xs font-medium text-text-secondary underline-offset-2 hover:underline\"\n >\n {expanded ? 'Hide answer' : 'Show answer'}\n </button>\n {expanded && (\n <p className=\"mt-2 whitespace-pre-wrap rounded-lg bg-bg-sunken p-3 text-sm text-text-primary\">\n {run.content}\n </p>\n )}\n </div>\n )}\n\n {run.groundingRefs.length > 0 && (\n <div className=\"flex flex-col gap-1.5\">\n <p className=\"text-xs font-medium text-text-tertiary\">\n Grounded in ({run.groundingRefs.length} sources)\n </p>\n <ul className=\"flex flex-wrap gap-1.5\">\n {run.groundingRefs.map((ref) => (\n <li\n key={`${ref.kind}-${ref.refId}`}\n className=\"inline-flex max-w-full items-center gap-1 rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs text-text-secondary\"\n title={ref.title}\n >\n <span className=\"shrink-0 font-medium\">\n {GROUNDING_KIND_LABELS[ref.kind] ?? formatEnumLabel(ref.kind)}\n </span>\n <span className=\"truncate\">{ref.title}</span>\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {run.reviewStatus !== 'PENDING' && (run.reviewNotes || run.reviewedAt) && (\n <p className=\"text-xs text-text-tertiary\">\n {run.reviewStatus === 'APPROVED' ? 'Approved' : 'Rejected'}\n {run.reviewNotes ? ` — ${run.reviewNotes}` : ''}\n </p>\n )}\n\n {canReview && isReviewableAiRun(run) && (\n <div className=\"flex flex-col gap-2 border-t border-border-seam pt-3\">\n <Textarea\n value={notes}\n onChange={(event) => setNotes(event.target.value)}\n rows={2}\n placeholder=\"Review notes (optional)\"\n disabled={review.isPending}\n />\n <div className=\"flex gap-2\">\n <Button\n size=\"sm\"\n onClick={() => decide(true)}\n disabled={review.isPending}\n aria-label=\"Approve AI answer\"\n >\n <Check className=\"mr-1.5 h-4 w-4\" aria-hidden=\"true\" /> Approve\n </Button>\n <Button\n size=\"sm\"\n variant=\"outline\"\n onClick={() => decide(false)}\n disabled={review.isPending}\n aria-label=\"Reject AI answer\"\n >\n <X className=\"mr-1.5 h-4 w-4\" aria-hidden=\"true\" /> Reject\n </Button>\n </div>\n </div>\n )}\n </GlassCard>\n );\n}\n\n// ============================================================================\n// Section: action buttons + run list for one grounding scope\n// ============================================================================\n\nexport interface AiContextSectionProps {\n /** Story-scoped use cases (SUMMARIZE_EVIDENCE, DRAFT_FRAMING_PROMPT). */\n storyId?: string;\n /** Collection-scoped use cases (SUGGEST_RELATED_TRADITIONS). */\n collectionId?: string;\n /** Oral-history use case (TRANSCRIBE_ORAL_HISTORY) — action only, no run list\n * filter exists for oral histories server-side. */\n oralHistoryId?: string;\n useCases: TcpAiUseCase[];\n title?: string;\n description?: string;\n className?: string;\n}\n\nexport function AiContextSection({\n storyId,\n collectionId,\n oralHistoryId,\n useCases,\n title = 'AI assistant',\n description = 'Citation-grounded answers from sources you can read. Every answer waits for editorial review before adoption.',\n className,\n}: AiContextSectionProps) {\n const { workspaceId } = useTheCulturePost();\n const permissions = useSafePermissions();\n const { canRead, canCreate, canReview } = resolveAiContextPermissions(permissions, workspaceId);\n const [activeUseCase, setActiveUseCase] = useState<TcpAiUseCase | null>(null);\n // Runs are listable per story or collection; the svc has no oralHistoryId filter.\n const listable = Boolean(storyId || collectionId) && canRead;\n const runsQuery = useTcpAiContextRuns({\n storyId,\n collectionId,\n pagination: { limit: 10 },\n enabled: listable,\n });\n\n if (!canRead && !canCreate) {\n return null;\n }\n\n const runs = listable ? (runsQuery.data?.items ?? []) : [];\n const pendingCount = runs.filter(isReviewableAiRun).length;\n\n return (\n <FeatureGate flag=\"theculturepost.ai-context\" defaultValue fallback={null}>\n <GlassCard treatment=\"plain\" className={`flex flex-col gap-4 p-5 sm:p-6 ${className ?? ''}`}>\n <div className=\"flex flex-wrap items-start justify-between gap-3\">\n <div>\n <h2 className=\"flex items-center gap-2 font-display text-xl font-semibold text-text-primary\">\n <Sparkles className=\"h-5 w-5 text-accent\" aria-hidden=\"true\" /> {title}\n {pendingCount > 0 && (\n <span className=\"rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-xs font-medium text-status-warning-text\">\n {pendingCount} pending\n </span>\n )}\n </h2>\n <p className=\"mt-1 text-sm text-text-secondary\">{description}</p>\n </div>\n {canCreate && (\n <div className=\"flex flex-wrap gap-2\">\n {useCases.map((useCase) => (\n <Button key={useCase} variant=\"outline\" onClick={() => setActiveUseCase(useCase)}>\n <Sparkles className=\"mr-1.5 h-4 w-4\" aria-hidden=\"true\" />\n {AI_USE_CASE_LABELS[useCase]}\n </Button>\n ))}\n </div>\n )}\n </div>\n\n {listable &&\n (runsQuery.isLoading ? (\n <LoadingView label=\"Loading AI runs…\" />\n ) : runsQuery.isError ? (\n <ErrorView title=\"Could not load AI runs\" onRetry={() => runsQuery.refetch()} />\n ) : runs.length === 0 ? (\n <EmptyState\n icon={<Sparkles className=\"h-9 w-9\" />}\n title=\"No AI runs yet\"\n description={\n canCreate\n ? 'Run one of the actions above to draft a citation-grounded answer.'\n : 'No citation-grounded AI runs have been created for this scope yet.'\n }\n />\n ) : (\n <div className=\"flex flex-col gap-3\">\n {runs.map((run) => (\n <AiRunCard key={run.id} run={run} canReview={canReview} />\n ))}\n </div>\n ))}\n\n {activeUseCase && (\n <GenerateAiContextDialog\n open\n onOpenChange={(open) => {\n if (!open) setActiveUseCase(null);\n }}\n useCase={activeUseCase}\n storyId={storyId}\n collectionId={collectionId}\n oralHistoryId={oralHistoryId}\n canReview={canReview}\n />\n )}\n </GlassCard>\n </FeatureGate>\n );\n}\n\n// ============================================================================\n// Editorial review queue (workspace-wide, StoriesPage overview)\n// ============================================================================\n\nexport function AiReviewQueue({ className }: { className?: string }) {\n const { workspaceId } = useTheCulturePost();\n const permissions = useSafePermissions();\n const { canRead, canReview } = resolveAiContextPermissions(permissions, workspaceId);\n\n if (!canRead) {\n return null;\n }\n\n return (\n <FeatureGate flag=\"theculturepost.ai-context\" defaultValue fallback={null}>\n <AiReviewQueueContent className={className} canReview={canReview} />\n </FeatureGate>\n );\n}\n\nfunction AiReviewQueueContent({\n className,\n canReview,\n}: {\n className?: string;\n canReview: boolean;\n}) {\n const runsQuery = useTcpAiContextRuns({ pagination: { limit: 50 } });\n const items = (runsQuery.data?.items ?? []).filter(isReviewableAiRun);\n\n if (runsQuery.isLoading) {\n return <LoadingView label=\"Loading AI review queue…\" />;\n }\n if (runsQuery.isError) {\n return (\n <ErrorView title=\"Could not load the AI review queue\" onRetry={() => runsQuery.refetch()} />\n );\n }\n if (items.length === 0) {\n return null;\n }\n\n return (\n <GlassCard treatment=\"plain\" className={`flex flex-col gap-3 p-5 sm:p-6 ${className ?? ''}`}>\n <h2 className=\"flex items-center gap-2 font-display text-xl font-semibold text-text-primary\">\n <Sparkles className=\"h-5 w-5 text-accent\" aria-hidden=\"true\" /> AI review queue\n <span className=\"rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-xs font-medium text-status-warning-text\">\n {items.length} pending\n </span>\n </h2>\n <p className=\"text-sm text-text-secondary\">\n Generated answers awaiting an editorial decision, newest first. Approve or reject them here,\n or in place on the story or collection they belong to.\n </p>\n <div className=\"flex flex-col gap-3\">\n {items.slice(0, 5).map((run) => (\n <AiRunCard key={run.id} run={run} canReview={canReview} />\n ))}\n {items.length > 5 && (\n <p className=\"text-xs text-text-tertiary\">\n {items.length - 5} more pending — open the story or collection they belong to review\n them in place.\n </p>\n )}\n </div>\n </GlassCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkDA,IAAaE,IAAmD;CAC9D,oBAAoB;CACpB,sBAAsB;CACtB,4BAA4B;CAC5B,yBAAyB;CACzB,iBAAiB;CACjB,sBAAsB;CACtB,qBAAqB;CACrB,cAAc;CACd,iBAAiB;CACjB,iBAAiB;CACjB,uBAAuB;CACvB,oBAAoB;CACpB,gBAAgB;AAClB,GAEMC,IAAgD;CACpD,oBAAoB;CACpB,sBACE;CACF,4BACE;CACF,yBACE;CACF,iBAAiB;CACjB,sBAAsB;CACtB,qBAAqB;CACrB,cAAc;CACd,iBAAiB;CACjB,iBAAiB;CACjB,uBACE;CACF,oBAAoB;CACpB,gBAAgB;AAClB,GAEMC,IAA4D;CAChE,UAAU;CACV,cAAc;CACd,cAAc;AAChB;AAoBA,SAAgBC,EAAwB,EACtC,SACA,iBACA,YACA,YACA,iBACA,kBACA,eAAY,IACZ,kBAC+B;CAC/B,IAAMC,IAAWC,EAAwB,GACnC,CAACC,GAAQC,KAAaC,QAAeP,EAAgBQ,EAAQ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D;MAAM,WAAU;MAAhB,UAAA,CACGkD,EAAM,QAAO,UACV;;IACJ;;GACJ,kBAAC,KAAD;IAAG,WAAU;IAA8B,UAAA;GAGxC,CAAA;GACH,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACGA,EAAM,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,MACtB,kBAACxD,GAAD;KAA6B;KAAgB;IAAY,GAAzCpB,EAAI,EAAqC,CAC1D,GACA4E,EAAM,SAAS,KACd,kBAAC,KAAD;KAAG,WAAU;KAAb,UAAA,CACGA,EAAM,SAAS,GAAE,mFAEjB;IAEF,CAAA,CAAA;;EACI;;AAEf"}
@@ -0,0 +1,8 @@
1
+ import { TcpFollowTargetType } from '../types';
2
+ export interface FollowButtonProps {
3
+ targetType: TcpFollowTargetType;
4
+ targetId: string;
5
+ targetLabel?: string | null;
6
+ size?: 'sm' | 'default';
7
+ }
8
+ export declare function FollowButton({ targetType, targetId, targetLabel, size, }: FollowButtonProps): import('react').JSX.Element;
@@ -0,0 +1,41 @@
1
+ import { useTcpFollowTarget as e, useTcpMyFollows as t, useTcpUnfollowTarget as n } from "../hooks/useTcpApi.js";
2
+ import "../hooks/index.js";
3
+ import { describeError as r, notify as i } from "../lib/toast.js";
4
+ import { Heart as a, HeartOff as o } from "lucide-react";
5
+ import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
6
+ import { Button as u } from "@burdenoff/fe-libs/ui";
7
+ // src/theculturepost/components/FollowButton.tsx
8
+ function d({ targetType: d, targetId: f, targetLabel: p, size: m = "sm" }) {
9
+ let { data: h } = t(d), g = e(), _ = n(), v = f.trim(), y = !!h?.some((e) => e.targetType === d && e.targetId === v), b = g.isPending || _.isPending;
10
+ return /* @__PURE__ */ c(u, {
11
+ type: "button",
12
+ size: m,
13
+ variant: y ? "secondary" : "outline",
14
+ disabled: b || !v,
15
+ onClick: () => {
16
+ v && (y ? _.mutate({
17
+ targetType: d,
18
+ targetId: v
19
+ }, {
20
+ onSuccess: () => i.success(`Unfollowed ${p ?? v}`),
21
+ onError: (e) => i.error("Could not unfollow", r(e))
22
+ }) : g.mutate({
23
+ targetType: d,
24
+ targetId: v,
25
+ targetLabel: p ?? v
26
+ }, {
27
+ onSuccess: () => i.success(`Following ${p ?? v}`),
28
+ onError: (e) => i.error("Could not follow", r(e))
29
+ }));
30
+ },
31
+ "aria-pressed": y,
32
+ children: y ? /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(o, { className: "mr-1.5 h-3.5 w-3.5" }), "Following"] }) : /* @__PURE__ */ l(s, { children: [
33
+ /* @__PURE__ */ c(a, { className: "mr-1.5 h-3.5 w-3.5" }),
34
+ "Follow ",
35
+ p || d.toLowerCase()
36
+ ] })
37
+ });
38
+ }
39
+ export { d as FollowButton };
40
+
41
+ //# sourceMappingURL=FollowButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FollowButton.js","names":["_Fragment","FollowButton","follows","useTcpMyFollows","targetType","follow","useTcpFollowTarget","unfollow","useTcpUnfollowTarget","normalizedId","targetId","isFollowing","f","busy","Button","notify","targetLabel","describeError","err","Fragment","HeartOff","Heart"],"sources":["../../../src/theculturepost/components/FollowButton.tsx"],"sourcesContent":["/**\n * FollowButton — Follow / Unfollow a tradition, topic, or contributor (BOFF-5846).\n */\n\nimport { Heart, HeartOff } from 'lucide-react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { useTcpFollowTarget, useTcpMyFollows, useTcpUnfollowTarget } from '../hooks';\nimport { describeError, notify } from '../lib/toast';\nimport type { TcpFollowTargetType } from '../types';\n\nexport interface FollowButtonProps {\n targetType: TcpFollowTargetType;\n targetId: string;\n targetLabel?: string | null;\n size?: 'sm' | 'default';\n}\n\nexport function FollowButton({\n targetType,\n targetId,\n targetLabel,\n size = 'sm',\n}: FollowButtonProps) {\n const { data: follows } = useTcpMyFollows(targetType);\n const follow = useTcpFollowTarget();\n const unfollow = useTcpUnfollowTarget();\n\n const normalizedId = targetId.trim();\n const isFollowing = Boolean(\n follows?.some((f) => f.targetType === targetType && f.targetId === normalizedId)\n );\n const busy = follow.isPending || unfollow.isPending;\n\n const handleToggle = () => {\n if (!normalizedId) return;\n if (isFollowing) {\n unfollow.mutate(\n { targetType, targetId: normalizedId },\n {\n onSuccess: () => notify.success(`Unfollowed ${targetLabel ?? normalizedId}`),\n onError: (err) => notify.error('Could not unfollow', describeError(err)),\n }\n );\n return;\n }\n\n follow.mutate(\n { targetType, targetId: normalizedId, targetLabel: targetLabel ?? normalizedId },\n {\n onSuccess: () => notify.success(`Following ${targetLabel ?? normalizedId}`),\n onError: (err) => notify.error('Could not follow', describeError(err)),\n }\n );\n };\n\n return (\n <Button\n type=\"button\"\n size={size}\n variant={isFollowing ? 'secondary' : 'outline'}\n disabled={busy || !normalizedId}\n onClick={handleToggle}\n aria-pressed={isFollowing}\n >\n {isFollowing ? (\n <>\n <HeartOff className=\"mr-1.5 h-3.5 w-3.5\" />\n Following\n </>\n ) : (\n <>\n <Heart className=\"mr-1.5 h-3.5 w-3.5\" />\n Follow {targetLabel ? targetLabel : targetType.toLowerCase()}\n </>\n )}\n </Button>\n );\n}\n"],"mappings":";;;;;;;AAiBA,SAAgBC,EAAa,EAC3B,eACA,aACA,gBACA,UAAO,QACa;CACpB,IAAM,EAAE,MAAMC,MAAYC,EAAgBC,CAAU,GAC9CC,IAASC,EAAmB,GAC5BC,IAAWC,EAAqB,GAEhCC,IAAeC,EAAS,KAAK,GAC7BC,IAAc,EAClBT,GAAS,MAAM,MAAMU,EAAE,eAAeR,KAAcQ,EAAE,aAAaH,CAAY,GAE3EI,IAAOR,EAAO,aAAaE,EAAS;CAwB1C,OACE,kBAACO,GAAD;EACE,MAAK;EACC;EACN,SAASH,IAAc,cAAc;EACrC,UAAUE,KAAQ,CAACJ;EACnB,eA5BuB;GACzB,AAAKA,MACDE,IACFJ,EAAS,OACP;IAAE;IAAY,UAAUE;GAAa,GACrC;IACE,iBAAiBM,EAAO,QAAQ,cAAcC,KAAeP,GAAc;IAC3E,UAAU,MAAQM,EAAO,MAAM,sBAAsBE,EAAcC,CAAG,CAAC;GACzE,CACF,IAIFb,EAAO,OACL;IAAE;IAAY,UAAUI;IAAc,aAAaO,KAAeP;GAAa,GAC/E;IACE,iBAAiBM,EAAO,QAAQ,aAAaC,KAAeP,GAAc;IAC1E,UAAU,MAAQM,EAAO,MAAM,oBAAoBE,EAAcC,CAAG,CAAC;GACvE,CACF;EACF;EASI,gBAAcP;EAEb,UAAAA,IACC,kBAAAX,GAAA,EAAA,UAAA,CACE,kBAACoB,GAAD,EAAU,WAAU,qBAAsB,CAAA,GAAC,WAE3C,EAAA,CAAA,IAEF,kBAAApB,GAAA,EAAA,UAAA;GACE,kBAACqB,GAAD,EAAO,WAAU,qBAAsB,CAAA;GAAC;GAChCL,KAA4BZ,EAAW,YAAY;EAC3D,EAAA,CAAA;CAEE,CAAA;AAEZ"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * ReaderContextDrawer — Grounded Reader Context Layer (BOFF-3858, BOFF-4645).
3
+ *
4
+ * Mounted on `StoryDetailPage`:
5
+ * 1. Plain-language term explanation (`tcpExplainTerm`) — cite-or-abstain with
6
+ * grounding citations, disputed-source caveats, and explicit abstention state.
7
+ * 2. Translation & transliteration (`tcpTranslateStory`) — creates a PENDING
8
+ * editorial review draft in the target BCP-47 locale; never auto-publishes
9
+ * and keeps the original text one click away.
10
+ * 3. Grounded related reading (`tcpRecommendRelated`) — workspace stories,
11
+ * collections, and PUBLIC/COMMUNITY oral histories.
12
+ */
13
+ export declare function ReaderContextDrawer({ storyId }: {
14
+ storyId: string;
15
+ }): import('react').JSX.Element;
@@ -0,0 +1,223 @@
1
+ import { useTheCulturePost as e } from "../context/TheCulturePostContext.js";
2
+ import "../hooks/index.js";
3
+ import { useTcpExplainTerm as t, useTcpRecommendRelated as n, useTcpTranslateStory as r } from "../hooks/useTcpApi.js";
4
+ import "../context/index.js";
5
+ import { describeError as i, notify as a } from "../lib/toast.js";
6
+ import { useState as o } from "react";
7
+ import { BookMarked as s, Compass as c, Languages as l, Sparkles as u } from "lucide-react";
8
+ import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
9
+ import { Button as m, GlassCard as h, Input as g, Select as _, SelectContent as v, SelectItem as y, SelectTrigger as b, SelectValue as x } from "@burdenoff/fe-libs/ui";
10
+ // src/theculturepost/components/ReaderContextDrawer.tsx
11
+ var S = [
12
+ {
13
+ code: "es",
14
+ label: "Spanish (es)"
15
+ },
16
+ {
17
+ code: "hi",
18
+ label: "Hindi (hi)"
19
+ },
20
+ {
21
+ code: "ta",
22
+ label: "Tamil (ta)"
23
+ },
24
+ {
25
+ code: "ar",
26
+ label: "Arabic (ar)"
27
+ },
28
+ {
29
+ code: "zh-Hans",
30
+ label: "Chinese Simplified (zh-Hans)"
31
+ },
32
+ {
33
+ code: "fr",
34
+ label: "French (fr)"
35
+ }
36
+ ];
37
+ function C({ storyId: C }) {
38
+ let { navigateTo: w } = e(), T = t(), E = r(), D = n(C, 5), [O, k] = o(""), [A, j] = o(null), [M, N] = o("es"), [P, F] = o(!0), [I, L] = o(null), R = () => {
39
+ let e = O.trim();
40
+ e && T.mutate({
41
+ term: e,
42
+ storyId: C
43
+ }, {
44
+ onSuccess: (e) => j(e),
45
+ onError: (e) => a.error("Could not explain term", i(e))
46
+ });
47
+ }, z = () => {
48
+ E.mutate({
49
+ storyId: C,
50
+ targetLocale: M,
51
+ includeTransliteration: P
52
+ }, {
53
+ onSuccess: (e) => {
54
+ L(e), a.success("Translation draft saved for editorial review", `Pending review (${M}) — original story unchanged.`);
55
+ },
56
+ onError: (e) => a.error("Could not create translation draft", i(e))
57
+ });
58
+ }, B = D.data ?? [];
59
+ return /* @__PURE__ */ p(h, {
60
+ treatment: "plain",
61
+ className: "space-y-5 p-5",
62
+ "data-testid": "tcp-reader-context",
63
+ children: [
64
+ /* @__PURE__ */ p("div", {
65
+ className: "flex items-center gap-2 text-sm font-semibold text-text-primary",
66
+ children: [/* @__PURE__ */ f(u, { className: "h-4 w-4 text-accent" }), /* @__PURE__ */ f("span", { children: "Grounded Reader Context" })]
67
+ }),
68
+ /* @__PURE__ */ p("div", {
69
+ className: "space-y-2",
70
+ children: [
71
+ /* @__PURE__ */ f("label", {
72
+ htmlFor: "tcp-explain-term",
73
+ className: "text-xs font-medium text-text-secondary",
74
+ children: "Explain a cultural term or reference (cite-or-abstain)"
75
+ }),
76
+ /* @__PURE__ */ p("div", {
77
+ className: "flex gap-2",
78
+ children: [/* @__PURE__ */ f(g, {
79
+ id: "tcp-explain-term",
80
+ value: O,
81
+ onChange: (e) => k(e.target.value),
82
+ placeholder: "e.g. Sangam, Kolam, Waqf…",
83
+ onKeyDown: (e) => {
84
+ e.key === "Enter" && R();
85
+ }
86
+ }), /* @__PURE__ */ f(m, {
87
+ size: "sm",
88
+ onClick: R,
89
+ disabled: T.isPending || !O.trim(),
90
+ children: T.isPending ? "Checking…" : "Explain"
91
+ })]
92
+ }),
93
+ A && /* @__PURE__ */ p("div", {
94
+ className: "rounded-lg border border-border-subtle bg-bg-surface/70 p-3 text-xs space-y-2",
95
+ children: [A.abstained ? /* @__PURE__ */ p("p", {
96
+ className: "font-medium text-status-warning-text",
97
+ children: [
98
+ "Abstained:",
99
+ " ",
100
+ A.abstentionReason ?? "No eligible cited sources found in this workspace."
101
+ ]
102
+ }) : /* @__PURE__ */ p(d, { children: [
103
+ /* @__PURE__ */ f("p", {
104
+ className: "text-text-primary whitespace-pre-wrap",
105
+ children: A.explanation
106
+ }),
107
+ A.hasDisputedSources && A.caveat && /* @__PURE__ */ p("p", {
108
+ className: "text-status-warning-text",
109
+ children: ["Caveat: ", A.caveat]
110
+ }),
111
+ A.groundingRefs.length > 0 && /* @__PURE__ */ p("div", {
112
+ className: "flex flex-wrap gap-1.5 text-text-tertiary",
113
+ children: [/* @__PURE__ */ f("span", { children: "Sources:" }), A.groundingRefs.map((e) => /* @__PURE__ */ f("span", {
114
+ className: "rounded border border-border-subtle px-1.5 py-0.5 text-text-secondary",
115
+ children: e.title
116
+ }, `${e.kind}-${e.refId}`))]
117
+ })
118
+ ] }), /* @__PURE__ */ f("p", {
119
+ className: "text-[11px] text-text-tertiary",
120
+ children: A.disclaimer
121
+ })]
122
+ })
123
+ ]
124
+ }),
125
+ /* @__PURE__ */ p("div", {
126
+ className: "space-y-2 border-t border-border-subtle pt-4",
127
+ children: [
128
+ /* @__PURE__ */ p("div", {
129
+ className: "flex items-center gap-1.5 text-xs font-medium text-text-secondary",
130
+ children: [/* @__PURE__ */ f(l, { className: "h-3.5 w-3.5" }), /* @__PURE__ */ f("span", { children: "Draft translation & transliteration (editorial review required)" })]
131
+ }),
132
+ /* @__PURE__ */ p("div", {
133
+ className: "flex flex-wrap items-center gap-2",
134
+ children: [
135
+ /* @__PURE__ */ p(_, {
136
+ value: M,
137
+ onValueChange: N,
138
+ children: [/* @__PURE__ */ f(b, {
139
+ className: "w-52",
140
+ children: /* @__PURE__ */ f(x, { placeholder: "Choose language" })
141
+ }), /* @__PURE__ */ f(v, { children: S.map((e) => /* @__PURE__ */ f(y, {
142
+ value: e.code,
143
+ children: e.label
144
+ }, e.code)) })]
145
+ }),
146
+ /* @__PURE__ */ p("label", {
147
+ className: "flex items-center gap-1.5 text-xs text-text-secondary",
148
+ children: [/* @__PURE__ */ f("input", {
149
+ type: "checkbox",
150
+ checked: P,
151
+ onChange: (e) => F(e.target.checked)
152
+ }), /* @__PURE__ */ f("span", { children: "Include transliteration" })]
153
+ }),
154
+ /* @__PURE__ */ f(m, {
155
+ size: "sm",
156
+ variant: "outline",
157
+ onClick: z,
158
+ disabled: E.isPending,
159
+ children: E.isPending ? "Drafting…" : "Request draft"
160
+ })
161
+ ]
162
+ }),
163
+ I && /* @__PURE__ */ p("div", {
164
+ className: "rounded-lg border border-border-subtle bg-bg-surface/70 p-3 text-xs space-y-1.5",
165
+ children: [/* @__PURE__ */ p("div", {
166
+ className: "flex items-center justify-between gap-2",
167
+ children: [/* @__PURE__ */ p("span", {
168
+ className: "font-medium text-text-primary",
169
+ children: [
170
+ "Draft reading (",
171
+ M,
172
+ ") — ",
173
+ I.reviewStatus
174
+ ]
175
+ }), /* @__PURE__ */ f("button", {
176
+ type: "button",
177
+ className: "text-accent underline",
178
+ onClick: () => L(null),
179
+ children: "Hide draft (view original)"
180
+ })]
181
+ }), I.content && /* @__PURE__ */ f("p", {
182
+ className: "whitespace-pre-wrap text-text-secondary",
183
+ children: I.content
184
+ })]
185
+ })
186
+ ]
187
+ }),
188
+ B.length > 0 && /* @__PURE__ */ p("div", {
189
+ className: "space-y-2 border-t border-border-subtle pt-4",
190
+ children: [/* @__PURE__ */ p("div", {
191
+ className: "flex items-center gap-1.5 text-xs font-medium text-text-secondary",
192
+ children: [/* @__PURE__ */ f(c, { className: "h-3.5 w-3.5" }), /* @__PURE__ */ f("span", { children: "Related reading from this workspace" })]
193
+ }), /* @__PURE__ */ f("ul", {
194
+ className: "space-y-1.5",
195
+ children: B.map((e) => /* @__PURE__ */ f("li", { children: /* @__PURE__ */ p("button", {
196
+ type: "button",
197
+ onClick: () => {
198
+ e.kind === "STORY" ? w(`stories/${e.refId}`) : e.kind === "COLLECTION" ? w(`archive/collections/${e.refId}`) : w("archive");
199
+ },
200
+ className: "flex w-full items-start gap-2 rounded-lg border border-border-subtle px-3 py-2 text-left text-xs hover:bg-bg-surface",
201
+ children: [/* @__PURE__ */ f(s, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-accent" }), /* @__PURE__ */ p("div", {
202
+ className: "min-w-0 flex-1",
203
+ children: [/* @__PURE__ */ f("div", {
204
+ className: "font-medium text-text-primary",
205
+ children: e.title
206
+ }), /* @__PURE__ */ p("div", {
207
+ className: "text-text-tertiary",
208
+ children: [
209
+ e.kind,
210
+ " · ",
211
+ e.reason
212
+ ]
213
+ })]
214
+ })]
215
+ }) }, `${e.kind}-${e.refId}`))
216
+ })]
217
+ })
218
+ ]
219
+ });
220
+ }
221
+ export { C as ReaderContextDrawer };
222
+
223
+ //# sourceMappingURL=ReaderContextDrawer.js.map