fansunited-data-layer 0.8.7 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/api/fansunited/index.d.ts +2 -0
  2. package/api/fansunited/index.d.ts.map +1 -1
  3. package/api/fansunited/search/__tests__/index.test.d.ts +2 -0
  4. package/api/fansunited/search/__tests__/index.test.d.ts.map +1 -0
  5. package/api/fansunited/search/__tests__/transformer.test.d.ts +2 -0
  6. package/api/fansunited/search/__tests__/transformer.test.d.ts.map +1 -0
  7. package/api/fansunited/search/constants.d.ts +2 -0
  8. package/api/fansunited/search/constants.d.ts.map +1 -0
  9. package/api/fansunited/search/http.d.ts +5 -0
  10. package/api/fansunited/search/http.d.ts.map +1 -0
  11. package/api/fansunited/search/index.d.ts +50 -0
  12. package/api/fansunited/search/index.d.ts.map +1 -0
  13. package/api/fansunited/search/raw-types.d.ts +93 -0
  14. package/api/fansunited/search/raw-types.d.ts.map +1 -0
  15. package/api/fansunited/search/transformer.d.ts +66 -0
  16. package/api/fansunited/search/transformer.d.ts.map +1 -0
  17. package/api/fansunited/search/types.d.ts +136 -0
  18. package/api/fansunited/search/types.d.ts.map +1 -0
  19. package/api/sportal365-sports/constants.d.ts +2 -0
  20. package/api/sportal365-sports/constants.d.ts.map +1 -1
  21. package/api/sportal365-sports/index.d.ts +2 -0
  22. package/api/sportal365-sports/index.d.ts.map +1 -1
  23. package/api/sportal365-sports/standings/http.d.ts +8 -0
  24. package/api/sportal365-sports/standings/http.d.ts.map +1 -0
  25. package/api/sportal365-sports/standings/index.d.ts +48 -0
  26. package/api/sportal365-sports/standings/index.d.ts.map +1 -0
  27. package/api/sportal365-sports/standings/standing.transformer.d.ts +18 -0
  28. package/api/sportal365-sports/standings/standing.transformer.d.ts.map +1 -0
  29. package/api/sportal365-sports/standings/standing.types.d.ts +105 -0
  30. package/api/sportal365-sports/standings/standing.types.d.ts.map +1 -0
  31. package/cache/__tests__/cache-manager.test.d.ts +2 -0
  32. package/cache/__tests__/cache-manager.test.d.ts.map +1 -0
  33. package/cache/__tests__/cleanup.test.d.ts +2 -0
  34. package/cache/__tests__/cleanup.test.d.ts.map +1 -0
  35. package/cache/__tests__/memory-store.test.d.ts +2 -0
  36. package/cache/__tests__/memory-store.test.d.ts.map +1 -0
  37. package/cache/__tests__/sqlite-store.test.d.ts +2 -0
  38. package/cache/__tests__/sqlite-store.test.d.ts.map +1 -0
  39. package/cache/cache-manager.d.ts +42 -0
  40. package/cache/cache-manager.d.ts.map +1 -0
  41. package/cache/cleanup.d.ts +7 -0
  42. package/cache/cleanup.d.ts.map +1 -0
  43. package/cache/index.d.ts +13 -0
  44. package/cache/index.d.ts.map +1 -0
  45. package/cache/memory-store.d.ts +12 -0
  46. package/cache/memory-store.d.ts.map +1 -0
  47. package/cache/sqlite-store.d.ts +19 -0
  48. package/cache/sqlite-store.d.ts.map +1 -0
  49. package/cache/types.d.ts +15 -0
  50. package/cache/types.d.ts.map +1 -0
  51. package/client.cjs +1 -1
  52. package/client.js +2 -2
  53. package/config/types.d.ts +2 -0
  54. package/config/types.d.ts.map +1 -1
  55. package/fansunited-data-layer.cjs +1 -1
  56. package/fansunited-data-layer.js +2660 -1342
  57. package/index.d.ts +7 -5
  58. package/index.d.ts.map +1 -1
  59. package/matches-D5jlWsqr.cjs +1 -0
  60. package/{matches-BefXoB5p.js → matches-dKvggZia.js} +47 -46
  61. package/package.json +11 -3
  62. package/types/canonical/base.types.d.ts +28 -2
  63. package/types/canonical/base.types.d.ts.map +1 -1
  64. package/types/canonical/index.d.ts +2 -2
  65. package/types/canonical/index.d.ts.map +1 -1
  66. package/types/canonical/standing.types.d.ts +25 -0
  67. package/types/canonical/standing.types.d.ts.map +1 -1
  68. package/matches-CiVDiSIz.cjs +0 -1
@@ -1,197 +1,197 @@
1
- import { t as _, g as A, f as ie, c as V, S as re, a as ee, b as ae, d as ce, e as de, h as le, i as ue } from "./matches-BefXoB5p.js";
2
- import { j as So, k as Co, l as Ao, m as Oo, n as No, o as Ro, p as Fo, q as Eo, r as Mo, s as Lo, u as Io, v as Go, w as Do, x as Po, y as bo, z as ko, A as Ho, B as Uo, C as Bo, D as $o, E as xo, F as Wo } from "./matches-BefXoB5p.js";
3
- import { useMemo as D } from "react";
4
- function me(e) {
1
+ import { t as L, g as b, f as Qt, c as ot, S as Vt, a as It, b as Kt, d as Xt, e as Jt, h as Zt, i as wt, j as te, k as ee } from "./matches-dKvggZia.js";
2
+ import { l as Xo, m as Jo, n as Zo, o as wo, p as ts, q as es, r as ns, s as os, u as ss, v as is, w as rs, x as as, y as cs, z as ls, A as ds, B as us, C as fs, D as hs, E as ms, F as gs, G as ps } from "./matches-dKvggZia.js";
3
+ import { useMemo as j } from "react";
4
+ function ne(t) {
5
5
  return {
6
6
  entityType: "tournament",
7
- id: e.id.toString(),
8
- name: e.name,
9
- slug: e.slug,
10
- gender: e.gender,
11
- type: e.type,
12
- region: e.region,
7
+ id: t.id.toString(),
8
+ name: t.name,
9
+ slug: t.slug,
10
+ gender: t.gender,
11
+ type: t.type,
12
+ region: t.region,
13
13
  country: {
14
- id: e.country.id.toString(),
15
- name: e.country.name,
14
+ id: t.country.id.toString(),
15
+ name: t.country.name,
16
16
  code: void 0,
17
- flag: e.country.url_flag ?? void 0,
18
- providerRef: _(e.country.uuid)
17
+ flag: t.country.url_flag ?? void 0,
18
+ providerRef: L(t.country.uuid)
19
19
  },
20
- assets: e.url_logo ? {
21
- logo: e.url_logo
20
+ assets: t.url_logo ? {
21
+ logo: t.url_logo
22
22
  } : void 0,
23
- providerRef: _(e.uuid)
23
+ providerRef: L(t.uuid)
24
24
  };
25
25
  }
26
- function fe(e) {
26
+ function oe(t) {
27
27
  return {
28
28
  entityType: "player",
29
- id: e.id.toString(),
30
- name: e.name,
31
- slug: e.slug,
32
- position: e.position,
33
- gender: e.gender,
34
- birthdate: e.birthdate,
29
+ id: t.id.toString(),
30
+ name: t.name,
31
+ slug: t.slug,
32
+ position: t.position,
33
+ gender: t.gender,
34
+ birthdate: t.birthdate,
35
35
  country: {
36
- id: e.country.id.toString(),
37
- name: e.country.name,
36
+ id: t.country.id.toString(),
37
+ name: t.country.name,
38
38
  code: void 0,
39
- flag: e.country.url_flag ?? void 0,
40
- providerRef: _(e.country.uuid)
39
+ flag: t.country.url_flag ?? void 0,
40
+ providerRef: L(t.country.uuid)
41
41
  },
42
- assets: e.url_thumb ? {
43
- photo: e.url_thumb
42
+ assets: t.url_thumb ? {
43
+ photo: t.url_thumb
44
44
  } : void 0,
45
- providerRef: _(e.uuid)
45
+ providerRef: L(t.uuid)
46
46
  };
47
47
  }
48
- function ge(e) {
48
+ function se(t) {
49
49
  return {
50
50
  entityType: "team",
51
- id: e.id.toString(),
52
- name: e.name,
53
- slug: e.slug,
54
- shortName: e.short_name ?? void 0,
55
- threeLetterCode: e.three_letter_code ?? void 0,
56
- type: e.type === "national" ? "national" : "club",
57
- gender: e.gender,
51
+ id: t.id.toString(),
52
+ name: t.name,
53
+ slug: t.slug,
54
+ shortName: t.short_name ?? void 0,
55
+ threeLetterCode: t.three_letter_code ?? void 0,
56
+ type: t.type === "national" ? "national" : "club",
57
+ gender: t.gender,
58
58
  country: {
59
- id: e.country.id.toString(),
60
- name: e.country.name,
59
+ id: t.country.id.toString(),
60
+ name: t.country.name,
61
61
  code: void 0,
62
- flag: e.country.url_flag ?? void 0,
63
- providerRef: _(e.country.uuid)
62
+ flag: t.country.url_flag ?? void 0,
63
+ providerRef: L(t.country.uuid)
64
64
  },
65
- assets: e.url_logo ? {
66
- logo: e.url_logo
65
+ assets: t.url_logo ? {
66
+ logo: t.url_logo
67
67
  } : void 0,
68
- providerRef: _(e.uuid)
68
+ providerRef: L(t.uuid)
69
69
  };
70
70
  }
71
- function pe(e) {
71
+ function ie(t) {
72
72
  return {
73
73
  entityType: "president",
74
- id: e.id.toString(),
75
- name: e.name,
76
- slug: e.slug,
77
- birthdate: e.birthdate ?? void 0,
74
+ id: t.id.toString(),
75
+ name: t.name,
76
+ slug: t.slug,
77
+ birthdate: t.birthdate ?? void 0,
78
78
  country: {
79
- id: e.country.id.toString(),
80
- name: e.country.name,
79
+ id: t.country.id.toString(),
80
+ name: t.country.name,
81
81
  code: void 0,
82
- flag: e.country.url_flag ?? void 0,
83
- providerRef: _(e.country.uuid)
82
+ flag: t.country.url_flag ?? void 0,
83
+ providerRef: L(t.country.uuid)
84
84
  },
85
- assets: e.url_thumb ? {
86
- photo: e.url_thumb
85
+ assets: t.url_thumb ? {
86
+ photo: t.url_thumb
87
87
  } : void 0,
88
- providerRef: _(e.uuid)
88
+ providerRef: L(t.uuid)
89
89
  };
90
90
  }
91
- function ye(e) {
91
+ function re(t) {
92
92
  return {
93
93
  entityType: "venue",
94
- id: e.id.toString(),
95
- name: e.name,
96
- slug: e.slug,
94
+ id: t.id.toString(),
95
+ name: t.name,
96
+ slug: t.slug,
97
97
  city: {
98
- id: e.city.id.toString(),
99
- name: e.city.name,
98
+ id: t.city.id.toString(),
99
+ name: t.city.name,
100
100
  country: {
101
- id: e.city.country.id.toString(),
102
- name: e.city.country.name,
101
+ id: t.city.country.id.toString(),
102
+ name: t.city.country.name,
103
103
  code: void 0,
104
- flag: e.city.country.url_flag ?? void 0,
105
- providerRef: _(e.city.country.uuid)
104
+ flag: t.city.country.url_flag ?? void 0,
105
+ providerRef: L(t.city.country.uuid)
106
106
  },
107
- providerRef: _(e.city.uuid)
107
+ providerRef: L(t.city.uuid)
108
108
  },
109
109
  country: {
110
- id: e.country.id.toString(),
111
- name: e.country.name,
110
+ id: t.country.id.toString(),
111
+ name: t.country.name,
112
112
  code: void 0,
113
- flag: e.country.url_flag ?? void 0,
114
- providerRef: _(e.country.uuid)
113
+ flag: t.country.url_flag ?? void 0,
114
+ providerRef: L(t.country.uuid)
115
115
  },
116
116
  profile: {
117
- latitude: e.profile.lat,
118
- longitude: e.profile.lng,
119
- capacity: e.profile.capacity
117
+ latitude: t.profile.lat,
118
+ longitude: t.profile.lng,
119
+ capacity: t.profile.capacity
120
120
  },
121
- assets: e.url_thumb ? {
122
- image: e.url_thumb
121
+ assets: t.url_thumb ? {
122
+ image: t.url_thumb
123
123
  } : void 0,
124
- providerRef: _(e.uuid)
124
+ providerRef: L(t.uuid)
125
125
  };
126
126
  }
127
- function he(e) {
127
+ function ae(t) {
128
128
  return {
129
129
  entityType: "coach",
130
- id: e.id.toString(),
131
- name: e.name,
132
- slug: e.slug,
133
- birthdate: e.birthdate ?? void 0,
130
+ id: t.id.toString(),
131
+ name: t.name,
132
+ slug: t.slug,
133
+ birthdate: t.birthdate ?? void 0,
134
134
  country: {
135
- id: e.country.id.toString(),
136
- name: e.country.name,
135
+ id: t.country.id.toString(),
136
+ name: t.country.name,
137
137
  code: void 0,
138
- flag: e.country.url_flag ?? void 0,
139
- providerRef: _(e.country.uuid)
138
+ flag: t.country.url_flag ?? void 0,
139
+ providerRef: L(t.country.uuid)
140
140
  },
141
- assets: e.url_thumb ? {
142
- photo: e.url_thumb
141
+ assets: t.url_thumb ? {
142
+ photo: t.url_thumb
143
143
  } : void 0,
144
- providerRef: _(e.uuid)
144
+ providerRef: L(t.uuid)
145
145
  };
146
146
  }
147
- function Te(e) {
148
- switch (e.entity_type) {
147
+ function ce(t) {
148
+ switch (t.entity_type) {
149
149
  case "tournament":
150
- return me(e);
150
+ return ne(t);
151
151
  case "player":
152
- return fe(e);
152
+ return oe(t);
153
153
  case "team":
154
- return ge(e);
154
+ return se(t);
155
155
  case "president":
156
- return pe(e);
156
+ return ie(t);
157
157
  case "venue":
158
- return ye(e);
158
+ return re(t);
159
159
  case "coach":
160
- return he(e);
160
+ return ae(t);
161
161
  default:
162
- throw new Error(`Unknown entity type: ${e.entity_type}`);
162
+ throw new Error(`Unknown entity type: ${t.entity_type}`);
163
163
  }
164
164
  }
165
- async function Nt(e, t) {
166
- if (!e.query || e.query.trim() === "")
165
+ async function zn(t, e) {
166
+ if (!t.query || t.query.trim() === "")
167
167
  return {
168
168
  results: [],
169
- query: e.query || ""
169
+ query: t.query || ""
170
170
  };
171
- const o = t || A(), { sportal365Sports: n } = o, s = e.entityTypes && e.entityTypes.length > 0 ? e.entityTypes : ["tournament", "player", "team", "president", "venue", "coach"], i = await ie.get({
171
+ const n = e || b(), { sportal365Sports: o } = n, s = t.entityTypes && t.entityTypes.length > 0 ? t.entityTypes : ["tournament", "player", "team", "president", "venue", "coach"], i = await Qt.get({
172
172
  path: "/search",
173
173
  params: {
174
- query: e.query.trim(),
174
+ query: t.query.trim(),
175
175
  entity_type: s.join(","),
176
- language_code: e.languageCode ?? n?.languageCode ?? "en"
176
+ language_code: t.languageCode ?? o?.languageCode ?? "en"
177
177
  },
178
178
  headers: {
179
- "Accept-Language": e.languageCode ?? n?.languageCode ?? "en"
179
+ "Accept-Language": t.languageCode ?? o?.languageCode ?? "en"
180
180
  },
181
- next: e.next,
182
- config: o
181
+ next: t.next,
182
+ config: n
183
183
  });
184
184
  return !i || i.length === 0 ? {
185
185
  results: [],
186
- query: e.query
186
+ query: t.query
187
187
  } : {
188
- results: i.map(Te),
189
- query: e.query
188
+ results: i.map(ce),
189
+ query: t.query
190
190
  };
191
191
  }
192
- const ve = V(re);
193
- function _e(e) {
194
- const t = {
192
+ const le = ot(Vt);
193
+ function de(t) {
194
+ const e = {
195
195
  FINISHED: "finished",
196
196
  NOT_STARTED: "not_started",
197
197
  LIVE: "live",
@@ -199,261 +199,261 @@ function _e(e) {
199
199
  CANCELLED: "cancelled",
200
200
  POSTPONED: "postponed",
201
201
  UNKNOWN: "not_started"
202
- }, o = e.type.toUpperCase();
202
+ }, n = t.type.toUpperCase();
203
203
  return {
204
- code: t[o] ?? "not_started",
205
- name: e.name,
206
- shortName: e.short_name,
207
- type: o
204
+ code: e[n] ?? "not_started",
205
+ name: t.name,
206
+ shortName: t.short_name,
207
+ type: n
208
208
  };
209
209
  }
210
- function Q(e) {
210
+ function Ot(t) {
211
211
  return {
212
- id: e.id,
213
- name: e.name,
214
- threeLetterCode: e.three_letter_code,
215
- slug: e.slug,
216
- type: e.type === "national" ? "national" : "club",
217
- gender: e.gender
212
+ id: t.id,
213
+ name: t.name,
214
+ threeLetterCode: t.three_letter_code,
215
+ slug: t.slug,
216
+ type: t.type === "national" ? "national" : "club",
217
+ gender: t.gender
218
218
  };
219
219
  }
220
- function Se(e) {
220
+ function ue(t) {
221
221
  return {
222
- kickoffTime: new Date(e.game_time),
223
- currentMinute: e.minute
222
+ kickoffTime: new Date(t.game_time),
223
+ currentMinute: t.minute
224
224
  };
225
225
  }
226
- function Ce(e) {
227
- if (!e.season?.competition) return;
228
- const t = e.season.competition;
226
+ function fe(t) {
227
+ if (!t.season?.competition) return;
228
+ const e = t.season.competition;
229
229
  return {
230
- id: t.id,
231
- name: t.name,
232
- slug: t.slug,
230
+ id: e.id,
231
+ name: e.name,
232
+ slug: e.slug,
233
233
  type: "LEAGUE",
234
- gender: t.gender,
235
- region: t.region,
236
- country: t.country ? {
237
- id: t.country.id,
238
- name: t.country.name
234
+ gender: e.gender,
235
+ region: e.region,
236
+ country: e.country ? {
237
+ id: e.country.id,
238
+ name: e.country.name
239
239
  } : void 0,
240
240
  season: {
241
- id: e.season.id,
242
- name: e.season.name,
243
- status: e.season.status
241
+ id: t.season.id,
242
+ name: t.season.name,
243
+ status: t.season.status
244
244
  },
245
- stage: e.stage ? {
246
- id: e.stage.id,
247
- name: e.stage.name,
248
- type: e.stage.type
245
+ stage: t.stage ? {
246
+ id: t.stage.id,
247
+ name: t.stage.name,
248
+ type: t.stage.type
249
249
  } : void 0
250
250
  };
251
251
  }
252
- function Ae(e) {
253
- if (e)
252
+ function he(t) {
253
+ if (t)
254
254
  return {
255
- id: e.id,
256
- name: e.name,
257
- slug: e.slug
255
+ id: t.id,
256
+ name: t.name,
257
+ slug: t.slug
258
258
  };
259
259
  }
260
- function Oe(e) {
261
- if (!e || e.length === 0) return;
262
- const t = e.filter((i) => i.result_type.category === "single_period");
263
- if (t.length === 0) return;
264
- let o = 0, n = 0;
260
+ function me(t) {
261
+ if (!t || t.length === 0) return;
262
+ const e = t.filter((i) => i.result_type.category === "single_period");
263
+ if (e.length === 0) return;
264
+ let n = 0, o = 0;
265
265
  const s = [];
266
- for (const i of t)
267
- o += i.home, n += i.away, s.push({
266
+ for (const i of e)
267
+ n += i.home, o += i.away, s.push({
268
268
  competitorOne: String(i.home),
269
269
  competitorTwo: String(i.away)
270
270
  });
271
271
  return {
272
- competitorOne: String(o),
273
- competitorTwo: String(n),
272
+ competitorOne: String(n),
273
+ competitorTwo: String(o),
274
274
  breakdown: {
275
275
  total: {
276
- competitorOne: String(o),
277
- competitorTwo: String(n)
276
+ competitorOne: String(n),
277
+ competitorTwo: String(o)
278
278
  },
279
279
  periods: s
280
280
  }
281
281
  };
282
282
  }
283
- function Ne(e) {
284
- if (e.winner)
283
+ function ge(t) {
284
+ if (t.winner)
285
285
  return {
286
- competitorId: e.winner.id
286
+ competitorId: t.winner.id
287
287
  };
288
288
  }
289
- function Re(e) {
289
+ function pe(t) {
290
290
  return {
291
- id: e.id,
292
- slug: e.slug,
293
- status: _e(e.status),
294
- timing: Se(e),
295
- competitorOne: Q(e.home_team),
296
- competitorTwo: Q(e.away_team),
297
- competition: Ce(e),
298
- round: e.round ? {
299
- id: e.round.id,
300
- key: e.round.uuid,
301
- name: e.round.name,
291
+ id: t.id,
292
+ slug: t.slug,
293
+ status: de(t.status),
294
+ timing: ue(t),
295
+ competitorOne: Ot(t.home_team),
296
+ competitorTwo: Ot(t.away_team),
297
+ competition: fe(t),
298
+ round: t.round ? {
299
+ id: t.round.id,
300
+ key: t.round.uuid,
301
+ name: t.round.name,
302
302
  type: "REGULAR",
303
- providerRef: _(e.round.uuid)
303
+ providerRef: L(t.round.uuid)
304
304
  } : void 0,
305
- venue: Ae(e.arena),
306
- score: Oe(e.score),
307
- winner: Ne(e),
308
- odds: e.odds ? ee(e.odds) : void 0,
309
- coverage: e.coverage === "NOT_LIVE" ? "UNKNOWN" : e.coverage,
305
+ venue: he(t.arena),
306
+ score: me(t.score),
307
+ winner: ge(t),
308
+ odds: t.odds ? It(t.odds) : void 0,
309
+ coverage: t.coverage === "NOT_LIVE" ? "UNKNOWN" : t.coverage,
310
310
  providerRef: [
311
311
  {
312
312
  provider: "sportal365-basketball",
313
- id: e.id
313
+ id: t.id
314
314
  }
315
315
  ]
316
316
  };
317
317
  }
318
- async function Rt(e, t) {
319
- const o = t || A(), { sportal365Sports: n } = o;
320
- return (await ve.get({
318
+ async function Yn(t, e) {
319
+ const n = e || b(), { sportal365Sports: o } = n;
320
+ return (await le.get({
321
321
  path: "/games",
322
322
  params: {
323
323
  offset: "0",
324
324
  limit: "1000",
325
- competition_list: e?.competitionList,
326
- status_type: e?.statusTypes,
327
- from_game_time: e?.fromGameTime,
328
- to_game_time: e?.toGameTime,
329
- odd_client: e?.oddClient ?? n?.oddClient,
330
- odd_type: e?.oddType,
331
- market_types: e?.marketTypes,
332
- language_code: e?.languageCode ?? n?.languageCode ?? "en"
325
+ competition_list: t?.competitionList,
326
+ status_type: t?.statusTypes,
327
+ from_game_time: t?.fromGameTime,
328
+ to_game_time: t?.toGameTime,
329
+ odd_client: t?.oddClient ?? o?.oddClient,
330
+ odd_type: t?.oddType,
331
+ market_types: t?.marketTypes,
332
+ language_code: t?.languageCode ?? o?.languageCode ?? "en"
333
333
  },
334
334
  headers: {
335
- "Accept-Language": e?.languageCode ?? n?.languageCode ?? "en"
335
+ "Accept-Language": t?.languageCode ?? o?.languageCode ?? "en"
336
336
  },
337
- next: e?.next,
338
- config: o
339
- })).games.map(Re);
337
+ next: t?.next,
338
+ config: n
339
+ })).games.map(pe);
340
340
  }
341
- const Fe = V(ae);
342
- function Ee(e) {
343
- const t = {
341
+ const ye = ot(Kt);
342
+ function Te(t) {
343
+ const e = {
344
344
  FINISHED: "finished",
345
345
  NOT_STARTED: "not_started",
346
346
  LIVE: "live",
347
347
  INTERRUPTED: "interrupted",
348
348
  CANCELLED: "cancelled",
349
349
  POSTPONED: "postponed"
350
- }, o = e.type.toUpperCase();
350
+ }, n = t.type.toUpperCase();
351
351
  return {
352
- code: t[o] ?? "not_started",
353
- name: e.name,
354
- shortName: e.short_name,
355
- type: o
352
+ code: e[n] ?? "not_started",
353
+ name: t.name,
354
+ shortName: t.short_name,
355
+ type: n
356
356
  };
357
357
  }
358
- function X(e) {
359
- if (e.type === "PLAYER")
358
+ function Et(t) {
359
+ if (t.type === "PLAYER")
360
360
  return {
361
- id: e.id,
362
- name: e.name,
363
- shortName: e.short_name,
364
- threeLetterCode: e.three_letter_code,
361
+ id: t.id,
362
+ name: t.name,
363
+ shortName: t.short_name,
364
+ threeLetterCode: t.three_letter_code,
365
365
  type: "player",
366
- country: e.details?.[0]?.country ? {
367
- id: e.details[0].country.id,
368
- name: e.details[0].country.name
366
+ country: t.details?.[0]?.country ? {
367
+ id: t.details[0].country.id,
368
+ name: t.details[0].country.name
369
369
  } : void 0,
370
- gender: e.details?.[0]?.gender
370
+ gender: t.details?.[0]?.gender
371
371
  };
372
- if (e.type === "TEAM_DOUBLE" && e.details && e.details.length === 2) {
373
- const t = {
374
- id: e.details[0].id,
375
- name: e.details[0].name,
376
- shortName: e.details[0].short_name,
377
- threeLetterCode: e.details[0].three_letter_code,
372
+ if (t.type === "TEAM_DOUBLE" && t.details && t.details.length === 2) {
373
+ const e = {
374
+ id: t.details[0].id,
375
+ name: t.details[0].name,
376
+ shortName: t.details[0].short_name,
377
+ threeLetterCode: t.details[0].three_letter_code,
378
378
  type: "player",
379
- country: e.details[0].country ? {
380
- id: e.details[0].country.id,
381
- name: e.details[0].country.name
379
+ country: t.details[0].country ? {
380
+ id: t.details[0].country.id,
381
+ name: t.details[0].country.name
382
382
  } : void 0,
383
- gender: e.details[0].gender
384
- }, o = {
385
- id: e.details[1].id,
386
- name: e.details[1].name,
387
- shortName: e.details[1].short_name,
388
- threeLetterCode: e.details[1].three_letter_code,
383
+ gender: t.details[0].gender
384
+ }, n = {
385
+ id: t.details[1].id,
386
+ name: t.details[1].name,
387
+ shortName: t.details[1].short_name,
388
+ threeLetterCode: t.details[1].three_letter_code,
389
389
  type: "player",
390
- country: e.details[1].country ? {
391
- id: e.details[1].country.id,
392
- name: e.details[1].country.name
390
+ country: t.details[1].country ? {
391
+ id: t.details[1].country.id,
392
+ name: t.details[1].country.name
393
393
  } : void 0,
394
- gender: e.details[1].gender
394
+ gender: t.details[1].gender
395
395
  };
396
396
  return {
397
- id: e.id,
398
- name: e.name,
399
- shortName: e.short_name,
400
- threeLetterCode: e.three_letter_code,
397
+ id: t.id,
398
+ name: t.name,
399
+ shortName: t.short_name,
400
+ threeLetterCode: t.three_letter_code,
401
401
  type: "pair",
402
- players: [t, o]
402
+ players: [e, n]
403
403
  };
404
404
  } else
405
405
  return {
406
- id: e.id,
407
- name: e.name,
408
- shortName: e.short_name,
409
- threeLetterCode: e.three_letter_code,
406
+ id: t.id,
407
+ name: t.name,
408
+ shortName: t.short_name,
409
+ threeLetterCode: t.three_letter_code,
410
410
  type: "national",
411
- country: e.details?.[0]?.country ? {
412
- id: e.details[0].country.id,
413
- name: e.details[0].country.name
411
+ country: t.details?.[0]?.country ? {
412
+ id: t.details[0].country.id,
413
+ name: t.details[0].country.name
414
414
  } : void 0,
415
- gender: e.details?.[0]?.gender
415
+ gender: t.details?.[0]?.gender
416
416
  };
417
417
  }
418
- function Me(e) {
418
+ function _e(t) {
419
419
  return {
420
- kickoffTime: new Date(e.scheduled_start_time),
421
- phaseStartedAt: e.started_at ? new Date(e.started_at) : void 0,
422
- finishedAt: e.finished_at ? new Date(e.finished_at) : void 0
420
+ kickoffTime: new Date(t.scheduled_start_time),
421
+ phaseStartedAt: t.started_at ? new Date(t.started_at) : void 0,
422
+ finishedAt: t.finished_at ? new Date(t.finished_at) : void 0
423
423
  };
424
424
  }
425
- function Le(e) {
426
- if (!e.tournament) return;
427
- const t = e.tournament;
425
+ function ve(t) {
426
+ if (!t.tournament) return;
427
+ const e = t.tournament;
428
428
  return {
429
- id: t.competition?.id ?? t.id,
430
- name: t.competition?.name ?? t.name,
431
- slug: t.competition?.slug ?? t.slug,
429
+ id: e.competition?.id ?? e.id,
430
+ name: e.competition?.name ?? e.name,
431
+ slug: e.competition?.slug ?? e.slug,
432
432
  type: "TOURNAMENT",
433
- gender: t.gender,
433
+ gender: e.gender,
434
434
  region: "INTERNATIONAL",
435
- country: t.country ? {
436
- id: t.country.id,
437
- name: t.country.name
435
+ country: e.country ? {
436
+ id: e.country.id,
437
+ name: e.country.name
438
438
  } : void 0
439
439
  };
440
440
  }
441
- function Ie(e) {
442
- if (!e.results || e.results.length === 0) return;
443
- const t = e.results.filter((d) => /^set\d+$/i.test(d.type.code));
444
- if (t.length === 0) return;
445
- const o = [];
446
- for (const d of t) {
447
- const l = d.values.find((c) => c.position === "1"), u = d.values.find((c) => c.position === "2");
448
- !l || !u || l.value == null || u.value == null || o.push({
449
- competitorOne: l.value,
450
- competitorTwo: u.value
441
+ function Se(t) {
442
+ if (!t.results || t.results.length === 0) return;
443
+ const e = t.results.filter((c) => /^set\d+$/i.test(c.type.code));
444
+ if (e.length === 0) return;
445
+ const n = [];
446
+ for (const c of e) {
447
+ const d = c.values.find((l) => l.position === "1"), f = c.values.find((l) => l.position === "2");
448
+ !d || !f || d.value == null || f.value == null || n.push({
449
+ competitorOne: d.value,
450
+ competitorTwo: f.value
451
451
  });
452
452
  }
453
- if (o.length === 0) return;
454
- const n = e.results.find((d) => d.type.code === "setswon"), s = n?.values.find((d) => d.position === "1"), i = n?.values.find((d) => d.position === "2");
453
+ if (n.length === 0) return;
454
+ const o = t.results.find((c) => c.type.code === "setswon"), s = o?.values.find((c) => c.position === "1"), i = o?.values.find((c) => c.position === "2");
455
455
  let r, a;
456
- return s?.value != null && i?.value != null ? (r = parseInt(s.value), a = parseInt(i.value)) : (r = o.filter((d) => parseInt(d.competitorOne) > parseInt(d.competitorTwo)).length, a = o.filter((d) => parseInt(d.competitorTwo) > parseInt(d.competitorOne)).length), {
456
+ return s?.value != null && i?.value != null ? (r = parseInt(s.value), a = parseInt(i.value)) : (r = n.filter((c) => parseInt(c.competitorOne) > parseInt(c.competitorTwo)).length, a = n.filter((c) => parseInt(c.competitorTwo) > parseInt(c.competitorOne)).length), {
457
457
  competitorOne: String(r),
458
458
  competitorTwo: String(a),
459
459
  breakdown: {
@@ -461,843 +461,1022 @@ function Ie(e) {
461
461
  competitorOne: String(r),
462
462
  competitorTwo: String(a)
463
463
  },
464
- periods: o
464
+ periods: n
465
465
  }
466
466
  };
467
467
  }
468
- function Ge(e) {
469
- const t = e.participants.find((o) => o.winner === "YES");
470
- if (t)
468
+ function Ae(t) {
469
+ const e = t.participants.find((n) => n.winner === "YES");
470
+ if (e)
471
471
  return {
472
- competitorId: t.id
472
+ competitorId: e.id
473
473
  };
474
474
  }
475
- function De(e) {
476
- const t = e.participants.sort((o, n) => o.position - n.position);
475
+ function Ce(t) {
476
+ const e = t.participants.sort((n, o) => n.position - o.position);
477
477
  return {
478
- id: e.id,
479
- slug: e.slug,
480
- status: Ee(e.status),
481
- timing: Me(e),
482
- competitorOne: X(t[0]),
483
- competitorTwo: X(t[1]),
484
- competition: Le(e),
485
- round: e.round ? {
486
- id: e.round.id,
487
- key: e.round.uuid,
488
- name: e.round.name,
478
+ id: t.id,
479
+ slug: t.slug,
480
+ status: Te(t.status),
481
+ timing: _e(t),
482
+ competitorOne: Et(e[0]),
483
+ competitorTwo: Et(e[1]),
484
+ competition: ve(t),
485
+ round: t.round ? {
486
+ id: t.round.id,
487
+ key: t.round.uuid,
488
+ name: t.round.name,
489
489
  type: "REGULAR",
490
- providerRef: _(e.round.uuid)
490
+ providerRef: L(t.round.uuid)
491
491
  } : void 0,
492
- score: Ie(e),
493
- winner: Ge(e),
494
- odds: e.odds ? ee(e.odds) : void 0,
495
- coverage: e.coverage?.type === "NOT_LIVE" ? "UNKNOWN" : e.coverage?.type,
492
+ score: Se(t),
493
+ winner: Ae(t),
494
+ odds: t.odds ? It(t.odds) : void 0,
495
+ coverage: t.coverage?.type === "NOT_LIVE" ? "UNKNOWN" : t.coverage?.type,
496
496
  metadata: {
497
- matchType: e.type,
498
- bestOfSets: e.best_of_sets,
499
- surface: e.tournament?.surface,
500
- indoorOutdoor: e.tournament?.indoor_outdoor
497
+ matchType: t.type,
498
+ bestOfSets: t.best_of_sets,
499
+ surface: t.tournament?.surface,
500
+ indoorOutdoor: t.tournament?.indoor_outdoor
501
501
  },
502
502
  providerRef: [
503
503
  {
504
504
  provider: "sportal365-tennis",
505
- id: e.id
505
+ id: t.id
506
506
  }
507
507
  ]
508
508
  };
509
509
  }
510
- async function Ft(e, t) {
511
- const o = t || A(), { sportal365Sports: n } = o;
512
- return (await Fe.get({
510
+ async function jn(t, e) {
511
+ const n = e || b(), { sportal365Sports: o } = n;
512
+ return (await ye.get({
513
513
  path: "/matches/livescore",
514
514
  params: {
515
- date: e?.date,
516
- utc_offset: e?.utcOffset?.toString(),
515
+ date: t?.date,
516
+ utc_offset: t?.utcOffset?.toString(),
517
517
  offset: "0",
518
518
  limit: "1000",
519
- type: e?.type,
520
- gender: e?.gender,
521
- status_type: e?.statusType,
522
- competition_list: e?.competitionList,
523
- odd_client: e?.oddClient ?? n?.oddClient,
524
- odd_type: e?.oddType,
525
- market_types: e?.marketTypes,
526
- language_code: e?.languageCode ?? n?.languageCode ?? "en"
519
+ type: t?.type,
520
+ gender: t?.gender,
521
+ status_type: t?.statusType,
522
+ competition_list: t?.competitionList,
523
+ odd_client: t?.oddClient ?? o?.oddClient,
524
+ odd_type: t?.oddType,
525
+ market_types: t?.marketTypes,
526
+ language_code: t?.languageCode ?? o?.languageCode ?? "en"
527
527
  },
528
528
  headers: {
529
- "Accept-Language": e?.languageCode ?? n?.languageCode ?? "en"
529
+ "Accept-Language": t?.languageCode ?? o?.languageCode ?? "en"
530
530
  },
531
- next: e?.next,
532
- config: o
533
- })).matches.map(De);
531
+ next: t?.next,
532
+ config: n
533
+ })).matches.map(Ce);
534
534
  }
535
- const Pe = V(ce);
536
- function R(e) {
535
+ const Oe = ot(Xt);
536
+ function D(t) {
537
537
  return {
538
- language: e.language,
539
- name: e.name,
540
- shortName: e.short_name ?? void 0,
541
- threeLetterCode: e.three_letter_code ?? void 0
538
+ language: t.language,
539
+ name: t.name,
540
+ shortName: t.short_name ?? void 0,
541
+ threeLetterCode: t.three_letter_code ?? void 0
542
542
  };
543
543
  }
544
- function F(e) {
545
- if (!(!e || !e.url))
544
+ function U(t) {
545
+ if (!(!t || !t.url))
546
546
  return {
547
- url: e.url
547
+ url: t.url
548
548
  };
549
549
  }
550
- function G(e) {
551
- if (e)
550
+ function z(t) {
551
+ if (t)
552
552
  return {
553
- id: e.id,
554
- legacyId: e.legacy_id ?? void 0,
555
- name: e.name,
556
- shortName: e.short_name ?? void 0,
557
- threeLetterCode: e.three_letter_code ?? void 0,
558
- translations: e.translations.map(R),
559
- displayAsset: F(e.display_asset),
560
- slug: e.slug,
561
- providerRef: e.id
553
+ id: t.id,
554
+ legacyId: t.legacy_id ?? void 0,
555
+ name: t.name,
556
+ shortName: t.short_name ?? void 0,
557
+ threeLetterCode: t.three_letter_code ?? void 0,
558
+ translations: t.translations.map(D),
559
+ displayAsset: U(t.display_asset),
560
+ slug: t.slug,
561
+ providerRef: t.id
562
562
  };
563
563
  }
564
- function K(e) {
564
+ function yt(t) {
565
565
  return {
566
566
  entityType: "team",
567
- id: e.id,
568
- legacyId: e.legacy_id ?? void 0,
569
- name: e.name,
570
- shortName: e.short_name ?? void 0,
571
- threeLetterCode: e.three_letter_code ?? void 0,
572
- translations: e.translations.map(R),
573
- displayAsset: F(e.display_asset),
574
- slug: e.slug,
575
- tagScore: e.tag_score ?? void 0,
576
- sport: e.sport,
577
- country: G(e.country),
578
- gender: e.gender,
579
- competitionIds: e.competition_ids,
580
- type: e.type,
581
- national: e.national,
582
- undecided: e.undecided,
583
- providerRef: e.id
567
+ id: t.id,
568
+ legacyId: t.legacy_id ?? void 0,
569
+ name: t.name,
570
+ shortName: t.short_name ?? void 0,
571
+ threeLetterCode: t.three_letter_code ?? void 0,
572
+ translations: t.translations.map(D),
573
+ displayAsset: U(t.display_asset),
574
+ slug: t.slug,
575
+ tagScore: t.tag_score ?? void 0,
576
+ sport: t.sport,
577
+ country: z(t.country),
578
+ gender: t.gender,
579
+ competitionIds: t.competition_ids,
580
+ type: t.type,
581
+ national: t.national,
582
+ undecided: t.undecided,
583
+ providerRef: t.id
584
584
  };
585
585
  }
586
- function te(e) {
586
+ function Pt(t) {
587
587
  return {
588
588
  entityType: "city",
589
- id: e.id,
590
- legacyId: e.legacy_id ?? void 0,
591
- name: e.name,
592
- shortName: e.short_name ?? void 0,
593
- threeLetterCode: e.three_letter_code ?? void 0,
594
- translations: e.translations.map(R),
595
- displayAsset: F(e.display_asset),
596
- slug: e.slug,
597
- tagScore: e.tag_score ?? void 0,
598
- sport: e.sport,
599
- country: G(e.country),
600
- providerRef: e.id
589
+ id: t.id,
590
+ legacyId: t.legacy_id ?? void 0,
591
+ name: t.name,
592
+ shortName: t.short_name ?? void 0,
593
+ threeLetterCode: t.three_letter_code ?? void 0,
594
+ translations: t.translations.map(D),
595
+ displayAsset: U(t.display_asset),
596
+ slug: t.slug,
597
+ tagScore: t.tag_score ?? void 0,
598
+ sport: t.sport,
599
+ country: z(t.country),
600
+ providerRef: t.id
601
601
  };
602
602
  }
603
- function be(e) {
603
+ function Ee(t) {
604
604
  return {
605
605
  entityType: "horse",
606
- id: e.id,
607
- legacyId: e.legacy_id ?? void 0,
608
- name: e.name,
609
- shortName: e.short_name ?? void 0,
610
- threeLetterCode: e.three_letter_code ?? void 0,
611
- translations: e.translations.map(R),
612
- displayAsset: F(e.display_asset),
613
- slug: e.slug,
614
- tagScore: e.tag_score ?? void 0,
615
- sport: e.sport,
616
- country: G(e.country),
617
- gender: e.gender,
618
- providerRef: e.id
606
+ id: t.id,
607
+ legacyId: t.legacy_id ?? void 0,
608
+ name: t.name,
609
+ shortName: t.short_name ?? void 0,
610
+ threeLetterCode: t.three_letter_code ?? void 0,
611
+ translations: t.translations.map(D),
612
+ displayAsset: U(t.display_asset),
613
+ slug: t.slug,
614
+ tagScore: t.tag_score ?? void 0,
615
+ sport: t.sport,
616
+ country: z(t.country),
617
+ gender: t.gender,
618
+ providerRef: t.id
619
619
  };
620
620
  }
621
- function ke(e) {
621
+ function Fe(t) {
622
622
  return {
623
623
  entityType: "player",
624
- id: e.id,
625
- legacyId: e.legacy_id ?? void 0,
626
- name: e.name,
627
- shortName: e.short_name ?? void 0,
628
- threeLetterCode: e.three_letter_code ?? void 0,
629
- translations: e.translations.map(R),
630
- displayAsset: F(e.display_asset),
631
- slug: e.slug,
632
- tagScore: e.tag_score ?? void 0,
633
- sport: e.sport,
634
- country: G(e.country),
635
- gender: e.gender,
636
- birthdate: e.birthdate ?? void 0,
637
- position: e.position ?? void 0,
638
- providerRef: e.id
624
+ id: t.id,
625
+ legacyId: t.legacy_id ?? void 0,
626
+ name: t.name,
627
+ shortName: t.short_name ?? void 0,
628
+ threeLetterCode: t.three_letter_code ?? void 0,
629
+ translations: t.translations.map(D),
630
+ displayAsset: U(t.display_asset),
631
+ slug: t.slug,
632
+ tagScore: t.tag_score ?? void 0,
633
+ sport: t.sport,
634
+ country: z(t.country),
635
+ gender: t.gender,
636
+ birthdate: t.birthdate ?? void 0,
637
+ position: t.position ?? void 0,
638
+ providerRef: t.id
639
639
  };
640
640
  }
641
- function He(e) {
641
+ function Le(t) {
642
642
  return {
643
643
  entityType: "coach",
644
- id: e.id,
645
- legacyId: e.legacy_id ?? void 0,
646
- name: e.name,
647
- shortName: e.short_name ?? void 0,
648
- threeLetterCode: e.three_letter_code ?? void 0,
649
- translations: e.translations.map(R),
650
- displayAsset: F(e.display_asset),
651
- slug: e.slug,
652
- tagScore: e.tag_score ?? void 0,
653
- sport: e.sport,
654
- country: G(e.country),
655
- gender: e.gender,
656
- birthdate: e.birthdate ?? void 0,
657
- providerRef: e.id
644
+ id: t.id,
645
+ legacyId: t.legacy_id ?? void 0,
646
+ name: t.name,
647
+ shortName: t.short_name ?? void 0,
648
+ threeLetterCode: t.three_letter_code ?? void 0,
649
+ translations: t.translations.map(D),
650
+ displayAsset: U(t.display_asset),
651
+ slug: t.slug,
652
+ tagScore: t.tag_score ?? void 0,
653
+ sport: t.sport,
654
+ country: z(t.country),
655
+ gender: t.gender,
656
+ birthdate: t.birthdate ?? void 0,
657
+ providerRef: t.id
658
658
  };
659
659
  }
660
- function Ue(e) {
660
+ function be(t) {
661
661
  return {
662
662
  entityType: "referee",
663
- id: e.id,
664
- legacyId: e.legacy_id ?? void 0,
665
- name: e.name,
666
- shortName: e.short_name ?? void 0,
667
- threeLetterCode: e.three_letter_code ?? void 0,
668
- translations: e.translations.map(R),
669
- displayAsset: F(e.display_asset),
670
- slug: e.slug,
671
- tagScore: e.tag_score ?? void 0,
672
- sport: e.sport,
673
- country: G(e.country),
674
- gender: e.gender,
675
- birthdate: e.birthdate ?? void 0,
676
- providerRef: e.id
663
+ id: t.id,
664
+ legacyId: t.legacy_id ?? void 0,
665
+ name: t.name,
666
+ shortName: t.short_name ?? void 0,
667
+ threeLetterCode: t.three_letter_code ?? void 0,
668
+ translations: t.translations.map(D),
669
+ displayAsset: U(t.display_asset),
670
+ slug: t.slug,
671
+ tagScore: t.tag_score ?? void 0,
672
+ sport: t.sport,
673
+ country: z(t.country),
674
+ gender: t.gender,
675
+ birthdate: t.birthdate ?? void 0,
676
+ providerRef: t.id
677
677
  };
678
678
  }
679
- function Be(e) {
679
+ function Ne(t) {
680
680
  return {
681
681
  entityType: "venue",
682
- id: e.id,
683
- legacyId: e.legacy_id ?? void 0,
684
- name: e.name,
685
- shortName: e.short_name ?? void 0,
686
- threeLetterCode: e.three_letter_code ?? void 0,
687
- translations: e.translations.map(R),
688
- displayAsset: F(e.display_asset),
689
- slug: e.slug,
690
- tagScore: e.tag_score ?? void 0,
691
- sport: e.sport,
692
- country: G(e.country),
693
- city: e.city ? te(e.city) : void 0,
694
- providerRef: e.id
682
+ id: t.id,
683
+ legacyId: t.legacy_id ?? void 0,
684
+ name: t.name,
685
+ shortName: t.short_name ?? void 0,
686
+ threeLetterCode: t.three_letter_code ?? void 0,
687
+ translations: t.translations.map(D),
688
+ displayAsset: U(t.display_asset),
689
+ slug: t.slug,
690
+ tagScore: t.tag_score ?? void 0,
691
+ sport: t.sport,
692
+ country: z(t.country),
693
+ city: t.city ? Pt(t.city) : void 0,
694
+ providerRef: t.id
695
695
  };
696
696
  }
697
- function $e(e) {
697
+ function Re(t) {
698
698
  return {
699
- entityType: e.entity_type,
700
- id: e.id,
701
- legacyId: e.legacy_id ?? void 0,
702
- name: e.name,
703
- shortName: e.short_name ?? void 0,
704
- threeLetterCode: e.three_letter_code ?? void 0,
705
- translations: e.translations.map(R),
706
- displayAsset: F(e.display_asset),
707
- slug: e.slug,
708
- tagScore: e.tag_score ?? void 0,
709
- sport: e.sport,
710
- country: G(e.country),
711
- gender: e.gender,
712
- type: e.type ?? void 0,
713
- region: e.region ?? void 0,
714
- providerRef: e.id
699
+ entityType: t.entity_type,
700
+ id: t.id,
701
+ legacyId: t.legacy_id ?? void 0,
702
+ name: t.name,
703
+ shortName: t.short_name ?? void 0,
704
+ threeLetterCode: t.three_letter_code ?? void 0,
705
+ translations: t.translations.map(D),
706
+ displayAsset: U(t.display_asset),
707
+ slug: t.slug,
708
+ tagScore: t.tag_score ?? void 0,
709
+ sport: t.sport,
710
+ country: z(t.country),
711
+ gender: t.gender,
712
+ type: t.type ?? void 0,
713
+ region: t.region ?? void 0,
714
+ providerRef: t.id
715
715
  };
716
716
  }
717
- function xe(e) {
717
+ function Ie(t) {
718
718
  return {
719
719
  entityType: "match",
720
- id: e.id,
721
- legacyId: e.legacy_id ?? void 0,
722
- name: e.name,
723
- shortName: e.short_name ?? void 0,
724
- threeLetterCode: e.three_letter_code ?? void 0,
725
- translations: e.translations.map(R),
726
- displayAsset: F(e.display_asset),
727
- slug: e.slug,
728
- tagScore: e.tag_score ?? void 0,
729
- sport: e.sport,
730
- competitionId: e.competition_id ?? void 0,
731
- startTime: e.start_time ?? void 0,
732
- homeTeam: e.home_team ? K(e.home_team) : void 0,
733
- awayTeam: e.away_team ? K(e.away_team) : void 0,
734
- providerRef: e.id
720
+ id: t.id,
721
+ legacyId: t.legacy_id ?? void 0,
722
+ name: t.name,
723
+ shortName: t.short_name ?? void 0,
724
+ threeLetterCode: t.three_letter_code ?? void 0,
725
+ translations: t.translations.map(D),
726
+ displayAsset: U(t.display_asset),
727
+ slug: t.slug,
728
+ tagScore: t.tag_score ?? void 0,
729
+ sport: t.sport,
730
+ competitionId: t.competition_id ?? void 0,
731
+ startTime: t.start_time ?? void 0,
732
+ homeTeam: t.home_team ? yt(t.home_team) : void 0,
733
+ awayTeam: t.away_team ? yt(t.away_team) : void 0,
734
+ providerRef: t.id
735
735
  };
736
736
  }
737
- function We(e) {
737
+ function Pe(t) {
738
738
  return {
739
739
  entityType: "country",
740
- id: e.id,
741
- legacyId: e.legacy_id ?? void 0,
742
- name: e.name,
743
- shortName: e.short_name ?? void 0,
744
- threeLetterCode: e.three_letter_code ?? void 0,
745
- translations: e.translations.map(R),
746
- displayAsset: F(e.display_asset),
747
- slug: e.slug,
748
- tagScore: e.tag_score ?? void 0,
749
- sport: e.sport,
750
- providerRef: e.id
740
+ id: t.id,
741
+ legacyId: t.legacy_id ?? void 0,
742
+ name: t.name,
743
+ shortName: t.short_name ?? void 0,
744
+ threeLetterCode: t.three_letter_code ?? void 0,
745
+ translations: t.translations.map(D),
746
+ displayAsset: U(t.display_asset),
747
+ slug: t.slug,
748
+ tagScore: t.tag_score ?? void 0,
749
+ sport: t.sport,
750
+ providerRef: t.id
751
751
  };
752
752
  }
753
- function qe(e) {
754
- switch (e.entity_type) {
753
+ function Me(t) {
754
+ switch (t.entity_type) {
755
755
  case "team":
756
- return K(e);
756
+ return yt(t);
757
757
  case "city":
758
- return te(e);
758
+ return Pt(t);
759
759
  case "horse":
760
- return be(e);
760
+ return Ee(t);
761
761
  case "player":
762
- return ke(e);
762
+ return Fe(t);
763
763
  case "coach":
764
- return He(e);
764
+ return Le(t);
765
765
  case "referee":
766
- return Ue(e);
766
+ return be(t);
767
767
  case "venue":
768
- return Be(e);
768
+ return Ne(t);
769
769
  case "tournament":
770
770
  case "competition":
771
- return $e(e);
771
+ return Re(t);
772
772
  case "match":
773
- return xe(e);
773
+ return Ie(t);
774
774
  case "country":
775
- return We(e);
775
+ return Pe(t);
776
776
  default: {
777
- const t = e;
778
- throw new Error(`Unknown entity type: ${t.entity_type}`);
777
+ const e = t;
778
+ throw new Error(`Unknown entity type: ${e.entity_type}`);
779
779
  }
780
780
  }
781
781
  }
782
- async function Et(e = {}, t) {
783
- const o = t ?? A(), n = {};
784
- e.name && (n.name = e.name), e.entityTypes && e.entityTypes.length > 0 && (n.entity_type = e.entityTypes.join(",")), e.sports && e.sports.length > 0 && (n.sport = e.sports.join(",")), e.eventStartTime && (n.event_start_time = e.eventStartTime), e.ids && e.ids.length > 0 && (n.ids = e.ids.join(",")), e.competitionIds && e.competitionIds.length > 0 && (n.competition_ids = e.competitionIds.join(",")), e.domain && (n.domain = e.domain), e.inputLanguage && (n.input_language = e.inputLanguage), e.translationLanguage && (n.translation_language = e.translationLanguage), e.limit !== void 0 && (n.limit = e.limit.toString()), e.offset !== void 0 && (n.offset = e.offset.toString());
785
- const s = await Pe.get({
782
+ async function qn(t = {}, e) {
783
+ const n = e ?? b(), o = {};
784
+ t.name && (o.name = t.name), t.entityTypes && t.entityTypes.length > 0 && (o.entity_type = t.entityTypes.join(",")), t.sports && t.sports.length > 0 && (o.sport = t.sports.join(",")), t.eventStartTime && (o.event_start_time = t.eventStartTime), t.ids && t.ids.length > 0 && (o.ids = t.ids.join(",")), t.competitionIds && t.competitionIds.length > 0 && (o.competition_ids = t.competitionIds.join(",")), t.domain && (o.domain = t.domain), t.inputLanguage && (o.input_language = t.inputLanguage), t.translationLanguage && (o.translation_language = t.translationLanguage), t.limit !== void 0 && (o.limit = t.limit.toString()), t.offset !== void 0 && (o.offset = t.offset.toString());
785
+ const s = await Oe.get({
786
786
  path: "/suggest",
787
- params: n,
788
- next: e.next,
789
- config: o
787
+ params: o,
788
+ next: t.next,
789
+ config: n
790
790
  });
791
791
  return !s.results || s.results.length === 0 ? {
792
792
  results: [],
793
- query: e.name
793
+ query: t.name
794
794
  } : {
795
- results: s.results.map(qe),
796
- query: e.name
795
+ results: s.results.map(Me),
796
+ query: t.name
797
+ };
798
+ }
799
+ const Ge = ot(Jt);
800
+ function De(t) {
801
+ const e = {
802
+ RANK: null,
803
+ // rank is a top-level field, not a stat
804
+ PLAYED: "played",
805
+ WINS: "won",
806
+ DRAWS: "drawn",
807
+ LOSSES: "lost",
808
+ GOALS_FOR: "goalsFor",
809
+ GOALS_AGAINST: "goalsAgainst",
810
+ POINTS: "points"
811
+ };
812
+ return t in e ? e[t] : t.toLowerCase().replace(/_/g, "");
813
+ }
814
+ function Mt(t) {
815
+ return {
816
+ CHAMPIONS_LEAGUE: "championsLeague",
817
+ CHAMPIONS_LEAGUE_QUAL: "championsLeagueQual",
818
+ CHAMPIONS_LEAGUE_8: "championsLeague8",
819
+ CHAMPIONS_LEAGUE_PLAYOFF_16: "championsLeaguePlayoff16",
820
+ PLAYOFF_TO_CHAMPIONS_LEAGUE: "playoffChampionsLeague",
821
+ PLAYOFF_TO_CHAMPIONS_LEAGUE_QUAL: "playoffChampionsLeagueQual",
822
+ UEFA_CUP: "europaLeague",
823
+ UEFA_QUAL: "europaLeagueQual",
824
+ UEFA_QUAL_PLAYOFF: "europaLeagueQualPlayoff",
825
+ PLAYOFF_TO_UEFA_QUAL: "playoffEuropaLeagueQual",
826
+ EUROPA_LEAGUE_8: "europaLeague8",
827
+ EUROPA_LEAGUE_PLAYOFF_16: "europaLeaguePlayoff16",
828
+ EUROPA_CONFERENCE_LEAGUE_PLAYOFF: "europaConferenceLeaguePlayoff",
829
+ EUROPA_CONFERENCE_LEAGUE_QUALIFICATION: "europaConferenceLeagueQual",
830
+ CONFERENCE_LEAGUE_8: "conferenceLeague8",
831
+ CONFERENCE_LEAGUE_PLAYOFF_16: "conferenceLeaguePlayoff16",
832
+ RELEGATION: "relegation",
833
+ RELEGATION_PLAYOFF: "relegationPlayoff",
834
+ PROMOTION: "promotion",
835
+ PROMOTION_PLAYOFF: "promotionPlayoff",
836
+ QUALIFICATION_TO_NEXT_STAGE: "qualificationNextStage",
837
+ POSSIBLE_QUALIFICATION_TO_NEXT_STAGE: "possibleQualificationNextStage",
838
+ CHAMPIONSHIP_PLAYOFF: "championshipPlayoff",
839
+ OVERALL_CHAMPIONSHIP_PLAYOFF: "overallChampionshipPlayoff",
840
+ CONFERENCE_CHAMPIONSHIP_PLAYOFF: "conferenceChampionshipPlayoff",
841
+ POSSIBLE_CONFERENCE_CHAMPIONSHIP_PLAYOFF: "possibleConferenceChampionshipPlayoff",
842
+ DIVISION_CHAMPIONSHIP_PLAYOFF: "divisionChampionshipPlayoff",
843
+ COPA_LIBERTADORES: "copaLibertadores",
844
+ PLAYOFF_TO_COPA_LIBERTADORES: "playoffCopaLibertadores",
845
+ PLAYOFF_TO_COPA_LIBERTADORES_QUAL: "playoffCopaLibertadoresQual",
846
+ PLAYOFF_TO_COPA_SUDAMERICANA: "playoffCopaSudamericana",
847
+ PLAYOFF_TO_CONCACAF_CHAMPIONS_LEAGUE: "playoffConcacafChampionsLeague",
848
+ CAF_CHAMPIONS_QUAL: "cafChampionsQual",
849
+ CAF_CONFEGERATION_CUP_QUAL: "cafConfederationCupQual",
850
+ CFU_CLUB_CHAMPIONSHIP: "cfuClubChampionship",
851
+ AFC_CHAMPIONS_LEAGUE: "afcChampionsLeague",
852
+ AFC_CHAMPIONS_LEAGUE_QUAL: "afcChampionsLeagueQual",
853
+ PLAYOFF_TO_AFC_CHAMPIONS_LEAGUE_QUAL: "playoffAfcChampionsLeagueQual",
854
+ WORLD_CUP: "worldCup"
855
+ }[t] ?? t.toLowerCase().replace(/_/g, "");
856
+ }
857
+ function Ue(t) {
858
+ return t === "RELEGATION" || t === "RELEGATION_PLAYOFF" ? "BOTTOM" : t.includes("PLAYOFF") ? "MIDDLE" : "TOP";
859
+ }
860
+ function xe(t, e) {
861
+ if (!e || e.length === 0) return;
862
+ const n = {
863
+ win: "W",
864
+ loss: "L",
865
+ draw: "D"
866
+ }, o = e.map((s) => {
867
+ const i = s.participants.find((u) => u.id === t), r = s.participants.find((u) => u.id !== t), a = i?.position === "1", c = s.result.find((u) => u.type === "display"), d = c?.results.find((u) => u.position === "1")?.value, f = c?.results.find((u) => u.position === "2")?.value, l = d && f ? `${d}-${f}` : void 0;
868
+ return {
869
+ matchId: s.id,
870
+ result: n[s.outcome] ?? "L",
871
+ score: l,
872
+ homeAway: a ? "HOME" : "AWAY",
873
+ opponent: {
874
+ id: r?.id ?? "",
875
+ name: r?.name ?? "",
876
+ logo: r?.display_asset?.url
877
+ },
878
+ date: new Date(s.start_time),
879
+ competition: s.competition ? {
880
+ id: s.competition.id,
881
+ name: s.competition.name
882
+ } : void 0
883
+ };
884
+ });
885
+ return {
886
+ competitorId: t,
887
+ results: o,
888
+ formString: o.map((s) => s.result).join("")
889
+ };
890
+ }
891
+ function He(t) {
892
+ const e = {};
893
+ for (const n of t) {
894
+ const o = De(n.type.code);
895
+ o && (e[o] = Number(n.value));
896
+ }
897
+ return e.goalsFor != null && e.goalsAgainst != null && e.goalDifference == null && (e.goalDifference = e.goalsFor - e.goalsAgainst), e;
898
+ }
899
+ function ke(t) {
900
+ const e = t.find((n) => n.type.code === "RANK");
901
+ return e ? Number(e.value) : 0;
902
+ }
903
+ function $e(t) {
904
+ const e = t.rules?.length > 0 ? t.rules.map((n) => Mt(n.standing_api_rule_type)) : void 0;
905
+ return {
906
+ rank: ke(t.columns),
907
+ competitor: {
908
+ id: t.team.id,
909
+ name: t.team.name,
910
+ shortName: t.team.short_name ?? void 0,
911
+ logo: void 0
912
+ // Standings API doesn't include logo in team object
913
+ },
914
+ stats: He(t.columns),
915
+ form: xe(t.team.id, t.form ?? []),
916
+ rules: e
917
+ };
918
+ }
919
+ function Be(t) {
920
+ const e = /* @__PURE__ */ new Map();
921
+ for (const n of t)
922
+ if (n.rules)
923
+ for (const o of n.rules) {
924
+ const s = Mt(o.standing_api_rule_type);
925
+ e.has(s) || e.set(s, {
926
+ key: s,
927
+ name: o.name,
928
+ position: Ue(o.type)
929
+ });
930
+ }
931
+ return Array.from(e.values());
932
+ }
933
+ function We(t) {
934
+ const e = t.standing.map($e), n = Be(t.standing);
935
+ return {
936
+ entries: e,
937
+ metadata: { legend: n }
797
938
  };
798
939
  }
799
- const Ve = V(de);
800
- function je(e, t) {
940
+ function ze(t) {
941
+ return t.standings.map((e) => ({
942
+ stage: {
943
+ id: t.stage.id,
944
+ name: t.stage.name
945
+ },
946
+ group: {
947
+ id: e.group.id,
948
+ name: e.group.name,
949
+ type: e.group.type
950
+ },
951
+ coverageType: e.type,
952
+ rankingType: e.ranking_type,
953
+ standings: We(e)
954
+ }));
955
+ }
956
+ function Ye(t) {
957
+ return !t?.data || t.data.length === 0 ? [] : t.data.flatMap(ze);
958
+ }
959
+ async function Qn(t, e) {
960
+ const n = e || b(), { sportal365Sports: o } = n, s = {
961
+ season_id: t.seasonId,
962
+ stage_id: t.stageId,
963
+ group_id: t.groupId,
964
+ coverage_type: t.coverageType,
965
+ home_away: t.homeAway,
966
+ optional_data: t.includeForm ? "form" : void 0,
967
+ row_limit: t.rowLimit?.toString(),
968
+ row_offset: t.rowOffset?.toString(),
969
+ translation_language: t.languageCode ?? o?.languageCode ?? "en"
970
+ }, i = await Ge.get({
971
+ path: `/standings/${t.sport}`,
972
+ params: s,
973
+ next: t.next,
974
+ config: n
975
+ });
976
+ return Ye(i);
977
+ }
978
+ const je = ot(Zt);
979
+ function qe(t, e) {
801
980
  return {
802
- teamId: e.id,
803
- teamName: e.name,
804
- seasonId: t,
805
- statistics: e.statistics.map((o) => ({
806
- key: o.id,
807
- value: o.value,
808
- label: o.name
981
+ teamId: t.id,
982
+ teamName: t.name,
983
+ seasonId: e,
984
+ statistics: t.statistics.map((n) => ({
985
+ key: n.id,
986
+ value: n.value,
987
+ label: n.name
809
988
  }))
810
989
  };
811
990
  }
812
- async function Mt(e, t) {
813
- const o = t || A(), n = e.next ?? { revalidate: 600 }, s = await Ve.get({
991
+ async function Vn(t, e) {
992
+ const n = e || b(), o = t.next ?? { revalidate: 600 }, s = await je.get({
814
993
  path: "/statistics/aggregate",
815
994
  params: {
816
- participant_ids: e.teamId,
817
- season_ids: e.seasonId,
995
+ participant_ids: t.teamId,
996
+ season_ids: t.seasonId,
818
997
  participant_type: "TEAM"
819
998
  },
820
- next: n,
821
- config: o
999
+ next: o,
1000
+ config: n
822
1001
  });
823
1002
  if (!s.data || s.data.length === 0)
824
- throw new Error(`No statistics found for team ${e.teamId} in season ${e.seasonId}`);
825
- return je(s.data[0], e.seasonId);
1003
+ throw new Error(`No statistics found for team ${t.teamId} in season ${t.seasonId}`);
1004
+ return qe(s.data[0], t.seasonId);
826
1005
  }
827
- function Ke(e) {
828
- const t = e.replace(/\/$/, "");
829
- function o(n) {
830
- return `${t}${n}`;
1006
+ function Gt(t) {
1007
+ const e = t.replace(/\/$/, "");
1008
+ function n(o) {
1009
+ return `${e}${o}`;
831
1010
  }
832
1011
  return {
833
- async get(n) {
834
- const s = n.config || A(), { fansUnited: i } = s;
1012
+ async get(o) {
1013
+ const s = o.config || b(), { fansUnited: i } = s;
835
1014
  if (!i)
836
1015
  throw new Error(
837
1016
  "Fans United configuration is missing. Add 'fansUnited' with 'apiKey' and 'clientId' to your config."
838
1017
  );
839
1018
  if (!i.apiKey || !i.clientId)
840
1019
  throw new Error("Fans United configuration requires both 'apiKey' and 'clientId'");
841
- const r = new URL(o(n.path));
842
- if (r.searchParams.set("key", i.apiKey), r.searchParams.set("client_id", i.clientId), n.params)
843
- for (const [u, c] of Object.entries(n.params))
844
- c !== void 0 && (Array.isArray(c) ? c.length > 0 && r.searchParams.set(u, c.join(",")) : r.searchParams.set(u, c));
845
- const a = 3e4, d = new URL(r.toString());
846
- d.searchParams.delete("key"), d.searchParams.delete("client_id"), console.log("🔗 FansUnited API URL:", d.toString());
847
- const l = await fetch(r.toString(), {
1020
+ const r = new URL(n(o.path));
1021
+ if (r.searchParams.set("key", i.apiKey), r.searchParams.set("client_id", i.clientId), o.params)
1022
+ for (const [f, l] of Object.entries(o.params))
1023
+ l !== void 0 && (Array.isArray(l) ? l.length > 0 && r.searchParams.set(f, l.join(",")) : r.searchParams.set(f, l));
1024
+ const a = 3e4, c = new URL(r.toString());
1025
+ c.searchParams.delete("key"), c.searchParams.delete("client_id"), console.log("🔗 FansUnited API URL:", c.toString());
1026
+ const d = await fetch(r.toString(), {
848
1027
  method: "GET",
849
1028
  headers: {
850
1029
  Accept: "application/json",
851
1030
  "Content-Type": "application/json",
852
1031
  // Merge custom headers (they can override defaults)
853
- ...n.headers
1032
+ ...o.headers
854
1033
  },
855
1034
  signal: AbortSignal.timeout(a),
856
1035
  // Next.js cache options for ISR/on-demand revalidation
857
- ...n.next && { next: n.next }
1036
+ ...o.next && { next: o.next }
858
1037
  });
859
- if (!l.ok) {
860
- let u = `Fans United API error: ${l.status} ${l.statusText}`;
1038
+ if (!d.ok) {
1039
+ let f = `Fans United API error: ${d.status} ${d.statusText}`;
861
1040
  try {
862
- const c = await l.text();
863
- c && (u += ` - ${c}`);
864
- } catch (c) {
1041
+ const l = await d.text();
1042
+ l && (f += ` - ${l}`);
1043
+ } catch (l) {
865
1044
  console.error("[Fans United HTTP] Failed to read error response body:", {
866
- error: c instanceof Error ? c.message : String(c),
867
- status: l.status,
868
- statusText: l.statusText
1045
+ error: l instanceof Error ? l.message : String(l),
1046
+ status: d.status,
1047
+ statusText: d.statusText
869
1048
  });
870
1049
  }
871
- throw new Error(u);
1050
+ throw new Error(f);
872
1051
  }
873
- return l.json();
1052
+ return d.json();
874
1053
  }
875
1054
  };
876
1055
  }
877
- const Ye = "https://football.fansunitedapi.com", I = Ke(Ye);
878
- function ze(e) {
1056
+ const Qe = "https://football.fansunitedapi.com", $ = Gt(Qe);
1057
+ function Ve(t) {
879
1058
  return {
880
- id: String(e.id),
881
- name: e.name,
882
- active: e.active,
1059
+ id: String(t.id),
1060
+ name: t.name,
1061
+ active: t.active,
883
1062
  providerRef: [
884
1063
  {
885
1064
  provider: "fansunited",
886
- id: String(e.id)
1065
+ id: String(t.id)
887
1066
  }
888
1067
  ]
889
1068
  };
890
1069
  }
891
- function Je(e) {
892
- const t = {
893
- id: String(e.id),
894
- name: e.name,
895
- shortName: e.short_name,
896
- slug: e.slug,
897
- type: e.type || "LEAGUE",
898
- region: e.region,
899
- gender: e.gender,
1070
+ function Ke(t) {
1071
+ const e = {
1072
+ id: String(t.id),
1073
+ name: t.name,
1074
+ shortName: t.short_name,
1075
+ slug: t.slug,
1076
+ type: t.type || "LEAGUE",
1077
+ region: t.region,
1078
+ gender: t.gender,
900
1079
  providerRef: [
901
1080
  {
902
1081
  provider: "fansunited",
903
- id: String(e.id)
1082
+ id: String(t.id)
904
1083
  }
905
1084
  ]
906
1085
  };
907
- return e.country && (t.country = {
908
- id: String(e.country.id),
909
- name: e.country.name,
910
- code: e.country.code,
911
- flag: e.country.assets?.flag,
1086
+ return t.country && (e.country = {
1087
+ id: String(t.country.id),
1088
+ name: t.country.name,
1089
+ code: t.country.code,
1090
+ flag: t.country.assets?.flag,
912
1091
  providerRef: [
913
1092
  {
914
1093
  provider: "fansunited",
915
- id: String(e.country.id)
1094
+ id: String(t.country.id)
916
1095
  }
917
1096
  ]
918
- }), e.assets?.logo && (t.assets = {
919
- logo: e.assets.logo
920
- }), e.seasons && e.seasons.length > 0 && (t.seasons = e.seasons.map(ze)), e.current_season && (t.season = {
921
- id: String(e.current_season.id),
922
- name: e.current_season.name,
923
- status: e.current_season.active ? "ACTIVE" : "INACTIVE"
924
- }), t;
925
- }
926
- function Qe(e) {
927
- return e.map(Je);
928
- }
929
- async function Lt(e, t) {
930
- const o = {};
931
- 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");
932
- const n = await I.get({
1097
+ }), t.assets?.logo && (e.assets = {
1098
+ logo: t.assets.logo
1099
+ }), t.seasons && t.seasons.length > 0 && (e.seasons = t.seasons.map(Ve)), t.current_season && (e.season = {
1100
+ id: String(t.current_season.id),
1101
+ name: t.current_season.name,
1102
+ status: t.current_season.active ? "ACTIVE" : "INACTIVE"
1103
+ }), e;
1104
+ }
1105
+ function Xe(t) {
1106
+ return t.map(Ke);
1107
+ }
1108
+ async function Kn(t, e) {
1109
+ const n = {};
1110
+ t?.lang ? n.lang = t.lang : n.lang = "EN", t?.sortField && (n.sort_field = t.sortField), t?.sortOrder && (n.sort_order = t.sortOrder), t?.page !== void 0 && (n.page = String(t.page)), t?.perPage !== void 0 && (n.per_page = String(t.perPage)), t?.countryId !== void 0 && (n.country_id = String(t.countryId)), t?.active !== void 0 && (n.active = t.active ? "1" : "0");
1111
+ const o = await $.get({
933
1112
  path: "/v1/competitions",
934
- params: o,
935
- config: t,
936
- next: e?.next
937
- }), s = n.data.map((l) => l.id), i = new Set(s);
1113
+ params: n,
1114
+ config: e,
1115
+ next: t?.next
1116
+ }), s = o.data.map((d) => d.id), i = new Set(s);
938
1117
  s.length !== i.size && console.warn("⚠️ API returned duplicate competitions!");
939
- const r = Qe(n.data), a = /* @__PURE__ */ new Set(), d = r.filter((l) => a.has(l.id) ? !1 : (a.add(l.id), !0));
940
- return r.length !== d.length && console.warn(`Removed ${r.length - d.length} duplicate competitions`), d;
1118
+ const r = Xe(o.data), a = /* @__PURE__ */ new Set(), c = r.filter((d) => a.has(d.id) ? !1 : (a.add(d.id), !0));
1119
+ return r.length !== c.length && console.warn(`Removed ${r.length - c.length} duplicate competitions`), c;
941
1120
  }
942
- function Xe(e) {
1121
+ function Je(t) {
943
1122
  return {
944
- id: e.id,
945
- name: e.name,
946
- code: e.country_code,
947
- assets: e.assets?.flag ? {
948
- flag: e.assets.flag
1123
+ id: t.id,
1124
+ name: t.name,
1125
+ code: t.country_code,
1126
+ assets: t.assets?.flag ? {
1127
+ flag: t.assets.flag
949
1128
  } : void 0,
950
1129
  providerRef: [
951
1130
  {
952
1131
  provider: "fansunited",
953
- id: e.id
1132
+ id: t.id
954
1133
  }
955
1134
  ]
956
1135
  };
957
1136
  }
958
- function Ze(e) {
1137
+ function Ze(t) {
959
1138
  return {
960
- id: e.id,
961
- name: e.name,
962
- type: e.type?.toUpperCase() || "LEAGUE",
963
- gender: e.gender?.toUpperCase(),
964
- country: e.country ? Xe(e.country) : void 0,
965
- assets: e.assets?.logo ? {
966
- logo: e.assets.logo
1139
+ id: t.id,
1140
+ name: t.name,
1141
+ type: t.type?.toUpperCase() || "LEAGUE",
1142
+ gender: t.gender?.toUpperCase(),
1143
+ country: t.country ? Je(t.country) : void 0,
1144
+ assets: t.assets?.logo ? {
1145
+ logo: t.assets.logo
967
1146
  } : void 0,
968
1147
  providerRef: [
969
1148
  {
970
1149
  provider: "fansunited",
971
- id: e.id
1150
+ id: t.id
972
1151
  }
973
1152
  ]
974
1153
  };
975
1154
  }
976
- function we(e) {
977
- return Ze(e.data);
1155
+ function we(t) {
1156
+ return Ze(t.data);
978
1157
  }
979
- async function It(e, t, o) {
980
- const n = o || A(), s = {};
981
- t?.lang && (s.lang = t.lang);
982
- const i = await I.get({
983
- path: `/v1/competitions/${e}`,
1158
+ async function Xn(t, e, n) {
1159
+ const o = n || b(), s = {};
1160
+ e?.lang && (s.lang = e.lang);
1161
+ const i = await $.get({
1162
+ path: `/v1/competitions/${t}`,
984
1163
  params: s,
985
- next: t?.next,
986
- config: n
1164
+ next: e?.next,
1165
+ config: o
987
1166
  });
988
1167
  return we(i);
989
1168
  }
990
- function et(e) {
1169
+ function tn(t) {
991
1170
  return {
992
- id: e.id,
993
- name: e.name,
994
- code: e.country_code,
995
- flag: e.assets?.flag,
1171
+ id: t.id,
1172
+ name: t.name,
1173
+ code: t.country_code,
1174
+ flag: t.assets?.flag,
996
1175
  providerRef: [
997
1176
  {
998
1177
  provider: "fansunited",
999
- id: e.id
1178
+ id: t.id
1000
1179
  }
1001
1180
  ]
1002
1181
  };
1003
1182
  }
1004
- function oe(e) {
1183
+ function Dt(t) {
1005
1184
  return {
1006
- id: e.id,
1007
- name: e.name,
1008
- shortName: e.short_name || void 0,
1009
- threeLetterCode: e.code,
1010
- type: e.national ? "national" : "club",
1011
- gender: e.gender ? e.gender.toUpperCase() : void 0,
1012
- country: e.country ? et(e.country) : void 0,
1013
- assets: e.assets?.logo ? {
1014
- logo: e.assets.logo
1185
+ id: t.id,
1186
+ name: t.name,
1187
+ shortName: t.short_name || void 0,
1188
+ threeLetterCode: t.code,
1189
+ type: t.national ? "national" : "club",
1190
+ gender: t.gender ? t.gender.toUpperCase() : void 0,
1191
+ country: t.country ? tn(t.country) : void 0,
1192
+ assets: t.assets?.logo ? {
1193
+ logo: t.assets.logo
1015
1194
  } : void 0,
1016
- metadata: e.colors ? {
1017
- shirtColors: e.colors.primary ? [
1195
+ metadata: t.colors ? {
1196
+ shirtColors: t.colors.primary ? [
1018
1197
  {
1019
1198
  type: "home",
1020
- colorCode: e.colors.primary
1199
+ colorCode: t.colors.primary
1021
1200
  }
1022
1201
  ] : void 0
1023
1202
  } : void 0,
1024
1203
  providerRef: [
1025
1204
  {
1026
1205
  provider: "fansunited",
1027
- id: e.id
1206
+ id: t.id
1028
1207
  }
1029
1208
  ]
1030
1209
  };
1031
1210
  }
1032
- function tt(e) {
1033
- return oe(e.data);
1211
+ function en(t) {
1212
+ return Dt(t.data);
1034
1213
  }
1035
- function ot(e) {
1036
- return e.data.map(oe);
1214
+ function nn(t) {
1215
+ return t.data.map(Dt);
1037
1216
  }
1038
- async function Gt(e, t, o) {
1039
- const n = o || A(), s = {};
1040
- t?.lang && (s.lang = t.lang);
1041
- const i = await I.get({
1042
- path: `/v1/teams/${e}`,
1217
+ async function Jn(t, e, n) {
1218
+ const o = n || b(), s = {};
1219
+ e?.lang && (s.lang = e.lang);
1220
+ const i = await $.get({
1221
+ path: `/v1/teams/${t}`,
1043
1222
  params: s,
1044
- next: t?.next,
1045
- config: n
1223
+ next: e?.next,
1224
+ config: o
1046
1225
  });
1047
- return tt(i);
1226
+ return en(i);
1048
1227
  }
1049
- async function Dt(e, t) {
1050
- const o = t || A(), n = {};
1051
- e?.lang && (n.lang = e.lang), e?.teamIds && (n.team_ids = e.teamIds), e?.countryId && (n.country_id = e.countryId), e?.name && (n.name = e.name), e?.scope && (n.scope = e.scope), e?.national !== void 0 && (n.national = String(e.national)), e?.gender && (n.gender = e.gender), 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);
1052
- const s = await I.get({
1228
+ async function Zn(t, e) {
1229
+ const n = e || b(), o = {};
1230
+ t?.lang && (o.lang = t.lang), t?.teamIds && (o.team_ids = t.teamIds), t?.countryId && (o.country_id = t.countryId), t?.name && (o.name = t.name), t?.scope && (o.scope = t.scope), t?.national !== void 0 && (o.national = String(t.national)), t?.gender && (o.gender = t.gender), t?.limit !== void 0 && (o.limit = String(t.limit)), t?.page !== void 0 && (o.page = String(t.page)), t?.sortField && (o.sort_field = t.sortField), t?.sortOrder && (o.sort_order = t.sortOrder);
1231
+ const s = await $.get({
1053
1232
  path: "/v1/teams",
1054
- params: n,
1055
- next: e?.next,
1056
- config: o
1233
+ params: o,
1234
+ next: t?.next,
1235
+ config: n
1057
1236
  });
1058
- return ot(s);
1237
+ return nn(s);
1059
1238
  }
1060
- function Y(e) {
1239
+ function vt(t) {
1061
1240
  return {
1062
- id: e.id,
1063
- name: e.name,
1064
- code: e.country_code,
1065
- flag: e.assets?.flag,
1241
+ id: t.id,
1242
+ name: t.name,
1243
+ code: t.country_code,
1244
+ flag: t.assets?.flag,
1066
1245
  providerRef: [
1067
1246
  {
1068
1247
  provider: "fansunited",
1069
- id: e.id
1248
+ id: t.id
1070
1249
  }
1071
1250
  ]
1072
1251
  };
1073
1252
  }
1074
- function nt(e) {
1253
+ function on(t) {
1075
1254
  return {
1076
- id: e.id,
1077
- name: e.name,
1078
- shortName: e.short_name ?? void 0,
1079
- fullName: e.full_name ?? void 0,
1080
- threeLetterCode: e.code,
1081
- type: e.national ? "national" : "club",
1082
- gender: e.gender?.toUpperCase(),
1083
- country: e.country ? Y(e.country) : void 0,
1084
- assets: e.assets?.logo ? {
1085
- logo: e.assets.logo
1255
+ id: t.id,
1256
+ name: t.name,
1257
+ shortName: t.short_name ?? void 0,
1258
+ fullName: t.full_name ?? void 0,
1259
+ threeLetterCode: t.code,
1260
+ type: t.national ? "national" : "club",
1261
+ gender: t.gender?.toUpperCase(),
1262
+ country: t.country ? vt(t.country) : void 0,
1263
+ assets: t.assets?.logo ? {
1264
+ logo: t.assets.logo
1086
1265
  } : void 0,
1087
1266
  providerRef: [
1088
1267
  {
1089
1268
  provider: "fansunited",
1090
- id: e.id
1269
+ id: t.id
1091
1270
  }
1092
1271
  ]
1093
1272
  };
1094
1273
  }
1095
- function st(e) {
1274
+ function sn(t) {
1096
1275
  return {
1097
- id: e.id,
1098
- name: e.name,
1099
- type: e.type?.toUpperCase() || "LEAGUE",
1100
- gender: e.gender?.toUpperCase(),
1101
- country: e.country ? Y(e.country) : void 0,
1102
- assets: e.assets?.logo ? {
1103
- logo: e.assets.logo
1276
+ id: t.id,
1277
+ name: t.name,
1278
+ type: t.type?.toUpperCase() || "LEAGUE",
1279
+ gender: t.gender?.toUpperCase(),
1280
+ country: t.country ? vt(t.country) : void 0,
1281
+ assets: t.assets?.logo ? {
1282
+ logo: t.assets.logo
1104
1283
  } : void 0,
1105
1284
  providerRef: [
1106
1285
  {
1107
1286
  provider: "fansunited",
1108
- id: e.id
1287
+ id: t.id
1109
1288
  }
1110
1289
  ]
1111
1290
  };
1112
1291
  }
1113
- function ne(e) {
1292
+ function Ut(t) {
1114
1293
  return {
1115
1294
  type: "player",
1116
- id: e.id,
1117
- name: e.name,
1118
- position: e.position,
1119
- birthdate: e.birth_date,
1120
- country: e.country ? Y(e.country) : void 0,
1121
- assets: e.assets?.headshot ? {
1122
- photo: e.assets.headshot
1295
+ id: t.id,
1296
+ name: t.name,
1297
+ position: t.position,
1298
+ birthdate: t.birth_date,
1299
+ country: t.country ? vt(t.country) : void 0,
1300
+ assets: t.assets?.headshot ? {
1301
+ photo: t.assets.headshot
1123
1302
  } : void 0,
1124
- teams: e.teams?.map(nt),
1125
- competitions: e.competitions?.map(st),
1303
+ teams: t.teams?.map(on),
1304
+ competitions: t.competitions?.map(sn),
1126
1305
  providerRef: [
1127
1306
  {
1128
1307
  provider: "fansunited",
1129
- id: e.id
1308
+ id: t.id
1130
1309
  }
1131
1310
  ]
1132
1311
  };
1133
1312
  }
1134
- function it(e) {
1135
- return ne(e.data);
1313
+ function rn(t) {
1314
+ return Ut(t.data);
1136
1315
  }
1137
- function rt(e) {
1138
- return e.data.map(ne);
1316
+ function an(t) {
1317
+ return t.data.map(Ut);
1139
1318
  }
1140
- async function Pt(e, t, o) {
1141
- const n = o || A(), s = {};
1142
- t?.lang && (s.lang = t.lang);
1143
- const i = await I.get({
1144
- path: `/v1/players/${e}`,
1319
+ async function wn(t, e, n) {
1320
+ const o = n || b(), s = {};
1321
+ e?.lang && (s.lang = e.lang);
1322
+ const i = await $.get({
1323
+ path: `/v1/players/${t}`,
1145
1324
  params: s,
1146
- next: t?.next,
1147
- config: n
1148
- });
1149
- return it(i);
1150
- }
1151
- async function bt(e, t) {
1152
- const o = t || A(), n = {};
1153
- 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);
1154
- const s = await I.get({
1155
- path: "/v1/players",
1156
- params: n,
1157
1325
  next: e?.next,
1158
1326
  config: o
1159
1327
  });
1160
- return rt(s);
1328
+ return rn(i);
1161
1329
  }
1162
- async function kt(e, t, o) {
1163
- const n = o || A(), s = {};
1164
- t?.lang && (s.lang = t.lang);
1165
- const i = await I.get({
1166
- path: `/v1/matches/${e}`,
1167
- params: s,
1330
+ async function to(t, e) {
1331
+ const n = e || b(), o = {};
1332
+ t?.lang && (o.lang = t.lang), t?.playerIds && (o.player_ids = t.playerIds), t?.countryId && (o.country_id = t.countryId), t?.name && (o.name = t.name), t?.scope && (o.scope = t.scope), t?.limit !== void 0 && (o.limit = String(t.limit)), t?.page !== void 0 && (o.page = String(t.page)), t?.sortField && (o.sort_field = t.sortField), t?.sortOrder && (o.sort_order = t.sortOrder);
1333
+ const s = await $.get({
1334
+ path: "/v1/players",
1335
+ params: o,
1168
1336
  next: t?.next,
1169
1337
  config: n
1170
1338
  });
1171
- return le(i);
1339
+ return an(s);
1172
1340
  }
1173
- async function Ht(e, t) {
1174
- const o = t || A(), n = {};
1175
- 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");
1176
- const s = await I.get({
1177
- path: "/v1/matches",
1178
- params: n,
1341
+ async function eo(t, e, n) {
1342
+ const o = n || b(), s = {};
1343
+ e?.lang && (s.lang = e.lang);
1344
+ const i = await $.get({
1345
+ path: `/v1/matches/${t}`,
1346
+ params: s,
1179
1347
  next: e?.next,
1180
1348
  config: o
1181
1349
  });
1182
- return ue(s);
1350
+ return wt(i);
1183
1351
  }
1184
- function z(e) {
1352
+ async function no(t, e) {
1353
+ const n = e || b(), o = {};
1354
+ t?.lang && (o.lang = t.lang), t?.competitions && (o.competitions = t.competitions), t?.countries && (o.countries = t.countries), t?.fromDate && (o.from_date = t.fromDate), t?.toDate && (o.to_date = t.toDate), t?.matches && (o.matches = t.matches), t?.teams && (o.teams = t.teams), t?.status && (o.status = t.status), t?.limit !== void 0 && (o.limit = String(t.limit)), t?.page !== void 0 && (o.page = String(t.page)), t?.sortField && (o.sort_field = t.sortField), t?.sortOrder && (o.sort_order = t.sortOrder), t?.showDeleted !== void 0 && (o.show_deleted = t.showDeleted ? "true" : "false");
1355
+ const s = await $.get({
1356
+ path: "/v1/matches",
1357
+ params: o,
1358
+ next: t?.next,
1359
+ config: n
1360
+ });
1361
+ return te(s);
1362
+ }
1363
+ function St(t) {
1185
1364
  return {
1186
- id: e.id,
1187
- name: e.name,
1188
- code: e.country_code,
1189
- flag: e.assets?.flag || void 0,
1365
+ id: t.id,
1366
+ name: t.name,
1367
+ code: t.country_code,
1368
+ flag: t.assets?.flag || void 0,
1190
1369
  providerRef: [
1191
1370
  {
1192
1371
  provider: "fansunited",
1193
- id: e.id
1372
+ id: t.id
1194
1373
  }
1195
1374
  ]
1196
1375
  };
1197
1376
  }
1198
- function at(e) {
1377
+ function cn(t) {
1199
1378
  return {
1200
- id: e.id,
1201
- name: e.name,
1202
- shortName: e.short_name || void 0,
1203
- type: e.type || "LEAGUE",
1204
- region: e.region,
1205
- gender: e.gender?.toUpperCase(),
1206
- country: e.country ? z(e.country) : void 0,
1207
- assets: e.assets?.logo ? {
1208
- logo: e.assets.logo
1379
+ id: t.id,
1380
+ name: t.name,
1381
+ shortName: t.short_name || void 0,
1382
+ type: t.type || "LEAGUE",
1383
+ region: t.region,
1384
+ gender: t.gender?.toUpperCase(),
1385
+ country: t.country ? St(t.country) : void 0,
1386
+ assets: t.assets?.logo ? {
1387
+ logo: t.assets.logo
1209
1388
  } : void 0,
1210
1389
  providerRef: [
1211
1390
  {
1212
1391
  provider: "fansunited",
1213
- id: e.id
1392
+ id: t.id
1214
1393
  }
1215
1394
  ]
1216
1395
  };
1217
1396
  }
1218
- function ct(e) {
1397
+ function ln(t) {
1219
1398
  return {
1220
1399
  type: "player",
1221
- id: e.id,
1222
- name: e.name,
1223
- position: e.position || void 0,
1224
- gender: e.gender?.toUpperCase(),
1225
- birthdate: e.birth_date || void 0,
1226
- country: e.country ? z(e.country) : void 0,
1227
- assets: e.assets?.headshot ? {
1228
- photo: e.assets.headshot
1400
+ id: t.id,
1401
+ name: t.name,
1402
+ position: t.position || void 0,
1403
+ gender: t.gender?.toUpperCase(),
1404
+ birthdate: t.birth_date || void 0,
1405
+ country: t.country ? St(t.country) : void 0,
1406
+ assets: t.assets?.headshot ? {
1407
+ photo: t.assets.headshot
1229
1408
  } : void 0,
1230
1409
  providerRef: [
1231
1410
  {
1232
1411
  provider: "fansunited",
1233
- id: e.id
1412
+ id: t.id
1234
1413
  }
1235
1414
  ]
1236
1415
  };
1237
1416
  }
1238
- function dt(e) {
1417
+ function dn(t) {
1239
1418
  return {
1240
- type: e.national ? "national" : "club",
1241
- id: e.id,
1242
- name: e.name,
1243
- shortName: e.short_name || void 0,
1244
- threeLetterCode: e.code || void 0,
1245
- gender: e.gender?.toUpperCase(),
1246
- country: e.country ? z(e.country) : void 0,
1247
- assets: e.assets?.logo ? {
1248
- logo: e.assets.logo
1419
+ type: t.national ? "national" : "club",
1420
+ id: t.id,
1421
+ name: t.name,
1422
+ shortName: t.short_name || void 0,
1423
+ threeLetterCode: t.code || void 0,
1424
+ gender: t.gender?.toUpperCase(),
1425
+ country: t.country ? St(t.country) : void 0,
1426
+ assets: t.assets?.logo ? {
1427
+ logo: t.assets.logo
1249
1428
  } : void 0,
1250
1429
  providerRef: [
1251
1430
  {
1252
1431
  provider: "fansunited",
1253
- id: e.id
1432
+ id: t.id
1254
1433
  }
1255
1434
  ]
1256
1435
  };
1257
1436
  }
1258
- function j(e) {
1259
- switch (e.entity_type) {
1437
+ function gt(t) {
1438
+ switch (t.entity_type) {
1260
1439
  case "competition": {
1261
- const t = at(e);
1440
+ const e = cn(t);
1262
1441
  return {
1263
1442
  source: "FOOTBALL",
1264
1443
  entityType: "competition",
1265
- entityId: e.id,
1266
- entityData: t
1444
+ entityId: t.id,
1445
+ entityData: e
1267
1446
  };
1268
1447
  }
1269
1448
  case "player": {
1270
- const t = ct(e);
1449
+ const e = ln(t);
1271
1450
  return {
1272
1451
  source: "FOOTBALL",
1273
1452
  entityType: "player",
1274
- entityId: e.id,
1275
- entityData: t
1453
+ entityId: t.id,
1454
+ entityData: e
1276
1455
  };
1277
1456
  }
1278
1457
  case "team": {
1279
- const t = dt(e);
1458
+ const e = dn(t);
1280
1459
  return {
1281
1460
  source: "FOOTBALL",
1282
1461
  entityType: "team",
1283
- entityId: e.id,
1284
- entityData: t
1462
+ entityId: t.id,
1463
+ entityData: e
1285
1464
  };
1286
1465
  }
1287
1466
  case "venue":
1288
1467
  case "coach":
1289
1468
  return null;
1290
1469
  default:
1291
- throw new Error(`Unknown entity type: ${e.entity_type}`);
1470
+ throw new Error(`Unknown entity type: ${t.entity_type}`);
1292
1471
  }
1293
1472
  }
1294
- async function Ut(e, t) {
1295
- if (!e.query || e.query.trim() === "")
1473
+ async function oo(t, e) {
1474
+ if (!t.query || t.query.trim() === "")
1296
1475
  return [];
1297
- const o = t || A(), n = {
1298
- q: e.query.trim()
1299
- }, i = (e.entityTypes && e.entityTypes.length > 0 ? e.entityTypes : ["competition", "team", "player"]).map((d) => {
1300
- switch (d) {
1476
+ const n = e || b(), o = {
1477
+ q: t.query.trim()
1478
+ }, i = (t.entityTypes && t.entityTypes.length > 0 ? t.entityTypes : ["competition", "team", "player"]).map((c) => {
1479
+ switch (c) {
1301
1480
  case "team":
1302
1481
  return "teams";
1303
1482
  case "player":
@@ -1305,93 +1484,1219 @@ async function Ut(e, t) {
1305
1484
  case "competition":
1306
1485
  return "competitions";
1307
1486
  default:
1308
- return d;
1487
+ return c;
1309
1488
  }
1310
1489
  });
1311
- n.entities = i.join(","), e.lang && (n.lang = e.lang), e.limit && (n.limit = String(e.limit));
1312
- const r = await I.get({
1490
+ o.entities = i.join(","), t.lang && (o.lang = t.lang), t.limit && (o.limit = String(t.limit));
1491
+ const r = await $.get({
1313
1492
  path: "/v1/search",
1314
- params: n,
1315
- next: e.next,
1316
- config: o
1493
+ params: o,
1494
+ next: t.next,
1495
+ config: n
1317
1496
  }), a = [];
1318
- return r.data && (r.data.competitions && r.data.competitions.forEach((d) => {
1319
- const l = j({ ...d, entity_type: "competition" });
1320
- l && a.push(l);
1321
- }), r.data.teams && r.data.teams.forEach((d) => {
1322
- const l = j({ ...d, entity_type: "team" });
1323
- l && a.push(l);
1324
- }), r.data.players && r.data.players.forEach((d) => {
1325
- const l = j({ ...d, entity_type: "player" });
1326
- l && a.push(l);
1497
+ return r.data && (r.data.competitions && r.data.competitions.forEach((c) => {
1498
+ const d = gt({ ...c, entity_type: "competition" });
1499
+ d && a.push(d);
1500
+ }), r.data.teams && r.data.teams.forEach((c) => {
1501
+ const d = gt({ ...c, entity_type: "team" });
1502
+ d && a.push(d);
1503
+ }), r.data.players && r.data.players.forEach((c) => {
1504
+ const d = gt({ ...c, entity_type: "player" });
1505
+ d && a.push(d);
1327
1506
  })), a;
1328
1507
  }
1329
- function Bt(e) {
1330
- return !e.seasons || e.seasons.length === 0 ? void 0 : e.seasons.find((o) => o.active) ?? e.seasons[0];
1508
+ const un = "https://search.fansunitedapi.com", B = Gt(un);
1509
+ var fn = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date, xt = /* @__PURE__ */ new Set(), Tt = typeof process == "object" && process ? process : {}, Ht = (t, e, n, o) => {
1510
+ typeof Tt.emitWarning == "function" ? Tt.emitWarning(t, e, n, o) : console.error(`[${n}] ${e}: ${t}`);
1511
+ }, ut = globalThis.AbortController, Ft = globalThis.AbortSignal;
1512
+ if (typeof ut > "u") {
1513
+ Ft = class {
1514
+ onabort;
1515
+ _onabort = [];
1516
+ reason;
1517
+ aborted = !1;
1518
+ addEventListener(n, o) {
1519
+ this._onabort.push(o);
1520
+ }
1521
+ }, ut = class {
1522
+ constructor() {
1523
+ e();
1524
+ }
1525
+ signal = new Ft();
1526
+ abort(n) {
1527
+ if (!this.signal.aborted) {
1528
+ this.signal.reason = n, this.signal.aborted = !0;
1529
+ for (let o of this.signal._onabort) o(n);
1530
+ this.signal.onabort?.(n);
1531
+ }
1532
+ }
1533
+ };
1534
+ let t = Tt.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", e = () => {
1535
+ t && (t = !1, Ht("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", e));
1536
+ };
1331
1537
  }
1332
- function $t(e, t) {
1333
- const o = /* @__PURE__ */ new Date(), n = t.filter((s) => {
1334
- const i = s.competitorOne.id === e || s.competitorTwo.id === e, r = s.status.type === "NOT_STARTED", a = new Date(s.timing.kickoffTime) >= o;
1538
+ var hn = (t) => !xt.has(t), W = (t) => t && t === Math.floor(t) && t > 0 && isFinite(t), kt = (t) => W(t) ? t <= Math.pow(2, 8) ? Uint8Array : t <= Math.pow(2, 16) ? Uint16Array : t <= Math.pow(2, 32) ? Uint32Array : t <= Number.MAX_SAFE_INTEGER ? dt : null : null, dt = class extends Array {
1539
+ constructor(t) {
1540
+ super(t), this.fill(0);
1541
+ }
1542
+ }, mn = class et {
1543
+ heap;
1544
+ length;
1545
+ static #a = !1;
1546
+ static create(e) {
1547
+ let n = kt(e);
1548
+ if (!n) return [];
1549
+ et.#a = !0;
1550
+ let o = new et(e, n);
1551
+ return et.#a = !1, o;
1552
+ }
1553
+ constructor(e, n) {
1554
+ if (!et.#a) throw new TypeError("instantiate Stack using Stack.create(n)");
1555
+ this.heap = new n(e), this.length = 0;
1556
+ }
1557
+ push(e) {
1558
+ this.heap[this.length++] = e;
1559
+ }
1560
+ pop() {
1561
+ return this.heap[--this.length];
1562
+ }
1563
+ }, gn = class $t {
1564
+ #a;
1565
+ #u;
1566
+ #p;
1567
+ #N;
1568
+ #y;
1569
+ #M;
1570
+ #G;
1571
+ #T;
1572
+ get perf() {
1573
+ return this.#T;
1574
+ }
1575
+ ttl;
1576
+ ttlResolution;
1577
+ ttlAutopurge;
1578
+ updateAgeOnGet;
1579
+ updateAgeOnHas;
1580
+ allowStale;
1581
+ noDisposeOnSet;
1582
+ noUpdateTTL;
1583
+ maxEntrySize;
1584
+ sizeCalculation;
1585
+ noDeleteOnFetchRejection;
1586
+ noDeleteOnStaleGet;
1587
+ allowStaleOnFetchAbort;
1588
+ allowStaleOnFetchRejection;
1589
+ ignoreFetchAbort;
1590
+ #s;
1591
+ #_;
1592
+ #o;
1593
+ #n;
1594
+ #t;
1595
+ #l;
1596
+ #f;
1597
+ #c;
1598
+ #i;
1599
+ #v;
1600
+ #r;
1601
+ #S;
1602
+ #A;
1603
+ #h;
1604
+ #m;
1605
+ #C;
1606
+ #b;
1607
+ #d;
1608
+ #D;
1609
+ static unsafeExposeInternals(e) {
1610
+ return { starts: e.#A, ttls: e.#h, autopurgeTimers: e.#m, sizes: e.#S, keyMap: e.#o, keyList: e.#n, valList: e.#t, next: e.#l, prev: e.#f, get head() {
1611
+ return e.#c;
1612
+ }, get tail() {
1613
+ return e.#i;
1614
+ }, free: e.#v, isBackgroundFetch: (n) => e.#e(n), backgroundFetch: (n, o, s, i) => e.#H(n, o, s, i), moveToTail: (n) => e.#P(n), indexes: (n) => e.#O(n), rindexes: (n) => e.#E(n), isStale: (n) => e.#g(n) };
1615
+ }
1616
+ get max() {
1617
+ return this.#a;
1618
+ }
1619
+ get maxSize() {
1620
+ return this.#u;
1621
+ }
1622
+ get calculatedSize() {
1623
+ return this.#_;
1624
+ }
1625
+ get size() {
1626
+ return this.#s;
1627
+ }
1628
+ get fetchMethod() {
1629
+ return this.#M;
1630
+ }
1631
+ get memoMethod() {
1632
+ return this.#G;
1633
+ }
1634
+ get dispose() {
1635
+ return this.#p;
1636
+ }
1637
+ get onInsert() {
1638
+ return this.#N;
1639
+ }
1640
+ get disposeAfter() {
1641
+ return this.#y;
1642
+ }
1643
+ constructor(e) {
1644
+ let { max: n = 0, ttl: o, ttlResolution: s = 1, ttlAutopurge: i, updateAgeOnGet: r, updateAgeOnHas: a, allowStale: c, dispose: d, onInsert: f, disposeAfter: l, noDisposeOnSet: u, noUpdateTTL: h, maxSize: p = 0, maxEntrySize: y = 0, sizeCalculation: S, fetchMethod: g, memoMethod: T, noDeleteOnFetchRejection: A, noDeleteOnStaleGet: C, allowStaleOnFetchRejection: v, allowStaleOnFetchAbort: R, ignoreFetchAbort: P, perf: M } = e;
1645
+ if (M !== void 0 && typeof M?.now != "function") throw new TypeError("perf option must have a now() method if specified");
1646
+ if (this.#T = M ?? fn, n !== 0 && !W(n)) throw new TypeError("max option must be a nonnegative integer");
1647
+ let m = n ? kt(n) : Array;
1648
+ if (!m) throw new Error("invalid max value: " + n);
1649
+ if (this.#a = n, this.#u = p, this.maxEntrySize = y || this.#u, this.sizeCalculation = S, this.sizeCalculation) {
1650
+ if (!this.#u && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
1651
+ if (typeof this.sizeCalculation != "function") throw new TypeError("sizeCalculation set to non-function");
1652
+ }
1653
+ if (T !== void 0 && typeof T != "function") throw new TypeError("memoMethod must be a function if defined");
1654
+ if (this.#G = T, g !== void 0 && typeof g != "function") throw new TypeError("fetchMethod must be a function if specified");
1655
+ if (this.#M = g, this.#b = !!g, this.#o = /* @__PURE__ */ new Map(), this.#n = new Array(n).fill(void 0), this.#t = new Array(n).fill(void 0), this.#l = new m(n), this.#f = new m(n), this.#c = 0, this.#i = 0, this.#v = mn.create(n), this.#s = 0, this.#_ = 0, typeof d == "function" && (this.#p = d), typeof f == "function" && (this.#N = f), typeof l == "function" ? (this.#y = l, this.#r = []) : (this.#y = void 0, this.#r = void 0), this.#C = !!this.#p, this.#D = !!this.#N, this.#d = !!this.#y, this.noDisposeOnSet = !!u, this.noUpdateTTL = !!h, this.noDeleteOnFetchRejection = !!A, this.allowStaleOnFetchRejection = !!v, this.allowStaleOnFetchAbort = !!R, this.ignoreFetchAbort = !!P, this.maxEntrySize !== 0) {
1656
+ if (this.#u !== 0 && !W(this.#u)) throw new TypeError("maxSize must be a positive integer if specified");
1657
+ if (!W(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
1658
+ this.#j();
1659
+ }
1660
+ if (this.allowStale = !!c, this.noDeleteOnStaleGet = !!C, this.updateAgeOnGet = !!r, this.updateAgeOnHas = !!a, this.ttlResolution = W(s) || s === 0 ? s : 1, this.ttlAutopurge = !!i, this.ttl = o || 0, this.ttl) {
1661
+ if (!W(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
1662
+ this.#k();
1663
+ }
1664
+ if (this.#a === 0 && this.ttl === 0 && this.#u === 0) throw new TypeError("At least one of max, maxSize, or ttl is required");
1665
+ if (!this.ttlAutopurge && !this.#a && !this.#u) {
1666
+ let O = "LRU_CACHE_UNBOUNDED";
1667
+ hn(O) && (xt.add(O), Ht("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", O, $t));
1668
+ }
1669
+ }
1670
+ getRemainingTTL(e) {
1671
+ return this.#o.has(e) ? 1 / 0 : 0;
1672
+ }
1673
+ #k() {
1674
+ let e = new dt(this.#a), n = new dt(this.#a);
1675
+ this.#h = e, this.#A = n;
1676
+ let o = this.ttlAutopurge ? new Array(this.#a) : void 0;
1677
+ this.#m = o, this.#$ = (r, a, c = this.#T.now()) => {
1678
+ if (n[r] = a !== 0 ? c : 0, e[r] = a, o?.[r] && (clearTimeout(o[r]), o[r] = void 0), a !== 0 && o) {
1679
+ let d = setTimeout(() => {
1680
+ this.#g(r) && this.#F(this.#n[r], "expire");
1681
+ }, a + 1);
1682
+ d.unref && d.unref(), o[r] = d;
1683
+ }
1684
+ }, this.#R = (r) => {
1685
+ n[r] = e[r] !== 0 ? this.#T.now() : 0;
1686
+ }, this.#L = (r, a) => {
1687
+ if (e[a]) {
1688
+ let c = e[a], d = n[a];
1689
+ if (!c || !d) return;
1690
+ r.ttl = c, r.start = d, r.now = s || i();
1691
+ let f = r.now - d;
1692
+ r.remainingTTL = c - f;
1693
+ }
1694
+ };
1695
+ let s = 0, i = () => {
1696
+ let r = this.#T.now();
1697
+ if (this.ttlResolution > 0) {
1698
+ s = r;
1699
+ let a = setTimeout(() => s = 0, this.ttlResolution);
1700
+ a.unref && a.unref();
1701
+ }
1702
+ return r;
1703
+ };
1704
+ this.getRemainingTTL = (r) => {
1705
+ let a = this.#o.get(r);
1706
+ if (a === void 0) return 0;
1707
+ let c = e[a], d = n[a];
1708
+ if (!c || !d) return 1 / 0;
1709
+ let f = (s || i()) - d;
1710
+ return c - f;
1711
+ }, this.#g = (r) => {
1712
+ let a = n[r], c = e[r];
1713
+ return !!c && !!a && (s || i()) - a > c;
1714
+ };
1715
+ }
1716
+ #R = () => {
1717
+ };
1718
+ #L = () => {
1719
+ };
1720
+ #$ = () => {
1721
+ };
1722
+ #g = () => !1;
1723
+ #j() {
1724
+ let e = new dt(this.#a);
1725
+ this.#_ = 0, this.#S = e, this.#I = (n) => {
1726
+ this.#_ -= e[n], e[n] = 0;
1727
+ }, this.#B = (n, o, s, i) => {
1728
+ if (this.#e(o)) return 0;
1729
+ if (!W(s)) if (i) {
1730
+ if (typeof i != "function") throw new TypeError("sizeCalculation must be a function");
1731
+ if (s = i(o, n), !W(s)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
1732
+ } else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
1733
+ return s;
1734
+ }, this.#U = (n, o, s) => {
1735
+ if (e[n] = o, this.#u) {
1736
+ let i = this.#u - e[n];
1737
+ for (; this.#_ > i; ) this.#x(!0);
1738
+ }
1739
+ this.#_ += e[n], s && (s.entrySize = o, s.totalCalculatedSize = this.#_);
1740
+ };
1741
+ }
1742
+ #I = (e) => {
1743
+ };
1744
+ #U = (e, n, o) => {
1745
+ };
1746
+ #B = (e, n, o, s) => {
1747
+ if (o || s) throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
1748
+ return 0;
1749
+ };
1750
+ *#O({ allowStale: e = this.allowStale } = {}) {
1751
+ if (this.#s) for (let n = this.#i; !(!this.#W(n) || ((e || !this.#g(n)) && (yield n), n === this.#c)); ) n = this.#f[n];
1752
+ }
1753
+ *#E({ allowStale: e = this.allowStale } = {}) {
1754
+ if (this.#s) for (let n = this.#c; !(!this.#W(n) || ((e || !this.#g(n)) && (yield n), n === this.#i)); ) n = this.#l[n];
1755
+ }
1756
+ #W(e) {
1757
+ return e !== void 0 && this.#o.get(this.#n[e]) === e;
1758
+ }
1759
+ *entries() {
1760
+ for (let e of this.#O()) this.#t[e] !== void 0 && this.#n[e] !== void 0 && !this.#e(this.#t[e]) && (yield [this.#n[e], this.#t[e]]);
1761
+ }
1762
+ *rentries() {
1763
+ for (let e of this.#E()) this.#t[e] !== void 0 && this.#n[e] !== void 0 && !this.#e(this.#t[e]) && (yield [this.#n[e], this.#t[e]]);
1764
+ }
1765
+ *keys() {
1766
+ for (let e of this.#O()) {
1767
+ let n = this.#n[e];
1768
+ n !== void 0 && !this.#e(this.#t[e]) && (yield n);
1769
+ }
1770
+ }
1771
+ *rkeys() {
1772
+ for (let e of this.#E()) {
1773
+ let n = this.#n[e];
1774
+ n !== void 0 && !this.#e(this.#t[e]) && (yield n);
1775
+ }
1776
+ }
1777
+ *values() {
1778
+ for (let e of this.#O()) this.#t[e] !== void 0 && !this.#e(this.#t[e]) && (yield this.#t[e]);
1779
+ }
1780
+ *rvalues() {
1781
+ for (let e of this.#E()) this.#t[e] !== void 0 && !this.#e(this.#t[e]) && (yield this.#t[e]);
1782
+ }
1783
+ [Symbol.iterator]() {
1784
+ return this.entries();
1785
+ }
1786
+ [Symbol.toStringTag] = "LRUCache";
1787
+ find(e, n = {}) {
1788
+ for (let o of this.#O()) {
1789
+ let s = this.#t[o], i = this.#e(s) ? s.__staleWhileFetching : s;
1790
+ if (i !== void 0 && e(i, this.#n[o], this)) return this.get(this.#n[o], n);
1791
+ }
1792
+ }
1793
+ forEach(e, n = this) {
1794
+ for (let o of this.#O()) {
1795
+ let s = this.#t[o], i = this.#e(s) ? s.__staleWhileFetching : s;
1796
+ i !== void 0 && e.call(n, i, this.#n[o], this);
1797
+ }
1798
+ }
1799
+ rforEach(e, n = this) {
1800
+ for (let o of this.#E()) {
1801
+ let s = this.#t[o], i = this.#e(s) ? s.__staleWhileFetching : s;
1802
+ i !== void 0 && e.call(n, i, this.#n[o], this);
1803
+ }
1804
+ }
1805
+ purgeStale() {
1806
+ let e = !1;
1807
+ for (let n of this.#E({ allowStale: !0 })) this.#g(n) && (this.#F(this.#n[n], "expire"), e = !0);
1808
+ return e;
1809
+ }
1810
+ info(e) {
1811
+ let n = this.#o.get(e);
1812
+ if (n === void 0) return;
1813
+ let o = this.#t[n], s = this.#e(o) ? o.__staleWhileFetching : o;
1814
+ if (s === void 0) return;
1815
+ let i = { value: s };
1816
+ if (this.#h && this.#A) {
1817
+ let r = this.#h[n], a = this.#A[n];
1818
+ if (r && a) {
1819
+ let c = r - (this.#T.now() - a);
1820
+ i.ttl = c, i.start = Date.now();
1821
+ }
1822
+ }
1823
+ return this.#S && (i.size = this.#S[n]), i;
1824
+ }
1825
+ dump() {
1826
+ let e = [];
1827
+ for (let n of this.#O({ allowStale: !0 })) {
1828
+ let o = this.#n[n], s = this.#t[n], i = this.#e(s) ? s.__staleWhileFetching : s;
1829
+ if (i === void 0 || o === void 0) continue;
1830
+ let r = { value: i };
1831
+ if (this.#h && this.#A) {
1832
+ r.ttl = this.#h[n];
1833
+ let a = this.#T.now() - this.#A[n];
1834
+ r.start = Math.floor(Date.now() - a);
1835
+ }
1836
+ this.#S && (r.size = this.#S[n]), e.unshift([o, r]);
1837
+ }
1838
+ return e;
1839
+ }
1840
+ load(e) {
1841
+ this.clear();
1842
+ for (let [n, o] of e) {
1843
+ if (o.start) {
1844
+ let s = Date.now() - o.start;
1845
+ o.start = this.#T.now() - s;
1846
+ }
1847
+ this.set(n, o.value, o);
1848
+ }
1849
+ }
1850
+ set(e, n, o = {}) {
1851
+ if (n === void 0) return this.delete(e), this;
1852
+ let { ttl: s = this.ttl, start: i, noDisposeOnSet: r = this.noDisposeOnSet, sizeCalculation: a = this.sizeCalculation, status: c } = o, { noUpdateTTL: d = this.noUpdateTTL } = o, f = this.#B(e, n, o.size || 0, a);
1853
+ if (this.maxEntrySize && f > this.maxEntrySize) return c && (c.set = "miss", c.maxEntrySizeExceeded = !0), this.#F(e, "set"), this;
1854
+ let l = this.#s === 0 ? void 0 : this.#o.get(e);
1855
+ if (l === void 0) l = this.#s === 0 ? this.#i : this.#v.length !== 0 ? this.#v.pop() : this.#s === this.#a ? this.#x(!1) : this.#s, this.#n[l] = e, this.#t[l] = n, this.#o.set(e, l), this.#l[this.#i] = l, this.#f[l] = this.#i, this.#i = l, this.#s++, this.#U(l, f, c), c && (c.set = "add"), d = !1, this.#D && this.#N?.(n, e, "add");
1856
+ else {
1857
+ this.#P(l);
1858
+ let u = this.#t[l];
1859
+ if (n !== u) {
1860
+ if (this.#b && this.#e(u)) {
1861
+ u.__abortController.abort(new Error("replaced"));
1862
+ let { __staleWhileFetching: h } = u;
1863
+ h !== void 0 && !r && (this.#C && this.#p?.(h, e, "set"), this.#d && this.#r?.push([h, e, "set"]));
1864
+ } else r || (this.#C && this.#p?.(u, e, "set"), this.#d && this.#r?.push([u, e, "set"]));
1865
+ if (this.#I(l), this.#U(l, f, c), this.#t[l] = n, c) {
1866
+ c.set = "replace";
1867
+ let h = u && this.#e(u) ? u.__staleWhileFetching : u;
1868
+ h !== void 0 && (c.oldValue = h);
1869
+ }
1870
+ } else c && (c.set = "update");
1871
+ this.#D && this.onInsert?.(n, e, n === u ? "update" : "replace");
1872
+ }
1873
+ if (s !== 0 && !this.#h && this.#k(), this.#h && (d || this.#$(l, s, i), c && this.#L(c, l)), !r && this.#d && this.#r) {
1874
+ let u = this.#r, h;
1875
+ for (; h = u?.shift(); ) this.#y?.(...h);
1876
+ }
1877
+ return this;
1878
+ }
1879
+ pop() {
1880
+ try {
1881
+ for (; this.#s; ) {
1882
+ let e = this.#t[this.#c];
1883
+ if (this.#x(!0), this.#e(e)) {
1884
+ if (e.__staleWhileFetching) return e.__staleWhileFetching;
1885
+ } else if (e !== void 0) return e;
1886
+ }
1887
+ } finally {
1888
+ if (this.#d && this.#r) {
1889
+ let e = this.#r, n;
1890
+ for (; n = e?.shift(); ) this.#y?.(...n);
1891
+ }
1892
+ }
1893
+ }
1894
+ #x(e) {
1895
+ let n = this.#c, o = this.#n[n], s = this.#t[n];
1896
+ return this.#b && this.#e(s) ? s.__abortController.abort(new Error("evicted")) : (this.#C || this.#d) && (this.#C && this.#p?.(s, o, "evict"), this.#d && this.#r?.push([s, o, "evict"])), this.#I(n), this.#m?.[n] && (clearTimeout(this.#m[n]), this.#m[n] = void 0), e && (this.#n[n] = void 0, this.#t[n] = void 0, this.#v.push(n)), this.#s === 1 ? (this.#c = this.#i = 0, this.#v.length = 0) : this.#c = this.#l[n], this.#o.delete(o), this.#s--, n;
1897
+ }
1898
+ has(e, n = {}) {
1899
+ let { updateAgeOnHas: o = this.updateAgeOnHas, status: s } = n, i = this.#o.get(e);
1900
+ if (i !== void 0) {
1901
+ let r = this.#t[i];
1902
+ if (this.#e(r) && r.__staleWhileFetching === void 0) return !1;
1903
+ if (this.#g(i)) s && (s.has = "stale", this.#L(s, i));
1904
+ else return o && this.#R(i), s && (s.has = "hit", this.#L(s, i)), !0;
1905
+ } else s && (s.has = "miss");
1906
+ return !1;
1907
+ }
1908
+ peek(e, n = {}) {
1909
+ let { allowStale: o = this.allowStale } = n, s = this.#o.get(e);
1910
+ if (s === void 0 || !o && this.#g(s)) return;
1911
+ let i = this.#t[s];
1912
+ return this.#e(i) ? i.__staleWhileFetching : i;
1913
+ }
1914
+ #H(e, n, o, s) {
1915
+ let i = n === void 0 ? void 0 : this.#t[n];
1916
+ if (this.#e(i)) return i;
1917
+ let r = new ut(), { signal: a } = o;
1918
+ a?.addEventListener("abort", () => r.abort(a.reason), { signal: r.signal });
1919
+ let c = { signal: r.signal, options: o, context: s }, d = (y, S = !1) => {
1920
+ let { aborted: g } = r.signal, T = o.ignoreFetchAbort && y !== void 0, A = o.ignoreFetchAbort || !!(o.allowStaleOnFetchAbort && y !== void 0);
1921
+ if (o.status && (g && !S ? (o.status.fetchAborted = !0, o.status.fetchError = r.signal.reason, T && (o.status.fetchAbortIgnored = !0)) : o.status.fetchResolved = !0), g && !T && !S) return l(r.signal.reason, A);
1922
+ let C = h, v = this.#t[n];
1923
+ return (v === h || T && S && v === void 0) && (y === void 0 ? C.__staleWhileFetching !== void 0 ? this.#t[n] = C.__staleWhileFetching : this.#F(e, "fetch") : (o.status && (o.status.fetchUpdated = !0), this.set(e, y, c.options))), y;
1924
+ }, f = (y) => (o.status && (o.status.fetchRejected = !0, o.status.fetchError = y), l(y, !1)), l = (y, S) => {
1925
+ let { aborted: g } = r.signal, T = g && o.allowStaleOnFetchAbort, A = T || o.allowStaleOnFetchRejection, C = A || o.noDeleteOnFetchRejection, v = h;
1926
+ if (this.#t[n] === h && (!C || !S && v.__staleWhileFetching === void 0 ? this.#F(e, "fetch") : T || (this.#t[n] = v.__staleWhileFetching)), A) return o.status && v.__staleWhileFetching !== void 0 && (o.status.returnedStale = !0), v.__staleWhileFetching;
1927
+ if (v.__returned === v) throw y;
1928
+ }, u = (y, S) => {
1929
+ let g = this.#M?.(e, i, c);
1930
+ g && g instanceof Promise && g.then((T) => y(T === void 0 ? void 0 : T), S), r.signal.addEventListener("abort", () => {
1931
+ (!o.ignoreFetchAbort || o.allowStaleOnFetchAbort) && (y(void 0), o.allowStaleOnFetchAbort && (y = (T) => d(T, !0)));
1932
+ });
1933
+ };
1934
+ o.status && (o.status.fetchDispatched = !0);
1935
+ let h = new Promise(u).then(d, f), p = Object.assign(h, { __abortController: r, __staleWhileFetching: i, __returned: void 0 });
1936
+ return n === void 0 ? (this.set(e, p, { ...c.options, status: void 0 }), n = this.#o.get(e)) : this.#t[n] = p, p;
1937
+ }
1938
+ #e(e) {
1939
+ if (!this.#b) return !1;
1940
+ let n = e;
1941
+ return !!n && n instanceof Promise && n.hasOwnProperty("__staleWhileFetching") && n.__abortController instanceof ut;
1942
+ }
1943
+ async fetch(e, n = {}) {
1944
+ let { allowStale: o = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: i = this.noDeleteOnStaleGet, ttl: r = this.ttl, noDisposeOnSet: a = this.noDisposeOnSet, size: c = 0, sizeCalculation: d = this.sizeCalculation, noUpdateTTL: f = this.noUpdateTTL, noDeleteOnFetchRejection: l = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: u = this.allowStaleOnFetchRejection, ignoreFetchAbort: h = this.ignoreFetchAbort, allowStaleOnFetchAbort: p = this.allowStaleOnFetchAbort, context: y, forceRefresh: S = !1, status: g, signal: T } = n;
1945
+ if (!this.#b) return g && (g.fetch = "get"), this.get(e, { allowStale: o, updateAgeOnGet: s, noDeleteOnStaleGet: i, status: g });
1946
+ let A = { allowStale: o, updateAgeOnGet: s, noDeleteOnStaleGet: i, ttl: r, noDisposeOnSet: a, size: c, sizeCalculation: d, noUpdateTTL: f, noDeleteOnFetchRejection: l, allowStaleOnFetchRejection: u, allowStaleOnFetchAbort: p, ignoreFetchAbort: h, status: g, signal: T }, C = this.#o.get(e);
1947
+ if (C === void 0) {
1948
+ g && (g.fetch = "miss");
1949
+ let v = this.#H(e, C, A, y);
1950
+ return v.__returned = v;
1951
+ } else {
1952
+ let v = this.#t[C];
1953
+ if (this.#e(v)) {
1954
+ let m = o && v.__staleWhileFetching !== void 0;
1955
+ return g && (g.fetch = "inflight", m && (g.returnedStale = !0)), m ? v.__staleWhileFetching : v.__returned = v;
1956
+ }
1957
+ let R = this.#g(C);
1958
+ if (!S && !R) return g && (g.fetch = "hit"), this.#P(C), s && this.#R(C), g && this.#L(g, C), v;
1959
+ let P = this.#H(e, C, A, y), M = P.__staleWhileFetching !== void 0 && o;
1960
+ return g && (g.fetch = R ? "stale" : "refresh", M && R && (g.returnedStale = !0)), M ? P.__staleWhileFetching : P.__returned = P;
1961
+ }
1962
+ }
1963
+ async forceFetch(e, n = {}) {
1964
+ let o = await this.fetch(e, n);
1965
+ if (o === void 0) throw new Error("fetch() returned undefined");
1966
+ return o;
1967
+ }
1968
+ memo(e, n = {}) {
1969
+ let o = this.#G;
1970
+ if (!o) throw new Error("no memoMethod provided to constructor");
1971
+ let { context: s, forceRefresh: i, ...r } = n, a = this.get(e, r);
1972
+ if (!i && a !== void 0) return a;
1973
+ let c = o(e, a, { options: r, context: s });
1974
+ return this.set(e, c, r), c;
1975
+ }
1976
+ get(e, n = {}) {
1977
+ let { allowStale: o = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: i = this.noDeleteOnStaleGet, status: r } = n, a = this.#o.get(e);
1978
+ if (a !== void 0) {
1979
+ let c = this.#t[a], d = this.#e(c);
1980
+ return r && this.#L(r, a), this.#g(a) ? (r && (r.get = "stale"), d ? (r && o && c.__staleWhileFetching !== void 0 && (r.returnedStale = !0), o ? c.__staleWhileFetching : void 0) : (i || this.#F(e, "expire"), r && o && (r.returnedStale = !0), o ? c : void 0)) : (r && (r.get = "hit"), d ? c.__staleWhileFetching : (this.#P(a), s && this.#R(a), c));
1981
+ } else r && (r.get = "miss");
1982
+ }
1983
+ #z(e, n) {
1984
+ this.#f[n] = e, this.#l[e] = n;
1985
+ }
1986
+ #P(e) {
1987
+ e !== this.#i && (e === this.#c ? this.#c = this.#l[e] : this.#z(this.#f[e], this.#l[e]), this.#z(this.#i, e), this.#i = e);
1988
+ }
1989
+ delete(e) {
1990
+ return this.#F(e, "delete");
1991
+ }
1992
+ #F(e, n) {
1993
+ let o = !1;
1994
+ if (this.#s !== 0) {
1995
+ let s = this.#o.get(e);
1996
+ if (s !== void 0) if (this.#m?.[s] && (clearTimeout(this.#m?.[s]), this.#m[s] = void 0), o = !0, this.#s === 1) this.#Y(n);
1997
+ else {
1998
+ this.#I(s);
1999
+ let i = this.#t[s];
2000
+ if (this.#e(i) ? i.__abortController.abort(new Error("deleted")) : (this.#C || this.#d) && (this.#C && this.#p?.(i, e, n), this.#d && this.#r?.push([i, e, n])), this.#o.delete(e), this.#n[s] = void 0, this.#t[s] = void 0, s === this.#i) this.#i = this.#f[s];
2001
+ else if (s === this.#c) this.#c = this.#l[s];
2002
+ else {
2003
+ let r = this.#f[s];
2004
+ this.#l[r] = this.#l[s];
2005
+ let a = this.#l[s];
2006
+ this.#f[a] = this.#f[s];
2007
+ }
2008
+ this.#s--, this.#v.push(s);
2009
+ }
2010
+ }
2011
+ if (this.#d && this.#r?.length) {
2012
+ let s = this.#r, i;
2013
+ for (; i = s?.shift(); ) this.#y?.(...i);
2014
+ }
2015
+ return o;
2016
+ }
2017
+ clear() {
2018
+ return this.#Y("delete");
2019
+ }
2020
+ #Y(e) {
2021
+ for (let n of this.#E({ allowStale: !0 })) {
2022
+ let o = this.#t[n];
2023
+ if (this.#e(o)) o.__abortController.abort(new Error("deleted"));
2024
+ else {
2025
+ let s = this.#n[n];
2026
+ this.#C && this.#p?.(o, s, e), this.#d && this.#r?.push([o, s, e]);
2027
+ }
2028
+ }
2029
+ if (this.#o.clear(), this.#t.fill(void 0), this.#n.fill(void 0), this.#h && this.#A) {
2030
+ this.#h.fill(0), this.#A.fill(0);
2031
+ for (let n of this.#m ?? []) n !== void 0 && clearTimeout(n);
2032
+ this.#m?.fill(void 0);
2033
+ }
2034
+ if (this.#S && this.#S.fill(0), this.#c = 0, this.#i = 0, this.#v.length = 0, this.#_ = 0, this.#s = 0, this.#d && this.#r) {
2035
+ let n = this.#r, o;
2036
+ for (; o = n?.shift(); ) this.#y?.(...o);
2037
+ }
2038
+ }
2039
+ };
2040
+ const pn = 50 * 1024 * 1024, tt = new gn({
2041
+ maxSize: pn,
2042
+ sizeCalculation: (t) => JSON.stringify(t.data).length
2043
+ }), F = {
2044
+ get(t) {
2045
+ return tt.get(t);
2046
+ },
2047
+ set(t, e) {
2048
+ tt.set(t, { data: e, storedAt: Date.now() });
2049
+ },
2050
+ delete(t) {
2051
+ tt.delete(t);
2052
+ },
2053
+ clear() {
2054
+ tt.clear();
2055
+ },
2056
+ get size() {
2057
+ return tt.size;
2058
+ }
2059
+ };
2060
+ let G = null;
2061
+ function so(t) {
2062
+ G = t;
2063
+ }
2064
+ const yn = {
2065
+ competitions: { staleTTL: 24 * 3600, maxTTL: 72 * 3600 },
2066
+ teams: { staleTTL: 24 * 3600, maxTTL: 48 * 3600 },
2067
+ athletes: { staleTTL: 24 * 3600, maxTTL: 48 * 3600 },
2068
+ venues: { staleTTL: 72 * 3600, maxTTL: 168 * 3600 },
2069
+ countries: { staleTTL: 96 * 3600, maxTTL: 168 * 3600 },
2070
+ coaches: { staleTTL: 24 * 3600, maxTTL: 48 * 3600 },
2071
+ search: { staleTTL: 300, maxTTL: 1800 }
2072
+ }, pt = /* @__PURE__ */ new Set();
2073
+ function Bt(t) {
2074
+ const e = yn[t];
2075
+ if (!e)
2076
+ throw new Error(`Unknown entity type: ${t}`);
2077
+ return e;
2078
+ }
2079
+ function ft(t, e) {
2080
+ return Date.now() - t.storedAt < e * 1e3;
2081
+ }
2082
+ function ht(t, e) {
2083
+ return Date.now() - t.storedAt >= e * 1e3;
2084
+ }
2085
+ function mt(t, e, n) {
2086
+ pt.has(t) || (pt.add(t), n().then((o) => {
2087
+ F.set(t, o), G?.isInitialized && G.set(t, e, o);
2088
+ }).catch((o) => {
2089
+ console.error(`[cache] Background refresh failed for ${t}:`, o);
2090
+ }).finally(() => {
2091
+ pt.delete(t);
2092
+ }));
2093
+ }
2094
+ async function q(t, e, n) {
2095
+ const { staleTTL: o, maxTTL: s } = Bt(e), i = F.get(t);
2096
+ if (i) {
2097
+ if (ft(i, o))
2098
+ return i.data;
2099
+ if (!ht(i, s))
2100
+ return mt(t, e, n), i.data;
2101
+ }
2102
+ if (G?.isInitialized) {
2103
+ const a = G.get(t);
2104
+ if (a && !ht(a, s))
2105
+ return F.set(t, a.data), ft(a, o) || mt(t, e, n), a.data;
2106
+ }
2107
+ const r = await n();
2108
+ return F.set(t, r), G?.isInitialized && G.set(t, e, r), r;
2109
+ }
2110
+ async function Tn(t, e, n, o) {
2111
+ const { staleTTL: s, maxTTL: i } = Bt(e), r = /* @__PURE__ */ new Map(), a = [];
2112
+ for (const c of t) {
2113
+ const d = o(c);
2114
+ let f = !1;
2115
+ const l = F.get(d);
2116
+ if (l && !ht(l, i) && (r.set(c, l.data), ft(l, s) || mt(d, e, async () => {
2117
+ const h = (await n([c])).get(c);
2118
+ if (!h) throw new Error(`Batch fetcher did not return ID: ${c}`);
2119
+ return h;
2120
+ }), f = !0), !f && G?.isInitialized) {
2121
+ const u = G.get(d);
2122
+ u && !ht(u, i) && (F.set(d, u.data), r.set(c, u.data), ft(u, s) || mt(d, e, async () => {
2123
+ const p = (await n([c])).get(c);
2124
+ if (!p) throw new Error(`Batch fetcher did not return ID: ${c}`);
2125
+ return p;
2126
+ }), f = !0);
2127
+ }
2128
+ f || a.push(c);
2129
+ }
2130
+ if (a.length > 0) {
2131
+ const c = await n(a);
2132
+ for (const [d, f] of c) {
2133
+ const l = o(d);
2134
+ F.set(l, f), G?.isInitialized && G.set(l, e, f), r.set(d, f);
2135
+ }
2136
+ }
2137
+ return r;
2138
+ }
2139
+ function io(t) {
2140
+ F.delete(t);
2141
+ }
2142
+ function x(t, e, n, o) {
2143
+ const s = e.toUpperCase(), i = t.find((r) => r.language.toUpperCase() === s);
2144
+ if (i)
2145
+ return {
2146
+ name: i.name,
2147
+ shortName: i.short_name ?? o ?? void 0
2148
+ };
2149
+ if (s !== "EN") {
2150
+ const r = t.find((a) => a.language.toUpperCase() === "EN");
2151
+ if (r)
2152
+ return {
2153
+ name: r.name,
2154
+ shortName: r.short_name ?? o ?? void 0
2155
+ };
2156
+ }
2157
+ return {
2158
+ name: n,
2159
+ shortName: o ?? void 0
2160
+ };
2161
+ }
2162
+ function Q(t) {
2163
+ const e = {};
2164
+ for (const n of t)
2165
+ e[n.key.toLowerCase()] = n.value;
2166
+ return e;
2167
+ }
2168
+ function K(t) {
2169
+ if (!t) return;
2170
+ const e = {};
2171
+ return t.primary_color && (e.primaryColor = t.primary_color), t.secondary_color && (e.secondaryColor = t.secondary_color), t.text_color && (e.textColor = t.text_color), t.background_color && (e.backgroundColor = t.background_color), t.background_gradient_from_color && (e.backgroundGradientFromColor = t.background_gradient_from_color), t.background_gradient_to_color && (e.backgroundGradientToColor = t.background_gradient_to_color), t.background_image && (e.backgroundImage = t.background_image), Object.keys(e).length > 0 ? e : void 0;
2172
+ }
2173
+ function X(t) {
2174
+ return t.map((e) => ({ provider: e.provider, id: e.id }));
2175
+ }
2176
+ function _n(t, e) {
2177
+ return t.filter((n) => n.relationship === e).map((n) => n.related_id);
2178
+ }
2179
+ function H(t, e, n) {
2180
+ const o = t || _n(e, "COUNTRY")[0];
2181
+ if (!o) return;
2182
+ const s = F.get(o) ?? F.get(`entity:${o}`);
2183
+ if (s?.data) {
2184
+ const i = s.data;
2185
+ return st(i, n);
2186
+ }
2187
+ return { id: o, name: o };
2188
+ }
2189
+ function st(t, e) {
2190
+ const { name: n, shortName: o } = x(t.translations ?? [], e, t.name, t.short_name), s = Q(t.assets ?? []);
2191
+ return {
2192
+ id: t.id,
2193
+ name: n,
2194
+ ...t.country_code ? { code: t.country_code } : {},
2195
+ ...s.flag ? { flag: s.flag } : {},
2196
+ ...o ? { shortName: o } : {}
2197
+ };
2198
+ }
2199
+ function At(t, e) {
2200
+ const { name: n, shortName: o } = x(t.translations ?? [], e, t.name, t.short_name), s = Q(t.assets ?? []), i = K(t.branding), r = H(null, t.related ?? [], e);
2201
+ return {
2202
+ id: t.id,
2203
+ name: n,
2204
+ sport: t.sport,
2205
+ ...o ? { shortName: o } : {},
2206
+ ...t.format ? { type: t.format } : {},
2207
+ ...r ? { country: r } : {},
2208
+ ...s.logo ? { assets: { logo: s.logo } } : {},
2209
+ ...i ? { metadata: { branding: i } } : {}
2210
+ };
2211
+ }
2212
+ function nt(t, e) {
2213
+ const { name: n, shortName: o } = x(t.translations ?? [], e, t.name, t.short_name), s = Q(t.assets ?? []), i = K(t.metadata?.branding), r = H(t.country_id, t.related ?? [], e);
2214
+ return {
2215
+ id: t.id,
2216
+ name: n,
2217
+ sport: t.sport,
2218
+ ...o ? { shortName: o } : {},
2219
+ ...t.three_letter_code ? { threeLetterCode: t.three_letter_code } : {},
2220
+ ...t.full_name ? { fullName: t.full_name } : {},
2221
+ ...t.nickname ? { nickname: t.nickname } : {},
2222
+ ...t.gender ? { gender: t.gender } : {},
2223
+ ...r ? { country: r } : {},
2224
+ ...s.logo ? { assets: { logo: s.logo } } : {},
2225
+ ...i ? { metadata: { branding: i } } : {}
2226
+ };
2227
+ }
2228
+ function Wt(t, e) {
2229
+ const { name: n, shortName: o } = x(t.translations ?? [], e, t.name, t.short_name), s = Q(t.assets ?? []), i = K(t.metadata?.branding), r = H(t.country_id, t.related ?? [], e);
2230
+ return {
2231
+ id: t.id,
2232
+ name: n,
2233
+ sport: t.sport,
2234
+ type: "player",
2235
+ ...o ? { shortName: o } : {},
2236
+ ...t.position ? { position: t.position } : {},
2237
+ ...t.birth_date ? { birthdate: t.birth_date } : {},
2238
+ ...t.shirt_number != null ? { shirtNumber: t.shirt_number } : {},
2239
+ ...t.gender ? { gender: t.gender } : {},
2240
+ ...r ? { country: r } : {},
2241
+ ...s.logo || s.headshot ? { assets: { ...s.logo ? { logo: s.logo } : {}, ...s.headshot ? { photo: s.headshot } : {} } } : {},
2242
+ ...i ? { metadata: { branding: i } } : {}
2243
+ };
2244
+ }
2245
+ function zt(t, e) {
2246
+ const { name: n } = x(t.translations ?? [], e, t.name, t.short_name), o = H(t.country_id, t.related ?? [], e), s = t.capacity != null || t.latitude != null || t.longitude != null;
2247
+ return {
2248
+ id: t.id,
2249
+ name: n,
2250
+ sport: t.sport,
2251
+ ...o ? { country: o } : {},
2252
+ ...s ? {
2253
+ profile: {
2254
+ ...t.capacity != null ? { capacity: t.capacity } : {},
2255
+ ...t.latitude != null ? { latitude: t.latitude } : {},
2256
+ ...t.longitude != null ? { longitude: t.longitude } : {}
2257
+ }
2258
+ } : {}
2259
+ };
2260
+ }
2261
+ function vn(t, e) {
2262
+ const { name: n } = x(t.translations ?? [], e, t.name, t.short_name), o = H(t.country_id, t.related ?? [], e);
2263
+ return {
2264
+ id: t.id,
2265
+ name: n,
2266
+ sport: t.sport,
2267
+ ...t.birth_date ? { birthdate: t.birth_date } : {},
2268
+ ...o ? { country: o } : {}
2269
+ };
2270
+ }
2271
+ function Sn(t, e, n) {
2272
+ const o = F.get(t) ?? F.get(`entity:${t}`);
2273
+ if (!o?.data) return;
2274
+ const s = o.data;
2275
+ switch (e) {
2276
+ case "COMPETITION":
2277
+ return At(s, n);
2278
+ case "TEAM":
2279
+ return nt(s, n);
2280
+ case "ATHLETE":
2281
+ return Wt(s, n);
2282
+ case "COUNTRY":
2283
+ return st(s, n);
2284
+ default:
2285
+ return;
2286
+ }
2287
+ }
2288
+ function it(t, e) {
2289
+ if (!t || t.length === 0) return;
2290
+ const n = {};
2291
+ for (const o of t) {
2292
+ const s = Sn(o.related_id, o.relationship, e);
2293
+ if (s)
2294
+ switch (o.relationship) {
2295
+ case "COMPETITION":
2296
+ (n.competitions ??= []).push(s);
2297
+ break;
2298
+ case "TEAM":
2299
+ (n.teams ??= []).push(s);
2300
+ break;
2301
+ case "ATHLETE":
2302
+ (n.athletes ??= []).push(s);
2303
+ break;
2304
+ case "COUNTRY":
2305
+ (n.countries ??= []).push(s);
2306
+ break;
2307
+ }
2308
+ }
2309
+ return Object.keys(n).length > 0 ? n : void 0;
2310
+ }
2311
+ function An(t, e) {
2312
+ const { name: n, shortName: o } = x(t.translations ?? [], e, t.name, t.short_name), s = Q(t.assets ?? []), i = K(t.branding), r = H(null, t.related ?? [], e), a = it(t.related ?? [], e);
2313
+ return {
2314
+ id: t.id,
2315
+ name: n,
2316
+ sport: t.sport,
2317
+ ...o ? { shortName: o } : {},
2318
+ ...t.format ? { type: t.format } : {},
2319
+ ...t.gender ? { gender: t.gender } : {},
2320
+ ...r ? { country: r } : {},
2321
+ ...s.logo ? { assets: { logo: s.logo } } : {},
2322
+ ...i ? { metadata: { branding: i } } : {},
2323
+ ...t.provider_ref?.length ? { providerRef: X(t.provider_ref) } : {},
2324
+ ...a ? { related: a } : {}
2325
+ };
2326
+ }
2327
+ function Lt(t, e) {
2328
+ const { name: n, shortName: o } = x(t.translations ?? [], e, t.name, t.short_name), s = Q(t.assets ?? []), i = K(t.metadata?.branding), r = H(t.country_id, t.related ?? [], e), a = it(t.related ?? [], e);
2329
+ return {
2330
+ id: t.id,
2331
+ name: n,
2332
+ sport: t.sport,
2333
+ ...o ? { shortName: o } : {},
2334
+ ...t.three_letter_code ? { threeLetterCode: t.three_letter_code } : {},
2335
+ ...t.full_name ? { fullName: t.full_name } : {},
2336
+ ...t.nickname ? { nickname: t.nickname } : {},
2337
+ ...t.gender ? { gender: t.gender } : {},
2338
+ ...r ? { country: r } : {},
2339
+ ...s.logo ? { assets: { logo: s.logo } } : {},
2340
+ ...i ? { metadata: { branding: i } } : {},
2341
+ ...t.provider_ref?.length ? { providerRef: X(t.provider_ref) } : {},
2342
+ ...a ? { related: a } : {}
2343
+ };
2344
+ }
2345
+ function Cn(t, e) {
2346
+ const { name: n, shortName: o } = x(t.translations ?? [], e, t.name, t.short_name), s = Q(t.assets ?? []), i = K(t.metadata?.branding), r = H(t.country_id, t.related ?? [], e), a = it(t.related ?? [], e);
2347
+ return {
2348
+ id: t.id,
2349
+ name: n,
2350
+ sport: t.sport,
2351
+ type: "player",
2352
+ ...o ? { shortName: o } : {},
2353
+ ...t.position ? { position: t.position } : {},
2354
+ ...t.birth_date ? { birthdate: t.birth_date } : {},
2355
+ ...t.shirt_number != null ? { shirtNumber: t.shirt_number } : {},
2356
+ ...t.gender ? { gender: t.gender } : {},
2357
+ ...r ? { country: r } : {},
2358
+ ...s.logo || s.headshot ? { assets: { ...s.logo ? { logo: s.logo } : {}, ...s.headshot ? { photo: s.headshot } : {} } } : {},
2359
+ ...i ? { metadata: { branding: i } } : {},
2360
+ ...t.provider_ref?.length ? { providerRef: X(t.provider_ref) } : {},
2361
+ ...a ? { related: a } : {}
2362
+ };
2363
+ }
2364
+ function On(t, e) {
2365
+ return {
2366
+ ...st(t, e),
2367
+ sport: t.sport,
2368
+ ...t.provider_ref?.length ? { providerRef: X(t.provider_ref) } : {}
2369
+ };
2370
+ }
2371
+ function En(t, e) {
2372
+ const { name: n } = x(t.translations ?? [], e, t.name, t.short_name), o = H(t.country_id, t.related ?? [], e), s = it(t.related ?? [], e), i = t.capacity != null || t.latitude != null || t.longitude != null;
2373
+ return {
2374
+ id: t.id,
2375
+ name: n,
2376
+ sport: t.sport,
2377
+ ...o ? { country: o } : {},
2378
+ ...i ? {
2379
+ profile: {
2380
+ ...t.capacity != null ? { capacity: t.capacity } : {},
2381
+ ...t.latitude != null ? { latitude: t.latitude } : {},
2382
+ ...t.longitude != null ? { longitude: t.longitude } : {}
2383
+ }
2384
+ } : {},
2385
+ ...t.provider_ref?.length ? { providerRef: X(t.provider_ref) } : {},
2386
+ ...s ? { related: s } : {}
2387
+ };
2388
+ }
2389
+ function Fn(t, e) {
2390
+ const { name: n } = x(t.translations ?? [], e, t.name, t.short_name), o = H(t.country_id, t.related ?? [], e), s = it(t.related ?? [], e);
2391
+ return {
2392
+ id: t.id,
2393
+ name: n,
2394
+ sport: t.sport,
2395
+ ...t.birth_date ? { birthdate: t.birth_date } : {},
2396
+ ...o ? { country: o } : {},
2397
+ ...t.provider_ref?.length ? { providerRef: X(t.provider_ref) } : {},
2398
+ ...s ? { related: s } : {}
2399
+ };
2400
+ }
2401
+ function Yt(t, e) {
2402
+ const n = t.content_type?.toUpperCase?.(), o = t.type?.toUpperCase?.(), s = t.entityType?.toLowerCase?.();
2403
+ return n === "COMPETITION" || s === "competition" ? { ...An(t, e), entityType: "competition" } : s === "country" || t.country_code !== void 0 ? { ...On(t, e), entityType: "country" } : s === "venue" || t.capacity !== void 0 && !s ? { ...En(t, e), entityType: "venue" } : s === "coach" || o === "COACH" ? { ...Fn(t, e), entityType: "coach" } : s === "athlete" || o === "PLAYER" || t.position !== void 0 || t.shirt_number !== void 0 ? { ...Cn(t, e), entityType: "athlete" } : s === "team" || o === "TEAM" || t.three_letter_code !== void 0 ? { ...Lt(t, e), entityType: "team" } : { ...Lt(t, e), entityType: "team" };
2404
+ }
2405
+ function Ln(t, e) {
2406
+ const n = t.content_type?.toUpperCase?.(), o = t.type?.toUpperCase?.(), s = t.entityType?.toLowerCase?.();
2407
+ return n === "COMPETITION" || s === "competition" ? { ...At(t, e), entityType: "competition" } : s === "country" || t.country_code !== void 0 ? { ...st(t, e), entityType: "country" } : s === "venue" || t.capacity !== void 0 && !s ? { ...zt(t, e), entityType: "venue" } : s === "coach" || o === "COACH" ? { ...vn(t, e), entityType: "coach" } : s === "athlete" || o === "PLAYER" || t.position !== void 0 || t.shirt_number !== void 0 ? { ...Wt(t, e), entityType: "athlete" } : s === "team" || o === "TEAM" || t.three_letter_code !== void 0 ? { ...nt(t, e), entityType: "team" } : { ...nt(t, e), entityType: "team" };
2408
+ }
2409
+ function J(t) {
2410
+ const e = Object.entries(t).filter(([, o]) => o !== void 0).sort(([o], [s]) => o.localeCompare(s)).map(([o, s]) => `${o}=${Array.isArray(s) ? s.join(",") : s}`).join("&");
2411
+ let n = 0;
2412
+ for (let o = 0; o < e.length; o++)
2413
+ n = (n << 5) - n + e.charCodeAt(o) | 0;
2414
+ return n.toString(36);
2415
+ }
2416
+ function V(t) {
2417
+ for (const e of t)
2418
+ e.id && F.set(`entity:${e.id}`, e);
2419
+ }
2420
+ function Y(t) {
2421
+ if (t?.lang) return t.lang;
2422
+ if (ee()) {
2423
+ const e = b();
2424
+ if (e.fansUnited && "lang" in e.fansUnited && e.fansUnited.lang)
2425
+ return e.fansUnited.lang;
2426
+ }
2427
+ return "EN";
2428
+ }
2429
+ function bt(t) {
2430
+ const e = /* @__PURE__ */ new Set();
2431
+ for (const n of t) {
2432
+ const o = n, s = o.related;
2433
+ if (s)
2434
+ for (const r of s)
2435
+ F.get(`entity:${r.related_id}`) || e.add(r.related_id);
2436
+ const i = o.country_id;
2437
+ i && !F.get(`entity:${i}`) && e.add(i);
2438
+ }
2439
+ return e;
2440
+ }
2441
+ async function _t(t, e) {
2442
+ if (t.size === 0) return [];
2443
+ const n = await B.get({
2444
+ path: "/v1/entities/search",
2445
+ params: { ids: Array.from(t) },
2446
+ next: e?.next,
2447
+ config: e?.config
2448
+ });
2449
+ return V(n.data), n.data;
2450
+ }
2451
+ async function jt(t, e) {
2452
+ const n = bt(t);
2453
+ if (n.size !== 0)
2454
+ try {
2455
+ const o = await _t(n, e), s = bt(o);
2456
+ s.size > 0 && await _t(s, e);
2457
+ } catch {
2458
+ }
2459
+ }
2460
+ async function rt(t, e) {
2461
+ const n = /* @__PURE__ */ new Set();
2462
+ for (const o of t) {
2463
+ const s = o, i = s.country_id;
2464
+ i && !F.get(`entity:${i}`) && n.add(i);
2465
+ const r = s.related;
2466
+ if (r)
2467
+ for (const a of r)
2468
+ a.relationship === "COUNTRY" && !F.get(`entity:${a.related_id}`) && n.add(a.related_id);
2469
+ }
2470
+ if (n.size !== 0)
2471
+ try {
2472
+ await _t(n, e);
2473
+ } catch {
2474
+ }
2475
+ }
2476
+ async function ro(t = {}, e) {
2477
+ const n = Y(t), o = {
2478
+ query: t.query,
2479
+ content_type: t.contentType,
2480
+ ids: t.ids,
2481
+ limit: t.limit?.toString(),
2482
+ page: t.page?.toString(),
2483
+ mode: t.mode,
2484
+ sport: t.sport,
2485
+ relationship: t.relationship,
2486
+ value: t.value
2487
+ }, s = `search:entities:${J(o)}`, i = await q(
2488
+ s,
2489
+ "search",
2490
+ () => B.get({
2491
+ path: "/v1/entities/search",
2492
+ params: o,
2493
+ next: t.next || e?.next,
2494
+ config: t.config
2495
+ })
2496
+ );
2497
+ return V(i.data), await rt(i.data, { next: t.next || e?.next, config: t.config }), { data: i.data.map(
2498
+ (a) => Ln(a, n)
2499
+ ), pagination: i.meta.pagination };
2500
+ }
2501
+ async function ao(t, e) {
2502
+ const n = Y(e), o = `entity:${t}`, s = await q(o, "search", async () => {
2503
+ const i = await B.get({
2504
+ path: "/v1/entities/search",
2505
+ params: { ids: [t] },
2506
+ next: e?.next,
2507
+ config: e?.config
2508
+ });
2509
+ if (!i.data || i.data.length === 0)
2510
+ throw new Error(`Entity not found: ${t}`);
2511
+ return i.data[0];
2512
+ });
2513
+ return await jt([s], { next: e?.next, config: e?.config }), Yt(s, n);
2514
+ }
2515
+ async function co(t, e) {
2516
+ if (t.length === 0) return [];
2517
+ const n = Y(e), o = await Tn(
2518
+ t,
2519
+ "search",
2520
+ async (i) => {
2521
+ const r = await B.get({
2522
+ path: "/v1/entities/search",
2523
+ params: { ids: i },
2524
+ next: e?.next,
2525
+ config: e?.config
2526
+ }), a = /* @__PURE__ */ new Map();
2527
+ for (const c of r.data)
2528
+ a.set(c.id, c);
2529
+ return a;
2530
+ },
2531
+ (i) => `entity:${i}`
2532
+ ), s = t.map((i) => o.get(i)).filter((i) => i !== void 0);
2533
+ return await jt(s, { next: e?.next, config: e?.config }), s.map((i) => Yt(i, n));
2534
+ }
2535
+ async function lo(t = {}) {
2536
+ const e = Y(t), n = {
2537
+ content_type: "competition",
2538
+ query: t.query,
2539
+ limit: t.limit?.toString(),
2540
+ page: t.page?.toString(),
2541
+ sport: t.sport
2542
+ }, o = `competitions:${J(n)}`, s = await q(
2543
+ o,
2544
+ "competitions",
2545
+ () => B.get({
2546
+ path: "/v1/entities/search",
2547
+ params: n,
2548
+ next: t.next,
2549
+ config: t.config
2550
+ })
2551
+ );
2552
+ return V(s.data), await rt(s.data, { next: t.next, config: t.config }), { data: s.data.map((r) => At(r, e)), pagination: s.meta.pagination };
2553
+ }
2554
+ async function uo(t, e = {}) {
2555
+ const n = Y(e), o = {
2556
+ content_type: "team",
2557
+ relationship: "COUNTRY",
2558
+ value: t,
2559
+ query: e.query,
2560
+ limit: e.limit?.toString(),
2561
+ page: e.page?.toString(),
2562
+ sport: e.sport
2563
+ }, s = `teams:country:${t}:${J(o)}`, i = await q(
2564
+ s,
2565
+ "teams",
2566
+ () => B.get({
2567
+ path: "/v1/entities/search",
2568
+ params: o,
2569
+ next: e.next,
2570
+ config: e.config
2571
+ })
2572
+ );
2573
+ return V(i.data), await rt(i.data, { next: e.next, config: e.config }), { data: i.data.map((a) => nt(a, n)), pagination: i.meta.pagination };
2574
+ }
2575
+ async function fo(t, e = {}) {
2576
+ const n = Y(e), o = {
2577
+ content_type: "team",
2578
+ relationship: "COMPETITION",
2579
+ value: t,
2580
+ query: e.query,
2581
+ limit: e.limit?.toString(),
2582
+ page: e.page?.toString(),
2583
+ sport: e.sport
2584
+ }, s = `teams:competition:${t}:${J(o)}`, i = await q(
2585
+ s,
2586
+ "teams",
2587
+ () => B.get({
2588
+ path: "/v1/entities/search",
2589
+ params: o,
2590
+ next: e.next,
2591
+ config: e.config
2592
+ })
2593
+ );
2594
+ return V(i.data), await rt(i.data, { next: e.next, config: e.config }), { data: i.data.map((a) => nt(a, n)), pagination: i.meta.pagination };
2595
+ }
2596
+ async function ho(t = {}) {
2597
+ const e = Y(t), n = {
2598
+ content_type: "country",
2599
+ query: t.query,
2600
+ limit: t.limit?.toString(),
2601
+ page: t.page?.toString(),
2602
+ sport: t.sport
2603
+ }, o = `countries:${J(n)}`, s = await q(
2604
+ o,
2605
+ "countries",
2606
+ () => B.get({
2607
+ path: "/v1/entities/search",
2608
+ params: n,
2609
+ next: t.next,
2610
+ config: t.config
2611
+ })
2612
+ );
2613
+ return V(s.data), { data: s.data.map((r) => st(r, e)), pagination: s.meta.pagination };
2614
+ }
2615
+ async function mo(t = {}) {
2616
+ const e = Y(t), n = {
2617
+ content_type: "venue",
2618
+ query: t.query,
2619
+ limit: t.limit?.toString(),
2620
+ page: t.page?.toString(),
2621
+ sport: t.sport
2622
+ }, o = `venues:${J(n)}`, s = await q(
2623
+ o,
2624
+ "venues",
2625
+ () => B.get({
2626
+ path: "/v1/entities/search",
2627
+ params: n,
2628
+ next: t.next,
2629
+ config: t.config
2630
+ })
2631
+ );
2632
+ return V(s.data), await rt(s.data, { next: t.next, config: t.config }), { data: s.data.map((r) => zt(r, e)), pagination: s.meta.pagination };
2633
+ }
2634
+ function go(t) {
2635
+ return !t.seasons || t.seasons.length === 0 ? void 0 : t.seasons.find((n) => n.active) ?? t.seasons[0];
2636
+ }
2637
+ function po(t, e) {
2638
+ const n = /* @__PURE__ */ new Date(), o = e.filter((s) => {
2639
+ const i = s.competitorOne.id === t || s.competitorTwo.id === t, r = s.status.type === "NOT_STARTED", a = new Date(s.timing.kickoffTime) >= n;
1335
2640
  return i && r && a;
1336
2641
  });
1337
- return n.sort((s, i) => new Date(s.timing.kickoffTime).getTime() - new Date(i.timing.kickoffTime).getTime()), n[0];
2642
+ return o.sort((s, i) => new Date(s.timing.kickoffTime).getTime() - new Date(i.timing.kickoffTime).getTime()), o[0];
1338
2643
  }
1339
- function xt(e, t) {
1340
- const o = /* @__PURE__ */ new Date(), n = t.filter((s) => {
1341
- const i = s.competitorOne.id === e || s.competitorTwo.id === e, r = s.status.type === "FINISHED", a = new Date(s.timing.kickoffTime) <= o;
2644
+ function yo(t, e) {
2645
+ const n = /* @__PURE__ */ new Date(), o = e.filter((s) => {
2646
+ const i = s.competitorOne.id === t || s.competitorTwo.id === t, r = s.status.type === "FINISHED", a = new Date(s.timing.kickoffTime) <= n;
1342
2647
  return i && r && a;
1343
2648
  });
1344
- return n.sort((s, i) => new Date(i.timing.kickoffTime).getTime() - new Date(s.timing.kickoffTime).getTime()), n[0];
2649
+ return o.sort((s, i) => new Date(i.timing.kickoffTime).getTime() - new Date(s.timing.kickoffTime).getTime()), o[0];
1345
2650
  }
1346
- function Wt(e, t) {
1347
- const o = /* @__PURE__ */ new Date();
1348
- return t.filter((s) => {
1349
- 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";
2651
+ function To(t, e) {
2652
+ const n = /* @__PURE__ */ new Date();
2653
+ return e.filter((s) => {
2654
+ const i = s.competitorOne.id === t || s.competitorTwo.id === t, r = s.status.type === "NOT_STARTED" || s.status.type === "LIVE", a = new Date(s.timing.kickoffTime) >= n || s.status.type === "LIVE";
1350
2655
  return i && r && a;
1351
2656
  }).sort(
1352
2657
  (s, i) => new Date(s.timing.kickoffTime).getTime() - new Date(i.timing.kickoffTime).getTime()
1353
2658
  );
1354
2659
  }
1355
- function qt(e, t) {
1356
- const o = /* @__PURE__ */ new Date();
1357
- return t.filter((s) => {
1358
- const i = s.competitorOne.id === e || s.competitorTwo.id === e, r = s.status.type === "FINISHED", a = new Date(s.timing.kickoffTime) <= o;
2660
+ function _o(t, e) {
2661
+ const n = /* @__PURE__ */ new Date();
2662
+ return e.filter((s) => {
2663
+ const i = s.competitorOne.id === t || s.competitorTwo.id === t, r = s.status.type === "FINISHED", a = new Date(s.timing.kickoffTime) <= n;
1359
2664
  return i && r && a;
1360
2665
  }).sort(
1361
2666
  (s, i) => new Date(i.timing.kickoffTime).getTime() - new Date(s.timing.kickoffTime).getTime()
1362
2667
  );
1363
2668
  }
1364
- function Vt(e, t, o) {
1365
- const n = o.filter((r) => r.status.type === "FINISHED"), s = o.filter(
2669
+ function vo(t, e, n) {
2670
+ const o = n.filter((r) => r.status.type === "FINISHED"), s = n.filter(
1366
2671
  (r) => r.status.type === "NOT_STARTED" || r.status.type === "POSTPONED"
1367
- ), i = t.entries.map((r) => {
1368
- const a = r.competitor.id, d = n.filter(
1369
- (m) => m.competitorOne.id === e && m.competitorTwo.id === a || m.competitorOne.id === a && m.competitorTwo.id === e
1370
- ), l = s.filter(
1371
- (m) => m.competitorOne.id === e && m.competitorTwo.id === a || m.competitorOne.id === a && m.competitorTwo.id === e
2672
+ ), i = e.entries.map((r) => {
2673
+ const a = r.competitor.id, c = o.filter(
2674
+ (u) => u.competitorOne.id === t && u.competitorTwo.id === a || u.competitorOne.id === a && u.competitorTwo.id === t
2675
+ ), d = s.filter(
2676
+ (u) => u.competitorOne.id === t && u.competitorTwo.id === a || u.competitorOne.id === a && u.competitorTwo.id === t
1372
2677
  );
1373
- let u, c;
1374
- return d.forEach((m) => {
1375
- const g = m.competitorOne.id === e, p = parseInt(m.score?.competitorOne ?? "0"), h = parseInt(m.score?.competitorTwo ?? "0"), E = g ? p : h, S = g ? h : p;
1376
- let O;
1377
- E > S ? O = "W" : E === S ? O = "D" : O = "L";
1378
- const M = {
1379
- result: O,
1380
- score: `${p} - ${h}`,
1381
- date: m.timing.kickoffTime,
1382
- matchId: m.id,
2678
+ let f, l;
2679
+ return c.forEach((u) => {
2680
+ const h = u.competitorOne.id === t, p = parseInt(u.score?.competitorOne ?? "0"), y = parseInt(u.score?.competitorTwo ?? "0"), S = h ? p : y, g = h ? y : p;
2681
+ let T;
2682
+ S > g ? T = "W" : S === g ? T = "D" : T = "L";
2683
+ const A = {
2684
+ result: T,
2685
+ score: `${p} - ${y}`,
2686
+ date: u.timing.kickoffTime,
2687
+ matchId: u.id,
1383
2688
  isUpcoming: !1
1384
2689
  };
1385
- g ? u = M : c = M;
1386
- }), l.forEach((m) => {
1387
- const g = m.competitorOne.id === e;
1388
- g && !u ? u = {
1389
- date: m.timing.kickoffTime,
1390
- matchId: m.id,
2690
+ h ? f = A : l = A;
2691
+ }), d.forEach((u) => {
2692
+ const h = u.competitorOne.id === t;
2693
+ h && !f ? f = {
2694
+ date: u.timing.kickoffTime,
2695
+ matchId: u.id,
1391
2696
  isUpcoming: !0
1392
- } : !g && !c && (c = {
1393
- date: m.timing.kickoffTime,
1394
- matchId: m.id,
2697
+ } : !h && !l && (l = {
2698
+ date: u.timing.kickoffTime,
2699
+ matchId: u.id,
1395
2700
  isUpcoming: !0
1396
2701
  });
1397
2702
  }), {
@@ -1402,76 +2707,76 @@ function Vt(e, t, o) {
1402
2707
  teamLogo: r.competitor.logo,
1403
2708
  gamesPlayed: r.stats.played ?? 0,
1404
2709
  points: r.stats.points ?? 0,
1405
- homeResult: u,
1406
- awayResult: c
2710
+ homeResult: f,
2711
+ awayResult: l
1407
2712
  };
1408
2713
  });
1409
2714
  return {
1410
- teamId: e,
2715
+ teamId: t,
1411
2716
  rows: i
1412
2717
  };
1413
2718
  }
1414
- function jt(e, t = 10) {
1415
- return e.players.filter((o) => (o.seasonStatistics?.goals ?? 0) > 0).sort((o, n) => {
1416
- const s = o.seasonStatistics?.goals ?? 0, i = n.seasonStatistics?.goals ?? 0;
2719
+ function So(t, e = 10) {
2720
+ return t.players.filter((n) => (n.seasonStatistics?.goals ?? 0) > 0).sort((n, o) => {
2721
+ const s = n.seasonStatistics?.goals ?? 0, i = o.seasonStatistics?.goals ?? 0;
1417
2722
  if (i !== s)
1418
2723
  return i - s;
1419
- const r = o.seasonStatistics?.assists ?? 0;
1420
- return (n.seasonStatistics?.assists ?? 0) - r;
1421
- }).slice(0, t);
2724
+ const r = n.seasonStatistics?.assists ?? 0;
2725
+ return (o.seasonStatistics?.assists ?? 0) - r;
2726
+ }).slice(0, e);
1422
2727
  }
1423
- function Kt(e, t = 10) {
1424
- return e.players.filter((o) => (o.seasonStatistics?.assists ?? 0) > 0).sort((o, n) => {
1425
- const s = o.seasonStatistics?.assists ?? 0, i = n.seasonStatistics?.assists ?? 0;
2728
+ function Ao(t, e = 10) {
2729
+ return t.players.filter((n) => (n.seasonStatistics?.assists ?? 0) > 0).sort((n, o) => {
2730
+ const s = n.seasonStatistics?.assists ?? 0, i = o.seasonStatistics?.assists ?? 0;
1426
2731
  if (i !== s)
1427
2732
  return i - s;
1428
- const r = o.seasonStatistics?.goals ?? 0;
1429
- return (n.seasonStatistics?.goals ?? 0) - r;
1430
- }).slice(0, t);
2733
+ const r = n.seasonStatistics?.goals ?? 0;
2734
+ return (o.seasonStatistics?.goals ?? 0) - r;
2735
+ }).slice(0, e);
1431
2736
  }
1432
- function Yt(e, t = 10) {
1433
- return e.players.filter((o) => (o.seasonStatistics?.appearances ?? 0) > 0).sort((o, n) => {
1434
- const s = o.seasonStatistics?.appearances ?? 0, i = n.seasonStatistics?.appearances ?? 0;
2737
+ function Co(t, e = 10) {
2738
+ return t.players.filter((n) => (n.seasonStatistics?.appearances ?? 0) > 0).sort((n, o) => {
2739
+ const s = n.seasonStatistics?.appearances ?? 0, i = o.seasonStatistics?.appearances ?? 0;
1435
2740
  if (i !== s)
1436
2741
  return i - s;
1437
- const r = o.seasonStatistics?.minutes ?? 0;
1438
- return (n.seasonStatistics?.minutes ?? 0) - r;
1439
- }).slice(0, t);
2742
+ const r = n.seasonStatistics?.minutes ?? 0;
2743
+ return (o.seasonStatistics?.minutes ?? 0) - r;
2744
+ }).slice(0, e);
1440
2745
  }
1441
- function zt(e, t = 10) {
1442
- return e.players.filter((o) => (o.seasonStatistics?.minutes ?? 0) > 0).sort((o, n) => {
1443
- const s = o.seasonStatistics?.minutes ?? 0, i = n.seasonStatistics?.minutes ?? 0;
2746
+ function Oo(t, e = 10) {
2747
+ return t.players.filter((n) => (n.seasonStatistics?.minutes ?? 0) > 0).sort((n, o) => {
2748
+ const s = n.seasonStatistics?.minutes ?? 0, i = o.seasonStatistics?.minutes ?? 0;
1444
2749
  if (i !== s)
1445
2750
  return i - s;
1446
- const r = o.seasonStatistics?.appearances ?? 0;
1447
- return (n.seasonStatistics?.appearances ?? 0) - r;
1448
- }).slice(0, t);
2751
+ const r = n.seasonStatistics?.appearances ?? 0;
2752
+ return (o.seasonStatistics?.appearances ?? 0) - r;
2753
+ }).slice(0, e);
1449
2754
  }
1450
- function Jt(e, t = 10) {
1451
- return e.players.filter((o) => (o.seasonStatistics?.cleansheets ?? 0) > 0).sort((o, n) => {
1452
- const s = o.seasonStatistics?.cleansheets ?? 0, i = n.seasonStatistics?.cleansheets ?? 0;
2755
+ function Eo(t, e = 10) {
2756
+ return t.players.filter((n) => (n.seasonStatistics?.cleansheets ?? 0) > 0).sort((n, o) => {
2757
+ const s = n.seasonStatistics?.cleansheets ?? 0, i = o.seasonStatistics?.cleansheets ?? 0;
1453
2758
  if (i !== s)
1454
2759
  return i - s;
1455
- const r = o.seasonStatistics?.appearances ?? 0;
1456
- return (n.seasonStatistics?.appearances ?? 0) - r;
1457
- }).slice(0, t);
1458
- }
1459
- function Qt(e, t = 10) {
1460
- return e.players.filter((o) => {
1461
- const n = o.seasonStatistics?.yellowCards ?? 0, s = o.seasonStatistics?.redCards ?? 0;
1462
- return n + s > 0;
1463
- }).sort((o, n) => {
1464
- const s = o.seasonStatistics?.yellowCards ?? 0, i = o.seasonStatistics?.redCards ?? 0, r = n.seasonStatistics?.yellowCards ?? 0, a = n.seasonStatistics?.redCards ?? 0, d = s + i * 3, l = r + a * 3;
1465
- return l !== d ? l - d : a !== i ? a - i : r - s;
1466
- }).slice(0, t);
1467
- }
1468
- function b(e) {
1469
- const t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
1470
- return e.forEach((n) => {
1471
- !n.mainEvents || n.mainEvents.length === 0 || n.mainEvents.forEach((s) => {
2760
+ const r = n.seasonStatistics?.appearances ?? 0;
2761
+ return (o.seasonStatistics?.appearances ?? 0) - r;
2762
+ }).slice(0, e);
2763
+ }
2764
+ function Fo(t, e = 10) {
2765
+ return t.players.filter((n) => {
2766
+ const o = n.seasonStatistics?.yellowCards ?? 0, s = n.seasonStatistics?.redCards ?? 0;
2767
+ return o + s > 0;
2768
+ }).sort((n, o) => {
2769
+ const s = n.seasonStatistics?.yellowCards ?? 0, i = n.seasonStatistics?.redCards ?? 0, r = o.seasonStatistics?.yellowCards ?? 0, a = o.seasonStatistics?.redCards ?? 0, c = s + i * 3, d = r + a * 3;
2770
+ return d !== c ? d - c : a !== i ? a - i : r - s;
2771
+ }).slice(0, e);
2772
+ }
2773
+ function Z(t) {
2774
+ const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
2775
+ return t.forEach((o) => {
2776
+ !o.mainEvents || o.mainEvents.length === 0 || o.mainEvents.forEach((s) => {
1472
2777
  if (s.primaryPlayer) {
1473
2778
  const i = s.primaryPlayer.id;
1474
- t.has(i) || t.set(i, {
2779
+ e.has(i) || e.set(i, {
1475
2780
  playerId: s.primaryPlayer.id,
1476
2781
  seasonId: "",
1477
2782
  // Not applicable for match aggregation
@@ -1483,12 +2788,12 @@ function b(e) {
1483
2788
  redCards: 0,
1484
2789
  appearances: 0
1485
2790
  });
1486
- const r = t.get(i);
1487
- 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);
2791
+ const r = e.get(i);
2792
+ n.has(i) || n.set(i, /* @__PURE__ */ new Set()), n.get(i).add(o.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);
1488
2793
  }
1489
2794
  if (s.secondaryPlayer && (s.type === "GOAL" || s.type === "PENALTY_GOAL")) {
1490
2795
  const i = s.secondaryPlayer.id;
1491
- t.has(i) || t.set(i, {
2796
+ e.has(i) || e.set(i, {
1492
2797
  playerId: s.secondaryPlayer.id,
1493
2798
  seasonId: "",
1494
2799
  // Not applicable for match aggregation
@@ -1500,205 +2805,205 @@ function b(e) {
1500
2805
  redCards: 0,
1501
2806
  appearances: 0
1502
2807
  });
1503
- const r = t.get(i);
1504
- r.assists = (r.assists ?? 0) + 1, o.has(i) || o.set(i, /* @__PURE__ */ new Set()), o.get(i).add(n.id);
2808
+ const r = e.get(i);
2809
+ r.assists = (r.assists ?? 0) + 1, n.has(i) || n.set(i, /* @__PURE__ */ new Set()), n.get(i).add(o.id);
1505
2810
  }
1506
2811
  });
1507
- }), o.forEach((n, s) => {
1508
- const i = t.get(s);
1509
- i && i.appearances !== void 0 && (i.appearances = n.size);
1510
- }), t;
1511
- }
1512
- function H(e) {
1513
- return Array.from(e.values()).map((t) => ({
1514
- ...t,
1515
- totalCards: (t.yellowCards ?? 0) + (t.redCards ?? 0)
2812
+ }), n.forEach((o, s) => {
2813
+ const i = e.get(s);
2814
+ i && i.appearances !== void 0 && (i.appearances = o.size);
2815
+ }), e;
2816
+ }
2817
+ function at(t) {
2818
+ return Array.from(t.values()).map((e) => ({
2819
+ ...e,
2820
+ totalCards: (e.yellowCards ?? 0) + (e.redCards ?? 0)
1516
2821
  }));
1517
2822
  }
1518
- function lt(e, t = 10) {
1519
- const o = b(e);
1520
- return H(o).filter((s) => (s.goals ?? 0) > 0).sort((s, i) => {
2823
+ function bn(t, e = 10) {
2824
+ const n = Z(t);
2825
+ return at(n).filter((s) => (s.goals ?? 0) > 0).sort((s, i) => {
1521
2826
  const r = s.goals ?? 0, a = i.goals ?? 0;
1522
2827
  if (a !== r)
1523
2828
  return a - r;
1524
- const d = s.assists ?? 0;
1525
- return (i.assists ?? 0) - d;
1526
- }).slice(0, t);
2829
+ const c = s.assists ?? 0;
2830
+ return (i.assists ?? 0) - c;
2831
+ }).slice(0, e);
1527
2832
  }
1528
- function ut(e, t = 10) {
1529
- const o = b(e);
1530
- return H(o).filter((s) => (s.assists ?? 0) > 0).sort((s, i) => {
2833
+ function Nn(t, e = 10) {
2834
+ const n = Z(t);
2835
+ return at(n).filter((s) => (s.assists ?? 0) > 0).sort((s, i) => {
1531
2836
  const r = s.assists ?? 0, a = i.assists ?? 0;
1532
2837
  if (a !== r)
1533
2838
  return a - r;
1534
- const d = s.goals ?? 0;
1535
- return (i.goals ?? 0) - d;
1536
- }).slice(0, t);
2839
+ const c = s.goals ?? 0;
2840
+ return (i.goals ?? 0) - c;
2841
+ }).slice(0, e);
1537
2842
  }
1538
- function mt(e, t = 10) {
1539
- const o = b(e);
1540
- return H(o).filter((s) => (s.totalCards ?? 0) > 0).sort((s, i) => {
2843
+ function Rn(t, e = 10) {
2844
+ const n = Z(t);
2845
+ return at(n).filter((s) => (s.totalCards ?? 0) > 0).sort((s, i) => {
1541
2846
  const r = (s.yellowCards ?? 0) + (s.redCards ?? 0) * 3, a = (i.yellowCards ?? 0) + (i.redCards ?? 0) * 3;
1542
2847
  if (a !== r)
1543
2848
  return a - r;
1544
- const d = s.redCards ?? 0, l = i.redCards ?? 0;
1545
- if (l !== d)
1546
- return l - d;
1547
- const u = s.yellowCards ?? 0;
1548
- return (i.yellowCards ?? 0) - u;
1549
- }).slice(0, t);
1550
- }
1551
- function ft(e, t = 10) {
1552
- const o = b(e);
1553
- return H(o).filter((s) => (s.goals ?? 0) + (s.assists ?? 0) > 0).sort((s, i) => {
2849
+ const c = s.redCards ?? 0, d = i.redCards ?? 0;
2850
+ if (d !== c)
2851
+ return d - c;
2852
+ const f = s.yellowCards ?? 0;
2853
+ return (i.yellowCards ?? 0) - f;
2854
+ }).slice(0, e);
2855
+ }
2856
+ function In(t, e = 10) {
2857
+ const n = Z(t);
2858
+ return at(n).filter((s) => (s.goals ?? 0) + (s.assists ?? 0) > 0).sort((s, i) => {
1554
2859
  const r = (s.goals ?? 0) + (s.assists ?? 0), a = (i.goals ?? 0) + (i.assists ?? 0);
1555
2860
  if (a !== r)
1556
2861
  return a - r;
1557
- const d = s.goals ?? 0, l = i.goals ?? 0;
1558
- if (l !== d)
1559
- return l - d;
1560
- const u = s.assists ?? 0;
1561
- return (i.assists ?? 0) - u;
1562
- }).slice(0, t);
1563
- }
1564
- function gt(e) {
1565
- const t = b(e);
1566
- return H(t).sort((n, s) => {
1567
- const i = n.appearances ?? 0, r = s.appearances ?? 0;
2862
+ const c = s.goals ?? 0, d = i.goals ?? 0;
2863
+ if (d !== c)
2864
+ return d - c;
2865
+ const f = s.assists ?? 0;
2866
+ return (i.assists ?? 0) - f;
2867
+ }).slice(0, e);
2868
+ }
2869
+ function Pn(t) {
2870
+ const e = Z(t);
2871
+ return at(e).sort((o, s) => {
2872
+ const i = o.appearances ?? 0, r = s.appearances ?? 0;
1568
2873
  if (r !== i)
1569
2874
  return r - i;
1570
- const a = (n.goals ?? 0) + (n.assists ?? 0);
2875
+ const a = (o.goals ?? 0) + (o.assists ?? 0);
1571
2876
  return (s.goals ?? 0) + (s.assists ?? 0) - a;
1572
2877
  });
1573
2878
  }
1574
- function Xt(e, t = 10) {
1575
- return D(() => lt(e, t), [e, t]);
2879
+ function Lo(t, e = 10) {
2880
+ return j(() => bn(t, e), [t, e]);
1576
2881
  }
1577
- function Zt(e, t = 10) {
1578
- return D(() => ut(e, t), [e, t]);
2882
+ function bo(t, e = 10) {
2883
+ return j(() => Nn(t, e), [t, e]);
1579
2884
  }
1580
- function wt(e, t = 10) {
1581
- return D(() => mt(e, t), [e, t]);
2885
+ function No(t, e = 10) {
2886
+ return j(() => Rn(t, e), [t, e]);
1582
2887
  }
1583
- function eo(e, t = 10) {
1584
- return D(() => ft(e, t), [e, t]);
2888
+ function Ro(t, e = 10) {
2889
+ return j(() => In(t, e), [t, e]);
1585
2890
  }
1586
- function to(e) {
1587
- return D(() => gt(e), [e]);
2891
+ function Io(t) {
2892
+ return j(() => Pn(t), [t]);
1588
2893
  }
1589
- function pt(e) {
1590
- return D(() => b(e), [e]);
2894
+ function Mn(t) {
2895
+ return j(() => Z(t), [t]);
1591
2896
  }
1592
- function oo(e, t) {
1593
- const o = pt(e);
1594
- return D(() => o.get(t), [o, t]);
2897
+ function Po(t, e) {
2898
+ const n = Mn(t);
2899
+ return j(() => n.get(e), [n, e]);
1595
2900
  }
1596
- const yt = ["GOAL", "PENALTY_GOAL", "OWN_GOAL"];
1597
- function N(e, t) {
1598
- return t > 0 ? e / t * 100 : 0;
2901
+ const Gn = ["GOAL", "PENALTY_GOAL", "OWN_GOAL"];
2902
+ function I(t, e) {
2903
+ return e > 0 ? t / e * 100 : 0;
1599
2904
  }
1600
- function W(e, t) {
1601
- return t > 0 ? e / t : 0;
2905
+ function ct(t, e) {
2906
+ return e > 0 ? t / e : 0;
1602
2907
  }
1603
- function no(e, t = !1, o = 2) {
1604
- return t ? `${Math.round(e)}%` : Number.isInteger(e) ? e.toString() : e.toFixed(o);
2908
+ function Mo(t, e = !1, n = 2) {
2909
+ return e ? `${Math.round(t)}%` : Number.isInteger(t) ? t.toString() : t.toFixed(n);
1605
2910
  }
1606
- function so(e, t) {
1607
- const o = typeof e == "string" ? parseFloat(e) : e;
1608
- if (isNaN(o) || t === 0) return "0";
1609
- const n = (o / t).toFixed(1);
1610
- return `${o} (${n} avg)`;
2911
+ function Go(t, e) {
2912
+ const n = typeof t == "string" ? parseFloat(t) : t;
2913
+ if (isNaN(n) || e === 0) return "0";
2914
+ const o = (n / e).toFixed(1);
2915
+ return `${n} (${o} avg)`;
1611
2916
  }
1612
- function io(e, t) {
1613
- const o = typeof e == "string" ? parseFloat(e) : e;
1614
- return isNaN(o) || t === 0 ? "0.0" : (o / t).toFixed(1);
2917
+ function Do(t, e) {
2918
+ const n = typeof t == "string" ? parseFloat(t) : t;
2919
+ return isNaN(n) || e === 0 ? "0.0" : (n / e).toFixed(1);
1615
2920
  }
1616
- function ro(e) {
1617
- const t = parseFloat(e);
1618
- return isNaN(t) ? "0%" : `${Math.round(t)}%`;
2921
+ function Uo(t) {
2922
+ const e = parseFloat(t);
2923
+ return isNaN(e) ? "0%" : `${Math.round(e)}%`;
1619
2924
  }
1620
- function ht(e, t, o) {
1621
- if (e.status?.type !== "FINISHED" || !e.score) return null;
1622
- const n = parseInt(e.score.competitorOne || "0"), s = parseInt(e.score.competitorTwo || "0"), i = o ? n : s, r = o ? s : n;
1623
- let a = null, d = null;
1624
- const l = e.score.breakdown?.halfTime;
1625
- if (l) {
1626
- const g = parseInt(l.competitorOne || "0"), p = parseInt(l.competitorTwo || "0");
1627
- a = o ? g : p, d = o ? p : g;
2925
+ function Dn(t, e, n) {
2926
+ if (t.status?.type !== "FINISHED" || !t.score) return null;
2927
+ const o = parseInt(t.score.competitorOne || "0"), s = parseInt(t.score.competitorTwo || "0"), i = n ? o : s, r = n ? s : o;
2928
+ let a = null, c = null;
2929
+ const d = t.score.breakdown?.halfTime;
2930
+ if (d) {
2931
+ const h = parseInt(d.competitorOne || "0"), p = parseInt(d.competitorTwo || "0");
2932
+ a = n ? h : p, c = n ? p : h;
1628
2933
  }
1629
- const u = e.statistics;
1630
- let c = null, m = null;
1631
- if (u) {
1632
- const g = u.find?.((p) => p.type === "CORNERS");
1633
- g && (c = o ? g.competitorOne : g.competitorTwo, m = o ? g.competitorTwo : g.competitorOne);
2934
+ const f = t.statistics;
2935
+ let l = null, u = null;
2936
+ if (f) {
2937
+ const h = f.find?.((p) => p.type === "CORNERS");
2938
+ h && (l = n ? h.competitorOne : h.competitorTwo, u = n ? h.competitorTwo : h.competitorOne);
1634
2939
  }
1635
2940
  return {
1636
2941
  goalsFor: i,
1637
2942
  goalsAgainst: r,
1638
2943
  halfTimeGoalsFor: a,
1639
- halfTimeGoalsAgainst: d,
1640
- cornersFor: c,
1641
- cornersAgainst: m,
2944
+ halfTimeGoalsAgainst: c,
2945
+ cornersFor: l,
2946
+ cornersAgainst: u,
1642
2947
  isWin: i > r,
1643
2948
  isDraw: i === r,
1644
2949
  isLoss: i < r
1645
2950
  };
1646
2951
  }
1647
- function J(e, t) {
1648
- return e.competitorOne.id === t;
2952
+ function Ct(t, e) {
2953
+ return t.competitorOne.id === e;
1649
2954
  }
1650
- function Tt(e, t) {
1651
- return e.competitorTwo.id === t;
2955
+ function Un(t, e) {
2956
+ return t.competitorTwo.id === e;
1652
2957
  }
1653
- function ao(e, t) {
1654
- return J(e, t) || Tt(e, t);
2958
+ function xo(t, e) {
2959
+ return Ct(t, e) || Un(t, e);
1655
2960
  }
1656
- function co(e) {
1657
- return e.status?.type === "FINISHED";
2961
+ function Ho(t) {
2962
+ return t.status?.type === "FINISHED";
1658
2963
  }
1659
- function lo(e, t) {
1660
- const o = J(e, t);
1661
- return parseInt(o ? e.score?.competitorOne || "0" : e.score?.competitorTwo || "0");
2964
+ function ko(t, e) {
2965
+ const n = Ct(t, e);
2966
+ return parseInt(n ? t.score?.competitorOne || "0" : t.score?.competitorTwo || "0");
1662
2967
  }
1663
- function uo(e, t) {
1664
- const o = J(e, t);
1665
- return parseInt(o ? e.score?.competitorTwo || "0" : e.score?.competitorOne || "0");
2968
+ function $o(t, e) {
2969
+ const n = Ct(t, e);
2970
+ return parseInt(n ? t.score?.competitorTwo || "0" : t.score?.competitorOne || "0");
1666
2971
  }
1667
- function mo(e, t, o) {
1668
- const n = e.filter((u) => {
1669
- if (u.status?.type !== "FINISHED" || !u.score) return !1;
1670
- const c = u.competitorOne.id === t || u.competitorTwo.id === t, m = u.competitorOne.id === o || u.competitorTwo.id === o;
1671
- return c && m;
2972
+ function Bo(t, e, n) {
2973
+ const o = t.filter((f) => {
2974
+ if (f.status?.type !== "FINISHED" || !f.score) return !1;
2975
+ const l = f.competitorOne.id === e || f.competitorTwo.id === e, u = f.competitorOne.id === n || f.competitorTwo.id === n;
2976
+ return l && u;
1672
2977
  });
1673
- let s = 0, i = 0, r = 0, a = 0, d = 0;
1674
- n.forEach((u) => {
1675
- const c = parseInt(u.score?.competitorOne || "0"), m = parseInt(u.score?.competitorTwo || "0"), g = u.competitorOne.id === t, p = g ? c : m, h = g ? m : c;
1676
- a += p, d += h, p > h ? s++ : h > p ? i++ : r++;
2978
+ let s = 0, i = 0, r = 0, a = 0, c = 0;
2979
+ o.forEach((f) => {
2980
+ const l = parseInt(f.score?.competitorOne || "0"), u = parseInt(f.score?.competitorTwo || "0"), h = f.competitorOne.id === e, p = h ? l : u, y = h ? u : l;
2981
+ a += p, c += y, p > y ? s++ : y > p ? i++ : r++;
1677
2982
  });
1678
- const l = n.length;
2983
+ const d = o.length;
1679
2984
  return {
1680
- totalMatches: l,
2985
+ totalMatches: d,
1681
2986
  homeTeamWins: s,
1682
2987
  awayTeamWins: i,
1683
2988
  draws: r,
1684
2989
  homeTeamGoals: a,
1685
- awayTeamGoals: d,
1686
- homeTeamWinPercentage: l > 0 ? s / l * 100 : 0,
1687
- awayTeamWinPercentage: l > 0 ? i / l * 100 : 0,
1688
- drawPercentage: l > 0 ? r / l * 100 : 0,
1689
- homeTeamAvgGoals: l > 0 ? a / l : 0,
1690
- awayTeamAvgGoals: l > 0 ? d / l : 0
2990
+ awayTeamGoals: c,
2991
+ homeTeamWinPercentage: d > 0 ? s / d * 100 : 0,
2992
+ awayTeamWinPercentage: d > 0 ? i / d * 100 : 0,
2993
+ drawPercentage: d > 0 ? r / d * 100 : 0,
2994
+ homeTeamAvgGoals: d > 0 ? a / d : 0,
2995
+ awayTeamAvgGoals: d > 0 ? c / d : 0
1691
2996
  };
1692
2997
  }
1693
- function fo(e, t, o, n = 5) {
1694
- return e.filter((i) => {
2998
+ function Wo(t, e, n, o = 5) {
2999
+ return t.filter((i) => {
1695
3000
  if (i.status?.type !== "FINISHED" || !i.score) return !1;
1696
- const r = i.competitorOne.id === t || i.competitorTwo.id === t, a = i.competitorOne.id === o || i.competitorTwo.id === o;
3001
+ const r = i.competitorOne.id === e || i.competitorTwo.id === e, a = i.competitorOne.id === n || i.competitorTwo.id === n;
1697
3002
  return r && a;
1698
- }).sort((i, r) => new Date(r.timing.kickoffTime).getTime() - new Date(i.timing.kickoffTime).getTime()).slice(0, n).map((i) => {
1699
- const r = parseInt(i.score?.competitorOne || "0"), a = parseInt(i.score?.competitorTwo || "0"), d = i.competitorOne.id === t, l = d ? r : a, u = d ? a : r;
1700
- let c;
1701
- return l > u ? c = "home" : u > l ? c = "away" : c = "draw", {
3003
+ }).sort((i, r) => new Date(r.timing.kickoffTime).getTime() - new Date(i.timing.kickoffTime).getTime()).slice(0, o).map((i) => {
3004
+ const r = parseInt(i.score?.competitorOne || "0"), a = parseInt(i.score?.competitorTwo || "0"), c = i.competitorOne.id === e, d = c ? r : a, f = c ? a : r;
3005
+ let l;
3006
+ return d > f ? l = "home" : f > d ? l = "away" : l = "draw", {
1702
3007
  id: i.id,
1703
3008
  date: new Date(i.timing.kickoffTime).toLocaleDateString("en-GB", {
1704
3009
  day: "numeric",
@@ -1712,49 +3017,49 @@ function fo(e, t, o, n = 5) {
1712
3017
  homeScore: r,
1713
3018
  awayScore: a,
1714
3019
  venue: i.venue?.name,
1715
- winner: c
3020
+ winner: l
1716
3021
  };
1717
3022
  });
1718
3023
  }
1719
- function vt(e, t, o) {
1720
- return e.filter((n) => {
1721
- const s = n.competitorOne.id === t, i = n.competitorTwo.id === t;
1722
- return !s && !i ? !1 : o === "home" ? s : i;
1723
- }).map((n) => {
1724
- const s = n.competitorOne.id === t;
1725
- return ht(n, t, s);
1726
- }).filter((n) => n !== null);
3024
+ function xn(t, e, n) {
3025
+ return t.filter((o) => {
3026
+ const s = o.competitorOne.id === e, i = o.competitorTwo.id === e;
3027
+ return !s && !i ? !1 : n === "home" ? s : i;
3028
+ }).map((o) => {
3029
+ const s = o.competitorOne.id === e;
3030
+ return Dn(o, e, s);
3031
+ }).filter((o) => o !== null);
1727
3032
  }
1728
- function Z(e, t, o, n) {
3033
+ function Nt(t, e, n, o) {
1729
3034
  let s = 0;
1730
- for (const i of e) {
1731
- const r = i.competitorOne.id === t, a = i.competitorTwo.id === t;
1732
- if (!r && !a || o === "home" && !r || o === "away" && !a || i.status?.type !== "FINISHED") continue;
1733
- const d = i.mainEvents;
1734
- if (!d || !Array.isArray(d)) continue;
1735
- const l = d.filter((p) => p.type && yt.includes(p.type)).sort((p, h) => {
1736
- const E = p.minute ?? 0, S = h.minute ?? 0;
1737
- return E !== S ? E - S : (p.injuryMinute ?? 0) - (h.injuryMinute ?? 0);
3035
+ for (const i of t) {
3036
+ const r = i.competitorOne.id === e, a = i.competitorTwo.id === e;
3037
+ if (!r && !a || n === "home" && !r || n === "away" && !a || i.status?.type !== "FINISHED") continue;
3038
+ const c = i.mainEvents;
3039
+ if (!c || !Array.isArray(c)) continue;
3040
+ const d = c.filter((p) => p.type && Gn.includes(p.type)).sort((p, y) => {
3041
+ const S = p.minute ?? 0, g = y.minute ?? 0;
3042
+ return S !== g ? S - g : (p.injuryMinute ?? 0) - (y.injuryMinute ?? 0);
1738
3043
  });
1739
- if (l.length === 0) continue;
1740
- const u = l[0], c = r ? "ONE" : "TWO", m = u.type === "OWN_GOAL";
1741
- let g;
1742
- m ? g = u.competitorPosition !== c : g = u.competitorPosition === c, (n === "scored" && g || n === "conceded" && !g) && s++;
3044
+ if (d.length === 0) continue;
3045
+ const f = d[0], l = r ? "ONE" : "TWO", u = f.type === "OWN_GOAL";
3046
+ let h;
3047
+ u ? h = f.competitorPosition !== l : h = f.competitorPosition === l, (o === "scored" && h || o === "conceded" && !h) && s++;
1743
3048
  }
1744
3049
  return s;
1745
3050
  }
1746
- function _t(e, t, o) {
1747
- let n = 0;
1748
- for (const s of e) {
1749
- const i = s.competitorOne.id === t, r = s.competitorTwo.id === t;
1750
- if (!i && !r || o === "home" && !i || o === "away" && !r || s.status?.type !== "FINISHED") continue;
3051
+ function Hn(t, e, n) {
3052
+ let o = 0;
3053
+ for (const s of t) {
3054
+ const i = s.competitorOne.id === e, r = s.competitorTwo.id === e;
3055
+ if (!i && !r || n === "home" && !i || n === "away" && !r || s.status?.type !== "FINISHED") continue;
1751
3056
  const a = s.mainEvents;
1752
- a && Array.isArray(a) && n++;
3057
+ a && Array.isArray(a) && o++;
1753
3058
  }
1754
- return n;
3059
+ return o;
1755
3060
  }
1756
- function go(e, t, o) {
1757
- const n = vt(e, t, o), s = n.length;
3061
+ function zo(t, e, n) {
3062
+ const o = xn(t, e, n), s = o.length;
1758
3063
  if (s === 0)
1759
3064
  return {
1760
3065
  played: 0,
@@ -1775,410 +3080,423 @@ function go(e, t, o) {
1775
3080
  avgCornersFor: 0,
1776
3081
  avgCornersAgainst: 0
1777
3082
  };
1778
- 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, 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, g = n.filter((f) => f.halfTimeGoalsFor !== null), p = g.length, h = g.filter((f) => {
1779
- const v = f.halfTimeGoalsFor, k = f.goalsFor - v;
1780
- return v > 0 && k > 0;
1781
- }).length, E = Z(e, t, o, "scored"), S = _t(e, t, o), O = g.filter((f) => f.halfTimeGoalsFor > f.halfTimeGoalsAgainst).length, M = g.filter((f) => {
1782
- const v = f.halfTimeGoalsAgainst, k = f.goalsAgainst - v;
1783
- return v > 0 && k > 0;
1784
- }).length, U = Z(e, t, o, "conceded"), B = g.filter((f) => f.halfTimeGoalsAgainst > f.halfTimeGoalsFor).length, P = n.filter((f) => f.cornersFor !== null), $ = P.reduce((f, v) => f + (v.cornersFor || 0), 0), x = P.reduce((f, v) => f + (v.cornersAgainst || 0), 0);
3083
+ const i = o.reduce((m, O) => m + O.goalsFor, 0), r = o.reduce((m, O) => m + O.goalsAgainst, 0), a = o.filter((m) => m.goalsAgainst === 0).length, c = o.filter((m) => m.isWin && m.goalsAgainst === 0).length, d = o.filter((m) => m.goalsFor > 0).length, f = o.filter((m) => m.goalsFor === 0).length, l = o.filter((m) => m.isLoss && m.goalsFor === 0).length, u = o.filter((m) => m.goalsAgainst > 0).length, h = o.filter((m) => m.halfTimeGoalsFor !== null), p = h.length, y = h.filter((m) => {
3084
+ const O = m.halfTimeGoalsFor, w = m.goalsFor - O;
3085
+ return O > 0 && w > 0;
3086
+ }).length, S = Nt(t, e, n, "scored"), g = Hn(t, e, n), T = h.filter((m) => m.halfTimeGoalsFor > m.halfTimeGoalsAgainst).length, A = h.filter((m) => {
3087
+ const O = m.halfTimeGoalsAgainst, w = m.goalsAgainst - O;
3088
+ return O > 0 && w > 0;
3089
+ }).length, C = Nt(t, e, n, "conceded"), v = h.filter((m) => m.halfTimeGoalsAgainst > m.halfTimeGoalsFor).length, R = o.filter((m) => m.cornersFor !== null), P = R.reduce((m, O) => m + (O.cornersFor || 0), 0), M = R.reduce((m, O) => m + (O.cornersAgainst || 0), 0);
1785
3090
  return {
1786
3091
  played: s,
1787
- goalsForPerMatch: W(i, s),
1788
- cleanSheets: N(a, s),
1789
- wonToNil: N(d, s),
1790
- scoringRate: N(l, s),
1791
- scoredInBothHalves: N(h, p),
1792
- scoredFirst: N(E, S),
1793
- leadingAtHalfTime: N(O, p),
1794
- goalsAgainstPerMatch: W(r, s),
1795
- failedToScore: N(u, s),
1796
- lostToNil: N(c, s),
1797
- concedingRate: N(m, s),
1798
- concededInBothHalves: N(M, p),
1799
- concededFirst: N(U, S),
1800
- losingAtHalfTime: N(B, p),
1801
- avgCornersFor: W($, P.length),
1802
- avgCornersAgainst: W(x, P.length)
1803
- };
1804
- }
1805
- function St(e, t) {
1806
- return e.filter((o) => o.status?.type !== "FINISHED" ? !1 : o.competitorOne.id === t || o.competitorTwo.id === t).map((o) => {
1807
- const n = o.competitorOne.id === t, s = parseInt(o.score?.competitorOne || "0"), i = parseInt(o.score?.competitorTwo || "0"), r = s + i, a = o.periods;
1808
- let d = null;
3092
+ goalsForPerMatch: ct(i, s),
3093
+ cleanSheets: I(a, s),
3094
+ wonToNil: I(c, s),
3095
+ scoringRate: I(d, s),
3096
+ scoredInBothHalves: I(y, p),
3097
+ scoredFirst: I(S, g),
3098
+ leadingAtHalfTime: I(T, p),
3099
+ goalsAgainstPerMatch: ct(r, s),
3100
+ failedToScore: I(f, s),
3101
+ lostToNil: I(l, s),
3102
+ concedingRate: I(u, s),
3103
+ concededInBothHalves: I(A, p),
3104
+ concededFirst: I(C, g),
3105
+ losingAtHalfTime: I(v, p),
3106
+ avgCornersFor: ct(P, R.length),
3107
+ avgCornersAgainst: ct(M, R.length)
3108
+ };
3109
+ }
3110
+ function kn(t, e) {
3111
+ return t.filter((n) => n.status?.type !== "FINISHED" ? !1 : n.competitorOne.id === e || n.competitorTwo.id === e).map((n) => {
3112
+ const o = n.competitorOne.id === e, s = parseInt(n.score?.competitorOne || "0"), i = parseInt(n.score?.competitorTwo || "0"), r = s + i, a = n.periods;
3113
+ let c = null;
1809
3114
  if (a && Array.isArray(a)) {
1810
- const l = a.find(
1811
- (u) => u.type === "FIRST_HALF" || u.type === "1ST_HALF"
3115
+ const d = a.find(
3116
+ (f) => f.type === "FIRST_HALF" || f.type === "1ST_HALF"
1812
3117
  );
1813
- if (l?.score) {
1814
- const u = parseInt(l.score.competitorOne || "0"), c = parseInt(l.score.competitorTwo || "0");
1815
- d = u + c;
3118
+ if (d?.score) {
3119
+ const f = parseInt(d.score.competitorOne || "0"), l = parseInt(d.score.competitorTwo || "0");
3120
+ c = f + l;
1816
3121
  }
1817
3122
  }
1818
- return { totalGoals: r, halfTimeGoals: d, isHome: n };
3123
+ return { totalGoals: r, halfTimeGoals: c, isHome: o };
1819
3124
  });
1820
3125
  }
1821
- function y(e, t) {
1822
- return e.length === 0 ? 0 : e.filter((n) => n > t).length / e.length * 100;
3126
+ function _(t, e) {
3127
+ return t.length === 0 ? 0 : t.filter((o) => o > e).length / t.length * 100;
1823
3128
  }
1824
- function po(e, t) {
1825
- const o = St(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), 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);
3129
+ function Yo(t, e) {
3130
+ const n = kn(t, e), o = n.filter((l) => l.isHome), s = n.filter((l) => !l.isHome), i = n.map((l) => l.totalGoals), r = o.map((l) => l.totalGoals), a = s.map((l) => l.totalGoals), c = n.filter((l) => l.halfTimeGoals !== null).map((l) => l.halfTimeGoals), d = o.filter((l) => l.halfTimeGoals !== null).map((l) => l.halfTimeGoals), f = s.filter((l) => l.halfTimeGoals !== null).map((l) => l.halfTimeGoals);
1826
3131
  return {
1827
3132
  over05: {
1828
- home: y(r, 0.5),
1829
- total: y(i, 0.5),
1830
- away: y(a, 0.5)
3133
+ home: _(r, 0.5),
3134
+ total: _(i, 0.5),
3135
+ away: _(a, 0.5)
1831
3136
  },
1832
3137
  over15: {
1833
- home: y(r, 1.5),
1834
- total: y(i, 1.5),
1835
- away: y(a, 1.5)
3138
+ home: _(r, 1.5),
3139
+ total: _(i, 1.5),
3140
+ away: _(a, 1.5)
1836
3141
  },
1837
3142
  over25: {
1838
- home: y(r, 2.5),
1839
- total: y(i, 2.5),
1840
- away: y(a, 2.5)
3143
+ home: _(r, 2.5),
3144
+ total: _(i, 2.5),
3145
+ away: _(a, 2.5)
1841
3146
  },
1842
3147
  over35: {
1843
- home: y(r, 3.5),
1844
- total: y(i, 3.5),
1845
- away: y(a, 3.5)
3148
+ home: _(r, 3.5),
3149
+ total: _(i, 3.5),
3150
+ away: _(a, 3.5)
1846
3151
  },
1847
3152
  over45: {
1848
- home: y(r, 4.5),
1849
- total: y(i, 4.5),
1850
- away: y(a, 4.5)
3153
+ home: _(r, 4.5),
3154
+ total: _(i, 4.5),
3155
+ away: _(a, 4.5)
1851
3156
  },
1852
3157
  over55: {
1853
- home: y(r, 5.5),
1854
- total: y(i, 5.5),
1855
- away: y(a, 5.5)
3158
+ home: _(r, 5.5),
3159
+ total: _(i, 5.5),
3160
+ away: _(a, 5.5)
1856
3161
  },
1857
3162
  over05HT: {
1858
- home: y(l, 0.5),
1859
- total: y(d, 0.5),
1860
- away: y(u, 0.5)
3163
+ home: _(d, 0.5),
3164
+ total: _(c, 0.5),
3165
+ away: _(f, 0.5)
1861
3166
  },
1862
3167
  over15HT: {
1863
- home: y(l, 1.5),
1864
- total: y(d, 1.5),
1865
- away: y(u, 1.5)
3168
+ home: _(d, 1.5),
3169
+ total: _(c, 1.5),
3170
+ away: _(f, 1.5)
1866
3171
  },
1867
3172
  over25HT: {
1868
- home: y(l, 2.5),
1869
- total: y(d, 2.5),
1870
- away: y(u, 2.5)
3173
+ home: _(d, 2.5),
3174
+ total: _(c, 2.5),
3175
+ away: _(f, 2.5)
1871
3176
  }
1872
3177
  };
1873
3178
  }
1874
- function Ct(e, t) {
1875
- const o = e.competitorOne.id === t, n = e.competitorTwo.id === t;
1876
- if (!o && !n || !e.score) return null;
1877
- const s = parseInt(o ? e.score.competitorOne || "0" : e.score.competitorTwo || "0"), i = parseInt(o ? e.score.competitorTwo || "0" : e.score.competitorOne || "0");
3179
+ function $n(t, e) {
3180
+ const n = t.competitorOne.id === e, o = t.competitorTwo.id === e;
3181
+ if (!n && !o || !t.score) return null;
3182
+ const s = parseInt(n ? t.score.competitorOne || "0" : t.score.competitorTwo || "0"), i = parseInt(n ? t.score.competitorTwo || "0" : t.score.competitorOne || "0");
1878
3183
  let r;
1879
3184
  return s > i ? r = "W" : s < i ? r = "L" : r = "D", {
1880
- result: { score: `${s}:${i}`, result: r, isHome: o },
1881
- isHome: o
3185
+ result: { score: `${s}:${i}`, result: r, isHome: n },
3186
+ isHome: n
1882
3187
  };
1883
3188
  }
1884
- function yo(e, t, o, n, s, i) {
1885
- const r = t?.entries.find((L) => L.competitor.id === e), a = o?.entries.find((L) => L.competitor.id === e), d = n?.entries.find((L) => L.competitor.id === e), l = s?.entries.find((L) => L.competitor.id === e), u = i?.entries.find((L) => L.competitor.id === e);
3189
+ function jo(t, e, n, o, s, i) {
3190
+ const r = e?.entries.find((k) => k.competitor.id === t), a = n?.entries.find((k) => k.competitor.id === t), c = o?.entries.find((k) => k.competitor.id === t), d = s?.entries.find((k) => k.competitor.id === t), f = i?.entries.find((k) => k.competitor.id === t);
1886
3191
  if (!r) return null;
1887
- const c = a?.stats?.goalsFor ?? 0, m = d?.stats?.goalsFor ?? 0, g = r?.stats?.goalsFor ?? 0, p = l?.stats?.goalsAgainst ?? 0, h = u?.stats?.goalsAgainst ?? 0, E = r?.stats?.goalsAgainst ?? 0, S = a?.stats?.played ?? 0, O = d?.stats?.played ?? 0, M = r?.stats?.played ?? 0, U = M > 0 ? g / M : 0, B = M > 0 ? E / M : 0, P = U + B, $ = S > 0 ? c / S : 0, x = O > 0 ? m / O : 0, f = S > 0 ? p / S : 0, v = O > 0 ? h / O : 0, k = $ + f, se = x + v;
1888
- return {
1889
- homeGoals: c,
1890
- totalGoals: g,
1891
- awayGoals: m,
1892
- homeGamesPlayed: S,
1893
- awayGamesPlayed: O,
1894
- totalGamesPlayed: M,
3192
+ const l = a?.stats?.goalsFor ?? 0, u = c?.stats?.goalsFor ?? 0, h = r?.stats?.goalsFor ?? 0, p = d?.stats?.goalsAgainst ?? 0, y = f?.stats?.goalsAgainst ?? 0, S = r?.stats?.goalsAgainst ?? 0, g = a?.stats?.played ?? 0, T = c?.stats?.played ?? 0, A = r?.stats?.played ?? 0, C = A > 0 ? h / A : 0, v = A > 0 ? S / A : 0, R = C + v, P = g > 0 ? l / g : 0, M = T > 0 ? u / T : 0, m = g > 0 ? p / g : 0, O = T > 0 ? y / T : 0, w = P + m, qt = M + O;
3193
+ return {
3194
+ homeGoals: l,
3195
+ totalGoals: h,
3196
+ awayGoals: u,
3197
+ homeGamesPlayed: g,
3198
+ awayGamesPlayed: T,
3199
+ totalGamesPlayed: A,
1895
3200
  homeGoalsConceded: p,
1896
- totalGoalsConceded: E,
1897
- awayGoalsConceded: h,
1898
- gfPerMatch: U,
1899
- gaPerMatch: B,
1900
- gfGaPerMatch: P,
1901
- homeGfPerMatch: $,
1902
- awayGfPerMatch: x,
1903
- homeGaPerMatch: f,
1904
- awayGaPerMatch: v,
1905
- homeGfGaPerMatch: k,
1906
- awayGfGaPerMatch: se
1907
- };
1908
- }
1909
- function C(e, t, o, n) {
1910
- const s = e.filter((r) => {
1911
- const a = r.competitorOne.id === t, d = r.competitorTwo.id === t;
1912
- return !(!a && !d || r.status?.type !== "FINISHED" || n === "home" && !a || n === "away" && !d);
3201
+ totalGoalsConceded: S,
3202
+ awayGoalsConceded: y,
3203
+ gfPerMatch: C,
3204
+ gaPerMatch: v,
3205
+ gfGaPerMatch: R,
3206
+ homeGfPerMatch: P,
3207
+ awayGfPerMatch: M,
3208
+ homeGaPerMatch: m,
3209
+ awayGaPerMatch: O,
3210
+ homeGfGaPerMatch: w,
3211
+ awayGfGaPerMatch: qt
3212
+ };
3213
+ }
3214
+ function N(t, e, n, o) {
3215
+ const s = t.filter((r) => {
3216
+ const a = r.competitorOne.id === e, c = r.competitorTwo.id === e;
3217
+ return !(!a && !c || r.status?.type !== "FINISHED" || o === "home" && !a || o === "away" && !c);
1913
3218
  }).sort((r, a) => new Date(a.timing.kickoffTime).getTime() - new Date(r.timing.kickoffTime).getTime());
1914
3219
  if (s.length === 0) return null;
1915
3220
  let i = 0;
1916
3221
  for (const r of s) {
1917
- const a = r.competitorOne.id === t;
1918
- if (o(r, t, a))
3222
+ const a = r.competitorOne.id === e;
3223
+ if (n(r, e, a))
1919
3224
  i++;
1920
3225
  else
1921
3226
  break;
1922
3227
  }
1923
3228
  return i > 0 ? i : null;
1924
3229
  }
1925
- const T = {
1926
- win: (e, t, o) => {
1927
- const n = parseInt(o ? e.score?.competitorOne || "0" : e.score?.competitorTwo || "0"), s = parseInt(o ? e.score?.competitorTwo || "0" : e.score?.competitorOne || "0");
1928
- return n > s;
3230
+ const E = {
3231
+ win: (t, e, n) => {
3232
+ const o = parseInt(n ? t.score?.competitorOne || "0" : t.score?.competitorTwo || "0"), s = parseInt(n ? t.score?.competitorTwo || "0" : t.score?.competitorOne || "0");
3233
+ return o > s;
1929
3234
  },
1930
- draw: (e) => e.score?.competitorOne === e.score?.competitorTwo,
1931
- loss: (e, t, o) => {
1932
- const n = parseInt(o ? e.score?.competitorOne || "0" : e.score?.competitorTwo || "0"), s = parseInt(o ? e.score?.competitorTwo || "0" : e.score?.competitorOne || "0");
1933
- return n < s;
3235
+ draw: (t) => t.score?.competitorOne === t.score?.competitorTwo,
3236
+ loss: (t, e, n) => {
3237
+ const o = parseInt(n ? t.score?.competitorOne || "0" : t.score?.competitorTwo || "0"), s = parseInt(n ? t.score?.competitorTwo || "0" : t.score?.competitorOne || "0");
3238
+ return o < s;
1934
3239
  },
1935
- noWin: (e, t, o) => !T.win(e, t, o),
1936
- noDraw: (e) => !T.draw(e),
1937
- noDefeat: (e, t, o) => !T.loss(e, t, o),
1938
- scored: (e, t, o) => parseInt(o ? e.score?.competitorOne || "0" : e.score?.competitorTwo || "0") >= 1,
1939
- conceded: (e, t, o) => parseInt(o ? e.score?.competitorTwo || "0" : e.score?.competitorOne || "0") >= 1,
1940
- noGoalScored: (e, t, o) => !T.scored(e, t, o),
1941
- noGoalConceded: (e, t, o) => !T.conceded(e, t, o),
1942
- over25: (e) => parseInt(e.score?.competitorOne || "0") + parseInt(e.score?.competitorTwo || "0") > 2,
1943
- under25: (e) => parseInt(e.score?.competitorOne || "0") + parseInt(e.score?.competitorTwo || "0") < 3,
1944
- scoredTwice: (e, t, o) => parseInt(o ? e.score?.competitorOne || "0" : e.score?.competitorTwo || "0") >= 2,
1945
- concededTwice: (e, t, o) => parseInt(o ? e.score?.competitorTwo || "0" : e.score?.competitorOne || "0") >= 2
3240
+ noWin: (t, e, n) => !E.win(t, e, n),
3241
+ noDraw: (t) => !E.draw(t),
3242
+ noDefeat: (t, e, n) => !E.loss(t, e, n),
3243
+ scored: (t, e, n) => parseInt(n ? t.score?.competitorOne || "0" : t.score?.competitorTwo || "0") >= 1,
3244
+ conceded: (t, e, n) => parseInt(n ? t.score?.competitorTwo || "0" : t.score?.competitorOne || "0") >= 1,
3245
+ noGoalScored: (t, e, n) => !E.scored(t, e, n),
3246
+ noGoalConceded: (t, e, n) => !E.conceded(t, e, n),
3247
+ over25: (t) => parseInt(t.score?.competitorOne || "0") + parseInt(t.score?.competitorTwo || "0") > 2,
3248
+ under25: (t) => parseInt(t.score?.competitorOne || "0") + parseInt(t.score?.competitorTwo || "0") < 3,
3249
+ scoredTwice: (t, e, n) => parseInt(n ? t.score?.competitorOne || "0" : t.score?.competitorTwo || "0") >= 2,
3250
+ concededTwice: (t, e, n) => parseInt(n ? t.score?.competitorTwo || "0" : t.score?.competitorOne || "0") >= 2
1946
3251
  };
1947
- function q(e, t, o) {
1948
- return {
1949
- win: C(e, t, T.win, o),
1950
- draw: C(e, t, T.draw, o),
1951
- loss: C(e, t, T.loss, o),
1952
- noWin: C(e, t, T.noWin, o),
1953
- noDraw: C(e, t, T.noDraw, o),
1954
- noDefeat: C(e, t, T.noDefeat, o),
1955
- scored: C(e, t, T.scored, o),
1956
- conceded: C(e, t, T.conceded, o),
1957
- noGoalScored: C(e, t, T.noGoalScored, o),
1958
- noGoalConceded: C(e, t, T.noGoalConceded, o),
1959
- over25: C(e, t, T.over25, o),
1960
- under25: C(e, t, T.under25, o),
1961
- scoredTwice: C(e, t, T.scoredTwice, o),
1962
- concededTwice: C(e, t, T.concededTwice, o)
1963
- };
1964
- }
1965
- function ho(e, t, o) {
1966
- const n = q(e, t, "home"), s = q(e, t), i = q(e, o, "away"), r = q(e, o);
3252
+ function lt(t, e, n) {
3253
+ return {
3254
+ win: N(t, e, E.win, n),
3255
+ draw: N(t, e, E.draw, n),
3256
+ loss: N(t, e, E.loss, n),
3257
+ noWin: N(t, e, E.noWin, n),
3258
+ noDraw: N(t, e, E.noDraw, n),
3259
+ noDefeat: N(t, e, E.noDefeat, n),
3260
+ scored: N(t, e, E.scored, n),
3261
+ conceded: N(t, e, E.conceded, n),
3262
+ noGoalScored: N(t, e, E.noGoalScored, n),
3263
+ noGoalConceded: N(t, e, E.noGoalConceded, n),
3264
+ over25: N(t, e, E.over25, n),
3265
+ under25: N(t, e, E.under25, n),
3266
+ scoredTwice: N(t, e, E.scoredTwice, n),
3267
+ concededTwice: N(t, e, E.concededTwice, n)
3268
+ };
3269
+ }
3270
+ function qo(t, e, n) {
3271
+ const o = lt(t, e, "home"), s = lt(t, e), i = lt(t, n, "away"), r = lt(t, n);
1967
3272
  return [
1968
3273
  {
1969
3274
  label: "Consecutive wins",
1970
- homeTeam: { home: n.win, total: s.win },
3275
+ homeTeam: { home: o.win, total: s.win },
1971
3276
  awayTeam: { total: r.win, home: i.win },
1972
3277
  colorType: "neutral"
1973
3278
  },
1974
3279
  {
1975
3280
  label: "Consecutive draws",
1976
- homeTeam: { home: n.draw, total: s.draw },
3281
+ homeTeam: { home: o.draw, total: s.draw },
1977
3282
  awayTeam: { total: r.draw, home: i.draw },
1978
3283
  colorType: "neutral"
1979
3284
  },
1980
3285
  {
1981
3286
  label: "Consecutive defeats",
1982
- homeTeam: { home: n.loss, total: s.loss },
3287
+ homeTeam: { home: o.loss, total: s.loss },
1983
3288
  awayTeam: { total: r.loss, home: i.loss },
1984
3289
  colorType: "neutral"
1985
3290
  },
1986
3291
  {
1987
3292
  label: "No win",
1988
- homeTeam: { home: n.noWin, total: s.noWin },
3293
+ homeTeam: { home: o.noWin, total: s.noWin },
1989
3294
  awayTeam: { total: r.noWin, home: i.noWin },
1990
3295
  colorType: "negative"
1991
3296
  },
1992
3297
  {
1993
3298
  label: "No draw",
1994
- homeTeam: { home: n.noDraw, total: s.noDraw },
3299
+ homeTeam: { home: o.noDraw, total: s.noDraw },
1995
3300
  awayTeam: { total: r.noDraw, home: i.noDraw },
1996
3301
  colorType: "neutral"
1997
3302
  },
1998
3303
  {
1999
3304
  label: "No defeat",
2000
- homeTeam: { home: n.noDefeat, total: s.noDefeat },
3305
+ homeTeam: { home: o.noDefeat, total: s.noDefeat },
2001
3306
  awayTeam: { total: r.noDefeat, home: i.noDefeat },
2002
3307
  colorType: "positive"
2003
3308
  },
2004
3309
  {
2005
3310
  label: "Scored at least once",
2006
- homeTeam: { home: n.scored, total: s.scored },
3311
+ homeTeam: { home: o.scored, total: s.scored },
2007
3312
  awayTeam: { total: r.scored, home: i.scored },
2008
3313
  colorType: "positive"
2009
3314
  },
2010
3315
  {
2011
3316
  label: "Conceded at least once",
2012
- homeTeam: { home: n.conceded, total: s.conceded },
3317
+ homeTeam: { home: o.conceded, total: s.conceded },
2013
3318
  awayTeam: { total: r.conceded, home: i.conceded },
2014
3319
  colorType: "negative"
2015
3320
  },
2016
3321
  {
2017
3322
  label: "No goal scored",
2018
- homeTeam: { home: n.noGoalScored, total: s.noGoalScored },
3323
+ homeTeam: { home: o.noGoalScored, total: s.noGoalScored },
2019
3324
  awayTeam: { total: r.noGoalScored, home: i.noGoalScored },
2020
3325
  colorType: "neutral"
2021
3326
  },
2022
3327
  {
2023
3328
  label: "No goal conceded",
2024
- homeTeam: { home: n.noGoalConceded, total: s.noGoalConceded },
3329
+ homeTeam: { home: o.noGoalConceded, total: s.noGoalConceded },
2025
3330
  awayTeam: { total: r.noGoalConceded, home: i.noGoalConceded },
2026
3331
  colorType: "neutral"
2027
3332
  },
2028
3333
  {
2029
3334
  label: "GS + GC over 2.5",
2030
- homeTeam: { home: n.over25, total: s.over25 },
3335
+ homeTeam: { home: o.over25, total: s.over25 },
2031
3336
  awayTeam: { total: r.over25, home: i.over25 },
2032
3337
  colorType: "neutral"
2033
3338
  },
2034
3339
  {
2035
3340
  label: "GS + GC under 2.5",
2036
- homeTeam: { home: n.under25, total: s.under25 },
3341
+ homeTeam: { home: o.under25, total: s.under25 },
2037
3342
  awayTeam: { total: r.under25, home: i.under25 },
2038
3343
  colorType: "neutral"
2039
3344
  },
2040
3345
  {
2041
3346
  label: "Scored at least twice",
2042
- homeTeam: { home: n.scoredTwice, total: s.scoredTwice },
3347
+ homeTeam: { home: o.scoredTwice, total: s.scoredTwice },
2043
3348
  awayTeam: { total: r.scoredTwice, home: i.scoredTwice },
2044
3349
  colorType: "positive"
2045
3350
  },
2046
3351
  {
2047
3352
  label: "Conceded at least twice",
2048
- homeTeam: { home: n.concededTwice, total: s.concededTwice },
3353
+ homeTeam: { home: o.concededTwice, total: s.concededTwice },
2049
3354
  awayTeam: { total: r.concededTwice, home: i.concededTwice },
2050
3355
  colorType: "negative"
2051
3356
  }
2052
3357
  ];
2053
3358
  }
2054
- function w(e, t) {
2055
- const o = /* @__PURE__ */ new Map();
2056
- return e.forEach((n) => {
2057
- if (n.status?.type !== "FINISHED") return;
2058
- const s = Ct(n, t);
3359
+ function Rt(t, e) {
3360
+ const n = /* @__PURE__ */ new Map();
3361
+ return t.forEach((o) => {
3362
+ if (o.status?.type !== "FINISHED") return;
3363
+ const s = $n(o, e);
2059
3364
  if (!s) return;
2060
- const i = s.isHome ? n.competitorTwo.id : n.competitorOne.id, r = s.isHome ? n.competitorTwo : n.competitorOne, a = o.get(i) || {
3365
+ const i = s.isHome ? o.competitorTwo.id : o.competitorOne.id, r = s.isHome ? o.competitorTwo : o.competitorOne, a = n.get(i) || {
2061
3366
  opponentId: i,
2062
3367
  opponentName: r.name,
2063
3368
  opponentLogo: r.assets?.logo
2064
3369
  };
2065
- s.isHome ? a.homeResult = s.result : a.awayResult = s.result, o.set(i, a);
2066
- }), o;
3370
+ s.isHome ? a.homeResult = s.result : a.awayResult = s.result, n.set(i, a);
3371
+ }), n;
2067
3372
  }
2068
- function To(e, t, o, n, s, i, r) {
2069
- const a = w(e, t), d = w(e, o), l = /* @__PURE__ */ new Set([
3373
+ function Qo(t, e, n, o, s, i, r) {
3374
+ const a = Rt(t, e), c = Rt(t, n), d = /* @__PURE__ */ new Set([
2070
3375
  ...a.keys(),
2071
- ...d.keys(),
2072
- t,
3376
+ ...c.keys(),
3377
+ e,
2073
3378
  // Include home team as row for away team results
2074
- o
3379
+ n
2075
3380
  // Include away team as row for home team results
2076
- ]), u = [];
2077
- return l.forEach((c) => {
2078
- const m = a.get(c), g = d.get(c);
2079
- if (!m && !g && c !== t && c !== o)
3381
+ ]), f = [];
3382
+ return d.forEach((l) => {
3383
+ const u = a.get(l), h = c.get(l);
3384
+ if (!u && !h && l !== e && l !== n)
2080
3385
  return;
2081
- let p, h;
2082
- c === t ? (p = n, h = i) : c === o ? (p = s, h = r) : (p = m?.opponentName || g?.opponentName || "", h = m?.opponentLogo || g?.opponentLogo), u.push({
2083
- opponentId: c,
3386
+ let p, y;
3387
+ l === e ? (p = o, y = i) : l === n ? (p = s, y = r) : (p = u?.opponentName || h?.opponentName || "", y = u?.opponentLogo || h?.opponentLogo), f.push({
3388
+ opponentId: l,
2084
3389
  opponentName: p,
2085
- opponentLogo: h,
2086
- homeTeamHome: m?.homeResult,
2087
- homeTeamAway: m?.awayResult,
2088
- awayTeamHome: g?.homeResult,
2089
- awayTeamAway: g?.awayResult,
2090
- isHomeTeamRow: c === t,
2091
- isAwayTeamRow: c === o
3390
+ opponentLogo: y,
3391
+ homeTeamHome: u?.homeResult,
3392
+ homeTeamAway: u?.awayResult,
3393
+ awayTeamHome: h?.homeResult,
3394
+ awayTeamAway: h?.awayResult,
3395
+ isHomeTeamRow: l === e,
3396
+ isAwayTeamRow: l === n
2092
3397
  });
2093
- }), u.sort((c, m) => c.isHomeTeamRow ? -1 : m.isHomeTeamRow ? 1 : c.isAwayTeamRow ? -1 : m.isAwayTeamRow ? 1 : c.opponentName.localeCompare(m.opponentName));
3398
+ }), f.sort((l, u) => l.isHomeTeamRow ? -1 : u.isHomeTeamRow ? 1 : l.isAwayTeamRow ? -1 : u.isAwayTeamRow ? 1 : l.opponentName.localeCompare(u.opponentName));
2094
3399
  }
2095
3400
  export {
2096
- yt as GOAL_EVENT_TYPES,
2097
- So as addProviderRef,
2098
- b as aggregatePlayerStatisticsFromMatches,
2099
- ht as analyzeMatch,
2100
- W as calcAverage,
2101
- N as calcPercentage,
2102
- mo as calculateH2HStats,
2103
- C as calculateStreak,
2104
- io as formatAsAverage,
2105
- ro as formatPossessionPercentage,
2106
- no as formatStatValue,
2107
- so as formatWithAverage,
2108
- Bt as getActiveSeason,
2109
- gt as getAllPlayerStatisticsFromMatches,
2110
- Rt as getBasketballLivescore,
2111
- Co as getBatchMatchOdds,
2112
- A as getConfig,
2113
- It as getFansUnitedFootballCompetition,
2114
- Lt as getFansUnitedFootballCompetitions,
2115
- kt as getFansUnitedFootballMatch,
2116
- Ht as getFansUnitedFootballMatches,
2117
- Pt as getFansUnitedFootballPlayer,
2118
- bt as getFansUnitedFootballPlayers,
2119
- Ut as getFansUnitedFootballSearch,
2120
- Gt as getFansUnitedFootballTeam,
2121
- Dt as getFansUnitedFootballTeams,
2122
- Ao as getFootballCompetition,
2123
- Oo as getFootballLivescore,
2124
- No as getFootballMatch,
2125
- Ro as getFootballMatchCommentary,
2126
- Fo as getFootballMatchEvents,
2127
- Eo as getFootballMatchLineups,
2128
- Mo as getFootballMatchOdds,
2129
- Lo as getFootballMatchStatistics,
2130
- Io as getFootballMatches,
2131
- Go as getFootballPlayerSeasonStatistics,
2132
- Do as getFootballSeasonDetails,
2133
- Po as getFootballStandings,
2134
- bo as getFootballTeam,
2135
- ko as getFootballTeamSquad,
2136
- Ho as getLeaderboardMatches,
2137
- Uo as getLeaderboardTeamMatches,
2138
- Bo as getLeaderboardTemplate,
2139
- Ct as getMatchResult,
2140
- mt as getMostCardedPlayersFromMatches,
2141
- uo as getOpponentScore,
2142
- $o as getProviderRefId,
2143
- fo as getRecentH2HMeetings,
2144
- qt as getTeamFinishedMatches,
2145
- yo as getTeamGoalStats,
2146
- go as getTeamHomeAwayStats,
2147
- Qt as getTeamMostDecorated,
2148
- $t as getTeamNextMatch,
2149
- po as getTeamOverUnderStats,
2150
- xt as getTeamPreviousMatch,
2151
- Vt as getTeamResultsTable,
2152
- lo as getTeamScore,
2153
- Mt as getTeamSeasonStatistics,
2154
- q as getTeamStreaks,
2155
- ho as getTeamStreaksComparison,
2156
- Yt as getTeamTopAppearances,
2157
- Kt as getTeamTopAssisters,
2158
- Jt as getTeamTopCleanSheets,
2159
- zt as getTeamTopMinutesPlayed,
2160
- jt as getTeamTopScorers,
2161
- Wt as getTeamUpcomingMatches,
2162
- To as getTeamsCommonOpponents,
2163
- Ft as getTennisLivescore,
2164
- ut as getTopAssistersFromMatches,
2165
- ft as getTopGoalContributorsFromMatches,
2166
- lt as getTopScorersFromMatches,
2167
- xo as isConfigured,
2168
- co as isMatchFinished,
2169
- Tt as isTeamAway,
2170
- J as isTeamHome,
2171
- ao as isTeamInMatch,
2172
- Et as search,
2173
- Nt as searchFootball,
2174
- Wo as setConfig,
2175
- T as streakFilters,
2176
- _ as toProviderRefArray,
2177
- to as useAllPlayerStatisticsFromMatches,
2178
- wt as useMostCardedPlayersFromMatches,
2179
- oo as usePlayerStatistics,
2180
- pt as usePlayerStatisticsMap,
2181
- Zt as useTopAssistersFromMatches,
2182
- eo as useTopGoalContributorsFromMatches,
2183
- Xt as useTopScorersFromMatches
3401
+ Gn as GOAL_EVENT_TYPES,
3402
+ Xo as addProviderRef,
3403
+ Z as aggregatePlayerStatisticsFromMatches,
3404
+ Dn as analyzeMatch,
3405
+ q as cached,
3406
+ Tn as cachedBatch,
3407
+ ct as calcAverage,
3408
+ I as calcPercentage,
3409
+ Bo as calculateH2HStats,
3410
+ N as calculateStreak,
3411
+ Do as formatAsAverage,
3412
+ Uo as formatPossessionPercentage,
3413
+ Mo as formatStatValue,
3414
+ Go as formatWithAverage,
3415
+ go as getActiveSeason,
3416
+ Pn as getAllPlayerStatisticsFromMatches,
3417
+ Yn as getBasketballLivescore,
3418
+ Jo as getBatchMatchOdds,
3419
+ b as getConfig,
3420
+ lo as getFansUnitedCompetitions,
3421
+ ho as getFansUnitedCountries,
3422
+ co as getFansUnitedEntitiesByIds,
3423
+ ao as getFansUnitedEntityById,
3424
+ Xn as getFansUnitedFootballCompetition,
3425
+ Kn as getFansUnitedFootballCompetitions,
3426
+ eo as getFansUnitedFootballMatch,
3427
+ no as getFansUnitedFootballMatches,
3428
+ wn as getFansUnitedFootballPlayer,
3429
+ to as getFansUnitedFootballPlayers,
3430
+ oo as getFansUnitedFootballSearch,
3431
+ Jn as getFansUnitedFootballTeam,
3432
+ Zn as getFansUnitedFootballTeams,
3433
+ ro as getFansUnitedSearchEntities,
3434
+ fo as getFansUnitedTeamsByCompetition,
3435
+ uo as getFansUnitedTeamsByCountry,
3436
+ mo as getFansUnitedVenues,
3437
+ Zo as getFootballCompetition,
3438
+ wo as getFootballLivescore,
3439
+ ts as getFootballMatch,
3440
+ es as getFootballMatchCommentary,
3441
+ ns as getFootballMatchEvents,
3442
+ os as getFootballMatchLineups,
3443
+ ss as getFootballMatchOdds,
3444
+ is as getFootballMatchStatistics,
3445
+ rs as getFootballMatches,
3446
+ as as getFootballPlayerSeasonStatistics,
3447
+ cs as getFootballSeasonDetails,
3448
+ ls as getFootballStandings,
3449
+ ds as getFootballTeam,
3450
+ us as getFootballTeamSquad,
3451
+ fs as getLeaderboardMatches,
3452
+ hs as getLeaderboardTeamMatches,
3453
+ ms as getLeaderboardTemplate,
3454
+ $n as getMatchResult,
3455
+ Rn as getMostCardedPlayersFromMatches,
3456
+ $o as getOpponentScore,
3457
+ gs as getProviderRefId,
3458
+ Wo as getRecentH2HMeetings,
3459
+ Qn as getSportal365Standings,
3460
+ _o as getTeamFinishedMatches,
3461
+ jo as getTeamGoalStats,
3462
+ zo as getTeamHomeAwayStats,
3463
+ Fo as getTeamMostDecorated,
3464
+ po as getTeamNextMatch,
3465
+ Yo as getTeamOverUnderStats,
3466
+ yo as getTeamPreviousMatch,
3467
+ vo as getTeamResultsTable,
3468
+ ko as getTeamScore,
3469
+ Vn as getTeamSeasonStatistics,
3470
+ lt as getTeamStreaks,
3471
+ qo as getTeamStreaksComparison,
3472
+ Co as getTeamTopAppearances,
3473
+ Ao as getTeamTopAssisters,
3474
+ Eo as getTeamTopCleanSheets,
3475
+ Oo as getTeamTopMinutesPlayed,
3476
+ So as getTeamTopScorers,
3477
+ To as getTeamUpcomingMatches,
3478
+ Qo as getTeamsCommonOpponents,
3479
+ jn as getTennisLivescore,
3480
+ Nn as getTopAssistersFromMatches,
3481
+ In as getTopGoalContributorsFromMatches,
3482
+ bn as getTopScorersFromMatches,
3483
+ so as initL2,
3484
+ io as invalidate,
3485
+ ee as isConfigured,
3486
+ Ho as isMatchFinished,
3487
+ Un as isTeamAway,
3488
+ Ct as isTeamHome,
3489
+ xo as isTeamInMatch,
3490
+ qn as search,
3491
+ zn as searchFootball,
3492
+ ps as setConfig,
3493
+ E as streakFilters,
3494
+ L as toProviderRefArray,
3495
+ Io as useAllPlayerStatisticsFromMatches,
3496
+ No as useMostCardedPlayersFromMatches,
3497
+ Po as usePlayerStatistics,
3498
+ Mn as usePlayerStatisticsMap,
3499
+ bo as useTopAssistersFromMatches,
3500
+ Ro as useTopGoalContributorsFromMatches,
3501
+ Lo as useTopScorersFromMatches
2184
3502
  };