@aglyn/plugins-ai 1.0.0-beta.268 → 1.0.0-beta.270

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 (60) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/ai-credits-card.component.d.ts +4 -3
  3. package/src/lib/components/ai-credits-card.component.js +25 -8
  4. package/src/lib/components/ai-credits-card.component.js.map +1 -1
  5. package/src/lib/components/ai-job-links.d.ts +6 -0
  6. package/src/lib/components/ai-job-links.js +9 -0
  7. package/src/lib/components/ai-job-links.js.map +1 -1
  8. package/src/lib/components/ai-products-hub-card.component.d.ts +6 -0
  9. package/src/lib/components/ai-products-hub-card.component.js +21 -6
  10. package/src/lib/components/ai-products-hub-card.component.js.map +1 -1
  11. package/src/lib/components/ai-site-build-page.component.js +3 -2
  12. package/src/lib/components/ai-site-build-page.component.js.map +1 -1
  13. package/src/lib/components/ai-store-finish-card.component.d.ts +14 -3
  14. package/src/lib/components/ai-store-finish-card.component.js +67 -9
  15. package/src/lib/components/ai-store-finish-card.component.js.map +1 -1
  16. package/src/lib/components/assist-build-card.component.js +3 -2
  17. package/src/lib/components/assist-build-card.component.js.map +1 -1
  18. package/src/lib/jobs/ai-job-build-step.d.ts +3 -0
  19. package/src/lib/jobs/ai-job-build-step.js +8 -2
  20. package/src/lib/jobs/ai-job-build-step.js.map +1 -1
  21. package/src/lib/jobs/ai-job-form-step.d.ts +9 -0
  22. package/src/lib/jobs/ai-job-form-step.js +21 -2
  23. package/src/lib/jobs/ai-job-form-step.js.map +1 -1
  24. package/src/lib/jobs/ai-job-page-language.d.ts +26 -9
  25. package/src/lib/jobs/ai-job-page-language.js +46 -3
  26. package/src/lib/jobs/ai-job-page-language.js.map +1 -1
  27. package/src/lib/jobs/ai-job-page-step.js +4 -2
  28. package/src/lib/jobs/ai-job-page-step.js.map +1 -1
  29. package/src/lib/jobs/ai-job-site-look.d.ts +2 -1
  30. package/src/lib/jobs/ai-job-site-look.js +6 -2
  31. package/src/lib/jobs/ai-job-site-look.js.map +1 -1
  32. package/src/lib/jobs/ai-job-site-step.js +11 -6
  33. package/src/lib/jobs/ai-job-site-step.js.map +1 -1
  34. package/src/lib/jobs/ai-layout-owner-photos.d.ts +57 -0
  35. package/src/lib/jobs/ai-layout-owner-photos.js +110 -0
  36. package/src/lib/jobs/ai-layout-owner-photos.js.map +1 -0
  37. package/src/lib/jobs/ai-layout-stock-photos.d.ts +51 -10
  38. package/src/lib/jobs/ai-layout-stock-photos.js +812 -121
  39. package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
  40. package/src/lib/jobs/fixtures/ai-stock-photo-agl3942-recordings.d.ts +29 -0
  41. package/src/lib/jobs/fixtures/ai-stock-photo-agl3942-recordings.js +291 -0
  42. package/src/lib/jobs/fixtures/ai-stock-photo-agl3942-recordings.js.map +1 -0
  43. package/src/lib/jobs/fixtures/ai-stock-photo-brightvale-recordings.d.ts +4 -0
  44. package/src/lib/jobs/fixtures/ai-stock-photo-brightvale-recordings.js +87 -1
  45. package/src/lib/jobs/fixtures/ai-stock-photo-brightvale-recordings.js.map +1 -1
  46. package/src/lib/jobs/fixtures/ai-stock-photo-mexicano-recordings.d.ts +31 -0
  47. package/src/lib/jobs/fixtures/ai-stock-photo-mexicano-recordings.js +325 -0
  48. package/src/lib/jobs/fixtures/ai-stock-photo-mexicano-recordings.js.map +1 -0
  49. package/src/lib/layout-language/ai-layout-motion.d.ts +60 -7
  50. package/src/lib/layout-language/ai-layout-motion.js +231 -4
  51. package/src/lib/layout-language/ai-layout-motion.js.map +1 -1
  52. package/src/lib/layout-language/ai-layout-pictures.d.ts +8 -0
  53. package/src/lib/layout-language/ai-layout-pictures.js +68 -4
  54. package/src/lib/layout-language/ai-layout-pictures.js.map +1 -1
  55. package/src/lib/model/ai-site-look.d.ts +10 -1
  56. package/src/lib/model/ai-site-look.js +14 -3
  57. package/src/lib/model/ai-site-look.js.map +1 -1
  58. package/src/lib/native-nav.d.ts +26 -0
  59. package/src/lib/native-nav.js +58 -0
  60. package/src/lib/native-nav.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.268",
3
+ "version": "1.0.0-beta.270",
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.268",
29
- "@aglyn/shared-data-enums": "1.0.0-beta.268",
30
- "@aglyn/shared-data-mdi": "1.0.0-beta.268",
31
- "@aglyn/shared-data-types": "1.0.0-beta.268",
32
- "@aglyn/shared-ui-email-campaigns": "1.0.0-beta.268",
33
- "@aglyn/shared-ui-jsx": "1.0.0-beta.268",
34
- "@aglyn/shared-ui-snackstack": "1.0.0-beta.268",
35
- "@aglyn/shared-ui-theme": "1.0.0-beta.268",
36
- "@aglyn/shared-util-email": "1.0.0-beta.268",
37
- "@aglyn/shared-util-errors": "1.0.0-beta.268",
38
- "@aglyn/shared-util-http": "1.0.0-beta.268",
39
- "@aglyn/shared-util-timestamp": "1.0.0-beta.268",
40
- "@aglyn/shared-util-tools": "1.0.0-beta.268",
41
- "@aglyn/tenant-data-admin": "1.0.0-beta.268",
42
- "@aglyn/tenant-feature-instance": "1.0.0-beta.268",
43
- "@aglyn/tenant-runtime": "1.0.0-beta.268",
28
+ "@aglyn/aglyn": "1.0.0-beta.270",
29
+ "@aglyn/shared-data-enums": "1.0.0-beta.270",
30
+ "@aglyn/shared-data-mdi": "1.0.0-beta.270",
31
+ "@aglyn/shared-data-types": "1.0.0-beta.270",
32
+ "@aglyn/shared-ui-email-campaigns": "1.0.0-beta.270",
33
+ "@aglyn/shared-ui-jsx": "1.0.0-beta.270",
34
+ "@aglyn/shared-ui-snackstack": "1.0.0-beta.270",
35
+ "@aglyn/shared-ui-theme": "1.0.0-beta.270",
36
+ "@aglyn/shared-util-email": "1.0.0-beta.270",
37
+ "@aglyn/shared-util-errors": "1.0.0-beta.270",
38
+ "@aglyn/shared-util-http": "1.0.0-beta.270",
39
+ "@aglyn/shared-util-timestamp": "1.0.0-beta.270",
40
+ "@aglyn/shared-util-tools": "1.0.0-beta.270",
41
+ "@aglyn/tenant-data-admin": "1.0.0-beta.270",
42
+ "@aglyn/tenant-feature-instance": "1.0.0-beta.270",
43
+ "@aglyn/tenant-runtime": "1.0.0-beta.270",
44
44
  "@swc/helpers": "0.5.23"
45
45
  },
46
46
  "peerDependencies": {
@@ -19,9 +19,10 @@ export interface AiCreditsCardProps {
19
19
  * Rendered only where a band is sold, which since AGL-3203 is every plan
20
20
  * row: Free carries the taste and Starter 750, so both render a meter even
21
21
  * though neither carries `aiAssist` — the band is credits, not the guided
22
- * rung. What still renders nothing is a band of ZERO, which now reaches this
23
- * component only as a per-org override, and a "0 of 0" meter is not a
24
- * readout of anything. ONE meter for one pool: the
22
+ * rung. A band of ZERO, which now reaches this component only as a per-org
23
+ * override, draws no meter — a "0 of 0" meter is not a readout of anything —
24
+ * but says the plan has no credits and links to Billing (AGL-3982), since a
25
+ * missing card reads as AI not existing here. ONE meter for one pool: the
25
26
  * add-on widens `assistCreditsPerMonth` rather than opening a second band,
26
27
  * so the limit here is already plan plus add-on and the caption under it
27
28
  * says how much of that the add-on is.
@@ -18,6 +18,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
18
  import { AI_ADDON_CREDITS_PER_MONTH, aiAddonName, hasAiAddon, isUnlimitedQuota, resolveEffectivePlan, resolveOrgEntitlements, resolvePlanPricing } from "@aglyn/aglyn";
19
19
  import { pluginDocsHelp } from "@aglyn/aglyn/app-utils/docs-help";
20
20
  import { CardDisplay } from "@aglyn/shared-ui-jsx";
21
+ import { PrerequisiteNotice } from "@aglyn/shared-ui-jsx/components/prerequisite-notice.component";
21
22
  import { UsageMeter } from "@aglyn/shared-ui-jsx/components/usage-meter.component";
22
23
  import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
23
24
  import { Link, Typography } from "@mui/material";
@@ -36,9 +37,10 @@ import { useUser } from "@aglyn/tenant-feature-instance";
36
37
  * Rendered only where a band is sold, which since AGL-3203 is every plan
37
38
  * row: Free carries the taste and Starter 750, so both render a meter even
38
39
  * though neither carries `aiAssist` — the band is credits, not the guided
39
- * rung. What still renders nothing is a band of ZERO, which now reaches this
40
- * component only as a per-org override, and a "0 of 0" meter is not a
41
- * readout of anything. ONE meter for one pool: the
40
+ * rung. A band of ZERO, which now reaches this component only as a per-org
41
+ * override, draws no meter — a "0 of 0" meter is not a readout of anything —
42
+ * but says the plan has no credits and links to Billing (AGL-3982), since a
43
+ * missing card reads as AI not existing here. ONE meter for one pool: the
42
44
  * add-on widens `assistCreditsPerMonth` rather than opening a second band,
43
45
  * so the limit here is already plan plus add-on and the caption under it
44
46
  * says how much of that the add-on is.
@@ -73,7 +75,25 @@ import { useUser } from "@aglyn/tenant-feature-instance";
73
75
  user
74
76
  ]);
75
77
  const entitlements = resolveOrgEntitlements(org);
76
- if (entitlements.assistCreditsPerMonth <= 0) return null;
78
+ const help = pluginDocsHelp('aiCredits', {
79
+ anchor: '#see-your-credits',
80
+ excerpt: 'AI credits drawn this month against your included band: your plan’s ' + 'credits plus the AI add-on’s. The band resets on the first of the month.'
81
+ });
82
+ // A band of zero (AGL-3982): said, with the way to a plan that has one,
83
+ // rather than a missing card that reads as AI not existing here.
84
+ if (entitlements.assistCreditsPerMonth <= 0) {
85
+ return /*#__PURE__*/ _jsx(CardDisplay, {
86
+ header: 'AI credits',
87
+ help: help,
88
+ contentGutterX: true,
89
+ contentGutterY: true,
90
+ children: /*#__PURE__*/ _jsx(PrerequisiteNotice, {
91
+ href: billingHref ? `${billingHref}#plans` : '#plans',
92
+ actionLabel: "See plans",
93
+ children: 'Your plan includes no AI credits. Choose a plan with AI credits in Billing to use the AI features.'
94
+ })
95
+ });
96
+ }
77
97
  const plan = resolveEffectivePlan(org);
78
98
  const aiAddonCredits = hasAiAddon(org) ? AI_ADDON_CREDITS_PER_MONTH[plan] : 0;
79
99
  // Sold to THIS workspace, not merely on its plan: a staff comp has no
@@ -81,10 +101,7 @@ import { useUser } from "@aglyn/tenant-feature-instance";
81
101
  const aiAddonSold = resolvePlanPricing(org).aiAddonMonthlyUsd != null;
82
102
  return /*#__PURE__*/ _jsxs(CardDisplay, {
83
103
  header: 'AI credits',
84
- help: pluginDocsHelp('aiCredits', {
85
- anchor: '#see-your-credits',
86
- excerpt: 'AI credits drawn this month against your included band: your plan’s ' + 'credits plus the AI add-on’s. The band resets on the first of the month.'
87
- }),
104
+ help: help,
88
105
  contentGutterX: true,
89
106
  contentGutterY: true,
90
107
  children: [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-credits-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport {\n AI_ADDON_CREDITS_PER_MONTH,\n aiAddonName,\n hasAiAddon,\n isUnlimitedQuota,\n resolveEffectivePlan,\n resolveOrgEntitlements,\n resolvePlanPricing,\n type AglynOrgBilling,\n} from '@aglyn/aglyn'\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { UsageMeter } from '@aglyn/shared-ui-jsx/components/usage-meter.component'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { Link, Typography } from '@mui/material'\nimport { useEffect, useState } from 'react'\nimport { useUser } from '@aglyn/tenant-feature-instance'\n\nexport interface AiCreditsCardProps {\n orgId?: string | null\n /** The billing-merged org doc the Usage page resolved. */\n org?: Partial<AglynOrgBilling> | null\n /** The Billing overview's path, for the one caption that points at the add-ons card. */\n billingHref?: string\n}\n\n/**\n * The AI credits meter (AGL-2899), on the Billing → Usage page's plugin\n * band below the platform's own meters (AGL-2939).\n *\n * Credits, because AI actions differ in cost by up to two orders of\n * magnitude — a question against generating a screen — and a message count\n * would price them the same. The band is refused at the cap, so this\n * readout is the only thing standing between a customer and learning their\n * limit by being turned down mid-build.\n *\n * Rendered only where a band is sold, which since AGL-3203 is every plan\n * row: Free carries the taste and Starter 750, so both render a meter even\n * though neither carries `aiAssist` — the band is credits, not the guided\n * rung. What still renders nothing is a band of ZERO, which now reaches this\n * component only as a per-org override, and a \"0 of 0\" meter is not a\n * readout of anything. ONE meter for one pool: the\n * add-on widens `assistCreditsPerMonth` rather than opening a second band,\n * so the limit here is already plan plus add-on and the caption under it\n * says how much of that the add-on is.\n *\n * From the server, not from Firestore like the platform's meters:\n * `orgs/{orgId}/assistUsage` is default-deny for every client, so a browser\n * read would fail silently and leave this reading \"not yet metered\" forever.\n * Credits, never dollars: the route is where the one conversion happens.\n */\nexport default function AiCreditsCard(props: AiCreditsCardProps) {\n const { orgId, org, billingHref } = props\n const { data: user } = useUser()\n const [credits, setCredits] = useState<{ used: number; limit: number | null } | null>(null)\n useEffect(() => {\n if (!orgId || !user) return undefined\n let active = true\n void (async () => {\n try {\n const response = await authorizedFetch(\n user,\n `/api/ai/billing/credits?orgId=${encodeURIComponent(orgId)}`,\n )\n if (!response.ok) return\n const result = await response.json()\n if (active && result?.credits) setCredits(result.credits)\n } catch {\n // The meter keeps its \"not yet metered\" state on failure —\n // deliberately not 0, which reads as \"you have used none\".\n }\n })()\n return () => {\n active = false\n }\n }, [orgId, user])\n\n const entitlements = resolveOrgEntitlements(org)\n if (entitlements.assistCreditsPerMonth <= 0) return null\n const plan = resolveEffectivePlan(org)\n const aiAddonCredits = hasAiAddon(org) ? AI_ADDON_CREDITS_PER_MONTH[plan] : 0\n // Sold to THIS workspace, not merely on its plan: a staff comp has no\n // subscription to add the item to, so its price list sells none (AGL-3034).\n const aiAddonSold = resolvePlanPricing(org).aiAddonMonthlyUsd != null\n return (\n <CardDisplay\n header={'AI credits'}\n help={pluginDocsHelp('aiCredits', {\n anchor: '#see-your-credits',\n excerpt:\n 'AI credits drawn this month against your included band: your plan’s ' +\n 'credits plus the AI add-on’s. The band resets on the first of the month.',\n })}\n contentGutterX\n contentGutterY\n >\n {/* An uncapped staff comp (AGL-3049) resolves this band `UNLIMITED`:\n the meter reads \"Unlimited\" and draws no bar, never \"/ Infinity\". */}\n <UsageMeter\n label=\"AI credits (this month)\"\n used={credits ? credits.used : null}\n limit={entitlements.assistCreditsPerMonth}\n unlimited={isUnlimitedQuota(entitlements.assistCreditsPerMonth)}\n upgradeHref={billingHref ? `${billingHref}#plans` : '#plans'}\n />\n {aiAddonCredits > 0 ? (\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n sx={{ display: 'block', mt: -1.5, mb: 2 }}\n >\n {`Includes ${aiAddonCredits.toLocaleString()} credits a month from ` +\n `the ${aiAddonName()} add-on.`}\n </Typography>\n ) : null}\n {/* A plan with a band that sells the add-on and has not bought it:\n the one line on the meters that points at more capacity rather\n than at an upgrade. */}\n {!entitlements.features.aiGenerative && aiAddonSold ? (\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n sx={{ display: 'block', mt: -1.5, mb: 2 }}\n >\n {`Generate pages, emails, campaigns and more with ${aiAddonName()}, ` +\n `and add ${AI_ADDON_CREDITS_PER_MONTH[plan].toLocaleString()} ` +\n 'credits a month to this pool: '}\n <Link href={`${billingHref ?? ''}#addons`} color=\"primary\" underline=\"hover\">\n {`Add ${aiAddonName()}`}\n </Link>\n {' in Billing → Plans.'}\n </Typography>\n ) : null}\n </CardDisplay>\n )\n}\n"],"names":["AI_ADDON_CREDITS_PER_MONTH","aiAddonName","hasAiAddon","isUnlimitedQuota","resolveEffectivePlan","resolveOrgEntitlements","resolvePlanPricing","pluginDocsHelp","CardDisplay","UsageMeter","authorizedFetch","Link","Typography","useEffect","useState","useUser","AiCreditsCard","props","orgId","org","billingHref","data","user","credits","setCredits","undefined","active","response","encodeURIComponent","ok","result","json","entitlements","assistCreditsPerMonth","plan","aiAddonCredits","aiAddonSold","aiAddonMonthlyUsd","header","help","anchor","excerpt","contentGutterX","contentGutterY","label","used","limit","unlimited","upgradeHref","variant","color","sx","display","mt","mb","toLocaleString","features","aiGenerative","href","underline"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SACEA,0BAA0B,EAC1BC,WAAW,EACXC,UAAU,EACVC,gBAAgB,EAChBC,oBAAoB,EACpBC,sBAAsB,EACtBC,kBAAkB,QAEb,eAAc;AACrB,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,WAAW,QAAQ,uBAAsB;AAClD,SAASC,UAAU,QAAQ,wDAAuD;AAClF,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,IAAI,EAAEC,UAAU,QAAQ,gBAAe;AAChD,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAC3C,SAASC,OAAO,QAAQ,iCAAgC;AAUxD;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,GACD,eAAe,SAASC,cAAcC,KAAyB;IAC7D,MAAM,EAAEC,KAAK,EAAEC,GAAG,EAAEC,WAAW,EAAE,GAAGH;IACpC,MAAM,EAAEI,MAAMC,IAAI,EAAE,GAAGP;IACvB,MAAM,CAACQ,SAASC,WAAW,GAAGV,SAAwD;IACtFD,UAAU;QACR,IAAI,CAACK,SAAS,CAACI,MAAM,OAAOG;QAC5B,IAAIC,SAAS;QACb,KAAK,AAAC,CAAA;YACJ,IAAI;gBACF,MAAMC,WAAW,MAAMjB,gBACrBY,MACA,CAAC,8BAA8B,EAAEM,mBAAmBV,QAAQ;gBAE9D,IAAI,CAACS,SA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AKC,IAAI;gBAAE;;oBAEvC,CAAC,gDAAgD,EAAErD,cAAc,EAAE,CAAC,GACnE,CAAC,QAAQ,EAAED,0BAA0B,CAACkC,KAAK,CAACqB,cAAc,GAAG,CAAC,CAAC,GAC/D;kCACF,KAAC5C;wBAAK+C,MAAM,GAAGtC,sBAAAA,cAAe,GAAG,OAAO,CAAC;wBAAE8B,OAAM;wBAAUS,WAAU;kCAClE,CAAC,IAAI,EAAE1D,eAAe;;oBAExB;;iBAED;;;AAGV"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-credits-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport {\n AI_ADDON_CREDITS_PER_MONTH,\n aiAddonName,\n hasAiAddon,\n isUnlimitedQuota,\n resolveEffectivePlan,\n resolveOrgEntitlements,\n resolvePlanPricing,\n type AglynOrgBilling,\n} from '@aglyn/aglyn'\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { PrerequisiteNotice } from '@aglyn/shared-ui-jsx/components/prerequisite-notice.component'\nimport { UsageMeter } from '@aglyn/shared-ui-jsx/components/usage-meter.component'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { Link, Typography } from '@mui/material'\nimport { useEffect, useState } from 'react'\nimport { useUser } from '@aglyn/tenant-feature-instance'\n\nexport interface AiCreditsCardProps {\n orgId?: string | null\n /** The billing-merged org doc the Usage page resolved. */\n org?: Partial<AglynOrgBilling> | null\n /** The Billing overview's path, for the one caption that points at the add-ons card. */\n billingHref?: string\n}\n\n/**\n * The AI credits meter (AGL-2899), on the Billing → Usage page's plugin\n * band below the platform's own meters (AGL-2939).\n *\n * Credits, because AI actions differ in cost by up to two orders of\n * magnitude — a question against generating a screen — and a message count\n * would price them the same. The band is refused at the cap, so this\n * readout is the only thing standing between a customer and learning their\n * limit by being turned down mid-build.\n *\n * Rendered only where a band is sold, which since AGL-3203 is every plan\n * row: Free carries the taste and Starter 750, so both render a meter even\n * though neither carries `aiAssist` — the band is credits, not the guided\n * rung. A band of ZERO, which now reaches this component only as a per-org\n * override, draws no meter — a \"0 of 0\" meter is not a readout of anything —\n * but says the plan has no credits and links to Billing (AGL-3982), since a\n * missing card reads as AI not existing here. ONE meter for one pool: the\n * add-on widens `assistCreditsPerMonth` rather than opening a second band,\n * so the limit here is already plan plus add-on and the caption under it\n * says how much of that the add-on is.\n *\n * From the server, not from Firestore like the platform's meters:\n * `orgs/{orgId}/assistUsage` is default-deny for every client, so a browser\n * read would fail silently and leave this reading \"not yet metered\" forever.\n * Credits, never dollars: the route is where the one conversion happens.\n */\nexport default function AiCreditsCard(props: AiCreditsCardProps) {\n const { orgId, org, billingHref } = props\n const { data: user } = useUser()\n const [credits, setCredits] = useState<{ used: number; limit: number | null } | null>(null)\n useEffect(() => {\n if (!orgId || !user) return undefined\n let active = true\n void (async () => {\n try {\n const response = await authorizedFetch(\n user,\n `/api/ai/billing/credits?orgId=${encodeURIComponent(orgId)}`,\n )\n if (!response.ok) return\n const result = await response.json()\n if (active && result?.credits) setCredits(result.credits)\n } catch {\n // The meter keeps its \"not yet metered\" state on failure —\n // deliberately not 0, which reads as \"you have used none\".\n }\n })()\n return () => {\n active = false\n }\n }, [orgId, user])\n\n const entitlements = resolveOrgEntitlements(org)\n const help = pluginDocsHelp('aiCredits', {\n anchor: '#see-your-credits',\n excerpt:\n 'AI credits drawn this month against your included band: your plan’s ' +\n 'credits plus the AI add-on’s. The band resets on the first of the month.',\n })\n // A band of zero (AGL-3982): said, with the way to a plan that has one,\n // rather than a missing card that reads as AI not existing here.\n if (entitlements.assistCreditsPerMonth <= 0) {\n return (\n <CardDisplay header={'AI credits'} help={help} contentGutterX contentGutterY>\n <PrerequisiteNotice href={billingHref ? `${billingHref}#plans` : '#plans'} actionLabel=\"See plans\">\n {'Your plan includes no AI credits. Choose a plan with AI credits in Billing to use the AI features.'}\n </PrerequisiteNotice>\n </CardDisplay>\n )\n }\n const plan = resolveEffectivePlan(org)\n const aiAddonCredits = hasAiAddon(org) ? AI_ADDON_CREDITS_PER_MONTH[plan] : 0\n // Sold to THIS workspace, not merely on its plan: a staff comp has no\n // subscription to add the item to, so its price list sells none (AGL-3034).\n const aiAddonSold = resolvePlanPricing(org).aiAddonMonthlyUsd != null\n return (\n <CardDisplay\n header={'AI credits'}\n help={help}\n contentGutterX\n contentGutterY\n >\n {/* An uncapped staff comp (AGL-3049) resolves this band `UNLIMITED`:\n the meter reads \"Unlimited\" and draws no bar, never \"/ Infinity\". */}\n <UsageMeter\n label=\"AI credits (this month)\"\n used={credits ? credits.used : null}\n limit={entitlements.assistCreditsPerMonth}\n unlimited={isUnlimitedQuota(entitlements.assistCreditsPerMonth)}\n upgradeHref={billingHref ? `${billingHref}#plans` : '#plans'}\n />\n {aiAddonCredits > 0 ? (\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n sx={{ display: 'block', mt: -1.5, mb: 2 }}\n >\n {`Includes ${aiAddonCredits.toLocaleString()} credits a month from ` +\n `the ${aiAddonName()} add-on.`}\n </Typography>\n ) : null}\n {/* A plan with a band that sells the add-on and has not bought it:\n the one line on the meters that points at more capacity rather\n than at an upgrade. */}\n {!entitlements.features.aiGenerative && aiAddonSold ? (\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n sx={{ display: 'block', mt: -1.5, mb: 2 }}\n >\n {`Generate pages, emails, campaigns and more with ${aiAddonName()}, ` +\n `and add ${AI_ADDON_CREDITS_PER_MONTH[plan].toLocaleString()} ` +\n 'credits a month to this pool: '}\n <Link href={`${billingHref ?? ''}#addons`} color=\"primary\" underline=\"hover\">\n {`Add ${aiAddonName()}`}\n </Link>\n {' in Billing → Plans.'}\n </Typography>\n ) : null}\n </CardDisplay>\n )\n}\n"],"names":["AI_ADDON_CREDITS_PER_MONTH","aiAddonName","hasAiAddon","isUnlimitedQuota","resolveEffectivePlan","resolveOrgEntitlements","resolvePlanPricing","pluginDocsHelp","CardDisplay","PrerequisiteNotice","UsageMeter","authorizedFetch","Link","Typography","useEffect","useState","useUser","AiCreditsCard","props","orgId","org","billingHref","data","user","credits","setCredits","undefined","active","response","encodeURIComponent","ok","result","json","entitlements","help","anchor","excerpt","assistCreditsPerMonth","header","contentGutterX","contentGutterY","href","actionLabel","plan","aiAddonCredits","aiAddonSold","aiAddonMonthlyUsd","label","used","limit","unlimited","upgradeHref","variant","color","sx","display","mt","mb","toLocaleString","features","aiGenerative","underline"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SACEA,0BAA0B,EAC1BC,WAAW,EACXC,UAAU,EACVC,gBAAgB,EAChBC,oBAAoB,EACpBC,sBAAsB,EACtBC,kBAAkB,QAEb,eAAc;AACrB,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,WAAW,QAAQ,uBAAsB;AAClD,SAASC,kBAAkB,QAAQ,gEAA+D;AAClG,SAASC,UAAU,QAAQ,wDAAuD;AAClF,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,IAAI,EAAEC,UAAU,QAAQ,gBAAe;AAChD,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAC3C,SAASC,OAAO,QAAQ,iCAAgC;AAUxD;;;;;;;;;;;;;;;;;;;;;;;;;CAyBC,GACD,eAAe,SAASC,cAAcC,KAAyB;IAC7D,MAAM,EAAEC,KAAK,EAAEC,GAAG,EAAEC,WAAW,EAAE,GAAGH;IACpC,MAAM,EAAEI,MAAMC,IAAI,EAAE,GAAGP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BAAqB;gBACzCa,WAAW/C,iBAAiB8B,aAAaI,qBAAqB;gBAC9Dc,aAAa9B,cAAc,GAAGA,YAAY,MAAM,CAAC,GAAG;;YAErDuB,iBAAiB,kBAChB,KAAC/B;gBACCuC,SAAQ;gBACRC,OAAM;gBACNC,IAAI;oBAAEC,SAAS;oBAASC,IAAI,CAAC;oBAAKC,IAAI;gBAAE;0BAEvC,CAAC,SAAS,EAAEb,eAAec,cAAc,GAAG,sBAAsB,CAAC,GAClE,CAAC,IAAI,EAAEzD,cAAc,QAAQ,CAAC;iBAEhC;YAIH,CAACgC,aAAa0B,QAAQ,CAACC,YAAY,IAAIf,4BACtC,MAAChC;gBACCuC,SAAQ;gBACRC,OAAM;gBACNC,IAAI;oBAAEC,SAAS;oBAASC,IAAI,CAAC;oBAAKC,IAAI;gBAAE;;oBAEvC,CAAC,gDAAgD,EAAExD,cAAc,EAAE,CAAC,GACnE,CAAC,QAAQ,EAAED,0BAA0B,CAAC2C,KAAK,CAACe,cAAc,GAAG,CAAC,CAAC,GAC/D;kCACF,KAAC9C;wBAAK6B,MAAM,GAAGpB,sBAAAA,cAAe,GAAG,OAAO,CAAC;wBAAEgC,OAAM;wBAAUQ,WAAU;kCAClE,CAAC,IAAI,EAAE5D,eAAe;;oBAExB;;iBAED;;;AAGV"}
@@ -61,5 +61,11 @@ export interface AiStoreFinishLink extends AiStoreFinishStep {
61
61
  * them, and the site's Pages.
62
62
  */
63
63
  export declare function aiStoreFinishLinks(job: Pick<AiJobSummary, 'kind' | 'status' | 'items' | 'outputs'> & Partial<Pick<AiJobSummary, 'sitePublish'>>, orgSlug: string): AiStoreFinishLink[] | null;
64
+ /**
65
+ * The site an AI-built store is on — the one {@link aiStoreFinishLinks}
66
+ * links — so "Finish your store" can read whether its workspace already takes
67
+ * payments (AGL-3982). `null` where no output names a site.
68
+ */
69
+ export declare function aiStoreFinishHostId(job: Pick<AiJobSummary, 'outputs'>): string | null;
64
70
  /** What a build's "Review your products" step says: its products are drafts, priced only where the request said. */
65
71
  export declare const AI_BUILD_STORE_PRODUCTS_TEXT = "Your new products are drafts. Set their prices, photos and stock, then make them active so they show in your store.";
@@ -249,6 +249,15 @@ export { AI_SITE_BUILD_HREF };
249
249
  }));
250
250
  return steps;
251
251
  }
252
+ /**
253
+ * The site an AI-built store is on — the one {@link aiStoreFinishLinks}
254
+ * links — so "Finish your store" can read whether its workspace already takes
255
+ * payments (AGL-3982). `null` where no output names a site.
256
+ */ export function aiStoreFinishHostId(job) {
257
+ var _ref;
258
+ var _job_outputs_find;
259
+ return (_ref = (_job_outputs_find = job.outputs.find((output)=>output.resource === 'screen' && output.hostSubdomain)) == null ? void 0 : _job_outputs_find.hostId) != null ? _ref : null;
260
+ }
252
261
  /** What a build's "Review your products" step says: its products are drafts, priced only where the request said. */ export const AI_BUILD_STORE_PRODUCTS_TEXT = 'Your new products are drafts. Set their prices, photos and stock, then make them active so they show in your store.';
253
262
 
254
263
  //# 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'\nimport { AI_STORE_FINISH_STEPS, type AiStoreFinishStep } from '../model/ai-site-store-pages'\nimport { AI_BUILD_STORE_LINKS_DRAFT_STEP, AI_BUILD_STORE_LINKS_MISSING_STEP } from '../model/ai-build-store-pages'\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 === 'media') {\n // Files a build organized (AGL-3752) open in the site's media library.\n return buildRoute(Route.HOST_MEDIA, { orgSlug, host })\n }\n if (output.resource === 'settings') {\n // Settings a build saved (AGL-3748) open where most of them are edited.\n return buildRoute(Route.HOST_SETUP_SEO, { orgSlug, host })\n }\n if (output.resource === 'tracking') {\n // Tags a build saved (AGL-3751) open on the card that edits them.\n return buildRoute(Route.HOST_SETUP_TRACKING, { orgSlug, host })\n }\n if (output.resource === 'draft' && output.draftResource) {\n // A draft another plugin wrote — a dataset a site start or a build made\n // (AGL-3616) — opens where its owner lists it, or nowhere it is not loaded.\n return pluginRecordListHref(output.draftResource, { 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\n/** One thing left to finish an AI-built store, with where it is done. */\nexport interface AiStoreFinishLink extends AiStoreFinishStep {\n /** The console page it is done on; `null` where the owner of that page is not loaded. */\n href: string | null\n}\n\n/**\n * What is left to finish a store a site start built (AGL-3676), or `null`\n * where the start built no store's own pages: its account, cart and policy\n * pages are written, so payments, products, shipping and tax, and the\n * policies' brackets are all that remain. Each links the exact console page:\n * the store's settings and its catalog, as the commerce plugin publishes\n * them, and the site's Pages.\n */\nexport function aiStoreFinishLinks(\n job: Pick<AiJobSummary, 'kind' | 'status' | 'items' | 'outputs'> & Partial<Pick<AiJobSummary, 'sitePublish'>>,\n orgSlug: string,\n): AiStoreFinishLink[] | null {\n // A site start's store, or an Assist build that made the site a store (AGL-3676).\n if ((job.kind !== 'site' && job.kind !== 'build') || job.status !== 'done' || !orgSlug) return null\n const row = (job.items ?? []).find((one) => one.slot === 'store')\n if (!row || (row.status !== 'succeeded' && row.status !== 'degraded')) return null\n const host = job.outputs.find((output) => output.resource === 'screen' && output.hostSubdomain)?.hostSubdomain\n if (!host) return null\n const context = { orgSlug, host: String(host) }\n // A build's products are drafts with no price unless asked, and it may\n // have written none of the policies (the site had them): its list says so.\n const build = job.kind === 'build'\n const mine = job.outputs.filter((output) => row.outputs.includes(output.id))\n const written = new Set(mine.map((output) => output.proposal?.['storePage']))\n const policies = !build || ['shipping', 'privacy', 'terms'].some((key) => written.has(key))\n const steps: AiStoreFinishLink[] = AI_STORE_FINISH_STEPS.filter((step) => step.id !== 'policies' || policies).map((step) => ({\n ...step,\n ...(build && step.id === 'products' ? { text: AI_BUILD_STORE_PRODUCTS_TEXT } : {}),\n href:\n step.opens === 'pages'\n ? buildRoute(Route.HOST_SCREENS, context)\n : step.opens === 'layouts' || step.opens === 'layout'\n ? buildRoute(Route.HOST_LAYOUTS, context)\n : step.record\n ? pluginRecordHref(step.opens, context, step.record)\n : pluginRecordListHref(step.opens, context),\n }))\n if (!build) return steps\n // The site's own header and footer (AGL-3676): links it had no list for are\n // the owner's to add; links drafted into it wait for its publish.\n if (mine.some((output) => output.proposal?.['storeLinks'] === 'missing')) {\n steps.push({ ...AI_BUILD_STORE_LINKS_MISSING_STEP, href: buildRoute(Route.HOST_LAYOUTS, context) })\n }\n const draft = mine.find((output) => output.resource === 'layout' && output.proposal?.['storeLinks'] === 'draft')\n const live = draft && job.sitePublish?.published.length\n if (draft && !live) steps.push({ ...AI_BUILD_STORE_LINKS_DRAFT_STEP, href: aiJobOutputHref(draft, orgSlug) })\n return steps\n}\n\n/** What a build's \"Review your products\" step says: its products are drafts, priced only where the request said. */\nexport const AI_BUILD_STORE_PRODUCTS_TEXT =\n 'Your new products are drafts. Set their prices, photos and stock, then make them active so they show in your store.'\n"],"names":["buildRoute","Route","pluginRecordHref","pluginRecordListHref","AI_JOB_BESIGNER_SEGMENT","BESIGNER_SEGMENT","AI_SITE_BUILD_HREF","AI_STORE_FINISH_STEPS","AI_BUILD_STORE_LINKS_DRAFT_STEP","AI_BUILD_STORE_LINKS_MISSING_STEP","aiJobOutputHref","output","orgSlug","host","hostSubdomain","segment","resource","base","id","versionId","collectionSlug","proposal","HOST_CONTENT_COLLECTION","HOST_CONTENT","HOST_SETUP_THEME","HOST_MEDIA","HOST_SETUP_SEO","HOST_SETUP_TRACKING","draftResource","aiJobPrimaryLink","job","status","screens","outputs","filter","length","href","HOST_SCREENS","String","label","aiSiteBuildHref","jobId","encodeURIComponent","aiSiteBuildDoneLinks","first","view","pages","aiCreditsBillingHref","MANAGE_BILLING","aiStoreFinishLinks","kind","row","items","find","one","slot","context","build","mine","includes","written","Set","map","policies","some","key","has","steps","step","text","AI_BUILD_STORE_PRODUCTS_TEXT","opens","HOST_LAYOUTS","record","push","draft","live","sitePublish","published"],"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;AAExG,SAASC,qBAAqB,QAAgC,kCAA8B;AAC5F,SAASC,+BAA+B,EAAEC,iCAAiC,QAAQ,mCAA+B;AAElH,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,UAAUV,gBAAgB,CAACM,OAAOK,QAAQ,C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BAAiBkE,KAAKG,KAAK,EAAEf,SAASY,KAAKK,MAAM,IACjDtE,qBAAqBiE,KAAKG,KAAK,EAAEf;;IAE7C,IAAI,CAACC,OAAO,OAAOU;IACnB,4EAA4E;IAC5E,kEAAkE;IAClE,IAAIT,KAAKM,IAAI,CAAC,CAACrD;YAAWA;eAAAA,EAAAA,mBAAAA,OAAOU,QAAQ,qBAAfV,gBAAiB,CAAC,aAAa,MAAK;QAAY;QACxEwD,MAAMO,IAAI,CAAC,aAAKjE;YAAmC2B,MAAMpC,WAAWC,MAAMuE,YAAY,EAAEhB;;IAC1F;IACA,MAAMmB,QAAQjB,KAAKL,IAAI,CAAC,CAAC1C;YAA2CA;eAAhCA,OAAOK,QAAQ,KAAK,YAAYL,EAAAA,mBAAAA,OAAOU,QAAQ,qBAAfV,gBAAiB,CAAC,aAAa,MAAK;;IACxG,MAAMiE,OAAOD,WAAS7C,mBAAAA,IAAI+C,WAAW,qBAAf/C,iBAAiBgD,SAAS,CAAC3C,MAAM;IACvD,IAAIwC,SAAS,CAACC,MAAMT,MAAMO,IAAI,CAAC,aAAKlE;QAAiC4B,MAAM1B,gBAAgBiE,OAAO/D;;IAClG,OAAOuD;AACT;AAEA,kHAAkH,GAClH,OAAO,MAAMG,+BACX,sHAAqH"}
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'\nimport { AI_STORE_FINISH_STEPS, type AiStoreFinishStep } from '../model/ai-site-store-pages'\nimport { AI_BUILD_STORE_LINKS_DRAFT_STEP, AI_BUILD_STORE_LINKS_MISSING_STEP } from '../model/ai-build-store-pages'\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 === 'media') {\n // Files a build organized (AGL-3752) open in the site's media library.\n return buildRoute(Route.HOST_MEDIA, { orgSlug, host })\n }\n if (output.resource === 'settings') {\n // Settings a build saved (AGL-3748) open where most of them are edited.\n return buildRoute(Route.HOST_SETUP_SEO, { orgSlug, host })\n }\n if (output.resource === 'tracking') {\n // Tags a build saved (AGL-3751) open on the card that edits them.\n return buildRoute(Route.HOST_SETUP_TRACKING, { orgSlug, host })\n }\n if (output.resource === 'draft' && output.draftResource) {\n // A draft another plugin wrote — a dataset a site start or a build made\n // (AGL-3616) — opens where its owner lists it, or nowhere it is not loaded.\n return pluginRecordListHref(output.draftResource, { 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\n/** One thing left to finish an AI-built store, with where it is done. */\nexport interface AiStoreFinishLink extends AiStoreFinishStep {\n /** The console page it is done on; `null` where the owner of that page is not loaded. */\n href: string | null\n}\n\n/**\n * What is left to finish a store a site start built (AGL-3676), or `null`\n * where the start built no store's own pages: its account, cart and policy\n * pages are written, so payments, products, shipping and tax, and the\n * policies' brackets are all that remain. Each links the exact console page:\n * the store's settings and its catalog, as the commerce plugin publishes\n * them, and the site's Pages.\n */\nexport function aiStoreFinishLinks(\n job: Pick<AiJobSummary, 'kind' | 'status' | 'items' | 'outputs'> & Partial<Pick<AiJobSummary, 'sitePublish'>>,\n orgSlug: string,\n): AiStoreFinishLink[] | null {\n // A site start's store, or an Assist build that made the site a store (AGL-3676).\n if ((job.kind !== 'site' && job.kind !== 'build') || job.status !== 'done' || !orgSlug) return null\n const row = (job.items ?? []).find((one) => one.slot === 'store')\n if (!row || (row.status !== 'succeeded' && row.status !== 'degraded')) return null\n const host = job.outputs.find((output) => output.resource === 'screen' && output.hostSubdomain)?.hostSubdomain\n if (!host) return null\n const context = { orgSlug, host: String(host) }\n // A build's products are drafts with no price unless asked, and it may\n // have written none of the policies (the site had them): its list says so.\n const build = job.kind === 'build'\n const mine = job.outputs.filter((output) => row.outputs.includes(output.id))\n const written = new Set(mine.map((output) => output.proposal?.['storePage']))\n const policies = !build || ['shipping', 'privacy', 'terms'].some((key) => written.has(key))\n const steps: AiStoreFinishLink[] = AI_STORE_FINISH_STEPS.filter((step) => step.id !== 'policies' || policies).map((step) => ({\n ...step,\n ...(build && step.id === 'products' ? { text: AI_BUILD_STORE_PRODUCTS_TEXT } : {}),\n href:\n step.opens === 'pages'\n ? buildRoute(Route.HOST_SCREENS, context)\n : step.opens === 'layouts' || step.opens === 'layout'\n ? buildRoute(Route.HOST_LAYOUTS, context)\n : step.record\n ? pluginRecordHref(step.opens, context, step.record)\n : pluginRecordListHref(step.opens, context),\n }))\n if (!build) return steps\n // The site's own header and footer (AGL-3676): links it had no list for are\n // the owner's to add; links drafted into it wait for its publish.\n if (mine.some((output) => output.proposal?.['storeLinks'] === 'missing')) {\n steps.push({ ...AI_BUILD_STORE_LINKS_MISSING_STEP, href: buildRoute(Route.HOST_LAYOUTS, context) })\n }\n const draft = mine.find((output) => output.resource === 'layout' && output.proposal?.['storeLinks'] === 'draft')\n const live = draft && job.sitePublish?.published.length\n if (draft && !live) steps.push({ ...AI_BUILD_STORE_LINKS_DRAFT_STEP, href: aiJobOutputHref(draft, orgSlug) })\n return steps\n}\n\n/**\n * The site an AI-built store is on — the one {@link aiStoreFinishLinks}\n * links — so \"Finish your store\" can read whether its workspace already takes\n * payments (AGL-3982). `null` where no output names a site.\n */\nexport function aiStoreFinishHostId(job: Pick<AiJobSummary, 'outputs'>): string | null {\n return job.outputs.find((output) => output.resource === 'screen' && output.hostSubdomain)?.hostId ?? null\n}\n\n/** What a build's \"Review your products\" step says: its products are drafts, priced only where the request said. */\nexport const AI_BUILD_STORE_PRODUCTS_TEXT =\n 'Your new products are drafts. Set their prices, photos and stock, then make them active so they show in your store.'\n"],"names":["buildRoute","Route","pluginRecordHref","pluginRecordListHref","AI_JOB_BESIGNER_SEGMENT","BESIGNER_SEGMENT","AI_SITE_BUILD_HREF","AI_STORE_FINISH_STEPS","AI_BUILD_STORE_LINKS_DRAFT_STEP","AI_BUILD_STORE_LINKS_MISSING_STEP","aiJobOutputHref","output","orgSlug","host","hostSubdomain","segment","resource","base","id","versionId","collectionSlug","proposal","HOST_CONTENT_COLLECTION","HOST_CONTENT","HOST_SETUP_THEME","HOST_MEDIA","HOST_SETUP_SEO","HOST_SETUP_TRACKING","draftResource","aiJobPrimaryLink","job","status","screens","outputs","filter","length","href","HOST_SCREENS","String","label","aiSiteBuildHref","jobId","encodeURIComponent","aiSiteBuildDoneLinks","first","view","pages","aiCreditsBillingHref","MANAGE_BILLING","aiStoreFinishLinks","kind","row","items","find","one","slot","context","build","mine","includes","written","Set","map","policies","some","key","has","steps","step","text","AI_BUILD_STORE_PRODUCTS_TEXT","opens","HOST_LAYOUTS","record","push","draft","live","sitePublish","published","aiStoreFinishHostId","hostId"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GACD,SAASA,UAAU,EAAEC,KAAK,QAAQ,wCAAuC;AACzE,SACEC,gBAAgB,EACh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AAIG,OAAO,CAACoB,IAAI,CAAC,CAAC1C,SAAWA,OAAOK,QAAQ,KAAK,YAAYL,OAAOG,aAAa,sBAAjFgB,kBAAoFkD,MAAM,mBAAI;AACvG;AAEA,kHAAkH,GAClH,OAAO,MAAMV,+BACX,sHAAqH"}
@@ -1,4 +1,10 @@
1
1
  import type { ConsoleProductsHubZoneProps } from './ai-product-zones';
2
+ /**
3
+ * Why "Write copy for products" is off (AGL-3982): it writes for the products
4
+ * listed on the page, and none are — a new catalog, or filters that match
5
+ * nothing.
6
+ */
7
+ export declare const NO_PRODUCTS_FOR_COPY: string;
2
8
  type BriefKind = 'catalog' | 'categories';
3
9
  /** What each brief dialog says. */
4
10
  export declare const AI_PRODUCTS_BRIEF_COPY: Readonly<Record<BriefKind, {
@@ -17,6 +17,7 @@
17
17
  import { _ as _extends } from "@swc/helpers/_/_extends";
18
18
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
19
  import { pluginDocsHelp } from "@aglyn/aglyn/app-utils/docs-help";
20
+ import { BlockedControl } from "@aglyn/shared-ui-jsx/components/blocked-control.component";
20
21
  import { ListTable } from "@aglyn/shared-ui-jsx/components/list-table.component";
21
22
  import { Alert, Box, Button, Chip, Dialog, DialogActions, DialogContent, DialogTitle, Link, Stack, TextField, Typography } from "@mui/material";
22
23
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
@@ -45,6 +46,11 @@ import { useAiProductsJobs } from "./use-ai-products-jobs.js";
45
46
  * the products the import created, as they land. Every write is the hub's
46
47
  * (`ConsoleProductsHubZoneProps`); this card writes nothing itself.
47
48
  */ const BRIEF_MAX_CHARS = 4000;
49
+ /**
50
+ * Why "Write copy for products" is off (AGL-3982): it writes for the products
51
+ * listed on the page, and none are — a new catalog, or filters that match
52
+ * nothing.
53
+ */ export const NO_PRODUCTS_FOR_COPY = 'Add a product first, or draft some with Propose products. AI writes copy for the products ' + 'listed below, so clear any filters that hide them.';
48
54
  /** What each brief dialog says. */ export const AI_PRODUCTS_BRIEF_COPY = {
49
55
  catalog: {
50
56
  title: 'Propose products',
@@ -321,12 +327,16 @@ export function AiProductsHubCard(props) {
321
327
  },
322
328
  spacing: 1,
323
329
  children: [
324
- /*#__PURE__*/ _jsx(Button, {
325
- size: "small",
326
- variant: "outlined",
327
- disabled: !orgId || !products.length,
328
- onClick: ()=>setPicking(true),
329
- children: 'Write copy for products'
330
+ /*#__PURE__*/ _jsx(BlockedControl, {
331
+ blocked: Boolean(orgId) && !products.length,
332
+ reason: NO_PRODUCTS_FOR_COPY,
333
+ children: /*#__PURE__*/ _jsx(Button, {
334
+ size: "small",
335
+ variant: "outlined",
336
+ disabled: !orgId || !products.length,
337
+ onClick: ()=>setPicking(true),
338
+ children: 'Write copy for products'
339
+ })
330
340
  }),
331
341
  /*#__PURE__*/ _jsx(Button, {
332
342
  size: "small",
@@ -350,6 +360,11 @@ export function AiProductsHubCard(props) {
350
360
  })
351
361
  ]
352
362
  }),
363
+ orgId && !products.length ? /*#__PURE__*/ _jsx(Typography, {
364
+ variant: "caption",
365
+ color: "text.secondary",
366
+ children: NO_PRODUCTS_FOR_COPY
367
+ }) : null,
353
368
  notice ? /*#__PURE__*/ _jsx(Alert, {
354
369
  severity: "warning",
355
370
  children: notice
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-products-hub-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport type { ConsoleProductsHubZoneProps } from './ai-product-zones'\nimport { ListTable, type ListTableProps } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport {\n Alert,\n Box,\n Button,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Link,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport type { AiJobSummary } from '../model/ai-jobs.types'\nimport {\n AI_PRODUCTS_BULK_MAX,\n AI_PRODUCTS_IMPORT_WRITE_COPY,\n aiProductsBulkBrief,\n aiProductsBulkCount,\n aiProductsJobInputs,\n aiProductsProposalOfKind,\n} from '../model/ai-products'\nimport { registerAiProductsBriefOpener } from './ai-products-create-button.component'\nimport { AiBulkCopyReview, AiCatalogReview, AiCategoriesReview } from './ai-products-proposals.component'\nimport { useAiProductsJobs } from './use-ai-products-jobs'\n\n/**\n * Commerce by AI on the products hub (AGL-2916), through the `productsHub`\n * zone. Three things a person asks for, each a `products` job, and each\n * proposal reviewed in a table before anything is written:\n *\n * - **Write copy for products** — up to 50 saved products, picked from the\n * hub's rows; a job works through them a product at a time, and each row is\n * applied on its own or all at once.\n * - **Propose products** — a store's first products from a brief, created as\n * drafts with their prices empty and no photo, both marked for the person to\n * set.\n * - **Propose categories and discounts** — from a brief, created as the\n * catalog and discounts cards create them, every discount switched off.\n *\n * \"Create with AI\" beside Add product and in the empty catalog\n * (`productsCreate`, AGL-3596) opens the Propose products brief here.\n *\n * An import whose `productImport` option asked for it starts a copy job for\n * the products the import created, as they land. Every write is the hub's\n * (`ConsoleProductsHubZoneProps`); this card writes nothing itself.\n */\n\nconst BRIEF_MAX_CHARS = 4_000\n\n/** A column of the product picker, in the shared list table's own terms. */\ntype GridColDef = NonNullable<ListTableProps['columns']>[number]\n\ntype BriefKind = 'catalog' | 'categories'\n\n/** What each brief dialog says. */\nexport const AI_PRODUCTS_BRIEF_COPY: Readonly<\n Record<BriefKind, { title: string; label: string; placeholder: string; next: string; submit: string }>\n> = {\n catalog: {\n title: 'Propose products',\n label: 'What does the store sell?',\n placeholder: 'A candle studio in Asheville: hand-poured soy candles in 8 oz and 16 oz jars, and wax melts',\n next:\n 'You review up to twelve proposed products before any is created. Each is created as a draft at a ' +\n 'suggested price and with no photo, and nothing is on your storefront until you review it and activate it.',\n submit: 'Propose products',\n },\n categories: {\n title: 'Propose categories and discounts',\n label: 'What should shoppers be able to browse, and what offers suit the store?',\n placeholder: 'A trail running shop: shoes, apparel and hydration packs, with a welcome offer for new runners',\n next:\n 'You review the proposed categories and discounts before any is created. Discounts are created switched ' +\n 'off, and a shopper sees none until you switch it on.',\n submit: 'Propose',\n },\n}\n\nconst nameKey = (name: string) => name.replace(/\\s+/g, ' ').trim().toLowerCase()\n\n/** Which card a `products` job belongs to: from what it proposed, or from what this card started. */\nfunction targetOf(job: AiJobSummary, started: Readonly<Record<string, string>>): string | null {\n if (started[job.id]) return started[job.id]\n if (aiProductsBulkCount(job) !== null) return 'bulk'\n if (aiProductsProposalOfKind(job, 'catalog')) return 'catalog'\n if (aiProductsProposalOfKind(job, 'categories')) return 'categories'\n return null\n}\n\nexport function AiProductsHubCard(props: ConsoleProductsHubZoneProps) {\n const { hostId, products, lastImport, applyProductCopy, createProductDrafts, createCategories, createDiscountDrafts } =\n props\n const { orgId, verdict, jobs, notice, start } = useAiProductsJobs({\n hostId,\n orgId: props.orgId,\n // A bulk job is known by its brief while it runs; a catalog or categories\n // job started elsewhere is shown once it has proposed.\n follows: (job) => aiProductsBulkCount(job) !== null,\n })\n const [started, setStarted] = useState<Record<string, string>>({})\n const [picking, setPicking] = useState(false)\n const [picked, setPicked] = useState<string[]>([])\n const [brief, setBrief] = useState<{ kind: BriefKind; text: string } | null>(null)\n const [busy, setBusy] = useState(false)\n const handledImports = useRef(new Set<string>())\n\n const startBulk = useCallback(\n async (productIds: readonly string[]) => {\n const ids = productIds.slice(0, AI_PRODUCTS_BULK_MAX)\n if (!ids.length) return false\n const job = await start(aiProductsBulkBrief(ids.length), aiProductsJobInputs({ target: 'bulk', productIds: [...ids] }))\n if (job) setStarted((current) => ({ ...current, [job.id]: 'bulk' }))\n return Boolean(job)\n },\n [start],\n )\n\n // An import that asked for its copy starts the job once, as the import lands.\n useEffect(() => {\n if (verdict !== 'ready' || !lastImport || handledImports.current.has(lastImport.key)) return\n handledImports.current.add(lastImport.key)\n if (lastImport.options[AI_PRODUCTS_IMPORT_WRITE_COPY] && lastImport.productIds.length) {\n void startBulk(lastImport.productIds)\n }\n }, [verdict, lastImport, startBulk])\n\n // \"Create with AI\" beside Add product (AGL-3596) opens this card's\n // Propose products brief. Offered from the moment the card is on the page,\n // so the door draws from the shell's gates alone (AGL-3601) rather than\n // after this card's list of recent proposals is read; the start door\n // decides when the brief is sent, and says why in the dialog if it refuses.\n useEffect(\n () => registerAiProductsBriefOpener(hostId, () => setBrief({ kind: 'catalog', text: '' })),\n [hostId],\n )\n\n const heldNames = useMemo(() => new Set(products.map((product) => nameKey(product.name))), [products])\n const pickerRows = useMemo(\n () =>\n products.map((product) => ({\n $id: product.id,\n name: product.name,\n status: product.status,\n photo: product.hasPhoto ? 'Yes' : 'No photo',\n })),\n [products],\n )\n const pickerColumns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Product', flex: 1, minWidth: 180 },\n { field: 'status', headerName: 'Status', width: 110 },\n { field: 'photo', headerName: 'Photo', width: 110 },\n ],\n [],\n )\n\n const latest = (target: string) => jobs.find((job) => targetOf(job, started) === target) ?? null\n const bulkJob = latest('bulk')\n const catalogJob = latest('catalog')\n const categoriesJob = latest('categories')\n const tooMany = picked.length > AI_PRODUCTS_BULK_MAX\n const help = pluginDocsHelp('aiProducts', {\n anchor: '#propose-a-first-catalog',\n excerpt:\n 'Write product copy, propose a first catalog, or propose categories and discounts from a brief. You review every proposal before anything is saved.',\n })\n const copy = brief ? AI_PRODUCTS_BRIEF_COPY[brief.kind] : null\n\n const submitBrief = async () => {\n if (!brief?.text.trim()) return\n setBusy(true)\n try {\n const job = await start(brief.text.trim(), aiProductsJobInputs({ target: brief.kind }))\n if (job) {\n setStarted((current) => ({ ...current, [job.id]: brief.kind }))\n setBrief(null)\n }\n } finally {\n setBusy(false)\n }\n }\n\n const briefDialog = (\n <Dialog open={Boolean(brief)} onClose={busy ? undefined : () => setBrief(null)} fullWidth maxWidth=\"sm\">\n <DialogTitle>{copy?.title}</DialogTitle>\n <DialogContent>\n <Stack spacing={2} sx={{ pt: 1 }}>\n <TextField\n label={copy?.label}\n placeholder={copy?.placeholder}\n multiline\n minRows={4}\n value={brief?.text ?? ''}\n onChange={(event) =>\n setBrief((current) => (current ? { ...current, text: event.target.value.slice(0, BRIEF_MAX_CHARS) } : current))\n }\n helperText={`${(brief?.text.length ?? 0).toLocaleString('en-US')} / ${BRIEF_MAX_CHARS.toLocaleString('en-US')}`}\n disabled={busy}\n autoFocus\n />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {copy?.next}\n </Typography>\n {brief?.kind === 'catalog' ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n <Chip size=\"small\" color=\"warning\" variant=\"outlined\" label=\"Prices stay empty\" />\n <Chip size=\"small\" color=\"warning\" variant=\"outlined\" label=\"Photos are yours to add\" />\n </Stack>\n ) : null}\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setBrief(null)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy || !orgId || !brief?.text.trim()} onClick={() => void submitBrief()}>\n {copy?.submit}\n </Button>\n </DialogActions>\n </Dialog>\n )\n\n // Until the card's list of recent proposals is read — or where the jobs\n // route will not list them — it draws nothing but a brief the products door\n // opened, whose start door says any refusal in the dialog.\n if (verdict !== 'ready') return briefDialog\n\n const submitPicked = async () => {\n setBusy(true)\n try {\n if (await startBulk(picked)) {\n setPicking(false)\n setPicked([])\n }\n } finally {\n setBusy(false)\n }\n }\n\n return (\n <Box sx={{ border: 1, borderColor: 'divider', borderRadius: 1, p: 1.5 }} aria-label=\"Products assistant\">\n <Stack spacing={1.5}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'baseline' }}>\n <Typography variant=\"subtitle2\" sx={{ flexGrow: 1 }}>\n {'Build your catalog with AI'}\n </Typography>\n <Link href={help.href} target=\"_blank\" rel=\"noopener\" variant=\"caption\" title={help.excerptText}>\n {'How it works'}\n </Link>\n </Stack>\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={1}>\n <Button size=\"small\" variant=\"outlined\" disabled={!orgId || !products.length} onClick={() => setPicking(true)}>\n {'Write copy for products'}\n </Button>\n <Button size=\"small\" variant=\"outlined\" disabled={!orgId} onClick={() => setBrief({ kind: 'catalog', text: '' })}>\n {'Propose products'}\n </Button>\n <Button\n size=\"small\"\n variant=\"outlined\"\n disabled={!orgId}\n onClick={() => setBrief({ kind: 'categories', text: '' })}\n >\n {'Propose categories and discounts'}\n </Button>\n </Stack>\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n {bulkJob ? (\n <AiBulkCopyReview key={bulkJob.id} job={bulkJob} applyProductCopy={applyProductCopy} />\n ) : null}\n {catalogJob ? (\n <AiCatalogReview\n key={catalogJob.id}\n job={catalogJob}\n heldNames={heldNames}\n createProductDrafts={createProductDrafts}\n />\n ) : null}\n {categoriesJob ? (\n <AiCategoriesReview\n key={categoriesJob.id}\n job={categoriesJob}\n createCategories={createCategories}\n createDiscountDrafts={createDiscountDrafts}\n />\n ) : null}\n </Stack>\n\n <Dialog open={picking} onClose={busy ? undefined : () => setPicking(false)} fullWidth maxWidth=\"md\">\n <DialogTitle>{'Write copy for products'}</DialogTitle>\n <DialogContent>\n <Stack spacing={1.5} sx={{ pt: 1 }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Pick up to ${AI_PRODUCTS_BULK_MAX} products. Each gets a proposed description, search listing and ` +\n 'tags from its name, text, options and first photo, and you review every one before it is saved. ' +\n 'Prices are never written.'}\n </Typography>\n <ListTable\n rows={pickerRows}\n columns={pickerColumns}\n // A picker over the rows the hub hands its zone, not a list to\n // search: a filter here would narrow only those rows (AGL-3321).\n disableColumnFilter\n quickFilter={false}\n selectable={{ selected: picked, onChange: setPicked }}\n />\n {tooMany ? (\n <Alert severity=\"info\">{`Pick at most ${AI_PRODUCTS_BULK_MAX} products at a time.`}</Alert>\n ) : null}\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setPicking(false)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy || !picked.length || tooMany} onClick={() => void submitPicked()}>\n {picked.length ? `Write copy for ${picked.length}` : 'Write copy'}\n </Button>\n </DialogActions>\n </Dialog>\n\n {briefDialog}\n </Box>\n )\n}\nAiProductsHubCard.displayName = 'AiProductsHubCard'\n\nexport default AiProductsHubCard\n"],"names":["pluginDocsHelp","ListTable","Alert","Box","Button","Chip","Dialog","DialogActions","DialogContent","DialogTitle","Link","Stack","TextField","Typography","useCallback","useEffect","useMemo","useRef","useState","AI_PRODUCTS_BULK_MAX","AI_PRODUCTS_IMPORT_WRITE_COPY","aiProductsBulkBrief","aiProductsBulkCount","aiProductsJobInputs","aiProductsProposalOfKind","registerAiProductsBriefOpener","AiBulkCopyReview","AiCatalogReview","AiCategoriesReview","useAiProductsJobs","BRIEF_MAX_CHARS","AI_PRODUCTS_BRIEF_COPY","catalog","title","label","placeholder","next","submit","categories","nameKey","name","replace","trim","toLowerCase","targetOf","job","started","id","AiProductsHubCard","props","hostId","products","lastImport","applyProductCopy","createProductDrafts","createCategories","createDiscountDrafts","orgId","verdict","jobs","notice","start","follows","setStarted","picking","setPicking","picked","setPicked","brief","setBrief","busy","setBusy","handledImports","Set","startBulk","productIds","ids","slice","length","target","current","Boolean","has","key","add","options","kind","text","heldNames","map","product","pickerRows","$id","status","photo","hasPhoto","pickerColumns","field","headerName","flex","minWidth","width","latest","find","bulkJob","catalogJob","categoriesJob","tooMany","help","anchor","excerpt","copy","submitBrief","briefDialog","open","onClose","undefined","fullWidth","maxWidth","spacing","sx","pt","multiline","minRows","value","onChange","event","helperText","toLocaleString","disabled","autoFocus","variant","color","direction","useFlexGap","flexWrap","size","severity","onClick","submitPicked","border","borderColor","borderRadius","p","aria-label","alignItems","flexGrow","href","rel","excerptText","xs","sm","rows","columns","disableColumnFilter","quickFilter","selectable","selected","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,cAAc,QAAQ,mCAAkC;AAEjE,SAASC,SAAS,QAA6B,uDAAsD;AACrG,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,IAAI,EACJC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAEzE,SACEC,oBAAoB,EACpBC,6BAA6B,EAC7BC,mBAAmB,EACnBC,mBAAmB,EACnBC,mBAAmB,EACnBC,wBAAwB,QACnB,0BAAsB;AAC7B,SAASC,6BAA6B,QAAQ,2CAAuC;AACrF,SAASC,gBAAgB,EAAEC,eAAe,EAAEC,kBAAkB,QAAQ,uCAAmC;AACzG,SAASC,iBAAiB,QAAQ,4BAAwB;AAE1D;;;;;;;;;;;;;;;;;;;;CAoBC,GAED,MAAMC,kBAAkB;AAOxB,iCAAiC,GACjC,OAAO,MAAMC,yBAET;IACFC,SAAS;QACPC,OAAO;QACPC,OAAO;QACPC,aAAa;QACbC,MACE,sGACA;QACFC,QAAQ;IACV;IACAC,YAAY;QACVL,OAAO;QACPC,OAAO;QACPC,aAAa;QACbC,MACE,4GACA;QACFC,QAAQ;IACV;AACF,EAAC;AAED,MAAME,UAAU,CAACC,OAAiBA,KAAKC,OAAO,CAAC,QAAQ,KAAKC,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../../../libs/plugins/ai/src/lib/components/ai-products-hub-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport type { ConsoleProductsHubZoneProps } from './ai-product-zones'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { ListTable, type ListTableProps } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport {\n Alert,\n Box,\n Button,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Link,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport type { AiJobSummary } from '../model/ai-jobs.types'\nimport {\n AI_PRODUCTS_BULK_MAX,\n AI_PRODUCTS_IMPORT_WRITE_COPY,\n aiProductsBulkBrief,\n aiProductsBulkCount,\n aiProductsJobInputs,\n aiProductsProposalOfKind,\n} from '../model/ai-products'\nimport { registerAiProductsBriefOpener } from './ai-products-create-button.component'\nimport { AiBulkCopyReview, AiCatalogReview, AiCategoriesReview } from './ai-products-proposals.component'\nimport { useAiProductsJobs } from './use-ai-products-jobs'\n\n/**\n * Commerce by AI on the products hub (AGL-2916), through the `productsHub`\n * zone. Three things a person asks for, each a `products` job, and each\n * proposal reviewed in a table before anything is written:\n *\n * - **Write copy for products** — up to 50 saved products, picked from the\n * hub's rows; a job works through them a product at a time, and each row is\n * applied on its own or all at once.\n * - **Propose products** — a store's first products from a brief, created as\n * drafts with their prices empty and no photo, both marked for the person to\n * set.\n * - **Propose categories and discounts** — from a brief, created as the\n * catalog and discounts cards create them, every discount switched off.\n *\n * \"Create with AI\" beside Add product and in the empty catalog\n * (`productsCreate`, AGL-3596) opens the Propose products brief here.\n *\n * An import whose `productImport` option asked for it starts a copy job for\n * the products the import created, as they land. Every write is the hub's\n * (`ConsoleProductsHubZoneProps`); this card writes nothing itself.\n */\n\nconst BRIEF_MAX_CHARS = 4_000\n\n/**\n * Why \"Write copy for products\" is off (AGL-3982): it writes for the products\n * listed on the page, and none are — a new catalog, or filters that match\n * nothing.\n */\nexport const NO_PRODUCTS_FOR_COPY =\n 'Add a product first, or draft some with Propose products. AI writes copy for the products ' +\n 'listed below, so clear any filters that hide them.'\n\n/** A column of the product picker, in the shared list table's own terms. */\ntype GridColDef = NonNullable<ListTableProps['columns']>[number]\n\ntype BriefKind = 'catalog' | 'categories'\n\n/** What each brief dialog says. */\nexport const AI_PRODUCTS_BRIEF_COPY: Readonly<\n Record<BriefKind, { title: string; label: string; placeholder: string; next: string; submit: string }>\n> = {\n catalog: {\n title: 'Propose products',\n label: 'What does the store sell?',\n placeholder: 'A candle studio in Asheville: hand-poured soy candles in 8 oz and 16 oz jars, and wax melts',\n next:\n 'You review up to twelve proposed products before any is created. Each is created as a draft at a ' +\n 'suggested price and with no photo, and nothing is on your storefront until you review it and activate it.',\n submit: 'Propose products',\n },\n categories: {\n title: 'Propose categories and discounts',\n label: 'What should shoppers be able to browse, and what offers suit the store?',\n placeholder: 'A trail running shop: shoes, apparel and hydration packs, with a welcome offer for new runners',\n next:\n 'You review the proposed categories and discounts before any is created. Discounts are created switched ' +\n 'off, and a shopper sees none until you switch it on.',\n submit: 'Propose',\n },\n}\n\nconst nameKey = (name: string) => name.replace(/\\s+/g, ' ').trim().toLowerCase()\n\n/** Which card a `products` job belongs to: from what it proposed, or from what this card started. */\nfunction targetOf(job: AiJobSummary, started: Readonly<Record<string, string>>): string | null {\n if (started[job.id]) return started[job.id]\n if (aiProductsBulkCount(job) !== null) return 'bulk'\n if (aiProductsProposalOfKind(job, 'catalog')) return 'catalog'\n if (aiProductsProposalOfKind(job, 'categories')) return 'categories'\n return null\n}\n\nexport function AiProductsHubCard(props: ConsoleProductsHubZoneProps) {\n const { hostId, products, lastImport, applyProductCopy, createProductDrafts, createCategories, createDiscountDrafts } =\n props\n const { orgId, verdict, jobs, notice, start } = useAiProductsJobs({\n hostId,\n orgId: props.orgId,\n // A bulk job is known by its brief while it runs; a catalog or categories\n // job started elsewhere is shown once it has proposed.\n follows: (job) => aiProductsBulkCount(job) !== null,\n })\n const [started, setStarted] = useState<Record<string, string>>({})\n const [picking, setPicking] = useState(false)\n const [picked, setPicked] = useState<string[]>([])\n const [brief, setBrief] = useState<{ kind: BriefKind; text: string } | null>(null)\n const [busy, setBusy] = useState(false)\n const handledImports = useRef(new Set<string>())\n\n const startBulk = useCallback(\n async (productIds: readonly string[]) => {\n const ids = productIds.slice(0, AI_PRODUCTS_BULK_MAX)\n if (!ids.length) return false\n const job = await start(aiProductsBulkBrief(ids.length), aiProductsJobInputs({ target: 'bulk', productIds: [...ids] }))\n if (job) setStarted((current) => ({ ...current, [job.id]: 'bulk' }))\n return Boolean(job)\n },\n [start],\n )\n\n // An import that asked for its copy starts the job once, as the import lands.\n useEffect(() => {\n if (verdict !== 'ready' || !lastImport || handledImports.current.has(lastImport.key)) return\n handledImports.current.add(lastImport.key)\n if (lastImport.options[AI_PRODUCTS_IMPORT_WRITE_COPY] && lastImport.productIds.length) {\n void startBulk(lastImport.productIds)\n }\n }, [verdict, lastImport, startBulk])\n\n // \"Create with AI\" beside Add product (AGL-3596) opens this card's\n // Propose products brief. Offered from the moment the card is on the page,\n // so the door draws from the shell's gates alone (AGL-3601) rather than\n // after this card's list of recent proposals is read; the start door\n // decides when the brief is sent, and says why in the dialog if it refuses.\n useEffect(\n () => registerAiProductsBriefOpener(hostId, () => setBrief({ kind: 'catalog', text: '' })),\n [hostId],\n )\n\n const heldNames = useMemo(() => new Set(products.map((product) => nameKey(product.name))), [products])\n const pickerRows = useMemo(\n () =>\n products.map((product) => ({\n $id: product.id,\n name: product.name,\n status: product.status,\n photo: product.hasPhoto ? 'Yes' : 'No photo',\n })),\n [products],\n )\n const pickerColumns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Product', flex: 1, minWidth: 180 },\n { field: 'status', headerName: 'Status', width: 110 },\n { field: 'photo', headerName: 'Photo', width: 110 },\n ],\n [],\n )\n\n const latest = (target: string) => jobs.find((job) => targetOf(job, started) === target) ?? null\n const bulkJob = latest('bulk')\n const catalogJob = latest('catalog')\n const categoriesJob = latest('categories')\n const tooMany = picked.length > AI_PRODUCTS_BULK_MAX\n const help = pluginDocsHelp('aiProducts', {\n anchor: '#propose-a-first-catalog',\n excerpt:\n 'Write product copy, propose a first catalog, or propose categories and discounts from a brief. You review every proposal before anything is saved.',\n })\n const copy = brief ? AI_PRODUCTS_BRIEF_COPY[brief.kind] : null\n\n const submitBrief = async () => {\n if (!brief?.text.trim()) return\n setBusy(true)\n try {\n const job = await start(brief.text.trim(), aiProductsJobInputs({ target: brief.kind }))\n if (job) {\n setStarted((current) => ({ ...current, [job.id]: brief.kind }))\n setBrief(null)\n }\n } finally {\n setBusy(false)\n }\n }\n\n const briefDialog = (\n <Dialog open={Boolean(brief)} onClose={busy ? undefined : () => setBrief(null)} fullWidth maxWidth=\"sm\">\n <DialogTitle>{copy?.title}</DialogTitle>\n <DialogContent>\n <Stack spacing={2} sx={{ pt: 1 }}>\n <TextField\n label={copy?.label}\n placeholder={copy?.placeholder}\n multiline\n minRows={4}\n value={brief?.text ?? ''}\n onChange={(event) =>\n setBrief((current) => (current ? { ...current, text: event.target.value.slice(0, BRIEF_MAX_CHARS) } : current))\n }\n helperText={`${(brief?.text.length ?? 0).toLocaleString('en-US')} / ${BRIEF_MAX_CHARS.toLocaleString('en-US')}`}\n disabled={busy}\n autoFocus\n />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {copy?.next}\n </Typography>\n {brief?.kind === 'catalog' ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n <Chip size=\"small\" color=\"warning\" variant=\"outlined\" label=\"Prices stay empty\" />\n <Chip size=\"small\" color=\"warning\" variant=\"outlined\" label=\"Photos are yours to add\" />\n </Stack>\n ) : null}\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setBrief(null)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy || !orgId || !brief?.text.trim()} onClick={() => void submitBrief()}>\n {copy?.submit}\n </Button>\n </DialogActions>\n </Dialog>\n )\n\n // Until the card's list of recent proposals is read — or where the jobs\n // route will not list them — it draws nothing but a brief the products door\n // opened, whose start door says any refusal in the dialog.\n if (verdict !== 'ready') return briefDialog\n\n const submitPicked = async () => {\n setBusy(true)\n try {\n if (await startBulk(picked)) {\n setPicking(false)\n setPicked([])\n }\n } finally {\n setBusy(false)\n }\n }\n\n return (\n <Box sx={{ border: 1, borderColor: 'divider', borderRadius: 1, p: 1.5 }} aria-label=\"Products assistant\">\n <Stack spacing={1.5}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'baseline' }}>\n <Typography variant=\"subtitle2\" sx={{ flexGrow: 1 }}>\n {'Build your catalog with AI'}\n </Typography>\n <Link href={help.href} target=\"_blank\" rel=\"noopener\" variant=\"caption\" title={help.excerptText}>\n {'How it works'}\n </Link>\n </Stack>\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={1}>\n {/* Copy is written for the products listed on this page (AGL-3982):\n with none listed the button says why rather than going dead. */}\n <BlockedControl blocked={Boolean(orgId) && !products.length} reason={NO_PRODUCTS_FOR_COPY}>\n <Button size=\"small\" variant=\"outlined\" disabled={!orgId || !products.length} onClick={() => setPicking(true)}>\n {'Write copy for products'}\n </Button>\n </BlockedControl>\n <Button size=\"small\" variant=\"outlined\" disabled={!orgId} onClick={() => setBrief({ kind: 'catalog', text: '' })}>\n {'Propose products'}\n </Button>\n <Button\n size=\"small\"\n variant=\"outlined\"\n disabled={!orgId}\n onClick={() => setBrief({ kind: 'categories', text: '' })}\n >\n {'Propose categories and discounts'}\n </Button>\n </Stack>\n {/* The same reason in plain view, for a touch screen with no hover. */}\n {orgId && !products.length ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {NO_PRODUCTS_FOR_COPY}\n </Typography>\n ) : null}\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n {bulkJob ? (\n <AiBulkCopyReview key={bulkJob.id} job={bulkJob} applyProductCopy={applyProductCopy} />\n ) : null}\n {catalogJob ? (\n <AiCatalogReview\n key={catalogJob.id}\n job={catalogJob}\n heldNames={heldNames}\n createProductDrafts={createProductDrafts}\n />\n ) : null}\n {categoriesJob ? (\n <AiCategoriesReview\n key={categoriesJob.id}\n job={categoriesJob}\n createCategories={createCategories}\n createDiscountDrafts={createDiscountDrafts}\n />\n ) : null}\n </Stack>\n\n <Dialog open={picking} onClose={busy ? undefined : () => setPicking(false)} fullWidth maxWidth=\"md\">\n <DialogTitle>{'Write copy for products'}</DialogTitle>\n <DialogContent>\n <Stack spacing={1.5} sx={{ pt: 1 }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Pick up to ${AI_PRODUCTS_BULK_MAX} products. Each gets a proposed description, search listing and ` +\n 'tags from its name, text, options and first photo, and you review every one before it is saved. ' +\n 'Prices are never written.'}\n </Typography>\n <ListTable\n rows={pickerRows}\n columns={pickerColumns}\n // A picker over the rows the hub hands its zone, not a list to\n // search: a filter here would narrow only those rows (AGL-3321).\n disableColumnFilter\n quickFilter={false}\n selectable={{ selected: picked, onChange: setPicked }}\n />\n {tooMany ? (\n <Alert severity=\"info\">{`Pick at most ${AI_PRODUCTS_BULK_MAX} products at a time.`}</Alert>\n ) : null}\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setPicking(false)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy || !picked.length || tooMany} onClick={() => void submitPicked()}>\n {picked.length ? `Write copy for ${picked.length}` : 'Write copy'}\n </Button>\n </DialogActions>\n </Dialog>\n\n {briefDialog}\n </Box>\n )\n}\nAiProductsHubCard.displayName = 'AiProductsHubCard'\n\nexport default AiProductsHubCard\n"],"names":["pluginDocsHelp","BlockedControl","ListTable","Alert","Box","Button","Chip","Dialog","DialogActions","DialogContent","DialogTitle","Link","Stack","TextField","Typography","useCallback","useEffect","useMemo","useRef","useState","AI_PRODUCTS_BULK_MAX","AI_PRODUCTS_IMPORT_WRITE_COPY","aiProductsBulkBrief","aiProductsBulkCount","aiProductsJobInputs","aiProductsProposalOfKind","registerAiProductsBriefOpener","AiBulkCopyReview","AiCatalogReview","AiCategoriesReview","useAiProductsJobs","BRIEF_MAX_CHARS","NO_PRODUCTS_FOR_COPY","AI_PRODUCTS_BRIEF_COPY","catalog","title","label","placeholder","next","submit","categories","nameKey","name","replace","trim","toLowerCase","targetOf","job","started","id","AiProductsHubCard","props","hostId","products","lastImport","applyProductCopy","createProductDrafts","createCategories","createDiscountDrafts","orgId","verdict","jobs","notice","start","follows","setStarted","picking","setPicking","picked","setPicked","brief","setBrief","busy","setBusy","handledImports","Set","startBulk","productIds","ids","slice","length","target","current","Boolean","has","key","add","options","kind","text","heldNames","map","product","pickerRows","$id","status","photo","hasPhoto","pickerColumns","field","headerName","flex","minWidth","width","latest","find","bulkJob","catalogJob","categoriesJob","tooMany","help","anchor","excerpt","copy","submitBrief","briefDialog","open","onClose","undefined","fullWidth","maxWidth","spacing","sx","pt","multiline","minRows","value","onChange","event","helperText","toLocaleString","disabled","autoFocus","variant","color","direction","useFlexGap","flexWrap","size","severity","onClick","submitPicked","border","borderColor","borderRadius","p","aria-label","alignItems","flexGrow","href","rel","excerptText","xs","sm","blocked","reason","rows","columns","disableColumnFilter","quickFilter","selectable","selected","displayName"],"mappings":"AAAA;;;;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ersFromInputs } from "../model/ai-site-start.js";
31
31
  import { AiSiteStartCard } from "./ai-site-start-card.component.js";
32
32
  import { AI_JOB_TERMINAL_STATUSES } from "../model/ai-jobs.types.js";
33
33
  import { followAiJobEvents } from "./ai-job-events.js";
34
- import { aiCreditsBillingHref, aiSiteBuildDoneLinks, aiStoreFinishLinks } from "./ai-job-links.js";
34
+ import { aiCreditsBillingHref, aiSiteBuildDoneLinks, aiStoreFinishHostId, aiStoreFinishLinks } from "./ai-job-links.js";
35
35
  import { AiStoreFinishCard } from "./ai-store-finish-card.component.js";
36
36
  import { AiJobPlan } from "./ai-job-plan.component.js";
37
37
  import { aiBuildCanRetry, aiBuildRetryCreditRange } from "../model/ai-build-progress.js";
@@ -651,7 +651,8 @@ export function AiSiteBuildPage({ hostId, segments, basePath }) {
651
651
  ]
652
652
  }),
653
653
  storeFinish && /*#__PURE__*/ _jsx(AiStoreFinishCard, {
654
- steps: storeFinish
654
+ steps: storeFinish,
655
+ hostId: aiStoreFinishHostId(ready)
655
656
  }),
656
657
  paused && // Paused by the meter (AGL-3660): the way to more credits — the
657
658
  // workspace's own Billing page, where plans and the AI add-on are