@aglyn/plugins-ai 1.22.2 → 1.22.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -17
- package/src/lib/jobs/ai-site-import-actions.d.ts +7 -0
- package/src/lib/jobs/ai-site-import-actions.js +15 -0
- package/src/lib/jobs/ai-site-import-actions.js.map +1 -1
- package/src/lib/layout-language/ai-layout-compiler.js +46 -3
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/plugins-ai",
|
|
3
|
-
"version": "1.22.
|
|
3
|
+
"version": "1.22.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,22 +25,22 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.22.
|
|
29
|
-
"@aglyn/shared-data-enums": "1.22.
|
|
30
|
-
"@aglyn/shared-data-mdi": "1.22.
|
|
31
|
-
"@aglyn/shared-data-types": "1.22.
|
|
32
|
-
"@aglyn/shared-ui-email-campaigns": "1.22.
|
|
33
|
-
"@aglyn/shared-ui-jsx": "1.22.
|
|
34
|
-
"@aglyn/shared-ui-snackstack": "1.22.
|
|
35
|
-
"@aglyn/shared-ui-theme": "1.22.
|
|
36
|
-
"@aglyn/shared-util-email": "1.22.
|
|
37
|
-
"@aglyn/shared-util-errors": "1.22.
|
|
38
|
-
"@aglyn/shared-util-http": "1.22.
|
|
39
|
-
"@aglyn/shared-util-timestamp": "1.22.
|
|
40
|
-
"@aglyn/shared-util-tools": "1.22.
|
|
41
|
-
"@aglyn/tenant-data-admin": "1.22.
|
|
42
|
-
"@aglyn/tenant-feature-instance": "1.22.
|
|
43
|
-
"@aglyn/tenant-runtime": "1.22.
|
|
28
|
+
"@aglyn/aglyn": "1.22.3",
|
|
29
|
+
"@aglyn/shared-data-enums": "1.22.3",
|
|
30
|
+
"@aglyn/shared-data-mdi": "1.22.3",
|
|
31
|
+
"@aglyn/shared-data-types": "1.22.3",
|
|
32
|
+
"@aglyn/shared-ui-email-campaigns": "1.22.3",
|
|
33
|
+
"@aglyn/shared-ui-jsx": "1.22.3",
|
|
34
|
+
"@aglyn/shared-ui-snackstack": "1.22.3",
|
|
35
|
+
"@aglyn/shared-ui-theme": "1.22.3",
|
|
36
|
+
"@aglyn/shared-util-email": "1.22.3",
|
|
37
|
+
"@aglyn/shared-util-errors": "1.22.3",
|
|
38
|
+
"@aglyn/shared-util-http": "1.22.3",
|
|
39
|
+
"@aglyn/shared-util-timestamp": "1.22.3",
|
|
40
|
+
"@aglyn/shared-util-tools": "1.22.3",
|
|
41
|
+
"@aglyn/tenant-data-admin": "1.22.3",
|
|
42
|
+
"@aglyn/tenant-feature-instance": "1.22.3",
|
|
43
|
+
"@aglyn/tenant-runtime": "1.22.3",
|
|
44
44
|
"@swc/helpers": "0.5.24"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
@@ -21,6 +21,12 @@ import type { AiLayoutSection } from '../layout-language/ai-layout-language';
|
|
|
21
21
|
* trailing slash, anything else as written.
|
|
22
22
|
*/
|
|
23
23
|
export declare function aiSiteImportDestinationKey(to: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* A call button's words without the stray mark its source left after the
|
|
26
|
+
* verb (AGL-4152): a contractor's "Call- 555-010-0142" reads "Call
|
|
27
|
+
* 555-010-0142". Only the mark goes; every word stays as written.
|
|
28
|
+
*/
|
|
29
|
+
export declare function aiSiteImportCallLabel(text: string): string;
|
|
24
30
|
/**
|
|
25
31
|
* A redesigned section's calls to action, each once and each where it belongs
|
|
26
32
|
* (AGL-4152), whatever the answer and the source's kept groups gave:
|
|
@@ -39,6 +45,7 @@ export declare function aiSiteImportDestinationKey(to: string): string;
|
|
|
39
45
|
* words where one of them has them. A call and a page are two places. A
|
|
40
46
|
* closing band's "Contact us" and "Request a quote", both to the contact
|
|
41
47
|
* page with a call between them, read as a mistake.
|
|
48
|
+
* - A call button's words lose a stray mark after the verb ("Call- 555…").
|
|
42
49
|
* - Of buttons side by side, only the first is filled; the rest are outlined.
|
|
43
50
|
*/
|
|
44
51
|
export declare function aiSiteImportSectionActions(section: Pick<AiLayoutSection, 'cols' | 'blocks'>, cta?: string | null): Pick<AiLayoutSection, 'cols' | 'blocks'>;
|
|
@@ -35,6 +35,13 @@ const clean = (text)=>typeof text === 'string' ? text.replace(/\s+/g, ' ').trim(
|
|
|
35
35
|
if (/^https?:\/\//i.test(value)) return value.toLowerCase().replace(/^http:/, 'https:').replace(/[/?#]+$/, '');
|
|
36
36
|
return value;
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* A call button's words without the stray mark its source left after the
|
|
40
|
+
* verb (AGL-4152): a contractor's "Call- 555-010-0142" reads "Call
|
|
41
|
+
* 555-010-0142". Only the mark goes; every word stays as written.
|
|
42
|
+
*/ export function aiSiteImportCallLabel(text) {
|
|
43
|
+
return text.replace(/^(\s*(?:call|text|phone|tel)\b)\s*[-\u2013\u2014:|]+\s*(?=[+(\d])/i, '$1 ');
|
|
44
|
+
}
|
|
38
45
|
/** Whether a button is drawn filled: the compiler's default, `primary` or `large`. */ const filled = (block)=>block.kind === 'button' && (block.style === undefined || block.style === 'primary' || block.style === 'large');
|
|
39
46
|
/**
|
|
40
47
|
* A redesigned section's calls to action, each once and each where it belongs
|
|
@@ -54,6 +61,7 @@ const clean = (text)=>typeof text === 'string' ? text.replace(/\s+/g, ' ').trim(
|
|
|
54
61
|
* words where one of them has them. A call and a page are two places. A
|
|
55
62
|
* closing band's "Contact us" and "Request a quote", both to the contact
|
|
56
63
|
* page with a call between them, read as a mistake.
|
|
64
|
+
* - A call button's words lose a stray mark after the verb ("Call- 555…").
|
|
57
65
|
* - Of buttons side by side, only the first is filled; the rest are outlined.
|
|
58
66
|
*/ export function aiSiteImportSectionActions(section, cta) {
|
|
59
67
|
let { cols, blocks } = section;
|
|
@@ -213,6 +221,13 @@ const clean = (text)=>typeof text === 'string' ? text.replace(/\s+/g, ' ').trim(
|
|
|
213
221
|
}) : block
|
|
214
222
|
];
|
|
215
223
|
});
|
|
224
|
+
// A call button's words without a stray mark after the verb.
|
|
225
|
+
blocks = blocks.map((block)=>{
|
|
226
|
+
var _block_to;
|
|
227
|
+
return block.kind === 'button' && /^tel:/i.test((_block_to = block.to) != null ? _block_to : '') && block.text ? _extends({}, block, {
|
|
228
|
+
text: aiSiteImportCallLabel(block.text)
|
|
229
|
+
}) : block;
|
|
230
|
+
});
|
|
216
231
|
// Buttons side by side, each to its own place: the first filled.
|
|
217
232
|
const out = [];
|
|
218
233
|
for (const block of blocks){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-site-import-actions.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*==========================================\n * A PAGE'S CALLS TO ACTION UNDER IMPROVE IT (AGL-4152).\n *\n * The mechanical tidying of a section's buttons, the same whether a\n * redesign drew the page or the page kept its source's layout: each call to\n * action once, where it belongs. No model is asked; nothing is reworded.\n *=========================================*/\n\nimport type { AiLayoutBlock, AiLayoutItem, AiLayoutSection } from '../layout-language/ai-layout-language'\n\nconst clean = (text: unknown): string => (typeof text === 'string' ? text.replace(/\\s+/g, ' ').trim() : '')\n\n/** A button's words and where it goes, as one key: two that share it are the same action. */\nconst actionKey = (text: string | undefined, to: string | undefined): string => `${clean(text).toLowerCase()}\\u0000${to ?? ''}`\n\n/** How strongly a button asks: filled 0, outlined 1, quiet 2. */\nconst strength = (block: AiLayoutBlock): number => (filled(block) ? 0 : block.style === 'secondary' ? 1 : 2)\n\n/**\n * Where a button goes, as two that go to one place share it (AGL-4152): a\n * phone by its digits, an email and a web address in any case and without a\n * trailing slash, anything else as written.\n */\nexport function aiSiteImportDestinationKey(to: string): string {\n const value = to.trim()\n if (/^tel:/i.test(value)) return `tel:${value.slice(4).replace(/[^\\d+]/g, '')}`\n if (/^mailto:/i.test(value)) return value.toLowerCase()\n if (/^https?:\\/\\//i.test(value)) return value.toLowerCase().replace(/^http:/, 'https:').replace(/[/?#]+$/, '')\n return value\n}\n\n/** Whether a button is drawn filled: the compiler's default, `primary` or `large`. */\nconst filled = (block: AiLayoutBlock): boolean => block.kind === 'button' && (block.style === undefined || block.style === 'primary' || block.style === 'large')\n\n/**\n * A redesigned section's calls to action, each once and each where it belongs\n * (AGL-4152), whatever the answer and the source's kept groups gave:\n *\n * - Buttons placed in a row's columns under a group that runs the row's width,\n * with nothing else in those columns, sit in the cards they go to where each\n * goes where exactly one card does, else together under the group: a row of\n * two buttons under three cards read as a grid half filled.\n * - A link with the same words to the same place on every item of a group\n * (each review's \"See more reviews\") is shown once, as a button after the\n * group, unless the section already has that button. Where only some items\n * carry it, each is that item's own action and stays.\n * - The same button twice in a section is shown once, the first.\n * - Buttons anywhere in a section to the same place are one: the strongest,\n * filled over outlined over quiet, the first of equals, with the header's\n * words where one of them has them. A call and a page are two places. A\n * closing band's \"Contact us\" and \"Request a quote\", both to the contact\n * page with a call between them, read as a mistake.\n * - Of buttons side by side, only the first is filled; the rest are outlined.\n */\nexport function aiSiteImportSectionActions(section: Pick<AiLayoutSection, 'cols' | 'blocks'>, cta?: string | null): Pick<AiLayoutSection, 'cols' | 'blocks'> {\n let { cols, blocks } = section\n // Buttons in columns under a group across the row.\n const placed = blocks.filter((block) => block.col !== undefined)\n const group = blocks.find((block) => block.col === undefined && (block.items?.length ?? 0) >= 2 && block.kind !== 'list' && block.kind !== 'faq')\n if (cols && cols.length >= 2 && group && placed.length && placed.every((block) => block.kind === 'button')) {\n const items = group.items as AiLayoutItem[]\n const cards = placed.map((button) => items.flatMap((item, at) => (button.to && item.to === button.to && !item.links?.length ? [at] : [])))\n const own = cards.every((found) => found.length === 1) && new Set(cards.map((found) => found[0])).size === cards.length\n if (own) {\n const into = new Map(placed.map((button, at) => [cards[at]?.[0] as number, button]))\n const carded = { ...group, items: items.map((item, at) => (into.has(at) ? { ...item, links: [{ text: into.get(at)?.text ?? '', to: item.to as string, style: 'secondary' as const }] } : item)) }\n blocks = blocks.flatMap((block) => (block === group ? [carded] : placed.includes(block) ? [] : [block]))\n } else blocks = blocks.map((block) => (placed.includes(block) ? (({ col: _col, ...rest }) => rest)(block) : block))\n cols = undefined\n }\n // A link repeated across a group's items, once after the group.\n const buttons = new Set(blocks.flatMap((block) => (block.kind === 'button' ? [actionKey(block.text, block.to)] : [])))\n blocks = blocks.flatMap((block) => {\n const items = block.items\n if (!items || items.length < 2) return [block]\n const counted = new Map<string, { text: string; to?: string; style?: AiLayoutBlock['style']; on: number }>()\n for (const item of items) {\n for (const key of new Set((item.links ?? []).map((link) => actionKey(link.text, link.to)))) {\n const link = item.links?.find((entry) => actionKey(entry.text, entry.to) === key)\n const was = counted.get(key)\n if (link) counted.set(key, { text: link.text, ...(link.to ? { to: link.to } : {}), ...(link.style ? { style: link.style } : {}), on: (was?.on ?? 0) + 1 })\n }\n }\n const repeated = new Map([...counted].filter(([, entry]) => entry.on === items.length))\n if (!repeated.size) return [block]\n const stripped = items.map((item) => {\n if (!item.links?.length) return item\n const links = item.links.filter((link) => !repeated.has(actionKey(link.text, link.to)))\n const { links: _links, ...rest } = item\n return links.length ? { ...rest, links } : rest\n })\n const after = [...repeated].flatMap(([key, entry]): AiLayoutBlock[] => {\n if (buttons.has(key)) return []\n buttons.add(key)\n return [{ kind: 'button', text: entry.text, ...(entry.to ? { to: entry.to } : {}), ...(entry.style ? { style: entry.style } : {}), ...(block.col !== undefined ? { col: block.col } : {}) }]\n })\n return [{ ...block, items: stripped }, ...after]\n })\n // The same button twice, once.\n const seen = new Set<string>()\n blocks = blocks.filter((block) => {\n if (block.kind !== 'button' || !block.to) return true\n const key = actionKey(block.text, block.to)\n if (seen.has(key)) return false\n seen.add(key)\n return true\n })\n // Buttons anywhere in the section to one place: one, the strongest (filled over outlined over quiet), the first of\n // equals, in its own place; with the header's words where one of them has them. A call and a page are two places.\n const wanted = clean(cta).toLowerCase()\n const kept = new Map<string, AiLayoutBlock>()\n const worded = new Map<string, AiLayoutBlock>()\n for (const block of blocks) {\n if (block.kind !== 'button' || !block.to) continue\n const key = aiSiteImportDestinationKey(block.to)\n const was = kept.get(key)\n if (!was || strength(block) < strength(was)) kept.set(key, block)\n if (wanted && clean(block.text).toLowerCase() === wanted && !worded.has(key)) worded.set(key, block)\n }\n blocks = blocks.flatMap((block) => {\n if (block.kind !== 'button' || !block.to) return [block]\n const key = aiSiteImportDestinationKey(block.to)\n if (kept.get(key) !== block) return []\n const words = worded.get(key)\n return [words && clean(block.text).toLowerCase() !== wanted ? { ...block, text: words.text } : block]\n })\n // Buttons side by side, each to its own place: the first filled.\n const out: AiLayoutBlock[] = []\n for (const block of blocks) {\n const before = out[out.length - 1]\n if (block.kind === 'button' && before?.kind === 'button' && before.col === block.col) {\n // Back over the run this button stands in.\n let start = out.length - 1\n while (start > 0 && out[start - 1]?.kind === 'button' && out[start - 1]?.col === block.col) start -= 1\n const run = out.slice(start)\n out.push(run.some(filled) && filled(block) ? { ...block, style: 'secondary' } : block)\n continue\n }\n out.push(block)\n }\n return { ...(cols ? { cols } : {}), blocks: out }\n}\n"],"names":["clean","text","replace","trim","actionKey","to","toLowerCase","strength","block","filled","style","aiSiteImportDestinationKey","value","test","slice","kind","undefined","aiSiteImportSectionActions","section","cta","cols","blocks","placed","filter","col","group","find","items","length","every","cards","map","button","flatMap","item","at","links","own","found","Set","size","into","Map","carded","has","get","includes","_col","rest","buttons","counted","key","link","entry","was","set","on","repeated","stripped","_links","after","add","seen","wanted","kept","worded","words","out","before","start","run","push","some"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;2CAM2C;;AAI3C,MAAMA,QAAQ,CAACC,OAA2B,OAAOA,SAAS,WAAWA,KAAKC,OAAO,CAAC,QAAQ,KAAKC,IAAI,KAAK;AAExG,2FAA2F,GAC3F,MAAMC,YAAY,CAACH,MAA0BI,KAAmC,GAAGL,MAAMC,MAAMK,WAAW,GAAG,MAAM,EAAED,aAAAA,KAAM,IAAI;AAE/H,+DAA+D,GAC/D,MAAME,WAAW,CAACC,QAAkCC,OAAOD,SAAS,IAAIA,MAAME,KAAK,KAAK,cAAc,IAAI;AAE1G;;;;CAIC,GACD,OAAO,SAASC,2BAA2BN,EAAU;IACnD,MAAMO,QAAQP,GAAGF,IAAI;IACrB,IAAI,SAASU,IAAI,CAACD,QAAQ,OAAO,CAAC,IAAI,EAAEA,MAAME,KAAK,CAAC,GAAGZ,OAAO,CAAC,WAAW,KAAK;IAC/E,IAAI,YAAYW,IAAI,CAACD,QAAQ,OAAOA,MAAMN,WAAW;IACrD,IAAI,gBAAgBO,IAAI,CAACD,QAAQ,OAAOA,MAAMN,WAAW,GAAGJ,OAAO,CAAC,UAAU,UAAUA,OAAO,CAAC,WAAW;IAC3G,OAAOU;AACT;AAEA,oFAAoF,GACpF,MAAMH,SAAS,CAACD,QAAkCA,MAAMO,IAAI,KAAK,YAAaP,CAAAA,MAAME,KAAK,KAAKM,aAAaR,MAAME,KAAK,KAAK,aAAaF,MAAME,KAAK,KAAK,OAAM;AAE9J;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,SAASO,2BAA2BC,OAAiD,EAAEC,GAAmB;IAC/G,IAAI,EAAEC,IAAI,EAAEC,MAAM,EAAE,GAAGH;IACvB,mDAAmD;IACnD,MAAMI,SAASD,O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SAAS3C,OAAO,OAAO,EAAE;QACtC,MAAM0D,QAAQD,OAAOpB,GAAG,CAACM;QACzB,OAAO;YAACe,SAASlE,MAAMQ,MAAMP,IAAI,EAAEK,WAAW,OAAOyD,SAAS,aAAKvD;gBAAOP,MAAMiE,MAAMjE,IAAI;iBAAKO;SAAM;IACvG;IACA,iEAAiE;IACjE,MAAM2D,MAAuB,EAAE;IAC/B,KAAK,MAAM3D,SAASa,OAAQ;QAC1B,MAAM+C,SAASD,GAAG,CAACA,IAAIvC,MAAM,GAAG,EAAE;QAClC,IAAIpB,MAAMO,IAAI,KAAK,YAAYqD,CAAAA,0BAAAA,OAAQrD,IAAI,MAAK,YAAYqD,OAAO5C,GAAG,KAAKhB,MAAMgB,GAAG,EAAE;gBAGhE2C,OAAqCA;YAFzD,2CAA2C;YAC3C,IAAIE,QAAQF,IAAIvC,MAAM,GAAG;YACzB,MAAOyC,QAAQ,KAAKF,EAAAA,QAAAA,GAAG,CAACE,QAAQ,EAAE,qBAAdF,MAAgBpD,IAAI,MAAK,YAAYoD,EAAAA,SAAAA,GAAG,CAACE,QAAQ,EAAE,qBAAdF,OAAgB3C,GAAG,MAAKhB,MAAMgB,GAAG,CAAE6C,SAAS;YACrG,MAAMC,MAAMH,IAAIrD,KAAK,CAACuD;YACtBF,IAAII,IAAI,CAACD,IAAIE,IAAI,CAAC/D,WAAWA,OAAOD,SAAS,aAAKA;gBAAOE,OAAO;iBAAgBF;YAChF;QACF;QACA2D,IAAII,IAAI,CAAC/D;IACX;IACA,OAAO,aAAMY,OAAO;QAAEA;IAAK,IAAI,CAAC;QAAIC,QAAQ8C;;AAC9C"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-site-import-actions.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*==========================================\n * A PAGE'S CALLS TO ACTION UNDER IMPROVE IT (AGL-4152).\n *\n * The mechanical tidying of a section's buttons, the same whether a\n * redesign drew the page or the page kept its source's layout: each call to\n * action once, where it belongs. No model is asked; nothing is reworded.\n *=========================================*/\n\nimport type { AiLayoutBlock, AiLayoutItem, AiLayoutSection } from '../layout-language/ai-layout-language'\n\nconst clean = (text: unknown): string => (typeof text === 'string' ? text.replace(/\\s+/g, ' ').trim() : '')\n\n/** A button's words and where it goes, as one key: two that share it are the same action. */\nconst actionKey = (text: string | undefined, to: string | undefined): string => `${clean(text).toLowerCase()}\\u0000${to ?? ''}`\n\n/** How strongly a button asks: filled 0, outlined 1, quiet 2. */\nconst strength = (block: AiLayoutBlock): number => (filled(block) ? 0 : block.style === 'secondary' ? 1 : 2)\n\n/**\n * Where a button goes, as two that go to one place share it (AGL-4152): a\n * phone by its digits, an email and a web address in any case and without a\n * trailing slash, anything else as written.\n */\nexport function aiSiteImportDestinationKey(to: string): string {\n const value = to.trim()\n if (/^tel:/i.test(value)) return `tel:${value.slice(4).replace(/[^\\d+]/g, '')}`\n if (/^mailto:/i.test(value)) return value.toLowerCase()\n if (/^https?:\\/\\//i.test(value)) return value.toLowerCase().replace(/^http:/, 'https:').replace(/[/?#]+$/, '')\n return value\n}\n\n/**\n * A call button's words without the stray mark its source left after the\n * verb (AGL-4152): a contractor's \"Call- 555-010-0142\" reads \"Call\n * 555-010-0142\". Only the mark goes; every word stays as written.\n */\nexport function aiSiteImportCallLabel(text: string): string {\n return text.replace(/^(\\s*(?:call|text|phone|tel)\\b)\\s*[-\\u2013\\u2014:|]+\\s*(?=[+(\\d])/i, '$1 ')\n}\n\n/** Whether a button is drawn filled: the compiler's default, `primary` or `large`. */\nconst filled = (block: AiLayoutBlock): boolean => block.kind === 'button' && (block.style === undefined || block.style === 'primary' || block.style === 'large')\n\n/**\n * A redesigned section's calls to action, each once and each where it belongs\n * (AGL-4152), whatever the answer and the source's kept groups gave:\n *\n * - Buttons placed in a row's columns under a group that runs the row's width,\n * with nothing else in those columns, sit in the cards they go to where each\n * goes where exactly one card does, else together under the group: a row of\n * two buttons under three cards read as a grid half filled.\n * - A link with the same words to the same place on every item of a group\n * (each review's \"See more reviews\") is shown once, as a button after the\n * group, unless the section already has that button. Where only some items\n * carry it, each is that item's own action and stays.\n * - The same button twice in a section is shown once, the first.\n * - Buttons anywhere in a section to the same place are one: the strongest,\n * filled over outlined over quiet, the first of equals, with the header's\n * words where one of them has them. A call and a page are two places. A\n * closing band's \"Contact us\" and \"Request a quote\", both to the contact\n * page with a call between them, read as a mistake.\n * - A call button's words lose a stray mark after the verb (\"Call- 555…\").\n * - Of buttons side by side, only the first is filled; the rest are outlined.\n */\nexport function aiSiteImportSectionActions(section: Pick<AiLayoutSection, 'cols' | 'blocks'>, cta?: string | null): Pick<AiLayoutSection, 'cols' | 'blocks'> {\n let { cols, blocks } = section\n // Buttons in columns under a group across the row.\n const placed = blocks.filter((block) => block.col !== undefined)\n const group = blocks.find((block) => block.col === undefined && (block.items?.length ?? 0) >= 2 && block.kind !== 'list' && block.kind !== 'faq')\n if (cols && cols.length >= 2 && group && placed.length && placed.every((block) => block.kind === 'button')) {\n const items = group.items as AiLayoutItem[]\n const cards = placed.map((button) => items.flatMap((item, at) => (button.to && item.to === button.to && !item.links?.length ? [at] : [])))\n const own = cards.every((found) => found.length === 1) && new Set(cards.map((found) => found[0])).size === cards.length\n if (own) {\n const into = new Map(placed.map((button, at) => [cards[at]?.[0] as number, button]))\n const carded = { ...group, items: items.map((item, at) => (into.has(at) ? { ...item, links: [{ text: into.get(at)?.text ?? '', to: item.to as string, style: 'secondary' as const }] } : item)) }\n blocks = blocks.flatMap((block) => (block === group ? [carded] : placed.includes(block) ? [] : [block]))\n } else blocks = blocks.map((block) => (placed.includes(block) ? (({ col: _col, ...rest }) => rest)(block) : block))\n cols = undefined\n }\n // A link repeated across a group's items, once after the group.\n const buttons = new Set(blocks.flatMap((block) => (block.kind === 'button' ? [actionKey(block.text, block.to)] : [])))\n blocks = blocks.flatMap((block) => {\n const items = block.items\n if (!items || items.length < 2) return [block]\n const counted = new Map<string, { text: string; to?: string; style?: AiLayoutBlock['style']; on: number }>()\n for (const item of items) {\n for (const key of new Set((item.links ?? []).map((link) => actionKey(link.text, link.to)))) {\n const link = item.links?.find((entry) => actionKey(entry.text, entry.to) === key)\n const was = counted.get(key)\n if (link) counted.set(key, { text: link.text, ...(link.to ? { to: link.to } : {}), ...(link.style ? { style: link.style } : {}), on: (was?.on ?? 0) + 1 })\n }\n }\n const repeated = new Map([...counted].filter(([, entry]) => entry.on === items.length))\n if (!repeated.size) return [block]\n const stripped = items.map((item) => {\n if (!item.links?.length) return item\n const links = item.links.filter((link) => !repeated.has(actionKey(link.text, link.to)))\n const { links: _links, ...rest } = item\n return links.length ? { ...rest, links } : rest\n })\n const after = [...repeated].flatMap(([key, entry]): AiLayoutBlock[] => {\n if (buttons.has(key)) return []\n buttons.add(key)\n return [{ kind: 'button', text: entry.text, ...(entry.to ? { to: entry.to } : {}), ...(entry.style ? { style: entry.style } : {}), ...(block.col !== undefined ? { col: block.col } : {}) }]\n })\n return [{ ...block, items: stripped }, ...after]\n })\n // The same button twice, once.\n const seen = new Set<string>()\n blocks = blocks.filter((block) => {\n if (block.kind !== 'button' || !block.to) return true\n const key = actionKey(block.text, block.to)\n if (seen.has(key)) return false\n seen.add(key)\n return true\n })\n // Buttons anywhere in the section to one place: one, the strongest (filled over outlined over quiet), the first of\n // equals, in its own place; with the header's words where one of them has them. A call and a page are two places.\n const wanted = clean(cta).toLowerCase()\n const kept = new Map<string, AiLayoutBlock>()\n const worded = new Map<string, AiLayoutBlock>()\n for (const block of blocks) {\n if (block.kind !== 'button' || !block.to) continue\n const key = aiSiteImportDestinationKey(block.to)\n const was = kept.get(key)\n if (!was || strength(block) < strength(was)) kept.set(key, block)\n if (wanted && clean(block.text).toLowerCase() === wanted && !worded.has(key)) worded.set(key, block)\n }\n blocks = blocks.flatMap((block) => {\n if (block.kind !== 'button' || !block.to) return [block]\n const key = aiSiteImportDestinationKey(block.to)\n if (kept.get(key) !== block) return []\n const words = worded.get(key)\n return [words && clean(block.text).toLowerCase() !== wanted ? { ...block, text: words.text } : block]\n })\n // A call button's words without a stray mark after the verb.\n blocks = blocks.map((block) => (block.kind === 'button' && /^tel:/i.test(block.to ?? '') && block.text ? { ...block, text: aiSiteImportCallLabel(block.text) } : block))\n // Buttons side by side, each to its own place: the first filled.\n const out: AiLayoutBlock[] = []\n for (const block of blocks) {\n const before = out[out.length - 1]\n if (block.kind === 'button' && before?.kind === 'button' && before.col === block.col) {\n // Back over the run this button stands in.\n let start = out.length - 1\n while (start > 0 && out[start - 1]?.kind === 'button' && out[start - 1]?.col === block.col) start -= 1\n const run = out.slice(start)\n out.push(run.some(filled) && filled(block) ? { ...block, style: 'secondary' } : block)\n continue\n }\n out.push(block)\n }\n return { ...(cols ? { cols } : {}), blocks: out }\n}\n"],"names":["clean","text","replace","trim","actionKey","to","toLowerCase","strength","block","filled","style","aiSiteImportDestinationKey","value","test","slice","aiSiteImportCallLabel","kind","undefined","aiSiteImportSectionActions","section","cta","cols","blocks","placed","filter","col","group","find","items","length","every","cards","map","button","flatMap","item","at","links","own","found","Set","size","into","Map","carded","has","get","includes","_col","rest","buttons","counted","key","link","entry","was","set","on","repeated","stripped","_links","after","add","seen","wanted","kept","worded","words","out","before","start","run","push","some"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;2CAM2C;;AAI3C,MAAMA,QAAQ,CAACC,OAA2B,OAAOA,SAAS,WAAWA,KAAKC,OAAO,CAAC,QAAQ,KAAKC,IAAI,KAAK;AAExG,2FAA2F,GAC3F,MAAMC,YAAY,CAACH,MAA0B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SAASA,OAAOU,GAAG,CAAC,CAACxB;YAAoDA;eAAzCA,MAAMQ,IAAI,KAAK,YAAY,SAASH,IAAI,EAACL,YAAAA,MAAMH,EAAE,YAARG,YAAY,OAAOA,MAAMP,IAAI,GAAG,aAAKO;YAAOP,MAAMc,sBAAsBP,MAAMP,IAAI;aAAMO;;IACjK,iEAAiE;IACjE,MAAM4D,MAAuB,EAAE;IAC/B,KAAK,MAAM5D,SAASc,OAAQ;QAC1B,MAAM+C,SAASD,GAAG,CAACA,IAAIvC,MAAM,GAAG,EAAE;QAClC,IAAIrB,MAAMQ,IAAI,KAAK,YAAYqD,CAAAA,0BAAAA,OAAQrD,IAAI,MAAK,YAAYqD,OAAO5C,GAAG,KAAKjB,MAAMiB,GAAG,EAAE;gBAGhE2C,OAAqCA;YAFzD,2CAA2C;YAC3C,IAAIE,QAAQF,IAAIvC,MAAM,GAAG;YACzB,MAAOyC,QAAQ,KAAKF,EAAAA,QAAAA,GAAG,CAACE,QAAQ,EAAE,qBAAdF,MAAgBpD,IAAI,MAAK,YAAYoD,EAAAA,SAAAA,GAAG,CAACE,QAAQ,EAAE,qBAAdF,OAAgB3C,GAAG,MAAKjB,MAAMiB,GAAG,CAAE6C,SAAS;YACrG,MAAMC,MAAMH,IAAItD,KAAK,CAACwD;YACtBF,IAAII,IAAI,CAACD,IAAIE,IAAI,CAAChE,WAAWA,OAAOD,SAAS,aAAKA;gBAAOE,OAAO;iBAAgBF;YAChF;QACF;QACA4D,IAAII,IAAI,CAAChE;IACX;IACA,OAAO,aAAMa,OAAO;QAAEA;IAAK,IAAI,CAAC;QAAIC,QAAQ8C;;AAC9C"}
|
|
@@ -1374,10 +1374,53 @@ function takeItems(scope, items) {
|
|
|
1374
1374
|
const kept = takeItems(scope, items);
|
|
1375
1375
|
items.length = kept.length;
|
|
1376
1376
|
}
|
|
1377
|
+
/**
|
|
1378
|
+
* A row's icons, every item or none (AGL-4152). A row the design gave icons
|
|
1379
|
+
* drew a card with none where its word was one the library does not have: a
|
|
1380
|
+
* contractor's redesigned services row showed icons on two cards of three.
|
|
1381
|
+
* An item whose word names nothing takes one its own words suggest, else the
|
|
1382
|
+
* row's neutral icon; a row where fewer than half the items name an icon
|
|
1383
|
+
* draws none. A row with the source's own drawings stays as it is.
|
|
1384
|
+
*/ function evenItemIcons(scope, block, items) {
|
|
1385
|
+
var _scope_words;
|
|
1386
|
+
if (items.length < 2 || items.some((item)=>item.iconPath) || aiIconOfWord(block.icon)) return items.slice();
|
|
1387
|
+
const named = items.filter((item)=>{
|
|
1388
|
+
var _item_icon;
|
|
1389
|
+
return (_item_icon = item.icon) == null ? void 0 : _item_icon.trim();
|
|
1390
|
+
}).length;
|
|
1391
|
+
const drawn = items.filter((item)=>aiIconOfWord(item.icon)).length;
|
|
1392
|
+
if (drawn === 0 || drawn === items.length) return items.slice();
|
|
1393
|
+
if (named * 2 <= items.length) {
|
|
1394
|
+
scope.page.settled.push({
|
|
1395
|
+
at: scope.at,
|
|
1396
|
+
what: `${items.length} items drawn with no icon, ${drawn} of them named one`
|
|
1397
|
+
});
|
|
1398
|
+
return items.map((_0)=>{
|
|
1399
|
+
let { icon: _icon } = _0, item = _object_without_properties_loose(_0, [
|
|
1400
|
+
"icon"
|
|
1401
|
+
]);
|
|
1402
|
+
return item;
|
|
1403
|
+
});
|
|
1404
|
+
}
|
|
1405
|
+
const words = aiStorefrontItemIcons(items, (word)=>!!aiIconOfWord(word), _extends({
|
|
1406
|
+
section: (_scope_words = scope.words) != null ? _scope_words : ''
|
|
1407
|
+
}, scope.page.design ? {
|
|
1408
|
+
kind: scope.page.design.input.kind
|
|
1409
|
+
} : {}));
|
|
1410
|
+
scope.page.settled.push({
|
|
1411
|
+
at: scope.at,
|
|
1412
|
+
what: `${items.length - drawn} of ${items.length} items given an icon their words suggest`
|
|
1413
|
+
});
|
|
1414
|
+
return items.map((item, at)=>aiIconOfWord(item.icon) ? item : _extends({}, item, {
|
|
1415
|
+
icon: words[at]
|
|
1416
|
+
}));
|
|
1417
|
+
}
|
|
1377
1418
|
function group(scope, block, room) {
|
|
1378
|
-
var _block_items;
|
|
1379
|
-
if (scope.page.options.verbatim) return importedGroup(scope, block,
|
|
1380
|
-
|
|
1419
|
+
var _block_items, _block_items1;
|
|
1420
|
+
if (scope.page.options.verbatim) return importedGroup(scope, _extends({}, block, {
|
|
1421
|
+
items: evenItemIcons(scope, block, (_block_items = block.items) != null ? _block_items : [])
|
|
1422
|
+
}), room);
|
|
1423
|
+
const items = takeItems(scope, evenItemIcons(scope, block, cleanItems(scope, (_block_items1 = block.items) != null ? _block_items1 : [])));
|
|
1381
1424
|
if (!items.length) return null;
|
|
1382
1425
|
const perRow = across(items.length, room, block.kind);
|
|
1383
1426
|
const placed = componentOf(scope.page.targets, block.to);
|