@aglyn/plugins-forms 1.0.0-beta.219 → 1.0.0-beta.220

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/plugins-forms",
3
- "version": "1.0.0-beta.219",
3
+ "version": "1.0.0-beta.220",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://aglyn.com",
6
6
  "repository": {
@@ -25,18 +25,17 @@
25
25
  "./package.json": "./package.json"
26
26
  },
27
27
  "dependencies": {
28
- "@aglyn/aglyn": "1.0.0-beta.219",
29
- "@aglyn/shared-data-enums": "1.0.0-beta.219",
30
- "@aglyn/shared-data-mdi": "1.0.0-beta.219",
31
- "@aglyn/shared-ui-email-campaigns": "1.0.0-beta.219",
32
- "@aglyn/shared-ui-jsx": "1.0.0-beta.219",
33
- "@aglyn/shared-ui-jsx-forms": "1.0.0-beta.219",
34
- "@aglyn/shared-ui-snackstack": "1.0.0-beta.219",
35
- "@aglyn/shared-util-http": "1.0.0-beta.219",
36
- "@aglyn/shared-util-timestamp": "1.0.0-beta.219",
37
- "@aglyn/shared-util-tools": "1.0.0-beta.219",
38
- "@aglyn/tenant-data-admin": "1.0.0-beta.219",
39
- "@aglyn/tenant-feature-instance": "1.0.0-beta.219",
28
+ "@aglyn/aglyn": "1.0.0-beta.220",
29
+ "@aglyn/shared-data-enums": "1.0.0-beta.220",
30
+ "@aglyn/shared-data-mdi": "1.0.0-beta.220",
31
+ "@aglyn/shared-ui-jsx": "1.0.0-beta.220",
32
+ "@aglyn/shared-ui-jsx-forms": "1.0.0-beta.220",
33
+ "@aglyn/shared-ui-snackstack": "1.0.0-beta.220",
34
+ "@aglyn/shared-util-http": "1.0.0-beta.220",
35
+ "@aglyn/shared-util-timestamp": "1.0.0-beta.220",
36
+ "@aglyn/shared-util-tools": "1.0.0-beta.220",
37
+ "@aglyn/tenant-data-admin": "1.0.0-beta.220",
38
+ "@aglyn/tenant-feature-instance": "1.0.0-beta.220",
40
39
  "@swc/helpers": "0.5.23"
41
40
  },
42
41
  "peerDependencies": {
@@ -44,7 +43,7 @@
44
43
  "@mui/x-data-grid": "^9.12.0",
45
44
  "firebase": "^12.18.0",
46
45
  "firebase-admin": "^14.3.0",
47
- "next": "16.3.3",
46
+ "next": "^16.3.3",
48
47
  "react": "^19.2.8"
49
48
  },
50
49
  "sideEffects": false,
@@ -30,8 +30,8 @@ import { ScrollTable } from "@aglyn/shared-ui-jsx/components/scroll-table.compon
30
30
  import { useSnackbar } from "@aglyn/shared-ui-snackstack";
31
31
  import { Timestamp } from "@aglyn/shared-util-timestamp";
32
32
  import { Alert, AlertTitle, Button, Chip, FormControlLabel, MenuItem, Stack, Switch, TableBody, TableCell, TableHead, TableRow, TextField, Typography } from "@mui/material";
33
- import { useConsoleHostRoute, useFirestore, useFirestoreCollection, useFirestoreDoc, useHostCampaigns, useHostVersionApi } from "@aglyn/tenant-feature-instance";
34
- import CampaignPicker from "@aglyn/shared-ui-email-campaigns/components/campaign-picker.component";
33
+ import { useConsoleHostRoute, useFirestore, useFirestoreCollection, useFirestoreDoc, useSiteContainerOptions, useHostVersionApi } from "@aglyn/tenant-feature-instance";
34
+ import ContainerPicker from "@aglyn/tenant-feature-instance/components/container-picker";
35
35
  import { collection, doc, limit, query, updateDoc } from "firebase/firestore";
36
36
  import { useRouter } from "next/navigation";
37
37
  import { useCallback, useMemo, useState } from "react";
@@ -189,10 +189,10 @@ import useFormStatsRecountApi from "./use-form-stats-recount-api.js";
189
189
  * page that drew them until a button was pressed would be showing a
190
190
  * merchant raw storage. Bounded at the ceiling the campaigns table itself
191
191
  * draws, so it can offer nothing that list does not.
192
- */ const siteCampaigns = useHostCampaigns(hostId, {
192
+ */ const siteCampaigns = useSiteContainerOptions('campaign', hostId, {
193
193
  enabled: Boolean(form)
194
194
  });
195
- const storedCampaigns = useMemo(()=>Aglyn.readCampaignIds(form), [
195
+ const storedCampaigns = useMemo(()=>Aglyn.readContainerIds(form, 'campaign'), [
196
196
  form
197
197
  ]);
198
198
  const effectiveCampaigns = campaignIds != null ? campaignIds : storedCampaigns;
@@ -427,7 +427,7 @@ import useFormStatsRecountApi from "./use-form-stats-recount-api.js";
427
427
  host,
428
428
  enqueueSnackbar
429
429
  ]);
430
- const dirty = name != null || lead != null || consentField != null || campaignIds != null && !Aglyn.campaignMembershipUnchanged(storedCampaigns, campaignIds);
430
+ const dirty = name != null || lead != null || consentField != null || campaignIds != null && !Aglyn.containerMembershipUnchanged(storedCampaigns, campaignIds);
431
431
  // Named before it is used on every row, so a role denial reads as a reason
432
432
  // rather than as a control that does nothing.
433
433
  const publishBlock = hostRoleLoaded ? 'Your role on this site can edit content but not publish it' : 'Checking what your role can do…';
@@ -490,7 +490,8 @@ import useFormStatsRecountApi from "./use-form-stats-recount-api.js";
490
490
  color: "text.secondary",
491
491
  children: `ID ${formId} — every submission is filed under this, so it never changes`
492
492
  }),
493
- /*#__PURE__*/ _jsx(CampaignPicker, {
493
+ /*#__PURE__*/ _jsx(ContainerPicker, {
494
+ kind: "campaign",
494
495
  options: siteCampaigns.options,
495
496
  value: effectiveCampaigns,
496
497
  onChange: setCampaignIds,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/forms/src/lib/components/form-detail-card.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 * as Aglyn from '@aglyn/aglyn'\nimport {\n buildRoute,\n type FormFieldDecl,\n formFieldsCanYieldAnEmail,\n formFieldsCaptureConsent,\n PageHeaderActions,\n PageHeaderRecord,\n listConsoleWidgets,\n pluginDocsHelp,\n Route,\n} from '@aglyn/aglyn'\nimport { useConsoleWidgetSlot } from '@aglyn/aglyn/app-utils/console-widget-slot-context'\n// The CRM's route builder by its leaf path, not the plugin barrel: the barrel\n// is the entry point the tenant's loader imports to activate the plugin's\n// site half, and a console page named there would ship to every published\n// page. The same import the Inbox makes for the same reason.\nimport { pluginRecordFilteredHref } from '@aglyn/aglyn/plugin-manager/plugin-record-routes'\nimport { ICON_VARIANT_BESIGNER } from '@aglyn/shared-data-enums'\nimport { AppLink, CardDisplay, GridItems, MdiIcon, useLoading } from '@aglyn/shared-ui-jsx'\nimport { ScrollTable } from '@aglyn/shared-ui-jsx/components/scroll-table.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { Timestamp } from '@aglyn/shared-util-timestamp'\nimport {\n Alert,\n AlertTitle,\n Button,\n Chip,\n FormControlLabel,\n MenuItem,\n Stack,\n Switch,\n TableBody,\n TableCell,\n TableHead,\n TableRow,\n TextField,\n Typography,\n} from '@mui/material'\nimport {\n useConsoleHostRoute,\n useFirestore,\n useFirestoreCollection,\n useFirestoreDoc,\n useHostCampaigns,\n useHostVersionApi,\n} from '@aglyn/tenant-feature-instance'\nimport CampaignPicker from '@aglyn/shared-ui-email-campaigns/components/campaign-picker.component'\nimport { collection, doc, limit, query, updateDoc } from 'firebase/firestore'\nimport { useRouter } from 'next/navigation'\nimport { useCallback, useMemo, useState } from 'react'\nimport { FORM_CONTACT_FIELDS_ZONE } from './form-zones'\nimport { FORMS_DOCUMENT_SEGMENT } from '../constants/bundle-common'\nimport FormDesignPreview from './form-design-preview.component'\nimport FormMetricsCard from './form-metrics-card.component'\nimport FormSubmissionsCard from './form-submissions-card.component'\nimport useFormPromoteApi from './use-form-promote-api'\nimport useFormStatsRecountApi from './use-form-stats-recount-api'\n\nexport interface FormDetailCardProps {\n hostId: string\n formId: string\n /**\n * The Forms surface's own absolute console path.\n *\n * Only the not-found branch links it. The trail carries the way back on a\n * form that exists, so a link beside the heading would be the breadcrumb\n * written twice; a form that does NOT exist has no heading of its own for\n * the trail to end on, and the reader needs somewhere to go.\n */\n basePath?: string\n /** Whether this viewer's role on the site may make a version live. */\n canPublish?: boolean\n /** False while the role is still being read; see the disabled reasons. */\n hostRoleLoaded?: boolean\n}\n\n/**\n * One form — the component detail surface, for a document that is also a\n * contract.\n *\n * The split this enforces is the reason it exists rather than sending a row\n * straight into the besigner. A form has two halves:\n *\n * - the DESIGN, which is what an author draws, and which lives in the\n * besigner reached from here;\n * - the DECLARATION — where a submission is routed and which field carries\n * marketing consent — which is edited here.\n *\n * They are edited apart because the declaration is what the design is then\n * checked AGAINST. `checkFormContract` compares the two at publish, so a\n * surface that let an author change both in one motion would let them satisfy\n * the check by moving whichever side happened to be easier — which is how a\n * form ends up with lead routing pointed at a field nobody fills in.\n *\n * ## Promotion lives here, not only in the besigner\n *\n * A component's version history offers Publish on any version: promotion is\n * how you go back, not only how you go forward, and an author restoring last\n * week's design should not have to open a canvas to do it.\n *\n * It rides `/api/forms/promote` rather than an `updateDoc` here, because\n * a form's promotion has to run `checkFormContract` on the tree it is about to\n * write and REFUSE. A check in this component would be advice a determined\n * client could skip; the route reads the stored version itself, so nothing\n * about the design crosses the wire inbound and there is no version of this\n * surface that can publish a design the check has not seen.\n */\nexport function FormDetailCard(props: FormDetailCardProps) {\n const { hostId, formId, basePath, canPublish, hostRoleLoaded } = props\n const firestore = useFirestore()\n const ContactFieldsZone = useConsoleWidgetSlot()\n // Read at render, after the shell has loaded its plugins.\n const hasContactFieldsWidget =\n listConsoleWidgets(FORM_CONTACT_FIELDS_ZONE.id).length > 0\n /**\n * The write a widget in the contact-fields zone asks for. The declaration\n * is one array on the form document, and the document is this plugin's, so\n * the page writes what the widget decided.\n */\n const saveFields = useCallback(\n async (fields: FormFieldDecl[]) => {\n await updateDoc(doc(firestore, 'hosts', hostId, 'forms', formId), {\n fields,\n updatedAt: Timestamp.now(),\n })\n },\n [firestore, hostId, formId],\n )\n const { orgSlug, subdomain: host } = useConsoleHostRoute(hostId)\n const createHostVersion = useHostVersionApi()\n const promoteForm = useFormPromoteApi()\n const recountFormStats = useFormStatsRecountApi()\n const router = useRouter()\n const { enqueueSnackbar } = useSnackbar()\n const { queueLoading } = useLoading()\n\n const { data: form, status } = useFirestoreDoc<any>(\n () => doc(firestore, 'hosts', hostId, 'forms', formId),\n [firestore, hostId, formId],\n { idField: '$id' },\n )\n // Three states, not two (AGL-706): loading and absent both arrive as\n // `undefined`, and an editable form over a mistyped id reads as data loss.\n const notFound = status !== 'loading' && !form\n\n /**\n * The published design, in BOTH stored forms (AGL-1151).\n *\n * The read above is converter-less, so `nodes` arrives exactly as stored —\n * msgpack for a design promoted since forms were compressed, a plain map\n * for everything older. Decoded once here because two surfaces below need\n * it and both fail silently on the raw value: `checkFormContract` reports\n * bogus violations against a tree it cannot walk, and the AGL-753 empty\n * guard passes on a `Bytes` because `Object.keys` counts the wrapper.\n */\n const formNodes = useMemo(\n () => Aglyn.decodeStoredNodes<Record<string, any>>(form?.nodes),\n [form?.nodes],\n )\n\n // No orderBy: the oldest version docs predate `createdAt`, and Firestore\n // drops documents missing the ordered field.\n const { data: versionDocs } = useFirestoreCollection<any>(\n () =>\n query(\n collection(firestore, 'hosts', hostId, 'forms', formId, 'versions'),\n limit(100),\n ),\n [firestore, hostId, formId],\n { idField: '$id' },\n )\n const versions = [...(versionDocs ?? [])].sort(\n (a: any, b: any) =>\n (b.createdAt?.seconds ?? 0) - (a.createdAt?.seconds ?? 0),\n )\n const publishedVersionId = form?.versionId as string | undefined\n\n const [name, setName] = useState<string | null>(null)\n const [lead, setLead] = useState<boolean | null>(null)\n const [consentField, setConsentField] = useState<string | null>(null)\n /**\n * The campaigns picked on screen, or null while the stored value stands.\n *\n * Null and `[]` are different: null means \"not touched\", `[]` means \"take\n * this form out of every campaign\". Collapsing them would make clearing the\n * last campaign a no-op, which is the half of set-and-clear that is easy to\n * ship broken.\n */\n const [campaignIds, setCampaignIds] = useState<string[] | null>(null)\n const [opening, setOpening] = useState(false)\n const [promoting, setPromoting] = useState<string | null>(null)\n /**\n * What a REFUSED promotion said, kept on the surface rather than in a toast.\n *\n * A contract violation is a list of things to go and fix in the besigner,\n * and a snackbar is gone by the time the author has read the second one.\n * The besigner's own refusal persists for the same reason.\n */\n const [promoteRefusal, setPromoteRefusal] = useState<{\n message: string\n violations: Aglyn.FormContractViolation[]\n } | null>(null)\n\n /** The fields the PUBLISHED design draws, which is what a submission can carry. */\n const declaredFields: Aglyn.FormFieldDecl[] = useMemo(\n () => (Array.isArray(form?.fields) ? form.fields : []),\n [form],\n )\n\n const effectiveLead = lead ?? form?.routing?.lead === true\n const effectiveConsent = consentField ?? String(form?.consentFieldName ?? '')\n /*\n * Whether lead routing COULD work on this design — the two preconditions\n * `checkFormContract` applies at publish, asked here so the switch says so\n * before it is flipped rather than after (AGL-2612). Consent is read as\n * it is being edited: picking a field below is what satisfies it.\n */\n const hasEmailField = formFieldsCanYieldAnEmail(declaredFields)\n const capturesConsent = formFieldsCaptureConsent(declaredFields, effectiveConsent)\n /*\n * Where this form's people are: the contacts list narrowed to this form,\n * asked of the plugin that keeps people (`null`, and no link, without one). Built from the resolved org slug and\n * subdomain the besigner link already waits on, so the link appears when\n * they land and never points at a half-built address.\n */\n const contactsHref =\n orgSlug && host\n ? pluginRecordFilteredHref('contact', { orgSlug, host }, 'form', formId)\n : null\n /*\n * WHICH CAMPAIGNS THIS FORM IS PART OF.\n *\n * The site's campaigns are read while this page is open because the field\n * is DISPLAYED here as well as edited here: the document stores ids, and a\n * page that drew them until a button was pressed would be showing a\n * merchant raw storage. Bounded at the ceiling the campaigns table itself\n * draws, so it can offer nothing that list does not.\n */\n const siteCampaigns = useHostCampaigns(hostId, { enabled: Boolean(form) })\n const storedCampaigns = useMemo(\n () => Aglyn.readCampaignIds(form as Record<string, unknown>),\n [form],\n )\n const effectiveCampaigns = campaignIds ?? storedCampaigns\n\n /**\n * What the published design would break, judged against the declaration as\n * it is being edited here.\n *\n * Shown here as well as at publish because the two halves are edited in\n * different places: turning lead routing on for a form whose design has no\n * email field is a break the author causes HERE, on a design they are not\n * looking at, and the besigner would not tell them until they next opened\n * it.\n */\n const violations = useMemo(\n () =>\n form\n ? Aglyn.checkFormContract({\n form: {\n routing: { ...(form.routing ?? {}), lead: effectiveLead },\n ...(effectiveConsent\n ? { consentFieldName: effectiveConsent }\n : {}),\n },\n formId,\n nodes: formNodes as never,\n formNodeId: findFormNodeId(formNodes as never),\n })\n : [],\n [form, formId, effectiveLead, effectiveConsent],\n )\n\n const handleSave = useCallback(async () => {\n const dequeue = queueLoading()\n try {\n await updateDoc(doc(firestore, 'hosts', hostId, 'forms', formId), {\n // A rename carries the keys the Forms list searches by (AGL-3330), or\n // the form would be findable only by the name it used to have.\n ...(name != null\n ? {\n displayName: name.trim(),\n ...Aglyn.formListFields({\n id: formId,\n displayName: name.trim(),\n slug: form?.slug,\n }),\n }\n : {}),\n ...(lead != null ? { routing: { ...(form?.routing ?? {}), lead } } : {}),\n ...(consentField != null\n ? { consentFieldName: consentField.trim() }\n : {}),\n // An empty selection is stored as an empty array rather than removing\n // the field: one shape for \"in no campaign\", which is what keeps this\n // writer and the campaign's own detach agreeing. `inCampaign` rides\n // with it, the boolean the list's \"In a campaign\" filter asks\n // (AGL-3330).\n ...(campaignIds != null ? Aglyn.formCampaignFields(campaignIds) : {}),\n updatedAt: Timestamp.now(),\n })\n setName(null)\n setLead(null)\n setConsentField(null)\n setCampaignIds(null)\n enqueueSnackbar('Form saved', { variant: 'success', persist: false })\n /*\n * A form that routes leads holds `0` of them until its first, and one\n * that does not holds none (AGL-3330). The counters are the server's\n * to write, so the switch asks for them to be recounted.\n */\n if (lead != null && lead !== (form?.routing?.lead === true)) {\n void recountFormStats({ hostId, formIds: [formId] })\n }\n } catch (error) {\n console.error(error)\n enqueueSnackbar('An error has occurred', {\n variant: 'error',\n allowDuplicate: true,\n })\n } finally {\n dequeue()\n }\n }, [\n firestore,\n hostId,\n formId,\n form,\n name,\n lead,\n consentField,\n campaignIds,\n queueLoading,\n enqueueSnackbar,\n recountFormStats,\n ])\n\n /**\n * Makes one version the version the live sites serve.\n *\n * The route decides, not this handler: it re-reads the stored version, runs\n * `checkFormContract` on the tree it is about to write, and answers 422 with\n * the violations when a publish would stop the submissions arriving. So the\n * only thing here is what to do with each answer — and a refusal is put on\n * the page rather than in a toast, because it is a list of things to fix.\n */\n const handlePromote = useCallback(\n (targetVersionId: string) => async () => {\n if (promoting) return\n setPromoting(targetVersionId)\n setPromoteRefusal(null)\n try {\n const result = await promoteForm({ hostId, formId, versionId: targetVersionId })\n if (!result.ok) {\n const message = result.message ?? 'Publish failed'\n setPromoteRefusal({\n message,\n violations: result.violations ?? [],\n })\n // `persist` because this is a refusal an author has to act on: an\n // auto-dismissed warning is how someone walks away believing the\n // form shipped.\n enqueueSnackbar(message, {\n variant: 'warning',\n allowDuplicate: true,\n persist: true,\n })\n return\n }\n enqueueSnackbar(\n 'Published. The live sites now serve this version, and the form’s ' +\n 'declared fields match it.',\n { variant: 'success', persist: false },\n )\n } catch (error) {\n console.error(error)\n enqueueSnackbar('Could not publish that version', {\n variant: 'error',\n allowDuplicate: true,\n persist: true,\n })\n } finally {\n setPromoting(null)\n }\n },\n [promoting, promoteForm, hostId, formId, enqueueSnackbar],\n )\n\n /**\n * Opens a version in the besigner, minting the first one when the form has\n * none.\n *\n * Forms adopted from a page carry a declared field list and a `nodes` map\n * seeded from the page they were adopted from — so the first version opens\n * on the form the site was ALREADY submitting rather than a blank canvas.\n */\n const handleOpen = useCallback(\n (targetVersionId?: string) => async () => {\n if (opening) return\n setOpening(true)\n try {\n let versionId = targetVersionId ?? publishedVersionId ?? versions[0]?.$id\n if (!versionId) {\n versionId = Aglyn.createResourceUid()\n // Rides /api/hosts/versions: rules deny the client create, and the\n // route allows a resource's FIRST version on every plan — which\n // this always is, since the form reached here with no `versionId`.\n await createHostVersion({\n hostId,\n kind: 'form',\n parentId: formId,\n id: versionId,\n data: {\n formId,\n hostId,\n displayName: 'Initial version',\n // Emptiness, not just absence: a form that holds no `nodes` and\n // `??` would pass an empty map straight through to a version\n // that opens uneditable (AGL-753). Measured on the DECODED\n // tree — `Object.keys` over a stored `Bytes` is non-empty, so\n // the raw value passes this guard and mints exactly the\n // uneditable version it exists to stop (AGL-1151).\n nodes: Object.keys(formNodes ?? {}).length\n ? formNodes\n : {\n [Aglyn.CANVAS_ROOT_ELEMENT_ID]: {\n $id: Aglyn.CANVAS_ROOT_ELEMENT_ID,\n componentId: 'div',\n nodes: [],\n },\n },\n ...(form?.rootId ? { rootId: form.rootId } : {}),\n },\n })\n await updateDoc(doc(firestore, 'hosts', hostId, 'forms', formId), {\n versionId,\n updatedAt: Timestamp.now(),\n })\n }\n // The editor's URL needs the resolved org slug and subdomain, which\n // `useConsoleHostRoute` reads. Until they land the button below is\n // disabled, so this branch cannot be reached without them.\n if (orgSlug && host) {\n router.push(\n buildRoute(Route.PLUGIN_DOCUMENT_BESIGNER, {\n orgSlug,\n host,\n documentSegment: FORMS_DOCUMENT_SEGMENT,\n docId: formId,\n versionId,\n }),\n )\n }\n } catch (error) {\n console.error(error)\n enqueueSnackbar('Could not open the besigner', {\n variant: 'error',\n allowDuplicate: true,\n })\n setOpening(false)\n }\n },\n [\n opening,\n createHostVersion,\n publishedVersionId,\n versions,\n firestore,\n hostId,\n formId,\n form,\n router,\n orgSlug,\n host,\n enqueueSnackbar,\n ],\n )\n\n const dirty =\n name != null ||\n lead != null ||\n consentField != null ||\n (campaignIds != null &&\n !Aglyn.campaignMembershipUnchanged(storedCampaigns, campaignIds))\n // Named before it is used on every row, so a role denial reads as a reason\n // rather than as a control that does nothing.\n const publishBlock = hostRoleLoaded\n ? 'Your role on this site can edit content but not publish it'\n : 'Checking what your role can do…'\n\n if (notFound) {\n return (\n <CardDisplay\n header=\"Form not found\"\n help={pluginDocsHelp('forms', {\n anchor: '#build-a-form',\n excerpt:\n 'A form is created from the Forms list and keeps the id every ' +\n 'submission is filed under.',\n })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={2} sx={{ alignItems: 'flex-start' }}>\n <Alert severity=\"info\">\n {`No form on this site has the id ${formId}. It may have been deleted, or the link may be from another site.`}\n </Alert>\n {basePath ? <AppLink href={basePath}>{'Back to forms'}</AppLink> : null}\n </Stack>\n </CardDisplay>\n )\n }\n\n /* The cards, named so the page chrome above them is a plain list of\n what this surface publishes upward. */\n const cards = (\n <GridItems\n spacing={3}\n items={[\n {\n size: { xs: 12, lg: 5 },\n children: (\n <CardDisplay\n header=\"Details\"\n help={pluginDocsHelp('forms', {\n anchor: '#build-a-form',\n excerpt:\n 'The id is what every submission is filed under, so ' +\n 'renaming a form never splits its history.',\n })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={2}>\n <TextField\n label=\"Display name\"\n size=\"small\"\n value={name ?? form?.displayName ?? ''}\n onChange={(event) => setName(event.target.value)}\n fullWidth\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`ID ${formId} — every submission is filed under this, so it never changes`}\n </Typography>\n {/*\n A FORM IS PART OF A CAMPAIGN, and may be part of several.\n The same signup form is placed by one push and re-placed by\n the next, so this is a multi-select — a single value would\n make filing it under this quarter's campaign silently\n un-file it from last quarter's.\n\n It is an assignment and nothing else: it does not decide who\n a campaign mails, and it does not credit a submission to\n one. Attribution is recorded from the link a visitor\n followed, on its own evidence, and it goes on saying what it\n says whatever is picked here.\n */}\n <CampaignPicker\n options={siteCampaigns.options}\n value={effectiveCampaigns}\n onChange={setCampaignIds}\n helperText=\"The campaigns this form is part of. It does not change who a campaign mails.\"\n empty={siteCampaigns.ready && !siteCampaigns.options.length}\n />\n <Stack direction=\"row\" spacing={1}>\n <Button\n variant=\"contained\"\n color=\"primary\"\n size=\"small\"\n disabled={!dirty}\n onClick={handleSave}\n >\n {'Save'}\n </Button>\n </Stack>\n </Stack>\n </CardDisplay>\n ),\n },\n {\n size: { xs: 12, lg: 7 },\n children: (\n <CardDisplay\n header=\"CRM routing\"\n help={pluginDocsHelp('forms', {\n anchor: '#where-submissions-go',\n excerpt:\n 'Every submission reaches the Inbox and updates the ' +\n 'contact. Lead routing and the consent field decide ' +\n 'what else happens to it.',\n })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={2}>\n {/*\n THE PART THAT IS NOT A SWITCH (AGL-2612). Every capture\n lands in Contacts whatever is set below; the switch decides\n only whether a LEAD is filed beside the contact. Said\n first, because the switch on its own read as the only way\n a submission reached the CRM.\n */}\n <Typography variant=\"body2\">\n {'Every submission with an email address updates the person ' +\n 'in Contacts at stage Lead — a new contact when the ' +\n 'address is new, an interaction on their timeline when it ' +\n 'is not. A customer stays a customer.'}\n </Typography>\n <Stack spacing={0.5}>\n <FormControlLabel\n control={\n <Switch\n checked={effectiveLead}\n onChange={(event) => setLead(event.target.checked)}\n />\n }\n label=\"Also create a lead from the address someone gives this form\"\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {!hasEmailField\n ? 'Needs an email field in the published design — a ' +\n 'submission without an address cannot key a lead, and ' +\n 'publishing with this on would be refused until one exists.'\n : !capturesConsent\n ? 'Needs a marketing consent field — a lead nobody opted ' +\n 'in with is one the team cannot email, and publishing ' +\n 'with this on would be refused until the field below ' +\n 'names one.'\n : 'Files a lead in CRM → Leads for the sales team to work, ' +\n 'carrying the opt-in the consent field records.'}\n </Typography>\n </Stack>\n <TextField\n select\n label=\"Marketing consent field\"\n size=\"small\"\n value={effectiveConsent}\n onChange={(event) => setConsentField(event.target.value)}\n fullWidth\n helperText=\"The one field that IS the opt-in. Submitting a form is never itself consent.\"\n >\n <MenuItem value=\"\">\n {'None — this form collects no opt-in'}\n </MenuItem>\n {declaredFields.map((field) => (\n <MenuItem key={field.fieldName} value={field.fieldName}>\n {field.label\n ? `${field.label} (${field.fieldName})`\n : field.fieldName}\n </MenuItem>\n ))}\n </TextField>\n {violations.length ? (\n <Alert severity=\"warning\">\n <AlertTitle>{'This form would stop collecting'}</AlertTitle>\n <Stack component=\"ul\" sx={{ pl: 2, m: 0 }}>\n {violations.map((violation) => (\n <Typography\n component=\"li\"\n variant=\"body2\"\n key={`${violation.code}:${violation.nodeId ?? violation.fieldName ?? ''}`}\n >\n {violation.message}\n </Typography>\n ))}\n </Stack>\n </Alert>\n ) : null}\n {/*\n The people this form captured, on the list that holds them.\n Withheld until the site's address resolves, for the reason\n the besigner button is.\n */}\n {contactsHref ? (\n <Typography variant=\"body2\">\n <AppLink href={contactsHref}>\n {'See the contacts this form captured in the CRM'}\n </AppLink>\n </Typography>\n ) : null}\n </Stack>\n </CardDisplay>\n ),\n },\n // Where each field saves on the person: another plugin's card, in a\n // zone this page hosts. No item at all where nothing fills it, so the\n // grid keeps no empty cell.\n ...(ContactFieldsZone && hasContactFieldsWidget\n ? [\n {\n size: { xs: 12 },\n children: (\n <ContactFieldsZone\n slot={FORM_CONTACT_FIELDS_ZONE.id}\n hostId={hostId}\n formId={formId}\n fields={declaredFields}\n loading={status === 'loading'}\n saveFields={saveFields}\n />\n ),\n },\n ]\n : []),\n {\n size: { xs: 12, lg: 5 },\n children: (\n <FormMetricsCard\n stats={form?.stats}\n fields={declaredFields}\n leadRouting={effectiveLead}\n loading={status === 'loading'}\n />\n ),\n },\n {\n size: { xs: 12, lg: 7 },\n children: (\n <CardDisplay\n header=\"Versions\"\n help={pluginDocsHelp('forms', {\n anchor: '#build-a-form',\n excerpt:\n 'Publishing a form version updates every page that ' +\n 'places it. Saving does not — a save is not a publish.',\n })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={2}>\n {promoteRefusal ? (\n <Alert\n severity=\"warning\"\n onClose={() => setPromoteRefusal(null)}\n >\n <AlertTitle>{promoteRefusal.message}</AlertTitle>\n {promoteRefusal.violations.length ? (\n <Stack component=\"ul\" sx={{ pl: 2, m: 0 }}>\n {promoteRefusal.violations.map((violation) => (\n <Typography\n component=\"li\"\n variant=\"body2\"\n key={`${violation.code}:${violation.nodeId ?? violation.fieldName ?? ''}`}\n >\n {violation.message}\n </Typography>\n ))}\n </Stack>\n ) : null}\n </Alert>\n ) : null}\n {versions.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No versions yet — opening the besigner creates the first one.'}\n </Typography>\n ) : (\n <ScrollTable size=\"small\">\n <TableHead>\n <TableRow>\n <TableCell>{'Version'}</TableCell>\n <TableCell>{'Created'}</TableCell>\n <TableCell>{'Updated'}</TableCell>\n <TableCell align=\"right\">{'Actions'}</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {versions.map((version: any) => (\n <TableRow key={version.$id} hover>\n <TableCell>\n <Stack\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center' }}\n >\n <Typography variant=\"body2\">\n {version.displayName ?? version.$id}\n </Typography>\n {version.$id === publishedVersionId ? (\n <Chip\n label=\"Current\"\n color=\"success\"\n size=\"small\"\n />\n ) : null}\n </Stack>\n </TableCell>\n <TableCell>\n {version.createdAt?.toDate?.().toLocaleString() ??\n '--'}\n </TableCell>\n <TableCell>\n {version.updatedAt?.toDate?.().toLocaleString() ??\n '--'}\n </TableCell>\n <TableCell align=\"right\">\n <Stack\n direction=\"row\"\n spacing={1}\n sx={{ justifyContent: 'flex-end' }}\n >\n <Button\n size=\"small\"\n disabled={opening || !orgSlug || !host}\n onClick={handleOpen(version.$id)}\n >\n {'Open'}\n </Button>\n {/*\n The version the sites already serve has nothing\n to promote to, so the control is disabled\n rather than absent — an absent control and an\n inapplicable one look identical, and only one\n of them is honest.\n */}\n <Button\n size=\"small\"\n variant=\"outlined\"\n title={canPublish ? undefined : publishBlock}\n disabled={\n !canPublish ||\n promoting !== null ||\n version.$id === publishedVersionId\n }\n onClick={handlePromote(version.$id)}\n >\n {promoting === version.$id\n ? 'Publishing…'\n : version.$id === publishedVersionId\n ? 'Published'\n : 'Publish'}\n </Button>\n </Stack>\n </TableCell>\n </TableRow>\n ))}\n </TableBody>\n </ScrollTable>\n )}\n </Stack>\n </CardDisplay>\n ),\n },\n {\n /*\n THE MESSAGES THEMSELVES, under the numbers that describe them.\n Full width because it is a table of people and what they wrote,\n and it sits below the metrics because those are read at a glance\n and this is read a row at a time.\n */\n size: { xs: 12 },\n children: <FormSubmissionsCard hostId={hostId} formId={formId} />,\n },\n {\n // Full width: the frame is a document, and a document in a\n // five-column card is a column of one-word lines.\n size: { xs: 12 },\n children: (\n <CardDisplay\n header=\"What a submission will carry\"\n help={pluginDocsHelp('forms', {\n anchor: '#field-types',\n excerpt:\n 'Each field arrives under its own name. Two fields ' +\n 'sharing one name arrive as a single answer.',\n })}\n contentGutterX\n contentGutterY\n >\n <FormDesignPreview\n formId={formId}\n nodes={form?.nodes}\n consentFieldName={\n effectiveConsent ? effectiveConsent : undefined\n }\n loading={status === 'loading'}\n />\n </CardDisplay>\n ),\n },\n ]}\n />\n )\n\n return (\n <>\n {/*\n The page chrome this surface cannot set for itself. The console shell\n owns the layout and builds its heading from the Forms nav item, so\n without these the page about one form is headed `Forms` and its trail\n stops on the list — the same on every row of it.\n */}\n <PageHeaderRecord\n title={form ? form.displayName || formId : undefined}\n />\n {/*\n The besigner is what this surface exists to reach, so it leads — in\n the PAGE header, which is where an action belongs on a surface with\n no section rail beneath it. Withheld when there is no form: it would\n mint a version document under an id that has none (AGL-706).\n */}\n <PageHeaderActions>\n <Button\n size=\"small\"\n variant=\"contained\"\n disabled={opening || !orgSlug || !host}\n title={\n orgSlug && host ? undefined : 'Resolving this site’s address…'\n }\n onClick={handleOpen()}\n startIcon={\n <MdiIcon color=\"inherit\" path={ICON_VARIANT_BESIGNER.path} />\n }\n >\n {opening ? 'Opening…' : 'Edit in besigner'}\n </Button>\n </PageHeaderActions>\n {cards}\n </>\n )\n}\nFormDetailCard.displayName = 'FormDetailCard'\n\n/**\n * The `form` node inside a published design.\n *\n * A form document's tree holds exactly one, because the document IS that\n * form — but the tree is a flat map with a synthetic root, so the node has to\n * be found rather than assumed to be the root itself.\n */\nfunction findFormNodeId(\n nodes: Record<string, { componentId?: string }> | undefined,\n): string | undefined {\n return Object.keys(nodes ?? {}).find(\n (id) => nodes?.[id]?.componentId === 'form',\n )\n}\n\nexport default FormDetailCard\n"],"names":["Aglyn","buildRoute","formFieldsCanYieldAnEmail","formFieldsCaptureConsent","PageHeaderActions","PageHeaderRecord","listConsoleWidgets","pluginDocsHelp","Route","useConsoleWidgetSlot","pluginRecordFilteredHref","ICON_VARIANT_BESIGNER","AppLink","CardDisplay","GridItems","MdiIcon","useLoading","ScrollTable","useSnackbar","Timestamp","Alert","AlertTitle","Button","Chip","FormControlLabel","MenuItem","Stack","Switch","TableBody","TableCell","TableHead","TableRow","TextField","Typography","useConsoleHostRoute","useFirestore","useFirestoreCollection","useFirestoreDoc","useHostCampaigns","useHostVersionApi","CampaignPicker","collection","doc","limit","query","updateDoc","useRouter","useCallback","useMemo","useState","FORM_CONTACT_FIELDS_ZONE","FORMS_DOCUMENT_SEGMENT","FormDesignPreview","FormMetricsCard","FormSubmissionsCard","useFormPromoteApi","useFormStatsRecountApi","FormDetailCard","props","name","form","hostId","formId","basePath","canPublish","hostRoleLoaded","firestore","ContactFieldsZone","hasContactFieldsWidget","id","length","saveFields","fields","updatedAt","now","orgSlug","subdomain","host","createHostVersion","promoteForm","recountFormStats","router","enqueueSnackbar","queueLoading","data","status","idField","notFound","formNodes","decodeStoredNodes","nodes","versionDocs","versions","sort","a","b","createdAt","seconds","publishedVersionId","versionId","setName","lead","setLead","consentField","setConsentField","campaignIds","setCampaignIds","opening","setOpening","promoting","setPromoting","promoteRefusal","setPromoteRefusal","declaredFields","Array","isArray","effectiveLead","routing","effectiveConsent","String","consentFieldName","hasEmailField","capturesConsent","contactsHref","siteCampaigns","enabled","Boolean","storedCampaigns","readCampaignIds","effectiveCampaigns","violations","checkFormContract","formNodeId","findFormNodeId","handleSave","dequeue","displayName","trim","formListFields","slug","formCampaignFields","variant","persist","formIds","error","console","allowDuplicate","handlePromote","targetVersionId","result","ok","message","handleOpen","$id","createResourceUid","kind","parentId","Object","keys","CANVAS_ROOT_ELEMENT_ID","componentId","rootId","push","PLUGIN_DOCUMENT_BESIGNER","documentSegment","docId","dirty","campaignMembershipUnchanged","publishBlock","header","help","anchor","excerpt","contentGutterX","contentGutterY","spacing","sx","alignItems","severity","href","cards","items","size","xs","lg","children","label","value","onChange","event","target","fullWidth","color","options","helperText","empty","ready","direction","disabled","onClick","control","checked","select","map","field","fieldName","component","pl","m","violation","code","nodeId","slot","loading","stats","leadRouting","onClose","align","version","hover","toDate","toLocaleString","justifyContent","title","undefined","startIcon","path","find"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,YAAYA,WAAW,eAAc;AACrC,SACEC,UAAU,EAEVC,yBAAyB,EACzBC,wBAAwB,EACxBC,iBAAiB,EACjBC,gBAAgB,EAChBC,kBAAkB,EAClBC,cAAc,EACdC,KAAK,QACA,eAAc;AACrB,SAASC,oBAAoB,QAAQ,qDAAoD;AACzF,8EAA8E;AAC9E,0EAA0E;AAC1E,0EAA0E;AAC1E,6DAA6D;AAC7D,SAASC,wBAAwB,QAAQ,mDAAkD;AAC3F,SAASC,qBAAqB,QAAQ,2BAA0B;AAChE,SAASC,OAAO,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,UAAU,QAAQ,uBAAsB;AAC3F,SAASC,WAAW,QAAQ,yDAAwD;AACpF,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,SAAS,QAAQ,+BAA8B;AACxD,SACEC,KAAK,EACLC,UAAU,EACVC,MAAM,EACNC,IAAI,EACJC,gBAAgB,EAChBC,QAAQ,EACRC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,SAAS,EACTC,SAAS,EACTC,QAAQ,EACRC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SACEC,mBAAmB,EACnBC,YAAY,EACZC,sBAAsB,EACtBC,eAAe,EACfC,gBAAgB,EAChBC,iBAAiB,QACZ,iCAAgC;AACvC,OAAOC,oBAAoB,wEAA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;;8BAG1DvH,UAAU,aAAa;;;YAG3ByE;;;AAGP;AACA3H,eAAe+E,WAAW,GAAG;AAE7B;;;;;;CAMC,GACD,SAASH,eACP3C,KAA2D;IAE3D,OAAOmE,OAAOC,IAAI,CAACpE,gBAAAA,QAAS,CAAC,GAAGyI,IAAI,CAClC,CAAC9J;YAAOqB;eAAAA,CAAAA,0BAAAA,YAAAA,KAAO,CAACrB,GAAG,qBAAXqB,UAAasE,WAAW,MAAK;;AAEzC;AAEA,eAAevG,eAAc"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/forms/src/lib/components/form-detail-card.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 * as Aglyn from '@aglyn/aglyn'\nimport {\n buildRoute,\n type FormFieldDecl,\n formFieldsCanYieldAnEmail,\n formFieldsCaptureConsent,\n PageHeaderActions,\n PageHeaderRecord,\n listConsoleWidgets,\n pluginDocsHelp,\n Route,\n} from '@aglyn/aglyn'\nimport { useConsoleWidgetSlot } from '@aglyn/aglyn/app-utils/console-widget-slot-context'\n// The CRM's route builder by its leaf path, not the plugin barrel: the barrel\n// is the entry point the tenant's loader imports to activate the plugin's\n// site half, and a console page named there would ship to every published\n// page. The same import the Inbox makes for the same reason.\nimport { pluginRecordFilteredHref } from '@aglyn/aglyn/plugin-manager/plugin-record-routes'\nimport { ICON_VARIANT_BESIGNER } from '@aglyn/shared-data-enums'\nimport { AppLink, CardDisplay, GridItems, MdiIcon, useLoading } from '@aglyn/shared-ui-jsx'\nimport { ScrollTable } from '@aglyn/shared-ui-jsx/components/scroll-table.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { Timestamp } from '@aglyn/shared-util-timestamp'\nimport {\n Alert,\n AlertTitle,\n Button,\n Chip,\n FormControlLabel,\n MenuItem,\n Stack,\n Switch,\n TableBody,\n TableCell,\n TableHead,\n TableRow,\n TextField,\n Typography,\n} from '@mui/material'\nimport {\n useConsoleHostRoute,\n useFirestore,\n useFirestoreCollection,\n useFirestoreDoc,\n useSiteContainerOptions,\n useHostVersionApi,\n} from '@aglyn/tenant-feature-instance'\nimport ContainerPicker from '@aglyn/tenant-feature-instance/components/container-picker'\nimport { collection, doc, limit, query, updateDoc } from 'firebase/firestore'\nimport { useRouter } from 'next/navigation'\nimport { useCallback, useMemo, useState } from 'react'\nimport { FORM_CONTACT_FIELDS_ZONE } from './form-zones'\nimport { FORMS_DOCUMENT_SEGMENT } from '../constants/bundle-common'\nimport FormDesignPreview from './form-design-preview.component'\nimport FormMetricsCard from './form-metrics-card.component'\nimport FormSubmissionsCard from './form-submissions-card.component'\nimport useFormPromoteApi from './use-form-promote-api'\nimport useFormStatsRecountApi from './use-form-stats-recount-api'\n\nexport interface FormDetailCardProps {\n hostId: string\n formId: string\n /**\n * The Forms surface's own absolute console path.\n *\n * Only the not-found branch links it. The trail carries the way back on a\n * form that exists, so a link beside the heading would be the breadcrumb\n * written twice; a form that does NOT exist has no heading of its own for\n * the trail to end on, and the reader needs somewhere to go.\n */\n basePath?: string\n /** Whether this viewer's role on the site may make a version live. */\n canPublish?: boolean\n /** False while the role is still being read; see the disabled reasons. */\n hostRoleLoaded?: boolean\n}\n\n/**\n * One form — the component detail surface, for a document that is also a\n * contract.\n *\n * The split this enforces is the reason it exists rather than sending a row\n * straight into the besigner. A form has two halves:\n *\n * - the DESIGN, which is what an author draws, and which lives in the\n * besigner reached from here;\n * - the DECLARATION — where a submission is routed and which field carries\n * marketing consent — which is edited here.\n *\n * They are edited apart because the declaration is what the design is then\n * checked AGAINST. `checkFormContract` compares the two at publish, so a\n * surface that let an author change both in one motion would let them satisfy\n * the check by moving whichever side happened to be easier — which is how a\n * form ends up with lead routing pointed at a field nobody fills in.\n *\n * ## Promotion lives here, not only in the besigner\n *\n * A component's version history offers Publish on any version: promotion is\n * how you go back, not only how you go forward, and an author restoring last\n * week's design should not have to open a canvas to do it.\n *\n * It rides `/api/forms/promote` rather than an `updateDoc` here, because\n * a form's promotion has to run `checkFormContract` on the tree it is about to\n * write and REFUSE. A check in this component would be advice a determined\n * client could skip; the route reads the stored version itself, so nothing\n * about the design crosses the wire inbound and there is no version of this\n * surface that can publish a design the check has not seen.\n */\nexport function FormDetailCard(props: FormDetailCardProps) {\n const { hostId, formId, basePath, canPublish, hostRoleLoaded } = props\n const firestore = useFirestore()\n const ContactFieldsZone = useConsoleWidgetSlot()\n // Read at render, after the shell has loaded its plugins.\n const hasContactFieldsWidget =\n listConsoleWidgets(FORM_CONTACT_FIELDS_ZONE.id).length > 0\n /**\n * The write a widget in the contact-fields zone asks for. The declaration\n * is one array on the form document, and the document is this plugin's, so\n * the page writes what the widget decided.\n */\n const saveFields = useCallback(\n async (fields: FormFieldDecl[]) => {\n await updateDoc(doc(firestore, 'hosts', hostId, 'forms', formId), {\n fields,\n updatedAt: Timestamp.now(),\n })\n },\n [firestore, hostId, formId],\n )\n const { orgSlug, subdomain: host } = useConsoleHostRoute(hostId)\n const createHostVersion = useHostVersionApi()\n const promoteForm = useFormPromoteApi()\n const recountFormStats = useFormStatsRecountApi()\n const router = useRouter()\n const { enqueueSnackbar } = useSnackbar()\n const { queueLoading } = useLoading()\n\n const { data: form, status } = useFirestoreDoc<any>(\n () => doc(firestore, 'hosts', hostId, 'forms', formId),\n [firestore, hostId, formId],\n { idField: '$id' },\n )\n // Three states, not two (AGL-706): loading and absent both arrive as\n // `undefined`, and an editable form over a mistyped id reads as data loss.\n const notFound = status !== 'loading' && !form\n\n /**\n * The published design, in BOTH stored forms (AGL-1151).\n *\n * The read above is converter-less, so `nodes` arrives exactly as stored —\n * msgpack for a design promoted since forms were compressed, a plain map\n * for everything older. Decoded once here because two surfaces below need\n * it and both fail silently on the raw value: `checkFormContract` reports\n * bogus violations against a tree it cannot walk, and the AGL-753 empty\n * guard passes on a `Bytes` because `Object.keys` counts the wrapper.\n */\n const formNodes = useMemo(\n () => Aglyn.decodeStoredNodes<Record<string, any>>(form?.nodes),\n [form?.nodes],\n )\n\n // No orderBy: the oldest version docs predate `createdAt`, and Firestore\n // drops documents missing the ordered field.\n const { data: versionDocs } = useFirestoreCollection<any>(\n () =>\n query(\n collection(firestore, 'hosts', hostId, 'forms', formId, 'versions'),\n limit(100),\n ),\n [firestore, hostId, formId],\n { idField: '$id' },\n )\n const versions = [...(versionDocs ?? [])].sort(\n (a: any, b: any) =>\n (b.createdAt?.seconds ?? 0) - (a.createdAt?.seconds ?? 0),\n )\n const publishedVersionId = form?.versionId as string | undefined\n\n const [name, setName] = useState<string | null>(null)\n const [lead, setLead] = useState<boolean | null>(null)\n const [consentField, setConsentField] = useState<string | null>(null)\n /**\n * The campaigns picked on screen, or null while the stored value stands.\n *\n * Null and `[]` are different: null means \"not touched\", `[]` means \"take\n * this form out of every campaign\". Collapsing them would make clearing the\n * last campaign a no-op, which is the half of set-and-clear that is easy to\n * ship broken.\n */\n const [campaignIds, setCampaignIds] = useState<string[] | null>(null)\n const [opening, setOpening] = useState(false)\n const [promoting, setPromoting] = useState<string | null>(null)\n /**\n * What a REFUSED promotion said, kept on the surface rather than in a toast.\n *\n * A contract violation is a list of things to go and fix in the besigner,\n * and a snackbar is gone by the time the author has read the second one.\n * The besigner's own refusal persists for the same reason.\n */\n const [promoteRefusal, setPromoteRefusal] = useState<{\n message: string\n violations: Aglyn.FormContractViolation[]\n } | null>(null)\n\n /** The fields the PUBLISHED design draws, which is what a submission can carry. */\n const declaredFields: Aglyn.FormFieldDecl[] = useMemo(\n () => (Array.isArray(form?.fields) ? form.fields : []),\n [form],\n )\n\n const effectiveLead = lead ?? form?.routing?.lead === true\n const effectiveConsent = consentField ?? String(form?.consentFieldName ?? '')\n /*\n * Whether lead routing COULD work on this design — the two preconditions\n * `checkFormContract` applies at publish, asked here so the switch says so\n * before it is flipped rather than after (AGL-2612). Consent is read as\n * it is being edited: picking a field below is what satisfies it.\n */\n const hasEmailField = formFieldsCanYieldAnEmail(declaredFields)\n const capturesConsent = formFieldsCaptureConsent(declaredFields, effectiveConsent)\n /*\n * Where this form's people are: the contacts list narrowed to this form,\n * asked of the plugin that keeps people (`null`, and no link, without one). Built from the resolved org slug and\n * subdomain the besigner link already waits on, so the link appears when\n * they land and never points at a half-built address.\n */\n const contactsHref =\n orgSlug && host\n ? pluginRecordFilteredHref('contact', { orgSlug, host }, 'form', formId)\n : null\n /*\n * WHICH CAMPAIGNS THIS FORM IS PART OF.\n *\n * The site's campaigns are read while this page is open because the field\n * is DISPLAYED here as well as edited here: the document stores ids, and a\n * page that drew them until a button was pressed would be showing a\n * merchant raw storage. Bounded at the ceiling the campaigns table itself\n * draws, so it can offer nothing that list does not.\n */\n const siteCampaigns = useSiteContainerOptions('campaign', hostId, { enabled: Boolean(form) })\n const storedCampaigns = useMemo(\n () => Aglyn.readContainerIds(form as Record<string, unknown>, 'campaign'),\n [form],\n )\n const effectiveCampaigns = campaignIds ?? storedCampaigns\n\n /**\n * What the published design would break, judged against the declaration as\n * it is being edited here.\n *\n * Shown here as well as at publish because the two halves are edited in\n * different places: turning lead routing on for a form whose design has no\n * email field is a break the author causes HERE, on a design they are not\n * looking at, and the besigner would not tell them until they next opened\n * it.\n */\n const violations = useMemo(\n () =>\n form\n ? Aglyn.checkFormContract({\n form: {\n routing: { ...(form.routing ?? {}), lead: effectiveLead },\n ...(effectiveConsent\n ? { consentFieldName: effectiveConsent }\n : {}),\n },\n formId,\n nodes: formNodes as never,\n formNodeId: findFormNodeId(formNodes as never),\n })\n : [],\n [form, formId, effectiveLead, effectiveConsent],\n )\n\n const handleSave = useCallback(async () => {\n const dequeue = queueLoading()\n try {\n await updateDoc(doc(firestore, 'hosts', hostId, 'forms', formId), {\n // A rename carries the keys the Forms list searches by (AGL-3330), or\n // the form would be findable only by the name it used to have.\n ...(name != null\n ? {\n displayName: name.trim(),\n ...Aglyn.formListFields({\n id: formId,\n displayName: name.trim(),\n slug: form?.slug,\n }),\n }\n : {}),\n ...(lead != null ? { routing: { ...(form?.routing ?? {}), lead } } : {}),\n ...(consentField != null\n ? { consentFieldName: consentField.trim() }\n : {}),\n // An empty selection is stored as an empty array rather than removing\n // the field: one shape for \"in no campaign\", which is what keeps this\n // writer and the campaign's own detach agreeing. `inCampaign` rides\n // with it, the boolean the list's \"In a campaign\" filter asks\n // (AGL-3330).\n ...(campaignIds != null ? Aglyn.formCampaignFields(campaignIds) : {}),\n updatedAt: Timestamp.now(),\n })\n setName(null)\n setLead(null)\n setConsentField(null)\n setCampaignIds(null)\n enqueueSnackbar('Form saved', { variant: 'success', persist: false })\n /*\n * A form that routes leads holds `0` of them until its first, and one\n * that does not holds none (AGL-3330). The counters are the server's\n * to write, so the switch asks for them to be recounted.\n */\n if (lead != null && lead !== (form?.routing?.lead === true)) {\n void recountFormStats({ hostId, formIds: [formId] })\n }\n } catch (error) {\n console.error(error)\n enqueueSnackbar('An error has occurred', {\n variant: 'error',\n allowDuplicate: true,\n })\n } finally {\n dequeue()\n }\n }, [\n firestore,\n hostId,\n formId,\n form,\n name,\n lead,\n consentField,\n campaignIds,\n queueLoading,\n enqueueSnackbar,\n recountFormStats,\n ])\n\n /**\n * Makes one version the version the live sites serve.\n *\n * The route decides, not this handler: it re-reads the stored version, runs\n * `checkFormContract` on the tree it is about to write, and answers 422 with\n * the violations when a publish would stop the submissions arriving. So the\n * only thing here is what to do with each answer — and a refusal is put on\n * the page rather than in a toast, because it is a list of things to fix.\n */\n const handlePromote = useCallback(\n (targetVersionId: string) => async () => {\n if (promoting) return\n setPromoting(targetVersionId)\n setPromoteRefusal(null)\n try {\n const result = await promoteForm({ hostId, formId, versionId: targetVersionId })\n if (!result.ok) {\n const message = result.message ?? 'Publish failed'\n setPromoteRefusal({\n message,\n violations: result.violations ?? [],\n })\n // `persist` because this is a refusal an author has to act on: an\n // auto-dismissed warning is how someone walks away believing the\n // form shipped.\n enqueueSnackbar(message, {\n variant: 'warning',\n allowDuplicate: true,\n persist: true,\n })\n return\n }\n enqueueSnackbar(\n 'Published. The live sites now serve this version, and the form’s ' +\n 'declared fields match it.',\n { variant: 'success', persist: false },\n )\n } catch (error) {\n console.error(error)\n enqueueSnackbar('Could not publish that version', {\n variant: 'error',\n allowDuplicate: true,\n persist: true,\n })\n } finally {\n setPromoting(null)\n }\n },\n [promoting, promoteForm, hostId, formId, enqueueSnackbar],\n )\n\n /**\n * Opens a version in the besigner, minting the first one when the form has\n * none.\n *\n * Forms adopted from a page carry a declared field list and a `nodes` map\n * seeded from the page they were adopted from — so the first version opens\n * on the form the site was ALREADY submitting rather than a blank canvas.\n */\n const handleOpen = useCallback(\n (targetVersionId?: string) => async () => {\n if (opening) return\n setOpening(true)\n try {\n let versionId = targetVersionId ?? publishedVersionId ?? versions[0]?.$id\n if (!versionId) {\n versionId = Aglyn.createResourceUid()\n // Rides /api/hosts/versions: rules deny the client create, and the\n // route allows a resource's FIRST version on every plan — which\n // this always is, since the form reached here with no `versionId`.\n await createHostVersion({\n hostId,\n kind: 'form',\n parentId: formId,\n id: versionId,\n data: {\n formId,\n hostId,\n displayName: 'Initial version',\n // Emptiness, not just absence: a form that holds no `nodes` and\n // `??` would pass an empty map straight through to a version\n // that opens uneditable (AGL-753). Measured on the DECODED\n // tree — `Object.keys` over a stored `Bytes` is non-empty, so\n // the raw value passes this guard and mints exactly the\n // uneditable version it exists to stop (AGL-1151).\n nodes: Object.keys(formNodes ?? {}).length\n ? formNodes\n : {\n [Aglyn.CANVAS_ROOT_ELEMENT_ID]: {\n $id: Aglyn.CANVAS_ROOT_ELEMENT_ID,\n componentId: 'div',\n nodes: [],\n },\n },\n ...(form?.rootId ? { rootId: form.rootId } : {}),\n },\n })\n await updateDoc(doc(firestore, 'hosts', hostId, 'forms', formId), {\n versionId,\n updatedAt: Timestamp.now(),\n })\n }\n // The editor's URL needs the resolved org slug and subdomain, which\n // `useConsoleHostRoute` reads. Until they land the button below is\n // disabled, so this branch cannot be reached without them.\n if (orgSlug && host) {\n router.push(\n buildRoute(Route.PLUGIN_DOCUMENT_BESIGNER, {\n orgSlug,\n host,\n documentSegment: FORMS_DOCUMENT_SEGMENT,\n docId: formId,\n versionId,\n }),\n )\n }\n } catch (error) {\n console.error(error)\n enqueueSnackbar('Could not open the besigner', {\n variant: 'error',\n allowDuplicate: true,\n })\n setOpening(false)\n }\n },\n [\n opening,\n createHostVersion,\n publishedVersionId,\n versions,\n firestore,\n hostId,\n formId,\n form,\n router,\n orgSlug,\n host,\n enqueueSnackbar,\n ],\n )\n\n const dirty =\n name != null ||\n lead != null ||\n consentField != null ||\n (campaignIds != null &&\n !Aglyn.containerMembershipUnchanged(storedCampaigns, campaignIds))\n // Named before it is used on every row, so a role denial reads as a reason\n // rather than as a control that does nothing.\n const publishBlock = hostRoleLoaded\n ? 'Your role on this site can edit content but not publish it'\n : 'Checking what your role can do…'\n\n if (notFound) {\n return (\n <CardDisplay\n header=\"Form not found\"\n help={pluginDocsHelp('forms', {\n anchor: '#build-a-form',\n excerpt:\n 'A form is created from the Forms list and keeps the id every ' +\n 'submission is filed under.',\n })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={2} sx={{ alignItems: 'flex-start' }}>\n <Alert severity=\"info\">\n {`No form on this site has the id ${formId}. It may have been deleted, or the link may be from another site.`}\n </Alert>\n {basePath ? <AppLink href={basePath}>{'Back to forms'}</AppLink> : null}\n </Stack>\n </CardDisplay>\n )\n }\n\n /* The cards, named so the page chrome above them is a plain list of\n what this surface publishes upward. */\n const cards = (\n <GridItems\n spacing={3}\n items={[\n {\n size: { xs: 12, lg: 5 },\n children: (\n <CardDisplay\n header=\"Details\"\n help={pluginDocsHelp('forms', {\n anchor: '#build-a-form',\n excerpt:\n 'The id is what every submission is filed under, so ' +\n 'renaming a form never splits its history.',\n })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={2}>\n <TextField\n label=\"Display name\"\n size=\"small\"\n value={name ?? form?.displayName ?? ''}\n onChange={(event) => setName(event.target.value)}\n fullWidth\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`ID ${formId} — every submission is filed under this, so it never changes`}\n </Typography>\n {/*\n A FORM IS PART OF A CAMPAIGN, and may be part of several.\n The same signup form is placed by one push and re-placed by\n the next, so this is a multi-select — a single value would\n make filing it under this quarter's campaign silently\n un-file it from last quarter's.\n\n It is an assignment and nothing else: it does not decide who\n a campaign mails, and it does not credit a submission to\n one. Attribution is recorded from the link a visitor\n followed, on its own evidence, and it goes on saying what it\n says whatever is picked here.\n */}\n <ContainerPicker\n kind=\"campaign\"\n options={siteCampaigns.options}\n value={effectiveCampaigns}\n onChange={setCampaignIds}\n helperText=\"The campaigns this form is part of. It does not change who a campaign mails.\"\n empty={siteCampaigns.ready && !siteCampaigns.options.length}\n />\n <Stack direction=\"row\" spacing={1}>\n <Button\n variant=\"contained\"\n color=\"primary\"\n size=\"small\"\n disabled={!dirty}\n onClick={handleSave}\n >\n {'Save'}\n </Button>\n </Stack>\n </Stack>\n </CardDisplay>\n ),\n },\n {\n size: { xs: 12, lg: 7 },\n children: (\n <CardDisplay\n header=\"CRM routing\"\n help={pluginDocsHelp('forms', {\n anchor: '#where-submissions-go',\n excerpt:\n 'Every submission reaches the Inbox and updates the ' +\n 'contact. Lead routing and the consent field decide ' +\n 'what else happens to it.',\n })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={2}>\n {/*\n THE PART THAT IS NOT A SWITCH (AGL-2612). Every capture\n lands in Contacts whatever is set below; the switch decides\n only whether a LEAD is filed beside the contact. Said\n first, because the switch on its own read as the only way\n a submission reached the CRM.\n */}\n <Typography variant=\"body2\">\n {'Every submission with an email address updates the person ' +\n 'in Contacts at stage Lead — a new contact when the ' +\n 'address is new, an interaction on their timeline when it ' +\n 'is not. A customer stays a customer.'}\n </Typography>\n <Stack spacing={0.5}>\n <FormControlLabel\n control={\n <Switch\n checked={effectiveLead}\n onChange={(event) => setLead(event.target.checked)}\n />\n }\n label=\"Also create a lead from the address someone gives this form\"\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {!hasEmailField\n ? 'Needs an email field in the published design — a ' +\n 'submission without an address cannot key a lead, and ' +\n 'publishing with this on would be refused until one exists.'\n : !capturesConsent\n ? 'Needs a marketing consent field — a lead nobody opted ' +\n 'in with is one the team cannot email, and publishing ' +\n 'with this on would be refused until the field below ' +\n 'names one.'\n : 'Files a lead in CRM → Leads for the sales team to work, ' +\n 'carrying the opt-in the consent field records.'}\n </Typography>\n </Stack>\n <TextField\n select\n label=\"Marketing consent field\"\n size=\"small\"\n value={effectiveConsent}\n onChange={(event) => setConsentField(event.target.value)}\n fullWidth\n helperText=\"The one field that IS the opt-in. Submitting a form is never itself consent.\"\n >\n <MenuItem value=\"\">\n {'None — this form collects no opt-in'}\n </MenuItem>\n {declaredFields.map((field) => (\n <MenuItem key={field.fieldName} value={field.fieldName}>\n {field.label\n ? `${field.label} (${field.fieldName})`\n : field.fieldName}\n </MenuItem>\n ))}\n </TextField>\n {violations.length ? (\n <Alert severity=\"warning\">\n <AlertTitle>{'This form would stop collecting'}</AlertTitle>\n <Stack component=\"ul\" sx={{ pl: 2, m: 0 }}>\n {violations.map((violation) => (\n <Typography\n component=\"li\"\n variant=\"body2\"\n key={`${violation.code}:${violation.nodeId ?? violation.fieldName ?? ''}`}\n >\n {violation.message}\n </Typography>\n ))}\n </Stack>\n </Alert>\n ) : null}\n {/*\n The people this form captured, on the list that holds them.\n Withheld until the site's address resolves, for the reason\n the besigner button is.\n */}\n {contactsHref ? (\n <Typography variant=\"body2\">\n <AppLink href={contactsHref}>\n {'See the contacts this form captured in the CRM'}\n </AppLink>\n </Typography>\n ) : null}\n </Stack>\n </CardDisplay>\n ),\n },\n // Where each field saves on the person: another plugin's card, in a\n // zone this page hosts. No item at all where nothing fills it, so the\n // grid keeps no empty cell.\n ...(ContactFieldsZone && hasContactFieldsWidget\n ? [\n {\n size: { xs: 12 },\n children: (\n <ContactFieldsZone\n slot={FORM_CONTACT_FIELDS_ZONE.id}\n hostId={hostId}\n formId={formId}\n fields={declaredFields}\n loading={status === 'loading'}\n saveFields={saveFields}\n />\n ),\n },\n ]\n : []),\n {\n size: { xs: 12, lg: 5 },\n children: (\n <FormMetricsCard\n stats={form?.stats}\n fields={declaredFields}\n leadRouting={effectiveLead}\n loading={status === 'loading'}\n />\n ),\n },\n {\n size: { xs: 12, lg: 7 },\n children: (\n <CardDisplay\n header=\"Versions\"\n help={pluginDocsHelp('forms', {\n anchor: '#build-a-form',\n excerpt:\n 'Publishing a form version updates every page that ' +\n 'places it. Saving does not — a save is not a publish.',\n })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={2}>\n {promoteRefusal ? (\n <Alert\n severity=\"warning\"\n onClose={() => setPromoteRefusal(null)}\n >\n <AlertTitle>{promoteRefusal.message}</AlertTitle>\n {promoteRefusal.violations.length ? (\n <Stack component=\"ul\" sx={{ pl: 2, m: 0 }}>\n {promoteRefusal.violations.map((violation) => (\n <Typography\n component=\"li\"\n variant=\"body2\"\n key={`${violation.code}:${violation.nodeId ?? violation.fieldName ?? ''}`}\n >\n {violation.message}\n </Typography>\n ))}\n </Stack>\n ) : null}\n </Alert>\n ) : null}\n {versions.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No versions yet — opening the besigner creates the first one.'}\n </Typography>\n ) : (\n <ScrollTable size=\"small\">\n <TableHead>\n <TableRow>\n <TableCell>{'Version'}</TableCell>\n <TableCell>{'Created'}</TableCell>\n <TableCell>{'Updated'}</TableCell>\n <TableCell align=\"right\">{'Actions'}</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {versions.map((version: any) => (\n <TableRow key={version.$id} hover>\n <TableCell>\n <Stack\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center' }}\n >\n <Typography variant=\"body2\">\n {version.displayName ?? version.$id}\n </Typography>\n {version.$id === publishedVersionId ? (\n <Chip\n label=\"Current\"\n color=\"success\"\n size=\"small\"\n />\n ) : null}\n </Stack>\n </TableCell>\n <TableCell>\n {version.createdAt?.toDate?.().toLocaleString() ??\n '--'}\n </TableCell>\n <TableCell>\n {version.updatedAt?.toDate?.().toLocaleString() ??\n '--'}\n </TableCell>\n <TableCell align=\"right\">\n <Stack\n direction=\"row\"\n spacing={1}\n sx={{ justifyContent: 'flex-end' }}\n >\n <Button\n size=\"small\"\n disabled={opening || !orgSlug || !host}\n onClick={handleOpen(version.$id)}\n >\n {'Open'}\n </Button>\n {/*\n The version the sites already serve has nothing\n to promote to, so the control is disabled\n rather than absent — an absent control and an\n inapplicable one look identical, and only one\n of them is honest.\n */}\n <Button\n size=\"small\"\n variant=\"outlined\"\n title={canPublish ? undefined : publishBlock}\n disabled={\n !canPublish ||\n promoting !== null ||\n version.$id === publishedVersionId\n }\n onClick={handlePromote(version.$id)}\n >\n {promoting === version.$id\n ? 'Publishing…'\n : version.$id === publishedVersionId\n ? 'Published'\n : 'Publish'}\n </Button>\n </Stack>\n </TableCell>\n </TableRow>\n ))}\n </TableBody>\n </ScrollTable>\n )}\n </Stack>\n </CardDisplay>\n ),\n },\n {\n /*\n THE MESSAGES THEMSELVES, under the numbers that describe them.\n Full width because it is a table of people and what they wrote,\n and it sits below the metrics because those are read at a glance\n and this is read a row at a time.\n */\n size: { xs: 12 },\n children: <FormSubmissionsCard hostId={hostId} formId={formId} />,\n },\n {\n // Full width: the frame is a document, and a document in a\n // five-column card is a column of one-word lines.\n size: { xs: 12 },\n children: (\n <CardDisplay\n header=\"What a submission will carry\"\n help={pluginDocsHelp('forms', {\n anchor: '#field-types',\n excerpt:\n 'Each field arrives under its own name. Two fields ' +\n 'sharing one name arrive as a single answer.',\n })}\n contentGutterX\n contentGutterY\n >\n <FormDesignPreview\n formId={formId}\n nodes={form?.nodes}\n consentFieldName={\n effectiveConsent ? effectiveConsent : undefined\n }\n loading={status === 'loading'}\n />\n </CardDisplay>\n ),\n },\n ]}\n />\n )\n\n return (\n <>\n {/*\n The page chrome this surface cannot set for itself. The console shell\n owns the layout and builds its heading from the Forms nav item, so\n without these the page about one form is headed `Forms` and its trail\n stops on the list — the same on every row of it.\n */}\n <PageHeaderRecord\n title={form ? form.displayName || formId : undefined}\n />\n {/*\n The besigner is what this surface exists to reach, so it leads — in\n the PAGE header, which is where an action belongs on a surface with\n no section rail beneath it. Withheld when there is no form: it would\n mint a version document under an id that has none (AGL-706).\n */}\n <PageHeaderActions>\n <Button\n size=\"small\"\n variant=\"contained\"\n disabled={opening || !orgSlug || !host}\n title={\n orgSlug && host ? undefined : 'Resolving this site’s address…'\n }\n onClick={handleOpen()}\n startIcon={\n <MdiIcon color=\"inherit\" path={ICON_VARIANT_BESIGNER.path} />\n }\n >\n {opening ? 'Opening…' : 'Edit in besigner'}\n </Button>\n </PageHeaderActions>\n {cards}\n </>\n )\n}\nFormDetailCard.displayName = 'FormDetailCard'\n\n/**\n * The `form` node inside a published design.\n *\n * A form document's tree holds exactly one, because the document IS that\n * form — but the tree is a flat map with a synthetic root, so the node has to\n * be found rather than assumed to be the root itself.\n */\nfunction findFormNodeId(\n nodes: Record<string, { componentId?: string }> | undefined,\n): string | undefined {\n return Object.keys(nodes ?? {}).find(\n (id) => nodes?.[id]?.componentId === 'form',\n )\n}\n\nexport default FormDetailCard\n"],"names":["Aglyn","buildRoute","formFieldsCanYieldAnEmail","formFieldsCaptureConsent","PageHeaderActions","PageHeaderRecord","listConsoleWidgets","pluginDocsHelp","Route","useConsoleWidgetSlot","pluginRecordFilteredHref","ICON_VARIANT_BESIGNER","AppLink","CardDisplay","GridItems","MdiIcon","useLoading","ScrollTable","useSnackbar","Timestamp","Alert","AlertTitle","Button","Chip","FormControlLabel","MenuItem","Stack","Switch","TableBody","TableCell","TableHead","TableRow","TextField","Typography","useConsoleHostRoute","useFirestore","useFirestoreCollection","useFirestoreDoc","useSiteContainerOptions","useHostVersionApi","ContainerPicker","collection","doc","limit","query","updateDoc","useRouter","useCallback","useMemo","useState","FORM_CONTACT_FIELDS_ZONE","FORMS_DOCUMENT_SEGMENT","FormDesignPreview","FormMetricsCard","FormSubmissionsCard","useFormPromoteApi","useFormStatsRecountApi","FormDetailCard","props","name","form","hostId","formId","basePath","canPublish","hostRoleLoaded","firestore","ContactFieldsZone","hasContactFieldsWidget","id","length","saveFields","fields","updatedAt","now","orgSlug","subdomain","host","createHostVersion","promoteForm","recountFormStats","router","enqueueSnackbar","queueLoading","data","status","idField","notFound","formNodes","decodeStoredNodes","nodes","versionDocs","versions","sort","a","b","createdAt","seconds","publishedVersionId","versionId","setName","lead","setLead","consentField","setConsentField","campaignIds","setCampaignIds","opening","setOpening","promoting","setPromoting","promoteRefusal","setPromoteRefusal","declaredFields","Array","isArray","effectiveLead","routing","effectiveConsent","String","consentFieldName","hasEmailField","capturesConsent","contactsHref","siteCampaigns","enabled","Boolean","storedCampaigns","readContainerIds","effectiveCampaigns","violations","checkFormContract","formNodeId","findFormNodeId","handleSave","dequeue","displayName","trim","formListFields","slug","formCampaignFields","variant","persist","formIds","error","console","allowDuplicate","handlePromote","targetVersionId","result","ok","message","handleOpen","$id","createResourceUid","kind","parentId","Object","keys","CANVAS_ROOT_ELEMENT_ID","componentId","rootId","push","PLUGIN_DOCUMENT_BESIGNER","documentSegment","docId","dirty","containerMembershipUnchanged","publishBlock","header","help","anchor","excerpt","contentGutterX","contentGutterY","spacing","sx","alignItems","severity","href","cards","items","size","xs","lg","children","label","value","onChange","event","target","fullWidth","color","options","helperText","empty","ready","direction","disabled","onClick","control","checked","select","map","field","fieldName","component","pl","m","violation","code","nodeId","slot","loading","stats","leadRouting","onClose","align","version","hover","toDate","toLocaleString","justifyContent","title","undefined","startIcon","path","find"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,YAAYA,WAAW,eAAc;AACrC,SACEC,U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AQjE,GAAG;;;;;;;;YA0E1C;YACA;gBACE;;;;;WAKC,GACD6B,MAAM;oBAAEC,IAAI;gBAAG;gBACfE,wBAAU,KAACnI;oBAAoBO,QAAQA;oBAAQC,QAAQA;;YACzD;YACA;gBACE,2DAA2D;gBAC3D,kDAAkD;gBAClDwH,MAAM;oBAAEC,IAAI;gBAAG;gBACfE,wBACE,KAAC5K;oBACC4J,QAAO;oBACPC,MAAMnK,eAAe,SAAS;wBAC5BoK,QAAQ;wBACRC,SACE,uDACA;oBACJ;oBACAC,cAAc;oBACdC,cAAc;8BAEd,cAAA,KAAC1H;wBACCU,QAAQA;wBACR4B,KAAK,EAAE9B,wBAAAA,KAAM8B,KAAK;wBAClB8B,kBACEF,mBAAmBA,mBAAmB0G;wBAExCX,SAAShI,WAAW;;;YAI5B;SACD;;IAIL,qBACE;;0BAOE,KAAChF;gBACC0N,OAAOnK,OAAOA,KAAK4E,WAAW,IAAI1E,SAASkK;;0BAQ7C,KAAC5N;0BACC,cAAA,KAACkB;oBACCgK,MAAK;oBACLzC,SAAQ;oBACRyD,UAAU3F,WAAW,CAAChC,WAAW,CAACE;oBAClCkJ,OACEpJ,WAAWE,OAAOmJ,YAAY;oBAEhCzB,SAAS/C;oBACTyE,yBACE,KAAClN;wBAAQiL,OAAM;wBAAUkC,MAAMvN,sBAAsBuN,IAAI;;8BAG1DvH,UAAU,aAAa;;;YAG3ByE;;;AAGP;AACA3H,eAAe+E,WAAW,GAAG;AAE7B;;;;;;CAMC,GACD,SAASH,eACP3C,KAA2D;IAE3D,OAAOmE,OAAOC,IAAI,CAACpE,gBAAAA,QAAS,CAAC,GAAGyI,IAAI,CAClC,CAAC9J;YAAOqB;eAAAA,CAAAA,0BAAAA,YAAAA,KAAO,CAACrB,GAAG,qBAAXqB,UAAasE,WAAW,MAAK;;AAEzC;AAEA,eAAevG,eAAc"}
@@ -15,6 +15,15 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import type { FormFieldDecl } from '@aglyn/aglyn';
18
+ import type { ConsoleHostScreensZoneProps } from '@aglyn/aglyn/plugin-manager/feature-plugins';
19
+ /**
20
+ * The Forms page of a site, beside its Create Form action (AGL-3043): another
21
+ * way to start a form. A widget here is handed the site and its org — the
22
+ * `hostScreens` contract a site's pages, templates and components hand too —
23
+ * and opens its own way to a new form; it writes nothing through the page.
24
+ */
25
+ export type HostFormsZoneProps = ConsoleHostScreensZoneProps;
26
+ export declare const HOST_FORMS_ZONE: import("@aglyn/aglyn/plugin-manager/plugin-zones").PluginZone<ConsoleHostScreensZoneProps>;
18
27
  /**
19
28
  * What the forms plugin hands a widget that reads ONE form's submissions.
20
29
  *
@@ -14,6 +14,7 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */ import { definePluginZone } from "@aglyn/aglyn/plugin-manager/plugin-zones";
17
+ export const HOST_FORMS_ZONE = definePluginZone('hostForms');
17
18
  export const FORM_SUBMISSIONS_ZONE = definePluginZone('formSubmissions');
18
19
  export const FORM_CONTACT_FIELDS_ZONE = definePluginZone('formContactFields');
19
20
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/forms/src/lib/components/form-zones.ts"],"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\nimport type { FormFieldDecl } from '@aglyn/aglyn'\nimport { definePluginZone } from '@aglyn/aglyn/plugin-manager/plugin-zones'\n\n/**\n * What the forms plugin hands a widget that reads ONE form's submissions.\n *\n * The forms plugin owns the form and the page it is read on; it does not own\n * the reader. Reading submissions — the paged, ordered walk, the read marks,\n * the replies, the attribution — is what a plugin like the Inbox is for, and\n * this zone is where one draws it, scoped to this form, without the forms\n * plugin importing it.\n */\nexport interface FormSubmissionsZoneProps {\n hostId: string\n formId: string\n}\n\nexport const FORM_SUBMISSIONS_ZONE =\n definePluginZone<FormSubmissionsZoneProps>('formSubmissions')\n\n/**\n * Where each of a form's fields saves on the person, decided by whichever\n * plugin keeps people.\n *\n * A form declares its fields; what a contact's fields are is another plugin's\n * to know. This zone sits on the form's page beside routing and the consent\n * field and hands that plugin the published declaration. A widget here decides\n * what the declaration should become and calls `saveFields`; the page does the\n * write, because the form document is this plugin's.\n */\nexport interface FormContactFieldsZoneProps {\n hostId: string\n formId: string\n /** The PUBLISHED declaration, as stored on the form document. */\n fields: readonly FormFieldDecl[]\n /** True while the form document is still being read. */\n loading?: boolean\n /** Writes the declaration back onto the form document. */\n saveFields: (fields: FormFieldDecl[]) => Promise<void>\n}\n\nexport const FORM_CONTACT_FIELDS_ZONE =\n definePluginZone<FormContactFieldsZoneProps>('formContactFields')\n"],"names":["definePluginZone","FORM_SUBMISSIONS_ZONE","FORM_CONTACT_FIELDS_ZONE"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAGD,SAASA,gBAAgB,QAAQ,2CAA0C;AAgB3E,OAAO,MAAMC,wBACXD,iBAA2C,mBAAkB;AAuB/D,OAAO,MAAME,2BACXF,iBAA6C,qBAAoB"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/forms/src/lib/components/form-zones.ts"],"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\nimport type { FormFieldDecl } from '@aglyn/aglyn'\nimport type { ConsoleHostScreensZoneProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { definePluginZone } from '@aglyn/aglyn/plugin-manager/plugin-zones'\n\n/**\n * The Forms page of a site, beside its Create Form action (AGL-3043): another\n * way to start a form. A widget here is handed the site and its org — the\n * `hostScreens` contract a site's pages, templates and components hand too —\n * and opens its own way to a new form; it writes nothing through the page.\n */\nexport type HostFormsZoneProps = ConsoleHostScreensZoneProps\n\nexport const HOST_FORMS_ZONE = definePluginZone<HostFormsZoneProps>('hostForms')\n\n/**\n * What the forms plugin hands a widget that reads ONE form's submissions.\n *\n * The forms plugin owns the form and the page it is read on; it does not own\n * the reader. Reading submissions — the paged, ordered walk, the read marks,\n * the replies, the attribution — is what a plugin like the Inbox is for, and\n * this zone is where one draws it, scoped to this form, without the forms\n * plugin importing it.\n */\nexport interface FormSubmissionsZoneProps {\n hostId: string\n formId: string\n}\n\nexport const FORM_SUBMISSIONS_ZONE =\n definePluginZone<FormSubmissionsZoneProps>('formSubmissions')\n\n/**\n * Where each of a form's fields saves on the person, decided by whichever\n * plugin keeps people.\n *\n * A form declares its fields; what a contact's fields are is another plugin's\n * to know. This zone sits on the form's page beside routing and the consent\n * field and hands that plugin the published declaration. A widget here decides\n * what the declaration should become and calls `saveFields`; the page does the\n * write, because the form document is this plugin's.\n */\nexport interface FormContactFieldsZoneProps {\n hostId: string\n formId: string\n /** The PUBLISHED declaration, as stored on the form document. */\n fields: readonly FormFieldDecl[]\n /** True while the form document is still being read. */\n loading?: boolean\n /** Writes the declaration back onto the form document. */\n saveFields: (fields: FormFieldDecl[]) => Promise<void>\n}\n\nexport const FORM_CONTACT_FIELDS_ZONE =\n definePluginZone<FormContactFieldsZoneProps>('formContactFields')\n"],"names":["definePluginZone","HOST_FORMS_ZONE","FORM_SUBMISSIONS_ZONE","FORM_CONTACT_FIELDS_ZONE"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAID,SAASA,gBAAgB,QAAQ,2CAA0C;AAU3E,OAAO,MAAMC,kBAAkBD,iBAAqC,aAAY;AAgBhF,OAAO,MAAME,wBACXF,iBAA2C,mBAAkB;AAuB/D,OAAO,MAAMG,2BACXH,iBAA6C,qBAAoB"}
@@ -18,7 +18,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
18
18
  * limitations under the License.
19
19
  */ import { sendAnalyticsBeacon } from "@aglyn/aglyn/app-utils/analytics-beacon";
20
20
  import { trackEventBeforeNavigation } from "@aglyn/aglyn/app-utils/analytics-events";
21
- import { campaignTouchField } from "@aglyn/aglyn/app-utils/campaign-touch";
21
+ import { utmTouchField } from "@aglyn/aglyn/app-utils/utm-touch";
22
22
  import * as Aglyn from "@aglyn/aglyn";
23
23
  import { mdiEmailFastOutline, mdiEmailOutline, mdiFormTextbox } from "@aglyn/shared-data-mdi";
24
24
  import { isSameOriginPath } from "@aglyn/shared-util-http/safe-redirect";
@@ -308,7 +308,7 @@ const REVEAL_NODE_ID_PATTERN = /^[A-Za-z0-9_-]+$/;
308
308
  website
309
309
  }, consentGroup ? {
310
310
  [CONSENT_GROUP_INPUT]: consentGroup
311
- } : {}, campaignTouchField()))
311
+ } : {}, utmTouchField()))
312
312
  });
313
313
  if (response.ok) {
314
314
  // Site alerts from the actions builder (AGL-148).