@burdenoff/microfe-theculturepost 2026.1201.1 → 2026.1202.1

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.
@@ -9,12 +9,18 @@ export interface GenerateAiContextDialogProps {
9
9
  storyId?: string;
10
10
  collectionId?: string;
11
11
  oralHistoryId?: string;
12
+ /** Whether the caller holds `theculturepost-ai-context:update` to review inline. */
13
+ canReview?: boolean;
12
14
  onGenerated?: (run: TcpAgentRun) => void;
13
15
  }
14
- export declare function GenerateAiContextDialog({ open, onOpenChange, useCase, storyId, collectionId, oralHistoryId, onGenerated, }: GenerateAiContextDialogProps): import('react').JSX.Element;
15
- export declare function AiRunCard({ run }: {
16
+ export declare function GenerateAiContextDialog({ open, onOpenChange, useCase, storyId, collectionId, oralHistoryId, canReview, onGenerated, }: GenerateAiContextDialogProps): import('react').JSX.Element;
17
+ export interface AiRunCardProps {
16
18
  run: TcpAgentRun;
17
- }): import('react').JSX.Element;
19
+ canReview?: boolean;
20
+ defaultExpanded?: boolean;
21
+ onReviewed?: (updated: TcpAgentRun) => void;
22
+ }
23
+ export declare function AiRunCard({ run, canReview, defaultExpanded, onReviewed, }: AiRunCardProps): import('react').JSX.Element;
18
24
  export interface AiContextSectionProps {
19
25
  /** Story-scoped use cases (SUMMARIZE_EVIDENCE, DRAFT_FRAMING_PROMPT). */
20
26
  storyId?: string;
@@ -28,7 +34,7 @@ export interface AiContextSectionProps {
28
34
  description?: string;
29
35
  className?: string;
30
36
  }
31
- export declare function AiContextSection({ storyId, collectionId, oralHistoryId, useCases, title, description, className, }: AiContextSectionProps): import('react').JSX.Element;
37
+ export declare function AiContextSection({ storyId, collectionId, oralHistoryId, useCases, title, description, className, }: AiContextSectionProps): import('react').JSX.Element | null;
32
38
  export declare function AiReviewQueue({ className }: {
33
39
  className?: string;
34
- }): import('react').JSX.Element;
40
+ }): import('react').JSX.Element | null;
@@ -1,213 +1,222 @@
1
- import { StatusBadge as e } from "./StatusBadge.js";
2
- import { EmptyState as t } from "./EmptyState.js";
3
- import { ErrorView as n, LoadingView as r } from "./StateViews.js";
4
- import { useTcpAiContextRuns as i, useTcpGenerateAiContext as a, useTcpReviewAiContext as o } from "../hooks/useTcpApi.js";
1
+ import { useTheCulturePost as e } from "../context/TheCulturePostContext.js";
2
+ import { StatusBadge as t } from "./StatusBadge.js";
3
+ import { EmptyState as n } from "./EmptyState.js";
4
+ import { ErrorView as r, LoadingView as i } from "./StateViews.js";
5
+ import "../context/index.js";
6
+ import { useTcpAiContextRuns as a, useTcpGenerateAiContext as o, useTcpReviewAiContext as s } from "../hooks/useTcpApi.js";
5
7
  import "../hooks/index.js";
6
- import { describeError as s, notify as c } from "../lib/toast.js";
7
- import { formatEnumLabel as l, formatRelativeTime as u } from "../utils/formatters.js";
8
- import { useState as d } from "react";
9
- import { FeatureGate as f } from "@burdenoff/fe-libs/shared/feature-flags";
10
- import { Check as p, Sparkles as m, X as h } from "lucide-react";
11
- import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
12
- import { Button as y, GlassCard as b, Label as x, ResponsiveDialog as S, ResponsiveDialogContent as C, ResponsiveDialogDescription as w, ResponsiveDialogFooter as T, ResponsiveDialogHeader as E, ResponsiveDialogTitle as D, Textarea as O } from "@burdenoff/fe-libs/ui";
8
+ import { describeError as c, notify as l } from "../lib/toast.js";
9
+ import { isReviewableAiRun as u, resolveAiContextPermissions as d } from "../utils/aiContextPermissions.js";
10
+ import { formatEnumLabel as f, formatRelativeTime as p } from "../utils/formatters.js";
11
+ import { useState as m } from "react";
12
+ import { FeatureGate as h } from "@burdenoff/fe-libs/shared/feature-flags";
13
+ import { Check as g, Sparkles as _, X as v } from "lucide-react";
14
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
15
+ import { Button as S, GlassCard as C, Label as w, ResponsiveDialog as T, ResponsiveDialogContent as E, ResponsiveDialogDescription as D, ResponsiveDialogFooter as O, ResponsiveDialogHeader as k, ResponsiveDialogTitle as A, Textarea as j } from "@burdenoff/fe-libs/ui";
16
+ import { useSafePermissions as M } from "@burdenoff/fe-libs/shared/providers/shell";
13
17
  // src/theculturepost/components/AiContextPanel.tsx
14
- var k = {
18
+ var N = {
15
19
  SUMMARIZE_EVIDENCE: "Summarise evidence",
16
20
  DRAFT_FRAMING_PROMPT: "Draft framing",
17
21
  SUGGEST_RELATED_TRADITIONS: "Find related traditions",
18
22
  TRANSCRIBE_ORAL_HISTORY: "Clean up transcript"
19
- }, A = {
23
+ }, P = {
20
24
  SUMMARIZE_EVIDENCE: "What do the cited sources say about this story’s central claims?",
21
25
  DRAFT_FRAMING_PROMPT: "Draft a short framing question that an editor could put to the cited sources.",
22
26
  SUGGEST_RELATED_TRADITIONS: "Which traditions or practices in this collection relate to each other, and why?",
23
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."
24
- }, j = {
28
+ }, F = {
25
29
  CITATION: "Citation",
26
30
  ARCHIVE_ITEM: "Artifact",
27
31
  ORAL_HISTORY: "Oral history"
28
- }, M = (e) => e.reviewStatus === "PENDING";
29
- function N({ open: e, onOpenChange: t, useCase: n, storyId: r, collectionId: i, oralHistoryId: o, onGenerated: l }) {
30
- let u = a(), [f, p] = d(() => A[n]), [h, b] = d(null), j = (e) => {
31
- e || (p(A[n]), b(null), u.reset()), t(e);
32
- };
33
- return /* @__PURE__ */ _(S, {
32
+ };
33
+ function I({ open: e, onOpenChange: t, useCase: n, storyId: r, collectionId: i, oralHistoryId: a, canReview: s = !0, onGenerated: u }) {
34
+ let d = o(), [f, p] = m(() => P[n]), [h, g] = m(null), v = (e) => {
35
+ e || (p(P[n]), g(null), d.reset()), t(e);
36
+ }, C = async () => {
37
+ let e = {
38
+ useCase: n,
39
+ prompt: f.trim(),
40
+ storyId: r ?? null,
41
+ collectionId: i ?? null,
42
+ oralHistoryId: a ?? null
43
+ };
44
+ try {
45
+ let t = await d.mutateAsync(e);
46
+ g(t), u?.(t);
47
+ } catch (e) {
48
+ l.error("Generation failed", c(e));
49
+ }
50
+ }, M = h?.reviewStatus === "APPROVED" ? "Run approved — recorded in the editorial log." : h?.reviewStatus === "REJECTED" ? "Run rejected — kept on record." : "Run created — it is awaiting editorial review.";
51
+ return /* @__PURE__ */ b(T, {
34
52
  open: e,
35
- onOpenChange: j,
36
- children: /* @__PURE__ */ v(C, {
53
+ onOpenChange: v,
54
+ children: /* @__PURE__ */ x(E, {
37
55
  className: "sm:max-w-xl",
38
56
  children: [
39
- /* @__PURE__ */ v(E, { children: [/* @__PURE__ */ _(D, { children: k[n] }), /* @__PURE__ */ _(w, { children: "Runs on this product’s AI answer only from sources you can read (PUBLIC/COMMUNITY). Every run starts as pending editorial review — nothing is adopted automatically." })] }),
40
- h ? /* @__PURE__ */ v("div", {
57
+ /* @__PURE__ */ x(k, { children: [/* @__PURE__ */ b(A, { children: N[n] }), /* @__PURE__ */ b(D, { children: "Runs on this product’s AI answer only from sources you can read (PUBLIC/COMMUNITY). Every run starts as pending editorial review — nothing is adopted automatically." })] }),
58
+ h ? /* @__PURE__ */ x("div", {
41
59
  className: "flex flex-col gap-4",
42
- children: [/* @__PURE__ */ _("p", {
60
+ children: [/* @__PURE__ */ b("p", {
43
61
  className: "text-sm text-text-secondary",
44
- children: "Run created — it is awaiting editorial review."
45
- }), /* @__PURE__ */ _(F, { run: h })]
46
- }) : /* @__PURE__ */ v("div", {
62
+ children: M
63
+ }), /* @__PURE__ */ b(R, {
64
+ run: h,
65
+ canReview: s,
66
+ defaultExpanded: !0,
67
+ onReviewed: g
68
+ })]
69
+ }) : /* @__PURE__ */ x("div", {
47
70
  className: "flex flex-col gap-2",
48
71
  children: [
49
- /* @__PURE__ */ _(x, {
72
+ /* @__PURE__ */ b(w, {
50
73
  htmlFor: "ai-context-prompt",
51
74
  children: "Your question or instruction"
52
75
  }),
53
- /* @__PURE__ */ _(O, {
76
+ /* @__PURE__ */ b(j, {
54
77
  id: "ai-context-prompt",
55
78
  value: f,
56
79
  onChange: (e) => p(e.target.value),
57
80
  rows: 4,
58
- disabled: u.isPending
81
+ disabled: d.isPending
59
82
  }),
60
- /* @__PURE__ */ _("p", {
83
+ /* @__PURE__ */ b("p", {
61
84
  className: "text-xs text-text-tertiary",
62
85
  children: "Combined server-side with the grounded sources — never sent to the model alone."
63
86
  })
64
87
  ]
65
88
  }),
66
- /* @__PURE__ */ _(T, { children: h ? /* @__PURE__ */ _(y, {
67
- onClick: () => j(!1),
89
+ /* @__PURE__ */ b(O, { children: h ? /* @__PURE__ */ b(S, {
90
+ onClick: () => v(!1),
68
91
  children: "Done"
69
- }) : /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ _(y, {
92
+ }) : /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b(S, {
70
93
  variant: "outline",
71
- onClick: () => j(!1),
72
- disabled: u.isPending,
94
+ onClick: () => v(!1),
95
+ disabled: d.isPending,
73
96
  children: "Cancel"
74
- }), /* @__PURE__ */ v(y, {
75
- onClick: async () => {
76
- let e = {
77
- useCase: n,
78
- prompt: f.trim(),
79
- storyId: r ?? null,
80
- collectionId: i ?? null,
81
- oralHistoryId: o ?? null
82
- };
83
- try {
84
- let t = await u.mutateAsync(e);
85
- b(t), l?.(t);
86
- } catch (e) {
87
- c.error("Generation failed", s(e));
88
- }
89
- },
90
- disabled: u.isPending || !f.trim(),
91
- children: [/* @__PURE__ */ _(m, {
97
+ }), /* @__PURE__ */ x(S, {
98
+ onClick: C,
99
+ disabled: d.isPending || !f.trim(),
100
+ children: [/* @__PURE__ */ b(_, {
92
101
  className: "mr-1.5 h-4 w-4",
93
102
  "aria-hidden": "true"
94
- }), u.isPending ? "Generating…" : "Generate"]
103
+ }), d.isPending ? "Generating…" : "Generate"]
95
104
  })] }) })
96
105
  ]
97
106
  })
98
107
  });
99
108
  }
100
- var P = {
109
+ var L = {
101
110
  LOW: "success",
102
111
  MEDIUM: "warning",
103
112
  HIGH: "destructive"
104
113
  };
105
- function F({ run: t }) {
106
- let n = o(), [r, i] = d(""), [a, f] = d(!1), m = async (e) => {
114
+ function R({ run: e, canReview: n = !0, defaultExpanded: r = !1, onReviewed: i }) {
115
+ let a = s(), [o, d] = m(""), [h, _] = m(r), y = async (t) => {
107
116
  try {
108
- await n.mutateAsync({
109
- id: t.id,
110
- approved: e,
111
- reviewNotes: r.trim() || void 0
112
- }), c.success(e ? "AI answer approved" : "AI answer rejected", e ? "It is now marked as reviewed." : "The run stays on record as rejected.");
117
+ let n = await a.mutateAsync({
118
+ id: e.id,
119
+ approved: t,
120
+ reviewNotes: o.trim() || void 0
121
+ });
122
+ i?.(n), l.success(t ? "AI answer approved" : "AI answer rejected", t ? "It is now marked as reviewed." : "The run stays on record as rejected.");
113
123
  } catch (e) {
114
- c.error("Review failed", s(e));
124
+ l.error("Review failed", c(e));
115
125
  }
116
126
  };
117
- return /* @__PURE__ */ v(b, {
127
+ return /* @__PURE__ */ x(C, {
118
128
  treatment: "plain",
119
129
  className: "flex flex-col gap-3 p-4",
120
130
  children: [
121
- /* @__PURE__ */ v("div", {
131
+ /* @__PURE__ */ x("div", {
122
132
  className: "flex flex-wrap items-center gap-1.5",
123
133
  children: [
124
- /* @__PURE__ */ _(e, { status: t.useCase }),
125
- /* @__PURE__ */ _(e, { status: t.reviewStatus }),
126
- t.status === "FAILED" && /* @__PURE__ */ _(e, { status: "FAILED" }),
127
- t.uncertainty && /* @__PURE__ */ v("span", {
128
- className: `inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${P[t.uncertainty] === "success" ? "bg-status-success-bg-subtle text-status-success-text" : P[t.uncertainty] === "destructive" ? "bg-status-error-bg-subtle text-status-error-text" : "bg-status-warning-bg-subtle text-status-warning-text"}`,
129
- children: ["Uncertainty: ", l(t.uncertainty)]
134
+ /* @__PURE__ */ b(t, { status: e.useCase }),
135
+ e.status === "FAILED" ? /* @__PURE__ */ b(t, { status: "FAILED" }) : /* @__PURE__ */ b(t, { status: e.reviewStatus }),
136
+ e.uncertainty && /* @__PURE__ */ x("span", {
137
+ className: `inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${L[e.uncertainty] === "success" ? "bg-status-success-bg-subtle text-status-success-text" : L[e.uncertainty] === "destructive" ? "bg-status-error-bg-subtle text-status-error-text" : "bg-status-warning-bg-subtle text-status-warning-text"}`,
138
+ children: ["Uncertainty: ", f(e.uncertainty)]
130
139
  }),
131
- /* @__PURE__ */ _("span", {
140
+ /* @__PURE__ */ b("span", {
132
141
  className: "ml-auto text-xs text-text-tertiary",
133
- children: u(t.createdAt)
142
+ children: p(e.createdAt)
134
143
  })
135
144
  ]
136
145
  }),
137
- /* @__PURE__ */ v("p", {
146
+ /* @__PURE__ */ x("p", {
138
147
  className: "text-sm text-text-secondary",
139
- children: [/* @__PURE__ */ _("span", {
148
+ children: [/* @__PURE__ */ b("span", {
140
149
  className: "font-medium text-text-primary",
141
150
  children: "Prompt: "
142
- }), t.promptSummary]
151
+ }), e.promptSummary]
143
152
  }),
144
- t.error && /* @__PURE__ */ _("p", {
153
+ e.error && /* @__PURE__ */ b("p", {
145
154
  className: "rounded-lg bg-status-error-bg-subtle p-2 text-xs text-status-error-text",
146
- children: t.error
155
+ children: e.error
147
156
  }),
148
- t.content && /* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("button", {
157
+ e.content && /* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("button", {
149
158
  type: "button",
150
- onClick: () => f((e) => !e),
159
+ onClick: () => _((e) => !e),
151
160
  className: "text-xs font-medium text-text-secondary underline-offset-2 hover:underline",
152
- children: a ? "Hide answer" : "Show answer"
153
- }), a && /* @__PURE__ */ _("p", {
161
+ children: h ? "Hide answer" : "Show answer"
162
+ }), h && /* @__PURE__ */ b("p", {
154
163
  className: "mt-2 whitespace-pre-wrap rounded-lg bg-bg-sunken p-3 text-sm text-text-primary",
155
- children: t.content
164
+ children: e.content
156
165
  })] }),
157
- t.groundingRefs.length > 0 && /* @__PURE__ */ v("div", {
166
+ e.groundingRefs.length > 0 && /* @__PURE__ */ x("div", {
158
167
  className: "flex flex-col gap-1.5",
159
- children: [/* @__PURE__ */ v("p", {
168
+ children: [/* @__PURE__ */ x("p", {
160
169
  className: "text-xs font-medium text-text-tertiary",
161
170
  children: [
162
171
  "Grounded in (",
163
- t.groundingRefs.length,
172
+ e.groundingRefs.length,
164
173
  " sources)"
165
174
  ]
166
- }), /* @__PURE__ */ _("ul", {
175
+ }), /* @__PURE__ */ b("ul", {
167
176
  className: "flex flex-wrap gap-1.5",
168
- children: t.groundingRefs.map((e) => /* @__PURE__ */ v("li", {
177
+ children: e.groundingRefs.map((e) => /* @__PURE__ */ x("li", {
169
178
  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",
170
179
  title: e.title,
171
- children: [/* @__PURE__ */ _("span", {
180
+ children: [/* @__PURE__ */ b("span", {
172
181
  className: "shrink-0 font-medium",
173
- children: j[e.kind] ?? l(e.kind)
174
- }), /* @__PURE__ */ _("span", {
182
+ children: F[e.kind] ?? f(e.kind)
183
+ }), /* @__PURE__ */ b("span", {
175
184
  className: "truncate",
176
185
  children: e.title
177
186
  })]
178
187
  }, `${e.kind}-${e.refId}`))
179
188
  })]
180
189
  }),
181
- t.reviewStatus !== "PENDING" && (t.reviewNotes || t.reviewedAt) && /* @__PURE__ */ v("p", {
190
+ e.reviewStatus !== "PENDING" && (e.reviewNotes || e.reviewedAt) && /* @__PURE__ */ x("p", {
182
191
  className: "text-xs text-text-tertiary",
183
- children: [t.reviewStatus === "APPROVED" ? "Approved" : "Rejected", t.reviewNotes ? ` — ${t.reviewNotes}` : ""]
192
+ children: [e.reviewStatus === "APPROVED" ? "Approved" : "Rejected", e.reviewNotes ? ` — ${e.reviewNotes}` : ""]
184
193
  }),
185
- M(t) && /* @__PURE__ */ v("div", {
194
+ n && u(e) && /* @__PURE__ */ x("div", {
186
195
  className: "flex flex-col gap-2 border-t border-border-seam pt-3",
187
- children: [/* @__PURE__ */ _(O, {
188
- value: r,
189
- onChange: (e) => i(e.target.value),
196
+ children: [/* @__PURE__ */ b(j, {
197
+ value: o,
198
+ onChange: (e) => d(e.target.value),
190
199
  rows: 2,
191
200
  placeholder: "Review notes (optional)",
192
- disabled: n.isPending
193
- }), /* @__PURE__ */ v("div", {
201
+ disabled: a.isPending
202
+ }), /* @__PURE__ */ x("div", {
194
203
  className: "flex gap-2",
195
- children: [/* @__PURE__ */ v(y, {
204
+ children: [/* @__PURE__ */ x(S, {
196
205
  size: "sm",
197
- onClick: () => m(!0),
198
- disabled: n.isPending,
206
+ onClick: () => y(!0),
207
+ disabled: a.isPending,
199
208
  "aria-label": "Approve AI answer",
200
- children: [/* @__PURE__ */ _(p, {
209
+ children: [/* @__PURE__ */ b(g, {
201
210
  className: "mr-1.5 h-4 w-4",
202
211
  "aria-hidden": "true"
203
212
  }), " Approve"]
204
- }), /* @__PURE__ */ v(y, {
213
+ }), /* @__PURE__ */ x(S, {
205
214
  size: "sm",
206
215
  variant: "outline",
207
- onClick: () => m(!1),
208
- disabled: n.isPending,
216
+ onClick: () => y(!1),
217
+ disabled: a.isPending,
209
218
  "aria-label": "Reject AI answer",
210
- children: [/* @__PURE__ */ _(h, {
219
+ children: [/* @__PURE__ */ b(v, {
211
220
  className: "mr-1.5 h-4 w-4",
212
221
  "aria-hidden": "true"
213
222
  }), " Reject"]
@@ -217,122 +226,135 @@ function F({ run: t }) {
217
226
  ]
218
227
  });
219
228
  }
220
- function I({ storyId: e, collectionId: a, oralHistoryId: o, useCases: s, title: c = "AI assistant", description: l = "Citation-grounded answers from sources you can read. Every answer waits for editorial review before adoption.", className: u }) {
221
- let [p, h] = d(null), g = !!(e || a), x = i({
222
- storyId: e,
223
- collectionId: a,
229
+ function z({ storyId: t, collectionId: o, oralHistoryId: s, useCases: c, title: l = "AI assistant", description: f = "Citation-grounded answers from sources you can read. Every answer waits for editorial review before adoption.", className: p }) {
230
+ let { workspaceId: g } = e(), v = M(), { canRead: y, canCreate: w, canReview: T } = d(v, g), [E, D] = m(null), O = !!(t || o) && y, k = a({
231
+ storyId: t,
232
+ collectionId: o,
224
233
  pagination: { limit: 10 },
225
- enabled: g
226
- }), S = g ? x.data?.items ?? [] : [], C = S.filter(M).length;
227
- return /* @__PURE__ */ _(f, {
234
+ enabled: O
235
+ });
236
+ if (!y && !w) return null;
237
+ let A = O ? k.data?.items ?? [] : [], j = A.filter(u).length;
238
+ return /* @__PURE__ */ b(h, {
228
239
  flag: "theculturepost.ai-context",
229
240
  defaultValue: !0,
230
241
  fallback: null,
231
- children: /* @__PURE__ */ v(b, {
242
+ children: /* @__PURE__ */ x(C, {
232
243
  treatment: "plain",
233
- className: `flex flex-col gap-4 p-5 sm:p-6 ${u ?? ""}`,
244
+ className: `flex flex-col gap-4 p-5 sm:p-6 ${p ?? ""}`,
234
245
  children: [
235
- /* @__PURE__ */ v("div", {
246
+ /* @__PURE__ */ x("div", {
236
247
  className: "flex flex-wrap items-start justify-between gap-3",
237
- children: [/* @__PURE__ */ v("div", { children: [/* @__PURE__ */ v("h2", {
248
+ children: [/* @__PURE__ */ x("div", { children: [/* @__PURE__ */ x("h2", {
238
249
  className: "flex items-center gap-2 font-display text-xl font-semibold text-text-primary",
239
250
  children: [
240
- /* @__PURE__ */ _(m, {
251
+ /* @__PURE__ */ b(_, {
241
252
  className: "h-5 w-5 text-accent",
242
253
  "aria-hidden": "true"
243
254
  }),
244
255
  " ",
245
- c,
246
- C > 0 && /* @__PURE__ */ v("span", {
256
+ l,
257
+ j > 0 && /* @__PURE__ */ x("span", {
247
258
  className: "rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-xs font-medium text-status-warning-text",
248
- children: [C, " pending"]
259
+ children: [j, " pending"]
249
260
  })
250
261
  ]
251
- }), /* @__PURE__ */ _("p", {
262
+ }), /* @__PURE__ */ b("p", {
252
263
  className: "mt-1 text-sm text-text-secondary",
253
- children: l
254
- })] }), /* @__PURE__ */ _("div", {
264
+ children: f
265
+ })] }), w && /* @__PURE__ */ b("div", {
255
266
  className: "flex flex-wrap gap-2",
256
- children: s.map((e) => /* @__PURE__ */ v(y, {
267
+ children: c.map((e) => /* @__PURE__ */ x(S, {
257
268
  variant: "outline",
258
- onClick: () => h(e),
259
- children: [/* @__PURE__ */ _(m, {
269
+ onClick: () => D(e),
270
+ children: [/* @__PURE__ */ b(_, {
260
271
  className: "mr-1.5 h-4 w-4",
261
272
  "aria-hidden": "true"
262
- }), k[e]]
273
+ }), N[e]]
263
274
  }, e))
264
275
  })]
265
276
  }),
266
- g && (x.isLoading ? /* @__PURE__ */ _(r, { label: "Loading AI runs…" }) : x.isError ? /* @__PURE__ */ _(n, {
277
+ O && (k.isLoading ? /* @__PURE__ */ b(i, { label: "Loading AI runs…" }) : k.isError ? /* @__PURE__ */ b(r, {
267
278
  title: "Could not load AI runs",
268
- onRetry: () => x.refetch()
269
- }) : S.length === 0 ? /* @__PURE__ */ _(t, {
270
- icon: /* @__PURE__ */ _(m, { className: "h-9 w-9" }),
279
+ onRetry: () => k.refetch()
280
+ }) : A.length === 0 ? /* @__PURE__ */ b(n, {
281
+ icon: /* @__PURE__ */ b(_, { className: "h-9 w-9" }),
271
282
  title: "No AI runs yet",
272
- description: "Run one of the actions above to draft a citation-grounded answer."
273
- }) : /* @__PURE__ */ _("div", {
283
+ description: w ? "Run one of the actions above to draft a citation-grounded answer." : "No citation-grounded AI runs have been created for this scope yet."
284
+ }) : /* @__PURE__ */ b("div", {
274
285
  className: "flex flex-col gap-3",
275
- children: S.map((e) => /* @__PURE__ */ _(F, { run: e }, e.id))
286
+ children: A.map((e) => /* @__PURE__ */ b(R, {
287
+ run: e,
288
+ canReview: T
289
+ }, e.id))
276
290
  })),
277
- p && /* @__PURE__ */ _(N, {
291
+ E && /* @__PURE__ */ b(I, {
278
292
  open: !0,
279
293
  onOpenChange: (e) => {
280
- e || h(null);
294
+ e || D(null);
281
295
  },
282
- useCase: p,
283
- storyId: e,
284
- collectionId: a,
285
- oralHistoryId: o
296
+ useCase: E,
297
+ storyId: t,
298
+ collectionId: o,
299
+ oralHistoryId: s,
300
+ canReview: T
286
301
  })
287
302
  ]
288
303
  })
289
304
  });
290
305
  }
291
- function L({ className: e }) {
292
- return /* @__PURE__ */ _(f, {
306
+ function B({ className: t }) {
307
+ let { workspaceId: n } = e(), r = M(), { canRead: i, canReview: a } = d(r, n);
308
+ return i ? /* @__PURE__ */ b(h, {
293
309
  flag: "theculturepost.ai-context",
294
310
  defaultValue: !0,
295
311
  fallback: null,
296
- children: /* @__PURE__ */ _(R, { className: e })
297
- });
312
+ children: /* @__PURE__ */ b(V, {
313
+ className: t,
314
+ canReview: a
315
+ })
316
+ }) : null;
298
317
  }
299
- function R({ className: e }) {
300
- let t = i({ pagination: { limit: 50 } }), a = (t.data?.items ?? []).filter(M);
301
- return t.isLoading ? /* @__PURE__ */ _(r, { label: "Loading AI review queue…" }) : t.isError ? /* @__PURE__ */ _(n, {
318
+ function V({ className: e, canReview: t }) {
319
+ let n = a({ pagination: { limit: 50 } }), o = (n.data?.items ?? []).filter(u);
320
+ return n.isLoading ? /* @__PURE__ */ b(i, { label: "Loading AI review queue…" }) : n.isError ? /* @__PURE__ */ b(r, {
302
321
  title: "Could not load the AI review queue",
303
- onRetry: () => t.refetch()
304
- }) : a.length === 0 ? null : /* @__PURE__ */ v(b, {
322
+ onRetry: () => n.refetch()
323
+ }) : o.length === 0 ? null : /* @__PURE__ */ x(C, {
305
324
  treatment: "plain",
306
325
  className: `flex flex-col gap-3 p-5 sm:p-6 ${e ?? ""}`,
307
326
  children: [
308
- /* @__PURE__ */ v("h2", {
327
+ /* @__PURE__ */ x("h2", {
309
328
  className: "flex items-center gap-2 font-display text-xl font-semibold text-text-primary",
310
329
  children: [
311
- /* @__PURE__ */ _(m, {
330
+ /* @__PURE__ */ b(_, {
312
331
  className: "h-5 w-5 text-accent",
313
332
  "aria-hidden": "true"
314
333
  }),
315
334
  " AI review queue",
316
- /* @__PURE__ */ v("span", {
335
+ /* @__PURE__ */ x("span", {
317
336
  className: "rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-xs font-medium text-status-warning-text",
318
- children: [a.length, " pending"]
337
+ children: [o.length, " pending"]
319
338
  })
320
339
  ]
321
340
  }),
322
- /* @__PURE__ */ _("p", {
341
+ /* @__PURE__ */ b("p", {
323
342
  className: "text-sm text-text-secondary",
324
343
  children: "Generated answers awaiting an editorial decision, newest first. Approve or reject them here, or in place on the story or collection they belong to."
325
344
  }),
326
- /* @__PURE__ */ v("div", {
345
+ /* @__PURE__ */ x("div", {
327
346
  className: "flex flex-col gap-3",
328
- children: [a.slice(0, 5).map((e) => /* @__PURE__ */ _(F, { run: e }, e.id)), a.length > 5 && /* @__PURE__ */ v("p", {
347
+ children: [o.slice(0, 5).map((e) => /* @__PURE__ */ b(R, {
348
+ run: e,
349
+ canReview: t
350
+ }, e.id)), o.length > 5 && /* @__PURE__ */ x("p", {
329
351
  className: "text-xs text-text-tertiary",
330
- children: [a.length - 5, " more pending — open the story or collection they belong to review them in place."]
352
+ children: [o.length - 5, " more pending — open the story or collection they belong to review them in place."]
331
353
  })]
332
354
  })
333
355
  ]
334
356
  });
335
357
  }
336
- export { k as AI_USE_CASE_LABELS, I as AiContextSection, L as AiReviewQueue, F as AiRunCard, N as GenerateAiContextDialog };
358
+ export { N as AI_USE_CASE_LABELS, z as AiContextSection, B as AiReviewQueue, R as AiRunCard, I as GenerateAiContextDialog };
337
359
 
338
360
  //# sourceMappingURL=AiContextPanel.js.map