fansunited-data-layer 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- import { t as C, g as F, f as se, c as Z, S as ie, a as ae } from "./index-D8MJQXDd.js";
2
- import { b as no, d as so, e as io, h as ao, i as ro, j as co, k as lo, l as uo, m as mo, n as fo, o as po, p as go, q as yo, r as ho, s as To, u as vo, v as So } from "./index-D8MJQXDd.js";
1
+ import { t as C, g as F, f as se, c as Z, S as ie, a as re } from "./index-DMVprv64.js";
2
+ import { b as no, d as so, e as io, h as ro, i as ao, j as co, k as lo, l as uo, m as mo, n as fo, o as po, p as go, q as yo, r as ho, s as To, u as vo, v as So } from "./index-DMVprv64.js";
3
3
  import { useMemo as L } from "react";
4
- function re(e) {
4
+ function ae(e) {
5
5
  return {
6
6
  entityType: "tournament",
7
7
  id: e.id.toString(),
@@ -147,7 +147,7 @@ function me(e) {
147
147
  function fe(e) {
148
148
  switch (e.entity_type) {
149
149
  case "tournament":
150
- return re(e);
150
+ return ae(e);
151
151
  case "player":
152
152
  return ce(e);
153
153
  case "team":
@@ -198,13 +198,13 @@ function M(e) {
198
198
  threeLetterCode: e.three_letter_code ?? void 0
199
199
  };
200
200
  }
201
- function N(e) {
201
+ function G(e) {
202
202
  if (!(!e || !e.url))
203
203
  return {
204
204
  url: e.url
205
205
  };
206
206
  }
207
- function I(e) {
207
+ function N(e) {
208
208
  if (e)
209
209
  return {
210
210
  id: e.id,
@@ -213,7 +213,7 @@ function I(e) {
213
213
  shortName: e.short_name ?? void 0,
214
214
  threeLetterCode: e.three_letter_code ?? void 0,
215
215
  translations: e.translations.map(M),
216
- displayAsset: N(e.display_asset),
216
+ displayAsset: G(e.display_asset),
217
217
  slug: e.slug,
218
218
  providerRef: e.id
219
219
  };
@@ -227,11 +227,11 @@ function V(e) {
227
227
  shortName: e.short_name ?? void 0,
228
228
  threeLetterCode: e.three_letter_code ?? void 0,
229
229
  translations: e.translations.map(M),
230
- displayAsset: N(e.display_asset),
230
+ displayAsset: G(e.display_asset),
231
231
  slug: e.slug,
232
232
  tagScore: e.tag_score ?? void 0,
233
233
  sport: e.sport,
234
- country: I(e.country),
234
+ country: N(e.country),
235
235
  gender: e.gender,
236
236
  competitionIds: e.competition_ids,
237
237
  type: e.type,
@@ -249,11 +249,11 @@ function w(e) {
249
249
  shortName: e.short_name ?? void 0,
250
250
  threeLetterCode: e.three_letter_code ?? void 0,
251
251
  translations: e.translations.map(M),
252
- displayAsset: N(e.display_asset),
252
+ displayAsset: G(e.display_asset),
253
253
  slug: e.slug,
254
254
  tagScore: e.tag_score ?? void 0,
255
255
  sport: e.sport,
256
- country: I(e.country),
256
+ country: N(e.country),
257
257
  providerRef: e.id
258
258
  };
259
259
  }
@@ -266,11 +266,11 @@ function ge(e) {
266
266
  shortName: e.short_name ?? void 0,
267
267
  threeLetterCode: e.three_letter_code ?? void 0,
268
268
  translations: e.translations.map(M),
269
- displayAsset: N(e.display_asset),
269
+ displayAsset: G(e.display_asset),
270
270
  slug: e.slug,
271
271
  tagScore: e.tag_score ?? void 0,
272
272
  sport: e.sport,
273
- country: I(e.country),
273
+ country: N(e.country),
274
274
  gender: e.gender,
275
275
  providerRef: e.id
276
276
  };
@@ -284,11 +284,11 @@ function ye(e) {
284
284
  shortName: e.short_name ?? void 0,
285
285
  threeLetterCode: e.three_letter_code ?? void 0,
286
286
  translations: e.translations.map(M),
287
- displayAsset: N(e.display_asset),
287
+ displayAsset: G(e.display_asset),
288
288
  slug: e.slug,
289
289
  tagScore: e.tag_score ?? void 0,
290
290
  sport: e.sport,
291
- country: I(e.country),
291
+ country: N(e.country),
292
292
  gender: e.gender,
293
293
  birthdate: e.birthdate ?? void 0,
294
294
  position: e.position ?? void 0,
@@ -304,11 +304,11 @@ function he(e) {
304
304
  shortName: e.short_name ?? void 0,
305
305
  threeLetterCode: e.three_letter_code ?? void 0,
306
306
  translations: e.translations.map(M),
307
- displayAsset: N(e.display_asset),
307
+ displayAsset: G(e.display_asset),
308
308
  slug: e.slug,
309
309
  tagScore: e.tag_score ?? void 0,
310
310
  sport: e.sport,
311
- country: I(e.country),
311
+ country: N(e.country),
312
312
  gender: e.gender,
313
313
  birthdate: e.birthdate ?? void 0,
314
314
  providerRef: e.id
@@ -323,11 +323,11 @@ function Te(e) {
323
323
  shortName: e.short_name ?? void 0,
324
324
  threeLetterCode: e.three_letter_code ?? void 0,
325
325
  translations: e.translations.map(M),
326
- displayAsset: N(e.display_asset),
326
+ displayAsset: G(e.display_asset),
327
327
  slug: e.slug,
328
328
  tagScore: e.tag_score ?? void 0,
329
329
  sport: e.sport,
330
- country: I(e.country),
330
+ country: N(e.country),
331
331
  gender: e.gender,
332
332
  birthdate: e.birthdate ?? void 0,
333
333
  providerRef: e.id
@@ -342,11 +342,11 @@ function ve(e) {
342
342
  shortName: e.short_name ?? void 0,
343
343
  threeLetterCode: e.three_letter_code ?? void 0,
344
344
  translations: e.translations.map(M),
345
- displayAsset: N(e.display_asset),
345
+ displayAsset: G(e.display_asset),
346
346
  slug: e.slug,
347
347
  tagScore: e.tag_score ?? void 0,
348
348
  sport: e.sport,
349
- country: I(e.country),
349
+ country: N(e.country),
350
350
  city: e.city ? w(e.city) : void 0,
351
351
  providerRef: e.id
352
352
  };
@@ -360,11 +360,11 @@ function Se(e) {
360
360
  shortName: e.short_name ?? void 0,
361
361
  threeLetterCode: e.three_letter_code ?? void 0,
362
362
  translations: e.translations.map(M),
363
- displayAsset: N(e.display_asset),
363
+ displayAsset: G(e.display_asset),
364
364
  slug: e.slug,
365
365
  tagScore: e.tag_score ?? void 0,
366
366
  sport: e.sport,
367
- country: I(e.country),
367
+ country: N(e.country),
368
368
  gender: e.gender,
369
369
  type: e.type ?? void 0,
370
370
  region: e.region ?? void 0,
@@ -380,7 +380,7 @@ function _e(e) {
380
380
  shortName: e.short_name ?? void 0,
381
381
  threeLetterCode: e.three_letter_code ?? void 0,
382
382
  translations: e.translations.map(M),
383
- displayAsset: N(e.display_asset),
383
+ displayAsset: G(e.display_asset),
384
384
  slug: e.slug,
385
385
  tagScore: e.tag_score ?? void 0,
386
386
  sport: e.sport,
@@ -400,7 +400,7 @@ function Ce(e) {
400
400
  shortName: e.short_name ?? void 0,
401
401
  threeLetterCode: e.three_letter_code ?? void 0,
402
402
  translations: e.translations.map(M),
403
- displayAsset: N(e.display_asset),
403
+ displayAsset: G(e.display_asset),
404
404
  slug: e.slug,
405
405
  tagScore: e.tag_score ?? void 0,
406
406
  sport: e.sport,
@@ -453,7 +453,7 @@ async function mt(e = {}, t) {
453
453
  query: e.name
454
454
  };
455
455
  }
456
- const Oe = Z(ae);
456
+ const Oe = Z(re);
457
457
  function Fe(e, t) {
458
458
  return {
459
459
  teamId: e.id,
@@ -467,45 +467,19 @@ function Fe(e, t) {
467
467
  };
468
468
  }
469
469
  async function ft(e, t) {
470
- const o = t || F(), n = e.next ?? { revalidate: 600 }, s = {
471
- participant_ids: e.teamId,
472
- season_ids: e.seasonId,
473
- participant_type: "TEAM"
474
- };
475
- console.log("[getTeamSeasonStatistics] Fetching team statistics:", {
476
- path: "/statistics/aggregate",
477
- params: s,
478
- teamId: e.teamId,
479
- seasonId: e.seasonId
480
- });
481
- const i = await Oe.get({
470
+ const o = t || F(), n = e.next ?? { revalidate: 600 }, s = await Oe.get({
482
471
  path: "/statistics/aggregate",
483
- params: s,
472
+ params: {
473
+ participant_ids: e.teamId,
474
+ season_ids: e.seasonId,
475
+ participant_type: "TEAM"
476
+ },
484
477
  next: n,
485
478
  config: o
486
479
  });
487
- if (console.log("[getTeamSeasonStatistics] API response received:", {
488
- hasData: !!i.data,
489
- dataLength: i.data?.length ?? 0,
490
- rawResponse: i
491
- }), !i.data || i.data.length === 0)
492
- throw console.error("[getTeamSeasonStatistics] No statistics found:", {
493
- teamId: e.teamId,
494
- seasonId: e.seasonId,
495
- rawResponse: i
496
- }), new Error(`No statistics found for team ${e.teamId} in season ${e.seasonId}`);
497
- console.log("[getTeamSeasonStatistics] Transforming team statistics:", {
498
- teamId: i.data[0].id,
499
- teamName: i.data[0].name,
500
- statisticsCount: i.data[0].statistics?.length ?? 0
501
- });
502
- const a = Fe(i.data[0], e.seasonId);
503
- return console.log("[getTeamSeasonStatistics] Successfully transformed team statistics:", {
504
- teamId: a.teamId,
505
- teamName: a.teamName,
506
- seasonId: a.seasonId,
507
- statisticsCount: a.statistics.length
508
- }), a;
480
+ if (!s.data || s.data.length === 0)
481
+ throw new Error(`No statistics found for team ${e.teamId} in season ${e.seasonId}`);
482
+ return Fe(s.data[0], e.seasonId);
509
483
  }
510
484
  function Me(e) {
511
485
  const t = e.replace(/\/$/, "");
@@ -521,11 +495,11 @@ function Me(e) {
521
495
  );
522
496
  if (!i.apiKey || !i.clientId)
523
497
  throw new Error("Fans United configuration requires both 'apiKey' and 'clientId'");
524
- const a = new URL(o(n.path));
525
- if (a.searchParams.set("key", i.apiKey), a.searchParams.set("client_id", i.clientId), n.params)
526
- for (const [l, u] of Object.entries(n.params))
527
- u !== void 0 && (Array.isArray(u) ? u.length > 0 && a.searchParams.set(l, u.join(",")) : a.searchParams.set(l, u));
528
- const d = await fetch(a.toString(), {
498
+ const r = new URL(o(n.path));
499
+ if (r.searchParams.set("key", i.apiKey), r.searchParams.set("client_id", i.clientId), n.params)
500
+ for (const [d, u] of Object.entries(n.params))
501
+ u !== void 0 && (Array.isArray(u) ? u.length > 0 && r.searchParams.set(d, u.join(",")) : r.searchParams.set(d, u));
502
+ const l = await fetch(r.toString(), {
529
503
  method: "GET",
530
504
  headers: {
531
505
  Accept: "application/json",
@@ -537,20 +511,25 @@ function Me(e) {
537
511
  // Next.js cache options for ISR/on-demand revalidation
538
512
  ...n.next && { next: n.next }
539
513
  });
540
- if (!d.ok) {
541
- let l = `Fans United API error: ${d.status} ${d.statusText}`;
514
+ if (!l.ok) {
515
+ let d = `Fans United API error: ${l.status} ${l.statusText}`;
542
516
  try {
543
- const u = await d.text();
544
- u && (l += ` - ${u}`);
545
- } catch {
517
+ const u = await l.text();
518
+ u && (d += ` - ${u}`);
519
+ } catch (u) {
520
+ console.error("[Fans United HTTP] Failed to read error response body:", {
521
+ error: u instanceof Error ? u.message : String(u),
522
+ status: l.status,
523
+ statusText: l.statusText
524
+ });
546
525
  }
547
- throw new Error(l);
526
+ throw new Error(d);
548
527
  }
549
- return d.json();
528
+ return l.json();
550
529
  }
551
530
  };
552
531
  }
553
- const Ne = "https://football.fansunitedapi.com", E = Me(Ne);
532
+ const Ge = "https://football.fansunitedapi.com", I = Me(Ge);
554
533
  function Re(e) {
555
534
  return {
556
535
  id: String(e.id),
@@ -564,7 +543,7 @@ function Re(e) {
564
543
  ]
565
544
  };
566
545
  }
567
- function Ge(e) {
546
+ function De(e) {
568
547
  const t = {
569
548
  id: String(e.id),
570
549
  name: e.name,
@@ -599,21 +578,21 @@ function Ge(e) {
599
578
  status: e.current_season.active ? "ACTIVE" : "INACTIVE"
600
579
  }), t;
601
580
  }
602
- function De(e) {
603
- return e.map(Ge);
581
+ function Ee(e) {
582
+ return e.map(De);
604
583
  }
605
584
  async function pt(e, t) {
606
585
  const o = {};
607
586
  e?.lang ? o.lang = e.lang : o.lang = "EN", e?.sortField && (o.sort_field = e.sortField), e?.sortOrder && (o.sort_order = e.sortOrder), e?.page !== void 0 && (o.page = String(e.page)), e?.perPage !== void 0 && (o.per_page = String(e.perPage)), e?.countryId !== void 0 && (o.country_id = String(e.countryId)), e?.active !== void 0 && (o.active = e.active ? "1" : "0");
608
- const n = await E.get({
587
+ const n = await I.get({
609
588
  path: "/v1/competitions",
610
589
  params: o,
611
590
  config: t,
612
591
  next: e?.next
613
592
  });
614
- return De(n.data);
593
+ return Ee(n.data);
615
594
  }
616
- function Ie(e) {
595
+ function Ne(e) {
617
596
  return {
618
597
  id: e.id,
619
598
  name: e.name,
@@ -629,13 +608,13 @@ function Ie(e) {
629
608
  ]
630
609
  };
631
610
  }
632
- function Ee(e) {
611
+ function Ie(e) {
633
612
  return {
634
613
  id: e.id,
635
614
  name: e.name,
636
615
  type: e.type?.toUpperCase() || "LEAGUE",
637
616
  gender: e.gender?.toUpperCase(),
638
- country: e.country ? Ie(e.country) : void 0,
617
+ country: e.country ? Ne(e.country) : void 0,
639
618
  assets: e.assets?.logo ? {
640
619
  logo: e.assets.logo
641
620
  } : void 0,
@@ -648,12 +627,12 @@ function Ee(e) {
648
627
  };
649
628
  }
650
629
  function Le(e) {
651
- return Ee(e.data);
630
+ return Ie(e.data);
652
631
  }
653
632
  async function gt(e, t, o) {
654
633
  const n = o || F(), s = {};
655
634
  t?.lang && (s.lang = t.lang);
656
- const i = await E.get({
635
+ const i = await I.get({
657
636
  path: `/v1/competitions/${e}`,
658
637
  params: s,
659
638
  next: t?.next,
@@ -709,7 +688,7 @@ function He(e) {
709
688
  async function yt(e, t, o) {
710
689
  const n = o || F(), s = {};
711
690
  t?.lang && (s.lang = t.lang);
712
- const i = await E.get({
691
+ const i = await I.get({
713
692
  path: `/v1/teams/${e}`,
714
693
  params: s,
715
694
  next: t?.next,
@@ -800,7 +779,7 @@ function Ue(e) {
800
779
  async function ht(e, t, o) {
801
780
  const n = o || F(), s = {};
802
781
  t?.lang && (s.lang = t.lang);
803
- const i = await E.get({
782
+ const i = await I.get({
804
783
  path: `/v1/players/${e}`,
805
784
  params: s,
806
785
  next: t?.next,
@@ -811,7 +790,7 @@ async function ht(e, t, o) {
811
790
  async function Tt(e, t) {
812
791
  const o = t || F(), n = {};
813
792
  e?.lang && (n.lang = e.lang), e?.playerIds && (n.player_ids = e.playerIds), e?.countryId && (n.country_id = e.countryId), e?.name && (n.name = e.name), e?.scope && (n.scope = e.scope), e?.limit !== void 0 && (n.limit = String(e.limit)), e?.page !== void 0 && (n.page = String(e.page)), e?.sortField && (n.sort_field = e.sortField), e?.sortOrder && (n.sort_order = e.sortOrder);
814
- const s = await E.get({
793
+ const s = await I.get({
815
794
  path: "/v1/players",
816
795
  params: n,
817
796
  next: e?.next,
@@ -949,7 +928,7 @@ function Ye(e) {
949
928
  async function vt(e, t, o) {
950
929
  const n = o || F(), s = {};
951
930
  t?.lang && (s.lang = t.lang);
952
- const i = await E.get({
931
+ const i = await I.get({
953
932
  path: `/v1/matches/${e}`,
954
933
  params: s,
955
934
  next: t?.next,
@@ -960,7 +939,7 @@ async function vt(e, t, o) {
960
939
  async function St(e, t) {
961
940
  const o = t || F(), n = {};
962
941
  e?.lang && (n.lang = e.lang), e?.competitions && (n.competitions = e.competitions), e?.countries && (n.countries = e.countries), e?.fromDate && (n.from_date = e.fromDate), e?.toDate && (n.to_date = e.toDate), e?.matches && (n.matches = e.matches), e?.teams && (n.teams = e.teams), e?.status && (n.status = e.status), e?.limit !== void 0 && (n.limit = String(e.limit)), e?.page !== void 0 && (n.page = String(e.page)), e?.sortField && (n.sort_field = e.sortField), e?.sortOrder && (n.sort_order = e.sortOrder), e?.showDeleted !== void 0 && (n.show_deleted = e.showDeleted ? "true" : "false");
963
- const s = await E.get({
942
+ const s = await I.get({
964
943
  path: "/v1/matches",
965
944
  params: n,
966
945
  next: e?.next,
@@ -1083,8 +1062,8 @@ async function _t(e, t) {
1083
1062
  return [];
1084
1063
  const o = t || F(), n = {
1085
1064
  q: e.query.trim()
1086
- }, i = (e.entityTypes && e.entityTypes.length > 0 ? e.entityTypes : ["competition", "team", "player"]).map((d) => {
1087
- switch (d) {
1065
+ }, i = (e.entityTypes && e.entityTypes.length > 0 ? e.entityTypes : ["competition", "team", "player"]).map((l) => {
1066
+ switch (l) {
1088
1067
  case "team":
1089
1068
  return "teams";
1090
1069
  case "player":
@@ -1092,49 +1071,49 @@ async function _t(e, t) {
1092
1071
  case "competition":
1093
1072
  return "competitions";
1094
1073
  default:
1095
- return d;
1074
+ return l;
1096
1075
  }
1097
1076
  });
1098
1077
  n.entities = i.join(","), e.lang && (n.lang = e.lang), e.limit && (n.limit = String(e.limit));
1099
- const a = await E.get({
1078
+ const r = await I.get({
1100
1079
  path: "/v1/search",
1101
1080
  params: n,
1102
1081
  next: e.next,
1103
1082
  config: o
1104
- }), r = [];
1105
- return a.data && (a.data.competitions && a.data.competitions.forEach((d) => {
1106
- const l = j({ ...d, entity_type: "competition" });
1107
- l && r.push(l);
1108
- }), a.data.teams && a.data.teams.forEach((d) => {
1109
- const l = j({ ...d, entity_type: "team" });
1110
- l && r.push(l);
1111
- }), a.data.players && a.data.players.forEach((d) => {
1112
- const l = j({ ...d, entity_type: "player" });
1113
- l && r.push(l);
1114
- })), r;
1083
+ }), a = [];
1084
+ return r.data && (r.data.competitions && r.data.competitions.forEach((l) => {
1085
+ const d = j({ ...l, entity_type: "competition" });
1086
+ d && a.push(d);
1087
+ }), r.data.teams && r.data.teams.forEach((l) => {
1088
+ const d = j({ ...l, entity_type: "team" });
1089
+ d && a.push(d);
1090
+ }), r.data.players && r.data.players.forEach((l) => {
1091
+ const d = j({ ...l, entity_type: "player" });
1092
+ d && a.push(d);
1093
+ })), a;
1115
1094
  }
1116
1095
  function Ct(e) {
1117
1096
  return !e.seasons || e.seasons.length === 0 ? void 0 : e.seasons.find((o) => o.active) ?? e.seasons[0];
1118
1097
  }
1119
1098
  function At(e, t) {
1120
1099
  const o = /* @__PURE__ */ new Date(), n = t.filter((s) => {
1121
- const i = s.competitorOne.id === e || s.competitorTwo.id === e, a = s.status.type === "NOT_STARTED", r = new Date(s.timing.kickoffTime) >= o;
1122
- return i && a && r;
1100
+ const i = s.competitorOne.id === e || s.competitorTwo.id === e, r = s.status.type === "NOT_STARTED", a = new Date(s.timing.kickoffTime) >= o;
1101
+ return i && r && a;
1123
1102
  });
1124
1103
  return n.sort((s, i) => new Date(s.timing.kickoffTime).getTime() - new Date(i.timing.kickoffTime).getTime()), n[0];
1125
1104
  }
1126
1105
  function Ot(e, t) {
1127
1106
  const o = /* @__PURE__ */ new Date(), n = t.filter((s) => {
1128
- const i = s.competitorOne.id === e || s.competitorTwo.id === e, a = s.status.type === "FINISHED", r = new Date(s.timing.kickoffTime) <= o;
1129
- return i && a && r;
1107
+ const i = s.competitorOne.id === e || s.competitorTwo.id === e, r = s.status.type === "FINISHED", a = new Date(s.timing.kickoffTime) <= o;
1108
+ return i && r && a;
1130
1109
  });
1131
1110
  return n.sort((s, i) => new Date(i.timing.kickoffTime).getTime() - new Date(s.timing.kickoffTime).getTime()), n[0];
1132
1111
  }
1133
1112
  function Ft(e, t) {
1134
1113
  const o = /* @__PURE__ */ new Date();
1135
1114
  return t.filter((s) => {
1136
- const i = s.competitorOne.id === e || s.competitorTwo.id === e, a = s.status.type === "NOT_STARTED" || s.status.type === "LIVE", r = new Date(s.timing.kickoffTime) >= o || s.status.type === "LIVE";
1137
- return i && a && r;
1115
+ const i = s.competitorOne.id === e || s.competitorTwo.id === e, r = s.status.type === "NOT_STARTED" || s.status.type === "LIVE", a = new Date(s.timing.kickoffTime) >= o || s.status.type === "LIVE";
1116
+ return i && r && a;
1138
1117
  }).sort(
1139
1118
  (s, i) => new Date(s.timing.kickoffTime).getTime() - new Date(i.timing.kickoffTime).getTime()
1140
1119
  );
@@ -1142,35 +1121,35 @@ function Ft(e, t) {
1142
1121
  function Mt(e, t) {
1143
1122
  const o = /* @__PURE__ */ new Date();
1144
1123
  return t.filter((s) => {
1145
- const i = s.competitorOne.id === e || s.competitorTwo.id === e, a = s.status.type === "FINISHED", r = new Date(s.timing.kickoffTime) <= o;
1146
- return i && a && r;
1124
+ const i = s.competitorOne.id === e || s.competitorTwo.id === e, r = s.status.type === "FINISHED", a = new Date(s.timing.kickoffTime) <= o;
1125
+ return i && r && a;
1147
1126
  }).sort(
1148
1127
  (s, i) => new Date(i.timing.kickoffTime).getTime() - new Date(s.timing.kickoffTime).getTime()
1149
1128
  );
1150
1129
  }
1151
- function Nt(e, t, o) {
1152
- const n = o.filter((a) => a.status.type === "FINISHED"), s = o.filter(
1153
- (a) => a.status.type === "NOT_STARTED" || a.status.type === "POSTPONED"
1154
- ), i = t.entries.map((a) => {
1155
- const r = a.competitor.id, d = n.filter(
1156
- (m) => m.competitorOne.id === e && m.competitorTwo.id === r || m.competitorOne.id === r && m.competitorTwo.id === e
1157
- ), l = s.filter(
1158
- (m) => m.competitorOne.id === e && m.competitorTwo.id === r || m.competitorOne.id === r && m.competitorTwo.id === e
1130
+ function Gt(e, t, o) {
1131
+ const n = o.filter((r) => r.status.type === "FINISHED"), s = o.filter(
1132
+ (r) => r.status.type === "NOT_STARTED" || r.status.type === "POSTPONED"
1133
+ ), i = t.entries.map((r) => {
1134
+ const a = r.competitor.id, l = n.filter(
1135
+ (m) => m.competitorOne.id === e && m.competitorTwo.id === a || m.competitorOne.id === a && m.competitorTwo.id === e
1136
+ ), d = s.filter(
1137
+ (m) => m.competitorOne.id === e && m.competitorTwo.id === a || m.competitorOne.id === a && m.competitorTwo.id === e
1159
1138
  );
1160
1139
  let u, c;
1161
- return d.forEach((m) => {
1140
+ return l.forEach((m) => {
1162
1141
  const p = m.competitorOne.id === e, g = parseInt(m.score?.competitorOne ?? "0"), h = parseInt(m.score?.competitorTwo ?? "0"), R = p ? g : h, S = p ? h : g;
1163
1142
  let A;
1164
1143
  R > S ? A = "W" : R === S ? A = "D" : A = "L";
1165
- const G = {
1144
+ const D = {
1166
1145
  result: A,
1167
1146
  score: `${g} - ${h}`,
1168
1147
  date: m.timing.kickoffTime,
1169
1148
  matchId: m.id,
1170
1149
  isUpcoming: !1
1171
1150
  };
1172
- p ? u = G : c = G;
1173
- }), l.forEach((m) => {
1151
+ p ? u = D : c = D;
1152
+ }), d.forEach((m) => {
1174
1153
  const p = m.competitorOne.id === e;
1175
1154
  p && !u ? u = {
1176
1155
  date: m.timing.kickoffTime,
@@ -1182,13 +1161,13 @@ function Nt(e, t, o) {
1182
1161
  isUpcoming: !0
1183
1162
  });
1184
1163
  }), {
1185
- rank: a.rank,
1186
- teamId: a.competitor.id,
1187
- teamName: a.competitor.name,
1188
- teamShortName: a.competitor.shortName,
1189
- teamLogo: a.competitor.logo,
1190
- gamesPlayed: a.stats.played ?? 0,
1191
- points: a.stats.points ?? 0,
1164
+ rank: r.rank,
1165
+ teamId: r.competitor.id,
1166
+ teamName: r.competitor.name,
1167
+ teamShortName: r.competitor.shortName,
1168
+ teamLogo: r.competitor.logo,
1169
+ gamesPlayed: r.stats.played ?? 0,
1170
+ points: r.stats.points ?? 0,
1192
1171
  homeResult: u,
1193
1172
  awayResult: c
1194
1173
  };
@@ -1203,44 +1182,44 @@ function Rt(e, t = 10) {
1203
1182
  const s = o.seasonStatistics?.goals ?? 0, i = n.seasonStatistics?.goals ?? 0;
1204
1183
  if (i !== s)
1205
1184
  return i - s;
1206
- const a = o.seasonStatistics?.assists ?? 0;
1207
- return (n.seasonStatistics?.assists ?? 0) - a;
1185
+ const r = o.seasonStatistics?.assists ?? 0;
1186
+ return (n.seasonStatistics?.assists ?? 0) - r;
1208
1187
  }).slice(0, t);
1209
1188
  }
1210
- function Gt(e, t = 10) {
1189
+ function Dt(e, t = 10) {
1211
1190
  return e.players.filter((o) => (o.seasonStatistics?.assists ?? 0) > 0).sort((o, n) => {
1212
1191
  const s = o.seasonStatistics?.assists ?? 0, i = n.seasonStatistics?.assists ?? 0;
1213
1192
  if (i !== s)
1214
1193
  return i - s;
1215
- const a = o.seasonStatistics?.goals ?? 0;
1216
- return (n.seasonStatistics?.goals ?? 0) - a;
1194
+ const r = o.seasonStatistics?.goals ?? 0;
1195
+ return (n.seasonStatistics?.goals ?? 0) - r;
1217
1196
  }).slice(0, t);
1218
1197
  }
1219
- function Dt(e, t = 10) {
1198
+ function Et(e, t = 10) {
1220
1199
  return e.players.filter((o) => (o.seasonStatistics?.appearances ?? 0) > 0).sort((o, n) => {
1221
1200
  const s = o.seasonStatistics?.appearances ?? 0, i = n.seasonStatistics?.appearances ?? 0;
1222
1201
  if (i !== s)
1223
1202
  return i - s;
1224
- const a = o.seasonStatistics?.minutes ?? 0;
1225
- return (n.seasonStatistics?.minutes ?? 0) - a;
1203
+ const r = o.seasonStatistics?.minutes ?? 0;
1204
+ return (n.seasonStatistics?.minutes ?? 0) - r;
1226
1205
  }).slice(0, t);
1227
1206
  }
1228
- function It(e, t = 10) {
1207
+ function Nt(e, t = 10) {
1229
1208
  return e.players.filter((o) => (o.seasonStatistics?.minutes ?? 0) > 0).sort((o, n) => {
1230
1209
  const s = o.seasonStatistics?.minutes ?? 0, i = n.seasonStatistics?.minutes ?? 0;
1231
1210
  if (i !== s)
1232
1211
  return i - s;
1233
- const a = o.seasonStatistics?.appearances ?? 0;
1234
- return (n.seasonStatistics?.appearances ?? 0) - a;
1212
+ const r = o.seasonStatistics?.appearances ?? 0;
1213
+ return (n.seasonStatistics?.appearances ?? 0) - r;
1235
1214
  }).slice(0, t);
1236
1215
  }
1237
- function Et(e, t = 10) {
1216
+ function It(e, t = 10) {
1238
1217
  return e.players.filter((o) => (o.seasonStatistics?.cleansheets ?? 0) > 0).sort((o, n) => {
1239
1218
  const s = o.seasonStatistics?.cleansheets ?? 0, i = n.seasonStatistics?.cleansheets ?? 0;
1240
1219
  if (i !== s)
1241
1220
  return i - s;
1242
- const a = o.seasonStatistics?.appearances ?? 0;
1243
- return (n.seasonStatistics?.appearances ?? 0) - a;
1221
+ const r = o.seasonStatistics?.appearances ?? 0;
1222
+ return (n.seasonStatistics?.appearances ?? 0) - r;
1244
1223
  }).slice(0, t);
1245
1224
  }
1246
1225
  function Lt(e, t = 10) {
@@ -1248,8 +1227,8 @@ function Lt(e, t = 10) {
1248
1227
  const n = o.seasonStatistics?.yellowCards ?? 0, s = o.seasonStatistics?.redCards ?? 0;
1249
1228
  return n + s > 0;
1250
1229
  }).sort((o, n) => {
1251
- const s = o.seasonStatistics?.yellowCards ?? 0, i = o.seasonStatistics?.redCards ?? 0, a = n.seasonStatistics?.yellowCards ?? 0, r = n.seasonStatistics?.redCards ?? 0, d = s + i * 3, l = a + r * 3;
1252
- return l !== d ? l - d : r !== i ? r - i : a - s;
1230
+ const s = o.seasonStatistics?.yellowCards ?? 0, i = o.seasonStatistics?.redCards ?? 0, r = n.seasonStatistics?.yellowCards ?? 0, a = n.seasonStatistics?.redCards ?? 0, l = s + i * 3, d = r + a * 3;
1231
+ return d !== l ? d - l : a !== i ? a - i : r - s;
1253
1232
  }).slice(0, t);
1254
1233
  }
1255
1234
  function b(e) {
@@ -1270,8 +1249,8 @@ function b(e) {
1270
1249
  redCards: 0,
1271
1250
  appearances: 0
1272
1251
  });
1273
- const a = t.get(i);
1274
- o.has(i) || o.set(i, /* @__PURE__ */ new Set()), o.get(i).add(n.id), (s.type === "GOAL" || s.type === "PENALTY_GOAL") && (a.goals = (a.goals ?? 0) + 1), s.type === "YELLOW_CARD" && (a.yellowCards = (a.yellowCards ?? 0) + 1), (s.type === "RED_CARD" || s.type === "YELLOW_RED_CARD") && (a.redCards = (a.redCards ?? 0) + 1);
1252
+ const r = t.get(i);
1253
+ o.has(i) || o.set(i, /* @__PURE__ */ new Set()), o.get(i).add(n.id), (s.type === "GOAL" || s.type === "PENALTY_GOAL") && (r.goals = (r.goals ?? 0) + 1), s.type === "YELLOW_CARD" && (r.yellowCards = (r.yellowCards ?? 0) + 1), (s.type === "RED_CARD" || s.type === "YELLOW_RED_CARD") && (r.redCards = (r.redCards ?? 0) + 1);
1275
1254
  }
1276
1255
  if (s.secondaryPlayer && (s.type === "GOAL" || s.type === "PENALTY_GOAL")) {
1277
1256
  const i = s.secondaryPlayer.id;
@@ -1287,8 +1266,8 @@ function b(e) {
1287
1266
  redCards: 0,
1288
1267
  appearances: 0
1289
1268
  });
1290
- const a = t.get(i);
1291
- a.assists = (a.assists ?? 0) + 1, o.has(i) || o.set(i, /* @__PURE__ */ new Set()), o.get(i).add(n.id);
1269
+ const r = t.get(i);
1270
+ r.assists = (r.assists ?? 0) + 1, o.has(i) || o.set(i, /* @__PURE__ */ new Set()), o.get(i).add(n.id);
1292
1271
  }
1293
1272
  });
1294
1273
  }), o.forEach((n, s) => {
@@ -1305,32 +1284,32 @@ function k(e) {
1305
1284
  function Qe(e, t = 10) {
1306
1285
  const o = b(e);
1307
1286
  return k(o).filter((s) => (s.goals ?? 0) > 0).sort((s, i) => {
1308
- const a = s.goals ?? 0, r = i.goals ?? 0;
1309
- if (r !== a)
1310
- return r - a;
1311
- const d = s.assists ?? 0;
1312
- return (i.assists ?? 0) - d;
1287
+ const r = s.goals ?? 0, a = i.goals ?? 0;
1288
+ if (a !== r)
1289
+ return a - r;
1290
+ const l = s.assists ?? 0;
1291
+ return (i.assists ?? 0) - l;
1313
1292
  }).slice(0, t);
1314
1293
  }
1315
1294
  function Xe(e, t = 10) {
1316
1295
  const o = b(e);
1317
1296
  return k(o).filter((s) => (s.assists ?? 0) > 0).sort((s, i) => {
1318
- const a = s.assists ?? 0, r = i.assists ?? 0;
1319
- if (r !== a)
1320
- return r - a;
1321
- const d = s.goals ?? 0;
1322
- return (i.goals ?? 0) - d;
1297
+ const r = s.assists ?? 0, a = i.assists ?? 0;
1298
+ if (a !== r)
1299
+ return a - r;
1300
+ const l = s.goals ?? 0;
1301
+ return (i.goals ?? 0) - l;
1323
1302
  }).slice(0, t);
1324
1303
  }
1325
1304
  function Ze(e, t = 10) {
1326
1305
  const o = b(e);
1327
1306
  return k(o).filter((s) => (s.totalCards ?? 0) > 0).sort((s, i) => {
1328
- const a = (s.yellowCards ?? 0) + (s.redCards ?? 0) * 3, r = (i.yellowCards ?? 0) + (i.redCards ?? 0) * 3;
1329
- if (r !== a)
1330
- return r - a;
1331
- const d = s.redCards ?? 0, l = i.redCards ?? 0;
1332
- if (l !== d)
1333
- return l - d;
1307
+ const r = (s.yellowCards ?? 0) + (s.redCards ?? 0) * 3, a = (i.yellowCards ?? 0) + (i.redCards ?? 0) * 3;
1308
+ if (a !== r)
1309
+ return a - r;
1310
+ const l = s.redCards ?? 0, d = i.redCards ?? 0;
1311
+ if (d !== l)
1312
+ return d - l;
1334
1313
  const u = s.yellowCards ?? 0;
1335
1314
  return (i.yellowCards ?? 0) - u;
1336
1315
  }).slice(0, t);
@@ -1338,12 +1317,12 @@ function Ze(e, t = 10) {
1338
1317
  function we(e, t = 10) {
1339
1318
  const o = b(e);
1340
1319
  return k(o).filter((s) => (s.goals ?? 0) + (s.assists ?? 0) > 0).sort((s, i) => {
1341
- const a = (s.goals ?? 0) + (s.assists ?? 0), r = (i.goals ?? 0) + (i.assists ?? 0);
1342
- if (r !== a)
1343
- return r - a;
1344
- const d = s.goals ?? 0, l = i.goals ?? 0;
1345
- if (l !== d)
1346
- return l - d;
1320
+ const r = (s.goals ?? 0) + (s.assists ?? 0), a = (i.goals ?? 0) + (i.assists ?? 0);
1321
+ if (a !== r)
1322
+ return a - r;
1323
+ const l = s.goals ?? 0, d = i.goals ?? 0;
1324
+ if (d !== l)
1325
+ return d - l;
1347
1326
  const u = s.assists ?? 0;
1348
1327
  return (i.assists ?? 0) - u;
1349
1328
  }).slice(0, t);
@@ -1351,11 +1330,11 @@ function we(e, t = 10) {
1351
1330
  function et(e) {
1352
1331
  const t = b(e);
1353
1332
  return k(t).sort((n, s) => {
1354
- const i = n.appearances ?? 0, a = s.appearances ?? 0;
1355
- if (a !== i)
1356
- return a - i;
1357
- const r = (n.goals ?? 0) + (n.assists ?? 0);
1358
- return (s.goals ?? 0) + (s.assists ?? 0) - r;
1333
+ const i = n.appearances ?? 0, r = s.appearances ?? 0;
1334
+ if (r !== i)
1335
+ return r - i;
1336
+ const a = (n.goals ?? 0) + (n.assists ?? 0);
1337
+ return (s.goals ?? 0) + (s.assists ?? 0) - a;
1359
1338
  });
1360
1339
  }
1361
1340
  function Pt(e, t = 10) {
@@ -1406,12 +1385,12 @@ function qt(e) {
1406
1385
  }
1407
1386
  function nt(e, t, o) {
1408
1387
  if (e.status?.type !== "FINISHED" || !e.score) return null;
1409
- const n = parseInt(e.score.competitorOne || "0"), s = parseInt(e.score.competitorTwo || "0"), i = o ? n : s, a = o ? s : n;
1410
- let r = null, d = null;
1411
- const l = e.score.breakdown?.halfTime;
1412
- if (l) {
1413
- const p = parseInt(l.competitorOne || "0"), g = parseInt(l.competitorTwo || "0");
1414
- r = o ? p : g, d = o ? g : p;
1388
+ const n = parseInt(e.score.competitorOne || "0"), s = parseInt(e.score.competitorTwo || "0"), i = o ? n : s, r = o ? s : n;
1389
+ let a = null, l = null;
1390
+ const d = e.score.breakdown?.halfTime;
1391
+ if (d) {
1392
+ const p = parseInt(d.competitorOne || "0"), g = parseInt(d.competitorTwo || "0");
1393
+ a = o ? p : g, l = o ? g : p;
1415
1394
  }
1416
1395
  const u = e.statistics;
1417
1396
  let c = null, m = null;
@@ -1421,14 +1400,14 @@ function nt(e, t, o) {
1421
1400
  }
1422
1401
  return {
1423
1402
  goalsFor: i,
1424
- goalsAgainst: a,
1425
- halfTimeGoalsFor: r,
1426
- halfTimeGoalsAgainst: d,
1403
+ goalsAgainst: r,
1404
+ halfTimeGoalsFor: a,
1405
+ halfTimeGoalsAgainst: l,
1427
1406
  cornersFor: c,
1428
1407
  cornersAgainst: m,
1429
- isWin: i > a,
1430
- isDraw: i === a,
1431
- isLoss: i < a
1408
+ isWin: i > r,
1409
+ isDraw: i === r,
1410
+ isLoss: i < r
1432
1411
  };
1433
1412
  }
1434
1413
  function z(e, t) {
@@ -1457,35 +1436,35 @@ function zt(e, t, o) {
1457
1436
  const c = u.competitorOne.id === t || u.competitorTwo.id === t, m = u.competitorOne.id === o || u.competitorTwo.id === o;
1458
1437
  return c && m;
1459
1438
  });
1460
- let s = 0, i = 0, a = 0, r = 0, d = 0;
1439
+ let s = 0, i = 0, r = 0, a = 0, l = 0;
1461
1440
  n.forEach((u) => {
1462
1441
  const c = parseInt(u.score?.competitorOne || "0"), m = parseInt(u.score?.competitorTwo || "0"), p = u.competitorOne.id === t, g = p ? c : m, h = p ? m : c;
1463
- r += g, d += h, g > h ? s++ : h > g ? i++ : a++;
1442
+ a += g, l += h, g > h ? s++ : h > g ? i++ : r++;
1464
1443
  });
1465
- const l = n.length;
1444
+ const d = n.length;
1466
1445
  return {
1467
- totalMatches: l,
1446
+ totalMatches: d,
1468
1447
  homeTeamWins: s,
1469
1448
  awayTeamWins: i,
1470
- draws: a,
1471
- homeTeamGoals: r,
1472
- awayTeamGoals: d,
1473
- homeTeamWinPercentage: l > 0 ? s / l * 100 : 0,
1474
- awayTeamWinPercentage: l > 0 ? i / l * 100 : 0,
1475
- drawPercentage: l > 0 ? a / l * 100 : 0,
1476
- homeTeamAvgGoals: l > 0 ? r / l : 0,
1477
- awayTeamAvgGoals: l > 0 ? d / l : 0
1449
+ draws: r,
1450
+ homeTeamGoals: a,
1451
+ awayTeamGoals: l,
1452
+ homeTeamWinPercentage: d > 0 ? s / d * 100 : 0,
1453
+ awayTeamWinPercentage: d > 0 ? i / d * 100 : 0,
1454
+ drawPercentage: d > 0 ? r / d * 100 : 0,
1455
+ homeTeamAvgGoals: d > 0 ? a / d : 0,
1456
+ awayTeamAvgGoals: d > 0 ? l / d : 0
1478
1457
  };
1479
1458
  }
1480
1459
  function Jt(e, t, o, n = 5) {
1481
1460
  return e.filter((i) => {
1482
1461
  if (i.status?.type !== "FINISHED" || !i.score) return !1;
1483
- const a = i.competitorOne.id === t || i.competitorTwo.id === t, r = i.competitorOne.id === o || i.competitorTwo.id === o;
1484
- return a && r;
1485
- }).sort((i, a) => new Date(a.timing.kickoffTime).getTime() - new Date(i.timing.kickoffTime).getTime()).slice(0, n).map((i) => {
1486
- const a = parseInt(i.score?.competitorOne || "0"), r = parseInt(i.score?.competitorTwo || "0"), d = i.competitorOne.id === t, l = d ? a : r, u = d ? r : a;
1462
+ const r = i.competitorOne.id === t || i.competitorTwo.id === t, a = i.competitorOne.id === o || i.competitorTwo.id === o;
1463
+ return r && a;
1464
+ }).sort((i, r) => new Date(r.timing.kickoffTime).getTime() - new Date(i.timing.kickoffTime).getTime()).slice(0, n).map((i) => {
1465
+ const r = parseInt(i.score?.competitorOne || "0"), a = parseInt(i.score?.competitorTwo || "0"), l = i.competitorOne.id === t, d = l ? r : a, u = l ? a : r;
1487
1466
  let c;
1488
- return l > u ? c = "home" : u > l ? c = "away" : c = "draw", {
1467
+ return d > u ? c = "home" : u > d ? c = "away" : c = "draw", {
1489
1468
  id: i.id,
1490
1469
  date: new Date(i.timing.kickoffTime).toLocaleDateString("en-GB", {
1491
1470
  day: "numeric",
@@ -1496,8 +1475,8 @@ function Jt(e, t, o, n = 5) {
1496
1475
  awayTeamName: i.competitorTwo.name,
1497
1476
  homeTeamLogo: i.competitorOne.assets?.logo,
1498
1477
  awayTeamLogo: i.competitorTwo.assets?.logo,
1499
- homeScore: a,
1500
- awayScore: r,
1478
+ homeScore: r,
1479
+ awayScore: a,
1501
1480
  venue: i.venue?.name,
1502
1481
  winner: c
1503
1482
  };
@@ -1515,28 +1494,28 @@ function it(e, t, o) {
1515
1494
  function Q(e, t, o, n) {
1516
1495
  let s = 0;
1517
1496
  for (const i of e) {
1518
- const a = i.competitorOne.id === t, r = i.competitorTwo.id === t;
1519
- if (!a && !r || o === "home" && !a || o === "away" && !r || i.status?.type !== "FINISHED") continue;
1520
- const d = i.mainEvents;
1521
- if (!d || !Array.isArray(d)) continue;
1522
- const l = d.filter((g) => g.type && ot.includes(g.type)).sort((g, h) => {
1497
+ const r = i.competitorOne.id === t, a = i.competitorTwo.id === t;
1498
+ if (!r && !a || o === "home" && !r || o === "away" && !a || i.status?.type !== "FINISHED") continue;
1499
+ const l = i.mainEvents;
1500
+ if (!l || !Array.isArray(l)) continue;
1501
+ const d = l.filter((g) => g.type && ot.includes(g.type)).sort((g, h) => {
1523
1502
  const R = g.minute ?? 0, S = h.minute ?? 0;
1524
1503
  return R !== S ? R - S : (g.injuryMinute ?? 0) - (h.injuryMinute ?? 0);
1525
1504
  });
1526
- if (l.length === 0) continue;
1527
- const u = l[0], c = a ? "ONE" : "TWO", m = u.type === "OWN_GOAL";
1505
+ if (d.length === 0) continue;
1506
+ const u = d[0], c = r ? "ONE" : "TWO", m = u.type === "OWN_GOAL";
1528
1507
  let p;
1529
1508
  m ? p = u.competitorPosition !== c : p = u.competitorPosition === c, (n === "scored" && p || n === "conceded" && !p) && s++;
1530
1509
  }
1531
1510
  return s;
1532
1511
  }
1533
- function at(e, t, o) {
1512
+ function rt(e, t, o) {
1534
1513
  let n = 0;
1535
1514
  for (const s of e) {
1536
- const i = s.competitorOne.id === t, a = s.competitorTwo.id === t;
1537
- if (!i && !a || o === "home" && !i || o === "away" && !a || s.status?.type !== "FINISHED") continue;
1538
- const r = s.mainEvents;
1539
- r && Array.isArray(r) && n++;
1515
+ const i = s.competitorOne.id === t, r = s.competitorTwo.id === t;
1516
+ if (!i && !r || o === "home" && !i || o === "away" && !r || s.status?.type !== "FINISHED") continue;
1517
+ const a = s.mainEvents;
1518
+ a && Array.isArray(a) && n++;
1540
1519
  }
1541
1520
  return n;
1542
1521
  }
@@ -1562,98 +1541,98 @@ function Qt(e, t, o) {
1562
1541
  avgCornersFor: 0,
1563
1542
  avgCornersAgainst: 0
1564
1543
  };
1565
- const i = n.reduce((f, v) => f + v.goalsFor, 0), a = n.reduce((f, v) => f + v.goalsAgainst, 0), r = n.filter((f) => f.goalsAgainst === 0).length, d = n.filter((f) => f.isWin && f.goalsAgainst === 0).length, l = n.filter((f) => f.goalsFor > 0).length, u = n.filter((f) => f.goalsFor === 0).length, c = n.filter((f) => f.isLoss && f.goalsFor === 0).length, m = n.filter((f) => f.goalsAgainst > 0).length, p = n.filter((f) => f.halfTimeGoalsFor !== null), g = p.length, h = p.filter((f) => {
1544
+ const i = n.reduce((f, v) => f + v.goalsFor, 0), r = n.reduce((f, v) => f + v.goalsAgainst, 0), a = n.filter((f) => f.goalsAgainst === 0).length, l = n.filter((f) => f.isWin && f.goalsAgainst === 0).length, d = n.filter((f) => f.goalsFor > 0).length, u = n.filter((f) => f.goalsFor === 0).length, c = n.filter((f) => f.isLoss && f.goalsFor === 0).length, m = n.filter((f) => f.goalsAgainst > 0).length, p = n.filter((f) => f.halfTimeGoalsFor !== null), g = p.length, h = p.filter((f) => {
1566
1545
  const v = f.halfTimeGoalsFor, H = f.goalsFor - v;
1567
1546
  return v > 0 && H > 0;
1568
- }).length, R = Q(e, t, o, "scored"), S = at(e, t, o), A = p.filter((f) => f.halfTimeGoalsFor > f.halfTimeGoalsAgainst).length, G = p.filter((f) => {
1547
+ }).length, R = Q(e, t, o, "scored"), S = rt(e, t, o), A = p.filter((f) => f.halfTimeGoalsFor > f.halfTimeGoalsAgainst).length, D = p.filter((f) => {
1569
1548
  const v = f.halfTimeGoalsAgainst, H = f.goalsAgainst - v;
1570
1549
  return v > 0 && H > 0;
1571
1550
  }).length, B = Q(e, t, o, "conceded"), $ = p.filter((f) => f.halfTimeGoalsAgainst > f.halfTimeGoalsFor).length, P = n.filter((f) => f.cornersFor !== null), U = P.reduce((f, v) => f + (v.cornersFor || 0), 0), x = P.reduce((f, v) => f + (v.cornersAgainst || 0), 0);
1572
1551
  return {
1573
1552
  played: s,
1574
1553
  goalsForPerMatch: W(i, s),
1575
- cleanSheets: O(r, s),
1576
- wonToNil: O(d, s),
1577
- scoringRate: O(l, s),
1554
+ cleanSheets: O(a, s),
1555
+ wonToNil: O(l, s),
1556
+ scoringRate: O(d, s),
1578
1557
  scoredInBothHalves: O(h, g),
1579
1558
  scoredFirst: O(R, S),
1580
1559
  leadingAtHalfTime: O(A, g),
1581
- goalsAgainstPerMatch: W(a, s),
1560
+ goalsAgainstPerMatch: W(r, s),
1582
1561
  failedToScore: O(u, s),
1583
1562
  lostToNil: O(c, s),
1584
1563
  concedingRate: O(m, s),
1585
- concededInBothHalves: O(G, g),
1564
+ concededInBothHalves: O(D, g),
1586
1565
  concededFirst: O(B, S),
1587
1566
  losingAtHalfTime: O($, g),
1588
1567
  avgCornersFor: W(U, P.length),
1589
1568
  avgCornersAgainst: W(x, P.length)
1590
1569
  };
1591
1570
  }
1592
- function rt(e, t) {
1571
+ function at(e, t) {
1593
1572
  return e.filter((o) => o.status?.type !== "FINISHED" ? !1 : o.competitorOne.id === t || o.competitorTwo.id === t).map((o) => {
1594
- const n = o.competitorOne.id === t, s = parseInt(o.score?.competitorOne || "0"), i = parseInt(o.score?.competitorTwo || "0"), a = s + i, r = o.periods;
1595
- let d = null;
1596
- if (r && Array.isArray(r)) {
1597
- const l = r.find(
1573
+ const n = o.competitorOne.id === t, s = parseInt(o.score?.competitorOne || "0"), i = parseInt(o.score?.competitorTwo || "0"), r = s + i, a = o.periods;
1574
+ let l = null;
1575
+ if (a && Array.isArray(a)) {
1576
+ const d = a.find(
1598
1577
  (u) => u.type === "FIRST_HALF" || u.type === "1ST_HALF"
1599
1578
  );
1600
- if (l?.score) {
1601
- const u = parseInt(l.score.competitorOne || "0"), c = parseInt(l.score.competitorTwo || "0");
1602
- d = u + c;
1579
+ if (d?.score) {
1580
+ const u = parseInt(d.score.competitorOne || "0"), c = parseInt(d.score.competitorTwo || "0");
1581
+ l = u + c;
1603
1582
  }
1604
1583
  }
1605
- return { totalGoals: a, halfTimeGoals: d, isHome: n };
1584
+ return { totalGoals: r, halfTimeGoals: l, isHome: n };
1606
1585
  });
1607
1586
  }
1608
1587
  function y(e, t) {
1609
1588
  return e.length === 0 ? 0 : e.filter((n) => n > t).length / e.length * 100;
1610
1589
  }
1611
1590
  function Xt(e, t) {
1612
- const o = rt(e, t), n = o.filter((c) => c.isHome), s = o.filter((c) => !c.isHome), i = o.map((c) => c.totalGoals), a = n.map((c) => c.totalGoals), r = s.map((c) => c.totalGoals), d = o.filter((c) => c.halfTimeGoals !== null).map((c) => c.halfTimeGoals), l = n.filter((c) => c.halfTimeGoals !== null).map((c) => c.halfTimeGoals), u = s.filter((c) => c.halfTimeGoals !== null).map((c) => c.halfTimeGoals);
1591
+ const o = at(e, t), n = o.filter((c) => c.isHome), s = o.filter((c) => !c.isHome), i = o.map((c) => c.totalGoals), r = n.map((c) => c.totalGoals), a = s.map((c) => c.totalGoals), l = o.filter((c) => c.halfTimeGoals !== null).map((c) => c.halfTimeGoals), d = n.filter((c) => c.halfTimeGoals !== null).map((c) => c.halfTimeGoals), u = s.filter((c) => c.halfTimeGoals !== null).map((c) => c.halfTimeGoals);
1613
1592
  return {
1614
1593
  over05: {
1615
- home: y(a, 0.5),
1594
+ home: y(r, 0.5),
1616
1595
  total: y(i, 0.5),
1617
- away: y(r, 0.5)
1596
+ away: y(a, 0.5)
1618
1597
  },
1619
1598
  over15: {
1620
- home: y(a, 1.5),
1599
+ home: y(r, 1.5),
1621
1600
  total: y(i, 1.5),
1622
- away: y(r, 1.5)
1601
+ away: y(a, 1.5)
1623
1602
  },
1624
1603
  over25: {
1625
- home: y(a, 2.5),
1604
+ home: y(r, 2.5),
1626
1605
  total: y(i, 2.5),
1627
- away: y(r, 2.5)
1606
+ away: y(a, 2.5)
1628
1607
  },
1629
1608
  over35: {
1630
- home: y(a, 3.5),
1609
+ home: y(r, 3.5),
1631
1610
  total: y(i, 3.5),
1632
- away: y(r, 3.5)
1611
+ away: y(a, 3.5)
1633
1612
  },
1634
1613
  over45: {
1635
- home: y(a, 4.5),
1614
+ home: y(r, 4.5),
1636
1615
  total: y(i, 4.5),
1637
- away: y(r, 4.5)
1616
+ away: y(a, 4.5)
1638
1617
  },
1639
1618
  over55: {
1640
- home: y(a, 5.5),
1619
+ home: y(r, 5.5),
1641
1620
  total: y(i, 5.5),
1642
- away: y(r, 5.5)
1621
+ away: y(a, 5.5)
1643
1622
  },
1644
1623
  over05HT: {
1645
- home: y(l, 0.5),
1646
- total: y(d, 0.5),
1624
+ home: y(d, 0.5),
1625
+ total: y(l, 0.5),
1647
1626
  away: y(u, 0.5)
1648
1627
  },
1649
1628
  over15HT: {
1650
- home: y(l, 1.5),
1651
- total: y(d, 1.5),
1629
+ home: y(d, 1.5),
1630
+ total: y(l, 1.5),
1652
1631
  away: y(u, 1.5)
1653
1632
  },
1654
1633
  over25HT: {
1655
- home: y(l, 2.5),
1656
- total: y(d, 2.5),
1634
+ home: y(d, 2.5),
1635
+ total: y(l, 2.5),
1657
1636
  away: y(u, 2.5)
1658
1637
  }
1659
1638
  };
@@ -1662,23 +1641,23 @@ function ct(e, t) {
1662
1641
  const o = e.competitorOne.id === t, n = e.competitorTwo.id === t;
1663
1642
  if (!o && !n || !e.score) return null;
1664
1643
  const s = parseInt(o ? e.score.competitorOne || "0" : e.score.competitorTwo || "0"), i = parseInt(o ? e.score.competitorTwo || "0" : e.score.competitorOne || "0");
1665
- let a;
1666
- return s > i ? a = "W" : s < i ? a = "L" : a = "D", {
1667
- result: { score: `${s}:${i}`, result: a, isHome: o },
1644
+ let r;
1645
+ return s > i ? r = "W" : s < i ? r = "L" : r = "D", {
1646
+ result: { score: `${s}:${i}`, result: r, isHome: o },
1668
1647
  isHome: o
1669
1648
  };
1670
1649
  }
1671
1650
  function Zt(e, t, o, n, s, i) {
1672
- const a = t?.entries.find((D) => D.competitor.id === e), r = o?.entries.find((D) => D.competitor.id === e), d = n?.entries.find((D) => D.competitor.id === e), l = s?.entries.find((D) => D.competitor.id === e), u = i?.entries.find((D) => D.competitor.id === e);
1673
- if (!a) return null;
1674
- const c = r?.stats?.goalsFor ?? 0, m = d?.stats?.goalsFor ?? 0, p = a?.stats?.goalsFor ?? 0, g = l?.stats?.goalsAgainst ?? 0, h = u?.stats?.goalsAgainst ?? 0, R = a?.stats?.goalsAgainst ?? 0, S = r?.stats?.played ?? 0, A = d?.stats?.played ?? 0, G = a?.stats?.played ?? 0, B = G > 0 ? p / G : 0, $ = G > 0 ? R / G : 0, P = B + $, U = S > 0 ? c / S : 0, x = A > 0 ? m / A : 0, f = S > 0 ? g / S : 0, v = A > 0 ? h / A : 0, H = U + f, ne = x + v;
1651
+ const r = t?.entries.find((E) => E.competitor.id === e), a = o?.entries.find((E) => E.competitor.id === e), l = n?.entries.find((E) => E.competitor.id === e), d = s?.entries.find((E) => E.competitor.id === e), u = i?.entries.find((E) => E.competitor.id === e);
1652
+ if (!r) return null;
1653
+ const c = a?.stats?.goalsFor ?? 0, m = l?.stats?.goalsFor ?? 0, p = r?.stats?.goalsFor ?? 0, g = d?.stats?.goalsAgainst ?? 0, h = u?.stats?.goalsAgainst ?? 0, R = r?.stats?.goalsAgainst ?? 0, S = a?.stats?.played ?? 0, A = l?.stats?.played ?? 0, D = r?.stats?.played ?? 0, B = D > 0 ? p / D : 0, $ = D > 0 ? R / D : 0, P = B + $, U = S > 0 ? c / S : 0, x = A > 0 ? m / A : 0, f = S > 0 ? g / S : 0, v = A > 0 ? h / A : 0, H = U + f, ne = x + v;
1675
1654
  return {
1676
1655
  homeGoals: c,
1677
1656
  totalGoals: p,
1678
1657
  awayGoals: m,
1679
1658
  homeGamesPlayed: S,
1680
1659
  awayGamesPlayed: A,
1681
- totalGamesPlayed: G,
1660
+ totalGamesPlayed: D,
1682
1661
  homeGoalsConceded: g,
1683
1662
  totalGoalsConceded: R,
1684
1663
  awayGoalsConceded: h,
@@ -1694,15 +1673,15 @@ function Zt(e, t, o, n, s, i) {
1694
1673
  };
1695
1674
  }
1696
1675
  function _(e, t, o, n) {
1697
- const s = e.filter((a) => {
1698
- const r = a.competitorOne.id === t, d = a.competitorTwo.id === t;
1699
- return !(!r && !d || a.status?.type !== "FINISHED" || n === "home" && !r || n === "away" && !d);
1700
- }).sort((a, r) => new Date(r.timing.kickoffTime).getTime() - new Date(a.timing.kickoffTime).getTime());
1676
+ const s = e.filter((r) => {
1677
+ const a = r.competitorOne.id === t, l = r.competitorTwo.id === t;
1678
+ return !(!a && !l || r.status?.type !== "FINISHED" || n === "home" && !a || n === "away" && !l);
1679
+ }).sort((r, a) => new Date(a.timing.kickoffTime).getTime() - new Date(r.timing.kickoffTime).getTime());
1701
1680
  if (s.length === 0) return null;
1702
1681
  let i = 0;
1703
- for (const a of s) {
1704
- const r = a.competitorOne.id === t;
1705
- if (o(a, t, r))
1682
+ for (const r of s) {
1683
+ const a = r.competitorOne.id === t;
1684
+ if (o(r, t, a))
1706
1685
  i++;
1707
1686
  else
1708
1687
  break;
@@ -1750,90 +1729,90 @@ function q(e, t, o) {
1750
1729
  };
1751
1730
  }
1752
1731
  function wt(e, t, o) {
1753
- const n = q(e, t, "home"), s = q(e, t), i = q(e, o, "away"), a = q(e, o);
1732
+ const n = q(e, t, "home"), s = q(e, t), i = q(e, o, "away"), r = q(e, o);
1754
1733
  return [
1755
1734
  {
1756
1735
  label: "Consecutive wins",
1757
1736
  homeTeam: { home: n.win, total: s.win },
1758
- awayTeam: { total: a.win, home: i.win },
1737
+ awayTeam: { total: r.win, home: i.win },
1759
1738
  colorType: "neutral"
1760
1739
  },
1761
1740
  {
1762
1741
  label: "Consecutive draws",
1763
1742
  homeTeam: { home: n.draw, total: s.draw },
1764
- awayTeam: { total: a.draw, home: i.draw },
1743
+ awayTeam: { total: r.draw, home: i.draw },
1765
1744
  colorType: "neutral"
1766
1745
  },
1767
1746
  {
1768
1747
  label: "Consecutive defeats",
1769
1748
  homeTeam: { home: n.loss, total: s.loss },
1770
- awayTeam: { total: a.loss, home: i.loss },
1749
+ awayTeam: { total: r.loss, home: i.loss },
1771
1750
  colorType: "neutral"
1772
1751
  },
1773
1752
  {
1774
1753
  label: "No win",
1775
1754
  homeTeam: { home: n.noWin, total: s.noWin },
1776
- awayTeam: { total: a.noWin, home: i.noWin },
1755
+ awayTeam: { total: r.noWin, home: i.noWin },
1777
1756
  colorType: "negative"
1778
1757
  },
1779
1758
  {
1780
1759
  label: "No draw",
1781
1760
  homeTeam: { home: n.noDraw, total: s.noDraw },
1782
- awayTeam: { total: a.noDraw, home: i.noDraw },
1761
+ awayTeam: { total: r.noDraw, home: i.noDraw },
1783
1762
  colorType: "neutral"
1784
1763
  },
1785
1764
  {
1786
1765
  label: "No defeat",
1787
1766
  homeTeam: { home: n.noDefeat, total: s.noDefeat },
1788
- awayTeam: { total: a.noDefeat, home: i.noDefeat },
1767
+ awayTeam: { total: r.noDefeat, home: i.noDefeat },
1789
1768
  colorType: "positive"
1790
1769
  },
1791
1770
  {
1792
1771
  label: "Scored at least once",
1793
1772
  homeTeam: { home: n.scored, total: s.scored },
1794
- awayTeam: { total: a.scored, home: i.scored },
1773
+ awayTeam: { total: r.scored, home: i.scored },
1795
1774
  colorType: "positive"
1796
1775
  },
1797
1776
  {
1798
1777
  label: "Conceded at least once",
1799
1778
  homeTeam: { home: n.conceded, total: s.conceded },
1800
- awayTeam: { total: a.conceded, home: i.conceded },
1779
+ awayTeam: { total: r.conceded, home: i.conceded },
1801
1780
  colorType: "negative"
1802
1781
  },
1803
1782
  {
1804
1783
  label: "No goal scored",
1805
1784
  homeTeam: { home: n.noGoalScored, total: s.noGoalScored },
1806
- awayTeam: { total: a.noGoalScored, home: i.noGoalScored },
1785
+ awayTeam: { total: r.noGoalScored, home: i.noGoalScored },
1807
1786
  colorType: "neutral"
1808
1787
  },
1809
1788
  {
1810
1789
  label: "No goal conceded",
1811
1790
  homeTeam: { home: n.noGoalConceded, total: s.noGoalConceded },
1812
- awayTeam: { total: a.noGoalConceded, home: i.noGoalConceded },
1791
+ awayTeam: { total: r.noGoalConceded, home: i.noGoalConceded },
1813
1792
  colorType: "neutral"
1814
1793
  },
1815
1794
  {
1816
1795
  label: "GS + GC over 2.5",
1817
1796
  homeTeam: { home: n.over25, total: s.over25 },
1818
- awayTeam: { total: a.over25, home: i.over25 },
1797
+ awayTeam: { total: r.over25, home: i.over25 },
1819
1798
  colorType: "neutral"
1820
1799
  },
1821
1800
  {
1822
1801
  label: "GS + GC under 2.5",
1823
1802
  homeTeam: { home: n.under25, total: s.under25 },
1824
- awayTeam: { total: a.under25, home: i.under25 },
1803
+ awayTeam: { total: r.under25, home: i.under25 },
1825
1804
  colorType: "neutral"
1826
1805
  },
1827
1806
  {
1828
1807
  label: "Scored at least twice",
1829
1808
  homeTeam: { home: n.scoredTwice, total: s.scoredTwice },
1830
- awayTeam: { total: a.scoredTwice, home: i.scoredTwice },
1809
+ awayTeam: { total: r.scoredTwice, home: i.scoredTwice },
1831
1810
  colorType: "positive"
1832
1811
  },
1833
1812
  {
1834
1813
  label: "Conceded at least twice",
1835
1814
  homeTeam: { home: n.concededTwice, total: s.concededTwice },
1836
- awayTeam: { total: a.concededTwice, home: i.concededTwice },
1815
+ awayTeam: { total: r.concededTwice, home: i.concededTwice },
1837
1816
  colorType: "negative"
1838
1817
  }
1839
1818
  ];
@@ -1844,29 +1823,29 @@ function X(e, t) {
1844
1823
  if (n.status?.type !== "FINISHED") return;
1845
1824
  const s = ct(n, t);
1846
1825
  if (!s) return;
1847
- const i = s.isHome ? n.competitorTwo.id : n.competitorOne.id, a = s.isHome ? n.competitorTwo : n.competitorOne, r = o.get(i) || {
1826
+ const i = s.isHome ? n.competitorTwo.id : n.competitorOne.id, r = s.isHome ? n.competitorTwo : n.competitorOne, a = o.get(i) || {
1848
1827
  opponentId: i,
1849
- opponentName: a.name,
1850
- opponentLogo: a.assets?.logo
1828
+ opponentName: r.name,
1829
+ opponentLogo: r.assets?.logo
1851
1830
  };
1852
- s.isHome ? r.homeResult = s.result : r.awayResult = s.result, o.set(i, r);
1831
+ s.isHome ? a.homeResult = s.result : a.awayResult = s.result, o.set(i, a);
1853
1832
  }), o;
1854
1833
  }
1855
- function eo(e, t, o, n, s, i, a) {
1856
- const r = X(e, t), d = X(e, o), l = /* @__PURE__ */ new Set([
1857
- ...r.keys(),
1858
- ...d.keys(),
1834
+ function eo(e, t, o, n, s, i, r) {
1835
+ const a = X(e, t), l = X(e, o), d = /* @__PURE__ */ new Set([
1836
+ ...a.keys(),
1837
+ ...l.keys(),
1859
1838
  t,
1860
1839
  // Include home team as row for away team results
1861
1840
  o
1862
1841
  // Include away team as row for home team results
1863
1842
  ]), u = [];
1864
- return l.forEach((c) => {
1865
- const m = r.get(c), p = d.get(c);
1843
+ return d.forEach((c) => {
1844
+ const m = a.get(c), p = l.get(c);
1866
1845
  if (!m && !p && c !== t && c !== o)
1867
1846
  return;
1868
1847
  let g, h;
1869
- c === t ? (g = n, h = i) : c === o ? (g = s, h = a) : (g = m?.opponentName || p?.opponentName || "", h = m?.opponentLogo || p?.opponentLogo), u.push({
1848
+ c === t ? (g = n, h = i) : c === o ? (g = s, h = r) : (g = m?.opponentName || p?.opponentName || "", h = m?.opponentLogo || p?.opponentLogo), u.push({
1870
1849
  opponentId: c,
1871
1850
  opponentName: g,
1872
1851
  opponentLogo: h,
@@ -1905,8 +1884,8 @@ export {
1905
1884
  yt as getFansUnitedFootballTeam,
1906
1885
  so as getFootballCompetition,
1907
1886
  io as getFootballMatch,
1908
- ao as getFootballMatchCommentary,
1909
- ro as getFootballMatchEvents,
1887
+ ro as getFootballMatchCommentary,
1888
+ ao as getFootballMatchEvents,
1910
1889
  co as getFootballMatchLineups,
1911
1890
  lo as getFootballMatchOdds,
1912
1891
  uo as getFootballMatchStatistics,
@@ -1928,15 +1907,15 @@ export {
1928
1907
  At as getTeamNextMatch,
1929
1908
  Xt as getTeamOverUnderStats,
1930
1909
  Ot as getTeamPreviousMatch,
1931
- Nt as getTeamResultsTable,
1910
+ Gt as getTeamResultsTable,
1932
1911
  Yt as getTeamScore,
1933
1912
  ft as getTeamSeasonStatistics,
1934
1913
  q as getTeamStreaks,
1935
1914
  wt as getTeamStreaksComparison,
1936
- Dt as getTeamTopAppearances,
1937
- Gt as getTeamTopAssisters,
1938
- Et as getTeamTopCleanSheets,
1939
- It as getTeamTopMinutesPlayed,
1915
+ Et as getTeamTopAppearances,
1916
+ Dt as getTeamTopAssisters,
1917
+ It as getTeamTopCleanSheets,
1918
+ Nt as getTeamTopMinutesPlayed,
1940
1919
  Rt as getTeamTopScorers,
1941
1920
  Ft as getTeamUpcomingMatches,
1942
1921
  eo as getTeamsCommonOpponents,