create-ailk 0.34.1 → 0.36.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.
Files changed (139) hide show
  1. package/README.md +1 -1
  2. package/component-catalog.json +37 -4
  3. package/component-catalog.md +11 -9
  4. package/dist/add-module.js +7 -2
  5. package/dist/derive-architecture.js +2 -0
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/lib/env-catalog.js +8 -0
  9. package/dist/module-architecture.js +9 -0
  10. package/dist/programmatic.js +5 -2
  11. package/dist/site-listing-path.d.ts +8 -0
  12. package/dist/site-listing-path.js +8 -0
  13. package/dist/surfaces.d.ts +20 -0
  14. package/dist/surfaces.js +32 -3
  15. package/dist/template-record.js +2 -0
  16. package/dist/topology.d.ts +4 -4
  17. package/dist/topology.js +104 -60
  18. package/dist/update.js +11 -0
  19. package/package.json +3 -3
  20. package/templates/.env.example +21 -0
  21. package/templates/apps/api/.env.example +7 -0
  22. package/templates/apps/api/CLAUDE.md +14 -9
  23. package/templates/apps/mcp/CLAUDE.md +18 -7
  24. package/templates/apps/web/.env.example +16 -0
  25. package/templates/apps/web/CLAUDE.md +46 -5
  26. package/templates/apps/web/app/[locale]/(auth)/__tests__/password-reset.test.tsx +2 -0
  27. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/page.test.tsx +52 -1
  28. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/remembered-method.test.ts +43 -0
  29. package/templates/apps/web/app/[locale]/(auth)/sign-in/__tests__/sign-in-card.test.tsx +108 -1
  30. package/templates/apps/web/app/[locale]/(auth)/sign-in/page.tsx +36 -3
  31. package/templates/apps/web/app/[locale]/(auth)/sign-in/remembered-method.ts +37 -0
  32. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-card.tsx +90 -33
  33. package/templates/apps/web/app/[locale]/(auth)/sign-in/sign-in-text.ts +9 -4
  34. package/templates/apps/web/app/[locale]/(authed)/__tests__/gate.test.tsx +79 -348
  35. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +12 -1
  36. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +55 -2
  37. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +43 -0
  38. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout-sign-out.test.tsx +10 -5
  39. package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +6 -5
  40. package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +1 -1
  41. package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +60 -6
  42. package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +32 -3
  43. package/templates/apps/web/app/[locale]/(authed)/account/connect/__tests__/page.test.tsx +8 -1
  44. package/templates/apps/web/app/[locale]/(authed)/account/connect/page.tsx +7 -3
  45. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/phone-verification.test.tsx +215 -0
  46. package/templates/apps/web/app/[locale]/(authed)/account/general/__tests__/seam-imports.test.ts +65 -0
  47. package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +47 -0
  48. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-actions.ts +122 -0
  49. package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +214 -0
  50. package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +6 -1
  51. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/invitation-id.test.ts +35 -0
  52. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/__tests__/page.test.tsx +266 -0
  53. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/actions.ts +116 -0
  54. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/invitation-id.ts +12 -0
  55. package/templates/apps/web/app/[locale]/(authed)/account/invitations/[invitationId]/page.tsx +154 -0
  56. package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +6 -4
  57. package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +3 -1
  58. package/templates/apps/web/app/[locale]/(authed)/layout.tsx +15 -13
  59. package/templates/apps/web/app/[locale]/(authed)/signed-out-gate.generated.tsx +20 -52
  60. package/templates/apps/web/app/[locale]/flows/[slug]/FlowStepperClient.tsx +43 -4
  61. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.deliverable.test.tsx +23 -9
  62. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.invite.test.tsx +15 -0
  63. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.permalink.test.tsx +74 -0
  64. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/FlowStepperClient.test.tsx +34 -1
  65. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/magnet-page.test.tsx +257 -4
  66. package/templates/apps/web/app/[locale]/flows/[slug]/__tests__/save.actions.test.ts +72 -92
  67. package/templates/apps/web/app/[locale]/flows/[slug]/email-moment.ts +2 -2
  68. package/templates/apps/web/app/[locale]/flows/[slug]/magnet-page.tsx +164 -65
  69. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/LevelChart.tsx +100 -0
  70. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsCard.tsx +99 -0
  71. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +415 -253
  72. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsEmailStep.tsx +113 -32
  73. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.no-commerce.test.tsx +16 -17
  74. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/ResultsClient.report.test.tsx +284 -0
  75. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/by-result.test.tsx +52 -19
  76. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/cards.test.tsx +402 -0
  77. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/page.test.tsx +100 -12
  78. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/__tests__/score.test.tsx +153 -101
  79. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/meeting-seam.ts +36 -0
  80. package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/page.tsx +121 -33
  81. package/templates/apps/web/app/[locale]/flows/[slug]/save.actions.ts +27 -17
  82. package/templates/apps/web/app/[locale]/flows/[slug]/served-flow.ts +91 -0
  83. package/templates/apps/web/app/[locale]/layout.tsx +42 -76
  84. package/templates/apps/web/app/[locale]/purchase/__tests__/success.test.tsx +50 -0
  85. package/templates/apps/web/app/[locale]/purchase/success/page.tsx +48 -7
  86. package/templates/apps/web/app/api/auth/hub/__tests__/entry-routes.test.ts +749 -0
  87. package/templates/apps/web/app/api/auth/hub/authorize/__tests__/route.test.ts +189 -6
  88. package/templates/apps/web/app/api/auth/hub/authorize/route.ts +101 -31
  89. package/templates/apps/web/app/api/auth/hub/continuation.ts +51 -2
  90. package/templates/apps/web/app/api/auth/hub/email/route.ts +111 -0
  91. package/templates/apps/web/app/api/auth/hub/entry-shared.ts +163 -0
  92. package/templates/apps/web/app/api/auth/hub/purchase/route.ts +230 -0
  93. package/templates/apps/web/app/api/auth/hub/purchase-link/route.ts +174 -0
  94. package/templates/apps/web/app/api/auth/hub/sign-up/route.ts +60 -0
  95. package/templates/apps/web/app/api/auth/hub/sign-up-evidence.ts +97 -0
  96. package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +475 -7
  97. package/templates/apps/web/app/api/hub-session/callback/route.ts +13 -47
  98. package/templates/apps/web/app/api/hub-session/email/route.ts +125 -0
  99. package/templates/apps/web/app/api/hub-session/one-tap/nonce/route.ts +49 -0
  100. package/templates/apps/web/app/api/hub-session/one-tap/route.ts +106 -0
  101. package/templates/apps/web/app/api/hub-session/open/route.ts +111 -0
  102. package/templates/apps/web/app/api/hub-session/sign-in/route.ts +23 -40
  103. package/templates/apps/web/app/api/hub-session/sign-out/route.ts +1 -10
  104. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +122 -0
  105. package/templates/apps/web/app/llms.txt/route.ts +14 -2
  106. package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +98 -0
  107. package/templates/apps/web/app/sitemap.xml/route.ts +13 -2
  108. package/templates/apps/web/auth.ts +133 -6
  109. package/templates/apps/web/components/sign-out-trigger.tsx +1 -1
  110. package/templates/apps/web/lib/__tests__/auth-email.test.ts +141 -0
  111. package/templates/apps/web/lib/__tests__/auth-phone.test.ts +445 -0
  112. package/templates/apps/web/lib/__tests__/auth-sms.test.ts +140 -0
  113. package/templates/apps/web/lib/__tests__/fixtures/tsconfig.flow.json +18 -0
  114. package/templates/apps/web/lib/__tests__/site-header.test.ts +13 -0
  115. package/templates/apps/web/lib/__tests__/telemetry-scrub.test.ts +19 -1
  116. package/templates/apps/web/lib/account-config.ts +24 -9
  117. package/templates/apps/web/lib/auth-email.ts +62 -6
  118. package/templates/apps/web/lib/auth-env.ts +13 -0
  119. package/templates/apps/web/lib/auth-sms.ts +180 -0
  120. package/templates/apps/web/lib/hub-session/__tests__/hub-session.test.ts +28 -0
  121. package/templates/apps/web/lib/hub-session/__tests__/spoke-sign-in.test.tsx +332 -0
  122. package/templates/apps/web/lib/hub-session/config.ts +7 -1
  123. package/templates/apps/web/lib/hub-session/entry.ts +238 -0
  124. package/templates/apps/web/lib/hub-session/index.ts +1 -4
  125. package/templates/apps/web/lib/hub-session/one-tap.tsx +148 -0
  126. package/templates/apps/web/lib/hub-session/session.ts +120 -2
  127. package/templates/apps/web/lib/hub-session/spoke-sign-in.tsx +277 -0
  128. package/templates/apps/web/lib/site-header.ts +14 -1
  129. package/templates/apps/web/lib/site-listing.ts +7 -0
  130. package/templates/apps/web/lib/telemetry-scrub.ts +11 -0
  131. package/templates/apps/web/lib/topology.generated.ts +39 -0
  132. package/templates/apps/web/messages/en.json +125 -21
  133. package/templates/apps/web/middleware.ts +34 -2
  134. package/templates/apps/web/security-headers.config.ts +21 -0
  135. package/versions.json +47 -47
  136. package/templates/apps/web/app/[locale]/(authed)/sign-in-gate.tsx +0 -162
  137. package/templates/apps/web/components/signed-in-nav.tsx +0 -79
  138. package/templates/apps/web/lib/hub-session/__tests__/sign-in-gate.test.tsx +0 -180
  139. package/templates/apps/web/lib/hub-session/sign-in-gate.tsx +0 -162
@@ -3,50 +3,54 @@
3
3
 
4
4
  /**
5
5
  * ResultsClient — the results permalink page's composition + view state
6
- * machine (#4842): `results` → `checkout` | `save` → saved.
6
+ * machine (#4842, redesigned by #11013 spec E): `results` → `checkout`.
7
7
  *
8
8
  * Runs the already-shipped pure `recommend()` on the decoded answers and
9
- * composes the LOCKED two-region frame (`FlowFrame`, DESIGN §2/§3/§7.2):
9
+ * composes the takeover window the walk lives in (`FlowFrame`, decisions
10
+ * 1–4 and 10–20 of docs/design-mocks/diagnostic-stepper-2026-11-06/README.md):
10
11
  *
11
- * - **results** — side panel = `FlowSidePanel` `safe-default` (the top fit,
12
- * its shown price when the register can price it, the always-present
13
- * Book-a-Call rail, §7.3); active region = the fits as
14
- * `RecommendationCard` (first fit `emphasis: "recommended"`, each with a
15
- * per-offer terminal — D2) + `PairingCard` when one matched; bar
16
- * `leading` = "Email me this plan" (D5), absent when the served
17
- * conversion is `none` (#10826).
12
+ * - **results** — no bar (decision 4). The recommendation heading and body
13
+ * where the register has them, then the **score** (decision 10): the
14
+ * points as a display number at `--flow-score-size`, "of {max}", the
15
+ * total's Level name and the `LevelChart` beside it; **Report Compiled**
16
+ * (decision 12) over one `ScoreBar` per dimension in register order; at
17
+ * most **one card** (decisions 14, 15 — straight to checkout, a by-result
18
+ * row's offering, the magnet's Email-links-to offering or appointment,
19
+ * else the older offer, the top fit as `RecommendationCard`); and the
20
+ * **Get your full report** form (decisions 13, 17, 18), inline, only when
21
+ * the walk asked no required email question and the conversion is not
22
+ * `none`. With a card its button is the primary and Send it is an
23
+ * outline button; with none Send it is primary (decision 16). From `md:`
24
+ * a two-column grid (score, Report Compiled and the form on the left,
25
+ * the card on the right); below it one column — score, Report Compiled,
26
+ * card, form — with the primary in a sticky bottom wrapper.
18
27
  * - **checkout** — Get Started performs DESIGN §7.6's panel FLIP: the
19
- * email step takes the frame's first (side) slot — "fields left" — and
20
- * the configurable price card (#4865, D3) takes the second (active)
21
- * slot — "price card right"; the card is controlled here, so its
22
- * seat / period / credit-stop state is EXACTLY what Pay sends. Below `md`
23
- * the frame stacks its slots in that same order, so the email step is
24
- * first on mobile and the card is the scroll-to. Bar `leading` = Back,
25
- * `trailing` = Pay.
26
- * - **save** — the same email step with the save framing; the side panel
27
- * stays the safe-default card (FR4); success renders the saved state.
28
+ * email step takes the frame's first (side) slot and the configurable
29
+ * price card (#4865, D3) the second (active) slot; the card is
30
+ * controlled here, so its seat / period / credit-stop state is EXACTLY
31
+ * what Pay sends. Bar `leading` = Back, `trailing` = Pay. Unchanged.
28
32
  *
29
- * #10828 — a scored register's results open with the respondent's own
30
- * score: the overall points out of the max and its Level name, then one
31
- * `ScoreBar` per dimension in register order, then the cards. The score is
32
- * `evaluateWaitlistScoring` over the decoded answers, run here as
33
- * `recommend()` is; a Level is named by the register's `levels.names`, else
34
- * "Level {n}". An unscored register (no scoring, or no points to score)
35
- * renders the cards only.
33
+ * The score is `evaluateWaitlistScoring` over the decoded answers, run here
34
+ * as `recommend()` is (#10828); a Level is named by the register's
35
+ * `levels.names` (five since #11034), else "Level {n}" for the total and
36
+ * "L{n}" on a dimension bar. An unscored register (no scoring, or no points
37
+ * to score) renders none of the score, the chart or Report Compiled
38
+ * (decision 19).
36
39
  *
37
- * The three frame regions keep their DOM identity across every transition
40
+ * The frame's regions keep their DOM identity across every transition
38
41
  * (#4806 FR7 — the frame is rendered once; only its slots change).
39
42
  *
40
43
  * Checkout is commerce's optional add-on to this signal-collectors page
41
44
  * (#6786): the price card and Pay come from `ResultsCheckoutContext`
42
- * (`checkout-seam.ts`), which commerce's `layout.tsx` provides. Without it —
43
- * a scaffold with no commerce — no fit offers Get Started (every terminal is
44
- * Book a Call), so the checkout view is unreachable; the results, the
45
- * Book-a-Call rail and "Email me this plan" are unchanged.
45
+ * (`checkout-seam.ts`), which commerce's `layout.tsx` provides. The Meeting
46
+ * card is scheduling's the same way (#11013 D-K): `ResultsMeetingContext`
47
+ * (`meeting-seam.ts`), provided by scheduling's `../layout.tsx` with at most
48
+ * the one meeting the magnet's `conversionLink` names. Without either, the
49
+ * context stays `undefined` and the page offers neither.
46
50
  *
47
- * Before a terminal or the save CTA is selected AND a valid email submitted,
48
- * this component makes no request of any kind (FR5 / PRD L108): the only
49
- * network call on the page is the server component's `flows.get`.
51
+ * Before a terminal or Send it is selected AND a valid email submitted, this
52
+ * component makes no request of any kind (FR5 / PRD L108): the only network
53
+ * calls on the page are the server component's.
50
54
  *
51
55
  * `RecommendRegister` (D6, #4770) is a structural `Pick` of the five fields
52
56
  * `recommend()` / `price()` read — `key`, `offers`, `pairings`, `rateTable`,
@@ -54,6 +58,7 @@
54
58
  * compiled config carries the register's own key on `experiment.key`.
55
59
  */
56
60
  import type {
61
+ FlowFrameBrand,
57
62
  RecommendationCardPrice,
58
63
  RecommendationCardTerminal,
59
64
  } from "@working-theory/ui";
@@ -61,18 +66,15 @@ import {
61
66
  Button,
62
67
  FlowFrame,
63
68
  Heading,
64
- PairingCard,
69
+ Link,
65
70
  RecommendationCard,
66
71
  ScoreBar,
67
72
  Text,
68
73
  } from "@working-theory/ui";
69
- import {
70
- FlowSidePanel,
71
- type FlowSidePanelView,
72
- } from "@working-theory/ui-signal-collectors";
73
74
  import type {
74
75
  FlowCompletion,
75
76
  FlowConfig,
77
+ FlowConversionLink,
76
78
  FlowSaveInput,
77
79
  LookupKeyPeriod,
78
80
  RecommendRegister,
@@ -83,19 +85,23 @@ import {
83
85
  flowRecommendRegister,
84
86
  recommend,
85
87
  resolveLocalizedString,
88
+ resultsPageAsksEmail,
86
89
  } from "@working-theory/validation";
87
90
  import { useTranslations } from "next-intl";
88
- import type { ReactElement, ReactNode } from "react";
91
+ import type { CSSProperties, ReactElement, ReactNode } from "react";
89
92
  import { useContext, useEffect, useMemo, useState } from "react";
90
93
 
91
94
  import { formatMinorUnits } from "../../../../../../lib/offerings-pricing";
92
- import { saveRecommendationAction } from "../../save.actions";
95
+ import { sendResultsEmailAction } from "../../save.actions";
93
96
 
94
97
  import type {
95
98
  ResultsCheckoutConfiguration,
96
99
  ResultsCheckoutInput,
97
100
  } from "./checkout-seam";
98
101
  import { ResultsCheckoutContext } from "./checkout-seam";
102
+ import { LevelChart } from "./LevelChart";
103
+ import { ResultsMeetingContext } from "./meeting-seam";
104
+ import { ResultsCard } from "./ResultsCard";
99
105
  import { ResultsEmailStep } from "./ResultsEmailStep";
100
106
 
101
107
  export type ResultsReturnState = "success" | "cancelled";
@@ -104,6 +110,8 @@ export type ResultsReturnState = "success" | "cancelled";
104
110
  * #10827 — the matched by-result row's offering, resolved by the page from
105
111
  * the shown set: named from the offering; `price` and `href` (its
106
112
  * `/pricing?plan=` card) only while it is shown — a draft has neither.
113
+ * #11013 D-G — its Stripe `description` and `features` too, so the card is
114
+ * the same Product card an Email-links-to offering draws.
107
115
  */
108
116
  export interface ResultsOfferingCard {
109
117
  offeringKey: string;
@@ -111,6 +119,8 @@ export interface ResultsOfferingCard {
111
119
  /** Stripe minor units, from the offering's own Price. */
112
120
  price?: { amount: number; currency: string; period: LookupKeyPeriod };
113
121
  href?: string;
122
+ description?: string;
123
+ features?: string[];
114
124
  /**
115
125
  * A checkout row's shown offering: on load the browser goes to `href`, the
116
126
  * Offerings buy route, as a top-level navigation; the card is the fallback.
@@ -118,9 +128,31 @@ export interface ResultsOfferingCard {
118
128
  checkoutOnLoad?: true;
119
129
  }
120
130
 
131
+ /**
132
+ * #11013 D-G (3) — the magnet's Email-links-to offering, resolved by the
133
+ * page from the shown set: the Product card. (An appointment's Meeting card
134
+ * arrives through the scheduling seam, not here.)
135
+ */
136
+ export interface ResultsConversionCard {
137
+ kind: "product";
138
+ name: string;
139
+ price?: ResultsOfferingCard["price"];
140
+ description?: string;
141
+ features?: string[];
142
+ /** Get Started's landing, `/pricing?plan=`. */
143
+ href: string;
144
+ }
145
+
121
146
  interface Props {
122
- /** The served config; `conversion` is the magnet's (#10826), absent from an older API. */
123
- config: FlowConfig & { conversion?: FlowCompletion };
147
+ /**
148
+ * The served config; `conversion`, `conversionLink` and `writtenReport`
149
+ * are the magnet's (#10826, #11013 D5), absent from an older API.
150
+ */
151
+ config: FlowConfig & {
152
+ conversion?: FlowCompletion;
153
+ conversionLink?: FlowConversionLink;
154
+ writtenReport?: boolean;
155
+ };
124
156
  locale: string;
125
157
  answers: Record<string, string | string[]>;
126
158
  slug: string;
@@ -130,9 +162,15 @@ interface Props {
130
162
  returnState?: ResultsReturnState;
131
163
  /** #10827 — the matched by-result row's offering card. */
132
164
  offeringCard?: ResultsOfferingCard;
165
+ /** #11013 D-G — the magnet's Email-links-to offering, when no by-result card won. */
166
+ conversionCard?: ResultsConversionCard;
167
+ /** #11013 D-A — the frame's brand header, built by the page. */
168
+ brand?: FlowFrameBrand;
169
+ /** #11013 D-A — where Esc leaves for; the flow's landing by default. */
170
+ exitHref?: string;
133
171
  }
134
172
 
135
- type View = "results" | "checkout" | "save";
173
+ type View = "results" | "checkout";
136
174
 
137
175
  const EMAIL_FORM_ID = "flow-results-email";
138
176
 
@@ -149,6 +187,18 @@ function resolveSafeLocale(candidate: string): string {
149
187
  return ENABLED_LOCALES.includes(candidate) ? candidate : DEFAULT_LOCALE;
150
188
  }
151
189
 
190
+ // #11013 decision 21 / spec E D-E — the score's size, read from
191
+ // `--flow-score-size` with the display role as its fallback, declared under
192
+ // this page's own property name so a site's `:root` declaration wins.
193
+ const FLOW_SCORE_SIZE_STYLE = {
194
+ "--ailk-flow-score-size": "var(--flow-score-size, var(--text-display))",
195
+ } as CSSProperties;
196
+
197
+ /** The sticky wrapper's safe-area inset (the FlowFrame bar's idiom). */
198
+ const SAFE_BOTTOM_STYLE = {
199
+ "--ailk-flow-safe-bottom": "max(env(safe-area-inset-bottom, 0px), 1rem)",
200
+ } as CSSProperties;
201
+
152
202
  /**
153
203
  * Next's redirect control-flow error (`redirect()` inside a Server Action),
154
204
  * recognised by its digest — `NEXT_REDIRECT;<push|replace>;<url>;<status>;`
@@ -179,6 +229,12 @@ function firstSeatRatePeriod(
179
229
  return rateTable.seatRates.find((rate) => rate.offer === offerKey)?.period;
180
230
  }
181
231
 
232
+ /** The primary action, mirrored into the phone's dock (decision 16): a card's link, a fit's terminal, or Send it. */
233
+ type PrimaryAction =
234
+ | { label: string; href: string }
235
+ | { label: string; onSelect: () => void }
236
+ | { label: string; form: string };
237
+
182
238
  export function ResultsClient({
183
239
  config,
184
240
  locale,
@@ -187,17 +243,29 @@ export function ResultsClient({
187
243
  payload,
188
244
  returnState,
189
245
  offeringCard,
246
+ conversionCard,
247
+ brand,
248
+ exitHref,
190
249
  }: Props): ReactElement {
191
250
  const t = useTranslations("flow");
192
251
  const tOfferings = useTranslations("pricingOfferings");
193
- // #10828 — the score's two words, from the catalog's existing entries.
194
- const tScore = useTranslations("account.results");
195
252
  const tLevel = useTranslations("waitlistDashboard.level");
196
253
  const checkout = useContext(ResultsCheckoutContext);
254
+ // #11013 D-K — the one meeting the scheduling layout provides, if any.
255
+ const meeting = useContext(ResultsMeetingContext);
197
256
  const { defaultLocale, offers = [], recommendation } = config;
198
257
 
199
258
  const register = useMemo<RecommendRegister>(() => flowRecommendRegister(config), [config]);
200
- const result = useMemo(() => recommend(register, answers), [register, answers]);
259
+ // #11013 D-C — a recommending flow with neither `offers` nor by-result rows
260
+ // reaches this page now; `recommend()` refuses such a register, so it is
261
+ // asked nothing and the page has no fit to show.
262
+ const result = useMemo(
263
+ () =>
264
+ register.offers !== undefined || register.byResult !== undefined
265
+ ? recommend(register, answers)
266
+ : undefined,
267
+ [register, answers],
268
+ );
201
269
  // #10828 — no points to score (max 0) is an unscored register. The
202
270
  // evaluator returns `dimensions` 1:1 with, and in the order of, the
203
271
  // register's own, so each takes its name by index.
@@ -226,7 +294,8 @@ export function ResultsClient({
226
294
  const [sessionId, setSessionId] = useState<string | undefined>();
227
295
  const [pending, setPending] = useState(false);
228
296
  const [error, setError] = useState<string | undefined>();
229
- const [saved, setSaved] = useState(false);
297
+ // #11013 D-F — the address the report was sent to; set, the form is "Sent to {email}."
298
+ const [sentTo, setSentTo] = useState<string | undefined>();
230
299
 
231
300
  // D4 — read the walk's own session id; a privacy mode that throws, or no
232
301
  // entry at all, degrades to cold (the key is simply omitted from the body).
@@ -279,7 +348,7 @@ export function ResultsClient({
279
348
  if (walked) window.location.replace(offeringHref);
280
349
  }, [checkoutOnLoad, offeringHref, returnState, slug]);
281
350
 
282
- const topFit = result.fits[0];
351
+ const topFit = result?.fits[0];
283
352
  const topOffer = topFit
284
353
  ? offers.find((offer) => offer.key === topFit.offerKey)
285
354
  : undefined;
@@ -296,12 +365,6 @@ export function ResultsClient({
296
365
  setView("checkout");
297
366
  }
298
367
 
299
- function openSave(): void {
300
- setError(undefined);
301
- setSaved(false);
302
- setView("save");
303
- }
304
-
305
368
  function back(): void {
306
369
  setError(undefined);
307
370
  setView("results");
@@ -357,19 +420,20 @@ export function ResultsClient({
357
420
  }
358
421
  }
359
422
 
360
- async function handleSave(email: string): Promise<void> {
423
+ // #11013 D-F — Send it: the results-email route runs the conversion.
424
+ async function handleSendReport(email: string): Promise<void> {
361
425
  setPending(true);
362
426
  setError(undefined);
363
427
  const body: FlowSaveInput = {
364
428
  answers,
365
429
  email,
366
- locale,
430
+ locale: safeLocale,
367
431
  ...(sessionId !== undefined ? { sessionId } : {}),
368
432
  };
369
433
  try {
370
- const outcome = await saveRecommendationAction(slug, body);
434
+ const outcome = await sendResultsEmailAction(slug, body);
371
435
  if (outcome.ok) {
372
- setSaved(true);
436
+ setSentTo(email);
373
437
  } else {
374
438
  setError(failureMessage(outcome.kind, outcome.retryAfterSeconds, "submitError"));
375
439
  }
@@ -380,38 +444,11 @@ export function ResultsClient({
380
444
  }
381
445
  }
382
446
 
383
- // ── Side panel ──────────────────────────────────────────────────────────
384
-
385
- const safeDefaultView: FlowSidePanelView | undefined = topOffer
386
- ? {
387
- kind: "safe-default",
388
- anchorTitle: t("sidePanel.anchorTitle"),
389
- offerName: resolve(topOffer.copy.name),
390
- ...(currency !== undefined && topOffer.price.kind !== "label"
391
- ? {
392
- price: {
393
- amountMinor: Math.round(topOffer.price.amount * 100),
394
- currency,
395
- locale,
396
- },
397
- showPrice: true,
398
- }
399
- : {}),
400
- action: { kind: "link", href: bookCallHref, label: t("bookCall") },
401
- }
402
- : undefined;
403
-
404
447
  // The frame's regions carry no inner padding of their own (FlowFrame.tsx
405
448
  // :151/:159) — the consumer pads, exactly as FlowStepper does for its step
406
449
  // body (`mx-auto w-full max-w-container-sm p-card`, FlowStepper.tsx:1280).
407
450
  const REGION_CLASS = "mx-auto w-full max-w-container-sm p-card";
408
451
 
409
- const safeDefaultPanel: ReactNode = safeDefaultView ? (
410
- <div className={REGION_CLASS}>
411
- <FlowSidePanel view={safeDefaultView} />
412
- </div>
413
- ) : undefined;
414
-
415
452
  // DESIGN §7.6 — the configurable price card, rendered into the frame's
416
453
  // SECOND slot (right at md+) on the checkout view; the email step takes the
417
454
  // first slot. Composed once here, placed below.
@@ -432,15 +469,124 @@ export function ResultsClient({
432
469
  );
433
470
  }
434
471
 
472
+ // ── The one card (decision 15) ───────────────────────────────────────────
473
+ //
474
+ // (1) a checkout row — `offeringCard` with `checkoutOnLoad`; (2) a by-result
475
+ // offering row — `offeringCard`; (3) Email links to — `conversionCard`
476
+ // (offering) or the seam's `meeting` (appointment, only the one the link
477
+ // names); (4) the older offer — the top fit. First present wins.
478
+ const link = config.conversionLink;
479
+ const meetingCard =
480
+ link?.kind === "appointment" && meeting !== undefined && meeting.slug === link.id
481
+ ? meeting
482
+ : undefined;
483
+
484
+ let card: ReactNode;
485
+ let primary: PrimaryAction | undefined;
486
+ if (offeringCard) {
487
+ const action = offeringHref !== undefined ? { href: offeringHref, label: t("getStarted") } : undefined;
488
+ card = (
489
+ <ResultsCard
490
+ eyebrow={t("priceCard.eyebrow")}
491
+ title={offeringCard.title}
492
+ {...(offeringCard.price ? { price: offeringPriceLabel(offeringCard.price) } : {})}
493
+ {...(offeringCard.description !== undefined ? { description: offeringCard.description } : {})}
494
+ {...(offeringCard.features !== undefined ? { features: offeringCard.features } : {})}
495
+ featuresLabel={t("whatsIncluded")}
496
+ {...(action !== undefined ? { action } : {})}
497
+ />
498
+ );
499
+ primary = action;
500
+ } else if (conversionCard) {
501
+ primary = { href: conversionCard.href, label: t("getStarted") };
502
+ card = (
503
+ <ResultsCard
504
+ eyebrow={t("priceCard.eyebrow")}
505
+ title={conversionCard.name}
506
+ {...(conversionCard.price ? { price: offeringPriceLabel(conversionCard.price) } : {})}
507
+ {...(conversionCard.description !== undefined ? { description: conversionCard.description } : {})}
508
+ {...(conversionCard.features !== undefined ? { features: conversionCard.features } : {})}
509
+ featuresLabel={t("whatsIncluded")}
510
+ action={primary}
511
+ />
512
+ );
513
+ } else if (meetingCard) {
514
+ primary = { href: meetingCard.href, label: meetingCard.bookLabel };
515
+ card = (
516
+ <ResultsCard
517
+ eyebrow={t("priceCard.eyebrow")}
518
+ title={meetingCard.title}
519
+ {...(meetingCard.description !== undefined ? { description: meetingCard.description } : {})}
520
+ action={primary}
521
+ />
522
+ );
523
+ } else if (topFit && topOffer) {
524
+ // Get Started only where commerce is on (#6786) AND the offer is quotable (D2).
525
+ const quotable =
526
+ checkout !== undefined && firstSeatRatePeriod(register, topOffer.key) !== undefined;
527
+ const onSelect = quotable
528
+ ? () => startCheckout(topOffer.key)
529
+ : () => window.location.assign(bookCallHref);
530
+ const terminal: RecommendationCardTerminal = quotable
531
+ ? { kind: "getStarted", label: t("getStarted"), onSelect }
532
+ : { kind: "bookCall", label: t("bookCall"), onSelect };
533
+ const price: RecommendationCardPrice | undefined =
534
+ currency !== undefined
535
+ ? {
536
+ ...topOffer.price,
537
+ currency,
538
+ locale,
539
+ ...(defaultLocale !== undefined ? { defaultLocale } : {}),
540
+ periodLabels,
541
+ fromPrefix: t("price.fromPrefix"),
542
+ }
543
+ : undefined;
544
+ primary = { label: terminal.label, onSelect };
545
+ card = (
546
+ <RecommendationCard
547
+ data-testid={`recommendation-card-${topFit.offerKey}`}
548
+ title={resolve(topOffer.copy.name)}
549
+ {...(topOffer.copy.description ? { description: resolve(topOffer.copy.description) } : {})}
550
+ emphasis="recommended"
551
+ recommendedLabel={t("priceCard.eyebrow")}
552
+ {...(price !== undefined ? { price } : {})}
553
+ terminal={terminal}
554
+ whyThis={{ label: t("whyThis"), content: resolve(topFit.reason) }}
555
+ />
556
+ );
557
+ }
558
+ const hasCard = card !== undefined;
559
+
560
+ // ── Get your full report (decisions 13, 17, 18) ──────────────────────────
561
+ const asksEmail =
562
+ resultsPageAsksEmail(config) && config.conversion !== undefined && config.conversion !== "none";
563
+ const formHeading =
564
+ (config.resultsPage?.formHeading !== undefined
565
+ ? resolve(config.resultsPage.formHeading)
566
+ : undefined) ??
567
+ (config.writtenReport === true ? t("resultsFormHeadingReport") : t("resultsFormHeadingResults"));
568
+ const formButton =
569
+ (config.resultsPage?.formButton !== undefined ? resolve(config.resultsPage.formButton) : undefined) ??
570
+ t("resultsFormButton");
571
+ // Decision 16 — with no card, Send it is the primary: on a phone a docked
572
+ // copy submits the form while the form itself stays in flow.
573
+ if (primary === undefined && asksEmail && sentTo === undefined) {
574
+ primary = { label: formButton, form: EMAIL_FORM_ID };
575
+ }
576
+
577
+ // The total's Level name (spec A's pattern), and a dimension's short one.
578
+ const names = config.scoring?.levels?.names;
579
+ const totalLevelName = (level: number): string => names?.[level - 1] ?? tLevel("label", { n: level });
580
+ const dimensionLevelName = (level: number): string => names?.[level - 1] ?? t("levelShort", { n: level });
581
+
435
582
  // ── Slots ────────────────────────────────────────────────────────────────
436
583
  //
437
- // `sidePanel` is the frame's FIRST slot (left at md+, first in the mobile
438
- // stack); `active` is its SECOND. On the results and save views the safe-
439
- // default card is first and the recommendation / email step second; on the
440
- // checkout view the slots FLIP (DESIGN §7.6 / §2's Checkout row): the email
441
- // step is first and the price card second.
584
+ // `sidePanel` is the frame's FIRST slot; `active` is its SECOND. On the
585
+ // results view the active region alone holds the page; on the checkout view
586
+ // the slots FLIP (DESIGN §7.6 / §2's Checkout row): the email step is first
587
+ // and the price card second.
442
588
 
443
- let sidePanel: ReactNode = safeDefaultPanel;
589
+ let sidePanel: ReactNode;
444
590
  let active: ReactNode;
445
591
  let leading: ReactNode;
446
592
  let trailing: ReactNode;
@@ -448,161 +594,132 @@ export function ResultsClient({
448
594
  if (view === "results") {
449
595
  const heading = recommendation ? resolve(recommendation.copy.title) : undefined;
450
596
  const body = recommendation?.copy.body ? resolve(recommendation.copy.body) : undefined;
451
- const levelName = (level: number): string =>
452
- config.scoring?.levels?.names[level - 1] ?? tLevel("label", { n: level });
597
+ const column = "md:col-span-3";
453
598
 
454
599
  active = (
455
- <div data-testid="flow-results">
456
- {returnState !== undefined ? (
600
+ <div
601
+ data-testid="flow-results"
602
+ className={hasCard ? "md:grid md:grid-cols-5 md:gap-x-10" : "mx-auto w-full max-w-container-sm"}
603
+ >
604
+ <div className={column}>
605
+ {returnState !== undefined ? (
606
+ <div
607
+ role="status"
608
+ data-testid="flow-results-return-state"
609
+ className="mb-block-loose"
610
+ >
611
+ <Text variant="body-sm" tone="muted">
612
+ {t(returnState === "success" ? "checkoutSuccess" : "checkoutCancelled")}
613
+ </Text>
614
+ </div>
615
+ ) : null}
616
+ {heading ? <Heading level={1}>{heading}</Heading> : null}
617
+ {body ? (
618
+ <Text variant="body" tone="muted" className="mt-block-tight">
619
+ {body}
620
+ </Text>
621
+ ) : null}
622
+ {score ? (
623
+ <div
624
+ data-testid="flow-results-score"
625
+ className="mt-block-loose flex flex-col gap-5 md:flex-row md:items-end md:gap-8"
626
+ style={FLOW_SCORE_SIZE_STYLE}
627
+ >
628
+ <div
629
+ data-testid="flow-results-score-total"
630
+ className="flex flex-row items-baseline gap-3 md:flex-col md:items-start md:gap-2 md:pb-6"
631
+ >
632
+ <span className="flex items-baseline gap-1.5 whitespace-nowrap">
633
+ <span
634
+ data-testid="flow-results-score-total-points"
635
+ className="font-display font-semibold leading-none tracking-tight tabular-nums text-fg text-(length:--ailk-flow-score-size)"
636
+ >
637
+ {score.total.points.toLocaleString(locale)}
638
+ </span>
639
+ <Text as="span" variant="body" tone="muted">
640
+ {t("scoreOutOf", { max: score.total.max })}
641
+ </Text>
642
+ </span>
643
+ <Text
644
+ as="span"
645
+ variant="body-sm"
646
+ className="font-semibold"
647
+ data-testid="flow-results-score-total-level"
648
+ >
649
+ {totalLevelName(score.total.level)}
650
+ </Text>
651
+ </div>
652
+ <LevelChart
653
+ className="min-w-0 flex-1"
654
+ level={score.total.level}
655
+ pct={score.total.pct}
656
+ label={t("levelChartLabel", {
657
+ level: score.total.level,
658
+ pct: Math.round(score.total.pct),
659
+ })}
660
+ />
661
+ </div>
662
+ ) : null}
663
+ </div>
664
+ {score && score.dimensions.length > 0 ? (
457
665
  <div
458
- role="status"
459
- data-testid="flow-results-return-state"
460
- className="mb-block-loose"
666
+ data-testid="flow-results-report-compiled"
667
+ className={`${column} mt-block-loose border-t border-(--color-border) pt-6`}
461
668
  >
462
- <Text variant="body-sm" tone="muted">
463
- {t(returnState === "success" ? "checkoutSuccess" : "checkoutCancelled")}
464
- </Text>
669
+ <Heading level={2} className="text-heading-4">
670
+ {t("reportCompiled")}
671
+ </Heading>
672
+ <div className="mt-4 flex flex-col gap-4">
673
+ {score.dimensions.map((dimension) => (
674
+ <ScoreBar
675
+ key={dimension.key}
676
+ label={dimension.name}
677
+ points={dimension.points}
678
+ max={dimension.max}
679
+ pct={dimension.pct}
680
+ levelName={dimensionLevelName(dimension.level)}
681
+ locale={locale}
682
+ data-testid={`flow-results-score-dimension-${dimension.key}`}
683
+ />
684
+ ))}
685
+ </div>
465
686
  </div>
466
687
  ) : null}
467
- {heading ? <Heading level={1}>{heading}</Heading> : null}
468
- {body ? (
469
- <Text variant="body" tone="muted" className="mt-block-tight">
470
- {body}
471
- </Text>
688
+ {hasCard ? (
689
+ <div className="mt-block-loose md:col-span-2 md:col-start-4 md:row-span-3 md:row-start-1 md:mt-0 md:self-start">
690
+ {card}
691
+ </div>
472
692
  ) : null}
473
- {score ? (
474
- <div data-testid="flow-results-score" className="mt-block-loose flex flex-col gap-6">
475
- <ScoreBar
476
- size="lg"
477
- label={tScore("score")}
478
- points={score.total.points}
479
- max={score.total.max}
480
- pct={score.total.pct}
481
- levelName={levelName(score.total.level)}
482
- locale={locale}
483
- data-testid="flow-results-score-total"
693
+ {asksEmail ? (
694
+ <div className={`${column} mt-block-loose border-t border-(--color-border) pt-6`}>
695
+ <ResultsEmailStep
696
+ title={formHeading}
697
+ formId={EMAIL_FORM_ID}
698
+ labels={{
699
+ invalidEmail: t("validationInvalidEmail"),
700
+ placeholder: t("emailPlaceholder"),
701
+ savedTitle: t("resultsSent", { email: sentTo ?? "" }),
702
+ }}
703
+ consent={t("resultsConsent")}
704
+ action={{
705
+ label: formButton,
706
+ variant: hasCard ? "outline" : "default",
707
+ ...(hasCard ? {} : { dockedBelowMd: true }),
708
+ }}
709
+ onSubmit={handleSendReport}
710
+ pending={pending}
711
+ {...(error !== undefined ? { error } : {})}
712
+ saved={sentTo !== undefined}
713
+ data-testid="flow-results-report"
484
714
  />
485
- {score.dimensions.length > 0 ? (
486
- <div className="flex flex-col gap-4">
487
- {score.dimensions.map((dimension) => (
488
- <ScoreBar
489
- key={dimension.key}
490
- label={dimension.name}
491
- points={dimension.points}
492
- max={dimension.max}
493
- pct={dimension.pct}
494
- levelName={levelName(dimension.level)}
495
- locale={locale}
496
- data-testid={`flow-results-score-dimension-${dimension.key}`}
497
- />
498
- ))}
499
- </div>
500
- ) : null}
501
715
  </div>
502
716
  ) : null}
503
- <div className="mt-block-loose flex flex-col gap-4">
504
- {offeringCard ? (
505
- <RecommendationCard
506
- data-testid={`recommendation-card-${offeringCard.offeringKey}`}
507
- title={offeringCard.title}
508
- emphasis="recommended"
509
- recommendedLabel={t("priceCard.eyebrow")}
510
- {...(offeringCard.price
511
- ? {
512
- price: {
513
- kind: "label",
514
- label: { [locale]: offeringPriceLabel(offeringCard.price) },
515
- currency: offeringCard.price.currency,
516
- locale,
517
- periodLabels,
518
- fromPrefix: t("price.fromPrefix"),
519
- },
520
- }
521
- : {})}
522
- {...(offeringHref !== undefined
523
- ? {
524
- terminal: {
525
- kind: "getStarted",
526
- label: t("getStarted"),
527
- onSelect: () => window.location.assign(offeringHref),
528
- },
529
- }
530
- : {})}
531
- />
532
- ) : null}
533
- {result.fits.map((fit, index) => {
534
- const offer = offers.find((o) => o.key === fit.offerKey);
535
- if (!offer) return null;
536
- // #10827 — one recommended card: a by-result card takes the badge.
537
- const recommendedFit = index === 0 && !offeringCard;
538
- // Get Started only where commerce is on (#6786) AND the offer is quotable (D2).
539
- const quotable =
540
- checkout !== undefined &&
541
- firstSeatRatePeriod(register, offer.key) !== undefined;
542
- const terminal: RecommendationCardTerminal = quotable
543
- ? {
544
- kind: "getStarted",
545
- label: t("getStarted"),
546
- onSelect: () => startCheckout(offer.key),
547
- }
548
- : {
549
- kind: "bookCall",
550
- label: t("bookCall"),
551
- onSelect: () => window.location.assign(bookCallHref),
552
- };
553
- const price: RecommendationCardPrice | undefined =
554
- currency !== undefined
555
- ? {
556
- ...offer.price,
557
- currency,
558
- locale,
559
- ...(defaultLocale !== undefined ? { defaultLocale } : {}),
560
- periodLabels,
561
- fromPrefix: t("price.fromPrefix"),
562
- }
563
- : undefined;
564
- return (
565
- <RecommendationCard
566
- key={fit.offerKey}
567
- data-testid={`recommendation-card-${fit.offerKey}`}
568
- title={resolve(offer.copy.name)}
569
- {...(offer.copy.description
570
- ? { description: resolve(offer.copy.description) }
571
- : {})}
572
- emphasis={recommendedFit ? "recommended" : "default"}
573
- {...(recommendedFit ? { recommendedLabel: t("priceCard.eyebrow") } : {})}
574
- {...(price !== undefined ? { price } : {})}
575
- terminal={terminal}
576
- whyThis={{ label: t("whyThis"), content: resolve(fit.reason) }}
577
- />
578
- );
579
- })}
580
- {result.pairing ? (
581
- <PairingCard
582
- title={t("pairingTitle")}
583
- pairing={result.pairing}
584
- offers={offers}
585
- locale={locale}
586
- {...(defaultLocale !== undefined ? { defaultLocale } : {})}
587
- data-testid="recommendation-pairing"
588
- />
589
- ) : null}
590
- </div>
591
717
  </div>
592
718
  );
593
- // #10826 — a magnet that converts no one (`none`) asks for no email.
594
- leading =
595
- config.conversion === "none" ? undefined : (
596
- <Button type="button" variant="ghost" size="big" onClick={openSave}>
597
- {t("emailMePlan")}
598
- </Button>
599
- );
600
- trailing = undefined;
601
719
  } else {
602
- const isCheckout = view === "checkout";
603
720
  const emailStep = (
604
721
  <ResultsEmailStep
605
- title={t(isCheckout ? "emailStepTitle" : "emailStepSaveTitle")}
722
+ title={t("emailStepTitle")}
606
723
  formId={EMAIL_FORM_ID}
607
724
  labels={{
608
725
  invalidEmail: t("validationInvalidEmail"),
@@ -610,48 +727,93 @@ export function ResultsClient({
610
727
  savedTitle: t("savedTitle"),
611
728
  savedBody: t("savedBody"),
612
729
  }}
613
- onSubmit={isCheckout ? handlePay : handleSave}
730
+ onSubmit={handlePay}
614
731
  pending={pending}
615
732
  {...(error !== undefined ? { error } : {})}
616
- saved={!isCheckout && saved}
617
733
  />
618
734
  );
619
- if (isCheckout) {
620
- sidePanel = <div className={REGION_CLASS}>{emailStep}</div>;
621
- active = priceCard;
622
- } else {
623
- active = emailStep;
624
- }
735
+ sidePanel = <div className={REGION_CLASS}>{emailStep}</div>;
736
+ active = priceCard;
625
737
  leading = (
626
738
  <Button type="button" variant="ghost" size="big" onClick={back} disabled={pending}>
627
739
  {t("back")}
628
740
  </Button>
629
741
  );
630
- trailing =
631
- !isCheckout && saved ? undefined : (
632
- <Button
633
- type="submit"
634
- form={EMAIL_FORM_ID}
635
- size="big"
636
- disabled={pending}
637
- data-testid={isCheckout ? "flow-results-pay" : "flow-results-save"}
638
- >
639
- {t(isCheckout ? "pay" : "emailMePlan")}
640
- </Button>
641
- );
742
+ trailing = (
743
+ <Button
744
+ type="submit"
745
+ form={EMAIL_FORM_ID}
746
+ size="big"
747
+ disabled={pending}
748
+ data-testid="flow-results-pay"
749
+ >
750
+ {t("pay")}
751
+ </Button>
752
+ );
642
753
  }
643
754
 
755
+ // Decision 16 — on a phone the card's button is anchored to the screen
756
+ // bottom (the board's dock), a row below the page's own scroller so the
757
+ // frame's middle region never overflows and its bottom fade never dims the
758
+ // primary; from `md:` the card's own button suffices.
759
+ const dock =
760
+ primary !== undefined ? (
761
+ <div
762
+ data-testid="flow-results-dock"
763
+ className="shrink-0 border-t border-(--color-border) bg-(--color-bg) px-5 pt-3 pb-(--ailk-flow-safe-bottom) md:hidden"
764
+ style={SAFE_BOTTOM_STYLE}
765
+ >
766
+ {"href" in primary ? (
767
+ <Button asChild size="big" className="min-h-11 w-full">
768
+ <Link href={primary.href} variant="bare">
769
+ {primary.label}
770
+ </Link>
771
+ </Button>
772
+ ) : "form" in primary ? (
773
+ <Button
774
+ type="submit"
775
+ form={primary.form}
776
+ size="big"
777
+ disabled={pending}
778
+ className="min-h-11 w-full"
779
+ data-testid="flow-results-dock-send"
780
+ >
781
+ {primary.label}
782
+ </Button>
783
+ ) : (
784
+ <Button type="button" size="big" className="min-h-11 w-full" onClick={primary.onSelect}>
785
+ {primary.label}
786
+ </Button>
787
+ )}
788
+ </div>
789
+ ) : null;
790
+
644
791
  return (
645
792
  <FlowFrame
646
- barMode="explicit"
793
+ takeover
794
+ barMode={view === "checkout" ? "explicit" : "none"}
647
795
  value={1}
648
796
  max={1}
797
+ {...(brand !== undefined ? { brand } : {})}
798
+ exit={{ href: exitHref ?? `/${safeLocale}/flows/${slug}`, label: t("exitLabel") }}
649
799
  sidePanel={sidePanel}
650
800
  leading={leading}
651
801
  trailing={trailing}
652
802
  data-testid="flow-results-frame"
653
803
  >
654
- {view === "checkout" ? active : <div className={REGION_CLASS}>{active}</div>}
804
+ {view === "checkout" ? (
805
+ active
806
+ ) : (
807
+ <div className="flex min-h-0 w-full flex-1 flex-col">
808
+ <div
809
+ data-testid="flow-results-scroller"
810
+ className="min-h-0 flex-1 overflow-y-auto md:min-h-fit md:flex-none md:overflow-visible"
811
+ >
812
+ <div className="mx-auto w-full max-w-container-lg p-card">{active}</div>
813
+ </div>
814
+ {dock}
815
+ </div>
816
+ )}
655
817
  </FlowFrame>
656
818
  );
657
819
  }