@aglyn/plugins-ai 1.14.0 → 1.15.1
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-build-page.component.js +5 -3
- package/src/lib/components/ai-site-build-page.component.js.map +1 -1
- package/src/lib/components/ai-site-import-finish.component.d.ts +3 -1
- package/src/lib/components/ai-site-import-finish.component.js +3 -3
- package/src/lib/components/ai-site-import-finish.component.js.map +1 -1
- package/src/lib/components/ai-site-import-job.component.d.ts +4 -3
- package/src/lib/components/ai-site-import-job.component.js +141 -43
- package/src/lib/components/ai-site-import-job.component.js.map +1 -1
- package/src/lib/components/ai-site-import-plan.component.d.ts +42 -0
- package/src/lib/components/ai-site-import-plan.component.js +246 -0
- package/src/lib/components/ai-site-import-plan.component.js.map +1 -0
- package/src/lib/components/ai-site-import-start.component.d.ts +3 -1
- package/src/lib/components/ai-site-import-start.component.js +6 -3
- package/src/lib/components/ai-site-import-start.component.js.map +1 -1
- package/src/lib/components/ai-site-start-card.component.js +6 -2
- package/src/lib/components/ai-site-start-card.component.js.map +1 -1
- package/src/lib/components/ai-site-start-steps.component.d.ts +3 -2
- package/src/lib/components/ai-site-start-steps.component.js +12 -5
- package/src/lib/components/ai-site-start-steps.component.js.map +1 -1
- package/src/lib/jobs/ai-job-import-step.d.ts +63 -2
- package/src/lib/jobs/ai-job-import-step.js +372 -22
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-job-layout-language.js +4 -1
- package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
- package/src/lib/jobs/ai-job-page-language.d.ts +23 -2
- package/src/lib/jobs/ai-job-page-language.js +252 -5
- package/src/lib/jobs/ai-job-page-language.js.map +1 -1
- package/src/lib/jobs/ai-job-page-step.d.ts +7 -0
- package/src/lib/jobs/ai-job-page-step.js +75 -12
- package/src/lib/jobs/ai-job-page-step.js.map +1 -1
- package/src/lib/jobs/ai-job-plan-step.js +4 -2
- package/src/lib/jobs/ai-job-plan-step.js.map +1 -1
- package/src/lib/jobs/ai-job-site-look.js +14 -5
- package/src/lib/jobs/ai-job-site-look.js.map +1 -1
- package/src/lib/jobs/ai-job-text-step.d.ts +11 -2
- package/src/lib/jobs/ai-job-text-step.js.map +1 -1
- package/src/lib/jobs/ai-jobs.js +2 -1
- package/src/lib/jobs/ai-jobs.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.d.ts +43 -2
- package/src/lib/jobs/ai-site-import-compile.js +131 -63
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-document.d.ts +25 -1
- package/src/lib/jobs/ai-site-import-document.js +26 -7
- package/src/lib/jobs/ai-site-import-document.js.map +1 -1
- package/src/lib/jobs/ai-site-import-honesty.d.ts +65 -0
- package/src/lib/jobs/ai-site-import-honesty.js +271 -0
- package/src/lib/jobs/ai-site-import-honesty.js.map +1 -0
- package/src/lib/jobs/ai-site-import-improve.d.ts +286 -0
- package/src/lib/jobs/ai-site-import-improve.js +1281 -0
- package/src/lib/jobs/ai-site-import-improve.js.map +1 -0
- package/src/lib/jobs/ai-site-import-look.d.ts +4 -0
- package/src/lib/jobs/ai-site-import-look.js +16 -6
- package/src/lib/jobs/ai-site-import-look.js.map +1 -1
- package/src/lib/jobs/ai-site-import-pictures.d.ts +83 -0
- package/src/lib/jobs/ai-site-import-pictures.js +261 -0
- package/src/lib/jobs/ai-site-import-pictures.js.map +1 -0
- package/src/lib/jobs/ai-site-import-plan.d.ts +78 -0
- package/src/lib/jobs/ai-site-import-plan.js +627 -0
- package/src/lib/jobs/ai-site-import-plan.js.map +1 -0
- package/src/lib/jobs/ai-site-import-wording.js +2 -5
- package/src/lib/jobs/ai-site-import-wording.js.map +1 -1
- package/src/lib/layout-language/ai-layout-compiler.d.ts +6 -0
- package/src/lib/layout-language/ai-layout-compiler.js +10 -6
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/layout-language/ai-layout-design.d.ts +9 -0
- package/src/lib/layout-language/ai-layout-design.js +29 -3
- package/src/lib/layout-language/ai-layout-design.js.map +1 -1
- package/src/lib/layout-language/ai-layout-frame-source.d.ts +5 -0
- package/src/lib/layout-language/ai-layout-frame-source.js +4 -2
- package/src/lib/layout-language/ai-layout-frame-source.js.map +1 -1
- package/src/lib/layout-language/ai-layout-frame.d.ts +2 -0
- package/src/lib/layout-language/ai-layout-frame.js +20 -12
- package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
- package/src/lib/layout-language/ai-layout-language.d.ts +8 -0
- package/src/lib/layout-language/ai-layout-language.js +7 -3
- package/src/lib/layout-language/ai-layout-language.js.map +1 -1
- package/src/lib/model/ai-credit-estimate.d.ts +16 -0
- package/src/lib/model/ai-credit-estimate.js +14 -0
- package/src/lib/model/ai-credit-estimate.js.map +1 -1
- package/src/lib/model/ai-site-import-fidelity.d.ts +64 -0
- package/src/lib/model/ai-site-import-fidelity.js +380 -0
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
- package/src/lib/model/ai-site-import-ledger.d.ts +82 -0
- package/src/lib/model/ai-site-import-ledger.js +254 -0
- package/src/lib/model/ai-site-import-ledger.js.map +1 -0
- package/src/lib/model/ai-site-import-view.d.ts +113 -7
- package/src/lib/model/ai-site-import-view.js +174 -16
- package/src/lib/model/ai-site-import-view.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +253 -3
- package/src/lib/model/ai-site-import.js +371 -25
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/model/ai-site-job.js +4 -0
- package/src/lib/model/ai-site-job.js.map +1 -1
- package/src/lib/model/ai-site-kinds.d.ts +2 -0
- package/src/lib/model/ai-site-kinds.js +7 -0
- package/src/lib/model/ai-site-kinds.js.map +1 -1
- package/src/lib/model/ai-site-look.d.ts +14 -5
- package/src/lib/model/ai-site-look.js +22 -16
- package/src/lib/model/ai-site-look.js.map +1 -1
- package/src/lib/model/ai-site-start.d.ts +37 -7
- package/src/lib/model/ai-site-start.js +54 -10
- package/src/lib/model/ai-site-start.js.map +1 -1
- package/src/lib/model/ai-site-starter-look.d.ts +69 -0
- package/src/lib/model/ai-site-starter-look.js +90 -0
- package/src/lib/model/ai-site-starter-look.js.map +1 -0
- package/src/lib/runtime/ai-doctrine-validators.d.ts +7 -0
- package/src/lib/runtime/ai-doctrine-validators.js +3 -2
- package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
- package/src/lib/runtime/ai-doctrine.d.ts +10 -0
- package/src/lib/runtime/ai-doctrine.js +16 -2
- package/src/lib/runtime/ai-doctrine.js.map +1 -1
- package/src/lib/server/ai-jobs-resume.js +12 -3
- package/src/lib/server/ai-jobs-resume.js.map +1 -1
- package/src/lib/server/ai-jobs-route.js +5 -1
- package/src/lib/server/ai-jobs-route.js.map +1 -1
- package/src/lib/server/ai-site-import-route.d.ts +6 -0
- package/src/lib/server/ai-site-import-route.js +8 -1
- package/src/lib/server/ai-site-import-route.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +46 -7
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +260 -14
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-improve-answers.d.ts +33 -0
- package/src/lib/site-import/fixtures/site-import-improve-answers.js +457 -0
- package/src/lib/site-import/fixtures/site-import-improve-answers.js.map +1 -0
- package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +29 -0
- package/src/lib/site-import/fixtures/site-layout-recordings.js +26 -0
- package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
- package/src/lib/site-import/site-import-flag.d.ts +17 -0
- package/src/lib/site-import/site-import-flag.js +15 -0
- package/src/lib/site-import/site-import-flag.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-site-import-look.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\n/*==========================================\n * THE SITE BROUGHT IN KEEPS ITS OWN LOOK (AGL-4084).\n *\n * The first wave's look pass, before the header and footer, with no model:\n *\n * - **The theme.** The owner's own home page is read once more as AglynBot,\n * with the edge headers a site this platform serves gets whether or not a\n * caller hands them in (AGL-4108: production handed none, our own edge\n * challenged the read, and the 10/29 site kept the starter's indigo), and\n * the signals a guided start reads off the sites a person likes\n * (AGL-3975: colors, ground, type mood, corners, buttons, cards, header,\n * density, motion) pin the look. What the reader found of the source's\n * look (AGL-4106) pins it closer (AGL-4108): its buttons' fill is the\n * brand and its links' color the accent, its page's ground is the site's,\n * its eyebrows' own color the theme's third and its eyebrows spaced\n * capitals with no line before them (AGL-4138), and its own font family\n * is the site's wherever the theme font catalog has it, else a pairing of\n * its type mood. The look is drawn and saved\n * exactly as a guided start's (`aiSiteStyleFor`, `aiSaveSiteTheme`): a\n * built-in base plus the brand colors and fonts, every color held to the\n * theme's reading checks. A site whose owner already chose a theme keeps\n * it.\n * - **The logo.** The source header's logo, as the source draws it, into the\n * site's media library once: an SVG is turned into a PNG 192 pixels tall\n * (the library takes pictures, not drawings), a picture is kept as it is.\n * - **The listing.** The home page's own title, description and share\n * picture become the site's listing, only while the site still has the\n * listing it was created with: an owner's own words are never written\n * over.\n *\n * A bare read never leaves the stock theme (AGL-4152). A source with no color\n * of its own to read (no colorful button, link or declared palette) takes its brand from its logo's dominant colorful hue, then its hero photo's,\n * read from the library's copy. With no picture to read either, what its\n * stylesheets use most decides, and with none of that the site still gets the\n * seed's own look for its kind of site, as a guided start with no answer does,\n * and the look says so (`from`). An owner's chosen theme is still kept.\n *\n * Nothing here fails a wave: a logo that cannot be brought in leaves the header\n * its name.\n *=========================================*/\n\nimport type { PluginMediaIngest } from '@aglyn/aglyn/plugin-manager/plugin-media-ingest'\nimport { themeFontFacts, type ThemeFontFacts } from '@aglyn/aglyn/plugin-manager/plugin-theme-font-catalog'\nimport { syncHostProjectionForMembers } from '@aglyn/tenant-data-admin/server/host-memberships'\nimport { aiSiteListingSeeded } from '../model/ai-site-entity'\nimport type { AiSiteImportFinish, AiSiteImportHome, AiSiteImportLook, AiSiteImportLookFrom, AiSiteImportPhoto, SiteImportLookFacts } from '../model/ai-site-import'\nimport { aiSiteKindFor } from '../model/ai-site-kinds'\nimport { aiHexOklch, aiSiteSeed, aiSiteStyleFor, type AiSiteLookPins, type AiSiteSourceFont, type AiSiteStyle } from '../model/ai-site-look'\nimport { aiSiteIsStarterSrc } from '../model/ai-site-photos'\nimport { AGLYN_BOT_USER_AGENT, siteImportOrigins, type SiteImportCrawlSeams } from '../site-import/site-import-crawl'\nimport { siteImportReadStylesheets } from '../site-import/site-import-css'\nimport { NO_SITE_IMPORT_HEADERS, siteImportEdgeHeadersFor, type SiteImportHeadersFor } from '../site-import/site-import-edge'\nimport { siteImportStylesheetLinks } from '../site-import/site-import-html'\nimport { bringInSiteImportPhotos, siteImportImageKey, siteImportLogoUrl } from '../site-import/site-import-images'\nimport { aiSaveSiteTheme, aiWorkspaceSiteStyles } from './ai-job-site-look'\nimport { aiSiteInspirationLookPins } from './ai-site-inspiration'\nimport { aiSiteInspirationSignals, type AiSiteInspirationSite } from './ai-site-inspiration-signals'\nimport {\n AI_THEME_BRAND_COLORS_PER_SOURCE,\n AI_THEME_REFERENCE_MAX_BYTES,\n AI_THEME_THEME_COLOR_WEIGHT,\n fetchPublicTextDetailed,\n logoMediaLocation,\n rankBrandColors,\n readLogoColors,\n type AiReferencePage,\n type PublicFetchOptions,\n type PublicFetchResult,\n} from './ai-theme-brand-inputs'\n\n/** The height an SVG logo is drawn at as a picture: crisp at twice the header's 40. */\nexport const AI_SITE_IMPORT_LOGO_HEIGHT = 192\n\n/** The largest logo file read. */\nexport const AI_SITE_IMPORT_LOGO_MAX_BYTES = 1024 * 1024\n\n/** One read's own clock in the look pass. */\nconst LOOK_READ_MS = 8_000\n\n/** The clock on starting the home page's stylesheets' reads: however many it links, a pass waits no longer than this and one read's own. */\nconst LOOK_SHEETS_MS = 12_000\n\ntype Fetch = (url: string, options: PublicFetchOptions) => Promise<PublicFetchResult>\n\n/**\n * The home page and its stylesheets, every one to the crawl's byte budget\n * (AGL-4152), read as AglynBot (AGL-4084).\n * `headersFor` is asked for every request and every redirect hop, as the\n * crawl asks it (`aiSiteImportLookHeaders`: the edge header only to the\n * site's own origins). `null` when the page cannot be read.\n */\nexport async function readSiteImportLookPage(\n url: string,\n input: { fetch?: Fetch; headersFor?: SiteImportHeadersFor | null; signal?: AbortSignal },\n): Promise<AiReferencePage | null> {\n const fetchText = input.fetch ?? fetchPublicTextDetailed\n const headersFor = input.headersFor ?? null\n const read = (address: string, maxBytes: number, accept: RegExp) =>\n fetchText(address, {\n maxBytes,\n accept,\n userAgent: AGLYN_BOT_USER_AGENT,\n timeoutMs: LOOK_READ_MS,\n ...(input.signal ? { signal: input.signal } : {}),\n ...(headersFor ? { headersFor } : {}),\n }).catch(() => null)\n const page = await read(url, AI_THEME_REFERENCE_MAX_BYTES, /text\\/html|application\\/xhtml\\+xml/i)\n if (!page?.ok) return null\n const startedAt = Date.now()\n const stylesheets = await siteImportReadStylesheets(siteImportStylesheetLinks(page.text, page.url), (sheet, maxBytes) => read(sheet, maxBytes, /text\\/css|text\\/plain/i), {\n outOfTime: () => Date.now() - startedAt >= LOOK_SHEETS_MS,\n })\n return { url: page.url, html: page.text, stylesheets }\n}\n\nconst SOLID_HEX = /(?<!&)#(?:[0-9a-f]{6}|[0-9a-f]{3})(?![0-9a-z])/gi\nconst SOLID_RGB = /rgba?\\(\\s*(\\d{1,3})\\s*[,\\s]\\s*(\\d{1,3})\\s*[,\\s]\\s*(\\d{1,3})\\s*(?:[,/]\\s*([\\d.]+%?)\\s*)?\\)/gi\nconst THEME_COLOR = /<meta\\b[^>]*\\bname\\s*=\\s*[\"']?theme-color\\b[^>]*\\bcontent\\s*=\\s*[\"']?\\s*(#[0-9a-f]{3,6})/gi\n\nconst hexOf = (value: string): string | null => {\n const raw = value.trim().toLowerCase()\n if (/^#[0-9a-f]{6}$/.test(raw)) return raw\n if (/^#[0-9a-f]{3}$/.test(raw)) return `#${raw[1]}${raw[1]}${raw[2]}${raw[2]}${raw[3]}${raw[3]}`\n return null\n}\n\n/**\n * A source's brand colors as it DRAWS them (AGL-4084): the colors its markup\n * and stylesheets use solid, most used first, the colorful before the greys.\n * A translucent color is a tint of one (a hover, a focus ring), never a use\n * of it, so it is not counted: aglyn.com's focus rings, a light blue at a\n * quarter strength, outnumbered the deep blue its buttons and links are\n * drawn in, which the theme reader would otherwise take as its brand.\n */\nexport function aiSiteImportBrandColors(page: Pick<AiReferencePage, 'html' | 'stylesheets'>): string[] {\n const weights = new Map<string, number>()\n const add = (hex: string | null, weight = 1) => {\n if (hex) weights.set(hex, (weights.get(hex) ?? 0) + weight)\n }\n for (const match of page.html.matchAll(THEME_COLOR)) add(hexOf(match[1] ?? ''), AI_THEME_THEME_COLOR_WEIGHT)\n for (const text of [page.html, ...page.stylesheets]) {\n for (const match of text.matchAll(SOLID_HEX)) add(hexOf(match[0]))\n for (const match of text.matchAll(SOLID_RGB)) {\n const alpha = match[4]\n if (alpha !== undefined && (alpha.endsWith('%') ? Number(alpha.slice(0, -1)) < 100 : Number(alpha) < 1)) continue\n const channels = [match[1], match[2], match[3]].map((value) => Math.min(255, Number(value)))\n add(`#${channels.map((value) => value.toString(16).padStart(2, '0')).join('')}`)\n }\n }\n return rankBrandColors(weights, AI_THEME_BRAND_COLORS_PER_SOURCE)\n}\n\n/** How colorful a color must be to carry a brand: the inspiration reader's own floor. */\nconst COLORFUL_CHROMA = 0.04\n\nconst colorful = (hex: string | null | undefined): hex is string => !!hex && /^#[0-9a-f]{6}$/i.test(hex) && aiHexOklch(hex).C >= COLORFUL_CHROMA\n\n/**\n * The brand and accent a source's look facts give (AGL-4108): the fill of\n * its filled buttons as the brand, the color of its links as the accent\n * where it is a color of its own, and the reverse where its buttons are not\n * colorful. The theme draws the brand at the nearest shade of it that reads\n * (`aiSiteColors`): aglyn.com's light blue buttons, under white words at\n * 2.4:1, come out at the deeper blue of its own links.\n */\nexport function aiSiteImportBrandOf(facts: (Pick<SiteImportLookFacts, 'buttonFill' | 'link'> & Pick<Partial<SiteImportLookFacts>, 'palette'>) | null | undefined): { brand: string; accent: string | null } | null {\n const fill = colorful(facts?.buttonFill) ? (facts?.buttonFill as string).toLowerCase() : null\n const link = colorful(facts?.link) ? (facts?.link as string).toLowerCase() : null\n // What its root declares its brand to be (AGL-4152), where nothing on its home page draws it.\n const palette = (facts?.palette ?? []).filter(colorful).map((hex) => hex.toLowerCase())\n const brand = fill ?? link ?? palette[0]\n if (!brand) return null\n return { brand, accent: (link && link !== brand ? link : palette.find((hex) => hex !== brand)) ?? null }\n}\n\nconst solidHex = (value: string | null | undefined): string | null => (value && /^#[0-9a-f]{6}$/i.test(value) ? value.toLowerCase() : null)\n\n/**\n * The look a source's signals pin (AGL-4084), drawn the way a guided start's\n * is: the kind of site its own description says, the import's seed, its\n * strongest color as the brand. What the reader found of its look\n * (`facts`, AGL-4108) pins it closer: its buttons' fill as the brand and its\n * links' color as the accent, its eyebrows' own color as the third, and its\n * own fonts where the catalog has them (`fonts`). Its pictures' colors\n * (`pictures`, AGL-4152) stand in for a brand where its facts show none. `null`\n * where nothing showed a color to carry a brand, unless asked to draw the look\n * from the seed alone (`draw`), which the pass does rather than leave the site\n * in the stock theme.\n *\n * How the owner asked the site to be finished (AGL-4152) says what else:\n * - **Keep my site** (`keep`, and an import that names none) pins the rest\n * of its look as it draws it: its page's ground and its dark bands', its\n * buttons' corners and case and their own fill and words, every inspiration\n * signal, and its eyebrows set as spaced capitals.\n * - **Improve it** (`improve`) pins only the brand, accent and third colors\n * and the fonts, so the base that suits the kind of site shows with its own\n * corners, buttons, grounds and eyebrows.\n */\nexport function aiSiteImportStyle(\n site: AiSiteInspirationSite | null,\n input: {\n seed: number\n description: string\n avoid?: readonly AiSiteStyle[]\n facts?: SiteImportLookFacts | null\n fonts?: AiSiteStyle['sourceFonts']\n finish?: AiSiteImportFinish | null\n pictures?: readonly string[]\n draw?: boolean\n },\n): AiSiteStyle | null {\n const facts = input.facts ?? null\n const finish: AiSiteImportFinish = input.finish === 'improve' ? 'improve' : 'keep'\n const pictured = input.pictures?.[0] ? { brand: input.pictures[0].toLowerCase(), accent: input.pictures[1]?.toLowerCase() ?? null } : null\n const own = aiSiteImportBrandOf(facts) ?? pictured\n if (!site && !own && !input.draw) return null\n const kind = aiSiteKindFor(input.description)\n const signals = site ? aiSiteInspirationLookPins({ v: 1, sites: [site], unread: 0 }, { kind, seed: input.seed }) : {}\n // Improve keeps the brand's colors and its type, and nothing else its source draws.\n const pins: AiSiteLookPins =\n finish === 'improve'\n ? {\n ...(signals.brand ? { brand: signals.brand } : {}),\n ...(signals.hue !== undefined ? { hue: signals.hue } : {}),\n ...(signals.accent !== undefined ? { accent: signals.accent } : {}),\n ...(signals.fonts ? { fonts: signals.fonts } : {}),\n }\n : signals\n if (own) {\n pins.brand = own.brand\n pins.hue = Math.round(aiHexOklch(own.brand).h) % 360\n if (own.accent) pins.accent = Math.round(aiHexOklch(own.accent).h) % 360\n }\n // Its buttons' corners round the theme's shape where its stylesheets did not say (AGL-4108).\n const radius = facts?.buttonRadius\n if (finish === 'keep' && typeof radius === 'number' && Number.isFinite(radius) && radius >= 0) {\n pins.buttons ??= radius >= 24 ? 'pill' : radius <= 2 ? 'square' : 'rounded'\n pins.corners ??= radius <= 2 ? 'sharp' : radius <= 10 ? 'soft' : radius <= 20 ? 'round' : 'pill'\n }\n // Its eyebrows as it sets them (AGL-4138): spaced capitals with no line before them — the\n // reader takes an eyebrow only in capitals, and no mark a page draws before one is a word of\n // it — and their own color, where it is one, as the theme's third.\n if (facts && finish === 'keep') pins.eyebrow = 'caps'\n if (colorful(facts?.eyebrow)) pins.tertiary = (facts?.eyebrow as string).toLowerCase()\n if (!pins.brand && !input.draw) return null\n const style = aiSiteStyleFor({ kind, answer: {}, seed: input.seed, brand: pins.brand, avoid: input.avoid ?? [], pins })\n const fonts = input.fonts ? { sourceFonts: input.fonts } : {}\n if (finish === 'improve') return { ...style, finish, ...fonts }\n // Keep my site (AGL-4152): its grounds, its buttons' case, and its filled buttons as it draws them.\n const page = solidHex(facts?.background)\n const darkPage = solidHex(facts?.darkBackground)\n const buttonFill = solidHex(facts?.buttonFill)\n const buttonText = buttonFill ? solidHex(facts?.buttonText) : null\n const caseOf = (value: string | null | undefined) => (value === 'upper' || value === 'none' ? value : null)\n const buttonCase = caseOf(facts?.buttonCase)\n const outlinedCase = caseOf(facts?.outlinedCase)\n const textCase = caseOf(facts?.textCase)\n const paper = solidHex(facts?.paperBackground)\n const darkPaper = solidHex(facts?.darkPaper)\n const outlinedFill = solidHex(facts?.outlinedFill)\n const buttonOutline = solidHex(facts?.buttonOutline)\n return {\n ...style,\n finish,\n ...(page ? { page } : {}),\n ...(darkPage ? { darkPage } : {}),\n ...(paper ? { paper } : {}),\n ...(darkPaper ? { darkPaper } : {}),\n ...(buttonCase ? { buttonCase } : {}),\n ...(outlinedCase ? { outlinedCase } : {}),\n ...(textCase ? { textCase } : {}),\n ...(outlinedFill ? { outlinedFill } : {}),\n ...(buttonOutline ? { buttonOutline } : {}),\n ...(buttonFill ? { buttonFill } : {}),\n ...(buttonText ? { buttonText } : {}),\n ...fonts,\n }\n}\n\n/** A family's facts, as the theme font catalog answers them. */\nexport type AiSiteImportFontFacts = (family: string) => Promise<ThemeFontFacts | undefined>\n\n/**\n * The source's own fonts (AGL-4108), each where the theme font catalog has\n * the family (Google Fonts', as the fonts plugin registers it), or the\n * source loads it from Google Fonts itself: its body's and its headings'.\n * `null` where its body's family is neither, and the pairing of the source's\n * type mood sets the site instead.\n */\nexport async function aiSiteImportSourceFonts(\n facts: Pick<SiteImportLookFacts, 'fonts'> | null | undefined,\n lookup: AiSiteImportFontFacts = themeFontFacts,\n): Promise<AiSiteStyle['sourceFonts']> {\n const fonts = facts?.fonts\n if (!fonts?.body) return null\n const loaded = new Set(fonts.google.map((family) => family.toLowerCase()))\n const resolve = async (family: string | null): Promise<AiSiteSourceFont | null> => {\n if (!family) return null\n const known = await lookup(family).catch(() => undefined)\n if (known) return { family: known.family, category: known.category, weights: [...known.weights] }\n return loaded.has(family.toLowerCase()) ? { family, category: 'sans-serif', weights: [] } : null\n }\n const body = await resolve(fonts.body)\n if (!body) return null\n const heading = fonts.headings && fonts.headings.toLowerCase() !== body.family.toLowerCase() ? await resolve(fonts.headings) : null\n return { body, heading }\n}\n\n/**\n * The site's listing in the home page's own words (AGL-4084), as field\n * paths: its title and description each only where the site still has the\n * one it was created with, so an owner's own listing is never written over.\n * `{}` with nothing to write.\n */\nexport function aiSiteImportListingUpdates(seo: unknown, displayName: unknown, home: Pick<AiSiteImportHome, 'title' | 'description'>): Record<string, string> {\n const seeded = aiSiteListingSeeded(seo, displayName)\n const current = (seo && typeof seo === 'object' ? seo : {}) as Record<string, unknown>\n const updates: Record<string, string> = {}\n const title = home.title.replace(/\\s+/g, ' ').trim()\n const description = home.description.replace(/\\s+/g, ' ').trim()\n if (title && seeded.title && title !== current['title']) updates['seo.title'] = title\n if (description && seeded.description && description !== current['description']) updates['seo.description'] = description\n return updates\n}\n\n/** Whether the site's share picture is still open: none, or the starter's (AGL-3988). */\nfunction shareOpen(seo: unknown): boolean {\n const image = (seo as { image?: unknown } | null | undefined)?.image\n if (image === undefined || image === null) return true\n return typeof image === 'string' && (!image.trim() || aiSiteIsStarterSrc(image))\n}\n\n/** Turns an SVG drawing into a PNG of a height; `null` where it cannot. */\nexport type AiSiteImportRasterize = (svg: Uint8Array, height: number) => Promise<Uint8Array | null>\n\nexport interface AiSiteImportLookDeps {\n fetch?: Fetch\n /** The edge headers for the source, asked with its domain; absent, the edge is asked as the crawl asks it (AGL-4108). */\n headersFor?: SiteImportCrawlSeams['headersFor']\n /** The edge's own answer, per address (`siteImportEdgeHeadersFor`), where no `headersFor` is given. */\n edgeHeadersFor?: typeof siteImportEdgeHeadersFor\n /** A family's facts in the theme font catalog (`themeFontFacts`). */\n fontFacts?: AiSiteImportFontFacts\n save?: typeof aiSaveSiteTheme\n others?: typeof aiWorkspaceSiteStyles\n ingest?: PluginMediaIngest | null\n rasterize?: AiSiteImportRasterize\n /** The site's document, as the listing reads it. */\n readHost?: (firestore: FirebaseFirestore.Firestore, hostId: string) => Promise<Record<string, unknown> | null>\n writeHost?: (firestore: FirebaseFirestore.Firestore, hostId: string, updates: Record<string, unknown>) => Promise<void>\n /** Re-fans the rows every site list reads a site's icon from (AGL-3972), after the look sets one. */\n syncMemberships?: (orgId: string, hostId: string) => Promise<void>\n /** A picture in the library's dominant colors (AGL-4152); `null` where it cannot be read. */\n pictureColors?: AiSiteImportPictureColors\n}\n\n/** A picture in the site's library's dominant colors (`dominantColorsFromPixels`). */\nexport type AiSiteImportPictureColors = (photo: AiSiteImportPhoto, input: { firestore: FirebaseFirestore.Firestore; hostId: string; orgId: string; signal?: AbortSignal }) => Promise<readonly string[] | null>\n\n/** The library's copy of a picture, decoded where `sharp` is shipped (`readLogoColors`, AGL-4048). */\nconst pictureColorsOf: AiSiteImportPictureColors = async (photo, { firestore, hostId, orgId, signal }) => {\n const location = logoMediaLocation(photo.src, hostId, orgId)\n if (!location) return null\n return readLogoColors(firestore, location, hostId, AbortSignal.any([AbortSignal.timeout(LOOK_READ_MS), ...(signal ? [signal] : [])]))\n}\n\n/** A read of a picture's colorful colors: none where it has none, or cannot be read. */\nasync function colorfulColorsOf(photo: AiSiteImportPhoto, read: AiSiteImportPictureColors, input: Parameters<AiSiteImportPictureColors>[1]): Promise<string[]> {\n const colors = await read(photo, input).catch((error: unknown) => {\n console.warn('[site-import] a picture’s colors could not be read', { hostId: input.hostId, error })\n return null\n })\n return (colors ?? []).filter(colorful).map((hex) => hex.toLowerCase())\n}\n\n/** The most pictures the home page's menus bring into the library (AGL-4139). */\nexport const AI_SITE_IMPORT_MENU_PICTURES = 4\n\n/** The pictures the home page's menus show (AGL-4139), each once, the first few: a featured card's. */\nexport function aiSiteImportMenuPictures(home: Pick<AiSiteImportHome, 'nav'>): Array<{ url: string; alt: string }> {\n const seen = new Set<string>()\n const out: Array<{ url: string; alt: string }> = []\n for (const group of home.nav?.items ?? []) {\n for (const column of group.columns ?? []) {\n if (!column.image || seen.has(column.image.url) || out.length >= AI_SITE_IMPORT_MENU_PICTURES) continue\n seen.add(column.image.url)\n out.push({ url: column.image.url, alt: column.image.alt })\n }\n }\n return out\n}\n\n/** Whether the site still has no icon of its own (AGL-4139): an owner's is never written over. */\nfunction faviconOpen(seo: unknown): boolean {\n const favicon = (seo as { favicon?: unknown } | null | undefined)?.favicon\n return favicon === undefined || favicon === null || (typeof favicon === 'string' && !favicon.trim())\n}\n\n\nexport interface AiSiteImportLookInput {\n firestore: FirebaseFirestore.Firestore\n hostId: string\n orgId: string\n /** The member the logo and the share picture are stored as. */\n uid: string\n /** The import job's id, which the look's seed is drawn from. */\n jobId: string\n domain: string\n home: AiSiteImportHome\n at: string\n signal?: AbortSignal\n /** How the site is finished (AGL-4152): Keep my site keeps more of the source's look. Absent is `keep`. */\n finish?: AiSiteImportFinish | null\n}\n\nasync function readHostDoc(firestore: FirebaseFirestore.Firestore, hostId: string): Promise<Record<string, unknown> | null> {\n const snapshot = await firestore.collection('hosts').doc(hostId).get()\n return snapshot.exists ? ((snapshot.data() ?? {}) as Record<string, unknown>) : null\n}\n\nasync function writeHostDoc(firestore: FirebaseFirestore.Firestore, hostId: string, updates: Record<string, unknown>): Promise<void> {\n await firestore.collection('hosts').doc(hostId).update(updates)\n}\n\n/** Turns an SVG into a PNG in this process, where `sharp` is shipped; `null` where it is not. */\nasync function rasterizeHere(svg: Uint8Array, height: number): Promise<Uint8Array | null> {\n const images = await import('./ai-image-reads')\n const origin = images.aiImageReadsOrigin()\n if (origin) return images.requestAiLogoRaster(origin, svg, height)\n return images.rasterizeAiLogoSvg(svg, height)\n}\n\n/**\n * The source header's logo in the site's library (AGL-4084), once: the copy\n * a page already brought in is reused by its key. An SVG becomes a PNG.\n * `null` where it cannot be brought in, and the header then prints the name.\n */\nexport async function aiSiteImportLogo(\n input: { hostId: string; uid: string; domain: string; logo: NonNullable<AiSiteImportHome['brand']['logo']>; alt: string; headersFor?: SiteImportHeadersFor | null; signal?: AbortSignal },\n deps: { fetch?: Fetch; ingest: PluginMediaIngest | null; rasterize?: AiSiteImportRasterize },\n): Promise<AiSiteImportPhoto | null> {\n const ingest = deps.ingest\n const url = siteImportLogoUrl(input.logo.url)\n if (!ingest?.findImportedPhoto || !url) return null\n const sourceKey = siteImportImageKey(url)\n try {\n const held = await ingest.findImportedPhoto({ hostId: input.hostId, sourceKey })\n if (held) return { mediaId: held.mediaId, src: held.src, alt: input.alt, from: url, ...(held.width ? { width: held.width } : {}), ...(held.height ? { height: held.height } : {}) }\n const fetched = await (deps.fetch ?? fetchPublicTextDetailed)(url, {\n maxBytes: AI_SITE_IMPORT_LOGO_MAX_BYTES,\n accept: /^image\\//i,\n acceptHeader: 'image/svg+xml,image/png,image/webp,image/jpeg;q=0.9',\n userAgent: AGLYN_BOT_USER_AGENT,\n timeoutMs: LOOK_READ_MS,\n refuseOver: true,\n binary: true,\n ...(input.signal ? { signal: input.signal } : {}),\n ...(input.headersFor ? { headersFor: input.headersFor } : {}),\n })\n if (!fetched.ok || !fetched.data?.byteLength) return null\n const type = fetched.contentType.split(';')[0].trim().toLowerCase()\n let bytes: Uint8Array | null = fetched.data\n let contentType = type\n if (type === 'image/svg+xml' || input.logo.type === 'svg') {\n bytes = await (deps.rasterize ?? rasterizeHere)(fetched.data, AI_SITE_IMPORT_LOGO_HEIGHT).catch(() => null)\n contentType = 'image/png'\n } else if (!/^image\\/(?:png|jpeg|webp|gif)$/.test(type)) {\n return null\n }\n if (!bytes?.byteLength) return null\n const stored = await ingest.ingest({\n hostId: input.hostId,\n uid: input.uid,\n fileName: `logo.${contentType === 'image/jpeg' ? 'jpg' : contentType.split('/')[1]}`,\n contentType,\n bytes,\n ...(input.alt ? { alt: input.alt.slice(0, 250) } : {}),\n importedFrom: { key: sourceKey, url, domain: input.domain },\n })\n if (!stored.ok) return null\n return { mediaId: stored.mediaId, src: stored.src, alt: input.alt, from: url, ...(stored.width ? { width: stored.width } : {}), ...(stored.height ? { height: stored.height } : {}) }\n } catch (error) {\n console.warn('[site-import] the logo could not be brought in', { hostId: input.hostId, error })\n return null\n }\n}\n\n/** The look pass (AGL-4084): the theme, the logo and the listing, from the owner's own home page. No model. */\nexport async function aiRunSiteImportLook(input: AiSiteImportLookInput, deps: AiSiteImportLookDeps = {}): Promise<AiSiteImportLook> {\n const { firestore, hostId, home } = input\n const headersFor = await aiSiteImportLookHeaders(input.domain, deps)\n const seed = aiSiteSeed(input.jobId)\n const page = await readSiteImportLookPage(home.url, { ...(deps.fetch ? { fetch: deps.fetch } : {}), headersFor, ...(input.signal ? { signal: input.signal } : {}) })\n // The source's own signals, its brand colors as it draws them solid.\n const signals = page ? aiSiteInspirationSignals(page) : null\n const site = signals && page ? { ...signals, colors: aiSiteImportBrandColors(page) } : signals\n const avoid = await (deps.others ?? aiWorkspaceSiteStyles)(firestore, { orgId: input.orgId, hostId })\n // What the reader found of its look, its buttons, ground and fonts (AGL-4108).\n const facts = home.look ?? null\n const fonts = await aiSiteImportSourceFonts(facts, deps.fontFacts)\n const ingest = deps.ingest ?? null\n const logo = home.brand.logo\n ? await aiSiteImportLogo(\n { hostId, uid: input.uid, domain: input.domain, logo: home.brand.logo, alt: home.siteName || home.brand.text, headersFor, ...(input.signal ? { signal: input.signal } : {}) },\n { ingest, ...(deps.fetch ? { fetch: deps.fetch } : {}), ...(deps.rasterize ? { rasterize: deps.rasterize } : {}) },\n )\n : null\n // No color of its own (AGL-4152): its logo's colorful colors, else its hero photo's, else its share picture's.\n let pictures: string[] = []\n let from: AiSiteImportLookFrom = 'source'\n if (!aiSiteImportBrandOf(facts)) {\n const read = deps.pictureColors ?? pictureColorsOf\n const asked = { firestore, hostId, orgId: input.orgId, ...(input.signal ? { signal: input.signal } : {}) }\n const ofLogo = logo ? await colorfulColorsOf(logo, read, asked) : []\n if (ofLogo.length) {\n pictures = ofLogo.slice(0, 2)\n from = 'logo'\n } else {\n for (const image of [home.hero, home.ogImage ? { url: home.ogImage, alt: '' } : null]) {\n if (!image) continue\n const { assets } = await bringInSiteImportPhotos(\n { hostId, uid: input.uid, domain: input.domain, images: [image], deadlineAt: Date.now() + LOOK_READ_MS, ...(input.signal ? { signal: input.signal } : {}) },\n { ingest, ...(deps.fetch ? { fetch: deps.fetch } : {}) },\n )\n const ofPhoto = assets[0] ? await colorfulColorsOf(assets[0], read, asked) : []\n if (!ofPhoto.length) continue\n pictures = ofPhoto.slice(0, 1)\n from = 'photo'\n break\n }\n }\n }\n const described = { seed, description: `${home.siteName} ${home.description}`, avoid, facts, fonts, finish: input.finish ?? null, pictures }\n let style = aiSiteImportStyle(site, described)\n // Nothing anywhere to read a color from: the seed's look for its kind, never the stock theme.\n if (!style) {\n style = aiSiteImportStyle(site, { ...described, draw: true }) as AiSiteStyle\n from = 'seed'\n }\n const saved = await (deps.save ?? aiSaveSiteTheme)(firestore, { hostId, jobId: input.jobId, style })\n if (saved.write === 'missing') throw new Error(`site ${hostId} vanished while its look was brought in`)\n const theme: AiSiteImportLook['theme'] = saved.write === 'kept' ? 'kept' : 'applied'\n // The pictures its menus show, in the library like its pages' photos (AGL-4139), for the header's panels.\n const menuImages = aiSiteImportMenuPictures(home)\n const menuPictures = menuImages.length\n ? (\n await bringInSiteImportPhotos(\n { hostId, uid: input.uid, domain: input.domain, images: menuImages, deadlineAt: Date.now() + LOOK_READ_MS, ...(input.signal ? { signal: input.signal } : {}) },\n { ingest, ...(deps.fetch ? { fetch: deps.fetch } : {}) },\n )\n ).assets\n : []\n // The site's listing in its own words, only over the one it was created with.\n let seo = false\n const host = await (deps.readHost ?? readHostDoc)(firestore, hostId)\n if (host) {\n const updates: Record<string, unknown> = aiSiteImportListingUpdates(host['seo'], host['displayName'], home)\n // The site's icon from the one its head names, where the site has none (AGL-4139).\n if (home.favicon && faviconOpen(host['seo'])) {\n const icon = await bringInSiteImportPhotos(\n { hostId, uid: input.uid, domain: input.domain, images: [{ url: home.favicon, alt: '' }], deadlineAt: Date.now() + LOOK_READ_MS, ...(input.signal ? { signal: input.signal } : {}) },\n { ingest, ...(deps.fetch ? { fetch: deps.fetch } : {}) },\n )\n const photo = icon.assets[0]\n if (photo) updates['seo.favicon'] = photo.src\n }\n if (home.ogImage && shareOpen(host['seo'])) {\n const share = await bringInSiteImportPhotos(\n { hostId, uid: input.uid, domain: input.domain, images: [{ url: home.ogImage, alt: '' }], deadlineAt: Date.now() + LOOK_READ_MS, ...(input.signal ? { signal: input.signal } : {}) },\n { ingest, ...(deps.fetch ? { fetch: deps.fetch } : {}) },\n )\n const photo = share.assets[0]\n if (photo) {\n updates['seo.image'] = photo.src\n if (photo.width) updates['seo.imageWidth'] = photo.width\n if (photo.height) updates['seo.imageHeight'] = photo.height\n }\n }\n if (Object.keys(updates).length) {\n await (deps.writeHost ?? writeHostDoc)(firestore, hostId, updates)\n seo = true\n // Every site list reads the icon the members' rows carry (AGL-3972).\n if (updates['seo.favicon']) {\n await (deps.syncMemberships ?? syncHostProjectionForMembers)(input.orgId, hostId).catch((error: unknown) => {\n console.warn('[site-import] the site lists were not told of the new icon', { hostId, error })\n })\n }\n }\n }\n const drawn = {\n ...(typeof style.headerAlign === 'string' ? { headerAlign: style.headerAlign } : {}),\n ...(typeof style.rhythm === 'string' ? { rhythm: style.rhythm } : {}),\n ...(typeof style.motion === 'string' ? { motion: style.motion } : {}),\n }\n const colors = [...new Set([...(facts ? [facts.buttonFill, facts.link, facts.eyebrow, ...(facts.palette ?? [])].filter(colorful).map((hex) => hex.toLowerCase()) : []), ...pictures, ...(site?.colors ?? [])])]\n return { at: input.at, theme, from, colors, logo, ...(menuPictures.length ? { pictures: menuPictures } : {}), seo, seed: style.seed, style: drawn }\n}\n\n/**\n * The headers the look's reads of the source go with, per address (AGL-4108),\n * exactly as the crawl's (`siteRequestHeaders`): the caller's where it hands\n * them in, else the edge's own, so a site this platform serves is read past\n * its challenge however the step was registered; and nothing for any address\n * off the site's two origins, a redirect hop's included. Never throws.\n *\n * The 10/29 look read went without the header twice over: no caller handed\n * one in, and the read passed headers the fetch does not take, which is why\n * this is a function the fetch asks for every hop (`headersFor`).\n */\nexport async function aiSiteImportLookHeaders(\n domain: string,\n deps: Pick<AiSiteImportLookDeps, 'headersFor' | 'edgeHeadersFor'>,\n): Promise<SiteImportHeadersFor> {\n const origins = siteImportOrigins(domain)\n let inner: SiteImportHeadersFor = NO_SITE_IMPORT_HEADERS\n try {\n if (deps.headersFor) {\n const headers = await deps.headersFor(domain)\n if (headers && Object.keys(headers).length) inner = () => headers\n } else {\n inner = await (deps.edgeHeadersFor ?? siteImportEdgeHeadersFor)(origins)\n }\n } catch (error) {\n console.warn('[site-import] the edge headers could not be read; reading the look without them', { domain, error })\n }\n return (url: URL) => (origins.includes(url.origin) ? inner(url) : {})\n}\n"],"names":["themeFontFacts","syncHostProjectionForMembers","aiSiteListingSeeded","aiSiteKindFor","aiHexOklch","aiSiteSeed","aiSiteStyleFor","aiSiteIsStarterSrc","AGLYN_BOT_USER_AGENT","siteImportOrigins","siteImportReadStylesheets","NO_SITE_IMPORT_HEADERS","siteImportEdgeHeadersFor","siteImportStylesheetLinks","bringInSiteImportPhotos","siteImportImageKey","siteImportLogoUrl","aiSaveSiteTheme","aiWorkspaceSiteStyles","aiSiteInspirationLookPins","aiSiteInspirationSignals","AI_THEME_BRAND_COLORS_PER_SOURCE","AI_THEME_REFERENCE_MAX_BYTES","AI_THEME_THEME_COLOR_WEIGHT","fetchPublicTextDetailed","logoMediaLocation","rankBrandColors","readLogoColors","AI_SITE_IMPORT_LOGO_HEIGHT","AI_SITE_IMPORT_LOGO_MAX_BYTES","LOOK_READ_MS","LOOK_SHEETS_MS","readSiteImportLookPage","url","input","fetchText","fetch","headersFor","read","address","maxBytes","accept","userAgent","timeoutMs","signal","catch","page","ok","startedAt","Date","now","stylesheets","text","sheet","outOfTime","html","SOLID_HEX","SOLID_RGB","THEME_COLOR","hexOf","value","raw","trim","toLowerCase","test","aiSiteImportBrandColors","match","weights","Map","add","hex","weight","set","get","matchAll","alpha","undefined","endsWith","Number","slice","channels","map","Math","min","toString","padStart","join","COLORFUL_CHROMA","colorful","C","aiSiteImportBrandOf","facts","fill","link","buttonFill","palette","filter","brand","accent","find","solidHex","aiSiteImportStyle","site","finish","pictured","pictures","own","draw","kind","description","signals","v","sites","unread","seed","pins","hue","fonts","round","h","radius","buttonRadius","isFinite","buttons","corners","eyebrow","tertiary","style","answer","avoid","sourceFonts","background","darkPage","darkBackground","buttonText","caseOf","buttonCase","outlinedCase","textCase","paper","paperBackground","darkPaper","outlinedFill","buttonOutline","aiSiteImportSourceFonts","lookup","body","loaded","Set","google","family","resolve","known","category","has","heading","headings","aiSiteImportListingUpdates","seo","displayName","home","seeded","current","updates","title","replace","shareOpen","image","pictureColorsOf","photo","firestore","hostId","orgId","location","src","AbortSignal","any","timeout","colorfulColorsOf","colors","error","console","warn","AI_SITE_IMPORT_MENU_PICTURES","aiSiteImportMenuPictures","seen","out","group","nav","items","column","columns","length","push","alt","faviconOpen","favicon","readHostDoc","snapshot","collection","doc","exists","data","writeHostDoc","update","rasterizeHere","svg","height","images","origin","aiImageReadsOrigin","requestAiLogoRaster","rasterizeAiLogoSvg","aiSiteImportLogo","deps","ingest","logo","findImportedPhoto","sourceKey","fetched","held","mediaId","from","width","acceptHeader","refuseOver","binary","byteLength","type","contentType","split","bytes","rasterize","stored","uid","fileName","importedFrom","key","domain","aiRunSiteImportLook","aiSiteImportLookHeaders","jobId","others","look","fontFacts","siteName","pictureColors","asked","ofLogo","hero","ogImage","assets","deadlineAt","ofPhoto","described","saved","save","write","Error","theme","menuImages","menuPictures","host","readHost","icon","share","Object","keys","writeHost","syncMemberships","drawn","headerAlign","rhythm","motion","at","origins","inner","headers","edgeHeadersFor","includes"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAuC2C;AAG3C,SAASA,cAAc,QAA6B,wDAAuD;AAC3G,SAASC,4BAA4B,QAAQ,mDAAkD;AAC/F,SAASC,mBAAmB,QAAQ,6BAAyB;AAE7D,SAASC,aAAa,QAAQ,4BAAwB;AACtD,SAASC,UAAU,EAAEC,UAAU,EAAEC,cAAc,QAAsE,2BAAuB;AAC5I,SAASC,kBAAkB,QAAQ,6BAAyB;AAC5D,SAASC,oBAAoB,EAAEC,iBAAiB,QAAmC,sCAAkC;AACrH,SAASC,yBAAyB,QAAQ,oCAAgC;AAC1E,SAASC,sBAAsB,EAAEC,wBAAwB,QAAmC,qCAAiC;AAC7H,SAASC,yBAAyB,QAAQ,qCAAiC;AAC3E,SAASC,uBAAuB,EAAEC,kBAAkB,EAAEC,iBAAiB,QAAQ,uCAAmC;AAClH,SAASC,eAAe,EAAEC,qBAAqB,QAAQ,wBAAoB;AAC3E,SAASC,yBAAyB,QAAQ,2BAAuB;AACjE,SAASC,wBAAwB,QAAoC,mCAA+B;AACpG,SACEC,gCAAgC,EAChCC,4BAA4B,EAC5BC,2BAA2B,EAC3BC,uBAAuB,EACvBC,iBAAiB,EACjBC,eAAe,EACfC,cAAc,QAIT,6BAAyB;AAEhC,qFAAqF,GACrF,OAAO,MAAMC,6BAA6B,IAAG;AAE7C,gCAAgC,GAChC,OAAO,MAAMC,gCAAgC,OAAO,KAAI;AAExD,2CAA2C,GAC3C,MAAMC,eAAe;AAErB,0IAA0I,GAC1I,MAAMC,iBAAiB;AAIvB;;;;;;CAMC,GACD,OAAO,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lC,iBAAAA,MAAMI,OAAO,YAAbJ,iBAAiB,EAAE;aAAE,CAACK,MAAM,CAACR,UAAUP,GAAG,CAAC,CAACX,MAAQA,IAAIP,WAAW,MAAM,EAAE;eAAM0C;uBAAcH,wBAAAA,KAAM6E,MAAM,mBAAI,EAAE;SAAE;KAAE;IAC/M,OAAO;QAAE+F,IAAIhP,MAAMgP,EAAE;QAAEf;QAAOrC;QAAM3C;QAAQqC;OAAU6C,aAAarE,MAAM,GAAG;QAAEvF,UAAU4J;IAAa,IAAI,CAAC;QAAIvG;QAAK5C,MAAMa,MAAMb,IAAI;QAAEa,OAAO+I;;AAC9I;AAEA;;;;;;;;;;CAUC,GACD,OAAO,eAAe9B,wBACpBF,MAAc,EACdxB,IAAiE;IAEjE,MAAM6D,UAAU1Q,kBAAkBqO;IAClC,IAAIsC,QAA8BzQ;IAClC,IAAI;QACF,IAAI2M,KAAKjL,UAAU,EAAE;YACnB,MAAMgP,UAAU,MAAM/D,KAAKjL,UAAU,CAACyM;YACtC,IAAIuC,WAAWX,OAAOC,IAAI,CAACU,SAASrF,MAAM,EAAEoF,QAAQ,IAAMC;QAC5D,OAAO;gBACU/D;YAAf8D,QAAQ,MAAM,EAAC9D,uBAAAA,KAAKgE,cAAc,YAAnBhE,uBAAuB1M,0BAA0BuQ;QAClE;IACF,EAAE,OAAO/F,OAAO;QACdC,QAAQC,IAAI,CAAC,mFAAmF;YAAEwD;YAAQ1D;QAAM;IAClH;IACA,OAAO,CAACnJ,MAAckP,QAAQI,QAAQ,CAACtP,IAAIgL,MAAM,IAAImE,MAAMnP,OAAO,CAAC;AACrE"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-site-import-look.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\n/*==========================================\n * THE SITE BROUGHT IN KEEPS ITS OWN LOOK (AGL-4084).\n *\n * The first wave's look pass, before the header and footer, with no model:\n *\n * - **The theme.** The owner's own home page is read once more as AglynBot,\n * with the edge headers a site this platform serves gets whether or not a\n * caller hands them in (AGL-4108: production handed none, our own edge\n * challenged the read, and the 10/29 site kept the starter's indigo), and\n * the signals a guided start reads off the sites a person likes\n * (AGL-3975: colors, ground, type mood, corners, buttons, cards, header,\n * density, motion) pin the look. What the reader found of the source's\n * look (AGL-4106) pins it closer (AGL-4108): its buttons' fill is the\n * brand and its links' color the accent, its page's ground is the site's,\n * its eyebrows' own color the theme's third and its eyebrows spaced\n * capitals with no line before them (AGL-4138), and its own font family\n * is the site's wherever the theme font catalog has it, else a pairing of\n * its type mood. The look is drawn and saved\n * exactly as a guided start's (`aiSiteStyleFor`, `aiSaveSiteTheme`): a\n * built-in base plus the brand colors and fonts, every color held to the\n * theme's reading checks. A site whose owner already chose a theme keeps\n * it.\n * - **The logo.** The source header's logo, as the source draws it, into the\n * site's media library once: an SVG is turned into a PNG 192 pixels tall\n * (the library takes pictures, not drawings), a picture is kept as it is.\n * - **The listing.** The home page's own title, description and share\n * picture become the site's listing, only while the site still has the\n * listing it was created with: an owner's own words are never written\n * over.\n *\n * A bare read never leaves the stock theme (AGL-4152). A source with no color\n * of its own to read (no colorful button, link or declared palette) takes its brand from its logo's dominant colorful hue, then its hero photo's,\n * read from the library's copy. With no picture to read either, what its\n * stylesheets use most decides, and with none of that the site still gets the\n * seed's own look for its kind of site, as a guided start with no answer does,\n * and the look says so (`from`). An owner's chosen theme is still kept.\n *\n * Nothing here fails a wave: a logo that cannot be brought in leaves the header\n * its name.\n *=========================================*/\n\nimport { DEFAULT_SITE_THEME } from '@aglyn/aglyn/app-utils/default-site'\nimport type { PluginMediaIngest } from '@aglyn/aglyn/plugin-manager/plugin-media-ingest'\nimport { themeFontFacts, type ThemeFontFacts } from '@aglyn/aglyn/plugin-manager/plugin-theme-font-catalog'\nimport { syncHostProjectionForMembers } from '@aglyn/tenant-data-admin/server/host-memberships'\nimport { aiSiteListingSeeded } from '../model/ai-site-entity'\nimport type { AiSiteImportFinish, AiSiteImportHome, AiSiteImportLook, AiSiteImportLookFrom, AiSiteImportPhoto, SiteImportLookFacts } from '../model/ai-site-import'\nimport { aiSiteKindFor } from '../model/ai-site-kinds'\nimport { siteImportFidelityThemeOf } from '../model/ai-site-import-fidelity'\nimport { aiHexOklch, aiSiteSeed, aiSiteStyleFor, aiSiteTheme, type AiSiteLookPins, type AiSiteSourceFont, type AiSiteStyle } from '../model/ai-site-look'\nimport { aiSiteIsStarterSrc } from '../model/ai-site-photos'\nimport { AGLYN_BOT_USER_AGENT, siteImportOrigins, type SiteImportCrawlSeams } from '../site-import/site-import-crawl'\nimport { siteImportReadStylesheets } from '../site-import/site-import-css'\nimport { NO_SITE_IMPORT_HEADERS, siteImportEdgeHeadersFor, type SiteImportHeadersFor } from '../site-import/site-import-edge'\nimport { siteImportStylesheetLinks } from '../site-import/site-import-html'\nimport { bringInSiteImportPhotos, siteImportImageKey, siteImportLogoUrl } from '../site-import/site-import-images'\nimport { aiSaveSiteTheme, aiWorkspaceSiteStyles } from './ai-job-site-look'\nimport { aiSiteInspirationLookPins } from './ai-site-inspiration'\nimport { aiSiteInspirationSignals, type AiSiteInspirationSite } from './ai-site-inspiration-signals'\nimport {\n AI_THEME_BRAND_COLORS_PER_SOURCE,\n AI_THEME_REFERENCE_MAX_BYTES,\n AI_THEME_THEME_COLOR_WEIGHT,\n fetchPublicTextDetailed,\n logoMediaLocation,\n rankBrandColors,\n readLogoColors,\n type AiReferencePage,\n type PublicFetchOptions,\n type PublicFetchResult,\n} from './ai-theme-brand-inputs'\n\n/** The height an SVG logo is drawn at as a picture: crisp at twice the header's 40. */\nexport const AI_SITE_IMPORT_LOGO_HEIGHT = 192\n\n/** The largest logo file read. */\nexport const AI_SITE_IMPORT_LOGO_MAX_BYTES = 1024 * 1024\n\n/** One read's own clock in the look pass. */\nconst LOOK_READ_MS = 8_000\n\n/** The clock on starting the home page's stylesheets' reads: however many it links, a pass waits no longer than this and one read's own. */\nconst LOOK_SHEETS_MS = 12_000\n\ntype Fetch = (url: string, options: PublicFetchOptions) => Promise<PublicFetchResult>\n\n/**\n * The home page and its stylesheets, every one to the crawl's byte budget\n * (AGL-4152), read as AglynBot (AGL-4084).\n * `headersFor` is asked for every request and every redirect hop, as the\n * crawl asks it (`aiSiteImportLookHeaders`: the edge header only to the\n * site's own origins). `null` when the page cannot be read.\n */\nexport async function readSiteImportLookPage(\n url: string,\n input: { fetch?: Fetch; headersFor?: SiteImportHeadersFor | null; signal?: AbortSignal },\n): Promise<AiReferencePage | null> {\n const fetchText = input.fetch ?? fetchPublicTextDetailed\n const headersFor = input.headersFor ?? null\n const read = (address: string, maxBytes: number, accept: RegExp) =>\n fetchText(address, {\n maxBytes,\n accept,\n userAgent: AGLYN_BOT_USER_AGENT,\n timeoutMs: LOOK_READ_MS,\n ...(input.signal ? { signal: input.signal } : {}),\n ...(headersFor ? { headersFor } : {}),\n }).catch(() => null)\n const page = await read(url, AI_THEME_REFERENCE_MAX_BYTES, /text\\/html|application\\/xhtml\\+xml/i)\n if (!page?.ok) return null\n const startedAt = Date.now()\n const stylesheets = await siteImportReadStylesheets(siteImportStylesheetLinks(page.text, page.url), (sheet, maxBytes) => read(sheet, maxBytes, /text\\/css|text\\/plain/i), {\n outOfTime: () => Date.now() - startedAt >= LOOK_SHEETS_MS,\n })\n return { url: page.url, html: page.text, stylesheets }\n}\n\nconst SOLID_HEX = /(?<!&)#(?:[0-9a-f]{6}|[0-9a-f]{3})(?![0-9a-z])/gi\nconst SOLID_RGB = /rgba?\\(\\s*(\\d{1,3})\\s*[,\\s]\\s*(\\d{1,3})\\s*[,\\s]\\s*(\\d{1,3})\\s*(?:[,/]\\s*([\\d.]+%?)\\s*)?\\)/gi\nconst THEME_COLOR = /<meta\\b[^>]*\\bname\\s*=\\s*[\"']?theme-color\\b[^>]*\\bcontent\\s*=\\s*[\"']?\\s*(#[0-9a-f]{3,6})/gi\n\nconst hexOf = (value: string): string | null => {\n const raw = value.trim().toLowerCase()\n if (/^#[0-9a-f]{6}$/.test(raw)) return raw\n if (/^#[0-9a-f]{3}$/.test(raw)) return `#${raw[1]}${raw[1]}${raw[2]}${raw[2]}${raw[3]}${raw[3]}`\n return null\n}\n\n/**\n * A source's brand colors as it DRAWS them (AGL-4084): the colors its markup\n * and stylesheets use solid, most used first, the colorful before the greys.\n * A translucent color is a tint of one (a hover, a focus ring), never a use\n * of it, so it is not counted: aglyn.com's focus rings, a light blue at a\n * quarter strength, outnumbered the deep blue its buttons and links are\n * drawn in, which the theme reader would otherwise take as its brand.\n */\nexport function aiSiteImportBrandColors(page: Pick<AiReferencePage, 'html' | 'stylesheets'>): string[] {\n const weights = new Map<string, number>()\n const add = (hex: string | null, weight = 1) => {\n if (hex) weights.set(hex, (weights.get(hex) ?? 0) + weight)\n }\n for (const match of page.html.matchAll(THEME_COLOR)) add(hexOf(match[1] ?? ''), AI_THEME_THEME_COLOR_WEIGHT)\n for (const text of [page.html, ...page.stylesheets]) {\n for (const match of text.matchAll(SOLID_HEX)) add(hexOf(match[0]))\n for (const match of text.matchAll(SOLID_RGB)) {\n const alpha = match[4]\n if (alpha !== undefined && (alpha.endsWith('%') ? Number(alpha.slice(0, -1)) < 100 : Number(alpha) < 1)) continue\n const channels = [match[1], match[2], match[3]].map((value) => Math.min(255, Number(value)))\n add(`#${channels.map((value) => value.toString(16).padStart(2, '0')).join('')}`)\n }\n }\n return rankBrandColors(weights, AI_THEME_BRAND_COLORS_PER_SOURCE)\n}\n\n/** How colorful a color must be to carry a brand: the inspiration reader's own floor. */\nconst COLORFUL_CHROMA = 0.04\n\nconst colorful = (hex: string | null | undefined): hex is string => !!hex && /^#[0-9a-f]{6}$/i.test(hex) && aiHexOklch(hex).C >= COLORFUL_CHROMA\n\n/**\n * The brand and accent a source's look facts give (AGL-4108): the fill of\n * its filled buttons as the brand, the color of its links as the accent\n * where it is a color of its own, and the reverse where its buttons are not\n * colorful. The theme draws the brand at the nearest shade of it that reads\n * (`aiSiteColors`): aglyn.com's light blue buttons, under white words at\n * 2.4:1, come out at the deeper blue of its own links.\n */\nexport function aiSiteImportBrandOf(facts: (Pick<SiteImportLookFacts, 'buttonFill' | 'link'> & Pick<Partial<SiteImportLookFacts>, 'palette'>) | null | undefined): { brand: string; accent: string | null } | null {\n const fill = colorful(facts?.buttonFill) ? (facts?.buttonFill as string).toLowerCase() : null\n const link = colorful(facts?.link) ? (facts?.link as string).toLowerCase() : null\n // What its root declares its brand to be (AGL-4152), where nothing on its home page draws it.\n const palette = (facts?.palette ?? []).filter(colorful).map((hex) => hex.toLowerCase())\n const brand = fill ?? link ?? palette[0]\n if (!brand) return null\n return { brand, accent: (link && link !== brand ? link : palette.find((hex) => hex !== brand)) ?? null }\n}\n\nconst solidHex = (value: string | null | undefined): string | null => (value && /^#[0-9a-f]{6}$/i.test(value) ? value.toLowerCase() : null)\n\n/**\n * The look a source's signals pin (AGL-4084), drawn the way a guided start's\n * is: the kind of site its own description says, the import's seed, its\n * strongest color as the brand. What the reader found of its look\n * (`facts`, AGL-4108) pins it closer: its buttons' fill as the brand and its\n * links' color as the accent, its eyebrows' own color as the third, and its\n * own fonts where the catalog has them (`fonts`). Its pictures' colors\n * (`pictures`, AGL-4152) stand in for a brand where its facts show none. `null`\n * where nothing showed a color to carry a brand, unless asked to draw the look\n * from the seed alone (`draw`), which the pass does rather than leave the site\n * in the stock theme.\n *\n * How the owner asked the site to be finished (AGL-4152) says what else:\n * - **Keep my site** (`keep`, and an import that names none) pins the rest\n * of its look as it draws it: its page's ground and its dark bands', its\n * buttons' corners and case and their own fill and words, every inspiration\n * signal, and its eyebrows set as spaced capitals.\n * - **Improve it** (`improve`) pins only the brand, accent and third colors\n * and the fonts, so the base that suits the kind of site shows with its own\n * corners, buttons, grounds and eyebrows.\n */\nexport function aiSiteImportStyle(\n site: AiSiteInspirationSite | null,\n input: {\n seed: number\n description: string\n avoid?: readonly AiSiteStyle[]\n facts?: SiteImportLookFacts | null\n fonts?: AiSiteStyle['sourceFonts']\n finish?: AiSiteImportFinish | null\n pictures?: readonly string[]\n draw?: boolean\n /** Under a generative Improve it (AGL-4152): a bright brand fills the buttons as it is, its links and words at a shade that reads. */\n generative?: boolean\n },\n): AiSiteStyle | null {\n const facts = input.facts ?? null\n const finish: AiSiteImportFinish = input.finish === 'improve' ? 'improve' : 'keep'\n const pictured = input.pictures?.[0] ? { brand: input.pictures[0].toLowerCase(), accent: input.pictures[1]?.toLowerCase() ?? null } : null\n const own = aiSiteImportBrandOf(facts) ?? pictured\n if (!site && !own && !input.draw) return null\n const kind = aiSiteKindFor(input.description)\n const signals = site ? aiSiteInspirationLookPins({ v: 1, sites: [site], unread: 0 }, { kind, seed: input.seed }) : {}\n // Improve keeps the brand's colors and its type, and nothing else its source draws.\n const pins: AiSiteLookPins =\n finish === 'improve'\n ? {\n ...(signals.brand ? { brand: signals.brand } : {}),\n ...(signals.hue !== undefined ? { hue: signals.hue } : {}),\n ...(signals.accent !== undefined ? { accent: signals.accent } : {}),\n ...(signals.fonts ? { fonts: signals.fonts } : {}),\n }\n : signals\n if (own) {\n pins.brand = own.brand\n pins.hue = Math.round(aiHexOklch(own.brand).h) % 360\n if (own.accent) pins.accent = Math.round(aiHexOklch(own.accent).h) % 360\n }\n // Its buttons' corners round the theme's shape where its stylesheets did not say (AGL-4108).\n const radius = facts?.buttonRadius\n if (finish === 'keep' && typeof radius === 'number' && Number.isFinite(radius) && radius >= 0) {\n pins.buttons ??= radius >= 24 ? 'pill' : radius <= 2 ? 'square' : 'rounded'\n pins.corners ??= radius <= 2 ? 'sharp' : radius <= 10 ? 'soft' : radius <= 20 ? 'round' : 'pill'\n }\n // Its eyebrows as it sets them (AGL-4138): spaced capitals with no line before them — the\n // reader takes an eyebrow only in capitals, and no mark a page draws before one is a word of\n // it — and their own color, where it is one, as the theme's third.\n if (facts && finish === 'keep') pins.eyebrow = 'caps'\n if (colorful(facts?.eyebrow)) pins.tertiary = (facts?.eyebrow as string).toLowerCase()\n if (!pins.brand && !input.draw) return null\n const style = aiSiteStyleFor({ kind, answer: {}, seed: input.seed, brand: pins.brand, avoid: input.avoid ?? [], pins })\n const fonts = input.fonts ? { sourceFonts: input.fonts } : {}\n if (finish === 'improve') return { ...style, finish, ...fonts, ...(input.generative ? { brandFill: true as const } : {}) }\n // Keep my site (AGL-4152): its grounds, its buttons' case, and its filled buttons as it draws them.\n const page = solidHex(facts?.background)\n const darkPage = solidHex(facts?.darkBackground)\n const buttonFill = solidHex(facts?.buttonFill)\n const buttonText = buttonFill ? solidHex(facts?.buttonText) : null\n const caseOf = (value: string | null | undefined) => (value === 'upper' || value === 'none' ? value : null)\n const buttonCase = caseOf(facts?.buttonCase)\n const outlinedCase = caseOf(facts?.outlinedCase)\n const textCase = caseOf(facts?.textCase)\n const paper = solidHex(facts?.paperBackground)\n const darkPaper = solidHex(facts?.darkPaper)\n const outlinedFill = solidHex(facts?.outlinedFill)\n const buttonOutline = solidHex(facts?.buttonOutline)\n return {\n ...style,\n finish,\n ...(page ? { page } : {}),\n ...(darkPage ? { darkPage } : {}),\n ...(paper ? { paper } : {}),\n ...(darkPaper ? { darkPaper } : {}),\n ...(buttonCase ? { buttonCase } : {}),\n ...(outlinedCase ? { outlinedCase } : {}),\n ...(textCase ? { textCase } : {}),\n ...(outlinedFill ? { outlinedFill } : {}),\n ...(buttonOutline ? { buttonOutline } : {}),\n ...(buttonFill ? { buttonFill } : {}),\n ...(buttonText ? { buttonText } : {}),\n ...fonts,\n }\n}\n\n/** A family's facts, as the theme font catalog answers them. */\nexport type AiSiteImportFontFacts = (family: string) => Promise<ThemeFontFacts | undefined>\n\n/**\n * The source's own fonts (AGL-4108), each where the theme font catalog has\n * the family (Google Fonts', as the fonts plugin registers it), or the\n * source loads it from Google Fonts itself: its body's and its headings'.\n * `null` where its body's family is neither, and the pairing of the source's\n * type mood sets the site instead.\n */\nexport async function aiSiteImportSourceFonts(\n facts: Pick<SiteImportLookFacts, 'fonts'> | null | undefined,\n lookup: AiSiteImportFontFacts = themeFontFacts,\n): Promise<AiSiteStyle['sourceFonts']> {\n const fonts = facts?.fonts\n if (!fonts?.body) return null\n const loaded = new Set(fonts.google.map((family) => family.toLowerCase()))\n const resolve = async (family: string | null): Promise<AiSiteSourceFont | null> => {\n if (!family) return null\n const known = await lookup(family).catch(() => undefined)\n if (known) return { family: known.family, category: known.category, weights: [...known.weights] }\n return loaded.has(family.toLowerCase()) ? { family, category: 'sans-serif', weights: [] } : null\n }\n const body = await resolve(fonts.body)\n if (!body) return null\n const heading = fonts.headings && fonts.headings.toLowerCase() !== body.family.toLowerCase() ? await resolve(fonts.headings) : null\n return { body, heading }\n}\n\n/**\n * The site's listing in the home page's own words (AGL-4084), as field\n * paths: its title and description each only where the site still has the\n * one it was created with, so an owner's own listing is never written over.\n * `{}` with nothing to write.\n */\nexport function aiSiteImportListingUpdates(seo: unknown, displayName: unknown, home: Pick<AiSiteImportHome, 'title' | 'description'>): Record<string, string> {\n const seeded = aiSiteListingSeeded(seo, displayName)\n const current = (seo && typeof seo === 'object' ? seo : {}) as Record<string, unknown>\n const updates: Record<string, string> = {}\n const title = home.title.replace(/\\s+/g, ' ').trim()\n const description = home.description.replace(/\\s+/g, ' ').trim()\n if (title && seeded.title && title !== current['title']) updates['seo.title'] = title\n if (description && seeded.description && description !== current['description']) updates['seo.description'] = description\n return updates\n}\n\n/** Whether the site's share picture is still open: none, or the starter's (AGL-3988). */\nfunction shareOpen(seo: unknown): boolean {\n const image = (seo as { image?: unknown } | null | undefined)?.image\n if (image === undefined || image === null) return true\n return typeof image === 'string' && (!image.trim() || aiSiteIsStarterSrc(image))\n}\n\n/** Turns an SVG drawing into a PNG of a height; `null` where it cannot. */\nexport type AiSiteImportRasterize = (svg: Uint8Array, height: number) => Promise<Uint8Array | null>\n\nexport interface AiSiteImportLookDeps {\n fetch?: Fetch\n /** The edge headers for the source, asked with its domain; absent, the edge is asked as the crawl asks it (AGL-4108). */\n headersFor?: SiteImportCrawlSeams['headersFor']\n /** The edge's own answer, per address (`siteImportEdgeHeadersFor`), where no `headersFor` is given. */\n edgeHeadersFor?: typeof siteImportEdgeHeadersFor\n /** A family's facts in the theme font catalog (`themeFontFacts`). */\n fontFacts?: AiSiteImportFontFacts\n save?: typeof aiSaveSiteTheme\n others?: typeof aiWorkspaceSiteStyles\n ingest?: PluginMediaIngest | null\n rasterize?: AiSiteImportRasterize\n /** The site's document, as the listing reads it. */\n readHost?: (firestore: FirebaseFirestore.Firestore, hostId: string) => Promise<Record<string, unknown> | null>\n writeHost?: (firestore: FirebaseFirestore.Firestore, hostId: string, updates: Record<string, unknown>) => Promise<void>\n /** Re-fans the rows every site list reads a site's icon from (AGL-3972), after the look sets one. */\n syncMemberships?: (orgId: string, hostId: string) => Promise<void>\n /** A picture in the library's dominant colors (AGL-4152); `null` where it cannot be read. */\n pictureColors?: AiSiteImportPictureColors\n}\n\n/** A picture in the site's library's dominant colors (`dominantColorsFromPixels`). */\nexport type AiSiteImportPictureColors = (photo: AiSiteImportPhoto, input: { firestore: FirebaseFirestore.Firestore; hostId: string; orgId: string; signal?: AbortSignal }) => Promise<readonly string[] | null>\n\n/** The library's copy of a picture, decoded where `sharp` is shipped (`readLogoColors`, AGL-4048). */\nconst pictureColorsOf: AiSiteImportPictureColors = async (photo, { firestore, hostId, orgId, signal }) => {\n const location = logoMediaLocation(photo.src, hostId, orgId)\n if (!location) return null\n return readLogoColors(firestore, location, hostId, AbortSignal.any([AbortSignal.timeout(LOOK_READ_MS), ...(signal ? [signal] : [])]))\n}\n\n/** A read of a picture's colorful colors: none where it has none, or cannot be read. */\nasync function colorfulColorsOf(photo: AiSiteImportPhoto, read: AiSiteImportPictureColors, input: Parameters<AiSiteImportPictureColors>[1]): Promise<string[]> {\n const colors = await read(photo, input).catch((error: unknown) => {\n console.warn('[site-import] a picture’s colors could not be read', { hostId: input.hostId, error })\n return null\n })\n return (colors ?? []).filter(colorful).map((hex) => hex.toLowerCase())\n}\n\n/** The most pictures the home page's menus bring into the library (AGL-4139). */\nexport const AI_SITE_IMPORT_MENU_PICTURES = 4\n\n/** The pictures the home page's menus show (AGL-4139), each once, the first few: a featured card's. */\nexport function aiSiteImportMenuPictures(home: Pick<AiSiteImportHome, 'nav'>): Array<{ url: string; alt: string }> {\n const seen = new Set<string>()\n const out: Array<{ url: string; alt: string }> = []\n for (const group of home.nav?.items ?? []) {\n for (const column of group.columns ?? []) {\n if (!column.image || seen.has(column.image.url) || out.length >= AI_SITE_IMPORT_MENU_PICTURES) continue\n seen.add(column.image.url)\n out.push({ url: column.image.url, alt: column.image.alt })\n }\n }\n return out\n}\n\n/** Whether the site still has no icon of its own (AGL-4139): an owner's is never written over. */\nfunction faviconOpen(seo: unknown): boolean {\n const favicon = (seo as { favicon?: unknown } | null | undefined)?.favicon\n return favicon === undefined || favicon === null || (typeof favicon === 'string' && !favicon.trim())\n}\n\n\nexport interface AiSiteImportLookInput {\n firestore: FirebaseFirestore.Firestore\n hostId: string\n orgId: string\n /** The member the logo and the share picture are stored as. */\n uid: string\n /** The import job's id, which the look's seed is drawn from. */\n jobId: string\n domain: string\n home: AiSiteImportHome\n at: string\n signal?: AbortSignal\n /** How the site is finished (AGL-4152): Keep my site keeps more of the source's look. Absent is `keep`. */\n finish?: AiSiteImportFinish | null\n /** Its first wave is a generative Improve it (AGL-4152). */\n generative?: boolean\n}\n\nasync function readHostDoc(firestore: FirebaseFirestore.Firestore, hostId: string): Promise<Record<string, unknown> | null> {\n const snapshot = await firestore.collection('hosts').doc(hostId).get()\n return snapshot.exists ? ((snapshot.data() ?? {}) as Record<string, unknown>) : null\n}\n\nasync function writeHostDoc(firestore: FirebaseFirestore.Firestore, hostId: string, updates: Record<string, unknown>): Promise<void> {\n await firestore.collection('hosts').doc(hostId).update(updates)\n}\n\n/** Turns an SVG into a PNG in this process, where `sharp` is shipped; `null` where it is not. */\nasync function rasterizeHere(svg: Uint8Array, height: number): Promise<Uint8Array | null> {\n const images = await import('./ai-image-reads')\n const origin = images.aiImageReadsOrigin()\n if (origin) return images.requestAiLogoRaster(origin, svg, height)\n return images.rasterizeAiLogoSvg(svg, height)\n}\n\n/**\n * The source header's logo in the site's library (AGL-4084), once: the copy\n * a page already brought in is reused by its key. An SVG becomes a PNG.\n * `null` where it cannot be brought in, and the header then prints the name.\n */\nexport async function aiSiteImportLogo(\n input: { hostId: string; uid: string; domain: string; logo: NonNullable<AiSiteImportHome['brand']['logo']>; alt: string; headersFor?: SiteImportHeadersFor | null; signal?: AbortSignal },\n deps: { fetch?: Fetch; ingest: PluginMediaIngest | null; rasterize?: AiSiteImportRasterize },\n): Promise<AiSiteImportPhoto | null> {\n const ingest = deps.ingest\n const url = siteImportLogoUrl(input.logo.url)\n if (!ingest?.findImportedPhoto || !url) return null\n const sourceKey = siteImportImageKey(url)\n try {\n const held = await ingest.findImportedPhoto({ hostId: input.hostId, sourceKey })\n if (held) return { mediaId: held.mediaId, src: held.src, alt: input.alt, from: url, ...(held.width ? { width: held.width } : {}), ...(held.height ? { height: held.height } : {}) }\n const fetched = await (deps.fetch ?? fetchPublicTextDetailed)(url, {\n maxBytes: AI_SITE_IMPORT_LOGO_MAX_BYTES,\n accept: /^image\\//i,\n acceptHeader: 'image/svg+xml,image/png,image/webp,image/jpeg;q=0.9',\n userAgent: AGLYN_BOT_USER_AGENT,\n timeoutMs: LOOK_READ_MS,\n refuseOver: true,\n binary: true,\n ...(input.signal ? { signal: input.signal } : {}),\n ...(input.headersFor ? { headersFor: input.headersFor } : {}),\n })\n if (!fetched.ok || !fetched.data?.byteLength) return null\n const type = fetched.contentType.split(';')[0].trim().toLowerCase()\n let bytes: Uint8Array | null = fetched.data\n let contentType = type\n if (type === 'image/svg+xml' || input.logo.type === 'svg') {\n bytes = await (deps.rasterize ?? rasterizeHere)(fetched.data, AI_SITE_IMPORT_LOGO_HEIGHT).catch(() => null)\n contentType = 'image/png'\n } else if (!/^image\\/(?:png|jpeg|webp|gif)$/.test(type)) {\n return null\n }\n if (!bytes?.byteLength) return null\n const stored = await ingest.ingest({\n hostId: input.hostId,\n uid: input.uid,\n fileName: `logo.${contentType === 'image/jpeg' ? 'jpg' : contentType.split('/')[1]}`,\n contentType,\n bytes,\n ...(input.alt ? { alt: input.alt.slice(0, 250) } : {}),\n importedFrom: { key: sourceKey, url, domain: input.domain },\n })\n if (!stored.ok) return null\n return { mediaId: stored.mediaId, src: stored.src, alt: input.alt, from: url, ...(stored.width ? { width: stored.width } : {}), ...(stored.height ? { height: stored.height } : {}) }\n } catch (error) {\n console.warn('[site-import] the logo could not be brought in', { hostId: input.hostId, error })\n return null\n }\n}\n\n/** The look pass (AGL-4084): the theme, the logo and the listing, from the owner's own home page. No model. */\nexport async function aiRunSiteImportLook(input: AiSiteImportLookInput, deps: AiSiteImportLookDeps = {}): Promise<AiSiteImportLook> {\n const { firestore, hostId, home } = input\n const headersFor = await aiSiteImportLookHeaders(input.domain, deps)\n const seed = aiSiteSeed(input.jobId)\n const page = await readSiteImportLookPage(home.url, { ...(deps.fetch ? { fetch: deps.fetch } : {}), headersFor, ...(input.signal ? { signal: input.signal } : {}) })\n // The source's own signals, its brand colors as it draws them solid.\n const signals = page ? aiSiteInspirationSignals(page) : null\n const site = signals && page ? { ...signals, colors: aiSiteImportBrandColors(page) } : signals\n const avoid = await (deps.others ?? aiWorkspaceSiteStyles)(firestore, { orgId: input.orgId, hostId })\n // What the reader found of its look, its buttons, ground and fonts (AGL-4108).\n const facts = home.look ?? null\n const fonts = await aiSiteImportSourceFonts(facts, deps.fontFacts)\n const ingest = deps.ingest ?? null\n const logo = home.brand.logo\n ? await aiSiteImportLogo(\n { hostId, uid: input.uid, domain: input.domain, logo: home.brand.logo, alt: home.siteName || home.brand.text, headersFor, ...(input.signal ? { signal: input.signal } : {}) },\n { ingest, ...(deps.fetch ? { fetch: deps.fetch } : {}), ...(deps.rasterize ? { rasterize: deps.rasterize } : {}) },\n )\n : null\n // No color of its own (AGL-4152): its logo's colorful colors, else its hero photo's, else its share picture's.\n let pictures: string[] = []\n let from: AiSiteImportLookFrom = 'source'\n if (!aiSiteImportBrandOf(facts)) {\n const read = deps.pictureColors ?? pictureColorsOf\n const asked = { firestore, hostId, orgId: input.orgId, ...(input.signal ? { signal: input.signal } : {}) }\n const ofLogo = logo ? await colorfulColorsOf(logo, read, asked) : []\n if (ofLogo.length) {\n pictures = ofLogo.slice(0, 2)\n from = 'logo'\n } else {\n for (const image of [home.hero, home.ogImage ? { url: home.ogImage, alt: '' } : null]) {\n if (!image) continue\n const { assets } = await bringInSiteImportPhotos(\n { hostId, uid: input.uid, domain: input.domain, images: [image], deadlineAt: Date.now() + LOOK_READ_MS, ...(input.signal ? { signal: input.signal } : {}) },\n { ingest, ...(deps.fetch ? { fetch: deps.fetch } : {}) },\n )\n const ofPhoto = assets[0] ? await colorfulColorsOf(assets[0], read, asked) : []\n if (!ofPhoto.length) continue\n pictures = ofPhoto.slice(0, 1)\n from = 'photo'\n break\n }\n }\n }\n const described = { seed, description: `${home.siteName} ${home.description}`, avoid, facts, fonts, finish: input.finish ?? null, pictures, ...(input.generative ? { generative: true } : {}) }\n let style = aiSiteImportStyle(site, described)\n // Nothing anywhere to read a color from: the seed's look for its kind, never the stock theme.\n if (!style) {\n style = aiSiteImportStyle(site, { ...described, draw: true }) as AiSiteStyle\n from = 'seed'\n }\n const saved = await (deps.save ?? aiSaveSiteTheme)(firestore, { hostId, jobId: input.jobId, style })\n if (saved.write === 'missing') throw new Error(`site ${hostId} vanished while its look was brought in`)\n const theme: AiSiteImportLook['theme'] = saved.write === 'kept' ? 'kept' : 'applied'\n // The pictures its menus show, in the library like its pages' photos (AGL-4139), for the header's panels.\n const menuImages = aiSiteImportMenuPictures(home)\n const menuPictures = menuImages.length\n ? (\n await bringInSiteImportPhotos(\n { hostId, uid: input.uid, domain: input.domain, images: menuImages, deadlineAt: Date.now() + LOOK_READ_MS, ...(input.signal ? { signal: input.signal } : {}) },\n { ingest, ...(deps.fetch ? { fetch: deps.fetch } : {}) },\n )\n ).assets\n : []\n // The site's listing in its own words, only over the one it was created with.\n let seo = false\n const host = await (deps.readHost ?? readHostDoc)(firestore, hostId)\n if (host) {\n const updates: Record<string, unknown> = aiSiteImportListingUpdates(host['seo'], host['displayName'], home)\n // The site's icon from the one its head names, where the site has none (AGL-4139).\n if (home.favicon && faviconOpen(host['seo'])) {\n const icon = await bringInSiteImportPhotos(\n { hostId, uid: input.uid, domain: input.domain, images: [{ url: home.favicon, alt: '' }], deadlineAt: Date.now() + LOOK_READ_MS, ...(input.signal ? { signal: input.signal } : {}) },\n { ingest, ...(deps.fetch ? { fetch: deps.fetch } : {}) },\n )\n const photo = icon.assets[0]\n if (photo) updates['seo.favicon'] = photo.src\n }\n if (home.ogImage && shareOpen(host['seo'])) {\n const share = await bringInSiteImportPhotos(\n { hostId, uid: input.uid, domain: input.domain, images: [{ url: home.ogImage, alt: '' }], deadlineAt: Date.now() + LOOK_READ_MS, ...(input.signal ? { signal: input.signal } : {}) },\n { ingest, ...(deps.fetch ? { fetch: deps.fetch } : {}) },\n )\n const photo = share.assets[0]\n if (photo) {\n updates['seo.image'] = photo.src\n if (photo.width) updates['seo.imageWidth'] = photo.width\n if (photo.height) updates['seo.imageHeight'] = photo.height\n }\n }\n if (Object.keys(updates).length) {\n await (deps.writeHost ?? writeHostDoc)(firestore, hostId, updates)\n seo = true\n // Every site list reads the icon the members' rows carry (AGL-3972).\n if (updates['seo.favicon']) {\n await (deps.syncMemberships ?? syncHostProjectionForMembers)(input.orgId, hostId).catch((error: unknown) => {\n console.warn('[site-import] the site lists were not told of the new icon', { hostId, error })\n })\n }\n }\n }\n const drawn = {\n ...(typeof style.headerAlign === 'string' ? { headerAlign: style.headerAlign } : {}),\n ...(typeof style.rhythm === 'string' ? { rhythm: style.rhythm } : {}),\n ...(typeof style.motion === 'string' ? { motion: style.motion } : {}),\n }\n const colors = [...new Set([...(facts ? [facts.buttonFill, facts.link, facts.eyebrow, ...(facts.palette ?? [])].filter(colorful).map((hex) => hex.toLowerCase()) : []), ...pictures, ...(site?.colors ?? [])])]\n // The colors a redesign is held to as it is asked (AGL-4152), where this look is the site's.\n const heldTo = input.generative && theme === 'applied' ? siteImportFidelityThemeOf(aiSiteTheme(style, DEFAULT_SITE_THEME), 'style') : null\n return { at: input.at, theme, from, colors, logo, ...(menuPictures.length ? { pictures: menuPictures } : {}), seo, seed: style.seed, style: drawn, ...(heldTo ? { drawn: heldTo as unknown as Record<string, unknown> } : {}) }\n}\n\n/**\n * The headers the look's reads of the source go with, per address (AGL-4108),\n * exactly as the crawl's (`siteRequestHeaders`): the caller's where it hands\n * them in, else the edge's own, so a site this platform serves is read past\n * its challenge however the step was registered; and nothing for any address\n * off the site's two origins, a redirect hop's included. Never throws.\n *\n * The 10/29 look read went without the header twice over: no caller handed\n * one in, and the read passed headers the fetch does not take, which is why\n * this is a function the fetch asks for every hop (`headersFor`).\n */\nexport async function aiSiteImportLookHeaders(\n domain: string,\n deps: Pick<AiSiteImportLookDeps, 'headersFor' | 'edgeHeadersFor'>,\n): Promise<SiteImportHeadersFor> {\n const origins = siteImportOrigins(domain)\n let inner: SiteImportHeadersFor = NO_SITE_IMPORT_HEADERS\n try {\n if (deps.headersFor) {\n const headers = await deps.headersFor(domain)\n if (headers && Object.keys(headers).length) inner = () => headers\n } else {\n inner = await (deps.edgeHeadersFor ?? siteImportEdgeHeadersFor)(origins)\n }\n } catch (error) {\n console.warn('[site-import] the edge headers could not be read; reading the look without them', { domain, error })\n }\n return (url: URL) => (origins.includes(url.origin) ? inner(url) : {})\n}\n"],"names":["DEFAULT_SITE_THEME","themeFontFacts","syncHostProjectionForMembers","aiSiteListingSeeded","aiSiteKindFor","siteImportFidelityThemeOf","aiHexOklch","aiSiteSeed","aiSiteStyleFor","aiSiteTheme","aiSiteIsStarterSrc","AGLYN_BOT_USER_AGENT","siteImportOrigins","siteImportReadStylesheets","NO_SITE_IMPORT_HEADERS","siteImportEdgeHeadersFor","siteImportStylesheetLinks","bringInSiteImportPhotos","siteImportImageKey","siteImportLogoUrl","aiSaveSiteTheme","aiWorkspaceSiteStyles","aiSiteInspirationLookPins","aiSiteInspirationSignals","AI_THEME_BRAND_COLORS_PER_SOURCE","AI_THEME_REFERENCE_MAX_BYTES","AI_THEME_THEME_COLOR_WEIGHT","fetchPublicTextDetailed","logoMediaLocation","rankBrandColors","readLogoColors","AI_SITE_IMPORT_LOGO_HEIGHT","AI_SITE_IMPORT_LOGO_MAX_BYTES","LOOK_READ_MS","LOOK_SHEETS_MS","readSiteImportLookPage","url","input","fetchText","fetch","headersFor","read","address","maxBytes","accept","userAgent","timeoutMs","signal","catch","page","ok","startedAt","Date","now","stylesheets","text","sheet","outOfTime","html","SOLID_HEX","SOLID_RGB","THEME_COLOR","hexOf","value","raw","trim","toLowerCase","test","aiSiteImportBrandColors","match","weights","Map","add","hex","weight","set","get","matchAll","alpha","undefined","endsWith","Number","slice","channels","map","Math","min","toString","padStart","join","COLORFUL_CHROMA","colorful","C","aiSiteImportBrandOf","facts","fill","link","buttonFill","palette","filter","brand","accent","find","solidHex","aiSiteImportStyle","site","finish","pictured","pictures","own","draw","kind","description","signals","v","sites","unread","seed","pins","hue","fonts","round","h","radius","buttonRadius","isFinite","buttons","corners","eyebrow","tertiary","style","answer","avoid","sourceFonts","generative","brandFill","background","darkPage","darkBackground","buttonText","caseOf","buttonCase","outlinedCase","textCase","paper","paperBackground","darkPaper","outlinedFill","buttonOutline","aiSiteImportSourceFonts","lookup","body","loaded","Set","google","family","resolve","known","category","has","heading","headings","aiSiteImportListingUpdates","seo","displayName","home","seeded","current","updates","title","replace","shareOpen","image","pictureColorsOf","photo","firestore","hostId","orgId","location","src","AbortSignal","any","timeout","colorfulColorsOf","colors","error","console","warn","AI_SITE_IMPORT_MENU_PICTURES","aiSiteImportMenuPictures","seen","out","group","nav","items","column","columns","length","push","alt","faviconOpen","favicon","readHostDoc","snapshot","collection","doc","exists","data","writeHostDoc","update","rasterizeHere","svg","height","images","origin","aiImageReadsOrigin","requestAiLogoRaster","rasterizeAiLogoSvg","aiSiteImportLogo","deps","ingest","logo","findImportedPhoto","sourceKey","fetched","held","mediaId","from","width","acceptHeader","refuseOver","binary","byteLength","type","contentType","split","bytes","rasterize","stored","uid","fileName","importedFrom","key","domain","aiRunSiteImportLook","aiSiteImportLookHeaders","jobId","others","look","fontFacts","siteName","pictureColors","asked","ofLogo","hero","ogImage","assets","deadlineAt","ofPhoto","described","saved","save","write","Error","theme","menuImages","menuPictures","host","readHost","icon","share","Object","keys","writeHost","syncMemberships","drawn","headerAlign","rhythm","motion","heldTo","at","origins","inner","headers","edgeHeadersFor","includes"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAuC2C,GAE3C,SAASA,kBAAkB,QAAQ,sCAAqC;AAExE,SAASC,cAAc,QAA6B,wDAAuD;AAC3G,SAASC,4BAA4B,QAAQ,mDAAkD;AAC/F,SAASC,mBAAmB,QAAQ,6BAAyB;AAE7D,SAASC,aAAa,QAAQ,4BAAwB;AACtD,SAASC,yBAAyB,QAAQ,sCAAkC;AAC5E,SAASC,UAAU,EAAEC,UAAU,EAAEC,cAAc,EAAEC,WAAW,QAAsE,2BAAuB;AACzJ,SAASC,kBAAkB,QAAQ,6BAAyB;AAC5D,SAASC,oBAAoB,EAAEC,iBAAiB,QAAmC,sCAAkC;AACrH,SAASC,yBAAyB,QAAQ,oCAAgC;AAC1E,SAASC,sBAAsB,EAAEC,wBAAwB,QAAmC,qCAAiC;AAC7H,SAASC,yBAAyB,QAAQ,qCAAiC;AAC3E,SAASC,uBAAuB,EAAEC,kBAAkB,EAAEC,iBAAiB,Q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M8D,UAAU7Q,kBAAkBuO;IAClC,IAAIuC,QAA8B5Q;IAClC,IAAI;QACF,IAAI6M,KAAKnL,UAAU,EAAE;YACnB,MAAMmP,UAAU,MAAMhE,KAAKnL,UAAU,CAAC2M;YACtC,IAAIwC,WAAWZ,OAAOC,IAAI,CAACW,SAAStF,MAAM,EAAEqF,QAAQ,IAAMC;QAC5D,OAAO;gBACUhE;YAAf+D,QAAQ,MAAM,EAAC/D,uBAAAA,KAAKiE,cAAc,YAAnBjE,uBAAuB5M,0BAA0B0Q;QAClE;IACF,EAAE,OAAOhG,OAAO;QACdC,QAAQC,IAAI,CAAC,mFAAmF;YAAEwD;YAAQ1D;QAAM;IAClH;IACA,OAAO,CAACrJ,MAAcqP,QAAQI,QAAQ,CAACzP,IAAIkL,MAAM,IAAIoE,MAAMtP,OAAO,CAAC;AACrE"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import type { PluginMediaIngest } from '@aglyn/aglyn/plugin-manager/plugin-media-ingest';
|
|
18
|
+
import { aiLayoutPictureBandCells, type AiLayoutPicturePhoto, type AiLayoutPictureSlot, type AiLayoutPictureSource } from '../layout-language/ai-layout-pictures';
|
|
19
|
+
import { type AiSiteImportPagePictures, type AiSiteImportPhoto } from '../model/ai-site-import';
|
|
20
|
+
import { type AiImageAspectRatio, type AiImageProvider } from '../providers/image-contract';
|
|
21
|
+
import { recordAssistCost } from '../usage/assist-usage';
|
|
22
|
+
type NodesMap = Parameters<typeof aiLayoutPictureBandCells>[0];
|
|
23
|
+
/** How long one generated picture is waited on: a picture is decoration, and a page never fails over one. */
|
|
24
|
+
export declare const AI_SITE_IMPORT_GENERATED_PICTURE_MS = 40000;
|
|
25
|
+
/** What a slot's picture came from, as the page's row tells it. */
|
|
26
|
+
export interface AiSiteImportPictureTally {
|
|
27
|
+
source: number;
|
|
28
|
+
stock: number;
|
|
29
|
+
generated: number;
|
|
30
|
+
/** What the generated pictures cost at the billed rates. */
|
|
31
|
+
generatedUsd: number;
|
|
32
|
+
/** The addresses of the source's photos a slot took. */
|
|
33
|
+
placed: string[];
|
|
34
|
+
}
|
|
35
|
+
export declare function aiSiteImportPictureTally(): AiSiteImportPictureTally;
|
|
36
|
+
/** A generated picture for a slot, stored and metered; `null` where it could not be made or kept. */
|
|
37
|
+
export type AiSiteImportPictureMaker = (slot: AiLayoutPictureSlot, tally: AiSiteImportPictureTally) => Promise<AiLayoutPicturePhoto | null>;
|
|
38
|
+
/**
|
|
39
|
+
* Which slots may take a generated picture (AGL-4152): the page's hero, or the
|
|
40
|
+
* first picture of a section that is no cell of a band, and none that shows a
|
|
41
|
+
* person, a product or a record's own thing.
|
|
42
|
+
*/
|
|
43
|
+
export declare function aiSiteImportGeneratedSlots(nodes: NodesMap, slots: readonly AiLayoutPictureSlot[]): boolean[];
|
|
44
|
+
/**
|
|
45
|
+
* The source a redesigned page's slots fill from, in the order above. `next`
|
|
46
|
+
* answers the slots the source's own photos leave and tallies its own stock
|
|
47
|
+
* photos; a slot it leaves empty takes a generated picture where one is allowed.
|
|
48
|
+
*/
|
|
49
|
+
export declare function aiSiteImportPictureSource(input: {
|
|
50
|
+
photos: readonly AiSiteImportPhoto[];
|
|
51
|
+
next: AiLayoutPictureSource | null;
|
|
52
|
+
make?: AiSiteImportPictureMaker | null;
|
|
53
|
+
nodes: NodesMap;
|
|
54
|
+
tally: AiSiteImportPictureTally;
|
|
55
|
+
/** The most generated pictures this page may take. */
|
|
56
|
+
cap?: number;
|
|
57
|
+
}): AiLayoutPictureSource | null;
|
|
58
|
+
/** The nearest shape the image models draw to a slot's frame. */
|
|
59
|
+
export declare function aiSiteImportPictureShape(aspect: number): AiImageAspectRatio;
|
|
60
|
+
/** What a generated picture is made through, and whether the workspace's meter has room for it. */
|
|
61
|
+
export interface AiSiteImportPictureMakerInput {
|
|
62
|
+
provider: AiImageProvider | null;
|
|
63
|
+
ingest: PluginMediaIngest | null;
|
|
64
|
+
firestore: FirebaseFirestore.Firestore;
|
|
65
|
+
orgId: string;
|
|
66
|
+
hostId: string;
|
|
67
|
+
uid: string;
|
|
68
|
+
/** What the site is, which a picture's own words are read with. */
|
|
69
|
+
about: string;
|
|
70
|
+
/** Whether the workspace's meter has room for a picture now. */
|
|
71
|
+
roomFor?: (credits: number) => boolean;
|
|
72
|
+
record?: typeof recordAssistCost;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A generated picture through the Media door's own parts (AGL-4152): the image
|
|
76
|
+
* provider at a paid plan's size, the fixed style wording, the media library's
|
|
77
|
+
* ingest as an upload this member made, the same provenance on the asset, and the
|
|
78
|
+
* same meter, charged only once it is stored. `null` where it cannot run here.
|
|
79
|
+
*/
|
|
80
|
+
export declare function aiSiteImportPictureMaker(input: AiSiteImportPictureMakerInput): AiSiteImportPictureMaker | null;
|
|
81
|
+
/** A page's pictures, as its row reads them once its slots are filled. */
|
|
82
|
+
export declare function aiSiteImportPagePicturesOf(pictures: AiSiteImportPagePictures, tally: AiSiteImportPictureTally): AiSiteImportPagePictures;
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ /*==========================================
|
|
17
|
+
* IMPROVE IT, GENERATIVE: A REDESIGNED PAGE'S PICTURES (AGL-4152).
|
|
18
|
+
*
|
|
19
|
+
* A redesign may ask for a picture where its own do not fit: a slot, which
|
|
20
|
+
* `aiResolveLayoutPictures` fills or drops. This is the order it fills from,
|
|
21
|
+
* first to last:
|
|
22
|
+
*
|
|
23
|
+
* 1. the page's own photos no `keep` placed;
|
|
24
|
+
* 2. the source photos the site's earlier pages left off;
|
|
25
|
+
* 3. what the site's own photo links hold, then the stock library
|
|
26
|
+
* (`aiLayoutSitePhotoSource`): no credits, copied into the library, its
|
|
27
|
+
* photographer kept, its brand-tag refusal held;
|
|
28
|
+
* 4. only where the owner switched them on, and it is quoted, a generated
|
|
29
|
+
* picture: a hero or a section's lead, never a person or a product, at most
|
|
30
|
+
* `AI_SITE_IMPORT_GENERATED_PICTURES_PER_PAGE` a page.
|
|
31
|
+
*
|
|
32
|
+
* A slot nothing fills is dropped, and the row around it redraws without a gap
|
|
33
|
+
* (`aiLayoutDropEmptyPictures`). The tally is what the page's row says.
|
|
34
|
+
*=========================================*/ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
35
|
+
import { aiLayoutPictureBandCells } from "../layout-language/ai-layout-pictures.js";
|
|
36
|
+
import { AI_SITE_IMPORT_GENERATED_PICTURES_PER_PAGE } from "../model/ai-site-import.js";
|
|
37
|
+
import { aiMediaCreditsPerPicture } from "../model/ai-media-credits.js";
|
|
38
|
+
import { estimateAiBilledUsd } from "../providers/catalog.js";
|
|
39
|
+
import { AiImageSafetyRefusal } from "../providers/image-contract.js";
|
|
40
|
+
import { aiImageAltText, aiImageFileName } from "../server/ai-media-image.js";
|
|
41
|
+
import { aiMediaRasterPrompt } from "../server/ai-media-raster-prompt.js";
|
|
42
|
+
import { recordAssistCost } from "../usage/assist-usage.js";
|
|
43
|
+
import { aiAssignOwnerPhotos } from "./ai-layout-owner-photos.js";
|
|
44
|
+
/** How long one generated picture is waited on: a picture is decoration, and a page never fails over one. */ export const AI_SITE_IMPORT_GENERATED_PICTURE_MS = 40000;
|
|
45
|
+
export function aiSiteImportPictureTally() {
|
|
46
|
+
return {
|
|
47
|
+
source: 0,
|
|
48
|
+
stock: 0,
|
|
49
|
+
generated: 0,
|
|
50
|
+
generatedUsd: 0,
|
|
51
|
+
placed: []
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** The words that say a picture shows a person: a generated one would show someone who does not exist as if they did. */ const SHOWS_PEOPLE = /\b(?:team|staff|crew|owner|owners|founder|founders|person|people|portrait|headshot|family|families|customer|customers|client|clients|patient|patients|doctor|dentist|stylist|therapist|attorney|lawyer|accountant)\b/i;
|
|
55
|
+
/**
|
|
56
|
+
* Which slots may take a generated picture (AGL-4152): the page's hero, or the
|
|
57
|
+
* first picture of a section that is no cell of a band, and none that shows a
|
|
58
|
+
* person, a product or a record's own thing.
|
|
59
|
+
*/ export function aiSiteImportGeneratedSlots(nodes, slots) {
|
|
60
|
+
const cells = aiLayoutPictureBandCells(nodes, slots);
|
|
61
|
+
const seen = new Set();
|
|
62
|
+
return slots.map((slot, index)=>{
|
|
63
|
+
const lead = !seen.has(slot.sectionIndex);
|
|
64
|
+
seen.add(slot.sectionIndex);
|
|
65
|
+
return lead && !cells[index] && !slot.product && !slot.people && !slot.record && !SHOWS_PEOPLE.test(slot.alt);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The source a redesigned page's slots fill from, in the order above. `next`
|
|
70
|
+
* answers the slots the source's own photos leave and tallies its own stock
|
|
71
|
+
* photos; a slot it leaves empty takes a generated picture where one is allowed.
|
|
72
|
+
*/ export function aiSiteImportPictureSource(input) {
|
|
73
|
+
var _input_cap;
|
|
74
|
+
const { next, make, tally } = input;
|
|
75
|
+
// A photo the library holds no size for cannot be framed.
|
|
76
|
+
const photos = input.photos.filter((photo)=>photo.width && photo.height);
|
|
77
|
+
if (!photos.length && !next && !make) return null;
|
|
78
|
+
const froms = new Map(photos.map((photo)=>{
|
|
79
|
+
var _photo_from;
|
|
80
|
+
return [
|
|
81
|
+
photo.src,
|
|
82
|
+
(_photo_from = photo.from) != null ? _photo_from : ''
|
|
83
|
+
];
|
|
84
|
+
}));
|
|
85
|
+
const cap = (_input_cap = input.cap) != null ? _input_cap : AI_SITE_IMPORT_GENERATED_PICTURES_PER_PAGE;
|
|
86
|
+
return async (slots, report)=>{
|
|
87
|
+
const own = aiAssignOwnerPhotos(slots, photos);
|
|
88
|
+
own.forEach((photo)=>{
|
|
89
|
+
if (!photo) return;
|
|
90
|
+
tally.source += 1;
|
|
91
|
+
const from = froms.get(photo.src);
|
|
92
|
+
if (from) tally.placed.push(from);
|
|
93
|
+
});
|
|
94
|
+
const open = slots.filter((_slot, index)=>!own[index]);
|
|
95
|
+
const found = next && open.length ? await next(open, report) : [];
|
|
96
|
+
let at = 0;
|
|
97
|
+
const answers = own.map((photo)=>{
|
|
98
|
+
var _ref;
|
|
99
|
+
return (_ref = photo != null ? photo : found[at++]) != null ? _ref : null;
|
|
100
|
+
});
|
|
101
|
+
if (!make) return answers;
|
|
102
|
+
const allowed = aiSiteImportGeneratedSlots(input.nodes, slots);
|
|
103
|
+
let left = Math.max(0, cap);
|
|
104
|
+
const out = [
|
|
105
|
+
...answers
|
|
106
|
+
];
|
|
107
|
+
// One at a time, so the cap holds whatever each comes to: the hero first, the biggest seen first.
|
|
108
|
+
const order = slots.map((slot, index)=>({
|
|
109
|
+
slot,
|
|
110
|
+
index
|
|
111
|
+
})).sort((a, b)=>Number(b.slot.role === 'hero') - Number(a.slot.role === 'hero') || a.index - b.index);
|
|
112
|
+
for (const { slot, index } of order){
|
|
113
|
+
var _answers_index;
|
|
114
|
+
if (left <= 0) break;
|
|
115
|
+
if (((_answers_index = answers[index]) == null ? void 0 : _answers_index.src) || !allowed[index]) continue;
|
|
116
|
+
const made = await make(slot, tally);
|
|
117
|
+
if (made) {
|
|
118
|
+
out[index] = made;
|
|
119
|
+
left -= 1;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return out;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/** The nearest shape the image models draw to a slot's frame. */ export function aiSiteImportPictureShape(aspect) {
|
|
126
|
+
var _ref;
|
|
127
|
+
var _sort_;
|
|
128
|
+
const shapes = [
|
|
129
|
+
[
|
|
130
|
+
'16:9',
|
|
131
|
+
16 / 9
|
|
132
|
+
],
|
|
133
|
+
[
|
|
134
|
+
'4:3',
|
|
135
|
+
4 / 3
|
|
136
|
+
],
|
|
137
|
+
[
|
|
138
|
+
'1:1',
|
|
139
|
+
1
|
|
140
|
+
],
|
|
141
|
+
[
|
|
142
|
+
'3:4',
|
|
143
|
+
3 / 4
|
|
144
|
+
],
|
|
145
|
+
[
|
|
146
|
+
'9:16',
|
|
147
|
+
9 / 16
|
|
148
|
+
]
|
|
149
|
+
];
|
|
150
|
+
const wanted = aspect > 0 && Number.isFinite(aspect) ? aspect : 4 / 3;
|
|
151
|
+
return (_ref = (_sort_ = [
|
|
152
|
+
...shapes
|
|
153
|
+
].sort((a, b)=>Math.abs(a[1] - wanted) - Math.abs(b[1] - wanted))[0]) == null ? void 0 : _sort_[0]) != null ? _ref : '4:3';
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* A generated picture through the Media door's own parts (AGL-4152): the image
|
|
157
|
+
* provider at a paid plan's size, the fixed style wording, the media library's
|
|
158
|
+
* ingest as an upload this member made, the same provenance on the asset, and the
|
|
159
|
+
* same meter, charged only once it is stored. `null` where it cannot run here.
|
|
160
|
+
*/ export function aiSiteImportPictureMaker(input) {
|
|
161
|
+
const { provider, ingest } = input;
|
|
162
|
+
if (!(provider == null ? void 0 : provider.configured()) || !ingest) return null;
|
|
163
|
+
const size = '1K';
|
|
164
|
+
return async (slot, tally)=>{
|
|
165
|
+
const model = provider.defaultModel();
|
|
166
|
+
if (input.roomFor && !input.roomFor(aiMediaCreditsPerPicture('photo', model, size))) return null;
|
|
167
|
+
const words = `${slot.alt}. For a website about: ${input.about}`.replace(/\s+/g, ' ').trim();
|
|
168
|
+
const timeout = new Promise((resolve)=>setTimeout(()=>resolve(null), AI_SITE_IMPORT_GENERATED_PICTURE_MS));
|
|
169
|
+
try {
|
|
170
|
+
var _stored_width, _stored_height;
|
|
171
|
+
const result = await Promise.race([
|
|
172
|
+
provider.generate({
|
|
173
|
+
model,
|
|
174
|
+
prompt: aiMediaRasterPrompt(words, 'natural'),
|
|
175
|
+
aspectRatio: aiSiteImportPictureShape(slot.aspect),
|
|
176
|
+
size,
|
|
177
|
+
count: 1
|
|
178
|
+
}),
|
|
179
|
+
timeout
|
|
180
|
+
]);
|
|
181
|
+
const image = result == null ? void 0 : result.images[0];
|
|
182
|
+
if (!result || !image) return null;
|
|
183
|
+
const alt = aiImageAltText(slot.alt);
|
|
184
|
+
const stored = await ingest.ingest({
|
|
185
|
+
hostId: input.hostId,
|
|
186
|
+
uid: input.uid,
|
|
187
|
+
fileName: aiImageFileName(slot.alt, 0, image.mimeType),
|
|
188
|
+
contentType: image.mimeType,
|
|
189
|
+
bytes: Buffer.from(image.base64, 'base64'),
|
|
190
|
+
alt,
|
|
191
|
+
description: 'Created with AI from a description.'
|
|
192
|
+
});
|
|
193
|
+
if (!stored.ok) return null;
|
|
194
|
+
const usage = _extends({}, result.usage, {
|
|
195
|
+
images: 1,
|
|
196
|
+
imageSize: size
|
|
197
|
+
});
|
|
198
|
+
let signalId = null;
|
|
199
|
+
try {
|
|
200
|
+
var _input_record;
|
|
201
|
+
signalId = await ((_input_record = input.record) != null ? _input_record : recordAssistCost)(input.firestore, input.orgId, {
|
|
202
|
+
route: 'ai/jobs',
|
|
203
|
+
hostId: input.hostId,
|
|
204
|
+
model,
|
|
205
|
+
tier: 'entitled',
|
|
206
|
+
usage,
|
|
207
|
+
docsPaths: [],
|
|
208
|
+
stopReason: 'end_turn',
|
|
209
|
+
free: null,
|
|
210
|
+
uid: input.uid,
|
|
211
|
+
kind: 'image'
|
|
212
|
+
});
|
|
213
|
+
} catch (error) {
|
|
214
|
+
console.error('ai site import: a generated picture’s usage was not recorded', {
|
|
215
|
+
orgId: input.orgId,
|
|
216
|
+
error
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
await input.firestore.collection('hosts').doc(input.hostId).collection('media').doc(stored.mediaId).update({
|
|
220
|
+
aiGenerated: {
|
|
221
|
+
model,
|
|
222
|
+
prompt: slot.alt,
|
|
223
|
+
mode: 'photo',
|
|
224
|
+
style: 'natural',
|
|
225
|
+
aspectRatio: aiSiteImportPictureShape(slot.aspect),
|
|
226
|
+
signalId,
|
|
227
|
+
generatedBy: input.uid,
|
|
228
|
+
createdAt: new Date()
|
|
229
|
+
}
|
|
230
|
+
}).catch((error)=>console.error('ai site import: a generated picture’s record was not written', {
|
|
231
|
+
mediaId: stored.mediaId,
|
|
232
|
+
error
|
|
233
|
+
}));
|
|
234
|
+
tally.generated += 1;
|
|
235
|
+
tally.generatedUsd += estimateAiBilledUsd(usage, model);
|
|
236
|
+
return {
|
|
237
|
+
src: stored.src,
|
|
238
|
+
width: (_stored_width = stored.width) != null ? _stored_width : 1024,
|
|
239
|
+
height: (_stored_height = stored.height) != null ? _stored_height : 1024,
|
|
240
|
+
alt
|
|
241
|
+
};
|
|
242
|
+
} catch (error) {
|
|
243
|
+
if (!(error instanceof AiImageSafetyRefusal)) console.warn('ai site import: a generated picture failed; its slot is dropped', {
|
|
244
|
+
error
|
|
245
|
+
});
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
/** A page's pictures, as its row reads them once its slots are filled. */ export function aiSiteImportPagePicturesOf(pictures, tally) {
|
|
251
|
+
const taken = new Set(tally.placed);
|
|
252
|
+
return {
|
|
253
|
+
source: pictures.source + tally.source,
|
|
254
|
+
stock: tally.stock,
|
|
255
|
+
generated: tally.generated,
|
|
256
|
+
slots: 0,
|
|
257
|
+
unplaced: pictures.unplaced.filter((url)=>!taken.has(url))
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
//# sourceMappingURL=ai-site-import-pictures.js.map
|