{{-- ══════════════════════════════════════════════════════════════════════ SCOREBAR MINI — the same match scorebar shown on the full player, rendered inside a video-card thumbnail during hover playback. Uses the design's fixed 1150 px canvas (identical to the main player's msb-scale block). Every card scales its own canvas via ResizeObserver so the scorebar keeps its pixel-perfect proportions at any card size. Static-only: fighter names, flags, clubs, corner labels, "Round 1" and 0-0 / 0:00. No live-scoring script — hover previews cover the first few seconds of the match where those values are always the baseline anyway. ════════════════════════════════════════════════════════════════════════ --}} @php $sbm_hd = $video->sportsMatch?->headerData(); $sbm_red = $sbm_hd['red'] ?? null; $sbm_blue = $sbm_hd['blue'] ?? null; $sbm_show = $sbm_hd && (($sbm_red['name'] ?? null) || ($sbm_blue['name'] ?? null)); @endphp @if ($sbm_show) @php $sbm_redName = $sbm_red['name'] ?? 'RED'; $sbm_blueName = $sbm_blue['name'] ?? 'BLUE'; $sbm_redClub = $sbm_red['club'] ?? ''; $sbm_blueClub = $sbm_blue['club'] ?? ''; $sbm_redFlag = strtolower(trim((string) ($sbm_red['flag'] ?? ''))); $sbm_blueFlag = strtolower(trim((string) ($sbm_blue['flag'] ?? ''))); $sbm_redLogo = !empty($sbm_red['club_logo']) ? route('media.thumbnail', $sbm_red['club_logo']) : null; $sbm_blueLogo = !empty($sbm_blue['club_logo']) ? route('media.thumbnail', $sbm_blue['club_logo']) : null; // Live-scoring payload — same shape as the full-player scoreboard uses. // Rounds drive the round label + per-round clock. Points give us the // score at any t (last point ≤ t defines the score). $sbm_rounds = $video->matchRounds() ->orderBy('round_number') ->get(['round_number', 'name', 'start_time_seconds']) ->map(fn ($r) => [ 'n' => (int) $r->round_number, 'name' => (string) ($r->name ?? ''), 'start' => (float) ($r->start_time_seconds ?? 0), ])->values()->all(); if (empty($sbm_rounds)) $sbm_rounds = [['n' => 1, 'name' => '', 'start' => 0]]; $sbm_points = $video->matchPoints() ->orderBy('timestamp_seconds') ->get(['timestamp_seconds', 'action', 'points', 'competitor', 'score_red', 'score_blue']) ->flatMap(function ($p) { // Same rule the full-player uses: a "both" event emits two feed rows // — one per corner — so the ticker shows both fighters scoring. $side = ($p->competitor === 'both') ? 'red' : $p->competitor; $rows = [[ 't' => (float) $p->timestamp_seconds, 'action' => (string) ($p->action ?? 'Point'), 'pts' => (int) $p->points, 'side' => $side, 'sr' => (int) ($p->score_red ?? 0), 'sb' => (int) ($p->score_blue ?? 0), ]]; if ($p->competitor === 'both') { $rows[] = array_merge($rows[0], ['side' => 'blue', 't' => (float) $p->timestamp_seconds + 0.001]); } return $rows; })->values()->all(); $sbm_sport = $sbm_hd['sport'] ?? null; $sbm_data = json_encode(['rounds' => $sbm_rounds, 'points' => $sbm_points, 'sport' => $sbm_sport], JSON_HEX_APOS | JSON_HEX_QUOT); @endphp