@bytebrand/fe-ui-core-autobahn 1.0.191 → 1.0.193

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,1253 +1,1288 @@
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
- export interface PriceTabsProps {
493
- car: AutobahnCar;
494
- mode: PaymentMode;
495
- onModeChange: (mode: PaymentMode) => void;
496
- t: TranslationFunction;
497
- /** extra class appended to the root (e.g. the SRP card's mobile-only `show-mobile` marker). */
498
- className?: string;
499
- }
500
-
501
- /**
502
- * Finanzierung / Leasing / Kaufen tab row — reuses the exact `.fin-tabs`/`.fin-tab` classes
503
- * the VDP's FinanceCalculator already renders (md3.css), so the card's tabs are visually
504
- * identical to the VDP's, not a second tab style. Leasing tab omitted when the car isn't
505
- * leasing-eligible (car.lease undefined) — same rule PricePaths already used.
506
- */
507
- export const PriceTabs: React.FunctionComponent<PriceTabsProps> = ({ car, mode, onModeChange, t, className }) => {
508
- const tabs: Array<[PaymentMode, string]> = [
509
- ['financing', t('autobahn:finance.mode.financing')],
510
- ...(car.lease != null ? ([['leasing', t('autobahn:finance.mode.leasing')]] as Array<[PaymentMode, string]>) : []),
511
- ['buy', t('autobahn:card.price.buy')],
512
- ];
513
- return (
514
- <div className={'fin-tabs' + (className ? ' ' + className : '')} role="tablist" onClick={(e) => e.stopPropagation()}>
515
- {tabs.map(([m, label]) => (
516
- <button
517
- key={m}
518
- type="button"
519
- role="tab"
520
- aria-selected={mode === m}
521
- className={'fin-tab' + (mode === m ? ' on' : '')}
522
- onClick={() => onModeChange(m)}
523
- >
524
- {label}
525
- </button>
526
- ))}
527
- </div>
528
- );
529
- };
530
-
531
- export interface PriceHeroProps {
532
- car: AutobahnCar;
533
- mode: PaymentMode;
534
- t: TranslationFunction;
535
- /** opt-in: render the "/mtl." unit next to the rate even without a struck old price to caption
536
- * (default false keeps every existing caller's behavior — the unit only ever showed alongside
537
- * the UVP-Rate/old-price group). The SRP desktop card wants the unit on every financing/leasing
538
- * rate, discounted or not. */
539
- alwaysShowUnit?: boolean;
540
- }
541
-
542
- /** footnote badge + click-to-open popover, shared by the Finanzierung/Leasing "UVP-Rate" (³) and
543
- * Kaufen "Hersteller-UVP" (²) captions on the hero price — same circle/popover, different digit
544
- * and body copy. */
545
- const UvpBadge: React.FunctionComponent<{
546
- n: number;
547
- open: boolean;
548
- onToggle: () => void;
549
- onClose: () => void;
550
- body: string;
551
- closeLabel: string;
552
- }> = ({ n, open, onToggle, onClose, body, closeLabel }) => (
553
- <>
554
- <span
555
- className="pp-eyebrow-badge"
556
- role="button"
557
- tabIndex={0}
558
- onClick={(e) => {
559
- e.stopPropagation();
560
- onToggle();
561
- }}
562
- >
563
- {n}
564
- </span>
565
- {open && (
566
- <div className="pp-uvp-tooltip" onClick={(e) => e.stopPropagation()}>
567
- <button
568
- type="button"
569
- className="pp-uvp-tooltip-close"
570
- aria-label={closeLabel}
571
- onClick={(e) => {
572
- e.stopPropagation();
573
- onClose();
574
- }}
575
- >
576
- <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
577
- <path d="M5 5L15 15M15 5L5 15" stroke="white" strokeWidth={2.4} strokeLinecap="round" />
578
- </svg>
579
- </button>
580
- <div className="pp-uvp-tooltip-body">{body}</div>
581
- </div>
582
- )}
583
- </>
584
- );
585
-
586
- /**
587
- * Hero price for the active tab — Finanzierung/Leasing show a monthly rate ("z.B. … €/mtl.")
588
- * with its own real struck-through old rate (getFinancing/getLeasing `oldMonthlyInstallment`,
589
- * same isStrikeShown gate as everywhere else); Kaufen shows the flat purchase price struck
590
- * against the real list price (car.listPrice, already used elsewhere on the card). The
591
- * superscript footnote markers (¹ price, ² struck reference, ³ "/mtl.") match the Figma card —
592
- * their legal text lives in the page's own footnote block, not duplicated per-card.
593
- */
594
- export const PriceHero: React.FunctionComponent<PriceHeroProps> = ({ car, mode, t, alwaysShowUnit }) => {
595
- const [uvpTooltipOpen, setUvpTooltipOpen] = useState(false);
596
- const isMoney = mode === 'buy';
597
- const value = mode === 'financing' ? car.monthly : mode === 'leasing' ? (car.lease as number) : car.price;
598
- const oldValue = mode === 'financing' ? car.oldMonthly : mode === 'leasing' ? car.oldLease : car.listPrice;
599
- const showOld = oldValue != null && oldValue > value;
600
- // shrink the 65px hero rate for long values (e.g. 1.234 €) so it doesn't overflow the card —
601
- // same digit-length technique as FinanceCalculator's own fin-rate-hero--len4/--len5/--len6.
602
- const rateDigits = !isMoney ? String(Math.round(value)).length : 0;
603
- const rateLenClass =
604
- rateDigits >= 6 ? ' pp-hero-val--len6' : rateDigits === 5 ? ' pp-hero-val--len5' : rateDigits === 4 ? ' pp-hero-val--len4' : '';
605
- // Kaufen: 6/7-digit purchase prices (e.g. 113.249 € / 1.553.249 €) shrink on desktop only —
606
- // separate from the financing/leasing --len6 above since the desktop Kaufen sizes don't match
607
- // the shared rate-based scale.
608
- const buyDigits = isMoney ? String(Math.round(value)).length : 0;
609
- const buyLen6Class = buyDigits >= 7 ? ' pp-hero-val--buy-len7' : buyDigits === 6 ? ' pp-hero-val--buy-len6' : '';
610
- const oldDigits = showOld ? String(Math.round(oldValue as number)).length : 0;
611
- const oldLenClass = oldDigits === 5 ? ' pp-hero-old--len5' : oldDigits === 4 ? ' pp-hero-old--len4' : '';
612
- return (
613
- <div className={'pp-hero' + (isMoney ? ' pp-hero--buy' : '')}>
614
- <div className="pp-hero-rate">
615
- <b className={'num pp-hero-val' + rateLenClass + buyLen6Class}>
616
- {isMoney ? value.toLocaleString('de-DE') : fmtRate(value)} €{isMoney && <sup>1</sup>}
617
- </b>
618
- {/* z.B./old-rate/unit grouped in one stacked column beside the hero figure — mirrors
619
- the VDP finance-calculator's .fin-rate-unit layout (FinanceCalculator.tsx) exactly.
620
- Only shown when there's a real old price to strike through — without a discount the
621
- eyebrow/unit have nothing to caption, so the whole group stays hidden. */}
622
- {!isMoney && showOld && (
623
- <span className="pp-hero-unit-group">
624
- {/* a real (not display:contents) flex-column box, matching .pp-hero-unit-group's own
625
- column layout exactly — so the click target covers the full area INCLUDING the
626
- gap between the two stacked lines, not just their text glyphs (display:contents
627
- has no box of its own there, so clicks in that gap fell through to the card link
628
- behind it instead of opening the tooltip). stopPropagation is required here too —
629
- the whole card (CarCard.tsx) has its own onClick={() => onOpen(car)} navigation,
630
- so without it a click on this block both opened the tooltip AND navigated away. */}
631
- <span
632
- style={{ display: 'flex', flexDirection: 'column' }}
633
- role="button"
634
- tabIndex={0}
635
- onClick={(e) => {
636
- e.stopPropagation();
637
- setUvpTooltipOpen((v) => !v);
638
- }}
639
- >
640
- <span className="pp-eyebrow">
641
- {t('autobahn:card.price.uvpRateLabel')}
642
- <UvpBadge
643
- n={3}
644
- open={uvpTooltipOpen}
645
- onToggle={() => setUvpTooltipOpen((v) => !v)}
646
- onClose={() => setUvpTooltipOpen(false)}
647
- closeLabel={t('autobahn:modal.close')}
648
- body={t(
649
- mode === 'leasing'
650
- ? 'autobahn:card.price.uvpRateTooltipBodyLeasing'
651
- : 'autobahn:card.price.uvpRateTooltipBody',
652
- )}
653
- />
654
- </span>
655
- <span className={'pp-hero-old' + oldLenClass}>{Math.round(oldValue as number).toLocaleString('de-DE')} €</span>
656
- </span>
657
- <span className="pp-hero-unit">{t('autobahn:card.price.perMonth')}</span>
658
- </span>
659
- )}
660
- {/* opt-in (alwaysShowUnit): no discount to caption, so just the plain unit next to the
661
- rate instead of the full UVP-Rate/old-price group — existing callers that don't pass
662
- this prop keep showing nothing here, exactly as before. */}
663
- {!isMoney && !showOld && alwaysShowUnit && <span className="pp-hero-unit">{t('autobahn:card.price.perMonth')}</span>}
664
- {/* Kaufen: no rate/unit to caption, just the real list price struck through — same
665
- car.listPrice already used by DropChip/PpRow. */}
666
- {isMoney && showOld && (
667
- <span className="pp-hero-unit-group">
668
- <span
669
- className={'pp-hero-old' + oldLenClass}
670
- role="button"
671
- tabIndex={0}
672
- onClick={(e) => {
673
- e.stopPropagation();
674
- setUvpTooltipOpen((v) => !v);
675
- }}
676
- >
677
- {Math.round(oldValue as number).toLocaleString('de-DE')} €
678
- <UvpBadge
679
- n={2}
680
- open={uvpTooltipOpen}
681
- onToggle={() => setUvpTooltipOpen((v) => !v)}
682
- onClose={() => setUvpTooltipOpen(false)}
683
- closeLabel={t('autobahn:modal.close')}
684
- body={t('autobahn:card.price.uvpListTooltipBody')}
685
- />
686
- </span>
687
- </span>
688
- )}
689
- </div>
690
- </div>
691
- );
692
- };
693
-
694
- /**
695
- * Financing/leasing terms line ("0 € Anzahlung · 48 Monate Laufzeit" / "0 € Sonderzahlung ·
696
- * 48 Mon. · 10.000 km/Jahr") + a "Finanzierungsdetails"/"Details" link, full-width under the
697
- * price/rating row — same real per-car (falling back to the default config) figures as
698
- * PricePaths' own terms line, just also wired to the page's rate-adjust sheet. Renders nothing
699
- * for the Kaufen tab (a cash purchase has no financing terms) or when neither a terms line nor
700
- * a details link end up with anything real to show.
701
- */
702
- export const PriceTerms: React.FunctionComponent<{
703
- car: AutobahnCar;
704
- mode: PaymentMode;
705
- onOpenRateAdjust?: (mode: PaymentMode) => void;
706
- /** takes over the "Finanzierungsdetails"/"Details" link's click (e.g. navigate to the VDP and
707
- * open the finance modal already expanded, scrolled to the breakdown) — when given, it wins
708
- * over onOpenRateAdjust for THIS link only; the mobile CTA row's own "Rate anpassen" button
709
- * keeps using onOpenRateAdjust regardless. */
710
- onShowDetails?: () => void;
711
- t: TranslationFunction;
712
- }> = ({ car, mode, onOpenRateAdjust, onShowDetails, t }) => {
713
- if (mode === 'buy') return null;
714
- const finFirstInstallment =
715
- car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
716
- const finMonths = car.finMonths ?? _finMonths;
717
- const leasFirstInstallment =
718
- car.leaseFirstInstallment != null ? car.leaseFirstInstallment.toLocaleString('de-DE') : _leasFirstInstallment;
719
- const leasMileage = car.leaseMileage ?? _leasMileage;
720
- const leasMonths = car.leaseMonths ?? _leasPeriod;
721
- const hasLeasTerms = Boolean(leasMileage && leasMonths);
722
- const leasMileageStr = leasMileage ? Number(leasMileage).toLocaleString('de-DE') : '';
723
- const termsText =
724
- mode === 'leasing'
725
- ? hasLeasTerms
726
- ? t('autobahn:card.price.leaseTerms', { firstInstallment: leasFirstInstallment, months: leasMonths, mileage: leasMileageStr })
727
- : ''
728
- : t('autobahn:card.price.financeTerms', { firstInstallment: finFirstInstallment, months: finMonths, count: finMonths });
729
- if (!termsText && !onOpenRateAdjust && !onShowDetails) return null;
730
- const detailsLabel = mode === 'leasing' ? t('autobahn:card.price.detailsLink') : t('autobahn:modal.financingDetails');
731
- // split on the translation's own ' · ' separator so the dot can be styled lighter than the
732
- // two figures around it (same literal separator convention as FinanceCalculator's condParts).
733
- const termsParts = termsText ? termsText.split(' · ') : [];
734
- return (
735
- <div className="cc-terms">
736
- {termsParts.map((part, i) => (
737
- <React.Fragment key={i}>
738
- {i > 0 && <span className="cc-terms-dot"> · </span>}
739
- {part}
740
- </React.Fragment>
741
- ))}
742
- {(onOpenRateAdjust || onShowDetails) && (
743
- <>
744
- {termsText && <span className="cc-terms-dot"> · </span>}
745
- <button
746
- type="button"
747
- className="cc-terms-link"
748
- onClick={(e) => {
749
- e.stopPropagation();
750
- if (onShowDetails) onShowDetails();
751
- else onOpenRateAdjust!(mode);
752
- }}
753
- >
754
- {detailsLabel}
755
- </button>
756
- </>
757
- )}
758
- </div>
759
- );
760
- };
761
-
762
- // Same real sales number VehicleDetailedNextPage.tsx (VDP) already dials via its own onCall —
763
- // duplicated here (not imported) because that page doesn't export it; both should eventually
764
- // read from one shared constant.
765
- export const DEALER_SALES_PHONE = '0800 40 30 182';
766
-
767
- /** default onCall — dials the real sales number directly, same tel: pattern VDP uses. */
768
- export function callDealerSalesPhone(): void {
769
- if (typeof window !== 'undefined') window.location.href = `tel:${DEALER_SALES_PHONE.replace(/\s/g, '')}`;
770
- }
771
-
772
- export interface CardCtaRowProps {
773
- car: AutobahnCar;
774
- /** which payment tab is currently active on the card — forwarded to onOpenRateAdjust so the
775
- * sheet opens on the SAME tab the user was looking at (the tab itself is CarCard-internal
776
- * state, so this is the only way the page learns it). */
777
- mode: PaymentMode;
778
- /** primary CTA — mirrors FinanceCalculator's onSecure ("Angebot anfragen"). */
779
- onRequestOffer: () => void;
780
- /** phone CTA — mirrors FinanceCalculator's onCall. */
781
- onCall: () => void;
782
- /**
783
- * opens the SAME "Rate anpassen" bottom-sheet FinanceDetailsModal already used on VDP mobile
784
- * (VdpModules.tsx) — the page mounts one shared modal instance and passes this car's data,
785
- * this button never builds its own sheet.
786
- */
787
- onOpenRateAdjust: (mode: PaymentMode) => void;
788
- t: TranslationFunction;
789
- }
790
-
791
- /**
792
- * Mobile-only 3-button CTA row (Figma: Angebot anfragen / phone / Rate anpassen). Desktop card
793
- * has no CTA row at all (confirmed: mobile-only, per explicit user correction). "Rate anpassen"
794
- * keeps its text label — only the phone button is icon-only, matching the mockup.
795
- */
796
- export const CardCtaRow: React.FunctionComponent<CardCtaRowProps> = ({ car, mode, onRequestOffer, onCall, onOpenRateAdjust, t }) => (
797
- <div
798
- className="card-cta-row show-mobile"
799
- style={{ display: 'flex', gap: 6, borderTop: '1px solid var(--md-outline-variant)', paddingTop: 8 }}
800
- >
801
- <Button
802
- variant="filled"
803
- style={{
804
- // Figma width (157px) as a STARTING size, not a hard fixed one — flex-grow:1 so this
805
- // button (and "Adjust rate" below) still fill extra row width on wider cards instead of
806
- // leaving dead space next to the fixed 40px phone button; flex-shrink:1 lets it narrow
807
- // gracefully (text ellipsizes via the existing .card-cta-row .mbtn overflow rule) rather
808
- // than overflow on very narrow cards.
809
- flex: '1 1 157px',
810
- height: 40,
811
- background: '#005cff',
812
- borderRadius: 16,
813
- padding: '0 8px',
814
- fontFamily: 'Arial, Arimo, sans-serif',
815
- fontStyle: 'normal',
816
- fontWeight: 700,
817
- fontSize: 13,
818
- lineHeight: '15px',
819
- color: '#ffffff',
820
- }}
821
- onClick={(e) => {
822
- e.stopPropagation();
823
- onRequestOffer();
824
- }}
825
- >
826
- {/* exact design icon (single self-contained SVG) — replaces the composed lucide
827
- file-text + check-circle badge (DocCheckIcon), which is still used as-is on VDP's own
828
- "Angebot anfragen" buttons; this swap is scoped to the search-card CTA only.
829
- flex:none for the same shrink reason as the "Adjust rate" icon above. */}
830
- <svg width="26" height="26" viewBox="0 0 26 26" fill="none" xmlns="http://www.w3.org/2000/svg" style={{ flex: 'none' }}>
831
- <path
832
- 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"
833
- stroke="white"
834
- strokeLinecap="round"
835
- strokeLinejoin="round"
836
- />
837
- <path d="M15.0312 3.85938V8.53125H19.7031" stroke="white" strokeLinecap="round" strokeLinejoin="round" />
838
- <path d="M8.9375 11.375H14.625" stroke="white" strokeLinecap="round" />
839
- <path d="M8.9375 14.625H13.4062" stroke="white" strokeLinecap="round" />
840
- <path d="M8.9375 17.875H12.5938" stroke="white" strokeLinecap="round" />
841
- <path
842
- 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"
843
- fill="#005CFF"
844
- stroke="white"
845
- />
846
- <path d="M17.0625 18.3219L18.5656 19.825L23.7656 14.625" stroke="white" strokeLinecap="round" strokeLinejoin="round" />
847
- <path d="M21.6533 17.875L23.2783 16.25" stroke="#005CFF" strokeLinecap="round" strokeLinejoin="round" />
848
- <path d="M20.1904 17.0625L21.8154 15.4375" stroke="#005CFF" strokeLinecap="round" strokeLinejoin="round" />
849
- </svg>
850
- {t('autobahn:finance.secureOffer')}
851
- </Button>
852
- <Button
853
- variant="outlined"
854
- style={{
855
- flex: '0 0 auto',
856
- width: 40,
857
- height: 40,
858
- background: '#ffffff',
859
- border: '1.6px solid #005cff',
860
- borderRadius: 16,
861
- padding: 0,
862
- }}
863
- onClick={(e) => {
864
- e.stopPropagation();
865
- onCall();
866
- }}
867
- >
868
- {/* exact design icon (not lucide's "phone") — no class="lucide", so the
869
- .card-cta-row .mbtn .lucide 15px override doesn't touch it; the rect-clip from the
870
- source SVG was a full-viewBox no-op (already inside 0-20/0-20) and dropped, since a
871
- static clipPath id would collide across the many CarCard instances on one search page. */}
872
- <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
873
- <path
874
- 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"
875
- stroke="#005cff"
876
- strokeWidth={1.66667}
877
- strokeLinecap="round"
878
- strokeLinejoin="round"
879
- />
880
- </svg>
881
- </Button>
882
- <Button
883
- variant="outlined"
884
- style={{
885
- // same "starting size that can still grow/shrink" reasoning as "Request offer" above.
886
- flex: '1 1 125px',
887
- height: 40,
888
- background: '#ffffff',
889
- border: '1.6px solid #5b6b7f',
890
- borderRadius: 16,
891
- padding: '0 6px',
892
- fontFamily: 'Arial, Arimo, sans-serif',
893
- fontStyle: 'normal',
894
- fontWeight: 700,
895
- fontSize: 13,
896
- lineHeight: '15px',
897
- color: '#5b6b7f',
898
- }}
899
- onClick={(e) => {
900
- e.stopPropagation();
901
- onOpenRateAdjust(mode);
902
- }}
903
- >
904
- {/* exact design icon (not lucide's "sliders-horizontal") — colors are baked into the SVG
905
- itself (matches the button's #5b6b7f border/text), not currentColor. flex:none is
906
- load-bearing: this button is a flex row (icon + the "Adjust rate" label) inside a fixed
907
- 125px width, and without it the icon was a shrinkable flex item — flexbox squeezed its
908
- WIDTH down to fit the text (rendering ~12.94x18, squashed) while its literal height
909
- attribute stayed 18. Lucide icons here dodge this via the unrelated .card-cta-row .mbtn
910
- .lucide CSS rule (flex: none), which doesn't match a plain <svg> with no lucide class. */}
911
- <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg" style={{ flex: 'none' }}>
912
- <path d="M3 5.25H15" stroke="#5B6B7F" strokeWidth={1.91667} strokeLinecap="round" strokeLinejoin="round" />
913
- <path
914
- 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"
915
- fill="#FFFEFE"
916
- stroke="#5B6B7F"
917
- strokeLinecap="round"
918
- strokeLinejoin="round"
919
- />
920
- <path d="M3 9H15" stroke="#5B6B7F" strokeWidth={1.91667} strokeLinecap="round" strokeLinejoin="round" />
921
- <path
922
- 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"
923
- fill="white"
924
- stroke="#5B6B7F"
925
- strokeLinecap="round"
926
- strokeLinejoin="round"
927
- />
928
- <path d="M3 12.75H15" stroke="#5B6B7F" strokeWidth={1.91667} strokeLinecap="round" strokeLinejoin="round" />
929
- <path
930
- 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"
931
- fill="white"
932
- stroke="#5B6B7F"
933
- strokeLinecap="round"
934
- strokeLinejoin="round"
935
- />
936
- </svg>
937
- {t('autobahn:finance.adjustRate')}
938
- </Button>
939
- </div>
940
- );
941
-
942
- export interface GalleryCounterProps {
943
- /** 1-based index of the currently shown photo. */
944
- current: number;
945
- total: number;
946
- /** Figma "Vehicle Gallery / Photos Button" light-pill treatment (Car Card, node 281:1016) —
947
- * CarRow keeps the original dark `.imglabel` pill until it gets the same design pass. */
948
- light?: boolean;
949
- /** makes the light pill a real button (opens the full VdpViewer lightbox on the grid card) —
950
- * the dark `.imglabel` variant stays a plain, non-interactive span either way. */
951
- onClick?: () => void;
952
- }
953
-
954
- /**
955
- * Bottom-left gallery overlay: expand icon + "current|total" (Figma). Reuses the existing
956
- * `.imglabel` pill style (already used for the list-card's photo-count badge) rather than a new
957
- * class — same dark translucent pill, just with the maximize icon instead of the image icon.
958
- *
959
- * States (shared policy across GalleryCounter, the carousel's own arrows/dots in CardCarousel,
960
- * and GalleryActivityPill below — see its own doc comment for the other two):
961
- * - single-image: `total` is the car's REAL, eagerly-known photo count (car.photos, from the
962
- * search payload — not the lazily-loaded gallery array length), so this is accurate even
963
- * before any image beyond the first has actually loaded. total<=1 → hidden: nothing to expand
964
- * into. Never a "1|1" placeholder.
965
- * - loading: while `total` itself is still unknown (car not yet resolved) the caller simply
966
- * hasn't rendered this component yet — there is no separate in-between skeleton state here.
967
- */
968
- export const GalleryCounter: React.FunctionComponent<GalleryCounterProps> = ({ current, total, light, onClick }) => {
969
- if (total <= 1) return null;
970
- if (light) {
971
- return (
972
- <button type="button" className="cc-photo-pill" onClick={onClick}>
973
- <Icon name="maximize" size={18} stroke={2} color="#111820" />
974
- {current} | {total}
975
- </button>
976
- );
977
- }
978
- return (
979
- <span className="imglabel">
980
- <Icon name="maximize" size={13} stroke={2} />
981
- {current}|{total}
982
- </span>
983
- );
984
- };
985
-
986
- export interface GalleryActivityPillProps {
987
- /** total detail-page views (stats totalCarImpCount) — real data only, never fabricated. */
988
- viewsCount?: number;
989
- /** total merkliste adds (stats totalFavCount) — real data only, never fabricated. */
990
- favoritesCount?: number;
991
- }
992
-
993
- /**
994
- * Bottom-right gallery overlay: eye + views, heart + favorites, in ONE pill (Figma "Push Chips /
995
- * Likes", node 297:1037). Each half renders independently.
996
- *
997
- * States (chosen ONE policy, applied identically to both halves):
998
- * - loading: `viewsCount`/`favoritesCount` are `undefined` until the async stats call
999
- * (UserActionsAPI 'stats/viewers') resolves for this car. No skeleton — the half (or the
1000
- * whole pill, if both are still pending) simply doesn't render yet, same "hidden, not a
1001
- * placeholder" discipline as GalleryCounter/CardCarousel's arrows above.
1002
- * - zero-value: a REAL `0` is treated the same as "not there" — hidden, not shown as "👁 0".
1003
- * Deliberate choice over spelling out "0" (the other option the ticket allows): on a dense
1004
- * grid of fresh listings a "👁 0 ❤ 0" pill on every card is noise, not signal. `!viewsCount`/
1005
- * `!favoritesCount` below intentionally don't distinguish real-0 from not-yet-loaded — both
1006
- * read as "nothing worth showing (yet)", which is the same outcome either way.
1007
- */
1008
- export const GalleryActivityPill: React.FunctionComponent<GalleryActivityPillProps> = ({ viewsCount, favoritesCount }) => {
1009
- if (!viewsCount && !favoritesCount) return null;
1010
- return (
1011
- <span className="cc-activity-pill">
1012
- {!!viewsCount && (
1013
- <span className="cc-activity-pill-item">
1014
- <Icon name="eye" size={16} stroke={1.9} color="#1D2A38" />
1015
- {viewsCount}
1016
- </span>
1017
- )}
1018
- {!!favoritesCount && (
1019
- <span className="cc-activity-pill-item">
1020
- <Icon name="heart" size={16} stroke={1.9} color="#1D2A38" />
1021
- {favoritesCount}
1022
- </span>
1023
- )}
1024
- </span>
1025
- );
1026
- };
1027
-
1028
- interface PpRowProps {
1029
- /** payment-path label (Finanzierung / Leasing / Kaufen). */
1030
- label: string;
1031
- /** the figure to show — a monthly rate (money=false) or a full price (money=true). */
1032
- value: number;
1033
- /** small unit before the figure, e.g. 'mtl.'. */
1034
- unit?: string;
1035
- /** real previous price to strike through (only ever the genuine list price). */
1036
- old?: number | null;
1037
- /** the financing row — kept visually dominant (larger). */
1038
- focus?: boolean;
1039
- /** format as a full euro price (Kaufen) instead of a rounded rate. */
1040
- money?: boolean;
1041
- t: TranslationFunction;
1042
- }
1043
-
1044
- /**
1045
- * One payment-path row: label (+ a quiet info marker) on the left, the price right-aligned
1046
- * with an optional struck-through previous price above it. Even row spacing reproduces the
1047
- * production "Finanzierung / Leasing / Kaufen" price table the design references. The struck
1048
- * `old` price gets the same "²" UvpBadge + click-to-open popover as PriceHero's own Kaufen
1049
- * old-price (same n, same body/close copy) — one-to-one, not a re-styled variant.
1050
- */
1051
- const PpRow: React.FunctionComponent<PpRowProps> = ({ label, value, unit, old, focus, money, t }) => {
1052
- const [uvpTooltipOpen, setUvpTooltipOpen] = useState(false);
1053
- // 5-plus-digit prices (e.g. 60.248 €) shrink to keep the row from crowding — 4-digit values
1054
- // stay at the base size. Same digit-length technique as PriceHero's buyLen6Class.
1055
- const valDigits = String(Math.round(value)).length;
1056
- const valLenClass = valDigits >= 5 ? ' pp-val--len5' : '';
1057
- return (
1058
- <div className={'pp-row' + (focus ? ' pp-row--focus' : '')}>
1059
- <span className="pp-row-label">
1060
- {label}
1061
- <Icon name="info" size={13} stroke={1.9} cls="pp-row-i" />
1062
- </span>
1063
- <span className="pp-row-price">
1064
- {old != null && (
1065
- <span
1066
- className="pp-old"
1067
- role="button"
1068
- tabIndex={0}
1069
- onClick={(e) => {
1070
- e.stopPropagation();
1071
- setUvpTooltipOpen((v) => !v);
1072
- }}
1073
- >
1074
- {old.toLocaleString('de-DE')} €
1075
- <UvpBadge
1076
- n={2}
1077
- open={uvpTooltipOpen}
1078
- onToggle={() => setUvpTooltipOpen((v) => !v)}
1079
- onClose={() => setUvpTooltipOpen(false)}
1080
- closeLabel={t('autobahn:modal.close')}
1081
- body={t('autobahn:card.price.uvpListTooltipBody')}
1082
- />
1083
- </span>
1084
- )}
1085
- <span className="pp-now">
1086
- {unit && <span className="pp-unit">{unit}</span>}
1087
- <b className={'num pp-val' + valLenClass}>
1088
- {money ? value.toLocaleString('de-DE') : fmtRate(value)} €{money && <sup>1</sup>}
1089
- </b>
1090
- </span>
1091
- </span>
1092
- </div>
1093
- );
1094
- };
1095
-
1096
- /**
1097
- * Monthly-rate payment paths (SRP price column, TOP group) — modelled on the legacy design:
1098
- * Finanzierung is the hero (eyebrow + big blue rate + its terms line), which both keeps the
1099
- * financing focus and FILLS the upper gap with real default-config info (Anzahlung · Laufzeit).
1100
- * Leasing follows as a quiet neutral row (with its own terms when the config carries them) and
1101
- * is omitted entirely when leasing isn't active. The Kaufen row is rendered separately
1102
- * (PriceKauf) below a divider so only the financing rate stands out — no wall of blue prices.
1103
- */
1104
- export const PricePaths: React.FunctionComponent<PricePathsProps> = ({ car, t, className, onShowDetails }) => {
1105
- const hasLease = car.lease != null;
1106
- // Terms of the config the displayed rate was actually computed with (per-car:
1107
- // dealer rate + the user's saved localStorage adjustments) — default config
1108
- // terms only when the car doesn't carry its own.
1109
- const finFirstInstallment =
1110
- car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
1111
- const finMonths = car.finMonths ?? _finMonths;
1112
- const leasFirstInstallment =
1113
- car.leaseFirstInstallment != null ? car.leaseFirstInstallment.toLocaleString('de-DE') : _leasFirstInstallment;
1114
- const leasMileage = car.leaseMileage ?? _leasMileage;
1115
- const leasMonths = car.leaseMonths ?? _leasPeriod;
1116
- const hasLeasTerms = Boolean(leasMileage && leasMonths);
1117
- const leasMileageStr = leasMileage ? Number(leasMileage).toLocaleString('de-DE') : '';
1118
- const detailsLink = (mode: PaymentMode): React.ReactNode =>
1119
- onShowDetails ? (
1120
- <button
1121
- type="button"
1122
- className="pp-details-link"
1123
- onClick={(e) => {
1124
- e.stopPropagation();
1125
- onShowDetails(mode);
1126
- }}
1127
- >
1128
- {t('autobahn:card.price.details')}
1129
- </button>
1130
- ) : (
1131
- <span className="pp-details-link">{t('autobahn:card.price.details')}</span>
1132
- );
1133
- return (
1134
- <div className={'pricepaths' + (className ? ' ' + className : '')}>
1135
- <div className="pp-eyebrow">{t('autobahn:card.price.financingFrom')}</div>
1136
- {/* reuses PriceHero's own financing rendering — the exact same stacked "UVP-Rate ⓘ /
1137
- struck price / mtl." group beside the rate that .cc-price and mobile's tab switcher
1138
- already use, so the rate + unit never fight for room in one flat row (the earlier
1139
- hand-rolled version here put them side by side and wrapped for any 4+-digit rate). */}
1140
- <PriceHero car={car} mode="financing" t={t} alwaysShowUnit />
1141
- <div className="pp-hero-terms">
1142
- {t('autobahn:card.price.financeTerms', {
1143
- firstInstallment: finFirstInstallment,
1144
- months: finMonths,
1145
- count: finMonths,
1146
- })}{' '}
1147
- · {detailsLink('financing')}
1148
- </div>
1149
- {/* ADV-405/408/411 Kreditkosten-Hinweis: one per card, under the financing conditions and
1150
- above the Leasing row. Financing is always shown in this column, so it is unconditional. */}
1151
- <CreditCostNotice t={t} size="small" cls="pp-ccn" />
1152
- {hasLease && (
1153
- <div className="pp-lease-row">
1154
- <PpRow label={t('autobahn:card.price.leasing')} value={car.lease as number} unit="mtl." t={t} />
1155
- {hasLeasTerms && (
1156
- <div className="pp-sub-terms">
1157
- {/* dedicated keys (not a rework of leaseTerms) so mobile/VDP's own reviewed
1158
- wording there stays untouched, but includes the same Sonderzahlung figure.
1159
- Split across two lines with an explicit <br/> (column is too narrow for all
1160
- three figures + Details on one line) — forced right after km/Jahr so "36" and
1161
- "Mon." always land on the same line instead of an awkward mid-number wrap. */}
1162
- {t('autobahn:card.price.leaseTermsCompactLine1', {
1163
- firstInstallment: leasFirstInstallment,
1164
- mileage: leasMileageStr,
1165
- })}{' · '}
1166
- <br />
1167
- {t('autobahn:card.price.leaseTermsCompactLine2', { months: leasMonths })}{' '}
1168
- · {detailsLink('leasing')}
1169
- </div>
1170
- )}
1171
- </div>
1172
- )}
1173
- </div>
1174
- );
1175
- };
1176
-
1177
- /**
1178
- * Kaufen (outright purchase) row — the BOTTOM group, separated from the monthly-rate paths by a
1179
- * divider. Quiet/neutral (not blue) and strikes the previous price only on a real list-price
1180
- * saving (never a fabricated "was" price).
1181
- */
1182
- export const PriceKauf: React.FunctionComponent<PricePathsProps> = ({ car, t }) => {
1183
- const showStrike = car.savings != null && car.savings > 600 && car.listPrice != null;
1184
- return (
1185
- <PpRow label={t('autobahn:card.price.buy')} value={car.price} old={showStrike ? (car.listPrice as number) : null} money t={t} />
1186
- );
1187
- };
1188
-
1189
- export interface PpActivityProps {
1190
- car: AutobahnCar;
1191
- t: TranslationFunction;
1192
- }
1193
-
1194
- /**
1195
- * Buyer-activity cue rendered below the CTA in the listing card.
1196
- *
1197
- * NEEDS-DATA: needs watchers + views. When either is missing we show the
1198
- * 'Daten folgt' marker instead of inventing interest figures.
1199
- */
1200
- export const PpActivity: React.FunctionComponent<PpActivityProps> = ({ car, t }) => {
1201
- // No real watcher/view data (no backend yet) → render nothing rather than a "Daten folgt"
1202
- // placeholder that reads as perpetual loading. Wire when UserActionsAPI stats are available.
1203
- if (car.watchers == null || car.views == null) return null;
1204
- const hrs = 1 + (car.views % 6);
1205
- return (
1206
- <div className="pp-activity">
1207
- <Icon name="eye" size={12} stroke={1.9} />
1208
- {t('autobahn:card.activity.watchers', { watchers: car.watchers, hrs, count: car.watchers })}
1209
- </div>
1210
- );
1211
- };
1212
-
1213
- export interface GalleryBadgesProps {
1214
- car: AutobahnCar;
1215
- t: TranslationFunction;
1216
- }
1217
-
1218
- /**
1219
- * Trust/activity badges overlaid on the photo itself, bottom-right (PM reference, 2026-07-10),
1220
- * Figma pill styling (border/radius/height — see .gallery-pill in md3.css). Mirrors the mobile
1221
- * VDP gallery header (availability · views · favorites · Geprüft).
1222
- *
1223
- * Each pill is independent, not all-or-nothing: a missing or zero view/favorite count just omits
1224
- * THAT pill (never shown as "0×") — availability and Geprüft still render on their own terms.
1225
- * .gallery-badges is anchored via `right`, not `left` (md3.css), so however many pills survive
1226
- * they stay stuck to the right edge instead of drifting to wherever the row happens to start.
1227
- */
1228
- export const GalleryBadges: React.FunctionComponent<GalleryBadgesProps> = ({ car, t }) => (
1229
- <div className="gallery-badges">
1230
- {car.availability && (
1231
- <span className="gallery-pill">
1232
- <Icon name="circle-check" size={15} stroke={2} color="var(--md-good)" />
1233
- {car.availability}
1234
- </span>
1235
- )}
1236
- {!!car.viewsCount && (
1237
- <span className="gallery-pill">
1238
- <Icon name="eye" size={15} stroke={1.9} />
1239
- {t('autobahn:card.activity.viewsCount', { count: car.viewsCount })}
1240
- </span>
1241
- )}
1242
- {!!car.favoritesCount && (
1243
- <span className="gallery-pill">
1244
- <Icon name="heart" size={15} stroke={1.9} />
1245
- {t('autobahn:card.activity.favoritesCount', { count: car.favoritesCount })}
1246
- </span>
1247
- )}
1248
- <span className="gallery-pill">
1249
- <Icon name="shield-check" size={15} stroke={1.9} />
1250
- {t('autobahn:card.trust.checked')}
1251
- </span>
1252
- </div>
1253
- );
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
+ return (
618
+ <div className={'pp-hero' + (isMoney ? ' pp-hero--buy' : '')}>
619
+ <div className="pp-hero-rate">
620
+ <b className={'num pp-hero-val' + rateLenClass + buyLen6Class}>
621
+ {isMoney ? value.toLocaleString('de-DE') : fmtRate(value)} €{isMoney && <sup>1</sup>}
622
+ </b>
623
+ {/* z.B./old-rate/unit grouped in one stacked column beside the hero figure — mirrors
624
+ the VDP finance-calculator's .fin-rate-unit layout (FinanceCalculator.tsx) exactly.
625
+ Only shown when there's a real old price to strike through — without a discount the
626
+ eyebrow/unit have nothing to caption, so the whole group stays hidden. */}
627
+ {!isMoney && showOld && (
628
+ <span className="pp-hero-unit-group">
629
+ {/* a real (not display:contents) flex-column box, matching .pp-hero-unit-group's own
630
+ column layout exactly — so the click target covers the full area INCLUDING the
631
+ gap between the two stacked lines, not just their text glyphs (display:contents
632
+ has no box of its own there, so clicks in that gap fell through to the card link
633
+ behind it instead of opening the tooltip). stopPropagation is required here too —
634
+ the whole card (CarCard.tsx) has its own onClick={() => onOpen(car)} navigation,
635
+ so without it a click on this block both opened the tooltip AND navigated away. */}
636
+ <span
637
+ style={{ display: 'flex', flexDirection: 'column' }}
638
+ role="button"
639
+ tabIndex={0}
640
+ onClick={(e) => {
641
+ e.stopPropagation();
642
+ setUvpTooltipOpen((v) => !v);
643
+ }}
644
+ >
645
+ <span className="pp-eyebrow">
646
+ {t('autobahn:card.price.uvpRateLabel')}
647
+ <UvpBadge
648
+ n={3}
649
+ open={uvpTooltipOpen}
650
+ onToggle={() => setUvpTooltipOpen((v) => !v)}
651
+ onClose={() => setUvpTooltipOpen(false)}
652
+ closeLabel={t('autobahn:modal.close')}
653
+ body={t(
654
+ mode === 'leasing'
655
+ ? 'autobahn:card.price.uvpRateTooltipBodyLeasing'
656
+ : 'autobahn:card.price.uvpRateTooltipBody',
657
+ )}
658
+ />
659
+ </span>
660
+ <span className={'pp-hero-old' + oldLenClass}>{Math.round(oldValue as number).toLocaleString('de-DE')} €</span>
661
+ </span>
662
+ <span className="pp-hero-unit">{t('autobahn:card.price.perMonth')}</span>
663
+ </span>
664
+ )}
665
+ {/* opt-in (alwaysShowUnit): no discount to caption, so just the plain unit next to the
666
+ rate instead of the full UVP-Rate/old-price group — existing callers that don't pass
667
+ this prop keep showing nothing here, exactly as before. */}
668
+ {!isMoney && !showOld && alwaysShowUnit && <span className="pp-hero-unit">{t('autobahn:card.price.perMonth')}</span>}
669
+ {/* Kaufen: no rate/unit to caption, just the real list price struck through — same
670
+ car.listPrice already used by DropChip/PpRow. */}
671
+ {isMoney && showOld && (
672
+ <span className="pp-hero-unit-group">
673
+ {/* ADV-423: "UVP" label right before the struck list price — desktop only (mobile
674
+ stays as it was); same tooltip toggle as the price itself. */}
675
+ <span
676
+ className="pp-uvp-label hide-mobile"
677
+ onClick={(e) => {
678
+ e.stopPropagation();
679
+ setUvpTooltipOpen((v) => !v);
680
+ }}
681
+ >
682
+ {t('autobahn:finance.uvp')}
683
+ </span>
684
+ <span
685
+ className={'pp-hero-old' + oldLenClass}
686
+ role="button"
687
+ tabIndex={0}
688
+ onClick={(e) => {
689
+ e.stopPropagation();
690
+ setUvpTooltipOpen((v) => !v);
691
+ }}
692
+ >
693
+ {Math.round(oldValue as number).toLocaleString('de-DE')} €
694
+ <UvpBadge
695
+ n={2}
696
+ open={uvpTooltipOpen}
697
+ onToggle={() => setUvpTooltipOpen((v) => !v)}
698
+ onClose={() => setUvpTooltipOpen(false)}
699
+ closeLabel={t('autobahn:modal.close')}
700
+ body={t('autobahn:card.price.uvpListTooltipBody')}
701
+ />
702
+ </span>
703
+ </span>
704
+ )}
705
+ </div>
706
+ </div>
707
+ );
708
+ };
709
+
710
+ /**
711
+ * Financing/leasing terms line ("0 € Anzahlung · 48 Monate Laufzeit" / "0 € Sonderzahlung ·
712
+ * 48 Mon. · 10.000 km/Jahr") + a "Finanzierungsdetails"/"Details" link, full-width under the
713
+ * price/rating row — same real per-car (falling back to the default config) figures as
714
+ * PricePaths' own terms line, just also wired to the page's rate-adjust sheet. Renders nothing
715
+ * for the Kaufen tab (a cash purchase has no financing terms) or when neither a terms line nor
716
+ * a details link end up with anything real to show.
717
+ */
718
+ export const PriceTerms: React.FunctionComponent<{
719
+ car: AutobahnCar;
720
+ mode: PaymentMode;
721
+ onOpenRateAdjust?: (mode: PaymentMode) => void;
722
+ /** takes over the "Finanzierungsdetails"/"Details" link's click (e.g. navigate to the VDP and
723
+ * open the finance modal already expanded, scrolled to the breakdown) — when given, it wins
724
+ * over onOpenRateAdjust for THIS link only; the mobile CTA row's own "Rate anpassen" button
725
+ * keeps using onOpenRateAdjust regardless. */
726
+ onShowDetails?: () => void;
727
+ t: TranslationFunction;
728
+ }> = ({ car, mode, onOpenRateAdjust, onShowDetails, t }) => {
729
+ // Kaufen (buy): a cash purchase has no financing terms/details link — used to `return null`
730
+ // here, which collapsed .cc-terms to 0 height on that tab while Financing/Leasing rendered a
731
+ // real line, jumping the price row (and everything below it: rating pill, CTA row) up/down on
732
+ // every tab switch. Render an empty, still-present .cc-terms div instead — same fix as the VDP
733
+ // FinanceCalculator's .fin-cond (md3.css), which reserves its line's height the same way.
734
+ if (mode === 'buy') return <div className="cc-terms" />;
735
+ const finFirstInstallment =
736
+ car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
737
+ const finMonths = car.finMonths ?? _finMonths;
738
+ const leasFirstInstallment =
739
+ car.leaseFirstInstallment != null ? car.leaseFirstInstallment.toLocaleString('de-DE') : _leasFirstInstallment;
740
+ const leasMileage = car.leaseMileage ?? _leasMileage;
741
+ const leasMonths = car.leaseMonths ?? _leasPeriod;
742
+ const hasLeasTerms = Boolean(leasMileage && leasMonths);
743
+ const leasMileageStr = leasMileage ? Number(leasMileage).toLocaleString('de-DE') : '';
744
+ const termsText =
745
+ mode === 'leasing'
746
+ ? hasLeasTerms
747
+ ? t('autobahn:card.price.leaseTerms', { firstInstallment: leasFirstInstallment, months: leasMonths, mileage: leasMileageStr })
748
+ : ''
749
+ : t('autobahn:card.price.financeTerms', { firstInstallment: finFirstInstallment, months: finMonths, count: finMonths });
750
+ if (!termsText && !onOpenRateAdjust && !onShowDetails) return null;
751
+ const detailsLabel = mode === 'leasing' ? t('autobahn:card.price.detailsLink') : t('autobahn:modal.financingDetails');
752
+ // split on the translation's own ' · ' separator so the dot can be styled lighter than the
753
+ // two figures around it (same literal separator convention as FinanceCalculator's condParts).
754
+ const termsParts = termsText ? termsText.split(' · ') : [];
755
+ return (
756
+ <div className="cc-terms">
757
+ {termsParts.map((part, i) => (
758
+ <React.Fragment key={i}>
759
+ {i > 0 && <span className="cc-terms-dot"> · </span>}
760
+ {part}
761
+ </React.Fragment>
762
+ ))}
763
+ {(onOpenRateAdjust || onShowDetails) && (
764
+ <>
765
+ {termsText && <span className="cc-terms-dot"> · </span>}
766
+ <button
767
+ type="button"
768
+ className="cc-terms-link"
769
+ onClick={(e) => {
770
+ e.stopPropagation();
771
+ if (onShowDetails) onShowDetails();
772
+ else onOpenRateAdjust!(mode);
773
+ }}
774
+ >
775
+ {detailsLabel}
776
+ </button>
777
+ </>
778
+ )}
779
+ </div>
780
+ );
781
+ };
782
+
783
+ // Same real sales number VehicleDetailedNextPage.tsx (VDP) already dials via its own onCall —
784
+ // duplicated here (not imported) because that page doesn't export it; both should eventually
785
+ // read from one shared constant.
786
+ export const DEALER_SALES_PHONE = '0800 40 30 182';
787
+
788
+ /** default onCall — dials the real sales number directly, same tel: pattern VDP uses. */
789
+ export function callDealerSalesPhone(): void {
790
+ if (typeof window !== 'undefined') window.location.href = `tel:${DEALER_SALES_PHONE.replace(/\s/g, '')}`;
791
+ }
792
+
793
+ export interface CardCtaRowProps {
794
+ car: AutobahnCar;
795
+ /** which payment tab is currently active on the card — forwarded to onOpenRateAdjust so the
796
+ * sheet opens on the SAME tab the user was looking at (the tab itself is CarCard-internal
797
+ * state, so this is the only way the page learns it). */
798
+ mode: PaymentMode;
799
+ /** primary CTA — mirrors FinanceCalculator's onSecure ("Angebot anfragen"). */
800
+ onRequestOffer: () => void;
801
+ /** phone CTA — mirrors FinanceCalculator's onCall. */
802
+ onCall: () => void;
803
+ /**
804
+ * opens the SAME "Rate anpassen" bottom-sheet FinanceDetailsModal already used on VDP mobile
805
+ * (VdpModules.tsx) — the page mounts one shared modal instance and passes this car's data,
806
+ * this button never builds its own sheet.
807
+ */
808
+ onOpenRateAdjust: (mode: PaymentMode) => void;
809
+ t: TranslationFunction;
810
+ }
811
+
812
+ /**
813
+ * Mobile-only 3-button CTA row (Figma: Angebot anfragen / phone / Rate anpassen). Desktop card
814
+ * has no CTA row at all (confirmed: mobile-only, per explicit user correction). "Rate anpassen"
815
+ * keeps its text label — only the phone button is icon-only, matching the mockup.
816
+ */
817
+ export const CardCtaRow: React.FunctionComponent<CardCtaRowProps> = ({ car, mode, onRequestOffer, onCall, onOpenRateAdjust, t }) => (
818
+ <div
819
+ className="card-cta-row show-mobile"
820
+ style={{ display: 'flex', gap: 6, borderTop: '1px solid var(--md-outline-variant)', paddingTop: 8 }}
821
+ >
822
+ <Button
823
+ variant="filled"
824
+ style={{
825
+ // Figma width (157px) as a STARTING size, not a hard fixed one — flex-grow:1 so this
826
+ // button (and "Adjust rate" below) still fill extra row width on wider cards instead of
827
+ // leaving dead space next to the fixed 40px phone button; flex-shrink:1 lets it narrow
828
+ // gracefully (text ellipsizes via the existing .card-cta-row .mbtn overflow rule) rather
829
+ // than overflow on very narrow cards.
830
+ flex: '1 1 157px',
831
+ height: 40,
832
+ background: '#005cff',
833
+ borderRadius: 16,
834
+ padding: '0 8px',
835
+ fontFamily: 'Arial, Arimo, sans-serif',
836
+ fontStyle: 'normal',
837
+ fontWeight: 700,
838
+ fontSize: 13,
839
+ lineHeight: '15px',
840
+ color: '#ffffff',
841
+ }}
842
+ onClick={(e) => {
843
+ e.stopPropagation();
844
+ onRequestOffer();
845
+ }}
846
+ >
847
+ {/* exact design icon (single self-contained SVG) — replaces the composed lucide
848
+ file-text + check-circle badge (DocCheckIcon), which is still used as-is on VDP's own
849
+ "Angebot anfragen" buttons; this swap is scoped to the search-card CTA only.
850
+ flex:none for the same shrink reason as the "Adjust rate" icon above. */}
851
+ <svg width="26" height="26" viewBox="0 0 26 26" fill="none" xmlns="http://www.w3.org/2000/svg" style={{ flex: 'none' }}>
852
+ <path
853
+ 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"
854
+ stroke="white"
855
+ strokeLinecap="round"
856
+ strokeLinejoin="round"
857
+ />
858
+ <path d="M15.0312 3.85938V8.53125H19.7031" stroke="white" strokeLinecap="round" strokeLinejoin="round" />
859
+ <path d="M8.9375 11.375H14.625" stroke="white" strokeLinecap="round" />
860
+ <path d="M8.9375 14.625H13.4062" stroke="white" strokeLinecap="round" />
861
+ <path d="M8.9375 17.875H12.5938" stroke="white" strokeLinecap="round" />
862
+ <path
863
+ 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"
864
+ fill="#005CFF"
865
+ stroke="white"
866
+ />
867
+ <path d="M17.0625 18.3219L18.5656 19.825L23.7656 14.625" stroke="white" strokeLinecap="round" strokeLinejoin="round" />
868
+ <path d="M21.6533 17.875L23.2783 16.25" stroke="#005CFF" strokeLinecap="round" strokeLinejoin="round" />
869
+ <path d="M20.1904 17.0625L21.8154 15.4375" stroke="#005CFF" strokeLinecap="round" strokeLinejoin="round" />
870
+ </svg>
871
+ {t('autobahn:finance.secureOffer')}
872
+ </Button>
873
+ <Button
874
+ variant="outlined"
875
+ style={{
876
+ flex: '0 0 auto',
877
+ width: 40,
878
+ height: 40,
879
+ background: '#ffffff',
880
+ border: '1.6px solid #005cff',
881
+ borderRadius: 16,
882
+ padding: 0,
883
+ }}
884
+ onClick={(e) => {
885
+ e.stopPropagation();
886
+ onCall();
887
+ }}
888
+ >
889
+ {/* exact design icon (not lucide's "phone") — no class="lucide", so the
890
+ .card-cta-row .mbtn .lucide 15px override doesn't touch it; the rect-clip from the
891
+ source SVG was a full-viewBox no-op (already inside 0-20/0-20) and dropped, since a
892
+ static clipPath id would collide across the many CarCard instances on one search page. */}
893
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
894
+ <path
895
+ 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"
896
+ stroke="#005cff"
897
+ strokeWidth={1.66667}
898
+ strokeLinecap="round"
899
+ strokeLinejoin="round"
900
+ />
901
+ </svg>
902
+ </Button>
903
+ <Button
904
+ variant="outlined"
905
+ style={{
906
+ // same "starting size that can still grow/shrink" reasoning as "Request offer" above.
907
+ flex: '1 1 125px',
908
+ height: 40,
909
+ background: '#ffffff',
910
+ border: '1.6px solid #5b6b7f',
911
+ borderRadius: 16,
912
+ padding: '0 6px',
913
+ fontFamily: 'Arial, Arimo, sans-serif',
914
+ fontStyle: 'normal',
915
+ fontWeight: 700,
916
+ fontSize: 13,
917
+ lineHeight: '15px',
918
+ color: '#5b6b7f',
919
+ }}
920
+ onClick={(e) => {
921
+ e.stopPropagation();
922
+ onOpenRateAdjust(mode);
923
+ }}
924
+ >
925
+ {/* exact design icon (not lucide's "sliders-horizontal") — colors are baked into the SVG
926
+ itself (matches the button's #5b6b7f border/text), not currentColor. flex:none is
927
+ load-bearing: this button is a flex row (icon + the "Adjust rate" label) inside a fixed
928
+ 125px width, and without it the icon was a shrinkable flex item — flexbox squeezed its
929
+ WIDTH down to fit the text (rendering ~12.94x18, squashed) while its literal height
930
+ attribute stayed 18. Lucide icons here dodge this via the unrelated .card-cta-row .mbtn
931
+ .lucide CSS rule (flex: none), which doesn't match a plain <svg> with no lucide class. */}
932
+ <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg" style={{ flex: 'none' }}>
933
+ <path d="M3 5.25H15" stroke="#5B6B7F" strokeWidth={1.91667} strokeLinecap="round" strokeLinejoin="round" />
934
+ <path
935
+ 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"
936
+ fill="#FFFEFE"
937
+ stroke="#5B6B7F"
938
+ strokeLinecap="round"
939
+ strokeLinejoin="round"
940
+ />
941
+ <path d="M3 9H15" stroke="#5B6B7F" strokeWidth={1.91667} strokeLinecap="round" strokeLinejoin="round" />
942
+ <path
943
+ 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"
944
+ fill="white"
945
+ stroke="#5B6B7F"
946
+ strokeLinecap="round"
947
+ strokeLinejoin="round"
948
+ />
949
+ <path d="M3 12.75H15" stroke="#5B6B7F" strokeWidth={1.91667} strokeLinecap="round" strokeLinejoin="round" />
950
+ <path
951
+ 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"
952
+ fill="white"
953
+ stroke="#5B6B7F"
954
+ strokeLinecap="round"
955
+ strokeLinejoin="round"
956
+ />
957
+ </svg>
958
+ {t('autobahn:finance.adjustRate')}
959
+ </Button>
960
+ </div>
961
+ );
962
+
963
+ export interface GalleryCounterProps {
964
+ /** 1-based index of the currently shown photo. */
965
+ current: number;
966
+ total: number;
967
+ /** Figma "Vehicle Gallery / Photos Button" light-pill treatment (Car Card, node 281:1016) —
968
+ * CarRow keeps the original dark `.imglabel` pill until it gets the same design pass. */
969
+ light?: boolean;
970
+ /** makes the light pill a real button (opens the full VdpViewer lightbox on the grid card) —
971
+ * the dark `.imglabel` variant stays a plain, non-interactive span either way. */
972
+ onClick?: () => void;
973
+ }
974
+
975
+ /**
976
+ * Bottom-left gallery overlay: expand icon + "current|total" (Figma). Reuses the existing
977
+ * `.imglabel` pill style (already used for the list-card's photo-count badge) rather than a new
978
+ * class — same dark translucent pill, just with the maximize icon instead of the image icon.
979
+ *
980
+ * States (shared policy across GalleryCounter, the carousel's own arrows/dots in CardCarousel,
981
+ * and GalleryActivityPill below — see its own doc comment for the other two):
982
+ * - single-image: `total` is the car's REAL, eagerly-known photo count (car.photos, from the
983
+ * search payload — not the lazily-loaded gallery array length), so this is accurate even
984
+ * before any image beyond the first has actually loaded. total<=1 → hidden: nothing to expand
985
+ * into. Never a "1|1" placeholder.
986
+ * - loading: while `total` itself is still unknown (car not yet resolved) the caller simply
987
+ * hasn't rendered this component yet — there is no separate in-between skeleton state here.
988
+ */
989
+ export const GalleryCounter: React.FunctionComponent<GalleryCounterProps> = ({ current, total, light, onClick }) => {
990
+ if (total <= 1) return null;
991
+ if (light) {
992
+ return (
993
+ <button type="button" className="cc-photo-pill" onClick={onClick}>
994
+ <Icon name="maximize" size={18} stroke={2} color="#111820" />
995
+ {current} | {total}
996
+ </button>
997
+ );
998
+ }
999
+ return (
1000
+ <span className="imglabel">
1001
+ <Icon name="maximize" size={13} stroke={2} />
1002
+ {current}|{total}
1003
+ </span>
1004
+ );
1005
+ };
1006
+
1007
+ export interface GalleryActivityPillProps {
1008
+ /** total detail-page views (stats totalCarImpCount) — real data only, never fabricated. */
1009
+ viewsCount?: number;
1010
+ /** total merkliste adds (stats totalFavCount) — real data only, never fabricated. */
1011
+ favoritesCount?: number;
1012
+ }
1013
+
1014
+ /**
1015
+ * Bottom-right gallery overlay: eye + views, heart + favorites, in ONE pill (Figma "Push Chips /
1016
+ * Likes", node 297:1037). Each half renders independently.
1017
+ *
1018
+ * States (chosen ONE policy, applied identically to both halves):
1019
+ * - loading: `viewsCount`/`favoritesCount` are `undefined` until the async stats call
1020
+ * (UserActionsAPI 'stats/viewers') resolves for this car. No skeleton — the half (or the
1021
+ * whole pill, if both are still pending) simply doesn't render yet, same "hidden, not a
1022
+ * placeholder" discipline as GalleryCounter/CardCarousel's arrows above.
1023
+ * - zero-value: a REAL `0` is treated the same as "not there" — hidden, not shown as "👁 0".
1024
+ * Deliberate choice over spelling out "0" (the other option the ticket allows): on a dense
1025
+ * grid of fresh listings a "👁 0 ❤ 0" pill on every card is noise, not signal. `!viewsCount`/
1026
+ * `!favoritesCount` below intentionally don't distinguish real-0 from not-yet-loaded — both
1027
+ * read as "nothing worth showing (yet)", which is the same outcome either way.
1028
+ */
1029
+ export const GalleryActivityPill: React.FunctionComponent<GalleryActivityPillProps> = ({ viewsCount, favoritesCount }) => {
1030
+ if (!viewsCount && !favoritesCount) return null;
1031
+ return (
1032
+ <span className="cc-activity-pill">
1033
+ {!!viewsCount && (
1034
+ <span className="cc-activity-pill-item">
1035
+ <Icon name="eye" size={16} stroke={1.9} color="#1D2A38" />
1036
+ {viewsCount}
1037
+ </span>
1038
+ )}
1039
+ {!!favoritesCount && (
1040
+ <span className="cc-activity-pill-item">
1041
+ <Icon name="heart" size={16} stroke={1.9} color="#1D2A38" />
1042
+ {favoritesCount}
1043
+ </span>
1044
+ )}
1045
+ </span>
1046
+ );
1047
+ };
1048
+
1049
+ interface PpRowProps {
1050
+ /** payment-path label (Finanzierung / Leasing / Kaufen). */
1051
+ label: string;
1052
+ /** the figure to show — a monthly rate (money=false) or a full price (money=true). */
1053
+ value: number;
1054
+ /** small unit before the figure, e.g. 'mtl.'. */
1055
+ unit?: string;
1056
+ /** real previous price to strike through (only ever the genuine list price). */
1057
+ old?: number | null;
1058
+ /** the financing row — kept visually dominant (larger). */
1059
+ focus?: boolean;
1060
+ /** format as a full euro price (Kaufen) instead of a rounded rate. */
1061
+ money?: boolean;
1062
+ t: TranslationFunction;
1063
+ }
1064
+
1065
+ /**
1066
+ * One payment-path row: label (+ a quiet info marker) on the left, the price right-aligned
1067
+ * with an optional struck-through previous price above it. Even row spacing reproduces the
1068
+ * production "Finanzierung / Leasing / Kaufen" price table the design references. The struck
1069
+ * `old` price gets the same "²" UvpBadge + click-to-open popover as PriceHero's own Kaufen
1070
+ * old-price (same n, same body/close copy) — one-to-one, not a re-styled variant.
1071
+ */
1072
+ const PpRow: React.FunctionComponent<PpRowProps> = ({ label, value, unit, old, focus, money, t }) => {
1073
+ const [uvpTooltipOpen, setUvpTooltipOpen] = useState(false);
1074
+ // 5-plus-digit prices (e.g. 60.248 €) shrink to keep the row from crowding — 4-digit values
1075
+ // stay at the base size. Same digit-length technique as PriceHero's buyLen6Class.
1076
+ const valDigits = String(Math.round(value)).length;
1077
+ const valLenClass = valDigits >= 5 ? ' pp-val--len5' : '';
1078
+ return (
1079
+ <div className={'pp-row' + (focus ? ' pp-row--focus' : '')}>
1080
+ <span className="pp-row-label">
1081
+ {label}
1082
+ <Icon name="info" size={13} stroke={1.9} cls="pp-row-i" />
1083
+ </span>
1084
+ <span className="pp-row-price">
1085
+ {old != null && (
1086
+ // ADV-423: "UVP" label for the struck list price (PpRow only renders in the desktop SRL
1087
+ // column, and `old` is only ever the Kaufen list price). md3.css places it above the
1088
+ // struck amount there — the fixed-width row has no room for it inline.
1089
+ <span className="pp-uvp-strike">
1090
+ <span
1091
+ className="pp-uvp-label"
1092
+ onClick={(e) => {
1093
+ e.stopPropagation();
1094
+ setUvpTooltipOpen((v) => !v);
1095
+ }}
1096
+ >
1097
+ {t('autobahn:finance.uvp')}
1098
+ </span>
1099
+ <span
1100
+ className="pp-old"
1101
+ role="button"
1102
+ tabIndex={0}
1103
+ onClick={(e) => {
1104
+ e.stopPropagation();
1105
+ setUvpTooltipOpen((v) => !v);
1106
+ }}
1107
+ >
1108
+ {old.toLocaleString('de-DE')} €
1109
+ <UvpBadge
1110
+ n={2}
1111
+ open={uvpTooltipOpen}
1112
+ onToggle={() => setUvpTooltipOpen((v) => !v)}
1113
+ onClose={() => setUvpTooltipOpen(false)}
1114
+ closeLabel={t('autobahn:modal.close')}
1115
+ body={t('autobahn:card.price.uvpListTooltipBody')}
1116
+ />
1117
+ </span>
1118
+ </span>
1119
+ )}
1120
+ <span className="pp-now">
1121
+ {unit && <span className="pp-unit">{unit}</span>}
1122
+ <b className={'num pp-val' + valLenClass}>
1123
+ {money ? value.toLocaleString('de-DE') : fmtRate(value)} €{money && <sup>1</sup>}
1124
+ </b>
1125
+ </span>
1126
+ </span>
1127
+ </div>
1128
+ );
1129
+ };
1130
+
1131
+ /**
1132
+ * Monthly-rate payment paths (SRP price column, TOP group) — modelled on the legacy design:
1133
+ * Finanzierung is the hero (eyebrow + big blue rate + its terms line), which both keeps the
1134
+ * financing focus and FILLS the upper gap with real default-config info (Anzahlung · Laufzeit).
1135
+ * Leasing follows as a quiet neutral row (with its own terms when the config carries them) and
1136
+ * is omitted entirely when leasing isn't active. The Kaufen row is rendered separately
1137
+ * (PriceKauf) below a divider so only the financing rate stands out — no wall of blue prices.
1138
+ */
1139
+ export const PricePaths: React.FunctionComponent<PricePathsProps> = ({ car, t, className, onShowDetails }) => {
1140
+ const hasLease = car.lease != null;
1141
+ // Terms of the config the displayed rate was actually computed with (per-car:
1142
+ // dealer rate + the user's saved localStorage adjustments) — default config
1143
+ // terms only when the car doesn't carry its own.
1144
+ const finFirstInstallment =
1145
+ car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
1146
+ const finMonths = car.finMonths ?? _finMonths;
1147
+ const leasFirstInstallment =
1148
+ car.leaseFirstInstallment != null ? car.leaseFirstInstallment.toLocaleString('de-DE') : _leasFirstInstallment;
1149
+ const leasMileage = car.leaseMileage ?? _leasMileage;
1150
+ const leasMonths = car.leaseMonths ?? _leasPeriod;
1151
+ const hasLeasTerms = Boolean(leasMileage && leasMonths);
1152
+ const leasMileageStr = leasMileage ? Number(leasMileage).toLocaleString('de-DE') : '';
1153
+ const detailsLink = (mode: PaymentMode): React.ReactNode =>
1154
+ onShowDetails ? (
1155
+ <button
1156
+ type="button"
1157
+ className="pp-details-link"
1158
+ onClick={(e) => {
1159
+ e.stopPropagation();
1160
+ onShowDetails(mode);
1161
+ }}
1162
+ >
1163
+ {t('autobahn:card.price.details')}
1164
+ </button>
1165
+ ) : (
1166
+ <span className="pp-details-link">{t('autobahn:card.price.details')}</span>
1167
+ );
1168
+ return (
1169
+ <div className={'pricepaths' + (className ? ' ' + className : '')}>
1170
+ <div className="pp-eyebrow">{t('autobahn:card.price.financingFrom')}</div>
1171
+ {/* reuses PriceHero's own financing rendering — the exact same stacked "UVP-Rate ⓘ /
1172
+ struck price / mtl." group beside the rate that .cc-price and mobile's tab switcher
1173
+ already use, so the rate + unit never fight for room in one flat row (the earlier
1174
+ hand-rolled version here put them side by side and wrapped for any 4+-digit rate). */}
1175
+ <PriceHero car={car} mode="financing" t={t} alwaysShowUnit />
1176
+ <div className="pp-hero-terms">
1177
+ {t('autobahn:card.price.financeTerms', {
1178
+ firstInstallment: finFirstInstallment,
1179
+ months: finMonths,
1180
+ count: finMonths,
1181
+ })}{' '}
1182
+ · {detailsLink('financing')}
1183
+ </div>
1184
+ {/* ADV-405/408/411 Kreditkosten-Hinweis: one per card, under the financing conditions and
1185
+ above the Leasing row. Financing is always shown in this column, so it is unconditional. */}
1186
+ <CreditCostNotice t={t} size="small" cls="pp-ccn" />
1187
+ {hasLease && (
1188
+ <div className="pp-lease-row">
1189
+ <PpRow label={t('autobahn:card.price.leasing')} value={car.lease as number} unit="mtl." t={t} />
1190
+ {hasLeasTerms && (
1191
+ <div className="pp-sub-terms">
1192
+ {/* dedicated keys (not a rework of leaseTerms) so mobile/VDP's own reviewed
1193
+ wording there stays untouched, but includes the same Sonderzahlung figure.
1194
+ Split across two lines with an explicit <br/> (column is too narrow for all
1195
+ three figures + Details on one line) — forced right after km/Jahr so "36" and
1196
+ "Mon." always land on the same line instead of an awkward mid-number wrap. */}
1197
+ {t('autobahn:card.price.leaseTermsCompactLine1', {
1198
+ firstInstallment: leasFirstInstallment,
1199
+ mileage: leasMileageStr,
1200
+ })}{' · '}
1201
+ <br />
1202
+ {t('autobahn:card.price.leaseTermsCompactLine2', { months: leasMonths })}{' '}
1203
+ · {detailsLink('leasing')}
1204
+ </div>
1205
+ )}
1206
+ </div>
1207
+ )}
1208
+ </div>
1209
+ );
1210
+ };
1211
+
1212
+ /**
1213
+ * Kaufen (outright purchase) row — the BOTTOM group, separated from the monthly-rate paths by a
1214
+ * divider. Quiet/neutral (not blue) and strikes the previous price only on a real list-price
1215
+ * saving (never a fabricated "was" price).
1216
+ */
1217
+ export const PriceKauf: React.FunctionComponent<PricePathsProps> = ({ car, t }) => {
1218
+ const showStrike = car.savings != null && car.savings > 600 && car.listPrice != null;
1219
+ return (
1220
+ <PpRow label={t('autobahn:card.price.buy')} value={car.price} old={showStrike ? (car.listPrice as number) : null} money t={t} />
1221
+ );
1222
+ };
1223
+
1224
+ export interface PpActivityProps {
1225
+ car: AutobahnCar;
1226
+ t: TranslationFunction;
1227
+ }
1228
+
1229
+ /**
1230
+ * Buyer-activity cue rendered below the CTA in the listing card.
1231
+ *
1232
+ * NEEDS-DATA: needs watchers + views. When either is missing we show the
1233
+ * 'Daten folgt' marker instead of inventing interest figures.
1234
+ */
1235
+ export const PpActivity: React.FunctionComponent<PpActivityProps> = ({ car, t }) => {
1236
+ // No real watcher/view data (no backend yet) → render nothing rather than a "Daten folgt"
1237
+ // placeholder that reads as perpetual loading. Wire when UserActionsAPI stats are available.
1238
+ if (car.watchers == null || car.views == null) return null;
1239
+ const hrs = 1 + (car.views % 6);
1240
+ return (
1241
+ <div className="pp-activity">
1242
+ <Icon name="eye" size={12} stroke={1.9} />
1243
+ {t('autobahn:card.activity.watchers', { watchers: car.watchers, hrs, count: car.watchers })}
1244
+ </div>
1245
+ );
1246
+ };
1247
+
1248
+ export interface GalleryBadgesProps {
1249
+ car: AutobahnCar;
1250
+ t: TranslationFunction;
1251
+ }
1252
+
1253
+ /**
1254
+ * Trust/activity badges overlaid on the photo itself, bottom-right (PM reference, 2026-07-10),
1255
+ * Figma pill styling (border/radius/height — see .gallery-pill in md3.css). Mirrors the mobile
1256
+ * VDP gallery header (availability · views · favorites · Geprüft).
1257
+ *
1258
+ * Each pill is independent, not all-or-nothing: a missing or zero view/favorite count just omits
1259
+ * THAT pill (never shown as "0×") — availability and Geprüft still render on their own terms.
1260
+ * .gallery-badges is anchored via `right`, not `left` (md3.css), so however many pills survive
1261
+ * they stay stuck to the right edge instead of drifting to wherever the row happens to start.
1262
+ */
1263
+ export const GalleryBadges: React.FunctionComponent<GalleryBadgesProps> = ({ car, t }) => (
1264
+ <div className="gallery-badges">
1265
+ {car.availability && (
1266
+ <span className="gallery-pill">
1267
+ <Icon name="circle-check" size={15} stroke={2} color="var(--md-good)" />
1268
+ {car.availability}
1269
+ </span>
1270
+ )}
1271
+ {!!car.viewsCount && (
1272
+ <span className="gallery-pill">
1273
+ <Icon name="eye" size={15} stroke={1.9} />
1274
+ {t('autobahn:card.activity.viewsCount', { count: car.viewsCount })}
1275
+ </span>
1276
+ )}
1277
+ {!!car.favoritesCount && (
1278
+ <span className="gallery-pill">
1279
+ <Icon name="heart" size={15} stroke={1.9} />
1280
+ {t('autobahn:card.activity.favoritesCount', { count: car.favoritesCount })}
1281
+ </span>
1282
+ )}
1283
+ <span className="gallery-pill">
1284
+ <Icon name="shield-check" size={15} stroke={1.9} />
1285
+ {t('autobahn:card.trust.checked')}
1286
+ </span>
1287
+ </div>
1288
+ );