fansunited-sdk-esm 1.2.3 → 1.2.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 +1 -1
- package/index.js.map +2 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -18,7 +18,7 @@ __p += '`),V&&(R+=`' +
|
|
|
18
18
|
function print() { __p += __j.call(arguments, '') }
|
|
19
19
|
`:`;
|
|
20
20
|
`)+R+`return __p
|
|
21
|
-
}`;var D=Eu(function(){return k(m,C+"return "+R).apply(s,d)});if(D.source=R,hl(D))throw D;return D}function QM(t){return W(t).toLowerCase()}function ZM(t){return W(t).toUpperCase()}function jM(t,i,o){if(t=W(t),t&&(o||i===s))return Dp(t);if(!t||!(i=Oe(i)))return t;var l=et(t),p=et(i),m=Gp(l,p),d=$p(l,p)+1;return Nt(l,m,d).join("")}function eb(t,i,o){if(t=W(t),t&&(o||i===s))return t.slice(0,Vp(t)+1);if(!t||!(i=Oe(i)))return t;var l=et(t),p=$p(l,et(i))+1;return Nt(l,0,p).join("")}function tb(t,i,o){if(t=W(t),t&&(o||i===s))return t.replace(hs,"");if(!t||!(i=Oe(i)))return t;var l=et(t),p=Gp(l,et(i));return Nt(l,p).join("")}function rb(t,i){var o=zm,l=Jm;if(j(i)){var p="separator"in i?i.separator:p;o="length"in i?U(i.length):o,l="omission"in i?Oe(i.omission):l}t=W(t);var m=t.length;if(dr(t)){var d=et(t);m=d.length}if(o>=m)return t;var h=o-fr(l);if(h<1)return l;var w=d?Nt(d,0,h).join(""):t.slice(0,h);if(p===s)return w+l;if(d&&(h+=w.length-h),gl(p)){if(t.slice(h).search(p)){var I,P=w;for(p.global||(p=xs(p.source,W(ap.exec(p))+"g")),p.lastIndex=0;I=p.exec(P);)var R=I.index;w=w.slice(0,R===s?h:R)}}else if(t.indexOf(Oe(p),h)!=h){var T=w.lastIndexOf(p);T>-1&&(w=w.slice(0,T))}return w+l}function ib(t){return t=W(t),t&&dd.test(t)?t.replace(ip,xf):t}var nb=br(function(t,i,o){return t+(o?" ":"")+i.toUpperCase()}),Ml=Cc("toUpperCase");function Tu(t,i,o){return t=W(t),i=o?s:i,i===s?Sf(t)?Bf(t):wf(t):t.match(i)||[]}var Eu=G(function(t,i){try{return Ae(t,s,i)}catch(o){return hl(o)?o:new L(o)}}),ob=bt(function(t,i){return qe(i,function(o){o=ct(o),wt(t,o,dl(t[o],t))}),t});function ab(t){var i=t==null?0:t.length,o=A();return t=i?Z(t,function(l){if(typeof l[1]!="function")throw new ke(a);return[o(l[0]),l[1]]}):[],G(function(l){for(var p=-1;++p<i;){var m=t[p];if(Ae(m[0],this,l))return Ae(m[1],this,l)}})}function sb(t){return xh(Ke(t,S))}function bl(t){return function(){return t}}function lb(t,i){return t==null||t!==t?i:t}var pb=xc(),cb=xc(!0);function Se(t){return t}function vl(t){return lc(typeof t=="function"?t:Ke(t,S))}function ub(t){return cc(Ke(t,S))}function mb(t,i){return uc(t,Ke(i,S))}var db=G(function(t,i){return function(o){return gi(o,t,i)}}),fb=G(function(t,i){return function(o){return gi(t,o,i)}});function _l(t,i,o){var l=pe(i),p=hn(i,l);o==null&&!(j(i)&&(p.length||!l.length))&&(o=i,i=t,t=this,p=hn(i,pe(i)));var m=!(j(o)&&"chain"in o)||!!o.chain,d=_t(t);return qe(p,function(h){var w=i[h];t[h]=w,d&&(t.prototype[h]=function(){var I=this.__chain__;if(m||I){var P=t(this.__wrapped__),R=P.__actions__=Pe(this.__actions__);return R.push({func:w,args:arguments,thisArg:t}),P.__chain__=I,P}return w.apply(t,Et([this.value()],arguments))})}),t}function hb(){return le._===this&&(le._=Hf),this}function Il(){}function gb(t){return t=U(t),G(function(i){return mc(i,t)})}var yb=el(Z),wb=el(Op),Mb=el(Rs);function Cu(t){return sl(t)?Fs(ct(t)):zh(t)}function bb(t){return function(i){return t==null?s:tr(t,i)}}var vb=Lc(),_b=Lc(!0);function Pl(){return[]}function Rl(){return!1}function Ib(){return{}}function Pb(){return""}function Rb(){return!0}function Fb(t,i){if(t=U(t),t<1||t>St)return[];var o=st,l=de(t,st);i=A(i),t-=st;for(var p=Es(l,i);++o<t;)i(o);return p}function Sb(t){return B(t)?Z(t,ct):Le(t)?[t]:Pe(Jc(W(t)))}function Tb(t){var i=++Gf;return W(t)+i}var Eb=vn(function(t,i){return t+i},0),Cb=tl("ceil"),Ab=vn(function(t,i){return t/i},1),xb=tl("floor");function Ob(t){return t&&t.length?fn(t,Se,$s):s}function Lb(t,i){return t&&t.length?fn(t,A(i,2),$s):s}function Bb(t){return Np(t,Se)}function Nb(t,i){return Np(t,A(i,2))}function Ub(t){return t&&t.length?fn(t,Se,ks):s}function Db(t,i){return t&&t.length?fn(t,A(i,2),ks):s}var Gb=vn(function(t,i){return t*i},1),$b=tl("round"),Hb=vn(function(t,i){return t-i},0);function Vb(t){return t&&t.length?Ts(t,Se):0}function qb(t,i){return t&&t.length?Ts(t,A(i,2)):0}return u.after=uw,u.ary=su,u.assign=Zw,u.assignIn=vu,u.assignInWith=Ln,u.assignWith=jw,u.at=eM,u.before=lu,u.bind=dl,u.bindAll=ob,u.bindKey=pu,u.castArray=Iw,u.chain=nu,u.chunk=xg,u.compact=Og,u.concat=Lg,u.cond=ab,u.conforms=sb,u.constant=bl,u.countBy=Vy,u.create=tM,u.curry=cu,u.curryRight=uu,u.debounce=mu,u.defaults=rM,u.defaultsDeep=iM,u.defer=mw,u.delay=dw,u.difference=Bg,u.differenceBy=Ng,u.differenceWith=Ug,u.drop=Dg,u.dropRight=Gg,u.dropRightWhile=$g,u.dropWhile=Hg,u.fill=Vg,u.filter=ky,u.flatMap=Xy,u.flatMapDeep=Yy,u.flatMapDepth=zy,u.flatten=eu,u.flattenDeep=qg,u.flattenDepth=kg,u.flip=fw,u.flow=pb,u.flowRight=cb,u.fromPairs=Wg,u.functions=cM,u.functionsIn=uM,u.groupBy=Jy,u.initial=Xg,u.intersection=Yg,u.intersectionBy=zg,u.intersectionWith=Jg,u.invert=dM,u.invertBy=fM,u.invokeMap=Zy,u.iteratee=vl,u.keyBy=jy,u.keys=pe,u.keysIn=Fe,u.map=Tn,u.mapKeys=gM,u.mapValues=yM,u.matches=ub,u.matchesProperty=mb,u.memoize=Cn,u.merge=wM,u.mergeWith=_u,u.method=db,u.methodOf=fb,u.mixin=_l,u.negate=An,u.nthArg=gb,u.omit=MM,u.omitBy=bM,u.once=hw,u.orderBy=ew,u.over=yb,u.overArgs=gw,u.overEvery=wb,u.overSome=Mb,u.partial=fl,u.partialRight=du,u.partition=tw,u.pick=vM,u.pickBy=Iu,u.property=Cu,u.propertyOf=bb,u.pull=ey,u.pullAll=ru,u.pullAllBy=ty,u.pullAllWith=ry,u.pullAt=iy,u.range=vb,u.rangeRight=_b,u.rearg=yw,u.reject=nw,u.remove=ny,u.rest=ww,u.reverse=ul,u.sampleSize=aw,u.set=IM,u.setWith=PM,u.shuffle=sw,u.slice=oy,u.sortBy=cw,u.sortedUniq=my,u.sortedUniqBy=dy,u.split=XM,u.spread=Mw,u.tail=fy,u.take=hy,u.takeRight=gy,u.takeRightWhile=yy,u.takeWhile=wy,u.tap=Oy,u.throttle=bw,u.thru=Sn,u.toArray=wu,u.toPairs=Pu,u.toPairsIn=Ru,u.toPath=Sb,u.toPlainObject=bu,u.transform=RM,u.unary=vw,u.union=My,u.unionBy=by,u.unionWith=vy,u.uniq=_y,u.uniqBy=Iy,u.uniqWith=Py,u.unset=FM,u.unzip=ml,u.unzipWith=iu,u.update=SM,u.updateWith=TM,u.values=Ir,u.valuesIn=EM,u.without=Ry,u.words=Tu,u.wrap=_w,u.xor=Fy,u.xorBy=Sy,u.xorWith=Ty,u.zip=Ey,u.zipObject=Cy,u.zipObjectDeep=Ay,u.zipWith=xy,u.entries=Pu,u.entriesIn=Ru,u.extend=vu,u.extendWith=Ln,_l(u,u),u.add=Eb,u.attempt=Eu,u.camelCase=OM,u.capitalize=Fu,u.ceil=Cb,u.clamp=CM,u.clone=Pw,u.cloneDeep=Fw,u.cloneDeepWith=Sw,u.cloneWith=Rw,u.conformsTo=Tw,u.deburr=Su,u.defaultTo=lb,u.divide=Ab,u.endsWith=LM,u.eq=rt,u.escape=BM,u.escapeRegExp=NM,u.every=qy,u.find=Wy,u.findIndex=Zc,u.findKey=nM,u.findLast=Ky,u.findLastIndex=jc,u.findLastKey=oM,u.floor=xb,u.forEach=ou,u.forEachRight=au,u.forIn=aM,u.forInRight=sM,u.forOwn=lM,u.forOwnRight=pM,u.get=yl,u.gt=Ew,u.gte=Cw,u.has=mM,u.hasIn=wl,u.head=tu,u.identity=Se,u.includes=Qy,u.indexOf=Kg,u.inRange=AM,u.invoke=hM,u.isArguments=nr,u.isArray=B,u.isArrayBuffer=Aw,u.isArrayLike=Re,u.isArrayLikeObject=te,u.isBoolean=xw,u.isBuffer=Ut,u.isDate=Ow,u.isElement=Lw,u.isEmpty=Bw,u.isEqual=Nw,u.isEqualWith=Uw,u.isError=hl,u.isFinite=Dw,u.isFunction=_t,u.isInteger=fu,u.isLength=xn,u.isMap=hu,u.isMatch=Gw,u.isMatchWith=$w,u.isNaN=Hw,u.isNative=Vw,u.isNil=kw,u.isNull=qw,u.isNumber=gu,u.isObject=j,u.isObjectLike=ee,u.isPlainObject=_i,u.isRegExp=gl,u.isSafeInteger=Ww,u.isSet=yu,u.isString=On,u.isSymbol=Le,u.isTypedArray=_r,u.isUndefined=Kw,u.isWeakMap=Xw,u.isWeakSet=Yw,u.join=Qg,u.kebabCase=UM,u.last=Ye,u.lastIndexOf=Zg,u.lowerCase=DM,u.lowerFirst=GM,u.lt=zw,u.lte=Jw,u.max=Ob,u.maxBy=Lb,u.mean=Bb,u.meanBy=Nb,u.min=Ub,u.minBy=Db,u.stubArray=Pl,u.stubFalse=Rl,u.stubObject=Ib,u.stubString=Pb,u.stubTrue=Rb,u.multiply=Gb,u.nth=jg,u.noConflict=hb,u.noop=Il,u.now=En,u.pad=$M,u.padEnd=HM,u.padStart=VM,u.parseInt=qM,u.random=xM,u.reduce=rw,u.reduceRight=iw,u.repeat=kM,u.replace=WM,u.result=_M,u.round=$b,u.runInContext=y,u.sample=ow,u.size=lw,u.snakeCase=KM,u.some=pw,u.sortedIndex=ay,u.sortedIndexBy=sy,u.sortedIndexOf=ly,u.sortedLastIndex=py,u.sortedLastIndexBy=cy,u.sortedLastIndexOf=uy,u.startCase=YM,u.startsWith=zM,u.subtract=Hb,u.sum=Vb,u.sumBy=qb,u.template=JM,u.times=Fb,u.toFinite=It,u.toInteger=U,u.toLength=Mu,u.toLower=QM,u.toNumber=ze,u.toSafeInteger=Qw,u.toString=W,u.toUpper=ZM,u.trim=jM,u.trimEnd=eb,u.trimStart=tb,u.truncate=rb,u.unescape=ib,u.uniqueId=Tb,u.upperCase=nb,u.upperFirst=Ml,u.each=ou,u.eachRight=au,u.first=tu,_l(u,function(){var t={};return lt(u,function(i,o){X.call(u.prototype,o)||(t[o]=i)}),t}(),{chain:!1}),u.VERSION=e,qe(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){u[t].placeholder=u}),qe(["drop","take"],function(t,i){H.prototype[t]=function(o){o=o===s?1:ae(U(o),0);var l=this.__filtered__&&!i?new H(this):this.clone();return l.__filtered__?l.__takeCount__=de(o,l.__takeCount__):l.__views__.push({size:de(o,st),type:t+(l.__dir__<0?"Right":"")}),l},H.prototype[t+"Right"]=function(o){return this.reverse()[t](o).reverse()}}),qe(["filter","map","takeWhile"],function(t,i){var o=i+1,l=o==ep||o==q;H.prototype[t]=function(p){var m=this.clone();return m.__iteratees__.push({iteratee:A(p,3),type:o}),m.__filtered__=m.__filtered__||l,m}}),qe(["head","last"],function(t,i){var o="take"+(i?"Right":"");H.prototype[t]=function(){return this[o](1).value()[0]}}),qe(["initial","tail"],function(t,i){var o="drop"+(i?"":"Right");H.prototype[t]=function(){return this.__filtered__?new H(this):this[o](1)}}),H.prototype.compact=function(){return this.filter(Se)},H.prototype.find=function(t){return this.filter(t).head()},H.prototype.findLast=function(t){return this.reverse().find(t)},H.prototype.invokeMap=G(function(t,i){return typeof t=="function"?new H(this):this.map(function(o){return gi(o,t,i)})}),H.prototype.reject=function(t){return this.filter(An(A(t)))},H.prototype.slice=function(t,i){t=U(t);var o=this;return o.__filtered__&&(t>0||i<0)?new H(o):(t<0?o=o.takeRight(-t):t&&(o=o.drop(t)),i!==s&&(i=U(i),o=i<0?o.dropRight(-i):o.take(i-t)),o)},H.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},H.prototype.toArray=function(){return this.take(st)},lt(H.prototype,function(t,i){var o=/^(?:filter|find|map|reject)|While$/.test(i),l=/^(?:head|last)$/.test(i),p=u[l?"take"+(i=="last"?"Right":""):i],m=l||/^find/.test(i);!p||(u.prototype[i]=function(){var d=this.__wrapped__,h=l?[1]:arguments,w=d instanceof H,I=h[0],P=w||B(d),R=function($){var V=p.apply(u,Et([$],h));return l&&T?V[0]:V};P&&o&&typeof I=="function"&&I.length!=1&&(w=P=!1);var T=this.__chain__,C=!!this.__actions__.length,x=m&&!T,D=w&&!C;if(!m&&P){d=D?d:new H(this);var O=t.apply(d,h);return O.__actions__.push({func:Sn,args:[R],thisArg:s}),new We(O,T)}return x&&D?t.apply(this,h):(O=this.thru(R),x?l?O.value()[0]:O.value():O)})}),qe(["pop","push","shift","sort","splice","unshift"],function(t){var i=Zi[t],o=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",l=/^(?:pop|shift)$/.test(t);u.prototype[t]=function(){var p=arguments;if(l&&!this.__chain__){var m=this.value();return i.apply(B(m)?m:[],p)}return this[o](function(d){return i.apply(B(d)?d:[],p)})}}),lt(H.prototype,function(t,i){var o=u[i];if(o){var l=o.name+"";X.call(yr,l)||(yr[l]=[]),yr[l].push({name:i,func:o})}}),yr[bn(s,ot).name]=[{name:"wrapper",func:s}],H.prototype.clone=ih,H.prototype.reverse=nh,H.prototype.value=oh,u.prototype.at=Ly,u.prototype.chain=By,u.prototype.commit=Ny,u.prototype.next=Uy,u.prototype.plant=Gy,u.prototype.reverse=$y,u.prototype.toJSON=u.prototype.valueOf=u.prototype.value=Hy,u.prototype.first=u.prototype.head,pi&&(u.prototype[pi]=Dy),u},At=Nf();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(le._=At,define(function(){return At})):Jt?((Jt.exports=At)._=At,vs._=At):le._=At}).call(Sr)});var Xl=Dt(Gt());var Gm=Dt(Um());var Kl=s=>{let e=250,r=[],n=0;return r[n]=[],s.forEach(a=>{r[n].length<=e?r[n].push(a):(n++,r[n]=[a])}),r},Vn=s=>{let e=[],r=200;for(;s.length>r;){let n=s.splice(0,r);e.push(n)}return e.push(s),e},Ee=(s,e)=>{let r="",n={profile:"https://profile.fansunitedapi.com/v1",football:"https://football.fansunitedapi.com/v1",idMapping:"https://id-mapping.fansunitedapi.com/v1",predictor:"https://prediction.fansunitedapi.com/v1",client:"https://client.fansunitedapi.com/v1",loyalty:"https://loyalty.fansunitedapi.com/v1"},a={profile:"http://localhost:8010/v1",football:"http://locahost:8080/v1",idMapping:"http://localhost:8030/v1",predictor:"http://localhost:8040/v1",client:"http://localhost:8070/v1",loyalty:"http://localhost:8060/v1"},c={profile:"https://profile.fansunitedstagingapi.com/v1",football:"https://football.fansunitedstagingapi.com/v1",idMapping:"https://id-mapping.fansunitedstagingapi.com/v1",predictor:"https://prediction.fansunitedstagingapi.com/v1",client:"https://client.fansunitedstagingapi.com/v1",loyalty:"https://loyalty.fansunitedstagingapi.com/v1"};return s==="prod"?r=n[e]:s==="dev"?r=a[e]:r=c[e],r},$t=s=>s.filter((r,n,a)=>n===a.indexOf(r)),qn=s=>Array.isArray(s)?s.map(e=>qn(e)):s!=null&&s.constructor===Object?Object.keys(s).reduce((e,r)=>({...e,[(0,Gm.camelCase)(r)]:qn(s[r])}),{}):s;var kn=class{id=null;name=null;avatar=null;gender=null;country=null;birthDate=null;interests=[];followingCount=0;followersCount=0};var Wn=class{profilesFromResponse=e=>e?e.map(r=>this.fullProfileFromResponse(r)):null;fullProfileFromResponse=e=>{let r=new kn;return r.id=e.id,r.name=e.name,r.avatar=e.avatar,r.gender=e.gender,r.country=e.country,r.birthDate=e.birth_date,r.interests=e.interests,r.followingCount=e.following_count,r.followersCount=e.followers_count,r}};var Kn=class{nextPageStartsAfter=null;itemsPerPage=null};var Tr=class{pagination=new Kn};var ie=class{meta=new Tr;data=[]};var Xn=class{avatar=null;followingId=null;name=null;profileId=null};var Yn=class{followResponse=e=>e.map(r=>this.remapResponse(r));followingFromResponse=e=>{let r=new ie;return r.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,r.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,r.data=e.data.map(n=>this.remapResponse(n)),r};remapResponse=e=>{let r=new Xn;return r.avatar=e.avatar,r.followingId=e.following_id,r.name=e.name,r.profileId=e.profile_id,r}};var zn=class{avatar=null;followerId=null;name=null;profileId=null};var Jn=class{followersFromResponse=e=>{let r=new ie;return r.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,r.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,r.data=e.data.map(n=>this.remapResponse(n)),r};remapResponse=e=>{let r=new zn;return r.avatar=e.avatar,r.followerId=e.follower_id,r.name=e.name,r.profileId=e.profile_id,r}};var Si=class{profile_ids=[]};var kv="/countries",Je="/profile",$m="/profiles",Qn=class{instanceAuth=null;instance=null;apiSignInUrl=null;profileRemapper=null;followingRemapper=null;followersRemapper=null;lang=null;constructor(e){this.lang=e.lang;let r=Ee(e.environment,"profile");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instanceAuth=Xl.default.create({baseURL:r,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instanceAuth.interceptors.request.use(n=>n,n=>{Promise.reject(n)}),this.instanceAuth.interceptors.response.use(n=>n,n=>{let a=n.config;if((n.response.status===403||n.response.status===401)&&!a._retry){a._retry=!0;let c=e.authProvider.getIdToken();return a.headers.Authorization=`Bearer ${c}`,this.instanceAuth(a)}return Promise.reject(n)}),this.instance=Xl.default.create({baseURL:r,headers:{"Content-Type":"application/json"}}),this.profileRemapper=new Wn,this.followingRemapper=new Yn,this.followersRemapper=new Jn}getCountries=async e=>{try{let r=`&lang=${this.lang}`,n=`${kv}${this.apiSignInUrl}${r}`,a=Date.now();return e&&(n+=`&disable_cache=${a}`),(await this.instance.get(n)).data.data}catch(r){throw console.warn("There was a problem fetching the countries:",r),r.response}};getProfile=async e=>{let r=`${Je}${this.apiSignInUrl}`;if(e){r=`${$m}/${e}${this.apiSignInUrl}`;try{let n=await this.instance.get(r);return this.profileRemapper.fullProfileFromResponse(n.data.data)}catch(n){throw console.warn(`There was a problem fetching the following profile: ${e}`,n),n.response}}else try{let n=await this.instanceAuth.get(r);return this.profileRemapper.fullProfileFromResponse(n.data.data)}catch(n){throw console.warn("There was a problem fetching your profile from API:",n),n.response}};getProfiles=async(e,r)=>{try{let n=`${$m}${this.apiSignInUrl}&profile_ids=${e.join(",")}`,a=Date.now();r&&(n+=`&disable_cache=${a}`);let c=await this.instance.get(n);return this.profileRemapper.profilesFromResponse(c.data.data)}catch(n){throw console.warn(`There was a problem fetching the following profiles: ${e.join(",")}`,n),n.response}};getFollowers=async(e,r)=>{let n=`${Je}/followers${this.apiSignInUrl}`;if(e&&!r){n=`${Je}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let a=await this.instanceAuth.get(n);return this.followersRemapper.followersFromResponse(a.data)}catch(a){throw console.warn("There was a problem fetching the followers for own profile",a),a.response}}else if(!e&&!r)try{let a=await this.instanceAuth.get(n);return this.followersRemapper.followersFromResponse(a.data)}catch(a){throw console.warn("There was a problem fetching the followers for own profile",a),a.response}e&&r?n=`${Je}/${r}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&r&&(n=`${Je}/${r}/followers${this.apiSignInUrl}`);try{let a=await this.instance.get(n);return this.followersRemapper.followersFromResponse(a.data)}catch(a){throw console.warn(`There was a problem fetching the followers for profile: ${r}`,a),a.response}};getFollowing=async(e,r)=>{let n=`${Je}/following${this.apiSignInUrl}`;if(e&&!r){n=`${Je}/following${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let a=await this.instanceAuth.get(n);return this.followingRemapper.followingFromResponse(a.data)}catch(a){throw console.warn("There was a problem fetching the followers of own profile",a),a.response}}else if(!e&&!r)try{let a=await this.instanceAuth.get(n);return this.followingRemapper.followingFromResponse(a.data)}catch(a){throw console.warn("There was a problem fetching the followers of own profile",a),a.response}e&&r?n=`${Je}/${r}/following${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&r&&(n=`${Je}/${r}/following${this.apiSignInUrl}`);try{let a=await this.instance.get(n);return this.followingRemapper.followingFromResponse(a.data)}catch(a){throw console.warn(`There was a problem fetching the followers of the following profile: ${r}`,a),a.response}};follow=async e=>{let r=new Si;r.profile_ids=e;try{let n=await this.instanceAuth.post(`${Je}/follow${this.apiSignInUrl}`,JSON.stringify(r));return this.followingRemapper.followResponse(n.data.data)}catch(n){throw console.warn(`There was a problem with POST request for profiles: ${e.join(",")} `,n),n.response}};unfollow=async e=>{let r=new Si;r.profile_ids=e;try{return await this.instanceAuth.delete(`${Je}/follow${this.apiSignInUrl}`,{data:JSON.stringify(r)}),!0}catch(n){throw console.warn(`There was a problem with DELETE request for profiles: ${e.join(",")} `,n),n.response}};updateProfile=async e=>{try{let r=await this.instanceAuth.patch(`${Je}${this.apiSignInUrl}`,e);return this.profileRemapper.fullProfileFromResponse(r.data.data)}catch(r){throw console.warn("There was a problem updating the own profile:",r),r.response}}};var Rt={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id"};var Hm="FansUnited",Vm={football:{ids:[],countries:[],competitions:[]},profile:{own:{},countries:[],expireAt:0}},Ht=class{idSchema="";expirationTimeout=600;constructor(e){this.idSchema=e.idSchema,(this.getData()===void 0||this.getData()===null)&&this.setData(Vm)}clearData=()=>{this.setData(Vm)};getEntityById=(e="",r="")=>this.getData().football.ids.find(n=>{let a=Rt[this.idSchema];return n&&`${n[a]}`===r&&n.resource===e});getEntity=(e,r,n)=>Array.isArray(e)?this.getData().football.ids.filter(a=>{let c=Rt[n];return a&&e.includes(`${a[c]}`)&&a.resource===r}):this.getData().football.ids.find(a=>{let c=Rt[n];return a&&`${a[c]}`===e&&a.resource===r});getEntityByNativeId=(e="",r="")=>this.getData().football.ids.find(n=>n&&`${n.id}`===r&&n.resource===e);checkForExistingIdObjs=(e,r)=>{let n=Rt[r],a={};return Object.keys(e).forEach(c=>{let f=e[c],v=this.getEntity(f,c,r).map(M=>M[n]),S=e[c].filter(M=>!v.includes(M));a[c]=f.map(M=>S.includes(M)?{id:M,exists:!1}:{id:M,exists:!0})}),a};getIdsByType=(e,r,n)=>{let a=Rt[n],c=Rt[r],f={};return Object.keys(e).forEach(g=>{let v=e[g],S=[];this.getData().football.ids.forEach(M=>{v.forEach((F,Y)=>{F===M[c]&&g===M.resource&&(S[Y]=M[a])})}),f[g]=S}),f};addIdMapping=e=>{let r=this.getData();r.football.ids.push(e),this.setData(r)};addIdMappings=e=>{let r=this.getData(),n=r.football.ids;n=[...n,...e],r.football.ids=n,this.setData(r)};setOwnProfile=e=>{let r=this.getData();r.profile.own=e,r.profile.expireAt=Math.floor(Date.now()/1e3)+this.expirationTimeout,this.setData(r)};getOwnProfile=()=>this.getData().profile.own;getProfileCountries=()=>this.getData().profile.countries;setProfileCountries=e=>{let r=this.getData();r.profile.countries=e,this.setData(r)};getFootballCountries=()=>this.getData().football.countries;setFootballCountries=e=>{let r=this.getData();r.football.countries=e,this.setData(r)};getCompetitions=e=>{let r=this.getData();return e?e.competitionSearchFilter(r.football.competitions):r.football.competitions};setCompetitions=e=>{let r=this.getData();r.football.competitions.push(...e),this.setData(r)};getExpirationProfile=()=>this.getData().profile.expireAt;getData=()=>JSON.parse(localStorage.getItem(Hm));setData=e=>{localStorage.setItem(Hm,JSON.stringify(e))}};var qm=Dt(Gt());var Ti={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},Zn=class{instance=null;apiSignInUrl="";constructor(e){let r=Ee(e.environment,"idMapping");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instance=qm.default.create({baseURL:r})}getEntityById=(e,r)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${config.idSchema}&${Ti[e]}=${r}`)}catch(n){throw console.warn(`There was a problem with id mapping request for the following id:${r}`,n),n.response}};getEntityByIdAndSchema=(e,r,n)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${Ti[e]}=${r}`)}catch(a){throw console.warn(`There was a problem with id mapping request for the following id:${r}`,a),a.response}};getEntityIdsByIdsAndSchema=(e,r,n)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${Ti[e]}=${r.join(",")}`)}catch(a){throw console.warn(`There was a problem with id mapping request for the following ids:${r.join(",")}`,a),a.response}};getEntitiesByIds=(e,r,n)=>{r.sort((f,g)=>f.localeCompare(g));let c=Kl(r).map(f=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${Ti[e]}=${f.join(",")}`)}catch(g){throw console.warn(`There was a problem with id mapping request for the following ids:${f.join(",")}`,g),g.response}});return Promise.all(c).then(f=>{let g=[];return f.forEach(v=>{g.push(...v.data.data)}),g})};getEntitiesByIdObjs=async(e,r)=>{let n=[],a={},c=[];Object.keys(e).forEach(S=>{n.push.apply(n,e[S])});let f=$t(n),g=Kl(f);for(let S of g){let M="";if(Object.keys(e).forEach(F=>{a[F]=[];let Y=S.filter(ve=>e[F].includes(ve));Y&&Y.length>0&&(a[F]=Y)}),Object.keys(a).forEach(F=>{a[F].length>0&&(a[F].sort((Y,ve)=>Y.localeCompare(ve)),M+="&",M+=`${Ti[F]}=${a[F].join(",")}`)}),M&&M.length>0)try{let F=await this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r||"native"}${M}`);c.push(F.data.data)}catch(F){throw console.warn("There was a problem with id mapping request",F),F.response}else c.push([])}return Array.prototype.concat.apply([],c)}};var jn=class{isBrowser=!1;localStorage=null;https=null;constructor(e){this.isBrowser=typeof window!="undefined",this.localStorage=new Ht(e),this.https=new Zn(e)}getEntitiesByIds=async(e,r,n)=>{if(this.isBrowser)try{let a=this.localStorage.checkForExistingIdObjs(e,r),c=this.splitForRequestAndExisting(a),f=await this.https.getEntitiesByIdObjs(c.request,r);return this.localStorage.addIdMappings(f),this.localStorage.getIdsByType(e,r,n)}catch(a){return console.warn("There was a problem retrieving the entity ids ",a),Promise.resolve([])}else try{let a=await this.https.getEntitiesByIdObjs(e,r);return Object.keys(e).forEach(c=>{e[c]=a.filter(f=>f.resource===c).map(f=>f[Rt[n]])}),e}catch(a){return console.warn("There was a problem retrieving the entity ids ",a),Promise.resolve([])}};getEntityById=async(e,r,n)=>{if(this.isBrowser){let a=this.localStorage.getEntity(e,r,n);if(a)return a;{let c=await this.requestEntity(e,r,n);return this.localStorage.addIdMappings(c),c}}else return await this.requestEntity(e,r,n)};splitForRequestAndExisting=e=>{let r={},n={};return Object.keys(e).forEach(a=>{r[a]=e[a].filter(c=>!c.exists).map(c=>c.id),n[a]=e[a].filter(c=>c.exists).map(c=>c.id)}),{existing:n,request:r}};requestEntity=async(e,r,n)=>{try{return e=Array.isArray(e)?e:[e],await this.https.getEntitiesByIds(r,e,n)}catch(a){return console.warn(`There was a problem retrieving the requested entity: ${a}`),null}}};var eo=s=>{switch(s){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 s}};var to=class{extractedObjIds={};traverse=(e,r)=>(r=eo(r),Array.isArray(e)?this.traverseArrExtract(e,r):e&&typeof e=="object"&&this.traverseObjExtract(e,r),this.extractedObjIds);traverseArrExtract=(e,r)=>{e&&e.length>0&&e.forEach(n=>{this.traverseObjExtract(n,r)})};traverseObjExtract=(e,r)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(n=>{let a=e[n];n==="id"||n==="teamId"?(this.extractedObjIds.hasOwnProperty(r)||(this.extractedObjIds[r]=[]),this.extractedObjIds[r].push(a)):e[n]&&this.traverse(e[n],n)})}};var ro=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(e,r,n)=>(r=eo(r),this.replaceObjIdsIndex===null&&(this.initReplaceObjIdsIndex(n),this.remappedIdsObj=n),Array.isArray(e)?this.traverseArrReplace(e,r):e&&typeof e=="object"&&this.traverseObjReplace(e,r),e);initReplaceObjIdsIndex=e=>{this.replaceObjIdsIndex={},Object.keys(e).forEach(r=>{this.replaceObjIdsIndex[r]=0})};traverseArrReplace=(e,r)=>{e&&e.length>0&&e.forEach(n=>{this.traverseObjReplace(n,r)})};traverseObjReplace=(e,r)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(n=>{n==="id"||n==="teamId"?(e[n]=this.remappedIdsObj[r][this.replaceObjIdsIndex[r]],this.replaceObjIdsIndex[r]=this.replaceObjIdsIndex[r]+1):e[n]&&this.traverse(e[n],n,this.remappedIdsObj)})}};var he=class{idSchema="";idMappingFacade=null;constructor(e){this.idSchema=e.idSchema,this.idMappingFacade=new jn(e)}getEntityIdBySchemaId=(e,r)=>this.idMappingFacade.getEntityById(e,r,this.idSchema);remapEntities=async(e,r)=>{let n=JSON.parse(JSON.stringify(e));try{if(this.idSchema!=="native"){let c=new to().traverse(n,r);return this.idMappingFacade.getEntitiesByIds(c,"native",this.idSchema).then(f=>new ro().traverse(n,r,f))}else return e}catch(a){return console.warn(`There was a problem remapping entity: ${r} with inner entity `,a),[]}};getEntityIdsBySchemaId=async(e,r,n)=>{let a={};return a[r]=e,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(a,this.idSchema,n):a}};var De=class{completed=!1;percentage;constructor(e){this.percentage=e}};var io=class{teamFollowed=new De(10);teamFavourite=new De(15);playerFollowed=new De(10);playerFavourite=new De(10);competitionFollowed=new De(10);competitionFavourite=new De(5);addedBirthdate=new De(10);addedGender=new De(10);addedCountry=new De(10);addedAvatar=new De(10)};var no=class{totalPercentage;breakdown=new io};var Ei=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 qt=class{isBrowser=!1;localStorage={};https=null;constructor(e,r){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.https=r}getOwn=async()=>{if(this.isBrowser){let e=Math.floor(Date.now()/1e3),r=this.localStorage.getExpirationProfile(),n=null;if(r>e&&(n=this.localStorage.getOwnProfile()),n)return JSON.parse(JSON.stringify(n));try{let a=await this.https.getProfile();return this.localStorage.setOwnProfile(a),a}catch(a){throw console.warn("There was a problem retrieving your profile: ",a),a}}else try{return await this.https.getProfile()}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};getByIds=async(e,r)=>{try{return r=r||!1,await this.https.getProfiles(e,r)}catch(n){throw console.warn(`There was a problem retrieving the selected profiles: ${e.join(",")} `,n),n}};getById=async e=>{try{return await this.https.getProfile(e)}catch(r){throw console.warn(`There was a problem retrieving the selected profile: ${e} `,r),r}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let r=this.localStorage.getProfileCountries();if(r&&r.length>0)return r;try{let n=await this.https.getCountries(e);return this.localStorage.setProfileCountries(n),n}catch(n){throw console.warn("There was a problem retrieving profile countries: ",n),n}}else try{return await this.https.getCountries(e)}catch(r){throw console.warn("There was a problem retrieving profile countries: ",r),r}};getFollowers=async(e,r)=>{try{return e&&(e=new Ei(e)),await this.https.getFollowers(e,r)}catch(n){throw console.warn("There was a problem retrieving your followers: ",n),n}};getFollowing=async(e,r)=>{try{return e&&(e=new Ei(e)),await this.https.getFollowing(e,r)}catch(n){throw console.warn("There was a problem retrieving your following profiles: ",n),n}};follow=async e=>{try{return await this.https.follow(e)}catch(r){throw console.warn(`There was a problem following profiles: ${e.join(",")} `,r),r}};unfollow=async e=>{try{return await this.https.unfollow(e)}catch(r){throw console.warn(`There was a problem unfollowing profiles: ${e.join(",")} `,r),r}};showFullnessProfile=e=>{let r=new no,n=0;return e.avatar&&(r.breakdown.addedAvatar.completed=!0,n+=r.breakdown.addedAvatar.percentage),e.birthDate&&(r.breakdown.addedBirthdate.completed=!0,n+=r.breakdown.addedBirthdate.percentage),e.country&&(r.breakdown.addedCountry.completed=!0,n+=r.breakdown.addedCountry.percentage),e.gender&&(r.breakdown.addedGender.completed=!0,n+=r.breakdown.addedGender.percentage),e.interests&&e.interests.length>0&&(e.interests.find(M=>M.type==="team"&&M.favourite)&&(r.breakdown.teamFavourite.completed=!0,n+=r.breakdown.teamFavourite.percentage),e.interests.find(M=>M.type==="team")&&(r.breakdown.teamFollowed.completed=!0,n+=r.breakdown.teamFollowed.percentage),e.interests.find(M=>M.type==="player"&&M.favourite)&&(r.breakdown.playerFavourite.completed=!0,n+=r.breakdown.playerFavourite.percentage),e.interests.find(M=>M.type==="player")&&(r.breakdown.playerFollowed.completed=!0,n+=r.breakdown.playerFollowed.percentage),e.interests.find(M=>M.type==="competition"&&M.favourite)&&(r.breakdown.competitionFavourite.completed=!0,n+=r.breakdown.competitionFavourite.percentage),e.interests.find(M=>M.type==="competition")&&(r.breakdown.competitionFollowed.completed=!0,n+=r.breakdown.competitionFollowed.percentage)),r.totalPercentage=n,r}};var oo=class{id=null;name=null;assets=null};var ao=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,r,n){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=n,this.https=r}getCountriesWithIdMapping=async e=>{try{let r=await this.getCountries(e);return this.idMapping.remapEntities(r,"country")}catch(r){throw console.warn("There was a problem browsing countries as football entities",r),r}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let r=this.localStorage.getFootballCountries();if(r&&r.length>0)return r;try{let n=await this.https.getCountries(e);return this.localStorage.setFootballCountries(n),n}catch(n){throw console.warn("There was a problem retrieving countries as football entities",n),n}}else return this.https.getCountries(e)}};var so=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 r=this.filter(e);return this.sortField||this.sortOrder?this.sort(r):r}catch(r){return console.warn("There was a problem filtering the local competitions",r),[]}};filter=e=>{let r=this.entitiesToSearchWith();return e.filter(n=>{let a=!0;return r.forEach(c=>{c!=="sortOrder"&&c!=="sortField"&&(c==="countryId"?a&&=n.country.id===this[c]:c==="name"?a&&=n.name.toLocaleLowerCase().includes(this[c].toLocaleLowerCase()):c==="competitionIds"?a&&=this[c].some(f=>n.id===f):a&&=n[c].toLocaleLowerCase()===this[c].toLocaleLowerCase())}),a})};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 r=[];return this.sortField==="name"?r=e.sort((n,a)=>this.sortOrder&&this.sortOrder==="desc"?a.name.localeCompare(n.name):n.name.localeCompare(a.name)):this.sortField==="countryId"?r=e.sort((n,a)=>this.sortOrder&&this.sortOrder==="desc"?a.country.id.localeCompare(n.country.id):n.country.id.localeCompare(a.country.id)):this.sortField==="scope"?e.forEach(n=>r[this.competitionIds.indexOf(n.id)]=n):!this.sortField&&this.sortOrder==="desc"&&(r=e.sort((n,a)=>a.id.localeCompare(n.id))),r}};var lo=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,r,n){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=n,this.https=r}getCompetitionsIdMapping=async(e,r)=>{try{let n=!1;if(e){if(e=new so(e),e.countryId){let c=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");c.country.length===0&&(n=!0),e.countryId=c.country[0]}if(e.competitionIds){let c=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");c.competition.length===0&&(n=!0),e.competitionIds=c.competition}if(n)return[]}let a=await this.getCompetitions(e,r);return await this.idMapping.remapEntities(a,"competition")}catch(n){throw console.warn("There was a problem browsing all of the competitions",n),n}};getCompetitions=async(e,r)=>{if(r=r||!1,this.isBrowser){let n=this.localStorage.getCompetitions(e);if(n&&n.length>0)return n;try{let a=await this.https.getCompetitions(e,r);return this.localStorage.setCompetitions(a),this.localStorage.getCompetitions(e)}catch(a){throw console.warn("There was a problem retrieving all competitions",a),a}}else return this.https.getCompetitions(e,r)};getCompetitionByIdIdMapping=async(e,r)=>{try{let a=(await this.idMapping.getEntityIdsBySchemaId([e],"competition","native")).competition[0],c=await this.getCompetitionById(a,r);return await this.idMapping.remapEntities(c,"competition")}catch(n){throw console.warn(`There was a problem browsing the following competition:${e}`,n),n}};getCompetitionById=async(e,r)=>{try{return r=r||!1,await this.https.getCompetitionById(e,r)}catch(n){throw console.warn(`There was a problem retrieving the competition with the following id: ${e}`,n),n}};getTopCompetitionsIdMapping=async e=>{try{let r=await this.getTopCompetitions(e);return await this.idMapping.remapEntities(r,"competition")}catch(r){throw console.warn("There was a problem browsing the top competitions",r),r}};getTopCompetitions=async e=>{try{return e=e||!1,await this.https.getTopCompetitions(e)}catch(r){throw console.warn("There was a problem retrieving the top competitions",r),r}}};var po=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 co=class{https=null;idMapping=null;constructor(e,r){this.idMapping=r,this.https=e}getTeamsIdMapping=async(e,r)=>{try{let n=!1;if(e){if(e=new po(e),e.countryId){let c=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");c.country.length===0&&(n=!0),e.countryId=c.country[0]}if(e.scope){let c=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");c.competition.length===0&&(n=!0),e.scope=c.competition}if(e.teamIds){let c=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");c.team.length===0&&(n=!0),e.teamIds=c.team}}if(n)return[];let a=await this.getTeams(e,r);return a.data=await this.idMapping.remapEntities(a.data,"team"),a}catch(n){throw console.warn("There was a problem browsing all teams",n),n}};getTeams=async(e,r)=>{try{return r=r||!1,await this.https.getTeams(e,r)}catch(n){throw console.warn("There was a problem retrieving all teams",n),n}};getTeamByIdIdMapping=async(e,r)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let a=await this.getTeamById(e,r);return await this.idMapping.remapEntities(a,"team")}catch(n){throw console.warn(`There was a problem browsing the following team:${e}`,n),n}};getTeamById=async(e,r)=>{try{return r=r||!1,await this.https.getTeamById(e,r)}catch(n){throw console.warn(`There was a problem retrieving the following team: ${e}`,n),n}};getTopTeamsIdMapping=async e=>{try{let r=await this.getTopTeams(e);return await this.idMapping.remapEntities(r,"team")}catch(r){throw console.warn("There was a problem browsing the top teams",r),r}};getTopTeams=async e=>{try{return e=e||!1,await this.https.getTopTeams(e)}catch(r){throw console.warn("There was a problem retrieving the top teams",r),r}};getNextMatchForTeamIdMapping=async(e,r)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let a=await this.getNextMatchForTeam(e,r);return await this.idMapping.remapEntities(a,"match")}catch(n){throw console.warn(`There was a problem browsing the next match for the following team:${e}`,n),n}};getNextMatchForTeam=async(e,r)=>{try{return r=r||!1,await this.https.getNextMatchForTeam(e,r)}catch(n){throw console.warn(`There was a problem retrieving the next match for the following team: ${e}`,n),n}};getPrevMatchForTeamIdMapping=async(e,r)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let a=await this.getPrevMatchForTeam(e,r);return await this.idMapping.remapEntities(a,"match")}catch(n){throw console.warn(`There was a problem browsing the previous match for the following team:${e}`,n),n}};getPrevMatchForTeam=async(e,r)=>{try{return r=r||!1,await this.https.getPrevMatchForTeam(e,r)}catch(n){throw console.warn(`There was a problem retrieving the previous match for the following team: ${e}`,n),n}}};var Ci=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 kt=class{https=null;idMapping=null;constructor(e,r){this.idMapping=r,this.https=e}getPlayersIdMapping=async(e,r)=>{try{let n=!1;if(e){if(e=new Ci(e),e.countryId){let c=await this.idMapping.getEntityIdsBySchemaId([e.countryId],"country","native");c.country.length===0&&(n=!0),e.countryId=c.country[0]}if(e.playerIds){let c=await this.idMapping.getEntityIdsBySchemaId(e.playerIds,"player","native");c.player.length===0&&(n=!0),e.playerIds=c.player}if(e.scope){let c=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");c.competition.length===0&&(n=!0),e.scope=c.competition}if(n)return[]}let a=await this.getPlayers(e,r);return a.data=await this.idMapping.remapEntities(a.data,"player"),a}catch(n){throw console.warn("There was a problem browsing the players",n),n}};getPlayersWithNativeIds=async e=>{let r=new Ci({playerIds:e}),n=await this.getPlayers(r);return n.data.sort((a,c)=>a.id.localeCompare(c.id)),await this.idMapping.remapEntities(n.data,"player")};getPlayersMapWithNativeIds=async e=>{let r={},n=$t(e);n.sort((c,f)=>c.localeCompare(f));let a=await this.getPlayersWithNativeIds(n);return n.forEach((c,f)=>r[c]=a[f]),r};getPlayers=async(e,r)=>{try{return r=r||!1,await this.https.getPlayers(e,r)}catch(n){throw console.warn("There was a problem retrieving the players",n),n}};getPlayerIdMapping=async(e,r)=>{try{let n=await this.idMapping.getEntityIdsBySchemaId([e],"player","native"),a=await this.getPlayerById(n.player[0],r);return await this.idMapping.remapEntities(a,"player")}catch(n){throw console.warn(`There was a problem browsing the following player:${e}`,n),n}};getPlayerById=async(e,r)=>{try{return r=r||!1,await this.https.getPlayerById(e,r)}catch(n){throw console.warn(`There was a problem retrieving the following player: ${e}`,n),n}};getTopPlayersIdMapping=async e=>{try{let r=await this.getTopPlayers(e);return await this.idMapping.remapEntities(r,"player")}catch(r){throw console.warn("There was a problem browsing the top players",r),r}};getTopPlayers=async e=>{try{return e=e||!1,await this.https.getTopPlayers(e)}catch(r){throw console.warn("There was a problem retrieving the top players",r),r}};getNextMatchForPlayerIdMapping=async(e,r)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let a=await this.getNextMatchForPlayer(e,r);return await this.idMapping.remapEntities(a,"match")}catch(n){throw console.warn(`There was a problem browsing the next match for player:${e}`,n),n}};getNextMatchForPlayer=async(e,r)=>{try{return r=r||!1,await this.https.getNextMatchForPlayer(e,r)}catch(n){throw console.warn(`There was a problem retrieving the next match for player: ${e}`,n),n}};getPrevMatchForPlayerIdMapping=async(e,r)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let a=await this.getPrevMatchForPlayer(e,r);return await this.idMapping.remapEntities(a,"match")}catch(n){throw console.warn(`There was a problem browsing the previous match for player:${e}`,n),n}};getPrevMatchForPlayer=async(e,r)=>{try{return r=r||!1,await this.https.getPrevMatchForPlayer(e,r)}catch(n){throw console.warn(`There was a problem retrieving the previous match for player: ${e}`,n),n}}};var Ai=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 Wt=class{https=null;idMapping=null;constructor(e,r){this.https=e,this.idMapping=r}getMatchesIdMapping=async(e,r)=>{try{if(e){if(e=new Ai(e),e.countryIds){let a=await this.idMapping.getEntityIdsBySchemaId(e.countryIds,"country","native");e.countryIds=a.country}if(e.competitionIds){let a=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");e.competitionIds=a.competition}if(e.matchIds){let a=await this.idMapping.getEntityIdsBySchemaId(e.matchIds,"match","native");e.matchIds=a.match}if(e.teamIds){let a=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");e.teamIds=a.team}}let n=await this.getMatches(e,r);return n.data=await this.idMapping.remapEntities(n.data,"match"),n}catch(n){throw console.warn("There was a problem browsing the matches",n),n}};getMatchesWithNativeIds=async e=>{let r=e.length,n=new Ai({matchIds:e,limit:r}),a=await this.getMatches(n);return a.data.sort((c,f)=>c.id.localeCompare(f.id)),await this.idMapping.remapEntities(a.data,"match")};getMatchesMapWithNativeIds=async e=>{let r={},n=$t(e);n.sort((c,f)=>c.localeCompare(f));let a=await this.getMatchesWithNativeIds(n);return n.forEach((c,f)=>r[c]=a[f]),r};getMatches=async(e,r)=>{try{return r=r||!1,await this.https.getMatches(e,r)}catch(n){throw console.warn("There was a problem retrieving the matches",n),n}};getMatchIdMapping=async(e,r)=>{try{let n=await this.idMapping.getEntityIdsBySchemaId([e],"match","native"),a=await this.getMatchById(n.match[0],r);return await this.idMapping.remapEntities(a,"match")}catch(n){throw console.warn(`There was a problem browsing the following match: ${e}`,n),n}};getMatchById=async(e,r)=>{try{return r=r||!1,await this.https.getMatchById(e,r)}catch(n){throw console.warn(`There was a problem retrieving the following match: ${e}`,n),n}}};var uo=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 mo=class{https=null;idMapping=null;constructor(e,r){this.https=e,this.idMapping=r}searchIdMapping=async(e,r)=>{try{if(e=new uo(e),e.scope){let a=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");e.scope=a.competition}let n=await this.search(e,r);if(n.teams&&n.teams.length>0){let a=await this.idMapping.remapEntities(n.teams,"team");n.teams=a}if(n.players&&n.players.length>0){let a=await this.idMapping.remapEntities(n.players,"player");n.players=a}if(n.competitions&&n.competitions.length>0){let a=await this.idMapping.remapEntities(n.competitions,"competition");n.competitions=a}return n}catch(n){throw console.warn("There was a problem with browsing the search result",n),n}};search=async(e,r)=>{try{return await this.https.search(e,r)}catch(n){throw console.warn("There was a problem retrieving the search response",n),n}}};var Kt=class{isBrowser=!1;localStorage={};https=null;idMapping=null;countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(e,r,n){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=n,this.https=r,this.countriesFacade=new ao(e,r,n),this.competitionsFacade=new lo(e,r,n),this.teamsFacade=new co(r,n),this.playerFacade=new kt(r,n),this.matchFacade=new Wt(r,n),this.searchFacade=new mo(r,n)}getCountries=async e=>this.countriesFacade.getCountriesWithIdMapping(e);getCompetitions=async(e,r)=>this.competitionsFacade.getCompetitionsIdMapping(e,r);getCompetitionById=async(e,r)=>this.competitionsFacade.getCompetitionByIdIdMapping(e,r);getTopCompetitions=async e=>this.competitionsFacade.getTopCompetitionsIdMapping(e);getTeams=async(e,r)=>this.teamsFacade.getTeamsIdMapping(e,r);getTeamById=async(e,r)=>this.teamsFacade.getTeamByIdIdMapping(e,r);getTopTeams=async e=>this.teamsFacade.getTopTeamsIdMapping(e);getNextMatchForTeam=async(e,r)=>this.teamsFacade.getNextMatchForTeamIdMapping(e,r);getPrevMatchForTeam=async(e,r)=>this.teamsFacade.getPrevMatchForTeamIdMapping(e,r);getPlayers=async(e,r)=>this.playerFacade.getPlayersIdMapping(e,r);getPlayerById=async(e,r)=>this.playerFacade.getPlayerIdMapping(e,r);getTopPlayers=async e=>this.playerFacade.getTopPlayersIdMapping(e);getNextMatchForPlayer=async(e,r)=>this.playerFacade.getNextMatchForPlayerIdMapping(e,r);getPrevMatchForPlayer=async(e,r)=>this.playerFacade.getPrevMatchForPlayerIdMapping(e,r);getMatches=async(e,r)=>this.matchFacade.getMatchesIdMapping(e,r);getMatchById=async(e,r)=>this.matchFacade.getMatchIdMapping(e,r);search=async(e,r)=>this.searchFacade.searchIdMapping(e,r)};var Er=class{idMapping=null;footballFacade=null;constructor(e,r){this.idMapping=e,this.footballFacade=r}remapInterestsToIdSchema=async e=>{let r=this.idMapping.idSchema;if(r!=="native")if(e&&e.length>0){let n={},a={};e.forEach(g=>{n.hasOwnProperty(g.type)||(n[g.type]=[],a[g.type]=[]),n[g.type].push(g.id),a[g.type].push(g)});let c=await this.idMapping.idMappingFacade.getEntitiesByIds(n,"native",r),f=[];for(let[g,v]of Object.entries(a))v.forEach((S,M)=>{S.id=c[g][M],f.push(S)});return f}else return e;return e};remapInterestToNative=async e=>{let r=this.idMapping.idSchema;if(r!=="native"){let n={},{id:a,type:c}=e;n[c]=[a];let f=await this.idMapping.idMappingFacade.getEntitiesByIds(n,r,"native");return e.id=f[c][0],e}return e};inquiryCustomInterests=async e=>{let r=[];if(e&&e.length>0&&(r=e.filter(n=>n.source==="custom")),r&&r.length>0){let n=e.filter(c=>c.source!=="custom"),a=await this.remapInterestsToIdSchema(n);return r.forEach(c=>a.push(c)),a}return await this.remapInterestsToIdSchema(e)};showFullInterests=async e=>{let r=[];if(e&&e.length>0)for(let n of e)if(n.source!=="custom"&&n.source==="football"){let a={};if(n.type==="team"){a.teamIds=[n.id];let c=await this.footballFacade.getTeams(a);n.model=c.data[0]}if(n.type==="player"){a.playerIds=[n.id];let c=await this.footballFacade.getPlayers(a);n.model=c.data[0]}if(n.type==="competition"){a.competitionIds=[n.id];let c=await this.footballFacade.getCompetitions(a);n.model=c[0]}n.model===void 0&&(n.model=null),r.push(n)}else r.push(n);return r};updateInterests=(e,r)=>{if(e&&r&&e.length===r.length){let n=r.filter(c=>e.some(f=>c.id===f.id&&c.type===f.type&&c.source===f.source&&c.favourite===f.favourite)),a=r.filter(c=>!e.some(f=>c.id===f.id&&c.type===f.type&&c.source===f.source&&c.favourite===f.favourite));return[...n,...a]}else return r}};var fo=class{profileHttps=null;activityHttps=null;footballHttps=null;localStorage=null;idMapping=null;profileFacade=null;footballFacade=null;interestsService=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;constructor(e,r,n,a,c){this.localStorage=e,this.profileHttps=r,this.activityHttps=n,this.footballHttps=c,this.idMapping=a,this.footballFacade=new Kt(e,c,a),this.interestsService=new Er(a,this.footballFacade),this.profileFacade=new qt(e,r)}getOwnProfile=async()=>{for(;this.isFetching;)console.log("Another thread is fetching profile..."),await this.delay(100);if(this.modified&&this.ownProfile)return console.log("Timestamp is less than 10 minutes OR profile is modifying "),this.ownProfile;let e=Math.floor(Date.now()/1e3);if(!this.ownProfile||this.expireAt<e){this.isFetching=!0,this.expireAt=Math.floor(Date.now()/1e3)+600;try{let r=await this.profileFacade.getOwn();this.setOwnProfile(r)}catch{this.isFetching=!1}return this.modified=!1,this.isFetching=!1,this.ownProfile}return this.ownProfile};delay=e=>new Promise(r=>{setTimeout(r,e)});setOwnProfile=e=>{this.ownProfile=e};extractUpdatedProps=(e,r)=>{let n={};return Object.keys(e).forEach(a=>{a==="gender"&&e[a]!==r[a]?n[a]=r[a]:a==="birthDate"?(r[a]===null||e[a]===null&&r[a]||e[a]!==r[a])&&(n.birth_date=r[a]):a==="country"?r[a]===null?n.country_id=r[a]:(e[a]===null&&r[a]||e[a].id!==r[a].id)&&(n.country_id=r[a].id):a==="interests"&&r[a]&&r[a].length>0&&(n[a]=this.interestsService.updateInterests(e[a],r[a]))}),n};getInfo=async()=>{let e=await this.getOwnProfile(),r=JSON.parse(JSON.stringify(e));return delete r.interests,r};showInterests=async()=>{let e=await this.getOwnProfile(),r=JSON.parse(JSON.stringify(e));return await this.interestsService.inquiryCustomInterests(r.interests)};showFullInterests=async()=>{let e=await this.getOwnProfile(),r=JSON.parse(JSON.stringify(e)),n=await this.interestsService.inquiryCustomInterests(r.interests);return await this.interestsService.showFullInterests(n)};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);getStats=async()=>await this.activityHttps.getStats();addInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let r=null;e.source!=="custom"?r=await this.interestsService.remapInterestToNative(e):r=e;let n=this.ownProfile.interests.filter(a=>a.id!==r.id||a.type!==r.type||a.source!==r.source);return this.ownProfile.interests=[...n],this.ownProfile.interests.push(r),this};addInterest=e=>(this.promises.push(this.addInterestPromise(e)),this);removeInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let r=null;return e.source!=="custom"?r=await this.interestsService.remapInterestToNative(e):r=e,this.ownProfile.interests=this.ownProfile.interests.filter(n=>n.id!==r.id||n.type!==r.type||n.source!==r.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 oo,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(),r=JSON.parse(JSON.stringify(e));return this.profileFacade.showFullnessProfile(r)};update=async()=>{if(this.promises.length===0)return this.ownProfile;await Promise.all(this.promises);let e=await this.profileFacade.getOwn(),r=await this.getOwnProfile(),n=this.extractUpdatedProps(e,r),a=await this.profileHttps.updateProfile(n);return this.modified=!1,this.expireAt=0,this.localStorage.setOwnProfile(a),delete a.interests,a}};var ho=class{profileHttps=null;activityHttps=null;footballFacade=null;localStorage=null;idMapping=null;profileFacade=null;interestsService=null;profileId="";constructor(e,r,n,a,c){this.localStorage=e,this.profileHttps=r,this.activityHttps=n,this.footballFacade=c,this.idMapping=a,this.interestsService=new Er(a,c),this.profileFacade=new qt(e,r)}setId=e=>(this.profileId=e,this);getProfile=async()=>await this.profileFacade.getById(this.profileId);getInfo=async()=>{let e=await this.getProfile();return delete e.interests,e};showInterests=async()=>{let e=await this.getProfile(),r=[];return r=e.interests,await this.interestsService.inquiryCustomInterests(r)};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)};getStats=async()=>await this.activityHttps.getStats(this.profileId)};var km=Dt(Gt());var go=class{id="";alias="";countryCode="";assets=null;name=""};var ne=class{countriesFromResponse=e=>{if(e)return e.map(r=>this.countryFromResponse(r))};countryFromResponse=e=>{try{if(e){let r=new go;return r.id=e.id,r.alias=e.alias,r.assets=e.assets,r.countryCode=e.country_code,r.name=e.name,r}}catch(r){throw r}return null}};var yo=class{id="";country=null;gender="";assets=null;type="";name=""};var Ce=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let r=new yo;return r.id=e.id,r.country=this.countryRemapper.countryFromResponse(e.country),r.gender=e.gender,r.assets=e.assets,r.type=e.type,r.name=e.name,r}catch(r){throw console.warn("There was a problem remapping the competition response",r),r}}};var wo=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var Mo=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName=""};var ge=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let r=new Mo;return r.id=e.id,r.country=this.countryRemapper.countryFromResponse(e.country),r.gender=e.gender,r.assets=e.assets,r.code=e.code,r.national=e.national,r.fullName=e.full_name,r.shortName=e.short_name,r.name=e.name,r}catch(r){throw console.warn("There was a problem remapping teams response",r),r}}};var bo=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new ne,this.teamBasicRemapper=new ge}fromResponse(e){try{let r=new wo;return r.id=e.id,r.country=this.countryRemapper.countryFromResponse(e.country),r.gender=e.gender,r.assets=e.assets,r.type=e.type,r.name=e.name,r.participants=e.participants.map(n=>this.teamBasicRemapper.fromResponse(n)),r}catch(r){throw console.warn("There was a problem remapping the competition response",r),r}}};var vo=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";squad=[]};var _o=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var Io=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let r=new _o;return r.id=e.id,r.startDate=e.start_date,r.endDate=e.end_date,r.shirtNumber=e.shirt_number,r.loan=e.loan,r.position=e.position,r.country=this.countryRemapper.countryFromResponse(e.country),r.name=e.name,r.assets=e.assets,r.birthDate=e.birth_date,r}catch(r){throw console.warn("There was a problem remapping the player from squad",r),r}}};var Po=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new ne,this.competitionRemapper=new Ce,this.playerRemapper=new Io}fromResponse(e){try{let r=new vo;return r.id=e.id,r.country=this.countryRemapper.countryFromResponse(e.country),r.gender=e.gender,r.assets=e.assets,r.code=e.code,r.national=e.national,r.fullName=e.full_name,r.shortName=e.short_name,r.name=e.name,r.competitions=e.competitions?e.competitions.map(n=>this.competitionRemapper.fromResponse(n)):[],r.squad=e.squad?e.squad.map(n=>this.playerRemapper.fromResponse(n)):[],r}catch(r){throw console.warn("There was a problem remapping team response",r),r}}};var Ro=class{id="";kickoffAt="";finishedAt="";updatedAt="";homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;context={competition:null};status={type:null,subType:null}};var Fo=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var Cr=class{fromResponse(e){try{let r=new Fo;return r.ftScore=this.statEntityFromResponse(e.ft_score),r.htScore=this.statEntityFromResponse(e.ht_score),r.aetScore=this.statEntityFromResponse(e.aet_score),r.aggScore=this.statEntityFromResponse(e.agg_score),r.penScore=this.statEntityFromResponse(e.pen_score),r}catch(r){throw console.warn("There was a problem remapping the scores",r),r}}statEntityFromResponse=e=>({homeGoals:e.home_goals,awayGoals:e.away_goals})};var So=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new ge,this.competitionRemapper=new Ce,this.scoresRemapper=new Cr}fromResponse(e){try{let r=new Ro;return r.id=e.id,r.kickoffAt=e.kickoff_at,r.finishedAt=e.finished_at,r.updatedAt=e.updated_at,r.homeTeam=this.teamRemapper.fromResponse(e.home_team),r.awayTeam=this.teamRemapper.fromResponse(e.away_team),r.lineupsConfirmed=e.lineups_confirmed,r.startedAt=e.started_at,r.minute=e.minute,r.scores=this.scoresRemapper.fromResponse(e.scores),r.context={competition:e.context.competition?this.competitionRemapper.fromResponse(e.context.competition):null},r.status={type:e.status.type,subType:e.status.sub_type},r}catch(r){throw console.warn("There was a problem remapping the match response",r),r}}};var To=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 Eo=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 Co=class{fromResponse(e){try{let r=new Eo;return r.corners=this.statEntityFromResponse(e.corners),r.crosses=this.statEntityFromResponse(e.crosses),r.offside=this.statEntityFromResponse(e.offside),r.shotsOn=this.statEntityFromResponse(e.shots_on),r.throwIn=this.statEntityFromResponse(e.throw_in),r.redCards=this.statEntityFromResponse(e.red_cards),r.shotsOff=this.statEntityFromResponse(e.shots_off),r.goalKicks=this.statEntityFromResponse(e.goal_kicks),r.possession=this.statEntityFromResponse(e.possession),r.treatments=this.statEntityFromResponse(e.treatments),r.yellowCards=this.statEntityFromResponse(e.yellow_cards),r.shotsBlocked=this.statEntityFromResponse(e.shots_blocked),r.substitutions=this.statEntityFromResponse(e.substitutions),r.counterAttacks=this.statEntityFromResponse(e.counter_attacks),r.foulsCommitted=this.statEntityFromResponse(e.fouls_committed),r}catch(r){throw console.warn("There was a problem remapping the stats",r),r}}statEntityFromResponse=e=>({homeTeam:e?e.home_team:null,awayTeam:e?e.away_team:null})};var Ar=class{homeTeam={players:[]};awayTeam={players:[]}};var Ao=class{id="";name="";position="";shirtNumber;assets=null;type=""};var xr=class{fromResponse(e){try{let r=new Ao;return r.id=e.id,r.name=e.name,r.position=e.position,r.shirtNumber=e.shirt_number,r.assets=e.assets,r.type=e.type,r}catch(r){throw console.warn("There was a problem remapping the player from timeline",r),r}}};var xo=class{playerRemapper=null;constructor(){this.playerRemapper=new xr}fromResponse(e){try{let r=new Ar;return r.homeTeam.players=e.home_team&&e.home_team.players?e.home_team.players.map(n=>this.playerRemapper.fromResponse(n)):[],r.awayTeam.players=e.away_team&&e.away_team.players?e.away_team.players.map(n=>this.playerRemapper.fromResponse(n)):[],r}catch(r){throw console.warn("There was a problem remapping the lineups",r),r}}};var Oo=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var Lo=class{playerRemapper=null;constructor(){this.playerRemapper=new xr}fromResponse(e){try{let r=new Oo;return r.minute=e.minute,r.type=e.type,r.teamId=e.team_id,r.player=this.playerRemapper.fromResponse(e.player),r.relatedPlayer=e.related_player?this.playerRemapper.fromResponse(e.related_player):null,r.updatedAt=e.updated_at,r}catch(r){throw console.warn("There was a problem remapping timeline",r),r}}};var Bo=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new ge,this.competitionsMapper=new Ce,this.lineupsMapper=new xo,this.scoresMapper=new Cr,this.statsMapper=new Co,this.timelineMapper=new Lo}fromResponse(e){try{let r=new To;return r.id=e.id,r.kickoffAt=e.kickoff_at,r.finishedAt=e.finished_at,r.updatedAt=e.updated_at,r.homeTeam=e.home_team?this.teamMapper.fromResponse(e.home_team):null,r.awayTeam=e.away_team?this.teamMapper.fromResponse(e.away_team):null,r.lineupsConfirmed=e.lineups_confirmed,r.startedAt=e.started_at,r.minute=e.minute,r.scores=this.scoresMapper.fromResponse(e.scores),r.stats=this.statsMapper.fromResponse(e.stats),r.context={competition:this.competitionsMapper.fromResponse(e.context.competition)},r.timeline=e.timeline?e.timeline.map(n=>this.timelineMapper.fromResponse(n)):[],r.status={type:e.status.type,subType:e.status.sub_type},r.lineups=e.lineups?this.lineupsMapper.fromResponse(e.lineups):new Ar,r}catch(r){throw console.warn("There was a problem remapping the match response",r),r}}};var No=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var Uo=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let r=new No;return r.id=e.id,r.firstName=e.first_name?e.first_name:null,r.lastName=e.last_name?e.last_name:null,r.name=e.name?e.name:null,r.birthDate=e.birth_date,r.country=this.countryRemapper.countryFromResponse(e.country),r.assets=e.assets,r.position=e.position,r}catch(r){throw console.warn("There was a problem remapping top player response",r),r}}};var Do=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;teams=[]};var Or=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new ne,this.teamRemapper=new ge}fromResponse(e){try{let r=new Do;return r.id=e.id,r.firstName=e.first_name?e.first_name:null,r.lastName=e.last_name?e.last_name:null,r.name=e.name?e.name:null,r.birthDate=e.birth_date,r.country=this.countryRemapper.countryFromResponse(e.country),r.assets=e.assets,r.teams=e.teams?e.teams.map(n=>this.teamRemapper.fromResponse(n)):[],r.position=e.position,r}catch(r){throw console.warn("There was a problem remapping players response",r),r}}};var Go=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;competitions=[];teams=[]};var $o=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new ne,this.teamRemapper=new ge,this.competitionRemapper=new Ce}fromResponse(e){try{let r=new Go;return r.id=e.id,r.firstName=e.first_name?e.first_name:null,r.lastName=e.last_name?e.last_name:null,r.name=e.name?e.name:null,r.birthDate=e.birth_date,r.country=this.countryRemapper.countryFromResponse(e.country),r.assets=e.assets,r.teams=e.teams?e.teams.map(n=>this.teamRemapper.fromResponse(n)):[],r.position=e.position,r.competitions=e.competitions?e.competitions.map(n=>this.competitionRemapper.fromResponse(n)):[],r}catch(r){throw console.warn("There was a problem remapping player response",r),r}}};var Ho=class{teams=null;players=null;competitions=null};var Vo=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new ge,this.playerRemapper=new Or,this.competitionremapper=new Ce}fromResponse(e){try{let r=new Ho;return r.teams=e.teams?e.teams.map(n=>this.teamRemapper.fromResponse(n)):[],r.players=e.players?e.players.map(n=>this.playerRemapper.fromResponse(n)):[],r.competitions=e.competitions?e.competitions.map(n=>this.competitionremapper.fromResponse(n)):[],r}catch(r){throw console.warn("There was a problem remapping search response",r),r}}};var Lr=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var Br=class{pagination=new Lr};var Nr=class{meta=new Br;data=[]};var qo=class{remapMetaProp=e=>{let r=new Br;return r.pagination.currentPage=e.pagination.current_page,r.pagination.itemsPerPage=e.pagination.items_per_page,r.pagination.totalItems=e.pagination.total_items,r.pagination.numberOfPages=e.pagination.number_of_pages,r}};var mt=class{instance=null;apiSignInUrl="";clientId="";limitIds=200;countryRemapper=null;competitionBasicRemapper=null;competitionFullRemapper=null;teamBasicRemapper=null;teamFullRemapper=null;matchBasicRemapper=null;matchFullRemapper=null;playerBasicRemapper=null;playerFullRemapper=null;topPlayerRemapper=null;searchRemapper=null;footballMetaRemapper=null;constructor(e){this.clientId=e.clientId;let r=Ee(e.environment,"football");this.apiSignInUrl=`?key=${e.apiKey}&lang=${e.lang}`,this.instance=km.default.create({baseURL:r}),this.countryRemapper=new ne,this.competitionBasicRemapper=new Ce,this.competitionFullRemapper=new bo,this.teamBasicRemapper=new ge,this.teamFullRemapper=new Po,this.matchBasicRemapper=new So,this.matchFullRemapper=new Bo,this.playerBasicRemapper=new Or,this.playerFullRemapper=new $o,this.topPlayerRemapper=new Uo,this.searchRemapper=new Vo,this.footballMetaRemapper=new qo}getCountries=async e=>{try{let r=`/countries${this.apiSignInUrl}`,n=Date.now();e&&(r+=`&disable_cache=${n}`);let a=await this.instance.get(r);return this.countryRemapper.countriesFromResponse(a.data.data)}catch(r){throw console.warn("There was a problem with the football countries request",r),r}};getCompetitions=async(e,r)=>{try{let n={},a=Date.now();if(r=r||!1,e&&e.competitionIds&&e.competitionIds.length>this.limitIds-1){let c=[],f=Vn(e.competitionIds);for(let v of f){e.competitionIds=v;let S=`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`;r&&(S+=`&disable_cache=${a}`),n=await this.instance.get(S),c.push(n.data.data.map(M=>this.competitionBasicRemapper.fromResponse(M)))}return Array.prototype.concat.apply([],c)}else{let c=`/competitions${this.apiSignInUrl}`;return e&&(c+=`${e.constructFilterUrl()}`),r&&(c+=`&disable_cache=${a}`),n=await this.instance.get(c),n.data.data.map(f=>this.competitionBasicRemapper.fromResponse(f))}}catch(n){throw console.warn("There was a problem with getCompetitions request",n),n.response}};getCompetitionById=async(e,r)=>{try{let n=`/competitions/${e}${this.apiSignInUrl}`,a=Date.now();r&&(n+=`&disable_cache=${a}`);let c=await this.instance.get(n);return this.competitionFullRemapper.fromResponse(c.data.data)}catch(n){throw console.warn("There was a problem with getCompetitionById request",n),n.response}};getTopCompetitions=async e=>{try{this.apiSignInUrl+=`&client_id=${this.clientId}`;let r=`/competitions/top${this.apiSignInUrl}`,n=Date.now();return e&&(r+=`&disable_cache=${n}`),(await this.instance.get(r)).data.data.map(c=>this.competitionBasicRemapper.fromResponse(c))}catch(r){throw console.warn("There was a problem with getTopCompetitions request",r),r.response}};getTeams=async(e,r)=>{try{let n={},a=Date.now();if(e&&e.teamIds&&e.teamIds.length>this.limitIds){let c=[],f=Vn(e.teamIds);for(let v of f){e.teamIds=v;let S=`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`;r&&(S+=`disable_cache=${a}`),n=await this.instance.get(S),c.push(n.data.data.map(M=>this.teamBasicRemapper.fromResponse(M)))}return Array.prototype.concat.apply([],c)}else{let c=new Nr,f=`/teams${this.apiSignInUrl}`;return e&&(f+=`${e.constructFilterUrl()}`),r&&(f+=`&disable_cache=${a}`),n=await this.instance.get(f),c.meta=this.footballMetaRemapper.remapMetaProp(n.data.meta),c.data=n.data.data.map(g=>this.teamBasicRemapper.fromResponse(g)),c}}catch(n){throw console.warn("There was a problem with getTeams request",n),n.response}};getTeamById=async(e,r)=>{try{let n=`/teams/${e}${this.apiSignInUrl}`,a=Date.now();r&&(n+=`disable_cache=${a}`);let c=await this.instance.get(n);return this.teamFullRemapper.fromResponse(c.data.data)}catch(n){throw console.warn("There was a problem with getTeamById request",n),n.response}};getTopTeams=async e=>{try{this.apiSignInUrl+=`&client_id=${this.clientId}`;let r=`/teams/top${this.apiSignInUrl}`,n=Date.now();e&&(r+=`$disable_cache=${n}`);let a=await this.instance.get(r);return a.data.data?a.data.data.map(c=>this.teamBasicRemapper.fromResponse(c)):[]}catch(r){throw console.warn("There was a problem with getTopTeams request",r),r.response}};getNextMatchForTeam=async(e,r)=>{try{let n=`/teams/${e}/next-match${this.apiSignInUrl}`,a=Date.now();r&&(n+=`&disable_cache=${a}`);let c=await this.instance.get(n);return this.matchFullRemapper.fromResponse(c.data.data)}catch(n){throw console.warn("There was a problem with getNextMatchForTeam request",n),n.response}};getPrevMatchForTeam=async(e,r)=>{try{let n=`/teams/${e}/previous-match${this.apiSignInUrl}`,a=Date.now();r&&(n+=`disable_cache=${a}`);let c=await this.instance.get(n);return this.matchFullRemapper.fromResponse(c.data.data)}catch(n){throw console.warn("There was a problem with getPrevMatchForTeam request",n),n.response}};getPlayers=async(e,r)=>{try{let n={},a=Date.now();if(e&&e.playerIds&&e.playerIds.length>this.limitIds-1){let c=[],f=Vn(e.playerIds);for(let v of f){e.playerIds=v;let S=`/players${this.apiSignInUrl}${e.constructFilterUrl()}`;r&&(S+=`&disable_cache=${a}`),n=await this.instance.get(S),c.push(n.data.data.map(M=>this.teamBasicRemapper.fromResponse(M)))}return Array.prototype.concat.apply([],c)}else{let c=new Nr,f=`/players${this.apiSignInUrl}`;return e&&(f+=`${e.constructFilterUrl()}`),r&&(f+=`&disable_cache=${a}`),n=await this.instance.get(f),c.meta=this.footballMetaRemapper.remapMetaProp(n.data.meta),c.data=n.data.data.map(g=>this.playerBasicRemapper.fromResponse(g)),c}}catch(n){throw console.warn("There was a problem with getPlayers request",n),n.response}};getPlayerById=async(e,r)=>{try{let n=`/players/${e}${this.apiSignInUrl}`,a=Date.now();r&&(n+=`&disable_cache=${a}`);let c=await this.instance.get(n);return this.playerFullRemapper.fromResponse(c.data.data)}catch(n){throw console.warn("There was a problem with getPlayerById request",n),n.response}};getTopPlayers=async e=>{try{this.apiSignInUrl+=`&client_id=${this.clientId}`;let r=`/players/top${this.apiSignInUrl}`,n=Date.now();return e&&(r+=`&disable_cache=${n}`),(await this.instance.get(r)).data.data.map(c=>this.topPlayerRemapper.fromResponse(c))}catch(r){throw console.warn("There was a problem with getTopPlayers request",r),r.response}};getNextMatchForPlayer=async(e,r)=>{try{let n=`/players/${e}/next-match${this.apiSignInUrl}`,a=Date.now();r&&(n+=`&disable_cache=${a}`);let c=await this.instance.get(n);return this.matchFullRemapper.fromResponse(c.data.data)}catch(n){throw console.warn("There was a problem with getNextMatchForPlayer request",n),n.response}};getPrevMatchForPlayer=async(e,r)=>{try{let n=`/players/${e}/previous-match${this.apiSignInUrl}`,a=Date.now();r&&(n+=`&disable_cache=${a}`);let c=await this.instance.get(n);return this.matchFullRemapper.fromResponse(c.data.data)}catch(n){throw console.warn("There was a problem with getPrevMatchForPlayer request",n),n.response}};getMatchById=async(e,r)=>{try{let n=`/matches/${e}${this.apiSignInUrl}`,a=Date.now();r&&(n+=`&disable_cache=${a}`);let c=await this.instance.get(n);return this.matchFullRemapper.fromResponse(c.data.data)}catch(n){throw console.warn("There was a problem with getMatchById request",n),n.response}};getMatches=async(e,r)=>{try{let n=new Nr,a=`/matches${this.apiSignInUrl}`,c=Date.now();e&&(a+=`${e.constructFilterUrl()}`),r&&(a+=`&disable_cache=${c}`);let f=await this.instance.get(a);return n.meta=this.footballMetaRemapper.remapMetaProp(f.data.meta),n.data=f.data.data.map(g=>this.matchBasicRemapper.fromResponse(g)),n}catch(n){throw console.warn("There was a problem with getMatches request",n),n.response}};search=async(e,r)=>{try{let n=`/search${this.apiSignInUrl}${e.constructFilterUrl()}`,a=Date.now();r&&(n+=`&disable_cache=${a}`);let c=await this.instance.get(n);return this.searchRemapper.fromResponse(c.data.data)}catch(n){throw console.warn("There was a problem with search request",n),n.response}}};var Yl=Dt(Gt());var ko=class{profileId;tier;points};var Wo=class{id=null;label=null};var Ko=class{type=null;id=null;label=null};var Ur=class{content=new Ko;tags=[];campaign=new Wo};var Dr=class{id=null;profileId=null;action=null;context=new Ur;points=0};var Xo=class{totalItems=0};var Yo=class{meta=new Xo;data=[new Dr]};var zo=class{remapSingleResponse=e=>{let r=new Dr;return r.id=e.id,r.profileId=e.profile_id,r.action=e.action,r.context.content=e.context.content??r.context.content,r.context.tags=e.context.tags,r.context.campaign=e.context.campaign??r.context.campaign,r.points=e.points,r};remapActivitiesResponse=e=>{let r=new Yo;return r.meta.totalItems=e.meta.total_items,r.data=e.data.map(n=>this.remapSingleResponse(n)),r};remapStatsReponse=e=>{let r=new ko;return r.profileId=e.profile_id,r.tier=e.tier,r.points=e.points,r}};var Gr=class{instanceAuth=null;instance=null;activityRemapper=null;apiSignInUrl=null;clientApiSignInUrl=null;constructor(e){let r=Ee(e.environment,"loyalty");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instanceAuth=Yl.default.create({baseURL:r,headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.authProvider.getIdToken()}`}}),this.instance=Yl.default.create({baseURL:r,headers:{"Content-Type":"application/json"}}),this.activityRemapper=new zo}createActivity=async e=>{try{let r=`/activities${this.apiSignInUrl}`,n=await this.instanceAuth.post(r,JSON.stringify(e));return this.activityRemapper.remapSingleResponse(n.data)}catch(r){throw console.warn("There was a problem with creating activity for user",r),r}};deleteActivity=async e=>{try{let r=`/activities/${e}${this.apiSignInUrl}`;return await this.instanceAuth.delete(r),!0}catch(r){throw console.warn(`There was a problem deleting the following activity: ${e}`,r),r.response}};getOwnActivities=async(e,r)=>{try{let n=`/activities${this.apiSignInUrl}`,a=Date.now();e&&(n+=`${e.constructFilterUrl()}`),r&&(n+=`disable_cache=${a}`);let c=await this.instanceAuth.get(n);return this.activityRemapper.remapActivitiesResponse(c.data)}catch(n){throw console.warn("There was a problem with fetching own activities",n),n}};getActivitiesForUser=async(e,r,n)=>{try{let a=`/users/${e}/activities${this.apiSignInUrl}`,c=Date.now();r&&(a+=`${r.constructFilterUrl()}`),n&&(a+=`disable_cache=${c}`);let f=await this.instance.get(a);return this.activityRemapper.remapActivitiesResponse(f.data)}catch(a){throw console.warn(`There was a problem with fetching activities for user ${e}`,a),a}};getStats=async e=>{try{let r="",n=null;return e?(r+=`/users/${e}/statistics${this.apiSignInUrl}`,n=await this.instance.get(r)):(r+=`/statistics${this.apiSignInUrl}`,n=await this.instanceAuth.get(r)),this.activityRemapper.remapStatsReponse(n.data.data)}catch(r){throw console.warn("There was a problem fetching profile`s statistics:",r),r.response}}};var $r=class{profileHttps=null;activityHttps=null;footballHttps=null;footballFacade=null;idMapping=null;localStorage=null;profileFacade=null;ownProfileBuilder=null;profileBuilder=null;constructor(e){this.profileHttps=new Qn(e),this.activityHttps=new Gr(e),this.footballHttps=new mt(e),this.idMapping=new he(e),this.localStorage=new Ht(e),this.footballFacade=new Kt(this.localStorage,this.footballHttps,this.idMapping),this.profileFacade=new qt(this.localStorage,this.profileHttps),this.ownProfileBuilder=new fo(this.localStorage,this.profileHttps,this.activityHttps,this.idMapping,this.footballHttps),this.profileBuilder=new ho(this.localStorage,this.profileHttps,this.activityHttps,this.idMapping,this.footballFacade)}getOwn=()=>this.ownProfileBuilder;getById=e=>this.profileBuilder.setId(e);getCountries=async e=>await this.profileFacade.getCountries(e);getByIds=async(e,r)=>await this.profileFacade.getByIds(e,r)};var Jo=class{validate=e=>{let r=this.validateField(e.lang),n=this.generateMessage(r);return{validation:r,message:n}};validateField=e=>{let r=["bg","ro","en"],n=null;return e!=null&&e.length>0?r.includes(e)?n="valid":n="invalid":n="missing",n};generateMessage=e=>{let r=null,n="warning";return e==="missing"&&(r="If no lang is passed the default one will be set which is: EN"),e==="invalid"&&(r="This lang value is not supported, the default one will be set which is: EN"),e==="valid"&&(r=null,n=null),{text:r,type:n}}};var Qo=class{validate(e){let r=this.validateField(e.environment),n=this.generateMessage(r);return{validation:r,message:n}}validateField=e=>{let r=["dev","staging","prod"],n=null;return e!=null&&e.length>0?r.includes(e)?n="valid":n="invalid":n="missing",n};generateMessage=e=>{let r=null,n="warning";return e==="missing"&&(r="If no environment is passed the default one will be set which is: prod"),e==="invalid"&&(r="This environment value is not supported, the default one will be set which is: prod"),e==="valid"&&(r=null,n=null),{text:r,type:n}}};var Zo=class{validate(e){let r=this.validateField(e.apiKey),n=this.generateMessage(r);return{validation:r,message:n}}validateField=e=>{let r=null;return e!=null&&e.length>0?r="valid":r="missing",r};generateMessage=e=>{let r=null,n="error";return e==="missing"&&(r="The field apiKey with valid value must be provided to use this SDK"),e==="valid"&&(n=null),{text:r,type:n}}};var jo=class{validate(e){let r=this.validateField(e.idSchema),n=this.generateMessage(r);return{validation:r,message:n}}validateField=e=>{let r=["native","sportal365","enetpulse","sportradar"],n=null;return e!=null&&e.length>0?r.includes(e)?n="valid":n="invalid":n="missing",n};generateMessage=e=>{let r=null,n="warning";return e==="missing"&&(r="If no idSchema is passed the default one will be set which is: native"),e==="invalid"&&(r="This idSchema value is not supported, the default one will be set which is: native"),e==="valid"&&(r=null,n=null),{text:r,type:n}}};var Oi=class{getIdToken=null;logout=null};var qr=class{text=null;type=null};var ea=class{validation=null;message=new qr;getIdToken={validation:null,message:new qr};logout={validation:null,message:new qr}};var ta=class{validate(e){let r=this.validateAuthProvider(e.authProvider);return r.validation!=="missing"&&(r=this.validateAuthProviderConfigFields(e.authProvider,r),r=this.generateAuthProviderConfigMessages(r),r=this.checkAuthProviderConfigMessagesForErrors(r)),r}validateAuthProvider=e=>{let r=Object.keys(new Oi),n=new ea;if(e){let c=Object.keys(e).filter(f=>!r.includes(f));c.length>0?(n.validation="invalid",n.message.type="warning",n.message.text=`${"You have passed a property which is not supported for the authentication provider:"} ${c.join(",")}`):n.validation="valid"}else n.validation="missing",n.message.type="error",n.message.text="The field authProvider must be provided to use this SDK";return n};validateAuthProviderConfigFields=(e,r)=>(Object.keys(new Oi).forEach(a=>{e[a]?r[a].validation="valid":r[a].validation="missing"}),r);generateAuthProviderConfigMessages=e=>(Object.keys(e).filter(r=>r!=="validation"&&r!=="message").forEach(r=>{let n=e[r];n.validation==="missing"&&(n.message.text=`${"The following property is missing from the authProvider object:"} ${r}`,n.message.type="error")}),e);checkAuthProviderConfigMessagesForErrors=e=>(Object.keys(e).filter(r=>r!=="validation"&&r!=="message").forEach(r=>{e[r].validation==="missing"&&e.validation==="valid"&&(e.validation="invalid",e.message.type="error",e.message.text="The field authProvider has missing properties")}),e)};var Li=class{validation;message};var ra=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;authProvider={getIdToken:new Li,logout:new Li};isValid=!1};var ia=class{validate(e){let r=this.validateField(e.clientId),n=this.generateMessage(r);return{validation:r,message:n}}validateField=e=>{let r=null;return e!=null&&e.length>0?r="valid":r="missing",r};generateMessage=e=>{let r=null,n="warning";return e==="missing"&&(r="The field clientId must be provided to use this SDK"),e==="valid"&&(r=null,n=null),{text:r,type:n}}};var na=class{validate=e=>{let r=this.checkFieldsForValues(e);return r.isValid=this.containsErrorMessage(r),r};checkFieldsForValues=e=>{let r=new ra,n={apiKey:new Zo,environment:new Qo,idSchema:new jo,clientId:new ia,lang:new Jo,authProvider:new ta};for(let[a,c]of Object.entries(r))a!=="isValid"&&(c=n[a].validate(e));return Object.keys(n).forEach(a=>{r[a]=n[a].validate(e)}),r};containsErrorMessage=e=>{let r=!0;for(let[n,a]of Object.entries(e))if(n!=="authProvider"){if(n!=="isValid"&&a.message.type==="error")return r=!1,r;if(n!=="isValid"&&a.message.type==="warning")return r=!0,r}return r}};var oa=class{https=null;idMapping=null;localStorage=null;footballFacade=null;constructor(e){this.https=new mt(e),this.idMapping=new he(e),this.localStorage=new Ht(e),this.footballFacade=new Kt(this.localStorage,this.https,this.idMapping)}getCountries=async e=>await this.footballFacade.getCountries(e);getCompetitions=async(e,r)=>await this.footballFacade.getCompetitions(e,r);getCompetitionById=async(e,r)=>await this.footballFacade.getCompetitionById(e,r);getTopCompetitions=async e=>await this.footballFacade.getTopCompetitions(e);getTeams=async(e,r)=>await this.footballFacade.getTeams(e,r);getTeamById=async(e,r)=>await this.footballFacade.getTeamById(e,r);getTopTeams=async e=>await this.footballFacade.getTopTeams(e);getNextMatchForTeam=async(e,r)=>await this.footballFacade.getNextMatchForTeam(e,r);getPrevMatchForTeam=async(e,r)=>await this.footballFacade.getPrevMatchForTeam(e,r);getPlayers=async(e,r)=>await this.footballFacade.getPlayers(e,r);getPlayerById=async(e,r)=>await this.footballFacade.getPlayerById(e,r);getTopPlayers=async e=>await this.footballFacade.getTopPlayers(e);getNextMatchForPlayer=async(e,r)=>await this.footballFacade.getNextMatchForPlayer(e,r);getPrevMatchForPlayer=async(e,r)=>await this.footballFacade.getPrevMatchForPlayer(e,r);getMatches=async(e,r)=>await this.footballFacade.getMatches(e,r);getMatchById=async(e,r)=>await this.footballFacade.getMatchById(e,r);search=async(e,r)=>await this.footballFacade.search(e,r)};var jl=Dt(Gt());var aa=class{value=null;playerId=null;playerModel=null};var kr=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new aa;result=null};var sa=class{value=!1;playerId=null};var nt=class{matchId=null;market=null;prediction=null;constructor(e,r,n,a){this.matchId=e,this.market=r,this.prediction=new sa,this.prediction.value=n,this.prediction.playerId=a}};var Wr=class{settledAt=null;resettledAt=null;status=null;outcome=null};var Ge=(q=>(q.FT_1X2="FT_1X2",q.HT_1X2="HT_1X2",q.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",q.DOUBLE_CHANCE="DOUBLE_CHANCE",q.HT_FT="HT_FT",q.PLAYER_SCORE="PLAYER_SCORE",q.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",q.PLAYER_RED_CARD="PLAYER_RED_CARD",q.RED_CARD_MATCH="RED_CARD_MATCH",q.PENALTY_MATCH="PENALTY_MATCH",q.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",q.CORNERS_MATCH="CORNERS_MATCH",q.CORRECT_SCORE="CORRECT_SCORE",q.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",q.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",q.OVER_GOALS_0_5="OVER_GOALS_0.5",q.OVER_GOALS_1_5="OVER_GOALS_1.5",q.OVER_GOALS_2_5="OVER_GOALS_2.5",q.OVER_GOALS_3_5="OVER_GOALS_3.5",q.OVER_GOALS_4_5="OVER_GOALS_4.5",q.OVER_GOALS_5_5="OVER_GOALS_5.5",q.OVER_GOALS_6_5="OVER_GOALS_6.5",q.OVER_CORNERS_6_5="OVER_CORNERS_6.5",q.OVER_CORNERS_7_5="OVER_CORNERS_7.5",q.OVER_CORNERS_8_5="OVER_CORNERS_8.5",q.OVER_CORNERS_9_5="OVER_CORNERS_9.5",q.OVER_CORNERS_10_5="OVER_CORNERS_10.5",q.OVER_CORNERS_11_5="OVER_CORNERS_11.5",q.OVER_CORNERS_12_5="OVER_CORNERS_12.5",q.OVER_CORNERS_13_5="OVER_CORNERS_13.5",q))(Ge||{}),Wm=["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"],Km=["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"],zl=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"];var la=class{value=null};var Xt=class{matchId=null;market="CORRECT_SCORE";prediction=null;constructor(e,r){this.matchId=e,this.prediction=new la,this.prediction.value=r}};var Qe=class{value=!1};var Kr=class{matchId=null;market=null;prediction=null;constructor(e,r,n){this.matchId=e,this.market=r,this.prediction=new Qe,this.prediction.value=n}};var Xr=class{matchId=null;market=null;prediction=null;constructor(e,r,n){this.matchId=e,this.market=r,this.prediction=new Qe,this.prediction.value=n}};var pa=class{matchFacade=null;playerFacade=null;predictorService=null;constructor(e,r,n){this.matchFacade=e,this.playerFacade=r,this.predictorService=n}remapFixturesRequest=e=>{let r={};if(r.match_id=e.matchId,r.match_type="FOOTBALL",e instanceof nt)r.market=e.market,r.prediction=e.prediction.value,r.player_id=e.prediction.playerId;else if(e instanceof Kr||e instanceof Xr){let n=e.market.split("_");r.market=n[0]+"_"+n[1],r.prediction=e.prediction.value,r.target=Number(n[2])}else if(e instanceof Xt){r.market=e.market;let n=e.prediction.value.split(":");r.goals_home=Number(n[0]),r.goals_away=Number(n[1])}else r.market=e.market,r.prediction=e.prediction.value;return r};remapFixturesResponse=async e=>{e.length>1&&e.sort((g,v)=>g.match_id.localeCompare(v.match_id));let r=[],n=[];for(let g of e)r.push(g.match_id),g.player_id&&!n.includes(g.player_id)&&n.push(g.player_id);let a=await this.matchFacade.getMatchesMapWithNativeIds(r),c=[];n.sort((g,v)=>g.localeCompare(v)),n&&n.length>0&&(c=await this.playerFacade.getPlayersMapWithNativeIds(n));let f=[];for(let g of e){let v=new kr;g.target?v.market=this.predictorService.convertMarketForResponseModel(g.market,g.target):v.market=g.market,v.matchId=a[g.match_id].id,v.matchType=g.match_type,v.matchModel=a?a[g.match_id]:null,g.goals_home!==void 0&&g.goals_away!==void 0?v.prediction.value=g.goals_home.toString()+":"+g.goals_away.toString():v.prediction.value=g.prediction,v.prediction.playerId=g.player_id?g.player_id:null,v.prediction.playerId&&(v.prediction.playerModel=c[g.player_id],v.prediction.playerId=c[g.player_id].id),v.result=this.remapResult(g.result),f.push(v)}return f};remapResult=e=>{let r=new Wr;return r.settledAt=e.settled_at,r.resettledAt=e.resettled_at,r.status=e.status,r.outcome=e.outcome,r}};var Yr=class{goldenGoal=null};var Bi=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new Yr;points=null;createdAt=null;updatedAt=null};var N=class{no=0;yes=0};var zr=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new N;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new N;penaltyMatch=new N;playerScoreFirstGoal={};cornersMatch={};correctScore={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new N;overOnePointFiveGoals=new N;overTwoPointFiveGoals=new N;overThreePointFiveGoals=new N;overFourPointFiveGoals=new N;overFivePointFiveGoals=new N;overSixPointFiveGoals=new N;overSixPointFiveCorners=new N;overSevenPointFiveCorners=new N;overEightPointFiveCorners=new N;overNinePointFiveCorners=new N;overTenPointFiveCorners=new N;overElevenPointFiveCorners=new N;overTwelvePointFiveCorners=new N;overThirteenPointFiveCorners=new N};var Jl=(n=>(n.ONE="1",n.X="x",n.TWO="2",n))(Jl||{}),Ql=(n=>(n.ONE_X="1x",n.X_TWO="x2",n.ONE_TWO="12",n))(Ql||{}),Zl=(S=>(S.ONE_ONE="1/1",S.ONE_X="1/x",S.ONE_TWO="1/2",S.X_ONE="x/1",S.X_X="x/x",S.X_TWO="x/2",S.TWO_ONE="2/1",S.TWO_X="2/x",S.TWO_TWO="2/2",S))(Zl||{});var ca=class{value=null};var ua=class{matchId=null;market="HT_FT";prediction=null;constructor(e,r){this.matchId=e,this.prediction=new ca,this.prediction.value=r}};var ma=class{value=null};var da=class{matchId=null;market="DOUBLE_CHANCE";prediction=null;constructor(e,r){this.matchId=e,this.prediction=new ma,this.prediction.value=r}};var Jr=class{value=null};var fa=class{matchId=null;market="FT_1X2";prediction=null;constructor(e,r){this.matchId=e,this.prediction=new Jr,this.prediction.value=r}};var ha=class{matchId=null;market="HT_1X2";prediction=null;constructor(e,r){this.matchId=e,this.prediction=new Jr,this.prediction.value=r}};var ga=class{value};var ya=class{matchId=null;market="CORNERS_MATCH";prediction=null;constructor(e,r){this.matchId=e,this.prediction=new ga,this.prediction.value=r}};var wa=class{matchId=null;market="BOTH_TEAMS_SCORE";prediction=null;constructor(e,r){this.matchId=e,this.prediction=new Qe,this.prediction.value=r}};var Ma=class{matchId=null;market="RED_CARD_MATCH";prediction=null;constructor(e,r){this.matchId=e,this.prediction=new Qe,this.prediction.value=r}};var ba=class{matchId=null;market="PENALTY_MATCH";prediction=null;constructor(e,r){this.matchId=e,this.prediction=new Qe,this.prediction.value=r}};var ar=class{id=null;title=null;description=null;type=null;status=null;predictionsCutoff=null;fixtures=[];createdAt=null;updatedAt=null};var sr=class{userId=null;points=null;results=[];tiebreaker=null};var va=(c=>(c.ACTIVE="ACTIVE",c.WON="WON",c.LOST="LOST",c.PARTIALLY_WON="PARTIALLY_WON",c.CANCELED="CANCELED",c))(va||{}),Ni=["WON","LOST","PARTIALLY_WON","CANCELED"];var se=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}constructFiltersUrl=()=>{let e="",r=!1;return this.status&&(r=Object.values(va).some(n=>this.status.includes(n))),this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),this.status&&r&&(e+="&",e+=`status=${this.status.join(",")}`),this.type&&(e+="&",e+=`game_types=${this.type}`),e}};var Ui=(f=>(f.OPEN="OPEN",f.LIVE="LIVE",f.PENDING="PENDING",f.CANCELED="CANCELED",f.CLOSED="CLOSED",f.SETTLED="SETTLED",f))(Ui||{});var $e=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(Ui).includes(this.status)&&(e+="&",e+=`status=${this.status}`),this.type&&(e+="&",e+=`type=${this.type}`),this.gameIds&&this.gameIds.length>0&&(e+="&",e+=`game_ids=${this.gameIds.join(",")}`),e}};var lr=class{id=null;title=null;description=null;type=null;status=null;predictionsCutoff=null;fixtures=[];createdAt=null;updatedAt=null};var Ft=class{id=null;title=null;description=null;type=null;status=null;predictionsCutoff=null;fixtures=[];createdAt=null;updatedAt=null};var dt=class{footballHttps=null;idMapping=null;matchFacade=null;playerFacade=null;constructor(e,r){this.footballHttps=new mt(e),this.idMapping=r,this.matchFacade=new Wt(this.footballHttps,r),this.playerFacade=new kt(this.footballHttps,r)}remapMatchIdToNative=async e=>{let r=await this.idMapping.getEntityIdsBySchemaId(e,"match","native"),n=[];return r.match.forEach(a=>n.push(a)),n};remapPlayerIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"player","native")).player[0];remapPlayerIdMapToNative=async e=>{let r={},n=$t(e),c=(await this.idMapping.getEntityIdsBySchemaId(n,"player","native")).player;return n.forEach((f,g)=>r[f]=c[g]),r};remapPlayerIdToIdSchema=async e=>{let r=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"];for(let[n,a]of Object.entries(e))if(r.includes(n))for(let c of Object.keys(a)){let f={player:[c]},v=(await this.idMapping.idMappingFacade.getEntitiesByIds(f,"native",this.idMapping.idSchema)).player[0];a[v]=a[c],delete a[c]}return e};convertMarket=e=>{let r=Object.keys(new zr),n=Object.values(Ge);for(let a=0;a<n.length;a++)e===n[a]&&(e=r[a]);return e};convertMarketForResponseModel=(e,r)=>{let n=r.toString();return e+"_"+n};validateFixture=(e,r,n,a)=>{let c=Object.values(Jl),f=Object.values(Zl),g=Object.values(Ql);if(r==="FT_1X2"){if(c.includes(n))return new fa(e,n)}else if(r==="HT_1X2"){if(c.includes(n))return new ha(e,n)}else if(r==="HT_FT"){if(f.includes(n))return new ua(e,n)}else if(r==="DOUBLE_CHANCE"){if(g.includes(n))return new da(e,n)}else if(r==="CORRECT_SCORE"){if(typeof n=="string"&&/\d+:\d+/.test(n))return new Xt(e,n)}else if(r==="CORNERS_MATCH"){if(typeof n=="number")return new ya(e,n)}else if(r==="BOTH_TEAMS_SCORE"){if(typeof n=="boolean")return new wa(e,n)}else if(r==="RED_CARD_MATCH"){if(typeof n=="boolean")return new Ma(e,n)}else if(r==="PENALTY_MATCH"){if(typeof n=="boolean")return new ba(e,n)}else if(zl.includes(r)){if(a&&typeof n=="boolean")return new nt(e,r,n,a)}else if(Wm.includes(r)){if(typeof n=="boolean")return new Xr(e,r,n)}else if(Km.includes(r)&&typeof n=="boolean")return new Kr(e,r,n)};getMarketSummary=(e,r,n)=>{let a=this.convertMarket(r),c={};if(c.matchId=e.matchId,c.matchType=e.matchType,Object.keys(e.predictions).includes(a))c[a]=e.predictions[a];else throw new Error("You have passed invalid market");return zl.includes(r)&&n?(c[a][n]||(c[a][n]=new N),c[a][n]):c};remapCompetitionsFromConfig=async e=>{let r={competition:e.fullCoverageCompetitions},n=await this.idMapping.idMappingFacade.getEntitiesByIds(r,"native",this.idMapping.idSchema);return e.fullCoverageCompetitions=n.competition,e};remapMatchIdsFixtures=async e=>{if(Array.isArray(e.data))if(e.data.length>0){let r=[],n=[];return e.data.forEach(a=>{a instanceof lr||a instanceof ar||a instanceof Ft?(a.fixtures.forEach(c=>r.push(c.matchId)),a instanceof Ft&&a.fixtures.forEach(c=>{c.prediction.playerId&&n.push(c.prediction.playerId)})):a instanceof sr&&a.results.forEach(c=>r.push(c.matchId))}),await this.refactorResponseArrModel(e,r,n)}else return e;else return await this.refactorResponseObjModel(e)};refactorResponseArrModel=async(e,r,n)=>{let a=[],c=await this.matchFacade.getMatchesMapWithNativeIds(r),f={};return n.length>0&&(f=await this.playerFacade.getPlayersMapWithNativeIds(n)),e.data.forEach(g=>{g instanceof lr||g instanceof ar||g instanceof Ft?(g.fixtures.forEach(v=>{v.matchModel=c[v.matchId],v.matchId=v.matchModel.id,g instanceof Ft&&v.prediction.playerId&&(v.prediction.playerModel=f[v.prediction.playerId],v.prediction.playerId=f[v.prediction.playerId].id)}),a.push(g)):g instanceof sr&&(g.results.forEach(v=>{v.matchModel=c[v.matchId],v.matchId=v.matchModel.id}),a.push(g))}),e.data=a,e};refactorResponseObjModel=async e=>{let r=[];e.fixtures.forEach(a=>r.push(a.matchId));let n=await this.matchFacade.getMatchesMapWithNativeIds(r);return e.fixtures.forEach(a=>{a.matchModel=n[a.matchId],a.matchId=n[a.matchId].id}),e};getCurrentGameId=e=>{let r=new Date;if(e.data.length>1){let n=[];return e.data.forEach(c=>n.push(c.predictionsCutoff)),e.data.sort((c,f)=>{let[g,v]=[c.predictionsCutoff,f.predictionsCutoff].map(S=>Math.abs(new Date(S)-r));return g-v})[0].id}else return e.data[0].id};initGameTypePredictions=e=>{let r={type:e};return r=new se(r),r};initGameFilters=(e,r,n)=>{if(r&&n)return r.type=e,r.gameIds=n,r=new $e(r),r;if(r&&!n)return r.type=e,r=new $e(r),r;if(!r&&n){let a={type:e,gameIds:n};return a=new $e(a),a}else{let a={type:e};return a=new $e(a),a}};addPredictionProp=async(e,r)=>(r.data.forEach((n,a)=>{n.id===e[a].game_instance_id&&n.fixtures.forEach((c,f)=>{e[a].fixtures[f].goals_home!==void 0&&e[a].fixtures[f].goals_away!==void 0?c.prediction.value=e[a].fixtures[f].goals_home+":"+e[a].fixtures[f].goals_away:c.prediction.value=e[a].fixtures[f].prediction,e[a].fixtures[f].player_id?c.prediction.playerId=e[a].fixtures[f].player_id:e[a].fixtures[f].target&&(c.prediction.target=e[a].fixtures[f].target),c.prediction.result=this.remapResult(e[a].fixtures[f].result)})}),await this.remapMatchIdsFixtures(r));remapResult=e=>{let r=new Wr;return r.settledAt=e.settled_at,r.resettledAt=e.resettled_at,r.status=e.status,r.outcome=e.outcome,r}};var Qr=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(e){this.gameInstanceId=e.gameInstanceId,e.fixtures.forEach(r=>this.fixtures.push(new Xt(r.matchId,r.prediction.value))),this.tiebreaker=e.tiebreaker?e.tiebreaker:null}};var Zr=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(e,r){this.footballHttps=new mt(e),this.matchFacade=new Wt(this.footballHttps,r),this.playerFacade=new kt(this.footballHttps,r),this.predictorService=new dt(e,r),this.fixturesRemapper=new pa(this.matchFacade,this.playerFacade,this.predictorService)}remapRequestBody=e=>{let r={};return r.game_instance_id=e.gameInstanceId,r.fixtures=e.fixtures.map(n=>this.fixturesRemapper.remapFixturesRequest(n)),e instanceof Qr&&e.tiebreaker&&(r.tiebreaker={},r.tiebreaker.golden_goal=e.tiebreaker.goldenGoal?e.tiebreaker.goldenGoal:null),r};remapResponseArrayBody=async e=>{let r=[],n=[],a={},c=[];e.forEach(g=>{g.fixtures.forEach(v=>{r.push(v.match_id),v.player_id&&n.push(v.player_id)})});let f=await this.matchFacade.getMatchesMapWithNativeIds(r);return n.length>0&&(a=await this.playerFacade.getPlayersMapWithNativeIds(n)),e.forEach(g=>{let v=new Bi,S=[];v.id=g.id,v.gameInstanceId=g.game_instance_id,v.gameType=g.game_type,v.wager=g.wager,v.totalFixtures=g.total_fixtures,v.settledFixtures=g.settled_fixtures,v.userId=g.user_id,g.fixtures.forEach(M=>{let F=new kr;M.target?F.market=this.predictorService.convertMarketForResponseModel(M.market,M.target):F.market=M.market,F.matchId=f[M.match_id].id,F.matchType=M.match_type,F.matchModel=f[M.match_id],M.goals_home!==void 0&&M.goals_away!==void 0?F.prediction.value=M.goals_home.toString()+":"+M.goals_away.toString():F.prediction.value=M.prediction,F.prediction.playerId=M.player_id?M.player_id:null,F.prediction.playerId&&(F.prediction.playerModel=a[F.prediction.playerId],F.prediction.playerId=a[F.prediction.playerId].id),F.result=this.fixturesRemapper.remapResult(M.result),S.push(F)}),v.fixtures=S,v.status=g.status,g.tiebreaker?v.tiebreaker.goldenGoal=g.tiebreaker.golden_goal:v.tiebreaker=null,v.points=g.points,v.createdAt=g.created_at,v.updatedAt=g.updated_at,c.push(v)}),c};remapResponseObjBody=async e=>{let r=new Bi;return r.id=e.id,r.gameInstanceId=e.game_instance_id,r.gameType=e.game_type,r.wager=e.wager,r.totalFixtures=e.total_fixtures,r.settledFixtures=e.settled_fixtures,r.userId=e.user_id,r.fixtures=await this.fixturesRemapper.remapFixturesResponse(e.fixtures),r.status=e.status,e.tiebreaker?r.tiebreaker.goldenGoal=e.tiebreaker.golden_goal:r.tiebreaker=null,r.points=e.points,r.createdAt=e.created_at,r.updatedAt=e.updated_at,r};remapPredictionModel=e=>{let r=new zr;return r.fullTimeOneXTwo=e.FT_1X2,r.halfTimeOneXTwo=e.HT_1X2,r.bothTeamsScore=e.BOTH_TEAMS_SCORE?e.BOTH_TEAMS_SCORE:new N,r.overZeroPointFiveGoals=e.OVER_GOALS["over:0.5"]?e.OVER_GOALS["over:0.5"]:new N,r.overOnePointFiveGoals=e.OVER_GOALS["over:1.5"]?e.OVER_GOALS["over:1.5"]:new N,r.overTwoPointFiveGoals=e.OVER_GOALS["over:2.5"]?e.OVER_GOALS["over:2.5"]:new N,r.overThreePointFiveGoals=e.OVER_GOALS["over:3.5"]?e.OVER_GOALS["over:3.5"]:new N,r.overFourPointFiveGoals=e.OVER_GOALS["over:4.5"]?e.OVER_GOALS["over:4.5"]:new N,r.overFivePointFiveGoals=e.OVER_GOALS["over:5.5"]?e.OVER_GOALS["over:5.5"]:new N,r.overSixPointFiveGoals=e.OVER_GOALS["over:6.5"]?e.OVER_GOALS["over:6.5"]:new N,r.overSixPointFiveCorners=e.OVER_CORNERS["over:6.5"]?e.OVER_CORNERS["over:6.5"]:new N,r.overSevenPointFiveCorners=e.OVER_CORNERS["over:7.5"]?e.OVER_CORNERS["over:7.5"]:new N,r.overEightPointFiveCorners=e.OVER_CORNERS["over:8.5"]?e.OVER_CORNERS["over:8.5"]:new N,r.overNinePointFiveCorners=e.OVER_CORNERS["over:9.5"]?e.OVER_CORNERS["over:9.5"]:new N,r.overTenPointFiveCorners=e.OVER_CORNERS["over:10.5"]?e.OVER_CORNERS["over:10.5"]:new N,r.overElevenPointFiveCorners=e.OVER_CORNERS["over:11.5"]?e.OVER_CORNERS["over:11.5"]:new N,r.overTwelvePointFiveCorners=e.OVER_CORNERS["over:12.5"]?e.OVER_CORNERS["over:12.5"]:new N,r.overThirteenPointFiveCorners=e.OVER_CORNERS["over:13.5"]?e.OVER_CORNERS["over:13.5"]:new N,r.doubleChance=e.DOUBLE_CHANCE,r.halfTimeFullTime=e.HT_FT,r.playerScore=e.PLAYER_SCORE,r.playerYellowCard=e.PLAYER_YELLOW_CARD,r.playerRedCard=e.PLAYER_RED_CARD,r.redCardMatch=e.RED_CARD_MATCH?e.RED_CARD_MATCH:new N,r.penaltyMatch=e.PENALTY_MATCH?e.PENALTY_MATCH:new N,r.playerScoreFirstGoal=e.PLAYER_SCORE_FIRST_GOAL,r.cornersMatch=e.CORNERS_MATCH,r.correctScore=e.CORRECT_SCORE,r.playerScoreHattrick=e.PLAYER_SCORE_HATTRICK,r.playerScoreTwice=e.PLAYER_SCORE_TWICE,r}};var _a=class{matchId=null;matchType=null;predictions=null};var Ia=class{remapPredictions=null;constructor(e,r){this.remapPredictions=new Zr(e,r)}remapResponse=e=>{let r=new _a;return r.matchId=e.match_id,r.matchType=e.match_type,r.predictions=this.remapPredictions.remapPredictionModel(e.predictions),r}};var Pa=class{matchId=null;matchType=null;market=null;matchModel=null};var Ra=class{value=null;target=null;playerId=null;playerModel=null;result=null};var Fa=class{matchId=null;matchType=null;market=null;matchModel=null;prediction=new Ra};var Sa=class{value=null;result=null};var Ta=class{matchId=null;matchType=null;market="CORRECT_SCORE";matchModel=null;prediction=new Sa};var Ea=class{matchId=null;matchModel=null;outcome=null};var Ca=class{remapPaginatedGames=e=>{let r=new ie;return r.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,r.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,r.data=e.data.map(n=>this.remapGamesListResponse(n)),r};remapGamesListResponse=e=>{let r=new lr;return r.id=e.id,r.title=e.title,r.description=e.description,r.type=e.type,r.status=e.status,r.predictionsCutoff=e.predictions_cutoff,r.fixtures=e.fixtures.map(n=>this.remapFixturesResponse(n)),r.createdAt=e.created_at,r.updatedAt=e.updated_at,r};remapFixturesResponse=e=>{let r=new Pa;return r.matchId=e.match_id,r.matchType=e.match_type,r.market=e.market,r};remapPaginatedUserTopXEditions=e=>{let r=new ie;return r.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,r.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,r.data=e.data.map(n=>this.remapUserTopXEditionsResponse(n)),r};remapUserTopXEditionsResponse=e=>{let r=new ar;return r.id=e.id,r.title=e.title,r.description=e.description,r.type=e.type,r.status=e.status,r.predictionsCutoff=e.predictions_cutoff,r.fixtures=e.fixtures.map(n=>this.remapTopXFixturesResponse(n)),r.createdAt=e.created_at,r.updatedAt=e.updated_at,r};remapTopXFixturesResponse=e=>{let r=new Ta;return r.matchId=e.match_id,r.matchType=e.match_type,r};remapPaginatedUserMathQuizEditions=e=>{let r=new ie;return r.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,r.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,r.data=e.data.map(n=>this.remapUserMatchQuizEditionsResponse(n)),r};remapUserMatchQuizEditionsResponse=e=>{let r=new Ft;return r.id=e.id,r.title=e.title,r.description=e.description,r.type=e.type,r.status=e.status,r.predictionsCutoff=e.predictions_cutoff,r.fixtures=e.fixtures.map(n=>this.remapMatchQuizFixturesResponse(n)),r.createdAt=e.created_at,r.updatedAt=e.updated_at,r};remapMatchQuizFixturesResponse=e=>{let r=new Fa;return r.matchId=e.match_id,r.matchType=e.match_type,r.market=e.market,r};remapPaginatedGameResults=e=>{let r=new ie;return r.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,r.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,r.data=e.data.map(n=>this.remapGameResults(n)),r};remapGameResults=e=>{let r=new sr;return r.userId=e.user_id,r.points=e.points?e.points:0,r.results=e.results.map(n=>this.remapResults(n)),r.tiebreaker=e.tiebreaker?this.remapTiebreaker(e.tiebreaker):null,r};remapResults=e=>{let r=new Ea;return r.matchId=e.match_id,r.outcome=e.outcome,r};remapTiebreaker=e=>{let r=new Yr;return r.goldenGoal=e.golden_goal,r}};var Aa=class{remapMetaData=e=>{let r=new Tr;return r.pagination.nextPageStartsAfter=e.pagination.next_page_starts_after,r.pagination.itemsPerPage=e.pagination.items_per_page,r}};var Yt=class{instanceAuth=null;instance=null;apiSignInUrl=null;clientApiSignInUrl=null;predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;metaRemapper=null;constructor(e,r){let n=Ee(e.environment,"predictor");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.predictionRemapper=new Zr(e,r),this.matchSummaryRemapper=new Ia(e,r),this.gamesRemapper=new Ca,this.metaRemapper=new Aa,this.instanceAuth=jl.default.create({baseURL:n,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instance=jl.default.create({baseURL:n,headers:{"Content-Type":"application/json"}})}makeFootballPrediction=async e=>{try{let r=this.predictionRemapper.remapRequestBody(e),n=await this.instanceAuth.post(`/predictions${this.apiSignInUrl}`,JSON.stringify(r));return await this.predictionRemapper.remapResponseObjBody(n.data)}catch(r){throw console.warn("There was a problem making POST request: ",r),r.response}};getMatchSummary=async e=>{try{let r=await this.instance.get(`/predictions/summary/${e}${this.apiSignInUrl}`);return this.matchSummaryRemapper.remapResponse(r.data)}catch(r){throw console.warn(`There was a problem fetching predictions for match: ${e} `,r),r.response}};deleteFootballPrediction=async e=>{try{return await this.instanceAuth.delete(`/predictions/${e}${this.apiSignInUrl}`),!0}catch(r){throw console.warn(`There was a problem deleting your prediction: ${e}`,r),r.response}};getMyPredictions=async e=>{try{let r=new ie,n=`/predictions${this.apiSignInUrl}`;e&&(n+=`${e.constructFiltersUrl()}`);let a=await this.instanceAuth.get(n);return r.meta=this.metaRemapper.remapMetaData(a.data.meta),r.data=await this.predictionRemapper.remapResponseArrayBody(a.data.data),r}catch(r){throw console.warn("There was a problem fetching own predictions",r),r.response}};getMyPredictionsNoRemap=async e=>{try{return(await this.instanceAuth.get(`/predictions${this.apiSignInUrl}${e.constructFiltersUrl()}`)).data.data}catch(r){throw console.warn("There was a problem fetching own predictions",r),r.response}};getUserPredictions=async(e,r,n)=>{try{let a=new ie,c=`/predictions/users/${e}${this.apiSignInUrl}`,f=Date.now();n&&(c+=`${n.constructFiltersUrl()}`),r&&(c+=`&disable_cache=${f}`);let g=await this.instance.get(c);return a.meta=this.metaRemapper.remapMetaData(g.data.meta),a.data=await this.predictionRemapper.remapResponseArrayBody(g.data.data),a}catch(a){throw console.warn(`There was a problem fetching predictions for user: ${e}`,a),a.response}};getUserPredictionsNoRemap=async(e,r)=>{try{return(await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}${r.constructFiltersUrl()}`)).data.data}catch(n){throw console.warn(`There was a problem fetching predictions for user: ${e}`,n),n.response}};getGames=async(e,r)=>{try{let n=`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,a=Date.now();r&&(n+=`&disable_cache=${a}`);let c=await this.instance.get(n);return this.gamesRemapper.remapPaginatedGames(c.data)}catch(n){throw console.warn("There was a problem fetching the games list",n),n.response}};getGameById=async(e,r)=>{try{let n=`/games/${e}${this.apiSignInUrl}`,a=Date.now();r&&(n+=`&disable_cache=${a}`);let c=await this.instance.get(n);return this.gamesRemapper.remapGamesListResponse(c.data)}catch(n){throw console.warn(`There was a problem fetching the following game: ${e}`,n),n.response}};getGamePredictions=async(e,r,n)=>{try{let a=new ie,c=`/games/${e}/predictions${this.apiSignInUrl}`,f=Date.now();n&&(c+=`${n.constructFiltersUrl()}`),r&&(c+=`&disable_cache=${f}`);let g=await this.instance.get(c);return a.meta=this.metaRemapper.remapMetaData(g.data.meta),a.data=await this.predictionRemapper.remapResponseArrayBody(g.data.data),a}catch(a){throw console.warn(`There was a problem fetching the predictions for game: ${e}`,a),a.response}};getUserGameEditions=async(e,r)=>{try{let n=null,a=`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,c=Date.now();r&&(a+=`&disable_cache=${c}`);let f=await this.instance.get(a);return f.data.data.forEach(g=>{g.type==="TOP_X"?n=this.gamesRemapper.remapPaginatedUserTopXEditions(f.data):g.type==="MATCH_QUIZ"&&(n=this.gamesRemapper.remapPaginatedUserMathQuizEditions(f.data))}),n}catch(n){throw console.warn("There was a problem fetching the games list",n),n.response}};getGameResults=async(e,r,n)=>{try{let a=`/games/${e}/results/${this.apiSignInUrl}`,c=Date.now();n&&(a+=`${n.constructFiltersUrl()}`),r&&(a+=`&disable_cache=${c}`);let f=await this.instance.get(a);return this.gamesRemapper.remapPaginatedGameResults(f.data)}catch(a){throw console.warn(`There was a problem fetching the results for the following game: ${e}`,a),a.response}}};var xa=class{fullCoverageCompetitions=null;markets=null};var Oa=class{remapConfig=e=>{let r=new xa;return r.fullCoverageCompetitions=e.full_coverage_competitions,r.markets=e.markets,r}};var La=class{gameInstanceId=null;fixtures=null};var Ba=class{predictorHttps=null;clientHttps=null;idMapping=null;predictorConfigRemapper=null;predictorService=null;constructor(e,r,n,a){this.predictorHttps=r,this.idMapping=a,this.clientHttps=n,this.predictorConfigRemapper=new Oa,this.predictorService=new dt(e,a)}makeFootballPrediction=async(e,r,n,a)=>{let c=this.predictorService.validateFixture(e,r,n,a),f=new La;if(c)if(this.idMapping.idSchema!=="native"){let g=c.matchId,v="",S=await this.predictorService.remapMatchIdToNative([g]);if(c.matchId=S[0],!c.matchId)throw new Error("Match id is invalid!");if(c instanceof nt&&(v=c.prediction.playerId,c.prediction.playerId=await this.predictorService.remapPlayerIdToNative([v]),!c.prediction.playerId))throw new Error("Player id is invalid!");f.fixtures=[c];let M=await this.predictorHttps.makeFootballPrediction(f);return M.fixtures.map(F=>{F.prediction.playerId&&(F.prediction.playerId=v),F.matchId=g}),M}else return f.fixtures=[c],await this.predictorHttps.makeFootballPrediction(f);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 n=(await this.predictorService.remapMatchIdToNative([e]))[0],a=await this.predictorHttps.getMatchSummary(n);a.matchId=e;let c=a.predictions,f=await this.predictorService.remapPlayerIdToIdSchema(c);return a.predictions=f,a}else return await this.predictorHttps.getMatchSummary(e)};getMarketSummary=async(e,r,n)=>{try{let a=await this.getMatchSummary(e);return this.predictorService.getMarketSummary(a,r,n)}catch(a){return a.message}};getConfig=async()=>{let e=await this.clientHttps.getConfig(),r=await this.predictorConfigRemapper.remapConfig(e.predictor);return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(r):r};deleteFootballPrediction=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyPredictions=async e=>(e&&(e=new se(e)),await this.predictorHttps.getMyPredictions(e));getMyCurrentPredictions=async e=>{if(e)e.status&&delete e.status,e.status=["ACTIVE"],e=new se(e);else{let r={status:["ACTIVE"]};e=new se(r)}return await this.getMyPredictions(e)};getMyPastPredictions=async e=>{if(e)e.status&&delete e.status,e.status=Ni,e=new se(e);else{let r={status:Ni};e=new se(r)}return await this.getMyPredictions(e)};getUserPredictions=async(e,r,n)=>(n=n||!1,r&&(r=new se(r)),await this.predictorHttps.getUserPredictions(e,n,r));getUserCurrentPredictions=async(e,r)=>{if(r)r.status&&delete r.status,r.status=["ACTIVE"],r=new se(r);else{let n={status:["ACTIVE"]};r=new se(n)}return await this.getUserPredictions(e,r)};getUserPastPredictions=async(e,r)=>{if(r)r.status&&delete r.status,r.status=Ni,r=new se(r);else{let n={status:Ni};r=new se(n)}return await this.getUserPredictions(e,r)}};var Xm=Dt(Gt());var jr=class{instance=null;apiSignInUrl="";constructor(e){let r=Ee(e.environment,"client");this.apiSignInUrl=`/clients/${e.clientId}/features?key=${e.apiKey}`,this.instance=Xm.default.create({baseURL:r,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 Na=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(e){this.idMapping=new he(e),this.predictorHttps=new Yt(e,this.idMapping),this.clientHttps=new jr(e),this.predictorFacade=new Ba(e,this.predictorHttps,this.clientHttps,this.idMapping)}makeFootballPrediction=async(e,r,n,a)=>await this.predictorFacade.makeFootballPrediction(e,r,n,a);getMatchSummary=async e=>await this.predictorFacade.getMatchSummary(e);getMarketSummary=async(e,r,n)=>await this.predictorFacade.getMarketSummary(e,r,n);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,r,n)=>await this.predictorFacade.getUserPredictions(e,r,n);getUserCurrentPredictions=async(e,r)=>await this.predictorFacade.getUserCurrentPredictions(e,r);getUserPastPredictions=async(e,r)=>await this.predictorFacade.getUserPastPredictions(e,r)};var Ym=Dt(Gt());var Ua=class{rankType=null;fromDate=null;toDate=null;pagination=new Lr};var Da=class{position=null;profileId=null;profileModel=null;points=null};var Ga=class{remapMeta=e=>{let r=new Ua;return r.rankType=e.rank_type,r.fromDate=e.from_date,r.toDate=e.to_date,r.pagination.currentPage=e.pagination.current_page,r.pagination.itemsPerPage=e.pagination.items_per_page,r.pagination.totalItems=e.pagination.total_items,r.pagination.numberOfPages=e.pagination.number_of_pages,r};remapResponseData=e=>{let r=[];return e.forEach(n=>{let a=new Da;a.position=n.position,a.profileId=n.profile_id,a.points=n.points,r.push(a)}),r}};var $a=class{id=null;name=null;type=null;fromDate=null;toDate=null;markets=[];teamIds=[];matchIds=[];gameIds=[];gameTypes=[];competitionIds=[]};var Ha=class{remapResponse=e=>{let r=[];return e.forEach(n=>{let a=new $a;a.id=n.id,a.name=n.name,a.type=n.type,a.fromDate=n.from_date,a.toDate=n.to_date,a.markets=n.markets?n.markets:null,a.teamIds=n.team_ids?n.team_ids:null,a.matchIds=n.match_ids?n.match_ids:null,a.gameIds=n.game_ids?n.game_ids:null,a.gameTypes=n.game_types?n.game_types:null,a.competitionIds=n.competition_ids?n.competition_ids:null,r.push(a)}),r};remapMeta=e=>{let r={};return r.totalItems=e.pagination.total_items,r}};var Va=class{instance=null;apiSignInUrl=null;clientApiSignInUrl=null;templateRemapper=null;leaderboardRemapper=null;constructor(e){let r=Ee(e.environment,"loyalty");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.templateRemapper=new Ha,this.leaderboardRemapper=new Ga,this.instance=Ym.default.create({baseURL:r,headers:{"Content-Type":"application/json"}})}getTemplates=async e=>{try{let r=`/leaderboard/templates/${this.apiSignInUrl}`,n=Date.now();e&&(r+=`&disable_cache=${n}`);let a=await this.instance.get(r),c=JSON.parse(JSON.stringify(a.data));return c.meta=this.templateRemapper.remapMeta(a.data.meta),c.data=this.templateRemapper.remapResponse(a.data.data),c}catch(r){throw console.warn("There was a problem fetching the list of templates",r),r.response}};getLeaderboard=async(e,r,n)=>{try{let a=`/leaderboard/${e}/${this.apiSignInUrl}`,c=Date.now();r&&(a+=`&disable_cache=${c}`),n&&(a+=`${n.constructFiltersUrl()}`);let f=await this.instance.get(a),g=JSON.parse(JSON.stringify(f.data));return g.meta=this.leaderboardRemapper.remapMeta(f.data.meta),g.data=this.leaderboardRemapper.remapResponseData(f.data.data),g}catch(a){throw console.warn(`There was a problem fetching the leaderboard for the following template: ${e}`,a),a.response}};getLeaderboardForGame=async(e,r,n)=>{try{let a=`/leaderboard/games/${e}/${this.apiSignInUrl}`,c=Date.now();r&&(a+=`&disable_cache=${c}`),n&&(a+=`${n.constructFiltersUrl()}`);let f=await this.instance.get(a),g=JSON.parse(JSON.stringify(f.data));return qn(g)}catch(a){throw console.warn(`There was a problem fetching the leaderboard for the following game: ${e}`,a),a.response}}};var Di=class{limit=null;page=null;constructor(e){this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null}constructFiltersUrl=()=>{let e="";return this.limit&&(e+="&",e+=`limit=${this.limit}`),this.page&&(e+="&",e+=`page=${this.page}`),e}};var qa=class{general=[];predictor=[];topX=[]};var ka=class{enabled=!1;rewards=null};var Wa=class{general=null;topX=null;predictor=null};var Ka=class{points=null;tiers=null;badges=null};var Xa=class{remapLoyaltyResponse=e=>{let r=new ka;return r.enabled=e.enabled,r.rewards=this.remapRewards(e.rewards),r};remapRewards=e=>{let r=new Ka;return r.points=this.remapPoints(e.points),r.tiers=e.tiers,r.badges=this.remapBadges(e.badges),r};remapPoints=e=>{let r=new Wa;return r.general=e.general,r.topX=e.top_x,r.predictor=e.predictor,r};remapBadges=e=>{let r=new qa;return r.general=e.general,r.predictor=e.predictor,r.topX=e.top_x,r}};var Ya=class{idMappingService=null;profileNamespace=null;constructor(e){this.idMappingService=new he(e),this.profileNamespace=new $r(e)}remapTemplatesIds=async e=>{if(e.length>0){let r=[],n=[],a=[],c=[],f=[],g=[];e.forEach(M=>{M.teamIds&&M.teamIds.length>0?r=[...r,...M.teamIds]:M.matchIds&&M.matchIds.length>0?a=[...a,...M.matchIds]:M.competitionIds&&M.competitionIds.length>0&&(f=[...f,...M.competitionIds])});let v={team:r,match:a,competition:f},S=await this.idMappingService.idMappingFacade.getEntitiesByIds(v,"native",this.idMappingService.idSchema);return n=[...S.team],c=[...S.match],g=[...S.competition],e.forEach(M=>{M.teamIds&&M.teamIds.length>0?M.teamIds=M.teamIds.map(F=>F=S.team.shift()):M.matchIds&&M.matchIds.length>0?M.matchIds=M.matchIds.map(F=>F=S.match.shift()):M.competitionIds&&M.competitionIds.length>0&&(M.competitionIds=M.competitionIds.map(F=>F=S.competition.shift()))}),e}return e};addProfileModel=async e=>{if(e.length>0){let r=[],n=[];e.forEach(c=>{r.push(c.profileId)});let a=await this.profileNamespace.getByIds(r);return e.forEach(c=>{a.forEach(f=>{f.id===c.profileId&&(delete f.interests,c.profileModel=f)}),c.profileModel||(c.profileModel=null),n.push(c)}),n}return e}};var za=class{config=null;clientHttps=null;loyaltyHttps=null;loyaltyRemapper=null;loyaltyService=null;constructor(e,r,n){this.config=e,this.clientHttps=r,this.loyaltyHttps=n,this.loyaltyRemapper=new Xa,this.loyaltyService=new Ya(this.config)}getConfig=async()=>{let e=await this.clientHttps.getConfig();return this.loyaltyRemapper.remapLoyaltyResponse(e.loyalty)};getTemplates=async e=>{if(e=e||!1,this.config.idSchema==="native")return await this.loyaltyHttps.getTemplates(e);let r=await this.loyaltyHttps.getTemplates(e);return r.data=await this.loyaltyService.remapTemplatesIds([...r.data]),r};getLeaderboard=async(e,r,n)=>{n=n||!1,r&&(r=new Di(r));let a=await this.loyaltyHttps.getLeaderboard(e,n,r);return a.data=await this.loyaltyService.addProfileModel(a.data),a};getLeaderboardForGame=async(e,r,n)=>{n=n||!1,r&&(r=new Di(r));let a=await this.loyaltyHttps.getLeaderboardForGame(e,n,r);return a.data=await this.loyaltyService.addProfileModel(a.data),a}};var Ja=class{clientHttps=null;loyaltyHttps=null;loyaltyFacade=null;constructor(e){this.clientHttps=new jr(e),this.loyaltyHttps=new Va(e),this.loyaltyFacade=new za(e,this.clientHttps,this.loyaltyHttps)}getConfig=()=>this.loyaltyFacade.getConfig();getTemplates=e=>this.loyaltyFacade.getTemplates(e);getLeaderboard=(e,r,n)=>this.loyaltyFacade.getLeaderboard(e,r,n);getLeaderboardForGame=(e,r,n)=>this.loyaltyFacade.getLeaderboardForGame(e,r,n)};var Qa=class{idMapping=null;predictorHttps=null;predictorService=null;constructor(e,r){this.idMapping=r,this.predictorHttps=new Yt(e,r),this.predictorService=new dt(e,r)}getGames=async(e,r)=>{r=r||!1;let n=this.predictorService.initGameFilters("TOP_X",e),a=await this.predictorHttps.getGames(n,r);return await this.predictorService.remapMatchIdsFixtures(a)};getGameById=async(e,r)=>{r=r||!1;let n=await this.predictorHttps.getGameById(e,r);return await this.predictorService.remapMatchIdsFixtures(n)};getGamePredictions=async(e,r,n)=>(n=n||!1,r&&(r.type&&delete r.type,r.status&&delete r.status,r=new se(r)),await this.predictorHttps.getGamePredictions(e,n,r));getGameResults=async(e,r,n)=>{n=n||!1,r&&(r.type&&delete r.type,r.gameIds&&delete r.gameIds,r=new $e(r));let a=await this.predictorHttps.getGameResults(e,n,r);return await this.predictorService.remapMatchIdsFixtures(a)};getCurrentGameResults=async e=>{e=e||!1;let r={status:"OPEN",type:"TOP_X"};r=new $e(r);let n=await this.predictorHttps.getGames(r,e),a=this.predictorService.getCurrentGameId(n);return(await this.getGameResults(a,null,e)).data[0]};play=async e=>{let r=new Qr(e);if(this.idMapping.idSchema!=="native"){let a=[];r.fixtures.forEach(f=>a.push(f.matchId));let c=await this.predictorService.remapMatchIdToNative(a);r.fixtures.forEach(f=>f.matchId=c.shift())}let n=await this.predictorHttps.makeFootballPrediction(r);return n.fixtures.forEach(a=>{a.matchId=a.matchModel.id}),n};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyGameEditions=async(e,r)=>{r=r||!1;let n=this.predictorService.initGameTypePredictions("TOP_X"),a=[],c=await this.predictorHttps.getMyPredictionsNoRemap(n);if(c.length>0){c.forEach(v=>{v.game_instance_id&&a.push(v.game_instance_id)});let f=this.predictorService.initGameFilters("TOP_X",e,a),g=await this.predictorHttps.getUserGameEditions(f,r);return await this.predictorService.addPredictionProp(c,g)}else return new ie};getMyGamePrediction=async e=>{let r=this.predictorService.initGameTypePredictions("TOP_X"),n=await this.predictorHttps.getMyPredictions(r);return n.data.length>0?n.data.filter(c=>c.gameInstanceId===e)[0]:null};getUserGameEditions=async(e,r,n)=>{n=n||!1;let a=this.predictorService.initGameTypePredictions("TOP_X"),c=[],f=await this.predictorHttps.getUserPredictionsNoRemap(e,a);if(f.length>0){f.forEach(S=>{S.game_instance_id&&c.push(S.game_instance_id)});let g=this.predictorService.initGameFilters("TOP_X",r,c),v=await this.predictorHttps.getUserGameEditions(g,n);return await this.predictorService.addPredictionProp(f,v)}else return new ie};getUserGamePrediction=async(e,r,n)=>{n=n||!1;let a=this.predictorService.initGameTypePredictions("TOP_X"),c=await this.predictorHttps.getUserPredictions(e,n,a);return c.data.length>0?c.data.filter(g=>g.gameInstanceId===r)[0]:null}};var Za=class{topXFacade=null;idMapping=null;constructor(e){this.idMapping=new he(e),this.topXFacade=new Qa(e,this.idMapping)}getGames=async(e,r)=>await this.topXFacade.getGames(e,r);getGameById=async(e,r)=>await this.topXFacade.getGameById(e,r);getGamePredictions=async(e,r,n)=>await this.topXFacade.getGamePredictions(e,r,n);getGameResults=async(e,r,n)=>await this.topXFacade.getGameResults(e,r,n);getCurrentGameResults=async e=>await this.topXFacade.getCurrentGameResults(e);play=async e=>await this.topXFacade.play(e);delete=async e=>await this.topXFacade.delete(e);getMyGameEditions=async(e,r)=>await this.topXFacade.getMyGameEditions(e,r);getMyGamePrediction=async e=>await this.topXFacade.getMyGamePrediction(e);getUserGameEditions=async(e,r,n)=>await this.topXFacade.getUserGameEditions(e,r,n);getUserGamePrediction=async(e,r,n)=>await this.topXFacade.getUserGamePrediction(e,r,n)};var ja=class{predictorHttps=null;predictorService=null;idMapping=null;constructor(e){this.idMapping=new he(e),this.predictorHttps=new Yt(e,this.idMapping),this.predictorService=new dt(e,this.idMapping)}play=async e=>{let r=e.fixtures.map(n=>this.predictorService.validateFixture(n.matchId,n.market,n.prediction.value,n.prediction.playerId));if(r){if(this.idMapping.idSchema!=="native"){let n=[],a=[];r.forEach(g=>{n.push(g.matchId),g instanceof nt&&a.push(g.prediction.playerId)});let c=await this.predictorService.remapMatchIdToNative(n),f={};a&&a.length>0&&(f=await this.predictorService.remapPlayerIdMapToNative(a)),r.forEach((g,v)=>{g.matchId=c[v],g instanceof nt&&(g.prediction.playerId=f[g.prediction.playerId])})}}else throw new Error("The prediction is invalid. Please check again have you passed appropriate prediction model");return e.fixtures=r,await this.predictorHttps.makeFootballPrediction(e)};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getGames=async(e,r)=>{r=r||!1;let n=this.predictorService.initGameFilters("MATCH_QUIZ",e),a=await this.predictorHttps.getGames(n,r);return await this.predictorService.remapMatchIdsFixtures(a)};getGameById=async(e,r)=>{r=r||!1;let n=await this.predictorHttps.getGameById(e,r);return await this.predictorService.remapMatchIdsFixtures(n)};getGamePredictions=async(e,r,n)=>(n=n||!1,r&&(r.type&&delete r.type,r.status&&delete r.status,r=new se(r)),await this.predictorHttps.getGamePredictions(e,n,r));getGameResults=async(e,r,n)=>{n=n||!1,r&&(r.type&&delete r.type,r.gameIds&&delete r.gameIds,r=new $e(r));let a=await this.predictorHttps.getGameResults(e,n,r);return await this.predictorService.remapMatchIdsFixtures(a)};getCurrentGameResults=async e=>{e=e||!1;let r={status:"OPEN",type:"MATCH_QUIZ"};r=new $e(r);let n=await this.predictorHttps.getGames(r,e),a=this.predictorService.getCurrentGameId(n);return(await this.getGameResults(a,null,e)).data[0]};getMyGameEditions=async(e,r)=>{r=r||!1;let n=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),a=[],c=await this.predictorHttps.getMyPredictionsNoRemap(n);if(c.length>0){c.forEach(v=>{v.game_instance_id&&a.push(v.game_instance_id)});let f=this.predictorService.initGameFilters("MATCH_QUIZ",e,a),g=await this.predictorHttps.getUserGameEditions(f,r);return await this.predictorService.addPredictionProp(c,g)}else return new ie};getMyGamePrediction=async e=>{let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),n=await this.predictorHttps.getMyPredictions(r);return n.data.length>0?n.data.filter(c=>c.gameInstanceId===e)[0]:null};getUserGameEditions=async(e,r,n)=>{n=n||!1;let a=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),c=[],f=await this.predictorHttps.getUserPredictionsNoRemap(e,a);if(f.length>0){f.forEach(S=>{S.game_instance_id&&c.push(S.game_instance_id)});let g=this.predictorService.initGameFilters("MATCH_QUIZ",r,c),v=await this.predictorHttps.getUserGameEditions(g,n);return await this.predictorService.addPredictionProp(f,v)}else return new ie};getUserGamePrediction=async(e,r,n)=>{n=n||!1;let a=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),c=await this.predictorHttps.getUserPredictions(e,n,a);return c.data.length>0?c.data.filter(g=>g.gameInstanceId===r)[0]:null}};var es=class{matchQuizFacade=null;constructor(e){this.matchQuizFacade=new ja(e)}play=async e=>await this.matchQuizFacade.play(e);delete=async e=>await this.matchQuizFacade.delete(e);getGames=async(e,r)=>await this.matchQuizFacade.getGames(e,r);getGameById=async(e,r)=>await this.matchQuizFacade.getGameById(e,r);getGamePredictions=async(e,r,n)=>await this.matchQuizFacade.getGamePredictions(e,r,n);getGameResults=async(e,r,n)=>await this.matchQuizFacade.getGameResults(e,r,n);getCurrentGameResults=async e=>await this.matchQuizFacade.getCurrentGameResults(e);getMyGameEditions=async(e,r)=>await this.matchQuizFacade.getMyGameEditions(e,r);getMyGamePrediction=async e=>await this.matchQuizFacade.getMyGamePrediction(e);getUserGameEditions=async(e,r,n)=>await this.matchQuizFacade.getUserGameEditions(e,r,n);getUserGamePrediction=async(e,r,n)=>await this.matchQuizFacade.getUserGamePrediction(e,r,n)};var Gi=class{action=null;page=null;limit=null;constructor(e){this.action=e.action?e.action:null,this.page=e.page?e.page:null,this.limit=e.limit?e.limit:null}constructFilterUrl=()=>{let e="";return this.action&&(e+="&",e+=`action=${this.action}`),this.page&&(e+="&",e+=`page=${this.page}`),this.limit&&(e+="&",e+=`limit=${this.limit}`),e}};var $i=class{action=null;context=new Ur;constructor(e,r,n,a){this.action=e,this.context.tags=r,n&&(this.context.content=n),a&&(this.context.campaign=a)}};var ts=class{idSchema;idMapping;constructor(e){this.idSchema=e.idSchema,this.idMapping=new he(e)}remapTagsIds=async(e,r,n)=>{let a={},c={},f=[];e.forEach(v=>{a.hasOwnProperty(v.type)||(a[v.type]=[],c[v.type]=[]),a[v.type].push(v.id),c[v.type].push(v)});let g=await this.idMapping.idMappingFacade.getEntitiesByIds(a,r,n);for(let[v,S]of Object.entries(c))S.forEach((M,F)=>{M.id=g[v][F],f.push(M)});return f}};var rs=class{idSchema;activityHttps;activityService;constructor(e){this.idSchema=e.idSchema,this.activityHttps=new Gr(e),this.activityService=new ts(e)}add=async(e,r,n,a)=>{if(this.idSchema!="native"){let f=JSON.parse(JSON.stringify(r)),g=await this.activityService.remapTagsIds(r,this.idSchema,"native"),v=new $i(e,g,n,a),S=await this.activityHttps.createActivity(v);return S.context.tags=f,S}let c=new $i(e,r,n,a);return this.activityHttps.createActivity(c)};delete=async e=>await this.activityHttps.deleteActivity(e);like=async(e,r,n)=>{let a="like";return await this.add(a,e,r,n)};dislike=async(e,r,n)=>{let a="dislike";return await this.add(a,e,r,n)};addPageview=async(e,r,n)=>{let a="page_view";return await this.add(a,e,r,n)};addContentConsumed=async(e,r,n)=>{let a="content_consumed";return await this.add(a,e,r,n)};addShare=async(e,r,n)=>{let a="share";return await this.add(a,e,r,n)};addComment=async(e,r,n)=>{let a="comment";return await this.add(a,e,r,n)};addClickAd=async(e,r,n)=>{let a="click_ad";return await this.add(a,e,r,n)};addConversion=async(e,r,n)=>{let a="conversion";return await this.add(a,e,r,n)};getOwn=async(e,r)=>{if(r=r||!1,e&&(e=new Gi(e)),this.idSchema!="native"){let n=await this.activityHttps.getOwnActivities(e,r);for(let a of n.data)await this.activityService.remapTagsIds(a.context.tags,"native",this.idSchema);return n}return await this.activityHttps.getOwnActivities(e,r)};getForUser=async(e,r,n)=>{if(n=n||!1,r&&(r=new Gi(r)),this.idSchema!="native"){let a=await this.activityHttps.getActivitiesForUser(e,r,n);for(let c of a.data)await this.activityService.remapTagsIds(c.context.tags,"native",this.idSchema);return a}return await this.activityHttps.getActivitiesForUser(e,r,n)}};var is=class{activityFacade;constructor(e){this.activityFacade=new rs(e)}add=async(e,r,n,a)=>await this.activityFacade.add(e,r,n,a);delete=async e=>await this.activityFacade.delete(e);like=async(e,r,n)=>await this.activityFacade.like(e,r,n);dislike=async(e,r,n)=>await this.activityFacade.dislike(e,r,n);addPageview=async(e,r,n)=>await this.activityFacade.addPageview(e,r,n);addContentConsumed=async(e,r,n)=>await this.activityFacade.addContentConsumed(e,r,n);addShare=async(e,r,n)=>await this.activityFacade.addShare(e,r,n);addComment=async(e,r,n)=>await this.activityFacade.addComment(e,r,n);addClickAd=async(e,r,n)=>await this.activityFacade.addClickAd(e,r,n);addConversion=async(e,r,n)=>await this.activityFacade.addConversion(e,r,n);getOwn=async(e,r)=>await this.activityFacade.getOwn(e,r);getForUser=async(e,r,n)=>await this.activityFacade.getForUser(e,r,n)};function Mx(s){let r=new na().validate(s);if(r.idSchema.validation==="missing"&&(console.warn(r.idSchema.message.text),s.idSchema="native"),r.environment.validation==="missing"&&(console.warn(r.environment.message.text),s.environment="prod"),r.lang.validation==="missing"&&(console.warn(r.lang.message.text),s.lang="en"),r.isValid)return{profile:new $r(s),football:new oa(s),predictor:new Na(s),loyalty:new Ja(s),topX:new Za(s),matchQuiz:new es(s),activity:new is(s)};throw new Error("Configuration is not valid")}export{Mx as FansUnitedSDK};
|
|
21
|
+
}`;var D=Eu(function(){return k(m,C+"return "+R).apply(s,d)});if(D.source=R,hl(D))throw D;return D}function QM(t){return W(t).toLowerCase()}function ZM(t){return W(t).toUpperCase()}function jM(t,i,o){if(t=W(t),t&&(o||i===s))return Dp(t);if(!t||!(i=Oe(i)))return t;var l=et(t),p=et(i),m=Gp(l,p),d=$p(l,p)+1;return Nt(l,m,d).join("")}function eb(t,i,o){if(t=W(t),t&&(o||i===s))return t.slice(0,Vp(t)+1);if(!t||!(i=Oe(i)))return t;var l=et(t),p=$p(l,et(i))+1;return Nt(l,0,p).join("")}function tb(t,i,o){if(t=W(t),t&&(o||i===s))return t.replace(hs,"");if(!t||!(i=Oe(i)))return t;var l=et(t),p=Gp(l,et(i));return Nt(l,p).join("")}function rb(t,i){var o=zm,l=Jm;if(j(i)){var p="separator"in i?i.separator:p;o="length"in i?U(i.length):o,l="omission"in i?Oe(i.omission):l}t=W(t);var m=t.length;if(dr(t)){var d=et(t);m=d.length}if(o>=m)return t;var h=o-fr(l);if(h<1)return l;var w=d?Nt(d,0,h).join(""):t.slice(0,h);if(p===s)return w+l;if(d&&(h+=w.length-h),gl(p)){if(t.slice(h).search(p)){var I,P=w;for(p.global||(p=xs(p.source,W(ap.exec(p))+"g")),p.lastIndex=0;I=p.exec(P);)var R=I.index;w=w.slice(0,R===s?h:R)}}else if(t.indexOf(Oe(p),h)!=h){var T=w.lastIndexOf(p);T>-1&&(w=w.slice(0,T))}return w+l}function ib(t){return t=W(t),t&&dd.test(t)?t.replace(ip,xf):t}var nb=br(function(t,i,o){return t+(o?" ":"")+i.toUpperCase()}),Ml=Cc("toUpperCase");function Tu(t,i,o){return t=W(t),i=o?s:i,i===s?Sf(t)?Bf(t):wf(t):t.match(i)||[]}var Eu=G(function(t,i){try{return Ae(t,s,i)}catch(o){return hl(o)?o:new L(o)}}),ob=bt(function(t,i){return qe(i,function(o){o=ct(o),wt(t,o,dl(t[o],t))}),t});function ab(t){var i=t==null?0:t.length,o=A();return t=i?Z(t,function(l){if(typeof l[1]!="function")throw new ke(a);return[o(l[0]),l[1]]}):[],G(function(l){for(var p=-1;++p<i;){var m=t[p];if(Ae(m[0],this,l))return Ae(m[1],this,l)}})}function sb(t){return xh(Ke(t,S))}function bl(t){return function(){return t}}function lb(t,i){return t==null||t!==t?i:t}var pb=xc(),cb=xc(!0);function Se(t){return t}function vl(t){return lc(typeof t=="function"?t:Ke(t,S))}function ub(t){return cc(Ke(t,S))}function mb(t,i){return uc(t,Ke(i,S))}var db=G(function(t,i){return function(o){return gi(o,t,i)}}),fb=G(function(t,i){return function(o){return gi(t,o,i)}});function _l(t,i,o){var l=pe(i),p=hn(i,l);o==null&&!(j(i)&&(p.length||!l.length))&&(o=i,i=t,t=this,p=hn(i,pe(i)));var m=!(j(o)&&"chain"in o)||!!o.chain,d=_t(t);return qe(p,function(h){var w=i[h];t[h]=w,d&&(t.prototype[h]=function(){var I=this.__chain__;if(m||I){var P=t(this.__wrapped__),R=P.__actions__=Pe(this.__actions__);return R.push({func:w,args:arguments,thisArg:t}),P.__chain__=I,P}return w.apply(t,Et([this.value()],arguments))})}),t}function hb(){return le._===this&&(le._=Hf),this}function Il(){}function gb(t){return t=U(t),G(function(i){return mc(i,t)})}var yb=el(Z),wb=el(Op),Mb=el(Rs);function Cu(t){return sl(t)?Fs(ct(t)):zh(t)}function bb(t){return function(i){return t==null?s:tr(t,i)}}var vb=Lc(),_b=Lc(!0);function Pl(){return[]}function Rl(){return!1}function Ib(){return{}}function Pb(){return""}function Rb(){return!0}function Fb(t,i){if(t=U(t),t<1||t>St)return[];var o=st,l=de(t,st);i=A(i),t-=st;for(var p=Es(l,i);++o<t;)i(o);return p}function Sb(t){return B(t)?Z(t,ct):Le(t)?[t]:Pe(Jc(W(t)))}function Tb(t){var i=++Gf;return W(t)+i}var Eb=vn(function(t,i){return t+i},0),Cb=tl("ceil"),Ab=vn(function(t,i){return t/i},1),xb=tl("floor");function Ob(t){return t&&t.length?fn(t,Se,$s):s}function Lb(t,i){return t&&t.length?fn(t,A(i,2),$s):s}function Bb(t){return Np(t,Se)}function Nb(t,i){return Np(t,A(i,2))}function Ub(t){return t&&t.length?fn(t,Se,ks):s}function Db(t,i){return t&&t.length?fn(t,A(i,2),ks):s}var Gb=vn(function(t,i){return t*i},1),$b=tl("round"),Hb=vn(function(t,i){return t-i},0);function Vb(t){return t&&t.length?Ts(t,Se):0}function qb(t,i){return t&&t.length?Ts(t,A(i,2)):0}return u.after=uw,u.ary=su,u.assign=Zw,u.assignIn=vu,u.assignInWith=Ln,u.assignWith=jw,u.at=eM,u.before=lu,u.bind=dl,u.bindAll=ob,u.bindKey=pu,u.castArray=Iw,u.chain=nu,u.chunk=xg,u.compact=Og,u.concat=Lg,u.cond=ab,u.conforms=sb,u.constant=bl,u.countBy=Vy,u.create=tM,u.curry=cu,u.curryRight=uu,u.debounce=mu,u.defaults=rM,u.defaultsDeep=iM,u.defer=mw,u.delay=dw,u.difference=Bg,u.differenceBy=Ng,u.differenceWith=Ug,u.drop=Dg,u.dropRight=Gg,u.dropRightWhile=$g,u.dropWhile=Hg,u.fill=Vg,u.filter=ky,u.flatMap=Xy,u.flatMapDeep=Yy,u.flatMapDepth=zy,u.flatten=eu,u.flattenDeep=qg,u.flattenDepth=kg,u.flip=fw,u.flow=pb,u.flowRight=cb,u.fromPairs=Wg,u.functions=cM,u.functionsIn=uM,u.groupBy=Jy,u.initial=Xg,u.intersection=Yg,u.intersectionBy=zg,u.intersectionWith=Jg,u.invert=dM,u.invertBy=fM,u.invokeMap=Zy,u.iteratee=vl,u.keyBy=jy,u.keys=pe,u.keysIn=Fe,u.map=Tn,u.mapKeys=gM,u.mapValues=yM,u.matches=ub,u.matchesProperty=mb,u.memoize=Cn,u.merge=wM,u.mergeWith=_u,u.method=db,u.methodOf=fb,u.mixin=_l,u.negate=An,u.nthArg=gb,u.omit=MM,u.omitBy=bM,u.once=hw,u.orderBy=ew,u.over=yb,u.overArgs=gw,u.overEvery=wb,u.overSome=Mb,u.partial=fl,u.partialRight=du,u.partition=tw,u.pick=vM,u.pickBy=Iu,u.property=Cu,u.propertyOf=bb,u.pull=ey,u.pullAll=ru,u.pullAllBy=ty,u.pullAllWith=ry,u.pullAt=iy,u.range=vb,u.rangeRight=_b,u.rearg=yw,u.reject=nw,u.remove=ny,u.rest=ww,u.reverse=ul,u.sampleSize=aw,u.set=IM,u.setWith=PM,u.shuffle=sw,u.slice=oy,u.sortBy=cw,u.sortedUniq=my,u.sortedUniqBy=dy,u.split=XM,u.spread=Mw,u.tail=fy,u.take=hy,u.takeRight=gy,u.takeRightWhile=yy,u.takeWhile=wy,u.tap=Oy,u.throttle=bw,u.thru=Sn,u.toArray=wu,u.toPairs=Pu,u.toPairsIn=Ru,u.toPath=Sb,u.toPlainObject=bu,u.transform=RM,u.unary=vw,u.union=My,u.unionBy=by,u.unionWith=vy,u.uniq=_y,u.uniqBy=Iy,u.uniqWith=Py,u.unset=FM,u.unzip=ml,u.unzipWith=iu,u.update=SM,u.updateWith=TM,u.values=Ir,u.valuesIn=EM,u.without=Ry,u.words=Tu,u.wrap=_w,u.xor=Fy,u.xorBy=Sy,u.xorWith=Ty,u.zip=Ey,u.zipObject=Cy,u.zipObjectDeep=Ay,u.zipWith=xy,u.entries=Pu,u.entriesIn=Ru,u.extend=vu,u.extendWith=Ln,_l(u,u),u.add=Eb,u.attempt=Eu,u.camelCase=OM,u.capitalize=Fu,u.ceil=Cb,u.clamp=CM,u.clone=Pw,u.cloneDeep=Fw,u.cloneDeepWith=Sw,u.cloneWith=Rw,u.conformsTo=Tw,u.deburr=Su,u.defaultTo=lb,u.divide=Ab,u.endsWith=LM,u.eq=rt,u.escape=BM,u.escapeRegExp=NM,u.every=qy,u.find=Wy,u.findIndex=Zc,u.findKey=nM,u.findLast=Ky,u.findLastIndex=jc,u.findLastKey=oM,u.floor=xb,u.forEach=ou,u.forEachRight=au,u.forIn=aM,u.forInRight=sM,u.forOwn=lM,u.forOwnRight=pM,u.get=yl,u.gt=Ew,u.gte=Cw,u.has=mM,u.hasIn=wl,u.head=tu,u.identity=Se,u.includes=Qy,u.indexOf=Kg,u.inRange=AM,u.invoke=hM,u.isArguments=nr,u.isArray=B,u.isArrayBuffer=Aw,u.isArrayLike=Re,u.isArrayLikeObject=te,u.isBoolean=xw,u.isBuffer=Ut,u.isDate=Ow,u.isElement=Lw,u.isEmpty=Bw,u.isEqual=Nw,u.isEqualWith=Uw,u.isError=hl,u.isFinite=Dw,u.isFunction=_t,u.isInteger=fu,u.isLength=xn,u.isMap=hu,u.isMatch=Gw,u.isMatchWith=$w,u.isNaN=Hw,u.isNative=Vw,u.isNil=kw,u.isNull=qw,u.isNumber=gu,u.isObject=j,u.isObjectLike=ee,u.isPlainObject=_i,u.isRegExp=gl,u.isSafeInteger=Ww,u.isSet=yu,u.isString=On,u.isSymbol=Le,u.isTypedArray=_r,u.isUndefined=Kw,u.isWeakMap=Xw,u.isWeakSet=Yw,u.join=Qg,u.kebabCase=UM,u.last=Ye,u.lastIndexOf=Zg,u.lowerCase=DM,u.lowerFirst=GM,u.lt=zw,u.lte=Jw,u.max=Ob,u.maxBy=Lb,u.mean=Bb,u.meanBy=Nb,u.min=Ub,u.minBy=Db,u.stubArray=Pl,u.stubFalse=Rl,u.stubObject=Ib,u.stubString=Pb,u.stubTrue=Rb,u.multiply=Gb,u.nth=jg,u.noConflict=hb,u.noop=Il,u.now=En,u.pad=$M,u.padEnd=HM,u.padStart=VM,u.parseInt=qM,u.random=xM,u.reduce=rw,u.reduceRight=iw,u.repeat=kM,u.replace=WM,u.result=_M,u.round=$b,u.runInContext=y,u.sample=ow,u.size=lw,u.snakeCase=KM,u.some=pw,u.sortedIndex=ay,u.sortedIndexBy=sy,u.sortedIndexOf=ly,u.sortedLastIndex=py,u.sortedLastIndexBy=cy,u.sortedLastIndexOf=uy,u.startCase=YM,u.startsWith=zM,u.subtract=Hb,u.sum=Vb,u.sumBy=qb,u.template=JM,u.times=Fb,u.toFinite=It,u.toInteger=U,u.toLength=Mu,u.toLower=QM,u.toNumber=ze,u.toSafeInteger=Qw,u.toString=W,u.toUpper=ZM,u.trim=jM,u.trimEnd=eb,u.trimStart=tb,u.truncate=rb,u.unescape=ib,u.uniqueId=Tb,u.upperCase=nb,u.upperFirst=Ml,u.each=ou,u.eachRight=au,u.first=tu,_l(u,function(){var t={};return lt(u,function(i,o){X.call(u.prototype,o)||(t[o]=i)}),t}(),{chain:!1}),u.VERSION=e,qe(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){u[t].placeholder=u}),qe(["drop","take"],function(t,i){H.prototype[t]=function(o){o=o===s?1:ae(U(o),0);var l=this.__filtered__&&!i?new H(this):this.clone();return l.__filtered__?l.__takeCount__=de(o,l.__takeCount__):l.__views__.push({size:de(o,st),type:t+(l.__dir__<0?"Right":"")}),l},H.prototype[t+"Right"]=function(o){return this.reverse()[t](o).reverse()}}),qe(["filter","map","takeWhile"],function(t,i){var o=i+1,l=o==ep||o==q;H.prototype[t]=function(p){var m=this.clone();return m.__iteratees__.push({iteratee:A(p,3),type:o}),m.__filtered__=m.__filtered__||l,m}}),qe(["head","last"],function(t,i){var o="take"+(i?"Right":"");H.prototype[t]=function(){return this[o](1).value()[0]}}),qe(["initial","tail"],function(t,i){var o="drop"+(i?"":"Right");H.prototype[t]=function(){return this.__filtered__?new H(this):this[o](1)}}),H.prototype.compact=function(){return this.filter(Se)},H.prototype.find=function(t){return this.filter(t).head()},H.prototype.findLast=function(t){return this.reverse().find(t)},H.prototype.invokeMap=G(function(t,i){return typeof t=="function"?new H(this):this.map(function(o){return gi(o,t,i)})}),H.prototype.reject=function(t){return this.filter(An(A(t)))},H.prototype.slice=function(t,i){t=U(t);var o=this;return o.__filtered__&&(t>0||i<0)?new H(o):(t<0?o=o.takeRight(-t):t&&(o=o.drop(t)),i!==s&&(i=U(i),o=i<0?o.dropRight(-i):o.take(i-t)),o)},H.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},H.prototype.toArray=function(){return this.take(st)},lt(H.prototype,function(t,i){var o=/^(?:filter|find|map|reject)|While$/.test(i),l=/^(?:head|last)$/.test(i),p=u[l?"take"+(i=="last"?"Right":""):i],m=l||/^find/.test(i);!p||(u.prototype[i]=function(){var d=this.__wrapped__,h=l?[1]:arguments,w=d instanceof H,I=h[0],P=w||B(d),R=function($){var V=p.apply(u,Et([$],h));return l&&T?V[0]:V};P&&o&&typeof I=="function"&&I.length!=1&&(w=P=!1);var T=this.__chain__,C=!!this.__actions__.length,x=m&&!T,D=w&&!C;if(!m&&P){d=D?d:new H(this);var O=t.apply(d,h);return O.__actions__.push({func:Sn,args:[R],thisArg:s}),new We(O,T)}return x&&D?t.apply(this,h):(O=this.thru(R),x?l?O.value()[0]:O.value():O)})}),qe(["pop","push","shift","sort","splice","unshift"],function(t){var i=Zi[t],o=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",l=/^(?:pop|shift)$/.test(t);u.prototype[t]=function(){var p=arguments;if(l&&!this.__chain__){var m=this.value();return i.apply(B(m)?m:[],p)}return this[o](function(d){return i.apply(B(d)?d:[],p)})}}),lt(H.prototype,function(t,i){var o=u[i];if(o){var l=o.name+"";X.call(yr,l)||(yr[l]=[]),yr[l].push({name:i,func:o})}}),yr[bn(s,ot).name]=[{name:"wrapper",func:s}],H.prototype.clone=ih,H.prototype.reverse=nh,H.prototype.value=oh,u.prototype.at=Ly,u.prototype.chain=By,u.prototype.commit=Ny,u.prototype.next=Uy,u.prototype.plant=Gy,u.prototype.reverse=$y,u.prototype.toJSON=u.prototype.valueOf=u.prototype.value=Hy,u.prototype.first=u.prototype.head,pi&&(u.prototype[pi]=Dy),u},At=Nf();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(le._=At,define(function(){return At})):Jt?((Jt.exports=At)._=At,vs._=At):le._=At}).call(Sr)});var Xl=Dt(Gt());var Gm=Dt(Um());var Kl=s=>{let e=250,r=[],n=0;return r[n]=[],s.forEach(a=>{r[n].length<=e?r[n].push(a):(n++,r[n]=[a])}),r},Vn=s=>{let e=[],r=200;for(;s.length>r;){let n=s.splice(0,r);e.push(n)}return e.push(s),e},Ee=(s,e)=>{let r="",n={profile:"https://profile.fansunitedapi.com/v1",football:"https://football.fansunitedapi.com/v1",idMapping:"https://id-mapping.fansunitedapi.com/v1",predictor:"https://prediction.fansunitedapi.com/v1",client:"https://client.fansunitedapi.com/v1",loyalty:"https://loyalty.fansunitedapi.com/v1"},a={profile:"http://localhost:8010/v1",football:"http://locahost:8080/v1",idMapping:"http://localhost:8030/v1",predictor:"http://localhost:8040/v1",client:"http://localhost:8070/v1",loyalty:"http://localhost:8060/v1"},c={profile:"https://profile.fansunitedstagingapi.com/v1",football:"https://football.fansunitedstagingapi.com/v1",idMapping:"https://id-mapping.fansunitedstagingapi.com/v1",predictor:"https://prediction.fansunitedstagingapi.com/v1",client:"https://client.fansunitedstagingapi.com/v1",loyalty:"https://loyalty.fansunitedstagingapi.com/v1"};return s==="prod"?r=n[e]:s==="dev"?r=a[e]:r=c[e],r},$t=s=>s.filter((r,n,a)=>n===a.indexOf(r)),qn=s=>Array.isArray(s)?s.map(e=>qn(e)):s!=null&&s.constructor===Object?Object.keys(s).reduce((e,r)=>({...e,[(0,Gm.camelCase)(r)]:qn(s[r])}),{}):s;var kn=class{id=null;name=null;avatar=null;gender=null;country=null;birthDate=null;interests=[];followingCount=0;followersCount=0};var Wn=class{profilesFromResponse=e=>e?e.map(r=>this.fullProfileFromResponse(r)):null;fullProfileFromResponse=e=>{let r=new kn;return r.id=e.id,r.name=e.name,r.avatar=e.avatar,r.gender=e.gender,r.country=e.country,r.birthDate=e.birth_date,r.interests=e.interests,r.followingCount=e.following_count,r.followersCount=e.followers_count,r}};var Kn=class{nextPageStartsAfter=null;itemsPerPage=null};var Tr=class{pagination=new Kn};var ie=class{meta=new Tr;data=[]};var Xn=class{avatar=null;followingId=null;name=null;profileId=null};var Yn=class{followResponse=e=>e.map(r=>this.remapResponse(r));followingFromResponse=e=>{let r=new ie;return r.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,r.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,r.data=e.data.map(n=>this.remapResponse(n)),r};remapResponse=e=>{let r=new Xn;return r.avatar=e.avatar,r.followingId=e.following_id,r.name=e.name,r.profileId=e.profile_id,r}};var zn=class{avatar=null;followerId=null;name=null;profileId=null};var Jn=class{followersFromResponse=e=>{let r=new ie;return r.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,r.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,r.data=e.data.map(n=>this.remapResponse(n)),r};remapResponse=e=>{let r=new zn;return r.avatar=e.avatar,r.followerId=e.follower_id,r.name=e.name,r.profileId=e.profile_id,r}};var Si=class{profile_ids=[]};var kv="/countries",Je="/profile",$m="/profiles",Qn=class{instanceAuth=null;instance=null;apiSignInUrl=null;profileRemapper=null;followingRemapper=null;followersRemapper=null;lang=null;constructor(e){this.lang=e.lang;let r=Ee(e.environment,"profile");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instanceAuth=Xl.default.create({baseURL:r,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instanceAuth.interceptors.request.use(n=>n,n=>{Promise.reject(n)}),this.instanceAuth.interceptors.response.use(n=>n,n=>{let a=n.config;if((n.response.status===403||n.response.status===401)&&!a._retry){a._retry=!0;let c=e.authProvider.getIdToken();return a.headers.Authorization=`Bearer ${c}`,this.instanceAuth(a)}return Promise.reject(n)}),this.instance=Xl.default.create({baseURL:r,headers:{"Content-Type":"application/json"}}),this.profileRemapper=new Wn,this.followingRemapper=new Yn,this.followersRemapper=new Jn}getCountries=async e=>{try{let r=`&lang=${this.lang}`,n=`${kv}${this.apiSignInUrl}${r}`,a=Date.now();return e&&(n+=`&disable_cache=${a}`),(await this.instance.get(n)).data.data}catch(r){throw console.warn("There was a problem fetching the countries:",r),r.response}};getProfile=async e=>{let r=`${Je}${this.apiSignInUrl}`;if(e){r=`${$m}/${e}${this.apiSignInUrl}`;try{let n=await this.instance.get(r);return this.profileRemapper.fullProfileFromResponse(n.data.data)}catch(n){throw console.warn(`There was a problem fetching the following profile: ${e}`,n),n.response}}else try{let n=await this.instanceAuth.get(r);return this.profileRemapper.fullProfileFromResponse(n.data.data)}catch(n){throw console.warn("There was a problem fetching your profile from API:",n),n.response}};getProfiles=async(e,r)=>{try{let n=`${$m}${this.apiSignInUrl}&profile_ids=${e.join(",")}`,a=Date.now();r&&(n+=`&disable_cache=${a}`);let c=await this.instance.get(n);return this.profileRemapper.profilesFromResponse(c.data.data)}catch(n){throw console.warn(`There was a problem fetching the following profiles: ${e.join(",")}`,n),n.response}};getFollowers=async(e,r)=>{let n=`${Je}/followers${this.apiSignInUrl}`;if(e&&!r){n=`${Je}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let a=await this.instanceAuth.get(n);return this.followersRemapper.followersFromResponse(a.data)}catch(a){throw console.warn("There was a problem fetching the followers for own profile",a),a.response}}else if(!e&&!r)try{let a=await this.instanceAuth.get(n);return this.followersRemapper.followersFromResponse(a.data)}catch(a){throw console.warn("There was a problem fetching the followers for own profile",a),a.response}e&&r?n=`${Je}/${r}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&r&&(n=`${Je}/${r}/followers${this.apiSignInUrl}`);try{let a=await this.instance.get(n);return this.followersRemapper.followersFromResponse(a.data)}catch(a){throw console.warn(`There was a problem fetching the followers for profile: ${r}`,a),a.response}};getFollowing=async(e,r)=>{let n=`${Je}/following${this.apiSignInUrl}`;if(e&&!r){n=`${Je}/following${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let a=await this.instanceAuth.get(n);return this.followingRemapper.followingFromResponse(a.data)}catch(a){throw console.warn("There was a problem fetching the followers of own profile",a),a.response}}else if(!e&&!r)try{let a=await this.instanceAuth.get(n);return this.followingRemapper.followingFromResponse(a.data)}catch(a){throw console.warn("There was a problem fetching the followers of own profile",a),a.response}e&&r?n=`${Je}/${r}/following${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&r&&(n=`${Je}/${r}/following${this.apiSignInUrl}`);try{let a=await this.instance.get(n);return this.followingRemapper.followingFromResponse(a.data)}catch(a){throw console.warn(`There was a problem fetching the followers of the following profile: ${r}`,a),a.response}};follow=async e=>{let r=new Si;r.profile_ids=e;try{let n=await this.instanceAuth.post(`${Je}/follow${this.apiSignInUrl}`,JSON.stringify(r));return this.followingRemapper.followResponse(n.data.data)}catch(n){throw console.warn(`There was a problem with POST request for profiles: ${e.join(",")} `,n),n.response}};unfollow=async e=>{let r=new Si;r.profile_ids=e;try{return await this.instanceAuth.delete(`${Je}/follow${this.apiSignInUrl}`,{data:JSON.stringify(r)}),!0}catch(n){throw console.warn(`There was a problem with DELETE request for profiles: ${e.join(",")} `,n),n.response}};updateProfile=async e=>{try{let r=await this.instanceAuth.patch(`${Je}${this.apiSignInUrl}`,e);return this.profileRemapper.fullProfileFromResponse(r.data.data)}catch(r){throw console.warn("There was a problem updating the own profile:",r),r.response}}};var Rt={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id"};var Hm="FansUnited",Vm={football:{ids:[],countries:[],competitions:[]},profile:{own:{},countries:[],expireAt:0}},Ht=class{idSchema="";expirationTimeout=600;constructor(e){this.idSchema=e.idSchema,(this.getData()===void 0||this.getData()===null)&&this.setData(Vm)}clearData=()=>{this.setData(Vm)};getEntityById=(e="",r="")=>this.getData().football.ids.find(n=>{let a=Rt[this.idSchema];return n&&`${n[a]}`===r&&n.resource===e});getEntity=(e,r,n)=>Array.isArray(e)?this.getData().football.ids.filter(a=>{let c=Rt[n];return a&&e.includes(`${a[c]}`)&&a.resource===r}):this.getData().football.ids.find(a=>{let c=Rt[n];return a&&`${a[c]}`===e&&a.resource===r});getEntityByNativeId=(e="",r="")=>this.getData().football.ids.find(n=>n&&`${n.id}`===r&&n.resource===e);checkForExistingIdObjs=(e,r)=>{let n=Rt[r],a={};return Object.keys(e).forEach(c=>{let f=e[c],v=this.getEntity(f,c,r).map(M=>M[n]),S=e[c].filter(M=>!v.includes(M));a[c]=f.map(M=>S.includes(M)?{id:M,exists:!1}:{id:M,exists:!0})}),a};getIdsByType=(e,r,n)=>{let a=Rt[n],c=Rt[r],f={};return Object.keys(e).forEach(g=>{let v=e[g],S=[];this.getData().football.ids.forEach(M=>{v.forEach((F,Y)=>{F===M[c]&&g===M.resource&&(S[Y]=M[a])})}),f[g]=S}),f};addIdMapping=e=>{let r=this.getData();r.football.ids.push(e),this.setData(r)};addIdMappings=e=>{let r=this.getData(),n=r.football.ids;n=[...n,...e],r.football.ids=n,this.setData(r)};setOwnProfile=e=>{let r=this.getData();r.profile.own=e,r.profile.expireAt=Math.floor(Date.now()/1e3)+this.expirationTimeout,this.setData(r)};getOwnProfile=()=>this.getData().profile.own;getProfileCountries=()=>this.getData().profile.countries;setProfileCountries=e=>{let r=this.getData();r.profile.countries=e,this.setData(r)};getFootballCountries=()=>this.getData().football.countries;setFootballCountries=e=>{let r=this.getData();r.football.countries=e,this.setData(r)};getCompetitions=e=>{let r=this.getData();return e?e.competitionSearchFilter(r.football.competitions):r.football.competitions};setCompetitions=e=>{let r=this.getData();r.football.competitions.push(...e),this.setData(r)};getExpirationProfile=()=>this.getData().profile.expireAt;getData=()=>JSON.parse(localStorage.getItem(Hm));setData=e=>{localStorage.setItem(Hm,JSON.stringify(e))}};var qm=Dt(Gt());var Ti={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},Zn=class{instance=null;apiSignInUrl="";constructor(e){let r=Ee(e.environment,"idMapping");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instance=qm.default.create({baseURL:r})}getEntityById=(e,r)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${config.idSchema}&${Ti[e]}=${r}`)}catch(n){throw console.warn(`There was a problem with id mapping request for the following id:${r}`,n),n.response}};getEntityByIdAndSchema=(e,r,n)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${Ti[e]}=${r}`)}catch(a){throw console.warn(`There was a problem with id mapping request for the following id:${r}`,a),a.response}};getEntityIdsByIdsAndSchema=(e,r,n)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${Ti[e]}=${r.join(",")}`)}catch(a){throw console.warn(`There was a problem with id mapping request for the following ids:${r.join(",")}`,a),a.response}};getEntitiesByIds=(e,r,n)=>{r.sort((f,g)=>f.localeCompare(g));let c=Kl(r).map(f=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${Ti[e]}=${f.join(",")}`)}catch(g){throw console.warn(`There was a problem with id mapping request for the following ids:${f.join(",")}`,g),g.response}});return Promise.all(c).then(f=>{let g=[];return f.forEach(v=>{g.push(...v.data.data)}),g})};getEntitiesByIdObjs=async(e,r)=>{let n=[],a={},c=[];Object.keys(e).forEach(S=>{n.push.apply(n,e[S])});let f=$t(n),g=Kl(f);for(let S of g){let M="";if(Object.keys(e).forEach(F=>{a[F]=[];let Y=S.filter(ve=>e[F].includes(ve));Y&&Y.length>0&&(a[F]=Y)}),Object.keys(a).forEach(F=>{a[F].length>0&&(a[F].sort((Y,ve)=>Y.localeCompare(ve)),M+="&",M+=`${Ti[F]}=${a[F].join(",")}`)}),M&&M.length>0)try{let F=await this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r||"native"}${M}`);c.push(F.data.data)}catch(F){throw console.warn("There was a problem with id mapping request",F),F.response}else c.push([])}return Array.prototype.concat.apply([],c)}};var jn=class{isBrowser=!1;localStorage=null;https=null;constructor(e){this.isBrowser=typeof window!="undefined",this.localStorage=new Ht(e),this.https=new Zn(e)}getEntitiesByIds=async(e,r,n)=>{if(this.isBrowser)try{let a=this.localStorage.checkForExistingIdObjs(e,r),c=this.splitForRequestAndExisting(a),f=await this.https.getEntitiesByIdObjs(c.request,r);return this.localStorage.addIdMappings(f),this.localStorage.getIdsByType(e,r,n)}catch(a){return console.warn("There was a problem retrieving the entity ids ",a),Promise.resolve([])}else try{let a=await this.https.getEntitiesByIdObjs(e,r);return Object.keys(e).forEach(c=>{e[c]=a.filter(f=>f.resource===c).map(f=>f[Rt[n]])}),e}catch(a){return console.warn("There was a problem retrieving the entity ids ",a),Promise.resolve([])}};getEntityById=async(e,r,n)=>{if(this.isBrowser){let a=this.localStorage.getEntity(e,r,n);if(a)return a;{let c=await this.requestEntity(e,r,n);return this.localStorage.addIdMappings(c),c}}else return await this.requestEntity(e,r,n)};splitForRequestAndExisting=e=>{let r={},n={};return Object.keys(e).forEach(a=>{r[a]=e[a].filter(c=>!c.exists).map(c=>c.id),n[a]=e[a].filter(c=>c.exists).map(c=>c.id)}),{existing:n,request:r}};requestEntity=async(e,r,n)=>{try{return e=Array.isArray(e)?e:[e],await this.https.getEntitiesByIds(r,e,n)}catch(a){return console.warn(`There was a problem retrieving the requested entity: ${a}`),null}}};var eo=s=>{switch(s){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 s}};var to=class{extractedObjIds={};traverse=(e,r)=>(r=eo(r),Array.isArray(e)?this.traverseArrExtract(e,r):e&&typeof e=="object"&&this.traverseObjExtract(e,r),this.extractedObjIds);traverseArrExtract=(e,r)=>{e&&e.length>0&&e.forEach(n=>{this.traverseObjExtract(n,r)})};traverseObjExtract=(e,r)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(n=>{let a=e[n];n==="id"||n==="teamId"?(this.extractedObjIds.hasOwnProperty(r)||(this.extractedObjIds[r]=[]),this.extractedObjIds[r].push(a)):e[n]&&this.traverse(e[n],n)})}};var ro=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(e,r,n)=>(r=eo(r),this.replaceObjIdsIndex===null&&(this.initReplaceObjIdsIndex(n),this.remappedIdsObj=n),Array.isArray(e)?this.traverseArrReplace(e,r):e&&typeof e=="object"&&this.traverseObjReplace(e,r),e);initReplaceObjIdsIndex=e=>{this.replaceObjIdsIndex={},Object.keys(e).forEach(r=>{this.replaceObjIdsIndex[r]=0})};traverseArrReplace=(e,r)=>{e&&e.length>0&&e.forEach(n=>{this.traverseObjReplace(n,r)})};traverseObjReplace=(e,r)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(n=>{n==="id"||n==="teamId"?(e[n]=this.remappedIdsObj[r][this.replaceObjIdsIndex[r]],this.replaceObjIdsIndex[r]=this.replaceObjIdsIndex[r]+1):e[n]&&this.traverse(e[n],n,this.remappedIdsObj)})}};var he=class{idSchema="";idMappingFacade=null;constructor(e){this.idSchema=e.idSchema,this.idMappingFacade=new jn(e)}getEntityIdBySchemaId=(e,r)=>this.idMappingFacade.getEntityById(e,r,this.idSchema);remapEntities=async(e,r)=>{let n=JSON.parse(JSON.stringify(e));try{if(this.idSchema!=="native"){let c=new to().traverse(n,r);return this.idMappingFacade.getEntitiesByIds(c,"native",this.idSchema).then(f=>new ro().traverse(n,r,f))}else return e}catch(a){return console.warn(`There was a problem remapping entity: ${r} with inner entity `,a),[]}};getEntityIdsBySchemaId=async(e,r,n)=>{let a={};return a[r]=e,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(a,this.idSchema,n):a}};var De=class{completed=!1;percentage;constructor(e){this.percentage=e}};var io=class{teamFollowed=new De(10);teamFavourite=new De(15);playerFollowed=new De(10);playerFavourite=new De(10);competitionFollowed=new De(10);competitionFavourite=new De(5);addedBirthdate=new De(10);addedGender=new De(10);addedCountry=new De(10);addedAvatar=new De(10)};var no=class{totalPercentage;breakdown=new io};var Ei=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 qt=class{isBrowser=!1;localStorage={};https=null;constructor(e,r){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.https=r}getOwn=async()=>{if(this.isBrowser){let e=Math.floor(Date.now()/1e3),r=this.localStorage.getExpirationProfile(),n=null;if(r>e&&(n=this.localStorage.getOwnProfile()),n)return JSON.parse(JSON.stringify(n));try{let a=await this.https.getProfile();return this.localStorage.setOwnProfile(a),a}catch(a){throw console.warn("There was a problem retrieving your profile: ",a),a}}else try{return await this.https.getProfile()}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};getByIds=async(e,r)=>{try{return r=r||!1,await this.https.getProfiles(e,r)}catch(n){throw console.warn(`There was a problem retrieving the selected profiles: ${e.join(",")} `,n),n}};getById=async e=>{try{return await this.https.getProfile(e)}catch(r){throw console.warn(`There was a problem retrieving the selected profile: ${e} `,r),r}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let r=this.localStorage.getProfileCountries();if(r&&r.length>0)return r;try{let n=await this.https.getCountries(e);return this.localStorage.setProfileCountries(n),n}catch(n){throw console.warn("There was a problem retrieving profile countries: ",n),n}}else try{return await this.https.getCountries(e)}catch(r){throw console.warn("There was a problem retrieving profile countries: ",r),r}};getFollowers=async(e,r)=>{try{return e&&(e=new Ei(e)),await this.https.getFollowers(e,r)}catch(n){throw console.warn("There was a problem retrieving your followers: ",n),n}};getFollowing=async(e,r)=>{try{return e&&(e=new Ei(e)),await this.https.getFollowing(e,r)}catch(n){throw console.warn("There was a problem retrieving your following profiles: ",n),n}};follow=async e=>{try{return await this.https.follow(e)}catch(r){throw console.warn(`There was a problem following profiles: ${e.join(",")} `,r),r}};unfollow=async e=>{try{return await this.https.unfollow(e)}catch(r){throw console.warn(`There was a problem unfollowing profiles: ${e.join(",")} `,r),r}};showFullnessProfile=e=>{let r=new no,n=0;return e.avatar&&(r.breakdown.addedAvatar.completed=!0,n+=r.breakdown.addedAvatar.percentage),e.birthDate&&(r.breakdown.addedBirthdate.completed=!0,n+=r.breakdown.addedBirthdate.percentage),e.country&&(r.breakdown.addedCountry.completed=!0,n+=r.breakdown.addedCountry.percentage),e.gender&&(r.breakdown.addedGender.completed=!0,n+=r.breakdown.addedGender.percentage),e.interests&&e.interests.length>0&&(e.interests.find(M=>M.type==="team"&&M.favourite)&&(r.breakdown.teamFavourite.completed=!0,n+=r.breakdown.teamFavourite.percentage),e.interests.find(M=>M.type==="team")&&(r.breakdown.teamFollowed.completed=!0,n+=r.breakdown.teamFollowed.percentage),e.interests.find(M=>M.type==="player"&&M.favourite)&&(r.breakdown.playerFavourite.completed=!0,n+=r.breakdown.playerFavourite.percentage),e.interests.find(M=>M.type==="player")&&(r.breakdown.playerFollowed.completed=!0,n+=r.breakdown.playerFollowed.percentage),e.interests.find(M=>M.type==="competition"&&M.favourite)&&(r.breakdown.competitionFavourite.completed=!0,n+=r.breakdown.competitionFavourite.percentage),e.interests.find(M=>M.type==="competition")&&(r.breakdown.competitionFollowed.completed=!0,n+=r.breakdown.competitionFollowed.percentage)),r.totalPercentage=n,r}};var oo=class{id=null;name=null;assets=null};var ao=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,r,n){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=n,this.https=r}getCountriesWithIdMapping=async e=>{try{let r=await this.getCountries(e);return this.idMapping.remapEntities(r,"country")}catch(r){throw console.warn("There was a problem browsing countries as football entities",r),r}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let r=this.localStorage.getFootballCountries();if(r&&r.length>0)return r;try{let n=await this.https.getCountries(e);return this.localStorage.setFootballCountries(n),n}catch(n){throw console.warn("There was a problem retrieving countries as football entities",n),n}}else return this.https.getCountries(e)}};var so=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 r=this.filter(e);return this.sortField||this.sortOrder?this.sort(r):r}catch(r){return console.warn("There was a problem filtering the local competitions",r),[]}};filter=e=>{let r=this.entitiesToSearchWith();return e.filter(n=>{let a=!0;return r.forEach(c=>{c!=="sortOrder"&&c!=="sortField"&&(c==="countryId"?a&&=n.country.id===this[c]:c==="name"?a&&=n.name.toLocaleLowerCase().includes(this[c].toLocaleLowerCase()):c==="competitionIds"?a&&=this[c].some(f=>n.id===f):a&&=n[c].toLocaleLowerCase()===this[c].toLocaleLowerCase())}),a})};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 r=[];return this.sortField==="name"?r=e.sort((n,a)=>this.sortOrder&&this.sortOrder==="desc"?a.name.localeCompare(n.name):n.name.localeCompare(a.name)):this.sortField==="countryId"?r=e.sort((n,a)=>this.sortOrder&&this.sortOrder==="desc"?a.country.id.localeCompare(n.country.id):n.country.id.localeCompare(a.country.id)):this.sortField==="scope"?e.forEach(n=>r[this.competitionIds.indexOf(n.id)]=n):!this.sortField&&this.sortOrder==="desc"&&(r=e.sort((n,a)=>a.id.localeCompare(n.id))),r}};var lo=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,r,n){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=n,this.https=r}getCompetitionsIdMapping=async(e,r)=>{try{let n=!1;if(e){if(e=new so(e),e.countryId){let c=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");c.country.length===0&&(n=!0),e.countryId=c.country[0]}if(e.competitionIds){let c=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");c.competition.length===0&&(n=!0),e.competitionIds=c.competition}if(n)return[]}let a=await this.getCompetitions(e,r);return await this.idMapping.remapEntities(a,"competition")}catch(n){throw console.warn("There was a problem browsing all of the competitions",n),n}};getCompetitions=async(e,r)=>{if(r=r||!1,this.isBrowser){let n=this.localStorage.getCompetitions(e);if(n&&n.length>0)return n;try{let a=await this.https.getCompetitions(e,r);return this.localStorage.setCompetitions(a),this.localStorage.getCompetitions(e)}catch(a){throw console.warn("There was a problem retrieving all competitions",a),a}}else return this.https.getCompetitions(e,r)};getCompetitionByIdIdMapping=async(e,r)=>{try{let a=(await this.idMapping.getEntityIdsBySchemaId([e],"competition","native")).competition[0],c=await this.getCompetitionById(a,r);return await this.idMapping.remapEntities(c,"competition")}catch(n){throw console.warn(`There was a problem browsing the following competition:${e}`,n),n}};getCompetitionById=async(e,r)=>{try{return r=r||!1,await this.https.getCompetitionById(e,r)}catch(n){throw console.warn(`There was a problem retrieving the competition with the following id: ${e}`,n),n}};getTopCompetitionsIdMapping=async e=>{try{let r=await this.getTopCompetitions(e);return await this.idMapping.remapEntities(r,"competition")}catch(r){throw console.warn("There was a problem browsing the top competitions",r),r}};getTopCompetitions=async e=>{try{return e=e||!1,await this.https.getTopCompetitions(e)}catch(r){throw console.warn("There was a problem retrieving the top competitions",r),r}}};var po=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 co=class{https=null;idMapping=null;constructor(e,r){this.idMapping=r,this.https=e}getTeamsIdMapping=async(e,r)=>{try{let n=!1;if(e){if(e=new po(e),e.countryId){let c=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");c.country.length===0&&(n=!0),e.countryId=c.country[0]}if(e.scope){let c=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");c.competition.length===0&&(n=!0),e.scope=c.competition}if(e.teamIds){let c=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");c.team.length===0&&(n=!0),e.teamIds=c.team}}if(n)return[];let a=await this.getTeams(e,r);return a.data=await this.idMapping.remapEntities(a.data,"team"),a}catch(n){throw console.warn("There was a problem browsing all teams",n),n}};getTeams=async(e,r)=>{try{return r=r||!1,await this.https.getTeams(e,r)}catch(n){throw console.warn("There was a problem retrieving all teams",n),n}};getTeamByIdIdMapping=async(e,r)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let a=await this.getTeamById(e,r);return await this.idMapping.remapEntities(a,"team")}catch(n){throw console.warn(`There was a problem browsing the following team:${e}`,n),n}};getTeamById=async(e,r)=>{try{return r=r||!1,await this.https.getTeamById(e,r)}catch(n){throw console.warn(`There was a problem retrieving the following team: ${e}`,n),n}};getTopTeamsIdMapping=async e=>{try{let r=await this.getTopTeams(e);return await this.idMapping.remapEntities(r,"team")}catch(r){throw console.warn("There was a problem browsing the top teams",r),r}};getTopTeams=async e=>{try{return e=e||!1,await this.https.getTopTeams(e)}catch(r){throw console.warn("There was a problem retrieving the top teams",r),r}};getNextMatchForTeamIdMapping=async(e,r)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let a=await this.getNextMatchForTeam(e,r);return await this.idMapping.remapEntities(a,"match")}catch(n){throw console.warn(`There was a problem browsing the next match for the following team:${e}`,n),n}};getNextMatchForTeam=async(e,r)=>{try{return r=r||!1,await this.https.getNextMatchForTeam(e,r)}catch(n){throw console.warn(`There was a problem retrieving the next match for the following team: ${e}`,n),n}};getPrevMatchForTeamIdMapping=async(e,r)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let a=await this.getPrevMatchForTeam(e,r);return await this.idMapping.remapEntities(a,"match")}catch(n){throw console.warn(`There was a problem browsing the previous match for the following team:${e}`,n),n}};getPrevMatchForTeam=async(e,r)=>{try{return r=r||!1,await this.https.getPrevMatchForTeam(e,r)}catch(n){throw console.warn(`There was a problem retrieving the previous match for the following team: ${e}`,n),n}}};var Ci=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 kt=class{https=null;idMapping=null;constructor(e,r){this.idMapping=r,this.https=e}getPlayersIdMapping=async(e,r)=>{try{let n=!1;if(e){if(e=new Ci(e),e.countryId){let c=await this.idMapping.getEntityIdsBySchemaId([e.countryId],"country","native");c.country.length===0&&(n=!0),e.countryId=c.country[0]}if(e.playerIds){let c=await this.idMapping.getEntityIdsBySchemaId(e.playerIds,"player","native");c.player.length===0&&(n=!0),e.playerIds=c.player}if(e.scope){let c=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");c.competition.length===0&&(n=!0),e.scope=c.competition}if(n)return[]}let a=await this.getPlayers(e,r);return a.data=await this.idMapping.remapEntities(a.data,"player"),a}catch(n){throw console.warn("There was a problem browsing the players",n),n}};getPlayersWithNativeIds=async e=>{let r=new Ci({playerIds:e}),n=await this.getPlayers(r);return n.data.sort((a,c)=>a.id.localeCompare(c.id)),await this.idMapping.remapEntities(n.data,"player")};getPlayersMapWithNativeIds=async e=>{let r={},n=$t(e);n.sort((c,f)=>c.localeCompare(f));let a=await this.getPlayersWithNativeIds(n);return n.forEach((c,f)=>r[c]=a[f]),r};getPlayers=async(e,r)=>{try{return r=r||!1,await this.https.getPlayers(e,r)}catch(n){throw console.warn("There was a problem retrieving the players",n),n}};getPlayerIdMapping=async(e,r)=>{try{let n=await this.idMapping.getEntityIdsBySchemaId([e],"player","native"),a=await this.getPlayerById(n.player[0],r);return await this.idMapping.remapEntities(a,"player")}catch(n){throw console.warn(`There was a problem browsing the following player:${e}`,n),n}};getPlayerById=async(e,r)=>{try{return r=r||!1,await this.https.getPlayerById(e,r)}catch(n){throw console.warn(`There was a problem retrieving the following player: ${e}`,n),n}};getTopPlayersIdMapping=async e=>{try{let r=await this.getTopPlayers(e);return await this.idMapping.remapEntities(r,"player")}catch(r){throw console.warn("There was a problem browsing the top players",r),r}};getTopPlayers=async e=>{try{return e=e||!1,await this.https.getTopPlayers(e)}catch(r){throw console.warn("There was a problem retrieving the top players",r),r}};getNextMatchForPlayerIdMapping=async(e,r)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let a=await this.getNextMatchForPlayer(e,r);return await this.idMapping.remapEntities(a,"match")}catch(n){throw console.warn(`There was a problem browsing the next match for player:${e}`,n),n}};getNextMatchForPlayer=async(e,r)=>{try{return r=r||!1,await this.https.getNextMatchForPlayer(e,r)}catch(n){throw console.warn(`There was a problem retrieving the next match for player: ${e}`,n),n}};getPrevMatchForPlayerIdMapping=async(e,r)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let a=await this.getPrevMatchForPlayer(e,r);return await this.idMapping.remapEntities(a,"match")}catch(n){throw console.warn(`There was a problem browsing the previous match for player:${e}`,n),n}};getPrevMatchForPlayer=async(e,r)=>{try{return r=r||!1,await this.https.getPrevMatchForPlayer(e,r)}catch(n){throw console.warn(`There was a problem retrieving the previous match for player: ${e}`,n),n}}};var Ai=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 Wt=class{https=null;idMapping=null;constructor(e,r){this.https=e,this.idMapping=r}getMatchesIdMapping=async(e,r)=>{try{if(e){if(e=new Ai(e),e.countryIds){let a=await this.idMapping.getEntityIdsBySchemaId(e.countryIds,"country","native");e.countryIds=a.country}if(e.competitionIds){let a=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");e.competitionIds=a.competition}if(e.matchIds){let a=await this.idMapping.getEntityIdsBySchemaId(e.matchIds,"match","native");e.matchIds=a.match}if(e.teamIds){let a=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");e.teamIds=a.team}}let n=await this.getMatches(e,r);return n.data=await this.idMapping.remapEntities(n.data,"match"),n}catch(n){throw console.warn("There was a problem browsing the matches",n),n}};getMatchesWithNativeIds=async e=>{let r=e.length,n=new Ai({matchIds:e,limit:r}),a=await this.getMatches(n);return a.data.sort((c,f)=>c.id.localeCompare(f.id)),await this.idMapping.remapEntities(a.data,"match")};getMatchesMapWithNativeIds=async e=>{let r={},n=$t(e);n.sort((c,f)=>c.localeCompare(f));let a=await this.getMatchesWithNativeIds(n);return n.forEach((c,f)=>r[c]=a[f]),r};getMatches=async(e,r)=>{try{return r=r||!1,await this.https.getMatches(e,r)}catch(n){throw console.warn("There was a problem retrieving the matches",n),n}};getMatchIdMapping=async(e,r)=>{try{let n=await this.idMapping.getEntityIdsBySchemaId([e],"match","native"),a=await this.getMatchById(n.match[0],r);return await this.idMapping.remapEntities(a,"match")}catch(n){throw console.warn(`There was a problem browsing the following match: ${e}`,n),n}};getMatchById=async(e,r)=>{try{return r=r||!1,await this.https.getMatchById(e,r)}catch(n){throw console.warn(`There was a problem retrieving the following match: ${e}`,n),n}}};var uo=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 mo=class{https=null;idMapping=null;constructor(e,r){this.https=e,this.idMapping=r}searchIdMapping=async(e,r)=>{try{if(e=new uo(e),e.scope){let a=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");e.scope=a.competition}let n=await this.search(e,r);if(n.teams&&n.teams.length>0){let a=await this.idMapping.remapEntities(n.teams,"team");n.teams=a}if(n.players&&n.players.length>0){let a=await this.idMapping.remapEntities(n.players,"player");n.players=a}if(n.competitions&&n.competitions.length>0){let a=await this.idMapping.remapEntities(n.competitions,"competition");n.competitions=a}return n}catch(n){throw console.warn("There was a problem with browsing the search result",n),n}};search=async(e,r)=>{try{return await this.https.search(e,r)}catch(n){throw console.warn("There was a problem retrieving the search response",n),n}}};var Kt=class{isBrowser=!1;localStorage={};https=null;idMapping=null;countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(e,r,n){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=n,this.https=r,this.countriesFacade=new ao(e,r,n),this.competitionsFacade=new lo(e,r,n),this.teamsFacade=new co(r,n),this.playerFacade=new kt(r,n),this.matchFacade=new Wt(r,n),this.searchFacade=new mo(r,n)}getCountries=async e=>this.countriesFacade.getCountriesWithIdMapping(e);getCompetitions=async(e,r)=>this.competitionsFacade.getCompetitionsIdMapping(e,r);getCompetitionById=async(e,r)=>this.competitionsFacade.getCompetitionByIdIdMapping(e,r);getTopCompetitions=async e=>this.competitionsFacade.getTopCompetitionsIdMapping(e);getTeams=async(e,r)=>this.teamsFacade.getTeamsIdMapping(e,r);getTeamById=async(e,r)=>this.teamsFacade.getTeamByIdIdMapping(e,r);getTopTeams=async e=>this.teamsFacade.getTopTeamsIdMapping(e);getNextMatchForTeam=async(e,r)=>this.teamsFacade.getNextMatchForTeamIdMapping(e,r);getPrevMatchForTeam=async(e,r)=>this.teamsFacade.getPrevMatchForTeamIdMapping(e,r);getPlayers=async(e,r)=>this.playerFacade.getPlayersIdMapping(e,r);getPlayerById=async(e,r)=>this.playerFacade.getPlayerIdMapping(e,r);getTopPlayers=async e=>this.playerFacade.getTopPlayersIdMapping(e);getNextMatchForPlayer=async(e,r)=>this.playerFacade.getNextMatchForPlayerIdMapping(e,r);getPrevMatchForPlayer=async(e,r)=>this.playerFacade.getPrevMatchForPlayerIdMapping(e,r);getMatches=async(e,r)=>this.matchFacade.getMatchesIdMapping(e,r);getMatchById=async(e,r)=>this.matchFacade.getMatchIdMapping(e,r);search=async(e,r)=>this.searchFacade.searchIdMapping(e,r)};var Er=class{idMapping=null;footballFacade=null;constructor(e,r){this.idMapping=e,this.footballFacade=r}remapInterestsToIdSchema=async e=>{let r=this.idMapping.idSchema;if(r!=="native")if(e&&e.length>0){let n={},a={};e.forEach(g=>{n.hasOwnProperty(g.type)||(n[g.type]=[],a[g.type]=[]),n[g.type].push(g.id),a[g.type].push(g)});let c=await this.idMapping.idMappingFacade.getEntitiesByIds(n,"native",r),f=[];for(let[g,v]of Object.entries(a))v.forEach((S,M)=>{S.id=c[g][M],f.push(S)});return f}else return e;return e};remapInterestToNative=async e=>{let r=this.idMapping.idSchema;if(r!=="native"){let n={},{id:a,type:c}=e;n[c]=[a];let f=await this.idMapping.idMappingFacade.getEntitiesByIds(n,r,"native");return e.id=f[c][0],e}return e};inquiryCustomInterests=async e=>{let r=[];if(e&&e.length>0&&(r=e.filter(n=>n.source==="custom")),r&&r.length>0){let n=e.filter(c=>c.source!=="custom"),a=await this.remapInterestsToIdSchema(n);return r.forEach(c=>a.push(c)),a}return await this.remapInterestsToIdSchema(e)};showFullInterests=async e=>{let r=[];if(e&&e.length>0)for(let n of e)if(n.source!=="custom"&&n.source==="football"){let a={};if(n.type==="team"){a.teamIds=[n.id];let c=await this.footballFacade.getTeams(a);n.model=c.data[0]}if(n.type==="player"){a.playerIds=[n.id];let c=await this.footballFacade.getPlayers(a);n.model=c.data[0]}if(n.type==="competition"){a.competitionIds=[n.id];let c=await this.footballFacade.getCompetitions(a);n.model=c[0]}n.model===void 0&&(n.model=null),r.push(n)}else r.push(n);return r};updateInterests=(e,r)=>{if(e&&r&&e.length===r.length){let n=r.filter(c=>e.some(f=>c.id===f.id&&c.type===f.type&&c.source===f.source&&c.favourite===f.favourite)),a=r.filter(c=>!e.some(f=>c.id===f.id&&c.type===f.type&&c.source===f.source&&c.favourite===f.favourite));return[...n,...a]}else return r}};var fo=class{profileHttps=null;activityHttps=null;footballHttps=null;localStorage=null;idMapping=null;profileFacade=null;footballFacade=null;interestsService=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;constructor(e,r,n,a,c){this.localStorage=e,this.profileHttps=r,this.activityHttps=n,this.footballHttps=c,this.idMapping=a,this.footballFacade=new Kt(e,c,a),this.interestsService=new Er(a,this.footballFacade),this.profileFacade=new qt(e,r)}getOwnProfile=async()=>{for(;this.isFetching;)console.log("Another thread is fetching profile..."),await this.delay(100);if(this.modified&&this.ownProfile)return console.log("Timestamp is less than 10 minutes OR profile is modifying "),this.ownProfile;let e=Math.floor(Date.now()/1e3);if(!this.ownProfile||this.expireAt<e){this.isFetching=!0,this.expireAt=Math.floor(Date.now()/1e3)+600;try{let r=await this.profileFacade.getOwn();this.setOwnProfile(r)}catch{this.isFetching=!1}return this.modified=!1,this.isFetching=!1,this.ownProfile}return this.ownProfile};delay=e=>new Promise(r=>{setTimeout(r,e)});setOwnProfile=e=>{this.ownProfile=e};extractUpdatedProps=(e,r)=>{let n={};return Object.keys(e).forEach(a=>{a==="gender"&&e[a]!==r[a]?n[a]=r[a]:a==="birthDate"?(r[a]===null||e[a]===null&&r[a]||e[a]!==r[a])&&(n.birth_date=r[a]):a==="country"?r[a]===null?n.country_id=r[a]:(e[a]===null&&r[a]||e[a].id!==r[a].id)&&(n.country_id=r[a].id):a==="interests"&&(r[a]&&r[a].length>0?n[a]=this.interestsService.updateInterests(e[a],r[a]):r[a]&&r[a].length===0&&(n[a]=r[a]))}),n};getInfo=async()=>{let e=await this.getOwnProfile(),r=JSON.parse(JSON.stringify(e));return delete r.interests,r};showInterests=async()=>{let e=await this.getOwnProfile(),r=JSON.parse(JSON.stringify(e));return await this.interestsService.inquiryCustomInterests(r.interests)};showFullInterests=async()=>{let e=await this.getOwnProfile(),r=JSON.parse(JSON.stringify(e)),n=await this.interestsService.inquiryCustomInterests(r.interests);return await this.interestsService.showFullInterests(n)};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);getStats=async()=>await this.activityHttps.getStats();addInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let r=null;e.source!=="custom"?r=await this.interestsService.remapInterestToNative(e):r=e;let n=this.ownProfile.interests.filter(a=>a.id!==r.id||a.type!==r.type||a.source!==r.source);return this.ownProfile.interests=[...n],this.ownProfile.interests.push(r),this};addInterest=e=>(this.promises.push(this.addInterestPromise(e)),this);removeInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let r=null;return e.source!=="custom"?r=await this.interestsService.remapInterestToNative(e):r=e,this.ownProfile.interests=this.ownProfile.interests.filter(n=>n.id!==r.id||n.type!==r.type||n.source!==r.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 oo,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(),r=JSON.parse(JSON.stringify(e));return this.profileFacade.showFullnessProfile(r)};update=async()=>{if(this.promises.length===0)return this.ownProfile;await Promise.all(this.promises);let e=await this.profileFacade.getOwn(),r=await this.getOwnProfile(),n=this.extractUpdatedProps(e,r),a=await this.profileHttps.updateProfile(n);return this.modified=!1,this.expireAt=0,this.localStorage.setOwnProfile(a),delete a.interests,a}};var ho=class{profileHttps=null;activityHttps=null;footballFacade=null;localStorage=null;idMapping=null;profileFacade=null;interestsService=null;profileId="";constructor(e,r,n,a,c){this.localStorage=e,this.profileHttps=r,this.activityHttps=n,this.footballFacade=c,this.idMapping=a,this.interestsService=new Er(a,c),this.profileFacade=new qt(e,r)}setId=e=>(this.profileId=e,this);getProfile=async()=>await this.profileFacade.getById(this.profileId);getInfo=async()=>{let e=await this.getProfile();return delete e.interests,e};showInterests=async()=>{let e=await this.getProfile(),r=[];return r=e.interests,await this.interestsService.inquiryCustomInterests(r)};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)};getStats=async()=>await this.activityHttps.getStats(this.profileId)};var km=Dt(Gt());var go=class{id="";alias="";countryCode="";assets=null;name=""};var ne=class{countriesFromResponse=e=>{if(e)return e.map(r=>this.countryFromResponse(r))};countryFromResponse=e=>{try{if(e){let r=new go;return r.id=e.id,r.alias=e.alias,r.assets=e.assets,r.countryCode=e.country_code,r.name=e.name,r}}catch(r){throw r}return null}};var yo=class{id="";country=null;gender="";assets=null;type="";name=""};var Ce=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let r=new yo;return r.id=e.id,r.country=this.countryRemapper.countryFromResponse(e.country),r.gender=e.gender,r.assets=e.assets,r.type=e.type,r.name=e.name,r}catch(r){throw console.warn("There was a problem remapping the competition response",r),r}}};var wo=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var Mo=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName=""};var ge=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let r=new Mo;return r.id=e.id,r.country=this.countryRemapper.countryFromResponse(e.country),r.gender=e.gender,r.assets=e.assets,r.code=e.code,r.national=e.national,r.fullName=e.full_name,r.shortName=e.short_name,r.name=e.name,r}catch(r){throw console.warn("There was a problem remapping teams response",r),r}}};var bo=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new ne,this.teamBasicRemapper=new ge}fromResponse(e){try{let r=new wo;return r.id=e.id,r.country=this.countryRemapper.countryFromResponse(e.country),r.gender=e.gender,r.assets=e.assets,r.type=e.type,r.name=e.name,r.participants=e.participants.map(n=>this.teamBasicRemapper.fromResponse(n)),r}catch(r){throw console.warn("There was a problem remapping the competition response",r),r}}};var vo=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";squad=[]};var _o=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var Io=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let r=new _o;return r.id=e.id,r.startDate=e.start_date,r.endDate=e.end_date,r.shirtNumber=e.shirt_number,r.loan=e.loan,r.position=e.position,r.country=this.countryRemapper.countryFromResponse(e.country),r.name=e.name,r.assets=e.assets,r.birthDate=e.birth_date,r}catch(r){throw console.warn("There was a problem remapping the player from squad",r),r}}};var Po=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new ne,this.competitionRemapper=new Ce,this.playerRemapper=new Io}fromResponse(e){try{let r=new vo;return r.id=e.id,r.country=this.countryRemapper.countryFromResponse(e.country),r.gender=e.gender,r.assets=e.assets,r.code=e.code,r.national=e.national,r.fullName=e.full_name,r.shortName=e.short_name,r.name=e.name,r.competitions=e.competitions?e.competitions.map(n=>this.competitionRemapper.fromResponse(n)):[],r.squad=e.squad?e.squad.map(n=>this.playerRemapper.fromResponse(n)):[],r}catch(r){throw console.warn("There was a problem remapping team response",r),r}}};var Ro=class{id="";kickoffAt="";finishedAt="";updatedAt="";homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;context={competition:null};status={type:null,subType:null}};var Fo=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var Cr=class{fromResponse(e){try{let r=new Fo;return r.ftScore=this.statEntityFromResponse(e.ft_score),r.htScore=this.statEntityFromResponse(e.ht_score),r.aetScore=this.statEntityFromResponse(e.aet_score),r.aggScore=this.statEntityFromResponse(e.agg_score),r.penScore=this.statEntityFromResponse(e.pen_score),r}catch(r){throw console.warn("There was a problem remapping the scores",r),r}}statEntityFromResponse=e=>({homeGoals:e.home_goals,awayGoals:e.away_goals})};var So=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new ge,this.competitionRemapper=new Ce,this.scoresRemapper=new Cr}fromResponse(e){try{let r=new Ro;return r.id=e.id,r.kickoffAt=e.kickoff_at,r.finishedAt=e.finished_at,r.updatedAt=e.updated_at,r.homeTeam=this.teamRemapper.fromResponse(e.home_team),r.awayTeam=this.teamRemapper.fromResponse(e.away_team),r.lineupsConfirmed=e.lineups_confirmed,r.startedAt=e.started_at,r.minute=e.minute,r.scores=this.scoresRemapper.fromResponse(e.scores),r.context={competition:e.context.competition?this.competitionRemapper.fromResponse(e.context.competition):null},r.status={type:e.status.type,subType:e.status.sub_type},r}catch(r){throw console.warn("There was a problem remapping the match response",r),r}}};var To=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 Eo=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 Co=class{fromResponse(e){try{let r=new Eo;return r.corners=this.statEntityFromResponse(e.corners),r.crosses=this.statEntityFromResponse(e.crosses),r.offside=this.statEntityFromResponse(e.offside),r.shotsOn=this.statEntityFromResponse(e.shots_on),r.throwIn=this.statEntityFromResponse(e.throw_in),r.redCards=this.statEntityFromResponse(e.red_cards),r.shotsOff=this.statEntityFromResponse(e.shots_off),r.goalKicks=this.statEntityFromResponse(e.goal_kicks),r.possession=this.statEntityFromResponse(e.possession),r.treatments=this.statEntityFromResponse(e.treatments),r.yellowCards=this.statEntityFromResponse(e.yellow_cards),r.shotsBlocked=this.statEntityFromResponse(e.shots_blocked),r.substitutions=this.statEntityFromResponse(e.substitutions),r.counterAttacks=this.statEntityFromResponse(e.counter_attacks),r.foulsCommitted=this.statEntityFromResponse(e.fouls_committed),r}catch(r){throw console.warn("There was a problem remapping the stats",r),r}}statEntityFromResponse=e=>({homeTeam:e?e.home_team:null,awayTeam:e?e.away_team:null})};var Ar=class{homeTeam={players:[]};awayTeam={players:[]}};var Ao=class{id="";name="";position="";shirtNumber;assets=null;type=""};var xr=class{fromResponse(e){try{let r=new Ao;return r.id=e.id,r.name=e.name,r.position=e.position,r.shirtNumber=e.shirt_number,r.assets=e.assets,r.type=e.type,r}catch(r){throw console.warn("There was a problem remapping the player from timeline",r),r}}};var xo=class{playerRemapper=null;constructor(){this.playerRemapper=new xr}fromResponse(e){try{let r=new Ar;return r.homeTeam.players=e.home_team&&e.home_team.players?e.home_team.players.map(n=>this.playerRemapper.fromResponse(n)):[],r.awayTeam.players=e.away_team&&e.away_team.players?e.away_team.players.map(n=>this.playerRemapper.fromResponse(n)):[],r}catch(r){throw console.warn("There was a problem remapping the lineups",r),r}}};var Oo=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var Lo=class{playerRemapper=null;constructor(){this.playerRemapper=new xr}fromResponse(e){try{let r=new Oo;return r.minute=e.minute,r.type=e.type,r.teamId=e.team_id,r.player=this.playerRemapper.fromResponse(e.player),r.relatedPlayer=e.related_player?this.playerRemapper.fromResponse(e.related_player):null,r.updatedAt=e.updated_at,r}catch(r){throw console.warn("There was a problem remapping timeline",r),r}}};var Bo=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new ge,this.competitionsMapper=new Ce,this.lineupsMapper=new xo,this.scoresMapper=new Cr,this.statsMapper=new Co,this.timelineMapper=new Lo}fromResponse(e){try{let r=new To;return r.id=e.id,r.kickoffAt=e.kickoff_at,r.finishedAt=e.finished_at,r.updatedAt=e.updated_at,r.homeTeam=e.home_team?this.teamMapper.fromResponse(e.home_team):null,r.awayTeam=e.away_team?this.teamMapper.fromResponse(e.away_team):null,r.lineupsConfirmed=e.lineups_confirmed,r.startedAt=e.started_at,r.minute=e.minute,r.scores=this.scoresMapper.fromResponse(e.scores),r.stats=this.statsMapper.fromResponse(e.stats),r.context={competition:this.competitionsMapper.fromResponse(e.context.competition)},r.timeline=e.timeline?e.timeline.map(n=>this.timelineMapper.fromResponse(n)):[],r.status={type:e.status.type,subType:e.status.sub_type},r.lineups=e.lineups?this.lineupsMapper.fromResponse(e.lineups):new Ar,r}catch(r){throw console.warn("There was a problem remapping the match response",r),r}}};var No=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var Uo=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let r=new No;return r.id=e.id,r.firstName=e.first_name?e.first_name:null,r.lastName=e.last_name?e.last_name:null,r.name=e.name?e.name:null,r.birthDate=e.birth_date,r.country=this.countryRemapper.countryFromResponse(e.country),r.assets=e.assets,r.position=e.position,r}catch(r){throw console.warn("There was a problem remapping top player response",r),r}}};var Do=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;teams=[]};var Or=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new ne,this.teamRemapper=new ge}fromResponse(e){try{let r=new Do;return r.id=e.id,r.firstName=e.first_name?e.first_name:null,r.lastName=e.last_name?e.last_name:null,r.name=e.name?e.name:null,r.birthDate=e.birth_date,r.country=this.countryRemapper.countryFromResponse(e.country),r.assets=e.assets,r.teams=e.teams?e.teams.map(n=>this.teamRemapper.fromResponse(n)):[],r.position=e.position,r}catch(r){throw console.warn("There was a problem remapping players response",r),r}}};var Go=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;competitions=[];teams=[]};var $o=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new ne,this.teamRemapper=new ge,this.competitionRemapper=new Ce}fromResponse(e){try{let r=new Go;return r.id=e.id,r.firstName=e.first_name?e.first_name:null,r.lastName=e.last_name?e.last_name:null,r.name=e.name?e.name:null,r.birthDate=e.birth_date,r.country=this.countryRemapper.countryFromResponse(e.country),r.assets=e.assets,r.teams=e.teams?e.teams.map(n=>this.teamRemapper.fromResponse(n)):[],r.position=e.position,r.competitions=e.competitions?e.competitions.map(n=>this.competitionRemapper.fromResponse(n)):[],r}catch(r){throw console.warn("There was a problem remapping player response",r),r}}};var Ho=class{teams=null;players=null;competitions=null};var Vo=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new ge,this.playerRemapper=new Or,this.competitionremapper=new Ce}fromResponse(e){try{let r=new Ho;return r.teams=e.teams?e.teams.map(n=>this.teamRemapper.fromResponse(n)):[],r.players=e.players?e.players.map(n=>this.playerRemapper.fromResponse(n)):[],r.competitions=e.competitions?e.competitions.map(n=>this.competitionremapper.fromResponse(n)):[],r}catch(r){throw console.warn("There was a problem remapping search response",r),r}}};var Lr=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var Br=class{pagination=new Lr};var Nr=class{meta=new Br;data=[]};var qo=class{remapMetaProp=e=>{let r=new Br;return r.pagination.currentPage=e.pagination.current_page,r.pagination.itemsPerPage=e.pagination.items_per_page,r.pagination.totalItems=e.pagination.total_items,r.pagination.numberOfPages=e.pagination.number_of_pages,r}};var mt=class{instance=null;apiSignInUrl="";clientId="";limitIds=200;countryRemapper=null;competitionBasicRemapper=null;competitionFullRemapper=null;teamBasicRemapper=null;teamFullRemapper=null;matchBasicRemapper=null;matchFullRemapper=null;playerBasicRemapper=null;playerFullRemapper=null;topPlayerRemapper=null;searchRemapper=null;footballMetaRemapper=null;constructor(e){this.clientId=e.clientId;let r=Ee(e.environment,"football");this.apiSignInUrl=`?key=${e.apiKey}&lang=${e.lang}`,this.instance=km.default.create({baseURL:r}),this.countryRemapper=new ne,this.competitionBasicRemapper=new Ce,this.competitionFullRemapper=new bo,this.teamBasicRemapper=new ge,this.teamFullRemapper=new Po,this.matchBasicRemapper=new So,this.matchFullRemapper=new Bo,this.playerBasicRemapper=new Or,this.playerFullRemapper=new $o,this.topPlayerRemapper=new Uo,this.searchRemapper=new Vo,this.footballMetaRemapper=new qo}getCountries=async e=>{try{let r=`/countries${this.apiSignInUrl}`,n=Date.now();e&&(r+=`&disable_cache=${n}`);let a=await this.instance.get(r);return this.countryRemapper.countriesFromResponse(a.data.data)}catch(r){throw console.warn("There was a problem with the football countries request",r),r}};getCompetitions=async(e,r)=>{try{let n={},a=Date.now();if(r=r||!1,e&&e.competitionIds&&e.competitionIds.length>this.limitIds-1){let c=[],f=Vn(e.competitionIds);for(let v of f){e.competitionIds=v;let S=`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`;r&&(S+=`&disable_cache=${a}`),n=await this.instance.get(S),c.push(n.data.data.map(M=>this.competitionBasicRemapper.fromResponse(M)))}return Array.prototype.concat.apply([],c)}else{let c=`/competitions${this.apiSignInUrl}`;return e&&(c+=`${e.constructFilterUrl()}`),r&&(c+=`&disable_cache=${a}`),n=await this.instance.get(c),n.data.data.map(f=>this.competitionBasicRemapper.fromResponse(f))}}catch(n){throw console.warn("There was a problem with getCompetitions request",n),n.response}};getCompetitionById=async(e,r)=>{try{let n=`/competitions/${e}${this.apiSignInUrl}`,a=Date.now();r&&(n+=`&disable_cache=${a}`);let c=await this.instance.get(n);return this.competitionFullRemapper.fromResponse(c.data.data)}catch(n){throw console.warn("There was a problem with getCompetitionById request",n),n.response}};getTopCompetitions=async e=>{try{this.apiSignInUrl+=`&client_id=${this.clientId}`;let r=`/competitions/top${this.apiSignInUrl}`,n=Date.now();return e&&(r+=`&disable_cache=${n}`),(await this.instance.get(r)).data.data.map(c=>this.competitionBasicRemapper.fromResponse(c))}catch(r){throw console.warn("There was a problem with getTopCompetitions request",r),r.response}};getTeams=async(e,r)=>{try{let n={},a=Date.now();if(e&&e.teamIds&&e.teamIds.length>this.limitIds){let c=[],f=Vn(e.teamIds);for(let v of f){e.teamIds=v;let S=`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`;r&&(S+=`disable_cache=${a}`),n=await this.instance.get(S),c.push(n.data.data.map(M=>this.teamBasicRemapper.fromResponse(M)))}return Array.prototype.concat.apply([],c)}else{let c=new Nr,f=`/teams${this.apiSignInUrl}`;return e&&(f+=`${e.constructFilterUrl()}`),r&&(f+=`&disable_cache=${a}`),n=await this.instance.get(f),c.meta=this.footballMetaRemapper.remapMetaProp(n.data.meta),c.data=n.data.data.map(g=>this.teamBasicRemapper.fromResponse(g)),c}}catch(n){throw console.warn("There was a problem with getTeams request",n),n.response}};getTeamById=async(e,r)=>{try{let n=`/teams/${e}${this.apiSignInUrl}`,a=Date.now();r&&(n+=`disable_cache=${a}`);let c=await this.instance.get(n);return this.teamFullRemapper.fromResponse(c.data.data)}catch(n){throw console.warn("There was a problem with getTeamById request",n),n.response}};getTopTeams=async e=>{try{this.apiSignInUrl+=`&client_id=${this.clientId}`;let r=`/teams/top${this.apiSignInUrl}`,n=Date.now();e&&(r+=`$disable_cache=${n}`);let a=await this.instance.get(r);return a.data.data?a.data.data.map(c=>this.teamBasicRemapper.fromResponse(c)):[]}catch(r){throw console.warn("There was a problem with getTopTeams request",r),r.response}};getNextMatchForTeam=async(e,r)=>{try{let n=`/teams/${e}/next-match${this.apiSignInUrl}`,a=Date.now();r&&(n+=`&disable_cache=${a}`);let c=await this.instance.get(n);return this.matchFullRemapper.fromResponse(c.data.data)}catch(n){throw console.warn("There was a problem with getNextMatchForTeam request",n),n.response}};getPrevMatchForTeam=async(e,r)=>{try{let n=`/teams/${e}/previous-match${this.apiSignInUrl}`,a=Date.now();r&&(n+=`disable_cache=${a}`);let c=await this.instance.get(n);return this.matchFullRemapper.fromResponse(c.data.data)}catch(n){throw console.warn("There was a problem with getPrevMatchForTeam request",n),n.response}};getPlayers=async(e,r)=>{try{let n={},a=Date.now();if(e&&e.playerIds&&e.playerIds.length>this.limitIds-1){let c=[],f=Vn(e.playerIds);for(let v of f){e.playerIds=v;let S=`/players${this.apiSignInUrl}${e.constructFilterUrl()}`;r&&(S+=`&disable_cache=${a}`),n=await this.instance.get(S),c.push(n.data.data.map(M=>this.teamBasicRemapper.fromResponse(M)))}return Array.prototype.concat.apply([],c)}else{let c=new Nr,f=`/players${this.apiSignInUrl}`;return e&&(f+=`${e.constructFilterUrl()}`),r&&(f+=`&disable_cache=${a}`),n=await this.instance.get(f),c.meta=this.footballMetaRemapper.remapMetaProp(n.data.meta),c.data=n.data.data.map(g=>this.playerBasicRemapper.fromResponse(g)),c}}catch(n){throw console.warn("There was a problem with getPlayers request",n),n.response}};getPlayerById=async(e,r)=>{try{let n=`/players/${e}${this.apiSignInUrl}`,a=Date.now();r&&(n+=`&disable_cache=${a}`);let c=await this.instance.get(n);return this.playerFullRemapper.fromResponse(c.data.data)}catch(n){throw console.warn("There was a problem with getPlayerById request",n),n.response}};getTopPlayers=async e=>{try{this.apiSignInUrl+=`&client_id=${this.clientId}`;let r=`/players/top${this.apiSignInUrl}`,n=Date.now();return e&&(r+=`&disable_cache=${n}`),(await this.instance.get(r)).data.data.map(c=>this.topPlayerRemapper.fromResponse(c))}catch(r){throw console.warn("There was a problem with getTopPlayers request",r),r.response}};getNextMatchForPlayer=async(e,r)=>{try{let n=`/players/${e}/next-match${this.apiSignInUrl}`,a=Date.now();r&&(n+=`&disable_cache=${a}`);let c=await this.instance.get(n);return this.matchFullRemapper.fromResponse(c.data.data)}catch(n){throw console.warn("There was a problem with getNextMatchForPlayer request",n),n.response}};getPrevMatchForPlayer=async(e,r)=>{try{let n=`/players/${e}/previous-match${this.apiSignInUrl}`,a=Date.now();r&&(n+=`&disable_cache=${a}`);let c=await this.instance.get(n);return this.matchFullRemapper.fromResponse(c.data.data)}catch(n){throw console.warn("There was a problem with getPrevMatchForPlayer request",n),n.response}};getMatchById=async(e,r)=>{try{let n=`/matches/${e}${this.apiSignInUrl}`,a=Date.now();r&&(n+=`&disable_cache=${a}`);let c=await this.instance.get(n);return this.matchFullRemapper.fromResponse(c.data.data)}catch(n){throw console.warn("There was a problem with getMatchById request",n),n.response}};getMatches=async(e,r)=>{try{let n=new Nr,a=`/matches${this.apiSignInUrl}`,c=Date.now();e&&(a+=`${e.constructFilterUrl()}`),r&&(a+=`&disable_cache=${c}`);let f=await this.instance.get(a);return n.meta=this.footballMetaRemapper.remapMetaProp(f.data.meta),n.data=f.data.data.map(g=>this.matchBasicRemapper.fromResponse(g)),n}catch(n){throw console.warn("There was a problem with getMatches request",n),n.response}};search=async(e,r)=>{try{let n=`/search${this.apiSignInUrl}${e.constructFilterUrl()}`,a=Date.now();r&&(n+=`&disable_cache=${a}`);let c=await this.instance.get(n);return this.searchRemapper.fromResponse(c.data.data)}catch(n){throw console.warn("There was a problem with search request",n),n.response}}};var Yl=Dt(Gt());var ko=class{profileId;tier;points};var Wo=class{id=null;label=null};var Ko=class{type=null;id=null;label=null};var Ur=class{content=new Ko;tags=[];campaign=new Wo};var Dr=class{id=null;profileId=null;action=null;context=new Ur;points=0};var Xo=class{totalItems=0};var Yo=class{meta=new Xo;data=[new Dr]};var zo=class{remapSingleResponse=e=>{let r=new Dr;return r.id=e.id,r.profileId=e.profile_id,r.action=e.action,r.context.content=e.context.content??r.context.content,r.context.tags=e.context.tags,r.context.campaign=e.context.campaign??r.context.campaign,r.points=e.points,r};remapActivitiesResponse=e=>{let r=new Yo;return r.meta.totalItems=e.meta.total_items,r.data=e.data.map(n=>this.remapSingleResponse(n)),r};remapStatsReponse=e=>{let r=new ko;return r.profileId=e.profile_id,r.tier=e.tier,r.points=e.points,r}};var Gr=class{instanceAuth=null;instance=null;activityRemapper=null;apiSignInUrl=null;clientApiSignInUrl=null;constructor(e){let r=Ee(e.environment,"loyalty");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instanceAuth=Yl.default.create({baseURL:r,headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.authProvider.getIdToken()}`}}),this.instance=Yl.default.create({baseURL:r,headers:{"Content-Type":"application/json"}}),this.activityRemapper=new zo}createActivity=async e=>{try{let r=`/activities${this.apiSignInUrl}`,n=await this.instanceAuth.post(r,JSON.stringify(e));return this.activityRemapper.remapSingleResponse(n.data)}catch(r){throw console.warn("There was a problem with creating activity for user",r),r}};deleteActivity=async e=>{try{let r=`/activities/${e}${this.apiSignInUrl}`;return await this.instanceAuth.delete(r),!0}catch(r){throw console.warn(`There was a problem deleting the following activity: ${e}`,r),r.response}};getOwnActivities=async(e,r)=>{try{let n=`/activities${this.apiSignInUrl}`,a=Date.now();e&&(n+=`${e.constructFilterUrl()}`),r&&(n+=`disable_cache=${a}`);let c=await this.instanceAuth.get(n);return this.activityRemapper.remapActivitiesResponse(c.data)}catch(n){throw console.warn("There was a problem with fetching own activities",n),n}};getActivitiesForUser=async(e,r,n)=>{try{let a=`/users/${e}/activities${this.apiSignInUrl}`,c=Date.now();r&&(a+=`${r.constructFilterUrl()}`),n&&(a+=`disable_cache=${c}`);let f=await this.instance.get(a);return this.activityRemapper.remapActivitiesResponse(f.data)}catch(a){throw console.warn(`There was a problem with fetching activities for user ${e}`,a),a}};getStats=async e=>{try{let r="",n=null;return e?(r+=`/users/${e}/statistics${this.apiSignInUrl}`,n=await this.instance.get(r)):(r+=`/statistics${this.apiSignInUrl}`,n=await this.instanceAuth.get(r)),this.activityRemapper.remapStatsReponse(n.data.data)}catch(r){throw console.warn("There was a problem fetching profile`s statistics:",r),r.response}}};var $r=class{profileHttps=null;activityHttps=null;footballHttps=null;footballFacade=null;idMapping=null;localStorage=null;profileFacade=null;ownProfileBuilder=null;profileBuilder=null;constructor(e){this.profileHttps=new Qn(e),this.activityHttps=new Gr(e),this.footballHttps=new mt(e),this.idMapping=new he(e),this.localStorage=new Ht(e),this.footballFacade=new Kt(this.localStorage,this.footballHttps,this.idMapping),this.profileFacade=new qt(this.localStorage,this.profileHttps),this.ownProfileBuilder=new fo(this.localStorage,this.profileHttps,this.activityHttps,this.idMapping,this.footballHttps),this.profileBuilder=new ho(this.localStorage,this.profileHttps,this.activityHttps,this.idMapping,this.footballFacade)}getOwn=()=>this.ownProfileBuilder;getById=e=>this.profileBuilder.setId(e);getCountries=async e=>await this.profileFacade.getCountries(e);getByIds=async(e,r)=>await this.profileFacade.getByIds(e,r)};var Jo=class{validate=e=>{let r=this.validateField(e.lang),n=this.generateMessage(r);return{validation:r,message:n}};validateField=e=>{let r=["bg","ro","en"],n=null;return e!=null&&e.length>0?r.includes(e)?n="valid":n="invalid":n="missing",n};generateMessage=e=>{let r=null,n="warning";return e==="missing"&&(r="If no lang is passed the default one will be set which is: EN"),e==="invalid"&&(r="This lang value is not supported, the default one will be set which is: EN"),e==="valid"&&(r=null,n=null),{text:r,type:n}}};var Qo=class{validate(e){let r=this.validateField(e.environment),n=this.generateMessage(r);return{validation:r,message:n}}validateField=e=>{let r=["dev","staging","prod"],n=null;return e!=null&&e.length>0?r.includes(e)?n="valid":n="invalid":n="missing",n};generateMessage=e=>{let r=null,n="warning";return e==="missing"&&(r="If no environment is passed the default one will be set which is: prod"),e==="invalid"&&(r="This environment value is not supported, the default one will be set which is: prod"),e==="valid"&&(r=null,n=null),{text:r,type:n}}};var Zo=class{validate(e){let r=this.validateField(e.apiKey),n=this.generateMessage(r);return{validation:r,message:n}}validateField=e=>{let r=null;return e!=null&&e.length>0?r="valid":r="missing",r};generateMessage=e=>{let r=null,n="error";return e==="missing"&&(r="The field apiKey with valid value must be provided to use this SDK"),e==="valid"&&(n=null),{text:r,type:n}}};var jo=class{validate(e){let r=this.validateField(e.idSchema),n=this.generateMessage(r);return{validation:r,message:n}}validateField=e=>{let r=["native","sportal365","enetpulse","sportradar"],n=null;return e!=null&&e.length>0?r.includes(e)?n="valid":n="invalid":n="missing",n};generateMessage=e=>{let r=null,n="warning";return e==="missing"&&(r="If no idSchema is passed the default one will be set which is: native"),e==="invalid"&&(r="This idSchema value is not supported, the default one will be set which is: native"),e==="valid"&&(r=null,n=null),{text:r,type:n}}};var Oi=class{getIdToken=null;logout=null};var qr=class{text=null;type=null};var ea=class{validation=null;message=new qr;getIdToken={validation:null,message:new qr};logout={validation:null,message:new qr}};var ta=class{validate(e){let r=this.validateAuthProvider(e.authProvider);return r.validation!=="missing"&&(r=this.validateAuthProviderConfigFields(e.authProvider,r),r=this.generateAuthProviderConfigMessages(r),r=this.checkAuthProviderConfigMessagesForErrors(r)),r}validateAuthProvider=e=>{let r=Object.keys(new Oi),n=new ea;if(e){let c=Object.keys(e).filter(f=>!r.includes(f));c.length>0?(n.validation="invalid",n.message.type="warning",n.message.text=`${"You have passed a property which is not supported for the authentication provider:"} ${c.join(",")}`):n.validation="valid"}else n.validation="missing",n.message.type="error",n.message.text="The field authProvider must be provided to use this SDK";return n};validateAuthProviderConfigFields=(e,r)=>(Object.keys(new Oi).forEach(a=>{e[a]?r[a].validation="valid":r[a].validation="missing"}),r);generateAuthProviderConfigMessages=e=>(Object.keys(e).filter(r=>r!=="validation"&&r!=="message").forEach(r=>{let n=e[r];n.validation==="missing"&&(n.message.text=`${"The following property is missing from the authProvider object:"} ${r}`,n.message.type="error")}),e);checkAuthProviderConfigMessagesForErrors=e=>(Object.keys(e).filter(r=>r!=="validation"&&r!=="message").forEach(r=>{e[r].validation==="missing"&&e.validation==="valid"&&(e.validation="invalid",e.message.type="error",e.message.text="The field authProvider has missing properties")}),e)};var Li=class{validation;message};var ra=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;authProvider={getIdToken:new Li,logout:new Li};isValid=!1};var ia=class{validate(e){let r=this.validateField(e.clientId),n=this.generateMessage(r);return{validation:r,message:n}}validateField=e=>{let r=null;return e!=null&&e.length>0?r="valid":r="missing",r};generateMessage=e=>{let r=null,n="warning";return e==="missing"&&(r="The field clientId must be provided to use this SDK"),e==="valid"&&(r=null,n=null),{text:r,type:n}}};var na=class{validate=e=>{let r=this.checkFieldsForValues(e);return r.isValid=this.containsErrorMessage(r),r};checkFieldsForValues=e=>{let r=new ra,n={apiKey:new Zo,environment:new Qo,idSchema:new jo,clientId:new ia,lang:new Jo,authProvider:new ta};for(let[a,c]of Object.entries(r))a!=="isValid"&&(c=n[a].validate(e));return Object.keys(n).forEach(a=>{r[a]=n[a].validate(e)}),r};containsErrorMessage=e=>{let r=!0;for(let[n,a]of Object.entries(e))if(n!=="authProvider"){if(n!=="isValid"&&a.message.type==="error")return r=!1,r;if(n!=="isValid"&&a.message.type==="warning")return r=!0,r}return r}};var oa=class{https=null;idMapping=null;localStorage=null;footballFacade=null;constructor(e){this.https=new mt(e),this.idMapping=new he(e),this.localStorage=new Ht(e),this.footballFacade=new Kt(this.localStorage,this.https,this.idMapping)}getCountries=async e=>await this.footballFacade.getCountries(e);getCompetitions=async(e,r)=>await this.footballFacade.getCompetitions(e,r);getCompetitionById=async(e,r)=>await this.footballFacade.getCompetitionById(e,r);getTopCompetitions=async e=>await this.footballFacade.getTopCompetitions(e);getTeams=async(e,r)=>await this.footballFacade.getTeams(e,r);getTeamById=async(e,r)=>await this.footballFacade.getTeamById(e,r);getTopTeams=async e=>await this.footballFacade.getTopTeams(e);getNextMatchForTeam=async(e,r)=>await this.footballFacade.getNextMatchForTeam(e,r);getPrevMatchForTeam=async(e,r)=>await this.footballFacade.getPrevMatchForTeam(e,r);getPlayers=async(e,r)=>await this.footballFacade.getPlayers(e,r);getPlayerById=async(e,r)=>await this.footballFacade.getPlayerById(e,r);getTopPlayers=async e=>await this.footballFacade.getTopPlayers(e);getNextMatchForPlayer=async(e,r)=>await this.footballFacade.getNextMatchForPlayer(e,r);getPrevMatchForPlayer=async(e,r)=>await this.footballFacade.getPrevMatchForPlayer(e,r);getMatches=async(e,r)=>await this.footballFacade.getMatches(e,r);getMatchById=async(e,r)=>await this.footballFacade.getMatchById(e,r);search=async(e,r)=>await this.footballFacade.search(e,r)};var jl=Dt(Gt());var aa=class{value=null;playerId=null;playerModel=null};var kr=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new aa;result=null};var sa=class{value=!1;playerId=null};var nt=class{matchId=null;market=null;prediction=null;constructor(e,r,n,a){this.matchId=e,this.market=r,this.prediction=new sa,this.prediction.value=n,this.prediction.playerId=a}};var Wr=class{settledAt=null;resettledAt=null;status=null;outcome=null};var Ge=(q=>(q.FT_1X2="FT_1X2",q.HT_1X2="HT_1X2",q.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",q.DOUBLE_CHANCE="DOUBLE_CHANCE",q.HT_FT="HT_FT",q.PLAYER_SCORE="PLAYER_SCORE",q.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",q.PLAYER_RED_CARD="PLAYER_RED_CARD",q.RED_CARD_MATCH="RED_CARD_MATCH",q.PENALTY_MATCH="PENALTY_MATCH",q.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",q.CORNERS_MATCH="CORNERS_MATCH",q.CORRECT_SCORE="CORRECT_SCORE",q.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",q.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",q.OVER_GOALS_0_5="OVER_GOALS_0.5",q.OVER_GOALS_1_5="OVER_GOALS_1.5",q.OVER_GOALS_2_5="OVER_GOALS_2.5",q.OVER_GOALS_3_5="OVER_GOALS_3.5",q.OVER_GOALS_4_5="OVER_GOALS_4.5",q.OVER_GOALS_5_5="OVER_GOALS_5.5",q.OVER_GOALS_6_5="OVER_GOALS_6.5",q.OVER_CORNERS_6_5="OVER_CORNERS_6.5",q.OVER_CORNERS_7_5="OVER_CORNERS_7.5",q.OVER_CORNERS_8_5="OVER_CORNERS_8.5",q.OVER_CORNERS_9_5="OVER_CORNERS_9.5",q.OVER_CORNERS_10_5="OVER_CORNERS_10.5",q.OVER_CORNERS_11_5="OVER_CORNERS_11.5",q.OVER_CORNERS_12_5="OVER_CORNERS_12.5",q.OVER_CORNERS_13_5="OVER_CORNERS_13.5",q))(Ge||{}),Wm=["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"],Km=["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"],zl=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"];var la=class{value=null};var Xt=class{matchId=null;market="CORRECT_SCORE";prediction=null;constructor(e,r){this.matchId=e,this.prediction=new la,this.prediction.value=r}};var Qe=class{value=!1};var Kr=class{matchId=null;market=null;prediction=null;constructor(e,r,n){this.matchId=e,this.market=r,this.prediction=new Qe,this.prediction.value=n}};var Xr=class{matchId=null;market=null;prediction=null;constructor(e,r,n){this.matchId=e,this.market=r,this.prediction=new Qe,this.prediction.value=n}};var pa=class{matchFacade=null;playerFacade=null;predictorService=null;constructor(e,r,n){this.matchFacade=e,this.playerFacade=r,this.predictorService=n}remapFixturesRequest=e=>{let r={};if(r.match_id=e.matchId,r.match_type="FOOTBALL",e instanceof nt)r.market=e.market,r.prediction=e.prediction.value,r.player_id=e.prediction.playerId;else if(e instanceof Kr||e instanceof Xr){let n=e.market.split("_");r.market=n[0]+"_"+n[1],r.prediction=e.prediction.value,r.target=Number(n[2])}else if(e instanceof Xt){r.market=e.market;let n=e.prediction.value.split(":");r.goals_home=Number(n[0]),r.goals_away=Number(n[1])}else r.market=e.market,r.prediction=e.prediction.value;return r};remapFixturesResponse=async e=>{e.length>1&&e.sort((g,v)=>g.match_id.localeCompare(v.match_id));let r=[],n=[];for(let g of e)r.push(g.match_id),g.player_id&&!n.includes(g.player_id)&&n.push(g.player_id);let a=await this.matchFacade.getMatchesMapWithNativeIds(r),c=[];n.sort((g,v)=>g.localeCompare(v)),n&&n.length>0&&(c=await this.playerFacade.getPlayersMapWithNativeIds(n));let f=[];for(let g of e){let v=new kr;g.target?v.market=this.predictorService.convertMarketForResponseModel(g.market,g.target):v.market=g.market,v.matchId=a[g.match_id].id,v.matchType=g.match_type,v.matchModel=a?a[g.match_id]:null,g.goals_home!==void 0&&g.goals_away!==void 0?v.prediction.value=g.goals_home.toString()+":"+g.goals_away.toString():v.prediction.value=g.prediction,v.prediction.playerId=g.player_id?g.player_id:null,v.prediction.playerId&&(v.prediction.playerModel=c[g.player_id],v.prediction.playerId=c[g.player_id].id),v.result=this.remapResult(g.result),f.push(v)}return f};remapResult=e=>{let r=new Wr;return r.settledAt=e.settled_at,r.resettledAt=e.resettled_at,r.status=e.status,r.outcome=e.outcome,r}};var Yr=class{goldenGoal=null};var Bi=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new Yr;points=null;createdAt=null;updatedAt=null};var N=class{no=0;yes=0};var zr=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new N;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new N;penaltyMatch=new N;playerScoreFirstGoal={};cornersMatch={};correctScore={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new N;overOnePointFiveGoals=new N;overTwoPointFiveGoals=new N;overThreePointFiveGoals=new N;overFourPointFiveGoals=new N;overFivePointFiveGoals=new N;overSixPointFiveGoals=new N;overSixPointFiveCorners=new N;overSevenPointFiveCorners=new N;overEightPointFiveCorners=new N;overNinePointFiveCorners=new N;overTenPointFiveCorners=new N;overElevenPointFiveCorners=new N;overTwelvePointFiveCorners=new N;overThirteenPointFiveCorners=new N};var Jl=(n=>(n.ONE="1",n.X="x",n.TWO="2",n))(Jl||{}),Ql=(n=>(n.ONE_X="1x",n.X_TWO="x2",n.ONE_TWO="12",n))(Ql||{}),Zl=(S=>(S.ONE_ONE="1/1",S.ONE_X="1/x",S.ONE_TWO="1/2",S.X_ONE="x/1",S.X_X="x/x",S.X_TWO="x/2",S.TWO_ONE="2/1",S.TWO_X="2/x",S.TWO_TWO="2/2",S))(Zl||{});var ca=class{value=null};var ua=class{matchId=null;market="HT_FT";prediction=null;constructor(e,r){this.matchId=e,this.prediction=new ca,this.prediction.value=r}};var ma=class{value=null};var da=class{matchId=null;market="DOUBLE_CHANCE";prediction=null;constructor(e,r){this.matchId=e,this.prediction=new ma,this.prediction.value=r}};var Jr=class{value=null};var fa=class{matchId=null;market="FT_1X2";prediction=null;constructor(e,r){this.matchId=e,this.prediction=new Jr,this.prediction.value=r}};var ha=class{matchId=null;market="HT_1X2";prediction=null;constructor(e,r){this.matchId=e,this.prediction=new Jr,this.prediction.value=r}};var ga=class{value};var ya=class{matchId=null;market="CORNERS_MATCH";prediction=null;constructor(e,r){this.matchId=e,this.prediction=new ga,this.prediction.value=r}};var wa=class{matchId=null;market="BOTH_TEAMS_SCORE";prediction=null;constructor(e,r){this.matchId=e,this.prediction=new Qe,this.prediction.value=r}};var Ma=class{matchId=null;market="RED_CARD_MATCH";prediction=null;constructor(e,r){this.matchId=e,this.prediction=new Qe,this.prediction.value=r}};var ba=class{matchId=null;market="PENALTY_MATCH";prediction=null;constructor(e,r){this.matchId=e,this.prediction=new Qe,this.prediction.value=r}};var ar=class{id=null;title=null;description=null;type=null;status=null;predictionsCutoff=null;fixtures=[];createdAt=null;updatedAt=null};var sr=class{userId=null;points=null;results=[];tiebreaker=null};var va=(c=>(c.ACTIVE="ACTIVE",c.WON="WON",c.LOST="LOST",c.PARTIALLY_WON="PARTIALLY_WON",c.CANCELED="CANCELED",c))(va||{}),Ni=["WON","LOST","PARTIALLY_WON","CANCELED"];var se=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}constructFiltersUrl=()=>{let e="",r=!1;return this.status&&(r=Object.values(va).some(n=>this.status.includes(n))),this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),this.status&&r&&(e+="&",e+=`status=${this.status.join(",")}`),this.type&&(e+="&",e+=`game_types=${this.type}`),e}};var Ui=(f=>(f.OPEN="OPEN",f.LIVE="LIVE",f.PENDING="PENDING",f.CANCELED="CANCELED",f.CLOSED="CLOSED",f.SETTLED="SETTLED",f))(Ui||{});var $e=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(Ui).includes(this.status)&&(e+="&",e+=`status=${this.status}`),this.type&&(e+="&",e+=`type=${this.type}`),this.gameIds&&this.gameIds.length>0&&(e+="&",e+=`game_ids=${this.gameIds.join(",")}`),e}};var lr=class{id=null;title=null;description=null;type=null;status=null;predictionsCutoff=null;fixtures=[];createdAt=null;updatedAt=null};var Ft=class{id=null;title=null;description=null;type=null;status=null;predictionsCutoff=null;fixtures=[];createdAt=null;updatedAt=null};var dt=class{footballHttps=null;idMapping=null;matchFacade=null;playerFacade=null;constructor(e,r){this.footballHttps=new mt(e),this.idMapping=r,this.matchFacade=new Wt(this.footballHttps,r),this.playerFacade=new kt(this.footballHttps,r)}remapMatchIdToNative=async e=>{let r=await this.idMapping.getEntityIdsBySchemaId(e,"match","native"),n=[];return r.match.forEach(a=>n.push(a)),n};remapPlayerIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"player","native")).player[0];remapPlayerIdMapToNative=async e=>{let r={},n=$t(e),c=(await this.idMapping.getEntityIdsBySchemaId(n,"player","native")).player;return n.forEach((f,g)=>r[f]=c[g]),r};remapPlayerIdToIdSchema=async e=>{let r=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"];for(let[n,a]of Object.entries(e))if(r.includes(n))for(let c of Object.keys(a)){let f={player:[c]},v=(await this.idMapping.idMappingFacade.getEntitiesByIds(f,"native",this.idMapping.idSchema)).player[0];a[v]=a[c],delete a[c]}return e};convertMarket=e=>{let r=Object.keys(new zr),n=Object.values(Ge);for(let a=0;a<n.length;a++)e===n[a]&&(e=r[a]);return e};convertMarketForResponseModel=(e,r)=>{let n=r.toString();return e+"_"+n};validateFixture=(e,r,n,a)=>{let c=Object.values(Jl),f=Object.values(Zl),g=Object.values(Ql);if(r==="FT_1X2"){if(c.includes(n))return new fa(e,n)}else if(r==="HT_1X2"){if(c.includes(n))return new ha(e,n)}else if(r==="HT_FT"){if(f.includes(n))return new ua(e,n)}else if(r==="DOUBLE_CHANCE"){if(g.includes(n))return new da(e,n)}else if(r==="CORRECT_SCORE"){if(typeof n=="string"&&/\d+:\d+/.test(n))return new Xt(e,n)}else if(r==="CORNERS_MATCH"){if(typeof n=="number")return new ya(e,n)}else if(r==="BOTH_TEAMS_SCORE"){if(typeof n=="boolean")return new wa(e,n)}else if(r==="RED_CARD_MATCH"){if(typeof n=="boolean")return new Ma(e,n)}else if(r==="PENALTY_MATCH"){if(typeof n=="boolean")return new ba(e,n)}else if(zl.includes(r)){if(a&&typeof n=="boolean")return new nt(e,r,n,a)}else if(Wm.includes(r)){if(typeof n=="boolean")return new Xr(e,r,n)}else if(Km.includes(r)&&typeof n=="boolean")return new Kr(e,r,n)};getMarketSummary=(e,r,n)=>{let a=this.convertMarket(r),c={};if(c.matchId=e.matchId,c.matchType=e.matchType,Object.keys(e.predictions).includes(a))c[a]=e.predictions[a];else throw new Error("You have passed invalid market");return zl.includes(r)&&n?(c[a][n]||(c[a][n]=new N),c[a][n]):c};remapCompetitionsFromConfig=async e=>{let r={competition:e.fullCoverageCompetitions},n=await this.idMapping.idMappingFacade.getEntitiesByIds(r,"native",this.idMapping.idSchema);return e.fullCoverageCompetitions=n.competition,e};remapMatchIdsFixtures=async e=>{if(Array.isArray(e.data))if(e.data.length>0){let r=[],n=[];return e.data.forEach(a=>{a instanceof lr||a instanceof ar||a instanceof Ft?(a.fixtures.forEach(c=>r.push(c.matchId)),a instanceof Ft&&a.fixtures.forEach(c=>{c.prediction.playerId&&n.push(c.prediction.playerId)})):a instanceof sr&&a.results.forEach(c=>r.push(c.matchId))}),await this.refactorResponseArrModel(e,r,n)}else return e;else return await this.refactorResponseObjModel(e)};refactorResponseArrModel=async(e,r,n)=>{let a=[],c=await this.matchFacade.getMatchesMapWithNativeIds(r),f={};return n.length>0&&(f=await this.playerFacade.getPlayersMapWithNativeIds(n)),e.data.forEach(g=>{g instanceof lr||g instanceof ar||g instanceof Ft?(g.fixtures.forEach(v=>{v.matchModel=c[v.matchId],v.matchId=v.matchModel.id,g instanceof Ft&&v.prediction.playerId&&(v.prediction.playerModel=f[v.prediction.playerId],v.prediction.playerId=f[v.prediction.playerId].id)}),a.push(g)):g instanceof sr&&(g.results.forEach(v=>{v.matchModel=c[v.matchId],v.matchId=v.matchModel.id}),a.push(g))}),e.data=a,e};refactorResponseObjModel=async e=>{let r=[];e.fixtures.forEach(a=>r.push(a.matchId));let n=await this.matchFacade.getMatchesMapWithNativeIds(r);return e.fixtures.forEach(a=>{a.matchModel=n[a.matchId],a.matchId=n[a.matchId].id}),e};getCurrentGameId=e=>{let r=new Date;if(e.data.length>1){let n=[];return e.data.forEach(c=>n.push(c.predictionsCutoff)),e.data.sort((c,f)=>{let[g,v]=[c.predictionsCutoff,f.predictionsCutoff].map(S=>Math.abs(new Date(S)-r));return g-v})[0].id}else return e.data[0].id};initGameTypePredictions=e=>{let r={type:e};return r=new se(r),r};initGameFilters=(e,r,n)=>{if(r&&n)return r.type=e,r.gameIds=n,r=new $e(r),r;if(r&&!n)return r.type=e,r=new $e(r),r;if(!r&&n){let a={type:e,gameIds:n};return a=new $e(a),a}else{let a={type:e};return a=new $e(a),a}};addPredictionProp=async(e,r)=>(r.data.forEach((n,a)=>{n.id===e[a].game_instance_id&&n.fixtures.forEach((c,f)=>{e[a].fixtures[f].goals_home!==void 0&&e[a].fixtures[f].goals_away!==void 0?c.prediction.value=e[a].fixtures[f].goals_home+":"+e[a].fixtures[f].goals_away:c.prediction.value=e[a].fixtures[f].prediction,e[a].fixtures[f].player_id?c.prediction.playerId=e[a].fixtures[f].player_id:e[a].fixtures[f].target&&(c.prediction.target=e[a].fixtures[f].target),c.prediction.result=this.remapResult(e[a].fixtures[f].result)})}),await this.remapMatchIdsFixtures(r));remapResult=e=>{let r=new Wr;return r.settledAt=e.settled_at,r.resettledAt=e.resettled_at,r.status=e.status,r.outcome=e.outcome,r}};var Qr=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(e){this.gameInstanceId=e.gameInstanceId,e.fixtures.forEach(r=>this.fixtures.push(new Xt(r.matchId,r.prediction.value))),this.tiebreaker=e.tiebreaker?e.tiebreaker:null}};var Zr=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(e,r){this.footballHttps=new mt(e),this.matchFacade=new Wt(this.footballHttps,r),this.playerFacade=new kt(this.footballHttps,r),this.predictorService=new dt(e,r),this.fixturesRemapper=new pa(this.matchFacade,this.playerFacade,this.predictorService)}remapRequestBody=e=>{let r={};return r.game_instance_id=e.gameInstanceId,r.fixtures=e.fixtures.map(n=>this.fixturesRemapper.remapFixturesRequest(n)),e instanceof Qr&&e.tiebreaker&&(r.tiebreaker={},r.tiebreaker.golden_goal=e.tiebreaker.goldenGoal?e.tiebreaker.goldenGoal:null),r};remapResponseArrayBody=async e=>{let r=[],n=[],a={},c=[];e.forEach(g=>{g.fixtures.forEach(v=>{r.push(v.match_id),v.player_id&&n.push(v.player_id)})});let f=await this.matchFacade.getMatchesMapWithNativeIds(r);return n.length>0&&(a=await this.playerFacade.getPlayersMapWithNativeIds(n)),e.forEach(g=>{let v=new Bi,S=[];v.id=g.id,v.gameInstanceId=g.game_instance_id,v.gameType=g.game_type,v.wager=g.wager,v.totalFixtures=g.total_fixtures,v.settledFixtures=g.settled_fixtures,v.userId=g.user_id,g.fixtures.forEach(M=>{let F=new kr;M.target?F.market=this.predictorService.convertMarketForResponseModel(M.market,M.target):F.market=M.market,F.matchId=f[M.match_id].id,F.matchType=M.match_type,F.matchModel=f[M.match_id],M.goals_home!==void 0&&M.goals_away!==void 0?F.prediction.value=M.goals_home.toString()+":"+M.goals_away.toString():F.prediction.value=M.prediction,F.prediction.playerId=M.player_id?M.player_id:null,F.prediction.playerId&&(F.prediction.playerModel=a[F.prediction.playerId],F.prediction.playerId=a[F.prediction.playerId].id),F.result=this.fixturesRemapper.remapResult(M.result),S.push(F)}),v.fixtures=S,v.status=g.status,g.tiebreaker?v.tiebreaker.goldenGoal=g.tiebreaker.golden_goal:v.tiebreaker=null,v.points=g.points,v.createdAt=g.created_at,v.updatedAt=g.updated_at,c.push(v)}),c};remapResponseObjBody=async e=>{let r=new Bi;return r.id=e.id,r.gameInstanceId=e.game_instance_id,r.gameType=e.game_type,r.wager=e.wager,r.totalFixtures=e.total_fixtures,r.settledFixtures=e.settled_fixtures,r.userId=e.user_id,r.fixtures=await this.fixturesRemapper.remapFixturesResponse(e.fixtures),r.status=e.status,e.tiebreaker?r.tiebreaker.goldenGoal=e.tiebreaker.golden_goal:r.tiebreaker=null,r.points=e.points,r.createdAt=e.created_at,r.updatedAt=e.updated_at,r};remapPredictionModel=e=>{let r=new zr;return r.fullTimeOneXTwo=e.FT_1X2,r.halfTimeOneXTwo=e.HT_1X2,r.bothTeamsScore=e.BOTH_TEAMS_SCORE?e.BOTH_TEAMS_SCORE:new N,r.overZeroPointFiveGoals=e.OVER_GOALS["over:0.5"]?e.OVER_GOALS["over:0.5"]:new N,r.overOnePointFiveGoals=e.OVER_GOALS["over:1.5"]?e.OVER_GOALS["over:1.5"]:new N,r.overTwoPointFiveGoals=e.OVER_GOALS["over:2.5"]?e.OVER_GOALS["over:2.5"]:new N,r.overThreePointFiveGoals=e.OVER_GOALS["over:3.5"]?e.OVER_GOALS["over:3.5"]:new N,r.overFourPointFiveGoals=e.OVER_GOALS["over:4.5"]?e.OVER_GOALS["over:4.5"]:new N,r.overFivePointFiveGoals=e.OVER_GOALS["over:5.5"]?e.OVER_GOALS["over:5.5"]:new N,r.overSixPointFiveGoals=e.OVER_GOALS["over:6.5"]?e.OVER_GOALS["over:6.5"]:new N,r.overSixPointFiveCorners=e.OVER_CORNERS["over:6.5"]?e.OVER_CORNERS["over:6.5"]:new N,r.overSevenPointFiveCorners=e.OVER_CORNERS["over:7.5"]?e.OVER_CORNERS["over:7.5"]:new N,r.overEightPointFiveCorners=e.OVER_CORNERS["over:8.5"]?e.OVER_CORNERS["over:8.5"]:new N,r.overNinePointFiveCorners=e.OVER_CORNERS["over:9.5"]?e.OVER_CORNERS["over:9.5"]:new N,r.overTenPointFiveCorners=e.OVER_CORNERS["over:10.5"]?e.OVER_CORNERS["over:10.5"]:new N,r.overElevenPointFiveCorners=e.OVER_CORNERS["over:11.5"]?e.OVER_CORNERS["over:11.5"]:new N,r.overTwelvePointFiveCorners=e.OVER_CORNERS["over:12.5"]?e.OVER_CORNERS["over:12.5"]:new N,r.overThirteenPointFiveCorners=e.OVER_CORNERS["over:13.5"]?e.OVER_CORNERS["over:13.5"]:new N,r.doubleChance=e.DOUBLE_CHANCE,r.halfTimeFullTime=e.HT_FT,r.playerScore=e.PLAYER_SCORE,r.playerYellowCard=e.PLAYER_YELLOW_CARD,r.playerRedCard=e.PLAYER_RED_CARD,r.redCardMatch=e.RED_CARD_MATCH?e.RED_CARD_MATCH:new N,r.penaltyMatch=e.PENALTY_MATCH?e.PENALTY_MATCH:new N,r.playerScoreFirstGoal=e.PLAYER_SCORE_FIRST_GOAL,r.cornersMatch=e.CORNERS_MATCH,r.correctScore=e.CORRECT_SCORE,r.playerScoreHattrick=e.PLAYER_SCORE_HATTRICK,r.playerScoreTwice=e.PLAYER_SCORE_TWICE,r}};var _a=class{matchId=null;matchType=null;predictions=null};var Ia=class{remapPredictions=null;constructor(e,r){this.remapPredictions=new Zr(e,r)}remapResponse=e=>{let r=new _a;return r.matchId=e.match_id,r.matchType=e.match_type,r.predictions=this.remapPredictions.remapPredictionModel(e.predictions),r}};var Pa=class{matchId=null;matchType=null;market=null;matchModel=null};var Ra=class{value=null;target=null;playerId=null;playerModel=null;result=null};var Fa=class{matchId=null;matchType=null;market=null;matchModel=null;prediction=new Ra};var Sa=class{value=null;result=null};var Ta=class{matchId=null;matchType=null;market="CORRECT_SCORE";matchModel=null;prediction=new Sa};var Ea=class{matchId=null;matchModel=null;outcome=null};var Ca=class{remapPaginatedGames=e=>{let r=new ie;return r.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,r.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,r.data=e.data.map(n=>this.remapGamesListResponse(n)),r};remapGamesListResponse=e=>{let r=new lr;return r.id=e.id,r.title=e.title,r.description=e.description,r.type=e.type,r.status=e.status,r.predictionsCutoff=e.predictions_cutoff,r.fixtures=e.fixtures.map(n=>this.remapFixturesResponse(n)),r.createdAt=e.created_at,r.updatedAt=e.updated_at,r};remapFixturesResponse=e=>{let r=new Pa;return r.matchId=e.match_id,r.matchType=e.match_type,r.market=e.market,r};remapPaginatedUserTopXEditions=e=>{let r=new ie;return r.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,r.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,r.data=e.data.map(n=>this.remapUserTopXEditionsResponse(n)),r};remapUserTopXEditionsResponse=e=>{let r=new ar;return r.id=e.id,r.title=e.title,r.description=e.description,r.type=e.type,r.status=e.status,r.predictionsCutoff=e.predictions_cutoff,r.fixtures=e.fixtures.map(n=>this.remapTopXFixturesResponse(n)),r.createdAt=e.created_at,r.updatedAt=e.updated_at,r};remapTopXFixturesResponse=e=>{let r=new Ta;return r.matchId=e.match_id,r.matchType=e.match_type,r};remapPaginatedUserMathQuizEditions=e=>{let r=new ie;return r.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,r.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,r.data=e.data.map(n=>this.remapUserMatchQuizEditionsResponse(n)),r};remapUserMatchQuizEditionsResponse=e=>{let r=new Ft;return r.id=e.id,r.title=e.title,r.description=e.description,r.type=e.type,r.status=e.status,r.predictionsCutoff=e.predictions_cutoff,r.fixtures=e.fixtures.map(n=>this.remapMatchQuizFixturesResponse(n)),r.createdAt=e.created_at,r.updatedAt=e.updated_at,r};remapMatchQuizFixturesResponse=e=>{let r=new Fa;return r.matchId=e.match_id,r.matchType=e.match_type,r.market=e.market,r};remapPaginatedGameResults=e=>{let r=new ie;return r.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,r.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,r.data=e.data.map(n=>this.remapGameResults(n)),r};remapGameResults=e=>{let r=new sr;return r.userId=e.user_id,r.points=e.points?e.points:0,r.results=e.results.map(n=>this.remapResults(n)),r.tiebreaker=e.tiebreaker?this.remapTiebreaker(e.tiebreaker):null,r};remapResults=e=>{let r=new Ea;return r.matchId=e.match_id,r.outcome=e.outcome,r};remapTiebreaker=e=>{let r=new Yr;return r.goldenGoal=e.golden_goal,r}};var Aa=class{remapMetaData=e=>{let r=new Tr;return r.pagination.nextPageStartsAfter=e.pagination.next_page_starts_after,r.pagination.itemsPerPage=e.pagination.items_per_page,r}};var Yt=class{instanceAuth=null;instance=null;apiSignInUrl=null;clientApiSignInUrl=null;predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;metaRemapper=null;constructor(e,r){let n=Ee(e.environment,"predictor");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.predictionRemapper=new Zr(e,r),this.matchSummaryRemapper=new Ia(e,r),this.gamesRemapper=new Ca,this.metaRemapper=new Aa,this.instanceAuth=jl.default.create({baseURL:n,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instance=jl.default.create({baseURL:n,headers:{"Content-Type":"application/json"}})}makeFootballPrediction=async e=>{try{let r=this.predictionRemapper.remapRequestBody(e),n=await this.instanceAuth.post(`/predictions${this.apiSignInUrl}`,JSON.stringify(r));return await this.predictionRemapper.remapResponseObjBody(n.data)}catch(r){throw console.warn("There was a problem making POST request: ",r),r.response}};getMatchSummary=async e=>{try{let r=await this.instance.get(`/predictions/summary/${e}${this.apiSignInUrl}`);return this.matchSummaryRemapper.remapResponse(r.data)}catch(r){throw console.warn(`There was a problem fetching predictions for match: ${e} `,r),r.response}};deleteFootballPrediction=async e=>{try{return await this.instanceAuth.delete(`/predictions/${e}${this.apiSignInUrl}`),!0}catch(r){throw console.warn(`There was a problem deleting your prediction: ${e}`,r),r.response}};getMyPredictions=async e=>{try{let r=new ie,n=`/predictions${this.apiSignInUrl}`;e&&(n+=`${e.constructFiltersUrl()}`);let a=await this.instanceAuth.get(n);return r.meta=this.metaRemapper.remapMetaData(a.data.meta),r.data=await this.predictionRemapper.remapResponseArrayBody(a.data.data),r}catch(r){throw console.warn("There was a problem fetching own predictions",r),r.response}};getMyPredictionsNoRemap=async e=>{try{return(await this.instanceAuth.get(`/predictions${this.apiSignInUrl}${e.constructFiltersUrl()}`)).data.data}catch(r){throw console.warn("There was a problem fetching own predictions",r),r.response}};getUserPredictions=async(e,r,n)=>{try{let a=new ie,c=`/predictions/users/${e}${this.apiSignInUrl}`,f=Date.now();n&&(c+=`${n.constructFiltersUrl()}`),r&&(c+=`&disable_cache=${f}`);let g=await this.instance.get(c);return a.meta=this.metaRemapper.remapMetaData(g.data.meta),a.data=await this.predictionRemapper.remapResponseArrayBody(g.data.data),a}catch(a){throw console.warn(`There was a problem fetching predictions for user: ${e}`,a),a.response}};getUserPredictionsNoRemap=async(e,r)=>{try{return(await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}${r.constructFiltersUrl()}`)).data.data}catch(n){throw console.warn(`There was a problem fetching predictions for user: ${e}`,n),n.response}};getGames=async(e,r)=>{try{let n=`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,a=Date.now();r&&(n+=`&disable_cache=${a}`);let c=await this.instance.get(n);return this.gamesRemapper.remapPaginatedGames(c.data)}catch(n){throw console.warn("There was a problem fetching the games list",n),n.response}};getGameById=async(e,r)=>{try{let n=`/games/${e}${this.apiSignInUrl}`,a=Date.now();r&&(n+=`&disable_cache=${a}`);let c=await this.instance.get(n);return this.gamesRemapper.remapGamesListResponse(c.data)}catch(n){throw console.warn(`There was a problem fetching the following game: ${e}`,n),n.response}};getGamePredictions=async(e,r,n)=>{try{let a=new ie,c=`/games/${e}/predictions${this.apiSignInUrl}`,f=Date.now();n&&(c+=`${n.constructFiltersUrl()}`),r&&(c+=`&disable_cache=${f}`);let g=await this.instance.get(c);return a.meta=this.metaRemapper.remapMetaData(g.data.meta),a.data=await this.predictionRemapper.remapResponseArrayBody(g.data.data),a}catch(a){throw console.warn(`There was a problem fetching the predictions for game: ${e}`,a),a.response}};getUserGameEditions=async(e,r)=>{try{let n=null,a=`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,c=Date.now();r&&(a+=`&disable_cache=${c}`);let f=await this.instance.get(a);return f.data.data.forEach(g=>{g.type==="TOP_X"?n=this.gamesRemapper.remapPaginatedUserTopXEditions(f.data):g.type==="MATCH_QUIZ"&&(n=this.gamesRemapper.remapPaginatedUserMathQuizEditions(f.data))}),n}catch(n){throw console.warn("There was a problem fetching the games list",n),n.response}};getGameResults=async(e,r,n)=>{try{let a=`/games/${e}/results/${this.apiSignInUrl}`,c=Date.now();n&&(a+=`${n.constructFiltersUrl()}`),r&&(a+=`&disable_cache=${c}`);let f=await this.instance.get(a);return this.gamesRemapper.remapPaginatedGameResults(f.data)}catch(a){throw console.warn(`There was a problem fetching the results for the following game: ${e}`,a),a.response}}};var xa=class{fullCoverageCompetitions=null;markets=null};var Oa=class{remapConfig=e=>{let r=new xa;return r.fullCoverageCompetitions=e.full_coverage_competitions,r.markets=e.markets,r}};var La=class{gameInstanceId=null;fixtures=null};var Ba=class{predictorHttps=null;clientHttps=null;idMapping=null;predictorConfigRemapper=null;predictorService=null;constructor(e,r,n,a){this.predictorHttps=r,this.idMapping=a,this.clientHttps=n,this.predictorConfigRemapper=new Oa,this.predictorService=new dt(e,a)}makeFootballPrediction=async(e,r,n,a)=>{let c=this.predictorService.validateFixture(e,r,n,a),f=new La;if(c)if(this.idMapping.idSchema!=="native"){let g=c.matchId,v="",S=await this.predictorService.remapMatchIdToNative([g]);if(c.matchId=S[0],!c.matchId)throw new Error("Match id is invalid!");if(c instanceof nt&&(v=c.prediction.playerId,c.prediction.playerId=await this.predictorService.remapPlayerIdToNative([v]),!c.prediction.playerId))throw new Error("Player id is invalid!");f.fixtures=[c];let M=await this.predictorHttps.makeFootballPrediction(f);return M.fixtures.map(F=>{F.prediction.playerId&&(F.prediction.playerId=v),F.matchId=g}),M}else return f.fixtures=[c],await this.predictorHttps.makeFootballPrediction(f);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 n=(await this.predictorService.remapMatchIdToNative([e]))[0],a=await this.predictorHttps.getMatchSummary(n);a.matchId=e;let c=a.predictions,f=await this.predictorService.remapPlayerIdToIdSchema(c);return a.predictions=f,a}else return await this.predictorHttps.getMatchSummary(e)};getMarketSummary=async(e,r,n)=>{try{let a=await this.getMatchSummary(e);return this.predictorService.getMarketSummary(a,r,n)}catch(a){return a.message}};getConfig=async()=>{let e=await this.clientHttps.getConfig(),r=await this.predictorConfigRemapper.remapConfig(e.predictor);return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(r):r};deleteFootballPrediction=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyPredictions=async e=>(e&&(e=new se(e)),await this.predictorHttps.getMyPredictions(e));getMyCurrentPredictions=async e=>{if(e)e.status&&delete e.status,e.status=["ACTIVE"],e=new se(e);else{let r={status:["ACTIVE"]};e=new se(r)}return await this.getMyPredictions(e)};getMyPastPredictions=async e=>{if(e)e.status&&delete e.status,e.status=Ni,e=new se(e);else{let r={status:Ni};e=new se(r)}return await this.getMyPredictions(e)};getUserPredictions=async(e,r,n)=>(n=n||!1,r&&(r=new se(r)),await this.predictorHttps.getUserPredictions(e,n,r));getUserCurrentPredictions=async(e,r)=>{if(r)r.status&&delete r.status,r.status=["ACTIVE"],r=new se(r);else{let n={status:["ACTIVE"]};r=new se(n)}return await this.getUserPredictions(e,r)};getUserPastPredictions=async(e,r)=>{if(r)r.status&&delete r.status,r.status=Ni,r=new se(r);else{let n={status:Ni};r=new se(n)}return await this.getUserPredictions(e,r)}};var Xm=Dt(Gt());var jr=class{instance=null;apiSignInUrl="";constructor(e){let r=Ee(e.environment,"client");this.apiSignInUrl=`/clients/${e.clientId}/features?key=${e.apiKey}`,this.instance=Xm.default.create({baseURL:r,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 Na=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(e){this.idMapping=new he(e),this.predictorHttps=new Yt(e,this.idMapping),this.clientHttps=new jr(e),this.predictorFacade=new Ba(e,this.predictorHttps,this.clientHttps,this.idMapping)}makeFootballPrediction=async(e,r,n,a)=>await this.predictorFacade.makeFootballPrediction(e,r,n,a);getMatchSummary=async e=>await this.predictorFacade.getMatchSummary(e);getMarketSummary=async(e,r,n)=>await this.predictorFacade.getMarketSummary(e,r,n);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,r,n)=>await this.predictorFacade.getUserPredictions(e,r,n);getUserCurrentPredictions=async(e,r)=>await this.predictorFacade.getUserCurrentPredictions(e,r);getUserPastPredictions=async(e,r)=>await this.predictorFacade.getUserPastPredictions(e,r)};var Ym=Dt(Gt());var Ua=class{rankType=null;fromDate=null;toDate=null;pagination=new Lr};var Da=class{position=null;profileId=null;profileModel=null;points=null};var Ga=class{remapMeta=e=>{let r=new Ua;return r.rankType=e.rank_type,r.fromDate=e.from_date,r.toDate=e.to_date,r.pagination.currentPage=e.pagination.current_page,r.pagination.itemsPerPage=e.pagination.items_per_page,r.pagination.totalItems=e.pagination.total_items,r.pagination.numberOfPages=e.pagination.number_of_pages,r};remapResponseData=e=>{let r=[];return e.forEach(n=>{let a=new Da;a.position=n.position,a.profileId=n.profile_id,a.points=n.points,r.push(a)}),r}};var $a=class{id=null;name=null;type=null;fromDate=null;toDate=null;markets=[];teamIds=[];matchIds=[];gameIds=[];gameTypes=[];competitionIds=[]};var Ha=class{remapResponse=e=>{let r=[];return e.forEach(n=>{let a=new $a;a.id=n.id,a.name=n.name,a.type=n.type,a.fromDate=n.from_date,a.toDate=n.to_date,a.markets=n.markets?n.markets:null,a.teamIds=n.team_ids?n.team_ids:null,a.matchIds=n.match_ids?n.match_ids:null,a.gameIds=n.game_ids?n.game_ids:null,a.gameTypes=n.game_types?n.game_types:null,a.competitionIds=n.competition_ids?n.competition_ids:null,r.push(a)}),r};remapMeta=e=>{let r={};return r.totalItems=e.pagination.total_items,r}};var Va=class{instance=null;apiSignInUrl=null;clientApiSignInUrl=null;templateRemapper=null;leaderboardRemapper=null;constructor(e){let r=Ee(e.environment,"loyalty");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.templateRemapper=new Ha,this.leaderboardRemapper=new Ga,this.instance=Ym.default.create({baseURL:r,headers:{"Content-Type":"application/json"}})}getTemplates=async e=>{try{let r=`/leaderboard/templates/${this.apiSignInUrl}`,n=Date.now();e&&(r+=`&disable_cache=${n}`);let a=await this.instance.get(r),c=JSON.parse(JSON.stringify(a.data));return c.meta=this.templateRemapper.remapMeta(a.data.meta),c.data=this.templateRemapper.remapResponse(a.data.data),c}catch(r){throw console.warn("There was a problem fetching the list of templates",r),r.response}};getLeaderboard=async(e,r,n)=>{try{let a=`/leaderboard/${e}/${this.apiSignInUrl}`,c=Date.now();r&&(a+=`&disable_cache=${c}`),n&&(a+=`${n.constructFiltersUrl()}`);let f=await this.instance.get(a),g=JSON.parse(JSON.stringify(f.data));return g.meta=this.leaderboardRemapper.remapMeta(f.data.meta),g.data=this.leaderboardRemapper.remapResponseData(f.data.data),g}catch(a){throw console.warn(`There was a problem fetching the leaderboard for the following template: ${e}`,a),a.response}};getLeaderboardForGame=async(e,r,n)=>{try{let a=`/leaderboard/games/${e}/${this.apiSignInUrl}`,c=Date.now();r&&(a+=`&disable_cache=${c}`),n&&(a+=`${n.constructFiltersUrl()}`);let f=await this.instance.get(a),g=JSON.parse(JSON.stringify(f.data));return qn(g)}catch(a){throw console.warn(`There was a problem fetching the leaderboard for the following game: ${e}`,a),a.response}}};var Di=class{limit=null;page=null;constructor(e){this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null}constructFiltersUrl=()=>{let e="";return this.limit&&(e+="&",e+=`limit=${this.limit}`),this.page&&(e+="&",e+=`page=${this.page}`),e}};var qa=class{general=[];predictor=[];topX=[]};var ka=class{enabled=!1;rewards=null};var Wa=class{general=null;topX=null;predictor=null};var Ka=class{points=null;tiers=null;badges=null};var Xa=class{remapLoyaltyResponse=e=>{let r=new ka;return r.enabled=e.enabled,r.rewards=this.remapRewards(e.rewards),r};remapRewards=e=>{let r=new Ka;return r.points=this.remapPoints(e.points),r.tiers=e.tiers,r.badges=this.remapBadges(e.badges),r};remapPoints=e=>{let r=new Wa;return r.general=e.general,r.topX=e.top_x,r.predictor=e.predictor,r};remapBadges=e=>{let r=new qa;return r.general=e.general,r.predictor=e.predictor,r.topX=e.top_x,r}};var Ya=class{idMappingService=null;profileNamespace=null;constructor(e){this.idMappingService=new he(e),this.profileNamespace=new $r(e)}remapTemplatesIds=async e=>{if(e.length>0){let r=[],n=[],a=[],c=[],f=[],g=[];e.forEach(M=>{M.teamIds&&M.teamIds.length>0?r=[...r,...M.teamIds]:M.matchIds&&M.matchIds.length>0?a=[...a,...M.matchIds]:M.competitionIds&&M.competitionIds.length>0&&(f=[...f,...M.competitionIds])});let v={team:r,match:a,competition:f},S=await this.idMappingService.idMappingFacade.getEntitiesByIds(v,"native",this.idMappingService.idSchema);return n=[...S.team],c=[...S.match],g=[...S.competition],e.forEach(M=>{M.teamIds&&M.teamIds.length>0?M.teamIds=M.teamIds.map(F=>F=S.team.shift()):M.matchIds&&M.matchIds.length>0?M.matchIds=M.matchIds.map(F=>F=S.match.shift()):M.competitionIds&&M.competitionIds.length>0&&(M.competitionIds=M.competitionIds.map(F=>F=S.competition.shift()))}),e}return e};addProfileModel=async e=>{if(e.length>0){let r=[],n=[];e.forEach(c=>{r.push(c.profileId)});let a=await this.profileNamespace.getByIds(r);return e.forEach(c=>{a.forEach(f=>{f.id===c.profileId&&(delete f.interests,c.profileModel=f)}),c.profileModel||(c.profileModel=null),n.push(c)}),n}return e}};var za=class{config=null;clientHttps=null;loyaltyHttps=null;loyaltyRemapper=null;loyaltyService=null;constructor(e,r,n){this.config=e,this.clientHttps=r,this.loyaltyHttps=n,this.loyaltyRemapper=new Xa,this.loyaltyService=new Ya(this.config)}getConfig=async()=>{let e=await this.clientHttps.getConfig();return this.loyaltyRemapper.remapLoyaltyResponse(e.loyalty)};getTemplates=async e=>{if(e=e||!1,this.config.idSchema==="native")return await this.loyaltyHttps.getTemplates(e);let r=await this.loyaltyHttps.getTemplates(e);return r.data=await this.loyaltyService.remapTemplatesIds([...r.data]),r};getLeaderboard=async(e,r,n)=>{n=n||!1,r&&(r=new Di(r));let a=await this.loyaltyHttps.getLeaderboard(e,n,r);return a.data=await this.loyaltyService.addProfileModel(a.data),a};getLeaderboardForGame=async(e,r,n)=>{n=n||!1,r&&(r=new Di(r));let a=await this.loyaltyHttps.getLeaderboardForGame(e,n,r);return a.data=await this.loyaltyService.addProfileModel(a.data),a}};var Ja=class{clientHttps=null;loyaltyHttps=null;loyaltyFacade=null;constructor(e){this.clientHttps=new jr(e),this.loyaltyHttps=new Va(e),this.loyaltyFacade=new za(e,this.clientHttps,this.loyaltyHttps)}getConfig=()=>this.loyaltyFacade.getConfig();getTemplates=e=>this.loyaltyFacade.getTemplates(e);getLeaderboard=(e,r,n)=>this.loyaltyFacade.getLeaderboard(e,r,n);getLeaderboardForGame=(e,r,n)=>this.loyaltyFacade.getLeaderboardForGame(e,r,n)};var Qa=class{idMapping=null;predictorHttps=null;predictorService=null;constructor(e,r){this.idMapping=r,this.predictorHttps=new Yt(e,r),this.predictorService=new dt(e,r)}getGames=async(e,r)=>{r=r||!1;let n=this.predictorService.initGameFilters("TOP_X",e),a=await this.predictorHttps.getGames(n,r);return await this.predictorService.remapMatchIdsFixtures(a)};getGameById=async(e,r)=>{r=r||!1;let n=await this.predictorHttps.getGameById(e,r);return await this.predictorService.remapMatchIdsFixtures(n)};getGamePredictions=async(e,r,n)=>(n=n||!1,r&&(r.type&&delete r.type,r.status&&delete r.status,r=new se(r)),await this.predictorHttps.getGamePredictions(e,n,r));getGameResults=async(e,r,n)=>{n=n||!1,r&&(r.type&&delete r.type,r.gameIds&&delete r.gameIds,r=new $e(r));let a=await this.predictorHttps.getGameResults(e,n,r);return await this.predictorService.remapMatchIdsFixtures(a)};getCurrentGameResults=async e=>{e=e||!1;let r={status:"OPEN",type:"TOP_X"};r=new $e(r);let n=await this.predictorHttps.getGames(r,e),a=this.predictorService.getCurrentGameId(n);return(await this.getGameResults(a,null,e)).data[0]};play=async e=>{let r=new Qr(e);if(this.idMapping.idSchema!=="native"){let a=[];r.fixtures.forEach(f=>a.push(f.matchId));let c=await this.predictorService.remapMatchIdToNative(a);r.fixtures.forEach(f=>f.matchId=c.shift())}let n=await this.predictorHttps.makeFootballPrediction(r);return n.fixtures.forEach(a=>{a.matchId=a.matchModel.id}),n};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyGameEditions=async(e,r)=>{r=r||!1;let n=this.predictorService.initGameTypePredictions("TOP_X"),a=[],c=await this.predictorHttps.getMyPredictionsNoRemap(n);if(c.length>0){c.forEach(v=>{v.game_instance_id&&a.push(v.game_instance_id)});let f=this.predictorService.initGameFilters("TOP_X",e,a),g=await this.predictorHttps.getUserGameEditions(f,r);return await this.predictorService.addPredictionProp(c,g)}else return new ie};getMyGamePrediction=async e=>{let r=this.predictorService.initGameTypePredictions("TOP_X"),n=await this.predictorHttps.getMyPredictions(r);return n.data.length>0?n.data.filter(c=>c.gameInstanceId===e)[0]:null};getUserGameEditions=async(e,r,n)=>{n=n||!1;let a=this.predictorService.initGameTypePredictions("TOP_X"),c=[],f=await this.predictorHttps.getUserPredictionsNoRemap(e,a);if(f.length>0){f.forEach(S=>{S.game_instance_id&&c.push(S.game_instance_id)});let g=this.predictorService.initGameFilters("TOP_X",r,c),v=await this.predictorHttps.getUserGameEditions(g,n);return await this.predictorService.addPredictionProp(f,v)}else return new ie};getUserGamePrediction=async(e,r,n)=>{n=n||!1;let a=this.predictorService.initGameTypePredictions("TOP_X"),c=await this.predictorHttps.getUserPredictions(e,n,a);return c.data.length>0?c.data.filter(g=>g.gameInstanceId===r)[0]:null}};var Za=class{topXFacade=null;idMapping=null;constructor(e){this.idMapping=new he(e),this.topXFacade=new Qa(e,this.idMapping)}getGames=async(e,r)=>await this.topXFacade.getGames(e,r);getGameById=async(e,r)=>await this.topXFacade.getGameById(e,r);getGamePredictions=async(e,r,n)=>await this.topXFacade.getGamePredictions(e,r,n);getGameResults=async(e,r,n)=>await this.topXFacade.getGameResults(e,r,n);getCurrentGameResults=async e=>await this.topXFacade.getCurrentGameResults(e);play=async e=>await this.topXFacade.play(e);delete=async e=>await this.topXFacade.delete(e);getMyGameEditions=async(e,r)=>await this.topXFacade.getMyGameEditions(e,r);getMyGamePrediction=async e=>await this.topXFacade.getMyGamePrediction(e);getUserGameEditions=async(e,r,n)=>await this.topXFacade.getUserGameEditions(e,r,n);getUserGamePrediction=async(e,r,n)=>await this.topXFacade.getUserGamePrediction(e,r,n)};var ja=class{predictorHttps=null;predictorService=null;idMapping=null;constructor(e){this.idMapping=new he(e),this.predictorHttps=new Yt(e,this.idMapping),this.predictorService=new dt(e,this.idMapping)}play=async e=>{let r=e.fixtures.map(n=>this.predictorService.validateFixture(n.matchId,n.market,n.prediction.value,n.prediction.playerId));if(r){if(this.idMapping.idSchema!=="native"){let n=[],a=[];r.forEach(g=>{n.push(g.matchId),g instanceof nt&&a.push(g.prediction.playerId)});let c=await this.predictorService.remapMatchIdToNative(n),f={};a&&a.length>0&&(f=await this.predictorService.remapPlayerIdMapToNative(a)),r.forEach((g,v)=>{g.matchId=c[v],g instanceof nt&&(g.prediction.playerId=f[g.prediction.playerId])})}}else throw new Error("The prediction is invalid. Please check again have you passed appropriate prediction model");return e.fixtures=r,await this.predictorHttps.makeFootballPrediction(e)};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getGames=async(e,r)=>{r=r||!1;let n=this.predictorService.initGameFilters("MATCH_QUIZ",e),a=await this.predictorHttps.getGames(n,r);return await this.predictorService.remapMatchIdsFixtures(a)};getGameById=async(e,r)=>{r=r||!1;let n=await this.predictorHttps.getGameById(e,r);return await this.predictorService.remapMatchIdsFixtures(n)};getGamePredictions=async(e,r,n)=>(n=n||!1,r&&(r.type&&delete r.type,r.status&&delete r.status,r=new se(r)),await this.predictorHttps.getGamePredictions(e,n,r));getGameResults=async(e,r,n)=>{n=n||!1,r&&(r.type&&delete r.type,r.gameIds&&delete r.gameIds,r=new $e(r));let a=await this.predictorHttps.getGameResults(e,n,r);return await this.predictorService.remapMatchIdsFixtures(a)};getCurrentGameResults=async e=>{e=e||!1;let r={status:"OPEN",type:"MATCH_QUIZ"};r=new $e(r);let n=await this.predictorHttps.getGames(r,e),a=this.predictorService.getCurrentGameId(n);return(await this.getGameResults(a,null,e)).data[0]};getMyGameEditions=async(e,r)=>{r=r||!1;let n=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),a=[],c=await this.predictorHttps.getMyPredictionsNoRemap(n);if(c.length>0){c.forEach(v=>{v.game_instance_id&&a.push(v.game_instance_id)});let f=this.predictorService.initGameFilters("MATCH_QUIZ",e,a),g=await this.predictorHttps.getUserGameEditions(f,r);return await this.predictorService.addPredictionProp(c,g)}else return new ie};getMyGamePrediction=async e=>{let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),n=await this.predictorHttps.getMyPredictions(r);return n.data.length>0?n.data.filter(c=>c.gameInstanceId===e)[0]:null};getUserGameEditions=async(e,r,n)=>{n=n||!1;let a=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),c=[],f=await this.predictorHttps.getUserPredictionsNoRemap(e,a);if(f.length>0){f.forEach(S=>{S.game_instance_id&&c.push(S.game_instance_id)});let g=this.predictorService.initGameFilters("MATCH_QUIZ",r,c),v=await this.predictorHttps.getUserGameEditions(g,n);return await this.predictorService.addPredictionProp(f,v)}else return new ie};getUserGamePrediction=async(e,r,n)=>{n=n||!1;let a=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),c=await this.predictorHttps.getUserPredictions(e,n,a);return c.data.length>0?c.data.filter(g=>g.gameInstanceId===r)[0]:null}};var es=class{matchQuizFacade=null;constructor(e){this.matchQuizFacade=new ja(e)}play=async e=>await this.matchQuizFacade.play(e);delete=async e=>await this.matchQuizFacade.delete(e);getGames=async(e,r)=>await this.matchQuizFacade.getGames(e,r);getGameById=async(e,r)=>await this.matchQuizFacade.getGameById(e,r);getGamePredictions=async(e,r,n)=>await this.matchQuizFacade.getGamePredictions(e,r,n);getGameResults=async(e,r,n)=>await this.matchQuizFacade.getGameResults(e,r,n);getCurrentGameResults=async e=>await this.matchQuizFacade.getCurrentGameResults(e);getMyGameEditions=async(e,r)=>await this.matchQuizFacade.getMyGameEditions(e,r);getMyGamePrediction=async e=>await this.matchQuizFacade.getMyGamePrediction(e);getUserGameEditions=async(e,r,n)=>await this.matchQuizFacade.getUserGameEditions(e,r,n);getUserGamePrediction=async(e,r,n)=>await this.matchQuizFacade.getUserGamePrediction(e,r,n)};var Gi=class{action=null;page=null;limit=null;constructor(e){this.action=e.action?e.action:null,this.page=e.page?e.page:null,this.limit=e.limit?e.limit:null}constructFilterUrl=()=>{let e="";return this.action&&(e+="&",e+=`action=${this.action}`),this.page&&(e+="&",e+=`page=${this.page}`),this.limit&&(e+="&",e+=`limit=${this.limit}`),e}};var $i=class{action=null;context=new Ur;constructor(e,r,n,a){this.action=e,this.context.tags=r,n&&(this.context.content=n),a&&(this.context.campaign=a)}};var ts=class{idSchema;idMapping;constructor(e){this.idSchema=e.idSchema,this.idMapping=new he(e)}remapTagsIds=async(e,r,n)=>{let a={},c={},f=[];e.forEach(v=>{a.hasOwnProperty(v.type)||(a[v.type]=[],c[v.type]=[]),a[v.type].push(v.id),c[v.type].push(v)});let g=await this.idMapping.idMappingFacade.getEntitiesByIds(a,r,n);for(let[v,S]of Object.entries(c))S.forEach((M,F)=>{M.id=g[v][F],f.push(M)});return f}};var rs=class{idSchema;activityHttps;activityService;constructor(e){this.idSchema=e.idSchema,this.activityHttps=new Gr(e),this.activityService=new ts(e)}add=async(e,r,n,a)=>{if(this.idSchema!="native"){let f=JSON.parse(JSON.stringify(r)),g=await this.activityService.remapTagsIds(r,this.idSchema,"native"),v=new $i(e,g,n,a),S=await this.activityHttps.createActivity(v);return S.context.tags=f,S}let c=new $i(e,r,n,a);return this.activityHttps.createActivity(c)};delete=async e=>await this.activityHttps.deleteActivity(e);like=async(e,r,n)=>{let a="like";return await this.add(a,e,r,n)};dislike=async(e,r,n)=>{let a="dislike";return await this.add(a,e,r,n)};addPageview=async(e,r,n)=>{let a="page_view";return await this.add(a,e,r,n)};addContentConsumed=async(e,r,n)=>{let a="content_consumed";return await this.add(a,e,r,n)};addShare=async(e,r,n)=>{let a="share";return await this.add(a,e,r,n)};addComment=async(e,r,n)=>{let a="comment";return await this.add(a,e,r,n)};addClickAd=async(e,r,n)=>{let a="click_ad";return await this.add(a,e,r,n)};addConversion=async(e,r,n)=>{let a="conversion";return await this.add(a,e,r,n)};getOwn=async(e,r)=>{if(r=r||!1,e&&(e=new Gi(e)),this.idSchema!="native"){let n=await this.activityHttps.getOwnActivities(e,r);for(let a of n.data)await this.activityService.remapTagsIds(a.context.tags,"native",this.idSchema);return n}return await this.activityHttps.getOwnActivities(e,r)};getForUser=async(e,r,n)=>{if(n=n||!1,r&&(r=new Gi(r)),this.idSchema!="native"){let a=await this.activityHttps.getActivitiesForUser(e,r,n);for(let c of a.data)await this.activityService.remapTagsIds(c.context.tags,"native",this.idSchema);return a}return await this.activityHttps.getActivitiesForUser(e,r,n)}};var is=class{activityFacade;constructor(e){this.activityFacade=new rs(e)}add=async(e,r,n,a)=>await this.activityFacade.add(e,r,n,a);delete=async e=>await this.activityFacade.delete(e);like=async(e,r,n)=>await this.activityFacade.like(e,r,n);dislike=async(e,r,n)=>await this.activityFacade.dislike(e,r,n);addPageview=async(e,r,n)=>await this.activityFacade.addPageview(e,r,n);addContentConsumed=async(e,r,n)=>await this.activityFacade.addContentConsumed(e,r,n);addShare=async(e,r,n)=>await this.activityFacade.addShare(e,r,n);addComment=async(e,r,n)=>await this.activityFacade.addComment(e,r,n);addClickAd=async(e,r,n)=>await this.activityFacade.addClickAd(e,r,n);addConversion=async(e,r,n)=>await this.activityFacade.addConversion(e,r,n);getOwn=async(e,r)=>await this.activityFacade.getOwn(e,r);getForUser=async(e,r,n)=>await this.activityFacade.getForUser(e,r,n)};function Mx(s){let r=new na().validate(s);if(r.idSchema.validation==="missing"&&(console.warn(r.idSchema.message.text),s.idSchema="native"),r.environment.validation==="missing"&&(console.warn(r.environment.message.text),s.environment="prod"),r.lang.validation==="missing"&&(console.warn(r.lang.message.text),s.lang="en"),r.isValid)return{profile:new $r(s),football:new oa(s),predictor:new Na(s),loyalty:new Ja(s),topX:new Za(s),matchQuiz:new es(s),activity:new is(s)};throw new Error("Configuration is not valid")}export{Mx as FansUnitedSDK};
|
|
22
22
|
/**
|
|
23
23
|
* @license
|
|
24
24
|
* Lodash <https://lodash.com/>
|