@aglyn/aglyn 1.5.0 → 1.7.0
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/README.md +2 -2
- package/package.json +11 -11
- package/src/lib/app-utils/business-details.d.ts +93 -0
- package/src/lib/app-utils/business-details.js +145 -0
- package/src/lib/app-utils/business-details.js.map +1 -0
- package/src/lib/app-utils/business-profile.d.ts +20 -3
- package/src/lib/app-utils/business-profile.js +31 -7
- package/src/lib/app-utils/business-profile.js.map +1 -1
- package/src/lib/app-utils/content-authors.d.ts +2 -0
- package/src/lib/app-utils/content-authors.js.map +1 -1
- package/src/lib/app-utils/docs-help-sections.generated.js +0 -1
- package/src/lib/app-utils/docs-help-sections.generated.js.map +1 -1
- package/src/lib/app-utils/docs-help.generated.js +0 -1
- package/src/lib/app-utils/docs-help.generated.js.map +1 -1
- package/src/lib/app-utils/docs-index.generated.js +17 -17
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/host-tokens.d.ts +53 -11
- package/src/lib/app-utils/host-tokens.js +173 -18
- package/src/lib/app-utils/host-tokens.js.map +1 -1
- package/src/lib/app-utils/site-email-chrome.js +3 -0
- package/src/lib/app-utils/site-email-chrome.js.map +1 -1
- package/src/lib/app-utils/site-entity-json-ld.js +17 -2
- package/src/lib/app-utils/site-entity-json-ld.js.map +1 -1
- package/src/lib/app-utils/weekly-summary.d.ts +19 -6
- package/src/lib/app-utils/weekly-summary.js +20 -5
- package/src/lib/app-utils/weekly-summary.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/site-entity-json-ld.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n type ContentAuthorImageContext,\n type HostSeoEntity,\n type SiteEntityHost,\n AUTHOR_NAME_MAX_LENGTH,\n SITE_ENTITY_FRAGMENT,\n contentAuthorSchemaType,\n hostSeoEntityImageJsonLd,\n siteProfileUrls,\n} from './content-authors'\nimport {\n type LocalBusinessType,\n PAYMENT_ACCEPTED_MAX_LENGTH,\n PRICE_RANGE_MAX_LENGTH,\n localBusinessType,\n normalizeAreaServed,\n parseOpeningHours,\n} from './local-business'\n\n/*\n * The SITE entity's JSON-LD: the nested `publisher` and the standalone node.\n *\n * ⛔ Kept apart from `content-authors`, which the compose pipeline reads and\n * therefore ships whole in the site runtime a published page downloads\n * (`check:tenant-wire-weight`). Only the tenant page's server render calls\n * these, and the LocalBusiness allow-list and hours parser they carry\n * (AGL-3383) have no business in a visitor's bundle. Reached through\n * `@aglyn/aglyn/server` only.\n */\n\n/** `content-authors`' trim-and-cap, for the fields this module reads. */\nconst text = (value: unknown, max = AUTHOR_NAME_MAX_LENGTH): string =>\n typeof value === 'string' ? value.trim().slice(0, max) : ''\n\n/**\n * The `@type` the SITE entity publishes under — {@link contentAuthorSchemaType}\n * with one refinement (AGL-3383): an entity that is not a Person and names a\n * business type on the allow-list publishes as that type.\n *\n * Person wins over a business type, because `schema.org` gives a Person none\n * of the properties a business type exists to carry. The stored `type` stays\n * Organization or Person either way; every LocalBusiness subtype IS an\n * Organization, so a consumer reading this as one is still right.\n *\n * Shared by the standalone node and the nested `publisher`, which carry the\n * same `@id` and must therefore not disagree about what they are.\n */\nexport function siteEntitySchemaType(\n entity: HostSeoEntity | null | undefined,\n): 'Person' | 'Organization' | LocalBusinessType {\n const base = contentAuthorSchemaType(entity?.type)\n if (base === 'Person') return base\n return localBusinessType(entity?.businessType) ?? base\n}\n\n/**\n * `schema.org` JSON-LD for the SITE entity (`host.seo.entity`) — the value\n * `Article.publisher` and `WebSite.publisher` are built from.\n *\n * Lives beside {@link contentAuthorJsonLd} on purpose (AGL-2486): a site\n * entity and a post author answer the same question about two different\n * subjects, and the reason the Person branch was broken for two years is that\n * the answer was written inline at its one call site where nothing could\n * test it. One module, two entry points, one `Person`/`Organization`\n * decision — {@link contentAuthorSchemaType}.\n *\n * `logo` is emitted verbatim on BOTH branches, unchanged from what the tenant\n * has always published. It is `host.seo.entity.logo`, a plain URL field on\n * the Setup form rather than a media-picker target, and re-keying it to\n * `image` for a Person would change the publisher block on every page of\n * every site that set one — a separate decision from this one.\n *\n * Given the site's origin, the node carries the standalone entity's `@id`\n * (AGL-3398). Without it a consumer reads this name-only node as a SECOND\n * entity: Google's Rich Results Test listed a site's LocalBusiness twice, the\n * nested one missing telephone, address, price range and image. With it, the\n * two are one entity described in two places.\n */\nexport function hostSeoEntityJsonLd(\n entity: HostSeoEntity | null | undefined,\n context?: { origin?: string },\n): Record<string, unknown> | undefined {\n const name = text(entity?.name, 400)\n if (!name) return undefined\n const origin = context?.origin?.replace(/\\/+$/, '') ?? ''\n return {\n '@type': siteEntitySchemaType(entity),\n ...(origin ? { '@id': `${origin}/${SITE_ENTITY_FRAGMENT}` } : {}),\n name,\n }\n}\n\n/**\n * The site's publisher as a STANDALONE, fully populated `schema.org` node\n * (AGL-2716).\n *\n * ## Why this exists next to {@link hostSeoEntityJsonLd}\n *\n * That function builds the value `publisher` takes: a `@type` and a `name`,\n * nested inside a `WebSite` or an `Article`, gated on the author having filled\n * in the Entity form. It is deliberately narrow, and every call site nests it.\n *\n * A consumer asking \"who runs this site, and how do I reach them\" — an AI\n * assistant answering a contact question, a readiness audit checking whether a\n * business is identifiable — looks for a TOP-LEVEL node of type `Organization`\n * carrying `name`, `description`, `contactPoint` and `address`. A publisher\n * nested two levels inside a `WebSite` answers a different question, and a\n * publisher that is absent because nobody filled in a form answers none.\n *\n * So this one:\n *\n * - is emitted as its own `<script type=\"application/ld+json\">`, at the top\n * level, where it can be found without walking into another node;\n * - FALLS BACK to the site's own identity when the Entity form is empty, so\n * every site on the platform publishes a complete entity rather than only\n * the sites whose author found the form;\n * - carries the contact and address fields, which are what turn \"a name\" into\n * \"a business a consumer can verify\".\n *\n * ## Why the fallback is safe\n *\n * It changes nothing that already exists: `hostSeoEntityJsonLd` still gates on\n * `entity.name`, so `publisher` appears exactly where it appeared before. The\n * fallback only decides what THIS node says, and a site's display name is its\n * publisher's name on the overwhelming majority of sites — the two differ when\n * a company's trading name differs from its site's, which is precisely the case\n * the Entity form exists to express.\n *\n * ## `@id`\n *\n * Both this node and the nested `publisher` carry the same `@id` when an\n * origin is known, so a consumer merges them into one entity instead of\n * reading a site that names its publisher twice with different detail.\n *\n * Returns `undefined` only when there is no name to be had from anywhere —\n * a host document with no entity, no display name and no SEO title.\n */\nexport function siteEntityJsonLd(\n host: SiteEntityHost | null | undefined,\n context?: ContentAuthorImageContext,\n): Record<string, unknown> | undefined {\n const entity = host?.seo?.entity ?? undefined\n const name =\n text(entity?.name, 400) ||\n text(host?.displayName, 400) ||\n text(host?.seo?.title, 400)\n if (!name) return undefined\n\n const origin = context?.origin?.replace(/\\/+$/, '') ?? ''\n const description =\n text(entity?.description, 800) || text(host?.seo?.description, 800)\n const url = text(entity?.url, 800) || origin\n\n /*\n `sameAs` is de-duplicated and https-only, matching the author serializer:\n a profile URL that is not fetchable teaches a consumer nothing, and the\n same profile listed twice reads as two identities.\n\n Through `siteProfileUrls` (AGL-3148) so the site's rendered social links\n count as profiles it claims, rather than only the SEO field that no host\n on the platform had filled in.\n */\n const sameAs = siteProfileUrls(host)\n\n /*\n A contactPoint needs something to contact. `contactType` alone is a label\n on nothing, so the point is emitted only when an address or a number is\n present — `schema.org` requires neither, and a consumer that finds a\n ContactPoint with no channel has been told less than it would learn from\n its absence.\n */\n const email = text(entity?.email, 320)\n const telephone = text(entity?.telephone, 64)\n const contactType = text(entity?.contactType, 120) || 'customer support'\n const contactPoint =\n email || telephone\n ? {\n '@type': 'ContactPoint',\n contactType,\n ...(email ? { email } : {}),\n ...(telephone ? { telephone } : {}),\n }\n : undefined\n\n const addressFields = {\n streetAddress: text(entity?.address?.streetAddress, 200),\n addressLocality: text(entity?.address?.addressLocality, 120),\n addressRegion: text(entity?.address?.addressRegion, 120),\n postalCode: text(entity?.address?.postalCode, 40),\n addressCountry: text(entity?.address?.addressCountry, 120),\n }\n const address = Object.entries(addressFields).filter(([, value]) => value)\n const schemaType = siteEntitySchemaType(entity)\n const picture = hostSeoEntityImageJsonLd(entity, context)\n const business =\n schemaType !== 'Person' && schemaType !== 'Organization'\n ? localBusinessJsonLd(entity, telephone, picture.logo)\n : {}\n\n return {\n '@context': 'https://schema.org',\n '@type': schemaType,\n ...(origin ? { '@id': `${origin}/${SITE_ENTITY_FRAGMENT}` } : {}),\n name,\n ...(description ? { description } : {}),\n ...(url ? { url } : {}),\n // `logo` for an Organization, `image` for a Person — the one field whose\n // KEY the branch changes. Shared with the nested publisher so the two\n // nodes cannot describe the same entity with different pictures.\n ...picture,\n ...(sameAs.length ? { sameAs } : {}),\n ...(contactPoint ? { contactPoint } : {}),\n ...(address.length\n ? { address: { '@type': 'PostalAddress', ...Object.fromEntries(address) } }\n : {}),\n ...business,\n }\n}\n\n/**\n * The properties only a LocalBusiness carries (AGL-3383), spread after\n * everything an Organization publishes so an Organization's output is\n * unchanged key for key.\n *\n * - `telephone` on the node itself as well as on its `contactPoint`: a\n * LocalBusiness has the property directly, and it is where a local result\n * reads the number from.\n * - `areaServed` as named `City` places. A service-area business commonly has\n * no street address to publish, and this is what says where it works.\n * - `openingHoursSpecification` from the hours text, invalid lines dropped.\n * - `image`, the entity logo (AGL-3398): Google recommends a picture of a\n * LocalBusiness and reads `image`, not the Organization-only `logo`, which\n * stays as well.\n *\n * Every one of them is omitted when empty, never published as `[]` or `''`.\n */\nfunction localBusinessJsonLd(\n entity: HostSeoEntity | null | undefined,\n telephone: string,\n logo: string | undefined,\n): Record<string, unknown> {\n const areaServed = normalizeAreaServed(entity?.areaServed)\n const hours = parseOpeningHours(entity?.openingHours)\n const priceRange = text(entity?.priceRange, PRICE_RANGE_MAX_LENGTH)\n const paymentAccepted = text(\n entity?.paymentAccepted,\n PAYMENT_ACCEPTED_MAX_LENGTH,\n )\n return {\n ...(telephone ? { telephone } : {}),\n ...(areaServed.length\n ? { areaServed: areaServed.map((name) => ({ '@type': 'City', name })) }\n : {}),\n ...(hours.length\n ? {\n openingHoursSpecification: hours.map((row) => ({\n '@type': 'OpeningHoursSpecification',\n dayOfWeek: row.days,\n opens: row.opens,\n closes: row.closes,\n })),\n }\n : {}),\n ...(priceRange ? { priceRange } : {}),\n ...(paymentAccepted ? { paymentAccepted } : {}),\n ...(logo ? { image: logo } : {}),\n }\n}\n"],"names":["AUTHOR_NAME_MAX_LENGTH","SITE_ENTITY_FRAGMENT","contentAuthorSchemaType","hostSeoEntityImageJsonLd","siteProfileUrls","PAYMENT_ACCEPTED_MAX_LENGTH","PRICE_RANGE_MAX_LENGTH","localBusinessType","normalizeAreaServed","parseOpeningHours","text","value","max","trim","slice","siteEntitySchemaType","entity","base","type","businessType","hostSeoEntityJsonLd","context","name","undefined","origin","replace","siteEntityJsonLd","host","seo","displayName","title","description","url","sameAs","email","telephone","contactType","contactPoint","addressFields","streetAddress","address","addressLocality","addressRegion","postalCode","addressCountry","Object","entries","filter","schemaType","picture","business","localBusinessJsonLd","logo","length","fromEntries","areaServed","hours","openingHours","priceRange","paymentAccepted","map","openingHoursSpecification","row","dayOfWeek","days","opens","closes","image"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAIEA,sBAAsB,EACtBC,oBAAoB,EACpBC,uBAAuB,EACvBC,wBAAwB,EACxBC,eAAe,QACV,uBAAmB;AAC1B,SAEEC,2BAA2B,EAC3BC,sBAAsB,EACtBC,iBAAiB,EACjBC,mBAAmB,EACnBC,iBAAiB,QACZ,sBAAkB;AAEzB;;;;;;;;;CASC,GAED,u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K;gBAChBC,QAAQJ,IAAII,MAAM;YACpB,CAAA;IACF,IACA,CAAC,GACDR,aAAa;QAAEA;IAAW,IAAI,CAAC,GAC/BC,kBAAkB;QAAEA;IAAgB,IAAI,CAAC,GACzCP,OAAO;QAAEe,OAAOf;IAAK,IAAI,CAAC;AAElC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/site-entity-json-ld.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n type ContentAuthorImageContext,\n type HostSeoEntity,\n type SiteEntityHost,\n AUTHOR_NAME_MAX_LENGTH,\n SITE_ENTITY_FRAGMENT,\n contentAuthorSchemaType,\n hostSeoEntityImageJsonLd,\n siteProfileUrls,\n} from './content-authors'\nimport { SITE_SLOGAN_MAX_LENGTH } from './business-details'\nimport { siteContactEmail } from './host-tokens'\nimport {\n type LocalBusinessType,\n PAYMENT_ACCEPTED_MAX_LENGTH,\n PRICE_RANGE_MAX_LENGTH,\n localBusinessType,\n normalizeAreaServed,\n parseOpeningHours,\n} from './local-business'\n\n/*\n * The SITE entity's JSON-LD: the nested `publisher` and the standalone node.\n *\n * ⛔ Kept apart from `content-authors`, which the compose pipeline reads and\n * therefore ships whole in the site runtime a published page downloads\n * (`check:tenant-wire-weight`). Only the tenant page's server render calls\n * these, and the LocalBusiness allow-list and hours parser they carry\n * (AGL-3383) have no business in a visitor's bundle. Reached through\n * `@aglyn/aglyn/server` only.\n */\n\n/** `content-authors`' trim-and-cap, for the fields this module reads. */\nconst text = (value: unknown, max = AUTHOR_NAME_MAX_LENGTH): string =>\n typeof value === 'string' ? value.trim().slice(0, max) : ''\n\n/**\n * The `@type` the SITE entity publishes under — {@link contentAuthorSchemaType}\n * with one refinement (AGL-3383): an entity that is not a Person and names a\n * business type on the allow-list publishes as that type.\n *\n * Person wins over a business type, because `schema.org` gives a Person none\n * of the properties a business type exists to carry. The stored `type` stays\n * Organization or Person either way; every LocalBusiness subtype IS an\n * Organization, so a consumer reading this as one is still right.\n *\n * Shared by the standalone node and the nested `publisher`, which carry the\n * same `@id` and must therefore not disagree about what they are.\n */\nexport function siteEntitySchemaType(\n entity: HostSeoEntity | null | undefined,\n): 'Person' | 'Organization' | LocalBusinessType {\n const base = contentAuthorSchemaType(entity?.type)\n if (base === 'Person') return base\n return localBusinessType(entity?.businessType) ?? base\n}\n\n/**\n * `schema.org` JSON-LD for the SITE entity (`host.seo.entity`) — the value\n * `Article.publisher` and `WebSite.publisher` are built from.\n *\n * Lives beside {@link contentAuthorJsonLd} on purpose (AGL-2486): a site\n * entity and a post author answer the same question about two different\n * subjects, and the reason the Person branch was broken for two years is that\n * the answer was written inline at its one call site where nothing could\n * test it. One module, two entry points, one `Person`/`Organization`\n * decision — {@link contentAuthorSchemaType}.\n *\n * `logo` is emitted verbatim on BOTH branches, unchanged from what the tenant\n * has always published. It is `host.seo.entity.logo`, a plain URL field on\n * the Setup form rather than a media-picker target, and re-keying it to\n * `image` for a Person would change the publisher block on every page of\n * every site that set one — a separate decision from this one.\n *\n * Given the site's origin, the node carries the standalone entity's `@id`\n * (AGL-3398). Without it a consumer reads this name-only node as a SECOND\n * entity: Google's Rich Results Test listed a site's LocalBusiness twice, the\n * nested one missing telephone, address, price range and image. With it, the\n * two are one entity described in two places.\n */\nexport function hostSeoEntityJsonLd(\n entity: HostSeoEntity | null | undefined,\n context?: { origin?: string },\n): Record<string, unknown> | undefined {\n const name = text(entity?.name, 400)\n if (!name) return undefined\n const origin = context?.origin?.replace(/\\/+$/, '') ?? ''\n return {\n '@type': siteEntitySchemaType(entity),\n ...(origin ? { '@id': `${origin}/${SITE_ENTITY_FRAGMENT}` } : {}),\n name,\n }\n}\n\n/**\n * The site's publisher as a STANDALONE, fully populated `schema.org` node\n * (AGL-2716).\n *\n * ## Why this exists next to {@link hostSeoEntityJsonLd}\n *\n * That function builds the value `publisher` takes: a `@type` and a `name`,\n * nested inside a `WebSite` or an `Article`, gated on the author having filled\n * in the Entity form. It is deliberately narrow, and every call site nests it.\n *\n * A consumer asking \"who runs this site, and how do I reach them\" — an AI\n * assistant answering a contact question, a readiness audit checking whether a\n * business is identifiable — looks for a TOP-LEVEL node of type `Organization`\n * carrying `name`, `description`, `contactPoint` and `address`. A publisher\n * nested two levels inside a `WebSite` answers a different question, and a\n * publisher that is absent because nobody filled in a form answers none.\n *\n * So this one:\n *\n * - is emitted as its own `<script type=\"application/ld+json\">`, at the top\n * level, where it can be found without walking into another node;\n * - FALLS BACK to the site's own identity when the Entity form is empty, so\n * every site on the platform publishes a complete entity rather than only\n * the sites whose author found the form;\n * - carries the contact and address fields, which are what turn \"a name\" into\n * \"a business a consumer can verify\".\n *\n * ## Why the fallback is safe\n *\n * It changes nothing that already exists: `hostSeoEntityJsonLd` still gates on\n * `entity.name`, so `publisher` appears exactly where it appeared before. The\n * fallback only decides what THIS node says, and a site's display name is its\n * publisher's name on the overwhelming majority of sites — the two differ when\n * a company's trading name differs from its site's, which is precisely the case\n * the Entity form exists to express.\n *\n * ## `@id`\n *\n * Both this node and the nested `publisher` carry the same `@id` when an\n * origin is known, so a consumer merges them into one entity instead of\n * reading a site that names its publisher twice with different detail.\n *\n * Returns `undefined` only when there is no name to be had from anywhere —\n * a host document with no entity, no display name and no SEO title.\n */\nexport function siteEntityJsonLd(\n host: SiteEntityHost | null | undefined,\n context?: ContentAuthorImageContext,\n): Record<string, unknown> | undefined {\n const entity = host?.seo?.entity ?? undefined\n const name =\n text(entity?.name, 400) ||\n text(host?.displayName, 400) ||\n text(host?.seo?.title, 400)\n if (!name) return undefined\n\n const origin = context?.origin?.replace(/\\/+$/, '') ?? ''\n const description =\n text(entity?.description, 800) || text(host?.seo?.description, 800)\n const url = text(entity?.url, 800) || origin\n\n /*\n `sameAs` is de-duplicated and https-only, matching the author serializer:\n a profile URL that is not fetchable teaches a consumer nothing, and the\n same profile listed twice reads as two identities.\n\n Through `siteProfileUrls` (AGL-3148) so the site's rendered social links\n count as profiles it claims, rather than only the SEO field that no host\n on the platform had filled in.\n */\n const sameAs = siteProfileUrls(host)\n\n /*\n A contactPoint needs something to contact. `contactType` alone is a label\n on nothing, so the point is emitted only when an address or a number is\n present — `schema.org` requires neither, and a consumer that finds a\n ContactPoint with no channel has been told less than it would learn from\n its absence.\n\n The email is the site's one email (AGL-4136): what Setup → Business\n profile saves to the entity, else the older one-block copy, so a site\n whose email lives only there still says how to reach it.\n */\n // `SiteEntityHost` names only the social links under `business`; the host\n // document handed here is the whole document, older email copy included.\n const email = text(\n siteContactEmail(host as Parameters<typeof siteContactEmail>[0]) ?? '',\n 320,\n )\n const telephone = text(entity?.telephone, 64)\n const contactType = text(entity?.contactType, 120) || 'customer support'\n const contactPoint =\n email || telephone\n ? {\n '@type': 'ContactPoint',\n contactType,\n ...(email ? { email } : {}),\n ...(telephone ? { telephone } : {}),\n }\n : undefined\n\n const addressFields = {\n streetAddress: text(entity?.address?.streetAddress, 200),\n addressLocality: text(entity?.address?.addressLocality, 120),\n addressRegion: text(entity?.address?.addressRegion, 120),\n postalCode: text(entity?.address?.postalCode, 40),\n addressCountry: text(entity?.address?.addressCountry, 120),\n }\n const address = Object.entries(addressFields).filter(([, value]) => value)\n const schemaType = siteEntitySchemaType(entity)\n const picture = hostSeoEntityImageJsonLd(entity, context)\n /*\n The business's slogan from Setup → Business profile (AGL-4136). `slogan` is an\n Organization property, which every LocalBusiness type inherits; a Person\n has none, so a site published by a person never carries it.\n */\n const slogan =\n schemaType === 'Person' ? '' : text(entity?.slogan, SITE_SLOGAN_MAX_LENGTH)\n const business =\n schemaType !== 'Person' && schemaType !== 'Organization'\n ? localBusinessJsonLd(entity, telephone, picture.logo)\n : {}\n\n return {\n '@context': 'https://schema.org',\n '@type': schemaType,\n ...(origin ? { '@id': `${origin}/${SITE_ENTITY_FRAGMENT}` } : {}),\n name,\n ...(description ? { description } : {}),\n ...(slogan ? { slogan } : {}),\n ...(url ? { url } : {}),\n // `logo` for an Organization, `image` for a Person — the one field whose\n // KEY the branch changes. Shared with the nested publisher so the two\n // nodes cannot describe the same entity with different pictures.\n ...picture,\n ...(sameAs.length ? { sameAs } : {}),\n ...(contactPoint ? { contactPoint } : {}),\n ...(address.length\n ? { address: { '@type': 'PostalAddress', ...Object.fromEntries(address) } }\n : {}),\n ...business,\n }\n}\n\n/**\n * The properties only a LocalBusiness carries (AGL-3383), spread after\n * everything an Organization publishes so an Organization's output is\n * unchanged key for key.\n *\n * - `telephone` on the node itself as well as on its `contactPoint`: a\n * LocalBusiness has the property directly, and it is where a local result\n * reads the number from.\n * - `areaServed` as named `City` places. A service-area business commonly has\n * no street address to publish, and this is what says where it works.\n * - `openingHoursSpecification` from the hours text, invalid lines dropped.\n * - `image`, the entity logo (AGL-3398): Google recommends a picture of a\n * LocalBusiness and reads `image`, not the Organization-only `logo`, which\n * stays as well.\n *\n * Every one of them is omitted when empty, never published as `[]` or `''`.\n */\nfunction localBusinessJsonLd(\n entity: HostSeoEntity | null | undefined,\n telephone: string,\n logo: string | undefined,\n): Record<string, unknown> {\n const areaServed = normalizeAreaServed(entity?.areaServed)\n const hours = parseOpeningHours(entity?.openingHours)\n const priceRange = text(entity?.priceRange, PRICE_RANGE_MAX_LENGTH)\n const paymentAccepted = text(\n entity?.paymentAccepted,\n PAYMENT_ACCEPTED_MAX_LENGTH,\n )\n return {\n ...(telephone ? { telephone } : {}),\n ...(areaServed.length\n ? { areaServed: areaServed.map((name) => ({ '@type': 'City', name })) }\n : {}),\n ...(hours.length\n ? {\n openingHoursSpecification: hours.map((row) => ({\n '@type': 'OpeningHoursSpecification',\n dayOfWeek: row.days,\n opens: row.opens,\n closes: row.closes,\n })),\n }\n : {}),\n ...(priceRange ? { priceRange } : {}),\n ...(paymentAccepted ? { paymentAccepted } : {}),\n ...(logo ? { image: logo } : {}),\n }\n}\n"],"names":["AUTHOR_NAME_MAX_LENGTH","SITE_ENTITY_FRAGMENT","contentAuthorSchemaType","hostSeoEntityImageJsonLd","siteProfileUrls","SITE_SLOGAN_MAX_LENGTH","siteContactEmail","PAYMENT_ACCEPTED_MAX_LENGTH","PRICE_RANGE_MAX_LENGTH","localBusinessType","normalizeAreaServed","parseOpeningHours","text","value","max","trim","slice","siteEntitySchemaType","entity","base","type","businessType","hostSeoEntityJsonLd","context","name","undefined","origin","replace","siteEntityJsonLd","host","seo","displayName","title","description","url","sameAs","email","telephone","contactType","contactPoint","addressFields","streetAddress","address","addressLocality","addressRegion","postalCode","addressCountry","Object","entries","filter","schemaType","picture","slogan","business","localBusinessJsonLd","logo","length","fromEntries","areaServed","hours","openingHours","priceRange","paymentAccepted","map","openingHoursSpecification","row","dayOfWeek","days","opens","closes","image"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAIEA,sBAAsB,EACtBC,oBAAoB,EACpBC,uBAAuB,EACvBC,wBAAwB,EACxBC,eAAe,QACV,uBAAmB;AAC1B,SAASC,sBAAsB,QAAQ,wBAAoB;AAC3D,SAASC,gBAAgB,QAAQ,mBAAe;AAChD,SAEEC,2BAA2B,EAC3BC,sBAAsB,EACtBC,iBAAiB,EACjBC,mBAAmB,EACnBC,iBAAiB,QACZ,sBAAkB;AAEzB;;;;;;;;;CASC,GAED,uEAAuE,GACvE,MAAMC,OAAO,CAACC,OAAgBC,MAAMd,sBAAsB,GACxD,OAAOa,UAAU,WAAWA,MAAME,IAAI,GAAGC,KAAK,CAAC,GAAGF,OAAO;AAE3D;;;;;;;;;;;;CAYC,GACD,OAAO,SAASG,qBACdC,MAAwC;QAIjCT;IAFP,MAAMU,OAAOjB,wBAAwBgB,0BAAAA,OAAQE,IAAI;I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GACDR,aAAa;QAAEA;IAAW,IAAI,CAAC,GAC/BC,kBAAkB;QAAEA;IAAgB,IAAI,CAAC,GACzCP,OAAO;QAAEe,OAAOf;IAAK,IAAI,CAAC;AAElC"}
|
|
@@ -157,25 +157,38 @@ export interface WeeklySummarySectionBar {
|
|
|
157
157
|
display: string;
|
|
158
158
|
marked: boolean;
|
|
159
159
|
}
|
|
160
|
+
/** One point of a section: a line to scan, the sentence behind it and, in the AI note, why and what next. */
|
|
161
|
+
export interface WeeklySummarySectionPoint {
|
|
162
|
+
headline: string | null;
|
|
163
|
+
text: string | null;
|
|
164
|
+
why?: string | null;
|
|
165
|
+
next?: string | null;
|
|
166
|
+
/** The report a next step points at. */
|
|
167
|
+
nextLink?: {
|
|
168
|
+
label: string;
|
|
169
|
+
url: string;
|
|
170
|
+
} | null;
|
|
171
|
+
}
|
|
160
172
|
/** One topic of a weekly email, told once: what stood out, and the figures behind it. */
|
|
161
173
|
export interface WeeklySummarySection {
|
|
162
|
-
|
|
174
|
+
/** Absent in the AI note, where each point names its own topic. */
|
|
175
|
+
title?: string | null;
|
|
163
176
|
/** Where the figures can be seen in full. */
|
|
164
177
|
link?: {
|
|
165
178
|
label: string;
|
|
166
179
|
url: string;
|
|
167
180
|
} | null;
|
|
168
|
-
|
|
169
|
-
points: ReadonlyArray<{
|
|
170
|
-
headline: string | null;
|
|
171
|
-
text: string | null;
|
|
172
|
-
}>;
|
|
181
|
+
points: readonly WeeklySummarySectionPoint[];
|
|
173
182
|
stats?: readonly PluginFigureSummaryStat[];
|
|
174
183
|
rows?: readonly WeeklySummarySectionRow[];
|
|
175
184
|
bars?: readonly WeeklySummarySectionBar[];
|
|
176
185
|
}
|
|
177
186
|
/** Tiles on their own, for an email that leads with its headline figures. */
|
|
178
187
|
export declare function weeklySummaryTilesHtml(stats: readonly PluginFigureSummaryStat[], colors: WeeklySummaryColors): string;
|
|
188
|
+
/** What an email opens with: its own read of the week, under a heading. */
|
|
189
|
+
export declare function weeklySummaryLeadHtml(heading: string, text: string, colors: WeeklySummaryColors): string;
|
|
190
|
+
/** A line of small print inside an email's body. */
|
|
191
|
+
export declare function weeklySummaryNoteHtml(text: string, colors: WeeklySummaryColors): string;
|
|
179
192
|
/** A weekly email's topics, a hairline between them; `following` when something already sits above the first. */
|
|
180
193
|
export declare function weeklySummarySectionsHtml(sections: readonly WeeklySummarySection[], colors: WeeklySummaryColors, following?: boolean): string;
|
|
181
194
|
/** The small print under the button, with its one link. */
|
|
@@ -257,6 +257,15 @@ function sectionTitleHtml(title, colors) {
|
|
|
257
257
|
/** Tiles on their own, for an email that leads with its headline figures. */ export function weeklySummaryTilesHtml(stats, colors) {
|
|
258
258
|
return stats.length ? `<div style="padding:12px 0 8px;">${tilesHtml(stats, colors)}</div>` : '';
|
|
259
259
|
}
|
|
260
|
+
/** A tinted block with an accent rule: a heading, then what it says, already drawn. */ function calloutHtml(heading, bodyHtml, colors) {
|
|
261
|
+
return `<div style="margin:16px 0 0;background-color:${colors.surface};border-left:3px solid ${colors.accent};border-radius:4px;padding:14px 16px;">` + `<div style="font-family:${FONT};font-size:14px;line-height:1.5;font-weight:700;color:${colors.text};">${esc(heading)}</div>` + `<div style="font-family:${FONT};font-size:14px;line-height:1.5;color:${colors.text};">${bodyHtml}</div>` + `</div>`;
|
|
262
|
+
}
|
|
263
|
+
/** What an email opens with: its own read of the week, under a heading. */ export function weeklySummaryLeadHtml(heading, text, colors) {
|
|
264
|
+
return calloutHtml(heading, figuresHtml(text, colors), colors);
|
|
265
|
+
}
|
|
266
|
+
/** A line of small print inside an email's body. */ export function weeklySummaryNoteHtml(text, colors) {
|
|
267
|
+
return `<div style="font-family:${FONT};font-size:13px;line-height:1.5;color:${colors.muted};padding:4px 0 8px;">${unlinked(text)}</div>`;
|
|
268
|
+
}
|
|
260
269
|
function sectionRowsHtml(rows, colors) {
|
|
261
270
|
const cell = `font-family:${FONT};font-size:14px;line-height:1.4;padding:7px 0;`;
|
|
262
271
|
// No column for a change no row has, so the figures reach the edge.
|
|
@@ -277,11 +286,17 @@ function sectionRowsHtml(rows, colors) {
|
|
|
277
286
|
});
|
|
278
287
|
return `<table role="presentation" style="width:100%;border-collapse:collapse;margin-top:8px;">${trs.join('')}</table>`;
|
|
279
288
|
}
|
|
289
|
+
/** "Likely why: …": a labeled line under a point, a link at its end when it has one. */ function pointLineHtml(label, text, link, colors) {
|
|
290
|
+
return `<div style="font-family:${FONT};font-size:14px;line-height:1.5;color:${colors.muted};padding:6px 0 0;">` + `<strong style="font-weight:700;color:${colors.text};">${esc(label)}:</strong> ${figuresHtml(text, colors)}` + (link ? ` <a href="${esc(link.url)}" style="font-weight:600;color:${colors.link};text-decoration:none;white-space:nowrap;">${esc(link.label)} →</a>` : '') + `</div>`;
|
|
291
|
+
}
|
|
280
292
|
function sectionHtml(section, colors, first) {
|
|
281
293
|
var _section_stats, _section_rows, _section_bars;
|
|
282
294
|
const link = section.link ? `<td style="padding:0;text-align:right;vertical-align:baseline;white-space:nowrap;">` + `<a href="${esc(section.link.url)}" style="font-family:${FONT};font-size:13px;line-height:1.4;font-weight:600;color:${colors.link};text-decoration:none;">${esc(section.link.label)} →</a>` + `</td>` : '';
|
|
283
|
-
const points = section.points.map((point)
|
|
284
|
-
|
|
295
|
+
const points = section.points.map((point)=>{
|
|
296
|
+
var _point_nextLink;
|
|
297
|
+
return `<div style="padding:6px 0 0;">` + (point.headline ? `<div style="font-family:${FONT};font-size:16px;line-height:1.35;font-weight:700;color:${colors.text};">${unlinked(point.headline)}</div>` : '') + (point.text ? `<div style="font-family:${FONT};font-size:14px;line-height:1.5;color:${colors.muted};">${figuresHtml(point.text, colors)}</div>` : '') + (point.why ? pointLineHtml('Likely why', point.why, null, colors) : '') + (point.next ? pointLineHtml('Try this', point.next, (_point_nextLink = point.nextLink) != null ? _point_nextLink : null, colors) : '') + `</div>`;
|
|
298
|
+
});
|
|
299
|
+
return `<div style="padding:${first ? '8px' : '18px'} 0 18px;${first ? '' : `border-top:1px solid ${colors.border};`}">` + (section.title ? `<table role="presentation" style="width:100%;border-collapse:collapse;"><tr>` + `<td style="font-family:${FONT};font-size:12px;line-height:1.4;font-weight:700;letter-spacing:0.06em;text-transform:uppercase;color:${colors.muted};padding:0;">${esc(section.title)}</td>` + link + `</tr></table>` : '') + points.join('') + (((_section_stats = section.stats) == null ? void 0 : _section_stats.length) ? `<div style="padding:8px 0 0;">${tilesHtml(section.stats, colors)}</div>` : '') + (((_section_rows = section.rows) == null ? void 0 : _section_rows.length) ? sectionRowsHtml(section.rows, colors) : '') + (((_section_bars = section.bars) == null ? void 0 : _section_bars.length) ? sectionBarsHtml(section.bars, colors) : '') + `</div>`;
|
|
285
300
|
}
|
|
286
301
|
/** A weekly email's topics, a hairline between them; `following` when something already sits above the first. */ export function weeklySummarySectionsHtml(sections, colors, following = false) {
|
|
287
302
|
return sections.map((section, index)=>sectionHtml(section, colors, index === 0 && !following)).join('');
|
|
@@ -314,7 +329,7 @@ function sectionHtml(section, colors, first) {
|
|
|
314
329
|
return `<div style="font-family:${FONT};font-size:14px;line-height:1.5;color:${colors.muted};padding:0 0 4px;">` + `${address} · ${esc(workspaceName)}</div>`;
|
|
315
330
|
}
|
|
316
331
|
function insightsHtml(url, colors) {
|
|
317
|
-
return
|
|
332
|
+
return calloutHtml('Want to know why the numbers moved?', `AI weekly insights read each site's week for you: why the numbers moved, and one thing to do next. ` + `<a href="${esc(url)}" style="color:${colors.link};text-decoration:underline;">Turn them on from Ask about your numbers</a>.`, colors);
|
|
318
333
|
}
|
|
319
334
|
function partText(part) {
|
|
320
335
|
var _part_stats, _part_rows, _part_bars;
|
|
@@ -385,7 +400,7 @@ function closing(input) {
|
|
|
385
400
|
] : [],
|
|
386
401
|
...input.aiInsightsUrl ? [
|
|
387
402
|
'',
|
|
388
|
-
`Want to know why the numbers moved? Turn on AI weekly insights from Ask about your numbers: ${input.aiInsightsUrl}`
|
|
403
|
+
`Want to know why the numbers moved, and what to do next? Turn on AI weekly insights from Ask about your numbers: ${input.aiInsightsUrl}`
|
|
389
404
|
] : [],
|
|
390
405
|
...closing(input)
|
|
391
406
|
].join('\n');
|
|
@@ -458,7 +473,7 @@ function closing(input) {
|
|
|
458
473
|
]),
|
|
459
474
|
...input.aiInsightsUrl ? [
|
|
460
475
|
'',
|
|
461
|
-
`Want to know why the numbers moved? Turn on AI weekly insights from Ask about your numbers: ${input.aiInsightsUrl}`
|
|
476
|
+
`Want to know why the numbers moved, and what to do next? Turn on AI weekly insights from Ask about your numbers: ${input.aiInsightsUrl}`
|
|
462
477
|
] : [],
|
|
463
478
|
...closing(input)
|
|
464
479
|
].join('\n');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/weekly-summary.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n pluginFigureCellText,\n pluginFigureIsoWeek,\n pluginFigureWindows,\n type PluginFigureCell,\n type PluginFigureRow,\n type PluginFigureSummaryPart,\n type PluginFigureSummaryStat,\n type PluginFigureTable,\n} from '../plugin-manager/plugin-figures'\n\n/**\n * THE WEEKLY SUMMARY (AGL-3867): the free Monday emails that say how a\n * workspace did the week before — one for each site that had something to\n * report, and an overview of the workspace that adds the sites up.\n *\n * They spend nothing. Every figure comes from a `plugin-figures` reader that\n * declares a `weeklySummary`, and that reader's owner says what its table\n * means as tiles and ranked rows, so each plugin's counting rules decide what\n * a figure is and nothing here names one. AI weekly insights (AGL-2915) are\n * the paid version that explains the figures, and stay opt-in because each\n * one spends the workspace's AI credits.\n *\n * This module is the period, the wording helpers the readers use, and both\n * emails' words and layout; the reads and the sends are\n * `@aglyn/tenant-data-admin/server/weekly-summary`. The layout is drawn as\n * email-safe tables with inline styles, in colors the caller resolves from\n * the email theme.\n */\n\n/** The key a person's switch is stored under in `users/{uid}.digestPrefs`; on until turned off. */\nexport const WEEKLY_SUMMARY_DIGEST_KEY = 'weeklySummary'\n\n/** The window every figure is read over. */\nexport const WEEKLY_SUMMARY_DAYS = 7\n\n/** Rows a ranked list names. */\nexport const WEEKLY_SUMMARY_TOP_ROWS = 5\n\n/** Counts a subject line or the overview's tiles lead with, at most. */\nexport const WEEKLY_SUMMARY_HEADLINE_COUNTS = 3\n\n/** Tiles in one row of an email. */\nconst TILES_PER_ROW = 3\n\n/**\n * The week a run reports on: the seven whole UTC days before the day it runs,\n * so a Monday run covers Monday to Sunday and never a part-day of today.\n * `now` is what each reader is handed; `week` keys the run's marker.\n */\nexport function weeklySummaryPeriod(runAt: Date): {\n now: Date\n week: string\n from: string\n to: string\n label: string\n} {\n const startOfToday = Date.UTC(runAt.getUTCFullYear(), runAt.getUTCMonth(), runAt.getUTCDate())\n const now = new Date(startOfToday - 1)\n const { current } = pluginFigureWindows(now, WEEKLY_SUMMARY_DAYS)\n return {\n now,\n week: pluginFigureIsoWeek(now),\n from: current.from,\n to: current.to,\n label: `${weeklySummaryDay(current.from)} – ${weeklySummaryDay(current.to)}`,\n }\n}\n\n/** `2026-10-05` as \"Oct 5\". */\nexport function weeklySummaryDay(day: string): string {\n const at = new Date(`${day}T00:00:00Z`)\n return at.toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: 'UTC' })\n}\n\n/** `2026-10-26` as \"Mon, Oct 26\". */\nexport function weeklySummaryWeekday(day: string): string {\n const at = new Date(`${day}T00:00:00Z`)\n return at.toLocaleDateString('en-US', { weekday: 'short', month: 'short', day: 'numeric', timeZone: 'UTC' })\n}\n\nconst ISO_DAY = /\\b\\d{4}-\\d{2}-\\d{2}\\b/g\n\n/**\n * A sentence's dates as a person says them: \"Monday 2026-10-26\" as \"Monday,\n * Oct 26\". Tables hand the model their dates in ISO form, and it copies them.\n */\nexport function weeklySummaryPlainDates(text: string): string {\n const said = (day: string) => {\n const words = weeklySummaryDay(day)\n return words === 'Invalid Date' ? day : words\n }\n return text\n .replace(/\\b((?:Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day),? (\\d{4}-\\d{2}-\\d{2})\\b/g, (_, weekday: string, day: string) => `${weekday}, ${said(day)}`)\n .replace(ISO_DAY, said)\n}\n\n// ── Helpers the readers word their parts with ──────────────────────────────\n\n/** A cell as a number, `0` for anything that is not one. */\nexport function figureCount(value: PluginFigureCell | undefined): number {\n return typeof value === 'number' && Number.isFinite(value) ? value : 0\n}\n\n/** The row whose `key` cell is `label`: \"Visitors\" in a table of figures. */\nexport function figureRow(table: PluginFigureTable, key: string, label: string): PluginFigureRow | undefined {\n return table.rows.find((row) => row[key] === label)\n}\n\n/** Whether a table carries a column, so a reader that changed shape is noticed rather than misread. */\nexport function figureHasColumn(table: PluginFigureTable, key: string): boolean {\n return table.columns.some((column) => column.key === key)\n}\n\n/** A cell as a tile, with its change when the table has one. */\nexport function figureStat(\n table: PluginFigureTable,\n row: PluginFigureRow,\n key: string,\n label: string,\n options: { change?: string; total?: { one: string; many: string } } = {},\n): PluginFigureSummaryStat {\n const change = options.change ? row[options.change] : undefined\n return {\n label,\n value: pluginFigureCellText(table, key, row[key] ?? 0),\n ...(typeof change === 'number' ? { change } : {}),\n ...(options.total ? { total: { count: figureCount(row[key]), ...options.total } } : {}),\n }\n}\n\n/** The named rows with the most of `key`, as ranked rows with their change; `[]` when none has any. */\nexport function figureRanked(\n table: PluginFigureTable,\n nameKey: string,\n key: string,\n rows: readonly PluginFigureRow[] = table.rows,\n): Array<{ label: string; value: string; change?: number }> {\n return rows\n .filter((row) => typeof row[nameKey] === 'string' && figureCount(row[key]) > 0)\n .slice(0, WEEKLY_SUMMARY_TOP_ROWS)\n .map((row) => {\n const change = row['change']\n return {\n label: String(row[nameKey]),\n value: pluginFigureCellText(table, key, row[key] ?? 0),\n ...(typeof change === 'number' ? { change } : {}),\n }\n })\n}\n\n/** A table of days as a chart, oldest first, the busiest marked; `[]` for a week with nothing in it. */\nexport function figureBars(\n table: PluginFigureTable,\n dayKey: string,\n key: string,\n): NonNullable<PluginFigureSummaryPart['bars']> {\n const most = Math.max(...table.rows.map((row) => figureCount(row[key])), 0)\n if (!most) return []\n return table.rows.map((row) => ({\n label: weeklySummaryWeekday(String(row[dayKey])),\n value: figureCount(row[key]),\n display: pluginFigureCellText(table, key, row[key] ?? 0),\n marked: figureCount(row[key]) === most,\n }))\n}\n\n/** A row's label as a person reads it, and the page it names, when it names one. */\nexport function weeklySummaryRowLink(label: string, siteUrl: string | null): { label: string; url: string | null } {\n const page = label.startsWith('/')\n return { label: label === '/' ? 'Home' : label, url: page && siteUrl ? `${siteUrl}${label === '/' ? '' : label}` : null }\n}\n\n/** \"1 order\", \"18 orders\". */\nexport function figurePlural(count: number, one: string, many: string): string {\n return `${count.toLocaleString('en-US')} ${count === 1 ? one : many}`\n}\n\n// ── The emails ─────────────────────────────────────────────────────────────\n\n/** One site's figures for the week. */\nexport interface WeeklySummarySite {\n name: string\n /** The site's dashboard in the console, absolute; `null` with no origin to build it from. */\n url: string | null\n /**\n * Where the site itself is, so a reader knows which site this is: its\n * custom domain when it serves on one, else its platform address. `null`\n * for a site with no address yet.\n */\n address?: { label: string; url: string } | null\n parts: readonly PluginFigureSummaryPart[]\n}\n\n/** The colors an email is drawn in, resolved from its theme by the caller. */\nexport interface WeeklySummaryColors {\n text: string\n muted: string\n border: string\n /** A tile's ground. */\n surface: string\n /** The accent rule beside a callout. */\n accent: string\n /** Links: the email theme's own link color, the one every other link in the email wears. */\n link: string\n /** A rise and a fall. */\n up: string\n down: string\n}\n\n/** A site with anything to say. */\nexport function weeklySummaryHasNews(site: Pick<WeeklySummarySite, 'parts'>): boolean {\n return site.parts.length > 0\n}\n\n/** The counts the readers offered for adding up, summed by noun, in the order they were first given. */\nexport function weeklySummaryTotals(\n sites: ReadonlyArray<Pick<WeeklySummarySite, 'parts'>>,\n): Array<{ count: number; one: string; many: string }> {\n const sums = new Map<string, { count: number; one: string; many: string }>()\n for (const site of sites) {\n for (const part of site.parts) {\n for (const stat of part.stats ?? []) {\n if (!stat.total || stat.total.count <= 0) continue\n const sum = sums.get(stat.total.one)\n sums.set(stat.total.one, sum ? { ...sum, count: sum.count + stat.total.count } : { ...stat.total })\n }\n }\n }\n return [...sums.values()]\n}\n\nfunction headline(sites: ReadonlyArray<Pick<WeeklySummarySite, 'parts'>>): string {\n return weeklySummaryTotals(sites)\n .slice(0, WEEKLY_SUMMARY_HEADLINE_COUNTS)\n .map(({ count, one, many }) => figurePlural(count, one, many))\n .join(', ')\n}\n\n/** \"+12.5%\", \"−27.9%\", \"no change\"; `null` with nothing to compare with. */\nexport function weeklySummaryChange(change: number | null | undefined): { text: string; sign: 1 | -1 | 0 } | null {\n if (typeof change !== 'number' || !Number.isFinite(change)) return null\n if (change === 0) return { text: 'no change', sign: 0 }\n const amount = Math.abs(change).toLocaleString('en-US', { maximumFractionDigits: 1 })\n return change > 0 ? { text: `+${amount}%`, sign: 1 } : { text: `−${amount}%`, sign: -1 }\n}\n\nconst esc = (value: string): string =>\n value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"')\n\nconst FONT = 'Helvetica, Arial, sans-serif'\n\nconst capitalized = (value: string): string => value.charAt(0).toUpperCase() + value.slice(1)\n\n/**\n * A label that reads like an address — `www.google.com` — kept from being\n * turned into a link by the inbox, which would draw it in the inbox's own\n * blue beside the theme's links. A zero-width space after each dot breaks\n * the detection and nothing a reader sees.\n */\nconst unlinked = (value: string): string => esc(value).replace(/\\./g, '.\\u200b')\n\nfunction changeHtml(change: number | null | undefined, colors: WeeklySummaryColors): string {\n const said = weeklySummaryChange(change)\n if (!said) return ''\n const color = said.sign > 0 ? colors.up : said.sign < 0 ? colors.down : colors.muted\n const arrow = said.sign > 0 ? '▲ ' : said.sign < 0 ? '▼ ' : ''\n return `<div style=\"font-family:${FONT};font-size:13px;line-height:1.4;font-weight:600;color:${color};\">${arrow}${esc(said.text)}</div>`\n}\n\n/**\n * How many tiles share each row: one row of up to three, two rows of two for\n * four, then rows of three — so a row is never left with an empty slot\n * beside two tiles.\n */\nexport function weeklySummaryTileRows(count: number): number[] {\n if (count <= 0) return []\n if (count <= TILES_PER_ROW) return [count]\n if (count === 4) return [2, 2]\n const rows: number[] = []\n for (let left = count; left > 0; left -= TILES_PER_ROW) rows.push(Math.min(TILES_PER_ROW, left))\n return rows\n}\n\n/** The gap between tiles, across and down. */\nconst TILE_GAP_PX = 8\n\n/** A cell that is only a gap: nothing in it may hold it open. */\nconst TILE_GAP = 'font-size:0;line-height:0;padding:0;'\n\n/**\n * Tiles, each a value, its label and its change, filling the width of their\n * row. The tile is the table cell itself, so a row's tiles are one height\n * whichever of them wraps, in every mail client; the gaps are cells of their own.\n */\nfunction tilesHtml(stats: readonly PluginFigureSummaryStat[], colors: WeeklySummaryColors): string {\n const sizes = weeklySummaryTileRows(stats.length)\n const rows: string[] = []\n let at = 0\n sizes.forEach((size) => {\n const cells = stats.slice(at, at + size)\n at += size\n // A tile alone takes half the row, not all of it, so it reads as a tile.\n const columns = Math.max(size, 2)\n const width = `${Math.floor(100 / columns)}%`\n const tds: string[] = []\n for (let index = 0; index < columns; index += 1) {\n if (index > 0) tds.push(`<td style=\"width:${TILE_GAP_PX}px;${TILE_GAP}\"> </td>`)\n const stat = cells[index]\n tds.push(\n stat\n ? `<td style=\"width:${width};background-color:${colors.surface};border:1px solid ${colors.border};border-radius:8px;padding:12px 14px;vertical-align:top;\">` +\n `<div style=\"font-family:${FONT};font-size:24px;line-height:1.2;font-weight:700;color:${colors.text};\">${esc(stat.value)}</div>` +\n `<div style=\"font-family:${FONT};font-size:13px;line-height:1.4;color:${colors.muted};\">${esc(stat.label)}</div>` +\n changeHtml(stat.change, colors) +\n `</td>`\n : `<td style=\"width:${width};\"></td>`,\n )\n }\n rows.push(`<tr>${tds.join('')}</tr>`)\n rows.push(`<tr><td colspan=\"${columns * 2 - 1}\" style=\"height:${TILE_GAP_PX}px;${TILE_GAP}\"> </td></tr>`)\n })\n return `<table role=\"presentation\" style=\"width:100%;border-collapse:separate;border-spacing:0;table-layout:fixed;\">${rows.join('')}</table>`\n}\n\nfunction sectionTitleHtml(title: string, colors: WeeklySummaryColors): string {\n return (\n `<div style=\"font-family:${FONT};font-size:12px;line-height:1.4;font-weight:700;letter-spacing:0.06em;` +\n `text-transform:uppercase;color:${colors.muted};padding:0 0 8px;\">${esc(title)}</div>`\n )\n}\n\n/** A figure in a sentence: a count, a sum or a percent, never the digits in a path or a date. */\nconst FIGURE =\n /(?<![\\p{L}\\p{N}_./-])(?<!(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) )[+\\-−]?[$€£¥]?(?:\\d{1,3}(?:,\\d{3})+|\\d+)(?:\\.\\d+)?%?(?![\\p{L}\\p{N}_/-])/gu\n\n/** A sentence with its figures in bold, so an eye running down the email lands on them. */\nfunction figuresHtml(text: string, colors: WeeklySummaryColors): string {\n let html = ''\n let at = 0\n for (const match of text.matchAll(FIGURE)) {\n html += `${unlinked(text.slice(at, match.index))}<strong style=\"font-weight:700;color:${colors.text};\">${esc(match[0])}</strong>`\n at = match.index + match[0].length\n }\n return html + unlinked(text.slice(at))\n}\n\n/** A figure a digest section lists: a page and its views. */\nexport interface WeeklySummarySectionRow {\n label: string\n /** Where the label goes: the page itself. */\n url?: string | null\n value: string\n change?: number | null\n}\n\n/** One day of a section's chart; `marked` when it is a day the section is about. */\nexport interface WeeklySummarySectionBar {\n label: string\n value: number\n /** The value as a person reads it. */\n display: string\n marked: boolean\n}\n\n/** One topic of a weekly email, told once: what stood out, and the figures behind it. */\nexport interface WeeklySummarySection {\n title: string\n /** Where the figures can be seen in full. */\n link?: { label: string; url: string } | null\n /** What was said about it: a line to scan and, if it needs one, the sentence behind it. */\n points: ReadonlyArray<{ headline: string | null; text: string | null }>\n stats?: readonly PluginFigureSummaryStat[]\n rows?: readonly WeeklySummarySectionRow[]\n bars?: readonly WeeklySummarySectionBar[]\n}\n\n/** Tiles on their own, for an email that leads with its headline figures. */\nexport function weeklySummaryTilesHtml(stats: readonly PluginFigureSummaryStat[], colors: WeeklySummaryColors): string {\n return stats.length ? `<div style=\"padding:12px 0 8px;\">${tilesHtml(stats, colors)}</div>` : ''\n}\n\nfunction sectionRowsHtml(rows: readonly WeeklySummarySectionRow[], colors: WeeklySummaryColors): string {\n const cell = `font-family:${FONT};font-size:14px;line-height:1.4;padding:7px 0;`\n // No column for a change no row has, so the figures reach the edge.\n const changes = rows.some((row) => weeklySummaryChange(row.change))\n const trs = rows.map((row, index) => {\n const border = index > 0 ? `border-top:1px solid ${colors.border};` : ''\n const label = row.url\n ? `<a href=\"${esc(row.url)}\" style=\"color:${colors.link};text-decoration:none;font-weight:600;\">${unlinked(row.label)}</a>`\n : unlinked(row.label)\n return (\n `<tr>` +\n `<td style=\"${cell}${border}color:${colors.text};word-break:break-word;\">${label}</td>` +\n `<td style=\"${cell}${border}color:${colors.text};font-weight:600;padding-left:12px;text-align:right;white-space:nowrap;\">${esc(row.value)}</td>` +\n (changes\n ? `<td style=\"${cell}${border}padding-left:12px;text-align:right;white-space:nowrap;\">${changeHtml(row.change, colors)}</td>`\n : '') +\n `</tr>`\n )\n })\n return `<table role=\"presentation\" style=\"width:100%;border-collapse:collapse;margin-top:8px;\">${trs.join('')}</table>`\n}\n\n/** Horizontal bars, drawn in table cells so every mail client keeps them. */\nfunction sectionBarsHtml(bars: readonly WeeklySummarySectionBar[], colors: WeeklySummaryColors): string {\n const most = Math.max(...bars.map((bar) => bar.value), 1)\n const trs = bars.map((bar) => {\n const text = `font-family:${FONT};font-size:13px;line-height:1.3;color:${bar.marked ? colors.text : colors.muted};white-space:nowrap;`\n const weight = bar.marked ? 'font-weight:700;' : ''\n return (\n `<tr>` +\n `<td style=\"${text}${weight}padding:3px 10px 3px 0;width:1%;\">${esc(bar.label)}</td>` +\n `<td style=\"padding:3px 0;\"><div style=\"background-color:${bar.marked ? colors.accent : colors.border};border-radius:2px;font-size:0;height:10px;line-height:0;width:${Math.max(1, Math.round((bar.value / most) * 100))}%;\"> </div></td>` +\n `<td style=\"${text}${weight}padding:3px 0 3px 10px;text-align:right;width:1%;\">${esc(bar.display)}</td>` +\n `</tr>`\n )\n })\n return `<table role=\"presentation\" style=\"width:100%;border-collapse:collapse;margin-top:8px;\">${trs.join('')}</table>`\n}\n\nfunction sectionHtml(section: WeeklySummarySection, colors: WeeklySummaryColors, first: boolean): string {\n const link = section.link\n ? `<td style=\"padding:0;text-align:right;vertical-align:baseline;white-space:nowrap;\">` +\n `<a href=\"${esc(section.link.url)}\" style=\"font-family:${FONT};font-size:13px;line-height:1.4;font-weight:600;color:${colors.link};text-decoration:none;\">${esc(section.link.label)} →</a>` +\n `</td>`\n : ''\n const points = section.points.map(\n (point) =>\n `<div style=\"padding:6px 0 0;\">` +\n (point.headline\n ? `<div style=\"font-family:${FONT};font-size:16px;line-height:1.35;font-weight:700;color:${colors.text};\">${unlinked(point.headline)}</div>`\n : '') +\n (point.text\n ? `<div style=\"font-family:${FONT};font-size:14px;line-height:1.5;color:${colors.muted};\">${figuresHtml(point.text, colors)}</div>`\n : '') +\n `</div>`,\n )\n return (\n `<div style=\"padding:${first ? '8px' : '18px'} 0 18px;${first ? '' : `border-top:1px solid ${colors.border};`}\">` +\n `<table role=\"presentation\" style=\"width:100%;border-collapse:collapse;\"><tr>` +\n `<td style=\"font-family:${FONT};font-size:12px;line-height:1.4;font-weight:700;letter-spacing:0.06em;text-transform:uppercase;color:${colors.muted};padding:0;\">${esc(section.title)}</td>` +\n link +\n `</tr></table>` +\n points.join('') +\n (section.stats?.length ? `<div style=\"padding:8px 0 0;\">${tilesHtml(section.stats, colors)}</div>` : '') +\n (section.rows?.length ? sectionRowsHtml(section.rows, colors) : '') +\n (section.bars?.length ? sectionBarsHtml(section.bars, colors) : '') +\n `</div>`\n )\n}\n\n/** A weekly email's topics, a hairline between them; `following` when something already sits above the first. */\nexport function weeklySummarySectionsHtml(\n sections: readonly WeeklySummarySection[],\n colors: WeeklySummaryColors,\n following = false,\n): string {\n return sections.map((section, index) => sectionHtml(section, colors, index === 0 && !following)).join('')\n}\n\n/** The small print under the button, with its one link. */\nexport function weeklySummaryFootnoteHtml(\n text: string,\n link: { label: string; url: string } | null,\n colors: WeeklySummaryColors,\n): string {\n return (\n `<div style=\"font-family:${FONT};font-size:12px;line-height:1.5;color:${colors.muted};padding:12px 0 0;\">` +\n esc(text) +\n (link ? ` <a href=\"${esc(link.url)}\" style=\"color:${colors.link};text-decoration:underline;\">${esc(link.label)}</a>` : '') +\n `</div>`\n )\n}\n\n/** A reader's part as a section of the email, its page rows linked to the site. */\nfunction partSection(part: PluginFigureSummaryPart, siteUrl: string | null): WeeklySummarySection {\n return {\n title: part.title,\n link: part.link ?? null,\n points: part.note ? [{ headline: null, text: part.note }] : [],\n ...(part.stats?.length ? { stats: part.stats } : {}),\n ...(part.rows?.length ? { rows: part.rows.map((row) => ({ ...row, ...weeklySummaryRowLink(row.label, siteUrl) })) } : {}),\n ...(part.bars?.length ? { bars: part.bars } : {}),\n }\n}\n\n/** \"aglyn.com · Aglyn LLC\": which site, linked, and whose. */\nfunction addressHtml(site: WeeklySummarySite, workspaceName: string, colors: WeeklySummaryColors): string {\n const address = site.address\n ? `<a href=\"${esc(site.address.url)}\" style=\"color:${colors.link};text-decoration:underline;font-weight:600;\">${esc(site.address.label)}</a>`\n : `<span style=\"font-weight:600;\">${esc(site.name)}</span>`\n return (\n `<div style=\"font-family:${FONT};font-size:14px;line-height:1.5;color:${colors.muted};padding:0 0 4px;\">` +\n `${address} · ${esc(workspaceName)}</div>`\n )\n}\n\nfunction insightsHtml(url: string, colors: WeeklySummaryColors): string {\n return (\n `<div style=\"margin:16px 0 0;background-color:${colors.surface};border-left:3px solid ${colors.accent};border-radius:4px;padding:14px 16px;\">` +\n `<div style=\"font-family:${FONT};font-size:14px;line-height:1.5;font-weight:700;color:${colors.text};\">Want to know why the numbers moved?</div>` +\n `<div style=\"font-family:${FONT};font-size:14px;line-height:1.5;color:${colors.text};\">` +\n `AI weekly insights explain each site's week in a few plain sentences. ` +\n `<a href=\"${esc(url)}\" style=\"color:${colors.link};text-decoration:underline;\">Turn them on from Ask about your numbers</a>.` +\n `</div></div>`\n )\n}\n\nfunction partText(part: PluginFigureSummaryPart): string[] {\n const lines = [part.title.toUpperCase()]\n if (part.note) lines.push(part.note)\n for (const stat of part.stats ?? []) {\n const said = weeklySummaryChange(stat.change)\n lines.push(`${stat.label}: ${stat.value}${said ? ` (${said.text})` : ''}`)\n }\n for (const row of part.rows ?? []) {\n const said = weeklySummaryChange(row.change)\n lines.push(`- ${row.label}: ${row.value}${said ? ` (${said.text})` : ''}`)\n }\n for (const bar of part.bars ?? []) lines.push(`- ${bar.label}: ${bar.display}`)\n if (part.link) lines.push(`${part.link.label}: ${part.link.url}`)\n return lines\n}\n\n/** What a send fills a weekly summary email's tokens with. */\nexport interface WeeklySummaryEmail {\n subject: string\n /** The heading: \"Aglyn last week\". */\n title: string\n /** \"Oct 5 – Oct 11, compared with the week before\". */\n period: string\n /** The figures, drawn. */\n html: string\n /** The small print under the button. */\n footnote: string\n /** The whole email as plain text, closing line included. */\n text: string\n buttonLabel: string\n /** Where the button goes; `''` when there is no console origin to link to. */\n url: string\n}\n\ninterface CommonInput {\n workspaceName: string\n productName: string\n periodLabel: string\n colors: WeeklySummaryColors\n /** Where AI weekly insights are turned on, when the plan includes them and this person has not; else `null`. */\n aiInsightsUrl: string | null\n settingsUrl: string\n}\n\nfunction footnote(input: CommonInput): string {\n return weeklySummaryFootnoteHtml('', { label: 'Change what you are emailed about', url: input.settingsUrl }, input.colors)\n}\n\nfunction closing(input: CommonInput): string[] {\n return [\n '',\n `You get this summary because you manage ${input.workspaceName}. Turn it off in Notifications: ${input.settingsUrl}`,\n ]\n}\n\n/**\n * One site's email, or `null` for a site with nothing to report. `workspace`\n * carries the workspace's own parts when this site's email stands in for the\n * overview, in a workspace with one active site.\n */\nexport function composeWeeklySummarySiteEmail(\n input: CommonInput & { site: WeeklySummarySite; workspace?: readonly PluginFigureSummaryPart[] },\n): WeeklySummaryEmail | null {\n const workspace = input.workspace ?? []\n if (!weeklySummaryHasNews(input.site) && !workspace.length) return null\n const lead = headline([input.site])\n const subject = lead ? `${input.site.name} last week: ${lead}` : `${input.site.name} last week`\n const siteUrl = input.site.address?.url ?? null\n const html =\n addressHtml(input.site, input.workspaceName, input.colors) +\n weeklySummarySectionsHtml(\n [\n ...input.site.parts.map((part) => partSection(part, siteUrl)),\n ...workspace.map((part) => partSection({ ...part, title: `${input.workspaceName} · ${part.title}` }, null)),\n ],\n input.colors,\n ) +\n (input.aiInsightsUrl ? insightsHtml(input.aiInsightsUrl, input.colors) : '')\n const text = [\n `${input.site.name} last week, ${input.periodLabel}. A change in brackets is against the week before.`,\n `Site: ${input.site.address ? `${input.site.address.label} (${input.site.address.url})` : input.site.name} · ${input.workspaceName}`,\n ...input.site.parts.flatMap((part) => ['', ...partText(part)]),\n ...workspace.flatMap((part) => ['', ...partText({ ...part, title: `${input.workspaceName} · ${part.title}` })]),\n ...(input.site.url ? ['', `Open ${input.site.name} in ${input.productName}: ${input.site.url}`] : []),\n ...(input.aiInsightsUrl\n ? ['', `Want to know why the numbers moved? Turn on AI weekly insights from Ask about your numbers: ${input.aiInsightsUrl}`]\n : []),\n ...closing(input),\n ].join('\\n')\n return {\n subject,\n title: `${input.site.name} last week`,\n period: `${input.periodLabel}, compared with the week before`,\n html,\n footnote: footnote(input),\n text,\n buttonLabel: `Open ${input.site.name}`,\n url: input.site.url ?? '',\n }\n}\n\n/**\n * The workspace overview: the week's totals across its sites, a line for each\n * site, and the workspace's own figures, or `null` when nothing anywhere has\n * anything to report.\n */\nexport function composeWeeklySummaryOverviewEmail(\n input: CommonInput & {\n sites: readonly WeeklySummarySite[]\n workspace: readonly PluginFigureSummaryPart[]\n /** The workspace's home in the console, absolute; `''` with no origin. */\n url: string\n },\n): WeeklySummaryEmail | null {\n const active = input.sites.filter(weeklySummaryHasNews)\n if (!active.length && !input.workspace.length) return null\n const totals = weeklySummaryTotals(active)\n const lead = totals\n .slice(0, WEEKLY_SUMMARY_HEADLINE_COUNTS)\n .map(({ count, one, many }) => figurePlural(count, one, many))\n .join(', ')\n const subject = lead ? `Your week at ${input.workspaceName}: ${lead}` : `Your week at ${input.workspaceName}`\n const { colors } = input\n const totalsPart: PluginFigureSummaryPart | null = totals.length\n ? {\n title: active.length === 1 ? 'At a glance' : `Across ${active.length} sites`,\n stats: totals.slice(0, TILES_PER_ROW * 2).map(({ count, one, many }) => ({\n label: capitalized(count === 1 ? one : many),\n value: count.toLocaleString('en-US'),\n })),\n }\n : null\n const siteLine = (site: WeeklySummarySite): string =>\n site.parts\n .flatMap((part) => part.stats ?? [])\n .filter((stat) => stat.total && stat.total.count > 0)\n .slice(0, WEEKLY_SUMMARY_HEADLINE_COUNTS)\n .map((stat) => {\n const total = stat.total as NonNullable<PluginFigureSummaryStat['total']>\n const said = weeklySummaryChange(stat.change)\n return `${figurePlural(total.count, total.one, total.many)}${said ? ` (${said.text})` : ''}`\n })\n .join(' · ')\n const quietCount = input.sites.length - active.length\n const quiet = quietCount\n ? `${figurePlural(quietCount, 'other site', 'other sites')} had nothing to report.`\n : ''\n const sitesHtml = active.length\n ? `<div style=\"padding:18px 0 8px;${totalsPart ? `border-top:1px solid ${colors.border};` : ''}\">` +\n sectionTitleHtml('Your sites', colors) +\n `<table role=\"presentation\" style=\"width:100%;border-collapse:collapse;\">` +\n active\n .map((site, index) => {\n const border = index < active.length - 1 ? `border-bottom:1px solid ${colors.border};` : ''\n const name = site.url\n ? `<a href=\"${esc(site.url)}\" style=\"color:${colors.link};text-decoration:none;font-weight:700;\">${esc(site.name)}</a>`\n : `<span style=\"font-weight:700;\">${esc(site.name)}</span>`\n const line = siteLine(site)\n const address = site.address\n ? ` <a href=\"${esc(site.address.url)}\" style=\"color:${colors.muted};text-decoration:underline;font-size:13px;font-weight:400;\">${esc(site.address.label)}</a>`\n : ''\n return (\n `<tr><td style=\"font-family:${FONT};font-size:15px;line-height:1.4;color:${colors.text};padding:10px 0;${border}\">` +\n name +\n address +\n (line ? `<div style=\"font-size:13px;line-height:1.5;color:${colors.muted};\">${esc(line)}</div>` : '') +\n `</td></tr>`\n )\n })\n .join('') +\n `</table>` +\n (quiet\n ? `<div style=\"font-family:${FONT};font-size:13px;line-height:1.5;color:${colors.muted};padding:4px 0 0;\">${esc(quiet)}</div>`\n : '') +\n `</div>`\n : ''\n const html =\n (totalsPart ? weeklySummarySectionsHtml([partSection(totalsPart, null)], colors) : '') +\n sitesHtml +\n weeklySummarySectionsHtml(\n input.workspace.map((part) => partSection(part, null)),\n colors,\n Boolean(totalsPart || sitesHtml),\n ) +\n (active.length > 1\n ? `<div style=\"font-family:${FONT};font-size:13px;line-height:1.5;color:${colors.muted};padding:8px 0 0;\">Each site's own summary arrives beside this one.</div>`\n : '') +\n (input.aiInsightsUrl ? insightsHtml(input.aiInsightsUrl, colors) : '')\n const text = [\n `Here is how ${input.workspaceName} did last week, ${input.periodLabel}. A change in brackets is against the week before.`,\n ...(totalsPart ? ['', ...partText(totalsPart)] : []),\n ...(active.length\n ? [\n '',\n 'YOUR SITES',\n ...active.map(\n (site) =>\n `- ${site.name}${site.address ? ` (${site.address.label})` : ''}: ${siteLine(site) || 'see its summary'}` +\n (site.url ? ` · ${site.url}` : ''),\n ),\n ...(quiet ? [quiet] : []),\n ]\n : []),\n ...input.workspace.flatMap((part) => ['', ...partText(part)]),\n ...(input.aiInsightsUrl\n ? ['', `Want to know why the numbers moved? Turn on AI weekly insights from Ask about your numbers: ${input.aiInsightsUrl}`]\n : []),\n ...closing(input),\n ].join('\\n')\n return {\n subject,\n title: `${input.workspaceName} last week`,\n period: `${input.periodLabel}, compared with the week before`,\n html,\n footnote: footnote(input),\n text,\n buttonLabel: `Open ${input.workspaceName}`,\n url: input.url,\n }\n}\n"],"names":["pluginFigureCellText","pluginFigureIsoWeek","pluginFigureWindows","WEEKLY_SUMMARY_DIGEST_KEY","WEEKLY_SUMMARY_DAYS","WEEKLY_SUMMARY_TOP_ROWS","WEEKLY_SUMMARY_HEADLINE_COUNTS","TILES_PER_ROW","weeklySummaryPeriod","runAt","startOfToday","Date","UTC","getUTCFullYear","getUTCMonth","getUTCDate","now","current","week","from","to","label","weeklySummaryDay","day","at","toLocaleDateString","month","timeZone","weeklySummaryWeekday","weekday","ISO_DAY","weeklySummaryPlainDates","text","said","words","replace","_","figureCount","value","Number","isFinite","figureRow","table","key","rows","find","row","figureHasColumn","columns","some","column","figureStat","options","change","undefined","total","count","figureRanked","nameKey","filter","slice","map","String","figureBars","dayKey","most","Math","max","display","marked","weeklySummaryRowLink","siteUrl","page","startsWith","url","figurePlural","one","many","toLocaleString","weeklySummaryHasNews","site","parts","length","weeklySummaryTotals","sites","sums","Map","part","stat","stats","sum","get","set","values","headline","join","weeklySummaryChange","sign","amount","abs","maximumFractionDigits","esc","FONT","capitalized","charAt","toUpperCase","unlinked","changeHtml","colors","color","up","down","muted","arrow","weeklySummaryTileRows","left","push","min","TILE_GAP_PX","TILE_GAP","tilesHtml","sizes","forEach","size","cells","width","floor","tds","index","surface","border","sectionTitleHtml","title","FIGURE","figuresHtml","html","match","matchAll","weeklySummaryTilesHtml","sectionRowsHtml","cell","changes","trs","link","sectionBarsHtml","bars","bar","weight","accent","round","sectionHtml","section","first","points","point","weeklySummarySectionsHtml","sections","following","weeklySummaryFootnoteHtml","partSection","note","addressHtml","workspaceName","address","name","insightsHtml","partText","lines","footnote","input","settingsUrl","closing","composeWeeklySummarySiteEmail","workspace","lead","subject","aiInsightsUrl","periodLabel","flatMap","productName","period","buttonLabel","composeWeeklySummaryOverviewEmail","active","totals","totalsPart","siteLine","quietCount","quiet","sitesHtml","line","Boolean"],"mapp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;YACE;YACA;eACGqG,OAAO1H,GAAG,CACX,CAACmB,OACC,CAAC,EAAE,EAAEA,KAAKoF,IAAI,GAAGpF,KAAKmF,OAAO,GAAG,CAAC,EAAE,EAAEnF,KAAKmF,OAAO,CAAC9I,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,EAAEqK,SAAS1G,SAAS,mBAAmB,GACxGA,CAAAA,KAAKN,GAAG,GAAG,CAAC,GAAG,EAAEM,KAAKN,GAAG,EAAE,GAAG,EAAC;eAEhCkH,QAAQ;gBAACA;aAAM,GAAG,EAAE;SACzB,GACD,EAAE;WACHnB,MAAMI,SAAS,CAACK,OAAO,CAAC,CAAC3F,OAAS;gBAAC;mBAAO+E,SAAS/E;aAAM;WACxDkF,MAAMO,aAAa,GACnB;YAAC;YAAI,CAAC,4FAA4F,EAAEP,MAAMO,aAAa,EAAE;SAAC,GAC1H,EAAE;WACHL,QAAQF;KACZ,CAAC1E,IAAI,CAAC;IACP,OAAO;QACLgF;QACA3C,OAAO,GAAGqC,MAAMP,aAAa,CAAC,UAAU,CAAC;QACzCkB,QAAQ,GAAGX,MAAMQ,WAAW,CAAC,+BAA+B,CAAC;QAC7D1C;QACAiC,UAAUA,SAASC;QACnBzI;QACAqJ,aAAa,CAAC,KAAK,EAAEZ,MAAMP,aAAa,EAAE;QAC1CxF,KAAK+F,MAAM/F,GAAG;IAChB;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/weekly-summary.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n pluginFigureCellText,\n pluginFigureIsoWeek,\n pluginFigureWindows,\n type PluginFigureCell,\n type PluginFigureRow,\n type PluginFigureSummaryPart,\n type PluginFigureSummaryStat,\n type PluginFigureTable,\n} from '../plugin-manager/plugin-figures'\n\n/**\n * THE WEEKLY SUMMARY (AGL-3867): the free Monday emails that say how a\n * workspace did the week before — one for each site that had something to\n * report, and an overview of the workspace that adds the sites up.\n *\n * They spend nothing. Every figure comes from a `plugin-figures` reader that\n * declares a `weeklySummary`, and that reader's owner says what its table\n * means as tiles and ranked rows, so each plugin's counting rules decide what\n * a figure is and nothing here names one. AI weekly insights (AGL-2915) are\n * the paid version that explains the figures, and stay opt-in because each\n * one spends the workspace's AI credits.\n *\n * This module is the period, the wording helpers the readers use, and both\n * emails' words and layout; the reads and the sends are\n * `@aglyn/tenant-data-admin/server/weekly-summary`. The layout is drawn as\n * email-safe tables with inline styles, in colors the caller resolves from\n * the email theme.\n */\n\n/** The key a person's switch is stored under in `users/{uid}.digestPrefs`; on until turned off. */\nexport const WEEKLY_SUMMARY_DIGEST_KEY = 'weeklySummary'\n\n/** The window every figure is read over. */\nexport const WEEKLY_SUMMARY_DAYS = 7\n\n/** Rows a ranked list names. */\nexport const WEEKLY_SUMMARY_TOP_ROWS = 5\n\n/** Counts a subject line or the overview's tiles lead with, at most. */\nexport const WEEKLY_SUMMARY_HEADLINE_COUNTS = 3\n\n/** Tiles in one row of an email. */\nconst TILES_PER_ROW = 3\n\n/**\n * The week a run reports on: the seven whole UTC days before the day it runs,\n * so a Monday run covers Monday to Sunday and never a part-day of today.\n * `now` is what each reader is handed; `week` keys the run's marker.\n */\nexport function weeklySummaryPeriod(runAt: Date): {\n now: Date\n week: string\n from: string\n to: string\n label: string\n} {\n const startOfToday = Date.UTC(runAt.getUTCFullYear(), runAt.getUTCMonth(), runAt.getUTCDate())\n const now = new Date(startOfToday - 1)\n const { current } = pluginFigureWindows(now, WEEKLY_SUMMARY_DAYS)\n return {\n now,\n week: pluginFigureIsoWeek(now),\n from: current.from,\n to: current.to,\n label: `${weeklySummaryDay(current.from)} – ${weeklySummaryDay(current.to)}`,\n }\n}\n\n/** `2026-10-05` as \"Oct 5\". */\nexport function weeklySummaryDay(day: string): string {\n const at = new Date(`${day}T00:00:00Z`)\n return at.toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: 'UTC' })\n}\n\n/** `2026-10-26` as \"Mon, Oct 26\". */\nexport function weeklySummaryWeekday(day: string): string {\n const at = new Date(`${day}T00:00:00Z`)\n return at.toLocaleDateString('en-US', { weekday: 'short', month: 'short', day: 'numeric', timeZone: 'UTC' })\n}\n\nconst ISO_DAY = /\\b\\d{4}-\\d{2}-\\d{2}\\b/g\n\n/**\n * A sentence's dates as a person says them: \"Monday 2026-10-26\" as \"Monday,\n * Oct 26\". Tables hand the model their dates in ISO form, and it copies them.\n */\nexport function weeklySummaryPlainDates(text: string): string {\n const said = (day: string) => {\n const words = weeklySummaryDay(day)\n return words === 'Invalid Date' ? day : words\n }\n return text\n .replace(/\\b((?:Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day),? (\\d{4}-\\d{2}-\\d{2})\\b/g, (_, weekday: string, day: string) => `${weekday}, ${said(day)}`)\n .replace(ISO_DAY, said)\n}\n\n// ── Helpers the readers word their parts with ──────────────────────────────\n\n/** A cell as a number, `0` for anything that is not one. */\nexport function figureCount(value: PluginFigureCell | undefined): number {\n return typeof value === 'number' && Number.isFinite(value) ? value : 0\n}\n\n/** The row whose `key` cell is `label`: \"Visitors\" in a table of figures. */\nexport function figureRow(table: PluginFigureTable, key: string, label: string): PluginFigureRow | undefined {\n return table.rows.find((row) => row[key] === label)\n}\n\n/** Whether a table carries a column, so a reader that changed shape is noticed rather than misread. */\nexport function figureHasColumn(table: PluginFigureTable, key: string): boolean {\n return table.columns.some((column) => column.key === key)\n}\n\n/** A cell as a tile, with its change when the table has one. */\nexport function figureStat(\n table: PluginFigureTable,\n row: PluginFigureRow,\n key: string,\n label: string,\n options: { change?: string; total?: { one: string; many: string } } = {},\n): PluginFigureSummaryStat {\n const change = options.change ? row[options.change] : undefined\n return {\n label,\n value: pluginFigureCellText(table, key, row[key] ?? 0),\n ...(typeof change === 'number' ? { change } : {}),\n ...(options.total ? { total: { count: figureCount(row[key]), ...options.total } } : {}),\n }\n}\n\n/** The named rows with the most of `key`, as ranked rows with their change; `[]` when none has any. */\nexport function figureRanked(\n table: PluginFigureTable,\n nameKey: string,\n key: string,\n rows: readonly PluginFigureRow[] = table.rows,\n): Array<{ label: string; value: string; change?: number }> {\n return rows\n .filter((row) => typeof row[nameKey] === 'string' && figureCount(row[key]) > 0)\n .slice(0, WEEKLY_SUMMARY_TOP_ROWS)\n .map((row) => {\n const change = row['change']\n return {\n label: String(row[nameKey]),\n value: pluginFigureCellText(table, key, row[key] ?? 0),\n ...(typeof change === 'number' ? { change } : {}),\n }\n })\n}\n\n/** A table of days as a chart, oldest first, the busiest marked; `[]` for a week with nothing in it. */\nexport function figureBars(\n table: PluginFigureTable,\n dayKey: string,\n key: string,\n): NonNullable<PluginFigureSummaryPart['bars']> {\n const most = Math.max(...table.rows.map((row) => figureCount(row[key])), 0)\n if (!most) return []\n return table.rows.map((row) => ({\n label: weeklySummaryWeekday(String(row[dayKey])),\n value: figureCount(row[key]),\n display: pluginFigureCellText(table, key, row[key] ?? 0),\n marked: figureCount(row[key]) === most,\n }))\n}\n\n/** A row's label as a person reads it, and the page it names, when it names one. */\nexport function weeklySummaryRowLink(label: string, siteUrl: string | null): { label: string; url: string | null } {\n const page = label.startsWith('/')\n return { label: label === '/' ? 'Home' : label, url: page && siteUrl ? `${siteUrl}${label === '/' ? '' : label}` : null }\n}\n\n/** \"1 order\", \"18 orders\". */\nexport function figurePlural(count: number, one: string, many: string): string {\n return `${count.toLocaleString('en-US')} ${count === 1 ? one : many}`\n}\n\n// ── The emails ─────────────────────────────────────────────────────────────\n\n/** One site's figures for the week. */\nexport interface WeeklySummarySite {\n name: string\n /** The site's dashboard in the console, absolute; `null` with no origin to build it from. */\n url: string | null\n /**\n * Where the site itself is, so a reader knows which site this is: its\n * custom domain when it serves on one, else its platform address. `null`\n * for a site with no address yet.\n */\n address?: { label: string; url: string } | null\n parts: readonly PluginFigureSummaryPart[]\n}\n\n/** The colors an email is drawn in, resolved from its theme by the caller. */\nexport interface WeeklySummaryColors {\n text: string\n muted: string\n border: string\n /** A tile's ground. */\n surface: string\n /** The accent rule beside a callout. */\n accent: string\n /** Links: the email theme's own link color, the one every other link in the email wears. */\n link: string\n /** A rise and a fall. */\n up: string\n down: string\n}\n\n/** A site with anything to say. */\nexport function weeklySummaryHasNews(site: Pick<WeeklySummarySite, 'parts'>): boolean {\n return site.parts.length > 0\n}\n\n/** The counts the readers offered for adding up, summed by noun, in the order they were first given. */\nexport function weeklySummaryTotals(\n sites: ReadonlyArray<Pick<WeeklySummarySite, 'parts'>>,\n): Array<{ count: number; one: string; many: string }> {\n const sums = new Map<string, { count: number; one: string; many: string }>()\n for (const site of sites) {\n for (const part of site.parts) {\n for (const stat of part.stats ?? []) {\n if (!stat.total || stat.total.count <= 0) continue\n const sum = sums.get(stat.total.one)\n sums.set(stat.total.one, sum ? { ...sum, count: sum.count + stat.total.count } : { ...stat.total })\n }\n }\n }\n return [...sums.values()]\n}\n\nfunction headline(sites: ReadonlyArray<Pick<WeeklySummarySite, 'parts'>>): string {\n return weeklySummaryTotals(sites)\n .slice(0, WEEKLY_SUMMARY_HEADLINE_COUNTS)\n .map(({ count, one, many }) => figurePlural(count, one, many))\n .join(', ')\n}\n\n/** \"+12.5%\", \"−27.9%\", \"no change\"; `null` with nothing to compare with. */\nexport function weeklySummaryChange(change: number | null | undefined): { text: string; sign: 1 | -1 | 0 } | null {\n if (typeof change !== 'number' || !Number.isFinite(change)) return null\n if (change === 0) return { text: 'no change', sign: 0 }\n const amount = Math.abs(change).toLocaleString('en-US', { maximumFractionDigits: 1 })\n return change > 0 ? { text: `+${amount}%`, sign: 1 } : { text: `−${amount}%`, sign: -1 }\n}\n\nconst esc = (value: string): string =>\n value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"')\n\nconst FONT = 'Helvetica, Arial, sans-serif'\n\nconst capitalized = (value: string): string => value.charAt(0).toUpperCase() + value.slice(1)\n\n/**\n * A label that reads like an address — `www.google.com` — kept from being\n * turned into a link by the inbox, which would draw it in the inbox's own\n * blue beside the theme's links. A zero-width space after each dot breaks\n * the detection and nothing a reader sees.\n */\nconst unlinked = (value: string): string => esc(value).replace(/\\./g, '.\\u200b')\n\nfunction changeHtml(change: number | null | undefined, colors: WeeklySummaryColors): string {\n const said = weeklySummaryChange(change)\n if (!said) return ''\n const color = said.sign > 0 ? colors.up : said.sign < 0 ? colors.down : colors.muted\n const arrow = said.sign > 0 ? '▲ ' : said.sign < 0 ? '▼ ' : ''\n return `<div style=\"font-family:${FONT};font-size:13px;line-height:1.4;font-weight:600;color:${color};\">${arrow}${esc(said.text)}</div>`\n}\n\n/**\n * How many tiles share each row: one row of up to three, two rows of two for\n * four, then rows of three — so a row is never left with an empty slot\n * beside two tiles.\n */\nexport function weeklySummaryTileRows(count: number): number[] {\n if (count <= 0) return []\n if (count <= TILES_PER_ROW) return [count]\n if (count === 4) return [2, 2]\n const rows: number[] = []\n for (let left = count; left > 0; left -= TILES_PER_ROW) rows.push(Math.min(TILES_PER_ROW, left))\n return rows\n}\n\n/** The gap between tiles, across and down. */\nconst TILE_GAP_PX = 8\n\n/** A cell that is only a gap: nothing in it may hold it open. */\nconst TILE_GAP = 'font-size:0;line-height:0;padding:0;'\n\n/**\n * Tiles, each a value, its label and its change, filling the width of their\n * row. The tile is the table cell itself, so a row's tiles are one height\n * whichever of them wraps, in every mail client; the gaps are cells of their own.\n */\nfunction tilesHtml(stats: readonly PluginFigureSummaryStat[], colors: WeeklySummaryColors): string {\n const sizes = weeklySummaryTileRows(stats.length)\n const rows: string[] = []\n let at = 0\n sizes.forEach((size) => {\n const cells = stats.slice(at, at + size)\n at += size\n // A tile alone takes half the row, not all of it, so it reads as a tile.\n const columns = Math.max(size, 2)\n const width = `${Math.floor(100 / columns)}%`\n const tds: string[] = []\n for (let index = 0; index < columns; index += 1) {\n if (index > 0) tds.push(`<td style=\"width:${TILE_GAP_PX}px;${TILE_GAP}\"> </td>`)\n const stat = cells[index]\n tds.push(\n stat\n ? `<td style=\"width:${width};background-color:${colors.surface};border:1px solid ${colors.border};border-radius:8px;padding:12px 14px;vertical-align:top;\">` +\n `<div style=\"font-family:${FONT};font-size:24px;line-height:1.2;font-weight:700;color:${colors.text};\">${esc(stat.value)}</div>` +\n `<div style=\"font-family:${FONT};font-size:13px;line-height:1.4;color:${colors.muted};\">${esc(stat.label)}</div>` +\n changeHtml(stat.change, colors) +\n `</td>`\n : `<td style=\"width:${width};\"></td>`,\n )\n }\n rows.push(`<tr>${tds.join('')}</tr>`)\n rows.push(`<tr><td colspan=\"${columns * 2 - 1}\" style=\"height:${TILE_GAP_PX}px;${TILE_GAP}\"> </td></tr>`)\n })\n return `<table role=\"presentation\" style=\"width:100%;border-collapse:separate;border-spacing:0;table-layout:fixed;\">${rows.join('')}</table>`\n}\n\nfunction sectionTitleHtml(title: string, colors: WeeklySummaryColors): string {\n return (\n `<div style=\"font-family:${FONT};font-size:12px;line-height:1.4;font-weight:700;letter-spacing:0.06em;` +\n `text-transform:uppercase;color:${colors.muted};padding:0 0 8px;\">${esc(title)}</div>`\n )\n}\n\n/** A figure in a sentence: a count, a sum or a percent, never the digits in a path or a date. */\nconst FIGURE =\n /(?<![\\p{L}\\p{N}_./-])(?<!(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) )[+\\-−]?[$€£¥]?(?:\\d{1,3}(?:,\\d{3})+|\\d+)(?:\\.\\d+)?%?(?![\\p{L}\\p{N}_/-])/gu\n\n/** A sentence with its figures in bold, so an eye running down the email lands on them. */\nfunction figuresHtml(text: string, colors: WeeklySummaryColors): string {\n let html = ''\n let at = 0\n for (const match of text.matchAll(FIGURE)) {\n html += `${unlinked(text.slice(at, match.index))}<strong style=\"font-weight:700;color:${colors.text};\">${esc(match[0])}</strong>`\n at = match.index + match[0].length\n }\n return html + unlinked(text.slice(at))\n}\n\n/** A figure a digest section lists: a page and its views. */\nexport interface WeeklySummarySectionRow {\n label: string\n /** Where the label goes: the page itself. */\n url?: string | null\n value: string\n change?: number | null\n}\n\n/** One day of a section's chart; `marked` when it is a day the section is about. */\nexport interface WeeklySummarySectionBar {\n label: string\n value: number\n /** The value as a person reads it. */\n display: string\n marked: boolean\n}\n\n/** One point of a section: a line to scan, the sentence behind it and, in the AI note, why and what next. */\nexport interface WeeklySummarySectionPoint {\n headline: string | null\n text: string | null\n why?: string | null\n next?: string | null\n /** The report a next step points at. */\n nextLink?: { label: string; url: string } | null\n}\n\n/** One topic of a weekly email, told once: what stood out, and the figures behind it. */\nexport interface WeeklySummarySection {\n /** Absent in the AI note, where each point names its own topic. */\n title?: string | null\n /** Where the figures can be seen in full. */\n link?: { label: string; url: string } | null\n points: readonly WeeklySummarySectionPoint[]\n stats?: readonly PluginFigureSummaryStat[]\n rows?: readonly WeeklySummarySectionRow[]\n bars?: readonly WeeklySummarySectionBar[]\n}\n\n/** Tiles on their own, for an email that leads with its headline figures. */\nexport function weeklySummaryTilesHtml(stats: readonly PluginFigureSummaryStat[], colors: WeeklySummaryColors): string {\n return stats.length ? `<div style=\"padding:12px 0 8px;\">${tilesHtml(stats, colors)}</div>` : ''\n}\n\n/** A tinted block with an accent rule: a heading, then what it says, already drawn. */\nfunction calloutHtml(heading: string, bodyHtml: string, colors: WeeklySummaryColors): string {\n return (\n `<div style=\"margin:16px 0 0;background-color:${colors.surface};border-left:3px solid ${colors.accent};border-radius:4px;padding:14px 16px;\">` +\n `<div style=\"font-family:${FONT};font-size:14px;line-height:1.5;font-weight:700;color:${colors.text};\">${esc(heading)}</div>` +\n `<div style=\"font-family:${FONT};font-size:14px;line-height:1.5;color:${colors.text};\">${bodyHtml}</div>` +\n `</div>`\n )\n}\n\n/** What an email opens with: its own read of the week, under a heading. */\nexport function weeklySummaryLeadHtml(heading: string, text: string, colors: WeeklySummaryColors): string {\n return calloutHtml(heading, figuresHtml(text, colors), colors)\n}\n\n/** A line of small print inside an email's body. */\nexport function weeklySummaryNoteHtml(text: string, colors: WeeklySummaryColors): string {\n return `<div style=\"font-family:${FONT};font-size:13px;line-height:1.5;color:${colors.muted};padding:4px 0 8px;\">${unlinked(text)}</div>`\n}\n\nfunction sectionRowsHtml(rows: readonly WeeklySummarySectionRow[], colors: WeeklySummaryColors): string {\n const cell = `font-family:${FONT};font-size:14px;line-height:1.4;padding:7px 0;`\n // No column for a change no row has, so the figures reach the edge.\n const changes = rows.some((row) => weeklySummaryChange(row.change))\n const trs = rows.map((row, index) => {\n const border = index > 0 ? `border-top:1px solid ${colors.border};` : ''\n const label = row.url\n ? `<a href=\"${esc(row.url)}\" style=\"color:${colors.link};text-decoration:none;font-weight:600;\">${unlinked(row.label)}</a>`\n : unlinked(row.label)\n return (\n `<tr>` +\n `<td style=\"${cell}${border}color:${colors.text};word-break:break-word;\">${label}</td>` +\n `<td style=\"${cell}${border}color:${colors.text};font-weight:600;padding-left:12px;text-align:right;white-space:nowrap;\">${esc(row.value)}</td>` +\n (changes\n ? `<td style=\"${cell}${border}padding-left:12px;text-align:right;white-space:nowrap;\">${changeHtml(row.change, colors)}</td>`\n : '') +\n `</tr>`\n )\n })\n return `<table role=\"presentation\" style=\"width:100%;border-collapse:collapse;margin-top:8px;\">${trs.join('')}</table>`\n}\n\n/** Horizontal bars, drawn in table cells so every mail client keeps them. */\nfunction sectionBarsHtml(bars: readonly WeeklySummarySectionBar[], colors: WeeklySummaryColors): string {\n const most = Math.max(...bars.map((bar) => bar.value), 1)\n const trs = bars.map((bar) => {\n const text = `font-family:${FONT};font-size:13px;line-height:1.3;color:${bar.marked ? colors.text : colors.muted};white-space:nowrap;`\n const weight = bar.marked ? 'font-weight:700;' : ''\n return (\n `<tr>` +\n `<td style=\"${text}${weight}padding:3px 10px 3px 0;width:1%;\">${esc(bar.label)}</td>` +\n `<td style=\"padding:3px 0;\"><div style=\"background-color:${bar.marked ? colors.accent : colors.border};border-radius:2px;font-size:0;height:10px;line-height:0;width:${Math.max(1, Math.round((bar.value / most) * 100))}%;\"> </div></td>` +\n `<td style=\"${text}${weight}padding:3px 0 3px 10px;text-align:right;width:1%;\">${esc(bar.display)}</td>` +\n `</tr>`\n )\n })\n return `<table role=\"presentation\" style=\"width:100%;border-collapse:collapse;margin-top:8px;\">${trs.join('')}</table>`\n}\n\n/** \"Likely why: …\": a labeled line under a point, a link at its end when it has one. */\nfunction pointLineHtml(\n label: string,\n text: string,\n link: { label: string; url: string } | null,\n colors: WeeklySummaryColors,\n): string {\n return (\n `<div style=\"font-family:${FONT};font-size:14px;line-height:1.5;color:${colors.muted};padding:6px 0 0;\">` +\n `<strong style=\"font-weight:700;color:${colors.text};\">${esc(label)}:</strong> ${figuresHtml(text, colors)}` +\n (link\n ? ` <a href=\"${esc(link.url)}\" style=\"font-weight:600;color:${colors.link};text-decoration:none;white-space:nowrap;\">${esc(link.label)} →</a>`\n : '') +\n `</div>`\n )\n}\n\nfunction sectionHtml(section: WeeklySummarySection, colors: WeeklySummaryColors, first: boolean): string {\n const link = section.link\n ? `<td style=\"padding:0;text-align:right;vertical-align:baseline;white-space:nowrap;\">` +\n `<a href=\"${esc(section.link.url)}\" style=\"font-family:${FONT};font-size:13px;line-height:1.4;font-weight:600;color:${colors.link};text-decoration:none;\">${esc(section.link.label)} →</a>` +\n `</td>`\n : ''\n const points = section.points.map(\n (point) =>\n `<div style=\"padding:6px 0 0;\">` +\n (point.headline\n ? `<div style=\"font-family:${FONT};font-size:16px;line-height:1.35;font-weight:700;color:${colors.text};\">${unlinked(point.headline)}</div>`\n : '') +\n (point.text\n ? `<div style=\"font-family:${FONT};font-size:14px;line-height:1.5;color:${colors.muted};\">${figuresHtml(point.text, colors)}</div>`\n : '') +\n (point.why ? pointLineHtml('Likely why', point.why, null, colors) : '') +\n (point.next ? pointLineHtml('Try this', point.next, point.nextLink ?? null, colors) : '') +\n `</div>`,\n )\n return (\n `<div style=\"padding:${first ? '8px' : '18px'} 0 18px;${first ? '' : `border-top:1px solid ${colors.border};`}\">` +\n (section.title\n ? `<table role=\"presentation\" style=\"width:100%;border-collapse:collapse;\"><tr>` +\n `<td style=\"font-family:${FONT};font-size:12px;line-height:1.4;font-weight:700;letter-spacing:0.06em;text-transform:uppercase;color:${colors.muted};padding:0;\">${esc(section.title)}</td>` +\n link +\n `</tr></table>`\n : '') +\n points.join('') +\n (section.stats?.length ? `<div style=\"padding:8px 0 0;\">${tilesHtml(section.stats, colors)}</div>` : '') +\n (section.rows?.length ? sectionRowsHtml(section.rows, colors) : '') +\n (section.bars?.length ? sectionBarsHtml(section.bars, colors) : '') +\n `</div>`\n )\n}\n\n/** A weekly email's topics, a hairline between them; `following` when something already sits above the first. */\nexport function weeklySummarySectionsHtml(\n sections: readonly WeeklySummarySection[],\n colors: WeeklySummaryColors,\n following = false,\n): string {\n return sections.map((section, index) => sectionHtml(section, colors, index === 0 && !following)).join('')\n}\n\n/** The small print under the button, with its one link. */\nexport function weeklySummaryFootnoteHtml(\n text: string,\n link: { label: string; url: string } | null,\n colors: WeeklySummaryColors,\n): string {\n return (\n `<div style=\"font-family:${FONT};font-size:12px;line-height:1.5;color:${colors.muted};padding:12px 0 0;\">` +\n esc(text) +\n (link ? ` <a href=\"${esc(link.url)}\" style=\"color:${colors.link};text-decoration:underline;\">${esc(link.label)}</a>` : '') +\n `</div>`\n )\n}\n\n/** A reader's part as a section of the email, its page rows linked to the site. */\nfunction partSection(part: PluginFigureSummaryPart, siteUrl: string | null): WeeklySummarySection {\n return {\n title: part.title,\n link: part.link ?? null,\n points: part.note ? [{ headline: null, text: part.note }] : [],\n ...(part.stats?.length ? { stats: part.stats } : {}),\n ...(part.rows?.length ? { rows: part.rows.map((row) => ({ ...row, ...weeklySummaryRowLink(row.label, siteUrl) })) } : {}),\n ...(part.bars?.length ? { bars: part.bars } : {}),\n }\n}\n\n/** \"aglyn.com · Aglyn LLC\": which site, linked, and whose. */\nfunction addressHtml(site: WeeklySummarySite, workspaceName: string, colors: WeeklySummaryColors): string {\n const address = site.address\n ? `<a href=\"${esc(site.address.url)}\" style=\"color:${colors.link};text-decoration:underline;font-weight:600;\">${esc(site.address.label)}</a>`\n : `<span style=\"font-weight:600;\">${esc(site.name)}</span>`\n return (\n `<div style=\"font-family:${FONT};font-size:14px;line-height:1.5;color:${colors.muted};padding:0 0 4px;\">` +\n `${address} · ${esc(workspaceName)}</div>`\n )\n}\n\nfunction insightsHtml(url: string, colors: WeeklySummaryColors): string {\n return calloutHtml(\n 'Want to know why the numbers moved?',\n `AI weekly insights read each site's week for you: why the numbers moved, and one thing to do next. ` +\n `<a href=\"${esc(url)}\" style=\"color:${colors.link};text-decoration:underline;\">Turn them on from Ask about your numbers</a>.`,\n colors,\n )\n}\n\nfunction partText(part: PluginFigureSummaryPart): string[] {\n const lines = [part.title.toUpperCase()]\n if (part.note) lines.push(part.note)\n for (const stat of part.stats ?? []) {\n const said = weeklySummaryChange(stat.change)\n lines.push(`${stat.label}: ${stat.value}${said ? ` (${said.text})` : ''}`)\n }\n for (const row of part.rows ?? []) {\n const said = weeklySummaryChange(row.change)\n lines.push(`- ${row.label}: ${row.value}${said ? ` (${said.text})` : ''}`)\n }\n for (const bar of part.bars ?? []) lines.push(`- ${bar.label}: ${bar.display}`)\n if (part.link) lines.push(`${part.link.label}: ${part.link.url}`)\n return lines\n}\n\n/** What a send fills a weekly summary email's tokens with. */\nexport interface WeeklySummaryEmail {\n subject: string\n /** The heading: \"Aglyn last week\". */\n title: string\n /** \"Oct 5 – Oct 11, compared with the week before\". */\n period: string\n /** The figures, drawn. */\n html: string\n /** The small print under the button. */\n footnote: string\n /** The whole email as plain text, closing line included. */\n text: string\n buttonLabel: string\n /** Where the button goes; `''` when there is no console origin to link to. */\n url: string\n}\n\ninterface CommonInput {\n workspaceName: string\n productName: string\n periodLabel: string\n colors: WeeklySummaryColors\n /** Where AI weekly insights are turned on, when the plan includes them and this person has not; else `null`. */\n aiInsightsUrl: string | null\n settingsUrl: string\n}\n\nfunction footnote(input: CommonInput): string {\n return weeklySummaryFootnoteHtml('', { label: 'Change what you are emailed about', url: input.settingsUrl }, input.colors)\n}\n\nfunction closing(input: CommonInput): string[] {\n return [\n '',\n `You get this summary because you manage ${input.workspaceName}. Turn it off in Notifications: ${input.settingsUrl}`,\n ]\n}\n\n/**\n * One site's email, or `null` for a site with nothing to report. `workspace`\n * carries the workspace's own parts when this site's email stands in for the\n * overview, in a workspace with one active site.\n */\nexport function composeWeeklySummarySiteEmail(\n input: CommonInput & { site: WeeklySummarySite; workspace?: readonly PluginFigureSummaryPart[] },\n): WeeklySummaryEmail | null {\n const workspace = input.workspace ?? []\n if (!weeklySummaryHasNews(input.site) && !workspace.length) return null\n const lead = headline([input.site])\n const subject = lead ? `${input.site.name} last week: ${lead}` : `${input.site.name} last week`\n const siteUrl = input.site.address?.url ?? null\n const html =\n addressHtml(input.site, input.workspaceName, input.colors) +\n weeklySummarySectionsHtml(\n [\n ...input.site.parts.map((part) => partSection(part, siteUrl)),\n ...workspace.map((part) => partSection({ ...part, title: `${input.workspaceName} · ${part.title}` }, null)),\n ],\n input.colors,\n ) +\n (input.aiInsightsUrl ? insightsHtml(input.aiInsightsUrl, input.colors) : '')\n const text = [\n `${input.site.name} last week, ${input.periodLabel}. A change in brackets is against the week before.`,\n `Site: ${input.site.address ? `${input.site.address.label} (${input.site.address.url})` : input.site.name} · ${input.workspaceName}`,\n ...input.site.parts.flatMap((part) => ['', ...partText(part)]),\n ...workspace.flatMap((part) => ['', ...partText({ ...part, title: `${input.workspaceName} · ${part.title}` })]),\n ...(input.site.url ? ['', `Open ${input.site.name} in ${input.productName}: ${input.site.url}`] : []),\n ...(input.aiInsightsUrl\n ? ['', `Want to know why the numbers moved, and what to do next? Turn on AI weekly insights from Ask about your numbers: ${input.aiInsightsUrl}`]\n : []),\n ...closing(input),\n ].join('\\n')\n return {\n subject,\n title: `${input.site.name} last week`,\n period: `${input.periodLabel}, compared with the week before`,\n html,\n footnote: footnote(input),\n text,\n buttonLabel: `Open ${input.site.name}`,\n url: input.site.url ?? '',\n }\n}\n\n/**\n * The workspace overview: the week's totals across its sites, a line for each\n * site, and the workspace's own figures, or `null` when nothing anywhere has\n * anything to report.\n */\nexport function composeWeeklySummaryOverviewEmail(\n input: CommonInput & {\n sites: readonly WeeklySummarySite[]\n workspace: readonly PluginFigureSummaryPart[]\n /** The workspace's home in the console, absolute; `''` with no origin. */\n url: string\n },\n): WeeklySummaryEmail | null {\n const active = input.sites.filter(weeklySummaryHasNews)\n if (!active.length && !input.workspace.length) return null\n const totals = weeklySummaryTotals(active)\n const lead = totals\n .slice(0, WEEKLY_SUMMARY_HEADLINE_COUNTS)\n .map(({ count, one, many }) => figurePlural(count, one, many))\n .join(', ')\n const subject = lead ? `Your week at ${input.workspaceName}: ${lead}` : `Your week at ${input.workspaceName}`\n const { colors } = input\n const totalsPart: PluginFigureSummaryPart | null = totals.length\n ? {\n title: active.length === 1 ? 'At a glance' : `Across ${active.length} sites`,\n stats: totals.slice(0, TILES_PER_ROW * 2).map(({ count, one, many }) => ({\n label: capitalized(count === 1 ? one : many),\n value: count.toLocaleString('en-US'),\n })),\n }\n : null\n const siteLine = (site: WeeklySummarySite): string =>\n site.parts\n .flatMap((part) => part.stats ?? [])\n .filter((stat) => stat.total && stat.total.count > 0)\n .slice(0, WEEKLY_SUMMARY_HEADLINE_COUNTS)\n .map((stat) => {\n const total = stat.total as NonNullable<PluginFigureSummaryStat['total']>\n const said = weeklySummaryChange(stat.change)\n return `${figurePlural(total.count, total.one, total.many)}${said ? ` (${said.text})` : ''}`\n })\n .join(' · ')\n const quietCount = input.sites.length - active.length\n const quiet = quietCount\n ? `${figurePlural(quietCount, 'other site', 'other sites')} had nothing to report.`\n : ''\n const sitesHtml = active.length\n ? `<div style=\"padding:18px 0 8px;${totalsPart ? `border-top:1px solid ${colors.border};` : ''}\">` +\n sectionTitleHtml('Your sites', colors) +\n `<table role=\"presentation\" style=\"width:100%;border-collapse:collapse;\">` +\n active\n .map((site, index) => {\n const border = index < active.length - 1 ? `border-bottom:1px solid ${colors.border};` : ''\n const name = site.url\n ? `<a href=\"${esc(site.url)}\" style=\"color:${colors.link};text-decoration:none;font-weight:700;\">${esc(site.name)}</a>`\n : `<span style=\"font-weight:700;\">${esc(site.name)}</span>`\n const line = siteLine(site)\n const address = site.address\n ? ` <a href=\"${esc(site.address.url)}\" style=\"color:${colors.muted};text-decoration:underline;font-size:13px;font-weight:400;\">${esc(site.address.label)}</a>`\n : ''\n return (\n `<tr><td style=\"font-family:${FONT};font-size:15px;line-height:1.4;color:${colors.text};padding:10px 0;${border}\">` +\n name +\n address +\n (line ? `<div style=\"font-size:13px;line-height:1.5;color:${colors.muted};\">${esc(line)}</div>` : '') +\n `</td></tr>`\n )\n })\n .join('') +\n `</table>` +\n (quiet\n ? `<div style=\"font-family:${FONT};font-size:13px;line-height:1.5;color:${colors.muted};padding:4px 0 0;\">${esc(quiet)}</div>`\n : '') +\n `</div>`\n : ''\n const html =\n (totalsPart ? weeklySummarySectionsHtml([partSection(totalsPart, null)], colors) : '') +\n sitesHtml +\n weeklySummarySectionsHtml(\n input.workspace.map((part) => partSection(part, null)),\n colors,\n Boolean(totalsPart || sitesHtml),\n ) +\n (active.length > 1\n ? `<div style=\"font-family:${FONT};font-size:13px;line-height:1.5;color:${colors.muted};padding:8px 0 0;\">Each site's own summary arrives beside this one.</div>`\n : '') +\n (input.aiInsightsUrl ? insightsHtml(input.aiInsightsUrl, colors) : '')\n const text = [\n `Here is how ${input.workspaceName} did last week, ${input.periodLabel}. A change in brackets is against the week before.`,\n ...(totalsPart ? ['', ...partText(totalsPart)] : []),\n ...(active.length\n ? [\n '',\n 'YOUR SITES',\n ...active.map(\n (site) =>\n `- ${site.name}${site.address ? ` (${site.address.label})` : ''}: ${siteLine(site) || 'see its summary'}` +\n (site.url ? ` · ${site.url}` : ''),\n ),\n ...(quiet ? [quiet] : []),\n ]\n : []),\n ...input.workspace.flatMap((part) => ['', ...partText(part)]),\n ...(input.aiInsightsUrl\n ? ['', `Want to know why the numbers moved, and what to do next? Turn on AI weekly insights from Ask about your numbers: ${input.aiInsightsUrl}`]\n : []),\n ...closing(input),\n ].join('\\n')\n return {\n subject,\n title: `${input.workspaceName} last week`,\n period: `${input.periodLabel}, compared with the week before`,\n html,\n footnote: footnote(input),\n text,\n buttonLabel: `Open ${input.workspaceName}`,\n url: input.url,\n }\n}\n"],"names":["pluginFigureCellText","pluginFigureIsoWeek","pluginFigureWindows","WEEKLY_SUMMARY_DIGEST_KEY","WEEKLY_SUMMARY_DAYS","WEEKLY_SUMMARY_TOP_ROWS","WEEKLY_SUMMARY_HEADLINE_COUNTS","TILES_PER_ROW","weeklySummaryPeriod","runAt","startOfToday","Date","UTC","getUTCFullYear","getUTCMonth","getUTCDate","now","current","week","from","to","label","weeklySummaryDay","day","at","toLocaleDateString","month","timeZone","weeklySummaryWeekday","weekday","ISO_DAY","weeklySummaryPlainDates","text","said","words","replace","_","figureCount","value","Number","isFinite","figureRow","table","key","rows","find","row","figureHasColumn","columns","some","column","figureStat","options","change","undefined","total","count","figureRanked","nameKey","filter","slice","map","String","figureBars","dayKey","most","Math","max","display","marked","weeklySummaryRowLink","siteUrl","page","startsWith","url","figurePlural","one","many","toLocaleString","weeklySummaryHasNews","site","parts","length","weeklySummaryTotals","sites","sums","Map","part","stat","stats","sum","get","set","values","headline","join","weeklySummaryChange","sign","amount","abs","maximumFractionDigits","esc","FONT","capitalized","charAt","toUpperCase","unlinked","changeHtml","colors","color","up","down","muted","arrow","weeklySummaryTileRows","left","push","min","TILE_GAP_PX","TILE_GAP","tilesHtml","sizes","forEach","size","cells","width","floor","tds","index","surface","border","sectionTitleHtml","title","FIGURE","figuresHtml","html","match","matchAll","weeklySummaryTilesHtml","calloutHtml","heading","bodyHtml","accent","weeklySummaryLeadHtml","weeklySummaryNoteHtml","sectionRowsHtml","cell","changes","trs","link","sectionBarsHtml","bars","bar","weight","round","pointLineHtml","sectionHtml","section","first","points","point","why","next","nextLink","weeklySummarySectionsHtml","sections","following","weeklySummaryFootnoteHtml","partSection","note","addressHtml","workspaceName","address","name","insightsHtml","partText","lines","footnote","input","settingsUrl","closing","composeWeeklySummarySiteEmail","workspace","lead","subject","aiInsightsUrl","periodLabel","flatMap","productName","period","buttonLabel","composeWeeklySummaryOverviewEmail","active","totals","totalsPart","siteLine","quietCount","quiet","sitesHtml","line","Boolean"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,oBAAoB,EACpBC,mBAAmB,EACnBC,mBAAmB,QAMd,sCAAkC;AAEzC;;;;;;;;;;;;;;;;;CAiBC,GAED,iGAAiG,GACjG,OAAO,MAAMC,4BAA4B,gBAAe;AAExD,0CAA0C,GAC1C,OAAO,MAAMC,sBAAsB,EAAC;AAEpC,8BAA8B,GAC9B,OAAO,MAAMC,0BAA0B,EAAC;AAExC,sEAAsE,GACtE,OAAO,MAAMC,iCAAiC,EAAC;AAE/C,kCAAkC,GAClC,MAAMC,gBAAgB;AAEtB;;;;CAIC,GACD,OAAO,SAASC,oBAAoBC,KAAW;IAO7C,MAAMC,eAAeC,KAAKC,GAAG,CAACH,MAAMI,cAAc,IAAIJ,MAAMK,WAAW,IAAIL,MAAMM,UAAU;IAC3F,MAAMC,MAAM,IAAIL,KAAKD,eAAe;IACpC,MAAM,EAAEO,OAAO,EAAE,GAAGf,oBAAoBc,KAAKZ;IAC7C,OAAO;QACLY;QACAE,MAAMjB,oBAAoBe;QAC1BG,MAAMF,QAAQE,IAAI;QAClBC,IAAIH,QAAQG,EAAE;QACdC,OAAO,GAAGC,iBAAiBL,QAAQE,IAAI,EAAE,GAAG,EAAEG,iBAAiBL,QAAQG,EAAE,GAAG;IAC9E;AACF;AAEA,6BAA6B,GAC7B,OAAO,SAASE,iBAAiBC,GAAW;IAC1C,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