UNPKG

@livescoresnu/footballui

Version:
1,713 lines 97 kB
import { L as V, U as b, S as H, E as R, a as C, b as se, c as ie, Y as ae, R as le, d as A, e as T, f as P, g as ne, C as ue, h as q, p as re, T as J, A as _e, i as be, P as ve, B as Ne, H as Se, W as Ie, j as pe, k as ke, l as E, V as Le, m as Z, n as Ce, o as Te, q as ze, r as Ee, s as de, t as Ae, F as U, u as Oe } from "./index-HUMAVJuf.js"; import { v as Mt } from "./index-HUMAVJuf.js"; import { jsx as t, jsxs as S, Fragment as k } from "react/jsx-runtime"; import Re, { useRef as De, useState as ee, useEffect as Fe, memo as M, Fragment as Pe, useCallback as He } from "react"; function fe(d) { const { events: e, lineups: s, team: c, isHome: n, formation: o, showFull: i, vertical: l, showPlayerImages: a, showClubLogos: u, fieldPattern: r, fieldColor: m, showAsTrapezium: f, isLoading: w, clickedListItem: _ } = d, x = s && s.filter( (g) => g?.type_id === V.LINEUP ).sort( (g, N) => (g?.formation_position ?? 0) - (N?.formation_position ?? 0) ), p = x?.filter((g) => g?.formation_position == null)?.length ?? !1, v = o != null && o != "-"; let h = [], y = []; return v && !w && (h = o?.split("-").map((g) => parseInt(g)) ?? [], h.unshift(1), y = h?.map((g, N) => { const I = p ? Me(N + 1, x ?? []) ?? [] : x?.splice(0, g) ?? []; return /* @__PURE__ */ t( Ue, { lineup: I, vertical: l, showPlayerImages: a, isHome: n, events: e ?? [], fieldColor: m, showAsTrapezium: f, clickedListItem: _ ?? (() => { }) }, N ); })), /* @__PURE__ */ S( "div", { className: b.classNames( f && n ? "perspective-750 " : "", "grid grid-rows-1 w-full overflow-hidden" ), children: [ /* @__PURE__ */ t( "div", { className: b.classNames( n ? "place-self-start" : l ? "place-self-start self-end" : "justify-self-end self-start", f && n ? "hidden" : "", "grid row-start-1 col-start-1 z-10 text-white p-2" ), children: /* @__PURE__ */ t( We, { showClubLogos: u, team: c ?? null, formation: o, clickedListItemId: _ } ) } ), /* @__PURE__ */ t( "div", { className: b.classNames( l ? "" : "min-w-96", f && n ? " px-0 sm:px-12 md:px-24" : "", "grid row-start-1 col-start-1 min-h-96 z-10" ), children: /* @__PURE__ */ t( "div", { className: b.classNames( n ? l ? "flex-col" : "flex-row" : l ? "flex-col-reverse" : "flex-row-reverse", "flex h-full justify-evenly text-white gap-2 p-2" ), children: v && y.length && !x?.length ? y : !w && /* @__PURE__ */ t("div", { className: "w-full text-center", children: "No line up available" }) } ) } ), /* @__PURE__ */ t( "div", { style: { backgroundImage: Ve( r, m, l, n ) }, className: b.classNames( l ? i ? n ? "rounded-t-md" : "rounded-b-md" : "rounded-md" : i ? n ? "rounded-l-md" : "rounded-r-md" : "rounded-md", f && n ? "mx-0 sm:mx-12 md:mx-32 rotate-x-45 -mt-32 -mb-7 rounded-xl" : "", w ? "animate-pulse" : "", "grid row-start-1 col-start-1" ), children: /* @__PURE__ */ S( "div", { className: b.classNames( n ? l ? "flex-col" : "flex-row" : l ? "flex-col-reverse" : "flex-row-reverse", i && n ? l ? "border-b-2" : "border-r-2" : "", Q(m), "flex justify-between items-center opacity-60" ), children: [ /* @__PURE__ */ t( Ge, { home: n, vertical: l, fieldColor: m } ), /* @__PURE__ */ t( Be, { home: n, vertical: l, fieldColor: m } ) ] } ) } ) ] } ); } const Ge = ({ home: d, vertical: e, fieldColor: s }) => /* @__PURE__ */ S( "div", { className: b.classNames( d ? e ? "flex-col" : "flex-row" : e ? "flex-col-reverse" : "flex-row-reverse", e ? "" : "sm:py-12", "flex h-fit items-center" ), children: [ /* @__PURE__ */ S( "div", { className: b.classNames( d ? e ? "justify-items-center" : "justify-items-start items-center" : e ? "justify-items-center items-end" : "justify-items-end items-center", "grid" ), children: [ /* @__PURE__ */ t( ce, { home: d, vertical: e, small: !1, fieldColor: s } ), /* @__PURE__ */ t( ce, { home: d, vertical: e, small: !0, fieldColor: s } ) ] } ), /* @__PURE__ */ t( "div", { className: b.classNames( d ? "rotate-180" : "", e ? "h-4 w-16 sm:h-8 sm:w-32" : "h-16 w-4 sm:h-32 sm:w-8", " overflow-hidden " ), children: /* @__PURE__ */ t( "div", { className: b.classNames( Q(s), "size-16 rounded-full border-2 sm:size-32" ) } ) } ) ] } ), ce = ({ home: d, vertical: e, small: s, fieldColor: c }) => /* @__PURE__ */ t( "div", { className: b.classNames( d ? e ? "border-b-2" : "border-r-2" : e ? "border-t-2" : "border-l-2", e ? s ? "h-6 w-20 sm:h-12 sm:w-48" : "h-16 w-48 sm:h-32 sm:w-96" : s ? "h-20 w-6 sm:h-40 sm:w-12 " : "h-48 w-16 sm:h-80 sm:w-28", e ? "border-x-2" : "border-y-2", Q(c), "col-start-2 row-start-1 flex" ) } ), Be = ({ home: d, vertical: e, fieldColor: s }) => /* @__PURE__ */ t( "div", { className: b.classNames( d ? "" : "rotate-180", e ? "h-8 w-16 sm:h-16 sm:w-32" : "h-16 w-8 sm:h-32 sm:w-16", "overflow-hidden " ), children: /* @__PURE__ */ t( "div", { className: b.classNames( Q(s), "size-16 rounded-full border-2 sm:size-32" ) } ) } ), Ue = ({ lineup: d, events: e, vertical: s, showPlayerImages: c, isHome: n, //fieldColor, showAsTrapezium: o, clickedListItem: i }) => { const l = d?.map((a) => { const u = a?.details?.find( (p) => p.type_id === H.RATING )?.data?.value || void 0, r = e?.filter( (p) => p.player_id === a.player_id || p.related_player_id === a.player_id ), m = (p) => p.player_id === a.player_id, f = r?.filter( (p) => (p.type_id === R.GOAL || p.type_id === R.PENALTY) && m(p) )?.length ?? 0, w = r?.find( (p) => p.type_id === R.YELLOWCARD && m(p) ), _ = r?.find( (p) => p.type_id === R.REDCARD && m(p) ), x = r?.find( (p) => p.type_id === R.SUBSTITUTION ); return /* @__PURE__ */ t( C, { id: a?.player_id ?? void 0, clickedItemId: a?.player_id ?? void 0, image: c && a?.player?.image_path ? a?.player?.image_path : /* @__PURE__ */ t("div", { className: "text-black flex text-base font-semibold items-center justify-center h-full ", children: a?.jersey_number ?? "-" }), title: a?.player?.display_name ? a?.player?.display_name : a?.player?.lastname ?? null, subtitle: u ? /* @__PURE__ */ t("div", { className: " flex items-center justify-center bg-black/20 rounded-b-sm w-full py-0.5", children: /* @__PURE__ */ t("div", { className: "text-xs w-fit items-center justify-center", children: Number(u) }) }) : null, subImages: { topRight: w ? /* @__PURE__ */ t(ae, { size: "medium" }) : _ ? /* @__PURE__ */ t(le, { size: "medium" }) : null, topLeft: x ? /* @__PURE__ */ t(ie, { size: "medium" }) : null, bottomLeft: a?.participant?.image_path ? a?.participant?.image_path : null, bottomRight: f > 0 ? /* @__PURE__ */ S(k, { children: [ /* @__PURE__ */ t("div", { className: "col-start-1 row-start-1 ", children: /* @__PURE__ */ t(se, { size: "medium" }) }), f > 1 && /* @__PURE__ */ t("div", { className: "col-start-1 row-start-1 text-black bg-white text-xs rounded-full border border-black w-4 h-4 flex justify-center items-center justify-self-end -mr-1.5 -mt-1.5", children: f }) ] }) : null }, listItemOptions: { textSize: "small", imageSize: "large", justify: "center", vertical: !0, highlighted: !0, rounded: "full", bold: !1, truncate: !0, imageShadow: o }, clickedListItem: i }, a?.player_id ); }); return /* @__PURE__ */ t( "div", { className: b.classNames( s ? n ? "flex-row items-start " : "flex-row-reverse items-start" : n ? "flex-col-reverse" : "flex-col", "flex justify-evenly perspective-250 gap-1" ), children: l } ); }; function Ve(d, e, s, c) { let n, o, i, l; switch (e) { case "green": n = "rgb(6,174,86)", o = "rgb(0,186,92)"; break; case "black": n = "rgb(28,28,30)", o = "rgb(10,10,12)"; break; case "pink": n = "rgb(226 126 217)", o = "rgb(250 132 240)"; break; case "loading": n = "rgb(255 255 255)", o = "rgb(229 231 235)"; break; default: n = "rgb(6,174,86)", o = "rgb(0,186,92)"; break; } switch (d) { case "stripes": s ? l = "to bottom" : l = "to right", i = "repeating-linear-gradient"; break; case "circle": c ? s ? l = "circle at bottom center" : l = "circle at center right" : s ? l = "circle at top center" : l = "circle at center left", i = "repeating-radial-gradient"; break; case "flat": i = "repeating-linear-gradient"; break; default: i = "repeating-linear-gradient"; break; } const a = `${n},${n} 16.6667%,${d == "flat" ? n : o} 16.6667%,${d == "flat" ? n : o} 33.3334%`; return `${i}(${l ? l + "," : ""} ${a})`; } function Q(d) { let e; switch (d) { case "green": e = "border-white"; break; case "black": e = "border-white"; break; case "pink": e = "border-white"; break; case "loading": e = "border-gray-400"; break; default: e = "border-white"; break; } return e; } function Me(d, e) { return e?.reduce( (n, o) => { const i = o?.formation_field?.split(":")[0] ?? void 0; return (i ? parseInt(i) ?? void 0 : void 0) === d && n.push(o), n; }, [] )?.sort( (n, o) => { const i = n?.formation_field?.split(":")[1] ?? void 0, l = o?.formation_field?.split(":")[1] ?? void 0; return parseInt(i ?? "") - parseInt(l ?? ""); } ); } const We = ({ team: d, showClubLogos: e, formation: s, clickedListItemId: c }) => /* @__PURE__ */ t( C, { id: d?.id ?? void 0, image: e && d?.image_path ? d?.image_path : null, title: d?.name ?? null, subtitle: s ?? null, listItemOptions: { textSize: "small", imageSize: "medium", rounded: "full", bold: !0, truncate: !0 }, clickedListItem: () => { c && d?.id && c(d?.id); } } ); function xt(d) { const { data: e, vertical: s, displayType: c, fieldPattern: n, fieldColor: o, showPlayerImages: i, showClubLogos: l, showEvents: a, isLoading: u, showAsTrapezium: r, clickedListItem: m } = d, { homeTeam: f, awayTeam: w } = e?.participants ? b.getHomeAndAwayTeams(e?.participants) : b.getHomeAndAwayTeamsByFormation(e?.formations || []) || {}, _ = (x) => { const p = x ? f : w, v = e?.lineups?.filter((g) => g?.team_id === p?.id) || [], h = e?.formations?.find((g) => g.participant_id === p?.id)?.formation || "-", y = e?.events?.filter((g) => g?.participant_id === p?.id) || []; return /* @__PURE__ */ t( fe, { events: a ? y : [], lineups: v, team: p ?? null, isHome: x, formation: h, showFull: c == "full", vertical: s, fieldPattern: n, fieldColor: u ? "loading" : o, showAsTrapezium: r, showPlayerImages: i, showClubLogos: l, isLoading: u, clickedListItem: m } ); }; return /* @__PURE__ */ t("div", { className: "flex flex-col w-full", children: c == "full" ? /* @__PURE__ */ S("div", { className: b.classNames(s ? "flex-col" : "", "flex"), children: [ _(!0), _(!1) ] }) : _(c == "home") }); } function te(d) { const { events: e, lineups: s, title: c, showPlayerImages: n, isLoading: o, clickedListItem: i } = d; if (o) return /* @__PURE__ */ t(A, { type: "Table", amount: 3 }); const l = s && s.sort( (a, u) => (a?.formation_position ?? 0) - (u?.formation_position ?? 0) ).map((a) => { const u = e && e.sort((f, w) => (w?.type_id || 0) - (f?.type_id || 0)).filter( (f) => f.player_id === a.player_id || f.related_player_id === a.player_id ), r = (f) => f.player_id === a.player_id, m = (f) => f.related_player_id === a.player_id; return /* @__PURE__ */ S("div", { className: "flex justify-between", children: [ /* @__PURE__ */ t( C, { id: a?.player?.id ?? void 0, image: n && a?.player?.image_path ? a?.player?.image_path : null, title: a?.player?.display_name ? a?.player?.display_name : a?.player_name ? a?.player_name : "-", subtitle: null, rank: a?.jersey_number ?? null, subImages: { bottomRight: a?.player?.country?.image_path ?? null }, clickedItemId: a?.player?.id ?? void 0, clickedListItem: i, listItemOptions: { textSize: "medium", imageSize: "medium", vertical: !1, justify: "start", truncate: !0, rounded: "full" } } ), /* @__PURE__ */ t("div", { className: "flex w-fit space-x-1 items-center", children: u && u.sort((f, w) => (w?.type_id ?? 0) - (f?.type_id ?? 0)).map((f) => { if ((f.type_id === R.GOAL || f.type_id === R.PENALTY) && r(f)) return /* @__PURE__ */ t(se, { size: "medium" }, f?.id); if (f.type_id === R.REDCARD && r(f)) return /* @__PURE__ */ t(le, { size: "medium" }, f?.id); if (f.type_id === R.YELLOWCARD && r(f)) return /* @__PURE__ */ t(ae, { size: "medium" }, f?.id); if ( //todo: there should never be more than one substitution event for a player f.type_id === R.SUBSTITUTION && (r(f) || m(f)) ) return /* @__PURE__ */ S( "div", { className: "flex space-x-1 justify-center items-center", children: [ /* @__PURE__ */ t(ie, { size: "medium" }), /* @__PURE__ */ S("span", { className: "text-xs", children: [ f.minute, "'" ] }) ] }, f?.id ); }) }) ] }, a?.id); }); return /* @__PURE__ */ S("div", { className: "flex flex-col bg-white dark:bg-white/10 rounded-md p-4 w-full space-y-2 text-sm dark:text-white/80", children: [ /* @__PURE__ */ t("span", { className: "text-left p-1 uppercase", children: c }), l ] }); } function _t(d) { const { data: e, displayType: s, showSubs: c, showPlayerImages: n, showClubLogos: o, showEvents: i, isLoading: l, clickedListItem: a } = d; if (l) return /* @__PURE__ */ t(A, { type: "CardList", amount: 1 }); const { homeTeam: u, awayTeam: r } = e?.participants ? b.getHomeAndAwayTeams(e?.participants) : b.getHomeAndAwayTeamsByFormation(e?.formations || []) || {}, m = (f) => { const w = f ? u : r; if (!w) return null; const _ = e?.lineups?.filter((v) => v?.team_id === w?.id).filter( (v) => v?.type_id === V.LINEUP ) || [], x = e?.lineups?.filter((v) => v?.team_id === w?.id).filter( (v) => v.type_id === V.BENCH ) || [], p = e?.events?.filter((v) => v?.participant_id === w?.id) || []; return /* @__PURE__ */ S("div", { className: "flex flex-col space-y-4", children: [ /* @__PURE__ */ t( C, { id: w?.id ?? void 0, image: o && w?.image_path ? w?.image_path : null, title: w?.name ?? null, listItemOptions: { textSize: "medium", imageSize: "medium", justify: "center", bold: !0, centered: !0 }, clickedListItem: a } ), !e?.lineups || e?.lineups?.length === 0 ? /* @__PURE__ */ t("div", { className: "flex w-full justify-center", children: /* @__PURE__ */ t("div", { className: "text-sm text-gray-500", children: "Lineup not available" }) }) : /* @__PURE__ */ S(k, { children: [ /* @__PURE__ */ t( te, { events: i ? p : [], lineups: _, title: "Starting eleven", isLoading: l, showPlayerImages: n, clickedListItem: a } ), c && /* @__PURE__ */ t( te, { events: i ? p : [], lineups: x, title: "Substitutes", isLoading: l, showPlayerImages: n, clickedListItem: a } ) ] }) ] }); }; return /* @__PURE__ */ t("div", { className: "flex flex-col w-full", children: s == "full" ? /* @__PURE__ */ S("div", { className: "flex-col space-y-4", children: [ m(!0), m(!1) ] }) : m(s == "home") }); } function je({ data: d, small: e }) { if (!d) return /* @__PURE__ */ t("div", { className: "flex space-x-0.5 md:space-x-1" }); const s = d?.sort((c, n) => c.sort_order - n.sort_order).slice(-5).map((c, n) => /* @__PURE__ */ t( "div", { className: b.classNames( c.form == "W" ? "bg-green-500" : c.form == "D" ? "bg-yellow-500" : "bg-red-500", n == 0 ? "bg-opacity-50" : n == 1 ? "bg-opacity-60" : n == 2 ? "bg-opacity-80" : n == 3 ? "bg-opacity-90" : "bg-opacity-100", e ? "w-4 h-4 text-xs" : "w-6 h-6 text-sm", "flex rounded-full justify-center items-center text-center text-white shrink-0" ), children: c.form }, c.id )); return /* @__PURE__ */ t("div", { className: "flex mt-0.5 items-center space-x-0.5 md:space-x-1", children: s }); } function B(d) { const e = De(null), { title: s, columns: c, rows: n, totals: o, isLoading: i, stickyHeader: l, size: a, labelShrink: u, rounded: r, hideHeader: m } = d, [f, w] = ee(!0), [_, x] = ee(!1), [p, v] = ee(!0); Fe(() => { if (i) return; const y = e.current; if (y) return y.addEventListener("scroll", h, { passive: !0 }), y.scrollWidth <= y.clientWidth && x(!0), () => { y.removeEventListener("scroll", h); }; }, [i]); const h = () => { if (e.current) { const { scrollLeft: y, scrollTop: g, clientWidth: N, scrollWidth: I } = e.current, L = y + 10 + N >= I, O = y == 0, W = g < 10; v(!!W), x(!!L), w(!!O); } }; return i ? /* @__PURE__ */ t(A, { type: "Table", amount: 3 }) : !n || !c ? null : /* @__PURE__ */ t( "div", { className: b.classNames( l ? "h-screen" : "", "flex flex-col" ), children: /* @__PURE__ */ S( "table", { cellPadding: 0, ref: e, className: "block w-full whitespace-nowrap relative overflow-x-auto table-auto border-separate border-spacing-y-2", children: [ /* @__PURE__ */ t(Ke, { columns: c, labelShrink: u }), m ? /* @__PURE__ */ t(k, {}) : /* @__PURE__ */ t( qe, { columns: c, title: s, isTop: p, isLeft: f, isRight: _, stickyHeader: l, labelShrink: u } ), /* @__PURE__ */ t( Ye, { rows: n, columns: c, rounded: r, size: a, isLeft: f, isRight: _ } ), o && /* @__PURE__ */ t( Qe, { columns: c, totals: o, isTop: p, isLeft: f, isRight: _ } ) ] } ) } ); } const $e = M(function({ columns: e, item: s, cellHeight: c, cellColor: n }) { const o = e?.map((i) => { const l = s?.rowCells?.find( (r) => r.type_id === i.type_id ), a = Ze(i?.textSize); let u = l?.value; return typeof l?.value == "boolean" && (u = u ? "Yes" : "No"), /* @__PURE__ */ t( "td", { className: b.classNames( c, n, a, "text-center align-middle " ), children: i?.highlight ? /* @__PURE__ */ t("span", { className: "bg-gray-100 dark:bg-white/80 dark:text-black rounded-md px-2 py-1 font-semibold", children: u || 0 }) : u || 0 }, i?.type_id ); }); return /* @__PURE__ */ t(k, { children: o }); }), Ye = M(function({ rows: e, columns: s, size: c, rounded: n, isLeft: o, isRight: i }) { const l = e?.sort((a, u) => (a.rowSortOrder ?? 0) - (u.rowSortOrder ?? 0)).map((a, u) => { const r = Je(c, a.rowIsSubHeader), m = et(a?.rowColor), f = Xe( a?.rowIsHighlighted, a?.rowIsDisabled, a.rowIsSubHeader ); return /* @__PURE__ */ S("tr", { children: [ /* @__PURE__ */ t( "td", { className: b.classNames( r, a.rowIsSubHeader ? "font-bold text-sm" : "", "sticky left-0 z-10 " ), children: /* @__PURE__ */ S("div", { className: "flex", children: [ /* @__PURE__ */ t( "div", { className: b.classNames( f, r, m, n ? "rounded-l-md" : "", "w-full px-2 align-middle text-left flex items-center" ), children: a.rowComponent } ), /* @__PURE__ */ t( "div", { className: b.classNames( o ? f : a.rowIsSubHeader ? "" : "bg-linear-to-l from-transparent to-black/10 w-2.5 -mr-2.5" ) } ) ] }) } ), !a.rowIsSubHeader && /* @__PURE__ */ S(k, { children: [ /* @__PURE__ */ t( $e, { columns: s, item: a, cellHeight: r, cellColor: f } ), /* @__PURE__ */ t( "td", { className: b.classNames( r, a.rowIsSubHeader ? "" : i ? n ? "rounded-r-md" : "" : "bg-linear-to-r from-transparent to-black/10", i ? f : "", "sticky right-0 z-10 w-2.5" ) }, a?.rowSortOrder + "-right" ) ] }) ] }, u); }); return /* @__PURE__ */ t("tbody", { children: l }); }), qe = M(function({ columns: e, title: s, isTop: c, isLeft: n, isRight: o, stickyHeader: i, labelShrink: l }) { if (!e?.length) return null; const a = e?.map((u, r) => /* @__PURE__ */ S( "th", { className: b.classNames( !c && i ? "bg-black text-white dark:bg-[#414141] dark:text-white/80 sticky top-0" : "", "h-8" ), children: [ /* @__PURE__ */ t("div", { className: "font-semibold text-xs leading-3 items-center justify-center text-center flex whitespace-break-spaces", children: /* @__PURE__ */ t("span", { className: "text-center line-clamp-3 px-1 break-words", children: u.icon ? u.icon : "-" }) }), " " ] }, r )); return /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ S("tr", { children: [ /* @__PURE__ */ t( "th", { className: b.classNames( l ? "" : "min-w-48", "sticky left-0 top-0 z-10 text-left text-sm w-full " ), children: /* @__PURE__ */ S("div", { className: "flex h-full", children: [ /* @__PURE__ */ t( "div", { className: b.classNames( n ? "" : "bg-[#eff4f8] dark:bg-[#121212]", "w-full p-2 align-middle text-left flex items-center rounded-l-md" ), children: s || /* @__PURE__ */ t(k, {}) } ), /* @__PURE__ */ t( "div", { className: b.classNames( n ? "" : "bg-linear-to-l from-transparent to-black/10 w-2.5 -mr-2.5" ) } ) ] }) } ), a, /* @__PURE__ */ t( "th", { className: b.classNames( o ? "" : "bg-linear-to-r from-transparent to-black/10", "sticky right-0 z-10 w-2.5 min-w-2.5" ) } ) ] }) }); }), Ke = M(function({ columns: e, labelShrink: s }) { const c = e?.map((n) => /* @__PURE__ */ t( "col", { className: b.classNames( n?.size == "sm" ? "w-6 min-w-6 sm:w-8 sm:min-w-8" : n?.size == "md" ? "w-8 min-w-8 sm:w-10 sm:min-w-10" : n?.size == "lg" ? "w-12 min-w-12" : n?.size == "xl" ? "w-16 min-w-16" : n?.size == "2xl" ? "w-24 min-w-24" : "" //"w-8" ) }, "col-" + n?.type_id )); return /* @__PURE__ */ S("colgroup", { children: [ /* @__PURE__ */ t( "col", { className: b.classNames(s ? "" : "min-w-48", "w-full") } ), c, /* @__PURE__ */ t("col", { className: "w-2.5 min-w-2.5 " }) ] }); }), Qe = M(function({ columns: e, totals: s, isLeft: c, isRight: n }) { const o = s ? e?.map((i) => /* @__PURE__ */ t("td", { className: "text-xs text-center", children: s?.[i.type_id] ? Number(s?.[i.type_id])?.toFixed( i.type_id == 118 ? 2 : 0 ) : "-" }, "total-" + i?.type_id)) : null; return /* @__PURE__ */ t("tfoot", { children: /* @__PURE__ */ S("tr", { children: [ /* @__PURE__ */ t("th", { className: "sticky left-0 top-0 z-10 text-left", children: /* @__PURE__ */ S("div", { className: "flex h-full", children: [ /* @__PURE__ */ t( "div", { className: b.classNames( c ? "" : "bg-[#eff4f8] dark:bg-[#121212]", "w-full p-2 align-middle text-left flex items-center rounded-l-md" ), children: "Total" } ), /* @__PURE__ */ t( "div", { className: b.classNames( c ? "" : "bg-linear-to-l from-transparent to-black/10 w-2.5 -mr-2.5" ) } ) ] }) }), o, /* @__PURE__ */ t( "th", { className: b.classNames( n ? "" : "bg-linear-to-r from-transparent to-black/10", "sticky right-0 z-10 w-2.5 min-w-2.5" ) } ) ] }) }); }); function Xe(d, e, s) { let c; return s ? c = "" : d ? c = "bg-gray-200 dark:bg-[#414141]" : e ? c = "bg-[#eff4f8] dark:bg-[#121212]" : c = "bg-white dark:bg-[#414141] dark:text-white/80", c; } function Je(d, e) { let s; if (e) return s = "h-8"; switch (d) { case "sm": s = "h-10"; break; case "md": s = "h-12"; break; case "lg": s = "h-16"; break; default: s = "h-10"; break; } return s; } function Ze(d) { let e; switch (d) { case "sm": e = "text-xs sm:text-sm"; break; case "md": e = "text-sm"; break; case "lg": e = "text-base"; break; default: e = "text-sm"; break; } return e; } function et(d) { let e; switch (d) { case "green": e = "border-l-green-500 border-l-4"; break; case "yellow": e = "border-l-yellow-500 border-l-4"; break; case "red": e = "border-l-red-500 border-l-4"; break; default: e = ""; break; } return e; } function bt(d) { const { data: e, groupId: s, showDetails: c, showForm: n, highlightedTeamIds: o, isLoading: i, stickyHeader: l, labelShrink: a, pointLast: u, size: r, rounded: m, clickedListItem: f } = d; if (i) return /* @__PURE__ */ t(A, { type: "Table", amount: 3 }); if (!e) return null; const x = ((s ? e.filter((p) => p?.group?.id === s) : e)?.reduce((p, v) => { const h = v?.group || { id: "noGroup", name: "" }, y = p.find( (g) => g.key === h?.id?.toString() ); return y ? y.data.push(v) : p.push({ key: h.id.toString(), name: h.name, data: [v] }), p; }, []).sort( (p, v) => p.name.localeCompare(v.name) )).map((p) => { const v = p?.data?.sort( (g, N) => (g.position ?? 0) - (N.position ?? 0) ).map((g) => { const N = g?.rule?.type_id ?? void 0, I = it(N), L = g?.details?.map( (D) => { if (D?.type_id === T.OVERALL_SCORED) { const z = g?.details && g?.details.find( (j) => j?.type_id === T.OVERALL_CONCEDED )?.value, F = D?.value + " - " + z; return { type_id: T.CUSTOM_OVERALL_SCORED_AND_CONCEDED, value: F }; } else if (D?.type_id === T.OVERALL_GOAL_DIFFERENCE) return { type_id: D?.type_id, value: D?.value !== null ? D?.value > 0 ? "+" + D?.value : D?.value : null }; return { type_id: D?.type_id, value: D?.value }; } ), O = !!(o && g?.participant_id && o?.includes(g?.participant_id)); return { rowComponent: /* @__PURE__ */ t( C, { image: g?.participant?.image_path ?? null, title: g?.participant?.name ?? null, subtitle: n && r != "sm" ? /* @__PURE__ */ t(je, { data: g?.form ?? null, small: !0 }) : void 0, id: g?.participant_id ?? null, clickedItemId: g?.participant_id ?? null, rank: g?.position, clickedListItem: f, listItemOptions: { textSize: "medium", imageSize: "medium", justify: "start", truncate: !0 } } ), rowColor: I, rowIsHighlighted: O, rowIsDisabled: !1, rowCells: L }; }), h = u ? st : tt, y = c ? h : h.filter((g) => g.keyStat); return /* @__PURE__ */ t( B, { title: p?.name, columns: y, rows: v, size: r, labelShrink: a, isLoading: i ?? !1, stickyHeader: l, rounded: m }, p?.key ); }); return /* @__PURE__ */ t(k, { children: x }); } const tt = [ { type_id: T.TOTAL_POINTS, icon: /* @__PURE__ */ t(k, { children: "P" }), keyStat: !0, size: "md", textSize: "md", highlight: !0 }, { type_id: T.OVERALL_MATCHES, icon: /* @__PURE__ */ t(k, { children: "Mp" }), keyStat: !0, size: "md", textSize: "md", highlight: !1 }, { type_id: T.OVERALL_WINS, icon: /* @__PURE__ */ t(k, { children: "W" }), keyStat: !0, size: "sm", textSize: "sm", highlight: !1 }, { type_id: T.OVERALL_DRAWS, icon: /* @__PURE__ */ t(k, { children: "D" }), keyStat: !0, size: "sm", textSize: "sm", highlight: !1 }, { type_id: T.OVERALL_LOST, icon: /* @__PURE__ */ t(k, { children: "L" }), keyStat: !0, size: "sm", textSize: "sm", highlight: !1 }, { type_id: T.CUSTOM_OVERALL_SCORED_AND_CONCEDED, icon: /* @__PURE__ */ t(k, { children: "Goals" }), keyStat: !1, size: "lg", textSize: "sm", highlight: !1 }, { type_id: T.OVERALL_GOAL_DIFFERENCE, icon: /* @__PURE__ */ t(k, { children: "Gd" }), keyStat: !0, size: "md", textSize: "sm", highlight: !1 } ], st = [ { type_id: T.OVERALL_MATCHES, icon: /* @__PURE__ */ t(k, { children: "Mp" }), keyStat: !0, size: "md", textSize: "md", highlight: !1 }, { type_id: T.OVERALL_WINS, icon: /* @__PURE__ */ t(k, { children: "W" }), keyStat: !0, size: "sm", textSize: "sm", highlight: !1 }, { type_id: T.OVERALL_DRAWS, icon: /* @__PURE__ */ t(k, { children: "D" }), keyStat: !0, size: "sm", textSize: "sm", highlight: !1 }, { type_id: T.OVERALL_LOST, icon: /* @__PURE__ */ t(k, { children: "L" }), keyStat: !0, size: "sm", textSize: "sm", highlight: !1 }, { type_id: T.CUSTOM_OVERALL_SCORED_AND_CONCEDED, icon: /* @__PURE__ */ t(k, { children: "Goals" }), keyStat: !1, size: "lg", textSize: "sm", highlight: !1 }, { type_id: T.OVERALL_GOAL_DIFFERENCE, icon: /* @__PURE__ */ t(k, { children: "Gd" }), keyStat: !0, size: "md", textSize: "sm", highlight: !1 }, { type_id: T.TOTAL_POINTS, icon: /* @__PURE__ */ t(k, { children: "P" }), keyStat: !0, size: "md", textSize: "md", highlight: !0 } ]; function it(d) { let e; switch (d) { case P.PROMOTION: case P.UEFA_CHAMPIONS_LEAGUE: case P["8TH_FINALS"]: case P.CHAMPIONSHIP_ROUND: e = "green"; break; case P.RELEGATION_PLAY_OFF: case P.PROMOTION_PLAY_OFF: case P.UEFA_EUROPA_LEAGUE: case P.UEFA_CHAMPIONS_LEAGUE_QUALIFIERS: e = "yellow"; break; case P.RELEGATION_ROUND: case P.RELEGATION: e = "red"; break; } return e; } function at({ id: d, image_path: e, component: s, vertical: c, subComponent: n, clickedEventItem: o }) { return /* @__PURE__ */ t( "div", { style: { backgroundImage: `url(${e})` }, onClick: () => o && d && o(d), className: b.classNames( o ? "cursor-pointer" : "", e ? "bg-(image:--image-url) bg-no-repeat bg-center bg-cover " : "bg-gray-200 dark:bg-white/10", "rounded-md h-full select-none" ), children: /* @__PURE__ */ S( "div", { className: b.classNames( c ? "flex-col" : "", e ? "bg-linear-to-b from-black/60 via-black/20 to-black/60" : "", "w-full p-2 rounded-md flex justify-between items-center h-full" ), children: [ /* @__PURE__ */ t("div", { className: "text-white w-full", children: s }), n ] } ) }, d ); } function vt(d) { const { data: e, isLoading: s, type: c, subComponent: n, imageSize: o, textSize: i, showClubLogo: l, showClubName: a, showFlag: u, justify: r, vertical: m, centered: f, highlighted: w, clickedListItem: _ } = d; if (s) return /* @__PURE__ */ t( A, { type: "Header", amount: 1, size: c == "player" || c == "team" ? "large" : "medium" } ); let x, p, v, h; if (c === "player") { const g = e?.teams?.find( (N) => N?.team?.type == "domestic" ); x = e?.display_name ?? null, p = g?.team?.venue?.image_path ?? "https://firebasestorage.googleapis.com/v0/b/oles-test-project.appspot.com/o/common%2Fstadium.png?alt=media&token=7075d1e6-b2d6-48e1-ae5e-5f12d570d847", v = g?.team?.name ?? null, h = g?.team?.image_path ?? null; } else x = e?.name ?? null, p = c === "team" ? e?.venue?.image_path ?? "https://firebasestorage.googleapis.com/v0/b/oles-test-project.appspot.com/o/common%2Fstadium.png?alt=media&token=7075d1e6-b2d6-48e1-ae5e-5f12d570d847" : c === "league" ? "https://firebasestorage.googleapis.com/v0/b/oles-test-project.appspot.com/o/common%2Fstadium.png?alt=media&token=7075d1e6-b2d6-48e1-ae5e-5f12d570d847" : null; return /* @__PURE__ */ t( at, { vertical: m, image_path: p ?? null, component: /* @__PURE__ */ t(() => /* @__PURE__ */ t( C, { id: e?.id ?? void 0, clickedItemId: e?.id ?? void 0, image: e?.image_path ?? null, title: x ?? null, subtitle: a ? v : null, subImages: { bottomLeft: c === "player" && u ? e?.country?.image_path : null, bottomRight: c === "player" && l ? h : null }, listItemOptions: { textSize: i, imageSize: o, rounded: "full", bold: !0, justify: r, vertical: m, centered: f, highlighted: w }, clickedListItem: _ } ), {}), subComponent: n } ); } function Nt(d) { const { data: e, statType: s, customStatsMap: c, showTotals: n, stickyHeader: o, rounded: i, isLoading: l, showLeagueLogos: a, clickedListItem: u } = d, r = ne?.filter( (x) => c?.length ? c?.includes(x.type_id) : s === "offensive" ? x.type === "offensive" && !x.onlyFixture : s === "defensive" ? x.type === "defensive" && !x.onlyFixture : s === "overall" ? x.type === "overall" && !x.onlyFixture : s === "key" ? x?.keyStat && !x.onlyFixture : !1 ), m = b.getStatsTotals( r, e?.statistics ?? [] ); let f = ""; const w = e?.statistics?.reduce((x, p) => { const v = x.find( (h) => h.name === p?.season?.name ); return v ? v.rows.push(p) : x.push({ name: p?.season?.name ?? "", ending_at: p?.season?.ending_at, rows: [p] }), x; }, []).sort( (x, p) => (new Date(p?.ending_at ?? "") ?? /* @__PURE__ */ new Date()).getTime() - (new Date(x?.ending_at ?? "") ?? /* @__PURE__ */ new Date()).getTime() ), _ = []; return w?.forEach((x, p) => { const v = { rowComponent: x?.name, rowIsDisabled: !0, rowIsSubHeader: !0 }; p == 0 ? f = x?.name : _.push(v), x?.rows?.forEach((h) => { const y = h?.details?.map( (N) => ({ type_id: N?.type_id, value: N?.value?.total }) ), g = /* @__PURE__ */ t( C, { image: a && h?.season?.league?.image_path ? h?.season?.league?.image_path : null, title: h?.season?.league?.name ?? null, subtitle: h?.team?.name ?? void 0, id: h?.id ?? null, clickedItemId: h?.season?.league?.id ?? null, clickedListItem: u, listItemOptions: { textSize: "medium", imageSize: "medium", justify: "start", truncate: !0 } } ); _.push({ rowComponent: g, rowIsDisabled: !1, rowCells: y, rowIsSubHeader: !1 }); }); }), /* @__PURE__ */ t( B, { columns: r, title: f, rows: _, size: "md", totals: n ? m : void 0, isLoading: l ?? !1, stickyHeader: o, rounded: i } ); } function St(d) { const { data: e, type: s, hideHeader: c, showPlayerImages: n, showClubName: o, rounded: i, title: l, isLoading: a, clickedListItem: u } = d, r = [ { type_id: s, icon: /* @__PURE__ */ t(k, { children: l }), keyStat: !0, size: "md", textSize: "md", highlight: !0 } ], m = s == H.GOAL_TOPSCORER || s == H.ASSIST_TOPSCORER || s == H.REDCARDS || s == H.YELLOWCARDS; if (!e || !Array.isArray(e) || !m) return null; const f = e?.map((w) => { const _ = [ { type_id: s, value: w?.total } ]; return { rowComponent: /* @__PURE__ */ t( C, { image: n && w?.player?.image_path ? w?.player?.image_path : null, title: w?.player?.display_name ?? null, subtitle: o && w?.participant?.name ? w?.participant?.name : null, id: w?.player_id ?? null, clickedItemId: w?.player_id ?? null, rank: w?.position, clickedListItem: u, listItemOptions: { textSize: "medium", imageSize: "medium", justify: "start", truncate: !0 } } ), rowIsDisabled: !1, rowCells: _ }; }); return /* @__PURE__ */ t( B, { columns: r, rows: f, size: o ? "md" : "sm", isLoading: a ?? !1, stickyHeader: !1, rounded: i, hideHeader: c } ); } function It(d) { const { data: e, showLeagueLogos: s, isLoading: c, clickedListItem: n } = d; if (c) return /* @__PURE__ */ t(A, { type: "Table", amount: 3, header: !0 }); if (!e) return null; const i = (e?.reduce( (l, a) => { const u = l.find( (r) => r.key === a?.country_id ); return u ? u.data.push(a) : l.push({ key: a?.country_id ?? 0, name: a?.country?.name ?? null, image_path: a?.country?.image_path ?? null, data: [a] }), l; }, [] )).sort((l, a) => (l.name ?? "").localeCompare(a.name ?? "")).map((l) => { const a = l.data?.sort((u, r) => u?.sort_order && r?.sort_order ? u.sort_order - r.sort_order : u?.sort_order ? -1 : r?.sort_order ? 1 : u?.name && r?.name ? (u.name ?? "").localeCompare(r.name ?? "") : 0).map((u) => /* @__PURE__ */ S( "div", { className: "flex h-12 items-center px-2 bg-white dark:bg-white/20 dark:text-white/80 rounded-md justify-between", children: [ /* @__PURE__ */ t( C, { image: s && u?.image_path ? u?.image_path : null, title: u?.name ?? null, id: u?.id ?? void 0, clickedItemId: u?.id ?? void 0, clickedSecondaryItemId: u?.currentseason?.id ?? void 0, clickedListItem: n, listItemOptions: { textSize: "medium", imageSize: "medium", justify: "start" } } ), /* @__PURE__ */ t("span", { className: "w-6", children: /* @__PURE__ */ t(ue, {}) }) ] }, u?.id )); return /* @__PURE__ */ S("div", { className: "flex flex-col space-y-2", children: [ /* @__PURE__ */ t( C, { image: l?.image_path, title: l?.name ?? null, id: l?.key ?? void 0, listItemOptions: { textSize: "medium", imageSize: "medium", justify: "start", rounded: "medium", bold: !0 } } ), a ] }, l?.key); }); return /* @__PURE__ */ t("div", { className: "flex w-full flex-col space-y-4", children: i }); } function kt(d) { const { data: e, size: s, showLogos: c, teamInFocus: n, groupBy: o, showTeamShortCode: i, showEventClockAndStatus: l, showLeagueLogo: a, showListLeagueLogo: u, showEventDate: r, showAsCard: m, showStadiumBackground: f, isLoading: w, showGoalScorers: _, clickedEventItem: x, clickedListItem: p } = d; return w ? /* @__PURE__ */ t(A, { type: "EventItem", amount: 3, size: s, header: !0 }) : e ? e?.reduce((h, y) => { const g = o === "season" ? y?.season_id ?? "none" : o === "league" ? y?.league_id ?? "none" : (o === "none" || !o) && "none", N = h.find( (I) => I.key === g ); return N ? N.fixtures.push(y) : h.push({ key: g ?? null, year: y?.season?.name, name: y?.league?.name ?? null, image_path: y?.league?.image_path, season_id: y?.season_id, league_id: y?.league_id, sort_order: y?.league?.sort_order, fixtures: [y] }), h; }, [])?.sort((h, y) => { const g = h.year ? h.year.split("/")[0] : null, N = y.year ? y.year.split("/")[0] : null; return g && N ? Number(N) - Number(g) : h?.name && y?.name ? h?.name?.localeCompare(y?.name) : 0; })?.sort((h, y) => { if (o === "season") { const g = h.year ? Number(h.year?.split("/")[0]) : null, N = y.year ? Number(y.year?.split("/")[0]) : null; return g && N ? N - g : h.name?.localeCompare(y.name ?? "") ?? 0; } else return h?.sort_order && y?.sort_order ? h.sort_order - y.sort_order : h?.sort_order ? -1 : y?.sort_order ? 1 : h?.name && y?.name ? h.name.localeCompare(y.name) : 0; }).map((h) => { const y = h?.fixtures?.sort((N, I) => new Date(N.starting_at_timestamp ?? 0).getTime() - new Date(I.starting_at_timestamp ?? 0).getTime()).map((N) => /* @__PURE__ */ t( q, { fixtureData: N, showEventClockAndStatus: l, teamInFocus: n, showLogos: c, showLeagueLogo: a, showEventDate: r, showGoalScorers: _ ?? !1, size: s, showTeamShortCode: i, showAsCard: m, showStadiumBackground: f, showScores: !0, showTime: !0, clickedEventItem: x, element: N?.element }, N?.id )), g = o === "season" || o === "league" ? /* @__PURE__ */ t("div", { className: "flex h-12 font-semibold min-w-max", children: /* @__PURE__ */ t( C, { image: u ? h?.image_path ?? null : null, title: h?.name ?? null, id: h?.league_id ?? void 0, subtitle: o === "season" ? h?.year : null, listItemOptions: { imageSize: "medium", textSize: "small", justify: "start" }, clickedItemId: h?.league_id ?? void 0, clickedSecondaryItemId: h?.season_id ?? void 0, clickedListItem: p } ) }) : null; return /* @__PURE__ */ S(Re.Fragment, { children: [ g, /* @__PURE__ */ t("div", { className: "flex w-full flex-col space-y-2", children: y }) ] }, h?.key); }) : null; } function Lt(d) { const { data: e, showPlayerImages: s, isLoading: c, clickedListItem: n } = d; if (c) return /* @__PURE__ */ t(A, { type: "CardList", amount: 1 }); const o = re?.map((i) => { const l = e?.sort((a, u) => (a?.jersey_number || 99) - (u?.jersey_number || 99)).filter((a) => a.position_id === i.position_id) || []; return /* @__PURE__ */ t( te, { lineups: l, title: i.plural, isLoading: c, showPlayerImages: s, clickedListItem: n }, i.position_id ); }); return /* @__PURE__ */ t("div", { className: "flex flex-col w-full space-y-2", children: o }); } function Ct(d) { const { data: e, clubId: s, showClubLogos: c, transferType: n, showPlayer: o, isLoading: i, clickedListItem: l } = d, u = [ { type_id: 0, icon: /* @__PURE__ */ t(k, { children: "From" }), keyStat: !0, size: "2xl", textSize: "sm", highlight: !1 }, { type_id: 1, icon: /* @__PURE__ */ t(k, { children: "To" }), keyStat: !0, size: "2xl", textSize: "sm", highlight: !1 }, { type_id: 2, icon: /* @__PURE__ */ t(k, { children: "Date" }), keyStat: !0, size: "2xl", textSize: "sm", highlight: !1 }, { type_id: 3, icon: /* @__PURE__ */ t(k, { children: "Fee" }), keyStat: !0, size: "xl", textSize: "md", highlight: !1 } ]?.filter((m) => { if (!(!o && m.type_id === 1)) return m; }), r = e?.filter((m) => n === "transferIn" && s ? m?.to_team_id === s : n === "transferOut" && s ? m?.from_team_id === s : !0).sort((m, f) => m.date && f.date ? new Date(f.date).getTime() - new Date(m.date).getTime() : 0).map((m) => { const f = m?.type_id == J.TRANSFER ? m?.amount ? "€" + m?.amount / 1e6 + "m" : "Undisc." : m?.type_id == J.FREE_TRANSFER ? "Free" : m.type_id == J.LOAN_TRANSFER ? "Loan" : "-", w = m?.to_team_id === s, _ = [ { type_id: 0, value: s && !w ? null : m?.fromteam?.name ?? "-" }, { type_id: 1, value: s && w ? null : m?.toteam?.name ?? "-" }, { type_id: 2, value: m?.date ? m?.date : "-" }, { type_id: 3, value: f } ], x = o ? m?.player?.image_path : m?.toteam?.image_path, p = o ? m?.player?.display_name : m?.toteam?.name, v = o ? m?.player?.country?.image_path : null, h = o ? m?.player_id : m?.to_team_id, y = o ? m?.player_id : m?.to_team_id; return { rowComponent: /* @__PURE__ */ t( C, { image: c && x || null, title: p ?? null, subImages: { bottomRight: v ?? null }, id: h ?? null, clickedItemId: y ?? null, clickedListItem: l, listItemOptions: { textSize: "medium", imageSize: "medium", justify: "start", truncate: !0 } } ), rowIsDisable