@wral/hsot-data 0.5.0 → 0.5.1

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,4 +1,4 @@
1
- import { LitElement as ce, html as n, css as $, nothing as p, svg as ee } from "lit";
1
+ import { LitElement as ce, html as n, css as $, nothing as p, svg as te } from "lit";
2
2
  import { createClient as Be } from "./client.mjs";
3
3
  const P = {
4
4
  game: "/{sport}/game/{id}/",
@@ -29,7 +29,7 @@ function x(a, e) {
29
29
  const [t, s, r] = String(a).split("-").map(Number);
30
30
  return !t || !s || !r ? "TBD" : new Date(t, s - 1, r).toLocaleDateString("en-US", e || { weekday: "short", month: "short", day: "numeric" });
31
31
  }
32
- function W(a) {
32
+ function V(a) {
33
33
  if (!a) return "";
34
34
  const [e, t] = String(a).split(":").map(Number);
35
35
  if (Number.isNaN(e)) return "";
@@ -46,17 +46,17 @@ function _(a = /* @__PURE__ */ new Date()) {
46
46
  const e = a.getFullYear();
47
47
  return a.getMonth() >= 6 ? `${e}-${e + 1}` : `${e - 1}-${e}`;
48
48
  }
49
- function V(a = /* @__PURE__ */ new Date()) {
49
+ function Y(a = /* @__PURE__ */ new Date()) {
50
50
  const e = (t) => String(t).padStart(2, "0");
51
51
  return `${a.getFullYear()}-${e(a.getMonth() + 1)}-${e(a.getDate())}`;
52
52
  }
53
- function ze(a, e = V()) {
53
+ function ze(a, e = Y()) {
54
54
  const t = [...new Set((a || []).filter(Boolean))].sort();
55
55
  if (!t.length || t.includes(e)) return e;
56
56
  const s = t.filter((r) => r < e);
57
57
  return s.length ? s[s.length - 1] : t[0];
58
58
  }
59
- function Y(a) {
59
+ function K(a) {
60
60
  return a ? (a.abbr || a.name || "?").slice(0, 4).toUpperCase() : "?";
61
61
  }
62
62
  function G(a) {
@@ -68,7 +68,7 @@ const Ae = (a) => {
68
68
  const e = ["th", "st", "nd", "rd"], t = a % 100;
69
69
  return a + (e[(t - 20) % 10] || e[t] || e[0]);
70
70
  };
71
- function te(a, e) {
71
+ function q(a, e) {
72
72
  const t = (o) => {
73
73
  const i = /^\d+/.exec(String(o ?? ""));
74
74
  return i ? Number(i[0]) : null;
@@ -88,7 +88,7 @@ function me(a) {
88
88
  const e = [];
89
89
  return a.finish === "overtime" && e.push("OT"), a.finish === "shootout" && e.push("PK-SO"), a.forfeit && a.forfeit !== "none" && e.push("Forfeit"), { kind: "final", label: `Final${e.length ? ` · ${e.join(" · ")}` : ""}` };
90
90
  }
91
- return a.state === "postponed" ? { kind: "warn", label: "Postponed" } : a.state === "canceled" ? { kind: "warn", label: "Canceled" } : { kind: "sched", label: `${x(a.date, { month: "short", day: "numeric" })} · ${W(a.time)}`.replace(/ · $/, "") };
91
+ return a.state === "postponed" ? { kind: "warn", label: "Postponed" } : a.state === "canceled" ? { kind: "warn", label: "Canceled" } : { kind: "sched", label: `${x(a.date, { month: "short", day: "numeric" })} · ${V(a.time)}`.replace(/ · $/, "") };
92
92
  }
93
93
  const Pe = ["boys", "girls"];
94
94
  function pe(a, e) {
@@ -97,11 +97,11 @@ function pe(a, e) {
97
97
  function fe(a, e) {
98
98
  return e ? (a || []).filter((t) => pe(t, e)) : a || [];
99
99
  }
100
- function q(a) {
100
+ function W(a) {
101
101
  const e = new Set((a || []).map((t) => t && t.gender));
102
102
  return Pe.filter((t) => e.has(t));
103
103
  }
104
- const Ee = (a) => q(a).length === 2, _e = /* @__PURE__ */ new Set(["game", "story", "page", "forum", "video", "gallery"]);
104
+ const Ee = (a) => W(a).length === 2, _e = /* @__PURE__ */ new Set(["game", "story", "page", "forum", "video", "gallery"]);
105
105
  function S(a) {
106
106
  let e = String(a || "").replace(/^[a-z][a-z0-9+.-]*:\/\/[^/#?]*/i, "");
107
107
  const t = e.indexOf("#");
@@ -212,7 +212,7 @@ class w extends ce {
212
212
  return n``;
213
213
  }
214
214
  }
215
- const b = (a) => Object.fromEntries((a || []).map((e) => [e.id, e])), Me = $`
215
+ const y = (a) => Object.fromEntries((a || []).map((e) => [e.id, e])), Me = $`
216
216
  :host {
217
217
  --hsot-red: var(--color-red, #D1232A);
218
218
  --hsot-red-deep: var(--color-red-dark, #951C21);
@@ -514,7 +514,7 @@ function ge(a, e) {
514
514
  return { team: t, rec: s, confPct: se(s.cw, s.cl, s.ct), overallPct: se(s.w, s.l, s.t) };
515
515
  }).sort((t, s) => s.confPct - t.confPct || s.overallPct - t.overallPct || s.rec.pf - s.rec.pa - (t.rec.pf - t.rec.pa));
516
516
  }
517
- function K(a, e) {
517
+ function Q(a, e) {
518
518
  return a.filter((t) => (t.homeTeamId === e || t.awayTeamId === e) && (t.state === "scheduled" || t.state === "live") && t.gameType !== "scrimmage").sort((t, s) => String(t.date).localeCompare(String(s.date)))[0] || null;
519
519
  }
520
520
  function re(a, e) {
@@ -527,7 +527,7 @@ function Nt(a, e, t, s = "") {
527
527
  o.sport === e && (t && o.effectiveDate > t || s && o.gender && o.gender !== s || (!r || o.effectiveDate > r.effectiveDate) && (r = o));
528
528
  return r;
529
529
  }
530
- function Q(a, e, t, s, r) {
530
+ function Z(a, e, t, s, r) {
531
531
  const o = e[t];
532
532
  if (!o) return null;
533
533
  const i = /* @__PURE__ */ new Map();
@@ -603,17 +603,17 @@ function C(a, e = 26) {
603
603
  const s = a.colorPrimary || "#030711", r = G(s);
604
604
  return n`<span class="swatch" aria-hidden="true"
605
605
  style="width:${e}px;height:${e}px;background:${s};color:${r};font-size:${Math.max(8, e * 0.28)}px"
606
- >${Y(a)}</span>`;
606
+ >${K(a)}</span>`;
607
607
  }
608
- function Z(a, e, t) {
609
- const s = Q(a.rankings, a.teamsById, e, a.sport, t);
608
+ function X(a, e, t) {
609
+ const s = Z(a.rankings, a.teamsById, e, a.sport, t);
610
610
  return s ? n`<span class="rankbadge">#${s}</span>` : p;
611
611
  }
612
612
  function O(a, e, t) {
613
613
  const s = T(a, e);
614
- return s ? n`${Z(a, e, t)}<a href=${g(a.hrefs.school, { id: s.id })}>${s.name}</a>` : n`<span class="mut">TBD</span>`;
614
+ return s ? n`${X(a, e, t)}<a href=${g(a.hrefs.school, { id: s.id })}>${s.name}</a>` : n`<span class="mut">TBD</span>`;
615
615
  }
616
- function X(a, e, t = 5) {
616
+ function J(a, e, t = 5) {
617
617
  const s = a.records[e];
618
618
  if (!s || !s.results.length) return n`<span class="mut">·</span>`;
619
619
  const r = s.results.slice(-1 * t);
@@ -670,14 +670,18 @@ function et(a, e) {
670
670
  return [...t.keys()].sort((r, o) => s(r) - s(o) || t.get(r) - t.get(o));
671
671
  }
672
672
  function tt(a, e) {
673
- return a.gameType === "conference" && a.conferenceId ? e[a.conferenceId]?.name || "Conference" : a.gameType === "playoff" ? "Playoffs" : a.gameType === "scrimmage" ? "Scrimmages" : "Nonconference";
673
+ if (a.gameType === "conference" && a.conferenceId) {
674
+ const t = e[a.conferenceId] || null;
675
+ return { name: t?.name || "Conference", conference: t };
676
+ }
677
+ return a.gameType === "playoff" ? { name: "Playoffs", conference: null } : a.gameType === "scrimmage" ? { name: "Scrimmages", conference: null } : { name: "Nonconference", conference: null };
674
678
  }
675
679
  function st(a, e) {
676
680
  const t = /* @__PURE__ */ new Map();
677
681
  return (a || []).forEach((s) => {
678
- const r = tt(s, e);
679
- t.has(r) || t.set(r, []), t.get(r).push(s);
680
- }), t;
682
+ const { name: r, conference: o } = tt(s, e);
683
+ t.has(r) || t.set(r, { name: r, conference: o, games: [] }), t.get(r).games.push(s);
684
+ }), [...t.values()];
681
685
  }
682
686
  const at = $`
683
687
  .toolbar.filters { gap: 0.5rem 1.1rem; }
@@ -686,6 +690,8 @@ const at = $`
686
690
  /* A phone can't fit the label and six chips on one line; the label takes
687
691
  its own row so the chips stay together instead of stranding the last. */
688
692
  @media (max-width: 480px) { .filters .asof { flex-basis: 100%; } }
693
+ /* Conference headings carry the standings cards' classification pills. */
694
+ .section-title .pill { margin-left: 0.3rem; vertical-align: 0.1em; }
689
695
  `;
690
696
  class rt extends w {
691
697
  static styles = [...A, at];
@@ -724,8 +730,8 @@ class rt extends w {
724
730
  }
725
731
  get ctx() {
726
732
  return (!this._ctx || this._ctxData !== this.data) && (this._ctx = {
727
- teamsById: b(this.data.teams),
728
- schoolsById: b(this.data.schools),
733
+ teamsById: y(this.data.teams),
734
+ schoolsById: y(this.data.schools),
729
735
  records: R(this.data.games),
730
736
  rankings: this.data.rankings,
731
737
  hrefs: z(this),
@@ -742,10 +748,14 @@ class rt extends w {
742
748
  }
743
749
  }
744
750
  renderView() {
745
- const e = this.ctx, t = b(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) => {
746
- const f = [c.awayTeamId, c.homeTeamId].map((u) => Q(e.rankings, e.teamsById, u, this.sport, c.date)).filter(Boolean);
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) => {
752
+ const f = [c.awayTeamId, c.homeTeamId].map((u) => Z(e.rankings, e.teamsById, u, this.sport, c.date)).filter(Boolean);
747
753
  return f.length ? Math.min(...f) : null;
748
- }, 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) : new Map(m.length ? [[i ? `All games · ${i}` : "All games", Je(m, l, e.teamsById, e.schoolsById)]] : []);
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 ? [{
755
+ name: i ? `All games · ${i}` : "All games",
756
+ conference: null,
757
+ games: Je(m, l, e.teamsById, e.schoolsById)
758
+ }] : [];
749
759
  return n`
750
760
  ${j(this, e, {
751
761
  title: n`${k(this.sport)} scores &amp; schedules`,
@@ -760,7 +770,7 @@ class rt extends w {
760
770
  this.date = c.target.value;
761
771
  }}>
762
772
  ${(s.includes(this.date) ? s : [...s, this.date].sort()).map((c) => n`<option value=${c} ?selected=${c === this.date}>
763
- ${x(c, { weekday: "short", month: "short", day: "numeric" })}${c === V() ? " · today" : ""}
773
+ ${x(c, { weekday: "short", month: "short", day: "numeric" })}${c === Y() ? " · today" : ""}
764
774
  </option>`)}
765
775
  </select>
766
776
  <button class="chip" ?disabled=${s.indexOf(this.date) <= 0}
@@ -792,10 +802,10 @@ class rt extends w {
792
802
  ${d.length ? p : n`<p class="empty">No ${this.sport} games on this date.</p>`}
793
803
  ${d.length && !m.length ? n`<p class="empty">No ${this.sport} games in the ${i} area code on this date.
794
804
  <button class="chip" @click=${() => this.pick({ area: "" })}>Every area</button></p>` : p}
795
- ${[...h.entries()].map(([c, f]) => n`
796
- <div class="section-title">${c}</div>
805
+ ${h.map(({ name: c, conference: f, games: u }) => n`
806
+ <div class="section-title">${c}${[...f?.classifications || []].sort(q).map((v) => n`<span class="pill class">${v}</span>`)}</div>
797
807
  <div class="card"><ul class="gamelist">
798
- ${f.map((u) => this.renderGame(e, u))}
808
+ ${u.map((v) => this.renderGame(e, v))}
799
809
  </ul></div>
800
810
  `)}
801
811
  `)}
@@ -840,7 +850,7 @@ class ot extends w {
840
850
  */
841
851
  get viewGender() {
842
852
  if (this.gender) return this.gender;
843
- const e = q(this.data?.teams);
853
+ const e = W(this.data?.teams);
844
854
  return e.length < 2 ? "" : e.includes(this.pickedGender) ? this.pickedGender : e[0];
845
855
  }
846
856
  async fetchData(e) {
@@ -868,8 +878,8 @@ class ot extends w {
868
878
  }
869
879
  get ctx() {
870
880
  return (!this._ctx || this._ctxData !== this.data || this._ctxGender !== this.viewGender) && (this._ctx = {
871
- teamsById: b(this.data.teams),
872
- schoolsById: b(this.data.schools),
881
+ teamsById: y(this.data.teams),
882
+ schoolsById: y(this.data.schools),
873
883
  records: R(this.data.games),
874
884
  rankings: this.data.rankings,
875
885
  hrefs: z(this),
@@ -880,7 +890,7 @@ class ot extends w {
880
890
  }, this._ctxData = this.data, this._ctxGender = this.viewGender), this._ctx;
881
891
  }
882
892
  renderView() {
883
- const e = this.ctx, t = this.viewGender, s = this.gender ? [] : q(this.data.teams), r = ["All", ...[...new Set(this.data.conferences.flatMap((i) => i.classifications || []))].sort(te)].slice(0, 9), o = this.data.conferences.filter((i) => i.active !== !1).filter((i) => this.classFilter === "All" || (i.classifications || []).includes(this.classFilter)).sort(he);
893
+ const e = this.ctx, t = this.viewGender, s = this.gender ? [] : W(this.data.teams), r = ["All", ...[...new Set(this.data.conferences.flatMap((i) => i.classifications || []))].sort(q)].slice(0, 9), o = this.data.conferences.filter((i) => i.active !== !1).filter((i) => this.classFilter === "All" || (i.classifications || []).includes(this.classFilter)).sort(he);
884
894
  return n`
885
895
  ${j(this, e, {
886
896
  title: n`${t ? `${k(t)} ` : ""}${k(this.sport)} standings`,
@@ -912,7 +922,7 @@ class ot extends w {
912
922
  this.query = i.target.value;
913
923
  }}>
914
924
  <span class="spacer"></span>
915
- <span class="asof">Records through ${x(V(), { month: "long", day: "numeric" })} · conference games count toward both records · scrimmages toward neither</span>
925
+ <span class="asof">Records through ${x(Y(), { month: "long", day: "numeric" })} · conference games count toward both records · scrimmages toward neither</span>
916
926
  </div>
917
927
  ${o.map((i) => this.renderConference(e, i))}
918
928
  `)}
@@ -926,7 +936,7 @@ class ot extends w {
926
936
  <div class="card">
927
937
  <div class="card-head">
928
938
  <h2>${t.name}</h2>
929
- ${[...t.classifications || []].sort(te).map((i) => n`<span class="pill class">${i}</span>`)}
939
+ ${[...t.classifications || []].sort(q).map((i) => n`<span class="pill class">${i}</span>`)}
930
940
  <span class="meta">${o.length} teams · membership derives from teams</span>
931
941
  </div>
932
942
  <div class="tablewrap"><table class="data">
@@ -945,7 +955,7 @@ class ot extends w {
945
955
  renderRow(e, t, s, r) {
946
956
  const o = e.schoolsById[t.team.schoolId], i = o?.name || t.team.name || "TBD";
947
957
  if (r && !i.toLowerCase().includes(r)) return p;
948
- const l = t.rec.pf - t.rec.pa, d = K(this.data.games, t.team.id), m = () => {
958
+ const l = t.rec.pf - t.rec.pa, d = Q(this.data.games, t.team.id), m = () => {
949
959
  location.href = g(e.hrefs.school, { id: t.team.schoolId });
950
960
  };
951
961
  return n`
@@ -954,7 +964,7 @@ class ot extends w {
954
964
  }}>
955
965
  <td class="mut">${s + 1}</td>
956
966
  <td class="teamcell">
957
- ${C(o)}${Z(e, t.team.id, null)}
967
+ ${C(o)}${X(e, t.team.id, null)}
958
968
  <a href=${g(e.hrefs.school, { id: t.team.schoolId })}>${i}</a>
959
969
  </td>
960
970
  <td class="num">${I(t.rec, !0)}</td>
@@ -965,7 +975,7 @@ class ot extends w {
965
975
  <td class="num">${t.rec.pa}</td>
966
976
  <td class="num" style="color:${l >= 0 ? "var(--hsot-win)" : "var(--hsot-loss)"}">${l > 0 ? "+" : ""}${l}</td>
967
977
  <td>${U(t.rec.results) || "·"}</td>
968
- <td>${X(e, t.team.id)}</td>
978
+ <td>${J(e, t.team.id)}</td>
969
979
  <td>${be(e, d, t.team.id)}</td>
970
980
  </tr>
971
981
  `;
@@ -1025,8 +1035,8 @@ class it extends w {
1025
1035
  }
1026
1036
  get ctx() {
1027
1037
  return (!this._ctx || this._ctxData !== this.data) && (this._ctx = {
1028
- teamsById: b(this.data.teams),
1029
- schoolsById: b(this.data.schools),
1038
+ teamsById: y(this.data.teams),
1039
+ schoolsById: y(this.data.schools),
1030
1040
  records: R(this.data.games),
1031
1041
  rankings: this.data.polls,
1032
1042
  hrefs: z(this),
@@ -1037,8 +1047,8 @@ class it extends w {
1037
1047
  const l = t.map((c, f) => {
1038
1048
  const u = (c.teamIds || []).indexOf(e);
1039
1049
  if (u === -1) return null;
1040
- const y = t.length === 1 ? 96 / 2 : f / (t.length - 1) * 90 + 3, v = 3 + u / 24 * 20;
1041
- return { x: y, y: v };
1050
+ const v = t.length === 1 ? 96 / 2 : f / (t.length - 1) * 90 + 3, b = 3 + u / 24 * 20;
1051
+ return { x: v, y: b };
1042
1052
  }), d = [];
1043
1053
  let m = [];
1044
1054
  if (l.forEach((c) => {
@@ -1046,9 +1056,9 @@ class it extends w {
1046
1056
  }), m.length && d.push(m), !d.length) return p;
1047
1057
  const h = l[s];
1048
1058
  return n`<svg class="sparkline" width=${96} height=${26} viewBox="0 0 ${96} ${26}" role="img" aria-label="rank history">
1049
- ${d.map((c) => ee`<polyline fill="none" stroke="var(--hsot-red)" stroke-width="2"
1059
+ ${d.map((c) => te`<polyline fill="none" stroke="var(--hsot-red)" stroke-width="2"
1050
1060
  points=${c.map((f) => `${f.x.toFixed(1)},${f.y.toFixed(1)}`).join(" ")}></polyline>`)}
1051
- ${h ? ee`<circle cx=${h.x.toFixed(1)} cy=${h.y.toFixed(1)} r="3" fill="var(--hsot-black)"></circle>` : p}
1061
+ ${h ? te`<circle cx=${h.x.toFixed(1)} cy=${h.y.toFixed(1)} r="3" fill="var(--hsot-black)"></circle>` : p}
1052
1062
  </svg>`;
1053
1063
  }
1054
1064
  movement(e, t, s) {
@@ -1058,7 +1068,7 @@ class it extends w {
1058
1068
  renderView() {
1059
1069
  const e = this.ctx, t = this.data.polls;
1060
1070
  if (!t.length) return n`<div class="view"><p class="empty">No ${this.sport} polls published yet this season.</p></div>`;
1061
- const s = Math.max(0, t.findIndex((c) => c.effectiveDate === this.pollDate)), r = t[s] || t[0], o = t[s + 1] || null, i = t.slice().reverse(), l = i.indexOf(r), d = b(this.data.conferences), m = (r.teamIds || [])[0], h = m ? T(e, m) : null;
1071
+ const s = Math.max(0, t.findIndex((c) => c.effectiveDate === this.pollDate)), r = t[s] || t[0], o = t[s + 1] || null, i = t.slice().reverse(), l = i.indexOf(r), d = y(this.data.conferences), m = (r.teamIds || [])[0], h = m ? T(e, m) : null;
1062
1072
  return n`
1063
1073
  ${j(this, e, {
1064
1074
  title: n`${k(this.sport)} Top 25`,
@@ -1122,12 +1132,12 @@ class it extends w {
1122
1132
  renderRow(e, t, s, r, o, i, l, d) {
1123
1133
  const m = T(e, l);
1124
1134
  if (!m) return p;
1125
- const h = e.records[l], c = re(e.records, l), f = K(this.data.games, l), u = i[e.teamsById[l]?.conferenceId], y = () => {
1135
+ const h = e.records[l], c = re(e.records, l), f = Q(this.data.games, l), u = i[e.teamsById[l]?.conferenceId], v = () => {
1126
1136
  location.href = g(e.hrefs.school, { id: m.id });
1127
1137
  };
1128
1138
  return n`
1129
- <tr class="rowlink" @click=${(v) => {
1130
- v.target.closest("a") || y();
1139
+ <tr class="rowlink" @click=${(b) => {
1140
+ b.target.closest("a") || v();
1131
1141
  }}>
1132
1142
  <td class="num" style="font-weight:700">${d}</td>
1133
1143
  <td>${this.movement(t, s, l)}</td>
@@ -1218,7 +1228,7 @@ class ct extends w {
1218
1228
  t && !this.sport && (this.sport = t), s && !this.gender && (this.gender = s);
1219
1229
  }
1220
1230
  async fetchData(e) {
1221
- const t = this.season || _(), s = await e.getSchool(this.schoolId), o = (await e.listTeams({ schoolId: this.schoolId })).items, i = this.sport || "football", l = o.find((v) => v.id === this.activeTeamId) || o.find((v) => v.sport === i && pe(v, this.gender)) || o.find((v) => v.sport === i) || o[0] || null, [d, m, h, c, f, u, y] = await Promise.all([
1231
+ const t = this.season || _(), s = await e.getSchool(this.schoolId), o = (await e.listTeams({ schoolId: this.schoolId })).items, i = this.sport || "football", l = o.find((b) => b.id === this.activeTeamId) || o.find((b) => b.sport === i && pe(b, this.gender)) || o.find((b) => b.sport === i) || o[0] || null, [d, m, h, c, f, u, v] = await Promise.all([
1222
1232
  l ? e.listGames({ sport: l.sport, season: t }) : Promise.resolve({ items: [] }),
1223
1233
  l ? e.listTeams({ sport: l.sport }) : Promise.resolve({ items: [] }),
1224
1234
  e.listSchools(),
@@ -1239,14 +1249,14 @@ class ct extends w {
1239
1249
  schools: h.items,
1240
1250
  conferences: c.items,
1241
1251
  rankings: f.items,
1242
- roster: u.items.find((v) => v.season === t) || null,
1243
- players: y.items
1252
+ roster: u.items.find((b) => b.season === t) || null,
1253
+ players: v.items
1244
1254
  };
1245
1255
  }
1246
1256
  get ctx() {
1247
1257
  return (!this._ctx || this._ctxData !== this.data) && (this._ctx = {
1248
- teamsById: b(this.data.allTeams.length ? this.data.allTeams : this.data.teams),
1249
- schoolsById: b(this.data.schools),
1258
+ teamsById: y(this.data.allTeams.length ? this.data.allTeams : this.data.teams),
1259
+ schoolsById: y(this.data.schools),
1250
1260
  records: R(this.data.games),
1251
1261
  rankings: this.data.rankings,
1252
1262
  hrefs: z(this),
@@ -1264,11 +1274,11 @@ class ct extends w {
1264
1274
  renderView() {
1265
1275
  const { school: e, teams: t, active: s, season: r } = this.data;
1266
1276
  if (!e) return n`<div class="view"><p class="empty">School not found.</p></div>`;
1267
- const o = this.ctx, i = G(e.colorPrimary || "#030711"), l = (e.adm || [])[0], d = b(this.data.conferences), m = s ? d[s.conferenceId] : null;
1277
+ const o = this.ctx, i = G(e.colorPrimary || "#030711"), l = (e.adm || [])[0], d = y(this.data.conferences), m = s ? d[s.conferenceId] : null;
1268
1278
  return n`
1269
1279
  <div class="schoolhero" style="background:linear-gradient(115deg, ${e.colorPrimary || "#030711"} 0%, ${e.colorPrimary || "#030711"} 55%, var(--hsot-black) 100%);color:${i}">
1270
1280
  <div class="inner">
1271
- ${M(e, 84) ? n`<img class="crest logo" alt="" loading="lazy" src=${M(e, 84)} />` : n`<div class="crest" style="background:${e.colorSecondary || "#7C7C7C"};color:${G(e.colorSecondary || "#7C7C7C")}">${Y(e)}</div>`}
1281
+ ${M(e, 84) ? n`<img class="crest logo" alt="" loading="lazy" src=${M(e, 84)} />` : n`<div class="crest" style="background:${e.colorSecondary || "#7C7C7C"};color:${G(e.colorSecondary || "#7C7C7C")}">${K(e)}</div>`}
1272
1282
  <div style="min-width:260px">
1273
1283
  <h1>${e.name} <span class="mascot">${e.mascot || ""}</span></h1>
1274
1284
  <div class="facts">
@@ -1296,7 +1306,7 @@ class ct extends w {
1296
1306
  `;
1297
1307
  }
1298
1308
  renderTeam(e, t, s, r) {
1299
- const o = e.records[t.id] || { w: 0, l: 0, t: 0, cw: 0, cl: 0, ct: 0, pf: 0, pa: 0, results: [] }, i = o.w + o.l + o.t, l = s ? fe(this.data.allTeams.filter((c) => c.conferenceId === s.id), t.gender) : [], d = s ? ge(l, e.records).findIndex((c) => c.team.id === t.id) + 1 : 0, m = Q(e.rankings, e.teamsById, t.id, t.sport, null), h = this.data.games.filter((c) => c.homeTeamId === t.id || c.awayTeamId === t.id).sort((c, f) => String(c.date).localeCompare(String(f.date)));
1309
+ const o = e.records[t.id] || { w: 0, l: 0, t: 0, cw: 0, cl: 0, ct: 0, pf: 0, pa: 0, results: [] }, i = o.w + o.l + o.t, l = s ? fe(this.data.allTeams.filter((c) => c.conferenceId === s.id), t.gender) : [], d = s ? ge(l, e.records).findIndex((c) => c.team.id === t.id) + 1 : 0, m = Z(e.rankings, e.teamsById, t.id, t.sport, null), h = this.data.games.filter((c) => c.homeTeamId === t.id || c.awayTeamId === t.id).sort((c, f) => String(c.date).localeCompare(String(f.date)));
1300
1310
  return n`
1301
1311
  <div class="tiles">
1302
1312
  <div class="tile"><div class="k">Overall</div><div class="v">${I(o)}</div><div class="s">${i} games played</div></div>
@@ -1305,7 +1315,7 @@ class ct extends w {
1305
1315
  <div class="tile"><div class="k">Points</div><div class="v">${i ? (o.pf / i).toFixed(1) : "0.0"}</div>
1306
1316
  <div class="s">scored per game · ${i ? (o.pa / i).toFixed(1) : "0.0"} allowed</div></div>
1307
1317
  <div class="tile"><div class="k">Streak</div><div class="v">${U(o.results) || "·"}</div>
1308
- <div class="s">last 5: ${X(e, t.id)}</div></div>
1318
+ <div class="s">last 5: ${J(e, t.id)}</div></div>
1309
1319
  <div class="tile"><div class="k">HSOT Top 25</div><div class="v">${m ? `#${m}` : "NR"}</div>
1310
1320
  <div class="s"><a href=${g(e.hrefs.section, { sport: t.sport, view: "rankings" })}>full poll</a></div></div>
1311
1321
  </div>
@@ -1329,7 +1339,7 @@ class ct extends w {
1329
1339
  }
1330
1340
  renderGameRow(e, t, s) {
1331
1341
  const r = s.homeTeamId === t.id, o = r ? s.awayTeamId : s.homeTeamId, i = r ? s.homeScore : s.awayScore, l = r ? s.awayScore : s.homeScore;
1332
- let d = n`<span class="mut">${W(s.time)}</span>`;
1342
+ let d = n`<span class="mut">${V(s.time)}</span>`;
1333
1343
  if (s.state === "final") {
1334
1344
  const h = H(s), c = h === "tie" ? "T" : h === (r ? "home" : "away") ? "W" : "L";
1335
1345
  d = n`<span class=${c}>${c}</span> ${i}-${l}${s.finish === "overtime" ? n` <span class="mut">OT</span>` : p}${s.forfeit && s.forfeit !== "none" ? n` <span class="mut">FF</span>` : p}`;
@@ -1353,7 +1363,7 @@ class ct extends w {
1353
1363
  const s = this.data.roster;
1354
1364
  if (!s)
1355
1365
  return n`<p class="empty">Roster not published for ${t}.</p>`;
1356
- const r = Ke(s, 560), o = this.data.school?.name || "", i = b(this.data.players), l = s.entries.slice().sort((m, h) => (m.number || 0) - (h.number || 0)), d = l.some((m) => i[m.playerId]?.college);
1366
+ const r = Ke(s, 560), o = this.data.school?.name || "", i = y(this.data.players), l = s.entries.slice().sort((m, h) => (m.number || 0) - (h.number || 0)), d = l.some((m) => i[m.playerId]?.college);
1357
1367
  return n`
1358
1368
  ${r ? n`<img class="rosterphoto" src=${r} loading="lazy" decoding="async"
1359
1369
  alt="${o} ${e.name} ${t} team photo" />` : p}
@@ -1394,11 +1404,11 @@ const xe = {
1394
1404
  function ke(a) {
1395
1405
  return (xe[a] || ["quarters", 4])[0];
1396
1406
  }
1397
- function J(a) {
1407
+ function ee(a) {
1398
1408
  return (xe[a] || ["quarters", 4])[1];
1399
1409
  }
1400
1410
  function dt(a, e) {
1401
- const t = ke(a), s = J(a);
1411
+ const t = ke(a), s = ee(a);
1402
1412
  if (e <= s || t === "innings" || t === "sets") return String(e);
1403
1413
  const r = e - s;
1404
1414
  return `OT${r > 1 ? r : ""}`;
@@ -1406,7 +1416,7 @@ function dt(a, e) {
1406
1416
  function ht(a, e) {
1407
1417
  const t = String(a ?? "").trim();
1408
1418
  let s;
1409
- 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)) ? J(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;
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;
1410
1420
  }
1411
1421
  const N = (a) => Number.isInteger(a) && a >= 0 ? a : null;
1412
1422
  function mt(a) {
@@ -1414,16 +1424,16 @@ function mt(a) {
1414
1424
  if (!e.length) return null;
1415
1425
  const t = a.sport, s = /* @__PURE__ */ new Map();
1416
1426
  for (const c of e) {
1417
- const f = ht(c?.period, t), u = N(c?.homeScore), y = N(c?.awayScore);
1418
- if (!f || u === null || y === null) return null;
1419
- const v = s.get(f) || { home: 0, away: 0 };
1420
- v.home = Math.max(v.home, u), v.away = Math.max(v.away, y), s.set(f, v);
1427
+ const f = ht(c?.period, t), u = N(c?.homeScore), v = N(c?.awayScore);
1428
+ if (!f || u === null || v === null) return null;
1429
+ const b = s.get(f) || { home: 0, away: 0 };
1430
+ b.home = Math.max(b.home, u), b.away = Math.max(b.away, v), s.set(f, b);
1421
1431
  }
1422
1432
  const r = Math.max(...s.keys()), o = [];
1423
1433
  let i = !0, l = { home: 0, away: 0 };
1424
1434
  for (let c = 1; c <= r; c += 1) {
1425
- const f = s.get(c) || l, u = f.home - l.home, y = f.away - l.away;
1426
- (u < 0 || y < 0) && (i = !1), o.push({ period: c, home: Math.max(u, 0), away: Math.max(y, 0) }), l = { home: Math.max(f.home, l.home), away: Math.max(f.away, l.away) };
1435
+ const f = s.get(c) || l, u = f.home - l.home, v = f.away - l.away;
1436
+ (u < 0 || v < 0) && (i = !1), o.push({ period: c, home: Math.max(u, 0), away: Math.max(v, 0) }), l = { home: Math.max(f.home, l.home), away: Math.max(f.away, l.away) };
1427
1437
  }
1428
1438
  const d = N(a.homeScore) ?? 0, m = N(a.awayScore) ?? 0, h = i && l.home === d && l.away === m;
1429
1439
  return i = i && l.home <= d && l.away <= m, { periods: o, reconciled: h, consistent: i };
@@ -1563,8 +1573,8 @@ class yt extends w {
1563
1573
  }
1564
1574
  get ctx() {
1565
1575
  return (!this._ctx || this._ctxData !== this.data) && (this._ctx = {
1566
- teamsById: b(this.data.teams),
1567
- schoolsById: b(this.data.schools),
1576
+ teamsById: y(this.data.teams),
1577
+ schoolsById: y(this.data.schools),
1568
1578
  records: R(this.data.games),
1569
1579
  rankings: this.data.rankings,
1570
1580
  hrefs: z(this),
@@ -1574,7 +1584,7 @@ class yt extends w {
1574
1584
  renderView() {
1575
1585
  const e = this.data.game;
1576
1586
  if (!e) return n`<div class="view"><p class="empty">Game not found.</p></div>`;
1577
- const t = this.ctx, s = b(this.data.conferences), r = t.teamsById[e.awayTeamId] ? t.schoolsById[t.teamsById[e.awayTeamId].schoolId] : null, o = t.teamsById[e.homeTeamId] ? t.schoolsById[t.teamsById[e.homeTeamId].schoolId] : null, i = H(e), l = (h) => e.state === "final" && i !== h && i !== "tie" ? "opacity:0.45" : "", d = e.conferenceId ? s[e.conferenceId] : null, m = this.data.games.filter((h) => h.id !== e.id && h.state === "final" && h.gameType !== "scrimmage" && (h.homeTeamId === e.homeTeamId && h.awayTeamId === e.awayTeamId || h.homeTeamId === e.awayTeamId && h.awayTeamId === e.homeTeamId));
1587
+ const t = this.ctx, s = y(this.data.conferences), r = t.teamsById[e.awayTeamId] ? t.schoolsById[t.teamsById[e.awayTeamId].schoolId] : null, o = t.teamsById[e.homeTeamId] ? t.schoolsById[t.teamsById[e.homeTeamId].schoolId] : null, i = H(e), l = (h) => e.state === "final" && i !== h && i !== "tie" ? "opacity:0.45" : "", d = e.conferenceId ? s[e.conferenceId] : null, m = this.data.games.filter((h) => h.id !== e.id && h.state === "final" && h.gameType !== "scrimmage" && (h.homeTeamId === e.homeTeamId && h.awayTeamId === e.awayTeamId || h.homeTeamId === e.awayTeamId && h.awayTeamId === e.homeTeamId));
1578
1588
  return n`
1579
1589
  ${B(this, n`
1580
1590
  ${D(this)}
@@ -1594,7 +1604,7 @@ class yt extends w {
1594
1604
  <span style=${l("home")}>${e.homeScore}</span>
1595
1605
  </div>
1596
1606
  <div class="status">${E(e)}</div>
1597
- <div class="status">${x(e.date, { weekday: "short", month: "short", day: "numeric", year: "numeric" })}${e.state === "scheduled" && e.time ? n` · ${W(e.time)}` : p} · ${e.venue || "Venue TBD"}
1607
+ <div class="status">${x(e.date, { weekday: "short", month: "short", day: "numeric", year: "numeric" })}${e.state === "scheduled" && e.time ? n` · ${V(e.time)}` : p} · ${e.venue || "Venue TBD"}
1598
1608
  ${e.broadcast ? n` · <span class="pill class">${e.broadcast}</span>` : p}</div>
1599
1609
  <div class="status">
1600
1610
  <span class="pill type">${e.gameType === "conference" ? `${d?.name || "Conference"} game` : e.gameType}</span>
@@ -1653,9 +1663,9 @@ class yt extends w {
1653
1663
  const i = e.teamsById[s], l = e.records[s], d = M(r, 58);
1654
1664
  return n`
1655
1665
  <div class="teamblock ${o ? "right" : ""}">
1656
- ${d ? n`<img class="crest logo" alt="" loading="lazy" src=${d} />` : n`<span class="crest" style="background:${r.colorPrimary || "#030711"};color:${G(r.colorPrimary || "#030711")}">${Y(r)}</span>`}
1666
+ ${d ? n`<img class="crest logo" alt="" loading="lazy" src=${d} />` : n`<span class="crest" style="background:${r.colorPrimary || "#030711"};color:${G(r.colorPrimary || "#030711")}">${K(r)}</span>`}
1657
1667
  <div>
1658
- <div class="tname">${Z(e, s, t.date)}<a href=${g(e.hrefs.school, { id: r.id })}>${r.name}</a></div>
1668
+ <div class="tname">${X(e, s, t.date)}<a href=${g(e.hrefs.school, { id: r.id })}>${r.name}</a></div>
1659
1669
  <div class="trec">${r.mascot || ""} · ${I(l)}${i?.conferenceId ? n` · ${I(l, !0)} conf` : p}</div>
1660
1670
  </div>
1661
1671
  </div>
@@ -1665,7 +1675,7 @@ class yt extends w {
1665
1675
  const r = pt(e);
1666
1676
  if (!r)
1667
1677
  return e.state === "scheduled" ? n`<p class="empty" style="text-align:center">Period scoring will appear once the game starts.</p>` : p;
1668
- const o = Math.max(J(e.sport), ...r.map((m) => m.period)), i = (m) => dt(e.sport, m), l = (m, h) => {
1678
+ const o = Math.max(ee(e.sport), ...r.map((m) => m.period)), i = (m) => dt(e.sport, m), l = (m, h) => {
1669
1679
  const c = r.find((f) => f.period === h);
1670
1680
  return c ? c[m] : e.state === "final" ? 0 : "·";
1671
1681
  }, d = (m, h, c) => n`
@@ -1714,12 +1724,12 @@ class yt extends w {
1714
1724
  }
1715
1725
  renderContext(e, t, s) {
1716
1726
  if (!s) return p;
1717
- const r = e.records[t], o = K(this.data.games, t);
1727
+ const r = e.records[t], o = Q(this.data.games, t);
1718
1728
  return n`
1719
1729
  <div class="card ctxcard">
1720
1730
  <div class="who">${C(s)}${s.name}</div>
1721
1731
  <div class="row">
1722
- <span>Last 5: ${X(e, t)}</span>
1732
+ <span>Last 5: ${J(e, t)}</span>
1723
1733
  <span>Streak: <b>${r ? U(r.results) : "·"}</b></span>
1724
1734
  <span>PF/PA: <b>${r ? `${r.pf} / ${r.pa}` : "·"}</b></span>
1725
1735
  <span>Next: ${o ? n`${x(o.date, { month: "numeric", day: "numeric" })}
@@ -1977,7 +1987,7 @@ function Dt(a, e, t) {
1977
1987
  let h = [...o.get(m)];
1978
1988
  if (d) {
1979
1989
  const c = (f) => {
1980
- const u = (i.get(f.id) || []).map((y) => d.get(y)).filter((y) => y !== void 0);
1990
+ const u = (i.get(f.id) || []).map((v) => d.get(v)).filter((v) => v !== void 0);
1981
1991
  return u.length ? Math.min(...u) : 1 / 0;
1982
1992
  };
1983
1993
  h.sort((f, u) => c(f) - c(u) || ie(f, u));
@@ -2094,8 +2104,8 @@ class Et extends w {
2094
2104
  }
2095
2105
  get ctx() {
2096
2106
  return (!this._ctx || this._ctxData !== this.data) && (this._ctx = {
2097
- teamsById: b(this.data.teams),
2098
- schoolsById: b(this.data.schools),
2107
+ teamsById: y(this.data.teams),
2108
+ schoolsById: y(this.data.schools),
2099
2109
  records: {},
2100
2110
  rankings: [],
2101
2111
  hrefs: z(this),
@@ -2211,6 +2221,6 @@ export {
2211
2221
  I as r,
2212
2222
  ge as s,
2213
2223
  U as t,
2214
- Q as u,
2224
+ Z as u,
2215
2225
  Te as v
2216
2226
  };
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-D3mrvZfC.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-ClfXvdcH.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.0",
3
+ "version": "0.5.1",
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",