@wral/hsot-data 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -521,7 +521,7 @@ function re(a, e) {
521
521
  const t = a[e];
522
522
  return t && t.results.length ? t.results[t.results.length - 1] : null;
523
523
  }
524
- function Nt(a, e, t, s = "") {
524
+ function Mt(a, e, t, s = "") {
525
525
  let r = null;
526
526
  for (const o of a || [])
527
527
  o.sport === e && (t && o.effectiveDate > t || s && o.gender && o.gender !== s || (!r || o.effectiveDate > r.effectiveDate) && (r = o));
@@ -643,20 +643,67 @@ function be(a, e, t) {
643
643
  const s = e.homeTeamId === t ? e.awayTeamId : e.homeTeamId, r = e.homeTeamId === t ? "vs" : "at";
644
644
  return n`${e.state === "live" ? n`<span class="pill live">Live</span> ` : n`${x(e.date, { month: "numeric", day: "numeric" })} `}${r} ${L(a, s)}`;
645
645
  }
646
- const Qe = ["all", "conferences"], ye = "all", oe = (a) => Qe.includes(a) ? a : ye, $e = Number.MAX_SAFE_INTEGER, we = (a, e, t) => {
646
+ const Qe = "https://api.wral.com/search";
647
+ function Ze(a) {
648
+ return a.map((e) => `uri:"${e}"`).join(" OR ");
649
+ }
650
+ function Xe(a, e) {
651
+ const t = String(a || Qe).replace(/\/+$/, ""), s = new URLSearchParams({ query: Ze(e), sort: "score", lang: "en" });
652
+ return `${t}/v1/query?${s}`;
653
+ }
654
+ function ye(a) {
655
+ try {
656
+ const e = new URL(a);
657
+ if (/(^|\.)smugmug\.com$/i.test(e.hostname)) {
658
+ const t = e.pathname.split("/").filter(Boolean).pop() || "", s = !t || /^[ni]-[A-Za-z0-9]+$/.test(t);
659
+ return {
660
+ uri: a,
661
+ title: s ? a : decodeURIComponent(t).replace(/-/g, " "),
662
+ photos: !0
663
+ };
664
+ }
665
+ } catch {
666
+ }
667
+ return { uri: a, title: a };
668
+ }
669
+ async function Je(a, e, t) {
670
+ const r = await ((...l) => fetch(...l))(Xe(a, e));
671
+ if (!r.ok) throw new Error(`search answered ${r.status}`);
672
+ const o = await r.json(), i = new Map((o.items || []).map((l) => [l.uri, l]));
673
+ return e.map((l) => i.get(l) || ye(l));
674
+ }
675
+ function et(a) {
676
+ try {
677
+ const e = new URL(a);
678
+ if (/(^|\.)smugmug\.com$/i.test(e.hostname)) return "Photos";
679
+ const t = e.pathname.split("/").filter(Boolean)[0] || "";
680
+ if (t === "video") return "Video";
681
+ if (t === "news" || t === "story") return "Story";
682
+ } catch {
683
+ }
684
+ return "Coverage";
685
+ }
686
+ function tt(a) {
687
+ const e = /* @__PURE__ */ new Map();
688
+ return (Array.isArray(a) ? a : []).filter((t) => /^https?:\/\//i.test(String(t || ""))).map((t) => {
689
+ const s = et(t), r = (e.get(s) || 0) + 1;
690
+ return e.set(s, r), { href: t, label: r > 1 ? `${s} ${r}` : s };
691
+ });
692
+ }
693
+ const st = ["all", "conferences"], $e = "all", oe = (a) => st.includes(a) ? a : $e, we = Number.MAX_SAFE_INTEGER, xe = (a, e, t) => {
647
694
  const s = a[t];
648
695
  return s && e[s.schoolId] || null;
649
696
  };
650
- function Ze(a, e) {
697
+ function at(a, e) {
651
698
  const t = (a || []).map((s) => e[s.schoolId]?.areaCode).filter(Boolean);
652
699
  return [...new Set(t)].sort();
653
700
  }
654
- function Xe(a, e, t, s) {
655
- return e ? [a.awayTeamId, a.homeTeamId].some((r) => we(t, s, r)?.areaCode === e) : !0;
701
+ function rt(a, e, t, s) {
702
+ return e ? [a.awayTeamId, a.homeTeamId].some((r) => xe(t, s, r)?.areaCode === e) : !0;
656
703
  }
657
- function Je(a, e, t, s) {
658
- const r = (l) => we(t, s, l)?.name || "", o = (l, d) => !l - !d || he(l, d), i = new Map((a || []).map((l) => [l, {
659
- rank: e(l) || $e,
704
+ function ot(a, e, t, s) {
705
+ const r = (l) => xe(t, s, l)?.name || "", o = (l, d) => !l - !d || he(l, d), i = new Map((a || []).map((l) => [l, {
706
+ rank: e(l) || we,
660
707
  away: r(l.awayTeamId),
661
708
  home: r(l.homeTeamId)
662
709
  }]));
@@ -665,25 +712,25 @@ function Je(a, e, t, s) {
665
712
  return m.rank - h.rank || o(m.away, h.away) || o(m.home, h.home) || String(l.time || "").localeCompare(String(d.time || ""));
666
713
  });
667
714
  }
668
- function et(a, e) {
669
- const t = new Map((a || []).map((r) => [r, e(r) || $e])), s = (r) => r.state === "live" ? 0 : 1;
715
+ function nt(a, e) {
716
+ const t = new Map((a || []).map((r) => [r, e(r) || we])), s = (r) => r.state === "live" ? 0 : 1;
670
717
  return [...t.keys()].sort((r, o) => s(r) - s(o) || t.get(r) - t.get(o));
671
718
  }
672
- function tt(a, e) {
719
+ function it(a, e) {
673
720
  if (a.gameType === "conference" && a.conferenceId) {
674
721
  const t = e[a.conferenceId] || null;
675
722
  return { name: t?.name || "Conference", conference: t };
676
723
  }
677
724
  return a.gameType === "playoff" ? { name: "Playoffs", conference: null } : a.gameType === "scrimmage" ? { name: "Scrimmages", conference: null } : { name: "Nonconference", conference: null };
678
725
  }
679
- function st(a, e) {
726
+ function lt(a, e) {
680
727
  const t = /* @__PURE__ */ new Map();
681
728
  return (a || []).forEach((s) => {
682
- const { name: r, conference: o } = tt(s, e);
729
+ const { name: r, conference: o } = it(s, e);
683
730
  t.has(r) || t.set(r, { name: r, conference: o, games: [] }), t.get(r).games.push(s);
684
731
  }), [...t.values()];
685
732
  }
686
- const at = $`
733
+ const ct = $`
687
734
  .toolbar.filters { gap: 0.5rem 1.1rem; }
688
735
  .filters [role="group"] { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
689
736
  .filters .asof { margin-right: 0.1rem; }
@@ -692,9 +739,14 @@ const at = $`
692
739
  @media (max-width: 480px) { .filters .asof { flex-basis: 100%; } }
693
740
  /* Conference headings carry the standings cards' classification pills. */
694
741
  .section-title .pill { margin-left: 0.3rem; vertical-align: 0.1em; }
742
+ /* The desk's coverage links ride in one group with the box-score link, in
743
+ its style, so a narrow row wraps them together instead of leaving a
744
+ lone "Story" beside the matchup and "Box score" on the next line. */
745
+ .gamelist .links { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.6rem; }
746
+ .gamelist .links a { font-size: 0.78rem; }
695
747
  `;
696
- class rt extends w {
697
- static styles = [...A, at];
748
+ class dt extends w {
749
+ static styles = [...A, ct];
698
750
  static properties = {
699
751
  ...w.properties,
700
752
  sport: { type: String },
@@ -743,18 +795,18 @@ class rt extends w {
743
795
  e !== null && (this.view = e), t !== null && (this.areaCode = t);
744
796
  try {
745
797
  const s = new URL(globalThis.location.href), r = (o, i, l) => i && i !== l ? s.searchParams.set(o, i) : s.searchParams.delete(o);
746
- r("view", oe(this.view), ye), r("area", this.areaCode, ""), globalThis.history?.replaceState(null, "", s);
798
+ r("view", oe(this.view), $e), r("area", this.areaCode, ""), globalThis.history?.replaceState(null, "", s);
747
799
  } catch {
748
800
  }
749
801
  }
750
802
  renderView() {
751
- const e = this.ctx, t = y(this.data.conferences), s = [...new Set(this.data.games.map((c) => c.date).filter(Boolean))].sort(), r = oe(this.view), o = Ze(this.data.teams, e.schoolsById), i = o.includes(this.areaCode) ? this.areaCode : "", l = (c) => {
803
+ const e = this.ctx, t = y(this.data.conferences), s = [...new Set(this.data.games.map((c) => c.date).filter(Boolean))].sort(), r = oe(this.view), o = at(this.data.teams, e.schoolsById), i = o.includes(this.areaCode) ? this.areaCode : "", l = (c) => {
752
804
  const f = [c.awayTeamId, c.homeTeamId].map((u) => Z(e.rankings, e.teamsById, u, this.sport, c.date)).filter(Boolean);
753
805
  return f.length ? Math.min(...f) : null;
754
- }, d = this.data.games.filter((c) => c.date === this.date), m = d.filter((c) => Xe(c, i, e.teamsById, e.schoolsById)), h = r === "conferences" ? st(et(m, l), t) : m.length ? [{
806
+ }, d = this.data.games.filter((c) => c.date === this.date), m = d.filter((c) => rt(c, i, e.teamsById, e.schoolsById)), h = r === "conferences" ? lt(nt(m, l), t) : m.length ? [{
755
807
  name: i ? `All games · ${i}` : "All games",
756
808
  conference: null,
757
- games: Je(m, l, e.teamsById, e.schoolsById)
809
+ games: ot(m, l, e.teamsById, e.schoolsById)
758
810
  }] : [];
759
811
  return n`
760
812
  ${j(this, e, {
@@ -814,6 +866,10 @@ class rt extends w {
814
866
  // Each team's score rides in a block beside its name (reader feedback:
815
867
  // a lone score column on the far right read as detached from the teams).
816
868
  // Scheduled games carry their start time on the status pill alone.
869
+ // The desk's coverage links (Game.coverageUrls, already on the games
870
+ // list, so they cost no request) sit before the box score link, labelled
871
+ // from each URL's shape (lib/search.mjs) rather than the site search the
872
+ // box score's coverage cards query.
817
873
  renderGame(e, t) {
818
874
  const s = t.state === "final" || t.state === "live", r = (i, l, d = p) => n`<span class="side">${O(e, i, t.date)}${s ? n`<span class="score">${l}</span>` : p}${d}</span>`, o = We(t);
819
875
  return n`
@@ -823,13 +879,16 @@ class rt extends w {
823
879
  ${o ? n`<span class="ff">${F(e, o === "home" ? t.homeTeamId : t.awayTeamId)} forfeited</span>` : p}
824
880
  <span class="where">${t.venue || ""}</span>
825
881
  ${t.broadcast ? n`<span class="pill class">${t.broadcast}</span>` : p}
826
- <a class="box" href=${g(e.hrefs.game, { sport: this.sport, id: t.id })}>Box score →</a>
882
+ <span class="links">
883
+ ${tt(t.coverageUrls).map((i) => n`<a href=${i.href}>${i.label}</a>`)}
884
+ <a class="box" href=${g(e.hrefs.game, { sport: this.sport, id: t.id })}>Box score →</a>
885
+ </span>
827
886
  </li>
828
887
  `;
829
888
  }
830
889
  }
831
- globalThis?.customElements && !globalThis.customElements.get("hsot-scores") && globalThis.customElements.define("hsot-scores", rt);
832
- class ot extends w {
890
+ globalThis?.customElements && !globalThis.customElements.get("hsot-scores") && globalThis.customElements.define("hsot-scores", dt);
891
+ class ht extends w {
833
892
  static styles = A;
834
893
  static properties = {
835
894
  ...w.properties,
@@ -981,8 +1040,8 @@ class ot extends w {
981
1040
  `;
982
1041
  }
983
1042
  }
984
- globalThis?.customElements && !globalThis.customElements.get("hsot-standings") && globalThis.customElements.define("hsot-standings", ot);
985
- const nt = $`
1043
+ globalThis?.customElements && !globalThis.customElements.get("hsot-standings") && globalThis.customElements.define("hsot-standings", ht);
1044
+ const mt = $`
986
1045
  .hero1 {
987
1046
  border-radius: var(--hsot-radius-md); color: var(--hsot-white);
988
1047
  padding: 1.3rem 1.4rem; display: flex; align-items: center; gap: 1.2rem;
@@ -999,8 +1058,8 @@ const nt = $`
999
1058
  .delta.new { background: var(--hsot-straw); color: #6b5900; border-radius: var(--hsot-radius-xs); padding: 0.1rem 0.3rem; font-size: 0.7rem; }
1000
1059
  .sparkline { vertical-align: middle; }
1001
1060
  `;
1002
- class it extends w {
1003
- static styles = [...A, nt];
1061
+ class pt extends w {
1062
+ static styles = [...A, mt];
1004
1063
  static properties = {
1005
1064
  ...w.properties,
1006
1065
  sport: { type: String },
@@ -1154,8 +1213,8 @@ class it extends w {
1154
1213
  `;
1155
1214
  }
1156
1215
  }
1157
- globalThis?.customElements && !globalThis.customElements.get("hsot-rankings") && globalThis.customElements.define("hsot-rankings", it);
1158
- const lt = $`
1216
+ globalThis?.customElements && !globalThis.customElements.get("hsot-rankings") && globalThis.customElements.define("hsot-rankings", pt);
1217
+ const ft = $`
1159
1218
  .schoolhero { color: var(--hsot-white); padding: 1.6rem 1.25rem 1.3rem; }
1160
1219
  .schoolhero .inner { max-width: 1366px; margin: 0 auto; display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
1161
1220
  .schoolhero .crest {
@@ -1209,8 +1268,8 @@ const lt = $`
1209
1268
  table.data.roster .sub { display: block; font-weight: 400; font-size: 0.78rem; color: var(--hsot-gray-5); }
1210
1269
  }
1211
1270
  `;
1212
- class ct extends w {
1213
- static styles = [...A, lt];
1271
+ class ut extends w {
1272
+ static styles = [...A, ft];
1214
1273
  static properties = {
1215
1274
  ...w.properties,
1216
1275
  schoolId: { type: String, attribute: "school-id" },
@@ -1389,8 +1448,8 @@ class ct extends w {
1389
1448
  `;
1390
1449
  }
1391
1450
  }
1392
- globalThis?.customElements && !globalThis.customElements.get("hsot-school") && globalThis.customElements.define("hsot-school", ct);
1393
- const xe = {
1451
+ globalThis?.customElements && !globalThis.customElements.get("hsot-school") && globalThis.customElements.define("hsot-school", ut);
1452
+ const ke = {
1394
1453
  football: ["quarters", 4],
1395
1454
  flag_football: ["quarters", 4],
1396
1455
  basketball: ["quarters", 4],
@@ -1401,30 +1460,30 @@ const xe = {
1401
1460
  softball: ["innings", 7],
1402
1461
  volleyball: ["sets", 3]
1403
1462
  };
1404
- function ke(a) {
1405
- return (xe[a] || ["quarters", 4])[0];
1463
+ function Ie(a) {
1464
+ return (ke[a] || ["quarters", 4])[0];
1406
1465
  }
1407
1466
  function ee(a) {
1408
- return (xe[a] || ["quarters", 4])[1];
1467
+ return (ke[a] || ["quarters", 4])[1];
1409
1468
  }
1410
- function dt(a, e) {
1411
- const t = ke(a), s = ee(a);
1469
+ function gt(a, e) {
1470
+ const t = Ie(a), s = ee(a);
1412
1471
  if (e <= s || t === "innings" || t === "sets") return String(e);
1413
1472
  const r = e - s;
1414
1473
  return `OT${r > 1 ? r : ""}`;
1415
1474
  }
1416
- function ht(a, e) {
1475
+ function vt(a, e) {
1417
1476
  const t = String(a ?? "").trim();
1418
1477
  let s;
1419
- return (s = /^(\d+)Q$/i.exec(t)) || (s = /^(\d+)H$/i.exec(t)) ? Number(s[1]) : /^half$/i.test(t) ? ke(e) === "halves" ? 1 : 2 : (s = /^(\d*)OT(\d*)$/i.exec(t)) ? ee(e) + Number(s[1] || s[2] || 1) : (s = /^[TB](\d+)$/i.exec(t)) || (s = /^(\d+)(?:st|nd|rd|th)\s*set$/i.exec(t)) || (s = /^set\s*(\d+)$/i.exec(t)) ? Number(s[1]) : null;
1478
+ return (s = /^(\d+)Q$/i.exec(t)) || (s = /^(\d+)H$/i.exec(t)) ? Number(s[1]) : /^half$/i.test(t) ? Ie(e) === "halves" ? 1 : 2 : (s = /^(\d*)OT(\d*)$/i.exec(t)) ? ee(e) + Number(s[1] || s[2] || 1) : (s = /^[TB](\d+)$/i.exec(t)) || (s = /^(\d+)(?:st|nd|rd|th)\s*set$/i.exec(t)) || (s = /^set\s*(\d+)$/i.exec(t)) ? Number(s[1]) : null;
1420
1479
  }
1421
1480
  const N = (a) => Number.isInteger(a) && a >= 0 ? a : null;
1422
- function mt(a) {
1481
+ function bt(a) {
1423
1482
  const e = Array.isArray(a?.scoringPlays) ? a.scoringPlays : [];
1424
1483
  if (!e.length) return null;
1425
1484
  const t = a.sport, s = /* @__PURE__ */ new Map();
1426
1485
  for (const c of e) {
1427
- const f = ht(c?.period, t), u = N(c?.homeScore), v = N(c?.awayScore);
1486
+ const f = vt(c?.period, t), u = N(c?.homeScore), v = N(c?.awayScore);
1428
1487
  if (!f || u === null || v === null) return null;
1429
1488
  const b = s.get(f) || { home: 0, away: 0 };
1430
1489
  b.home = Math.max(b.home, u), b.away = Math.max(b.away, v), s.set(f, b);
@@ -1438,41 +1497,12 @@ function mt(a) {
1438
1497
  const d = N(a.homeScore) ?? 0, m = N(a.awayScore) ?? 0, h = i && l.home === d && l.away === m;
1439
1498
  return i = i && l.home <= d && l.away <= m, { periods: o, reconciled: h, consistent: i };
1440
1499
  }
1441
- function pt(a) {
1500
+ function yt(a) {
1442
1501
  if (Array.isArray(a?.periodScores) && a.periodScores.length) return a.periodScores;
1443
- const e = mt(a);
1502
+ const e = bt(a);
1444
1503
  return e ? a.state === "final" ? e.reconciled ? e.periods : null : e.consistent ? e.periods : null : null;
1445
1504
  }
1446
- const ft = "https://api.wral.com/search";
1447
- function ut(a) {
1448
- return a.map((e) => `uri:"${e}"`).join(" OR ");
1449
- }
1450
- function gt(a, e) {
1451
- const t = String(a || ft).replace(/\/+$/, ""), s = new URLSearchParams({ query: ut(e), sort: "score", lang: "en" });
1452
- return `${t}/v1/query?${s}`;
1453
- }
1454
- function Ie(a) {
1455
- try {
1456
- const e = new URL(a);
1457
- if (/(^|\.)smugmug\.com$/i.test(e.hostname)) {
1458
- const t = e.pathname.split("/").filter(Boolean).pop() || "", s = !t || /^[ni]-[A-Za-z0-9]+$/.test(t);
1459
- return {
1460
- uri: a,
1461
- title: s ? a : decodeURIComponent(t).replace(/-/g, " "),
1462
- photos: !0
1463
- };
1464
- }
1465
- } catch {
1466
- }
1467
- return { uri: a, title: a };
1468
- }
1469
- async function vt(a, e, t) {
1470
- const r = await ((...l) => fetch(...l))(gt(a, e));
1471
- if (!r.ok) throw new Error(`search answered ${r.status}`);
1472
- const o = await r.json(), i = new Map((o.items || []).map((l) => [l.uri, l]));
1473
- return e.map((l) => i.get(l) || Ie(l));
1474
- }
1475
- const bt = $`
1505
+ const $t = $`
1476
1506
  .breadcrumbs { font-size: 0.8125rem; margin: 0.9rem 0 0; color: var(--hsot-gray-5); }
1477
1507
  .breadcrumbs a { text-decoration: none; }
1478
1508
  .scorehead { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: center; padding: 1.4rem 1rem; }
@@ -1528,8 +1558,8 @@ const bt = $`
1528
1558
  .cols { grid-template-columns: 1fr; }
1529
1559
  }
1530
1560
  `;
1531
- class yt extends w {
1532
- static styles = [...A, bt];
1561
+ class wt extends w {
1562
+ static styles = [...A, $t];
1533
1563
  static properties = {
1534
1564
  ...w.properties,
1535
1565
  gameId: { type: String, attribute: "game-id" },
@@ -1559,7 +1589,7 @@ class yt extends w {
1559
1589
  // links (fetchCoverage already degrades per-URL index misses).
1560
1590
  // The embed drops the Coverage grid, so it skips the search
1561
1591
  // round-trip entirely rather than fetching cards it will not render.
1562
- s.length && !this.embed ? vt(this.searchApi, s).catch(() => s.map(Ie)) : Promise.resolve([])
1592
+ s.length && !this.embed ? Je(this.searchApi, s).catch(() => s.map(ye)) : Promise.resolve([])
1563
1593
  ]);
1564
1594
  return {
1565
1595
  game: t,
@@ -1672,10 +1702,10 @@ class yt extends w {
1672
1702
  `;
1673
1703
  }
1674
1704
  renderLineScore(e, t, s) {
1675
- const r = pt(e);
1705
+ const r = yt(e);
1676
1706
  if (!r)
1677
1707
  return e.state === "scheduled" ? n`<p class="empty" style="text-align:center">Period scoring will appear once the game starts.</p>` : p;
1678
- const o = Math.max(ee(e.sport), ...r.map((m) => m.period)), i = (m) => dt(e.sport, m), l = (m, h) => {
1708
+ const o = Math.max(ee(e.sport), ...r.map((m) => m.period)), i = (m) => gt(e.sport, m), l = (m, h) => {
1679
1709
  const c = r.find((f) => f.period === h);
1680
1710
  return c ? c[m] : e.state === "final" ? 0 : "·";
1681
1711
  }, d = (m, h, c) => n`
@@ -1739,9 +1769,9 @@ class yt extends w {
1739
1769
  `;
1740
1770
  }
1741
1771
  }
1742
- globalThis?.customElements && !globalThis.customElements.get("hsot-boxscore") && globalThis.customElements.define("hsot-boxscore", yt);
1743
- const $t = 250, wt = 2;
1744
- class xt extends ce {
1772
+ globalThis?.customElements && !globalThis.customElements.get("hsot-boxscore") && globalThis.customElements.define("hsot-boxscore", wt);
1773
+ const xt = 250, kt = 2;
1774
+ class It extends ce {
1745
1775
  static properties = {
1746
1776
  api: { type: String },
1747
1777
  schoolHref: { type: String, attribute: "school-href" },
@@ -1821,11 +1851,11 @@ class xt extends ce {
1821
1851
  }
1822
1852
  onInput(e) {
1823
1853
  const t = e.target.value.trim();
1824
- if (clearTimeout(this.debounceTimer), t.length < wt) {
1854
+ if (clearTimeout(this.debounceTimer), t.length < kt) {
1825
1855
  this.abortController?.abort(), this.results = [], this.open = !1, this.searched = !1;
1826
1856
  return;
1827
1857
  }
1828
- this.debounceTimer = setTimeout(() => this.search(t), $t);
1858
+ this.debounceTimer = setTimeout(() => this.search(t), xt);
1829
1859
  }
1830
1860
  async search(e) {
1831
1861
  this.abortController?.abort(), this.abortController = new AbortController();
@@ -1918,7 +1948,7 @@ class xt extends ce {
1918
1948
  `;
1919
1949
  }
1920
1950
  }
1921
- globalThis?.customElements && !globalThis.customElements.get("hsot-school-search") && globalThis.customElements.define("hsot-school-search", xt);
1951
+ globalThis?.customElements && !globalThis.customElements.get("hsot-school-search") && globalThis.customElements.define("hsot-school-search", It);
1922
1952
  function Se(a, e) {
1923
1953
  const t = new Map(a.map((d) => [d.id, d])), s = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
1924
1954
  for (const d of e || [])
@@ -1938,17 +1968,17 @@ function Te(a, e = [], t = 0) {
1938
1968
  for (const s of a.children || []) Te(s, e, t + 1);
1939
1969
  return e;
1940
1970
  }
1941
- const kt = (a) => Math.max(1, Math.round(Math.log2(a || 2)));
1942
- function It({ round: a, perGroup: e, groupCount: t = 1 }) {
1943
- const s = kt(e), o = (t === 4 ? s + 2 : t === 2 ? s + 1 : s) - a;
1971
+ const St = (a) => Math.max(1, Math.round(Math.log2(a || 2)));
1972
+ function Tt({ round: a, perGroup: e, groupCount: t = 1 }) {
1973
+ const s = St(e), o = (t === 4 ? s + 2 : t === 2 ? s + 1 : s) - a;
1944
1974
  return o === 0 ? t > 1 ? "Championship" : "Final" : o === 1 ? "Semifinal" : `Round ${a}`;
1945
1975
  }
1946
- function St(a) {
1976
+ function Ct(a) {
1947
1977
  if (!a || !a.length) return "setup";
1948
1978
  const e = Math.max(...a.map((s) => s.round ?? 0)), t = a.filter((s) => (s.round ?? 0) === e);
1949
1979
  return t.length && t.every((s) => s.state === "final") ? "complete" : a.some((s) => s.state !== "scheduled" || s.homeScore || s.awayScore || s.round === 1 && (s.homeTeamId || s.awayTeamId)) ? "active" : "setup";
1950
1980
  }
1951
- function Tt(a, e) {
1981
+ function Bt(a, e) {
1952
1982
  const t = a?.groupNames || [];
1953
1983
  if (t.length >= 2) {
1954
1984
  const r = t.map((o) => ({ key: o, name: o }));
@@ -1957,11 +1987,11 @@ function Tt(a, e) {
1957
1987
  const s = [...new Set((e || []).map((r) => r.bracketGroup).filter(Boolean))];
1958
1988
  return [{ key: null, name: s.length === 1 ? s[0] : "Bracket" }];
1959
1989
  }
1960
- const Ct = (a, e) => e?.key == null ? [...a || []] : (a || []).filter((t) => t.bracketGroup === e.key), ne = (a) => {
1990
+ const Dt = (a, e) => e?.key == null ? [...a || []] : (a || []).filter((t) => t.bracketGroup === e.key), ne = (a) => {
1961
1991
  const e = /(\d+)\s*$/.exec(a.label || "");
1962
1992
  return e ? Number(e[1]) : 1 / 0;
1963
1993
  }, ie = (a, e) => ne(a) - ne(e) || String(a.id).localeCompare(String(e.id));
1964
- function Bt(a, e) {
1994
+ function Ft(a, e) {
1965
1995
  if (a.every((r) => Number.isInteger(r.round))) return (r) => r.round;
1966
1996
  const t = Se(a, e), s = /* @__PURE__ */ new Map();
1967
1997
  for (const r of Array.isArray(t) ? t : [t]) {
@@ -1970,10 +2000,10 @@ function Bt(a, e) {
1970
2000
  }
1971
2001
  return (r) => Number.isInteger(r.round) ? r.round : s.get(r.id) || 1;
1972
2002
  }
1973
- function Dt(a, e, t) {
1974
- const s = Ct(a, t);
2003
+ function zt(a, e, t) {
2004
+ const s = Dt(a, t);
1975
2005
  if (!s.length) return [];
1976
- const r = Bt(a || [], e || []), o = /* @__PURE__ */ new Map();
2006
+ const r = Ft(a || [], e || []), o = /* @__PURE__ */ new Map();
1977
2007
  for (const m of s) {
1978
2008
  const h = r(m);
1979
2009
  o.has(h) || o.set(h, []), o.get(h).push(m);
@@ -1997,7 +2027,7 @@ function Dt(a, e, t) {
1997
2027
  }
1998
2028
  return l;
1999
2029
  }
2000
- function Ft(a, e, t) {
2030
+ function At(a, e, t) {
2001
2031
  const s = a[`${e}TeamId`] || null, r = (t || []).find((i) => i.gameId === a.id && i.slot === e), o = a[`${e}Seed`] ?? r?.seed ?? null;
2002
2032
  return { teamId: s, seed: o, bye: !s && !!r?.isBye };
2003
2033
  }
@@ -2005,14 +2035,14 @@ function Ce(a) {
2005
2035
  const e = H(a);
2006
2036
  return e === "home" || e === "away" ? e : null;
2007
2037
  }
2008
- function zt(a, e) {
2038
+ function Pt(a, e) {
2009
2039
  const t = Se(a || [], e || []);
2010
2040
  if (!t || Array.isArray(t)) return null;
2011
2041
  const s = Ce(t.game);
2012
2042
  return s && t.game[`${s}TeamId`] || null;
2013
2043
  }
2014
2044
  const le = { active: 0, setup: 1, complete: 2 };
2015
- function At(a, { id: e, param: t } = {}) {
2045
+ function Et(a, { id: e, param: t } = {}) {
2016
2046
  const s = a || [];
2017
2047
  if (!s.length) return null;
2018
2048
  for (const r of [e, t]) {
@@ -2022,7 +2052,7 @@ function At(a, { id: e, param: t } = {}) {
2022
2052
  }
2023
2053
  return [...s].sort((r, o) => (le[r.status] ?? 3) - (le[o.status] ?? 3) || String(r.name || "").localeCompare(String(o.name || "")))[0];
2024
2054
  }
2025
- const Pt = $`
2055
+ const _t = $`
2026
2056
  .bracket { display: flex; gap: 1rem; align-items: stretch; overflow-x: auto; padding-bottom: 0.5rem; }
2027
2057
  .round { flex: 0 0 250px; display: flex; flex-direction: column; min-width: 0; }
2028
2058
  .roundhead {
@@ -2068,8 +2098,8 @@ const Pt = $`
2068
2098
  .champ .tname a { color: inherit; text-decoration: none; font-weight: 700; }
2069
2099
  @media (max-width: 720px) { .round { flex-basis: 215px; } }
2070
2100
  `;
2071
- class Et extends w {
2072
- static styles = [A, Pt];
2101
+ class Rt extends w {
2102
+ static styles = [A, _t];
2073
2103
  static properties = {
2074
2104
  ...w.properties,
2075
2105
  sport: { type: String },
@@ -2082,7 +2112,7 @@ class Et extends w {
2082
2112
  super(), this.sport = "football", this.season = "", this.tournamentId = "", this.picked = "", this.group = null;
2083
2113
  }
2084
2114
  async fetchData(e) {
2085
- const t = this.season || _(), s = (await e.listTournaments({ sport: this.sport, season: t })).items, r = new URLSearchParams(globalThis.location?.search || "").get("tournament"), o = At(s, { id: this.picked || this.tournamentId, param: r });
2115
+ const t = this.season || _(), s = (await e.listTournaments({ sport: this.sport, season: t })).items, r = new URLSearchParams(globalThis.location?.search || "").get("tournament"), o = Et(s, { id: this.picked || this.tournamentId, param: r });
2086
2116
  if (!o) return { season: t, tournaments: s, tournament: null };
2087
2117
  const [i, l, d, m, h] = await Promise.all([
2088
2118
  e.listSeedings(o.id),
@@ -2135,7 +2165,7 @@ class Et extends w {
2135
2165
  ${D(this)}
2136
2166
  <div class="card"><div class="empty">No ${this.sport} brackets have been published for the ${e.season} season yet.</div></div>
2137
2167
  `)}`;
2138
- const r = Tt(e.tournament, e.games), o = r.find((c) => c.key === this.group) || r[0], i = (e.tournament.groupNames || []).length >= 2 ? e.tournament.groupNames.length : 1, l = (Number(e.tournament.size) || 0) / i, d = Dt(e.games, e.edges, o), m = St(e.games), h = zt(e.games, e.edges);
2168
+ const r = Bt(e.tournament, e.games), o = r.find((c) => c.key === this.group) || r[0], i = (e.tournament.groupNames || []).length >= 2 ? e.tournament.groupNames.length : 1, l = (Number(e.tournament.size) || 0) / i, d = zt(e.games, e.edges, o), m = Ct(e.games), h = Pt(e.games, e.edges);
2139
2169
  return n`
2140
2170
  ${s}
2141
2171
  ${B(this, n`
@@ -2164,7 +2194,7 @@ class Et extends w {
2164
2194
  <div class="bracket" role="region" aria-label="${o.name} bracket">
2165
2195
  ${d.map((c) => n`
2166
2196
  <section class="round">
2167
- <h3 class="roundhead">${It({ round: c.round, perGroup: l, groupCount: i })}</h3>
2197
+ <h3 class="roundhead">${Tt({ round: c.round, perGroup: l, groupCount: i })}</h3>
2168
2198
  <div class="games">${c.games.map((f) => this.renderMatchup(t, f))}</div>
2169
2199
  </section>`)}
2170
2200
  </div>` : n`<div class="card"><div class="empty">This bracket has no games yet.</div></div>`}
@@ -2187,7 +2217,7 @@ class Et extends w {
2187
2217
  `;
2188
2218
  }
2189
2219
  renderSlot(e, t, s) {
2190
- const { teamId: r, seed: o, bye: i } = Ft(t, s, this.data.seedings), l = Ce(t), d = t.state === "live" || t.state === "final";
2220
+ const { teamId: r, seed: o, bye: i } = At(t, s, this.data.seedings), l = Ce(t), d = t.state === "live" || t.state === "final";
2191
2221
  return n`
2192
2222
  <div class="slot ${l ? l === s ? "winner" : "loser" : ""}">
2193
2223
  <span class="seed">${o ?? ""}</span>
@@ -2197,27 +2227,27 @@ class Et extends w {
2197
2227
  `;
2198
2228
  }
2199
2229
  }
2200
- globalThis?.customElements && !globalThis.customElements.get("hsot-brackets") && globalThis.customElements.define("hsot-brackets", Et);
2230
+ globalThis?.customElements && !globalThis.customElements.get("hsot-brackets") && globalThis.customElements.define("hsot-brackets", Rt);
2201
2231
  export {
2202
2232
  P as D,
2203
- yt as H,
2204
- Et as a,
2205
- it as b,
2206
- ct as c,
2207
- xt as d,
2208
- rt as e,
2209
- ot as f,
2210
- Tt as g,
2233
+ wt as H,
2234
+ Rt as a,
2235
+ pt as b,
2236
+ ut as c,
2237
+ It as d,
2238
+ dt as e,
2239
+ ht as f,
2240
+ Bt as g,
2211
2241
  Se as h,
2212
- zt as i,
2242
+ Pt as i,
2213
2243
  R as j,
2214
- St as k,
2244
+ Ct as k,
2215
2245
  g as l,
2216
2246
  H as m,
2217
- Nt as n,
2218
- It as o,
2247
+ Mt as n,
2248
+ Tt as o,
2219
2249
  Ve as p,
2220
- Dt as q,
2250
+ zt as q,
2221
2251
  I as r,
2222
2252
  ge as s,
2223
2253
  U as t,
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { D as o, H as e, a as t, b as r, c as n, d as c, e as l, f as m, g as i, h as u, i as d, j as H, k as p, l as S, m as k, p as g, r as R, n as f, o as h, q as T, s as b, t as v, u as x, v as B } from "./hsot-brackets-ClfXvdcH.js";
1
+ import { D as o, H as e, a as t, b as r, c as n, d as c, e as l, f as m, g as i, h as u, i as d, j as H, k as p, l as S, m as k, p as g, r as R, n as f, o as h, q as T, s as b, t as v, u as x, v as B } from "./hsot-brackets-CfP_Djqm.js";
2
2
  import { createClient as D } from "./client.mjs";
3
3
  export {
4
4
  o as DEFAULT_HREFS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wral/hsot-data",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "description": "Lit web components for the HighSchoolOT public data pages: scores/schedules, standings, rankings, school pages, and box scores, rendered from api-hsot v1 read payloads.",
6
6
  "author": "WRAL Digital",