@aglyn/plugins-workflows 1.0.0-beta.246 → 1.0.0-beta.249
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 +12 -12
- package/src/lib/components/automation-step-fields.component.d.ts +6 -1
- package/src/lib/components/automation-step-fields.component.js +34 -49
- package/src/lib/components/automation-step-fields.component.js.map +1 -1
- package/src/lib/components/element-picker-dialog.component.d.ts +39 -0
- package/src/lib/components/element-picker-dialog.component.js +185 -0
- package/src/lib/components/element-picker-dialog.component.js.map +1 -0
- package/src/lib/components/element-selector-field.component.d.ts +41 -0
- package/src/lib/components/element-selector-field.component.js +126 -0
- package/src/lib/components/element-selector-field.component.js.map +1 -0
- package/src/lib/components/host-actions-card.component.js +11 -11
- package/src/lib/components/host-actions-card.component.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/workflows/src/lib/components/host-actions-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 ACTION_MAX_STEPS,\n type AglynOrgBilling,\n checkEntitlement,\n createResourceUid,\n ELEMENT_SCOPED_SITE_EVENTS,\n HOST_EVENT_TYPES,\n hostEventLabel,\n HOST_EVENT_PAYLOAD_KEYS,\n hostEventPayloadHint,\n type HostEventType,\n isSiteEventType,\n pluginDocsHelp,\n SITE_EVENT_TYPES,\n type TriggerCombinator,\n triggerFilterProblem,\n} from '@aglyn/aglyn'\nimport { useConsoleWidgetSlot } from '@aglyn/aglyn/app-utils/console-widget-slot-context'\nimport {\n type InteractionRecipe,\n interactionRecipe,\n interactionRecipes,\n interactionRecipeStamp,\n} from '@aglyn/aglyn/plugin-manager/interaction-recipes'\nimport {\n pluginRecordListQuery,\n pluginRecordsFromRows,\n} from '@aglyn/aglyn/plugin-manager/plugin-record-lists'\nimport {\n AUTOMATION_EDITOR_ZONE,\n HOST_AUTOMATIONS_ZONE,\n OPEN_ACTION_PARAM,\n requestedActionId,\n type AutomationTarget,\n} from './workflow-zones'\nimport { CardDisplay, useConfirmationContext } 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 { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { Timestamp } from '@aglyn/shared-util-timestamp'\nimport {\n Alert,\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n ListItemText,\n Menu,\n MenuItem,\n Stack,\n Switch,\n TextField,\n Typography,\n} from '@mui/material'\nimport {\n collection,\n doc,\n setDoc,\n updateDoc,\n} from 'firebase/firestore'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport {\n ceilingedWindow,\n collectionCeiling,\n useFirestore,\n useFirestoreCollection,\n useHostResourceApi,\n useUser,\n writeGuardedBySeed,\n} from '@aglyn/tenant-feature-instance'\nimport { ACTION_TEST_RUN_API_ROUTE } from '../model/action-test-run'\nimport {\n AutomationStepFields,\n type AutomationStepKind,\n defaultStep,\n} from './automation-step-fields.component'\nimport {\n conditionRowsFromTrigger,\n conditionsFromRows,\n type ConditionRowDraft,\n EMPTY_CONDITION_ROW,\n TriggerConditionRows,\n} from './automation-trigger-conditions.component'\nimport HostRunHistoryCard from './host-run-history-card.component'\nimport {\n EDITOR_OPTION_CEILING,\n useAutomationStepPickers,\n} from './use-automation-step-pickers'\nimport { siteInteractionDocument } from '@aglyn/aglyn/app-utils/site-interactions'\nimport {\n HOST_ACTION_STEP_LABELS,\n type HostAction,\n type HostActionStepType,\n stepRunsAfterWait,\n validateHostAction,\n} from '../model/host-actions'\nimport {\n describeInteractionPlaceholder,\n interactionPlaceholders,\n} from '@aglyn/aglyn/app-utils/draft-placeholders'\n\nconst CUSTOM_EVENT_VALUE = '__custom__'\n\n/**\n * How many action documents the card reads.\n *\n * A CEILING, not a page size — see the query, which explains why this one\n * collection cannot be sliced by the server without making the count beneath\n * the list a per-page number.\n *\n * `ACTIONS_MAX_PER_HOST` is 500, so the ceiling really can bite and the probe\n * beside it is what says when it has.\n */\nconst ACTION_CEILING = 100\n\ninterface ActionDraft extends HostAction {\n id: string | null\n /** Raw custom-event text when the trigger select is on \"custom\". */\n customEvent: string\n // Structured payload conditions (AGL-557), chainable with AND/OR\n // (AGL-565) — held as rows like the steps list; legacy\n // single-`condition` docs hydrate through normalizeTriggerConditions.\n conditionRows: ConditionRowDraft[]\n conditionCombinator: TriggerCombinator\n /**\n * The recipe this draft started from (AGL-2626), so the editor can say\n * so, and what Save writes back as the action's stamp (AGL-2639): null\n * for an action begun blank, and `undefined` for a stored action from\n * before the stamp existed — which Save leaves as it found it, so an\n * edit never turns \"unknown\" into \"no recipe\".\n */\n recipe: string | null | undefined\n}\n\n\n/** Every Actions step, as the builder's \"Do\" picker offers it. */\nconst ACTION_STEP_KINDS: AutomationStepKind[] = Object.entries(\n HOST_ACTION_STEP_LABELS,\n).map(([value, label]) => ({ value, label }))\n\n\n/**\n * A stored action — or one a recipe just built — as the editor holds it.\n *\n * One conversion for both doors, because they must agree: an action that\n * round-trips through Edit and one a recipe hands over are the same shape\n * to the editor, and a field the Edit path hydrated that the recipe path\n * forgot would be a recipe whose conditions vanished on open. Site events\n * are first-class (AGL-256/266): their selector/threshold/path config is\n * kept through an edit. Structured conditions (AGL-557; chained AGL-565)\n * become rows; a legacy single-condition doc normalizes to one row.\n */\nfunction draftFromAction(\n action: Record<string, any>,\n id: string | null,\n): ActionDraft {\n const builtIn =\n HOST_EVENT_TYPES.includes(action.trigger?.event) ||\n isSiteEventType(String(action.trigger?.event ?? ''))\n return {\n id,\n name: action.name ?? '',\n trigger: {\n event: builtIn ? action.trigger.event : CUSTOM_EVENT_VALUE,\n filter: action.trigger?.filter ?? '',\n selector: action.trigger?.selector ?? '',\n threshold: action.trigger?.threshold,\n pathPattern: action.trigger?.pathPattern ?? '',\n oncePerVisitor: action.trigger?.oncePerVisitor === true,\n oncePerSession: action.trigger?.oncePerSession === true,\n everyTime: action.trigger?.everyTime === true,\n ...(Number(action.trigger?.cooldownMinutes) >= 1\n ? { cooldownMinutes: Number(action.trigger?.cooldownMinutes) }\n : {}),\n },\n steps: action.steps ?? [],\n enabled: action.enabled !== false,\n customEvent: builtIn ? '' : (action.trigger?.event ?? ''),\n conditionRows: conditionRowsFromTrigger(action.trigger),\n conditionCombinator: action.trigger?.combinator === 'or' ? 'or' : 'and',\n // A recipe stamps what it builds, and a stored action carries what it\n // was saved with — one reader for both doors, unknown kept unknown.\n recipe: interactionRecipeStamp(action),\n }\n}\n\n/** A trigger bound to one element, which makes the row an interaction. */\nconst LEAF_SELECTOR = /^\\[data-aglyn=\"leaf:.+\"\\]$/\n\n/**\n * Actions builder (AGL-148): HubSpot-style enrollment — trigger event →\n * optional filter → ordered steps (run workflow, site alert, custom\n * event, dataset append). Runs server-side via runEventActions; paid\n * feature (`actions` flag, Pro+, `actionRunsPerMonth` metered).\n */\nexport function HostActionsCard(props: {\n hostId: string\n org?: Partial<AglynOrgBilling>\n}) {\n const { hostId, org } = props\n // Org-shared data root (AGL-237). Null until the org lookup settles\n // (AGL-1061), and for a host with no owning org — the pre-migration host\n // path is gone (AGL-1050), so the dataset and list pickers stay empty\n // instead of offering rows from a path nothing else reads.\n const firestore = useFirestore()\n // Action creation is server-owned since AGL-2266 (the cap); every other\n // action write on this surface stays client-direct.\n const createResource = useHostResourceApi()\n // The caller's token, for the test run's console door.\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const { confirm } = useConfirmationContext()\n /**\n * The shell's zone renderer, for what other plugins add to automations\n * (AGL-2919); `null` outside the console shell, where there is no workspace\n * to gate on.\n */\n const ExtensionZone = useConsoleWidgetSlot()\n\n const {\n data: actionDocs,\n status: actionsStatus,\n /**\n * The action rows this card's editor is seeded from are unconfirmed by\n * the server (AGL-1358). Editing an action copies the whole stored row\n * into `draft` — name, trigger and every step — and writes all of it\n * back, so `merge: true` protects nothing and a cached seed reverts a\n * colleague's newer version of the steps nobody here touched.\n *\n * The same shape the interaction builder guards (AGL-1066); this is its\n * card twin, and it was the one that never got the guard.\n */\n fromCache: actionsFromCache,\n } = useFirestoreCollection<any>(\n /*\n * ORDERED AND CEILINGED, deliberately not paged by the query (AGL-2501) —\n * the same decision as the workflows card beside it.\n *\n * `limit(100)` alone is answered in DOCUMENT-ID order, so the window was a\n * pseudo-random hundred that the `localeCompare` below arranged\n * alphabetically, and nothing said the list was bounded.\n *\n * `collectionCeiling` does not change WHICH hundred — document-id order is\n * what the bare cap already returned. What it changes is that the order is\n * NAMED, so the obvious next edit is caught: ordering on `name` would HIDE\n * every action written without one rather than mis-sorting the list, and\n * `/api/hosts/resources` validates no field for presence while\n * `IMPORTABLE_FIELDS.actions` copies one only if the export carried it.\n *\n * The QUERY is not paged because this collection holds TWO audiences. A\n * row whose trigger names a leaf selector is an element interaction, which\n * belongs to its document and is reported below as a count rather than\n * listed; the rest are the site's actions. Both partitions are derived\n * from the rows in hand, so a server page would make \"3 interactions are\n * set up on their own elements\" mean \"3 on this page\" — a count that is a\n * window length, which is the defect this sweep keeps finding rather than\n * a shape it should add.\n */\n () =>\n collectionCeiling(\n collection(firestore, 'hosts', hostId, 'actions'),\n ACTION_CEILING,\n ),\n [firestore, hostId],\n { idField: '$id' },\n )\n const { rows: readActions, truncated: actionsTruncated } =\n ceilingedWindow<any>(actionDocs, ACTION_CEILING)\n const [draft, setDraft] = useState<ActionDraft | null>(null)\n /**\n * The editor has been opened at least once in this session.\n *\n * A LATCH rather than `draft` itself, because the pickers below key their\n * listeners on it. Tracking the dialog would tear those subscriptions down\n * on Cancel and pay for them again on the next Edit, so a merchant working\n * through ten actions would buy the same six windows ten times — worse than\n * the mount-time read this replaces. Latched, a reader who never edits pays\n * nothing and a reader who edits pays once.\n */\n const [editorOpened, setEditorOpened] = useState(false)\n if (draft && !editorOpened) setEditorOpened(true)\n /*\n * The step editor's six option lists, read on the same latch as the\n * Workflows builder's — one hook, because the two editors offer one set of\n * steps and a second copy would be a second read cost to keep in agreement.\n */\n const { pickers: stepPickers, truncated: truncatedPickers } =\n useAutomationStepPickers(hostId, editorOpened)\n const liveActions = readActions.filter((action: any) => !action.deletedAt)\n /*\n * Opens a listed action in the editor, for a widget in the `hostAutomations`\n * zone — one that drafted an action and offers to open it. Read through a\n * ref so the callback keeps one identity while the list changes beneath it,\n * and answers `false` for an id the list has not read yet.\n */\n const listedRef = useRef<any[]>(liveActions)\n listedRef.current = liveActions\n const openAction = useCallback((actionId: string) => {\n const action = listedRef.current.find((row: any) => row.$id === actionId)\n if (!action) return false\n setDraft(draftFromAction(action, action.$id))\n return true\n }, [])\n /*\n * An action the address names (AGL-3603): the Workflows section drafts one\n * there and sends the reader here to open it. Opened once the list has read\n * it, then dropped from the address so a reload does not reopen it.\n */\n const [requested, setRequested] = useState<string | null>(() =>\n typeof window === 'undefined' ? null : requestedActionId(window.location.search),\n )\n useEffect(() => {\n if (!requested || !openAction(requested)) return\n setRequested(null)\n const url = new URL(window.location.href)\n url.searchParams.delete(OPEN_ACTION_PARAM)\n window.history.replaceState(window.history.state, '', url.toString())\n }, [requested, openAction, liveActions.length])\n /**\n * Element interactions are not listed here.\n *\n * An ACTION is something the SITE does — an order was placed, a form was\n * submitted. An INTERACTION is something an ELEMENT does, and it belongs to\n * the document that holds the element: it publishes and rolls back with it,\n * travels with it, and is deleted with it. This page is the site's\n * automation list, and a nav menu's hover timing sitting in it beside \"when\n * an order is placed\" was the tell that the two had been conflated.\n *\n * These rows are the ones written BEFORE the move, still bound by selector.\n * They keep running and stay editable — on their element, in the besigner,\n * which is now the only place they appear. Counted rather than hidden\n * outright, so the page can say where they went instead of appearing to\n * have lost them.\n */\n const elementScoped = liveActions.filter((action: any) =>\n LEAF_SELECTOR.test(String(action?.trigger?.selector ?? '')),\n )\n // Sorting is safe here in a way it is not on a paged list: these rows are\n // the whole collection below the ceiling, not a slice of one.\n const actions = liveActions\n .filter((action: any) => !elementScoped.includes(action))\n .sort((a: any, b: any) =>\n String(a.name ?? '').localeCompare(String(b.name ?? '')),\n )\n // The page is a SLICE: the rows are already in hand, and both the element\n // interaction count and the alphabetical order need all of them.\n const [page, setPage] = useState(0)\n const [pageSize, setPageSize] = useState(TABLE_PAGE_SIZE_DEFAULT)\n const visibleActions = useMemo(\n () => actions.slice(page * pageSize, page * pageSize + pageSize),\n [actions, page, pageSize],\n )\n\n const patch = useCallback(\n (updater: (previous: ActionDraft) => ActionDraft) =>\n setDraft((previous) => (previous ? updater(previous) : previous)),\n [],\n )\n\n /** The saved action the editor has open, as the `automationEditor` zone names it. */\n const draftId = draft?.id ?? null\n const draftName = draft?.name ?? ''\n const editorTarget = useMemo<AutomationTarget | null>(\n () => (draftId ? { type: 'action', id: draftId, name: draftName } : null),\n // The name the editor opened with: the zone reads the automation as it is\n // stored, so a rename being typed does not make it a different one.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [draftId],\n )\n\n /**\n * Whether this workspace may open the editor at all. One gate for the\n * blank action and the recipes: a recipe is an action, so the plan that\n * carries one carries the other, and the refusal reads the same.\n */\n const actionsEntitled = useCallback(() => {\n if (checkEntitlement(org, 'actions')) return true\n enqueueSnackbar(\n 'The actions builder requires a Pro plan — see Billing to upgrade',\n { variant: 'warning', persist: false },\n )\n return false\n }, [org, enqueueSnackbar])\n\n const handleAdd = useCallback(() => {\n if (!actionsEntitled()) return\n setDraft({\n id: null,\n name: '',\n trigger: { event: 'formSubmission', filter: '' },\n steps: [defaultStep('siteAlert')],\n enabled: true,\n customEvent: '',\n conditionRows: [EMPTY_CONDITION_ROW],\n conditionCombinator: 'and',\n recipe: null,\n })\n }, [actionsEntitled])\n\n /*\n * THE RECIPES (AGL-2626).\n *\n * A recipe opens the editor prefilled and writes nothing: the draft it\n * builds is the one Save would persist, and until then it is state in\n * this card and nowhere else. The recipes are the plugins' that write them\n * (`interaction-recipes`, AGL-3080) — the CRM's \"Welcome a new lead\" is the\n * CRM's — and this card offers whatever they registered. Most open at once;\n * one that picks a record first opens a picker, and the records are listed\n * through the list source the plugin that keeps them publishes, for this\n * site — the one host-scoped piece of the feature, held here rather than in\n * the recipe.\n */\n const [recipesAnchor, setRecipesAnchor] = useState<HTMLElement | null>(null)\n const [pickFor, setPickFor] = useState<InteractionRecipe | null>(null)\n const [pickedId, setPickedId] = useState('')\n /**\n * The picker has been opened at least once — the `editorOpened` latch's\n * twin, and for the same reason: the records are read for this picker only,\n * and a reader who never opens it pays nothing.\n */\n const pickKind = pickFor?.picks?.kind ?? null\n const [pickedKind, setPickedKind] = useState<string | null>(null)\n if (pickKind && pickKind !== pickedKind) setPickedKind(pickKind)\n const { data: pickRead } = useFirestoreCollection<any>(\n () =>\n pickedKind\n ? pluginRecordListQuery(pickedKind, firestore, {\n hostId,\n limit: EDITOR_OPTION_CEILING + 1,\n })\n : null,\n [firestore, hostId, pickedKind],\n { idField: '$id' },\n )\n const { rows: pickRows, truncated: pickTruncated } = ceilingedWindow<any>(\n pickRead,\n EDITOR_OPTION_CEILING,\n )\n // What the owner leaves out (an archived form collects nothing, so a recipe\n // keyed on it would never fire) is not offered. The facts the owner shares\n // ride along to the recipe, which may shape its draft by them (AGL-3458).\n const pickOptions = pluginRecordsFromRows(pickedKind ?? '', pickRows)\n .map((record) => ({ id: record.id, name: record.name, facts: record.facts }))\n .sort((a, b) => a.name.localeCompare(b.name))\n\n /*\n * The site's forms for the trigger's \"Form is\" condition (AGL-3458), for an\n * event that carries the form's id — through the same list source the\n * recipe picker reads, latched like it: read once the editor is open on\n * such an event, and never before.\n */\n const eventCarriesFormId = Boolean(\n draft && HOST_EVENT_PAYLOAD_KEYS[draft.trigger.event as HostEventType]?.includes('formId'),\n )\n const [formConditionOpened, setFormConditionOpened] = useState(false)\n if (eventCarriesFormId && !formConditionOpened) setFormConditionOpened(true)\n const { data: formConditionRead } = useFirestoreCollection<any>(\n () =>\n formConditionOpened\n ? pluginRecordListQuery('form', firestore, {\n hostId,\n limit: EDITOR_OPTION_CEILING + 1,\n })\n : null,\n [firestore, hostId, formConditionOpened],\n { idField: '$id' },\n )\n const formOptions = pluginRecordsFromRows(\n 'form',\n ceilingedWindow<any>(formConditionRead, EDITOR_OPTION_CEILING).rows,\n )\n .map((record) => ({ id: record.id, name: record.name }))\n .sort((a, b) => a.name.localeCompare(b.name))\n\n const handleRecipe = useCallback(\n (recipe: InteractionRecipe) => {\n setRecipesAnchor(null)\n if (!actionsEntitled()) return\n if (recipe.picks) {\n setPickedId('')\n setPickFor(recipe)\n return\n }\n setDraft(draftFromAction(recipe.build(), null))\n },\n [actionsEntitled],\n )\n\n const handlePicked = useCallback(() => {\n const recipe = pickFor\n const picked = pickOptions.find((option) => option.id === pickedId)\n if (!recipe || !picked) return\n setPickFor(null)\n setDraft(draftFromAction(recipe.build({ picked }), null))\n }, [pickFor, pickOptions, pickedId])\n\n // Run log + test runs (AGL-266).\n const [runsFor, setRunsFor] = useState<any | null>(null)\n const handleTestRun = useCallback(\n async (action: any) => {\n try {\n /*\n * The console's own door, signed: a page's `events/dispatch` is a\n * tenant route this origin does not serve. The route reads the\n * trigger off the stored action and marks the run as a test, so the\n * body names only which action on which site.\n */\n const response = await authorizedFetch(\n user,\n `/api/${ACTION_TEST_RUN_API_ROUTE}`,\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, actionId: action.$id }),\n },\n )\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n return void enqueueSnackbar(payload?.error ?? 'Test run failed', {\n variant: 'warning',\n persist: false,\n })\n }\n const alerts = Array.isArray(payload?.alerts) ? payload.alerts : []\n enqueueSnackbar(\n alerts.length\n ? `Test ran — first alert: ${alerts[0].message}`\n : 'Test ran — server steps executed (see Runs)',\n { variant: 'success', persist: false },\n )\n } catch (error) {\n console.error(error)\n enqueueSnackbar('Test run failed', { variant: 'error' })\n }\n },\n [hostId, user, enqueueSnackbar],\n )\n\n const handleSave = useCallback(async () => {\n if (!draft) return\n const isCustom = draft.trigger.event === CUSTOM_EVENT_VALUE\n const candidate: HostAction = {\n name: draft.name.trim().slice(0, 60),\n trigger: {\n event: isCustom ? draft.customEvent.trim() : draft.trigger.event,\n ...(draft.trigger.filter?.trim()\n ? { filter: draft.trigger.filter.trim() }\n : {}),\n // Site-event config (AGL-256).\n ...(draft.trigger.selector?.trim()\n ? { selector: draft.trigger.selector.trim() }\n : {}),\n ...(Number(draft.trigger.threshold) > 0\n ? { threshold: Number(draft.trigger.threshold) }\n : {}),\n ...(draft.trigger.pathPattern?.trim()\n ? { pathPattern: draft.trigger.pathPattern.trim() }\n : {}),\n // Frequency caps (AGL-274).\n ...(draft.trigger.oncePerVisitor === true\n ? { oncePerVisitor: true }\n : {}),\n ...(draft.trigger.oncePerSession === true\n ? { oncePerSession: true }\n : {}),\n ...(Number(draft.trigger.cooldownMinutes) >= 1\n ? { cooldownMinutes: Number(draft.trigger.cooldownMinutes) }\n : {}),\n ...(draft.trigger.everyTime === true ? { everyTime: true } : {}),\n // Structured payload conditions (AGL-557; chained AGL-565):\n // rows keep their blank fields so validateHostAction surfaces\n // the miss. Saves always write the list shape — the legacy\n // single `condition` is only ever read, never written back.\n ...conditionsFromRows(draft.conditionRows, draft.conditionCombinator),\n },\n steps: draft.steps,\n enabled: draft.enabled !== false,\n // The stamp travels only when the draft knows one way or the other;\n // an older action's silence is kept (see interactionRecipeStamp).\n ...(draft.recipe !== undefined ? { recipe: draft.recipe } : {}),\n }\n const problem = validateHostAction(candidate)\n if (problem) {\n return void enqueueSnackbar(problem, {\n variant: 'warning',\n persist: false,\n })\n }\n try {\n const id = draft.id ?? createResourceUid()\n /**\n * Refuse an EDIT whose seed the server never confirmed (AGL-1358).\n *\n * The payload is the whole action. `merge: true` is here so the\n * frequency caps and conditions can be nulled explicitly, not to\n * protect untouched fields — there are none, they are all in the\n * payload. So a cached seed does not lose one edit, it reverts the\n * trigger and every step to whatever the cache last held, on an\n * automation that is running on a live site.\n *\n * Only the edit path. A NEW action is built from `EMPTY_*` defaults at\n * a fresh uid and can overwrite nothing; the first snapshot of any\n * listener is `fromCache: true`, so guarding a create would refuse a\n * save that was never unsafe.\n *\n * The guard WRAPS the write — the interaction builder's early return\n * is the shape you can keep while losing the protection.\n */\n /**\n * The action DOCUMENT is created by the server (AGL-2266).\n *\n * `hosts/{hostId}/actions` was in none of the host catch-all's exclusion\n * lists, so any editor could create one client-direct on any plan and\n * nothing counted them. /api/hosts/resources now owns the create and\n * holds `ACTIONS_MAX_PER_HOST` from a server read.\n *\n * Only the create moves, and it writes a SHELL. The merge-set below is\n * untouched and still carries the whole candidate — trigger, steps,\n * conditions, the explicit nulls AGL-274/557 depend on — so no field can\n * be lost to the route's allow-list, and for an existing action this\n * path does not run at all.\n */\n if (!draft.id) {\n try {\n await createResource({\n hostId,\n resource: 'action',\n id,\n data: { name: candidate.name ?? draft.name ?? 'Untitled action' },\n })\n } catch (error: any) {\n return void enqueueSnackbar(\n error?.message ?? 'Could not create the interaction',\n { variant: 'error' },\n )\n }\n }\n const verdict = await writeGuardedBySeed(\n {\n subject: 'action',\n unreadable: Boolean(draft.id) && actionsStatus === 'error',\n fromCache: Boolean(draft.id) && actionsFromCache,\n },\n async () => {\n await setDoc(\n doc(firestore, 'hosts', hostId, 'actions', id),\n {\n // The stored shape (AGL-2639), shared with the recipe-install\n // route: frequency caps overwrite explicitly (AGL-274) because\n // a merge-set keeps omitted keys, so switching one off must\n // write it out; conditions follow suit (AGL-557/565) — the\n // list + combinator write null when cleared, and the legacy\n // single `condition` is always nulled.\n ...siteInteractionDocument(candidate),\n updatedAt: Timestamp.now(),\n ...(draft.id ? {} : { createdAt: Timestamp.now() }),\n },\n { merge: true },\n )\n },\n )\n // A refusal keeps the editor open with everything that was typed.\n if (!verdict.ok) {\n return void enqueueSnackbar(verdict.message, {\n variant: 'warning',\n persist: false,\n })\n }\n setDraft(null)\n enqueueSnackbar('Action saved', { variant: 'success', persist: false })\n } catch (error) {\n console.error(error)\n enqueueSnackbar('An error has occurred', {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n }, [\n draft,\n firestore,\n createResource,\n hostId,\n enqueueSnackbar,\n actionsFromCache,\n actionsStatus,\n ])\n\n const handleDelete = useCallback(\n (action: any) => async () => {\n const confirmed = await confirm({\n title: 'Delete this action?',\n description: `\"${action.name}\" stops running on its trigger.`,\n confirmationText: 'Delete',\n confirmationButtonProps: { color: 'error' },\n })\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return\n await updateDoc(doc(firestore, 'hosts', hostId, 'actions', action.$id), {\n deletedAt: Timestamp.now(),\n })\n },\n [confirm, firestore, hostId],\n )\n\n const handleToggle = useCallback(\n (action: any) => async (event: { target: { checked: boolean } }) => {\n const enabled = event.target.checked\n /*\n * A placeholder is a value nobody has supplied yet. Switched on, the\n * step holding it fails every run and a condition holding one never\n * matches, so turning such an automation on is confirmed, naming what\n * is still missing.\n */\n const missing = enabled ? interactionPlaceholders(action) : []\n if (missing.length) {\n const confirmed = await confirm({\n title: 'Switch on with placeholders?',\n description:\n `\"${action.name}\" still has ${missing.length === 1 ? 'a placeholder' : `${missing.length} placeholders`} ` +\n `to fill in: ${missing.slice(0, 3).map(describeInteractionPlaceholder).join('; ')}` +\n `${missing.length > 3 ? '; …' : ''}. Open it with Edit to fill ` +\n `${missing.length === 1 ? 'it' : 'them'} in first.`,\n confirmationText: 'Switch on anyway',\n })\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return\n }\n await updateDoc(doc(firestore, 'hosts', hostId, 'actions', action.$id), {\n enabled,\n })\n },\n [confirm, firestore, hostId],\n )\n\n return (\n <CardDisplay\n header={'Actions'}\n help={pluginDocsHelp('actionsBuilder', { anchor: '#create-an-action' })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={1}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'When a site event fires, run automations in order — trigger a ' +\n 'workflow, show the visitor an alert, chain a custom event, or ' +\n 'write to a dataset. Pro plans and up.'}\n </Typography>\n {visibleActions.map((action: any) => {\n const missing = interactionPlaceholders(action).length\n return (\n <Stack\n key={action.$id}\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center' }}\n >\n <Switch\n size=\"small\"\n checked={action.enabled !== false}\n onChange={handleToggle(action)}\n />\n <Stack sx={{ flex: 1, minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {action.name}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\" noWrap>\n {`on ${hostEventLabel(action.trigger?.event)}` +\n ` · ${(action.steps ?? [])\n .map(\n (step: any) =>\n HOST_ACTION_STEP_LABELS[\n step.type as HostActionStepType\n ] ?? step.type,\n )\n .join(' → ')}`}\n </Typography>\n {missing ? (\n <Typography variant=\"caption\" color=\"warning.main\" noWrap>\n {missing === 1\n ? '1 placeholder to fill in'\n : `${missing} placeholders to fill in`}\n </Typography>\n ) : null}\n </Stack>\n <Button\n size=\"small\"\n onClick={() => setDraft(draftFromAction(action, action.$id))}\n >\n {'Edit'}\n </Button>\n {isSiteEventType(String(action.trigger?.event ?? '')) ? (\n // Test run (AGL-266): the server steps only, run now as a real\n // run through the console's test-run door.\n <Button size=\"small\" onClick={() => void handleTestRun(action)}>\n {'Test'}\n </Button>\n ) : null}\n <Button size=\"small\" onClick={() => setRunsFor(action)}>\n {'Runs'}\n </Button>\n <Button size=\"small\" color=\"error\" onClick={handleDelete(action)}>\n {'Delete'}\n </Button>\n </Stack>\n )\n })}\n {actions.length === 0 ? null : (\n <ListPagination\n page={page}\n pageSize={pageSize}\n rowCount={visibleActions.length}\n // The actions the card HOLDS, which is what the reader is paging\n // through — not the collection, whose other half is the element\n // interactions counted below.\n count={actions.length}\n onPageChange={setPage}\n onPageSizeChange={setPageSize}\n />\n )}\n {actionsTruncated ? (\n <Alert severity=\"info\">\n {`Showing the first ${ACTION_CEILING} rows of this site’s ` +\n 'automations, ordered by id. There are more — both the list ' +\n 'above and the interaction count below describe only what was ' +\n 'read.'}\n </Alert>\n ) : null}\n <Stack direction=\"row\" spacing={1} sx={{ alignSelf: 'flex-start' }}>\n <Button size=\"small\" color=\"primary\" onClick={handleAdd}>\n {'Add action'}\n </Button>\n <Button\n size=\"small\"\n color=\"primary\"\n aria-haspopup=\"menu\"\n aria-controls={recipesAnchor ? 'host-action-recipes' : undefined}\n aria-expanded={recipesAnchor ? true : undefined}\n onClick={(event) => setRecipesAnchor(event.currentTarget)}\n >\n {'Recipes'}\n </Button>\n {/*\n Other ways to start an automation, from plugins (AGL-2919): the\n `hostAutomations` zone, drawn through the shell's own gated slot. A\n plugin page cannot mount that slot itself, so the shell hands it\n down, and a widget here passes the gates a console page's would.\n */}\n {ExtensionZone ? (\n <ExtensionZone\n slot={HOST_AUTOMATIONS_ZONE.id}\n hostId={hostId}\n orgId={org?.$id}\n openAction={openAction}\n />\n ) : null}\n </Stack>\n <Menu\n id=\"host-action-recipes\"\n anchorEl={recipesAnchor}\n open={Boolean(recipesAnchor)}\n onClose={() => setRecipesAnchor(null)}\n >\n {interactionRecipes().map((recipe) => (\n <MenuItem key={recipe.id} onClick={() => handleRecipe(recipe)}>\n <ListItemText\n primary={recipe.title}\n secondary={recipe.description}\n slotProps={{ secondary: { sx: { whiteSpace: 'normal', maxWidth: 360 } } }}\n />\n </MenuItem>\n ))}\n </Menu>\n {/* Says where they went. A list that silently drops rows\n a reader saw last week is a list they stop trusting; this is the\n one sentence that makes the absence deliberate. */}\n {elementScoped.length ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {elementScoped.length === 1\n ? '1 interaction is set up on its own element — '\n : `${elementScoped.length} interactions are set up on their own elements — `}\n {'open the element in the besigner to edit it. Interactions ' +\n 'belong to the page they are on, so they publish and roll back ' +\n 'with it.'}\n </Typography>\n ) : null}\n </Stack>\n\n <Dialog\n open={Boolean(draft)}\n onClose={() => setDraft(null)}\n maxWidth=\"sm\"\n fullWidth\n >\n <DialogTitle>{draft?.id ? 'Edit action' : 'Add action'}</DialogTitle>\n <DialogContent\n sx={{ display: 'flex', flexDirection: 'column', gap: 1.5, pt: 1 }}\n >\n {ExtensionZone && editorTarget ? (\n <ExtensionZone\n slot={AUTOMATION_EDITOR_ZONE.id}\n hostId={hostId}\n orgId={org?.$id}\n target={editorTarget}\n openAction={openAction}\n />\n ) : null}\n {draft?.recipe ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Started from the “${\n interactionRecipe(draft.recipe)?.title ?? 'recipe'\n }” recipe — change anything, then save.`}\n </Typography>\n ) : null}\n {/*\n A short picker is worse than an empty one, because it looks\n complete: the target an author cannot find reads as deleted, and\n the step gets pointed somewhere else.\n */}\n {truncatedPickers.length > 0 ? (\n <Alert severity=\"info\" sx={{ mt: 1 }}>\n {`Offering the first ${EDITOR_OPTION_CEILING} rows, ordered by ` +\n `id, for: ${truncatedPickers.join(', ')}. This site has ` +\n 'more, so a step target may not be listed below.'}\n </Alert>\n ) : null}\n <TextField\n label=\"Name\"\n value={draft?.name ?? ''}\n onChange={(event) =>\n patch((previous) => ({ ...previous, name: event.target.value }))\n }\n size=\"small\"\n autoFocus\n sx={{ mt: 1 }}\n />\n <Stack direction=\"row\" spacing={1}>\n <TextField\n select\n label=\"Trigger event\"\n value={draft?.trigger.event ?? ''}\n onChange={(event) =>\n patch((previous) => ({\n ...previous,\n trigger: { ...previous.trigger, event: event.target.value },\n }))\n }\n size=\"small\"\n sx={{ minWidth: 180 }}\n >\n {HOST_EVENT_TYPES.map((eventType) => (\n <MenuItem key={eventType} value={eventType}>\n {hostEventLabel(eventType)}\n </MenuItem>\n ))}\n {SITE_EVENT_TYPES.map((eventType) => (\n <MenuItem key={eventType} value={eventType}>\n {`${eventType} (on page)`}\n </MenuItem>\n ))}\n <MenuItem value={CUSTOM_EVENT_VALUE}>{'Custom event…'}</MenuItem>\n </TextField>\n {draft?.trigger.event === CUSTOM_EVENT_VALUE ? (\n <TextField\n label=\"Custom event name\"\n value={draft?.customEvent ?? ''}\n onChange={(event) =>\n patch((previous) => ({\n ...previous,\n customEvent: event.target.value,\n }))\n }\n size=\"small\"\n sx={{ flex: 1 }}\n />\n ) : (\n <TextField\n label=\"Filter (optional)\"\n placeholder=\"subscribe\"\n // A comparison belongs in the conditions below: the filter's\n // evaluator is arithmetic, and `path == \"/pricing\"` throws on\n // every event, so it is refused here (AGL-3458). Otherwise,\n // what the expression — and the conditions — can name for\n // this event; nothing for an event whose payload is not\n // written down, rather than a guess.\n error={Boolean(triggerFilterProblem(draft?.trigger.filter))}\n helperText={\n triggerFilterProblem(draft?.trigger.filter) ??\n hostEventPayloadHint(draft?.trigger.event) ??\n undefined\n }\n value={draft?.trigger.filter ?? ''}\n onChange={(event) =>\n patch((previous) => ({\n ...previous,\n trigger: {\n ...previous.trigger,\n filter: event.target.value,\n },\n }))\n }\n size=\"small\"\n sx={{ flex: 1 }}\n />\n )}\n </Stack>\n {/* Structured payload conditions (AGL-557): the no-code sibling\n of the filter — e.g. only when `subscribe` is not empty.\n Chainable with AND/OR (AGL-565), rows styled like steps. */}\n <TriggerConditionRows\n rows={draft?.conditionRows ?? []}\n combinator={draft?.conditionCombinator ?? 'and'}\n onRowsChange={(update) =>\n patch((previous) => ({\n ...previous,\n conditionRows: update(previous.conditionRows),\n }))\n }\n onCombinatorChange={(combinator) =>\n patch((previous) => ({\n ...previous,\n conditionCombinator: combinator,\n }))\n }\n // \"Form is …\", picked by id, where the event names the form (AGL-3458).\n {...(eventCarriesFormId ? { formOptions } : {})}\n />\n {isSiteEventType(draft?.trigger.event ?? '') ? (\n // Site-event config (AGL-256): what/where the trigger watches.\n <Stack direction=\"row\" spacing={1}>\n {(ELEMENT_SCOPED_SITE_EVENTS as readonly string[]).includes(\n draft?.trigger.event ?? '',\n ) ? (\n <TextField\n label=\"CSS selector\"\n placeholder=\"#pricing-table\"\n value={draft?.trigger.selector ?? ''}\n onChange={(event) =>\n patch((previous) => ({\n ...previous,\n trigger: {\n ...previous.trigger,\n selector: event.target.value,\n },\n }))\n }\n size=\"small\"\n sx={{ flex: 1 }}\n />\n ) : null}\n {['scrollDepth', 'timeOnPage'].includes(\n draft?.trigger.event ?? '',\n ) ? (\n <TextField\n type=\"number\"\n label={\n draft?.trigger.event === 'scrollDepth'\n ? 'Scroll %'\n : 'Seconds'\n }\n value={draft?.trigger.threshold ?? ''}\n onChange={(event) =>\n patch((previous) => ({\n ...previous,\n trigger: {\n ...previous.trigger,\n threshold: Number(event.target.value),\n },\n }))\n }\n size=\"small\"\n sx={{ width: 120 }}\n />\n ) : null}\n <TextField\n label=\"Only on pages (optional)\"\n placeholder=\"/pricing or /blog/*\"\n value={draft?.trigger.pathPattern ?? ''}\n onChange={(event) =>\n patch((previous) => ({\n ...previous,\n trigger: {\n ...previous.trigger,\n pathPattern: event.target.value,\n },\n }))\n }\n size=\"small\"\n sx={{ flex: 1 }}\n />\n {/* Frequency caps (AGL-274). */}\n <TextField\n select\n label=\"Frequency\"\n size=\"small\"\n sx={{ minWidth: 170 }}\n value={\n draft?.trigger.oncePerVisitor\n ? 'visitor'\n : draft?.trigger.oncePerSession\n ? 'session'\n : Number(draft?.trigger.cooldownMinutes) >= 1\n ? 'cooldown'\n : draft?.trigger.everyTime\n ? 'every'\n : ''\n }\n onChange={(event) => {\n const mode = event.target.value\n patch((previous) => ({\n ...previous,\n trigger: {\n ...previous.trigger,\n // Every occurrence (AGL-562): repeatable UI\n // choreography (menu/drawer toggles).\n everyTime: mode === 'every',\n oncePerVisitor: mode === 'visitor',\n oncePerSession: mode === 'session',\n cooldownMinutes:\n mode === 'cooldown'\n ? Number(previous.trigger.cooldownMinutes) >= 1\n ? Number(previous.trigger.cooldownMinutes)\n : 60\n : undefined,\n },\n }))\n }}\n >\n <MenuItem value=\"\">{'Every matching pageview'}</MenuItem>\n <MenuItem value=\"every\">\n {'Every occurrence (repeatable)'}\n </MenuItem>\n <MenuItem value=\"session\">{'Once per session'}</MenuItem>\n <MenuItem value=\"visitor\">{'Once per visitor'}</MenuItem>\n <MenuItem value=\"cooldown\">{'With a cooldown'}</MenuItem>\n </TextField>\n {Number(draft?.trigger.cooldownMinutes) >= 1 &&\n !draft?.trigger.oncePerVisitor &&\n !draft?.trigger.oncePerSession ? (\n <TextField\n type=\"number\"\n label=\"Cooldown (minutes)\"\n size=\"small\"\n sx={{ width: 150 }}\n value={draft?.trigger.cooldownMinutes ?? 60}\n onChange={(event) =>\n patch((previous) => ({\n ...previous,\n trigger: {\n ...previous.trigger,\n cooldownMinutes: Number(event.target.value),\n },\n }))\n }\n />\n ) : null}\n </Stack>\n ) : null}\n <Typography variant=\"overline\" color=\"text.secondary\">\n {'Steps (run in order)'}\n </Typography>\n {(draft?.steps ?? []).map((step, index) => (\n <AutomationStepFields\n key={index}\n step={step}\n index={index}\n kind={step.type}\n kinds={ACTION_STEP_KINDS}\n stepForKind={(value) => defaultStep(value as HostActionStepType)}\n pickers={stepPickers}\n onSteps={(update) =>\n patch((previous) => ({\n ...previous,\n steps: update(previous.steps),\n }))\n }\n replyContext={{\n event: draft?.trigger.event,\n afterWait: stepRunsAfterWait(draft?.steps, index),\n }}\n />\n ))}\n <Button\n size=\"small\"\n sx={{ alignSelf: 'flex-start' }}\n disabled={(draft?.steps.length ?? 0) >= ACTION_MAX_STEPS}\n onClick={() =>\n patch((previous) => ({\n ...previous,\n steps: [...previous.steps, defaultStep('siteAlert')],\n }))\n }\n >\n {'Add step'}\n </Button>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setDraft(null)}>{'Cancel'}</Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={!draft?.name.trim()}\n onClick={handleSave}\n >\n {'Save action'}\n </Button>\n </DialogActions>\n </Dialog>\n <Dialog\n open={Boolean(pickFor)}\n onClose={() => setPickFor(null)}\n maxWidth=\"xs\"\n fullWidth\n >\n <DialogTitle>{pickFor?.title ?? ''}</DialogTitle>\n <DialogContent\n sx={{ display: 'flex', flexDirection: 'column', gap: 1.5, pt: 1 }}\n >\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`${pickFor?.picks?.prompt ?? ''} The action opens ready to edit; ` +\n 'nothing is saved until you save it.'}\n </Typography>\n {pickTruncated ? (\n <Alert severity=\"info\">\n {`Offering the first ${EDITOR_OPTION_CEILING} ${pickFor?.picks?.plural ?? ''}, ` +\n `ordered by id. This site has more, so the ` +\n `${(pickFor?.picks?.label ?? '').toLowerCase()} you want may not be listed.`}\n </Alert>\n ) : null}\n {pickOptions.length ? (\n <TextField\n select\n label={pickFor?.picks?.label ?? ''}\n value={pickedId}\n onChange={(event) => setPickedId(event.target.value)}\n size=\"small\"\n sx={{ mt: 1 }}\n >\n {pickOptions.map((option) => (\n <MenuItem key={option.id} value={option.id}>\n {option.name}\n </MenuItem>\n ))}\n </TextField>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {pickFor?.picks?.none ?? ''}\n </Typography>\n )}\n </DialogContent>\n <DialogActions>\n <Button color=\"inherit\" onClick={() => setPickFor(null)}>\n {'Cancel'}\n </Button>\n <Button\n variant=\"contained\"\n disabled={!pickedId}\n onClick={handlePicked}\n >\n {'Use recipe'}\n </Button>\n </DialogActions>\n </Dialog>\n <Dialog\n open={Boolean(runsFor)}\n onClose={() => setRunsFor(null)}\n // md: the history's four columns fit without the table scrolling.\n maxWidth=\"md\"\n fullWidth\n >\n <DialogTitle>{`Runs — ${runsFor?.name ?? ''}`}</DialogTitle>\n <DialogContent>\n {runsFor ? (\n <HostRunHistoryCard\n hostId={hostId}\n orgId={org?.$id}\n targetId={runsFor.$id}\n targetType=\"action\"\n targetName={runsFor.name ?? ''}\n header=\"Recent runs\"\n />\n ) : null}\n </DialogContent>\n <DialogActions>\n <Button color=\"inherit\" onClick={() => setRunsFor(null)}>\n {'Close'}\n </Button>\n </DialogActions>\n </Dialog>\n </CardDisplay>\n )\n}\nHostActionsCard.displayName = 'HostActionsCard'\n\nexport default HostActionsCard\n"],"names":["ACTION_MAX_STEPS","checkEntitlement","createResourceUid","ELEMENT_SCOPED_SITE_EVENTS","HOST_EVENT_TYPES","hostEventLabel","HOST_EVENT_PAYLOAD_KEYS","hostEventPayloadHint","isSiteEventType","pluginDocsHelp","SITE_EVENT_TYPES","triggerFilterProblem","useConsoleWidgetSlot","interactionRecipe","interactionRecipes","interactionRecipeStamp","pluginRecordListQuery","pluginRecordsFromRows","AUTOMATION_EDITOR_ZONE","HOST_AUTOMATIONS_ZONE","OPEN_ACTION_PARAM","requestedActionId","CardDisplay","useConfirmationContext","ListPagination","TABLE_PAGE_SIZE_DEFAULT","useSnackbar","authorizedFetch","Timestamp","Alert","Button","Dialog","DialogActions","DialogContent","DialogTitle","ListItemText","Menu","MenuItem","Stack","Switch","TextField","Typography","collection","doc","setDoc","updateDoc","useCallback","useEffect","useMemo","useRef","useState","ceilingedWindow","collectionCeiling","useFirestore","useFirestoreCollection","useHostResourceApi","useUser","writeGuardedBySeed","ACTION_TEST_RUN_API_ROUTE","AutomationStepFields","defaultStep","conditionRowsFromTrigger","conditionsFromRows","EMPTY_CONDITION_ROW","TriggerConditionRows","HostRunHistoryCard","EDITOR_OPTION_CEILING","useAutomationStepPickers","siteInteractionDocument","HOST_ACTION_STEP_LABELS","stepRunsAfterWait","validateHostAction","describeInteractionPlaceholder","interactionPlaceholders","CUSTOM_EVENT_VALUE","ACTION_CEILING","ACTION_STEP_KINDS","Object","entries","map","value","label","draftFromAction","action","id","builtIn","includes","trigger","event","String","name","filter","selector","threshold","pathPattern","oncePerVisitor","oncePerSession","everyTime","Number","cooldownMinutes","steps","enabled","customEvent","conditionRows","conditionCombinator","combinator","recipe","LEAF_SELECTOR","HostActionsCard","props","runsFor","pickFor","hostId","org","firestore","createResource","data","user","enqueueSnackbar","confirm","ExtensionZone","actionDocs","status","actionsStatus","fromCache","actionsFromCache","idField","rows","readActions","truncated","actionsTruncated","draft","setDraft","editorOpened","setEditorOpened","pickers","stepPickers","truncatedPickers","liveActions","deletedAt","listedRef","current","openAction","actionId","find","row","$id","requested","setRequested","window","location","search","url","URL","href","searchParams","delete","history","replaceState","state","toString","length","elementScoped","test","actions","sort","a","b","localeCompare","page","setPage","pageSize","setPageSize","visibleActions","slice","patch","updater","previous","draftId","draftName","editorTarget","type","actionsEntitled","variant","persist","handleAdd","recipesAnchor","setRecipesAnchor","setPickFor","pickedId","setPickedId","pickKind","picks","kind","pickedKind","setPickedKind","pickRead","limit","pickRows","pickTruncated","pickOptions","record","facts","eventCarriesFormId","Boolean","formConditionOpened","setFormConditionOpened","formConditionRead","formOptions","handleRecipe","build","handlePicked","picked","option","setRunsFor","handleTestRun","response","method","headers","body","JSON","stringify","payload","json","catch","ok","error","alerts","Array","isArray","message","console","handleSave","isCustom","candidate","trim","undefined","problem","resource","verdict","subject","unreadable","updatedAt","now","createdAt","merge","allowDuplicate","handleDelete","confirmed","title","description","confirmationText","confirmationButtonProps","color","then","handleToggle","target","checked","missing","join","header","help","anchor","contentGutterX","contentGutterY","spacing","direction","sx","alignItems","size","onChange","flex","minWidth","noWrap","step","onClick","rowCount","count","onPageChange","onPageSizeChange","severity","alignSelf","aria-haspopup","aria-controls","aria-expanded","currentTarget","slot","orgId","anchorEl","open","onClose","primary","secondary","slotProps","whiteSpace","maxWidth","fullWidth","display","flexDirection","gap","pt","mt","autoFocus","select","eventType","placeholder","helperText","onRowsChange","update","onCombinatorChange","width","mode","index","kinds","stepForKind","onSteps","replyContext","afterWait","disabled","prompt","plural","toLowerCase","none","targetId","targetType","targetName","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SACEA,gBAAgB,EAEhBC,gBAAgB,EAChBC,iBAAiB,EACjBC,0BA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zD;kCACE6E,wBACC,KAAC7C;4BACC+C,QAAQA;4BACR+K,KAAK,EAAE9K,uBAAAA,IAAKiC,GAAG;4BACfiL,UAAUrN,QAAQoC,GAAG;4BACrBkL,YAAW;4BACXC,UAAU,GAAEvN,gBAAAA,QAAQpB,IAAI,YAAZoB,gBAAgB;4BAC5BsJ,QAAO;6BAEP;;kCAEN,KAACpO;kCACC,cAAA,KAACF;4BAAO+N,OAAM;4BAAUsB,SAAS,IAAM7D,WAAW;sCAC/C;;;;;;;AAMb;AACA1G,gBAAgB0N,WAAW,GAAG;AAE9B,eAAe1N,gBAAe"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/workflows/src/lib/components/host-actions-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 ACTION_MAX_STEPS,\n type AglynOrgBilling,\n checkEntitlement,\n createResourceUid,\n ELEMENT_SCOPED_SITE_EVENTS,\n HOST_EVENT_TYPES,\n hostEventLabel,\n HOST_EVENT_PAYLOAD_KEYS,\n hostEventPayloadHint,\n type HostEventType,\n isSiteEventType,\n pluginDocsHelp,\n SITE_EVENT_TYPES,\n type TriggerCombinator,\n triggerFilterProblem,\n} from '@aglyn/aglyn'\nimport { useConsoleWidgetSlot } from '@aglyn/aglyn/app-utils/console-widget-slot-context'\nimport {\n type InteractionRecipe,\n interactionRecipe,\n interactionRecipes,\n interactionRecipeStamp,\n} from '@aglyn/aglyn/plugin-manager/interaction-recipes'\nimport {\n pluginRecordListQuery,\n pluginRecordsFromRows,\n} from '@aglyn/aglyn/plugin-manager/plugin-record-lists'\nimport {\n AUTOMATION_EDITOR_ZONE,\n HOST_AUTOMATIONS_ZONE,\n OPEN_ACTION_PARAM,\n requestedActionId,\n type AutomationTarget,\n} from './workflow-zones'\nimport { CardDisplay, useConfirmationContext } 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 { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { Timestamp } from '@aglyn/shared-util-timestamp'\nimport {\n Alert,\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n ListItemText,\n Menu,\n MenuItem,\n Stack,\n Switch,\n TextField,\n Typography,\n} from '@mui/material'\nimport {\n collection,\n doc,\n setDoc,\n updateDoc,\n} from 'firebase/firestore'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport {\n ceilingedWindow,\n collectionCeiling,\n useFirestore,\n useFirestoreCollection,\n useHostResourceApi,\n useUser,\n writeGuardedBySeed,\n} from '@aglyn/tenant-feature-instance'\nimport { ACTION_TEST_RUN_API_ROUTE } from '../model/action-test-run'\nimport {\n AutomationStepFields,\n type AutomationStepKind,\n defaultStep,\n} from './automation-step-fields.component'\nimport { ElementSelectorField } from './element-selector-field.component'\nimport {\n conditionRowsFromTrigger,\n conditionsFromRows,\n type ConditionRowDraft,\n EMPTY_CONDITION_ROW,\n TriggerConditionRows,\n} from './automation-trigger-conditions.component'\nimport HostRunHistoryCard from './host-run-history-card.component'\nimport {\n EDITOR_OPTION_CEILING,\n useAutomationStepPickers,\n} from './use-automation-step-pickers'\nimport { siteInteractionDocument } from '@aglyn/aglyn/app-utils/site-interactions'\nimport {\n HOST_ACTION_STEP_LABELS,\n type HostAction,\n type HostActionStepType,\n stepRunsAfterWait,\n validateHostAction,\n} from '../model/host-actions'\nimport {\n describeInteractionPlaceholder,\n interactionPlaceholders,\n} from '@aglyn/aglyn/app-utils/draft-placeholders'\n\nconst CUSTOM_EVENT_VALUE = '__custom__'\n\n/**\n * How many action documents the card reads.\n *\n * A CEILING, not a page size — see the query, which explains why this one\n * collection cannot be sliced by the server without making the count beneath\n * the list a per-page number.\n *\n * `ACTIONS_MAX_PER_HOST` is 500, so the ceiling really can bite and the probe\n * beside it is what says when it has.\n */\nconst ACTION_CEILING = 100\n\ninterface ActionDraft extends HostAction {\n id: string | null\n /** Raw custom-event text when the trigger select is on \"custom\". */\n customEvent: string\n // Structured payload conditions (AGL-557), chainable with AND/OR\n // (AGL-565) — held as rows like the steps list; legacy\n // single-`condition` docs hydrate through normalizeTriggerConditions.\n conditionRows: ConditionRowDraft[]\n conditionCombinator: TriggerCombinator\n /**\n * The recipe this draft started from (AGL-2626), so the editor can say\n * so, and what Save writes back as the action's stamp (AGL-2639): null\n * for an action begun blank, and `undefined` for a stored action from\n * before the stamp existed — which Save leaves as it found it, so an\n * edit never turns \"unknown\" into \"no recipe\".\n */\n recipe: string | null | undefined\n}\n\n\n/** Every Actions step, as the builder's \"Do\" picker offers it. */\nconst ACTION_STEP_KINDS: AutomationStepKind[] = Object.entries(\n HOST_ACTION_STEP_LABELS,\n).map(([value, label]) => ({ value, label }))\n\n\n/**\n * A stored action — or one a recipe just built — as the editor holds it.\n *\n * One conversion for both doors, because they must agree: an action that\n * round-trips through Edit and one a recipe hands over are the same shape\n * to the editor, and a field the Edit path hydrated that the recipe path\n * forgot would be a recipe whose conditions vanished on open. Site events\n * are first-class (AGL-256/266): their selector/threshold/path config is\n * kept through an edit. Structured conditions (AGL-557; chained AGL-565)\n * become rows; a legacy single-condition doc normalizes to one row.\n */\nfunction draftFromAction(\n action: Record<string, any>,\n id: string | null,\n): ActionDraft {\n const builtIn =\n HOST_EVENT_TYPES.includes(action.trigger?.event) ||\n isSiteEventType(String(action.trigger?.event ?? ''))\n return {\n id,\n name: action.name ?? '',\n trigger: {\n event: builtIn ? action.trigger.event : CUSTOM_EVENT_VALUE,\n filter: action.trigger?.filter ?? '',\n selector: action.trigger?.selector ?? '',\n threshold: action.trigger?.threshold,\n pathPattern: action.trigger?.pathPattern ?? '',\n oncePerVisitor: action.trigger?.oncePerVisitor === true,\n oncePerSession: action.trigger?.oncePerSession === true,\n everyTime: action.trigger?.everyTime === true,\n ...(Number(action.trigger?.cooldownMinutes) >= 1\n ? { cooldownMinutes: Number(action.trigger?.cooldownMinutes) }\n : {}),\n },\n steps: action.steps ?? [],\n enabled: action.enabled !== false,\n customEvent: builtIn ? '' : (action.trigger?.event ?? ''),\n conditionRows: conditionRowsFromTrigger(action.trigger),\n conditionCombinator: action.trigger?.combinator === 'or' ? 'or' : 'and',\n // A recipe stamps what it builds, and a stored action carries what it\n // was saved with — one reader for both doors, unknown kept unknown.\n recipe: interactionRecipeStamp(action),\n }\n}\n\n/** A trigger bound to one element, which makes the row an interaction. */\nconst LEAF_SELECTOR = /^\\[data-aglyn=\"leaf:.+\"\\]$/\n\n/**\n * Actions builder (AGL-148): HubSpot-style enrollment — trigger event →\n * optional filter → ordered steps (run workflow, site alert, custom\n * event, dataset append). Runs server-side via runEventActions; paid\n * feature (`actions` flag, Pro+, `actionRunsPerMonth` metered).\n */\nexport function HostActionsCard(props: {\n hostId: string\n org?: Partial<AglynOrgBilling>\n}) {\n const { hostId, org } = props\n // Org-shared data root (AGL-237). Null until the org lookup settles\n // (AGL-1061), and for a host with no owning org — the pre-migration host\n // path is gone (AGL-1050), so the dataset and list pickers stay empty\n // instead of offering rows from a path nothing else reads.\n const firestore = useFirestore()\n // Action creation is server-owned since AGL-2266 (the cap); every other\n // action write on this surface stays client-direct.\n const createResource = useHostResourceApi()\n // The caller's token, for the test run's console door.\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const { confirm } = useConfirmationContext()\n /**\n * The shell's zone renderer, for what other plugins add to automations\n * (AGL-2919); `null` outside the console shell, where there is no workspace\n * to gate on.\n */\n const ExtensionZone = useConsoleWidgetSlot()\n\n const {\n data: actionDocs,\n status: actionsStatus,\n /**\n * The action rows this card's editor is seeded from are unconfirmed by\n * the server (AGL-1358). Editing an action copies the whole stored row\n * into `draft` — name, trigger and every step — and writes all of it\n * back, so `merge: true` protects nothing and a cached seed reverts a\n * colleague's newer version of the steps nobody here touched.\n *\n * The same shape the interaction builder guards (AGL-1066); this is its\n * card twin, and it was the one that never got the guard.\n */\n fromCache: actionsFromCache,\n } = useFirestoreCollection<any>(\n /*\n * ORDERED AND CEILINGED, deliberately not paged by the query (AGL-2501) —\n * the same decision as the workflows card beside it.\n *\n * `limit(100)` alone is answered in DOCUMENT-ID order, so the window was a\n * pseudo-random hundred that the `localeCompare` below arranged\n * alphabetically, and nothing said the list was bounded.\n *\n * `collectionCeiling` does not change WHICH hundred — document-id order is\n * what the bare cap already returned. What it changes is that the order is\n * NAMED, so the obvious next edit is caught: ordering on `name` would HIDE\n * every action written without one rather than mis-sorting the list, and\n * `/api/hosts/resources` validates no field for presence while\n * `IMPORTABLE_FIELDS.actions` copies one only if the export carried it.\n *\n * The QUERY is not paged because this collection holds TWO audiences. A\n * row whose trigger names a leaf selector is an element interaction, which\n * belongs to its document and is reported below as a count rather than\n * listed; the rest are the site's actions. Both partitions are derived\n * from the rows in hand, so a server page would make \"3 interactions are\n * set up on their own elements\" mean \"3 on this page\" — a count that is a\n * window length, which is the defect this sweep keeps finding rather than\n * a shape it should add.\n */\n () =>\n collectionCeiling(\n collection(firestore, 'hosts', hostId, 'actions'),\n ACTION_CEILING,\n ),\n [firestore, hostId],\n { idField: '$id' },\n )\n const { rows: readActions, truncated: actionsTruncated } =\n ceilingedWindow<any>(actionDocs, ACTION_CEILING)\n const [draft, setDraft] = useState<ActionDraft | null>(null)\n /**\n * The editor has been opened at least once in this session.\n *\n * A LATCH rather than `draft` itself, because the pickers below key their\n * listeners on it. Tracking the dialog would tear those subscriptions down\n * on Cancel and pay for them again on the next Edit, so a merchant working\n * through ten actions would buy the same six windows ten times — worse than\n * the mount-time read this replaces. Latched, a reader who never edits pays\n * nothing and a reader who edits pays once.\n */\n const [editorOpened, setEditorOpened] = useState(false)\n if (draft && !editorOpened) setEditorOpened(true)\n /*\n * The step editor's six option lists, read on the same latch as the\n * Workflows builder's — one hook, because the two editors offer one set of\n * steps and a second copy would be a second read cost to keep in agreement.\n */\n const { pickers: stepPickers, truncated: truncatedPickers } =\n useAutomationStepPickers(hostId, editorOpened)\n const liveActions = readActions.filter((action: any) => !action.deletedAt)\n /*\n * Opens a listed action in the editor, for a widget in the `hostAutomations`\n * zone — one that drafted an action and offers to open it. Read through a\n * ref so the callback keeps one identity while the list changes beneath it,\n * and answers `false` for an id the list has not read yet.\n */\n const listedRef = useRef<any[]>(liveActions)\n listedRef.current = liveActions\n const openAction = useCallback((actionId: string) => {\n const action = listedRef.current.find((row: any) => row.$id === actionId)\n if (!action) return false\n setDraft(draftFromAction(action, action.$id))\n return true\n }, [])\n /*\n * An action the address names (AGL-3603): the Workflows section drafts one\n * there and sends the reader here to open it. Opened once the list has read\n * it, then dropped from the address so a reload does not reopen it.\n */\n const [requested, setRequested] = useState<string | null>(() =>\n typeof window === 'undefined' ? null : requestedActionId(window.location.search),\n )\n useEffect(() => {\n if (!requested || !openAction(requested)) return\n setRequested(null)\n const url = new URL(window.location.href)\n url.searchParams.delete(OPEN_ACTION_PARAM)\n window.history.replaceState(window.history.state, '', url.toString())\n }, [requested, openAction, liveActions.length])\n /**\n * Element interactions are not listed here.\n *\n * An ACTION is something the SITE does — an order was placed, a form was\n * submitted. An INTERACTION is something an ELEMENT does, and it belongs to\n * the document that holds the element: it publishes and rolls back with it,\n * travels with it, and is deleted with it. This page is the site's\n * automation list, and a nav menu's hover timing sitting in it beside \"when\n * an order is placed\" was the tell that the two had been conflated.\n *\n * These rows are the ones written BEFORE the move, still bound by selector.\n * They keep running and stay editable — on their element, in the besigner,\n * which is now the only place they appear. Counted rather than hidden\n * outright, so the page can say where they went instead of appearing to\n * have lost them.\n */\n const elementScoped = liveActions.filter((action: any) =>\n LEAF_SELECTOR.test(String(action?.trigger?.selector ?? '')),\n )\n // Sorting is safe here in a way it is not on a paged list: these rows are\n // the whole collection below the ceiling, not a slice of one.\n const actions = liveActions\n .filter((action: any) => !elementScoped.includes(action))\n .sort((a: any, b: any) =>\n String(a.name ?? '').localeCompare(String(b.name ?? '')),\n )\n // The page is a SLICE: the rows are already in hand, and both the element\n // interaction count and the alphabetical order need all of them.\n const [page, setPage] = useState(0)\n const [pageSize, setPageSize] = useState(TABLE_PAGE_SIZE_DEFAULT)\n const visibleActions = useMemo(\n () => actions.slice(page * pageSize, page * pageSize + pageSize),\n [actions, page, pageSize],\n )\n\n const patch = useCallback(\n (updater: (previous: ActionDraft) => ActionDraft) =>\n setDraft((previous) => (previous ? updater(previous) : previous)),\n [],\n )\n\n /** The saved action the editor has open, as the `automationEditor` zone names it. */\n const draftId = draft?.id ?? null\n const draftName = draft?.name ?? ''\n const editorTarget = useMemo<AutomationTarget | null>(\n () => (draftId ? { type: 'action', id: draftId, name: draftName } : null),\n // The name the editor opened with: the zone reads the automation as it is\n // stored, so a rename being typed does not make it a different one.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [draftId],\n )\n\n /**\n * Whether this workspace may open the editor at all. One gate for the\n * blank action and the recipes: a recipe is an action, so the plan that\n * carries one carries the other, and the refusal reads the same.\n */\n const actionsEntitled = useCallback(() => {\n if (checkEntitlement(org, 'actions')) return true\n enqueueSnackbar(\n 'The actions builder requires a Pro plan — see Billing to upgrade',\n { variant: 'warning', persist: false },\n )\n return false\n }, [org, enqueueSnackbar])\n\n const handleAdd = useCallback(() => {\n if (!actionsEntitled()) return\n setDraft({\n id: null,\n name: '',\n trigger: { event: 'formSubmission', filter: '' },\n steps: [defaultStep('siteAlert')],\n enabled: true,\n customEvent: '',\n conditionRows: [EMPTY_CONDITION_ROW],\n conditionCombinator: 'and',\n recipe: null,\n })\n }, [actionsEntitled])\n\n /*\n * THE RECIPES (AGL-2626).\n *\n * A recipe opens the editor prefilled and writes nothing: the draft it\n * builds is the one Save would persist, and until then it is state in\n * this card and nowhere else. The recipes are the plugins' that write them\n * (`interaction-recipes`, AGL-3080) — the CRM's \"Welcome a new lead\" is the\n * CRM's — and this card offers whatever they registered. Most open at once;\n * one that picks a record first opens a picker, and the records are listed\n * through the list source the plugin that keeps them publishes, for this\n * site — the one host-scoped piece of the feature, held here rather than in\n * the recipe.\n */\n const [recipesAnchor, setRecipesAnchor] = useState<HTMLElement | null>(null)\n const [pickFor, setPickFor] = useState<InteractionRecipe | null>(null)\n const [pickedId, setPickedId] = useState('')\n /**\n * The picker has been opened at least once — the `editorOpened` latch's\n * twin, and for the same reason: the records are read for this picker only,\n * and a reader who never opens it pays nothing.\n */\n const pickKind = pickFor?.picks?.kind ?? null\n const [pickedKind, setPickedKind] = useState<string | null>(null)\n if (pickKind && pickKind !== pickedKind) setPickedKind(pickKind)\n const { data: pickRead } = useFirestoreCollection<any>(\n () =>\n pickedKind\n ? pluginRecordListQuery(pickedKind, firestore, {\n hostId,\n limit: EDITOR_OPTION_CEILING + 1,\n })\n : null,\n [firestore, hostId, pickedKind],\n { idField: '$id' },\n )\n const { rows: pickRows, truncated: pickTruncated } = ceilingedWindow<any>(\n pickRead,\n EDITOR_OPTION_CEILING,\n )\n // What the owner leaves out (an archived form collects nothing, so a recipe\n // keyed on it would never fire) is not offered. The facts the owner shares\n // ride along to the recipe, which may shape its draft by them (AGL-3458).\n const pickOptions = pluginRecordsFromRows(pickedKind ?? '', pickRows)\n .map((record) => ({ id: record.id, name: record.name, facts: record.facts }))\n .sort((a, b) => a.name.localeCompare(b.name))\n\n /*\n * The site's forms for the trigger's \"Form is\" condition (AGL-3458), for an\n * event that carries the form's id — through the same list source the\n * recipe picker reads, latched like it: read once the editor is open on\n * such an event, and never before.\n */\n const eventCarriesFormId = Boolean(\n draft && HOST_EVENT_PAYLOAD_KEYS[draft.trigger.event as HostEventType]?.includes('formId'),\n )\n const [formConditionOpened, setFormConditionOpened] = useState(false)\n if (eventCarriesFormId && !formConditionOpened) setFormConditionOpened(true)\n const { data: formConditionRead } = useFirestoreCollection<any>(\n () =>\n formConditionOpened\n ? pluginRecordListQuery('form', firestore, {\n hostId,\n limit: EDITOR_OPTION_CEILING + 1,\n })\n : null,\n [firestore, hostId, formConditionOpened],\n { idField: '$id' },\n )\n const formOptions = pluginRecordsFromRows(\n 'form',\n ceilingedWindow<any>(formConditionRead, EDITOR_OPTION_CEILING).rows,\n )\n .map((record) => ({ id: record.id, name: record.name }))\n .sort((a, b) => a.name.localeCompare(b.name))\n\n const handleRecipe = useCallback(\n (recipe: InteractionRecipe) => {\n setRecipesAnchor(null)\n if (!actionsEntitled()) return\n if (recipe.picks) {\n setPickedId('')\n setPickFor(recipe)\n return\n }\n setDraft(draftFromAction(recipe.build(), null))\n },\n [actionsEntitled],\n )\n\n const handlePicked = useCallback(() => {\n const recipe = pickFor\n const picked = pickOptions.find((option) => option.id === pickedId)\n if (!recipe || !picked) return\n setPickFor(null)\n setDraft(draftFromAction(recipe.build({ picked }), null))\n }, [pickFor, pickOptions, pickedId])\n\n // Run log + test runs (AGL-266).\n const [runsFor, setRunsFor] = useState<any | null>(null)\n const handleTestRun = useCallback(\n async (action: any) => {\n try {\n /*\n * The console's own door, signed: a page's `events/dispatch` is a\n * tenant route this origin does not serve. The route reads the\n * trigger off the stored action and marks the run as a test, so the\n * body names only which action on which site.\n */\n const response = await authorizedFetch(\n user,\n `/api/${ACTION_TEST_RUN_API_ROUTE}`,\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, actionId: action.$id }),\n },\n )\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n return void enqueueSnackbar(payload?.error ?? 'Test run failed', {\n variant: 'warning',\n persist: false,\n })\n }\n const alerts = Array.isArray(payload?.alerts) ? payload.alerts : []\n enqueueSnackbar(\n alerts.length\n ? `Test ran — first alert: ${alerts[0].message}`\n : 'Test ran — server steps executed (see Runs)',\n { variant: 'success', persist: false },\n )\n } catch (error) {\n console.error(error)\n enqueueSnackbar('Test run failed', { variant: 'error' })\n }\n },\n [hostId, user, enqueueSnackbar],\n )\n\n const handleSave = useCallback(async () => {\n if (!draft) return\n const isCustom = draft.trigger.event === CUSTOM_EVENT_VALUE\n const candidate: HostAction = {\n name: draft.name.trim().slice(0, 60),\n trigger: {\n event: isCustom ? draft.customEvent.trim() : draft.trigger.event,\n ...(draft.trigger.filter?.trim()\n ? { filter: draft.trigger.filter.trim() }\n : {}),\n // Site-event config (AGL-256).\n ...(draft.trigger.selector?.trim()\n ? { selector: draft.trigger.selector.trim() }\n : {}),\n ...(Number(draft.trigger.threshold) > 0\n ? { threshold: Number(draft.trigger.threshold) }\n : {}),\n ...(draft.trigger.pathPattern?.trim()\n ? { pathPattern: draft.trigger.pathPattern.trim() }\n : {}),\n // Frequency caps (AGL-274).\n ...(draft.trigger.oncePerVisitor === true\n ? { oncePerVisitor: true }\n : {}),\n ...(draft.trigger.oncePerSession === true\n ? { oncePerSession: true }\n : {}),\n ...(Number(draft.trigger.cooldownMinutes) >= 1\n ? { cooldownMinutes: Number(draft.trigger.cooldownMinutes) }\n : {}),\n ...(draft.trigger.everyTime === true ? { everyTime: true } : {}),\n // Structured payload conditions (AGL-557; chained AGL-565):\n // rows keep their blank fields so validateHostAction surfaces\n // the miss. Saves always write the list shape — the legacy\n // single `condition` is only ever read, never written back.\n ...conditionsFromRows(draft.conditionRows, draft.conditionCombinator),\n },\n steps: draft.steps,\n enabled: draft.enabled !== false,\n // The stamp travels only when the draft knows one way or the other;\n // an older action's silence is kept (see interactionRecipeStamp).\n ...(draft.recipe !== undefined ? { recipe: draft.recipe } : {}),\n }\n const problem = validateHostAction(candidate)\n if (problem) {\n return void enqueueSnackbar(problem, {\n variant: 'warning',\n persist: false,\n })\n }\n try {\n const id = draft.id ?? createResourceUid()\n /**\n * Refuse an EDIT whose seed the server never confirmed (AGL-1358).\n *\n * The payload is the whole action. `merge: true` is here so the\n * frequency caps and conditions can be nulled explicitly, not to\n * protect untouched fields — there are none, they are all in the\n * payload. So a cached seed does not lose one edit, it reverts the\n * trigger and every step to whatever the cache last held, on an\n * automation that is running on a live site.\n *\n * Only the edit path. A NEW action is built from `EMPTY_*` defaults at\n * a fresh uid and can overwrite nothing; the first snapshot of any\n * listener is `fromCache: true`, so guarding a create would refuse a\n * save that was never unsafe.\n *\n * The guard WRAPS the write — the interaction builder's early return\n * is the shape you can keep while losing the protection.\n */\n /**\n * The action DOCUMENT is created by the server (AGL-2266).\n *\n * `hosts/{hostId}/actions` was in none of the host catch-all's exclusion\n * lists, so any editor could create one client-direct on any plan and\n * nothing counted them. /api/hosts/resources now owns the create and\n * holds `ACTIONS_MAX_PER_HOST` from a server read.\n *\n * Only the create moves, and it writes a SHELL. The merge-set below is\n * untouched and still carries the whole candidate — trigger, steps,\n * conditions, the explicit nulls AGL-274/557 depend on — so no field can\n * be lost to the route's allow-list, and for an existing action this\n * path does not run at all.\n */\n if (!draft.id) {\n try {\n await createResource({\n hostId,\n resource: 'action',\n id,\n data: { name: candidate.name ?? draft.name ?? 'Untitled action' },\n })\n } catch (error: any) {\n return void enqueueSnackbar(\n error?.message ?? 'Could not create the interaction',\n { variant: 'error' },\n )\n }\n }\n const verdict = await writeGuardedBySeed(\n {\n subject: 'action',\n unreadable: Boolean(draft.id) && actionsStatus === 'error',\n fromCache: Boolean(draft.id) && actionsFromCache,\n },\n async () => {\n await setDoc(\n doc(firestore, 'hosts', hostId, 'actions', id),\n {\n // The stored shape (AGL-2639), shared with the recipe-install\n // route: frequency caps overwrite explicitly (AGL-274) because\n // a merge-set keeps omitted keys, so switching one off must\n // write it out; conditions follow suit (AGL-557/565) — the\n // list + combinator write null when cleared, and the legacy\n // single `condition` is always nulled.\n ...siteInteractionDocument(candidate),\n updatedAt: Timestamp.now(),\n ...(draft.id ? {} : { createdAt: Timestamp.now() }),\n },\n { merge: true },\n )\n },\n )\n // A refusal keeps the editor open with everything that was typed.\n if (!verdict.ok) {\n return void enqueueSnackbar(verdict.message, {\n variant: 'warning',\n persist: false,\n })\n }\n setDraft(null)\n enqueueSnackbar('Action saved', { variant: 'success', persist: false })\n } catch (error) {\n console.error(error)\n enqueueSnackbar('An error has occurred', {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n }, [\n draft,\n firestore,\n createResource,\n hostId,\n enqueueSnackbar,\n actionsFromCache,\n actionsStatus,\n ])\n\n const handleDelete = useCallback(\n (action: any) => async () => {\n const confirmed = await confirm({\n title: 'Delete this action?',\n description: `\"${action.name}\" stops running on its trigger.`,\n confirmationText: 'Delete',\n confirmationButtonProps: { color: 'error' },\n })\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return\n await updateDoc(doc(firestore, 'hosts', hostId, 'actions', action.$id), {\n deletedAt: Timestamp.now(),\n })\n },\n [confirm, firestore, hostId],\n )\n\n const handleToggle = useCallback(\n (action: any) => async (event: { target: { checked: boolean } }) => {\n const enabled = event.target.checked\n /*\n * A placeholder is a value nobody has supplied yet. Switched on, the\n * step holding it fails every run and a condition holding one never\n * matches, so turning such an automation on is confirmed, naming what\n * is still missing.\n */\n const missing = enabled ? interactionPlaceholders(action) : []\n if (missing.length) {\n const confirmed = await confirm({\n title: 'Switch on with placeholders?',\n description:\n `\"${action.name}\" still has ${missing.length === 1 ? 'a placeholder' : `${missing.length} placeholders`} ` +\n `to fill in: ${missing.slice(0, 3).map(describeInteractionPlaceholder).join('; ')}` +\n `${missing.length > 3 ? '; …' : ''}. Open it with Edit to fill ` +\n `${missing.length === 1 ? 'it' : 'them'} in first.`,\n confirmationText: 'Switch on anyway',\n })\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return\n }\n await updateDoc(doc(firestore, 'hosts', hostId, 'actions', action.$id), {\n enabled,\n })\n },\n [confirm, firestore, hostId],\n )\n\n return (\n <CardDisplay\n header={'Actions'}\n help={pluginDocsHelp('actionsBuilder', { anchor: '#create-an-action' })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={1}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'When a site event fires, run automations in order — trigger a ' +\n 'workflow, show the visitor an alert, chain a custom event, or ' +\n 'write to a dataset. Pro plans and up.'}\n </Typography>\n {visibleActions.map((action: any) => {\n const missing = interactionPlaceholders(action).length\n return (\n <Stack\n key={action.$id}\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center' }}\n >\n <Switch\n size=\"small\"\n checked={action.enabled !== false}\n onChange={handleToggle(action)}\n />\n <Stack sx={{ flex: 1, minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {action.name}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\" noWrap>\n {`on ${hostEventLabel(action.trigger?.event)}` +\n ` · ${(action.steps ?? [])\n .map(\n (step: any) =>\n HOST_ACTION_STEP_LABELS[\n step.type as HostActionStepType\n ] ?? step.type,\n )\n .join(' → ')}`}\n </Typography>\n {missing ? (\n <Typography variant=\"caption\" color=\"warning.main\" noWrap>\n {missing === 1\n ? '1 placeholder to fill in'\n : `${missing} placeholders to fill in`}\n </Typography>\n ) : null}\n </Stack>\n <Button\n size=\"small\"\n onClick={() => setDraft(draftFromAction(action, action.$id))}\n >\n {'Edit'}\n </Button>\n {isSiteEventType(String(action.trigger?.event ?? '')) ? (\n // Test run (AGL-266): the server steps only, run now as a real\n // run through the console's test-run door.\n <Button size=\"small\" onClick={() => void handleTestRun(action)}>\n {'Test'}\n </Button>\n ) : null}\n <Button size=\"small\" onClick={() => setRunsFor(action)}>\n {'Runs'}\n </Button>\n <Button size=\"small\" color=\"error\" onClick={handleDelete(action)}>\n {'Delete'}\n </Button>\n </Stack>\n )\n })}\n {actions.length === 0 ? null : (\n <ListPagination\n page={page}\n pageSize={pageSize}\n rowCount={visibleActions.length}\n // The actions the card HOLDS, which is what the reader is paging\n // through — not the collection, whose other half is the element\n // interactions counted below.\n count={actions.length}\n onPageChange={setPage}\n onPageSizeChange={setPageSize}\n />\n )}\n {actionsTruncated ? (\n <Alert severity=\"info\">\n {`Showing the first ${ACTION_CEILING} rows of this site’s ` +\n 'automations, ordered by id. There are more — both the list ' +\n 'above and the interaction count below describe only what was ' +\n 'read.'}\n </Alert>\n ) : null}\n <Stack direction=\"row\" spacing={1} sx={{ alignSelf: 'flex-start' }}>\n <Button size=\"small\" color=\"primary\" onClick={handleAdd}>\n {'Add action'}\n </Button>\n <Button\n size=\"small\"\n color=\"primary\"\n aria-haspopup=\"menu\"\n aria-controls={recipesAnchor ? 'host-action-recipes' : undefined}\n aria-expanded={recipesAnchor ? true : undefined}\n onClick={(event) => setRecipesAnchor(event.currentTarget)}\n >\n {'Recipes'}\n </Button>\n {/*\n Other ways to start an automation, from plugins (AGL-2919): the\n `hostAutomations` zone, drawn through the shell's own gated slot. A\n plugin page cannot mount that slot itself, so the shell hands it\n down, and a widget here passes the gates a console page's would.\n */}\n {ExtensionZone ? (\n <ExtensionZone\n slot={HOST_AUTOMATIONS_ZONE.id}\n hostId={hostId}\n orgId={org?.$id}\n openAction={openAction}\n />\n ) : null}\n </Stack>\n <Menu\n id=\"host-action-recipes\"\n anchorEl={recipesAnchor}\n open={Boolean(recipesAnchor)}\n onClose={() => setRecipesAnchor(null)}\n >\n {interactionRecipes().map((recipe) => (\n <MenuItem key={recipe.id} onClick={() => handleRecipe(recipe)}>\n <ListItemText\n primary={recipe.title}\n secondary={recipe.description}\n slotProps={{ secondary: { sx: { whiteSpace: 'normal', maxWidth: 360 } } }}\n />\n </MenuItem>\n ))}\n </Menu>\n {/* Says where they went. A list that silently drops rows\n a reader saw last week is a list they stop trusting; this is the\n one sentence that makes the absence deliberate. */}\n {elementScoped.length ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {elementScoped.length === 1\n ? '1 interaction is set up on its own element — '\n : `${elementScoped.length} interactions are set up on their own elements — `}\n {'open the element in the besigner to edit it. Interactions ' +\n 'belong to the page they are on, so they publish and roll back ' +\n 'with it.'}\n </Typography>\n ) : null}\n </Stack>\n\n <Dialog\n open={Boolean(draft)}\n onClose={() => setDraft(null)}\n maxWidth=\"sm\"\n fullWidth\n >\n <DialogTitle>{draft?.id ? 'Edit action' : 'Add action'}</DialogTitle>\n <DialogContent\n sx={{ display: 'flex', flexDirection: 'column', gap: 1.5, pt: 1 }}\n >\n {ExtensionZone && editorTarget ? (\n <ExtensionZone\n slot={AUTOMATION_EDITOR_ZONE.id}\n hostId={hostId}\n orgId={org?.$id}\n target={editorTarget}\n openAction={openAction}\n />\n ) : null}\n {draft?.recipe ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Started from the “${\n interactionRecipe(draft.recipe)?.title ?? 'recipe'\n }” recipe — change anything, then save.`}\n </Typography>\n ) : null}\n {/*\n A short picker is worse than an empty one, because it looks\n complete: the target an author cannot find reads as deleted, and\n the step gets pointed somewhere else.\n */}\n {truncatedPickers.length > 0 ? (\n <Alert severity=\"info\" sx={{ mt: 1 }}>\n {`Offering the first ${EDITOR_OPTION_CEILING} rows, ordered by ` +\n `id, for: ${truncatedPickers.join(', ')}. This site has ` +\n 'more, so a step target may not be listed below.'}\n </Alert>\n ) : null}\n <TextField\n label=\"Name\"\n value={draft?.name ?? ''}\n onChange={(event) =>\n patch((previous) => ({ ...previous, name: event.target.value }))\n }\n size=\"small\"\n autoFocus\n sx={{ mt: 1 }}\n />\n <Stack direction=\"row\" spacing={1}>\n <TextField\n select\n label=\"Trigger event\"\n value={draft?.trigger.event ?? ''}\n onChange={(event) =>\n patch((previous) => ({\n ...previous,\n trigger: { ...previous.trigger, event: event.target.value },\n }))\n }\n size=\"small\"\n sx={{ minWidth: 180 }}\n >\n {HOST_EVENT_TYPES.map((eventType) => (\n <MenuItem key={eventType} value={eventType}>\n {hostEventLabel(eventType)}\n </MenuItem>\n ))}\n {SITE_EVENT_TYPES.map((eventType) => (\n <MenuItem key={eventType} value={eventType}>\n {`${eventType} (on page)`}\n </MenuItem>\n ))}\n <MenuItem value={CUSTOM_EVENT_VALUE}>{'Custom event…'}</MenuItem>\n </TextField>\n {draft?.trigger.event === CUSTOM_EVENT_VALUE ? (\n <TextField\n label=\"Custom event name\"\n value={draft?.customEvent ?? ''}\n onChange={(event) =>\n patch((previous) => ({\n ...previous,\n customEvent: event.target.value,\n }))\n }\n size=\"small\"\n sx={{ flex: 1 }}\n />\n ) : (\n <TextField\n label=\"Filter (optional)\"\n placeholder=\"subscribe\"\n // A comparison belongs in the conditions below: the filter's\n // evaluator is arithmetic, and `path == \"/pricing\"` throws on\n // every event, so it is refused here (AGL-3458). Otherwise,\n // what the expression — and the conditions — can name for\n // this event; nothing for an event whose payload is not\n // written down, rather than a guess.\n error={Boolean(triggerFilterProblem(draft?.trigger.filter))}\n helperText={\n triggerFilterProblem(draft?.trigger.filter) ??\n hostEventPayloadHint(draft?.trigger.event) ??\n undefined\n }\n value={draft?.trigger.filter ?? ''}\n onChange={(event) =>\n patch((previous) => ({\n ...previous,\n trigger: {\n ...previous.trigger,\n filter: event.target.value,\n },\n }))\n }\n size=\"small\"\n sx={{ flex: 1 }}\n />\n )}\n </Stack>\n {/* Structured payload conditions (AGL-557): the no-code sibling\n of the filter — e.g. only when `subscribe` is not empty.\n Chainable with AND/OR (AGL-565), rows styled like steps. */}\n <TriggerConditionRows\n rows={draft?.conditionRows ?? []}\n combinator={draft?.conditionCombinator ?? 'and'}\n onRowsChange={(update) =>\n patch((previous) => ({\n ...previous,\n conditionRows: update(previous.conditionRows),\n }))\n }\n onCombinatorChange={(combinator) =>\n patch((previous) => ({\n ...previous,\n conditionCombinator: combinator,\n }))\n }\n // \"Form is …\", picked by id, where the event names the form (AGL-3458).\n {...(eventCarriesFormId ? { formOptions } : {})}\n />\n {isSiteEventType(draft?.trigger.event ?? '') ? (\n // Site-event config (AGL-256): what/where the trigger watches.\n <Stack direction=\"row\" spacing={1}>\n {(ELEMENT_SCOPED_SITE_EVENTS as readonly string[]).includes(\n draft?.trigger.event ?? '',\n ) ? (\n <ElementSelectorField\n label=\"Element\"\n hostId={hostId}\n // Open the page the trigger is limited to, when it names one.\n initialPath={\n draft?.trigger.pathPattern && !draft.trigger.pathPattern.includes('*')\n ? draft.trigger.pathPattern\n : undefined\n }\n value={draft?.trigger.selector ?? ''}\n onChange={(selector) =>\n patch((previous) => ({\n ...previous,\n trigger: { ...previous.trigger, selector },\n }))\n }\n />\n ) : null}\n {['scrollDepth', 'timeOnPage'].includes(\n draft?.trigger.event ?? '',\n ) ? (\n <TextField\n type=\"number\"\n label={\n draft?.trigger.event === 'scrollDepth'\n ? 'Scroll %'\n : 'Seconds'\n }\n value={draft?.trigger.threshold ?? ''}\n onChange={(event) =>\n patch((previous) => ({\n ...previous,\n trigger: {\n ...previous.trigger,\n threshold: Number(event.target.value),\n },\n }))\n }\n size=\"small\"\n sx={{ width: 120 }}\n />\n ) : null}\n <TextField\n label=\"Only on pages (optional)\"\n placeholder=\"/pricing or /blog/*\"\n value={draft?.trigger.pathPattern ?? ''}\n onChange={(event) =>\n patch((previous) => ({\n ...previous,\n trigger: {\n ...previous.trigger,\n pathPattern: event.target.value,\n },\n }))\n }\n size=\"small\"\n sx={{ flex: 1 }}\n />\n {/* Frequency caps (AGL-274). */}\n <TextField\n select\n label=\"Frequency\"\n size=\"small\"\n sx={{ minWidth: 170 }}\n value={\n draft?.trigger.oncePerVisitor\n ? 'visitor'\n : draft?.trigger.oncePerSession\n ? 'session'\n : Number(draft?.trigger.cooldownMinutes) >= 1\n ? 'cooldown'\n : draft?.trigger.everyTime\n ? 'every'\n : ''\n }\n onChange={(event) => {\n const mode = event.target.value\n patch((previous) => ({\n ...previous,\n trigger: {\n ...previous.trigger,\n // Every occurrence (AGL-562): repeatable UI\n // choreography (menu/drawer toggles).\n everyTime: mode === 'every',\n oncePerVisitor: mode === 'visitor',\n oncePerSession: mode === 'session',\n cooldownMinutes:\n mode === 'cooldown'\n ? Number(previous.trigger.cooldownMinutes) >= 1\n ? Number(previous.trigger.cooldownMinutes)\n : 60\n : undefined,\n },\n }))\n }}\n >\n <MenuItem value=\"\">{'Every matching pageview'}</MenuItem>\n <MenuItem value=\"every\">\n {'Every occurrence (repeatable)'}\n </MenuItem>\n <MenuItem value=\"session\">{'Once per session'}</MenuItem>\n <MenuItem value=\"visitor\">{'Once per visitor'}</MenuItem>\n <MenuItem value=\"cooldown\">{'With a cooldown'}</MenuItem>\n </TextField>\n {Number(draft?.trigger.cooldownMinutes) >= 1 &&\n !draft?.trigger.oncePerVisitor &&\n !draft?.trigger.oncePerSession ? (\n <TextField\n type=\"number\"\n label=\"Cooldown (minutes)\"\n size=\"small\"\n sx={{ width: 150 }}\n value={draft?.trigger.cooldownMinutes ?? 60}\n onChange={(event) =>\n patch((previous) => ({\n ...previous,\n trigger: {\n ...previous.trigger,\n cooldownMinutes: Number(event.target.value),\n },\n }))\n }\n />\n ) : null}\n </Stack>\n ) : null}\n <Typography variant=\"overline\" color=\"text.secondary\">\n {'Steps (run in order)'}\n </Typography>\n {(draft?.steps ?? []).map((step, index) => (\n <AutomationStepFields\n key={index}\n step={step}\n index={index}\n kind={step.type}\n kinds={ACTION_STEP_KINDS}\n stepForKind={(value) => defaultStep(value as HostActionStepType)}\n pickers={stepPickers}\n onSteps={(update) =>\n patch((previous) => ({\n ...previous,\n steps: update(previous.steps),\n }))\n }\n replyContext={{\n event: draft?.trigger.event,\n afterWait: stepRunsAfterWait(draft?.steps, index),\n }}\n siteHostId={hostId}\n />\n ))}\n <Button\n size=\"small\"\n sx={{ alignSelf: 'flex-start' }}\n disabled={(draft?.steps.length ?? 0) >= ACTION_MAX_STEPS}\n onClick={() =>\n patch((previous) => ({\n ...previous,\n steps: [...previous.steps, defaultStep('siteAlert')],\n }))\n }\n >\n {'Add step'}\n </Button>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setDraft(null)}>{'Cancel'}</Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={!draft?.name.trim()}\n onClick={handleSave}\n >\n {'Save action'}\n </Button>\n </DialogActions>\n </Dialog>\n <Dialog\n open={Boolean(pickFor)}\n onClose={() => setPickFor(null)}\n maxWidth=\"xs\"\n fullWidth\n >\n <DialogTitle>{pickFor?.title ?? ''}</DialogTitle>\n <DialogContent\n sx={{ display: 'flex', flexDirection: 'column', gap: 1.5, pt: 1 }}\n >\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`${pickFor?.picks?.prompt ?? ''} The action opens ready to edit; ` +\n 'nothing is saved until you save it.'}\n </Typography>\n {pickTruncated ? (\n <Alert severity=\"info\">\n {`Offering the first ${EDITOR_OPTION_CEILING} ${pickFor?.picks?.plural ?? ''}, ` +\n `ordered by id. This site has more, so the ` +\n `${(pickFor?.picks?.label ?? '').toLowerCase()} you want may not be listed.`}\n </Alert>\n ) : null}\n {pickOptions.length ? (\n <TextField\n select\n label={pickFor?.picks?.label ?? ''}\n value={pickedId}\n onChange={(event) => setPickedId(event.target.value)}\n size=\"small\"\n sx={{ mt: 1 }}\n >\n {pickOptions.map((option) => (\n <MenuItem key={option.id} value={option.id}>\n {option.name}\n </MenuItem>\n ))}\n </TextField>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {pickFor?.picks?.none ?? ''}\n </Typography>\n )}\n </DialogContent>\n <DialogActions>\n <Button color=\"inherit\" onClick={() => setPickFor(null)}>\n {'Cancel'}\n </Button>\n <Button\n variant=\"contained\"\n disabled={!pickedId}\n onClick={handlePicked}\n >\n {'Use recipe'}\n </Button>\n </DialogActions>\n </Dialog>\n <Dialog\n open={Boolean(runsFor)}\n onClose={() => setRunsFor(null)}\n // md: the history's four columns fit without the table scrolling.\n maxWidth=\"md\"\n fullWidth\n >\n <DialogTitle>{`Runs — ${runsFor?.name ?? ''}`}</DialogTitle>\n <DialogContent>\n {runsFor ? (\n <HostRunHistoryCard\n hostId={hostId}\n orgId={org?.$id}\n targetId={runsFor.$id}\n targetType=\"action\"\n targetName={runsFor.name ?? ''}\n header=\"Recent runs\"\n />\n ) : null}\n </DialogContent>\n <DialogActions>\n <Button color=\"inherit\" onClick={() => setRunsFor(null)}>\n {'Close'}\n </Button>\n </DialogActions>\n </Dialog>\n </CardDisplay>\n )\n}\nHostActionsCard.displayName = 'HostActionsCard'\n\nexport default HostActionsCard\n"],"names":["ACTION_MAX_STEPS","checkEntitlement","createResourceUid","ELEMENT_SCOPED_SITE_EVENTS","HOST_EVENT_TYPES","hostEventLabel","HOST_EVENT_PAYLOAD_KEYS","hostEventPayloadHint","isSiteEventType","pluginDocsHelp","SITE_EVENT_TYPES","triggerFilterProblem","useConsoleWidgetSlot","interactionRecipe","interactionRecipes","interactionRecipeStamp","pluginRecordListQuery","pluginRecordsFromRows","AUTOMATION_EDITOR_ZONE","HOST_AUTOMATIONS_ZONE","OPEN_ACTION_PARAM","requestedActionId","CardDisplay","useConfirmationContext","ListPagination","TABLE_PAGE_SIZE_DEFAULT","useSnackbar","authorizedFetch","Timestamp","Alert","Button","Dialog","DialogActions","DialogContent","DialogTitle","ListItemText","Menu","MenuItem","Stack","Switch","TextField","Typography","collection","doc","setDoc","updateDoc","useCallback","useEffect","useMemo","useRef","useState","ceilingedWindow","collectionCeiling","useFirestore","useFirestoreCollection","useHostResourceApi","useUser","writeGuardedBySeed","ACTION_TEST_RUN_API_ROUTE","AutomationStepFields","defaultStep","ElementSelectorField","conditionRowsFromTrigger","conditionsFromRows","EMPTY_CONDITION_ROW","TriggerConditionRows","HostRunHistoryCard","EDITOR_OPTION_CEILING","useAutomationStepPickers","siteInteractionDocument","HOST_ACTION_STEP_LABELS","stepRunsAfterWait","validateHostAction","describeInteractionPlaceholder","interactionPlaceholders","CUSTOM_EVENT_VALUE","ACTION_CEILING","ACTION_STEP_KINDS","Object","entries","map","value","label","draftFromAction","action","id","builtIn","includes","trigger","event","String","name","filter","selector","threshold","pathPattern","oncePerVisitor","oncePerSession","everyTime","Number","cooldownMinutes","steps","enabled","customEvent","conditionRows","conditionCombinator","combinator","recipe","LEAF_SELECTOR","HostActionsCard","props","runsFor","pickFor","hostId","org","firestore","createResource","data","user","enqueueSnackbar","confirm","ExtensionZone","actionDocs","status","actionsStatus","fromCache","actionsFromCache","idField","rows","readActions","truncated","actionsTruncated","draft","setDraft","editorOpened","setEditorOpened","pickers","stepPickers","truncatedPickers","liveActions","deletedAt","listedRef","current","openAction","actionId","find","row","$id","requested","setRequested","window","location","search","url","URL","href","searchParams","delete","history","replaceState","state","toString","length","elementScoped","test","actions","sort","a","b","localeCompare","page","setPage","pageSize","setPageSize","visibleActions","slice","patch","updater","previous","draftId","draftName","editorTarget","type","actionsEntitled","variant","persist","handleAdd","recipesAnchor","setRecipesAnchor","setPickFor","pickedId","setPickedId","pickKind","picks","kind","pickedKind","setPickedKind","pickRead","limit","pickRows","pickTruncated","pickOptions","record","facts","eventCarriesFormId","Boolean","formConditionOpened","setFormConditionOpened","formConditionRead","formOptions","handleRecipe","build","handlePicked","picked","option","setRunsFor","handleTestRun","response","method","headers","body","JSON","stringify","payload","json","catch","ok","error","alerts","Array","isArray","message","console","handleSave","isCustom","candidate","trim","undefined","problem","resource","verdict","subject","unreadable","updatedAt","now","createdAt","merge","allowDuplicate","handleDelete","confirmed","title","description","confirmationText","confirmationButtonProps","color","then","handleToggle","target","checked","missing","join","header","help","anchor","contentGutterX","contentGutterY","spacing","direction","sx","alignItems","size","onChange","flex","minWidth","noWrap","step","onClick","rowCount","count","onPageChange","onPageSizeChange","severity","alignSelf","aria-haspopup","aria-controls","aria-expanded","currentTarget","slot","orgId","anchorEl","open","onClose","primary","secondary","slotProps","whiteSpace","maxWidth","fullWidth","display","flexDirection","gap","pt","mt","autoFocus","select","eventType","placeholder","helperText","onRowsChange","update","onCombinatorChange","initialPath","width","mode","index","kinds","stepForKind","onSteps","replyContext","afterWait","siteHostId","disabled","prompt","plural","toLowerCase","none","targetId","targetType","targetName","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SACEA,gBAAgB,EAEhBC,gBAAgB,EAChBC,iBAAiB,EACjBC,0BAA0B,EAC1BC,gBAAgB,EAChBC,cAAc,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