@aglyn/plugins-ai 1.0.0-beta.259 → 1.0.0-beta.261
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 +17 -17
- package/src/lib/components/ai-site-start-card.component.js +43 -34
- package/src/lib/components/ai-site-start-card.component.js.map +1 -1
- package/src/lib/jobs/ai-job-admission.d.ts +6 -0
- package/src/lib/jobs/ai-job-admission.js.map +1 -1
- package/src/lib/jobs/ai-job-site-step.js +10 -6
- package/src/lib/jobs/ai-job-site-step.js.map +1 -1
- package/src/lib/jobs/ai-layout-stock-photos.d.ts +43 -11
- package/src/lib/jobs/ai-layout-stock-photos.js +319 -32
- package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
- package/src/lib/jobs/ai-stock-photo-picker.js +13 -7
- package/src/lib/jobs/ai-stock-photo-picker.js.map +1 -1
- package/src/lib/jobs/fixtures/ai-stock-photo-agl3856-recordings.d.ts +35 -0
- package/src/lib/jobs/fixtures/ai-stock-photo-agl3856-recordings.js +404 -0
- package/src/lib/jobs/fixtures/ai-stock-photo-agl3856-recordings.js.map +1 -0
- package/src/lib/layout-language/ai-layout-motion.d.ts +9 -3
- package/src/lib/layout-language/ai-layout-motion.js +9 -3
- package/src/lib/layout-language/ai-layout-motion.js.map +1 -1
- package/src/lib/layout-language/ai-layout-pictures.d.ts +10 -1
- package/src/lib/layout-language/ai-layout-pictures.js +12 -6
- package/src/lib/layout-language/ai-layout-pictures.js.map +1 -1
- package/src/lib/runtime/ai-doctrine-validators.d.ts +40 -0
- package/src/lib/runtime/ai-doctrine-validators.js +132 -1
- package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
- package/src/lib/runtime/ai-doctrine.js +6 -2
- package/src/lib/runtime/ai-doctrine.js.map +1 -1
- package/src/lib/server/ai-jobs-route.js +19 -0
- package/src/lib/server/ai-jobs-route.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/plugins-ai",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.261",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,22 +25,22 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.0.0-beta.
|
|
29
|
-
"@aglyn/shared-data-enums": "1.0.0-beta.
|
|
30
|
-
"@aglyn/shared-data-mdi": "1.0.0-beta.
|
|
31
|
-
"@aglyn/shared-data-types": "1.0.0-beta.
|
|
32
|
-
"@aglyn/shared-ui-email-campaigns": "1.0.0-beta.
|
|
33
|
-
"@aglyn/shared-ui-jsx": "1.0.0-beta.
|
|
34
|
-
"@aglyn/shared-ui-snackstack": "1.0.0-beta.
|
|
35
|
-
"@aglyn/shared-ui-theme": "1.0.0-beta.
|
|
36
|
-
"@aglyn/shared-util-email": "1.0.0-beta.
|
|
37
|
-
"@aglyn/shared-util-errors": "1.0.0-beta.
|
|
38
|
-
"@aglyn/shared-util-http": "1.0.0-beta.
|
|
39
|
-
"@aglyn/shared-util-timestamp": "1.0.0-beta.
|
|
40
|
-
"@aglyn/shared-util-tools": "1.0.0-beta.
|
|
41
|
-
"@aglyn/tenant-data-admin": "1.0.0-beta.
|
|
42
|
-
"@aglyn/tenant-feature-instance": "1.0.0-beta.
|
|
43
|
-
"@aglyn/tenant-runtime": "1.0.0-beta.
|
|
28
|
+
"@aglyn/aglyn": "1.0.0-beta.261",
|
|
29
|
+
"@aglyn/shared-data-enums": "1.0.0-beta.261",
|
|
30
|
+
"@aglyn/shared-data-mdi": "1.0.0-beta.261",
|
|
31
|
+
"@aglyn/shared-data-types": "1.0.0-beta.261",
|
|
32
|
+
"@aglyn/shared-ui-email-campaigns": "1.0.0-beta.261",
|
|
33
|
+
"@aglyn/shared-ui-jsx": "1.0.0-beta.261",
|
|
34
|
+
"@aglyn/shared-ui-snackstack": "1.0.0-beta.261",
|
|
35
|
+
"@aglyn/shared-ui-theme": "1.0.0-beta.261",
|
|
36
|
+
"@aglyn/shared-util-email": "1.0.0-beta.261",
|
|
37
|
+
"@aglyn/shared-util-errors": "1.0.0-beta.261",
|
|
38
|
+
"@aglyn/shared-util-http": "1.0.0-beta.261",
|
|
39
|
+
"@aglyn/shared-util-timestamp": "1.0.0-beta.261",
|
|
40
|
+
"@aglyn/shared-util-tools": "1.0.0-beta.261",
|
|
41
|
+
"@aglyn/tenant-data-admin": "1.0.0-beta.261",
|
|
42
|
+
"@aglyn/tenant-feature-instance": "1.0.0-beta.261",
|
|
43
|
+
"@aglyn/tenant-runtime": "1.0.0-beta.261",
|
|
44
44
|
"@swc/helpers": "0.5.23"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
@@ -355,15 +355,54 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
|
|
|
355
355
|
setServerPrompt(null);
|
|
356
356
|
try {
|
|
357
357
|
var _ref;
|
|
358
|
+
const requestJob = (siteId, check)=>authorizedFetch(userRef.current, '/api/ai/jobs', {
|
|
359
|
+
method: 'POST',
|
|
360
|
+
headers: {
|
|
361
|
+
'Content-Type': 'application/json'
|
|
362
|
+
},
|
|
363
|
+
body: JSON.stringify(_extends({
|
|
364
|
+
orgId,
|
|
365
|
+
hostId: siteId,
|
|
366
|
+
kind: 'site',
|
|
367
|
+
brief: aiSiteStartBrief(asked),
|
|
368
|
+
// The guided start confirms its own plan (AGL-3594): the build
|
|
369
|
+
// follows the plan with no approval to make.
|
|
370
|
+
inputs: _extends({}, aiSiteStartInputs(asked), {
|
|
371
|
+
[AI_JOB_AUTO_CONFIRM_INPUT]: true
|
|
372
|
+
})
|
|
373
|
+
}, pickedModel ? {
|
|
374
|
+
model: pickedModel
|
|
375
|
+
} : {}, options.creditsConfirmed ? {
|
|
376
|
+
creditsConfirmed: true
|
|
377
|
+
} : {}, check ? {
|
|
378
|
+
check: true
|
|
379
|
+
} : {}))
|
|
380
|
+
});
|
|
381
|
+
// A refusal said in the dialog, or the Free go-ahead it asks for.
|
|
382
|
+
const refused = async (response)=>{
|
|
383
|
+
var _ref;
|
|
384
|
+
const payload = await response.json().catch(()=>null);
|
|
385
|
+
if (response.ok) return payload != null ? payload : {};
|
|
386
|
+
if (response.status === 409 && (payload == null ? void 0 : payload.code) === AI_CREDITS_CONFIRM_CODE && (payload == null ? void 0 : payload.credits)) {
|
|
387
|
+
setServerPrompt(payload.credits);
|
|
388
|
+
return null;
|
|
389
|
+
}
|
|
390
|
+
const locked = parseLockdownRefusal(response.status, payload);
|
|
391
|
+
setNotice(locked ? lockdownRefusalText(locked) : String((_ref = payload == null ? void 0 : payload.error) != null ? _ref : 'The site could not be started. Try again.'));
|
|
392
|
+
return null;
|
|
393
|
+
};
|
|
358
394
|
// The site, created now when it does not exist yet (AGL-3761): this is
|
|
359
|
-
// the moment the person asked for it.
|
|
360
|
-
//
|
|
395
|
+
// the moment the person asked for it. The start is checked first
|
|
396
|
+
// (AGL-3859), so one the jobs route would refuse, or would ask the Free
|
|
397
|
+
// go-ahead for, is answered before any site exists. A refusal about the
|
|
398
|
+
// name or address goes back to step 1, where they are typed.
|
|
361
399
|
let site = {
|
|
362
400
|
hostId,
|
|
363
401
|
host,
|
|
364
402
|
orgSlug
|
|
365
403
|
};
|
|
366
404
|
if (!hostId && pendingSite) {
|
|
405
|
+
if (!pendingSite.created && !await refused(await requestJob(null, true))) return;
|
|
367
406
|
const made = await pendingSite.create();
|
|
368
407
|
if ('error' in made) {
|
|
369
408
|
setNotice(made.error);
|
|
@@ -377,38 +416,8 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
|
|
|
377
416
|
};
|
|
378
417
|
}
|
|
379
418
|
if (!site.hostId) return;
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
headers: {
|
|
383
|
-
'Content-Type': 'application/json'
|
|
384
|
-
},
|
|
385
|
-
body: JSON.stringify(_extends({
|
|
386
|
-
orgId,
|
|
387
|
-
hostId: site.hostId,
|
|
388
|
-
kind: 'site',
|
|
389
|
-
brief: aiSiteStartBrief(asked),
|
|
390
|
-
// The guided start confirms its own plan (AGL-3594): the build
|
|
391
|
-
// follows the plan with no approval to make.
|
|
392
|
-
inputs: _extends({}, aiSiteStartInputs(asked), {
|
|
393
|
-
[AI_JOB_AUTO_CONFIRM_INPUT]: true
|
|
394
|
-
})
|
|
395
|
-
}, pickedModel ? {
|
|
396
|
-
model: pickedModel
|
|
397
|
-
} : {}, options.creditsConfirmed ? {
|
|
398
|
-
creditsConfirmed: true
|
|
399
|
-
} : {}))
|
|
400
|
-
});
|
|
401
|
-
const payload = await response.json().catch(()=>null);
|
|
402
|
-
if (!response.ok) {
|
|
403
|
-
var _ref1;
|
|
404
|
-
if (response.status === 409 && (payload == null ? void 0 : payload.code) === AI_CREDITS_CONFIRM_CODE && (payload == null ? void 0 : payload.credits)) {
|
|
405
|
-
setServerPrompt(payload.credits);
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
const locked = parseLockdownRefusal(response.status, payload);
|
|
409
|
-
setNotice(locked ? lockdownRefusalText(locked) : String((_ref1 = payload == null ? void 0 : payload.error) != null ? _ref1 : 'The site could not be started. Try again.'));
|
|
410
|
-
return;
|
|
411
|
-
}
|
|
419
|
+
const payload = await refused(await requestJob(site.hostId, false));
|
|
420
|
+
if (!payload) return;
|
|
412
421
|
const created = (_ref = payload == null ? void 0 : payload.job) != null ? _ref : null;
|
|
413
422
|
if (!created) {
|
|
414
423
|
setNotice('The site could not be started. Try again.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-site-start-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n'use client'\n\nimport { lockdownRefusalText, parseLockdownRefusal, PLATFORM_BRAND_NAME } from '@aglyn/aglyn'\nimport { trackEvent } from '@aglyn/aglyn/app-utils/analytics-events'\nimport type { ConsoleHostFirstRunZoneProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { ICON_VARIANT_CLOSE } from '@aglyn/shared-data-enums'\nimport {\n mdiAccount,\n mdiBookOpenPageVariant,\n mdiBriefcaseOutline,\n mdiCalendarHeart,\n mdiCamera,\n mdiClockOutline,\n mdiContentCut,\n mdiCreation,\n mdiDumbbell,\n mdiHandHeart,\n mdiHeartPulse,\n mdiHomeCity,\n mdiMusic,\n mdiPaletteOutline,\n mdiRocketLaunch,\n mdiScaleBalance,\n mdiSchool,\n mdiShopping,\n mdiSilverwareForkKnife,\n mdiViewGridOutline,\n mdiWrench,\n mdiYoga,\n mdiPageLayoutHeaderFooter,\n} from '@aglyn/shared-data-mdi'\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport { HelpTip, MdiIcon } from '@aglyn/shared-ui-jsx'\nimport { OptionCardGrid } from '@aglyn/shared-ui-jsx/components/option-card-grid.component'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n AppBar,\n Box,\n Button,\n Card,\n CardActionArea,\n Chip,\n CircularProgress,\n Container,\n Dialog,\n DialogActions,\n DialogContent,\n DialogContentText,\n DialogTitle,\n IconButton,\n MenuItem,\n Stack,\n Step,\n StepLabel,\n Stepper,\n TextField,\n Toolbar,\n Typography,\n} from '@mui/material'\nimport { alpha, type Theme } from '@mui/material/styles'\nimport { useRouter } from 'next/navigation'\nimport {\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n type ReactNode,\n type SyntheticEvent,\n} from 'react'\nimport {\n AI_JOB_AUTO_CONFIRM_INPUT,\n AI_SITE_FREE_PAGES,\n AI_SITE_FREE_PAGES_NOTE,\n AI_SITE_SUBMISSION_CHOICES,\n aiFreeCreditsNoneLeftText,\n aiFreeCreditsResetLabel,\n aiFreeSiteCreditRange,\n aiFreeSitePrompt,\n aiSiteCreditRange,\n type AiFreeCreditsLeft,\n aiSitePagesBand,\n type AiSiteSubmissions,\n} from '../model/ai-site-job'\nimport { FREE_AI_TASTE_CREDITS_PER_MONTH } from '../plan-entitlements'\nimport {\n AI_CREDITS_CONFIRM_CODE,\n aiCreditRangeText,\n type AiCreditRange,\n type AiCreditsPrompt,\n} from '../model/ai-credit-estimate'\nimport { AiCreditsPromptNotice } from './ai-credits-prompt.component'\nimport {\n AI_SITE_START_ANSWERS,\n AI_SITE_START_TYPES,\n aiSiteStartBrief,\n aiSiteStartKind,\n aiSiteStartInputs,\n aiSiteStartRefusal,\n type AiSiteStartAnswers,\n} from '../model/ai-site-start'\nimport type { AiJobSummary } from '../model/ai-jobs.types'\nimport { AI_SITE_KINDS, aiSiteKindOfInputs } from '../model/ai-site-kinds'\n\n/** The icon each kind of site's card shows. */\nconst AI_SITE_KIND_ICONS: Record<string, string> = {\n business: mdiBriefcaseOutline.path,\n trades: mdiWrench.path,\n professional: mdiScaleBalance.path,\n wellness: mdiHeartPulse.path,\n restaurant: mdiSilverwareForkKnife.path,\n store: mdiShopping.path,\n portfolio: mdiViewGridOutline.path,\n studio: mdiPaletteOutline.path,\n photography: mdiCamera.path,\n blog: mdiBookOpenPageVariant.path,\n events: mdiCalendarHeart.path,\n fitness: mdiDumbbell.path,\n yoga: mdiYoga.path,\n beauty: mdiContentCut.path,\n realestate: mdiHomeCity.path,\n education: mdiSchool.path,\n nonprofit: mdiHandHeart.path,\n music: mdiMusic.path,\n personal: mdiAccount.path,\n landing: mdiRocketLaunch.path,\n 'coming-soon': mdiClockOutline.path,\n}\nimport { AiJobFollow } from './ai-job-follow.component'\nimport { AiModelSelector } from './ai-model-selector.component'\nimport { useAiModelChoice } from './use-ai-model-choice'\nimport { aiCreditsBillingHref, aiSiteBuildHref } from './ai-job-links'\nimport { publishAiJob } from './ai-jobs-store'\n\n/**\n * The guided start (AGL-2918), on the `hostFirstRun` zone of the page a newly\n * created site lands on: a choice, a few questions, and the site scaffold they\n * become.\n *\n * ── Two steps (AGL-3594) ─────────────────────────────────────────────────\n *\n * Step 1 asks how to start, as two equal cards: the starter site — a\n * ready-made home page with a header and footer — or AI. The starter card is\n * the zone's `startBlank`, which gives a site born for the guided start the\n * starter every other new site is born with. The AI card moves to step 2, the\n * questions, which have a Back to step 1.\n *\n * ── A full screen dialog, and therefore three ways out ───────────────────\n *\n * The questions take the whole screen, which is the only presentation that\n * gets them read — but a surface that takes the screen and cannot be left is\n * a funnel, so leaving is drawn first and works three ways on both steps:\n *\n * - the close control at the start of the header,\n * - \"Skip\" at the end of it, named \"Skip and start blank\",\n * - Escape, which `Dialog` reports through `onClose`.\n *\n * Before a job is started all three are the zone's own `startBlank`: the\n * starter site, and no job, no draft, no record of a site half begun. After,\n * they close through `leave`, and the job builds the site.\n *\n * ── Or before the site exists (AGL-3761) ─────────────────────────────────\n *\n * \"Create site\" draws this straight away, with the zone's `pendingSite` and\n * no site. Step 1 then asks the site's name and address (the shell's own\n * fields) above the two cards, and the site is created only by a choice that\n * needs one: the starter card or Skip (`startBlank`, which creates it with the\n * starter), or Plan my site, which creates it and then starts the job on it.\n * The close control and Escape create nothing there: they are `leave`. If the\n * site was created and its job could not start, the site is a real one, and\n * every way out gives it the starter as above, so none is left empty.\n *\n * Escape and the close control are DISMISSALS, though, and Skip is a choice\n * (AGL-3660, 2026-10-08). Once anything is typed or picked, a dismissal asks\n * \"Leave without your answers?\" first, focused on Keep editing, so a stray\n * Escape — the second press after closing the model menu was the one in\n * production — can never trade a brief for the starter. Escape that reached\n * the dialog from a portal it does not contain (a menu, a select's list) is\n * that popup's, and the dialog ignores it.\n *\n * The header is the dialog's own chrome rather than part of its body, so the\n * way out cannot be scrolled off, and it is never disabled — least of all\n * while a request is in flight, which is the moment a person most wants it.\n * Nothing is focused ahead of the dialog's own frame, so the first thing a\n * keyboard reaches is the close control.\n *\n * ── It is absent until the route has answered ────────────────────────────\n *\n * The dialog covers the page, so being drawn on a guess is worse here than it\n * is for a card: it would be a takeover every flag-off workspace watches\n * disappear. Nothing renders at all — no `Dialog`, no portal — until the jobs\n * route has admitted this workspace, and a 404, a 403 or an unreachable route\n * is this widget staying absent and the ordinary blank page being all there\n * is. That the widget is mounted is itself the last of a stack of gates: the\n * shell held the plan's `aiGenerative` entitlement, the site's AI switch and\n * the reader's `ai.generate` first. A lockdown is the start door's to say,\n * here, in its own words.\n *\n * ── It builds and publishes for you ──────────────────────────────────────\n *\n * \"Plan my site\" starts a `site` job, which PLANS first: the pages, their\n * addresses, the navigation, the layout, the contact form and a palette. The\n * guided start confirms its own plan (AGL-3594), so the build follows with no\n * approval to make, and the site is published, indexable, when it is done.\n * The person edits or unpublishes it afterwards.\n *\n * ── It stays with the job (AGL-3593) ─────────────────────────────────────\n *\n * Once the job exists the dialog follows it live — planning, the plan with\n * its Confirm, building, then the draft pages to open — so a person never has\n * to leave it to get their site built. \"Open AI jobs\" follows the job in the\n * Assist panel instead; it leaves the guided start the way every other exit\n * does, because the dialog covers the panel it opens.\n */\n\ntype Verdict = 'checking' | 'ready' | 'hidden'\n\ntype Step = 'choose' | 'describe'\n\n/** Labels the dialog for a reader, from its own heading. */\nconst TITLE_ID = 'ai-site-start-title'\n\n/**\n * The takeover's surface, for its paper, its bar and its footer alike: the\n * console page's own background (AGL-3596). The paper sits at elevation 0,\n * which is what keeps MUI's dark-mode elevation overlay off it.\n */\nexport const AI_SITE_START_SURFACE_SX = { bgcolor: 'background.default' } as const\n\n/** The two steps, as the indicator under the header names them. */\nconst STEP_LABELS = ['Choose', 'Describe'] as const\n\n/** The soft round badge an icon sits in, in its accent's tint. */\nfunction IconBadge({ accent, children }: { accent: 'primary' | 'secondary'; children: ReactNode }) {\n return (\n <Box\n aria-hidden\n sx={(theme: Theme) => ({\n width: theme.spacing(9),\n height: theme.spacing(9),\n borderRadius: '50%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n bgcolor: alpha(theme.palette[accent].main, theme.palette.mode === 'dark' ? 0.24 : 0.12),\n color: `${accent}.main`,\n fontSize: theme.spacing(5.5),\n })}\n >\n {children}\n </Box>\n )\n}\n\n/**\n * One way to start, as a card the whole of which is the button. Its accessible\n * name is its title; its description describes it.\n */\nfunction ChoiceCard({\n accent,\n icon,\n iconId,\n title,\n description,\n busy = false,\n onChoose,\n children,\n}: {\n accent: 'primary' | 'secondary'\n icon: string\n /** Names the icon for a reader of the markup; the icon itself is decorative. */\n iconId: string\n title: string\n description: string\n busy?: boolean\n onChoose: () => void\n children?: ReactNode\n}) {\n const id = useId()\n return (\n <Card\n variant=\"outlined\"\n sx={(theme: Theme) => ({\n borderRadius: 2,\n height: '100%',\n transition: theme.transitions.create(['border-color', 'box-shadow', 'transform'], {\n duration: theme.transitions.duration.shorter,\n }),\n '&:hover, &:focus-within': {\n borderColor: `${accent}.main`,\n boxShadow: theme.shadows[4],\n transform: `translateY(-${theme.spacing(0.25)})`,\n },\n '@media (prefers-reduced-motion: reduce)': {\n transition: 'none',\n '&:hover, &:focus-within': { transform: 'none' },\n },\n })}\n >\n <CardActionArea\n onClick={onChoose}\n disabled={busy}\n aria-labelledby={`${id}-title`}\n aria-describedby={`${id}-description`}\n aria-busy={busy || undefined}\n sx={{ height: '100%', p: { xs: 3, sm: 4 } }}\n >\n <Stack spacing={2} sx={{ alignItems: 'center', textAlign: 'center' }}>\n <IconBadge accent={accent}>\n {busy ? (\n <CircularProgress size=\"1em\" color={accent} aria-label={`${title}…`} />\n ) : (\n <MdiIcon path={icon} data-icon={iconId} aria-hidden />\n )}\n </IconBadge>\n <Typography id={`${id}-title`} variant=\"h6\" component=\"h2\">\n {title}\n </Typography>\n <Typography id={`${id}-description`} variant=\"body2\" color=\"text.secondary\">\n {description}\n </Typography>\n {children}\n </Stack>\n </CardActionArea>\n </Card>\n )\n}\n\n/** A small label above a group of questions. */\n/**\n * Each part of the guided start links its own section of the Start with AI\n * guide (AGL-3660), so a `?` says what that one group of answers changes.\n */\nconst START_HELP = {\n choose: pluginDocsHelp('aiStart', {\n anchor: '#how-do-you-want-to-start',\n excerpt:\n 'The starter site gives you a ready-made home page to edit. Start with AI asks a few questions, then plans, writes and publishes your pages.',\n }),\n business: pluginDocsHelp('aiStart', {\n anchor: '#your-business',\n excerpt:\n 'What kind of site it is picks its style and pages; who it is for is who every page and the contact form are written for.',\n }),\n style: pluginDocsHelp('aiSiteLooks', {\n anchor: '#choose-a-style',\n excerpt:\n 'The style decides the look — theme, colors, fonts, buttons — and which pages the site usually has. Every site gets its own variation.',\n }),\n details: pluginDocsHelp('aiStart', {\n anchor: '#details',\n excerpt:\n 'Where contact form messages go, how many pages to write, and on paid plans whether to draft a welcome email. All can be changed later.',\n }),\n estimate: pluginDocsHelp('aiCredits', {\n anchor: '#before-a-job-starts',\n excerpt:\n 'About what a start like this costs, measured on real builds, and the most it can cost. What it really costs is what each step spends, and you can watch that add up while it runs.',\n }),\n}\n\nfunction SectionLabel({ children, help }: { children: ReactNode; help?: ReturnType<typeof pluginDocsHelp> }) {\n return (\n <Stack direction=\"row\" spacing={0.5} sx={{ alignItems: 'center' }}>\n <Typography variant=\"overline\" color=\"text.secondary\" component=\"h2\" sx={{ display: 'block' }}>\n {children}\n </Typography>\n {help ? <HelpTip {...help} /> : null}\n </Stack>\n )\n}\n\n/**\n * The guided start, as the `hostFirstRun` zone draws it, or reopened on a\n * failed start's own answers (AGL-3596): `initialAnswers` opens it on the\n * questions, filled in, for the person to adjust and start a fresh job.\n */\nexport type AiSiteStartCardProps = ConsoleHostFirstRunZoneProps & {\n initialAnswers?: AiSiteStartAnswers | null\n}\n\nexport function AiSiteStartCard({\n hostId,\n orgId,\n orgSlug,\n host,\n startBlank,\n leave,\n pendingSite,\n initialAnswers = null,\n}: AiSiteStartCardProps) {\n const { data: user } = useUser()\n const router = useRouter()\n // Held in a ref so a request reads WHO is signed in, never the identity of\n // the object that says so.\n const userRef = useRef(user)\n userRef.current = user\n const uid = user?.uid ?? null\n const [verdict, setVerdict] = useState<Verdict>('checking')\n // Read once: a start reopened on its answers stays one while it is open.\n const reopened = useRef(initialAnswers !== null)\n const [step, setStep] = useState<Step>(initialAnswers ? 'describe' : 'choose')\n const [answers, setAnswers] = useState<AiSiteStartAnswers>(initialAnswers ?? AI_SITE_START_ANSWERS)\n const [busy, setBusy] = useState(false)\n // The starter card's own busy state while `startBlank` runs (AGL-3594).\n const [startingStarter, setStartingStarter] = useState(false)\n const [notice, setNotice] = useState<string | null>(null)\n /** The site job \"Plan my site\" started, as the create door answered with it. */\n const [started, setStarted] = useState<AiJobSummary | null>(null)\n // The Free taste's page band (AGL-3594), read off the verdict request.\n const [freeTaste, setFreeTaste] = useState(false)\n // What the Free workspace has left this month (AGL-3660), as the same read\n // the create door refuses on: the less of its own band and its owner's\n // allowance across their Free workspaces. `null` when the route said none.\n const [freeCredits, setFreeCredits] = useState<AiFreeCreditsLeft | null>(null)\n // \"Leave without your answers?\" (AGL-3660): a dismissal with a brief typed.\n const [confirmingLeave, setConfirmingLeave] = useState(false)\n // The dialog's own root, to tell its Escape from a nested popup's.\n const dialogRef = useRef<HTMLDivElement | null>(null)\n // Drawn by \"Create site\" before the site exists (AGL-3761): the shell's\n // name and address are asked on step 1, and the site is created only by\n // the starter, Skip, or Plan my site. Read through a ref by the verdict\n // below, which must not re-run when the shell re-renders it.\n const pendingRef = useRef(pendingSite)\n pendingRef.current = pendingSite\n const creating = Boolean(pendingSite) && !pendingSite?.created\n\n useEffect(() => {\n if (!orgId || !uid) return\n let active = true\n void (async () => {\n try {\n const response = await authorizedFetch(\n userRef.current,\n `/api/ai/jobs?orgId=${encodeURIComponent(orgId)}&limit=1`,\n )\n const payload = response.ok ? await response.json().catch(() => null) : null\n if (active) {\n if (payload?.freeTaste === true) {\n setFreeTaste(true)\n const credits = payload?.freeCredits as AiFreeCreditsLeft | undefined\n if (credits && Number.isFinite(credits.left)) setFreeCredits(credits)\n // A reopened start keeps the pages it asked for, within the band.\n setAnswers((current) => ({\n ...current,\n pages: reopened.current ? Math.min(current.pages, AI_SITE_FREE_PAGES.max) : AI_SITE_FREE_PAGES.max,\n welcomeEmail: false,\n }))\n }\n const shown = response.status !== 404 && response.status !== 403\n setVerdict(shown ? 'ready' : 'hidden')\n // \"Create site\" shows its own dialog when this one will not draw.\n pendingRef.current?.ready(shown)\n }\n } catch {\n if (active) {\n setVerdict('hidden')\n pendingRef.current?.ready(false)\n }\n }\n })()\n return () => {\n active = false\n }\n }, [orgId, uid])\n\n const answer = useCallback(\n (patch: Partial<AiSiteStartAnswers>) =>\n setAnswers((current) => ({ ...current, ...patch })),\n [],\n )\n\n // A Free start past what is left asks first (AGL-3722): it is admitted on\n // its measured p90, and one past what is left starts only on \"Build what\n // fits\" (pausing with Resume where the credits run out), or smaller as the\n // home page alone. The create door asks the same, so a stale dialog meets\n // the prompt there too (`serverPrompt`). Nothing at all left is a dead\n // stop until the credits renew or the workspace upgrades.\n const [serverPrompt, setServerPrompt] = useState<AiCreditsPrompt | null>(null)\n // The door's prompt was for the pages it was asked with.\n useEffect(() => setServerPrompt(null), [answers.pages])\n // A store's first products and a blog's first posts are part of the start (AGL-3676, AGL-3798).\n const siteKind = aiSiteKindOfInputs(aiSiteStartInputs(answers))?.id ?? null\n const prompt = freeTaste ? (aiFreeSitePrompt(freeCredits, answers.pages, { siteKind }) ?? serverPrompt) : null\n const noneLeft = freeTaste && freeCredits !== null && freeCredits.left <= 0\n const refusal = aiSiteStartRefusal(answers, { freeTaste })\n const band = aiSitePagesBand(freeTaste)\n // On a paid plan the person picks the model that builds the site (AGL-3660),\n // Auto by default, from the models their plan allows; every step of the job\n // runs on it. A Free workspace builds on the default and is offered none.\n const modelChoice = useAiModelChoice({ orgId, hostId, surface: 'jobs', kind: 'job.page' })\n // A pick remembered from before needs its cost to estimate by; Auto does not,\n // and the list is otherwise read when the picker opens.\n const { load: loadModels, model: rememberedModel } = modelChoice\n useEffect(() => {\n if (!freeTaste && step === 'describe' && rememberedModel) loadModels()\n }, [freeTaste, step, rememberedModel, loadModels])\n const pickedModel = freeTaste ? null : modelChoice.model\n\n const plan = useCallback(async (options: { creditsConfirmed?: boolean; pages?: number } = {}) => {\n const asked = options.pages ? { ...answers, pages: options.pages } : answers\n if (!orgId || aiSiteStartRefusal(asked, { freeTaste }) || noneLeft) return\n // Past what is left, only an explicit go-ahead starts it.\n if (freeTaste && !options.creditsConfirmed && aiFreeSitePrompt(freeCredits, asked.pages, { siteKind })) return\n if (options.pages) answer({ pages: options.pages })\n setBusy(true)\n setNotice(null)\n setServerPrompt(null)\n try {\n // The site, created now when it does not exist yet (AGL-3761): this is\n // the moment the person asked for it. A refusal is said here, and one\n // about the name or address goes back to step 1, where they are typed.\n let site = { hostId, host, orgSlug }\n if (!hostId && pendingSite) {\n const made = await pendingSite.create()\n if ('error' in made) {\n setNotice(made.error)\n if (made.address) setStep('choose')\n return\n }\n site = { hostId: made.hostId, host: made.host, orgSlug: made.orgSlug || orgSlug }\n }\n if (!site.hostId) return\n const response = await authorizedFetch(userRef.current, '/api/ai/jobs', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n orgId,\n hostId: site.hostId,\n kind: 'site',\n brief: aiSiteStartBrief(asked),\n // The guided start confirms its own plan (AGL-3594): the build\n // follows the plan with no approval to make.\n inputs: { ...aiSiteStartInputs(asked), [AI_JOB_AUTO_CONFIRM_INPUT]: true },\n ...(pickedModel ? { model: pickedModel } : {}),\n ...(options.creditsConfirmed ? { creditsConfirmed: true } : {}),\n }),\n })\n const payload = await response.json().catch(() => null)\n if (!response.ok) {\n if (response.status === 409 && payload?.code === AI_CREDITS_CONFIRM_CODE && payload?.credits) {\n setServerPrompt(payload.credits as AiCreditsPrompt)\n return\n }\n const locked = parseLockdownRefusal(response.status, payload)\n setNotice(\n locked\n ? lockdownRefusalText(locked)\n : String(payload?.error ?? 'The site could not be started. Try again.'),\n )\n return\n }\n const created = (payload?.job as AiJobSummary | undefined) ?? null\n if (!created) {\n setNotice('The site could not be started. Try again.')\n return\n }\n // The indicator and the launcher count it from the moment it exists.\n publishAiJob(created)\n // Where the next step is (AGL-3594): the site's \"Building your site\"\n // page for this job. The zone closes without the starter first, so the\n // setup page does not ask again behind it.\n const href = aiSiteBuildHref(site.orgSlug, site.host, created.id)\n if (href) {\n ;(leave ?? (() => undefined))()\n router.push(href)\n return\n }\n setStarted(created)\n } catch {\n setNotice('The site could not be started. Try again.')\n } finally {\n setBusy(false)\n }\n }, [orgId, hostId, answers, answer, freeTaste, freeCredits, noneLeft, orgSlug, host, leave, router, pickedModel, pendingSite, siteKind])\n\n // The zone's `startBlank`. Before the site exists it creates it with the\n // starter, and answers `false` when it could not — most often a name or\n // address to fix, which step 1 shows.\n const runStartBlank = useCallback(() => {\n const result = startBlank()\n if (result && typeof result.then === 'function') {\n void result.then((done) => {\n if (done) return\n setStartingStarter(false)\n setStep('choose')\n })\n }\n }, [startBlank])\n\n const chooseStarter = useCallback(() => {\n if (pendingSite && !pendingSite.created && !pendingSite.check()) return\n setStartingStarter(true)\n trackEvent('site_start_choice', { choice: 'starter' })\n runStartBlank()\n }, [pendingSite, runStartBlank])\n\n const chooseAi = useCallback(() => {\n if (pendingSite && !pendingSite.created && !pendingSite.check()) return\n trackEvent('site_start_choice', { choice: 'ai' })\n setStep('describe')\n }, [pendingSite])\n\n if (verdict !== 'ready') return null\n\n // Before a job is started Skip is the blank site, which writes the starter\n // (AGL-3594); after, it only closes — the job builds the site.\n const exit = started ? (leave ?? runStartBlank) : runStartBlank\n // Escape and the close control. Before \"Create site\" has made the site\n // (AGL-3761) there is nothing to give a starter to, so they only close,\n // and nothing is created; otherwise they are the same way out as Skip.\n const dismissTo = creating && !started ? (leave ?? runStartBlank) : exit\n // Anything the person typed or picked, which a dismissal must not discard\n // silently (AGL-3660). After a job starts there is nothing left to lose.\n const drafted =\n !started &&\n Boolean(\n answers.siteType.trim() ||\n answers.audience.trim() ||\n answers.kind !== null ||\n (creating && pendingSite?.dirty),\n )\n // Escape and the close control: a dismissal, never a choice. Escape that\n // bubbled here through React from a portal outside this dialog's own DOM is\n // a nested menu's, already handled there, and is not this dialog's to act on.\n const dismiss = (event?: SyntheticEvent | object, reason?: string) => {\n if (reason === 'escapeKeyDown') {\n const target = (event as SyntheticEvent | undefined)?.target\n const root = dialogRef.current\n if (root && target instanceof Node && !root.contains(target)) return\n }\n if (drafted) setConfirmingLeave(true)\n else dismissTo()\n }\n const leaveDraft = () => {\n setConfirmingLeave(false)\n dismissTo()\n }\n\n // The chosen model's cost against Auto's, as the model list states it.\n const modelMultiplier =\n (pickedModel && modelChoice.options?.options.find((option) => option.id === pickedModel)?.multiplier) || 1\n // What the start is likely to cost and at most (AGL-3722): \"About 137\n // credits (up to 283)\", the measured figures scaled by the chosen model.\n const scaled = (range: AiCreditRange): AiCreditRange => ({\n likely: Math.round(range.likely * modelMultiplier),\n p90: Math.round(range.p90 * modelMultiplier),\n ceiling: Math.round(range.ceiling * modelMultiplier),\n })\n const estimate = freeTaste\n ? aiFreeSiteCreditRange(answers.pages, { siteKind })\n : scaled(aiSiteCreditRange(answers.pages, { welcomeEmail: answers.welcomeEmail, siteKind }))\n // A Free start quotes what is LEFT (AGL-3660), shared across the owner's\n // Free workspaces — never the month's whole allowance as if none were spent.\n const estimateText = freeTaste\n ? freeCredits\n ? `${aiCreditRangeText(estimate)}. You have ${freeCredits.left.toLocaleString('en-US')} of your ${freeCredits.total.toLocaleString('en-US')} free AI credits left this month, until ${aiFreeCreditsResetLabel(freeCredits.resetsOn)}`\n : `${aiCreditRangeText(estimate)}, of the ${FREE_AI_TASTE_CREDITS_PER_MONTH} AI credits you get free each month`\n : `${aiCreditRangeText(estimate)}, estimated`\n\n const choosing = step === 'choose' && !started\n\n return (\n <Dialog\n open\n fullScreen\n ref={dialogRef}\n onClose={dismiss}\n aria-labelledby={TITLE_ID}\n // The console's own page surface, in both modes. A Dialog's paper sits\n // at elevation 24 by default, and in dark mode MUI lightens an elevated\n // paper with a white overlay, which turned the whole takeover a\n // washed-out gray; the overlay is for floating surfaces, and this one\n // fills the screen, so its paper is flat.\n slotProps={{ paper: { elevation: 0, sx: AI_SITE_START_SURFACE_SX } }}\n >\n {/*\n The way out, before anything it is a way out of: a slim header on the\n paper surface. On a narrow screen it is the TITLE that gives way, so\n the exits keep their words at every width.\n */}\n <AppBar\n position=\"relative\"\n color=\"inherit\"\n elevation={0}\n enableColorOnDark\n sx={{ ...AI_SITE_START_SURFACE_SX, borderBottom: 1, borderColor: 'divider' }}\n >\n <Toolbar variant=\"dense\" sx={{ gap: 1 }}>\n <IconButton\n edge=\"start\"\n color=\"inherit\"\n onClick={() => dismiss()}\n aria-label=\"Close the guided start\"\n >\n <MdiIcon path={ICON_VARIANT_CLOSE.path} />\n </IconButton>\n <Typography\n id={TITLE_ID}\n variant=\"subtitle1\"\n component=\"div\"\n noWrap\n sx={{ textOverflow: 'ellipsis', flex: 1 }}\n >\n {'Start your site'}\n </Typography>\n <Button color=\"inherit\" onClick={exit} aria-label={started ? 'Close' : 'Skip and start blank'}>\n {started ? 'Close' : 'Skip'}\n </Button>\n </Toolbar>\n </AppBar>\n <DialogContent sx={{ px: { xs: 2, sm: 3 } }}>\n <Container maxWidth={choosing ? 'md' : 'sm'} disableGutters sx={{ py: { xs: 3, sm: 5 } }}>\n <Stack spacing={4}>\n <Stepper\n activeStep={choosing ? 0 : 1}\n aria-label={choosing ? 'Step 1 of 2' : 'Step 2 of 2'}\n sx={{ maxWidth: (theme: Theme) => theme.spacing(40), width: '100%', mx: 'auto' }}\n >\n {STEP_LABELS.map((label) => (\n <Step key={label}>\n <StepLabel>{label}</StepLabel>\n </Step>\n ))}\n </Stepper>\n <Stack spacing={1} sx={{ textAlign: choosing ? 'center' : 'left' }}>\n <Typography variant=\"h4\" component=\"h1\">\n {choosing ? 'How do you want to start?' : 'Tell us about your site'}\n </Typography>\n <Typography variant=\"body1\" color=\"text.secondary\">\n {choosing ? <HelpTip sx={{ float: 'right' }} {...START_HELP.choose} /> : null}\n {choosing\n ? creating\n ? 'Name your site, then choose how it starts. You can change everything later.'\n : 'You can change everything later.'\n : `A few answers and ${PLATFORM_BRAND_NAME} AI plans and writes your pages, then publishes your site.`}\n </Typography>\n </Stack>\n {notice && <Alert severity=\"info\">{notice}</Alert>}\n {step === 'describe' && !started && noneLeft && freeCredits && (\n <Alert\n severity=\"warning\"\n action={\n orgSlug ? (\n <Button color=\"inherit\" size=\"small\" href={aiCreditsBillingHref(orgSlug)}>\n {'Upgrade'}\n </Button>\n ) : undefined\n }\n >\n {aiFreeCreditsNoneLeftText(freeCredits.resetsOn)}\n </Alert>\n )}\n {step === 'describe' && !started && !noneLeft && prompt && (\n <AiCreditsPromptNotice\n prompt={prompt}\n noun=\"site\"\n orgSlug={orgSlug}\n busy={busy}\n onBuildWhatFits={() => void plan({ creditsConfirmed: true })}\n onSmaller={() => void plan({ creditsConfirmed: true, pages: 1 })}\n />\n )}\n {choosing && creating && pendingSite ? (\n <Stack spacing={2} component=\"section\" aria-label=\"Your site\">\n <SectionLabel>{'Your site'}</SectionLabel>\n {pendingSite.fields}\n </Stack>\n ) : null}\n {choosing ? (\n <Box\n sx={{\n display: 'grid',\n gridTemplateColumns: { xs: '1fr', sm: '1fr 1fr' },\n gap: 3,\n }}\n >\n <ChoiceCard\n accent=\"secondary\"\n icon={mdiPageLayoutHeaderFooter.path}\n iconId=\"page-layout-header-footer\"\n title=\"Start from the starter site\"\n description=\"A ready-made home page with a header, footer and contact form you can edit.\"\n busy={startingStarter}\n onChoose={chooseStarter}\n />\n <ChoiceCard\n accent=\"primary\"\n icon={mdiCreation.path}\n iconId=\"creation\"\n title=\"Start with AI\"\n description={`Answer a few questions and ${PLATFORM_BRAND_NAME} AI plans your pages.`}\n onChoose={chooseAi}\n >\n <Chip size=\"small\" color=\"primary\" label=\"Recommended\" />\n {freeTaste && (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Up to ${AI_SITE_FREE_PAGES.max} pages on the Free plan`}\n </Typography>\n )}\n </ChoiceCard>\n </Box>\n ) : started && orgId ? (\n <Card variant=\"outlined\" sx={{ borderRadius: 2, p: { xs: 2, sm: 3 } }}>\n <AiJobFollow\n job={started}\n orgId={orgId}\n orgSlug={orgSlug}\n user={user}\n intro={\n 'Your site is being planned. It is then built and published for you, with ' +\n 'nothing to approve. You can edit or unpublish it afterwards.'\n }\n // Full screen: AI jobs opens in the panel this dialog covers.\n onOpenJobs={exit}\n />\n </Card>\n ) : (\n <>\n <Stack spacing={2} component=\"section\" aria-label=\"Your business\">\n <SectionLabel help={START_HELP.business}>{'Your business'}</SectionLabel>\n <TextField\n fullWidth\n required\n label=\"What kind of site are you creating?\"\n placeholder=\"a neighborhood dog groomer that takes bookings\"\n value={answers.siteType}\n onChange={(event) => answer({ siteType: event.target.value })}\n helperText=\"A few words is enough, or pick one below.\"\n />\n <Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 1 }}>\n {AI_SITE_START_TYPES.map((type) => (\n <Chip\n key={type}\n label={type}\n size=\"small\"\n color={answers.siteType === type ? 'primary' : 'default'}\n variant={answers.siteType === type ? 'filled' : 'outlined'}\n onClick={() => answer({ siteType: type })}\n />\n ))}\n </Box>\n <TextField\n fullWidth\n label=\"Who is it for?\"\n placeholder=\"local dog owners who want a regular groom booked online\"\n value={answers.audience}\n onChange={(event) => answer({ audience: event.target.value })}\n helperText=\"Optional. It narrows who the pages are written for.\"\n />\n </Stack>\n <Stack spacing={2} component=\"section\" aria-label=\"Style\">\n <SectionLabel help={START_HELP.style}>{'Style'}</SectionLabel>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {answers.kind\n ? 'This decides how your site looks and which pages it usually has.'\n : 'Picked from your answer above. Choose another to change how your site looks and which pages it usually has.'}\n </Typography>\n <OptionCardGrid\n label=\"Style of site\"\n options={AI_SITE_KINDS.map((kind) => ({\n id: kind.id,\n title: kind.label,\n description: kind.blurb,\n icon: AI_SITE_KIND_ICONS[kind.id],\n }))}\n value={aiSiteStartKind(answers).id}\n onChange={(kind) => answer({ kind })}\n />\n </Stack>\n <Stack spacing={2} component=\"section\" aria-label=\"Details\">\n <SectionLabel help={START_HELP.details}>{'Details'}</SectionLabel>\n {/*\n The one setting a new site owner has to make, asked where\n they are already answering: a contact form nobody routed\n files its messages somewhere the person has not looked.\n */}\n <TextField\n select\n fullWidth\n label=\"Where do form submissions go?\"\n value={answers.submissions}\n onChange={(event) =>\n answer({ submissions: event.target.value as AiSiteSubmissions })\n }\n helperText=\"You can change this on the form itself afterwards.\"\n >\n {AI_SITE_SUBMISSION_CHOICES.map((option) => (\n <MenuItem key={option.id} value={option.id}>\n {`${option.label} — ${option.blurb}`}\n </MenuItem>\n ))}\n </TextField>\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>\n <TextField\n select\n fullWidth\n label=\"Pages\"\n value={answers.pages}\n onChange={(event) => answer({ pages: Number(event.target.value) })}\n helperText={freeTaste ? AI_SITE_FREE_PAGES_NOTE : undefined}\n >\n {Array.from(\n { length: band.max - band.min + 1 },\n (_, index) => band.min + index,\n ).map((count) => (\n <MenuItem key={count} value={count}>\n {count}\n </MenuItem>\n ))}\n </TextField>\n {!freeTaste && (\n <TextField\n select\n fullWidth\n label=\"Welcome email\"\n value={answers.welcomeEmail ? 'yes' : 'no'}\n onChange={(event) => answer({ welcomeEmail: event.target.value === 'yes' })}\n >\n <MenuItem value=\"yes\">{'Draft one'}</MenuItem>\n <MenuItem value=\"no\">{'No'}</MenuItem>\n </TextField>\n )}\n </Stack>\n </Stack>\n </>\n )}\n </Stack>\n </Container>\n </DialogContent>\n {step === 'describe' && !started && (\n /* The footer stays put while the questions scroll. It wraps, because\n the estimate, the reason and the buttons are wider than a phone. */\n <DialogActions\n sx={{\n px: { xs: 2, sm: 3 },\n py: 2,\n flexWrap: 'wrap',\n rowGap: 1,\n columnGap: 2,\n borderTop: 1,\n borderColor: 'divider',\n ...AI_SITE_START_SURFACE_SX,\n }}\n >\n <Stack direction=\"row\" spacing={0.5} sx={{ alignItems: 'center', mr: 'auto', minWidth: 0 }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`${estimateText}.`}\n </Typography>\n <HelpTip {...START_HELP.estimate} ariaLabel=\"How the estimate works\" />\n </Stack>\n {refusal && (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {refusal}\n </Typography>\n )}\n {!freeTaste && <AiModelSelector choice={modelChoice} disabled={busy} />}\n <Button onClick={() => setStep('choose')}>{'Back'}</Button>\n <Button\n variant=\"contained\"\n size=\"large\"\n disabled={busy || Boolean(refusal) || Boolean(prompt) || noneLeft}\n onClick={() => void plan()}\n startIcon={<MdiIcon path={mdiCreation.path} />}\n >\n {busy ? 'Starting…' : 'Plan my site'}\n </Button>\n </DialogActions>\n )}\n <Dialog\n open={confirmingLeave}\n onClose={() => setConfirmingLeave(false)}\n aria-labelledby={`${TITLE_ID}-leave`}\n aria-describedby={`${TITLE_ID}-leave-text`}\n maxWidth=\"xs\"\n >\n <DialogTitle id={`${TITLE_ID}-leave`}>{'Leave without your answers?'}</DialogTitle>\n <DialogContent>\n <DialogContentText id={`${TITLE_ID}-leave-text`}>\n {creating\n ? 'What you typed is not saved, and no site is created.'\n : 'What you typed is not saved. Leaving starts your site from the starter site instead.'}\n </DialogContentText>\n </DialogContent>\n <DialogActions>\n <Button color=\"inherit\" onClick={leaveDraft}>\n {creating ? 'Leave' : 'Leave and start blank'}\n </Button>\n <Button variant=\"contained\" autoFocus onClick={() => setConfirmingLeave(false)}>\n {'Keep editing'}\n </Button>\n </DialogActions>\n </Dialog>\n </Dialog>\n )\n}\n\nexport default AiSiteStartCard\n"],"names":["lockdownRefusalText","parseLockdownRefusal","PLATFORM_BRAND_NAME","trackEvent","ICON_VARIANT_CLOSE","mdiAccount","mdiBookOpenPageVariant","mdiBriefcaseOutline","mdiCalendarHeart","mdiCamera","mdiClockOutline","mdiContentCut","mdiCreation","mdiDumbbell","mdiHandHeart","mdiHeartPulse","mdiHomeCity","mdiMusic","mdiPaletteOutline","mdiRocketLaunch","mdiScaleBalance","mdiSchool","mdiShopping","mdiSilverwareForkKnife","mdiViewGridOutline","mdiWrench","mdiYoga","mdiPageLayoutHeaderFooter","pluginDocsHelp","HelpTip","MdiIcon","OptionCardGrid","authorizedFetch","useUser","Alert","AppBar","Box","Button","Card","CardActionArea","Chip","CircularProgress","Container","Dialog","DialogActions","DialogContent","DialogContentText","DialogTitle","IconButton","MenuItem","Stack","Step","StepLabel","Stepper","TextField","Toolbar","Typography","alpha","useRouter","useCallback","useEffect","useId","useRef","useState","AI_JOB_AUTO_CONFIRM_INPUT","AI_SITE_FREE_PAGES","AI_SITE_FREE_PAGES_NOTE","AI_SITE_SUBMISSION_CHOICES","aiFreeCreditsNoneLeftText","aiFreeCreditsResetLabel","aiFreeSiteCreditRange","aiFreeSitePrompt","aiSiteCreditRange","aiSitePagesBand","FREE_AI_TASTE_CREDITS_PER_MONTH","AI_CREDITS_CONFIRM_CODE","aiCreditRangeText","AiCreditsPromptNotice","AI_SITE_START_ANSWERS","AI_SITE_START_TYPES","aiSiteStartBrief","aiSiteStartKind","aiSiteStartInputs","aiSiteStartRefusal","AI_SITE_KINDS","aiSiteKindOfInputs","AI_SITE_KIND_ICONS","business","path","trades","professional","wellness","restaurant","store","portfolio","studio","photography","blog","events","fitness","yoga","beauty","realestate","education","nonprofit","music","personal","landing","AiJobFollow","AiModelSelector","useAiModelChoice","aiCreditsBillingHref","aiSiteBuildHref","publishAiJob","TITLE_ID","AI_SITE_START_SURFACE_SX","bgcolor","STEP_LABELS","IconBadge","accent","children","aria-hidden","sx","theme","width","spacing","height","borderRadius","display","alignItems","justifyContent","palette","main","mode","color","fontSize","ChoiceCard","icon","iconId","title","description","busy","onChoose","id","variant","transition","transitions","create","duration","shorter","borderColor","boxShadow","shadows","transform","onClick","disabled","aria-labelledby","aria-describedby","aria-busy","undefined","p","xs","sm","textAlign","size","aria-label","data-icon","component","START_HELP","choose","anchor","excerpt","style","details","estimate","SectionLabel","help","direction","AiSiteStartCard","hostId","orgId","orgSlug","host","startBlank","leave","pendingSite","initialAnswers","modelChoice","data","user","router","userRef","current","uid","verdict","setVerdict","reopened","step","setStep","answers","setAnswers","setBusy","startingStarter","setStartingStarter","notice","setNotice","started","setStarted","freeTaste","setFreeTaste","freeCredits","setFreeCredits","confirmingLeave","setConfirmingLeave","dialogRef","pendingRef","creating","Boolean","created","active","response","encodeURIComponent","payload","ok","json","catch","credits","Number","isFinite","left","pages","Math","min","max","welcomeEmail","shown","status","ready","answer","patch","serverPrompt","setServerPrompt","siteKind","prompt","noneLeft","refusal","band","surface","kind","load","loadModels","model","rememberedModel","pickedModel","plan","options","asked","creditsConfirmed","site","made","error","address","method","headers","body","JSON","stringify","brief","inputs","code","locked","String","job","href","push","runStartBlank","result","then","done","chooseStarter","check","choice","chooseAi","exit","dismissTo","drafted","siteType","trim","audience","dirty","dismiss","event","reason","target","root","Node","contains","leaveDraft","modelMultiplier","find","option","multiplier","scaled","range","likely","round","p90","ceiling","estimateText","toLocaleString","total","resetsOn","choosing","open","fullScreen","ref","onClose","slotProps","paper","elevation","position","enableColorOnDark","borderBottom","gap","edge","noWrap","textOverflow","flex","px","maxWidth","disableGutters","py","activeStep","mx","map","label","float","severity","action","noun","onBuildWhatFits","onSmaller","fields","gridTemplateColumns","intro","onOpenJobs","fullWidth","required","placeholder","value","onChange","helperText","flexWrap","type","blurb","select","submissions","Array","from","length","_","index","count","rowGap","columnGap","borderTop","mr","minWidth","ariaLabel","startIcon","autoFocus"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;AAEA,SAASA,mBAAmB,EAAEC,o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;gCAAO2G,SAAQ;gCAAYkO,SAAS;gCAACxN,SAAS,IAAM2D,mBAAmB;0CACrE;;;;;;;;AAMb;AAEA,eAAenC,gBAAe"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-site-start-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n'use client'\n\nimport { lockdownRefusalText, parseLockdownRefusal, PLATFORM_BRAND_NAME } from '@aglyn/aglyn'\nimport { trackEvent } from '@aglyn/aglyn/app-utils/analytics-events'\nimport type { ConsoleHostFirstRunZoneProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { ICON_VARIANT_CLOSE } from '@aglyn/shared-data-enums'\nimport {\n mdiAccount,\n mdiBookOpenPageVariant,\n mdiBriefcaseOutline,\n mdiCalendarHeart,\n mdiCamera,\n mdiClockOutline,\n mdiContentCut,\n mdiCreation,\n mdiDumbbell,\n mdiHandHeart,\n mdiHeartPulse,\n mdiHomeCity,\n mdiMusic,\n mdiPaletteOutline,\n mdiRocketLaunch,\n mdiScaleBalance,\n mdiSchool,\n mdiShopping,\n mdiSilverwareForkKnife,\n mdiViewGridOutline,\n mdiWrench,\n mdiYoga,\n mdiPageLayoutHeaderFooter,\n} from '@aglyn/shared-data-mdi'\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport { HelpTip, MdiIcon } from '@aglyn/shared-ui-jsx'\nimport { OptionCardGrid } from '@aglyn/shared-ui-jsx/components/option-card-grid.component'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n AppBar,\n Box,\n Button,\n Card,\n CardActionArea,\n Chip,\n CircularProgress,\n Container,\n Dialog,\n DialogActions,\n DialogContent,\n DialogContentText,\n DialogTitle,\n IconButton,\n MenuItem,\n Stack,\n Step,\n StepLabel,\n Stepper,\n TextField,\n Toolbar,\n Typography,\n} from '@mui/material'\nimport { alpha, type Theme } from '@mui/material/styles'\nimport { useRouter } from 'next/navigation'\nimport {\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n type ReactNode,\n type SyntheticEvent,\n} from 'react'\nimport {\n AI_JOB_AUTO_CONFIRM_INPUT,\n AI_SITE_FREE_PAGES,\n AI_SITE_FREE_PAGES_NOTE,\n AI_SITE_SUBMISSION_CHOICES,\n aiFreeCreditsNoneLeftText,\n aiFreeCreditsResetLabel,\n aiFreeSiteCreditRange,\n aiFreeSitePrompt,\n aiSiteCreditRange,\n type AiFreeCreditsLeft,\n aiSitePagesBand,\n type AiSiteSubmissions,\n} from '../model/ai-site-job'\nimport { FREE_AI_TASTE_CREDITS_PER_MONTH } from '../plan-entitlements'\nimport {\n AI_CREDITS_CONFIRM_CODE,\n aiCreditRangeText,\n type AiCreditRange,\n type AiCreditsPrompt,\n} from '../model/ai-credit-estimate'\nimport { AiCreditsPromptNotice } from './ai-credits-prompt.component'\nimport {\n AI_SITE_START_ANSWERS,\n AI_SITE_START_TYPES,\n aiSiteStartBrief,\n aiSiteStartKind,\n aiSiteStartInputs,\n aiSiteStartRefusal,\n type AiSiteStartAnswers,\n} from '../model/ai-site-start'\nimport type { AiJobSummary } from '../model/ai-jobs.types'\nimport { AI_SITE_KINDS, aiSiteKindOfInputs } from '../model/ai-site-kinds'\n\n/** The icon each kind of site's card shows. */\nconst AI_SITE_KIND_ICONS: Record<string, string> = {\n business: mdiBriefcaseOutline.path,\n trades: mdiWrench.path,\n professional: mdiScaleBalance.path,\n wellness: mdiHeartPulse.path,\n restaurant: mdiSilverwareForkKnife.path,\n store: mdiShopping.path,\n portfolio: mdiViewGridOutline.path,\n studio: mdiPaletteOutline.path,\n photography: mdiCamera.path,\n blog: mdiBookOpenPageVariant.path,\n events: mdiCalendarHeart.path,\n fitness: mdiDumbbell.path,\n yoga: mdiYoga.path,\n beauty: mdiContentCut.path,\n realestate: mdiHomeCity.path,\n education: mdiSchool.path,\n nonprofit: mdiHandHeart.path,\n music: mdiMusic.path,\n personal: mdiAccount.path,\n landing: mdiRocketLaunch.path,\n 'coming-soon': mdiClockOutline.path,\n}\nimport { AiJobFollow } from './ai-job-follow.component'\nimport { AiModelSelector } from './ai-model-selector.component'\nimport { useAiModelChoice } from './use-ai-model-choice'\nimport { aiCreditsBillingHref, aiSiteBuildHref } from './ai-job-links'\nimport { publishAiJob } from './ai-jobs-store'\n\n/**\n * The guided start (AGL-2918), on the `hostFirstRun` zone of the page a newly\n * created site lands on: a choice, a few questions, and the site scaffold they\n * become.\n *\n * ── Two steps (AGL-3594) ─────────────────────────────────────────────────\n *\n * Step 1 asks how to start, as two equal cards: the starter site — a\n * ready-made home page with a header and footer — or AI. The starter card is\n * the zone's `startBlank`, which gives a site born for the guided start the\n * starter every other new site is born with. The AI card moves to step 2, the\n * questions, which have a Back to step 1.\n *\n * ── A full screen dialog, and therefore three ways out ───────────────────\n *\n * The questions take the whole screen, which is the only presentation that\n * gets them read — but a surface that takes the screen and cannot be left is\n * a funnel, so leaving is drawn first and works three ways on both steps:\n *\n * - the close control at the start of the header,\n * - \"Skip\" at the end of it, named \"Skip and start blank\",\n * - Escape, which `Dialog` reports through `onClose`.\n *\n * Before a job is started all three are the zone's own `startBlank`: the\n * starter site, and no job, no draft, no record of a site half begun. After,\n * they close through `leave`, and the job builds the site.\n *\n * ── Or before the site exists (AGL-3761) ─────────────────────────────────\n *\n * \"Create site\" draws this straight away, with the zone's `pendingSite` and\n * no site. Step 1 then asks the site's name and address (the shell's own\n * fields) above the two cards, and the site is created only by a choice that\n * needs one: the starter card or Skip (`startBlank`, which creates it with the\n * starter), or Plan my site, which creates it and then starts the job on it.\n * The close control and Escape create nothing there: they are `leave`. If the\n * site was created and its job could not start, the site is a real one, and\n * every way out gives it the starter as above, so none is left empty.\n *\n * Escape and the close control are DISMISSALS, though, and Skip is a choice\n * (AGL-3660, 2026-10-08). Once anything is typed or picked, a dismissal asks\n * \"Leave without your answers?\" first, focused on Keep editing, so a stray\n * Escape — the second press after closing the model menu was the one in\n * production — can never trade a brief for the starter. Escape that reached\n * the dialog from a portal it does not contain (a menu, a select's list) is\n * that popup's, and the dialog ignores it.\n *\n * The header is the dialog's own chrome rather than part of its body, so the\n * way out cannot be scrolled off, and it is never disabled — least of all\n * while a request is in flight, which is the moment a person most wants it.\n * Nothing is focused ahead of the dialog's own frame, so the first thing a\n * keyboard reaches is the close control.\n *\n * ── It is absent until the route has answered ────────────────────────────\n *\n * The dialog covers the page, so being drawn on a guess is worse here than it\n * is for a card: it would be a takeover every flag-off workspace watches\n * disappear. Nothing renders at all — no `Dialog`, no portal — until the jobs\n * route has admitted this workspace, and a 404, a 403 or an unreachable route\n * is this widget staying absent and the ordinary blank page being all there\n * is. That the widget is mounted is itself the last of a stack of gates: the\n * shell held the plan's `aiGenerative` entitlement, the site's AI switch and\n * the reader's `ai.generate` first. A lockdown is the start door's to say,\n * here, in its own words.\n *\n * ── It builds and publishes for you ──────────────────────────────────────\n *\n * \"Plan my site\" starts a `site` job, which PLANS first: the pages, their\n * addresses, the navigation, the layout, the contact form and a palette. The\n * guided start confirms its own plan (AGL-3594), so the build follows with no\n * approval to make, and the site is published, indexable, when it is done.\n * The person edits or unpublishes it afterwards.\n *\n * ── It stays with the job (AGL-3593) ─────────────────────────────────────\n *\n * Once the job exists the dialog follows it live — planning, the plan with\n * its Confirm, building, then the draft pages to open — so a person never has\n * to leave it to get their site built. \"Open AI jobs\" follows the job in the\n * Assist panel instead; it leaves the guided start the way every other exit\n * does, because the dialog covers the panel it opens.\n */\n\ntype Verdict = 'checking' | 'ready' | 'hidden'\n\ntype Step = 'choose' | 'describe'\n\n/** Labels the dialog for a reader, from its own heading. */\nconst TITLE_ID = 'ai-site-start-title'\n\n/**\n * The takeover's surface, for its paper, its bar and its footer alike: the\n * console page's own background (AGL-3596). The paper sits at elevation 0,\n * which is what keeps MUI's dark-mode elevation overlay off it.\n */\nexport const AI_SITE_START_SURFACE_SX = { bgcolor: 'background.default' } as const\n\n/** The two steps, as the indicator under the header names them. */\nconst STEP_LABELS = ['Choose', 'Describe'] as const\n\n/** The soft round badge an icon sits in, in its accent's tint. */\nfunction IconBadge({ accent, children }: { accent: 'primary' | 'secondary'; children: ReactNode }) {\n return (\n <Box\n aria-hidden\n sx={(theme: Theme) => ({\n width: theme.spacing(9),\n height: theme.spacing(9),\n borderRadius: '50%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n bgcolor: alpha(theme.palette[accent].main, theme.palette.mode === 'dark' ? 0.24 : 0.12),\n color: `${accent}.main`,\n fontSize: theme.spacing(5.5),\n })}\n >\n {children}\n </Box>\n )\n}\n\n/**\n * One way to start, as a card the whole of which is the button. Its accessible\n * name is its title; its description describes it.\n */\nfunction ChoiceCard({\n accent,\n icon,\n iconId,\n title,\n description,\n busy = false,\n onChoose,\n children,\n}: {\n accent: 'primary' | 'secondary'\n icon: string\n /** Names the icon for a reader of the markup; the icon itself is decorative. */\n iconId: string\n title: string\n description: string\n busy?: boolean\n onChoose: () => void\n children?: ReactNode\n}) {\n const id = useId()\n return (\n <Card\n variant=\"outlined\"\n sx={(theme: Theme) => ({\n borderRadius: 2,\n height: '100%',\n transition: theme.transitions.create(['border-color', 'box-shadow', 'transform'], {\n duration: theme.transitions.duration.shorter,\n }),\n '&:hover, &:focus-within': {\n borderColor: `${accent}.main`,\n boxShadow: theme.shadows[4],\n transform: `translateY(-${theme.spacing(0.25)})`,\n },\n '@media (prefers-reduced-motion: reduce)': {\n transition: 'none',\n '&:hover, &:focus-within': { transform: 'none' },\n },\n })}\n >\n <CardActionArea\n onClick={onChoose}\n disabled={busy}\n aria-labelledby={`${id}-title`}\n aria-describedby={`${id}-description`}\n aria-busy={busy || undefined}\n sx={{ height: '100%', p: { xs: 3, sm: 4 } }}\n >\n <Stack spacing={2} sx={{ alignItems: 'center', textAlign: 'center' }}>\n <IconBadge accent={accent}>\n {busy ? (\n <CircularProgress size=\"1em\" color={accent} aria-label={`${title}…`} />\n ) : (\n <MdiIcon path={icon} data-icon={iconId} aria-hidden />\n )}\n </IconBadge>\n <Typography id={`${id}-title`} variant=\"h6\" component=\"h2\">\n {title}\n </Typography>\n <Typography id={`${id}-description`} variant=\"body2\" color=\"text.secondary\">\n {description}\n </Typography>\n {children}\n </Stack>\n </CardActionArea>\n </Card>\n )\n}\n\n/** A small label above a group of questions. */\n/**\n * Each part of the guided start links its own section of the Start with AI\n * guide (AGL-3660), so a `?` says what that one group of answers changes.\n */\nconst START_HELP = {\n choose: pluginDocsHelp('aiStart', {\n anchor: '#how-do-you-want-to-start',\n excerpt:\n 'The starter site gives you a ready-made home page to edit. Start with AI asks a few questions, then plans, writes and publishes your pages.',\n }),\n business: pluginDocsHelp('aiStart', {\n anchor: '#your-business',\n excerpt:\n 'What kind of site it is picks its style and pages; who it is for is who every page and the contact form are written for.',\n }),\n style: pluginDocsHelp('aiSiteLooks', {\n anchor: '#choose-a-style',\n excerpt:\n 'The style decides the look — theme, colors, fonts, buttons — and which pages the site usually has. Every site gets its own variation.',\n }),\n details: pluginDocsHelp('aiStart', {\n anchor: '#details',\n excerpt:\n 'Where contact form messages go, how many pages to write, and on paid plans whether to draft a welcome email. All can be changed later.',\n }),\n estimate: pluginDocsHelp('aiCredits', {\n anchor: '#before-a-job-starts',\n excerpt:\n 'About what a start like this costs, measured on real builds, and the most it can cost. What it really costs is what each step spends, and you can watch that add up while it runs.',\n }),\n}\n\nfunction SectionLabel({ children, help }: { children: ReactNode; help?: ReturnType<typeof pluginDocsHelp> }) {\n return (\n <Stack direction=\"row\" spacing={0.5} sx={{ alignItems: 'center' }}>\n <Typography variant=\"overline\" color=\"text.secondary\" component=\"h2\" sx={{ display: 'block' }}>\n {children}\n </Typography>\n {help ? <HelpTip {...help} /> : null}\n </Stack>\n )\n}\n\n/**\n * The guided start, as the `hostFirstRun` zone draws it, or reopened on a\n * failed start's own answers (AGL-3596): `initialAnswers` opens it on the\n * questions, filled in, for the person to adjust and start a fresh job.\n */\nexport type AiSiteStartCardProps = ConsoleHostFirstRunZoneProps & {\n initialAnswers?: AiSiteStartAnswers | null\n}\n\nexport function AiSiteStartCard({\n hostId,\n orgId,\n orgSlug,\n host,\n startBlank,\n leave,\n pendingSite,\n initialAnswers = null,\n}: AiSiteStartCardProps) {\n const { data: user } = useUser()\n const router = useRouter()\n // Held in a ref so a request reads WHO is signed in, never the identity of\n // the object that says so.\n const userRef = useRef(user)\n userRef.current = user\n const uid = user?.uid ?? null\n const [verdict, setVerdict] = useState<Verdict>('checking')\n // Read once: a start reopened on its answers stays one while it is open.\n const reopened = useRef(initialAnswers !== null)\n const [step, setStep] = useState<Step>(initialAnswers ? 'describe' : 'choose')\n const [answers, setAnswers] = useState<AiSiteStartAnswers>(initialAnswers ?? AI_SITE_START_ANSWERS)\n const [busy, setBusy] = useState(false)\n // The starter card's own busy state while `startBlank` runs (AGL-3594).\n const [startingStarter, setStartingStarter] = useState(false)\n const [notice, setNotice] = useState<string | null>(null)\n /** The site job \"Plan my site\" started, as the create door answered with it. */\n const [started, setStarted] = useState<AiJobSummary | null>(null)\n // The Free taste's page band (AGL-3594), read off the verdict request.\n const [freeTaste, setFreeTaste] = useState(false)\n // What the Free workspace has left this month (AGL-3660), as the same read\n // the create door refuses on: the less of its own band and its owner's\n // allowance across their Free workspaces. `null` when the route said none.\n const [freeCredits, setFreeCredits] = useState<AiFreeCreditsLeft | null>(null)\n // \"Leave without your answers?\" (AGL-3660): a dismissal with a brief typed.\n const [confirmingLeave, setConfirmingLeave] = useState(false)\n // The dialog's own root, to tell its Escape from a nested popup's.\n const dialogRef = useRef<HTMLDivElement | null>(null)\n // Drawn by \"Create site\" before the site exists (AGL-3761): the shell's\n // name and address are asked on step 1, and the site is created only by\n // the starter, Skip, or Plan my site. Read through a ref by the verdict\n // below, which must not re-run when the shell re-renders it.\n const pendingRef = useRef(pendingSite)\n pendingRef.current = pendingSite\n const creating = Boolean(pendingSite) && !pendingSite?.created\n\n useEffect(() => {\n if (!orgId || !uid) return\n let active = true\n void (async () => {\n try {\n const response = await authorizedFetch(\n userRef.current,\n `/api/ai/jobs?orgId=${encodeURIComponent(orgId)}&limit=1`,\n )\n const payload = response.ok ? await response.json().catch(() => null) : null\n if (active) {\n if (payload?.freeTaste === true) {\n setFreeTaste(true)\n const credits = payload?.freeCredits as AiFreeCreditsLeft | undefined\n if (credits && Number.isFinite(credits.left)) setFreeCredits(credits)\n // A reopened start keeps the pages it asked for, within the band.\n setAnswers((current) => ({\n ...current,\n pages: reopened.current ? Math.min(current.pages, AI_SITE_FREE_PAGES.max) : AI_SITE_FREE_PAGES.max,\n welcomeEmail: false,\n }))\n }\n const shown = response.status !== 404 && response.status !== 403\n setVerdict(shown ? 'ready' : 'hidden')\n // \"Create site\" shows its own dialog when this one will not draw.\n pendingRef.current?.ready(shown)\n }\n } catch {\n if (active) {\n setVerdict('hidden')\n pendingRef.current?.ready(false)\n }\n }\n })()\n return () => {\n active = false\n }\n }, [orgId, uid])\n\n const answer = useCallback(\n (patch: Partial<AiSiteStartAnswers>) =>\n setAnswers((current) => ({ ...current, ...patch })),\n [],\n )\n\n // A Free start past what is left asks first (AGL-3722): it is admitted on\n // its measured p90, and one past what is left starts only on \"Build what\n // fits\" (pausing with Resume where the credits run out), or smaller as the\n // home page alone. The create door asks the same, so a stale dialog meets\n // the prompt there too (`serverPrompt`). Nothing at all left is a dead\n // stop until the credits renew or the workspace upgrades.\n const [serverPrompt, setServerPrompt] = useState<AiCreditsPrompt | null>(null)\n // The door's prompt was for the pages it was asked with.\n useEffect(() => setServerPrompt(null), [answers.pages])\n // A store's first products and a blog's first posts are part of the start (AGL-3676, AGL-3798).\n const siteKind = aiSiteKindOfInputs(aiSiteStartInputs(answers))?.id ?? null\n const prompt = freeTaste ? (aiFreeSitePrompt(freeCredits, answers.pages, { siteKind }) ?? serverPrompt) : null\n const noneLeft = freeTaste && freeCredits !== null && freeCredits.left <= 0\n const refusal = aiSiteStartRefusal(answers, { freeTaste })\n const band = aiSitePagesBand(freeTaste)\n // On a paid plan the person picks the model that builds the site (AGL-3660),\n // Auto by default, from the models their plan allows; every step of the job\n // runs on it. A Free workspace builds on the default and is offered none.\n const modelChoice = useAiModelChoice({ orgId, hostId, surface: 'jobs', kind: 'job.page' })\n // A pick remembered from before needs its cost to estimate by; Auto does not,\n // and the list is otherwise read when the picker opens.\n const { load: loadModels, model: rememberedModel } = modelChoice\n useEffect(() => {\n if (!freeTaste && step === 'describe' && rememberedModel) loadModels()\n }, [freeTaste, step, rememberedModel, loadModels])\n const pickedModel = freeTaste ? null : modelChoice.model\n\n const plan = useCallback(async (options: { creditsConfirmed?: boolean; pages?: number } = {}) => {\n const asked = options.pages ? { ...answers, pages: options.pages } : answers\n if (!orgId || aiSiteStartRefusal(asked, { freeTaste }) || noneLeft) return\n // Past what is left, only an explicit go-ahead starts it.\n if (freeTaste && !options.creditsConfirmed && aiFreeSitePrompt(freeCredits, asked.pages, { siteKind })) return\n if (options.pages) answer({ pages: options.pages })\n setBusy(true)\n setNotice(null)\n setServerPrompt(null)\n try {\n const requestJob = (siteId: string | null, check: boolean) =>\n authorizedFetch(userRef.current, '/api/ai/jobs', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n orgId,\n hostId: siteId,\n kind: 'site',\n brief: aiSiteStartBrief(asked),\n // The guided start confirms its own plan (AGL-3594): the build\n // follows the plan with no approval to make.\n inputs: { ...aiSiteStartInputs(asked), [AI_JOB_AUTO_CONFIRM_INPUT]: true },\n ...(pickedModel ? { model: pickedModel } : {}),\n ...(options.creditsConfirmed ? { creditsConfirmed: true } : {}),\n ...(check ? { check: true } : {}),\n }),\n })\n // A refusal said in the dialog, or the Free go-ahead it asks for.\n const refused = async (response: Response): Promise<unknown> => {\n const payload = await response.json().catch(() => null)\n if (response.ok) return payload ?? {}\n if (response.status === 409 && payload?.code === AI_CREDITS_CONFIRM_CODE && payload?.credits) {\n setServerPrompt(payload.credits as AiCreditsPrompt)\n return null\n }\n const locked = parseLockdownRefusal(response.status, payload)\n setNotice(\n locked\n ? lockdownRefusalText(locked)\n : String(payload?.error ?? 'The site could not be started. Try again.'),\n )\n return null\n }\n // The site, created now when it does not exist yet (AGL-3761): this is\n // the moment the person asked for it. The start is checked first\n // (AGL-3859), so one the jobs route would refuse, or would ask the Free\n // go-ahead for, is answered before any site exists. A refusal about the\n // name or address goes back to step 1, where they are typed.\n let site = { hostId, host, orgSlug }\n if (!hostId && pendingSite) {\n if (!pendingSite.created && !(await refused(await requestJob(null, true)))) return\n const made = await pendingSite.create()\n if ('error' in made) {\n setNotice(made.error)\n if (made.address) setStep('choose')\n return\n }\n site = { hostId: made.hostId, host: made.host, orgSlug: made.orgSlug || orgSlug }\n }\n if (!site.hostId) return\n const payload = (await refused(await requestJob(site.hostId, false))) as { job?: AiJobSummary } | null\n if (!payload) return\n const created = (payload?.job as AiJobSummary | undefined) ?? null\n if (!created) {\n setNotice('The site could not be started. Try again.')\n return\n }\n // The indicator and the launcher count it from the moment it exists.\n publishAiJob(created)\n // Where the next step is (AGL-3594): the site's \"Building your site\"\n // page for this job. The zone closes without the starter first, so the\n // setup page does not ask again behind it.\n const href = aiSiteBuildHref(site.orgSlug, site.host, created.id)\n if (href) {\n ;(leave ?? (() => undefined))()\n router.push(href)\n return\n }\n setStarted(created)\n } catch {\n setNotice('The site could not be started. Try again.')\n } finally {\n setBusy(false)\n }\n }, [orgId, hostId, answers, answer, freeTaste, freeCredits, noneLeft, orgSlug, host, leave, router, pickedModel, pendingSite, siteKind])\n\n // The zone's `startBlank`. Before the site exists it creates it with the\n // starter, and answers `false` when it could not — most often a name or\n // address to fix, which step 1 shows.\n const runStartBlank = useCallback(() => {\n const result = startBlank()\n if (result && typeof result.then === 'function') {\n void result.then((done) => {\n if (done) return\n setStartingStarter(false)\n setStep('choose')\n })\n }\n }, [startBlank])\n\n const chooseStarter = useCallback(() => {\n if (pendingSite && !pendingSite.created && !pendingSite.check()) return\n setStartingStarter(true)\n trackEvent('site_start_choice', { choice: 'starter' })\n runStartBlank()\n }, [pendingSite, runStartBlank])\n\n const chooseAi = useCallback(() => {\n if (pendingSite && !pendingSite.created && !pendingSite.check()) return\n trackEvent('site_start_choice', { choice: 'ai' })\n setStep('describe')\n }, [pendingSite])\n\n if (verdict !== 'ready') return null\n\n // Before a job is started Skip is the blank site, which writes the starter\n // (AGL-3594); after, it only closes — the job builds the site.\n const exit = started ? (leave ?? runStartBlank) : runStartBlank\n // Escape and the close control. Before \"Create site\" has made the site\n // (AGL-3761) there is nothing to give a starter to, so they only close,\n // and nothing is created; otherwise they are the same way out as Skip.\n const dismissTo = creating && !started ? (leave ?? runStartBlank) : exit\n // Anything the person typed or picked, which a dismissal must not discard\n // silently (AGL-3660). After a job starts there is nothing left to lose.\n const drafted =\n !started &&\n Boolean(\n answers.siteType.trim() ||\n answers.audience.trim() ||\n answers.kind !== null ||\n (creating && pendingSite?.dirty),\n )\n // Escape and the close control: a dismissal, never a choice. Escape that\n // bubbled here through React from a portal outside this dialog's own DOM is\n // a nested menu's, already handled there, and is not this dialog's to act on.\n const dismiss = (event?: SyntheticEvent | object, reason?: string) => {\n if (reason === 'escapeKeyDown') {\n const target = (event as SyntheticEvent | undefined)?.target\n const root = dialogRef.current\n if (root && target instanceof Node && !root.contains(target)) return\n }\n if (drafted) setConfirmingLeave(true)\n else dismissTo()\n }\n const leaveDraft = () => {\n setConfirmingLeave(false)\n dismissTo()\n }\n\n // The chosen model's cost against Auto's, as the model list states it.\n const modelMultiplier =\n (pickedModel && modelChoice.options?.options.find((option) => option.id === pickedModel)?.multiplier) || 1\n // What the start is likely to cost and at most (AGL-3722): \"About 137\n // credits (up to 283)\", the measured figures scaled by the chosen model.\n const scaled = (range: AiCreditRange): AiCreditRange => ({\n likely: Math.round(range.likely * modelMultiplier),\n p90: Math.round(range.p90 * modelMultiplier),\n ceiling: Math.round(range.ceiling * modelMultiplier),\n })\n const estimate = freeTaste\n ? aiFreeSiteCreditRange(answers.pages, { siteKind })\n : scaled(aiSiteCreditRange(answers.pages, { welcomeEmail: answers.welcomeEmail, siteKind }))\n // A Free start quotes what is LEFT (AGL-3660), shared across the owner's\n // Free workspaces — never the month's whole allowance as if none were spent.\n const estimateText = freeTaste\n ? freeCredits\n ? `${aiCreditRangeText(estimate)}. You have ${freeCredits.left.toLocaleString('en-US')} of your ${freeCredits.total.toLocaleString('en-US')} free AI credits left this month, until ${aiFreeCreditsResetLabel(freeCredits.resetsOn)}`\n : `${aiCreditRangeText(estimate)}, of the ${FREE_AI_TASTE_CREDITS_PER_MONTH} AI credits you get free each month`\n : `${aiCreditRangeText(estimate)}, estimated`\n\n const choosing = step === 'choose' && !started\n\n return (\n <Dialog\n open\n fullScreen\n ref={dialogRef}\n onClose={dismiss}\n aria-labelledby={TITLE_ID}\n // The console's own page surface, in both modes. A Dialog's paper sits\n // at elevation 24 by default, and in dark mode MUI lightens an elevated\n // paper with a white overlay, which turned the whole takeover a\n // washed-out gray; the overlay is for floating surfaces, and this one\n // fills the screen, so its paper is flat.\n slotProps={{ paper: { elevation: 0, sx: AI_SITE_START_SURFACE_SX } }}\n >\n {/*\n The way out, before anything it is a way out of: a slim header on the\n paper surface. On a narrow screen it is the TITLE that gives way, so\n the exits keep their words at every width.\n */}\n <AppBar\n position=\"relative\"\n color=\"inherit\"\n elevation={0}\n enableColorOnDark\n sx={{ ...AI_SITE_START_SURFACE_SX, borderBottom: 1, borderColor: 'divider' }}\n >\n <Toolbar variant=\"dense\" sx={{ gap: 1 }}>\n <IconButton\n edge=\"start\"\n color=\"inherit\"\n onClick={() => dismiss()}\n aria-label=\"Close the guided start\"\n >\n <MdiIcon path={ICON_VARIANT_CLOSE.path} />\n </IconButton>\n <Typography\n id={TITLE_ID}\n variant=\"subtitle1\"\n component=\"div\"\n noWrap\n sx={{ textOverflow: 'ellipsis', flex: 1 }}\n >\n {'Start your site'}\n </Typography>\n <Button color=\"inherit\" onClick={exit} aria-label={started ? 'Close' : 'Skip and start blank'}>\n {started ? 'Close' : 'Skip'}\n </Button>\n </Toolbar>\n </AppBar>\n <DialogContent sx={{ px: { xs: 2, sm: 3 } }}>\n <Container maxWidth={choosing ? 'md' : 'sm'} disableGutters sx={{ py: { xs: 3, sm: 5 } }}>\n <Stack spacing={4}>\n <Stepper\n activeStep={choosing ? 0 : 1}\n aria-label={choosing ? 'Step 1 of 2' : 'Step 2 of 2'}\n sx={{ maxWidth: (theme: Theme) => theme.spacing(40), width: '100%', mx: 'auto' }}\n >\n {STEP_LABELS.map((label) => (\n <Step key={label}>\n <StepLabel>{label}</StepLabel>\n </Step>\n ))}\n </Stepper>\n <Stack spacing={1} sx={{ textAlign: choosing ? 'center' : 'left' }}>\n <Typography variant=\"h4\" component=\"h1\">\n {choosing ? 'How do you want to start?' : 'Tell us about your site'}\n </Typography>\n <Typography variant=\"body1\" color=\"text.secondary\">\n {choosing ? <HelpTip sx={{ float: 'right' }} {...START_HELP.choose} /> : null}\n {choosing\n ? creating\n ? 'Name your site, then choose how it starts. You can change everything later.'\n : 'You can change everything later.'\n : `A few answers and ${PLATFORM_BRAND_NAME} AI plans and writes your pages, then publishes your site.`}\n </Typography>\n </Stack>\n {notice && <Alert severity=\"info\">{notice}</Alert>}\n {step === 'describe' && !started && noneLeft && freeCredits && (\n <Alert\n severity=\"warning\"\n action={\n orgSlug ? (\n <Button color=\"inherit\" size=\"small\" href={aiCreditsBillingHref(orgSlug)}>\n {'Upgrade'}\n </Button>\n ) : undefined\n }\n >\n {aiFreeCreditsNoneLeftText(freeCredits.resetsOn)}\n </Alert>\n )}\n {step === 'describe' && !started && !noneLeft && prompt && (\n <AiCreditsPromptNotice\n prompt={prompt}\n noun=\"site\"\n orgSlug={orgSlug}\n busy={busy}\n onBuildWhatFits={() => void plan({ creditsConfirmed: true })}\n onSmaller={() => void plan({ creditsConfirmed: true, pages: 1 })}\n />\n )}\n {choosing && creating && pendingSite ? (\n <Stack spacing={2} component=\"section\" aria-label=\"Your site\">\n <SectionLabel>{'Your site'}</SectionLabel>\n {pendingSite.fields}\n </Stack>\n ) : null}\n {choosing ? (\n <Box\n sx={{\n display: 'grid',\n gridTemplateColumns: { xs: '1fr', sm: '1fr 1fr' },\n gap: 3,\n }}\n >\n <ChoiceCard\n accent=\"secondary\"\n icon={mdiPageLayoutHeaderFooter.path}\n iconId=\"page-layout-header-footer\"\n title=\"Start from the starter site\"\n description=\"A ready-made home page with a header, footer and contact form you can edit.\"\n busy={startingStarter}\n onChoose={chooseStarter}\n />\n <ChoiceCard\n accent=\"primary\"\n icon={mdiCreation.path}\n iconId=\"creation\"\n title=\"Start with AI\"\n description={`Answer a few questions and ${PLATFORM_BRAND_NAME} AI plans your pages.`}\n onChoose={chooseAi}\n >\n <Chip size=\"small\" color=\"primary\" label=\"Recommended\" />\n {freeTaste && (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Up to ${AI_SITE_FREE_PAGES.max} pages on the Free plan`}\n </Typography>\n )}\n </ChoiceCard>\n </Box>\n ) : started && orgId ? (\n <Card variant=\"outlined\" sx={{ borderRadius: 2, p: { xs: 2, sm: 3 } }}>\n <AiJobFollow\n job={started}\n orgId={orgId}\n orgSlug={orgSlug}\n user={user}\n intro={\n 'Your site is being planned. It is then built and published for you, with ' +\n 'nothing to approve. You can edit or unpublish it afterwards.'\n }\n // Full screen: AI jobs opens in the panel this dialog covers.\n onOpenJobs={exit}\n />\n </Card>\n ) : (\n <>\n <Stack spacing={2} component=\"section\" aria-label=\"Your business\">\n <SectionLabel help={START_HELP.business}>{'Your business'}</SectionLabel>\n <TextField\n fullWidth\n required\n label=\"What kind of site are you creating?\"\n placeholder=\"a neighborhood dog groomer that takes bookings\"\n value={answers.siteType}\n onChange={(event) => answer({ siteType: event.target.value })}\n helperText=\"A few words is enough, or pick one below.\"\n />\n <Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 1 }}>\n {AI_SITE_START_TYPES.map((type) => (\n <Chip\n key={type}\n label={type}\n size=\"small\"\n color={answers.siteType === type ? 'primary' : 'default'}\n variant={answers.siteType === type ? 'filled' : 'outlined'}\n onClick={() => answer({ siteType: type })}\n />\n ))}\n </Box>\n <TextField\n fullWidth\n label=\"Who is it for?\"\n placeholder=\"local dog owners who want a regular groom booked online\"\n value={answers.audience}\n onChange={(event) => answer({ audience: event.target.value })}\n helperText=\"Optional. It narrows who the pages are written for.\"\n />\n </Stack>\n <Stack spacing={2} component=\"section\" aria-label=\"Style\">\n <SectionLabel help={START_HELP.style}>{'Style'}</SectionLabel>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {answers.kind\n ? 'This decides how your site looks and which pages it usually has.'\n : 'Picked from your answer above. Choose another to change how your site looks and which pages it usually has.'}\n </Typography>\n <OptionCardGrid\n label=\"Style of site\"\n options={AI_SITE_KINDS.map((kind) => ({\n id: kind.id,\n title: kind.label,\n description: kind.blurb,\n icon: AI_SITE_KIND_ICONS[kind.id],\n }))}\n value={aiSiteStartKind(answers).id}\n onChange={(kind) => answer({ kind })}\n />\n </Stack>\n <Stack spacing={2} component=\"section\" aria-label=\"Details\">\n <SectionLabel help={START_HELP.details}>{'Details'}</SectionLabel>\n {/*\n The one setting a new site owner has to make, asked where\n they are already answering: a contact form nobody routed\n files its messages somewhere the person has not looked.\n */}\n <TextField\n select\n fullWidth\n label=\"Where do form submissions go?\"\n value={answers.submissions}\n onChange={(event) =>\n answer({ submissions: event.target.value as AiSiteSubmissions })\n }\n helperText=\"You can change this on the form itself afterwards.\"\n >\n {AI_SITE_SUBMISSION_CHOICES.map((option) => (\n <MenuItem key={option.id} value={option.id}>\n {`${option.label} — ${option.blurb}`}\n </MenuItem>\n ))}\n </TextField>\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>\n <TextField\n select\n fullWidth\n label=\"Pages\"\n value={answers.pages}\n onChange={(event) => answer({ pages: Number(event.target.value) })}\n helperText={freeTaste ? AI_SITE_FREE_PAGES_NOTE : undefined}\n >\n {Array.from(\n { length: band.max - band.min + 1 },\n (_, index) => band.min + index,\n ).map((count) => (\n <MenuItem key={count} value={count}>\n {count}\n </MenuItem>\n ))}\n </TextField>\n {!freeTaste && (\n <TextField\n select\n fullWidth\n label=\"Welcome email\"\n value={answers.welcomeEmail ? 'yes' : 'no'}\n onChange={(event) => answer({ welcomeEmail: event.target.value === 'yes' })}\n >\n <MenuItem value=\"yes\">{'Draft one'}</MenuItem>\n <MenuItem value=\"no\">{'No'}</MenuItem>\n </TextField>\n )}\n </Stack>\n </Stack>\n </>\n )}\n </Stack>\n </Container>\n </DialogContent>\n {step === 'describe' && !started && (\n /* The footer stays put while the questions scroll. It wraps, because\n the estimate, the reason and the buttons are wider than a phone. */\n <DialogActions\n sx={{\n px: { xs: 2, sm: 3 },\n py: 2,\n flexWrap: 'wrap',\n rowGap: 1,\n columnGap: 2,\n borderTop: 1,\n borderColor: 'divider',\n ...AI_SITE_START_SURFACE_SX,\n }}\n >\n <Stack direction=\"row\" spacing={0.5} sx={{ alignItems: 'center', mr: 'auto', minWidth: 0 }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`${estimateText}.`}\n </Typography>\n <HelpTip {...START_HELP.estimate} ariaLabel=\"How the estimate works\" />\n </Stack>\n {refusal && (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {refusal}\n </Typography>\n )}\n {!freeTaste && <AiModelSelector choice={modelChoice} disabled={busy} />}\n <Button onClick={() => setStep('choose')}>{'Back'}</Button>\n <Button\n variant=\"contained\"\n size=\"large\"\n disabled={busy || Boolean(refusal) || Boolean(prompt) || noneLeft}\n onClick={() => void plan()}\n startIcon={<MdiIcon path={mdiCreation.path} />}\n >\n {busy ? 'Starting…' : 'Plan my site'}\n </Button>\n </DialogActions>\n )}\n <Dialog\n open={confirmingLeave}\n onClose={() => setConfirmingLeave(false)}\n aria-labelledby={`${TITLE_ID}-leave`}\n aria-describedby={`${TITLE_ID}-leave-text`}\n maxWidth=\"xs\"\n >\n <DialogTitle id={`${TITLE_ID}-leave`}>{'Leave without your answers?'}</DialogTitle>\n <DialogContent>\n <DialogContentText id={`${TITLE_ID}-leave-text`}>\n {creating\n ? 'What you typed is not saved, and no site is created.'\n : 'What you typed is not saved. Leaving starts your site from the starter site instead.'}\n </DialogContentText>\n </DialogContent>\n <DialogActions>\n <Button color=\"inherit\" onClick={leaveDraft}>\n {creating ? 'Leave' : 'Leave and start blank'}\n </Button>\n <Button variant=\"contained\" autoFocus onClick={() => setConfirmingLeave(false)}>\n {'Keep editing'}\n </Button>\n </DialogActions>\n </Dialog>\n </Dialog>\n )\n}\n\nexport default AiSiteStartCard\n"],"names":["lockdownRefusalText","parseLockdownRefusal","PLATFORM_BRAND_NAME","trackEvent","ICON_VARIANT_CLOSE","mdiAccount","mdiBookOpenPageVariant","mdiBriefcaseOutline","mdiCalendarHeart","mdiCamera","mdiClockOutline","mdiContentCut","mdiCreation","mdiDumbbell","mdiHandHeart","mdiHeartPulse","mdiHomeCity","mdiMusic","mdiPaletteOutline","mdiRocketLaunch","mdiScaleBalance","mdiSchool","mdiShopping","mdiSilverwareForkKnife","mdiViewGridOutline","mdiWrench","mdiYoga","mdiPageLayoutHeaderFooter","pluginDocsHelp","HelpTip","MdiIcon","OptionCardGrid","authorizedFetch","useUser","Alert","AppBar","Box","Button","Card","CardActionArea","Chip","CircularProgress","Container","Dialog","DialogActions","DialogContent","DialogContentText","DialogTitle","IconButton","MenuItem","Stack","Step","StepLabel","Stepper","TextField","Toolbar","Typography","alpha","useRouter","useCallback","useEffect","useId","useRef","useState","AI_JOB_AUTO_CONFIRM_INPUT","AI_SITE_FREE_PAGES","AI_SITE_FREE_PAGES_NOTE","AI_SITE_SUBMISSION_CHOICES","aiFreeCreditsNoneLeftText","aiFreeCreditsResetLabel","aiFreeSiteCreditRange","aiFreeSitePrompt","aiSiteCreditRange","aiSitePagesBand","FREE_AI_TASTE_CREDITS_PER_MONTH","AI_CREDITS_CONFIRM_CODE","aiCreditRangeText","AiCreditsPromptNotice","AI_SITE_START_ANSWERS","AI_SITE_START_TYPES","aiSiteStartBrief","aiSiteStartKind","aiSiteStartInputs","aiSiteStartRefusal","AI_SITE_KINDS","aiSiteKindOfInputs","AI_SITE_KIND_ICONS","business","path","trades","professional","wellness","restaurant","store","portfolio","studio","photography","blog","events","fitness","yoga","beauty","realestate","education","nonprofit","music","personal","landing","AiJobFollow","AiModelSelector","useAiModelChoice","aiCreditsBillingHref","aiSiteBuildHref","publishAiJob","TITLE_ID","AI_SITE_START_SURFACE_SX","bgcolor","STEP_LABELS","IconBadge","accent","children","aria-hidden","sx","theme","width","spacing","height","borderRadius","display","alignItems","justifyContent","palette","main","mode","color","fontSize","ChoiceCard","icon","iconId","title","description","busy","onChoose","id","variant","transition","transitions","create","duration","shorter","borderColor","boxShadow","shadows","transform","onClick","disabled","aria-labelledby","aria-describedby","aria-busy","undefined","p","xs","sm","textAlign","size","aria-label","data-icon","component","START_HELP","choose","anchor","excerpt","style","details","estimate","SectionLabel","help","direction","AiSiteStartCard","hostId","orgId","orgSlug","host","startBlank","leave","pendingSite","initialAnswers","modelChoice","data","user","router","userRef","current","uid","verdict","setVerdict","reopened","step","setStep","answers","setAnswers","setBusy","startingStarter","setStartingStarter","notice","setNotice","started","setStarted","freeTaste","setFreeTaste","freeCredits","setFreeCredits","confirmingLeave","setConfirmingLeave","dialogRef","pendingRef","creating","Boolean","created","active","response","encodeURIComponent","payload","ok","json","catch","credits","Number","isFinite","left","pages","Math","min","max","welcomeEmail","shown","status","ready","answer","patch","serverPrompt","setServerPrompt","siteKind","prompt","noneLeft","refusal","band","surface","kind","load","loadModels","model","rememberedModel","pickedModel","plan","options","asked","creditsConfirmed","requestJob","siteId","check","method","headers","body","JSON","stringify","brief","inputs","refused","code","locked","String","error","site","made","address","job","href","push","runStartBlank","result","then","done","chooseStarter","choice","chooseAi","exit","dismissTo","drafted","siteType","trim","audience","dirty","dismiss","event","reason","target","root","Node","contains","leaveDraft","modelMultiplier","find","option","multiplier","scaled","range","likely","round","p90","ceiling","estimateText","toLocaleString","total","resetsOn","choosing","open","fullScreen","ref","onClose","slotProps","paper","elevation","position","enableColorOnDark","borderBottom","gap","edge","noWrap","textOverflow","flex","px","maxWidth","disableGutters","py","activeStep","mx","map","label","float","severity","action","noun","onBuildWhatFits","onSmaller","fields","gridTemplateColumns","intro","onOpenJobs","fullWidth","required","placeholder","value","onChange","helperText","flexWrap","type","blurb","select","submissions","Array","from","length","_","index","count","rowGap","columnGap","borderTop","mr","minWidth","ariaLabel","startIcon","autoFocus"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;AAEA,SAASA,mBAAmB,EAAEC,oBAAoB,EAAEC,mBAAmB,QAAQ,eAAc;AAC7F,SAASC,UAAU,QAAQ,0CAAyC;AAEpE,SAASC,kBAAkB,QAAQ,2BAA0B;AAC7D,SACEC,UAAU,EACVC,sBAAsB,EACtBC,mBAAmB,EACnBC,gBAAgB,EAChBC,SAAS,EACTC,eAAe,EACfC,aAAa,EACbC,WAAW,EACXC,WAAW,EACXC,YAAY,EACZC,aAAa,EACbC,WAAW,EACXC,QAAQ,EACRC,iBAAiB,EACjBC,eAAe,EACfC,eAAe,EACfC,SAAS,EACTC,WAAW,EACXC,sBAAsB,EACtBC,kBAAkB,EAClBC,SAAS,EACTC,OAAO,EACPC,yBAAyB,QACpB,yBAAwB;AAC/B,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,OAAO,EAAEC,OAAO,QAAQ,uBAAsB;AACvD,SAASC,cAAc,QAAQ,6DAA4D;AAC3F,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,KAAK,EACLC,MAAM,EACNC,GAAG,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AAa,CAAC,CAAC;;0CAErB,KAAC1R,sBAAY2I,WAAWM,QAAQ;gCAAEqM,WAAU;;;;oBAE7C9H,yBACC,KAAC7L;wBAAWwF,SAAQ;wBAAQV,OAAM;kCAC/B+G;;oBAGJ,CAACrC,2BAAa,KAACnG;wBAAgB+K,QAAQjG;wBAAahC,UAAUd;;kCAC/D,KAACxG;wBAAOqH,SAAS,IAAM4C,QAAQ;kCAAY;;kCAC3C,KAACjK;wBACC2G,SAAQ;wBACRoB,MAAK;wBACLT,UAAUd,QAAQ4E,QAAQ4B,YAAY5B,QAAQ0B,WAAWC;wBACzD1F,SAAS,IAAM,KAAKoG;wBACpBsH,yBAAW,KAACtV;4BAAQ0D,MAAM5E,YAAY4E,IAAI;;kCAEzCqD,OAAO,cAAc;;;;0BAI5B,MAAClG;gBACCiR,MAAMxG;gBACN2G,SAAS,IAAM1G,mBAAmB;gBAClCzD,mBAAiB,GAAG1C,SAAS,MAAM,CAAC;gBACpC2C,oBAAkB,GAAG3C,SAAS,WAAW,CAAC;gBAC1C0N,UAAS;;kCAET,KAAC7R;wBAAYgG,IAAI,GAAG7B,SAAS,MAAM,CAAC;kCAAG;;kCACvC,KAACrE;kCACC,cAAA,KAACC;4BAAkBiG,IAAI,GAAG7B,SAAS,WAAW,CAAC;sCAC5CsG,WACG,yDACA;;;kCAGR,MAAC5K;;0CACC,KAACP;gCAAOiG,OAAM;gCAAUoB,SAASkJ;0CAC9BpF,WAAW,UAAU;;0CAExB,KAACnL;gCAAO2G,SAAQ;gCAAYqO,SAAS;gCAAC3N,SAAS,IAAM2D,mBAAmB;0CACrE;;;;;;;;AAMb;AAEA,eAAenC,gBAAe"}
|
|
@@ -43,6 +43,12 @@ export interface AiJobAdmissionContext {
|
|
|
43
43
|
firestore: FirebaseFirestore.Firestore;
|
|
44
44
|
orgId: string;
|
|
45
45
|
hostId: string | null;
|
|
46
|
+
/**
|
|
47
|
+
* The create door's check, asked before "Create site" makes the site the
|
|
48
|
+
* job is for (AGL-3859): `hostId` is null because the site does not exist
|
|
49
|
+
* yet, and a kind that needs one answers for everything but the site.
|
|
50
|
+
*/
|
|
51
|
+
siteToCome?: boolean;
|
|
46
52
|
/** The job's kind-specific inputs, as the door parsed or the job stored them. */
|
|
47
53
|
inputs: Readonly<Record<string, unknown>>;
|
|
48
54
|
/** The org document the gate ladder read; a check narrows it to the fields it reads. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-job-admission.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 { AiCreditsPrompt } from '../model/ai-credit-estimate'\nimport type { AiJobKind, AiJobPlan } from '../model/ai-jobs.types'\nimport {\n AI_OFF_FOR_SITE_COPY,\n AI_OFF_FOR_SITE_STATUS,\n isAiOffForSite,\n} from '../model/ai-site-switch'\n\n/**\n * What a job kind checks before a job of it runs (AGL-2909).\n *\n * The create door parses the body every kind shares — the org, the site, the\n * brief, scalar inputs — and nothing the machine knows says whether THIS kind\n * can finish: a layout needs a site to write to, a page template names the\n * collection it renders, and both write a document the site's plan counts.\n * A job that cannot finish should never start, because a planned kind spends\n * on its plan before it writes anything. So a kind registers one check, the\n * create door asks it after the gate ladder admitted the request and before\n * the job exists, and the resume door asks it again before a confirmed plan\n * runs, since an allowance free at creation may be used by now. Either way\n * a refusal hands the reservation back and spends nothing.\n *\n * The resume door also hands the check the plan being confirmed (AGL-2907),\n * so a kind that can build only some plans — a page job builds one screen\n * from what the site has — refuses the others when a member confirms them,\n * not a beat later from inside the step.\n *\n * The registry lives apart from the machine so the doors read it without the\n * generators, and a generator registers here beside its runner.\n */\n\nexport interface AiJobAdmissionContext {\n /** The Admin SDK handle the door runs on. */\n firestore: FirebaseFirestore.Firestore\n orgId: string\n hostId: string | null\n /** The job's kind-specific inputs, as the door parsed or the job stored them. */\n inputs: Readonly<Record<string, unknown>>\n /** The org document the gate ladder read; a check narrows it to the fields it reads. */\n org: object | null\n /**\n * The job's plan when the door is resuming a job that has one; absent at\n * creation, when no plan exists yet.\n */\n plan?: AiJobPlan | null\n /**\n * The member whose request spends: the creator at the create door, the\n * member confirming at the resume door. A kind whose draft another plugin\n * writes asks that plugin whether this member may create one.\n */\n uid?: string | null\n /**\n * The person chose \"Build what fits\" (AGL-3722): a Free job whose p90 is\n * more than what is left is admitted, to build as much as it can and pause\n * with Resume. Unset, such a job is answered with the prompt instead.\n */\n creditsConfirmed?: boolean\n /**\n * Told the prompt a confirmed Free job was admitted past (AGL-3722), so the\n * door records the confirmation on the job: who, when, what was left.\n */\n onCreditsConfirmed?: (prompt: AiCreditsPrompt) => void\n}\n\nexport interface AiJobAdmissionRefusal {\n /**\n * 429: what the month's AI credits have left cannot pay for it (AGL-3660);\n * 409: a Free job past what is left, waiting for the person's go-ahead\n * (AGL-3722) — `code` and `credits` say what to ask.\n */\n status: 400 | 403 | 404 | 409 | 429\n /** Customer-safe: the door answers with it as it stands. */\n error: string\n /** `AI_CREDITS_CONFIRM_CODE` on a 409 that asks for the go-ahead. */\n code?: string\n /** The figures and choices that 409 asks with. */\n credits?: AiCreditsPrompt\n}\n\nexport type AiJobAdmission = (\n context: AiJobAdmissionContext,\n) => Promise<AiJobAdmissionRefusal | null>\n\nconst admissions = new Map<AiJobKind, AiJobAdmission>()\n\n/** Idempotent per kind; the last registration wins, and `null` unregisters. */\nexport function registerAiJobAdmission(kind: AiJobKind, admission: AiJobAdmission | null): void {\n if (admission) admissions.set(kind, admission)\n else admissions.delete(kind)\n}\n\n/** The kind's registered admission, or `null` when it has none. */\nexport function aiJobAdmissionFor(kind: AiJobKind): AiJobAdmission | null {\n return admissions.get(kind) ?? null\n}\n\n/** The kind's refusal, or `null` when it admits the job or has nothing to check. */\nexport async function aiJobAdmissionRefusal(\n kind: AiJobKind,\n context: AiJobAdmissionContext,\n): Promise<AiJobAdmissionRefusal | null> {\n const admission = admissions.get(kind)\n return admission ? admission(context) : null\n}\n\n/**\n * The refusal for a job on a site that switched AI off (AGL-3028), or `null`.\n *\n * Every kind meets it, and every door asks it BEFORE the kind's own check —\n * the create door, each site of an agency batch, and a resume — so no job\n * comes to exist, or runs another step, for a site that said no, and a\n * switched-off site never pays for a kind's reads. A job with no site is\n * workspace-level and always passes.\n */\nexport async function aiJobSiteRefusal(\n context: Pick<AiJobAdmissionContext, 'firestore' | 'org' | 'hostId'>,\n): Promise<AiJobAdmissionRefusal | null> {\n return (await isAiOffForSite(context.firestore, context.org, context.hostId))\n ? { status: AI_OFF_FOR_SITE_STATUS, error: AI_OFF_FOR_SITE_COPY }\n : null\n}\n"],"names":["AI_OFF_FOR_SITE_COPY","AI_OFF_FOR_SITE_STATUS","isAiOffForSite","admissions","Map","registerAiJobAdmission","kind","admission","set","delete","aiJobAdmissionFor","get","aiJobAdmissionRefusal","context","aiJobSiteRefusal","firestore","org","hostId","status","error"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAID,SACEA,oBAAoB,EACpBC,sBAAsB,EACtBC,cAAc,QACT,6BAAyB;
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-job-admission.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 { AiCreditsPrompt } from '../model/ai-credit-estimate'\nimport type { AiJobKind, AiJobPlan } from '../model/ai-jobs.types'\nimport {\n AI_OFF_FOR_SITE_COPY,\n AI_OFF_FOR_SITE_STATUS,\n isAiOffForSite,\n} from '../model/ai-site-switch'\n\n/**\n * What a job kind checks before a job of it runs (AGL-2909).\n *\n * The create door parses the body every kind shares — the org, the site, the\n * brief, scalar inputs — and nothing the machine knows says whether THIS kind\n * can finish: a layout needs a site to write to, a page template names the\n * collection it renders, and both write a document the site's plan counts.\n * A job that cannot finish should never start, because a planned kind spends\n * on its plan before it writes anything. So a kind registers one check, the\n * create door asks it after the gate ladder admitted the request and before\n * the job exists, and the resume door asks it again before a confirmed plan\n * runs, since an allowance free at creation may be used by now. Either way\n * a refusal hands the reservation back and spends nothing.\n *\n * The resume door also hands the check the plan being confirmed (AGL-2907),\n * so a kind that can build only some plans — a page job builds one screen\n * from what the site has — refuses the others when a member confirms them,\n * not a beat later from inside the step.\n *\n * The registry lives apart from the machine so the doors read it without the\n * generators, and a generator registers here beside its runner.\n */\n\nexport interface AiJobAdmissionContext {\n /** The Admin SDK handle the door runs on. */\n firestore: FirebaseFirestore.Firestore\n orgId: string\n hostId: string | null\n /**\n * The create door's check, asked before \"Create site\" makes the site the\n * job is for (AGL-3859): `hostId` is null because the site does not exist\n * yet, and a kind that needs one answers for everything but the site.\n */\n siteToCome?: boolean\n /** The job's kind-specific inputs, as the door parsed or the job stored them. */\n inputs: Readonly<Record<string, unknown>>\n /** The org document the gate ladder read; a check narrows it to the fields it reads. */\n org: object | null\n /**\n * The job's plan when the door is resuming a job that has one; absent at\n * creation, when no plan exists yet.\n */\n plan?: AiJobPlan | null\n /**\n * The member whose request spends: the creator at the create door, the\n * member confirming at the resume door. A kind whose draft another plugin\n * writes asks that plugin whether this member may create one.\n */\n uid?: string | null\n /**\n * The person chose \"Build what fits\" (AGL-3722): a Free job whose p90 is\n * more than what is left is admitted, to build as much as it can and pause\n * with Resume. Unset, such a job is answered with the prompt instead.\n */\n creditsConfirmed?: boolean\n /**\n * Told the prompt a confirmed Free job was admitted past (AGL-3722), so the\n * door records the confirmation on the job: who, when, what was left.\n */\n onCreditsConfirmed?: (prompt: AiCreditsPrompt) => void\n}\n\nexport interface AiJobAdmissionRefusal {\n /**\n * 429: what the month's AI credits have left cannot pay for it (AGL-3660);\n * 409: a Free job past what is left, waiting for the person's go-ahead\n * (AGL-3722) — `code` and `credits` say what to ask.\n */\n status: 400 | 403 | 404 | 409 | 429\n /** Customer-safe: the door answers with it as it stands. */\n error: string\n /** `AI_CREDITS_CONFIRM_CODE` on a 409 that asks for the go-ahead. */\n code?: string\n /** The figures and choices that 409 asks with. */\n credits?: AiCreditsPrompt\n}\n\nexport type AiJobAdmission = (\n context: AiJobAdmissionContext,\n) => Promise<AiJobAdmissionRefusal | null>\n\nconst admissions = new Map<AiJobKind, AiJobAdmission>()\n\n/** Idempotent per kind; the last registration wins, and `null` unregisters. */\nexport function registerAiJobAdmission(kind: AiJobKind, admission: AiJobAdmission | null): void {\n if (admission) admissions.set(kind, admission)\n else admissions.delete(kind)\n}\n\n/** The kind's registered admission, or `null` when it has none. */\nexport function aiJobAdmissionFor(kind: AiJobKind): AiJobAdmission | null {\n return admissions.get(kind) ?? null\n}\n\n/** The kind's refusal, or `null` when it admits the job or has nothing to check. */\nexport async function aiJobAdmissionRefusal(\n kind: AiJobKind,\n context: AiJobAdmissionContext,\n): Promise<AiJobAdmissionRefusal | null> {\n const admission = admissions.get(kind)\n return admission ? admission(context) : null\n}\n\n/**\n * The refusal for a job on a site that switched AI off (AGL-3028), or `null`.\n *\n * Every kind meets it, and every door asks it BEFORE the kind's own check —\n * the create door, each site of an agency batch, and a resume — so no job\n * comes to exist, or runs another step, for a site that said no, and a\n * switched-off site never pays for a kind's reads. A job with no site is\n * workspace-level and always passes.\n */\nexport async function aiJobSiteRefusal(\n context: Pick<AiJobAdmissionContext, 'firestore' | 'org' | 'hostId'>,\n): Promise<AiJobAdmissionRefusal | null> {\n return (await isAiOffForSite(context.firestore, context.org, context.hostId))\n ? { status: AI_OFF_FOR_SITE_STATUS, error: AI_OFF_FOR_SITE_COPY }\n : null\n}\n"],"names":["AI_OFF_FOR_SITE_COPY","AI_OFF_FOR_SITE_STATUS","isAiOffForSite","admissions","Map","registerAiJobAdmission","kind","admission","set","delete","aiJobAdmissionFor","get","aiJobAdmissionRefusal","context","aiJobSiteRefusal","firestore","org","hostId","status","error"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAID,SACEA,oBAAoB,EACpBC,sBAAsB,EACtBC,cAAc,QACT,6BAAyB;AAmFhC,MAAMC,aAAa,IAAIC;AAEvB,6EAA6E,GAC7E,OAAO,SAASC,uBAAuBC,IAAe,EAAEC,SAAgC;IACtF,IAAIA,WAAWJ,WAAWK,GAAG,CAACF,MAAMC;SAC/BJ,WAAWM,MAAM,CAACH;AACzB;AAEA,iEAAiE,GACjE,OAAO,SAASI,kBAAkBJ,IAAe;QACxCH;IAAP,QAAOA,kBAAAA,WAAWQ,GAAG,CAACL,iBAAfH,kBAAwB;AACjC;AAEA,kFAAkF,GAClF,OAAO,eAAeS,sBACpBN,IAAe,EACfO,OAA8B;IAE9B,MAAMN,YAAYJ,WAAWQ,GAAG,CAACL;IACjC,OAAOC,YAAYA,UAAUM,WAAW;AAC1C;AAEA;;;;;;;;CAQC,GACD,OAAO,eAAeC,iBACpBD,OAAoE;IAEpE,OAAO,AAAC,MAAMX,eAAeW,QAAQE,SAAS,EAAEF,QAAQG,GAAG,EAAEH,QAAQI,MAAM,IACvE;QAAEC,QAAQjB;QAAwBkB,OAAOnB;IAAqB,IAC9D;AACN"}
|
|
@@ -764,17 +764,21 @@ export const AI_SITE_NO_PLAN_COPY = 'This site job has no confirmed plan to buil
|
|
|
764
764
|
error: shape
|
|
765
765
|
};
|
|
766
766
|
}
|
|
767
|
-
if (!context.hostId) {
|
|
767
|
+
if (!context.hostId && !context.siteToCome) {
|
|
768
768
|
return {
|
|
769
769
|
status: 400,
|
|
770
770
|
error: 'Open the site the scaffold is for before starting the job'
|
|
771
771
|
};
|
|
772
772
|
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
773
|
+
// A site still to come (AGL-3859) is the one "Create site" makes for
|
|
774
|
+
// this org once everything else here has said yes.
|
|
775
|
+
if (context.hostId) {
|
|
776
|
+
const owner = await resolveOrgIdForHost(context.hostId);
|
|
777
|
+
if (!owner || owner !== context.orgId) return {
|
|
778
|
+
status: 404,
|
|
779
|
+
error: 'Unknown site'
|
|
780
|
+
};
|
|
781
|
+
}
|
|
778
782
|
if (!aiJobStepRunnerFor('page')) {
|
|
779
783
|
return {
|
|
780
784
|
status: 400,
|