@aglyn/plugins-ai 1.0.0-beta.233 → 1.0.0-beta.234

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.
Files changed (104) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/ai-job-links.d.ts +6 -0
  3. package/src/lib/components/ai-job-links.js +9 -0
  4. package/src/lib/components/ai-job-links.js.map +1 -1
  5. package/src/lib/components/ai-site-build-page.component.js +41 -3
  6. package/src/lib/components/ai-site-build-page.component.js.map +1 -1
  7. package/src/lib/components/ai-site-start-card.component.js +91 -8
  8. package/src/lib/components/ai-site-start-card.component.js.map +1 -1
  9. package/src/lib/jobs/ai-job-admission.d.ts +2 -1
  10. package/src/lib/jobs/ai-job-admission.js.map +1 -1
  11. package/src/lib/jobs/ai-job-email-step.d.ts +39 -0
  12. package/src/lib/jobs/ai-job-email-step.js +116 -5
  13. package/src/lib/jobs/ai-job-email-step.js.map +1 -1
  14. package/src/lib/jobs/ai-job-layout-language.d.ts +3 -0
  15. package/src/lib/jobs/ai-job-layout-language.js +3 -1
  16. package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
  17. package/src/lib/jobs/ai-job-layout-site-pages.d.ts +2 -0
  18. package/src/lib/jobs/ai-job-layout-site-pages.js +23 -11
  19. package/src/lib/jobs/ai-job-layout-site-pages.js.map +1 -1
  20. package/src/lib/jobs/ai-job-layout-step.js +3 -2
  21. package/src/lib/jobs/ai-job-layout-step.js.map +1 -1
  22. package/src/lib/jobs/ai-job-page-language.d.ts +16 -0
  23. package/src/lib/jobs/ai-job-page-language.js +35 -6
  24. package/src/lib/jobs/ai-job-page-language.js.map +1 -1
  25. package/src/lib/jobs/ai-job-page-step.d.ts +3 -0
  26. package/src/lib/jobs/ai-job-page-step.js +18 -4
  27. package/src/lib/jobs/ai-job-page-step.js.map +1 -1
  28. package/src/lib/jobs/ai-job-plan-step.d.ts +34 -0
  29. package/src/lib/jobs/ai-job-plan-step.js +106 -14
  30. package/src/lib/jobs/ai-job-plan-step.js.map +1 -1
  31. package/src/lib/jobs/ai-job-site-content.d.ts +6 -6
  32. package/src/lib/jobs/ai-job-site-content.js +6 -12
  33. package/src/lib/jobs/ai-job-site-content.js.map +1 -1
  34. package/src/lib/jobs/ai-job-site-step.d.ts +11 -0
  35. package/src/lib/jobs/ai-job-site-step.js +96 -44
  36. package/src/lib/jobs/ai-job-site-step.js.map +1 -1
  37. package/src/lib/jobs/ai-jobs.d.ts +8 -4
  38. package/src/lib/jobs/ai-jobs.js +19 -2
  39. package/src/lib/jobs/ai-jobs.js.map +1 -1
  40. package/src/lib/jobs/ai-layout-stock-photos.d.ts +98 -0
  41. package/src/lib/jobs/ai-layout-stock-photos.js +248 -0
  42. package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -0
  43. package/src/lib/jobs/ai-site-publish.d.ts +11 -0
  44. package/src/lib/jobs/ai-site-publish.js +31 -1
  45. package/src/lib/jobs/ai-site-publish.js.map +1 -1
  46. package/src/lib/jobs/fixtures/ai-juniper-portfolio-page-recording.d.ts +151 -0
  47. package/src/lib/jobs/fixtures/ai-juniper-portfolio-page-recording.js +183 -0
  48. package/src/lib/jobs/fixtures/ai-juniper-portfolio-page-recording.js.map +1 -0
  49. package/src/lib/jobs/fixtures/ai-slow-roads-site-plan-recording.d.ts +27 -0
  50. package/src/lib/jobs/fixtures/ai-slow-roads-site-plan-recording.js +192 -0
  51. package/src/lib/jobs/fixtures/ai-slow-roads-site-plan-recording.js.map +1 -0
  52. package/src/lib/jobs/fixtures/ai-yoga-site-plan-recording.d.ts +27 -0
  53. package/src/lib/jobs/fixtures/ai-yoga-site-plan-recording.js +222 -0
  54. package/src/lib/jobs/fixtures/ai-yoga-site-plan-recording.js.map +1 -0
  55. package/src/lib/layout-language/ai-layout-compiler.d.ts +29 -0
  56. package/src/lib/layout-language/ai-layout-compiler.js +698 -12
  57. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  58. package/src/lib/layout-language/ai-layout-design.d.ts +107 -0
  59. package/src/lib/layout-language/ai-layout-design.js +197 -0
  60. package/src/lib/layout-language/ai-layout-design.js.map +1 -0
  61. package/src/lib/layout-language/ai-layout-frame.d.ts +6 -0
  62. package/src/lib/layout-language/ai-layout-frame.js +22 -6
  63. package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
  64. package/src/lib/layout-language/ai-layout-language.d.ts +2 -0
  65. package/src/lib/layout-language/ai-layout-language.js +15 -1
  66. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  67. package/src/lib/layout-language/ai-layout-links.d.ts +11 -0
  68. package/src/lib/layout-language/ai-layout-links.js +4 -0
  69. package/src/lib/layout-language/ai-layout-links.js.map +1 -1
  70. package/src/lib/layout-language/ai-layout-pictures.d.ts +11 -5
  71. package/src/lib/layout-language/ai-layout-pictures.js +80 -17
  72. package/src/lib/layout-language/ai-layout-pictures.js.map +1 -1
  73. package/src/lib/model/ai-job-notice.d.ts +9 -1
  74. package/src/lib/model/ai-job-notice.js +23 -0
  75. package/src/lib/model/ai-job-notice.js.map +1 -1
  76. package/src/lib/model/ai-plan-capabilities.d.ts +7 -0
  77. package/src/lib/model/ai-plan-capabilities.js.map +1 -1
  78. package/src/lib/model/ai-site-build-progress.d.ts +12 -2
  79. package/src/lib/model/ai-site-build-progress.js +78 -4
  80. package/src/lib/model/ai-site-build-progress.js.map +1 -1
  81. package/src/lib/model/ai-site-job.d.ts +209 -22
  82. package/src/lib/model/ai-site-job.js +247 -20
  83. package/src/lib/model/ai-site-job.js.map +1 -1
  84. package/src/lib/model/ai-site-kinds.js +6 -1
  85. package/src/lib/model/ai-site-kinds.js.map +1 -1
  86. package/src/lib/model/ai-site-look.d.ts +21 -0
  87. package/src/lib/model/ai-site-look.js +63 -14
  88. package/src/lib/model/ai-site-look.js.map +1 -1
  89. package/src/lib/runtime/ai-doctrine-validators.d.ts +32 -1
  90. package/src/lib/runtime/ai-doctrine-validators.js +227 -4
  91. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  92. package/src/lib/runtime/ai-doctrine.js +5 -3
  93. package/src/lib/runtime/ai-doctrine.js.map +1 -1
  94. package/src/lib/runtime/ai-palette.generated.d.ts +2 -0
  95. package/src/lib/runtime/ai-palette.generated.js +18 -2
  96. package/src/lib/runtime/ai-palette.generated.js.map +1 -1
  97. package/src/lib/server/ai-jobs-resume.js.map +1 -1
  98. package/src/lib/server/ai-jobs-route.js +15 -3
  99. package/src/lib/server/ai-jobs-route.js.map +1 -1
  100. package/src/lib/server/assist-edit.js +5 -2
  101. package/src/lib/server/assist-edit.js.map +1 -1
  102. package/src/lib/usage/free-ai-credits-left.d.ts +54 -0
  103. package/src/lib/usage/free-ai-credits-left.js +62 -0
  104. package/src/lib/usage/free-ai-credits-left.js.map +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/plugins-ai",
3
- "version": "1.0.0-beta.233",
3
+ "version": "1.0.0-beta.234",
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.233",
29
- "@aglyn/shared-data-enums": "1.0.0-beta.233",
30
- "@aglyn/shared-data-mdi": "1.0.0-beta.233",
31
- "@aglyn/shared-data-types": "1.0.0-beta.233",
32
- "@aglyn/shared-ui-email-campaigns": "1.0.0-beta.233",
33
- "@aglyn/shared-ui-jsx": "1.0.0-beta.233",
34
- "@aglyn/shared-ui-snackstack": "1.0.0-beta.233",
35
- "@aglyn/shared-ui-theme": "1.0.0-beta.233",
36
- "@aglyn/shared-util-email": "1.0.0-beta.233",
37
- "@aglyn/shared-util-errors": "1.0.0-beta.233",
38
- "@aglyn/shared-util-http": "1.0.0-beta.233",
39
- "@aglyn/shared-util-timestamp": "1.0.0-beta.233",
40
- "@aglyn/shared-util-tools": "1.0.0-beta.233",
41
- "@aglyn/tenant-data-admin": "1.0.0-beta.233",
42
- "@aglyn/tenant-feature-instance": "1.0.0-beta.233",
43
- "@aglyn/tenant-runtime": "1.0.0-beta.233",
28
+ "@aglyn/aglyn": "1.0.0-beta.234",
29
+ "@aglyn/shared-data-enums": "1.0.0-beta.234",
30
+ "@aglyn/shared-data-mdi": "1.0.0-beta.234",
31
+ "@aglyn/shared-data-types": "1.0.0-beta.234",
32
+ "@aglyn/shared-ui-email-campaigns": "1.0.0-beta.234",
33
+ "@aglyn/shared-ui-jsx": "1.0.0-beta.234",
34
+ "@aglyn/shared-ui-snackstack": "1.0.0-beta.234",
35
+ "@aglyn/shared-ui-theme": "1.0.0-beta.234",
36
+ "@aglyn/shared-util-email": "1.0.0-beta.234",
37
+ "@aglyn/shared-util-errors": "1.0.0-beta.234",
38
+ "@aglyn/shared-util-http": "1.0.0-beta.234",
39
+ "@aglyn/shared-util-timestamp": "1.0.0-beta.234",
40
+ "@aglyn/shared-util-tools": "1.0.0-beta.234",
41
+ "@aglyn/tenant-data-admin": "1.0.0-beta.234",
42
+ "@aglyn/tenant-feature-instance": "1.0.0-beta.234",
43
+ "@aglyn/tenant-runtime": "1.0.0-beta.234",
44
44
  "@swc/helpers": "0.5.23"
45
45
  },
46
46
  "peerDependencies": {
@@ -40,3 +40,9 @@ export declare function aiSiteBuildDoneLinks(job: Pick<AiJobSummary, 'outputs'>,
40
40
  view: string | null;
41
41
  pages: string | null;
42
42
  };
43
+ /**
44
+ * Where a person gets more AI credits (AGL-3660): the workspace's Billing
45
+ * page at its plans, where an upgrade and the AI add-on are both sold — the
46
+ * door the AI credits meter's own upgrade link opens.
47
+ */
48
+ export declare function aiCreditsBillingHref(orgSlug: string): string;
@@ -149,5 +149,14 @@ export { AI_SITE_BUILD_HREF };
149
149
  })
150
150
  };
151
151
  }
152
+ /**
153
+ * Where a person gets more AI credits (AGL-3660): the workspace's Billing
154
+ * page at its plans, where an upgrade and the AI add-on are both sold — the
155
+ * door the AI credits meter's own upgrade link opens.
156
+ */ export function aiCreditsBillingHref(orgSlug) {
157
+ return `${buildRoute(Route.MANAGE_BILLING, {
158
+ orgSlug
159
+ })}#plans`;
160
+ }
152
161
 
153
162
  //# sourceMappingURL=ai-job-links.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-job-links.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 */\nimport { buildRoute, Route } from '@aglyn/aglyn/app-utils/console-routes'\nimport {\n pluginRecordHref,\n pluginRecordListHref,\n} from '@aglyn/aglyn/plugin-manager/plugin-record-routes'\nimport { AI_JOB_BESIGNER_SEGMENT as BESIGNER_SEGMENT, AI_SITE_BUILD_HREF } from '../model/ai-job-notice'\nimport type { AiJobOutput, AiJobSummary } from '../model/ai-jobs.types'\n\n// Where a job's work opens in the console (AGL-2904), shared by the AI jobs\n// drawer and every dialog that follows the job it started (AGL-3593).\n\n/**\n * Where \"open draft\" goes, or `null` when the output has no page of its\n * own — a `text` output carries its copy on the job and is shown inline.\n * A versioned resource opens in the besigner on the version the job wrote;\n * one the console lists without a detail page opens its list; a `theme`\n * proposal opens the site's Theme section, where it is put in the editor.\n *\n * A console URL names a site by its SUBDOMAIN: the `[host]` segment resolves\n * through the member's host projection by subdomain, never by document id.\n * So an output that carries no `hostSubdomain` gets no link rather than one\n * that opens no site.\n */\nexport function aiJobOutputHref(output: AiJobOutput, orgSlug: string): string | null {\n const host = output.hostSubdomain\n if (!orgSlug || !host) return null\n const segment = BESIGNER_SEGMENT[output.resource]\n if (segment) {\n const base = `/${orgSlug}/hosts/${host}/${segment}/${output.id}`\n return output.versionId ? `${base}/versions/${output.versionId}/besigner` : base\n }\n if (output.resource === 'product') {\n // The catalog a drafted product lands in: the commerce plugin's address\n // for it (AGL-3080), or no link where commerce is not loaded.\n return pluginRecordListHref('product', { orgSlug, host })\n }\n if (output.resource === 'workflow') {\n // A drafted automation is an action (AGL-2919), listed switched off on\n // the workflows plugin's list of actions, or no link where it is not loaded.\n return pluginRecordListHref('action', { orgSlug, host })\n }\n if (output.resource === 'entry') {\n // A post a guided start wrote (AGL-3676) opens in its blog's list in Content.\n const collectionSlug = output.proposal?.['collectionSlug']\n return typeof collectionSlug === 'string' && collectionSlug\n ? buildRoute(Route.HOST_CONTENT_COLLECTION, { orgSlug, host, collectionSlug })\n : buildRoute(Route.HOST_CONTENT, { orgSlug, host })\n }\n if (output.resource === 'theme') {\n return buildRoute(Route.HOST_SETUP_THEME, { orgSlug, host })\n }\n if (output.resource === 'form') {\n // A new form has no version for the besigner to open: its own page — the\n // forms plugin's address for it — mints the first one, and holds the\n // routing and consent it declares.\n return pluginRecordHref('form', { orgSlug, host }, output.id)\n }\n if (output.resource === 'campaign') {\n // A campaign's page is the marketing plugin's, under the site: its\n // address for the campaign (AGL-3080), or no link where it is not loaded.\n return pluginRecordHref('campaign', { orgSlug, host }, output.id)\n }\n return null\n}\n\n/**\n * The ONE action a finished job's row, its notification and the dialog that\n * started it lead with (AGL-3593): what the job built. Several pages from one\n * job — a site's — open the site's Pages list, where they wait as drafts; one\n * output with a page of its own opens that page; anything else has no single\n * place to go, and the row's own links stand. `null` until the job is done.\n */\nexport function aiJobPrimaryLink(\n job: Pick<AiJobSummary, 'status' | 'outputs'>,\n orgSlug: string,\n): { href: string; label: string } | null {\n if (job.status !== 'done' || !orgSlug) return null\n const screens = job.outputs.filter(\n (output) => output.resource === 'screen' && output.hostSubdomain,\n )\n if (screens.length > 1) {\n return {\n href: buildRoute(Route.HOST_SCREENS, { orgSlug, host: String(screens[0].hostSubdomain) }),\n label: 'Open your draft pages',\n }\n }\n for (const output of job.outputs) {\n const href = aiJobOutputHref(output, orgSlug)\n if (href) {\n return {\n href,\n label: output.resource === 'screen' ? 'Open the draft page' : `Open ${output.label}`,\n }\n }\n }\n return null\n}\n\nexport { AI_SITE_BUILD_HREF }\n\n/**\n * The \"Building your site\" page for one site job (AGL-3594): linkable, so the\n * guided start lands on it, a reload keeps it and a notification opens it.\n * `null` without the org slug or the site's subdomain a console URL needs.\n */\nexport function aiSiteBuildHref(\n orgSlug: string | null | undefined,\n hostSubdomain: string | null | undefined,\n jobId: string,\n): string | null {\n if (!orgSlug || !hostSubdomain || !jobId) return null\n return `/${orgSlug}/hosts/${hostSubdomain}${AI_SITE_BUILD_HREF}/${encodeURIComponent(jobId)}`\n}\n\n/**\n * A finished site's two ways in (AGL-3594): its first page's draft, opened in\n * the console's preview of that version, and the Pages list every draft waits\n * in. Either is `null` where the job reported nothing to open.\n */\nexport function aiSiteBuildDoneLinks(\n job: Pick<AiJobSummary, 'outputs'>,\n orgSlug: string,\n): { view: string | null; pages: string | null } {\n const screens = job.outputs.filter((output) => output.resource === 'screen' && output.hostSubdomain)\n const first = screens[0]\n if (!first || !orgSlug) return { view: null, pages: null }\n const host = String(first.hostSubdomain)\n return {\n view: first.versionId\n ? `/${orgSlug}/hosts/${host}/screens/${first.id}/versions/${first.versionId}/view`\n : null,\n pages: buildRoute(Route.HOST_SCREENS, { orgSlug, host }),\n }\n}\n"],"names":["buildRoute","Route","pluginRecordHref","pluginRecordListHref","AI_JOB_BESIGNER_SEGMENT","BESIGNER_SEGMENT","AI_SITE_BUILD_HREF","aiJobOutputHref","output","orgSlug","host","hostSubdomain","segment","resource","base","id","versionId","collectionSlug","proposal","HOST_CONTENT_COLLECTION","HOST_CONTENT","HOST_SETUP_THEME","aiJobPrimaryLink","job","status","screens","outputs","filter","length","href","HOST_SCREENS","String","label","aiSiteBuildHref","jobId","encodeURIComponent","aiSiteBuildDoneLinks","first","view","pages"],"mappings":"AAAA;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AO,CAAC,CAAC,EAAEzB,QAAQ,OAAO,EAAEE,gBAAgBL,mBAAmB,CAAC,EAAE6B,mBAAmBD,QAAQ;AAC/F;AAEA;;;;CAIC,GACD,OAAO,SAASE,qBACdb,GAAkC,EAClCd,OAAe;IAEf,MAAMgB,UAAUF,IAAIG,OAAO,CAACC,MAAM,CAAC,CAACnB,SAAWA,OAAOK,QAAQ,KAAK,YAAYL,OAAOG,aAAa;IACnG,MAAM0B,QAAQZ,OAAO,CAAC,EAAE;IACxB,IAAI,CAACY,SAAS,CAAC5B,SAAS,OAAO;QAAE6B,MAAM;QAAMC,OAAO;IAAK;IACzD,MAAM7B,OAAOqB,OAAOM,MAAM1B,aAAa;IACvC,OAAO;QACL2B,MAAMD,MAAMrB,SAAS,GACjB,CAAC,CAAC,EAAEP,QAAQ,OAAO,EAAEC,KAAK,SAAS,EAAE2B,MAAMtB,EAAE,CAAC,UAAU,EAAEsB,MAAMrB,SAAS,CAAC,KAAK,CAAC,GAChF;QACJuB,OAAOvC,WAAWC,MAAM6B,YAAY,EAAE;YAAErB;YAASC;QAAK;IACxD;AACF"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-job-links.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 */\nimport { buildRoute, Route } from '@aglyn/aglyn/app-utils/console-routes'\nimport {\n pluginRecordHref,\n pluginRecordListHref,\n} from '@aglyn/aglyn/plugin-manager/plugin-record-routes'\nimport { AI_JOB_BESIGNER_SEGMENT as BESIGNER_SEGMENT, AI_SITE_BUILD_HREF } from '../model/ai-job-notice'\nimport type { AiJobOutput, AiJobSummary } from '../model/ai-jobs.types'\n\n// Where a job's work opens in the console (AGL-2904), shared by the AI jobs\n// drawer and every dialog that follows the job it started (AGL-3593).\n\n/**\n * Where \"open draft\" goes, or `null` when the output has no page of its\n * own — a `text` output carries its copy on the job and is shown inline.\n * A versioned resource opens in the besigner on the version the job wrote;\n * one the console lists without a detail page opens its list; a `theme`\n * proposal opens the site's Theme section, where it is put in the editor.\n *\n * A console URL names a site by its SUBDOMAIN: the `[host]` segment resolves\n * through the member's host projection by subdomain, never by document id.\n * So an output that carries no `hostSubdomain` gets no link rather than one\n * that opens no site.\n */\nexport function aiJobOutputHref(output: AiJobOutput, orgSlug: string): string | null {\n const host = output.hostSubdomain\n if (!orgSlug || !host) return null\n const segment = BESIGNER_SEGMENT[output.resource]\n if (segment) {\n const base = `/${orgSlug}/hosts/${host}/${segment}/${output.id}`\n return output.versionId ? `${base}/versions/${output.versionId}/besigner` : base\n }\n if (output.resource === 'product') {\n // The catalog a drafted product lands in: the commerce plugin's address\n // for it (AGL-3080), or no link where commerce is not loaded.\n return pluginRecordListHref('product', { orgSlug, host })\n }\n if (output.resource === 'workflow') {\n // A drafted automation is an action (AGL-2919), listed switched off on\n // the workflows plugin's list of actions, or no link where it is not loaded.\n return pluginRecordListHref('action', { orgSlug, host })\n }\n if (output.resource === 'entry') {\n // A post a guided start wrote (AGL-3676) opens in its blog's list in Content.\n const collectionSlug = output.proposal?.['collectionSlug']\n return typeof collectionSlug === 'string' && collectionSlug\n ? buildRoute(Route.HOST_CONTENT_COLLECTION, { orgSlug, host, collectionSlug })\n : buildRoute(Route.HOST_CONTENT, { orgSlug, host })\n }\n if (output.resource === 'theme') {\n return buildRoute(Route.HOST_SETUP_THEME, { orgSlug, host })\n }\n if (output.resource === 'form') {\n // A new form has no version for the besigner to open: its own page — the\n // forms plugin's address for it — mints the first one, and holds the\n // routing and consent it declares.\n return pluginRecordHref('form', { orgSlug, host }, output.id)\n }\n if (output.resource === 'campaign') {\n // A campaign's page is the marketing plugin's, under the site: its\n // address for the campaign (AGL-3080), or no link where it is not loaded.\n return pluginRecordHref('campaign', { orgSlug, host }, output.id)\n }\n return null\n}\n\n/**\n * The ONE action a finished job's row, its notification and the dialog that\n * started it lead with (AGL-3593): what the job built. Several pages from one\n * job — a site's — open the site's Pages list, where they wait as drafts; one\n * output with a page of its own opens that page; anything else has no single\n * place to go, and the row's own links stand. `null` until the job is done.\n */\nexport function aiJobPrimaryLink(\n job: Pick<AiJobSummary, 'status' | 'outputs'>,\n orgSlug: string,\n): { href: string; label: string } | null {\n if (job.status !== 'done' || !orgSlug) return null\n const screens = job.outputs.filter(\n (output) => output.resource === 'screen' && output.hostSubdomain,\n )\n if (screens.length > 1) {\n return {\n href: buildRoute(Route.HOST_SCREENS, { orgSlug, host: String(screens[0].hostSubdomain) }),\n label: 'Open your draft pages',\n }\n }\n for (const output of job.outputs) {\n const href = aiJobOutputHref(output, orgSlug)\n if (href) {\n return {\n href,\n label: output.resource === 'screen' ? 'Open the draft page' : `Open ${output.label}`,\n }\n }\n }\n return null\n}\n\nexport { AI_SITE_BUILD_HREF }\n\n/**\n * The \"Building your site\" page for one site job (AGL-3594): linkable, so the\n * guided start lands on it, a reload keeps it and a notification opens it.\n * `null` without the org slug or the site's subdomain a console URL needs.\n */\nexport function aiSiteBuildHref(\n orgSlug: string | null | undefined,\n hostSubdomain: string | null | undefined,\n jobId: string,\n): string | null {\n if (!orgSlug || !hostSubdomain || !jobId) return null\n return `/${orgSlug}/hosts/${hostSubdomain}${AI_SITE_BUILD_HREF}/${encodeURIComponent(jobId)}`\n}\n\n/**\n * A finished site's two ways in (AGL-3594): its first page's draft, opened in\n * the console's preview of that version, and the Pages list every draft waits\n * in. Either is `null` where the job reported nothing to open.\n */\nexport function aiSiteBuildDoneLinks(\n job: Pick<AiJobSummary, 'outputs'>,\n orgSlug: string,\n): { view: string | null; pages: string | null } {\n const screens = job.outputs.filter((output) => output.resource === 'screen' && output.hostSubdomain)\n const first = screens[0]\n if (!first || !orgSlug) return { view: null, pages: null }\n const host = String(first.hostSubdomain)\n return {\n view: first.versionId\n ? `/${orgSlug}/hosts/${host}/screens/${first.id}/versions/${first.versionId}/view`\n : null,\n pages: buildRoute(Route.HOST_SCREENS, { orgSlug, host }),\n }\n}\n\n/**\n * Where a person gets more AI credits (AGL-3660): the workspace's Billing\n * page at its plans, where an upgrade and the AI add-on are both sold — the\n * door the AI credits meter's own upgrade link opens.\n */\nexport function aiCreditsBillingHref(orgSlug: string): string {\n return `${buildRoute(Route.MANAGE_BILLING, { orgSlug })}#plans`\n}\n"],"names":["buildRoute","Route","pluginRecordHref","pluginRecordListHref","AI_JOB_BESIGNER_SEGMENT","BESIGNER_SEGMENT","AI_SITE_BUILD_HREF","aiJobOutputHref","output","orgSlug","host","hostSubdomain","segment","resource","base","id","versionId","collectionSlug","proposal","HOST_CONTENT_COLLECTION","HOST_CONTENT","HOST_SETUP_THEME","aiJobPrimaryLink","job","status","screens","outputs","filter","length","href","HOST_SCREENS","String","label","aiSiteBuildHref","jobId","encodeURIComponent","aiSiteBuildDoneLinks","first","view","pages","aiCreditsBillingHref","MANAGE_BILLING"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD,SAASA,UAAU,EAAEC,KAAK,QAAQ,wCAAuC;AACzE,SACEC,gBAAgB,EAChBC,oBAAoB,QACf,mDAAkD;AACzD,SAASC,2BAA2BC,gBAAgB,EAAEC,kBAAkB,QAAQ,4BAAwB;AAGxG,4EAA4E;AAC5E,sEAAsE;AAEtE;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,gBAAgBC,MAAmB,EAAEC,OAAe;IAClE,MAAMC,OAAOF,OAAOG,aAAa;IACjC,IAAI,CAACF,WAAW,CAACC,MAAM,OAAO;IAC9B,MAAME,UAAUP,gBAAgB,CAACG,OAAOK,QAAQ,CAAC;IACjD,IAAID,SAAS;QACX,MAAME,OAAO,CAAC,CAAC,EAAEL,QAAQ,OA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B,CAAC,CAAC,EAAEP,QAAQ,OAAO,EAAEC,KAAK,SAAS,EAAE2B,MAAMtB,EAAE,CAAC,UAAU,EAAEsB,MAAMrB,SAAS,CAAC,KAAK,CAAC,GAChF;QACJuB,OAAOvC,WAAWC,MAAM6B,YAAY,EAAE;YAAErB;YAASC;QAAK;IACxD;AACF;AAEA;;;;CAIC,GACD,OAAO,SAAS8B,qBAAqB/B,OAAe;IAClD,OAAO,GAAGT,WAAWC,MAAMwC,cAAc,EAAE;QAAEhC;IAAQ,GAAG,MAAM,CAAC;AACjE"}
@@ -18,7 +18,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
18
18
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
19
  import { PLATFORM_BRAND_NAME } from "@aglyn/aglyn";
20
20
  import { PageHeaderRecord } from "@aglyn/aglyn/app-utils/page-header-record-context";
21
- import { mdiAlertCircle, mdiCheckCircle, mdiChevronDown, mdiClockOutline, mdiMinusCircleOutline } from "@aglyn/shared-data-mdi";
21
+ import { mdiAlertCircle, mdiCheckCircle, mdiChevronDown, mdiClockOutline, mdiMinusCircleOutline, mdiPauseCircle } from "@aglyn/shared-data-mdi";
22
22
  import { AppLink, MdiIcon } from "@aglyn/shared-ui-jsx";
23
23
  import { SITE_LIVE_NOTICE_BODY, SITE_LIVE_NOTICE_TITLE, SiteLiveNotice } from "@aglyn/shared-ui-jsx/components/site-live-notice.component";
24
24
  import { useUser } from "@aglyn/tenant-feature-instance";
@@ -30,7 +30,7 @@ import { aiSiteStartAnswersFromInputs } from "../model/ai-site-start.js";
30
30
  import { AiSiteStartCard } from "./ai-site-start-card.component.js";
31
31
  import { AI_JOB_TERMINAL_STATUSES } from "../model/ai-jobs.types.js";
32
32
  import { followAiJobEvents } from "./ai-job-events.js";
33
- import { aiSiteBuildDoneLinks } from "./ai-job-links.js";
33
+ import { aiCreditsBillingHref, aiSiteBuildDoneLinks } from "./ai-job-links.js";
34
34
  import { AiJobPlan } from "./ai-job-plan.component.js";
35
35
  import { aiBuildCanRetry } from "../model/ai-build-progress.js";
36
36
  import { resumeAiJobRequest } from "./ai-job-requests.js";
@@ -122,6 +122,12 @@ const ROW_ICON = {
122
122
  path: mdiMinusCircleOutline.path,
123
123
  color: 'text.disabled',
124
124
  label: 'Not built'
125
+ },
126
+ // Paused by the meter (AGL-3660): no spinner — it is not running.
127
+ paused: {
128
+ path: mdiPauseCircle.path,
129
+ color: 'warning.main',
130
+ label: 'Paused'
125
131
  }
126
132
  };
127
133
  function RowIcon({ state }) {
@@ -339,6 +345,8 @@ export function AiSiteBuildPage({ hostId, segments, basePath }) {
339
345
  };
340
346
  const sitePublish = ready.kind === 'site' && phase === 'done' ? (_ready_sitePublish = ready.sitePublish) != null ? _ready_sitePublish : null : null;
341
347
  const liveUrl = sitePublish && sitePublish.published.length > 0 ? sitePublish.liveUrl : null;
348
+ // Paused by the meter (AGL-3660): out of credits or at a cap, carried on by Resume.
349
+ const paused = ready.status === 'needs_input';
342
350
  const retryRefusal = (_ready_review = ready.review) == null ? void 0 : _ready_review.retryRefusal;
343
351
  const buildRetry = aiBuildCanRetry(ready);
344
352
  const canRetry = phase === 'stopped' && ((_ready_review1 = ready.review) == null ? void 0 : _ready_review1.reason) === 'doctrine' || buildRetry;
@@ -570,7 +578,37 @@ export function AiSiteBuildPage({ hostId, segments, basePath }) {
570
578
  })
571
579
  ]
572
580
  }),
573
- (phase === 'stopped' || phase === 'failed' || phase === 'canceled') && /*#__PURE__*/ _jsxs(Stack, {
581
+ paused && // Paused by the meter (AGL-3660): the way to more credits — the
582
+ // workspace's own Billing page, where plans and the AI add-on are
583
+ // sold — and Resume, which carries on this same job from its paused
584
+ // step once credits are there again.
585
+ /*#__PURE__*/ _jsxs(Stack, {
586
+ direction: {
587
+ xs: 'column',
588
+ sm: 'row'
589
+ },
590
+ spacing: 2,
591
+ sx: {
592
+ alignItems: {
593
+ sm: 'center'
594
+ }
595
+ },
596
+ children: [
597
+ /*#__PURE__*/ _jsx(Button, {
598
+ variant: "contained",
599
+ disabled: busy,
600
+ onClick: ()=>void confirmPlan(ready),
601
+ children: busy ? 'Resuming…' : 'Resume'
602
+ }),
603
+ orgSlug ? /*#__PURE__*/ _jsx(Button, {
604
+ variant: "outlined",
605
+ component: AppLink,
606
+ href: aiCreditsBillingHref(orgSlug),
607
+ children: 'Get more AI credits'
608
+ }) : null
609
+ ]
610
+ }),
611
+ !paused && (phase === 'stopped' || phase === 'failed' || phase === 'canceled') && /*#__PURE__*/ _jsxs(Stack, {
574
612
  spacing: 1,
575
613
  children: [
576
614
  retryRefusal && /*#__PURE__*/ _jsx(Typography, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-site-build-page.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 { PLATFORM_BRAND_NAME } from '@aglyn/aglyn'\nimport { PageHeaderRecord } from '@aglyn/aglyn/app-utils/page-header-record-context'\nimport type { ConsolePluginPageProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport {\n mdiAlertCircle,\n mdiCheckCircle,\n mdiChevronDown,\n mdiClockOutline,\n mdiMinusCircleOutline,\n} from '@aglyn/shared-data-mdi'\nimport { AppLink, MdiIcon } from '@aglyn/shared-ui-jsx'\nimport {\n SITE_LIVE_NOTICE_BODY,\n SITE_LIVE_NOTICE_TITLE,\n SiteLiveNotice,\n} from '@aglyn/shared-ui-jsx/components/site-live-notice.component'\nimport type { MaybeTokenSource } from '@aglyn/shared-util-http/authorized-token'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Accordion,\n AccordionDetails,\n AccordionSummary,\n Alert,\n Box,\n Button,\n Card,\n CircularProgress,\n Container,\n LinearProgress,\n Stack,\n Typography,\n} from '@mui/material'\nimport { type ReactNode, useCallback, useEffect, useRef, useState } from 'react'\nimport {\n aiJobPageCopy,\n aiSiteBuildCreditsLine,\n aiSiteBuildFraction,\n aiSiteBuildPhase,\n aiSiteBuildRows,\n type AiSiteBuildRowState,\n} from '../model/ai-site-build-progress'\nimport { aiJobRefundCopy, aiSiteStarterFallbackOffered } from '../model/ai-job-failure-copy'\nimport { aiSiteStartAnswersFromInputs } from '../model/ai-site-start'\nimport { AiSiteStartCard } from './ai-site-start-card.component'\nimport { AI_JOB_TERMINAL_STATUSES, type AiJobSummary } from '../model/ai-jobs.types'\nimport { followAiJobEvents } from './ai-job-events'\nimport { aiSiteBuildDoneLinks } from './ai-job-links'\nimport { AiJobPlan } from './ai-job-plan.component'\nimport { aiBuildCanRetry } from '../model/ai-build-progress'\nimport { resumeAiJobRequest } from './ai-job-requests'\nimport { useAiJobSite } from './ai-job-site'\nimport { AiSiteStarterFallback } from './ai-site-starter-fallback.component'\n\n/**\n * \"Building your site\" (AGL-3594): one job's page, at `/ai-jobs/{jobId}`\n * under its site — where the guided start sends a person the moment they\n * plan a site, and where a notification about that job opens.\n *\n * A guided site start confirms its own plan (`autoConfirm`), so there is no\n * approval to make here: the page says what is happening, step by step, live\n * from the job's events route; shows what is being built; and, when the job\n * ends, leads with the next thing to do — the live site and the pages to\n * edit, or, where it stopped, the plain sentence for why and what to do\n * about it. It is linkable and survives a reload, because it reads the job by\n * the id in its own address under the site's own route.\n *\n * Every wait ends (AGL-3596): a site that cannot be read, a job the route\n * does not know, a route that fails, and a first state that never arrives\n * each end on a sentence instead of a spinner.\n *\n * Mounted by `AiJobsPage`, the plugin's unlisted `/ai-jobs` route: no tab on\n * the site's strip, an address under it.\n */\n\n/** How long the job's first state may take before the page says it could not be loaded. */\nexport const AI_JOB_FIRST_STATE_TIMEOUT_MS = 20_000\n\n/**\n * One job, followed by id: its latest summary; `null` while the first state\n * is out; `'missing'` when the route says there is no such job for this\n * reader; `'error'` when the route failed or no state arrived in time.\n */\nexport type AiJobByIdState = AiJobSummary | 'missing' | 'error' | null\n\n/** Follows one job by id. `retry` follows it again after a `'missing'` or `'error'`. */\nexport function useAiJobById(\n user: MaybeTokenSource,\n orgId: string | null,\n jobId: string | null,\n): [AiJobByIdState, (job: AiJobSummary) => void, () => void] {\n const userRef = useRef(user)\n userRef.current = user\n const [job, setJob] = useState<AiJobByIdState>(null)\n const [attempt, setAttempt] = useState(0)\n const status = job && typeof job === 'object' ? job.status : null\n // Followed until the job ENDS (AGL-3596), not until it first stops: a guided\n // start parks on its plan for the instant it takes to confirm it, and a page\n // that stopped following there showed that park — the plan's 13 credits and\n // \"the plan is ready\" — after the job had built, spent and failed.\n const moving = status === null || !AI_JOB_TERMINAL_STATUSES.includes(status)\n useEffect(() => {\n if (!orgId || !jobId || !moving) return undefined\n const controller = new AbortController()\n let heard = false\n const timer = setTimeout(() => {\n if (!heard) setJob((current) => current ?? 'error')\n }, AI_JOB_FIRST_STATE_TIMEOUT_MS)\n void followAiJobEvents(() => userRef.current, orgId, jobId, controller.signal, (next) => {\n heard = true\n setJob(next)\n }).then((end) => {\n if (heard || controller.signal.aborted) return\n const unheard: AiJobByIdState = end === 'not-found' ? 'missing' : 'error'\n setJob((current) => (current && typeof current === 'object' ? current : unheard))\n })\n return () => {\n clearTimeout(timer)\n controller.abort()\n }\n }, [orgId, jobId, moving, attempt])\n const retry = useCallback(() => {\n setJob(null)\n setAttempt((count) => count + 1)\n }, [])\n return [job, setJob, retry]\n}\n\nconst ROW_ICON: Readonly<Record<Exclude<AiSiteBuildRowState, 'active'>, { path: string; color: string; label: string }>> = {\n done: { path: mdiCheckCircle.path, color: 'success.main', label: 'Done' },\n waiting: { path: mdiClockOutline.path, color: 'text.disabled', label: 'Waiting' },\n failed: { path: mdiAlertCircle.path, color: 'error.main', label: 'Couldn’t be built' },\n skipped: { path: mdiMinusCircleOutline.path, color: 'text.disabled', label: 'Not built' },\n}\n\nfunction RowIcon({ state }: { state: AiSiteBuildRowState }) {\n if (state === 'active') {\n return <CircularProgress size={20} aria-label=\"In progress\" />\n }\n const icon = ROW_ICON[state]\n return (\n <Box component=\"span\" role=\"img\" aria-label={icon.label} sx={{ color: icon.color, display: 'inline-flex', fontSize: (theme) => theme.spacing(2.5) }}>\n <MdiIcon path={icon.path} aria-hidden />\n </Box>\n )\n}\n\n/** The page's frame: the site's name over the heading and its sentence. */\n/** \"0:42\", \"3:05\": how long the active row has been running, from when it started or was first seen. */\nfunction useElapsed(key: string | null, startedAt: string | null | undefined): string | null {\n const [now, setNow] = useState(() => Date.now())\n const seen = useRef<{ key: string | null; at: number }>({ key: null, at: Date.now() })\n if (seen.current.key !== key) seen.current = { key, at: Date.now() }\n useEffect(() => {\n if (!key) return\n const timer = setInterval(() => setNow(Date.now()), 1000)\n return () => clearInterval(timer)\n }, [key])\n if (!key) return null\n const started = startedAt ? Date.parse(startedAt) : NaN\n const from = Number.isFinite(started) ? Math.min(started, seen.current.at) : seen.current.at\n const seconds = Math.max(0, Math.floor((now - from) / 1000))\n return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')}`\n}\n\nfunction Frame({\n siteName,\n heading,\n lede,\n children,\n}: {\n siteName?: string\n /** Left out when the content leads with a heading of its own. */\n heading?: string\n lede?: string\n children?: ReactNode\n}) {\n return (\n <Container maxWidth=\"sm\" sx={{ py: { xs: 3, sm: 5 }, px: { xs: 2, sm: 3 } }}>\n <Stack spacing={4}>\n <Stack spacing={1}>\n {siteName ? (\n <Typography variant=\"overline\" color=\"text.secondary\">\n {siteName}\n </Typography>\n ) : null}\n {heading ? (\n <Typography variant=\"h4\" component=\"h1\">\n {heading}\n </Typography>\n ) : null}\n {lede ? (\n <Typography variant=\"body1\" color=\"text.secondary\">\n {lede}\n </Typography>\n ) : null}\n </Stack>\n {children}\n </Stack>\n </Container>\n )\n}\n\nexport function AiSiteBuildPage({ hostId, segments, basePath }: ConsolePluginPageProps) {\n const { data: user } = useUser()\n const jobId = segments?.[0] ? decodeURIComponent(String(segments[0])) : null\n const orgSlug = (basePath ?? '').split('/')[1] ?? ''\n // `/{orgSlug}/hosts/{subdomain}/ai-jobs`: the site's subdomain, which a console URL names it by.\n const hostSubdomain = (basePath ?? '').split('/')[3] || null\n const site = useAiJobSite(hostId)\n const orgId = site.status === 'ready' ? site.orgId : null\n const siteName = site.status === 'ready' ? site.name : undefined\n\n const [job, setJob, retry] = useAiJobById(user, orgId, jobId)\n const [busy, setBusy] = useState(false)\n const [notice, setNotice] = useState<string | null>(null)\n // A failed guided start's Try again reopens its questions, filled in (AGL-3596);\n // `?retry=1` — what the AI jobs drawer links — opens them on arrival.\n const [retrying, setRetrying] = useState(\n () => typeof window !== 'undefined' && new URLSearchParams(window.location.search).get('retry') === '1',\n )\n const tryAgain = useCallback(async () => {\n if (!orgId || !job || typeof job !== 'object') return\n setBusy(true)\n setNotice(null)\n // A finished build tries again only what failed (AGL-3616).\n const decision = await resumeAiJobRequest(\n user,\n orgId,\n job,\n aiBuildCanRetry(job) ? { retry: 'failed-items' } : {},\n )\n if (decision.job) setJob(decision.job)\n if (decision.error) setNotice(decision.error)\n setBusy(false)\n }, [orgId, job, user, setJob])\n const confirmPlan = useCallback(\n async (target: AiJobSummary, options: { publish?: boolean } = {}) => {\n if (!orgId) return\n setBusy(true)\n setNotice(null)\n const decision = await resumeAiJobRequest(user, orgId, target, options)\n if (decision.job) setJob(decision.job)\n if (decision.error) setNotice(decision.error)\n setBusy(false)\n },\n [orgId, user, setJob],\n )\n\n const ready = job && typeof job === 'object' ? job : null\n const copy = ready ? aiJobPageCopy(ready, PLATFORM_BRAND_NAME) : null\n // The active row's running time, read before any early return (a hook).\n const liveRow =\n ready && aiSiteBuildPhase(ready) === 'working'\n ? (aiSiteBuildRows(ready).find((row) => row.state === 'active') ?? null)\n : null\n const elapsed = useElapsed(liveRow ? `${ready?.id}:${liveRow.id}` : null, liveRow?.startedAt)\n // The shell's header names the job's page as the page does, and its trail\n // walks back to the site's AI jobs.\n const record = <PageHeaderRecord title={copy?.heading} />\n\n if (site.status === 'error') {\n return (\n <Frame heading=\"This site could not be read\">\n <Alert severity=\"warning\">\n {'The site this job belongs to could not be loaded. Check your connection and reload the page.'}\n </Alert>\n </Frame>\n )\n }\n if (job === 'missing') {\n return (\n <Frame siteName={siteName} heading=\"This job could not be found\">\n <Alert severity=\"info\">{'It may belong to another workspace, or it may have expired.'}</Alert>\n {basePath ? (\n <Box>\n <Button variant=\"outlined\" component={AppLink} href={basePath}>\n {'See this site’s AI jobs'}\n </Button>\n </Box>\n ) : null}\n </Frame>\n )\n }\n if (job === 'error') {\n return (\n <Frame siteName={siteName} heading=\"This job could not be loaded\">\n <Alert\n severity=\"warning\"\n action={\n <Button color=\"inherit\" size=\"small\" onClick={retry}>\n {'Try again'}\n </Button>\n }\n >\n {'Something went wrong reading it. It may still be running: try again in a moment.'}\n </Alert>\n </Frame>\n )\n }\n if (!ready || !copy) {\n return (\n <Frame siteName={siteName} heading=\"Building your site\">\n <Stack sx={{ alignItems: 'center', py: 4 }}>\n <CircularProgress aria-label=\"Loading the job\" />\n </Stack>\n </Frame>\n )\n }\n\n const phase = aiSiteBuildPhase(ready)\n const rows = aiSiteBuildRows(ready)\n const fraction = aiSiteBuildFraction(rows)\n const activeRow = phase === 'working' ? (rows.find((row) => row.state === 'active') ?? null) : null\n const credits = aiSiteBuildCreditsLine(ready)\n const links = phase === 'done' ? aiSiteBuildDoneLinks(ready, orgSlug) : { view: null, pages: null }\n const sitePublish = ready.kind === 'site' && phase === 'done' ? (ready.sitePublish ?? null) : null\n const liveUrl = sitePublish && sitePublish.published.length > 0 ? sitePublish.liveUrl : null\n const retryRefusal = ready.review?.retryRefusal\n const buildRetry = aiBuildCanRetry(ready)\n const canRetry = (phase === 'stopped' && ready.review?.reason === 'doctrine') || buildRetry\n const buildPlanWaiting = ready.kind === 'build' && phase === 'stopped' && ready.review?.reason === 'plan'\n // A guided start that ended without building its site starts over from its\n // own answers, as a fresh job: the questions reopen filled in.\n const restartAnswers =\n ready.kind === 'site' && (phase === 'failed' || phase === 'canceled')\n ? aiSiteStartAnswersFromInputs(ready.siteInputs)\n : null\n const refund = phase === 'failed' || phase === 'stopped' || phase === 'canceled' ? aiJobRefundCopy(ready) : null\n // A whole site put live says so in the words every new site goes live in\n // (AGL-3663); a partial build or a page left a draft keeps its own account.\n const liveNotice =\n liveUrl !== null &&\n !sitePublish?.drafts.length &&\n copy.heading === SITE_LIVE_NOTICE_TITLE &&\n copy.lede === SITE_LIVE_NOTICE_BODY\n\n return (\n <Frame siteName={siteName} {...(liveNotice ? {} : { heading: copy.heading, lede: copy.lede })}>\n {record}\n {liveNotice && <SiteLiveNotice liveUrl={liveUrl} pagesHref={links.pages} headingComponent=\"h1\" />}\n {notice && <Alert severity=\"warning\">{notice}</Alert>}\n <Card variant=\"outlined\" sx={{ borderRadius: 2 }}>\n {phase === 'working' &&\n (fraction !== null ? (\n <LinearProgress\n variant=\"determinate\"\n value={Math.round(fraction * 100)}\n aria-label={`Building: ${rows.filter((row) => row.state === 'done').length} of ${rows.length} steps done`}\n />\n ) : (\n <LinearProgress aria-label=\"Building\" />\n ))}\n <Box component=\"ol\" aria-label=\"Progress\" sx={{ listStyle: 'none', m: 0, p: { xs: 2, sm: 3 } }}>\n <Stack spacing={2}>\n {rows.map((row) => (\n <Stack component=\"li\" key={row.id} direction=\"row\" spacing={2} sx={{ alignItems: 'flex-start' }}>\n <Box sx={{ width: (theme) => theme.spacing(3), display: 'flex', justifyContent: 'center' }}>\n <RowIcon state={row.state} />\n </Box>\n <Box sx={{ flex: 1, minWidth: 0 }}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'baseline', justifyContent: 'space-between' }}>\n <Typography\n variant=\"body1\"\n color={row.state === 'waiting' || row.state === 'skipped' ? 'text.secondary' : 'text.primary'}\n >\n {row.label}\n </Typography>\n {row.id === activeRow?.id && elapsed ? (\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ fontVariantNumeric: 'tabular-nums' }}>\n {elapsed}\n </Typography>\n ) : typeof row.credits === 'number' && row.credits > 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ whiteSpace: 'nowrap' }}>\n {`${row.credits} ${row.credits === 1 ? 'credit' : 'credits'}`}\n </Typography>\n ) : null}\n </Stack>\n {row.id === activeRow?.id && row.hint ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {row.hint}\n </Typography>\n ) : null}\n {row.sections?.length && (row.state === 'active' || row.state === 'done') ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`${row.state === 'active' ? 'Writing' : 'Wrote'}: ${row.sections.join(', ')}`}\n </Typography>\n ) : null}\n {/* A build item's failure, note or refund (AGL-3616). */}\n {row.detail ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {row.detail}\n </Typography>\n ) : null}\n </Box>\n </Stack>\n ))}\n </Stack>\n </Box>\n </Card>\n {refund && (ready.refundedCredits ?? 0) > 0 ? (\n <Alert severity=\"info\">{refund}</Alert>\n ) : credits ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {credits}\n </Typography>\n ) : null}\n {retrying && restartAnswers && hostId ? (\n <AiSiteStartCard\n hostId={hostId}\n orgId={orgId ?? undefined}\n orgSlug={orgSlug}\n host={hostSubdomain}\n initialAnswers={restartAnswers}\n startBlank={() => setRetrying(false)}\n leave={() => setRetrying(false)}\n />\n ) : null}\n {buildPlanWaiting ? (\n // A build's plan, confirmed here as in the chat (AGL-3616).\n <AiJobPlan job={ready} busy={busy} onResume={(target, options) => void confirmPlan(target, options)} />\n ) : null}\n {sitePublish && sitePublish.drafts.length > 0 && (\n // The pages the publish left as drafts, each with its plain reason;\n // Edit your pages is where they are fixed and published.\n <Alert severity=\"warning\">\n <Typography variant=\"body2\" sx={{ mb: 1 }}>\n {sitePublish.drafts.length === 1 ? 'This page stayed a draft:' : 'These pages stayed drafts:'}\n </Typography>\n <Box component=\"ul\" sx={{ m: 0, pl: 2.5 }}>\n {sitePublish.drafts.map((draft) => (\n <li key={draft.id}>\n <Typography variant=\"body2\">{`${draft.label}: ${draft.reason}`}</Typography>\n </li>\n ))}\n </Box>\n <Typography variant=\"body2\" sx={{ mt: 1 }}>\n {'Open Edit your pages to fix and publish them.'}\n </Typography>\n </Alert>\n )}\n {phase === 'done' && buildRetry && (\n <Box>\n <Button variant=\"outlined\" disabled={busy} onClick={() => void tryAgain()}>\n {'Try again what failed'}\n </Button>\n </Box>\n )}\n {phase === 'done' && !liveNotice && (\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>\n {liveUrl ? (\n // The live site, in a tab of its own: the console stays where it is.\n <Button\n variant=\"contained\"\n size=\"large\"\n component=\"a\"\n href={liveUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n {'View your site'}\n </Button>\n ) : links.view ? (\n <Button variant=\"contained\" size=\"large\" component={AppLink} href={links.view}>\n {'View your site'}\n </Button>\n ) : null}\n {links.pages && (\n <Button variant=\"outlined\" size=\"large\" component={AppLink} href={links.pages}>\n {'Edit your pages'}\n </Button>\n )}\n </Stack>\n )}\n {(phase === 'stopped' || phase === 'failed' || phase === 'canceled') && (\n <Stack spacing={1}>\n {retryRefusal && (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {retryRefusal}\n </Typography>\n )}\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2} sx={{ alignItems: { sm: 'center' } }}>\n {restartAnswers && hostId && (\n <Button variant=\"contained\" onClick={() => setRetrying(true)}>\n {'Try again'}\n </Button>\n )}\n {canRetry && (\n <Button\n variant=\"contained\"\n disabled={busy || Boolean(retryRefusal)}\n onClick={() => void tryAgain()}\n >\n {'Try again'}\n </Button>\n )}\n {aiSiteStarterFallbackOffered(ready) && user ? <AiSiteStarterFallback job={ready} user={user} /> : null}\n </Stack>\n </Stack>\n )}\n {ready.plan && ready.plan.screens.length > 0 && (\n <Accordion\n // Open while the site is built, so the plan is in view as each part of it is written.\n defaultExpanded={phase === 'working'}\n variant=\"outlined\"\n disableGutters\n sx={{ borderRadius: 2, '&::before': { display: 'none' } }}\n >\n <AccordionSummary expandIcon={<MdiIcon path={mdiChevronDown.path} />}>\n <Typography variant=\"subtitle1\">{'What we’re building'}</Typography>\n </AccordionSummary>\n <AccordionDetails>\n <Stack component=\"ul\" spacing={1.5} sx={{ m: 0, pl: 2.5 }}>\n {ready.plan.screens.map((screen, index) => (\n <Box component=\"li\" key={`${screen.slug}-${index}`}>\n <Typography variant=\"body1\">{`${screen.title} — ${screen.slug}`}</Typography>\n {screen.sections.length > 0 && (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {screen.sections.map((section) => section.name).join(', ')}\n </Typography>\n )}\n </Box>\n ))}\n </Stack>\n </AccordionDetails>\n </Accordion>\n )}\n </Frame>\n )\n}\n\nexport default AiSiteBuildPage\n"],"names":["PLATFORM_BRAND_NAME","PageHeaderRecord","mdiAlertCircle","mdiCheckCircle","mdiChevronDown","mdiClockOutline","mdiMinusCircleOutline","AppLink","MdiIcon","SITE_LIVE_NOTICE_BODY","SITE_LIVE_NOTICE_TITLE","SiteLiveNotice","useUser","Accordion","AccordionDetails","AccordionSummary","Alert","Box","Button","Card","CircularProgress","Container","LinearProgress","Stack","Typography","useCallback","useEffect","useRef","useState","aiJobPageCopy","aiSiteBuildCreditsLine","aiSiteBuildFraction","aiSiteBuildPhase","aiSiteBuildRows","aiJobRefundCopy","aiSiteStarterFallbackOffered","aiSiteStartAnswersFromInputs","AiSiteStartCard","AI_JOB_TERMINAL_STATUSES","followAiJobEvents","aiSiteBuildDoneLinks","AiJobPlan","aiBuildCanRetry","resumeAiJobRequest","useAiJobSite","AiSiteStarterFallback","AI_JOB_FIRST_STATE_TIMEOUT_MS","useAiJobById","user","orgId","jobId","userRef","current","job","setJob","attempt","setAttempt","status","moving","includes","undefined","controller","AbortController","heard","timer","setTimeout","signal","next","then","end","aborted","unheard","clearTimeout","abort","retry","count","ROW_ICON","done","path","color","label","waiting","failed","skipped","RowIcon","state","size","aria-label","icon","component","role","sx","display","fontSize","theme","spacing","aria-hidden","useElapsed","key","startedAt","now","setNow","Date","seen","at","setInterval","clearInterval","started","parse","NaN","from","Number","isFinite","Math","min","seconds","max","floor","String","padStart","Frame","siteName","heading","lede","children","maxWidth","py","xs","sm","px","variant","AiSiteBuildPage","hostId","segments","basePath","rows","ready","data","decodeURIComponent","orgSlug","split","hostSubdomain","site","name","busy","setBusy","notice","setNotice","retrying","setRetrying","window","URLSearchParams","location","search","get","tryAgain","decision","error","confirmPlan","target","options","copy","liveRow","find","row","elapsed","id","record","title","severity","href","action","onClick","alignItems","phase","fraction","activeRow","credits","links","view","pages","sitePublish","kind","liveUrl","published","length","retryRefusal","review","buildRetry","canRetry","reason","buildPlanWaiting","restartAnswers","siteInputs","refund","liveNotice","drafts","pagesHref","headingComponent","borderRadius","value","round","filter","listStyle","m","p","map","direction","width","justifyContent","flex","minWidth","fontVariantNumeric","whiteSpace","hint","sections","join","detail","refundedCredits","host","initialAnswers","startBlank","leave","onResume","mb","pl","draft","li","mt","disabled","rel","Boolean","plan","screens","defaultExpanded","disableGutters","expandIcon","screen","index","slug","section"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;AAEA,SAASA,mBAAmB,QAAQ,eAAc;AAClD,SAASC,gBAAgB,QAAQ,oDAAmD;AAEpF,SACEC,cAAc,EACdC,cAAc,EACdC,cAAc,EACdC,eAAe,EACfC,qBAAqB,QAChB,yBAAwB;AAC/B,SAASC,OAAO,EAAEC,OAAO,QAAQ,uBAAsB;AACvD,SACEC,qBAAqB,EACrBC,sBAAsB,EACtBC,cAAc,QACT,6DAA4D;AAEnE,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,SAAS,EACTC,gBAAgB,EAChBC,gBAAgB,EAChBC,KAAK,EACLC,GAA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oBAAG,aAAa;wBAAE3G,SAAS;oBAAO;gBAAE;;kCAExD,KAAC7E;wBAAiB6N,0BAAY,KAACpO;4BAAQsE,MAAM1E,eAAe0E,IAAI;;kCAC9D,cAAA,KAACtD;4BAAW0G,SAAQ;sCAAa;;;kCAEnC,KAACpH;kCACC,cAAA,KAACS;4BAAMkE,WAAU;4BAAKM,SAAS;4BAAKJ,IAAI;gCAAEiH,GAAG;gCAAGqB,IAAI;4BAAI;sCACrDzF,MAAMgG,IAAI,CAACC,OAAO,CAAC3B,GAAG,CAAC,CAAC+B,QAAQC,sBAC/B,MAAC7N;oCAAIwE,WAAU;;sDACb,KAACjE;4CAAW0G,SAAQ;sDAAS,GAAG2G,OAAOrE,KAAK,CAAC,GAAG,EAAEqE,OAAOE,IAAI,EAAE;;wCAC9DF,OAAOtB,QAAQ,CAAC9B,MAAM,GAAG,mBACxB,KAACjK;4CAAW0G,SAAQ;4CAAQnD,OAAM;sDAC/B8J,OAAOtB,QAAQ,CAACT,GAAG,CAAC,CAACkC,UAAYA,QAAQjG,IAAI,EAAEyE,IAAI,CAAC;;;mCAJlC,GAAGqB,OAAOE,IAAI,CAAC,CAAC,EAAED,OAAO;;;;;;;AAelE;AAEA,eAAe3G,gBAAe"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-site-build-page.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 { PLATFORM_BRAND_NAME } from '@aglyn/aglyn'\nimport { PageHeaderRecord } from '@aglyn/aglyn/app-utils/page-header-record-context'\nimport type { ConsolePluginPageProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport {\n mdiAlertCircle,\n mdiCheckCircle,\n mdiChevronDown,\n mdiClockOutline,\n mdiMinusCircleOutline,\n mdiPauseCircle,\n} from '@aglyn/shared-data-mdi'\nimport { AppLink, MdiIcon } from '@aglyn/shared-ui-jsx'\nimport {\n SITE_LIVE_NOTICE_BODY,\n SITE_LIVE_NOTICE_TITLE,\n SiteLiveNotice,\n} from '@aglyn/shared-ui-jsx/components/site-live-notice.component'\nimport type { MaybeTokenSource } from '@aglyn/shared-util-http/authorized-token'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Accordion,\n AccordionDetails,\n AccordionSummary,\n Alert,\n Box,\n Button,\n Card,\n CircularProgress,\n Container,\n LinearProgress,\n Stack,\n Typography,\n} from '@mui/material'\nimport { type ReactNode, useCallback, useEffect, useRef, useState } from 'react'\nimport {\n aiJobPageCopy,\n aiSiteBuildCreditsLine,\n aiSiteBuildFraction,\n aiSiteBuildPhase,\n aiSiteBuildRows,\n type AiSiteBuildRowState,\n} from '../model/ai-site-build-progress'\nimport { aiJobRefundCopy, aiSiteStarterFallbackOffered } from '../model/ai-job-failure-copy'\nimport { aiSiteStartAnswersFromInputs } from '../model/ai-site-start'\nimport { AiSiteStartCard } from './ai-site-start-card.component'\nimport { AI_JOB_TERMINAL_STATUSES, type AiJobSummary } from '../model/ai-jobs.types'\nimport { followAiJobEvents } from './ai-job-events'\nimport { aiCreditsBillingHref, aiSiteBuildDoneLinks } from './ai-job-links'\nimport { AiJobPlan } from './ai-job-plan.component'\nimport { aiBuildCanRetry } from '../model/ai-build-progress'\nimport { resumeAiJobRequest } from './ai-job-requests'\nimport { useAiJobSite } from './ai-job-site'\nimport { AiSiteStarterFallback } from './ai-site-starter-fallback.component'\n\n/**\n * \"Building your site\" (AGL-3594): one job's page, at `/ai-jobs/{jobId}`\n * under its site — where the guided start sends a person the moment they\n * plan a site, and where a notification about that job opens.\n *\n * A guided site start confirms its own plan (`autoConfirm`), so there is no\n * approval to make here: the page says what is happening, step by step, live\n * from the job's events route; shows what is being built; and, when the job\n * ends, leads with the next thing to do — the live site and the pages to\n * edit, or, where it stopped, the plain sentence for why and what to do\n * about it. It is linkable and survives a reload, because it reads the job by\n * the id in its own address under the site's own route.\n *\n * Every wait ends (AGL-3596): a site that cannot be read, a job the route\n * does not know, a route that fails, and a first state that never arrives\n * each end on a sentence instead of a spinner.\n *\n * Mounted by `AiJobsPage`, the plugin's unlisted `/ai-jobs` route: no tab on\n * the site's strip, an address under it.\n */\n\n/** How long the job's first state may take before the page says it could not be loaded. */\nexport const AI_JOB_FIRST_STATE_TIMEOUT_MS = 20_000\n\n/**\n * One job, followed by id: its latest summary; `null` while the first state\n * is out; `'missing'` when the route says there is no such job for this\n * reader; `'error'` when the route failed or no state arrived in time.\n */\nexport type AiJobByIdState = AiJobSummary | 'missing' | 'error' | null\n\n/** Follows one job by id. `retry` follows it again after a `'missing'` or `'error'`. */\nexport function useAiJobById(\n user: MaybeTokenSource,\n orgId: string | null,\n jobId: string | null,\n): [AiJobByIdState, (job: AiJobSummary) => void, () => void] {\n const userRef = useRef(user)\n userRef.current = user\n const [job, setJob] = useState<AiJobByIdState>(null)\n const [attempt, setAttempt] = useState(0)\n const status = job && typeof job === 'object' ? job.status : null\n // Followed until the job ENDS (AGL-3596), not until it first stops: a guided\n // start parks on its plan for the instant it takes to confirm it, and a page\n // that stopped following there showed that park — the plan's 13 credits and\n // \"the plan is ready\" — after the job had built, spent and failed.\n const moving = status === null || !AI_JOB_TERMINAL_STATUSES.includes(status)\n useEffect(() => {\n if (!orgId || !jobId || !moving) return undefined\n const controller = new AbortController()\n let heard = false\n const timer = setTimeout(() => {\n if (!heard) setJob((current) => current ?? 'error')\n }, AI_JOB_FIRST_STATE_TIMEOUT_MS)\n void followAiJobEvents(() => userRef.current, orgId, jobId, controller.signal, (next) => {\n heard = true\n setJob(next)\n }).then((end) => {\n if (heard || controller.signal.aborted) return\n const unheard: AiJobByIdState = end === 'not-found' ? 'missing' : 'error'\n setJob((current) => (current && typeof current === 'object' ? current : unheard))\n })\n return () => {\n clearTimeout(timer)\n controller.abort()\n }\n }, [orgId, jobId, moving, attempt])\n const retry = useCallback(() => {\n setJob(null)\n setAttempt((count) => count + 1)\n }, [])\n return [job, setJob, retry]\n}\n\nconst ROW_ICON: Readonly<Record<Exclude<AiSiteBuildRowState, 'active'>, { path: string; color: string; label: string }>> = {\n done: { path: mdiCheckCircle.path, color: 'success.main', label: 'Done' },\n waiting: { path: mdiClockOutline.path, color: 'text.disabled', label: 'Waiting' },\n failed: { path: mdiAlertCircle.path, color: 'error.main', label: 'Couldn’t be built' },\n skipped: { path: mdiMinusCircleOutline.path, color: 'text.disabled', label: 'Not built' },\n // Paused by the meter (AGL-3660): no spinner — it is not running.\n paused: { path: mdiPauseCircle.path, color: 'warning.main', label: 'Paused' },\n}\n\nfunction RowIcon({ state }: { state: AiSiteBuildRowState }) {\n if (state === 'active') {\n return <CircularProgress size={20} aria-label=\"In progress\" />\n }\n const icon = ROW_ICON[state]\n return (\n <Box component=\"span\" role=\"img\" aria-label={icon.label} sx={{ color: icon.color, display: 'inline-flex', fontSize: (theme) => theme.spacing(2.5) }}>\n <MdiIcon path={icon.path} aria-hidden />\n </Box>\n )\n}\n\n/** The page's frame: the site's name over the heading and its sentence. */\n/** \"0:42\", \"3:05\": how long the active row has been running, from when it started or was first seen. */\nfunction useElapsed(key: string | null, startedAt: string | null | undefined): string | null {\n const [now, setNow] = useState(() => Date.now())\n const seen = useRef<{ key: string | null; at: number }>({ key: null, at: Date.now() })\n if (seen.current.key !== key) seen.current = { key, at: Date.now() }\n useEffect(() => {\n if (!key) return\n const timer = setInterval(() => setNow(Date.now()), 1000)\n return () => clearInterval(timer)\n }, [key])\n if (!key) return null\n const started = startedAt ? Date.parse(startedAt) : NaN\n const from = Number.isFinite(started) ? Math.min(started, seen.current.at) : seen.current.at\n const seconds = Math.max(0, Math.floor((now - from) / 1000))\n return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')}`\n}\n\nfunction Frame({\n siteName,\n heading,\n lede,\n children,\n}: {\n siteName?: string\n /** Left out when the content leads with a heading of its own. */\n heading?: string\n lede?: string\n children?: ReactNode\n}) {\n return (\n <Container maxWidth=\"sm\" sx={{ py: { xs: 3, sm: 5 }, px: { xs: 2, sm: 3 } }}>\n <Stack spacing={4}>\n <Stack spacing={1}>\n {siteName ? (\n <Typography variant=\"overline\" color=\"text.secondary\">\n {siteName}\n </Typography>\n ) : null}\n {heading ? (\n <Typography variant=\"h4\" component=\"h1\">\n {heading}\n </Typography>\n ) : null}\n {lede ? (\n <Typography variant=\"body1\" color=\"text.secondary\">\n {lede}\n </Typography>\n ) : null}\n </Stack>\n {children}\n </Stack>\n </Container>\n )\n}\n\nexport function AiSiteBuildPage({ hostId, segments, basePath }: ConsolePluginPageProps) {\n const { data: user } = useUser()\n const jobId = segments?.[0] ? decodeURIComponent(String(segments[0])) : null\n const orgSlug = (basePath ?? '').split('/')[1] ?? ''\n // `/{orgSlug}/hosts/{subdomain}/ai-jobs`: the site's subdomain, which a console URL names it by.\n const hostSubdomain = (basePath ?? '').split('/')[3] || null\n const site = useAiJobSite(hostId)\n const orgId = site.status === 'ready' ? site.orgId : null\n const siteName = site.status === 'ready' ? site.name : undefined\n\n const [job, setJob, retry] = useAiJobById(user, orgId, jobId)\n const [busy, setBusy] = useState(false)\n const [notice, setNotice] = useState<string | null>(null)\n // A failed guided start's Try again reopens its questions, filled in (AGL-3596);\n // `?retry=1` — what the AI jobs drawer links — opens them on arrival.\n const [retrying, setRetrying] = useState(\n () => typeof window !== 'undefined' && new URLSearchParams(window.location.search).get('retry') === '1',\n )\n const tryAgain = useCallback(async () => {\n if (!orgId || !job || typeof job !== 'object') return\n setBusy(true)\n setNotice(null)\n // A finished build tries again only what failed (AGL-3616).\n const decision = await resumeAiJobRequest(\n user,\n orgId,\n job,\n aiBuildCanRetry(job) ? { retry: 'failed-items' } : {},\n )\n if (decision.job) setJob(decision.job)\n if (decision.error) setNotice(decision.error)\n setBusy(false)\n }, [orgId, job, user, setJob])\n const confirmPlan = useCallback(\n async (target: AiJobSummary, options: { publish?: boolean } = {}) => {\n if (!orgId) return\n setBusy(true)\n setNotice(null)\n const decision = await resumeAiJobRequest(user, orgId, target, options)\n if (decision.job) setJob(decision.job)\n if (decision.error) setNotice(decision.error)\n setBusy(false)\n },\n [orgId, user, setJob],\n )\n\n const ready = job && typeof job === 'object' ? job : null\n const copy = ready ? aiJobPageCopy(ready, PLATFORM_BRAND_NAME) : null\n // The active row's running time, read before any early return (a hook).\n const liveRow =\n ready && aiSiteBuildPhase(ready) === 'working'\n ? (aiSiteBuildRows(ready).find((row) => row.state === 'active') ?? null)\n : null\n const elapsed = useElapsed(liveRow ? `${ready?.id}:${liveRow.id}` : null, liveRow?.startedAt)\n // The shell's header names the job's page as the page does, and its trail\n // walks back to the site's AI jobs.\n const record = <PageHeaderRecord title={copy?.heading} />\n\n if (site.status === 'error') {\n return (\n <Frame heading=\"This site could not be read\">\n <Alert severity=\"warning\">\n {'The site this job belongs to could not be loaded. Check your connection and reload the page.'}\n </Alert>\n </Frame>\n )\n }\n if (job === 'missing') {\n return (\n <Frame siteName={siteName} heading=\"This job could not be found\">\n <Alert severity=\"info\">{'It may belong to another workspace, or it may have expired.'}</Alert>\n {basePath ? (\n <Box>\n <Button variant=\"outlined\" component={AppLink} href={basePath}>\n {'See this site’s AI jobs'}\n </Button>\n </Box>\n ) : null}\n </Frame>\n )\n }\n if (job === 'error') {\n return (\n <Frame siteName={siteName} heading=\"This job could not be loaded\">\n <Alert\n severity=\"warning\"\n action={\n <Button color=\"inherit\" size=\"small\" onClick={retry}>\n {'Try again'}\n </Button>\n }\n >\n {'Something went wrong reading it. It may still be running: try again in a moment.'}\n </Alert>\n </Frame>\n )\n }\n if (!ready || !copy) {\n return (\n <Frame siteName={siteName} heading=\"Building your site\">\n <Stack sx={{ alignItems: 'center', py: 4 }}>\n <CircularProgress aria-label=\"Loading the job\" />\n </Stack>\n </Frame>\n )\n }\n\n const phase = aiSiteBuildPhase(ready)\n const rows = aiSiteBuildRows(ready)\n const fraction = aiSiteBuildFraction(rows)\n const activeRow = phase === 'working' ? (rows.find((row) => row.state === 'active') ?? null) : null\n const credits = aiSiteBuildCreditsLine(ready)\n const links = phase === 'done' ? aiSiteBuildDoneLinks(ready, orgSlug) : { view: null, pages: null }\n const sitePublish = ready.kind === 'site' && phase === 'done' ? (ready.sitePublish ?? null) : null\n const liveUrl = sitePublish && sitePublish.published.length > 0 ? sitePublish.liveUrl : null\n // Paused by the meter (AGL-3660): out of credits or at a cap, carried on by Resume.\n const paused = ready.status === 'needs_input'\n const retryRefusal = ready.review?.retryRefusal\n const buildRetry = aiBuildCanRetry(ready)\n const canRetry = (phase === 'stopped' && ready.review?.reason === 'doctrine') || buildRetry\n const buildPlanWaiting = ready.kind === 'build' && phase === 'stopped' && ready.review?.reason === 'plan'\n // A guided start that ended without building its site starts over from its\n // own answers, as a fresh job: the questions reopen filled in.\n const restartAnswers =\n ready.kind === 'site' && (phase === 'failed' || phase === 'canceled')\n ? aiSiteStartAnswersFromInputs(ready.siteInputs)\n : null\n const refund = phase === 'failed' || phase === 'stopped' || phase === 'canceled' ? aiJobRefundCopy(ready) : null\n // A whole site put live says so in the words every new site goes live in\n // (AGL-3663); a partial build or a page left a draft keeps its own account.\n const liveNotice =\n liveUrl !== null &&\n !sitePublish?.drafts.length &&\n copy.heading === SITE_LIVE_NOTICE_TITLE &&\n copy.lede === SITE_LIVE_NOTICE_BODY\n\n return (\n <Frame siteName={siteName} {...(liveNotice ? {} : { heading: copy.heading, lede: copy.lede })}>\n {record}\n {liveNotice && <SiteLiveNotice liveUrl={liveUrl} pagesHref={links.pages} headingComponent=\"h1\" />}\n {notice && <Alert severity=\"warning\">{notice}</Alert>}\n <Card variant=\"outlined\" sx={{ borderRadius: 2 }}>\n {phase === 'working' &&\n (fraction !== null ? (\n <LinearProgress\n variant=\"determinate\"\n value={Math.round(fraction * 100)}\n aria-label={`Building: ${rows.filter((row) => row.state === 'done').length} of ${rows.length} steps done`}\n />\n ) : (\n <LinearProgress aria-label=\"Building\" />\n ))}\n <Box component=\"ol\" aria-label=\"Progress\" sx={{ listStyle: 'none', m: 0, p: { xs: 2, sm: 3 } }}>\n <Stack spacing={2}>\n {rows.map((row) => (\n <Stack component=\"li\" key={row.id} direction=\"row\" spacing={2} sx={{ alignItems: 'flex-start' }}>\n <Box sx={{ width: (theme) => theme.spacing(3), display: 'flex', justifyContent: 'center' }}>\n <RowIcon state={row.state} />\n </Box>\n <Box sx={{ flex: 1, minWidth: 0 }}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'baseline', justifyContent: 'space-between' }}>\n <Typography\n variant=\"body1\"\n color={row.state === 'waiting' || row.state === 'skipped' ? 'text.secondary' : 'text.primary'}\n >\n {row.label}\n </Typography>\n {row.id === activeRow?.id && elapsed ? (\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ fontVariantNumeric: 'tabular-nums' }}>\n {elapsed}\n </Typography>\n ) : typeof row.credits === 'number' && row.credits > 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ whiteSpace: 'nowrap' }}>\n {`${row.credits} ${row.credits === 1 ? 'credit' : 'credits'}`}\n </Typography>\n ) : null}\n </Stack>\n {row.id === activeRow?.id && row.hint ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {row.hint}\n </Typography>\n ) : null}\n {row.sections?.length && (row.state === 'active' || row.state === 'done') ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`${row.state === 'active' ? 'Writing' : 'Wrote'}: ${row.sections.join(', ')}`}\n </Typography>\n ) : null}\n {/* A build item's failure, note or refund (AGL-3616). */}\n {row.detail ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {row.detail}\n </Typography>\n ) : null}\n </Box>\n </Stack>\n ))}\n </Stack>\n </Box>\n </Card>\n {refund && (ready.refundedCredits ?? 0) > 0 ? (\n <Alert severity=\"info\">{refund}</Alert>\n ) : credits ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {credits}\n </Typography>\n ) : null}\n {retrying && restartAnswers && hostId ? (\n <AiSiteStartCard\n hostId={hostId}\n orgId={orgId ?? undefined}\n orgSlug={orgSlug}\n host={hostSubdomain}\n initialAnswers={restartAnswers}\n startBlank={() => setRetrying(false)}\n leave={() => setRetrying(false)}\n />\n ) : null}\n {buildPlanWaiting ? (\n // A build's plan, confirmed here as in the chat (AGL-3616).\n <AiJobPlan job={ready} busy={busy} onResume={(target, options) => void confirmPlan(target, options)} />\n ) : null}\n {sitePublish && sitePublish.drafts.length > 0 && (\n // The pages the publish left as drafts, each with its plain reason;\n // Edit your pages is where they are fixed and published.\n <Alert severity=\"warning\">\n <Typography variant=\"body2\" sx={{ mb: 1 }}>\n {sitePublish.drafts.length === 1 ? 'This page stayed a draft:' : 'These pages stayed drafts:'}\n </Typography>\n <Box component=\"ul\" sx={{ m: 0, pl: 2.5 }}>\n {sitePublish.drafts.map((draft) => (\n <li key={draft.id}>\n <Typography variant=\"body2\">{`${draft.label}: ${draft.reason}`}</Typography>\n </li>\n ))}\n </Box>\n <Typography variant=\"body2\" sx={{ mt: 1 }}>\n {'Open Edit your pages to fix and publish them.'}\n </Typography>\n </Alert>\n )}\n {phase === 'done' && buildRetry && (\n <Box>\n <Button variant=\"outlined\" disabled={busy} onClick={() => void tryAgain()}>\n {'Try again what failed'}\n </Button>\n </Box>\n )}\n {phase === 'done' && !liveNotice && (\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>\n {liveUrl ? (\n // The live site, in a tab of its own: the console stays where it is.\n <Button\n variant=\"contained\"\n size=\"large\"\n component=\"a\"\n href={liveUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n {'View your site'}\n </Button>\n ) : links.view ? (\n <Button variant=\"contained\" size=\"large\" component={AppLink} href={links.view}>\n {'View your site'}\n </Button>\n ) : null}\n {links.pages && (\n <Button variant=\"outlined\" size=\"large\" component={AppLink} href={links.pages}>\n {'Edit your pages'}\n </Button>\n )}\n </Stack>\n )}\n {paused && (\n // Paused by the meter (AGL-3660): the way to more credits — the\n // workspace's own Billing page, where plans and the AI add-on are\n // sold — and Resume, which carries on this same job from its paused\n // step once credits are there again.\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2} sx={{ alignItems: { sm: 'center' } }}>\n <Button variant=\"contained\" disabled={busy} onClick={() => void confirmPlan(ready)}>\n {busy ? 'Resuming…' : 'Resume'}\n </Button>\n {orgSlug ? (\n <Button variant=\"outlined\" component={AppLink} href={aiCreditsBillingHref(orgSlug)}>\n {'Get more AI credits'}\n </Button>\n ) : null}\n </Stack>\n )}\n {!paused && (phase === 'stopped' || phase === 'failed' || phase === 'canceled') && (\n <Stack spacing={1}>\n {retryRefusal && (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {retryRefusal}\n </Typography>\n )}\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2} sx={{ alignItems: { sm: 'center' } }}>\n {restartAnswers && hostId && (\n <Button variant=\"contained\" onClick={() => setRetrying(true)}>\n {'Try again'}\n </Button>\n )}\n {canRetry && (\n <Button\n variant=\"contained\"\n disabled={busy || Boolean(retryRefusal)}\n onClick={() => void tryAgain()}\n >\n {'Try again'}\n </Button>\n )}\n {aiSiteStarterFallbackOffered(ready) && user ? <AiSiteStarterFallback job={ready} user={user} /> : null}\n </Stack>\n </Stack>\n )}\n {ready.plan && ready.plan.screens.length > 0 && (\n <Accordion\n // Open while the site is built, so the plan is in view as each part of it is written.\n defaultExpanded={phase === 'working'}\n variant=\"outlined\"\n disableGutters\n sx={{ borderRadius: 2, '&::before': { display: 'none' } }}\n >\n <AccordionSummary expandIcon={<MdiIcon path={mdiChevronDown.path} />}>\n <Typography variant=\"subtitle1\">{'What we’re building'}</Typography>\n </AccordionSummary>\n <AccordionDetails>\n <Stack component=\"ul\" spacing={1.5} sx={{ m: 0, pl: 2.5 }}>\n {ready.plan.screens.map((screen, index) => (\n <Box component=\"li\" key={`${screen.slug}-${index}`}>\n <Typography variant=\"body1\">{`${screen.title} — ${screen.slug}`}</Typography>\n {screen.sections.length > 0 && (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {screen.sections.map((section) => section.name).join(', ')}\n </Typography>\n )}\n </Box>\n ))}\n </Stack>\n </AccordionDetails>\n </Accordion>\n )}\n </Frame>\n )\n}\n\nexport default AiSiteBuildPage\n"],"names":["PLATFORM_BRAND_NAME","PageHeaderRecord","mdiAlertCircle","mdiCheckCircle","mdiChevronDown","mdiClockOutline","mdiMinusCircleOutline","mdiPauseCircle","AppLink","MdiIcon","SITE_LIVE_NOTICE_BODY","SITE_LIVE_NOTICE_TITLE","SiteLiveNotice","useUser","Accordion","AccordionDetails","AccordionSummary","Alert","Box","Button","Card","CircularProgress","Container","LinearProgress","Stack","Typography","useCallback","useEffect","useRef","useState","aiJobPageCopy","aiSiteBuildCreditsLine","aiSiteBuildFraction","aiSiteBuildPhase","aiSiteBuildRows","aiJobRefundCopy","aiSiteStarterFallbackOffered","aiSiteStartAnswersFromInputs","AiSiteStartCard","AI_JOB_TERMINAL_STATUSES","followAiJobEvents","aiCreditsBillingHref","aiSiteBuildDoneLinks","AiJobPlan","aiBuildCanRetry","resumeAiJobRequest","useAiJobSite","AiSiteStarterFallback","AI_JOB_FIRST_STATE_TIMEOUT_MS","useAiJobById","user","orgId","jobId","userRef","current","job","setJob","attempt","setAttempt","status","moving","includes","undefined","controller","AbortController","heard","timer","setTimeout","signal","next","then","end","aborted","unheard","clearTimeout","abort","retry","count","ROW_ICON","done","path","color","label","waiting","failed","skipped","paused","RowIcon","state","size","aria-label","icon","component","role","sx","display","fontSize","theme","spacing","aria-hidden","useElapsed","key","startedAt","now","setNow","Date","seen","at","setInterval","clearInterval","started","parse","NaN","from","Number","isFinite","Math","min","seconds","max","floor","String","padStart","Frame","siteName","heading","lede","children","maxWidth","py","xs","sm","px","variant","AiSiteBuildPage","hostId","segments","basePath","rows","ready","data","decodeURIComponent","orgSlug","split","hostSubdomain","site","name","busy","setBusy","notice","setNotice","retrying","setRetrying","window","URLSearchParams","location","search","get","tryAgain","decision","error","confirmPlan","target","options","copy","liveRow","find","row","elapsed","id","record","title","severity","href","action","onClick","alignItems","phase","fraction","activeRow","credits","links","view","pages","sitePublish","kind","liveUrl","published","length","retryRefusal","review","buildRetry","canRetry","reason","buildPlanWaiting","restartAnswers","siteInputs","refund","liveNotice","drafts","pagesHref","headingComponent","borderRadius","value","round","filter","listStyle","m","p","map","direction","width","justifyContent","flex","minWidth","fontVariantNumeric","whiteSpace","hint","sections","join","detail","refundedCredits","host","initialAnswers","startBlank","leave","onResume","mb","pl","draft","li","mt","disabled","rel","Boolean","plan","screens","defaultExpanded","disableGutters","expandIcon","screen","index","slug","section"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;AAEA,SAASA,mBAAmB,QAAQ,eAAc;AAClD,SAASC,gBAAgB,QAAQ,oDAAmD;AAEpF,SACEC,cAAc,EACdC,cAAc,EACdC,cAAc,EACdC,eAAe,EACfC,qBAAqB,EACrBC,cAAc,QACT,yBAAwB;AAC/B,SAASC,OAAO,EAAEC,OAAO,QAAQ,uBAAsB;AACvD,SACEC,qBAAqB,EACrBC,sBAAsB,EACtBC,cAAc,QACT,6DAA4D;AAEnE,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,SAAS,EACTC,gBAAgB,EAChBC,gBAAgB,EAChBC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,gBAAgB,EAChBC,SAAS,EACTC,cAAc,EACdC,KAAK,EACLC,UAAU,QACL,gBAAe;AACtB,SAAyBC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAChF,SACEC,aAAa,EACbC,sBAAsB,EACtBC,mBAAmB,EACnBC,gBAAgB,EAChBC,eAAe,QAEV,qCAAiC;AACxC,SAASC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Bd,SAAS,IAAM,KAAKjB;0CAEnB;;4BAGJ1H,6BAA6BuG,UAAUzF,qBAAO,KAACH;gCAAsBQ,KAAKoF;gCAAOzF,MAAMA;iCAAW;;;;;YAIxGyF,MAAMgG,IAAI,IAAIhG,MAAMgG,IAAI,CAACC,OAAO,CAAChD,MAAM,GAAG,mBACzC,MAAC9K;gBACC,sFAAsF;gBACtF+N,iBAAiB5D,UAAU;gBAC3B5C,SAAQ;gBACRyG,cAAc;gBACdhJ,IAAI;oBAAE4G,cAAc;oBAAG,aAAa;wBAAE3G,SAAS;oBAAO;gBAAE;;kCAExD,KAAC/E;wBAAiB+N,0BAAY,KAACtO;4BAAQuE,MAAM5E,eAAe4E,IAAI;;kCAC9D,cAAA,KAACvD;4BAAW4G,SAAQ;sCAAa;;;kCAEnC,KAACtH;kCACC,cAAA,KAACS;4BAAMoE,WAAU;4BAAKM,SAAS;4BAAKJ,IAAI;gCAAEiH,GAAG;gCAAGqB,IAAI;4BAAI;sCACrDzF,MAAMgG,IAAI,CAACC,OAAO,CAAC3B,GAAG,CAAC,CAAC+B,QAAQC,sBAC/B,MAAC/N;oCAAI0E,WAAU;;sDACb,KAACnE;4CAAW4G,SAAQ;sDAAS,GAAG2G,OAAOrE,KAAK,CAAC,GAAG,EAAEqE,OAAOE,IAAI,EAAE;;wCAC9DF,OAAOtB,QAAQ,CAAC9B,MAAM,GAAG,mBACxB,KAACnK;4CAAW4G,SAAQ;4CAAQpD,OAAM;sDAC/B+J,OAAOtB,QAAQ,CAACT,GAAG,CAAC,CAACkC,UAAYA,QAAQjG,IAAI,EAAEyE,IAAI,CAAC;;;mCAJlC,GAAGqB,OAAOE,IAAI,CAAC,CAAC,EAAED,OAAO;;;;;;;AAelE;AAEA,eAAe3G,gBAAe"}
@@ -24,11 +24,11 @@ import { MdiIcon } from "@aglyn/shared-ui-jsx";
24
24
  import { OptionCardGrid } from "@aglyn/shared-ui-jsx/components/option-card-grid.component";
25
25
  import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
26
26
  import { useUser } from "@aglyn/tenant-feature-instance";
27
- import { Alert, AppBar, Box, Button, Card, CardActionArea, Chip, CircularProgress, Container, Dialog, DialogActions, DialogContent, IconButton, MenuItem, Stack, Step, StepLabel, Stepper, TextField, Toolbar, Tooltip, Typography } from "@mui/material";
27
+ import { Alert, AppBar, Box, Button, Card, CardActionArea, Chip, CircularProgress, Container, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, IconButton, MenuItem, Stack, Step, StepLabel, Stepper, TextField, Toolbar, Tooltip, Typography } from "@mui/material";
28
28
  import { alpha } from "@mui/material/styles";
29
29
  import { useRouter } from "next/navigation";
30
30
  import { useCallback, useEffect, useId, useRef, useState } from "react";
31
- import { AI_JOB_AUTO_CONFIRM_INPUT, AI_SITE_FREE_PAGES, AI_SITE_FREE_PAGES_NOTE, AI_SITE_SUBMISSION_CHOICES, aiFreeSiteCreditEstimate, aiSiteCreditEstimate, aiSitePagesBand } from "../model/ai-site-job.js";
31
+ import { AI_JOB_AUTO_CONFIRM_INPUT, AI_SITE_FREE_PAGES, AI_SITE_FREE_PAGES_NOTE, AI_SITE_SUBMISSION_CHOICES, aiFreeCreditsResetLabel, aiFreeSiteCreditEstimate, aiFreeSiteShortfall, aiFreeSiteShortfallText, aiSiteCreditEstimate, aiSitePagesBand } from "../model/ai-site-job.js";
32
32
  import { FREE_AI_TASTE_CREDITS_PER_MONTH } from "../plan-entitlements.js";
33
33
  import { AI_SITE_START_ANSWERS, AI_SITE_START_TYPES, aiSiteStartBrief, aiSiteStartKind, aiSiteStartInputs, aiSiteStartRefusal } from "../model/ai-site-start.js";
34
34
  import { AI_SITE_KINDS } from "../model/ai-site-kinds.js";
@@ -58,7 +58,7 @@ import { AI_SITE_KINDS } from "../model/ai-site-kinds.js";
58
58
  import { AiJobFollow } from "./ai-job-follow.component.js";
59
59
  import { AiModelSelector } from "./ai-model-selector.component.js";
60
60
  import { useAiModelChoice } from "./use-ai-model-choice.js";
61
- import { aiSiteBuildHref } from "./ai-job-links.js";
61
+ import { aiCreditsBillingHref, aiSiteBuildHref } from "./ai-job-links.js";
62
62
  import { publishAiJob } from "./ai-jobs-store.js";
63
63
  /** Labels the dialog for a reader, from its own heading. */ const TITLE_ID = 'ai-site-start-title';
64
64
  /**
@@ -201,6 +201,14 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
201
201
  /** The site job "Plan my site" started, as the create door answered with it. */ const [started, setStarted] = useState(null);
202
202
  // The Free taste's page band (AGL-3594), read off the verdict request.
203
203
  const [freeTaste, setFreeTaste] = useState(false);
204
+ // What the Free workspace has left this month (AGL-3660), as the same read
205
+ // the create door refuses on: the less of its own band and its owner's
206
+ // allowance across their Free workspaces. `null` when the route said none.
207
+ const [freeCredits, setFreeCredits] = useState(null);
208
+ // "Leave without your answers?" (AGL-3660): a dismissal with a brief typed.
209
+ const [confirmingLeave, setConfirmingLeave] = useState(false);
210
+ // The dialog's own root, to tell its Escape from a nested popup's.
211
+ const dialogRef = useRef(null);
204
212
  useEffect(()=>{
205
213
  if (!orgId || !uid) return;
206
214
  let active = true;
@@ -211,6 +219,8 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
211
219
  if (active) {
212
220
  if ((payload == null ? void 0 : payload.freeTaste) === true) {
213
221
  setFreeTaste(true);
222
+ const credits = payload == null ? void 0 : payload.freeCredits;
223
+ if (credits && Number.isFinite(credits.left)) setFreeCredits(credits);
214
224
  // A reopened start keeps the pages it asked for, within the band.
215
225
  setAnswers((current)=>_extends({}, current, {
216
226
  pages: reopened.current ? Math.min(current.pages, AI_SITE_FREE_PAGES.max) : AI_SITE_FREE_PAGES.max,
@@ -231,6 +241,9 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
231
241
  uid
232
242
  ]);
233
243
  const answer = useCallback((patch)=>setAnswers((current)=>_extends({}, current, patch)), []);
244
+ // A Free start what is left cannot pay for is not started (AGL-3660): the
245
+ // dialog says so before anything spends, and the create door refuses it too.
246
+ const shortfall = freeTaste ? aiFreeSiteShortfall(freeCredits, answers.pages) : null;
234
247
  const refusal = aiSiteStartRefusal(answers, {
235
248
  freeTaste
236
249
  });
@@ -259,7 +272,7 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
259
272
  const plan = useCallback(async ()=>{
260
273
  if (!orgId || aiSiteStartRefusal(answers, {
261
274
  freeTaste
262
- })) return;
275
+ }) || shortfall) return;
263
276
  setBusy(true);
264
277
  setNotice(null);
265
278
  try {
@@ -318,6 +331,7 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
318
331
  hostId,
319
332
  answers,
320
333
  freeTaste,
334
+ shortfall,
321
335
  orgSlug,
322
336
  host,
323
337
  leave,
@@ -343,17 +357,39 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
343
357
  // Before a job is started every way out is the blank site, which writes the
344
358
  // starter (AGL-3594); after, it only closes — the job builds the site.
345
359
  const exit = started ? leave != null ? leave : startBlank : startBlank;
360
+ // Anything the person typed or picked, which a dismissal must not discard
361
+ // silently (AGL-3660). After a job starts there is nothing left to lose.
362
+ const drafted = !started && Boolean(answers.siteType.trim() || answers.audience.trim() || answers.kind !== null);
363
+ // Escape and the close control: a dismissal, never a choice. Escape that
364
+ // bubbled here through React from a portal outside this dialog's own DOM is
365
+ // a nested menu's, already handled there, and is not this dialog's to act on.
366
+ const dismiss = (event, reason)=>{
367
+ if (reason === 'escapeKeyDown') {
368
+ const target = event == null ? void 0 : event.target;
369
+ const root = dialogRef.current;
370
+ if (root && target instanceof Node && !root.contains(target)) return;
371
+ }
372
+ if (drafted) setConfirmingLeave(true);
373
+ else exit();
374
+ };
375
+ const leaveDraft = ()=>{
376
+ setConfirmingLeave(false);
377
+ exit();
378
+ };
346
379
  // The chosen model's cost against Auto's, as the model list states it.
347
380
  const modelMultiplier = pickedModel && ((_modelChoice_options = modelChoice.options) == null ? void 0 : (_modelChoice_options_options_find = _modelChoice_options.options.find((option)=>option.id === pickedModel)) == null ? void 0 : _modelChoice_options_options_find.multiplier) || 1;
348
381
  const estimate = freeTaste ? aiFreeSiteCreditEstimate(answers.pages) : Math.round(aiSiteCreditEstimate(answers.pages, {
349
382
  welcomeEmail: answers.welcomeEmail
350
383
  }) * modelMultiplier);
351
- const estimateText = freeTaste ? `Up to about ${estimate.toLocaleString('en-US')} of the ${FREE_AI_TASTE_CREDITS_PER_MONTH} AI credits your Free workspace has each month` : `About ${estimate.toLocaleString('en-US')} credits, estimated`;
384
+ // A Free start quotes what is LEFT (AGL-3660), shared across the owner's
385
+ // Free workspaces — never the month's whole allowance as if none were spent.
386
+ const estimateText = freeTaste ? freeCredits ? `Up to about ${estimate.toLocaleString('en-US')} AI credits. You have ${freeCredits.left.toLocaleString('en-US')} of your ${freeCredits.total.toLocaleString('en-US')} free AI credits left this month, until ${aiFreeCreditsResetLabel(freeCredits.resetsOn)}` : `Up to about ${estimate.toLocaleString('en-US')} of the ${FREE_AI_TASTE_CREDITS_PER_MONTH} AI credits you get free each month` : `About ${estimate.toLocaleString('en-US')} credits, estimated`;
352
387
  const choosing = step === 'choose' && !started;
353
388
  return /*#__PURE__*/ _jsxs(Dialog, {
354
389
  open: true,
355
390
  fullScreen: true,
356
- onClose: exit,
391
+ ref: dialogRef,
392
+ onClose: dismiss,
357
393
  "aria-labelledby": TITLE_ID,
358
394
  // The console's own page surface, in both modes. A Dialog's paper sits
359
395
  // at elevation 24 by default, and in dark mode MUI lightens an elevated
@@ -385,7 +421,7 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
385
421
  /*#__PURE__*/ _jsx(IconButton, {
386
422
  edge: "start",
387
423
  color: "inherit",
388
- onClick: exit,
424
+ onClick: ()=>dismiss(),
389
425
  "aria-label": "Close the guided start",
390
426
  children: /*#__PURE__*/ _jsx(MdiIcon, {
391
427
  path: ICON_VARIANT_CLOSE.path
@@ -466,6 +502,19 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
466
502
  severity: "info",
467
503
  children: notice
468
504
  }),
505
+ step === 'describe' && !started && shortfall && freeCredits && /*#__PURE__*/ _jsxs(Alert, {
506
+ severity: "warning",
507
+ action: orgSlug ? /*#__PURE__*/ _jsx(Button, {
508
+ color: "inherit",
509
+ size: "small",
510
+ href: aiCreditsBillingHref(orgSlug),
511
+ children: 'Upgrade'
512
+ }) : undefined,
513
+ children: [
514
+ aiFreeSiteShortfallText(shortfall, freeCredits.resetsOn),
515
+ answers.pages > 1 && !aiFreeSiteShortfall(freeCredits, 1) ? ' Or choose 1 page, which what you have left covers.' : null
516
+ ]
517
+ }),
469
518
  choosing ? /*#__PURE__*/ _jsxs(Box, {
470
519
  sx: {
471
520
  display: 'grid',
@@ -738,7 +787,7 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
738
787
  /*#__PURE__*/ _jsx(Button, {
739
788
  variant: "contained",
740
789
  size: "large",
741
- disabled: busy || Boolean(refusal),
790
+ disabled: busy || Boolean(refusal) || Boolean(shortfall),
742
791
  onClick: plan,
743
792
  startIcon: /*#__PURE__*/ _jsx(MdiIcon, {
744
793
  path: mdiCreation.path
@@ -746,6 +795,40 @@ export function AiSiteStartCard({ hostId, orgId, orgSlug, host, startBlank, leav
746
795
  children: busy ? 'Starting…' : 'Plan my site'
747
796
  })
748
797
  ]
798
+ }),
799
+ /*#__PURE__*/ _jsxs(Dialog, {
800
+ open: confirmingLeave,
801
+ onClose: ()=>setConfirmingLeave(false),
802
+ "aria-labelledby": `${TITLE_ID}-leave`,
803
+ "aria-describedby": `${TITLE_ID}-leave-text`,
804
+ maxWidth: "xs",
805
+ children: [
806
+ /*#__PURE__*/ _jsx(DialogTitle, {
807
+ id: `${TITLE_ID}-leave`,
808
+ children: 'Leave without your answers?'
809
+ }),
810
+ /*#__PURE__*/ _jsx(DialogContent, {
811
+ children: /*#__PURE__*/ _jsx(DialogContentText, {
812
+ id: `${TITLE_ID}-leave-text`,
813
+ children: 'What you typed is not saved. Leaving starts your site from the starter site instead.'
814
+ })
815
+ }),
816
+ /*#__PURE__*/ _jsxs(DialogActions, {
817
+ children: [
818
+ /*#__PURE__*/ _jsx(Button, {
819
+ color: "inherit",
820
+ onClick: leaveDraft,
821
+ children: 'Leave and start blank'
822
+ }),
823
+ /*#__PURE__*/ _jsx(Button, {
824
+ variant: "contained",
825
+ autoFocus: true,
826
+ onClick: ()=>setConfirmingLeave(false),
827
+ children: 'Keep editing'
828
+ })
829
+ ]
830
+ })
831
+ ]
749
832
  })
750
833
  ]
751
834
  });