create-ailk 0.46.3 → 0.46.5

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.
@@ -18,7 +18,8 @@
18
18
  * `parseLookupKey` accepts — plus, for a bundled plan, `?with=` and the
19
19
  * required product's key (#10028 D9); no href is built from any other
20
20
  * field (D5) — except a contact's Stripe URL (#12193 D2, the contract's
21
- * one stated exception), by `contactLink`'s rule.
21
+ * one stated exception) and a plan's footnote link (#12243, the same
22
+ * exception extended), both by `contactLink`'s rule.
22
23
  * - §3.7 — `yearly` reads as annual and `once` as one-time at render, never
23
24
  * in the key (D2).
24
25
  *
@@ -39,6 +40,15 @@
39
40
  * point) is one level card whose levels are its points: each level's amount,
40
41
  * label and checkout link come from its Price, everything else from the
41
42
  * product (`offeringPointProducts`). A product is named by any of its slugs.
43
+ *
44
+ * #12243 — a plan's `footnote` and its link ride its card, and a level card
45
+ * takes its first level's (a card field, never a level's). `siteOrigin` makes a
46
+ * same-origin link an internal path; without it every link is external.
47
+ *
48
+ * #12246 — `offeringsPlanColumns` resolves a comparison table's plan columns
49
+ * from the same shown set: each slug's name, price, checkout link and
50
+ * Recommended flag, from the card `planCard` / `bundleCard` builds for it.
51
+ * #12280 — a column's price carries the product's unit, as its card does.
42
52
  */
43
53
  import {
44
54
  PRICING_SEGMENT_LEVELS_MAX,
@@ -48,7 +58,9 @@ import {
48
58
  offeringPointProducts,
49
59
  offeringPricePoints,
50
60
  parseLookupKey,
61
+ planColumnSlugs,
51
62
  lookupKeyPeriodSchema,
63
+ type PlanColumnOffering,
52
64
  workspaceShownSetSchema,
53
65
  type LookupKeyPeriod,
54
66
  type OfferPrice,
@@ -56,6 +68,7 @@ import {
56
68
  type OfferingsPrice,
57
69
  type OfferingsProduct,
58
70
  type PageSection,
71
+ type PriceParts,
59
72
  } from "@working-theory/validation";
60
73
 
61
74
  /** The period words, read by name from their one home (#8876 AC-9). */
@@ -66,23 +79,33 @@ type PricingSectionData = Extract<PageSection, { type: "pricing" }>["data"];
66
79
  // #12193 D9 — `offerPrices` (`OfferPrice`, the contribution's shape) is a
67
80
  // render-time field, never in the stored section schema, so no author or agent
68
81
  // can declare one.
82
+ // #12242 D1 — `priceParts` (`PriceParts`) is render-time too: a side's amount
83
+ // and unit as two elements, beside the unchanged `price` phrases.
69
84
  type PricingPlanLevel = NonNullable<PricingSectionData["plans"][number]["levels"]>[number] & {
70
85
  offerPrices?: OfferPrice[];
86
+ priceParts?: PriceParts;
71
87
  };
72
- /** The schema's plan card plus the render-time `offerPrices`, on it and its levels. */
88
+ /**
89
+ * The schema's plan card plus the render-time `offerPrices` and `priceParts`,
90
+ * on it and its levels, and the render-time `images` (#12241 D8): the
91
+ * product's Stripe images, the wide layout's side slot when the page types none.
92
+ */
73
93
  type PricingPlanCard = Omit<PricingSectionData["plans"][number], "levels"> & {
74
94
  levels?: PricingPlanLevel[];
75
95
  offerPrices?: OfferPrice[];
96
+ priceParts?: PriceParts;
97
+ images?: Array<{ src: string; alt: string }>;
76
98
  };
99
+ /** A bound section's yearly-line and strike choices (#12242 D4, D5). */
100
+ interface CardOptions {
101
+ annualLine?: "billed" | "savings" | "none" | undefined;
102
+ strikeMonthly?: boolean | undefined;
103
+ }
77
104
  /** A bound section's level card, as the page writes it (#12174 D6). */
78
105
  export type OfferingsLevelGroup = NonNullable<PricingSectionData["offeringGroups"]>[number];
79
- /** `AddonCard` ignores `key`; it is carried so a tile names its `{plan}` too. */
80
- type PricingAddonTile = NonNullable<PricingSectionData["addons"]>[number] & {
81
- key: string;
82
- };
83
106
 
84
107
  export interface OfferingsPricingLabels {
85
- /** The CTA label on every card and tile whose product sets none of its own. */
108
+ /** The CTA label on every card whose product sets none of its own. */
86
109
  cta: string;
87
110
  /** The recommended plan's pill and the recommended add-on's eyebrow. */
88
111
  recommended: string;
@@ -98,6 +121,15 @@ export interface OfferingsPricingLabels {
98
121
  billedYearly(amount: string): string;
99
122
  /** A contact card's price when it has no display price (#12193 D5 rule 7). */
100
123
  custom: string;
124
+ /** The period words inside a card's unit (#12242 D2): "/mo", "/yr". */
125
+ perMonth: string;
126
+ perYear: string;
127
+ /** The one site pattern joining a period word and a unit label (#12242 AC-9). */
128
+ unitWithLabel(period: string, label: string): string;
129
+ /** The yearly line as a savings percentage (#12242 D4). */
130
+ savings(percent: string): string;
131
+ /** The screen-reader sentence beside a struck monthly price (#12242 D5). */
132
+ regularPrice(regular: string, current: string): string;
101
133
  }
102
134
 
103
135
  export interface OfferingsPricing {
@@ -315,6 +347,7 @@ function bundleCard(
315
347
  highlighted: boolean,
316
348
  locale: string,
317
349
  labels: OfferingsPricingLabels,
350
+ siteOrigin: string | undefined,
318
351
  ): PricingPlanCard | null {
319
352
  const once = priceFor(product, PERIOD.once);
320
353
  const monthly = priceFor(required, PERIOD.monthly);
@@ -353,6 +386,7 @@ function bundleCard(
353
386
  const annualHref =
354
387
  monthly && yearly && offeringsBundleHref(once.lookupKey, yearly.lookupKey);
355
388
  if (annualHref) card.annualCtaHref = annualHref;
389
+ Object.assign(card, footnoteOf(product, siteOrigin));
356
390
  if (highlighted) {
357
391
  card.highlighted = true;
358
392
  card.highlightStyle = "pill";
@@ -361,11 +395,38 @@ function bundleCard(
361
395
  return card;
362
396
  }
363
397
 
398
+ /**
399
+ * One product's own card: its bundle card when it `requires` a product of
400
+ * `offerings` (none when that product is missing or has several price points,
401
+ * its recurring Price being ambiguous — #12210 D6 rule 8), else `planCard`.
402
+ * The plans fragment and a comparison table's plan columns (#12246 D3) both
403
+ * build a card here.
404
+ */
405
+ function ownCard(
406
+ product: OfferingsProduct,
407
+ offerings: readonly OfferingsProduct[],
408
+ highlighted: boolean,
409
+ locale: string,
410
+ labels: OfferingsPricingLabels,
411
+ siteOrigin: string | undefined,
412
+ cardOptions: CardOptions = {},
413
+ ): PricingPlanCard | null {
414
+ if (product.requires === undefined)
415
+ return planCard(product, highlighted, locale, labels, siteOrigin, cardOptions);
416
+ const named = new Set([product.requires]);
417
+ const required = offerings.find((o) => namedIn(o, named));
418
+ return required && offeringPointProducts(required).length === 1
419
+ ? bundleCard(product, required, highlighted, locale, labels, siteOrigin)
420
+ : null;
421
+ }
422
+
364
423
  function planCard(
365
424
  product: OfferingsProduct,
366
425
  highlighted: boolean,
367
426
  locale: string,
368
427
  labels: OfferingsPricingLabels,
428
+ siteOrigin: string | undefined,
429
+ options: CardOptions = {},
369
430
  ): PricingPlanCard | null {
370
431
  const shown = shownPrice(product);
371
432
  const href = shown ? offeringsCheckoutHref(shown.lookupKey) : null;
@@ -379,17 +440,34 @@ function planCard(
379
440
  // Beside a monthly Price, annual mode shows the yearly Price per month, so
380
441
  // the two modes compare in one unit (#12139 D1), in whole currency units
381
442
  // (#12193 D8); its exact total goes in a note.
443
+ // #12242 D1 — the same amounts as two elements: the amount, and the period
444
+ // word joined to the Stripe unit label by the site's one pattern.
445
+ const noun = product.unitLabel ? stripFormatCharacters(product.unitLabel) : "";
446
+ const unitOf = (period: string) => (noun ? labels.unitWithLabel(period, noun) : period);
447
+ const priceParts: PriceParts = {};
448
+ const monthlyAmount = monthly && formatMinorUnits(monthly.amount, monthly.currency, locale);
449
+ if (monthlyAmount) priceParts.monthly = { amount: monthlyAmount, unit: unitOf(labels.perMonth) };
382
450
  if (yearly) {
383
451
  const unit = 10 ** currencyExponent(yearly.currency);
452
+ const perMonth = Math.round(yearly.amount / 12 / unit) * unit;
453
+ const perMonthAmount = formatMinorUnits(perMonth, yearly.currency, locale);
384
454
  price.annual = monthly
385
- ? labels.monthly(
386
- formatMinorUnits(
387
- Math.round(yearly.amount / 12 / unit) * unit,
388
- yearly.currency,
389
- locale,
390
- ),
391
- )
455
+ ? labels.monthly(perMonthAmount)
392
456
  : phrase(yearly, locale, labels);
457
+ priceParts.annual = monthly
458
+ ? { amount: perMonthAmount, unit: unitOf(labels.perMonth) }
459
+ : { amount: formatMinorUnits(yearly.amount, yearly.currency, locale), unit: unitOf(labels.perYear) };
460
+ // #12242 D5 — the standard monthly price struck beside a lower per-month one.
461
+ if (
462
+ options.strikeMonthly === true &&
463
+ monthly &&
464
+ monthlyAmount &&
465
+ monthly.currency === yearly.currency &&
466
+ perMonth < monthly.amount
467
+ ) {
468
+ priceParts.annual.was = monthlyAmount;
469
+ priceParts.annual.wasLabel = labels.regularPrice(monthlyAmount, perMonthAmount);
470
+ }
393
471
  }
394
472
  if (once && !monthly && !yearly) price.custom = phrase(once, locale, labels);
395
473
 
@@ -401,16 +479,26 @@ function planCard(
401
479
  cta: { label: ctaLabel(product, labels), href },
402
480
  offerPrices: offerPricesOf([monthly, yearly, once]),
403
481
  };
482
+ if (priceParts.monthly || priceParts.annual) card.priceParts = priceParts;
404
483
  const description =
405
484
  product.description && stripFormatCharacters(product.description, true);
406
485
  if (description) card.description = description;
407
486
  if (product.unitLabel)
408
487
  card.priceUnit = stripFormatCharacters(product.unitLabel);
409
488
  if (product.note) card.priceSubhead = stripFormatCharacters(product.note);
410
- if (monthly && yearly)
411
- card.annualPriceNote = labels.billedYearly(
412
- formatMinorUnits(yearly.amount, yearly.currency, locale),
413
- );
489
+ // #12242 D4 — the yearly line: billed (the default), a savings percentage
490
+ // worked out from the two Stripe prices, or none.
491
+ if (monthly && yearly) {
492
+ if (options.annualLine === "savings") {
493
+ const percent = Math.round((1 - yearly.amount / (12 * monthly.amount)) * 100);
494
+ if (monthly.currency === yearly.currency && percent >= 1)
495
+ card.annualPriceNote = labels.savings(String(percent));
496
+ } else if (options.annualLine !== "none") {
497
+ card.annualPriceNote = labels.billedYearly(
498
+ formatMinorUnits(yearly.amount, yearly.currency, locale),
499
+ );
500
+ }
501
+ }
414
502
  // A deposit plan's footnote (#10030 D10), in its one-time Price's currency;
415
503
  // it takes the footnote over a terms note (the rarer field).
416
504
  if (product.deposit !== undefined && once)
@@ -425,6 +513,10 @@ function planCard(
425
513
  const annualHref =
426
514
  monthly && yearly && offeringsCheckoutHref(yearly.lookupKey);
427
515
  if (annualHref) card.annualCtaHref = annualHref;
516
+ Object.assign(card, footnoteOf(product, siteOrigin));
517
+ // #12241 D8 — the product's Stripe images (the normalizer keeps them only
518
+ // under `ailk_images: on`), each described by the card's title.
519
+ if (product.images) card.images = product.images.map((src) => ({ src, alt: card.name }));
428
520
  if (highlighted) {
429
521
  card.highlighted = true;
430
522
  card.highlightStyle = "pill";
@@ -461,6 +553,7 @@ function splitBlocks(
461
553
  priceFootnote: _priceFootnote,
462
554
  priceFootnoteAnnualOnly: _priceFootnoteAnnualOnly,
463
555
  offerPrices: _offerPrices,
556
+ priceParts: _priceParts,
464
557
  ...shared
465
558
  } = card;
466
559
  // Each block publishes only the Price it sells (#12193 D9).
@@ -488,6 +581,15 @@ function splitBlocks(
488
581
  ];
489
582
  }
490
583
 
584
+ /** Whether `cards` need the billing toggle: a card or level priced both monthly and annually (#12174 D6). */
585
+ function needsToggle(cards: PricingPlanCard[]): boolean {
586
+ return cards.some((card) =>
587
+ [card, ...(card.levels ?? [])].some(
588
+ (shown) => shown.price.monthly !== undefined && shown.price.annual !== undefined,
589
+ ),
590
+ );
591
+ }
592
+
491
593
  /**
492
594
  * The plans fragment in `layout` (#12140 D3): the cards as built, framed for
493
595
  * the layout that renders them. Absent, today's toggle fragment. `product` is
@@ -507,23 +609,17 @@ function plansFragment(
507
609
  variant: "three-tiers-with-toggle",
508
610
  cardLayout: "centered",
509
611
  // #12174 D6 — a level priced both ways turns it on too.
510
- billingToggle: cards.some((card) =>
511
- [card, ...(card.levels ?? [])].some(
512
- (shown) =>
513
- shown.price.monthly !== undefined &&
514
- shown.price.annual !== undefined,
515
- ),
516
- ),
612
+ billingToggle: needsToggle(cards),
517
613
  plans: cards,
518
614
  };
519
615
  // These variants show monthly prices only, so they take no toggle.
520
- case "with-comparison-table":
521
616
  case "two-tiers-with-extra-tier":
522
617
  case "band-hero":
523
618
  return { variant: layout, cardLayout: "centered", plans: cards };
524
- // The variant renders one plan and has no card layout.
619
+ // The variant renders one plan and has no card layout; since #12241 D5
620
+ // its card follows the toggle, as the toggle layout's do.
525
621
  case "single-price-with-details":
526
- return { variant: layout, plans: cards.slice(0, 1) };
622
+ return { variant: layout, billingToggle: needsToggle(cards.slice(0, 1)), plans: cards.slice(0, 1) };
527
623
  case "features-and-plans": {
528
624
  // A level card (#12174 D6) is never split: `product` is undefined then.
529
625
  const split =
@@ -552,6 +648,7 @@ function levelOf(card: PricingPlanCard): Omit<PricingPlanLevel, "label" | "key">
552
648
  };
553
649
  if (card.description !== undefined) level.description = card.description;
554
650
  if (card.offerPrices !== undefined) level.offerPrices = card.offerPrices;
651
+ if (card.priceParts !== undefined) level.priceParts = card.priceParts;
555
652
  if (card.priceUnit !== undefined) level.priceUnit = card.priceUnit;
556
653
  if (card.priceSubhead !== undefined) level.priceSubhead = card.priceSubhead;
557
654
  if (card.annualPriceNote !== undefined)
@@ -585,6 +682,8 @@ function levelCards(
585
682
  planProducts: OfferingsProduct[],
586
683
  locale: string,
587
684
  labels: OfferingsPricingLabels,
685
+ siteOrigin: string | undefined,
686
+ cardOptions: CardOptions,
588
687
  ): PricingPlanCard[] {
589
688
  // #12210 D6 rule 5 — a level names one slug, so one price point.
590
689
  const byPlan = new Map(
@@ -600,18 +699,27 @@ function levelCards(
600
699
  // is highlighted (#12210 D12).
601
700
  const recommendedId = grouped.find((p) => p.recommended)?.productId;
602
701
  return groups.flatMap((group) => {
603
- const levels: PricingPlanLevel[] = group.levels.flatMap((level) => {
702
+ const built = group.levels.flatMap((level) => {
604
703
  const product = byPlan.get(level.plan);
605
- const card = product && planCard(product, false, locale, labels);
704
+ const card = product && planCard(product, false, locale, labels, siteOrigin, cardOptions);
606
705
  if (!card) return [];
607
706
  const { description: _description, ...fields } = levelOf(card);
608
- return [{ label: level.label, key: product.plan, ...fields, ...helperOf(product) }];
707
+ return [{ card, level: { label: level.label, key: product.plan, ...fields, ...helperOf(product) } }];
609
708
  });
709
+ const levels: PricingPlanLevel[] = built.map((entry) => entry.level);
610
710
  const first = levels[0];
611
711
  if (!first) return [];
612
712
  // #12209 D5 — `helper` is level-only, so the card's own fields leave it out.
613
713
  const { label: _label, key: _key, helper: _helper, ...shown } = first;
614
- const card: PricingPlanCard = { key: group.key, name: group.name, ...shown, levels };
714
+ // #12243 — the footnote is a card field: the first level's product's.
715
+ const card: PricingPlanCard = {
716
+ key: group.key,
717
+ name: group.name,
718
+ ...shown,
719
+ ...cardFootnote(built[0]?.card),
720
+ ...cardImages(built[0]?.card, group.name),
721
+ levels,
722
+ };
615
723
  if (group.description !== undefined) card.description = group.description;
616
724
  // #12209 D2 — the group's control rides its card to the section.
617
725
  if (group.levelSwitchControl !== undefined) card.levelSwitchControl = group.levelSwitchControl;
@@ -624,36 +732,27 @@ function levelCards(
624
732
  });
625
733
  }
626
734
 
627
- function addonTile(
735
+ /**
736
+ * An add-on's card (#12241 D3): its plan card — description, both prices,
737
+ * unit, note and checkout links — plus its eyebrow, the seller's
738
+ * `ailk_eyebrow`, which on the recommended add-on is the Recommended label.
739
+ * Never highlighted, so the pill, the filled button and `?plan=` stay
740
+ * plans-only.
741
+ */
742
+ function addonCard(
628
743
  product: OfferingsProduct,
629
- highlighted: boolean,
744
+ recommended: boolean,
630
745
  locale: string,
631
746
  labels: OfferingsPricingLabels,
632
- ): PricingAddonTile | null {
633
- const shown = shownPrice(product);
634
- const href = shown && offeringsCheckoutHref(shown.lookupKey);
635
- if (!shown || !href) return null;
636
-
637
- const tile: PricingAddonTile = {
638
- key: product.plan,
639
- name: titleOf(product),
640
- price: phrase(shown, locale, labels),
641
- features: features(product),
642
- cta: { label: ctaLabel(product, labels), href },
643
- };
644
- if (product.unitLabel)
645
- tile.qualifier = stripFormatCharacters(product.unitLabel);
646
- // #12103 D5 — the seller's eyebrow and note; the recommended add-on's
647
- // eyebrow stays the Recommended label, the one place a tile shows it.
648
- const eyebrow = product.eyebrow && stripFormatCharacters(product.eyebrow);
649
- if (eyebrow) tile.eyebrow = eyebrow;
650
- const note = product.note && stripFormatCharacters(product.note);
651
- if (note) tile.note = note;
652
- if (highlighted) {
653
- tile.eyebrow = labels.recommended;
654
- tile.checkTone = "primary";
655
- }
656
- return tile;
747
+ siteOrigin: string | undefined,
748
+ ): PricingPlanCard | null {
749
+ const card = planCard(product, false, locale, labels, siteOrigin);
750
+ if (!card) return null;
751
+ const eyebrow = recommended
752
+ ? labels.recommended
753
+ : product.eyebrow && stripFormatCharacters(product.eyebrow);
754
+ if (eyebrow) card.eyebrow = eyebrow;
755
+ return card;
657
756
  }
658
757
 
659
758
  /**
@@ -684,6 +783,38 @@ function contactLink(
684
783
  return { href: url.href, external: true };
685
784
  }
686
785
 
786
+ /**
787
+ * A plan's card footnote (#12243), its format characters stripped, and its
788
+ * link through `contactLink` — the contact URL's rule, so a same-origin URL is
789
+ * an internal path, another origin's the full URL; a link `contactLink` gives
790
+ * none for is dropped and the footnote kept as text alone.
791
+ */
792
+ function footnoteOf(
793
+ product: Pick<OfferingsProduct, "footnote" | "footnoteLink">,
794
+ siteOrigin: string | undefined,
795
+ ): Pick<PricingPlanCard, "footnote" | "footnoteLink"> {
796
+ if (product.footnote === undefined) return {};
797
+ const footnote = stripFormatCharacters(product.footnote);
798
+ const { footnoteLink } = product;
799
+ const link = footnoteLink && contactLink(footnoteLink.url, siteOrigin);
800
+ return footnoteLink && link
801
+ ? { footnote, footnoteLink: { label: stripFormatCharacters(footnoteLink.label), href: link.href } }
802
+ : { footnote };
803
+ }
804
+
805
+ /** `card`'s footnote and its link, for the level card it leads (#12243 — a card field, never a level's). */
806
+ function cardFootnote(card: PricingPlanCard | undefined): Pick<PricingPlanCard, "footnote" | "footnoteLink"> {
807
+ return {
808
+ ...(card?.footnote !== undefined && { footnote: card.footnote }),
809
+ ...(card?.footnoteLink !== undefined && { footnoteLink: card.footnoteLink }),
810
+ };
811
+ }
812
+
813
+ /** `card`'s Stripe images for the level card it leads, described by that card's `title` (#12241 D8 — a card field, never a level's). */
814
+ function cardImages(card: PricingPlanCard | undefined, title: string): Pick<PricingPlanCard, "images"> {
815
+ return card?.images ? { images: card.images.map(({ src }) => ({ src, alt: title })) } : {};
816
+ }
817
+
687
818
  /** A plan contact's card (#12193 D5 rule 7): no Price, so no `Offer` and never highlighted. */
688
819
  function contactCard(
689
820
  contact: OfferingsContactProduct,
@@ -702,24 +833,7 @@ function contactCard(
702
833
  };
703
834
  const description = contact.description && stripFormatCharacters(contact.description, true);
704
835
  if (description) card.description = description;
705
- return card;
706
- }
707
-
708
- /** An add-on contact's tile (#12193 AC-7): its display price, label and link. */
709
- function contactTile(
710
- contact: OfferingsContactProduct,
711
- siteOrigin: string | undefined,
712
- labels: OfferingsPricingLabels,
713
- ): PricingAddonTile | null {
714
- const link = contactLink(contact.url, siteOrigin);
715
- if (!link) return null;
716
- return {
717
- key: contact.plan,
718
- name: titleOf(contact),
719
- price: contact.priceText ? stripFormatCharacters(contact.priceText) : labels.custom,
720
- features: features(contact),
721
- cta: { label: ctaLabel(contact, labels), ...link },
722
- };
836
+ return Object.assign(card, footnoteOf(contact, siteOrigin));
723
837
  }
724
838
 
725
839
  /** `ailkOrder`, null last. */
@@ -764,9 +878,13 @@ function tierCard(
764
878
  locale: string,
765
879
  labels: OfferingsPricingLabels,
766
880
  levelLimit: number,
881
+ siteOrigin: string | undefined,
882
+ cardOptions: CardOptions,
767
883
  ): PricingPlanCard | null {
768
884
  const title = stripFormatCharacters(name);
769
885
  const levels: PricingPlanLevel[] = [];
886
+ // #12243 — the footnote is a card field: the first level's product's.
887
+ let firstCard: PricingPlanCard | undefined;
770
888
  // A member with price points sends the card to the select, so the tier keeps
771
889
  // up to the select's 20 levels rather than cutting its members at four.
772
890
  const memberLimit = members.some((m) => offeringPointProducts(m).length > 1) ? PRICING_SELECT_LEVELS_MAX : levelLimit;
@@ -777,7 +895,7 @@ function tierCard(
777
895
  .slice(0, PRICING_SELECT_LEVELS_MAX);
778
896
  const hasPoints = entries.some(({ product, point }) => point !== product);
779
897
  for (const { product, point } of entries) {
780
- const card = planCard(point, false, locale, labels);
898
+ const card = planCard(point, false, locale, labels, siteOrigin, cardOptions);
781
899
  const shown = shownPrice(point);
782
900
  if (!card || !shown) continue;
783
901
  const taken = new Set(levels.map((level) => level.label));
@@ -793,17 +911,31 @@ function tierCard(
793
911
  (text): text is string => text !== undefined && text.length > 0 && !taken.has(text),
794
912
  );
795
913
  if (label === undefined) continue;
796
- const detail =
797
- isPoint && label !== pricePhrase && [...pricePhrase].length <= LEVEL_DETAIL_MAX
914
+ // #12241 D6 — a level's detail is its Price's `ailk_detail`: a point's
915
+ // own Price's, a tier level's first of monthly, yearly, once to carry
916
+ // one. Without one a point keeps its price phrase, as before.
917
+ const priceDetail = isPoint
918
+ ? shown.detail
919
+ : [PERIOD.monthly, PERIOD.yearly, PERIOD.once].map((period) => priceFor(point, period)?.detail).find(Boolean);
920
+ const detail = priceDetail
921
+ ? { detail: priceDetail }
922
+ : isPoint && label !== pricePhrase && [...pricePhrase].length <= LEVEL_DETAIL_MAX
798
923
  ? { detail: pricePhrase }
799
924
  : {};
800
925
  levels.push({ label, key: point.plan, ...levelOf(card), ...helperOf(product), ...detail });
926
+ firstCard ??= card;
801
927
  }
802
928
  const first = levels[0];
803
929
  if (!first) return null;
804
930
  // #12209 D3, D5 — `helper` and `detail` are level-only, so the card's own fields leave them out.
805
931
  const { label: _label, helper: _helper, detail: _detail, ...shown } = first;
806
- const card: PricingPlanCard = { ...shown, name: title, ...(levels.length > 1 ? { levels } : {}) };
932
+ const card: PricingPlanCard = {
933
+ ...shown,
934
+ name: title,
935
+ ...cardFootnote(firstCard),
936
+ ...cardImages(firstCard, title),
937
+ ...(levels.length > 1 ? { levels } : {}),
938
+ };
807
939
  // #12210 D6 rule 6 — segments keep four levels (#12209 AC 8).
808
940
  if (hasPoints && levels.length > PRICING_SEGMENT_LEVELS_MAX) card.levelSwitchControl = "select";
809
941
  if (highlighted) {
@@ -912,13 +1044,19 @@ function narrowToPlans(
912
1044
  * `tiers` (#12193 D5, a selecting bound section) groups plain plans sharing a
913
1045
  * Stripe `tier` into one card each (`tierCard`). `collection` maps every shown
914
1046
  * product of that collection in place of `plans`, with its contacts as
915
- * contact cards and tiles, linked by `contactLink` against `siteOrigin`.
1047
+ * contact cards and tiles, linked by `contactLink` against `siteOrigin`, as
1048
+ * every footnote link is (#12243).
916
1049
  * Cards and tiles are ordered by `ailkOrder`. Absent, the cards are built
917
1050
  * exactly as before, and no contact is shown.
918
1051
  *
919
1052
  * With `tiers`, `levelLimit` (#12209 D8) caps a tier card's levels — four
920
1053
  * (the default, segments) or twenty (a select) — and `groupTiers: false`
921
1054
  * (#12209 D11) makes every plan its own card, whatever its tier.
1055
+ *
1056
+ * `contactPlans` (#12238, operator 2026-11-23) is a section's own
1057
+ * `offeringPlans`: a shown contact it names by slug becomes a contact card or
1058
+ * tile, as a collection's does. Read only without `collection`; the page's
1059
+ * `plans` never shows a contact.
922
1060
  */
923
1061
  export function offeringsPricing(
924
1062
  shownSet: unknown,
@@ -934,16 +1072,20 @@ export function offeringsPricing(
934
1072
  levelLimit?: number | undefined;
935
1073
  groupTiers?: boolean | undefined;
936
1074
  siteOrigin?: string | undefined;
1075
+ contactPlans?: readonly string[] | undefined;
1076
+ annualLine?: CardOptions["annualLine"];
1077
+ strikeMonthly?: boolean | undefined;
937
1078
  },
938
1079
  ): OfferingsPricing | null {
939
1080
  const parsed = shownSetSchema.safeParse(shownSet);
940
1081
  if (!parsed.success) return null;
941
1082
  const { state, offerings: shown } = parsed.data;
942
1083
  const { collection, siteOrigin, locale, labels } = options;
943
- const contacts =
944
- collection === undefined
945
- ? []
946
- : (parsed.data.contacts ?? []).filter((c) => inCollection(c.collection, collection));
1084
+ const cardOptions: CardOptions = { annualLine: options.annualLine, strikeMonthly: options.strikeMonthly };
1085
+ const named = new Set(options.contactPlans);
1086
+ const contacts = (parsed.data.contacts ?? []).filter((c) =>
1087
+ collection === undefined ? named.has(c.plan) : inCollection(c.collection, collection),
1088
+ );
947
1089
  if (state !== "current" || (shown.length === 0 && contacts.length === 0)) return null;
948
1090
 
949
1091
  // #10028 D9 — a product some shown plan requires is sold only inside that
@@ -990,25 +1132,20 @@ export function offeringsPricing(
990
1132
  locale,
991
1133
  labels,
992
1134
  options.levelLimit ?? PRICING_SEGMENT_LEVELS_MAX,
1135
+ siteOrigin,
1136
+ cardOptions,
993
1137
  ),
994
1138
  order: p.ailkOrder,
995
1139
  contact: false,
996
1140
  });
997
1141
  continue;
998
1142
  }
999
- const named = p.requires === undefined ? undefined : new Set([p.requires]);
1000
- const required = named && offerings.find((o) => namedIn(o, named));
1001
1143
  // #12210 D6 rules 3, 8 — a multi-point product is one level card of its
1002
- // points; a bundle whose required product has points gives no card, its
1003
- // recurring Price being ambiguous.
1144
+ // points; anything else is its own card (`ownCard`).
1004
1145
  const item =
1005
- p.requires !== undefined
1006
- ? required && offeringPointProducts(required).length === 1
1007
- ? bundleCard(p, required, p.plan === recommendedPlan, locale, labels)
1008
- : null
1009
- : offeringPointProducts(p).length > 1
1010
- ? tierCard(titleOf(p), [p], p.plan === recommendedPlan, locale, labels, 1)
1011
- : planCard(p, p.plan === recommendedPlan, locale, labels);
1146
+ p.requires === undefined && offeringPointProducts(p).length > 1
1147
+ ? tierCard(titleOf(p), [p], p.plan === recommendedPlan, locale, labels, 1, siteOrigin, cardOptions)
1148
+ : ownCard(p, offerings, p.plan === recommendedPlan, locale, labels, siteOrigin, cardOptions);
1012
1149
  placedPlans.push({ item, order: p.ailkOrder, contact: false });
1013
1150
  }
1014
1151
  for (const c of contacts.filter((c) => c.ailkGroup === "plan")) {
@@ -1018,17 +1155,18 @@ export function offeringsPricing(
1018
1155
  const ordered = <T>(placed: Placed<T>[]) =>
1019
1156
  options.tiers ? inOrder(placed) : placed.map((entry) => entry.item);
1020
1157
  const plans = options.levelGroups
1021
- ? levelCards(options.levelGroups, planProducts, locale, labels)
1158
+ ? levelCards(options.levelGroups, planProducts, locale, labels, siteOrigin, cardOptions)
1022
1159
  : ordered(placedPlans).filter(isPresent);
1023
- const addons = ordered<PricingAddonTile | null>([
1160
+ // #12241 D3 — add-ons are cards, an add-on contact a contact card.
1161
+ const addons = ordered<PricingPlanCard | null>([
1024
1162
  ...addonProducts.map((p) => ({
1025
- item: addonTile(p, p.plan === recommendedAddon, locale, labels),
1163
+ item: addonCard(p, p.plan === recommendedAddon, locale, labels, siteOrigin),
1026
1164
  order: p.ailkOrder,
1027
1165
  contact: false,
1028
1166
  })),
1029
1167
  ...contacts
1030
1168
  .filter((c) => c.ailkGroup === "addon")
1031
- .map((c) => ({ item: contactTile(c, siteOrigin, labels), order: c.ailkOrder, contact: true })),
1169
+ .map((c) => ({ item: contactCard(c, siteOrigin, labels), order: c.ailkOrder, contact: true })),
1032
1170
  ]).filter(isPresent);
1033
1171
 
1034
1172
  // Each card is keyed by its product's `{plan}`, so a lone card names its product.
@@ -1043,6 +1181,66 @@ export function offeringsPricing(
1043
1181
  plans.length > 0
1044
1182
  ? plansFragment(plans, options.layout, product, locale, labels)
1045
1183
  : null,
1046
- addons: addons.length > 0 ? { variant: "addons", plans: [], addons } : null,
1184
+ addons:
1185
+ addons.length > 0
1186
+ ? { variant: "addons", billingToggle: needsToggle(addons), plans: addons }
1187
+ : null,
1047
1188
  };
1048
1189
  }
1190
+
1191
+ /** A side's amount and unit as the card draws them, joined by its space (#12280 D2); else `phrase`. */
1192
+ function joinedPrice(part: PriceParts["monthly"], phrase: string | undefined): string | undefined {
1193
+ return part ? `${part.amount} ${part.unit}` : phrase;
1194
+ }
1195
+
1196
+ /**
1197
+ * Each of `slugs` the shown set shows as a plan column (#12246 D3), by slug:
1198
+ * a slug `planColumnSlugs` holds, as the card its point product would get —
1199
+ * `bundleCard` for a product that `requires` one (no column when that bundle
1200
+ * gives no card), else `planCard` (`ownCard`). One column per slug, so a
1201
+ * price point shows its own price. Every string is a card's, so it reaches
1202
+ * markup as React text only (T2), and every link is a card's own checkout
1203
+ * link (T3). Empty for a set that does not parse or is not `current`; never
1204
+ * reads the page's `plans`.
1205
+ */
1206
+ export function offeringsPlanColumns(
1207
+ shownSet: unknown,
1208
+ slugs: Iterable<string>,
1209
+ options: { locale: string; labels: OfferingsPricingLabels },
1210
+ ): Map<string, PlanColumnOffering> {
1211
+ const columns = new Map<string, PlanColumnOffering>();
1212
+ const parsed = shownSetSchema.safeParse(shownSet);
1213
+ if (!parsed.success || parsed.data.state !== "current") return columns;
1214
+ const shown = parsed.data.offerings;
1215
+ const shownSlugs = planColumnSlugs(shown);
1216
+ const products = shown.filter((o) => o.ailkGroup === "plan" && namedIn(o, shownSlugs));
1217
+ const recommendedPlan = firstRecommended(products);
1218
+ const { locale, labels } = options;
1219
+ for (const slug of new Set(slugs)) {
1220
+ if (!shownSlugs.has(slug)) continue;
1221
+ const product = products.find((o) => offeringPlanSlugs(o).includes(slug));
1222
+ const point = product && offeringPointProducts(product).find((p) => p.plan === slug);
1223
+ // A column shows the card's name, price and checkout link only, so the
1224
+ // card's footnote link (`siteOrigin`) and display options never matter here.
1225
+ const card = point && ownCard(point, shown, false, locale, labels, undefined);
1226
+ if (!product || !card) continue;
1227
+ // #12280 D2, D4 — with a unit noun, a side reads the card's amount and
1228
+ // unit, joined by the card's own space; else the card's phrase, unchanged.
1229
+ const parts = card.priceUnit ? card.priceParts : undefined;
1230
+ const monthly = joinedPrice(parts?.monthly, card.price.monthly);
1231
+ const annual = joinedPrice(parts?.annual, card.price.annual);
1232
+ const { custom } = card.price;
1233
+ columns.set(slug, {
1234
+ name: card.name,
1235
+ price: {
1236
+ ...(monthly !== undefined ? { monthly } : {}),
1237
+ ...(annual !== undefined ? { annual } : {}),
1238
+ ...(custom !== undefined ? { custom } : {}),
1239
+ },
1240
+ cta: { label: card.cta.label, href: card.cta.href },
1241
+ ...(card.annualCtaHref !== undefined ? { annualCtaHref: card.annualCtaHref } : {}),
1242
+ ...(product.plan === recommendedPlan ? { recommended: true as const } : {}),
1243
+ });
1244
+ }
1245
+ return columns;
1246
+ }