@aglyn/plugins-outreach 1.0.0-beta.204 → 1.0.0-beta.206

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/outreach/src/lib/components/next-send.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 { Tooltip, Typography } from '@mui/material'\nimport { useEffect, useState } from 'react'\nimport type { OutreachNextSendState, OutreachQueuedReason } from '../engine/next-send'\nimport { isOutreachWindowOpen } from '../engine/schedule'\nimport { OUTREACH_TICK_MINUTES, outreachTickAllowance } from '../engine/sending-capacity'\nimport type { OutreachMailbox } from '../model/outreach.types'\nimport { formatOutreachTime } from './outreach-ui'\n\n/*\n * The words for an enrollment's next send (AGL-3366): a time while it is\n * still ahead, and once it has come, the queue it is waiting in — short in\n * the cell, whole in the tooltip, which also keeps the exact due time.\n */\n\nconst QUEUED_LABELS: Record<OutreachQueuedReason, string> = {\n paced: 'Queued · paced',\n next_run: 'Queued · next run',\n window_closed: 'Queued · window closed',\n daily_cap_reached: 'Queued · cap reached',\n mailbox_not_sending: 'Held · mailbox not sending',\n sequence_not_active: 'Held · sequence not active',\n}\n\n/**\n * The clock next sends are judged against, moved on every minute so a row\n * turns from its time to \"Queued\" while the page stays open.\n */\nexport function useOutreachNowMs(everyMs = 60_000): number {\n const [nowMs, setNowMs] = useState(() => Date.now())\n useEffect(() => {\n const timer = setInterval(() => setNowMs(Date.now()), everyMs)\n return () => clearInterval(timer)\n }, [everyMs])\n return nowMs\n}\n\n/** What the cell, the chip and the export say. */\nexport function outreachNextSendLabel(state: OutreachNextSendState, timeZone: string | null): string {\n if (state.kind === 'none') return '—'\n if (state.kind === 'scheduled') return formatOutreachTime(state.dueAtMs, timeZone)\n return QUEUED_LABELS[state.reason]\n}\n\n/** The whole explanation of a queued send; `''` for one that is not queued. */\nexport function outreachNextSendDetail(state: OutreachNextSendState, timeZone: string | null): string {\n if (state.kind !== 'queued') return ''\n const time = (ms: number | null) => formatOutreachTime(ms, timeZone)\n const due = `Due ${time(state.dueAtMs)}.`\n const pacing = state.pacing\n ? ` This mailbox has sent ${state.pacing.sentToday} of ${state.pacing.dailyCap} today` +\n (state.reason === 'paced' ? ` and may send ${state.pacing.allowance} in this run.` : '.')\n : ''\n switch (state.reason) {\n case 'paced':\n return (\n `${due} Emails go out a few at a time every ${OUTREACH_TICK_MINUTES} minutes, ` +\n 'follow-ups first, so the day’s cap is spread across the send window rather than ' +\n `sent at once. This one goes out in a later run.${pacing}`\n )\n case 'next_run':\n return `${due} The task is created on the next run, within ${OUTREACH_TICK_MINUTES} minutes.`\n case 'window_closed':\n return `${due} The send window is closed; it goes out once the window opens${\n state.opensAtMs ? `, ${time(state.opensAtMs)}` : ''\n }.${pacing}`\n case 'daily_cap_reached':\n return `${due}${pacing} Sending resumes${\n state.opensAtMs ? ` ${time(state.opensAtMs)}` : ' in the next window'\n }.`\n case 'mailbox_not_sending':\n return `${due} Its mailbox is not sending, so nothing goes out until it is connected and resumed.`\n case 'sequence_not_active':\n return `${due} The sequence is not active, so nothing goes out until it is activated.`\n }\n}\n\n/**\n * The Mailboxes card's one line on pacing: what has gone today against the\n * cap, and how much the next run may send — the number a due enrollment's\n * \"Queued\" is waiting on.\n */\nexport function outreachPacingNote(\n mailbox: Pick<\n OutreachMailbox,\n 'status' | 'dailyCap' | 'rampStartedAtMs' | 'timezone' | 'window' | 'health'\n >,\n nowMs: number,\n): string {\n const tick = outreachTickAllowance({ mailbox, nowMs })\n if (tick.hold === 'mailbox_not_connected' || tick.hold === 'invalid_timezone') {\n return 'Sends nothing until it is connected and sending.'\n }\n const today = `Today: ${tick.sentToday} of ${tick.dailyCap} sent`\n if (tick.hold === 'daily_cap_reached') return `${today} · cap reached, sending resumes in the next day’s window.`\n if (!isOutreachWindowOpen(nowMs, mailbox.window, mailbox.timezone)) {\n return `${today} · outside its send window.`\n }\n return (\n `${today} · up to ${tick.allowance} per ${OUTREACH_TICK_MINUTES}-minute run now, ` +\n 'follow-ups first, so the rest of the day’s cap is spread across the window.'\n )\n}\n\n/** An enrollment's next send, with the reason on hover when it is queued. */\nexport function OutreachNextSend(props: { state: OutreachNextSendState; timeZone: string | null }) {\n const { state, timeZone } = props\n const label = outreachNextSendLabel(state, timeZone)\n if (state.kind !== 'queued') {\n return (\n <Typography variant=\"body2\" color={state.kind === 'none' ? 'text.secondary' : undefined}>\n {label}\n </Typography>\n )\n }\n return (\n <Tooltip title={outreachNextSendDetail(state, timeZone)} describeChild>\n <Typography\n variant=\"body2\"\n color={\n state.reason === 'mailbox_not_sending' || state.reason === 'sequence_not_active'\n ? 'warning.main'\n : 'text.secondary'\n }\n sx={{ textDecoration: 'underline dotted', textUnderlineOffset: 3, cursor: 'help' }}\n >\n {label}\n </Typography>\n </Tooltip>\n )\n}\n"],"names":["Tooltip","Typography","useEffect","useState","isOutreachWindowOpen","OUTREACH_TICK_MINUTES","outreachTickAllowance","formatOutreachTime","QUEUED_LABELS","paced","next_run","window_closed","daily_cap_reached","mailbox_not_sending","sequence_not_active","useOutreachNowMs","everyMs","nowMs","setNowMs","Date","now","timer","setInterval","clearInterval","outreachNextSendLabel","state","timeZone","kind","dueAtMs","reason","outreachNextSendDetail","time","ms","due","pacing","sentToday","dailyCap","allowance","opensAtMs","outreachPacingNote","mailbox","tick","hold","today","window","timezone","OutreachNextSend","props","label","variant","color","undefined","title","describeChild","sx","textDecoration","textUnderlineOffset","cursor"],"mappings":"AAAA;;;;;;;;;;;;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,OAAO,GAAGF,MAAM,2BAA2B,CAAC;IAC9C;IACA,OACE,GAAGA,MAAM,SAAS,EAAEF,KAAKJ,SAAS,CAAC,KAAK,EAAEhC,sBAAsB,iBAAiB,CAAC,GAClF;AAEJ;AAEA,2EAA2E,GAC3E,OAAO,SAASyC,iBAAiBC,KAAgE;IAC/F,MAAM,EAAEtB,KAAK,EAAEC,QAAQ,EAAE,GAAGqB;IAC5B,MAAMC,QAAQxB,sBAAsBC,OAAOC;IAC3C,IAAID,MAAME,IAAI,KAAK,UAAU;QAC3B,qBACE,KAAC1B;YAAWgD,SAAQ;YAAQC,OAAOzB,MAAME,IAAI,KAAK,SAAS,mBAAmBwB;sBAC3EH;;IAGP;IACA,qBACE,KAAChD;QAAQoD,OAAOtB,uBAAuBL,OAAOC;QAAW2B,aAAa;kBACpE,cAAA,KAACpD;YACCgD,SAAQ;YACRC,OACEzB,MAAMI,MAAM,KAAK,yBAAyBJ,MAAMI,MAAM,KAAK,wBACvD,iBACA;YAENyB,IAAI;gBAAEC,gBAAgB;gBAAoBC,qBAAqB;gBAAGC,QAAQ;YAAO;sBAEhFT;;;AAIT"}
@@ -447,6 +447,8 @@ import { useOutreachSequence, useOutreachSequenceLinks } from "./use-outreach-da
447
447
  // not it counts them now.
448
448
  trackClicks: sequence.settings.trackClicks || ((_sequence_stats = sequence.stats) == null ? void 0 : _sequence_stats.clickTracked) === true,
449
449
  timeZone: (_ref2 = mailbox == null ? void 0 : mailbox.timezone) != null ? _ref2 : null,
450
+ mailbox: props.mailboxes.status === 'ready' ? mailbox : undefined,
451
+ sequence: sequence,
450
452
  api: api,
451
453
  enrollAction: sequence.status === 'active' ? enrollButton : undefined,
452
454
  onOpen: (enrollment)=>navigate(enrollmentHref(enrollment)),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/outreach/src/lib/components/sequence-detail.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 { consentGroupForHost } from '@aglyn/aglyn/app-utils/consent-groups'\nimport type { ConsolePluginOrgMount } from '@aglyn/aglyn'\nimport {\n mdiAccountMultiplePlusOutline,\n mdiChevronLeft,\n} from '@aglyn/shared-data-mdi'\nimport { MdiIcon } from '@aglyn/shared-ui-jsx'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Button,\n Card,\n Dialog,\n DialogActions,\n DialogContent,\n DialogContentText,\n DialogTitle,\n Stack,\n Tab,\n Tabs,\n Typography,\n} from '@mui/material'\nimport EmptyStateComponent from '@aglyn/shared-ui-jsx/components/empty-state.component'\nimport type { ListFilterClause } from '@aglyn/shared-ui-jsx/const/list-grid-filter'\nimport { usePathname, useRouter, useSearchParams } from 'next/navigation'\nimport { useMemo, useState } from 'react'\nimport { validateOutreachOrgSettings } from '../engine/sequence-validation'\nimport type { OutreachSequenceAction } from '../model/outreach-api'\nimport type { OutreachEnrollment } from '../model/outreach.types'\nimport { outreachSequenceLinkReport } from '../model/sequence-report'\nimport {\n outreachMailboxActivationIssue,\n outreachSequenceMailboxState,\n type OutreachSequenceIssue,\n type OutreachSequenceMailboxState,\n} from '../model/sequence-draft'\nimport { OutreachEnrollDialog } from './enroll-dialog'\nimport {\n outreachClauseLivesInUrl,\n outreachEnrollmentFilterSearch,\n outreachEnrollmentsFilterHref,\n outreachEnrollmentUrlClauses,\n} from './enrollment-filter-params'\nimport { OutreachEnrollmentsTable } from './enrollments-table'\nimport {\n OutreachLink,\n OutreachLoading,\n OutreachLoadProblem,\n OutreachSequenceStatusChip,\n useOutreachNavigate,\n} from './outreach-ui'\nimport { OutreachSequenceEditor } from './sequence-editor'\nimport { OutreachSequenceReportCard } from './sequence-report-card'\nimport { OutreachRouteError, useOutreachApi } from './use-outreach-api'\nimport {\n useOutreachSequence,\n useOutreachSequenceLinks,\n} from './use-outreach-data'\nimport type { OutreachMailboxesResult } from './use-outreach-mailboxes'\nimport type { OutreachSettingsLoad } from './use-outreach-settings'\n\nexport type OutreachSequenceTab = 'steps' | 'enrollments'\n\nexport interface OutreachSequenceDetailProps {\n orgId: string\n orgMount?: ConsolePluginOrgMount\n /** The organization document the shell loaded: whose consent groups name a site's contacts. */\n org?: Record<string, unknown> | null\n /** Where the Sequences section lives: `/[orgSlug]/outreach/sequences`. */\n sectionPath: string\n sequenceId: string\n tab: OutreachSequenceTab\n settings: OutreachSettingsLoad\n mailboxes: OutreachMailboxesResult\n /** The Mailboxes section: where a mailbox is connected, resumed or reconnected. */\n mailboxesPath: string\n /** The Compliance section: where the footer's legal name and address are set. */\n compliancePath: string\n}\n\n/** Something activation would refuse, and where it is put right. */\nexport interface OutreachActivationBlocker {\n message: string\n href: string\n linkLabel: string\n}\n\n/**\n * What stops a sequence being activated, read before anyone clicks: its\n * mailbox not sending, and a footer the organization cannot write yet —\n * each in the words the status route refuses with. Only a finished read\n * says something is missing, so nothing is claimed while one is loading.\n */\nexport function outreachActivationBlockers(input: {\n sequence: { mailboxId: string }\n mailboxes: OutreachMailboxesResult\n settings: OutreachSettingsLoad\n paths: { steps: string; mailboxes: string; compliance: string }\n}): OutreachActivationBlocker[] {\n const blockers: OutreachActivationBlocker[] = []\n if (input.mailboxes.status === 'ready') {\n const mailbox =\n input.mailboxes.mailboxes.find((entry) => entry.id === input.sequence.mailboxId) ?? null\n const issue = outreachMailboxActivationIssue(input.sequence.mailboxId, mailbox)\n if (issue) {\n blockers.push(\n issue.code === 'mailbox_not_sending'\n ? { message: issue.message, href: input.paths.mailboxes, linkLabel: 'Open Mailboxes' }\n : { message: issue.message, href: input.paths.steps, linkLabel: 'Choose a mailbox' },\n )\n }\n }\n if (input.settings.status === 'ready') {\n for (const issue of validateOutreachOrgSettings(input.settings.settings)) {\n blockers.push({ message: issue.message, href: input.paths.compliance, linkLabel: 'Open Compliance' })\n }\n }\n return blockers\n}\n\n/** What an active sequence's page says while its mailbox is not sending. */\nconst NOT_SENDING: Record<Exclude<OutreachSequenceMailboxState, 'sending'>, string> = {\n none: 'This sequence has no mailbox, so nothing is sent from it.',\n gone: 'This sequence’s mailbox is no longer connected, so nothing is sent from it.',\n paused: 'This sequence’s mailbox is paused, so nothing is sent until it is resumed.',\n reconnect_required:\n 'Google stopped accepting this sequence’s mailbox, so nothing is sent until it is reconnected.',\n}\n\n/** One person's page (AGL-3332): `…/sequences/{id}/enrollments/{enrollmentId}`. */\nexport function outreachEnrollmentPath(\n sectionPath: string,\n sequenceId: string,\n enrollmentId: string,\n): string {\n return `${sectionPath}/${sequenceId}/enrollments/${encodeURIComponent(enrollmentId)}`\n}\n\n/** The words an action's button and its snackbar use. */\nconst ACTIONS: Record<OutreachSequenceAction, { label: string; done: string }> =\n {\n activate: { label: 'Activate', done: 'Sequence activated.' },\n pause: { label: 'Pause', done: 'Sequence paused.' },\n archive: { label: 'Archive', done: 'Sequence archived.' },\n }\n\n/**\n * One sequence (AGL-2980): its steps in the editor, the people enrolled in\n * it, and what can be done with it — activate, pause, archive, delete a\n * draft, and enroll people in an active one.\n */\nexport function OutreachSequenceDetail(props: OutreachSequenceDetailProps) {\n const { orgId, sequenceId, sectionPath } = props\n const api = useOutreachApi(orgId)\n const navigate = useOutreachNavigate()\n const { enqueueSnackbar } = useSnackbar()\n const { data: user } = useUser()\n const loaded = useOutreachSequence(orgId, sequenceId)\n // One document however large the sequence, and read on both tabs, because\n // the report card sits above them (AGL-3239).\n const links = useOutreachSequenceLinks(orgId, sequenceId)\n const [busy, setBusy] = useState(false)\n const [refusal, setRefusal] = useState<{\n message: string\n issues: OutreachSequenceIssue[]\n } | null>(null)\n const [confirming, setConfirming] = useState<'archive' | 'delete' | null>(\n null,\n )\n const [enrolling, setEnrolling] = useState(false)\n\n /*\n * The enrollments table's filter (AGL-3332). \"Who clicked\" and \"who\n * followed this destination\" live in the URL, where the Results card\n * sets them and where back from a person finds them again; every other\n * clause the panel sets is the page's own.\n */\n const router = useRouter()\n const pathname = usePathname()\n const searchParams = useSearchParams()\n const search = searchParams?.toString() ?? ''\n const urlClauses = useMemo(\n () => outreachEnrollmentUrlClauses(new URLSearchParams(search)),\n [search],\n )\n const [ownClauses, setOwnClauses] = useState<ListFilterClause[]>([])\n const clauses = useMemo(() => [...ownClauses, ...urlClauses], [ownClauses, urlClauses])\n const setClauses = (next: ListFilterClause[]) => {\n setOwnClauses(next.filter((clause) => !outreachClauseLivesInUrl(clause)))\n const nextSearch = outreachEnrollmentFilterSearch(next, search)\n if (nextSearch !== search) {\n router.replace(nextSearch ? `${pathname}?${nextSearch}` : pathname, { scroll: false })\n }\n }\n const linkOptions = useMemo(\n () =>\n outreachSequenceLinkReport(\n links.status === 'ready' ? (links.data ?? undefined) : undefined,\n ).rows.map((row) => ({ value: row.url, label: row.url })),\n [links],\n )\n\n const sequence = loaded.data\n const detailPath = `${sectionPath}/${sequenceId}`\n const enrollmentsPath = `${detailPath}/enrollments`\n const enrollmentHref = (enrollment: OutreachEnrollment) =>\n outreachEnrollmentPath(sectionPath, sequenceId, enrollment.id)\n const back = (\n <OutreachLink href={sectionPath}>\n <Stack\n direction=\"row\"\n spacing={0.5}\n component=\"span\"\n sx={{ alignItems: 'center', display: 'inline-flex' }}\n >\n <MdiIcon path={mdiChevronLeft.path} fontSize=\"small\" />\n <span>Sequences</span>\n </Stack>\n </OutreachLink>\n )\n\n if (loaded.status === 'loading')\n return <OutreachLoading label=\"Loading the sequence…\" />\n if (loaded.status === 'error' || loaded.status === 'refused') {\n return <OutreachLoadProblem status={loaded.status} what=\"sequence\" />\n }\n if (!sequence) {\n return (\n <Stack spacing={2}>\n {back}\n <Card variant=\"outlined\">\n <EmptyStateComponent label=\"This sequence no longer exists\" />\n </Card>\n </Stack>\n )\n }\n\n const mailbox =\n props.mailboxes.mailboxes.find((entry) => entry.id === sequence.mailboxId) ??\n null\n const mailboxState =\n props.mailboxes.status === 'ready'\n ? outreachSequenceMailboxState(sequence.mailboxId, mailbox)\n : 'sending'\n const activatable = sequence.status === 'draft' || sequence.status === 'paused'\n const blockers = activatable\n ? outreachActivationBlockers({\n sequence,\n mailboxes: props.mailboxes,\n settings: props.settings,\n paths: {\n steps: detailPath,\n mailboxes: props.mailboxesPath,\n compliance: props.compliancePath,\n },\n })\n : []\n // Enrolling onto a mailbox that is gone is refused by the route; a paused\n // one only makes the new people wait with everyone else.\n const canEnroll =\n sequence.status === 'active' &&\n mailboxState !== 'gone' &&\n mailboxState !== 'none'\n const act = async (action: OutreachSequenceAction) => {\n setBusy(true)\n setRefusal(null)\n try {\n const answer = await api.setSequenceStatus(sequence.id, action)\n enqueueSnackbar(\n action === 'archive' && answer.stoppedEnrollments\n ? `${ACTIONS.archive.done} ${answer.stoppedEnrollments} ${answer.stoppedEnrollments === 1 ? 'person was' : 'people were'} stopped.`\n : ACTIONS[action].done,\n { variant: 'success' },\n )\n } catch (error) {\n setRefusal({\n message: (error as Error).message,\n issues:\n error instanceof OutreachRouteError\n ? error.issues.filter(\n (issue): issue is OutreachSequenceIssue => 'path' in issue,\n )\n : [],\n })\n } finally {\n setBusy(false)\n }\n }\n const remove = async () => {\n setBusy(true)\n setRefusal(null)\n try {\n await api.deleteSequence(sequence.id)\n enqueueSnackbar('Sequence deleted.', { variant: 'success' })\n navigate(sectionPath)\n } catch (error) {\n setRefusal({ message: (error as Error).message, issues: [] })\n setBusy(false)\n }\n }\n\n const enrollButton = (\n <Button\n variant=\"contained\"\n startIcon={\n <MdiIcon path={mdiAccountMultiplePlusOutline.path} fontSize=\"small\" />\n }\n disabled={!canEnroll}\n onClick={() => setEnrolling(true)}\n >\n Enroll people\n </Button>\n )\n\n return (\n <Stack spacing={2}>\n {back}\n <Stack\n direction={{ xs: 'column', md: 'row' }}\n spacing={1.5}\n sx={{ alignItems: { md: 'center' }, justifyContent: 'space-between' }}\n >\n <Stack\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center', minWidth: 0 }}\n >\n <Typography\n variant=\"h5\"\n component=\"h2\"\n sx={{ wordBreak: 'break-word' }}\n >\n {sequence.name}\n </Typography>\n <OutreachSequenceStatusChip status={sequence.status} />\n </Stack>\n <Stack direction=\"row\" spacing={1} sx={{ flexWrap: 'wrap', rowGap: 1 }}>\n {activatable ? (\n <Button\n variant=\"outlined\"\n disabled={busy || blockers.length > 0}\n onClick={() => void act('activate')}\n >\n {ACTIONS.activate.label}\n </Button>\n ) : null}\n {sequence.status === 'active' ? (\n <Button\n variant=\"outlined\"\n disabled={busy}\n onClick={() => void act('pause')}\n >\n {ACTIONS.pause.label}\n </Button>\n ) : null}\n {sequence.status !== 'archived' ? (\n <Button\n variant=\"outlined\"\n color=\"error\"\n disabled={busy}\n onClick={() => setConfirming('archive')}\n >\n {ACTIONS.archive.label}\n </Button>\n ) : null}\n {sequence.status === 'draft' ? (\n <Button\n variant=\"text\"\n color=\"error\"\n disabled={busy}\n onClick={() => setConfirming('delete')}\n >\n Delete\n </Button>\n ) : null}\n {sequence.status === 'active' ? enrollButton : null}\n </Stack>\n </Stack>\n\n {refusal ? (\n <Alert severity=\"error\" onClose={() => setRefusal(null)}>\n <Stack spacing={0.5}>\n <span>{refusal.message}</span>\n {refusal.issues.length > 1 ? (\n <Stack component=\"ul\" spacing={0.25} sx={{ m: 0, pl: 2.5 }}>\n {refusal.issues.slice(1).map((issue) => (\n <li key={`${issue.path}:${issue.code}`}>{issue.message}</li>\n ))}\n </Stack>\n ) : null}\n </Stack>\n </Alert>\n ) : null}\n {blockers.length ? (\n <Alert severity=\"warning\" data-testid=\"outreach-activation-blockers\">\n <Stack spacing={0.5}>\n <span>\n {sequence.status === 'draft'\n ? 'A draft sends nothing, and this one can’t be activated yet:'\n : 'This sequence can’t be activated again yet:'}\n </span>\n <Stack component=\"ul\" spacing={0.25} sx={{ m: 0, pl: 2.5 }}>\n {blockers.map((blocker) => (\n <li key={blocker.message}>\n {blocker.message}{' '}\n <OutreachLink href={blocker.href}>{blocker.linkLabel}</OutreachLink>\n </li>\n ))}\n </Stack>\n </Stack>\n </Alert>\n ) : sequence.status === 'draft' ? (\n <Alert severity=\"info\">\n A draft sends nothing. Activate it to enroll people.\n </Alert>\n ) : null}\n {sequence.status === 'active' && mailboxState !== 'sending' ? (\n <Alert severity=\"warning\">\n {NOT_SENDING[mailboxState]}{' '}\n <OutreachLink href={props.mailboxesPath}>Open Mailboxes</OutreachLink>\n </Alert>\n ) : null}\n\n {/*\n * Above the tabs, not inside one (AGL-3239): what a sequence is doing\n * is the question a rep opens it with, and putting it behind a tab\n * makes the steps the first answer to \"how is this going\".\n *\n * A draft has sent nothing and measured nothing, so it gets no card\n * rather than a row of zeroes.\n */}\n {sequence.status === 'draft' ? null : (\n <OutreachSequenceReportCard\n sequence={sequence}\n links={links}\n timeZone={mailbox?.timezone ?? null}\n // Each leads to the people behind it, on the Enrollments tab's own\n // filter (AGL-3332).\n onShowClickers={() =>\n navigate(outreachEnrollmentsFilterHref(enrollmentsPath, { clicked: true }))\n }\n onShowLink={(url) =>\n navigate(outreachEnrollmentsFilterHref(enrollmentsPath, { link: url }))\n }\n />\n )}\n\n <Tabs\n value={props.tab}\n onChange={(_event, next: OutreachSequenceTab) =>\n navigate(next === 'steps' ? detailPath : enrollmentsPath)\n }\n aria-label=\"Sequence\"\n >\n <Tab value=\"steps\" label=\"Steps\" />\n <Tab value=\"enrollments\" label=\"Enrollments\" />\n </Tabs>\n\n {props.tab === 'steps' ? (\n <OutreachSequenceEditor\n orgId={orgId}\n orgMount={props.orgMount}\n org={props.org}\n sequence={sequence}\n settings={props.settings}\n mailboxes={props.mailboxes}\n mailboxesPath={props.mailboxesPath}\n onSaved={() => undefined}\n />\n ) : (\n <OutreachEnrollmentsTable\n orgId={orgId}\n sequenceId={sequence.id}\n steps={sequence.steps}\n // A sequence that counted clicks once has them to show, whether or\n // not it counts them now.\n trackClicks={sequence.settings.trackClicks || sequence.stats?.clickTracked === true}\n timeZone={mailbox?.timezone ?? null}\n api={api}\n enrollAction={sequence.status === 'active' ? enrollButton : undefined}\n onOpen={(enrollment) => navigate(enrollmentHref(enrollment))}\n hrefFor={enrollmentHref}\n clauses={clauses}\n onClausesChange={setClauses}\n linkOptions={linkOptions}\n />\n )}\n\n <OutreachEnrollDialog\n open={enrolling}\n onClose={() => setEnrolling(false)}\n orgId={orgId}\n sequence={sequence}\n contactGroupId={\n sequence.hostId\n ? consentGroupForHost(props.org ?? null, sequence.hostId).groupId\n : ''\n }\n uid={user?.uid ?? null}\n api={api}\n />\n\n <Dialog\n open={Boolean(confirming)}\n onClose={() => setConfirming(null)}\n fullWidth\n maxWidth=\"xs\"\n >\n <DialogTitle>\n {confirming === 'delete'\n ? 'Delete this draft?'\n : 'Archive this sequence?'}\n </DialogTitle>\n <DialogContent>\n <DialogContentText>\n {confirming === 'delete'\n ? 'It is removed for good. Nobody was ever enrolled in it.'\n : 'Archiving is final. Everyone still in it is stopped, and it takes no one new.'}\n </DialogContentText>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setConfirming(null)}>Cancel</Button>\n <Button\n color=\"error\"\n variant=\"contained\"\n onClick={() => {\n const chosen = confirming\n setConfirming(null)\n if (chosen === 'delete') void remove()\n else void act('archive')\n }}\n >\n {confirming === 'delete' ? 'Delete' : 'Archive'}\n </Button>\n </DialogActions>\n </Dialog>\n </Stack>\n )\n}\nOutreachSequenceDetail.displayName = 'OutreachSequenceDetail'\n\nexport default OutreachSequenceDetail\n"],"names":["consentGroupForHost","mdiAccountMultiplePlusOutline","mdiChevronLeft","MdiIcon","useSnackbar","useUser","Alert","Button","Card","Dialog","DialogActions","DialogContent","DialogContentText","DialogTitle","Stack","Tab","Tabs","Typography","EmptyStateComponent","usePathname","useRouter","useSearchParams","useMemo","useState","validateOutreachOrgSettings","outreachSequenceLinkReport","outreachMailboxActivationIssue","outreachSequenceMailboxState","OutreachEnrollDialog","outreachClauseLivesInUrl","outreachEnrollmentFilterSearch","outreachEnrollmentsFilterHref","outreachEnrollmentUrlClauses","OutreachEnrollmentsTable","OutreachLink","OutreachLoading","OutreachLoadProblem","OutreachSequenceStatusChip","useOutreachNavigate","OutreachSequenceEditor","OutreachSequenceReportCard","OutreachRouteError","useOutreachApi","useOutreachSequence","useOutreachSequenceLinks","outreachActivationBlockers","input","blockers","mailboxes","status","mailbox","find","entry","id","sequence","mailboxId","issue","push","code","message","href","paths","linkLabel","steps","settings","compliance","NOT_SENDING","none","gone","paused","reconnect_required","outreachEnrollmentPath","sectionPath","sequenceId","enrollmentId","encodeURIComponent","ACTIONS","activate","label","done","pause","archive","OutreachSequenceDetail","props","orgId","api","navigate","enqueueSnackbar","data","user","loaded","links","busy","setBusy","refusal","setRefusal","confirming","setConfirming","enrolling","setEnrolling","router","pathname","searchParams","search","toString","urlClauses","URLSearchParams","ownClauses","setOwnClauses","clauses","setClauses","next","filter","clause","nextSearch","replace","scroll","linkOptions","undefined","rows","map","row","value","url","detailPath","enrollmentsPath","enrollmentHref","enrollment","back","direction","spacing","component","sx","alignItems","display","path","fontSize","span","what","variant","mailboxState","activatable","mailboxesPath","compliancePath","canEnroll","act","action","answer","setSequenceStatus","stoppedEnrollments","error","issues","remove","deleteSequence","enrollButton","startIcon","disabled","onClick","xs","md","justifyContent","minWidth","wordBreak","name","flexWrap","rowGap","length","color","severity","onClose","m","pl","slice","li","data-testid","blocker","timeZone","timezone","onShowClickers","clicked","onShowLink","link","tab","onChange","_event","aria-label","orgMount","org","onSaved","trackClicks","stats","clickTracked","enrollAction","onOpen","hrefFor","onClausesChange","open","contactGroupId","hostId","groupId","uid","Boolean","fullWidth","maxWidth","chosen","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SAASA,mBAAmB,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yG,eAAepC;gBAC5D2E,QAAQ,CAAClE,aAAezC,SAASwC,eAAeC;gBAChDmE,SAASpE;gBACTjB,SAASA;gBACTsF,iBAAiBrF;gBACjBO,aAAaA;;0BAIjB,KAACzF;gBACCwK,MAAMlG;gBACNuE,SAAS,IAAMtE,aAAa;gBAC5Bf,OAAOA;gBACP9B,UAAUA;gBACV+I,gBACE/I,SAASgJ,MAAM,GACXtM,qBAAoBmF,aAAAA,MAAMwG,GAAG,YAATxG,aAAa,MAAM7B,SAASgJ,MAAM,EAAEC,OAAO,GAC/D;gBAENC,GAAG,WAAE/G,wBAAAA,KAAM+G,GAAG,oBAAI;gBAClBnH,KAAKA;;0BAGP,MAAC5E;gBACC2L,MAAMK,QAAQzG;gBACdyE,SAAS,IAAMxE,cAAc;gBAC7ByG,SAAS;gBACTC,UAAS;;kCAET,KAAC9L;kCACEmF,eAAe,WACZ,uBACA;;kCAEN,KAACrF;kCACC,cAAA,KAACC;sCACEoF,eAAe,WACZ,4DACA;;;kCAGR,MAACtF;;0CACC,KAACH;gCAAOsJ,SAAS,IAAM5D,cAAc;0CAAO;;0CAC5C,KAAC1F;gCACCgK,OAAM;gCACN5B,SAAQ;gCACRkB,SAAS;oCACP,MAAM+C,SAAS5G;oCACfC,cAAc;oCACd,IAAI2G,WAAW,UAAU,KAAKpD;yCACzB,KAAKP,IAAI;gCAChB;0CAECjD,eAAe,WAAW,WAAW;;;;;;;;AAMlD;AACAd,uBAAuB2H,WAAW,GAAG;AAErC,eAAe3H,uBAAsB"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/outreach/src/lib/components/sequence-detail.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 { consentGroupForHost } from '@aglyn/aglyn/app-utils/consent-groups'\nimport type { ConsolePluginOrgMount } from '@aglyn/aglyn'\nimport {\n mdiAccountMultiplePlusOutline,\n mdiChevronLeft,\n} from '@aglyn/shared-data-mdi'\nimport { MdiIcon } from '@aglyn/shared-ui-jsx'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Button,\n Card,\n Dialog,\n DialogActions,\n DialogContent,\n DialogContentText,\n DialogTitle,\n Stack,\n Tab,\n Tabs,\n Typography,\n} from '@mui/material'\nimport EmptyStateComponent from '@aglyn/shared-ui-jsx/components/empty-state.component'\nimport type { ListFilterClause } from '@aglyn/shared-ui-jsx/const/list-grid-filter'\nimport { usePathname, useRouter, useSearchParams } from 'next/navigation'\nimport { useMemo, useState } from 'react'\nimport { validateOutreachOrgSettings } from '../engine/sequence-validation'\nimport type { OutreachSequenceAction } from '../model/outreach-api'\nimport type { OutreachEnrollment } from '../model/outreach.types'\nimport { outreachSequenceLinkReport } from '../model/sequence-report'\nimport {\n outreachMailboxActivationIssue,\n outreachSequenceMailboxState,\n type OutreachSequenceIssue,\n type OutreachSequenceMailboxState,\n} from '../model/sequence-draft'\nimport { OutreachEnrollDialog } from './enroll-dialog'\nimport {\n outreachClauseLivesInUrl,\n outreachEnrollmentFilterSearch,\n outreachEnrollmentsFilterHref,\n outreachEnrollmentUrlClauses,\n} from './enrollment-filter-params'\nimport { OutreachEnrollmentsTable } from './enrollments-table'\nimport {\n OutreachLink,\n OutreachLoading,\n OutreachLoadProblem,\n OutreachSequenceStatusChip,\n useOutreachNavigate,\n} from './outreach-ui'\nimport { OutreachSequenceEditor } from './sequence-editor'\nimport { OutreachSequenceReportCard } from './sequence-report-card'\nimport { OutreachRouteError, useOutreachApi } from './use-outreach-api'\nimport {\n useOutreachSequence,\n useOutreachSequenceLinks,\n} from './use-outreach-data'\nimport type { OutreachMailboxesResult } from './use-outreach-mailboxes'\nimport type { OutreachSettingsLoad } from './use-outreach-settings'\n\nexport type OutreachSequenceTab = 'steps' | 'enrollments'\n\nexport interface OutreachSequenceDetailProps {\n orgId: string\n orgMount?: ConsolePluginOrgMount\n /** The organization document the shell loaded: whose consent groups name a site's contacts. */\n org?: Record<string, unknown> | null\n /** Where the Sequences section lives: `/[orgSlug]/outreach/sequences`. */\n sectionPath: string\n sequenceId: string\n tab: OutreachSequenceTab\n settings: OutreachSettingsLoad\n mailboxes: OutreachMailboxesResult\n /** The Mailboxes section: where a mailbox is connected, resumed or reconnected. */\n mailboxesPath: string\n /** The Compliance section: where the footer's legal name and address are set. */\n compliancePath: string\n}\n\n/** Something activation would refuse, and where it is put right. */\nexport interface OutreachActivationBlocker {\n message: string\n href: string\n linkLabel: string\n}\n\n/**\n * What stops a sequence being activated, read before anyone clicks: its\n * mailbox not sending, and a footer the organization cannot write yet —\n * each in the words the status route refuses with. Only a finished read\n * says something is missing, so nothing is claimed while one is loading.\n */\nexport function outreachActivationBlockers(input: {\n sequence: { mailboxId: string }\n mailboxes: OutreachMailboxesResult\n settings: OutreachSettingsLoad\n paths: { steps: string; mailboxes: string; compliance: string }\n}): OutreachActivationBlocker[] {\n const blockers: OutreachActivationBlocker[] = []\n if (input.mailboxes.status === 'ready') {\n const mailbox =\n input.mailboxes.mailboxes.find((entry) => entry.id === input.sequence.mailboxId) ?? null\n const issue = outreachMailboxActivationIssue(input.sequence.mailboxId, mailbox)\n if (issue) {\n blockers.push(\n issue.code === 'mailbox_not_sending'\n ? { message: issue.message, href: input.paths.mailboxes, linkLabel: 'Open Mailboxes' }\n : { message: issue.message, href: input.paths.steps, linkLabel: 'Choose a mailbox' },\n )\n }\n }\n if (input.settings.status === 'ready') {\n for (const issue of validateOutreachOrgSettings(input.settings.settings)) {\n blockers.push({ message: issue.message, href: input.paths.compliance, linkLabel: 'Open Compliance' })\n }\n }\n return blockers\n}\n\n/** What an active sequence's page says while its mailbox is not sending. */\nconst NOT_SENDING: Record<Exclude<OutreachSequenceMailboxState, 'sending'>, string> = {\n none: 'This sequence has no mailbox, so nothing is sent from it.',\n gone: 'This sequence’s mailbox is no longer connected, so nothing is sent from it.',\n paused: 'This sequence’s mailbox is paused, so nothing is sent until it is resumed.',\n reconnect_required:\n 'Google stopped accepting this sequence’s mailbox, so nothing is sent until it is reconnected.',\n}\n\n/** One person's page (AGL-3332): `…/sequences/{id}/enrollments/{enrollmentId}`. */\nexport function outreachEnrollmentPath(\n sectionPath: string,\n sequenceId: string,\n enrollmentId: string,\n): string {\n return `${sectionPath}/${sequenceId}/enrollments/${encodeURIComponent(enrollmentId)}`\n}\n\n/** The words an action's button and its snackbar use. */\nconst ACTIONS: Record<OutreachSequenceAction, { label: string; done: string }> =\n {\n activate: { label: 'Activate', done: 'Sequence activated.' },\n pause: { label: 'Pause', done: 'Sequence paused.' },\n archive: { label: 'Archive', done: 'Sequence archived.' },\n }\n\n/**\n * One sequence (AGL-2980): its steps in the editor, the people enrolled in\n * it, and what can be done with it — activate, pause, archive, delete a\n * draft, and enroll people in an active one.\n */\nexport function OutreachSequenceDetail(props: OutreachSequenceDetailProps) {\n const { orgId, sequenceId, sectionPath } = props\n const api = useOutreachApi(orgId)\n const navigate = useOutreachNavigate()\n const { enqueueSnackbar } = useSnackbar()\n const { data: user } = useUser()\n const loaded = useOutreachSequence(orgId, sequenceId)\n // One document however large the sequence, and read on both tabs, because\n // the report card sits above them (AGL-3239).\n const links = useOutreachSequenceLinks(orgId, sequenceId)\n const [busy, setBusy] = useState(false)\n const [refusal, setRefusal] = useState<{\n message: string\n issues: OutreachSequenceIssue[]\n } | null>(null)\n const [confirming, setConfirming] = useState<'archive' | 'delete' | null>(\n null,\n )\n const [enrolling, setEnrolling] = useState(false)\n\n /*\n * The enrollments table's filter (AGL-3332). \"Who clicked\" and \"who\n * followed this destination\" live in the URL, where the Results card\n * sets them and where back from a person finds them again; every other\n * clause the panel sets is the page's own.\n */\n const router = useRouter()\n const pathname = usePathname()\n const searchParams = useSearchParams()\n const search = searchParams?.toString() ?? ''\n const urlClauses = useMemo(\n () => outreachEnrollmentUrlClauses(new URLSearchParams(search)),\n [search],\n )\n const [ownClauses, setOwnClauses] = useState<ListFilterClause[]>([])\n const clauses = useMemo(() => [...ownClauses, ...urlClauses], [ownClauses, urlClauses])\n const setClauses = (next: ListFilterClause[]) => {\n setOwnClauses(next.filter((clause) => !outreachClauseLivesInUrl(clause)))\n const nextSearch = outreachEnrollmentFilterSearch(next, search)\n if (nextSearch !== search) {\n router.replace(nextSearch ? `${pathname}?${nextSearch}` : pathname, { scroll: false })\n }\n }\n const linkOptions = useMemo(\n () =>\n outreachSequenceLinkReport(\n links.status === 'ready' ? (links.data ?? undefined) : undefined,\n ).rows.map((row) => ({ value: row.url, label: row.url })),\n [links],\n )\n\n const sequence = loaded.data\n const detailPath = `${sectionPath}/${sequenceId}`\n const enrollmentsPath = `${detailPath}/enrollments`\n const enrollmentHref = (enrollment: OutreachEnrollment) =>\n outreachEnrollmentPath(sectionPath, sequenceId, enrollment.id)\n const back = (\n <OutreachLink href={sectionPath}>\n <Stack\n direction=\"row\"\n spacing={0.5}\n component=\"span\"\n sx={{ alignItems: 'center', display: 'inline-flex' }}\n >\n <MdiIcon path={mdiChevronLeft.path} fontSize=\"small\" />\n <span>Sequences</span>\n </Stack>\n </OutreachLink>\n )\n\n if (loaded.status === 'loading')\n return <OutreachLoading label=\"Loading the sequence…\" />\n if (loaded.status === 'error' || loaded.status === 'refused') {\n return <OutreachLoadProblem status={loaded.status} what=\"sequence\" />\n }\n if (!sequence) {\n return (\n <Stack spacing={2}>\n {back}\n <Card variant=\"outlined\">\n <EmptyStateComponent label=\"This sequence no longer exists\" />\n </Card>\n </Stack>\n )\n }\n\n const mailbox =\n props.mailboxes.mailboxes.find((entry) => entry.id === sequence.mailboxId) ??\n null\n const mailboxState =\n props.mailboxes.status === 'ready'\n ? outreachSequenceMailboxState(sequence.mailboxId, mailbox)\n : 'sending'\n const activatable = sequence.status === 'draft' || sequence.status === 'paused'\n const blockers = activatable\n ? outreachActivationBlockers({\n sequence,\n mailboxes: props.mailboxes,\n settings: props.settings,\n paths: {\n steps: detailPath,\n mailboxes: props.mailboxesPath,\n compliance: props.compliancePath,\n },\n })\n : []\n // Enrolling onto a mailbox that is gone is refused by the route; a paused\n // one only makes the new people wait with everyone else.\n const canEnroll =\n sequence.status === 'active' &&\n mailboxState !== 'gone' &&\n mailboxState !== 'none'\n const act = async (action: OutreachSequenceAction) => {\n setBusy(true)\n setRefusal(null)\n try {\n const answer = await api.setSequenceStatus(sequence.id, action)\n enqueueSnackbar(\n action === 'archive' && answer.stoppedEnrollments\n ? `${ACTIONS.archive.done} ${answer.stoppedEnrollments} ${answer.stoppedEnrollments === 1 ? 'person was' : 'people were'} stopped.`\n : ACTIONS[action].done,\n { variant: 'success' },\n )\n } catch (error) {\n setRefusal({\n message: (error as Error).message,\n issues:\n error instanceof OutreachRouteError\n ? error.issues.filter(\n (issue): issue is OutreachSequenceIssue => 'path' in issue,\n )\n : [],\n })\n } finally {\n setBusy(false)\n }\n }\n const remove = async () => {\n setBusy(true)\n setRefusal(null)\n try {\n await api.deleteSequence(sequence.id)\n enqueueSnackbar('Sequence deleted.', { variant: 'success' })\n navigate(sectionPath)\n } catch (error) {\n setRefusal({ message: (error as Error).message, issues: [] })\n setBusy(false)\n }\n }\n\n const enrollButton = (\n <Button\n variant=\"contained\"\n startIcon={\n <MdiIcon path={mdiAccountMultiplePlusOutline.path} fontSize=\"small\" />\n }\n disabled={!canEnroll}\n onClick={() => setEnrolling(true)}\n >\n Enroll people\n </Button>\n )\n\n return (\n <Stack spacing={2}>\n {back}\n <Stack\n direction={{ xs: 'column', md: 'row' }}\n spacing={1.5}\n sx={{ alignItems: { md: 'center' }, justifyContent: 'space-between' }}\n >\n <Stack\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center', minWidth: 0 }}\n >\n <Typography\n variant=\"h5\"\n component=\"h2\"\n sx={{ wordBreak: 'break-word' }}\n >\n {sequence.name}\n </Typography>\n <OutreachSequenceStatusChip status={sequence.status} />\n </Stack>\n <Stack direction=\"row\" spacing={1} sx={{ flexWrap: 'wrap', rowGap: 1 }}>\n {activatable ? (\n <Button\n variant=\"outlined\"\n disabled={busy || blockers.length > 0}\n onClick={() => void act('activate')}\n >\n {ACTIONS.activate.label}\n </Button>\n ) : null}\n {sequence.status === 'active' ? (\n <Button\n variant=\"outlined\"\n disabled={busy}\n onClick={() => void act('pause')}\n >\n {ACTIONS.pause.label}\n </Button>\n ) : null}\n {sequence.status !== 'archived' ? (\n <Button\n variant=\"outlined\"\n color=\"error\"\n disabled={busy}\n onClick={() => setConfirming('archive')}\n >\n {ACTIONS.archive.label}\n </Button>\n ) : null}\n {sequence.status === 'draft' ? (\n <Button\n variant=\"text\"\n color=\"error\"\n disabled={busy}\n onClick={() => setConfirming('delete')}\n >\n Delete\n </Button>\n ) : null}\n {sequence.status === 'active' ? enrollButton : null}\n </Stack>\n </Stack>\n\n {refusal ? (\n <Alert severity=\"error\" onClose={() => setRefusal(null)}>\n <Stack spacing={0.5}>\n <span>{refusal.message}</span>\n {refusal.issues.length > 1 ? (\n <Stack component=\"ul\" spacing={0.25} sx={{ m: 0, pl: 2.5 }}>\n {refusal.issues.slice(1).map((issue) => (\n <li key={`${issue.path}:${issue.code}`}>{issue.message}</li>\n ))}\n </Stack>\n ) : null}\n </Stack>\n </Alert>\n ) : null}\n {blockers.length ? (\n <Alert severity=\"warning\" data-testid=\"outreach-activation-blockers\">\n <Stack spacing={0.5}>\n <span>\n {sequence.status === 'draft'\n ? 'A draft sends nothing, and this one can’t be activated yet:'\n : 'This sequence can’t be activated again yet:'}\n </span>\n <Stack component=\"ul\" spacing={0.25} sx={{ m: 0, pl: 2.5 }}>\n {blockers.map((blocker) => (\n <li key={blocker.message}>\n {blocker.message}{' '}\n <OutreachLink href={blocker.href}>{blocker.linkLabel}</OutreachLink>\n </li>\n ))}\n </Stack>\n </Stack>\n </Alert>\n ) : sequence.status === 'draft' ? (\n <Alert severity=\"info\">\n A draft sends nothing. Activate it to enroll people.\n </Alert>\n ) : null}\n {sequence.status === 'active' && mailboxState !== 'sending' ? (\n <Alert severity=\"warning\">\n {NOT_SENDING[mailboxState]}{' '}\n <OutreachLink href={props.mailboxesPath}>Open Mailboxes</OutreachLink>\n </Alert>\n ) : null}\n\n {/*\n * Above the tabs, not inside one (AGL-3239): what a sequence is doing\n * is the question a rep opens it with, and putting it behind a tab\n * makes the steps the first answer to \"how is this going\".\n *\n * A draft has sent nothing and measured nothing, so it gets no card\n * rather than a row of zeroes.\n */}\n {sequence.status === 'draft' ? null : (\n <OutreachSequenceReportCard\n sequence={sequence}\n links={links}\n timeZone={mailbox?.timezone ?? null}\n // Each leads to the people behind it, on the Enrollments tab's own\n // filter (AGL-3332).\n onShowClickers={() =>\n navigate(outreachEnrollmentsFilterHref(enrollmentsPath, { clicked: true }))\n }\n onShowLink={(url) =>\n navigate(outreachEnrollmentsFilterHref(enrollmentsPath, { link: url }))\n }\n />\n )}\n\n <Tabs\n value={props.tab}\n onChange={(_event, next: OutreachSequenceTab) =>\n navigate(next === 'steps' ? detailPath : enrollmentsPath)\n }\n aria-label=\"Sequence\"\n >\n <Tab value=\"steps\" label=\"Steps\" />\n <Tab value=\"enrollments\" label=\"Enrollments\" />\n </Tabs>\n\n {props.tab === 'steps' ? (\n <OutreachSequenceEditor\n orgId={orgId}\n orgMount={props.orgMount}\n org={props.org}\n sequence={sequence}\n settings={props.settings}\n mailboxes={props.mailboxes}\n mailboxesPath={props.mailboxesPath}\n onSaved={() => undefined}\n />\n ) : (\n <OutreachEnrollmentsTable\n orgId={orgId}\n sequenceId={sequence.id}\n steps={sequence.steps}\n // A sequence that counted clicks once has them to show, whether or\n // not it counts them now.\n trackClicks={sequence.settings.trackClicks || sequence.stats?.clickTracked === true}\n timeZone={mailbox?.timezone ?? null}\n mailbox={props.mailboxes.status === 'ready' ? mailbox : undefined}\n sequence={sequence}\n api={api}\n enrollAction={sequence.status === 'active' ? enrollButton : undefined}\n onOpen={(enrollment) => navigate(enrollmentHref(enrollment))}\n hrefFor={enrollmentHref}\n clauses={clauses}\n onClausesChange={setClauses}\n linkOptions={linkOptions}\n />\n )}\n\n <OutreachEnrollDialog\n open={enrolling}\n onClose={() => setEnrolling(false)}\n orgId={orgId}\n sequence={sequence}\n contactGroupId={\n sequence.hostId\n ? consentGroupForHost(props.org ?? null, sequence.hostId).groupId\n : ''\n }\n uid={user?.uid ?? null}\n api={api}\n />\n\n <Dialog\n open={Boolean(confirming)}\n onClose={() => setConfirming(null)}\n fullWidth\n maxWidth=\"xs\"\n >\n <DialogTitle>\n {confirming === 'delete'\n ? 'Delete this draft?'\n : 'Archive this sequence?'}\n </DialogTitle>\n <DialogContent>\n <DialogContentText>\n {confirming === 'delete'\n ? 'It is removed for good. Nobody was ever enrolled in it.'\n : 'Archiving is final. Everyone still in it is stopped, and it takes no one new.'}\n </DialogContentText>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setConfirming(null)}>Cancel</Button>\n <Button\n color=\"error\"\n variant=\"contained\"\n onClick={() => {\n const chosen = confirming\n setConfirming(null)\n if (chosen === 'delete') void remove()\n else void act('archive')\n }}\n >\n {confirming === 'delete' ? 'Delete' : 'Archive'}\n </Button>\n </DialogActions>\n </Dialog>\n </Stack>\n )\n}\nOutreachSequenceDetail.displayName = 'OutreachSequenceDetail'\n\nexport default OutreachSequenceDetail\n"],"names":["consentGroupForHost","mdiAccountMultiplePlusOutline","mdiChevronLeft","MdiIcon","useSnackbar","useUser","Alert","Button","Card","Dialog","DialogActions","DialogContent","DialogContentText","DialogTitle","Stack","Tab","Tabs","Typography","EmptyStateComponent","usePathname","useRouter","useSearchParams","useMemo","useState","validateOutreachOrgSettings","outreachSequenceLinkReport","outreachMailboxActivationIssue","outreachSequenceMailboxState","OutreachEnrollDialog","outreachClauseLivesInUrl","outreachEnrollmentFilterSearch","outreachEnrollmentsFilterHref","outreachEnrollmentUrlClauses","OutreachEnrollmentsTable","OutreachLink","OutreachLoading","OutreachLoadProblem","OutreachSequenceStatusChip","useOutreachNavigate","OutreachSequenceEditor","OutreachSequenceReportCard","OutreachRouteError","useOutreachApi","useOutreachSequence","useOutreachSequenceLinks","outreachActivationBlockers","input","blockers","mailboxes","status","mailbox","find","entry","id","sequence","mailboxId","issue","push","code","message","href","paths","linkLabel","steps","settings","compliance","NOT_SENDING","none","gone","paused","reconnect_required","outreachEnrollmentPath","sectionPath","sequenceId","enrollmentId","encodeURIComponent","ACTIONS","activate","label","done","pause","archive","OutreachSequenceDetail","props","orgId","api","navigate","enqueueSnackbar","data","user","loaded","links","busy","setBusy","refusal","setRefusal","confirming","setConfirming","enrolling","setEnrolling","router","pathname","searchParams","search","toString","urlClauses","URLSearchParams","ownClauses","setOwnClauses","clauses","setClauses","next","filter","clause","nextSearch","replace","scroll","linkOptions","undefined","rows","map","row","value","url","detailPath","enrollmentsPath","enrollmentHref","enrollment","back","direction","spacing","component","sx","alignItems","display","path","fontSize","span","what","variant","mailboxState","activatable","mailboxesPath","compliancePath","canEnroll","act","action","answer","setSequenceStatus","stoppedEnrollments","error","issues","remove","deleteSequence","enrollButton","startIcon","disabled","onClick","xs","md","justifyContent","minWidth","wordBreak","name","flexWrap","rowGap","length","color","severity","onClose","m","pl","slice","li","data-testid","blocker","timeZone","timezone","onShowClickers","clicked","onShowLink","link","tab","onChange","_event","aria-label","orgMount","org","onSaved","trackClicks","stats","clickTracked","enrollAction","onOpen","hrefFor","onClausesChange","open","contactGroupId","hostId","groupId","uid","Boolean","fullWidth","maxWidth","chosen","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SAASA,mBAAmB,QAAQ,wCAAuC;AAE3E,SACEC,6BAA6B,EAC7BC,cAAc,QACT,yBAAwB;AAC/B,SAASC,OAAO,QAAQ,uBAAsB;AA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AAQ,CAAClE,aAAezC,SAASwC,eAAeC;gBAChDmE,SAASpE;gBACTjB,SAASA;gBACTsF,iBAAiBrF;gBACjBO,aAAaA;;0BAIjB,KAACzF;gBACCwK,MAAMlG;gBACNuE,SAAS,IAAMtE,aAAa;gBAC5Bf,OAAOA;gBACP9B,UAAUA;gBACV+I,gBACE/I,SAASgJ,MAAM,GACXtM,qBAAoBmF,aAAAA,MAAMwG,GAAG,YAATxG,aAAa,MAAM7B,SAASgJ,MAAM,EAAEC,OAAO,GAC/D;gBAENC,GAAG,WAAE/G,wBAAAA,KAAM+G,GAAG,oBAAI;gBAClBnH,KAAKA;;0BAGP,MAAC5E;gBACC2L,MAAMK,QAAQzG;gBACdyE,SAAS,IAAMxE,cAAc;gBAC7ByG,SAAS;gBACTC,UAAS;;kCAET,KAAC9L;kCACEmF,eAAe,WACZ,uBACA;;kCAEN,KAACrF;kCACC,cAAA,KAACC;sCACEoF,eAAe,WACZ,4DACA;;;kCAGR,MAACtF;;0CACC,KAACH;gCAAOsJ,SAAS,IAAM5D,cAAc;0CAAO;;0CAC5C,KAAC1F;gCACCgK,OAAM;gCACN5B,SAAQ;gCACRkB,SAAS;oCACP,MAAM+C,SAAS5G;oCACfC,cAAc;oCACd,IAAI2G,WAAW,UAAU,KAAKpD;yCACzB,KAAKP,IAAI;gCAChB;0CAECjD,eAAe,WAAW,WAAW;;;;;;;;AAMlD;AACAd,uBAAuB2H,WAAW,GAAG;AAErC,eAAe3H,uBAAsB"}
@@ -19,6 +19,7 @@ export * from './recipient-country';
19
19
  export * from './gates';
20
20
  export * from './schedule';
21
21
  export * from './sending-capacity';
22
+ export * from './next-send';
22
23
  export * from './enrollment-state';
23
24
  export * from './compose';
24
25
  export * from './thread-message';
@@ -22,6 +22,7 @@ export * from "./recipient-country.js";
22
22
  export * from "./gates.js";
23
23
  export * from "./schedule.js";
24
24
  export * from "./sending-capacity.js";
25
+ export * from "./next-send.js";
25
26
  export * from "./enrollment-state.js";
26
27
  export * from "./compose.js";
27
28
  export * from "./thread-message.js";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/outreach/src/lib/engine/index.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\n/*\n * The Outreach engine (AGL-2979): pure decisions, no I/O, safe for the\n * console and the server alike. `./do-not-contact` is deliberately absent —\n * it hashes with `node:crypto` — and is imported by its own path.\n */\nexport * from './sequence-validation'\nexport * from './recipient-country'\nexport * from './gates'\nexport * from './schedule'\nexport * from './sending-capacity'\nexport * from './enrollment-state'\nexport * from './compose'\nexport * from './thread-message'\nexport * from './delivery-status'\nexport * from './opt-out-intent'\nexport * from './thread-classification'\nexport * from './mailbox-health'\nexport * from './mailbox-notice'\nexport * from './gateway-block'\nexport * from './do-not-contact-domain'\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;CAIC,GACD,cAAc,2BAAuB;AACrC,cAAc,yBAAqB;AACnC,cAAc,aAAS;AACvB,cAAc,gBAAY;AAC1B,cAAc,wBAAoB;AAClC,cAAc,wBAAoB;AAClC,cAAc,eAAW;AACzB,cAAc,sBAAkB;AAChC,cAAc,uBAAmB;AACjC,cAAc,sBAAkB;AAChC,cAAc,6BAAyB;AACvC,cAAc,sBAAkB;AAChC,cAAc,sBAAkB;AAChC,cAAc,qBAAiB;AAC/B,cAAc,6BAAyB"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/outreach/src/lib/engine/index.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\n/*\n * The Outreach engine (AGL-2979): pure decisions, no I/O, safe for the\n * console and the server alike. `./do-not-contact` is deliberately absent —\n * it hashes with `node:crypto` — and is imported by its own path.\n */\nexport * from './sequence-validation'\nexport * from './recipient-country'\nexport * from './gates'\nexport * from './schedule'\nexport * from './sending-capacity'\nexport * from './next-send'\nexport * from './enrollment-state'\nexport * from './compose'\nexport * from './thread-message'\nexport * from './delivery-status'\nexport * from './opt-out-intent'\nexport * from './thread-classification'\nexport * from './mailbox-health'\nexport * from './mailbox-notice'\nexport * from './gateway-block'\nexport * from './do-not-contact-domain'\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;CAIC,GACD,cAAc,2BAAuB;AACrC,cAAc,yBAAqB;AACnC,cAAc,aAAS;AACvB,cAAc,gBAAY;AAC1B,cAAc,wBAAoB;AAClC,cAAc,iBAAa;AAC3B,cAAc,wBAAoB;AAClC,cAAc,eAAW;AACzB,cAAc,sBAAkB;AAChC,cAAc,uBAAmB;AACjC,cAAc,sBAAkB;AAChC,cAAc,6BAAyB;AACvC,cAAc,sBAAkB;AAChC,cAAc,sBAAkB;AAChC,cAAc,qBAAiB;AAC/B,cAAc,6BAAyB"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import type { OutreachEnrollment, OutreachMailbox, OutreachSequence } from '../model/outreach.types';
18
+ import { type OutreachTickAllowance } from './sending-capacity';
19
+ /** Why a due enrollment has not gone yet. */
20
+ export type OutreachQueuedReason =
21
+ /** Its turn comes in a later run: the day's cap is spread over the window. */
22
+ 'paced'
23
+ /** A task step, which the next run turns into a CRM task. */
24
+ | 'next_run'
25
+ /** The send window is closed; it goes when the window next opens. */
26
+ | 'window_closed'
27
+ /** The mailbox has sent its cap for today. */
28
+ | 'daily_cap_reached'
29
+ /** The mailbox is missing, paused or disconnected: nothing sends. */
30
+ | 'mailbox_not_sending'
31
+ /** The sequence is not active: nothing sends. */
32
+ | 'sequence_not_active';
33
+ export type OutreachNextSendState = {
34
+ kind: 'none';
35
+ } | {
36
+ kind: 'scheduled';
37
+ dueAtMs: number;
38
+ } | {
39
+ kind: 'queued';
40
+ dueAtMs: number;
41
+ reason: OutreachQueuedReason;
42
+ /** When the window it waits for next opens, for the two reasons that wait on one. */
43
+ opensAtMs: number | null;
44
+ /** The mailbox's allowance this run, when the mailbox is known and sending. */
45
+ pacing: Pick<OutreachTickAllowance, 'allowance' | 'dailyCap' | 'sentToday'> | null;
46
+ };
47
+ export interface OutreachNextSendInput {
48
+ enrollment: Pick<OutreachEnrollment, 'status' | 'nextDueAtMs' | 'stopReason' | 'stepIndex'>;
49
+ /** The enrollment's sequence; omitted when the reader does not have it. */
50
+ sequence?: Pick<OutreachSequence, 'status' | 'steps' | 'settings'> | null;
51
+ /**
52
+ * The enrollment's mailbox: `undefined` while it is still loading, which
53
+ * reads as "paced" without figures, and `null` when there is none.
54
+ */
55
+ mailbox: Pick<OutreachMailbox, 'status' | 'dailyCap' | 'rampStartedAtMs' | 'timezone' | 'window' | 'health'> | null | undefined;
56
+ nowMs: number;
57
+ }
58
+ /** What an enrollment's "Next send" says — see the module note. */
59
+ export declare function outreachNextSendState(input: OutreachNextSendInput): OutreachNextSendState;
@@ -0,0 +1,100 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ /*==========================================
17
+ * WHAT "NEXT SEND" MEANS ONCE THE TIME HAS COME (AGL-3366).
18
+ *
19
+ * An enrollment's `nextDueAtMs` is the earliest it may go, not when it
20
+ * goes. The runtime sends a mailbox's share of the day each run (see
21
+ * `./sending-capacity`), follow-ups first, so on a busy morning a first
22
+ * email can stay due for an hour or more. A past timestamp in that state
23
+ * reads as a send that failed; what it is, is a place in a queue.
24
+ *
25
+ * So a due, active enrollment is described by why it is still waiting:
26
+ * paced across the window, waiting for the window to open, over today's
27
+ * cap, or held because its mailbox or sequence is not sending. No "sends
28
+ * by" time is projected: the order is decided across every sequence on the
29
+ * mailbox, which no one page of enrollments can see.
30
+ *==========================================*/ import { isValidTimeZone, nextWeeklyOpening, zonedDayKey } from "@aglyn/shared-util-timestamp/zoned-time";
31
+ import { effectiveOutreachWindow, isOutreachWindowOpen, outreachWindowSchedule } from "./schedule.js";
32
+ import { outreachTickAllowance } from "./sending-capacity.js";
33
+ /**
34
+ * The first opening of the window on a later local day than `nowMs`'s —
35
+ * when a mailbox that has spent today's cap sends again.
36
+ */ function openingOnALaterDay(nowMs, schedule, timeZone) {
37
+ const today = zonedDayKey(nowMs, timeZone);
38
+ let atMs = nowMs;
39
+ for(let guard = 0; guard < 16; guard += 1){
40
+ const opening = nextWeeklyOpening(atMs, schedule, timeZone);
41
+ if (!opening) return null;
42
+ if (opening.startMs > nowMs && zonedDayKey(opening.startMs, timeZone) !== today) {
43
+ return opening.startMs;
44
+ }
45
+ atMs = opening.endMs;
46
+ }
47
+ return null;
48
+ }
49
+ /** What an enrollment's "Next send" says — see the module note. */ export function outreachNextSendState(input) {
50
+ var _sequence_steps, _sequence_settings;
51
+ const { enrollment, sequence, mailbox, nowMs } = input;
52
+ const due = enrollment.nextDueAtMs;
53
+ if (enrollment.status !== 'active' && enrollment.status !== 'paused') return {
54
+ kind: 'none'
55
+ };
56
+ if (typeof due !== 'number' || !Number.isFinite(due)) return {
57
+ kind: 'none'
58
+ };
59
+ if (enrollment.status === 'paused' || enrollment.stopReason || due > nowMs) {
60
+ return {
61
+ kind: 'scheduled',
62
+ dueAtMs: due
63
+ };
64
+ }
65
+ const queued = (reason, opensAtMs = null, pacing = null)=>({
66
+ kind: 'queued',
67
+ dueAtMs: due,
68
+ reason,
69
+ opensAtMs,
70
+ pacing: pacing ? {
71
+ allowance: pacing.allowance,
72
+ dailyCap: pacing.dailyCap,
73
+ sentToday: pacing.sentToday
74
+ } : null
75
+ });
76
+ if (sequence && sequence.status !== 'active') return queued('sequence_not_active');
77
+ if (mailbox === undefined) return queued('paced');
78
+ if (!mailbox || mailbox.status !== 'connected' || !isValidTimeZone(mailbox.timezone)) {
79
+ return queued('mailbox_not_sending');
80
+ }
81
+ const step = sequence == null ? void 0 : (_sequence_steps = sequence.steps) == null ? void 0 : _sequence_steps[enrollment.stepIndex];
82
+ if ((step == null ? void 0 : step.kind) === 'task') return queued('next_run');
83
+ const window = effectiveOutreachWindow(sequence == null ? void 0 : (_sequence_settings = sequence.settings) == null ? void 0 : _sequence_settings.window, mailbox.window);
84
+ const schedule = outreachWindowSchedule(window);
85
+ const allowance = outreachTickAllowance({
86
+ mailbox,
87
+ nowMs
88
+ });
89
+ if (allowance.hold === 'daily_cap_reached') {
90
+ return queued('daily_cap_reached', openingOnALaterDay(nowMs, schedule, mailbox.timezone), allowance);
91
+ }
92
+ if (!isOutreachWindowOpen(nowMs, window, mailbox.timezone)) {
93
+ var _ref;
94
+ const opening = nextWeeklyOpening(nowMs, schedule, mailbox.timezone);
95
+ return queued('window_closed', (_ref = opening == null ? void 0 : opening.startMs) != null ? _ref : null, allowance);
96
+ }
97
+ return queued('paced', null, allowance);
98
+ }
99
+
100
+ //# sourceMappingURL=next-send.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/outreach/src/lib/engine/next-send.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\n/*==========================================\n * WHAT \"NEXT SEND\" MEANS ONCE THE TIME HAS COME (AGL-3366).\n *\n * An enrollment's `nextDueAtMs` is the earliest it may go, not when it\n * goes. The runtime sends a mailbox's share of the day each run (see\n * `./sending-capacity`), follow-ups first, so on a busy morning a first\n * email can stay due for an hour or more. A past timestamp in that state\n * reads as a send that failed; what it is, is a place in a queue.\n *\n * So a due, active enrollment is described by why it is still waiting:\n * paced across the window, waiting for the window to open, over today's\n * cap, or held because its mailbox or sequence is not sending. No \"sends\n * by\" time is projected: the order is decided across every sequence on the\n * mailbox, which no one page of enrollments can see.\n *==========================================*/\n\nimport { isValidTimeZone, nextWeeklyOpening, zonedDayKey } from '@aglyn/shared-util-timestamp/zoned-time'\nimport type {\n OutreachEnrollment,\n OutreachMailbox,\n OutreachSequence,\n} from '../model/outreach.types'\nimport { effectiveOutreachWindow, isOutreachWindowOpen, outreachWindowSchedule } from './schedule'\nimport { outreachTickAllowance, type OutreachTickAllowance } from './sending-capacity'\n\n/** Why a due enrollment has not gone yet. */\nexport type OutreachQueuedReason =\n /** Its turn comes in a later run: the day's cap is spread over the window. */\n | 'paced'\n /** A task step, which the next run turns into a CRM task. */\n | 'next_run'\n /** The send window is closed; it goes when the window next opens. */\n | 'window_closed'\n /** The mailbox has sent its cap for today. */\n | 'daily_cap_reached'\n /** The mailbox is missing, paused or disconnected: nothing sends. */\n | 'mailbox_not_sending'\n /** The sequence is not active: nothing sends. */\n | 'sequence_not_active'\n\nexport type OutreachNextSendState =\n | { kind: 'none' }\n | { kind: 'scheduled'; dueAtMs: number }\n | {\n kind: 'queued'\n dueAtMs: number\n reason: OutreachQueuedReason\n /** When the window it waits for next opens, for the two reasons that wait on one. */\n opensAtMs: number | null\n /** The mailbox's allowance this run, when the mailbox is known and sending. */\n pacing: Pick<OutreachTickAllowance, 'allowance' | 'dailyCap' | 'sentToday'> | null\n }\n\nexport interface OutreachNextSendInput {\n enrollment: Pick<OutreachEnrollment, 'status' | 'nextDueAtMs' | 'stopReason' | 'stepIndex'>\n /** The enrollment's sequence; omitted when the reader does not have it. */\n sequence?: Pick<OutreachSequence, 'status' | 'steps' | 'settings'> | null\n /**\n * The enrollment's mailbox: `undefined` while it is still loading, which\n * reads as \"paced\" without figures, and `null` when there is none.\n */\n mailbox: Pick<\n OutreachMailbox,\n 'status' | 'dailyCap' | 'rampStartedAtMs' | 'timezone' | 'window' | 'health'\n > | null | undefined\n nowMs: number\n}\n\n/**\n * The first opening of the window on a later local day than `nowMs`'s —\n * when a mailbox that has spent today's cap sends again.\n */\nfunction openingOnALaterDay(\n nowMs: number,\n schedule: ReturnType<typeof outreachWindowSchedule>,\n timeZone: string,\n): number | null {\n const today = zonedDayKey(nowMs, timeZone)\n let atMs = nowMs\n for (let guard = 0; guard < 16; guard += 1) {\n const opening = nextWeeklyOpening(atMs, schedule, timeZone)\n if (!opening) return null\n if (opening.startMs > nowMs && zonedDayKey(opening.startMs, timeZone) !== today) {\n return opening.startMs\n }\n atMs = opening.endMs\n }\n return null\n}\n\n/** What an enrollment's \"Next send\" says — see the module note. */\nexport function outreachNextSendState(input: OutreachNextSendInput): OutreachNextSendState {\n const { enrollment, sequence, mailbox, nowMs } = input\n const due = enrollment.nextDueAtMs\n if (enrollment.status !== 'active' && enrollment.status !== 'paused') return { kind: 'none' }\n if (typeof due !== 'number' || !Number.isFinite(due)) return { kind: 'none' }\n if (enrollment.status === 'paused' || enrollment.stopReason || due > nowMs) {\n return { kind: 'scheduled', dueAtMs: due }\n }\n const queued = (\n reason: OutreachQueuedReason,\n opensAtMs: number | null = null,\n pacing: OutreachTickAllowance | null = null,\n ): OutreachNextSendState => ({\n kind: 'queued',\n dueAtMs: due,\n reason,\n opensAtMs,\n pacing: pacing\n ? { allowance: pacing.allowance, dailyCap: pacing.dailyCap, sentToday: pacing.sentToday }\n : null,\n })\n\n if (sequence && sequence.status !== 'active') return queued('sequence_not_active')\n if (mailbox === undefined) return queued('paced')\n if (!mailbox || mailbox.status !== 'connected' || !isValidTimeZone(mailbox.timezone)) {\n return queued('mailbox_not_sending')\n }\n const step = sequence?.steps?.[enrollment.stepIndex]\n if (step?.kind === 'task') return queued('next_run')\n\n const window = effectiveOutreachWindow(sequence?.settings?.window, mailbox.window)\n const schedule = outreachWindowSchedule(window)\n const allowance = outreachTickAllowance({ mailbox, nowMs })\n if (allowance.hold === 'daily_cap_reached') {\n return queued('daily_cap_reached', openingOnALaterDay(nowMs, schedule, mailbox.timezone), allowance)\n }\n if (!isOutreachWindowOpen(nowMs, window, mailbox.timezone)) {\n const opening = nextWeeklyOpening(nowMs, schedule, mailbox.timezone)\n return queued('window_closed', opening?.startMs ?? null, allowance)\n }\n return queued('paced', null, allowance)\n}\n"],"names":["isValidTimeZone","nextWeeklyOpening","zonedDayKey","effectiveOutreachWindow","isOutreachWindowOpen","outreachWindowSchedule","outreachTickAllowance","openingOnALaterDay","nowMs","schedule","timeZone","today","atMs","guard","opening","startMs","endMs","outreachNextSendState","input","sequence","enrollment","mailbox","due","nextDueAtMs","status","kind","Number","isFinite","stopReason","dueAtMs","queued","reason","opensAtMs","pacing","allowance","dailyCap","sentToday","undefined","timezone","step","steps","stepIndex","window","settings","hold"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;4CAc4C,GAE5C,SAASA,eAAe,EAAEC,iBAAiB,EAAEC,WAAW,QAAQ,0CAAyC;AAMzG,SAASC,uBAAuB,EAAEC,oBAAoB,EAAEC,sBAAsB,QAAQ,gBAAY;AAClG,SAASC,qBAAqB,QAAoC,wBAAoB;AA6CtF;;;CAGC,GACD,SAASC,mBACPC,KAAa,EACbC,QAAmD,EACnDC,QAAgB;IAEhB,MAAMC,QAAQT,YAAYM,OAAOE;IACjC,IAAIE,OAAOJ;IACX,IAAK,IAAIK,QAAQ,GAAGA,QAAQ,IAAIA,SAAS,EAAG;QAC1C,MAAMC,UAAUb,kBAAkBW,MAAMH,UAAUC;QAClD,IAAI,CAACI,SAAS,OAAO;QACrB,IAAIA,QAAQC,OAAO,GAAGP,SAASN,YAAYY,QAAQC,OAAO,EAAEL,cAAcC,OAAO;YAC/E,OAAOG,QAAQC,OAAO;QACxB;QACAH,OAAOE,QAAQE,KAAK;IACtB;IACA,OAAO;AACT;AAEA,iEAAiE,GACjE,OAAO,SAASC,sBAAsBC,KAA4B;QA2BnDC,iBAG0BA;IA7BvC,MAAM,EAAEC,UAAU,EAAED,QAAQ,EAAEE,OAAO,EAAEb,KAAK,EAAE,GAAGU;IACjD,MAAMI,MAAMF,WAAWG,WAAW;IAClC,IAAIH,WAAWI,MAAM,KAAK,YAAYJ,WAAWI,MAAM,KAAK,UAAU,OAAO;QAAEC,MAAM;IAAO;IAC5F,IAAI,OAAOH,QAAQ,YAAY,CAACI,OAAOC,QAAQ,CAACL,MAAM,OAAO;QAAEG,MAAM;IAAO;IAC5E,IAAIL,WAAWI,MAAM,KAAK,YAAYJ,WAAWQ,UA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