@aglyn/plugins-workflows 1.0.0-beta.188 → 1.0.0-beta.190

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/plugins-workflows",
3
- "version": "1.0.0-beta.188",
3
+ "version": "1.0.0-beta.190",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://aglyn.com",
6
6
  "repository": {
@@ -25,21 +25,22 @@
25
25
  "./package.json": "./package.json"
26
26
  },
27
27
  "dependencies": {
28
- "@aglyn/aglyn": "1.0.0-beta.188",
29
- "@aglyn/shared-data-mdi": "1.0.0-beta.188",
30
- "@aglyn/shared-ui-jsx": "1.0.0-beta.188",
31
- "@aglyn/shared-ui-next": "1.0.0-beta.188",
32
- "@aglyn/shared-ui-snackstack": "1.0.0-beta.188",
33
- "@aglyn/shared-util-email": "1.0.0-beta.188",
34
- "@aglyn/shared-util-http": "1.0.0-beta.188",
35
- "@aglyn/shared-util-timestamp": "1.0.0-beta.188",
36
- "@aglyn/tenant-data-admin": "1.0.0-beta.188",
37
- "@aglyn/tenant-feature-instance": "1.0.0-beta.188",
38
- "@aglyn/tenant-runtime": "1.0.0-beta.188",
28
+ "@aglyn/aglyn": "1.0.0-beta.190",
29
+ "@aglyn/shared-data-mdi": "1.0.0-beta.190",
30
+ "@aglyn/shared-ui-jsx": "1.0.0-beta.190",
31
+ "@aglyn/shared-ui-next": "1.0.0-beta.190",
32
+ "@aglyn/shared-ui-snackstack": "1.0.0-beta.190",
33
+ "@aglyn/shared-util-email": "1.0.0-beta.190",
34
+ "@aglyn/shared-util-http": "1.0.0-beta.190",
35
+ "@aglyn/shared-util-timestamp": "1.0.0-beta.190",
36
+ "@aglyn/tenant-data-admin": "1.0.0-beta.190",
37
+ "@aglyn/tenant-feature-instance": "1.0.0-beta.190",
38
+ "@aglyn/tenant-runtime": "1.0.0-beta.190",
39
39
  "@swc/helpers": "0.5.23"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@mui/material": "^9.3.1",
43
+ "@mui/x-data-grid": "^9.12.0",
43
44
  "firebase": "^12.18.0",
44
45
  "firebase-admin": "^14.3.0",
45
46
  "next": "16.3.3",
@@ -14,14 +14,19 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */ 'use client';
17
+ import { _ as _extends } from "@swc/helpers/_/_extends";
17
18
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
19
  import { actionRunResult, actionRunSummary, actionTriggerLabel } from "@aglyn/aglyn/app-utils/activity-presenter";
19
20
  import { useConsoleWidgetSlot } from "@aglyn/aglyn/app-utils/console-widget-slot-context";
21
+ import { HOST_EVENT_TYPES } from "@aglyn/aglyn/app-utils/workflows";
20
22
  import { CardDisplay } from "@aglyn/shared-ui-jsx";
23
+ import ListFilterChips from "@aglyn/shared-ui-jsx/components/list-filter-chips.component";
21
24
  import { ListPagination } from "@aglyn/shared-ui-jsx/components/list-pagination.component";
25
+ import { ListTable } from "@aglyn/shared-ui-jsx/components/list-table.component";
26
+ import { inMemoryListField } from "@aglyn/shared-ui-jsx/const/list-grid-filter";
22
27
  import { TABLE_PAGE_SIZE_DEFAULT } from "@aglyn/shared-ui-jsx/const/table-pagination";
23
- import { ScrollTable } from "@aglyn/shared-ui-jsx/components/scroll-table.component";
24
- import { Alert, Chip, Stack, TableBody, TableCell, TableHead, TableRow, Tooltip, Typography } from "@mui/material";
28
+ import { useListRowsFilter } from "@aglyn/shared-ui-jsx/hooks/use-list-rows-filter";
29
+ import { Alert, Chip, Stack, Tooltip, Typography } from "@mui/material";
25
30
  import { collection, limit, orderBy, query, where } from "firebase/firestore";
26
31
  import { useEffect, useMemo, useState } from "react";
27
32
  import { useFirestore, useFirestoreCollection } from "@aglyn/tenant-feature-instance";
@@ -52,6 +57,37 @@ const RESULT_LABEL = {
52
57
  failed: 'Failed',
53
58
  skipped: 'Skipped'
54
59
  };
60
+ /*
61
+ * What the run grid's Filters panel offers. The card holds its whole window,
62
+ * so the panel and the search answer over every run it read. Trigger and
63
+ * Result are picked from the event list and the three verdicts; what
64
+ * happened is typed.
65
+ */ const RUN_FILTER_FIELDS = [
66
+ inMemoryListField('createdAtMs', 'date'),
67
+ inMemoryListField('trigger', 'select'),
68
+ inMemoryListField('result', 'select'),
69
+ inMemoryListField('summary', 'text')
70
+ ];
71
+ const RUN_FILTER_HEADERS = {
72
+ createdAtMs: 'Time',
73
+ trigger: 'Trigger',
74
+ result: 'Result',
75
+ summary: 'What happened'
76
+ };
77
+ const RUN_FILTER_OPTIONS = {
78
+ trigger: HOST_EVENT_TYPES.map((event)=>({
79
+ value: event,
80
+ label: actionTriggerLabel(event)
81
+ })),
82
+ result: Object.keys(RESULT_LABEL).map((result)=>({
83
+ value: result,
84
+ label: RESULT_LABEL[result]
85
+ }))
86
+ };
87
+ /** What the quick search reads on a run row. */ const RUN_SEARCH_FIELDS = [
88
+ 'summary',
89
+ 'triggerLabel'
90
+ ];
55
91
  /**
56
92
  * The run-history table `/product/workflows` advertises (AGL-2171):
57
93
  * `Time | Trigger | Result | What happened`.
@@ -139,10 +175,31 @@ const RESULT_LABEL = {
139
175
  var _ref, _ref1;
140
176
  var _b_entry_createdAt, _a_entry_createdAt;
141
177
  return ((_ref = (_b_entry_createdAt = b.entry.createdAt) == null ? void 0 : _b_entry_createdAt.seconds) != null ? _ref : 0) - ((_ref1 = (_a_entry_createdAt = a.entry.createdAt) == null ? void 0 : _a_entry_createdAt.seconds) != null ? _ref1 : 0);
178
+ }).map(({ entry, result })=>{
179
+ var _entry_trigger;
180
+ var _entry_createdAt;
181
+ return {
182
+ $id: String(entry.$id),
183
+ entry,
184
+ result,
185
+ trigger: String((_entry_trigger = entry.trigger) != null ? _entry_trigger : ''),
186
+ // `formSubmission` → `Form submitted`.
187
+ triggerLabel: actionTriggerLabel(entry.trigger),
188
+ summary: actionRunSummary(entry),
189
+ createdAtMs: typeof ((_entry_createdAt = entry.createdAt) == null ? void 0 : _entry_createdAt.seconds) === 'number' ? entry.createdAt.seconds * 1000 : null
190
+ };
142
191
  }), [
143
192
  entries,
144
193
  targetId
145
194
  ]);
195
+ const listFilter = useListRowsFilter({
196
+ rows: runs,
197
+ fields: RUN_FILTER_FIELDS,
198
+ options: RUN_FILTER_OPTIONS,
199
+ headers: RUN_FILTER_HEADERS,
200
+ search: RUN_SEARCH_FIELDS
201
+ });
202
+ const matched = listFilter.rows;
146
203
  /*
147
204
  * The page is a SLICE, because the rows are already in hand.
148
205
  *
@@ -157,15 +214,90 @@ const RESULT_LABEL = {
157
214
  // A different workflow is a different history: page three of the last one
158
215
  // is not a position in this one, and an out-of-range page renders empty
159
216
  // with no explanation, which reads as the runs having gone.
217
+ // A narrowed list starts again at its first page, for the same reason.
218
+ const searchKey = listFilter.gridFilter.searchWords.join(' ');
160
219
  useEffect(()=>setPage(0), [
161
220
  targetId,
162
- hostId
221
+ hostId,
222
+ listFilter.gridFilter.clauses,
223
+ searchKey
163
224
  ]);
164
- const shown = useMemo(()=>runs.slice(page * pageSize, page * pageSize + pageSize), [
165
- runs,
225
+ const shown = useMemo(()=>matched.slice(page * pageSize, page * pageSize + pageSize), [
226
+ matched,
166
227
  page,
167
228
  pageSize
168
229
  ]);
230
+ const { filterColumns } = listFilter;
231
+ const columns = useMemo(()=>filterColumns([
232
+ {
233
+ field: 'createdAtMs',
234
+ headerName: 'Time',
235
+ width: 120,
236
+ renderCell: ({ row })=>{
237
+ var _row_entry_createdAt_toDate, _row_entry_createdAt;
238
+ const at = (_row_entry_createdAt = row.entry.createdAt) == null ? void 0 : (_row_entry_createdAt_toDate = _row_entry_createdAt.toDate) == null ? void 0 : _row_entry_createdAt_toDate.call(_row_entry_createdAt);
239
+ return /*#__PURE__*/ _jsx(Tooltip, {
240
+ title: at ? at.toLocaleString() : '',
241
+ children: /*#__PURE__*/ _jsx("span", {
242
+ children: at ? at.toLocaleTimeString() : '--'
243
+ })
244
+ });
245
+ }
246
+ },
247
+ {
248
+ field: 'trigger',
249
+ headerName: 'Trigger',
250
+ width: 180,
251
+ renderCell: ({ row })=>row.triggerLabel
252
+ },
253
+ {
254
+ field: 'result',
255
+ headerName: 'Result',
256
+ width: 120,
257
+ renderCell: ({ row })=>/*#__PURE__*/ _jsx(Chip, {
258
+ size: "small",
259
+ variant: "outlined",
260
+ color: RESULT_COLOR[row.result],
261
+ label: RESULT_LABEL[row.result]
262
+ })
263
+ },
264
+ {
265
+ field: 'summary',
266
+ headerName: 'What happened',
267
+ flex: 1,
268
+ minWidth: 220,
269
+ renderCell: ({ row })=>/*#__PURE__*/ _jsxs(Stack, {
270
+ sx: {
271
+ minWidth: 0,
272
+ py: 0.75
273
+ },
274
+ children: [
275
+ /*#__PURE__*/ _jsx(Typography, {
276
+ variant: "body2",
277
+ children: row.summary
278
+ }),
279
+ row.entry.durationMs != null ? /*#__PURE__*/ _jsx(Typography, {
280
+ variant: "caption",
281
+ color: "text.secondary",
282
+ children: `${row.entry.durationMs}ms`
283
+ }) : null,
284
+ RunZone && zoneTarget && row.result === 'failed' ? /*#__PURE__*/ _jsx(RunZone, {
285
+ slot: "automationRun",
286
+ hostId: hostId,
287
+ orgId: orgId,
288
+ target: zoneTarget,
289
+ runId: row.$id
290
+ }) : null
291
+ ]
292
+ })
293
+ }
294
+ ]), [
295
+ filterColumns,
296
+ RunZone,
297
+ zoneTarget,
298
+ hostId,
299
+ orgId
300
+ ]);
169
301
  return /*#__PURE__*/ _jsx(CardDisplay, {
170
302
  header: header,
171
303
  help: help,
@@ -179,94 +311,27 @@ const RESULT_LABEL = {
179
311
  }) : /*#__PURE__*/ _jsxs(Stack, {
180
312
  spacing: 1.5,
181
313
  children: [
182
- /*#__PURE__*/ _jsxs(ScrollTable, {
183
- size: "small",
314
+ /*#__PURE__*/ _jsx(ListFilterChips, _extends({}, listFilter.chipsProps)),
315
+ /*#__PURE__*/ _jsx(ListTable, _extends({
184
316
  "aria-label": "Run history",
185
- children: [
186
- /*#__PURE__*/ _jsx(TableHead, {
187
- children: /*#__PURE__*/ _jsxs(TableRow, {
188
- children: [
189
- /*#__PURE__*/ _jsx(TableCell, {
190
- children: 'Time'
191
- }),
192
- /*#__PURE__*/ _jsx(TableCell, {
193
- children: 'Trigger'
194
- }),
195
- /*#__PURE__*/ _jsx(TableCell, {
196
- children: 'Result'
197
- }),
198
- /*#__PURE__*/ _jsx(TableCell, {
199
- children: 'What happened'
200
- })
201
- ]
202
- })
203
- }),
204
- /*#__PURE__*/ _jsx(TableBody, {
205
- children: shown.map(({ entry, result })=>{
206
- var _entry_createdAt_toDate, _entry_createdAt;
207
- const at = (_entry_createdAt = entry.createdAt) == null ? void 0 : (_entry_createdAt_toDate = _entry_createdAt.toDate) == null ? void 0 : _entry_createdAt_toDate.call(_entry_createdAt);
208
- return /*#__PURE__*/ _jsxs(TableRow, {
209
- children: [
210
- /*#__PURE__*/ _jsx(TableCell, {
211
- sx: {
212
- whiteSpace: 'nowrap'
213
- },
214
- children: /*#__PURE__*/ _jsx(Tooltip, {
215
- title: at ? at.toLocaleString() : '',
216
- children: /*#__PURE__*/ _jsx("span", {
217
- children: at ? at.toLocaleTimeString() : '--'
218
- })
219
- })
220
- }),
221
- /*#__PURE__*/ _jsx(TableCell, {
222
- sx: {
223
- whiteSpace: 'nowrap'
224
- },
225
- children: actionTriggerLabel(entry.trigger)
226
- }),
227
- /*#__PURE__*/ _jsx(TableCell, {
228
- children: /*#__PURE__*/ _jsx(Chip, {
229
- size: "small",
230
- variant: "outlined",
231
- color: RESULT_COLOR[result],
232
- label: RESULT_LABEL[result]
233
- })
234
- }),
235
- /*#__PURE__*/ _jsxs(TableCell, {
236
- children: [
237
- /*#__PURE__*/ _jsx(Typography, {
238
- variant: "body2",
239
- children: actionRunSummary(entry)
240
- }),
241
- entry.durationMs != null ? /*#__PURE__*/ _jsx(Typography, {
242
- variant: "caption",
243
- color: "text.secondary",
244
- children: `${entry.durationMs}ms`
245
- }) : null,
246
- RunZone && zoneTarget && result === 'failed' ? /*#__PURE__*/ _jsx(RunZone, {
247
- slot: "automationRun",
248
- hostId: hostId,
249
- orgId: orgId,
250
- target: zoneTarget,
251
- runId: entry.$id
252
- }) : null
253
- ]
254
- })
255
- ]
256
- }, entry.$id);
257
- })
258
- })
259
- ]
260
- }),
317
+ rows: shown,
318
+ columns: columns
319
+ }, listFilter.gridProps, {
320
+ // A failed run carries what other plugins add under its summary.
321
+ getRowHeight: ()=>'auto',
322
+ // `ListPagination` below pages the matches.
323
+ hideFooter: true,
324
+ noRowsLabel: "No runs match these filters"
325
+ })),
261
326
  /*#__PURE__*/ _jsx(ListPagination, {
262
327
  page: page,
263
328
  pageSize: pageSize,
264
329
  rowCount: shown.length,
265
- // The runs in the window, which is a number this card genuinely
266
- // holds. What it does not know is how many runs are OLDER than the
267
- // window, and the notice below says so rather than letting the
268
- // count line imply a total it cannot see.
269
- count: runs.length,
330
+ // The runs in the window that match, which is a number this card
331
+ // genuinely holds. What it does not know is how many runs are OLDER
332
+ // than the window, and the notice below says so rather than letting
333
+ // the count line imply a total it cannot see.
334
+ count: matched.length,
270
335
  onPageChange: setPage,
271
336
  onPageSizeChange: setPageSize
272
337
  }),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/workflows/src/lib/components/host-run-history-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport {\n actionRunResult,\n actionRunSummary,\n actionTriggerLabel,\n} from '@aglyn/aglyn/app-utils/activity-presenter'\nimport { useConsoleWidgetSlot } from '@aglyn/aglyn/app-utils/console-widget-slot-context'\nimport type { ConsoleAutomationTarget } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { CardDisplay, type HelpTipContent } from '@aglyn/shared-ui-jsx'\nimport { ListPagination } from '@aglyn/shared-ui-jsx/components/list-pagination.component'\nimport { TABLE_PAGE_SIZE_DEFAULT } from '@aglyn/shared-ui-jsx/const/table-pagination'\nimport { ScrollTable } from '@aglyn/shared-ui-jsx/components/scroll-table.component'\nimport {\n Alert,\n Chip,\n Stack,\n TableBody,\n TableCell,\n TableHead,\n TableRow,\n Tooltip,\n Typography,\n} from '@mui/material'\nimport { collection, limit, orderBy, query, where } from 'firebase/firestore'\nimport { useEffect, useMemo, useState } from 'react'\nimport {\n useFirestore,\n useFirestoreCollection,\n} from '@aglyn/tenant-feature-instance'\nimport { pluginDocsHelp } from '@aglyn/aglyn'\n\nexport interface HostRunHistoryCardProps {\n hostId: string\n /** The org the page names, for what other plugins add to a failed run. */\n orgId?: string\n /** Show only runs of this action/workflow. */\n targetId?: string\n /**\n * What `targetId` names, and its name. A run row records its automation's id\n * but not whether it is an action or a workflow, so the card that opened the\n * history says; without it, a failed run offers nothing beside its summary.\n */\n targetType?: ConsoleAutomationTarget['type']\n targetName?: string\n header?: string\n /** Overrides the default help affordance on the card header. */\n help?: HelpTipContent\n}\n\n/**\n * Activity rows read before the run filter.\n *\n * A CEILING rather than a page, and the difference is the client-side filter\n * below. `activity` holds publishes, media saves and member changes as well as\n * runs, and only a document carrying a run verdict is a row here — so a\n * server page of ten activity entries might contain two runs, one, or none,\n * and paging the QUERY would hand the reader pages of wildly different\n * heights with no way to tell a short page from the end of the history.\n *\n * The filter cannot move to the server either: `actionRunResult` falls back to\n * reading the prose `action` for entries written before AGL-2171, which have\n * no `result` field, and `where('result','in',…)` excludes exactly those. That\n * is the same field-presence trap as ordering on an optional field, and it\n * would silently drop every historic run.\n */\nconst WINDOW = 200\n\nconst RESULT_COLOR = {\n succeeded: 'success',\n failed: 'error',\n skipped: 'warning',\n} as const\n\nconst RESULT_LABEL = {\n succeeded: 'Succeeded',\n failed: 'Failed',\n skipped: 'Skipped',\n} as const\n\n/**\n * The run-history table `/product/workflows` advertises (AGL-2171):\n * `Time | Trigger | Result | What happened`.\n *\n * A separate component from `HostActivityCard` on purpose. That card is\n * the site's general feed — publishes, media saves, member changes — and\n * a run is a different record with different columns. Pointing the Runs\n * dialog at the general feed is what produced a list of\n * `Action ran on formSubmission — My automation` where the mockup shows\n * four columns.\n *\n * `actionRunResult` returning `undefined` is the filter: the activity\n * collection holds far more than runs, and a publish has no verdict. An\n * entry that is not a run simply does not appear, rather than appearing\n * under a `Succeeded` that means nothing for it.\n */\nexport function HostRunHistoryCard(props: HostRunHistoryCardProps) {\n const {\n hostId,\n orgId,\n targetId,\n targetType,\n targetName = '',\n header = 'Run history',\n help = pluginDocsHelp('buildAWorkflow', {\n anchor: '#4-save-and-test',\n excerpt:\n 'Every run of this automation, including the ones a trigger ' +\n 'condition skipped — which is the answer to \"why did it not fire?\".',\n }),\n } = props\n const firestore = useFirestore()\n /**\n * The shell's zone renderer (AGL-2919), for what other plugins add to a\n * failed run; `null` outside the console shell.\n */\n const RunZone = useConsoleWidgetSlot()\n /** The automation a failed run belongs to, as the `automationRun` zone names it. */\n const zoneTarget = useMemo<ConsoleAutomationTarget | null>(\n () => (targetId && targetType ? { type: targetType, id: targetId, name: targetName } : null),\n [targetId, targetType, targetName],\n )\n /*\n * The window is NARROWED BY THE SERVER, not by the client (AGL-2292).\n *\n * A bare `limit(200)` with no ordering is not \"the most recent 200 runs\" —\n * Firestore answers an unordered limit in `__name__` order, so it is an\n * arbitrary slice of the host's whole activity feed. `activity` also holds\n * publishes, media saves and member changes, and only entries carrying a\n * run result survive the filter below, so a busy site could fill all 200\n * places with rows this card discards and report \"No runs yet\" for a\n * workflow that had run all day.\n *\n * `target.id` equality is what makes the read proportional to the card:\n * it asks for this workflow's rows rather than the site's. It carries no\n * `orderBy` deliberately — an equality plus an ordering on a second field\n * needs a composite index, and the client sort below already puts the\n * newest first. The untargeted case has no equality to pair, so it orders\n * server-side instead.\n */\n const { data: entries } = useFirestoreCollection<any>(\n () => {\n if (!hostId) return null\n const base = collection(firestore, 'hosts', hostId, 'activity')\n /*\n * `WINDOW + 1` is a PROBE, not an off-by-one (AGL-2501).\n *\n * The card used to say \"showing what we read\" by saying nothing at all.\n * Reading one document more than the ceiling turns \"there is older\n * history than this\" into a fact for the price of a single read;\n * comparing `length === WINDOW` cannot, because it is wrong in both\n * directions at exactly the count that equals the ceiling. The probe row\n * is dropped below and never rendered.\n */\n return targetId\n ? query(base, where('target.id', '==', targetId), limit(WINDOW + 1))\n : query(base, orderBy('createdAt', 'desc'), limit(WINDOW + 1))\n },\n // `targetId` belongs here: it now shapes the query, so a card that\n // switched workflows without it would go on showing the first one's runs.\n [firestore, hostId, targetId],\n { idField: '$id' },\n )\n /** The activity ceiling bit — there are older entries than were read. */\n const truncated = (entries?.length ?? 0) > WINDOW\n\n const runs = useMemo(\n () =>\n [...(entries ?? [])]\n .slice(0, WINDOW)\n .filter((entry) => !targetId || entry.target?.id === targetId)\n .map((entry) => ({ entry, result: actionRunResult(entry) }))\n .filter(\n (row): row is { entry: any; result: keyof typeof RESULT_LABEL } =>\n Boolean(row.result),\n )\n .sort(\n (a, b) =>\n (b.entry.createdAt?.seconds ?? 0) -\n (a.entry.createdAt?.seconds ?? 0),\n ),\n [entries, targetId],\n )\n\n /*\n * The page is a SLICE, because the rows are already in hand.\n *\n * Every run in the window has been read and paid for by the query above, so\n * a second query per page would buy nothing and cost a read. What the card\n * lacked was not a cheaper read but a control: it sliced the newest\n * twenty-five off the window and rendered them in one wall, so run\n * twenty-six was read, discarded, and unreachable — on the surface a reader\n * opens precisely to ask \"why did it not fire the time before last?\".\n */\n const [page, setPage] = useState(0)\n const [pageSize, setPageSize] = useState(TABLE_PAGE_SIZE_DEFAULT)\n // A different workflow is a different history: page three of the last one\n // is not a position in this one, and an out-of-range page renders empty\n // with no explanation, which reads as the runs having gone.\n useEffect(() => setPage(0), [targetId, hostId])\n const shown = useMemo(\n () => runs.slice(page * pageSize, page * pageSize + pageSize),\n [runs, page, pageSize],\n )\n\n return (\n <CardDisplay\n header={header}\n help={help}\n contentGutterX\n contentGutterY\n contentBordered=\"all\"\n >\n {runs.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No runs yet — every run of this automation is logged here, ' +\n 'including the ones a condition skipped.'}\n </Typography>\n ) : (\n <Stack spacing={1.5}>\n <ScrollTable size=\"small\" aria-label=\"Run history\">\n <TableHead>\n <TableRow>\n <TableCell>{'Time'}</TableCell>\n <TableCell>{'Trigger'}</TableCell>\n <TableCell>{'Result'}</TableCell>\n <TableCell>{'What happened'}</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {shown.map(({ entry, result }) => {\n const at = entry.createdAt?.toDate?.()\n return (\n <TableRow key={entry.$id}>\n <TableCell sx={{ whiteSpace: 'nowrap' }}>\n <Tooltip title={at ? at.toLocaleString() : ''}>\n <span>{at ? at.toLocaleTimeString() : '--'}</span>\n </Tooltip>\n </TableCell>\n <TableCell sx={{ whiteSpace: 'nowrap' }}>\n {/* `formSubmission` → `Form submitted`. */}\n {actionTriggerLabel(entry.trigger)}\n </TableCell>\n <TableCell>\n <Chip\n size=\"small\"\n variant=\"outlined\"\n color={RESULT_COLOR[result]}\n label={RESULT_LABEL[result]}\n />\n </TableCell>\n <TableCell>\n <Typography variant=\"body2\">\n {actionRunSummary(entry)}\n </Typography>\n {entry.durationMs != null ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`${entry.durationMs}ms`}\n </Typography>\n ) : null}\n {/*\n What other plugins add to a failed run (AGL-2919): the\n `automationRun` zone, through the shell's gated slot.\n */}\n {RunZone && zoneTarget && result === 'failed' ? (\n <RunZone\n slot=\"automationRun\"\n hostId={hostId}\n orgId={orgId}\n target={zoneTarget}\n runId={entry.$id}\n />\n ) : null}\n </TableCell>\n </TableRow>\n )\n })}\n </TableBody>\n </ScrollTable>\n <ListPagination\n page={page}\n pageSize={pageSize}\n rowCount={shown.length}\n // The runs in the window, which is a number this card genuinely\n // holds. What it does not know is how many runs are OLDER than the\n // window, and the notice below says so rather than letting the\n // count line imply a total it cannot see.\n count={runs.length}\n onPageChange={setPage}\n onPageSizeChange={setPageSize}\n />\n {truncated ? (\n <Alert severity=\"info\">\n {`Runs found in the ${WINDOW} most recent activity entries for ` +\n 'this site. Older runs than that are recorded and are not ' +\n 'listed here.'}\n </Alert>\n ) : null}\n </Stack>\n )}\n </CardDisplay>\n )\n}\nHostRunHistoryCard.displayName = 'HostRunHistoryCard'\n\nexport default HostRunHistoryCard\n"],"names":["actionRunResult","actionRunSummary","actionTriggerLabel","useConsoleWidgetSlot","CardDisplay","ListPagination","TABLE_PAGE_SIZE_DEFAULT","ScrollTable","Alert","Chip","Stack","TableBody","TableCell","TableHead","TableRow","Tooltip","Typography","collection","limit","orderBy","query","where","useEffect","useMemo","useState","useFirestore","useFirestoreCollection","pluginDocsHelp","WINDOW","RESULT_COLOR","succeeded","failed","skipped","RESULT_LABEL","HostRunHistoryCard","props","hostId","orgId","targetId","targetType","targetName","header","help","anchor","excerpt","firestore","RunZone","zoneTarget","type","id","name","data","entries","base","idField","truncated","length","runs","slice","filter","entry","target","map","result","row","Boolean","sort","a","b","createdAt","seconds","page","setPage","pageSize","setPageSize","shown","contentGutterX","contentGutterY","contentBordered","variant","color","spacing","size","aria-label","at","toDate","sx","whiteSpace","title","toLocaleString","span","toLocaleTimeString","trigger","label","durationMs","slot","runId","$id","rowCount","count","onPageChange","onPageSizeChange","severity","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SACEA,eAAe,EACfC,gBAAgB,EAChBC,kBAAkB,QACb,4CAA2C;AAClD,SAASC,oBAAoB,QAAQ,qDAAoD;AAEzF,SAASC,WAAW,QAA6B,uBAAsB;AACvE,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,uB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iD,MAAK;oDACL3D,QAAQA;oDACRC,OAAOA;oDACPwB,QAAQd;oDACRiD,OAAOpC,MAAMqC,GAAG;qDAEhB;;;;mCAvCOrC,MAAMqC,GAAG;4BA2C5B;;;;8BAGJ,KAAC5F;oBACCkE,MAAMA;oBACNE,UAAUA;oBACVyB,UAAUvB,MAAMnB,MAAM;oBACtB,gEAAgE;oBAChE,mEAAmE;oBACnE,+DAA+D;oBAC/D,0CAA0C;oBAC1C2C,OAAO1C,KAAKD,MAAM;oBAClB4C,cAAc5B;oBACd6B,kBAAkB3B;;gBAEnBnB,0BACC,KAAC/C;oBAAM8F,UAAS;8BACb,CAAC,kBAAkB,EAAE1E,OAAO,kCAAkC,CAAC,GAC9D,8DACA;qBAEF;;;;AAKZ;AACAM,mBAAmBqE,WAAW,GAAG;AAEjC,eAAerE,mBAAkB"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/workflows/src/lib/components/host-run-history-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport {\n actionRunResult,\n actionRunSummary,\n actionTriggerLabel,\n} from '@aglyn/aglyn/app-utils/activity-presenter'\nimport { useConsoleWidgetSlot } from '@aglyn/aglyn/app-utils/console-widget-slot-context'\nimport { HOST_EVENT_TYPES } from '@aglyn/aglyn/app-utils/workflows'\nimport type { ConsoleAutomationTarget } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { CardDisplay, type HelpTipContent } from '@aglyn/shared-ui-jsx'\nimport ListFilterChips from '@aglyn/shared-ui-jsx/components/list-filter-chips.component'\nimport { ListPagination } from '@aglyn/shared-ui-jsx/components/list-pagination.component'\nimport { ListTable } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport { inMemoryListField } from '@aglyn/shared-ui-jsx/const/list-grid-filter'\nimport { TABLE_PAGE_SIZE_DEFAULT } from '@aglyn/shared-ui-jsx/const/table-pagination'\nimport { useListRowsFilter } from '@aglyn/shared-ui-jsx/hooks/use-list-rows-filter'\nimport { Alert, Chip, Stack, Tooltip, Typography } from '@mui/material'\nimport type { GridColDef } from '@mui/x-data-grid'\nimport { collection, limit, orderBy, query, where } from 'firebase/firestore'\nimport { useEffect, useMemo, useState } from 'react'\nimport {\n useFirestore,\n useFirestoreCollection,\n} from '@aglyn/tenant-feature-instance'\nimport { pluginDocsHelp } from '@aglyn/aglyn'\n\nexport interface HostRunHistoryCardProps {\n hostId: string\n /** The org the page names, for what other plugins add to a failed run. */\n orgId?: string\n /** Show only runs of this action/workflow. */\n targetId?: string\n /**\n * What `targetId` names, and its name. A run row records its automation's id\n * but not whether it is an action or a workflow, so the card that opened the\n * history says; without it, a failed run offers nothing beside its summary.\n */\n targetType?: ConsoleAutomationTarget['type']\n targetName?: string\n header?: string\n /** Overrides the default help affordance on the card header. */\n help?: HelpTipContent\n}\n\n/**\n * Activity rows read before the run filter.\n *\n * A CEILING rather than a page, and the difference is the client-side filter\n * below. `activity` holds publishes, media saves and member changes as well as\n * runs, and only a document carrying a run verdict is a row here — so a\n * server page of ten activity entries might contain two runs, one, or none,\n * and paging the QUERY would hand the reader pages of wildly different\n * heights with no way to tell a short page from the end of the history.\n *\n * The filter cannot move to the server either: `actionRunResult` falls back to\n * reading the prose `action` for entries written before AGL-2171, which have\n * no `result` field, and `where('result','in',…)` excludes exactly those. That\n * is the same field-presence trap as ordering on an optional field, and it\n * would silently drop every historic run.\n */\nconst WINDOW = 200\n\nconst RESULT_COLOR = {\n succeeded: 'success',\n failed: 'error',\n skipped: 'warning',\n} as const\n\nconst RESULT_LABEL = {\n succeeded: 'Succeeded',\n failed: 'Failed',\n skipped: 'Skipped',\n} as const\n\ntype RunResult = keyof typeof RESULT_LABEL\n\n/** One run as the grid holds it: the entry, and what it is shown and filtered by. */\ninterface RunRow {\n $id: string\n entry: any\n result: RunResult\n trigger: string\n triggerLabel: string\n summary: string\n createdAtMs: number | null\n}\n\n/*\n * What the run grid's Filters panel offers. The card holds its whole window,\n * so the panel and the search answer over every run it read. Trigger and\n * Result are picked from the event list and the three verdicts; what\n * happened is typed.\n */\nconst RUN_FILTER_FIELDS = [\n inMemoryListField('createdAtMs', 'date'),\n inMemoryListField('trigger', 'select'),\n inMemoryListField('result', 'select'),\n inMemoryListField('summary', 'text'),\n]\nconst RUN_FILTER_HEADERS: Readonly<Record<string, string>> = {\n createdAtMs: 'Time',\n trigger: 'Trigger',\n result: 'Result',\n summary: 'What happened',\n}\nconst RUN_FILTER_OPTIONS = {\n trigger: HOST_EVENT_TYPES.map((event) => ({\n value: event,\n label: actionTriggerLabel(event),\n })),\n result: (Object.keys(RESULT_LABEL) as RunResult[]).map((result) => ({\n value: result,\n label: RESULT_LABEL[result],\n })),\n}\n/** What the quick search reads on a run row. */\nconst RUN_SEARCH_FIELDS = ['summary', 'triggerLabel'] as const\n\n/**\n * The run-history table `/product/workflows` advertises (AGL-2171):\n * `Time | Trigger | Result | What happened`.\n *\n * A separate component from `HostActivityCard` on purpose. That card is\n * the site's general feed — publishes, media saves, member changes — and\n * a run is a different record with different columns. Pointing the Runs\n * dialog at the general feed is what produced a list of\n * `Action ran on formSubmission — My automation` where the mockup shows\n * four columns.\n *\n * `actionRunResult` returning `undefined` is the filter: the activity\n * collection holds far more than runs, and a publish has no verdict. An\n * entry that is not a run simply does not appear, rather than appearing\n * under a `Succeeded` that means nothing for it.\n */\nexport function HostRunHistoryCard(props: HostRunHistoryCardProps) {\n const {\n hostId,\n orgId,\n targetId,\n targetType,\n targetName = '',\n header = 'Run history',\n help = pluginDocsHelp('buildAWorkflow', {\n anchor: '#4-save-and-test',\n excerpt:\n 'Every run of this automation, including the ones a trigger ' +\n 'condition skipped — which is the answer to \"why did it not fire?\".',\n }),\n } = props\n const firestore = useFirestore()\n /**\n * The shell's zone renderer (AGL-2919), for what other plugins add to a\n * failed run; `null` outside the console shell.\n */\n const RunZone = useConsoleWidgetSlot()\n /** The automation a failed run belongs to, as the `automationRun` zone names it. */\n const zoneTarget = useMemo<ConsoleAutomationTarget | null>(\n () => (targetId && targetType ? { type: targetType, id: targetId, name: targetName } : null),\n [targetId, targetType, targetName],\n )\n /*\n * The window is NARROWED BY THE SERVER, not by the client (AGL-2292).\n *\n * A bare `limit(200)` with no ordering is not \"the most recent 200 runs\" —\n * Firestore answers an unordered limit in `__name__` order, so it is an\n * arbitrary slice of the host's whole activity feed. `activity` also holds\n * publishes, media saves and member changes, and only entries carrying a\n * run result survive the filter below, so a busy site could fill all 200\n * places with rows this card discards and report \"No runs yet\" for a\n * workflow that had run all day.\n *\n * `target.id` equality is what makes the read proportional to the card:\n * it asks for this workflow's rows rather than the site's. It carries no\n * `orderBy` deliberately — an equality plus an ordering on a second field\n * needs a composite index, and the client sort below already puts the\n * newest first. The untargeted case has no equality to pair, so it orders\n * server-side instead.\n */\n const { data: entries } = useFirestoreCollection<any>(\n () => {\n if (!hostId) return null\n const base = collection(firestore, 'hosts', hostId, 'activity')\n /*\n * `WINDOW + 1` is a PROBE, not an off-by-one (AGL-2501).\n *\n * The card used to say \"showing what we read\" by saying nothing at all.\n * Reading one document more than the ceiling turns \"there is older\n * history than this\" into a fact for the price of a single read;\n * comparing `length === WINDOW` cannot, because it is wrong in both\n * directions at exactly the count that equals the ceiling. The probe row\n * is dropped below and never rendered.\n */\n return targetId\n ? query(base, where('target.id', '==', targetId), limit(WINDOW + 1))\n : query(base, orderBy('createdAt', 'desc'), limit(WINDOW + 1))\n },\n // `targetId` belongs here: it now shapes the query, so a card that\n // switched workflows without it would go on showing the first one's runs.\n [firestore, hostId, targetId],\n { idField: '$id' },\n )\n /** The activity ceiling bit — there are older entries than were read. */\n const truncated = (entries?.length ?? 0) > WINDOW\n\n const runs = useMemo(\n () =>\n [...(entries ?? [])]\n .slice(0, WINDOW)\n .filter((entry) => !targetId || entry.target?.id === targetId)\n .map((entry) => ({ entry, result: actionRunResult(entry) }))\n .filter(\n (row): row is { entry: any; result: RunResult } =>\n Boolean(row.result),\n )\n .sort(\n (a, b) =>\n (b.entry.createdAt?.seconds ?? 0) -\n (a.entry.createdAt?.seconds ?? 0),\n )\n .map(\n ({ entry, result }): RunRow => ({\n $id: String(entry.$id),\n entry,\n result,\n trigger: String(entry.trigger ?? ''),\n // `formSubmission` → `Form submitted`.\n triggerLabel: actionTriggerLabel(entry.trigger),\n summary: actionRunSummary(entry),\n createdAtMs:\n typeof entry.createdAt?.seconds === 'number'\n ? entry.createdAt.seconds * 1000\n : null,\n }),\n ),\n [entries, targetId],\n )\n const listFilter = useListRowsFilter({\n rows: runs,\n fields: RUN_FILTER_FIELDS,\n options: RUN_FILTER_OPTIONS,\n headers: RUN_FILTER_HEADERS,\n search: RUN_SEARCH_FIELDS,\n })\n const matched = listFilter.rows\n\n /*\n * The page is a SLICE, because the rows are already in hand.\n *\n * Every run in the window has been read and paid for by the query above, so\n * a second query per page would buy nothing and cost a read. What the card\n * lacked was not a cheaper read but a control: it sliced the newest\n * twenty-five off the window and rendered them in one wall, so run\n * twenty-six was read, discarded, and unreachable — on the surface a reader\n * opens precisely to ask \"why did it not fire the time before last?\".\n */\n const [page, setPage] = useState(0)\n const [pageSize, setPageSize] = useState(TABLE_PAGE_SIZE_DEFAULT)\n // A different workflow is a different history: page three of the last one\n // is not a position in this one, and an out-of-range page renders empty\n // with no explanation, which reads as the runs having gone.\n // A narrowed list starts again at its first page, for the same reason.\n const searchKey = listFilter.gridFilter.searchWords.join(' ')\n useEffect(\n () => setPage(0),\n [targetId, hostId, listFilter.gridFilter.clauses, searchKey],\n )\n const shown = useMemo(\n () => matched.slice(page * pageSize, page * pageSize + pageSize),\n [matched, page, pageSize],\n )\n\n const { filterColumns } = listFilter\n const columns = useMemo(\n () =>\n filterColumns([\n {\n field: 'createdAtMs',\n headerName: 'Time',\n width: 120,\n renderCell: ({ row }: { row: RunRow }) => {\n const at = row.entry.createdAt?.toDate?.()\n return (\n <Tooltip title={at ? at.toLocaleString() : ''}>\n <span>{at ? at.toLocaleTimeString() : '--'}</span>\n </Tooltip>\n )\n },\n },\n {\n field: 'trigger',\n headerName: 'Trigger',\n width: 180,\n renderCell: ({ row }: { row: RunRow }) => row.triggerLabel,\n },\n {\n field: 'result',\n headerName: 'Result',\n width: 120,\n renderCell: ({ row }: { row: RunRow }) => (\n <Chip\n size=\"small\"\n variant=\"outlined\"\n color={RESULT_COLOR[row.result]}\n label={RESULT_LABEL[row.result]}\n />\n ),\n },\n {\n field: 'summary',\n headerName: 'What happened',\n flex: 1,\n minWidth: 220,\n renderCell: ({ row }: { row: RunRow }) => (\n <Stack sx={{ minWidth: 0, py: 0.75 }}>\n <Typography variant=\"body2\">{row.summary}</Typography>\n {row.entry.durationMs != null ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`${row.entry.durationMs}ms`}\n </Typography>\n ) : null}\n {/*\n What other plugins add to a failed run (AGL-2919): the\n `automationRun` zone, through the shell's gated slot.\n */}\n {RunZone && zoneTarget && row.result === 'failed' ? (\n <RunZone\n slot=\"automationRun\"\n hostId={hostId}\n orgId={orgId}\n target={zoneTarget}\n runId={row.$id}\n />\n ) : null}\n </Stack>\n ),\n },\n ] as GridColDef[]),\n [filterColumns, RunZone, zoneTarget, hostId, orgId],\n )\n\n return (\n <CardDisplay\n header={header}\n help={help}\n contentGutterX\n contentGutterY\n contentBordered=\"all\"\n >\n {runs.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No runs yet — every run of this automation is logged here, ' +\n 'including the ones a condition skipped.'}\n </Typography>\n ) : (\n <Stack spacing={1.5}>\n <ListFilterChips {...listFilter.chipsProps} />\n <ListTable\n aria-label=\"Run history\"\n rows={shown}\n columns={columns}\n {...listFilter.gridProps}\n // A failed run carries what other plugins add under its summary.\n getRowHeight={() => 'auto'}\n // `ListPagination` below pages the matches.\n hideFooter\n noRowsLabel=\"No runs match these filters\"\n />\n <ListPagination\n page={page}\n pageSize={pageSize}\n rowCount={shown.length}\n // The runs in the window that match, which is a number this card\n // genuinely holds. What it does not know is how many runs are OLDER\n // than the window, and the notice below says so rather than letting\n // the count line imply a total it cannot see.\n count={matched.length}\n onPageChange={setPage}\n onPageSizeChange={setPageSize}\n />\n {truncated ? (\n <Alert severity=\"info\">\n {`Runs found in the ${WINDOW} most recent activity entries for ` +\n 'this site. Older runs than that are recorded and are not ' +\n 'listed here.'}\n </Alert>\n ) : null}\n </Stack>\n )}\n </CardDisplay>\n )\n}\nHostRunHistoryCard.displayName = 'HostRunHistoryCard'\n\nexport default HostRunHistoryCard\n"],"names":["actionRunResult","actionRunSummary","actionTriggerLabel","useConsoleWidgetSlot","HOST_EVENT_TYPES","CardDisplay","ListFilterChips","ListPagination","ListTable","inMemoryListField","TABLE_PAGE_SIZE_DEFAULT","useListRowsFilter","Alert","Chip","Stack","Tooltip","Typography","collection","limit","orderBy","query","where","useEffect","useMemo","useState","useFirestore","useFirestoreCollection","pluginDocsHelp","WINDOW","RESULT_COLOR","succeeded","failed","skipped","RESULT_LABEL","RUN_FILTER_FIELDS","RUN_FILTER_HEADERS","createdAtMs","trigger","result","summary","RUN_FILTER_OPTIONS","map","event","value","label","Object","keys","RUN_SEARCH_FIELDS","HostRunHistoryCard","props","hostId","orgId","targetId","targetType","targetName","header","help","anchor","excerpt","firestore","RunZone","zoneTarget","type","id","name","data","entries","base","idField","truncated","length","runs","slice","filter","entry","target","row","Boolean","sort","a","b","createdAt","seconds","$id","String","triggerLabel","listFilter","rows","fields","options","headers","search","matched","page","setPage","pageSize","setPageSize","searchKey","gridFilter","searchWords","join","clauses","shown","filterColumns","columns","field","headerName","width","renderCell","at","toDate","title","toLocaleString","span","toLocaleTimeString","size","variant","color","flex","minWidth","sx","py","durationMs","slot","runId","contentGutterX","contentGutterY","contentBordered","spacing","chipsProps","aria-label","gridProps","getRowHeight","hideFooter","noRowsLabel","rowCount","count","onPageChange","onPageSizeChange","severity","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SACEA,eAAe,EACfC,gBAAgB,EAChBC,kBAAkB,QACb,4CAA2C;AAClD,SAASC,oBAAoB,QAAQ,qDAAoD;AACzF,SAASC,gBAAgB,QAAQ,mCAAkC;AAEnE,SAASC,WAAW,QAA6B,uBAAsB;AACvE,OAAOC,qBAAqB,8DAA6D;AACzF,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,SAAS,QAAQ,uDAAsD;AAChF,SAASC,iBAAiB,QAAQ,8CAA6C;AAC/E,SAASC,uBAAuB,QAAQ,8CAA6C;AACrF,SAASC,iBAAiB,QAAQ,kDAAiD;AACnF,SAASC,KAAK,EAAEC,IAAI,EAAEC,KAAK,EAAEC,OAAO,EAAEC,UAAU,QAAQ,gBAAe;AAEvE,SAASC,UAAU,EAAEC,KAAK,EAAEC,OAAO,EAAEC,KAAK,EAAEC,KAAK,QAAQ,qBAAoB;AAC7E,SAASC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACpD,SACEC,YAAY,EACZC,sBAAsB,QACjB,iCAAgC;AACvC,SAASC,cAAc,QAAQ,eAAc;AAoB7C;;;;;;;;;;;;;;;CAeC,GACD,MAAMC,SAAS;AAEf,MAAMC,eAAe;IACnBC,WAAW;IACXC,QAAQ;IACRC,SAAS;AACX;AAEA,MAAMC,eAAe;IACnBH,WAAW;IACXC,QAAQ;IACRC,SAAS;AACX;AAeA;;;;;CAKC,GACD,MAAME,oBAAoB;IACxBzB,kBAAkB,eAAe;IACjCA,kBAAkB,WAAW;IAC7BA,kBAAkB,UAAU;IAC5BA,kBAAkB,WAAW;CAC9B;AACD,MAAM0B,qBAAuD;IAC3DC,aAAa;IACbC,SAAS;IACTC,QAAQ;I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