All files / src/components TournamentMatchRow.vue

98.7% Statements 459/465
89.65% Branches 130/145
100% Functions 15/15
98.7% Lines 459/465

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 5971x 1x 1x 1x                 1x 1x   1x     1x 1x   1x 1x 1x 1x 1x   1x 1169x 1169x 1169x 1169x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x   1x 1x 1x 1x       1x   1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 97x 97x 97x 97x 97x 97x 97x   97x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x   1x 1x 1x 1x 1x 1x 1x           1x 1x   1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 1x   2441x 2441x 1x 1x 1x         1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x       1x 1x 1x       1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x   1x   1x 1x 1x 1x 1x 1x   1x 11x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 2x 2x 2x 2x   2x 1x 1x       1x 1x 1x 1x       1x 1x 1x   1x                                                       1x   1x   1x 1x 1x 1x 222x 111x 222x 1x 53x 25x 53x 1x 1x 1x 1x   1x 1x 1x   1x 37x 37x 37x 37x 37x 37x 37x 37x 37x 37x 37x 37x   1x 1x 1x 2x 1x 1x 1x 1x 1x 1x   1x 1x 1x   1x 123x 61x 123x 123x   1x 1x   1x 1x 1x 1x   1x 1x 1x 1x 51x 51x 1x 1x   1x 9x 9x 9x 9x 9x 9x 9x 2x 2x 2x 2x 2x 2x 2x 9x 9x   1x 1x 1x 1x 1x 14x 14x 1x   1x 979x 979x 1x   1x   1x 1x 976x 12x 12x 12x 1x   1x 1x 976x 12x 12x 12x 1x   1x 967x 1x   1x 1x 1x 1022x 1022x 1x   1x 1x 1x   1x 1x 1x 1x 1022x 1022x 22x 22x 1x 1x 1x 19x 19x 1x 1x   1x 966x 19x 74x 966x 966x 1x   1x 1x 1x 966x 7x 7x 7x 7x 966x       1x   1x 1038x 1038x 1038x 1038x 1038x 1038x 1038x 1038x 1038x 1038x 1038x 1038x 1038x 1038x 1038x 1038x 1038x 1038x 1038x 2076x 2076x 2076x 1038x 1x   1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1022x 1x 1x 1019x 1x 1x 1x 1x 1x 1019x 1019x 1019x 7x 7x 1001x 1x   1x 1x 1x 1x 1x 1x 1x   1x 1022x 1022x 1022x 1022x 1022x 1022x 1022x 1022x 1022x 1x   1x 1021x 1021x 28x 28x 1021x 83x 83x 1021x 3x 3x 3x 1021x 514x 514x 514x 514x 514x 514x 1021x 1x                                          
<template>
  <div
    @click="onCardClick"
    :class="[
      'group bg-card rounded-xl border border-line px-3 sm:px-4 py-3 cursor-pointer min-w-0',
      'hover:border-brand-300 dark:hover:border-brand-500 hover:shadow-md transition-all',
      'focus-within:ring-2 focus-within:ring-brand-500/40',
      // The viewer's own club gets an amber rail; everyone else a plain edge.
      mine
        ? 'border-l-[3px] border-l-accent-400 hover:border-l-accent-400'
        : '',
    ]"
    data-testid="tournament-match-row"
    :data-mine="mine ? 'true' : 'false'"
  >
    <!-- The card is not itself a button: it holds the edit control and the
         score inputs, which a role="button" would hide from screen readers.
         The team block is the real button; a click anywhere else on the card
         is a mouse convenience that does the same. -->
    <!-- One match as a card (SB-1865): meta line (kickoff, venue, tags,
         status), then each team on its own line with its crest and score, so a
         long club name truncates instead of squeezing the score off a phone. -->
    <!-- Meta line -->
    <div class="flex items-center gap-2 min-w-0 mb-2">
      <div
        class="flex items-center gap-1.5 min-w-0 flex-1 text-xs text-fg-muted"
      >
        <span
          v-if="showKickoff"
          class="font-semibold text-fg tabular-nums whitespace-nowrap"
          data-testid="match-kickoff"
          >{{ kickoffLabel || '—' }}</span
        >
        <span
          v-if="venueLabel"
          class="truncate min-w-0"
          data-testid="match-venue"
          ><span v-if="showKickoff" aria-hidden="true">· </span
          >{{ venueLabel }}</span
        >
        <span class="flex items-center gap-1 min-w-0 overflow-hidden">
          <TournamentChip
            v-for="chip in chips"
            :key="chip.key"
            :variant="chip.variant"
            class="truncate max-w-[10rem]"
          >
            {{ chip.text }}
          </TournamentChip>
        </span>
      </div>
 
      <template v-if="!editing">
        <span
          v-if="hasStatus"
          :class="[
            'shrink-0 inline-flex items-center gap-1 rounded-full px-2 py-0.5',
            statusPillClass,
          ]"
          data-testid="match-status-pill"
        >
          <span
            v-if="isLiveScored"
            class="relative flex w-1.5 h-1.5"
            aria-hidden="true"
          >
            <span
              class="absolute inline-flex h-full w-full rounded-full bg-red-500 opacity-75 animate-ping"
            ></span>
            <span
              class="relative inline-flex rounded-full w-1.5 h-1.5 bg-red-500"
            ></span>
          </span>
          <MatchStatusLabel
            :status="match.match_status"
            :scoring-mode="match.scoring_mode"
            :match-date="match.match_date"
          />
        </span>
        <button
          v-if="canEdit"
          type="button"
          class="shrink-0 -my-2 -mr-1.5 w-11 h-11 flex items-center justify-center rounded-full text-fg-muted hover:text-brand-500 hover:bg-surface-alt focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500"
          :aria-label="`Edit score: ${match.home_team?.name} vs ${match.away_team?.name}`"
          data-testid="edit-score-button"
          @click.stop="startEditing"
        >
          ✎
        </button>
      </template>
      <div v-else class="flex items-center gap-1 shrink-0" @click.stop>
        <button
          type="button"
          class="px-3 h-9 rounded-lg text-xs font-semibold bg-brand-500 text-white disabled:opacity-50"
          data-testid="save-score-button"
          :disabled="saving || !canSubmit"
          @click.stop="submit"
        >
          {{ saving ? '…' : 'Save' }}
        </button>
        <button
          type="button"
          class="px-2 h-9 rounded-lg text-xs font-medium text-fg-muted hover:text-fg"
          aria-label="Cancel score edit"
          data-testid="cancel-score-button"
          :disabled="saving"
          @click.stop="cancel"
        >
          ✕
        </button>
      </div>
    </div>
 
    <!-- Teams: the button that opens the match. While the score is being
         edited it is a plain block, because inputs cannot sit in a button. -->
    <component
      :is="editing ? 'div' : 'button'"
      :type="editing ? undefined : 'button'"
      :aria-label="editing ? undefined : cardLabel"
      :class="[
        'block w-full text-left space-y-1.5 rounded-lg',
        editing
          ? ''
          : 'focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-2 focus-visible:ring-offset-card',
      ]"
      :data-testid="editing ? 'tournament-score-editor' : 'match-select'"
      @click.stop="!editing && $emit('select', match)"
    >
      <!-- The fixture in words, for anyone copying the text. -->
      <span class="sr-only" data-testid="match-fixture-text"
        >{{ match.home_team?.name }} {{ scoreText }}
        {{ match.away_team?.name }}</span
      >
      <div
        v-for="side in sides"
        :key="side.key"
        class="flex items-center gap-2.5 min-w-0"
      >
        <ClubLogo
          v-if="side.club?.logo_url"
          :logo-url="side.club.logo_url"
          :name="side.club.name || side.team?.name || ''"
          size="xs"
        />
        <span
          v-else
          class="w-6 h-6 shrink-0 rounded-full bg-surface-alt flex items-center justify-center text-[10px] font-bold text-fg-muted"
          >{{ initialOf(side.team?.name) }}</span
        >
        <span
          :class="[
            'flex-1 min-w-0 truncate text-sm',
            side.mine || side.won ? 'font-semibold text-fg' : 'text-fg',
            side.lost ? 'text-fg-muted' : '',
          ]"
          :title="side.team?.name"
          >{{ side.team?.name }}</span
        >
        <input
          v-if="editing"
          :ref="el => setInputRef(side.key, el)"
          :value="side.key === 'home' ? homeScore : awayScore"
          type="number"
          min="0"
          inputmode="numeric"
          :aria-label="`${side.team?.name} score`"
          :data-testid="
            side.key === 'home' ? 'edit-home-score' : 'edit-away-score'
          "
          class="score-input w-14 h-10 shrink-0 text-center text-base font-semibold rounded-lg border border-line bg-surface text-fg tabular-nums"
          @input="onScoreInput(side.key, $event)"
          @keyup.enter="side.key === 'home' ? advanceOrSubmit() : submit()"
          @keyup.esc="cancel"
        />
        <span
          v-else-if="played"
          :class="[
            'shrink-0 min-w-[1.5rem] text-right text-base tabular-nums',
            side.lost ? 'font-medium text-fg-muted' : 'font-bold text-fg',
          ]"
          data-testid="team-score"
          >{{ side.score
          }}<span
            v-if="hasPenalties"
            class="ml-1 text-xs font-medium text-fg-muted"
            >({{ side.pens }})</span
          ></span
        >
      </div>
    </component>
 
    <!-- Where it is played, when the feed says (SB-1874). Absent renders
         nothing: no placeholder, no "TBD". -->
    <p
      v-if="locationLabel"
      class="mt-1.5 flex items-center gap-1 min-w-0 text-xs text-fg-muted"
      :title="locationLabel"
      data-testid="match-location"
    >
      <svg
        viewBox="0 0 24 24"
        class="w-3.5 h-3.5 shrink-0"
        fill="none"
        stroke="currentColor"
        stroke-width="2"
        stroke-linecap="round"
        stroke-linejoin="round"
        aria-hidden="true"
      >
        <path d="M12 21s-7-6.2-7-11.5a7 7 0 0 1 14 0C19 14.8 12 21 12 21z" />
        <circle cx="12" cy="9.5" r="2.5" />
      </svg>
      <span class="truncate min-w-0">{{ locationLabel }}</span>
    </p>
 
    <!-- Shootouts exist only because regulation ended level, so the inputs
         only exist then — and only in a bracket round, where a draw has to be
         broken. -->
    <div
      v-if="editing && showPenalties"
      class="flex items-center justify-end gap-1.5 mt-2"
      data-testid="penalty-editor"
      @click.stop
    >
      <span class="text-[11px] uppercase tracking-wide text-fg-muted"
        >Penalties</span
      >
      <input
        v-model="homePenaltyScore"
        type="number"
        min="0"
        inputmode="numeric"
        aria-label="Home penalty score"
        data-testid="edit-home-penalty"
        class="score-input w-12 h-9 text-center text-sm rounded-lg border border-line bg-surface text-fg tabular-nums"
      />
      <span class="text-fg-muted text-xs">-</span>
      <input
        v-model="awayPenaltyScore"
        type="number"
        min="0"
        inputmode="numeric"
        aria-label="Away penalty score"
        data-testid="edit-away-penalty"
        class="score-input w-12 h-9 text-center text-sm rounded-lg border border-line bg-surface text-fg tabular-nums"
      />
    </div>
 
    <p
      v-if="editing && saveError"
      class="mt-1.5 text-xs text-danger-500 text-right"
      role="alert"
      data-testid="save-score-error"
    >
      {{ saveError }}
    </p>
  </div>
</template>
 
<script setup>
import { computed, nextTick, ref, watch } from 'vue';
import ClubLogo from './shared/ClubLogo.vue';
import TournamentChip from './ui/TournamentChip.vue';
import MatchStatusLabel from './ui/MatchStatusLabel.vue';
import {
  ROUND_LABELS_SHORT as ROUND_LABELS,
  SHOOTOUT_ROUNDS,
} from '../utils/tournamentRounds';
import { SCORED_STATUSES, isMyMatch } from '../utils/tournamentStatus';
import { formatKickoff } from '../utils/tournamentDays';
 
const props = defineProps({
  match: { type: Object, required: true },
  // Age-group chip is noise on a single-age tournament — the header already
  // states the age group.
  showAgeChip: { type: Boolean, default: false },
  // Knockout rows show which round they are; group-stage rows show the pool.
  showRoundChip: { type: Boolean, default: false },
  showGroupChip: { type: Boolean, default: true },
  // The signed-in user's club / team, so their own fixtures stand out.
  // Both null (signed out) makes the highlight a silent no-op.
  myClubId: { type: Number, default: null },
  myTeamId: { type: Number, default: null },
  // Whether this viewer may score THIS match. Resolved by the parent, which
  // already holds the auth store, so the row stays a presentation component.
  canEdit: { type: Boolean, default: false },
  // Set by the parent while its PATCH is in flight, and to the API's message
  // if that write fails. A failure keeps the editor open with the typed
  // scores intact — retyping a score you already entered is the worst thing
  // this row could ask of someone standing on a touchline.
  saving: { type: Boolean, default: false },
  saveError: { type: String, default: '' },
  // This match is a tournament Match of the Day (SB-1560).
  isMotd: { type: Boolean, default: false },
  // IANA zone kickoffs are shown in — the venue's (SB-1865). Null = the
  // viewer's own clock.
  timeZone: { type: String, default: null },
  // Off under a time-slot header, which already says when.
  showKickoff: { type: Boolean, default: true },
});
 
const emit = defineEmits(['select', 'save']);
 
const editing = ref(false);
const homeInput = ref(null);
const awayInput = ref(null);
const setInputRef = (key, el) => {
  if (key === 'home') homeInput.value = el;
  else awayInput.value = el;
};
const onScoreInput = (key, event) => {
  if (key === 'home') homeScore.value = event.target.value;
  else awayScore.value = event.target.value;
};
const homeScore = ref('');
const awayScore = ref('');
const homePenaltyScore = ref('');
const awayPenaltyScore = ref('');
 
// Absent is not zero: a match nobody has scored opens with empty boxes, not
// with 0-0, which would be a claim that it finished goalless.
const asField = value => (value == null ? '' : String(value));
 
const startEditing = async () => {
  homeScore.value = asField(props.match.home_score);
  awayScore.value = asField(props.match.away_score);
  homePenaltyScore.value = asField(props.match.home_penalty_score);
  awayPenaltyScore.value = asField(props.match.away_penalty_score);
  editing.value = true;
  // Whoever opened this is holding a phone at the side of a pitch and already
  // knows the score. Land them in the first box with any existing value
  // selected, so typing replaces it (SB-914).
  await nextTick();
  homeInput.value?.focus();
  homeInput.value?.select?.();
};
 
// Enter is the advance key, not a digit count: a scoreline can be two digits
// (10-2), so nothing may jump boxes on the first keystroke.
const advanceOrSubmit = () => {
  if (awayScore.value === '' || awayScore.value == null) {
    awayInput.value?.focus();
    awayInput.value?.select?.();
    return;
  }
  submit();
};
 
const cancel = () => {
  editing.value = false;
};
 
const toScore = value => {
  if (value === '' || value == null) return null;
  const n = Number(value);
  return Number.isInteger(n) && n >= 0 ? n : null;
};
 
const parsedHome = computed(() => toScore(homeScore.value));
const parsedAway = computed(() => toScore(awayScore.value));
 
// Both sides or neither — a half-entered score is not a result.
const canSubmit = computed(
  () => parsedHome.value !== null && parsedAway.value !== null
);
 
// Shootout inputs appear only for a level score in a round that has to
// produce a winner (SHOOTOUT_ROUNDS).
const showPenalties = computed(
  () =>
    SHOOTOUT_ROUNDS.has(props.match.tournament_round) &&
    canSubmit.value &&
    parsedHome.value === parsedAway.value
);
 
const submit = () => {
  if (!canSubmit.value || props.saving) return;
  const payload = {
    match: props.match,
    home_score: parsedHome.value,
    away_score: parsedAway.value,
  };
  if (showPenalties.value) {
    const homePens = toScore(homePenaltyScore.value);
    const awayPens = toScore(awayPenaltyScore.value);
    if (homePens !== null && awayPens !== null) {
      payload.home_penalty_score = homePens;
      payload.away_penalty_score = awayPens;
    }
  }
  emit('save', payload);
};
 
// The parent owns the write, so the editor closes on the transition out of
// `saving` — but only when the write actually succeeded.
watch(
  () => props.saving,
  (isSaving, wasSaving) => {
    if (wasSaving && !isSaving && !props.saveError) editing.value = false;
  }
);
 
const identity = computed(() => ({
  clubId: props.myClubId,
  teamId: props.myTeamId,
}));
 
const mine = computed(() => isMyMatch(props.match, identity.value));
 
const isHomeMine = computed(
  () =>
    mine.value &&
    ((props.myClubId != null &&
      props.match.home_team_club?.id === props.myClubId) ||
      (props.myTeamId != null && props.match.home_team?.id === props.myTeamId))
);
 
const isAwayMine = computed(
  () =>
    mine.value &&
    ((props.myClubId != null &&
      props.match.away_team_club?.id === props.myClubId) ||
      (props.myTeamId != null && props.match.away_team?.id === props.myTeamId))
);
 
const kickoffLabel = computed(() =>
  formatKickoff(props.match.scheduled_kickoff, props.timeZone)
);
 
// Field / venue, when the feed carries one. Most matches do not; the line
// is then simply absent.
const venueLabel = computed(() => {
  const m = props.match;
  return m.field_name || m.field || m.venue_name || m.venue || '';
});
 
// The pitch, as the feed sends it (matches.location, SB-1874). Whitespace
// alone is no location.
const locationLabel = computed(() => (props.match.location || '').trim());
 
// A scoreline is shown only under a status that can have one: stored
// placeholder zeros on an unplayed fixture are not a 0-0 (SB-886).
const played = computed(
  () =>
    props.match.home_score != null &&
    props.match.away_score != null &&
    (props.match.match_status == null ||
      SCORED_STATUSES.includes(props.match.match_status))
);
const hasPenalties = computed(
  () =>
    played.value &&
    props.match.home_penalty_score != null &&
    props.match.away_penalty_score != null
);
 
const scoreText = computed(() => {
  if (!played.value) return 'vs';
  const pens = hasPenalties.value
    ? ` (${props.match.home_penalty_score} – ${props.match.away_penalty_score} pk)`
    : '';
  return `${props.match.home_score} – ${props.match.away_score}${pens}`;
});
 
// Who won, for emphasis only. A finished match with a level score and a
// shootout is decided on penalties.
const winner = computed(() => {
  if (!played.value || props.match.match_status !== 'completed') return null;
  const m = props.match;
  if (m.home_score !== m.away_score) {
    return m.home_score > m.away_score ? 'home' : 'away';
  }
  if (hasPenalties.value && m.home_penalty_score !== m.away_penalty_score) {
    return m.home_penalty_score > m.away_penalty_score ? 'home' : 'away';
  }
  return null;
});
 
const sides = computed(() => {
  const m = props.match;
  return [
    {
      key: 'home',
      team: m.home_team,
      club: m.home_team_club,
      score: m.home_score,
      pens: m.home_penalty_score,
      mine: isHomeMine.value,
    },
    {
      key: 'away',
      team: m.away_team,
      club: m.away_team_club,
      score: m.away_score,
      pens: m.away_penalty_score,
      mine: isAwayMine.value,
    },
  ].map(side => ({
    ...side,
    won: winner.value === side.key,
    lost: winner.value != null && winner.value !== side.key,
  }));
});
 
const initialOf = name => (name ? name.trim().charAt(0).toUpperCase() : '?');
 
// Statuses MatchStatusLabel can name; anything else renders no pill at all.
const KNOWN_STATUSES = [
  'completed',
  'forfeit',
  'live',
  'in_progress',
  'cancelled',
  'postponed',
  'scheduled',
  'tbd',
];
const hasStatus = computed(() =>
  KNOWN_STATUSES.includes(props.match.match_status)
);
const isUnderWay = computed(() =>
  ['live', 'in_progress'].includes(props.match.match_status)
);
const isLiveScored = computed(
  () => isUnderWay.value && props.match.scoring_mode === 'live'
);
const statusPillClass = computed(() => {
  if (isLiveScored.value) return 'bg-red-50 dark:bg-red-950/60';
  if (isUnderWay.value) return 'bg-amber-50 dark:bg-amber-950/60';
  if (props.match.match_status === 'completed') {
    return 'bg-green-50 dark:bg-green-950/50';
  }
  return 'bg-surface-alt';
});
 
// A click that lands on a control inside the card (edit, save, a score
// box) belongs to that control; anywhere else opens the match.
const onCardClick = event => {
  if (editing.value) return;
  if (event?.target?.closest?.('button, input, a, select, textarea')) return;
  emit('select', props.match);
};
 
const cardLabel = computed(() => {
  const m = props.match;
  const when = props.showKickoff && kickoffLabel.value;
  return [
    `${m.home_team?.name ?? 'TBD'} ${scoreText.value} ${m.away_team?.name ?? 'TBD'}`,
    when || null,
    'match details',
  ]
    .filter(Boolean)
    .join(', ');
});
 
const chips = computed(() => {
  const out = [];
  if (props.isMotd) {
    out.push({ key: 'motd', variant: 'motd', text: '◆ Match of the Day' });
  }
  if (props.showAgeChip && props.match.age_group) {
    out.push({ key: 'age', variant: 'age', text: props.match.age_group.name });
  }
  if (props.showRoundChip) {
    const label = ROUND_LABELS[props.match.tournament_round];
    if (label) out.push({ key: 'round', variant: 'round', text: label });
  }
  if (props.showGroupChip && props.match.tournament_group) {
    out.push({
      key: 'group',
      variant: 'group',
      text: props.match.tournament_group,
    });
  }
  return out;
});
</script>
 
<style scoped>
/*
 * Chrome renders a number input's stepper arrows *inside* the box. At the width
 * this editor used, the arrows covered the digit entirely — you could type a
 * score and not see it (SB-914). Nobody steps a scoreline one goal at a time
 * with a mouse anyway; the arrows are pure loss here.
 */
.score-input::-webkit-outer-spin-button,
.score-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
 
.score-input {
  -moz-appearance: textfield;
  appearance: textfield;
}
</style>