fansunited-data-layer 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +44 -0
  2. package/dist/api/sportal365-sports/football/competitions/competition.types.d.ts +148 -0
  3. package/dist/api/sportal365-sports/football/competitions/competition.types.d.ts.map +1 -0
  4. package/dist/api/sportal365-sports/football/competitions/index.d.ts +51 -0
  5. package/dist/api/sportal365-sports/football/competitions/index.d.ts.map +1 -0
  6. package/dist/api/sportal365-sports/football/competitions/utils.d.ts +14 -0
  7. package/dist/api/sportal365-sports/football/competitions/utils.d.ts.map +1 -0
  8. package/dist/api/sportal365-sports/football/index.d.ts +2 -0
  9. package/dist/api/sportal365-sports/football/index.d.ts.map +1 -1
  10. package/dist/api/sportal365-sports/football/matches/index.d.ts.map +1 -1
  11. package/dist/api/sportal365-sports/football/matches/types/commentary.types.d.ts +3 -0
  12. package/dist/api/sportal365-sports/football/matches/types/commentary.types.d.ts.map +1 -1
  13. package/dist/api/sportal365-sports/football/matches/types/option.types.d.ts +13 -0
  14. package/dist/api/sportal365-sports/football/matches/types/option.types.d.ts.map +1 -1
  15. package/dist/api/sportal365-sports/football/standings/http.d.ts.map +1 -1
  16. package/dist/api/sportal365-sports/football/standings/index.d.ts.map +1 -1
  17. package/dist/api/sportal365-sports/football/standings/standing.types.d.ts +3 -0
  18. package/dist/api/sportal365-sports/football/standings/standing.types.d.ts.map +1 -1
  19. package/dist/api/sportal365-sports/football/teams/index.d.ts.map +1 -1
  20. package/dist/api/sportal365-sports/football/teams/team.types.d.ts +3 -0
  21. package/dist/api/sportal365-sports/football/teams/team.types.d.ts.map +1 -1
  22. package/dist/api/sportal365-sports/http.d.ts +12 -0
  23. package/dist/api/sportal365-sports/http.d.ts.map +1 -1
  24. package/dist/api/sportal365-sports/index.d.ts +3 -2
  25. package/dist/api/sportal365-sports/index.d.ts.map +1 -1
  26. package/dist/client.cjs +6 -0
  27. package/dist/client.d.ts +20 -0
  28. package/dist/client.d.ts.map +1 -0
  29. package/dist/client.js +451 -0
  30. package/dist/fansunited-data-layer.cjs +1 -0
  31. package/dist/fansunited-data-layer.js +52 -1093
  32. package/dist/helpers/competition.helpers.d.ts +22 -0
  33. package/dist/helpers/competition.helpers.d.ts.map +1 -0
  34. package/dist/helpers/index.d.ts +6 -0
  35. package/dist/helpers/index.d.ts.map +1 -0
  36. package/dist/helpers/team.helpers.d.ts +45 -0
  37. package/dist/helpers/team.helpers.d.ts.map +1 -0
  38. package/dist/index-4gbkCyy3.cjs +1 -0
  39. package/dist/index-C8byrMrI.js +806 -0
  40. package/dist/index.d.ts +5 -4
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/providers/competition.provider.d.ts +1 -1
  43. package/dist/providers/competition.provider.d.ts.map +1 -1
  44. package/dist/providers/competition.types.d.ts +21 -3
  45. package/dist/providers/competition.types.d.ts.map +1 -1
  46. package/dist/types/canonical/base.types.d.ts +51 -0
  47. package/dist/types/canonical/base.types.d.ts.map +1 -1
  48. package/dist/types/canonical/index.d.ts +1 -1
  49. package/dist/types/canonical/index.d.ts.map +1 -1
  50. package/package.json +8 -3
  51. package/dist/fansunited-data-layer.umd.cjs +0 -6
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Competition helper functions
3
+ */
4
+ import type { FUSportsCompetition, FUSportsSeason } from "../types/canonical";
5
+ /**
6
+ * Get the active season from a competition
7
+ *
8
+ * Returns the season where `active` is true. If no season is active,
9
+ * returns the first season in the list (typically the most recent).
10
+ *
11
+ * @param competition - The competition with seasons array
12
+ * @returns The active season, or the first season, or undefined if no seasons exist
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const competition = await getFootballCompetition('3');
17
+ * const activeSeason = getActiveSeason(competition);
18
+ * console.log(activeSeason?.name); // "2024/2025"
19
+ * ```
20
+ */
21
+ export declare function getActiveSeason(competition: FUSportsCompetition): FUSportsSeason | undefined;
22
+ //# sourceMappingURL=competition.helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"competition.helpers.d.ts","sourceRoot":"","sources":["../../src/lib/helpers/competition.helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAE9E;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,mBAAmB,GAAG,cAAc,GAAG,SAAS,CAU5F"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Helper functions for FansUnited Data Layer
3
+ */
4
+ export { getActiveSeason } from "./competition.helpers";
5
+ export { getTeamNextMatch, getTeamPreviousMatch } from "./team.helpers";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/helpers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Team helper functions
3
+ */
4
+ import type { FUSportsMatch } from "../types/canonical";
5
+ /**
6
+ * Get the next upcoming match for a team from a list of matches
7
+ *
8
+ * Filters matches to find the team's next scheduled match (NOT_STARTED or LIVE)
9
+ * with the earliest start time from now.
10
+ *
11
+ * @param teamId - The team ID
12
+ * @param matches - Array of matches to filter through
13
+ * @returns The next match or undefined if no upcoming match found
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const matches = await getFootballMatches({ teamIds: ['102'], limit: 50, offset: 0 });
18
+ * const nextMatch = getTeamNextMatch('102', matches);
19
+ * if (nextMatch) {
20
+ * console.log(`Next: ${nextMatch.competitorOne.name} vs ${nextMatch.competitorTwo.name}`);
21
+ * console.log(`Kickoff: ${nextMatch.timing.kickoffTime}`);
22
+ * }
23
+ * ```
24
+ */
25
+ export declare function getTeamNextMatch(teamId: string, matches: FUSportsMatch[]): FUSportsMatch | undefined;
26
+ /**
27
+ * Get the previous/last match for a team from a list of matches
28
+ *
29
+ * Filters matches to find the team's most recent finished match.
30
+ *
31
+ * @param teamId - The team ID
32
+ * @param matches - Array of matches to filter through
33
+ * @returns The previous match or undefined if no finished match found
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const matches = await getFootballMatches({ teamIds: ['102'], limit: 50, offset: 0 });
38
+ * const prevMatch = getTeamPreviousMatch('102', matches);
39
+ * if (prevMatch) {
40
+ * console.log(`Last: ${prevMatch.competitorOne.name} ${prevMatch.score?.home}-${prevMatch.score?.away} ${prevMatch.competitorTwo.name}`);
41
+ * }
42
+ * ```
43
+ */
44
+ export declare function getTeamPreviousMatch(teamId: string, matches: FUSportsMatch[]): FUSportsMatch | undefined;
45
+ //# sourceMappingURL=team.helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"team.helpers.d.ts","sourceRoot":"","sources":["../../src/lib/helpers/team.helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,aAAa,GAAG,SAAS,CAepG;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,aAAa,GAAG,SAAS,CAexG"}
@@ -0,0 +1 @@
1
+ "use strict";let g=null;function A(t){g=t}function r(){if(!g)throw new Error("Data layer config not initialized. Call setConfig() in your root layout.");return g}function v(){return g!==null}function O(t){const e=t.replace(/\/$/,"");function o(){const{sportal365Sports:s}=r();if(!s)throw new Error("Sportal365 Sports API configuration is missing");const a=`${s.username}:${s.password}`;return`Basic ${btoa(a)}`}function n(s){return`${e}${s}`}return{async get(s){const{sportal365Sports:a}=r();if(!a)throw new Error("Sportal365 Sports API configuration is missing");const d=new URL(n(s.path));if(s.params)for(const[l,m]of Object.entries(s.params))m!==void 0&&(Array.isArray(m)?m.length>0&&d.searchParams.set(l,m.join(",")):d.searchParams.set(l,m));const c=await fetch(d.toString(),{method:"GET",headers:{Authorization:o(),"Content-Type":"application/json","X-Project":a.projectId},signal:a.timeout?AbortSignal.timeout(a.timeout):void 0,...s.next&&{next:s.next}});if(!c.ok)throw new Error(`Sportal365 API error: ${c.status} ${c.statusText}`);return c.json()}}}const I="https://football.api.sportal365.com",C="https://standing.api.sportal365.com",u=O(I);function _(t){if(t)return{id:t.id,name:t.name,slug:t.slug,position:t.position,gender:t.gender,assets:t.assets?{photo:t.assets.thumb?.url,photoTransparent:t.assets.thumb_transparent_background?.url}:void 0}}const b={GOAL:"GOAL",PENALTY_GOAL:"PENALTY_GOAL",OWN_GOAL:"OWN_GOAL",DISALLOWED_GOAL:"DISALLOWED_GOAL",PENALTY_SHOOTOUT_SCORED:"PENALTY_SHOOTOUT_SCORED",PENALTY_SHOOTOUT_MISSED:"PENALTY_SHOOTOUT_MISSED",YELLOW_CARD:"YELLOW_CARD",RED_CARD:"RED_CARD",YELLOW_RED_CARD:"YELLOW_RED_CARD",SUBSTITUTION:"SUBSTITUTION",KICKOFF:"KICKOFF",HALFTIME:"HALFTIME",START_SECOND_HALF:"START_SECOND_HALF",FINISHED:"FINISHED",INJURY_TIME:"INJURY_TIME",PENALTY_AWARDED:"PENALTY_AWARDED",PENALTY_MISSED:"PENALTY_MISSED",PENALTY_SAVED:"PENALTY_SAVED"};function p(t){const e=b[t.type_code];return e?{id:t.id,type:e,competitorPosition:t.team_position==="HOME"?"ONE":"TWO",minute:t.minute,injuryMinute:t.injury_minute,primaryPlayer:_(t.primary_player),secondaryPlayer:_(t.secondary_player),score:t.score?{competitorOne:String(t.score.home),competitorTwo:String(t.score.away)}:void 0}:(console.warn(`Unknown event type: ${t.type_code}`),null)}function L(t){return{code:{FINISHED:"finished",NOT_STARTED:"not_started",LIVE:"live",INTERRUPTED:"interrupted",CANCELLED:"cancelled",POSTPONED:"postponed",UNKNOWN:"not_started",ABANDONED:"abandoned"}[t.type]??"not_started",name:t.name,shortName:t.short_name,type:t.type}}function y(t){return{id:t.id,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code,slug:t.slug,type:t.type??"club",gender:t.gender,assets:t.assets?{logo:t.assets.logo?.url,homeKit:t.assets.home_kit?.url,awayKit:t.assets.away_kit?.url,squadImage:t.assets.squad_image?.url}:void 0,metadata:t.shirt_color?{shirtColor:t.shirt_color}:void 0}}function k(t){return{kickoffTime:new Date(t.kickoff_time),currentMinute:t.minute?.regular_time,phaseStartedAt:t.phase_started_at?new Date(t.phase_started_at):void 0,finishedAt:t.finished_at?new Date(t.finished_at):void 0,firstHalfStartedAt:t.first_half_started_at?new Date(t.first_half_started_at):void 0,secondHalfStartedAt:t.second_half_started_at?new Date(t.second_half_started_at):void 0,extraTimeFirstHalfStartedAt:t.extra_time_first_half_started_at?new Date(t.extra_time_first_half_started_at):void 0,extraTimeSecondHalfStartedAt:t.extra_time_second_half_started_at?new Date(t.extra_time_second_half_started_at):void 0}}function D(t){if(!t)return;const e=n=>n?{competitorOne:String(n.home),competitorTwo:String(n.away)}:void 0,o=t.total??t.regular_time;return{competitorOne:o?.home!=null?String(o.home):null,competitorTwo:o?.away!=null?String(o.away):null,breakdown:{total:e(t.total),halfTime:e(t.half_time),regularTime:e(t.regular_time),extraTime:e(t.extra_time),penaltyShootout:e(t.penalty_shootout),aggregate:e(t.aggregate)}}}function N(t){if(t)return{id:t.id,name:t.name,slug:t.slug,assets:t.assets?.image?.url?{image:t.assets.image.url}:void 0}}function F(t){if(t?.length)return t.map(e=>({id:e.id,name:e.name,slug:e.slug,role:e.role??"REFEREE",gender:e.gender}))}function P(t){if(!t.season?.tournament)return;const{tournament:e,...o}=t.season;return{id:e.id,name:e.name,slug:e.slug,type:e.type,region:e.region,country:e.country?{id:e.country.id,name:e.country.name,code:e.country.code??void 0,flag:e.country.assets?.flag?.url}:void 0,season:{id:o.id,name:o.name,status:o.status},stage:t.stage?{id:t.stage.id,name:t.stage.name,type:t.stage.type}:void 0,assets:e.assets?.logo?.url?{logo:e.assets.logo.url}:void 0}}function R(t){if(!t.winner?.match?.id)return;const e={"Regular Time":"REGULAR_TIME","Extra Time":"EXTRA_TIME",Penalties:"PENALTIES"};return{competitorId:t.winner.match.id,reason:t.winner.match.reason?.name?e[t.winner.match.reason.name]:void 0,aggregate:!!t.winner.aggregate}}function T(t){return{id:t.id,slug:t.slug,status:L(t.status),timing:k(t),competitorOne:y(t.home_team),competitorTwo:y(t.away_team),competition:P(t),round:t.round?{id:t.round.id??t.round.key,key:t.round.key,name:t.round.name,type:t.round.type??"REGULAR"}:void 0,group:t.group?{id:t.group.id,name:t.group.name}:void 0,venue:N(t.venue),officials:F(t.referees),spectators:t.spectators??void 0,score:D(t.score),mainEvents:t.main_events?.map(p).filter(e=>e!==null),penaltyShootoutEvents:t.penalty_shootout_events?.map(p).filter(e=>e!==null),winner:R(t),coverage:t.coverage==="NOT_LIVE"?"UNKNOWN":t.coverage,lineupStatus:t.lineup_status==="UNCONFIRMED"?"EXPECTED":t.lineup_status}}function x(t){const e=t.player;return{id:e.id,name:e.name,slug:e.slug,position:e.position,shirtNumber:t.shirt_number,positionX:t.position_x??void 0,positionY:t.position_y??void 0,country:e.country?{id:e.country.id,name:e.country.name,code:e.country.code}:void 0,birthdate:e.birthdate,profile:e.profile?{height:e.profile.height,weight:e.profile.weight}:void 0,events:t.events?.map(p).filter(o=>o!==null)}}function h(t){const e=[],o=[];for(const n of t.players){const s=x(n);n.type.category==="start"?e.push(s):n.type.category==="sub"&&o.push(s)}return{competitorId:t.team_id,formation:t.formation,coach:t.coach?{id:t.coach.id,name:t.coach.name,slug:t.coach.slug,country:t.coach.country?{id:t.coach.country.id,name:t.coach.country.name,code:t.coach.country.code}:void 0,birthdate:t.coach.birthdate}:void 0,starters:e,substitutes:o}}function M(t){return{matchId:t.match_id,confirmed:t.status==="CONFIRMED",competitorOne:h(t.home_team),competitorTwo:h(t.away_team)}}function i(t,e,o,n){return e==null?null:{key:t,value:String(e),label:o,unit:n}}function E(t,e){const o=(e.shots_on??0)+(e.shots_off??0)+(e.shots_blocked??0),n=[i("possession",e.possession,"Possession","%"),i("shots_total",o,"Shots"),i("shots_on_target",e.shots_on,"Shots on Target"),i("shots_off_target",e.shots_off,"Shots off Target"),i("shots_blocked",e.shots_blocked,"Shots Blocked"),i("corners",e.corners,"Corner Kicks"),i("goal_kicks",e.goal_kicks,"Goal Kicks"),i("throw_ins",e.throw_in,"Throw Ins"),i("offsides",e.offside,"Offsides"),i("fouls",e.fouls_committed,"Fouls"),i("yellow_cards",e.yellow_cards,"Yellow Cards"),i("passes",e.pass,"Passes"),i("crosses",e.crosses,"Crosses")];return{competitorId:t,statistics:n.filter(s=>s!==null)}}function U(t){const e=t.find(n=>n.home_team),o=t.find(n=>!n.home_team);if(!e||!o)throw new Error("Missing competitor statistics");return{competitorOne:E(String(e.team.id),e.statistics),competitorTwo:E(String(o.team.id),o.statistics)}}function $(t){const e=t.urls?.find(o=>o.app_type==="desktop")?.url;return{id:t.id,name:t.name,code:t.code,value:t.value??void 0,odds:t.odds,oddsOld:t.odds_old,movement:t.movement==="STABLE"?"NONE":t.movement,url:e}}function H(t){return{type:{id:t.type.id,code:t.type.code,name:t.type.name},period:{id:t.scope.id,type:t.scope.type,name:t.scope.name},selections:t.selections.map($)}}function Y(t){return{operator:{id:t.bookmaker.id,name:t.bookmaker.name,url:t.bookmaker.url,branding:t.bookmaker.branding?{backgroundColor:t.bookmaker.branding.background_color,textColor:t.bookmaker.branding.text_color,logo:t.bookmaker.assets?.[0]?.logo}:void 0},type:t.type,markets:t.markets.map(H)}}function G(t,e){return{matchId:t,operators:e.map(Y)}}function S(t){if(t==null||t==="")return;const e=typeof t=="number"?t:parseInt(t,10);return isNaN(e)?void 0:e}function W(t){return{externalId:t.external_id,minute:S(t.elapsed),addedTime:S(t.elapsed_plus),text:t.auto_text,details:t.details,meta:{type:t.type,commentaryType:t.commentary_type,subtype1:t.subtype_1,subtype2:t.subtype_2,timestamp:t.incident_timestamp}}}async function j(t,e={}){const{sportal365Sports:o}=r(),n=await u.get({path:`/v2/matches/${t}`,params:{language_code:e.languageCode??o?.languageCode??"en",odd_client:e.oddClient,odd_type:e.oddType,scope_type:e.scopeType,odd_format:e.oddFormat,market_types:e.marketTypes,bookmaker_ids:e.bookmakerIds,optional_data:e.optionalData},next:e.next});return T(n)}async function K(t,e={}){const{sportal365Sports:o}=r();return(await u.get({path:`/v2/matches/${t}/events`,params:{language_code:e.languageCode??o?.languageCode??"en"},next:e.next})).events.map(p).filter(s=>s!==null)}async function B(t,e={}){const{sportal365Sports:o}=r(),n=await u.get({path:`/v2/matches/${t}/lineups`,params:{language_code:e.languageCode??o?.languageCode??"en"},next:e.next});return M(n)}async function V(t,e={}){const{sportal365Sports:o}=r(),n=await u.get({path:`/v2/matches/${t}`,params:{language_code:e.languageCode??o?.languageCode??"en",odd_client:e.oddClient??o?.oddClient,odd_type:e.oddType,scope_type:e.scopeType??"ALL",odd_format:e.oddFormat??"DECIMAL",market_types:e.marketTypes,bookmaker_ids:e.bookmakerIds},next:e.next});return G(t,n.odds??[])}async function X(t,e={}){const{sportal365Sports:o}=r(),n=await u.get({path:`/events/${t}/teamstats`,params:{language_code:e.languageCode??o?.languageCode??"en"},next:e.next});return U(n)}async function z(t,e={}){const{sportal365Sports:o}=r();return(await u.get({path:`/matches/${t}/commentary`,params:{language_code:e.languageCode??o?.languageCode??"en"},next:e.next})).map(W)}async function q(t){const{sportal365Sports:e}=r();return(await u.get({path:"/v2/matches",params:{language_code:t.languageCode??e?.languageCode??"en",limit:t.limit.toString(),offset:t.offset.toString(),tournament_ids:t.tournamentIds,season_ids:t.seasonIds,stage_ids:t.stageIds,group_ids:t.groupIds,round_ids:t.roundIds,round_filter:t.roundFilter,from_kickoff_time:t.fromKickoffTime,to_kickoff_time:t.toKickoffTime,team_ids:t.teamIds,team_ids_operator:t.teamIdsOperator,referee_id:t.refereeId,venue_id:t.venueId,player_id:t.playerId,status_types:t.statusTypes,status_codes:t.statusCodes,odd_client:t.oddClient??e?.oddClient,odd_type:t.oddType,scope_type:t.scopeType,odd_format:t.oddFormat,market_types:t.marketTypes,bookmaker_ids:t.bookmakerIds,sort_direction:t.sortDirection,optional_data:t.optionalData},next:t.next})).matches.map(T)}function J(t){return{id:String(t.id),name:t.name,slug:t.slug,type:t.type,region:t.region,gender:t.gender,country:{id:String(t.country.id),name:t.country.name,flag:t.country.url_flag},seasons:t.seasons.map(e=>({id:String(e.id),name:e.name,slug:e.slug,active:e.active})),assets:t.url_logo?{logo:t.url_logo}:void 0}}function Q(t){const e=t.rounds.map(o=>({id:o.id,name:o.name,key:o.key,type:o.type,status:o.status,startDate:o.start_date,endDate:o.end_date}));return{id:t.stage.id,name:t.stage.name,slug:t.stage.slug,shortName:t.stage.short_name??void 0,type:t.stage.type,status:t.stage.status,coverage:t.stage.coverage,order:t.stage.order_in_season,startDate:t.stage.start_date,endDate:t.stage.end_date,rounds:e}}function Z(t){const{season:e,stages:o}=t,{tournament:n}=e,s={id:n.id,name:n.name,slug:n.slug,type:n.type,region:n.region,gender:n.gender,country:{id:n.country.id,name:n.country.name,code:n.country.code??void 0,flag:n.country.assets?.flag?.url},assets:n.assets?.logo?.url?{logo:n.assets.logo.url}:void 0};return{id:e.id,name:e.name,slug:e.slug,active:e.status==="ACTIVE",status:e.status==="ACTIVE"?"ACTIVE":"INACTIVE",competition:s,stages:o.map(Q)}}async function w(t,e={}){const{sportal365Sports:o}=r(),n=await u.get({path:`/tournaments/${t}`,params:{language_code:e.languageCode??o?.languageCode??"en"},next:e.next});return J(n)}async function tt(t={}){const{sportal365Sports:e}=r();if(!t.seasonId&&!t.competitionId)throw new Error("Either seasonId or competitionId must be provided");const o={language_code:t.languageCode??e?.languageCode??"en"};t.seasonId?o.season_id=t.seasonId:t.competitionId&&(o.tournament_id=t.competitionId,t.status&&(o.status=t.status));const n=await u.get({path:"/v2/seasons/details",params:o,next:t.next});return Z(n)}const et=C.replace(/\/$/,"");function ot(){const{sportal365Sports:t}=r();if(!t)throw new Error("Sportal365 Sports API configuration is missing");const e=`${t.username}:${t.password}`;return`Basic ${btoa(e)}`}function nt(t){return`${et}${t}`}const st={async get(t){const{sportal365Sports:e}=r();if(!e)throw new Error("Sportal365 Sports API configuration is missing");const o=new URL(nt(t.path));if(t.params)for(const[s,a]of Object.entries(t.params))a!==void 0&&(Array.isArray(a)?a.length>0&&o.searchParams.set(s,a.join(",")):o.searchParams.set(s,a));const n=await fetch(o.toString(),{method:"GET",headers:{Authorization:ot(),"Content-Type":"application/json","X-Project":e.projectId},signal:e.timeout?AbortSignal.timeout(e.timeout):void 0,...t.next&&{next:t.next}});if(!n.ok){const s=await n.text();throw new Error(`Sportal365 Standings API error: ${n.status} ${n.statusText} - ${s}`)}return n.json()}};function at(t){return{RANK:"rank",PLAYED:"played",WINS:"won",DRAWS:"drawn",LOSSES:"lost",GOALS_FOR:"goalsFor",GOALS_AGAINST:"goalsAgainst",GOAL_DIFFERENCE:"goalDifference",POINTS:"points"}[t]??t.toLowerCase()}function f(t){return{CHAMPIONS_LEAGUE:"championsLeague",EUROPA_LEAGUE:"europaLeague",CONFERENCE_LEAGUE:"conferenceLeague",RELEGATION:"relegation",PLAYOFF:"playoff",PROMOTION:"promotion"}[t]??t.toLowerCase().replace(/_/g,"")}function rt(t){switch(t){case"win":return"W";case"loss":return"L";case"draw":return"D"}}function it(t,e){if(!e||e.length===0)return;const o=e.map(s=>{const a=s.participants.find(c=>c.id!==t)??s.participants[0],d=s.result?.[0]?.results?.map(c=>c.value).join("-")??void 0;return{matchId:s.id,result:rt(s.outcome),score:d,opponent:{id:a.id,name:a.name,logo:a.display_asset?.url??a.assets?.logo?.url},date:new Date(s.start_time),competition:s.competition?{id:s.competition.id,name:s.competition.name}:void 0}}),n=o.map(s=>s.result).join("");return{competitorId:t,results:o,formString:n}}function dt(t){return{key:f(t.standing_api_rule_type),name:t.name,position:t.type}}function ct(t){const e={};let o=0;for(const d of t.columns){const c=at(d.type.code),l=parseInt(d.value,10);d.type.code==="RANK"?o=l:e[c]=isNaN(l)?void 0:l}const n=t.rules?.length>0?t.rules.map(d=>f(d.standing_api_rule_type)):void 0,s=it(t.team.id,t.form),a=t.team.assets?.logo?.url;return{rank:o,competitor:{id:t.team.id,name:t.team.name,shortName:t.team.short_name??void 0,logo:a},stats:e,form:s,rules:n}}function ut(t){const e=t.map(ct),o=new Map;for(const n of t)if(n.rules)for(const s of n.rules){const a=f(s.standing_api_rule_type);o.has(a)||o.set(a,dt(s))}return{entries:e,metadata:{legend:Array.from(o.values())}}}async function lt(t){const o=(await st.get({path:"/standings/football",params:{stage_id:t.stageId,coverage_type:t.coverageType??"ALL",optional_data:t.optionalData},next:t.next})).data?.[0];if(!o?.standings?.length)return{entries:[],metadata:{legend:[]}};const n=o.standings[0];return n?.standing?.length?ut(n.standing):{entries:[],metadata:{legend:[]}}}exports.footballHttp=u;exports.getConfig=r;exports.getFootballCompetition=w;exports.getFootballMatch=j;exports.getFootballMatchCommentary=z;exports.getFootballMatchEvents=K;exports.getFootballMatchLineups=B;exports.getFootballMatchOdds=V;exports.getFootballMatchStatistics=X;exports.getFootballMatches=q;exports.getFootballSeasonDetails=tt;exports.getFootballStandings=lt;exports.isConfigured=v;exports.setConfig=A;