@nukleus-sports/ui-patterns 0.4.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.cjs ADDED
@@ -0,0 +1,2320 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/team/index.ts
21
+ var team_exports = {};
22
+ __export(team_exports, {
23
+ EmptyValue: () => EmptyValue,
24
+ FactField: () => FactField,
25
+ FactPills: () => FactPills,
26
+ FieldLabel: () => FieldLabel,
27
+ RecentGamesWidget: () => RecentGamesWidget,
28
+ SeasonSelector: () => SeasonSelector,
29
+ StatColumn: () => StatColumn,
30
+ StatRankingLeaderboardDialog: () => StatRankingLeaderboardDialog,
31
+ TeamFactsContent: () => TeamFactsContent,
32
+ TeamFactsWidget: () => TeamFactsWidget,
33
+ TeamInfoCard: () => TeamInfoCard,
34
+ TeamScheduleTable: () => TeamScheduleTable,
35
+ TeamSeasonScheduleSummaryPanel: () => TeamSeasonScheduleSummaryPanel,
36
+ TeamSeasonStatsSummaryPanel: () => TeamSeasonStatsSummaryPanel,
37
+ TeamSeasonStatsWidget: () => TeamSeasonStatsWidget,
38
+ TeamStaffTable: () => TeamStaffTable,
39
+ TeamStatsTable: () => TeamStatsTable,
40
+ VenuePhoto: () => VenuePhoto
41
+ });
42
+ module.exports = __toCommonJS(team_exports);
43
+
44
+ // src/team/team-info-card.tsx
45
+ var import_ui_web2 = require("@nukleus-sports/ui-web");
46
+ var import_core = require("@nukleus-sports/core");
47
+
48
+ // src/entity-avatar.tsx
49
+ var import_ui_web = require("@nukleus-sports/ui-web");
50
+ var import_jsx_runtime = require("react/jsx-runtime");
51
+ var sizeClasses = {
52
+ xs: "h-4 w-4",
53
+ sm: "h-6 w-6",
54
+ md: "h-8 w-8",
55
+ lg: "h-12 w-12",
56
+ xl: "h-16 w-16",
57
+ "2xl": "h-[120px] w-[120px]",
58
+ "3xl": "h-40 w-40"
59
+ };
60
+ var initialSizeClasses = {
61
+ xs: "text-[8px]",
62
+ sm: "text-xs",
63
+ md: "text-sm",
64
+ lg: "text-base",
65
+ xl: "text-lg",
66
+ "2xl": "text-2xl",
67
+ "3xl": "text-2xl"
68
+ };
69
+ var contactSizeClasses = {
70
+ xs: "h-4 w-4",
71
+ sm: "h-6 w-6",
72
+ md: "h-8 w-8",
73
+ lg: "h-12 w-12",
74
+ xl: "h-16 w-16",
75
+ "2xl": "h-[120px] w-[120px]",
76
+ "3xl": "h-40 w-40"
77
+ };
78
+ var contactInitialSizeClasses = {
79
+ xs: "text-[8px]",
80
+ sm: "text-[10px]",
81
+ md: "text-sm",
82
+ lg: "text-base",
83
+ xl: "text-lg",
84
+ "2xl": "text-2xl",
85
+ "3xl": "text-2xl"
86
+ };
87
+ function EntityAvatar({
88
+ entityType = "initials",
89
+ entityData,
90
+ firstName,
91
+ lastName,
92
+ name,
93
+ imageUrl,
94
+ resolveImageUrl,
95
+ size = "md",
96
+ className,
97
+ fallbackClassName,
98
+ showInitials = true,
99
+ cacheBreaker
100
+ }) {
101
+ const extractedFirstName = firstName || entityData?.first_name || "";
102
+ const extractedLastName = lastName || entityData?.last_name || "";
103
+ const extractedName = name || entityData?.name || "";
104
+ const isSquared = entityType === "team" || entityType === "company";
105
+ const usesContactSizes = entityType === "contact" || entityType === "company" || entityType === "initials";
106
+ const avatarSizeClasses = usesContactSizes ? contactSizeClasses : sizeClasses;
107
+ const initialsSizeClasses = usesContactSizes ? contactInitialSizeClasses : initialSizeClasses;
108
+ const defaultSize = usesContactSizes ? "sm" : "md";
109
+ const effectiveSize = size || defaultSize;
110
+ const getRawImageUrl = () => {
111
+ if (imageUrl) return imageUrl;
112
+ switch (entityType) {
113
+ case "player":
114
+ return entityData?.player_image_url ?? null;
115
+ case "coach":
116
+ return entityData?.coach_image_url ?? null;
117
+ case "team":
118
+ return entityData?.team_logo_url ?? null;
119
+ case "initials":
120
+ case "contact":
121
+ case "company":
122
+ return entityData?.avatar_url ?? null;
123
+ case "agency":
124
+ return entityData?.profile_image_url ?? null;
125
+ default:
126
+ return null;
127
+ }
128
+ };
129
+ const getImageUrl = () => {
130
+ const rawUrl = getRawImageUrl();
131
+ if (!rawUrl) return null;
132
+ if (resolveImageUrl) {
133
+ return resolveImageUrl(rawUrl, { entityType, size: effectiveSize, cacheBreaker });
134
+ }
135
+ if (rawUrl.startsWith("http") || rawUrl.startsWith("data:")) {
136
+ return rawUrl;
137
+ }
138
+ return null;
139
+ };
140
+ const getInitials = () => {
141
+ if (!showInitials) {
142
+ const defaults = {
143
+ player: "P",
144
+ coach: "C",
145
+ team: "T",
146
+ contact: "C",
147
+ company: "C",
148
+ agency: "",
149
+ initials: ""
150
+ };
151
+ return defaults[entityType];
152
+ }
153
+ switch (entityType) {
154
+ case "player":
155
+ case "coach":
156
+ case "agency": {
157
+ const first = extractedFirstName?.[0] || "";
158
+ const last = extractedLastName?.[0] || "";
159
+ const initials2 = (first + last).toUpperCase();
160
+ if (initials2) return initials2;
161
+ if (entityType === "player") return "P";
162
+ if (entityType === "coach") return "C";
163
+ return "?";
164
+ }
165
+ case "team": {
166
+ const teamName = entityData?.team || "";
167
+ const nickname = entityData?.nickname || "";
168
+ const displayName = nickname || teamName || "";
169
+ const words = displayName.trim().split(/\s+/);
170
+ if (words.length >= 2) {
171
+ return (words[0][0] + words[1][0]).toUpperCase();
172
+ } else if (words.length === 1 && words[0].length >= 2) {
173
+ return words[0].substring(0, 2).toUpperCase();
174
+ }
175
+ return "T";
176
+ }
177
+ case "initials": {
178
+ const displayName = extractedName.trim();
179
+ if (!displayName) return "?";
180
+ const nameParts = displayName.trim().split(/\s+/);
181
+ if (nameParts.length >= 2) {
182
+ return (nameParts[0][0] + nameParts[nameParts.length - 1][0]).toUpperCase();
183
+ }
184
+ return displayName.substring(0, 2).toUpperCase();
185
+ }
186
+ case "contact":
187
+ case "company": {
188
+ const displayName = extractedName;
189
+ if (!displayName) return "C";
190
+ const nameParts = displayName.trim().split(/\s+/);
191
+ if (nameParts.length >= 2) {
192
+ if (entityType === "company") {
193
+ return (nameParts[0][0] + nameParts[1][0]).toUpperCase();
194
+ } else {
195
+ return (nameParts[0][0] + nameParts[nameParts.length - 1][0]).toUpperCase();
196
+ }
197
+ }
198
+ return displayName.substring(0, 2).toUpperCase();
199
+ }
200
+ default:
201
+ return "?";
202
+ }
203
+ };
204
+ const getDefaultImageUrl = () => {
205
+ switch (entityType) {
206
+ case "player":
207
+ case "coach":
208
+ return "/images/headshot_default.png";
209
+ case "team":
210
+ return "/images/team_default.png";
211
+ case "contact":
212
+ return "/images/contact_default.png";
213
+ case "company":
214
+ return "/images/company_default.png";
215
+ case "agency":
216
+ return "/images/agency_default.png";
217
+ case "initials":
218
+ return "/images/headshot_default.png";
219
+ default:
220
+ return "/images/headshot_default.png";
221
+ }
222
+ };
223
+ const getAltText = () => {
224
+ switch (entityType) {
225
+ case "player":
226
+ return `${extractedFirstName} ${extractedLastName}`.trim() || "Player avatar";
227
+ case "coach":
228
+ return `${extractedFirstName} ${extractedLastName}`.trim() || "Coach avatar";
229
+ case "team":
230
+ return `${entityData?.team || entityData?.nickname || "Team"} logo`;
231
+ case "initials":
232
+ return `${extractedName}`.trim() || "User avatar";
233
+ case "contact":
234
+ return extractedName || "Profile Picture";
235
+ case "company":
236
+ return extractedName || "Company avatar";
237
+ case "agency":
238
+ return `${extractedFirstName} ${extractedLastName}`.trim() || "User avatar";
239
+ default:
240
+ return "Avatar";
241
+ }
242
+ };
243
+ const processedImageUrl = getImageUrl();
244
+ const defaultImageUrl = getDefaultImageUrl();
245
+ const initials = getInitials();
246
+ const altText = getAltText();
247
+ const hasValidImage = Boolean(
248
+ processedImageUrl && processedImageUrl !== "null" && processedImageUrl !== null && processedImageUrl.trim() !== ""
249
+ );
250
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui_web.Avatar, { className: (0, import_ui_web.cn)(avatarSizeClasses[effectiveSize], isSquared && "rounded-lg", className), children: [
251
+ hasValidImage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui_web.AvatarImage, { src: processedImageUrl, alt: altText }),
252
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
253
+ import_ui_web.AvatarFallback,
254
+ {
255
+ className: (0, import_ui_web.cn)(
256
+ initialsSizeClasses[effectiveSize],
257
+ isSquared && "rounded-lg bg-greys-grey-table-h",
258
+ fallbackClassName
259
+ ),
260
+ children: entityType === "contact" || entityType === "initials" ? initials : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
261
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
262
+ "img",
263
+ {
264
+ src: defaultImageUrl,
265
+ alt: altText,
266
+ className: "aspect-square h-full w-full object-cover"
267
+ }
268
+ ),
269
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only", children: initials })
270
+ ] })
271
+ }
272
+ )
273
+ ] });
274
+ }
275
+
276
+ // src/team/team-info-card.tsx
277
+ var import_jsx_runtime2 = require("react/jsx-runtime");
278
+ var TAB_TRIGGER_CLASS = "flex-1 bg-card text-[13px] text-text-primary data-[state=active]:bg-card data-[state=active]:text-primary-color-nuk-text data-[state=active]:shadow-none border-b border-greys-grey-strokes-tables data-[state=active]:border-primary-color-nuk-ui-elem rounded-none px-0 pb-2 mb-[-1px] relative after:absolute after:left-0 after:-bottom-[1px] after:w-full after:h-[2px] after:content-[''] after:bg-transparent data-[state=active]:after:bg-primary-color-nuk-ui-elem";
279
+ function TeamInfoCard({ team, resolveImageUrl, className }) {
280
+ const teamDisplayName = (0, import_core.formatTeamName)(team.team, team.nickname) || "Team not found";
281
+ const conferenceInfo = team.specificData?.conference || team.specificData?.division ? `${team.specificData.conference || ""} ${team.specificData.division || ""}`.trim() : "";
282
+ const { venue: venueInfo, facility: facilityInfo } = (0, import_core.getTeamPlaceSummaries)(
283
+ team.specificData,
284
+ team.leagueAbbreviation
285
+ );
286
+ const socials = team.specificData?.socials ?? [];
287
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
288
+ import_ui_web2.Card,
289
+ {
290
+ className: (0, import_ui_web2.cn)(
291
+ "p-4 sm:py-4 sm:px-9 w-full xl:w-[420px] flex flex-col overflow-hidden border-none h-full md:min-h-[612px]",
292
+ className
293
+ ),
294
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ui_web2.CardContent, { className: "flex flex-col gap-4 items-center p-0", children: [
295
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex sm:flex-col sm:items-center sm:gap-4", children: [
296
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
297
+ EntityAvatar,
298
+ {
299
+ entityType: "team",
300
+ entityData: {
301
+ team: team.team,
302
+ nickname: team.nickname,
303
+ team_logo_url: team.teamLogoUrl
304
+ },
305
+ resolveImageUrl,
306
+ size: "3xl",
307
+ className: "rounded-none",
308
+ fallbackClassName: "text-2xl font-bold"
309
+ }
310
+ ),
311
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex flex-col gap-2 justify-center px-4 sm:items-center", children: [
312
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "text-text-primary text-[24px] font-black sm:player-card-name", children: teamDisplayName }),
313
+ conferenceInfo && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-sm text-text-primary", children: conferenceInfo })
314
+ ] })
315
+ ] }),
316
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ui_web2.Tabs, { defaultValue: "info", className: "w-full", children: [
317
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ui_web2.TabsList, { className: "grid w-full grid-cols-2 bg-transparent border-b rounded-none h-auto p-0 text-text-primary", children: [
318
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui_web2.TabsTrigger, { value: "info", className: TAB_TRIGGER_CLASS, children: "Info" }),
319
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui_web2.TabsTrigger, { value: "social", className: TAB_TRIGGER_CLASS, children: "Social" })
320
+ ] }),
321
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui_web2.TabsContent, { value: "info", className: "mt-3", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "grid grid-cols-[auto_1fr] gap-4", children: [
322
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-col", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "text-text-primary body-text", children: [
323
+ venueInfo.label,
324
+ ":"
325
+ ] }) }),
326
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-col text-right", children: venueInfo.name ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "text-text-primary body-text", children: [
327
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: venueInfo.name }),
328
+ venueInfo.address && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: venueInfo.address })
329
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-text-primary body-text", children: "No address available" }) }),
330
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-col", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "text-text-primary body-text", children: [
331
+ facilityInfo.label,
332
+ ":"
333
+ ] }) }),
334
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-col text-right", children: facilityInfo.name ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "text-text-primary body-text", children: [
335
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: facilityInfo.name }),
336
+ facilityInfo.address && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: facilityInfo.address })
337
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-text-primary body-text", children: "No address available" }) }),
338
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-col", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-text-primary body-text", children: "Website:" }) }),
339
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-col text-right", children: team.officialWebsite ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
340
+ "a",
341
+ {
342
+ href: /^https?:\/\//.test(team.officialWebsite) ? team.officialWebsite : `http://${team.officialWebsite}`,
343
+ target: "_blank",
344
+ rel: "noopener noreferrer",
345
+ className: "text-primary-color-nuk-text body-text inline-flex items-center justify-end gap-1",
346
+ children: [
347
+ team.officialWebsite.replace(/^https?:\/\//, ""),
348
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { className: "w-3 h-3", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
349
+ "path",
350
+ {
351
+ strokeLinecap: "round",
352
+ strokeLinejoin: "round",
353
+ strokeWidth: 2,
354
+ d: "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
355
+ }
356
+ ) })
357
+ ]
358
+ }
359
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-text-primary body-text", children: "No website available" }) })
360
+ ] }) }),
361
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui_web2.TabsContent, { value: "social", className: "mt-3", children: socials.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-text-primary body-text", children: "No social networks yet." }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-col gap-3", children: socials.map((social) => {
362
+ const handle = social.handle || social.url?.split("/").pop() || "";
363
+ const url = social.url || `https://${social.platform.toLowerCase()}.com/${handle}`;
364
+ const displayHandle = handle.startsWith("@") ? handle : `@${handle}`;
365
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
366
+ "div",
367
+ {
368
+ className: "flex items-center justify-between gap-2",
369
+ children: [
370
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "text-text-primary body-text", children: social.platform }),
371
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
372
+ "a",
373
+ {
374
+ href: url,
375
+ target: "_blank",
376
+ rel: "noopener noreferrer",
377
+ className: "text-primary-color-nuk-text body-text hover:underline line-clamp-2 break-words",
378
+ children: displayHandle
379
+ }
380
+ )
381
+ ]
382
+ },
383
+ `${social.platform}:${social.handle ?? ""}:${social.url ?? ""}`
384
+ );
385
+ }) }) })
386
+ ] })
387
+ ] })
388
+ }
389
+ );
390
+ }
391
+
392
+ // src/team/team-staff-table.tsx
393
+ var import_react = require("react");
394
+ var import_ui_web3 = require("@nukleus-sports/ui-web");
395
+ var import_core2 = require("@nukleus-sports/core");
396
+ var import_jsx_runtime3 = require("react/jsx-runtime");
397
+ var CATEGORY_ORDER = [
398
+ "Head Coaches",
399
+ "Assistant Coaches",
400
+ "Offensive Coaches",
401
+ "Defensive Coaches",
402
+ "Special Teams Coaches"
403
+ ];
404
+ var UNCATEGORIZED_LABEL = "Other Coaches";
405
+ var DEFAULT_SORT = [{ id: "display_order", desc: false }];
406
+ function TeamStaffTable({
407
+ staff,
408
+ loading,
409
+ isError,
410
+ interactive = false,
411
+ onStaffClick,
412
+ sortable = false,
413
+ sorting,
414
+ onSortingChange,
415
+ virtualized = false,
416
+ isSplitLayout = false,
417
+ isCompact = false,
418
+ resolveImageUrl,
419
+ className
420
+ }) {
421
+ const [internalSorting, setInternalSorting] = (0, import_react.useState)(DEFAULT_SORT);
422
+ const activeSorting = sorting ?? internalSorting;
423
+ const handleSortingChange = onSortingChange ?? setInternalSorting;
424
+ const effectiveVirtualized = virtualized && !isSplitLayout;
425
+ const rows = (0, import_react.useMemo)(() => {
426
+ if (staff.length === 0) return [];
427
+ const grouped = /* @__PURE__ */ new Map();
428
+ for (const member of staff) {
429
+ const key = member.position_group || UNCATEGORIZED_LABEL;
430
+ if (!grouped.has(key)) grouped.set(key, []);
431
+ grouped.get(key).push(member);
432
+ }
433
+ grouped.forEach((list, key) => {
434
+ grouped.set(key, (0, import_core2.sortTeamStaff)(list, activeSorting));
435
+ });
436
+ const orderedKeys = [
437
+ ...CATEGORY_ORDER.filter((k) => grouped.has(k)),
438
+ ...Array.from(grouped.keys()).filter((k) => !CATEGORY_ORDER.includes(k))
439
+ ];
440
+ const result = [];
441
+ for (const key of orderedKeys) {
442
+ result.push({
443
+ id: -1 * (result.length + 1),
444
+ first_name: "",
445
+ last_name: "",
446
+ position: null,
447
+ position_group: key,
448
+ coach_image_url: null,
449
+ display_order: 0,
450
+ __isCategoryRow: true,
451
+ __categoryLabel: key
452
+ });
453
+ result.push(...grouped.get(key));
454
+ }
455
+ return result;
456
+ }, [staff, activeSorting]);
457
+ const { visibleItems, sentinelRef, hasMore } = (0, import_ui_web3.useInfiniteList)(rows, {
458
+ resetKey: `${staff.length}|${JSON.stringify(activeSorting)}`
459
+ });
460
+ const displayedRows = effectiveVirtualized ? visibleItems : rows;
461
+ const columns = (0, import_react.useMemo)(() => {
462
+ const activate = (id) => onStaffClick?.(id);
463
+ const interactionProps = (id, ariaLabel) => interactive ? {
464
+ onClick: () => activate(id),
465
+ onKeyDown: (e) => {
466
+ if (e.key === "Enter" || e.key === " ") {
467
+ e.preventDefault();
468
+ activate(id);
469
+ }
470
+ },
471
+ tabIndex: 0,
472
+ role: "button",
473
+ "aria-label": ariaLabel
474
+ } : {};
475
+ const nameHeader = sortable ? (0, import_ui_web3.createClickableSortableHeader)("Name") : "Name";
476
+ const positionHeader = sortable ? (0, import_ui_web3.createClickableSortableHeader)("Position") : "Position";
477
+ return [
478
+ {
479
+ id: "name",
480
+ header: nameHeader,
481
+ accessorFn: (row) => `${row.first_name} ${row.last_name}`,
482
+ cell: ({ row }) => {
483
+ const member = row.original;
484
+ const fullName = `${member.first_name} ${member.last_name}`.trim();
485
+ const labelText = `View ${fullName}'s profile`;
486
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex gap-2 items-center w-full line-clamp-2", children: [
487
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
488
+ "div",
489
+ {
490
+ className: (0, import_ui_web3.cn)("flex items-center justify-center", interactive && "cursor-pointer"),
491
+ ...interactionProps(member.id, labelText),
492
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
493
+ EntityAvatar,
494
+ {
495
+ entityType: "coach",
496
+ entityData: {
497
+ first_name: member.first_name,
498
+ last_name: member.last_name,
499
+ coach_image_url: member.coach_image_url
500
+ },
501
+ resolveImageUrl,
502
+ size: isCompact ? "xs" : "lg"
503
+ }
504
+ )
505
+ }
506
+ ),
507
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
508
+ "div",
509
+ {
510
+ className: (0, import_ui_web3.cn)("line-clamp-2", interactive && "cursor-pointer"),
511
+ ...interactionProps(member.id, labelText),
512
+ children: fullName
513
+ }
514
+ )
515
+ ] });
516
+ },
517
+ meta: { cellSize: isCompact ? "teamMobile" : "xl" }
518
+ },
519
+ {
520
+ id: "position",
521
+ header: positionHeader,
522
+ accessorFn: (row) => row.position || "-",
523
+ cell: ({ row }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "flex items-center h-full min-h-[46px]", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
524
+ "span",
525
+ {
526
+ className: (0, import_ui_web3.cn)("line-clamp-2 break-words", interactive && "cursor-pointer"),
527
+ ...interactionProps(
528
+ row.original.id,
529
+ `View ${row.original.first_name} ${row.original.last_name}'s position`
530
+ ),
531
+ children: row.original.position || "-"
532
+ }
533
+ ) }),
534
+ meta: { cellSize: "l" }
535
+ }
536
+ ];
537
+ }, [interactive, onStaffClick, sortable, isCompact, resolveImageUrl]);
538
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "w-full xl:flex xl:h-full xl:flex-1 xl:min-h-0 xl:flex-col xl:overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
539
+ import_ui_web3.BaseTable,
540
+ {
541
+ columns,
542
+ data: displayedRows,
543
+ sorting: sortable ? activeSorting : void 0,
544
+ onSortingChange: sortable ? ((updater) => {
545
+ const next = typeof updater === "function" ? updater(activeSorting) : updater;
546
+ handleSortingChange(next);
547
+ }) : void 0,
548
+ manualSorting: sortable,
549
+ loading,
550
+ emptyMessage: isError ? "Failed to load coaching staff. Please try again." : "No coaches found.",
551
+ pageSize: Math.max(displayedRows.length, 25),
552
+ hidePagination: effectiveVirtualized,
553
+ stickyHeader: true,
554
+ splitLayout: isSplitLayout,
555
+ numberOfColumns: 1,
556
+ splitLayoutGridCols: isCompact ? "!grid-cols-[minmax(120px,120px)_1fr]" : isSplitLayout ? "sm:!grid-cols-[minmax(220px,220px)_1fr]" : "",
557
+ containerClassName: (0, import_ui_web3.cn)("border-0 rounded-none", effectiveVirtualized && "h-full"),
558
+ className: (0, import_ui_web3.cn)(
559
+ "border-none",
560
+ effectiveVirtualized && "h-full min-h-0 w-full xl:flex-1 xl:overflow-hidden",
561
+ className
562
+ ),
563
+ bottomContent: effectiveVirtualized && hasMore ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: sentinelRef, className: "h-px w-full" }) : null,
564
+ getRowBanner: (row) => row.__isCategoryRow ? row.__categoryLabel : null,
565
+ bannerRowClassName: "bg-greys-background-hover hover:bg-greys-background-hover",
566
+ getRowClassName: (row) => row.__isCategoryRow ? "hidden" : ""
567
+ }
568
+ ) });
569
+ }
570
+
571
+ // src/team/stat-column.tsx
572
+ var import_jsx_runtime4 = require("react/jsx-runtime");
573
+ function StatColumn({ label, value, suffix, rankBadge }) {
574
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-col items-center h-full justify-center flex-1 gap-1 sm:gap-3 w-full", children: [
575
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "label-xs-medium text-text-secondary leading-normal opacity-[0.8] ss05", children: label }),
576
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "text-[19px] font-semibold sm:text-[32px] sm:font-bold text-text-primary leading-normal title-text opacity-[0.8]", children: [
577
+ value,
578
+ suffix || ""
579
+ ] }),
580
+ rankBadge
581
+ ] });
582
+ }
583
+
584
+ // src/team/team-season-stats-summary-panel.tsx
585
+ var import_ui_web4 = require("@nukleus-sports/ui-web");
586
+ var import_core3 = require("@nukleus-sports/core");
587
+ var import_jsx_runtime5 = require("react/jsx-runtime");
588
+ function getStatusMessage({
589
+ isSupportedSport,
590
+ selectedYear,
591
+ selectedType,
592
+ isError,
593
+ stats
594
+ }) {
595
+ if (!isSupportedSport) return "Team season stats coming soon.";
596
+ if (!selectedYear || selectedType === null) return "Select a season to view stats.";
597
+ if (isError && !stats) return "Couldn't load season stats. Please try again.";
598
+ if (!stats) return "No season stats for the current season.";
599
+ return null;
600
+ }
601
+ function TeamSeasonStatsSummaryPanel({
602
+ sportId,
603
+ selectedYear,
604
+ selectedType,
605
+ stats,
606
+ loading,
607
+ isError,
608
+ className
609
+ }) {
610
+ const columns = (0, import_core3.getTeamStatColumns)(sportId);
611
+ const statusMessage = loading ? null : getStatusMessage({
612
+ isSupportedSport: (0, import_core3.isSupportedTeamStatsSport)(sportId),
613
+ selectedYear,
614
+ selectedType,
615
+ isError,
616
+ stats
617
+ });
618
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_ui_web4.Card, { className: (0, import_ui_web4.cn)("border-0 p-4 flex flex-col gap-4", className), children: [
619
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_ui_web4.CardHeader, { className: "p-0", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_ui_web4.CardTitle, { className: "text-base text-text-primary font-medium leading-normal", children: "Season Stats" }) }),
620
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_ui_web4.CardContent, { className: "p-0 flex-1 flex justify-center items-center", children: loading ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex items-center justify-center w-full", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_ui_web4.Skeleton, { className: "h-4 w-3/4" }) }) : statusMessage ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex items-center justify-center w-full text-14.5 text-text-secondary", children: statusMessage }) : stats && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "w-full flex flex-col sm:flex-row gap-6 sm:gap-3 justify-between items-center", children: columns.map((col, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
621
+ StatColumn,
622
+ {
623
+ label: col.label,
624
+ value: stats.values[i],
625
+ suffix: col.suffix
626
+ },
627
+ col.label
628
+ )) }) })
629
+ ] });
630
+ }
631
+
632
+ // src/team/team-season-schedule-summary-panel.tsx
633
+ var import_ui_web5 = require("@nukleus-sports/ui-web");
634
+ var import_jsx_runtime6 = require("react/jsx-runtime");
635
+ function TeamSeasonScheduleSummaryPanel({
636
+ selectedYear,
637
+ selectedType,
638
+ summary,
639
+ loading,
640
+ isError,
641
+ className
642
+ }) {
643
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_ui_web5.Card, { className: (0, import_ui_web5.cn)("border-0 p-4 flex flex-col gap-4", className), children: [
644
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui_web5.CardHeader, { className: "p-0", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui_web5.CardTitle, { className: "text-base text-text-primary font-medium leading-normal", children: "Season Summary" }) }),
645
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui_web5.CardContent, { className: "p-0 flex-1 flex justify-center items-center", children: loading ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex items-center justify-center w-full", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_ui_web5.Skeleton, { className: "h-4 w-3/4" }) }) : !selectedYear || selectedType === null ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex items-center justify-center w-full text-14.5 text-text-secondary", children: "Select a season to view summary." }) : isError && !summary ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex items-center justify-center w-full text-14.5 text-text-secondary", children: "Couldn't load the schedule summary. Please try again." }) : !summary ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex items-center justify-center w-full text-14.5 text-text-secondary", children: "No schedule data for the current season." }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "w-full flex flex-col sm:flex-row gap-6 sm:gap-3 justify-between items-center", children: [
646
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StatColumn, { label: "Record", value: summary.record }),
647
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
648
+ StatColumn,
649
+ {
650
+ label: "Games Played",
651
+ value: `${summary.gamesPlayed} of ${summary.totalGames}`
652
+ }
653
+ )
654
+ ] }) })
655
+ ] });
656
+ }
657
+
658
+ // src/team/season-selector.tsx
659
+ var import_ui_web6 = require("@nukleus-sports/ui-web");
660
+ var import_jsx_runtime7 = require("react/jsx-runtime");
661
+ function SeasonSelector({
662
+ years,
663
+ types,
664
+ selectedYear,
665
+ selectedType,
666
+ onYearChange,
667
+ onTypeChange,
668
+ hideTypeOnMobile = false,
669
+ className
670
+ }) {
671
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: (0, import_ui_web6.cn)("flex gap-3", className), children: [
672
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
673
+ import_ui_web6.Select,
674
+ {
675
+ value: selectedYear?.toString() ?? "",
676
+ onValueChange: (value) => onYearChange(Number(value)),
677
+ children: [
678
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui_web6.SelectTrigger, { variant: "widget", size: "widget", "aria-label": "Season year", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui_web6.SelectValue, { placeholder: "Select year" }) }),
679
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
680
+ import_ui_web6.SelectContent,
681
+ {
682
+ className: "bg-card border-border z-50 [&_.checkbox]:!flex",
683
+ classNameViewPort: "gap-2",
684
+ children: years.map((year) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui_web6.SelectItem, { value: year.value.toString(), className: "min-h-8", children: year.label }, year.value))
685
+ }
686
+ )
687
+ ]
688
+ }
689
+ ),
690
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: (0, import_ui_web6.cn)(hideTypeOnMobile && "hidden sm:block"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
691
+ import_ui_web6.Select,
692
+ {
693
+ value: selectedType?.toString() ?? "",
694
+ onValueChange: (value) => onTypeChange(Number(value)),
695
+ disabled: selectedYear === null,
696
+ children: [
697
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui_web6.SelectTrigger, { variant: "widget", size: "widget", "aria-label": "Season type", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui_web6.SelectValue, { placeholder: "Select type" }) }),
698
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
699
+ import_ui_web6.SelectContent,
700
+ {
701
+ className: "bg-card border-border z-50 [&_.checkbox]:!flex",
702
+ classNameViewPort: "gap-2",
703
+ children: types.map((type) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui_web6.SelectItem, { value: type.value.toString(), className: "min-h-8", children: type.label }, type.value))
704
+ }
705
+ )
706
+ ]
707
+ }
708
+ ) })
709
+ ] });
710
+ }
711
+
712
+ // src/team/fact-pills.tsx
713
+ var import_react2 = require("react");
714
+ var import_ui_web7 = require("@nukleus-sports/ui-web");
715
+ var import_jsx_runtime8 = require("react/jsx-runtime");
716
+ var MAX_ROWS = 2;
717
+ var KEY_SEPARATOR = "";
718
+ var PILL_CLASS = "flex min-w-0 max-w-full shrink-0 items-center justify-center rounded-[6px] bg-greys-background-hover px-2 py-0.5 label-xs-table font-ss02-ss05 text-text-primary";
719
+ var TOGGLE_CLASS = "flex shrink-0 items-center py-0.5 label-xs-table font-ss02-ss05 text-primary-color-nuk-text hover:underline focus-visible:underline focus-visible:outline-none";
720
+ function pillKeys(items) {
721
+ const seen = /* @__PURE__ */ new Map();
722
+ return items.map((item) => {
723
+ const text = String(item);
724
+ const count = seen.get(text) ?? 0;
725
+ seen.set(text, count + 1);
726
+ return `${text}${KEY_SEPARATOR}${count}`;
727
+ });
728
+ }
729
+ function FactPills({ items, capped = false }) {
730
+ const listId = (0, import_react2.useId)();
731
+ const listRef = (0, import_react2.useRef)(null);
732
+ const [expanded, setExpanded] = (0, import_react2.useState)(false);
733
+ const [visibleCount, setVisibleCount] = (0, import_react2.useState)(null);
734
+ const [clipHeight, setClipHeight] = (0, import_react2.useState)(null);
735
+ const [width, setWidth] = (0, import_react2.useState)(0);
736
+ const contentKey = items.join(KEY_SEPARATOR);
737
+ const keys = pillKeys(items);
738
+ const collapsible = capped && !expanded;
739
+ (0, import_react2.useLayoutEffect)(() => {
740
+ const list = listRef.current;
741
+ if (!capped || !list || typeof ResizeObserver === "undefined") return;
742
+ const observer = new ResizeObserver((entries) => {
743
+ const next = Math.round(entries[0]?.contentRect.width ?? 0);
744
+ setWidth((prev) => prev === next ? prev : next);
745
+ });
746
+ observer.observe(list);
747
+ return () => observer.disconnect();
748
+ }, [capped]);
749
+ const measurementKey = `${width}:${contentKey}`;
750
+ const [measuredFor, setMeasuredFor] = (0, import_react2.useState)(measurementKey);
751
+ if (measuredFor !== measurementKey) {
752
+ setMeasuredFor(measurementKey);
753
+ if (visibleCount !== null) setVisibleCount(null);
754
+ }
755
+ (0, import_react2.useLayoutEffect)(() => {
756
+ const list = listRef.current;
757
+ if (!collapsible || !list) return;
758
+ const children = Array.from(list.children).filter(
759
+ (el) => el instanceof HTMLElement
760
+ );
761
+ const first = children[0];
762
+ if (!first || first.offsetHeight === 0) return;
763
+ const rowGap = Number.parseFloat(getComputedStyle(list).rowGap) || 0;
764
+ const rowStep = first.offsetHeight + rowGap;
765
+ const lastRowTop = first.offsetTop + rowStep * (MAX_ROWS - 1);
766
+ const fits = (el) => el.offsetTop <= lastRowTop + 1;
767
+ if (visibleCount === null) {
768
+ const nextClip = Math.ceil(rowStep * MAX_ROWS - rowGap);
769
+ setClipHeight((prev) => prev === nextClip ? prev : nextClip);
770
+ const fitting = children.filter(fits).length;
771
+ if (fitting < items.length) setVisibleCount(fitting);
772
+ return;
773
+ }
774
+ const toggle = children[children.length - 1];
775
+ if (toggle && !fits(toggle)) {
776
+ setVisibleCount((prev) => prev !== null && prev > 0 ? prev - 1 : prev);
777
+ }
778
+ }, [collapsible, visibleCount, contentKey, items.length, width]);
779
+ const truncated = collapsible && visibleCount !== null && visibleCount < items.length;
780
+ const shownCount = truncated ? visibleCount : items.length;
781
+ const handleShowMore = () => setExpanded(true);
782
+ const handleShowLess = () => {
783
+ setExpanded(false);
784
+ setVisibleCount(null);
785
+ };
786
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
787
+ "ul",
788
+ {
789
+ id: listId,
790
+ ref: listRef,
791
+ className: (0, import_ui_web7.cn)(
792
+ "flex w-full flex-wrap content-start items-start gap-1",
793
+ collapsible && "overflow-hidden"
794
+ ),
795
+ style: collapsible && clipHeight !== null ? { maxHeight: clipHeight } : void 0,
796
+ children: [
797
+ items.slice(0, shownCount).map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { className: PILL_CLASS, title: String(item), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "truncate", children: item }) }, keys[index])),
798
+ truncated && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { className: "flex shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
799
+ "button",
800
+ {
801
+ type: "button",
802
+ className: TOGGLE_CLASS,
803
+ "aria-expanded": false,
804
+ "aria-controls": listId,
805
+ onClick: handleShowMore,
806
+ children: "Show More"
807
+ }
808
+ ) }),
809
+ capped && expanded && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { className: "flex shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
810
+ "button",
811
+ {
812
+ type: "button",
813
+ className: TOGGLE_CLASS,
814
+ "aria-expanded": true,
815
+ "aria-controls": listId,
816
+ onClick: handleShowLess,
817
+ children: "Show Less"
818
+ }
819
+ ) })
820
+ ]
821
+ }
822
+ );
823
+ }
824
+
825
+ // src/team/fact-field.tsx
826
+ var import_ui_web8 = require("@nukleus-sports/ui-web");
827
+ var import_core4 = require("@nukleus-sports/core");
828
+ var import_jsx_runtime9 = require("react/jsx-runtime");
829
+ function numberFact(facts, key) {
830
+ const value = facts[key];
831
+ return typeof value === "number" ? value : null;
832
+ }
833
+ function listFact(facts, key) {
834
+ const value = facts[key];
835
+ return Array.isArray(value) ? value : [];
836
+ }
837
+ function textFact(facts, key) {
838
+ const value = facts[key];
839
+ return typeof value === "string" ? value : null;
840
+ }
841
+ function EmptyValue({ children = import_core4.EMPTY_FACT_VALUE }) {
842
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "body-text font-ss02-ss05 text-text-secondary", children });
843
+ }
844
+ function FieldLabel({ children }) {
845
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "w-full label-xs-text font-ss02-ss05 text-text-secondary", children });
846
+ }
847
+ function CountFact({
848
+ factKey,
849
+ data
850
+ }) {
851
+ const { facts, config } = data;
852
+ const pairedYears = import_core4.TEAM_FACT_YEAR_PAIRS[factKey];
853
+ const years = pairedYears ? (0, import_core4.formatYearPills)(listFact(facts, pairedYears), config.formatChampionshipYear) : [];
854
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex min-w-0 flex-col items-start gap-1", children: [
855
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FieldLabel, { children: config.labels[factKey] }),
856
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "stat-count-number title-text text-text-primary", children: (0, import_core4.formatTeamFactNumber)("count", numberFact(facts, factKey)) }),
857
+ years.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FactPills, { items: years, capped: true })
858
+ ] });
859
+ }
860
+ function RivalValue({
861
+ rival,
862
+ resolveImageUrl,
863
+ getRivalHref
864
+ }) {
865
+ switch (rival.status) {
866
+ case "none":
867
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(EmptyValue, {});
868
+ case "loading":
869
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_ui_web8.Skeleton, { className: "h-8 w-40", "aria-label": "Loading rival" });
870
+ case "error":
871
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(EmptyValue, { children: "Couldn't load the rival team" });
872
+ case "ready": {
873
+ const content = /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
874
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
875
+ EntityAvatar,
876
+ {
877
+ entityType: "initials",
878
+ name: rival.rival.name,
879
+ imageUrl: rival.rival.teamLogoUrl,
880
+ resolveImageUrl,
881
+ size: "md",
882
+ className: "shrink-0"
883
+ }
884
+ ),
885
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "min-w-0", children: rival.rival.name })
886
+ ] });
887
+ const className = "inline-flex max-w-full items-center gap-1.5 body-text-semibold font-ss02-ss05 text-primary-color-nuk-text";
888
+ return getRivalHref ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("a", { href: getRivalHref(rival.rival.id), className: (0, import_ui_web8.cn)(className, "hover:underline"), children: content }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className, children: content });
889
+ }
890
+ }
891
+ }
892
+ function factValue(factKey, layout, data, resolveImageUrl, getRivalHref) {
893
+ const { facts, config } = data;
894
+ const kind = import_core4.TEAM_FACT_KINDS[factKey];
895
+ if (kind === "number" || kind === "year" || kind === "text") {
896
+ const display = kind === "text" ? textFact(facts, factKey) : (0, import_core4.formatTeamFactNumber)(kind, numberFact(facts, factKey));
897
+ const isEmpty = !display || display === import_core4.EMPTY_FACT_VALUE;
898
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
899
+ "span",
900
+ {
901
+ className: (0, import_ui_web8.cn)(
902
+ "w-full header-xl-medium-card font-ss02-ss05 [overflow-wrap:anywhere]",
903
+ isEmpty ? "text-text-secondary" : "text-text-primary"
904
+ ),
905
+ children: display ?? import_core4.EMPTY_FACT_VALUE
906
+ }
907
+ );
908
+ }
909
+ if (kind === "years" || kind === "labeled_years" || kind === "list") {
910
+ const raw = listFact(facts, factKey);
911
+ const items = kind === "years" ? (0, import_core4.formatYearPills)(raw, config.formatChampionshipYear) : raw;
912
+ return items.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FactPills, { items, capped: layout === "grid" }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(EmptyValue, {});
913
+ }
914
+ if (kind === "rival") {
915
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
916
+ RivalValue,
917
+ {
918
+ rival: data.rival,
919
+ resolveImageUrl,
920
+ getRivalHref
921
+ }
922
+ );
923
+ }
924
+ const text = textFact(facts, factKey);
925
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
926
+ "p",
927
+ {
928
+ className: (0, import_ui_web8.cn)(
929
+ "w-full body-text font-ss02-ss05 whitespace-pre-line",
930
+ text ? "text-text-primary" : "text-text-secondary"
931
+ ),
932
+ children: text ?? import_core4.EMPTY_FACT_VALUE
933
+ }
934
+ );
935
+ }
936
+ function FactField({
937
+ factKey,
938
+ layout,
939
+ data,
940
+ resolveImageUrl,
941
+ getRivalHref
942
+ }) {
943
+ const kind = import_core4.TEAM_FACT_KINDS[factKey];
944
+ if (kind === "count") return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CountFact, { factKey, data });
945
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
946
+ "div",
947
+ {
948
+ className: (0, import_ui_web8.cn)(
949
+ "flex min-w-0 flex-col items-start gap-1.5",
950
+ layout === "row" && "flex-1",
951
+ layout === "grid" && kind !== "list" && "gap-1"
952
+ ),
953
+ children: [
954
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FieldLabel, { children: data.config.labels[factKey] }),
955
+ factValue(factKey, layout, data, resolveImageUrl, getRivalHref)
956
+ ]
957
+ }
958
+ );
959
+ }
960
+
961
+ // src/team/venue-photo.tsx
962
+ var import_react3 = require("react");
963
+ var import_ui_web9 = require("@nukleus-sports/ui-web");
964
+ var import_icons = require("@nukleus-sports/icons");
965
+ var import_core5 = require("@nukleus-sports/core");
966
+ var import_jsx_runtime10 = require("react/jsx-runtime");
967
+ var PHOTO_WIDTHS = [640, 960, 1280];
968
+ var PHOTO_SIZES = "(min-width: 1280px) 420px, 100vw";
969
+ var LINK_CLASS = "inline-flex shrink-0 items-center gap-1 hover:text-text-primary";
970
+ function NewTabNote() {
971
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "sr-only", children: " (opens in a new tab)" });
972
+ }
973
+ function resolvePhotoSources(path, resolveImageUrl) {
974
+ const candidates = PHOTO_WIDTHS.flatMap((width) => {
975
+ const url = resolveImageUrl(path, width);
976
+ return url ? [{ url, width }] : [];
977
+ });
978
+ return {
979
+ original: resolveImageUrl(path) ?? void 0,
980
+ srcSet: candidates.length ? candidates.map(({ url, width }) => `${url} ${width}w`).join(", ") : void 0,
981
+ resized: resolveImageUrl(path, 960) ?? candidates[0]?.url
982
+ };
983
+ }
984
+ function VenueNameOnly({ name, label }) {
985
+ if (!name) return null;
986
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex min-w-0 flex-col items-start gap-1.5", children: [
987
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FieldLabel, { children: label }),
988
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "w-full header-xl-medium-card font-ss02-ss05 text-text-primary", children: name })
989
+ ] });
990
+ }
991
+ function PhotoCaption({ name, image }) {
992
+ const credit = (0, import_core5.facilityImageCredit)(image);
993
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("figcaption", { className: "flex w-full flex-col gap-1 xxs-body-text font-ss02-ss05", children: [
994
+ name && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "w-full text-text-primary", children: name }),
995
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex w-full items-start gap-2 text-greys-text-secondary", children: [
996
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "min-w-0 flex-1", children: credit ? `Photo: ${credit}` : "Photo from Wikimedia Commons" }),
997
+ image.sourceUrl && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
998
+ "a",
999
+ {
1000
+ href: image.sourceUrl,
1001
+ target: "_blank",
1002
+ rel: "noopener noreferrer",
1003
+ className: LINK_CLASS,
1004
+ children: [
1005
+ "Source",
1006
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(NewTabNote, {}),
1007
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { "aria-hidden": "true", className: "flex shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1008
+ import_icons.XsViewInvoiceIcon,
1009
+ {
1010
+ width: 16,
1011
+ height: 16,
1012
+ className: "shrink-0 text-greys-ui-elem-strokes"
1013
+ }
1014
+ ) })
1015
+ ]
1016
+ }
1017
+ ),
1018
+ image.licenseUrl && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1019
+ "a",
1020
+ {
1021
+ href: image.licenseUrl,
1022
+ target: "_blank",
1023
+ rel: "noopener noreferrer",
1024
+ className: LINK_CLASS,
1025
+ children: [
1026
+ "License",
1027
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(NewTabNote, {})
1028
+ ]
1029
+ }
1030
+ )
1031
+ ] })
1032
+ ] });
1033
+ }
1034
+ function VenuePhoto({ venue, label, resolveImageUrl }) {
1035
+ const { name, image } = venue;
1036
+ const [failed, setFailed] = (0, import_react3.useState)("none");
1037
+ const [isLoaded, setIsLoaded] = (0, import_react3.useState)(false);
1038
+ const sources = image && resolveImageUrl ? resolvePhotoSources(image.path, resolveImageUrl) : null;
1039
+ const useResized = failed === "none" && Boolean(sources?.srcSet);
1040
+ const src = failed === "all" ? void 0 : useResized ? sources?.resized : sources?.original;
1041
+ if (!image || !src) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(VenueNameOnly, { name, label });
1042
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("figure", { className: "flex w-full flex-col gap-3", children: [
1043
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1044
+ "img",
1045
+ {
1046
+ src,
1047
+ srcSet: useResized ? sources?.srcSet : void 0,
1048
+ sizes: useResized ? PHOTO_SIZES : void 0,
1049
+ onLoad: () => setIsLoaded(true),
1050
+ onError: () => setFailed(useResized ? "resized" : "all"),
1051
+ alt: name ?? label,
1052
+ className: (0, import_ui_web9.cn)(
1053
+ "h-[150px] w-full rounded-[8px] bg-greys-background-hover object-cover",
1054
+ !isLoaded && "animate-pulse"
1055
+ ),
1056
+ loading: "lazy"
1057
+ }
1058
+ ),
1059
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PhotoCaption, { name, image })
1060
+ ] });
1061
+ }
1062
+
1063
+ // src/team/team-facts-content.tsx
1064
+ var import_core6 = require("@nukleus-sports/core");
1065
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1066
+ var SECTION_FIELDS_CLASS = {
1067
+ grid: "grid grid-cols-2 items-start gap-3",
1068
+ row: "flex items-start gap-3",
1069
+ column: "flex flex-col gap-3"
1070
+ };
1071
+ var SECTION_CLASS = (
1072
+ // 11px + the 1px border = a 12px inset.
1073
+ "flex w-full min-w-0 flex-col gap-3 overflow-hidden rounded-[10px] border border-greys-grey-strokes-tables bg-greys-light-grey p-3"
1074
+ );
1075
+ function TeamFactsContent({
1076
+ data,
1077
+ resolveImageUrl,
1078
+ resolveVenuePhotoUrl,
1079
+ getRivalHref
1080
+ }) {
1081
+ const { config, venue, hasFacts } = data;
1082
+ const photo = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1083
+ VenuePhoto,
1084
+ {
1085
+ venue,
1086
+ label: config.venue.label,
1087
+ resolveImageUrl: resolveVenuePhotoUrl
1088
+ },
1089
+ venue.image?.path ?? "none"
1090
+ );
1091
+ if (!hasFacts) {
1092
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex flex-col gap-3", children: [
1093
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "flex h-[120px] items-center justify-center rounded-[10px] border border-dashed border-greys-grey-strokes-tables text-14.5 text-text-secondary", children: "No team facts yet." }),
1094
+ (venue.image || venue.name) && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("section", { className: SECTION_CLASS, children: photo })
1095
+ ] });
1096
+ }
1097
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "flex flex-col gap-3", children: config.sections.map((section) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("section", { "aria-label": section.title, className: SECTION_CLASS, children: [
1098
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h3", { className: "label-xs-semibold-text font-ss02-ss05 uppercase text-greys-text-secondary", children: section.title }),
1099
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: SECTION_FIELDS_CLASS[section.layout], children: (0, import_core6.teamFactsDisplayFields)(section).map((key) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1100
+ FactField,
1101
+ {
1102
+ factKey: key,
1103
+ layout: section.layout,
1104
+ data,
1105
+ resolveImageUrl,
1106
+ getRivalHref
1107
+ },
1108
+ key
1109
+ )) }),
1110
+ section.showsVenuePhoto && photo
1111
+ ] }, section.title)) });
1112
+ }
1113
+
1114
+ // src/team/team-facts-widget.tsx
1115
+ var import_ui_web10 = require("@nukleus-sports/ui-web");
1116
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1117
+ var SKELETON_KEYS = ["trophy-case", "tradition", "profile"];
1118
+ function TeamFactsWidget({
1119
+ state,
1120
+ resolveImageUrl,
1121
+ resolveVenuePhotoUrl,
1122
+ getRivalHref,
1123
+ className
1124
+ }) {
1125
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1126
+ import_ui_web10.Card,
1127
+ {
1128
+ className: (0, import_ui_web10.cn)(
1129
+ "flex w-full min-w-0 flex-col gap-3 rounded-[10px] border-0 px-4 pb-[22px] pt-4",
1130
+ // Matches the Team Info card's desktop height (TeamInfoCard `md:min-h-[612px]`).
1131
+ "xl:min-h-[612px] xl:self-stretch xl:[contain:size]",
1132
+ className
1133
+ ),
1134
+ children: [
1135
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui_web10.CardHeader, { className: "flex h-8 shrink-0 flex-row items-center p-0", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui_web10.CardTitle, { className: "header-xl-medium-card font-ss02-ss05 text-text-primary", children: "Team Facts" }) }),
1136
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_ui_web10.CardContent, { className: "p-0 xl:min-h-0 xl:flex-1 xl:overflow-y-auto xl:[scrollbar-width:none] xl:[&::-webkit-scrollbar]:hidden", children: [
1137
+ state.status === "loading" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex flex-col gap-3", role: "status", "aria-label": "Loading team facts", children: SKELETON_KEYS.map((key) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui_web10.Skeleton, { className: "h-[200px] w-full rounded-[10px]" }, key)) }),
1138
+ state.status === "error" && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1139
+ "div",
1140
+ {
1141
+ role: "alert",
1142
+ className: "flex h-[120px] flex-col items-center justify-center gap-2 text-14.5 text-text-secondary",
1143
+ children: [
1144
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: "Couldn't load team facts." }),
1145
+ state.devMessage && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "xxs-body-text", children: state.devMessage }),
1146
+ state.retry && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ui_web10.Button, { type: "button", variant: "outline", size: "sm", onClick: state.retry, children: "Try again" })
1147
+ ]
1148
+ }
1149
+ ),
1150
+ state.status === "ready" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1151
+ TeamFactsContent,
1152
+ {
1153
+ data: state.data,
1154
+ resolveImageUrl,
1155
+ resolveVenuePhotoUrl,
1156
+ getRivalHref
1157
+ },
1158
+ state.data.teamId
1159
+ )
1160
+ ] })
1161
+ ]
1162
+ }
1163
+ );
1164
+ }
1165
+
1166
+ // src/team/stat-ranking-leaderboard-dialog.tsx
1167
+ var import_react4 = require("react");
1168
+ var import_ui_web11 = require("@nukleus-sports/ui-web");
1169
+ var import_icons2 = require("@nukleus-sports/icons");
1170
+ var import_core7 = require("@nukleus-sports/core");
1171
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1172
+ var PAGE_BUTTON_BASE = "background";
1173
+ var PAGE_BUTTON_DESKTOP = "!h-[32px] !w-[32px] p-[6px]";
1174
+ var PAGE_BUTTON_MOBILE = "!h-11 !w-11 p-3 !outline-0 !border-0 !bg-inherit";
1175
+ var HIGHLIGHT_CLASS = "text-semantic-color-status-priority-completed-copy bg-primary-color-total-row-table-2";
1176
+ function formatRank(rank, tied) {
1177
+ return tied ? `T-${(0, import_core7.toOrdinal)(rank)}` : (0, import_core7.toOrdinal)(rank);
1178
+ }
1179
+ function Footnotes({ notes }) {
1180
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { children: notes.map((note) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { className: "alert-text-italic text-text-secondary", children: [
1181
+ "* ",
1182
+ note
1183
+ ] }, note)) });
1184
+ }
1185
+ function Pagination({ page, totalPages, isCountKnown, isSm, onPageChange }) {
1186
+ const buttonClass = (0, import_ui_web11.cn)(PAGE_BUTTON_BASE, isSm ? PAGE_BUTTON_DESKTOP : PAGE_BUTTON_MOBILE);
1187
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center justify-between", children: [
1188
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "label-xs-text text-text-secondary", children: isCountKnown ? `Page ${page} of ${totalPages}` : `Page ${page}` }),
1189
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-3", children: [
1190
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1191
+ import_ui_web11.Button,
1192
+ {
1193
+ variant: "secondary-greys",
1194
+ size: "sm",
1195
+ className: buttonClass,
1196
+ onClick: () => onPageChange(Math.max(1, page - 1)),
1197
+ disabled: page === 1,
1198
+ "aria-label": "Go to previous page",
1199
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons2.ChevronLeftIcon, { className: "h-4 w-4" })
1200
+ }
1201
+ ),
1202
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1203
+ import_ui_web11.Button,
1204
+ {
1205
+ variant: "secondary-greys",
1206
+ size: "sm",
1207
+ className: buttonClass,
1208
+ onClick: () => onPageChange(Math.min(totalPages, page + 1)),
1209
+ disabled: !isCountKnown || page >= totalPages,
1210
+ "aria-label": "Go to next page",
1211
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons2.ChevronRightIcon, { className: "h-4 w-4" })
1212
+ }
1213
+ )
1214
+ ] })
1215
+ ] });
1216
+ }
1217
+ function useLeaderboardColumns(entityLabel, statLabel, formatValue, isSm) {
1218
+ return (0, import_react4.useMemo)(
1219
+ () => [
1220
+ {
1221
+ accessorKey: "rank",
1222
+ header: "Rank",
1223
+ // BaseTable already wraps every cell in its own <TableCell>; returning another here would
1224
+ // nest <td>s. Column styling goes through rowCellClassName (the row highlight is the
1225
+ // table's getRowClassName).
1226
+ meta: { cellSize: "xs", rowCellClassName: "tabular-nums" },
1227
+ cell: ({ row }) => formatRank(row.original.rank, row.original.tied)
1228
+ },
1229
+ {
1230
+ accessorKey: "entityName",
1231
+ header: entityLabel,
1232
+ meta: { cellSize: isSm ? "xxl" : "m" },
1233
+ cell: ({ row }) => row.original.entityName
1234
+ },
1235
+ {
1236
+ accessorKey: "value",
1237
+ header: () => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "text-right text-wrap line-clamp-2", title: statLabel, children: statLabel }),
1238
+ meta: {
1239
+ cellSize: isSm ? "m" : "xs",
1240
+ rowCellClassName: "text-right tabular-nums break-all"
1241
+ },
1242
+ cell: ({ row }) => formatValue(row.original.value)
1243
+ }
1244
+ ],
1245
+ [entityLabel, statLabel, formatValue, isSm]
1246
+ );
1247
+ }
1248
+ function LeaderboardTable(props) {
1249
+ const { rows, highlightEntityId, pageSize, loading, isError, isConfigError } = props;
1250
+ const columns = useLeaderboardColumns(
1251
+ props.entityLabel,
1252
+ props.statLabel,
1253
+ props.formatValue,
1254
+ props.isSm
1255
+ );
1256
+ if (isConfigError) {
1257
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex items-center justify-center h-full text-14.5 text-text-secondary", children: "Couldn't load ranking details. Please try again." });
1258
+ }
1259
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
1260
+ isError && rows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-12 text-destructive px-1 pb-2", children: "Couldn't refresh rankings. Showing the last loaded data." }),
1261
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1262
+ import_ui_web11.BaseTable,
1263
+ {
1264
+ columns,
1265
+ data: rows,
1266
+ loading,
1267
+ pageSize,
1268
+ stickyHeader: true,
1269
+ numberOfColumns: 2,
1270
+ tableClassName: "!border-separate border-spacing-0 !overflow-visible",
1271
+ containerClassName: "border-0 rounded-none w-full !overflow-visible [&_div.overflow-auto]:!overflow-visible [&_div.overflow-auto]:!h-auto",
1272
+ className: "w-full",
1273
+ emptyMessage: isError ? "Couldn't load ranking data. Please try again." : "No ranking data available.",
1274
+ getRowId: (row) => `${row.entityId}-${row.rank}`,
1275
+ getRowClassName: (row) => highlightEntityId != null && row.entityId === highlightEntityId ? HIGHLIGHT_CLASS : ""
1276
+ }
1277
+ )
1278
+ ] });
1279
+ }
1280
+ function LeaderboardContent(props) {
1281
+ const { subtitle, footnotes = [], isSm, page, totalCount, pageSize, onPageChange } = props;
1282
+ const isCountKnown = totalCount !== void 0;
1283
+ const totalPages = Math.max(1, Math.ceil((totalCount ?? 0) / pageSize));
1284
+ const showPagination = page > 1 || isCountKnown && totalPages > 1;
1285
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col h-full overflow-hidden", children: [
1286
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col gap-6 sm:gap-4 overflow-hidden px-5", children: [
1287
+ subtitle && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui_web11.DialogDescription, { className: "flex flex-col gap-1 header-xl-medium-card text-text-secondary sm:px-4 font-ss02 ss05 leading-normal", children: [
1288
+ subtitle,
1289
+ !isSm && footnotes.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Footnotes, { notes: footnotes })
1290
+ ] }),
1291
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex-1 overflow-y-auto", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LeaderboardTable, { ...props }) })
1292
+ ] }),
1293
+ (footnotes.length > 0 || showPagination) && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col pt-3 pb-6 px-9 border-t border-border gap-3 relative z-10 shadow-[0_0_4px_0_rgba(0,0,0,0.25)]", children: [
1294
+ footnotes.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Footnotes, { notes: footnotes }),
1295
+ showPagination && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1296
+ Pagination,
1297
+ {
1298
+ page,
1299
+ totalPages,
1300
+ isCountKnown,
1301
+ isSm,
1302
+ onPageChange
1303
+ }
1304
+ )
1305
+ ] })
1306
+ ] });
1307
+ }
1308
+ function StatRankingLeaderboardDialog(props) {
1309
+ const { open, onOpenChange, title, isSm } = props;
1310
+ if (isSm) {
1311
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui_web11.Dialog, { open, onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_ui_web11.DialogContent, { className: "p-0 min-w-[536px] sm:max-w-[500px] pt-4 gap-6 bg-card border-0 flex flex-col max-h-[85vh]", children: [
1312
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui_web11.DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_ui_web11.DialogTitle, { className: "header-xl-medium-card", children: title }) }),
1313
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LeaderboardContent, { ...props })
1314
+ ] }) });
1315
+ }
1316
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1317
+ import_ui_web11.MobileModalLayout,
1318
+ {
1319
+ onCancel: () => onOpenChange(false),
1320
+ isOpen: open,
1321
+ isSm,
1322
+ title,
1323
+ cancelButtonName: "Close",
1324
+ childClassName: "h-auto min-h-full h-[calc(100vh-100px)]",
1325
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex flex-col h-full pt-6", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LeaderboardContent, { ...props }) })
1326
+ }
1327
+ );
1328
+ }
1329
+
1330
+ // src/team/team-season-stats-widget.tsx
1331
+ var import_ui_web12 = require("@nukleus-sports/ui-web");
1332
+ var import_core8 = require("@nukleus-sports/core");
1333
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1334
+ var PRESEASON_TYPE = 1;
1335
+ var RANK_TEXT_CLASS = "label-xs-medium text-text-secondary";
1336
+ var RANK_LINK_CLASS = `${RANK_TEXT_CLASS} hover:text-text-primary hover:underline cursor-pointer transition-colors`;
1337
+ function RankBadge({
1338
+ rankText,
1339
+ statLabel,
1340
+ configId,
1341
+ isRankingsError,
1342
+ onRankClick
1343
+ }) {
1344
+ if (isRankingsError) {
1345
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "label-xs-medium text-destructive", title: "Couldn't load ranking", children: [
1346
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { "aria-hidden": "true", children: "--" }),
1347
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "sr-only", children: "Couldn't load ranking" })
1348
+ ] });
1349
+ }
1350
+ if (!rankText) return null;
1351
+ if (!onRankClick) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: RANK_TEXT_CLASS, children: rankText });
1352
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1353
+ import_ui_web12.Button,
1354
+ {
1355
+ type: "button",
1356
+ variant: "unstyled",
1357
+ size: "none",
1358
+ "aria-label": `${rankText} in ${statLabel}: view leaderboard`,
1359
+ onClick: (event) => {
1360
+ event.stopPropagation();
1361
+ onRankClick(configId);
1362
+ },
1363
+ className: RANK_LINK_CLASS,
1364
+ children: rankText
1365
+ }
1366
+ );
1367
+ }
1368
+ function CenteredMessage({ children }) {
1369
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "flex items-center justify-center h-full text-14.5 text-text-secondary", children });
1370
+ }
1371
+ function StatsBody({
1372
+ stats,
1373
+ sportId,
1374
+ rankings,
1375
+ configIds,
1376
+ showRanks,
1377
+ isSummaryError,
1378
+ isRankingsError,
1379
+ onRankClick
1380
+ }) {
1381
+ const columns = (0, import_core8.getTeamStatColumns)(sportId);
1382
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-col gap-1.5 h-full w-full justify-center", children: [
1383
+ isSummaryError && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-12 text-destructive", children: "Couldn't refresh stats. Showing the last loaded data." }),
1384
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "grid grid-cols-2 gap-x-1.5 gap-y-1.5 sm:flex sm:flex-row sm:gap-3 sm:justify-between items-center w-full", children: columns.map((column, index) => {
1385
+ const configId = configIds?.[index];
1386
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1387
+ StatColumn,
1388
+ {
1389
+ label: column.label,
1390
+ value: stats.values[index],
1391
+ suffix: column.suffix,
1392
+ rankBadge: showRanks && configId !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1393
+ RankBadge,
1394
+ {
1395
+ rankText: (0, import_core8.formatStatRankByConfig)(rankings, configId),
1396
+ statLabel: column.label,
1397
+ configId,
1398
+ isRankingsError,
1399
+ onRankClick
1400
+ }
1401
+ ) : void 0
1402
+ },
1403
+ column.label
1404
+ );
1405
+ }) })
1406
+ ] });
1407
+ }
1408
+ function getEmptyMessage(isSupportedSport, hasSeason, isSummaryError) {
1409
+ if (!isSupportedSport) return "Team season stats coming soon.";
1410
+ if (!hasSeason) return "Select a season to view stats.";
1411
+ return isSummaryError ? "Couldn't load season stats. Please try again." : "No season stats for the current season.";
1412
+ }
1413
+ function TeamSeasonStatsWidget({
1414
+ sportId,
1415
+ leagueId,
1416
+ seasons,
1417
+ seasonsLoading = false,
1418
+ summary,
1419
+ rankings,
1420
+ statsLoading = false,
1421
+ isSummaryError = false,
1422
+ isRankingsError = false,
1423
+ onRankClick,
1424
+ className
1425
+ }) {
1426
+ const isSupportedSport = sportId != null && (0, import_core8.isSupportedTeamStatsSport)(sportId);
1427
+ const hasSeason = Boolean(seasons?.selectedYear) && seasons?.selectedType != null;
1428
+ const stats = isSupportedSport && hasSeason ? (0, import_core8.computeTeamSeasonStatsFromSummary)(summary, sportId) : null;
1429
+ const configIds = (0, import_core8.getTeamRankingConfigIds)(sportId, leagueId);
1430
+ const showRanks = seasons?.selectedType !== PRESEASON_TYPE;
1431
+ if (seasonsLoading) {
1432
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_ui_web12.Card, { className: (0, import_ui_web12.cn)("border-0 p-4 h-[300px]", className), children: [
1433
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui_web12.CardHeader, { className: "p-0 pb-4", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui_web12.CardTitle, { className: "text-base font-medium", children: "Season Stats" }) }),
1434
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui_web12.CardContent, { className: "p-0", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "space-y-3 flex justify-center items-center w-full h-full", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui_web12.IconLoader, {}) }) })
1435
+ ] });
1436
+ }
1437
+ let body;
1438
+ if (statsLoading) {
1439
+ body = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui_web12.Skeleton, { className: "h-4 w-3/4" }) });
1440
+ } else if (isSupportedSport && stats) {
1441
+ body = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1442
+ StatsBody,
1443
+ {
1444
+ stats,
1445
+ sportId,
1446
+ rankings: rankings ?? [],
1447
+ configIds,
1448
+ showRanks,
1449
+ isSummaryError,
1450
+ isRankingsError,
1451
+ onRankClick
1452
+ }
1453
+ );
1454
+ } else {
1455
+ body = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CenteredMessage, { children: getEmptyMessage(isSupportedSport, hasSeason, isSummaryError) });
1456
+ }
1457
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1458
+ import_ui_web12.Card,
1459
+ {
1460
+ className: (0, import_ui_web12.cn)(
1461
+ "border-0 px-4 py-3 sm:p-4 flex flex-col gap-[25px] sm:gap-4 sm:h-[300px]",
1462
+ className
1463
+ ),
1464
+ children: [
1465
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui_web12.CardHeader, { className: "p-0", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-row items-center justify-between w-full h-8", children: [
1466
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui_web12.CardTitle, { className: "header-xl-medium-card text-base text-text-primary", children: "Team Stats" }),
1467
+ isSupportedSport && seasons && seasons.years.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SeasonSelector, { ...seasons, hideTypeOnMobile: true })
1468
+ ] }) }),
1469
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_ui_web12.CardContent, { className: "p-0 h-auto sm:h-[220px] flex justify-center", children: body })
1470
+ ]
1471
+ }
1472
+ );
1473
+ }
1474
+
1475
+ // src/team/recent-games-widget.tsx
1476
+ var import_react5 = require("react");
1477
+ var import_ui_web13 = require("@nukleus-sports/ui-web");
1478
+ var import_icons3 = require("@nukleus-sports/icons");
1479
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1480
+ var DATE_FORMAT = new Intl.DateTimeFormat("en-US", {
1481
+ weekday: "long",
1482
+ month: "long",
1483
+ day: "numeric",
1484
+ year: "numeric"
1485
+ });
1486
+ var MESSAGES = {
1487
+ "no-team": "No games available.",
1488
+ "team-error": "Couldn't load team info. Please try again.",
1489
+ "games-error": "Couldn't load games. Please try again."
1490
+ };
1491
+ function ResultText({ result }) {
1492
+ if (result.outcome === "none") return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-text-secondary text-14", children: "--" });
1493
+ if (result.outcome === "tie") {
1494
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "text-14 font-medium text-text-primary", children: [
1495
+ "T ",
1496
+ result.detail
1497
+ ] });
1498
+ }
1499
+ const isWin = result.outcome === "win";
1500
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "text-14 font-medium", children: [
1501
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1502
+ "span",
1503
+ {
1504
+ className: isWin ? "text-primary-color-nuk-text" : "text-semantic-color-status-priority-blocked-hot-copy",
1505
+ children: isWin ? "W" : "L"
1506
+ }
1507
+ ),
1508
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "text-text-primary", children: [
1509
+ " ",
1510
+ result.detail
1511
+ ] })
1512
+ ] });
1513
+ }
1514
+ function OpponentLogo({ opponent, resolveImageUrl, defaultLogoUrl }) {
1515
+ const [failedUrl, setFailedUrl] = (0, import_react5.useState)(null);
1516
+ const { logo } = opponent;
1517
+ const resolved = logo ? logo.stored ? resolveImageUrl?.(logo.url) : logo.url : void 0;
1518
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1519
+ "img",
1520
+ {
1521
+ src: resolved && resolved !== failedUrl ? resolved : defaultLogoUrl,
1522
+ alt: `${opponent.name} logo`,
1523
+ className: "h-8 w-8 rounded-full",
1524
+ loading: "lazy",
1525
+ onError: () => {
1526
+ if (resolved) setFailedUrl(resolved);
1527
+ }
1528
+ }
1529
+ );
1530
+ }
1531
+ function GameItem({ row, resolveImageUrl, defaultLogoUrl }) {
1532
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "border-b border-border last:border-0", children: [
1533
+ row.isFirstUpcoming && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "px-2 pt-2 text-12 font-medium uppercase tracking-wide text-text-secondary", children: "Upcoming" }),
1534
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-col p-2 gap-[5px]", children: [
1535
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-14 font-normal text-text-secondary", children: DATE_FORMAT.format(new Date(row.gameDate)) }),
1536
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-3", children: [
1537
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-14 font-normal text-text-secondary shrink-0", children: row.isHome ? "vs " : "@ " }),
1538
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1539
+ OpponentLogo,
1540
+ {
1541
+ opponent: row.opponent,
1542
+ resolveImageUrl,
1543
+ defaultLogoUrl
1544
+ }
1545
+ ),
1546
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-14.5 font-normal text-text-primary truncate", children: row.opponent.name }),
1547
+ row.result && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
1548
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-14 text-text-secondary", children: "-" }),
1549
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ResultText, { result: row.result })
1550
+ ] })
1551
+ ] }),
1552
+ row.time && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-14 font-normal text-text-secondary", children: row.time })
1553
+ ] })
1554
+ ] });
1555
+ }
1556
+ function Message({ children }) {
1557
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "text-text-primary text-14.5 px-1", children });
1558
+ }
1559
+ function Body({
1560
+ status,
1561
+ rows,
1562
+ resolveImageUrl,
1563
+ defaultLogoUrl
1564
+ }) {
1565
+ if (status === "loading") {
1566
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "space-y-4 flex justify-center items-center w-full h-full", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_ui_web13.IconLoader, {}) });
1567
+ }
1568
+ if (status !== "ready") return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Message, { children: MESSAGES[status] });
1569
+ if (rows.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Message, { children: "There are no games scheduled at this time." });
1570
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "flex flex-col overflow-y-auto overflow-x-hidden gap-1", children: rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1571
+ GameItem,
1572
+ {
1573
+ row,
1574
+ resolveImageUrl,
1575
+ defaultLogoUrl
1576
+ },
1577
+ row.id
1578
+ )) });
1579
+ }
1580
+ function RecentGamesWidget({
1581
+ status,
1582
+ rows,
1583
+ resolveImageUrl,
1584
+ defaultLogoUrl,
1585
+ onExpand,
1586
+ className
1587
+ }) {
1588
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
1589
+ import_ui_web13.Card,
1590
+ {
1591
+ className: (0, import_ui_web13.cn)(
1592
+ "p-4 w-full xl:w-[420px] flex flex-col overflow-hidden border-none gap-3 h-full md:min-h-[612px]",
1593
+ className
1594
+ ),
1595
+ children: [
1596
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_ui_web13.CardHeader, { className: "flex flex-row items-center justify-between space-y-0 p-0", children: [
1597
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_ui_web13.CardTitle, { children: "Recent Games" }),
1598
+ onExpand && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1599
+ import_ui_web13.Button,
1600
+ {
1601
+ type: "button",
1602
+ variant: "ghost",
1603
+ size: "sm",
1604
+ "aria-label": "View full schedule",
1605
+ onClick: onExpand,
1606
+ className: "outline-1 background outline-offset-[-1px] outline-[hsl(var(--color-ui-elem-strokes))] outline h-[32px] w-[32px]",
1607
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons3.ArrowUpRightIcon, { className: "text-greys-icons h-5 w-5" })
1608
+ }
1609
+ )
1610
+ ] }),
1611
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_ui_web13.CardContent, { className: "flex-1 flex flex-col overflow-hidden p-0", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1612
+ Body,
1613
+ {
1614
+ status,
1615
+ rows,
1616
+ resolveImageUrl,
1617
+ defaultLogoUrl
1618
+ }
1619
+ ) })
1620
+ ]
1621
+ }
1622
+ );
1623
+ }
1624
+
1625
+ // src/team/team-stats-table.tsx
1626
+ var import_react6 = require("react");
1627
+ var import_ui_web14 = require("@nukleus-sports/ui-web");
1628
+ var import_core9 = require("@nukleus-sports/core");
1629
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1630
+ function stripLeadingSlash(path) {
1631
+ return path.startsWith("/") ? path.slice(1) : path;
1632
+ }
1633
+ function isDefinedStatType(value) {
1634
+ return Boolean(value);
1635
+ }
1636
+ function getAvailableStatCategories(stats) {
1637
+ return Array.from(
1638
+ new Set(
1639
+ stats.flatMap(
1640
+ (stat) => (stat.stat_details?.stats ?? []).map((s) => s.stat_type).filter(isDefinedStatType)
1641
+ )
1642
+ )
1643
+ );
1644
+ }
1645
+ function deriveSelectedStatCategory(requested, available) {
1646
+ if (requested && available.includes(requested)) return requested;
1647
+ if (available.includes("offense")) return "offense";
1648
+ return available[0] ?? "offense";
1649
+ }
1650
+ function getStatsEmptyMessage(seasons, statsCount) {
1651
+ if (!seasons.selectedYear || seasons.selectedType === null) {
1652
+ return "Select a season to view stats.";
1653
+ }
1654
+ if (statsCount === 0) {
1655
+ const yearLabel = seasons.years.find((y) => y.value === seasons.selectedYear)?.label;
1656
+ const typeLabel = seasons.types.find((t) => t.value === seasons.selectedType)?.label;
1657
+ return `No stats available for ${yearLabel} - ${typeLabel}.`;
1658
+ }
1659
+ return "No stats found for this season";
1660
+ }
1661
+ function formatTeamStatDate(stat) {
1662
+ const dateStr = stat.stat_details?.game_details?.date;
1663
+ const date = dateStr ? new Date(dateStr) : null;
1664
+ if (!date || Number.isNaN(date.getTime())) {
1665
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-text-primary body-text", children: "--" });
1666
+ }
1667
+ const formatted = date.toLocaleDateString("en-US", { month: "short", day: "numeric" });
1668
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "text-13.5 font-normal text-text-primary", children: formatted });
1669
+ }
1670
+ function getTeamStatResult(stat) {
1671
+ const gameDetails = stat.stat_details?.game_details;
1672
+ if (gameDetails?.home_team_score === void 0 || gameDetails?.away_team_score === void 0) {
1673
+ return "--";
1674
+ }
1675
+ const isHome = stat.team_id === gameDetails.home_team_id;
1676
+ const homeScore = gameDetails.home_team_score;
1677
+ const awayScore = gameDetails.away_team_score;
1678
+ let winLoss = "T";
1679
+ if (homeScore !== awayScore) {
1680
+ const teamWon = isHome ? homeScore > awayScore : awayScore > homeScore;
1681
+ winLoss = teamWon ? "W" : "L";
1682
+ }
1683
+ const teamScore = isHome ? homeScore : awayScore;
1684
+ const opponentScore = isHome ? awayScore : homeScore;
1685
+ const score = `${teamScore}-${opponentScore}${gameDetails.status_alt_details ? ` ${gameDetails.status_alt_details}` : ""}`;
1686
+ const colorClass = winLoss === "W" ? "text-primary-color-nuk-text" : winLoss === "L" ? "text-semantic-color-status-priority-blocked-hot-copy" : "text-text-primary";
1687
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-baseline gap-1 leading-tight", children: [
1688
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: (0, import_ui_web14.cn)(colorClass, "body-text"), children: winLoss }),
1689
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-text-primary body-text", children: score })
1690
+ ] });
1691
+ }
1692
+ function StatOpponentCell({
1693
+ stat,
1694
+ resolveOpponentLogoUrl,
1695
+ defaultLogoUrl,
1696
+ showName
1697
+ }) {
1698
+ const [failedUrl, setFailedUrl] = (0, import_react6.useState)(null);
1699
+ const gameDetails = stat.stat_details?.game_details;
1700
+ const isHome = stat.team_id === gameDetails?.home_team_id;
1701
+ const opponentName = isHome ? gameDetails?.away_team_name : gameDetails?.home_team_name;
1702
+ const opponentLogoPath = isHome ? gameDetails?.away_team_logo : gameDetails?.home_team_logo;
1703
+ if (!opponentName) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children: "--" });
1704
+ const prefix = isHome ? "vs" : "@";
1705
+ const resolved = opponentLogoPath ? resolveOpponentLogoUrl(stripLeadingSlash(opponentLogoPath)) : null;
1706
+ const logoSrc = resolved && resolved !== failedUrl ? resolved : defaultLogoUrl;
1707
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "h-full overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex items-center h-full", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex max-sm:gap-1 gap-2 items-center font-normal leading-tight text-12", children: [
1708
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-text-primary body-text", children: prefix }),
1709
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1710
+ "img",
1711
+ {
1712
+ src: logoSrc,
1713
+ alt: showName ? "" : opponentName,
1714
+ className: "max-sm:w-5 max-sm:h-5 w-4 h-4 rounded-full flex-shrink-0",
1715
+ onError: () => {
1716
+ if (resolved) setFailedUrl(resolved);
1717
+ }
1718
+ }
1719
+ ),
1720
+ showName && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-primary-color-nuk-text body-text line-clamp-2", children: opponentName })
1721
+ ] }) }) });
1722
+ }
1723
+ function buildStatsColumns({
1724
+ filteredStatTypes,
1725
+ selectedStatCategory,
1726
+ resolveOpponentLogoUrl,
1727
+ defaultLogoUrl,
1728
+ isSm,
1729
+ isSmallLaptop
1730
+ }) {
1731
+ return [
1732
+ {
1733
+ id: "game_date",
1734
+ header: () => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "w-[50px] shrink-0", children: "Date" }),
1735
+ cell: ({ row }) => formatTeamStatDate(row.original),
1736
+ meta: { cellSize: isSm ? "xs" : "xxs", headerClassName: "h-auto" }
1737
+ },
1738
+ {
1739
+ id: "opponent",
1740
+ header: () => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { children: isSm ? "Opponent" : "Opp" }),
1741
+ cell: ({ row }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1742
+ StatOpponentCell,
1743
+ {
1744
+ stat: row.original,
1745
+ resolveOpponentLogoUrl,
1746
+ defaultLogoUrl,
1747
+ showName: isSm
1748
+ }
1749
+ ),
1750
+ meta: {
1751
+ cellSize: isSm ? isSmallLaptop ? "lg" : "l" : "eclipse",
1752
+ headerClassName: "h-auto"
1753
+ }
1754
+ },
1755
+ {
1756
+ id: "result",
1757
+ header: "Result",
1758
+ cell: ({ row }) => getTeamStatResult(row.original),
1759
+ meta: { cellSize: "xs", headerClassName: "h-auto", rowCellClassName: "!min-w-[70px]" }
1760
+ },
1761
+ ...filteredStatTypes.map((statType) => ({
1762
+ id: statType.name,
1763
+ header: statType.label || statType.name,
1764
+ cell: ({ row }) => {
1765
+ const value = row.original.stat_details?.stats?.find(
1766
+ (s) => s.stat_id === statType.id && s.stat_type === selectedStatCategory
1767
+ )?.stat_value;
1768
+ return value !== void 0 ? value : "--";
1769
+ },
1770
+ meta: {
1771
+ cellSize: "xxs",
1772
+ headerClassName: "h-auto py-0 !whitespace-normal !overflow-visible !text-clip !break-words !line-clamp-2"
1773
+ }
1774
+ }))
1775
+ ];
1776
+ }
1777
+ function StatsBody2({
1778
+ seasons,
1779
+ showsCategoryPicker,
1780
+ selectedStatCategory,
1781
+ availableStatCategories,
1782
+ onStatCategoryChange,
1783
+ isStatTypesError,
1784
+ hasVisibleStatTypes,
1785
+ columns,
1786
+ stats,
1787
+ statsLoading,
1788
+ isStatsError,
1789
+ isSm,
1790
+ isSmallLaptop,
1791
+ emptyMessage
1792
+ }) {
1793
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
1794
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-2 min-[360px]:gap-3", children: [
1795
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SeasonSelector, { ...seasons, className: "gap-2 min-[360px]:gap-3" }),
1796
+ showsCategoryPicker && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
1797
+ import_ui_web14.Select,
1798
+ {
1799
+ value: selectedStatCategory,
1800
+ onValueChange: onStatCategoryChange,
1801
+ disabled: !seasons.selectedYear || seasons.selectedType === null,
1802
+ children: [
1803
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.SelectTrigger, { variant: "widget", size: "widget", "aria-label": "Stat category", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.SelectValue, { placeholder: "Select stat category" }) }),
1804
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1805
+ import_ui_web14.SelectContent,
1806
+ {
1807
+ className: "bg-popover border-border z-50 [&_.checkbox]:!flex",
1808
+ classNameViewPort: "gap-2",
1809
+ children: availableStatCategories.map((category) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.SelectItem, { value: category, className: "capitalize min-h-8", children: category.charAt(0).toUpperCase() + category.slice(1) }, category))
1810
+ }
1811
+ )
1812
+ ]
1813
+ }
1814
+ )
1815
+ ] }),
1816
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "space-y-4 xl:flex-1 xl:min-h-0 xl:overflow-hidden", children: [
1817
+ isStatTypesError && !hasVisibleStatTypes && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-text-secondary text-13.5", children: "Couldn't load stat categories -- showing limited columns." }),
1818
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1819
+ import_ui_web14.BaseTable,
1820
+ {
1821
+ columns,
1822
+ data: stats,
1823
+ pageSize: stats.length || 10,
1824
+ hidePagination: true,
1825
+ stickyHeader: true,
1826
+ splitLayout: isSmallLaptop || !isSm,
1827
+ splitLayoutGridCols: isSm ? "sm:!grid-cols-[minmax(232px,auto)_1fr]" : "!grid-cols-[minmax(117px,auto)_1fr]",
1828
+ loading: statsLoading,
1829
+ containerClassName: "border-0 rounded-none h-full",
1830
+ className: "border-none xl:h-full xl:min-h-0",
1831
+ numberOfColumns: 2,
1832
+ emptyMessage: isStatsError && stats.length === 0 ? "Couldn't load stats. Please try again." : emptyMessage
1833
+ }
1834
+ )
1835
+ ] })
1836
+ ] });
1837
+ }
1838
+ function TeamStatsTable({
1839
+ stats,
1840
+ statsLoading = false,
1841
+ isStatsError = false,
1842
+ statTypes,
1843
+ isStatTypesError = false,
1844
+ sportId,
1845
+ isTeamError = false,
1846
+ resolveOpponentLogoUrl,
1847
+ defaultLogoUrl,
1848
+ seasons,
1849
+ seasonsLoading = false,
1850
+ isSeasonsError = false,
1851
+ isSm,
1852
+ isSmallLaptop,
1853
+ className
1854
+ }) {
1855
+ const [requestedStatCategory, setRequestedStatCategory] = (0, import_react6.useState)(null);
1856
+ const availableStatCategories = getAvailableStatCategories(stats);
1857
+ const selectedStatCategory = deriveSelectedStatCategory(
1858
+ requestedStatCategory,
1859
+ availableStatCategories
1860
+ );
1861
+ if (isTeamError) {
1862
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.Card, { className: (0, import_ui_web14.cn)("border-0", className), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.CardContent, { className: "p-4 flex justify-center items-center", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-text-secondary", children: "Couldn't load team information. Please try again." }) }) });
1863
+ }
1864
+ if (seasonsLoading || sportId === null) {
1865
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.Card, { className: (0, import_ui_web14.cn)("border-0", className), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_ui_web14.CardContent, { className: "space-y-4 pt-6", children: [
1866
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col gap-3 sm:flex-row justify-start", children: [
1867
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.Skeleton, { className: "h-7 w-[68px] bg-form rounded-[5px]" }),
1868
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.Skeleton, { className: "h-7 w-[142px] bg-form rounded-[5px]" }),
1869
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.Skeleton, { className: "h-7 w-[102px] bg-form rounded-[5px]" })
1870
+ ] }),
1871
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.Skeleton, { className: "h-40 w-full bg-form !mt-3" })
1872
+ ] }) });
1873
+ }
1874
+ if (!seasons || seasons.years.length === 0) {
1875
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.Card, { className: (0, import_ui_web14.cn)("border-none", className), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.CardContent, { className: "pt-6", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "text-center py-8", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("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." }) }) }) });
1876
+ }
1877
+ const visibleStatTypes = (0, import_core9.getVisibleTeamStatTypes)(statTypes, sportId);
1878
+ const filteredStatTypes = (0, import_core9.getOrderedTeamStatTypesForCategory)(
1879
+ visibleStatTypes,
1880
+ sportId,
1881
+ selectedStatCategory
1882
+ );
1883
+ const showsCategoryPicker = availableStatCategories.length > 0 && (0, import_core9.showsTeamStatCategoryPicker)(sportId);
1884
+ const columns = buildStatsColumns({
1885
+ filteredStatTypes,
1886
+ selectedStatCategory,
1887
+ resolveOpponentLogoUrl,
1888
+ defaultLogoUrl,
1889
+ isSm,
1890
+ isSmallLaptop
1891
+ });
1892
+ const emptyMessage = getStatsEmptyMessage(seasons, stats.length);
1893
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
1894
+ import_ui_web14.Card,
1895
+ {
1896
+ className: (0, import_ui_web14.cn)(
1897
+ "border-none p-4 flex flex-col gap-3 xl:h-full xl:min-h-0 xl:flex-1 xl:overflow-hidden",
1898
+ className
1899
+ ),
1900
+ children: [
1901
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.CardHeader, { className: "p-0", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.CardTitle, { children: "Stats" }) }),
1902
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.CardContent, { className: "space-y-0 p-0 flex flex-col gap-3 xl:flex-1 xl:min-h-0", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1903
+ StatsBody2,
1904
+ {
1905
+ seasons,
1906
+ showsCategoryPicker,
1907
+ selectedStatCategory,
1908
+ availableStatCategories,
1909
+ onStatCategoryChange: setRequestedStatCategory,
1910
+ isStatTypesError,
1911
+ hasVisibleStatTypes: visibleStatTypes.length > 0,
1912
+ columns,
1913
+ stats,
1914
+ statsLoading,
1915
+ isStatsError,
1916
+ isSm,
1917
+ isSmallLaptop,
1918
+ emptyMessage
1919
+ }
1920
+ ) })
1921
+ ]
1922
+ }
1923
+ );
1924
+ }
1925
+
1926
+ // src/team/team-schedule-table.tsx
1927
+ var import_ui_web15 = require("@nukleus-sports/ui-web");
1928
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1929
+ var SPECIAL_LOGO_LEAGUES = ["NFL", "NBA", "NHL", "MLB", "WNBA"];
1930
+ var COLLEGE_LEAGUE_IDS = [2, 6, 13];
1931
+ var COMPLETED_STATUS_ID = "3";
1932
+ var DATE_FORMAT2 = new Intl.DateTimeFormat("en-US", { month: "short", day: "numeric" });
1933
+ function firstCompetition(game) {
1934
+ return game.game_details?.competitions?.[0];
1935
+ }
1936
+ function formatScore(score) {
1937
+ if (score?.displayValue) return score.displayValue;
1938
+ if (typeof score?.value === "number") return String(score.value);
1939
+ return "0";
1940
+ }
1941
+ function findCompetitor(competitors, teamEspnId) {
1942
+ if (!competitors || competitors.length !== 2 || !teamEspnId) return null;
1943
+ const [first, second] = competitors;
1944
+ if (!first || !second) return null;
1945
+ if (first.id === teamEspnId) return { own: first, other: second };
1946
+ if (second.id === teamEspnId) return { own: second, other: first };
1947
+ return null;
1948
+ }
1949
+ function findLeader(competitors, leaderType) {
1950
+ if (!competitors || competitors.length !== 2) return null;
1951
+ for (const competitor of competitors) {
1952
+ const leader = competitor?.leaders?.find((entry) => entry.name === leaderType);
1953
+ const top = leader?.leaders?.[0];
1954
+ if (top?.athlete) {
1955
+ return {
1956
+ displayName: top.athlete.displayName || "--",
1957
+ displayValue: top.displayValue || "--"
1958
+ };
1959
+ }
1960
+ }
1961
+ return null;
1962
+ }
1963
+ function showsFootballLeaders(leagueId) {
1964
+ return leagueId !== null && [1, 2, 13].includes(leagueId);
1965
+ }
1966
+ function showsBasketballLeaders(leagueId) {
1967
+ return leagueId !== null && [4, 5, 6].includes(leagueId);
1968
+ }
1969
+ function showsHockeyLeaders(leagueId) {
1970
+ return leagueId === 14;
1971
+ }
1972
+ function showsMlbLeaders(leagueId) {
1973
+ return leagueId === 7;
1974
+ }
1975
+ function leaderCell(leader, small = false) {
1976
+ if (!leader) return "--";
1977
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-col leading-tight", children: [
1978
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-text-primary font-normal truncate", children: leader.displayName }),
1979
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1980
+ "span",
1981
+ {
1982
+ className: (0, import_ui_web15.cn)(
1983
+ small ? "text-text-secondary text-11" : "text-text-primary body-text",
1984
+ "truncate"
1985
+ ),
1986
+ children: leader.displayValue
1987
+ }
1988
+ )
1989
+ ] });
1990
+ }
1991
+ function formatScheduleDate(game) {
1992
+ if (!game.game_details) return "--";
1993
+ try {
1994
+ const { timeValid, date: rawDate } = game.game_details;
1995
+ const date = timeValid ? new Date(rawDate) : (() => {
1996
+ const [year, month, day] = rawDate.split("T")[0].split("-").map(Number);
1997
+ return new Date(year, month - 1, day);
1998
+ })();
1999
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-text-primary body-text", children: DATE_FORMAT2.format(date) });
2000
+ } catch {
2001
+ return "--";
2002
+ }
2003
+ }
2004
+ function getScheduleResult(game, teamEspnId) {
2005
+ const competition = firstCompetition(game);
2006
+ if (competition?.status?.type?.id !== COMPLETED_STATUS_ID) return null;
2007
+ const match = findCompetitor(competition.competitors, teamEspnId);
2008
+ if (!match) return null;
2009
+ const { own, other } = match;
2010
+ const ownValue = own.score?.value;
2011
+ const otherValue = other.score?.value;
2012
+ const scoresKnown = typeof ownValue === "number" && typeof otherValue === "number";
2013
+ const tied = scoresKnown && ownValue === otherValue;
2014
+ const winLoss = tied ? "T" : own.winner === true ? "W" : "L";
2015
+ const score = `${formatScore(own.score)}-${formatScore(other.score)}`;
2016
+ const colorClass = winLoss === "W" ? "text-primary-color-nuk-text" : winLoss === "L" ? "text-semantic-color-status-priority-blocked-hot-copy" : "text-text-primary";
2017
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-baseline gap-1 leading-tight", children: [
2018
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: (0, import_ui_web15.cn)(colorClass, "body-text"), children: winLoss }),
2019
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-text-primary body-text", children: score })
2020
+ ] });
2021
+ }
2022
+ function getScheduleRecord(game, teamEspnId) {
2023
+ const competition = firstCompetition(game);
2024
+ if (competition?.status?.type?.id !== COMPLETED_STATUS_ID) return "--";
2025
+ return findCompetitor(competition.competitors, teamEspnId)?.own.record?.[0]?.displayValue || "--";
2026
+ }
2027
+ function getWinningGoalie(game) {
2028
+ const athlete = firstCompetition(game)?.featuredAthletes?.[0]?.athlete;
2029
+ if (!athlete?.lastName) return "--";
2030
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "flex flex-col leading-tight", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-text-primary font-normal truncate", children: athlete.lastName }) });
2031
+ }
2032
+ function getHockeyTopPlayer(game) {
2033
+ const competitors = firstCompetition(game)?.competitors;
2034
+ const competitor = competitors?.find((c) => c?.leaders?.[0]?.leaders?.length);
2035
+ const top = competitor?.leaders?.[0]?.leaders?.[0];
2036
+ if (!top?.athlete?.lastName) return "--";
2037
+ return leaderCell(
2038
+ { displayName: top.athlete.lastName, displayValue: top.displayValue || "--" },
2039
+ true
2040
+ );
2041
+ }
2042
+ function getMlbPitcher(game, pitcherType) {
2043
+ const pitcher = firstCompetition(game)?.featuredAthletes?.find((a) => a.name === pitcherType);
2044
+ const athlete = pitcher?.athlete;
2045
+ if (!athlete?.lastName) return "--";
2046
+ const stat = pitcherType === "savingPitcher" ? athlete.saves : athlete.record;
2047
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-col leading-tight", children: [
2048
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-text-primary font-normal truncate", children: athlete.lastName }),
2049
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-text-secondary text-11 truncate", children: stat || "--" })
2050
+ ] });
2051
+ }
2052
+ function OpponentCell({
2053
+ game,
2054
+ teamEspnId,
2055
+ leagueId,
2056
+ leagueAbbreviation,
2057
+ resolveLogoUrl,
2058
+ defaultLogoUrl,
2059
+ showName
2060
+ }) {
2061
+ const match = findCompetitor(firstCompetition(game)?.competitors, teamEspnId);
2062
+ if (!match || leagueId === null || !leagueAbbreviation) return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: "--" });
2063
+ const prefix = match.own.homeAway === "home" ? "vs" : "@";
2064
+ const opponentTeam = match.other.team;
2065
+ const isSpecialLeague = SPECIAL_LOGO_LEAGUES.includes(leagueAbbreviation);
2066
+ const identifier = isSpecialLeague ? opponentTeam.abbreviation : opponentTeam.id;
2067
+ const folder = COLLEGE_LEAGUE_IDS.includes(leagueId) ? "NCAA" : leagueAbbreviation;
2068
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-1 sm:gap-2 h-full overflow-hidden", children: [
2069
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-text-primary body-text shrink-0 sm:w-4", children: prefix }),
2070
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2071
+ "img",
2072
+ {
2073
+ src: resolveLogoUrl(folder, identifier),
2074
+ alt: showName ? "" : opponentTeam.displayName,
2075
+ loading: "lazy",
2076
+ className: "h-5 w-5 shrink-0 inline sm:h-6 sm:w-6 sm:mr-2",
2077
+ onError: (event) => {
2078
+ event.currentTarget.src = defaultLogoUrl;
2079
+ }
2080
+ }
2081
+ ),
2082
+ showName && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-primary-color-nuk-text body-text line-clamp-2", children: opponentTeam.displayName })
2083
+ ] });
2084
+ }
2085
+ function buildScheduleColumns({
2086
+ leagueId,
2087
+ leagueAbbreviation,
2088
+ teamEspnId,
2089
+ resolveLogoUrl,
2090
+ defaultLogoUrl,
2091
+ isSm,
2092
+ isSmallLaptop
2093
+ }) {
2094
+ const showsHockey = showsHockeyLeaders(leagueId);
2095
+ return [
2096
+ {
2097
+ id: "game_date",
2098
+ header: () => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "w-[50px] shrink-0", children: "Date" }),
2099
+ accessorFn: (row) => row.game_date,
2100
+ cell: ({ row }) => formatScheduleDate(row.original),
2101
+ meta: { cellSize: isSm ? "xs" : "xxs" }
2102
+ },
2103
+ {
2104
+ id: "opponent",
2105
+ header: () => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: isSm ? "Opponent" : "Opp" }),
2106
+ cell: ({ row }) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2107
+ OpponentCell,
2108
+ {
2109
+ game: row.original,
2110
+ teamEspnId,
2111
+ leagueId,
2112
+ leagueAbbreviation,
2113
+ resolveLogoUrl,
2114
+ defaultLogoUrl,
2115
+ showName: isSm
2116
+ }
2117
+ ),
2118
+ meta: { cellSize: isSm ? isSmallLaptop ? "lg" : "l" : "eclipse" }
2119
+ },
2120
+ {
2121
+ id: "result",
2122
+ header: "Result",
2123
+ cell: ({ row }) => getScheduleResult(row.original, teamEspnId) ?? "--",
2124
+ meta: { cellSize: "xs" }
2125
+ },
2126
+ {
2127
+ id: "record",
2128
+ header: showsHockey ? "W-L-OTL" : "W-L",
2129
+ cell: ({ row }) => getScheduleRecord(row.original, teamEspnId),
2130
+ meta: { cellSize: "xs" }
2131
+ },
2132
+ ...showsMlbLeaders(leagueId) ? [
2133
+ {
2134
+ id: "win",
2135
+ header: "Win",
2136
+ cell: ({ row }) => getMlbPitcher(row.original, "winningPitcher"),
2137
+ meta: { cellSize: "s" }
2138
+ },
2139
+ {
2140
+ id: "loss",
2141
+ header: "Loss",
2142
+ cell: ({ row }) => getMlbPitcher(row.original, "losingPitcher"),
2143
+ meta: { cellSize: "s" }
2144
+ },
2145
+ {
2146
+ id: "save",
2147
+ header: "Save",
2148
+ cell: ({ row }) => getMlbPitcher(row.original, "savingPitcher"),
2149
+ meta: { cellSize: "s" }
2150
+ }
2151
+ ] : [],
2152
+ ...showsBasketballLeaders(leagueId) ? [
2153
+ {
2154
+ id: "topPts",
2155
+ header: "Top Pts",
2156
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "points"), true),
2157
+ meta: { cellSize: "s" }
2158
+ },
2159
+ {
2160
+ id: "topReb",
2161
+ header: "Top Reb",
2162
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "rebounds"), true),
2163
+ meta: { cellSize: "s" }
2164
+ },
2165
+ {
2166
+ id: "topAst",
2167
+ header: "Top Ast",
2168
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "assists"), true),
2169
+ meta: { cellSize: "s" }
2170
+ }
2171
+ ] : [],
2172
+ ...showsHockey ? [
2173
+ {
2174
+ id: "wGoalie",
2175
+ header: "W Goalie",
2176
+ cell: ({ row }) => getWinningGoalie(row.original),
2177
+ meta: { cellSize: "s" }
2178
+ },
2179
+ {
2180
+ id: "topPlayer",
2181
+ header: "Top Player",
2182
+ cell: ({ row }) => getHockeyTopPlayer(row.original),
2183
+ meta: { cellSize: "s" }
2184
+ }
2185
+ ] : [],
2186
+ ...showsFootballLeaders(leagueId) ? [
2187
+ {
2188
+ id: "topPass",
2189
+ header: "Top Pass",
2190
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "passingLeader")),
2191
+ meta: { cellSize: "l" }
2192
+ },
2193
+ {
2194
+ id: "topRush",
2195
+ header: "Top Rush",
2196
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "rushingLeader")),
2197
+ meta: { cellSize: "l" }
2198
+ },
2199
+ {
2200
+ id: "topRec",
2201
+ header: "Top Rec",
2202
+ cell: ({ row }) => leaderCell(
2203
+ findLeader(firstCompetition(row.original)?.competitors, "receivingLeader")
2204
+ ),
2205
+ meta: { cellSize: "l" }
2206
+ }
2207
+ ] : []
2208
+ ];
2209
+ }
2210
+ function ScheduleBody({
2211
+ seasonsLoading,
2212
+ seasons,
2213
+ isSeasonsError,
2214
+ columns,
2215
+ games,
2216
+ gamesLoading,
2217
+ isGamesError,
2218
+ isSm,
2219
+ isSmallLaptop
2220
+ }) {
2221
+ if (seasonsLoading) {
2222
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "flex justify-center py-8", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "text-sm text-text-primary", children: "Loading seasons..." }) });
2223
+ }
2224
+ if (!seasons || seasons.years.length === 0) {
2225
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "text-center py-8", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-text-primary", children: isSeasonsError ? "Couldn't load seasons. Please try again." : "No seasons found" }) });
2226
+ }
2227
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-col gap-3", children: [
2228
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SeasonSelector, { ...seasons, className: "gap-2 min-[360px]:gap-3" }),
2229
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2230
+ import_ui_web15.BaseTable,
2231
+ {
2232
+ columns,
2233
+ data: games,
2234
+ pageSize: games.length || 10,
2235
+ splitLayout: isSmallLaptop || !isSm,
2236
+ splitLayoutGridCols: isSm ? "sm:!grid-cols-[minmax(232px,auto)_1fr]" : "!grid-cols-[minmax(117px,auto)_1fr]",
2237
+ loading: gamesLoading,
2238
+ containerClassName: "border-0 rounded-none h-full",
2239
+ className: "h-full border-none",
2240
+ numberOfColumns: 2,
2241
+ emptyMessage: isGamesError ? "Couldn't load games. Please try again." : "No games found for this season"
2242
+ }
2243
+ ) })
2244
+ ] });
2245
+ }
2246
+ function TeamScheduleTable({
2247
+ games,
2248
+ gamesLoading = false,
2249
+ isGamesError = false,
2250
+ leagueId,
2251
+ leagueAbbreviation,
2252
+ isTeamError = false,
2253
+ teamEspnId,
2254
+ resolveLogoUrl,
2255
+ defaultLogoUrl,
2256
+ seasons,
2257
+ seasonsLoading = false,
2258
+ isSeasonsError = false,
2259
+ isSm,
2260
+ isSmallLaptop,
2261
+ className
2262
+ }) {
2263
+ const columns = buildScheduleColumns({
2264
+ leagueId,
2265
+ leagueAbbreviation,
2266
+ teamEspnId,
2267
+ resolveLogoUrl,
2268
+ defaultLogoUrl,
2269
+ isSm,
2270
+ isSmallLaptop
2271
+ });
2272
+ if (isTeamError) {
2273
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui_web15.Card, { className: (0, import_ui_web15.cn)("border-0", className), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui_web15.CardContent, { className: "p-4 flex justify-center items-center", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-text-secondary", children: "Couldn't load team information. Please try again." }) }) });
2274
+ }
2275
+ if (leagueId === null) {
2276
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui_web15.Card, { className: (0, import_ui_web15.cn)("border-0", className), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_ui_web15.CardContent, { className: "p-4 flex justify-center items-center gap-2", children: [
2277
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui_web15.IconLoader, {}),
2278
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-text-secondary", children: "Loading team information..." })
2279
+ ] }) });
2280
+ }
2281
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_ui_web15.Card, { className: (0, import_ui_web15.cn)("border-none p-4 flex flex-col gap-3", className), children: [
2282
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui_web15.CardHeader, { className: "p-0 flex flex-row items-center justify-between space-y-0", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui_web15.CardTitle, { children: "Schedule" }) }),
2283
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui_web15.CardContent, { className: "space-y-0 p-0 flex flex-col gap-3", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2284
+ ScheduleBody,
2285
+ {
2286
+ seasonsLoading,
2287
+ seasons,
2288
+ isSeasonsError,
2289
+ columns,
2290
+ games,
2291
+ gamesLoading,
2292
+ isGamesError,
2293
+ isSm,
2294
+ isSmallLaptop
2295
+ }
2296
+ ) })
2297
+ ] });
2298
+ }
2299
+ // Annotate the CommonJS export names for ESM import in node:
2300
+ 0 && (module.exports = {
2301
+ EmptyValue,
2302
+ FactField,
2303
+ FactPills,
2304
+ FieldLabel,
2305
+ RecentGamesWidget,
2306
+ SeasonSelector,
2307
+ StatColumn,
2308
+ StatRankingLeaderboardDialog,
2309
+ TeamFactsContent,
2310
+ TeamFactsWidget,
2311
+ TeamInfoCard,
2312
+ TeamScheduleTable,
2313
+ TeamSeasonScheduleSummaryPanel,
2314
+ TeamSeasonStatsSummaryPanel,
2315
+ TeamSeasonStatsWidget,
2316
+ TeamStaffTable,
2317
+ TeamStatsTable,
2318
+ VenuePhoto
2319
+ });
2320
+ //# sourceMappingURL=team.cjs.map