@aglyn/plugins-ai 1.0.0-beta.291 → 1.0.0-beta.293
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -17
- package/src/lib/components/ai-site-import-job.component.js +5 -4
- package/src/lib/components/ai-site-import-job.component.js.map +1 -1
- package/src/lib/components/ai-site-import-start.component.js +3 -3
- package/src/lib/components/ai-site-import-start.component.js.map +1 -1
- package/src/lib/components/ai-site-start-card.component.d.ts +1 -1
- package/src/lib/components/ai-site-start-card.component.js +129 -29
- package/src/lib/components/ai-site-start-card.component.js.map +1 -1
- package/src/lib/components/ai-site-start-steps.component.d.ts +15 -3
- package/src/lib/components/ai-site-start-steps.component.js +42 -25
- package/src/lib/components/ai-site-start-steps.component.js.map +1 -1
- package/src/lib/components/ai-site-style-previews.d.ts +17 -0
- package/src/lib/components/ai-site-style-previews.js +26 -95
- package/src/lib/components/ai-site-style-previews.js.map +1 -1
- package/src/lib/declarations.server.js +22 -0
- package/src/lib/declarations.server.js.map +1 -1
- package/src/lib/jobs/ai-job-import-step.d.ts +21 -2
- package/src/lib/jobs/ai-job-import-step.js +179 -49
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-job-layout-language.d.ts +27 -3
- package/src/lib/jobs/ai-job-layout-language.js +156 -113
- package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
- package/src/lib/jobs/ai-job-layout-step.js +56 -17
- package/src/lib/jobs/ai-job-layout-step.js.map +1 -1
- package/src/lib/jobs/ai-job-page-language.d.ts +25 -15
- package/src/lib/jobs/ai-job-page-language.js +120 -66
- package/src/lib/jobs/ai-job-page-language.js.map +1 -1
- package/src/lib/jobs/ai-job-page-step.js +27 -7
- package/src/lib/jobs/ai-job-page-step.js.map +1 -1
- package/src/lib/jobs/ai-job-site-datasets.d.ts +12 -4
- package/src/lib/jobs/ai-job-site-datasets.js +36 -16
- package/src/lib/jobs/ai-job-site-datasets.js.map +1 -1
- package/src/lib/jobs/ai-jobs.js +6 -2
- package/src/lib/jobs/ai-jobs.js.map +1 -1
- package/src/lib/jobs/ai-layout-stock-photos.d.ts +50 -1
- package/src/lib/jobs/ai-layout-stock-photos.js +586 -35
- package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.d.ts +147 -0
- package/src/lib/jobs/ai-site-import-compile.js +1143 -0
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -0
- package/src/lib/jobs/ai-site-import-document.d.ts +9 -36
- package/src/lib/jobs/ai-site-import-document.js +23 -489
- package/src/lib/jobs/ai-site-import-document.js.map +1 -1
- package/src/lib/jobs/ai-site-import-look.d.ts +54 -7
- package/src/lib/jobs/ai-site-import-look.js +163 -52
- package/src/lib/jobs/ai-site-import-look.js.map +1 -1
- package/src/lib/jobs/ai-site-import-publish.d.ts +7 -1
- package/src/lib/jobs/ai-site-import-publish.js +19 -5
- package/src/lib/jobs/ai-site-import-publish.js.map +1 -1
- package/src/lib/jobs/ai-site-late-photos.js +4 -2
- package/src/lib/jobs/ai-site-late-photos.js.map +1 -1
- package/src/lib/jobs/ai-site-publish.d.ts +10 -1
- package/src/lib/jobs/ai-site-publish.js +8 -3
- package/src/lib/jobs/ai-site-publish.js.map +1 -1
- package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1029-recordings.d.ts +23 -0
- package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1029-recordings.js +677 -0
- package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1029-recordings.js.map +1 -0
- package/src/lib/layout-language/ai-layout-compiler.d.ts +26 -0
- package/src/lib/layout-language/ai-layout-compiler.js +677 -33
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/layout-language/ai-layout-frame-hollows.js +5 -1
- package/src/lib/layout-language/ai-layout-frame-hollows.js.map +1 -1
- package/src/lib/layout-language/ai-layout-frame-source.d.ts +196 -0
- package/src/lib/layout-language/ai-layout-frame-source.js +726 -0
- package/src/lib/layout-language/ai-layout-frame-source.js.map +1 -0
- package/src/lib/layout-language/ai-layout-frame.d.ts +22 -0
- package/src/lib/layout-language/ai-layout-frame.js +121 -29
- package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
- package/src/lib/layout-language/ai-layout-language.d.ts +103 -37
- package/src/lib/layout-language/ai-layout-language.js +85 -120
- package/src/lib/layout-language/ai-layout-language.js.map +1 -1
- package/src/lib/model/ai-credit-estimate.d.ts +11 -7
- package/src/lib/model/ai-credit-estimate.js +11 -7
- package/src/lib/model/ai-credit-estimate.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +307 -13
- package/src/lib/model/ai-site-import.js +227 -19
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/model/ai-site-look.d.ts +65 -1
- package/src/lib/model/ai-site-look.js +141 -23
- package/src/lib/model/ai-site-look.js.map +1 -1
- package/src/lib/model/ai-site-photos.d.ts +2 -0
- package/src/lib/model/ai-site-photos.js.map +1 -1
- package/src/lib/model/ai-site-start-steps.d.ts +4 -3
- package/src/lib/model/ai-site-start-steps.js +11 -3
- package/src/lib/model/ai-site-start-steps.js.map +1 -1
- package/src/lib/model/ai-site-start.d.ts +23 -2
- package/src/lib/model/ai-site-start.js +25 -3
- package/src/lib/model/ai-site-start.js.map +1 -1
- package/src/lib/providers/routing.d.ts +11 -0
- package/src/lib/providers/routing.js +23 -0
- package/src/lib/providers/routing.js.map +1 -1
- package/src/lib/runtime/ai-doctrine-validators.d.ts +4 -2
- package/src/lib/runtime/ai-doctrine-validators.js +7 -2
- package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
- package/src/lib/runtime/ai-icon-library.d.ts +4 -0
- package/src/lib/runtime/ai-icon-library.js +4 -0
- package/src/lib/runtime/ai-icon-library.js.map +1 -1
- package/src/lib/runtime/ai-node-tree.js +5 -1
- package/src/lib/runtime/ai-node-tree.js.map +1 -1
- package/src/lib/runtime/ai-palette.d.ts +2 -0
- package/src/lib/runtime/ai-palette.generated.js +19 -3
- package/src/lib/runtime/ai-palette.generated.js.map +1 -1
- package/src/lib/runtime/ai-palette.js +2 -1
- package/src/lib/runtime/ai-palette.js.map +1 -1
- package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +50 -0
- package/src/lib/site-import/fixtures/site-layout-recordings.js +86 -0
- package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -0
- package/src/lib/site-import/site-import-crawl.d.ts +18 -1
- package/src/lib/site-import/site-import-crawl.js +70 -10
- package/src/lib/site-import/site-import-crawl.js.map +1 -1
- package/src/lib/site-import/site-import-css.d.ts +110 -0
- package/src/lib/site-import/site-import-css.js +826 -0
- package/src/lib/site-import/site-import-css.js.map +1 -0
- package/src/lib/site-import/site-import-html.d.ts +116 -1
- package/src/lib/site-import/site-import-html.js +538 -46
- package/src/lib/site-import/site-import-html.js.map +1 -1
- package/src/lib/site-import/site-import-layout.d.ts +79 -0
- package/src/lib/site-import/site-import-layout.js +1608 -0
- package/src/lib/site-import/site-import-layout.js.map +1 -0
- package/src/lib/site-import/site-import-nav.d.ts +40 -0
- package/src/lib/site-import/site-import-nav.js +437 -0
- package/src/lib/site-import/site-import-nav.js.map +1 -0
- package/src/lib/site-import/site-import-page.d.ts +8 -1
- package/src/lib/site-import/site-import-page.js +24 -2
- package/src/lib/site-import/site-import-page.js.map +1 -1
- package/src/lib/assets/site-styles/beauty.webp +0 -0
- package/src/lib/assets/site-styles/blog.webp +0 -0
- package/src/lib/assets/site-styles/business.webp +0 -0
- package/src/lib/assets/site-styles/coming-soon.webp +0 -0
- package/src/lib/assets/site-styles/education.webp +0 -0
- package/src/lib/assets/site-styles/events.webp +0 -0
- package/src/lib/assets/site-styles/fitness.webp +0 -0
- package/src/lib/assets/site-styles/landing.webp +0 -0
- package/src/lib/assets/site-styles/music.webp +0 -0
- package/src/lib/assets/site-styles/nonprofit.webp +0 -0
- package/src/lib/assets/site-styles/personal.webp +0 -0
- package/src/lib/assets/site-styles/photography.webp +0 -0
- package/src/lib/assets/site-styles/portfolio.webp +0 -0
- package/src/lib/assets/site-styles/professional.webp +0 -0
- package/src/lib/assets/site-styles/realestate.webp +0 -0
- package/src/lib/assets/site-styles/restaurant.webp +0 -0
- package/src/lib/assets/site-styles/store.webp +0 -0
- package/src/lib/assets/site-styles/studio.webp +0 -0
- package/src/lib/assets/site-styles/trades.webp +0 -0
- package/src/lib/assets/site-styles/wellness.webp +0 -0
- package/src/lib/assets/site-styles/yoga.webp +0 -0
- package/src/lib/site-import/site-import-review.d.ts +0 -40
- package/src/lib/site-import/site-import-review.js +0 -149
- package/src/lib/site-import/site-import-review.js.map +0 -1
|
@@ -77,6 +77,8 @@ export interface AiSiteListRecord {
|
|
|
77
77
|
/** The library photo it shows, with its size and words; absent on a starter. */
|
|
78
78
|
photo?: AiLayoutPicturePhoto;
|
|
79
79
|
refused?: AiStockRefusedPicks;
|
|
80
|
+
/** A record of a thing of its own (AGL-4092): its own photo or its starter, never another record's or the job's. */
|
|
81
|
+
itsOwn?: true;
|
|
80
82
|
}
|
|
81
83
|
/** A pictured list of the start, one of whose records holds a starter photo. */
|
|
82
84
|
export interface AiSiteStarterList {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-site-photos.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { StockPhotoSearchRequest } from '@aglyn/aglyn/plugin-manager/stock-photo-provider'\nimport type { AiLayoutPicturePhoto, AiLayoutPictureRole } from '../layout-language/ai-layout-pictures'\n\n/**\n * THE PICTURES A SITE START LEFT ON A STARTER PHOTO (AGL-3988).\n *\n * A guided start's pages and its datasets' records are each built in a pass\n * of their own, minutes apart. A picture the stock library could not fill in\n * its pass took a starter photo there: its picks' downloads refused by the\n * library's image hosts in a burst, or no photo of the job's own to take\n * yet. The v1.0.0-beta.271 Laurel Fork Photography start (2026-10-19 23:05Z)\n * filed all twelve \"Gallery collections\" covers and its home hero under an\n * office team and a desk: pixabay.com's Cloudflare answered 429 to 22\n * downloads while the covers were built, before the job had copied any\n * photo, and to 11 more on the home page, the first page built.\n *\n * Each such picture is written down here, with the picks the hosts refused,\n * on the job, by the machine, in the write that records its pass. The site\n * step's late photo pass (`jobs/ai-site-late-photos.ts`) reads it once every\n * page is built and before the site is published: it asks the refused picks\n * for again, a minute after the refusal, and gives every picture still on a\n * starter one of the photos the job copied. Pure.\n */\n\n/** Where a starter photo is served from: the platform's own files, on every site's origin. */\nexport const AI_SITE_STARTER_PREFIX = '/_static/starter/'\n\n/** Whether an address is a starter photo's. */\nexport function aiSiteIsStarterSrc(src: unknown): boolean {\n return typeof src === 'string' && src.startsWith(AI_SITE_STARTER_PREFIX)\n}\n\n/** The picks a slot kept in hand whose downloads the library's image hosts refused, to ask for again. */\nexport interface AiStockRefusedPicks {\n /** The search they came from, as it was sent: asked again, the provider's cache answers it. */\n request: StockPhotoSearchRequest\n /** The picks' source keys (`pixabay:5401602`), best first. */\n keys: string[]\n /** When the last of them was refused, ISO. */\n at: string\n}\n\n/** A picture of one of the start's pages that holds a starter photo. */\nexport interface AiSiteStarterSlot {\n /** The `image` node. */\n image: string\n /** What the picture was to show, in the slot's own words: a starter's alt text is the starter's. */\n words: string\n role: AiLayoutPictureRole\n /** The frame's shape, width over height. */\n aspect: number\n refused?: AiStockRefusedPicks\n}\n\n/** A page of the start with the pictures it left on a starter. */\nexport interface AiSiteStarterPage {\n /** The page's draft. */\n screen: string\n slots: AiSiteStarterSlot[]\n}\n\n/** A record of a pictured list, as its photo was written. */\nexport interface AiSiteListRecord {\n /** The record's name: its first field's value. */\n name: string\n /** What the list files it under, where it files its records (AGL-3856). */\n category?: string\n /** The value its photo field holds: a starter's path, or the library photo's CDN path. */\n value: string\n /** The library photo it shows, with its size and words; absent on a starter. */\n photo?: AiLayoutPicturePhoto\n refused?: AiStockRefusedPicks\n}\n\n/** A pictured list of the start, one of whose records holds a starter photo. */\nexport interface AiSiteStarterList {\n /** The dataset. */\n dataset: string\n /** Its photo field, by id. */\n imageField: string\n /** The field its records keep what their photo shows in, by id (AGL-3856). */\n altField?: string\n /** A list of the business's people: a record of it never takes a photo of anything but a person. */\n people?: boolean\n /** Every record, in order, so a record's neighbors are known. */\n records: AiSiteListRecord[]\n}\n\n/** What a site job holds on its pictures that took a starter, until its late photo pass. */\nexport interface AiSitePhotos {\n pages: AiSiteStarterPage[]\n lists: AiSiteStarterList[]\n /**\n * The late photo passes that ran out of time and handed this back (AGL-3988).\n * The site step publishes on the last pass its bound gives them, whatever\n * the pictures hold then, so a burst that never clears never holds a site\n * back.\n */\n latePasses?: number\n}\n\n/** The most of each a job keeps: a site's pages, each one's pictures, and its lists' records. */\nconst PAGES_MAX = 12\nconst SLOTS_MAX = 16\nconst LISTS_MAX = 8\nconst RECORDS_MAX = 24\nconst KEYS_MAX = 3\n\n/** An entry with its refused picks bounded, and none where it has none. */\nfunction withPicks<T extends { refused?: AiStockRefusedPicks }>(entry: T): T {\n const copy = { ...entry }\n delete copy.refused\n const keys = entry.refused?.keys.slice(0, KEYS_MAX) ?? []\n return entry.refused && keys.length ? { ...copy, refused: { ...entry.refused, keys } } : copy\n}\n\n/** A page's starters as a job keeps them: bounded, and none without a picture. */\nfunction pageOf(page: AiSiteStarterPage): AiSiteStarterPage | null {\n const slots = page.slots.slice(0, SLOTS_MAX).map(withPicks)\n return page.screen && slots.length ? { screen: page.screen, slots } : null\n}\n\n/** Whether a list still holds a starter on any record. */\nfunction listHoldsStarters(list: AiSiteStarterList): boolean {\n return list.records.some((record) => aiSiteIsStarterSrc(record.value))\n}\n\n/**\n * The job's photos state once a unit reported its own (AGL-3988): a page's\n * or a list's entry replaces the one it had, by its draft or its dataset;\n * every other entry stays. `null` where neither holds anything.\n */\nexport function aiSiteMergePhotos(\n previous: AiSitePhotos | null | undefined,\n next: Partial<AiSitePhotos> | null | undefined,\n): AiSitePhotos | null {\n const pages = new Map((previous?.pages ?? []).map((page) => [page.screen, page]))\n for (const page of next?.pages ?? []) {\n const kept = pageOf(page)\n if (kept) pages.set(kept.screen, kept)\n else pages.delete(page.screen)\n }\n const lists = new Map((previous?.lists ?? []).map((list) => [list.dataset, list]))\n for (const list of next?.lists ?? []) {\n if (list.dataset && list.imageField && listHoldsStarters(list)) {\n lists.set(list.dataset, { ...list, records: list.records.slice(0, RECORDS_MAX).map(withPicks) })\n } else lists.delete(list.dataset)\n }\n const merged: AiSitePhotos = { pages: [...pages.values()].slice(0, PAGES_MAX), lists: [...lists.values()].slice(0, LISTS_MAX) }\n const latePasses = next?.latePasses ?? previous?.latePasses\n if (latePasses) merged.latePasses = latePasses\n return merged.pages.length || merged.lists.length ? merged : null\n}\n\n/**\n * Whether a site job owes its late photo pass: a page picture or a list\n * record it left on a starter. With `pageIds`, only a picture of one of\n * those pages counts: a page that was not built is never published.\n */\nexport function aiSitePhotosOwed(photos: AiSitePhotos | null | undefined, pageIds?: readonly string[]): boolean {\n const built = pageIds ? new Set(pageIds) : null\n return Boolean(\n photos?.pages.some((page) => page.slots.length && (!built || built.has(page.screen))) || photos?.lists.some(listHoldsStarters),\n )\n}\n\n/** When the newest refusal the state holds was made, in ms; `null` where none was. */\nexport function aiSitePhotosLastRefusalMs(photos: AiSitePhotos | null | undefined): number | null {\n const times = [\n ...(photos?.pages ?? []).flatMap((page) => page.slots.map((slot) => slot.refused?.at)),\n ...(photos?.lists ?? []).flatMap((list) => list.records.map((record) => record.refused?.at)),\n ]\n .map((at) => (at ? Date.parse(at) : NaN))\n .filter((ms) => Number.isFinite(ms))\n return times.length ? Math.max(...times) : null\n}\n"],"names":["AI_SITE_STARTER_PREFIX","aiSiteIsStarterSrc","src","startsWith","PAGES_MAX","SLOTS_MAX","LISTS_MAX","RECORDS_MAX","KEYS_MAX","withPicks","entry","copy","refused","keys","slice","length","pageOf","page","slots","map","screen","listHoldsStarters","list","records","some","record","value","aiSiteMergePhotos","previous","next","pages","Map","kept","set","delete","lists","dataset","imageField","merged","values","latePasses","aiSitePhotosOwed","photos","pageIds","built","Set","Boolean","has","aiSitePhotosLastRefusalMs","times","flatMap","slot","at","Date","parse","NaN","filter","ms","Number","isFinite","Math","max"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAKD;;;;;;;;;;;;;;;;;;;CAmBC,GAED,4FAA4F,GAC5F,OAAO,MAAMA,yBAAyB,oBAAmB;AAEzD,6CAA6C,GAC7C,OAAO,SAASC,mBAAmBC,GAAY;IAC7C,OAAO,OAAOA,QAAQ,YAAYA,IAAIC,UAAU,CAACH;AACnD;AAuEA,+FAA+F,GAC/F,MAAMI,YAAY;AAClB,MAAMC,YAAY;AAClB,MAAMC,YAAY;AAClB,MAAMC,cAAc;AACpB,MAAMC,WAAW;AAEjB,yEAAyE,GACzE,SAASC,UAAuDC,KAAQ;;QAGzDA;IAFb,MAAMC,OAAO,aAAKD;IAClB,OAAOC,KAAKC,OAAO;IACnB,MAAMC,gBAAOH,iBAAAA,MAAME,OAAO,qBAAbF,eAAeG,IAAI,CAACC,KAAK,CAAC,GAAGN,4BAAa,EAAE;IACzD,OAAOE,MAAME,OAAO,IAAIC,KAAKE,MAAM,GAAG,aAAKJ;QAAMC,SAAS,aAAKF,MAAME,OAAO;YAAEC;;SAAWF;AAC3F;AAEA,gFAAgF,GAChF,SAASK,OAAOC,IAAuB;IACrC,MAAMC,QAAQD,KAAKC,KAAK,CAACJ,KAAK,CAAC,GAAGT,WAAWc,GAAG,CAACV;IACjD,OAAOQ,KAAKG,MAAM,IAAIF,MAAMH,MAAM,GAAG;QAAEK,QAAQH,KAAKG,MAAM;QAA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n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { StockPhotoSearchRequest } from '@aglyn/aglyn/plugin-manager/stock-photo-provider'\nimport type { AiLayoutPicturePhoto, AiLayoutPictureRole } from '../layout-language/ai-layout-pictures'\n\n/**\n * THE PICTURES A SITE START LEFT ON A STARTER PHOTO (AGL-3988).\n *\n * A guided start's pages and its datasets' records are each built in a pass\n * of their own, minutes apart. A picture the stock library could not fill in\n * its pass took a starter photo there: its picks' downloads refused by the\n * library's image hosts in a burst, or no photo of the job's own to take\n * yet. The v1.0.0-beta.271 Laurel Fork Photography start (2026-10-19 23:05Z)\n * filed all twelve \"Gallery collections\" covers and its home hero under an\n * office team and a desk: pixabay.com's Cloudflare answered 429 to 22\n * downloads while the covers were built, before the job had copied any\n * photo, and to 11 more on the home page, the first page built.\n *\n * Each such picture is written down here, with the picks the hosts refused,\n * on the job, by the machine, in the write that records its pass. The site\n * step's late photo pass (`jobs/ai-site-late-photos.ts`) reads it once every\n * page is built and before the site is published: it asks the refused picks\n * for again, a minute after the refusal, and gives every picture still on a\n * starter one of the photos the job copied. Pure.\n */\n\n/** Where a starter photo is served from: the platform's own files, on every site's origin. */\nexport const AI_SITE_STARTER_PREFIX = '/_static/starter/'\n\n/** Whether an address is a starter photo's. */\nexport function aiSiteIsStarterSrc(src: unknown): boolean {\n return typeof src === 'string' && src.startsWith(AI_SITE_STARTER_PREFIX)\n}\n\n/** The picks a slot kept in hand whose downloads the library's image hosts refused, to ask for again. */\nexport interface AiStockRefusedPicks {\n /** The search they came from, as it was sent: asked again, the provider's cache answers it. */\n request: StockPhotoSearchRequest\n /** The picks' source keys (`pixabay:5401602`), best first. */\n keys: string[]\n /** When the last of them was refused, ISO. */\n at: string\n}\n\n/** A picture of one of the start's pages that holds a starter photo. */\nexport interface AiSiteStarterSlot {\n /** The `image` node. */\n image: string\n /** What the picture was to show, in the slot's own words: a starter's alt text is the starter's. */\n words: string\n role: AiLayoutPictureRole\n /** The frame's shape, width over height. */\n aspect: number\n refused?: AiStockRefusedPicks\n}\n\n/** A page of the start with the pictures it left on a starter. */\nexport interface AiSiteStarterPage {\n /** The page's draft. */\n screen: string\n slots: AiSiteStarterSlot[]\n}\n\n/** A record of a pictured list, as its photo was written. */\nexport interface AiSiteListRecord {\n /** The record's name: its first field's value. */\n name: string\n /** What the list files it under, where it files its records (AGL-3856). */\n category?: string\n /** The value its photo field holds: a starter's path, or the library photo's CDN path. */\n value: string\n /** The library photo it shows, with its size and words; absent on a starter. */\n photo?: AiLayoutPicturePhoto\n refused?: AiStockRefusedPicks\n /** A record of a thing of its own (AGL-4092): its own photo or its starter, never another record's or the job's. */\n itsOwn?: true\n}\n\n/** A pictured list of the start, one of whose records holds a starter photo. */\nexport interface AiSiteStarterList {\n /** The dataset. */\n dataset: string\n /** Its photo field, by id. */\n imageField: string\n /** The field its records keep what their photo shows in, by id (AGL-3856). */\n altField?: string\n /** A list of the business's people: a record of it never takes a photo of anything but a person. */\n people?: boolean\n /** Every record, in order, so a record's neighbors are known. */\n records: AiSiteListRecord[]\n}\n\n/** What a site job holds on its pictures that took a starter, until its late photo pass. */\nexport interface AiSitePhotos {\n pages: AiSiteStarterPage[]\n lists: AiSiteStarterList[]\n /**\n * The late photo passes that ran out of time and handed this back (AGL-3988).\n * The site step publishes on the last pass its bound gives them, whatever\n * the pictures hold then, so a burst that never clears never holds a site\n * back.\n */\n latePasses?: number\n}\n\n/** The most of each a job keeps: a site's pages, each one's pictures, and its lists' records. */\nconst PAGES_MAX = 12\nconst SLOTS_MAX = 16\nconst LISTS_MAX = 8\nconst RECORDS_MAX = 24\nconst KEYS_MAX = 3\n\n/** An entry with its refused picks bounded, and none where it has none. */\nfunction withPicks<T extends { refused?: AiStockRefusedPicks }>(entry: T): T {\n const copy = { ...entry }\n delete copy.refused\n const keys = entry.refused?.keys.slice(0, KEYS_MAX) ?? []\n return entry.refused && keys.length ? { ...copy, refused: { ...entry.refused, keys } } : copy\n}\n\n/** A page's starters as a job keeps them: bounded, and none without a picture. */\nfunction pageOf(page: AiSiteStarterPage): AiSiteStarterPage | null {\n const slots = page.slots.slice(0, SLOTS_MAX).map(withPicks)\n return page.screen && slots.length ? { screen: page.screen, slots } : null\n}\n\n/** Whether a list still holds a starter on any record. */\nfunction listHoldsStarters(list: AiSiteStarterList): boolean {\n return list.records.some((record) => aiSiteIsStarterSrc(record.value))\n}\n\n/**\n * The job's photos state once a unit reported its own (AGL-3988): a page's\n * or a list's entry replaces the one it had, by its draft or its dataset;\n * every other entry stays. `null` where neither holds anything.\n */\nexport function aiSiteMergePhotos(\n previous: AiSitePhotos | null | undefined,\n next: Partial<AiSitePhotos> | null | undefined,\n): AiSitePhotos | null {\n const pages = new Map((previous?.pages ?? []).map((page) => [page.screen, page]))\n for (const page of next?.pages ?? []) {\n const kept = pageOf(page)\n if (kept) pages.set(kept.screen, kept)\n else pages.delete(page.screen)\n }\n const lists = new Map((previous?.lists ?? []).map((list) => [list.dataset, list]))\n for (const list of next?.lists ?? []) {\n if (list.dataset && list.imageField && listHoldsStarters(list)) {\n lists.set(list.dataset, { ...list, records: list.records.slice(0, RECORDS_MAX).map(withPicks) })\n } else lists.delete(list.dataset)\n }\n const merged: AiSitePhotos = { pages: [...pages.values()].slice(0, PAGES_MAX), lists: [...lists.values()].slice(0, LISTS_MAX) }\n const latePasses = next?.latePasses ?? previous?.latePasses\n if (latePasses) merged.latePasses = latePasses\n return merged.pages.length || merged.lists.length ? merged : null\n}\n\n/**\n * Whether a site job owes its late photo pass: a page picture or a list\n * record it left on a starter. With `pageIds`, only a picture of one of\n * those pages counts: a page that was not built is never published.\n */\nexport function aiSitePhotosOwed(photos: AiSitePhotos | null | undefined, pageIds?: readonly string[]): boolean {\n const built = pageIds ? new Set(pageIds) : null\n return Boolean(\n photos?.pages.some((page) => page.slots.length && (!built || built.has(page.screen))) || photos?.lists.some(listHoldsStarters),\n )\n}\n\n/** When the newest refusal the state holds was made, in ms; `null` where none was. */\nexport function aiSitePhotosLastRefusalMs(photos: AiSitePhotos | null | undefined): number | null {\n const times = [\n ...(photos?.pages ?? []).flatMap((page) => page.slots.map((slot) => slot.refused?.at)),\n ...(photos?.lists ?? []).flatMap((list) => list.records.map((record) => record.refused?.at)),\n ]\n .map((at) => (at ? Date.parse(at) : NaN))\n .filter((ms) => Number.isFinite(ms))\n return times.length ? Math.max(...times) : null\n}\n"],"names":["AI_SITE_STARTER_PREFIX","aiSiteIsStarterSrc","src","startsWith","PAGES_MAX","SLOTS_MAX","LISTS_MAX","RECORDS_MAX","KEYS_MAX","withPicks","entry","copy","refused","keys","slice","length","pageOf","page","slots","map","screen","listHoldsStarters","list","records","some","record","value","aiSiteMergePhotos","previous","next","pages","Map","kept","set","delete","lists","dataset","imageField","merged","values","latePasses","aiSitePhotosOwed","photos","pageIds","built","Set","Boolean","has","aiSitePhotosLastRefusalMs","times","flatMap","slot","at","Date","parse","NaN","filter","ms","Number","isFinite","Math","max"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAKD;;;;;;;;;;;;;;;;;;;CAmBC,GAED,4FAA4F,GAC5F,OAAO,MAAMA,yBAAyB,oBAAmB;AAEzD,6CAA6C,GAC7C,OAAO,SAASC,mBAAmBC,GAAY;IAC7C,OAAO,OAAOA,QAAQ,YAAYA,IAAIC,UAAU,CAACH;AACnD;AAyEA,+FAA+F,GAC/F,MAAMI,YAAY;AAClB,MAAMC,YAAY;AAClB,MAAMC,YAAY;AAClB,MAAMC,cAAc;AACpB,MAAMC,WAAW;AAEjB,yEAAyE,GACzE,SAASC,UAAuDC,KAAQ;;QAGzDA;IAFb,MAAMC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ACV,0BAAAA,OAAQP,KAAK,oBAAI,EAAE,EAAEe,OAAO,CAAC,CAAC5B,OAASA,KAAKC,OAAO,CAACJ,GAAG,CAAC,CAACM;oBAAWA;wBAAAA,kBAAAA,OAAOb,OAAO,qBAAda,gBAAgB2B,EAAE;;KAC3F,CACEjC,GAAG,CAAC,CAACiC,KAAQA,KAAKC,KAAKC,KAAK,CAACF,MAAMG,KACnCC,MAAM,CAAC,CAACC,KAAOC,OAAOC,QAAQ,CAACF;IAClC,OAAOR,MAAMlC,MAAM,GAAG6C,KAAKC,GAAG,IAAIZ,SAAS;AAC7C"}
|
|
@@ -23,8 +23,9 @@ import { type AiSiteStartAnswers, type AiSiteStartExtraKey } from './ai-site-sta
|
|
|
23
23
|
* Splitting the questions changes nothing they become. Every step writes the
|
|
24
24
|
* same {@link AiSiteStartAnswers} the single form did, and only the review's
|
|
25
25
|
* "Plan my site" turns them into the job's brief and inputs, through the same
|
|
26
|
-
* `aiSiteStartBrief` / `aiSiteStartInputs`.
|
|
27
|
-
*
|
|
26
|
+
* `aiSiteStartBrief` / `aiSiteStartInputs`. Two answers are required: what
|
|
27
|
+
* kind of site it is, and a style card clicked (AGL-4049; "Pick for me" is
|
|
28
|
+
* one), since nothing is chosen for a person.
|
|
28
29
|
*
|
|
29
30
|
* Pure: ids, titles, which answers each step holds, and each step's reasons
|
|
30
31
|
* not to go forward, worded as `aiSiteStartRefusal` words them.
|
|
@@ -35,7 +36,7 @@ export type AiSiteStartStep = (typeof AI_SITE_START_STEPS)[number];
|
|
|
35
36
|
/** Each step's short name, as the progress indicator shows it. */
|
|
36
37
|
export declare const AI_SITE_START_STEP_LABELS: Readonly<Record<AiSiteStartStep, string>>;
|
|
37
38
|
/** An answer a step asks for, by its key on {@link AiSiteStartAnswers}. */
|
|
38
|
-
export type AiSiteStartField = 'siteType' | 'audience' | 'kind' | 'inspiration' | 'pages' | 'submissions' | 'welcomeEmail' | AiSiteStartExtraKey;
|
|
39
|
+
export type AiSiteStartField = 'siteType' | 'audience' | 'style' | 'kind' | 'inspiration' | 'pages' | 'submissions' | 'welcomeEmail' | AiSiteStartExtraKey;
|
|
39
40
|
/**
|
|
40
41
|
* The extras each step's "More details" offers (AGL-3979), in the order it
|
|
41
42
|
* draws them. The phone number and the email are on the Details step itself,
|
|
@@ -15,7 +15,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/ import { AI_SITE_INPUT_MAX_CHARS, AI_SITE_SUBMISSIONS, aiSitePagesBand } from "./ai-site-job.js";
|
|
18
|
-
import { aiSiteStartExtraProblem, aiSiteStartInspirationRefusal } from "./ai-site-start.js";
|
|
18
|
+
import { AI_SITE_START_STYLE_REQUIRED, aiSiteStartExtraProblem, aiSiteStartInspirationRefusal } from "./ai-site-start.js";
|
|
19
19
|
/**
|
|
20
20
|
* The guided start's steps (AGL-3898): the same questions `ai-site-start.ts`
|
|
21
21
|
* asks, one decision to a step, so a person answers one thing at a time and
|
|
@@ -24,8 +24,9 @@ import { aiSiteStartExtraProblem, aiSiteStartInspirationRefusal } from "./ai-sit
|
|
|
24
24
|
* Splitting the questions changes nothing they become. Every step writes the
|
|
25
25
|
* same {@link AiSiteStartAnswers} the single form did, and only the review's
|
|
26
26
|
* "Plan my site" turns them into the job's brief and inputs, through the same
|
|
27
|
-
* `aiSiteStartBrief` / `aiSiteStartInputs`.
|
|
28
|
-
*
|
|
27
|
+
* `aiSiteStartBrief` / `aiSiteStartInputs`. Two answers are required: what
|
|
28
|
+
* kind of site it is, and a style card clicked (AGL-4049; "Pick for me" is
|
|
29
|
+
* one), since nothing is chosen for a person.
|
|
29
30
|
*
|
|
30
31
|
* Pure: ids, titles, which answers each step holds, and each step's reasons
|
|
31
32
|
* not to go forward, worded as `aiSiteStartRefusal` words them.
|
|
@@ -86,6 +87,7 @@ import { aiSiteStartExtraProblem, aiSiteStartInspirationRefusal } from "./ai-sit
|
|
|
86
87
|
],
|
|
87
88
|
// The sites they like sit under the style cards (AGL-3975), when asked.
|
|
88
89
|
style: [
|
|
90
|
+
'style',
|
|
89
91
|
'kind',
|
|
90
92
|
'inspiration',
|
|
91
93
|
...AI_SITE_START_MORE_FIELDS.style
|
|
@@ -131,6 +133,11 @@ import { aiSiteStartExtraProblem, aiSiteStartInspirationRefusal } from "./ai-sit
|
|
|
131
133
|
code: 'too_long'
|
|
132
134
|
};
|
|
133
135
|
}
|
|
136
|
+
// Nothing is chosen for a person (AGL-4049): a card, "Pick for me" included.
|
|
137
|
+
if (answers.style === null) errors.style = {
|
|
138
|
+
message: AI_SITE_START_STYLE_REQUIRED,
|
|
139
|
+
code: 'required'
|
|
140
|
+
};
|
|
134
141
|
const band = aiSitePagesBand(options.freeTaste);
|
|
135
142
|
if (!Number.isInteger(answers.pages) || answers.pages < band.min || answers.pages > band.max) {
|
|
136
143
|
errors.pages = {
|
|
@@ -161,6 +168,7 @@ import { aiSiteStartExtraProblem, aiSiteStartInspirationRefusal } from "./ai-sit
|
|
|
161
168
|
const CORE_FIELDS = new Set([
|
|
162
169
|
'siteType',
|
|
163
170
|
'audience',
|
|
171
|
+
'style',
|
|
164
172
|
'kind',
|
|
165
173
|
'inspiration',
|
|
166
174
|
'pages',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-site-start-steps.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 { AI_SITE_INPUT_MAX_CHARS, AI_SITE_SUBMISSIONS, aiSitePagesBand } from './ai-site-job'\nimport {\n aiSiteStartExtraProblem,\n aiSiteStartInspirationRefusal,\n type AiSiteStartAnswers,\n type AiSiteStartExtraKey,\n} from './ai-site-start'\n\n/**\n * The guided start's steps (AGL-3898): the same questions `ai-site-start.ts`\n * asks, one decision to a step, so a person answers one thing at a time and\n * the funnel can say which one they stopped at.\n *\n * Splitting the questions changes nothing they become. Every step writes the\n * same {@link AiSiteStartAnswers} the single form did, and only the review's\n * \"Plan my site\" turns them into the job's brief and inputs, through the same\n * `aiSiteStartBrief` / `aiSiteStartInputs`. Which answers are required is\n * unchanged too: only what kind of site it is.\n *\n * Pure: ids, titles, which answers each step holds, and each step's reasons\n * not to go forward, worded as `aiSiteStartRefusal` words them.\n */\n\n/** A step of the guided start, in order. `choose` is the starter-or-AI choice the questions follow. */\nexport const AI_SITE_START_STEPS = ['choose', 'kind', 'audience', 'style', 'details', 'review'] as const\n\nexport type AiSiteStartStep = (typeof AI_SITE_START_STEPS)[number]\n\n/** Each step's short name, as the progress indicator shows it. */\nexport const AI_SITE_START_STEP_LABELS: Readonly<Record<AiSiteStartStep, string>> = {\n choose: 'Start',\n kind: 'Your site',\n audience: 'Audience',\n style: 'Style',\n details: 'Details',\n review: 'Review',\n}\n\n/** An answer a step asks for, by its key on {@link AiSiteStartAnswers}. */\nexport type AiSiteStartField =\n | 'siteType'\n | 'audience'\n | 'kind'\n | 'inspiration'\n | 'pages'\n | 'submissions'\n | 'welcomeEmail'\n | AiSiteStartExtraKey\n\n/**\n * The extras each step's \"More details\" offers (AGL-3979), in the order it\n * draws them. The phone number and the email are on the Details step itself,\n * above where messages go: they are the two a new site most needs.\n */\nexport const AI_SITE_START_MORE_FIELDS: Readonly<Record<AiSiteStartStep, readonly AiSiteStartExtraKey[]>> = {\n choose: [],\n kind: ['tagline', 'founded'],\n audience: ['serviceArea', 'priceRange', 'languages'],\n style: ['brand'],\n details: ['street', 'city', 'region', 'postalCode', 'country', 'hours', 'social'],\n review: [],\n}\n\n/** The answers each step holds, its \"More details\" last. */\nexport const AI_SITE_START_STEP_FIELDS: Readonly<Record<AiSiteStartStep, readonly AiSiteStartField[]>> = {\n choose: [],\n kind: ['siteType', ...AI_SITE_START_MORE_FIELDS.kind],\n audience: ['audience', ...AI_SITE_START_MORE_FIELDS.audience],\n // The sites they like sit under the style cards (AGL-3975), when asked.\n style: ['kind', 'inspiration', ...AI_SITE_START_MORE_FIELDS.style],\n details: ['phone', 'email', 'submissions', 'pages', 'welcomeEmail', ...AI_SITE_START_MORE_FIELDS.details],\n review: [],\n}\n\n/** Why an answer cannot go forward, as a closed code the funnel can count. */\nexport type AiSiteStartErrorCode = 'required' | 'too_long' | 'out_of_range' | 'invalid'\n\n/** One answer's reason not to go forward: the sentence beside the field, and its code. */\nexport interface AiSiteStartFieldError {\n message: string\n code: AiSiteStartErrorCode\n}\n\n/** The step's place, from 0. */\nexport function aiSiteStartStepIndex(step: AiSiteStartStep): number {\n return AI_SITE_START_STEPS.indexOf(step)\n}\n\n/** The step after this one, or `null` after the review. */\nexport function aiSiteStartNextStep(step: AiSiteStartStep): AiSiteStartStep | null {\n return AI_SITE_START_STEPS[aiSiteStartStepIndex(step) + 1] ?? null\n}\n\n/** The step before this one, or `null` before the choice. */\nexport function aiSiteStartPreviousStep(step: AiSiteStartStep): AiSiteStartStep | null {\n const index = aiSiteStartStepIndex(step)\n return index > 0 ? (AI_SITE_START_STEPS[index - 1] ?? null) : null\n}\n\n/** Every answer's reason not to go forward, by field, with nothing for an answer that may. */\nexport function aiSiteStartFieldErrors(\n answers: AiSiteStartAnswers,\n options: { freeTaste?: boolean } = {},\n): Partial<Record<AiSiteStartField, AiSiteStartFieldError>> {\n const errors: Partial<Record<AiSiteStartField, AiSiteStartFieldError>> = {}\n const siteType = answers.siteType.trim()\n if (!siteType) errors.siteType = { message: 'Say what kind of site this is.', code: 'required' }\n else if (siteType.length > AI_SITE_INPUT_MAX_CHARS) {\n errors.siteType = { message: `Keep what kind of site this is under ${AI_SITE_INPUT_MAX_CHARS} characters.`, code: 'too_long' }\n }\n if (answers.audience.trim().length > AI_SITE_INPUT_MAX_CHARS) {\n errors.audience = { message: `Keep who the site is for under ${AI_SITE_INPUT_MAX_CHARS} characters.`, code: 'too_long' }\n }\n const band = aiSitePagesBand(options.freeTaste)\n if (!Number.isInteger(answers.pages) || answers.pages < band.min || answers.pages > band.max) {\n errors.pages = { message: `A site is planned with ${band.min} to ${band.max} pages.`, code: 'out_of_range' }\n }\n if (!(AI_SITE_SUBMISSIONS as readonly string[]).includes(answers.submissions)) {\n errors.submissions = { message: 'Say where the contact form’s submissions go.', code: 'invalid' }\n }\n const inspiration = aiSiteStartInspirationRefusal(answers, options)\n if (inspiration) errors.inspiration = { message: inspiration, code: 'invalid' }\n // Every extra is optional; one given is held to its own rule (AGL-3979).\n for (const field of Object.values(AI_SITE_START_STEP_FIELDS).flat()) {\n if (field in errors) continue\n const problem = isExtra(field) ? aiSiteStartExtraProblem(field, answers[field] ?? '') : null\n if (problem) errors[field] = problem\n }\n return errors\n}\n\nconst CORE_FIELDS: ReadonlySet<AiSiteStartField> = new Set([\n 'siteType',\n 'audience',\n 'kind',\n 'inspiration',\n 'pages',\n 'submissions',\n 'welcomeEmail',\n])\n\nfunction isExtra(field: AiSiteStartField): field is AiSiteStartExtraKey {\n return !CORE_FIELDS.has(field)\n}\n\n/** One step's reasons not to go forward, in the order its fields are drawn; empty when it may. */\nexport function aiSiteStartStepErrors(\n step: AiSiteStartStep,\n answers: AiSiteStartAnswers,\n options: { freeTaste?: boolean } = {},\n): Array<{ field: AiSiteStartField } & AiSiteStartFieldError> {\n const errors = aiSiteStartFieldErrors(answers, options)\n return AI_SITE_START_STEP_FIELDS[step].flatMap((field) => {\n const error = errors[field]\n return error ? [{ field, ...error }] : []\n })\n}\n\n/** The first step holding an answer that cannot go forward, for a review that was reached with one; `null` for none. */\nexport function aiSiteStartFirstInvalidStep(\n answers: AiSiteStartAnswers,\n options: { freeTaste?: boolean } = {},\n): AiSiteStartStep | null {\n return AI_SITE_START_STEPS.find((step) => aiSiteStartStepErrors(step, answers, options).length > 0) ?? null\n}\n"],"names":["AI_SITE_INPUT_MAX_CHARS","AI_SITE_SUBMISSIONS","aiSitePagesBand","aiSiteStartExtraProblem","aiSiteStartInspirationRefusal","AI_SITE_START_STEPS","AI_SITE_START_STEP_LABELS","choose","kind","audience","style","details","review","AI_SITE_START_MORE_FIELDS","AI_SITE_START_STEP_FIELDS","aiSiteStartStepIndex","step","indexOf","aiSiteStartNextStep","aiSiteStartPreviousStep","index","aiSiteStartFieldErrors","answers","options","errors","siteType","trim","message","code","length","band","freeTaste","Number","isInteger","pages","min","max","includes","submissions","inspiration","field","Object","values","flat","problem","isExtra","CORE_FIELDS","Set","has","aiSiteStartStepErrors","flatMap","error","aiSiteStartFirstInvalidStep","find"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,uBAAuB,EAAEC,mBAAmB,EAAEC,eAAe,QAAQ,mBAAe;AAC7F,SACEC,uBAAuB,EACvBC,6BAA6B,QAGxB,qBAAiB;AAExB;;;;;;;;;;;;;CAaC,GAED,qGAAqG,GACrG,OAAO,MAAMC,sBAAsB;IAAC;IAAU;IAAQ;IAAY;IAAS;IAAW;CAAS,CAAS;AAIxG,gEAAgE,GAChE,OAAO,MAAMC,4BAAuE;IAClFC,QAAQ;IACRC,MAAM;IACNC,UAAU;IACVC,OAAO;IACPC,SAAS;IACTC,QAAQ;AACV,EAAC;AAaD;;;;CAIC,GACD,OAAO,MAAMC,4BAA+F;IAC1GN,QAAQ,EAAE;IACVC,MAAM;QAAC;QAAW;KAAU;IAC5BC,UAAU;QAAC;QAAe;QAAc;KAAY;IACpDC,OAAO;QAAC;KAAQ;IAChBC,SAAS;QAAC;QAAU;QAAQ;QAAU;QAAc;QAAW;QAAS;KAAS;IACjFC,QAAQ,EAAE;AACZ,EAAC;AAED,0DAA0D,GAC1D,OAAO,MAAME,4BAA4F;IACvGP,QAAQ,EAAE;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C,OAAO,CAAC,CAACV;QAC9C,MAAMW,QAAQ3B,MAAM,CAACgB,MAAM;QAC3B,OAAOW,QAAQ;YAAC;gBAAEX;eAAUW;SAAQ,GAAG,EAAE;IAC3C;AACF;AAEA,sHAAsH,GACtH,OAAO,SAASC,4BACd9B,OAA2B,EAC3BC,UAAmC,CAAC,CAAC;QAE9BlB;IAAP,QAAOA,4BAAAA,oBAAoBgD,IAAI,CAAC,CAACrC,OAASiC,sBAAsBjC,MAAMM,SAASC,SAASM,MAAM,GAAG,cAA1FxB,4BAAgG;AACzG"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-site-start-steps.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 { AI_SITE_INPUT_MAX_CHARS, AI_SITE_SUBMISSIONS, aiSitePagesBand } from './ai-site-job'\nimport {\n AI_SITE_START_STYLE_REQUIRED,\n aiSiteStartExtraProblem,\n aiSiteStartInspirationRefusal,\n type AiSiteStartAnswers,\n type AiSiteStartExtraKey,\n} from './ai-site-start'\n\n/**\n * The guided start's steps (AGL-3898): the same questions `ai-site-start.ts`\n * asks, one decision to a step, so a person answers one thing at a time and\n * the funnel can say which one they stopped at.\n *\n * Splitting the questions changes nothing they become. Every step writes the\n * same {@link AiSiteStartAnswers} the single form did, and only the review's\n * \"Plan my site\" turns them into the job's brief and inputs, through the same\n * `aiSiteStartBrief` / `aiSiteStartInputs`. Two answers are required: what\n * kind of site it is, and a style card clicked (AGL-4049; \"Pick for me\" is\n * one), since nothing is chosen for a person.\n *\n * Pure: ids, titles, which answers each step holds, and each step's reasons\n * not to go forward, worded as `aiSiteStartRefusal` words them.\n */\n\n/** A step of the guided start, in order. `choose` is the starter-or-AI choice the questions follow. */\nexport const AI_SITE_START_STEPS = ['choose', 'kind', 'audience', 'style', 'details', 'review'] as const\n\nexport type AiSiteStartStep = (typeof AI_SITE_START_STEPS)[number]\n\n/** Each step's short name, as the progress indicator shows it. */\nexport const AI_SITE_START_STEP_LABELS: Readonly<Record<AiSiteStartStep, string>> = {\n choose: 'Start',\n kind: 'Your site',\n audience: 'Audience',\n style: 'Style',\n details: 'Details',\n review: 'Review',\n}\n\n/** An answer a step asks for, by its key on {@link AiSiteStartAnswers}. */\nexport type AiSiteStartField =\n | 'siteType'\n | 'audience'\n | 'style'\n | 'kind'\n | 'inspiration'\n | 'pages'\n | 'submissions'\n | 'welcomeEmail'\n | AiSiteStartExtraKey\n\n/**\n * The extras each step's \"More details\" offers (AGL-3979), in the order it\n * draws them. The phone number and the email are on the Details step itself,\n * above where messages go: they are the two a new site most needs.\n */\nexport const AI_SITE_START_MORE_FIELDS: Readonly<Record<AiSiteStartStep, readonly AiSiteStartExtraKey[]>> = {\n choose: [],\n kind: ['tagline', 'founded'],\n audience: ['serviceArea', 'priceRange', 'languages'],\n style: ['brand'],\n details: ['street', 'city', 'region', 'postalCode', 'country', 'hours', 'social'],\n review: [],\n}\n\n/** The answers each step holds, its \"More details\" last. */\nexport const AI_SITE_START_STEP_FIELDS: Readonly<Record<AiSiteStartStep, readonly AiSiteStartField[]>> = {\n choose: [],\n kind: ['siteType', ...AI_SITE_START_MORE_FIELDS.kind],\n audience: ['audience', ...AI_SITE_START_MORE_FIELDS.audience],\n // The sites they like sit under the style cards (AGL-3975), when asked.\n style: ['style', 'kind', 'inspiration', ...AI_SITE_START_MORE_FIELDS.style],\n details: ['phone', 'email', 'submissions', 'pages', 'welcomeEmail', ...AI_SITE_START_MORE_FIELDS.details],\n review: [],\n}\n\n/** Why an answer cannot go forward, as a closed code the funnel can count. */\nexport type AiSiteStartErrorCode = 'required' | 'too_long' | 'out_of_range' | 'invalid'\n\n/** One answer's reason not to go forward: the sentence beside the field, and its code. */\nexport interface AiSiteStartFieldError {\n message: string\n code: AiSiteStartErrorCode\n}\n\n/** The step's place, from 0. */\nexport function aiSiteStartStepIndex(step: AiSiteStartStep): number {\n return AI_SITE_START_STEPS.indexOf(step)\n}\n\n/** The step after this one, or `null` after the review. */\nexport function aiSiteStartNextStep(step: AiSiteStartStep): AiSiteStartStep | null {\n return AI_SITE_START_STEPS[aiSiteStartStepIndex(step) + 1] ?? null\n}\n\n/** The step before this one, or `null` before the choice. */\nexport function aiSiteStartPreviousStep(step: AiSiteStartStep): AiSiteStartStep | null {\n const index = aiSiteStartStepIndex(step)\n return index > 0 ? (AI_SITE_START_STEPS[index - 1] ?? null) : null\n}\n\n/** Every answer's reason not to go forward, by field, with nothing for an answer that may. */\nexport function aiSiteStartFieldErrors(\n answers: AiSiteStartAnswers,\n options: { freeTaste?: boolean } = {},\n): Partial<Record<AiSiteStartField, AiSiteStartFieldError>> {\n const errors: Partial<Record<AiSiteStartField, AiSiteStartFieldError>> = {}\n const siteType = answers.siteType.trim()\n if (!siteType) errors.siteType = { message: 'Say what kind of site this is.', code: 'required' }\n else if (siteType.length > AI_SITE_INPUT_MAX_CHARS) {\n errors.siteType = { message: `Keep what kind of site this is under ${AI_SITE_INPUT_MAX_CHARS} characters.`, code: 'too_long' }\n }\n if (answers.audience.trim().length > AI_SITE_INPUT_MAX_CHARS) {\n errors.audience = { message: `Keep who the site is for under ${AI_SITE_INPUT_MAX_CHARS} characters.`, code: 'too_long' }\n }\n // Nothing is chosen for a person (AGL-4049): a card, \"Pick for me\" included.\n if (answers.style === null) errors.style = { message: AI_SITE_START_STYLE_REQUIRED, code: 'required' }\n const band = aiSitePagesBand(options.freeTaste)\n if (!Number.isInteger(answers.pages) || answers.pages < band.min || answers.pages > band.max) {\n errors.pages = { message: `A site is planned with ${band.min} to ${band.max} pages.`, code: 'out_of_range' }\n }\n if (!(AI_SITE_SUBMISSIONS as readonly string[]).includes(answers.submissions)) {\n errors.submissions = { message: 'Say where the contact form’s submissions go.', code: 'invalid' }\n }\n const inspiration = aiSiteStartInspirationRefusal(answers, options)\n if (inspiration) errors.inspiration = { message: inspiration, code: 'invalid' }\n // Every extra is optional; one given is held to its own rule (AGL-3979).\n for (const field of Object.values(AI_SITE_START_STEP_FIELDS).flat()) {\n if (field in errors) continue\n const problem = isExtra(field) ? aiSiteStartExtraProblem(field, answers[field] ?? '') : null\n if (problem) errors[field] = problem\n }\n return errors\n}\n\nconst CORE_FIELDS: ReadonlySet<AiSiteStartField> = new Set([\n 'siteType',\n 'audience',\n 'style',\n 'kind',\n 'inspiration',\n 'pages',\n 'submissions',\n 'welcomeEmail',\n])\n\nfunction isExtra(field: AiSiteStartField): field is AiSiteStartExtraKey {\n return !CORE_FIELDS.has(field)\n}\n\n/** One step's reasons not to go forward, in the order its fields are drawn; empty when it may. */\nexport function aiSiteStartStepErrors(\n step: AiSiteStartStep,\n answers: AiSiteStartAnswers,\n options: { freeTaste?: boolean } = {},\n): Array<{ field: AiSiteStartField } & AiSiteStartFieldError> {\n const errors = aiSiteStartFieldErrors(answers, options)\n return AI_SITE_START_STEP_FIELDS[step].flatMap((field) => {\n const error = errors[field]\n return error ? [{ field, ...error }] : []\n })\n}\n\n/** The first step holding an answer that cannot go forward, for a review that was reached with one; `null` for none. */\nexport function aiSiteStartFirstInvalidStep(\n answers: AiSiteStartAnswers,\n options: { freeTaste?: boolean } = {},\n): AiSiteStartStep | null {\n return AI_SITE_START_STEPS.find((step) => aiSiteStartStepErrors(step, answers, options).length > 0) ?? null\n}\n"],"names":["AI_SITE_INPUT_MAX_CHARS","AI_SITE_SUBMISSIONS","aiSitePagesBand","AI_SITE_START_STYLE_REQUIRED","aiSiteStartExtraProblem","aiSiteStartInspirationRefusal","AI_SITE_START_STEPS","AI_SITE_START_STEP_LABELS","choose","kind","audience","style","details","review","AI_SITE_START_MORE_FIELDS","AI_SITE_START_STEP_FIELDS","aiSiteStartStepIndex","step","indexOf","aiSiteStartNextStep","aiSiteStartPreviousStep","index","aiSiteStartFieldErrors","answers","options","errors","siteType","trim","message","code","length","band","freeTaste","Number","isInteger","pages","min","max","includes","submissions","inspiration","field","Object","values","flat","problem","isExtra","CORE_FIELDS","Set","has","aiSiteStartStepErrors","flatMap","error","aiSiteStartFirstInvalidStep","find"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,uBAAuB,EAAEC,mBAAmB,EAAEC,eAAe,QAAQ,mBAAe;AAC7F,SACEC,4BAA4B,EAC5BC,uBAAuB,EACvBC,6BAA6B,QAGxB,qBAAiB;AAExB;;;;;;;;;;;;;;CAcC,GAED,qGAAqG,GACrG,OAAO,MAAMC,sBAAsB;IAAC;IAAU;IAAQ;IAAY;IAAS;IAAW;CAAS,CAAS;AAIxG,gEAAgE,GAChE,OAAO,MAAMC,4BAAuE;IAClFC,QAAQ;IACRC,MAAM;IACNC,UAAU;IACVC,OAAO;IACPC,SAAS;IACTC,QAAQ;AACV,EAAC;AAcD;;;;CAIC,GACD,OAAO,MAAMC,4BAA+F;IAC1GN,QAAQ,EAAE;IACVC,MAAM;QAAC;QAAW;KAAU;IAC5BC,UAAU;QAAC;QAAe;QAAc;KAAY;IACpDC,OAAO;QAAC;KAAQ;IAChBC,SAAS;QAAC;QAAU;QAAQ;QAAU;QAAc;QAAW;QAAS;KAAS;IACjFC,QAAQ,EAAE;AACZ,EAAC;AAED,0DAA0D,GAC1D,OAAO,MAAME,4BAA4F;IACvGP,QAAQ,EAAE;IACVC,MAAM;QAAC;WAAeK,0BAA0BL,IAAI;KAAC;IACrDC,UAAU;QAAC;WAAeI,0BAA0BJ,QAAQ;KAAC;IAC7D,wEAAwE;IACxEC,OAAO;QAAC;QAAS;QAAQ;WAAkBG,0BAA0BH,KAAK;KAAC;IAC3EC,SAAS;QAAC;QAAS;QAAS;QAAe;QAAS;WAAmBE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AUW;SAAQ,GAAG,EAAE;IAC3C;AACF;AAEA,sHAAsH,GACtH,OAAO,SAASC,4BACd9B,OAA2B,EAC3BC,UAAmC,CAAC,CAAC;QAE9BlB;IAAP,QAAOA,4BAAAA,oBAAoBgD,IAAI,CAAC,CAACrC,OAASiC,sBAAsBjC,MAAMM,SAASC,SAASM,MAAM,GAAG,cAA1FxB,4BAAgG;AACzG"}
|
|
@@ -89,10 +89,17 @@ export interface AiSiteStartAnswers extends AiSiteDetails {
|
|
|
89
89
|
audience: string;
|
|
90
90
|
/** The example they liked, by {@link AiSiteStartExample.id}; `null` for none. */
|
|
91
91
|
example: string | null;
|
|
92
|
+
/**
|
|
93
|
+
* The style card they clicked (AGL-4049): a kind's id, or
|
|
94
|
+
* `SITE_STYLE_AUTO` for "Pick for me"; `null` while they have clicked none.
|
|
95
|
+
* Nothing is chosen for a person, so the Style step does not go forward on
|
|
96
|
+
* `null` ({@link aiSiteStartStyleAnswer} sets this and {@link kind} together).
|
|
97
|
+
*/
|
|
98
|
+
style: string | null;
|
|
92
99
|
/**
|
|
93
100
|
* The kind of site they picked (AGL-3660), by its `AI_SITE_KINDS` id;
|
|
94
|
-
* `null`
|
|
95
|
-
* the one used ({@link aiSiteStartKind}).
|
|
101
|
+
* `null` for "Pick for me", or before a style is chosen, when the kind
|
|
102
|
+
* their first answer suggests is the one used ({@link aiSiteStartKind}).
|
|
96
103
|
*/
|
|
97
104
|
kind: string | null;
|
|
98
105
|
/** How many pages to plan. */
|
|
@@ -119,6 +126,14 @@ export interface AiSiteStartAnswers extends AiSiteDetails {
|
|
|
119
126
|
* thing a person should have to choose.
|
|
120
127
|
*/
|
|
121
128
|
export declare const AI_SITE_START_ANSWERS: AiSiteStartAnswers;
|
|
129
|
+
/**
|
|
130
|
+
* Why the Style step does not go forward before a card is clicked (AGL-4049),
|
|
131
|
+
* and why the review does not plan: nothing is chosen for a person, and
|
|
132
|
+
* "Pick for me" is a card too. The door itself admits a start without one
|
|
133
|
+
* ({@link aiSiteStartRefusal} is what it would refuse), so this is the
|
|
134
|
+
* questions' rule, held by `aiSiteStartStepErrors` and the card.
|
|
135
|
+
*/
|
|
136
|
+
export declare const AI_SITE_START_STYLE_REQUIRED = "Choose a style, or Pick for me.";
|
|
122
137
|
/** The answers a person may give beyond the ones each step asks, by key (AGL-3979). */
|
|
123
138
|
export type AiSiteStartExtraKey = AiSiteDetailKey | 'city' | 'brand';
|
|
124
139
|
/** Every extra, in the order the review lists them. */
|
|
@@ -130,6 +145,12 @@ export declare function aiSiteStartExtraProblem(key: AiSiteStartExtraKey, value:
|
|
|
130
145
|
} | null;
|
|
131
146
|
/** The extras a person gave, in the review's order: what "More details" was used for. */
|
|
132
147
|
export declare function aiSiteStartExtrasGiven(answers: AiSiteStartAnswers): AiSiteStartExtraKey[];
|
|
148
|
+
/**
|
|
149
|
+
* A style card clicked (AGL-4049), as the answers hold it: the card's id as
|
|
150
|
+
* the style, and the kind it names — none for "Pick for me", which leaves the
|
|
151
|
+
* kind to what the site is and who it is for.
|
|
152
|
+
*/
|
|
153
|
+
export declare function aiSiteStartStyleAnswer(id: string): Pick<AiSiteStartAnswers, 'style' | 'kind'>;
|
|
133
154
|
/** The kind of site the answers pick, else the one what the site is and who it is for suggest. */
|
|
134
155
|
export declare function aiSiteStartKind(answers: Pick<AiSiteStartAnswers, 'kind' | 'siteType'> & Partial<Pick<AiSiteStartAnswers, 'audience'>>): AiSiteKind;
|
|
135
156
|
/** The example an answer names, or `null` when it names none this list knows. */
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
17
|
+
import { SITE_STYLE_AUTO } from "@aglyn/aglyn/app-utils/site-styles";
|
|
17
18
|
import { weeklyHoursFromText, weeklyHoursToText } from "@aglyn/shared-ui-jsx/utils/weekly-hours";
|
|
18
19
|
import { AI_SITE_DETAIL_KEYS, AI_SITE_NO_DETAILS, aiSiteDetailProblem, aiSiteDetailsOf } from "./ai-site-details.js";
|
|
19
20
|
import { aiSiteKind, aiSiteKindFor } from "./ai-site-kinds.js";
|
|
@@ -79,6 +80,7 @@ import { AI_SITE_INPUT_MAX_CHARS, AI_SITE_SUBMISSIONS, aiSitePagesBand } from ".
|
|
|
79
80
|
siteType: '',
|
|
80
81
|
audience: '',
|
|
81
82
|
example: null,
|
|
83
|
+
style: null,
|
|
82
84
|
kind: null,
|
|
83
85
|
pages: 5,
|
|
84
86
|
submissions: 'inbox',
|
|
@@ -86,6 +88,13 @@ import { AI_SITE_INPUT_MAX_CHARS, AI_SITE_SUBMISSIONS, aiSitePagesBand } from ".
|
|
|
86
88
|
city: '',
|
|
87
89
|
brand: ''
|
|
88
90
|
}, AI_SITE_NO_DETAILS);
|
|
91
|
+
/**
|
|
92
|
+
* Why the Style step does not go forward before a card is clicked (AGL-4049),
|
|
93
|
+
* and why the review does not plan: nothing is chosen for a person, and
|
|
94
|
+
* "Pick for me" is a card too. The door itself admits a start without one
|
|
95
|
+
* ({@link aiSiteStartRefusal} is what it would refuse), so this is the
|
|
96
|
+
* questions' rule, held by `aiSiteStartStepErrors` and the card.
|
|
97
|
+
*/ export const AI_SITE_START_STYLE_REQUIRED = 'Choose a style, or Pick for me.';
|
|
89
98
|
/** Every extra, in the order the review lists them. */ export const AI_SITE_START_EXTRA_KEYS = [
|
|
90
99
|
'phone',
|
|
91
100
|
'email',
|
|
@@ -118,6 +127,18 @@ import { AI_SITE_INPUT_MAX_CHARS, AI_SITE_SUBMISSIONS, aiSitePagesBand } from ".
|
|
|
118
127
|
return ((_answers_key = answers[key]) != null ? _answers_key : '').trim() !== '';
|
|
119
128
|
});
|
|
120
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* A style card clicked (AGL-4049), as the answers hold it: the card's id as
|
|
132
|
+
* the style, and the kind it names — none for "Pick for me", which leaves the
|
|
133
|
+
* kind to what the site is and who it is for.
|
|
134
|
+
*/ export function aiSiteStartStyleAnswer(id) {
|
|
135
|
+
var _ref;
|
|
136
|
+
var _aiSiteKind;
|
|
137
|
+
return {
|
|
138
|
+
style: id,
|
|
139
|
+
kind: id === SITE_STYLE_AUTO ? null : (_ref = (_aiSiteKind = aiSiteKind(id)) == null ? void 0 : _aiSiteKind.id) != null ? _ref : null
|
|
140
|
+
};
|
|
141
|
+
}
|
|
121
142
|
/** The kind of site the answers pick, else the one what the site is and who it is for suggest. */ export function aiSiteStartKind(answers) {
|
|
122
143
|
var _aiSiteKind, _answers_audience;
|
|
123
144
|
return (_aiSiteKind = aiSiteKind(answers.kind)) != null ? _aiSiteKind : aiSiteKindFor(answers.siteType, (_answers_audience = answers.audience) != null ? _answers_audience : '');
|
|
@@ -283,8 +304,8 @@ import { AI_SITE_INPUT_MAX_CHARS, AI_SITE_SUBMISSIONS, aiSitePagesBand } from ".
|
|
|
283
304
|
return _extends({
|
|
284
305
|
siteType,
|
|
285
306
|
audience: text('audience'),
|
|
286
|
-
example: AI_SITE_START_EXAMPLES.some((entry)=>entry.id === starter) ? starter : null
|
|
287
|
-
|
|
307
|
+
example: AI_SITE_START_EXAMPLES.some((entry)=>entry.id === starter) ? starter : null
|
|
308
|
+
}, aiSiteStartStyleAnswer((_ref = (_aiSiteKind = aiSiteKind(text('siteKind'))) == null ? void 0 : _aiSiteKind.id) != null ? _ref : SITE_STYLE_AUTO), {
|
|
288
309
|
pages: Math.min(band.max, Math.max(band.min, pages)),
|
|
289
310
|
submissions: AI_SITE_SUBMISSIONS.includes(submissions) ? submissions : AI_SITE_START_ANSWERS.submissions,
|
|
290
311
|
welcomeEmail: options.freeTaste ? false : (inputs == null ? void 0 : inputs['welcomeEmail']) !== false,
|
|
@@ -346,7 +367,8 @@ import { AI_SITE_INPUT_MAX_CHARS, AI_SITE_SUBMISSIONS, aiSitePagesBand } from ".
|
|
|
346
367
|
hours: clientBuildHours(intake.hours)
|
|
347
368
|
});
|
|
348
369
|
return _extends({}, AI_SITE_START_ANSWERS, {
|
|
349
|
-
siteType: bounded(intake.whatTheyDo, AI_SITE_INPUT_MAX_CHARS)
|
|
370
|
+
siteType: bounded(intake.whatTheyDo, AI_SITE_INPUT_MAX_CHARS)
|
|
371
|
+
}, aiSiteStartStyleAnswer(SITE_STYLE_AUTO), {
|
|
350
372
|
phone: details.phone,
|
|
351
373
|
email: details.email,
|
|
352
374
|
serviceArea: details.serviceArea,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-site-start.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ClientBuildIntake } from '@aglyn/aglyn/app-utils/client-build'\nimport { weeklyHoursFromText, weeklyHoursToText } from '@aglyn/shared-ui-jsx/utils/weekly-hours'\nimport {\n AI_SITE_DETAIL_KEYS,\n AI_SITE_NO_DETAILS,\n aiSiteDetailProblem,\n aiSiteDetailsOf,\n type AiSiteDetailKey,\n type AiSiteDetails,\n} from './ai-site-details'\nimport { aiSiteKind, aiSiteKindFor, type AiSiteKind } from './ai-site-kinds'\nimport {\n AI_SITE_INSPIRATION_INPUT,\n aiSiteInspirationInput,\n aiSiteInspirationLimit,\n aiSiteInspirationRefusal,\n aiSiteInspirationUrl,\n} from './ai-site-inspiration'\nimport {\n AI_SITE_INPUT_MAX_CHARS,\n AI_SITE_SUBMISSIONS,\n aiSitePagesBand,\n type AiSiteJobInputs,\n type AiSiteSubmissions,\n} from './ai-site-job'\n\n/**\n * The guided start (AGL-2918): the questions a person answers on a site they\n * have just made, and the site job those answers become.\n *\n * A scaffold already exists — the `site` job plans four to eight pages, a\n * layout, a contact form, a palette and a welcome email, and builds every one\n * of them as a draft. What it had no way in through was a brief: somebody had\n * to know what to write, on a site where nothing has happened yet. So this\n * module is the QUESTIONS, and nothing else: what is asked, what an answer may\n * be, and how a set of answers becomes the brief and the scalar inputs the\n * `site` door already takes.\n *\n * ── Answering is never the way out ───────────────────────────────────────\n *\n * There is no answer here that means \"not this\". The way past the questions\n * is the `hostFirstRun` zone's own `startBlank`, which is drawn beside them\n * from the first one and creates nothing at all — see the zone in\n * `CONSOLE_WIDGET_SLOTS`. Putting the exit inside the question set would make\n * leaving a thing you answer your way to, and it is not.\n *\n * ── Every answer but the first is optional ───────────────────────────────\n *\n * Only what a site is FOR has no default worth guessing. The audience narrows\n * the copy, the example steers the shape, the page count and the welcome\n * email are defaults a person may change — so a person who types six words\n * and confirms gets a planned site, and the rest of the questions are there\n * for the person who wants to answer them.\n *\n * Pure: shapes, vocabularies and two string builders. No React, no network,\n * and no import of the starter catalog — {@link AI_SITE_START_EXAMPLES} names\n * the starters rather than reading them, so the console does not carry a\n * catalog of node maps to draw five cards. `ai-site-start.spec.ts` holds the\n * two lists to each other.\n */\n\n/** A worked example a person picks to steer what the site should look like. */\nexport interface AiSiteStartExample {\n /** A `STARTER_TEMPLATES` id, which is a persisted identifier. */\n id: string\n /** The starter as its card names it. */\n label: string\n /** The starter's category, which is how the examples group. */\n category: string\n /** What the example is, in one line a person reads before picking it. */\n blurb: string\n}\n\n/**\n * The examples the start offers, in the order they are shown. The platform's\n * own starter sites: a person who has no words for what they want has seen\n * these five shapes before, and picking one says more than a sentence would.\n */\nexport const AI_SITE_START_EXAMPLES: readonly AiSiteStartExample[] = [\n {\n id: 'business',\n label: 'Business',\n category: 'Business',\n blurb: 'A home page led by what you do, an about page and a contact page',\n },\n {\n id: 'landing',\n label: 'Landing Page',\n category: 'Marketing',\n blurb: 'One page that leads to one action, with the reasons to take it',\n },\n {\n id: 'portfolio',\n label: 'Portfolio',\n category: 'Personal',\n blurb: 'An introduction, a grid of work and a way to get in touch',\n },\n {\n id: 'physical-shop',\n label: 'Shop (physical products)',\n category: 'Commerce',\n blurb: 'Featured products, a shop to browse, and a cart',\n },\n {\n id: 'digital-shop',\n label: 'Shop (digital products)',\n category: 'Commerce',\n blurb: 'Downloads up front, a shop to browse, and a cart',\n },\n]\n\n/**\n * Kinds of site offered beside the first question's box, so answering it can\n * be a tap. They fill the box rather than replacing it: what somebody is\n * building is theirs to say, and a list of eight is a list somebody is not on.\n */\nexport const AI_SITE_START_TYPES: readonly string[] = [\n 'a local service business',\n 'a restaurant or cafe',\n 'a professional practice',\n 'a trades business',\n 'a shop',\n 'a nonprofit',\n 'a personal portfolio',\n 'an event',\n]\n\n/**\n * What a person answered; the shape the card holds and the brief is built from.\n *\n * Beside the answers each step asks, the business details its \"More details\"\n * offers (AGL-3979, `AiSiteDetails`): every one optional and `''` until given,\n * the phone number and email on the Details step itself.\n */\nexport interface AiSiteStartAnswers extends AiSiteDetails {\n /** What kind of site this is. The one answer with no default. */\n siteType: string\n /** Who the site is for; empty when they did not say. */\n audience: string\n /** The example they liked, by {@link AiSiteStartExample.id}; `null` for none. */\n example: string | null\n /**\n * The kind of site they picked (AGL-3660), by its `AI_SITE_KINDS` id;\n * `null` until they pick one, when the kind their first answer suggests is\n * the one used ({@link aiSiteStartKind}).\n */\n kind: string | null\n /** How many pages to plan. */\n pages: number\n /** Where the contact form's submissions go. */\n submissions: AiSiteSubmissions\n /** Whether the scaffold also drafts a welcome email. */\n welcomeEmail: boolean\n /** The city or town the business is in (AGL-3979); empty when they did not say. */\n city: string\n /** The brand color, as a six-digit hex (AGL-3979); empty for the style's own. */\n brand: string\n /**\n * The sites they like (AGL-3975), as typed, one a field; absent or empty\n * for none. Asked only while `release_ai_site_inspiration` is on.\n */\n inspiration?: string[]\n}\n\n/**\n * What the questions start on. Five pages because it is the middle of the\n * band the scaffold builds, a welcome email because the scaffold drafts one\n * unless it is told not to, and the Inbox because it is what every submission\n * does anyway — filing a lead as well is the addition, and an addition is the\n * thing a person should have to choose.\n */\nexport const AI_SITE_START_ANSWERS: AiSiteStartAnswers = {\n siteType: '',\n audience: '',\n example: null,\n kind: null,\n pages: 5,\n submissions: 'inbox',\n welcomeEmail: true,\n city: '',\n brand: '',\n ...AI_SITE_NO_DETAILS,\n}\n\n/** The answers a person may give beyond the ones each step asks, by key (AGL-3979). */\nexport type AiSiteStartExtraKey = AiSiteDetailKey | 'city' | 'brand'\n\n/** Every extra, in the order the review lists them. */\nexport const AI_SITE_START_EXTRA_KEYS: readonly AiSiteStartExtraKey[] = [\n 'phone',\n 'email',\n 'tagline',\n 'founded',\n 'serviceArea',\n 'priceRange',\n 'languages',\n 'brand',\n 'street',\n 'city',\n 'region',\n 'postalCode',\n 'country',\n 'hours',\n 'social',\n]\n\n/** What is wrong with one extra, worded for beside its field; `null` when it may be used. */\nexport function aiSiteStartExtraProblem(\n key: AiSiteStartExtraKey,\n value: string,\n): { code: 'too_long' | 'invalid'; message: string } | null {\n if (key === 'city' || key === 'brand') {\n return value.trim().length > AI_SITE_INPUT_MAX_CHARS\n ? { code: 'too_long', message: `Keep this under ${AI_SITE_INPUT_MAX_CHARS} characters.` }\n : null\n }\n return aiSiteDetailProblem(key, value)\n}\n\n/** The extras a person gave, in the review's order: what \"More details\" was used for. */\nexport function aiSiteStartExtrasGiven(answers: AiSiteStartAnswers): AiSiteStartExtraKey[] {\n return AI_SITE_START_EXTRA_KEYS.filter((key) => (answers[key] ?? '').trim() !== '')\n}\n\n/** The kind of site the answers pick, else the one what the site is and who it is for suggest. */\nexport function aiSiteStartKind(\n answers: Pick<AiSiteStartAnswers, 'kind' | 'siteType'> & Partial<Pick<AiSiteStartAnswers, 'audience'>>,\n): AiSiteKind {\n return aiSiteKind(answers.kind) ?? aiSiteKindFor(answers.siteType, answers.audience ?? '')\n}\n\n/** The example an answer names, or `null` when it names none this list knows. */\nexport function aiSiteStartExample(\n answers: AiSiteStartAnswers,\n): AiSiteStartExample | null {\n if (!answers.example) return null\n return AI_SITE_START_EXAMPLES.find((entry) => entry.id === answers.example) ?? null\n}\n\n/**\n * Why these answers cannot start a site, in a sentence a person reads; `null`\n * when they can. The door's own parser is what actually admits the job — this\n * is what the card says before it asks for one.\n */\nexport function aiSiteStartRefusal(\n answers: AiSiteStartAnswers,\n options: { freeTaste?: boolean } = {},\n): string | null {\n // The workspace's own band (AGL-3594): one or two pages on the Free taste.\n const band = aiSitePagesBand(options.freeTaste)\n const siteType = answers.siteType.trim()\n if (!siteType) return 'Say what kind of site this is.'\n if (siteType.length > AI_SITE_INPUT_MAX_CHARS) {\n return `Keep what kind of site this is under ${AI_SITE_INPUT_MAX_CHARS} characters.`\n }\n if (answers.audience.trim().length > AI_SITE_INPUT_MAX_CHARS) {\n return `Keep who the site is for under ${AI_SITE_INPUT_MAX_CHARS} characters.`\n }\n if (!Number.isInteger(answers.pages) || answers.pages < band.min || answers.pages > band.max) {\n return `A site is planned with ${band.min} to ${band.max} pages.`\n }\n if (answers.example !== null && !aiSiteStartExample(answers)) {\n return 'Pick one of the examples, or none of them.'\n }\n if (!(AI_SITE_SUBMISSIONS as readonly string[]).includes(answers.submissions)) {\n return 'Say where the contact form’s submissions go.'\n }\n for (const key of AI_SITE_START_EXTRA_KEYS) {\n const problem = aiSiteStartExtraProblem(key, answers[key] ?? '')\n if (problem) return problem.message\n }\n return aiSiteStartInspirationRefusal(answers, options)\n}\n\n/** The sites they typed, without the empty fields. */\nexport function aiSiteStartInspirationTyped(answers: Pick<AiSiteStartAnswers, 'inspiration'>): string[] {\n return (answers.inspiration ?? []).map((entry) => entry.trim()).filter(Boolean)\n}\n\n/** Why the sites they like cannot go forward, as the door would refuse them; `null` when they can. */\nexport function aiSiteStartInspirationRefusal(\n answers: Pick<AiSiteStartAnswers, 'inspiration'>,\n options: { freeTaste?: boolean } = {},\n): string | null {\n const typed = aiSiteStartInspirationTyped(answers)\n if (typed.some((entry) => !aiSiteInspirationUrl(entry))) {\n return 'Give each site you like as its https address, like https://example.com.'\n }\n return aiSiteInspirationRefusal(typed, options.freeTaste)\n}\n\n/**\n * The answers as the brief the `site` job is created with: the plan step reads\n * it as the person's own words, so it says what they said and asks for nothing\n * they did not.\n */\nexport function aiSiteStartBrief(answers: AiSiteStartAnswers): string {\n const siteType = answers.siteType.trim()\n const audience = answers.audience.trim()\n const example = aiSiteStartExample(answers)\n const sentences = [\n `A ${answers.pages}-page website for ${siteType}.`,\n ]\n if (audience) sentences.push(`It is for ${audience}.`)\n if (example) {\n sentences.push(\n `Follow the shape of the ${example.label} starter: ${example.blurb.toLowerCase()}.`,\n )\n }\n // The kind they picked, or the one their answer suggests (AGL-3660).\n sentences.push(`Make it a ${aiSiteStartKind(answers).label.toLowerCase()} site.`)\n // The form on the page a visitor opens to get in touch, never every page's\n // last band (AGL-3899): \"on the page that asks to be contacted\" read as\n // the home's closing band on 16 of the 22 newest production starts.\n sentences.push(\n answers.pages === 1\n ? 'Plan the page around what a visitor comes to do, with a contact form on it.'\n : 'Plan a page for each thing a visitor comes to do, with the contact form on the page a visitor opens to get in touch.',\n )\n if (audience) {\n // Said of the FORM as well as of the copy: who fills a form in is what\n // decides which fields it asks for, and a brief that named the audience\n // once, in a sentence about the pages, left the form to guess.\n sentences.push(`Ask the contact form for what ${audience} would be asked for.`)\n }\n return sentences.join(' ')\n}\n\n/**\n * The answers as the `site` job's scalar inputs. Read by the door's\n * {@link parseAiSiteJobInputs}, and put in front of the model one per line by\n * the plan step, which is how the audience and the example reach the plan\n * without a prompt of their own.\n *\n * The per-site variables an agency batch fills — the business name, the city,\n * the brand — are left empty here: the questions never ask them. The name is\n * the site's own, and the create door fills it from the site\n * (`aiJobAdmittedInputs`, AGL-3596) when the job is started — a job that\n * reached the model with no name had the model invent one for its header and\n * footer.\n */\nexport function aiSiteStartInputs(\n answers: AiSiteStartAnswers,\n): Omit<AiSiteJobInputs, 'batchId' | 'inspiration' | AiSiteDetailKey> & Partial<AiSiteDetails> & { inspiration?: string } {\n const example = aiSiteStartExample(answers)\n const kind = aiSiteStartKind(answers)\n // The details are sent only where given (AGL-3979): the plan step lists\n // every scalar input on a line of its own, and a start without them is\n // asked exactly what it was asked before.\n const details: Partial<AiSiteDetails> = {}\n for (const key of AI_SITE_DETAIL_KEYS) {\n const value = (answers[key] ?? '').trim()\n if (value) details[key] = value\n }\n // The sites they like travel only when there are some (AGL-3975), so a\n // start without them asks for exactly what it always did.\n const inspiration = aiSiteInspirationInput(aiSiteStartInspirationTyped(answers))\n return {\n businessType: answers.siteType.trim(),\n audience: answers.audience.trim(),\n starter: example?.id ?? kind.starter,\n siteKind: kind.id,\n pages: answers.pages,\n businessName: '',\n city: (answers.city ?? '').trim(),\n brand: (answers.brand ?? '').trim(),\n submissions: answers.submissions,\n welcomeEmail: answers.welcomeEmail,\n ...details,\n ...(inspiration ? { [AI_SITE_INSPIRATION_INPUT]: inspiration } : {}),\n }\n}\n\n/** The site inputs a guided start's answers become, by name: what a summary carries back (AGL-3596). */\nexport const AI_SITE_START_INPUT_KEYS = [\n 'businessType',\n 'audience',\n 'starter',\n 'siteKind',\n 'pages',\n 'businessName',\n 'city',\n 'brand',\n 'submissions',\n 'welcomeEmail',\n ...AI_SITE_DETAIL_KEYS,\n AI_SITE_INSPIRATION_INPUT,\n] as const\n\n/** A site job's scalar inputs, and nothing else its inputs carry; `null` when it has none. */\nexport function aiSiteStartInputsOf(\n inputs: Readonly<Record<string, unknown>> | null | undefined,\n): Record<string, unknown> | null {\n if (!inputs) return null\n const kept: Record<string, unknown> = {}\n for (const key of AI_SITE_START_INPUT_KEYS) {\n const value = inputs[key]\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') kept[key] = value\n }\n return Object.keys(kept).length ? kept : null\n}\n\n/**\n * A failed start's answers, back as the questions hold them (AGL-3596), so\n * Try again reopens the guided start filled in for the person to adjust:\n * the inverse of {@link aiSiteStartInputs}. Read defensively — an answer the\n * questions no longer offer goes back to its default — and held to the\n * workspace's page band. `null` when the inputs say no kind of site at all.\n */\nexport function aiSiteStartAnswersFromInputs(\n inputs: Readonly<Record<string, unknown>> | null | undefined,\n options: { freeTaste?: boolean } = {},\n): AiSiteStartAnswers | null {\n const text = (key: string) => (typeof inputs?.[key] === 'string' ? (inputs[key] as string).trim() : '')\n const siteType = text('businessType')\n if (!siteType) return null\n const band = aiSitePagesBand(options.freeTaste)\n const pages = typeof inputs?.['pages'] === 'number' ? Math.round(inputs['pages'] as number) : AI_SITE_START_ANSWERS.pages\n const starter = text('starter')\n const submissions = text('submissions')\n return {\n siteType,\n audience: text('audience'),\n example: AI_SITE_START_EXAMPLES.some((entry) => entry.id === starter) ? starter : null,\n kind: aiSiteKind(text('siteKind'))?.id ?? null,\n pages: Math.min(band.max, Math.max(band.min, pages)),\n submissions: (AI_SITE_SUBMISSIONS as readonly string[]).includes(submissions)\n ? (submissions as AiSiteSubmissions)\n : AI_SITE_START_ANSWERS.submissions,\n welcomeEmail: options.freeTaste ? false : inputs?.['welcomeEmail'] !== false,\n city: text('city'),\n brand: text('brand'),\n ...(Object.fromEntries(AI_SITE_DETAIL_KEYS.map((key) => [key, text(key)])) as unknown as AiSiteDetails),\n // The sites they liked come back as typed, within the workspace's limit (AGL-3975).\n ...(text(AI_SITE_INSPIRATION_INPUT)\n ? { inspiration: text(AI_SITE_INSPIRATION_INPUT).split(/\\s+/).filter(Boolean).slice(0, aiSiteInspirationLimit(options.freeTaste)) }\n : {}),\n }\n}\n\n// ── A build staff run for a client (AGL-3958) ───────────────────────────────\n\n/** Shortens an answer to what a scalar input admits, on a word where it can. */\nfunction bounded(value: string, max: number): string {\n const trimmed = value.trim().replace(/\\s+/g, ' ')\n if (trimmed.length <= max) return trimmed\n const cut = trimmed.slice(0, max)\n const space = cut.lastIndexOf(' ')\n return (space > max / 2 ? cut.slice(0, space) : cut).trim()\n}\n\n/** A time with am or pm: \"9am\", \"5:30 pm\", \"12 a.m.\". */\nconst TWELVE_HOUR_TIME = /\\b(\\d{1,2})(?::(\\d{2}))?\\s*([ap])\\.?m\\.?(?![a-z])/gi\n\n/**\n * The hours an owner gave, in the shape the Details step's hours picker\n * writes (`Tu-Sa 09:00-17:00`, one set of days a line), so the plan reads\n * them as it reads hours picked there. A time with am or pm is the time it\n * names, \"to\" joins a range as a dash does, and days with their hours may be\n * set apart by a comma, a semicolon or a line. Whatever still does not read\n * as hours — \"8–5\", \"Sat by appointment\" — is left out rather than guessed at.\n */\nfunction clientBuildHours(hours: string): string {\n const lines = hours\n .replace(TWELVE_HOUR_TIME, (time, hour: string, minutes: string | undefined, half: string) => {\n const h = Number(hour)\n if (h < 1 || h > 12) return time\n const clock = (h % 12) + (half.toLowerCase() === 'p' ? 12 : 0)\n return `${String(clock).padStart(2, '0')}:${minutes ?? '00'}`\n })\n .replace(/\\s+to\\s+/gi, '-')\n .replace(/(\\d{1,2}:\\d{2})\\s*,\\s*/g, '$1\\n')\n .replace(/;/g, '\\n')\n const week = weeklyHoursFromText(lines).hours\n return week.some((day) => day.length) ? weeklyHoursToText(week) : ''\n}\n\n/**\n * The towns an intake serves, one a line, as the Details step's \"Areas you\n * serve\" holds them: \"Austin, Round Rock and Pflugerville\" is three.\n */\nfunction clientBuildServiceArea(towns: string): string {\n return towns\n .split(/\\r?\\n|[,;]|\\s+(?:and|&)\\s+/i)\n .map((town) => town.trim())\n .filter(Boolean)\n .join('\\n')\n}\n\n/**\n * The questions' answers for a site staff are building for a client: what\n * the business does is the kind of site, and the details the intake holds\n * fill the Details step's own fields (AGL-3979, AGL-3995): the phone, the\n * email, the towns as the areas it serves and the hours, each held to that\n * detail's own rule, so one the Details step would refuse is left empty\n * there. Every other answer keeps its default, which the review shows to\n * change. The intake, a refused detail included, also reaches the job\n * through {@link aiSiteStartClientInputs} and {@link aiSiteStartClientBrief}.\n */\nexport function aiSiteStartAnswersFromClientBuild(intake: ClientBuildIntake): AiSiteStartAnswers {\n const details = aiSiteDetailsOf({\n phone: intake.phone,\n email: intake.email,\n serviceArea: clientBuildServiceArea(intake.towns),\n hours: clientBuildHours(intake.hours),\n })\n return {\n ...AI_SITE_START_ANSWERS,\n siteType: bounded(intake.whatTheyDo, AI_SITE_INPUT_MAX_CHARS),\n phone: details.phone,\n email: details.email,\n serviceArea: details.serviceArea,\n hours: details.hours,\n }\n}\n\n/**\n * The per-site inputs the intake fills, which the guided start's own\n * questions leave empty: the business's name for the header and footer, and\n * the towns it serves as its place.\n *\n * The towns are the place only while no address is given. The Entity reads\n * `city` as the address's own locality wherever there is a street or a\n * postal code (`aiSiteEntity`), so once the answers carry either, `city` is\n * the city the Details step was given with that address, never the towns\n * (AGL-3995). The intake asks no address, so today that is the Details step's\n * own, typed on the review; the towns still reach the site as the areas it\n * serves.\n */\nexport function aiSiteStartClientInputs(\n intake: ClientBuildIntake,\n answers?: Pick<AiSiteStartAnswers, 'street' | 'postalCode' | 'city'> | null,\n): Pick<AiSiteJobInputs, 'businessName' | 'city'> {\n const addressed = Boolean(answers?.street.trim() || answers?.postalCode.trim())\n return {\n businessName: bounded(intake.businessName, AI_SITE_INPUT_MAX_CHARS),\n city: bounded(addressed ? (answers?.city ?? '') : intake.towns, AI_SITE_INPUT_MAX_CHARS),\n }\n}\n\n/**\n * The intake as sentences added to the brief: how to reach the business and\n * when it is open, which the site should say where a visitor looks for them,\n * and the owner's own words, quoted, which the copy should sound like. Empty\n * answers say nothing.\n */\nexport function aiSiteStartClientBrief(intake: ClientBuildIntake): string {\n const name = intake.businessName.trim()\n const towns = intake.towns.trim()\n const phone = intake.phone.trim()\n const email = intake.email.trim()\n const hours = intake.hours.trim()\n const words = intake.ownerWords.trim().replace(/\\s+/g, ' ')\n const sentences: string[] = []\n if (name) sentences.push(`The business is called ${name}.`)\n if (towns) sentences.push(`It serves ${towns}.`)\n const contact = [phone ? `call ${phone}` : '', email ? `email ${email}` : ''].filter(Boolean)\n if (contact.length) {\n sentences.push(`Visitors reach it to ${contact.join(' or ')}; say so wherever the site tells them how to get in touch.`)\n }\n if (hours) sentences.push(`Its hours are ${hours}.`)\n if (words) sentences.push(`In the owner's own words: \"${words}\" Write the copy so it sounds like them.`)\n return sentences.join(' ')\n}\n\n/**\n * What the review says the client build adds beyond its own rows, so staff\n * see the intake is used without it being asked again: the business's name\n * and the owner's own words, which no row shows. The phone, email, towns and\n * hours are the review's Details rows already (AGL-3995), so the note does\n * not say them twice: \"Also from the client's details: Harbor Plumbing and\n * the owner's own words.\"\n */\nexport function aiSiteStartClientNote(intake: ClientBuildIntake): string {\n const parts = [intake.businessName.trim(), intake.ownerWords.trim() ? \"the owner's own words\" : ''].filter(Boolean)\n if (!parts.length) return 'Built from the client’s details.'\n return `Also from the client’s details: ${parts.join(' and ')}.`\n}\n"],"names":["weeklyHoursFromText","weeklyHoursToText","AI_SITE_DETAIL_KEYS","AI_SITE_NO_DETAILS","aiSiteDetailProblem","aiSiteDetailsOf","aiSiteKind","aiSiteKindFor","AI_SITE_INSPIRATION_INPUT","aiSiteInspirationInput","aiSiteInspirationLimit","aiSiteInspirationRefusal","aiSiteInspirationUrl","AI_SITE_INPUT_MAX_CHARS","AI_SITE_SUBMISSIONS","aiSitePagesBand","AI_SITE_START_EXAMPLES","id","label","category","blurb","AI_SITE_START_TYPES","AI_SITE_START_ANSWERS","siteType","audience","example","kind","pages","submissions","welcomeEmail","city","brand","AI_SITE_START_EXTRA_KEYS","aiSiteStartExtraProblem","key","value","trim","length","code","message","aiSiteStartExtrasGiven","answers","filter","aiSiteStartKind","aiSiteStartExample","find","entry","aiSiteStartRefusal","options","band","freeTaste","Number","isInteger","min","max","includes","problem","aiSiteStartInspirationRefusal","aiSiteStartInspirationTyped","inspiration","map","Boolean","typed","some","aiSiteStartBrief","sentences","push","toLowerCase","join","aiSiteStartInputs","details","businessType","starter","siteKind","businessName","AI_SITE_START_INPUT_KEYS","aiSiteStartInputsOf","inputs","kept","Object","keys","aiSiteStartAnswersFromInputs","text","Math","round","fromEntries","split","slice","bounded","trimmed","replace","cut","space","lastIndexOf","TWELVE_HOUR_TIME","clientBuildHours","hours","lines","time","hour","minutes","half","h","clock","String","padStart","week","day","clientBuildServiceArea","towns","town","aiSiteStartAnswersFromClientBuild","intake","phone","email","serviceArea","whatTheyDo","aiSiteStartClientInputs","addressed","street","postalCode","aiSiteStartClientBrief","name","words","ownerWords","contact","aiSiteStartClientNote","parts"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SAASA,mBAAmB,EAAEC,iBAAiB,QAAQ,0CAAyC;AAChG,SACEC,mBAAmB,EACnBC,kBAAkB,EAClBC,mBAAmB,EACnBC,eAAe,QAGV,uBAAmB;AAC1B,SAASC,UAAU,EAAEC,aAAa,QAAyB,qBAAiB;AAC5E,SACEC,yBAAyB,EACzBC,sBAAsB,EACtBC,sBAAsB,EACtBC,wBAAwB,EACxBC,oBAAoB,QACf,2BAAuB;AAC9B,SACEC,uBAAuB,EACvBC,mBAAmB,EACnBC,eAAe,QAGV,mBAAe;AAiDtB;;;;CAIC,GACD,OAAO,MAAMC,yBAAwD;IACnE;QACEC,IAAI;QACJC,OAAO;QACPC,UAAU;QACVC,OAAO;IACT;IACA;QACEH,IAAI;QACJC,OAAO;QACPC,UAAU;QACVC,OAAO;IACT;IACA;QACEH,IAAI;QACJC,OAAO;QACPC,UAAU;QACVC,OAAO;IACT;IACA;QACEH,IAAI;QACJC,OAAO;QACPC,UAAU;QACVC,OAAO;IACT;IACA;QACEH,IAAI;QACJC,OAAO;QACPC,UAAU;QACVC,OAAO;IACT;CACD,CAAA;AAED;;;;CAIC,GACD,OAAO,MAAMC,sBAAyC;IACpD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAuCD;;;;;;CAMC,GACD,OAAO,MAAMC,wBAA4C;IACvDC,UAAU;IACVC,UAAU;IACVC,SAAS;IACTC,MAAM;IACNC,OAAO;IACPC,aAAa;IACbC,cAAc;IACdC,MAAM;IACNC,OAAO;GACJ5B,oBACJ;AAKD,qDAAqD,GACrD,OAAO,MAAM6B,2BAA2D;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AAC,CAAC;IAC1D,IAAIb,OAAO5C,UAAUC,IAAI,CAAC,CAAC,UAAU,EAAE2C,MAAM,CAAC,CAAC;IAC/C,MAAMgB,UAAU;QAACZ,QAAQ,CAAC,KAAK,EAAEA,OAAO,GAAG;QAAIC,QAAQ,CAAC,MAAM,EAAEA,OAAO,GAAG;KAAG,CAACxE,MAAM,CAACmB;IACrF,IAAIgE,QAAQxF,MAAM,EAAE;QAClB4B,UAAUC,IAAI,CAAC,CAAC,qBAAqB,EAAE2D,QAAQzD,IAAI,CAAC,QAAQ,0DAA0D,CAAC;IACzH;IACA,IAAI4B,OAAO/B,UAAUC,IAAI,CAAC,CAAC,cAAc,EAAE8B,MAAM,CAAC,CAAC;IACnD,IAAI2B,OAAO1D,UAAUC,IAAI,CAAC,CAAC,2BAA2B,EAAEyD,MAAM,wCAAwC,CAAC;IACvG,OAAO1D,UAAUG,IAAI,CAAC;AACxB;AAEA;;;;;;;CAOC,GACD,OAAO,SAAS0D,sBAAsBd,MAAyB;IAC7D,MAAMe,QAAQ;QAACf,OAAOtC,YAAY,CAACtC,IAAI;QAAI4E,OAAOY,UAAU,CAACxF,IAAI,KAAK,0BAA0B;KAAG,CAACM,MAAM,CAACmB;IAC3G,IAAI,CAACkE,MAAM1F,MAAM,EAAE,OAAO;IAC1B,OAAO,CAAC,gCAAgC,EAAE0F,MAAM3D,IAAI,CAAC,SAAS,CAAC,CAAC;AAClE"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-site-start.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ClientBuildIntake } from '@aglyn/aglyn/app-utils/client-build'\nimport { SITE_STYLE_AUTO } from '@aglyn/aglyn/app-utils/site-styles'\nimport { weeklyHoursFromText, weeklyHoursToText } from '@aglyn/shared-ui-jsx/utils/weekly-hours'\nimport {\n AI_SITE_DETAIL_KEYS,\n AI_SITE_NO_DETAILS,\n aiSiteDetailProblem,\n aiSiteDetailsOf,\n type AiSiteDetailKey,\n type AiSiteDetails,\n} from './ai-site-details'\nimport { aiSiteKind, aiSiteKindFor, type AiSiteKind } from './ai-site-kinds'\nimport {\n AI_SITE_INSPIRATION_INPUT,\n aiSiteInspirationInput,\n aiSiteInspirationLimit,\n aiSiteInspirationRefusal,\n aiSiteInspirationUrl,\n} from './ai-site-inspiration'\nimport {\n AI_SITE_INPUT_MAX_CHARS,\n AI_SITE_SUBMISSIONS,\n aiSitePagesBand,\n type AiSiteJobInputs,\n type AiSiteSubmissions,\n} from './ai-site-job'\n\n/**\n * The guided start (AGL-2918): the questions a person answers on a site they\n * have just made, and the site job those answers become.\n *\n * A scaffold already exists — the `site` job plans four to eight pages, a\n * layout, a contact form, a palette and a welcome email, and builds every one\n * of them as a draft. What it had no way in through was a brief: somebody had\n * to know what to write, on a site where nothing has happened yet. So this\n * module is the QUESTIONS, and nothing else: what is asked, what an answer may\n * be, and how a set of answers becomes the brief and the scalar inputs the\n * `site` door already takes.\n *\n * ── Answering is never the way out ───────────────────────────────────────\n *\n * There is no answer here that means \"not this\". The way past the questions\n * is the `hostFirstRun` zone's own `startBlank`, which is drawn beside them\n * from the first one and creates nothing at all — see the zone in\n * `CONSOLE_WIDGET_SLOTS`. Putting the exit inside the question set would make\n * leaving a thing you answer your way to, and it is not.\n *\n * ── Every answer but the first is optional ───────────────────────────────\n *\n * Only what a site is FOR has no default worth guessing. The audience narrows\n * the copy, the example steers the shape, the page count and the welcome\n * email are defaults a person may change — so a person who types six words\n * and confirms gets a planned site, and the rest of the questions are there\n * for the person who wants to answer them.\n *\n * Pure: shapes, vocabularies and two string builders. No React, no network,\n * and no import of the starter catalog — {@link AI_SITE_START_EXAMPLES} names\n * the starters rather than reading them, so the console does not carry a\n * catalog of node maps to draw five cards. `ai-site-start.spec.ts` holds the\n * two lists to each other.\n */\n\n/** A worked example a person picks to steer what the site should look like. */\nexport interface AiSiteStartExample {\n /** A `STARTER_TEMPLATES` id, which is a persisted identifier. */\n id: string\n /** The starter as its card names it. */\n label: string\n /** The starter's category, which is how the examples group. */\n category: string\n /** What the example is, in one line a person reads before picking it. */\n blurb: string\n}\n\n/**\n * The examples the start offers, in the order they are shown. The platform's\n * own starter sites: a person who has no words for what they want has seen\n * these five shapes before, and picking one says more than a sentence would.\n */\nexport const AI_SITE_START_EXAMPLES: readonly AiSiteStartExample[] = [\n {\n id: 'business',\n label: 'Business',\n category: 'Business',\n blurb: 'A home page led by what you do, an about page and a contact page',\n },\n {\n id: 'landing',\n label: 'Landing Page',\n category: 'Marketing',\n blurb: 'One page that leads to one action, with the reasons to take it',\n },\n {\n id: 'portfolio',\n label: 'Portfolio',\n category: 'Personal',\n blurb: 'An introduction, a grid of work and a way to get in touch',\n },\n {\n id: 'physical-shop',\n label: 'Shop (physical products)',\n category: 'Commerce',\n blurb: 'Featured products, a shop to browse, and a cart',\n },\n {\n id: 'digital-shop',\n label: 'Shop (digital products)',\n category: 'Commerce',\n blurb: 'Downloads up front, a shop to browse, and a cart',\n },\n]\n\n/**\n * Kinds of site offered beside the first question's box, so answering it can\n * be a tap. They fill the box rather than replacing it: what somebody is\n * building is theirs to say, and a list of eight is a list somebody is not on.\n */\nexport const AI_SITE_START_TYPES: readonly string[] = [\n 'a local service business',\n 'a restaurant or cafe',\n 'a professional practice',\n 'a trades business',\n 'a shop',\n 'a nonprofit',\n 'a personal portfolio',\n 'an event',\n]\n\n/**\n * What a person answered; the shape the card holds and the brief is built from.\n *\n * Beside the answers each step asks, the business details its \"More details\"\n * offers (AGL-3979, `AiSiteDetails`): every one optional and `''` until given,\n * the phone number and email on the Details step itself.\n */\nexport interface AiSiteStartAnswers extends AiSiteDetails {\n /** What kind of site this is. The one answer with no default. */\n siteType: string\n /** Who the site is for; empty when they did not say. */\n audience: string\n /** The example they liked, by {@link AiSiteStartExample.id}; `null` for none. */\n example: string | null\n /**\n * The style card they clicked (AGL-4049): a kind's id, or\n * `SITE_STYLE_AUTO` for \"Pick for me\"; `null` while they have clicked none.\n * Nothing is chosen for a person, so the Style step does not go forward on\n * `null` ({@link aiSiteStartStyleAnswer} sets this and {@link kind} together).\n */\n style: string | null\n /**\n * The kind of site they picked (AGL-3660), by its `AI_SITE_KINDS` id;\n * `null` for \"Pick for me\", or before a style is chosen, when the kind\n * their first answer suggests is the one used ({@link aiSiteStartKind}).\n */\n kind: string | null\n /** How many pages to plan. */\n pages: number\n /** Where the contact form's submissions go. */\n submissions: AiSiteSubmissions\n /** Whether the scaffold also drafts a welcome email. */\n welcomeEmail: boolean\n /** The city or town the business is in (AGL-3979); empty when they did not say. */\n city: string\n /** The brand color, as a six-digit hex (AGL-3979); empty for the style's own. */\n brand: string\n /**\n * The sites they like (AGL-3975), as typed, one a field; absent or empty\n * for none. Asked only while `release_ai_site_inspiration` is on.\n */\n inspiration?: string[]\n}\n\n/**\n * What the questions start on. Five pages because it is the middle of the\n * band the scaffold builds, a welcome email because the scaffold drafts one\n * unless it is told not to, and the Inbox because it is what every submission\n * does anyway — filing a lead as well is the addition, and an addition is the\n * thing a person should have to choose.\n */\nexport const AI_SITE_START_ANSWERS: AiSiteStartAnswers = {\n siteType: '',\n audience: '',\n example: null,\n style: null,\n kind: null,\n pages: 5,\n submissions: 'inbox',\n welcomeEmail: true,\n city: '',\n brand: '',\n ...AI_SITE_NO_DETAILS,\n}\n\n/**\n * Why the Style step does not go forward before a card is clicked (AGL-4049),\n * and why the review does not plan: nothing is chosen for a person, and\n * \"Pick for me\" is a card too. The door itself admits a start without one\n * ({@link aiSiteStartRefusal} is what it would refuse), so this is the\n * questions' rule, held by `aiSiteStartStepErrors` and the card.\n */\nexport const AI_SITE_START_STYLE_REQUIRED = 'Choose a style, or Pick for me.'\n\n/** The answers a person may give beyond the ones each step asks, by key (AGL-3979). */\nexport type AiSiteStartExtraKey = AiSiteDetailKey | 'city' | 'brand'\n\n/** Every extra, in the order the review lists them. */\nexport const AI_SITE_START_EXTRA_KEYS: readonly AiSiteStartExtraKey[] = [\n 'phone',\n 'email',\n 'tagline',\n 'founded',\n 'serviceArea',\n 'priceRange',\n 'languages',\n 'brand',\n 'street',\n 'city',\n 'region',\n 'postalCode',\n 'country',\n 'hours',\n 'social',\n]\n\n/** What is wrong with one extra, worded for beside its field; `null` when it may be used. */\nexport function aiSiteStartExtraProblem(\n key: AiSiteStartExtraKey,\n value: string,\n): { code: 'too_long' | 'invalid'; message: string } | null {\n if (key === 'city' || key === 'brand') {\n return value.trim().length > AI_SITE_INPUT_MAX_CHARS\n ? { code: 'too_long', message: `Keep this under ${AI_SITE_INPUT_MAX_CHARS} characters.` }\n : null\n }\n return aiSiteDetailProblem(key, value)\n}\n\n/** The extras a person gave, in the review's order: what \"More details\" was used for. */\nexport function aiSiteStartExtrasGiven(answers: AiSiteStartAnswers): AiSiteStartExtraKey[] {\n return AI_SITE_START_EXTRA_KEYS.filter((key) => (answers[key] ?? '').trim() !== '')\n}\n\n/**\n * A style card clicked (AGL-4049), as the answers hold it: the card's id as\n * the style, and the kind it names — none for \"Pick for me\", which leaves the\n * kind to what the site is and who it is for.\n */\nexport function aiSiteStartStyleAnswer(id: string): Pick<AiSiteStartAnswers, 'style' | 'kind'> {\n return { style: id, kind: id === SITE_STYLE_AUTO ? null : (aiSiteKind(id)?.id ?? null) }\n}\n\n/** The kind of site the answers pick, else the one what the site is and who it is for suggest. */\nexport function aiSiteStartKind(\n answers: Pick<AiSiteStartAnswers, 'kind' | 'siteType'> & Partial<Pick<AiSiteStartAnswers, 'audience'>>,\n): AiSiteKind {\n return aiSiteKind(answers.kind) ?? aiSiteKindFor(answers.siteType, answers.audience ?? '')\n}\n\n/** The example an answer names, or `null` when it names none this list knows. */\nexport function aiSiteStartExample(\n answers: AiSiteStartAnswers,\n): AiSiteStartExample | null {\n if (!answers.example) return null\n return AI_SITE_START_EXAMPLES.find((entry) => entry.id === answers.example) ?? null\n}\n\n/**\n * Why these answers cannot start a site, in a sentence a person reads; `null`\n * when they can. The door's own parser is what actually admits the job — this\n * is what the card says before it asks for one.\n */\nexport function aiSiteStartRefusal(\n answers: AiSiteStartAnswers,\n options: { freeTaste?: boolean } = {},\n): string | null {\n // The workspace's own band (AGL-3594): one or two pages on the Free taste.\n const band = aiSitePagesBand(options.freeTaste)\n const siteType = answers.siteType.trim()\n if (!siteType) return 'Say what kind of site this is.'\n if (siteType.length > AI_SITE_INPUT_MAX_CHARS) {\n return `Keep what kind of site this is under ${AI_SITE_INPUT_MAX_CHARS} characters.`\n }\n if (answers.audience.trim().length > AI_SITE_INPUT_MAX_CHARS) {\n return `Keep who the site is for under ${AI_SITE_INPUT_MAX_CHARS} characters.`\n }\n if (!Number.isInteger(answers.pages) || answers.pages < band.min || answers.pages > band.max) {\n return `A site is planned with ${band.min} to ${band.max} pages.`\n }\n if (answers.example !== null && !aiSiteStartExample(answers)) {\n return 'Pick one of the examples, or none of them.'\n }\n if (!(AI_SITE_SUBMISSIONS as readonly string[]).includes(answers.submissions)) {\n return 'Say where the contact form’s submissions go.'\n }\n for (const key of AI_SITE_START_EXTRA_KEYS) {\n const problem = aiSiteStartExtraProblem(key, answers[key] ?? '')\n if (problem) return problem.message\n }\n return aiSiteStartInspirationRefusal(answers, options)\n}\n\n/** The sites they typed, without the empty fields. */\nexport function aiSiteStartInspirationTyped(answers: Pick<AiSiteStartAnswers, 'inspiration'>): string[] {\n return (answers.inspiration ?? []).map((entry) => entry.trim()).filter(Boolean)\n}\n\n/** Why the sites they like cannot go forward, as the door would refuse them; `null` when they can. */\nexport function aiSiteStartInspirationRefusal(\n answers: Pick<AiSiteStartAnswers, 'inspiration'>,\n options: { freeTaste?: boolean } = {},\n): string | null {\n const typed = aiSiteStartInspirationTyped(answers)\n if (typed.some((entry) => !aiSiteInspirationUrl(entry))) {\n return 'Give each site you like as its https address, like https://example.com.'\n }\n return aiSiteInspirationRefusal(typed, options.freeTaste)\n}\n\n/**\n * The answers as the brief the `site` job is created with: the plan step reads\n * it as the person's own words, so it says what they said and asks for nothing\n * they did not.\n */\nexport function aiSiteStartBrief(answers: AiSiteStartAnswers): string {\n const siteType = answers.siteType.trim()\n const audience = answers.audience.trim()\n const example = aiSiteStartExample(answers)\n const sentences = [\n `A ${answers.pages}-page website for ${siteType}.`,\n ]\n if (audience) sentences.push(`It is for ${audience}.`)\n if (example) {\n sentences.push(\n `Follow the shape of the ${example.label} starter: ${example.blurb.toLowerCase()}.`,\n )\n }\n // The kind they picked, or the one their answer suggests (AGL-3660).\n sentences.push(`Make it a ${aiSiteStartKind(answers).label.toLowerCase()} site.`)\n // The form on the page a visitor opens to get in touch, never every page's\n // last band (AGL-3899): \"on the page that asks to be contacted\" read as\n // the home's closing band on 16 of the 22 newest production starts.\n sentences.push(\n answers.pages === 1\n ? 'Plan the page around what a visitor comes to do, with a contact form on it.'\n : 'Plan a page for each thing a visitor comes to do, with the contact form on the page a visitor opens to get in touch.',\n )\n if (audience) {\n // Said of the FORM as well as of the copy: who fills a form in is what\n // decides which fields it asks for, and a brief that named the audience\n // once, in a sentence about the pages, left the form to guess.\n sentences.push(`Ask the contact form for what ${audience} would be asked for.`)\n }\n return sentences.join(' ')\n}\n\n/**\n * The answers as the `site` job's scalar inputs. Read by the door's\n * {@link parseAiSiteJobInputs}, and put in front of the model one per line by\n * the plan step, which is how the audience and the example reach the plan\n * without a prompt of their own.\n *\n * The per-site variables an agency batch fills — the business name, the city,\n * the brand — are left empty here: the questions never ask them. The name is\n * the site's own, and the create door fills it from the site\n * (`aiJobAdmittedInputs`, AGL-3596) when the job is started — a job that\n * reached the model with no name had the model invent one for its header and\n * footer.\n */\nexport function aiSiteStartInputs(\n answers: AiSiteStartAnswers,\n): Omit<AiSiteJobInputs, 'batchId' | 'inspiration' | AiSiteDetailKey> & Partial<AiSiteDetails> & { inspiration?: string } {\n const example = aiSiteStartExample(answers)\n const kind = aiSiteStartKind(answers)\n // The details are sent only where given (AGL-3979): the plan step lists\n // every scalar input on a line of its own, and a start without them is\n // asked exactly what it was asked before.\n const details: Partial<AiSiteDetails> = {}\n for (const key of AI_SITE_DETAIL_KEYS) {\n const value = (answers[key] ?? '').trim()\n if (value) details[key] = value\n }\n // The sites they like travel only when there are some (AGL-3975), so a\n // start without them asks for exactly what it always did.\n const inspiration = aiSiteInspirationInput(aiSiteStartInspirationTyped(answers))\n return {\n businessType: answers.siteType.trim(),\n audience: answers.audience.trim(),\n starter: example?.id ?? kind.starter,\n siteKind: kind.id,\n pages: answers.pages,\n businessName: '',\n city: (answers.city ?? '').trim(),\n brand: (answers.brand ?? '').trim(),\n submissions: answers.submissions,\n welcomeEmail: answers.welcomeEmail,\n ...details,\n ...(inspiration ? { [AI_SITE_INSPIRATION_INPUT]: inspiration } : {}),\n }\n}\n\n/** The site inputs a guided start's answers become, by name: what a summary carries back (AGL-3596). */\nexport const AI_SITE_START_INPUT_KEYS = [\n 'businessType',\n 'audience',\n 'starter',\n 'siteKind',\n 'pages',\n 'businessName',\n 'city',\n 'brand',\n 'submissions',\n 'welcomeEmail',\n ...AI_SITE_DETAIL_KEYS,\n AI_SITE_INSPIRATION_INPUT,\n] as const\n\n/** A site job's scalar inputs, and nothing else its inputs carry; `null` when it has none. */\nexport function aiSiteStartInputsOf(\n inputs: Readonly<Record<string, unknown>> | null | undefined,\n): Record<string, unknown> | null {\n if (!inputs) return null\n const kept: Record<string, unknown> = {}\n for (const key of AI_SITE_START_INPUT_KEYS) {\n const value = inputs[key]\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') kept[key] = value\n }\n return Object.keys(kept).length ? kept : null\n}\n\n/**\n * A failed start's answers, back as the questions hold them (AGL-3596), so\n * Try again reopens the guided start filled in for the person to adjust:\n * the inverse of {@link aiSiteStartInputs}. Read defensively — an answer the\n * questions no longer offer goes back to its default — and held to the\n * workspace's page band. `null` when the inputs say no kind of site at all.\n */\nexport function aiSiteStartAnswersFromInputs(\n inputs: Readonly<Record<string, unknown>> | null | undefined,\n options: { freeTaste?: boolean } = {},\n): AiSiteStartAnswers | null {\n const text = (key: string) => (typeof inputs?.[key] === 'string' ? (inputs[key] as string).trim() : '')\n const siteType = text('businessType')\n if (!siteType) return null\n const band = aiSitePagesBand(options.freeTaste)\n const pages = typeof inputs?.['pages'] === 'number' ? Math.round(inputs['pages'] as number) : AI_SITE_START_ANSWERS.pages\n const starter = text('starter')\n const submissions = text('submissions')\n return {\n siteType,\n audience: text('audience'),\n example: AI_SITE_START_EXAMPLES.some((entry) => entry.id === starter) ? starter : null,\n // A start that ran had its style chosen: its kind, or \"Pick for me\".\n ...aiSiteStartStyleAnswer(aiSiteKind(text('siteKind'))?.id ?? SITE_STYLE_AUTO),\n pages: Math.min(band.max, Math.max(band.min, pages)),\n submissions: (AI_SITE_SUBMISSIONS as readonly string[]).includes(submissions)\n ? (submissions as AiSiteSubmissions)\n : AI_SITE_START_ANSWERS.submissions,\n welcomeEmail: options.freeTaste ? false : inputs?.['welcomeEmail'] !== false,\n city: text('city'),\n brand: text('brand'),\n ...(Object.fromEntries(AI_SITE_DETAIL_KEYS.map((key) => [key, text(key)])) as unknown as AiSiteDetails),\n // The sites they liked come back as typed, within the workspace's limit (AGL-3975).\n ...(text(AI_SITE_INSPIRATION_INPUT)\n ? { inspiration: text(AI_SITE_INSPIRATION_INPUT).split(/\\s+/).filter(Boolean).slice(0, aiSiteInspirationLimit(options.freeTaste)) }\n : {}),\n }\n}\n\n// ── A build staff run for a client (AGL-3958) ───────────────────────────────\n\n/** Shortens an answer to what a scalar input admits, on a word where it can. */\nfunction bounded(value: string, max: number): string {\n const trimmed = value.trim().replace(/\\s+/g, ' ')\n if (trimmed.length <= max) return trimmed\n const cut = trimmed.slice(0, max)\n const space = cut.lastIndexOf(' ')\n return (space > max / 2 ? cut.slice(0, space) : cut).trim()\n}\n\n/** A time with am or pm: \"9am\", \"5:30 pm\", \"12 a.m.\". */\nconst TWELVE_HOUR_TIME = /\\b(\\d{1,2})(?::(\\d{2}))?\\s*([ap])\\.?m\\.?(?![a-z])/gi\n\n/**\n * The hours an owner gave, in the shape the Details step's hours picker\n * writes (`Tu-Sa 09:00-17:00`, one set of days a line), so the plan reads\n * them as it reads hours picked there. A time with am or pm is the time it\n * names, \"to\" joins a range as a dash does, and days with their hours may be\n * set apart by a comma, a semicolon or a line. Whatever still does not read\n * as hours — \"8–5\", \"Sat by appointment\" — is left out rather than guessed at.\n */\nfunction clientBuildHours(hours: string): string {\n const lines = hours\n .replace(TWELVE_HOUR_TIME, (time, hour: string, minutes: string | undefined, half: string) => {\n const h = Number(hour)\n if (h < 1 || h > 12) return time\n const clock = (h % 12) + (half.toLowerCase() === 'p' ? 12 : 0)\n return `${String(clock).padStart(2, '0')}:${minutes ?? '00'}`\n })\n .replace(/\\s+to\\s+/gi, '-')\n .replace(/(\\d{1,2}:\\d{2})\\s*,\\s*/g, '$1\\n')\n .replace(/;/g, '\\n')\n const week = weeklyHoursFromText(lines).hours\n return week.some((day) => day.length) ? weeklyHoursToText(week) : ''\n}\n\n/**\n * The towns an intake serves, one a line, as the Details step's \"Areas you\n * serve\" holds them: \"Austin, Round Rock and Pflugerville\" is three.\n */\nfunction clientBuildServiceArea(towns: string): string {\n return towns\n .split(/\\r?\\n|[,;]|\\s+(?:and|&)\\s+/i)\n .map((town) => town.trim())\n .filter(Boolean)\n .join('\\n')\n}\n\n/**\n * The questions' answers for a site staff are building for a client: what\n * the business does is the kind of site, and the details the intake holds\n * fill the Details step's own fields (AGL-3979, AGL-3995): the phone, the\n * email, the towns as the areas it serves and the hours, each held to that\n * detail's own rule, so one the Details step would refuse is left empty\n * there. Every other answer keeps its default, which the review shows to\n * change. The intake, a refused detail included, also reaches the job\n * through {@link aiSiteStartClientInputs} and {@link aiSiteStartClientBrief}.\n */\nexport function aiSiteStartAnswersFromClientBuild(intake: ClientBuildIntake): AiSiteStartAnswers {\n const details = aiSiteDetailsOf({\n phone: intake.phone,\n email: intake.email,\n serviceArea: clientBuildServiceArea(intake.towns),\n hours: clientBuildHours(intake.hours),\n })\n return {\n ...AI_SITE_START_ANSWERS,\n siteType: bounded(intake.whatTheyDo, AI_SITE_INPUT_MAX_CHARS),\n // The site exists already and the intake answered for it: what the\n // business does picks its style, as \"Pick for me\" does, and staff change\n // it on the review like any answer.\n ...aiSiteStartStyleAnswer(SITE_STYLE_AUTO),\n phone: details.phone,\n email: details.email,\n serviceArea: details.serviceArea,\n hours: details.hours,\n }\n}\n\n/**\n * The per-site inputs the intake fills, which the guided start's own\n * questions leave empty: the business's name for the header and footer, and\n * the towns it serves as its place.\n *\n * The towns are the place only while no address is given. The Entity reads\n * `city` as the address's own locality wherever there is a street or a\n * postal code (`aiSiteEntity`), so once the answers carry either, `city` is\n * the city the Details step was given with that address, never the towns\n * (AGL-3995). The intake asks no address, so today that is the Details step's\n * own, typed on the review; the towns still reach the site as the areas it\n * serves.\n */\nexport function aiSiteStartClientInputs(\n intake: ClientBuildIntake,\n answers?: Pick<AiSiteStartAnswers, 'street' | 'postalCode' | 'city'> | null,\n): Pick<AiSiteJobInputs, 'businessName' | 'city'> {\n const addressed = Boolean(answers?.street.trim() || answers?.postalCode.trim())\n return {\n businessName: bounded(intake.businessName, AI_SITE_INPUT_MAX_CHARS),\n city: bounded(addressed ? (answers?.city ?? '') : intake.towns, AI_SITE_INPUT_MAX_CHARS),\n }\n}\n\n/**\n * The intake as sentences added to the brief: how to reach the business and\n * when it is open, which the site should say where a visitor looks for them,\n * and the owner's own words, quoted, which the copy should sound like. Empty\n * answers say nothing.\n */\nexport function aiSiteStartClientBrief(intake: ClientBuildIntake): string {\n const name = intake.businessName.trim()\n const towns = intake.towns.trim()\n const phone = intake.phone.trim()\n const email = intake.email.trim()\n const hours = intake.hours.trim()\n const words = intake.ownerWords.trim().replace(/\\s+/g, ' ')\n const sentences: string[] = []\n if (name) sentences.push(`The business is called ${name}.`)\n if (towns) sentences.push(`It serves ${towns}.`)\n const contact = [phone ? `call ${phone}` : '', email ? `email ${email}` : ''].filter(Boolean)\n if (contact.length) {\n sentences.push(`Visitors reach it to ${contact.join(' or ')}; say so wherever the site tells them how to get in touch.`)\n }\n if (hours) sentences.push(`Its hours are ${hours}.`)\n if (words) sentences.push(`In the owner's own words: \"${words}\" Write the copy so it sounds like them.`)\n return sentences.join(' ')\n}\n\n/**\n * What the review says the client build adds beyond its own rows, so staff\n * see the intake is used without it being asked again: the business's name\n * and the owner's own words, which no row shows. The phone, email, towns and\n * hours are the review's Details rows already (AGL-3995), so the note does\n * not say them twice: \"Also from the client's details: Harbor Plumbing and\n * the owner's own words.\"\n */\nexport function aiSiteStartClientNote(intake: ClientBuildIntake): string {\n const parts = [intake.businessName.trim(), intake.ownerWords.trim() ? \"the owner's own words\" : ''].filter(Boolean)\n if (!parts.length) return 'Built from the client’s details.'\n return `Also from the client’s details: ${parts.join(' and ')}.`\n}\n"],"names":["SITE_STYLE_AUTO","weeklyHoursFromText","weeklyHoursToText","AI_SITE_DETAIL_KEYS","AI_SITE_NO_DETAILS","aiSiteDetailProblem","aiSiteDetailsOf","aiSiteKind","aiSiteKindFor","AI_SITE_INSPIRATION_INPUT","aiSiteInspirationInput","aiSiteInspirationLimit","aiSiteInspirationRefusal","aiSiteInspirationUrl","AI_SITE_INPUT_MAX_CHARS","AI_SITE_SUBMISSIONS","aiSitePagesBand","AI_SITE_START_EXAMPLES","id","label","category","blurb","AI_SITE_START_TYPES","AI_SITE_START_ANSWERS","siteType","audience","example","style","kind","pages","submissions","welcomeEmail","city","brand","AI_SITE_START_STYLE_REQUIRED","AI_SITE_START_EXTRA_KEYS","aiSiteStartExtraProblem","key","value","trim","length","code","message","aiSiteStartExtrasGiven","answers","filter","aiSiteStartStyleAnswer","aiSiteStartKind","aiSiteStartExample","find","entry","aiSiteStartRefusal","options","band","freeTaste","Number","isInteger","min","max","includes","problem","aiSiteStartInspirationRefusal","aiSiteStartInspirationTyped","inspiration","map","Boolean","typed","some","aiSiteStartBrief","sentences","push","toLowerCase","join","aiSiteStartInputs","details","businessType","starter","siteKind","businessName","AI_SITE_START_INPUT_KEYS","aiSiteStartInputsOf","inputs","kept","Object","keys","aiSiteStartAnswersFromInputs","text","Math","round","fromEntries","split","slice","bounded","trimmed","replace","cut","space","lastIndexOf","TWELVE_HOUR_TIME","clientBuildHours","hours","lines","time","hour","minutes","half","h","clock","String","padStart","week","day","clientBuildServiceArea","towns","town","aiSiteStartAnswersFromClientBuild","intake","phone","email","serviceArea","whatTheyDo","aiSiteStartClientInputs","addressed","street","postalCode","aiSiteStartClientBrief","name","words","ownerWords","contact","aiSiteStartClientNote","parts"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SAASA,eAAe,QAAQ,qCAAoC;AACpE,SAASC,mBAAmB,EAAEC,iBAAiB,QAAQ,0CAAyC;AAChG,SACEC,mBAAmB,EACnBC,kBAAkB,EAClBC,mBAAmB,EACnBC,eAAe,QAGV,uBAAmB;AAC1B,SAASC,UAAU,EAAEC,aAAa,QAAyB,qBAAiB;AAC5E,SACEC,yBAAyB,EACzBC,sBAAsB,EACtBC,sBAAsB,EACtBC,wBAAwB,EACxBC,oBAAoB,QACf,2BAAuB;AAC9B,SACEC,uBAAuB,EACvBC,mBAAmB,EACnBC,eAAe,QAGV,mBAAe;AAiDtB;;;;CAIC,GACD,OAAO,MAAMC,yBAAwD;IACnE;QACEC,IAAI;QACJC,OAAO;QACPC,UAAU;QACVC,OAAO;IACT;IACA;QACEH,IAAI;QACJC,OAAO;QACPC,UAAU;QACVC,OAAO;IACT;IACA;QACEH,IAAI;QACJC,OAAO;QACPC,UAAU;QACVC,OAAO;IACT;IACA;QACEH,IAAI;QACJC,OAAO;QACPC,UAAU;QACVC,OAAO;IACT;IACA;QACEH,IAAI;QACJC,OAA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AAS0D,sBAAsBd,MAAyB;IAC7D,MAAMe,QAAQ;QAACf,OAAOtC,YAAY,CAACvC,IAAI;QAAI6E,OAAOY,UAAU,CAACzF,IAAI,KAAK,0BAA0B;KAAG,CAACM,MAAM,CAACoB;IAC3G,IAAI,CAACkE,MAAM3F,MAAM,EAAE,OAAO;IAC1B,OAAO,CAAC,gCAAgC,EAAE2F,MAAM3D,IAAI,CAAC,SAAS,CAAC,CAAC;AAClE"}
|
|
@@ -129,5 +129,16 @@ export declare function aiRouteSettings(kind: AiStepKind): {
|
|
|
129
129
|
thinking?: AiThinking;
|
|
130
130
|
effort?: AiEffort;
|
|
131
131
|
};
|
|
132
|
+
/**
|
|
133
|
+
* The model a step runs on held to at least the step's own tier (AGL-4107):
|
|
134
|
+
* `chosen`, the model the job's switch picked, where it serves the step's
|
|
135
|
+
* tier or a higher one; else the provider's own model of that tier. The
|
|
136
|
+
* deployment's `AI_DEFAULT_MODEL` names a model for EVERY step, so a smaller
|
|
137
|
+
* one named there served the balanced step a page brought in asks its design
|
|
138
|
+
* of, and laid the 10/29 import out wrong. A step this holds keeps its tier
|
|
139
|
+
* whatever the environment says; one the catalog does not know is the
|
|
140
|
+
* provider's own model of the tier.
|
|
141
|
+
*/
|
|
142
|
+
export declare function aiModelAtLeastStepTier(kind: AiStepKind, chosen: string | undefined, settings?: AiPluginSettings): string;
|
|
132
143
|
/** The model id alone — what a door records on the meter and the job. */
|
|
133
144
|
export declare function aiModelForStep(kind: AiStepKind, settings?: AiPluginSettings): string;
|
|
@@ -552,6 +552,29 @@ import { aiProviderById, defaultAiProvider } from "./registry.js";
|
|
|
552
552
|
effort: row.effort
|
|
553
553
|
} : {});
|
|
554
554
|
}
|
|
555
|
+
const TIER_RANK = {
|
|
556
|
+
fast: 0,
|
|
557
|
+
balanced: 1,
|
|
558
|
+
deep: 2
|
|
559
|
+
};
|
|
560
|
+
/**
|
|
561
|
+
* The model a step runs on held to at least the step's own tier (AGL-4107):
|
|
562
|
+
* `chosen`, the model the job's switch picked, where it serves the step's
|
|
563
|
+
* tier or a higher one; else the provider's own model of that tier. The
|
|
564
|
+
* deployment's `AI_DEFAULT_MODEL` names a model for EVERY step, so a smaller
|
|
565
|
+
* one named there served the balanced step a page brought in asks its design
|
|
566
|
+
* of, and laid the 10/29 import out wrong. A step this holds keeps its tier
|
|
567
|
+
* whatever the environment says; one the catalog does not know is the
|
|
568
|
+
* provider's own model of the tier.
|
|
569
|
+
*/ export function aiModelAtLeastStepTier(kind, chosen, settings) {
|
|
570
|
+
var _ref;
|
|
571
|
+
const tier = AI_STEP_TIERS[kind];
|
|
572
|
+
const provider = resolveAiProvider(settings);
|
|
573
|
+
const serving = chosen ? aiCatalogEntry(aiServingModelId(chosen)) : undefined;
|
|
574
|
+
if (serving && (!provider || serving.provider === provider.id) && TIER_RANK[serving.tier] >= TIER_RANK[tier]) return serving.id;
|
|
575
|
+
const floor = provider ? aiDefaultModelFor(provider.id, tier) : undefined;
|
|
576
|
+
return (_ref = floor != null ? floor : chosen) != null ? _ref : aiModelForStep(kind, settings);
|
|
577
|
+
}
|
|
555
578
|
/** The model id alone — what a door records on the meter and the job. */ export function aiModelForStep(kind, settings) {
|
|
556
579
|
const route = resolveAiRoute(kind, settings);
|
|
557
580
|
if (!route) {
|