@nukleus-sports/ui-patterns 0.5.0 → 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.
package/dist/team.js CHANGED
@@ -1424,6 +1424,706 @@ function RecentGamesWidget({
1424
1424
  }
1425
1425
  );
1426
1426
  }
1427
+
1428
+ // src/team/team-stats-table.tsx
1429
+ import { useState as useState5 } from "react";
1430
+ import {
1431
+ BaseTable as BaseTable3,
1432
+ Card as Card7,
1433
+ CardContent as CardContent7,
1434
+ CardHeader as CardHeader6,
1435
+ CardTitle as CardTitle6,
1436
+ Select as Select2,
1437
+ SelectContent as SelectContent2,
1438
+ SelectItem as SelectItem2,
1439
+ SelectTrigger as SelectTrigger2,
1440
+ SelectValue as SelectValue2,
1441
+ Skeleton as Skeleton6,
1442
+ cn as cn13
1443
+ } from "@nukleus-sports/ui-web";
1444
+ import {
1445
+ getOrderedTeamStatTypesForCategory,
1446
+ getVisibleTeamStatTypes,
1447
+ showsTeamStatCategoryPicker
1448
+ } from "@nukleus-sports/core";
1449
+ import { Fragment as Fragment4, jsx as jsx15, jsxs as jsxs15 } from "react/jsx-runtime";
1450
+ function stripLeadingSlash(path) {
1451
+ return path.startsWith("/") ? path.slice(1) : path;
1452
+ }
1453
+ function isDefinedStatType(value) {
1454
+ return Boolean(value);
1455
+ }
1456
+ function getAvailableStatCategories(stats) {
1457
+ return Array.from(
1458
+ new Set(
1459
+ stats.flatMap(
1460
+ (stat) => (stat.stat_details?.stats ?? []).map((s) => s.stat_type).filter(isDefinedStatType)
1461
+ )
1462
+ )
1463
+ );
1464
+ }
1465
+ function deriveSelectedStatCategory(requested, available) {
1466
+ if (requested && available.includes(requested)) return requested;
1467
+ if (available.includes("offense")) return "offense";
1468
+ return available[0] ?? "offense";
1469
+ }
1470
+ function getStatsEmptyMessage(seasons, statsCount) {
1471
+ if (!seasons.selectedYear || seasons.selectedType === null) {
1472
+ return "Select a season to view stats.";
1473
+ }
1474
+ if (statsCount === 0) {
1475
+ const yearLabel = seasons.years.find((y) => y.value === seasons.selectedYear)?.label;
1476
+ const typeLabel = seasons.types.find((t) => t.value === seasons.selectedType)?.label;
1477
+ return `No stats available for ${yearLabel} - ${typeLabel}.`;
1478
+ }
1479
+ return "No stats found for this season";
1480
+ }
1481
+ function formatTeamStatDate(stat) {
1482
+ const dateStr = stat.stat_details?.game_details?.date;
1483
+ const date = dateStr ? new Date(dateStr) : null;
1484
+ if (!date || Number.isNaN(date.getTime())) {
1485
+ return /* @__PURE__ */ jsx15("span", { className: "text-text-primary body-text", children: "--" });
1486
+ }
1487
+ const formatted = date.toLocaleDateString("en-US", { month: "short", day: "numeric" });
1488
+ return /* @__PURE__ */ jsx15("div", { className: "text-13.5 font-normal text-text-primary", children: formatted });
1489
+ }
1490
+ function getTeamStatResult(stat) {
1491
+ const gameDetails = stat.stat_details?.game_details;
1492
+ if (gameDetails?.home_team_score === void 0 || gameDetails?.away_team_score === void 0) {
1493
+ return "--";
1494
+ }
1495
+ const isHome = stat.team_id === gameDetails.home_team_id;
1496
+ const homeScore = gameDetails.home_team_score;
1497
+ const awayScore = gameDetails.away_team_score;
1498
+ let winLoss = "T";
1499
+ if (homeScore !== awayScore) {
1500
+ const teamWon = isHome ? homeScore > awayScore : awayScore > homeScore;
1501
+ winLoss = teamWon ? "W" : "L";
1502
+ }
1503
+ const teamScore = isHome ? homeScore : awayScore;
1504
+ const opponentScore = isHome ? awayScore : homeScore;
1505
+ const score = `${teamScore}-${opponentScore}${gameDetails.status_alt_details ? ` ${gameDetails.status_alt_details}` : ""}`;
1506
+ const colorClass = winLoss === "W" ? "text-primary-color-nuk-text" : winLoss === "L" ? "text-semantic-color-status-priority-blocked-hot-copy" : "text-text-primary";
1507
+ return /* @__PURE__ */ jsxs15("div", { className: "flex items-baseline gap-1 leading-tight", children: [
1508
+ /* @__PURE__ */ jsx15("span", { className: cn13(colorClass, "body-text"), children: winLoss }),
1509
+ /* @__PURE__ */ jsx15("span", { className: "text-text-primary body-text", children: score })
1510
+ ] });
1511
+ }
1512
+ function StatOpponentCell({
1513
+ stat,
1514
+ resolveOpponentLogoUrl,
1515
+ defaultLogoUrl,
1516
+ showName
1517
+ }) {
1518
+ const [failedUrl, setFailedUrl] = useState5(null);
1519
+ const gameDetails = stat.stat_details?.game_details;
1520
+ const isHome = stat.team_id === gameDetails?.home_team_id;
1521
+ const opponentName = isHome ? gameDetails?.away_team_name : gameDetails?.home_team_name;
1522
+ const opponentLogoPath = isHome ? gameDetails?.away_team_logo : gameDetails?.home_team_logo;
1523
+ if (!opponentName) return /* @__PURE__ */ jsx15(Fragment4, { children: "--" });
1524
+ const prefix = isHome ? "vs" : "@";
1525
+ const resolved = opponentLogoPath ? resolveOpponentLogoUrl(stripLeadingSlash(opponentLogoPath)) : null;
1526
+ const logoSrc = resolved && resolved !== failedUrl ? resolved : defaultLogoUrl;
1527
+ return /* @__PURE__ */ jsx15("div", { className: "h-full overflow-hidden", children: /* @__PURE__ */ jsx15("div", { className: "flex items-center h-full", children: /* @__PURE__ */ jsxs15("div", { className: "flex max-sm:gap-1 gap-2 items-center font-normal leading-tight text-12", children: [
1528
+ /* @__PURE__ */ jsx15("span", { className: "text-text-primary body-text", children: prefix }),
1529
+ /* @__PURE__ */ jsx15(
1530
+ "img",
1531
+ {
1532
+ src: logoSrc,
1533
+ alt: showName ? "" : opponentName,
1534
+ className: "max-sm:w-5 max-sm:h-5 w-4 h-4 rounded-full flex-shrink-0",
1535
+ onError: () => {
1536
+ if (resolved) setFailedUrl(resolved);
1537
+ }
1538
+ }
1539
+ ),
1540
+ showName && /* @__PURE__ */ jsx15("span", { className: "text-primary-color-nuk-text body-text line-clamp-2", children: opponentName })
1541
+ ] }) }) });
1542
+ }
1543
+ function buildStatsColumns({
1544
+ filteredStatTypes,
1545
+ selectedStatCategory,
1546
+ resolveOpponentLogoUrl,
1547
+ defaultLogoUrl,
1548
+ isSm,
1549
+ isSmallLaptop
1550
+ }) {
1551
+ return [
1552
+ {
1553
+ id: "game_date",
1554
+ header: () => /* @__PURE__ */ jsx15("div", { className: "w-[50px] shrink-0", children: "Date" }),
1555
+ cell: ({ row }) => formatTeamStatDate(row.original),
1556
+ meta: { cellSize: isSm ? "xs" : "xxs", headerClassName: "h-auto" }
1557
+ },
1558
+ {
1559
+ id: "opponent",
1560
+ header: () => /* @__PURE__ */ jsx15("div", { children: isSm ? "Opponent" : "Opp" }),
1561
+ cell: ({ row }) => /* @__PURE__ */ jsx15(
1562
+ StatOpponentCell,
1563
+ {
1564
+ stat: row.original,
1565
+ resolveOpponentLogoUrl,
1566
+ defaultLogoUrl,
1567
+ showName: isSm
1568
+ }
1569
+ ),
1570
+ meta: {
1571
+ cellSize: isSm ? isSmallLaptop ? "lg" : "l" : "eclipse",
1572
+ headerClassName: "h-auto"
1573
+ }
1574
+ },
1575
+ {
1576
+ id: "result",
1577
+ header: "Result",
1578
+ cell: ({ row }) => getTeamStatResult(row.original),
1579
+ meta: { cellSize: "xs", headerClassName: "h-auto", rowCellClassName: "!min-w-[70px]" }
1580
+ },
1581
+ ...filteredStatTypes.map((statType) => ({
1582
+ id: statType.name,
1583
+ header: statType.label || statType.name,
1584
+ cell: ({ row }) => {
1585
+ const value = row.original.stat_details?.stats?.find(
1586
+ (s) => s.stat_id === statType.id && s.stat_type === selectedStatCategory
1587
+ )?.stat_value;
1588
+ return value !== void 0 ? value : "--";
1589
+ },
1590
+ meta: {
1591
+ cellSize: "xxs",
1592
+ headerClassName: "h-auto py-0 !whitespace-normal !overflow-visible !text-clip !break-words !line-clamp-2"
1593
+ }
1594
+ }))
1595
+ ];
1596
+ }
1597
+ function StatsBody2({
1598
+ seasons,
1599
+ showsCategoryPicker,
1600
+ selectedStatCategory,
1601
+ availableStatCategories,
1602
+ onStatCategoryChange,
1603
+ isStatTypesError,
1604
+ hasVisibleStatTypes,
1605
+ columns,
1606
+ stats,
1607
+ statsLoading,
1608
+ isStatsError,
1609
+ isSm,
1610
+ isSmallLaptop,
1611
+ emptyMessage
1612
+ }) {
1613
+ return /* @__PURE__ */ jsxs15(Fragment4, { children: [
1614
+ /* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-2 min-[360px]:gap-3", children: [
1615
+ /* @__PURE__ */ jsx15(SeasonSelector, { ...seasons, className: "gap-2 min-[360px]:gap-3" }),
1616
+ showsCategoryPicker && /* @__PURE__ */ jsxs15(
1617
+ Select2,
1618
+ {
1619
+ value: selectedStatCategory,
1620
+ onValueChange: onStatCategoryChange,
1621
+ disabled: !seasons.selectedYear || seasons.selectedType === null,
1622
+ children: [
1623
+ /* @__PURE__ */ jsx15(SelectTrigger2, { variant: "widget", size: "widget", "aria-label": "Stat category", children: /* @__PURE__ */ jsx15(SelectValue2, { placeholder: "Select stat category" }) }),
1624
+ /* @__PURE__ */ jsx15(
1625
+ SelectContent2,
1626
+ {
1627
+ className: "bg-popover border-border z-50 [&_.checkbox]:!flex",
1628
+ classNameViewPort: "gap-2",
1629
+ children: availableStatCategories.map((category) => /* @__PURE__ */ jsx15(SelectItem2, { value: category, className: "capitalize min-h-8", children: category.charAt(0).toUpperCase() + category.slice(1) }, category))
1630
+ }
1631
+ )
1632
+ ]
1633
+ }
1634
+ )
1635
+ ] }),
1636
+ /* @__PURE__ */ jsxs15("div", { className: "space-y-4 xl:flex-1 xl:min-h-0 xl:overflow-hidden", children: [
1637
+ isStatTypesError && !hasVisibleStatTypes && /* @__PURE__ */ jsx15("p", { className: "text-text-secondary text-13.5", children: "Couldn't load stat categories -- showing limited columns." }),
1638
+ /* @__PURE__ */ jsx15(
1639
+ BaseTable3,
1640
+ {
1641
+ columns,
1642
+ data: stats,
1643
+ pageSize: stats.length || 10,
1644
+ hidePagination: true,
1645
+ stickyHeader: true,
1646
+ splitLayout: isSmallLaptop || !isSm,
1647
+ splitLayoutGridCols: isSm ? "sm:!grid-cols-[minmax(232px,auto)_1fr]" : "!grid-cols-[minmax(117px,auto)_1fr]",
1648
+ loading: statsLoading,
1649
+ containerClassName: "border-0 rounded-none h-full",
1650
+ className: "border-none xl:h-full xl:min-h-0",
1651
+ numberOfColumns: 2,
1652
+ emptyMessage: isStatsError && stats.length === 0 ? "Couldn't load stats. Please try again." : emptyMessage
1653
+ }
1654
+ )
1655
+ ] })
1656
+ ] });
1657
+ }
1658
+ function TeamStatsTable({
1659
+ stats,
1660
+ statsLoading = false,
1661
+ isStatsError = false,
1662
+ statTypes,
1663
+ isStatTypesError = false,
1664
+ sportId,
1665
+ isTeamError = false,
1666
+ resolveOpponentLogoUrl,
1667
+ defaultLogoUrl,
1668
+ seasons,
1669
+ seasonsLoading = false,
1670
+ isSeasonsError = false,
1671
+ isSm,
1672
+ isSmallLaptop,
1673
+ className
1674
+ }) {
1675
+ const [requestedStatCategory, setRequestedStatCategory] = useState5(null);
1676
+ const availableStatCategories = getAvailableStatCategories(stats);
1677
+ const selectedStatCategory = deriveSelectedStatCategory(
1678
+ requestedStatCategory,
1679
+ availableStatCategories
1680
+ );
1681
+ if (isTeamError) {
1682
+ return /* @__PURE__ */ jsx15(Card7, { className: cn13("border-0", className), children: /* @__PURE__ */ jsx15(CardContent7, { className: "p-4 flex justify-center items-center", children: /* @__PURE__ */ jsx15("p", { className: "text-text-secondary", children: "Couldn't load team information. Please try again." }) }) });
1683
+ }
1684
+ if (seasonsLoading || sportId === null) {
1685
+ return /* @__PURE__ */ jsx15(Card7, { className: cn13("border-0", className), children: /* @__PURE__ */ jsxs15(CardContent7, { className: "space-y-4 pt-6", children: [
1686
+ /* @__PURE__ */ jsxs15("div", { className: "flex flex-col gap-3 sm:flex-row justify-start", children: [
1687
+ /* @__PURE__ */ jsx15(Skeleton6, { className: "h-7 w-[68px] bg-form rounded-[5px]" }),
1688
+ /* @__PURE__ */ jsx15(Skeleton6, { className: "h-7 w-[142px] bg-form rounded-[5px]" }),
1689
+ /* @__PURE__ */ jsx15(Skeleton6, { className: "h-7 w-[102px] bg-form rounded-[5px]" })
1690
+ ] }),
1691
+ /* @__PURE__ */ jsx15(Skeleton6, { className: "h-40 w-full bg-form !mt-3" })
1692
+ ] }) });
1693
+ }
1694
+ if (!seasons || seasons.years.length === 0) {
1695
+ return /* @__PURE__ */ jsx15(Card7, { className: cn13("border-none", className), children: /* @__PURE__ */ jsx15(CardContent7, { className: "pt-6", children: /* @__PURE__ */ jsx15("div", { className: "text-center py-8", children: /* @__PURE__ */ jsx15("p", { className: "text-text-primary text-14.5 font-normal leading-normal", children: isSeasonsError ? "Couldn't load stats. Please try again." : "There are no stats for this team at this time." }) }) }) });
1696
+ }
1697
+ const visibleStatTypes = getVisibleTeamStatTypes(statTypes, sportId);
1698
+ const filteredStatTypes = getOrderedTeamStatTypesForCategory(
1699
+ visibleStatTypes,
1700
+ sportId,
1701
+ selectedStatCategory
1702
+ );
1703
+ const showsCategoryPicker = availableStatCategories.length > 0 && showsTeamStatCategoryPicker(sportId);
1704
+ const columns = buildStatsColumns({
1705
+ filteredStatTypes,
1706
+ selectedStatCategory,
1707
+ resolveOpponentLogoUrl,
1708
+ defaultLogoUrl,
1709
+ isSm,
1710
+ isSmallLaptop
1711
+ });
1712
+ const emptyMessage = getStatsEmptyMessage(seasons, stats.length);
1713
+ return /* @__PURE__ */ jsxs15(
1714
+ Card7,
1715
+ {
1716
+ className: cn13(
1717
+ "border-none p-4 flex flex-col gap-3 xl:h-full xl:min-h-0 xl:flex-1 xl:overflow-hidden",
1718
+ className
1719
+ ),
1720
+ children: [
1721
+ /* @__PURE__ */ jsx15(CardHeader6, { className: "p-0", children: /* @__PURE__ */ jsx15(CardTitle6, { children: "Stats" }) }),
1722
+ /* @__PURE__ */ jsx15(CardContent7, { className: "space-y-0 p-0 flex flex-col gap-3 xl:flex-1 xl:min-h-0", children: /* @__PURE__ */ jsx15(
1723
+ StatsBody2,
1724
+ {
1725
+ seasons,
1726
+ showsCategoryPicker,
1727
+ selectedStatCategory,
1728
+ availableStatCategories,
1729
+ onStatCategoryChange: setRequestedStatCategory,
1730
+ isStatTypesError,
1731
+ hasVisibleStatTypes: visibleStatTypes.length > 0,
1732
+ columns,
1733
+ stats,
1734
+ statsLoading,
1735
+ isStatsError,
1736
+ isSm,
1737
+ isSmallLaptop,
1738
+ emptyMessage
1739
+ }
1740
+ ) })
1741
+ ]
1742
+ }
1743
+ );
1744
+ }
1745
+
1746
+ // src/team/team-schedule-table.tsx
1747
+ import {
1748
+ BaseTable as BaseTable4,
1749
+ Card as Card8,
1750
+ CardContent as CardContent8,
1751
+ CardHeader as CardHeader7,
1752
+ CardTitle as CardTitle7,
1753
+ IconLoader as IconLoader3,
1754
+ cn as cn14
1755
+ } from "@nukleus-sports/ui-web";
1756
+ import { Fragment as Fragment5, jsx as jsx16, jsxs as jsxs16 } from "react/jsx-runtime";
1757
+ var SPECIAL_LOGO_LEAGUES = ["NFL", "NBA", "NHL", "MLB", "WNBA"];
1758
+ var COLLEGE_LEAGUE_IDS = [2, 6, 13];
1759
+ var COMPLETED_STATUS_ID = "3";
1760
+ var DATE_FORMAT2 = new Intl.DateTimeFormat("en-US", { month: "short", day: "numeric" });
1761
+ function firstCompetition(game) {
1762
+ return game.game_details?.competitions?.[0];
1763
+ }
1764
+ function formatScore(score) {
1765
+ if (score?.displayValue) return score.displayValue;
1766
+ if (typeof score?.value === "number") return String(score.value);
1767
+ return "0";
1768
+ }
1769
+ function findCompetitor(competitors, teamEspnId) {
1770
+ if (!competitors || competitors.length !== 2 || !teamEspnId) return null;
1771
+ const [first, second] = competitors;
1772
+ if (!first || !second) return null;
1773
+ if (first.id === teamEspnId) return { own: first, other: second };
1774
+ if (second.id === teamEspnId) return { own: second, other: first };
1775
+ return null;
1776
+ }
1777
+ function findLeader(competitors, leaderType) {
1778
+ if (!competitors || competitors.length !== 2) return null;
1779
+ for (const competitor of competitors) {
1780
+ const leader = competitor?.leaders?.find((entry) => entry.name === leaderType);
1781
+ const top = leader?.leaders?.[0];
1782
+ if (top?.athlete) {
1783
+ return {
1784
+ displayName: top.athlete.displayName || "--",
1785
+ displayValue: top.displayValue || "--"
1786
+ };
1787
+ }
1788
+ }
1789
+ return null;
1790
+ }
1791
+ function showsFootballLeaders(leagueId) {
1792
+ return leagueId !== null && [1, 2, 13].includes(leagueId);
1793
+ }
1794
+ function showsBasketballLeaders(leagueId) {
1795
+ return leagueId !== null && [4, 5, 6].includes(leagueId);
1796
+ }
1797
+ function showsHockeyLeaders(leagueId) {
1798
+ return leagueId === 14;
1799
+ }
1800
+ function showsMlbLeaders(leagueId) {
1801
+ return leagueId === 7;
1802
+ }
1803
+ function leaderCell(leader, small = false) {
1804
+ if (!leader) return "--";
1805
+ return /* @__PURE__ */ jsxs16("div", { className: "flex flex-col leading-tight", children: [
1806
+ /* @__PURE__ */ jsx16("span", { className: "text-text-primary font-normal truncate", children: leader.displayName }),
1807
+ /* @__PURE__ */ jsx16(
1808
+ "span",
1809
+ {
1810
+ className: cn14(
1811
+ small ? "text-text-secondary text-11" : "text-text-primary body-text",
1812
+ "truncate"
1813
+ ),
1814
+ children: leader.displayValue
1815
+ }
1816
+ )
1817
+ ] });
1818
+ }
1819
+ function formatScheduleDate(game) {
1820
+ if (!game.game_details) return "--";
1821
+ try {
1822
+ const { timeValid, date: rawDate } = game.game_details;
1823
+ const date = timeValid ? new Date(rawDate) : (() => {
1824
+ const [year, month, day] = rawDate.split("T")[0].split("-").map(Number);
1825
+ return new Date(year, month - 1, day);
1826
+ })();
1827
+ return /* @__PURE__ */ jsx16("span", { className: "text-text-primary body-text", children: DATE_FORMAT2.format(date) });
1828
+ } catch {
1829
+ return "--";
1830
+ }
1831
+ }
1832
+ function getScheduleResult(game, teamEspnId) {
1833
+ const competition = firstCompetition(game);
1834
+ if (competition?.status?.type?.id !== COMPLETED_STATUS_ID) return null;
1835
+ const match = findCompetitor(competition.competitors, teamEspnId);
1836
+ if (!match) return null;
1837
+ const { own, other } = match;
1838
+ const ownValue = own.score?.value;
1839
+ const otherValue = other.score?.value;
1840
+ const scoresKnown = typeof ownValue === "number" && typeof otherValue === "number";
1841
+ const tied = scoresKnown && ownValue === otherValue;
1842
+ const winLoss = tied ? "T" : own.winner === true ? "W" : "L";
1843
+ const score = `${formatScore(own.score)}-${formatScore(other.score)}`;
1844
+ const colorClass = winLoss === "W" ? "text-primary-color-nuk-text" : winLoss === "L" ? "text-semantic-color-status-priority-blocked-hot-copy" : "text-text-primary";
1845
+ return /* @__PURE__ */ jsxs16("div", { className: "flex items-baseline gap-1 leading-tight", children: [
1846
+ /* @__PURE__ */ jsx16("span", { className: cn14(colorClass, "body-text"), children: winLoss }),
1847
+ /* @__PURE__ */ jsx16("span", { className: "text-text-primary body-text", children: score })
1848
+ ] });
1849
+ }
1850
+ function getScheduleRecord(game, teamEspnId) {
1851
+ const competition = firstCompetition(game);
1852
+ if (competition?.status?.type?.id !== COMPLETED_STATUS_ID) return "--";
1853
+ return findCompetitor(competition.competitors, teamEspnId)?.own.record?.[0]?.displayValue || "--";
1854
+ }
1855
+ function getWinningGoalie(game) {
1856
+ const athlete = firstCompetition(game)?.featuredAthletes?.[0]?.athlete;
1857
+ if (!athlete?.lastName) return "--";
1858
+ return /* @__PURE__ */ jsx16("div", { className: "flex flex-col leading-tight", children: /* @__PURE__ */ jsx16("span", { className: "text-text-primary font-normal truncate", children: athlete.lastName }) });
1859
+ }
1860
+ function getHockeyTopPlayer(game) {
1861
+ const competitors = firstCompetition(game)?.competitors;
1862
+ const competitor = competitors?.find((c) => c?.leaders?.[0]?.leaders?.length);
1863
+ const top = competitor?.leaders?.[0]?.leaders?.[0];
1864
+ if (!top?.athlete?.lastName) return "--";
1865
+ return leaderCell(
1866
+ { displayName: top.athlete.lastName, displayValue: top.displayValue || "--" },
1867
+ true
1868
+ );
1869
+ }
1870
+ function getMlbPitcher(game, pitcherType) {
1871
+ const pitcher = firstCompetition(game)?.featuredAthletes?.find((a) => a.name === pitcherType);
1872
+ const athlete = pitcher?.athlete;
1873
+ if (!athlete?.lastName) return "--";
1874
+ const stat = pitcherType === "savingPitcher" ? athlete.saves : athlete.record;
1875
+ return /* @__PURE__ */ jsxs16("div", { className: "flex flex-col leading-tight", children: [
1876
+ /* @__PURE__ */ jsx16("span", { className: "text-text-primary font-normal truncate", children: athlete.lastName }),
1877
+ /* @__PURE__ */ jsx16("span", { className: "text-text-secondary text-11 truncate", children: stat || "--" })
1878
+ ] });
1879
+ }
1880
+ function OpponentCell({
1881
+ game,
1882
+ teamEspnId,
1883
+ leagueId,
1884
+ leagueAbbreviation,
1885
+ resolveLogoUrl,
1886
+ defaultLogoUrl,
1887
+ showName
1888
+ }) {
1889
+ const match = findCompetitor(firstCompetition(game)?.competitors, teamEspnId);
1890
+ if (!match || leagueId === null || !leagueAbbreviation) return /* @__PURE__ */ jsx16(Fragment5, { children: "--" });
1891
+ const prefix = match.own.homeAway === "home" ? "vs" : "@";
1892
+ const opponentTeam = match.other.team;
1893
+ const isSpecialLeague = SPECIAL_LOGO_LEAGUES.includes(leagueAbbreviation);
1894
+ const identifier = isSpecialLeague ? opponentTeam.abbreviation : opponentTeam.id;
1895
+ const folder = COLLEGE_LEAGUE_IDS.includes(leagueId) ? "NCAA" : leagueAbbreviation;
1896
+ return /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-1 sm:gap-2 h-full overflow-hidden", children: [
1897
+ /* @__PURE__ */ jsx16("span", { className: "text-text-primary body-text shrink-0 sm:w-4", children: prefix }),
1898
+ /* @__PURE__ */ jsx16(
1899
+ "img",
1900
+ {
1901
+ src: resolveLogoUrl(folder, identifier),
1902
+ alt: showName ? "" : opponentTeam.displayName,
1903
+ loading: "lazy",
1904
+ className: "h-5 w-5 shrink-0 inline sm:h-6 sm:w-6 sm:mr-2",
1905
+ onError: (event) => {
1906
+ event.currentTarget.src = defaultLogoUrl;
1907
+ }
1908
+ }
1909
+ ),
1910
+ showName && /* @__PURE__ */ jsx16("span", { className: "text-primary-color-nuk-text body-text line-clamp-2", children: opponentTeam.displayName })
1911
+ ] });
1912
+ }
1913
+ function buildScheduleColumns({
1914
+ leagueId,
1915
+ leagueAbbreviation,
1916
+ teamEspnId,
1917
+ resolveLogoUrl,
1918
+ defaultLogoUrl,
1919
+ isSm,
1920
+ isSmallLaptop
1921
+ }) {
1922
+ const showsHockey = showsHockeyLeaders(leagueId);
1923
+ return [
1924
+ {
1925
+ id: "game_date",
1926
+ header: () => /* @__PURE__ */ jsx16("div", { className: "w-[50px] shrink-0", children: "Date" }),
1927
+ accessorFn: (row) => row.game_date,
1928
+ cell: ({ row }) => formatScheduleDate(row.original),
1929
+ meta: { cellSize: isSm ? "xs" : "xxs" }
1930
+ },
1931
+ {
1932
+ id: "opponent",
1933
+ header: () => /* @__PURE__ */ jsx16("div", { children: isSm ? "Opponent" : "Opp" }),
1934
+ cell: ({ row }) => /* @__PURE__ */ jsx16(
1935
+ OpponentCell,
1936
+ {
1937
+ game: row.original,
1938
+ teamEspnId,
1939
+ leagueId,
1940
+ leagueAbbreviation,
1941
+ resolveLogoUrl,
1942
+ defaultLogoUrl,
1943
+ showName: isSm
1944
+ }
1945
+ ),
1946
+ meta: { cellSize: isSm ? isSmallLaptop ? "lg" : "l" : "eclipse" }
1947
+ },
1948
+ {
1949
+ id: "result",
1950
+ header: "Result",
1951
+ cell: ({ row }) => getScheduleResult(row.original, teamEspnId) ?? "--",
1952
+ meta: { cellSize: "xs" }
1953
+ },
1954
+ {
1955
+ id: "record",
1956
+ header: showsHockey ? "W-L-OTL" : "W-L",
1957
+ cell: ({ row }) => getScheduleRecord(row.original, teamEspnId),
1958
+ meta: { cellSize: "xs" }
1959
+ },
1960
+ ...showsMlbLeaders(leagueId) ? [
1961
+ {
1962
+ id: "win",
1963
+ header: "Win",
1964
+ cell: ({ row }) => getMlbPitcher(row.original, "winningPitcher"),
1965
+ meta: { cellSize: "s" }
1966
+ },
1967
+ {
1968
+ id: "loss",
1969
+ header: "Loss",
1970
+ cell: ({ row }) => getMlbPitcher(row.original, "losingPitcher"),
1971
+ meta: { cellSize: "s" }
1972
+ },
1973
+ {
1974
+ id: "save",
1975
+ header: "Save",
1976
+ cell: ({ row }) => getMlbPitcher(row.original, "savingPitcher"),
1977
+ meta: { cellSize: "s" }
1978
+ }
1979
+ ] : [],
1980
+ ...showsBasketballLeaders(leagueId) ? [
1981
+ {
1982
+ id: "topPts",
1983
+ header: "Top Pts",
1984
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "points"), true),
1985
+ meta: { cellSize: "s" }
1986
+ },
1987
+ {
1988
+ id: "topReb",
1989
+ header: "Top Reb",
1990
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "rebounds"), true),
1991
+ meta: { cellSize: "s" }
1992
+ },
1993
+ {
1994
+ id: "topAst",
1995
+ header: "Top Ast",
1996
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "assists"), true),
1997
+ meta: { cellSize: "s" }
1998
+ }
1999
+ ] : [],
2000
+ ...showsHockey ? [
2001
+ {
2002
+ id: "wGoalie",
2003
+ header: "W Goalie",
2004
+ cell: ({ row }) => getWinningGoalie(row.original),
2005
+ meta: { cellSize: "s" }
2006
+ },
2007
+ {
2008
+ id: "topPlayer",
2009
+ header: "Top Player",
2010
+ cell: ({ row }) => getHockeyTopPlayer(row.original),
2011
+ meta: { cellSize: "s" }
2012
+ }
2013
+ ] : [],
2014
+ ...showsFootballLeaders(leagueId) ? [
2015
+ {
2016
+ id: "topPass",
2017
+ header: "Top Pass",
2018
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "passingLeader")),
2019
+ meta: { cellSize: "l" }
2020
+ },
2021
+ {
2022
+ id: "topRush",
2023
+ header: "Top Rush",
2024
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "rushingLeader")),
2025
+ meta: { cellSize: "l" }
2026
+ },
2027
+ {
2028
+ id: "topRec",
2029
+ header: "Top Rec",
2030
+ cell: ({ row }) => leaderCell(
2031
+ findLeader(firstCompetition(row.original)?.competitors, "receivingLeader")
2032
+ ),
2033
+ meta: { cellSize: "l" }
2034
+ }
2035
+ ] : []
2036
+ ];
2037
+ }
2038
+ function ScheduleBody({
2039
+ seasonsLoading,
2040
+ seasons,
2041
+ isSeasonsError,
2042
+ columns,
2043
+ games,
2044
+ gamesLoading,
2045
+ isGamesError,
2046
+ isSm,
2047
+ isSmallLaptop
2048
+ }) {
2049
+ if (seasonsLoading) {
2050
+ return /* @__PURE__ */ jsx16("div", { className: "flex justify-center py-8", children: /* @__PURE__ */ jsx16("div", { className: "text-sm text-text-primary", children: "Loading seasons..." }) });
2051
+ }
2052
+ if (!seasons || seasons.years.length === 0) {
2053
+ return /* @__PURE__ */ jsx16("div", { className: "text-center py-8", children: /* @__PURE__ */ jsx16("p", { className: "text-text-primary", children: isSeasonsError ? "Couldn't load seasons. Please try again." : "No seasons found" }) });
2054
+ }
2055
+ return /* @__PURE__ */ jsxs16("div", { className: "flex flex-col gap-3", children: [
2056
+ /* @__PURE__ */ jsx16(SeasonSelector, { ...seasons, className: "gap-2 min-[360px]:gap-3" }),
2057
+ /* @__PURE__ */ jsx16("div", { children: /* @__PURE__ */ jsx16(
2058
+ BaseTable4,
2059
+ {
2060
+ columns,
2061
+ data: games,
2062
+ pageSize: games.length || 10,
2063
+ splitLayout: isSmallLaptop || !isSm,
2064
+ splitLayoutGridCols: isSm ? "sm:!grid-cols-[minmax(232px,auto)_1fr]" : "!grid-cols-[minmax(117px,auto)_1fr]",
2065
+ loading: gamesLoading,
2066
+ containerClassName: "border-0 rounded-none h-full",
2067
+ className: "h-full border-none",
2068
+ numberOfColumns: 2,
2069
+ emptyMessage: isGamesError ? "Couldn't load games. Please try again." : "No games found for this season"
2070
+ }
2071
+ ) })
2072
+ ] });
2073
+ }
2074
+ function TeamScheduleTable({
2075
+ games,
2076
+ gamesLoading = false,
2077
+ isGamesError = false,
2078
+ leagueId,
2079
+ leagueAbbreviation,
2080
+ isTeamError = false,
2081
+ teamEspnId,
2082
+ resolveLogoUrl,
2083
+ defaultLogoUrl,
2084
+ seasons,
2085
+ seasonsLoading = false,
2086
+ isSeasonsError = false,
2087
+ isSm,
2088
+ isSmallLaptop,
2089
+ className
2090
+ }) {
2091
+ const columns = buildScheduleColumns({
2092
+ leagueId,
2093
+ leagueAbbreviation,
2094
+ teamEspnId,
2095
+ resolveLogoUrl,
2096
+ defaultLogoUrl,
2097
+ isSm,
2098
+ isSmallLaptop
2099
+ });
2100
+ if (isTeamError) {
2101
+ return /* @__PURE__ */ jsx16(Card8, { className: cn14("border-0", className), children: /* @__PURE__ */ jsx16(CardContent8, { className: "p-4 flex justify-center items-center", children: /* @__PURE__ */ jsx16("p", { className: "text-text-secondary", children: "Couldn't load team information. Please try again." }) }) });
2102
+ }
2103
+ if (leagueId === null) {
2104
+ return /* @__PURE__ */ jsx16(Card8, { className: cn14("border-0", className), children: /* @__PURE__ */ jsxs16(CardContent8, { className: "p-4 flex justify-center items-center gap-2", children: [
2105
+ /* @__PURE__ */ jsx16(IconLoader3, {}),
2106
+ /* @__PURE__ */ jsx16("p", { className: "text-text-secondary", children: "Loading team information..." })
2107
+ ] }) });
2108
+ }
2109
+ return /* @__PURE__ */ jsxs16(Card8, { className: cn14("border-none p-4 flex flex-col gap-3", className), children: [
2110
+ /* @__PURE__ */ jsx16(CardHeader7, { className: "p-0 flex flex-row items-center justify-between space-y-0", children: /* @__PURE__ */ jsx16(CardTitle7, { children: "Schedule" }) }),
2111
+ /* @__PURE__ */ jsx16(CardContent8, { className: "space-y-0 p-0 flex flex-col gap-3", children: /* @__PURE__ */ jsx16(
2112
+ ScheduleBody,
2113
+ {
2114
+ seasonsLoading,
2115
+ seasons,
2116
+ isSeasonsError,
2117
+ columns,
2118
+ games,
2119
+ gamesLoading,
2120
+ isGamesError,
2121
+ isSm,
2122
+ isSmallLaptop
2123
+ }
2124
+ ) })
2125
+ ] });
2126
+ }
1427
2127
  export {
1428
2128
  EmptyValue,
1429
2129
  FactField,
@@ -1436,10 +2136,12 @@ export {
1436
2136
  TeamFactsContent,
1437
2137
  TeamFactsWidget,
1438
2138
  TeamInfoCard,
2139
+ TeamScheduleTable,
1439
2140
  TeamSeasonScheduleSummaryPanel,
1440
2141
  TeamSeasonStatsSummaryPanel,
1441
2142
  TeamSeasonStatsWidget,
1442
2143
  TeamStaffTable,
2144
+ TeamStatsTable,
1443
2145
  VenuePhoto
1444
2146
  };
1445
2147
  //# sourceMappingURL=team.js.map