@aglyn/plugins-ai 1.0.0-beta.252 → 1.0.0-beta.254

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 (65) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/ai-site-start-card.component.js +16 -8
  3. package/src/lib/components/ai-site-start-card.component.js.map +1 -1
  4. package/src/lib/jobs/ai-job-form-dataset.d.ts +6 -1
  5. package/src/lib/jobs/ai-job-form-dataset.js +7 -2
  6. package/src/lib/jobs/ai-job-form-dataset.js.map +1 -1
  7. package/src/lib/jobs/ai-job-page-language.d.ts +10 -5
  8. package/src/lib/jobs/ai-job-page-language.js +10 -5
  9. package/src/lib/jobs/ai-job-page-language.js.map +1 -1
  10. package/src/lib/jobs/ai-job-plan-step.d.ts +13 -1
  11. package/src/lib/jobs/ai-job-plan-step.js +27 -8
  12. package/src/lib/jobs/ai-job-plan-step.js.map +1 -1
  13. package/src/lib/jobs/ai-job-site-content.d.ts +32 -16
  14. package/src/lib/jobs/ai-job-site-content.js +43 -20
  15. package/src/lib/jobs/ai-job-site-content.js.map +1 -1
  16. package/src/lib/jobs/ai-job-site-datasets.d.ts +1 -1
  17. package/src/lib/jobs/ai-job-site-datasets.js +2 -2
  18. package/src/lib/jobs/ai-job-site-datasets.js.map +1 -1
  19. package/src/lib/jobs/ai-job-site-step.d.ts +3 -0
  20. package/src/lib/jobs/ai-job-site-step.js +25 -12
  21. package/src/lib/jobs/ai-job-site-step.js.map +1 -1
  22. package/src/lib/layout-language/ai-layout-language.js +5 -1
  23. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  24. package/src/lib/layout-language/ai-layout-links.js +5 -2
  25. package/src/lib/layout-language/ai-layout-links.js.map +1 -1
  26. package/src/lib/model/ai-credit-estimate.d.ts +7 -1
  27. package/src/lib/model/ai-credit-estimate.js +7 -1
  28. package/src/lib/model/ai-credit-estimate.js.map +1 -1
  29. package/src/lib/model/ai-plan-capabilities.d.ts +5 -0
  30. package/src/lib/model/ai-plan-capabilities.js.map +1 -1
  31. package/src/lib/model/ai-site-job.d.ts +32 -12
  32. package/src/lib/model/ai-site-job.js +35 -20
  33. package/src/lib/model/ai-site-job.js.map +1 -1
  34. package/src/lib/model/ai-site-kinds.d.ts +5 -5
  35. package/src/lib/model/ai-site-kinds.js +5 -5
  36. package/src/lib/model/ai-site-kinds.js.map +1 -1
  37. package/src/lib/model/ai-site-start-seo.d.ts +11 -2
  38. package/src/lib/model/ai-site-start-seo.js +29 -15
  39. package/src/lib/model/ai-site-start-seo.js.map +1 -1
  40. package/src/lib/providers/anthropic.js +29 -7
  41. package/src/lib/providers/anthropic.js.map +1 -1
  42. package/src/lib/providers/contract.d.ts +19 -1
  43. package/src/lib/providers/contract.js +10 -0
  44. package/src/lib/providers/contract.js.map +1 -1
  45. package/src/lib/providers/routing.js +24 -4
  46. package/src/lib/providers/routing.js.map +1 -1
  47. package/src/lib/runtime/ai-dev-env.d.ts +25 -4
  48. package/src/lib/runtime/ai-dev-env.js +41 -14
  49. package/src/lib/runtime/ai-dev-env.js.map +1 -1
  50. package/src/lib/runtime/ai-dev-replay.d.ts +4 -0
  51. package/src/lib/runtime/ai-dev-replay.js +4 -0
  52. package/src/lib/runtime/ai-dev-replay.js.map +1 -1
  53. package/src/lib/runtime/ai-doctrine-validators.js +13 -3
  54. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  55. package/src/lib/runtime/ai-eval-live.d.ts +35 -1
  56. package/src/lib/runtime/ai-eval-live.js +46 -2
  57. package/src/lib/runtime/ai-eval-live.js.map +1 -1
  58. package/src/lib/runtime/ai-live-batch.d.ts +20 -4
  59. package/src/lib/runtime/ai-live-batch.js +57 -10
  60. package/src/lib/runtime/ai-live-batch.js.map +1 -1
  61. package/src/lib/runtime/ai-runtime.js +4 -2
  62. package/src/lib/runtime/ai-runtime.js.map +1 -1
  63. package/src/lib/server/ai-media-image.d.ts +5 -1
  64. package/src/lib/server/ai-media-image.js +6 -2
  65. package/src/lib/server/ai-media-image.js.map +1 -1
@@ -16,12 +16,13 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
16
16
  * limitations under the License.
17
17
  */ import { resolveMediaSrc } from "@aglyn/aglyn/app-utils/media-ref";
18
18
  import { hostRoleCanWrite } from "@aglyn/aglyn/app-utils/organizations";
19
+ import { resolveEffectivePlan } from "@aglyn/aglyn/app-utils/plan-entitlements";
19
20
  import { pluginResourceDraftWriter } from "@aglyn/aglyn/plugin-manager/plugin-resource-drafts";
20
21
  import { publishContentEntries, writeContentCollection, writeContentEntryDraft } from "@aglyn/tenant-data-admin/server/content-entry-drafts";
21
22
  import { aiCatalogPrice, aiProductsProposalOf } from "../model/ai-products.js";
22
23
  import { aiSiteKindOfInputs } from "../model/ai-site-kinds.js";
23
24
  import { AI_SITE_BLOG_NAME, AI_SITE_BLOG_SLUGS, aiSiteWords } from "../model/ai-site-job.js";
24
- import { AI_STEP_TIERS } from "../providers/catalog.js";
25
+ import { AI_STEP_TIERS, aiCatalogEntry, aiDefaultModelFor } from "../providers/catalog.js";
25
26
  import { aiModelForStep } from "../providers/routing.js";
26
27
  import { AI_BLOG_POST_MAX_TOKENS, AI_BLOG_POST_STEP, generateAiBlogPost } from "../runtime/ai-blog-post-generation.js";
27
28
  import { aiLayoutStarterPhotos } from "../layout-language/ai-layout-pictures.js";
@@ -36,13 +37,14 @@ import { aiGenerationSpent, aiUnspentOutcome } from "./ai-job-generation.js";
36
37
  *
37
38
  * A site of the kind "Blog & writing" or "Online store" got the right look
38
39
  * and pages, and nothing real in them: the writing page's cards and the
39
- * shop's grid named posts and products nobody had written. On a paid plan,
40
- * the scaffold now builds one more part for those two kinds, before the
41
- * pages, each its own row with its own timer and credits:
40
+ * shop's grid named posts and products nobody had written. The scaffold now
41
+ * builds one more part for those two kinds, before the pages, each its own
42
+ * row with its own timer and credits — a store's on a paid plan only:
42
43
  *
43
44
  * - WRITING YOUR FIRST POSTS: a content collection "Blog" — the platform's
44
45
  * own blog, served at `/{slug}` with an entry page per post — and
45
- * `AI_SITE_POSTS` posts in it, one generation a pass. Each is written as a
46
+ * `AI_SITE_POSTS` posts in it on a paid plan, `AI_SITE_FREE_POSTS` on the
47
+ * Free taste, one generation a pass. Each is written as a
46
48
  * draft through the same rules the console's routes hold
47
49
  * (`content-entry-drafts.ts`), bylined with the business's name the person
48
50
  * gave, and given a cover: a stock photo of its own title where the
@@ -68,35 +70,54 @@ import { aiGenerationSpent, aiUnspentOutcome } from "./ai-job-generation.js";
68
70
  * sections that show them list the real records (`aiSiteListings`,
69
71
  * `ai-layout-listings.ts`): the shop's Product grid, the blog's posts.
70
72
  *
71
- * ── Not on the Free taste ────────────────────────────────────────────────
73
+ * ── On the Free taste ────────────────────────────────────────────────────
72
74
  *
73
- * A guided start's Free site writes no first posts and no products. Built on
74
- * an empty site with its layout and form, it leaves 57 credits once its eight
75
- * sections and its retried page's room are held (`aiFreeSiteSectionsWithin`,
76
- * AGL-3660), which since AGL-3781 would hold the 4 one post costs at its worst
77
- * on the fast tier; but a Free site has no content part of its own, and a Free
78
- * plan includes neither the `commerce` feature nor a product
79
- * (`productsPerHost` is 0).
80
- * `ai-job-free-site.spec.ts` shows the arithmetic. Free sites keep the pages
81
- * their kind already describes; the owner adds posts and products after.
75
+ * A guided start's Free blog writes ONE first post (Zach, 2026-10-14,
76
+ * AGL-3798), and a Free store no products. Built on an empty site with its
77
+ * layout and form, a Free site leaves 57 credits once its eight sections and
78
+ * its retried page's room are held (`aiFreeSiteSectionsWithin`, AGL-3660).
79
+ * One post at its worst is 4 on the fast tier since AGL-3781 (Claude Haiku
80
+ * 5.5 at the platform's markup), so a Free blog's post is written there
81
+ * (`aiSitePostModel`): on the balanced tier `copy.blog` routes to, the same
82
+ * post is 68, past what the wall leaves. The wall counts it
83
+ * (`AI_FREE_SITE_WORST_CASE_CREDITS.post`), and its eight sections still fit
84
+ * beside it. A Free plan includes neither the `commerce` feature nor a
85
+ * product (`productsPerHost` is 0), so a Free store keeps the pages its kind
86
+ * describes and the owner adds products after.
87
+ * `ai-job-free-site.spec.ts` shows the arithmetic.
82
88
  */ /** How many first posts a paid blog gets. */ export const AI_SITE_POSTS = 3;
89
+ /** How many first posts a Free blog gets (`model/ai-site-job.ts`, which the Free wall reads). */ export { AI_SITE_FREE_POSTS } from "../model/ai-site-job.js";
83
90
  /** How many first products a paid store gets: asked for, and the most written. */ export const AI_SITE_PRODUCTS = {
84
91
  min: 3,
85
92
  max: 6
86
93
  };
87
94
  /** What a products row says when none of what we made could be written: our failure, refunded. */ export const AI_SITE_PRODUCTS_NOT_WRITTEN_COPY = 'Your first products could not be added this time.';
88
- /** What each part's row reads. */ export const AI_SITE_POSTS_LABEL = 'Writing your first posts';
95
+ /** What each part's row reads; a Free blog's one post reads in the singular. */ export const AI_SITE_POSTS_LABEL = 'Writing your first posts';
96
+ export const AI_SITE_POST_LABEL = 'Writing your first post';
89
97
  export const AI_SITE_PRODUCTS_LABEL = 'Adding your first products';
90
98
  /** The blog the posts go in, and the addresses it may answer at (`model/ai-site-job.ts`). */ export { AI_SITE_BLOG_NAME, AI_SITE_BLOG_SLUGS } from "../model/ai-site-job.js";
91
99
  /** The input a site unit's own job carries what the part needs in. */ export const AI_SITE_CONTENT_INPUT = 'siteContent';
92
- /** Which part a site of these answers gets; `null` for the Free taste and every other kind. */ export function aiSiteContentPart(inputs, freeTaste) {
100
+ /** Which part a site of these answers gets: a blog's posts, a paid store's products, else `null`. */ export function aiSiteContentPart(inputs, freeTaste) {
93
101
  var _aiSiteKindOfInputs;
94
- if (freeTaste) return null;
95
102
  const kind = (_aiSiteKindOfInputs = aiSiteKindOfInputs(inputs)) == null ? void 0 : _aiSiteKindOfInputs.id;
96
103
  if (kind === 'blog') return 'posts';
97
- if (kind === 'store') return 'products';
104
+ if (kind === 'store' && !freeTaste) return 'products';
98
105
  return null;
99
106
  }
107
+ /**
108
+ * The model a site's post is written on: the routed one, except that a Free
109
+ * blog's post is written on its provider's fast tier, as a Free site's plan
110
+ * and look are (`aiSitePlanModel`, `aiSiteLookModel`). On the balanced tier
111
+ * `copy.blog` routes to, one post at its worst is past what the Free wall
112
+ * leaves. A model the creator picked by name stays theirs.
113
+ */ export function aiSitePostModel(job, routed, freeTaste) {
114
+ var _ref;
115
+ if (!freeTaste) return routed;
116
+ const picked = typeof job.model === 'string' ? job.model.trim() : '';
117
+ if (picked && picked !== 'auto') return routed;
118
+ const entry = aiCatalogEntry(routed);
119
+ return (_ref = entry ? aiDefaultModelFor(entry.provider, 'fast') : undefined) != null ? _ref : routed;
120
+ }
100
121
  /**
101
122
  * ASSUMED: what one post pass reads and writes beside its generation: the
102
123
  * host, the collection's slug claim and the entry's transaction.
@@ -213,7 +234,9 @@ const limitReview = (message)=>({
213
234
  return async (context)=>{
214
235
  var _ref;
215
236
  const { job, firestore, signal } = context;
216
- const model = (_ref = context.modelFor == null ? void 0 : context.modelFor.call(context, AI_BLOG_POST_STEP)) != null ? _ref : aiModelForStep(AI_BLOG_POST_STEP);
237
+ const freeTaste = Boolean(context.org) && resolveEffectivePlan(context.org) === 'free';
238
+ const routed = (_ref = context.modelFor == null ? void 0 : context.modelFor.call(context, AI_BLOG_POST_STEP)) != null ? _ref : aiModelForStep(AI_BLOG_POST_STEP);
239
+ const model = aiSitePostModel(job, routed, freeTaste);
217
240
  if (!job.hostId) return _extends({}, aiUnspentOutcome(model), {
218
241
  failure: 'Open the site before writing its posts.'
219
242
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-job-site-content.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { resolveMediaSrc } from '@aglyn/aglyn/app-utils/media-ref'\nimport { hostRoleCanWrite } from '@aglyn/aglyn/app-utils/organizations'\nimport { pluginResourceDraftWriter } from '@aglyn/aglyn/plugin-manager/plugin-resource-drafts'\nimport {\n publishContentEntries,\n writeContentCollection,\n writeContentEntryDraft,\n} from '@aglyn/tenant-data-admin/server/content-entry-drafts'\nimport { aiCatalogPrice, aiProductsProposalOf } from '../model/ai-products'\nimport type { AiJob, AiJobOutput } from '../model/ai-jobs.types'\nimport { aiSiteKindOfInputs } from '../model/ai-site-kinds'\nimport { AI_SITE_BLOG_NAME, AI_SITE_BLOG_SLUGS, aiSiteWords } from '../model/ai-site-job'\nimport { AI_STEP_TIERS } from '../providers/catalog'\nimport { aiModelForStep } from '../providers/routing'\nimport {\n AI_BLOG_POST_MAX_TOKENS,\n AI_BLOG_POST_STEP,\n generateAiBlogPost,\n} from '../runtime/ai-blog-post-generation'\nimport {\n aiLayoutStarterPhotos,\n type AiLayoutPicturePhoto,\n type AiLayoutPictureSlot,\n} from '../layout-language/ai-layout-pictures'\nimport { aiOriginJobId } from './ai-job-draft-ids'\nimport { aiLayoutStockPhotoSource, aiStockPhotoWordsOf } from './ai-layout-stock-photos'\nimport {\n aiLayoutListingId,\n aiLayoutListingPlacements,\n type AiLayoutListing,\n type AiLayoutListingScreen,\n} from '../layout-language/ai-layout-listings'\nimport { aiJobAdmissionFor, type AiJobAdmissionRefusal } from './ai-job-admission'\nimport { aiJobStepBudget } from './ai-job-budget'\nimport { aiGenerationSpent, aiUnspentOutcome } from './ai-job-generation'\nimport type { AiJobStepContext, AiJobStepOutcome, AiJobStepRunner } from './ai-job-text-step'\n\n/**\n * A GUIDED START'S FIRST POSTS AND FIRST PRODUCTS (AGL-3676).\n *\n * A site of the kind \"Blog & writing\" or \"Online store\" got the right look\n * and pages, and nothing real in them: the writing page's cards and the\n * shop's grid named posts and products nobody had written. On a paid plan,\n * the scaffold now builds one more part for those two kinds, before the\n * pages, each its own row with its own timer and credits:\n *\n * - WRITING YOUR FIRST POSTS: a content collection \"Blog\" — the platform's\n * own blog, served at `/{slug}` with an entry page per post — and\n * `AI_SITE_POSTS` posts in it, one generation a pass. Each is written as a\n * draft through the same rules the console's routes hold\n * (`content-entry-drafts.ts`), bylined with the business's name the person\n * gave, and given a cover: a stock photo of its own title where the\n * deployment has a library, else a starter (AGL-3676), which the blog's\n * cards show. They go live with the\n * site: the guided start's publish publishes them with its pages\n * (`aiPublishSitePosts`), as a person's Publish would.\n * - ADDING YOUR FIRST PRODUCTS: the `products` step's catalog, asked for\n * `AI_SITE_PRODUCTS` products, each written through the commerce plugin's\n * `product` draft writer, at the price the catalog suggests for what it\n * is (Zach, 2026-10-12: a bar of soap is not priced like a gift set),\n * which code keeps in range (`aiCatalogPrice`); a product with no price\n * in range takes the writer's default price (his 2026-10-08 \"default a\n * price\", AGL-3676). Every price is the owner's to change, and the job's\n * row says so. Since the\n * 2026-10-08 Ember & Wick start, whose store showed no product at all,\n * each is LISTED at once (`comingSoon`: written `active`). Each gets a\n * photo in its slot, a stock photo of its own words where the deployment\n * has a library, else a starter, for the owner to replace with their\n * own.\n *\n * The pages built after them are told their titles or names, and the\n * sections that show them list the real records (`aiSiteListings`,\n * `ai-layout-listings.ts`): the shop's Product grid, the blog's posts.\n *\n * ── Not on the Free taste ────────────────────────────────────────────────\n *\n * A guided start's Free site writes no first posts and no products. Built on\n * an empty site with its layout and form, it leaves 57 credits once its eight\n * sections and its retried page's room are held (`aiFreeSiteSectionsWithin`,\n * AGL-3660), which since AGL-3781 would hold the 4 one post costs at its worst\n * on the fast tier; but a Free site has no content part of its own, and a Free\n * plan includes neither the `commerce` feature nor a product\n * (`productsPerHost` is 0).\n * `ai-job-free-site.spec.ts` shows the arithmetic. Free sites keep the pages\n * their kind already describes; the owner adds posts and products after.\n */\n\n/** How many first posts a paid blog gets. */\nexport const AI_SITE_POSTS = 3\n\n/** How many first products a paid store gets: asked for, and the most written. */\nexport const AI_SITE_PRODUCTS = { min: 3, max: 6 } as const\n\n/** What a products row says when none of what we made could be written: our failure, refunded. */\nexport const AI_SITE_PRODUCTS_NOT_WRITTEN_COPY = 'Your first products could not be added this time.'\n\n/** What each part's row reads. */\nexport const AI_SITE_POSTS_LABEL = 'Writing your first posts'\nexport const AI_SITE_PRODUCTS_LABEL = 'Adding your first products'\n\n/** The blog the posts go in, and the addresses it may answer at (`model/ai-site-job.ts`). */\nexport { AI_SITE_BLOG_NAME, AI_SITE_BLOG_SLUGS } from '../model/ai-site-job'\n\n/** The input a site unit's own job carries what the part needs in. */\nexport const AI_SITE_CONTENT_INPUT = 'siteContent'\n\n/** Which part a site of these answers gets; `null` for the Free taste and every other kind. */\nexport function aiSiteContentPart(\n inputs: Readonly<Record<string, unknown>> | null | undefined,\n freeTaste: boolean,\n): 'posts' | 'products' | null {\n if (freeTaste) return null\n const kind = aiSiteKindOfInputs(inputs)?.id\n if (kind === 'blog') return 'posts'\n if (kind === 'store') return 'products'\n return null\n}\n\n/**\n * ASSUMED: what one post pass reads and writes beside its generation: the\n * host, the collection's slug claim and the entry's transaction.\n */\nexport const AI_SITE_POST_WRITES_MS = 1_500\n\n/** One post's pass: its generation and re-ask at the `copy.blog` ceiling, and its writes. */\nexport const AI_SITE_POST_BUDGET = aiJobStepBudget({\n tier: AI_STEP_TIERS[AI_BLOG_POST_STEP],\n maxTokens: AI_BLOG_POST_MAX_TOKENS,\n lookups: 0,\n ownReadsMs: AI_SITE_POST_WRITES_MS,\n})\n\n/** What a posts unit's job is told: the posts already written and the addresses the blog must not take. */\nexport interface AiSitePostsInput {\n written: Array<{ id: string; title: string }>\n total: number\n /** Addresses the site's own pages answer at, which the blog must not shadow. */\n avoidSlugs: string[]\n /** Who the posts are by: the business's name as given, else empty. */\n byline: string\n}\n\n/** What a products unit's job is told. */\nexport interface AiSiteProductsInput {\n min: number\n max: number\n}\n\nconst str = (value: unknown): string => (typeof value === 'string' ? value.trim() : '')\n\nfunction postsInputOf(job: Pick<AiJob, 'inputs'>): AiSitePostsInput {\n const raw = (job.inputs?.[AI_SITE_CONTENT_INPUT] ?? {}) as Partial<AiSitePostsInput>\n return {\n written: Array.isArray(raw.written) ? raw.written.filter((one) => one && typeof one.id === 'string') : [],\n total: typeof raw.total === 'number' && raw.total > 0 ? Math.floor(raw.total) : AI_SITE_POSTS,\n avoidSlugs: Array.isArray(raw.avoidSlugs) ? raw.avoidSlugs.map(str).filter(Boolean) : [],\n byline: str(raw.byline),\n }\n}\n\n/** The id of the `index`th post, of the blog its unit writes under `unitJobId`. */\nexport function aiSitePostId(unitJobId: string, index: number): string {\n return `${unitJobId}-${index}`\n}\n\n/** The id of the `index`th product a products unit writes. */\nexport function aiSiteProductId(unitJobId: string, index: number): string {\n return `${unitJobId}-${index}`\n}\n\n/** A site's subdomain and name, as its outputs and its posts' byline read them. */\nasync function readSite(\n firestore: FirebaseFirestore.Firestore,\n hostId: string,\n): Promise<{ subdomain: string | null; name: string } | null> {\n const host = await firestore.collection('hosts').doc(hostId).get()\n if (!host.exists) return null\n const seo = (host.get('seo') ?? {}) as Record<string, unknown>\n const subdomain = str(host.get('subdomain')) || null\n return { subdomain, name: str(host.get('displayName')) || str(seo['title']) }\n}\n\nconst limitReview = (message: string) => ({ reason: 'limit' as const, message, findings: [] })\n\nexport interface AiSitePostsRunnerDeps {\n generate?: typeof generateAiBlogPost\n writeCollection?: typeof writeContentCollection\n writeEntry?: typeof writeContentEntryDraft\n /** Where each post's cover comes from; the stock library, else the starters, otherwise. */\n cover?: typeof aiSitePostCover\n}\n\n/** A post's cover's shape: the blog's cards' (`COLLECTION_LIST_COVER_RATIO`, the posts listing's). */\nconst AI_SITE_POST_COVER_ASPECT = 3 / 2\n\n/**\n * A post's cover (AGL-3676): a stock photo of the post's own title, copied\n * into the site's library, where the deployment has a stock library; else the\n * starter photo a post was always given, turned by the job so blogs differ.\n * The blog's cards and the post's page show it, for the owner to replace.\n * Never throws: a post whose search fails takes its starter.\n */\nexport async function aiSitePostCover(input: {\n job: Pick<AiJob, '$id' | 'hostId' | 'createdBy' | 'inputs' | 'brief' | 'plan'>\n title: string\n index: number\n total: number\n signal?: AbortSignal\n stockPhotos?: typeof aiLayoutStockPhotoSource\n}): Promise<string | null> {\n const { job, index } = input\n if (job.hostId && input.title.trim()) {\n try {\n const source = (input.stockPhotos ?? aiLayoutStockPhotoSource)({\n hostId: job.hostId,\n uid: job.createdBy,\n seed: `${job.$id}:posts:${index}`,\n business: aiSiteWords(job.inputs).about || job.brief,\n ...aiStockPhotoWordsOf(job),\n sectionNames: ['Blog'],\n jobId: aiOriginJobId(job),\n ...(input.signal ? { signal: input.signal } : {}),\n })\n const [found] = source\n ? await source([\n {\n imageId: `cover${index}`,\n frameId: null,\n iconId: null,\n alt: input.title,\n aspect: AI_SITE_POST_COVER_ASPECT,\n sectionIndex: 0,\n role: 'gallery' as const,\n },\n ])\n : []\n if (found?.src) return found.src\n } catch (error) {\n console.warn('ai site posts: the stock photo failed; the starter covers it', { error: String(error) })\n }\n }\n const starters = aiLayoutStarterPhotos(\n Array.from({ length: Math.max(input.total, index + 1) }, (_, slot) => ({\n imageId: `cover${slot}`,\n frameId: null,\n iconId: null,\n alt: '',\n aspect: 16 / 9,\n sectionIndex: slot + 1,\n role: 'gallery' as const,\n })),\n job.$id,\n )\n return starters[index]?.src ?? null\n}\n\n/**\n * The posts unit's runner, on the job the scaffold derived for it: one post a\n * pass, continuing while posts remain. Its first pass makes the blog; every\n * pass finds it again under the unit's own id, and a post under its own id,\n * so a pass repeated after its write reports the post it already wrote.\n */\nexport function createAiSitePostsRunner(deps: AiSitePostsRunnerDeps = {}): AiJobStepRunner {\n const generate = deps.generate ?? generateAiBlogPost\n const writeCollection = deps.writeCollection ?? writeContentCollection\n const writeEntry = deps.writeEntry ?? writeContentEntryDraft\n const coverFor = deps.cover ?? aiSitePostCover\n return async (context): Promise<AiJobStepOutcome> => {\n const { job, firestore, signal } = context\n const model = context.modelFor?.(AI_BLOG_POST_STEP) ?? aiModelForStep(AI_BLOG_POST_STEP)\n if (!job.hostId) return { ...aiUnspentOutcome(model), failure: 'Open the site before writing its posts.' }\n const input = postsInputOf(job)\n const index = input.written.length\n if (index >= input.total) return aiUnspentOutcome(model)\n const site = await readSite(firestore, job.hostId)\n if (!site) return { ...aiUnspentOutcome(model), failure: 'This site no longer exists.' }\n const avoid = new Set(input.avoidSlugs.map((slug) => slug.toLowerCase()))\n const blog = await writeCollection(firestore, {\n hostId: job.hostId,\n uid: job.createdBy,\n id: job.$id,\n displayName: AI_SITE_BLOG_NAME,\n slugs: AI_SITE_BLOG_SLUGS.filter((slug) => !avoid.has(slug)),\n now: context.now,\n })\n if (blog.ok === false) return aiUnspentOutcome(model, { review: limitReview(blog.error) })\n\n const generation = await generate({\n brief: job.brief,\n merchantWords: job.brief,\n earlierTitles: input.written.map((post) => post.title),\n index: index + 1,\n total: input.total,\n model,\n maxTokens: AI_SITE_POST_BUDGET.maxTokens(model),\n ...(signal ? { signal } : {}),\n })\n const spent = aiGenerationSpent(generation)\n if (generation.status === 'refused') return { ...spent, refused: true }\n if (generation.status === 'needs_input') return { ...spent, failure: generation.message }\n const post = generation.value\n // A stock photo of its title as its cover, else a starter (AGL-3676).\n const cover = await coverFor({\n job,\n title: post.title,\n index,\n total: input.total,\n ...(signal ? { signal } : {}),\n }).catch(() => null)\n const byline = input.byline || site.name\n const written = await writeEntry(firestore, {\n hostId: job.hostId,\n collectionId: blog.id,\n uid: job.createdBy,\n id: aiSitePostId(job.$id, index),\n content: {\n title: post.title,\n excerpt: post.excerpt,\n body: post.body,\n seoDescription: post.seoDescription,\n ...(cover ? { coverImage: cover, coverImageAlt: post.title } : {}),\n ...(byline ? { authorName: byline } : {}),\n },\n now: context.now,\n })\n if (written.ok === false) return { ...spent, review: limitReview(written.error) }\n const output: AiJobOutput = {\n resource: 'entry',\n id: written.id,\n hostId: job.hostId,\n hostSubdomain: site.subdomain,\n label: written.title,\n note: `A post in ${blog.displayName}, at /${blog.slug}/${written.slug}. It goes live with the site.`,\n proposal: { collectionId: blog.id, collectionSlug: blog.slug, slug: written.slug },\n }\n return { ...spent, outputs: [output], ...(index + 1 < input.total ? { continue: true } : {}) }\n }\n}\n\nexport const runAiSitePostsUnit = createAiSitePostsRunner()\n\nexport interface AiSiteProductsRunnerDeps {\n /** The catalog's runner: the `products` step's. */\n catalog: AiJobStepRunner\n writerFor?: typeof pluginResourceDraftWriter\n /** Where each product's photo comes from; the stock library, else the starters, otherwise. */\n photos?: typeof aiSiteProductPhotos\n}\n\n/**\n * A photo for each product (AGL-3676), in order: a stock photo of the\n * product's own words, copied into the site's library, where the deployment\n * has a stock library; else a starter photo, as a page's empty picture takes\n * one. It fills the photo slot every product card and product page has, for\n * the owner to replace with their own; the product's note says so. Never\n * throws: a product with no photo is still written.\n */\nexport async function aiSiteProductPhotos(input: {\n job: Pick<AiJob, '$id' | 'hostId' | 'createdBy' | 'inputs' | 'brief' | 'plan'>\n names: readonly string[]\n /** What each product's photo should show, as its catalog proposed it, by position (AGL-3676). */\n shows?: readonly string[]\n signal?: AbortSignal\n stockPhotos?: typeof aiLayoutStockPhotoSource\n}): Promise<Array<string | null>> {\n if (!input.names.length || !input.job.hostId) return input.names.map(() => null)\n const slots: AiLayoutPictureSlot[] = input.names.map((name, index) => ({\n imageId: `product${index}`,\n frameId: null,\n iconId: null,\n alt: name,\n // The product card's own shape (`cardStyle: 'photo'`).\n aspect: 4 / 5,\n sectionIndex: 0,\n role: 'gallery' as const,\n // Searched for by its own name, then what its photo shows, with the shop's\n // category, and held to that category (AGL-3676).\n product: { subjects: [name, input.shows?.[index] ?? ''].filter((words) => words.trim()) },\n }))\n const seed = `${input.job.$id}:products`\n let found: ReadonlyArray<AiLayoutPicturePhoto | null> = []\n try {\n const source = (input.stockPhotos ?? aiLayoutStockPhotoSource)({\n hostId: input.job.hostId,\n uid: input.job.createdBy,\n seed,\n business: aiSiteWords(input.job.inputs).about || input.job.brief,\n ...aiStockPhotoWordsOf(input.job),\n sectionNames: ['Products'],\n jobId: aiOriginJobId(input.job),\n // Each product may try its name, its photo's subject, its category, a\n // gift's wrapper and the craft's broad searches (AGL-3660).\n searches: slots.length * 6,\n ...(input.signal ? { signal: input.signal } : {}),\n })\n if (source) found = await source(slots)\n } catch (error) {\n console.warn('ai site products: the stock photos failed; starter photos fill them', { error: String(error) })\n }\n const starters = aiLayoutStarterPhotos(slots, seed)\n const hostId = input.job.hostId\n // Every product has a photo (AGL-3676): a starter where no stock photo\n // named its category, never an empty tile.\n return slots.map(\n (_slot, index) =>\n aiSiteProductPhotoSrc(found[index]?.src, hostId) ?? aiSiteProductPhotoSrc(starters[index]?.src, hostId),\n )\n}\n\n/**\n * A photo as a product stores it: the form the console's picker writes when\n * an owner picks one from the library (`console-media-picker-provider`), the\n * asset's CDN path `/api/media/cdn/{scope}/{mediaId}`, or a starter's own\n * site path. A page's picture slot holds the library's `media:` reference\n * (`mediaNodeSrc`), which is what the stock source hands back, and the\n * product's rules take only an https address or a path on the site: the\n * candle store's guided start of 2026-10-09 (job FYNasg1h0S) wrote no\n * product at all because every photo was a `media:` reference. The path\n * names the asset, not its bytes, so a replace in the library still reaches\n * the product. Anything else is no photo, never a value the product refuses.\n */\nexport function aiSiteProductPhotoSrc(src: string | null | undefined, hostId: string): string | null {\n if (!src) return null\n const path = resolveMediaSrc(src, { hostId })\n if (!path || path.length > 2_000 || /[\\s\"'<>]/.test(path)) return null\n return path.startsWith('/') || path.startsWith('https://') ? path : null\n}\n\n/**\n * A proposed product's real choices (AGL-3676): each option with two or more\n * distinct values. An option of one value is no choice for a shopper to make\n * — the beta.237 Willow Wick gift set's \"Scent\" select offered nothing — so\n * it is left out, and its one value stays in the product's own words.\n */\nexport function aiSiteProductChoices(\n options: ReadonlyArray<{ name: string; values: readonly string[] }> | null | undefined,\n): Array<{ name: string; values: string[] }> {\n return (options ?? []).flatMap((option) => {\n const seen = new Set<string>()\n const values = option.values\n .map((value) => value.trim())\n .filter((value) => value && !seen.has(value.toLowerCase()) && !!seen.add(value.toLowerCase()))\n return option.name.trim() && values.length >= 2 ? [{ name: option.name.trim(), values }] : []\n })\n}\n\n/** The sentence the products unit's brief ends with, which the catalog's rules read as how many. */\nexport function aiSiteProductsBriefLine(input: AiSiteProductsInput = AI_SITE_PRODUCTS): string {\n return `Propose between ${input.min} and ${input.max} products: the store's first ones.`\n}\n\n/**\n * The products unit's runner: the `products` step's catalog for the store's\n * brief, then each proposed product, up to the most a site starts with,\n * written by the plugin that keeps products at its suggested price (else the\n * store's default), listed. A\n * product past the plan's allowance stops the writing there, and the row\n * says how many were added; none at all is the allowance's review. A photo\n * the product's rules refuse is dropped and the product written without it;\n * a product they refuse outright is skipped, and none written for that\n * reason is our failure, refunded, never the person's review (AGL-3676).\n */\nexport function createAiSiteProductsRunner(deps: AiSiteProductsRunnerDeps): AiJobStepRunner {\n const writerFor = deps.writerFor ?? pluginResourceDraftWriter\n return async (context): Promise<AiJobStepOutcome> => {\n const { job } = context\n const keeper = writerFor('product')\n const model = context.modelFor?.('job.products') ?? aiModelForStep('job.products')\n if (!keeper || !job.hostId) return { ...aiUnspentOutcome(model), failure: 'Products are not available on this site.' }\n const outcome = await deps.catalog({\n ...context,\n job: { ...job, kind: 'products', inputs: { ...job.inputs, target: 'catalog' } },\n })\n if (outcome.refused || outcome.failure || outcome.review) return outcome\n const catalog = outcome.outputs.map((output) => ({ output, proposal: aiProductsProposalOf(output) })).find(\n (entry) => entry.proposal?.kind === 'catalog',\n )\n if (!catalog || catalog.proposal?.kind !== 'catalog') return { ...outcome, outputs: [] }\n const proposed = catalog.proposal.products.slice(0, AI_SITE_PRODUCTS.max)\n const photos = await (deps.photos ?? aiSiteProductPhotos)({\n job,\n names: proposed.map((product) => product.name),\n shows: proposed.map((product) => product.photo ?? ''),\n ...(context.signal ? { signal: context.signal } : {}),\n }).catch(() => proposed.map(() => null))\n const outputs: AiJobOutput[] = []\n let stopped: string | null = null\n /** The product's rules refusing what we made: ours, never the workspace's (AGL-3676). */\n let rejected: string | null = null\n for (const [index, product] of proposed.entries()) {\n const content: Record<string, unknown> = {\n name: product.name,\n type: product.type,\n // Listed at once, so no \"[gift card terms]\" gap reaches a shopper:\n // a sentence that leaves a fact for the owner is left out.\n description: aiSiteProductDescriptionWithoutGaps(product.description),\n tags: product.tags,\n // A choice is two values or more (AGL-3676): a \"Scent\" of one value\n // drew a select with nothing to pick on the live Willow Wick page.\n options: aiSiteProductChoices(product.options),\n seoTitle: product.seoTitle,\n seoDescription: product.seoDescription,\n comingSoon: true,\n // The catalog's suggested price for what the product is (Zach,\n // 2026-10-12), held to range once more here: none, or one out of\n // range, is left unstated and the writer gives the store's default.\n ...aiSiteProductPriceContent(product.price),\n }\n // A photo we picked that the product's rules refuse is dropped, never\n // the product: its slot stays empty for the owner's own.\n const photo = photos[index] ?? null\n const withPhoto = photo ? { ...content, mediaUrls: [photo] } : content\n const photoRefused =\n photo !== null &&\n keeper.writer.check(withPhoto, { hostId: job.hostId }).ok === false &&\n keeper.writer.check(content, { hostId: job.hostId }).ok\n if (photoRefused) {\n console.warn('ai site products: the product refused its photo; written without it', {\n orgId: job.orgId,\n jobId: job.$id,\n photo,\n })\n }\n const written = await keeper.writer.write({\n orgId: job.orgId,\n hostId: job.hostId,\n uid: job.createdBy,\n org: (context.org ?? null) as Readonly<Record<string, unknown>> | null,\n now: context.now,\n id: aiSiteProductId(job.$id, index),\n name: product.name,\n // Its suggested price, else the store's default, for the owner to\n // change (AGL-3676). Listed at once. Its photo slot holds a stock or\n // starter photo for the owner to replace.\n content: photoRefused ? content : withPhoto,\n })\n if (written.ok === false) {\n // A 400 is the product's rules refusing content we made: that one\n // product is skipped and the rest are still written. Anything else\n // (the allowance, the role, the site) stops the writing there.\n if (written.status === 400) {\n console.error('ai site products: the product writer refused a product we made', {\n orgId: job.orgId,\n jobId: job.$id,\n index,\n error: written.error,\n })\n rejected = written.error\n continue\n }\n stopped = written.error\n break\n }\n outputs.push({\n resource: 'product',\n id: written.id,\n hostId: job.hostId,\n hostSubdomain: catalog.output.hostSubdomain ?? null,\n label: written.name,\n note: AI_SITE_PRODUCT_NOTE,\n })\n }\n if (!outputs.length) {\n // Nothing written because the product's rules refused what we made:\n // the failure is ours, so the item's credits are refunded\n // (`aiUnitFailure` → `ours: true`). Only the workspace's allowance,\n // role or site is the person's to review.\n if (!stopped && rejected) return { ...outcome, outputs: [], failure: AI_SITE_PRODUCTS_NOT_WRITTEN_COPY }\n return { ...outcome, outputs: [], review: limitReview(stopped ?? 'No product could be added.') }\n }\n // The allowance that stopped the rest is said where the last one added is.\n const last = outputs[outputs.length - 1]\n if (stopped) {\n last.note = `${last.note} ${outputs.length} of ${proposed.length} added: ${stopped}.`\n } else if (outputs.length < proposed.length) {\n last.note = `${last.note} ${outputs.length} of ${proposed.length} added.`\n }\n return { ...outcome, outputs }\n }\n}\n\n/**\n * Whether a part may be built for this member on this site, asked before its\n * first pass so a refusal spends nothing; `null` admits. Products ask what a\n * `products` job asks (the plan's commerce feature, Commerce on and released\n * for the site) and the writer's own refusal (role, allowance); posts ask\n * that the member may write the site's content.\n */\nexport async function aiSiteContentRefusal(\n part: 'posts' | 'products',\n context: Pick<AiJobStepContext, 'firestore' | 'org' | 'now'> & { job: Pick<AiJob, 'orgId' | 'hostId' | 'createdBy' | 'inputs'> },\n deps: { writerFor?: typeof pluginResourceDraftWriter; admissionFor?: typeof aiJobAdmissionFor } = {},\n): Promise<string | null> {\n const { job, firestore } = context\n if (!job.hostId) return 'Open the site first.'\n if (part === 'posts') {\n const host = await firestore.collection('hosts').doc(job.hostId).get()\n return hostRoleCanWrite((host.get('memberRoles') ?? {})[job.createdBy]) ? null : 'Editing requires the editor role'\n }\n const admission = (deps.admissionFor ?? aiJobAdmissionFor)('products')\n const refused: AiJobAdmissionRefusal | null = admission\n ? await admission({\n firestore,\n orgId: job.orgId,\n hostId: job.hostId,\n inputs: { target: 'catalog' },\n org: context.org ?? null,\n uid: job.createdBy,\n })\n : { status: 403, error: 'Products are not available on this site.' }\n if (refused) return refused.error\n const keeper = (deps.writerFor ?? pluginResourceDraftWriter)('product')\n if (!keeper) return 'Products are not available on this site.'\n const room = await keeper.writer.refusal({\n orgId: job.orgId,\n hostId: job.hostId,\n uid: job.createdBy,\n org: (context.org ?? null) as Readonly<Record<string, unknown>> | null,\n now: context.now,\n })\n return room?.error ?? null\n}\n\n/** The guided start's posts, published with its pages (AGL-3676). */\nexport interface AiSitePostsPublish {\n published: number\n kept: number\n /** The blog's own addresses, for the publish's cache drop. */\n paths: string[]\n}\n\n/**\n * Publishes the posts a guided start wrote, as the entry editor's Publish\n * does, once its pages are live. Never throws: a post that stays a draft is\n * the owner's to publish from Content.\n */\nexport async function aiPublishSitePosts(\n firestore: FirebaseFirestore.Firestore,\n input: { job: Pick<AiJob, '$id' | 'orgId' | 'hostId' | 'createdBy'>; outputs: readonly AiJobOutput[]; now: Date },\n publish: typeof publishContentEntries = publishContentEntries,\n): Promise<AiSitePostsPublish | null> {\n const posts = input.outputs.filter((output) => output.resource === 'entry')\n const collectionId = str(posts[0]?.proposal?.['collectionId'])\n const collectionSlug = str(posts[0]?.proposal?.['collectionSlug'])\n if (!input.job.hostId || !posts.length || !collectionId) return null\n try {\n const result = await publish(firestore, {\n hostId: input.job.hostId,\n collectionId,\n uid: input.job.createdBy,\n ids: posts.map((post) => post.id),\n now: input.now,\n })\n if ('ok' in result) {\n console.warn('ai site posts not published', { jobId: input.job.$id, error: result.error })\n return { published: 0, kept: posts.length, paths: [] }\n }\n const slugs = posts\n .filter((post) => result.published.includes(post.id))\n .map((post) => str(post.proposal?.['slug']))\n .filter(Boolean)\n return {\n published: result.published.length,\n kept: result.kept.length,\n paths: collectionSlug ? [`/${collectionSlug}`, ...slugs.map((slug) => `/${collectionSlug}/${slug}`)] : [],\n }\n } catch (error) {\n console.error('ai site posts publish threw', { orgId: input.job.orgId, jobId: input.job.$id, error })\n return null\n }\n}\n\n/**\n * The site's listings a layout or a page unit is handed (AGL-3676,\n * `ai-layout-listings.ts`): the store's catalog once its products are written,\n * the blog once its posts are, each with the sections of the plan's pages\n * that list it. A layout is built before either, so it is told the store will\n * sell (`sells`, its ledger still owing the products part), which puts the\n * cart in its header.\n */\nexport function aiSiteListings(input: {\n outputs: readonly AiJobOutput[]\n screens: readonly AiLayoutListingScreen[]\n /** The ledger owes a store's first products: a layout built before them carries the cart. */\n sells?: boolean\n /**\n * The site is a store (`siteKind: 'store'`, AGL-3676): its Shop page and\n * its home list the catalog whatever its first products came to — the\n * live Hearth & Wick start's products step failed, and its Shop page was\n * six cards naming kinds of candle. An empty catalog says so in the grid.\n */\n store?: boolean\n /**\n * The site is a music site (`siteKind: 'music'`, AGL-3716): its Music page,\n * or its home, places an empty Music player for the artist's own tracks.\n * Nothing is sourced: the owner uploads the recordings.\n */\n music?: boolean\n}): AiLayoutListing[] {\n const listings: AiLayoutListing[] = []\n const products = input.outputs.filter((output) => output.resource === 'product' && !output.proposal)\n if (products.length || input.sells || input.store) {\n const contact = aiSiteContactPath(input.screens)\n listings.push({\n id: aiLayoutListingId('products'),\n kind: 'products',\n name: 'the shop',\n records: products.map((product) => product.label),\n ...(contact ? { emptyAction: { label: 'Get in touch', href: contact } } : {}),\n // A store whose first products were skipped or failed lists its\n // (empty) catalog, but its header carries no cart until it sells.\n ...(products.length || input.sells ? {} : { cart: false }),\n placements: aiLayoutListingPlacements('products', input.screens),\n })\n // A store that sells shows its customers' reviews and takes newsletter\n // sign-ups where its pages name them (AGL-3676): both commerce elements,\n // so only where the store's commerce runs, never on a store that cannot\n // sell yet.\n if (products.length || input.sells) {\n for (const kind of ['reviews', 'signup'] as const) {\n const placements = aiLayoutListingPlacements(kind, input.screens)\n if (placements.length) listings.push({ id: aiLayoutListingId(kind), kind, name: kind === 'reviews' ? 'the store' : 'the newsletter', records: [], placements })\n }\n }\n }\n const posts = input.outputs.filter((output) => output.resource === 'entry')\n const slug = str(posts[0]?.proposal?.['collectionSlug'])\n if (posts.length && slug) {\n listings.push({\n id: aiLayoutListingId('posts'),\n kind: 'posts',\n name: 'the blog',\n records: posts.map((post) => post.label),\n href: `/${slug}`,\n collectionSlug: slug,\n placements: aiLayoutListingPlacements('posts', input.screens),\n })\n }\n if (input.music) {\n const placements = aiLayoutListingPlacements('tracks', input.screens)\n if (placements.length) {\n listings.push({ id: aiLayoutListingId('tracks'), kind: 'tracks', name: 'the music', records: [], placements })\n }\n }\n return listings\n}\n\n/** The page a visitor gets in touch on, by its path: one whose address or name says contact, else the one placing a form. */\nfunction aiSiteContactPath(screens: readonly AiLayoutListingScreen[]): string | null {\n const path = (slug: string) => `/${slug.trim().replace(/^\\/+|\\/+$/g, '')}`\n const isPath = (slug: string) => /^\\/[a-z0-9-]+(?:\\/[a-z0-9-]+)*$/.test(path(slug))\n const named = screens.find((screen) => isPath(screen.slug) && /\\b(contact|get in touch|enquir|inquir)/i.test(`${screen.slug} ${screen.title}`))\n if (named) return path(named.slug)\n const form = screens.find((screen) => isPath(screen.slug) && screen.sections.some((section) => (section.uses ?? []).some((use) => /form/i.test(use))))\n return form ? path(form.slug) : null\n}\n\n/**\n * A proposed product's description with each sentence that leaves a gap for\n * the owner (\"Delivery details: [how and when the card is sent].\") taken\n * out (AGL-3676): a start's products are listed as soon as they are written,\n * and a live run's gift card showed its gaps on the product page. A line\n * break is kept; nothing else is changed.\n */\nexport function aiSiteProductDescriptionWithoutGaps(description: string): string {\n return description\n .split('\\n')\n .map((line) =>\n line\n .split(/(?<=[.!?])\\s+/)\n .filter((sentence) => !/\\[[^\\]]+\\]/.test(sentence))\n .join(' '),\n )\n .join('\\n')\n .replace(/\\n{3,}/g, '\\n\\n')\n .trim()\n}\n\n/** What each product a start wrote says on the job's page (AGL-3676). */\nexport const AI_SITE_PRODUCT_NOTE =\n 'On your store at a suggested price. Change its price — and add your own photo — in Products.'\n\n/** The note a store's products row carries once they are written (AGL-3676): the step left before it sells. */\nexport const AI_SITE_PRODUCTS_PRICE_NOTE =\n 'Your products are on your store at suggested prices. Review and change them in Products.'\n\n/**\n * The price a start writes a product with (Zach, 2026-10-12): the catalog's\n * suggestion as `aiCatalogPrice` keeps it, stated as the writer reads one\n * (`priceUsd`); nothing when there is none in range, so the writer gives the\n * store's default price. Never `priceUsd: null`, which would leave the\n * product unpriced on purpose.\n */\nexport function aiSiteProductPriceContent(price: unknown): { priceUsd?: number } {\n const kept = aiCatalogPrice(price)\n return kept === null ? {} : { priceUsd: kept }\n}\n\n/** What a page of a blog or a store is told about the posts or products built before it. */\nexport function aiSiteContentBriefLines(outputs: readonly AiJobOutput[]): string[] {\n const posts = outputs.filter((output) => output.resource === 'entry')\n const products = outputs.filter((output) => output.resource === 'product' && !output.proposal)\n const lines: string[] = []\n if (posts.length) {\n const slug = str(posts[0].proposal?.['collectionSlug'])\n lines.push(\n `This site's blog${slug ? ` at /${slug}` : ''} has these posts: ${posts.map((post) => `“${post.label}”`).join(', ')}.`,\n 'Where a page features writing, feature these posts by their titles; never name a post that is not in this list.',\n )\n }\n if (products.length) {\n lines.push(\n `This store's products are: ${products.map((product) => `“${product.label}”`).join(', ')}.`,\n 'Where a page features products, feature these by their names; never name another product, and never state a price.',\n // The collection tiles a storefront home shows (AGL-3676): its own range, grouped.\n 'Where a page shows the shop by collection, group these products into two to four collections by what they are (a kind, a use or an occasion), one item each, named for the group and never for one product.',\n )\n }\n return lines\n}\n"],"names":["resolveMediaSrc","hostRoleCanWrite","pluginResourceDraftWriter","publishContentEntries","writeContentCollection","writeContentEntryDraft","aiCatalogPrice","aiProductsProposalOf","aiSiteKindOfInputs","AI_SITE_BLOG_NAME","AI_SITE_BLOG_SLUGS","aiSiteWords","AI_STEP_TIERS","aiModelForStep","AI_BLOG_POST_MAX_TOKENS","AI_BLOG_POST_STEP","generateAiBlogPost","aiLayoutStarterPhotos","aiOriginJobId","aiLayoutStockPhotoSource","aiStockPhotoWordsOf","aiLayoutListingId","aiLayoutListingPlacements","aiJobAdmissionFor","aiJobStepBudget","aiGenerationSpent","aiUnspentOutcome","AI_SITE_POSTS","AI_SITE_PRODUCTS","min","max","AI_SITE_PRODUCTS_NOT_WRITTEN_COPY","AI_SITE_POSTS_LABEL","AI_SITE_PRODUCTS_LABEL","AI_SITE_CONTENT_INPUT","aiSiteContentPart","inputs","freeTaste","kind","id","AI_SITE_POST_WRITES_MS","AI_SITE_POST_BUDGET","tier","maxTokens","lookups","ownReadsMs","str","value","trim","postsInputOf","job","raw","written","Array","isArray","filter","one","total","Math","floor","avoidSlugs","map","Boolean","byline","aiSitePostId","unitJobId","index","aiSiteProductId","readSite","firestore","hostId","host","collection","doc","get","exists","seo","subdomain","name","limitReview","message","reason","findings","AI_SITE_POST_COVER_ASPECT","aiSitePostCover","input","starters","title","source","stockPhotos","uid","createdBy","seed","$id","business","about","brief","sectionNames","jobId","signal","found","imageId","frameId","iconId","alt","aspect","sectionIndex","role","src","error","console","warn","String","from","length","_","slot","createAiSitePostsRunner","deps","generate","writeCollection","writeEntry","coverFor","cover","context","model","modelFor","failure","site","avoid","Set","slug","toLowerCase","blog","displayName","slugs","has","now","ok","review","generation","merchantWords","earlierTitles","post","spent","status","refused","catch","collectionId","content","excerpt","body","seoDescription","coverImage","coverImageAlt","authorName","output","resource","hostSubdomain","label","note","proposal","collectionSlug","outputs","continue","runAiSitePostsUnit","aiSiteProductPhotos","names","slots","product","subjects","shows","words","searches","_slot","aiSiteProductPhotoSrc","path","test","startsWith","aiSiteProductChoices","options","flatMap","option","seen","values","add","aiSiteProductsBriefLine","createAiSiteProductsRunner","writerFor","catalog","keeper","outcome","target","find","entry","proposed","products","slice","photos","photo","stopped","rejected","entries","type","description","aiSiteProductDescriptionWithoutGaps","tags","seoTitle","comingSoon","aiSiteProductPriceContent","price","withPhoto","mediaUrls","photoRefused","writer","check","orgId","write","org","push","AI_SITE_PRODUCT_NOTE","last","aiSiteContentRefusal","part","admission","admissionFor","room","refusal","aiPublishSitePosts","publish","posts","result","ids","published","kept","paths","includes","aiSiteListings","listings","sells","store","contact","aiSiteContactPath","screens","records","emptyAction","href","cart","placements","music","replace","isPath","named","screen","form","sections","some","section","uses","use","split","line","sentence","join","AI_SITE_PRODUCTS_PRICE_NOTE","priceUsd","aiSiteContentBriefLines","lines"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,eAAe,QAAQ,mCAAkC;AAClE,SAASC,gBAAgB,QAAQ,uCAAsC;AACvE,SAASC,yBAAyB,QAAQ,qDAAoD;AAC9F,SACEC,qBAAqB,EACrBC,sBAAsB,EACtBC,sBAAsB,QACjB,uDAAsD;AAC7D,SAASC,cAAc,EAAEC,oBAAoB,QAAQ,0BAAsB;AAE3E,SAASC,kBAAkB,QAAQ,4BAAwB;AAC3D,SAASC,iBAAiB,EAAEC,kBAAkB,EAAEC,WAAW,QAAQ,0BAAsB;AACzF,SAASC,aAAa,QAAQ,0BAAsB;AACpD,SAASC,cAAc,QAAQ,0BAAsB;AACrD,SACEC,uBAAuB,EACvBC,iBAAiB,EACjBC,kBAAkB,QACb,wCAAoC;AAC3C,SACEC,qBAAqB,QAGhB,2CAAuC;AAC9C,SAASC,aAAa,QAAQ,wBAAoB;AAClD,SAASC,wBAAwB,EAAEC,mBAAmB,QAAQ,8BAA0B;AACxF,SACEC,iBAAiB,EACjBC,yBAAyB,QAGpB,2CAAuC;AAC9C,SAASC,iBAAiB,QAAoC,wBAAoB;AAClF,SAASC,eAAe,QAAQ,qBAAiB;AACjD,SAASC,iBAAiB,EAAEC,gBAAgB,QAAQ,yBAAqB;AAGzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDC,GAED,2CAA2C,GAC3C,OAAO,MAAMC,gBAAgB,EAAC;AAE9B,gFAAgF,GAChF,OAAO,MAAMC,mBAAmB;IAAEC,KAAK;IAAGC,KAAK;AAAE,EAAU;AAE3D,gGAAgG,GAChG,OAAO,MAAMC,oCAAoC,oDAAmD;AAEpG,gCAAgC,GAChC,OAAO,MAAMC,sBAAsB,2BAA0B;AAC7D,OA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AAMhD,IAAI,CACR,CAAC,2BAA2B,EAAEvB,SAASvI,GAAG,CAAC,CAAC4G,UAAY,CAAC,CAAC,EAAEA,QAAQV,KAAK,CAAC,CAAC,CAAC,EAAEwG,IAAI,CAAC,MAAM,CAAC,CAAC,EAC3F,sHACA,mFAAmF;QACnF;IAEJ;IACA,OAAOI;AACT"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-job-site-content.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { resolveMediaSrc } from '@aglyn/aglyn/app-utils/media-ref'\nimport { hostRoleCanWrite } from '@aglyn/aglyn/app-utils/organizations'\nimport { resolveEffectivePlan } from '@aglyn/aglyn/app-utils/plan-entitlements'\nimport { pluginResourceDraftWriter } from '@aglyn/aglyn/plugin-manager/plugin-resource-drafts'\nimport {\n publishContentEntries,\n writeContentCollection,\n writeContentEntryDraft,\n} from '@aglyn/tenant-data-admin/server/content-entry-drafts'\nimport { aiCatalogPrice, aiProductsProposalOf } from '../model/ai-products'\nimport type { AiJob, AiJobOutput } from '../model/ai-jobs.types'\nimport { aiSiteKindOfInputs } from '../model/ai-site-kinds'\nimport { AI_SITE_BLOG_NAME, AI_SITE_BLOG_SLUGS, aiSiteWords } from '../model/ai-site-job'\nimport { AI_STEP_TIERS, aiCatalogEntry, aiDefaultModelFor } from '../providers/catalog'\nimport { aiModelForStep } from '../providers/routing'\nimport {\n AI_BLOG_POST_MAX_TOKENS,\n AI_BLOG_POST_STEP,\n generateAiBlogPost,\n} from '../runtime/ai-blog-post-generation'\nimport {\n aiLayoutStarterPhotos,\n type AiLayoutPicturePhoto,\n type AiLayoutPictureSlot,\n} from '../layout-language/ai-layout-pictures'\nimport { aiOriginJobId } from './ai-job-draft-ids'\nimport { aiLayoutStockPhotoSource, aiStockPhotoWordsOf } from './ai-layout-stock-photos'\nimport {\n aiLayoutListingId,\n aiLayoutListingPlacements,\n type AiLayoutListing,\n type AiLayoutListingScreen,\n} from '../layout-language/ai-layout-listings'\nimport { aiJobAdmissionFor, type AiJobAdmissionRefusal } from './ai-job-admission'\nimport { aiJobStepBudget } from './ai-job-budget'\nimport { aiGenerationSpent, aiUnspentOutcome } from './ai-job-generation'\nimport type { AiJobStepContext, AiJobStepOutcome, AiJobStepRunner } from './ai-job-text-step'\n\n/**\n * A GUIDED START'S FIRST POSTS AND FIRST PRODUCTS (AGL-3676).\n *\n * A site of the kind \"Blog & writing\" or \"Online store\" got the right look\n * and pages, and nothing real in them: the writing page's cards and the\n * shop's grid named posts and products nobody had written. The scaffold now\n * builds one more part for those two kinds, before the pages, each its own\n * row with its own timer and credits — a store's on a paid plan only:\n *\n * - WRITING YOUR FIRST POSTS: a content collection \"Blog\" — the platform's\n * own blog, served at `/{slug}` with an entry page per post — and\n * `AI_SITE_POSTS` posts in it on a paid plan, `AI_SITE_FREE_POSTS` on the\n * Free taste, one generation a pass. Each is written as a\n * draft through the same rules the console's routes hold\n * (`content-entry-drafts.ts`), bylined with the business's name the person\n * gave, and given a cover: a stock photo of its own title where the\n * deployment has a library, else a starter (AGL-3676), which the blog's\n * cards show. They go live with the\n * site: the guided start's publish publishes them with its pages\n * (`aiPublishSitePosts`), as a person's Publish would.\n * - ADDING YOUR FIRST PRODUCTS: the `products` step's catalog, asked for\n * `AI_SITE_PRODUCTS` products, each written through the commerce plugin's\n * `product` draft writer, at the price the catalog suggests for what it\n * is (Zach, 2026-10-12: a bar of soap is not priced like a gift set),\n * which code keeps in range (`aiCatalogPrice`); a product with no price\n * in range takes the writer's default price (his 2026-10-08 \"default a\n * price\", AGL-3676). Every price is the owner's to change, and the job's\n * row says so. Since the\n * 2026-10-08 Ember & Wick start, whose store showed no product at all,\n * each is LISTED at once (`comingSoon`: written `active`). Each gets a\n * photo in its slot, a stock photo of its own words where the deployment\n * has a library, else a starter, for the owner to replace with their\n * own.\n *\n * The pages built after them are told their titles or names, and the\n * sections that show them list the real records (`aiSiteListings`,\n * `ai-layout-listings.ts`): the shop's Product grid, the blog's posts.\n *\n * ── On the Free taste ────────────────────────────────────────────────────\n *\n * A guided start's Free blog writes ONE first post (Zach, 2026-10-14,\n * AGL-3798), and a Free store no products. Built on an empty site with its\n * layout and form, a Free site leaves 57 credits once its eight sections and\n * its retried page's room are held (`aiFreeSiteSectionsWithin`, AGL-3660).\n * One post at its worst is 4 on the fast tier since AGL-3781 (Claude Haiku\n * 5.5 at the platform's markup), so a Free blog's post is written there\n * (`aiSitePostModel`): on the balanced tier `copy.blog` routes to, the same\n * post is 68, past what the wall leaves. The wall counts it\n * (`AI_FREE_SITE_WORST_CASE_CREDITS.post`), and its eight sections still fit\n * beside it. A Free plan includes neither the `commerce` feature nor a\n * product (`productsPerHost` is 0), so a Free store keeps the pages its kind\n * describes and the owner adds products after.\n * `ai-job-free-site.spec.ts` shows the arithmetic.\n */\n\n/** How many first posts a paid blog gets. */\nexport const AI_SITE_POSTS = 3\n\n/** How many first posts a Free blog gets (`model/ai-site-job.ts`, which the Free wall reads). */\nexport { AI_SITE_FREE_POSTS } from '../model/ai-site-job'\n\n/** How many first products a paid store gets: asked for, and the most written. */\nexport const AI_SITE_PRODUCTS = { min: 3, max: 6 } as const\n\n/** What a products row says when none of what we made could be written: our failure, refunded. */\nexport const AI_SITE_PRODUCTS_NOT_WRITTEN_COPY = 'Your first products could not be added this time.'\n\n/** What each part's row reads; a Free blog's one post reads in the singular. */\nexport const AI_SITE_POSTS_LABEL = 'Writing your first posts'\nexport const AI_SITE_POST_LABEL = 'Writing your first post'\nexport const AI_SITE_PRODUCTS_LABEL = 'Adding your first products'\n\n/** The blog the posts go in, and the addresses it may answer at (`model/ai-site-job.ts`). */\nexport { AI_SITE_BLOG_NAME, AI_SITE_BLOG_SLUGS } from '../model/ai-site-job'\n\n/** The input a site unit's own job carries what the part needs in. */\nexport const AI_SITE_CONTENT_INPUT = 'siteContent'\n\n/** Which part a site of these answers gets: a blog's posts, a paid store's products, else `null`. */\nexport function aiSiteContentPart(\n inputs: Readonly<Record<string, unknown>> | null | undefined,\n freeTaste: boolean,\n): 'posts' | 'products' | null {\n const kind = aiSiteKindOfInputs(inputs)?.id\n if (kind === 'blog') return 'posts'\n if (kind === 'store' && !freeTaste) return 'products'\n return null\n}\n\n/**\n * The model a site's post is written on: the routed one, except that a Free\n * blog's post is written on its provider's fast tier, as a Free site's plan\n * and look are (`aiSitePlanModel`, `aiSiteLookModel`). On the balanced tier\n * `copy.blog` routes to, one post at its worst is past what the Free wall\n * leaves. A model the creator picked by name stays theirs.\n */\nexport function aiSitePostModel(job: Pick<AiJob, 'model'>, routed: string, freeTaste: boolean): string {\n if (!freeTaste) return routed\n const picked = typeof job.model === 'string' ? job.model.trim() : ''\n if (picked && picked !== 'auto') return routed\n const entry = aiCatalogEntry(routed)\n return (entry ? aiDefaultModelFor(entry.provider, 'fast') : undefined) ?? routed\n}\n\n/**\n * ASSUMED: what one post pass reads and writes beside its generation: the\n * host, the collection's slug claim and the entry's transaction.\n */\nexport const AI_SITE_POST_WRITES_MS = 1_500\n\n/** One post's pass: its generation and re-ask at the `copy.blog` ceiling, and its writes. */\nexport const AI_SITE_POST_BUDGET = aiJobStepBudget({\n tier: AI_STEP_TIERS[AI_BLOG_POST_STEP],\n maxTokens: AI_BLOG_POST_MAX_TOKENS,\n lookups: 0,\n ownReadsMs: AI_SITE_POST_WRITES_MS,\n})\n\n/** What a posts unit's job is told: the posts already written and the addresses the blog must not take. */\nexport interface AiSitePostsInput {\n written: Array<{ id: string; title: string }>\n total: number\n /** Addresses the site's own pages answer at, which the blog must not shadow. */\n avoidSlugs: string[]\n /** Who the posts are by: the business's name as given, else empty. */\n byline: string\n}\n\n/** What a products unit's job is told. */\nexport interface AiSiteProductsInput {\n min: number\n max: number\n}\n\nconst str = (value: unknown): string => (typeof value === 'string' ? value.trim() : '')\n\nfunction postsInputOf(job: Pick<AiJob, 'inputs'>): AiSitePostsInput {\n const raw = (job.inputs?.[AI_SITE_CONTENT_INPUT] ?? {}) as Partial<AiSitePostsInput>\n return {\n written: Array.isArray(raw.written) ? raw.written.filter((one) => one && typeof one.id === 'string') : [],\n total: typeof raw.total === 'number' && raw.total > 0 ? Math.floor(raw.total) : AI_SITE_POSTS,\n avoidSlugs: Array.isArray(raw.avoidSlugs) ? raw.avoidSlugs.map(str).filter(Boolean) : [],\n byline: str(raw.byline),\n }\n}\n\n/** The id of the `index`th post, of the blog its unit writes under `unitJobId`. */\nexport function aiSitePostId(unitJobId: string, index: number): string {\n return `${unitJobId}-${index}`\n}\n\n/** The id of the `index`th product a products unit writes. */\nexport function aiSiteProductId(unitJobId: string, index: number): string {\n return `${unitJobId}-${index}`\n}\n\n/** A site's subdomain and name, as its outputs and its posts' byline read them. */\nasync function readSite(\n firestore: FirebaseFirestore.Firestore,\n hostId: string,\n): Promise<{ subdomain: string | null; name: string } | null> {\n const host = await firestore.collection('hosts').doc(hostId).get()\n if (!host.exists) return null\n const seo = (host.get('seo') ?? {}) as Record<string, unknown>\n const subdomain = str(host.get('subdomain')) || null\n return { subdomain, name: str(host.get('displayName')) || str(seo['title']) }\n}\n\nconst limitReview = (message: string) => ({ reason: 'limit' as const, message, findings: [] })\n\nexport interface AiSitePostsRunnerDeps {\n generate?: typeof generateAiBlogPost\n writeCollection?: typeof writeContentCollection\n writeEntry?: typeof writeContentEntryDraft\n /** Where each post's cover comes from; the stock library, else the starters, otherwise. */\n cover?: typeof aiSitePostCover\n}\n\n/** A post's cover's shape: the blog's cards' (`COLLECTION_LIST_COVER_RATIO`, the posts listing's). */\nconst AI_SITE_POST_COVER_ASPECT = 3 / 2\n\n/**\n * A post's cover (AGL-3676): a stock photo of the post's own title, copied\n * into the site's library, where the deployment has a stock library; else the\n * starter photo a post was always given, turned by the job so blogs differ.\n * The blog's cards and the post's page show it, for the owner to replace.\n * Never throws: a post whose search fails takes its starter.\n */\nexport async function aiSitePostCover(input: {\n job: Pick<AiJob, '$id' | 'hostId' | 'createdBy' | 'inputs' | 'brief' | 'plan'>\n title: string\n index: number\n total: number\n signal?: AbortSignal\n stockPhotos?: typeof aiLayoutStockPhotoSource\n}): Promise<string | null> {\n const { job, index } = input\n if (job.hostId && input.title.trim()) {\n try {\n const source = (input.stockPhotos ?? aiLayoutStockPhotoSource)({\n hostId: job.hostId,\n uid: job.createdBy,\n seed: `${job.$id}:posts:${index}`,\n business: aiSiteWords(job.inputs).about || job.brief,\n ...aiStockPhotoWordsOf(job),\n sectionNames: ['Blog'],\n jobId: aiOriginJobId(job),\n ...(input.signal ? { signal: input.signal } : {}),\n })\n const [found] = source\n ? await source([\n {\n imageId: `cover${index}`,\n frameId: null,\n iconId: null,\n alt: input.title,\n aspect: AI_SITE_POST_COVER_ASPECT,\n sectionIndex: 0,\n role: 'gallery' as const,\n },\n ])\n : []\n if (found?.src) return found.src\n } catch (error) {\n console.warn('ai site posts: the stock photo failed; the starter covers it', { error: String(error) })\n }\n }\n const starters = aiLayoutStarterPhotos(\n Array.from({ length: Math.max(input.total, index + 1) }, (_, slot) => ({\n imageId: `cover${slot}`,\n frameId: null,\n iconId: null,\n alt: '',\n aspect: 16 / 9,\n sectionIndex: slot + 1,\n role: 'gallery' as const,\n })),\n job.$id,\n )\n return starters[index]?.src ?? null\n}\n\n/**\n * The posts unit's runner, on the job the scaffold derived for it: one post a\n * pass, continuing while posts remain. Its first pass makes the blog; every\n * pass finds it again under the unit's own id, and a post under its own id,\n * so a pass repeated after its write reports the post it already wrote.\n */\nexport function createAiSitePostsRunner(deps: AiSitePostsRunnerDeps = {}): AiJobStepRunner {\n const generate = deps.generate ?? generateAiBlogPost\n const writeCollection = deps.writeCollection ?? writeContentCollection\n const writeEntry = deps.writeEntry ?? writeContentEntryDraft\n const coverFor = deps.cover ?? aiSitePostCover\n return async (context): Promise<AiJobStepOutcome> => {\n const { job, firestore, signal } = context\n const freeTaste = Boolean(context.org) && resolveEffectivePlan(context.org as never) === 'free'\n const routed = context.modelFor?.(AI_BLOG_POST_STEP) ?? aiModelForStep(AI_BLOG_POST_STEP)\n const model = aiSitePostModel(job, routed, freeTaste)\n if (!job.hostId) return { ...aiUnspentOutcome(model), failure: 'Open the site before writing its posts.' }\n const input = postsInputOf(job)\n const index = input.written.length\n if (index >= input.total) return aiUnspentOutcome(model)\n const site = await readSite(firestore, job.hostId)\n if (!site) return { ...aiUnspentOutcome(model), failure: 'This site no longer exists.' }\n const avoid = new Set(input.avoidSlugs.map((slug) => slug.toLowerCase()))\n const blog = await writeCollection(firestore, {\n hostId: job.hostId,\n uid: job.createdBy,\n id: job.$id,\n displayName: AI_SITE_BLOG_NAME,\n slugs: AI_SITE_BLOG_SLUGS.filter((slug) => !avoid.has(slug)),\n now: context.now,\n })\n if (blog.ok === false) return aiUnspentOutcome(model, { review: limitReview(blog.error) })\n\n const generation = await generate({\n brief: job.brief,\n merchantWords: job.brief,\n earlierTitles: input.written.map((post) => post.title),\n index: index + 1,\n total: input.total,\n model,\n maxTokens: AI_SITE_POST_BUDGET.maxTokens(model),\n ...(signal ? { signal } : {}),\n })\n const spent = aiGenerationSpent(generation)\n if (generation.status === 'refused') return { ...spent, refused: true }\n if (generation.status === 'needs_input') return { ...spent, failure: generation.message }\n const post = generation.value\n // A stock photo of its title as its cover, else a starter (AGL-3676).\n const cover = await coverFor({\n job,\n title: post.title,\n index,\n total: input.total,\n ...(signal ? { signal } : {}),\n }).catch(() => null)\n const byline = input.byline || site.name\n const written = await writeEntry(firestore, {\n hostId: job.hostId,\n collectionId: blog.id,\n uid: job.createdBy,\n id: aiSitePostId(job.$id, index),\n content: {\n title: post.title,\n excerpt: post.excerpt,\n body: post.body,\n seoDescription: post.seoDescription,\n ...(cover ? { coverImage: cover, coverImageAlt: post.title } : {}),\n ...(byline ? { authorName: byline } : {}),\n },\n now: context.now,\n })\n if (written.ok === false) return { ...spent, review: limitReview(written.error) }\n const output: AiJobOutput = {\n resource: 'entry',\n id: written.id,\n hostId: job.hostId,\n hostSubdomain: site.subdomain,\n label: written.title,\n note: `A post in ${blog.displayName}, at /${blog.slug}/${written.slug}. It goes live with the site.`,\n proposal: { collectionId: blog.id, collectionSlug: blog.slug, slug: written.slug },\n }\n return { ...spent, outputs: [output], ...(index + 1 < input.total ? { continue: true } : {}) }\n }\n}\n\nexport const runAiSitePostsUnit = createAiSitePostsRunner()\n\nexport interface AiSiteProductsRunnerDeps {\n /** The catalog's runner: the `products` step's. */\n catalog: AiJobStepRunner\n writerFor?: typeof pluginResourceDraftWriter\n /** Where each product's photo comes from; the stock library, else the starters, otherwise. */\n photos?: typeof aiSiteProductPhotos\n}\n\n/**\n * A photo for each product (AGL-3676), in order: a stock photo of the\n * product's own words, copied into the site's library, where the deployment\n * has a stock library; else a starter photo, as a page's empty picture takes\n * one. It fills the photo slot every product card and product page has, for\n * the owner to replace with their own; the product's note says so. Never\n * throws: a product with no photo is still written.\n */\nexport async function aiSiteProductPhotos(input: {\n job: Pick<AiJob, '$id' | 'hostId' | 'createdBy' | 'inputs' | 'brief' | 'plan'>\n names: readonly string[]\n /** What each product's photo should show, as its catalog proposed it, by position (AGL-3676). */\n shows?: readonly string[]\n signal?: AbortSignal\n stockPhotos?: typeof aiLayoutStockPhotoSource\n}): Promise<Array<string | null>> {\n if (!input.names.length || !input.job.hostId) return input.names.map(() => null)\n const slots: AiLayoutPictureSlot[] = input.names.map((name, index) => ({\n imageId: `product${index}`,\n frameId: null,\n iconId: null,\n alt: name,\n // The product card's own shape (`cardStyle: 'photo'`).\n aspect: 4 / 5,\n sectionIndex: 0,\n role: 'gallery' as const,\n // Searched for by its own name, then what its photo shows, with the shop's\n // category, and held to that category (AGL-3676).\n product: { subjects: [name, input.shows?.[index] ?? ''].filter((words) => words.trim()) },\n }))\n const seed = `${input.job.$id}:products`\n let found: ReadonlyArray<AiLayoutPicturePhoto | null> = []\n try {\n const source = (input.stockPhotos ?? aiLayoutStockPhotoSource)({\n hostId: input.job.hostId,\n uid: input.job.createdBy,\n seed,\n business: aiSiteWords(input.job.inputs).about || input.job.brief,\n ...aiStockPhotoWordsOf(input.job),\n sectionNames: ['Products'],\n jobId: aiOriginJobId(input.job),\n // Each product may try its name, its photo's subject, its category, a\n // gift's wrapper and the craft's broad searches (AGL-3660).\n searches: slots.length * 6,\n ...(input.signal ? { signal: input.signal } : {}),\n })\n if (source) found = await source(slots)\n } catch (error) {\n console.warn('ai site products: the stock photos failed; starter photos fill them', { error: String(error) })\n }\n const starters = aiLayoutStarterPhotos(slots, seed)\n const hostId = input.job.hostId\n // Every product has a photo (AGL-3676): a starter where no stock photo\n // named its category, never an empty tile.\n return slots.map(\n (_slot, index) =>\n aiSiteProductPhotoSrc(found[index]?.src, hostId) ?? aiSiteProductPhotoSrc(starters[index]?.src, hostId),\n )\n}\n\n/**\n * A photo as a product stores it: the form the console's picker writes when\n * an owner picks one from the library (`console-media-picker-provider`), the\n * asset's CDN path `/api/media/cdn/{scope}/{mediaId}`, or a starter's own\n * site path. A page's picture slot holds the library's `media:` reference\n * (`mediaNodeSrc`), which is what the stock source hands back, and the\n * product's rules take only an https address or a path on the site: the\n * candle store's guided start of 2026-10-09 (job FYNasg1h0S) wrote no\n * product at all because every photo was a `media:` reference. The path\n * names the asset, not its bytes, so a replace in the library still reaches\n * the product. Anything else is no photo, never a value the product refuses.\n */\nexport function aiSiteProductPhotoSrc(src: string | null | undefined, hostId: string): string | null {\n if (!src) return null\n const path = resolveMediaSrc(src, { hostId })\n if (!path || path.length > 2_000 || /[\\s\"'<>]/.test(path)) return null\n return path.startsWith('/') || path.startsWith('https://') ? path : null\n}\n\n/**\n * A proposed product's real choices (AGL-3676): each option with two or more\n * distinct values. An option of one value is no choice for a shopper to make\n * — the beta.237 Willow Wick gift set's \"Scent\" select offered nothing — so\n * it is left out, and its one value stays in the product's own words.\n */\nexport function aiSiteProductChoices(\n options: ReadonlyArray<{ name: string; values: readonly string[] }> | null | undefined,\n): Array<{ name: string; values: string[] }> {\n return (options ?? []).flatMap((option) => {\n const seen = new Set<string>()\n const values = option.values\n .map((value) => value.trim())\n .filter((value) => value && !seen.has(value.toLowerCase()) && !!seen.add(value.toLowerCase()))\n return option.name.trim() && values.length >= 2 ? [{ name: option.name.trim(), values }] : []\n })\n}\n\n/** The sentence the products unit's brief ends with, which the catalog's rules read as how many. */\nexport function aiSiteProductsBriefLine(input: AiSiteProductsInput = AI_SITE_PRODUCTS): string {\n return `Propose between ${input.min} and ${input.max} products: the store's first ones.`\n}\n\n/**\n * The products unit's runner: the `products` step's catalog for the store's\n * brief, then each proposed product, up to the most a site starts with,\n * written by the plugin that keeps products at its suggested price (else the\n * store's default), listed. A\n * product past the plan's allowance stops the writing there, and the row\n * says how many were added; none at all is the allowance's review. A photo\n * the product's rules refuse is dropped and the product written without it;\n * a product they refuse outright is skipped, and none written for that\n * reason is our failure, refunded, never the person's review (AGL-3676).\n */\nexport function createAiSiteProductsRunner(deps: AiSiteProductsRunnerDeps): AiJobStepRunner {\n const writerFor = deps.writerFor ?? pluginResourceDraftWriter\n return async (context): Promise<AiJobStepOutcome> => {\n const { job } = context\n const keeper = writerFor('product')\n const model = context.modelFor?.('job.products') ?? aiModelForStep('job.products')\n if (!keeper || !job.hostId) return { ...aiUnspentOutcome(model), failure: 'Products are not available on this site.' }\n const outcome = await deps.catalog({\n ...context,\n job: { ...job, kind: 'products', inputs: { ...job.inputs, target: 'catalog' } },\n })\n if (outcome.refused || outcome.failure || outcome.review) return outcome\n const catalog = outcome.outputs.map((output) => ({ output, proposal: aiProductsProposalOf(output) })).find(\n (entry) => entry.proposal?.kind === 'catalog',\n )\n if (!catalog || catalog.proposal?.kind !== 'catalog') return { ...outcome, outputs: [] }\n const proposed = catalog.proposal.products.slice(0, AI_SITE_PRODUCTS.max)\n const photos = await (deps.photos ?? aiSiteProductPhotos)({\n job,\n names: proposed.map((product) => product.name),\n shows: proposed.map((product) => product.photo ?? ''),\n ...(context.signal ? { signal: context.signal } : {}),\n }).catch(() => proposed.map(() => null))\n const outputs: AiJobOutput[] = []\n let stopped: string | null = null\n /** The product's rules refusing what we made: ours, never the workspace's (AGL-3676). */\n let rejected: string | null = null\n for (const [index, product] of proposed.entries()) {\n const content: Record<string, unknown> = {\n name: product.name,\n type: product.type,\n // Listed at once, so no \"[gift card terms]\" gap reaches a shopper:\n // a sentence that leaves a fact for the owner is left out.\n description: aiSiteProductDescriptionWithoutGaps(product.description),\n tags: product.tags,\n // A choice is two values or more (AGL-3676): a \"Scent\" of one value\n // drew a select with nothing to pick on the live Willow Wick page.\n options: aiSiteProductChoices(product.options),\n seoTitle: product.seoTitle,\n seoDescription: product.seoDescription,\n comingSoon: true,\n // The catalog's suggested price for what the product is (Zach,\n // 2026-10-12), held to range once more here: none, or one out of\n // range, is left unstated and the writer gives the store's default.\n ...aiSiteProductPriceContent(product.price),\n }\n // A photo we picked that the product's rules refuse is dropped, never\n // the product: its slot stays empty for the owner's own.\n const photo = photos[index] ?? null\n const withPhoto = photo ? { ...content, mediaUrls: [photo] } : content\n const photoRefused =\n photo !== null &&\n keeper.writer.check(withPhoto, { hostId: job.hostId }).ok === false &&\n keeper.writer.check(content, { hostId: job.hostId }).ok\n if (photoRefused) {\n console.warn('ai site products: the product refused its photo; written without it', {\n orgId: job.orgId,\n jobId: job.$id,\n photo,\n })\n }\n const written = await keeper.writer.write({\n orgId: job.orgId,\n hostId: job.hostId,\n uid: job.createdBy,\n org: (context.org ?? null) as Readonly<Record<string, unknown>> | null,\n now: context.now,\n id: aiSiteProductId(job.$id, index),\n name: product.name,\n // Its suggested price, else the store's default, for the owner to\n // change (AGL-3676). Listed at once. Its photo slot holds a stock or\n // starter photo for the owner to replace.\n content: photoRefused ? content : withPhoto,\n })\n if (written.ok === false) {\n // A 400 is the product's rules refusing content we made: that one\n // product is skipped and the rest are still written. Anything else\n // (the allowance, the role, the site) stops the writing there.\n if (written.status === 400) {\n console.error('ai site products: the product writer refused a product we made', {\n orgId: job.orgId,\n jobId: job.$id,\n index,\n error: written.error,\n })\n rejected = written.error\n continue\n }\n stopped = written.error\n break\n }\n outputs.push({\n resource: 'product',\n id: written.id,\n hostId: job.hostId,\n hostSubdomain: catalog.output.hostSubdomain ?? null,\n label: written.name,\n note: AI_SITE_PRODUCT_NOTE,\n })\n }\n if (!outputs.length) {\n // Nothing written because the product's rules refused what we made:\n // the failure is ours, so the item's credits are refunded\n // (`aiUnitFailure` → `ours: true`). Only the workspace's allowance,\n // role or site is the person's to review.\n if (!stopped && rejected) return { ...outcome, outputs: [], failure: AI_SITE_PRODUCTS_NOT_WRITTEN_COPY }\n return { ...outcome, outputs: [], review: limitReview(stopped ?? 'No product could be added.') }\n }\n // The allowance that stopped the rest is said where the last one added is.\n const last = outputs[outputs.length - 1]\n if (stopped) {\n last.note = `${last.note} ${outputs.length} of ${proposed.length} added: ${stopped}.`\n } else if (outputs.length < proposed.length) {\n last.note = `${last.note} ${outputs.length} of ${proposed.length} added.`\n }\n return { ...outcome, outputs }\n }\n}\n\n/**\n * Whether a part may be built for this member on this site, asked before its\n * first pass so a refusal spends nothing; `null` admits. Products ask what a\n * `products` job asks (the plan's commerce feature, Commerce on and released\n * for the site) and the writer's own refusal (role, allowance); posts ask\n * that the member may write the site's content.\n */\nexport async function aiSiteContentRefusal(\n part: 'posts' | 'products',\n context: Pick<AiJobStepContext, 'firestore' | 'org' | 'now'> & { job: Pick<AiJob, 'orgId' | 'hostId' | 'createdBy' | 'inputs'> },\n deps: { writerFor?: typeof pluginResourceDraftWriter; admissionFor?: typeof aiJobAdmissionFor } = {},\n): Promise<string | null> {\n const { job, firestore } = context\n if (!job.hostId) return 'Open the site first.'\n if (part === 'posts') {\n const host = await firestore.collection('hosts').doc(job.hostId).get()\n return hostRoleCanWrite((host.get('memberRoles') ?? {})[job.createdBy]) ? null : 'Editing requires the editor role'\n }\n const admission = (deps.admissionFor ?? aiJobAdmissionFor)('products')\n const refused: AiJobAdmissionRefusal | null = admission\n ? await admission({\n firestore,\n orgId: job.orgId,\n hostId: job.hostId,\n inputs: { target: 'catalog' },\n org: context.org ?? null,\n uid: job.createdBy,\n })\n : { status: 403, error: 'Products are not available on this site.' }\n if (refused) return refused.error\n const keeper = (deps.writerFor ?? pluginResourceDraftWriter)('product')\n if (!keeper) return 'Products are not available on this site.'\n const room = await keeper.writer.refusal({\n orgId: job.orgId,\n hostId: job.hostId,\n uid: job.createdBy,\n org: (context.org ?? null) as Readonly<Record<string, unknown>> | null,\n now: context.now,\n })\n return room?.error ?? null\n}\n\n/** The guided start's posts, published with its pages (AGL-3676). */\nexport interface AiSitePostsPublish {\n published: number\n kept: number\n /** The blog's own addresses, for the publish's cache drop. */\n paths: string[]\n}\n\n/**\n * Publishes the posts a guided start wrote, as the entry editor's Publish\n * does, once its pages are live. Never throws: a post that stays a draft is\n * the owner's to publish from Content.\n */\nexport async function aiPublishSitePosts(\n firestore: FirebaseFirestore.Firestore,\n input: { job: Pick<AiJob, '$id' | 'orgId' | 'hostId' | 'createdBy'>; outputs: readonly AiJobOutput[]; now: Date },\n publish: typeof publishContentEntries = publishContentEntries,\n): Promise<AiSitePostsPublish | null> {\n const posts = input.outputs.filter((output) => output.resource === 'entry')\n const collectionId = str(posts[0]?.proposal?.['collectionId'])\n const collectionSlug = str(posts[0]?.proposal?.['collectionSlug'])\n if (!input.job.hostId || !posts.length || !collectionId) return null\n try {\n const result = await publish(firestore, {\n hostId: input.job.hostId,\n collectionId,\n uid: input.job.createdBy,\n ids: posts.map((post) => post.id),\n now: input.now,\n })\n if ('ok' in result) {\n console.warn('ai site posts not published', { jobId: input.job.$id, error: result.error })\n return { published: 0, kept: posts.length, paths: [] }\n }\n const slugs = posts\n .filter((post) => result.published.includes(post.id))\n .map((post) => str(post.proposal?.['slug']))\n .filter(Boolean)\n return {\n published: result.published.length,\n kept: result.kept.length,\n paths: collectionSlug ? [`/${collectionSlug}`, ...slugs.map((slug) => `/${collectionSlug}/${slug}`)] : [],\n }\n } catch (error) {\n console.error('ai site posts publish threw', { orgId: input.job.orgId, jobId: input.job.$id, error })\n return null\n }\n}\n\n/**\n * The site's listings a layout or a page unit is handed (AGL-3676,\n * `ai-layout-listings.ts`): the store's catalog once its products are written,\n * the blog once its posts are, each with the sections of the plan's pages\n * that list it. A layout is built before either, so it is told the store will\n * sell (`sells`, its ledger still owing the products part), which puts the\n * cart in its header.\n */\nexport function aiSiteListings(input: {\n outputs: readonly AiJobOutput[]\n screens: readonly AiLayoutListingScreen[]\n /** The ledger owes a store's first products: a layout built before them carries the cart. */\n sells?: boolean\n /**\n * The site is a store (`siteKind: 'store'`, AGL-3676): its Shop page and\n * its home list the catalog whatever its first products came to — the\n * live Hearth & Wick start's products step failed, and its Shop page was\n * six cards naming kinds of candle. An empty catalog says so in the grid.\n */\n store?: boolean\n /**\n * The site is a music site (`siteKind: 'music'`, AGL-3716): its Music page,\n * or its home, places an empty Music player for the artist's own tracks.\n * Nothing is sourced: the owner uploads the recordings.\n */\n music?: boolean\n}): AiLayoutListing[] {\n const listings: AiLayoutListing[] = []\n const products = input.outputs.filter((output) => output.resource === 'product' && !output.proposal)\n if (products.length || input.sells || input.store) {\n const contact = aiSiteContactPath(input.screens)\n listings.push({\n id: aiLayoutListingId('products'),\n kind: 'products',\n name: 'the shop',\n records: products.map((product) => product.label),\n ...(contact ? { emptyAction: { label: 'Get in touch', href: contact } } : {}),\n // A store whose first products were skipped or failed lists its\n // (empty) catalog, but its header carries no cart until it sells.\n ...(products.length || input.sells ? {} : { cart: false }),\n placements: aiLayoutListingPlacements('products', input.screens),\n })\n // A store that sells shows its customers' reviews and takes newsletter\n // sign-ups where its pages name them (AGL-3676): both commerce elements,\n // so only where the store's commerce runs, never on a store that cannot\n // sell yet.\n if (products.length || input.sells) {\n for (const kind of ['reviews', 'signup'] as const) {\n const placements = aiLayoutListingPlacements(kind, input.screens)\n if (placements.length) listings.push({ id: aiLayoutListingId(kind), kind, name: kind === 'reviews' ? 'the store' : 'the newsletter', records: [], placements })\n }\n }\n }\n const posts = input.outputs.filter((output) => output.resource === 'entry')\n const slug = str(posts[0]?.proposal?.['collectionSlug'])\n if (posts.length && slug) {\n listings.push({\n id: aiLayoutListingId('posts'),\n kind: 'posts',\n name: 'the blog',\n records: posts.map((post) => post.label),\n href: `/${slug}`,\n collectionSlug: slug,\n placements: aiLayoutListingPlacements('posts', input.screens),\n })\n }\n if (input.music) {\n const placements = aiLayoutListingPlacements('tracks', input.screens)\n if (placements.length) {\n listings.push({ id: aiLayoutListingId('tracks'), kind: 'tracks', name: 'the music', records: [], placements })\n }\n }\n return listings\n}\n\n/** The page a visitor gets in touch on, by its path: one whose address or name says contact, else the one placing a form. */\nfunction aiSiteContactPath(screens: readonly AiLayoutListingScreen[]): string | null {\n const path = (slug: string) => `/${slug.trim().replace(/^\\/+|\\/+$/g, '')}`\n const isPath = (slug: string) => /^\\/[a-z0-9-]+(?:\\/[a-z0-9-]+)*$/.test(path(slug))\n const named = screens.find((screen) => isPath(screen.slug) && /\\b(contact|get in touch|enquir|inquir)/i.test(`${screen.slug} ${screen.title}`))\n if (named) return path(named.slug)\n const form = screens.find((screen) => isPath(screen.slug) && screen.sections.some((section) => (section.uses ?? []).some((use) => /form/i.test(use))))\n return form ? path(form.slug) : null\n}\n\n/**\n * A proposed product's description with each sentence that leaves a gap for\n * the owner (\"Delivery details: [how and when the card is sent].\") taken\n * out (AGL-3676): a start's products are listed as soon as they are written,\n * and a live run's gift card showed its gaps on the product page. A line\n * break is kept; nothing else is changed.\n */\nexport function aiSiteProductDescriptionWithoutGaps(description: string): string {\n return description\n .split('\\n')\n .map((line) =>\n line\n .split(/(?<=[.!?])\\s+/)\n .filter((sentence) => !/\\[[^\\]]+\\]/.test(sentence))\n .join(' '),\n )\n .join('\\n')\n .replace(/\\n{3,}/g, '\\n\\n')\n .trim()\n}\n\n/** What each product a start wrote says on the job's page (AGL-3676). */\nexport const AI_SITE_PRODUCT_NOTE =\n 'On your store at a suggested price. Change its price — and add your own photo — in Products.'\n\n/** The note a store's products row carries once they are written (AGL-3676): the step left before it sells. */\nexport const AI_SITE_PRODUCTS_PRICE_NOTE =\n 'Your products are on your store at suggested prices. Review and change them in Products.'\n\n/**\n * The price a start writes a product with (Zach, 2026-10-12): the catalog's\n * suggestion as `aiCatalogPrice` keeps it, stated as the writer reads one\n * (`priceUsd`); nothing when there is none in range, so the writer gives the\n * store's default price. Never `priceUsd: null`, which would leave the\n * product unpriced on purpose.\n */\nexport function aiSiteProductPriceContent(price: unknown): { priceUsd?: number } {\n const kept = aiCatalogPrice(price)\n return kept === null ? {} : { priceUsd: kept }\n}\n\n/** What a page of a blog or a store is told about the posts or products built before it. */\nexport function aiSiteContentBriefLines(outputs: readonly AiJobOutput[]): string[] {\n const posts = outputs.filter((output) => output.resource === 'entry')\n const products = outputs.filter((output) => output.resource === 'product' && !output.proposal)\n const lines: string[] = []\n if (posts.length) {\n const slug = str(posts[0].proposal?.['collectionSlug'])\n lines.push(\n `This site's blog${slug ? ` at /${slug}` : ''} has these posts: ${posts.map((post) => `“${post.label}”`).join(', ')}.`,\n 'Where a page features writing, feature these posts by their titles; never name a post that is not in this list.',\n )\n }\n if (products.length) {\n lines.push(\n `This store's products are: ${products.map((product) => `“${product.label}”`).join(', ')}.`,\n 'Where a page features products, feature these by their names; never name another product, and never state a price.',\n // The collection tiles a storefront home shows (AGL-3676): its own range, grouped.\n 'Where a page shows the shop by collection, group these products into two to four collections by what they are (a kind, a use or an occasion), one item each, named for the group and never for one product.',\n )\n }\n return lines\n}\n"],"names":["resolveMediaSrc","hostRoleCanWrite","resolveEffectivePlan","pluginResourceDraftWriter","publishContentEntries","writeContentCollection","writeContentEntryDraft","aiCatalogPrice","aiProductsProposalOf","aiSiteKindOfInputs","AI_SITE_BLOG_NAME","AI_SITE_BLOG_SLUGS","aiSiteWords","AI_STEP_TIERS","aiCatalogEntry","aiDefaultModelFor","aiModelForStep","AI_BLOG_POST_MAX_TOKENS","AI_BLOG_POST_STEP","generateAiBlogPost","aiLayoutStarterPhotos","aiOriginJobId","aiLayoutStockPhotoSource","aiStockPhotoWordsOf","aiLayoutListingId","aiLayoutListingPlacements","aiJobAdmissionFor","aiJobStepBudget","aiGenerationSpent","aiUnspentOutcome","AI_SITE_POSTS","AI_SITE_FREE_POSTS","AI_SITE_PRODUCTS","min","max","AI_SITE_PRODUCTS_NOT_WRITTEN_COPY","AI_SITE_POSTS_LABEL","AI_SITE_POST_LABEL","AI_SITE_PRODUCTS_LABEL","AI_SITE_CONTENT_INPUT","aiSiteContentPart","inputs","freeTaste","kind","id","aiSitePostModel","job","routed","entry","picked","model","trim","provider","undefined","AI_SITE_POST_WRITES_MS","AI_SITE_POST_BUDGET","tier","maxTokens","lookups","ownReadsMs","str","value","postsInputOf","raw","written","Array","isArray","filter","one","total","Math","floor","avoidSlugs","map","Boolean","byline","aiSitePostId","unitJobId","index","aiSiteProductId","readSite","firestore","hostId","host","collection","doc","get","exists","seo","subdomain","name","limitReview","message","reason","findings","AI_SITE_POST_COVER_ASPECT","aiSitePostCover","input","starters","title","source","stockPhotos","uid","createdBy","seed","$id","business","about","brief","sectionNames","jobId","signal","found","imageId","frameId","iconId","alt","aspect","sectionIndex","role","src","error","console","warn","String","from","length","_","slot","createAiSitePostsRunner","deps","generate","writeCollection","writeEntry","coverFor","cover","context","org","modelFor","failure","site","avoid","Set","slug","toLowerCase","blog","displayName","slugs","has","now","ok","review","generation","merchantWords","earlierTitles","post","spent","status","refused","catch","collectionId","content","excerpt","body","seoDescription","coverImage","coverImageAlt","authorName","output","resource","hostSubdomain","label","note","proposal","collectionSlug","outputs","continue","runAiSitePostsUnit","aiSiteProductPhotos","names","slots","product","subjects","shows","words","searches","_slot","aiSiteProductPhotoSrc","path","test","startsWith","aiSiteProductChoices","options","flatMap","option","seen","values","add","aiSiteProductsBriefLine","createAiSiteProductsRunner","writerFor","catalog","keeper","outcome","target","find","proposed","products","slice","photos","photo","stopped","rejected","entries","type","description","aiSiteProductDescriptionWithoutGaps","tags","seoTitle","comingSoon","aiSiteProductPriceContent","price","withPhoto","mediaUrls","photoRefused","writer","check","orgId","write","push","AI_SITE_PRODUCT_NOTE","last","aiSiteContentRefusal","part","admission","admissionFor","room","refusal","aiPublishSitePosts","publish","posts","result","ids","published","kept","paths","includes","aiSiteListings","listings","sells","store","contact","aiSiteContactPath","screens","records","emptyAction","href","cart","placements","music","replace","isPath","named","screen","form","sections","some","section","uses","use","split","line","sentence","join","AI_SITE_PRODUCTS_PRICE_NOTE","priceUsd","aiSiteContentBriefLines","lines"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,eAAe,QAAQ,mCAAkC;AAClE,SAASC,gBAAgB,QAAQ,uCAAsC;AACvE,SAASC,oBAAoB,QAAQ,2CAA0C;AAC/E,SAASC,yBAAyB,QAAQ,qDAAoD;AAC9F,SACEC,qBAAqB,EACrBC,sBAAsB,EACtBC,sBAAsB,QACjB,uDAAsD;AAC7D,SAASC,cAAc,EAAEC,oBAAoB,QAAQ,0BAAsB;AAE3E,SAASC,kBAAkB,QAAQ,4BAAwB;AAC3D,SAASC,iBAAiB,EAAEC,kBAAkB,EAAEC,WAAW,QAAQ,0BAAsB;AACzF,SAASC,aAAa,EAAEC,cAAc,EAAEC,iBAAiB,QAAQ,0BAAsB;AACvF,SAASC,cAAc,QAAQ,0BAAsB;AACrD,SACEC,uBAAuB,EACvBC,iBAAiB,EACjBC,kBAAkB,QACb,wCAAoC;AAC3C,SACEC,qBAAqB,QAGhB,2CAAuC;AAC9C,SAASC,aAAa,QAAQ,wBAAoB;AAClD,SAASC,wBAAwB,EAAEC,mBAAmB,QAAQ,8BAA0B;AACxF,SACEC,iBAAiB,EACjBC,yBAAyB,QAGpB,2CAAuC;AAC9C,SAASC,iBAAiB,QAAoC,wBAAoB;AAClF,S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DatasetInputOf(dataset: Pick<AiBuildPlanCreate, 'n
124
124
  export declare function aiSiteRecordTemplateOf(screen: Pick<AiBuildPlanScreen, 'record'>): string | null;
125
125
  /** The most fields a form's dataset is designed with: the data plugin writer's own ceiling is higher. */
126
126
  export declare const AI_SITE_FORM_DATASET_FIELDS_MAX = 12;
127
- /** A planned field as a person reads it: `fullName` and `full_name` are "Full name". */
127
+ /** A planned field as a person reads it: `fullName` and `full_name` are "Full name", `fechaDeÚltimaVisita` "Fecha de última visita". */
128
128
  export declare function aiSiteDatasetFieldName(planned: string): string;
129
129
  /**
130
130
  * A dataset a form writes to, as the data plugin's writer takes it
@@ -176,8 +176,8 @@ function datasetInputOf(job) {
176
176
  'boolean',
177
177
  'list'
178
178
  ];
179
- /** A planned field as a person reads it: `fullName` and `full_name` are "Full name". */ export function aiSiteDatasetFieldName(planned) {
180
- const words = planned.replace(/([a-z0-9])([A-Z])/g, '$1 $2').replace(/[_-]+/g, ' ').replace(/\s+/g, ' ').trim();
179
+ /** A planned field as a person reads it: `fullName` and `full_name` are "Full name", `fechaDeÚltimaVisita` "Fecha de última visita". */ export function aiSiteDatasetFieldName(planned) {
180
+ const words = planned.replace(RegExp("([\\u0061-\\u007A\\u00B5\\u00DF-\\u00F6\\u00F8-\\u00FF\\u0101\\u0103\\u0105\\u0107\\u0109\\u010B\\u010D\\u010F\\u0111\\u0113\\u0115\\u0117\\u0119\\u011B\\u011D\\u011F\\u0121\\u0123\\u0125\\u0127\\u0129\\u012B\\u012D\\u012F\\u0131\\u0133\\u0135\\u0137-\\u0138\\u013A\\u013C\\u013E\\u0140\\u0142\\u0144\\u0146\\u0148-\\u0149\\u014B\\u014D\\u014F\\u0151\\u0153\\u0155\\u0157\\u0159\\u015B\\u015D\\u015F\\u0161\\u0163\\u0165\\u0167\\u0169\\u016B\\u016D\\u016F\\u0171\\u0173\\u0175\\u0177\\u017A\\u017C\\u017E-\\u0180\\u0183\\u0185\\u0188\\u018C-\\u018D\\u0192\\u0195\\u0199-\\u019B\\u019E\\u01A1\\u01A3\\u01A5\\u01A8\\u01AA-\\u01AB\\u01AD\\u01B0\\u01B4\\u01B6\\u01B9-\\u01BA\\u01BD-\\u01BF\\u01C6\\u01C9\\u01CC\\u01CE\\u01D0\\u01D2\\u01D4\\u01D6\\u01D8\\u01DA\\u01DC-\\u01DD\\u01DF\\u01E1\\u01E3\\u01E5\\u01E7\\u01E9\\u01EB\\u01ED\\u01EF-\\u01F0\\u01F3\\u01F5\\u01F9\\u01FB\\u01FD\\u01FF\\u0201\\u0203\\u0205\\u0207\\u0209\\u020B\\u020D\\u020F\\u0211\\u0213\\u0215\\u0217\\u0219\\u021B\\u021D\\u021F\\u0221\\u0223\\u0225\\u0227\\u0229\\u022B\\u022D\\u022F\\u0231\\u0233-\\u0239\\u023C\\u023F-\\u0240\\u0242\\u0247\\u0249\\u024B\\u024D\\u024F-\\u0293\\u0296-\\u02AF\\u0371\\u0373\\u0377\\u037B-\\u037D\\u0390\\u03AC-\\u03CE\\u03D0-\\u03D1\\u03D5-\\u03D7\\u03D9\\u03DB\\u03DD\\u03DF\\u03E1\\u03E3\\u03E5\\u03E7\\u03E9\\u03EB\\u03ED\\u03EF-\\u03F3\\u03F5\\u03F8\\u03FB-\\u03FC\\u0430-\\u045F\\u0461\\u0463\\u0465\\u0467\\u0469\\u046B\\u046D\\u046F\\u0471\\u0473\\u0475\\u0477\\u0479\\u047B\\u047D\\u047F\\u0481\\u048B\\u048D\\u048F\\u0491\\u0493\\u0495\\u0497\\u0499\\u049B\\u049D\\u049F\\u04A1\\u04A3\\u04A5\\u04A7\\u04A9\\u04AB\\u04AD\\u04AF\\u04B1\\u04B3\\u04B5\\u04B7\\u04B9\\u04BB\\u04BD\\u04BF\\u04C2\\u04C4\\u04C6\\u04C8\\u04CA\\u04CC\\u04CE-\\u04CF\\u04D1\\u04D3\\u04D5\\u04D7\\u04D9\\u04DB\\u04DD\\u04DF\\u04E1\\u04E3\\u04E5\\u04E7\\u04E9\\u04EB\\u04ED\\u04EF\\u04F1\\u04F3\\u04F5\\u04F7\\u04F9\\u04FB\\u04FD\\u04FF\\u0501\\u0503\\u0505\\u0507\\u0509\\u050B\\u050D\\u050F\\u0511\\u0513\\u0515\\u0517\\u0519\\u051B\\u051D\\u051F\\u0521\\u0523\\u0525\\u0527\\u0529\\u052B\\u052D\\u052F\\u0560-\\u0588\\u10D0-\\u10FA\\u10FD-\\u10FF\\u13F8-\\u13FD\\u1C80-\\u1C88\\u1C8A\\u1D00-\\u1D2B\\u1D6B-\\u1D77\\u1D79-\\u1D9A\\u1E01\\u1E03\\u1E05\\u1E07\\u1E09\\u1E0B\\u1E0D\\u1E0F\\u1E11\\u1E13\\u1E15\\u1E17\\u1E19\\u1E1B\\u1E1D\\u1E1F\\u1E21\\u1E23\\u1E25\\u1E27\\u1E29\\u1E2B\\u1E2D\\u1E2F\\u1E31\\u1E33\\u1E35\\u1E37\\u1E39\\u1E3B\\u1E3D\\u1E3F\\u1E41\\u1E43\\u1E45\\u1E47\\u1E49\\u1E4B\\u1E4D\\u1E4F\\u1E51\\u1E53\\u1E55\\u1E57\\u1E59\\u1E5B\\u1E5D\\u1E5F\\u1E61\\u1E63\\u1E65\\u1E67\\u1E69\\u1E6B\\u1E6D\\u1E6F\\u1E71\\u1E73\\u1E75\\u1E77\\u1E79\\u1E7B\\u1E7D\\u1E7F\\u1E81\\u1E83\\u1E85\\u1E87\\u1E89\\u1E8B\\u1E8D\\u1E8F\\u1E91\\u1E93\\u1E95-\\u1E9D\\u1E9F\\u1EA1\\u1EA3\\u1EA5\\u1EA7\\u1EA9\\u1EAB\\u1EAD\\u1EAF\\u1EB1\\u1EB3\\u1EB5\\u1EB7\\u1EB9\\u1EBB\\u1EBD\\u1EBF\\u1EC1\\u1EC3\\u1EC5\\u1EC7\\u1EC9\\u1ECB\\u1ECD\\u1ECF\\u1ED1\\u1ED3\\u1ED5\\u1ED7\\u1ED9\\u1EDB\\u1EDD\\u1EDF\\u1EE1\\u1EE3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\\uA665\\uA667\\uA669\\uA66B\\uA66D\\uA681\\uA683\\uA685\\uA687\\uA689\\uA68B\\uA68D\\uA68F\\uA691\\uA693\\uA695\\uA697\\uA699\\uA69B\\uA723\\uA725\\uA727\\uA729\\uA72B\\uA72D\\uA72F-\\uA731\\uA733\\uA735\\uA737\\uA739\\uA73B\\uA73D\\uA73F\\uA741\\uA743\\uA745\\uA747\\uA749\\uA74B\\uA74D\\uA74F\\uA751\\uA753\\uA755\\uA757\\uA759\\uA75B\\uA75D\\uA75F\\uA761\\uA763\\uA765\\uA767\\uA769\\uA76B\\uA76D\\uA76F\\uA771-\\uA778\\uA77A\\uA77C\\uA77F\\uA781\\uA783\\uA785\\uA787\\uA78C\\uA78E\\uA791\\uA793-\\uA795\\uA797\\uA799\\uA79B\\uA79D\\uA79F\\uA7A1\\uA7A3\\uA7A5\\uA7A7\\uA7A9\\uA7AF\\uA7B5\\uA7B7\\uA7B9\\uA7BB\\uA7BD\\uA7BF\\uA7C1\\uA7C3\\uA7C8\\uA7CA\\uA7CD\\uA7CF\\uA7D1\\uA7D3\\uA7D5\\uA7D7\\uA7D9\\uA7DB\\uA7F6\\uA7FA\\uAB30-\\uAB5A\\uAB60-\\uAB68\\uAB70-\\uABBF\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFF41-\\uFF5A\\u{10428}-\\u{1044F}\\u{104D8}-\\u{104FB}\\u{10597}-\\u{105A1}\\u{105A3}-\\u{105B1}\\u{105B3}-\\u{105B9}\\u{105BB}-\\u{105BC}\\u{10CC0}-\\u{10CF2}\\u{10D70}-\\u{10D85}\\u{118C0}-\\u{118DF}\\u{16E60}-\\u{16E7F}\\u{16EBB}-\\u{16ED3}\\u{1D41A}-\\u{1D433}\\u{1D44E}-\\u{1D454}\\u{1D456}-\\u{1D467}\\u{1D482}-\\u{1D49B}\\u{1D4B6}-\\u{1D4B9}\\u{1D4BB}\\u{1D4BD}-\\u{1D4C3}\\u{1D4C5}-\\u{1D4CF}\\u{1D4EA}-\\u{1D503}\\u{1D51E}-\\u{1D537}\\u{1D552}-\\u{1D56B}\\u{1D586}-\\u{1D59F}\\u{1D5BA}-\\u{1D5D3}\\u{1D5EE}-\\u{1D607}\\u{1D622}-\\u{1D63B}\\u{1D656}-\\u{1D66F}\\u{1D68A}-\\u{1D6A5}\\u{1D6C2}-\\u{1D6DA}\\u{1D6DC}-\\u{1D6E1}\\u{1D6FC}-\\u{1D714}\\u{1D716}-\\u{1D71B}\\u{1D736}-\\u{1D74E}\\u{1D750}-\\u{1D755}\\u{1D770}-\\u{1D788}\\u{1D78A}-\\u{1D78F}\\u{1D7AA}-\\u{1D7C2}\\u{1D7C4}-\\u{1D7C9}\\u{1D7CB}\\u{1DF00}-\\u{1DF09}\\u{1DF0B}-\\u{1DF1E}\\u{1DF25}-\\u{1DF2A}\\u{1E922}-\\u{1E943}\\u0030-\\u0039\\u00B2-\\u00B3\\u00B9\\u00BC-\\u00BE\\u0660-\\u0669\\u06F0-\\u06F9\\u07C0-\\u07C9\\u0966-\\u096F\\u09E6-\\u09EF\\u09F4-\\u09F9\\u0A66-\\u0A6F\\u0AE6-\\u0AEF\\u0B66-\\u0B6F\\u0B72-\\u0B77\\u0BE6-\\u0BF2\\u0C66-\\u0C6F\\u0C78-\\u0C7E\\u0CE6-\\u0CEF\\u0D58-\\u0D5E\\u0D66-\\u0D78\\u0DE6-\\u0DEF\\u0E50-\\u0E59\\u0ED0-\\u0ED9\\u0F20-\\u0F33\\u1040-\\u1049\\u1090-\\u1099\\u1369-\\u137C\\u16EE-\\u16F0\\u17E0-\\u17E9\\u17F0-\\u17F9\\u1810-\\u1819\\u1946-\\u194F\\u19D0-\\u19DA\\u1A80-\\u1A89\\u1A90-\\u1A99\\u1B50-\\u1B59\\u1BB0-\\u1BB9\\u1C40-\\u1C49\\u1C50-\\u1C59\\u2070\\u2074-\\u2079\\u2080-\\u2089\\u2150-\\u2182\\u2185-\\u2189\\u2460-\\u249B\\u24EA-\\u24FF\\u2776-\\u2793\\u2CFD\\u3007\\u3021-\\u3029\\u3038-\\u303A\\u3192-\\u3195\\u3220-\\u3229\\u3248-\\u324F\\u3251-\\u325F\\u3280-\\u3289\\u32B1-\\u32BF\\uA620-\\uA629\\uA6E6-\\uA6EF\\uA830-\\uA835\\uA8D0-\\uA8D9\\uA900-\\uA909\\uA9D0-\\uA9D9\\uA9F0-\\uA9F9\\uAA50-\\uAA59\\uABF0-\\uABF9\\uFF10-\\uFF19\\u{10107}-\\u{10133}\\u{10140}-\\u{10178}\\u{1018A}-\\u{1018B}\\u{102E1}-\\u{102FB}\\u{10320}-\\u{10323}\\u{10341}\\u{1034A}\\u{103D1}-\\u{103D5}\\u{104A0}-\\u{104A9}\\u{10858}-\\u{1085F}\\u{10879}-\\u{1087F}\\u{108A7}-\\u{108AF}\\u{108FB}-\\u{108FF}\\u{10916}-\\u{1091B}\\u{109BC}-\\u{109BD}\\u{109C0}-\\u{109CF}\\u{109D2}-\\u{109FF}\\u{10A40}-\\u{10A48}\\u{10A7D}-\\u{10A7E}\\u{10A9D}-\\u{10A9F}\\u{10AEB}-\\u{10AEF}\\u{10B58}-\\u{10B5F}\\u{10B78}-\\u{10B7F}\\u{10BA9}-\\u{10BAF}\\u{10CFA}-\\u{10CFF}\\u{10D30}-\\u{10D39}\\u{10D40}-\\u{10D49}\\u{10E60}-\\u{10E7E}\\u{10F1D}-\\u{10F26}\\u{10F51}-\\u{10F54}\\u{10FC5}-\\u{10FCB}\\u{11052}-\\u{1106F}\\u{110F0}-\\u{110F9}\\u{11136}-\\u{1113F}\\u{111D0}-\\u{111D9}\\u{111E1}-\\u{111F4}\\u{112F0}-\\u{112F9}\\u{11450}-\\u{11459}\\u{114D0}-\\u{114D9}\\u{11650}-\\u{11659}\\u{116C0}-\\u{116C9}\\u{116D0}-\\u{116E3}\\u{11730}-\\u{1173B}\\u{118E0}-\\u{118F2}\\u{11950}-\\u{11959}\\u{11BF0}-\\u{11BF9}\\u{11C50}-\\u{11C6C}\\u{11D50}-\\u{11D59}\\u{11DA0}-\\u{11DA9}\\u{11DE0}-\\u{11DE9}\\u{11F50}-\\u{11F59}\\u{11FC0}-\\u{11FD4}\\u{12400}-\\u{1246E}\\u{16130}-\\u{16139}\\u{16A60}-\\u{16A69}\\u{16AC0}-\\u{16AC9}\\u{16B50}-\\u{16B59}\\u{16B5B}-\\u{16B61}\\u{16D70}-\\u{16D79}\\u{16E80}-\\u{16E96}\\u{16FF4}-\\u{16FF6}\\u{1CCF0}-\\u{1CCF9}\\u{1D2C0}-\\u{1D2D3}\\u{1D2E0}-\\u{1D2F3}\\u{1D360}-\\u{1D378}\\u{1D7CE}-\\u{1D7FF}\\u{1E140}-\\u{1E149}\\u{1E2F0}-\\u{1E2F9}\\u{1E4F0}-\\u{1E4F9}\\u{1E5F1}-\\u{1E5FA}\\u{1E8C7}-\\u{1E8CF}\\u{1E950}-\\u{1E959}\\u{1EC71}-\\u{1ECAB}\\u{1ECAD}-\\u{1ECAF}\\u{1ECB1}-\\u{1ECB4}\\u{1ED01}-\\u{1ED2D}\\u{1ED2F}-\\u{1ED3D}\\u{1F100}-\\u{1F10C}\\u{1FBF0}-\\u{1FBF9}])([\\u0041-\\u005A\\u00C0-\\u00D6\\u00D8-\\u00DE\\u0100\\u0102\\u0104\\u0106\\u0108\\u010A\\u010C\\u010E\\u0110\\u0112\\u0114\\u0116\\u0118\\u011A\\u011C\\u011E\\u0120\\u0122\\u0124\\u0126\\u0128\\u012A\\u012C\\u012E\\u0130\\u0132\\u0134\\u0136\\u0139\\u013B\\u013D\\u013F\\u0141\\u0143\\u0145\\u0147\\u014A\\u014C\\u014E\\u0150\\u0152\\u0154\\u0156\\u0158\\u015A\\u015C\\u015E\\u0160\\u0162\\u0164\\u0166\\u0168\\u016A\\u016C\\u016E\\u0170\\u0172\\u0174\\u0176\\u0178-\\u0179\\u017B\\u017D\\u0181-\\u0182\\u0184\\u0186-\\u0187\\u0189-\\u018B\\u018E-\\u0191\\u0193-\\u0194\\u0196-\\u0198\\u019C-\\u019D\\u019F-\\u01A0\\u01A2\\u01A4\\u01A6-\\u01A7\\u01A9\\u01AC\\u01AE-\\u01AF\\u01B1-\\u01B3\\u01B5\\u01B7-\\u01B8\\u01BC\\u01C4\\u01C7\\u01CA\\u01CD\\u01CF\\u01D1\\u01D3\\u01D5\\u01D7\\u01D9\\u01DB\\u01DE\\u01E0\\u01E2\\u01E4\\u01E6\\u01E8\\u01EA\\u01EC\\u01EE\\u01F1\\u01F4\\u01F6-\\u01F8\\u01FA\\u01FC\\u01FE\\u0200\\u0202\\u0204\\u0206\\u0208\\u020A\\u020C\\u020E\\u0210\\u0212\\u0214\\u0216\\u0218\\u021A\\u021C\\u021E\\u0220\\u0222\\u0224\\u0226\\u0228\\u022A\\u022C\\u022E\\u0230\\u0232\\u023A-\\u023B\\u023D-\\u023E\\u0241\\u0243-\\u0246\\u0248\\u024A\\u024C\\u024E\\u0370\\u0372\\u0376\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u038F\\u0391-\\u03A1\\u03A3-\\u03AB\\u03CF\\u03D2-\\u03D4\\u03D8\\u03DA\\u03DC\\u03DE\\u03E0\\u03E2\\u03E4\\u03E6\\u03E8\\u03EA\\u03EC\\u03EE\\u03F4\\u03F7\\u03F9-\\u03FA\\u03FD-\\u042F\\u0460\\u0462\\u0464\\u0466\\u0468\\u046A\\u046C\\u046E\\u0470\\u0472\\u0474\\u0476\\u0478\\u047A\\u047C\\u047E\\u0480\\u048A\\u048C\\u048E\\u0490\\u0492\\u0494\\u0496\\u0498\\u049A\\u049C\\u049E\\u04A0\\u04A2\\u04A4\\u04A6\\u04A8\\u04AA\\u04AC\\u04AE\\u04B0\\u04B2\\u04B4\\u04B6\\u04B8\\u04BA\\u04BC\\u04BE\\u04C0-\\u04C1\\u04C3\\u04C5\\u04C7\\u04C9\\u04CB\\u04CD\\u04D0\\u04D2\\u04D4\\u04D6\\u04D8\\u04DA\\u04DC\\u04DE\\u04E0\\u04E2\\u04E4\\u04E6\\u04E8\\u04EA\\u04EC\\u04EE\\u04F0\\u04F2\\u04F4\\u04F6\\u04F8\\u04FA\\u04FC\\u04FE\\u0500\\u0502\\u0504\\u0506\\u0508\\u050A\\u050C\\u050E\\u0510\\u0512\\u0514\\u0516\\u0518\\u051A\\u051C\\u051E\\u0520\\u0522\\u0524\\u0526\\u0528\\u052A\\u052C\\u052E\\u0531-\\u0556\\u10A0-\\u10C5\\u10C7\\u10CD\\u13A0-\\u13F5\\u1C89\\u1C90-\\u1CBA\\u1CBD-\\u1CBF\\u1E00\\u1E02\\u1E04\\u1E06\\u1E08\\u1E0A\\u1E0C\\u1E0E\\u1E10\\u1E12\\u1E14\\u1E16\\u1E18\\u1E1A\\u1E1C\\u1E1E\\u1E20\\u1E22\\u1E24\\u1E26\\u1E28\\u1E2A\\u1E2C\\u1E2E\\u1E30\\u1E32\\u1E34\\u1E36\\u1E38\\u1E3A\\u1E3C\\u1E3E\\u1E40\\u1E42\\u1E44\\u1E46\\u1E48\\u1E4A\\u1E4C\\u1E4E\\u1E50\\u1E52\\u1E54\\u1E56\\u1E58\\u1E5A\\u1E5C\\u1E5E\\u1E60\\u1E62\\u1E64\\u1E66\\u1E68\\u1E6A\\u1E6C\\u1E6E\\u1E70\\u1E72\\u1E74\\u1E76\\u1E78\\u1E7A\\u1E7C\\u1E7E\\u1E80\\u1E82\\u1E84\\u1E86\\u1E88\\u1E8A\\u1E8C\\u1E8E\\u1E90\\u1E92\\u1E94\\u1E9E\\u1EA0\\u1EA2\\u1EA4\\u1EA6\\u1EA8\\u1EAA\\u1EAC\\u1EAE\\u1EB0\\u1EB2\\u1EB4\\u1EB6\\u1EB8\\u1EBA\\u1EBC\\u1EBE\\u1EC0\\u1EC2\\u1EC4\\u1EC6\\u1EC8\\u1ECA\\u1ECC\\u1ECE\\u1ED0\\u1ED2\\u1ED4\\u1ED6\\u1ED8\\u1EDA\\u1EDC\\u1EDE\\u1EE0\\u1EE2\\u1EE4\\u1EE6\\u1EE8\\u1EEA\\u1EEC\\u1EEE\\u1EF0\\u1EF2\\u1EF4\\u1EF6\\u1EF8\\u1EFA\\u1EFC\\u1EFE\\u1F08-\\u1F0F\\u1F18-\\u1F1D\\u1F28-\\u1F2F\\u1F38-\\u1F3F\\u1F48-\\u1F4D\\u1F59\\u1F5B\\u1F5D\\u1F5F\\u1F68-\\u1F6F\\u1FB8-\\u1FBB\\u1FC8-\\u1FCB\\u1FD8-\\u1FDB\\u1FE8-\\u1FEC\\u1FF8-\\u1FFB\\u2102\\u2107\\u210B-\\u210D\\u2110-\\u2112\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u2130-\\u2133\\u213E-\\u213F\\u2145\\u2183\\u2C00-\\u2C2F\\u2C60\\u2C62-\\u2C64\\u2C67\\u2C69\\u2C6B\\u2C6D-\\u2C70\\u2C72\\u2C75\\u2C7E-\\u2C80\\u2C82\\u2C84\\u2C86\\u2C88\\u2C8A\\u2C8C\\u2C8E\\u2C90\\u2C92\\u2C94\\u2C96\\u2C98\\u2C9A\\u2C9C\\u2C9E\\u2CA0\\u2CA2\\u2CA4\\u2CA6\\u2CA8\\u2CAA\\u2CAC\\u2CAE\\u2CB0\\u2CB2\\u2CB4\\u2CB6\\u2CB8\\u2CBA\\u2CBC\\u2CBE\\u2CC0\\u2CC2\\u2CC4\\u2CC6\\u2CC8\\u2CCA\\u2CCC\\u2CCE\\u2CD0\\u2CD2\\u2CD4\\u2CD6\\u2CD8\\u2CDA\\u2CDC\\u2CDE\\u2CE0\\u2CE2\\u2CEB\\u2CED\\u2CF2\\uA640\\uA642\\uA644\\uA646\\uA648\\uA64A\\uA64C\\uA64E\\uA650\\uA652\\uA654\\uA656\\uA658\\uA65A\\uA65C\\uA65E\\uA660\\uA662\\uA664\\uA666\\uA668\\uA66A\\uA66C\\uA680\\uA682\\uA684\\uA686\\uA688\\uA68A\\uA68C\\uA68E\\uA690\\uA692\\uA694\\uA696\\uA698\\uA69A\\uA722\\uA724\\uA726\\uA728\\uA72A\\uA72C\\uA72E\\uA732\\uA734\\uA736\\uA738\\uA73A\\uA73C\\uA73E\\uA740\\uA742\\uA744\\uA746\\uA748\\uA74A\\uA74C\\uA74E\\uA750\\uA752\\uA754\\uA756\\uA758\\uA75A\\uA75C\\uA75E\\uA760\\uA762\\uA764\\uA766\\uA768\\uA76A\\uA76C\\uA76E\\uA779\\uA77B\\uA77D-\\uA77E\\uA780\\uA782\\uA784\\uA786\\uA78B\\uA78D\\uA790\\uA792\\uA796\\uA798\\uA79A\\uA79C\\uA79E\\uA7A0\\uA7A2\\uA7A4\\uA7A6\\uA7A8\\uA7AA-\\uA7AE\\uA7B0-\\uA7B4\\uA7B6\\uA7B8\\uA7BA\\uA7BC\\uA7BE\\uA7C0\\uA7C2\\uA7C4-\\uA7C7\\uA7C9\\uA7CB-\\uA7CC\\uA7CE\\uA7D0\\uA7D2\\uA7D4\\uA7D6\\uA7D8\\uA7DA\\uA7DC\\uA7F5\\uFF21-\\uFF3A\\u{10400}-\\u{10427}\\u{104B0}-\\u{104D3}\\u{10570}-\\u{1057A}\\u{1057C}-\\u{1058A}\\u{1058C}-\\u{10592}\\u{10594}-\\u{10595}\\u{10C80}-\\u{10CB2}\\u{10D50}-\\u{10D65}\\u{118A0}-\\u{118BF}\\u{16E40}-\\u{16E5F}\\u{16EA0}-\\u{16EB8}\\u{1D400}-\\u{1D419}\\u{1D434}-\\u{1D44D}\\u{1D468}-\\u{1D481}\\u{1D49C}\\u{1D49E}-\\u{1D49F}\\u{1D4A2}\\u{1D4A5}-\\u{1D4A6}\\u{1D4A9}-\\u{1D4AC}\\u{1D4AE}-\\u{1D4B5}\\u{1D4D0}-\\u{1D4E9}\\u{1D504}-\\u{1D505}\\u{1D507}-\\u{1D50A}\\u{1D50D}-\\u{1D514}\\u{1D516}-\\u{1D51C}\\u{1D538}-\\u{1D539}\\u{1D53B}-\\u{1D53E}\\u{1D540}-\\u{1D544}\\u{1D546}\\u{1D54A}-\\u{1D550}\\u{1D56C}-\\u{1D585}\\u{1D5A0}-\\u{1D5B9}\\u{1D5D4}-\\u{1D5ED}\\u{1D608}-\\u{1D621}\\u{1D63C}-\\u{1D655}\\u{1D670}-\\u{1D689}\\u{1D6A8}-\\u{1D6C0}\\u{1D6E2}-\\u{1D6FA}\\u{1D71C}-\\u{1D734}\\u{1D756}-\\u{1D76E}\\u{1D790}-\\u{1D7A8}\\u{1D7CA}\\u{1E900}-\\u{1E921}])", "gu"), '$1 $2').replace(/[_-]+/g, ' ').replace(/\s+/g, ' ').trim();
181
181
  return words ? words.charAt(0).toUpperCase() + words.slice(1).toLowerCase() : '';
182
182
  }
183
183
  /**