fansunited-sdk-esm 1.1.0 → 1.1.4
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 +2 -2
- package/index.js.map +3 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
2
|
-
`),function(n){if(a=n.indexOf(":"),r=Ur.trim(n.substr(0,a)).toLowerCase(),i=Ur.trim(n.substr(a+1)),r){if(t[r]&&Wo.indexOf(r)>=0)return;r==="set-cookie"?t[r]=(t[r]?t[r]:[]).concat([i]):t[r]=t[r]?t[r]+", "+i:i}}),t}});var Oi=h((Va,_i)=>{"use strict";var Ei=M();_i.exports=Ei.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a"),r;function i(a){var s=a;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 r=i(window.location.href),function(s){var n=Ei.isString(s)?i(s):s;return n.protocol===r.protocol&&n.host===r.host}}():function(){return function(){return!0}}()});var he=h((Da,xi)=>{"use strict";function $r(o){this.message=o}$r.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};$r.prototype.__CANCEL__=!0;xi.exports=$r});var Hr=h((Ua,Ai)=>{"use strict";var _e=M(),Jo=wi(),zo=bi(),Qo=Lr(),Zo=vi(),ea=Ti(),ta=Oi(),Gr=Dr(),ra=fe(),ia=he();Ai.exports=function(e){return new Promise(function(r,i){var a=e.data,s=e.headers,n=e.responseType,p;function m(){e.cancelToken&&e.cancelToken.unsubscribe(p),e.signal&&e.signal.removeEventListener("abort",p)}_e.isFormData(a)&&delete s["Content-Type"];var l=new XMLHttpRequest;if(e.auth){var u=e.auth.username||"",w=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";s.Authorization="Basic "+btoa(u+":"+w)}var ue=Zo(e.baseURL,e.url);l.open(e.method.toUpperCase(),Qo(ue,e.params,e.paramsSerializer),!0),l.timeout=e.timeout;function ii(){if(!!l){var C="getAllResponseHeaders"in l?ea(l.getAllResponseHeaders()):null,k=!n||n==="text"||n==="json"?l.responseText:l.response,G={data:k,status:l.status,statusText:l.statusText,headers:C,config:e,request:l};Jo(function(Er){r(Er),m()},function(Er){i(Er),m()},G),l=null}}if("onloadend"in l?l.onloadend=ii:l.onreadystatechange=function(){!l||l.readyState!==4||l.status===0&&!(l.responseURL&&l.responseURL.indexOf("file:")===0)||setTimeout(ii)},l.onabort=function(){!l||(i(Gr("Request aborted",e,"ECONNABORTED",l)),l=null)},l.onerror=function(){i(Gr("Network Error",e,null,l)),l=null},l.ontimeout=function(){var k=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",G=e.transitional||ra.transitional;e.timeoutErrorMessage&&(k=e.timeoutErrorMessage),i(Gr(k,e,G.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",l)),l=null},_e.isStandardBrowserEnv()){var oi=(e.withCredentials||ta(ue))&&e.xsrfCookieName?zo.read(e.xsrfCookieName):void 0;oi&&(s[e.xsrfHeaderName]=oi)}"setRequestHeader"in l&&_e.forEach(s,function(k,G){typeof a=="undefined"&&G.toLowerCase()==="content-type"?delete s[G]:l.setRequestHeader(G,k)}),_e.isUndefined(e.withCredentials)||(l.withCredentials=!!e.withCredentials),n&&n!=="json"&&(l.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&l.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&l.upload&&l.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(p=function(C){!l||(i(!C||C&&C.type?new ia("canceled"):C),l.abort(),l=null)},e.cancelToken&&e.cancelToken.subscribe(p),e.signal&&(e.signal.aborted?p():e.signal.addEventListener("abort",p))),a||(a=null),l.send(a)})}});var fe=h(($a,Li)=>{"use strict";var y=M(),Bi=hi(),oa=Vr(),aa={"Content-Type":"application/x-www-form-urlencoded"};function Ni(o,e){!y.isUndefined(o)&&y.isUndefined(o["Content-Type"])&&(o["Content-Type"]=e)}function sa(){var o;return typeof XMLHttpRequest!="undefined"?o=Hr():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(o=Hr()),o}function na(o,e,t){if(y.isString(o))try{return(e||JSON.parse)(o),y.trim(o)}catch(r){if(r.name!=="SyntaxError")throw r}return(t||JSON.stringify)(o)}var Oe={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:sa(),transformRequest:[function(e,t){return Bi(t,"Accept"),Bi(t,"Content-Type"),y.isFormData(e)||y.isArrayBuffer(e)||y.isBuffer(e)||y.isStream(e)||y.isFile(e)||y.isBlob(e)?e:y.isArrayBufferView(e)?e.buffer:y.isURLSearchParams(e)?(Ni(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):y.isObject(e)||t&&t["Content-Type"]==="application/json"?(Ni(t,"application/json"),na(e)):e}],transformResponse:[function(e){var t=this.transitional||Oe.transitional,r=t&&t.silentJSONParsing,i=t&&t.forcedJSONParsing,a=!r&&this.responseType==="json";if(a||i&&y.isString(e)&&e.length)try{return JSON.parse(e)}catch(s){if(a)throw s.name==="SyntaxError"?oa(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, */*"}}};y.forEach(["delete","get","head"],function(e){Oe.headers[e]={}});y.forEach(["post","put","patch"],function(e){Oe.headers[e]=y.merge(aa)});Li.exports=Oe});var Di=h((Ga,Vi)=>{"use strict";var la=M(),pa=fe();Vi.exports=function(e,t,r){var i=this||pa;return la.forEach(r,function(s){e=s.call(i,e,t)}),e}});var kr=h((Ha,Ui)=>{"use strict";Ui.exports=function(e){return!!(e&&e.__CANCEL__)}});var Hi=h((ka,Gi)=>{"use strict";var $i=M(),qr=Di(),ca=kr(),ma=fe(),ua=he();function jr(o){if(o.cancelToken&&o.cancelToken.throwIfRequested(),o.signal&&o.signal.aborted)throw new ua("canceled")}Gi.exports=function(e){jr(e),e.headers=e.headers||{},e.data=qr.call(e,e.data,e.headers,e.transformRequest),e.headers=$i.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),$i.forEach(["delete","get","head","post","put","patch","common"],function(i){delete e.headers[i]});var t=e.adapter||ma.adapter;return t(e).then(function(i){return jr(e),i.data=qr.call(e,i.data,i.headers,e.transformResponse),i},function(i){return ca(i)||(jr(e),i&&i.response&&(i.response.data=qr.call(e,i.response.data,i.response.headers,e.transformResponse))),Promise.reject(i)})}});var Kr=h((qa,ki)=>{"use strict";var I=M();ki.exports=function(e,t){t=t||{};var r={};function i(l,u){return I.isPlainObject(l)&&I.isPlainObject(u)?I.merge(l,u):I.isPlainObject(u)?I.merge({},u):I.isArray(u)?u.slice():u}function a(l){if(I.isUndefined(t[l])){if(!I.isUndefined(e[l]))return i(void 0,e[l])}else return i(e[l],t[l])}function s(l){if(!I.isUndefined(t[l]))return i(void 0,t[l])}function n(l){if(I.isUndefined(t[l])){if(!I.isUndefined(e[l]))return i(void 0,e[l])}else return i(void 0,t[l])}function p(l){if(l in t)return i(e[l],t[l]);if(l in e)return i(void 0,e[l])}var m={url:s,method:s,data:s,baseURL:n,transformRequest:n,transformResponse:n,paramsSerializer:n,timeout:n,timeoutMessage:n,withCredentials:n,adapter:n,responseType:n,xsrfCookieName:n,xsrfHeaderName:n,onUploadProgress:n,onDownloadProgress:n,decompress:n,maxContentLength:n,maxBodyLength:n,transport:n,httpAgent:n,httpsAgent:n,cancelToken:n,socketPath:n,responseEncoding:n,validateStatus:p};return I.forEach(Object.keys(e).concat(Object.keys(t)),function(u){var w=m[u]||a,ue=w(u);I.isUndefined(ue)&&w!==p||(r[u]=ue)}),r}});var Yr=h((ja,qi)=>{qi.exports={version:"0.24.0"}});var Yi=h((Ka,Ki)=>{"use strict";var da=Yr().version,Xr={};["object","boolean","number","function","string","symbol"].forEach(function(o,e){Xr[o]=function(r){return typeof r===o||"a"+(e<1?"n ":" ")+o}});var ji={};Xr.transitional=function(e,t,r){function i(a,s){return"[Axios v"+da+"] Transitional option '"+a+"'"+s+(r?". "+r:"")}return function(a,s,n){if(e===!1)throw new Error(i(s," has been removed"+(t?" in "+t:"")));return t&&!ji[s]&&(ji[s]=!0,console.warn(i(s," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(a,s,n):!0}};function ha(o,e,t){if(typeof o!="object")throw new TypeError("options must be an object");for(var r=Object.keys(o),i=r.length;i-- >0;){var a=r[i],s=e[a];if(s){var n=o[a],p=n===void 0||s(n,a,o);if(p!==!0)throw new TypeError("option "+a+" must be "+p);continue}if(t!==!0)throw Error("Unknown option "+a)}}Ki.exports={assertOptions:ha,validators:Xr}});var Zi=h((Ya,Qi)=>{"use strict";var Xi=M(),fa=Lr(),Wi=ui(),Ji=Hi(),xe=Kr(),zi=Yi(),j=zi.validators;function ye(o){this.defaults=o,this.interceptors={request:new Wi,response:new Wi}}ye.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=xe(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&&zi.assertOptions(t,{silentJSONParsing:j.transitional(j.boolean),forcedJSONParsing:j.transitional(j.boolean),clarifyTimeoutError:j.transitional(j.boolean)},!1);var r=[],i=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(e)===!1||(i=i&&w.synchronous,r.unshift(w.fulfilled,w.rejected))});var a=[];this.interceptors.response.forEach(function(w){a.push(w.fulfilled,w.rejected)});var s;if(!i){var n=[Ji,void 0];for(Array.prototype.unshift.apply(n,r),n=n.concat(a),s=Promise.resolve(e);n.length;)s=s.then(n.shift(),n.shift());return s}for(var p=e;r.length;){var m=r.shift(),l=r.shift();try{p=m(p)}catch(u){l(u);break}}try{s=Ji(p)}catch(u){return Promise.reject(u)}for(;a.length;)s=s.then(a.shift(),a.shift());return s};ye.prototype.getUri=function(e){return e=xe(this.defaults,e),fa(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};Xi.forEach(["delete","get","head","options"],function(e){ye.prototype[e]=function(t,r){return this.request(xe(r||{},{method:e,url:t,data:(r||{}).data}))}});Xi.forEach(["post","put","patch"],function(e){ye.prototype[e]=function(t,r,i){return this.request(xe(i||{},{method:e,url:t,data:r}))}});Qi.exports=ye});var to=h((Xa,eo)=>{"use strict";var ya=he();function K(o){if(typeof o!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(i){e=i});var t=this;this.promise.then(function(r){if(!!t._listeners){var i,a=t._listeners.length;for(i=0;i<a;i++)t._listeners[i](r);t._listeners=null}}),this.promise.then=function(r){var i,a=new Promise(function(s){t.subscribe(s),i=s}).then(r);return a.cancel=function(){t.unsubscribe(i)},a},o(function(i){t.reason||(t.reason=new ya(i),e(t.reason))})}K.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};K.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};K.prototype.unsubscribe=function(e){if(!!this._listeners){var t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}};K.source=function(){var e,t=new K(function(i){e=i});return{token:t,cancel:e}};eo.exports=K});var io=h((Wa,ro)=>{"use strict";ro.exports=function(e){return function(r){return e.apply(null,r)}}});var ao=h((Ja,oo)=>{"use strict";oo.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var lo=h((za,Wr)=>{"use strict";var so=M(),ga=Or(),Ae=Zi(),wa=Kr(),Ma=fe();function no(o){var e=new Ae(o),t=ga(Ae.prototype.request,e);return so.extend(t,Ae.prototype,e),so.extend(t,e),t.create=function(i){return no(wa(o,i))},t}var T=no(Ma);T.Axios=Ae;T.Cancel=he();T.CancelToken=to();T.isCancel=kr();T.VERSION=Yr().version;T.all=function(e){return Promise.all(e)};T.spread=io();T.isAxiosError=ao();Wr.exports=T;Wr.exports.default=T});var Y=h((Qa,po)=>{po.exports=lo()});var zr=de(Y());var Jr=o=>{let e=[],t=0;return o.forEach(r=>{e[t]?e[t].length<249?e[t].push(r):(t=t+1,e[t]=[r]):e[t]=[r]}),e},Be=o=>{let e=[],t=200;for(;o.length>t-1;){let r=o.splice(0,t-1);e.push(r)}return e.push(o),e},E=(o,e)=>{let t="";return o==="prod"||o==="sandbox"?t={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"}[e]:t={profile:"http://localhost:8010",football:"http://locahost:8080",idMapping:"http://localhost:8030",predictor:"http://localhost:8040",client:"http://localhost:8080"}[e],t};var Ne=class{id=null;name=null;avatar=null;gender=null;country=null;birthDate=null;interests=[]};var Le=class{profilesFromResponse=e=>e?e.map(t=>this.fullProfileFromResponse(t)):null;fullProfileFromResponse=e=>{let t=new Ne;return t.avatar=e.avatar,t.birthDate=e.birth_date,t.country=e.country,t.gender=e.gender,t.id=e.id,t.interests=e.interests,t.name=e.name,t};profileToRequest=e=>({country_id:e.country?e.country.id:null,gender:e.gender,birth_date:e.birthDate,interests:e.interests,name:e.name})};var Ve=class{avatar=null;followingId=null;name=null;profileId=null};var De=class{followingFromResponse=e=>e.map(t=>this.remapResponse(t));remapResponse=e=>{let t=new Ve;return t.avatar=e.avatar,t.followingId=e.following_id,t.name=e.name,t.profileId=e.profile_id,t}};var Ue=class{avatar=null;followerId=null;name=null;profileId=null};var $e=class{followersFromResponse=e=>e.map(t=>this.remapResponse(t));remapResponse=e=>{let t=new Ue;return t.avatar=e.avatar,t.followerId=e.follower_id,t.name=e.name,t.profileId=e.profile_id,t}};var ge=class{profile_ids=[]};var ba="/countries",S="/profile",co="/profiles",Ge=class{instanceAuth=null;instance=null;apiSignInUrl=null;profileRemapper=null;followingRemapper=null;followersRemapper=null;constructor(e){let t=E(e.environment,"profile");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}&lang=${e.lang}`,this.instanceAuth=zr.default.create({baseURL:t,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instance=zr.default.create({baseURL:t,headers:{"Content-Type":"application/json"}}),this.profileRemapper=new Le,this.followingRemapper=new De,this.followersRemapper=new $e}getCountries=async()=>{try{return(await this.instance.get(`${ba}${this.apiSignInUrl}`)).data.data}catch(e){throw console.warn("There was a problem fetching the countries:",e),e.response}};getProfile=async e=>{let t=`${S}${this.apiSignInUrl}`;if(e){t=`${co}/${e}${this.apiSignInUrl}`;try{let r=await this.instance.get(t);return this.profileRemapper.fullProfileFromResponse(r.data.data)}catch(r){throw console.warn(`There was a problem fetching the following profile: ${e}`,r),r.response}}else try{let r=await this.instanceAuth.get(t);return this.profileRemapper.fullProfileFromResponse(r.data.data)}catch(r){throw console.warn(`There was a problem fetching the following profile: ${e}`,r),r.response}};getProfiles=async e=>{try{let t=await this.instance.get(`${co}${this.apiSignInUrl}&profile_ids=${e.join(",")}`);return this.profileRemapper.profilesFromResponse(t.data.data)}catch(t){throw console.warn(`There was a problem fetching the following profiles: ${e.join(",")}`,t),t.response}};getFollowers=async(e,t)=>{let r=`${S}/followers${this.apiSignInUrl}`;if(e&&!t){r=`${S}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let i=await this.instanceAuth.get(r);return this.followersRemapper.followersFromResponse(i.data.data)}catch(i){throw console.warn("There was a problem fetching the followers for own profile",i),i.response}}else if(!e&&!t)try{let i=await this.instanceAuth.get(r);return this.followersRemapper.followersFromResponse(i.data.data)}catch(i){throw console.warn("There was a problem fetching the followers for own profile",i),i.response}e&&t?r=`${S}/${t}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(r=`${S}/${t}/followers${this.apiSignInUrl}`);try{let i=await this.instance.get(r);return this.followersRemapper.followersFromResponse(i.data.data)}catch(i){throw console.warn(`There was a problem fetching the followers for profile: ${t}`,i),i.response}};getFollowing=async(e,t)=>{let r=`${S}/following${this.apiSignInUrl}`;if(e&&!t){r=`${S}/following${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let i=await this.instanceAuth.get(r);return this.followingRemapper.followingFromResponse(i.data.data)}catch(i){throw console.warn("There was a problem fetching the followers of own profile",i),i.response}}else if(!e&&!t)try{let i=await this.instanceAuth.get(r);return this.followingRemapper.followingFromResponse(i.data.data)}catch(i){throw console.warn("There was a problem fetching the followers of own profile",i),i.response}e&&t?r=`${S}/${t}/following${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(r=`${S}/${t}/following${this.apiSignInUrl}`);try{let i=await this.instance.get(r);return this.followingRemapper.followingFromResponse(i.data.data)}catch(i){throw console.warn(`There was a problem fetching the followers of the following profile: ${t}`,i),i.response}};follow=async e=>{let t=new ge;t.profile_ids=e;try{let r=await this.instanceAuth.post(`${S}/follow${this.apiSignInUrl}`,JSON.stringify(t));return this.followingRemapper.followingFromResponse(r.data.data)}catch(r){throw console.warn(`There was a problem with POST request for profiles: ${e.join(",")} `,r),r.response}};unfollow=async e=>{let t=new ge;t.profile_ids=e;try{return await this.instanceAuth.delete(`${S}/follow${this.apiSignInUrl}`,{data:JSON.stringify(t)}),!0}catch(r){throw console.warn(`There was a problem with DELETE request for profiles: ${e.join(",")} `,r),r.response}};updateProfile=async e=>{try{let t=this.profileRemapper.profileToRequest(e),r=await this.instanceAuth.patch(`${S}${this.apiSignInUrl}`,t);return this.profileRemapper.fullProfileFromResponse(r.data.data)}catch(t){throw console.warn("There was a problem updating the own profile:",t),t.response}}};var x={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id"};var mo="FansUnited",uo={football:{ids:[],countries:[],competitions:[]},profile:{own:{},countries:[],expireAt:0}},A=class{idSchema="";exparationTimeout=600;constructor(e){this.idSchema=e.idSchema,(this.getData()===void 0||this.getData()===null)&&this.setData(uo)}clearData=()=>{this.setData(uo)};getEntityById=(e="",t="")=>this.getData().football.ids.find(r=>{let i=x[this.idSchema];return r&&`${r[i]}`===t&&r.resource===e});getEntity=(e,t,r)=>Array.isArray(e)?this.getData().football.ids.filter(i=>{let a=x[r];return i&&e.includes(`${i[a]}`)&&i.resource===t}):this.getData().football.ids.find(i=>{let a=x[r];return i&&`${i[a]}`===e&&i.resource===t});getEntityByNativeId=(e="",t="")=>this.getData().football.ids.find(r=>r&&`${r.id}`===t&&r.resource===e);checkForExistingIdObjs=(e,t)=>{let r=x[t],i={};return Object.keys(e).forEach(a=>{let s=e[a],p=this.getEntity(s,a,t).map(l=>l[r]),m=e[a].filter(l=>!p.includes(l));i[a]=s.map(l=>m.includes(l)?{id:l,exists:!1}:{id:l,exists:!0})}),i};getIdsByType=(e,t,r)=>{let i=x[r],a=x[t],s={};return Object.keys(e).forEach(n=>{let p=e[n],m=[];this.getData().football.ids.forEach(l=>{p.forEach((u,w)=>{u===l[a]&&n===l.resource&&(m[w]=l[i])})}),s[n]=m}),s};addIdMapping=e=>{let t=this.getData();t.football.ids.push(e),this.setData(t)};addIdMappings=e=>{let t=this.getData(),r=t.football.ids;r=[...r,...e],t.football.ids=r,this.setData(t)};setOwnProfile=e=>{let t=this.getData();t.profile.own=e,t.profile.expireAt=Math.floor(Date.now()/1e3)+this.exparationTimeout,this.setData(t)};getOwnProfile=()=>this.getData().profile.own;getProfileCountries=()=>this.getData().profile.countries;setProfileCountries=e=>{let t=this.getData();t.profile.countries=e,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();t.football.competitions.push(...e),this.setData(t)};getExparationProfile=()=>this.getData().profile.expireAt;getData=()=>JSON.parse(localStorage.getItem(mo));setData=e=>{localStorage.setItem(mo,JSON.stringify(e))}};var ho=de(Y());var we={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},He=class{instance=null;apiSignInUrl="";constructor(e){let t=E(e.environment,"idMapping");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instance=ho.default.create({baseURL:t})}getEntityById=(e,t)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${config.idSchema}&${we[e]}=${t}`)}catch(r){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,r),r.response}};getEntityByIdAndSchema=(e,t,r)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${we[e]}=${t}`)}catch(i){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,i),i.response}};getEntityIdsByIdsAndSchema=(e,t,r)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${we[e]}=${t.join(",")}`)}catch(i){throw console.warn(`There was a problem with id mapping request for the following ids:${t.join(",")}`,i),i.response}};getEntitiesByIds=(e,t,r)=>{t.sort((s,n)=>s.localeCompare(n));let a=Jr(t).map(s=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${we[e]}=${s.join(",")}`)}catch(n){throw console.warn(`There was a problem with id mapping request for the following ids:${s.join(",")}`,n),n.response}});return Promise.all(a).then(s=>{let n=[];return s.forEach(p=>{n.push(...p.data.data)}),n})};getEntitiesByIdObjs=async(e,t)=>{let r="";if(Object.keys(e).forEach(i=>{if(e[i].length>0){let a=e[i].filter((n,p,m)=>p===m.indexOf(n));Jr(a).map(n=>{n.sort((p,m)=>p.localeCompare(m)),r+="&",r+=`${we[i]}=${n.join(",")}`})}}),r&&r.length>0)try{return(await this.instance.get(`/football${this.apiSignInUrl}&input_provider=${t||"native"}${r}`)).data.data}catch(i){throw console.warn("There was a problem with id mapping request",i),i.response}else return[]}};var ke=class{isBrowser=!1;localStorage=null;https=null;constructor(e){this.isBrowser=typeof window!="undefined",this.localStorage=new A(e),this.https=new He(e)}getEntitiesByIds=async(e,t,r)=>{if(this.isBrowser)try{let i=this.localStorage.checkForExistingIdObjs(e,t),a=this.splitForRequestAndExisting(i),s=await this.https.getEntitiesByIdObjs(a.request,t);return this.localStorage.addIdMappings(s),this.localStorage.getIdsByType(e,t,r)}catch(i){return console.warn("There was a problem retrieving the entity ids ",i),Promise.resolve([])}else try{let i=await this.https.getEntitiesByIdObjs(e,t);return Object.keys(e).forEach(a=>{e[a]=i.filter(s=>s.resource===a).map(s=>s[x[r]])}),e}catch(i){return console.warn("There was a problem retrieving the entity ids ",i),Promise.resolve([])}};getEntityById=async(e,t,r)=>{if(this.isBrowser){let i=this.localStorage.getEntity(e,t,r);if(i)return i;{let a=await this.requestEntity(e,t,r);return this.localStorage.addIdMappings(a),a}}else return await this.requestEntity(e,t,r)};splitForRequestAndExisting=e=>{let t={},r={};return Object.keys(e).forEach(i=>{t[i]=e[i].filter(a=>!a.exists).map(a=>a.id),r[i]=e[i].filter(a=>a.exists).map(a=>a.id)}),{existing:r,request:t}};requestEntity=async(e,t,r)=>{try{return e=Array.isArray(e)?e:[e],await this.https.getEntitiesByIds(t,e,r)}catch(i){return console.warn(`There was a problem retrieving the requested entity: ${i}`),null}}};var qe=o=>{switch(o){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 o}};var je=class{extractedObjIds={};traverse=(e,t)=>(t=qe(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(r=>{this.traverseObjExtract(r,t)})};traverseObjExtract=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(r=>{let i=e[r];r==="id"||r==="teamId"?(this.extractedObjIds.hasOwnProperty(t)||(this.extractedObjIds[t]=[]),this.extractedObjIds[t].push(i)):e[r]&&this.traverse(e[r],r)})}};var Ke=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(e,t,r)=>(t=qe(t),this.replaceObjIdsIndex===null&&(this.initReplaceObjIdsIndex(r),this.remappedIdsObj=r),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(r=>{this.traverseObjReplace(r,t)})};traverseObjReplace=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(r=>{r==="id"||r==="teamId"?(e[r]=this.remappedIdsObj[t][this.replaceObjIdsIndex[t]],this.replaceObjIdsIndex[t]=this.replaceObjIdsIndex[t]+1):e[r]&&this.traverse(e[r],r,this.remappedIdsObj)})}};var _=class{idSchema="";idMappingFacade=null;constructor(e){this.idSchema=e.idSchema,this.idMappingFacade=new ke(e)}getEntityIdBySchemaId=(e,t)=>this.idMappingFacade.getEntityById(e,t,this.idSchema);remapEntities=async(e,t)=>{let r=JSON.parse(JSON.stringify(e));try{if(this.idSchema!=="native"){let a=new je().traverse(r,t);return this.idMappingFacade.getEntitiesByIds(a,"native",this.idSchema).then(s=>new Ke().traverse(r,t,s))}else return e}catch(i){return console.warn(`There was a problem remapping entity: ${t} with inner entity `,i),[]}};getEntityIdsBySchemaId=async(e,t,r)=>{let i={};return i[t]=e,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(i,this.idSchema,r):i}};var R=class{completed=!1;percentage;constructor(e){this.percentage=e}};var Ye=class{teamFollowed=new R(10);teamFavourite=new R(15);playerFollowed=new R(10);playerFavourite=new R(10);competitionFollowed=new R(10);competitionFavourite=new R(5);addedBirthdate=new R(10);addedGender=new R(10);addedCountry=new R(10);addedAvatar=new R(10)};var Xe=class{totalPercentage;breakdown=new Ye};var be=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 B=class{isBrowser=!1;localStorage={};https=null;constructor(e,t){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.https=t}getOwn=async()=>{if(this.isBrowser){let e=Math.floor(Date.now()/1e3),t=this.localStorage.getExparationProfile(),r=null;if(t>e&&(r=this.localStorage.getOwnProfile()),r)return r;try{let i=await this.https.getProfile();return this.localStorage.setOwnProfile(i),i}catch(i){throw console.warn("There was a problem retrieving your profile: ",i),i}}else try{return await this.https.getProfile()}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};getByIds=async e=>{try{return await this.https.getProfiles(e)}catch(t){throw console.warn(`There was a problem retrieving the selected profiles: ${e.join(",")} `,t),t}};getById=async e=>{try{return await this.https.getProfile(e)}catch(t){throw console.warn(`There was a problem retrieving the selected profile: ${e} `,t),t}};getCountries=async()=>{if(this.isBrowser){let e=this.localStorage.getProfileCountries();if(e&&e.length>0)return e;try{let t=await this.https.getCountries();return this.localStorage.setProfileCountries(t),t}catch(t){throw console.warn("There was a problem retrieving profile countries: ",t),t}}else try{return await this.https.getCountries()}catch(e){throw console.warn("There was a problem retrieving profile countries: ",e),e}};getFollowers=async(e,t)=>{try{return e&&(e=new be(e)),await this.https.getFollowers(e,t)}catch(r){throw console.warn("There was a problem retrieving your followers: ",r),r}};getFollowing=async(e,t)=>{try{return e&&(e=new be(e)),await this.https.getFollowing(e,t)}catch(r){throw console.warn("There was a problem retrieving your following profiles: ",r),r}};follow=async e=>{try{return await this.https.follow(e)}catch(t){throw console.warn(`There was a problem following profiles: ${e.join(",")} `,t),t}};unfollow=async e=>{try{return await this.https.unfollow(e)}catch(t){throw console.warn(`There was a problem unfollowing profiles: ${e.join(",")} `,t),t}};showFullnessProfile=e=>{let t=new Xe,r=0;return e.avatar&&(t.breakdown.addedAvatar.completed=!0,r+=t.breakdown.addedAvatar.percentage),e.birthDate&&(t.breakdown.addedBirthdate.completed=!0,r+=t.breakdown.addedBirthdate.percentage),e.country&&(t.breakdown.addedCountry.completed=!0,r+=t.breakdown.addedCountry.percentage),e.gender&&(t.breakdown.addedGender.completed=!0,r+=t.breakdown.addedGender.percentage),e.interests&&e.interests.length>0&&(e.interests.find(l=>l.type==="team"&&l.favourite)&&(t.breakdown.teamFavourite.completed=!0,r+=t.breakdown.teamFavourite.percentage),e.interests.find(l=>l.type==="team")&&(t.breakdown.teamFollowed.completed=!0,r+=t.breakdown.teamFollowed.percentage),e.interests.find(l=>l.type==="player"&&l.favourite)&&(t.breakdown.playerFavourite.completed=!0,r+=t.breakdown.playerFavourite.percentage),e.interests.find(l=>l.type==="player")&&(t.breakdown.playerFollowed.completed=!0,r+=t.breakdown.playerFollowed.percentage),e.interests.find(l=>l.type==="competition"&&l.favourite)&&(t.breakdown.competitionFavourite.completed=!0,r+=t.breakdown.competitionFavourite.percentage),e.interests.find(l=>l.type==="competition")&&(t.breakdown.competitionFollowed.completed=!0,r+=t.breakdown.competitionFollowed.percentage)),t.totalPercentage=r,t}};var We=class{id=null;name=null;assets=null};var Je=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,r){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=r,this.https=t}getCountriesWithIdMapping=async()=>{try{let e=await this.getCountries();return this.idMapping.remapEntities(e,"country")}catch(e){throw console.warn("There was a problem browsing countries as football entities",e),e}};getCountries=async()=>{if(this.isBrowser){let e=this.localStorage.getFootballCountries();if(e&&e.length>0)return e;try{let t=await this.https.getCountries();return this.localStorage.setFootballCountries(t),t}catch(t){throw console.warn("There was a problem retrieving countries as football entities",t),t}}else return this.https.getCountries()}};var ze=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(r=>{let i=!0;return t.forEach(a=>{a!=="sortOrder"&&a!=="sortField"&&(a==="countryId"?i&&=r.country.id===this[a]:a==="name"?i&&=r.name.toLocaleLowerCase().includes(this[a].toLocaleLowerCase()):a==="competitionIds"?i&&=this[a].some(s=>r.id===s):i&&=r[a].toLocaleLowerCase()===this[a].toLocaleLowerCase())}),i})};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((r,i)=>this.sortOrder&&this.sortOrder==="desc"?i.name.localeCompare(r.name):r.name.localeCompare(i.name)):this.sortField==="countryId"?t=e.sort((r,i)=>this.sortOrder&&this.sortOrder==="desc"?i.country.id.localeCompare(r.country.id):r.country.id.localeCompare(i.country.id)):this.sortField==="scope"?e.forEach(r=>t[this.competitionIds.indexOf(r.id)]=r):!this.sortField&&this.sortOrder==="desc"&&(t=e.sort((r,i)=>i.id.localeCompare(r.id))),t}};var Qe=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,r){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=r,this.https=t}getCompetitionsIdMapping=async e=>{try{let t=!1;if(e){if(e=new ze(e),e.countryId){let i=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");i.country.length===0&&(t=!0),e.countryId=i.country[0]}if(e.competitionIds){let i=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");i.competition.length===0&&(t=!0),e.competitionIds=i.competition}if(t)return[]}let r=await this.getCompetitions(e);return await this.idMapping.remapEntities(r,"competition")}catch(t){throw console.warn("There was a problem browsing all of the competitions",t),t}};getCompetitions=async e=>{if(this.isBrowser){let t=this.localStorage.getCompetitions(e);if(t&&t.length>0)return t;try{let r=await this.https.getCompetitions(e);return this.localStorage.setCompetitions(r),this.localStorage.getCompetitions(e)}catch(r){throw console.warn("There was a problem retrieving all competitions",r),r}}else return this.https.getCompetitions(e)};getCompetitionByIdIdMapping=async e=>{try{let r=(await this.idMapping.getEntityIdsBySchemaId([e],"competition","native")).competition[0],i=await this.getCompetitionById(r);return await this.idMapping.remapEntities(i,"competition")}catch(t){throw console.warn(`There was a problem browsing the following competition:${e}`,t),t}};getCompetitionById=async e=>{try{return await this.https.getCompetitionById(e)}catch(t){throw console.warn(`There was a problem retrieving the competition with the following id: ${e}`,t),t}};getTopCompetitionsIdMapping=async()=>{try{let e=await this.getTopCompetitions();return await this.idMapping.remapEntities(e,"competition")}catch(e){throw console.warn("There was a problem browsing the top competitions",e),e}};getTopCompetitions=async()=>{try{return await this.https.getTopCompetitions()}catch(e){throw console.warn("There was a problem retrieving the top competitions",e),e}}};var Ze=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 et=class{https=null;idMapping=null;constructor(e,t){this.idMapping=t,this.https=e}getTeamsIdMapping=async e=>{try{let t=!1;if(e){if(e=new Ze(e),e.countryId){let i=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");i.country.length===0&&(t=!0),e.countryId=i.country[0]}if(e.scope){let i=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");i.competition.length===0&&(t=!0),e.scope=i.competition}if(e.teamIds){let i=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");i.team.length===0&&(t=!0),e.teamIds=i.team}}if(t)return[];let r=await this.getTeams(e);return await this.idMapping.remapEntities(r,"team")}catch(t){throw console.warn("There was a problem browsing all teams",t),t}};getTeams=async e=>{try{return await this.https.getTeams(e)}catch(t){throw console.warn("There was a problem retrieving all teams",t),t}};getTeamByIdIdMapping=async e=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let r=await this.getTeamById(e);return await this.idMapping.remapEntities(r,"team")}catch(t){throw console.warn(`There was a problem browsing the following team:${e}`,t),t}};getTeamById=async e=>{try{return await this.https.getTeamById(e)}catch(t){throw console.warn(`There was a problem retrieving the following team: ${e}`,t),t}};getTopTeamsIdMapping=async()=>{try{let e=await this.getTopTeams();return await this.idMapping.remapEntities(e,"team")}catch(e){throw console.warn("There was a problem browsing the top teams",e),e}};getTopTeams=async()=>{try{return await this.https.getTopTeams()}catch(e){throw console.warn("There was a problem retrieving the top teams",e),e}};getNextMatchForTeamIdMapping=async e=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let r=await this.getNextMatchForTeam(e);return await this.idMapping.remapEntities(r,"match")}catch(t){throw console.warn(`There was a problem browsing the next match for the following team:${e}`,t),t}};getNextMatchForTeam=async e=>{try{return await this.https.getNextMatchForTeam(e)}catch(t){throw console.warn(`There was a problem retrieving the next match for the following team: ${e}`,t),t}};getPrevMatchForTeamIdMapping=async e=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let r=await this.getPrevMatchForTeam(e);return await this.idMapping.remapEntities(r,"match")}catch(t){throw console.warn(`There was a problem browsing the previous match for the following team:${e}`,t),t}};getPrevMatchForTeam=async e=>{try{return await this.https.getPrevMatchForTeam(e)}catch(t){throw console.warn(`There was a problem retrieving the previous match for the following team: ${e}`,t),t}}};var Ie=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 X=class{https=null;idMapping=null;constructor(e,t){this.idMapping=t,this.https=e}getPlayersIdMapping=async e=>{try{let t=!1;if(e){if(e=new Ie(e),e.countryId){let i=await this.idMapping.getEntityIdsBySchemaId([e.countryId],"country","native");i.country.length===0&&(t=!0),e.countryId=i.country[0]}if(e.playerIds){let i=await this.idMapping.getEntityIdsBySchemaId(e.playerIds,"player","native");i.player.length===0&&(t=!0),e.playerIds=i.player}if(e.scope){let i=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");i.competition.length===0&&(t=!0),e.scope=i.competition}if(t)return[]}let r=await this.getPlayers(e);return await this.idMapping.remapEntities(r,"player")}catch(t){throw console.warn("There was a problem browsing the players",t),t}};getPlayersWithNativeIds=async e=>{let t=new Ie({playerIds:e}),r=await this.getPlayers(t);return await this.idMapping.remapEntities(r,"player")};getPlayersMapWithNativeIds=async e=>{let t=await this.getPlayersWithNativeIds(e),r={};if(e.length===t.length)e.forEach((i,a)=>r[i]=t[a]);else throw new Error("API did not find a player response for some of the player ids");return r};getPlayers=async e=>{try{return await this.https.getPlayers(e)}catch(t){throw console.warn("There was a problem retrieving the players",t),t}};getPlayerIdMapping=async e=>{try{let t=await this.idMapping.getEntityIdsBySchemaId([e],"player","native"),r=await this.getPlayerById(t.player[0]);return await this.idMapping.remapEntities(r,"player")}catch(t){throw console.warn(`There was a problem browsing the following player:${e}`,t),t}};getPlayerById=async e=>{try{return await this.https.getPlayerById(e)}catch(t){throw console.warn(`There was a problem retrieving the following player: ${e}`,t),t}};getTopPlayersIdMapping=async()=>{try{let e=await this.getTopPlayers();return await this.idMapping.remapEntities(e,"player")}catch(e){throw console.warn("There was a problem browsing the top players",e),e}};getTopPlayers=async()=>{try{return await this.https.getTopPlayers()}catch(e){throw console.warn("There was a problem retrieving the top players",e),e}};getNextMatchForPlayerIdMapping=async e=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let r=await this.getNextMatchForPlayer(e);return await this.idMapping.remapEntities(r,"match")}catch(t){throw console.warn(`There was a problem browsing the next match for player:${e}`,t),t}};getNextMatchForPlayer=async e=>{try{return await this.https.getNextMatchForPlayer(e)}catch(t){throw console.warn(`There was a problem retrieving the next match for player: ${e}`,t),t}};getPrevMatchForPlayerIdMapping=async e=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let r=await this.getPrevMatchForPlayer(e);return await this.idMapping.remapEntities(r,"match")}catch(t){throw console.warn(`There was a problem browsing the previous match for player:${e}`,t),t}};getPrevMatchForPlayer=async e=>{try{return await this.https.getPrevMatchForPlayer(e)}catch(t){throw console.warn(`There was a problem retrieving the previous match for player: ${e}`,t),t}}};var Re=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 N=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}getMatchesIdMapping=async e=>{try{if(e){if(e=new Re(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 t=await this.getMatches(e);return await this.idMapping.remapEntities(t,"match")}catch(t){throw console.warn("There was a problem browsing the matches",t),t}};getMatchesWithNativeIds=async e=>{let t=new Re({matchIds:e}),r=await this.getMatches(t);return await this.idMapping.remapEntities(r,"match")};getMatches=async e=>{try{return await this.https.getMatches(e)}catch(t){throw console.warn("There was a problem retrieving the matches",t),t}};getMatchIdMapping=async e=>{try{let t=await this.idMapping.getEntityIdsBySchemaId([e],"match","native"),r=await this.getMatchById(t.match[0]);return await this.idMapping.remapEntities(r,"match")}catch(t){throw console.warn(`There was a problem browsing the following match: ${e}`,t),t}};getMatchById=async e=>{try{return await this.https.getMatchById(e)}catch(t){throw console.warn(`There was a problem retrieving the following match: ${e}`,t),t}}};var tt=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 rt=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}searchIdMapping=async e=>{try{if(e=new tt(e),e.scope){let r=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");e.scope=r.competition}let t=await this.search(e);if(t.teams&&t.teams.length>0){let r=await this.idMapping.remapEntities(t.teams,"team");t.teams=r}if(t.players&&t.players.length>0){let r=await this.idMapping.remapEntities(t.players,"player");t.players=r}if(t.competitions&&t.competitions.length>0){let r=await this.idMapping.remapEntities(t.competitions,"competition");t.competitions=r}return t}catch(t){throw console.warn("There was a problem with browsing the search result",t),t}};search=async e=>{try{return await this.https.search(e)}catch(t){throw console.warn("There was a problem retrieving the search response",t),t}}};var L=class{isBrowser=!1;localStorage={};https=null;idMapping=null;countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(e,t,r){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=r,this.https=t,this.countriesFacade=new Je(e,t,r),this.competitionsFacade=new Qe(e,t,r),this.teamsFacade=new et(t,r),this.playerFacade=new X(t,r),this.matchFacade=new N(t,r),this.searchFacade=new rt(t,r)}getCountries=async()=>this.countriesFacade.getCountriesWithIdMapping();getCompetitions=async e=>this.competitionsFacade.getCompetitionsIdMapping(e);getCompetitionById=async e=>this.competitionsFacade.getCompetitionByIdIdMapping(e);getTopCompetitions=async()=>this.competitionsFacade.getTopCompetitionsIdMapping();getTeams=async e=>this.teamsFacade.getTeamsIdMapping(e);getTeamById=async e=>this.teamsFacade.getTeamByIdIdMapping(e);getTopTeams=async()=>this.teamsFacade.getTopTeamsIdMapping();getNextMatchForTeam=async e=>this.teamsFacade.getNextMatchForTeamIdMapping(e);getPrevMatchForTeam=async e=>this.teamsFacade.getPrevMatchForTeamIdMapping(e);getPlayers=async e=>this.playerFacade.getPlayersIdMapping(e);getPlayerById=async e=>this.playerFacade.getPlayerIdMapping(e);getTopPlayers=async()=>this.playerFacade.getTopPlayersIdMapping();getNextMatchForPlayer=async e=>this.playerFacade.getNextMatchForPlayerIdMapping(e);getPrevMatchForPlayer=async e=>this.playerFacade.getPrevMatchForPlayerIdMapping(e);getMatches=async e=>this.matchFacade.getMatchesIdMapping(e);getMatchById=async e=>this.matchFacade.getMatchIdMapping(e);search=async e=>this.searchFacade.searchIdMapping(e)};var W=class{idMapping=null;footballFacade=null;constructor(e,t){this.idMapping=e,this.footballFacade=t}remapInterestsToIdSchema=async e=>{let t=this.idMapping.idSchema;if(t!=="native")if(e.length>0){let r={},i={};e.forEach(n=>{r.hasOwnProperty(n.type)||(r[n.type]=[],i[n.type]=[]),r[n.type].push(n.id),i[n.type].push(n)});let a=await this.idMapping.idMappingFacade.getEntitiesByIds(r,"native",t),s=[];for(let[n,p]of Object.entries(i))p.forEach((m,l)=>{m.id=a[n][l],s.push(m)});return s}else return e;else return e};remapInterestToNative=async e=>{let t=this.idMapping.idSchema;if(t!=="native"){let r={},{id:i,type:a}=e;r[a]=[i];let s=await this.idMapping.idMappingFacade.getEntitiesByIds(r,t,"native");return e.id=s[a][0],e}return e};inquiryCustomInterests=async e=>{let t=[];if(e&&e.length>0&&(t=e.filter(r=>r.source==="custom")),t&&t.length>0){let r=e.filter(a=>a.source!=="custom"),i=await this.remapInterestsToIdSchema(r);return t.forEach(a=>i.push(a)),i}return await this.remapInterestsToIdSchema(e)};showFullInterests=async e=>{let t=[];if(e&&e.length>0)for(let r of e)if(r.source!=="custom"&&r.source==="football"){let i={};if(r.type==="team"){i.teamIds=[r.id];let a=await this.footballFacade.getTeams(i);r.model=a[0]}if(r.type==="player"){i.playerIds=[r.id];let a=await this.footballFacade.getPlayers(i);r.model=a[0]}if(r.type==="competition"){i.competitionIds=[r.id];let a=await this.footballFacade.getCompetitions(i);r.model=a[0]}r.model===void 0&&(r.model=null),t.push(r)}else t.push(r);return t}};var it=class{profileHttps=null;footballHttps=null;localStorage=null;idMapping=null;profileFacade=null;footballFacade=null;interestsService=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;constructor(e,t,r,i){this.localStorage=e,this.profileHttps=t,this.footballHttps=i,this.idMapping=r,this.footballFacade=new L(e,i,r),this.interestsService=new W(r,this.footballFacade),this.profileFacade=new B(e,t)}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;let t=await this.profileFacade.getOwn();return this.setOwnProfile(t),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=[];return t=e.interests,await this.interestsService.inquiryCustomInterests(t)};showFullInterests=async()=>{let e=await this.showInterests();return await this.interestsService.showFullInterests(e)};getFollowers=async e=>await this.profileFacade.getFollowers(e);getFollowing=async e=>await this.profileFacade.getFollowing(e);follow=async e=>await this.profileFacade.follow(e);unfollow=async e=>await this.profileFacade.unfollow(e);addInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;e.source!=="custom"?t=await this.interestsService.remapInterestToNative(e):t=e;let r=this.ownProfile.interests.filter(i=>i.id!==t.id||i.type!==t.type||i.source!==t.source);return this.ownProfile.interests=[...r],this.ownProfile.interests.push(t),this};addInterest=e=>(this.promises.push(this.addInterestPromise(e)),this);removeInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;return e.source!=="custom"?t=await this.interestsService.remapInterestToNative(e):t=e,this.ownProfile.interests=this.ownProfile.interests.filter(r=>r.id!==t.id||r.type!==t.type||r.source!==t.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);setCountryPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e&&!this.ownProfile.country?(this.ownProfile.country=new We,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)};update=async()=>{if(this.promises.length===0)return this.ownProfile;await Promise.all(this.promises);let e=await this.getOwnProfile(),t=await this.profileHttps.updateProfile(e);return this.modified=!1,this.expireAt=0,this.localStorage.setOwnProfile(t),delete t.interests,t}};var ot=class{profileHttps=null;footballFacade=null;localStorage=null;idMapping=null;profileFacade=null;interestsService=null;profileId="";constructor(e,t,r,i){this.localStorage=e,this.profileHttps=t,this.footballFacade=i,this.idMapping=r,this.interestsService=new W(r,i),this.profileFacade=new B(e,t)}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=[];return t=e.interests,await this.interestsService.inquiryCustomInterests(t)};showFullInterests=async()=>{let e=await this.showInterests();return await this.interestsService.showFullInterests(e)};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)}};var fo=de(Y());var at=class{id="";alias="";countryCode="";assets=null;name=""};var f=class{countriesFromResponse=e=>{if(e)return e.map(t=>this.countryFromResponse(t))};countryFromResponse=e=>{try{if(e){let t=new at;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 st=class{id="";country=null;gender="";assets=null;type="";name=""};var b=class{countryRemapper=null;constructor(){this.countryRemapper=new f}fromResponse(e){try{let t=new st;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 nt=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var lt=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName=""};var g=class{countryRemapper=null;constructor(){this.countryRemapper=new f}fromResponse(e){try{let t=new lt;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}catch(t){throw console.warn("There was a problem remapping teams response",t),t}}};var pt=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new f,this.teamBasicRemapper=new g}fromResponse(e){try{let t=new nt;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(r=>this.teamBasicRemapper.fromResponse(r)),t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var ct=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";squad=[]};var mt=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var ut=class{countryRemapper=null;constructor(){this.countryRemapper=new f}fromResponse(e){try{let t=new mt;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 dt=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new f,this.competitionRemapper=new b,this.playerRemapper=new ut}fromResponse(e){try{let t=new ct;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.competitions=e.competitions?e.competitions.map(r=>this.competitionRemapper.fromResponse(r)):[],t.squad=e.squad?e.squad.map(r=>this.playerRemapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping team response",t),t}}};var ht=class{id="";kickoffAt="";finishedAt="";updatedAt="";homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;context={competition:null};status={type:null,subType:null}};var ft=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var J=class{fromResponse(e){try{let t=new ft;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 yt=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new g,this.competitionRemapper=new b,this.scoresRemapper=new J}fromResponse(e){try{let t=new ht;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,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 gt=class{id="";kickoffAt="";finishedAt="";updatedAt="";homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;stats=null;context={competition:null};timeline=[];status={type:null,subType:null};lineups=null};var wt=class{corners=null;crosses=null;offside=null;shotsOn=null;throwIn=null;redCards=null;shotsOff=null;goalKicks=null;possession=null;treatments=null;yellowCards=null;shotsBlocked=null;substitutions=null;counterAttacks=null;foulsCommitted=null};var Mt=class{fromResponse(e){try{let t=new wt;return t.corners=this.statEntityFromResponse(e.corners),t.crosses=this.statEntityFromResponse(e.crosses),t.offside=this.statEntityFromResponse(e.offside),t.shotsOn=this.statEntityFromResponse(e.shots_on),t.throwIn=this.statEntityFromResponse(e.throw_in),t.redCards=this.statEntityFromResponse(e.red_cards),t.shotsOff=this.statEntityFromResponse(e.shots_off),t.goalKicks=this.statEntityFromResponse(e.goal_kicks),t.possession=this.statEntityFromResponse(e.possession),t.treatments=this.statEntityFromResponse(e.treatments),t.yellowCards=this.statEntityFromResponse(e.yellow_cards),t.shotsBlocked=this.statEntityFromResponse(e.shots_blocked),t.substitutions=this.statEntityFromResponse(e.substitutions),t.counterAttacks=this.statEntityFromResponse(e.counter_attacks),t.foulsCommitted=this.statEntityFromResponse(e.fouls_committed),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 z=class{homeTeam={players:[]};awayTeam={players:[]}};var bt=class{id="";name="";position="";shirtNumber;assets=null;type=""};var Q=class{fromResponse(e){try{let t=new bt;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 It=class{playerRemapper=null;constructor(){this.playerRemapper=new Q}fromResponse(e){try{let t=new z;return t.homeTeam.players=e.home_team&&e.home_team.players?e.home_team.players.map(r=>this.playerRemapper.fromResponse(r)):[],t.awayTeam.players=e.away_team&&e.away_team.players?e.away_team.players.map(r=>this.playerRemapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping the lineups",t),t}}};var Rt=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var Ft=class{playerRemapper=null;constructor(){this.playerRemapper=new Q}fromResponse(e){try{let t=new Rt;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 Pt=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new g,this.competitionsMapper=new b,this.lineupsMapper=new It,this.scoresMapper=new J,this.statsMapper=new Mt,this.timelineMapper=new Ft}fromResponse(e){try{let t=new gt;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,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(r=>this.timelineMapper.fromResponse(r)):[],t.status={type:e.status.type,subType:e.status.sub_type},t.lineups=e.lineups?this.lineupsMapper.fromResponse(e.lineups):new z,t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var St=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var vt=class{countryRemapper=null;constructor(){this.countryRemapper=new f}fromResponse(e){try{let t=new St;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 Ct=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;teams=[]};var Z=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new f,this.teamRemapper=new g}fromResponse(e){try{let t=new Ct;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(r=>this.teamRemapper.fromResponse(r)):[],t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping players response",t),t}}};var Tt=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;competitions=[];teams=[]};var Et=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new f,this.teamRemapper=new g,this.competitionRemapper=new b}fromResponse(e){try{let t=new Tt;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(r=>this.teamRemapper.fromResponse(r)):[],t.position=e.position,t.competitions=e.competitions?e.competitions.map(r=>this.competitionRemapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping player response",t),t}}};var _t=class{teams=null;players=null;competitions=null};var Ot=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new g,this.playerRemapper=new Z,this.competitionremapper=new b}fromResponse(e){try{let t=new _t;return t.teams=e.teams?e.teams.map(r=>this.teamRemapper.fromResponse(r)):[],t.players=e.players?e.players.map(r=>this.playerRemapper.fromResponse(r)):[],t.competitions=e.competitions?e.competitions.map(r=>this.competitionremapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping search response",t),t}}};var O=class{instance=null;apiSignInUrl="";idSchema="";limitIds=200;countryRemapper=null;competitionBasicRemapper=null;competitionFullRemapper=null;teamBasicRemapper=null;teamFullRemapper=null;matchBasicRemapper=null;matchFullRemapper=null;playerBasicRemapper=null;playerFullRemapper=null;topPlayerRemapper=null;searchRemapper=null;constructor(e){let t=E(e.environment,"football");this.apiSignInUrl=`?key=${e.apiKey}&lang=${e.lang}&client_id=${e.clientId}`,this.idSchema=e.idSchema,this.instance=fo.default.create({baseURL:t}),this.countryRemapper=new f,this.competitionBasicRemapper=new b,this.competitionFullRemapper=new pt,this.teamBasicRemapper=new g,this.teamFullRemapper=new dt,this.matchBasicRemapper=new yt,this.matchFullRemapper=new Pt,this.playerBasicRemapper=new Z,this.playerFullRemapper=new Et,this.topPlayerRemapper=new vt,this.searchRemapper=new Ot}getCountries=async()=>{try{let e=await this.instance.get(`/countries${this.apiSignInUrl}`);return this.countryRemapper.countriesFromResponse(e.data.data)}catch(e){throw console.warn("There was a problem with the football countries request",e),e}};getCompetitions=async e=>{try{let t={};if(e&&e.competitionIds&&e.competitionIds.length>this.limitIds-1){let r=[],i=Be(e.competitionIds);for(let s of i)e.competitionIds=s,t=await this.instance.get(`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`),r.push(t.data.data.map(n=>this.competitionBasicRemapper.fromResponse(n)));return Array.prototype.concat.apply([],r)}else return t=e?await this.instance.get(`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instance.get(`/competitions${this.apiSignInUrl}`),t.data.data.map(r=>this.competitionBasicRemapper.fromResponse(r))}catch(t){throw console.warn("There was a problem with getCompetitions request",t),t.response}};getCompetitionById=async e=>{try{let t=await this.instance.get(`/competitions/${e}${this.apiSignInUrl}`);return this.competitionFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getCompetitionById request",t),t.response}};getTopCompetitions=async()=>{try{return(await this.instance.get(`/competitions/top${this.apiSignInUrl}`)).data.data.map(t=>this.competitionBasicRemapper.fromResponse(t))}catch(e){throw console.warn("There was a problem with getTopCompetitions request",e),e.response}};getTeams=async e=>{try{let t={};if(e&&e.teamIds&&e.teamIds.length>this.limitIds-1){let r=[],i=Be(e.teamIds);for(let s of i)e.teamIds=s,t=await this.instance.get(`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`),r.push(t.data.data.map(n=>this.teamBasicRemapper.fromResponse(n)));return Array.prototype.concat.apply([],r)}else return t=e?await this.instance.get(`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instance.get(`/teams${this.apiSignInUrl}`),t.data.data.map(r=>this.teamBasicRemapper.fromResponse(r))}catch(t){throw console.warn("There was a problem with getTeams request",t),t.response}};getTeamById=async e=>{try{let t=await this.instance.get(`/teams/${e}${this.apiSignInUrl}`);return this.teamFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getTeamById request",t),t.response}};getTopTeams=async()=>{try{let e=await this.instance.get(`/teams/top${this.apiSignInUrl}`);return e.data.data?e.data.data.map(t=>this.teamBasicRemapper.fromResponse(t)):[]}catch(e){throw console.warn("There was a problem with getTopTeams request",e),e.response}};getNextMatchForTeam=async e=>{try{let t=await this.instance.get(`/teams/${e}/next-match${this.apiSignInUrl}`);return this.matchFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getNextMatchForTeam request",t),t.response}};getPrevMatchForTeam=async e=>{try{let t=await this.instance.get(`/teams/${e}/previous-match${this.apiSignInUrl}`);return this.matchFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getPrevMatchForTeam request",t),t.response}};getPlayers=async e=>{try{let t={};if(e&&e.playerIds&&e.playerIds.length>this.limitIds-1){let r=[],i=Be(e.playerIds);for(let s of i)e.playerIds=s,t=await this.instance.get(`/players${this.apiSignInUrl}${e.constructFilterUrl()}`),r.push(t.data.data.map(n=>this.teamBasicRemapper.fromResponse(n)));return Array.prototype.concat.apply([],r)}else return(e?await this.instance.get(`/players${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instance.get(`/players${this.apiSignInUrl}`)).data.data.map(i=>this.playerBasicRemapper.fromResponse(i))}catch(t){throw console.warn("There was a problem with getPlayers request",t),t.response}};getPlayerById=async e=>{try{let t=await this.instance.get(`/players/${e}${this.apiSignInUrl}`);return this.playerFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getPlayerById request",t),t.response}};getTopPlayers=async()=>{try{return(await this.instance.get(`/players/top${this.apiSignInUrl}`)).data.data.map(t=>this.topPlayerRemapper.fromResponse(t))}catch(e){throw console.warn("There was a problem with getTopPlayers request",e),e.response}};getNextMatchForPlayer=async e=>{try{let t=await this.instance.get(`/players/${e}/next-match${this.apiSignInUrl}`);return this.matchFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getNextMatchForPlayer request",t),t.response}};getPrevMatchForPlayer=async e=>{try{let t=await this.instance.get(`/players/${e}/previous-match${this.apiSignInUrl}`);return this.matchFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getPrevMatchForPlayer request",t),t.response}};getMatchById=async e=>{try{let t=await this.instance.get(`/matches/${e}${this.apiSignInUrl}`);return this.matchFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getMatchById request",t),t.response}};getMatches=async e=>{try{return(e?await this.instance.get(`/matches${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instance.get(`/matches${this.apiSignInUrl}`)).data.data.map(r=>this.matchBasicRemapper.fromResponse(r))}catch(t){throw console.warn("There was a problem with getMatches request",t),t.response}};search=async e=>{try{let t=await this.instance.get(`/search${this.apiSignInUrl}${e.constructFilterUrl()}`);return this.searchRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with search request",t),t.response}}};var xt=class{profileHttps=null;footballHttps=null;footballFacade=null;idMapping=null;localStorage=null;profileFacade=null;ownProfileBuilder=null;profileBuilder=null;constructor(e){this.profileHttps=new Ge(e),this.footballHttps=new O(e),this.idMapping=new _(e),this.localStorage=new A(e),this.footballFacade=new L(this.localStorage,this.footballHttps,this.idMapping),this.profileFacade=new B(this.localStorage,this.profileHttps),this.ownProfileBuilder=new it(this.localStorage,this.profileHttps,this.idMapping,this.footballHttps),this.profileBuilder=new ot(this.localStorage,this.profileHttps,this.idMapping,this.footballFacade)}getOwn=()=>this.ownProfileBuilder;getById=e=>this.profileBuilder.setId(e);getCountries=async()=>await this.profileFacade.getCountries();getByIds=async e=>await this.profileFacade.getByIds(e)};var At=class{validate=e=>{let t=this.validateField(e.lang),r=this.generateMessage(t);return{validation:t,message:r}};validateField=e=>{let t=["bg","ro","en"],r=null;return e!=null&&e.length>0?t.includes(e)?r="valid":r="invalid":r="missing",r};generateMessage=e=>{let t=null,r="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,r=null),{text:t,type:r}}};var Bt=class{validate(e){let t=this.validateField(e.environment),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=["dev","sandbox","prod"],r=null;return e!=null&&e.length>0?t.includes(e)?r="valid":r="invalid":r="missing",r};generateMessage=e=>{let t=null,r="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,r=null),{text:t,type:r}}};var Nt=class{validate(e){let t=this.validateField(e.apiKey),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,r="error";return e==="missing"&&(t="The field apiKey with valid value must be provided to use this SDK"),e==="valid"&&(r=null),{text:t,type:r}}};var Lt=class{validate(e){let t=this.validateField(e.idSchema),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=["native","sportal365","enetpulse","sportradar"],r=null;return e!=null&&e.length>0?t.includes(e)?r="valid":r="invalid":r="missing",r};generateMessage=e=>{let t=null,r="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,r=null),{text:t,type:r}}};var Pe=class{getIdToken=null;logout=null};var re=class{text=null;type=null};var Vt=class{validation=null;message=new re;getIdToken={validation:null,message:new re};logout={validation:null,message:new re}};var Dt=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 Pe),r=new Vt;if(e){let a=Object.keys(e).filter(s=>!t.includes(s));a.length>0?(r.validation="invalid",r.message.type="warning",r.message.text=`${"You have passed a property which is not supported for the authentication provider:"} ${a.join(",")}`):r.validation="valid"}else r.validation="missing",r.message.type="error",r.message.text="The field authProvider must be provided to use this SDK";return r};validateAuthProviderConfigFields=(e,t)=>(Object.keys(new Pe).forEach(i=>{e[i]?t[i].validation="valid":t[i].validation="missing"}),t);generateAuthProviderConfigMessages=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{let r=e[t];r.validation==="missing"&&(r.message.text=`${"The following property is missing from the authProvider object:"} ${t}`,r.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 Se=class{validation;message};var Ut=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;authProvider={getIdToken:new Se,logout:new Se};isValid=!1};var $t=class{validate(e){let t=this.validateField(e.clientId),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,r="warning";return e==="missing"&&(t="The field clientId must be provided to use this SDK"),e==="valid"&&(t=null,r=null),{text:t,type:r}}};var Gt=class{validate=e=>{let t=this.checkFieldsForValues(e);return t.isValid=this.containsErrorMessage(t),t};checkFieldsForValues=e=>{let t=new Ut,r={apiKey:new Nt,environment:new Bt,idSchema:new Lt,clientId:new $t,lang:new At,authProvider:new Dt};for(let[i,a]of Object.entries(t))i!=="isValid"&&(a=r[i].validate(e));return Object.keys(r).forEach(i=>{t[i]=r[i].validate(e)}),t};containsErrorMessage=e=>{let t=!0;for(let[r,i]of Object.entries(e))if(r!=="authProvider"){if(r!=="isValid"&&i.message.type==="error")return t=!1,t;if(r!=="isValid"&&i.message.type==="warning")return t=!0,t}return t}};var Ht=class{https=null;idMapping=null;localStorage=null;footballFacade=null;constructor(e){this.https=new O(e),this.idMapping=new _(e),this.localStorage=new A(e),this.footballFacade=new L(this.localStorage,this.https,this.idMapping)}getCountries=async()=>await this.footballFacade.getCountries();getCompetitions=async e=>await this.footballFacade.getCompetitions(e);getCompetitionById=async e=>await this.footballFacade.getCompetitionById(e);getTopCompetitions=async()=>await this.footballFacade.getTopCompetitions();getTeams=async e=>await this.footballFacade.getTeams(e);getTeamById=async e=>await this.footballFacade.getTeamById(e);getTopTeams=async()=>await this.footballFacade.getTopTeams();getNextMatchForTeam=async e=>await this.footballFacade.getNextMatchForTeam(e);getPrevMatchForTeam=async e=>await this.footballFacade.getPrevMatchForTeam(e);getPlayers=async e=>await this.footballFacade.getPlayers(e);getPlayerById=async e=>await this.footballFacade.getPlayerById(e);getTopPlayers=async()=>await this.footballFacade.getTopPlayers();getNextMatchForPlayer=async e=>await this.footballFacade.getNextMatchForPlayer(e);getPrevMatchForPlayer=async e=>await this.footballFacade.getPrevMatchForPlayer(e);getMatches=async e=>await this.footballFacade.getMatches(e);getMatchById=async e=>await this.footballFacade.getMatchById(e);search=async e=>await this.footballFacade.search(e)};var ri=de(Y());var kt=class{value=null;playerId=null;playerModel=null};var qt=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new kt;result=null};var jt=class{value=!1;playerId=null};var V=class{matchId=null;market=null;prediction=null;constructor(e,t,r,i){this.matchId=e,this.market=t,this.prediction=new jt,this.prediction.value=r,this.prediction.playerId=i}};var Kt=class{settledAt=null;resettledAt=null;status=null;outcome=null};var F=(d=>(d.FT_1X2="FT_1X2",d.HT_1X2="HT_1X2",d.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",d.DOUBLE_CHANCE="DOUBLE_CHANCE",d.HT_FT="HT_FT",d.PLAYER_SCORE="PLAYER_SCORE",d.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",d.PLAYER_RED_CARD="PLAYER_RED_CARD",d.RED_CARD_MATCH="RED_CARD_MATCH",d.PENALTY_MATCH="PENALTY_MATCH",d.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",d.CORNERS_MATCH="CORNERS_MATCH",d.CORRECT_SCORE="CORRECT_SCORE",d.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",d.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",d.OVER_GOALS_0_5="OVER_GOALS_0.5",d.OVER_GOALS_1_5="OVER_GOALS_1.5",d.OVER_GOALS_2_5="OVER_GOALS_2.5",d.OVER_GOALS_3_5="OVER_GOALS_3.5",d.OVER_GOALS_4_5="OVER_GOALS_4.5",d.OVER_GOALS_5_5="OVER_GOALS_5.5",d.OVER_GOALS_6_5="OVER_GOALS_6.5",d.OVER_CORNERS_6_5="OVER_CORNERS_6.5",d.OVER_CORNERS_7_5="OVER_CORNERS_7.5",d.OVER_CORNERS_8_5="OVER_CORNERS_8.5",d.OVER_CORNERS_9_5="OVER_CORNERS_9.5",d.OVER_CORNERS_10_5="OVER_CORNERS_10.5",d.OVER_CORNERS_11_5="OVER_CORNERS_11.5",d.OVER_CORNERS_12_5="OVER_CORNERS_12.5",d.OVER_CORNERS_13_5="OVER_CORNERS_13.5",d))(F||{}),yo=["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"],go=["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"],Qr=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"];var Yt=class{value=null};var D=class{matchId=null;market="CORRECT_SCORE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Yt,this.prediction.value=t}};var v=class{value=!1};var ie=class{matchId=null;market=null;prediction=null;constructor(e,t,r){this.matchId=e,this.market=t,this.prediction=new v,this.prediction.value=r}};var oe=class{matchId=null;market=null;prediction=null;constructor(e,t,r){this.matchId=e,this.market=t,this.prediction=new v,this.prediction.value=r}};var c=class{no=0;yes=0};var ae=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new c;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new c;penaltyMatch=new c;playerScoreFirstGoal={};cornersMatch={};correctScore={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new c;overOnePointFiveGoals=new c;overTwoPointFiveGoals=new c;overThreePointFiveGoals=new c;overFourPointFiveGoals=new c;overFivePointFiveGoals=new c;overSixPointFiveGoals=new c;overSixPointFiveCorners=new c;overSevenPointFiveCorners=new c;overEightPointFiveCorners=new c;overNinePointFiveCorners=new c;overTenPointFiveCorners=new c;overElevenPointFiveCorners=new c;overTwelvePointFiveCorners=new c;overThirteenPointFiveCorners=new c};var Zr=(r=>(r.ONE="1",r.X="x",r.TWO="2",r))(Zr||{}),ei=(r=>(r.ONE_X="1x",r.X_TWO="x2",r.ONE_TWO="12",r))(ei||{}),ti=(m=>(m.ONE_ONE="1/1",m.ONE_X="1/x",m.ONE_TWO="1/2",m.X_ONE="x/1",m.X_X="x/x",m.X_TWO="x/2",m.TWO_ONE="2/1",m.TWO_X="2/x",m.TWO_TWO="2/2",m))(ti||{});var Xt=class{value=null};var Wt=class{matchId=null;market="HT_FT";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Xt,this.prediction.value=t}};var Jt=class{value=null};var zt=class{matchId=null;market="DOUBLE_CHANCE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Jt,this.prediction.value=t}};var se=class{value=null};var Qt=class{matchId=null;market="FT_1X2";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new se,this.prediction.value=t}};var Zt=class{matchId=null;market="HT_1X2";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new se,this.prediction.value=t}};var er=class{value};var tr=class{matchId=null;market="CORNERS_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new er,this.prediction.value=t}};var rr=class{matchId=null;market="BOTH_TEAMS_SCORE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new v,this.prediction.value=t}};var ir=class{matchId=null;market="RED_CARD_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new v,this.prediction.value=t}};var or=class{matchId=null;market="PENALTY_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new v,this.prediction.value=t}};var U=class{id=null;title=null;description=null;type=null;status=null;predictionsCutoff=null;fixtures=[];createdAt=null;updatedAt=null};var ne=class{userId=null;points=null;results=[];tiebreaker=null};var $=class{footballHttps=null;idMapping=null;matchFacade=null;constructor(e,t){this.footballHttps=new O(e),this.idMapping=t,this.matchFacade=new N(this.footballHttps,t)}remapMatchIdToNative=async e=>{let t=await this.idMapping.getEntityIdsBySchemaId(e,"match","native"),r=[];return t.match.forEach(i=>r.push(i)),r};remapPlayerIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"player","native")).player[0];remapPlayerIdToIdSchema=async e=>{let t=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"];for(let[r,i]of Object.entries(e))if(t.includes(r))for(let a of Object.keys(i)){let s={player:[a]},p=(await this.idMapping.idMappingFacade.getEntitiesByIds(s,"native",this.idMapping.idSchema)).player[0];i[p]=i[a],delete i[a]}return e};convertMarket=e=>{let t=Object.keys(new ae),r=Object.values(F);for(let i=0;i<r.length;i++)e===r[i]&&(e=t[i]);return e};convertMarketForResponseModel=(e,t)=>{let r=t.toString();return e+"_"+r};validateFixture=(e,t,r,i)=>{let a=Object.values(Zr),s=Object.values(ti),n=Object.values(ei);if(t==="FT_1X2"){if(a.includes(r))return new Qt(e,r)}else if(t==="HT_1X2"){if(a.includes(r))return new Zt(e,r)}else if(t==="HT_FT"){if(s.includes(r))return new Wt(e,r)}else if(t==="DOUBLE_CHANCE"){if(n.includes(r))return new zt(e,r)}else if(t==="CORRECT_SCORE"){if(typeof r=="string"&&/\d+:\d+/.test(r))return new D(e,r)}else if(t==="CORNERS_MATCH"){if(typeof r=="number")return new tr(e,r)}else if(t==="BOTH_TEAMS_SCORE"){if(typeof r=="boolean")return new rr(e,r)}else if(t==="RED_CARD_MATCH"){if(typeof r=="boolean")return new ir(e,r)}else if(t==="PENALTY_MATCH"){if(typeof r=="boolean")return new or(e,r)}else if(Qr.includes(t)){if(i&&typeof r=="boolean")return new V(e,t,r,i)}else if(yo.includes(t)){if(typeof r=="boolean")return new oe(e,t,r)}else if(go.includes(t)&&typeof r=="boolean")return new ie(e,t,r)};getMarketSummary=(e,t,r)=>{let i=this.convertMarket(t),a={};if(a.matchId=e.matchId,a.matchType=e.matchType,Object.keys(e.predictions).includes(i))a[i]=e.predictions[i];else throw new Error("You have passed invalid market");return Qr.includes(t)&&r?(a[i][r]||(a[i][r]=new c),a[i][r]):a};remapCompetitionsFromConfig=async e=>{let t={competition:e.fullCoverageCompetitions},r=await this.idMapping.idMappingFacade.getEntitiesByIds(t,"native",this.idMapping.idSchema);return e.fullCoverageCompetitions=r.competition,e};remapPredictions=async e=>{if(this.idMapping.idSchema!=="native")if(e&&e.length>0){for(let t of e)for(let r of t.fixtures)r.matchId=r.matchModel.id;return e}else return e;else return e};remapMatchIdsFixtures=async e=>{if(Array.isArray(e))if(e.length>0){let t=[];for(let r of e){let i=await this.refactorResponseModel(r);t.push(i)}return t}else return e;else return await this.refactorResponseModel(e)};refactorResponseModel=async e=>{let t=[];if(e instanceof U){e.fixtures.forEach(i=>t.push(i.matchId));let r=await this.matchFacade.getMatchesWithNativeIds(t);return e.fixtures.sort((i,a)=>i.matchId.localeCompare(a.matchId)),r.forEach((i,a)=>{e.fixtures[a].matchModel=i,this.idMapping.idSchema!=="native"&&(e.fixtures[a].matchId=i.id)}),e}else if(e instanceof ne){e.results.forEach(i=>t.push(i.matchId));let r=await this.matchFacade.getMatchesWithNativeIds(t);return e.results.sort((i,a)=>i.matchId.localeCompare(a.matchId)),r.forEach((i,a)=>{e.results[a].matchModel=i,this.idMapping.idSchema!=="native"&&(e.results[a].matchId=i.id)}),e}}};var ar=class{idMapping=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t,r,i,a){this.idMapping=t,this.footballHttps=r,this.matchFacade=i,this.playerFacade=a,this.predictorService=new $(e,t)}remapFixturesRequest=e=>{let t={};if(t.match_id=e.matchId,t.match_type="FOOTBALL",e instanceof V)t.market=e.market,t.prediction=e.prediction.value,t.player_id=e.prediction.playerId;else if(e instanceof ie||e instanceof oe){let r=e.market.split("_");t.market=r[0]+"_"+r[1],t.prediction=e.prediction.value,t.target=r[2]}else if(e instanceof D){t.market=e.market;let r=e.prediction.value.split(":");t.goals_home=r[0],t.goals_away=r[1]}else t.market=e.market,t.prediction=e.prediction.value;return t};remapFixturesResponse=async e=>{e.length>1&&e.sort((n,p)=>n.match_id.localeCompare(p.match_id));let t=[],r=[];for(let n of e)t.push(n.match_id),n.player_id&&!r.includes(n.player_id)&&r.push(n.player_id);let i=await this.matchFacade.getMatchesWithNativeIds(t),a=[];r.sort((n,p)=>n.localeCompare(p)),r&&r.length>0&&(a=await this.playerFacade.getPlayersMapWithNativeIds(r));let s=[];for(let n of e){let p=new qt;n.target?p.market=this.predictorService.convertMarketForResponseModel(n.market,n.target):p.market=n.market,p.matchId=n.match_id,p.matchType=n.match_type,p.matchModel=i?i.shift():null,n.goals_home!==void 0&&n.goals_away!==void 0?p.prediction.value=n.goals_home.toString()+":"+n.goals_away.toString():p.prediction.value=n.prediction,p.prediction.playerId=n.player_id?n.player_id:null,p.prediction.playerId&&Object.keys(a).forEach(m=>{p.prediction.playerId===m&&(p.prediction.playerModel=a[m],p.prediction.playerId=a[m].id)}),p.result=this.remapResult(n.result),s.push(p)}return s};remapResult=e=>{let t=new Kt;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t}};var sr=class{id=null;gameInstanceId=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=null;points=null;createdAt=null;updatedAt=null};var le=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;constructor(e,t){this.footballHttps=new O(e),this.matchFacade=new N(this.footballHttps,t),this.playerFacade=new X(this.footballHttps,t),this.fixturesRemapper=new ar(e,t,this.footballHttps,this.matchFacade,this.playerFacade)}remapRequestBody=e=>{let t={};return t.game_instance_id=e.gameInstanceId,t.fixtures=e.fixtures.map(r=>this.fixturesRemapper.remapFixturesRequest(r)),t};remapResponseObjBody=async e=>{let t=new sr;return t.id=e.id,t.gameInstanceId=e.game_instance_id,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,t.tiebreaker=e.tiebreaker,t.points=e.points,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapPredictionModel=e=>{let t=new ae;return t.fullTimeOneXTwo=e.FT_1X2,t.halfTimeOneXTwo=e.HT_1X2,t.bothTeamsScore=e.BOTH_TEAMS_SCORE?e.BOTH_TEAMS_SCORE:new c,t.overZeroPointFiveGoals=e.OVER_GOALS["over:0.5"]?e.OVER_GOALS["over:0.5"]:new c,t.overOnePointFiveGoals=e.OVER_GOALS["over:1.5"]?e.OVER_GOALS["over:1.5"]:new c,t.overTwoPointFiveGoals=e.OVER_GOALS["over:2.5"]?e.OVER_GOALS["over:2.5"]:new c,t.overThreePointFiveGoals=e.OVER_GOALS["over:3.5"]?e.OVER_GOALS["over:3.5"]:new c,t.overFourPointFiveGoals=e.OVER_GOALS["over:4.5"]?e.OVER_GOALS["over:4.5"]:new c,t.overFivePointFiveGoals=e.OVER_GOALS["over:5.5"]?e.OVER_GOALS["over:5.5"]:new c,t.overSixPointFiveGoals=e.OVER_GOALS["over:6.5"]?e.OVER_GOALS["over:6.5"]:new c,t.overSixPointFiveCorners=e.OVER_CORNERS["over:6.5"]?e.OVER_CORNERS["over:6.5"]:new c,t.overSevenPointFiveCorners=e.OVER_CORNERS["over:7.5"]?e.OVER_CORNERS["over:7.5"]:new c,t.overEightPointFiveCorners=e.OVER_CORNERS["over:8.5"]?e.OVER_CORNERS["over:8.5"]:new c,t.overNinePointFiveCorners=e.OVER_CORNERS["over:9.5"]?e.OVER_CORNERS["over:9.5"]:new c,t.overTenPointFiveCorners=e.OVER_CORNERS["over:10.5"]?e.OVER_CORNERS["over:10.5"]:new c,t.overElevenPointFiveCorners=e.OVER_CORNERS["over:11.5"]?e.OVER_CORNERS["over:11.5"]:new c,t.overTwelvePointFiveCorners=e.OVER_CORNERS["over:12.5"]?e.OVER_CORNERS["over:12.5"]:new c,t.overThirteenPointFiveCorners=e.OVER_CORNERS["over:13.5"]?e.OVER_CORNERS["over:13.5"]:new c,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?e.RED_CARD_MATCH:new c,t.penaltyMatch=e.PENALTY_MATCH?e.PENALTY_MATCH:new c,t.playerScoreFirstGoal=e.PLAYER_SCORE_FIRST_GOAL,t.cornersMatch=e.CORNERS_MATCH,t.correctScore=e.CORRECT_SCORE,t.playerScoreHattrick=e.PLAYER_SCORE_HATTRICK,t.playerScoreTwice=e.PLAYER_SCORE_TWICE,t}};var nr=class{matchId=null;matchType=null;predictions=null};var lr=class{remapPredictions=null;constructor(e,t){this.remapPredictions=new le(e,t)}remapResponse=e=>{let t=new nr;return t.matchId=e.match_id,t.matchType=e.match_type,t.predictions=this.remapPredictions.remapPredictionModel(e.predictions),t}};var pr=class{matchId=null;matchType=null;market="CORRECT_SCORE";matchModel=null};var cr=class{matchId=null;matchModel=null;outcome=null};var mr=class{goldenGoal=null};var ur=class{remapGamesListResponse=e=>{let t=new U;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.fixtures=e.fixtures.map(r=>this.remapFixturesResponse(r)),t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapFixturesResponse=e=>{let t=new pr;return t.matchId=e.match_id,t.matchType=e.match_type,t};remapGameResults=e=>{let t=new ne;return t.userId=e.user_id,t.points=e.points?e.points:0,t.results=e.results.map(r=>this.remapResults(r)),t.tiebreaker=e.tiebreaker?this.remapTiebreaker(e.tiebreaker):null,t};remapResults=e=>{let t=new cr;return t.matchId=e.match_id,t.outcome=e.outcome,t};remapTiebreaker=e=>{let t=new mr;return t.goldenGoal=e.golden_goal,t}};var pe=class{instanceAuth=null;instance=null;apiSignInUrl=null;clientApiSignInUrl=null;predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;constructor(e,t){let r=E(e.environment,"predictor");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.predictionRemapper=new le(e,t),this.matchSummaryRemapper=new lr(e,t),this.gamesRemapper=new ur,this.instanceAuth=ri.default.create({baseURL:r,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instance=ri.default.create({baseURL:r,headers:{"Content-Type":"application/json"}})}makeFootballPrediction=async e=>{try{let t=this.predictionRemapper.remapRequestBody(e),r=await this.instanceAuth.post(`/predictions${this.apiSignInUrl}`,JSON.stringify(t));return await this.predictionRemapper.remapResponseObjBody(r.data)}catch(t){throw console.warn("There was a problem making POST request: ",t),t.response}};getMatchSummary=async e=>{try{let t=await this.instance.get(`/predictions/summary/${e}${this.apiSignInUrl}`);return this.matchSummaryRemapper.remapResponse(t.data)}catch(t){throw console.warn(`There was a problem fetching predictions for match: ${e} `,t),t.response}};deleteFootballPrediction=async e=>{try{return await this.instanceAuth.delete(`/predictions/${e}${this.apiSignInUrl}`),!0}catch(t){throw console.warn(`There was a problem deleting your prediction: ${e}`,t),t.response}};getMyPredictions=async e=>{try{let t=e?await this.instanceAuth.get(`/predictions${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instanceAuth.get(`/predictions${this.apiSignInUrl}`),r=[];for(let i of t.data.data){let a=await this.predictionRemapper.remapResponseObjBody(i);r.push(a)}return r}catch(t){throw console.warn("There was a problem fetching own predictions",t),t.response}};getUserPredictions=async(e,t)=>{try{let r=t?await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}${t.constructFilterUrl()}`):await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}`),i=[];for(let a of r.data.data){let s=await this.predictionRemapper.remapResponseObjBody(a);i.push(s)}return i}catch(r){throw console.warn(`There was a problem fetching predictions for user: ${e}`,r),r.response}};getGames=async e=>{try{return(await this.instance.get(`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`)).data.data.map(r=>this.gamesRemapper.remapGamesListResponse(r))}catch(t){throw console.warn("There was a problem fetching the games list",t),t.response}};getGameById=async e=>{try{let t=await this.instance.get(`/games/${e}${this.apiSignInUrl}`);return this.gamesRemapper.remapGamesListResponse(t.data)}catch(t){throw console.warn(`There was a problem fetching the following game: ${e}`,t),t.response}};getGameResults=async(e,t)=>{try{return(t?await this.instance.get(`/games/${e}/results/${this.apiSignInUrl}${t.constructFiltersUrl()}`):await this.instance.get(`/games/${e}/results/${this.apiSignInUrl}`)).data.data.map(i=>this.gamesRemapper.remapGameResults(i))}catch(r){throw console.warn(`There was a problem fetching the results for the following game: ${e}`,r),r.response}}};var dr=class{fullCoverageCompetitions=null;markets=null};var hr=class{remapConfig=e=>{let t=new dr;return t.fullCoverageCompetitions=e.full_coverage_competitions,t.markets=e.markets,t}};var fr=class{gameInstanceId=null;fixtures=null};var yr=(a=>(a.ACTIVE="ACTIVE",a.WON="WON",a.LOST="LOST",a.PARTIALLY_WON="PARTIALLY_WON",a.CANCELED="CANCELED",a))(yr||{}),ve=["WON","LOST","PARTIALLY_WON","CANCELED"];var P=class{limit=null;startAfter=null;status=null;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null,this.status=e.status?e.status:null}constructFilterUrl=()=>{let e="",t=!1;return this.status&&(t=Object.values(yr).some(r=>this.status.includes(r))),this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),this.status&&t&&(e+="&",e+=`status=${this.status.join(",")}`),e}};var gr=class{predictorHttps=null;clientHttps=null;idMapping=null;predictorConfigRemapper=null;predictorService=null;constructor(e,t,r,i){this.predictorHttps=t,this.idMapping=i,this.clientHttps=r,this.predictorConfigRemapper=new hr,this.predictorService=new $(e,i)}makeFootballPrediction=async(e,t,r,i)=>{let a=this.predictorService.validateFixture(e,t,r,i),s=new fr;if(a)if(this.idMapping.idSchema!=="native"){let n=a.matchId,p="",m=await this.predictorService.remapMatchIdToNative([n]);if(a.matchId=m[0],!a.matchId)throw new Error("Match id is invalid!");if(a instanceof V&&(p=a.prediction.playerId,a.prediction.playerId=await this.predictorService.remapPlayerIdToNative([p]),!a.prediction.playerId))throw new Error("Player id is invalid!");s.fixtures=[a];let l=await this.predictorHttps.makeFootballPrediction(s);return l.fixtures.map(u=>{u.prediction.playerId&&(u.prediction.playerId=p),u.matchId=n}),l}else return s.fixtures=[a],await this.predictorHttps.makeFootballPrediction(s);else throw new Error("The prediction is invalid. Please check again have you passed appropriate prediction model")};getMatchSummary=async e=>{if(this.idMapping.idSchema!=="native"){let r=(await this.predictorService.remapMatchIdToNative([e]))[0],i=await this.predictorHttps.getMatchSummary(r);i.matchId=e;let a=i.predictions,s=await this.predictorService.remapPlayerIdToIdSchema(a);return i.predictions=s,i}else return await this.predictorHttps.getMatchSummary(e)};getMarketSummary=async(e,t,r)=>{try{let i=await this.getMatchSummary(e);return this.predictorService.getMarketSummary(i,t,r)}catch(i){return i.message}};getConfig=async()=>{let e=await this.clientHttps.getConfig(),t=await this.predictorConfigRemapper.remapConfig(e.predictor);return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(t):t};deleteFootballPrediction=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyPredictions=async e=>{e&&(e=new P(e));let t=await this.predictorHttps.getMyPredictions(e);return await this.predictorService.remapPredictions(t)};getMyCurrentPredictions=async e=>{if(e)e.status=["ACTIVE"],e=new P(e);else{let t={status:["ACTIVE"]};e=new P(t)}return await this.getMyPredictions(e)};getMyPastPredictions=async e=>{if(e)e.status=ve,e=new P(e);else{let t={status:ve};e=new P(t)}return await this.getMyPredictions(e)};getUserPredictions=async(e,t)=>{t&&(t=new P(t));let r=await this.predictorHttps.getUserPredictions(e,t);return await this.predictorService.remapPredictions(r)};getUserCurrentPredictions=async(e,t)=>{if(t)t.status=["ACTIVE"],t=new P(t);else{let r={status:["ACTIVE"]};t=new P(r)}return await this.getUserPredictions(e,t)};getUserPastPredictions=async(e,t)=>{if(t)t.status=ve,t=new P(t);else{let r={status:ve};t=new P(r)}return await this.getUserPredictions(e,t)}};var wo=de(Y());var ce=class{instance=null;apiSignInUrl="";constructor(e){let t=E(e.environment,"client");this.apiSignInUrl=`/clients/${e.clientId}/features?key=${e.apiKey}`,this.instance=wo.default.create({baseURL:t,headers:{"Content-Type":"application/json"}})}getConfig=async()=>{try{return(await this.instance.get(`${this.apiSignInUrl}`)).data.data}catch(e){throw console.warn("There was a problem fetching configuration from Client API",e),e.response}}};var wr=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(e){this.idMapping=new _(e),this.predictorHttps=new pe(e,this.idMapping),this.clientHttps=new ce(e),this.predictorFacade=new gr(e,this.predictorHttps,this.clientHttps,this.idMapping)}makeFootballPrediction=async(e,t,r,i)=>await this.predictorFacade.makeFootballPrediction(e,t,r,i);getMatchSummary=async e=>await this.predictorFacade.getMatchSummary(e);getMarketSummary=async(e,t,r)=>await this.predictorFacade.getMarketSummary(e,t,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);getUserPredictions=async(e,t)=>await this.predictorFacade.getUserPredictions(e,t);getUserCurrentPredictions=async(e,t)=>await this.predictorFacade.getUserCurrentPredictions(e,t);getUserPastPredictions=async(e,t)=>await this.predictorFacade.getUserPastPredictions(e,t)};var Mr=class{general=[];predictor=[];topX=[]};var br=class{enabled=!1;rewards=null};var Ir=class{general=null;topX=null;predictor=null};var Rr=class{points=null;tiers=null;badges=null};var Fr=class{remapLoyaltyResponse=e=>{let t=new br;return t.enabled=e.enabled,t.rewards=this.remapRewards(e.rewards),t};remapRewards=e=>{let t=new Rr;return t.points=this.remapPoints(e.points),t.tiers=e.tiers,t.badges=this.remapBadges(e.badges),t};remapPoints=e=>{let t=new Ir;return t.general=e.general,t.topX=e.top_x,t.predictor=e.predictor,t};remapBadges=e=>{let t=new Mr;return t.general=e.general,t.predictor=e.predictor,t.topX=e.top_x,t}};var Pr=class{https=null;loyaltyRemapper=null;constructor(e){this.https=e,this.loyaltyRemapper=new Fr}getConfig=async()=>{let e=await this.https.getConfig();return this.loyaltyRemapper.remapLoyaltyResponse(e.loyalty)}};var Sr=class{https=null;loyaltyFacade=null;constructor(e){this.https=new ce(e),this.loyaltyFacade=new Pr(this.https)}getConfig=async()=>await this.loyaltyFacade.getConfig()};var me=class{limit=null;startAfter=null;status=null;type=null;gameIds=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.gameIds=e.gameIds?e.gameIds:null}constructFiltersUrl=()=>{let e="";return this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),this.status&&(e+="&",e+=`status=${this.status}`),this.type&&(e+="&",e+=`type=${this.type}`),this.gameIds&&(e+="&",e+=`game_ids=${this.gameIds.join(",")}`),e}};var vr=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(e){this.gameInstanceId=e.gameInstanceId,e.fixtures.forEach(t=>this.fixtures.push(new D(t.matchId,t.prediction.value))),this.tiebreaker=e.tiebreaker?e.tiebreaker:null}};var Cr=class{idMapping=null;predictorHttps=null;predictorService=null;constructor(e,t){this.idMapping=t,this.predictorHttps=new pe(e,t),this.predictorService=new $(e,t)}getGames=async e=>{let t=[new U];if(e)e.type="TOP_X",e=new me(e),t=await this.predictorHttps.getGames(e);else{let r={type:"TOP_X"};r=new me(r),t=await this.predictorHttps.getGames(r)}return await this.predictorService.remapMatchIdsFixtures(t)};getGameById=async e=>{let t=await this.predictorHttps.getGameById(e);return await this.predictorService.remapMatchIdsFixtures(t)};getGameResults=async(e,t)=>{t&&(t=new me(t));let r=await this.predictorHttps.getGameResults(e,t);return await this.predictorService.remapMatchIdsFixtures(r)};play=async e=>{let t=new vr(e);if(this.idMapping.idSchema!=="native"){let i=[];t.fixtures.forEach(s=>i.push(s.matchId));let a=await this.predictorService.remapMatchIdToNative(i);t.fixtures.forEach(s=>s.matchId=a.shift())}let r=await this.predictorHttps.makeFootballPrediction(t);return r.fixtures.forEach(i=>{i.matchId=i.matchModel.id}),r}};var Tr=class{topXFacade=null;idMapping=null;constructor(e){this.idMapping=new _(e),this.topXFacade=new Cr(e,this.idMapping)}getGames=async e=>await this.topXFacade.getGames(e);getGameById=async e=>await this.topXFacade.getGameById(e);getGameResults=async(e,t)=>await this.topXFacade.getGameResults(e,t);play=async e=>await this.topXFacade.play(e)};function Ld(o){let t=new Gt().validate(o);if(t.idSchema.validation==="missing"&&(console.warn(t.idSchema.message.text),o.idSchema="native"),t.environment.validation==="missing"&&(console.warn(t.environment.message.text),o.environment="prod"),t.lang.validation==="missing"&&(console.warn(t.lang.message.text),o.lang="en"),t.isValid)return{profile:new xt(o),football:new Ht(o),predictor:new wr(o),loyalty:new Sr(o),topX:new Tr(o)};throw new Error("Configuration is not valid")}export{Ld as FansUnitedSDK};
|
|
1
|
+
var To=Object.create;var Gr=Object.defineProperty;var Eo=Object.getOwnPropertyDescriptor;var Co=Object.getOwnPropertyNames;var _o=Object.getPrototypeOf,Oo=Object.prototype.hasOwnProperty;var xo=o=>Gr(o,"__esModule",{value:!0});var h=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports);var Ao=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Co(e))!Oo.call(o,i)&&(t||i!=="default")&&Gr(o,i,{get:()=>e[i],enumerable:!(r=Eo(e,i))||r.enumerable});return o},Me=(o,e)=>Ao(xo(Gr(o!=null?To(_o(o)):{},"default",!e&&o&&o.__esModule?{get:()=>o.default,enumerable:!0}:{value:o,enumerable:!0})),o);var Vr=h((Oa,ui)=>{"use strict";ui.exports=function(e,t){return function(){for(var i=new Array(arguments.length),a=0;a<i.length;a++)i[a]=arguments[a];return e.apply(t,i)}}});var b=h((xa,fi)=>{"use strict";var Bo=Vr(),q=Object.prototype.toString;function Ur(o){return q.call(o)==="[object Array]"}function Dr(o){return typeof o=="undefined"}function No(o){return o!==null&&!Dr(o)&&o.constructor!==null&&!Dr(o.constructor)&&typeof o.constructor.isBuffer=="function"&&o.constructor.isBuffer(o)}function Lo(o){return q.call(o)==="[object ArrayBuffer]"}function Go(o){return typeof FormData!="undefined"&&o instanceof FormData}function Vo(o){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(o):e=o&&o.buffer&&o.buffer instanceof ArrayBuffer,e}function Uo(o){return typeof o=="string"}function Do(o){return typeof o=="number"}function di(o){return o!==null&&typeof o=="object"}function Ne(o){if(q.call(o)!=="[object Object]")return!1;var e=Object.getPrototypeOf(o);return e===null||e===Object.prototype}function $o(o){return q.call(o)==="[object Date]"}function ko(o){return q.call(o)==="[object File]"}function Ho(o){return q.call(o)==="[object Blob]"}function hi(o){return q.call(o)==="[object Function]"}function qo(o){return di(o)&&hi(o.pipe)}function jo(o){return typeof URLSearchParams!="undefined"&&o instanceof URLSearchParams}function Xo(o){return o.trim?o.trim():o.replace(/^\s+|\s+$/g,"")}function Ko(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function $r(o,e){if(!(o===null||typeof o=="undefined"))if(typeof o!="object"&&(o=[o]),Ur(o))for(var t=0,r=o.length;t<r;t++)e.call(null,o[t],t,o);else for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&e.call(null,o[i],i,o)}function kr(){var o={};function e(i,a){Ne(o[a])&&Ne(i)?o[a]=kr(o[a],i):Ne(i)?o[a]=kr({},i):Ur(i)?o[a]=i.slice():o[a]=i}for(var t=0,r=arguments.length;t<r;t++)$r(arguments[t],e);return o}function Yo(o,e,t){return $r(e,function(i,a){t&&typeof i=="function"?o[a]=Bo(i,t):o[a]=i}),o}function Wo(o){return o.charCodeAt(0)===65279&&(o=o.slice(1)),o}fi.exports={isArray:Ur,isArrayBuffer:Lo,isBuffer:No,isFormData:Go,isArrayBufferView:Vo,isString:Uo,isNumber:Do,isObject:di,isPlainObject:Ne,isUndefined:Dr,isDate:$o,isFile:ko,isBlob:Ho,isFunction:hi,isStream:qo,isURLSearchParams:jo,isStandardBrowserEnv:Ko,forEach:$r,merge:kr,extend:Yo,trim:Xo,stripBOM:Wo}});var Hr=h((Aa,gi)=>{"use strict";var W=b();function yi(o){return encodeURIComponent(o).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}gi.exports=function(e,t,r){if(!t)return e;var i;if(r)i=r(t);else if(W.isURLSearchParams(t))i=t.toString();else{var a=[];W.forEach(t,function(p,u){p===null||typeof p=="undefined"||(W.isArray(p)?u=u+"[]":p=[p],W.forEach(p,function(c){W.isDate(c)?c=c.toISOString():W.isObject(c)&&(c=JSON.stringify(c)),a.push(yi(u)+"="+yi(c))}))}),i=a.join("&")}if(i){var s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}});var Mi=h((Ba,wi)=>{"use strict";var Jo=b();function Le(){this.handlers=[]}Le.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1};Le.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};Le.prototype.forEach=function(e){Jo.forEach(this.handlers,function(r){r!==null&&e(r)})};wi.exports=Le});var Ii=h((Na,bi)=>{"use strict";var zo=b();bi.exports=function(e,t){zo.forEach(e,function(i,a){a!==t&&a.toUpperCase()===t.toUpperCase()&&(e[t]=i,delete e[a])})}});var qr=h((La,Ri)=>{"use strict";Ri.exports=function(e,t,r,i,a){return e.config=t,r&&(e.code=r),e.request=i,e.response=a,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 jr=h((Ga,Fi)=>{"use strict";var Qo=qr();Fi.exports=function(e,t,r,i,a){var s=new Error(e);return Qo(s,t,r,i,a)}});var vi=h((Va,Pi)=>{"use strict";var Zo=jr();Pi.exports=function(e,t,r){var i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(Zo("Request failed with status code "+r.status,r.config,null,r.request,r))}});var Ti=h((Ua,Si)=>{"use strict";var Ge=b();Si.exports=Ge.isStandardBrowserEnv()?function(){return{write:function(t,r,i,a,s,n){var p=[];p.push(t+"="+encodeURIComponent(r)),Ge.isNumber(i)&&p.push("expires="+new Date(i).toGMTString()),Ge.isString(a)&&p.push("path="+a),Ge.isString(s)&&p.push("domain="+s),n===!0&&p.push("secure"),document.cookie=p.join("; ")},read:function(t){var r=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()});var Ci=h((Da,Ei)=>{"use strict";Ei.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}});var Oi=h(($a,_i)=>{"use strict";_i.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}});var Ai=h((ka,xi)=>{"use strict";var ea=Ci(),ta=Oi();xi.exports=function(e,t){return e&&!ea(t)?ta(e,t):t}});var Ni=h((Ha,Bi)=>{"use strict";var Xr=b(),ra=["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"];Bi.exports=function(e){var t={},r,i,a;return e&&Xr.forEach(e.split(`
|
|
2
|
+
`),function(n){if(a=n.indexOf(":"),r=Xr.trim(n.substr(0,a)).toLowerCase(),i=Xr.trim(n.substr(a+1)),r){if(t[r]&&ra.indexOf(r)>=0)return;r==="set-cookie"?t[r]=(t[r]?t[r]:[]).concat([i]):t[r]=t[r]?t[r]+", "+i:i}}),t}});var Vi=h((qa,Gi)=>{"use strict";var Li=b();Gi.exports=Li.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a"),r;function i(a){var s=a;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 r=i(window.location.href),function(s){var n=Li.isString(s)?i(s):s;return n.protocol===r.protocol&&n.host===r.host}}():function(){return function(){return!0}}()});var be=h((ja,Ui)=>{"use strict";function Kr(o){this.message=o}Kr.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};Kr.prototype.__CANCEL__=!0;Ui.exports=Kr});var Wr=h((Xa,Di)=>{"use strict";var Ve=b(),ia=vi(),oa=Ti(),aa=Hr(),sa=Ai(),na=Ni(),la=Vi(),Yr=jr(),pa=Ie(),ca=be();Di.exports=function(e){return new Promise(function(r,i){var a=e.data,s=e.headers,n=e.responseType,p;function u(){e.cancelToken&&e.cancelToken.unsubscribe(p),e.signal&&e.signal.removeEventListener("abort",p)}Ve.isFormData(a)&&delete s["Content-Type"];var l=new XMLHttpRequest;if(e.auth){var c=e.auth.username||"",w=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";s.Authorization="Basic "+btoa(c+":"+w)}var we=sa(e.baseURL,e.url);l.open(e.method.toUpperCase(),aa(we,e.params,e.paramsSerializer),!0),l.timeout=e.timeout;function ci(){if(!!l){var C="getAllResponseHeaders"in l?na(l.getAllResponseHeaders()):null,Y=!n||n==="text"||n==="json"?l.responseText:l.response,H={data:Y,status:l.status,statusText:l.statusText,headers:C,config:e,request:l};ia(function(Lr){r(Lr),u()},function(Lr){i(Lr),u()},H),l=null}}if("onloadend"in l?l.onloadend=ci:l.onreadystatechange=function(){!l||l.readyState!==4||l.status===0&&!(l.responseURL&&l.responseURL.indexOf("file:")===0)||setTimeout(ci)},l.onabort=function(){!l||(i(Yr("Request aborted",e,"ECONNABORTED",l)),l=null)},l.onerror=function(){i(Yr("Network Error",e,null,l)),l=null},l.ontimeout=function(){var Y=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",H=e.transitional||pa.transitional;e.timeoutErrorMessage&&(Y=e.timeoutErrorMessage),i(Yr(Y,e,H.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",l)),l=null},Ve.isStandardBrowserEnv()){var mi=(e.withCredentials||la(we))&&e.xsrfCookieName?oa.read(e.xsrfCookieName):void 0;mi&&(s[e.xsrfHeaderName]=mi)}"setRequestHeader"in l&&Ve.forEach(s,function(Y,H){typeof a=="undefined"&&H.toLowerCase()==="content-type"?delete s[H]:l.setRequestHeader(H,Y)}),Ve.isUndefined(e.withCredentials)||(l.withCredentials=!!e.withCredentials),n&&n!=="json"&&(l.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&l.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&l.upload&&l.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(p=function(C){!l||(i(!C||C&&C.type?new ca("canceled"):C),l.abort(),l=null)},e.cancelToken&&e.cancelToken.subscribe(p),e.signal&&(e.signal.aborted?p():e.signal.addEventListener("abort",p))),a||(a=null),l.send(a)})}});var Ie=h((Ka,Hi)=>{"use strict";var y=b(),$i=Ii(),ma=qr(),ua={"Content-Type":"application/x-www-form-urlencoded"};function ki(o,e){!y.isUndefined(o)&&y.isUndefined(o["Content-Type"])&&(o["Content-Type"]=e)}function da(){var o;return typeof XMLHttpRequest!="undefined"?o=Wr():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(o=Wr()),o}function ha(o,e,t){if(y.isString(o))try{return(e||JSON.parse)(o),y.trim(o)}catch(r){if(r.name!=="SyntaxError")throw r}return(t||JSON.stringify)(o)}var Ue={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:da(),transformRequest:[function(e,t){return $i(t,"Accept"),$i(t,"Content-Type"),y.isFormData(e)||y.isArrayBuffer(e)||y.isBuffer(e)||y.isStream(e)||y.isFile(e)||y.isBlob(e)?e:y.isArrayBufferView(e)?e.buffer:y.isURLSearchParams(e)?(ki(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):y.isObject(e)||t&&t["Content-Type"]==="application/json"?(ki(t,"application/json"),ha(e)):e}],transformResponse:[function(e){var t=this.transitional||Ue.transitional,r=t&&t.silentJSONParsing,i=t&&t.forcedJSONParsing,a=!r&&this.responseType==="json";if(a||i&&y.isString(e)&&e.length)try{return JSON.parse(e)}catch(s){if(a)throw s.name==="SyntaxError"?ma(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, */*"}}};y.forEach(["delete","get","head"],function(e){Ue.headers[e]={}});y.forEach(["post","put","patch"],function(e){Ue.headers[e]=y.merge(ua)});Hi.exports=Ue});var ji=h((Ya,qi)=>{"use strict";var fa=b(),ya=Ie();qi.exports=function(e,t,r){var i=this||ya;return fa.forEach(r,function(s){e=s.call(i,e,t)}),e}});var Jr=h((Wa,Xi)=>{"use strict";Xi.exports=function(e){return!!(e&&e.__CANCEL__)}});var Wi=h((Ja,Yi)=>{"use strict";var Ki=b(),zr=ji(),ga=Jr(),wa=Ie(),Ma=be();function Qr(o){if(o.cancelToken&&o.cancelToken.throwIfRequested(),o.signal&&o.signal.aborted)throw new Ma("canceled")}Yi.exports=function(e){Qr(e),e.headers=e.headers||{},e.data=zr.call(e,e.data,e.headers,e.transformRequest),e.headers=Ki.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Ki.forEach(["delete","get","head","post","put","patch","common"],function(i){delete e.headers[i]});var t=e.adapter||wa.adapter;return t(e).then(function(i){return Qr(e),i.data=zr.call(e,i.data,i.headers,e.transformResponse),i},function(i){return ga(i)||(Qr(e),i&&i.response&&(i.response.data=zr.call(e,i.response.data,i.response.headers,e.transformResponse))),Promise.reject(i)})}});var Zr=h((za,Ji)=>{"use strict";var R=b();Ji.exports=function(e,t){t=t||{};var r={};function i(l,c){return R.isPlainObject(l)&&R.isPlainObject(c)?R.merge(l,c):R.isPlainObject(c)?R.merge({},c):R.isArray(c)?c.slice():c}function a(l){if(R.isUndefined(t[l])){if(!R.isUndefined(e[l]))return i(void 0,e[l])}else return i(e[l],t[l])}function s(l){if(!R.isUndefined(t[l]))return i(void 0,t[l])}function n(l){if(R.isUndefined(t[l])){if(!R.isUndefined(e[l]))return i(void 0,e[l])}else return i(void 0,t[l])}function p(l){if(l in t)return i(e[l],t[l]);if(l in e)return i(void 0,e[l])}var u={url:s,method:s,data:s,baseURL:n,transformRequest:n,transformResponse:n,paramsSerializer:n,timeout:n,timeoutMessage:n,withCredentials:n,adapter:n,responseType:n,xsrfCookieName:n,xsrfHeaderName:n,onUploadProgress:n,onDownloadProgress:n,decompress:n,maxContentLength:n,maxBodyLength:n,transport:n,httpAgent:n,httpsAgent:n,cancelToken:n,socketPath:n,responseEncoding:n,validateStatus:p};return R.forEach(Object.keys(e).concat(Object.keys(t)),function(c){var w=u[c]||a,we=w(c);R.isUndefined(we)&&w!==p||(r[c]=we)}),r}});var ei=h((Qa,zi)=>{zi.exports={version:"0.24.0"}});var eo=h((Za,Zi)=>{"use strict";var ba=ei().version,ti={};["object","boolean","number","function","string","symbol"].forEach(function(o,e){ti[o]=function(r){return typeof r===o||"a"+(e<1?"n ":" ")+o}});var Qi={};ti.transitional=function(e,t,r){function i(a,s){return"[Axios v"+ba+"] Transitional option '"+a+"'"+s+(r?". "+r:"")}return function(a,s,n){if(e===!1)throw new Error(i(s," has been removed"+(t?" in "+t:"")));return t&&!Qi[s]&&(Qi[s]=!0,console.warn(i(s," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(a,s,n):!0}};function Ia(o,e,t){if(typeof o!="object")throw new TypeError("options must be an object");for(var r=Object.keys(o),i=r.length;i-- >0;){var a=r[i],s=e[a];if(s){var n=o[a],p=n===void 0||s(n,a,o);if(p!==!0)throw new TypeError("option "+a+" must be "+p);continue}if(t!==!0)throw Error("Unknown option "+a)}}Zi.exports={assertOptions:Ia,validators:ti}});var so=h((es,ao)=>{"use strict";var to=b(),Ra=Hr(),ro=Mi(),io=Wi(),De=Zr(),oo=eo(),J=oo.validators;function Re(o){this.defaults=o,this.interceptors={request:new ro,response:new ro}}Re.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=De(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&&oo.assertOptions(t,{silentJSONParsing:J.transitional(J.boolean),forcedJSONParsing:J.transitional(J.boolean),clarifyTimeoutError:J.transitional(J.boolean)},!1);var r=[],i=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(e)===!1||(i=i&&w.synchronous,r.unshift(w.fulfilled,w.rejected))});var a=[];this.interceptors.response.forEach(function(w){a.push(w.fulfilled,w.rejected)});var s;if(!i){var n=[io,void 0];for(Array.prototype.unshift.apply(n,r),n=n.concat(a),s=Promise.resolve(e);n.length;)s=s.then(n.shift(),n.shift());return s}for(var p=e;r.length;){var u=r.shift(),l=r.shift();try{p=u(p)}catch(c){l(c);break}}try{s=io(p)}catch(c){return Promise.reject(c)}for(;a.length;)s=s.then(a.shift(),a.shift());return s};Re.prototype.getUri=function(e){return e=De(this.defaults,e),Ra(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};to.forEach(["delete","get","head","options"],function(e){Re.prototype[e]=function(t,r){return this.request(De(r||{},{method:e,url:t,data:(r||{}).data}))}});to.forEach(["post","put","patch"],function(e){Re.prototype[e]=function(t,r,i){return this.request(De(i||{},{method:e,url:t,data:r}))}});ao.exports=Re});var lo=h((ts,no)=>{"use strict";var Fa=be();function z(o){if(typeof o!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(i){e=i});var t=this;this.promise.then(function(r){if(!!t._listeners){var i,a=t._listeners.length;for(i=0;i<a;i++)t._listeners[i](r);t._listeners=null}}),this.promise.then=function(r){var i,a=new Promise(function(s){t.subscribe(s),i=s}).then(r);return a.cancel=function(){t.unsubscribe(i)},a},o(function(i){t.reason||(t.reason=new Fa(i),e(t.reason))})}z.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};z.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};z.prototype.unsubscribe=function(e){if(!!this._listeners){var t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}};z.source=function(){var e,t=new z(function(i){e=i});return{token:t,cancel:e}};no.exports=z});var co=h((rs,po)=>{"use strict";po.exports=function(e){return function(r){return e.apply(null,r)}}});var uo=h((is,mo)=>{"use strict";mo.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var yo=h((os,ri)=>{"use strict";var ho=b(),Pa=Vr(),$e=so(),va=Zr(),Sa=Ie();function fo(o){var e=new $e(o),t=Pa($e.prototype.request,e);return ho.extend(t,$e.prototype,e),ho.extend(t,e),t.create=function(i){return fo(va(o,i))},t}var O=fo(Sa);O.Axios=$e;O.Cancel=be();O.CancelToken=lo();O.isCancel=Jr();O.VERSION=ei().version;O.all=function(e){return Promise.all(e)};O.spread=co();O.isAxiosError=uo();ri.exports=O;ri.exports.default=O});var Q=h((as,go)=>{go.exports=yo()});var oi=Me(Q());var ii=o=>{let e=[],t=0;return o.forEach(r=>{e[t]?e[t].length<249?e[t].push(r):(t=t+1,e[t]=[r]):e[t]=[r]}),e},ke=o=>{let e=[],t=200;for(;o.length>t-1;){let r=o.splice(0,t-1);e.push(r)}return e.push(o),e},x=(o,e)=>{let t="";return o==="prod"||o==="sandbox"?t={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"}[e]:t={profile:"http://localhost:8010",football:"http://locahost:8080",idMapping:"http://localhost:8030",predictor:"http://localhost:8040",client:"http://localhost:8080"}[e],t},L=o=>o.filter((t,r,i)=>r===i.indexOf(t));var He=class{id=null;name=null;avatar=null;gender=null;country=null;birthDate=null;interests=[]};var qe=class{profilesFromResponse=e=>e?e.map(t=>this.fullProfileFromResponse(t)):null;fullProfileFromResponse=e=>{let t=new He;return t.avatar=e.avatar,t.birthDate=e.birth_date,t.country=e.country,t.gender=e.gender,t.id=e.id,t.interests=e.interests,t.name=e.name,t};profileToRequest=e=>({country_id:e.country?e.country.id:null,gender:e.gender,birth_date:e.birthDate,interests:e.interests,name:e.name})};var je=class{avatar=null;followingId=null;name=null;profileId=null};var Xe=class{followingFromResponse=e=>e.map(t=>this.remapResponse(t));remapResponse=e=>{let t=new je;return t.avatar=e.avatar,t.followingId=e.following_id,t.name=e.name,t.profileId=e.profile_id,t}};var Ke=class{avatar=null;followerId=null;name=null;profileId=null};var Ye=class{followersFromResponse=e=>e.map(t=>this.remapResponse(t));remapResponse=e=>{let t=new Ke;return t.avatar=e.avatar,t.followerId=e.follower_id,t.name=e.name,t.profileId=e.profile_id,t}};var Fe=class{profile_ids=[]};var Ta="/countries",S="/profile",wo="/profiles",We=class{instanceAuth=null;instance=null;apiSignInUrl=null;profileRemapper=null;followingRemapper=null;followersRemapper=null;constructor(e){let t=x(e.environment,"profile");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}&lang=${e.lang}`,this.instanceAuth=oi.default.create({baseURL:t,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instance=oi.default.create({baseURL:t,headers:{"Content-Type":"application/json"}}),this.profileRemapper=new qe,this.followingRemapper=new Xe,this.followersRemapper=new Ye}getCountries=async()=>{try{return(await this.instance.get(`${Ta}${this.apiSignInUrl}`)).data.data}catch(e){throw console.warn("There was a problem fetching the countries:",e),e.response}};getProfile=async e=>{let t=`${S}${this.apiSignInUrl}`;if(e){t=`${wo}/${e}${this.apiSignInUrl}`;try{let r=await this.instance.get(t);return this.profileRemapper.fullProfileFromResponse(r.data.data)}catch(r){throw console.warn(`There was a problem fetching the following profile: ${e}`,r),r.response}}else try{let r=await this.instanceAuth.get(t);return this.profileRemapper.fullProfileFromResponse(r.data.data)}catch(r){throw console.warn(`There was a problem fetching the following profile: ${e}`,r),r.response}};getProfiles=async e=>{try{let t=await this.instance.get(`${wo}${this.apiSignInUrl}&profile_ids=${e.join(",")}`);return this.profileRemapper.profilesFromResponse(t.data.data)}catch(t){throw console.warn(`There was a problem fetching the following profiles: ${e.join(",")}`,t),t.response}};getFollowers=async(e,t)=>{let r=`${S}/followers${this.apiSignInUrl}`;if(e&&!t){r=`${S}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let i=await this.instanceAuth.get(r);return this.followersRemapper.followersFromResponse(i.data.data)}catch(i){throw console.warn("There was a problem fetching the followers for own profile",i),i.response}}else if(!e&&!t)try{let i=await this.instanceAuth.get(r);return this.followersRemapper.followersFromResponse(i.data.data)}catch(i){throw console.warn("There was a problem fetching the followers for own profile",i),i.response}e&&t?r=`${S}/${t}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(r=`${S}/${t}/followers${this.apiSignInUrl}`);try{let i=await this.instance.get(r);return this.followersRemapper.followersFromResponse(i.data.data)}catch(i){throw console.warn(`There was a problem fetching the followers for profile: ${t}`,i),i.response}};getFollowing=async(e,t)=>{let r=`${S}/following${this.apiSignInUrl}`;if(e&&!t){r=`${S}/following${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let i=await this.instanceAuth.get(r);return this.followingRemapper.followingFromResponse(i.data.data)}catch(i){throw console.warn("There was a problem fetching the followers of own profile",i),i.response}}else if(!e&&!t)try{let i=await this.instanceAuth.get(r);return this.followingRemapper.followingFromResponse(i.data.data)}catch(i){throw console.warn("There was a problem fetching the followers of own profile",i),i.response}e&&t?r=`${S}/${t}/following${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(r=`${S}/${t}/following${this.apiSignInUrl}`);try{let i=await this.instance.get(r);return this.followingRemapper.followingFromResponse(i.data.data)}catch(i){throw console.warn(`There was a problem fetching the followers of the following profile: ${t}`,i),i.response}};follow=async e=>{let t=new Fe;t.profile_ids=e;try{let r=await this.instanceAuth.post(`${S}/follow${this.apiSignInUrl}`,JSON.stringify(t));return this.followingRemapper.followingFromResponse(r.data.data)}catch(r){throw console.warn(`There was a problem with POST request for profiles: ${e.join(",")} `,r),r.response}};unfollow=async e=>{let t=new Fe;t.profile_ids=e;try{return await this.instanceAuth.delete(`${S}/follow${this.apiSignInUrl}`,{data:JSON.stringify(t)}),!0}catch(r){throw console.warn(`There was a problem with DELETE request for profiles: ${e.join(",")} `,r),r.response}};updateProfile=async e=>{try{let t=this.profileRemapper.profileToRequest(e),r=await this.instanceAuth.patch(`${S}${this.apiSignInUrl}`,t);return this.profileRemapper.fullProfileFromResponse(r.data.data)}catch(t){throw console.warn("There was a problem updating the own profile:",t),t.response}}};var N={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id"};var Mo="FansUnited",bo={football:{ids:[],countries:[],competitions:[]},profile:{own:{},countries:[],expireAt:0}},G=class{idSchema="";exparationTimeout=600;constructor(e){this.idSchema=e.idSchema,(this.getData()===void 0||this.getData()===null)&&this.setData(bo)}clearData=()=>{this.setData(bo)};getEntityById=(e="",t="")=>this.getData().football.ids.find(r=>{let i=N[this.idSchema];return r&&`${r[i]}`===t&&r.resource===e});getEntity=(e,t,r)=>Array.isArray(e)?this.getData().football.ids.filter(i=>{let a=N[r];return i&&e.includes(`${i[a]}`)&&i.resource===t}):this.getData().football.ids.find(i=>{let a=N[r];return i&&`${i[a]}`===e&&i.resource===t});getEntityByNativeId=(e="",t="")=>this.getData().football.ids.find(r=>r&&`${r.id}`===t&&r.resource===e);checkForExistingIdObjs=(e,t)=>{let r=N[t],i={};return Object.keys(e).forEach(a=>{let s=e[a],p=this.getEntity(s,a,t).map(l=>l[r]),u=e[a].filter(l=>!p.includes(l));i[a]=s.map(l=>u.includes(l)?{id:l,exists:!1}:{id:l,exists:!0})}),i};getIdsByType=(e,t,r)=>{let i=N[r],a=N[t],s={};return Object.keys(e).forEach(n=>{let p=e[n],u=[];this.getData().football.ids.forEach(l=>{p.forEach((c,w)=>{c===l[a]&&n===l.resource&&(u[w]=l[i])})}),s[n]=u}),s};addIdMapping=e=>{let t=this.getData();t.football.ids.push(e),this.setData(t)};addIdMappings=e=>{let t=this.getData(),r=t.football.ids;r=[...r,...e],t.football.ids=r,this.setData(t)};setOwnProfile=e=>{let t=this.getData();t.profile.own=e,t.profile.expireAt=Math.floor(Date.now()/1e3)+this.exparationTimeout,this.setData(t)};getOwnProfile=()=>this.getData().profile.own;getProfileCountries=()=>this.getData().profile.countries;setProfileCountries=e=>{let t=this.getData();t.profile.countries=e,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();t.football.competitions.push(...e),this.setData(t)};getExparationProfile=()=>this.getData().profile.expireAt;getData=()=>JSON.parse(localStorage.getItem(Mo));setData=e=>{localStorage.setItem(Mo,JSON.stringify(e))}};var Io=Me(Q());var Pe={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},Je=class{instance=null;apiSignInUrl="";constructor(e){let t=x(e.environment,"idMapping");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instance=Io.default.create({baseURL:t})}getEntityById=(e,t)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${config.idSchema}&${Pe[e]}=${t}`)}catch(r){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,r),r.response}};getEntityByIdAndSchema=(e,t,r)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${Pe[e]}=${t}`)}catch(i){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,i),i.response}};getEntityIdsByIdsAndSchema=(e,t,r)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${Pe[e]}=${t.join(",")}`)}catch(i){throw console.warn(`There was a problem with id mapping request for the following ids:${t.join(",")}`,i),i.response}};getEntitiesByIds=(e,t,r)=>{t.sort((s,n)=>s.localeCompare(n));let a=ii(t).map(s=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${Pe[e]}=${s.join(",")}`)}catch(n){throw console.warn(`There was a problem with id mapping request for the following ids:${s.join(",")}`,n),n.response}});return Promise.all(a).then(s=>{let n=[];return s.forEach(p=>{n.push(...p.data.data)}),n})};getEntitiesByIdObjs=async(e,t)=>{let r="";if(Object.keys(e).forEach(i=>{if(e[i].length>0){let a=L(e[i]);ii(a).map(n=>{n.sort((p,u)=>p.localeCompare(u)),r+="&",r+=`${Pe[i]}=${n.join(",")}`})}}),r&&r.length>0)try{return(await this.instance.get(`/football${this.apiSignInUrl}&input_provider=${t||"native"}${r}`)).data.data}catch(i){throw console.warn("There was a problem with id mapping request",i),i.response}else return[]}};var ze=class{isBrowser=!1;localStorage=null;https=null;constructor(e){this.isBrowser=typeof window!="undefined",this.localStorage=new G(e),this.https=new Je(e)}getEntitiesByIds=async(e,t,r)=>{if(this.isBrowser)try{let i=this.localStorage.checkForExistingIdObjs(e,t),a=this.splitForRequestAndExisting(i),s=await this.https.getEntitiesByIdObjs(a.request,t);return this.localStorage.addIdMappings(s),this.localStorage.getIdsByType(e,t,r)}catch(i){return console.warn("There was a problem retrieving the entity ids ",i),Promise.resolve([])}else try{let i=await this.https.getEntitiesByIdObjs(e,t);return Object.keys(e).forEach(a=>{e[a]=i.filter(s=>s.resource===a).map(s=>s[N[r]])}),e}catch(i){return console.warn("There was a problem retrieving the entity ids ",i),Promise.resolve([])}};getEntityById=async(e,t,r)=>{if(this.isBrowser){let i=this.localStorage.getEntity(e,t,r);if(i)return i;{let a=await this.requestEntity(e,t,r);return this.localStorage.addIdMappings(a),a}}else return await this.requestEntity(e,t,r)};splitForRequestAndExisting=e=>{let t={},r={};return Object.keys(e).forEach(i=>{t[i]=e[i].filter(a=>!a.exists).map(a=>a.id),r[i]=e[i].filter(a=>a.exists).map(a=>a.id)}),{existing:r,request:t}};requestEntity=async(e,t,r)=>{try{return e=Array.isArray(e)?e:[e],await this.https.getEntitiesByIds(t,e,r)}catch(i){return console.warn(`There was a problem retrieving the requested entity: ${i}`),null}}};var Qe=o=>{switch(o){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 o}};var Ze=class{extractedObjIds={};traverse=(e,t)=>(t=Qe(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(r=>{this.traverseObjExtract(r,t)})};traverseObjExtract=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(r=>{let i=e[r];r==="id"||r==="teamId"?(this.extractedObjIds.hasOwnProperty(t)||(this.extractedObjIds[t]=[]),this.extractedObjIds[t].push(i)):e[r]&&this.traverse(e[r],r)})}};var et=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(e,t,r)=>(t=Qe(t),this.replaceObjIdsIndex===null&&(this.initReplaceObjIdsIndex(r),this.remappedIdsObj=r),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(r=>{this.traverseObjReplace(r,t)})};traverseObjReplace=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(r=>{r==="id"||r==="teamId"?(e[r]=this.remappedIdsObj[t][this.replaceObjIdsIndex[t]],this.replaceObjIdsIndex[t]=this.replaceObjIdsIndex[t]+1):e[r]&&this.traverse(e[r],r,this.remappedIdsObj)})}};var T=class{idSchema="";idMappingFacade=null;constructor(e){this.idSchema=e.idSchema,this.idMappingFacade=new ze(e)}getEntityIdBySchemaId=(e,t)=>this.idMappingFacade.getEntityById(e,t,this.idSchema);remapEntities=async(e,t)=>{let r=JSON.parse(JSON.stringify(e));try{if(this.idSchema!=="native"){let a=new Ze().traverse(r,t);return this.idMappingFacade.getEntitiesByIds(a,"native",this.idSchema).then(s=>new et().traverse(r,t,s))}else return e}catch(i){return console.warn(`There was a problem remapping entity: ${t} with inner entity `,i),[]}};getEntityIdsBySchemaId=async(e,t,r)=>{let i={};return i[t]=e,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(i,this.idSchema,r):i}};var F=class{completed=!1;percentage;constructor(e){this.percentage=e}};var tt=class{teamFollowed=new F(10);teamFavourite=new F(15);playerFollowed=new F(10);playerFavourite=new F(10);competitionFollowed=new F(10);competitionFavourite=new F(5);addedBirthdate=new F(10);addedGender=new F(10);addedCountry=new F(10);addedAvatar=new F(10)};var rt=class{totalPercentage;breakdown=new tt};var Se=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 V=class{isBrowser=!1;localStorage={};https=null;constructor(e,t){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.https=t}getOwn=async()=>{if(this.isBrowser){let e=Math.floor(Date.now()/1e3),t=this.localStorage.getExparationProfile(),r=null;if(t>e&&(r=this.localStorage.getOwnProfile()),r)return r;try{let i=await this.https.getProfile();return this.localStorage.setOwnProfile(i),i}catch(i){throw console.warn("There was a problem retrieving your profile: ",i),i}}else try{return await this.https.getProfile()}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};getByIds=async e=>{try{return await this.https.getProfiles(e)}catch(t){throw console.warn(`There was a problem retrieving the selected profiles: ${e.join(",")} `,t),t}};getById=async e=>{try{return await this.https.getProfile(e)}catch(t){throw console.warn(`There was a problem retrieving the selected profile: ${e} `,t),t}};getCountries=async()=>{if(this.isBrowser){let e=this.localStorage.getProfileCountries();if(e&&e.length>0)return e;try{let t=await this.https.getCountries();return this.localStorage.setProfileCountries(t),t}catch(t){throw console.warn("There was a problem retrieving profile countries: ",t),t}}else try{return await this.https.getCountries()}catch(e){throw console.warn("There was a problem retrieving profile countries: ",e),e}};getFollowers=async(e,t)=>{try{return e&&(e=new Se(e)),await this.https.getFollowers(e,t)}catch(r){throw console.warn("There was a problem retrieving your followers: ",r),r}};getFollowing=async(e,t)=>{try{return e&&(e=new Se(e)),await this.https.getFollowing(e,t)}catch(r){throw console.warn("There was a problem retrieving your following profiles: ",r),r}};follow=async e=>{try{return await this.https.follow(e)}catch(t){throw console.warn(`There was a problem following profiles: ${e.join(",")} `,t),t}};unfollow=async e=>{try{return await this.https.unfollow(e)}catch(t){throw console.warn(`There was a problem unfollowing profiles: ${e.join(",")} `,t),t}};showFullnessProfile=e=>{let t=new rt,r=0;return e.avatar&&(t.breakdown.addedAvatar.completed=!0,r+=t.breakdown.addedAvatar.percentage),e.birthDate&&(t.breakdown.addedBirthdate.completed=!0,r+=t.breakdown.addedBirthdate.percentage),e.country&&(t.breakdown.addedCountry.completed=!0,r+=t.breakdown.addedCountry.percentage),e.gender&&(t.breakdown.addedGender.completed=!0,r+=t.breakdown.addedGender.percentage),e.interests&&e.interests.length>0&&(e.interests.find(l=>l.type==="team"&&l.favourite)&&(t.breakdown.teamFavourite.completed=!0,r+=t.breakdown.teamFavourite.percentage),e.interests.find(l=>l.type==="team")&&(t.breakdown.teamFollowed.completed=!0,r+=t.breakdown.teamFollowed.percentage),e.interests.find(l=>l.type==="player"&&l.favourite)&&(t.breakdown.playerFavourite.completed=!0,r+=t.breakdown.playerFavourite.percentage),e.interests.find(l=>l.type==="player")&&(t.breakdown.playerFollowed.completed=!0,r+=t.breakdown.playerFollowed.percentage),e.interests.find(l=>l.type==="competition"&&l.favourite)&&(t.breakdown.competitionFavourite.completed=!0,r+=t.breakdown.competitionFavourite.percentage),e.interests.find(l=>l.type==="competition")&&(t.breakdown.competitionFollowed.completed=!0,r+=t.breakdown.competitionFollowed.percentage)),t.totalPercentage=r,t}};var it=class{id=null;name=null;assets=null};var ot=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,r){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=r,this.https=t}getCountriesWithIdMapping=async()=>{try{let e=await this.getCountries();return this.idMapping.remapEntities(e,"country")}catch(e){throw console.warn("There was a problem browsing countries as football entities",e),e}};getCountries=async()=>{if(this.isBrowser){let e=this.localStorage.getFootballCountries();if(e&&e.length>0)return e;try{let t=await this.https.getCountries();return this.localStorage.setFootballCountries(t),t}catch(t){throw console.warn("There was a problem retrieving countries as football entities",t),t}}else return this.https.getCountries()}};var at=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(r=>{let i=!0;return t.forEach(a=>{a!=="sortOrder"&&a!=="sortField"&&(a==="countryId"?i&&=r.country.id===this[a]:a==="name"?i&&=r.name.toLocaleLowerCase().includes(this[a].toLocaleLowerCase()):a==="competitionIds"?i&&=this[a].some(s=>r.id===s):i&&=r[a].toLocaleLowerCase()===this[a].toLocaleLowerCase())}),i})};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((r,i)=>this.sortOrder&&this.sortOrder==="desc"?i.name.localeCompare(r.name):r.name.localeCompare(i.name)):this.sortField==="countryId"?t=e.sort((r,i)=>this.sortOrder&&this.sortOrder==="desc"?i.country.id.localeCompare(r.country.id):r.country.id.localeCompare(i.country.id)):this.sortField==="scope"?e.forEach(r=>t[this.competitionIds.indexOf(r.id)]=r):!this.sortField&&this.sortOrder==="desc"&&(t=e.sort((r,i)=>i.id.localeCompare(r.id))),t}};var st=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,r){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=r,this.https=t}getCompetitionsIdMapping=async e=>{try{let t=!1;if(e){if(e=new at(e),e.countryId){let i=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");i.country.length===0&&(t=!0),e.countryId=i.country[0]}if(e.competitionIds){let i=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");i.competition.length===0&&(t=!0),e.competitionIds=i.competition}if(t)return[]}let r=await this.getCompetitions(e);return await this.idMapping.remapEntities(r,"competition")}catch(t){throw console.warn("There was a problem browsing all of the competitions",t),t}};getCompetitions=async e=>{if(this.isBrowser){let t=this.localStorage.getCompetitions(e);if(t&&t.length>0)return t;try{let r=await this.https.getCompetitions(e);return this.localStorage.setCompetitions(r),this.localStorage.getCompetitions(e)}catch(r){throw console.warn("There was a problem retrieving all competitions",r),r}}else return this.https.getCompetitions(e)};getCompetitionByIdIdMapping=async e=>{try{let r=(await this.idMapping.getEntityIdsBySchemaId([e],"competition","native")).competition[0],i=await this.getCompetitionById(r);return await this.idMapping.remapEntities(i,"competition")}catch(t){throw console.warn(`There was a problem browsing the following competition:${e}`,t),t}};getCompetitionById=async e=>{try{return await this.https.getCompetitionById(e)}catch(t){throw console.warn(`There was a problem retrieving the competition with the following id: ${e}`,t),t}};getTopCompetitionsIdMapping=async()=>{try{let e=await this.getTopCompetitions();return await this.idMapping.remapEntities(e,"competition")}catch(e){throw console.warn("There was a problem browsing the top competitions",e),e}};getTopCompetitions=async()=>{try{return await this.https.getTopCompetitions()}catch(e){throw console.warn("There was a problem retrieving the top competitions",e),e}}};var nt=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 lt=class{https=null;idMapping=null;constructor(e,t){this.idMapping=t,this.https=e}getTeamsIdMapping=async e=>{try{let t=!1;if(e){if(e=new nt(e),e.countryId){let i=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");i.country.length===0&&(t=!0),e.countryId=i.country[0]}if(e.scope){let i=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");i.competition.length===0&&(t=!0),e.scope=i.competition}if(e.teamIds){let i=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");i.team.length===0&&(t=!0),e.teamIds=i.team}}if(t)return[];let r=await this.getTeams(e);return await this.idMapping.remapEntities(r,"team")}catch(t){throw console.warn("There was a problem browsing all teams",t),t}};getTeams=async e=>{try{return await this.https.getTeams(e)}catch(t){throw console.warn("There was a problem retrieving all teams",t),t}};getTeamByIdIdMapping=async e=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let r=await this.getTeamById(e);return await this.idMapping.remapEntities(r,"team")}catch(t){throw console.warn(`There was a problem browsing the following team:${e}`,t),t}};getTeamById=async e=>{try{return await this.https.getTeamById(e)}catch(t){throw console.warn(`There was a problem retrieving the following team: ${e}`,t),t}};getTopTeamsIdMapping=async()=>{try{let e=await this.getTopTeams();return await this.idMapping.remapEntities(e,"team")}catch(e){throw console.warn("There was a problem browsing the top teams",e),e}};getTopTeams=async()=>{try{return await this.https.getTopTeams()}catch(e){throw console.warn("There was a problem retrieving the top teams",e),e}};getNextMatchForTeamIdMapping=async e=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let r=await this.getNextMatchForTeam(e);return await this.idMapping.remapEntities(r,"match")}catch(t){throw console.warn(`There was a problem browsing the next match for the following team:${e}`,t),t}};getNextMatchForTeam=async e=>{try{return await this.https.getNextMatchForTeam(e)}catch(t){throw console.warn(`There was a problem retrieving the next match for the following team: ${e}`,t),t}};getPrevMatchForTeamIdMapping=async e=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let r=await this.getPrevMatchForTeam(e);return await this.idMapping.remapEntities(r,"match")}catch(t){throw console.warn(`There was a problem browsing the previous match for the following team:${e}`,t),t}};getPrevMatchForTeam=async e=>{try{return await this.https.getPrevMatchForTeam(e)}catch(t){throw console.warn(`There was a problem retrieving the previous match for the following team: ${e}`,t),t}}};var Te=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 Z=class{https=null;idMapping=null;constructor(e,t){this.idMapping=t,this.https=e}getPlayersIdMapping=async e=>{try{let t=!1;if(e){if(e=new Te(e),e.countryId){let i=await this.idMapping.getEntityIdsBySchemaId([e.countryId],"country","native");i.country.length===0&&(t=!0),e.countryId=i.country[0]}if(e.playerIds){let i=await this.idMapping.getEntityIdsBySchemaId(e.playerIds,"player","native");i.player.length===0&&(t=!0),e.playerIds=i.player}if(e.scope){let i=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");i.competition.length===0&&(t=!0),e.scope=i.competition}if(t)return[]}let r=await this.getPlayers(e);return await this.idMapping.remapEntities(r,"player")}catch(t){throw console.warn("There was a problem browsing the players",t),t}};getPlayersWithNativeIds=async e=>{let t=new Te({playerIds:e}),r=await this.getPlayers(t);return r.sort((i,a)=>i.id.localeCompare(a.id)),await this.idMapping.remapEntities(r,"player")};getPlayersMapWithNativeIds=async e=>{let t={},r=L(e);r.sort((a,s)=>a.localeCompare(s));let i=await this.getPlayersWithNativeIds(r);return r.forEach((a,s)=>t[a]=i[s]),t};getPlayers=async e=>{try{return await this.https.getPlayers(e)}catch(t){throw console.warn("There was a problem retrieving the players",t),t}};getPlayerIdMapping=async e=>{try{let t=await this.idMapping.getEntityIdsBySchemaId([e],"player","native"),r=await this.getPlayerById(t.player[0]);return await this.idMapping.remapEntities(r,"player")}catch(t){throw console.warn(`There was a problem browsing the following player:${e}`,t),t}};getPlayerById=async e=>{try{return await this.https.getPlayerById(e)}catch(t){throw console.warn(`There was a problem retrieving the following player: ${e}`,t),t}};getTopPlayersIdMapping=async()=>{try{let e=await this.getTopPlayers();return await this.idMapping.remapEntities(e,"player")}catch(e){throw console.warn("There was a problem browsing the top players",e),e}};getTopPlayers=async()=>{try{return await this.https.getTopPlayers()}catch(e){throw console.warn("There was a problem retrieving the top players",e),e}};getNextMatchForPlayerIdMapping=async e=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let r=await this.getNextMatchForPlayer(e);return await this.idMapping.remapEntities(r,"match")}catch(t){throw console.warn(`There was a problem browsing the next match for player:${e}`,t),t}};getNextMatchForPlayer=async e=>{try{return await this.https.getNextMatchForPlayer(e)}catch(t){throw console.warn(`There was a problem retrieving the next match for player: ${e}`,t),t}};getPrevMatchForPlayerIdMapping=async e=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let r=await this.getPrevMatchForPlayer(e);return await this.idMapping.remapEntities(r,"match")}catch(t){throw console.warn(`There was a problem browsing the previous match for player:${e}`,t),t}};getPrevMatchForPlayer=async e=>{try{return await this.https.getPrevMatchForPlayer(e)}catch(t){throw console.warn(`There was a problem retrieving the previous match for player: ${e}`,t),t}}};var Ee=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 U=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}getMatchesIdMapping=async e=>{try{if(e){if(e=new Ee(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 t=await this.getMatches(e);return await this.idMapping.remapEntities(t,"match")}catch(t){throw console.warn("There was a problem browsing the matches",t),t}};getMatchesWithNativeIds=async e=>{let t=new Ee({matchIds:e}),r=await this.getMatches(t);return r.sort((i,a)=>i.id.localeCompare(a.id)),await this.idMapping.remapEntities(r,"match")};getMatchesMapWithNativeIds=async e=>{let t={},r=L(e);r.sort((a,s)=>a.localeCompare(s));let i=await this.getMatchesWithNativeIds(r);return r.forEach((a,s)=>t[a]=i[s]),t};getMatches=async e=>{try{return await this.https.getMatches(e)}catch(t){throw console.warn("There was a problem retrieving the matches",t),t}};getMatchIdMapping=async e=>{try{let t=await this.idMapping.getEntityIdsBySchemaId([e],"match","native"),r=await this.getMatchById(t.match[0]);return await this.idMapping.remapEntities(r,"match")}catch(t){throw console.warn(`There was a problem browsing the following match: ${e}`,t),t}};getMatchById=async e=>{try{return await this.https.getMatchById(e)}catch(t){throw console.warn(`There was a problem retrieving the following match: ${e}`,t),t}}};var pt=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 ct=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}searchIdMapping=async e=>{try{if(e=new pt(e),e.scope){let r=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");e.scope=r.competition}let t=await this.search(e);if(t.teams&&t.teams.length>0){let r=await this.idMapping.remapEntities(t.teams,"team");t.teams=r}if(t.players&&t.players.length>0){let r=await this.idMapping.remapEntities(t.players,"player");t.players=r}if(t.competitions&&t.competitions.length>0){let r=await this.idMapping.remapEntities(t.competitions,"competition");t.competitions=r}return t}catch(t){throw console.warn("There was a problem with browsing the search result",t),t}};search=async e=>{try{return await this.https.search(e)}catch(t){throw console.warn("There was a problem retrieving the search response",t),t}}};var D=class{isBrowser=!1;localStorage={};https=null;idMapping=null;countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(e,t,r){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=r,this.https=t,this.countriesFacade=new ot(e,t,r),this.competitionsFacade=new st(e,t,r),this.teamsFacade=new lt(t,r),this.playerFacade=new Z(t,r),this.matchFacade=new U(t,r),this.searchFacade=new ct(t,r)}getCountries=async()=>this.countriesFacade.getCountriesWithIdMapping();getCompetitions=async e=>this.competitionsFacade.getCompetitionsIdMapping(e);getCompetitionById=async e=>this.competitionsFacade.getCompetitionByIdIdMapping(e);getTopCompetitions=async()=>this.competitionsFacade.getTopCompetitionsIdMapping();getTeams=async e=>this.teamsFacade.getTeamsIdMapping(e);getTeamById=async e=>this.teamsFacade.getTeamByIdIdMapping(e);getTopTeams=async()=>this.teamsFacade.getTopTeamsIdMapping();getNextMatchForTeam=async e=>this.teamsFacade.getNextMatchForTeamIdMapping(e);getPrevMatchForTeam=async e=>this.teamsFacade.getPrevMatchForTeamIdMapping(e);getPlayers=async e=>this.playerFacade.getPlayersIdMapping(e);getPlayerById=async e=>this.playerFacade.getPlayerIdMapping(e);getTopPlayers=async()=>this.playerFacade.getTopPlayersIdMapping();getNextMatchForPlayer=async e=>this.playerFacade.getNextMatchForPlayerIdMapping(e);getPrevMatchForPlayer=async e=>this.playerFacade.getPrevMatchForPlayerIdMapping(e);getMatches=async e=>this.matchFacade.getMatchesIdMapping(e);getMatchById=async e=>this.matchFacade.getMatchIdMapping(e);search=async e=>this.searchFacade.searchIdMapping(e)};var ee=class{idMapping=null;footballFacade=null;constructor(e,t){this.idMapping=e,this.footballFacade=t}remapInterestsToIdSchema=async e=>{let t=this.idMapping.idSchema;if(t!=="native")if(e.length>0){let r={},i={};e.forEach(n=>{r.hasOwnProperty(n.type)||(r[n.type]=[],i[n.type]=[]),r[n.type].push(n.id),i[n.type].push(n)});let a=await this.idMapping.idMappingFacade.getEntitiesByIds(r,"native",t),s=[];for(let[n,p]of Object.entries(i))p.forEach((u,l)=>{u.id=a[n][l],s.push(u)});return s}else return e;else return e};remapInterestToNative=async e=>{let t=this.idMapping.idSchema;if(t!=="native"){let r={},{id:i,type:a}=e;r[a]=[i];let s=await this.idMapping.idMappingFacade.getEntitiesByIds(r,t,"native");return e.id=s[a][0],e}return e};inquiryCustomInterests=async e=>{let t=[];if(e&&e.length>0&&(t=e.filter(r=>r.source==="custom")),t&&t.length>0){let r=e.filter(a=>a.source!=="custom"),i=await this.remapInterestsToIdSchema(r);return t.forEach(a=>i.push(a)),i}return await this.remapInterestsToIdSchema(e)};showFullInterests=async e=>{let t=[];if(e&&e.length>0)for(let r of e)if(r.source!=="custom"&&r.source==="football"){let i={};if(r.type==="team"){i.teamIds=[r.id];let a=await this.footballFacade.getTeams(i);r.model=a[0]}if(r.type==="player"){i.playerIds=[r.id];let a=await this.footballFacade.getPlayers(i);r.model=a[0]}if(r.type==="competition"){i.competitionIds=[r.id];let a=await this.footballFacade.getCompetitions(i);r.model=a[0]}r.model===void 0&&(r.model=null),t.push(r)}else t.push(r);return t}};var mt=class{profileHttps=null;footballHttps=null;localStorage=null;idMapping=null;profileFacade=null;footballFacade=null;interestsService=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;constructor(e,t,r,i){this.localStorage=e,this.profileHttps=t,this.footballHttps=i,this.idMapping=r,this.footballFacade=new D(e,i,r),this.interestsService=new ee(r,this.footballFacade),this.profileFacade=new V(e,t)}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;let t=await this.profileFacade.getOwn();return this.setOwnProfile(t),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=[];return t=e.interests,await this.interestsService.inquiryCustomInterests(t)};showFullInterests=async()=>{let e=await this.showInterests();return await this.interestsService.showFullInterests(e)};getFollowers=async e=>await this.profileFacade.getFollowers(e);getFollowing=async e=>await this.profileFacade.getFollowing(e);follow=async e=>await this.profileFacade.follow(e);unfollow=async e=>await this.profileFacade.unfollow(e);addInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;e.source!=="custom"?t=await this.interestsService.remapInterestToNative(e):t=e;let r=this.ownProfile.interests.filter(i=>i.id!==t.id||i.type!==t.type||i.source!==t.source);return this.ownProfile.interests=[...r],this.ownProfile.interests.push(t),this};addInterest=e=>(this.promises.push(this.addInterestPromise(e)),this);removeInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;return e.source!=="custom"?t=await this.interestsService.remapInterestToNative(e):t=e,this.ownProfile.interests=this.ownProfile.interests.filter(r=>r.id!==t.id||r.type!==t.type||r.source!==t.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);setCountryPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e&&!this.ownProfile.country?(this.ownProfile.country=new it,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)};update=async()=>{if(this.promises.length===0)return this.ownProfile;await Promise.all(this.promises);let e=await this.getOwnProfile(),t=await this.profileHttps.updateProfile(e);return this.modified=!1,this.expireAt=0,this.localStorage.setOwnProfile(t),delete t.interests,t}};var ut=class{profileHttps=null;footballFacade=null;localStorage=null;idMapping=null;profileFacade=null;interestsService=null;profileId="";constructor(e,t,r,i){this.localStorage=e,this.profileHttps=t,this.footballFacade=i,this.idMapping=r,this.interestsService=new ee(r,i),this.profileFacade=new V(e,t)}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=[];return t=e.interests,await this.interestsService.inquiryCustomInterests(t)};showFullInterests=async()=>{let e=await this.showInterests();return await this.interestsService.showFullInterests(e)};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)}};var Ro=Me(Q());var dt=class{id="";alias="";countryCode="";assets=null;name=""};var f=class{countriesFromResponse=e=>{if(e)return e.map(t=>this.countryFromResponse(t))};countryFromResponse=e=>{try{if(e){let t=new dt;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 ht=class{id="";country=null;gender="";assets=null;type="";name=""};var I=class{countryRemapper=null;constructor(){this.countryRemapper=new f}fromResponse(e){try{let t=new ht;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 ft=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var yt=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName=""};var g=class{countryRemapper=null;constructor(){this.countryRemapper=new f}fromResponse(e){try{let t=new yt;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}catch(t){throw console.warn("There was a problem remapping teams response",t),t}}};var gt=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new f,this.teamBasicRemapper=new g}fromResponse(e){try{let t=new ft;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(r=>this.teamBasicRemapper.fromResponse(r)),t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var wt=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";squad=[]};var Mt=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var bt=class{countryRemapper=null;constructor(){this.countryRemapper=new f}fromResponse(e){try{let t=new Mt;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 It=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new f,this.competitionRemapper=new I,this.playerRemapper=new bt}fromResponse(e){try{let t=new wt;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.competitions=e.competitions?e.competitions.map(r=>this.competitionRemapper.fromResponse(r)):[],t.squad=e.squad?e.squad.map(r=>this.playerRemapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping team response",t),t}}};var Rt=class{id="";kickoffAt="";finishedAt="";updatedAt="";homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;context={competition:null};status={type:null,subType:null}};var Ft=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var te=class{fromResponse(e){try{let t=new Ft;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 Pt=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new g,this.competitionRemapper=new I,this.scoresRemapper=new te}fromResponse(e){try{let t=new Rt;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,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 vt=class{id="";kickoffAt="";finishedAt="";updatedAt="";homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;stats=null;context={competition:null};timeline=[];status={type:null,subType:null};lineups=null};var St=class{corners=null;crosses=null;offside=null;shotsOn=null;throwIn=null;redCards=null;shotsOff=null;goalKicks=null;possession=null;treatments=null;yellowCards=null;shotsBlocked=null;substitutions=null;counterAttacks=null;foulsCommitted=null};var Tt=class{fromResponse(e){try{let t=new St;return t.corners=this.statEntityFromResponse(e.corners),t.crosses=this.statEntityFromResponse(e.crosses),t.offside=this.statEntityFromResponse(e.offside),t.shotsOn=this.statEntityFromResponse(e.shots_on),t.throwIn=this.statEntityFromResponse(e.throw_in),t.redCards=this.statEntityFromResponse(e.red_cards),t.shotsOff=this.statEntityFromResponse(e.shots_off),t.goalKicks=this.statEntityFromResponse(e.goal_kicks),t.possession=this.statEntityFromResponse(e.possession),t.treatments=this.statEntityFromResponse(e.treatments),t.yellowCards=this.statEntityFromResponse(e.yellow_cards),t.shotsBlocked=this.statEntityFromResponse(e.shots_blocked),t.substitutions=this.statEntityFromResponse(e.substitutions),t.counterAttacks=this.statEntityFromResponse(e.counter_attacks),t.foulsCommitted=this.statEntityFromResponse(e.fouls_committed),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 re=class{homeTeam={players:[]};awayTeam={players:[]}};var Et=class{id="";name="";position="";shirtNumber;assets=null;type=""};var ie=class{fromResponse(e){try{let t=new Et;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 Ct=class{playerRemapper=null;constructor(){this.playerRemapper=new ie}fromResponse(e){try{let t=new re;return t.homeTeam.players=e.home_team&&e.home_team.players?e.home_team.players.map(r=>this.playerRemapper.fromResponse(r)):[],t.awayTeam.players=e.away_team&&e.away_team.players?e.away_team.players.map(r=>this.playerRemapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping the lineups",t),t}}};var _t=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var Ot=class{playerRemapper=null;constructor(){this.playerRemapper=new ie}fromResponse(e){try{let t=new _t;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 xt=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new g,this.competitionsMapper=new I,this.lineupsMapper=new Ct,this.scoresMapper=new te,this.statsMapper=new Tt,this.timelineMapper=new Ot}fromResponse(e){try{let t=new vt;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,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(r=>this.timelineMapper.fromResponse(r)):[],t.status={type:e.status.type,subType:e.status.sub_type},t.lineups=e.lineups?this.lineupsMapper.fromResponse(e.lineups):new re,t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var At=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var Bt=class{countryRemapper=null;constructor(){this.countryRemapper=new f}fromResponse(e){try{let t=new At;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 Nt=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;teams=[]};var oe=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new f,this.teamRemapper=new g}fromResponse(e){try{let t=new Nt;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(r=>this.teamRemapper.fromResponse(r)):[],t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping players response",t),t}}};var Lt=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;competitions=[];teams=[]};var Gt=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new f,this.teamRemapper=new g,this.competitionRemapper=new I}fromResponse(e){try{let t=new Lt;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(r=>this.teamRemapper.fromResponse(r)):[],t.position=e.position,t.competitions=e.competitions?e.competitions.map(r=>this.competitionRemapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping player response",t),t}}};var Vt=class{teams=null;players=null;competitions=null};var Ut=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new g,this.playerRemapper=new oe,this.competitionremapper=new I}fromResponse(e){try{let t=new Vt;return t.teams=e.teams?e.teams.map(r=>this.teamRemapper.fromResponse(r)):[],t.players=e.players?e.players.map(r=>this.playerRemapper.fromResponse(r)):[],t.competitions=e.competitions?e.competitions.map(r=>this.competitionremapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping search response",t),t}}};var A=class{instance=null;apiSignInUrl="";idSchema="";limitIds=200;countryRemapper=null;competitionBasicRemapper=null;competitionFullRemapper=null;teamBasicRemapper=null;teamFullRemapper=null;matchBasicRemapper=null;matchFullRemapper=null;playerBasicRemapper=null;playerFullRemapper=null;topPlayerRemapper=null;searchRemapper=null;constructor(e){let t=x(e.environment,"football");this.apiSignInUrl=`?key=${e.apiKey}&lang=${e.lang}&client_id=${e.clientId}`,this.idSchema=e.idSchema,this.instance=Ro.default.create({baseURL:t}),this.countryRemapper=new f,this.competitionBasicRemapper=new I,this.competitionFullRemapper=new gt,this.teamBasicRemapper=new g,this.teamFullRemapper=new It,this.matchBasicRemapper=new Pt,this.matchFullRemapper=new xt,this.playerBasicRemapper=new oe,this.playerFullRemapper=new Gt,this.topPlayerRemapper=new Bt,this.searchRemapper=new Ut}getCountries=async()=>{try{let e=await this.instance.get(`/countries${this.apiSignInUrl}`);return this.countryRemapper.countriesFromResponse(e.data.data)}catch(e){throw console.warn("There was a problem with the football countries request",e),e}};getCompetitions=async e=>{try{let t={};if(e&&e.competitionIds&&e.competitionIds.length>this.limitIds-1){let r=[],i=ke(e.competitionIds);for(let s of i)e.competitionIds=s,t=await this.instance.get(`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`),r.push(t.data.data.map(n=>this.competitionBasicRemapper.fromResponse(n)));return Array.prototype.concat.apply([],r)}else return t=e?await this.instance.get(`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instance.get(`/competitions${this.apiSignInUrl}`),t.data.data.map(r=>this.competitionBasicRemapper.fromResponse(r))}catch(t){throw console.warn("There was a problem with getCompetitions request",t),t.response}};getCompetitionById=async e=>{try{let t=await this.instance.get(`/competitions/${e}${this.apiSignInUrl}`);return this.competitionFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getCompetitionById request",t),t.response}};getTopCompetitions=async()=>{try{return(await this.instance.get(`/competitions/top${this.apiSignInUrl}`)).data.data.map(t=>this.competitionBasicRemapper.fromResponse(t))}catch(e){throw console.warn("There was a problem with getTopCompetitions request",e),e.response}};getTeams=async e=>{try{let t={};if(e&&e.teamIds&&e.teamIds.length>this.limitIds-1){let r=[],i=ke(e.teamIds);for(let s of i)e.teamIds=s,t=await this.instance.get(`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`),r.push(t.data.data.map(n=>this.teamBasicRemapper.fromResponse(n)));return Array.prototype.concat.apply([],r)}else return t=e?await this.instance.get(`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instance.get(`/teams${this.apiSignInUrl}`),t.data.data.map(r=>this.teamBasicRemapper.fromResponse(r))}catch(t){throw console.warn("There was a problem with getTeams request",t),t.response}};getTeamById=async e=>{try{let t=await this.instance.get(`/teams/${e}${this.apiSignInUrl}`);return this.teamFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getTeamById request",t),t.response}};getTopTeams=async()=>{try{let e=await this.instance.get(`/teams/top${this.apiSignInUrl}`);return e.data.data?e.data.data.map(t=>this.teamBasicRemapper.fromResponse(t)):[]}catch(e){throw console.warn("There was a problem with getTopTeams request",e),e.response}};getNextMatchForTeam=async e=>{try{let t=await this.instance.get(`/teams/${e}/next-match${this.apiSignInUrl}`);return this.matchFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getNextMatchForTeam request",t),t.response}};getPrevMatchForTeam=async e=>{try{let t=await this.instance.get(`/teams/${e}/previous-match${this.apiSignInUrl}`);return this.matchFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getPrevMatchForTeam request",t),t.response}};getPlayers=async e=>{try{let t={};if(e&&e.playerIds&&e.playerIds.length>this.limitIds-1){let r=[],i=ke(e.playerIds);for(let s of i)e.playerIds=s,t=await this.instance.get(`/players${this.apiSignInUrl}${e.constructFilterUrl()}`),r.push(t.data.data.map(n=>this.teamBasicRemapper.fromResponse(n)));return Array.prototype.concat.apply([],r)}else return(e?await this.instance.get(`/players${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instance.get(`/players${this.apiSignInUrl}`)).data.data.map(i=>this.playerBasicRemapper.fromResponse(i))}catch(t){throw console.warn("There was a problem with getPlayers request",t),t.response}};getPlayerById=async e=>{try{let t=await this.instance.get(`/players/${e}${this.apiSignInUrl}`);return this.playerFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getPlayerById request",t),t.response}};getTopPlayers=async()=>{try{return(await this.instance.get(`/players/top${this.apiSignInUrl}`)).data.data.map(t=>this.topPlayerRemapper.fromResponse(t))}catch(e){throw console.warn("There was a problem with getTopPlayers request",e),e.response}};getNextMatchForPlayer=async e=>{try{let t=await this.instance.get(`/players/${e}/next-match${this.apiSignInUrl}`);return this.matchFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getNextMatchForPlayer request",t),t.response}};getPrevMatchForPlayer=async e=>{try{let t=await this.instance.get(`/players/${e}/previous-match${this.apiSignInUrl}`);return this.matchFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getPrevMatchForPlayer request",t),t.response}};getMatchById=async e=>{try{let t=await this.instance.get(`/matches/${e}${this.apiSignInUrl}`);return this.matchFullRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with getMatchById request",t),t.response}};getMatches=async e=>{try{return(e?await this.instance.get(`/matches${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instance.get(`/matches${this.apiSignInUrl}`)).data.data.map(r=>this.matchBasicRemapper.fromResponse(r))}catch(t){throw console.warn("There was a problem with getMatches request",t),t.response}};search=async e=>{try{let t=await this.instance.get(`/search${this.apiSignInUrl}${e.constructFilterUrl()}`);return this.searchRemapper.fromResponse(t.data.data)}catch(t){throw console.warn("There was a problem with search request",t),t.response}}};var Dt=class{profileHttps=null;footballHttps=null;footballFacade=null;idMapping=null;localStorage=null;profileFacade=null;ownProfileBuilder=null;profileBuilder=null;constructor(e){this.profileHttps=new We(e),this.footballHttps=new A(e),this.idMapping=new T(e),this.localStorage=new G(e),this.footballFacade=new D(this.localStorage,this.footballHttps,this.idMapping),this.profileFacade=new V(this.localStorage,this.profileHttps),this.ownProfileBuilder=new mt(this.localStorage,this.profileHttps,this.idMapping,this.footballHttps),this.profileBuilder=new ut(this.localStorage,this.profileHttps,this.idMapping,this.footballFacade)}getOwn=()=>this.ownProfileBuilder;getById=e=>this.profileBuilder.setId(e);getCountries=async()=>await this.profileFacade.getCountries();getByIds=async e=>await this.profileFacade.getByIds(e)};var $t=class{validate=e=>{let t=this.validateField(e.lang),r=this.generateMessage(t);return{validation:t,message:r}};validateField=e=>{let t=["bg","ro","en"],r=null;return e!=null&&e.length>0?t.includes(e)?r="valid":r="invalid":r="missing",r};generateMessage=e=>{let t=null,r="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,r=null),{text:t,type:r}}};var kt=class{validate(e){let t=this.validateField(e.environment),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=["dev","sandbox","prod"],r=null;return e!=null&&e.length>0?t.includes(e)?r="valid":r="invalid":r="missing",r};generateMessage=e=>{let t=null,r="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,r=null),{text:t,type:r}}};var Ht=class{validate(e){let t=this.validateField(e.apiKey),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,r="error";return e==="missing"&&(t="The field apiKey with valid value must be provided to use this SDK"),e==="valid"&&(r=null),{text:t,type:r}}};var qt=class{validate(e){let t=this.validateField(e.idSchema),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=["native","sportal365","enetpulse","sportradar"],r=null;return e!=null&&e.length>0?t.includes(e)?r="valid":r="invalid":r="missing",r};generateMessage=e=>{let t=null,r="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,r=null),{text:t,type:r}}};var _e=class{getIdToken=null;logout=null};var ne=class{text=null;type=null};var jt=class{validation=null;message=new ne;getIdToken={validation:null,message:new ne};logout={validation:null,message:new ne}};var Xt=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 _e),r=new jt;if(e){let a=Object.keys(e).filter(s=>!t.includes(s));a.length>0?(r.validation="invalid",r.message.type="warning",r.message.text=`${"You have passed a property which is not supported for the authentication provider:"} ${a.join(",")}`):r.validation="valid"}else r.validation="missing",r.message.type="error",r.message.text="The field authProvider must be provided to use this SDK";return r};validateAuthProviderConfigFields=(e,t)=>(Object.keys(new _e).forEach(i=>{e[i]?t[i].validation="valid":t[i].validation="missing"}),t);generateAuthProviderConfigMessages=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{let r=e[t];r.validation==="missing"&&(r.message.text=`${"The following property is missing from the authProvider object:"} ${t}`,r.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 Oe=class{validation;message};var Kt=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;authProvider={getIdToken:new Oe,logout:new Oe};isValid=!1};var Yt=class{validate(e){let t=this.validateField(e.clientId),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,r="warning";return e==="missing"&&(t="The field clientId must be provided to use this SDK"),e==="valid"&&(t=null,r=null),{text:t,type:r}}};var Wt=class{validate=e=>{let t=this.checkFieldsForValues(e);return t.isValid=this.containsErrorMessage(t),t};checkFieldsForValues=e=>{let t=new Kt,r={apiKey:new Ht,environment:new kt,idSchema:new qt,clientId:new Yt,lang:new $t,authProvider:new Xt};for(let[i,a]of Object.entries(t))i!=="isValid"&&(a=r[i].validate(e));return Object.keys(r).forEach(i=>{t[i]=r[i].validate(e)}),t};containsErrorMessage=e=>{let t=!0;for(let[r,i]of Object.entries(e))if(r!=="authProvider"){if(r!=="isValid"&&i.message.type==="error")return t=!1,t;if(r!=="isValid"&&i.message.type==="warning")return t=!0,t}return t}};var Jt=class{https=null;idMapping=null;localStorage=null;footballFacade=null;constructor(e){this.https=new A(e),this.idMapping=new T(e),this.localStorage=new G(e),this.footballFacade=new D(this.localStorage,this.https,this.idMapping)}getCountries=async()=>await this.footballFacade.getCountries();getCompetitions=async e=>await this.footballFacade.getCompetitions(e);getCompetitionById=async e=>await this.footballFacade.getCompetitionById(e);getTopCompetitions=async()=>await this.footballFacade.getTopCompetitions();getTeams=async e=>await this.footballFacade.getTeams(e);getTeamById=async e=>await this.footballFacade.getTeamById(e);getTopTeams=async()=>await this.footballFacade.getTopTeams();getNextMatchForTeam=async e=>await this.footballFacade.getNextMatchForTeam(e);getPrevMatchForTeam=async e=>await this.footballFacade.getPrevMatchForTeam(e);getPlayers=async e=>await this.footballFacade.getPlayers(e);getPlayerById=async e=>await this.footballFacade.getPlayerById(e);getTopPlayers=async()=>await this.footballFacade.getTopPlayers();getNextMatchForPlayer=async e=>await this.footballFacade.getNextMatchForPlayer(e);getPrevMatchForPlayer=async e=>await this.footballFacade.getPrevMatchForPlayer(e);getMatches=async e=>await this.footballFacade.getMatches(e);getMatchById=async e=>await this.footballFacade.getMatchById(e);search=async e=>await this.footballFacade.search(e)};var pi=Me(Q());var zt=class{value=null;playerId=null;playerModel=null};var le=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new zt;result=null};var Qt=class{value=!1;playerId=null};var _=class{matchId=null;market=null;prediction=null;constructor(e,t,r,i){this.matchId=e,this.market=t,this.prediction=new Qt,this.prediction.value=r,this.prediction.playerId=i}};var pe=class{settledAt=null;resettledAt=null;status=null;outcome=null};var P=(d=>(d.FT_1X2="FT_1X2",d.HT_1X2="HT_1X2",d.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",d.DOUBLE_CHANCE="DOUBLE_CHANCE",d.HT_FT="HT_FT",d.PLAYER_SCORE="PLAYER_SCORE",d.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",d.PLAYER_RED_CARD="PLAYER_RED_CARD",d.RED_CARD_MATCH="RED_CARD_MATCH",d.PENALTY_MATCH="PENALTY_MATCH",d.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",d.CORNERS_MATCH="CORNERS_MATCH",d.CORRECT_SCORE="CORRECT_SCORE",d.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",d.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",d.OVER_GOALS_0_5="OVER_GOALS_0.5",d.OVER_GOALS_1_5="OVER_GOALS_1.5",d.OVER_GOALS_2_5="OVER_GOALS_2.5",d.OVER_GOALS_3_5="OVER_GOALS_3.5",d.OVER_GOALS_4_5="OVER_GOALS_4.5",d.OVER_GOALS_5_5="OVER_GOALS_5.5",d.OVER_GOALS_6_5="OVER_GOALS_6.5",d.OVER_CORNERS_6_5="OVER_CORNERS_6.5",d.OVER_CORNERS_7_5="OVER_CORNERS_7.5",d.OVER_CORNERS_8_5="OVER_CORNERS_8.5",d.OVER_CORNERS_9_5="OVER_CORNERS_9.5",d.OVER_CORNERS_10_5="OVER_CORNERS_10.5",d.OVER_CORNERS_11_5="OVER_CORNERS_11.5",d.OVER_CORNERS_12_5="OVER_CORNERS_12.5",d.OVER_CORNERS_13_5="OVER_CORNERS_13.5",d))(P||{}),Fo=["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"],Po=["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"],ai=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"];var Zt=class{value=null};var $=class{matchId=null;market="CORRECT_SCORE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Zt,this.prediction.value=t}};var E=class{value=!1};var ce=class{matchId=null;market=null;prediction=null;constructor(e,t,r){this.matchId=e,this.market=t,this.prediction=new E,this.prediction.value=r}};var me=class{matchId=null;market=null;prediction=null;constructor(e,t,r){this.matchId=e,this.market=t,this.prediction=new E,this.prediction.value=r}};var er=class{matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t,r){this.matchFacade=e,this.playerFacade=t,this.predictorService=r}remapFixturesRequest=e=>{let t={};if(t.match_id=e.matchId,t.match_type="FOOTBALL",e instanceof _)t.market=e.market,t.prediction=e.prediction.value,t.player_id=e.prediction.playerId;else if(e instanceof ce||e instanceof me){let r=e.market.split("_");t.market=r[0]+"_"+r[1],t.prediction=e.prediction.value,t.target=Number(r[2])}else if(e instanceof $){t.market=e.market;let r=e.prediction.value.split(":");t.goals_home=Number(r[0]),t.goals_away=Number(r[1])}else t.market=e.market,t.prediction=e.prediction.value;return t};remapFixturesResponse=async e=>{e.length>1&&e.sort((n,p)=>n.match_id.localeCompare(p.match_id));let t=[],r=[];for(let n of e)t.push(n.match_id),n.player_id&&!r.includes(n.player_id)&&r.push(n.player_id);let i=await this.matchFacade.getMatchesMapWithNativeIds(t),a=[];r.sort((n,p)=>n.localeCompare(p)),r&&r.length>0&&(a=await this.playerFacade.getPlayersMapWithNativeIds(r));let s=[];for(let n of e){let p=new le;n.target?p.market=this.predictorService.convertMarketForResponseModel(n.market,n.target):p.market=n.market,p.matchId=i[n.match_id].id,p.matchType=n.match_type,p.matchModel=i?i[n.match_id]:null,n.goals_home!==void 0&&n.goals_away!==void 0?p.prediction.value=n.goals_home.toString()+":"+n.goals_away.toString():p.prediction.value=n.prediction,p.prediction.playerId=n.player_id?n.player_id:null,p.prediction.playerId&&(p.prediction.playerModel=a[n.player_id],p.prediction.playerId=a[n.player_id].id),p.result=this.remapResult(n.result),s.push(p)}return s};remapResult=e=>{let t=new pe;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t}};var ue=class{goldenGoal=null};var xe=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new ue;points=null;createdAt=null;updatedAt=null};var m=class{no=0;yes=0};var de=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new m;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new m;penaltyMatch=new m;playerScoreFirstGoal={};cornersMatch={};correctScore={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new m;overOnePointFiveGoals=new m;overTwoPointFiveGoals=new m;overThreePointFiveGoals=new m;overFourPointFiveGoals=new m;overFivePointFiveGoals=new m;overSixPointFiveGoals=new m;overSixPointFiveCorners=new m;overSevenPointFiveCorners=new m;overEightPointFiveCorners=new m;overNinePointFiveCorners=new m;overTenPointFiveCorners=new m;overElevenPointFiveCorners=new m;overTwelvePointFiveCorners=new m;overThirteenPointFiveCorners=new m};var si=(r=>(r.ONE="1",r.X="x",r.TWO="2",r))(si||{}),ni=(r=>(r.ONE_X="1x",r.X_TWO="x2",r.ONE_TWO="12",r))(ni||{}),li=(u=>(u.ONE_ONE="1/1",u.ONE_X="1/x",u.ONE_TWO="1/2",u.X_ONE="x/1",u.X_X="x/x",u.X_TWO="x/2",u.TWO_ONE="2/1",u.TWO_X="2/x",u.TWO_TWO="2/2",u))(li||{});var tr=class{value=null};var rr=class{matchId=null;market="HT_FT";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new tr,this.prediction.value=t}};var ir=class{value=null};var or=class{matchId=null;market="DOUBLE_CHANCE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new ir,this.prediction.value=t}};var he=class{value=null};var ar=class{matchId=null;market="FT_1X2";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new he,this.prediction.value=t}};var sr=class{matchId=null;market="HT_1X2";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new he,this.prediction.value=t}};var nr=class{value};var lr=class{matchId=null;market="CORNERS_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new nr,this.prediction.value=t}};var pr=class{matchId=null;market="BOTH_TEAMS_SCORE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new E,this.prediction.value=t}};var cr=class{matchId=null;market="RED_CARD_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new E,this.prediction.value=t}};var mr=class{matchId=null;market="PENALTY_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new E,this.prediction.value=t}};var j=class{id=null;title=null;description=null;type=null;status=null;predictionsCutoff=null;fixtures=[];createdAt=null;updatedAt=null};var X=class{userId=null;points=null;results=[];tiebreaker=null};var ur=(a=>(a.ACTIVE="ACTIVE",a.WON="WON",a.LOST="LOST",a.PARTIALLY_WON="PARTIALLY_WON",a.CANCELED="CANCELED",a))(ur||{}),Ae=["WON","LOST","PARTIALLY_WON","CANCELED"];var M=class{limit=null;startAfter=null;status=null;type=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}constructFilterUrl=()=>{let e="",t=!1;return this.status&&(t=Object.values(ur).some(r=>this.status.includes(r))),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}`),e}};var Be=(s=>(s.OPEN="OPEN",s.LIVE="LIVE",s.PENDING="PENDING",s.CANCELED="CANCELED",s.CLOSED="CLOSED",s.SETTLED="SETTLED",s))(Be||{});var v=class{limit=null;startAfter=null;status=null;type=null;gameIds=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.gameIds=e.gameIds?e.gameIds:null}constructFiltersUrl=()=>{let e="";return this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),this.status&&Object.values(Be).includes(this.status)&&(e+="&",e+=`status=${this.status}`),this.type&&(e+="&",e+=`type=${this.type}`),this.gameIds&&(e+="&",e+=`game_ids=${this.gameIds.join(",")}`),e}};var K=class{id=null;title=null;description=null;type=null;status=null;predictionsCutoff=null;fixtures=[];createdAt=null;updatedAt=null};var B=class{footballHttps=null;idMapping=null;matchFacade=null;constructor(e,t){this.footballHttps=new A(e),this.idMapping=t,this.matchFacade=new U(this.footballHttps,t)}remapMatchIdToNative=async e=>{let t=await this.idMapping.getEntityIdsBySchemaId(e,"match","native"),r=[];return t.match.forEach(i=>r.push(i)),r};remapPlayerIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"player","native")).player[0];remapPlayerIdMapToNative=async e=>{let t={},r=L(e),a=(await this.idMapping.getEntityIdsBySchemaId(r,"player","native")).player;return r.forEach((s,n)=>t[s]=a[n]),t};remapPlayerIdToIdSchema=async e=>{let t=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"];for(let[r,i]of Object.entries(e))if(t.includes(r))for(let a of Object.keys(i)){let s={player:[a]},p=(await this.idMapping.idMappingFacade.getEntitiesByIds(s,"native",this.idMapping.idSchema)).player[0];i[p]=i[a],delete i[a]}return e};convertMarket=e=>{let t=Object.keys(new de),r=Object.values(P);for(let i=0;i<r.length;i++)e===r[i]&&(e=t[i]);return e};convertMarketForResponseModel=(e,t)=>{let r=t.toString();return e+"_"+r};validateFixture=(e,t,r,i)=>{let a=Object.values(si),s=Object.values(li),n=Object.values(ni);if(t==="FT_1X2"){if(a.includes(r))return new ar(e,r)}else if(t==="HT_1X2"){if(a.includes(r))return new sr(e,r)}else if(t==="HT_FT"){if(s.includes(r))return new rr(e,r)}else if(t==="DOUBLE_CHANCE"){if(n.includes(r))return new or(e,r)}else if(t==="CORRECT_SCORE"){if(typeof r=="string"&&/\d+:\d+/.test(r))return new $(e,r)}else if(t==="CORNERS_MATCH"){if(typeof r=="number")return new lr(e,r)}else if(t==="BOTH_TEAMS_SCORE"){if(typeof r=="boolean")return new pr(e,r)}else if(t==="RED_CARD_MATCH"){if(typeof r=="boolean")return new cr(e,r)}else if(t==="PENALTY_MATCH"){if(typeof r=="boolean")return new mr(e,r)}else if(ai.includes(t)){if(i&&typeof r=="boolean")return new _(e,t,r,i)}else if(Fo.includes(t)){if(typeof r=="boolean")return new me(e,t,r)}else if(Po.includes(t)&&typeof r=="boolean")return new ce(e,t,r)};getMarketSummary=(e,t,r)=>{let i=this.convertMarket(t),a={};if(a.matchId=e.matchId,a.matchType=e.matchType,Object.keys(e.predictions).includes(i))a[i]=e.predictions[i];else throw new Error("You have passed invalid market");return ai.includes(t)&&r?(a[i][r]||(a[i][r]=new m),a[i][r]):a};remapCompetitionsFromConfig=async e=>{let t={competition:e.fullCoverageCompetitions},r=await this.idMapping.idMappingFacade.getEntitiesByIds(t,"native",this.idMapping.idSchema);return e.fullCoverageCompetitions=r.competition,e};remapMatchIdsFixtures=async e=>{if(Array.isArray(e))if(e.length>0){let t=[];return e.forEach(r=>{r instanceof K||r instanceof j?r.fixtures.forEach(i=>t.push(i.matchId)):r instanceof X&&r.results.forEach(i=>t.push(i.matchId))}),await this.refactorResponseArrModel(e,t)}else return e;else return await this.refactorResponseObjModel(e)};refactorResponseArrModel=async(e,t)=>{let r=[],i=await this.matchFacade.getMatchesMapWithNativeIds(t);return e.forEach(a=>{a instanceof K||a instanceof j?(a.fixtures.forEach(s=>{s.matchModel=i[s.matchId],s.matchId=s.matchModel.id}),r.push(a)):a instanceof X&&(a.results.forEach(s=>{s.matchModel=i[s.matchId],s.matchId=s.matchModel.id}),r.push(a))}),r};refactorResponseObjModel=async e=>{let t=[];e.fixtures.forEach(i=>t.push(i.matchId));let r=await this.matchFacade.getMatchesMapWithNativeIds(t);return e.fixtures.forEach(i=>{i.matchModel=r[i.matchId],i.matchId=r[i.matchId].id}),e};getCurrentGameId=e=>{let t=new Date;if(e.length>1){let r=[];return e.forEach(a=>r.push(a.predictionsCutoff)),e.sort((a,s)=>{let[n,p]=[a.predictionsCutoff,s.predictionsCutoff].map(u=>Math.abs(new Date(u)-t));return n-p})[0].id}else return e[0].id};initGameTypePredictions=e=>{let t={type:e};return t=new M(t),t};initGameFilters=(e,t,r)=>{if(t&&r)return t.type=e,t.gameIds=r,t=new v(t),t;if(t&&!r)return t.type=e,t=new v(t),t;if(!t&&r){let i={type:e,gameIds:r};return i=new v(i),i}else{let i={type:e};return i=new v(i),i}};addPredictionProp=(e,t)=>(t.forEach((r,i)=>{r.id===e[i].game_instance_id&&r.fixtures.forEach((a,s)=>{a.prediction.value=e[i].fixtures[s].goals_home+":"+e[i].fixtures[s].goals_away,a.prediction.result=this.remapResult(e[i].fixtures[s].result)})}),this.remapMatchIdsFixtures(t));remapResult=e=>{let t=new pe;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t}};var fe=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(e){this.gameInstanceId=e.gameInstanceId,e.fixtures.forEach(t=>this.fixtures.push(new $(t.matchId,t.prediction.value))),this.tiebreaker=e.tiebreaker?e.tiebreaker:null}};var ye=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t){this.footballHttps=new A(e),this.matchFacade=new U(this.footballHttps,t),this.playerFacade=new Z(this.footballHttps,t),this.predictorService=new B(e,t),this.fixturesRemapper=new er(this.matchFacade,this.playerFacade,this.predictorService)}remapRequestBody=e=>{let t={};return t.game_instance_id=e.gameInstanceId,t.fixtures=e.fixtures.map(r=>this.fixturesRemapper.remapFixturesRequest(r)),e instanceof fe&&e.tiebreaker&&(t.tiebreaker={},t.tiebreaker.golden_goal=e.tiebreaker.goldenGoal?e.tiebreaker.goldenGoal:null),t};remapResponseArrayBody=async e=>{let t=[],r=[],i={},a=[];e.forEach(n=>{n.fixtures.forEach(p=>{t.push(p.match_id),p.player_id&&r.push(p.player_id)})});let s=await this.matchFacade.getMatchesMapWithNativeIds(t);return r.length>0&&(i=await this.playerFacade.getPlayersMapWithNativeIds(r)),e.forEach(n=>{let p=new xe,u=[];p.id=n.id,p.gameInstanceId=n.game_instance_id,p.gameType=n.game_type,p.wager=n.wager,p.totalFixtures=n.total_fixtures,p.settledFixtures=n.settled_fixtures,p.userId=n.user_id,n.fixtures.forEach(l=>{let c=new le;l.target?c.market=this.predictorService.convertMarketForResponseModel(l.market,l.target):c.market=l.market,c.matchId=s[l.match_id].id,c.matchType=l.match_type,c.matchModel=s[l.match_id],l.goals_home!==void 0&&l.goals_away!==void 0?c.prediction.value=l.goals_home.toString()+":"+l.goals_away.toString():c.prediction.value=l.prediction,c.prediction.playerId=l.player_id?l.player_id:null,c.prediction.playerId&&(c.prediction.playerModel=i[c.prediction.playerId],c.prediction.playerId=i[c.prediction.playerId].id),c.result=this.fixturesRemapper.remapResult(l.result),u.push(c)}),p.fixtures=u,p.status=n.status,n.tiebreaker?p.tiebreaker.goldenGoal=n.tiebreaker.golden_goal:p.tiebreaker=null,p.points=n.points,p.createdAt=n.created_at,p.updatedAt=n.updated_at,a.push(p)}),a};remapResponseObjBody=async e=>{let t=new xe;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 de;return t.fullTimeOneXTwo=e.FT_1X2,t.halfTimeOneXTwo=e.HT_1X2,t.bothTeamsScore=e.BOTH_TEAMS_SCORE?e.BOTH_TEAMS_SCORE:new m,t.overZeroPointFiveGoals=e.OVER_GOALS["over:0.5"]?e.OVER_GOALS["over:0.5"]:new m,t.overOnePointFiveGoals=e.OVER_GOALS["over:1.5"]?e.OVER_GOALS["over:1.5"]:new m,t.overTwoPointFiveGoals=e.OVER_GOALS["over:2.5"]?e.OVER_GOALS["over:2.5"]:new m,t.overThreePointFiveGoals=e.OVER_GOALS["over:3.5"]?e.OVER_GOALS["over:3.5"]:new m,t.overFourPointFiveGoals=e.OVER_GOALS["over:4.5"]?e.OVER_GOALS["over:4.5"]:new m,t.overFivePointFiveGoals=e.OVER_GOALS["over:5.5"]?e.OVER_GOALS["over:5.5"]:new m,t.overSixPointFiveGoals=e.OVER_GOALS["over:6.5"]?e.OVER_GOALS["over:6.5"]:new m,t.overSixPointFiveCorners=e.OVER_CORNERS["over:6.5"]?e.OVER_CORNERS["over:6.5"]:new m,t.overSevenPointFiveCorners=e.OVER_CORNERS["over:7.5"]?e.OVER_CORNERS["over:7.5"]:new m,t.overEightPointFiveCorners=e.OVER_CORNERS["over:8.5"]?e.OVER_CORNERS["over:8.5"]:new m,t.overNinePointFiveCorners=e.OVER_CORNERS["over:9.5"]?e.OVER_CORNERS["over:9.5"]:new m,t.overTenPointFiveCorners=e.OVER_CORNERS["over:10.5"]?e.OVER_CORNERS["over:10.5"]:new m,t.overElevenPointFiveCorners=e.OVER_CORNERS["over:11.5"]?e.OVER_CORNERS["over:11.5"]:new m,t.overTwelvePointFiveCorners=e.OVER_CORNERS["over:12.5"]?e.OVER_CORNERS["over:12.5"]:new m,t.overThirteenPointFiveCorners=e.OVER_CORNERS["over:13.5"]?e.OVER_CORNERS["over:13.5"]:new m,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?e.RED_CARD_MATCH:new m,t.penaltyMatch=e.PENALTY_MATCH?e.PENALTY_MATCH:new m,t.playerScoreFirstGoal=e.PLAYER_SCORE_FIRST_GOAL,t.cornersMatch=e.CORNERS_MATCH,t.correctScore=e.CORRECT_SCORE,t.playerScoreHattrick=e.PLAYER_SCORE_HATTRICK,t.playerScoreTwice=e.PLAYER_SCORE_TWICE,t}};var dr=class{matchId=null;matchType=null;predictions=null};var hr=class{remapPredictions=null;constructor(e,t){this.remapPredictions=new ye(e,t)}remapResponse=e=>{let t=new dr;return t.matchId=e.match_id,t.matchType=e.match_type,t.predictions=this.remapPredictions.remapPredictionModel(e.predictions),t}};var fr=class{matchId=null;matchType=null;market=null;matchModel=null};var yr=class{value=null;result=null};var gr=class{matchId=null;matchType=null;market="CORRECT_SCORE";matchModel=null;prediction=new yr};var wr=class{matchId=null;matchModel=null;outcome=null};var Mr=class{remapGamesListResponse=e=>{let t=new K;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.fixtures=e.fixtures.map(r=>this.remapFixturesResponse(r)),t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapFixturesResponse=e=>{let t=new fr;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t};remapUserTopXEditionsResponse=e=>{let t=new j;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.fixtures=e.fixtures.map(r=>this.remapTopXFixturesResponse(r)),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};remapGameResults=e=>{let t=new X;return t.userId=e.user_id,t.points=e.points?e.points:0,t.results=e.results.map(r=>this.remapResults(r)),t.tiebreaker=e.tiebreaker?this.remapTiebreaker(e.tiebreaker):null,t};remapResults=e=>{let t=new wr;return t.matchId=e.match_id,t.outcome=e.outcome,t};remapTiebreaker=e=>{let t=new ue;return t.goldenGoal=e.golden_goal,t}};var k=class{instanceAuth=null;instance=null;apiSignInUrl=null;clientApiSignInUrl=null;predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;constructor(e,t){let r=x(e.environment,"predictor");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.predictionRemapper=new ye(e,t),this.matchSummaryRemapper=new hr(e,t),this.gamesRemapper=new Mr,this.instanceAuth=pi.default.create({baseURL:r,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instance=pi.default.create({baseURL:r,headers:{"Content-Type":"application/json"}})}makeFootballPrediction=async e=>{try{let t=this.predictionRemapper.remapRequestBody(e),r=await this.instanceAuth.post(`/predictions${this.apiSignInUrl}`,JSON.stringify(t));return await this.predictionRemapper.remapResponseObjBody(r.data)}catch(t){throw console.warn("There was a problem making POST request: ",t),t.response}};getMatchSummary=async e=>{try{let t=await this.instance.get(`/predictions/summary/${e}${this.apiSignInUrl}`);return this.matchSummaryRemapper.remapResponse(t.data)}catch(t){throw console.warn(`There was a problem fetching predictions for match: ${e} `,t),t.response}};deleteFootballPrediction=async e=>{try{return await this.instanceAuth.delete(`/predictions/${e}${this.apiSignInUrl}`),!0}catch(t){throw console.warn(`There was a problem deleting your prediction: ${e}`,t),t.response}};getMyPredictions=async e=>{try{let t=e?await this.instanceAuth.get(`/predictions${this.apiSignInUrl}${e.constructFilterUrl()}`):await this.instanceAuth.get(`/predictions${this.apiSignInUrl}`);return await this.predictionRemapper.remapResponseArrayBody(t.data.data)}catch(t){throw console.warn("There was a problem fetching own predictions",t),t.response}};getMyPredictionsNoRemap=async e=>{try{return(await this.instanceAuth.get(`/predictions${this.apiSignInUrl}${e.constructFilterUrl()}`)).data.data}catch(t){throw console.warn("There was a problem fetching own predictions",t),t.response}};getUserPredictions=async(e,t)=>{try{let r=t?await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}${t.constructFilterUrl()}`):await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}`);return await this.predictionRemapper.remapResponseArrayBody(r.data.data)}catch(r){throw console.warn(`There was a problem fetching predictions for user: ${e}`,r),r.response}};getUserPredictionsNoRemap=async(e,t)=>{try{return(await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}${t.constructFilterUrl()}`)).data.data}catch(r){throw console.warn(`There was a problem fetching predictions for user: ${e}`,r),r.response}};getGames=async e=>{try{return(await this.instance.get(`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`)).data.data.map(r=>this.gamesRemapper.remapGamesListResponse(r))}catch(t){throw console.warn("There was a problem fetching the games list",t),t.response}};getGameById=async e=>{try{let t=await this.instance.get(`/games/${e}${this.apiSignInUrl}`);return this.gamesRemapper.remapGamesListResponse(t.data)}catch(t){throw console.warn(`There was a problem fetching the following game: ${e}`,t),t.response}};getUserGameEditions=async e=>{try{return(await this.instance.get(`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`)).data.data.map(r=>{if(r.type==="TOP_X")return this.gamesRemapper.remapUserTopXEditionsResponse(r)})}catch(t){throw console.warn("There was a problem fetching the games list",t),t.response}};getGameResults=async(e,t)=>{try{return(t?await this.instance.get(`/games/${e}/results/${this.apiSignInUrl}${t.constructFiltersUrl()}`):await this.instance.get(`/games/${e}/results/${this.apiSignInUrl}`)).data.data.map(i=>this.gamesRemapper.remapGameResults(i))}catch(r){throw console.warn(`There was a problem fetching the results for the following game: ${e}`,r),r.response}}};var br=class{fullCoverageCompetitions=null;markets=null};var Ir=class{remapConfig=e=>{let t=new br;return t.fullCoverageCompetitions=e.full_coverage_competitions,t.markets=e.markets,t}};var Rr=class{gameInstanceId=null;fixtures=null};var Fr=class{predictorHttps=null;clientHttps=null;idMapping=null;predictorConfigRemapper=null;predictorService=null;constructor(e,t,r,i){this.predictorHttps=t,this.idMapping=i,this.clientHttps=r,this.predictorConfigRemapper=new Ir,this.predictorService=new B(e,i)}makeFootballPrediction=async(e,t,r,i)=>{let a=this.predictorService.validateFixture(e,t,r,i),s=new Rr;if(a)if(this.idMapping.idSchema!=="native"){let n=a.matchId,p="",u=await this.predictorService.remapMatchIdToNative([n]);if(a.matchId=u[0],!a.matchId)throw new Error("Match id is invalid!");if(a instanceof _&&(p=a.prediction.playerId,a.prediction.playerId=await this.predictorService.remapPlayerIdToNative([p]),!a.prediction.playerId))throw new Error("Player id is invalid!");s.fixtures=[a];let l=await this.predictorHttps.makeFootballPrediction(s);return l.fixtures.map(c=>{c.prediction.playerId&&(c.prediction.playerId=p),c.matchId=n}),l}else return s.fixtures=[a],await this.predictorHttps.makeFootballPrediction(s);else throw new Error("The prediction is invalid. Please check again have you passed appropriate prediction model")};getMatchSummary=async e=>{if(this.idMapping.idSchema!=="native"){let r=(await this.predictorService.remapMatchIdToNative([e]))[0],i=await this.predictorHttps.getMatchSummary(r);i.matchId=e;let a=i.predictions,s=await this.predictorService.remapPlayerIdToIdSchema(a);return i.predictions=s,i}else return await this.predictorHttps.getMatchSummary(e)};getMarketSummary=async(e,t,r)=>{try{let i=await this.getMatchSummary(e);return this.predictorService.getMarketSummary(i,t,r)}catch(i){return i.message}};getConfig=async()=>{let e=await this.clientHttps.getConfig(),t=await this.predictorConfigRemapper.remapConfig(e.predictor);return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(t):t};deleteFootballPrediction=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyPredictions=async e=>(e&&(e=new M(e)),await this.predictorHttps.getMyPredictions(e));getMyCurrentPredictions=async e=>{if(e)e.status=["ACTIVE"],e=new M(e);else{let t={status:["ACTIVE"]};e=new M(t)}return await this.getMyPredictions(e)};getMyPastPredictions=async e=>{if(e)e.status=Ae,e=new M(e);else{let t={status:Ae};e=new M(t)}return await this.getMyPredictions(e)};getUserPredictions=async(e,t)=>(t&&(t=new M(t)),await this.predictorHttps.getUserPredictions(e,t));getUserCurrentPredictions=async(e,t)=>{if(t)t.status=["ACTIVE"],t=new M(t);else{let r={status:["ACTIVE"]};t=new M(r)}return await this.getUserPredictions(e,t)};getUserPastPredictions=async(e,t)=>{if(t)t.status=Ae,t=new M(t);else{let r={status:Ae};t=new M(r)}return await this.getUserPredictions(e,t)}};var vo=Me(Q());var ge=class{instance=null;apiSignInUrl="";constructor(e){let t=x(e.environment,"client");this.apiSignInUrl=`/clients/${e.clientId}/features?key=${e.apiKey}`,this.instance=vo.default.create({baseURL:t,headers:{"Content-Type":"application/json"}})}getConfig=async()=>{try{return(await this.instance.get(`${this.apiSignInUrl}`)).data.data}catch(e){throw console.warn("There was a problem fetching configuration from Client API",e),e.response}}};var Pr=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(e){this.idMapping=new T(e),this.predictorHttps=new k(e,this.idMapping),this.clientHttps=new ge(e),this.predictorFacade=new Fr(e,this.predictorHttps,this.clientHttps,this.idMapping)}makeFootballPrediction=async(e,t,r,i)=>await this.predictorFacade.makeFootballPrediction(e,t,r,i);getMatchSummary=async e=>await this.predictorFacade.getMatchSummary(e);getMarketSummary=async(e,t,r)=>await this.predictorFacade.getMarketSummary(e,t,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);getUserPredictions=async(e,t)=>await this.predictorFacade.getUserPredictions(e,t);getUserCurrentPredictions=async(e,t)=>await this.predictorFacade.getUserCurrentPredictions(e,t);getUserPastPredictions=async(e,t)=>await this.predictorFacade.getUserPastPredictions(e,t)};var vr=class{general=[];predictor=[];topX=[]};var Sr=class{enabled=!1;rewards=null};var Tr=class{general=null;topX=null;predictor=null};var Er=class{points=null;tiers=null;badges=null};var Cr=class{remapLoyaltyResponse=e=>{let t=new Sr;return t.enabled=e.enabled,t.rewards=this.remapRewards(e.rewards),t};remapRewards=e=>{let t=new Er;return t.points=this.remapPoints(e.points),t.tiers=e.tiers,t.badges=this.remapBadges(e.badges),t};remapPoints=e=>{let t=new Tr;return t.general=e.general,t.topX=e.top_x,t.predictor=e.predictor,t};remapBadges=e=>{let t=new vr;return t.general=e.general,t.predictor=e.predictor,t.topX=e.top_x,t}};var _r=class{https=null;loyaltyRemapper=null;constructor(e){this.https=e,this.loyaltyRemapper=new Cr}getConfig=async()=>{let e=await this.https.getConfig();return this.loyaltyRemapper.remapLoyaltyResponse(e.loyalty)}};var Or=class{https=null;loyaltyFacade=null;constructor(e){this.https=new ge(e),this.loyaltyFacade=new _r(this.https)}getConfig=async()=>await this.loyaltyFacade.getConfig()};var xr=class{idMapping=null;predictorHttps=null;predictorService=null;constructor(e,t){this.idMapping=t,this.predictorHttps=new k(e,t),this.predictorService=new B(e,t)}getGames=async e=>{let t=this.predictorService.initGameFilters("TOP_X",e),r=await this.predictorHttps.getGames(t);return await this.predictorService.remapMatchIdsFixtures(r)};getGameById=async e=>{let t=await this.predictorHttps.getGameById(e);return await this.predictorService.remapMatchIdsFixtures(t)};getGameResults=async(e,t)=>{t&&(t=new v(t));let r=await this.predictorHttps.getGameResults(e,t);return await this.predictorService.remapMatchIdsFixtures(r)};getCurrentGameResults=async()=>{let e={status:"OPEN",type:"TOP_X"};e=new v(e);let t=await this.predictorHttps.getGames(e),r=this.predictorService.getCurrentGameId(t);return(await this.getGameResults(r))[0]};play=async e=>{let t=new fe(e);if(this.idMapping.idSchema!=="native"){let i=[];t.fixtures.forEach(s=>i.push(s.matchId));let a=await this.predictorService.remapMatchIdToNative(i);t.fixtures.forEach(s=>s.matchId=a.shift())}let r=await this.predictorHttps.makeFootballPrediction(t);return r.fixtures.forEach(i=>{i.matchId=i.matchModel.id}),r};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyGameEditions=async e=>{let t=this.predictorService.initGameTypePredictions("TOP_X"),r=[],i=await this.predictorHttps.getMyPredictionsNoRemap(t);i.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let a=this.predictorService.initGameFilters("TOP_X",e,r),s=await this.predictorHttps.getUserGameEditions(a);return this.predictorService.addPredictionProp(i,s)};getMyGamePrediction=async e=>{let t=this.predictorService.initGameTypePredictions("TOP_X");return(await this.predictorHttps.getMyPredictions(t)).filter(a=>a.gameInstanceId===e)[0]};getUserGameEditions=async(e,t)=>{let r=this.predictorService.initGameTypePredictions("TOP_X"),i=[],a=await this.predictorHttps.getUserPredictionsNoRemap(e,r);a.forEach(p=>{p.game_instance_id&&i.push(p.game_instance_id)});let s=this.predictorService.initGameFilters("TOP_X",t,i),n=await this.predictorHttps.getUserGameEditions(s);return this.predictorService.addPredictionProp(a,n)};getUserGamePrediction=async(e,t)=>{let r=this.predictorService.initGameTypePredictions("TOP_X");return(await this.predictorHttps.getUserPredictions(e,r)).filter(s=>s.gameInstanceId===t)[0]}};var Ar=class{topXFacade=null;idMapping=null;constructor(e){this.idMapping=new T(e),this.topXFacade=new xr(e,this.idMapping)}getGames=async e=>await this.topXFacade.getGames(e);getGameById=async e=>await this.topXFacade.getGameById(e);getGameResults=async(e,t)=>await this.topXFacade.getGameResults(e,t);getCurrentGameResults=async()=>await this.topXFacade.getCurrentGameResults();play=async e=>await this.topXFacade.play(e);delete=async e=>await this.topXFacade.delete(e);getMyGameEditions=async e=>await this.topXFacade.getMyGameEditions(e);getMyGamePrediction=async e=>await this.topXFacade.getMyGamePrediction(e);getUserGameEditions=async(e,t)=>await this.topXFacade.getUserGameEditions(e,t);getUserGamePrediction=async(e,t)=>await this.topXFacade.getUserGamePrediction(e,t)};var Br=class{predictorHttps=null;predictorService=null;idMapping=null;constructor(e){this.idMapping=new T(e),this.predictorHttps=new k(e,this.idMapping),this.predictorService=new B(e,this.idMapping)}play=async e=>{let t=e.fixtures.map(r=>this.predictorService.validateFixture(r.matchId,r.market,r.prediction.value,r.prediction.playerId));if(t){if(this.idMapping.idSchema!=="native"){let r=[],i=[];t.forEach(n=>{r.push(n.matchId),n instanceof _&&i.push(n.prediction.playerId)});let a=await this.predictorService.remapMatchIdToNative(r),s={};i&&i.length>0&&(s=await this.predictorService.remapPlayerIdMapToNative(i)),t.forEach((n,p)=>{n.matchId=a[p],n instanceof _&&(n.prediction.playerId=s[n.prediction.playerId])})}}else throw new Error("The prediction is invalid. Please check again have you passed appropriate prediction model");return e.fixtures=t,await this.predictorHttps.makeFootballPrediction(e)};getGames=async e=>{let t=this.predictorService.initGameFilters("MATCH_QUIZ",e),r=await this.predictorHttps.getGames(t);return await this.predictorService.remapMatchIdsFixtures(r)};getGameById=async e=>{let t=await this.predictorHttps.getGameById(e);return await this.predictorService.remapMatchIdsFixtures(t)};getGameResults=async(e,t)=>{t&&(t=new v(t));let r=await this.predictorHttps.getGameResults(e,t);return await this.predictorService.remapMatchIdsFixtures(r)};getCurrentGameResults=async()=>{let e={status:"OPEN",type:"MATCH_QUIZ"};e=new v(e);let t=await this.predictorHttps.getGames(e),r=this.predictorService.getCurrentGameId(t);return(await this.getGameResults(r))[0]}};var Nr=class{matchQuizFacade=null;constructor(e){this.matchQuizFacade=new Br(e)}play=async e=>await this.matchQuizFacade.play(e);getGames=async e=>await this.matchQuizFacade.getGames(e);getGameById=async e=>await this.matchQuizFacade.getGameById(e);getGameResults=async(e,t)=>await this.matchQuizFacade.getGameResults(e,t);getCurrentGameResults=async()=>await this.matchQuizFacade.getCurrentGameResults()};function gh(o){let t=new Wt().validate(o);if(t.idSchema.validation==="missing"&&(console.warn(t.idSchema.message.text),o.idSchema="native"),t.environment.validation==="missing"&&(console.warn(t.environment.message.text),o.environment="prod"),t.lang.validation==="missing"&&(console.warn(t.lang.message.text),o.lang="en"),t.isValid)return{profile:new Dt(o),football:new Jt(o),predictor:new Pr(o),loyalty:new Or(o),topX:new Ar(o),matchQuiz:new Nr(o)};throw new Error("Configuration is not valid")}export{gh as FansUnitedSDK};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|