@bytebrand/fe-ui-core-autobahn 1.0.200 → 1.0.202

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.
@@ -1,1290 +1,1333 @@
1
- // Autobahn (auto.de redesign) — car-card helper parts.
2
- //
3
- // Typed React 18 + TS port of the helper components from the design kit
4
- // (docs/redesign/design-source/ui_kits/website/CarCard.jsx). Pure /
5
- // presentational: every value comes from the `AutobahnCar` prop, there is no
6
- // store / API / `window` access. The design kit's `window.CO2_CLASSES` /
7
- // `window.CO2_COLORS` globals are replaced by the shared autobahn constants.
8
- //
9
- // These render correctly only inside a `<div className="md3">` subtree (the
10
- // `.pricepaths`, `.pp-*`, `.specstrip`, `.imglabel` … classes are scoped there).
11
- //
12
- // NEEDS-DATA discipline (the point of the ticket): wherever the design showed a
13
- // figure we have no real source for, these helpers render the NEEDS_DATA_LABEL
14
- // ('Daten folgt') marker instead of inventing a number — see PricePaths'
15
- // market band and PpActivity. DropChip renders nothing when there is no drop.
16
-
17
- import React, { useState } from 'react';
18
- import { TranslationFunction } from '../types';
19
- import { defaultConfig } from '@bytebrand/fe-financing';
20
-
21
- import { Icon, Button, CreditCostNotice } from '../ui';
22
- import { EvalBar } from '../vdp/FinanceCalculator';
23
- import { CO2_CLASSES, CO2_COLORS, TIER_KEYS, TIER_COLORS } from '../constants';
24
- import { AutobahnCar } from './types';
25
- // pure, non-React — shared with the Meta AIA marketing-image renderer (a plain Node service).
26
- export { ratingTone } from '../data/toAutobahnCar';
27
-
28
- // Default financing/leasing terms shown under the rate (the SRP card has no per-car selector, so
29
- // these are the same default config the displayed rate is computed with — consistent, not invented).
30
- const _finCfg = (defaultConfig as any).financing || {};
31
- const _leasCfg = (defaultConfig as any).leasing || {};
32
- /** financing terms inputs (rendered via t in PricePaths), e.g. "0 € Anzahlung · 48 Monate Laufzeit". */
33
- const _finFirstInstallment = (_finCfg.firstInstallment || 0).toLocaleString('de-DE');
34
- const _finMonths = _finCfg.rawPaybackPeriod || _finCfg.paybackPeriod || 48;
35
- /** leasing terms fallbacks (used when the car doesn't carry its own), e.g. "10.000 km/Jahr · 48 Monate". */
36
- const _leasPeriod = _leasCfg.rawPaybackPeriod || _leasCfg.paybackPeriod;
37
- const _leasMileage = _leasCfg.annualMileage || _leasCfg.mileage;
38
- const _leasFirstInstallment = (_leasCfg.firstInstallment || 0).toLocaleString('de-DE');
39
-
40
- /** mileage → 'X.XXX km' (de-DE grouping). */
41
- export function fmtKm(n: number): string {
42
- return n.toLocaleString('de-DE') + ' km';
43
- }
44
-
45
- /**
46
- * Monthly rate → de-DE integer euro string (e.g. 402.12 → "402"). Rates are shown as whole
47
- * euros like the legacy card ("271 €"); a raw float printed directly rendered as "402.12 €",
48
- * which a German reader parses as 402.120 — fixed here with rounding + de-DE grouping.
49
- */
50
- export function fmtRate(n: number): string {
51
- return Math.round(n).toLocaleString('de-DE');
52
- }
53
-
54
- /** strip a trailing parenthetical, e.g. '110 kW (150 PS)' → '110 kW'. */
55
- function stripParen(s: string): string {
56
- return s.replace(/\s*\(.*\)/, '');
57
- }
58
-
59
- /**
60
- * Opposite of stripParen, for car.power specifically: pull the PS value OUT of the trailing
61
- * parenthetical instead of discarding it, e.g. '145 kW (197 PS)' → '197 PS' — the card wants
62
- * PS only, no kW at all. Regex requires the paren to actually contain "N PS" (not just any
63
- * parenthetical) and falls back to the plain stripParen(kW) result when it doesn't, so a power
64
- * string without a PS conversion still renders something instead of going blank.
65
- */
66
- function extractPS(s: string): string {
67
- const m = s.match(/\((\d+\s*PS)\)\s*$/i);
68
- return m ? m[1].replace(/\s+/, ' ') : stripParen(s);
69
- }
70
-
71
- // Compact spec for cards: short fuel/gear labels so all five values fit ONE line
72
- // without clipping.
73
- const FUEL_SHORT: Record<string, string> = {
74
- 'Plug-in-Hybrid': 'Hybrid',
75
- Benzin: 'Benzin',
76
- Diesel: 'Diesel',
77
- Elektro: 'Elektro',
78
- };
79
- const GEAR_SHORT: Record<string, string> = {
80
- Automatik: 'Automatik',
81
- Schaltgetriebe: 'Manuell',
82
- };
83
-
84
- /** five compact spec values for the grid card's one-line spec strip. */
85
- export function cardSpec(car: AutobahnCar): string[] {
86
- const fuel = stripParen(car.fuel);
87
- return [
88
- fmtKm(car.km),
89
- car.reg,
90
- extractPS(car.power),
91
- FUEL_SHORT[fuel] || fuel,
92
- GEAR_SHORT[car.gear] || car.gear,
93
- ];
94
- }
95
-
96
- export interface SpecLineProps {
97
- items: string[];
98
- size?: number;
99
- /** never wrap — clip overflow with ellipsis (single line). */
100
- oneLine?: boolean;
101
- }
102
-
103
- /** Compact pipe-separated spec line (AutoScout pattern). */
104
- export const SpecLine: React.FunctionComponent<SpecLineProps> = ({ items, size = 12.5, oneLine = false }) => (
105
- <div
106
- className="cc-spec"
107
- style={{
108
- display: 'flex',
109
- flexWrap: oneLine ? 'nowrap' : 'wrap',
110
- alignItems: 'center',
111
- gap: '2px 8px',
112
- fontSize: size,
113
- color: 'var(--md-on-surface-variant)',
114
- ...(oneLine ? { overflow: 'hidden', whiteSpace: 'nowrap' } : {}),
115
- }}
116
- >
117
- {items.map((v, i) => (
118
- <React.Fragment key={i}>
119
- {i > 0 && <span style={{ color: 'var(--md-outline-variant)', flex: 'none' }}>·</span>}
120
- <span style={oneLine ? { whiteSpace: 'nowrap' } : undefined}>{v}</span>
121
- </React.Fragment>
122
- ))}
123
- </div>
124
- );
125
-
126
- export interface PriceBlockProps {
127
- car: AutobahnCar;
128
- align?: 'left' | 'right';
129
- t: TranslationFunction;
130
- }
131
-
132
- /** Price block — rate-first (monthly is the lead), purchase price secondary. */
133
- export const PriceBlock: React.FunctionComponent<PriceBlockProps> = ({ car, align = 'left', t }) => {
134
- const showStrike = car.savings != null && car.savings > 600 && car.listPrice != null;
135
- return (
136
- <div style={{ textAlign: align }}>
137
- <div
138
- style={{
139
- display: 'flex',
140
- alignItems: 'baseline',
141
- gap: 5,
142
- justifyContent: align === 'right' ? 'flex-end' : 'flex-start',
143
- }}
144
- >
145
- <span
146
- className="num"
147
- style={{
148
- fontWeight: 700,
149
- fontSize: 26,
150
- color: 'var(--md-primary)',
151
- letterSpacing: '-.6px',
152
- whiteSpace: 'nowrap',
153
- }}
154
- >
155
- {fmtRate(car.monthly)} €
156
- </span>
157
- <span className="md-label-sm">{t('autobahn:card.price.perMonth')}</span>
158
- </div>
159
- <div
160
- className="md-label-sm"
161
- style={{
162
- marginTop: 1,
163
- display: 'flex',
164
- flexWrap: 'wrap',
165
- gap: '0 6px',
166
- justifyContent: align === 'right' ? 'flex-end' : 'flex-start',
167
- }}
168
- >
169
- <span style={{ whiteSpace: 'nowrap' }}>
170
- {t('autobahn:card.price.purchasePrice')}{' '}
171
- <b style={{ color: 'var(--md-on-surface)' }}>{car.price.toLocaleString('de-DE')} €</b>
172
- </span>
173
- {showStrike && (
174
- <span
175
- style={{
176
- color: 'var(--md-on-surface-variant)',
177
- textDecoration: 'line-through',
178
- whiteSpace: 'nowrap',
179
- }}
180
- >
181
- {car.listPrice!.toLocaleString('de-DE')} €
182
- </span>
183
- )}
184
- </div>
185
- </div>
186
- );
187
- };
188
-
189
- export interface DropChipProps {
190
- /** real price reduction in EUR; when undefined the chip renders nothing. */
191
- amount?: number;
192
- t: TranslationFunction;
193
- }
194
-
195
- /**
196
- * Price-drop chip — a REAL reduction on this car. White pill so it doesn't
197
- * compete with the solid green rating chip. Renders nothing when there is no
198
- * drop (we never fabricate a reduction).
199
- */
200
- export const DropChip: React.FunctionComponent<DropChipProps> = ({ amount, t }) => {
201
- if (amount == null) {
202
- return null;
203
- }
204
- return (
205
- <span
206
- className="deal-chip deal-chip--drop"
207
- style={{
208
- display: 'inline-flex',
209
- alignItems: 'center',
210
- gap: 3,
211
- height: 22,
212
- padding: '0 8px',
213
- borderRadius: 'var(--md-r-full)',
214
- background: 'rgba(255,255,255,.94)',
215
- color: 'var(--md-good)',
216
- fontSize: 10.5,
217
- fontWeight: 700,
218
- lineHeight: '14px',
219
- boxShadow: 'var(--md-e1)',
220
- whiteSpace: 'nowrap',
221
- }}
222
- >
223
- <Icon name="trending-down" size={12} stroke={2.4} color="var(--md-good)" />
224
- {t('autobahn:card.price.priceDropAmount', { amount: amount.toLocaleString('de-DE') })}
225
- </span>
226
- );
227
- };
228
-
229
- /** shared deal-badge pill style (NEU/drop/percent/zero-down all share the same compact shape). */
230
- const dealPill: React.CSSProperties = {
231
- display: 'inline-flex',
232
- alignItems: 'center',
233
- height: 22,
234
- padding: '0 8px',
235
- borderRadius: 'var(--md-r-full)',
236
- fontSize: 10.5,
237
- fontWeight: 700,
238
- boxShadow: 'var(--md-e1)',
239
- whiteSpace: 'nowrap',
240
- };
241
-
242
- /** Percent price-drop chip (−X%). Red pill — pairs with DropChip. Renders nothing without a real pct. */
243
- export const PercentChip: React.FunctionComponent<{ pct?: number }> = ({ pct }) => {
244
- if (pct == null || pct <= 0) return null;
245
- return (
246
- <span className="deal-chip deal-chip--percent" style={{ ...dealPill, background: 'var(--md-error)', color: '#fff', lineHeight: '14px' }}>
247
- −{pct}%
248
- </span>
249
- );
250
- };
251
-
252
- /**
253
- * Zero-down-payment chip (offer.showDownPayment). Cyan pill. Spells out "0 € Anzahlung" where
254
- * there is room (grid cards / wide image) and uses the compact "0 € Anz." on the narrow list-card
255
- * image, so the badge row always stays on ONE line on both desktop and mobile.
256
- */
257
- export const ZeroDownChip: React.FunctionComponent<{
258
- show?: boolean;
259
- compact?: boolean;
260
- t: TranslationFunction;
261
- className?: string;
262
- /** overrides the default pill look (e.g. the desktop "mcard" full-text badge's own blue tint/size
263
- * from the Figma export) — merged last so it wins over the shared dealPill defaults below. */
264
- style?: React.CSSProperties;
265
- }> = ({ show, compact, t, className, style }) => {
266
- if (!show) return null;
267
- return (
268
- <span
269
- className={className}
270
- style={{ ...dealPill, background: 'var(--md-accent-container)', color: 'var(--md-on-accent-container)', ...style }}
271
- >
272
- {compact ? t('autobahn:card.price.zeroDownCompact') : t('autobahn:card.price.zeroDown')}
273
- </span>
274
- );
275
- };
276
-
277
- /**
278
- * "⚡ Angebot" gray badge — NOT a separate backend flag (none exists yet). Shown whenever the
279
- * card already carries a real deal signal (NEU / price drop / meaningful savings / 0€ Anzahlung
280
- * / percent drop) — i.e. it labels the same real discount the other badges point at, rather
281
- * than inventing a new "is this an offer" field. Revisit if/when a dedicated flag exists.
282
- */
283
- export const OfferBadge: React.FunctionComponent<{ show: boolean; t: TranslationFunction }> = ({ show, t }) => {
284
- if (!show) return null;
285
- return (
286
- <span className="offer-badge">
287
- <Icon name="zap" size={13} stroke={2.2} />
288
- {t('autobahn:card.badge.offer')}
289
- </span>
290
- );
291
- };
292
-
293
- interface InlineClsProps {
294
- /** CO₂ class letter, e.g. 'B'. */
295
- c: string;
296
- }
297
-
298
- /** Small inline colored CO₂-class letter (keeps EnVKV line a fixed height). */
299
- const InlineCls: React.FunctionComponent<InlineClsProps> = ({ c }) => {
300
- const i = Math.max(0, CO2_CLASSES.indexOf(c as (typeof CO2_CLASSES)[number]));
301
- const color = CO2_COLORS[i] || 'var(--md-outline)';
302
- return (
303
- <span
304
- style={{
305
- display: 'inline-flex',
306
- width: 14,
307
- height: 14,
308
- borderRadius: 3,
309
- background: color,
310
- color: '#fff',
311
- fontSize: 9.5,
312
- fontWeight: 800,
313
- alignItems: 'center',
314
- justifyContent: 'center',
315
- verticalAlign: '-2px',
316
- margin: '0 1px',
317
- }}
318
- >
319
- {c}
320
- </span>
321
- );
322
- };
323
-
324
- export interface EcoLineProps {
325
- car: AutobahnCar;
326
- style?: React.CSSProperties;
327
- t: TranslationFunction;
328
- }
329
-
330
- /**
331
- * Pkw-EnVKV legal line — full consumption + CO₂ + class. REQUIRED on every
332
- * German car ad and must stay visible. Quiet fine-print footnote with a fixed
333
- * min-height so all cards stay the same height. Handles the PHEV dual-figure
334
- * variant when a `phev` block is present.
335
- */
336
- export const EcoLine: React.FunctionComponent<EcoLineProps> = ({ car, style, t }) => {
337
- const wrap: React.CSSProperties = {
338
- borderTop: '1px solid var(--md-outline-variant)',
339
- paddingTop: 8,
340
- minHeight: 41,
341
- fontSize: 11,
342
- lineHeight: 1.5,
343
- color: 'var(--md-on-surface-variant)',
344
- ...style,
345
- };
346
- if (car.phev) {
347
- const p = car.phev;
348
- return (
349
- <div className="eco-line" style={wrap}>
350
- {p.consEl}{' '}
351
- {t('autobahn:card.eco.phevConsumptionLine', {
352
- consFuel: p.consFuel,
353
- consDis: p.consDis,
354
- co2w: p.co2w,
355
- co2classW: p.co2classW,
356
- co2classD: p.co2classD,
357
- })}
358
- </div>
359
- );
360
- }
361
- return (
362
- <div className="eco-line" style={wrap}>
363
- {t('autobahn:card.eco.consumptionLine', { cons: car.cons, co2: car.co2, co2class: car.co2class })}
364
- </div>
365
- );
366
- };
367
-
368
- export interface SeoLineProps {
369
- car: AutobahnCar;
370
- style?: React.CSSProperties;
371
- }
372
-
373
- /**
374
- * Full spec + equipment footer line (fuel, category, gearbox, colour, condition, drive
375
- * type, then every equipment highlight) — the small gray text under the card's CTA row,
376
- * same field/format as the legacy VehicleSmallCard's SeoText. Renders nothing without
377
- * `car.seoText` (needs-data: only fe-landing currently populates it).
378
- */
379
- export const SeoLine: React.FunctionComponent<SeoLineProps> = ({ car, style }) => {
380
- if (!car.seoText) return null;
381
- return (
382
- <div
383
- style={{
384
- fontSize: 10,
385
- lineHeight: '14px',
386
- color: 'var(--md-on-surface-variant)',
387
- maxHeight: 42,
388
- overflow: 'hidden',
389
- ...style,
390
- }}
391
- >
392
- {car.seoText}
393
- </div>
394
- );
395
- };
396
-
397
- export interface PricePathsProps {
398
- car: AutobahnCar;
399
- t: TranslationFunction;
400
- /** extra class appended to the root (e.g. the SRP card's desktop-only `hide-mobile` marker). */
401
- className?: string;
402
- /** takes over the financing/leasing terms rows' own "Details" links — e.g. navigate to this
403
- * car's VDP and open its finance modal already expanded, on the tab the link was under
404
- * (financing/leasing). Optional/page-owned like CarCard's onShowFinancingDetails; when
405
- * omitted the links render as plain (non-interactive) text, same as before this prop existed. */
406
- onShowDetails?: (mode: PaymentMode) => void;
407
- }
408
-
409
- /** Map the AutobahnCar rating tone → meter segment index (0 best … 4 worst). */
410
- const TONE_TO_TIER: Record<string, number> = { top: 0, good: 1, fair: 2, raised: 3, high: 4 };
411
-
412
- /**
413
- * Discrete Preisbewertung tier bar + thumb (Figma: 5 solid segments — green/light-green/yellow/
414
- * orange/red — with a white circular marker at the car's position, same `.fin-eval-bar`/
415
- * `.fin-eval-seg` segmented treatment the grid CarCard's PriceEvalCol/EvalBar already uses; no
416
- * text label here since the tier is already named by the StatChip pill next to the price).
417
- * Renders nothing when there is no rating/band (needs-data: we never draw a fake market position).
418
- */
419
- export const PriceMeter: React.FunctionComponent<{ car: AutobahnCar; t: TranslationFunction }> = ({ car }) => {
420
- const hasMarket =
421
- car.marketLow != null && car.marketAvg != null && car.marketHigh != null && car.marketHigh > car.marketLow;
422
- const bar = (tier: number) => {
423
- const leftPct = Math.max(4, Math.min(96, (tier / 4) * 100));
424
- const tierIndex = Math.max(0, Math.min(4, Math.round(tier)));
425
- return (
426
- <div className="fin-eval-bar">
427
- {TIER_COLORS.map((c, i) => (
428
- <span key={i} className="fin-eval-seg" style={{ background: c }} />
429
- ))}
430
- <div
431
- className={`fin-eval-thumb${TIER_KEYS[tierIndex] === 'good' ? ' fin-eval-thumb--good' : ''}`}
432
- style={{ left: `${leftPct}%`, borderColor: TIER_COLORS[tierIndex] }}
433
- />
434
- </div>
435
- );
436
- };
437
- if (hasMarket) {
438
- const mpos = Math.max(0, Math.min(1, (car.price - car.marketLow!) / (car.marketHigh! - car.marketLow!)));
439
- return bar(mpos * 4);
440
- }
441
- if (car.rating && TONE_TO_TIER[car.rating] != null) {
442
- // No market BAND yet, but the real Preisbewertung tier (same signal as the rating chip)
443
- // drives the thumb position. Real data, not faked.
444
- return bar(TONE_TO_TIER[car.rating]);
445
- }
446
- return null;
447
- };
448
-
449
- /**
450
- * Preisbewertung pill + segmented tier bar, grouped in one column exactly like the VDP
451
- * finance-calculator's mobile .fin-eval-col (FinanceCalculator.tsx/EvalBar) — the grid card's
452
- * replacement for the old StatChip pill + full-width gradient .pp-bar pairing. Renders nothing
453
- * without a rating (needs-data: never invent a tier).
454
- */
455
- export const PriceEvalCol: React.FunctionComponent<{ car: AutobahnCar; t: TranslationFunction }> = ({ car, t }) => {
456
- const tier = car.rating ? TONE_TO_TIER[car.rating] : undefined;
457
- if (tier == null) return null;
458
- const hasMarket =
459
- car.marketLow != null && car.marketAvg != null && car.marketHigh != null && car.marketHigh > car.marketLow;
460
- // same continuous market-position math as PriceMeter's knob, reused as EvalBar's leftPct override.
461
- const leftPct = hasMarket
462
- ? Math.max(4, Math.min(96, ((car.price - car.marketLow!) / (car.marketHigh! - car.marketLow!)) * 100))
463
- : undefined;
464
- const isGood = TIER_KEYS[tier] === 'good';
465
- // each tier shows its own real label now (Top/Guter/Fairer/Erhöht/Hoher Preis) — no more
466
- // collapsing 'good' onto the "Top-Preis" claim. Pill styling (colour/class/footnote) unchanged.
467
- const tierLabel = t('autobahn:tier.' + car.rating);
468
- // 'good' collapses onto the 'top' tier's own color too (#168a45), matching the fixed
469
- // "Top-Preis" text above rather than tier 1's lighter TIER_COLORS[1] green.
470
- const pillColor = isGood ? TIER_COLORS[0] : TIER_COLORS[tier];
471
- return (
472
- <div className="fin-eval-col">
473
- <div className="fin-eval-pill-cell">
474
- <span
475
- className={`fin-eval-pill${isGood ? ' fin-eval-pill--good' : ''}`}
476
- style={{ color: pillColor, background: `color-mix(in srgb, ${pillColor} 16%, transparent)` }}
477
- aria-label={t('autobahn:finance.priceRatingAria', { rating: tierLabel })}
478
- >
479
- {tierLabel}
480
- {isGood && <sup>4</sup>}
481
- </span>
482
- </div>
483
- <div className="fin-eval-bar-cell">
484
- <EvalBar tier={tier} leftPct={leftPct} />
485
- </div>
486
- </div>
487
- );
488
- };
489
-
490
- export type PaymentMode = 'financing' | 'leasing' | 'buy';
491
-
492
- /** The tab a card opens on: the requested one (default Finanzierung), but never Leasing for a car
493
- * without a lease rate — PriceTabs has no Leasing tab for it. */
494
- export const startPaymentMode = (car: AutobahnCar, requested?: PaymentMode): PaymentMode =>
495
- requested === 'leasing' && car.lease == null ? 'financing' : requested || 'financing';
496
-
497
- export interface PriceTabsProps {
498
- car: AutobahnCar;
499
- mode: PaymentMode;
500
- onModeChange: (mode: PaymentMode) => void;
501
- t: TranslationFunction;
502
- /** extra class appended to the root (e.g. the SRP card's mobile-only `show-mobile` marker). */
503
- className?: string;
504
- }
505
-
506
- /**
507
- * Finanzierung / Leasing / Kaufen tab row — reuses the exact `.fin-tabs`/`.fin-tab` classes
508
- * the VDP's FinanceCalculator already renders (md3.css), so the card's tabs are visually
509
- * identical to the VDP's, not a second tab style. Leasing tab omitted when the car isn't
510
- * leasing-eligible (car.lease undefined) — same rule PricePaths already used.
511
- */
512
- export const PriceTabs: React.FunctionComponent<PriceTabsProps> = ({ car, mode, onModeChange, t, className }) => {
513
- const tabs: Array<[PaymentMode, string]> = [
514
- ['financing', t('autobahn:finance.mode.financing')],
515
- ...(car.lease != null ? ([['leasing', t('autobahn:finance.mode.leasing')]] as Array<[PaymentMode, string]>) : []),
516
- ['buy', t('autobahn:card.price.buy')],
517
- ];
518
- return (
519
- <div className={'fin-tabs' + (className ? ' ' + className : '')} role="tablist" onClick={(e) => e.stopPropagation()}>
520
- {tabs.map(([m, label]) => (
521
- <button
522
- key={m}
523
- type="button"
524
- role="tab"
525
- aria-selected={mode === m}
526
- className={'fin-tab' + (mode === m ? ' on' : '')}
527
- onClick={() => onModeChange(m)}
528
- >
529
- {label}
530
- </button>
531
- ))}
532
- </div>
533
- );
534
- };
535
-
536
- export interface PriceHeroProps {
537
- car: AutobahnCar;
538
- mode: PaymentMode;
539
- t: TranslationFunction;
540
- /** opt-in: render the "/mtl." unit next to the rate even without a struck old price to caption
541
- * (default false keeps every existing caller's behavior — the unit only ever showed alongside
542
- * the UVP-Rate/old-price group). The SRP desktop card wants the unit on every financing/leasing
543
- * rate, discounted or not. */
544
- alwaysShowUnit?: boolean;
545
- }
546
-
547
- /** footnote badge + click-to-open popover, shared by the Finanzierung/Leasing "UVP-Rate" (³) and
548
- * Kaufen "Hersteller-UVP" (²) captions on the hero price — same circle/popover, different digit
549
- * and body copy. */
550
- const UvpBadge: React.FunctionComponent<{
551
- n: number;
552
- open: boolean;
553
- onToggle: () => void;
554
- onClose: () => void;
555
- body: string;
556
- closeLabel: string;
557
- }> = ({ n, open, onToggle, onClose, body, closeLabel }) => (
558
- <>
559
- <span
560
- className="pp-eyebrow-badge"
561
- role="button"
562
- tabIndex={0}
563
- onClick={(e) => {
564
- e.stopPropagation();
565
- onToggle();
566
- }}
567
- >
568
- {n}
569
- </span>
570
- {open && (
571
- <div className="pp-uvp-tooltip" onClick={(e) => e.stopPropagation()}>
572
- <button
573
- type="button"
574
- className="pp-uvp-tooltip-close"
575
- aria-label={closeLabel}
576
- onClick={(e) => {
577
- e.stopPropagation();
578
- onClose();
579
- }}
580
- >
581
- <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
582
- <path d="M5 5L15 15M15 5L5 15" stroke="white" strokeWidth={2.4} strokeLinecap="round" />
583
- </svg>
584
- </button>
585
- <div className="pp-uvp-tooltip-body">{body}</div>
586
- </div>
587
- )}
588
- </>
589
- );
590
-
591
- /**
592
- * Hero price for the active tab — Finanzierung/Leasing show a monthly rate ("z.B. … €/mtl.")
593
- * with its own real struck-through old rate (getFinancing/getLeasing `oldMonthlyInstallment`,
594
- * same isStrikeShown gate as everywhere else); Kaufen shows the flat purchase price struck
595
- * against the real list price (car.listPrice, already used elsewhere on the card). The
596
- * superscript footnote markers (¹ price, ² struck reference, ³ "/mtl.") match the Figma card —
597
- * their legal text lives in the page's own footnote block, not duplicated per-card.
598
- */
599
- export const PriceHero: React.FunctionComponent<PriceHeroProps> = ({ car, mode, t, alwaysShowUnit }) => {
600
- const [uvpTooltipOpen, setUvpTooltipOpen] = useState(false);
601
- const isMoney = mode === 'buy';
602
- const value = mode === 'financing' ? car.monthly : mode === 'leasing' ? (car.lease as number) : car.price;
603
- const oldValue = mode === 'financing' ? car.oldMonthly : mode === 'leasing' ? car.oldLease : car.listPrice;
604
- const showOld = oldValue != null && oldValue > value;
605
- // shrink the 65px hero rate for long values (e.g. 1.234 €) so it doesn't overflow the card —
606
- // same digit-length technique as FinanceCalculator's own fin-rate-hero--len4/--len5/--len6.
607
- const rateDigits = !isMoney ? String(Math.round(value)).length : 0;
608
- const rateLenClass =
609
- rateDigits >= 6 ? ' pp-hero-val--len6' : rateDigits === 5 ? ' pp-hero-val--len5' : rateDigits === 4 ? ' pp-hero-val--len4' : '';
610
- // Kaufen: 6/7-digit purchase prices (e.g. 113.249 € / 1.553.249 €) shrink on desktop only —
611
- // separate from the financing/leasing --len6 above since the desktop Kaufen sizes don't match
612
- // the shared rate-based scale.
613
- const buyDigits = isMoney ? String(Math.round(value)).length : 0;
614
- const buyLen6Class = buyDigits >= 7 ? ' pp-hero-val--buy-len7' : buyDigits === 6 ? ' pp-hero-val--buy-len6' : '';
615
- const oldDigits = showOld ? String(Math.round(oldValue as number)).length : 0;
616
- const oldLenClass = oldDigits === 5 ? ' pp-hero-old--len5' : oldDigits === 4 ? ' pp-hero-old--len4' : '';
617
- // ADV-423: the "UVP" label shrinks together with the struck price it captions
618
- const uvpLenClass = oldDigits === 5 ? ' pp-uvp-label--len5' : oldDigits === 4 ? ' pp-uvp-label--len4' : '';
619
- return (
620
- <div className={'pp-hero' + (isMoney ? ' pp-hero--buy' : '')}>
621
- <div className="pp-hero-rate">
622
- <b className={'num pp-hero-val' + rateLenClass + buyLen6Class}>
623
- {isMoney ? value.toLocaleString('de-DE') : fmtRate(value)} €{isMoney && <sup>1</sup>}
624
- </b>
625
- {/* z.B./old-rate/unit grouped in one stacked column beside the hero figure — mirrors
626
- the VDP finance-calculator's .fin-rate-unit layout (FinanceCalculator.tsx) exactly.
627
- Only shown when there's a real old price to strike through — without a discount the
628
- eyebrow/unit have nothing to caption, so the whole group stays hidden. */}
629
- {!isMoney && showOld && (
630
- <span className="pp-hero-unit-group">
631
- {/* a real (not display:contents) flex-column box, matching .pp-hero-unit-group's own
632
- column layout exactly — so the click target covers the full area INCLUDING the
633
- gap between the two stacked lines, not just their text glyphs (display:contents
634
- has no box of its own there, so clicks in that gap fell through to the card link
635
- behind it instead of opening the tooltip). stopPropagation is required here too —
636
- the whole card (CarCard.tsx) has its own onClick={() => onOpen(car)} navigation,
637
- so without it a click on this block both opened the tooltip AND navigated away. */}
638
- <span
639
- style={{ display: 'flex', flexDirection: 'column' }}
640
- role="button"
641
- tabIndex={0}
642
- onClick={(e) => {
643
- e.stopPropagation();
644
- setUvpTooltipOpen((v) => !v);
645
- }}
646
- >
647
- <span className="pp-eyebrow">
648
- {t('autobahn:card.price.uvpRateLabel')}
649
- <UvpBadge
650
- n={3}
651
- open={uvpTooltipOpen}
652
- onToggle={() => setUvpTooltipOpen((v) => !v)}
653
- onClose={() => setUvpTooltipOpen(false)}
654
- closeLabel={t('autobahn:modal.close')}
655
- body={t(
656
- mode === 'leasing'
657
- ? 'autobahn:card.price.uvpRateTooltipBodyLeasing'
658
- : 'autobahn:card.price.uvpRateTooltipBody',
659
- )}
660
- />
661
- </span>
662
- <span className={'pp-hero-old' + oldLenClass}>{Math.round(oldValue as number).toLocaleString('de-DE')} €</span>
663
- </span>
664
- <span className="pp-hero-unit">{t('autobahn:card.price.perMonth')}</span>
665
- </span>
666
- )}
667
- {/* opt-in (alwaysShowUnit): no discount to caption, so just the plain unit next to the
668
- rate instead of the full UVP-Rate/old-price group — existing callers that don't pass
669
- this prop keep showing nothing here, exactly as before. */}
670
- {!isMoney && !showOld && alwaysShowUnit && <span className="pp-hero-unit">{t('autobahn:card.price.perMonth')}</span>}
671
- {/* Kaufen: no rate/unit to caption, just the real list price struck through — same
672
- car.listPrice already used by DropChip/PpRow. */}
673
- {isMoney && showOld && (
674
- <span className="pp-hero-unit-group">
675
- {/* ADV-423: "UVP" label right before the struck list price, same size as that price
676
- (md3.css); same tooltip toggle as the price itself. */}
677
- <span
678
- className={'pp-uvp-label' + uvpLenClass}
679
- onClick={(e) => {
680
- e.stopPropagation();
681
- setUvpTooltipOpen((v) => !v);
682
- }}
683
- >
684
- {t('autobahn:finance.uvp')}
685
- </span>
686
- <span
687
- className={'pp-hero-old' + oldLenClass}
688
- role="button"
689
- tabIndex={0}
690
- onClick={(e) => {
691
- e.stopPropagation();
692
- setUvpTooltipOpen((v) => !v);
693
- }}
694
- >
695
- {Math.round(oldValue as number).toLocaleString('de-DE')} €
696
- <UvpBadge
697
- n={2}
698
- open={uvpTooltipOpen}
699
- onToggle={() => setUvpTooltipOpen((v) => !v)}
700
- onClose={() => setUvpTooltipOpen(false)}
701
- closeLabel={t('autobahn:modal.close')}
702
- body={t('autobahn:card.price.uvpListTooltipBody')}
703
- />
704
- </span>
705
- </span>
706
- )}
707
- </div>
708
- </div>
709
- );
710
- };
711
-
712
- /**
713
- * Financing/leasing terms line ("0 € Anzahlung · 48 Monate Laufzeit" / "0 € Sonderzahlung ·
714
- * 48 Mon. · 10.000 km/Jahr") + a "Finanzierungsdetails"/"Details" link, full-width under the
715
- * price/rating row — same real per-car (falling back to the default config) figures as
716
- * PricePaths' own terms line, just also wired to the page's rate-adjust sheet. Renders nothing
717
- * for the Kaufen tab (a cash purchase has no financing terms) or when neither a terms line nor
718
- * a details link end up with anything real to show.
719
- */
720
- export const PriceTerms: React.FunctionComponent<{
721
- car: AutobahnCar;
722
- mode: PaymentMode;
723
- onOpenRateAdjust?: (mode: PaymentMode) => void;
724
- /** takes over the "Finanzierungsdetails"/"Details" link's click (e.g. navigate to the VDP and
725
- * open the finance modal already expanded, scrolled to the breakdown) — when given, it wins
726
- * over onOpenRateAdjust for THIS link only; the mobile CTA row's own "Rate anpassen" button
727
- * keeps using onOpenRateAdjust regardless. */
728
- onShowDetails?: () => void;
729
- t: TranslationFunction;
730
- }> = ({ car, mode, onOpenRateAdjust, onShowDetails, t }) => {
731
- // Kaufen (buy): a cash purchase has no financing terms/details link — used to `return null`
732
- // here, which collapsed .cc-terms to 0 height on that tab while Financing/Leasing rendered a
733
- // real line, jumping the price row (and everything below it: rating pill, CTA row) up/down on
734
- // every tab switch. Render an empty, still-present .cc-terms div instead — same fix as the VDP
735
- // FinanceCalculator's .fin-cond (md3.css), which reserves its line's height the same way.
736
- if (mode === 'buy') return <div className="cc-terms" />;
737
- const finFirstInstallment =
738
- car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
739
- const finMonths = car.finMonths ?? _finMonths;
740
- const leasFirstInstallment =
741
- car.leaseFirstInstallment != null ? car.leaseFirstInstallment.toLocaleString('de-DE') : _leasFirstInstallment;
742
- const leasMileage = car.leaseMileage ?? _leasMileage;
743
- const leasMonths = car.leaseMonths ?? _leasPeriod;
744
- const hasLeasTerms = Boolean(leasMileage && leasMonths);
745
- const leasMileageStr = leasMileage ? Number(leasMileage).toLocaleString('de-DE') : '';
746
- const termsText =
747
- mode === 'leasing'
748
- ? hasLeasTerms
749
- ? t('autobahn:card.price.leaseTerms', { firstInstallment: leasFirstInstallment, months: leasMonths, mileage: leasMileageStr })
750
- : ''
751
- : t('autobahn:card.price.financeTerms', { firstInstallment: finFirstInstallment, months: finMonths, count: finMonths });
752
- if (!termsText && !onOpenRateAdjust && !onShowDetails) return null;
753
- const detailsLabel = mode === 'leasing' ? t('autobahn:card.price.detailsLink') : t('autobahn:modal.financingDetails');
754
- // split on the translation's own ' · ' separator so the dot can be styled lighter than the
755
- // two figures around it (same literal separator convention as FinanceCalculator's condParts).
756
- const termsParts = termsText ? termsText.split(' · ') : [];
757
- return (
758
- <div className="cc-terms">
759
- {termsParts.map((part, i) => (
760
- <React.Fragment key={i}>
761
- {i > 0 && <span className="cc-terms-dot"> · </span>}
762
- {part}
763
- </React.Fragment>
764
- ))}
765
- {(onOpenRateAdjust || onShowDetails) && (
766
- <>
767
- {termsText && <span className="cc-terms-dot"> · </span>}
768
- <button
769
- type="button"
770
- className="cc-terms-link"
771
- onClick={(e) => {
772
- e.stopPropagation();
773
- if (onShowDetails) onShowDetails();
774
- else onOpenRateAdjust!(mode);
775
- }}
776
- >
777
- {detailsLabel}
778
- </button>
779
- </>
780
- )}
781
- </div>
782
- );
783
- };
784
-
785
- // Same real sales number VehicleDetailedNextPage.tsx (VDP) already dials via its own onCall —
786
- // duplicated here (not imported) because that page doesn't export it; both should eventually
787
- // read from one shared constant.
788
- export const DEALER_SALES_PHONE = '0800 40 30 182';
789
-
790
- /** default onCall — dials the real sales number directly, same tel: pattern VDP uses. */
791
- export function callDealerSalesPhone(): void {
792
- if (typeof window !== 'undefined') window.location.href = `tel:${DEALER_SALES_PHONE.replace(/\s/g, '')}`;
793
- }
794
-
795
- export interface CardCtaRowProps {
796
- car: AutobahnCar;
797
- /** which payment tab is currently active on the card — forwarded to onOpenRateAdjust so the
798
- * sheet opens on the SAME tab the user was looking at (the tab itself is CarCard-internal
799
- * state, so this is the only way the page learns it). */
800
- mode: PaymentMode;
801
- /** primary CTA — mirrors FinanceCalculator's onSecure ("Angebot anfragen"). */
802
- onRequestOffer: () => void;
803
- /** phone CTA — mirrors FinanceCalculator's onCall. */
804
- onCall: () => void;
805
- /**
806
- * opens the SAME "Rate anpassen" bottom-sheet FinanceDetailsModal already used on VDP mobile
807
- * (VdpModules.tsx) — the page mounts one shared modal instance and passes this car's data,
808
- * this button never builds its own sheet.
809
- */
810
- onOpenRateAdjust: (mode: PaymentMode) => void;
811
- t: TranslationFunction;
812
- }
813
-
814
- /**
815
- * Mobile-only 3-button CTA row (Figma: Angebot anfragen / phone / Rate anpassen). Desktop card
816
- * has no CTA row at all (confirmed: mobile-only, per explicit user correction). "Rate anpassen"
817
- * keeps its text label — only the phone button is icon-only, matching the mockup.
818
- */
819
- export const CardCtaRow: React.FunctionComponent<CardCtaRowProps> = ({ car, mode, onRequestOffer, onCall, onOpenRateAdjust, t }) => (
820
- <div
821
- className="card-cta-row show-mobile"
822
- style={{ display: 'flex', gap: 6, borderTop: '1px solid var(--md-outline-variant)', paddingTop: 8 }}
823
- >
824
- <Button
825
- variant="filled"
826
- style={{
827
- // Figma width (157px) as a STARTING size, not a hard fixed one — flex-grow:1 so this
828
- // button (and "Adjust rate" below) still fill extra row width on wider cards instead of
829
- // leaving dead space next to the fixed 40px phone button; flex-shrink:1 lets it narrow
830
- // gracefully (text ellipsizes via the existing .card-cta-row .mbtn overflow rule) rather
831
- // than overflow on very narrow cards.
832
- flex: '1 1 157px',
833
- height: 40,
834
- background: '#005cff',
835
- borderRadius: 16,
836
- padding: '0 8px',
837
- fontFamily: 'Arial, Arimo, sans-serif',
838
- fontStyle: 'normal',
839
- fontWeight: 700,
840
- fontSize: 13,
841
- lineHeight: '15px',
842
- color: '#ffffff',
843
- }}
844
- onClick={(e) => {
845
- e.stopPropagation();
846
- onRequestOffer();
847
- }}
848
- >
849
- {/* exact design icon (single self-contained SVG) — replaces the composed lucide
850
- file-text + check-circle badge (DocCheckIcon), which is still used as-is on VDP's own
851
- "Angebot anfragen" buttons; this swap is scoped to the search-card CTA only.
852
- flex:none for the same shrink reason as the "Adjust rate" icon above. */}
853
- <svg width="26" height="26" viewBox="0 0 26 26" fill="none" xmlns="http://www.w3.org/2000/svg" style={{ flex: 'none' }}>
854
- <path
855
- d="M6.90625 3.65625H15.275L19.9062 8.2875V20.7188C19.9062 21.6162 19.1787 22.3438 18.2812 22.3438H6.90625C6.00879 22.3438 5.28125 21.6162 5.28125 20.7188V5.28125C5.28125 4.38379 6.00879 3.65625 6.90625 3.65625Z"
856
- stroke="white"
857
- strokeLinecap="round"
858
- strokeLinejoin="round"
859
- />
860
- <path d="M15.0312 3.85938V8.53125H19.7031" stroke="white" strokeLinecap="round" strokeLinejoin="round" />
861
- <path d="M8.9375 11.375H14.625" stroke="white" strokeLinecap="round" />
862
- <path d="M8.9375 14.625H13.4062" stroke="white" strokeLinecap="round" />
863
- <path d="M8.9375 17.875H12.5938" stroke="white" strokeLinecap="round" />
864
- <path
865
- d="M18.4844 23.1562C20.8402 23.1562 22.75 21.2465 22.75 18.8906C22.75 16.5348 20.8402 14.625 18.4844 14.625C16.1285 14.625 14.2188 16.5348 14.2188 18.8906C14.2188 21.2465 16.1285 23.1562 18.4844 23.1562Z"
866
- fill="#005CFF"
867
- stroke="white"
868
- />
869
- <path d="M17.0625 18.3219L18.5656 19.825L23.7656 14.625" stroke="white" strokeLinecap="round" strokeLinejoin="round" />
870
- <path d="M21.6533 17.875L23.2783 16.25" stroke="#005CFF" strokeLinecap="round" strokeLinejoin="round" />
871
- <path d="M20.1904 17.0625L21.8154 15.4375" stroke="#005CFF" strokeLinecap="round" strokeLinejoin="round" />
872
- </svg>
873
- {t('autobahn:finance.secureOffer')}
874
- </Button>
875
- <Button
876
- variant="outlined"
877
- style={{
878
- flex: '0 0 auto',
879
- width: 40,
880
- height: 40,
881
- background: '#ffffff',
882
- border: '1.6px solid #005cff',
883
- borderRadius: 16,
884
- padding: 0,
885
- }}
886
- onClick={(e) => {
887
- e.stopPropagation();
888
- onCall();
889
- }}
890
- >
891
- {/* exact design icon (not lucide's "phone") — no class="lucide", so the
892
- .card-cta-row .mbtn .lucide 15px override doesn't touch it; the rect-clip from the
893
- source SVG was a full-viewBox no-op (already inside 0-20/0-20) and dropped, since a
894
- static clipPath id would collide across the many CarCard instances on one search page. */}
895
- <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
896
- <path
897
- d="M18.3332 14.1004V16.6004C18.3341 16.8325 18.2866 17.0622 18.1936 17.2749C18.1006 17.4875 17.9643 17.6784 17.7933 17.8353C17.6222 17.9922 17.4203 18.1116 17.2005 18.186C16.9806 18.2603 16.7477 18.288 16.5165 18.2671C13.9523 17.9881 11.4892 17.1119 9.32486 15.7087C7.31139 14.4293 5.60431 12.7222 4.32486 10.7087C2.91679 8.5346 2.04037 6.0595 1.76653 3.48374C1.7457 3.2533 1.77309 3.02104 1.84695 2.80176C1.9208 2.58248 2.03951 2.38098 2.1955 2.21009C2.3515 2.0392 2.54137 1.90266 2.75302 1.80917C2.96468 1.71569 3.19348 1.66729 3.42486 1.66707H5.92486C6.32928 1.66309 6.72136 1.80631 7.028 2.07002C7.33464 2.33373 7.53493 2.69995 7.59153 3.10041C7.69153 3.85041 7.86653 4.57541 8.11653 5.26707C8.22865 5.56534 8.25291 5.8895 8.18645 6.20114C8.11999 6.51278 7.96558 6.79883 7.74153 7.02541L6.74153 8.03374C7.95617 10.2329 9.76739 12.0441 11.9665 13.2587L12.9749 12.2587C13.2014 12.0347 13.4875 11.8803 13.7991 11.8138C14.1108 11.7474 14.4349 11.7716 14.7332 11.8837C15.4249 12.1337 16.1499 12.3087 16.8999 12.4087C17.3047 12.4658 17.6744 12.6697 17.9386 12.9817C18.2029 13.2936 18.3433 13.6917 18.3332 14.1004Z"
898
- stroke="#005cff"
899
- strokeWidth={1.66667}
900
- strokeLinecap="round"
901
- strokeLinejoin="round"
902
- />
903
- </svg>
904
- </Button>
905
- <Button
906
- variant="outlined"
907
- style={{
908
- // same "starting size that can still grow/shrink" reasoning as "Request offer" above.
909
- flex: '1 1 125px',
910
- height: 40,
911
- background: '#ffffff',
912
- border: '1.6px solid #5b6b7f',
913
- borderRadius: 16,
914
- padding: '0 6px',
915
- fontFamily: 'Arial, Arimo, sans-serif',
916
- fontStyle: 'normal',
917
- fontWeight: 700,
918
- fontSize: 13,
919
- lineHeight: '15px',
920
- color: '#5b6b7f',
921
- }}
922
- onClick={(e) => {
923
- e.stopPropagation();
924
- onOpenRateAdjust(mode);
925
- }}
926
- >
927
- {/* exact design icon (not lucide's "sliders-horizontal") — colors are baked into the SVG
928
- itself (matches the button's #5b6b7f border/text), not currentColor. flex:none is
929
- load-bearing: this button is a flex row (icon + the "Adjust rate" label) inside a fixed
930
- 125px width, and without it the icon was a shrinkable flex item — flexbox squeezed its
931
- WIDTH down to fit the text (rendering ~12.94x18, squashed) while its literal height
932
- attribute stayed 18. Lucide icons here dodge this via the unrelated .card-cta-row .mbtn
933
- .lucide CSS rule (flex: none), which doesn't match a plain <svg> with no lucide class. */}
934
- <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg" style={{ flex: 'none' }}>
935
- <path d="M3 5.25H15" stroke="#5B6B7F" strokeWidth={1.91667} strokeLinecap="round" strokeLinejoin="round" />
936
- <path
937
- d="M6 6.75C6.82843 6.75 7.5 6.07843 7.5 5.25C7.5 4.42157 6.82843 3.75 6 3.75C5.17157 3.75 4.5 4.42157 4.5 5.25C4.5 6.07843 5.17157 6.75 6 6.75Z"
938
- fill="#FFFEFE"
939
- stroke="#5B6B7F"
940
- strokeLinecap="round"
941
- strokeLinejoin="round"
942
- />
943
- <path d="M3 9H15" stroke="#5B6B7F" strokeWidth={1.91667} strokeLinecap="round" strokeLinejoin="round" />
944
- <path
945
- d="M12.4565 10.5C13.285 10.5 13.9565 9.82843 13.9565 9C13.9565 8.17157 13.285 7.5 12.4565 7.5C11.6281 7.5 10.9565 8.17157 10.9565 9C10.9565 9.82843 11.6281 10.5 12.4565 10.5Z"
946
- fill="white"
947
- stroke="#5B6B7F"
948
- strokeLinecap="round"
949
- strokeLinejoin="round"
950
- />
951
- <path d="M3 12.75H15" stroke="#5B6B7F" strokeWidth={1.91667} strokeLinecap="round" strokeLinejoin="round" />
952
- <path
953
- d="M9.81543 14.25C10.6439 14.25 11.3154 13.5784 11.3154 12.75C11.3154 11.9216 10.6439 11.25 9.81543 11.25C8.987 11.25 8.31543 11.9216 8.31543 12.75C8.31543 13.5784 8.987 14.25 9.81543 14.25Z"
954
- fill="white"
955
- stroke="#5B6B7F"
956
- strokeLinecap="round"
957
- strokeLinejoin="round"
958
- />
959
- </svg>
960
- {t('autobahn:finance.adjustRate')}
961
- </Button>
962
- </div>
963
- );
964
-
965
- export interface GalleryCounterProps {
966
- /** 1-based index of the currently shown photo. */
967
- current: number;
968
- total: number;
969
- /** Figma "Vehicle Gallery / Photos Button" light-pill treatment (Car Card, node 281:1016) —
970
- * CarRow keeps the original dark `.imglabel` pill until it gets the same design pass. */
971
- light?: boolean;
972
- /** makes the light pill a real button (opens the full VdpViewer lightbox on the grid card) —
973
- * the dark `.imglabel` variant stays a plain, non-interactive span either way. */
974
- onClick?: () => void;
975
- }
976
-
977
- /**
978
- * Bottom-left gallery overlay: expand icon + "current|total" (Figma). Reuses the existing
979
- * `.imglabel` pill style (already used for the list-card's photo-count badge) rather than a new
980
- * class — same dark translucent pill, just with the maximize icon instead of the image icon.
981
- *
982
- * States (shared policy across GalleryCounter, the carousel's own arrows/dots in CardCarousel,
983
- * and GalleryActivityPill below — see its own doc comment for the other two):
984
- * - single-image: `total` is the car's REAL, eagerly-known photo count (car.photos, from the
985
- * search payload — not the lazily-loaded gallery array length), so this is accurate even
986
- * before any image beyond the first has actually loaded. total<=1 → hidden: nothing to expand
987
- * into. Never a "1|1" placeholder.
988
- * - loading: while `total` itself is still unknown (car not yet resolved) the caller simply
989
- * hasn't rendered this component yet — there is no separate in-between skeleton state here.
990
- */
991
- export const GalleryCounter: React.FunctionComponent<GalleryCounterProps> = ({ current, total, light, onClick }) => {
992
- if (total <= 1) return null;
993
- if (light) {
994
- return (
995
- <button type="button" className="cc-photo-pill" onClick={onClick}>
996
- <Icon name="maximize" size={18} stroke={2} color="#111820" />
997
- {current} | {total}
998
- </button>
999
- );
1000
- }
1001
- return (
1002
- <span className="imglabel">
1003
- <Icon name="maximize" size={13} stroke={2} />
1004
- {current}|{total}
1005
- </span>
1006
- );
1007
- };
1008
-
1009
- export interface GalleryActivityPillProps {
1010
- /** total detail-page views (stats totalCarImpCount) — real data only, never fabricated. */
1011
- viewsCount?: number;
1012
- /** total merkliste adds (stats totalFavCount) — real data only, never fabricated. */
1013
- favoritesCount?: number;
1014
- }
1015
-
1016
- /**
1017
- * Bottom-right gallery overlay: eye + views, heart + favorites, in ONE pill (Figma "Push Chips /
1018
- * Likes", node 297:1037). Each half renders independently.
1019
- *
1020
- * States (chosen ONE policy, applied identically to both halves):
1021
- * - loading: `viewsCount`/`favoritesCount` are `undefined` until the async stats call
1022
- * (UserActionsAPI 'stats/viewers') resolves for this car. No skeleton — the half (or the
1023
- * whole pill, if both are still pending) simply doesn't render yet, same "hidden, not a
1024
- * placeholder" discipline as GalleryCounter/CardCarousel's arrows above.
1025
- * - zero-value: a REAL `0` is treated the same as "not there" — hidden, not shown as "👁 0".
1026
- * Deliberate choice over spelling out "0" (the other option the ticket allows): on a dense
1027
- * grid of fresh listings a "👁 0 ❤ 0" pill on every card is noise, not signal. `!viewsCount`/
1028
- * `!favoritesCount` below intentionally don't distinguish real-0 from not-yet-loaded — both
1029
- * read as "nothing worth showing (yet)", which is the same outcome either way.
1030
- */
1031
- export const GalleryActivityPill: React.FunctionComponent<GalleryActivityPillProps> = ({ viewsCount, favoritesCount }) => {
1032
- if (!viewsCount && !favoritesCount) return null;
1033
- return (
1034
- <span className="cc-activity-pill">
1035
- {!!viewsCount && (
1036
- <span className="cc-activity-pill-item">
1037
- <Icon name="eye" size={16} stroke={1.9} color="#1D2A38" />
1038
- {viewsCount}
1039
- </span>
1040
- )}
1041
- {!!favoritesCount && (
1042
- <span className="cc-activity-pill-item">
1043
- <Icon name="heart" size={16} stroke={1.9} color="#1D2A38" />
1044
- {favoritesCount}
1045
- </span>
1046
- )}
1047
- </span>
1048
- );
1049
- };
1050
-
1051
- interface PpRowProps {
1052
- /** payment-path label (Finanzierung / Leasing / Kaufen). */
1053
- label: string;
1054
- /** the figure to show — a monthly rate (money=false) or a full price (money=true). */
1055
- value: number;
1056
- /** small unit before the figure, e.g. 'mtl.'. */
1057
- unit?: string;
1058
- /** real previous price to strike through (only ever the genuine list price). */
1059
- old?: number | null;
1060
- /** the financing row — kept visually dominant (larger). */
1061
- focus?: boolean;
1062
- /** format as a full euro price (Kaufen) instead of a rounded rate. */
1063
- money?: boolean;
1064
- t: TranslationFunction;
1065
- }
1066
-
1067
- /**
1068
- * One payment-path row: label (+ a quiet info marker) on the left, the price right-aligned
1069
- * with an optional struck-through previous price above it. Even row spacing reproduces the
1070
- * production "Finanzierung / Leasing / Kaufen" price table the design references. The struck
1071
- * `old` price gets the same "²" UvpBadge + click-to-open popover as PriceHero's own Kaufen
1072
- * old-price (same n, same body/close copy) — one-to-one, not a re-styled variant.
1073
- */
1074
- const PpRow: React.FunctionComponent<PpRowProps> = ({ label, value, unit, old, focus, money, t }) => {
1075
- const [uvpTooltipOpen, setUvpTooltipOpen] = useState(false);
1076
- // 5-plus-digit prices (e.g. 60.248 €) shrink to keep the row from crowding — 4-digit values
1077
- // stay at the base size. Same digit-length technique as PriceHero's buyLen6Class.
1078
- const valDigits = String(Math.round(value)).length;
1079
- const valLenClass = valDigits >= 5 ? ' pp-val--len5' : '';
1080
- return (
1081
- <div className={'pp-row' + (focus ? ' pp-row--focus' : '')}>
1082
- <span className="pp-row-label">
1083
- {label}
1084
- <Icon name="info" size={13} stroke={1.9} cls="pp-row-i" />
1085
- </span>
1086
- <span className="pp-row-price">
1087
- {old != null && (
1088
- // ADV-423: "UVP" label for the struck list price (PpRow only renders in the desktop SRL
1089
- // column, and `old` is only ever the Kaufen list price). md3.css places it above the
1090
- // struck amount there — the fixed-width row has no room for it inline.
1091
- <span className="pp-uvp-strike">
1092
- <span
1093
- className="pp-uvp-label"
1094
- onClick={(e) => {
1095
- e.stopPropagation();
1096
- setUvpTooltipOpen((v) => !v);
1097
- }}
1098
- >
1099
- {t('autobahn:finance.uvp')}
1100
- </span>
1101
- <span
1102
- className="pp-old"
1103
- role="button"
1104
- tabIndex={0}
1105
- onClick={(e) => {
1106
- e.stopPropagation();
1107
- setUvpTooltipOpen((v) => !v);
1108
- }}
1109
- >
1110
- {old.toLocaleString('de-DE')} €
1111
- <UvpBadge
1112
- n={2}
1113
- open={uvpTooltipOpen}
1114
- onToggle={() => setUvpTooltipOpen((v) => !v)}
1115
- onClose={() => setUvpTooltipOpen(false)}
1116
- closeLabel={t('autobahn:modal.close')}
1117
- body={t('autobahn:card.price.uvpListTooltipBody')}
1118
- />
1119
- </span>
1120
- </span>
1121
- )}
1122
- <span className="pp-now">
1123
- {unit && <span className="pp-unit">{unit}</span>}
1124
- <b className={'num pp-val' + valLenClass}>
1125
- {money ? value.toLocaleString('de-DE') : fmtRate(value)} €{money && <sup>1</sup>}
1126
- </b>
1127
- </span>
1128
- </span>
1129
- </div>
1130
- );
1131
- };
1132
-
1133
- /**
1134
- * Monthly-rate payment paths (SRP price column, TOP group) — modelled on the legacy design:
1135
- * Finanzierung is the hero (eyebrow + big blue rate + its terms line), which both keeps the
1136
- * financing focus and FILLS the upper gap with real default-config info (Anzahlung · Laufzeit).
1137
- * Leasing follows as a quiet neutral row (with its own terms when the config carries them) and
1138
- * is omitted entirely when leasing isn't active. The Kaufen row is rendered separately
1139
- * (PriceKauf) below a divider so only the financing rate stands out — no wall of blue prices.
1140
- */
1141
- export const PricePaths: React.FunctionComponent<PricePathsProps> = ({ car, t, className, onShowDetails }) => {
1142
- const hasLease = car.lease != null;
1143
- // Terms of the config the displayed rate was actually computed with (per-car:
1144
- // dealer rate + the user's saved localStorage adjustments) — default config
1145
- // terms only when the car doesn't carry its own.
1146
- const finFirstInstallment =
1147
- car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
1148
- const finMonths = car.finMonths ?? _finMonths;
1149
- const leasFirstInstallment =
1150
- car.leaseFirstInstallment != null ? car.leaseFirstInstallment.toLocaleString('de-DE') : _leasFirstInstallment;
1151
- const leasMileage = car.leaseMileage ?? _leasMileage;
1152
- const leasMonths = car.leaseMonths ?? _leasPeriod;
1153
- const hasLeasTerms = Boolean(leasMileage && leasMonths);
1154
- const leasMileageStr = leasMileage ? Number(leasMileage).toLocaleString('de-DE') : '';
1155
- const detailsLink = (mode: PaymentMode): React.ReactNode =>
1156
- onShowDetails ? (
1157
- <button
1158
- type="button"
1159
- className="pp-details-link"
1160
- onClick={(e) => {
1161
- e.stopPropagation();
1162
- onShowDetails(mode);
1163
- }}
1164
- >
1165
- {t('autobahn:card.price.details')}
1166
- </button>
1167
- ) : (
1168
- <span className="pp-details-link">{t('autobahn:card.price.details')}</span>
1169
- );
1170
- return (
1171
- <div className={'pricepaths' + (className ? ' ' + className : '')}>
1172
- <div className="pp-eyebrow">{t('autobahn:card.price.financingFrom')}</div>
1173
- {/* reuses PriceHero's own financing rendering — the exact same stacked "UVP-Rate ⓘ /
1174
- struck price / mtl." group beside the rate that .cc-price and mobile's tab switcher
1175
- already use, so the rate + unit never fight for room in one flat row (the earlier
1176
- hand-rolled version here put them side by side and wrapped for any 4+-digit rate). */}
1177
- <PriceHero car={car} mode="financing" t={t} alwaysShowUnit />
1178
- <div className="pp-hero-terms">
1179
- {t('autobahn:card.price.financeTerms', {
1180
- firstInstallment: finFirstInstallment,
1181
- months: finMonths,
1182
- count: finMonths,
1183
- })}{' '}
1184
- · {detailsLink('financing')}
1185
- </div>
1186
- {/* ADV-405/408/411 Kreditkosten-Hinweis: one per card, under the financing conditions and
1187
- above the Leasing row. Financing is always shown in this column, so it is unconditional. */}
1188
- <CreditCostNotice t={t} size="small" cls="pp-ccn" />
1189
- {hasLease && (
1190
- <div className="pp-lease-row">
1191
- <PpRow label={t('autobahn:card.price.leasing')} value={car.lease as number} unit="mtl." t={t} />
1192
- {hasLeasTerms && (
1193
- <div className="pp-sub-terms">
1194
- {/* dedicated keys (not a rework of leaseTerms) so mobile/VDP's own reviewed
1195
- wording there stays untouched, but includes the same Sonderzahlung figure.
1196
- Split across two lines with an explicit <br/> (column is too narrow for all
1197
- three figures + Details on one line) — forced right after km/Jahr so "36" and
1198
- "Mon." always land on the same line instead of an awkward mid-number wrap. */}
1199
- {t('autobahn:card.price.leaseTermsCompactLine1', {
1200
- firstInstallment: leasFirstInstallment,
1201
- mileage: leasMileageStr,
1202
- })}{' · '}
1203
- <br />
1204
- {t('autobahn:card.price.leaseTermsCompactLine2', { months: leasMonths })}{' '}
1205
- · {detailsLink('leasing')}
1206
- </div>
1207
- )}
1208
- </div>
1209
- )}
1210
- </div>
1211
- );
1212
- };
1213
-
1214
- /**
1215
- * Kaufen (outright purchase) row — the BOTTOM group, separated from the monthly-rate paths by a
1216
- * divider. Quiet/neutral (not blue) and strikes the previous price only on a real list-price
1217
- * saving (never a fabricated "was" price).
1218
- */
1219
- export const PriceKauf: React.FunctionComponent<PricePathsProps> = ({ car, t }) => {
1220
- const showStrike = car.savings != null && car.savings > 600 && car.listPrice != null;
1221
- return (
1222
- <PpRow label={t('autobahn:card.price.buy')} value={car.price} old={showStrike ? (car.listPrice as number) : null} money t={t} />
1223
- );
1224
- };
1225
-
1226
- export interface PpActivityProps {
1227
- car: AutobahnCar;
1228
- t: TranslationFunction;
1229
- }
1230
-
1231
- /**
1232
- * Buyer-activity cue rendered below the CTA in the listing card.
1233
- *
1234
- * NEEDS-DATA: needs watchers + views. When either is missing we show the
1235
- * 'Daten folgt' marker instead of inventing interest figures.
1236
- */
1237
- export const PpActivity: React.FunctionComponent<PpActivityProps> = ({ car, t }) => {
1238
- // No real watcher/view data (no backend yet) → render nothing rather than a "Daten folgt"
1239
- // placeholder that reads as perpetual loading. Wire when UserActionsAPI stats are available.
1240
- if (car.watchers == null || car.views == null) return null;
1241
- const hrs = 1 + (car.views % 6);
1242
- return (
1243
- <div className="pp-activity">
1244
- <Icon name="eye" size={12} stroke={1.9} />
1245
- {t('autobahn:card.activity.watchers', { watchers: car.watchers, hrs, count: car.watchers })}
1246
- </div>
1247
- );
1248
- };
1249
-
1250
- export interface GalleryBadgesProps {
1251
- car: AutobahnCar;
1252
- t: TranslationFunction;
1253
- }
1254
-
1255
- /**
1256
- * Trust/activity badges overlaid on the photo itself, bottom-right (PM reference, 2026-07-10),
1257
- * Figma pill styling (border/radius/height — see .gallery-pill in md3.css). Mirrors the mobile
1258
- * VDP gallery header (availability · views · favorites · Geprüft).
1259
- *
1260
- * Each pill is independent, not all-or-nothing: a missing or zero view/favorite count just omits
1261
- * THAT pill (never shown as "0×") — availability and Geprüft still render on their own terms.
1262
- * .gallery-badges is anchored via `right`, not `left` (md3.css), so however many pills survive
1263
- * they stay stuck to the right edge instead of drifting to wherever the row happens to start.
1264
- */
1265
- export const GalleryBadges: React.FunctionComponent<GalleryBadgesProps> = ({ car, t }) => (
1266
- <div className="gallery-badges">
1267
- {car.availability && (
1268
- <span className="gallery-pill">
1269
- <Icon name="circle-check" size={15} stroke={2} color="var(--md-good)" />
1270
- {car.availability}
1271
- </span>
1272
- )}
1273
- {!!car.viewsCount && (
1274
- <span className="gallery-pill">
1275
- <Icon name="eye" size={15} stroke={1.9} />
1276
- {t('autobahn:card.activity.viewsCount', { count: car.viewsCount })}
1277
- </span>
1278
- )}
1279
- {!!car.favoritesCount && (
1280
- <span className="gallery-pill">
1281
- <Icon name="heart" size={15} stroke={1.9} />
1282
- {t('autobahn:card.activity.favoritesCount', { count: car.favoritesCount })}
1283
- </span>
1284
- )}
1285
- <span className="gallery-pill">
1286
- <Icon name="shield-check" size={15} stroke={1.9} />
1287
- {t('autobahn:card.trust.checked')}
1288
- </span>
1289
- </div>
1290
- );
1
+ // Autobahn (auto.de redesign) — car-card helper parts.
2
+ //
3
+ // Typed React 18 + TS port of the helper components from the design kit
4
+ // (docs/redesign/design-source/ui_kits/website/CarCard.jsx). Pure /
5
+ // presentational: every value comes from the `AutobahnCar` prop, there is no
6
+ // store / API / `window` access. The design kit's `window.CO2_CLASSES` /
7
+ // `window.CO2_COLORS` globals are replaced by the shared autobahn constants.
8
+ //
9
+ // These render correctly only inside a `<div className="md3">` subtree (the
10
+ // `.pricepaths`, `.pp-*`, `.specstrip`, `.imglabel` … classes are scoped there).
11
+ //
12
+ // NEEDS-DATA discipline (the point of the ticket): wherever the design showed a
13
+ // figure we have no real source for, these helpers render the NEEDS_DATA_LABEL
14
+ // ('Daten folgt') marker instead of inventing a number — see PricePaths'
15
+ // market band and PpActivity. DropChip renders nothing when there is no drop.
16
+
17
+ import React, { useState } from 'react';
18
+ import { TranslationFunction } from '../types';
19
+ import { defaultConfig } from '@bytebrand/fe-financing';
20
+
21
+ import { Icon, Button, CreditCostNotice, CreditKeyFigures, hasCreditKeyFigures } from '../ui';
22
+ import type { CreditKeyFiguresData } from '../ui';
23
+ import { EvalBar } from '../vdp/FinanceCalculator';
24
+ import { CO2_CLASSES, CO2_COLORS, TIER_KEYS, TIER_COLORS } from '../constants';
25
+ import { AutobahnCar } from './types';
26
+ // pure, non-React — shared with the Meta AIA marketing-image renderer (a plain Node service).
27
+ export { ratingTone } from '../data/toAutobahnCar';
28
+
29
+ // Default financing/leasing terms shown under the rate (the SRP card has no per-car selector, so
30
+ // these are the same default config the displayed rate is computed with — consistent, not invented).
31
+ const _finCfg = (defaultConfig as any).financing || {};
32
+ const _leasCfg = (defaultConfig as any).leasing || {};
33
+ /** financing terms inputs (rendered via t in PricePaths), e.g. "0 € Anzahlung · 48 Monate Laufzeit". */
34
+ const _finFirstInstallment = (_finCfg.firstInstallment || 0).toLocaleString('de-DE');
35
+ const _finMonths = _finCfg.rawPaybackPeriod || _finCfg.paybackPeriod || 48;
36
+ /** leasing terms fallbacks (used when the car doesn't carry its own), e.g. "10.000 km/Jahr · 48 Monate". */
37
+ const _leasPeriod = _leasCfg.rawPaybackPeriod || _leasCfg.paybackPeriod;
38
+ const _leasMileage = _leasCfg.annualMileage || _leasCfg.mileage;
39
+ const _leasFirstInstallment = (_leasCfg.firstInstallment || 0).toLocaleString('de-DE');
40
+
41
+ /**
42
+ * ADV-405 follow-up (PM 19.11): the car's real financing key figures (Kerndaten) — the same
43
+ * price.financing values the Finanzierungsdetails layer lists (toAutobahnCar). No default-config
44
+ * fallback here: a missing figure is simply omitted by CreditKeyFigures, and with none real the
45
+ * hosts keep their previous conditions line.
46
+ */
47
+ const finKeyFigures = (car: AutobahnCar): CreditKeyFiguresData => ({
48
+ months: car.finMonths,
49
+ netLoan: car.finNetLoan,
50
+ total: car.finTotal,
51
+ nominal: car.finNominal,
52
+ apr: car.finApr,
53
+ finalInstallment: car.finFinal,
54
+ });
55
+
56
+ /** mileage → 'X.XXX km' (de-DE grouping). */
57
+ export function fmtKm(n: number): string {
58
+ return n.toLocaleString('de-DE') + ' km';
59
+ }
60
+
61
+ /**
62
+ * Monthly rate → de-DE integer euro string (e.g. 402.12 → "402"). Rates are shown as whole
63
+ * euros like the legacy card ("271 €"); a raw float printed directly rendered as "402.12 €",
64
+ * which a German reader parses as 402.120 — fixed here with rounding + de-DE grouping.
65
+ */
66
+ export function fmtRate(n: number): string {
67
+ return Math.round(n).toLocaleString('de-DE');
68
+ }
69
+
70
+ /** strip a trailing parenthetical, e.g. '110 kW (150 PS)' → '110 kW'. */
71
+ function stripParen(s: string): string {
72
+ return s.replace(/\s*\(.*\)/, '');
73
+ }
74
+
75
+ /**
76
+ * Opposite of stripParen, for car.power specifically: pull the PS value OUT of the trailing
77
+ * parenthetical instead of discarding it, e.g. '145 kW (197 PS)' → '197 PS' — the card wants
78
+ * PS only, no kW at all. Regex requires the paren to actually contain "N PS" (not just any
79
+ * parenthetical) and falls back to the plain stripParen(kW) result when it doesn't, so a power
80
+ * string without a PS conversion still renders something instead of going blank.
81
+ */
82
+ function extractPS(s: string): string {
83
+ const m = s.match(/\((\d+\s*PS)\)\s*$/i);
84
+ return m ? m[1].replace(/\s+/, ' ') : stripParen(s);
85
+ }
86
+
87
+ // Compact spec for cards: short fuel/gear labels so all five values fit ONE line
88
+ // without clipping.
89
+ const FUEL_SHORT: Record<string, string> = {
90
+ 'Plug-in-Hybrid': 'Hybrid',
91
+ Benzin: 'Benzin',
92
+ Diesel: 'Diesel',
93
+ Elektro: 'Elektro',
94
+ };
95
+ const GEAR_SHORT: Record<string, string> = {
96
+ Automatik: 'Automatik',
97
+ Schaltgetriebe: 'Manuell',
98
+ };
99
+
100
+ /** five compact spec values for the grid card's one-line spec strip. */
101
+ export function cardSpec(car: AutobahnCar): string[] {
102
+ const fuel = stripParen(car.fuel);
103
+ return [
104
+ fmtKm(car.km),
105
+ car.reg,
106
+ extractPS(car.power),
107
+ FUEL_SHORT[fuel] || fuel,
108
+ GEAR_SHORT[car.gear] || car.gear,
109
+ ];
110
+ }
111
+
112
+ export interface SpecLineProps {
113
+ items: string[];
114
+ size?: number;
115
+ /** never wrap — clip overflow with ellipsis (single line). */
116
+ oneLine?: boolean;
117
+ }
118
+
119
+ /** Compact pipe-separated spec line (AutoScout pattern). */
120
+ export const SpecLine: React.FunctionComponent<SpecLineProps> = ({ items, size = 12.5, oneLine = false }) => (
121
+ <div
122
+ className="cc-spec"
123
+ style={{
124
+ display: 'flex',
125
+ flexWrap: oneLine ? 'nowrap' : 'wrap',
126
+ alignItems: 'center',
127
+ gap: '2px 8px',
128
+ fontSize: size,
129
+ color: 'var(--md-on-surface-variant)',
130
+ ...(oneLine ? { overflow: 'hidden', whiteSpace: 'nowrap' } : {}),
131
+ }}
132
+ >
133
+ {items.map((v, i) => (
134
+ <React.Fragment key={i}>
135
+ {i > 0 && <span style={{ color: 'var(--md-outline-variant)', flex: 'none' }}>·</span>}
136
+ <span style={oneLine ? { whiteSpace: 'nowrap' } : undefined}>{v}</span>
137
+ </React.Fragment>
138
+ ))}
139
+ </div>
140
+ );
141
+
142
+ export interface PriceBlockProps {
143
+ car: AutobahnCar;
144
+ align?: 'left' | 'right';
145
+ t: TranslationFunction;
146
+ }
147
+
148
+ /** Price block — rate-first (monthly is the lead), purchase price secondary. */
149
+ export const PriceBlock: React.FunctionComponent<PriceBlockProps> = ({ car, align = 'left', t }) => {
150
+ const showStrike = car.savings != null && car.savings > 600 && car.listPrice != null;
151
+ return (
152
+ <div style={{ textAlign: align }}>
153
+ <div
154
+ style={{
155
+ display: 'flex',
156
+ alignItems: 'baseline',
157
+ gap: 5,
158
+ justifyContent: align === 'right' ? 'flex-end' : 'flex-start',
159
+ }}
160
+ >
161
+ <span
162
+ className="num"
163
+ style={{
164
+ fontWeight: 700,
165
+ fontSize: 26,
166
+ color: 'var(--md-primary)',
167
+ letterSpacing: '-.6px',
168
+ whiteSpace: 'nowrap',
169
+ }}
170
+ >
171
+ {fmtRate(car.monthly)} €
172
+ </span>
173
+ <span className="md-label-sm">{t('autobahn:card.price.perMonth')}</span>
174
+ </div>
175
+ <div
176
+ className="md-label-sm"
177
+ style={{
178
+ marginTop: 1,
179
+ display: 'flex',
180
+ flexWrap: 'wrap',
181
+ gap: '0 6px',
182
+ justifyContent: align === 'right' ? 'flex-end' : 'flex-start',
183
+ }}
184
+ >
185
+ <span style={{ whiteSpace: 'nowrap' }}>
186
+ {t('autobahn:card.price.purchasePrice')}{' '}
187
+ <b style={{ color: 'var(--md-on-surface)' }}>{car.price.toLocaleString('de-DE')} €</b>
188
+ </span>
189
+ {showStrike && (
190
+ <span
191
+ style={{
192
+ color: 'var(--md-on-surface-variant)',
193
+ textDecoration: 'line-through',
194
+ whiteSpace: 'nowrap',
195
+ }}
196
+ >
197
+ {car.listPrice!.toLocaleString('de-DE')} €
198
+ </span>
199
+ )}
200
+ </div>
201
+ </div>
202
+ );
203
+ };
204
+
205
+ export interface DropChipProps {
206
+ /** real price reduction in EUR; when undefined the chip renders nothing. */
207
+ amount?: number;
208
+ t: TranslationFunction;
209
+ }
210
+
211
+ /**
212
+ * Price-drop chip — a REAL reduction on this car. White pill so it doesn't
213
+ * compete with the solid green rating chip. Renders nothing when there is no
214
+ * drop (we never fabricate a reduction).
215
+ */
216
+ export const DropChip: React.FunctionComponent<DropChipProps> = ({ amount, t }) => {
217
+ if (amount == null) {
218
+ return null;
219
+ }
220
+ return (
221
+ <span
222
+ className="deal-chip deal-chip--drop"
223
+ style={{
224
+ display: 'inline-flex',
225
+ alignItems: 'center',
226
+ gap: 3,
227
+ height: 22,
228
+ padding: '0 8px',
229
+ borderRadius: 'var(--md-r-full)',
230
+ background: 'rgba(255,255,255,.94)',
231
+ color: 'var(--md-good)',
232
+ fontSize: 10.5,
233
+ fontWeight: 700,
234
+ lineHeight: '14px',
235
+ boxShadow: 'var(--md-e1)',
236
+ whiteSpace: 'nowrap',
237
+ }}
238
+ >
239
+ <Icon name="trending-down" size={12} stroke={2.4} color="var(--md-good)" />
240
+ {t('autobahn:card.price.priceDropAmount', { amount: amount.toLocaleString('de-DE') })}
241
+ </span>
242
+ );
243
+ };
244
+
245
+ /** shared deal-badge pill style (NEU/drop/percent/zero-down all share the same compact shape). */
246
+ const dealPill: React.CSSProperties = {
247
+ display: 'inline-flex',
248
+ alignItems: 'center',
249
+ height: 22,
250
+ padding: '0 8px',
251
+ borderRadius: 'var(--md-r-full)',
252
+ fontSize: 10.5,
253
+ fontWeight: 700,
254
+ boxShadow: 'var(--md-e1)',
255
+ whiteSpace: 'nowrap',
256
+ };
257
+
258
+ /** Percent price-drop chip (−X%). Red pill — pairs with DropChip. Renders nothing without a real pct. */
259
+ export const PercentChip: React.FunctionComponent<{ pct?: number }> = ({ pct }) => {
260
+ if (pct == null || pct <= 0) return null;
261
+ return (
262
+ <span className="deal-chip deal-chip--percent" style={{ ...dealPill, background: 'var(--md-error)', color: '#fff', lineHeight: '14px' }}>
263
+ −{pct}%
264
+ </span>
265
+ );
266
+ };
267
+
268
+ /**
269
+ * Zero-down-payment chip (offer.showDownPayment). Cyan pill. Spells out "0 € Anzahlung" where
270
+ * there is room (grid cards / wide image) and uses the compact "0 € Anz." on the narrow list-card
271
+ * image, so the badge row always stays on ONE line on both desktop and mobile.
272
+ */
273
+ export const ZeroDownChip: React.FunctionComponent<{
274
+ show?: boolean;
275
+ compact?: boolean;
276
+ t: TranslationFunction;
277
+ className?: string;
278
+ /** overrides the default pill look (e.g. the desktop "mcard" full-text badge's own blue tint/size
279
+ * from the Figma export) — merged last so it wins over the shared dealPill defaults below. */
280
+ style?: React.CSSProperties;
281
+ }> = ({ show, compact, t, className, style }) => {
282
+ if (!show) return null;
283
+ return (
284
+ <span
285
+ className={className}
286
+ style={{ ...dealPill, background: 'var(--md-accent-container)', color: 'var(--md-on-accent-container)', ...style }}
287
+ >
288
+ {compact ? t('autobahn:card.price.zeroDownCompact') : t('autobahn:card.price.zeroDown')}
289
+ </span>
290
+ );
291
+ };
292
+
293
+ /**
294
+ * "⚡ Angebot" gray badge — NOT a separate backend flag (none exists yet). Shown whenever the
295
+ * card already carries a real deal signal (NEU / price drop / meaningful savings / 0€ Anzahlung
296
+ * / percent drop) — i.e. it labels the same real discount the other badges point at, rather
297
+ * than inventing a new "is this an offer" field. Revisit if/when a dedicated flag exists.
298
+ */
299
+ export const OfferBadge: React.FunctionComponent<{ show: boolean; t: TranslationFunction }> = ({ show, t }) => {
300
+ if (!show) return null;
301
+ return (
302
+ <span className="offer-badge">
303
+ <Icon name="zap" size={13} stroke={2.2} />
304
+ {t('autobahn:card.badge.offer')}
305
+ </span>
306
+ );
307
+ };
308
+
309
+ interface InlineClsProps {
310
+ /** CO₂ class letter, e.g. 'B'. */
311
+ c: string;
312
+ }
313
+
314
+ /** Small inline colored CO₂-class letter (keeps EnVKV line a fixed height). */
315
+ const InlineCls: React.FunctionComponent<InlineClsProps> = ({ c }) => {
316
+ const i = Math.max(0, CO2_CLASSES.indexOf(c as (typeof CO2_CLASSES)[number]));
317
+ const color = CO2_COLORS[i] || 'var(--md-outline)';
318
+ return (
319
+ <span
320
+ style={{
321
+ display: 'inline-flex',
322
+ width: 14,
323
+ height: 14,
324
+ borderRadius: 3,
325
+ background: color,
326
+ color: '#fff',
327
+ fontSize: 9.5,
328
+ fontWeight: 800,
329
+ alignItems: 'center',
330
+ justifyContent: 'center',
331
+ verticalAlign: '-2px',
332
+ margin: '0 1px',
333
+ }}
334
+ >
335
+ {c}
336
+ </span>
337
+ );
338
+ };
339
+
340
+ export interface EcoLineProps {
341
+ car: AutobahnCar;
342
+ style?: React.CSSProperties;
343
+ t: TranslationFunction;
344
+ }
345
+
346
+ /**
347
+ * Pkw-EnVKV legal line — full consumption + CO₂ + class. REQUIRED on every
348
+ * German car ad and must stay visible. Quiet fine-print footnote with a fixed
349
+ * min-height so all cards stay the same height. Handles the PHEV dual-figure
350
+ * variant when a `phev` block is present.
351
+ */
352
+ export const EcoLine: React.FunctionComponent<EcoLineProps> = ({ car, style, t }) => {
353
+ const wrap: React.CSSProperties = {
354
+ borderTop: '1px solid var(--md-outline-variant)',
355
+ paddingTop: 8,
356
+ minHeight: 41,
357
+ fontSize: 11,
358
+ lineHeight: 1.5,
359
+ color: 'var(--md-on-surface-variant)',
360
+ ...style,
361
+ };
362
+ if (car.phev) {
363
+ const p = car.phev;
364
+ return (
365
+ <div className="eco-line" style={wrap}>
366
+ {p.consEl}{' '}
367
+ {t('autobahn:card.eco.phevConsumptionLine', {
368
+ consFuel: p.consFuel,
369
+ consDis: p.consDis,
370
+ co2w: p.co2w,
371
+ co2classW: p.co2classW,
372
+ co2classD: p.co2classD,
373
+ })}
374
+ </div>
375
+ );
376
+ }
377
+ return (
378
+ <div className="eco-line" style={wrap}>
379
+ {t('autobahn:card.eco.consumptionLine', { cons: car.cons, co2: car.co2, co2class: car.co2class })}
380
+ </div>
381
+ );
382
+ };
383
+
384
+ export interface SeoLineProps {
385
+ car: AutobahnCar;
386
+ style?: React.CSSProperties;
387
+ }
388
+
389
+ /**
390
+ * Full spec + equipment footer line (fuel, category, gearbox, colour, condition, drive
391
+ * type, then every equipment highlight) — the small gray text under the card's CTA row,
392
+ * same field/format as the legacy VehicleSmallCard's SeoText. Renders nothing without
393
+ * `car.seoText` (needs-data: only fe-landing currently populates it).
394
+ */
395
+ export const SeoLine: React.FunctionComponent<SeoLineProps> = ({ car, style }) => {
396
+ if (!car.seoText) return null;
397
+ return (
398
+ <div
399
+ style={{
400
+ fontSize: 10,
401
+ lineHeight: '14px',
402
+ color: 'var(--md-on-surface-variant)',
403
+ maxHeight: 42,
404
+ overflow: 'hidden',
405
+ ...style,
406
+ }}
407
+ >
408
+ {car.seoText}
409
+ </div>
410
+ );
411
+ };
412
+
413
+ export interface PricePathsProps {
414
+ car: AutobahnCar;
415
+ t: TranslationFunction;
416
+ /** extra class appended to the root (e.g. the SRP card's desktop-only `hide-mobile` marker). */
417
+ className?: string;
418
+ /** takes over the financing/leasing terms rows' own "Details" links — e.g. navigate to this
419
+ * car's VDP and open its finance modal already expanded, on the tab the link was under
420
+ * (financing/leasing). Optional/page-owned like CarCard's onShowFinancingDetails; when
421
+ * omitted the links render as plain (non-interactive) text, same as before this prop existed. */
422
+ onShowDetails?: (mode: PaymentMode) => void;
423
+ }
424
+
425
+ /** Map the AutobahnCar rating tone → meter segment index (0 best … 4 worst). */
426
+ const TONE_TO_TIER: Record<string, number> = { top: 0, good: 1, fair: 2, raised: 3, high: 4 };
427
+
428
+ /**
429
+ * Discrete Preisbewertung tier bar + thumb (Figma: 5 solid segments — green/light-green/yellow/
430
+ * orange/red — with a white circular marker at the car's position, same `.fin-eval-bar`/
431
+ * `.fin-eval-seg` segmented treatment the grid CarCard's PriceEvalCol/EvalBar already uses; no
432
+ * text label here since the tier is already named by the StatChip pill next to the price).
433
+ * Renders nothing when there is no rating/band (needs-data: we never draw a fake market position).
434
+ */
435
+ export const PriceMeter: React.FunctionComponent<{ car: AutobahnCar; t: TranslationFunction }> = ({ car }) => {
436
+ const hasMarket =
437
+ car.marketLow != null && car.marketAvg != null && car.marketHigh != null && car.marketHigh > car.marketLow;
438
+ const bar = (tier: number) => {
439
+ const leftPct = Math.max(4, Math.min(96, (tier / 4) * 100));
440
+ const tierIndex = Math.max(0, Math.min(4, Math.round(tier)));
441
+ return (
442
+ <div className="fin-eval-bar">
443
+ {TIER_COLORS.map((c, i) => (
444
+ <span key={i} className="fin-eval-seg" style={{ background: c }} />
445
+ ))}
446
+ <div
447
+ className={`fin-eval-thumb${TIER_KEYS[tierIndex] === 'good' ? ' fin-eval-thumb--good' : ''}`}
448
+ style={{ left: `${leftPct}%`, borderColor: TIER_COLORS[tierIndex] }}
449
+ />
450
+ </div>
451
+ );
452
+ };
453
+ if (hasMarket) {
454
+ const mpos = Math.max(0, Math.min(1, (car.price - car.marketLow!) / (car.marketHigh! - car.marketLow!)));
455
+ return bar(mpos * 4);
456
+ }
457
+ if (car.rating && TONE_TO_TIER[car.rating] != null) {
458
+ // No market BAND yet, but the real Preisbewertung tier (same signal as the rating chip)
459
+ // drives the thumb position. Real data, not faked.
460
+ return bar(TONE_TO_TIER[car.rating]);
461
+ }
462
+ return null;
463
+ };
464
+
465
+ /**
466
+ * Preisbewertung pill + segmented tier bar, grouped in one column exactly like the VDP
467
+ * finance-calculator's mobile .fin-eval-col (FinanceCalculator.tsx/EvalBar) — the grid card's
468
+ * replacement for the old StatChip pill + full-width gradient .pp-bar pairing. Renders nothing
469
+ * without a rating (needs-data: never invent a tier).
470
+ */
471
+ export const PriceEvalCol: React.FunctionComponent<{ car: AutobahnCar; t: TranslationFunction }> = ({ car, t }) => {
472
+ const tier = car.rating ? TONE_TO_TIER[car.rating] : undefined;
473
+ if (tier == null) return null;
474
+ const hasMarket =
475
+ car.marketLow != null && car.marketAvg != null && car.marketHigh != null && car.marketHigh > car.marketLow;
476
+ // same continuous market-position math as PriceMeter's knob, reused as EvalBar's leftPct override.
477
+ const leftPct = hasMarket
478
+ ? Math.max(4, Math.min(96, ((car.price - car.marketLow!) / (car.marketHigh! - car.marketLow!)) * 100))
479
+ : undefined;
480
+ const isGood = TIER_KEYS[tier] === 'good';
481
+ // each tier shows its own real label now (Top/Guter/Fairer/Erhöht/Hoher Preis) — no more
482
+ // collapsing 'good' onto the "Top-Preis" claim. Pill styling (colour/class/footnote) unchanged.
483
+ const tierLabel = t('autobahn:tier.' + car.rating);
484
+ // 'good' collapses onto the 'top' tier's own color too (#168a45), matching the fixed
485
+ // "Top-Preis" text above rather than tier 1's lighter TIER_COLORS[1] green.
486
+ const pillColor = isGood ? TIER_COLORS[0] : TIER_COLORS[tier];
487
+ return (
488
+ <div className="fin-eval-col">
489
+ <div className="fin-eval-pill-cell">
490
+ <span
491
+ className={`fin-eval-pill${isGood ? ' fin-eval-pill--good' : ''}`}
492
+ style={{ color: pillColor, background: `color-mix(in srgb, ${pillColor} 16%, transparent)` }}
493
+ aria-label={t('autobahn:finance.priceRatingAria', { rating: tierLabel })}
494
+ >
495
+ {tierLabel}
496
+ {isGood && <sup>4</sup>}
497
+ </span>
498
+ </div>
499
+ <div className="fin-eval-bar-cell">
500
+ <EvalBar tier={tier} leftPct={leftPct} />
501
+ </div>
502
+ </div>
503
+ );
504
+ };
505
+
506
+ export type PaymentMode = 'financing' | 'leasing' | 'buy';
507
+
508
+ /** The tab a card opens on: the requested one (default Finanzierung), but never Leasing for a car
509
+ * without a lease rate — PriceTabs has no Leasing tab for it. */
510
+ export const startPaymentMode = (car: AutobahnCar, requested?: PaymentMode): PaymentMode =>
511
+ requested === 'leasing' && car.lease == null ? 'financing' : requested || 'financing';
512
+
513
+ export interface PriceTabsProps {
514
+ car: AutobahnCar;
515
+ mode: PaymentMode;
516
+ onModeChange: (mode: PaymentMode) => void;
517
+ t: TranslationFunction;
518
+ /** extra class appended to the root (e.g. the SRP card's mobile-only `show-mobile` marker). */
519
+ className?: string;
520
+ }
521
+
522
+ /**
523
+ * Finanzierung / Leasing / Kaufen tab row — reuses the exact `.fin-tabs`/`.fin-tab` classes
524
+ * the VDP's FinanceCalculator already renders (md3.css), so the card's tabs are visually
525
+ * identical to the VDP's, not a second tab style. Leasing tab omitted when the car isn't
526
+ * leasing-eligible (car.lease undefined) — same rule PricePaths already used.
527
+ */
528
+ export const PriceTabs: React.FunctionComponent<PriceTabsProps> = ({ car, mode, onModeChange, t, className }) => {
529
+ const tabs: Array<[PaymentMode, string]> = [
530
+ ['financing', t('autobahn:finance.mode.financing')],
531
+ ...(car.lease != null ? ([['leasing', t('autobahn:finance.mode.leasing')]] as Array<[PaymentMode, string]>) : []),
532
+ ['buy', t('autobahn:card.price.buy')],
533
+ ];
534
+ return (
535
+ <div className={'fin-tabs' + (className ? ' ' + className : '')} role="tablist" onClick={(e) => e.stopPropagation()}>
536
+ {tabs.map(([m, label]) => (
537
+ <button
538
+ key={m}
539
+ type="button"
540
+ role="tab"
541
+ aria-selected={mode === m}
542
+ className={'fin-tab' + (mode === m ? ' on' : '')}
543
+ onClick={() => onModeChange(m)}
544
+ >
545
+ {label}
546
+ </button>
547
+ ))}
548
+ </div>
549
+ );
550
+ };
551
+
552
+ export interface PriceHeroProps {
553
+ car: AutobahnCar;
554
+ mode: PaymentMode;
555
+ t: TranslationFunction;
556
+ /** opt-in: render the "/mtl." unit next to the rate even without a struck old price to caption
557
+ * (default false keeps every existing caller's behavior — the unit only ever showed alongside
558
+ * the UVP-Rate/old-price group). The SRP desktop card wants the unit on every financing/leasing
559
+ * rate, discounted or not. */
560
+ alwaysShowUnit?: boolean;
561
+ }
562
+
563
+ /** footnote badge + click-to-open popover, shared by the Finanzierung/Leasing "UVP-Rate" (³) and
564
+ * Kaufen "Hersteller-UVP" (²) captions on the hero price — same circle/popover, different digit
565
+ * and body copy. */
566
+ const UvpBadge: React.FunctionComponent<{
567
+ n: number;
568
+ open: boolean;
569
+ onToggle: () => void;
570
+ onClose: () => void;
571
+ body: string;
572
+ closeLabel: string;
573
+ }> = ({ n, open, onToggle, onClose, body, closeLabel }) => (
574
+ <>
575
+ <span
576
+ className="pp-eyebrow-badge"
577
+ role="button"
578
+ tabIndex={0}
579
+ onClick={(e) => {
580
+ e.stopPropagation();
581
+ onToggle();
582
+ }}
583
+ >
584
+ {n}
585
+ </span>
586
+ {open && (
587
+ <div className="pp-uvp-tooltip" onClick={(e) => e.stopPropagation()}>
588
+ <button
589
+ type="button"
590
+ className="pp-uvp-tooltip-close"
591
+ aria-label={closeLabel}
592
+ onClick={(e) => {
593
+ e.stopPropagation();
594
+ onClose();
595
+ }}
596
+ >
597
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
598
+ <path d="M5 5L15 15M15 5L5 15" stroke="white" strokeWidth={2.4} strokeLinecap="round" />
599
+ </svg>
600
+ </button>
601
+ <div className="pp-uvp-tooltip-body">{body}</div>
602
+ </div>
603
+ )}
604
+ </>
605
+ );
606
+
607
+ /**
608
+ * Hero price for the active tab — Finanzierung/Leasing show a monthly rate ("z.B. … €/mtl.")
609
+ * with its own real struck-through old rate (getFinancing/getLeasing `oldMonthlyInstallment`,
610
+ * same isStrikeShown gate as everywhere else); Kaufen shows the flat purchase price struck
611
+ * against the real list price (car.listPrice, already used elsewhere on the card). The
612
+ * superscript footnote markers (¹ price, ² struck reference, ³ "/mtl.") match the Figma card —
613
+ * their legal text lives in the page's own footnote block, not duplicated per-card.
614
+ */
615
+ export const PriceHero: React.FunctionComponent<PriceHeroProps> = ({ car, mode, t, alwaysShowUnit }) => {
616
+ const [uvpTooltipOpen, setUvpTooltipOpen] = useState(false);
617
+ const isMoney = mode === 'buy';
618
+ const value = mode === 'financing' ? car.monthly : mode === 'leasing' ? (car.lease as number) : car.price;
619
+ const oldValue = mode === 'financing' ? car.oldMonthly : mode === 'leasing' ? car.oldLease : car.listPrice;
620
+ const showOld = oldValue != null && oldValue > value;
621
+ // shrink the 65px hero rate for long values (e.g. 1.234 €) so it doesn't overflow the card —
622
+ // same digit-length technique as FinanceCalculator's own fin-rate-hero--len4/--len5/--len6.
623
+ const rateDigits = !isMoney ? String(Math.round(value)).length : 0;
624
+ const rateLenClass =
625
+ rateDigits >= 6 ? ' pp-hero-val--len6' : rateDigits === 5 ? ' pp-hero-val--len5' : rateDigits === 4 ? ' pp-hero-val--len4' : '';
626
+ // Kaufen: 6/7-digit purchase prices (e.g. 113.249 € / 1.553.249 €) shrink on desktop only —
627
+ // separate from the financing/leasing --len6 above since the desktop Kaufen sizes don't match
628
+ // the shared rate-based scale.
629
+ const buyDigits = isMoney ? String(Math.round(value)).length : 0;
630
+ const buyLen6Class = buyDigits >= 7 ? ' pp-hero-val--buy-len7' : buyDigits === 6 ? ' pp-hero-val--buy-len6' : '';
631
+ const oldDigits = showOld ? String(Math.round(oldValue as number)).length : 0;
632
+ const oldLenClass = oldDigits === 5 ? ' pp-hero-old--len5' : oldDigits === 4 ? ' pp-hero-old--len4' : '';
633
+ // ADV-423: the "UVP" label shrinks together with the struck price it captions
634
+ const uvpLenClass = oldDigits === 5 ? ' pp-uvp-label--len5' : oldDigits === 4 ? ' pp-uvp-label--len4' : '';
635
+ return (
636
+ <div className={'pp-hero' + (isMoney ? ' pp-hero--buy' : '')}>
637
+ <div className="pp-hero-rate">
638
+ <b className={'num pp-hero-val' + rateLenClass + buyLen6Class}>
639
+ {isMoney ? value.toLocaleString('de-DE') : fmtRate(value)} €{isMoney && <sup>1</sup>}
640
+ </b>
641
+ {/* z.B./old-rate/unit grouped in one stacked column beside the hero figure — mirrors
642
+ the VDP finance-calculator's .fin-rate-unit layout (FinanceCalculator.tsx) exactly.
643
+ Only shown when there's a real old price to strike through — without a discount the
644
+ eyebrow/unit have nothing to caption, so the whole group stays hidden. */}
645
+ {!isMoney && showOld && (
646
+ <span className="pp-hero-unit-group">
647
+ {/* a real (not display:contents) flex-column box, matching .pp-hero-unit-group's own
648
+ column layout exactly — so the click target covers the full area INCLUDING the
649
+ gap between the two stacked lines, not just their text glyphs (display:contents
650
+ has no box of its own there, so clicks in that gap fell through to the card link
651
+ behind it instead of opening the tooltip). stopPropagation is required here too —
652
+ the whole card (CarCard.tsx) has its own onClick={() => onOpen(car)} navigation,
653
+ so without it a click on this block both opened the tooltip AND navigated away. */}
654
+ <span
655
+ style={{ display: 'flex', flexDirection: 'column' }}
656
+ role="button"
657
+ tabIndex={0}
658
+ onClick={(e) => {
659
+ e.stopPropagation();
660
+ setUvpTooltipOpen((v) => !v);
661
+ }}
662
+ >
663
+ <span className="pp-eyebrow">
664
+ {t('autobahn:card.price.uvpRateLabel')}
665
+ <UvpBadge
666
+ n={3}
667
+ open={uvpTooltipOpen}
668
+ onToggle={() => setUvpTooltipOpen((v) => !v)}
669
+ onClose={() => setUvpTooltipOpen(false)}
670
+ closeLabel={t('autobahn:modal.close')}
671
+ body={t(
672
+ mode === 'leasing'
673
+ ? 'autobahn:card.price.uvpRateTooltipBodyLeasing'
674
+ : 'autobahn:card.price.uvpRateTooltipBody',
675
+ )}
676
+ />
677
+ </span>
678
+ <span className={'pp-hero-old' + oldLenClass}>{Math.round(oldValue as number).toLocaleString('de-DE')} €</span>
679
+ </span>
680
+ <span className="pp-hero-unit">{t('autobahn:card.price.perMonth')}</span>
681
+ </span>
682
+ )}
683
+ {/* opt-in (alwaysShowUnit): no discount to caption, so just the plain unit next to the
684
+ rate instead of the full UVP-Rate/old-price group — existing callers that don't pass
685
+ this prop keep showing nothing here, exactly as before. */}
686
+ {!isMoney && !showOld && alwaysShowUnit && <span className="pp-hero-unit">{t('autobahn:card.price.perMonth')}</span>}
687
+ {/* Kaufen: no rate/unit to caption, just the real list price struck through — same
688
+ car.listPrice already used by DropChip/PpRow. */}
689
+ {isMoney && showOld && (
690
+ <span className="pp-hero-unit-group">
691
+ {/* ADV-423: "UVP" label right before the struck list price, same size as that price
692
+ (md3.css); same tooltip toggle as the price itself. */}
693
+ <span
694
+ className={'pp-uvp-label' + uvpLenClass}
695
+ onClick={(e) => {
696
+ e.stopPropagation();
697
+ setUvpTooltipOpen((v) => !v);
698
+ }}
699
+ >
700
+ {t('autobahn:finance.uvp')}
701
+ </span>
702
+ <span
703
+ className={'pp-hero-old' + oldLenClass}
704
+ role="button"
705
+ tabIndex={0}
706
+ onClick={(e) => {
707
+ e.stopPropagation();
708
+ setUvpTooltipOpen((v) => !v);
709
+ }}
710
+ >
711
+ {Math.round(oldValue as number).toLocaleString('de-DE')} €
712
+ <UvpBadge
713
+ n={2}
714
+ open={uvpTooltipOpen}
715
+ onToggle={() => setUvpTooltipOpen((v) => !v)}
716
+ onClose={() => setUvpTooltipOpen(false)}
717
+ closeLabel={t('autobahn:modal.close')}
718
+ body={t('autobahn:card.price.uvpListTooltipBody')}
719
+ />
720
+ </span>
721
+ </span>
722
+ )}
723
+ </div>
724
+ </div>
725
+ );
726
+ };
727
+
728
+ /**
729
+ * Financing/leasing terms line ("0 € Anzahlung · 48 Monate Laufzeit" / "0 € Sonderzahlung ·
730
+ * 48 Mon. · 10.000 km/Jahr") + a "Finanzierungsdetails"/"Details" link, full-width under the
731
+ * price/rating row — same real per-car (falling back to the default config) figures as
732
+ * PricePaths' own terms line, just also wired to the page's rate-adjust sheet. Renders nothing
733
+ * for the Kaufen tab (a cash purchase has no financing terms) or when neither a terms line nor
734
+ * a details link end up with anything real to show.
735
+ */
736
+ export const PriceTerms: React.FunctionComponent<{
737
+ car: AutobahnCar;
738
+ mode: PaymentMode;
739
+ onOpenRateAdjust?: (mode: PaymentMode) => void;
740
+ /** takes over the "Finanzierungsdetails"/"Details" link's click (e.g. navigate to the VDP and
741
+ * open the finance modal already expanded, scrolled to the breakdown) — when given, it wins
742
+ * over onOpenRateAdjust for THIS link only; the mobile CTA row's own "Rate anpassen" button
743
+ * keeps using onOpenRateAdjust regardless. */
744
+ onShowDetails?: () => void;
745
+ t: TranslationFunction;
746
+ }> = ({ car, mode, onOpenRateAdjust, onShowDetails, t }) => {
747
+ // Kaufen (buy): a cash purchase has no financing terms/details link — used to `return null`
748
+ // here, which collapsed .cc-terms to 0 height on that tab while Financing/Leasing rendered a
749
+ // real line, jumping the price row (and everything below it: rating pill, CTA row) up/down on
750
+ // every tab switch. Render an empty, still-present .cc-terms div instead — same fix as the VDP
751
+ // FinanceCalculator's .fin-cond (md3.css), which reserves its line's height the same way.
752
+ if (mode === 'buy') return <div className="cc-terms" />;
753
+ const finFirstInstallment =
754
+ car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
755
+ const finMonths = car.finMonths ?? _finMonths;
756
+ const leasFirstInstallment =
757
+ car.leaseFirstInstallment != null ? car.leaseFirstInstallment.toLocaleString('de-DE') : _leasFirstInstallment;
758
+ const leasMileage = car.leaseMileage ?? _leasMileage;
759
+ const leasMonths = car.leaseMonths ?? _leasPeriod;
760
+ const hasLeasTerms = Boolean(leasMileage && leasMonths);
761
+ const leasMileageStr = leasMileage ? Number(leasMileage).toLocaleString('de-DE') : '';
762
+ const termsText =
763
+ mode === 'leasing'
764
+ ? hasLeasTerms
765
+ ? t('autobahn:card.price.leaseTerms', { firstInstallment: leasFirstInstallment, months: leasMonths, mileage: leasMileageStr })
766
+ : ''
767
+ : t('autobahn:card.price.financeTerms', { firstInstallment: finFirstInstallment, months: finMonths, count: finMonths });
768
+ if (!termsText && !onOpenRateAdjust && !onShowDetails) return null;
769
+ const detailsLabel = mode === 'leasing' ? t('autobahn:card.price.detailsLink') : t('autobahn:modal.financingDetails');
770
+ const detailsButton =
771
+ onOpenRateAdjust || onShowDetails ? (
772
+ <button
773
+ type="button"
774
+ className="cc-terms-link"
775
+ onClick={(e) => {
776
+ e.stopPropagation();
777
+ if (onShowDetails) onShowDetails();
778
+ else onOpenRateAdjust!(mode);
779
+ }}
780
+ >
781
+ {detailsLabel}
782
+ </button>
783
+ ) : null;
784
+ // ADV-405 follow-up (PM 19.11): on the Finanzierung tab the conditions line under the rate shows
785
+ // the financing key figures instead ("60 Mon. · … Nettokredit · Gesamtbetrag: …" / "… Sollzins
786
+ // fest · … eff. Jahreszins · Finanzierungsdetails"), inside the same .cc-terms so its 12px
787
+ // #0e2238 typography applies; the block grows to 2+ lines (the stack cell takes the tallest
788
+ // slot). Leasing keeps its line; with no real figure the old financing terms line stays.
789
+ const kf = finKeyFigures(car);
790
+ if (mode === 'financing' && hasCreditKeyFigures(kf)) {
791
+ return (
792
+ <div className="cc-terms">
793
+ <CreditKeyFigures t={t} figures={kf} details={detailsButton || undefined} cls="cc-ckf" />
794
+ </div>
795
+ );
796
+ }
797
+ // split on the translation's own ' · ' separator so the dot can be styled lighter than the
798
+ // two figures around it (same literal separator convention as FinanceCalculator's condParts).
799
+ const termsParts = termsText ? termsText.split(' · ') : [];
800
+ return (
801
+ <div className="cc-terms">
802
+ {termsParts.map((part, i) => (
803
+ <React.Fragment key={i}>
804
+ {i > 0 && <span className="cc-terms-dot"> · </span>}
805
+ {part}
806
+ </React.Fragment>
807
+ ))}
808
+ {detailsButton && (
809
+ <>
810
+ {termsText && <span className="cc-terms-dot"> · </span>}
811
+ {detailsButton}
812
+ </>
813
+ )}
814
+ </div>
815
+ );
816
+ };
817
+
818
+ // Same real sales number VehicleDetailedNextPage.tsx (VDP) already dials via its own onCall —
819
+ // duplicated here (not imported) because that page doesn't export it; both should eventually
820
+ // read from one shared constant.
821
+ export const DEALER_SALES_PHONE = '0800 40 30 182';
822
+
823
+ /** default onCall — dials the real sales number directly, same tel: pattern VDP uses. */
824
+ export function callDealerSalesPhone(): void {
825
+ if (typeof window !== 'undefined') window.location.href = `tel:${DEALER_SALES_PHONE.replace(/\s/g, '')}`;
826
+ }
827
+
828
+ export interface CardCtaRowProps {
829
+ car: AutobahnCar;
830
+ /** which payment tab is currently active on the card — forwarded to onOpenRateAdjust so the
831
+ * sheet opens on the SAME tab the user was looking at (the tab itself is CarCard-internal
832
+ * state, so this is the only way the page learns it). */
833
+ mode: PaymentMode;
834
+ /** primary CTA — mirrors FinanceCalculator's onSecure ("Angebot anfragen"). */
835
+ onRequestOffer: () => void;
836
+ /** phone CTA — mirrors FinanceCalculator's onCall. */
837
+ onCall: () => void;
838
+ /**
839
+ * opens the SAME "Rate anpassen" bottom-sheet FinanceDetailsModal already used on VDP mobile
840
+ * (VdpModules.tsx) — the page mounts one shared modal instance and passes this car's data,
841
+ * this button never builds its own sheet.
842
+ */
843
+ onOpenRateAdjust: (mode: PaymentMode) => void;
844
+ t: TranslationFunction;
845
+ }
846
+
847
+ /**
848
+ * Mobile-only 3-button CTA row (Figma: Angebot anfragen / phone / Rate anpassen). Desktop card
849
+ * has no CTA row at all (confirmed: mobile-only, per explicit user correction). "Rate anpassen"
850
+ * keeps its text label — only the phone button is icon-only, matching the mockup.
851
+ */
852
+ export const CardCtaRow: React.FunctionComponent<CardCtaRowProps> = ({ car, mode, onRequestOffer, onCall, onOpenRateAdjust, t }) => (
853
+ <div
854
+ className="card-cta-row show-mobile"
855
+ style={{ display: 'flex', gap: 6, borderTop: '1px solid var(--md-outline-variant)', paddingTop: 8 }}
856
+ >
857
+ <Button
858
+ variant="filled"
859
+ style={{
860
+ // Figma width (157px) as a STARTING size, not a hard fixed one — flex-grow:1 so this
861
+ // button (and "Adjust rate" below) still fill extra row width on wider cards instead of
862
+ // leaving dead space next to the fixed 40px phone button; flex-shrink:1 lets it narrow
863
+ // gracefully (text ellipsizes via the existing .card-cta-row .mbtn overflow rule) rather
864
+ // than overflow on very narrow cards.
865
+ flex: '1 1 157px',
866
+ height: 40,
867
+ background: '#005cff',
868
+ borderRadius: 16,
869
+ padding: '0 8px',
870
+ fontFamily: 'Arial, Arimo, sans-serif',
871
+ fontStyle: 'normal',
872
+ fontWeight: 700,
873
+ fontSize: 13,
874
+ lineHeight: '15px',
875
+ color: '#ffffff',
876
+ }}
877
+ onClick={(e) => {
878
+ e.stopPropagation();
879
+ onRequestOffer();
880
+ }}
881
+ >
882
+ {/* exact design icon (single self-contained SVG) — replaces the composed lucide
883
+ file-text + check-circle badge (DocCheckIcon), which is still used as-is on VDP's own
884
+ "Angebot anfragen" buttons; this swap is scoped to the search-card CTA only.
885
+ flex:none for the same shrink reason as the "Adjust rate" icon above. */}
886
+ <svg width="26" height="26" viewBox="0 0 26 26" fill="none" xmlns="http://www.w3.org/2000/svg" style={{ flex: 'none' }}>
887
+ <path
888
+ d="M6.90625 3.65625H15.275L19.9062 8.2875V20.7188C19.9062 21.6162 19.1787 22.3438 18.2812 22.3438H6.90625C6.00879 22.3438 5.28125 21.6162 5.28125 20.7188V5.28125C5.28125 4.38379 6.00879 3.65625 6.90625 3.65625Z"
889
+ stroke="white"
890
+ strokeLinecap="round"
891
+ strokeLinejoin="round"
892
+ />
893
+ <path d="M15.0312 3.85938V8.53125H19.7031" stroke="white" strokeLinecap="round" strokeLinejoin="round" />
894
+ <path d="M8.9375 11.375H14.625" stroke="white" strokeLinecap="round" />
895
+ <path d="M8.9375 14.625H13.4062" stroke="white" strokeLinecap="round" />
896
+ <path d="M8.9375 17.875H12.5938" stroke="white" strokeLinecap="round" />
897
+ <path
898
+ d="M18.4844 23.1562C20.8402 23.1562 22.75 21.2465 22.75 18.8906C22.75 16.5348 20.8402 14.625 18.4844 14.625C16.1285 14.625 14.2188 16.5348 14.2188 18.8906C14.2188 21.2465 16.1285 23.1562 18.4844 23.1562Z"
899
+ fill="#005CFF"
900
+ stroke="white"
901
+ />
902
+ <path d="M17.0625 18.3219L18.5656 19.825L23.7656 14.625" stroke="white" strokeLinecap="round" strokeLinejoin="round" />
903
+ <path d="M21.6533 17.875L23.2783 16.25" stroke="#005CFF" strokeLinecap="round" strokeLinejoin="round" />
904
+ <path d="M20.1904 17.0625L21.8154 15.4375" stroke="#005CFF" strokeLinecap="round" strokeLinejoin="round" />
905
+ </svg>
906
+ {t('autobahn:finance.secureOffer')}
907
+ </Button>
908
+ <Button
909
+ variant="outlined"
910
+ style={{
911
+ flex: '0 0 auto',
912
+ width: 40,
913
+ height: 40,
914
+ background: '#ffffff',
915
+ border: '1.6px solid #005cff',
916
+ borderRadius: 16,
917
+ padding: 0,
918
+ }}
919
+ onClick={(e) => {
920
+ e.stopPropagation();
921
+ onCall();
922
+ }}
923
+ >
924
+ {/* exact design icon (not lucide's "phone") — no class="lucide", so the
925
+ .card-cta-row .mbtn .lucide 15px override doesn't touch it; the rect-clip from the
926
+ source SVG was a full-viewBox no-op (already inside 0-20/0-20) and dropped, since a
927
+ static clipPath id would collide across the many CarCard instances on one search page. */}
928
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
929
+ <path
930
+ d="M18.3332 14.1004V16.6004C18.3341 16.8325 18.2866 17.0622 18.1936 17.2749C18.1006 17.4875 17.9643 17.6784 17.7933 17.8353C17.6222 17.9922 17.4203 18.1116 17.2005 18.186C16.9806 18.2603 16.7477 18.288 16.5165 18.2671C13.9523 17.9881 11.4892 17.1119 9.32486 15.7087C7.31139 14.4293 5.60431 12.7222 4.32486 10.7087C2.91679 8.5346 2.04037 6.0595 1.76653 3.48374C1.7457 3.2533 1.77309 3.02104 1.84695 2.80176C1.9208 2.58248 2.03951 2.38098 2.1955 2.21009C2.3515 2.0392 2.54137 1.90266 2.75302 1.80917C2.96468 1.71569 3.19348 1.66729 3.42486 1.66707H5.92486C6.32928 1.66309 6.72136 1.80631 7.028 2.07002C7.33464 2.33373 7.53493 2.69995 7.59153 3.10041C7.69153 3.85041 7.86653 4.57541 8.11653 5.26707C8.22865 5.56534 8.25291 5.8895 8.18645 6.20114C8.11999 6.51278 7.96558 6.79883 7.74153 7.02541L6.74153 8.03374C7.95617 10.2329 9.76739 12.0441 11.9665 13.2587L12.9749 12.2587C13.2014 12.0347 13.4875 11.8803 13.7991 11.8138C14.1108 11.7474 14.4349 11.7716 14.7332 11.8837C15.4249 12.1337 16.1499 12.3087 16.8999 12.4087C17.3047 12.4658 17.6744 12.6697 17.9386 12.9817C18.2029 13.2936 18.3433 13.6917 18.3332 14.1004Z"
931
+ stroke="#005cff"
932
+ strokeWidth={1.66667}
933
+ strokeLinecap="round"
934
+ strokeLinejoin="round"
935
+ />
936
+ </svg>
937
+ </Button>
938
+ <Button
939
+ variant="outlined"
940
+ style={{
941
+ // same "starting size that can still grow/shrink" reasoning as "Request offer" above.
942
+ flex: '1 1 125px',
943
+ height: 40,
944
+ background: '#ffffff',
945
+ border: '1.6px solid #5b6b7f',
946
+ borderRadius: 16,
947
+ padding: '0 6px',
948
+ fontFamily: 'Arial, Arimo, sans-serif',
949
+ fontStyle: 'normal',
950
+ fontWeight: 700,
951
+ fontSize: 13,
952
+ lineHeight: '15px',
953
+ color: '#5b6b7f',
954
+ }}
955
+ onClick={(e) => {
956
+ e.stopPropagation();
957
+ onOpenRateAdjust(mode);
958
+ }}
959
+ >
960
+ {/* exact design icon (not lucide's "sliders-horizontal") — colors are baked into the SVG
961
+ itself (matches the button's #5b6b7f border/text), not currentColor. flex:none is
962
+ load-bearing: this button is a flex row (icon + the "Adjust rate" label) inside a fixed
963
+ 125px width, and without it the icon was a shrinkable flex item — flexbox squeezed its
964
+ WIDTH down to fit the text (rendering ~12.94x18, squashed) while its literal height
965
+ attribute stayed 18. Lucide icons here dodge this via the unrelated .card-cta-row .mbtn
966
+ .lucide CSS rule (flex: none), which doesn't match a plain <svg> with no lucide class. */}
967
+ <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg" style={{ flex: 'none' }}>
968
+ <path d="M3 5.25H15" stroke="#5B6B7F" strokeWidth={1.91667} strokeLinecap="round" strokeLinejoin="round" />
969
+ <path
970
+ d="M6 6.75C6.82843 6.75 7.5 6.07843 7.5 5.25C7.5 4.42157 6.82843 3.75 6 3.75C5.17157 3.75 4.5 4.42157 4.5 5.25C4.5 6.07843 5.17157 6.75 6 6.75Z"
971
+ fill="#FFFEFE"
972
+ stroke="#5B6B7F"
973
+ strokeLinecap="round"
974
+ strokeLinejoin="round"
975
+ />
976
+ <path d="M3 9H15" stroke="#5B6B7F" strokeWidth={1.91667} strokeLinecap="round" strokeLinejoin="round" />
977
+ <path
978
+ d="M12.4565 10.5C13.285 10.5 13.9565 9.82843 13.9565 9C13.9565 8.17157 13.285 7.5 12.4565 7.5C11.6281 7.5 10.9565 8.17157 10.9565 9C10.9565 9.82843 11.6281 10.5 12.4565 10.5Z"
979
+ fill="white"
980
+ stroke="#5B6B7F"
981
+ strokeLinecap="round"
982
+ strokeLinejoin="round"
983
+ />
984
+ <path d="M3 12.75H15" stroke="#5B6B7F" strokeWidth={1.91667} strokeLinecap="round" strokeLinejoin="round" />
985
+ <path
986
+ d="M9.81543 14.25C10.6439 14.25 11.3154 13.5784 11.3154 12.75C11.3154 11.9216 10.6439 11.25 9.81543 11.25C8.987 11.25 8.31543 11.9216 8.31543 12.75C8.31543 13.5784 8.987 14.25 9.81543 14.25Z"
987
+ fill="white"
988
+ stroke="#5B6B7F"
989
+ strokeLinecap="round"
990
+ strokeLinejoin="round"
991
+ />
992
+ </svg>
993
+ {t('autobahn:finance.adjustRate')}
994
+ </Button>
995
+ </div>
996
+ );
997
+
998
+ export interface GalleryCounterProps {
999
+ /** 1-based index of the currently shown photo. */
1000
+ current: number;
1001
+ total: number;
1002
+ /** Figma "Vehicle Gallery / Photos Button" light-pill treatment (Car Card, node 281:1016) —
1003
+ * CarRow keeps the original dark `.imglabel` pill until it gets the same design pass. */
1004
+ light?: boolean;
1005
+ /** makes the light pill a real button (opens the full VdpViewer lightbox on the grid card) —
1006
+ * the dark `.imglabel` variant stays a plain, non-interactive span either way. */
1007
+ onClick?: () => void;
1008
+ }
1009
+
1010
+ /**
1011
+ * Bottom-left gallery overlay: expand icon + "current|total" (Figma). Reuses the existing
1012
+ * `.imglabel` pill style (already used for the list-card's photo-count badge) rather than a new
1013
+ * class — same dark translucent pill, just with the maximize icon instead of the image icon.
1014
+ *
1015
+ * States (shared policy across GalleryCounter, the carousel's own arrows/dots in CardCarousel,
1016
+ * and GalleryActivityPill below — see its own doc comment for the other two):
1017
+ * - single-image: `total` is the car's REAL, eagerly-known photo count (car.photos, from the
1018
+ * search payload — not the lazily-loaded gallery array length), so this is accurate even
1019
+ * before any image beyond the first has actually loaded. total<=1 → hidden: nothing to expand
1020
+ * into. Never a "1|1" placeholder.
1021
+ * - loading: while `total` itself is still unknown (car not yet resolved) the caller simply
1022
+ * hasn't rendered this component yet — there is no separate in-between skeleton state here.
1023
+ */
1024
+ export const GalleryCounter: React.FunctionComponent<GalleryCounterProps> = ({ current, total, light, onClick }) => {
1025
+ if (total <= 1) return null;
1026
+ if (light) {
1027
+ return (
1028
+ <button type="button" className="cc-photo-pill" onClick={onClick}>
1029
+ <Icon name="maximize" size={18} stroke={2} color="#111820" />
1030
+ {current} | {total}
1031
+ </button>
1032
+ );
1033
+ }
1034
+ return (
1035
+ <span className="imglabel">
1036
+ <Icon name="maximize" size={13} stroke={2} />
1037
+ {current}|{total}
1038
+ </span>
1039
+ );
1040
+ };
1041
+
1042
+ export interface GalleryActivityPillProps {
1043
+ /** total detail-page views (stats totalCarImpCount) — real data only, never fabricated. */
1044
+ viewsCount?: number;
1045
+ /** total merkliste adds (stats totalFavCount) — real data only, never fabricated. */
1046
+ favoritesCount?: number;
1047
+ }
1048
+
1049
+ /**
1050
+ * Bottom-right gallery overlay: eye + views, heart + favorites, in ONE pill (Figma "Push Chips /
1051
+ * Likes", node 297:1037). Each half renders independently.
1052
+ *
1053
+ * States (chosen ONE policy, applied identically to both halves):
1054
+ * - loading: `viewsCount`/`favoritesCount` are `undefined` until the async stats call
1055
+ * (UserActionsAPI 'stats/viewers') resolves for this car. No skeleton — the half (or the
1056
+ * whole pill, if both are still pending) simply doesn't render yet, same "hidden, not a
1057
+ * placeholder" discipline as GalleryCounter/CardCarousel's arrows above.
1058
+ * - zero-value: a REAL `0` is treated the same as "not there" — hidden, not shown as "👁 0".
1059
+ * Deliberate choice over spelling out "0" (the other option the ticket allows): on a dense
1060
+ * grid of fresh listings a "👁 0 ❤ 0" pill on every card is noise, not signal. `!viewsCount`/
1061
+ * `!favoritesCount` below intentionally don't distinguish real-0 from not-yet-loaded — both
1062
+ * read as "nothing worth showing (yet)", which is the same outcome either way.
1063
+ */
1064
+ export const GalleryActivityPill: React.FunctionComponent<GalleryActivityPillProps> = ({ viewsCount, favoritesCount }) => {
1065
+ if (!viewsCount && !favoritesCount) return null;
1066
+ return (
1067
+ <span className="cc-activity-pill">
1068
+ {!!viewsCount && (
1069
+ <span className="cc-activity-pill-item">
1070
+ <Icon name="eye" size={16} stroke={1.9} color="#1D2A38" />
1071
+ {viewsCount}
1072
+ </span>
1073
+ )}
1074
+ {!!favoritesCount && (
1075
+ <span className="cc-activity-pill-item">
1076
+ <Icon name="heart" size={16} stroke={1.9} color="#1D2A38" />
1077
+ {favoritesCount}
1078
+ </span>
1079
+ )}
1080
+ </span>
1081
+ );
1082
+ };
1083
+
1084
+ interface PpRowProps {
1085
+ /** payment-path label (Finanzierung / Leasing / Kaufen). */
1086
+ label: string;
1087
+ /** the figure to show — a monthly rate (money=false) or a full price (money=true). */
1088
+ value: number;
1089
+ /** small unit before the figure, e.g. 'mtl.'. */
1090
+ unit?: string;
1091
+ /** real previous price to strike through (only ever the genuine list price). */
1092
+ old?: number | null;
1093
+ /** the financing row — kept visually dominant (larger). */
1094
+ focus?: boolean;
1095
+ /** format as a full euro price (Kaufen) instead of a rounded rate. */
1096
+ money?: boolean;
1097
+ t: TranslationFunction;
1098
+ }
1099
+
1100
+ /**
1101
+ * One payment-path row: label (+ a quiet info marker) on the left, the price right-aligned
1102
+ * with an optional struck-through previous price above it. Even row spacing reproduces the
1103
+ * production "Finanzierung / Leasing / Kaufen" price table the design references. The struck
1104
+ * `old` price gets the same "²" UvpBadge + click-to-open popover as PriceHero's own Kaufen
1105
+ * old-price (same n, same body/close copy) — one-to-one, not a re-styled variant.
1106
+ */
1107
+ const PpRow: React.FunctionComponent<PpRowProps> = ({ label, value, unit, old, focus, money, t }) => {
1108
+ const [uvpTooltipOpen, setUvpTooltipOpen] = useState(false);
1109
+ // 5-plus-digit prices (e.g. 60.248 €) shrink to keep the row from crowding — 4-digit values
1110
+ // stay at the base size. Same digit-length technique as PriceHero's buyLen6Class.
1111
+ const valDigits = String(Math.round(value)).length;
1112
+ const valLenClass = valDigits >= 5 ? ' pp-val--len5' : '';
1113
+ return (
1114
+ <div className={'pp-row' + (focus ? ' pp-row--focus' : '')}>
1115
+ <span className="pp-row-label">
1116
+ {label}
1117
+ <Icon name="info" size={13} stroke={1.9} cls="pp-row-i" />
1118
+ </span>
1119
+ <span className="pp-row-price">
1120
+ {old != null && (
1121
+ // ADV-423: "UVP" label for the struck list price (PpRow only renders in the desktop SRL
1122
+ // column, and `old` is only ever the Kaufen list price). md3.css places it above the
1123
+ // struck amount there — the fixed-width row has no room for it inline.
1124
+ <span className="pp-uvp-strike">
1125
+ <span
1126
+ className="pp-uvp-label"
1127
+ onClick={(e) => {
1128
+ e.stopPropagation();
1129
+ setUvpTooltipOpen((v) => !v);
1130
+ }}
1131
+ >
1132
+ {t('autobahn:finance.uvp')}
1133
+ </span>
1134
+ <span
1135
+ className="pp-old"
1136
+ role="button"
1137
+ tabIndex={0}
1138
+ onClick={(e) => {
1139
+ e.stopPropagation();
1140
+ setUvpTooltipOpen((v) => !v);
1141
+ }}
1142
+ >
1143
+ {old.toLocaleString('de-DE')} €
1144
+ <UvpBadge
1145
+ n={2}
1146
+ open={uvpTooltipOpen}
1147
+ onToggle={() => setUvpTooltipOpen((v) => !v)}
1148
+ onClose={() => setUvpTooltipOpen(false)}
1149
+ closeLabel={t('autobahn:modal.close')}
1150
+ body={t('autobahn:card.price.uvpListTooltipBody')}
1151
+ />
1152
+ </span>
1153
+ </span>
1154
+ )}
1155
+ <span className="pp-now">
1156
+ {unit && <span className="pp-unit">{unit}</span>}
1157
+ <b className={'num pp-val' + valLenClass}>
1158
+ {money ? value.toLocaleString('de-DE') : fmtRate(value)} €{money && <sup>1</sup>}
1159
+ </b>
1160
+ </span>
1161
+ </span>
1162
+ </div>
1163
+ );
1164
+ };
1165
+
1166
+ /**
1167
+ * Monthly-rate payment paths (SRP price column, TOP group) — modelled on the legacy design:
1168
+ * Finanzierung is the hero (eyebrow + big blue rate + its terms line), which both keeps the
1169
+ * financing focus and FILLS the upper gap with real default-config info (Anzahlung · Laufzeit).
1170
+ * Leasing follows as a quiet neutral row (with its own terms when the config carries them) and
1171
+ * is omitted entirely when leasing isn't active. The Kaufen row is rendered separately
1172
+ * (PriceKauf) below a divider so only the financing rate stands out — no wall of blue prices.
1173
+ */
1174
+ export const PricePaths: React.FunctionComponent<PricePathsProps> = ({ car, t, className, onShowDetails }) => {
1175
+ const hasLease = car.lease != null;
1176
+ // Terms of the config the displayed rate was actually computed with (per-car:
1177
+ // dealer rate + the user's saved localStorage adjustments) — default config
1178
+ // terms only when the car doesn't carry its own.
1179
+ const finFirstInstallment =
1180
+ car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
1181
+ const finMonths = car.finMonths ?? _finMonths;
1182
+ const finKf = finKeyFigures(car);
1183
+ const leasFirstInstallment =
1184
+ car.leaseFirstInstallment != null ? car.leaseFirstInstallment.toLocaleString('de-DE') : _leasFirstInstallment;
1185
+ const leasMileage = car.leaseMileage ?? _leasMileage;
1186
+ const leasMonths = car.leaseMonths ?? _leasPeriod;
1187
+ const hasLeasTerms = Boolean(leasMileage && leasMonths);
1188
+ const leasMileageStr = leasMileage ? Number(leasMileage).toLocaleString('de-DE') : '';
1189
+ const detailsLink = (mode: PaymentMode): React.ReactNode =>
1190
+ onShowDetails ? (
1191
+ <button
1192
+ type="button"
1193
+ className="pp-details-link"
1194
+ onClick={(e) => {
1195
+ e.stopPropagation();
1196
+ onShowDetails(mode);
1197
+ }}
1198
+ >
1199
+ {t('autobahn:card.price.details')}
1200
+ </button>
1201
+ ) : (
1202
+ <span className="pp-details-link">{t('autobahn:card.price.details')}</span>
1203
+ );
1204
+ return (
1205
+ <div className={'pricepaths' + (className ? ' ' + className : '')}>
1206
+ <div className="pp-eyebrow">{t('autobahn:card.price.financingFrom')}</div>
1207
+ {/* reuses PriceHero's own financing rendering — the exact same stacked "UVP-Rate ⓘ /
1208
+ struck price / mtl." group beside the rate that .cc-price and mobile's tab switcher
1209
+ already use, so the rate + unit never fight for room in one flat row (the earlier
1210
+ hand-rolled version here put them side by side and wrapped for any 4+-digit rate). */}
1211
+ <PriceHero car={car} mode="financing" t={t} alwaysShowUnit />
1212
+ <div className="pp-hero-terms">
1213
+ {/* ADV-405 follow-up (PM 19.11): the financing key figures replace the "Anzahlung ·
1214
+ Laufzeit" terms here (same .pp-hero-terms size/colour, wraps in the narrow column);
1215
+ without any real figure the old terms line stays. Leasing row below unchanged. */}
1216
+ {hasCreditKeyFigures(finKf) ? (
1217
+ <CreditKeyFigures t={t} figures={finKf} details={detailsLink('financing')} cls="pp-ckf" />
1218
+ ) : (
1219
+ <>
1220
+ {t('autobahn:card.price.financeTerms', {
1221
+ firstInstallment: finFirstInstallment,
1222
+ months: finMonths,
1223
+ count: finMonths,
1224
+ })}{' '}
1225
+ · {detailsLink('financing')}
1226
+ </>
1227
+ )}
1228
+ </div>
1229
+ {/* ADV-405/408/411 Kreditkosten-Hinweis: one per card, under the financing conditions and
1230
+ above the Leasing row. Financing is always shown in this column, so it is unconditional. */}
1231
+ <CreditCostNotice t={t} size="small" cls="pp-ccn" />
1232
+ {hasLease && (
1233
+ <div className="pp-lease-row">
1234
+ <PpRow label={t('autobahn:card.price.leasing')} value={car.lease as number} unit="mtl." t={t} />
1235
+ {hasLeasTerms && (
1236
+ <div className="pp-sub-terms">
1237
+ {/* dedicated keys (not a rework of leaseTerms) so mobile/VDP's own reviewed
1238
+ wording there stays untouched, but includes the same Sonderzahlung figure.
1239
+ Split across two lines with an explicit <br/> (column is too narrow for all
1240
+ three figures + Details on one line) — forced right after km/Jahr so "36" and
1241
+ "Mon." always land on the same line instead of an awkward mid-number wrap. */}
1242
+ {t('autobahn:card.price.leaseTermsCompactLine1', {
1243
+ firstInstallment: leasFirstInstallment,
1244
+ mileage: leasMileageStr,
1245
+ })}{' · '}
1246
+ <br />
1247
+ {t('autobahn:card.price.leaseTermsCompactLine2', { months: leasMonths })}{' '}
1248
+ · {detailsLink('leasing')}
1249
+ </div>
1250
+ )}
1251
+ </div>
1252
+ )}
1253
+ </div>
1254
+ );
1255
+ };
1256
+
1257
+ /**
1258
+ * Kaufen (outright purchase) row — the BOTTOM group, separated from the monthly-rate paths by a
1259
+ * divider. Quiet/neutral (not blue) and strikes the previous price only on a real list-price
1260
+ * saving (never a fabricated "was" price).
1261
+ */
1262
+ export const PriceKauf: React.FunctionComponent<PricePathsProps> = ({ car, t }) => {
1263
+ const showStrike = car.savings != null && car.savings > 600 && car.listPrice != null;
1264
+ return (
1265
+ <PpRow label={t('autobahn:card.price.buy')} value={car.price} old={showStrike ? (car.listPrice as number) : null} money t={t} />
1266
+ );
1267
+ };
1268
+
1269
+ export interface PpActivityProps {
1270
+ car: AutobahnCar;
1271
+ t: TranslationFunction;
1272
+ }
1273
+
1274
+ /**
1275
+ * Buyer-activity cue rendered below the CTA in the listing card.
1276
+ *
1277
+ * NEEDS-DATA: needs watchers + views. When either is missing we show the
1278
+ * 'Daten folgt' marker instead of inventing interest figures.
1279
+ */
1280
+ export const PpActivity: React.FunctionComponent<PpActivityProps> = ({ car, t }) => {
1281
+ // No real watcher/view data (no backend yet) → render nothing rather than a "Daten folgt"
1282
+ // placeholder that reads as perpetual loading. Wire when UserActionsAPI stats are available.
1283
+ if (car.watchers == null || car.views == null) return null;
1284
+ const hrs = 1 + (car.views % 6);
1285
+ return (
1286
+ <div className="pp-activity">
1287
+ <Icon name="eye" size={12} stroke={1.9} />
1288
+ {t('autobahn:card.activity.watchers', { watchers: car.watchers, hrs, count: car.watchers })}
1289
+ </div>
1290
+ );
1291
+ };
1292
+
1293
+ export interface GalleryBadgesProps {
1294
+ car: AutobahnCar;
1295
+ t: TranslationFunction;
1296
+ }
1297
+
1298
+ /**
1299
+ * Trust/activity badges overlaid on the photo itself, bottom-right (PM reference, 2026-07-10),
1300
+ * Figma pill styling (border/radius/height — see .gallery-pill in md3.css). Mirrors the mobile
1301
+ * VDP gallery header (availability · views · favorites · Geprüft).
1302
+ *
1303
+ * Each pill is independent, not all-or-nothing: a missing or zero view/favorite count just omits
1304
+ * THAT pill (never shown as "0×") — availability and Geprüft still render on their own terms.
1305
+ * .gallery-badges is anchored via `right`, not `left` (md3.css), so however many pills survive
1306
+ * they stay stuck to the right edge instead of drifting to wherever the row happens to start.
1307
+ */
1308
+ export const GalleryBadges: React.FunctionComponent<GalleryBadgesProps> = ({ car, t }) => (
1309
+ <div className="gallery-badges">
1310
+ {car.availability && (
1311
+ <span className="gallery-pill">
1312
+ <Icon name="circle-check" size={15} stroke={2} color="var(--md-good)" />
1313
+ {car.availability}
1314
+ </span>
1315
+ )}
1316
+ {!!car.viewsCount && (
1317
+ <span className="gallery-pill">
1318
+ <Icon name="eye" size={15} stroke={1.9} />
1319
+ {t('autobahn:card.activity.viewsCount', { count: car.viewsCount })}
1320
+ </span>
1321
+ )}
1322
+ {!!car.favoritesCount && (
1323
+ <span className="gallery-pill">
1324
+ <Icon name="heart" size={15} stroke={1.9} />
1325
+ {t('autobahn:card.activity.favoritesCount', { count: car.favoritesCount })}
1326
+ </span>
1327
+ )}
1328
+ <span className="gallery-pill">
1329
+ <Icon name="shield-check" size={15} stroke={1.9} />
1330
+ {t('autobahn:card.trust.checked')}
1331
+ </span>
1332
+ </div>
1333
+ );