fansunited-data-layer 0.9.0 → 0.11.1
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/football/index.d.ts +1 -1
- package/api/fansunited/football/index.d.ts.map +1 -1
- package/api/fansunited/football/matches/index.d.ts +36 -0
- package/api/fansunited/football/matches/index.d.ts.map +1 -1
- package/api/fansunited/football/matches/transformer.d.ts.map +1 -1
- package/api/fansunited/football/matches/types.d.ts +1 -0
- package/api/fansunited/football/matches/types.d.ts.map +1 -1
- package/api/fansunited/index.d.ts +3 -1
- package/api/fansunited/index.d.ts.map +1 -1
- package/api/fansunited/search/__tests__/index.test.d.ts +2 -0
- package/api/fansunited/search/__tests__/index.test.d.ts.map +1 -0
- package/api/fansunited/search/__tests__/transformer.test.d.ts +2 -0
- package/api/fansunited/search/__tests__/transformer.test.d.ts.map +1 -0
- package/api/fansunited/search/constants.d.ts +2 -0
- package/api/fansunited/search/constants.d.ts.map +1 -0
- package/api/fansunited/search/http.d.ts +5 -0
- package/api/fansunited/search/http.d.ts.map +1 -0
- package/api/fansunited/search/index.d.ts +50 -0
- package/api/fansunited/search/index.d.ts.map +1 -0
- package/api/fansunited/search/raw-types.d.ts +93 -0
- package/api/fansunited/search/raw-types.d.ts.map +1 -0
- package/api/fansunited/search/transformer.d.ts +66 -0
- package/api/fansunited/search/transformer.d.ts.map +1 -0
- package/api/fansunited/search/types.d.ts +136 -0
- package/api/fansunited/search/types.d.ts.map +1 -0
- package/api/sportal365-sports/basketball/games/transformers/game.d.ts.map +1 -1
- package/api/sportal365-sports/football/matches/transformers/match.d.ts.map +1 -1
- package/api/sportal365-sports/tennis/matches/transformers/match.d.ts.map +1 -1
- package/cache/__tests__/cache-manager.test.d.ts +2 -0
- package/cache/__tests__/cache-manager.test.d.ts.map +1 -0
- package/cache/__tests__/cleanup.test.d.ts +2 -0
- package/cache/__tests__/cleanup.test.d.ts.map +1 -0
- package/cache/__tests__/memory-store.test.d.ts +2 -0
- package/cache/__tests__/memory-store.test.d.ts.map +1 -0
- package/cache/__tests__/sqlite-store.test.d.ts +2 -0
- package/cache/__tests__/sqlite-store.test.d.ts.map +1 -0
- package/cache/cache-manager.d.ts +42 -0
- package/cache/cache-manager.d.ts.map +1 -0
- package/cache/cleanup.d.ts +7 -0
- package/cache/cleanup.d.ts.map +1 -0
- package/cache/index.d.ts +13 -0
- package/cache/index.d.ts.map +1 -0
- package/cache/memory-store.d.ts +12 -0
- package/cache/memory-store.d.ts.map +1 -0
- package/cache/sqlite-store.d.ts +19 -0
- package/cache/sqlite-store.d.ts.map +1 -0
- package/cache/types.d.ts +15 -0
- package/cache/types.d.ts.map +1 -0
- package/client.cjs +1 -1
- package/client.js +2 -2
- package/config/types.d.ts +2 -0
- package/config/types.d.ts.map +1 -1
- package/fansunited-data-layer.cjs +1 -1
- package/fansunited-data-layer.js +2643 -1455
- package/index.d.ts +5 -3
- package/index.d.ts.map +1 -1
- package/matches-CINPI4_G.cjs +1 -0
- package/{matches-CIte0UPI.js → matches-CIPlUJky.js} +23 -21
- package/package.json +11 -3
- package/types/canonical/base.types.d.ts +28 -2
- package/types/canonical/base.types.d.ts.map +1 -1
- package/types/canonical/index.d.ts +1 -1
- package/types/canonical/index.d.ts.map +1 -1
- package/types/canonical/match.types.d.ts +1 -0
- package/types/canonical/match.types.d.ts.map +1 -1
- package/matches-D5jlWsqr.cjs +0 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache Manager - Orchestrates L1 (memory) + optional L2 with SWR pattern
|
|
3
|
+
*
|
|
4
|
+
* L2 (SQLite) is never statically imported here — it's injected at runtime
|
|
5
|
+
* via initL2() so that browser bundles don't pull in better-sqlite3.
|
|
6
|
+
*/
|
|
7
|
+
import type { CacheEntry, EntityCacheConfig, EntityType } from "./types";
|
|
8
|
+
/** Interface that L2 stores must satisfy */
|
|
9
|
+
export interface L2Store {
|
|
10
|
+
get isInitialized(): boolean;
|
|
11
|
+
get<T>(key: string): CacheEntry<T> | undefined;
|
|
12
|
+
set(key: string, entity: string, data: unknown): void;
|
|
13
|
+
setMany(entries: {
|
|
14
|
+
key: string;
|
|
15
|
+
entity: string;
|
|
16
|
+
data: unknown;
|
|
17
|
+
}[]): void;
|
|
18
|
+
cleanup(entity: string, maxTTLSeconds: number): number;
|
|
19
|
+
clear(): void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Initialize L2 cache layer. Call on server startup.
|
|
23
|
+
* Client-side apps skip this — L2 is never loaded.
|
|
24
|
+
*/
|
|
25
|
+
export declare function initL2(store: L2Store): void;
|
|
26
|
+
/** Get the L2 store (if initialized) */
|
|
27
|
+
export declare function getL2(): L2Store | null;
|
|
28
|
+
declare const ENTITY_TTL_CONFIG: Record<EntityType, EntityCacheConfig>;
|
|
29
|
+
/**
|
|
30
|
+
* Single-key cache-through with SWR (Stale-While-Revalidate)
|
|
31
|
+
*/
|
|
32
|
+
export declare function cached<T>(key: string, entity: EntityType, fetcher: () => Promise<T>): Promise<T>;
|
|
33
|
+
/**
|
|
34
|
+
* Smart batch cache — only fetches uncached IDs from the API
|
|
35
|
+
*/
|
|
36
|
+
export declare function cachedBatch<T>(ids: string[], entity: EntityType, batchFetcher: (missingIds: string[]) => Promise<Map<string, T>>, keyFn: (id: string) => string): Promise<Map<string, T>>;
|
|
37
|
+
/**
|
|
38
|
+
* Remove an entry from both cache layers
|
|
39
|
+
*/
|
|
40
|
+
export declare function invalidate(key: string): void;
|
|
41
|
+
export { ENTITY_TTL_CONFIG };
|
|
42
|
+
//# sourceMappingURL=cache-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-manager.d.ts","sourceRoot":"","sources":["../../src/lib/cache/cache-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEzE,4CAA4C;AAC5C,MAAM,WAAW,OAAO;IACpB,IAAI,aAAa,IAAI,OAAO,CAAC;IAC7B,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IAC/C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IACtD,OAAO,CAAC,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,EAAE,GAAG,IAAI,CAAC;IACzE,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC;IACvD,KAAK,IAAI,IAAI,CAAC;CACjB;AAKD;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAE3C;AAED,wCAAwC;AACxC,wBAAgB,KAAK,IAAI,OAAO,GAAG,IAAI,CAEtC;AAED,QAAA,MAAM,iBAAiB,EAAE,MAAM,CAAC,UAAU,EAAE,iBAAiB,CAQ5D,CAAC;AAwCF;;GAEG;AACH,wBAAsB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAoCtG;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,CAAC,EAC/B,GAAG,EAAE,MAAM,EAAE,EACb,MAAM,EAAE,UAAU,EAClB,YAAY,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAC/D,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,GAC9B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CA6DzB;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE5C;AAGD,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanup.d.ts","sourceRoot":"","sources":["../../src/lib/cache/cleanup.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,wBAAgB,UAAU,IAAI,IAAI,CAWjC;AAED,wBAAgB,oBAAoB,CAAC,UAAU,SAAiB,GAAG,IAAI,CAGtE;AAED,wBAAgB,mBAAmB,IAAI,IAAI,CAK1C"}
|
package/cache/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache layer - public API
|
|
3
|
+
*
|
|
4
|
+
* NOTE: sqlite-store.ts is NOT exported here to avoid pulling better-sqlite3
|
|
5
|
+
* into browser bundles. Server-side consumers should import it directly:
|
|
6
|
+
* import { initSqliteStore, sqliteStore } from './cache/sqlite-store';
|
|
7
|
+
*/
|
|
8
|
+
export { memoryStore } from "./memory-store";
|
|
9
|
+
export { cached, cachedBatch, invalidate, initL2 } from "./cache-manager";
|
|
10
|
+
export type { L2Store } from "./cache-manager";
|
|
11
|
+
export { runCleanup, startCleanupSchedule, stopCleanupSchedule } from "./cleanup";
|
|
12
|
+
export type { CacheEntry, EntityCacheConfig, EntityType } from "./types";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/cache/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC1E,YAAY,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAClF,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* L1 Cache - LRU in-memory store
|
|
3
|
+
*/
|
|
4
|
+
import type { CacheEntry } from "./types";
|
|
5
|
+
export declare const memoryStore: {
|
|
6
|
+
get<T>(key: string): CacheEntry<T> | undefined;
|
|
7
|
+
set<T>(key: string, data: T): void;
|
|
8
|
+
delete(key: string): void;
|
|
9
|
+
clear(): void;
|
|
10
|
+
readonly size: number;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=memory-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-store.d.ts","sourceRoot":"","sources":["../../src/lib/cache/memory-store.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAW1C,eAAO,MAAM,WAAW;QAChB,CAAC,OAAO,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS;QAI1C,CAAC,OAAO,MAAM,QAAQ,CAAC,GAAG,IAAI;gBAItB,MAAM,GAAG,IAAI;aAIhB,IAAI;mBAID,MAAM;CAGrB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* L2 Cache - SQLite on-disk store (server-only)
|
|
3
|
+
*/
|
|
4
|
+
import type { CacheEntry } from "./types";
|
|
5
|
+
export declare function initSqliteStore(dbPath?: string): void;
|
|
6
|
+
export declare const sqliteStore: {
|
|
7
|
+
readonly isInitialized: boolean;
|
|
8
|
+
get<T>(key: string): CacheEntry<T> | undefined;
|
|
9
|
+
set(key: string, entity: string, data: unknown): void;
|
|
10
|
+
setMany(entries: {
|
|
11
|
+
key: string;
|
|
12
|
+
entity: string;
|
|
13
|
+
data: unknown;
|
|
14
|
+
}[]): void;
|
|
15
|
+
cleanup(entity: string, maxTTLSeconds: number): number;
|
|
16
|
+
clear(): void;
|
|
17
|
+
close(): void;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=sqlite-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-store.d.ts","sourceRoot":"","sources":["../../src/lib/cache/sqlite-store.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAW1C,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CA4BrD;AAED,eAAO,MAAM,WAAW;4BACC,OAAO;QAIxB,CAAC,OAAO,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS;aAarC,MAAM,UAAU,MAAM,QAAQ,OAAO,GAAG,IAAI;qBASpC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,EAAE,GAAG,IAAI;oBAgBxD,MAAM,iBAAiB,MAAM,GAAG,MAAM;aAQ7C,IAAI;aAIJ,IAAI;CAMhB,CAAC"}
|
package/cache/types.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared cache types
|
|
3
|
+
*/
|
|
4
|
+
export interface CacheEntry<T> {
|
|
5
|
+
data: T;
|
|
6
|
+
storedAt: number;
|
|
7
|
+
}
|
|
8
|
+
export interface EntityCacheConfig {
|
|
9
|
+
/** Time in seconds before data is considered stale (triggers background refresh) */
|
|
10
|
+
staleTTL: number;
|
|
11
|
+
/** Time in seconds before data is completely expired and must be re-fetched */
|
|
12
|
+
maxTTL: number;
|
|
13
|
+
}
|
|
14
|
+
export type EntityType = "competitions" | "teams" | "athletes" | "venues" | "countries" | "coaches" | "search";
|
|
15
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/cache/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,UAAU,CAAC,CAAC;IACzB,IAAI,EAAE,CAAC,CAAC;IACR,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAC9B,oFAAoF;IACpF,QAAQ,EAAE,MAAM,CAAC;IACjB,+EAA+E;IAC/E,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC"}
|
package/client.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react"),B=require("./matches-
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react"),B=require("./matches-CINPI4_G.cjs");var at={exports:{}},$e={};var ya;function Ss(){if(ya)return $e;ya=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function a(i,s,r){var n=null;if(r!==void 0&&(n=""+r),s.key!==void 0&&(n=""+s.key),"key"in s){r={};for(var o in s)o!=="key"&&(r[o]=s[o])}else r=s;return s=r.ref,{$$typeof:e,type:i,key:n,ref:s!==void 0?s:null,props:r}}return $e.Fragment=t,$e.jsx=a,$e.jsxs=a,$e}var Ue={};var wa;function Cs(){return wa||(wa=1,process.env.NODE_ENV!=="production"&&(function(){function e(w){if(w==null)return null;if(typeof w=="function")return w.$$typeof===P?null:w.displayName||w.name||null;if(typeof w=="string")return w;switch(w){case T:return"Fragment";case O:return"Profiler";case I:return"StrictMode";case g:return"Suspense";case f:return"SuspenseList";case M:return"Activity"}if(typeof w=="object")switch(typeof w.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),w.$$typeof){case v:return"Portal";case G:return w.displayName||"Context";case C:return(w._context.displayName||"Context")+".Consumer";case A:var R=w.render;return w=w.displayName,w||(w=R.displayName||R.name||"",w=w!==""?"ForwardRef("+w+")":"ForwardRef"),w;case y:return R=w.displayName||null,R!==null?R:e(w.type)||"Memo";case b:R=w._payload,w=w._init;try{return e(w(R))}catch{}}return null}function t(w){return""+w}function a(w){try{t(w);var R=!1}catch{R=!0}if(R){R=console;var F=R.error,N=typeof Symbol=="function"&&Symbol.toStringTag&&w[Symbol.toStringTag]||w.constructor.name||"Object";return F.call(R,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",N),t(w)}}function i(w){if(w===T)return"<>";if(typeof w=="object"&&w!==null&&w.$$typeof===b)return"<...>";try{var R=e(w);return R?"<"+R+">":"<...>"}catch{return"<...>"}}function s(){var w=D.A;return w===null?null:w.getOwner()}function r(){return Error("react-stack-top-frame")}function n(w){if(U.call(w,"key")){var R=Object.getOwnPropertyDescriptor(w,"key").get;if(R&&R.isReactWarning)return!1}return w.key!==void 0}function o(w,R){function F(){re||(re=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",R))}F.isReactWarning=!0,Object.defineProperty(w,"key",{get:F,configurable:!0})}function l(){var w=e(this.type);return ie[w]||(ie[w]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),w=this.props.ref,w!==void 0?w:null}function c(w,R,F,N,ne,Ie){var $=F.ref;return w={$$typeof:_,type:w,key:R,props:F,_owner:N},($!==void 0?$:null)!==null?Object.defineProperty(w,"ref",{enumerable:!1,get:l}):Object.defineProperty(w,"ref",{enumerable:!1,value:null}),w._store={},Object.defineProperty(w._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(w,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(w,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ne}),Object.defineProperty(w,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Ie}),Object.freeze&&(Object.freeze(w.props),Object.freeze(w)),w}function d(w,R,F,N,ne,Ie){var $=R.children;if($!==void 0)if(N)if(j($)){for(N=0;N<$.length;N++)p($[N]);Object.freeze&&Object.freeze($)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else p($);if(U.call(R,"key")){$=e(w);var ee=Object.keys(R).filter(function(Ge){return Ge!=="key"});N=0<ee.length?"{key: someKey, "+ee.join(": ..., ")+": ...}":"{key: someKey}",Z[$+N]||(ee=0<ee.length?"{"+ee.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
package/client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import Ds, { createContext as Xe, useContext as Je, useMemo as P, useCallback as v, useState as U, useEffect as ue, useRef as Ls } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { w as xs, z as Ns, n as Gs, y as ga, A as fa, B as ya, p as wa, r as $s, v as Us, q as Bs, C as Hs, E as Vs, m as Ws } from "./matches-CIPlUJky.js";
|
|
4
|
+
import { D as fh } from "./matches-CIPlUJky.js";
|
|
5
5
|
var nt = { exports: {} }, Be = {};
|
|
6
6
|
var _a;
|
|
7
7
|
function zs() {
|
package/config/types.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ export interface DataLayerConfig {
|
|
|
31
31
|
apiKey: string;
|
|
32
32
|
/** Client ID for FansUnited services (required) */
|
|
33
33
|
clientId: string;
|
|
34
|
+
/** Default language for search results (e.g., "EN", "BG"). Defaults to "EN" */
|
|
35
|
+
lang?: string;
|
|
34
36
|
};
|
|
35
37
|
}
|
|
36
38
|
//# sourceMappingURL=types.d.ts.map
|
package/config/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/config/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,sBAAsB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,mFAAmF;IACnF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC1B,GAAG,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC5B,kDAAkD;IAClD,qBAAqB,EAAE,kBAAkB,GAAG,qBAAqB,CAAC;IAElE,0CAA0C;IAC1C,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;IAE1C,gCAAgC;IAChC,OAAO,CAAC,EAAE,aAAa,CAAC;IAExB;;;;OAIG;IACH,UAAU,CAAC,EAAE;QACT,iDAAiD;QACjD,MAAM,EAAE,MAAM,CAAC;QACf,mDAAmD;QACnD,QAAQ,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/config/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,sBAAsB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,mFAAmF;IACnF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC1B,GAAG,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC5B,kDAAkD;IAClD,qBAAqB,EAAE,kBAAkB,GAAG,qBAAqB,CAAC;IAElE,0CAA0C;IAC1C,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;IAE1C,gCAAgC;IAChC,OAAO,CAAC,EAAE,aAAa,CAAC;IAExB;;;;OAIG;IACH,UAAU,CAAC,EAAE;QACT,iDAAiD;QACjD,MAAM,EAAE,MAAM,CAAC;QACf,mDAAmD;QACnD,QAAQ,EAAE,MAAM,CAAC;QACjB,+EAA+E;QAC/E,IAAI,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./matches-D5jlWsqr.cjs"),I=require("react");function fe(e){return{entityType:"tournament",id:e.id.toString(),name:e.name,slug:e.slug,gender:e.gender,type:e.type,region:e.region,country:{id:e.country.id.toString(),name:e.country.name,code:void 0,flag:e.country.url_flag??void 0,providerRef:u.toProviderRefArray(e.country.uuid)},assets:e.url_logo?{logo:e.url_logo}:void 0,providerRef:u.toProviderRefArray(e.uuid)}}function ge(e){return{entityType:"player",id:e.id.toString(),name:e.name,slug:e.slug,position:e.position,gender:e.gender,birthdate:e.birthdate,country:{id:e.country.id.toString(),name:e.country.name,code:void 0,flag:e.country.url_flag??void 0,providerRef:u.toProviderRefArray(e.country.uuid)},assets:e.url_thumb?{photo:e.url_thumb}:void 0,providerRef:u.toProviderRefArray(e.uuid)}}function pe(e){return{entityType:"team",id:e.id.toString(),name:e.name,slug:e.slug,shortName:e.short_name??void 0,threeLetterCode:e.three_letter_code??void 0,type:e.type==="national"?"national":"club",gender:e.gender,country:{id:e.country.id.toString(),name:e.country.name,code:void 0,flag:e.country.url_flag??void 0,providerRef:u.toProviderRefArray(e.country.uuid)},assets:e.url_logo?{logo:e.url_logo}:void 0,providerRef:u.toProviderRefArray(e.uuid)}}function ye(e){return{entityType:"president",id:e.id.toString(),name:e.name,slug:e.slug,birthdate:e.birthdate??void 0,country:{id:e.country.id.toString(),name:e.country.name,code:void 0,flag:e.country.url_flag??void 0,providerRef:u.toProviderRefArray(e.country.uuid)},assets:e.url_thumb?{photo:e.url_thumb}:void 0,providerRef:u.toProviderRefArray(e.uuid)}}function he(e){return{entityType:"venue",id:e.id.toString(),name:e.name,slug:e.slug,city:{id:e.city.id.toString(),name:e.city.name,country:{id:e.city.country.id.toString(),name:e.city.country.name,code:void 0,flag:e.city.country.url_flag??void 0,providerRef:u.toProviderRefArray(e.city.country.uuid)},providerRef:u.toProviderRefArray(e.city.uuid)},country:{id:e.country.id.toString(),name:e.country.name,code:void 0,flag:e.country.url_flag??void 0,providerRef:u.toProviderRefArray(e.country.uuid)},profile:{latitude:e.profile.lat,longitude:e.profile.lng,capacity:e.profile.capacity},assets:e.url_thumb?{image:e.url_thumb}:void 0,providerRef:u.toProviderRefArray(e.uuid)}}function Te(e){return{entityType:"coach",id:e.id.toString(),name:e.name,slug:e.slug,birthdate:e.birthdate??void 0,country:{id:e.country.id.toString(),name:e.country.name,code:void 0,flag:e.country.url_flag??void 0,providerRef:u.toProviderRefArray(e.country.uuid)},assets:e.url_thumb?{photo:e.url_thumb}:void 0,providerRef:u.toProviderRefArray(e.uuid)}}function _e(e){switch(e.entity_type){case"tournament":return fe(e);case"player":return ge(e);case"team":return pe(e);case"president":return ye(e);case"venue":return he(e);case"coach":return Te(e);default:throw new Error(`Unknown entity type: ${e.entity_type}`)}}async function ve(e,t){if(!e.query||e.query.trim()==="")return{results:[],query:e.query||""};const o=t||u.getConfig(),{sportal365Sports:n}=o,s=e.entityTypes&&e.entityTypes.length>0?e.entityTypes:["tournament","player","team","president","venue","coach"],i=await u.footballHttp.get({path:"/search",params:{query:e.query.trim(),entity_type:s.join(","),language_code:e.languageCode??n?.languageCode??"en"},headers:{"Accept-Language":e.languageCode??n?.languageCode??"en"},next:e.next,config:o});return!i||i.length===0?{results:[],query:e.query}:{results:i.map(_e),query:e.query}}const Ae=u.createHttpClient(u.SPORTAL365_BASKETBALL_DOMAIN);function Se(e){const t={FINISHED:"finished",NOT_STARTED:"not_started",LIVE:"live",INTERRUPTED:"interrupted",CANCELLED:"cancelled",POSTPONED:"postponed",UNKNOWN:"not_started"},o=e.type.toUpperCase();return{code:t[o]??"not_started",name:e.name,shortName:e.short_name,type:o}}function K(e){return{id:e.id,name:e.name,threeLetterCode:e.three_letter_code,slug:e.slug,type:e.type==="national"?"national":"club",gender:e.gender}}function Ce(e){return{kickoffTime:new Date(e.game_time),currentMinute:e.minute}}function Oe(e){if(!e.season?.competition)return;const t=e.season.competition;return{id:t.id,name:t.name,slug:t.slug,type:"LEAGUE",gender:t.gender,region:t.region,country:t.country?{id:t.country.id,name:t.country.name}:void 0,season:{id:e.season.id,name:e.season.name,status:e.season.status},stage:e.stage?{id:e.stage.id,name:e.stage.name,type:e.stage.type}:void 0}}function Fe(e){if(e)return{id:e.id,name:e.name,slug:e.slug}}function Le(e){if(!e||e.length===0)return;const t=e.filter(i=>i.result_type.category==="single_period");if(t.length===0)return;let o=0,n=0;const s=[];for(const i of t)o+=i.home,n+=i.away,s.push({competitorOne:String(i.home),competitorTwo:String(i.away)});return{competitorOne:String(o),competitorTwo:String(n),breakdown:{total:{competitorOne:String(o),competitorTwo:String(n)},periods:s}}}function Ee(e){if(e.winner)return{competitorId:e.winner.id}}function Pe(e){return{id:e.id,slug:e.slug,status:Se(e.status),timing:Ce(e),competitorOne:K(e.home_team),competitorTwo:K(e.away_team),competition:Oe(e),round:e.round?{id:e.round.id,key:e.round.uuid,name:e.round.name,type:"REGULAR",providerRef:u.toProviderRefArray(e.round.uuid)}:void 0,venue:Fe(e.arena),score:Le(e.score),winner:Ee(e),odds:e.odds?u.transformOdds(e.odds):void 0,coverage:e.coverage==="NOT_LIVE"?"UNKNOWN":e.coverage,providerRef:[{provider:"sportal365-basketball",id:e.id}]}}async function Ne(e,t){const o=t||u.getConfig(),{sportal365Sports:n}=o;return(await Ae.get({path:"/games",params:{offset:"0",limit:"1000",competition_list:e?.competitionList,status_type:e?.statusTypes,from_game_time:e?.fromGameTime,to_game_time:e?.toGameTime,odd_client:e?.oddClient??n?.oddClient,odd_type:e?.oddType,market_types:e?.marketTypes,language_code:e?.languageCode??n?.languageCode??"en"},headers:{"Accept-Language":e?.languageCode??n?.languageCode??"en"},next:e?.next,config:o})).games.map(Pe)}const Me=u.createHttpClient(u.SPORTAL365_TENNIS_DOMAIN);function Re(e){const t={FINISHED:"finished",NOT_STARTED:"not_started",LIVE:"live",INTERRUPTED:"interrupted",CANCELLED:"cancelled",POSTPONED:"postponed"},o=e.type.toUpperCase();return{code:t[o]??"not_started",name:e.name,shortName:e.short_name,type:o}}function z(e){if(e.type==="PLAYER")return{id:e.id,name:e.name,shortName:e.short_name,threeLetterCode:e.three_letter_code,type:"player",country:e.details?.[0]?.country?{id:e.details[0].country.id,name:e.details[0].country.name}:void 0,gender:e.details?.[0]?.gender};if(e.type==="TEAM_DOUBLE"&&e.details&&e.details.length===2){const t={id:e.details[0].id,name:e.details[0].name,shortName:e.details[0].short_name,threeLetterCode:e.details[0].three_letter_code,type:"player",country:e.details[0].country?{id:e.details[0].country.id,name:e.details[0].country.name}:void 0,gender:e.details[0].gender},o={id:e.details[1].id,name:e.details[1].name,shortName:e.details[1].short_name,threeLetterCode:e.details[1].three_letter_code,type:"player",country:e.details[1].country?{id:e.details[1].country.id,name:e.details[1].country.name}:void 0,gender:e.details[1].gender};return{id:e.id,name:e.name,shortName:e.short_name,threeLetterCode:e.three_letter_code,type:"pair",players:[t,o]}}else return{id:e.id,name:e.name,shortName:e.short_name,threeLetterCode:e.three_letter_code,type:"national",country:e.details?.[0]?.country?{id:e.details[0].country.id,name:e.details[0].country.name}:void 0,gender:e.details?.[0]?.gender}}function Ie(e){return{kickoffTime:new Date(e.scheduled_start_time),phaseStartedAt:e.started_at?new Date(e.started_at):void 0,finishedAt:e.finished_at?new Date(e.finished_at):void 0}}function Ge(e){if(!e.tournament)return;const t=e.tournament;return{id:t.competition?.id??t.id,name:t.competition?.name??t.name,slug:t.competition?.slug??t.slug,type:"TOURNAMENT",gender:t.gender,region:"INTERNATIONAL",country:t.country?{id:t.country.id,name:t.country.name}:void 0}}function be(e){if(!e.results||e.results.length===0)return;const t=e.results.filter(c=>/^set\d+$/i.test(c.type.code));if(t.length===0)return;const o=[];for(const c of t){const d=c.values.find(l=>l.position==="1"),m=c.values.find(l=>l.position==="2");!d||!m||d.value==null||m.value==null||o.push({competitorOne:d.value,competitorTwo:m.value})}if(o.length===0)return;const n=e.results.find(c=>c.type.code==="setswon"),s=n?.values.find(c=>c.position==="1"),i=n?.values.find(c=>c.position==="2");let a,r;return s?.value!=null&&i?.value!=null?(a=parseInt(s.value),r=parseInt(i.value)):(a=o.filter(c=>parseInt(c.competitorOne)>parseInt(c.competitorTwo)).length,r=o.filter(c=>parseInt(c.competitorTwo)>parseInt(c.competitorOne)).length),{competitorOne:String(a),competitorTwo:String(r),breakdown:{total:{competitorOne:String(a),competitorTwo:String(r)},periods:o}}}function De(e){const t=e.participants.find(o=>o.winner==="YES");if(t)return{competitorId:t.id}}function Ue(e){const t=e.participants.sort((o,n)=>o.position-n.position);return{id:e.id,slug:e.slug,status:Re(e.status),timing:Ie(e),competitorOne:z(t[0]),competitorTwo:z(t[1]),competition:Ge(e),round:e.round?{id:e.round.id,key:e.round.uuid,name:e.round.name,type:"REGULAR",providerRef:u.toProviderRefArray(e.round.uuid)}:void 0,score:be(e),winner:De(e),odds:e.odds?u.transformOdds(e.odds):void 0,coverage:e.coverage?.type==="NOT_LIVE"?"UNKNOWN":e.coverage?.type,metadata:{matchType:e.type,bestOfSets:e.best_of_sets,surface:e.tournament?.surface,indoorOutdoor:e.tournament?.indoor_outdoor},providerRef:[{provider:"sportal365-tennis",id:e.id}]}}async function He(e,t){const o=t||u.getConfig(),{sportal365Sports:n}=o;return(await Me.get({path:"/matches/livescore",params:{date:e?.date,utc_offset:e?.utcOffset?.toString(),offset:"0",limit:"1000",type:e?.type,gender:e?.gender,status_type:e?.statusType,competition_list:e?.competitionList,odd_client:e?.oddClient??n?.oddClient,odd_type:e?.oddType,market_types:e?.marketTypes,language_code:e?.languageCode??n?.languageCode??"en"},headers:{"Accept-Language":e?.languageCode??n?.languageCode??"en"},next:e?.next,config:o})).matches.map(Ue)}const ke=u.createHttpClient(u.SPORTAL365_SPORTS_SEARCH_DOMAIN);function F(e){return{language:e.language,name:e.name,shortName:e.short_name??void 0,threeLetterCode:e.three_letter_code??void 0}}function L(e){if(!(!e||!e.url))return{url:e.url}}function R(e){if(e)return{id:e.id,legacyId:e.legacy_id??void 0,name:e.name,shortName:e.short_name??void 0,threeLetterCode:e.three_letter_code??void 0,translations:e.translations.map(F),displayAsset:L(e.display_asset),slug:e.slug,providerRef:e.id}}function q(e){return{entityType:"team",id:e.id,legacyId:e.legacy_id??void 0,name:e.name,shortName:e.short_name??void 0,threeLetterCode:e.three_letter_code??void 0,translations:e.translations.map(F),displayAsset:L(e.display_asset),slug:e.slug,tagScore:e.tag_score??void 0,sport:e.sport,country:R(e.country),gender:e.gender,competitionIds:e.competition_ids,type:e.type,national:e.national,undecided:e.undecided,providerRef:e.id}}function Z(e){return{entityType:"city",id:e.id,legacyId:e.legacy_id??void 0,name:e.name,shortName:e.short_name??void 0,threeLetterCode:e.three_letter_code??void 0,translations:e.translations.map(F),displayAsset:L(e.display_asset),slug:e.slug,tagScore:e.tag_score??void 0,sport:e.sport,country:R(e.country),providerRef:e.id}}function Be(e){return{entityType:"horse",id:e.id,legacyId:e.legacy_id??void 0,name:e.name,shortName:e.short_name??void 0,threeLetterCode:e.three_letter_code??void 0,translations:e.translations.map(F),displayAsset:L(e.display_asset),slug:e.slug,tagScore:e.tag_score??void 0,sport:e.sport,country:R(e.country),gender:e.gender,providerRef:e.id}}function $e(e){return{entityType:"player",id:e.id,legacyId:e.legacy_id??void 0,name:e.name,shortName:e.short_name??void 0,threeLetterCode:e.three_letter_code??void 0,translations:e.translations.map(F),displayAsset:L(e.display_asset),slug:e.slug,tagScore:e.tag_score??void 0,sport:e.sport,country:R(e.country),gender:e.gender,birthdate:e.birthdate??void 0,position:e.position??void 0,providerRef:e.id}}function xe(e){return{entityType:"coach",id:e.id,legacyId:e.legacy_id??void 0,name:e.name,shortName:e.short_name??void 0,threeLetterCode:e.three_letter_code??void 0,translations:e.translations.map(F),displayAsset:L(e.display_asset),slug:e.slug,tagScore:e.tag_score??void 0,sport:e.sport,country:R(e.country),gender:e.gender,birthdate:e.birthdate??void 0,providerRef:e.id}}function We(e){return{entityType:"referee",id:e.id,legacyId:e.legacy_id??void 0,name:e.name,shortName:e.short_name??void 0,threeLetterCode:e.three_letter_code??void 0,translations:e.translations.map(F),displayAsset:L(e.display_asset),slug:e.slug,tagScore:e.tag_score??void 0,sport:e.sport,country:R(e.country),gender:e.gender,birthdate:e.birthdate??void 0,providerRef:e.id}}function Ye(e){return{entityType:"venue",id:e.id,legacyId:e.legacy_id??void 0,name:e.name,shortName:e.short_name??void 0,threeLetterCode:e.three_letter_code??void 0,translations:e.translations.map(F),displayAsset:L(e.display_asset),slug:e.slug,tagScore:e.tag_score??void 0,sport:e.sport,country:R(e.country),city:e.city?Z(e.city):void 0,providerRef:e.id}}function Qe(e){return{entityType:e.entity_type,id:e.id,legacyId:e.legacy_id??void 0,name:e.name,shortName:e.short_name??void 0,threeLetterCode:e.three_letter_code??void 0,translations:e.translations.map(F),displayAsset:L(e.display_asset),slug:e.slug,tagScore:e.tag_score??void 0,sport:e.sport,country:R(e.country),gender:e.gender,type:e.type??void 0,region:e.region??void 0,providerRef:e.id}}function qe(e){return{entityType:"match",id:e.id,legacyId:e.legacy_id??void 0,name:e.name,shortName:e.short_name??void 0,threeLetterCode:e.three_letter_code??void 0,translations:e.translations.map(F),displayAsset:L(e.display_asset),slug:e.slug,tagScore:e.tag_score??void 0,sport:e.sport,competitionId:e.competition_id??void 0,startTime:e.start_time??void 0,homeTeam:e.home_team?q(e.home_team):void 0,awayTeam:e.away_team?q(e.away_team):void 0,providerRef:e.id}}function Ve(e){return{entityType:"country",id:e.id,legacyId:e.legacy_id??void 0,name:e.name,shortName:e.short_name??void 0,threeLetterCode:e.three_letter_code??void 0,translations:e.translations.map(F),displayAsset:L(e.display_asset),slug:e.slug,tagScore:e.tag_score??void 0,sport:e.sport,providerRef:e.id}}function je(e){switch(e.entity_type){case"team":return q(e);case"city":return Z(e);case"horse":return Be(e);case"player":return $e(e);case"coach":return xe(e);case"referee":return We(e);case"venue":return Ye(e);case"tournament":case"competition":return Qe(e);case"match":return qe(e);case"country":return Ve(e);default:{const t=e;throw new Error(`Unknown entity type: ${t.entity_type}`)}}}async function Ke(e={},t){const o=t??u.getConfig(),n={};e.name&&(n.name=e.name),e.entityTypes&&e.entityTypes.length>0&&(n.entity_type=e.entityTypes.join(",")),e.sports&&e.sports.length>0&&(n.sport=e.sports.join(",")),e.eventStartTime&&(n.event_start_time=e.eventStartTime),e.ids&&e.ids.length>0&&(n.ids=e.ids.join(",")),e.competitionIds&&e.competitionIds.length>0&&(n.competition_ids=e.competitionIds.join(",")),e.domain&&(n.domain=e.domain),e.inputLanguage&&(n.input_language=e.inputLanguage),e.translationLanguage&&(n.translation_language=e.translationLanguage),e.limit!==void 0&&(n.limit=e.limit.toString()),e.offset!==void 0&&(n.offset=e.offset.toString());const s=await ke.get({path:"/suggest",params:n,next:e.next,config:o});return!s.results||s.results.length===0?{results:[],query:e.name}:{results:s.results.map(je),query:e.name}}const ze=u.createHttpClient(u.SPORTAL365_STANDINGS_DOMAIN);function Xe(e){const t={RANK:null,PLAYED:"played",WINS:"won",DRAWS:"drawn",LOSSES:"lost",GOALS_FOR:"goalsFor",GOALS_AGAINST:"goalsAgainst",POINTS:"points"};return e in t?t[e]:e.toLowerCase().replace(/_/g,"")}function w(e){return{CHAMPIONS_LEAGUE:"championsLeague",CHAMPIONS_LEAGUE_QUAL:"championsLeagueQual",CHAMPIONS_LEAGUE_8:"championsLeague8",CHAMPIONS_LEAGUE_PLAYOFF_16:"championsLeaguePlayoff16",PLAYOFF_TO_CHAMPIONS_LEAGUE:"playoffChampionsLeague",PLAYOFF_TO_CHAMPIONS_LEAGUE_QUAL:"playoffChampionsLeagueQual",UEFA_CUP:"europaLeague",UEFA_QUAL:"europaLeagueQual",UEFA_QUAL_PLAYOFF:"europaLeagueQualPlayoff",PLAYOFF_TO_UEFA_QUAL:"playoffEuropaLeagueQual",EUROPA_LEAGUE_8:"europaLeague8",EUROPA_LEAGUE_PLAYOFF_16:"europaLeaguePlayoff16",EUROPA_CONFERENCE_LEAGUE_PLAYOFF:"europaConferenceLeaguePlayoff",EUROPA_CONFERENCE_LEAGUE_QUALIFICATION:"europaConferenceLeagueQual",CONFERENCE_LEAGUE_8:"conferenceLeague8",CONFERENCE_LEAGUE_PLAYOFF_16:"conferenceLeaguePlayoff16",RELEGATION:"relegation",RELEGATION_PLAYOFF:"relegationPlayoff",PROMOTION:"promotion",PROMOTION_PLAYOFF:"promotionPlayoff",QUALIFICATION_TO_NEXT_STAGE:"qualificationNextStage",POSSIBLE_QUALIFICATION_TO_NEXT_STAGE:"possibleQualificationNextStage",CHAMPIONSHIP_PLAYOFF:"championshipPlayoff",OVERALL_CHAMPIONSHIP_PLAYOFF:"overallChampionshipPlayoff",CONFERENCE_CHAMPIONSHIP_PLAYOFF:"conferenceChampionshipPlayoff",POSSIBLE_CONFERENCE_CHAMPIONSHIP_PLAYOFF:"possibleConferenceChampionshipPlayoff",DIVISION_CHAMPIONSHIP_PLAYOFF:"divisionChampionshipPlayoff",COPA_LIBERTADORES:"copaLibertadores",PLAYOFF_TO_COPA_LIBERTADORES:"playoffCopaLibertadores",PLAYOFF_TO_COPA_LIBERTADORES_QUAL:"playoffCopaLibertadoresQual",PLAYOFF_TO_COPA_SUDAMERICANA:"playoffCopaSudamericana",PLAYOFF_TO_CONCACAF_CHAMPIONS_LEAGUE:"playoffConcacafChampionsLeague",CAF_CHAMPIONS_QUAL:"cafChampionsQual",CAF_CONFEGERATION_CUP_QUAL:"cafConfederationCupQual",CFU_CLUB_CHAMPIONSHIP:"cfuClubChampionship",AFC_CHAMPIONS_LEAGUE:"afcChampionsLeague",AFC_CHAMPIONS_LEAGUE_QUAL:"afcChampionsLeagueQual",PLAYOFF_TO_AFC_CHAMPIONS_LEAGUE_QUAL:"playoffAfcChampionsLeagueQual",WORLD_CUP:"worldCup"}[e]??e.toLowerCase().replace(/_/g,"")}function Je(e){return e==="RELEGATION"||e==="RELEGATION_PLAYOFF"?"BOTTOM":e.includes("PLAYOFF")?"MIDDLE":"TOP"}function Ze(e,t){if(!t||t.length===0)return;const o={win:"W",loss:"L",draw:"D"},n=t.map(s=>{const i=s.participants.find(f=>f.id===e),a=s.participants.find(f=>f.id!==e),r=i?.position==="1",c=s.result.find(f=>f.type==="display"),d=c?.results.find(f=>f.position==="1")?.value,m=c?.results.find(f=>f.position==="2")?.value,l=d&&m?`${d}-${m}`:void 0;return{matchId:s.id,result:o[s.outcome]??"L",score:l,homeAway:r?"HOME":"AWAY",opponent:{id:a?.id??"",name:a?.name??"",logo:a?.display_asset?.url},date:new Date(s.start_time),competition:s.competition?{id:s.competition.id,name:s.competition.name}:void 0}});return{competitorId:e,results:n,formString:n.map(s=>s.result).join("")}}function we(e){const t={};for(const o of e){const n=Xe(o.type.code);n&&(t[n]=Number(o.value))}return t.goalsFor!=null&&t.goalsAgainst!=null&&t.goalDifference==null&&(t.goalDifference=t.goalsFor-t.goalsAgainst),t}function et(e){const t=e.find(o=>o.type.code==="RANK");return t?Number(t.value):0}function tt(e){const t=e.rules?.length>0?e.rules.map(o=>w(o.standing_api_rule_type)):void 0;return{rank:et(e.columns),competitor:{id:e.team.id,name:e.team.name,shortName:e.team.short_name??void 0,logo:void 0},stats:we(e.columns),form:Ze(e.team.id,e.form??[]),rules:t}}function ot(e){const t=new Map;for(const o of e)if(o.rules)for(const n of o.rules){const s=w(n.standing_api_rule_type);t.has(s)||t.set(s,{key:s,name:n.name,position:Je(n.type)})}return Array.from(t.values())}function nt(e){const t=e.standing.map(tt),o=ot(e.standing);return{entries:t,metadata:{legend:o}}}function st(e){return e.standings.map(t=>({stage:{id:e.stage.id,name:e.stage.name},group:{id:t.group.id,name:t.group.name,type:t.group.type},coverageType:t.type,rankingType:t.ranking_type,standings:nt(t)}))}function it(e){return!e?.data||e.data.length===0?[]:e.data.flatMap(st)}async function at(e,t){const o=t||u.getConfig(),{sportal365Sports:n}=o,s={season_id:e.seasonId,stage_id:e.stageId,group_id:e.groupId,coverage_type:e.coverageType,home_away:e.homeAway,optional_data:e.includeForm?"form":void 0,row_limit:e.rowLimit?.toString(),row_offset:e.rowOffset?.toString(),translation_language:e.languageCode??n?.languageCode??"en"},i=await ze.get({path:`/standings/${e.sport}`,params:s,next:e.next,config:o});return it(i)}const rt=u.createHttpClient(u.SPORTAL365_STATISTICS_DOMAIN);function ct(e,t){return{teamId:e.id,teamName:e.name,seasonId:t,statistics:e.statistics.map(o=>({key:o.id,value:o.value,label:o.name}))}}async function lt(e,t){const o=t||u.getConfig(),n=e.next??{revalidate:600},s=await rt.get({path:"/statistics/aggregate",params:{participant_ids:e.teamId,season_ids:e.seasonId,participant_type:"TEAM"},next:n,config:o});if(!s.data||s.data.length===0)throw new Error(`No statistics found for team ${e.teamId} in season ${e.seasonId}`);return ct(s.data[0],e.seasonId)}function dt(e){const t=e.replace(/\/$/,"");function o(n){return`${t}${n}`}return{async get(n){const s=n.config||u.getConfig(),{fansUnited:i}=s;if(!i)throw new Error("Fans United configuration is missing. Add 'fansUnited' with 'apiKey' and 'clientId' to your config.");if(!i.apiKey||!i.clientId)throw new Error("Fans United configuration requires both 'apiKey' and 'clientId'");const a=new URL(o(n.path));if(a.searchParams.set("key",i.apiKey),a.searchParams.set("client_id",i.clientId),n.params)for(const[m,l]of Object.entries(n.params))l!==void 0&&(Array.isArray(l)?l.length>0&&a.searchParams.set(m,l.join(",")):a.searchParams.set(m,l));const r=3e4,c=new URL(a.toString());c.searchParams.delete("key"),c.searchParams.delete("client_id"),console.log("🔗 FansUnited API URL:",c.toString());const d=await fetch(a.toString(),{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json",...n.headers},signal:AbortSignal.timeout(r),...n.next&&{next:n.next}});if(!d.ok){let m=`Fans United API error: ${d.status} ${d.statusText}`;try{const l=await d.text();l&&(m+=` - ${l}`)}catch(l){console.error("[Fans United HTTP] Failed to read error response body:",{error:l instanceof Error?l.message:String(l),status:d.status,statusText:d.statusText})}throw new Error(m)}return d.json()}}}const ut="https://football.fansunitedapi.com",M=dt(ut);function mt(e){return{id:String(e.id),name:e.name,active:e.active,providerRef:[{provider:"fansunited",id:String(e.id)}]}}function ft(e){const t={id:String(e.id),name:e.name,shortName:e.short_name,slug:e.slug,type:e.type||"LEAGUE",region:e.region,gender:e.gender,providerRef:[{provider:"fansunited",id:String(e.id)}]};return e.country&&(t.country={id:String(e.country.id),name:e.country.name,code:e.country.code,flag:e.country.assets?.flag,providerRef:[{provider:"fansunited",id:String(e.country.id)}]}),e.assets?.logo&&(t.assets={logo:e.assets.logo}),e.seasons&&e.seasons.length>0&&(t.seasons=e.seasons.map(mt)),e.current_season&&(t.season={id:String(e.current_season.id),name:e.current_season.name,status:e.current_season.active?"ACTIVE":"INACTIVE"}),t}function gt(e){return e.map(ft)}async function pt(e,t){const o={};e?.lang?o.lang=e.lang:o.lang="EN",e?.sortField&&(o.sort_field=e.sortField),e?.sortOrder&&(o.sort_order=e.sortOrder),e?.page!==void 0&&(o.page=String(e.page)),e?.perPage!==void 0&&(o.per_page=String(e.perPage)),e?.countryId!==void 0&&(o.country_id=String(e.countryId)),e?.active!==void 0&&(o.active=e.active?"1":"0");const n=await M.get({path:"/v1/competitions",params:o,config:t,next:e?.next}),s=n.data.map(d=>d.id),i=new Set(s);s.length!==i.size&&console.warn("⚠️ API returned duplicate competitions!");const a=gt(n.data),r=new Set,c=a.filter(d=>r.has(d.id)?!1:(r.add(d.id),!0));return a.length!==c.length&&console.warn(`Removed ${a.length-c.length} duplicate competitions`),c}function yt(e){return{id:e.id,name:e.name,code:e.country_code,assets:e.assets?.flag?{flag:e.assets.flag}:void 0,providerRef:[{provider:"fansunited",id:e.id}]}}function ht(e){return{id:e.id,name:e.name,type:e.type?.toUpperCase()||"LEAGUE",gender:e.gender?.toUpperCase(),country:e.country?yt(e.country):void 0,assets:e.assets?.logo?{logo:e.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:e.id}]}}function Tt(e){return ht(e.data)}async function _t(e,t,o){const n=o||u.getConfig(),s={};t?.lang&&(s.lang=t.lang);const i=await M.get({path:`/v1/competitions/${e}`,params:s,next:t?.next,config:n});return Tt(i)}function vt(e){return{id:e.id,name:e.name,code:e.country_code,flag:e.assets?.flag,providerRef:[{provider:"fansunited",id:e.id}]}}function ee(e){return{id:e.id,name:e.name,shortName:e.short_name||void 0,threeLetterCode:e.code,type:e.national?"national":"club",gender:e.gender?e.gender.toUpperCase():void 0,country:e.country?vt(e.country):void 0,assets:e.assets?.logo?{logo:e.assets.logo}:void 0,metadata:e.colors?{shirtColors:e.colors.primary?[{type:"home",colorCode:e.colors.primary}]:void 0}:void 0,providerRef:[{provider:"fansunited",id:e.id}]}}function At(e){return ee(e.data)}function St(e){return e.data.map(ee)}async function Ct(e,t,o){const n=o||u.getConfig(),s={};t?.lang&&(s.lang=t.lang);const i=await M.get({path:`/v1/teams/${e}`,params:s,next:t?.next,config:n});return At(i)}async function Ot(e,t){const o=t||u.getConfig(),n={};e?.lang&&(n.lang=e.lang),e?.teamIds&&(n.team_ids=e.teamIds),e?.countryId&&(n.country_id=e.countryId),e?.name&&(n.name=e.name),e?.scope&&(n.scope=e.scope),e?.national!==void 0&&(n.national=String(e.national)),e?.gender&&(n.gender=e.gender),e?.limit!==void 0&&(n.limit=String(e.limit)),e?.page!==void 0&&(n.page=String(e.page)),e?.sortField&&(n.sort_field=e.sortField),e?.sortOrder&&(n.sort_order=e.sortOrder);const s=await M.get({path:"/v1/teams",params:n,next:e?.next,config:o});return St(s)}function V(e){return{id:e.id,name:e.name,code:e.country_code,flag:e.assets?.flag,providerRef:[{provider:"fansunited",id:e.id}]}}function Ft(e){return{id:e.id,name:e.name,shortName:e.short_name??void 0,fullName:e.full_name??void 0,threeLetterCode:e.code,type:e.national?"national":"club",gender:e.gender?.toUpperCase(),country:e.country?V(e.country):void 0,assets:e.assets?.logo?{logo:e.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:e.id}]}}function Lt(e){return{id:e.id,name:e.name,type:e.type?.toUpperCase()||"LEAGUE",gender:e.gender?.toUpperCase(),country:e.country?V(e.country):void 0,assets:e.assets?.logo?{logo:e.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:e.id}]}}function te(e){return{type:"player",id:e.id,name:e.name,position:e.position,birthdate:e.birth_date,country:e.country?V(e.country):void 0,assets:e.assets?.headshot?{photo:e.assets.headshot}:void 0,teams:e.teams?.map(Ft),competitions:e.competitions?.map(Lt),providerRef:[{provider:"fansunited",id:e.id}]}}function Et(e){return te(e.data)}function Pt(e){return e.data.map(te)}async function Nt(e,t,o){const n=o||u.getConfig(),s={};t?.lang&&(s.lang=t.lang);const i=await M.get({path:`/v1/players/${e}`,params:s,next:t?.next,config:n});return Et(i)}async function Mt(e,t){const o=t||u.getConfig(),n={};e?.lang&&(n.lang=e.lang),e?.playerIds&&(n.player_ids=e.playerIds),e?.countryId&&(n.country_id=e.countryId),e?.name&&(n.name=e.name),e?.scope&&(n.scope=e.scope),e?.limit!==void 0&&(n.limit=String(e.limit)),e?.page!==void 0&&(n.page=String(e.page)),e?.sortField&&(n.sort_field=e.sortField),e?.sortOrder&&(n.sort_order=e.sortOrder);const s=await M.get({path:"/v1/players",params:n,next:e?.next,config:o});return Pt(s)}async function Rt(e,t,o){const n=o||u.getConfig(),s={};t?.lang&&(s.lang=t.lang);const i=await M.get({path:`/v1/matches/${e}`,params:s,next:t?.next,config:n});return u.transformMatch(i)}async function It(e,t){const o=t||u.getConfig(),n={};e?.lang&&(n.lang=e.lang),e?.competitions&&(n.competitions=e.competitions),e?.countries&&(n.countries=e.countries),e?.fromDate&&(n.from_date=e.fromDate),e?.toDate&&(n.to_date=e.toDate),e?.matches&&(n.matches=e.matches),e?.teams&&(n.teams=e.teams),e?.status&&(n.status=e.status),e?.limit!==void 0&&(n.limit=String(e.limit)),e?.page!==void 0&&(n.page=String(e.page)),e?.sortField&&(n.sort_field=e.sortField),e?.sortOrder&&(n.sort_order=e.sortOrder),e?.showDeleted!==void 0&&(n.show_deleted=e.showDeleted?"true":"false");const s=await M.get({path:"/v1/matches",params:n,next:e?.next,config:o});return u.transformMatches(s)}function j(e){return{id:e.id,name:e.name,code:e.country_code,flag:e.assets?.flag||void 0,providerRef:[{provider:"fansunited",id:e.id}]}}function Gt(e){return{id:e.id,name:e.name,shortName:e.short_name||void 0,type:e.type||"LEAGUE",region:e.region,gender:e.gender?.toUpperCase(),country:e.country?j(e.country):void 0,assets:e.assets?.logo?{logo:e.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:e.id}]}}function bt(e){return{type:"player",id:e.id,name:e.name,position:e.position||void 0,gender:e.gender?.toUpperCase(),birthdate:e.birth_date||void 0,country:e.country?j(e.country):void 0,assets:e.assets?.headshot?{photo:e.assets.headshot}:void 0,providerRef:[{provider:"fansunited",id:e.id}]}}function Dt(e){return{type:e.national?"national":"club",id:e.id,name:e.name,shortName:e.short_name||void 0,threeLetterCode:e.code||void 0,gender:e.gender?.toUpperCase(),country:e.country?j(e.country):void 0,assets:e.assets?.logo?{logo:e.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:e.id}]}}function Q(e){switch(e.entity_type){case"competition":{const t=Gt(e);return{source:"FOOTBALL",entityType:"competition",entityId:e.id,entityData:t}}case"player":{const t=bt(e);return{source:"FOOTBALL",entityType:"player",entityId:e.id,entityData:t}}case"team":{const t=Dt(e);return{source:"FOOTBALL",entityType:"team",entityId:e.id,entityData:t}}case"venue":case"coach":return null;default:throw new Error(`Unknown entity type: ${e.entity_type}`)}}async function Ut(e,t){if(!e.query||e.query.trim()==="")return[];const o=t||u.getConfig(),n={q:e.query.trim()},i=(e.entityTypes&&e.entityTypes.length>0?e.entityTypes:["competition","team","player"]).map(c=>{switch(c){case"team":return"teams";case"player":return"players";case"competition":return"competitions";default:return c}});n.entities=i.join(","),e.lang&&(n.lang=e.lang),e.limit&&(n.limit=String(e.limit));const a=await M.get({path:"/v1/search",params:n,next:e.next,config:o}),r=[];return a.data&&(a.data.competitions&&a.data.competitions.forEach(c=>{const d=Q({...c,entity_type:"competition"});d&&r.push(d)}),a.data.teams&&a.data.teams.forEach(c=>{const d=Q({...c,entity_type:"team"});d&&r.push(d)}),a.data.players&&a.data.players.forEach(c=>{const d=Q({...c,entity_type:"player"});d&&r.push(d)})),r}function Ht(e){return!e.seasons||e.seasons.length===0?void 0:e.seasons.find(o=>o.active)??e.seasons[0]}function kt(e,t){const o=new Date,n=t.filter(s=>{const i=s.competitorOne.id===e||s.competitorTwo.id===e,a=s.status.type==="NOT_STARTED",r=new Date(s.timing.kickoffTime)>=o;return i&&a&&r});return n.sort((s,i)=>new Date(s.timing.kickoffTime).getTime()-new Date(i.timing.kickoffTime).getTime()),n[0]}function Bt(e,t){const o=new Date,n=t.filter(s=>{const i=s.competitorOne.id===e||s.competitorTwo.id===e,a=s.status.type==="FINISHED",r=new Date(s.timing.kickoffTime)<=o;return i&&a&&r});return n.sort((s,i)=>new Date(i.timing.kickoffTime).getTime()-new Date(s.timing.kickoffTime).getTime()),n[0]}function $t(e,t){const o=new Date;return t.filter(s=>{const i=s.competitorOne.id===e||s.competitorTwo.id===e,a=s.status.type==="NOT_STARTED"||s.status.type==="LIVE",r=new Date(s.timing.kickoffTime)>=o||s.status.type==="LIVE";return i&&a&&r}).sort((s,i)=>new Date(s.timing.kickoffTime).getTime()-new Date(i.timing.kickoffTime).getTime())}function xt(e,t){const o=new Date;return t.filter(s=>{const i=s.competitorOne.id===e||s.competitorTwo.id===e,a=s.status.type==="FINISHED",r=new Date(s.timing.kickoffTime)<=o;return i&&a&&r}).sort((s,i)=>new Date(i.timing.kickoffTime).getTime()-new Date(s.timing.kickoffTime).getTime())}function Wt(e,t,o){const n=o.filter(a=>a.status.type==="FINISHED"),s=o.filter(a=>a.status.type==="NOT_STARTED"||a.status.type==="POSTPONED"),i=t.entries.map(a=>{const r=a.competitor.id,c=n.filter(f=>f.competitorOne.id===e&&f.competitorTwo.id===r||f.competitorOne.id===r&&f.competitorTwo.id===e),d=s.filter(f=>f.competitorOne.id===e&&f.competitorTwo.id===r||f.competitorOne.id===r&&f.competitorTwo.id===e);let m,l;return c.forEach(f=>{const p=f.competitorOne.id===e,y=parseInt(f.score?.competitorOne??"0"),T=parseInt(f.score?.competitorTwo??"0"),E=p?y:T,S=p?T:y;let O;E>S?O="W":E===S?O="D":O="L";const P={result:O,score:`${y} - ${T}`,date:f.timing.kickoffTime,matchId:f.id,isUpcoming:!1};p?m=P:l=P}),d.forEach(f=>{const p=f.competitorOne.id===e;p&&!m?m={date:f.timing.kickoffTime,matchId:f.id,isUpcoming:!0}:!p&&!l&&(l={date:f.timing.kickoffTime,matchId:f.id,isUpcoming:!0})}),{rank:a.rank,teamId:a.competitor.id,teamName:a.competitor.name,teamShortName:a.competitor.shortName,teamLogo:a.competitor.logo,gamesPlayed:a.stats.played??0,points:a.stats.points??0,homeResult:m,awayResult:l}});return{teamId:e,rows:i}}function Yt(e,t=10){return e.players.filter(o=>(o.seasonStatistics?.goals??0)>0).sort((o,n)=>{const s=o.seasonStatistics?.goals??0,i=n.seasonStatistics?.goals??0;if(i!==s)return i-s;const a=o.seasonStatistics?.assists??0;return(n.seasonStatistics?.assists??0)-a}).slice(0,t)}function Qt(e,t=10){return e.players.filter(o=>(o.seasonStatistics?.assists??0)>0).sort((o,n)=>{const s=o.seasonStatistics?.assists??0,i=n.seasonStatistics?.assists??0;if(i!==s)return i-s;const a=o.seasonStatistics?.goals??0;return(n.seasonStatistics?.goals??0)-a}).slice(0,t)}function qt(e,t=10){return e.players.filter(o=>(o.seasonStatistics?.appearances??0)>0).sort((o,n)=>{const s=o.seasonStatistics?.appearances??0,i=n.seasonStatistics?.appearances??0;if(i!==s)return i-s;const a=o.seasonStatistics?.minutes??0;return(n.seasonStatistics?.minutes??0)-a}).slice(0,t)}function Vt(e,t=10){return e.players.filter(o=>(o.seasonStatistics?.minutes??0)>0).sort((o,n)=>{const s=o.seasonStatistics?.minutes??0,i=n.seasonStatistics?.minutes??0;if(i!==s)return i-s;const a=o.seasonStatistics?.appearances??0;return(n.seasonStatistics?.appearances??0)-a}).slice(0,t)}function jt(e,t=10){return e.players.filter(o=>(o.seasonStatistics?.cleansheets??0)>0).sort((o,n)=>{const s=o.seasonStatistics?.cleansheets??0,i=n.seasonStatistics?.cleansheets??0;if(i!==s)return i-s;const a=o.seasonStatistics?.appearances??0;return(n.seasonStatistics?.appearances??0)-a}).slice(0,t)}function Kt(e,t=10){return e.players.filter(o=>{const n=o.seasonStatistics?.yellowCards??0,s=o.seasonStatistics?.redCards??0;return n+s>0}).sort((o,n)=>{const s=o.seasonStatistics?.yellowCards??0,i=o.seasonStatistics?.redCards??0,a=n.seasonStatistics?.yellowCards??0,r=n.seasonStatistics?.redCards??0,c=s+i*3,d=a+r*3;return d!==c?d-c:r!==i?r-i:a-s}).slice(0,t)}function G(e){const t=new Map,o=new Map;return e.forEach(n=>{!n.mainEvents||n.mainEvents.length===0||n.mainEvents.forEach(s=>{if(s.primaryPlayer){const i=s.primaryPlayer.id;t.has(i)||t.set(i,{playerId:s.primaryPlayer.id,seasonId:"",teamId:"",goals:0,assists:0,yellowCards:0,redCards:0,appearances:0});const a=t.get(i);o.has(i)||o.set(i,new Set),o.get(i).add(n.id),(s.type==="GOAL"||s.type==="PENALTY_GOAL")&&(a.goals=(a.goals??0)+1),s.type==="YELLOW_CARD"&&(a.yellowCards=(a.yellowCards??0)+1),(s.type==="RED_CARD"||s.type==="YELLOW_RED_CARD")&&(a.redCards=(a.redCards??0)+1)}if(s.secondaryPlayer&&(s.type==="GOAL"||s.type==="PENALTY_GOAL")){const i=s.secondaryPlayer.id;t.has(i)||t.set(i,{playerId:s.secondaryPlayer.id,seasonId:"",teamId:"",goals:0,assists:0,yellowCards:0,redCards:0,appearances:0});const a=t.get(i);a.assists=(a.assists??0)+1,o.has(i)||o.set(i,new Set),o.get(i).add(n.id)}})}),o.forEach((n,s)=>{const i=t.get(s);i&&i.appearances!==void 0&&(i.appearances=n.size)}),t}function k(e){return Array.from(e.values()).map(t=>({...t,totalCards:(t.yellowCards??0)+(t.redCards??0)}))}function oe(e,t=10){const o=G(e);return k(o).filter(s=>(s.goals??0)>0).sort((s,i)=>{const a=s.goals??0,r=i.goals??0;if(r!==a)return r-a;const c=s.assists??0;return(i.assists??0)-c}).slice(0,t)}function ne(e,t=10){const o=G(e);return k(o).filter(s=>(s.assists??0)>0).sort((s,i)=>{const a=s.assists??0,r=i.assists??0;if(r!==a)return r-a;const c=s.goals??0;return(i.goals??0)-c}).slice(0,t)}function se(e,t=10){const o=G(e);return k(o).filter(s=>(s.totalCards??0)>0).sort((s,i)=>{const a=(s.yellowCards??0)+(s.redCards??0)*3,r=(i.yellowCards??0)+(i.redCards??0)*3;if(r!==a)return r-a;const c=s.redCards??0,d=i.redCards??0;if(d!==c)return d-c;const m=s.yellowCards??0;return(i.yellowCards??0)-m}).slice(0,t)}function ie(e,t=10){const o=G(e);return k(o).filter(s=>(s.goals??0)+(s.assists??0)>0).sort((s,i)=>{const a=(s.goals??0)+(s.assists??0),r=(i.goals??0)+(i.assists??0);if(r!==a)return r-a;const c=s.goals??0,d=i.goals??0;if(d!==c)return d-c;const m=s.assists??0;return(i.assists??0)-m}).slice(0,t)}function ae(e){const t=G(e);return k(t).sort((n,s)=>{const i=n.appearances??0,a=s.appearances??0;if(a!==i)return a-i;const r=(n.goals??0)+(n.assists??0);return(s.goals??0)+(s.assists??0)-r})}function zt(e,t=10){return I.useMemo(()=>oe(e,t),[e,t])}function Xt(e,t=10){return I.useMemo(()=>ne(e,t),[e,t])}function Jt(e,t=10){return I.useMemo(()=>se(e,t),[e,t])}function Zt(e,t=10){return I.useMemo(()=>ie(e,t),[e,t])}function wt(e){return I.useMemo(()=>ae(e),[e])}function re(e){return I.useMemo(()=>G(e),[e])}function eo(e,t){const o=re(e);return I.useMemo(()=>o.get(t),[o,t])}const ce=["GOAL","PENALTY_GOAL","OWN_GOAL"];function C(e,t){return t>0?e/t*100:0}function U(e,t){return t>0?e/t:0}function to(e,t=!1,o=2){return t?`${Math.round(e)}%`:Number.isInteger(e)?e.toString():e.toFixed(o)}function oo(e,t){const o=typeof e=="string"?parseFloat(e):e;if(isNaN(o)||t===0)return"0";const n=(o/t).toFixed(1);return`${o} (${n} avg)`}function no(e,t){const o=typeof e=="string"?parseFloat(e):e;return isNaN(o)||t===0?"0.0":(o/t).toFixed(1)}function so(e){const t=parseFloat(e);return isNaN(t)?"0%":`${Math.round(t)}%`}function le(e,t,o){if(e.status?.type!=="FINISHED"||!e.score)return null;const n=parseInt(e.score.competitorOne||"0"),s=parseInt(e.score.competitorTwo||"0"),i=o?n:s,a=o?s:n;let r=null,c=null;const d=e.score.breakdown?.halfTime;if(d){const p=parseInt(d.competitorOne||"0"),y=parseInt(d.competitorTwo||"0");r=o?p:y,c=o?y:p}const m=e.statistics;let l=null,f=null;if(m){const p=m.find?.(y=>y.type==="CORNERS");p&&(l=o?p.competitorOne:p.competitorTwo,f=o?p.competitorTwo:p.competitorOne)}return{goalsFor:i,goalsAgainst:a,halfTimeGoalsFor:r,halfTimeGoalsAgainst:c,cornersFor:l,cornersAgainst:f,isWin:i>a,isDraw:i===a,isLoss:i<a}}function Y(e,t){return e.competitorOne.id===t}function de(e,t){return e.competitorTwo.id===t}function io(e,t){return Y(e,t)||de(e,t)}function ao(e){return e.status?.type==="FINISHED"}function ro(e,t){const o=Y(e,t);return parseInt(o?e.score?.competitorOne||"0":e.score?.competitorTwo||"0")}function co(e,t){const o=Y(e,t);return parseInt(o?e.score?.competitorTwo||"0":e.score?.competitorOne||"0")}function lo(e,t,o){const n=e.filter(m=>{if(m.status?.type!=="FINISHED"||!m.score)return!1;const l=m.competitorOne.id===t||m.competitorTwo.id===t,f=m.competitorOne.id===o||m.competitorTwo.id===o;return l&&f});let s=0,i=0,a=0,r=0,c=0;n.forEach(m=>{const l=parseInt(m.score?.competitorOne||"0"),f=parseInt(m.score?.competitorTwo||"0"),p=m.competitorOne.id===t,y=p?l:f,T=p?f:l;r+=y,c+=T,y>T?s++:T>y?i++:a++});const d=n.length;return{totalMatches:d,homeTeamWins:s,awayTeamWins:i,draws:a,homeTeamGoals:r,awayTeamGoals:c,homeTeamWinPercentage:d>0?s/d*100:0,awayTeamWinPercentage:d>0?i/d*100:0,drawPercentage:d>0?a/d*100:0,homeTeamAvgGoals:d>0?r/d:0,awayTeamAvgGoals:d>0?c/d:0}}function uo(e,t,o,n=5){return e.filter(i=>{if(i.status?.type!=="FINISHED"||!i.score)return!1;const a=i.competitorOne.id===t||i.competitorTwo.id===t,r=i.competitorOne.id===o||i.competitorTwo.id===o;return a&&r}).sort((i,a)=>new Date(a.timing.kickoffTime).getTime()-new Date(i.timing.kickoffTime).getTime()).slice(0,n).map(i=>{const a=parseInt(i.score?.competitorOne||"0"),r=parseInt(i.score?.competitorTwo||"0"),c=i.competitorOne.id===t,d=c?a:r,m=c?r:a;let l;return d>m?l="home":m>d?l="away":l="draw",{id:i.id,date:new Date(i.timing.kickoffTime).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}),homeTeamName:i.competitorOne.name,awayTeamName:i.competitorTwo.name,homeTeamLogo:i.competitorOne.assets?.logo,awayTeamLogo:i.competitorTwo.assets?.logo,homeScore:a,awayScore:r,venue:i.venue?.name,winner:l}})}function mo(e,t,o){return e.filter(n=>{const s=n.competitorOne.id===t,i=n.competitorTwo.id===t;return!s&&!i?!1:o==="home"?s:i}).map(n=>{const s=n.competitorOne.id===t;return le(n,t,s)}).filter(n=>n!==null)}function X(e,t,o,n){let s=0;for(const i of e){const a=i.competitorOne.id===t,r=i.competitorTwo.id===t;if(!a&&!r||o==="home"&&!a||o==="away"&&!r||i.status?.type!=="FINISHED")continue;const c=i.mainEvents;if(!c||!Array.isArray(c))continue;const d=c.filter(y=>y.type&&ce.includes(y.type)).sort((y,T)=>{const E=y.minute??0,S=T.minute??0;return E!==S?E-S:(y.injuryMinute??0)-(T.injuryMinute??0)});if(d.length===0)continue;const m=d[0],l=a?"ONE":"TWO",f=m.type==="OWN_GOAL";let p;f?p=m.competitorPosition!==l:p=m.competitorPosition===l,(n==="scored"&&p||n==="conceded"&&!p)&&s++}return s}function fo(e,t,o){let n=0;for(const s of e){const i=s.competitorOne.id===t,a=s.competitorTwo.id===t;if(!i&&!a||o==="home"&&!i||o==="away"&&!a||s.status?.type!=="FINISHED")continue;const r=s.mainEvents;r&&Array.isArray(r)&&n++}return n}function go(e,t,o){const n=mo(e,t,o),s=n.length;if(s===0)return{played:0,goalsForPerMatch:0,cleanSheets:0,wonToNil:0,scoringRate:0,scoredInBothHalves:0,scoredFirst:0,leadingAtHalfTime:0,goalsAgainstPerMatch:0,failedToScore:0,lostToNil:0,concedingRate:0,concededInBothHalves:0,concededFirst:0,losingAtHalfTime:0,avgCornersFor:0,avgCornersAgainst:0};const i=n.reduce((g,v)=>g+v.goalsFor,0),a=n.reduce((g,v)=>g+v.goalsAgainst,0),r=n.filter(g=>g.goalsAgainst===0).length,c=n.filter(g=>g.isWin&&g.goalsAgainst===0).length,d=n.filter(g=>g.goalsFor>0).length,m=n.filter(g=>g.goalsFor===0).length,l=n.filter(g=>g.isLoss&&g.goalsFor===0).length,f=n.filter(g=>g.goalsAgainst>0).length,p=n.filter(g=>g.halfTimeGoalsFor!==null),y=p.length,T=p.filter(g=>{const v=g.halfTimeGoalsFor,D=g.goalsFor-v;return v>0&&D>0}).length,E=X(e,t,o,"scored"),S=fo(e,t,o),O=p.filter(g=>g.halfTimeGoalsFor>g.halfTimeGoalsAgainst).length,P=p.filter(g=>{const v=g.halfTimeGoalsAgainst,D=g.goalsAgainst-v;return v>0&&D>0}).length,B=X(e,t,o,"conceded"),$=p.filter(g=>g.halfTimeGoalsAgainst>g.halfTimeGoalsFor).length,b=n.filter(g=>g.cornersFor!==null),x=b.reduce((g,v)=>g+(v.cornersFor||0),0),W=b.reduce((g,v)=>g+(v.cornersAgainst||0),0);return{played:s,goalsForPerMatch:U(i,s),cleanSheets:C(r,s),wonToNil:C(c,s),scoringRate:C(d,s),scoredInBothHalves:C(T,y),scoredFirst:C(E,S),leadingAtHalfTime:C(O,y),goalsAgainstPerMatch:U(a,s),failedToScore:C(m,s),lostToNil:C(l,s),concedingRate:C(f,s),concededInBothHalves:C(P,y),concededFirst:C(B,S),losingAtHalfTime:C($,y),avgCornersFor:U(x,b.length),avgCornersAgainst:U(W,b.length)}}function po(e,t){return e.filter(o=>o.status?.type!=="FINISHED"?!1:o.competitorOne.id===t||o.competitorTwo.id===t).map(o=>{const n=o.competitorOne.id===t,s=parseInt(o.score?.competitorOne||"0"),i=parseInt(o.score?.competitorTwo||"0"),a=s+i,r=o.periods;let c=null;if(r&&Array.isArray(r)){const d=r.find(m=>m.type==="FIRST_HALF"||m.type==="1ST_HALF");if(d?.score){const m=parseInt(d.score.competitorOne||"0"),l=parseInt(d.score.competitorTwo||"0");c=m+l}}return{totalGoals:a,halfTimeGoals:c,isHome:n}})}function h(e,t){return e.length===0?0:e.filter(n=>n>t).length/e.length*100}function yo(e,t){const o=po(e,t),n=o.filter(l=>l.isHome),s=o.filter(l=>!l.isHome),i=o.map(l=>l.totalGoals),a=n.map(l=>l.totalGoals),r=s.map(l=>l.totalGoals),c=o.filter(l=>l.halfTimeGoals!==null).map(l=>l.halfTimeGoals),d=n.filter(l=>l.halfTimeGoals!==null).map(l=>l.halfTimeGoals),m=s.filter(l=>l.halfTimeGoals!==null).map(l=>l.halfTimeGoals);return{over05:{home:h(a,.5),total:h(i,.5),away:h(r,.5)},over15:{home:h(a,1.5),total:h(i,1.5),away:h(r,1.5)},over25:{home:h(a,2.5),total:h(i,2.5),away:h(r,2.5)},over35:{home:h(a,3.5),total:h(i,3.5),away:h(r,3.5)},over45:{home:h(a,4.5),total:h(i,4.5),away:h(r,4.5)},over55:{home:h(a,5.5),total:h(i,5.5),away:h(r,5.5)},over05HT:{home:h(d,.5),total:h(c,.5),away:h(m,.5)},over15HT:{home:h(d,1.5),total:h(c,1.5),away:h(m,1.5)},over25HT:{home:h(d,2.5),total:h(c,2.5),away:h(m,2.5)}}}function ue(e,t){const o=e.competitorOne.id===t,n=e.competitorTwo.id===t;if(!o&&!n||!e.score)return null;const s=parseInt(o?e.score.competitorOne||"0":e.score.competitorTwo||"0"),i=parseInt(o?e.score.competitorTwo||"0":e.score.competitorOne||"0");let a;return s>i?a="W":s<i?a="L":a="D",{result:{score:`${s}:${i}`,result:a,isHome:o},isHome:o}}function ho(e,t,o,n,s,i){const a=t?.entries.find(N=>N.competitor.id===e),r=o?.entries.find(N=>N.competitor.id===e),c=n?.entries.find(N=>N.competitor.id===e),d=s?.entries.find(N=>N.competitor.id===e),m=i?.entries.find(N=>N.competitor.id===e);if(!a)return null;const l=r?.stats?.goalsFor??0,f=c?.stats?.goalsFor??0,p=a?.stats?.goalsFor??0,y=d?.stats?.goalsAgainst??0,T=m?.stats?.goalsAgainst??0,E=a?.stats?.goalsAgainst??0,S=r?.stats?.played??0,O=c?.stats?.played??0,P=a?.stats?.played??0,B=P>0?p/P:0,$=P>0?E/P:0,b=B+$,x=S>0?l/S:0,W=O>0?f/O:0,g=S>0?y/S:0,v=O>0?T/O:0,D=x+g,me=W+v;return{homeGoals:l,totalGoals:p,awayGoals:f,homeGamesPlayed:S,awayGamesPlayed:O,totalGamesPlayed:P,homeGoalsConceded:y,totalGoalsConceded:E,awayGoalsConceded:T,gfPerMatch:B,gaPerMatch:$,gfGaPerMatch:b,homeGfPerMatch:x,awayGfPerMatch:W,homeGaPerMatch:g,awayGaPerMatch:v,homeGfGaPerMatch:D,awayGfGaPerMatch:me}}function A(e,t,o,n){const s=e.filter(a=>{const r=a.competitorOne.id===t,c=a.competitorTwo.id===t;return!(!r&&!c||a.status?.type!=="FINISHED"||n==="home"&&!r||n==="away"&&!c)}).sort((a,r)=>new Date(r.timing.kickoffTime).getTime()-new Date(a.timing.kickoffTime).getTime());if(s.length===0)return null;let i=0;for(const a of s){const r=a.competitorOne.id===t;if(o(a,t,r))i++;else break}return i>0?i:null}const _={win:(e,t,o)=>{const n=parseInt(o?e.score?.competitorOne||"0":e.score?.competitorTwo||"0"),s=parseInt(o?e.score?.competitorTwo||"0":e.score?.competitorOne||"0");return n>s},draw:e=>e.score?.competitorOne===e.score?.competitorTwo,loss:(e,t,o)=>{const n=parseInt(o?e.score?.competitorOne||"0":e.score?.competitorTwo||"0"),s=parseInt(o?e.score?.competitorTwo||"0":e.score?.competitorOne||"0");return n<s},noWin:(e,t,o)=>!_.win(e,t,o),noDraw:e=>!_.draw(e),noDefeat:(e,t,o)=>!_.loss(e,t,o),scored:(e,t,o)=>parseInt(o?e.score?.competitorOne||"0":e.score?.competitorTwo||"0")>=1,conceded:(e,t,o)=>parseInt(o?e.score?.competitorTwo||"0":e.score?.competitorOne||"0")>=1,noGoalScored:(e,t,o)=>!_.scored(e,t,o),noGoalConceded:(e,t,o)=>!_.conceded(e,t,o),over25:e=>parseInt(e.score?.competitorOne||"0")+parseInt(e.score?.competitorTwo||"0")>2,under25:e=>parseInt(e.score?.competitorOne||"0")+parseInt(e.score?.competitorTwo||"0")<3,scoredTwice:(e,t,o)=>parseInt(o?e.score?.competitorOne||"0":e.score?.competitorTwo||"0")>=2,concededTwice:(e,t,o)=>parseInt(o?e.score?.competitorTwo||"0":e.score?.competitorOne||"0")>=2};function H(e,t,o){return{win:A(e,t,_.win,o),draw:A(e,t,_.draw,o),loss:A(e,t,_.loss,o),noWin:A(e,t,_.noWin,o),noDraw:A(e,t,_.noDraw,o),noDefeat:A(e,t,_.noDefeat,o),scored:A(e,t,_.scored,o),conceded:A(e,t,_.conceded,o),noGoalScored:A(e,t,_.noGoalScored,o),noGoalConceded:A(e,t,_.noGoalConceded,o),over25:A(e,t,_.over25,o),under25:A(e,t,_.under25,o),scoredTwice:A(e,t,_.scoredTwice,o),concededTwice:A(e,t,_.concededTwice,o)}}function To(e,t,o){const n=H(e,t,"home"),s=H(e,t),i=H(e,o,"away"),a=H(e,o);return[{label:"Consecutive wins",homeTeam:{home:n.win,total:s.win},awayTeam:{total:a.win,home:i.win},colorType:"neutral"},{label:"Consecutive draws",homeTeam:{home:n.draw,total:s.draw},awayTeam:{total:a.draw,home:i.draw},colorType:"neutral"},{label:"Consecutive defeats",homeTeam:{home:n.loss,total:s.loss},awayTeam:{total:a.loss,home:i.loss},colorType:"neutral"},{label:"No win",homeTeam:{home:n.noWin,total:s.noWin},awayTeam:{total:a.noWin,home:i.noWin},colorType:"negative"},{label:"No draw",homeTeam:{home:n.noDraw,total:s.noDraw},awayTeam:{total:a.noDraw,home:i.noDraw},colorType:"neutral"},{label:"No defeat",homeTeam:{home:n.noDefeat,total:s.noDefeat},awayTeam:{total:a.noDefeat,home:i.noDefeat},colorType:"positive"},{label:"Scored at least once",homeTeam:{home:n.scored,total:s.scored},awayTeam:{total:a.scored,home:i.scored},colorType:"positive"},{label:"Conceded at least once",homeTeam:{home:n.conceded,total:s.conceded},awayTeam:{total:a.conceded,home:i.conceded},colorType:"negative"},{label:"No goal scored",homeTeam:{home:n.noGoalScored,total:s.noGoalScored},awayTeam:{total:a.noGoalScored,home:i.noGoalScored},colorType:"neutral"},{label:"No goal conceded",homeTeam:{home:n.noGoalConceded,total:s.noGoalConceded},awayTeam:{total:a.noGoalConceded,home:i.noGoalConceded},colorType:"neutral"},{label:"GS + GC over 2.5",homeTeam:{home:n.over25,total:s.over25},awayTeam:{total:a.over25,home:i.over25},colorType:"neutral"},{label:"GS + GC under 2.5",homeTeam:{home:n.under25,total:s.under25},awayTeam:{total:a.under25,home:i.under25},colorType:"neutral"},{label:"Scored at least twice",homeTeam:{home:n.scoredTwice,total:s.scoredTwice},awayTeam:{total:a.scoredTwice,home:i.scoredTwice},colorType:"positive"},{label:"Conceded at least twice",homeTeam:{home:n.concededTwice,total:s.concededTwice},awayTeam:{total:a.concededTwice,home:i.concededTwice},colorType:"negative"}]}function J(e,t){const o=new Map;return e.forEach(n=>{if(n.status?.type!=="FINISHED")return;const s=ue(n,t);if(!s)return;const i=s.isHome?n.competitorTwo.id:n.competitorOne.id,a=s.isHome?n.competitorTwo:n.competitorOne,r=o.get(i)||{opponentId:i,opponentName:a.name,opponentLogo:a.assets?.logo};s.isHome?r.homeResult=s.result:r.awayResult=s.result,o.set(i,r)}),o}function _o(e,t,o,n,s,i,a){const r=J(e,t),c=J(e,o),d=new Set([...r.keys(),...c.keys(),t,o]),m=[];return d.forEach(l=>{const f=r.get(l),p=c.get(l);if(!f&&!p&&l!==t&&l!==o)return;let y,T;l===t?(y=n,T=i):l===o?(y=s,T=a):(y=f?.opponentName||p?.opponentName||"",T=f?.opponentLogo||p?.opponentLogo),m.push({opponentId:l,opponentName:y,opponentLogo:T,homeTeamHome:f?.homeResult,homeTeamAway:f?.awayResult,awayTeamHome:p?.homeResult,awayTeamAway:p?.awayResult,isHomeTeamRow:l===t,isAwayTeamRow:l===o})}),m.sort((l,f)=>l.isHomeTeamRow?-1:f.isHomeTeamRow?1:l.isAwayTeamRow?-1:f.isAwayTeamRow?1:l.opponentName.localeCompare(f.opponentName))}exports.addProviderRef=u.addProviderRef;exports.getBatchMatchOdds=u.getBatchMatchOdds;exports.getConfig=u.getConfig;exports.getFootballCompetition=u.getFootballCompetition;exports.getFootballLivescore=u.getFootballLivescore;exports.getFootballMatch=u.getFootballMatch;exports.getFootballMatchCommentary=u.getFootballMatchCommentary;exports.getFootballMatchEvents=u.getFootballMatchEvents;exports.getFootballMatchLineups=u.getFootballMatchLineups;exports.getFootballMatchOdds=u.getFootballMatchOdds;exports.getFootballMatchStatistics=u.getFootballMatchStatistics;exports.getFootballMatches=u.getFootballMatches;exports.getFootballPlayerSeasonStatistics=u.getFootballPlayerSeasonStatistics;exports.getFootballSeasonDetails=u.getFootballSeasonDetails;exports.getFootballStandings=u.getFootballStandings;exports.getFootballTeam=u.getFootballTeam;exports.getFootballTeamSquad=u.getFootballTeamSquad;exports.getLeaderboardMatches=u.getLeaderboardMatches;exports.getLeaderboardTeamMatches=u.getLeaderboardTeamMatches;exports.getLeaderboardTemplate=u.getLeaderboardTemplate;exports.getProviderRefId=u.getProviderRefId;exports.isConfigured=u.isConfigured;exports.setConfig=u.setConfig;exports.toProviderRefArray=u.toProviderRefArray;exports.GOAL_EVENT_TYPES=ce;exports.aggregatePlayerStatisticsFromMatches=G;exports.analyzeMatch=le;exports.calcAverage=U;exports.calcPercentage=C;exports.calculateH2HStats=lo;exports.calculateStreak=A;exports.formatAsAverage=no;exports.formatPossessionPercentage=so;exports.formatStatValue=to;exports.formatWithAverage=oo;exports.getActiveSeason=Ht;exports.getAllPlayerStatisticsFromMatches=ae;exports.getBasketballLivescore=Ne;exports.getFansUnitedFootballCompetition=_t;exports.getFansUnitedFootballCompetitions=pt;exports.getFansUnitedFootballMatch=Rt;exports.getFansUnitedFootballMatches=It;exports.getFansUnitedFootballPlayer=Nt;exports.getFansUnitedFootballPlayers=Mt;exports.getFansUnitedFootballSearch=Ut;exports.getFansUnitedFootballTeam=Ct;exports.getFansUnitedFootballTeams=Ot;exports.getMatchResult=ue;exports.getMostCardedPlayersFromMatches=se;exports.getOpponentScore=co;exports.getRecentH2HMeetings=uo;exports.getSportal365Standings=at;exports.getTeamFinishedMatches=xt;exports.getTeamGoalStats=ho;exports.getTeamHomeAwayStats=go;exports.getTeamMostDecorated=Kt;exports.getTeamNextMatch=kt;exports.getTeamOverUnderStats=yo;exports.getTeamPreviousMatch=Bt;exports.getTeamResultsTable=Wt;exports.getTeamScore=ro;exports.getTeamSeasonStatistics=lt;exports.getTeamStreaks=H;exports.getTeamStreaksComparison=To;exports.getTeamTopAppearances=qt;exports.getTeamTopAssisters=Qt;exports.getTeamTopCleanSheets=jt;exports.getTeamTopMinutesPlayed=Vt;exports.getTeamTopScorers=Yt;exports.getTeamUpcomingMatches=$t;exports.getTeamsCommonOpponents=_o;exports.getTennisLivescore=He;exports.getTopAssistersFromMatches=ne;exports.getTopGoalContributorsFromMatches=ie;exports.getTopScorersFromMatches=oe;exports.isMatchFinished=ao;exports.isTeamAway=de;exports.isTeamHome=Y;exports.isTeamInMatch=io;exports.search=Ke;exports.searchFootball=ve;exports.streakFilters=_;exports.useAllPlayerStatisticsFromMatches=wt;exports.useMostCardedPlayersFromMatches=Jt;exports.usePlayerStatistics=eo;exports.usePlayerStatisticsMap=re;exports.useTopAssistersFromMatches=Xt;exports.useTopGoalContributorsFromMatches=Zt;exports.useTopScorersFromMatches=zt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./matches-CINPI4_G.cjs"),j=require("react");function ee(t){return{entityType:"tournament",id:t.id.toString(),name:t.name,slug:t.slug,gender:t.gender,type:t.type,region:t.region,country:{id:t.country.id.toString(),name:t.country.name,code:void 0,flag:t.country.url_flag??void 0,providerRef:h.toProviderRefArray(t.country.uuid)},assets:t.url_logo?{logo:t.url_logo}:void 0,providerRef:h.toProviderRefArray(t.uuid)}}function oe(t){return{entityType:"player",id:t.id.toString(),name:t.name,slug:t.slug,position:t.position,gender:t.gender,birthdate:t.birthdate,country:{id:t.country.id.toString(),name:t.country.name,code:void 0,flag:t.country.url_flag??void 0,providerRef:h.toProviderRefArray(t.country.uuid)},assets:t.url_thumb?{photo:t.url_thumb}:void 0,providerRef:h.toProviderRefArray(t.uuid)}}function ne(t){return{entityType:"team",id:t.id.toString(),name:t.name,slug:t.slug,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,type:t.type==="national"?"national":"club",gender:t.gender,country:{id:t.country.id.toString(),name:t.country.name,code:void 0,flag:t.country.url_flag??void 0,providerRef:h.toProviderRefArray(t.country.uuid)},assets:t.url_logo?{logo:t.url_logo}:void 0,providerRef:h.toProviderRefArray(t.uuid)}}function se(t){return{entityType:"president",id:t.id.toString(),name:t.name,slug:t.slug,birthdate:t.birthdate??void 0,country:{id:t.country.id.toString(),name:t.country.name,code:void 0,flag:t.country.url_flag??void 0,providerRef:h.toProviderRefArray(t.country.uuid)},assets:t.url_thumb?{photo:t.url_thumb}:void 0,providerRef:h.toProviderRefArray(t.uuid)}}function ie(t){return{entityType:"venue",id:t.id.toString(),name:t.name,slug:t.slug,city:{id:t.city.id.toString(),name:t.city.name,country:{id:t.city.country.id.toString(),name:t.city.country.name,code:void 0,flag:t.city.country.url_flag??void 0,providerRef:h.toProviderRefArray(t.city.country.uuid)},providerRef:h.toProviderRefArray(t.city.uuid)},country:{id:t.country.id.toString(),name:t.country.name,code:void 0,flag:t.country.url_flag??void 0,providerRef:h.toProviderRefArray(t.country.uuid)},profile:{latitude:t.profile.lat,longitude:t.profile.lng,capacity:t.profile.capacity},assets:t.url_thumb?{image:t.url_thumb}:void 0,providerRef:h.toProviderRefArray(t.uuid)}}function re(t){return{entityType:"coach",id:t.id.toString(),name:t.name,slug:t.slug,birthdate:t.birthdate??void 0,country:{id:t.country.id.toString(),name:t.country.name,code:void 0,flag:t.country.url_flag??void 0,providerRef:h.toProviderRefArray(t.country.uuid)},assets:t.url_thumb?{photo:t.url_thumb}:void 0,providerRef:h.toProviderRefArray(t.uuid)}}function ae(t){switch(t.entity_type){case"tournament":return ee(t);case"player":return oe(t);case"team":return ne(t);case"president":return se(t);case"venue":return ie(t);case"coach":return re(t);default:throw new Error(`Unknown entity type: ${t.entity_type}`)}}async function ce(t,e){if(!t.query||t.query.trim()==="")return{results:[],query:t.query||""};const o=e||h.getConfig(),{sportal365Sports:n}=o,s=t.entityTypes&&t.entityTypes.length>0?t.entityTypes:["tournament","player","team","president","venue","coach"],i=await h.footballHttp.get({path:"/search",params:{query:t.query.trim(),entity_type:s.join(","),language_code:t.languageCode??n?.languageCode??"en"},headers:{"Accept-Language":t.languageCode??n?.languageCode??"en"},next:t.next,config:o});return!i||i.length===0?{results:[],query:t.query}:{results:i.map(ae),query:t.query}}const le=h.createHttpClient(h.SPORTAL365_BASKETBALL_DOMAIN);function de(t){const e={FINISHED:"finished",NOT_STARTED:"not_started",LIVE:"live",INTERRUPTED:"interrupted",CANCELLED:"cancelled",POSTPONED:"postponed",UNKNOWN:"not_started"},o=t.type.toUpperCase();return{code:e[o]??"not_started",name:t.name,shortName:t.short_name,type:o}}function At(t){return{id:t.id,name:t.name,threeLetterCode:t.three_letter_code,slug:t.slug,type:t.type==="national"?"national":"club",gender:t.gender}}function ue(t){return{kickoffTime:new Date(t.game_time),currentMinute:t.minute}}function fe(t){if(!t.season?.competition)return;const e=t.season.competition;return{id:e.id,name:e.name,slug:e.slug,type:"LEAGUE",gender:e.gender,region:e.region,country:e.country?{id:e.country.id,name:e.country.name}:void 0,season:{id:t.season.id,name:t.season.name,status:t.season.status},stage:t.stage?{id:t.stage.id,name:t.stage.name,type:t.stage.type}:void 0}}function he(t){if(t)return{id:t.id,name:t.name,slug:t.slug}}function me(t){if(!t||t.length===0)return;const e=t.filter(i=>i.result_type.category==="single_period");if(e.length===0)return;let o=0,n=0;const s=[];for(const i of e)o+=i.home,n+=i.away,s.push({competitorOne:String(i.home),competitorTwo:String(i.away)});return{competitorOne:String(o),competitorTwo:String(n),breakdown:{total:{competitorOne:String(o),competitorTwo:String(n)},periods:s}}}function ge(t){if(t.winner)return{competitorId:t.winner.id}}function pe(t){return{id:t.id,slug:t.slug,sport:"basketball",status:de(t.status),timing:ue(t),competitorOne:At(t.home_team),competitorTwo:At(t.away_team),competition:fe(t),round:t.round?{id:t.round.id,key:t.round.uuid,name:t.round.name,type:"REGULAR",providerRef:h.toProviderRefArray(t.round.uuid)}:void 0,venue:he(t.arena),score:me(t.score),winner:ge(t),odds:t.odds?h.transformOdds(t.odds):void 0,coverage:t.coverage==="NOT_LIVE"?"UNKNOWN":t.coverage,providerRef:[{provider:"sportal365-basketball",id:t.id}]}}async function ye(t,e){const o=e||h.getConfig(),{sportal365Sports:n}=o;return(await le.get({path:"/games",params:{offset:"0",limit:"1000",competition_list:t?.competitionList,status_type:t?.statusTypes,from_game_time:t?.fromGameTime,to_game_time:t?.toGameTime,odd_client:t?.oddClient??n?.oddClient,odd_type:t?.oddType,market_types:t?.marketTypes,language_code:t?.languageCode??n?.languageCode??"en"},headers:{"Accept-Language":t?.languageCode??n?.languageCode??"en"},next:t?.next,config:o})).games.map(pe)}const Te=h.createHttpClient(h.SPORTAL365_TENNIS_DOMAIN);function _e(t){const e={FINISHED:"finished",NOT_STARTED:"not_started",LIVE:"live",INTERRUPTED:"interrupted",CANCELLED:"cancelled",POSTPONED:"postponed"},o=t.type.toUpperCase();return{code:e[o]??"not_started",name:t.name,shortName:t.short_name,type:o}}function Ct(t){if(t.type==="PLAYER")return{id:t.id,name:t.name,shortName:t.short_name,threeLetterCode:t.three_letter_code,type:"player",country:t.details?.[0]?.country?{id:t.details[0].country.id,name:t.details[0].country.name}:void 0,gender:t.details?.[0]?.gender};if(t.type==="TEAM_DOUBLE"&&t.details&&t.details.length===2){const e={id:t.details[0].id,name:t.details[0].name,shortName:t.details[0].short_name,threeLetterCode:t.details[0].three_letter_code,type:"player",country:t.details[0].country?{id:t.details[0].country.id,name:t.details[0].country.name}:void 0,gender:t.details[0].gender},o={id:t.details[1].id,name:t.details[1].name,shortName:t.details[1].short_name,threeLetterCode:t.details[1].three_letter_code,type:"player",country:t.details[1].country?{id:t.details[1].country.id,name:t.details[1].country.name}:void 0,gender:t.details[1].gender};return{id:t.id,name:t.name,shortName:t.short_name,threeLetterCode:t.three_letter_code,type:"pair",players:[e,o]}}else return{id:t.id,name:t.name,shortName:t.short_name,threeLetterCode:t.three_letter_code,type:"national",country:t.details?.[0]?.country?{id:t.details[0].country.id,name:t.details[0].country.name}:void 0,gender:t.details?.[0]?.gender}}function ve(t){return{kickoffTime:new Date(t.scheduled_start_time),phaseStartedAt:t.started_at?new Date(t.started_at):void 0,finishedAt:t.finished_at?new Date(t.finished_at):void 0}}function Se(t){if(!t.tournament)return;const e=t.tournament;return{id:e.competition?.id??e.id,name:e.competition?.name??e.name,slug:e.competition?.slug??e.slug,type:"TOURNAMENT",gender:e.gender,region:"INTERNATIONAL",country:e.country?{id:e.country.id,name:e.country.name}:void 0}}function Ae(t){if(!t.results||t.results.length===0)return;const e=t.results.filter(c=>/^set\d+$/i.test(c.type.code));if(e.length===0)return;const o=[];for(const c of e){const d=c.values.find(l=>l.position==="1"),f=c.values.find(l=>l.position==="2");!d||!f||d.value==null||f.value==null||o.push({competitorOne:d.value,competitorTwo:f.value})}if(o.length===0)return;const n=t.results.find(c=>c.type.code==="setswon"),s=n?.values.find(c=>c.position==="1"),i=n?.values.find(c=>c.position==="2");let r,a;return s?.value!=null&&i?.value!=null?(r=parseInt(s.value),a=parseInt(i.value)):(r=o.filter(c=>parseInt(c.competitorOne)>parseInt(c.competitorTwo)).length,a=o.filter(c=>parseInt(c.competitorTwo)>parseInt(c.competitorOne)).length),{competitorOne:String(r),competitorTwo:String(a),breakdown:{total:{competitorOne:String(r),competitorTwo:String(a)},periods:o}}}function Ce(t){const e=t.participants.find(o=>o.winner==="YES");if(e)return{competitorId:e.id}}function Oe(t){const e=t.participants.sort((o,n)=>o.position-n.position);return{id:t.id,slug:t.slug,sport:"tennis",status:_e(t.status),timing:ve(t),competitorOne:Ct(e[0]),competitorTwo:Ct(e[1]),competition:Se(t),round:t.round?{id:t.round.id,key:t.round.uuid,name:t.round.name,type:"REGULAR",providerRef:h.toProviderRefArray(t.round.uuid)}:void 0,score:Ae(t),winner:Ce(t),odds:t.odds?h.transformOdds(t.odds):void 0,coverage:t.coverage?.type==="NOT_LIVE"?"UNKNOWN":t.coverage?.type,metadata:{matchType:t.type,bestOfSets:t.best_of_sets,surface:t.tournament?.surface,indoorOutdoor:t.tournament?.indoor_outdoor},providerRef:[{provider:"sportal365-tennis",id:t.id}]}}async function Fe(t,e){const o=e||h.getConfig(),{sportal365Sports:n}=o;return(await Te.get({path:"/matches/livescore",params:{date:t?.date,utc_offset:t?.utcOffset?.toString(),offset:"0",limit:"1000",type:t?.type,gender:t?.gender,status_type:t?.statusType,competition_list:t?.competitionList,odd_client:t?.oddClient??n?.oddClient,odd_type:t?.oddType,market_types:t?.marketTypes,language_code:t?.languageCode??n?.languageCode??"en"},headers:{"Accept-Language":t?.languageCode??n?.languageCode??"en"},next:t?.next,config:o})).matches.map(Oe)}const Ee=h.createHttpClient(h.SPORTAL365_SPORTS_SEARCH_DOMAIN);function G(t){return{language:t.language,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0}}function D(t){if(!(!t||!t.url))return{url:t.url}}function W(t){if(t)return{id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,providerRef:t.id}}function pt(t){return{entityType:"team",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),gender:t.gender,competitionIds:t.competition_ids,type:t.type,national:t.national,undecided:t.undecided,providerRef:t.id}}function Rt(t){return{entityType:"city",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),providerRef:t.id}}function Le(t){return{entityType:"horse",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),gender:t.gender,providerRef:t.id}}function be(t){return{entityType:"player",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),gender:t.gender,birthdate:t.birthdate??void 0,position:t.position??void 0,providerRef:t.id}}function Re(t){return{entityType:"coach",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),gender:t.gender,birthdate:t.birthdate??void 0,providerRef:t.id}}function Ne(t){return{entityType:"referee",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),gender:t.gender,birthdate:t.birthdate??void 0,providerRef:t.id}}function Pe(t){return{entityType:"venue",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),city:t.city?Rt(t.city):void 0,providerRef:t.id}}function Me(t){return{entityType:t.entity_type,id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,country:W(t.country),gender:t.gender,type:t.type??void 0,region:t.region??void 0,providerRef:t.id}}function Ie(t){return{entityType:"match",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,competitionId:t.competition_id??void 0,startTime:t.start_time??void 0,homeTeam:t.home_team?pt(t.home_team):void 0,awayTeam:t.away_team?pt(t.away_team):void 0,providerRef:t.id}}function Ue(t){return{entityType:"country",id:t.id,legacyId:t.legacy_id??void 0,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code??void 0,translations:t.translations.map(G),displayAsset:D(t.display_asset),slug:t.slug,tagScore:t.tag_score??void 0,sport:t.sport,providerRef:t.id}}function Ge(t){switch(t.entity_type){case"team":return pt(t);case"city":return Rt(t);case"horse":return Le(t);case"player":return be(t);case"coach":return Re(t);case"referee":return Ne(t);case"venue":return Pe(t);case"tournament":case"competition":return Me(t);case"match":return Ie(t);case"country":return Ue(t);default:{const e=t;throw new Error(`Unknown entity type: ${e.entity_type}`)}}}async function De(t={},e){const o=e??h.getConfig(),n={};t.name&&(n.name=t.name),t.entityTypes&&t.entityTypes.length>0&&(n.entity_type=t.entityTypes.join(",")),t.sports&&t.sports.length>0&&(n.sport=t.sports.join(",")),t.eventStartTime&&(n.event_start_time=t.eventStartTime),t.ids&&t.ids.length>0&&(n.ids=t.ids.join(",")),t.competitionIds&&t.competitionIds.length>0&&(n.competition_ids=t.competitionIds.join(",")),t.domain&&(n.domain=t.domain),t.inputLanguage&&(n.input_language=t.inputLanguage),t.translationLanguage&&(n.translation_language=t.translationLanguage),t.limit!==void 0&&(n.limit=t.limit.toString()),t.offset!==void 0&&(n.offset=t.offset.toString());const s=await Ee.get({path:"/suggest",params:n,next:t.next,config:o});return!s.results||s.results.length===0?{results:[],query:t.name}:{results:s.results.map(Ge),query:t.name}}const xe=h.createHttpClient(h.SPORTAL365_STANDINGS_DOMAIN);function He(t){const e={RANK:null,PLAYED:"played",WINS:"won",DRAWS:"drawn",LOSSES:"lost",GOALS_FOR:"goalsFor",GOALS_AGAINST:"goalsAgainst",POINTS:"points"};return t in e?e[t]:t.toLowerCase().replace(/_/g,"")}function Nt(t){return{CHAMPIONS_LEAGUE:"championsLeague",CHAMPIONS_LEAGUE_QUAL:"championsLeagueQual",CHAMPIONS_LEAGUE_8:"championsLeague8",CHAMPIONS_LEAGUE_PLAYOFF_16:"championsLeaguePlayoff16",PLAYOFF_TO_CHAMPIONS_LEAGUE:"playoffChampionsLeague",PLAYOFF_TO_CHAMPIONS_LEAGUE_QUAL:"playoffChampionsLeagueQual",UEFA_CUP:"europaLeague",UEFA_QUAL:"europaLeagueQual",UEFA_QUAL_PLAYOFF:"europaLeagueQualPlayoff",PLAYOFF_TO_UEFA_QUAL:"playoffEuropaLeagueQual",EUROPA_LEAGUE_8:"europaLeague8",EUROPA_LEAGUE_PLAYOFF_16:"europaLeaguePlayoff16",EUROPA_CONFERENCE_LEAGUE_PLAYOFF:"europaConferenceLeaguePlayoff",EUROPA_CONFERENCE_LEAGUE_QUALIFICATION:"europaConferenceLeagueQual",CONFERENCE_LEAGUE_8:"conferenceLeague8",CONFERENCE_LEAGUE_PLAYOFF_16:"conferenceLeaguePlayoff16",RELEGATION:"relegation",RELEGATION_PLAYOFF:"relegationPlayoff",PROMOTION:"promotion",PROMOTION_PLAYOFF:"promotionPlayoff",QUALIFICATION_TO_NEXT_STAGE:"qualificationNextStage",POSSIBLE_QUALIFICATION_TO_NEXT_STAGE:"possibleQualificationNextStage",CHAMPIONSHIP_PLAYOFF:"championshipPlayoff",OVERALL_CHAMPIONSHIP_PLAYOFF:"overallChampionshipPlayoff",CONFERENCE_CHAMPIONSHIP_PLAYOFF:"conferenceChampionshipPlayoff",POSSIBLE_CONFERENCE_CHAMPIONSHIP_PLAYOFF:"possibleConferenceChampionshipPlayoff",DIVISION_CHAMPIONSHIP_PLAYOFF:"divisionChampionshipPlayoff",COPA_LIBERTADORES:"copaLibertadores",PLAYOFF_TO_COPA_LIBERTADORES:"playoffCopaLibertadores",PLAYOFF_TO_COPA_LIBERTADORES_QUAL:"playoffCopaLibertadoresQual",PLAYOFF_TO_COPA_SUDAMERICANA:"playoffCopaSudamericana",PLAYOFF_TO_CONCACAF_CHAMPIONS_LEAGUE:"playoffConcacafChampionsLeague",CAF_CHAMPIONS_QUAL:"cafChampionsQual",CAF_CONFEGERATION_CUP_QUAL:"cafConfederationCupQual",CFU_CLUB_CHAMPIONSHIP:"cfuClubChampionship",AFC_CHAMPIONS_LEAGUE:"afcChampionsLeague",AFC_CHAMPIONS_LEAGUE_QUAL:"afcChampionsLeagueQual",PLAYOFF_TO_AFC_CHAMPIONS_LEAGUE_QUAL:"playoffAfcChampionsLeagueQual",WORLD_CUP:"worldCup"}[t]??t.toLowerCase().replace(/_/g,"")}function ke(t){return t==="RELEGATION"||t==="RELEGATION_PLAYOFF"?"BOTTOM":t.includes("PLAYOFF")?"MIDDLE":"TOP"}function $e(t,e){if(!e||e.length===0)return;const o={win:"W",loss:"L",draw:"D"},n=e.map(s=>{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;return{matchId:s.id,result:o[s.outcome]??"L",score:l,homeAway:a?"HOME":"AWAY",opponent:{id:r?.id??"",name:r?.name??"",logo:r?.display_asset?.url},date:new Date(s.start_time),competition:s.competition?{id:s.competition.id,name:s.competition.name}:void 0}});return{competitorId:t,results:n,formString:n.map(s=>s.result).join("")}}function Be(t){const e={};for(const o of t){const n=He(o.type.code);n&&(e[n]=Number(o.value))}return e.goalsFor!=null&&e.goalsAgainst!=null&&e.goalDifference==null&&(e.goalDifference=e.goalsFor-e.goalsAgainst),e}function We(t){const e=t.find(o=>o.type.code==="RANK");return e?Number(e.value):0}function ze(t){const e=t.rules?.length>0?t.rules.map(o=>Nt(o.standing_api_rule_type)):void 0;return{rank:We(t.columns),competitor:{id:t.team.id,name:t.team.name,shortName:t.team.short_name??void 0,logo:void 0},stats:Be(t.columns),form:$e(t.team.id,t.form??[]),rules:e}}function Ye(t){const e=new Map;for(const o of t)if(o.rules)for(const n of o.rules){const s=Nt(n.standing_api_rule_type);e.has(s)||e.set(s,{key:s,name:n.name,position:ke(n.type)})}return Array.from(e.values())}function je(t){const e=t.standing.map(ze),o=Ye(t.standing);return{entries:e,metadata:{legend:o}}}function qe(t){return t.standings.map(e=>({stage:{id:t.stage.id,name:t.stage.name},group:{id:e.group.id,name:e.group.name,type:e.group.type},coverageType:e.type,rankingType:e.ranking_type,standings:je(e)}))}function Ve(t){return!t?.data||t.data.length===0?[]:t.data.flatMap(qe)}async function Qe(t,e){const o=e||h.getConfig(),{sportal365Sports:n}=o,s={season_id:t.seasonId,stage_id:t.stageId,group_id:t.groupId,coverage_type:t.coverageType,home_away:t.homeAway,optional_data:t.includeForm?"form":void 0,row_limit:t.rowLimit?.toString(),row_offset:t.rowOffset?.toString(),translation_language:t.languageCode??n?.languageCode??"en"},i=await xe.get({path:`/standings/${t.sport}`,params:s,next:t.next,config:o});return Ve(i)}const Ke=h.createHttpClient(h.SPORTAL365_STATISTICS_DOMAIN);function Xe(t,e){return{teamId:t.id,teamName:t.name,seasonId:e,statistics:t.statistics.map(o=>({key:o.id,value:o.value,label:o.name}))}}async function Je(t,e){const o=e||h.getConfig(),n=t.next??{revalidate:600},s=await Ke.get({path:"/statistics/aggregate",params:{participant_ids:t.teamId,season_ids:t.seasonId,participant_type:"TEAM"},next:n,config:o});if(!s.data||s.data.length===0)throw new Error(`No statistics found for team ${t.teamId} in season ${t.seasonId}`);return Xe(s.data[0],t.seasonId)}function Pt(t){const e=t.replace(/\/$/,"");function o(n){return`${e}${n}`}return{async get(n){const s=n.config||h.getConfig(),{fansUnited:i}=s;if(!i)throw new Error("Fans United configuration is missing. Add 'fansUnited' with 'apiKey' and 'clientId' to your config.");if(!i.apiKey||!i.clientId)throw new Error("Fans United configuration requires both 'apiKey' and 'clientId'");const r=new URL(o(n.path));if(r.searchParams.set("key",i.apiKey),r.searchParams.set("client_id",i.clientId),n.params)for(const[f,l]of Object.entries(n.params))l!==void 0&&(Array.isArray(l)?l.length>0&&r.searchParams.set(f,l.join(",")):r.searchParams.set(f,l));const a=3e4,c=new URL(r.toString());c.searchParams.delete("key"),c.searchParams.delete("client_id"),console.log("🔗 FansUnited API URL:",c.toString());const d=await fetch(r.toString(),{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json",...n.headers},signal:AbortSignal.timeout(a),...n.next&&{next:n.next}});if(!d.ok){let f=`Fans United API error: ${d.status} ${d.statusText}`;try{const l=await d.text();l&&(f+=` - ${l}`)}catch(l){console.error("[Fans United HTTP] Failed to read error response body:",{error:l instanceof Error?l.message:String(l),status:d.status,statusText:d.statusText})}throw new Error(f)}return d.json()}}}const Ze="https://football.fansunitedapi.com",N=Pt(Ze);function we(t){return{id:String(t.id),name:t.name,active:t.active,providerRef:[{provider:"fansunited",id:String(t.id)}]}}function to(t){const e={id:String(t.id),name:t.name,shortName:t.short_name,slug:t.slug,type:t.type||"LEAGUE",region:t.region,gender:t.gender,providerRef:[{provider:"fansunited",id:String(t.id)}]};return t.country&&(e.country={id:String(t.country.id),name:t.country.name,code:t.country.code,flag:t.country.assets?.flag,providerRef:[{provider:"fansunited",id:String(t.country.id)}]}),t.assets?.logo&&(e.assets={logo:t.assets.logo}),t.seasons&&t.seasons.length>0&&(e.seasons=t.seasons.map(we)),t.current_season&&(e.season={id:String(t.current_season.id),name:t.current_season.name,status:t.current_season.active?"ACTIVE":"INACTIVE"}),e}function eo(t){return t.map(to)}async function oo(t,e){const o={};t?.lang?o.lang=t.lang:o.lang="EN",t?.sortField&&(o.sort_field=t.sortField),t?.sortOrder&&(o.sort_order=t.sortOrder),t?.page!==void 0&&(o.page=String(t.page)),t?.perPage!==void 0&&(o.per_page=String(t.perPage)),t?.countryId!==void 0&&(o.country_id=String(t.countryId)),t?.active!==void 0&&(o.active=t.active?"1":"0");const n=await N.get({path:"/v1/competitions",params:o,config:e,next:t?.next}),s=n.data.map(d=>d.id),i=new Set(s);s.length!==i.size&&console.warn("⚠️ API returned duplicate competitions!");const r=eo(n.data),a=new Set,c=r.filter(d=>a.has(d.id)?!1:(a.add(d.id),!0));return r.length!==c.length&&console.warn(`Removed ${r.length-c.length} duplicate competitions`),c}function no(t){return{id:t.id,name:t.name,code:t.country_code,assets:t.assets?.flag?{flag:t.assets.flag}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function so(t){return{id:t.id,name:t.name,type:t.type?.toUpperCase()||"LEAGUE",gender:t.gender?.toUpperCase(),country:t.country?no(t.country):void 0,assets:t.assets?.logo?{logo:t.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function io(t){return so(t.data)}async function ro(t,e,o){const n=o||h.getConfig(),s={};e?.lang&&(s.lang=e.lang);const i=await N.get({path:`/v1/competitions/${t}`,params:s,next:e?.next,config:n});return io(i)}function ao(t){return{id:t.id,name:t.name,code:t.country_code,flag:t.assets?.flag,providerRef:[{provider:"fansunited",id:t.id}]}}function Mt(t){return{id:t.id,name:t.name,shortName:t.short_name||void 0,threeLetterCode:t.code,type:t.national?"national":"club",gender:t.gender?t.gender.toUpperCase():void 0,country:t.country?ao(t.country):void 0,assets:t.assets?.logo?{logo:t.assets.logo}:void 0,metadata:t.colors?{shirtColors:t.colors.primary?[{type:"home",colorCode:t.colors.primary}]:void 0}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function co(t){return Mt(t.data)}function lo(t){return t.data.map(Mt)}async function uo(t,e,o){const n=o||h.getConfig(),s={};e?.lang&&(s.lang=e.lang);const i=await N.get({path:`/v1/teams/${t}`,params:s,next:e?.next,config:n});return co(i)}async function fo(t,e){const o=e||h.getConfig(),n={};t?.lang&&(n.lang=t.lang),t?.teamIds&&(n.team_ids=t.teamIds),t?.countryId&&(n.country_id=t.countryId),t?.name&&(n.name=t.name),t?.scope&&(n.scope=t.scope),t?.national!==void 0&&(n.national=String(t.national)),t?.gender&&(n.gender=t.gender),t?.limit!==void 0&&(n.limit=String(t.limit)),t?.page!==void 0&&(n.page=String(t.page)),t?.sortField&&(n.sort_field=t.sortField),t?.sortOrder&&(n.sort_order=t.sortOrder);const s=await N.get({path:"/v1/teams",params:n,next:t?.next,config:o});return lo(s)}function _t(t){return{id:t.id,name:t.name,code:t.country_code,flag:t.assets?.flag,providerRef:[{provider:"fansunited",id:t.id}]}}function ho(t){return{id:t.id,name:t.name,shortName:t.short_name??void 0,fullName:t.full_name??void 0,threeLetterCode:t.code,type:t.national?"national":"club",gender:t.gender?.toUpperCase(),country:t.country?_t(t.country):void 0,assets:t.assets?.logo?{logo:t.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function mo(t){return{id:t.id,name:t.name,type:t.type?.toUpperCase()||"LEAGUE",gender:t.gender?.toUpperCase(),country:t.country?_t(t.country):void 0,assets:t.assets?.logo?{logo:t.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function It(t){return{type:"player",id:t.id,name:t.name,position:t.position,birthdate:t.birth_date,country:t.country?_t(t.country):void 0,assets:t.assets?.headshot?{photo:t.assets.headshot}:void 0,teams:t.teams?.map(ho),competitions:t.competitions?.map(mo),providerRef:[{provider:"fansunited",id:t.id}]}}function go(t){return It(t.data)}function po(t){return t.data.map(It)}async function yo(t,e,o){const n=o||h.getConfig(),s={};e?.lang&&(s.lang=e.lang);const i=await N.get({path:`/v1/players/${t}`,params:s,next:e?.next,config:n});return go(i)}async function To(t,e){const o=e||h.getConfig(),n={};t?.lang&&(n.lang=t.lang),t?.playerIds&&(n.player_ids=t.playerIds),t?.countryId&&(n.country_id=t.countryId),t?.name&&(n.name=t.name),t?.scope&&(n.scope=t.scope),t?.limit!==void 0&&(n.limit=String(t.limit)),t?.page!==void 0&&(n.page=String(t.page)),t?.sortField&&(n.sort_field=t.sortField),t?.sortOrder&&(n.sort_order=t.sortOrder);const s=await N.get({path:"/v1/players",params:n,next:t?.next,config:o});return po(s)}async function _o(t,e,o){const n=o||h.getConfig(),s={};e?.lang&&(s.lang=e.lang);const i=await N.get({path:`/v1/matches/${t}`,params:s,next:e?.next,config:n});return h.transformMatch(i)}async function vo(t,e){const o=e||h.getConfig(),n={};t?.lang&&(n.lang=t.lang),t?.competitions&&(n.competitions=t.competitions),t?.countries&&(n.countries=t.countries),t?.fromDate&&(n.from_date=t.fromDate),t?.toDate&&(n.to_date=t.toDate),t?.matches&&(n.matches=t.matches),t?.teams&&(n.teams=t.teams),t?.status&&(n.status=t.status),t?.limit!==void 0&&(n.limit=String(t.limit)),t?.page!==void 0&&(n.page=String(t.page)),t?.sortField&&(n.sort_field=t.sortField),t?.sortOrder&&(n.sort_order=t.sortOrder),t?.showDeleted!==void 0&&(n.show_deleted=t.showDeleted?"true":"false");const s=await N.get({path:"/v1/matches",params:n,next:t?.next,config:o});return h.transformMatches(s)}async function So(t,e,o){const n=o||h.getConfig(),s={};e?.lang&&(s.lang=e.lang);const i=await N.get({path:`/v1/teams/${t}/next-match`,params:s,next:e?.next,config:n});return h.transformMatch(i)}async function Ao(t,e,o){const n=o||h.getConfig(),s={};e?.lang&&(s.lang=e.lang);const i=await N.get({path:`/v1/teams/${t}/previous-match`,params:s,next:e?.next,config:n});return h.transformMatch(i)}async function Co(t,e,o){const n=o||h.getConfig(),s={};e?.lang&&(s.lang=e.lang);const i=await N.get({path:`/v1/players/${t}/next-match`,params:s,next:e?.next,config:n});return h.transformMatch(i)}async function Oo(t,e,o){const n=o||h.getConfig(),s={};e?.lang&&(s.lang=e.lang);const i=await N.get({path:`/v1/players/${t}/previous-match`,params:s,next:e?.next,config:n});return h.transformMatch(i)}function vt(t){return{id:t.id,name:t.name,code:t.country_code,flag:t.assets?.flag||void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function Fo(t){return{id:t.id,name:t.name,shortName:t.short_name||void 0,type:t.type||"LEAGUE",region:t.region,gender:t.gender?.toUpperCase(),country:t.country?vt(t.country):void 0,assets:t.assets?.logo?{logo:t.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function Eo(t){return{type:"player",id:t.id,name:t.name,position:t.position||void 0,gender:t.gender?.toUpperCase(),birthdate:t.birth_date||void 0,country:t.country?vt(t.country):void 0,assets:t.assets?.headshot?{photo:t.assets.headshot}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function Lo(t){return{type:t.national?"national":"club",id:t.id,name:t.name,shortName:t.short_name||void 0,threeLetterCode:t.code||void 0,gender:t.gender?.toUpperCase(),country:t.country?vt(t.country):void 0,assets:t.assets?.logo?{logo:t.assets.logo}:void 0,providerRef:[{provider:"fansunited",id:t.id}]}}function mt(t){switch(t.entity_type){case"competition":{const e=Fo(t);return{source:"FOOTBALL",entityType:"competition",entityId:t.id,entityData:e}}case"player":{const e=Eo(t);return{source:"FOOTBALL",entityType:"player",entityId:t.id,entityData:e}}case"team":{const e=Lo(t);return{source:"FOOTBALL",entityType:"team",entityId:t.id,entityData:e}}case"venue":case"coach":return null;default:throw new Error(`Unknown entity type: ${t.entity_type}`)}}async function bo(t,e){if(!t.query||t.query.trim()==="")return[];const o=e||h.getConfig(),n={q:t.query.trim()},i=(t.entityTypes&&t.entityTypes.length>0?t.entityTypes:["competition","team","player"]).map(c=>{switch(c){case"team":return"teams";case"player":return"players";case"competition":return"competitions";default:return c}});n.entities=i.join(","),t.lang&&(n.lang=t.lang),t.limit&&(n.limit=String(t.limit));const r=await N.get({path:"/v1/search",params:n,next:t.next,config:o}),a=[];return r.data&&(r.data.competitions&&r.data.competitions.forEach(c=>{const d=mt({...c,entity_type:"competition"});d&&a.push(d)}),r.data.teams&&r.data.teams.forEach(c=>{const d=mt({...c,entity_type:"team"});d&&a.push(d)}),r.data.players&&r.data.players.forEach(c=>{const d=mt({...c,entity_type:"player"});d&&a.push(d)})),a}const Ro="https://search.fansunitedapi.com",$=Pt(Ro);var No=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Ut=new Set,yt=typeof process=="object"&&process?process:{},Gt=(t,e,o,n)=>{typeof yt.emitWarning=="function"?yt.emitWarning(t,e,o,n):console.error(`[${o}] ${e}: ${t}`)},lt=globalThis.AbortController,Ot=globalThis.AbortSignal;if(typeof lt>"u"){Ot=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(o,n){this._onabort.push(n)}},lt=class{constructor(){e()}signal=new Ot;abort(o){if(!this.signal.aborted){this.signal.reason=o,this.signal.aborted=!0;for(let n of this.signal._onabort)n(o);this.signal.onabort?.(o)}}};let t=yt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{t&&(t=!1,Gt("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))}}var Po=t=>!Ut.has(t),B=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),Dt=t=>B(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?ct:null:null,ct=class extends Array{constructor(t){super(t),this.fill(0)}},Mo=class tt{heap;length;static#a=!1;static create(e){let o=Dt(e);if(!o)return[];tt.#a=!0;let n=new tt(e,o);return tt.#a=!1,n}constructor(e,o){if(!tt.#a)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new o(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},Io=class xt{#a;#u;#p;#R;#y;#I;#U;#T;get perf(){return this.#T}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#s;#_;#n;#o;#t;#l;#f;#c;#i;#v;#r;#S;#A;#h;#m;#C;#b;#d;#G;static unsafeExposeInternals(e){return{starts:e.#A,ttls:e.#h,autopurgeTimers:e.#m,sizes:e.#S,keyMap:e.#n,keyList:e.#o,valList:e.#t,next:e.#l,prev:e.#f,get head(){return e.#c},get tail(){return e.#i},free:e.#v,isBackgroundFetch:o=>e.#e(o),backgroundFetch:(o,n,s,i)=>e.#H(o,n,s,i),moveToTail:o=>e.#M(o),indexes:o=>e.#O(o),rindexes:o=>e.#F(o),isStale:o=>e.#g(o)}}get max(){return this.#a}get maxSize(){return this.#u}get calculatedSize(){return this.#_}get size(){return this.#s}get fetchMethod(){return this.#I}get memoMethod(){return this.#U}get dispose(){return this.#p}get onInsert(){return this.#R}get disposeAfter(){return this.#y}constructor(e){let{max:o=0,ttl:n,ttlResolution:s=1,ttlAutopurge:i,updateAgeOnGet:r,updateAgeOnHas:a,allowStale:c,dispose:d,onInsert:f,disposeAfter:l,noDisposeOnSet:u,noUpdateTTL:m,maxSize:y=0,maxEntrySize:T=0,sizeCalculation:A,fetchMethod:p,memoMethod:_,noDeleteOnFetchRejection:C,noDeleteOnStaleGet:O,allowStaleOnFetchRejection:S,allowStaleOnFetchAbort:P,ignoreFetchAbort:M,perf:I}=e;if(I!==void 0&&typeof I?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#T=I??No,o!==0&&!B(o))throw new TypeError("max option must be a nonnegative integer");let g=o?Dt(o):Array;if(!g)throw new Error("invalid max value: "+o);if(this.#a=o,this.#u=y,this.maxEntrySize=T||this.#u,this.sizeCalculation=A,this.sizeCalculation){if(!this.#u&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(_!==void 0&&typeof _!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#U=_,p!==void 0&&typeof p!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#I=p,this.#b=!!p,this.#n=new Map,this.#o=new Array(o).fill(void 0),this.#t=new Array(o).fill(void 0),this.#l=new g(o),this.#f=new g(o),this.#c=0,this.#i=0,this.#v=Mo.create(o),this.#s=0,this.#_=0,typeof d=="function"&&(this.#p=d),typeof f=="function"&&(this.#R=f),typeof l=="function"?(this.#y=l,this.#r=[]):(this.#y=void 0,this.#r=void 0),this.#C=!!this.#p,this.#G=!!this.#R,this.#d=!!this.#y,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!m,this.noDeleteOnFetchRejection=!!C,this.allowStaleOnFetchRejection=!!S,this.allowStaleOnFetchAbort=!!P,this.ignoreFetchAbort=!!M,this.maxEntrySize!==0){if(this.#u!==0&&!B(this.#u))throw new TypeError("maxSize must be a positive integer if specified");if(!B(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#j()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!O,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!a,this.ttlResolution=B(s)||s===0?s:1,this.ttlAutopurge=!!i,this.ttl=n||0,this.ttl){if(!B(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#k()}if(this.#a===0&&this.ttl===0&&this.#u===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#a&&!this.#u){let F="LRU_CACHE_UNBOUNDED";Po(F)&&(Ut.add(F),Gt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",F,xt))}}getRemainingTTL(e){return this.#n.has(e)?1/0:0}#k(){let e=new ct(this.#a),o=new ct(this.#a);this.#h=e,this.#A=o;let n=this.ttlAutopurge?new Array(this.#a):void 0;this.#m=n,this.#$=(r,a,c=this.#T.now())=>{if(o[r]=a!==0?c:0,e[r]=a,n?.[r]&&(clearTimeout(n[r]),n[r]=void 0),a!==0&&n){let d=setTimeout(()=>{this.#g(r)&&this.#E(this.#o[r],"expire")},a+1);d.unref&&d.unref(),n[r]=d}},this.#N=r=>{o[r]=e[r]!==0?this.#T.now():0},this.#L=(r,a)=>{if(e[a]){let c=e[a],d=o[a];if(!c||!d)return;r.ttl=c,r.start=d,r.now=s||i();let f=r.now-d;r.remainingTTL=c-f}};let s=0,i=()=>{let r=this.#T.now();if(this.ttlResolution>0){s=r;let a=setTimeout(()=>s=0,this.ttlResolution);a.unref&&a.unref()}return r};this.getRemainingTTL=r=>{let a=this.#n.get(r);if(a===void 0)return 0;let c=e[a],d=o[a];if(!c||!d)return 1/0;let f=(s||i())-d;return c-f},this.#g=r=>{let a=o[r],c=e[r];return!!c&&!!a&&(s||i())-a>c}}#N=()=>{};#L=()=>{};#$=()=>{};#g=()=>!1;#j(){let e=new ct(this.#a);this.#_=0,this.#S=e,this.#P=o=>{this.#_-=e[o],e[o]=0},this.#B=(o,n,s,i)=>{if(this.#e(n))return 0;if(!B(s))if(i){if(typeof i!="function")throw new TypeError("sizeCalculation must be a function");if(s=i(n,o),!B(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return s},this.#D=(o,n,s)=>{if(e[o]=n,this.#u){let i=this.#u-e[o];for(;this.#_>i;)this.#x(!0)}this.#_+=e[o],s&&(s.entrySize=n,s.totalCalculatedSize=this.#_)}}#P=e=>{};#D=(e,o,n)=>{};#B=(e,o,n,s)=>{if(n||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:e=this.allowStale}={}){if(this.#s)for(let o=this.#i;!(!this.#W(o)||((e||!this.#g(o))&&(yield o),o===this.#c));)o=this.#f[o]}*#F({allowStale:e=this.allowStale}={}){if(this.#s)for(let o=this.#c;!(!this.#W(o)||((e||!this.#g(o))&&(yield o),o===this.#i));)o=this.#l[o]}#W(e){return e!==void 0&&this.#n.get(this.#o[e])===e}*entries(){for(let e of this.#O())this.#t[e]!==void 0&&this.#o[e]!==void 0&&!this.#e(this.#t[e])&&(yield[this.#o[e],this.#t[e]])}*rentries(){for(let e of this.#F())this.#t[e]!==void 0&&this.#o[e]!==void 0&&!this.#e(this.#t[e])&&(yield[this.#o[e],this.#t[e]])}*keys(){for(let e of this.#O()){let o=this.#o[e];o!==void 0&&!this.#e(this.#t[e])&&(yield o)}}*rkeys(){for(let e of this.#F()){let o=this.#o[e];o!==void 0&&!this.#e(this.#t[e])&&(yield o)}}*values(){for(let e of this.#O())this.#t[e]!==void 0&&!this.#e(this.#t[e])&&(yield this.#t[e])}*rvalues(){for(let e of this.#F())this.#t[e]!==void 0&&!this.#e(this.#t[e])&&(yield this.#t[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,o={}){for(let n of this.#O()){let s=this.#t[n],i=this.#e(s)?s.__staleWhileFetching:s;if(i!==void 0&&e(i,this.#o[n],this))return this.get(this.#o[n],o)}}forEach(e,o=this){for(let n of this.#O()){let s=this.#t[n],i=this.#e(s)?s.__staleWhileFetching:s;i!==void 0&&e.call(o,i,this.#o[n],this)}}rforEach(e,o=this){for(let n of this.#F()){let s=this.#t[n],i=this.#e(s)?s.__staleWhileFetching:s;i!==void 0&&e.call(o,i,this.#o[n],this)}}purgeStale(){let e=!1;for(let o of this.#F({allowStale:!0}))this.#g(o)&&(this.#E(this.#o[o],"expire"),e=!0);return e}info(e){let o=this.#n.get(e);if(o===void 0)return;let n=this.#t[o],s=this.#e(n)?n.__staleWhileFetching:n;if(s===void 0)return;let i={value:s};if(this.#h&&this.#A){let r=this.#h[o],a=this.#A[o];if(r&&a){let c=r-(this.#T.now()-a);i.ttl=c,i.start=Date.now()}}return this.#S&&(i.size=this.#S[o]),i}dump(){let e=[];for(let o of this.#O({allowStale:!0})){let n=this.#o[o],s=this.#t[o],i=this.#e(s)?s.__staleWhileFetching:s;if(i===void 0||n===void 0)continue;let r={value:i};if(this.#h&&this.#A){r.ttl=this.#h[o];let a=this.#T.now()-this.#A[o];r.start=Math.floor(Date.now()-a)}this.#S&&(r.size=this.#S[o]),e.unshift([n,r])}return e}load(e){this.clear();for(let[o,n]of e){if(n.start){let s=Date.now()-n.start;n.start=this.#T.now()-s}this.set(o,n.value,n)}}set(e,o,n={}){if(o===void 0)return this.delete(e),this;let{ttl:s=this.ttl,start:i,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:c}=n,{noUpdateTTL:d=this.noUpdateTTL}=n,f=this.#B(e,o,n.size||0,a);if(this.maxEntrySize&&f>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this.#E(e,"set"),this;let l=this.#s===0?void 0:this.#n.get(e);if(l===void 0)l=this.#s===0?this.#i:this.#v.length!==0?this.#v.pop():this.#s===this.#a?this.#x(!1):this.#s,this.#o[l]=e,this.#t[l]=o,this.#n.set(e,l),this.#l[this.#i]=l,this.#f[l]=this.#i,this.#i=l,this.#s++,this.#D(l,f,c),c&&(c.set="add"),d=!1,this.#G&&this.#R?.(o,e,"add");else{this.#M(l);let u=this.#t[l];if(o!==u){if(this.#b&&this.#e(u)){u.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:m}=u;m!==void 0&&!r&&(this.#C&&this.#p?.(m,e,"set"),this.#d&&this.#r?.push([m,e,"set"]))}else r||(this.#C&&this.#p?.(u,e,"set"),this.#d&&this.#r?.push([u,e,"set"]));if(this.#P(l),this.#D(l,f,c),this.#t[l]=o,c){c.set="replace";let m=u&&this.#e(u)?u.__staleWhileFetching:u;m!==void 0&&(c.oldValue=m)}}else c&&(c.set="update");this.#G&&this.onInsert?.(o,e,o===u?"update":"replace")}if(s!==0&&!this.#h&&this.#k(),this.#h&&(d||this.#$(l,s,i),c&&this.#L(c,l)),!r&&this.#d&&this.#r){let u=this.#r,m;for(;m=u?.shift();)this.#y?.(...m)}return this}pop(){try{for(;this.#s;){let e=this.#t[this.#c];if(this.#x(!0),this.#e(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#d&&this.#r){let e=this.#r,o;for(;o=e?.shift();)this.#y?.(...o)}}}#x(e){let o=this.#c,n=this.#o[o],s=this.#t[o];return this.#b&&this.#e(s)?s.__abortController.abort(new Error("evicted")):(this.#C||this.#d)&&(this.#C&&this.#p?.(s,n,"evict"),this.#d&&this.#r?.push([s,n,"evict"])),this.#P(o),this.#m?.[o]&&(clearTimeout(this.#m[o]),this.#m[o]=void 0),e&&(this.#o[o]=void 0,this.#t[o]=void 0,this.#v.push(o)),this.#s===1?(this.#c=this.#i=0,this.#v.length=0):this.#c=this.#l[o],this.#n.delete(n),this.#s--,o}has(e,o={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:s}=o,i=this.#n.get(e);if(i!==void 0){let r=this.#t[i];if(this.#e(r)&&r.__staleWhileFetching===void 0)return!1;if(this.#g(i))s&&(s.has="stale",this.#L(s,i));else return n&&this.#N(i),s&&(s.has="hit",this.#L(s,i)),!0}else s&&(s.has="miss");return!1}peek(e,o={}){let{allowStale:n=this.allowStale}=o,s=this.#n.get(e);if(s===void 0||!n&&this.#g(s))return;let i=this.#t[s];return this.#e(i)?i.__staleWhileFetching:i}#H(e,o,n,s){let i=o===void 0?void 0:this.#t[o];if(this.#e(i))return i;let r=new lt,{signal:a}=n;a?.addEventListener("abort",()=>r.abort(a.reason),{signal:r.signal});let c={signal:r.signal,options:n,context:s},d=(T,A=!1)=>{let{aborted:p}=r.signal,_=n.ignoreFetchAbort&&T!==void 0,C=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&T!==void 0);if(n.status&&(p&&!A?(n.status.fetchAborted=!0,n.status.fetchError=r.signal.reason,_&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),p&&!_&&!A)return l(r.signal.reason,C);let O=m,S=this.#t[o];return(S===m||_&&A&&S===void 0)&&(T===void 0?O.__staleWhileFetching!==void 0?this.#t[o]=O.__staleWhileFetching:this.#E(e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(e,T,c.options))),T},f=T=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=T),l(T,!1)),l=(T,A)=>{let{aborted:p}=r.signal,_=p&&n.allowStaleOnFetchAbort,C=_||n.allowStaleOnFetchRejection,O=C||n.noDeleteOnFetchRejection,S=m;if(this.#t[o]===m&&(!O||!A&&S.__staleWhileFetching===void 0?this.#E(e,"fetch"):_||(this.#t[o]=S.__staleWhileFetching)),C)return n.status&&S.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),S.__staleWhileFetching;if(S.__returned===S)throw T},u=(T,A)=>{let p=this.#I?.(e,i,c);p&&p instanceof Promise&&p.then(_=>T(_===void 0?void 0:_),A),r.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(T(void 0),n.allowStaleOnFetchAbort&&(T=_=>d(_,!0)))})};n.status&&(n.status.fetchDispatched=!0);let m=new Promise(u).then(d,f),y=Object.assign(m,{__abortController:r,__staleWhileFetching:i,__returned:void 0});return o===void 0?(this.set(e,y,{...c.options,status:void 0}),o=this.#n.get(e)):this.#t[o]=y,y}#e(e){if(!this.#b)return!1;let o=e;return!!o&&o instanceof Promise&&o.hasOwnProperty("__staleWhileFetching")&&o.__abortController instanceof lt}async fetch(e,o={}){let{allowStale:n=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:m=this.ignoreFetchAbort,allowStaleOnFetchAbort:y=this.allowStaleOnFetchAbort,context:T,forceRefresh:A=!1,status:p,signal:_}=o;if(!this.#b)return p&&(p.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:i,status:p});let C={allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:i,ttl:r,noDisposeOnSet:a,size:c,sizeCalculation:d,noUpdateTTL:f,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:y,ignoreFetchAbort:m,status:p,signal:_},O=this.#n.get(e);if(O===void 0){p&&(p.fetch="miss");let S=this.#H(e,O,C,T);return S.__returned=S}else{let S=this.#t[O];if(this.#e(S)){let g=n&&S.__staleWhileFetching!==void 0;return p&&(p.fetch="inflight",g&&(p.returnedStale=!0)),g?S.__staleWhileFetching:S.__returned=S}let P=this.#g(O);if(!A&&!P)return p&&(p.fetch="hit"),this.#M(O),s&&this.#N(O),p&&this.#L(p,O),S;let M=this.#H(e,O,C,T),I=M.__staleWhileFetching!==void 0&&n;return p&&(p.fetch=P?"stale":"refresh",I&&P&&(p.returnedStale=!0)),I?M.__staleWhileFetching:M.__returned=M}}async forceFetch(e,o={}){let n=await this.fetch(e,o);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,o={}){let n=this.#U;if(!n)throw new Error("no memoMethod provided to constructor");let{context:s,forceRefresh:i,...r}=o,a=this.get(e,r);if(!i&&a!==void 0)return a;let c=n(e,a,{options:r,context:s});return this.set(e,c,r),c}get(e,o={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:r}=o,a=this.#n.get(e);if(a!==void 0){let c=this.#t[a],d=this.#e(c);return r&&this.#L(r,a),this.#g(a)?(r&&(r.get="stale"),d?(r&&n&&c.__staleWhileFetching!==void 0&&(r.returnedStale=!0),n?c.__staleWhileFetching:void 0):(i||this.#E(e,"expire"),r&&n&&(r.returnedStale=!0),n?c:void 0)):(r&&(r.get="hit"),d?c.__staleWhileFetching:(this.#M(a),s&&this.#N(a),c))}else r&&(r.get="miss")}#z(e,o){this.#f[o]=e,this.#l[e]=o}#M(e){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)}delete(e){return this.#E(e,"delete")}#E(e,o){let n=!1;if(this.#s!==0){let s=this.#n.get(e);if(s!==void 0)if(this.#m?.[s]&&(clearTimeout(this.#m?.[s]),this.#m[s]=void 0),n=!0,this.#s===1)this.#Y(o);else{this.#P(s);let i=this.#t[s];if(this.#e(i)?i.__abortController.abort(new Error("deleted")):(this.#C||this.#d)&&(this.#C&&this.#p?.(i,e,o),this.#d&&this.#r?.push([i,e,o])),this.#n.delete(e),this.#o[s]=void 0,this.#t[s]=void 0,s===this.#i)this.#i=this.#f[s];else if(s===this.#c)this.#c=this.#l[s];else{let r=this.#f[s];this.#l[r]=this.#l[s];let a=this.#l[s];this.#f[a]=this.#f[s]}this.#s--,this.#v.push(s)}}if(this.#d&&this.#r?.length){let s=this.#r,i;for(;i=s?.shift();)this.#y?.(...i)}return n}clear(){return this.#Y("delete")}#Y(e){for(let o of this.#F({allowStale:!0})){let n=this.#t[o];if(this.#e(n))n.__abortController.abort(new Error("deleted"));else{let s=this.#o[o];this.#C&&this.#p?.(n,s,e),this.#d&&this.#r?.push([n,s,e])}}if(this.#n.clear(),this.#t.fill(void 0),this.#o.fill(void 0),this.#h&&this.#A){this.#h.fill(0),this.#A.fill(0);for(let o of this.#m??[])o!==void 0&&clearTimeout(o);this.#m?.fill(void 0)}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){let o=this.#r,n;for(;n=o?.shift();)this.#y?.(...n)}}};const Uo=50*1024*1024,w=new Io({maxSize:Uo,sizeCalculation:t=>JSON.stringify(t.data).length}),L={get(t){return w.get(t)},set(t,e){w.set(t,{data:e,storedAt:Date.now()})},delete(t){w.delete(t)},clear(){w.clear()},get size(){return w.size}};let U=null;function Go(t){U=t}const Do={competitions:{staleTTL:24*3600,maxTTL:72*3600},teams:{staleTTL:24*3600,maxTTL:48*3600},athletes:{staleTTL:24*3600,maxTTL:48*3600},venues:{staleTTL:72*3600,maxTTL:168*3600},countries:{staleTTL:96*3600,maxTTL:168*3600},coaches:{staleTTL:24*3600,maxTTL:48*3600},search:{staleTTL:300,maxTTL:1800}},gt=new Set;function Ht(t){const e=Do[t];if(!e)throw new Error(`Unknown entity type: ${t}`);return e}function dt(t,e){return Date.now()-t.storedAt<e*1e3}function ut(t,e){return Date.now()-t.storedAt>=e*1e3}function ft(t,e,o){gt.has(t)||(gt.add(t),o().then(n=>{L.set(t,n),U?.isInitialized&&U.set(t,e,n)}).catch(n=>{console.error(`[cache] Background refresh failed for ${t}:`,n)}).finally(()=>{gt.delete(t)}))}async function z(t,e,o){const{staleTTL:n,maxTTL:s}=Ht(e),i=L.get(t);if(i){if(dt(i,n))return i.data;if(!ut(i,s))return ft(t,e,o),i.data}if(U?.isInitialized){const a=U.get(t);if(a&&!ut(a,s))return L.set(t,a.data),dt(a,n)||ft(t,e,o),a.data}const r=await o();return L.set(t,r),U?.isInitialized&&U.set(t,e,r),r}async function kt(t,e,o,n){const{staleTTL:s,maxTTL:i}=Ht(e),r=new Map,a=[];for(const c of t){const d=n(c);let f=!1;const l=L.get(d);if(l&&!ut(l,i)&&(r.set(c,l.data),dt(l,s)||ft(d,e,async()=>{const m=(await o([c])).get(c);if(!m)throw new Error(`Batch fetcher did not return ID: ${c}`);return m}),f=!0),!f&&U?.isInitialized){const u=U.get(d);u&&!ut(u,i)&&(L.set(d,u.data),r.set(c,u.data),dt(u,s)||ft(d,e,async()=>{const y=(await o([c])).get(c);if(!y)throw new Error(`Batch fetcher did not return ID: ${c}`);return y}),f=!0)}f||a.push(c)}if(a.length>0){const c=await o(a);for(const[d,f]of c){const l=n(d);L.set(l,f),U?.isInitialized&&U.set(l,e,f),r.set(d,f)}}return r}function xo(t){L.delete(t)}function x(t,e,o,n){const s=e.toUpperCase(),i=t.find(r=>r.language.toUpperCase()===s);if(i)return{name:i.name,shortName:i.short_name??n??void 0};if(s!=="EN"){const r=t.find(a=>a.language.toUpperCase()==="EN");if(r)return{name:r.name,shortName:r.short_name??n??void 0}}return{name:o,shortName:n??void 0}}function q(t){const e={};for(const o of t)e[o.key.toLowerCase()]=o.value;return e}function K(t){if(!t)return;const e={};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}function X(t){return t.map(e=>({provider:e.provider,id:e.id}))}function Ho(t,e){return t.filter(o=>o.relationship===e).map(o=>o.related_id)}function H(t,e,o){const n=t||Ho(e,"COUNTRY")[0];if(!n)return;const s=L.get(n)??L.get(`entity:${n}`);if(s?.data){const i=s.data;return st(i,o)}return{id:n,name:n}}function st(t,e){const{name:o,shortName:n}=x(t.translations??[],e,t.name,t.short_name),s=q(t.assets??[]);return{id:t.id,name:o,...t.country_code?{code:t.country_code}:{},...s.flag?{flag:s.flag}:{},...n?{shortName:n}:{}}}function St(t,e){const{name:o,shortName:n}=x(t.translations??[],e,t.name,t.short_name),s=q(t.assets??[]),i=K(t.branding),r=H(null,t.related??[],e);return{id:t.id,name:o,sport:t.sport,...n?{shortName:n}:{},...t.format?{type:t.format}:{},...r?{country:r}:{},...s.logo?{assets:{logo:s.logo}}:{},...i?{metadata:{branding:i}}:{}}}function nt(t,e){const{name:o,shortName:n}=x(t.translations??[],e,t.name,t.short_name),s=q(t.assets??[]),i=K(t.metadata?.branding),r=H(t.country_id,t.related??[],e);return{id:t.id,name:o,sport:t.sport,...n?{shortName:n}:{},...t.three_letter_code?{threeLetterCode:t.three_letter_code}:{},...t.full_name?{fullName:t.full_name}:{},...t.nickname?{nickname:t.nickname}:{},...t.gender?{gender:t.gender}:{},...r?{country:r}:{},...s.logo?{assets:{logo:s.logo}}:{},...i?{metadata:{branding:i}}:{}}}function $t(t,e){const{name:o,shortName:n}=x(t.translations??[],e,t.name,t.short_name),s=q(t.assets??[]),i=K(t.metadata?.branding),r=H(t.country_id,t.related??[],e);return{id:t.id,name:o,sport:t.sport,type:"player",...n?{shortName:n}:{},...t.position?{position:t.position}:{},...t.birth_date?{birthdate:t.birth_date}:{},...t.shirt_number!=null?{shirtNumber:t.shirt_number}:{},...t.gender?{gender:t.gender}:{},...r?{country:r}:{},...s.logo||s.headshot?{assets:{...s.logo?{logo:s.logo}:{},...s.headshot?{photo:s.headshot}:{}}}:{},...i?{metadata:{branding:i}}:{}}}function Bt(t,e){const{name:o}=x(t.translations??[],e,t.name,t.short_name),n=H(t.country_id,t.related??[],e),s=t.capacity!=null||t.latitude!=null||t.longitude!=null;return{id:t.id,name:o,sport:t.sport,...n?{country:n}:{},...s?{profile:{...t.capacity!=null?{capacity:t.capacity}:{},...t.latitude!=null?{latitude:t.latitude}:{},...t.longitude!=null?{longitude:t.longitude}:{}}}:{}}}function ko(t,e){const{name:o}=x(t.translations??[],e,t.name,t.short_name),n=H(t.country_id,t.related??[],e);return{id:t.id,name:o,sport:t.sport,...t.birth_date?{birthdate:t.birth_date}:{},...n?{country:n}:{}}}function $o(t,e,o){const n=L.get(t)??L.get(`entity:${t}`);if(!n?.data)return;const s=n.data;switch(e){case"COMPETITION":return St(s,o);case"TEAM":return nt(s,o);case"ATHLETE":return $t(s,o);case"COUNTRY":return st(s,o);default:return}}function it(t,e){if(!t||t.length===0)return;const o={};for(const n of t){const s=$o(n.related_id,n.relationship,e);if(s)switch(n.relationship){case"COMPETITION":(o.competitions??=[]).push(s);break;case"TEAM":(o.teams??=[]).push(s);break;case"ATHLETE":(o.athletes??=[]).push(s);break;case"COUNTRY":(o.countries??=[]).push(s);break}}return Object.keys(o).length>0?o:void 0}function Bo(t,e){const{name:o,shortName:n}=x(t.translations??[],e,t.name,t.short_name),s=q(t.assets??[]),i=K(t.branding),r=H(null,t.related??[],e),a=it(t.related??[],e);return{id:t.id,name:o,sport:t.sport,...n?{shortName:n}:{},...t.format?{type:t.format}:{},...t.gender?{gender:t.gender}:{},...r?{country:r}:{},...s.logo?{assets:{logo:s.logo}}:{},...i?{metadata:{branding:i}}:{},...t.provider_ref?.length?{providerRef:X(t.provider_ref)}:{},...a?{related:a}:{}}}function Ft(t,e){const{name:o,shortName:n}=x(t.translations??[],e,t.name,t.short_name),s=q(t.assets??[]),i=K(t.metadata?.branding),r=H(t.country_id,t.related??[],e),a=it(t.related??[],e);return{id:t.id,name:o,sport:t.sport,...n?{shortName:n}:{},...t.three_letter_code?{threeLetterCode:t.three_letter_code}:{},...t.full_name?{fullName:t.full_name}:{},...t.nickname?{nickname:t.nickname}:{},...t.gender?{gender:t.gender}:{},...r?{country:r}:{},...s.logo?{assets:{logo:s.logo}}:{},...i?{metadata:{branding:i}}:{},...t.provider_ref?.length?{providerRef:X(t.provider_ref)}:{},...a?{related:a}:{}}}function Wo(t,e){const{name:o,shortName:n}=x(t.translations??[],e,t.name,t.short_name),s=q(t.assets??[]),i=K(t.metadata?.branding),r=H(t.country_id,t.related??[],e),a=it(t.related??[],e);return{id:t.id,name:o,sport:t.sport,type:"player",...n?{shortName:n}:{},...t.position?{position:t.position}:{},...t.birth_date?{birthdate:t.birth_date}:{},...t.shirt_number!=null?{shirtNumber:t.shirt_number}:{},...t.gender?{gender:t.gender}:{},...r?{country:r}:{},...s.logo||s.headshot?{assets:{...s.logo?{logo:s.logo}:{},...s.headshot?{photo:s.headshot}:{}}}:{},...i?{metadata:{branding:i}}:{},...t.provider_ref?.length?{providerRef:X(t.provider_ref)}:{},...a?{related:a}:{}}}function zo(t,e){return{...st(t,e),sport:t.sport,...t.provider_ref?.length?{providerRef:X(t.provider_ref)}:{}}}function Yo(t,e){const{name:o}=x(t.translations??[],e,t.name,t.short_name),n=H(t.country_id,t.related??[],e),s=it(t.related??[],e),i=t.capacity!=null||t.latitude!=null||t.longitude!=null;return{id:t.id,name:o,sport:t.sport,...n?{country:n}:{},...i?{profile:{...t.capacity!=null?{capacity:t.capacity}:{},...t.latitude!=null?{latitude:t.latitude}:{},...t.longitude!=null?{longitude:t.longitude}:{}}}:{},...t.provider_ref?.length?{providerRef:X(t.provider_ref)}:{},...s?{related:s}:{}}}function jo(t,e){const{name:o}=x(t.translations??[],e,t.name,t.short_name),n=H(t.country_id,t.related??[],e),s=it(t.related??[],e);return{id:t.id,name:o,sport:t.sport,...t.birth_date?{birthdate:t.birth_date}:{},...n?{country:n}:{},...t.provider_ref?.length?{providerRef:X(t.provider_ref)}:{},...s?{related:s}:{}}}function Wt(t,e){const o=t.content_type?.toUpperCase?.(),n=t.type?.toUpperCase?.(),s=t.entityType?.toLowerCase?.();return o==="COMPETITION"||s==="competition"?{...Bo(t,e),entityType:"competition"}:s==="country"||t.country_code!==void 0?{...zo(t,e),entityType:"country"}:s==="venue"||t.capacity!==void 0&&!s?{...Yo(t,e),entityType:"venue"}:s==="coach"||n==="COACH"?{...jo(t,e),entityType:"coach"}:s==="athlete"||n==="PLAYER"||t.position!==void 0||t.shirt_number!==void 0?{...Wo(t,e),entityType:"athlete"}:s==="team"||n==="TEAM"||t.three_letter_code!==void 0?{...Ft(t,e),entityType:"team"}:{...Ft(t,e),entityType:"team"}}function qo(t,e){const o=t.content_type?.toUpperCase?.(),n=t.type?.toUpperCase?.(),s=t.entityType?.toLowerCase?.();return o==="COMPETITION"||s==="competition"?{...St(t,e),entityType:"competition"}:s==="country"||t.country_code!==void 0?{...st(t,e),entityType:"country"}:s==="venue"||t.capacity!==void 0&&!s?{...Bt(t,e),entityType:"venue"}:s==="coach"||n==="COACH"?{...ko(t,e),entityType:"coach"}:s==="athlete"||n==="PLAYER"||t.position!==void 0||t.shirt_number!==void 0?{...$t(t,e),entityType:"athlete"}:s==="team"||n==="TEAM"||t.three_letter_code!==void 0?{...nt(t,e),entityType:"team"}:{...nt(t,e),entityType:"team"}}function J(t){const e=Object.entries(t).filter(([,n])=>n!==void 0).sort(([n],[s])=>n.localeCompare(s)).map(([n,s])=>`${n}=${Array.isArray(s)?s.join(","):s}`).join("&");let o=0;for(let n=0;n<e.length;n++)o=(o<<5)-o+e.charCodeAt(n)|0;return o.toString(36)}function V(t){for(const e of t)e.id&&L.set(`entity:${e.id}`,e)}function Y(t){if(t?.lang)return t.lang;if(h.isConfigured()){const e=h.getConfig();if(e.fansUnited&&"lang"in e.fansUnited&&e.fansUnited.lang)return e.fansUnited.lang}return"EN"}function Et(t){const e=new Set;for(const o of t){const n=o,s=n.related;if(s)for(const r of s)L.get(`entity:${r.related_id}`)||e.add(r.related_id);const i=n.country_id;i&&!L.get(`entity:${i}`)&&e.add(i)}return e}async function Tt(t,e){if(t.size===0)return[];const o=await $.get({path:"/v1/entities/search",params:{ids:Array.from(t)},next:e?.next,config:e?.config});return V(o.data),o.data}async function zt(t,e){const o=Et(t);if(o.size!==0)try{const n=await Tt(o,e),s=Et(n);s.size>0&&await Tt(s,e)}catch{}}async function rt(t,e){const o=new Set;for(const n of t){const s=n,i=s.country_id;i&&!L.get(`entity:${i}`)&&o.add(i);const r=s.related;if(r)for(const a of r)a.relationship==="COUNTRY"&&!L.get(`entity:${a.related_id}`)&&o.add(a.related_id)}if(o.size!==0)try{await Tt(o,e)}catch{}}async function Vo(t={},e){const o=Y(t),n={query:t.query,content_type:t.contentType,ids:t.ids,limit:t.limit?.toString(),page:t.page?.toString(),mode:t.mode,sport:t.sport,relationship:t.relationship,value:t.value},s=`search:entities:${J(n)}`,i=await z(s,"search",()=>$.get({path:"/v1/entities/search",params:n,next:t.next||e?.next,config:t.config}));return V(i.data),await rt(i.data,{next:t.next||e?.next,config:t.config}),{data:i.data.map(a=>qo(a,o)),pagination:i.meta.pagination}}async function Qo(t,e){const o=Y(e),n=`entity:${t}`,s=await z(n,"search",async()=>{const i=await $.get({path:"/v1/entities/search",params:{ids:[t]},next:e?.next,config:e?.config});if(!i.data||i.data.length===0)throw new Error(`Entity not found: ${t}`);return i.data[0]});return await zt([s],{next:e?.next,config:e?.config}),Wt(s,o)}async function Ko(t,e){if(t.length===0)return[];const o=Y(e),n=await kt(t,"search",async i=>{const r=await $.get({path:"/v1/entities/search",params:{ids:i},next:e?.next,config:e?.config}),a=new Map;for(const c of r.data)a.set(c.id,c);return a},i=>`entity:${i}`),s=t.map(i=>n.get(i)).filter(i=>i!==void 0);return await zt(s,{next:e?.next,config:e?.config}),s.map(i=>Wt(i,o))}async function Xo(t={}){const e=Y(t),o={content_type:"competition",query:t.query,limit:t.limit?.toString(),page:t.page?.toString(),sport:t.sport},n=`competitions:${J(o)}`,s=await z(n,"competitions",()=>$.get({path:"/v1/entities/search",params:o,next:t.next,config:t.config}));return V(s.data),await rt(s.data,{next:t.next,config:t.config}),{data:s.data.map(r=>St(r,e)),pagination:s.meta.pagination}}async function Jo(t,e={}){const o=Y(e),n={content_type:"team",relationship:"COUNTRY",value:t,query:e.query,limit:e.limit?.toString(),page:e.page?.toString(),sport:e.sport},s=`teams:country:${t}:${J(n)}`,i=await z(s,"teams",()=>$.get({path:"/v1/entities/search",params:n,next:e.next,config:e.config}));return V(i.data),await rt(i.data,{next:e.next,config:e.config}),{data:i.data.map(a=>nt(a,o)),pagination:i.meta.pagination}}async function Zo(t,e={}){const o=Y(e),n={content_type:"team",relationship:"COMPETITION",value:t,query:e.query,limit:e.limit?.toString(),page:e.page?.toString(),sport:e.sport},s=`teams:competition:${t}:${J(n)}`,i=await z(s,"teams",()=>$.get({path:"/v1/entities/search",params:n,next:e.next,config:e.config}));return V(i.data),await rt(i.data,{next:e.next,config:e.config}),{data:i.data.map(a=>nt(a,o)),pagination:i.meta.pagination}}async function wo(t={}){const e=Y(t),o={content_type:"country",query:t.query,limit:t.limit?.toString(),page:t.page?.toString(),sport:t.sport},n=`countries:${J(o)}`,s=await z(n,"countries",()=>$.get({path:"/v1/entities/search",params:o,next:t.next,config:t.config}));return V(s.data),{data:s.data.map(r=>st(r,e)),pagination:s.meta.pagination}}async function tn(t={}){const e=Y(t),o={content_type:"venue",query:t.query,limit:t.limit?.toString(),page:t.page?.toString(),sport:t.sport},n=`venues:${J(o)}`,s=await z(n,"venues",()=>$.get({path:"/v1/entities/search",params:o,next:t.next,config:t.config}));return V(s.data),await rt(s.data,{next:t.next,config:t.config}),{data:s.data.map(r=>Bt(r,e)),pagination:s.meta.pagination}}function en(t){return!t.seasons||t.seasons.length===0?void 0:t.seasons.find(o=>o.active)??t.seasons[0]}function on(t,e){const o=new Date,n=e.filter(s=>{const i=s.competitorOne.id===t||s.competitorTwo.id===t,r=s.status.type==="NOT_STARTED",a=new Date(s.timing.kickoffTime)>=o;return i&&r&&a});return n.sort((s,i)=>new Date(s.timing.kickoffTime).getTime()-new Date(i.timing.kickoffTime).getTime()),n[0]}function nn(t,e){const o=new Date,n=e.filter(s=>{const i=s.competitorOne.id===t||s.competitorTwo.id===t,r=s.status.type==="FINISHED",a=new Date(s.timing.kickoffTime)<=o;return i&&r&&a});return n.sort((s,i)=>new Date(i.timing.kickoffTime).getTime()-new Date(s.timing.kickoffTime).getTime()),n[0]}function sn(t,e){const o=new Date;return e.filter(s=>{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)>=o||s.status.type==="LIVE";return i&&r&&a}).sort((s,i)=>new Date(s.timing.kickoffTime).getTime()-new Date(i.timing.kickoffTime).getTime())}function rn(t,e){const o=new Date;return e.filter(s=>{const i=s.competitorOne.id===t||s.competitorTwo.id===t,r=s.status.type==="FINISHED",a=new Date(s.timing.kickoffTime)<=o;return i&&r&&a}).sort((s,i)=>new Date(i.timing.kickoffTime).getTime()-new Date(s.timing.kickoffTime).getTime())}function an(t,e,o){const n=o.filter(r=>r.status.type==="FINISHED"),s=o.filter(r=>r.status.type==="NOT_STARTED"||r.status.type==="POSTPONED"),i=e.entries.map(r=>{const a=r.competitor.id,c=n.filter(u=>u.competitorOne.id===t&&u.competitorTwo.id===a||u.competitorOne.id===a&&u.competitorTwo.id===t),d=s.filter(u=>u.competitorOne.id===t&&u.competitorTwo.id===a||u.competitorOne.id===a&&u.competitorTwo.id===t);let f,l;return c.forEach(u=>{const m=u.competitorOne.id===t,y=parseInt(u.score?.competitorOne??"0"),T=parseInt(u.score?.competitorTwo??"0"),A=m?y:T,p=m?T:y;let _;A>p?_="W":A===p?_="D":_="L";const C={result:_,score:`${y} - ${T}`,date:u.timing.kickoffTime,matchId:u.id,isUpcoming:!1};m?f=C:l=C}),d.forEach(u=>{const m=u.competitorOne.id===t;m&&!f?f={date:u.timing.kickoffTime,matchId:u.id,isUpcoming:!0}:!m&&!l&&(l={date:u.timing.kickoffTime,matchId:u.id,isUpcoming:!0})}),{rank:r.rank,teamId:r.competitor.id,teamName:r.competitor.name,teamShortName:r.competitor.shortName,teamLogo:r.competitor.logo,gamesPlayed:r.stats.played??0,points:r.stats.points??0,homeResult:f,awayResult:l}});return{teamId:t,rows:i}}function cn(t,e=10){return t.players.filter(o=>(o.seasonStatistics?.goals??0)>0).sort((o,n)=>{const s=o.seasonStatistics?.goals??0,i=n.seasonStatistics?.goals??0;if(i!==s)return i-s;const r=o.seasonStatistics?.assists??0;return(n.seasonStatistics?.assists??0)-r}).slice(0,e)}function ln(t,e=10){return t.players.filter(o=>(o.seasonStatistics?.assists??0)>0).sort((o,n)=>{const s=o.seasonStatistics?.assists??0,i=n.seasonStatistics?.assists??0;if(i!==s)return i-s;const r=o.seasonStatistics?.goals??0;return(n.seasonStatistics?.goals??0)-r}).slice(0,e)}function dn(t,e=10){return t.players.filter(o=>(o.seasonStatistics?.appearances??0)>0).sort((o,n)=>{const s=o.seasonStatistics?.appearances??0,i=n.seasonStatistics?.appearances??0;if(i!==s)return i-s;const r=o.seasonStatistics?.minutes??0;return(n.seasonStatistics?.minutes??0)-r}).slice(0,e)}function un(t,e=10){return t.players.filter(o=>(o.seasonStatistics?.minutes??0)>0).sort((o,n)=>{const s=o.seasonStatistics?.minutes??0,i=n.seasonStatistics?.minutes??0;if(i!==s)return i-s;const r=o.seasonStatistics?.appearances??0;return(n.seasonStatistics?.appearances??0)-r}).slice(0,e)}function fn(t,e=10){return t.players.filter(o=>(o.seasonStatistics?.cleansheets??0)>0).sort((o,n)=>{const s=o.seasonStatistics?.cleansheets??0,i=n.seasonStatistics?.cleansheets??0;if(i!==s)return i-s;const r=o.seasonStatistics?.appearances??0;return(n.seasonStatistics?.appearances??0)-r}).slice(0,e)}function hn(t,e=10){return t.players.filter(o=>{const n=o.seasonStatistics?.yellowCards??0,s=o.seasonStatistics?.redCards??0;return n+s>0}).sort((o,n)=>{const s=o.seasonStatistics?.yellowCards??0,i=o.seasonStatistics?.redCards??0,r=n.seasonStatistics?.yellowCards??0,a=n.seasonStatistics?.redCards??0,c=s+i*3,d=r+a*3;return d!==c?d-c:a!==i?a-i:r-s}).slice(0,e)}function Q(t){const e=new Map,o=new Map;return t.forEach(n=>{!n.mainEvents||n.mainEvents.length===0||n.mainEvents.forEach(s=>{if(s.primaryPlayer){const i=s.primaryPlayer.id;e.has(i)||e.set(i,{playerId:s.primaryPlayer.id,seasonId:"",teamId:"",goals:0,assists:0,yellowCards:0,redCards:0,appearances:0});const r=e.get(i);o.has(i)||o.set(i,new Set),o.get(i).add(n.id),(s.type==="GOAL"||s.type==="PENALTY_GOAL")&&(r.goals=(r.goals??0)+1),s.type==="YELLOW_CARD"&&(r.yellowCards=(r.yellowCards??0)+1),(s.type==="RED_CARD"||s.type==="YELLOW_RED_CARD")&&(r.redCards=(r.redCards??0)+1)}if(s.secondaryPlayer&&(s.type==="GOAL"||s.type==="PENALTY_GOAL")){const i=s.secondaryPlayer.id;e.has(i)||e.set(i,{playerId:s.secondaryPlayer.id,seasonId:"",teamId:"",goals:0,assists:0,yellowCards:0,redCards:0,appearances:0});const r=e.get(i);r.assists=(r.assists??0)+1,o.has(i)||o.set(i,new Set),o.get(i).add(n.id)}})}),o.forEach((n,s)=>{const i=e.get(s);i&&i.appearances!==void 0&&(i.appearances=n.size)}),e}function at(t){return Array.from(t.values()).map(e=>({...e,totalCards:(e.yellowCards??0)+(e.redCards??0)}))}function Yt(t,e=10){const o=Q(t);return at(o).filter(s=>(s.goals??0)>0).sort((s,i)=>{const r=s.goals??0,a=i.goals??0;if(a!==r)return a-r;const c=s.assists??0;return(i.assists??0)-c}).slice(0,e)}function jt(t,e=10){const o=Q(t);return at(o).filter(s=>(s.assists??0)>0).sort((s,i)=>{const r=s.assists??0,a=i.assists??0;if(a!==r)return a-r;const c=s.goals??0;return(i.goals??0)-c}).slice(0,e)}function qt(t,e=10){const o=Q(t);return at(o).filter(s=>(s.totalCards??0)>0).sort((s,i)=>{const r=(s.yellowCards??0)+(s.redCards??0)*3,a=(i.yellowCards??0)+(i.redCards??0)*3;if(a!==r)return a-r;const c=s.redCards??0,d=i.redCards??0;if(d!==c)return d-c;const f=s.yellowCards??0;return(i.yellowCards??0)-f}).slice(0,e)}function Vt(t,e=10){const o=Q(t);return at(o).filter(s=>(s.goals??0)+(s.assists??0)>0).sort((s,i)=>{const r=(s.goals??0)+(s.assists??0),a=(i.goals??0)+(i.assists??0);if(a!==r)return a-r;const c=s.goals??0,d=i.goals??0;if(d!==c)return d-c;const f=s.assists??0;return(i.assists??0)-f}).slice(0,e)}function Qt(t){const e=Q(t);return at(e).sort((n,s)=>{const i=n.appearances??0,r=s.appearances??0;if(r!==i)return r-i;const a=(n.goals??0)+(n.assists??0);return(s.goals??0)+(s.assists??0)-a})}function mn(t,e=10){return j.useMemo(()=>Yt(t,e),[t,e])}function gn(t,e=10){return j.useMemo(()=>jt(t,e),[t,e])}function pn(t,e=10){return j.useMemo(()=>qt(t,e),[t,e])}function yn(t,e=10){return j.useMemo(()=>Vt(t,e),[t,e])}function Tn(t){return j.useMemo(()=>Qt(t),[t])}function Kt(t){return j.useMemo(()=>Q(t),[t])}function _n(t,e){const o=Kt(t);return j.useMemo(()=>o.get(e),[o,e])}const Xt=["GOAL","PENALTY_GOAL","OWN_GOAL"];function R(t,e){return e>0?t/e*100:0}function et(t,e){return e>0?t/e:0}function vn(t,e=!1,o=2){return e?`${Math.round(t)}%`:Number.isInteger(t)?t.toString():t.toFixed(o)}function Sn(t,e){const o=typeof t=="string"?parseFloat(t):t;if(isNaN(o)||e===0)return"0";const n=(o/e).toFixed(1);return`${o} (${n} avg)`}function An(t,e){const o=typeof t=="string"?parseFloat(t):t;return isNaN(o)||e===0?"0.0":(o/e).toFixed(1)}function Cn(t){const e=parseFloat(t);return isNaN(e)?"0%":`${Math.round(e)}%`}function Jt(t,e,o){if(t.status?.type!=="FINISHED"||!t.score)return null;const n=parseInt(t.score.competitorOne||"0"),s=parseInt(t.score.competitorTwo||"0"),i=o?n:s,r=o?s:n;let a=null,c=null;const d=t.score.breakdown?.halfTime;if(d){const m=parseInt(d.competitorOne||"0"),y=parseInt(d.competitorTwo||"0");a=o?m:y,c=o?y:m}const f=t.statistics;let l=null,u=null;if(f){const m=f.find?.(y=>y.type==="CORNERS");m&&(l=o?m.competitorOne:m.competitorTwo,u=o?m.competitorTwo:m.competitorOne)}return{goalsFor:i,goalsAgainst:r,halfTimeGoalsFor:a,halfTimeGoalsAgainst:c,cornersFor:l,cornersAgainst:u,isWin:i>r,isDraw:i===r,isLoss:i<r}}function ht(t,e){return t.competitorOne.id===e}function Zt(t,e){return t.competitorTwo.id===e}function On(t,e){return ht(t,e)||Zt(t,e)}function Fn(t){return t.status?.type==="FINISHED"}function En(t,e){const o=ht(t,e);return parseInt(o?t.score?.competitorOne||"0":t.score?.competitorTwo||"0")}function Ln(t,e){const o=ht(t,e);return parseInt(o?t.score?.competitorTwo||"0":t.score?.competitorOne||"0")}function bn(t,e,o){const n=t.filter(f=>{if(f.status?.type!=="FINISHED"||!f.score)return!1;const l=f.competitorOne.id===e||f.competitorTwo.id===e,u=f.competitorOne.id===o||f.competitorTwo.id===o;return l&&u});let s=0,i=0,r=0,a=0,c=0;n.forEach(f=>{const l=parseInt(f.score?.competitorOne||"0"),u=parseInt(f.score?.competitorTwo||"0"),m=f.competitorOne.id===e,y=m?l:u,T=m?u:l;a+=y,c+=T,y>T?s++:T>y?i++:r++});const d=n.length;return{totalMatches:d,homeTeamWins:s,awayTeamWins:i,draws:r,homeTeamGoals:a,awayTeamGoals:c,homeTeamWinPercentage:d>0?s/d*100:0,awayTeamWinPercentage:d>0?i/d*100:0,drawPercentage:d>0?r/d*100:0,homeTeamAvgGoals:d>0?a/d:0,awayTeamAvgGoals:d>0?c/d:0}}function Rn(t,e,o,n=5){return t.filter(i=>{if(i.status?.type!=="FINISHED"||!i.score)return!1;const r=i.competitorOne.id===e||i.competitorTwo.id===e,a=i.competitorOne.id===o||i.competitorTwo.id===o;return r&&a}).sort((i,r)=>new Date(r.timing.kickoffTime).getTime()-new Date(i.timing.kickoffTime).getTime()).slice(0,n).map(i=>{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;let l;return d>f?l="home":f>d?l="away":l="draw",{id:i.id,date:new Date(i.timing.kickoffTime).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}),homeTeamName:i.competitorOne.name,awayTeamName:i.competitorTwo.name,homeTeamLogo:i.competitorOne.assets?.logo,awayTeamLogo:i.competitorTwo.assets?.logo,homeScore:r,awayScore:a,venue:i.venue?.name,winner:l}})}function Nn(t,e,o){return t.filter(n=>{const s=n.competitorOne.id===e,i=n.competitorTwo.id===e;return!s&&!i?!1:o==="home"?s:i}).map(n=>{const s=n.competitorOne.id===e;return Jt(n,e,s)}).filter(n=>n!==null)}function Lt(t,e,o,n){let s=0;for(const i of t){const r=i.competitorOne.id===e,a=i.competitorTwo.id===e;if(!r&&!a||o==="home"&&!r||o==="away"&&!a||i.status?.type!=="FINISHED")continue;const c=i.mainEvents;if(!c||!Array.isArray(c))continue;const d=c.filter(y=>y.type&&Xt.includes(y.type)).sort((y,T)=>{const A=y.minute??0,p=T.minute??0;return A!==p?A-p:(y.injuryMinute??0)-(T.injuryMinute??0)});if(d.length===0)continue;const f=d[0],l=r?"ONE":"TWO",u=f.type==="OWN_GOAL";let m;u?m=f.competitorPosition!==l:m=f.competitorPosition===l,(n==="scored"&&m||n==="conceded"&&!m)&&s++}return s}function Pn(t,e,o){let n=0;for(const s of t){const i=s.competitorOne.id===e,r=s.competitorTwo.id===e;if(!i&&!r||o==="home"&&!i||o==="away"&&!r||s.status?.type!=="FINISHED")continue;const a=s.mainEvents;a&&Array.isArray(a)&&n++}return n}function Mn(t,e,o){const n=Nn(t,e,o),s=n.length;if(s===0)return{played:0,goalsForPerMatch:0,cleanSheets:0,wonToNil:0,scoringRate:0,scoredInBothHalves:0,scoredFirst:0,leadingAtHalfTime:0,goalsAgainstPerMatch:0,failedToScore:0,lostToNil:0,concedingRate:0,concededInBothHalves:0,concededFirst:0,losingAtHalfTime:0,avgCornersFor:0,avgCornersAgainst:0};const i=n.reduce((g,F)=>g+F.goalsFor,0),r=n.reduce((g,F)=>g+F.goalsAgainst,0),a=n.filter(g=>g.goalsAgainst===0).length,c=n.filter(g=>g.isWin&&g.goalsAgainst===0).length,d=n.filter(g=>g.goalsFor>0).length,f=n.filter(g=>g.goalsFor===0).length,l=n.filter(g=>g.isLoss&&g.goalsFor===0).length,u=n.filter(g=>g.goalsAgainst>0).length,m=n.filter(g=>g.halfTimeGoalsFor!==null),y=m.length,T=m.filter(g=>{const F=g.halfTimeGoalsFor,Z=g.goalsFor-F;return F>0&&Z>0}).length,A=Lt(t,e,o,"scored"),p=Pn(t,e,o),_=m.filter(g=>g.halfTimeGoalsFor>g.halfTimeGoalsAgainst).length,C=m.filter(g=>{const F=g.halfTimeGoalsAgainst,Z=g.goalsAgainst-F;return F>0&&Z>0}).length,O=Lt(t,e,o,"conceded"),S=m.filter(g=>g.halfTimeGoalsAgainst>g.halfTimeGoalsFor).length,P=n.filter(g=>g.cornersFor!==null),M=P.reduce((g,F)=>g+(F.cornersFor||0),0),I=P.reduce((g,F)=>g+(F.cornersAgainst||0),0);return{played:s,goalsForPerMatch:et(i,s),cleanSheets:R(a,s),wonToNil:R(c,s),scoringRate:R(d,s),scoredInBothHalves:R(T,y),scoredFirst:R(A,p),leadingAtHalfTime:R(_,y),goalsAgainstPerMatch:et(r,s),failedToScore:R(f,s),lostToNil:R(l,s),concedingRate:R(u,s),concededInBothHalves:R(C,y),concededFirst:R(O,p),losingAtHalfTime:R(S,y),avgCornersFor:et(M,P.length),avgCornersAgainst:et(I,P.length)}}function In(t,e){return t.filter(o=>o.status?.type!=="FINISHED"?!1:o.competitorOne.id===e||o.competitorTwo.id===e).map(o=>{const n=o.competitorOne.id===e,s=parseInt(o.score?.competitorOne||"0"),i=parseInt(o.score?.competitorTwo||"0"),r=s+i,a=o.periods;let c=null;if(a&&Array.isArray(a)){const d=a.find(f=>f.type==="FIRST_HALF"||f.type==="1ST_HALF");if(d?.score){const f=parseInt(d.score.competitorOne||"0"),l=parseInt(d.score.competitorTwo||"0");c=f+l}}return{totalGoals:r,halfTimeGoals:c,isHome:n}})}function v(t,e){return t.length===0?0:t.filter(n=>n>e).length/t.length*100}function Un(t,e){const o=In(t,e),n=o.filter(l=>l.isHome),s=o.filter(l=>!l.isHome),i=o.map(l=>l.totalGoals),r=n.map(l=>l.totalGoals),a=s.map(l=>l.totalGoals),c=o.filter(l=>l.halfTimeGoals!==null).map(l=>l.halfTimeGoals),d=n.filter(l=>l.halfTimeGoals!==null).map(l=>l.halfTimeGoals),f=s.filter(l=>l.halfTimeGoals!==null).map(l=>l.halfTimeGoals);return{over05:{home:v(r,.5),total:v(i,.5),away:v(a,.5)},over15:{home:v(r,1.5),total:v(i,1.5),away:v(a,1.5)},over25:{home:v(r,2.5),total:v(i,2.5),away:v(a,2.5)},over35:{home:v(r,3.5),total:v(i,3.5),away:v(a,3.5)},over45:{home:v(r,4.5),total:v(i,4.5),away:v(a,4.5)},over55:{home:v(r,5.5),total:v(i,5.5),away:v(a,5.5)},over05HT:{home:v(d,.5),total:v(c,.5),away:v(f,.5)},over15HT:{home:v(d,1.5),total:v(c,1.5),away:v(f,1.5)},over25HT:{home:v(d,2.5),total:v(c,2.5),away:v(f,2.5)}}}function wt(t,e){const o=t.competitorOne.id===e,n=t.competitorTwo.id===e;if(!o&&!n||!t.score)return null;const s=parseInt(o?t.score.competitorOne||"0":t.score.competitorTwo||"0"),i=parseInt(o?t.score.competitorTwo||"0":t.score.competitorOne||"0");let r;return s>i?r="W":s<i?r="L":r="D",{result:{score:`${s}:${i}`,result:r,isHome:o},isHome:o}}function Gn(t,e,o,n,s,i){const r=e?.entries.find(k=>k.competitor.id===t),a=o?.entries.find(k=>k.competitor.id===t),c=n?.entries.find(k=>k.competitor.id===t),d=s?.entries.find(k=>k.competitor.id===t),f=i?.entries.find(k=>k.competitor.id===t);if(!r)return null;const l=a?.stats?.goalsFor??0,u=c?.stats?.goalsFor??0,m=r?.stats?.goalsFor??0,y=d?.stats?.goalsAgainst??0,T=f?.stats?.goalsAgainst??0,A=r?.stats?.goalsAgainst??0,p=a?.stats?.played??0,_=c?.stats?.played??0,C=r?.stats?.played??0,O=C>0?m/C:0,S=C>0?A/C:0,P=O+S,M=p>0?l/p:0,I=_>0?u/_:0,g=p>0?y/p:0,F=_>0?T/_:0,Z=M+g,te=I+F;return{homeGoals:l,totalGoals:m,awayGoals:u,homeGamesPlayed:p,awayGamesPlayed:_,totalGamesPlayed:C,homeGoalsConceded:y,totalGoalsConceded:A,awayGoalsConceded:T,gfPerMatch:O,gaPerMatch:S,gfGaPerMatch:P,homeGfPerMatch:M,awayGfPerMatch:I,homeGaPerMatch:g,awayGaPerMatch:F,homeGfGaPerMatch:Z,awayGfGaPerMatch:te}}function b(t,e,o,n){const s=t.filter(r=>{const a=r.competitorOne.id===e,c=r.competitorTwo.id===e;return!(!a&&!c||r.status?.type!=="FINISHED"||n==="home"&&!a||n==="away"&&!c)}).sort((r,a)=>new Date(a.timing.kickoffTime).getTime()-new Date(r.timing.kickoffTime).getTime());if(s.length===0)return null;let i=0;for(const r of s){const a=r.competitorOne.id===e;if(o(r,e,a))i++;else break}return i>0?i:null}const E={win:(t,e,o)=>{const n=parseInt(o?t.score?.competitorOne||"0":t.score?.competitorTwo||"0"),s=parseInt(o?t.score?.competitorTwo||"0":t.score?.competitorOne||"0");return n>s},draw:t=>t.score?.competitorOne===t.score?.competitorTwo,loss:(t,e,o)=>{const n=parseInt(o?t.score?.competitorOne||"0":t.score?.competitorTwo||"0"),s=parseInt(o?t.score?.competitorTwo||"0":t.score?.competitorOne||"0");return n<s},noWin:(t,e,o)=>!E.win(t,e,o),noDraw:t=>!E.draw(t),noDefeat:(t,e,o)=>!E.loss(t,e,o),scored:(t,e,o)=>parseInt(o?t.score?.competitorOne||"0":t.score?.competitorTwo||"0")>=1,conceded:(t,e,o)=>parseInt(o?t.score?.competitorTwo||"0":t.score?.competitorOne||"0")>=1,noGoalScored:(t,e,o)=>!E.scored(t,e,o),noGoalConceded:(t,e,o)=>!E.conceded(t,e,o),over25:t=>parseInt(t.score?.competitorOne||"0")+parseInt(t.score?.competitorTwo||"0")>2,under25:t=>parseInt(t.score?.competitorOne||"0")+parseInt(t.score?.competitorTwo||"0")<3,scoredTwice:(t,e,o)=>parseInt(o?t.score?.competitorOne||"0":t.score?.competitorTwo||"0")>=2,concededTwice:(t,e,o)=>parseInt(o?t.score?.competitorTwo||"0":t.score?.competitorOne||"0")>=2};function ot(t,e,o){return{win:b(t,e,E.win,o),draw:b(t,e,E.draw,o),loss:b(t,e,E.loss,o),noWin:b(t,e,E.noWin,o),noDraw:b(t,e,E.noDraw,o),noDefeat:b(t,e,E.noDefeat,o),scored:b(t,e,E.scored,o),conceded:b(t,e,E.conceded,o),noGoalScored:b(t,e,E.noGoalScored,o),noGoalConceded:b(t,e,E.noGoalConceded,o),over25:b(t,e,E.over25,o),under25:b(t,e,E.under25,o),scoredTwice:b(t,e,E.scoredTwice,o),concededTwice:b(t,e,E.concededTwice,o)}}function Dn(t,e,o){const n=ot(t,e,"home"),s=ot(t,e),i=ot(t,o,"away"),r=ot(t,o);return[{label:"Consecutive wins",homeTeam:{home:n.win,total:s.win},awayTeam:{total:r.win,home:i.win},colorType:"neutral"},{label:"Consecutive draws",homeTeam:{home:n.draw,total:s.draw},awayTeam:{total:r.draw,home:i.draw},colorType:"neutral"},{label:"Consecutive defeats",homeTeam:{home:n.loss,total:s.loss},awayTeam:{total:r.loss,home:i.loss},colorType:"neutral"},{label:"No win",homeTeam:{home:n.noWin,total:s.noWin},awayTeam:{total:r.noWin,home:i.noWin},colorType:"negative"},{label:"No draw",homeTeam:{home:n.noDraw,total:s.noDraw},awayTeam:{total:r.noDraw,home:i.noDraw},colorType:"neutral"},{label:"No defeat",homeTeam:{home:n.noDefeat,total:s.noDefeat},awayTeam:{total:r.noDefeat,home:i.noDefeat},colorType:"positive"},{label:"Scored at least once",homeTeam:{home:n.scored,total:s.scored},awayTeam:{total:r.scored,home:i.scored},colorType:"positive"},{label:"Conceded at least once",homeTeam:{home:n.conceded,total:s.conceded},awayTeam:{total:r.conceded,home:i.conceded},colorType:"negative"},{label:"No goal scored",homeTeam:{home:n.noGoalScored,total:s.noGoalScored},awayTeam:{total:r.noGoalScored,home:i.noGoalScored},colorType:"neutral"},{label:"No goal conceded",homeTeam:{home:n.noGoalConceded,total:s.noGoalConceded},awayTeam:{total:r.noGoalConceded,home:i.noGoalConceded},colorType:"neutral"},{label:"GS + GC over 2.5",homeTeam:{home:n.over25,total:s.over25},awayTeam:{total:r.over25,home:i.over25},colorType:"neutral"},{label:"GS + GC under 2.5",homeTeam:{home:n.under25,total:s.under25},awayTeam:{total:r.under25,home:i.under25},colorType:"neutral"},{label:"Scored at least twice",homeTeam:{home:n.scoredTwice,total:s.scoredTwice},awayTeam:{total:r.scoredTwice,home:i.scoredTwice},colorType:"positive"},{label:"Conceded at least twice",homeTeam:{home:n.concededTwice,total:s.concededTwice},awayTeam:{total:r.concededTwice,home:i.concededTwice},colorType:"negative"}]}function bt(t,e){const o=new Map;return t.forEach(n=>{if(n.status?.type!=="FINISHED")return;const s=wt(n,e);if(!s)return;const i=s.isHome?n.competitorTwo.id:n.competitorOne.id,r=s.isHome?n.competitorTwo:n.competitorOne,a=o.get(i)||{opponentId:i,opponentName:r.name,opponentLogo:r.assets?.logo};s.isHome?a.homeResult=s.result:a.awayResult=s.result,o.set(i,a)}),o}function xn(t,e,o,n,s,i,r){const a=bt(t,e),c=bt(t,o),d=new Set([...a.keys(),...c.keys(),e,o]),f=[];return d.forEach(l=>{const u=a.get(l),m=c.get(l);if(!u&&!m&&l!==e&&l!==o)return;let y,T;l===e?(y=n,T=i):l===o?(y=s,T=r):(y=u?.opponentName||m?.opponentName||"",T=u?.opponentLogo||m?.opponentLogo),f.push({opponentId:l,opponentName:y,opponentLogo:T,homeTeamHome:u?.homeResult,homeTeamAway:u?.awayResult,awayTeamHome:m?.homeResult,awayTeamAway:m?.awayResult,isHomeTeamRow:l===e,isAwayTeamRow:l===o})}),f.sort((l,u)=>l.isHomeTeamRow?-1:u.isHomeTeamRow?1:l.isAwayTeamRow?-1:u.isAwayTeamRow?1:l.opponentName.localeCompare(u.opponentName))}exports.addProviderRef=h.addProviderRef;exports.getBatchMatchOdds=h.getBatchMatchOdds;exports.getConfig=h.getConfig;exports.getFootballCompetition=h.getFootballCompetition;exports.getFootballLivescore=h.getFootballLivescore;exports.getFootballMatch=h.getFootballMatch;exports.getFootballMatchCommentary=h.getFootballMatchCommentary;exports.getFootballMatchEvents=h.getFootballMatchEvents;exports.getFootballMatchLineups=h.getFootballMatchLineups;exports.getFootballMatchOdds=h.getFootballMatchOdds;exports.getFootballMatchStatistics=h.getFootballMatchStatistics;exports.getFootballMatches=h.getFootballMatches;exports.getFootballPlayerSeasonStatistics=h.getFootballPlayerSeasonStatistics;exports.getFootballSeasonDetails=h.getFootballSeasonDetails;exports.getFootballStandings=h.getFootballStandings;exports.getFootballTeam=h.getFootballTeam;exports.getFootballTeamSquad=h.getFootballTeamSquad;exports.getLeaderboardMatches=h.getLeaderboardMatches;exports.getLeaderboardTeamMatches=h.getLeaderboardTeamMatches;exports.getLeaderboardTemplate=h.getLeaderboardTemplate;exports.getProviderRefId=h.getProviderRefId;exports.isConfigured=h.isConfigured;exports.setConfig=h.setConfig;exports.toProviderRefArray=h.toProviderRefArray;exports.GOAL_EVENT_TYPES=Xt;exports.aggregatePlayerStatisticsFromMatches=Q;exports.analyzeMatch=Jt;exports.cached=z;exports.cachedBatch=kt;exports.calcAverage=et;exports.calcPercentage=R;exports.calculateH2HStats=bn;exports.calculateStreak=b;exports.formatAsAverage=An;exports.formatPossessionPercentage=Cn;exports.formatStatValue=vn;exports.formatWithAverage=Sn;exports.getActiveSeason=en;exports.getAllPlayerStatisticsFromMatches=Qt;exports.getBasketballLivescore=ye;exports.getFansUnitedCompetitions=Xo;exports.getFansUnitedCountries=wo;exports.getFansUnitedEntitiesByIds=Ko;exports.getFansUnitedEntityById=Qo;exports.getFansUnitedFootballCompetition=ro;exports.getFansUnitedFootballCompetitions=oo;exports.getFansUnitedFootballMatch=_o;exports.getFansUnitedFootballMatches=vo;exports.getFansUnitedFootballPlayer=yo;exports.getFansUnitedFootballPlayerNextMatch=Co;exports.getFansUnitedFootballPlayerPreviousMatch=Oo;exports.getFansUnitedFootballPlayers=To;exports.getFansUnitedFootballSearch=bo;exports.getFansUnitedFootballTeam=uo;exports.getFansUnitedFootballTeamNextMatch=So;exports.getFansUnitedFootballTeamPreviousMatch=Ao;exports.getFansUnitedFootballTeams=fo;exports.getFansUnitedSearchEntities=Vo;exports.getFansUnitedTeamsByCompetition=Zo;exports.getFansUnitedTeamsByCountry=Jo;exports.getFansUnitedVenues=tn;exports.getMatchResult=wt;exports.getMostCardedPlayersFromMatches=qt;exports.getOpponentScore=Ln;exports.getRecentH2HMeetings=Rn;exports.getSportal365Standings=Qe;exports.getTeamFinishedMatches=rn;exports.getTeamGoalStats=Gn;exports.getTeamHomeAwayStats=Mn;exports.getTeamMostDecorated=hn;exports.getTeamNextMatch=on;exports.getTeamOverUnderStats=Un;exports.getTeamPreviousMatch=nn;exports.getTeamResultsTable=an;exports.getTeamScore=En;exports.getTeamSeasonStatistics=Je;exports.getTeamStreaks=ot;exports.getTeamStreaksComparison=Dn;exports.getTeamTopAppearances=dn;exports.getTeamTopAssisters=ln;exports.getTeamTopCleanSheets=fn;exports.getTeamTopMinutesPlayed=un;exports.getTeamTopScorers=cn;exports.getTeamUpcomingMatches=sn;exports.getTeamsCommonOpponents=xn;exports.getTennisLivescore=Fe;exports.getTopAssistersFromMatches=jt;exports.getTopGoalContributorsFromMatches=Vt;exports.getTopScorersFromMatches=Yt;exports.initL2=Go;exports.invalidate=xo;exports.isMatchFinished=Fn;exports.isTeamAway=Zt;exports.isTeamHome=ht;exports.isTeamInMatch=On;exports.search=De;exports.searchFootball=ce;exports.streakFilters=E;exports.useAllPlayerStatisticsFromMatches=Tn;exports.useMostCardedPlayersFromMatches=pn;exports.usePlayerStatistics=_n;exports.usePlayerStatisticsMap=Kt;exports.useTopAssistersFromMatches=gn;exports.useTopGoalContributorsFromMatches=yn;exports.useTopScorersFromMatches=mn;
|