fansunited-sdk-esm 1.34.1 → 1.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +3 -3
- package/index.js.map +2 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var ss=Object.create;var so=Object.defineProperty;var ns=Object.getOwnPropertyDescriptor;var ls=Object.getOwnPropertyNames;var ps=Object.getPrototypeOf,cs=Object.prototype.hasOwnProperty;var ms=a=>so(a,"__esModule",{value:!0});var f=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports);var ds=(a,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ls(e))!cs.call(a,r)&&(t||r!=="default")&&so(a,r,{get:()=>e[r],enumerable:!(i=ns(e,r))||i.enumerable});return a},us=(a,e)=>ds(ms(so(a!=null?ss(ps(a)):{},"default",!e&&a&&a.__esModule?{get:()=>a.default,enumerable:!0}:{value:a,enumerable:!0})),a);var lo=f((Ln,Go)=>{"use strict";Go.exports=function(e,t){return function(){for(var r=new Array(arguments.length),o=0;o<r.length;o++)r[o]=arguments[o];return e.apply(t,r)}}});var _=f((Bn,qo)=>{"use strict";var hs=lo(),me=Object.prototype.toString;function po(a){return me.call(a)==="[object Array]"}function co(a){return typeof a=="undefined"}function fs(a){return a!==null&&!co(a)&&a.constructor!==null&&!co(a.constructor)&&typeof a.constructor.isBuffer=="function"&&a.constructor.isBuffer(a)}function gs(a){return me.call(a)==="[object ArrayBuffer]"}function ys(a){return typeof FormData!="undefined"&&a instanceof FormData}function Ms(a){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(a):e=a&&a.buffer&&a.buffer instanceof ArrayBuffer,e}function bs(a){return typeof a=="string"}function ws(a){return typeof a=="number"}function Vo(a){return a!==null&&typeof a=="object"}function Ct(a){if(me.call(a)!=="[object Object]")return!1;var e=Object.getPrototypeOf(a);return e===null||e===Object.prototype}function Is(a){return me.call(a)==="[object Date]"}function Fs(a){return me.call(a)==="[object File]"}function Ps(a){return me.call(a)==="[object Blob]"}function $o(a){return me.call(a)==="[object Function]"}function Es(a){return Vo(a)&&$o(a.pipe)}function Rs(a){return typeof URLSearchParams!="undefined"&&a instanceof URLSearchParams}function Ts(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function
|
|
2
|
-
`),function(l){if(o=l.indexOf(":"),i=yo.trim(l.substr(0,o)).toLowerCase(),r=yo.trim(l.substr(o+1)),i){if(t[i]&&Bs.indexOf(i)>=0)return;i==="set-cookie"?t[i]=(t[i]?t[i]:[]).concat([r]):t[i]=t[i]?t[i]+", "+r:r}}),t}});var ua=f((Kn,da)=>{"use strict";var ma=_();da.exports=ma.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a"),i;function r(o){var s=o;return e&&(t.setAttribute("href",s),s=t.href),t.setAttribute("href",s),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return i=r(window.location.href),function(s){var l=ma.isString(s)?r(s):s;return l.protocol===i.protocol&&l.host===i.host}}():function(){return function(){return!0}}()});var ct=f((Yn,ha)=>{"use strict";function Mo(a){this.message=a}Mo.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};Mo.prototype.__CANCEL__=!0;ha.exports=Mo});var wo=f((Qn,fa)=>{"use strict";var Ot=_(),Ns=ea(),Us=ia(),Hs=ho(),ks=la(),Gs=ca(),Vs=ua(),bo=go(),$s=mt(),qs=ct();fa.exports=function(e){return new Promise(function(i,r){var o=e.data,s=e.headers,l=e.responseType,n;function c(){e.cancelToken&&e.cancelToken.unsubscribe(n),e.signal&&e.signal.removeEventListener("abort",n)}Ot.isFormData(o)&&delete s["Content-Type"];var p=new XMLHttpRequest;if(e.auth){var m=e.auth.username||"",d=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";s.Authorization="Basic "+btoa(m+":"+d)}var J=ks(e.baseURL,e.url);p.open(e.method.toUpperCase(),Hs(J,e.params,e.paramsSerializer),!0),p.timeout=e.timeout;function Uo(){if(!!p){var G="getAllResponseHeaders"in p?Gs(p.getAllResponseHeaders()):null,ye=!l||l==="text"||l==="json"?p.responseText:p.response,ce={data:ye,status:p.status,statusText:p.statusText,headers:G,config:e,request:p};Ns(function(ao){i(ao),c()},function(ao){r(ao),c()},ce),p=null}}if("onloadend"in p?p.onloadend=Uo:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(Uo)},p.onabort=function(){!p||(r(bo("Request aborted",e,"ECONNABORTED",p)),p=null)},p.onerror=function(){r(bo("Network Error",e,null,p)),p=null},p.ontimeout=function(){var ye=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",ce=e.transitional||$s.transitional;e.timeoutErrorMessage&&(ye=e.timeoutErrorMessage),r(bo(ye,e,ce.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",p)),p=null},Ot.isStandardBrowserEnv()){var Ho=(e.withCredentials||Vs(J))&&e.xsrfCookieName?Us.read(e.xsrfCookieName):void 0;Ho&&(s[e.xsrfHeaderName]=Ho)}"setRequestHeader"in p&&Ot.forEach(s,function(ye,ce){typeof o=="undefined"&&ce.toLowerCase()==="content-type"?delete s[ce]:p.setRequestHeader(ce,ye)}),Ot.isUndefined(e.withCredentials)||(p.withCredentials=!!e.withCredentials),l&&l!=="json"&&(p.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&p.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&p.upload&&p.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(n=function(G){!p||(r(!G||G&&G.type?new qs("canceled"):G),p.abort(),p=null)},e.cancelToken&&e.cancelToken.subscribe(n),e.signal&&(e.signal.aborted?n():e.signal.addEventListener("abort",n))),o||(o=null),p.send(o)})}});var mt=f((zn,Ma)=>{"use strict";var P=_(),ga=Qo(),js=fo(),Xs={"Content-Type":"application/x-www-form-urlencoded"};function ya(a,e){!P.isUndefined(a)&&P.isUndefined(a["Content-Type"])&&(a["Content-Type"]=e)}function Ws(){var a;return typeof XMLHttpRequest!="undefined"?a=wo():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(a=wo()),a}function Ks(a,e,t){if(P.isString(a))try{return(e||JSON.parse)(a),P.trim(a)}catch(i){if(i.name!=="SyntaxError")throw i}return(t||JSON.stringify)(a)}var Dt={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:Ws(),transformRequest:[function(e,t){return ga(t,"Accept"),ga(t,"Content-Type"),P.isFormData(e)||P.isArrayBuffer(e)||P.isBuffer(e)||P.isStream(e)||P.isFile(e)||P.isBlob(e)?e:P.isArrayBufferView(e)?e.buffer:P.isURLSearchParams(e)?(ya(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):P.isObject(e)||t&&t["Content-Type"]==="application/json"?(ya(t,"application/json"),Ks(e)):e}],transformResponse:[function(e){var t=this.transitional||Dt.transitional,i=t&&t.silentJSONParsing,r=t&&t.forcedJSONParsing,o=!i&&this.responseType==="json";if(o||r&&P.isString(e)&&e.length)try{return JSON.parse(e)}catch(s){if(o)throw s.name==="SyntaxError"?js(s,this,"E_JSON_PARSE"):s}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};P.forEach(["delete","get","head"],function(e){Dt.headers[e]={}});P.forEach(["post","put","patch"],function(e){Dt.headers[e]=P.merge(Xs)});Ma.exports=Dt});var wa=f((Jn,ba)=>{"use strict";var Ys=_(),Qs=mt();ba.exports=function(e,t,i){var r=this||Qs;return Ys.forEach(i,function(s){e=s.call(r,e,t)}),e}});var Io=f((Zn,Ia)=>{"use strict";Ia.exports=function(e){return!!(e&&e.__CANCEL__)}});var Ea=f((el,Pa)=>{"use strict";var Fa=_(),Fo=wa(),zs=Io(),Js=mt(),Zs=ct();function Po(a){if(a.cancelToken&&a.cancelToken.throwIfRequested(),a.signal&&a.signal.aborted)throw new Zs("canceled")}Pa.exports=function(e){Po(e),e.headers=e.headers||{},e.data=Fo.call(e,e.data,e.headers,e.transformRequest),e.headers=Fa.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Fa.forEach(["delete","get","head","post","put","patch","common"],function(r){delete e.headers[r]});var t=e.adapter||Js.adapter;return t(e).then(function(r){return Po(e),r.data=Fo.call(e,r.data,r.headers,e.transformResponse),r},function(r){return zs(r)||(Po(e),r&&r.response&&(r.response.data=Fo.call(e,r.response.data,r.response.headers,e.transformResponse))),Promise.reject(r)})}});var Eo=f((tl,Ra)=>{"use strict";var x=_();Ra.exports=function(e,t){t=t||{};var i={};function r(p,m){return x.isPlainObject(p)&&x.isPlainObject(m)?x.merge(p,m):x.isPlainObject(m)?x.merge({},m):x.isArray(m)?m.slice():m}function o(p){if(x.isUndefined(t[p])){if(!x.isUndefined(e[p]))return r(void 0,e[p])}else return r(e[p],t[p])}function s(p){if(!x.isUndefined(t[p]))return r(void 0,t[p])}function l(p){if(x.isUndefined(t[p])){if(!x.isUndefined(e[p]))return r(void 0,e[p])}else return r(void 0,t[p])}function n(p){if(p in t)return r(e[p],t[p]);if(p in e)return r(void 0,e[p])}var c={url:s,method:s,data:s,baseURL:l,transformRequest:l,transformResponse:l,paramsSerializer:l,timeout:l,timeoutMessage:l,withCredentials:l,adapter:l,responseType:l,xsrfCookieName:l,xsrfHeaderName:l,onUploadProgress:l,onDownloadProgress:l,decompress:l,maxContentLength:l,maxBodyLength:l,transport:l,httpAgent:l,httpsAgent:l,cancelToken:l,socketPath:l,responseEncoding:l,validateStatus:n};return x.forEach(Object.keys(e).concat(Object.keys(t)),function(m){var d=c[m]||o,J=d(m);x.isUndefined(J)&&d!==n||(i[m]=J)}),i}});var Ro=f((il,Ta)=>{Ta.exports={version:"0.24.0"}});var _a=f((rl,va)=>{"use strict";var en=Ro().version,To={};["object","boolean","number","function","string","symbol"].forEach(function(a,e){To[a]=function(i){return typeof i===a||"a"+(e<1?"n ":" ")+a}});var Sa={};To.transitional=function(e,t,i){function r(o,s){return"[Axios v"+en+"] Transitional option '"+o+"'"+s+(i?". "+i:"")}return function(o,s,l){if(e===!1)throw new Error(r(s," has been removed"+(t?" in "+t:"")));return t&&!Sa[s]&&(Sa[s]=!0,console.warn(r(s," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(o,s,l):!0}};function tn(a,e,t){if(typeof a!="object")throw new TypeError("options must be an object");for(var i=Object.keys(a),r=i.length;r-- >0;){var o=i[r],s=e[o];if(s){var l=a[o],n=l===void 0||s(l,o,a);if(n!==!0)throw new TypeError("option "+o+" must be "+n);continue}if(t!==!0)throw Error("Unknown option "+o)}}va.exports={assertOptions:tn,validators:To}});var La=f((ol,Da)=>{"use strict";var Ca=_(),rn=ho(),Aa=Ko(),xa=Ea(),Lt=Eo(),Oa=_a(),Ie=Oa.validators;function dt(a){this.defaults=a,this.interceptors={request:new Aa,response:new Aa}}dt.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=Lt(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;t!==void 0&&Oa.assertOptions(t,{silentJSONParsing:Ie.transitional(Ie.boolean),forcedJSONParsing:Ie.transitional(Ie.boolean),clarifyTimeoutError:Ie.transitional(Ie.boolean)},!1);var i=[],r=!0;this.interceptors.request.forEach(function(d){typeof d.runWhen=="function"&&d.runWhen(e)===!1||(r=r&&d.synchronous,i.unshift(d.fulfilled,d.rejected))});var o=[];this.interceptors.response.forEach(function(d){o.push(d.fulfilled,d.rejected)});var s;if(!r){var l=[xa,void 0];for(Array.prototype.unshift.apply(l,i),l=l.concat(o),s=Promise.resolve(e);l.length;)s=s.then(l.shift(),l.shift());return s}for(var n=e;i.length;){var c=i.shift(),p=i.shift();try{n=c(n)}catch(m){p(m);break}}try{s=xa(n)}catch(m){return Promise.reject(m)}for(;o.length;)s=s.then(o.shift(),o.shift());return s};dt.prototype.getUri=function(e){return e=Lt(this.defaults,e),rn(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};Ca.forEach(["delete","get","head","options"],function(e){dt.prototype[e]=function(t,i){return this.request(Lt(i||{},{method:e,url:t,data:(i||{}).data}))}});Ca.forEach(["post","put","patch"],function(e){dt.prototype[e]=function(t,i,r){return this.request(Lt(r||{},{method:e,url:t,data:i}))}});Da.exports=dt});var Na=f((al,Ba)=>{"use strict";var on=ct();function Fe(a){if(typeof a!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(r){e=r});var t=this;this.promise.then(function(i){if(!!t._listeners){var r,o=t._listeners.length;for(r=0;r<o;r++)t._listeners[r](i);t._listeners=null}}),this.promise.then=function(i){var r,o=new Promise(function(s){t.subscribe(s),r=s}).then(i);return o.cancel=function(){t.unsubscribe(r)},o},a(function(r){t.reason||(t.reason=new on(r),e(t.reason))})}Fe.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};Fe.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};Fe.prototype.unsubscribe=function(e){if(!!this._listeners){var t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}};Fe.source=function(){var e,t=new Fe(function(r){e=r});return{token:t,cancel:e}};Ba.exports=Fe});var Ha=f((sl,Ua)=>{"use strict";Ua.exports=function(e){return function(i){return e.apply(null,i)}}});var Ga=f((nl,ka)=>{"use strict";ka.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var qa=f((ll,So)=>{"use strict";var Va=_(),an=lo(),Bt=La(),sn=Eo(),nn=mt();function $a(a){var e=new Bt(a),t=an(Bt.prototype.request,e);return Va.extend(t,Bt.prototype,e),Va.extend(t,e),t.create=function(r){return $a(sn(a,r))},t}var $=$a(nn);$.Axios=Bt;$.Cancel=ct();$.CancelToken=Na();$.isCancel=Io();$.VERSION=Ro().version;$.all=function(e){return Promise.all(e)};$.spread=Ha();$.isAxiosError=Ga();So.exports=$;So.exports.default=$});var Xa=f((pl,ja)=>{ja.exports=qa()});var no=a=>{let e=200,t=[],i=0;return t[i]=[],a.forEach(r=>{t[i].length<=e-1?t[i].push(r):(i++,t[i]=[r])}),t},Me=(a,e)=>{let t=[];for(;a.length>e;){let i=a.splice(0,e);t.push(i)}return t.push(a),t},v=(a,e)=>{let t="",i={profile:"https://profile.fansunitedapi.com/v1",football:"https://football.fansunitedapi.com/v1",idMapping:"https://id-mapping.fansunitedapi.com/v1",predictor:"https://prediction.fansunitedapi.com/v1",client:"https://client.fansunitedapi.com/v1",loyalty:"https://loyalty.fansunitedapi.com/v1"},r={profile:"http://localhost:8010/v1",football:"http://localhost:8080/v1",idMapping:"http://localhost:8030/v1",predictor:"http://localhost:8040/v1",client:"http://localhost:8070/v1",loyalty:"http://localhost:8060/v1"},o={profile:"https://profile.fansunitedstagingapi.com/v1",football:"https://football.fansunitedstagingapi.com/v1",idMapping:"https://id-mapping.fansunitedstagingapi.com/v1",predictor:"https://prediction.fansunitedstagingapi.com/v1",client:"https://client.fansunitedstagingapi.com/v1",loyalty:"https://loyalty.fansunitedstagingapi.com/v1"};return a==="prod"?t=i[e]:a==="dev"?t=r[e]:t=o[e],t},te=a=>a.filter((t,i,r)=>i===r.indexOf(t)),I=a=>a||!1,F=()=>`&disable_cache=${Date.now()}`,Ft=a=>JSON.parse(JSON.stringify(a.sort((e,t)=>e.localeCompare(t))));var Pt=class{id=null;name=null;nickname=null;avatar=null;gender=null;country=null;birthDate=null;interests=[];followingCount=0;followersCount=0};var Et=class{profilesFromResponse=e=>e?e.map(t=>this.fullProfileFromResponse(t)):null;fullProfileFromResponse=e=>{let t=new Pt;return t.id=e.id,t.name=e.name,t.nickname=e.nickname,t.avatar=e.avatar,t.gender=e.gender,t.country=e.country,t.birthDate=e.birth_date,t.interests=e.interests?e.interests:[],t.followingCount=e.following_count,t.followersCount=e.followers_count,t}};var Rt=class{nextPageStartsAfter=null;itemsPerPage=null};var be=class{pagination=new Rt};var M=class{meta=new be;data=[]};var Tt=class{avatar=null;followingId=null;name=null;nickname=null;profileId=null};var St=class{followResponse=e=>e.map(t=>this.remapResponse(t));followingFromResponse=e=>{let t=new M;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(i=>this.remapResponse(i)),t};remapResponse=e=>{let t=new Tt;return t.avatar=e.avatar,t.followingId=e.following_id,t.name=e.name,t.profileId=e.profile_id,t.nickname=e.nickname,t}};var vt=class{avatar=null;followerId=null;name=null;nickname=null;profileId=null};var _t=class{followersFromResponse=e=>{let t=new M;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(i=>this.remapResponse(i)),t};remapResponse=e=>{let t=new vt;return t.avatar=e.avatar,t.followerId=e.follower_id,t.name=e.name,t.profileId=e.profile_id,t}};var pt=class{profile_ids=[]};var Ht=us(Xa());function vo(a){this.message=a}vo.prototype=new Error,vo.prototype.name="InvalidCharacterError";var Wa=typeof window!="undefined"&&window.atob&&window.atob.bind(window)||function(a){var e=String(a).replace(/=+$/,"");if(e.length%4==1)throw new vo("'atob' failed: The string to be decoded is not correctly encoded.");for(var t,i,r=0,o=0,s="";i=e.charAt(o++);~i&&(t=r%4?64*t+i:i,r++%4)?s+=String.fromCharCode(255&t>>(-2*r&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return s};function ln(a){var e=a.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Wa(t).replace(/(.)/g,function(i,r){var o=r.charCodeAt(0).toString(16).toUpperCase();return o.length<2&&(o="0"+o),"%"+o}))}(e)}catch{return Wa(e)}}function Nt(a){this.message=a}function pn(a,e){if(typeof a!="string")throw new Nt("Invalid token specified");var t=(e=e||{}).header===!0?0:1;try{return JSON.parse(ln(a.split(".")[t]))}catch(i){throw new Nt("Invalid token specified: "+i.message)}}Nt.prototype=new Error,Nt.prototype.name="InvalidTokenError";var Ka=pn;var h=class{response={error:{code:0,status:"",message:""}};constructor(e,t,i){this.response.error.code=e,this.response.error.status=t,this.response.error.message=i}};var Ya=(a,e,t)=>{let i={data:a.data,status:e,statusText:t,headers:a.headers,config:a};return{code:String(e),config:a,isAxiosError:!0,toJSON:()=>({}),name:"Unauthorized",message:t,response:i}};var D={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id"},_o={PREDICTOR_USER_RELATED_OPERATION:"https://docs.fansunitedmedia.com/docs/predictor-operations#user-related-operations"},Co=["matchId","matchType","market","prediction"];var Ao={UNEXPECTED_STATUS_PROP:`Unexpected provided property 'status'. You can NOT use this property for this method. For more information visit our documentation:
|
|
1
|
+
var ss=Object.create;var so=Object.defineProperty;var ns=Object.getOwnPropertyDescriptor;var ls=Object.getOwnPropertyNames;var ps=Object.getPrototypeOf,cs=Object.prototype.hasOwnProperty;var ms=a=>so(a,"__esModule",{value:!0});var f=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports);var ds=(a,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ls(e))!cs.call(a,r)&&(t||r!=="default")&&so(a,r,{get:()=>e[r],enumerable:!(i=ns(e,r))||i.enumerable});return a},us=(a,e)=>ds(ms(so(a!=null?ss(ps(a)):{},"default",!e&&a&&a.__esModule?{get:()=>a.default,enumerable:!0}:{value:a,enumerable:!0})),a);var lo=f((Ln,Go)=>{"use strict";Go.exports=function(e,t){return function(){for(var r=new Array(arguments.length),o=0;o<r.length;o++)r[o]=arguments[o];return e.apply(t,r)}}});var _=f((Bn,qo)=>{"use strict";var hs=lo(),me=Object.prototype.toString;function po(a){return me.call(a)==="[object Array]"}function co(a){return typeof a=="undefined"}function fs(a){return a!==null&&!co(a)&&a.constructor!==null&&!co(a.constructor)&&typeof a.constructor.isBuffer=="function"&&a.constructor.isBuffer(a)}function gs(a){return me.call(a)==="[object ArrayBuffer]"}function ys(a){return typeof FormData!="undefined"&&a instanceof FormData}function Ms(a){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(a):e=a&&a.buffer&&a.buffer instanceof ArrayBuffer,e}function bs(a){return typeof a=="string"}function ws(a){return typeof a=="number"}function Vo(a){return a!==null&&typeof a=="object"}function Ct(a){if(me.call(a)!=="[object Object]")return!1;var e=Object.getPrototypeOf(a);return e===null||e===Object.prototype}function Is(a){return me.call(a)==="[object Date]"}function Fs(a){return me.call(a)==="[object File]"}function Ps(a){return me.call(a)==="[object Blob]"}function $o(a){return me.call(a)==="[object Function]"}function Es(a){return Vo(a)&&$o(a.pipe)}function Rs(a){return typeof URLSearchParams!="undefined"&&a instanceof URLSearchParams}function Ts(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function vs(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function mo(a,e){if(!(a===null||typeof a=="undefined"))if(typeof a!="object"&&(a=[a]),po(a))for(var t=0,i=a.length;t<i;t++)e.call(null,a[t],t,a);else for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&e.call(null,a[r],r,a)}function uo(){var a={};function e(r,o){Ct(a[o])&&Ct(r)?a[o]=uo(a[o],r):Ct(r)?a[o]=uo({},r):po(r)?a[o]=r.slice():a[o]=r}for(var t=0,i=arguments.length;t<i;t++)mo(arguments[t],e);return a}function Ss(a,e,t){return mo(e,function(r,o){t&&typeof r=="function"?a[o]=hs(r,t):a[o]=r}),a}function _s(a){return a.charCodeAt(0)===65279&&(a=a.slice(1)),a}qo.exports={isArray:po,isArrayBuffer:gs,isBuffer:fs,isFormData:ys,isArrayBufferView:Ms,isString:bs,isNumber:ws,isObject:Vo,isPlainObject:Ct,isUndefined:co,isDate:Is,isFile:Fs,isBlob:Ps,isFunction:$o,isStream:Es,isURLSearchParams:Rs,isStandardBrowserEnv:vs,forEach:mo,merge:uo,extend:Ss,trim:Ts,stripBOM:_s}});var ho=f((Nn,Xo)=>{"use strict";var we=_();function jo(a){return encodeURIComponent(a).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}Xo.exports=function(e,t,i){if(!t)return e;var r;if(i)r=i(t);else if(we.isURLSearchParams(t))r=t.toString();else{var o=[];we.forEach(t,function(n,c){n===null||typeof n=="undefined"||(we.isArray(n)?c=c+"[]":n=[n],we.forEach(n,function(m){we.isDate(m)?m=m.toISOString():we.isObject(m)&&(m=JSON.stringify(m)),o.push(jo(c)+"="+jo(m))}))}),r=o.join("&")}if(r){var s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+r}return e}});var Ko=f((Un,Wo)=>{"use strict";var Cs=_();function At(){this.handlers=[]}At.prototype.use=function(e,t,i){return this.handlers.push({fulfilled:e,rejected:t,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1};At.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};At.prototype.forEach=function(e){Cs.forEach(this.handlers,function(i){i!==null&&e(i)})};Wo.exports=At});var Qo=f((Hn,Yo)=>{"use strict";var As=_();Yo.exports=function(e,t){As.forEach(e,function(r,o){o!==t&&o.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[o])})}});var fo=f((kn,zo)=>{"use strict";zo.exports=function(e,t,i,r,o){return e.config=t,i&&(e.code=i),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e}});var go=f((Gn,Jo)=>{"use strict";var xs=fo();Jo.exports=function(e,t,i,r,o){var s=new Error(e);return xs(s,t,i,r,o)}});var ea=f((Vn,Zo)=>{"use strict";var Os=go();Zo.exports=function(e,t,i){var r=i.config.validateStatus;!i.status||!r||r(i.status)?e(i):t(Os("Request failed with status code "+i.status,i.config,null,i.request,i))}});var ia=f(($n,ta)=>{"use strict";var xt=_();ta.exports=xt.isStandardBrowserEnv()?function(){return{write:function(t,i,r,o,s,l){var n=[];n.push(t+"="+encodeURIComponent(i)),xt.isNumber(r)&&n.push("expires="+new Date(r).toGMTString()),xt.isString(o)&&n.push("path="+o),xt.isString(s)&&n.push("domain="+s),l===!0&&n.push("secure"),document.cookie=n.join("; ")},read:function(t){var i=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return i?decodeURIComponent(i[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()});var oa=f((qn,ra)=>{"use strict";ra.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}});var sa=f((jn,aa)=>{"use strict";aa.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}});var la=f((Xn,na)=>{"use strict";var Ds=oa(),Ls=sa();na.exports=function(e,t){return e&&!Ds(t)?Ls(e,t):t}});var ca=f((Wn,pa)=>{"use strict";var yo=_(),Bs=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];pa.exports=function(e){var t={},i,r,o;return e&&yo.forEach(e.split(`
|
|
2
|
+
`),function(l){if(o=l.indexOf(":"),i=yo.trim(l.substr(0,o)).toLowerCase(),r=yo.trim(l.substr(o+1)),i){if(t[i]&&Bs.indexOf(i)>=0)return;i==="set-cookie"?t[i]=(t[i]?t[i]:[]).concat([r]):t[i]=t[i]?t[i]+", "+r:r}}),t}});var ua=f((Kn,da)=>{"use strict";var ma=_();da.exports=ma.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a"),i;function r(o){var s=o;return e&&(t.setAttribute("href",s),s=t.href),t.setAttribute("href",s),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return i=r(window.location.href),function(s){var l=ma.isString(s)?r(s):s;return l.protocol===i.protocol&&l.host===i.host}}():function(){return function(){return!0}}()});var ct=f((Yn,ha)=>{"use strict";function Mo(a){this.message=a}Mo.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};Mo.prototype.__CANCEL__=!0;ha.exports=Mo});var wo=f((Qn,fa)=>{"use strict";var Ot=_(),Ns=ea(),Us=ia(),Hs=ho(),ks=la(),Gs=ca(),Vs=ua(),bo=go(),$s=mt(),qs=ct();fa.exports=function(e){return new Promise(function(i,r){var o=e.data,s=e.headers,l=e.responseType,n;function c(){e.cancelToken&&e.cancelToken.unsubscribe(n),e.signal&&e.signal.removeEventListener("abort",n)}Ot.isFormData(o)&&delete s["Content-Type"];var p=new XMLHttpRequest;if(e.auth){var m=e.auth.username||"",d=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";s.Authorization="Basic "+btoa(m+":"+d)}var J=ks(e.baseURL,e.url);p.open(e.method.toUpperCase(),Hs(J,e.params,e.paramsSerializer),!0),p.timeout=e.timeout;function Uo(){if(!!p){var G="getAllResponseHeaders"in p?Gs(p.getAllResponseHeaders()):null,ye=!l||l==="text"||l==="json"?p.responseText:p.response,ce={data:ye,status:p.status,statusText:p.statusText,headers:G,config:e,request:p};Ns(function(ao){i(ao),c()},function(ao){r(ao),c()},ce),p=null}}if("onloadend"in p?p.onloadend=Uo:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(Uo)},p.onabort=function(){!p||(r(bo("Request aborted",e,"ECONNABORTED",p)),p=null)},p.onerror=function(){r(bo("Network Error",e,null,p)),p=null},p.ontimeout=function(){var ye=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",ce=e.transitional||$s.transitional;e.timeoutErrorMessage&&(ye=e.timeoutErrorMessage),r(bo(ye,e,ce.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",p)),p=null},Ot.isStandardBrowserEnv()){var Ho=(e.withCredentials||Vs(J))&&e.xsrfCookieName?Us.read(e.xsrfCookieName):void 0;Ho&&(s[e.xsrfHeaderName]=Ho)}"setRequestHeader"in p&&Ot.forEach(s,function(ye,ce){typeof o=="undefined"&&ce.toLowerCase()==="content-type"?delete s[ce]:p.setRequestHeader(ce,ye)}),Ot.isUndefined(e.withCredentials)||(p.withCredentials=!!e.withCredentials),l&&l!=="json"&&(p.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&p.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&p.upload&&p.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(n=function(G){!p||(r(!G||G&&G.type?new qs("canceled"):G),p.abort(),p=null)},e.cancelToken&&e.cancelToken.subscribe(n),e.signal&&(e.signal.aborted?n():e.signal.addEventListener("abort",n))),o||(o=null),p.send(o)})}});var mt=f((zn,Ma)=>{"use strict";var P=_(),ga=Qo(),js=fo(),Xs={"Content-Type":"application/x-www-form-urlencoded"};function ya(a,e){!P.isUndefined(a)&&P.isUndefined(a["Content-Type"])&&(a["Content-Type"]=e)}function Ws(){var a;return typeof XMLHttpRequest!="undefined"?a=wo():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(a=wo()),a}function Ks(a,e,t){if(P.isString(a))try{return(e||JSON.parse)(a),P.trim(a)}catch(i){if(i.name!=="SyntaxError")throw i}return(t||JSON.stringify)(a)}var Dt={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:Ws(),transformRequest:[function(e,t){return ga(t,"Accept"),ga(t,"Content-Type"),P.isFormData(e)||P.isArrayBuffer(e)||P.isBuffer(e)||P.isStream(e)||P.isFile(e)||P.isBlob(e)?e:P.isArrayBufferView(e)?e.buffer:P.isURLSearchParams(e)?(ya(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):P.isObject(e)||t&&t["Content-Type"]==="application/json"?(ya(t,"application/json"),Ks(e)):e}],transformResponse:[function(e){var t=this.transitional||Dt.transitional,i=t&&t.silentJSONParsing,r=t&&t.forcedJSONParsing,o=!i&&this.responseType==="json";if(o||r&&P.isString(e)&&e.length)try{return JSON.parse(e)}catch(s){if(o)throw s.name==="SyntaxError"?js(s,this,"E_JSON_PARSE"):s}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};P.forEach(["delete","get","head"],function(e){Dt.headers[e]={}});P.forEach(["post","put","patch"],function(e){Dt.headers[e]=P.merge(Xs)});Ma.exports=Dt});var wa=f((Jn,ba)=>{"use strict";var Ys=_(),Qs=mt();ba.exports=function(e,t,i){var r=this||Qs;return Ys.forEach(i,function(s){e=s.call(r,e,t)}),e}});var Io=f((Zn,Ia)=>{"use strict";Ia.exports=function(e){return!!(e&&e.__CANCEL__)}});var Ea=f((el,Pa)=>{"use strict";var Fa=_(),Fo=wa(),zs=Io(),Js=mt(),Zs=ct();function Po(a){if(a.cancelToken&&a.cancelToken.throwIfRequested(),a.signal&&a.signal.aborted)throw new Zs("canceled")}Pa.exports=function(e){Po(e),e.headers=e.headers||{},e.data=Fo.call(e,e.data,e.headers,e.transformRequest),e.headers=Fa.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Fa.forEach(["delete","get","head","post","put","patch","common"],function(r){delete e.headers[r]});var t=e.adapter||Js.adapter;return t(e).then(function(r){return Po(e),r.data=Fo.call(e,r.data,r.headers,e.transformResponse),r},function(r){return zs(r)||(Po(e),r&&r.response&&(r.response.data=Fo.call(e,r.response.data,r.response.headers,e.transformResponse))),Promise.reject(r)})}});var Eo=f((tl,Ra)=>{"use strict";var x=_();Ra.exports=function(e,t){t=t||{};var i={};function r(p,m){return x.isPlainObject(p)&&x.isPlainObject(m)?x.merge(p,m):x.isPlainObject(m)?x.merge({},m):x.isArray(m)?m.slice():m}function o(p){if(x.isUndefined(t[p])){if(!x.isUndefined(e[p]))return r(void 0,e[p])}else return r(e[p],t[p])}function s(p){if(!x.isUndefined(t[p]))return r(void 0,t[p])}function l(p){if(x.isUndefined(t[p])){if(!x.isUndefined(e[p]))return r(void 0,e[p])}else return r(void 0,t[p])}function n(p){if(p in t)return r(e[p],t[p]);if(p in e)return r(void 0,e[p])}var c={url:s,method:s,data:s,baseURL:l,transformRequest:l,transformResponse:l,paramsSerializer:l,timeout:l,timeoutMessage:l,withCredentials:l,adapter:l,responseType:l,xsrfCookieName:l,xsrfHeaderName:l,onUploadProgress:l,onDownloadProgress:l,decompress:l,maxContentLength:l,maxBodyLength:l,transport:l,httpAgent:l,httpsAgent:l,cancelToken:l,socketPath:l,responseEncoding:l,validateStatus:n};return x.forEach(Object.keys(e).concat(Object.keys(t)),function(m){var d=c[m]||o,J=d(m);x.isUndefined(J)&&d!==n||(i[m]=J)}),i}});var Ro=f((il,Ta)=>{Ta.exports={version:"0.24.0"}});var _a=f((rl,Sa)=>{"use strict";var en=Ro().version,To={};["object","boolean","number","function","string","symbol"].forEach(function(a,e){To[a]=function(i){return typeof i===a||"a"+(e<1?"n ":" ")+a}});var va={};To.transitional=function(e,t,i){function r(o,s){return"[Axios v"+en+"] Transitional option '"+o+"'"+s+(i?". "+i:"")}return function(o,s,l){if(e===!1)throw new Error(r(s," has been removed"+(t?" in "+t:"")));return t&&!va[s]&&(va[s]=!0,console.warn(r(s," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(o,s,l):!0}};function tn(a,e,t){if(typeof a!="object")throw new TypeError("options must be an object");for(var i=Object.keys(a),r=i.length;r-- >0;){var o=i[r],s=e[o];if(s){var l=a[o],n=l===void 0||s(l,o,a);if(n!==!0)throw new TypeError("option "+o+" must be "+n);continue}if(t!==!0)throw Error("Unknown option "+o)}}Sa.exports={assertOptions:tn,validators:To}});var La=f((ol,Da)=>{"use strict";var Ca=_(),rn=ho(),Aa=Ko(),xa=Ea(),Lt=Eo(),Oa=_a(),Ie=Oa.validators;function dt(a){this.defaults=a,this.interceptors={request:new Aa,response:new Aa}}dt.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=Lt(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;t!==void 0&&Oa.assertOptions(t,{silentJSONParsing:Ie.transitional(Ie.boolean),forcedJSONParsing:Ie.transitional(Ie.boolean),clarifyTimeoutError:Ie.transitional(Ie.boolean)},!1);var i=[],r=!0;this.interceptors.request.forEach(function(d){typeof d.runWhen=="function"&&d.runWhen(e)===!1||(r=r&&d.synchronous,i.unshift(d.fulfilled,d.rejected))});var o=[];this.interceptors.response.forEach(function(d){o.push(d.fulfilled,d.rejected)});var s;if(!r){var l=[xa,void 0];for(Array.prototype.unshift.apply(l,i),l=l.concat(o),s=Promise.resolve(e);l.length;)s=s.then(l.shift(),l.shift());return s}for(var n=e;i.length;){var c=i.shift(),p=i.shift();try{n=c(n)}catch(m){p(m);break}}try{s=xa(n)}catch(m){return Promise.reject(m)}for(;o.length;)s=s.then(o.shift(),o.shift());return s};dt.prototype.getUri=function(e){return e=Lt(this.defaults,e),rn(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};Ca.forEach(["delete","get","head","options"],function(e){dt.prototype[e]=function(t,i){return this.request(Lt(i||{},{method:e,url:t,data:(i||{}).data}))}});Ca.forEach(["post","put","patch"],function(e){dt.prototype[e]=function(t,i,r){return this.request(Lt(r||{},{method:e,url:t,data:i}))}});Da.exports=dt});var Na=f((al,Ba)=>{"use strict";var on=ct();function Fe(a){if(typeof a!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(r){e=r});var t=this;this.promise.then(function(i){if(!!t._listeners){var r,o=t._listeners.length;for(r=0;r<o;r++)t._listeners[r](i);t._listeners=null}}),this.promise.then=function(i){var r,o=new Promise(function(s){t.subscribe(s),r=s}).then(i);return o.cancel=function(){t.unsubscribe(r)},o},a(function(r){t.reason||(t.reason=new on(r),e(t.reason))})}Fe.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};Fe.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};Fe.prototype.unsubscribe=function(e){if(!!this._listeners){var t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}};Fe.source=function(){var e,t=new Fe(function(r){e=r});return{token:t,cancel:e}};Ba.exports=Fe});var Ha=f((sl,Ua)=>{"use strict";Ua.exports=function(e){return function(i){return e.apply(null,i)}}});var Ga=f((nl,ka)=>{"use strict";ka.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var qa=f((ll,vo)=>{"use strict";var Va=_(),an=lo(),Bt=La(),sn=Eo(),nn=mt();function $a(a){var e=new Bt(a),t=an(Bt.prototype.request,e);return Va.extend(t,Bt.prototype,e),Va.extend(t,e),t.create=function(r){return $a(sn(a,r))},t}var $=$a(nn);$.Axios=Bt;$.Cancel=ct();$.CancelToken=Na();$.isCancel=Io();$.VERSION=Ro().version;$.all=function(e){return Promise.all(e)};$.spread=Ha();$.isAxiosError=Ga();vo.exports=$;vo.exports.default=$});var Xa=f((pl,ja)=>{ja.exports=qa()});var no=a=>{let e=200,t=[],i=0;return t[i]=[],a.forEach(r=>{t[i].length<=e-1?t[i].push(r):(i++,t[i]=[r])}),t},Me=(a,e)=>{let t=[];for(;a.length>e;){let i=a.splice(0,e);t.push(i)}return t.push(a),t},S=(a,e)=>{let t="",i={profile:"https://profile.fansunitedapi.com/v1",football:"https://football.fansunitedapi.com/v1",idMapping:"https://id-mapping.fansunitedapi.com/v1",predictor:"https://prediction.fansunitedapi.com/v1",client:"https://client.fansunitedapi.com/v1",loyalty:"https://loyalty.fansunitedapi.com/v1"},r={profile:"http://localhost:8010/v1",football:"http://localhost:8080/v1",idMapping:"http://localhost:8030/v1",predictor:"http://localhost:8040/v1",client:"http://localhost:8070/v1",loyalty:"http://localhost:8060/v1"},o={profile:"https://profile.fansunitedstagingapi.com/v1",football:"https://football.fansunitedstagingapi.com/v1",idMapping:"https://id-mapping.fansunitedstagingapi.com/v1",predictor:"https://prediction.fansunitedstagingapi.com/v1",client:"https://client.fansunitedstagingapi.com/v1",loyalty:"https://loyalty.fansunitedstagingapi.com/v1"};return a==="prod"?t=i[e]:a==="dev"?t=r[e]:t=o[e],t},te=a=>a.filter((t,i,r)=>i===r.indexOf(t)),I=a=>a||!1,F=()=>`&disable_cache=${Date.now()}`,Ft=a=>JSON.parse(JSON.stringify(a.sort((e,t)=>e.localeCompare(t))));var Pt=class{id=null;name=null;nickname=null;avatar=null;gender=null;country=null;birthDate=null;interests=[];followingCount=0;followersCount=0};var Et=class{profilesFromResponse=e=>e?e.map(t=>this.fullProfileFromResponse(t)):null;fullProfileFromResponse=e=>{let t=new Pt;return t.id=e.id,t.name=e.name,t.nickname=e.nickname,t.avatar=e.avatar,t.gender=e.gender,t.country=e.country,t.birthDate=e.birth_date,t.interests=e.interests?e.interests:[],t.followingCount=e.following_count,t.followersCount=e.followers_count,t}};var Rt=class{nextPageStartsAfter=null;itemsPerPage=null};var be=class{pagination=new Rt};var M=class{meta=new be;data=[]};var Tt=class{avatar=null;followingId=null;name=null;nickname=null;profileId=null};var vt=class{followResponse=e=>e.map(t=>this.remapResponse(t));followingFromResponse=e=>{let t=new M;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(i=>this.remapResponse(i)),t};remapResponse=e=>{let t=new Tt;return t.avatar=e.avatar,t.followingId=e.following_id,t.name=e.name,t.profileId=e.profile_id,t.nickname=e.nickname,t}};var St=class{avatar=null;followerId=null;name=null;nickname=null;profileId=null};var _t=class{followersFromResponse=e=>{let t=new M;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(i=>this.remapResponse(i)),t};remapResponse=e=>{let t=new St;return t.avatar=e.avatar,t.followerId=e.follower_id,t.name=e.name,t.profileId=e.profile_id,t}};var pt=class{profile_ids=[]};var Ht=us(Xa());function So(a){this.message=a}So.prototype=new Error,So.prototype.name="InvalidCharacterError";var Wa=typeof window!="undefined"&&window.atob&&window.atob.bind(window)||function(a){var e=String(a).replace(/=+$/,"");if(e.length%4==1)throw new So("'atob' failed: The string to be decoded is not correctly encoded.");for(var t,i,r=0,o=0,s="";i=e.charAt(o++);~i&&(t=r%4?64*t+i:i,r++%4)?s+=String.fromCharCode(255&t>>(-2*r&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return s};function ln(a){var e=a.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Wa(t).replace(/(.)/g,function(i,r){var o=r.charCodeAt(0).toString(16).toUpperCase();return o.length<2&&(o="0"+o),"%"+o}))}(e)}catch{return Wa(e)}}function Nt(a){this.message=a}function pn(a,e){if(typeof a!="string")throw new Nt("Invalid token specified");var t=(e=e||{}).header===!0?0:1;try{return JSON.parse(ln(a.split(".")[t]))}catch(i){throw new Nt("Invalid token specified: "+i.message)}}Nt.prototype=new Error,Nt.prototype.name="InvalidTokenError";var Ka=pn;var h=class{response={error:{code:0,status:"",message:""}};constructor(e,t,i){this.response.error.code=e,this.response.error.status=t,this.response.error.message=i}};var Ya=(a,e,t)=>{let i={data:a.data,status:e,statusText:t,headers:a.headers,config:a};return{code:String(e),config:a,isAxiosError:!0,toJSON:()=>({}),name:"Unauthorized",message:t,response:i}};var D={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id"},_o={PREDICTOR_USER_RELATED_OPERATION:"https://docs.fansunitedmedia.com/docs/predictor-operations#user-related-operations"},Co=["matchId","matchType","market","prediction"];var Ao={UNEXPECTED_STATUS_PROP:`Unexpected provided property 'status'. You can NOT use this property for this method. For more information visit our documentation:
|
|
3
3
|
${_o.PREDICTOR_USER_RELATED_OPERATION}`,UNEXPECTED_TYPE_PROP:`Unexpected provided property 'type'. You can NOT use this property for this method. For more information visit our documentation:
|
|
4
|
-
${_o.PREDICTOR_USER_RELATED_OPERATION}`},Qa=(a,e)=>`The prediction '${a}' is invalid for market '${e}'. Please check again have you passed appropriate prediction model. For more information please visit our documentation: https://docs.fansunitedmedia.com/sdks/js/match.quiz#gamerelatedoperations`,Ut=a=>`The market '${a}' is not supported from Fans United. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,za=a=>`The market '${a}' is not valid for Top X game. The only available market is CORRECT_SCORE.`,Ja=a=>`The field/s '${a.length>1?a.join(", "):a[0]}' is/are invalid. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/javascript-sdk`,Za=(a,e)=>`The following field/s is/are missing from ${a}: '${e.length>1?e.join(", "):e[0]}'. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,es=(a,e)=>`The field ${a} has incorrect type. The correct type is ${e}`;var E=class{apiSignInUrl=null;instanceAuth=null;instance=null;errorHandlingMode=null;constructor(e,t){this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.errorHandlingMode=e.errorHandlingMode,this.instanceAuth=Ht.default.create({baseURL:t,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instanceAuth.interceptors.request.use(i=>{let r=null;try{r=Ka(e.authProvider.getIdToken())}catch(s){if(this.errorHandlingMode==="default")throw Ya(i,401,s.message);if(this.errorHandlingMode==="standard")throw new h(401,"invalid_token","Invalid JWT token is provided")}return Date.now()>r.exp&&(Ht.default.defaults.headers.common.Authorization=`Bearer ${e.authProvider.getIdToken()}`,i.headers.Authorization=`Bearer ${e.authProvider.getIdToken()}`),i},i=>{Promise.reject(i)}),this.instanceAuth.interceptors.response.use(i=>i,i=>{let r=i.config;if((i.response?.status===403||i.response?.status===401)&&!r._retry){r._retry=!0;let o=e.authProvider.getIdToken();return r.headers.Authorization=`Bearer ${o}`,this.instanceAuth(r)}if(this.errorHandlingMode==="standard"&&i.response?.status===401){let o=new h(401,"unauthorized","The provided JWT token is expired");return Promise.reject(o)}return Promise.reject(i)}),this.instance=Ht.default.create({baseURL:t,headers:{"Content-Type":"application/json"}})}transformAxiosErrorToFansUnitedException=e=>{if(this.errorHandlingMode==="standard"&&e.response&&e.response.data&&e.response.data.error){let{code:t,status:i,message:r}=e.response.data.error;return new h(t,i,r)}return e}};var cn="/countries",C="/profile",xo="/profiles",Ee=class extends E{profileRemapper=null;followingRemapper=null;followersRemapper=null;lang=null;limitIds=100;constructor(e){super(e,v(e.environment,"profile"));this.lang=e.lang,this.profileRemapper=new Et,this.followingRemapper=new St,this.followersRemapper=new _t}getCountries=async e=>{try{let t=`&lang=${this.lang}`,i=`${cn}${this.apiSignInUrl}${t}`,r=Date.now();return e&&(i+=`&disable_cache=${r}`),(await this.instance.get(i)).data.data}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem fetching the countries:",i),i.response}};getProfile=async e=>{let t=`${C}${this.apiSignInUrl}`;if(e){t=`${xo}/${e}${this.apiSignInUrl}`;try{let i=await this.instance.get(t);return this.profileRemapper.fullProfileFromResponse(i.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn(`There was a problem fetching the following profile: ${e}`,r),r.response}}else try{let i=await this.instanceAuth.get(t);return this.profileRemapper.fullProfileFromResponse(i.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem fetching your profile from API:",r),r.response}};getProfiles=async(e,t)=>{try{let i=Date.now();if(e.length>this.limitIds){let s=[],l=Me(e,this.limitIds);for(let n of l){let c=`${xo}${this.apiSignInUrl}&profile_ids=${n.join(",")}`;t&&(c+=`&disable_cache=${i}`);let p=await this.instance.get(c);s.push(...this.profileRemapper.profilesFromResponse(p.data.data))}return s}let r=`${xo}${this.apiSignInUrl}&profile_ids=${e.join(",")}`;t&&(r+=`&disable_cache=${i}`);let o=await this.instance.get(r);return this.profileRemapper.profilesFromResponse(o.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn(`There was a problem fetching the following profiles: ${e.join(",")}`,r),r.response}};getFollowers=async(e,t)=>{let i=`${C}/followers${this.apiSignInUrl}`;if(e&&!t){i=`${C}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let r=await this.instanceAuth.get(i);return this.followersRemapper.followersFromResponse(r.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn("There was a problem fetching the followers for own profile",o),o.response}}else if(!e&&!t)try{let r=await this.instanceAuth.get(i);return this.followersRemapper.followersFromResponse(r.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn("There was a problem fetching the followers for own profile",o),o.response}e&&t?i=`${C}/${t}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(i=`${C}/${t}/followers${this.apiSignInUrl}`);try{let r=await this.instance.get(i);return this.followersRemapper.followersFromResponse(r.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn(`There was a problem fetching the followers for profile: ${t}`,o),o.response}};getFollowing=async(e,t)=>{let i=`${C}/following${this.apiSignInUrl}`;if(e&&!t){i=`${C}/following${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let r=await this.instanceAuth.get(i);return this.followingRemapper.followingFromResponse(r.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn("There was a problem fetching the followers of own profile",o),o.response}}else if(!e&&!t)try{let r=await this.instanceAuth.get(i);return this.followingRemapper.followingFromResponse(r.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn("There was a problem fetching the followers of own profile",o),o.response}e&&t?i=`${C}/${t}/following${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(i=`${C}/${t}/following${this.apiSignInUrl}`);try{let r=await this.instance.get(i);return this.followingRemapper.followingFromResponse(r.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn(`There was a problem fetching the followers of the following profile: ${t}`,o),o.response}};follow=async e=>{let t=new pt;t.profile_ids=e;try{let i=await this.instanceAuth.post(`${C}/follow${this.apiSignInUrl}`,JSON.stringify(t));return this.followingRemapper.followResponse(i.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn(`There was a problem with POST request for profiles: ${e.join(",")} `,r),r.response}};unfollow=async e=>{let t=new pt;t.profile_ids=e;try{return await this.instanceAuth.delete(`${C}/follow${this.apiSignInUrl}`,{data:JSON.stringify(t)}),!0}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn(`There was a problem with DELETE request for profiles: ${e.join(",")} `,r),r.response}};getBadges=async e=>{let t=`${C}/badges${this.apiSignInUrl}`;try{return e?(t=`${C}/${e}/badges${this.apiSignInUrl}`,(await this.instance.get(t)).data.data):(await this.instanceAuth.get(t)).data.data}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with fetching the badges",r),r.response}};updateProfile=async e=>{try{let t=await this.instanceAuth.patch(`${C}${this.apiSignInUrl}`,e);return this.profileRemapper.fullProfileFromResponse(t.data.data)}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem updating the own profile:",i),i.response}}};var ts="FansUnited",Oo={football:{ids:[],countries:[],competitions:[],expirations:{ids:0}},profile:{info:{},statistics:{},badges:null,countries:[],expirations:{profile:0,statistics:0,badges:0}},client:{features:{},expirations:{features:0}}},L=class{idSchema="";expirationProfileTimeout=600;expirationBadgesTimeout=3600;expirationClientFeaturesTimeout=14400;expirationFootballIdsTimeout=604800;constructor(e){this.idSchema=e.idSchema,(this.getData()===void 0||this.getData()===null)&&this.setData(Oo)}clearData=()=>{this.setData(Oo)};getEntityById=(e="",t="")=>this.getData().football.ids.find(i=>{let r=D[this.idSchema];return i&&`${i[r]}`===t&&i.resource===e});getEntity=(e,t,i)=>Array.isArray(e)?this.getData().football.ids.filter(r=>{let o=D[i];return r&&e.includes(`${r[o]}`)&&r.resource===t}):this.getData().football.ids.find(r=>{let o=D[i];return r&&`${r[o]}`===e&&r.resource===t});getEntityByNativeId=(e="",t="")=>this.getData().football.ids.find(i=>i&&`${i.id}`===t&&i.resource===e);checkForExistingIdObjs=(e,t)=>{let i=D[t],r={};return Object.keys(e).forEach(o=>{let s=e[o],n=this.getEntity(s,o,t).map(p=>p[i]),c=e[o].filter(p=>!n.includes(p));r[o]=s.map(p=>c.includes(p)?{id:p,exists:!1}:{id:p,exists:!0})}),r};getIdsByType=(e,t,i)=>{let r=D[i],o=D[t],s={};return Object.keys(e).forEach(l=>{let n=e[l],c=[];this.getData().football.ids.forEach(p=>{n.forEach((m,d)=>{m===p[o]&&l===p.resource&&(c[d]=p[r])})}),s[l]=c}),s};addIdMapping=e=>{let t=this.getData();t.football.ids.push(e),this.setData(t)};addIdMappings=e=>{let t=this.getData(),i=t.football.ids;i=[...i,...e],t.football.ids=i,this.setData(t)};addTopIdMappings=e=>{let t=this.getData();if(t.football.ids.length){let i=JSON.parse(JSON.stringify(t.football.ids));i=i.filter(r=>r.resource!=="match"),e=e.filter(r=>r.resource==="match"),i=[...i,...e],t.football.ids=i}else t.football.ids=e;t.football.expirations.ids=Math.floor(Date.now()/1e3)+this.expirationFootballIdsTimeout,this.setData(t)};setOwnProfile=e=>{let t=this.getData();t.profile.info=e,t.profile.expirations.profile=Math.floor(Date.now()/1e3)+this.expirationProfileTimeout,this.setData(t)};getOwnProfile=()=>this.getData().profile.info;getProfileCountries=()=>this.getData().profile.countries;setProfileCountries=e=>{let t=this.getData();t.profile.countries=e,this.setData(t)};getProfileStats=()=>this.getData().profile.statistics;setProfileStats=e=>{let t=this.getData();t.profile.statistics=e,t.profile.expirations.statistics=Math.floor(Date.now()/1e3)+this.expirationProfileTimeout,this.setData(t)};getProfileBadges=()=>this.getData().profile.badges;setProfileBadges=e=>{let t=this.getData();t.profile.badges=e,t.profile.expirations.badges=Math.floor(Date.now()/1e3)+this.expirationBadgesTimeout,this.setData(t)};getFootballCountries=()=>this.getData().football.countries;setFootballCountries=e=>{let t=this.getData();t.football.countries=e,this.setData(t)};getCompetitions=e=>{let t=this.getData();return e?e.competitionSearchFilter(t.football.competitions):t.football.competitions};setCompetitions=e=>{let t=this.getData(),i=[...t.football.competitions];i.push(...e),t.football.competitions=this.makeCompetitionsUnique(i),this.setData(t)};getCompetitionsLength=()=>{let{football:e}=this.getData();return e.competitions.length};getClientFeatures=()=>this.getData().client.features;setClientFeatures=e=>{let t=this.getData(),i=JSON.parse(JSON.stringify(e));t.client.expirations.features=Math.floor(Date.now()/1e3)+this.expirationClientFeaturesTimeout,t.client.features=i,this.setData(t)};getExpiration=(e,t)=>{this.initialNewSchema(e,"expirations");let i=this.getData();switch(t){case"profile":return i.profile.expirations.profile;case"statistics":return i.profile.expirations.statistics;case"badges":return i.profile.expirations.badges;case"features":return i.client.expirations.features;case"ids":return i.football.expirations.ids}};makeCompetitionsUnique=e=>{let t=new Set;return e.filter(i=>{let r=!t.has(i.id);return t.add(i.id),r})};getData=()=>JSON.parse(localStorage.getItem(ts));setData=e=>{localStorage.setItem(ts,JSON.stringify(e))};initialNewSchema=(e,t)=>{let i=this.getData();(!i||!i[e]||!i[e][t])&&this.setData(Oo)}};var ut={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},kt=class extends E{constructor(e){super(e,v(e.environment,"idMapping"));this.apiSignInUrl=this.apiSignInUrl.split("&")[0]}getEntityById=(e,t)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${config.idSchema}&${ut[e]}=${t}`)}catch(i){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,i),i.response}};getEntityByIdAndSchema=(e,t,i)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${i}&${ut[e]}=${t}`)}catch(r){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,r),r.response}};getEntityIdsByIdsAndSchema=(e,t,i)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${i}&${ut[e]}=${t.join(",")}`)}catch(r){throw console.warn(`There was a problem with id mapping request for the following ids:${t.join(",")}`,r),r.response}};getEntitiesByIds=(e,t,i)=>{t.sort((s,l)=>s.localeCompare(l));let o=no(t).map(s=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${i}&${ut[e]}=${s.join(",")}`)}catch(l){let n=this.transformAxiosErrorToFansUnitedException(l);throw console.warn(`There was a problem with id mapping request for the following ids:${s.join(",")}`,n),n.response}});return Promise.all(o).then(s=>{let l=[];return s.forEach(n=>{l.push(...n.data.data)}),l})};getEntitiesByIdObjs=async(e,t)=>{let i=[],r={},o=[];Object.keys(e).forEach(c=>{i.push.apply(i,e[c])});let s=te(i),l=no(s);for(let c of l){let p="";if(Object.keys(e).forEach(m=>{r[m]=[];let d=c.filter(J=>e[m].includes(J));d&&d.length>0&&(r[m]=d)}),Object.keys(r).forEach(m=>{r[m].length>0&&(r[m].sort((d,J)=>d.localeCompare(J)),p+="&",p+=`${ut[m]}=${r[m].join(",")}`)}),p&&p.length>0)try{let m=await this.instance.get(`/football${this.apiSignInUrl}&input_provider=${t||"native"}${p}`);o.push(m.data.data)}catch(m){let d=this.transformAxiosErrorToFansUnitedException(m);throw console.warn("There was a problem with id mapping request",d),d.response}else o.push([])}return Array.prototype.concat.apply([],o)};getTopEntities=async()=>{try{return(await this.instance.get(`/football/top${this.apiSignInUrl}`)).data.data}catch(e){let t=this.transformAxiosErrorToFansUnitedException(e);throw console.warn("There was a problem with top id mappings request",t),t.response}}};var Gt=class{isBrowser=!1;localStorage=null;https=null;constructor(e){this.isBrowser=typeof window!="undefined",this.localStorage=new L(e),this.https=new kt(e)}getEntitiesByIds=async(e,t,i)=>{if(this.isBrowser){await this.setTopIdMappings();try{let r=this.localStorage.checkForExistingIdObjs(e,t),o=this.splitForRequestAndExisting(r),s=await this.https.getEntitiesByIdObjs(o.request,t);return this.localStorage.addIdMappings(s),this.localStorage.getIdsByType(e,t,i)}catch(r){return console.warn("There was a problem retrieving the entity ids ",r),Promise.resolve([])}}else try{let r=await this.https.getEntitiesByIdObjs(e,t);return Object.keys(e).forEach(o=>{e[o]=r.filter(s=>s.resource===o).map(s=>s[D[i]])}),e}catch(r){return console.warn("There was a problem retrieving the entity ids ",r),Promise.resolve([])}};getEntityById=async(e,t,i)=>{if(this.isBrowser){let r=this.localStorage.getEntity(e,t,i);if(r)return r;{let o=await this.requestEntity(e,t,i);return this.localStorage.addIdMappings(o),o}}else return await this.requestEntity(e,t,i)};splitForRequestAndExisting=e=>{let t={},i={};return Object.keys(e).forEach(r=>{t[r]=e[r].filter(o=>!o.exists).map(o=>o.id),i[r]=e[r].filter(o=>o.exists).map(o=>o.id)}),{existing:i,request:t}};requestEntity=async(e,t,i)=>{try{return e=Array.isArray(e)?e:[e],await this.https.getEntitiesByIds(t,e,i)}catch(r){return console.warn(`There was a problem retrieving the requested entity: ${r}`),null}};setTopIdMappings=async()=>{let e=Math.floor(Date.now()/1e3);if(this.localStorage.getExpiration("football","ids")>e)return Promise.resolve();let i=await this.https.getTopEntities();this.localStorage.addTopIdMappings(i)}};var Vt=a=>{switch(a){case"competitions":return"competition";case"players":case"relatedPlayer":case"squad":return"player";case"teams":case"participants":case"homeTeam":case"awayTeam":case"timeline":case"teamId":return"team";default:return a}};var $t=class{extractedObjIds={};traverse=(e,t)=>(t=Vt(t),Array.isArray(e)?this.traverseArrExtract(e,t):e&&typeof e=="object"&&this.traverseObjExtract(e,t),this.extractedObjIds);traverseArrExtract=(e,t)=>{e&&e.length>0&&e.forEach(i=>{this.traverseObjExtract(i,t)})};traverseObjExtract=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(i=>{let r=e[i];i==="id"||i==="teamId"?(this.extractedObjIds.hasOwnProperty(t)||(this.extractedObjIds[t]=[]),r&&this.extractedObjIds[t].push(r)):e[i]&&this.traverse(e[i],i)})}};var qt=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(e,t,i)=>(t=Vt(t),this.replaceObjIdsIndex===null&&(this.initReplaceObjIdsIndex(i),this.remappedIdsObj=i),Array.isArray(e)?this.traverseArrReplace(e,t):e&&typeof e=="object"&&this.traverseObjReplace(e,t),e);initReplaceObjIdsIndex=e=>{this.replaceObjIdsIndex={},Object.keys(e).forEach(t=>{this.replaceObjIdsIndex[t]=0})};traverseArrReplace=(e,t)=>{e&&e.length>0&&e.forEach(i=>{this.traverseObjReplace(i,t)})};traverseObjReplace=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(i=>{i==="id"||i==="teamId"?e[i]&&(e[i]=this.remappedIdsObj[t][this.replaceObjIdsIndex[t]],this.replaceObjIdsIndex[t]=this.replaceObjIdsIndex[t]+1):e[i]&&this.traverse(e[i],i,this.remappedIdsObj)})}};var b=class{idSchema="";idMappingFacade=null;constructor(e){this.idSchema=e.idSchema,this.idMappingFacade=new Gt(e)}getEntityIdBySchemaId=(e,t)=>this.idMappingFacade.getEntityById(e,t,this.idSchema);remapEntities=async(e,t)=>{let i=JSON.parse(JSON.stringify(e));try{if(this.idSchema!=="native"){let o=new $t().traverse(i,t);return this.idMappingFacade.getEntitiesByIds(o,"native",this.idSchema).then(s=>new qt().traverse(i,t,s))}else return e}catch(r){return console.warn(`There was a problem remapping entity: ${t} with inner entity `,r),[]}};getEntityIdsBySchemaId=async(e,t,i)=>{let r={};return r[t]=e,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(r,this.idSchema,i):r}};var O=class{completed=!1;percentage;constructor(e){this.percentage=e}};var jt=class{teamFollowed=new O(10);teamFavourite=new O(15);playerFollowed=new O(10);playerFavourite=new O(10);competitionFollowed=new O(10);competitionFavourite=new O(5);addedBirthdate=new O(10);addedGender=new O(10);addedCountry=new O(10);addedAvatar=new O(10)};var Xt=class{totalPercentage;breakdown=new jt};var ht=class{limit=0;startAfter=null;constructor(e){this.limit=e.limit?e.limit:20,this.startAfter=e.startAfter?e.startAfter:null}constructFilterUrl=()=>{let e="";return this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.startAfter&&(e=e+"&",e=e+`start_after=${this.startAfter}`),e}};var j=class{isBrowser=!1;localStorage={};profileHttps=null;activityHttps=null;constructor(e,t,i){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.profileHttps=t,this.activityHttps=i}getOwn=async()=>{if(this.isBrowser){let e=this.getLocalStorageData("profile");if(e)return JSON.parse(JSON.stringify(e));try{let t=await this.profileHttps.getProfile();return this.localStorage.setOwnProfile(t),t}catch(t){throw console.warn("There was a problem retrieving your profile: ",t),t}}else try{return await this.profileHttps.getProfile()}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};updateOwnProfile=async()=>{try{let e=await this.profileHttps.getProfile();return this.localStorage.setOwnProfile(e),e}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};getByIds=async(e,t)=>{try{return t=t||!1,await this.profileHttps.getProfiles(e,t)}catch(i){throw console.warn(`There was a problem retrieving the selected profiles: ${e.join(",")} `,i),i}};getById=async e=>{try{return await this.profileHttps.getProfile(e)}catch(t){throw console.warn(`There was a problem retrieving the selected profile: ${e} `,t),t}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let t=this.localStorage.getProfileCountries();if(t&&t.length>0)return t;try{let i=await this.profileHttps.getCountries(e);return this.localStorage.setProfileCountries(i),i}catch(i){throw console.warn("There was a problem retrieving profile countries: ",i),i}}else try{return await this.profileHttps.getCountries(e)}catch(t){throw console.warn("There was a problem retrieving profile countries: ",t),t}};getFollowers=async(e,t)=>{try{e&&(e=new ht(e));let i=await this.profileHttps.getFollowers(e,t),r=i.data.map(o=>o.followerId);if(r.length){let o=await this.getByIds(r),s=i.data.map(l=>(o.forEach(n=>{l.followerId===n.id&&(l.name=n.name,l.nickname=n.nickname,l.avatar=n.avatar)}),l));return i.data=s,i}return i}catch(i){throw console.warn("There was a problem retrieving your followers: ",i),i}};getFollowing=async(e,t)=>{try{e&&(e=new ht(e));let i=await this.profileHttps.getFollowing(e,t),r=i.data.map(o=>o.followingId);if(r.length){let o=await this.getByIds(r),s=i.data.map(l=>(o.forEach(n=>{l.followingId===n.id&&(l.name=n.name,l.nickname=n.nickname,l.avatar=n.avatar)}),l));return i.data=s,i}return i}catch(i){throw console.warn("There was a problem retrieving your following profiles: ",i),i}};follow=async e=>{try{return await this.profileHttps.follow(e)}catch(t){throw console.warn(`There was a problem following profiles: ${e.join(",")} `,t),t}};unfollow=async e=>{try{return await this.profileHttps.unfollow(e)}catch(t){throw console.warn(`There was a problem unfollowing profiles: ${e.join(",")} `,t),t}};showFullnessProfile=e=>{let t=new Xt,i=0;return e.avatar&&(t.breakdown.addedAvatar.completed=!0,i+=t.breakdown.addedAvatar.percentage),e.birthDate&&(t.breakdown.addedBirthdate.completed=!0,i+=t.breakdown.addedBirthdate.percentage),e.country&&(t.breakdown.addedCountry.completed=!0,i+=t.breakdown.addedCountry.percentage),e.gender&&(t.breakdown.addedGender.completed=!0,i+=t.breakdown.addedGender.percentage),e.interests&&e.interests.length>0&&(e.interests.find(p=>p.type==="team"&&p.favourite)&&(t.breakdown.teamFavourite.completed=!0,i+=t.breakdown.teamFavourite.percentage),e.interests.find(p=>p.type==="team")&&(t.breakdown.teamFollowed.completed=!0,i+=t.breakdown.teamFollowed.percentage),e.interests.find(p=>p.type==="player"&&p.favourite)&&(t.breakdown.playerFavourite.completed=!0,i+=t.breakdown.playerFavourite.percentage),e.interests.find(p=>p.type==="player")&&(t.breakdown.playerFollowed.completed=!0,i+=t.breakdown.playerFollowed.percentage),e.interests.find(p=>p.type==="competition"&&p.favourite)&&(t.breakdown.competitionFavourite.completed=!0,i+=t.breakdown.competitionFavourite.percentage),e.interests.find(p=>p.type==="competition")&&(t.breakdown.competitionFollowed.completed=!0,i+=t.breakdown.competitionFollowed.percentage)),t.totalPercentage=i,t};getStats=async()=>{if(this.isBrowser){let e=this.getLocalStorageData("statistics");if(e&&Object.keys(e).length)return JSON.parse(JSON.stringify(e));try{let t=await this.activityHttps.getStats();return this.localStorage.setProfileStats(t),t}catch(t){throw console.warn("There was a problem retrieving own profile statistics: ",t),t}}else try{return await this.activityHttps.getStats()}catch(e){throw console.warn("There was a problem retrieving own profile statistics: ",e),e}};getBadges=async()=>{if(this.isBrowser){let e=this.getLocalStorageData("badges");if(e)return e;try{let t=await this.profileHttps.getBadges();return this.localStorage.setProfileBadges(t),t}catch(t){throw console.warn("There was a problem retrieving own profile badges: ",t),t}}else try{return await this.profileHttps.getBadges()}catch(e){throw console.warn("There was a problem retrieving own profile badges: ",e),e}};getLocalStorageData=e=>{let t=Math.floor(Date.now()/1e3),i=this.localStorage.getExpiration("profile",e);switch(e){case"profile":if(i>t)return this.localStorage.getOwnProfile();case"statistics":if(i>t)return this.localStorage.getProfileStats();case"badges":if(i>t)return this.localStorage.getProfileBadges();default:return null}}};var Wt=class{id=null;name=null;assets=null};var Kt=class{extractUpdatedProps=(e,t)=>{let i=["name","nickname","gender","avatar"],r={};return Object.keys(e).forEach(o=>{if(i.includes(o)&&e[o]!==t[o])r[o]=t[o];else if(o==="birthDate")(t[o]===null||e[o]===null&&t[o]||e[o]!==t[o])&&(r.birth_date=t[o]);else if(o==="country")t[o]===null?r.country_id=t[o]:(e[o]===null&&t[o]||e[o].id!==t[o].id)&&(r.country_id=t[o].id);else if(o==="interests"){let s=e[o],l=t[o];l.length&&this.isNewInterest(s,l)?r[o]=this.updateInterests(s,l):(!l.length&&s.length||s.length!==l.length&&!this.isNewInterest(s,l))&&(r[o]=l)}}),r};updateInterests=(e,t)=>{if(e.length===t.length){let[i,r]=this.extractSameAndNewInterests(e,t);return[...r,...i]}else return t};isNewInterest=(e,t)=>{let i=!1,[r]=this.extractSameAndNewInterests(e,t);return r.length&&(i=!0),i};extractSameAndNewInterests=(e,t)=>{let i=t.filter(o=>e.some(s=>o.id===s.id&&o.type===s.type&&o.source===s.source&&o.favourite===s.favourite));return[t.filter(o=>!e.some(s=>o.id===s.id&&o.type===s.type&&o.source===s.source&&o.favourite===s.favourite)),i]};isAvatarValidURL=e=>{try{return new URL(e),!0}catch{return!1}}};var g=class extends Error{code=0;status=null;message=null;constructor(e,t,i){super();this.code=e,this.status=t,this.message=i}errorMessage=()=>this.message};var Yt=class{idsRemapper=null;profileHttps=null;profileService=null;localStorage=null;profileFacade=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;errorHandlingMode=null;constructor(e,t,i,r,o){this.idsRemapper=e,this.localStorage=t,this.profileHttps=i,this.errorHandlingMode=o,this.profileService=new Kt,this.profileFacade=new j(t,i,r)}getOwnProfile=async()=>{for(;this.isFetching;)console.log("Another thread is fetching profile..."),await this.delay(100);if(this.modified&&this.ownProfile)return console.log("Timestamp is less than 10 minutes OR profile is modifying "),this.ownProfile;let e=Math.floor(Date.now()/1e3);if(!this.ownProfile||this.expireAt<e){this.isFetching=!0,this.expireAt=Math.floor(Date.now()/1e3)+600;try{let t=await this.profileFacade.getOwn();this.setOwnProfile(t)}catch(t){throw this.isFetching=!1,t}return this.modified=!1,this.isFetching=!1,this.ownProfile}return this.ownProfile};delay=e=>new Promise(t=>{setTimeout(t,e)});setOwnProfile=e=>{this.ownProfile=e};getInfo=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return delete t.interests,t};showInterests=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.remapInterests(t.interests)};showFullInterests=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.showFullInterests(t.interests)};getFollowers=async e=>await this.profileFacade.getFollowers(e);getFollowing=async e=>await this.profileFacade.getFollowing(e);follow=async e=>{let t=await this.profileFacade.follow(e),i=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(i),t};unfollow=async e=>{let t=await this.profileFacade.unfollow(e),i=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(i),t};getStats=async()=>{let e=await this.profileFacade.getStats();return await this.idsRemapper.remapSuccessRatesEntities(e)};getBadges=async()=>await this.profileFacade.getBadges();addInterestPromise=async e=>{this.modified=!0;let t={...e};await this.getOwnProfile();let i=null;e.source!=="custom"?i=await this.idsRemapper.remapInterestToNative(t):i=t;let r=this.ownProfile.interests.filter(o=>o.id!==i.id||o.type!==i.type||o.source!==i.source);return this.ownProfile.interests=[...r],this.ownProfile.interests.push(i),this};addInterest=e=>(this.promises.push(this.addInterestPromise(e)),this);removeInterestPromise=async e=>{this.modified=!0;let t={...e};await this.getOwnProfile();let i=null;return e.source!=="custom"?i=await this.idsRemapper.remapInterestToNative(t):i=t,this.ownProfile.interests=this.ownProfile.interests.filter(r=>r.id!==i.id||r.type!==i.type||r.source!==i.source),this};removeInterest=e=>(this.promises.push(this.removeInterestPromise(e)),this);setBirthdatePromise=async e=>(this.modified=!0,await this.getOwnProfile(),e?this.ownProfile.birthDate=e:this.ownProfile.birthDate=null,this);setBirthdate=e=>(this.promises.push(this.setBirthdatePromise(e)),this);setGenderPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e==="male"||e==="female"?this.ownProfile.gender=e:this.ownProfile.gender="unspecified",this);setGender=e=>(this.promises.push(this.setGenderPromise(e)),this);setNicknamePromise=async e=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.nickname=e,this);setNickname=e=>(this.promises.push(this.setNicknamePromise(e)),this);setNamePromise=async e=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.name=e,this);setName=e=>(this.promises.push(this.setNamePromise(e)),this);setCountryPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e&&!this.ownProfile.country?(this.ownProfile.country=new Wt,this.ownProfile.country.id=e):e&&this.ownProfile.country?this.ownProfile.country.id=e:this.ownProfile.country=null,this);setCountry=e=>(this.promises.push(this.setCountryPromise(e)),this);showFullnessProfile=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return this.profileFacade.showFullnessProfile(t)};setAvatarPromise=async e=>{if(this.modified=!0,await this.getOwnProfile(),this.profileService.isAvatarValidURL(e))this.ownProfile.avatar=e;else{if(this.errorHandlingMode==="default")throw new g(400,"invalid_avatar","Invalid URL syntax for avatar image.");if(this.errorHandlingMode==="standard")throw new h(400,"invalid_avatar","Invalid URL syntax for avatar image.").response}return this};setAvatar=e=>(this.promises.push(this.setAvatarPromise(e)),this);update=async()=>{if(this.promises.length===0)return this.ownProfile;await Promise.all(this.promises);let e=await this.profileFacade.getOwn(),t=await this.getOwnProfile(),i=this.profileService.extractUpdatedProps(e,t);if(this.modified=!1,this.expireAt=0,Object.keys(i).length){let o=await this.profileHttps.updateProfile(i),s=JSON.parse(JSON.stringify(o));return this.setOwnProfile(s),this.localStorage.setOwnProfile(s),delete o.interests,o}let r=JSON.parse(JSON.stringify(this.ownProfile));return delete r.interests,r}};var Qt=class{idsRemapper=null;profileHttps=null;activityHttps=null;profileFacade=null;profileId="";constructor(e,t,i,r){this.idsRemapper=e,this.profileHttps=i,this.activityHttps=r,this.profileFacade=new j(t,i,r)}setId=e=>(this.profileId=e,this);getProfile=async()=>await this.profileFacade.getById(this.profileId);getInfo=async()=>{let e=await this.getProfile();return delete e.interests,e};showInterests=async()=>{let e=await this.getProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.remapInterests(t.interests)};showFullInterests=async()=>{let e=await this.getProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.showFullInterests(t.interests)};getFollowers=async e=>await this.profileFacade.getFollowers(e,this.profileId);getFollowing=async e=>await this.profileFacade.getFollowing(e,this.profileId);showFullnessProfile=async()=>{let e=await this.getProfile();return this.profileFacade.showFullnessProfile(e)};getStats=async e=>{let t=await this.activityHttps.getStats(this.profileId,e);return await this.idsRemapper.remapSuccessRatesEntities(t)};getBadges=async()=>await this.profileHttps.getBadges(this.profileId)};var zt=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,i){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=i,this.https=t}getCountriesWithIdMapping=async e=>{try{let t=await this.getCountries(e);return this.idMapping.remapEntities(t,"country")}catch(t){throw console.warn("There was a problem browsing countries as football entities",t),t}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let t=this.localStorage.getFootballCountries();if(t&&t.length>0)return t;try{let i=await this.https.getCountries(e);return this.localStorage.setFootballCountries(i),i}catch(i){throw console.warn("There was a problem retrieving countries as football entities",i),i}}else return this.https.getCountries(e)}};var ft=class{countryId=null;name=null;gender=null;type=null;sortField=null;sortOrder=null;competitionIds=null;constructor(e){this.countryId=e.countryId?`${e.countryId}`:null,this.name=e.name?e.name:null,this.gender=e.gender?e.gender:null,this.type=e.type?e.type:null,this.sortField=e.sortField?`${e.sortField}`:null,this.sortOrder=e.sortOrder?`${e.sortOrder}`:null,this.competitionIds=e.competitionIds?e.competitionIds:null}constructFilterUrl=()=>{let e="";return this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.gender&&(e=e+"&",e=e+`gender=${this.gender}`),this.type&&(e=e+"&",e=e+`type=${this.type}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),this.name&&(e=e+"&",e=e+`name=${this.name}`),this.competitionIds&&(e=e+"&",e=e+`competition_ids=${this.competitionIds.join(",")}`),e};competitionSearchFilter=e=>{try{let t=this.filter(e);return this.sortField||this.sortOrder?this.sort(t):t}catch(t){return console.warn("There was a problem filtering the local competitions",t),[]}};filter=e=>{let t=this.entitiesToSearchWith();return e.filter(i=>{let r=!0;return t.forEach(o=>{o!=="sortOrder"&&o!=="sortField"&&(o==="countryId"?r&&=i.country.id===this[o]:o==="name"?r&&=i.name.toLocaleLowerCase().includes(this[o].toLocaleLowerCase()):o==="competitionIds"?r&&=this[o].some(s=>i.id===s):r&&=i[o].toLocaleLowerCase()===this[o].toLocaleLowerCase())}),r})};entitiesToSearchWith=()=>{let e=[];return this.countryId&&e.push("countryId"),this.name&&e.push("name"),this.gender&&e.push("gender"),this.type&&e.push("type"),this.sortField&&e.push("sortField"),this.sortOrder&&e.push("sortOrder"),this.competitionIds&&e.push("competitionIds"),e};sort=e=>{let t=[];return this.sortField==="name"?t=e.sort((i,r)=>this.sortOrder&&this.sortOrder==="desc"?r.name.localeCompare(i.name):i.name.localeCompare(r.name)):this.sortField==="country"?t=e.sort((i,r)=>this.sortOrder&&this.sortOrder==="desc"?r.country.name.localeCompare(i.country.name):i.country.name.localeCompare(r.country.name)):this.sortField==="scope"?e.forEach(i=>t[this.competitionIds.indexOf(i.id)]=i):!this.sortField&&this.sortOrder==="desc"&&(t=e.sort((i,r)=>r.id.localeCompare(i.id))),t}};var Jt=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,i){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=i,this.https=t}getCompetitionsIdMapping=async(e,t)=>{try{let i=!1;if(e){if(e=new ft(e),e.countryId){let o=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");o.country.length===0&&(i=!0),e.countryId=o.country[0]}if(e.competitionIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");o.competition.length===0&&(i=!0),e.competitionIds=o.competition}if(i)return[]}let r=await this.getCompetitions(e,t);return await this.idMapping.remapEntities(r,"competition")}catch(i){throw console.warn("There was a problem browsing all of the competitions",i),i}};getCompetitionsMapWithNativeIds=async e=>{let t=new Map,i=e.length,r=new ft({competitionIds:e,limit:i}),o=await this.getCompetitions(r);o.sort((n,c)=>n.id.localeCompare(c.id));let s=Ft(e),l=await this.idMapping.remapEntities(o,"competition");return s.forEach((n,c)=>t.set(n,l[c])),t};getCompetitions=async(e,t)=>{let i=null;if(t=t||!1,this.isBrowser){if(!this.localStorage.getCompetitionsLength()){try{i=await this.https.getCompetitions()}catch(r){throw console.warn("There was a problem retrieving all competitions",r),r}this.localStorage.setCompetitions(i)}return this.localStorage.getCompetitions(e)}else return this.https.getCompetitions(e,t)};getCompetitionByIdIdMapping=async(e,t)=>{try{let r=(await this.idMapping.getEntityIdsBySchemaId([e],"competition","native")).competition[0],o=await this.getCompetitionById(r,t);return await this.idMapping.remapEntities(o,"competition")}catch(i){throw console.warn(`There was a problem browsing the following competition:${e}`,i),i}};getCompetitionById=async(e,t)=>{try{return t=t||!1,await this.https.getCompetitionById(e,t)}catch(i){throw console.warn(`There was a problem retrieving the competition with the following id: ${e}`,i),i}};getTopCompetitionsIdMapping=async e=>{try{let t=await this.getTopCompetitions(e);return await this.idMapping.remapEntities(t,"competition")}catch(t){throw console.warn("There was a problem browsing the top competitions",t),t}};getTopCompetitions=async e=>{try{return e=e||!1,await this.https.getTopCompetitions(e)}catch(t){throw console.warn("There was a problem retrieving the top competitions",t),t}}};var gt=class{name=null;countryId=null;national=!1;gender=null;limit=null;page=null;scope=null;sortField=null;sortOrder=null;teamIds=null;constructor(e){this.name=e.name?e.name:null,this.countryId=e.countryId?`${e.countryId}`:null,this.national=e.national?e.national:!1,this.gender=e.gender?e.gender:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.scope=e.scope?e.scope:null,this.sortField=e.sortField?`${e.sortField}`:null,this.sortOrder=e.sortOrder?`${e.sortOrder}`:null,this.teamIds=e.teamIds?e.teamIds:null}constructFilterUrl=()=>{let e="";return this.name&&(e=e+"&",e=e+`name=${this.name}`),this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.national&&(e=e+"&",e=e+`national=${this.national}`),this.gender&&(e=e+"&",e=e+`gender=${this.gender}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),this.teamIds&&(e=e+"&",e=e+`team_ids=${this.teamIds.join(",")}`),e}};var Zt=class{general=[];predictor=[];topX=[];matchQuiz=[]};var Re=class{points=null;gameParticipationCount=null;entityId=null;entityType=null;predictionsMade=null;correctPredictions=null};var ei=class{id;label;assets={mainImageUrl:""};enabled;requirements=new Re};var ti=class{id;weight;multiplier;conditions};var ii=class{value=[new ti]};var Te=class{points=null;tiers=null;badges=null};var ri=class{enabled=!1;conditions={list:null};actions=new ii;rewards=new Te};var oi=class{general=null;comments=null;predictor=null;activity=null;topX=null;matchQuiz=null};var Se=class{enabled=!1;defaultMarkets=null;competitionsWhitelist=null};var ve=class{enabled=!1;minFixtures=null;maxFixtures=null;competitionsWhitelist=null};var ai=class{competitions=[];teams=[];markets=[]};var _e=class{enabled=!1;fullCoverageCompetitions=null;markets=null;successRateScopes=new ai};var si=class{remapPredictorConfig=e=>{let t=new _e;return t.enabled=e.enabled,t.fullCoverageCompetitions=e.full_coverage_competitions,t.markets=e.markets,t.successRateScopes=e.success_rate_scopes,t};remapTopXConfig=e=>{let t=new ve;return t.enabled=e.enabled,t.minFixtures=e.min_fixtures,t.maxFixtures=e.max_fixtures,t.competitionsWhitelist=e.competitions_whitelist,t};remapMatchQuizConfig=e=>{let t=new Se;return t.enabled=e.enabled,t.defaultMarkets=e.default_markets,t.competitionsWhitelist=e.competitions_whitelist,t};remapLoyaltyConfig=e=>{let t=new ri;return t.enabled=e.enabled,t.conditions.list=e.conditions.list,t.actions.value=e.actions.value,t.rewards=this.remapRewards(e.rewards),t};remapRewards=e=>{let t=new Te;return t.points=this.remapPoints(e.points),t.tiers=e.tiers,t.badges=this.remapBadges(e.badges),t};remapPoints=e=>{let t=new oi;return t.general=e.general,t.comments=e.comments,t.predictor=e.predictor,t.activity=e.activity,t.topX=e.top_x,t.matchQuiz=e.match_quiz,t};remapBadges=e=>{let t=new Zt;return t.general=e.general,t.predictor=this.remapBadgeValues(e.predictor),t.topX=this.remapBadgeValues(e.top_x),t.matchQuiz=this.remapBadgeValues(e.match_quiz),t};remapBadgeValues=e=>e.map(t=>{let i=new ei;return i.id=t.id,i.label=t.label,i.enabled=t.enabled,t.assets?i.assets.mainImageUrl=t.assets.main_image_url:i.assets=t.assets,i.requirements=this.remapRequirements(t.requirements),i});remapRequirements=e=>{let t=new Re;return t.points=e.points,t.gameParticipationCount=e.game_participation_count,t.entityId=e.entity_id,t.entityType=e.entity_type,t.predictionsMade=e.predictions_made,t.correctPredictions=e.correct_predictions,t}};var B=class extends E{featureConfigRemapper=null;localStorage=null;clientId=null;constructor(e){super(e,v(e.environment,"client"));this.clientId=e.clientId,this.localStorage=new L(e),this.featureConfigRemapper=new si}getConfig=async e=>{try{let t=this.getCachedFeatures();if(!t){let i=`/clients/${this.clientId}/features`,r=this.apiSignInUrl.split("&")[0];t=(await this.instance.get(`${i}${r}`)).data.data,this.localStorage.setClientFeatures(t)}switch(e){case"predictor":return this.featureConfigRemapper.remapPredictorConfig(t.predictor);case"topX":return this.featureConfigRemapper.remapTopXConfig(t.top_x);case"matchQuiz":return this.featureConfigRemapper.remapMatchQuizConfig(t.match_quiz);case"loyalty":return this.featureConfigRemapper.remapLoyaltyConfig(t.loyalty)}}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem fetching configuration from Client API",i),i.response}};getCachedFeatures=()=>{let e=this.getLocalStorageData();if(!(!e||!Object.keys(e).length))return e};getLocalStorageData=()=>{let e=Math.floor(Date.now()/1e3);return this.localStorage.getExpiration("client","features")>e?this.localStorage.getClientFeatures():null}};var ie=class{clientHttps=null;constructor(e){this.clientHttps=new B(e)}setAvailableMarketsForMatch=async e=>{let{fullCoverageCompetitions:t,markets:i}=await this.clientHttps.getConfig("predictor");if(Array.isArray(e))return e.map(r=>this.setAvailableMarkets(r,t,i));if(typeof e=="object"&&Object.keys(e).length)return this.setAvailableMarkets(e,t,i)};setAvailableMarkets=(e,t,i)=>{let r=e.context.competition?.id;return r&&this.isMatchInCoverageCompetition(r,t)?(e.availableMarkets=i.all,e):(e.availableMarkets=i.main,e)};isMatchInCoverageCompetition=(e,t)=>{let i=!1;return t.includes(e)&&(i=!0),i}};var li=class{footballService=null;https=null;idMapping=null;constructor(e,t,i){this.idMapping=i,this.https=t,this.footballService=new ie(e)}getTeamsIdMapping=async(e,t)=>{try{let i=!1;if(e){if(e=new gt(e),e.countryId){let o=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");o.country.length===0&&(i=!0),e.countryId=o.country[0]}if(e.scope){let o=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");o.competition.length===0&&(i=!0),e.scope=o.competition}if(e.teamIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");o.team.length===0&&(i=!0),e.teamIds=o.team}}if(i)return[];let r=await this.getTeams(e,t);return r.data=await this.idMapping.remapEntities(r.data,"team"),r}catch(i){throw console.warn("There was a problem browsing all teams",i),i}};getTeamsMapWithNativeIds=async e=>{let t=new Map,i=e.length,r=new gt({teamIds:e,limit:i}),{data:o}=await this.getTeams(r);o.sort((n,c)=>n.id.localeCompare(c.id));let s=Ft(e),l=await this.idMapping.remapEntities(o,"team");return s.forEach((n,c)=>t.set(n,l[c])),t};getTeams=async(e,t)=>{try{return t=t||!1,await this.https.getTeams(e,t)}catch(i){throw console.warn("There was a problem retrieving all teams",i),i}};getTeamByIdIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let r=await this.getTeamById(e,t);return await this.idMapping.remapEntities(r,"team")}catch(i){throw console.warn(`There was a problem browsing the following team:${e}`,i),i}};getTeamById=async(e,t)=>{try{return t=t||!1,await this.https.getTeamById(e,t)}catch(i){throw console.warn(`There was a problem retrieving the following team: ${e}`,i),i}};getTopTeamsIdMapping=async e=>{try{let t=await this.getTopTeams(e);return await this.idMapping.remapEntities(t,"team")}catch(t){throw console.warn("There was a problem browsing the top teams",t),t}};getTopTeams=async e=>{try{return e=e||!1,await this.https.getTopTeams(e)}catch(t){throw console.warn("There was a problem retrieving the top teams",t),t}};getNextMatchForTeamIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let r=await this.getNextMatchForTeam(e,t);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the next match for the following team:${e}`,i),i}};getNextMatchForTeam=async(e,t)=>{try{t=t||!1;let i=await this.https.getNextMatchForTeam(e,t);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the next match for the following team: ${e}`,i),i}};getPrevMatchForTeamIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let r=await this.getPrevMatchForTeam(e,t);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the previous match for the following team:${e}`,i),i}};getPrevMatchForTeam=async(e,t)=>{try{t=t||!1;let i=await this.https.getPrevMatchForTeam(e,t);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the previous match for the following team: ${e}`,i),i}}};var yt=class{countryId=null;scope=null;name=null;playerIds=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(e){this.countryId=e.countryId?e.countryId:null,this.scope=e.scope?e.scope:null,this.name=e.name?e.name:null,this.playerIds=e.playerIds?e.playerIds:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.sortField=e.sortField?e.sortField:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFilterUrl=()=>{let e="";return this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),this.name&&(e=e+"&",e=e+`name=${this.name}`),this.playerIds&&(e=e+"&",e=e+`player_ids=${this.playerIds.join(",")}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),e}};var re=class{https=null;footballService=null;idMapping=null;constructor(e,t,i){this.idMapping=i,this.https=t,this.footballService=new ie(e)}getPlayersIdMapping=async(e,t)=>{try{let i=!1;if(e){if(e=new yt(e),e.countryId){let o=await this.idMapping.getEntityIdsBySchemaId([e.countryId],"country","native");o.country.length===0&&(i=!0),e.countryId=o.country[0]}if(e.playerIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.playerIds,"player","native");o.player.length===0&&(i=!0),e.playerIds=o.player}if(e.scope){let o=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");o.competition.length===0&&(i=!0),e.scope=o.competition}if(i)return[]}let r=await this.getPlayers(e,t);return r.data=await this.idMapping.remapEntities(r.data,"player"),r}catch(i){throw console.warn("There was a problem browsing the players",i),i}};getPlayersWithNativeIds=async e=>{let t=e.length,i=new yt({playerIds:e,limit:t}),r=await this.getPlayers(i);return r.data.sort((o,s)=>o.id.localeCompare(s.id)),await this.idMapping.remapEntities(r.data,"player")};getPlayersMapWithNativeIds=async e=>{let t={},i=te(e);i.sort((o,s)=>o.localeCompare(s));let r=await this.getPlayersWithNativeIds(i);return i.forEach((o,s)=>t[o]=r[s]),t};getPlayers=async(e,t)=>{try{return t=t||!1,await this.https.getPlayers(e,t)}catch(i){throw console.warn("There was a problem retrieving the players",i),i}};getPlayerIdMapping=async(e,t)=>{try{let i=await this.idMapping.getEntityIdsBySchemaId([e],"player","native"),r=await this.getPlayerById(i.player[0],t);return await this.idMapping.remapEntities(r,"player")}catch(i){throw console.warn(`There was a problem browsing the following player:${e}`,i),i}};getPlayerById=async(e,t)=>{try{return t=t||!1,await this.https.getPlayerById(e,t)}catch(i){throw console.warn(`There was a problem retrieving the following player: ${e}`,i),i}};getTopPlayersIdMapping=async e=>{try{let t=await this.getTopPlayers(e);return await this.idMapping.remapEntities(t,"player")}catch(t){throw console.warn("There was a problem browsing the top players",t),t}};getTopPlayers=async e=>{try{return e=e||!1,await this.https.getTopPlayers(e)}catch(t){throw console.warn("There was a problem retrieving the top players",t),t}};getNextMatchForPlayerIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let r=await this.getNextMatchForPlayer(e,t);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the next match for player:${e}`,i),i}};getNextMatchForPlayer=async(e,t)=>{try{t=t||!1;let i=await this.https.getNextMatchForPlayer(e,t);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the next match for player: ${e}`,i),i}};getPrevMatchForPlayerIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let r=await this.getPrevMatchForPlayer(e,t);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the previous match for player:${e}`,i),i}};getPrevMatchForPlayer=async(e,t)=>{try{t=t||!1;let i=await this.https.getPrevMatchForPlayer(e,t);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the previous match for player: ${e}`,i),i}}};var Ce=class{countryIds=null;competitionIds=null;matchIds=null;status=null;teamIds=null;fromDate=null;toDate=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(e){this.countryIds=e.countryIds?e.countryIds:null,this.competitionIds=e.competitionIds?e.competitionIds:null,this.matchIds=e.matchIds?e.matchIds:null,this.status=e.status?e.status:null,this.teamIds=e.teamIds?e.teamIds:null,this.fromDate=e.fromDate?e.fromDate:null,this.toDate=e.toDate?e.toDate:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.sortField=e.sortField?e.sortField:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFilterUrl=()=>{let e="";return this.countryIds&&(e=e+"&",e=e+`countries=${this.countryIds.join(",")}`),this.competitionIds&&(e=e+"&",e=e+`competitions=${this.competitionIds.join(",")}`),this.matchIds&&(e=e+"&",e=e+`matches=${this.matchIds.join(",")}`),this.status&&(e=e+"&",e=e+`status=${this.status}`),this.teamIds&&(e=e+"&",e=e+`teams=${this.teamIds.join(",")}`),this.fromDate&&(e=e+"&",e=e+`from_date=${this.fromDate}`),this.toDate&&(e=e+"&",e=e+`to_date=${this.toDate}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),e}};var oe=class{https=null;idMapping=null;footballService=null;constructor(e,t,i){this.https=t,this.idMapping=i,this.footballService=new ie(e)}getMatchesIdMapping=async(e,t)=>{try{if(e){if(e=new Ce(e),e.countryIds){let r=await this.idMapping.getEntityIdsBySchemaId(e.countryIds,"country","native");e.countryIds=r.country}if(e.competitionIds){let r=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");e.competitionIds=r.competition}if(e.matchIds){let r=await this.idMapping.getEntityIdsBySchemaId(e.matchIds,"match","native");e.matchIds=r.match}if(e.teamIds){let r=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");e.teamIds=r.team}}let i=await this.getMatches(e,t);return i.data=await this.footballService.setAvailableMarketsForMatch([...i.data]),i.data=await this.idMapping.remapEntities(i.data,"match"),i}catch(i){throw console.warn("There was a problem browsing the matches",i),i}};getMatchesWithNativeIds=async e=>{let t=e.length,i=new Ce({matchIds:e,limit:t}),r=await this.getMatches(i);return r.data.sort((o,s)=>o.id.localeCompare(s.id)),await this.idMapping.remapEntities(r.data,"match")};getMatchesMapWithNativeIds=async e=>{let t={},i=te(e);i.sort((o,s)=>o.localeCompare(s));let r=await this.getMatchesWithNativeIds(i);if(i.length!==r.length){let o=new Ce({matchIds:i,limit:i.length}),s=await this.getMatches(o),l=i.filter(n=>{if(s.data.every(c=>c.id!==n))return n});i=i.filter(n=>{if(!l.includes(n))return n})}return i.forEach((o,s)=>t[o]=r[s]),t};getMatches=async(e,t)=>{try{return t=t||!1,await this.https.getMatches(e,t)}catch(i){throw console.warn("There was a problem retrieving the matches",i),i}};getMatchIdMapping=async(e,t)=>{try{let i=await this.idMapping.getEntityIdsBySchemaId([e],"match","native"),r=await this.getMatchById(i.match[0],t),o=await this.footballService.setAvailableMarketsForMatch(r);return await this.idMapping.remapEntities(o,"match")}catch(i){throw console.warn(`There was a problem browsing the following match: ${e}`,i),i}};getMatchById=async(e,t)=>{try{return t=t||!1,await this.https.getMatchById(e,t)}catch(i){throw console.warn(`There was a problem retrieving the following match: ${e}`,i),i}}};var pi=class{entities=null;query=null;scope=null;constructor(e){this.entities=e.entities?e.entities:null,this.query=e.query?e.query:null,this.scope=e.scope?e.scope:null}constructFilterUrl=()=>{let e="";return this.entities&&(e=e+"&",e=e+`entities=${this.entities.join(",")}`),this.query&&(e=e+"&",e=e+`q=${this.query}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),e}};var ci=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}searchIdMapping=async(e,t)=>{try{if(e=new pi(e),e.scope){let r=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");e.scope=r.competition}let i=await this.search(e,t);if(i.teams&&i.teams.length>0){let r=await this.idMapping.remapEntities(i.teams,"team");i.teams=r}if(i.players&&i.players.length>0){let r=await this.idMapping.remapEntities(i.players,"player");i.players=r}if(i.competitions&&i.competitions.length>0){let r=await this.idMapping.remapEntities(i.competitions,"competition");i.competitions=r}return i}catch(i){throw console.warn("There was a problem with browsing the search result",i),i}};search=async(e,t)=>{try{return await this.https.search(e,t)}catch(i){throw console.warn("There was a problem retrieving the search response",i),i}}};var Ae=class{countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(e,t,i,r){this.countriesFacade=new zt(t,i,r),this.competitionsFacade=new Jt(t,i,r),this.teamsFacade=new li(e,i,r),this.playerFacade=new re(e,i,r),this.matchFacade=new oe(e,i,r),this.searchFacade=new ci(i,r)}getCountries=async e=>this.countriesFacade.getCountriesWithIdMapping(e);getCompetitions=async(e,t)=>this.competitionsFacade.getCompetitionsIdMapping(e,t);getCompetitionById=async(e,t)=>this.competitionsFacade.getCompetitionByIdIdMapping(e,t);getTopCompetitions=async e=>this.competitionsFacade.getTopCompetitionsIdMapping(e);getCompetitionsMapWithNativeIds=async e=>await this.competitionsFacade.getCompetitionsMapWithNativeIds(e);getTeams=async(e,t)=>this.teamsFacade.getTeamsIdMapping(e,t);getTeamById=async(e,t)=>this.teamsFacade.getTeamByIdIdMapping(e,t);getTopTeams=async e=>this.teamsFacade.getTopTeamsIdMapping(e);getNextMatchForTeam=async(e,t)=>this.teamsFacade.getNextMatchForTeamIdMapping(e,t);getPrevMatchForTeam=async(e,t)=>this.teamsFacade.getPrevMatchForTeamIdMapping(e,t);getTeamsMapWithNativeIds=async e=>await this.teamsFacade.getTeamsMapWithNativeIds(e);getPlayers=async(e,t)=>this.playerFacade.getPlayersIdMapping(e,t);getPlayerById=async(e,t)=>this.playerFacade.getPlayerIdMapping(e,t);getTopPlayers=async e=>this.playerFacade.getTopPlayersIdMapping(e);getNextMatchForPlayer=async(e,t)=>this.playerFacade.getNextMatchForPlayerIdMapping(e,t);getPrevMatchForPlayer=async(e,t)=>this.playerFacade.getPrevMatchForPlayerIdMapping(e,t);getPlayersMapWithNativeIds=async e=>this.playerFacade.getPlayersMapWithNativeIds(e);getMatches=async(e,t)=>this.matchFacade.getMatchesIdMapping(e,t);getMatchById=async(e,t)=>this.matchFacade.getMatchIdMapping(e,t);search=async(e,t)=>this.searchFacade.searchIdMapping(e,t)};var mi=class{id="";alias="";countryCode="";assets=null;name=""};var w=class{countriesFromResponse=e=>{if(e)return e.map(t=>this.countryFromResponse(t))};countryFromResponse=e=>{try{if(e){let t=new mi;return t.id=e.id,t.alias=e.alias,t.assets=e.assets,t.countryCode=e.country_code,t.name=e.name,t}}catch(t){throw t}return null}};var di=class{id="";country=null;gender="";assets=null;type="";name=""};var A=class{countryRemapper=null;constructor(){this.countryRemapper=new w}fromResponse(e){try{let t=new di;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var ui=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var hi=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName="";isDeleted=!1};var R=class{countryRemapper=null;constructor(){this.countryRemapper=new w}fromResponse(e){try{let t=new hi;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t.isDeleted=e.is_deleted,t}catch(t){throw console.warn("There was a problem remapping teams response",t),t}}};var fi=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new w,this.teamBasicRemapper=new R}fromResponse(e){try{let t=new ui;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t.participants=e.participants.map(i=>this.teamBasicRemapper.fromResponse(i)),t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var gi=class{primary=null;secondary=null;tertiary=null};var yi=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";isDeleted=!1;colors=new gi;squad=[]};var Mi=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var bi=class{countryRemapper=null;constructor(){this.countryRemapper=new w}fromResponse(e){try{let t=new Mi;return t.id=e.id,t.startDate=e.start_date,t.endDate=e.end_date,t.shirtNumber=e.shirt_number,t.loan=e.loan,t.position=e.position,t.country=this.countryRemapper.countryFromResponse(e.country),t.name=e.name,t.assets=e.assets,t.birthDate=e.birth_date,t}catch(t){throw console.warn("There was a problem remapping the player from squad",t),t}}};var wi=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new w,this.competitionRemapper=new A,this.playerRemapper=new bi}fromResponse(e){try{let t=new yi;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t.isDeleted=e.is_deleted,t.competitions=e.competitions?e.competitions.map(i=>this.competitionRemapper.fromResponse(i)):[],t.colors=e.colors?e.colors:t.colors,t.squad=e.squad?e.squad.map(i=>this.playerRemapper.fromResponse(i)):[],t}catch(t){throw console.warn("There was a problem remapping team response",t),t}}};var Ii=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;homeTeam=null;awayTeam=null;isDeleted=!1;lineupsConfirmed=!1;startedAt="";minute="";scores=null;context={competition:null};status={type:null,subType:null}};var Fi=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var xe=class{fromResponse(e){try{let t=new Fi;return t.ftScore=this.statEntityFromResponse(e.ft_score),t.htScore=this.statEntityFromResponse(e.ht_score),t.aetScore=this.statEntityFromResponse(e.aet_score),t.aggScore=this.statEntityFromResponse(e.agg_score),t.penScore=this.statEntityFromResponse(e.pen_score),t}catch(t){throw console.warn("There was a problem remapping the scores",t),t}}statEntityFromResponse=e=>({homeGoals:e.home_goals,awayGoals:e.away_goals})};var Pi=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new R,this.competitionRemapper=new A,this.scoresRemapper=new xe}fromResponse(e){try{let t=new Ii;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.isDeleted=e.is_deleted,t.homeTeam=this.teamRemapper.fromResponse(e.home_team),t.awayTeam=this.teamRemapper.fromResponse(e.away_team),t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresRemapper.fromResponse(e.scores),t.context={competition:e.context.competition?this.competitionRemapper.fromResponse(e.context.competition):null},t.status={type:e.status.type,subType:e.status.sub_type},t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var N=class{type=null;subType=null};var Ei=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;isDeleted=!1;homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;stats=null;context={competition:null};timeline=[];status=new N;lineups=null};var Ri=class{corners=null;cornersFirstHalf=null;cornersSecondHalf=null;cornersExtraTime=null;crosses=null;crossesFirstHalf=null;crossesSecondHalf=null;crossesExtraTime=null;offside=null;offsideFirstHalf=null;offsideSecondHalf=null;offsideExtraTime=null;shotsOn=null;shotsOnFirstHalf=null;shotsOnSecondHalf=null;shotsOnExtraTime=null;throwIn=null;throwInFirstHalf=null;throwInSecondHalf=null;throwInExtraTime=null;redCards=null;redCardsFirstHalf=null;redCardsSecondHalf=null;redCardsExtraTime=null;shotsOff=null;shotsOffFirstHalf=null;shotsOffSecondHalf=null;shotsOffExtraTime=null;goalKicks=null;goalKicksFirstHalf=null;goalKicksSecondHalf=null;goalKicksExtraTime=null;possession=null;possessionFirstHalf=null;possessionSecondHalf=null;possessionExtraTime=null;treatments=null;treatmentsFirstHalf=null;treatmentsSecondHalf=null;treatmentsExtraTime=null;yellowCards=null;yellowCardsFirstHalf=null;yellowCardsSecondHalf=null;yellowCardsExtraTime=null;shotsBlocked=null;shotsBlockedFirstHalf=null;shotsBlockedSecondHalf=null;shotsBlockedExtraTime=null;substitutions=null;substitutionsFirstHalf=null;substitutionsSecondHalf=null;substitutionsExtraTime=null;counterAttacks=null;counterAttacksFirstHalf=null;counterAttacksSecondHalf=null;counterAttacksExtraTime=null;foulsCommitted=null;foulsCommittedFirstHalf=null;foulsCommittedSecondHalf=null;foulsCommittedExtraTime=null};var Ti=class{fromResponse(e){try{let t=new Ri;return t.corners=this.statEntityFromResponse(e.corners),t.cornersFirstHalf=this.statEntityFromResponse(e.corners_1h),t.cornersSecondHalf=this.statEntityFromResponse(e.corners_2h),t.cornersExtraTime=this.statEntityFromResponse(e.corners_et),t.crosses=this.statEntityFromResponse(e.crosses),t.crossesFirstHalf=this.statEntityFromResponse(e.crosses_1h),t.crossesSecondHalf=this.statEntityFromResponse(e.crosses_2h),t.crossesExtraTime=this.statEntityFromResponse(e.crosses_et),t.offside=this.statEntityFromResponse(e.offside),t.offsideFirstHalf=this.statEntityFromResponse(e.offside_1h),t.offsideSecondHalf=this.statEntityFromResponse(e.offside_2h),t.offsideExtraTime=this.statEntityFromResponse(e.offside_et),t.shotsOn=this.statEntityFromResponse(e.shots_on),t.shotsOnFirstHalf=this.statEntityFromResponse(e.shots_on_1h),t.shotsOnSecondHalf=this.statEntityFromResponse(e.shots_on_2h),t.shotsOnExtraTime=this.statEntityFromResponse(e.shots_on_et),t.throwIn=this.statEntityFromResponse(e.throw_in),t.throwInFirstHalf=this.statEntityFromResponse(e.throw_in_1h),t.throwInSecondHalf=this.statEntityFromResponse(e.throw_in_2h),t.throwInExtraTime=this.statEntityFromResponse(e.throw_in_et),t.redCards=this.statEntityFromResponse(e.red_cards),t.redCardsFirstHalf=this.statEntityFromResponse(e.red_cards_1h),t.redCardsSecondHalf=this.statEntityFromResponse(e.red_cards_2h),t.redCardsExtraTime=this.statEntityFromResponse(e.red_cards_et),t.shotsOff=this.statEntityFromResponse(e.shots_off),t.shotsOffFirstHalf=this.statEntityFromResponse(e.shots_off_1h),t.shotsOffSecondHalf=this.statEntityFromResponse(e.shots_off_2h),t.shotsOffExtraTime=this.statEntityFromResponse(e.shots_off_et),t.goalKicks=this.statEntityFromResponse(e.goal_kicks),t.goalKicksFirstHalf=this.statEntityFromResponse(e.goal_kicks_1h),t.goalKicksSecondHalf=this.statEntityFromResponse(e.goal_kicks_2h),t.goalKicksExtraTime=this.statEntityFromResponse(e.goal_kicks_et),t.possession=this.statEntityFromResponse(e.possession),t.possessionFirstHalf=this.statEntityFromResponse(e.possession_1h),t.possessionSecondHalf=this.statEntityFromResponse(e.possession_2h),t.possessionExtraTime=this.statEntityFromResponse(e.possession_et),t.treatments=this.statEntityFromResponse(e.treatments),t.treatmentsFirstHalf=this.statEntityFromResponse(e.treatments_1h),t.treatmentsSecondHalf=this.statEntityFromResponse(e.treatments_2h),t.treatmentsExtraTime=this.statEntityFromResponse(e.treatments_et),t.yellowCards=this.statEntityFromResponse(e.yellow_cards),t.yellowCardsFirstHalf=this.statEntityFromResponse(e.yellow_cards_1h),t.yellowCardsSecondHalf=this.statEntityFromResponse(e.yellow_cards_2h),t.yellowCardsExtraTime=this.statEntityFromResponse(e.yellow_cards_et),t.shotsBlocked=this.statEntityFromResponse(e.shots_blocked),t.shotsBlockedFirstHalf=this.statEntityFromResponse(e.shots_blocked_1h),t.shotsBlockedSecondHalf=this.statEntityFromResponse(e.shots_blocked_2h),t.shotsBlockedExtraTime=this.statEntityFromResponse(e.shots_blocked_et),t.substitutions=this.statEntityFromResponse(e.substitutions),t.substitutionsFirstHalf=this.statEntityFromResponse(e.substitutions_1h),t.substitutionsSecondHalf=this.statEntityFromResponse(e.substitutions_2h),t.substitutionsExtraTime=this.statEntityFromResponse(e.substitutions_et),t.counterAttacks=this.statEntityFromResponse(e.counter_attacks),t.counterAttacksFirstHalf=this.statEntityFromResponse(e.counter_attacks_1h),t.counterAttacksSecondHalf=this.statEntityFromResponse(e.counter_attacks_2h),t.counterAttacksExtraTime=this.statEntityFromResponse(e.counter_attacks_et),t.foulsCommitted=this.statEntityFromResponse(e.fouls_committed),t.foulsCommittedFirstHalf=this.statEntityFromResponse(e.fouls_committed_1h),t.foulsCommittedSecondHalf=this.statEntityFromResponse(e.fouls_committed_2h),t.foulsCommittedExtraTime=this.statEntityFromResponse(e.fouls_committed_et),t}catch(t){throw console.warn("There was a problem remapping the stats",t),t}}statEntityFromResponse=e=>({homeTeam:e?e.home_team:null,awayTeam:e?e.away_team:null})};var Oe=class{homeTeam={players:[]};awayTeam={players:[]}};var Si=class{id="";name="";position="";shirtNumber;assets=null;type=""};var De=class{fromResponse(e){try{let t=new Si;return t.id=e.id,t.name=e.name,t.position=e.position,t.shirtNumber=e.shirt_number,t.assets=e.assets,t.type=e.type,t}catch(t){throw console.warn("There was a problem remapping the player from timeline",t),t}}};var vi=class{playerRemapper=null;constructor(){this.playerRemapper=new De}fromResponse(e){try{let t=new Oe;return t.homeTeam.players=e.home_team&&e.home_team.players?e.home_team.players.map(i=>this.playerRemapper.fromResponse(i)):[],t.awayTeam.players=e.away_team&&e.away_team.players?e.away_team.players.map(i=>this.playerRemapper.fromResponse(i)):[],t}catch(t){throw console.warn("There was a problem remapping the lineups",t),t}}};var _i=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var Ci=class{playerRemapper=null;constructor(){this.playerRemapper=new De}fromResponse(e){try{let t=new _i;return t.minute=e.minute,t.type=e.type,t.teamId=e.team_id,t.player=this.playerRemapper.fromResponse(e.player),t.relatedPlayer=e.related_player?this.playerRemapper.fromResponse(e.related_player):null,t.updatedAt=e.updated_at,t}catch(t){throw console.warn("There was a problem remapping timeline",t),t}}};var Ai=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new R,this.competitionsMapper=new A,this.lineupsMapper=new vi,this.scoresMapper=new xe,this.statsMapper=new Ti,this.timelineMapper=new Ci}fromResponse(e){try{let t=new Ei;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.isDeleted=e.is_deleted,t.homeTeam=e.home_team?this.teamMapper.fromResponse(e.home_team):null,t.awayTeam=e.away_team?this.teamMapper.fromResponse(e.away_team):null,t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresMapper.fromResponse(e.scores),t.stats=this.statsMapper.fromResponse(e.stats),t.context={competition:this.competitionsMapper.fromResponse(e.context.competition)},t.timeline=e.timeline?e.timeline.map(i=>this.timelineMapper.fromResponse(i)):[],t.status={type:e.status.type,subType:e.status.sub_type},t.lineups=e.lineups?this.lineupsMapper.fromResponse(e.lineups):new Oe,t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var xi=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var Oi=class{countryRemapper=null;constructor(){this.countryRemapper=new w}fromResponse(e){try{let t=new xi;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping top player response",t),t}}};var Di=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;teams=[]};var Le=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new w,this.teamRemapper=new R}fromResponse(e){try{let t=new Di;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(i=>this.teamRemapper.fromResponse(i)):[],t.position=e.position,t.isDeleted=e.is_deleted,t}catch(t){throw console.warn("There was a problem remapping players response",t),t}}};var Li=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;competitions=[];teams=[]};var Bi=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new w,this.teamRemapper=new R,this.competitionRemapper=new A}fromResponse(e){try{let t=new Li;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(i=>this.teamRemapper.fromResponse(i)):[],t.position=e.position,t.isDeleted=e.is_deleted,t.competitions=e.competitions?e.competitions.map(i=>this.competitionRemapper.fromResponse(i)):[],t}catch(t){throw console.warn("There was a problem remapping player response",t),t}}};var Ni=class{teams=null;players=null;competitions=null};var Ui=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new R,this.playerRemapper=new Le,this.competitionremapper=new A}fromResponse(e){try{let t=new Ni;return t.teams=e.teams?e.teams.map(i=>this.teamRemapper.fromResponse(i)):[],t.players=e.players?e.players.map(i=>this.playerRemapper.fromResponse(i)):[],t.competitions=e.competitions?e.competitions.map(i=>this.competitionremapper.fromResponse(i)):[],t}catch(t){throw console.warn("There was a problem remapping search response",t),t}}};var Be=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var X=class{pagination=new Be};var Ne=class{meta=new X;data=[]};var Hi=class{remapMetaProp=e=>{let t=new X;return t.pagination.currentPage=e.pagination.current_page,t.pagination.itemsPerPage=e.pagination.items_per_page,t.pagination.totalItems=e.pagination.total_items,t.pagination.numberOfPages=e.pagination.number_of_pages,t}};var W=class extends E{limitIds=200;countryRemapper=null;competitionBasicRemapper=null;competitionFullRemapper=null;teamBasicRemapper=null;teamFullRemapper=null;matchBasicRemapper=null;matchFullRemapper=null;playerBasicRemapper=null;playerFullRemapper=null;topPlayerRemapper=null;searchRemapper=null;footballMetaRemapper=null;constructor(e){super(e,v(e.environment,"football"));this.apiSignInUrl=e.lang!=="en"?this.apiSignInUrl+`&lang=${e.lang}`:this.apiSignInUrl,this.countryRemapper=new w,this.competitionBasicRemapper=new A,this.competitionFullRemapper=new fi,this.teamBasicRemapper=new R,this.teamFullRemapper=new wi,this.matchBasicRemapper=new Pi,this.matchFullRemapper=new Ai,this.playerBasicRemapper=new Le,this.playerFullRemapper=new Bi,this.topPlayerRemapper=new Oi,this.searchRemapper=new Ui,this.footballMetaRemapper=new Hi}getCountries=async e=>{try{let t=`/countries${this.apiSignInUrl}`,i=Date.now();e&&(t+=`&disable_cache=${i}`);let r=await this.instance.get(t);return this.countryRemapper.countriesFromResponse(r.data.data)}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem with the football countries request",i),i.response}};getCompetitions=async(e,t)=>{try{let i={},r=Date.now();if(t=t||!1,e&&e.competitionIds&&e.competitionIds.length>this.limitIds-1){let o=[],s=Me(e.competitionIds,this.limitIds);for(let n of s){e.competitionIds=n;let c=`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(c+=`&disable_cache=${r}`),i=await this.instance.get(c),o.push(i.data.data.map(p=>this.competitionBasicRemapper.fromResponse(p)))}return Array.prototype.concat.apply([],o)}else{let o=`/competitions${this.apiSignInUrl}`;return e&&(o+=`${e.constructFilterUrl()}`),t&&(o+=`&disable_cache=${r}`),i=await this.instance.get(o),i.data.data.map(s=>this.competitionBasicRemapper.fromResponse(s))}}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getCompetitions request",r),r.response}};getCompetitionById=async(e,t)=>{try{let i=`/competitions/${e}${this.apiSignInUrl}`,r=Date.now();t&&(i+=`&disable_cache=${r}`);let o=await this.instance.get(i);return this.competitionFullRemapper.fromResponse(o.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getCompetitionById request",r),r.response}};getTopCompetitions=async e=>{try{let t=`/competitions/top${this.apiSignInUrl}`,i=Date.now();return e&&(t+=`&disable_cache=${i}`),(await this.instance.get(t)).data.data.map(o=>this.competitionBasicRemapper.fromResponse(o))}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem with getTopCompetitions request",i),i.response}};getTeams=async(e,t)=>{try{let i={},r=Date.now();if(e&&e.teamIds&&e.teamIds.length>this.limitIds){let o=[],s=Me(e.teamIds,this.limitIds);for(let n of s){e.teamIds=n;let c=`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(c+=`disable_cache=${r}`),i=await this.instance.get(c),o.push(i.data.data.map(p=>this.teamBasicRemapper.fromResponse(p)))}return Array.prototype.concat.apply([],o)}else{let o=new Ne,s=`/teams${this.apiSignInUrl}`;return e&&(s+=`${e.constructFilterUrl()}`),t&&(s+=`&disable_cache=${r}`),i=await this.instance.get(s),o.meta=this.footballMetaRemapper.remapMetaProp(i.data.meta),o.data=i.data.data.map(l=>this.teamBasicRemapper.fromResponse(l)),o}}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getTeams request",r),r.response}};getTeamById=async(e,t)=>{try{let i=`/teams/${e}${this.apiSignInUrl}`,r=Date.now();t&&(i+=`disable_cache=${r}`);let o=await this.instance.get(i);return this.teamFullRemapper.fromResponse(o.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getTeamById request",r),r.response}};getTopTeams=async e=>{try{let t=`/teams/top${this.apiSignInUrl}`,i=Date.now();e&&(t+=`$disable_cache=${i}`);let r=await this.instance.get(t);return r.data.data?r.data.data.map(o=>this.teamBasicRemapper.fromResponse(o)):[]}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem with getTopTeams request",i),i.response}};getNextMatchForTeam=async(e,t)=>{try{let i=`/teams/${e}/next-match${this.apiSignInUrl}`,r=Date.now();t&&(i+=`&disable_cache=${r}`);let o=await this.instance.get(i);return this.matchFullRemapper.fromResponse(o.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getNextMatchForTeam request",r),r.response}};getPrevMatchForTeam=async(e,t)=>{try{let i=`/teams/${e}/previous-match${this.apiSignInUrl}`,r=Date.now();t&&(i+=`disable_cache=${r}`);let o=await this.instance.get(i);return this.matchFullRemapper.fromResponse(o.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getPrevMatchForTeam request",r),r.response}};getPlayers=async(e,t)=>{try{let i={},r=Date.now();if(e&&e.playerIds&&e.playerIds.length>this.limitIds-1){let o=[],s=Me(e.playerIds,this.limitIds);for(let n of s){e.playerIds=n;let c=`/players${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(c+=`&disable_cache=${r}`),i=await this.instance.get(c),o.push(i.data.data.map(p=>this.teamBasicRemapper.fromResponse(p)))}return Array.prototype.concat.apply([],o)}else{let o=new Ne,s=`/players${this.apiSignInUrl}`;return e&&(s+=`${e.constructFilterUrl()}`),t&&(s+=`&disable_cache=${r}`),i=await this.instance.get(s),o.meta=this.footballMetaRemapper.remapMetaProp(i.data.meta),o.data=i.data.data.map(l=>this.playerBasicRemapper.fromResponse(l)),o}}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getPlayers request",r),r.response}};getPlayerById=async(e,t)=>{try{let i=`/players/${e}${this.apiSignInUrl}`,r=Date.now();t&&(i+=`&disable_cache=${r}`);let o=await this.instance.get(i);return this.playerFullRemapper.fromResponse(o.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getPlayerById request",r),r.response}};getTopPlayers=async e=>{try{let t=`/players/top${this.apiSignInUrl}`,i=Date.now();return e&&(t+=`&disable_cache=${i}`),(await this.instance.get(t)).data.data.map(o=>this.topPlayerRemapper.fromResponse(o))}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem with getTopPlayers request",i),i.response}};getNextMatchForPlayer=async(e,t)=>{try{let i=`/players/${e}/next-match${this.apiSignInUrl}`,r=Date.now();t&&(i+=`&disable_cache=${r}`);let o=await this.instance.get(i);return this.matchFullRemapper.fromResponse(o.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getNextMatchForPlayer request",r),r.response}};getPrevMatchForPlayer=async(e,t)=>{try{let i=`/players/${e}/previous-match${this.apiSignInUrl}`,r=Date.now();t&&(i+=`&disable_cache=${r}`);let o=await this.instance.get(i);return this.matchFullRemapper.fromResponse(o.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getPrevMatchForPlayer request",r),r.response}};getMatchById=async(e,t)=>{try{let i=`/matches/${e}${this.apiSignInUrl}`,r=Date.now();t&&(i+=`&disable_cache=${r}`);let o=await this.instance.get(i);return this.matchFullRemapper.fromResponse(o.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getMatchById request",r),r.response}};getMatches=async(e,t)=>{try{let i=new Ne,r=`/matches${this.apiSignInUrl}`,o=Date.now();e&&(r+=`${e.constructFilterUrl()}`),t&&(r+=`&disable_cache=${o}`);let s=await this.instance.get(r);return i.meta=this.footballMetaRemapper.remapMetaProp(s.data.meta),i.data=s.data.data.map(l=>this.matchBasicRemapper.fromResponse(l)),i}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getMatches request",r),r.response}};search=async(e,t)=>{try{let i=`/search${this.apiSignInUrl}${e.constructFilterUrl()}`,r=Date.now();t&&(i+=`&disable_cache=${r}`);let o=await this.instance.get(i);return this.searchRemapper.fromResponse(o.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with search request",r),r.response}}};var T=(u=>(u.FT_1X2="FT_1X2",u.HT_1X2="HT_1X2",u.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",u.DOUBLE_CHANCE="DOUBLE_CHANCE",u.HT_FT="HT_FT",u.PLAYER_SCORE="PLAYER_SCORE",u.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",u.PLAYER_RED_CARD="PLAYER_RED_CARD",u.RED_CARD_MATCH="RED_CARD_MATCH",u.PENALTY_MATCH="PENALTY_MATCH",u.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",u.CORNERS_MATCH="CORNERS_MATCH",u.CORRECT_SCORE="CORRECT_SCORE",u.CORRECT_SCORE_ADVANCED="CORRECT_SCORE_ADVANCED",u.CORRECT_SCORE_HT="CORRECT_SCORE_HT",u.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",u.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",u.OVER_GOALS_0_5="OVER_GOALS_0_5",u.OVER_GOALS_1_5="OVER_GOALS_1_5",u.OVER_GOALS_2_5="OVER_GOALS_2_5",u.OVER_GOALS_3_5="OVER_GOALS_3_5",u.OVER_GOALS_4_5="OVER_GOALS_4_5",u.OVER_GOALS_5_5="OVER_GOALS_5_5",u.OVER_GOALS_6_5="OVER_GOALS_6_5",u.OVER_CORNERS_6_5="OVER_CORNERS_6_5",u.OVER_CORNERS_7_5="OVER_CORNERS_7_5",u.OVER_CORNERS_8_5="OVER_CORNERS_8_5",u.OVER_CORNERS_9_5="OVER_CORNERS_9_5",u.OVER_CORNERS_10_5="OVER_CORNERS_10_5",u.OVER_CORNERS_11_5="OVER_CORNERS_11_5",u.OVER_CORNERS_12_5="OVER_CORNERS_12_5",u.OVER_CORNERS_13_5="OVER_CORNERS_13_5",u))(T||{}),is=["OVER_GOALS_0_5","OVER_GOALS_1_5","OVER_GOALS_2_5","OVER_GOALS_3_5","OVER_GOALS_4_5","OVER_GOALS_5_5","OVER_GOALS_6_5"],rs=["OVER_CORNERS_6_5","OVER_CORNERS_7_5","OVER_CORNERS_8_5","OVER_CORNERS_9_5","OVER_CORNERS_10_5","OVER_CORNERS_11_5","OVER_CORNERS_12_5","OVER_CORNERS_13_5"],V=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"],os=["FT_1X2","HT_1X2","HT_FT","DOUBLE_CHANCE","CORNERS_MATCH","CORRECT_SCORE","CORRECT_SCORE_HT","CORRECT_SCORE_ADVANCED"],Ue="PLAYER_SCORE_FIRST_GOAL";var ki=class{overallPercent;byFootballCompetition;byFootballTeam;byFootballMarket};var Gi=class{profileId;tier;points;successRates=new ki};var Vi=class{successRatePercent;model=null};var He=class{content=null;tags=[];campaign=null};var ke=class{id=null;profileId=null;property=null;value=null;action=null;context=new He;points=0};var $i=class{meta=new X;data=[new ke]};var qi=class{remapSingleResponse=e=>{let t=new ke;return t.id=e.id,t.profileId=e.profile_id,t.property=e.property,t.value=e.value,t.action=e.action,t.context.content=e.context.content,t.context.tags=e.context.tags,t.context.campaign=e.context.campaign,t.points=e.points,t};remapActivitiesResponse=e=>{let t=new $i;return t.meta.pagination.currentPage=e.meta.pagination.current_page,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.meta.pagination.numberOfPages=e.meta.pagination.number_of_pages,t.meta.pagination.totalItems=e.meta.pagination.total_items,t.data=e.data.map(i=>this.remapSingleResponse(i)),t};remapStatsReponse=e=>{let t=new Gi;return t.profileId=e.profile_id,t.tier=e.tier,t.points=e.points,t.successRates.overallPercent=e.success_rates.overall_percent,t.successRates.byFootballCompetition=this.constructNewRecord(e.success_rates.by_competition),t.successRates.byFootballTeam=this.constructNewRecord(e.success_rates.by_team),t.successRates.byFootballMarket=this.constructNewRecord(e.success_rates.by_market),t};constructNewRecord=e=>{let t;if(Object.entries(e).length)Object.entries(e).forEach(([i,r])=>{t={...t,[i]:this.remapSuccessRatePercent(r)},T[i]&&delete t[i].model});else return e;return t};remapSuccessRatePercent=e=>{let t=new Vi;return t.successRatePercent=e.success_rate_percent,t}};var Ge=class extends E{activityRemapper=null;constructor(e){super(e,v(e.environment,"loyalty"));this.activityRemapper=new qi}createActivity=async e=>{try{let t=`/activities${this.apiSignInUrl}`,i=await this.instanceAuth.post(t,JSON.stringify(e));return this.activityRemapper.remapSingleResponse(i.data)}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem with creating activity for user",i),i.response}};deleteActivity=async e=>{try{let t=`/activities/${e}${this.apiSignInUrl}`;return await this.instanceAuth.delete(t),!0}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn(`There was a problem deleting the following activity: ${e}`,i),i.response}};getOwnActivities=async(e,t)=>{try{let i=`/activities${this.apiSignInUrl}`,r=Date.now();e&&(i+=`${e.constructFilterUrl()}`),t&&(i+=`disable_cache=${r}`);let o=await this.instanceAuth.get(i);return this.activityRemapper.remapActivitiesResponse(o.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with fetching own activities",r),r.response}};getActivitiesForUser=async(e,t,i)=>{try{let r=`/users/${e}/activities${this.apiSignInUrl}`,o=Date.now();t&&(r+=`${t.constructFilterUrl()}`),i&&(r+=`disable_cache=${o}`);let s=await this.instance.get(r);return this.activityRemapper.remapActivitiesResponse(s.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn(`There was a problem with fetching activities for user ${e}`,o),o.response}};getStats=async(e,t)=>{try{let i="",r=null;return e?(i+=I(t)?`/users/${e}/statistics${this.apiSignInUrl}${F()}`:`/users/${e}/statistics${this.apiSignInUrl}`,r=await this.instance.get(i)):(i+=`/statistics${this.apiSignInUrl}`,r=await this.instanceAuth.get(i)),this.activityRemapper.remapStatsReponse(r.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem fetching profile`s statistics:",r),r.response}}};var ji=class{id="";source="";type="";favourite=!1};var Xi=class extends ji{model=null};var Wi=class{idMapping=null;idSchema=null;native="native";footballFacade=null;constructor(e,t,i){this.idMapping=i,this.idSchema=e.idSchema,this.footballFacade=t}remapSuccessRatesEntities=async e=>{let{successRates:t}=e,i={competition:this.getIdsKeys(t.byFootballCompetition),team:this.getIdsKeys(t.byFootballTeam)};if(Object.values(i.competition).length){let r=e.successRates.byFootballCompetition;e.successRates.byFootballCompetition=await this.setModels(r,i.competition,"competition")}if(Object.values(i.team).length){let r=e.successRates.byFootballTeam;e.successRates.byFootballTeam=await this.setModels(r,i.team,"team")}return e};setModels=async(e,t,i)=>{let r=null,o;switch(i){case"competition":r=await this.footballFacade.getCompetitionsMapWithNativeIds(t);break;case"team":r=await this.footballFacade.getTeamsMapWithNativeIds(t);break}return Object.keys(e).forEach(s=>{let l=r.get(s);o={...o,[l.id]:e[s]},o[l.id].model=l}),o};getIdsKeys=e=>{let t=JSON.parse(JSON.stringify(e));return Object.keys(t)};remapInterestsToIdSchema=async e=>{if(this.idSchema!==this.native)if(e&&e.length>0){let t={},i={},r=e.filter(n=>n.source.toLocaleUpperCase()==="FOOTBALL"),o=e.filter(n=>n.source.toLocaleUpperCase()!=="FOOTBALL");r.forEach(n=>{t.hasOwnProperty(n.type)||(t[n.type]=[],i[n.type]=[]),t[n.type].push(n.id),i[n.type].push(n)});let s=await this.remapIdsObj(t,this.native,this.idSchema),l=[];for(let[n,c]of Object.entries(i))c.forEach((p,m)=>{p.id=s[n][m],l.push(p)});return l.concat(o)}else return e;return e};remapInterestToNative=async e=>{if(this.idSchema!==this.native&&e.source.toLocaleUpperCase()==="FOOTBALL"){let t={},{id:i,type:r}=e;t[r]=[i];let o=await this.remapIdsObj(t,this.idSchema,this.native);return e.id=o[r][0],e}return e};inquiryCustomInterests=(e,t)=>{let i=[];return e&&e.length>0&&(i=e.filter(r=>r.source.toLocaleUpperCase()==="CUSTOM"),t)?i.map(r=>{let o=new Xi;return o.id=r.id,o.type=r.type,o.source=r.source,o.favourite=r.favourite,o}):i};remapInterests=async e=>{let t=!1,i=this.inquiryCustomInterests(e,t);if(i&&i.length>0){let r=e.filter(s=>s.source.toLocaleUpperCase()!=="CUSTOM"),o=await this.remapInterestsToIdSchema(r);return i.forEach(s=>o.push(s)),o}return await this.remapInterestsToIdSchema(e)};showFullInterests=async e=>{let t=[];if(e&&e.length>0){let i=!0,r=this.inquiryCustomInterests(e,i);t.push(r);let o=e.filter(p=>p.source.toLocaleUpperCase()!=="CUSTOM"),{competitionsMap:s,teamsMap:l,playersMap:n}=await this.getInterestsEntitiesMap(o),c=o.map(p=>{let m=null;if(p.source.toLocaleUpperCase()==="FOOTBALL"){if(p.type==="competition")return m=s.get(p.id),m&&(p.id=m.id),p.model=m,p;if(p.type==="team")return m=l.get(p.id),m&&(p.id=m.id),p.model=m,p;if(p.type==="player")return n?(p.model=n[p.id],p.id=n[p.id].id):p.model=m,p}else return p.model=m,p});return t.push(c),t.flat()}return t};getInterestsEntitiesMap=async e=>{let t=[],i=[],r=[],o=new Map,s=new Map,l=null;return e.forEach(n=>{n.type==="competition"&&n.source.toLocaleUpperCase()==="FOOTBALL"?t.push(n.id):n.type==="team"&&n.source.toLocaleUpperCase()==="FOOTBALL"?i.push(n.id):n.type==="player"&&n.source.toLocaleUpperCase()==="FOOTBALL"&&r.push(n.id)}),t.length&&(o=await this.footballFacade.getCompetitionsMapWithNativeIds(t)),i.length&&(s=await this.footballFacade.getTeamsMapWithNativeIds(i)),r.length&&(l=await this.footballFacade.getPlayersMapWithNativeIds(r)),{competitionsMap:o,teamsMap:s,playersMap:l}};remapIdsObj=async(e,t,i)=>await this.idMapping.idMappingFacade.getEntitiesByIds(e,t,i)};var Ki=class{idMapping=null;profileOperations=null;constructor(e,t){this.idMapping=new b(e),this.profileOperations=new Wi(e,t,this.idMapping)}remapSuccessRatesEntities=async e=>await this.profileOperations.remapSuccessRatesEntities(e);remapInterestToNative=async e=>await this.profileOperations.remapInterestToNative(e);remapInterests=async e=>await this.profileOperations.remapInterests(e);showFullInterests=async e=>await this.profileOperations.showFullInterests(e)};var ae=class{idsRemapper=null;profileHttps=null;activityHttps=null;footballHttps=null;footballFacade=null;idMapping=null;localStorage=null;profileFacade=null;ownProfileBuilder=null;profileBuilder=null;constructor(e){this.profileHttps=new Ee(e),this.activityHttps=new Ge(e),this.footballHttps=new W(e),this.idMapping=new b(e),this.localStorage=new L(e),this.footballFacade=new Ae(e,this.localStorage,this.footballHttps,this.idMapping),this.profileFacade=new j(this.localStorage,this.profileHttps,this.activityHttps),this.idsRemapper=new Ki(e,this.footballFacade),this.ownProfileBuilder=new Yt(this.idsRemapper,this.localStorage,this.profileHttps,this.activityHttps,e.errorHandlingMode),this.profileBuilder=new Qt(this.idsRemapper,this.localStorage,this.profileHttps,this.activityHttps)}getOwn=()=>this.ownProfileBuilder;getById=e=>this.profileBuilder.setId(e);getCountries=async e=>await this.profileFacade.getCountries(e);getByIds=async(e,t)=>await this.profileFacade.getByIds(e,t)};var Yi=class{validate=e=>{let t=this.validateField(e.lang),i=this.generateMessage(t);return{validation:t,message:i}};validateField=e=>{let t=["bg","ro","en","el"],i=null;return e!=null&&e.length>0?t.includes(e)?i="valid":i="invalid":i="missing",i};generateMessage=e=>{let t=null,i="warning";return e==="missing"&&(t="If no lang is passed the default one will be set which is: en"),e==="invalid"&&(t="This lang value is not supported, the default one will be set which is: en"),e==="valid"&&(t=null,i=null),{text:t,type:i}}};var Qi=class{validate(e){let t=this.validateField(e.environment),i=this.generateMessage(t);return{validation:t,message:i}}validateField=e=>{let t=["dev","staging","prod"],i=null;return e!=null&&e.length>0?t.includes(e)?i="valid":i="invalid":i="missing",i};generateMessage=e=>{let t=null,i="warning";return e==="missing"&&(t="If no environment is passed the default one will be set which is: prod"),e==="invalid"&&(t="This environment value is not supported, the default one will be set which is: prod"),e==="valid"&&(t=null,i=null),{text:t,type:i}}};var zi=class{validate(e){let t=this.validateField(e.apiKey),i=this.generateMessage(t);return{validation:t,message:i}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,i="error";return e==="missing"&&(t="The field apiKey with valid value must be provided to use Fans United JS SDK"),e==="valid"&&(i=null),{text:t,type:i}}};var Ji=class{validate(e){let t=this.validateField(e.idSchema),i=this.generateMessage(t);return{validation:t,message:i}}validateField=e=>{let t=["native","sportal365","enetpulse","sportradar"],i=null;return e!=null&&e.length>0?t.includes(e)?i="valid":i="invalid":i="missing",i};generateMessage=e=>{let t=null,i="warning";return e==="missing"&&(t="If no idSchema is passed the default one will be set which is: native"),e==="invalid"&&(t="This idSchema value is not supported, the default one will be set which is: native"),e==="valid"&&(t=null,i=null),{text:t,type:i}}};var fe=class{getIdToken=null;logout=null};var $e=class{text=null;type=null};var Zi=class{validation=null;message=new $e;getIdToken={validation:null,message:new $e};logout={validation:null,message:new $e}};var er=class{validate(e){let t=this.validateAuthProvider(e.authProvider);return t.validation!=="missing"&&(t=this.validateAuthProviderConfigFields(e.authProvider,t),t=this.generateAuthProviderConfigMessages(t),t=this.checkAuthProviderConfigMessagesForErrors(t)),t}validateAuthProvider=e=>{let t=Object.keys(new fe),i=new Zi;if(e){let o=Object.keys(e).filter(s=>!t.includes(s));o.length>0?(i.validation="invalid",i.message.type="warning",i.message.text=`${"You have passed a property which is not supported for the authentication provider:"} ${o.join(",")}`):i.validation="valid"}else i.validation="missing",i.message.type="error",i.message.text="The field authProvider must be provided to use this SDK";return i};validateAuthProviderConfigFields=(e,t)=>(Object.keys(new fe).forEach(r=>{e[r]?t[r].validation="valid":t[r].validation="missing"}),t);generateAuthProviderConfigMessages=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{let i=e[t];i.validation==="missing"&&(i.message.text=`${"The following property is missing from the authProvider object:"} ${t}`,i.message.type="error")}),e);checkAuthProviderConfigMessagesForErrors=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{e[t].validation==="missing"&&e.validation==="valid"&&(e.validation="invalid",e.message.type="error",e.message.text="The field authProvider has missing properties")}),e)};var Mt=class{validation;message};var tr=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;errorHandlingMode=null;authProvider={getIdToken:new Mt,logout:new Mt};isValid=!1};var ir=class{validate(e){let t=this.validateField(e.clientId),i=this.generateMessage(t);return{validation:t,message:i}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,i="error";return e==="missing"&&(t="The field clientId must be provided to use Fans United JS SDK"),e==="valid"&&(t=null,i=null),{text:t,type:i}}};var rr=class{validate=e=>{let t=this.validateField(e.errorHandlingMode),i=this.generateMessage(t);return{validation:t,message:i}};validateField=e=>{let t=["default","standard"],i=null;return e?t.includes(e)?i="valid":i="invalid":i="missing",i};generateMessage=e=>{let t=null,i="warning";return e==="missing"&&(t="If no errorHandlingMode is passed the default one will be set which is: default"),e==="invalid"&&(t="This errorHandlingMode value is not supported, the default one will be set which is: default"),e==="valid"&&(t=null,i=null),{text:t,type:i}}};var or=class{validate=e=>{let t=this.checkFieldsForValues(e);return t.isValid=this.containsErrorMessage(t),t};checkFieldsForValues=e=>{let t=new tr,i={apiKey:new zi,environment:new Qi,idSchema:new Ji,clientId:new ir,lang:new Yi,errorHandlingMode:new rr,authProvider:new er};for(let[r,o]of Object.entries(t))r!=="isValid"&&(o=i[r].validate(e));return Object.keys(i).forEach(r=>{t[r]=i[r].validate(e)}),t};containsErrorMessage=e=>{let t=!0;for(let[i,r]of Object.entries(e))if(i!=="authProvider"){if(i!=="isValid"&&r.message.type==="error")return t=!1,t;if(i!=="isValid"&&r.message.type==="warning")return t=!0,t}else if(r.message.type==="error")return t=!1,t;return t}};var qe=class{https=null;idMapping=null;localStorage=null;footballFacade=null;constructor(e){this.https=new W(e),this.idMapping=new b(e),this.localStorage=new L(e),this.footballFacade=new Ae(e,this.localStorage,this.https,this.idMapping)}getCountries=async e=>await this.footballFacade.getCountries(e);getCompetitions=async(e,t)=>await this.footballFacade.getCompetitions(e,t);getCompetitionById=async(e,t)=>await this.footballFacade.getCompetitionById(e,t);getTopCompetitions=async e=>await this.footballFacade.getTopCompetitions(e);getTeams=async(e,t)=>await this.footballFacade.getTeams(e,t);getTeamById=async(e,t)=>await this.footballFacade.getTeamById(e,t);getTopTeams=async e=>await this.footballFacade.getTopTeams(e);getNextMatchForTeam=async(e,t)=>await this.footballFacade.getNextMatchForTeam(e,t);getPrevMatchForTeam=async(e,t)=>await this.footballFacade.getPrevMatchForTeam(e,t);getPlayers=async(e,t)=>await this.footballFacade.getPlayers(e,t);getPlayerById=async(e,t)=>await this.footballFacade.getPlayerById(e,t);getTopPlayers=async e=>await this.footballFacade.getTopPlayers(e);getNextMatchForPlayer=async(e,t)=>await this.footballFacade.getNextMatchForPlayer(e,t);getPrevMatchForPlayer=async(e,t)=>await this.footballFacade.getPrevMatchForPlayer(e,t);getMatches=async(e,t)=>await this.footballFacade.getMatches(e,t);getMatchById=async(e,t)=>await this.footballFacade.getMatchById(e,t);search=async(e,t)=>await this.footballFacade.search(e,t)};var ar=class{value=null;playerId=null;playerModel=null};var je=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new ar;result=null};var sr=class{value=!1;playerId=null};var U=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,i,r){this.matchId=e,this.market=t,this.prediction=new sr,this.prediction.value=i,this.prediction.playerId=r}};var Xe=class{settledAt=null;resettledAt=null;status=null;outcome=null;points=0};var nr=class{value=null};var ne=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,i){this.matchId=e,this.market=t,this.prediction=new nr,this.prediction.value=i}};var H=class{value=!1};var We=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,i){this.matchId=e,this.market=t,this.prediction=new H,this.prediction.value=i}};var Ke=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,i){this.matchId=e,this.market=t,this.prediction=new H,this.prediction.value=i}};var lr=class{matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t,i){this.matchFacade=e,this.playerFacade=t,this.predictorService=i}remapFixturesRequest=e=>{let t={};if(t.match_id=e.matchId,t.match_type="FOOTBALL",e instanceof U)t.market=e.market,t.prediction=e.prediction.value,t.player_id=e.prediction.playerId;else if(e instanceof We||e instanceof Ke)t.market=e.market,t.prediction=e.prediction.value;else if(e instanceof ne){t.market=e.market;let i=e.prediction.value.split(":");t.goals_home=Number(i[0]),t.goals_away=Number(i[1])}else t.market=e.market,t.prediction=e.prediction.value;return t};remapFixturesResponse=async e=>{let t="OWN_GOAL",i=[],r=[],o=null,s=[];e.length>1&&e.sort((n,c)=>n.match_id.localeCompare(c.match_id));for(let n of e)i.push(n.match_id),n.player_id&&!r.includes(n.player_id)&&r.push(n.player_id);let l=await this.matchFacade.getMatchesMapWithNativeIds(i);r.sort((n,c)=>n.localeCompare(c)),r&&r.length>0&&!r.includes(t)&&(o=await this.playerFacade.getPlayersMapWithNativeIds(r));for(let n of e){let c=new je;n.target?c.market=this.predictorService.convertMarketForResponseModel(n.market,n.target):c.market=n.market,c.matchId=l[n.match_id].id,c.matchType=n.match_type,c.matchModel=l?l[n.match_id]:null,delete c.matchModel.availableMarkets,n.goals_home!==void 0&&n.goals_away!==void 0?c.prediction.value=n.goals_home.toString()+":"+n.goals_away.toString():c.prediction.value=n.prediction,c.prediction.playerId=n.player_id?n.player_id:null,c.prediction.playerId&&c.prediction.playerId!==t&&(c.prediction.playerModel=o[n.player_id],c.prediction.playerId=o[n.player_id].id),c.result=this.remapResult(n.result),s.push(c)}return s};remapResult=e=>{let t=new Xe;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t.points=e.points,t}};var K=class{goldenGoal=null};var bt=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new K;points=null;createdAt=null;updatedAt=null};var y=class{no=0;yes=0};var Ye=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new y;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new y;penaltyMatch=new y;playerScoreFirstGoal={};cornersMatch={};correctScore={};correctScoreHalfTime={};correctScoreAdvanced={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new y;overOnePointFiveGoals=new y;overTwoPointFiveGoals=new y;overThreePointFiveGoals=new y;overFourPointFiveGoals=new y;overFivePointFiveGoals=new y;overSixPointFiveGoals=new y;overSixPointFiveCorners=new y;overSevenPointFiveCorners=new y;overEightPointFiveCorners=new y;overNinePointFiveCorners=new y;overTenPointFiveCorners=new y;overElevenPointFiveCorners=new y;overTwelvePointFiveCorners=new y;overThirteenPointFiveCorners=new y};var Y=class{timeTiebreaker=!1};var le=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new Y;predictionId=null;participantsCount=0;related=null;excludedProfileIds=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;scheduleOpenAt=null;images=null;predictionTiebreaker=new K};var ge=class{userId=null;points=null;results=[];tiebreaker=null};var pr=(o=>(o.ACTIVE="ACTIVE",o.WON="WON",o.LOST="LOST",o.PARTIALLY_WON="PARTIALLY_WON",o.CANCELED="CANCELED",o))(pr||{}),Do=["WON","LOST","PARTIALLY_WON","CANCELED"];var S=class{limit=null;startAfter=null;status=null;type=null;matchIds=null;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null,this.status=e.status?e.status:null,this.type=e.type?e.type:null,this.matchIds=e.matchIds?e.matchIds:null}constructFiltersUrl=()=>{let e="",t=!1;return this.status&&(t=Object.values(pr).some(i=>this.status.includes(i))),this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),this.status&&t&&(e+="&",e+=`status=${this.status.join(",")}`),this.type&&(e+="&",e+=`game_types=${this.type}`),this.matchIds&&(e+="&",e+=`match_ids=${this.matchIds.join(",")}`),e}};var Qe=class{limit;startAfter;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null}constructMainFiltersUrl(){let e="";return this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),e}};var wt=(s=>(s.OPEN="OPEN",s.LIVE="LIVE",s.PENDING="PENDING",s.CANCELED="CANCELED",s.CLOSED="CLOSED",s.SETTLED="SETTLED",s))(wt||{});var k=class extends Qe{status=null;type=null;gameIds=null;sortOrder=null;constructor(e){super(e);this.status=e.status?e.status:null,this.type=e.type?e.type:null,this.gameIds=e.gameIds?e.gameIds:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFiltersUrl=()=>{let e=super.constructMainFiltersUrl();return this.status&&Object.values(wt).includes(this.status)&&(e+="&",e+=`status=${this.status}`),this.type&&(e+="&",e+=`type=${this.type}`),this.gameIds&&this.gameIds.length>0&&(e+="&",e+=`game_ids=${this.gameIds.join(",")}`),this.sortOrder&&(e+="&",e+=`sort_order=${this.sortOrder}`),e}};var ze=class{main=null;cover=null;mobile=null};var Z=class{id=null;title=null;description=null;type=null;status=null;scheduleOpenAt=null;predictionsCutoff=null;fixtures=[];tiebreaker=new Y;participantsCount=0;related=null;excludedProfileIds=null;rules=null;flags=null;images=new ze;createdAt=null;updatedAt=null};var ee=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new Y;predictionId=null;participantsCount=0;related=null;excludedProfileIds=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;images=null;scheduleOpenAt=null};var Je=class extends Z{adContent=null;labels=null;customFields=null};var Q=class{footballHttps=null;idMapping=null;matchFacade=null;playerFacade=null;profileNamespace=null;constructor(e,t){this.footballHttps=new W(e),this.idMapping=t,this.matchFacade=new oe(e,this.footballHttps,t),this.playerFacade=new re(e,this.footballHttps,t),this.profileNamespace=new ae(e)}remapMatchIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"match","native")).match;remapPlayerIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"player","native")).player[0];remapPlayerIdMapToNative=async e=>{let t={},i=te(e),o=(await this.idMapping.getEntityIdsBySchemaId(i,"player","native")).player;return i.forEach((s,l)=>t[s]=o[l]),t};remapPlayerIdToIdSchema=async e=>{let t=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"],i=[];for(let[o,s]of Object.entries(e))if(t.includes(o))for(let l of Object.keys(s))l!=="NOBODY"&&l!=="OWN_GOAL"&&i.push(l);if(!i.length)return e;let r=await this.playerFacade.getPlayersMapWithNativeIds(i);for(let[o,s]of Object.entries(e))if(t.includes(o))for(let l of Object.keys(s))l!=="NOBODY"&&l!=="OWN_GOAL"&&(s[r[l].id]=s[l],s[r[l].id].model=r[l],this.idMapping.idSchema!=="native"&&delete s[l]);return e};convertMarket=e=>{let t=Object.keys(new Ye),i=Object.values(T);for(let r=0;r<i.length;r++)e===i[r]&&(e=t[r]);return e};convertMarketForResponseModel=(e,t)=>{let i=t.toString();return e+"_"+i};getMarketSummary=async(e,t,i)=>{let r=this.convertMarket(t),o={};if(o.matchId=e.matchId,o.matchType=e.matchType,Object.keys(e.predictions).includes(r))o[r]=e.predictions[r];else throw new Error("You have passed invalid market");if(V.includes(t)&&i){let l="";if(i!=="OWN_GOAL"&&i!=="NOBODY"&&(l=(await this.idMapping.idMappingFacade.getEntitiesByIds({player:[i]},this.idMapping.idSchema,"native")).player[0]),l&&o[r][l]){let n=await this.playerFacade.getPlayersMapWithNativeIds([l]);return o[r][l].model=n[l],o[r][l]}else return l?(o[r][l]=new y,o[r][l]):o[r][i]}else if(V.includes(t)&&!i){let l=Object.keys(o[r]).filter(c=>c!=="NOBODY"&&c!=="OWN_GOAL"),n=l.length?await this.playerFacade.getPlayersMapWithNativeIds(l):{};Object.keys(n).length&&Object.keys(o[r]).forEach(c=>{c!=="NOBODY"&&c!=="OWN_GOAL"&&(o[r][n[c].id]=o[r][c],o[r][n[c].id].model=n[c],this.idMapping.idSchema!=="native"&&delete o[r][c])})}return o};remapCompetitionsFromConfig=async e=>{if(e instanceof _e){let t={competition:e.fullCoverageCompetitions},i={competition:e.successRateScopes.competitions},r={team:e.successRateScopes.teams},o=await this.idMapping.idMappingFacade.getEntitiesByIds(t,"native",this.idMapping.idSchema),s=await this.idMapping.idMappingFacade.getEntitiesByIds(i,"native",this.idMapping.idSchema),l=await this.idMapping.idMappingFacade.getEntitiesByIds(r,"native",this.idMapping.idSchema);return e.fullCoverageCompetitions=o.competition,e.successRateScopes.competitions=s.competition,e.successRateScopes.teams=l.team,e}if(e instanceof ve||e instanceof Se){let t={competition:e.competitionsWhitelist},i=await this.idMapping.idMappingFacade.getEntitiesByIds(t,"native",this.idMapping.idSchema);return e.competitionsWhitelist=i.competition,e}};remapMatchIdsFixtures=async e=>{if(Array.isArray(e.data))if(e.data.length>0){let t=[],i=[];return e.data.forEach(r=>{r instanceof Z||r instanceof le||r instanceof ee||r instanceof Je?(r.fixtures.forEach(o=>t.push(o.matchId)),r instanceof ee&&r.fixtures.forEach(o=>{o.prediction.playerId&&o.prediction.playerId!=="OWN_GOAL"&&i.push(o.prediction.playerId)})):r instanceof ge&&r.results.forEach(o=>t.push(o.matchId))}),await this.refactorResponseArrModel(e,t,i)}else return e;else return await this.refactorResponseObjModel(e)};refactorResponseArrModel=async(e,t,i)=>{let r=[],o=await this.matchFacade.getMatchesMapWithNativeIds(t),s={};return i.length>0&&(s=await this.playerFacade.getPlayersMapWithNativeIds(i)),e.data.forEach(l=>{l instanceof Z||l instanceof le||l instanceof ee?(l.fixtures.forEach(n=>{this.handleMatchModel(o,n),l instanceof ee&&n.prediction.playerId&&n.prediction.playerId!=="OWN_GOAL"&&(n.prediction.playerModel=s[n.prediction.playerId],n.prediction.playerId=s[n.prediction.playerId].id)}),r.push(l)):l instanceof ge&&(l.results.forEach(n=>{n.matchModel=o[n.matchId],delete n.matchModel.availableMarkets,n.matchId=n.matchModel.id}),r.push(l))}),e.data=r,e};refactorResponseObjModel=async e=>{let t=[];e.fixtures.forEach(r=>t.push(r.matchId));let i=await this.matchFacade.getMatchesMapWithNativeIds(t);return e.fixtures.forEach(r=>this.handleMatchModel(i,r)),e};getCurrentGameId=e=>{let t=new Date;if(e.data.length>1){let i=[];return e.data.forEach(o=>i.push(o.predictionsCutoff)),e.data.sort((o,s)=>{let[l,n]=[o.predictionsCutoff,s.predictionsCutoff].map(c=>Math.abs(new Date(c)-t));return l-n})[0].id}else return e.data[0].id};initGameTypePredictions=(e,t)=>{let i={type:e,limit:null,startAfter:null};return t&&(i={...i,limit:t.limit,startAfter:t.startAfter}),i=new S(i),i};initGameFilters=(e,t,i)=>{if(t&&i)return t.type=e,t.gameIds=i,t=new k(t),t;if(t&&!i)return t.type=e,t=new k(t),t;if(!t&&i){let r={type:e,gameIds:i};return r=new k(r),r}else{let r={type:e};return r=new k(r),r}};addPredictionProp=async(e,t)=>(t.data.forEach(i=>{e.data.forEach(r=>{i.id===r.game_instance_id&&(i.predictionId=r.id,i.outcome=r.status,i.fixtures.forEach((o,s)=>{r.fixtures[s].goals_home!==void 0&&r.fixtures[s].goals_away!==void 0?o.prediction.value=r.fixtures[s].goals_home+":"+r.fixtures[s].goals_away:o.prediction.value=r.fixtures[s].prediction,r.fixtures[s].player_id?o.prediction.playerId=r.fixtures[s].player_id:r.fixtures[s].target&&(o.prediction.target=r.fixtures[s].target),o.prediction.result=this.remapResult(r.fixtures[s].result)}),i.predictionsMadeAt=r.created_at,i.points=r.points,i instanceof le&&(r.tiebreaker?i.predictionTiebreaker.goldenGoal=r.tiebreaker.golden_goal:i.predictionTiebreaker=r.tiebreaker))})}),t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,await this.remapMatchIdsFixtures(t));remapResult=e=>{let t=new Xe;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t.points=e.points,t};areIdsExceeded=e=>{let t=10;return e.length>t};initPredictionsFilters=(e,t,i)=>{switch(t){case"user":e&&(e=new S(e));break;case"current":if(e)this.deleteUnexpectedProperties(e),e.status=["ACTIVE"],e=new S(e);else{let r={status:["ACTIVE"]};e=new S(r)}break;case"past":if(e)this.deleteUnexpectedProperties(e),e.status=Do,e=new S(e);else{let r={status:Do};e=new S(r)}break;case"matches":if(e)this.deleteUnexpectedProperties(e),e.matchIds=i,e=new S(e);else{let r={matchIds:i};e=new S(r)}break}return e};completeGameMarketResults=async(e,t)=>{switch(t){case"MATCH_QUIZ":let i={},r=e.results[0].matchId,o=e.results.map(c=>V.includes(c.market)&&!c.result.includes("OWN_GOAL")?[...c.result]:[]).flat(),s=await this.matchFacade.getMatchesMapWithNativeIds([r]);return o.length&&(i=await this.playerFacade.getPlayersMapWithNativeIds(o)),e.results=e.results.map(c=>{if(c.matchModel=s[c.matchId]?s[c.matchId]:null,c.playerModels&&Object.keys(i).length&&c.result.forEach(m=>{let d=i[m];c.playerModels.push(d)}),this.idMapping.idSchema!=="native"&&(this.remapMatchIdForResultsMarkets(s,c),c.playerModels&&Object.keys(i).length)){let p=c.result;c.result=p.map(m=>i[m].id)}return c}),e;case"TOP_X":let l=e.results.map(c=>c.matchId),n=await this.matchFacade.getMatchesMapWithNativeIds(l);if(e.results=e.results.map(c=>(c.matchModel=n[c.matchId]?n[c.matchId]:null,this.idMapping.idSchema!=="native"&&this.remapMatchIdForResultsMarkets(n,c),c)),e.tieBreakers.goldenGoals.length){let c=e.tieBreakers.goldenGoals.map(m=>m.playerId),p=await this.playerFacade.getPlayersMapWithNativeIds(c);e.tieBreakers.goldenGoals=e.tieBreakers.goldenGoals.map(m=>(m.matchModel=n[m.matchId],m.playerModel=p[m.playerId],this.idMapping.idSchema!=="native"&&(m.matchId=n[m.matchId].id,m.playerId=p[m.playerId].id),m))}return e}};completeContestWinners=async e=>{let t=e.userList.map(r=>r.profileId),i=await this.profileNamespace.getByIds(t);return e.userList.forEach(r=>{let o=i.filter(s=>s.id===r.profileId)[0];delete o.interests,r.profileModel=o}),e};handleMatchModel=(e,t)=>{e[t.matchId]?(t.matchModel=e[t.matchId],delete t.matchModel.availableMarkets,t.matchId=t.matchModel.id):(t.matchModel=null,this.idMapping.idSchema!=="native"&&this.idMapping.idMappingFacade.getEntityById(t.matchId,"match","native").then(i=>{t.matchId=i[D[this.idMapping.idSchema]]}))};remapMatchIdForResultsMarkets=(e,t)=>{e[t.matchId]?t.matchId=e[t.matchId].id:this.idMapping.idMappingFacade.getEntityById(t.matchId,"match","native").then(i=>{t.matchId=i[D[this.idMapping.idSchema]]})};deleteUnexpectedProperties=e=>(e.status&&(console.warn(Ao.UNEXPECTED_STATUS_PROP),delete e.status),e.type&&(console.warn(Ao.UNEXPECTED_TYPE_PROP),delete e.type),e)};var Ze=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(e){this.gameInstanceId=e.gameInstanceId,e.fixtures.forEach(t=>this.fixtures.push(new ne(t.matchId,t.market,t.prediction.value))),this.tiebreaker=e.tiebreaker?e.tiebreaker:null}};var et=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t){this.footballHttps=new W(e),this.matchFacade=new oe(e,this.footballHttps,t),this.playerFacade=new re(e,this.footballHttps,t),this.predictorService=new Q(e,t),this.fixturesRemapper=new lr(this.matchFacade,this.playerFacade,this.predictorService)}remapRequestBody=e=>{let t={};return t.game_instance_id=e.gameInstanceId,t.fixtures=e.fixtures.map(i=>this.fixturesRemapper.remapFixturesRequest(i)),e instanceof Ze&&e.tiebreaker&&(t.tiebreaker={},t.tiebreaker.golden_goal=e.tiebreaker.goldenGoal?e.tiebreaker.goldenGoal:null),t};remapResponseArrayBody=async e=>{if(e.length){let t="OWN_GOAL",i=[],r=[],o={},s=[];e.forEach(n=>{n.fixtures.forEach(c=>{i.push(c.match_id),c.player_id&&c.player_id!==t&&r.push(c.player_id)})});let l=await this.matchFacade.getMatchesMapWithNativeIds(i);return r.length>0&&(o=await this.playerFacade.getPlayersMapWithNativeIds(r)),e.forEach(n=>{let c=new bt,p=[];c.id=n.id,c.gameInstanceId=n.game_instance_id,c.gameType=n.game_type,c.wager=n.wager,c.totalFixtures=n.total_fixtures,c.settledFixtures=n.settled_fixtures,c.userId=n.user_id,n.fixtures.forEach(m=>{let d=new je;m.target?d.market=this.predictorService.convertMarketForResponseModel(m.market,m.target):d.market=m.market,d.matchId=l[m.match_id].id,d.matchType=m.match_type,d.matchModel=l[m.match_id],delete d.matchModel.availableMarkets,m.goals_home!==void 0&&m.goals_away!==void 0?d.prediction.value=m.goals_home.toString()+":"+m.goals_away.toString():d.prediction.value=m.prediction,d.prediction.playerId=m.player_id?m.player_id:null,d.prediction.playerId&&d.prediction.playerId!==t&&(d.prediction.playerModel=o[d.prediction.playerId],d.prediction.playerId=o[d.prediction.playerId].id),d.result=this.fixturesRemapper.remapResult(m.result),p.push(d)}),c.fixtures=p,c.status=n.status,n.tiebreaker?c.tiebreaker.goldenGoal=n.tiebreaker.golden_goal:c.tiebreaker=null,c.points=n.points,c.createdAt=n.created_at,c.updatedAt=n.updated_at,s.push(c)}),s}return e};remapResponseObjBody=async e=>{let t=new bt;return t.id=e.id,t.gameInstanceId=e.game_instance_id,t.gameType=e.game_type,t.wager=e.wager,t.totalFixtures=e.total_fixtures,t.settledFixtures=e.settled_fixtures,t.userId=e.user_id,t.fixtures=await this.fixturesRemapper.remapFixturesResponse(e.fixtures),t.status=e.status,e.tiebreaker?t.tiebreaker.goldenGoal=e.tiebreaker.golden_goal:t.tiebreaker=null,t.points=e.points,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapPredictionModel=e=>{let t=new Ye;return t.fullTimeOneXTwo=e.FT_1X2,t.halfTimeOneXTwo=e.HT_1X2,t.bothTeamsScore=e.BOTH_TEAMS_SCORE,t.overZeroPointFiveGoals=e.OVER_GOALS_0_5,t.overOnePointFiveGoals=e.OVER_GOALS_1_5,t.overTwoPointFiveGoals=e.OVER_GOALS_2_5,t.overThreePointFiveGoals=e.OVER_GOALS_3_5,t.overFourPointFiveGoals=e.OVER_GOALS_4_5,t.overFivePointFiveGoals=e.OVER_GOALS_5_5,t.overSixPointFiveGoals=e.OVER_GOALS_6_5,t.overSixPointFiveCorners=e.OVER_CORNERS_6_5,t.overSevenPointFiveCorners=e.OVER_CORNERS_7_5,t.overEightPointFiveCorners=e.OVER_CORNERS_8_5,t.overNinePointFiveCorners=e.OVER_CORNERS_9_5,t.overTenPointFiveCorners=e.OVER_CORNERS_10_5,t.overElevenPointFiveCorners=e.OVER_CORNERS_11_5,t.overTwelvePointFiveCorners=e.OVER_CORNERS_12_5,t.overThirteenPointFiveCorners=e.OVER_CORNERS_13_5,t.doubleChance=e.DOUBLE_CHANCE,t.halfTimeFullTime=e.HT_FT,t.playerScore=e.PLAYER_SCORE,t.playerYellowCard=e.PLAYER_YELLOW_CARD,t.playerRedCard=e.PLAYER_RED_CARD,t.redCardMatch=e.RED_CARD_MATCH,t.penaltyMatch=e.PENALTY_MATCH,t.playerScoreFirstGoal=e.PLAYER_SCORE_FIRST_GOAL,t.cornersMatch=e.CORNERS_MATCH,t.correctScore=e.CORRECT_SCORE,t.correctScoreHalfTime=e.CORRECT_SCORE_HT,t.correctScoreAdvanced=e.CORRECT_SCORE_ADVANCED,t.playerScoreHattrick=e.PLAYER_SCORE_HATTRICK,t.playerScoreTwice=e.PLAYER_SCORE_TWICE,t}};var cr=class{matchId=null;matchType=null;predictions=null};var mr=class{remapPredictions=null;constructor(e,t){this.remapPredictions=new et(e,t)}remapResponse=e=>{let t=new cr;return t.matchId=e.match_id,t.matchType=e.match_type,t.predictions=this.remapPredictions.remapPredictionModel(e.predictions),t}};var dr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new N};var ur=class{value=null;target=null;playerId=null;playerModel=null;result=null};var hr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new N;prediction=new ur};var fr=class{value=null;result=null};var gr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new N;prediction=new fr};var yr=class{matchId=null;matchModel=null;outcome=null};var Mr=class{gameId=null;results=null;tieBreakers=null};var tt=class{entityId=null;entityType=null};var br=class{contestId="";contestType="GAME";contestModel=null;description="";userList=[]};var wr=class{position="";profileId="";profileModel=null;note="";tags=[]};var Ir=class{remapPaginatedGames=e=>{let t=new M;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(i=>this.remapGamesListResponse(i)),t};remapGamesListResponse=e=>{let t=new Z;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.scheduleOpenAt=e.schedule_open_at,t.predictionsCutoff=e.predictions_cutoff,t.fixtures=e.fixtures.map(i=>this.remapFixturesResponse(i)),t.tiebreaker=e.tiebreaker?this.remapTimeTiebreaker(e.tiebreaker.time_tiebreaker):null,t.participantsCount=e.participants_count,t.related=e.related?this.remapRelated(e.related):null,t.excludedProfileIds=e.excluded_profile_ids,t.rules=e.rules,t.flags=e.flags,t.images=e.images,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapGameByIdResponse=e=>{let t=new Je;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.scheduleOpenAt=e.schedule_open_at,t.predictionsCutoff=e.predictions_cutoff,t.fixtures=e.fixtures.map(i=>this.remapFixturesResponse(i)),t.tiebreaker=e.tiebreaker?this.remapTimeTiebreaker(e.tiebreaker.time_tiebreaker):null,t.participantsCount=e.participants_count,t.related=e.related?this.remapRelated(e.related):null,t.excludedProfileIds=e.excluded_profile_ids,t.rules=e.rules,t.flags=e.flags,t.adContent=e.ad_content,t.labels=e.labels,t.customFields=e.custom_fields,t.images=e.images,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapFixturesResponse=e=>{let t=new dr;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t.matchStatus.type=e.match_status.type,t.matchStatus.subType=e.match_status.sub_type,t};remapPaginatedUserTopXEditions=e=>{let t=new M;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(i=>this.remapUserTopXEditionsResponse(i)),t};remapUserTopXEditionsResponse=e=>{let t=new le;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.scheduleOpenAt=e.schedule_open_at,t.fixtures=e.fixtures.map(i=>this.remapTopXFixturesResponse(i)),t.tiebreaker=e.tiebreaker?this.remapTimeTiebreaker(e.tiebreaker.time_tiebreaker):null,t.participantsCount=e.participants_count,t.related=e.related?this.remapRelated(e.related):null,t.excludedProfileIds=e.excluded_profile_ids,t.rules=e.rules,t.flags=e.flags,t.images=e.images,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapTopXFixturesResponse=e=>{let t=new gr;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t.matchStatus.type=e.match_status.type,t.matchStatus.subType=e.match_status.sub_type,t};remapPaginatedUserMathQuizEditions=e=>{let t=new M;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(i=>this.remapUserMatchQuizEditionsResponse(i)),t};remapUserMatchQuizEditionsResponse=e=>{let t=new ee;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.scheduleOpenAt=e.schedule_open_at,t.fixtures=e.fixtures.map(i=>this.remapMatchQuizFixturesResponse(i)),t.tiebreaker=e.tiebreaker?this.remapTimeTiebreaker(e.tiebreaker.time_tiebreaker):null,t.participantsCount=e.participants_count,t.related=e.related?this.remapRelated(e.related):null,t.excludedProfileIds=e.excluded_profile_ids,t.rules=e.rules,t.flags=e.flags,t.images=e.images,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapMatchQuizFixturesResponse=e=>{let t=new hr;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t.matchStatus.type=e.match_status.type,t.matchStatus.subType=e.match_status.sub_type,t};remapPaginatedGameResults=e=>{let t=new M;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(i=>this.remapGameResults(i)),t};remapGameResults=e=>{let t=new ge;return t.userId=e.user_id,t.points=e.points?e.points:0,t.results=e.results.map(i=>this.remapResults(i)),t.tiebreaker=e.tiebreaker?this.remapTiebreaker(e.tiebreaker):null,t};remapGameMarketsResults=e=>{let t=new Mr;return t.gameId=e.game_id,t.results=this.remapMarketsResults(e.results),t.tieBreakers=e.tie_breakers?this.remapTieBreakers(e.tie_breakers):null,t};remapContestWinners=e=>{let t=new br;return t.contestId=e.contest_id,t.contestType=e.contest_type,t.description=e.description,t.userList=e.user_list.map(i=>this.remapUserListWinners(i)),t};remapUserListWinners=e=>{let t=new wr;return t.position=e.position,t.profileId=e.profile_id,t.note=e.note,t.tags=e.tags,t};remapTieBreakers=e=>{let t={goldenGoals:[]};return t.goldenGoals=e.golden_goals.map(i=>({minute:i.minute,matchId:i.match_id,matchModel:null,playerId:i.player_id,playerModel:null,goalType:i.goal_type})),t};remapMarketsResults=e=>{let t=[];return e.forEach(i=>{let r={matchId:i.match_id,market:i.market,result:this.remapMarketResult(i.market,i.result),matchModel:null,playerModels:[],matchStatus:this.remapMarketsResultsMatchStatus(i.match_status)};t.push(this.deleteUnusefulField(r))}),t};remapMarketsResultsMatchStatus=e=>{let t=new N;return t.type=e.type,t.subType=e.sub_type,t};remapMarketResult=(e,t)=>{if(os.includes(e))return t[0];if(V.includes(e))return t;if(t[0]==="true")return!0;if(t[0]==="false")return!1};deleteUnusefulField=e=>((!V.includes(e.market)||this.isPlayerMarketWithNoResult(e.market,e.result))&&delete e.playerModels,e);isPlayerMarketWithNoResult=(e,t)=>V.includes(e)&&t.length===0;remapResults=e=>{let t=new yr;return t.matchId=e.match_id,t.outcome=e.outcome,t};remapTiebreaker=e=>{let t=new K;return t.goldenGoal=e.golden_goal,t};remapTimeTiebreaker=e=>{let t=new Y;return t.timeTiebreaker=e,t};remapRelated=e=>e.map(t=>{let i=new tt;return i.entityId=t.entity_id,i.entityType=t.entity_type,i})};var Fr=class{remapMetaData=e=>{let t=new be;return t.pagination.nextPageStartsAfter=e.pagination.next_page_starts_after,t.pagination.itemsPerPage=e.pagination.items_per_page,t}};var z=class extends E{predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;metaRemapper=null;constructor(e,t){super(e,v(e.environment,"predictor"));this.predictionRemapper=new et(e,t),this.matchSummaryRemapper=new mr(e,t),this.gamesRemapper=new Ir,this.metaRemapper=new Fr}makeFootballPrediction=async e=>{try{let t=this.predictionRemapper.remapRequestBody(e),i=await this.instanceAuth.post(`/predictions${this.apiSignInUrl}`,JSON.stringify(t));return await this.predictionRemapper.remapResponseObjBody(i.data)}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem making POST request: ",i),i.response}};getMatchSummary=async(e,t)=>{let i=I(t)?`/predictions/summary/${e}${this.apiSignInUrl}${F()}`:`/predictions/summary/${e}${this.apiSignInUrl}`;try{let r=await this.instance.get(i);return this.matchSummaryRemapper.remapResponse(r.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn(`There was a problem fetching predictions for match: ${e} `,o),o.response}};deleteFootballPrediction=async e=>{try{return await this.instanceAuth.delete(`/predictions/${e}${this.apiSignInUrl}`),!0}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn(`There was a problem deleting your prediction: ${e}`,i),i.response}};getMyPredictions=async e=>{try{let t=new M,i=`/predictions${this.apiSignInUrl}`;e&&(i+=`${e.constructFiltersUrl()}`);let r=await this.instanceAuth.get(i);return t.meta=this.metaRemapper.remapMetaData(r.data.meta),t.data=await this.predictionRemapper.remapResponseArrayBody(r.data.data),t}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem fetching own predictions",i),i.response}};getMyPredictionsNoRemap=async e=>{try{return(await this.instanceAuth.get(`/predictions${this.apiSignInUrl}${e.constructFiltersUrl()}`)).data}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem fetching own predictions",i),i.response}};getUserPredictions=async(e,t,i)=>{try{let r=new M,o=I(t)?`/predictions/users/${e}${this.apiSignInUrl}${F()}`:`/predictions/users/${e}${this.apiSignInUrl}`;i&&(o+=`${i.constructFiltersUrl()}`);let s=await this.instance.get(o);return r.meta=this.metaRemapper.remapMetaData(s.data.meta),r.data=await this.predictionRemapper.remapResponseArrayBody(s.data.data),r}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn(`There was a problem fetching predictions for user: ${e}`,o),o.response}};getUserPredictionsNoRemap=async(e,t)=>{try{return(await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}${t.constructFiltersUrl()}`)).data}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn(`There was a problem fetching predictions for user: ${e}`,r),r.response}};getGames=async(e,t)=>{try{let i=I(t)?`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}${F()}`:`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,r=await this.instance.get(i);return this.gamesRemapper.remapPaginatedGames(r.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem fetching the games list",r),r.response}};getGameById=async(e,t)=>{try{let i=I(t)?`/games/${e}${this.apiSignInUrl}${F()}`:`/games/${e}${this.apiSignInUrl}`,r=await this.instance.get(i);return this.gamesRemapper.remapGameByIdResponse(r.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn(`There was a problem fetching the following game: ${e}`,r),r.response}};getGamePredictions=async(e,t,i)=>{try{let r=new M,o=I(t)?`/games/${e}/predictions${this.apiSignInUrl}${F()}`:`/games/${e}/predictions${this.apiSignInUrl}`;i&&(o+=`${i.constructFiltersUrl()}`);let s=await this.instance.get(o);return r.meta=this.metaRemapper.remapMetaData(s.data.meta),r.data=await this.predictionRemapper.remapResponseArrayBody(s.data.data),r}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn(`There was a problem fetching the predictions for game: ${e}`,o),o.response}};getUserGameEditions=async(e,t)=>{try{let i=null,r=I(t)?`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}${F()}`:`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,o=await this.instance.get(r);return o.data.data.forEach(s=>{s.type==="TOP_X"?i=this.gamesRemapper.remapPaginatedUserTopXEditions(o.data):s.type==="MATCH_QUIZ"&&(i=this.gamesRemapper.remapPaginatedUserMathQuizEditions(o.data))}),i}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem fetching the games list",r),r.response}};getGameResults=async(e,t,i)=>{try{let r=I(t)?`/games/${e}/results/${this.apiSignInUrl}${F()}`:`/games/${e}/results/${this.apiSignInUrl}`;i&&(r+=`${i.constructMainFiltersUrl()}`);let o=await this.instance.get(r);return this.gamesRemapper.remapPaginatedGameResults(o.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn(`There was a problem fetching the results for the following game: ${e}`,o),o.response}};getMarketResultsForGame=async(e,t)=>{let i=`/games/${e}/correct-results/${this.apiSignInUrl}`;I(t)&&(i+=`${F()}`);try{let r=await this.instance.get(i);return this.gamesRemapper.remapGameMarketsResults(r.data.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn(`There was a problem fetching the markets correct results for the following game: ${e}`,o),o.response}};getContestWinners=async e=>{try{let t=await this.instance.get(`/winners/${this.apiSignInUrl}&contest_id=${e}`);return this.gamesRemapper.remapContestWinners(t.data)}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn(`There was a problem fetching winners for the following game: ${e}`,i),i.response}};getPredictionById=async e=>{try{let t=`/predictions/${e}${this.apiSignInUrl}`,i=await this.instanceAuth.get(t);return(await this.predictionRemapper.remapResponseArrayBody([i.data.data]))[0]}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn(`There was a problem fetching info for the following prediction: ${e}`,i),i.response}}};var it=class{gameInstanceId=null;fixtures=null};var Lo=(i=>(i.ONE="1",i.X="x",i.TWO="2",i))(Lo||{}),Bo=(i=>(i.ONE_X="1x",i.X_TWO="x2",i.ONE_TWO="12",i))(Bo||{}),No=(c=>(c.ONE_ONE="1/1",c.ONE_X="1/x",c.ONE_TWO="1/2",c.X_ONE="x/1",c.X_X="x/x",c.X_TWO="x/2",c.TWO_ONE="2/1",c.TWO_X="2/x",c.TWO_TWO="2/2",c))(No||{});var Pr=class{matchId=null;market="BOTH_TEAMS_SCORE";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new H,this.prediction.value=t}};var Er=class{value};var Rr=class{matchId=null;market="CORNERS_MATCH";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Er,this.prediction.value=t}};var Tr=class{value=null};var Sr=class{matchId=null;market="DOUBLE_CHANCE";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Tr,this.prediction.value=t}};var vr=class{value=null};var _r=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,i){this.matchId=e,this.market=t,this.prediction=new vr,this.prediction.value=i}};var Cr=class{value=null};var Ar=class{matchId=null;market="HT_FT";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Cr,this.prediction.value=t}};var xr=class{matchId=null;market="PENALTY_MATCH";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new H,this.prediction.value=t}};var Or=class{matchId=null;market="RED_CARD_MATCH";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new H,this.prediction.value=t}};var pe=class{errorHandlingMode=null;constructor(e){this.errorHandlingMode=e}validateBodyFields=(e,t)=>{let i=Object.keys(t),r=Object.keys(new it);switch(e){case"MATCH_QUIZ":i.forEach(n=>{r.includes(n)||this.throwInvalidParamException([n])});break;case"TOP_X":let s=t;s.fixtures.forEach(n=>this.validateMarketTopX(n.market));let l="tiebreaker";i.includes(l)&&s.tiebreaker&&this.validateTiebreaker(s.tiebreaker),i.forEach(n=>{n!=="tiebreaker"&&!r.includes(n)&&this.throwInvalidParamException([n])});break}let o=r.filter(s=>!i.includes(s));return o.length&&this.throwMissingFieldsException("game prediction body",o),t.fixtures.forEach(s=>{this.validateFixtureFields(s)}),t};validateFixture=(e,t,i,r)=>{this.validateMarket(t);let o=Object.values(Lo),s=Object.values(No),l=Object.values(Bo);if(t==="FT_1X2"||t==="HT_1X2"){if(o.includes(i))return new _r(e,t,i)}else if(t==="HT_FT"){if(s.includes(i))return new Ar(e,i)}else if(t==="DOUBLE_CHANCE"){if(l.includes(i))return new Sr(e,i)}else if(t==="CORRECT_SCORE"||t==="CORRECT_SCORE_ADVANCED"||t==="CORRECT_SCORE_HT"){if(typeof i=="string"&&/\d+:\d+/.test(i))return new ne(e,t,i)}else if(t==="CORNERS_MATCH"){if(typeof i=="number")return new Rr(e,i)}else if(t==="BOTH_TEAMS_SCORE"){if(this.isPredictionBoolean(i))return new Pr(e,i)}else if(t==="RED_CARD_MATCH"){if(this.isPredictionBoolean(i))return new Or(e,i)}else if(t==="PENALTY_MATCH"){if(this.isPredictionBoolean(i))return new xr(e,i)}else if(V.includes(t)){let n="OWN_GOAL";if(this.validatePlayerId(t,r),t===Ue&&this.isPredictionBoolean(i)){let c=r&&r===n?n:r;return new U(e,t,i,c)}if(r&&this.isPredictionBoolean(i))return new U(e,t,i,r)}else if(is.includes(t)){if(this.isPredictionBoolean(i))return new Ke(e,t,i)}else if(rs.includes(t)&&this.isPredictionBoolean(i))return new We(e,t,i);this.throwInvalidPredictionException(i,t)};validateFixtureFields=e=>{let t=Object.keys(e);t.forEach(r=>{Co.includes(r)||this.throwInvalidParamException([r])});let i=Co.filter(r=>{if(r!=="matchType"&&!t.includes(r))return r});i.length&&this.throwMissingFieldsException("fixtures",i),this.validatePredictionKey(e.market,e.prediction)};validateTiebreaker=e=>{let t=Object.keys(e);(!t.length||typeof e!="object")&&this.throwInvalidType("tiebreaker","object");let i=Object.keys(new K)[0];t.forEach(r=>{i!==r&&this.throwInvalidParamException([r])}),t.includes(i)||this.throwMissingFieldsException("tiebreaker",[i]),typeof e.goldenGoal!="number"&&this.throwInvalidType("goldenGoal","number")};validatePredictionKey=(e,t)=>{if(typeof t=="object"){let i=Object.keys(t),r=["value"];if(i.length||this.throwMissingFieldsException("prediction",r),i.length===1&&!i.includes(r[0])&&this.throwInvalidParamException(i),i.length>1){V.includes(e)&&r.push("playerId");let o=i.filter(s=>!r.includes(s));o.length&&this.throwInvalidParamException(o)}}else this.throwInvalidType("prediction","object")};validatePlayerId=(e,t)=>{let i="playerId";e!==Ue&&(t||this.throwInvalidParamException([i]),typeof t!="string"&&this.throwInvalidType(i,"string"))};validateMarket=e=>{Object.values(T).includes(e)||this.throwInvalidMarketException(e)};validateMarketTopX=e=>{e!=="CORRECT_SCORE"&&e!=="CORRECT_SCORE_ADVANCED"&&this.throwInvalidMarketException(e,"TOP_X")};isPredictionBoolean=e=>typeof e=="boolean";throwInvalidPredictionException=(e,t)=>{let i=Qa(e,t);throw this.errorHandlingMode==="default"?new g(400,"INVALID_PREDICTION",i):new h(400,"INVALID_TYPE",i).response};throwInvalidMarketException=(e,t)=>{let i=null;throw t&&t==="TOP_X"?i=za(e):i=Ut(e),this.errorHandlingMode==="default"?new g(400,"INVALID_MARKET",i):new h(400,"INVALID_TYPE",i).response};throwInvalidParamException=e=>{let t=Ja(e);throw this.errorHandlingMode==="default"?new g(400,"INVALID_FIELD",t):new h(400,"INVALID_TYPE",t).response};throwMissingFieldsException=(e,t)=>{let i=Za(e,t);throw this.errorHandlingMode==="default"?new g(400,"INVALID_FIELD",i):new h(400,"INVALID_TYPE",i).response};throwInvalidType=(e,t)=>{let i=es(e,t);throw this.errorHandlingMode==="default"?new g(400,"INVALID_TYPE",i):new h(400,"INVALID_TYPE",i).response}};var Dr=class{predictorHttps=null;clientHttps=null;idMapping=null;predictorService=null;predictorValidator=null;errorHandlingMode=null;constructor(e,t,i,r){this.predictorHttps=t,this.idMapping=r,this.clientHttps=i,this.errorHandlingMode=e.errorHandlingMode,this.predictorValidator=new pe(e.errorHandlingMode),this.predictorService=new Q(e,r)}makeFootballPrediction=async(e,t,i,r)=>{let o=this.predictorValidator.validateFixture(e,t,i,r),s=new it;if(this.idMapping.idSchema!=="native"){let l=o.matchId,n="",c=await this.predictorService.remapMatchIdToNative([l]);if(o.matchId=c[0],this.errorHandlingMode==="default"&&!o.matchId)throw new g(400,"INVALID_FIELD","Match id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&!o.matchId)throw new h(400,"INVALID_FIELD","Match id is invalid!").response;if(o instanceof U&&o.prediction.playerId!=="OWN_GOAL"){if(o.prediction.playerId&&(n=o.prediction.playerId,o.prediction.playerId=await this.predictorService.remapPlayerIdToNative([n])),this.errorHandlingMode==="default"&&o.market!==Ue&&!o.prediction.playerId)throw new g(400,"INVALID_FIELD","Player id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&o.market!==Ue&&!o.prediction.playerId)throw new h(400,"INVALID_FIELD","Player id is invalid!").response}s.fixtures=[o];let p=await this.predictorHttps.makeFootballPrediction(s);return p.fixtures.forEach(m=>{m.prediction.playerId&&m.prediction.playerId!=="OWN_GOAL"&&(m.prediction.playerId=n),m.matchId=l}),p}else return s.fixtures=[o],await this.predictorHttps.makeFootballPrediction(s)};getMatchSummary=async(e,t)=>{let i=await this.getMatchSummaryBase(e,t),r=JSON.parse(JSON.stringify(i.predictions)),o=await this.predictorService.remapPlayerIdToIdSchema(r);return i.predictions=o,i};getMarketSummary=async(e,t,i,r)=>{try{let o=await this.getMatchSummaryBase(e,r);return await this.predictorService.getMarketSummary(o,t,i)}catch(o){throw o}};getMatchSummaryBase=async(e,t)=>{if(this.idMapping.idSchema!=="native"){let r=(await this.predictorService.remapMatchIdToNative([e]))[0],o=await this.predictorHttps.getMatchSummary(r,t);return o.matchId=e,o}else return await this.predictorHttps.getMatchSummary(e,t)};getConfig=async()=>{let e=await this.clientHttps.getConfig("predictor");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(e):e};deleteFootballPrediction=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyPredictions=async e=>{let t=this.predictorService.initPredictionsFilters(e,"user");return await this.predictorHttps.getMyPredictions(t)};getMyPredictionsForMatches=async(e,t)=>{if(this.errorHandlingMode==="default"&&this.predictorService.areIdsExceeded(e))throw new g(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();if(this.errorHandlingMode==="standard"&&this.predictorService.areIdsExceeded(e))throw new h(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").response;this.idMapping.idSchema!=="native"&&(e=await this.predictorService.remapMatchIdToNative([...e]));let i=this.predictorService.initPredictionsFilters(t,"matches",e);return await this.predictorHttps.getMyPredictions(i)};getMyCurrentPredictions=async e=>{let t=this.predictorService.initPredictionsFilters(e,"current");return await this.predictorHttps.getMyPredictions(t)};getMyPastPredictions=async e=>{let t=this.predictorService.initPredictionsFilters(e,"past");return await this.predictorHttps.getMyPredictions(t)};getUserPredictions=async(e,t,i)=>{let r=this.predictorService.initPredictionsFilters(t,"user");return await this.predictorHttps.getUserPredictions(e,i,r)};getUserCurrentPredictions=async(e,t,i)=>{let r=this.predictorService.initPredictionsFilters(t,"current");return await this.predictorHttps.getUserPredictions(e,i,r)};getUserPastPredictions=async(e,t,i)=>{let r=this.predictorService.initPredictionsFilters(t,"past");return await this.predictorHttps.getUserPredictions(e,i,r)};getUserPredictionsForMatches=async(e,t,i,r)=>{if(this.errorHandlingMode==="default"&&this.predictorService.areIdsExceeded(t))throw new g(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();if(this.errorHandlingMode==="standard"&&this.predictorService.areIdsExceeded(t))throw new h(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").response;this.idMapping.idSchema!=="native"&&(t=await this.predictorService.remapMatchIdToNative([...t]));let o=this.predictorService.initPredictionsFilters(i,"matches",t);return await this.predictorHttps.getUserPredictions(e,r,o)};getPredictionById=async e=>await this.predictorHttps.getPredictionById(e)};var Lr=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(e){this.idMapping=new b(e),this.predictorHttps=new z(e,this.idMapping),this.clientHttps=new B(e),this.predictorFacade=new Dr(e,this.predictorHttps,this.clientHttps,this.idMapping)}makeFootballPrediction=async(e,t,i,r)=>await this.predictorFacade.makeFootballPrediction(e,t,i,r);getMatchSummary=async(e,t)=>await this.predictorFacade.getMatchSummary(e,t);getMarketSummary=async(e,t,i,r)=>await this.predictorFacade.getMarketSummary(e,t,i,r);getConfig=async()=>await this.predictorFacade.getConfig();deleteFootballPrediction=async e=>await this.predictorFacade.deleteFootballPrediction(e);getMyPredictions=async e=>await this.predictorFacade.getMyPredictions(e);getMyCurrentPredictions=async e=>await this.predictorFacade.getMyCurrentPredictions(e);getMyPastPredictions=async e=>await this.predictorFacade.getMyPastPredictions(e);getMyPredictionsForMatches=async(e,t)=>await this.predictorFacade.getMyPredictionsForMatches(e,t);getUserPredictions=async(e,t,i)=>await this.predictorFacade.getUserPredictions(e,t,i);getUserCurrentPredictions=async(e,t,i)=>await this.predictorFacade.getUserCurrentPredictions(e,t,i);getUserPastPredictions=async(e,t,i)=>await this.predictorFacade.getUserPastPredictions(e,t,i);getUserPredictionsForMatches=async(e,t,i,r)=>await this.predictorFacade.getUserPredictionsForMatches(e,t,i,r);getPredictionById=async e=>await this.predictorFacade.getPredictionById(e)};var Br=class{rankType=null;fromDate=null;toDate=null;pagination=new Be};var rt=class{position=null;profileId=null;profileModel=null;points=null;predictionsMade=null};var Nr=class{remapResponse=e=>(e.meta=this.remapMeta(e.meta),e.data=this.remapData(e.data),e);remapMeta=e=>{let t=new Br;return t.rankType=e.rank_type,t.fromDate=e.from_date,t.toDate=e.to_date,t.pagination.currentPage=e.pagination.current_page,t.pagination.itemsPerPage=e.pagination.items_per_page,t.pagination.totalItems=e.pagination.total_items,t.pagination.numberOfPages=e.pagination.number_of_pages,t};remapData=e=>{let t=[];return e.forEach(i=>{let r=new rt;r.position=i.position,r.profileId=i.profile_id,r.points=i.points,r.predictionsMade=i.predictions_made,t.push(r)}),t}};var Ur=class extends rt{id=null;rankType=null;model=null;gameType=null};var Hr=class{remapRankings=e=>(e.meta=this.remapMeta(e.meta),e.data=this.remapData(e.data),e);remapMeta=e=>{let t=new X;return t.pagination.currentPage=e.pagination.current_page,t.pagination.itemsPerPage=e.pagination.items_per_page,t.pagination.numberOfPages=e.pagination.number_of_pages,t.pagination.totalItems=e.pagination.total_items,t};remapData(e){let t=[];return e.forEach(i=>{let r=new Ur;r.id=i.id,r.rankType=i.rank_type,r.position=i.position,r.points=i.points,r.gameType=i.game_type,delete r.profileId,delete r.profileModel,delete r.predictionsMade,t.push(r)}),t}};var ot=class{id=null;name=null;description=null;type=null;fromDate=null;toDate=null;markets=[];teamIds=[];matchIds=[];gameIds=[];gameTypes=[];competitionIds=[];excludedProfileIds=[];rules=null;flags=null;images=new ze;status=null;automaticallyChangeStatus=!0;createdAt=null;updatedAt=null;related=null};var kr=class extends ot{labels=null;customFields=null;adContent=null};var Gr=class{remapResponse=e=>{let t=[];return e.forEach(i=>{let r=new ot;r.id=i.id,r.name=i.name,r.description=i.description,r.type=i.type,r.fromDate=i.from_date,r.toDate=i.to_date,r.markets=i.markets?i.markets:null,r.teamIds=i.team_ids?i.team_ids:null,r.matchIds=i.match_ids?i.match_ids:null,r.gameIds=i.game_ids?i.game_ids:null,r.gameTypes=i.game_types?i.game_types:null,r.competitionIds=i.competition_ids?i.competition_ids:null,r.excludedProfileIds=i.excluded_profile_ids?i.excluded_profile_ids:null,r.rules=i.rules?i.rules:null,r.flags=i.flags?i.flags:null,r.images=i.images?i.images:null,r.status=i.status?i.status:null,r.automaticallyChangeStatus=i.automatically_change_status,r.createdAt=i.created_at,r.updatedAt=i.updated_at,r.related=i.related?this.remapRelated(i.related):null,t.push(r)}),t};remapResponseId=e=>{let t=new kr;return t.id=e.id,t.name=e.name,t.description=e.description,t.type=e.type,t.fromDate=e.from_date,t.toDate=e.to_date,t.markets=e.markets?e.markets:null,t.teamIds=e.team_ids?e.team_ids:null,t.matchIds=e.match_ids?e.match_ids:null,t.gameIds=e.game_ids?e.game_ids:null,t.gameTypes=e.game_types?e.game_types:null,t.competitionIds=e.competition_ids?e.competition_ids:null,t.excludedProfileIds=e.excluded_profile_ids?e.excluded_profile_ids:null,t.rules=e.rules?e.rules:null,t.flags=e.flags?e.flags:null,t.images=e.images?e.images:null,t.status=e.status?e.status:null,t.automaticallyChangeStatus=e.automatically_change_status,t.related=e.related?this.remapRelated(e.related):null,t.labels=e.labels,t.customFields=e.custom_fields,t.adContent=e.ad_content,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapMeta=e=>{let t={};return t.totalItems=e.pagination.total_items,t};remapRelated=e=>e.map(t=>{let i=new tt;return i.entityId=t.entity_id,i.entityType=t.entity_type,i})};var Vr=class{position=null;points=null;predictionsMade=null;profileId=null;profileModel=null;successRatePercent=null};var $r=class{remapHighestSuccessRate=e=>e.map(t=>{let i=new Vr;return i.position=t.position,i.points=t.points,i.predictionsMade=t.predictions_made,i.profileId=t.profile_id,i.successRatePercent=t.success_rate_percent,i})};var qr=class extends E{templateRemapper=null;leaderboardRemapper=null;rankingsRemapper=null;highestSuccessRateRemapper=null;constructor(e){super(e,v(e.environment,"loyalty"));this.templateRemapper=new Gr,this.leaderboardRemapper=new Nr,this.rankingsRemapper=new Hr,this.highestSuccessRateRemapper=new $r}getTemplates=async(e,t)=>{try{let i=I(e)?`/leaderboard/templates/${this.apiSignInUrl}${F()}`:`/leaderboard/templates/${this.apiSignInUrl}`,r=await this.instance.get(i);if(t){let o=JSON.parse(JSON.stringify(r.data));return o.meta=this.templateRemapper.remapMeta(r.data.meta),o.data=this.templateRemapper.remapResponse(r.data.data),o}return this.templateRemapper.remapResponse(r.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem fetching the list of templates",r),r.response}};getTemplateById=async(e,t)=>{try{let i=I(t)?`/leaderboard/templates/${e}${this.apiSignInUrl}${F()}`:`/leaderboard/templates/${e}${this.apiSignInUrl}`,r=await this.instance.get(i);return this.templateRemapper.remapResponseId(r.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn(`There was a problem requesting the following template: ${e}`,r),r.response}};getLeaderboard=async(e,t,i)=>{try{let r=I(t)?`/leaderboard/${e}/${this.apiSignInUrl}${F()}`:`/leaderboard/${e}/${this.apiSignInUrl}`;i&&(r+=`${i.constructFiltersUrl()}`);let o=await this.instance.get(r),s=JSON.parse(JSON.stringify(o.data));return this.leaderboardRemapper.remapResponse(s)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn(`There was a problem fetching the leaderboard for the following template: ${e}`,o),o.response}};getLeaderboardForGame=async(e,t,i)=>{try{let r=I(t)?`/leaderboard/games/${e}/${this.apiSignInUrl}${F()}`:`/leaderboard/games/${e}/${this.apiSignInUrl}`;i&&(r+=`${i.constructFiltersUrl()}`);let o=await this.instance.get(r),s=JSON.parse(JSON.stringify(o.data));return this.leaderboardRemapper.remapResponse(s)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn(`There was a problem fetching the leaderboard for the following game: ${e}`,o),o.response}};getUserRankings=async(e,t,i)=>{let r=`/leaderboard/users/${e}/rankings/${this.apiSignInUrl}`;t&&(r+=`${t.constructFiltersUrl()}`),I(i)&&(r+=`${F()}`);try{let o=await this.instance.get(r);return this.rankingsRemapper.remapRankings(o.data)}catch(o){let s=this.transformAxiosErrorToFansUnitedException(o);throw console.warn(`There was a problem fetching the rankings for the following user: ${e}`,s),s.response}};getHighestSuccessRate=async(e,t)=>{let i=`/statistics/top${this.apiSignInUrl}`;e&&(i+=`${e.constructFiltersUrl()}`),I(t)&&(i+=`${F()}`);try{let r=await this.instance.get(i);return this.highestSuccessRateRemapper.remapHighestSuccessRate(r.data.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn("There was a problem fetching highest success rate",o),o.response}};getEntitiesFollows=async(e,t)=>{let i=I(t)?`/statistics/follows${this.apiSignInUrl}${F()}`:`/statistics/follows${this.apiSignInUrl}`;e.footballCompetitions&&(i+=`&competitions=${e.footballCompetitions.join(",")}`),e.footballTeams&&(i+=`&teams=${e.footballTeams.join(",")}`),e.footballPlayers&&(i+=`&players=${e.footballPlayers.join(",")}`);try{return(await this.instance.get(i)).data.data}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn("There was a problem fetching follows for entities",o),o.response}}};var jr=class{general;predictor;topX;matchQuiz};var at=class{limit=null;page=null;constructor(e){this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null}constructFiltersUrl(){let e="";return this.limit&&(e+="&",e+=`limit=${this.limit}`),this.page&&(e+="&",e+=`page=${this.page}`),e}};var Xr=class extends at{sortOrder=null;rankType=null;leaderboardIds=null;gameType=null;constructor(e){super(e);this.sortOrder=e.sortOrder,this.rankType=e.rankType,this.leaderboardIds=e.leaderboardIds,this.gameType=e.type&&e.type.toLowerCase()==="game"?e.gameType:null}constructFiltersUrl=()=>{let e=super.constructFiltersUrl();return this.sortOrder&&(e+="&",e+=`sort_order=${this.sortOrder}`),this.rankType&&(e+="&",e+=`rank_type=${this.rankType}`),this.leaderboardIds&&(e+="&",e+=`type_ids=${this.leaderboardIds.join(",")}`),this.gameType&&(e+="&",e+=`game_type=${this.gameType}`),e}};var Wr=class{idMappingService=null;profileNamespace=null;footballNamespace=null;errorHandlingMode=null;constructor(e){this.idMappingService=new b(e),this.profileNamespace=new ae(e),this.footballNamespace=new qe(e),this.errorHandlingMode=e.errorHandlingMode}remapTemplatesIds=async e=>{if(e.length>0){let t=[],i=[],r=[],o=[],s=[],l=[];e.forEach(p=>{p.teamIds&&p.teamIds.length>0?t=[...t,...p.teamIds]:p.matchIds&&p.matchIds.length>0?r=[...r,...p.matchIds]:p.competitionIds&&p.competitionIds.length>0&&(s=[...s,...p.competitionIds])});let n={team:t,match:r,competition:s},c=await this.idMappingService.idMappingFacade.getEntitiesByIds(n,"native",this.idMappingService.idSchema);return i=[...c.team],o=[...c.match],l=[...c.competition],e.forEach(p=>{p.teamIds&&p.teamIds.length>0?p.teamIds=p.teamIds.map(m=>m=c.team.shift()):p.matchIds&&p.matchIds.length>0?p.matchIds=p.matchIds.map(m=>m=c.match.shift()):p.competitionIds&&p.competitionIds.length>0&&(p.competitionIds=p.competitionIds.map(m=>m=c.competition.shift()))}),e}return e};addProfileModelToLeaderboad=async e=>{if(e.length>0){let t=[],i=e.map(o=>o.profileId);if(!i.length)return e;let r=await this.profileNamespace.getByIds(i);return e.forEach(o=>{r.forEach(s=>{s.id===o.profileId&&(delete s.interests,o.profileModel=s)}),o.profileModel||(o.profileModel=null),t.push(o)}),t}return e};buildClientBadges=e=>{let t=new jr;return t.general=this.extractEnabledBadgesId(e.general),t.predictor=this.extractEnabledBadgesId(e.predictor),t.topX=this.extractEnabledBadgesId(e.topX),t.matchQuiz=this.extractEnabledBadgesId(e.matchQuiz),t};initFilters=(e,t)=>{switch(t){case"loyalty":e&&(e=new at(e));break;case"rankings":e&&(e=new Xr(e));break}return e};addProfileModelToHighestSuccessRate=async e=>{let t=e.map(r=>r.profileId);if(!t.length)return e;let i=await this.profileNamespace.getByIds(t);return e.map(r=>(i.forEach(o=>{o.id===r.profileId&&(delete o.interests,r.profileModel=o)}),r))};extractRankingsIdsMap=e=>{let t=[],i=[],r=[];return e.forEach(o=>{o.rankType==="GAME"&&o.gameType==="TOP_X"?t.push(o.id):o.rankType==="GAME"&&o.gameType==="MATCH_QUIZ"?i.push(o.id):o.rankType==="TEMPLATE"&&r.push(o.id)}),[t,i,r]};setModelsForUserRankings=(e,t,i,r)=>(r.data.forEach(o=>{o.gameType==="MATCH_QUIZ"&&t?o.model=t.filter(s=>s.id===o.id)[0]:o.gameType==="TOP_X"&&e?o.model=e.filter(s=>s.id===o.id)[0]:o.rankType==="TEMPLATE"&&i&&(o.model=i.filter(s=>s.id===o.id)[0])}),r);completeContestWinners=async e=>{let t=e.userList.map(r=>r.profileId),i=await this.profileNamespace.getByIds(t);return e.userList.forEach(r=>{let o=i.filter(s=>s.id===r.profileId)[0];delete o.interests,r.profileModel=o}),e};validateEntitiesFollowsFilters=e=>{let t=24;if(!e||(!e.footballCompetitions||!e.footballCompetitions.length)&&(!e.footballTeams||!e.footballTeams.length)&&(!e.footballPlayers||!e.footballPlayers.length))throw this.errorHandlingMode==="default"?new g(400,"invalid_filters","At least one of footballCompetitions, footballTeams or footballPlayers properties should be provided for filters."):new h(400,"invalid_filters","At least one of footballCompetitions, footballTeams or footballPlayers properties should be provided for filters.").response;if(e.footballCompetitions&&e.footballCompetitions.length>t||e.footballTeams&&e.footballTeams.length>t||e.footballPlayers&&e.footballPlayers.length>t)throw this.errorHandlingMode==="default"?new g(400,"EXCEEDED_LENGTH","Maximum length per entity should be 24 or less."):new h(400,"EXCEEDED_LENGTH","Maximum length per entity should be 24 or less.").response};remapEntitiesFollowsFilters=async e=>{let t=JSON.parse(JSON.stringify(e)),i={},r={};t.footballCompetitions&&t.footballCompetitions.length&&(r.competition=t.footballCompetitions),t.footballTeams&&t.footballTeams.length&&(r.team=t.footballTeams),t.footballPlayers&&t.footballPlayers.length&&(r.player=t.footballPlayers);let o=await this.idMappingService.idMappingFacade.getEntitiesByIds(r,this.idMappingService.idSchema,"native");return Object.keys(o).forEach(s=>{s==="competition"?i.footballCompetitions=o[s]:s==="team"?i.footballTeams=o[s]:s==="player"&&(i.footballPlayers=o[s])}),i};addModelsToEntitiesFollows=async e=>{let t=[],i="fb:c:",r=new Map,o=[],s="fb:t:",l=new Map,n=[],c="fb:p:",p=null;return e.breakdown.forEach(m=>{m.id.includes(i)?t.push(m.id):m.id.includes(s)?o.push(m.id):m.id.includes(c)&&n.push(m.id)}),t.length&&(r=await this.footballNamespace.footballFacade.competitionsFacade.getCompetitionsMapWithNativeIds(t)),o.length&&(l=await this.footballNamespace.footballFacade.teamsFacade.getTeamsMapWithNativeIds(o)),n.length&&(p=await this.footballNamespace.footballFacade.playerFacade.getPlayersMapWithNativeIds(n)),e.breakdown.forEach(m=>{m.id.includes(i)?(m.model=r.get(m.id),m.id=m.model.id):m.id.includes(s)?(m.model=l.get(m.id),m.id=m.model.id):m.id.includes(c)&&(m.model=p[m.id],m.id=m.model.id)}),e};extractEnabledBadgesId=e=>{let t=[];return e.forEach(i=>{i.enabled&&t.push(i.id)}),t}};var Kr=class{validate=(e,t)=>{e.market&&this.validateMarket(e.market,t),e.fromDate&&this.validateDate(e.fromDate,"fromDate",t),e.toDate&&this.validateDate(e.toDate,"toDate",t),e.usersCount&&this.validateNumberFilters(e.usersCount,"usersCount",t),e.minimumPredictions&&this.validateNumberFilters(e.minimumPredictions,"minimumPredictions",t)};validateMarket=(e,t)=>{if(!Object.keys(T).includes(e)){let r=Ut(e);throw t==="default"?new g(400,"INVALID_MARKET",r):new h(400,"INVALID_MARKET",r).response}};validateDate=(e,t,i)=>{let r=/^\d{4}-\d{2}-\d{2}$/;if(typeof e!="string")throw i==="default"?new g(400,"invalid_filters","You have provided invalid type. The valid type is "+`string for ${t} filter`):new h(400,"invalid_filters","You have provided invalid type. The valid type is "+`string for ${t} filter`).response;if(!r.test(e))throw i==="default"?new g(400,"invalid_filters","You have provided invalid value. The valid value is "+`YYYY-MM-DD for ${t}`):new h(400,"invalid_filters","You have provided invalid value. The valid value is "+`YYYY-MM-DD for ${t}`).response};validateNumberFilters=(e,t,i)=>{let r=t==="usersCount"?1:0,o=t==="usersCount"?1e3:1e6;if(typeof e!="number")throw i==="default"?new g(400,"invalid_filters","You have provided invalid type. The valid type is "+`number for ${t} filter`):new h(400,"invalid_filters","You have provided invalid type. The valid type is "+`number for ${t} filter`).response;if(e<r||e>o)throw i==="default"?new g(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${o}`):new h(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${o}`).response}};var st=class{idMapping=null;predictorHttps=null;predictorService=null;predictorValidator=null;clientHttps=null;errorHandlingMode=null;constructor(e,t){this.idMapping=t,this.errorHandlingMode=e.errorHandlingMode,this.predictorValidator=new pe(e.errorHandlingMode),this.predictorHttps=new z(e,t),this.predictorService=new Q(e,t),this.clientHttps=new B(e)}getConfig=async()=>{let e=await this.clientHttps.getConfig("topX");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(e):e};getGames=async(e,t)=>{t=t||!1;let i=this.predictorService.initGameFilters("TOP_X",e),r=await this.predictorHttps.getGames(i,t);return await this.predictorService.remapMatchIdsFixtures(r)};getGameById=async(e,t)=>{t=t||!1;let i=await this.predictorHttps.getGameById(e,t);return await this.predictorService.remapMatchIdsFixtures(i)};getGamePredictions=async(e,t,i)=>(i=i||!1,t&&(t.type&&delete t.type,t.status&&delete t.status,t=new S(t)),await this.predictorHttps.getGamePredictions(e,i,t));getGameResults=async(e,t,i)=>{i=i||!1,t&&(t=new k(t));let r=await this.predictorHttps.getGameResults(e,i,t);return await this.predictorService.remapMatchIdsFixtures(r)};getCurrentGameResults=async e=>{e=e||!1;let t={status:"OPEN",type:"TOP_X"};t=new k(t);let i=await this.predictorHttps.getGames(t,e),r=this.predictorService.getCurrentGameId(i);return(await this.getGameResults(r,null,e)).data[0]};play=async e=>{let t=new Ze(e);if(t=this.predictorValidator.validateBodyFields("TOP_X",t),t.fixtures=t.fixtures.map(r=>this.predictorValidator.validateFixture(r.matchId,r.market,r.prediction.value)),this.idMapping.idSchema!=="native"){let r=[];t.fixtures.forEach(s=>r.push(s.matchId));let o=await this.predictorService.remapMatchIdToNative(r);t.fixtures.forEach(s=>s.matchId=o.shift())}let i=await this.predictorHttps.makeFootballPrediction(t);return i.fixtures.forEach(r=>{r.matchId=r.matchModel.id}),i};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyGameEditions=async(e,t)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),t=t||!1;let i=this.predictorService.initGameTypePredictions("TOP_X",e),r=[],o=await this.predictorHttps.getMyPredictionsNoRemap(i);if(o.data.length>0){o.data.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let s=this.predictorService.initGameFilters("TOP_X",null,r),l=await this.predictorHttps.getUserGameEditions(s,t);return await this.predictorService.addPredictionProp(o,l)}else return new M};getMyGamePrediction=async e=>{let t=this.predictorService.initGameTypePredictions("TOP_X"),i=await this.predictorHttps.getMyPredictions(t);if(i.data.length>0){let r=i.data.filter(o=>o.gameInstanceId===e);return r.length?r[0]:null}return null};getUserGameEditions=async(e,t,i)=>{t&&t.limit&&this.validateLimitFilterOnGames(t.limit),i=i||!1;let r=this.predictorService.initGameTypePredictions("TOP_X",t),o=[],s=await this.predictorHttps.getUserPredictionsNoRemap(e,r);if(s.data.length>0){s.data.forEach(c=>{c.game_instance_id&&o.push(c.game_instance_id)});let l=this.predictorService.initGameFilters("TOP_X",null,o),n=await this.predictorHttps.getUserGameEditions(l,i);return await this.predictorService.addPredictionProp(s,n)}else return new M};getUserGamePrediction=async(e,t,i)=>{i=i||!1;let r=this.predictorService.initGameTypePredictions("TOP_X"),o=await this.predictorHttps.getUserPredictions(e,i,r);if(o.data.length>0){let s=o.data.filter(l=>l.gameInstanceId===t);return s.length?s[0]:null}else return null};getMarketsResultsForGame=async(e,t)=>{let i=await this.predictorHttps.getMarketResultsForGame(e,t);return await this.predictorService.completeGameMarketResults(i,"TOP_X")};getGameWinners=async e=>{let t=await this.predictorHttps.getContestWinners(e),i=await this.getGameById(e);return t.contestModel=i,this.predictorService.completeContestWinners(t)};validateLimitFilterOnGames=e=>{let t=50;if(this.errorHandlingMode==="default"&&e>t)throw new g(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.");if(this.errorHandlingMode==="standard"&&e>t)throw new h(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.").response}};var nt=class{predictorHttps=null;predictorService=null;idMapping=null;clientHttps=null;predictorValidator=null;errorHandlingMode=null;constructor(e){this.predictorValidator=new pe(e.errorHandlingMode),this.idMapping=new b(e),this.predictorHttps=new z(e,this.idMapping),this.predictorService=new Q(e,this.idMapping),this.clientHttps=new B(e),this.errorHandlingMode=e.errorHandlingMode}getConfig=async()=>{let e=await this.clientHttps.getConfig("matchQuiz");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(e):e};play=async e=>{e=this.predictorValidator.validateBodyFields("MATCH_QUIZ",e);let t=e.fixtures.map(i=>this.predictorValidator.validateFixture(i.matchId,i.market,i.prediction.value,i.prediction.playerId));if(t&&t.length&&this.idMapping.idSchema!=="native"){let i=[],r=[];t.forEach(l=>{i.push(l.matchId),l instanceof U&&l.prediction.playerId&&l.prediction.playerId!=="OWN_GOAL"&&r.push(l.prediction.playerId)});let o=await this.predictorService.remapMatchIdToNative(i),s={};r&&r.length>0&&(s=await this.predictorService.remapPlayerIdMapToNative(r)),t.forEach((l,n)=>{l.matchId=o[n],l instanceof U&&l.prediction.playerId!=="OWN_GOAL"&&(l.prediction.playerId=s[l.prediction.playerId])})}return e.fixtures=t,await this.predictorHttps.makeFootballPrediction(e)};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getGames=async(e,t)=>{t=t||!1;let i=this.predictorService.initGameFilters("MATCH_QUIZ",e),r=await this.predictorHttps.getGames(i,t);return await this.predictorService.remapMatchIdsFixtures(r)};getGameById=async(e,t)=>{t=t||!1;let i=await this.predictorHttps.getGameById(e,t);return await this.predictorService.remapMatchIdsFixtures(i)};getGamePredictions=async(e,t,i)=>(i=i||!1,t&&(t.type&&delete t.type,t.status&&delete t.status,t=new S(t)),await this.predictorHttps.getGamePredictions(e,i,t));getGameResults=async(e,t,i)=>{i=i||!1,t&&(t=new Qe(t));let r=await this.predictorHttps.getGameResults(e,i,t);return await this.predictorService.remapMatchIdsFixtures(r)};getCurrentGameResults=async e=>{e=e||!1;let t={status:"OPEN",type:"MATCH_QUIZ"};t=new k(t);let i=await this.predictorHttps.getGames(t,e),r=this.predictorService.getCurrentGameId(i);return(await this.getGameResults(r,null,e)).data[0]};getMyGameEditions=async(e,t)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),t=t||!1;let i=this.predictorService.initGameTypePredictions("MATCH_QUIZ",e),r=[],o=await this.predictorHttps.getMyPredictionsNoRemap(i);if(o.data.length>0){o.data.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let s=this.predictorService.initGameFilters("MATCH_QUIZ",null,r),l=await this.predictorHttps.getUserGameEditions(s,t);return await this.predictorService.addPredictionProp(o,l)}else return new M};getMyGamePrediction=async e=>{let t=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),i=await this.predictorHttps.getMyPredictions(t);if(i.data.length>0){let r=i.data.filter(o=>o.gameInstanceId===e);return r.length?r[0]:null}return null};getUserGameEditions=async(e,t,i)=>{t&&t.limit&&this.validateLimitFilterOnGames(t.limit),i=i||!1;let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ",t),o=[],s=await this.predictorHttps.getUserPredictionsNoRemap(e,r);if(s.data.length>0){s.data.forEach(c=>{c.game_instance_id&&o.push(c.game_instance_id)});let l=this.predictorService.initGameFilters("MATCH_QUIZ",null,o),n=await this.predictorHttps.getUserGameEditions(l,i);return await this.predictorService.addPredictionProp(s,n)}else return new M};getUserGamePrediction=async(e,t,i)=>{i=i||!1;let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),o=await this.predictorHttps.getUserPredictions(e,i,r);if(o.data.length>0){let s=o.data.filter(l=>l.gameInstanceId===t);return s.length?s[0]:null}else return null};getMarketsResultsForGame=async(e,t)=>{let i=await this.predictorHttps.getMarketResultsForGame(e,t);return await this.predictorService.completeGameMarketResults(i,"MATCH_QUIZ")};getGameWinners=async e=>{let t=await this.predictorHttps.getContestWinners(e),i=await this.getGameById(e);return t.contestModel=i,this.predictorService.completeContestWinners(t)};validateLimitFilterOnGames=e=>{let t=50;if(this.errorHandlingMode==="default"&&e>t)throw new g(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.");if(this.errorHandlingMode==="standard"&&e>t)throw new h(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.").response}};var Yr=class{market;fromDate;toDate;usersCount;minimumPredictions;constructor(e){this.market=e.market?e.market:null,this.fromDate=e.fromDate?e.fromDate:null,this.toDate=e.toDate?e.toDate:null,this.usersCount=e.usersCount?e.usersCount:null,this.minimumPredictions=e.minimumPredictions?e.minimumPredictions:null}constructFiltersUrl(){let e="";return this.market&&(e+="&",e+=`market=${this.market}`),this.fromDate&&(e+="&",e+=`from_date=${this.fromDate}`),this.toDate&&(e+="&",e+=`to_date=${this.toDate}`),this.usersCount&&(e+="&",e+=`users_count=${this.usersCount}`),this.minimumPredictions&&(e+="&",e+=`minimum_predictions=${this.minimumPredictions}`),e}};var Qr=class{config=null;clientHttps=null;loyaltyHttps=null;loyaltyService=null;profileFacade=null;loyaltyValidator=null;idMapping=null;topXFacade=null;matchQuizFacade=null;predictorHttps=null;errorHandlingMode=null;constructor(e,t,i,r,o){this.config=e,this.clientHttps=t,this.loyaltyHttps=i,this.profileFacade=new j(o,r),this.loyaltyService=new Wr(this.config),this.loyaltyValidator=new Kr,this.idMapping=new b(e),this.topXFacade=new st(e,this.idMapping),this.matchQuizFacade=new nt(e),this.predictorHttps=new z(e,this.idMapping),this.errorHandlingMode=e.errorHandlingMode}getConfig=async()=>await this.clientHttps.getConfig("loyalty");getClientBadges=async()=>{let e=await this.getConfig();return this.loyaltyService.buildClientBadges(e.rewards.badges)};getTemplates=async e=>{let t=!0;if(this.config.idSchema==="native")return await this.loyaltyHttps.getTemplates(e,t);let i=await this.loyaltyHttps.getTemplates(e,t);return i.data=await this.loyaltyService.remapTemplatesIds([...i.data]),i};getTemplateById=async(e,t)=>{let i=await this.loyaltyHttps.getTemplateById(e,t);return this.config.idSchema==="native"?i:(await this.loyaltyService.remapTemplatesIds([i]))[0]};getLeaderboard=async(e,t,i)=>{t=this.loyaltyService.initFilters(t,"loyalty");let r=await this.loyaltyHttps.getLeaderboard(e,i,t);return r.data=await this.loyaltyService.addProfileModelToLeaderboad(r.data),r};getLeaderboardForGame=async(e,t,i)=>{t=this.loyaltyService.initFilters(t,"loyalty");let r=await this.loyaltyHttps.getLeaderboardForGame(e,i,t);return r.data=await this.loyaltyService.addProfileModelToLeaderboad(r.data),r};getOwnRankings=async(e,t)=>{let{id:i}=await this.profileFacade.getOwn();return this.getUserRankings(i,e,t)};getUserRankings=async(e,t,i)=>{t=this.loyaltyService.initFilters(t,"rankings");let r=await this.loyaltyHttps.getUserRankings(e,t,i);return await this.getModelsForUserRankings(r)};getHighestSuccessRate=async(e,t)=>{e&&(e=new Yr(e),this.loyaltyValidator.validate(e,this.errorHandlingMode));let i=await this.loyaltyHttps.getHighestSuccessRate(e,t);return this.loyaltyService.addProfileModelToHighestSuccessRate(i)};getTemplateWinners=async e=>{let t=await this.predictorHttps.getContestWinners(e),i=await this.getTemplateById(e);return t.contestModel=i,this.loyaltyService.completeContestWinners(t)};getEntitiesFollows=async(e,t)=>{this.loyaltyService.validateEntitiesFollowsFilters(e),this.config.idSchema!=="native"&&(e=await this.loyaltyService.remapEntitiesFollowsFilters(e));let i=await this.loyaltyHttps.getEntitiesFollows(e,t);return await this.loyaltyService.addModelsToEntitiesFollows(i)};getModelsForUserRankings=async e=>{let t=null,i=null,r=null,[o,s,l]=this.loyaltyService.extractRankingsIdsMap(e.data);if(l.length&&(t=(await this.getTemplates()).data.filter(c=>l.includes(c.id))),o.length){let n={gameIds:o};i=(await this.topXFacade.getGames(n)).data}if(s.length){let n={gameIds:s};r=(await this.matchQuizFacade.getGames(n)).data}return this.loyaltyService.setModelsForUserRankings(i,r,t,e)}};var zr=class{clientHttps=null;profileHttps=null;loyaltyHttps=null;loyaltyFacade=null;localStorage=null;constructor(e){this.clientHttps=new B(e),this.profileHttps=new Ee(e),this.loyaltyHttps=new qr(e),this.localStorage=new L(e),this.loyaltyFacade=new Qr(e,this.clientHttps,this.loyaltyHttps,this.profileHttps,this.localStorage)}getConfig=async()=>await this.loyaltyFacade.getConfig();getClientBadges=async()=>await this.loyaltyFacade.getClientBadges();getTemplates=async e=>await this.loyaltyFacade.getTemplates(e);getTemplateById=async(e,t)=>await this.loyaltyFacade.getTemplateById(e,t);getLeaderboard=async(e,t,i)=>await this.loyaltyFacade.getLeaderboard(e,t,i);getLeaderboardForGame=async(e,t,i)=>await this.loyaltyFacade.getLeaderboardForGame(e,t,i);getOwnRankings=async(e,t)=>await this.loyaltyFacade.getOwnRankings(e,t);getUserRankings=async(e,t,i)=>await this.loyaltyFacade.getUserRankings(e,t,i);getHighestSuccessRate=async(e,t)=>await this.loyaltyFacade.getHighestSuccessRate(e,t);getTemplateWinners=async e=>await this.loyaltyFacade.getTemplateWinners(e);getEntitiesFollows=async(e,t)=>await this.loyaltyFacade.getEntitiesFollows(e,t)};var Jr=class{topXFacade=null;idMapping=null;constructor(e){this.idMapping=new b(e),this.topXFacade=new st(e,this.idMapping)}getConfig=async()=>await this.topXFacade.getConfig();getGames=async(e,t)=>await this.topXFacade.getGames(e,t);getGameById=async(e,t)=>await this.topXFacade.getGameById(e,t);getGamePredictions=async(e,t,i)=>await this.topXFacade.getGamePredictions(e,t,i);getGameResults=async(e,t,i)=>await this.topXFacade.getGameResults(e,t,i);getCurrentGameResults=async e=>await this.topXFacade.getCurrentGameResults(e);play=async e=>await this.topXFacade.play(e);delete=async e=>await this.topXFacade.delete(e);getMyGameEditions=async(e,t)=>await this.topXFacade.getMyGameEditions(e,t);getMyGamePrediction=async e=>await this.topXFacade.getMyGamePrediction(e);getUserGameEditions=async(e,t,i)=>await this.topXFacade.getUserGameEditions(e,t,i);getUserGamePrediction=async(e,t,i)=>await this.topXFacade.getUserGamePrediction(e,t,i);getMarketsResultsForGame=async(e,t)=>await this.topXFacade.getMarketsResultsForGame(e,t);getGameWinners=async e=>await this.topXFacade.getGameWinners(e)};var Zr=class{matchQuizFacade=null;constructor(e){this.matchQuizFacade=new nt(e)}getConfig=async()=>await this.matchQuizFacade.getConfig();play=async e=>await this.matchQuizFacade.play(e);delete=async e=>await this.matchQuizFacade.delete(e);getGames=async(e,t)=>await this.matchQuizFacade.getGames(e,t);getGameById=async(e,t)=>await this.matchQuizFacade.getGameById(e,t);getGamePredictions=async(e,t,i)=>await this.matchQuizFacade.getGamePredictions(e,t,i);getGameResults=async(e,t,i)=>await this.matchQuizFacade.getGameResults(e,t,i);getCurrentGameResults=async e=>await this.matchQuizFacade.getCurrentGameResults(e);getMyGameEditions=async(e,t)=>await this.matchQuizFacade.getMyGameEditions(e,t);getMyGamePrediction=async e=>await this.matchQuizFacade.getMyGamePrediction(e);getUserGameEditions=async(e,t,i)=>await this.matchQuizFacade.getUserGameEditions(e,t,i);getUserGamePrediction=async(e,t,i)=>await this.matchQuizFacade.getUserGamePrediction(e,t,i);getMarketsResultsForGame=async(e,t)=>await this.matchQuizFacade.getMarketsResultsForGame(e,t);getGameWinners=async e=>await this.matchQuizFacade.getGameWinners(e)};var It=class{action=null;context=new He;constructor(e,t,i,r){this.action=e,this.context.tags=t,i&&(this.context.content=i),r&&(this.context.campaign=r)}};var eo=class{idSchema;idMapping;constructor(e){this.idSchema=e.idSchema,this.idMapping=new b(e)}remapTagsIds=async(e,t,i)=>{if(!e||!e.length)return e;let r={},o={},s=[];e.forEach(n=>{r.hasOwnProperty(n.type)||(r[n.type]=[],o[n.type]=[]),r[n.type].push(n.id),o[n.type].push(n)});let l=await this.idMapping.idMappingFacade.getEntitiesByIds(r,t,i);for(let[n,c]of Object.entries(o))c.forEach((p,m)=>{p.id=l[n][m],s.push(p)});return s}};var lt=class{page=null;limit=null;constructor(e){this.page=e.page?e.page:null,this.limit=e.limit?e.limit:null}};var to=class extends lt{action=null;constructor(e){super(e);this.action=e.action?e.action:null}constructFilterUrl(){let e="";return this.action&&(e+="&",e+=`action=${this.action}`),this.page&&(e+="&",e+=`page=${this.page}`),this.limit&&(e+="&",e+=`limit=${this.limit}`),e}};var io=class extends lt{action=null;constructor(e){super(e);this.action=e.action?e.action:null}constructFilterUrl(){let e="";return this.action&&(e+="&",e+=`action=${this.action}`),this.page&&(e+="&",e+=`page=${this.page}`),this.limit&&(e+="&",e+=`limit=${this.limit}`),e}};var ro=class{idSchema;activityHttps;activityService;constructor(e){this.idSchema=e.idSchema,this.activityHttps=new Ge(e),this.activityService=new eo(e)}add=async(e,t,i,r)=>{if(this.idSchema!="native"){let s=JSON.parse(JSON.stringify(t)),l=await this.activityService.remapTagsIds(t,this.idSchema,"native"),n=new It(e,l,i,r),c=await this.activityHttps.createActivity(n);return c.context.tags=s,c}let o=new It(e,t,i,r);return this.activityHttps.createActivity(o)};delete=async e=>await this.activityHttps.deleteActivity(e);like=async(e,t,i)=>{let r="like";return await this.add(r,e,t,i)};dislike=async(e,t,i)=>{let r="dislike";return await this.add(r,e,t,i)};addPageview=async(e,t,i)=>{let r="page_view";return await this.add(r,e,t,i)};addContentConsumed=async(e,t,i)=>{let r="content_consumed";return await this.add(r,e,t,i)};addShare=async(e,t,i)=>{let r="share";return await this.add(r,e,t,i)};addComment=async(e,t,i)=>{let r="comment";return await this.add(r,e,t,i)};addClickAd=async(e,t,i)=>{let r="click_ad";return await this.add(r,e,t,i)};addConversion=async(e,t,i)=>{let r="conversion";return await this.add(r,e,t,i)};getOwn=async(e,t)=>{if(t=t||!1,e&&(e=new to(e)),this.idSchema!="native"){let i=await this.activityHttps.getOwnActivities(e,t);for(let r of i.data)await this.activityService.remapTagsIds(r.context.tags,"native",this.idSchema);return i}return await this.activityHttps.getOwnActivities(e,t)};getForUser=async(e,t,i)=>{if(i=i||!1,t&&(t=new io(t)),this.idSchema!="native"){let r=await this.activityHttps.getActivitiesForUser(e,t,i);for(let o of r.data)await this.activityService.remapTagsIds(o.context.tags,"native",this.idSchema);return r}return await this.activityHttps.getActivitiesForUser(e,t,i)}};var oo=class{activityFacade;constructor(e){this.activityFacade=new ro(e)}add=async(e,t,i,r)=>await this.activityFacade.add(e,t,i,r);delete=async e=>await this.activityFacade.delete(e);like=async(e,t,i)=>await this.activityFacade.like(e,t,i);dislike=async(e,t,i)=>await this.activityFacade.dislike(e,t,i);addPageview=async(e,t,i)=>await this.activityFacade.addPageview(e,t,i);addContentConsumed=async(e,t,i)=>await this.activityFacade.addContentConsumed(e,t,i);addShare=async(e,t,i)=>await this.activityFacade.addShare(e,t,i);addComment=async(e,t,i)=>await this.activityFacade.addComment(e,t,i);addClickAd=async(e,t,i)=>await this.activityFacade.addClickAd(e,t,i);addConversion=async(e,t,i)=>await this.activityFacade.addConversion(e,t,i);getOwn=async(e,t)=>await this.activityFacade.getOwn(e,t);getForUser=async(e,t,i)=>await this.activityFacade.getForUser(e,t,i)};function cI(a){let t=new or().validate(a);if((t.idSchema.validation==="missing"||t.idSchema.validation==="invalid")&&(console.warn(t.idSchema.message.text),a.idSchema="native"),(t.environment.validation==="missing"||t.environment.validation==="invalid")&&(console.warn(t.environment.message.text),a.environment="prod"),(t.lang.validation==="missing"||t.lang.validation==="invalid")&&(console.warn(t.lang.message.text),a.lang="en"),(t.errorHandlingMode.validation==="missing"||t.errorHandlingMode.validation==="invalid")&&(console.warn(t.errorHandlingMode.message.text),a.errorHandlingMode="default"),t.authProvider.validation==="invalid"&&console.warn(t.authProvider.message.text),t.isValid)return{profile:new ae(a),football:new qe(a),predictor:new Lr(a),loyalty:new zr(a),topX:new Jr(a),matchQuiz:new Zr(a),activity:new oo(a)};un(t)}var un=a=>{let e="authProvider",t="isValid";Object.keys(a).forEach(i=>{let r=a[i];if(i!==t&&i!==e){if(r.message.type==="error")throw new Error(r.message.text)}else i!==t&&i===e&&Object.keys(new fe).forEach(o=>{if(r[o].message.type==="error")throw new Error(r[o].message.text)})})};export{cI as FansUnitedSDK};
|
|
4
|
+
${_o.PREDICTOR_USER_RELATED_OPERATION}`},Qa=(a,e)=>`The prediction '${a}' is invalid for market '${e}'. Please check again have you passed appropriate prediction model. For more information please visit our documentation: https://docs.fansunitedmedia.com/sdks/js/match.quiz#gamerelatedoperations`,Ut=a=>`The market '${a}' is not supported from Fans United. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,za=a=>`The market '${a}' is not valid for Top X game. The only available market is CORRECT_SCORE.`,Ja=a=>`The field/s '${a.length>1?a.join(", "):a[0]}' is/are invalid. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/javascript-sdk`,Za=(a,e)=>`The following field/s is/are missing from ${a}: '${e.length>1?e.join(", "):e[0]}'. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,es=(a,e)=>`The field ${a} has incorrect type. The correct type is ${e}`;var E=class{apiSignInUrl=null;instanceAuth=null;instance=null;errorHandlingMode=null;constructor(e,t){this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.errorHandlingMode=e.errorHandlingMode,this.instanceAuth=Ht.default.create({baseURL:t,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instanceAuth.interceptors.request.use(i=>{let r=null;try{r=Ka(e.authProvider.getIdToken())}catch(s){if(this.errorHandlingMode==="default")throw Ya(i,401,s.message);if(this.errorHandlingMode==="standard")throw new h(401,"invalid_token","Invalid JWT token is provided")}return Date.now()>r.exp&&(Ht.default.defaults.headers.common.Authorization=`Bearer ${e.authProvider.getIdToken()}`,i.headers.Authorization=`Bearer ${e.authProvider.getIdToken()}`),i},i=>{Promise.reject(i)}),this.instanceAuth.interceptors.response.use(i=>i,i=>{let r=i.config;if((i.response?.status===403||i.response?.status===401)&&!r._retry){r._retry=!0;let o=e.authProvider.getIdToken();return r.headers.Authorization=`Bearer ${o}`,this.instanceAuth(r)}if(this.errorHandlingMode==="standard"&&i.response?.status===401){let o=new h(401,"unauthorized","The provided JWT token is expired");return Promise.reject(o)}return Promise.reject(i)}),this.instance=Ht.default.create({baseURL:t,headers:{"Content-Type":"application/json"}})}transformAxiosErrorToFansUnitedException=e=>{if(this.errorHandlingMode==="standard"&&e.response&&e.response.data&&e.response.data.error){let{code:t,status:i,message:r}=e.response.data.error;return new h(t,i,r)}return e}};var cn="/countries",C="/profile",xo="/profiles",Ee=class extends E{profileRemapper=null;followingRemapper=null;followersRemapper=null;lang=null;limitIds=100;constructor(e){super(e,S(e.environment,"profile"));this.lang=e.lang,this.profileRemapper=new Et,this.followingRemapper=new vt,this.followersRemapper=new _t}getCountries=async e=>{try{let t=`&lang=${this.lang}`,i=`${cn}${this.apiSignInUrl}${t}`,r=Date.now();return e&&(i+=`&disable_cache=${r}`),(await this.instance.get(i)).data.data}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem fetching the countries:",i),i.response}};getProfile=async e=>{let t=`${C}${this.apiSignInUrl}`;if(e){t=`${xo}/${e}${this.apiSignInUrl}`;try{let i=await this.instance.get(t);return this.profileRemapper.fullProfileFromResponse(i.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn(`There was a problem fetching the following profile: ${e}`,r),r.response}}else try{let i=await this.instanceAuth.get(t);return this.profileRemapper.fullProfileFromResponse(i.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem fetching your profile from API:",r),r.response}};getProfiles=async(e,t)=>{try{let i=Date.now();if(e.length>this.limitIds){let s=[],l=Me(e,this.limitIds);for(let n of l){let c=`${xo}${this.apiSignInUrl}&profile_ids=${n.join(",")}`;t&&(c+=`&disable_cache=${i}`);let p=await this.instance.get(c);s.push(...this.profileRemapper.profilesFromResponse(p.data.data))}return s}let r=`${xo}${this.apiSignInUrl}&profile_ids=${e.join(",")}`;t&&(r+=`&disable_cache=${i}`);let o=await this.instance.get(r);return this.profileRemapper.profilesFromResponse(o.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn(`There was a problem fetching the following profiles: ${e.join(",")}`,r),r.response}};getFollowers=async(e,t)=>{let i=`${C}/followers${this.apiSignInUrl}`;if(e&&!t){i=`${C}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let r=await this.instanceAuth.get(i);return this.followersRemapper.followersFromResponse(r.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn("There was a problem fetching the followers for own profile",o),o.response}}else if(!e&&!t)try{let r=await this.instanceAuth.get(i);return this.followersRemapper.followersFromResponse(r.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn("There was a problem fetching the followers for own profile",o),o.response}e&&t?i=`${C}/${t}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(i=`${C}/${t}/followers${this.apiSignInUrl}`);try{let r=await this.instance.get(i);return this.followersRemapper.followersFromResponse(r.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn(`There was a problem fetching the followers for profile: ${t}`,o),o.response}};getFollowing=async(e,t)=>{let i=`${C}/following${this.apiSignInUrl}`;if(e&&!t){i=`${C}/following${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let r=await this.instanceAuth.get(i);return this.followingRemapper.followingFromResponse(r.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn("There was a problem fetching the followers of own profile",o),o.response}}else if(!e&&!t)try{let r=await this.instanceAuth.get(i);return this.followingRemapper.followingFromResponse(r.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn("There was a problem fetching the followers of own profile",o),o.response}e&&t?i=`${C}/${t}/following${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(i=`${C}/${t}/following${this.apiSignInUrl}`);try{let r=await this.instance.get(i);return this.followingRemapper.followingFromResponse(r.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn(`There was a problem fetching the followers of the following profile: ${t}`,o),o.response}};follow=async e=>{let t=new pt;t.profile_ids=e;try{let i=await this.instanceAuth.post(`${C}/follow${this.apiSignInUrl}`,JSON.stringify(t));return this.followingRemapper.followResponse(i.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn(`There was a problem with POST request for profiles: ${e.join(",")} `,r),r.response}};unfollow=async e=>{let t=new pt;t.profile_ids=e;try{return await this.instanceAuth.delete(`${C}/follow${this.apiSignInUrl}`,{data:JSON.stringify(t)}),!0}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn(`There was a problem with DELETE request for profiles: ${e.join(",")} `,r),r.response}};getBadges=async e=>{let t=`${C}/badges${this.apiSignInUrl}`;try{return e?(t=`${C}/${e}/badges${this.apiSignInUrl}`,(await this.instance.get(t)).data.data):(await this.instanceAuth.get(t)).data.data}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with fetching the badges",r),r.response}};updateProfile=async e=>{try{let t=await this.instanceAuth.patch(`${C}${this.apiSignInUrl}`,e);return this.profileRemapper.fullProfileFromResponse(t.data.data)}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem updating the own profile:",i),i.response}}};var ts="FansUnited",Oo={football:{ids:[],countries:[],competitions:[],expirations:{ids:0}},profile:{info:{},statistics:{},badges:null,countries:[],expirations:{profile:0,statistics:0,badges:0}},client:{features:{},expirations:{features:0}}},L=class{idSchema="";expirationProfileTimeout=600;expirationBadgesTimeout=3600;expirationClientFeaturesTimeout=14400;expirationFootballIdsTimeout=604800;constructor(e){this.idSchema=e.idSchema,(this.getData()===void 0||this.getData()===null)&&this.setData(Oo)}clearData=()=>{this.setData(Oo)};getEntityById=(e="",t="")=>this.getData().football.ids.find(i=>{let r=D[this.idSchema];return i&&`${i[r]}`===t&&i.resource===e});getEntity=(e,t,i)=>Array.isArray(e)?this.getData().football.ids.filter(r=>{let o=D[i];return r&&e.includes(`${r[o]}`)&&r.resource===t}):this.getData().football.ids.find(r=>{let o=D[i];return r&&`${r[o]}`===e&&r.resource===t});getEntityByNativeId=(e="",t="")=>this.getData().football.ids.find(i=>i&&`${i.id}`===t&&i.resource===e);checkForExistingIdObjs=(e,t)=>{let i=D[t],r={};return Object.keys(e).forEach(o=>{let s=e[o],n=this.getEntity(s,o,t).map(p=>p[i]),c=e[o].filter(p=>!n.includes(p));r[o]=s.map(p=>c.includes(p)?{id:p,exists:!1}:{id:p,exists:!0})}),r};getIdsByType=(e,t,i)=>{let r=D[i],o=D[t],s={};return Object.keys(e).forEach(l=>{let n=e[l],c=[];this.getData().football.ids.forEach(p=>{n.forEach((m,d)=>{m===p[o]&&l===p.resource&&(c[d]=p[r])})}),s[l]=c}),s};addIdMapping=e=>{let t=this.getData();t.football.ids.push(e),this.setData(t)};addIdMappings=e=>{let t=this.getData(),i=t.football.ids;i=[...i,...e],t.football.ids=i,this.setData(t)};addTopIdMappings=e=>{let t=this.getData();if(t.football.ids.length){let i=JSON.parse(JSON.stringify(t.football.ids));i=i.filter(r=>r.resource!=="match"),e=e.filter(r=>r.resource==="match"),i=[...i,...e],t.football.ids=i}else t.football.ids=e;t.football.expirations.ids=Math.floor(Date.now()/1e3)+this.expirationFootballIdsTimeout,this.setData(t)};setOwnProfile=e=>{let t=this.getData();t.profile.info=e,t.profile.expirations.profile=Math.floor(Date.now()/1e3)+this.expirationProfileTimeout,this.setData(t)};getOwnProfile=()=>this.getData().profile.info;getProfileCountries=()=>this.getData().profile.countries;setProfileCountries=e=>{let t=this.getData();t.profile.countries=e,this.setData(t)};getProfileStats=()=>this.getData().profile.statistics;setProfileStats=e=>{let t=this.getData();t.profile.statistics=e,t.profile.expirations.statistics=Math.floor(Date.now()/1e3)+this.expirationProfileTimeout,this.setData(t)};getProfileBadges=()=>this.getData().profile.badges;setProfileBadges=e=>{let t=this.getData();t.profile.badges=e,t.profile.expirations.badges=Math.floor(Date.now()/1e3)+this.expirationBadgesTimeout,this.setData(t)};getFootballCountries=()=>this.getData().football.countries;setFootballCountries=e=>{let t=this.getData();t.football.countries=e,this.setData(t)};getCompetitions=e=>{let t=this.getData();return e?e.competitionSearchFilter(t.football.competitions):t.football.competitions};setCompetitions=e=>{let t=this.getData(),i=[...t.football.competitions];i.push(...e),t.football.competitions=this.makeCompetitionsUnique(i),this.setData(t)};getCompetitionsLength=()=>{let{football:e}=this.getData();return e.competitions.length};getClientFeatures=()=>this.getData().client.features;setClientFeatures=e=>{let t=this.getData(),i=JSON.parse(JSON.stringify(e));t.client.expirations.features=Math.floor(Date.now()/1e3)+this.expirationClientFeaturesTimeout,t.client.features=i,this.setData(t)};getExpiration=(e,t)=>{this.initialNewSchema(e,"expirations");let i=this.getData();switch(t){case"profile":return i.profile.expirations.profile;case"statistics":return i.profile.expirations.statistics;case"badges":return i.profile.expirations.badges;case"features":return i.client.expirations.features;case"ids":return i.football.expirations.ids}};makeCompetitionsUnique=e=>{let t=new Set;return e.filter(i=>{let r=!t.has(i.id);return t.add(i.id),r})};getData=()=>JSON.parse(localStorage.getItem(ts));setData=e=>{localStorage.setItem(ts,JSON.stringify(e))};initialNewSchema=(e,t)=>{let i=this.getData();(!i||!i[e]||!i[e][t])&&this.setData(Oo)}};var ut={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},kt=class extends E{constructor(e){super(e,S(e.environment,"idMapping"))}getEntityById=(e,t)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${config.idSchema}&${ut[e]}=${t}`)}catch(i){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,i),i.response}};getEntityByIdAndSchema=(e,t,i)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${i}&${ut[e]}=${t}`)}catch(r){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,r),r.response}};getEntityIdsByIdsAndSchema=(e,t,i)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${i}&${ut[e]}=${t.join(",")}`)}catch(r){throw console.warn(`There was a problem with id mapping request for the following ids:${t.join(",")}`,r),r.response}};getEntitiesByIds=(e,t,i)=>{t.sort((s,l)=>s.localeCompare(l));let o=no(t).map(s=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${i}&${ut[e]}=${s.join(",")}`)}catch(l){let n=this.transformAxiosErrorToFansUnitedException(l);throw console.warn(`There was a problem with id mapping request for the following ids:${s.join(",")}`,n),n.response}});return Promise.all(o).then(s=>{let l=[];return s.forEach(n=>{l.push(...n.data.data)}),l})};getEntitiesByIdObjs=async(e,t)=>{let i=[],r={},o=[];Object.keys(e).forEach(c=>{i.push.apply(i,e[c])});let s=te(i),l=no(s);for(let c of l){let p="";if(Object.keys(e).forEach(m=>{r[m]=[];let d=c.filter(J=>e[m].includes(J));d&&d.length>0&&(r[m]=d)}),Object.keys(r).forEach(m=>{r[m].length>0&&(r[m].sort((d,J)=>d.localeCompare(J)),p+="&",p+=`${ut[m]}=${r[m].join(",")}`)}),p&&p.length>0)try{let m=await this.instance.get(`/football${this.apiSignInUrl}&input_provider=${t||"native"}${p}`);o.push(m.data.data)}catch(m){let d=this.transformAxiosErrorToFansUnitedException(m);throw console.warn("There was a problem with id mapping request",d),d.response}else o.push([])}return Array.prototype.concat.apply([],o)};getTopEntities=async()=>{try{return(await this.instance.get(`/football/top${this.apiSignInUrl}`)).data.data}catch(e){let t=this.transformAxiosErrorToFansUnitedException(e);throw console.warn("There was a problem with top id mappings request",t),t.response}}};var Gt=class{isBrowser=!1;localStorage=null;https=null;constructor(e){this.isBrowser=typeof window!="undefined",this.localStorage=new L(e),this.https=new kt(e)}getEntitiesByIds=async(e,t,i)=>{if(this.isBrowser){await this.setTopIdMappings();try{let r=this.localStorage.checkForExistingIdObjs(e,t),o=this.splitForRequestAndExisting(r),s=await this.https.getEntitiesByIdObjs(o.request,t);return this.localStorage.addIdMappings(s),this.localStorage.getIdsByType(e,t,i)}catch(r){return console.warn("There was a problem retrieving the entity ids ",r),Promise.resolve([])}}else try{let r=await this.https.getEntitiesByIdObjs(e,t);return Object.keys(e).forEach(o=>{e[o]=r.filter(s=>s.resource===o).map(s=>s[D[i]])}),e}catch(r){return console.warn("There was a problem retrieving the entity ids ",r),Promise.resolve([])}};getEntityById=async(e,t,i)=>{if(this.isBrowser){let r=this.localStorage.getEntity(e,t,i);if(r)return r;{let o=await this.requestEntity(e,t,i);return this.localStorage.addIdMappings(o),o}}else return await this.requestEntity(e,t,i)};splitForRequestAndExisting=e=>{let t={},i={};return Object.keys(e).forEach(r=>{t[r]=e[r].filter(o=>!o.exists).map(o=>o.id),i[r]=e[r].filter(o=>o.exists).map(o=>o.id)}),{existing:i,request:t}};requestEntity=async(e,t,i)=>{try{return e=Array.isArray(e)?e:[e],await this.https.getEntitiesByIds(t,e,i)}catch(r){return console.warn(`There was a problem retrieving the requested entity: ${r}`),null}};setTopIdMappings=async()=>{let e=Math.floor(Date.now()/1e3);if(this.localStorage.getExpiration("football","ids")>e)return Promise.resolve();let i=await this.https.getTopEntities();this.localStorage.addTopIdMappings(i)}};var Vt=a=>{switch(a){case"competitions":return"competition";case"players":case"relatedPlayer":case"squad":return"player";case"teams":case"participants":case"homeTeam":case"awayTeam":case"timeline":case"teamId":return"team";default:return a}};var $t=class{extractedObjIds={};traverse=(e,t)=>(t=Vt(t),Array.isArray(e)?this.traverseArrExtract(e,t):e&&typeof e=="object"&&this.traverseObjExtract(e,t),this.extractedObjIds);traverseArrExtract=(e,t)=>{e&&e.length>0&&e.forEach(i=>{this.traverseObjExtract(i,t)})};traverseObjExtract=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(i=>{let r=e[i];i==="id"||i==="teamId"?(this.extractedObjIds.hasOwnProperty(t)||(this.extractedObjIds[t]=[]),r&&this.extractedObjIds[t].push(r)):e[i]&&this.traverse(e[i],i)})}};var qt=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(e,t,i)=>(t=Vt(t),this.replaceObjIdsIndex===null&&(this.initReplaceObjIdsIndex(i),this.remappedIdsObj=i),Array.isArray(e)?this.traverseArrReplace(e,t):e&&typeof e=="object"&&this.traverseObjReplace(e,t),e);initReplaceObjIdsIndex=e=>{this.replaceObjIdsIndex={},Object.keys(e).forEach(t=>{this.replaceObjIdsIndex[t]=0})};traverseArrReplace=(e,t)=>{e&&e.length>0&&e.forEach(i=>{this.traverseObjReplace(i,t)})};traverseObjReplace=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(i=>{i==="id"||i==="teamId"?e[i]&&(e[i]=this.remappedIdsObj[t][this.replaceObjIdsIndex[t]],this.replaceObjIdsIndex[t]=this.replaceObjIdsIndex[t]+1):e[i]&&this.traverse(e[i],i,this.remappedIdsObj)})}};var b=class{idSchema="";idMappingFacade=null;constructor(e){this.idSchema=e.idSchema,this.idMappingFacade=new Gt(e)}getEntityIdBySchemaId=(e,t)=>this.idMappingFacade.getEntityById(e,t,this.idSchema);remapEntities=async(e,t)=>{let i=JSON.parse(JSON.stringify(e));try{if(this.idSchema!=="native"){let o=new $t().traverse(i,t);return this.idMappingFacade.getEntitiesByIds(o,"native",this.idSchema).then(s=>new qt().traverse(i,t,s))}else return e}catch(r){return console.warn(`There was a problem remapping entity: ${t} with inner entity `,r),[]}};getEntityIdsBySchemaId=async(e,t,i)=>{let r={};return r[t]=e,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(r,this.idSchema,i):r}};var O=class{completed=!1;percentage;constructor(e){this.percentage=e}};var jt=class{teamFollowed=new O(10);teamFavourite=new O(15);playerFollowed=new O(10);playerFavourite=new O(10);competitionFollowed=new O(10);competitionFavourite=new O(5);addedBirthdate=new O(10);addedGender=new O(10);addedCountry=new O(10);addedAvatar=new O(10)};var Xt=class{totalPercentage;breakdown=new jt};var ht=class{limit=0;startAfter=null;constructor(e){this.limit=e.limit?e.limit:20,this.startAfter=e.startAfter?e.startAfter:null}constructFilterUrl=()=>{let e="";return this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.startAfter&&(e=e+"&",e=e+`start_after=${this.startAfter}`),e}};var j=class{isBrowser=!1;localStorage={};profileHttps=null;activityHttps=null;constructor(e,t,i){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.profileHttps=t,this.activityHttps=i}getOwn=async()=>{if(this.isBrowser){let e=this.getLocalStorageData("profile");if(e)return JSON.parse(JSON.stringify(e));try{let t=await this.profileHttps.getProfile();return this.localStorage.setOwnProfile(t),t}catch(t){throw console.warn("There was a problem retrieving your profile: ",t),t}}else try{return await this.profileHttps.getProfile()}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};updateOwnProfile=async()=>{try{let e=await this.profileHttps.getProfile();return this.localStorage.setOwnProfile(e),e}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};getByIds=async(e,t)=>{try{return t=t||!1,await this.profileHttps.getProfiles(e,t)}catch(i){throw console.warn(`There was a problem retrieving the selected profiles: ${e.join(",")} `,i),i}};getById=async e=>{try{return await this.profileHttps.getProfile(e)}catch(t){throw console.warn(`There was a problem retrieving the selected profile: ${e} `,t),t}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let t=this.localStorage.getProfileCountries();if(t&&t.length>0)return t;try{let i=await this.profileHttps.getCountries(e);return this.localStorage.setProfileCountries(i),i}catch(i){throw console.warn("There was a problem retrieving profile countries: ",i),i}}else try{return await this.profileHttps.getCountries(e)}catch(t){throw console.warn("There was a problem retrieving profile countries: ",t),t}};getFollowers=async(e,t)=>{try{e&&(e=new ht(e));let i=await this.profileHttps.getFollowers(e,t),r=i.data.map(o=>o.followerId);if(r.length){let o=await this.getByIds(r),s=i.data.map(l=>(o.forEach(n=>{l.followerId===n.id&&(l.name=n.name,l.nickname=n.nickname,l.avatar=n.avatar)}),l));return i.data=s,i}return i}catch(i){throw console.warn("There was a problem retrieving your followers: ",i),i}};getFollowing=async(e,t)=>{try{e&&(e=new ht(e));let i=await this.profileHttps.getFollowing(e,t),r=i.data.map(o=>o.followingId);if(r.length){let o=await this.getByIds(r),s=i.data.map(l=>(o.forEach(n=>{l.followingId===n.id&&(l.name=n.name,l.nickname=n.nickname,l.avatar=n.avatar)}),l));return i.data=s,i}return i}catch(i){throw console.warn("There was a problem retrieving your following profiles: ",i),i}};follow=async e=>{try{return await this.profileHttps.follow(e)}catch(t){throw console.warn(`There was a problem following profiles: ${e.join(",")} `,t),t}};unfollow=async e=>{try{return await this.profileHttps.unfollow(e)}catch(t){throw console.warn(`There was a problem unfollowing profiles: ${e.join(",")} `,t),t}};showFullnessProfile=e=>{let t=new Xt,i=0;return e.avatar&&(t.breakdown.addedAvatar.completed=!0,i+=t.breakdown.addedAvatar.percentage),e.birthDate&&(t.breakdown.addedBirthdate.completed=!0,i+=t.breakdown.addedBirthdate.percentage),e.country&&(t.breakdown.addedCountry.completed=!0,i+=t.breakdown.addedCountry.percentage),e.gender&&(t.breakdown.addedGender.completed=!0,i+=t.breakdown.addedGender.percentage),e.interests&&e.interests.length>0&&(e.interests.find(p=>p.type==="team"&&p.favourite)&&(t.breakdown.teamFavourite.completed=!0,i+=t.breakdown.teamFavourite.percentage),e.interests.find(p=>p.type==="team")&&(t.breakdown.teamFollowed.completed=!0,i+=t.breakdown.teamFollowed.percentage),e.interests.find(p=>p.type==="player"&&p.favourite)&&(t.breakdown.playerFavourite.completed=!0,i+=t.breakdown.playerFavourite.percentage),e.interests.find(p=>p.type==="player")&&(t.breakdown.playerFollowed.completed=!0,i+=t.breakdown.playerFollowed.percentage),e.interests.find(p=>p.type==="competition"&&p.favourite)&&(t.breakdown.competitionFavourite.completed=!0,i+=t.breakdown.competitionFavourite.percentage),e.interests.find(p=>p.type==="competition")&&(t.breakdown.competitionFollowed.completed=!0,i+=t.breakdown.competitionFollowed.percentage)),t.totalPercentage=i,t};getStats=async()=>{if(this.isBrowser){let e=this.getLocalStorageData("statistics");if(e&&Object.keys(e).length)return JSON.parse(JSON.stringify(e));try{let t=await this.activityHttps.getStats();return this.localStorage.setProfileStats(t),t}catch(t){throw console.warn("There was a problem retrieving own profile statistics: ",t),t}}else try{return await this.activityHttps.getStats()}catch(e){throw console.warn("There was a problem retrieving own profile statistics: ",e),e}};getBadges=async()=>{if(this.isBrowser){let e=this.getLocalStorageData("badges");if(e)return e;try{let t=await this.profileHttps.getBadges();return this.localStorage.setProfileBadges(t),t}catch(t){throw console.warn("There was a problem retrieving own profile badges: ",t),t}}else try{return await this.profileHttps.getBadges()}catch(e){throw console.warn("There was a problem retrieving own profile badges: ",e),e}};getLocalStorageData=e=>{let t=Math.floor(Date.now()/1e3),i=this.localStorage.getExpiration("profile",e);switch(e){case"profile":if(i>t)return this.localStorage.getOwnProfile();case"statistics":if(i>t)return this.localStorage.getProfileStats();case"badges":if(i>t)return this.localStorage.getProfileBadges();default:return null}}};var Wt=class{id=null;name=null;assets=null};var Kt=class{extractUpdatedProps=(e,t)=>{let i=["name","nickname","gender","avatar"],r={};return Object.keys(e).forEach(o=>{if(i.includes(o)&&e[o]!==t[o])r[o]=t[o];else if(o==="birthDate")(t[o]===null||e[o]===null&&t[o]||e[o]!==t[o])&&(r.birth_date=t[o]);else if(o==="country")t[o]===null?r.country_id=t[o]:(e[o]===null&&t[o]||e[o].id!==t[o].id)&&(r.country_id=t[o].id);else if(o==="interests"){let s=e[o],l=t[o];l.length&&this.isNewInterest(s,l)?r[o]=this.updateInterests(s,l):(!l.length&&s.length||s.length!==l.length&&!this.isNewInterest(s,l))&&(r[o]=l)}}),r};updateInterests=(e,t)=>{if(e.length===t.length){let[i,r]=this.extractSameAndNewInterests(e,t);return[...r,...i]}else return t};isNewInterest=(e,t)=>{let i=!1,[r]=this.extractSameAndNewInterests(e,t);return r.length&&(i=!0),i};extractSameAndNewInterests=(e,t)=>{let i=t.filter(o=>e.some(s=>o.id===s.id&&o.type===s.type&&o.source===s.source&&o.favourite===s.favourite));return[t.filter(o=>!e.some(s=>o.id===s.id&&o.type===s.type&&o.source===s.source&&o.favourite===s.favourite)),i]};isAvatarValidURL=e=>{try{return new URL(e),!0}catch{return!1}}};var g=class extends Error{code=0;status=null;message=null;constructor(e,t,i){super();this.code=e,this.status=t,this.message=i}errorMessage=()=>this.message};var Yt=class{idsRemapper=null;profileHttps=null;profileService=null;localStorage=null;profileFacade=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;errorHandlingMode=null;constructor(e,t,i,r,o){this.idsRemapper=e,this.localStorage=t,this.profileHttps=i,this.errorHandlingMode=o,this.profileService=new Kt,this.profileFacade=new j(t,i,r)}getOwnProfile=async()=>{for(;this.isFetching;)console.log("Another thread is fetching profile..."),await this.delay(100);if(this.modified&&this.ownProfile)return console.log("Timestamp is less than 10 minutes OR profile is modifying "),this.ownProfile;let e=Math.floor(Date.now()/1e3);if(!this.ownProfile||this.expireAt<e){this.isFetching=!0,this.expireAt=Math.floor(Date.now()/1e3)+600;try{let t=await this.profileFacade.getOwn();this.setOwnProfile(t)}catch(t){throw this.isFetching=!1,t}return this.modified=!1,this.isFetching=!1,this.ownProfile}return this.ownProfile};delay=e=>new Promise(t=>{setTimeout(t,e)});setOwnProfile=e=>{this.ownProfile=e};getInfo=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return delete t.interests,t};showInterests=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.remapInterests(t.interests)};showFullInterests=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.showFullInterests(t.interests)};getFollowers=async e=>await this.profileFacade.getFollowers(e);getFollowing=async e=>await this.profileFacade.getFollowing(e);follow=async e=>{let t=await this.profileFacade.follow(e),i=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(i),t};unfollow=async e=>{let t=await this.profileFacade.unfollow(e),i=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(i),t};getStats=async()=>{let e=await this.profileFacade.getStats();return await this.idsRemapper.remapSuccessRatesEntities(e)};getBadges=async()=>await this.profileFacade.getBadges();addInterestPromise=async e=>{this.modified=!0;let t={...e};await this.getOwnProfile();let i=null;e.source!=="custom"?i=await this.idsRemapper.remapInterestToNative(t):i=t;let r=this.ownProfile.interests.filter(o=>o.id!==i.id||o.type!==i.type||o.source!==i.source);return this.ownProfile.interests=[...r],this.ownProfile.interests.push(i),this};addInterest=e=>(this.promises.push(this.addInterestPromise(e)),this);removeInterestPromise=async e=>{this.modified=!0;let t={...e};await this.getOwnProfile();let i=null;return e.source!=="custom"?i=await this.idsRemapper.remapInterestToNative(t):i=t,this.ownProfile.interests=this.ownProfile.interests.filter(r=>r.id!==i.id||r.type!==i.type||r.source!==i.source),this};removeInterest=e=>(this.promises.push(this.removeInterestPromise(e)),this);setBirthdatePromise=async e=>(this.modified=!0,await this.getOwnProfile(),e?this.ownProfile.birthDate=e:this.ownProfile.birthDate=null,this);setBirthdate=e=>(this.promises.push(this.setBirthdatePromise(e)),this);setGenderPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e==="male"||e==="female"?this.ownProfile.gender=e:this.ownProfile.gender="unspecified",this);setGender=e=>(this.promises.push(this.setGenderPromise(e)),this);setNicknamePromise=async e=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.nickname=e,this);setNickname=e=>(this.promises.push(this.setNicknamePromise(e)),this);setNamePromise=async e=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.name=e,this);setName=e=>(this.promises.push(this.setNamePromise(e)),this);setCountryPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e&&!this.ownProfile.country?(this.ownProfile.country=new Wt,this.ownProfile.country.id=e):e&&this.ownProfile.country?this.ownProfile.country.id=e:this.ownProfile.country=null,this);setCountry=e=>(this.promises.push(this.setCountryPromise(e)),this);showFullnessProfile=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return this.profileFacade.showFullnessProfile(t)};setAvatarPromise=async e=>{if(this.modified=!0,await this.getOwnProfile(),this.profileService.isAvatarValidURL(e))this.ownProfile.avatar=e;else{if(this.errorHandlingMode==="default")throw new g(400,"invalid_avatar","Invalid URL syntax for avatar image.");if(this.errorHandlingMode==="standard")throw new h(400,"invalid_avatar","Invalid URL syntax for avatar image.").response}return this};setAvatar=e=>(this.promises.push(this.setAvatarPromise(e)),this);update=async()=>{if(this.promises.length===0)return this.ownProfile;await Promise.all(this.promises);let e=await this.profileFacade.getOwn(),t=await this.getOwnProfile(),i=this.profileService.extractUpdatedProps(e,t);if(this.modified=!1,this.expireAt=0,Object.keys(i).length){let o=await this.profileHttps.updateProfile(i),s=JSON.parse(JSON.stringify(o));return this.setOwnProfile(s),this.localStorage.setOwnProfile(s),delete o.interests,o}let r=JSON.parse(JSON.stringify(this.ownProfile));return delete r.interests,r}};var Qt=class{idsRemapper=null;profileHttps=null;activityHttps=null;profileFacade=null;profileId="";constructor(e,t,i,r){this.idsRemapper=e,this.profileHttps=i,this.activityHttps=r,this.profileFacade=new j(t,i,r)}setId=e=>(this.profileId=e,this);getProfile=async()=>await this.profileFacade.getById(this.profileId);getInfo=async()=>{let e=await this.getProfile();return delete e.interests,e};showInterests=async()=>{let e=await this.getProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.remapInterests(t.interests)};showFullInterests=async()=>{let e=await this.getProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.showFullInterests(t.interests)};getFollowers=async e=>await this.profileFacade.getFollowers(e,this.profileId);getFollowing=async e=>await this.profileFacade.getFollowing(e,this.profileId);showFullnessProfile=async()=>{let e=await this.getProfile();return this.profileFacade.showFullnessProfile(e)};getStats=async e=>{let t=await this.activityHttps.getStats(this.profileId,e);return await this.idsRemapper.remapSuccessRatesEntities(t)};getBadges=async()=>await this.profileHttps.getBadges(this.profileId)};var zt=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,i){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=i,this.https=t}getCountriesWithIdMapping=async e=>{try{let t=await this.getCountries(e);return this.idMapping.remapEntities(t,"country")}catch(t){throw console.warn("There was a problem browsing countries as football entities",t),t}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let t=this.localStorage.getFootballCountries();if(t&&t.length>0)return t;try{let i=await this.https.getCountries(e);return this.localStorage.setFootballCountries(i),i}catch(i){throw console.warn("There was a problem retrieving countries as football entities",i),i}}else return this.https.getCountries(e)}};var ft=class{countryId=null;name=null;gender=null;type=null;sortField=null;sortOrder=null;competitionIds=null;constructor(e){this.countryId=e.countryId?`${e.countryId}`:null,this.name=e.name?e.name:null,this.gender=e.gender?e.gender:null,this.type=e.type?e.type:null,this.sortField=e.sortField?`${e.sortField}`:null,this.sortOrder=e.sortOrder?`${e.sortOrder}`:null,this.competitionIds=e.competitionIds?e.competitionIds:null}constructFilterUrl=()=>{let e="";return this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.gender&&(e=e+"&",e=e+`gender=${this.gender}`),this.type&&(e=e+"&",e=e+`type=${this.type}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),this.name&&(e=e+"&",e=e+`name=${this.name}`),this.competitionIds&&(e=e+"&",e=e+`competition_ids=${this.competitionIds.join(",")}`),e};competitionSearchFilter=e=>{try{let t=this.filter(e);return this.sortField||this.sortOrder?this.sort(t):t}catch(t){return console.warn("There was a problem filtering the local competitions",t),[]}};filter=e=>{let t=this.entitiesToSearchWith();return e.filter(i=>{let r=!0;return t.forEach(o=>{o!=="sortOrder"&&o!=="sortField"&&(o==="countryId"?r&&=i.country.id===this[o]:o==="name"?r&&=i.name.toLocaleLowerCase().includes(this[o].toLocaleLowerCase()):o==="competitionIds"?r&&=this[o].some(s=>i.id===s):r&&=i[o].toLocaleLowerCase()===this[o].toLocaleLowerCase())}),r})};entitiesToSearchWith=()=>{let e=[];return this.countryId&&e.push("countryId"),this.name&&e.push("name"),this.gender&&e.push("gender"),this.type&&e.push("type"),this.sortField&&e.push("sortField"),this.sortOrder&&e.push("sortOrder"),this.competitionIds&&e.push("competitionIds"),e};sort=e=>{let t=[];return this.sortField==="name"?t=e.sort((i,r)=>this.sortOrder&&this.sortOrder==="desc"?r.name.localeCompare(i.name):i.name.localeCompare(r.name)):this.sortField==="country"?t=e.sort((i,r)=>this.sortOrder&&this.sortOrder==="desc"?r.country.name.localeCompare(i.country.name):i.country.name.localeCompare(r.country.name)):this.sortField==="scope"?e.forEach(i=>t[this.competitionIds.indexOf(i.id)]=i):!this.sortField&&this.sortOrder==="desc"&&(t=e.sort((i,r)=>r.id.localeCompare(i.id))),t}};var Jt=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,i){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=i,this.https=t}getCompetitionsIdMapping=async(e,t)=>{try{let i=!1;if(e){if(e=new ft(e),e.countryId){let o=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");o.country.length===0&&(i=!0),e.countryId=o.country[0]}if(e.competitionIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");o.competition.length===0&&(i=!0),e.competitionIds=o.competition}if(i)return[]}let r=await this.getCompetitions(e,t);return await this.idMapping.remapEntities(r,"competition")}catch(i){throw console.warn("There was a problem browsing all of the competitions",i),i}};getCompetitionsMapWithNativeIds=async e=>{let t=new Map,i=e.length,r=new ft({competitionIds:e,limit:i}),o=await this.getCompetitions(r);o.sort((n,c)=>n.id.localeCompare(c.id));let s=Ft(e),l=await this.idMapping.remapEntities(o,"competition");return s.forEach((n,c)=>t.set(n,l[c])),t};getCompetitions=async(e,t)=>{let i=null;if(t=t||!1,this.isBrowser){if(!this.localStorage.getCompetitionsLength()){try{i=await this.https.getCompetitions()}catch(r){throw console.warn("There was a problem retrieving all competitions",r),r}this.localStorage.setCompetitions(i)}return this.localStorage.getCompetitions(e)}else return this.https.getCompetitions(e,t)};getCompetitionByIdIdMapping=async(e,t)=>{try{let r=(await this.idMapping.getEntityIdsBySchemaId([e],"competition","native")).competition[0],o=await this.getCompetitionById(r,t);return await this.idMapping.remapEntities(o,"competition")}catch(i){throw console.warn(`There was a problem browsing the following competition:${e}`,i),i}};getCompetitionById=async(e,t)=>{try{return t=t||!1,await this.https.getCompetitionById(e,t)}catch(i){throw console.warn(`There was a problem retrieving the competition with the following id: ${e}`,i),i}};getTopCompetitionsIdMapping=async e=>{try{let t=await this.getTopCompetitions(e);return await this.idMapping.remapEntities(t,"competition")}catch(t){throw console.warn("There was a problem browsing the top competitions",t),t}};getTopCompetitions=async e=>{try{return e=e||!1,await this.https.getTopCompetitions(e)}catch(t){throw console.warn("There was a problem retrieving the top competitions",t),t}}};var gt=class{name=null;countryId=null;national=!1;gender=null;limit=null;page=null;scope=null;sortField=null;sortOrder=null;teamIds=null;constructor(e){this.name=e.name?e.name:null,this.countryId=e.countryId?`${e.countryId}`:null,this.national=e.national?e.national:!1,this.gender=e.gender?e.gender:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.scope=e.scope?e.scope:null,this.sortField=e.sortField?`${e.sortField}`:null,this.sortOrder=e.sortOrder?`${e.sortOrder}`:null,this.teamIds=e.teamIds?e.teamIds:null}constructFilterUrl=()=>{let e="";return this.name&&(e=e+"&",e=e+`name=${this.name}`),this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.national&&(e=e+"&",e=e+`national=${this.national}`),this.gender&&(e=e+"&",e=e+`gender=${this.gender}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),this.teamIds&&(e=e+"&",e=e+`team_ids=${this.teamIds.join(",")}`),e}};var Zt=class{general=[];predictor=[];topX=[];matchQuiz=[]};var Re=class{points=null;gameParticipationCount=null;entityId=null;entityType=null;predictionsMade=null;correctPredictions=null};var ei=class{id;label;assets={mainImageUrl:""};enabled;requirements=new Re};var ti=class{id;weight;multiplier;conditions};var ii=class{value=[new ti]};var Te=class{points=null;tiers=null;badges=null};var ri=class{enabled=!1;conditions={list:null};actions=new ii;rewards=new Te};var oi=class{general=null;comments=null;predictor=null;activity=null;topX=null;matchQuiz=null};var ve=class{enabled=!1;defaultMarkets=null;competitionsWhitelist=null};var Se=class{enabled=!1;minFixtures=null;maxFixtures=null;competitionsWhitelist=null};var ai=class{competitions=[];teams=[];markets=[]};var _e=class{enabled=!1;fullCoverageCompetitions=null;markets=null;successRateScopes=new ai};var si=class{remapPredictorConfig=e=>{let t=new _e;return t.enabled=e.enabled,t.fullCoverageCompetitions=e.full_coverage_competitions,t.markets=e.markets,t.successRateScopes=e.success_rate_scopes,t};remapTopXConfig=e=>{let t=new Se;return t.enabled=e.enabled,t.minFixtures=e.min_fixtures,t.maxFixtures=e.max_fixtures,t.competitionsWhitelist=e.competitions_whitelist,t};remapMatchQuizConfig=e=>{let t=new ve;return t.enabled=e.enabled,t.defaultMarkets=e.default_markets,t.competitionsWhitelist=e.competitions_whitelist,t};remapLoyaltyConfig=e=>{let t=new ri;return t.enabled=e.enabled,t.conditions.list=e.conditions.list,t.actions.value=e.actions.value,t.rewards=this.remapRewards(e.rewards),t};remapRewards=e=>{let t=new Te;return t.points=this.remapPoints(e.points),t.tiers=e.tiers,t.badges=this.remapBadges(e.badges),t};remapPoints=e=>{let t=new oi;return t.general=e.general,t.comments=e.comments,t.predictor=e.predictor,t.activity=e.activity,t.topX=e.top_x,t.matchQuiz=e.match_quiz,t};remapBadges=e=>{let t=new Zt;return t.general=e.general,t.predictor=this.remapBadgeValues(e.predictor),t.topX=this.remapBadgeValues(e.top_x),t.matchQuiz=this.remapBadgeValues(e.match_quiz),t};remapBadgeValues=e=>e.map(t=>{let i=new ei;return i.id=t.id,i.label=t.label,i.enabled=t.enabled,t.assets?i.assets.mainImageUrl=t.assets.main_image_url:i.assets=t.assets,i.requirements=this.remapRequirements(t.requirements),i});remapRequirements=e=>{let t=new Re;return t.points=e.points,t.gameParticipationCount=e.game_participation_count,t.entityId=e.entity_id,t.entityType=e.entity_type,t.predictionsMade=e.predictions_made,t.correctPredictions=e.correct_predictions,t}};var B=class extends E{featureConfigRemapper=null;localStorage=null;clientId=null;constructor(e){super(e,S(e.environment,"client"));this.clientId=e.clientId,this.localStorage=new L(e),this.featureConfigRemapper=new si}getConfig=async e=>{try{let t=this.getCachedFeatures();if(!t){let i=`/clients/${this.clientId}/features`,r=this.apiSignInUrl.split("&")[0];t=(await this.instance.get(`${i}${r}`)).data.data,this.localStorage.setClientFeatures(t)}switch(e){case"predictor":return this.featureConfigRemapper.remapPredictorConfig(t.predictor);case"topX":return this.featureConfigRemapper.remapTopXConfig(t.top_x);case"matchQuiz":return this.featureConfigRemapper.remapMatchQuizConfig(t.match_quiz);case"loyalty":return this.featureConfigRemapper.remapLoyaltyConfig(t.loyalty)}}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem fetching configuration from Client API",i),i.response}};getCachedFeatures=()=>{let e=this.getLocalStorageData();if(!(!e||!Object.keys(e).length))return e};getLocalStorageData=()=>{let e=Math.floor(Date.now()/1e3);return this.localStorage.getExpiration("client","features")>e?this.localStorage.getClientFeatures():null}};var ie=class{clientHttps=null;constructor(e){this.clientHttps=new B(e)}setAvailableMarketsForMatch=async e=>{let{fullCoverageCompetitions:t,markets:i}=await this.clientHttps.getConfig("predictor");if(Array.isArray(e))return e.map(r=>this.setAvailableMarkets(r,t,i));if(typeof e=="object"&&Object.keys(e).length)return this.setAvailableMarkets(e,t,i)};setAvailableMarkets=(e,t,i)=>{let r=e.context.competition?.id;return r&&this.isMatchInCoverageCompetition(r,t)?(e.availableMarkets=i.all,e):(e.availableMarkets=i.main,e)};isMatchInCoverageCompetition=(e,t)=>{let i=!1;return t.includes(e)&&(i=!0),i}};var li=class{footballService=null;https=null;idMapping=null;constructor(e,t,i){this.idMapping=i,this.https=t,this.footballService=new ie(e)}getTeamsIdMapping=async(e,t)=>{try{let i=!1;if(e){if(e=new gt(e),e.countryId){let o=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");o.country.length===0&&(i=!0),e.countryId=o.country[0]}if(e.scope){let o=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");o.competition.length===0&&(i=!0),e.scope=o.competition}if(e.teamIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");o.team.length===0&&(i=!0),e.teamIds=o.team}}if(i)return[];let r=await this.getTeams(e,t);return r.data=await this.idMapping.remapEntities(r.data,"team"),r}catch(i){throw console.warn("There was a problem browsing all teams",i),i}};getTeamsMapWithNativeIds=async e=>{let t=new Map,i=e.length,r=new gt({teamIds:e,limit:i}),{data:o}=await this.getTeams(r);o.sort((n,c)=>n.id.localeCompare(c.id));let s=Ft(e),l=await this.idMapping.remapEntities(o,"team");return s.forEach((n,c)=>t.set(n,l[c])),t};getTeams=async(e,t)=>{try{return t=t||!1,await this.https.getTeams(e,t)}catch(i){throw console.warn("There was a problem retrieving all teams",i),i}};getTeamByIdIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let r=await this.getTeamById(e,t);return await this.idMapping.remapEntities(r,"team")}catch(i){throw console.warn(`There was a problem browsing the following team:${e}`,i),i}};getTeamById=async(e,t)=>{try{return t=t||!1,await this.https.getTeamById(e,t)}catch(i){throw console.warn(`There was a problem retrieving the following team: ${e}`,i),i}};getTopTeamsIdMapping=async e=>{try{let t=await this.getTopTeams(e);return await this.idMapping.remapEntities(t,"team")}catch(t){throw console.warn("There was a problem browsing the top teams",t),t}};getTopTeams=async e=>{try{return e=e||!1,await this.https.getTopTeams(e)}catch(t){throw console.warn("There was a problem retrieving the top teams",t),t}};getNextMatchForTeamIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let r=await this.getNextMatchForTeam(e,t);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the next match for the following team:${e}`,i),i}};getNextMatchForTeam=async(e,t)=>{try{t=t||!1;let i=await this.https.getNextMatchForTeam(e,t);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the next match for the following team: ${e}`,i),i}};getPrevMatchForTeamIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let r=await this.getPrevMatchForTeam(e,t);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the previous match for the following team:${e}`,i),i}};getPrevMatchForTeam=async(e,t)=>{try{t=t||!1;let i=await this.https.getPrevMatchForTeam(e,t);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the previous match for the following team: ${e}`,i),i}}};var yt=class{countryId=null;scope=null;name=null;playerIds=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(e){this.countryId=e.countryId?e.countryId:null,this.scope=e.scope?e.scope:null,this.name=e.name?e.name:null,this.playerIds=e.playerIds?e.playerIds:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.sortField=e.sortField?e.sortField:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFilterUrl=()=>{let e="";return this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),this.name&&(e=e+"&",e=e+`name=${this.name}`),this.playerIds&&(e=e+"&",e=e+`player_ids=${this.playerIds.join(",")}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),e}};var re=class{https=null;footballService=null;idMapping=null;constructor(e,t,i){this.idMapping=i,this.https=t,this.footballService=new ie(e)}getPlayersIdMapping=async(e,t)=>{try{let i=!1;if(e){if(e=new yt(e),e.countryId){let o=await this.idMapping.getEntityIdsBySchemaId([e.countryId],"country","native");o.country.length===0&&(i=!0),e.countryId=o.country[0]}if(e.playerIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.playerIds,"player","native");o.player.length===0&&(i=!0),e.playerIds=o.player}if(e.scope){let o=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");o.competition.length===0&&(i=!0),e.scope=o.competition}if(i)return[]}let r=await this.getPlayers(e,t);return r.data=await this.idMapping.remapEntities(r.data,"player"),r}catch(i){throw console.warn("There was a problem browsing the players",i),i}};getPlayersWithNativeIds=async e=>{let t=e.length,i=new yt({playerIds:e,limit:t}),r=await this.getPlayers(i);return r.data.sort((o,s)=>o.id.localeCompare(s.id)),await this.idMapping.remapEntities(r.data,"player")};getPlayersMapWithNativeIds=async e=>{let t={},i=te(e);i.sort((o,s)=>o.localeCompare(s));let r=await this.getPlayersWithNativeIds(i);return i.forEach((o,s)=>t[o]=r[s]),t};getPlayers=async(e,t)=>{try{return t=t||!1,await this.https.getPlayers(e,t)}catch(i){throw console.warn("There was a problem retrieving the players",i),i}};getPlayerIdMapping=async(e,t)=>{try{let i=await this.idMapping.getEntityIdsBySchemaId([e],"player","native"),r=await this.getPlayerById(i.player[0],t);return await this.idMapping.remapEntities(r,"player")}catch(i){throw console.warn(`There was a problem browsing the following player:${e}`,i),i}};getPlayerById=async(e,t)=>{try{return t=t||!1,await this.https.getPlayerById(e,t)}catch(i){throw console.warn(`There was a problem retrieving the following player: ${e}`,i),i}};getTopPlayersIdMapping=async e=>{try{let t=await this.getTopPlayers(e);return await this.idMapping.remapEntities(t,"player")}catch(t){throw console.warn("There was a problem browsing the top players",t),t}};getTopPlayers=async e=>{try{return e=e||!1,await this.https.getTopPlayers(e)}catch(t){throw console.warn("There was a problem retrieving the top players",t),t}};getNextMatchForPlayerIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let r=await this.getNextMatchForPlayer(e,t);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the next match for player:${e}`,i),i}};getNextMatchForPlayer=async(e,t)=>{try{t=t||!1;let i=await this.https.getNextMatchForPlayer(e,t);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the next match for player: ${e}`,i),i}};getPrevMatchForPlayerIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let r=await this.getPrevMatchForPlayer(e,t);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the previous match for player:${e}`,i),i}};getPrevMatchForPlayer=async(e,t)=>{try{t=t||!1;let i=await this.https.getPrevMatchForPlayer(e,t);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the previous match for player: ${e}`,i),i}}};var Ce=class{countryIds=null;competitionIds=null;matchIds=null;status=null;teamIds=null;fromDate=null;toDate=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(e){this.countryIds=e.countryIds?e.countryIds:null,this.competitionIds=e.competitionIds?e.competitionIds:null,this.matchIds=e.matchIds?e.matchIds:null,this.status=e.status?e.status:null,this.teamIds=e.teamIds?e.teamIds:null,this.fromDate=e.fromDate?e.fromDate:null,this.toDate=e.toDate?e.toDate:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.sortField=e.sortField?e.sortField:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFilterUrl=()=>{let e="";return this.countryIds&&(e=e+"&",e=e+`countries=${this.countryIds.join(",")}`),this.competitionIds&&(e=e+"&",e=e+`competitions=${this.competitionIds.join(",")}`),this.matchIds&&(e=e+"&",e=e+`matches=${this.matchIds.join(",")}`),this.status&&(e=e+"&",e=e+`status=${this.status}`),this.teamIds&&(e=e+"&",e=e+`teams=${this.teamIds.join(",")}`),this.fromDate&&(e=e+"&",e=e+`from_date=${this.fromDate}`),this.toDate&&(e=e+"&",e=e+`to_date=${this.toDate}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),e}};var oe=class{https=null;idMapping=null;footballService=null;constructor(e,t,i){this.https=t,this.idMapping=i,this.footballService=new ie(e)}getMatchesIdMapping=async(e,t)=>{try{if(e){if(e=new Ce(e),e.countryIds){let r=await this.idMapping.getEntityIdsBySchemaId(e.countryIds,"country","native");e.countryIds=r.country}if(e.competitionIds){let r=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");e.competitionIds=r.competition}if(e.matchIds){let r=await this.idMapping.getEntityIdsBySchemaId(e.matchIds,"match","native");e.matchIds=r.match}if(e.teamIds){let r=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");e.teamIds=r.team}}let i=await this.getMatches(e,t);return i.data=await this.footballService.setAvailableMarketsForMatch([...i.data]),i.data=await this.idMapping.remapEntities(i.data,"match"),i}catch(i){throw console.warn("There was a problem browsing the matches",i),i}};getMatchesWithNativeIds=async e=>{let t=e.length,i=new Ce({matchIds:e,limit:t}),r=await this.getMatches(i);return r.data.sort((o,s)=>o.id.localeCompare(s.id)),await this.idMapping.remapEntities(r.data,"match")};getMatchesMapWithNativeIds=async e=>{let t={},i=te(e);i.sort((o,s)=>o.localeCompare(s));let r=await this.getMatchesWithNativeIds(i);if(i.length!==r.length){let o=new Ce({matchIds:i,limit:i.length}),s=await this.getMatches(o),l=i.filter(n=>{if(s.data.every(c=>c.id!==n))return n});i=i.filter(n=>{if(!l.includes(n))return n})}return i.forEach((o,s)=>t[o]=r[s]),t};getMatches=async(e,t)=>{try{return t=t||!1,await this.https.getMatches(e,t)}catch(i){throw console.warn("There was a problem retrieving the matches",i),i}};getMatchIdMapping=async(e,t)=>{try{let i=await this.idMapping.getEntityIdsBySchemaId([e],"match","native"),r=await this.getMatchById(i.match[0],t),o=await this.footballService.setAvailableMarketsForMatch(r);return await this.idMapping.remapEntities(o,"match")}catch(i){throw console.warn(`There was a problem browsing the following match: ${e}`,i),i}};getMatchById=async(e,t)=>{try{return t=t||!1,await this.https.getMatchById(e,t)}catch(i){throw console.warn(`There was a problem retrieving the following match: ${e}`,i),i}}};var pi=class{entities=null;query=null;scope=null;constructor(e){this.entities=e.entities?e.entities:null,this.query=e.query?e.query:null,this.scope=e.scope?e.scope:null}constructFilterUrl=()=>{let e="";return this.entities&&(e=e+"&",e=e+`entities=${this.entities.join(",")}`),this.query&&(e=e+"&",e=e+`q=${this.query}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),e}};var ci=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}searchIdMapping=async(e,t)=>{try{if(e=new pi(e),e.scope){let r=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");e.scope=r.competition}let i=await this.search(e,t);if(i.teams&&i.teams.length>0){let r=await this.idMapping.remapEntities(i.teams,"team");i.teams=r}if(i.players&&i.players.length>0){let r=await this.idMapping.remapEntities(i.players,"player");i.players=r}if(i.competitions&&i.competitions.length>0){let r=await this.idMapping.remapEntities(i.competitions,"competition");i.competitions=r}return i}catch(i){throw console.warn("There was a problem with browsing the search result",i),i}};search=async(e,t)=>{try{return await this.https.search(e,t)}catch(i){throw console.warn("There was a problem retrieving the search response",i),i}}};var Ae=class{countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(e,t,i,r){this.countriesFacade=new zt(t,i,r),this.competitionsFacade=new Jt(t,i,r),this.teamsFacade=new li(e,i,r),this.playerFacade=new re(e,i,r),this.matchFacade=new oe(e,i,r),this.searchFacade=new ci(i,r)}getCountries=async e=>this.countriesFacade.getCountriesWithIdMapping(e);getCompetitions=async(e,t)=>this.competitionsFacade.getCompetitionsIdMapping(e,t);getCompetitionById=async(e,t)=>this.competitionsFacade.getCompetitionByIdIdMapping(e,t);getTopCompetitions=async e=>this.competitionsFacade.getTopCompetitionsIdMapping(e);getCompetitionsMapWithNativeIds=async e=>await this.competitionsFacade.getCompetitionsMapWithNativeIds(e);getTeams=async(e,t)=>this.teamsFacade.getTeamsIdMapping(e,t);getTeamById=async(e,t)=>this.teamsFacade.getTeamByIdIdMapping(e,t);getTopTeams=async e=>this.teamsFacade.getTopTeamsIdMapping(e);getNextMatchForTeam=async(e,t)=>this.teamsFacade.getNextMatchForTeamIdMapping(e,t);getPrevMatchForTeam=async(e,t)=>this.teamsFacade.getPrevMatchForTeamIdMapping(e,t);getTeamsMapWithNativeIds=async e=>await this.teamsFacade.getTeamsMapWithNativeIds(e);getPlayers=async(e,t)=>this.playerFacade.getPlayersIdMapping(e,t);getPlayerById=async(e,t)=>this.playerFacade.getPlayerIdMapping(e,t);getTopPlayers=async e=>this.playerFacade.getTopPlayersIdMapping(e);getNextMatchForPlayer=async(e,t)=>this.playerFacade.getNextMatchForPlayerIdMapping(e,t);getPrevMatchForPlayer=async(e,t)=>this.playerFacade.getPrevMatchForPlayerIdMapping(e,t);getPlayersMapWithNativeIds=async e=>this.playerFacade.getPlayersMapWithNativeIds(e);getMatches=async(e,t)=>this.matchFacade.getMatchesIdMapping(e,t);getMatchById=async(e,t)=>this.matchFacade.getMatchIdMapping(e,t);search=async(e,t)=>this.searchFacade.searchIdMapping(e,t)};var mi=class{id="";alias="";countryCode="";assets=null;name=""};var w=class{countriesFromResponse=e=>{if(e)return e.map(t=>this.countryFromResponse(t))};countryFromResponse=e=>{try{if(e){let t=new mi;return t.id=e.id,t.alias=e.alias,t.assets=e.assets,t.countryCode=e.country_code,t.name=e.name,t}}catch(t){throw t}return null}};var di=class{id="";country=null;gender="";assets=null;type="";name=""};var A=class{countryRemapper=null;constructor(){this.countryRemapper=new w}fromResponse(e){try{let t=new di;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var ui=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var hi=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName="";isDeleted=!1};var R=class{countryRemapper=null;constructor(){this.countryRemapper=new w}fromResponse(e){try{let t=new hi;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t.isDeleted=e.is_deleted,t}catch(t){throw console.warn("There was a problem remapping teams response",t),t}}};var fi=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new w,this.teamBasicRemapper=new R}fromResponse(e){try{let t=new ui;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t.participants=e.participants.map(i=>this.teamBasicRemapper.fromResponse(i)),t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var gi=class{primary=null;secondary=null;tertiary=null};var yi=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";isDeleted=!1;colors=new gi;squad=[]};var Mi=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var bi=class{countryRemapper=null;constructor(){this.countryRemapper=new w}fromResponse(e){try{let t=new Mi;return t.id=e.id,t.startDate=e.start_date,t.endDate=e.end_date,t.shirtNumber=e.shirt_number,t.loan=e.loan,t.position=e.position,t.country=this.countryRemapper.countryFromResponse(e.country),t.name=e.name,t.assets=e.assets,t.birthDate=e.birth_date,t}catch(t){throw console.warn("There was a problem remapping the player from squad",t),t}}};var wi=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new w,this.competitionRemapper=new A,this.playerRemapper=new bi}fromResponse(e){try{let t=new yi;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t.isDeleted=e.is_deleted,t.competitions=e.competitions?e.competitions.map(i=>this.competitionRemapper.fromResponse(i)):[],t.colors=e.colors?e.colors:t.colors,t.squad=e.squad?e.squad.map(i=>this.playerRemapper.fromResponse(i)):[],t}catch(t){throw console.warn("There was a problem remapping team response",t),t}}};var Ii=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;homeTeam=null;awayTeam=null;isDeleted=!1;lineupsConfirmed=!1;startedAt="";minute="";scores=null;context={competition:null};status={type:null,subType:null}};var Fi=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var xe=class{fromResponse(e){try{let t=new Fi;return t.ftScore=this.statEntityFromResponse(e.ft_score),t.htScore=this.statEntityFromResponse(e.ht_score),t.aetScore=this.statEntityFromResponse(e.aet_score),t.aggScore=this.statEntityFromResponse(e.agg_score),t.penScore=this.statEntityFromResponse(e.pen_score),t}catch(t){throw console.warn("There was a problem remapping the scores",t),t}}statEntityFromResponse=e=>({homeGoals:e.home_goals,awayGoals:e.away_goals})};var Pi=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new R,this.competitionRemapper=new A,this.scoresRemapper=new xe}fromResponse(e){try{let t=new Ii;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.isDeleted=e.is_deleted,t.homeTeam=this.teamRemapper.fromResponse(e.home_team),t.awayTeam=this.teamRemapper.fromResponse(e.away_team),t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresRemapper.fromResponse(e.scores),t.context={competition:e.context.competition?this.competitionRemapper.fromResponse(e.context.competition):null},t.status={type:e.status.type,subType:e.status.sub_type},t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var N=class{type=null;subType=null};var Ei=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;isDeleted=!1;homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;stats=null;context={competition:null};timeline=[];status=new N;lineups=null};var Ri=class{corners=null;cornersFirstHalf=null;cornersSecondHalf=null;cornersExtraTime=null;crosses=null;crossesFirstHalf=null;crossesSecondHalf=null;crossesExtraTime=null;offside=null;offsideFirstHalf=null;offsideSecondHalf=null;offsideExtraTime=null;shotsOn=null;shotsOnFirstHalf=null;shotsOnSecondHalf=null;shotsOnExtraTime=null;throwIn=null;throwInFirstHalf=null;throwInSecondHalf=null;throwInExtraTime=null;redCards=null;redCardsFirstHalf=null;redCardsSecondHalf=null;redCardsExtraTime=null;shotsOff=null;shotsOffFirstHalf=null;shotsOffSecondHalf=null;shotsOffExtraTime=null;goalKicks=null;goalKicksFirstHalf=null;goalKicksSecondHalf=null;goalKicksExtraTime=null;possession=null;possessionFirstHalf=null;possessionSecondHalf=null;possessionExtraTime=null;treatments=null;treatmentsFirstHalf=null;treatmentsSecondHalf=null;treatmentsExtraTime=null;yellowCards=null;yellowCardsFirstHalf=null;yellowCardsSecondHalf=null;yellowCardsExtraTime=null;shotsBlocked=null;shotsBlockedFirstHalf=null;shotsBlockedSecondHalf=null;shotsBlockedExtraTime=null;substitutions=null;substitutionsFirstHalf=null;substitutionsSecondHalf=null;substitutionsExtraTime=null;counterAttacks=null;counterAttacksFirstHalf=null;counterAttacksSecondHalf=null;counterAttacksExtraTime=null;foulsCommitted=null;foulsCommittedFirstHalf=null;foulsCommittedSecondHalf=null;foulsCommittedExtraTime=null};var Ti=class{fromResponse(e){try{let t=new Ri;return t.corners=this.statEntityFromResponse(e.corners),t.cornersFirstHalf=this.statEntityFromResponse(e.corners_1h),t.cornersSecondHalf=this.statEntityFromResponse(e.corners_2h),t.cornersExtraTime=this.statEntityFromResponse(e.corners_et),t.crosses=this.statEntityFromResponse(e.crosses),t.crossesFirstHalf=this.statEntityFromResponse(e.crosses_1h),t.crossesSecondHalf=this.statEntityFromResponse(e.crosses_2h),t.crossesExtraTime=this.statEntityFromResponse(e.crosses_et),t.offside=this.statEntityFromResponse(e.offside),t.offsideFirstHalf=this.statEntityFromResponse(e.offside_1h),t.offsideSecondHalf=this.statEntityFromResponse(e.offside_2h),t.offsideExtraTime=this.statEntityFromResponse(e.offside_et),t.shotsOn=this.statEntityFromResponse(e.shots_on),t.shotsOnFirstHalf=this.statEntityFromResponse(e.shots_on_1h),t.shotsOnSecondHalf=this.statEntityFromResponse(e.shots_on_2h),t.shotsOnExtraTime=this.statEntityFromResponse(e.shots_on_et),t.throwIn=this.statEntityFromResponse(e.throw_in),t.throwInFirstHalf=this.statEntityFromResponse(e.throw_in_1h),t.throwInSecondHalf=this.statEntityFromResponse(e.throw_in_2h),t.throwInExtraTime=this.statEntityFromResponse(e.throw_in_et),t.redCards=this.statEntityFromResponse(e.red_cards),t.redCardsFirstHalf=this.statEntityFromResponse(e.red_cards_1h),t.redCardsSecondHalf=this.statEntityFromResponse(e.red_cards_2h),t.redCardsExtraTime=this.statEntityFromResponse(e.red_cards_et),t.shotsOff=this.statEntityFromResponse(e.shots_off),t.shotsOffFirstHalf=this.statEntityFromResponse(e.shots_off_1h),t.shotsOffSecondHalf=this.statEntityFromResponse(e.shots_off_2h),t.shotsOffExtraTime=this.statEntityFromResponse(e.shots_off_et),t.goalKicks=this.statEntityFromResponse(e.goal_kicks),t.goalKicksFirstHalf=this.statEntityFromResponse(e.goal_kicks_1h),t.goalKicksSecondHalf=this.statEntityFromResponse(e.goal_kicks_2h),t.goalKicksExtraTime=this.statEntityFromResponse(e.goal_kicks_et),t.possession=this.statEntityFromResponse(e.possession),t.possessionFirstHalf=this.statEntityFromResponse(e.possession_1h),t.possessionSecondHalf=this.statEntityFromResponse(e.possession_2h),t.possessionExtraTime=this.statEntityFromResponse(e.possession_et),t.treatments=this.statEntityFromResponse(e.treatments),t.treatmentsFirstHalf=this.statEntityFromResponse(e.treatments_1h),t.treatmentsSecondHalf=this.statEntityFromResponse(e.treatments_2h),t.treatmentsExtraTime=this.statEntityFromResponse(e.treatments_et),t.yellowCards=this.statEntityFromResponse(e.yellow_cards),t.yellowCardsFirstHalf=this.statEntityFromResponse(e.yellow_cards_1h),t.yellowCardsSecondHalf=this.statEntityFromResponse(e.yellow_cards_2h),t.yellowCardsExtraTime=this.statEntityFromResponse(e.yellow_cards_et),t.shotsBlocked=this.statEntityFromResponse(e.shots_blocked),t.shotsBlockedFirstHalf=this.statEntityFromResponse(e.shots_blocked_1h),t.shotsBlockedSecondHalf=this.statEntityFromResponse(e.shots_blocked_2h),t.shotsBlockedExtraTime=this.statEntityFromResponse(e.shots_blocked_et),t.substitutions=this.statEntityFromResponse(e.substitutions),t.substitutionsFirstHalf=this.statEntityFromResponse(e.substitutions_1h),t.substitutionsSecondHalf=this.statEntityFromResponse(e.substitutions_2h),t.substitutionsExtraTime=this.statEntityFromResponse(e.substitutions_et),t.counterAttacks=this.statEntityFromResponse(e.counter_attacks),t.counterAttacksFirstHalf=this.statEntityFromResponse(e.counter_attacks_1h),t.counterAttacksSecondHalf=this.statEntityFromResponse(e.counter_attacks_2h),t.counterAttacksExtraTime=this.statEntityFromResponse(e.counter_attacks_et),t.foulsCommitted=this.statEntityFromResponse(e.fouls_committed),t.foulsCommittedFirstHalf=this.statEntityFromResponse(e.fouls_committed_1h),t.foulsCommittedSecondHalf=this.statEntityFromResponse(e.fouls_committed_2h),t.foulsCommittedExtraTime=this.statEntityFromResponse(e.fouls_committed_et),t}catch(t){throw console.warn("There was a problem remapping the stats",t),t}}statEntityFromResponse=e=>({homeTeam:e?e.home_team:null,awayTeam:e?e.away_team:null})};var Oe=class{homeTeam={players:[]};awayTeam={players:[]}};var vi=class{id="";name="";position="";shirtNumber;assets=null;type=""};var De=class{fromResponse(e){try{let t=new vi;return t.id=e.id,t.name=e.name,t.position=e.position,t.shirtNumber=e.shirt_number,t.assets=e.assets,t.type=e.type,t}catch(t){throw console.warn("There was a problem remapping the player from timeline",t),t}}};var Si=class{playerRemapper=null;constructor(){this.playerRemapper=new De}fromResponse(e){try{let t=new Oe;return t.homeTeam.players=e.home_team&&e.home_team.players?e.home_team.players.map(i=>this.playerRemapper.fromResponse(i)):[],t.awayTeam.players=e.away_team&&e.away_team.players?e.away_team.players.map(i=>this.playerRemapper.fromResponse(i)):[],t}catch(t){throw console.warn("There was a problem remapping the lineups",t),t}}};var _i=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var Ci=class{playerRemapper=null;constructor(){this.playerRemapper=new De}fromResponse(e){try{let t=new _i;return t.minute=e.minute,t.type=e.type,t.teamId=e.team_id,t.player=this.playerRemapper.fromResponse(e.player),t.relatedPlayer=e.related_player?this.playerRemapper.fromResponse(e.related_player):null,t.updatedAt=e.updated_at,t}catch(t){throw console.warn("There was a problem remapping timeline",t),t}}};var Ai=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new R,this.competitionsMapper=new A,this.lineupsMapper=new Si,this.scoresMapper=new xe,this.statsMapper=new Ti,this.timelineMapper=new Ci}fromResponse(e){try{let t=new Ei;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.isDeleted=e.is_deleted,t.homeTeam=e.home_team?this.teamMapper.fromResponse(e.home_team):null,t.awayTeam=e.away_team?this.teamMapper.fromResponse(e.away_team):null,t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresMapper.fromResponse(e.scores),t.stats=this.statsMapper.fromResponse(e.stats),t.context={competition:this.competitionsMapper.fromResponse(e.context.competition)},t.timeline=e.timeline?e.timeline.map(i=>this.timelineMapper.fromResponse(i)):[],t.status={type:e.status.type,subType:e.status.sub_type},t.lineups=e.lineups?this.lineupsMapper.fromResponse(e.lineups):new Oe,t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var xi=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var Oi=class{countryRemapper=null;constructor(){this.countryRemapper=new w}fromResponse(e){try{let t=new xi;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping top player response",t),t}}};var Di=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;teams=[]};var Le=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new w,this.teamRemapper=new R}fromResponse(e){try{let t=new Di;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(i=>this.teamRemapper.fromResponse(i)):[],t.position=e.position,t.isDeleted=e.is_deleted,t}catch(t){throw console.warn("There was a problem remapping players response",t),t}}};var Li=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;competitions=[];teams=[]};var Bi=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new w,this.teamRemapper=new R,this.competitionRemapper=new A}fromResponse(e){try{let t=new Li;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(i=>this.teamRemapper.fromResponse(i)):[],t.position=e.position,t.isDeleted=e.is_deleted,t.competitions=e.competitions?e.competitions.map(i=>this.competitionRemapper.fromResponse(i)):[],t}catch(t){throw console.warn("There was a problem remapping player response",t),t}}};var Ni=class{teams=null;players=null;competitions=null};var Ui=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new R,this.playerRemapper=new Le,this.competitionremapper=new A}fromResponse(e){try{let t=new Ni;return t.teams=e.teams?e.teams.map(i=>this.teamRemapper.fromResponse(i)):[],t.players=e.players?e.players.map(i=>this.playerRemapper.fromResponse(i)):[],t.competitions=e.competitions?e.competitions.map(i=>this.competitionremapper.fromResponse(i)):[],t}catch(t){throw console.warn("There was a problem remapping search response",t),t}}};var Be=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var X=class{pagination=new Be};var Ne=class{meta=new X;data=[]};var Hi=class{remapMetaProp=e=>{let t=new X;return t.pagination.currentPage=e.pagination.current_page,t.pagination.itemsPerPage=e.pagination.items_per_page,t.pagination.totalItems=e.pagination.total_items,t.pagination.numberOfPages=e.pagination.number_of_pages,t}};var W=class extends E{limitIds=200;countryRemapper=null;competitionBasicRemapper=null;competitionFullRemapper=null;teamBasicRemapper=null;teamFullRemapper=null;matchBasicRemapper=null;matchFullRemapper=null;playerBasicRemapper=null;playerFullRemapper=null;topPlayerRemapper=null;searchRemapper=null;footballMetaRemapper=null;constructor(e){super(e,S(e.environment,"football"));this.apiSignInUrl=e.lang!=="en"?this.apiSignInUrl+`&lang=${e.lang}`:this.apiSignInUrl,this.countryRemapper=new w,this.competitionBasicRemapper=new A,this.competitionFullRemapper=new fi,this.teamBasicRemapper=new R,this.teamFullRemapper=new wi,this.matchBasicRemapper=new Pi,this.matchFullRemapper=new Ai,this.playerBasicRemapper=new Le,this.playerFullRemapper=new Bi,this.topPlayerRemapper=new Oi,this.searchRemapper=new Ui,this.footballMetaRemapper=new Hi}getCountries=async e=>{try{let t=`/countries${this.apiSignInUrl}`,i=Date.now();e&&(t+=`&disable_cache=${i}`);let r=await this.instance.get(t);return this.countryRemapper.countriesFromResponse(r.data.data)}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem with the football countries request",i),i.response}};getCompetitions=async(e,t)=>{try{let i={},r=Date.now();if(t=t||!1,e&&e.competitionIds&&e.competitionIds.length>this.limitIds-1){let o=[],s=Me(e.competitionIds,this.limitIds);for(let n of s){e.competitionIds=n;let c=`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(c+=`&disable_cache=${r}`),i=await this.instance.get(c),o.push(i.data.data.map(p=>this.competitionBasicRemapper.fromResponse(p)))}return Array.prototype.concat.apply([],o)}else{let o=`/competitions${this.apiSignInUrl}`;return e&&(o+=`${e.constructFilterUrl()}`),t&&(o+=`&disable_cache=${r}`),i=await this.instance.get(o),i.data.data.map(s=>this.competitionBasicRemapper.fromResponse(s))}}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getCompetitions request",r),r.response}};getCompetitionById=async(e,t)=>{try{let i=`/competitions/${e}${this.apiSignInUrl}`,r=Date.now();t&&(i+=`&disable_cache=${r}`);let o=await this.instance.get(i);return this.competitionFullRemapper.fromResponse(o.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getCompetitionById request",r),r.response}};getTopCompetitions=async e=>{try{let t=`/competitions/top${this.apiSignInUrl}`,i=Date.now();return e&&(t+=`&disable_cache=${i}`),(await this.instance.get(t)).data.data.map(o=>this.competitionBasicRemapper.fromResponse(o))}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem with getTopCompetitions request",i),i.response}};getTeams=async(e,t)=>{try{let i={},r=Date.now();if(e&&e.teamIds&&e.teamIds.length>this.limitIds){let o=[],s=Me(e.teamIds,this.limitIds);for(let n of s){e.teamIds=n;let c=`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(c+=`disable_cache=${r}`),i=await this.instance.get(c),o.push(i.data.data.map(p=>this.teamBasicRemapper.fromResponse(p)))}return Array.prototype.concat.apply([],o)}else{let o=new Ne,s=`/teams${this.apiSignInUrl}`;return e&&(s+=`${e.constructFilterUrl()}`),t&&(s+=`&disable_cache=${r}`),i=await this.instance.get(s),o.meta=this.footballMetaRemapper.remapMetaProp(i.data.meta),o.data=i.data.data.map(l=>this.teamBasicRemapper.fromResponse(l)),o}}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getTeams request",r),r.response}};getTeamById=async(e,t)=>{try{let i=`/teams/${e}${this.apiSignInUrl}`,r=Date.now();t&&(i+=`disable_cache=${r}`);let o=await this.instance.get(i);return this.teamFullRemapper.fromResponse(o.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getTeamById request",r),r.response}};getTopTeams=async e=>{try{let t=`/teams/top${this.apiSignInUrl}`,i=Date.now();e&&(t+=`$disable_cache=${i}`);let r=await this.instance.get(t);return r.data.data?r.data.data.map(o=>this.teamBasicRemapper.fromResponse(o)):[]}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem with getTopTeams request",i),i.response}};getNextMatchForTeam=async(e,t)=>{try{let i=`/teams/${e}/next-match${this.apiSignInUrl}`,r=Date.now();t&&(i+=`&disable_cache=${r}`);let o=await this.instance.get(i);return this.matchFullRemapper.fromResponse(o.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getNextMatchForTeam request",r),r.response}};getPrevMatchForTeam=async(e,t)=>{try{let i=`/teams/${e}/previous-match${this.apiSignInUrl}`,r=Date.now();t&&(i+=`disable_cache=${r}`);let o=await this.instance.get(i);return this.matchFullRemapper.fromResponse(o.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getPrevMatchForTeam request",r),r.response}};getPlayers=async(e,t)=>{try{let i={},r=Date.now();if(e&&e.playerIds&&e.playerIds.length>this.limitIds-1){let o=[],s=Me(e.playerIds,this.limitIds);for(let n of s){e.playerIds=n;let c=`/players${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(c+=`&disable_cache=${r}`),i=await this.instance.get(c),o.push(i.data.data.map(p=>this.teamBasicRemapper.fromResponse(p)))}return Array.prototype.concat.apply([],o)}else{let o=new Ne,s=`/players${this.apiSignInUrl}`;return e&&(s+=`${e.constructFilterUrl()}`),t&&(s+=`&disable_cache=${r}`),i=await this.instance.get(s),o.meta=this.footballMetaRemapper.remapMetaProp(i.data.meta),o.data=i.data.data.map(l=>this.playerBasicRemapper.fromResponse(l)),o}}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getPlayers request",r),r.response}};getPlayerById=async(e,t)=>{try{let i=`/players/${e}${this.apiSignInUrl}`,r=Date.now();t&&(i+=`&disable_cache=${r}`);let o=await this.instance.get(i);return this.playerFullRemapper.fromResponse(o.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getPlayerById request",r),r.response}};getTopPlayers=async e=>{try{let t=`/players/top${this.apiSignInUrl}`,i=Date.now();return e&&(t+=`&disable_cache=${i}`),(await this.instance.get(t)).data.data.map(o=>this.topPlayerRemapper.fromResponse(o))}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem with getTopPlayers request",i),i.response}};getNextMatchForPlayer=async(e,t)=>{try{let i=`/players/${e}/next-match${this.apiSignInUrl}`,r=Date.now();t&&(i+=`&disable_cache=${r}`);let o=await this.instance.get(i);return this.matchFullRemapper.fromResponse(o.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getNextMatchForPlayer request",r),r.response}};getPrevMatchForPlayer=async(e,t)=>{try{let i=`/players/${e}/previous-match${this.apiSignInUrl}`,r=Date.now();t&&(i+=`&disable_cache=${r}`);let o=await this.instance.get(i);return this.matchFullRemapper.fromResponse(o.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getPrevMatchForPlayer request",r),r.response}};getMatchById=async(e,t)=>{try{let i=`/matches/${e}${this.apiSignInUrl}`,r=Date.now();t&&(i+=`&disable_cache=${r}`);let o=await this.instance.get(i);return this.matchFullRemapper.fromResponse(o.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getMatchById request",r),r.response}};getMatches=async(e,t)=>{try{let i=new Ne,r=`/matches${this.apiSignInUrl}`,o=Date.now();e&&(r+=`${e.constructFilterUrl()}`),t&&(r+=`&disable_cache=${o}`);let s=await this.instance.get(r);return i.meta=this.footballMetaRemapper.remapMetaProp(s.data.meta),i.data=s.data.data.map(l=>this.matchBasicRemapper.fromResponse(l)),i}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with getMatches request",r),r.response}};search=async(e,t)=>{try{let i=`/search${this.apiSignInUrl}${e.constructFilterUrl()}`,r=Date.now();t&&(i+=`&disable_cache=${r}`);let o=await this.instance.get(i);return this.searchRemapper.fromResponse(o.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with search request",r),r.response}}};var T=(u=>(u.FT_1X2="FT_1X2",u.HT_1X2="HT_1X2",u.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",u.DOUBLE_CHANCE="DOUBLE_CHANCE",u.HT_FT="HT_FT",u.PLAYER_SCORE="PLAYER_SCORE",u.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",u.PLAYER_RED_CARD="PLAYER_RED_CARD",u.RED_CARD_MATCH="RED_CARD_MATCH",u.PENALTY_MATCH="PENALTY_MATCH",u.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",u.CORNERS_MATCH="CORNERS_MATCH",u.CORRECT_SCORE="CORRECT_SCORE",u.CORRECT_SCORE_ADVANCED="CORRECT_SCORE_ADVANCED",u.CORRECT_SCORE_HT="CORRECT_SCORE_HT",u.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",u.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",u.OVER_GOALS_0_5="OVER_GOALS_0_5",u.OVER_GOALS_1_5="OVER_GOALS_1_5",u.OVER_GOALS_2_5="OVER_GOALS_2_5",u.OVER_GOALS_3_5="OVER_GOALS_3_5",u.OVER_GOALS_4_5="OVER_GOALS_4_5",u.OVER_GOALS_5_5="OVER_GOALS_5_5",u.OVER_GOALS_6_5="OVER_GOALS_6_5",u.OVER_CORNERS_6_5="OVER_CORNERS_6_5",u.OVER_CORNERS_7_5="OVER_CORNERS_7_5",u.OVER_CORNERS_8_5="OVER_CORNERS_8_5",u.OVER_CORNERS_9_5="OVER_CORNERS_9_5",u.OVER_CORNERS_10_5="OVER_CORNERS_10_5",u.OVER_CORNERS_11_5="OVER_CORNERS_11_5",u.OVER_CORNERS_12_5="OVER_CORNERS_12_5",u.OVER_CORNERS_13_5="OVER_CORNERS_13_5",u))(T||{}),is=["OVER_GOALS_0_5","OVER_GOALS_1_5","OVER_GOALS_2_5","OVER_GOALS_3_5","OVER_GOALS_4_5","OVER_GOALS_5_5","OVER_GOALS_6_5"],rs=["OVER_CORNERS_6_5","OVER_CORNERS_7_5","OVER_CORNERS_8_5","OVER_CORNERS_9_5","OVER_CORNERS_10_5","OVER_CORNERS_11_5","OVER_CORNERS_12_5","OVER_CORNERS_13_5"],V=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"],os=["FT_1X2","HT_1X2","HT_FT","DOUBLE_CHANCE","CORNERS_MATCH","CORRECT_SCORE","CORRECT_SCORE_HT","CORRECT_SCORE_ADVANCED"],Ue="PLAYER_SCORE_FIRST_GOAL";var ki=class{overallPercent;byFootballCompetition;byFootballTeam;byFootballMarket};var Gi=class{profileId;tier;points;successRates=new ki};var Vi=class{successRatePercent;model=null};var He=class{content=null;tags=[];campaign=null};var ke=class{id=null;profileId=null;property=null;value=null;action=null;context=new He;points=0};var $i=class{meta=new X;data=[new ke]};var qi=class{remapSingleResponse=e=>{let t=new ke;return t.id=e.id,t.profileId=e.profile_id,t.property=e.property,t.value=e.value,t.action=e.action,t.context.content=e.context.content,t.context.tags=e.context.tags,t.context.campaign=e.context.campaign,t.points=e.points,t};remapActivitiesResponse=e=>{let t=new $i;return t.meta.pagination.currentPage=e.meta.pagination.current_page,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.meta.pagination.numberOfPages=e.meta.pagination.number_of_pages,t.meta.pagination.totalItems=e.meta.pagination.total_items,t.data=e.data.map(i=>this.remapSingleResponse(i)),t};remapStatsReponse=e=>{let t=new Gi;return t.profileId=e.profile_id,t.tier=e.tier,t.points=e.points,t.successRates.overallPercent=e.success_rates.overall_percent,t.successRates.byFootballCompetition=this.constructNewRecord(e.success_rates.by_competition),t.successRates.byFootballTeam=this.constructNewRecord(e.success_rates.by_team),t.successRates.byFootballMarket=this.constructNewRecord(e.success_rates.by_market),t};constructNewRecord=e=>{let t;if(Object.entries(e).length)Object.entries(e).forEach(([i,r])=>{t={...t,[i]:this.remapSuccessRatePercent(r)},T[i]&&delete t[i].model});else return e;return t};remapSuccessRatePercent=e=>{let t=new Vi;return t.successRatePercent=e.success_rate_percent,t}};var Ge=class extends E{activityRemapper=null;constructor(e){super(e,S(e.environment,"loyalty"));this.activityRemapper=new qi}createActivity=async e=>{try{let t=`/activities${this.apiSignInUrl}`,i=await this.instanceAuth.post(t,JSON.stringify(e));return this.activityRemapper.remapSingleResponse(i.data)}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem with creating activity for user",i),i.response}};deleteActivity=async e=>{try{let t=`/activities/${e}${this.apiSignInUrl}`;return await this.instanceAuth.delete(t),!0}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn(`There was a problem deleting the following activity: ${e}`,i),i.response}};getOwnActivities=async(e,t)=>{try{let i=`/activities${this.apiSignInUrl}`,r=Date.now();e&&(i+=`${e.constructFilterUrl()}`),t&&(i+=`disable_cache=${r}`);let o=await this.instanceAuth.get(i);return this.activityRemapper.remapActivitiesResponse(o.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem with fetching own activities",r),r.response}};getActivitiesForUser=async(e,t,i)=>{try{let r=`/users/${e}/activities${this.apiSignInUrl}`,o=Date.now();t&&(r+=`${t.constructFilterUrl()}`),i&&(r+=`disable_cache=${o}`);let s=await this.instance.get(r);return this.activityRemapper.remapActivitiesResponse(s.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn(`There was a problem with fetching activities for user ${e}`,o),o.response}};getStats=async(e,t)=>{try{let i="",r=null;return e?(i+=I(t)?`/users/${e}/statistics${this.apiSignInUrl}${F()}`:`/users/${e}/statistics${this.apiSignInUrl}`,r=await this.instance.get(i)):(i+=`/statistics${this.apiSignInUrl}`,r=await this.instanceAuth.get(i)),this.activityRemapper.remapStatsReponse(r.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem fetching profile`s statistics:",r),r.response}}};var ji=class{id="";source="";type="";favourite=!1};var Xi=class extends ji{model=null};var Wi=class{idMapping=null;idSchema=null;native="native";footballFacade=null;constructor(e,t,i){this.idMapping=i,this.idSchema=e.idSchema,this.footballFacade=t}remapSuccessRatesEntities=async e=>{let{successRates:t}=e,i={competition:this.getIdsKeys(t.byFootballCompetition),team:this.getIdsKeys(t.byFootballTeam)};if(Object.values(i.competition).length){let r=e.successRates.byFootballCompetition;e.successRates.byFootballCompetition=await this.setModels(r,i.competition,"competition")}if(Object.values(i.team).length){let r=e.successRates.byFootballTeam;e.successRates.byFootballTeam=await this.setModels(r,i.team,"team")}return e};setModels=async(e,t,i)=>{let r=null,o;switch(i){case"competition":r=await this.footballFacade.getCompetitionsMapWithNativeIds(t);break;case"team":r=await this.footballFacade.getTeamsMapWithNativeIds(t);break}return Object.keys(e).forEach(s=>{let l=r.get(s);o={...o,[l.id]:e[s]},o[l.id].model=l}),o};getIdsKeys=e=>{let t=JSON.parse(JSON.stringify(e));return Object.keys(t)};remapInterestsToIdSchema=async e=>{if(this.idSchema!==this.native)if(e&&e.length>0){let t={},i={},r=e.filter(n=>n.source.toLocaleUpperCase()==="FOOTBALL"),o=e.filter(n=>n.source.toLocaleUpperCase()!=="FOOTBALL");r.forEach(n=>{t.hasOwnProperty(n.type)||(t[n.type]=[],i[n.type]=[]),t[n.type].push(n.id),i[n.type].push(n)});let s=await this.remapIdsObj(t,this.native,this.idSchema),l=[];for(let[n,c]of Object.entries(i))c.forEach((p,m)=>{p.id=s[n][m],l.push(p)});return l.concat(o)}else return e;return e};remapInterestToNative=async e=>{if(this.idSchema!==this.native&&e.source.toLocaleUpperCase()==="FOOTBALL"){let t={},{id:i,type:r}=e;t[r]=[i];let o=await this.remapIdsObj(t,this.idSchema,this.native);return e.id=o[r][0],e}return e};inquiryCustomInterests=(e,t)=>{let i=[];return e&&e.length>0&&(i=e.filter(r=>r.source.toLocaleUpperCase()==="CUSTOM"),t)?i.map(r=>{let o=new Xi;return o.id=r.id,o.type=r.type,o.source=r.source,o.favourite=r.favourite,o}):i};remapInterests=async e=>{let t=!1,i=this.inquiryCustomInterests(e,t);if(i&&i.length>0){let r=e.filter(s=>s.source.toLocaleUpperCase()!=="CUSTOM"),o=await this.remapInterestsToIdSchema(r);return i.forEach(s=>o.push(s)),o}return await this.remapInterestsToIdSchema(e)};showFullInterests=async e=>{let t=[];if(e&&e.length>0){let i=!0,r=this.inquiryCustomInterests(e,i);t.push(r);let o=e.filter(p=>p.source.toLocaleUpperCase()!=="CUSTOM"),{competitionsMap:s,teamsMap:l,playersMap:n}=await this.getInterestsEntitiesMap(o),c=o.map(p=>{let m=null;if(p.source.toLocaleUpperCase()==="FOOTBALL"){if(p.type==="competition")return m=s.get(p.id),m&&(p.id=m.id),p.model=m,p;if(p.type==="team")return m=l.get(p.id),m&&(p.id=m.id),p.model=m,p;if(p.type==="player")return n?(p.model=n[p.id],p.id=n[p.id].id):p.model=m,p}else return p.model=m,p});return t.push(c),t.flat()}return t};getInterestsEntitiesMap=async e=>{let t=[],i=[],r=[],o=new Map,s=new Map,l=null;return e.forEach(n=>{n.type==="competition"&&n.source.toLocaleUpperCase()==="FOOTBALL"?t.push(n.id):n.type==="team"&&n.source.toLocaleUpperCase()==="FOOTBALL"?i.push(n.id):n.type==="player"&&n.source.toLocaleUpperCase()==="FOOTBALL"&&r.push(n.id)}),t.length&&(o=await this.footballFacade.getCompetitionsMapWithNativeIds(t)),i.length&&(s=await this.footballFacade.getTeamsMapWithNativeIds(i)),r.length&&(l=await this.footballFacade.getPlayersMapWithNativeIds(r)),{competitionsMap:o,teamsMap:s,playersMap:l}};remapIdsObj=async(e,t,i)=>await this.idMapping.idMappingFacade.getEntitiesByIds(e,t,i)};var Ki=class{idMapping=null;profileOperations=null;constructor(e,t){this.idMapping=new b(e),this.profileOperations=new Wi(e,t,this.idMapping)}remapSuccessRatesEntities=async e=>await this.profileOperations.remapSuccessRatesEntities(e);remapInterestToNative=async e=>await this.profileOperations.remapInterestToNative(e);remapInterests=async e=>await this.profileOperations.remapInterests(e);showFullInterests=async e=>await this.profileOperations.showFullInterests(e)};var ae=class{idsRemapper=null;profileHttps=null;activityHttps=null;footballHttps=null;footballFacade=null;idMapping=null;localStorage=null;profileFacade=null;ownProfileBuilder=null;profileBuilder=null;constructor(e){this.profileHttps=new Ee(e),this.activityHttps=new Ge(e),this.footballHttps=new W(e),this.idMapping=new b(e),this.localStorage=new L(e),this.footballFacade=new Ae(e,this.localStorage,this.footballHttps,this.idMapping),this.profileFacade=new j(this.localStorage,this.profileHttps,this.activityHttps),this.idsRemapper=new Ki(e,this.footballFacade),this.ownProfileBuilder=new Yt(this.idsRemapper,this.localStorage,this.profileHttps,this.activityHttps,e.errorHandlingMode),this.profileBuilder=new Qt(this.idsRemapper,this.localStorage,this.profileHttps,this.activityHttps)}getOwn=()=>this.ownProfileBuilder;getById=e=>this.profileBuilder.setId(e);getCountries=async e=>await this.profileFacade.getCountries(e);getByIds=async(e,t)=>await this.profileFacade.getByIds(e,t)};var Yi=class{validate=e=>{let t=this.validateField(e.lang),i=this.generateMessage(t);return{validation:t,message:i}};validateField=e=>{let t=["bg","ro","en","el"],i=null;return e!=null&&e.length>0?t.includes(e)?i="valid":i="invalid":i="missing",i};generateMessage=e=>{let t=null,i="warning";return e==="missing"&&(t="If no lang is passed the default one will be set which is: en"),e==="invalid"&&(t="This lang value is not supported, the default one will be set which is: en"),e==="valid"&&(t=null,i=null),{text:t,type:i}}};var Qi=class{validate(e){let t=this.validateField(e.environment),i=this.generateMessage(t);return{validation:t,message:i}}validateField=e=>{let t=["dev","staging","prod"],i=null;return e!=null&&e.length>0?t.includes(e)?i="valid":i="invalid":i="missing",i};generateMessage=e=>{let t=null,i="warning";return e==="missing"&&(t="If no environment is passed the default one will be set which is: prod"),e==="invalid"&&(t="This environment value is not supported, the default one will be set which is: prod"),e==="valid"&&(t=null,i=null),{text:t,type:i}}};var zi=class{validate(e){let t=this.validateField(e.apiKey),i=this.generateMessage(t);return{validation:t,message:i}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,i="error";return e==="missing"&&(t="The field apiKey with valid value must be provided to use Fans United JS SDK"),e==="valid"&&(i=null),{text:t,type:i}}};var Ji=class{validate(e){let t=this.validateField(e.idSchema),i=this.generateMessage(t);return{validation:t,message:i}}validateField=e=>{let t=["native","sportal365","enetpulse","sportradar"],i=null;return e!=null&&e.length>0?t.includes(e)?i="valid":i="invalid":i="missing",i};generateMessage=e=>{let t=null,i="warning";return e==="missing"&&(t="If no idSchema is passed the default one will be set which is: native"),e==="invalid"&&(t="This idSchema value is not supported, the default one will be set which is: native"),e==="valid"&&(t=null,i=null),{text:t,type:i}}};var fe=class{getIdToken=null;logout=null};var $e=class{text=null;type=null};var Zi=class{validation=null;message=new $e;getIdToken={validation:null,message:new $e};logout={validation:null,message:new $e}};var er=class{validate(e){let t=this.validateAuthProvider(e.authProvider);return t.validation!=="missing"&&(t=this.validateAuthProviderConfigFields(e.authProvider,t),t=this.generateAuthProviderConfigMessages(t),t=this.checkAuthProviderConfigMessagesForErrors(t)),t}validateAuthProvider=e=>{let t=Object.keys(new fe),i=new Zi;if(e){let o=Object.keys(e).filter(s=>!t.includes(s));o.length>0?(i.validation="invalid",i.message.type="warning",i.message.text=`${"You have passed a property which is not supported for the authentication provider:"} ${o.join(",")}`):i.validation="valid"}else i.validation="missing",i.message.type="error",i.message.text="The field authProvider must be provided to use this SDK";return i};validateAuthProviderConfigFields=(e,t)=>(Object.keys(new fe).forEach(r=>{e[r]?t[r].validation="valid":t[r].validation="missing"}),t);generateAuthProviderConfigMessages=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{let i=e[t];i.validation==="missing"&&(i.message.text=`${"The following property is missing from the authProvider object:"} ${t}`,i.message.type="error")}),e);checkAuthProviderConfigMessagesForErrors=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{e[t].validation==="missing"&&e.validation==="valid"&&(e.validation="invalid",e.message.type="error",e.message.text="The field authProvider has missing properties")}),e)};var Mt=class{validation;message};var tr=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;errorHandlingMode=null;authProvider={getIdToken:new Mt,logout:new Mt};isValid=!1};var ir=class{validate(e){let t=this.validateField(e.clientId),i=this.generateMessage(t);return{validation:t,message:i}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,i="error";return e==="missing"&&(t="The field clientId must be provided to use Fans United JS SDK"),e==="valid"&&(t=null,i=null),{text:t,type:i}}};var rr=class{validate=e=>{let t=this.validateField(e.errorHandlingMode),i=this.generateMessage(t);return{validation:t,message:i}};validateField=e=>{let t=["default","standard"],i=null;return e?t.includes(e)?i="valid":i="invalid":i="missing",i};generateMessage=e=>{let t=null,i="warning";return e==="missing"&&(t="If no errorHandlingMode is passed the default one will be set which is: default"),e==="invalid"&&(t="This errorHandlingMode value is not supported, the default one will be set which is: default"),e==="valid"&&(t=null,i=null),{text:t,type:i}}};var or=class{validate=e=>{let t=this.checkFieldsForValues(e);return t.isValid=this.containsErrorMessage(t),t};checkFieldsForValues=e=>{let t=new tr,i={apiKey:new zi,environment:new Qi,idSchema:new Ji,clientId:new ir,lang:new Yi,errorHandlingMode:new rr,authProvider:new er};for(let[r,o]of Object.entries(t))r!=="isValid"&&(o=i[r].validate(e));return Object.keys(i).forEach(r=>{t[r]=i[r].validate(e)}),t};containsErrorMessage=e=>{let t=!0;for(let[i,r]of Object.entries(e))if(i!=="authProvider"){if(i!=="isValid"&&r.message.type==="error")return t=!1,t;if(i!=="isValid"&&r.message.type==="warning")return t=!0,t}else if(r.message.type==="error")return t=!1,t;return t}};var qe=class{https=null;idMapping=null;localStorage=null;footballFacade=null;constructor(e){this.https=new W(e),this.idMapping=new b(e),this.localStorage=new L(e),this.footballFacade=new Ae(e,this.localStorage,this.https,this.idMapping)}getCountries=async e=>await this.footballFacade.getCountries(e);getCompetitions=async(e,t)=>await this.footballFacade.getCompetitions(e,t);getCompetitionById=async(e,t)=>await this.footballFacade.getCompetitionById(e,t);getTopCompetitions=async e=>await this.footballFacade.getTopCompetitions(e);getTeams=async(e,t)=>await this.footballFacade.getTeams(e,t);getTeamById=async(e,t)=>await this.footballFacade.getTeamById(e,t);getTopTeams=async e=>await this.footballFacade.getTopTeams(e);getNextMatchForTeam=async(e,t)=>await this.footballFacade.getNextMatchForTeam(e,t);getPrevMatchForTeam=async(e,t)=>await this.footballFacade.getPrevMatchForTeam(e,t);getPlayers=async(e,t)=>await this.footballFacade.getPlayers(e,t);getPlayerById=async(e,t)=>await this.footballFacade.getPlayerById(e,t);getTopPlayers=async e=>await this.footballFacade.getTopPlayers(e);getNextMatchForPlayer=async(e,t)=>await this.footballFacade.getNextMatchForPlayer(e,t);getPrevMatchForPlayer=async(e,t)=>await this.footballFacade.getPrevMatchForPlayer(e,t);getMatches=async(e,t)=>await this.footballFacade.getMatches(e,t);getMatchById=async(e,t)=>await this.footballFacade.getMatchById(e,t);search=async(e,t)=>await this.footballFacade.search(e,t)};var ar=class{value=null;playerId=null;playerModel=null};var je=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new ar;result=null};var sr=class{value=!1;playerId=null};var U=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,i,r){this.matchId=e,this.market=t,this.prediction=new sr,this.prediction.value=i,this.prediction.playerId=r}};var Xe=class{settledAt=null;resettledAt=null;status=null;outcome=null;points=0};var nr=class{value=null};var ne=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,i){this.matchId=e,this.market=t,this.prediction=new nr,this.prediction.value=i}};var H=class{value=!1};var We=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,i){this.matchId=e,this.market=t,this.prediction=new H,this.prediction.value=i}};var Ke=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,i){this.matchId=e,this.market=t,this.prediction=new H,this.prediction.value=i}};var lr=class{matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t,i){this.matchFacade=e,this.playerFacade=t,this.predictorService=i}remapFixturesRequest=e=>{let t={};if(t.match_id=e.matchId,t.match_type="FOOTBALL",e instanceof U)t.market=e.market,t.prediction=e.prediction.value,t.player_id=e.prediction.playerId;else if(e instanceof We||e instanceof Ke)t.market=e.market,t.prediction=e.prediction.value;else if(e instanceof ne){t.market=e.market;let i=e.prediction.value.split(":");t.goals_home=Number(i[0]),t.goals_away=Number(i[1])}else t.market=e.market,t.prediction=e.prediction.value;return t};remapFixturesResponse=async e=>{let t="OWN_GOAL",i=[],r=[],o=null,s=[];e.length>1&&e.sort((n,c)=>n.match_id.localeCompare(c.match_id));for(let n of e)i.push(n.match_id),n.player_id&&!r.includes(n.player_id)&&r.push(n.player_id);let l=await this.matchFacade.getMatchesMapWithNativeIds(i);r.sort((n,c)=>n.localeCompare(c)),r&&r.length>0&&!r.includes(t)&&(o=await this.playerFacade.getPlayersMapWithNativeIds(r));for(let n of e){let c=new je;n.target?c.market=this.predictorService.convertMarketForResponseModel(n.market,n.target):c.market=n.market,c.matchId=l[n.match_id].id,c.matchType=n.match_type,c.matchModel=l?l[n.match_id]:null,delete c.matchModel.availableMarkets,n.goals_home!==void 0&&n.goals_away!==void 0?c.prediction.value=n.goals_home.toString()+":"+n.goals_away.toString():c.prediction.value=n.prediction,c.prediction.playerId=n.player_id?n.player_id:null,c.prediction.playerId&&c.prediction.playerId!==t&&(c.prediction.playerModel=o[n.player_id],c.prediction.playerId=o[n.player_id].id),c.result=this.remapResult(n.result),s.push(c)}return s};remapResult=e=>{let t=new Xe;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t.points=e.points,t}};var K=class{goldenGoal=null};var bt=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new K;points=null;createdAt=null;updatedAt=null};var y=class{no=0;yes=0};var Ye=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new y;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new y;penaltyMatch=new y;playerScoreFirstGoal={};cornersMatch={};correctScore={};correctScoreHalfTime={};correctScoreAdvanced={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new y;overOnePointFiveGoals=new y;overTwoPointFiveGoals=new y;overThreePointFiveGoals=new y;overFourPointFiveGoals=new y;overFivePointFiveGoals=new y;overSixPointFiveGoals=new y;overSixPointFiveCorners=new y;overSevenPointFiveCorners=new y;overEightPointFiveCorners=new y;overNinePointFiveCorners=new y;overTenPointFiveCorners=new y;overElevenPointFiveCorners=new y;overTwelvePointFiveCorners=new y;overThirteenPointFiveCorners=new y};var Y=class{timeTiebreaker=!1};var le=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new Y;predictionId=null;participantsCount=0;related=null;excludedProfileIds=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;scheduleOpenAt=null;images=null;predictionTiebreaker=new K};var ge=class{userId=null;points=null;results=[];tiebreaker=null};var pr=(o=>(o.ACTIVE="ACTIVE",o.WON="WON",o.LOST="LOST",o.PARTIALLY_WON="PARTIALLY_WON",o.CANCELED="CANCELED",o))(pr||{}),Do=["WON","LOST","PARTIALLY_WON","CANCELED"];var v=class{limit=null;startAfter=null;status=null;type=null;matchIds=null;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null,this.status=e.status?e.status:null,this.type=e.type?e.type:null,this.matchIds=e.matchIds?e.matchIds:null}constructFiltersUrl=()=>{let e="",t=!1;return this.status&&(t=Object.values(pr).some(i=>this.status.includes(i))),this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),this.status&&t&&(e+="&",e+=`status=${this.status.join(",")}`),this.type&&(e+="&",e+=`game_types=${this.type}`),this.matchIds&&(e+="&",e+=`match_ids=${this.matchIds.join(",")}`),e}};var Qe=class{limit;startAfter;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null}constructMainFiltersUrl(){let e="";return this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),e}};var wt=(s=>(s.OPEN="OPEN",s.LIVE="LIVE",s.PENDING="PENDING",s.CANCELED="CANCELED",s.CLOSED="CLOSED",s.SETTLED="SETTLED",s))(wt||{});var k=class extends Qe{status=null;type=null;gameIds=null;sortOrder=null;constructor(e){super(e);this.status=e.status?e.status:null,this.type=e.type?e.type:null,this.gameIds=e.gameIds?e.gameIds:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFiltersUrl=()=>{let e=super.constructMainFiltersUrl();return this.status&&Object.values(wt).includes(this.status)&&(e+="&",e+=`status=${this.status}`),this.type&&(e+="&",e+=`type=${this.type}`),this.gameIds&&this.gameIds.length>0&&(e+="&",e+=`game_ids=${this.gameIds.join(",")}`),this.sortOrder&&(e+="&",e+=`sort_order=${this.sortOrder}`),e}};var ze=class{main=null;cover=null;mobile=null};var Z=class{id=null;title=null;description=null;type=null;status=null;scheduleOpenAt=null;predictionsCutoff=null;fixtures=[];tiebreaker=new Y;participantsCount=0;related=null;excludedProfileIds=null;rules=null;flags=null;images=new ze;createdAt=null;updatedAt=null};var ee=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new Y;predictionId=null;participantsCount=0;related=null;excludedProfileIds=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;images=null;scheduleOpenAt=null};var Je=class extends Z{adContent=null;labels=null;customFields=null};var Q=class{footballHttps=null;idMapping=null;matchFacade=null;playerFacade=null;profileNamespace=null;constructor(e,t){this.footballHttps=new W(e),this.idMapping=t,this.matchFacade=new oe(e,this.footballHttps,t),this.playerFacade=new re(e,this.footballHttps,t),this.profileNamespace=new ae(e)}remapMatchIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"match","native")).match;remapPlayerIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"player","native")).player[0];remapPlayerIdMapToNative=async e=>{let t={},i=te(e),o=(await this.idMapping.getEntityIdsBySchemaId(i,"player","native")).player;return i.forEach((s,l)=>t[s]=o[l]),t};remapPlayerIdToIdSchema=async e=>{let t=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"],i=[];for(let[o,s]of Object.entries(e))if(t.includes(o))for(let l of Object.keys(s))l!=="NOBODY"&&l!=="OWN_GOAL"&&i.push(l);if(!i.length)return e;let r=await this.playerFacade.getPlayersMapWithNativeIds(i);for(let[o,s]of Object.entries(e))if(t.includes(o))for(let l of Object.keys(s))l!=="NOBODY"&&l!=="OWN_GOAL"&&(s[r[l].id]=s[l],s[r[l].id].model=r[l],this.idMapping.idSchema!=="native"&&delete s[l]);return e};convertMarket=e=>{let t=Object.keys(new Ye),i=Object.values(T);for(let r=0;r<i.length;r++)e===i[r]&&(e=t[r]);return e};convertMarketForResponseModel=(e,t)=>{let i=t.toString();return e+"_"+i};getMarketSummary=async(e,t,i)=>{let r=this.convertMarket(t),o={};if(o.matchId=e.matchId,o.matchType=e.matchType,Object.keys(e.predictions).includes(r))o[r]=e.predictions[r];else throw new Error("You have passed invalid market");if(V.includes(t)&&i){let l="";if(i!=="OWN_GOAL"&&i!=="NOBODY"&&(l=(await this.idMapping.idMappingFacade.getEntitiesByIds({player:[i]},this.idMapping.idSchema,"native")).player[0]),l&&o[r][l]){let n=await this.playerFacade.getPlayersMapWithNativeIds([l]);return o[r][l].model=n[l],o[r][l]}else return l?(o[r][l]=new y,o[r][l]):o[r][i]}else if(V.includes(t)&&!i){let l=Object.keys(o[r]).filter(c=>c!=="NOBODY"&&c!=="OWN_GOAL"),n=l.length?await this.playerFacade.getPlayersMapWithNativeIds(l):{};Object.keys(n).length&&Object.keys(o[r]).forEach(c=>{c!=="NOBODY"&&c!=="OWN_GOAL"&&(o[r][n[c].id]=o[r][c],o[r][n[c].id].model=n[c],this.idMapping.idSchema!=="native"&&delete o[r][c])})}return o};remapCompetitionsFromConfig=async e=>{if(e instanceof _e){let t={competition:e.fullCoverageCompetitions},i={competition:e.successRateScopes.competitions},r={team:e.successRateScopes.teams},o=await this.idMapping.idMappingFacade.getEntitiesByIds(t,"native",this.idMapping.idSchema),s=await this.idMapping.idMappingFacade.getEntitiesByIds(i,"native",this.idMapping.idSchema),l=await this.idMapping.idMappingFacade.getEntitiesByIds(r,"native",this.idMapping.idSchema);return e.fullCoverageCompetitions=o.competition,e.successRateScopes.competitions=s.competition,e.successRateScopes.teams=l.team,e}if(e instanceof Se||e instanceof ve){let t={competition:e.competitionsWhitelist},i=await this.idMapping.idMappingFacade.getEntitiesByIds(t,"native",this.idMapping.idSchema);return e.competitionsWhitelist=i.competition,e}};remapMatchIdsFixtures=async e=>{if(Array.isArray(e.data))if(e.data.length>0){let t=[],i=[];return e.data.forEach(r=>{r instanceof Z||r instanceof le||r instanceof ee||r instanceof Je?(r.fixtures.forEach(o=>t.push(o.matchId)),r instanceof ee&&r.fixtures.forEach(o=>{o.prediction.playerId&&o.prediction.playerId!=="OWN_GOAL"&&i.push(o.prediction.playerId)})):r instanceof ge&&r.results.forEach(o=>t.push(o.matchId))}),await this.refactorResponseArrModel(e,t,i)}else return e;else return await this.refactorResponseObjModel(e)};refactorResponseArrModel=async(e,t,i)=>{let r=[],o=await this.matchFacade.getMatchesMapWithNativeIds(t),s={};return i.length>0&&(s=await this.playerFacade.getPlayersMapWithNativeIds(i)),e.data.forEach(l=>{l instanceof Z||l instanceof le||l instanceof ee?(l.fixtures.forEach(n=>{this.handleMatchModel(o,n),l instanceof ee&&n.prediction.playerId&&n.prediction.playerId!=="OWN_GOAL"&&(n.prediction.playerModel=s[n.prediction.playerId],n.prediction.playerId=s[n.prediction.playerId].id)}),r.push(l)):l instanceof ge&&(l.results.forEach(n=>{n.matchModel=o[n.matchId],delete n.matchModel.availableMarkets,n.matchId=n.matchModel.id}),r.push(l))}),e.data=r,e};refactorResponseObjModel=async e=>{let t=[];e.fixtures.forEach(r=>t.push(r.matchId));let i=await this.matchFacade.getMatchesMapWithNativeIds(t);return e.fixtures.forEach(r=>this.handleMatchModel(i,r)),e};getCurrentGameId=e=>{let t=new Date;if(e.data.length>1){let i=[];return e.data.forEach(o=>i.push(o.predictionsCutoff)),e.data.sort((o,s)=>{let[l,n]=[o.predictionsCutoff,s.predictionsCutoff].map(c=>Math.abs(new Date(c)-t));return l-n})[0].id}else return e.data[0].id};initGameTypePredictions=(e,t)=>{let i={type:e,limit:null,startAfter:null};return t&&(i={...i,limit:t.limit,startAfter:t.startAfter}),i=new v(i),i};initGameFilters=(e,t,i)=>{if(t&&i)return t.type=e,t.gameIds=i,t=new k(t),t;if(t&&!i)return t.type=e,t=new k(t),t;if(!t&&i){let r={type:e,gameIds:i};return r=new k(r),r}else{let r={type:e};return r=new k(r),r}};addPredictionProp=async(e,t)=>(t.data.forEach(i=>{e.data.forEach(r=>{i.id===r.game_instance_id&&(i.predictionId=r.id,i.outcome=r.status,i.fixtures.forEach((o,s)=>{r.fixtures[s].goals_home!==void 0&&r.fixtures[s].goals_away!==void 0?o.prediction.value=r.fixtures[s].goals_home+":"+r.fixtures[s].goals_away:o.prediction.value=r.fixtures[s].prediction,r.fixtures[s].player_id?o.prediction.playerId=r.fixtures[s].player_id:r.fixtures[s].target&&(o.prediction.target=r.fixtures[s].target),o.prediction.result=this.remapResult(r.fixtures[s].result)}),i.predictionsMadeAt=r.created_at,i.points=r.points,i instanceof le&&(r.tiebreaker?i.predictionTiebreaker.goldenGoal=r.tiebreaker.golden_goal:i.predictionTiebreaker=r.tiebreaker))})}),t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,await this.remapMatchIdsFixtures(t));remapResult=e=>{let t=new Xe;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t.points=e.points,t};areIdsExceeded=e=>{let t=10;return e.length>t};initPredictionsFilters=(e,t,i)=>{switch(t){case"user":e&&(e=new v(e));break;case"current":if(e)this.deleteUnexpectedProperties(e),e.status=["ACTIVE"],e=new v(e);else{let r={status:["ACTIVE"]};e=new v(r)}break;case"past":if(e)this.deleteUnexpectedProperties(e),e.status=Do,e=new v(e);else{let r={status:Do};e=new v(r)}break;case"matches":if(e)this.deleteUnexpectedProperties(e),e.matchIds=i,e=new v(e);else{let r={matchIds:i};e=new v(r)}break}return e};completeGameMarketResults=async(e,t)=>{switch(t){case"MATCH_QUIZ":let i={},r=e.results[0].matchId,o=e.results.map(c=>V.includes(c.market)&&!c.result.includes("OWN_GOAL")?[...c.result]:[]).flat(),s=await this.matchFacade.getMatchesMapWithNativeIds([r]);return o.length&&(i=await this.playerFacade.getPlayersMapWithNativeIds(o)),e.results=e.results.map(c=>{if(c.matchModel=s[c.matchId]?s[c.matchId]:null,c.playerModels&&Object.keys(i).length&&c.result.forEach(m=>{let d=i[m];c.playerModels.push(d)}),this.idMapping.idSchema!=="native"&&(this.remapMatchIdForResultsMarkets(s,c),c.playerModels&&Object.keys(i).length)){let p=c.result;c.result=p.map(m=>i[m].id)}return c}),e;case"TOP_X":let l=e.results.map(c=>c.matchId),n=await this.matchFacade.getMatchesMapWithNativeIds(l);if(e.results=e.results.map(c=>(c.matchModel=n[c.matchId]?n[c.matchId]:null,this.idMapping.idSchema!=="native"&&this.remapMatchIdForResultsMarkets(n,c),c)),e.tieBreakers.goldenGoals.length){let c=e.tieBreakers.goldenGoals.map(m=>m.playerId),p=await this.playerFacade.getPlayersMapWithNativeIds(c);e.tieBreakers.goldenGoals=e.tieBreakers.goldenGoals.map(m=>(m.matchModel=n[m.matchId],m.playerModel=p[m.playerId],this.idMapping.idSchema!=="native"&&(m.matchId=n[m.matchId].id,m.playerId=p[m.playerId].id),m))}return e}};completeContestWinners=async e=>{let t=e.userList.map(r=>r.profileId),i=await this.profileNamespace.getByIds(t);return e.userList.forEach(r=>{let o=i.filter(s=>s.id===r.profileId)[0];delete o.interests,r.profileModel=o}),e};handleMatchModel=(e,t)=>{e[t.matchId]?(t.matchModel=e[t.matchId],delete t.matchModel.availableMarkets,t.matchId=t.matchModel.id):(t.matchModel=null,this.idMapping.idSchema!=="native"&&this.idMapping.idMappingFacade.getEntityById(t.matchId,"match","native").then(i=>{t.matchId=i[D[this.idMapping.idSchema]]}))};remapMatchIdForResultsMarkets=(e,t)=>{e[t.matchId]?t.matchId=e[t.matchId].id:this.idMapping.idMappingFacade.getEntityById(t.matchId,"match","native").then(i=>{t.matchId=i[D[this.idMapping.idSchema]]})};deleteUnexpectedProperties=e=>(e.status&&(console.warn(Ao.UNEXPECTED_STATUS_PROP),delete e.status),e.type&&(console.warn(Ao.UNEXPECTED_TYPE_PROP),delete e.type),e)};var Ze=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(e){this.gameInstanceId=e.gameInstanceId,e.fixtures.forEach(t=>this.fixtures.push(new ne(t.matchId,t.market,t.prediction.value))),this.tiebreaker=e.tiebreaker?e.tiebreaker:null}};var et=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t){this.footballHttps=new W(e),this.matchFacade=new oe(e,this.footballHttps,t),this.playerFacade=new re(e,this.footballHttps,t),this.predictorService=new Q(e,t),this.fixturesRemapper=new lr(this.matchFacade,this.playerFacade,this.predictorService)}remapRequestBody=e=>{let t={};return t.game_instance_id=e.gameInstanceId,t.fixtures=e.fixtures.map(i=>this.fixturesRemapper.remapFixturesRequest(i)),e instanceof Ze&&e.tiebreaker&&(t.tiebreaker={},t.tiebreaker.golden_goal=e.tiebreaker.goldenGoal?e.tiebreaker.goldenGoal:null),t};remapResponseArrayBody=async e=>{if(e.length){let t="OWN_GOAL",i=[],r=[],o={},s=[];e.forEach(n=>{n.fixtures.forEach(c=>{i.push(c.match_id),c.player_id&&c.player_id!==t&&r.push(c.player_id)})});let l=await this.matchFacade.getMatchesMapWithNativeIds(i);return r.length>0&&(o=await this.playerFacade.getPlayersMapWithNativeIds(r)),e.forEach(n=>{let c=new bt,p=[];c.id=n.id,c.gameInstanceId=n.game_instance_id,c.gameType=n.game_type,c.wager=n.wager,c.totalFixtures=n.total_fixtures,c.settledFixtures=n.settled_fixtures,c.userId=n.user_id,n.fixtures.forEach(m=>{let d=new je;m.target?d.market=this.predictorService.convertMarketForResponseModel(m.market,m.target):d.market=m.market,d.matchId=l[m.match_id].id,d.matchType=m.match_type,d.matchModel=l[m.match_id],delete d.matchModel.availableMarkets,m.goals_home!==void 0&&m.goals_away!==void 0?d.prediction.value=m.goals_home.toString()+":"+m.goals_away.toString():d.prediction.value=m.prediction,d.prediction.playerId=m.player_id?m.player_id:null,d.prediction.playerId&&d.prediction.playerId!==t&&(d.prediction.playerModel=o[d.prediction.playerId],d.prediction.playerId=o[d.prediction.playerId].id),d.result=this.fixturesRemapper.remapResult(m.result),p.push(d)}),c.fixtures=p,c.status=n.status,n.tiebreaker?c.tiebreaker.goldenGoal=n.tiebreaker.golden_goal:c.tiebreaker=null,c.points=n.points,c.createdAt=n.created_at,c.updatedAt=n.updated_at,s.push(c)}),s}return e};remapResponseObjBody=async e=>{let t=new bt;return t.id=e.id,t.gameInstanceId=e.game_instance_id,t.gameType=e.game_type,t.wager=e.wager,t.totalFixtures=e.total_fixtures,t.settledFixtures=e.settled_fixtures,t.userId=e.user_id,t.fixtures=await this.fixturesRemapper.remapFixturesResponse(e.fixtures),t.status=e.status,e.tiebreaker?t.tiebreaker.goldenGoal=e.tiebreaker.golden_goal:t.tiebreaker=null,t.points=e.points,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapPredictionModel=e=>{let t=new Ye;return t.fullTimeOneXTwo=e.FT_1X2,t.halfTimeOneXTwo=e.HT_1X2,t.bothTeamsScore=e.BOTH_TEAMS_SCORE,t.overZeroPointFiveGoals=e.OVER_GOALS_0_5,t.overOnePointFiveGoals=e.OVER_GOALS_1_5,t.overTwoPointFiveGoals=e.OVER_GOALS_2_5,t.overThreePointFiveGoals=e.OVER_GOALS_3_5,t.overFourPointFiveGoals=e.OVER_GOALS_4_5,t.overFivePointFiveGoals=e.OVER_GOALS_5_5,t.overSixPointFiveGoals=e.OVER_GOALS_6_5,t.overSixPointFiveCorners=e.OVER_CORNERS_6_5,t.overSevenPointFiveCorners=e.OVER_CORNERS_7_5,t.overEightPointFiveCorners=e.OVER_CORNERS_8_5,t.overNinePointFiveCorners=e.OVER_CORNERS_9_5,t.overTenPointFiveCorners=e.OVER_CORNERS_10_5,t.overElevenPointFiveCorners=e.OVER_CORNERS_11_5,t.overTwelvePointFiveCorners=e.OVER_CORNERS_12_5,t.overThirteenPointFiveCorners=e.OVER_CORNERS_13_5,t.doubleChance=e.DOUBLE_CHANCE,t.halfTimeFullTime=e.HT_FT,t.playerScore=e.PLAYER_SCORE,t.playerYellowCard=e.PLAYER_YELLOW_CARD,t.playerRedCard=e.PLAYER_RED_CARD,t.redCardMatch=e.RED_CARD_MATCH,t.penaltyMatch=e.PENALTY_MATCH,t.playerScoreFirstGoal=e.PLAYER_SCORE_FIRST_GOAL,t.cornersMatch=e.CORNERS_MATCH,t.correctScore=e.CORRECT_SCORE,t.correctScoreHalfTime=e.CORRECT_SCORE_HT,t.correctScoreAdvanced=e.CORRECT_SCORE_ADVANCED,t.playerScoreHattrick=e.PLAYER_SCORE_HATTRICK,t.playerScoreTwice=e.PLAYER_SCORE_TWICE,t}};var cr=class{matchId=null;matchType=null;predictions=null};var mr=class{remapPredictions=null;constructor(e,t){this.remapPredictions=new et(e,t)}remapResponse=e=>{let t=new cr;return t.matchId=e.match_id,t.matchType=e.match_type,t.predictions=this.remapPredictions.remapPredictionModel(e.predictions),t}};var dr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new N};var ur=class{value=null;target=null;playerId=null;playerModel=null;result=null};var hr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new N;prediction=new ur};var fr=class{value=null;result=null};var gr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new N;prediction=new fr};var yr=class{matchId=null;matchModel=null;outcome=null};var Mr=class{gameId=null;results=null;tieBreakers=null};var tt=class{entityId=null;entityType=null};var br=class{contestId="";contestType="GAME";contestModel=null;description="";userList=[]};var wr=class{position="";profileId="";profileModel=null;note="";tags=[]};var Ir=class{remapPaginatedGames=e=>{let t=new M;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(i=>this.remapGamesListResponse(i)),t};remapGamesListResponse=e=>{let t=new Z;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.scheduleOpenAt=e.schedule_open_at,t.predictionsCutoff=e.predictions_cutoff,t.fixtures=e.fixtures.map(i=>this.remapFixturesResponse(i)),t.tiebreaker=e.tiebreaker?this.remapTimeTiebreaker(e.tiebreaker.time_tiebreaker):null,t.participantsCount=e.participants_count,t.related=e.related?this.remapRelated(e.related):null,t.excludedProfileIds=e.excluded_profile_ids,t.rules=e.rules,t.flags=e.flags,t.images=e.images,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapGameByIdResponse=e=>{let t=new Je;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.scheduleOpenAt=e.schedule_open_at,t.predictionsCutoff=e.predictions_cutoff,t.fixtures=e.fixtures.map(i=>this.remapFixturesResponse(i)),t.tiebreaker=e.tiebreaker?this.remapTimeTiebreaker(e.tiebreaker.time_tiebreaker):null,t.participantsCount=e.participants_count,t.related=e.related?this.remapRelated(e.related):null,t.excludedProfileIds=e.excluded_profile_ids,t.rules=e.rules,t.flags=e.flags,t.adContent=e.ad_content,t.labels=e.labels,t.customFields=e.custom_fields,t.images=e.images,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapFixturesResponse=e=>{let t=new dr;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t.matchStatus.type=e.match_status.type,t.matchStatus.subType=e.match_status.sub_type,t};remapPaginatedUserTopXEditions=e=>{let t=new M;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(i=>this.remapUserTopXEditionsResponse(i)),t};remapUserTopXEditionsResponse=e=>{let t=new le;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.scheduleOpenAt=e.schedule_open_at,t.fixtures=e.fixtures.map(i=>this.remapTopXFixturesResponse(i)),t.tiebreaker=e.tiebreaker?this.remapTimeTiebreaker(e.tiebreaker.time_tiebreaker):null,t.participantsCount=e.participants_count,t.related=e.related?this.remapRelated(e.related):null,t.excludedProfileIds=e.excluded_profile_ids,t.rules=e.rules,t.flags=e.flags,t.images=e.images,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapTopXFixturesResponse=e=>{let t=new gr;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t.matchStatus.type=e.match_status.type,t.matchStatus.subType=e.match_status.sub_type,t};remapPaginatedUserMathQuizEditions=e=>{let t=new M;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(i=>this.remapUserMatchQuizEditionsResponse(i)),t};remapUserMatchQuizEditionsResponse=e=>{let t=new ee;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.scheduleOpenAt=e.schedule_open_at,t.fixtures=e.fixtures.map(i=>this.remapMatchQuizFixturesResponse(i)),t.tiebreaker=e.tiebreaker?this.remapTimeTiebreaker(e.tiebreaker.time_tiebreaker):null,t.participantsCount=e.participants_count,t.related=e.related?this.remapRelated(e.related):null,t.excludedProfileIds=e.excluded_profile_ids,t.rules=e.rules,t.flags=e.flags,t.images=e.images,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapMatchQuizFixturesResponse=e=>{let t=new hr;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t.matchStatus.type=e.match_status.type,t.matchStatus.subType=e.match_status.sub_type,t};remapPaginatedGameResults=e=>{let t=new M;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(i=>this.remapGameResults(i)),t};remapGameResults=e=>{let t=new ge;return t.userId=e.user_id,t.points=e.points?e.points:0,t.results=e.results.map(i=>this.remapResults(i)),t.tiebreaker=e.tiebreaker?this.remapTiebreaker(e.tiebreaker):null,t};remapGameMarketsResults=e=>{let t=new Mr;return t.gameId=e.game_id,t.results=this.remapMarketsResults(e.results),t.tieBreakers=e.tie_breakers?this.remapTieBreakers(e.tie_breakers):null,t};remapContestWinners=e=>{let t=new br;return t.contestId=e.contest_id,t.contestType=e.contest_type,t.description=e.description,t.userList=e.user_list.map(i=>this.remapUserListWinners(i)),t};remapUserListWinners=e=>{let t=new wr;return t.position=e.position,t.profileId=e.profile_id,t.note=e.note,t.tags=e.tags,t};remapTieBreakers=e=>{let t={goldenGoals:[]};return t.goldenGoals=e.golden_goals.map(i=>({minute:i.minute,matchId:i.match_id,matchModel:null,playerId:i.player_id,playerModel:null,goalType:i.goal_type})),t};remapMarketsResults=e=>{let t=[];return e.forEach(i=>{let r={matchId:i.match_id,market:i.market,result:this.remapMarketResult(i.market,i.result),matchModel:null,playerModels:[],matchStatus:this.remapMarketsResultsMatchStatus(i.match_status)};t.push(this.deleteUnusefulField(r))}),t};remapMarketsResultsMatchStatus=e=>{let t=new N;return t.type=e.type,t.subType=e.sub_type,t};remapMarketResult=(e,t)=>{if(os.includes(e))return t[0];if(V.includes(e))return t;if(t[0]==="true")return!0;if(t[0]==="false")return!1};deleteUnusefulField=e=>((!V.includes(e.market)||this.isPlayerMarketWithNoResult(e.market,e.result))&&delete e.playerModels,e);isPlayerMarketWithNoResult=(e,t)=>V.includes(e)&&t.length===0;remapResults=e=>{let t=new yr;return t.matchId=e.match_id,t.outcome=e.outcome,t};remapTiebreaker=e=>{let t=new K;return t.goldenGoal=e.golden_goal,t};remapTimeTiebreaker=e=>{let t=new Y;return t.timeTiebreaker=e,t};remapRelated=e=>e.map(t=>{let i=new tt;return i.entityId=t.entity_id,i.entityType=t.entity_type,i})};var Fr=class{remapMetaData=e=>{let t=new be;return t.pagination.nextPageStartsAfter=e.pagination.next_page_starts_after,t.pagination.itemsPerPage=e.pagination.items_per_page,t}};var z=class extends E{predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;metaRemapper=null;constructor(e,t){super(e,S(e.environment,"predictor"));this.predictionRemapper=new et(e,t),this.matchSummaryRemapper=new mr(e,t),this.gamesRemapper=new Ir,this.metaRemapper=new Fr}makeFootballPrediction=async e=>{try{let t=this.predictionRemapper.remapRequestBody(e),i=await this.instanceAuth.post(`/predictions${this.apiSignInUrl}`,JSON.stringify(t));return await this.predictionRemapper.remapResponseObjBody(i.data)}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem making POST request: ",i),i.response}};getMatchSummary=async(e,t)=>{let i=I(t)?`/predictions/summary/${e}${this.apiSignInUrl}${F()}`:`/predictions/summary/${e}${this.apiSignInUrl}`;try{let r=await this.instance.get(i);return this.matchSummaryRemapper.remapResponse(r.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn(`There was a problem fetching predictions for match: ${e} `,o),o.response}};deleteFootballPrediction=async e=>{try{return await this.instanceAuth.delete(`/predictions/${e}${this.apiSignInUrl}`),!0}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn(`There was a problem deleting your prediction: ${e}`,i),i.response}};getMyPredictions=async e=>{try{let t=new M,i=`/predictions${this.apiSignInUrl}`;e&&(i+=`${e.constructFiltersUrl()}`);let r=await this.instanceAuth.get(i);return t.meta=this.metaRemapper.remapMetaData(r.data.meta),t.data=await this.predictionRemapper.remapResponseArrayBody(r.data.data),t}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem fetching own predictions",i),i.response}};getMyPredictionsNoRemap=async e=>{try{return(await this.instanceAuth.get(`/predictions${this.apiSignInUrl}${e.constructFiltersUrl()}`)).data}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn("There was a problem fetching own predictions",i),i.response}};getUserPredictions=async(e,t,i)=>{try{let r=new M,o=I(t)?`/predictions/users/${e}${this.apiSignInUrl}${F()}`:`/predictions/users/${e}${this.apiSignInUrl}`;i&&(o+=`${i.constructFiltersUrl()}`);let s=await this.instance.get(o);return r.meta=this.metaRemapper.remapMetaData(s.data.meta),r.data=await this.predictionRemapper.remapResponseArrayBody(s.data.data),r}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn(`There was a problem fetching predictions for user: ${e}`,o),o.response}};getUserPredictionsNoRemap=async(e,t)=>{try{return(await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}${t.constructFiltersUrl()}`)).data}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn(`There was a problem fetching predictions for user: ${e}`,r),r.response}};getGames=async(e,t)=>{try{let i=I(t)?`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}${F()}`:`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,r=await this.instance.get(i);return this.gamesRemapper.remapPaginatedGames(r.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem fetching the games list",r),r.response}};getGameById=async(e,t)=>{try{let i=I(t)?`/games/${e}${this.apiSignInUrl}${F()}`:`/games/${e}${this.apiSignInUrl}`,r=await this.instance.get(i);return this.gamesRemapper.remapGameByIdResponse(r.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn(`There was a problem fetching the following game: ${e}`,r),r.response}};getGamePredictions=async(e,t,i)=>{try{let r=new M,o=I(t)?`/games/${e}/predictions${this.apiSignInUrl}${F()}`:`/games/${e}/predictions${this.apiSignInUrl}`;i&&(o+=`${i.constructFiltersUrl()}`);let s=await this.instance.get(o);return r.meta=this.metaRemapper.remapMetaData(s.data.meta),r.data=await this.predictionRemapper.remapResponseArrayBody(s.data.data),r}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn(`There was a problem fetching the predictions for game: ${e}`,o),o.response}};getUserGameEditions=async(e,t)=>{try{let i=null,r=I(t)?`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}${F()}`:`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,o=await this.instance.get(r);return o.data.data.forEach(s=>{s.type==="TOP_X"?i=this.gamesRemapper.remapPaginatedUserTopXEditions(o.data):s.type==="MATCH_QUIZ"&&(i=this.gamesRemapper.remapPaginatedUserMathQuizEditions(o.data))}),i}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem fetching the games list",r),r.response}};getGameResults=async(e,t,i)=>{try{let r=I(t)?`/games/${e}/results/${this.apiSignInUrl}${F()}`:`/games/${e}/results/${this.apiSignInUrl}`;i&&(r+=`${i.constructMainFiltersUrl()}`);let o=await this.instance.get(r);return this.gamesRemapper.remapPaginatedGameResults(o.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn(`There was a problem fetching the results for the following game: ${e}`,o),o.response}};getMarketResultsForGame=async(e,t)=>{let i=`/games/${e}/correct-results/${this.apiSignInUrl}`;I(t)&&(i+=`${F()}`);try{let r=await this.instance.get(i);return this.gamesRemapper.remapGameMarketsResults(r.data.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn(`There was a problem fetching the markets correct results for the following game: ${e}`,o),o.response}};getContestWinners=async e=>{try{let t=await this.instance.get(`/winners/${this.apiSignInUrl}&contest_id=${e}`);return this.gamesRemapper.remapContestWinners(t.data)}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn(`There was a problem fetching winners for the following game: ${e}`,i),i.response}};getPredictionById=async e=>{try{let t=`/predictions/${e}${this.apiSignInUrl}`,i=await this.instanceAuth.get(t);return(await this.predictionRemapper.remapResponseArrayBody([i.data.data]))[0]}catch(t){let i=this.transformAxiosErrorToFansUnitedException(t);throw console.warn(`There was a problem fetching info for the following prediction: ${e}`,i),i.response}}};var it=class{gameInstanceId=null;fixtures=null};var Lo=(i=>(i.ONE="1",i.X="x",i.TWO="2",i))(Lo||{}),Bo=(i=>(i.ONE_X="1x",i.X_TWO="x2",i.ONE_TWO="12",i))(Bo||{}),No=(c=>(c.ONE_ONE="1/1",c.ONE_X="1/x",c.ONE_TWO="1/2",c.X_ONE="x/1",c.X_X="x/x",c.X_TWO="x/2",c.TWO_ONE="2/1",c.TWO_X="2/x",c.TWO_TWO="2/2",c))(No||{});var Pr=class{matchId=null;market="BOTH_TEAMS_SCORE";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new H,this.prediction.value=t}};var Er=class{value};var Rr=class{matchId=null;market="CORNERS_MATCH";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Er,this.prediction.value=t}};var Tr=class{value=null};var vr=class{matchId=null;market="DOUBLE_CHANCE";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Tr,this.prediction.value=t}};var Sr=class{value=null};var _r=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,i){this.matchId=e,this.market=t,this.prediction=new Sr,this.prediction.value=i}};var Cr=class{value=null};var Ar=class{matchId=null;market="HT_FT";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Cr,this.prediction.value=t}};var xr=class{matchId=null;market="PENALTY_MATCH";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new H,this.prediction.value=t}};var Or=class{matchId=null;market="RED_CARD_MATCH";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new H,this.prediction.value=t}};var pe=class{errorHandlingMode=null;constructor(e){this.errorHandlingMode=e}validateBodyFields=(e,t)=>{let i=Object.keys(t),r=Object.keys(new it);switch(e){case"MATCH_QUIZ":i.forEach(n=>{r.includes(n)||this.throwInvalidParamException([n])});break;case"TOP_X":let s=t;s.fixtures.forEach(n=>this.validateMarketTopX(n.market));let l="tiebreaker";i.includes(l)&&s.tiebreaker&&this.validateTiebreaker(s.tiebreaker),i.forEach(n=>{n!=="tiebreaker"&&!r.includes(n)&&this.throwInvalidParamException([n])});break}let o=r.filter(s=>!i.includes(s));return o.length&&this.throwMissingFieldsException("game prediction body",o),t.fixtures.forEach(s=>{this.validateFixtureFields(s)}),t};validateFixture=(e,t,i,r)=>{this.validateMarket(t);let o=Object.values(Lo),s=Object.values(No),l=Object.values(Bo);if(t==="FT_1X2"||t==="HT_1X2"){if(o.includes(i))return new _r(e,t,i)}else if(t==="HT_FT"){if(s.includes(i))return new Ar(e,i)}else if(t==="DOUBLE_CHANCE"){if(l.includes(i))return new vr(e,i)}else if(t==="CORRECT_SCORE"||t==="CORRECT_SCORE_ADVANCED"||t==="CORRECT_SCORE_HT"){if(typeof i=="string"&&/\d+:\d+/.test(i))return new ne(e,t,i)}else if(t==="CORNERS_MATCH"){if(typeof i=="number")return new Rr(e,i)}else if(t==="BOTH_TEAMS_SCORE"){if(this.isPredictionBoolean(i))return new Pr(e,i)}else if(t==="RED_CARD_MATCH"){if(this.isPredictionBoolean(i))return new Or(e,i)}else if(t==="PENALTY_MATCH"){if(this.isPredictionBoolean(i))return new xr(e,i)}else if(V.includes(t)){let n="OWN_GOAL";if(this.validatePlayerId(t,r),t===Ue&&this.isPredictionBoolean(i)){let c=r&&r===n?n:r;return new U(e,t,i,c)}if(r&&this.isPredictionBoolean(i))return new U(e,t,i,r)}else if(is.includes(t)){if(this.isPredictionBoolean(i))return new Ke(e,t,i)}else if(rs.includes(t)&&this.isPredictionBoolean(i))return new We(e,t,i);this.throwInvalidPredictionException(i,t)};validateFixtureFields=e=>{let t=Object.keys(e);t.forEach(r=>{Co.includes(r)||this.throwInvalidParamException([r])});let i=Co.filter(r=>{if(r!=="matchType"&&!t.includes(r))return r});i.length&&this.throwMissingFieldsException("fixtures",i),this.validatePredictionKey(e.market,e.prediction)};validateTiebreaker=e=>{let t=Object.keys(e);(!t.length||typeof e!="object")&&this.throwInvalidType("tiebreaker","object");let i=Object.keys(new K)[0];t.forEach(r=>{i!==r&&this.throwInvalidParamException([r])}),t.includes(i)||this.throwMissingFieldsException("tiebreaker",[i]),typeof e.goldenGoal!="number"&&this.throwInvalidType("goldenGoal","number")};validatePredictionKey=(e,t)=>{if(typeof t=="object"){let i=Object.keys(t),r=["value"];if(i.length||this.throwMissingFieldsException("prediction",r),i.length===1&&!i.includes(r[0])&&this.throwInvalidParamException(i),i.length>1){V.includes(e)&&r.push("playerId");let o=i.filter(s=>!r.includes(s));o.length&&this.throwInvalidParamException(o)}}else this.throwInvalidType("prediction","object")};validatePlayerId=(e,t)=>{let i="playerId";e!==Ue&&(t||this.throwInvalidParamException([i]),typeof t!="string"&&this.throwInvalidType(i,"string"))};validateMarket=e=>{Object.values(T).includes(e)||this.throwInvalidMarketException(e)};validateMarketTopX=e=>{e!=="CORRECT_SCORE"&&e!=="CORRECT_SCORE_ADVANCED"&&this.throwInvalidMarketException(e,"TOP_X")};isPredictionBoolean=e=>typeof e=="boolean";throwInvalidPredictionException=(e,t)=>{let i=Qa(e,t);throw this.errorHandlingMode==="default"?new g(400,"INVALID_PREDICTION",i):new h(400,"INVALID_TYPE",i).response};throwInvalidMarketException=(e,t)=>{let i=null;throw t&&t==="TOP_X"?i=za(e):i=Ut(e),this.errorHandlingMode==="default"?new g(400,"INVALID_MARKET",i):new h(400,"INVALID_TYPE",i).response};throwInvalidParamException=e=>{let t=Ja(e);throw this.errorHandlingMode==="default"?new g(400,"INVALID_FIELD",t):new h(400,"INVALID_TYPE",t).response};throwMissingFieldsException=(e,t)=>{let i=Za(e,t);throw this.errorHandlingMode==="default"?new g(400,"INVALID_FIELD",i):new h(400,"INVALID_TYPE",i).response};throwInvalidType=(e,t)=>{let i=es(e,t);throw this.errorHandlingMode==="default"?new g(400,"INVALID_TYPE",i):new h(400,"INVALID_TYPE",i).response}};var Dr=class{predictorHttps=null;clientHttps=null;idMapping=null;predictorService=null;predictorValidator=null;errorHandlingMode=null;constructor(e,t,i,r){this.predictorHttps=t,this.idMapping=r,this.clientHttps=i,this.errorHandlingMode=e.errorHandlingMode,this.predictorValidator=new pe(e.errorHandlingMode),this.predictorService=new Q(e,r)}makeFootballPrediction=async(e,t,i,r)=>{let o=this.predictorValidator.validateFixture(e,t,i,r),s=new it;if(this.idMapping.idSchema!=="native"){let l=o.matchId,n="",c=await this.predictorService.remapMatchIdToNative([l]);if(o.matchId=c[0],this.errorHandlingMode==="default"&&!o.matchId)throw new g(400,"INVALID_FIELD","Match id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&!o.matchId)throw new h(400,"INVALID_FIELD","Match id is invalid!").response;if(o instanceof U&&o.prediction.playerId!=="OWN_GOAL"){if(o.prediction.playerId&&(n=o.prediction.playerId,o.prediction.playerId=await this.predictorService.remapPlayerIdToNative([n])),this.errorHandlingMode==="default"&&o.market!==Ue&&!o.prediction.playerId)throw new g(400,"INVALID_FIELD","Player id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&o.market!==Ue&&!o.prediction.playerId)throw new h(400,"INVALID_FIELD","Player id is invalid!").response}s.fixtures=[o];let p=await this.predictorHttps.makeFootballPrediction(s);return p.fixtures.forEach(m=>{m.prediction.playerId&&m.prediction.playerId!=="OWN_GOAL"&&(m.prediction.playerId=n),m.matchId=l}),p}else return s.fixtures=[o],await this.predictorHttps.makeFootballPrediction(s)};getMatchSummary=async(e,t)=>{let i=await this.getMatchSummaryBase(e,t),r=JSON.parse(JSON.stringify(i.predictions)),o=await this.predictorService.remapPlayerIdToIdSchema(r);return i.predictions=o,i};getMarketSummary=async(e,t,i,r)=>{try{let o=await this.getMatchSummaryBase(e,r);return await this.predictorService.getMarketSummary(o,t,i)}catch(o){throw o}};getMatchSummaryBase=async(e,t)=>{if(this.idMapping.idSchema!=="native"){let r=(await this.predictorService.remapMatchIdToNative([e]))[0],o=await this.predictorHttps.getMatchSummary(r,t);return o.matchId=e,o}else return await this.predictorHttps.getMatchSummary(e,t)};getConfig=async()=>{let e=await this.clientHttps.getConfig("predictor");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(e):e};deleteFootballPrediction=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyPredictions=async e=>{let t=this.predictorService.initPredictionsFilters(e,"user");return await this.predictorHttps.getMyPredictions(t)};getMyPredictionsForMatches=async(e,t)=>{if(this.errorHandlingMode==="default"&&this.predictorService.areIdsExceeded(e))throw new g(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();if(this.errorHandlingMode==="standard"&&this.predictorService.areIdsExceeded(e))throw new h(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").response;this.idMapping.idSchema!=="native"&&(e=await this.predictorService.remapMatchIdToNative([...e]));let i=this.predictorService.initPredictionsFilters(t,"matches",e);return await this.predictorHttps.getMyPredictions(i)};getMyCurrentPredictions=async e=>{let t=this.predictorService.initPredictionsFilters(e,"current");return await this.predictorHttps.getMyPredictions(t)};getMyPastPredictions=async e=>{let t=this.predictorService.initPredictionsFilters(e,"past");return await this.predictorHttps.getMyPredictions(t)};getUserPredictions=async(e,t,i)=>{let r=this.predictorService.initPredictionsFilters(t,"user");return await this.predictorHttps.getUserPredictions(e,i,r)};getUserCurrentPredictions=async(e,t,i)=>{let r=this.predictorService.initPredictionsFilters(t,"current");return await this.predictorHttps.getUserPredictions(e,i,r)};getUserPastPredictions=async(e,t,i)=>{let r=this.predictorService.initPredictionsFilters(t,"past");return await this.predictorHttps.getUserPredictions(e,i,r)};getUserPredictionsForMatches=async(e,t,i,r)=>{if(this.errorHandlingMode==="default"&&this.predictorService.areIdsExceeded(t))throw new g(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();if(this.errorHandlingMode==="standard"&&this.predictorService.areIdsExceeded(t))throw new h(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").response;this.idMapping.idSchema!=="native"&&(t=await this.predictorService.remapMatchIdToNative([...t]));let o=this.predictorService.initPredictionsFilters(i,"matches",t);return await this.predictorHttps.getUserPredictions(e,r,o)};getPredictionById=async e=>await this.predictorHttps.getPredictionById(e)};var Lr=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(e){this.idMapping=new b(e),this.predictorHttps=new z(e,this.idMapping),this.clientHttps=new B(e),this.predictorFacade=new Dr(e,this.predictorHttps,this.clientHttps,this.idMapping)}makeFootballPrediction=async(e,t,i,r)=>await this.predictorFacade.makeFootballPrediction(e,t,i,r);getMatchSummary=async(e,t)=>await this.predictorFacade.getMatchSummary(e,t);getMarketSummary=async(e,t,i,r)=>await this.predictorFacade.getMarketSummary(e,t,i,r);getConfig=async()=>await this.predictorFacade.getConfig();deleteFootballPrediction=async e=>await this.predictorFacade.deleteFootballPrediction(e);getMyPredictions=async e=>await this.predictorFacade.getMyPredictions(e);getMyCurrentPredictions=async e=>await this.predictorFacade.getMyCurrentPredictions(e);getMyPastPredictions=async e=>await this.predictorFacade.getMyPastPredictions(e);getMyPredictionsForMatches=async(e,t)=>await this.predictorFacade.getMyPredictionsForMatches(e,t);getUserPredictions=async(e,t,i)=>await this.predictorFacade.getUserPredictions(e,t,i);getUserCurrentPredictions=async(e,t,i)=>await this.predictorFacade.getUserCurrentPredictions(e,t,i);getUserPastPredictions=async(e,t,i)=>await this.predictorFacade.getUserPastPredictions(e,t,i);getUserPredictionsForMatches=async(e,t,i,r)=>await this.predictorFacade.getUserPredictionsForMatches(e,t,i,r);getPredictionById=async e=>await this.predictorFacade.getPredictionById(e)};var Br=class{rankType=null;fromDate=null;toDate=null;pagination=new Be};var rt=class{position=null;profileId=null;profileModel=null;points=null;predictionsMade=null};var Nr=class{remapResponse=e=>(e.meta=this.remapMeta(e.meta),e.data=this.remapData(e.data),e);remapMeta=e=>{let t=new Br;return t.rankType=e.rank_type,t.fromDate=e.from_date,t.toDate=e.to_date,t.pagination.currentPage=e.pagination.current_page,t.pagination.itemsPerPage=e.pagination.items_per_page,t.pagination.totalItems=e.pagination.total_items,t.pagination.numberOfPages=e.pagination.number_of_pages,t};remapData=e=>{let t=[];return e.forEach(i=>{let r=new rt;r.position=i.position,r.profileId=i.profile_id,r.points=i.points,r.predictionsMade=i.predictions_made,t.push(r)}),t}};var Ur=class extends rt{id=null;rankType=null;model=null;gameType=null};var Hr=class{remapRankings=e=>(e.meta=this.remapMeta(e.meta),e.data=this.remapData(e.data),e);remapMeta=e=>{let t=new X;return t.pagination.currentPage=e.pagination.current_page,t.pagination.itemsPerPage=e.pagination.items_per_page,t.pagination.numberOfPages=e.pagination.number_of_pages,t.pagination.totalItems=e.pagination.total_items,t};remapData(e){let t=[];return e.forEach(i=>{let r=new Ur;r.id=i.id,r.rankType=i.rank_type,r.position=i.position,r.points=i.points,r.gameType=i.game_type,delete r.profileId,delete r.profileModel,delete r.predictionsMade,t.push(r)}),t}};var ot=class{id=null;name=null;description=null;type=null;fromDate=null;toDate=null;markets=[];teamIds=[];matchIds=[];gameIds=[];gameTypes=[];competitionIds=[];excludedProfileIds=[];rules=null;flags=null;images=new ze;status=null;automaticallyChangeStatus=!0;createdAt=null;updatedAt=null;related=null};var kr=class extends ot{labels=null;customFields=null;adContent=null};var Gr=class{remapResponse=e=>{let t=[];return e.forEach(i=>{let r=new ot;r.id=i.id,r.name=i.name,r.description=i.description,r.type=i.type,r.fromDate=i.from_date,r.toDate=i.to_date,r.markets=i.markets?i.markets:null,r.teamIds=i.team_ids?i.team_ids:null,r.matchIds=i.match_ids?i.match_ids:null,r.gameIds=i.game_ids?i.game_ids:null,r.gameTypes=i.game_types?i.game_types:null,r.competitionIds=i.competition_ids?i.competition_ids:null,r.excludedProfileIds=i.excluded_profile_ids?i.excluded_profile_ids:null,r.rules=i.rules?i.rules:null,r.flags=i.flags?i.flags:null,r.images=i.images?i.images:null,r.status=i.status?i.status:null,r.automaticallyChangeStatus=i.automatically_change_status,r.createdAt=i.created_at,r.updatedAt=i.updated_at,r.related=i.related?this.remapRelated(i.related):null,t.push(r)}),t};remapResponseId=e=>{let t=new kr;return t.id=e.id,t.name=e.name,t.description=e.description,t.type=e.type,t.fromDate=e.from_date,t.toDate=e.to_date,t.markets=e.markets?e.markets:null,t.teamIds=e.team_ids?e.team_ids:null,t.matchIds=e.match_ids?e.match_ids:null,t.gameIds=e.game_ids?e.game_ids:null,t.gameTypes=e.game_types?e.game_types:null,t.competitionIds=e.competition_ids?e.competition_ids:null,t.excludedProfileIds=e.excluded_profile_ids?e.excluded_profile_ids:null,t.rules=e.rules?e.rules:null,t.flags=e.flags?e.flags:null,t.images=e.images?e.images:null,t.status=e.status?e.status:null,t.automaticallyChangeStatus=e.automatically_change_status,t.related=e.related?this.remapRelated(e.related):null,t.labels=e.labels,t.customFields=e.custom_fields,t.adContent=e.ad_content,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapMeta=e=>{let t={};return t.totalItems=e.pagination.total_items,t};remapRelated=e=>e.map(t=>{let i=new tt;return i.entityId=t.entity_id,i.entityType=t.entity_type,i})};var Vr=class{position=null;points=null;predictionsMade=null;profileId=null;profileModel=null;successRatePercent=null};var $r=class{remapHighestSuccessRate=e=>e.map(t=>{let i=new Vr;return i.position=t.position,i.points=t.points,i.predictionsMade=t.predictions_made,i.profileId=t.profile_id,i.successRatePercent=t.success_rate_percent,i})};var qr=class extends E{templateRemapper=null;leaderboardRemapper=null;rankingsRemapper=null;highestSuccessRateRemapper=null;constructor(e){super(e,S(e.environment,"loyalty"));this.templateRemapper=new Gr,this.leaderboardRemapper=new Nr,this.rankingsRemapper=new Hr,this.highestSuccessRateRemapper=new $r}getTemplates=async(e,t)=>{try{let i=I(e)?`/leaderboard/templates/${this.apiSignInUrl}${F()}`:`/leaderboard/templates/${this.apiSignInUrl}`,r=await this.instance.get(i);if(t){let o=JSON.parse(JSON.stringify(r.data));return o.meta=this.templateRemapper.remapMeta(r.data.meta),o.data=this.templateRemapper.remapResponse(r.data.data),o}return this.templateRemapper.remapResponse(r.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn("There was a problem fetching the list of templates",r),r.response}};getTemplateById=async(e,t)=>{try{let i=I(t)?`/leaderboard/templates/${e}${this.apiSignInUrl}${F()}`:`/leaderboard/templates/${e}${this.apiSignInUrl}`,r=await this.instance.get(i);return this.templateRemapper.remapResponseId(r.data.data)}catch(i){let r=this.transformAxiosErrorToFansUnitedException(i);throw console.warn(`There was a problem requesting the following template: ${e}`,r),r.response}};getLeaderboard=async(e,t,i)=>{try{let r=I(t)?`/leaderboard/${e}/${this.apiSignInUrl}${F()}`:`/leaderboard/${e}/${this.apiSignInUrl}`;i&&(r+=`${i.constructFiltersUrl()}`);let o=await this.instance.get(r),s=JSON.parse(JSON.stringify(o.data));return this.leaderboardRemapper.remapResponse(s)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn(`There was a problem fetching the leaderboard for the following template: ${e}`,o),o.response}};getLeaderboardForGame=async(e,t,i)=>{try{let r=I(t)?`/leaderboard/games/${e}/${this.apiSignInUrl}${F()}`:`/leaderboard/games/${e}/${this.apiSignInUrl}`;i&&(r+=`${i.constructFiltersUrl()}`);let o=await this.instance.get(r),s=JSON.parse(JSON.stringify(o.data));return this.leaderboardRemapper.remapResponse(s)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn(`There was a problem fetching the leaderboard for the following game: ${e}`,o),o.response}};getUserRankings=async(e,t,i)=>{let r=`/leaderboard/users/${e}/rankings/${this.apiSignInUrl}`;t&&(r+=`${t.constructFiltersUrl()}`),I(i)&&(r+=`${F()}`);try{let o=await this.instance.get(r);return this.rankingsRemapper.remapRankings(o.data)}catch(o){let s=this.transformAxiosErrorToFansUnitedException(o);throw console.warn(`There was a problem fetching the rankings for the following user: ${e}`,s),s.response}};getHighestSuccessRate=async(e,t)=>{let i=`/statistics/top${this.apiSignInUrl}`;e&&(i+=`${e.constructFiltersUrl()}`),I(t)&&(i+=`${F()}`);try{let r=await this.instance.get(i);return this.highestSuccessRateRemapper.remapHighestSuccessRate(r.data.data)}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn("There was a problem fetching highest success rate",o),o.response}};getEntitiesFollows=async(e,t)=>{let i=I(t)?`/statistics/follows${this.apiSignInUrl}${F()}`:`/statistics/follows${this.apiSignInUrl}`;e.footballCompetitions&&(i+=`&competitions=${e.footballCompetitions.join(",")}`),e.footballTeams&&(i+=`&teams=${e.footballTeams.join(",")}`),e.footballPlayers&&(i+=`&players=${e.footballPlayers.join(",")}`);try{return(await this.instance.get(i)).data.data}catch(r){let o=this.transformAxiosErrorToFansUnitedException(r);throw console.warn("There was a problem fetching follows for entities",o),o.response}}};var jr=class{general;predictor;topX;matchQuiz};var at=class{limit=null;page=null;constructor(e){this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null}constructFiltersUrl(){let e="";return this.limit&&(e+="&",e+=`limit=${this.limit}`),this.page&&(e+="&",e+=`page=${this.page}`),e}};var Xr=class extends at{sortOrder=null;rankType=null;leaderboardIds=null;gameType=null;constructor(e){super(e);this.sortOrder=e.sortOrder,this.rankType=e.rankType,this.leaderboardIds=e.leaderboardIds,this.gameType=e.type&&e.type.toLowerCase()==="game"?e.gameType:null}constructFiltersUrl=()=>{let e=super.constructFiltersUrl();return this.sortOrder&&(e+="&",e+=`sort_order=${this.sortOrder}`),this.rankType&&(e+="&",e+=`rank_type=${this.rankType}`),this.leaderboardIds&&(e+="&",e+=`type_ids=${this.leaderboardIds.join(",")}`),this.gameType&&(e+="&",e+=`game_type=${this.gameType}`),e}};var Wr=class{idMappingService=null;profileNamespace=null;footballNamespace=null;errorHandlingMode=null;constructor(e){this.idMappingService=new b(e),this.profileNamespace=new ae(e),this.footballNamespace=new qe(e),this.errorHandlingMode=e.errorHandlingMode}remapTemplatesIds=async e=>{if(e.length>0){let t=[],i=[],r=[],o=[],s=[],l=[];e.forEach(p=>{p.teamIds&&p.teamIds.length>0?t=[...t,...p.teamIds]:p.matchIds&&p.matchIds.length>0?r=[...r,...p.matchIds]:p.competitionIds&&p.competitionIds.length>0&&(s=[...s,...p.competitionIds])});let n={team:t,match:r,competition:s},c=await this.idMappingService.idMappingFacade.getEntitiesByIds(n,"native",this.idMappingService.idSchema);return i=[...c.team],o=[...c.match],l=[...c.competition],e.forEach(p=>{p.teamIds&&p.teamIds.length>0?p.teamIds=p.teamIds.map(m=>m=c.team.shift()):p.matchIds&&p.matchIds.length>0?p.matchIds=p.matchIds.map(m=>m=c.match.shift()):p.competitionIds&&p.competitionIds.length>0&&(p.competitionIds=p.competitionIds.map(m=>m=c.competition.shift()))}),e}return e};addProfileModelToLeaderboad=async e=>{if(e.length>0){let t=[],i=e.map(o=>o.profileId);if(!i.length)return e;let r=await this.profileNamespace.getByIds(i);return e.forEach(o=>{r.forEach(s=>{s.id===o.profileId&&(delete s.interests,o.profileModel=s)}),o.profileModel||(o.profileModel=null),t.push(o)}),t}return e};buildClientBadges=e=>{let t=new jr;return t.general=this.extractEnabledBadgesId(e.general),t.predictor=this.extractEnabledBadgesId(e.predictor),t.topX=this.extractEnabledBadgesId(e.topX),t.matchQuiz=this.extractEnabledBadgesId(e.matchQuiz),t};initFilters=(e,t)=>{switch(t){case"loyalty":e&&(e=new at(e));break;case"rankings":e&&(e=new Xr(e));break}return e};addProfileModelToHighestSuccessRate=async e=>{let t=e.map(r=>r.profileId);if(!t.length)return e;let i=await this.profileNamespace.getByIds(t);return e.map(r=>(i.forEach(o=>{o.id===r.profileId&&(delete o.interests,r.profileModel=o)}),r))};extractRankingsIdsMap=e=>{let t=[],i=[],r=[];return e.forEach(o=>{o.rankType==="GAME"&&o.gameType==="TOP_X"?t.push(o.id):o.rankType==="GAME"&&o.gameType==="MATCH_QUIZ"?i.push(o.id):o.rankType==="TEMPLATE"&&r.push(o.id)}),[t,i,r]};setModelsForUserRankings=(e,t,i,r)=>(r.data.forEach(o=>{o.gameType==="MATCH_QUIZ"&&t?o.model=t.filter(s=>s.id===o.id)[0]:o.gameType==="TOP_X"&&e?o.model=e.filter(s=>s.id===o.id)[0]:o.rankType==="TEMPLATE"&&i&&(o.model=i.filter(s=>s.id===o.id)[0])}),r);completeContestWinners=async e=>{let t=e.userList.map(r=>r.profileId),i=await this.profileNamespace.getByIds(t);return e.userList.forEach(r=>{let o=i.filter(s=>s.id===r.profileId)[0];delete o.interests,r.profileModel=o}),e};validateEntitiesFollowsFilters=e=>{let t=24;if(!e||(!e.footballCompetitions||!e.footballCompetitions.length)&&(!e.footballTeams||!e.footballTeams.length)&&(!e.footballPlayers||!e.footballPlayers.length))throw this.errorHandlingMode==="default"?new g(400,"invalid_filters","At least one of footballCompetitions, footballTeams or footballPlayers properties should be provided for filters."):new h(400,"invalid_filters","At least one of footballCompetitions, footballTeams or footballPlayers properties should be provided for filters.").response;if(e.footballCompetitions&&e.footballCompetitions.length>t||e.footballTeams&&e.footballTeams.length>t||e.footballPlayers&&e.footballPlayers.length>t)throw this.errorHandlingMode==="default"?new g(400,"EXCEEDED_LENGTH","Maximum length per entity should be 24 or less."):new h(400,"EXCEEDED_LENGTH","Maximum length per entity should be 24 or less.").response};remapEntitiesFollowsFilters=async e=>{let t=JSON.parse(JSON.stringify(e)),i={},r={};t.footballCompetitions&&t.footballCompetitions.length&&(r.competition=t.footballCompetitions),t.footballTeams&&t.footballTeams.length&&(r.team=t.footballTeams),t.footballPlayers&&t.footballPlayers.length&&(r.player=t.footballPlayers);let o=await this.idMappingService.idMappingFacade.getEntitiesByIds(r,this.idMappingService.idSchema,"native");return Object.keys(o).forEach(s=>{s==="competition"?i.footballCompetitions=o[s]:s==="team"?i.footballTeams=o[s]:s==="player"&&(i.footballPlayers=o[s])}),i};addModelsToEntitiesFollows=async e=>{let t=[],i="fb:c:",r=new Map,o=[],s="fb:t:",l=new Map,n=[],c="fb:p:",p=null;return e.breakdown.forEach(m=>{m.id.includes(i)?t.push(m.id):m.id.includes(s)?o.push(m.id):m.id.includes(c)&&n.push(m.id)}),t.length&&(r=await this.footballNamespace.footballFacade.competitionsFacade.getCompetitionsMapWithNativeIds(t)),o.length&&(l=await this.footballNamespace.footballFacade.teamsFacade.getTeamsMapWithNativeIds(o)),n.length&&(p=await this.footballNamespace.footballFacade.playerFacade.getPlayersMapWithNativeIds(n)),e.breakdown.forEach(m=>{m.id.includes(i)?(m.model=r.get(m.id),m.id=m.model.id):m.id.includes(s)?(m.model=l.get(m.id),m.id=m.model.id):m.id.includes(c)&&(m.model=p[m.id],m.id=m.model.id)}),e};extractEnabledBadgesId=e=>{let t=[];return e.forEach(i=>{i.enabled&&t.push(i.id)}),t}};var Kr=class{validate=(e,t)=>{e.market&&this.validateMarket(e.market,t),e.fromDate&&this.validateDate(e.fromDate,"fromDate",t),e.toDate&&this.validateDate(e.toDate,"toDate",t),e.usersCount&&this.validateNumberFilters(e.usersCount,"usersCount",t),e.minimumPredictions&&this.validateNumberFilters(e.minimumPredictions,"minimumPredictions",t)};validateMarket=(e,t)=>{if(!Object.keys(T).includes(e)){let r=Ut(e);throw t==="default"?new g(400,"INVALID_MARKET",r):new h(400,"INVALID_MARKET",r).response}};validateDate=(e,t,i)=>{let r=/^\d{4}-\d{2}-\d{2}$/;if(typeof e!="string")throw i==="default"?new g(400,"invalid_filters","You have provided invalid type. The valid type is "+`string for ${t} filter`):new h(400,"invalid_filters","You have provided invalid type. The valid type is "+`string for ${t} filter`).response;if(!r.test(e))throw i==="default"?new g(400,"invalid_filters","You have provided invalid value. The valid value is "+`YYYY-MM-DD for ${t}`):new h(400,"invalid_filters","You have provided invalid value. The valid value is "+`YYYY-MM-DD for ${t}`).response};validateNumberFilters=(e,t,i)=>{let r=t==="usersCount"?1:0,o=t==="usersCount"?1e3:1e6;if(typeof e!="number")throw i==="default"?new g(400,"invalid_filters","You have provided invalid type. The valid type is "+`number for ${t} filter`):new h(400,"invalid_filters","You have provided invalid type. The valid type is "+`number for ${t} filter`).response;if(e<r||e>o)throw i==="default"?new g(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${o}`):new h(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${o}`).response}};var st=class{idMapping=null;predictorHttps=null;predictorService=null;predictorValidator=null;clientHttps=null;errorHandlingMode=null;constructor(e,t){this.idMapping=t,this.errorHandlingMode=e.errorHandlingMode,this.predictorValidator=new pe(e.errorHandlingMode),this.predictorHttps=new z(e,t),this.predictorService=new Q(e,t),this.clientHttps=new B(e)}getConfig=async()=>{let e=await this.clientHttps.getConfig("topX");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(e):e};getGames=async(e,t)=>{t=t||!1;let i=this.predictorService.initGameFilters("TOP_X",e),r=await this.predictorHttps.getGames(i,t);return await this.predictorService.remapMatchIdsFixtures(r)};getGameById=async(e,t)=>{t=t||!1;let i=await this.predictorHttps.getGameById(e,t);return await this.predictorService.remapMatchIdsFixtures(i)};getGamePredictions=async(e,t,i)=>(i=i||!1,t&&(t.type&&delete t.type,t.status&&delete t.status,t=new v(t)),await this.predictorHttps.getGamePredictions(e,i,t));getGameResults=async(e,t,i)=>{i=i||!1,t&&(t=new k(t));let r=await this.predictorHttps.getGameResults(e,i,t);return await this.predictorService.remapMatchIdsFixtures(r)};getCurrentGameResults=async e=>{e=e||!1;let t={status:"OPEN",type:"TOP_X"};t=new k(t);let i=await this.predictorHttps.getGames(t,e),r=this.predictorService.getCurrentGameId(i);return(await this.getGameResults(r,null,e)).data[0]};play=async e=>{let t=new Ze(e);if(t=this.predictorValidator.validateBodyFields("TOP_X",t),t.fixtures=t.fixtures.map(r=>this.predictorValidator.validateFixture(r.matchId,r.market,r.prediction.value)),this.idMapping.idSchema!=="native"){let r=[];t.fixtures.forEach(s=>r.push(s.matchId));let o=await this.predictorService.remapMatchIdToNative(r);t.fixtures.forEach(s=>s.matchId=o.shift())}let i=await this.predictorHttps.makeFootballPrediction(t);return i.fixtures.forEach(r=>{r.matchId=r.matchModel.id}),i};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyGameEditions=async(e,t)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),t=t||!1;let i=this.predictorService.initGameTypePredictions("TOP_X",e),r=[],o=await this.predictorHttps.getMyPredictionsNoRemap(i);if(o.data.length>0){o.data.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let s=this.predictorService.initGameFilters("TOP_X",null,r),l=await this.predictorHttps.getUserGameEditions(s,t);return await this.predictorService.addPredictionProp(o,l)}else return new M};getMyGamePrediction=async e=>{let t=this.predictorService.initGameTypePredictions("TOP_X"),i=await this.predictorHttps.getMyPredictions(t);if(i.data.length>0){let r=i.data.filter(o=>o.gameInstanceId===e);return r.length?r[0]:null}return null};getUserGameEditions=async(e,t,i)=>{t&&t.limit&&this.validateLimitFilterOnGames(t.limit),i=i||!1;let r=this.predictorService.initGameTypePredictions("TOP_X",t),o=[],s=await this.predictorHttps.getUserPredictionsNoRemap(e,r);if(s.data.length>0){s.data.forEach(c=>{c.game_instance_id&&o.push(c.game_instance_id)});let l=this.predictorService.initGameFilters("TOP_X",null,o),n=await this.predictorHttps.getUserGameEditions(l,i);return await this.predictorService.addPredictionProp(s,n)}else return new M};getUserGamePrediction=async(e,t,i)=>{i=i||!1;let r=this.predictorService.initGameTypePredictions("TOP_X"),o=await this.predictorHttps.getUserPredictions(e,i,r);if(o.data.length>0){let s=o.data.filter(l=>l.gameInstanceId===t);return s.length?s[0]:null}else return null};getMarketsResultsForGame=async(e,t)=>{let i=await this.predictorHttps.getMarketResultsForGame(e,t);return await this.predictorService.completeGameMarketResults(i,"TOP_X")};getGameWinners=async e=>{let t=await this.predictorHttps.getContestWinners(e),i=await this.getGameById(e);return t.contestModel=i,this.predictorService.completeContestWinners(t)};validateLimitFilterOnGames=e=>{let t=50;if(this.errorHandlingMode==="default"&&e>t)throw new g(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.");if(this.errorHandlingMode==="standard"&&e>t)throw new h(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.").response}};var nt=class{predictorHttps=null;predictorService=null;idMapping=null;clientHttps=null;predictorValidator=null;errorHandlingMode=null;constructor(e){this.predictorValidator=new pe(e.errorHandlingMode),this.idMapping=new b(e),this.predictorHttps=new z(e,this.idMapping),this.predictorService=new Q(e,this.idMapping),this.clientHttps=new B(e),this.errorHandlingMode=e.errorHandlingMode}getConfig=async()=>{let e=await this.clientHttps.getConfig("matchQuiz");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(e):e};play=async e=>{e=this.predictorValidator.validateBodyFields("MATCH_QUIZ",e);let t=e.fixtures.map(i=>this.predictorValidator.validateFixture(i.matchId,i.market,i.prediction.value,i.prediction.playerId));if(t&&t.length&&this.idMapping.idSchema!=="native"){let i=[],r=[];t.forEach(l=>{i.push(l.matchId),l instanceof U&&l.prediction.playerId&&l.prediction.playerId!=="OWN_GOAL"&&r.push(l.prediction.playerId)});let o=await this.predictorService.remapMatchIdToNative(i),s={};r&&r.length>0&&(s=await this.predictorService.remapPlayerIdMapToNative(r)),t.forEach((l,n)=>{l.matchId=o[n],l instanceof U&&l.prediction.playerId!=="OWN_GOAL"&&(l.prediction.playerId=s[l.prediction.playerId])})}return e.fixtures=t,await this.predictorHttps.makeFootballPrediction(e)};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getGames=async(e,t)=>{t=t||!1;let i=this.predictorService.initGameFilters("MATCH_QUIZ",e),r=await this.predictorHttps.getGames(i,t);return await this.predictorService.remapMatchIdsFixtures(r)};getGameById=async(e,t)=>{t=t||!1;let i=await this.predictorHttps.getGameById(e,t);return await this.predictorService.remapMatchIdsFixtures(i)};getGamePredictions=async(e,t,i)=>(i=i||!1,t&&(t.type&&delete t.type,t.status&&delete t.status,t=new v(t)),await this.predictorHttps.getGamePredictions(e,i,t));getGameResults=async(e,t,i)=>{i=i||!1,t&&(t=new Qe(t));let r=await this.predictorHttps.getGameResults(e,i,t);return await this.predictorService.remapMatchIdsFixtures(r)};getCurrentGameResults=async e=>{e=e||!1;let t={status:"OPEN",type:"MATCH_QUIZ"};t=new k(t);let i=await this.predictorHttps.getGames(t,e),r=this.predictorService.getCurrentGameId(i);return(await this.getGameResults(r,null,e)).data[0]};getMyGameEditions=async(e,t)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),t=t||!1;let i=this.predictorService.initGameTypePredictions("MATCH_QUIZ",e),r=[],o=await this.predictorHttps.getMyPredictionsNoRemap(i);if(o.data.length>0){o.data.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let s=this.predictorService.initGameFilters("MATCH_QUIZ",null,r),l=await this.predictorHttps.getUserGameEditions(s,t);return await this.predictorService.addPredictionProp(o,l)}else return new M};getMyGamePrediction=async e=>{let t=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),i=await this.predictorHttps.getMyPredictions(t);if(i.data.length>0){let r=i.data.filter(o=>o.gameInstanceId===e);return r.length?r[0]:null}return null};getUserGameEditions=async(e,t,i)=>{t&&t.limit&&this.validateLimitFilterOnGames(t.limit),i=i||!1;let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ",t),o=[],s=await this.predictorHttps.getUserPredictionsNoRemap(e,r);if(s.data.length>0){s.data.forEach(c=>{c.game_instance_id&&o.push(c.game_instance_id)});let l=this.predictorService.initGameFilters("MATCH_QUIZ",null,o),n=await this.predictorHttps.getUserGameEditions(l,i);return await this.predictorService.addPredictionProp(s,n)}else return new M};getUserGamePrediction=async(e,t,i)=>{i=i||!1;let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),o=await this.predictorHttps.getUserPredictions(e,i,r);if(o.data.length>0){let s=o.data.filter(l=>l.gameInstanceId===t);return s.length?s[0]:null}else return null};getMarketsResultsForGame=async(e,t)=>{let i=await this.predictorHttps.getMarketResultsForGame(e,t);return await this.predictorService.completeGameMarketResults(i,"MATCH_QUIZ")};getGameWinners=async e=>{let t=await this.predictorHttps.getContestWinners(e),i=await this.getGameById(e);return t.contestModel=i,this.predictorService.completeContestWinners(t)};validateLimitFilterOnGames=e=>{let t=50;if(this.errorHandlingMode==="default"&&e>t)throw new g(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.");if(this.errorHandlingMode==="standard"&&e>t)throw new h(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.").response}};var Yr=class{market;fromDate;toDate;usersCount;minimumPredictions;constructor(e){this.market=e.market?e.market:null,this.fromDate=e.fromDate?e.fromDate:null,this.toDate=e.toDate?e.toDate:null,this.usersCount=e.usersCount?e.usersCount:null,this.minimumPredictions=e.minimumPredictions?e.minimumPredictions:null}constructFiltersUrl(){let e="";return this.market&&(e+="&",e+=`market=${this.market}`),this.fromDate&&(e+="&",e+=`from_date=${this.fromDate}`),this.toDate&&(e+="&",e+=`to_date=${this.toDate}`),this.usersCount&&(e+="&",e+=`users_count=${this.usersCount}`),this.minimumPredictions&&(e+="&",e+=`minimum_predictions=${this.minimumPredictions}`),e}};var Qr=class{config=null;clientHttps=null;loyaltyHttps=null;loyaltyService=null;profileFacade=null;loyaltyValidator=null;idMapping=null;topXFacade=null;matchQuizFacade=null;predictorHttps=null;errorHandlingMode=null;constructor(e,t,i,r,o){this.config=e,this.clientHttps=t,this.loyaltyHttps=i,this.profileFacade=new j(o,r),this.loyaltyService=new Wr(this.config),this.loyaltyValidator=new Kr,this.idMapping=new b(e),this.topXFacade=new st(e,this.idMapping),this.matchQuizFacade=new nt(e),this.predictorHttps=new z(e,this.idMapping),this.errorHandlingMode=e.errorHandlingMode}getConfig=async()=>await this.clientHttps.getConfig("loyalty");getClientBadges=async()=>{let e=await this.getConfig();return this.loyaltyService.buildClientBadges(e.rewards.badges)};getTemplates=async e=>{let t=!0;if(this.config.idSchema==="native")return await this.loyaltyHttps.getTemplates(e,t);let i=await this.loyaltyHttps.getTemplates(e,t);return i.data=await this.loyaltyService.remapTemplatesIds([...i.data]),i};getTemplateById=async(e,t)=>{let i=await this.loyaltyHttps.getTemplateById(e,t);return this.config.idSchema==="native"?i:(await this.loyaltyService.remapTemplatesIds([i]))[0]};getLeaderboard=async(e,t,i)=>{t=this.loyaltyService.initFilters(t,"loyalty");let r=await this.loyaltyHttps.getLeaderboard(e,i,t);return r.data=await this.loyaltyService.addProfileModelToLeaderboad(r.data),r};getLeaderboardForGame=async(e,t,i)=>{t=this.loyaltyService.initFilters(t,"loyalty");let r=await this.loyaltyHttps.getLeaderboardForGame(e,i,t);return r.data=await this.loyaltyService.addProfileModelToLeaderboad(r.data),r};getOwnRankings=async(e,t)=>{let{id:i}=await this.profileFacade.getOwn();return this.getUserRankings(i,e,t)};getUserRankings=async(e,t,i)=>{t=this.loyaltyService.initFilters(t,"rankings");let r=await this.loyaltyHttps.getUserRankings(e,t,i);return await this.getModelsForUserRankings(r)};getHighestSuccessRate=async(e,t)=>{e&&(e=new Yr(e),this.loyaltyValidator.validate(e,this.errorHandlingMode));let i=await this.loyaltyHttps.getHighestSuccessRate(e,t);return this.loyaltyService.addProfileModelToHighestSuccessRate(i)};getTemplateWinners=async e=>{let t=await this.predictorHttps.getContestWinners(e),i=await this.getTemplateById(e);return t.contestModel=i,this.loyaltyService.completeContestWinners(t)};getEntitiesFollows=async(e,t)=>{this.loyaltyService.validateEntitiesFollowsFilters(e),this.config.idSchema!=="native"&&(e=await this.loyaltyService.remapEntitiesFollowsFilters(e));let i=await this.loyaltyHttps.getEntitiesFollows(e,t);return await this.loyaltyService.addModelsToEntitiesFollows(i)};getModelsForUserRankings=async e=>{let t=null,i=null,r=null,[o,s,l]=this.loyaltyService.extractRankingsIdsMap(e.data);if(l.length&&(t=(await this.getTemplates()).data.filter(c=>l.includes(c.id))),o.length){let n={gameIds:o};i=(await this.topXFacade.getGames(n)).data}if(s.length){let n={gameIds:s};r=(await this.matchQuizFacade.getGames(n)).data}return this.loyaltyService.setModelsForUserRankings(i,r,t,e)}};var zr=class{clientHttps=null;profileHttps=null;loyaltyHttps=null;loyaltyFacade=null;localStorage=null;constructor(e){this.clientHttps=new B(e),this.profileHttps=new Ee(e),this.loyaltyHttps=new qr(e),this.localStorage=new L(e),this.loyaltyFacade=new Qr(e,this.clientHttps,this.loyaltyHttps,this.profileHttps,this.localStorage)}getConfig=async()=>await this.loyaltyFacade.getConfig();getClientBadges=async()=>await this.loyaltyFacade.getClientBadges();getTemplates=async e=>await this.loyaltyFacade.getTemplates(e);getTemplateById=async(e,t)=>await this.loyaltyFacade.getTemplateById(e,t);getLeaderboard=async(e,t,i)=>await this.loyaltyFacade.getLeaderboard(e,t,i);getLeaderboardForGame=async(e,t,i)=>await this.loyaltyFacade.getLeaderboardForGame(e,t,i);getOwnRankings=async(e,t)=>await this.loyaltyFacade.getOwnRankings(e,t);getUserRankings=async(e,t,i)=>await this.loyaltyFacade.getUserRankings(e,t,i);getHighestSuccessRate=async(e,t)=>await this.loyaltyFacade.getHighestSuccessRate(e,t);getTemplateWinners=async e=>await this.loyaltyFacade.getTemplateWinners(e);getEntitiesFollows=async(e,t)=>await this.loyaltyFacade.getEntitiesFollows(e,t)};var Jr=class{topXFacade=null;idMapping=null;constructor(e){this.idMapping=new b(e),this.topXFacade=new st(e,this.idMapping)}getConfig=async()=>await this.topXFacade.getConfig();getGames=async(e,t)=>await this.topXFacade.getGames(e,t);getGameById=async(e,t)=>await this.topXFacade.getGameById(e,t);getGamePredictions=async(e,t,i)=>await this.topXFacade.getGamePredictions(e,t,i);getGameResults=async(e,t,i)=>await this.topXFacade.getGameResults(e,t,i);getCurrentGameResults=async e=>await this.topXFacade.getCurrentGameResults(e);play=async e=>await this.topXFacade.play(e);delete=async e=>await this.topXFacade.delete(e);getMyGameEditions=async(e,t)=>await this.topXFacade.getMyGameEditions(e,t);getMyGamePrediction=async e=>await this.topXFacade.getMyGamePrediction(e);getUserGameEditions=async(e,t,i)=>await this.topXFacade.getUserGameEditions(e,t,i);getUserGamePrediction=async(e,t,i)=>await this.topXFacade.getUserGamePrediction(e,t,i);getMarketsResultsForGame=async(e,t)=>await this.topXFacade.getMarketsResultsForGame(e,t);getGameWinners=async e=>await this.topXFacade.getGameWinners(e)};var Zr=class{matchQuizFacade=null;constructor(e){this.matchQuizFacade=new nt(e)}getConfig=async()=>await this.matchQuizFacade.getConfig();play=async e=>await this.matchQuizFacade.play(e);delete=async e=>await this.matchQuizFacade.delete(e);getGames=async(e,t)=>await this.matchQuizFacade.getGames(e,t);getGameById=async(e,t)=>await this.matchQuizFacade.getGameById(e,t);getGamePredictions=async(e,t,i)=>await this.matchQuizFacade.getGamePredictions(e,t,i);getGameResults=async(e,t,i)=>await this.matchQuizFacade.getGameResults(e,t,i);getCurrentGameResults=async e=>await this.matchQuizFacade.getCurrentGameResults(e);getMyGameEditions=async(e,t)=>await this.matchQuizFacade.getMyGameEditions(e,t);getMyGamePrediction=async e=>await this.matchQuizFacade.getMyGamePrediction(e);getUserGameEditions=async(e,t,i)=>await this.matchQuizFacade.getUserGameEditions(e,t,i);getUserGamePrediction=async(e,t,i)=>await this.matchQuizFacade.getUserGamePrediction(e,t,i);getMarketsResultsForGame=async(e,t)=>await this.matchQuizFacade.getMarketsResultsForGame(e,t);getGameWinners=async e=>await this.matchQuizFacade.getGameWinners(e)};var It=class{action=null;context=new He;constructor(e,t,i,r){this.action=e,this.context.tags=t,i&&(this.context.content=i),r&&(this.context.campaign=r)}};var eo=class{idSchema;idMapping;constructor(e){this.idSchema=e.idSchema,this.idMapping=new b(e)}remapTagsIds=async(e,t,i)=>{if(!e||!e.length)return e;let r={},o={},s=[];e.forEach(n=>{r.hasOwnProperty(n.type)||(r[n.type]=[],o[n.type]=[]),r[n.type].push(n.id),o[n.type].push(n)});let l=await this.idMapping.idMappingFacade.getEntitiesByIds(r,t,i);for(let[n,c]of Object.entries(o))c.forEach((p,m)=>{p.id=l[n][m],s.push(p)});return s}};var lt=class{page=null;limit=null;constructor(e){this.page=e.page?e.page:null,this.limit=e.limit?e.limit:null}};var to=class extends lt{action=null;constructor(e){super(e);this.action=e.action?e.action:null}constructFilterUrl(){let e="";return this.action&&(e+="&",e+=`action=${this.action}`),this.page&&(e+="&",e+=`page=${this.page}`),this.limit&&(e+="&",e+=`limit=${this.limit}`),e}};var io=class extends lt{action=null;constructor(e){super(e);this.action=e.action?e.action:null}constructFilterUrl(){let e="";return this.action&&(e+="&",e+=`action=${this.action}`),this.page&&(e+="&",e+=`page=${this.page}`),this.limit&&(e+="&",e+=`limit=${this.limit}`),e}};var ro=class{idSchema;activityHttps;activityService;constructor(e){this.idSchema=e.idSchema,this.activityHttps=new Ge(e),this.activityService=new eo(e)}add=async(e,t,i,r)=>{if(this.idSchema!="native"){let s=JSON.parse(JSON.stringify(t)),l=await this.activityService.remapTagsIds(t,this.idSchema,"native"),n=new It(e,l,i,r),c=await this.activityHttps.createActivity(n);return c.context.tags=s,c}let o=new It(e,t,i,r);return this.activityHttps.createActivity(o)};delete=async e=>await this.activityHttps.deleteActivity(e);like=async(e,t,i)=>{let r="like";return await this.add(r,e,t,i)};dislike=async(e,t,i)=>{let r="dislike";return await this.add(r,e,t,i)};addPageview=async(e,t,i)=>{let r="page_view";return await this.add(r,e,t,i)};addContentConsumed=async(e,t,i)=>{let r="content_consumed";return await this.add(r,e,t,i)};addShare=async(e,t,i)=>{let r="share";return await this.add(r,e,t,i)};addComment=async(e,t,i)=>{let r="comment";return await this.add(r,e,t,i)};addClickAd=async(e,t,i)=>{let r="click_ad";return await this.add(r,e,t,i)};addConversion=async(e,t,i)=>{let r="conversion";return await this.add(r,e,t,i)};getOwn=async(e,t)=>{if(t=t||!1,e&&(e=new to(e)),this.idSchema!="native"){let i=await this.activityHttps.getOwnActivities(e,t);for(let r of i.data)await this.activityService.remapTagsIds(r.context.tags,"native",this.idSchema);return i}return await this.activityHttps.getOwnActivities(e,t)};getForUser=async(e,t,i)=>{if(i=i||!1,t&&(t=new io(t)),this.idSchema!="native"){let r=await this.activityHttps.getActivitiesForUser(e,t,i);for(let o of r.data)await this.activityService.remapTagsIds(o.context.tags,"native",this.idSchema);return r}return await this.activityHttps.getActivitiesForUser(e,t,i)}};var oo=class{activityFacade;constructor(e){this.activityFacade=new ro(e)}add=async(e,t,i,r)=>await this.activityFacade.add(e,t,i,r);delete=async e=>await this.activityFacade.delete(e);like=async(e,t,i)=>await this.activityFacade.like(e,t,i);dislike=async(e,t,i)=>await this.activityFacade.dislike(e,t,i);addPageview=async(e,t,i)=>await this.activityFacade.addPageview(e,t,i);addContentConsumed=async(e,t,i)=>await this.activityFacade.addContentConsumed(e,t,i);addShare=async(e,t,i)=>await this.activityFacade.addShare(e,t,i);addComment=async(e,t,i)=>await this.activityFacade.addComment(e,t,i);addClickAd=async(e,t,i)=>await this.activityFacade.addClickAd(e,t,i);addConversion=async(e,t,i)=>await this.activityFacade.addConversion(e,t,i);getOwn=async(e,t)=>await this.activityFacade.getOwn(e,t);getForUser=async(e,t,i)=>await this.activityFacade.getForUser(e,t,i)};function cI(a){let t=new or().validate(a);if((t.idSchema.validation==="missing"||t.idSchema.validation==="invalid")&&(console.warn(t.idSchema.message.text),a.idSchema="native"),(t.environment.validation==="missing"||t.environment.validation==="invalid")&&(console.warn(t.environment.message.text),a.environment="prod"),(t.lang.validation==="missing"||t.lang.validation==="invalid")&&(console.warn(t.lang.message.text),a.lang="en"),(t.errorHandlingMode.validation==="missing"||t.errorHandlingMode.validation==="invalid")&&(console.warn(t.errorHandlingMode.message.text),a.errorHandlingMode="default"),t.authProvider.validation==="invalid"&&console.warn(t.authProvider.message.text),t.isValid)return{profile:new ae(a),football:new qe(a),predictor:new Lr(a),loyalty:new zr(a),topX:new Jr(a),matchQuiz:new Zr(a),activity:new oo(a)};un(t)}var un=a=>{let e="authProvider",t="isValid";Object.keys(a).forEach(i=>{let r=a[i];if(i!==t&&i!==e){if(r.message.type==="error")throw new Error(r.message.text)}else i!==t&&i===e&&Object.keys(new fe).forEach(o=>{if(r[o].message.type==="error")throw new Error(r[o].message.text)})})};export{cI as FansUnitedSDK};
|
|
5
5
|
//# sourceMappingURL=index.js.map
|