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