fansunited-sdk-esm 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -18,7 +18,7 @@ __p += '`),H&&(R+=`' +
18
18
  function print() { __p += __j.call(arguments, '') }
19
19
  `:`;
20
20
  `)+R+`return __p
21
- }`;var D=em(function(){return q(m,C+"return "+R).apply(s,f)});if(D.source=R,Dl(D))throw D;return D}function _b(r){return W(r).toLowerCase()}function Rb(r){return W(r).toUpperCase()}function Fb(r,i,o){if(r=W(r),r&&(o||i===s))return pc(r);if(!r||!(i=De(i)))return r;var l=nt(r),c=nt(i),m=cc(l,c),f=uc(l,c)+1;return Vt(l,m,f).join("")}function Sb(r,i,o){if(r=W(r),r&&(o||i===s))return r.slice(0,dc(r)+1);if(!r||!(i=De(i)))return r;var l=nt(r),c=uc(l,nt(i))+1;return Vt(l,0,c).join("")}function Tb(r,i,o){if(r=W(r),r&&(o||i===s))return r.replace(Ds,"");if(!r||!(i=De(i)))return r;var l=nt(r),c=cc(l,nt(i));return Vt(l,c).join("")}function Eb(r,i){var o=Pd,l=Id;if(Z(i)){var c="separator"in i?i.separator:c;o="length"in i?N(i.length):o,l="omission"in i?De(i.omission):l}r=W(r);var m=r.length;if(vr(r)){var f=nt(r);m=f.length}if(o>=m)return r;var g=o-Pr(l);if(g<1)return l;var M=f?Vt(f,0,g).join(""):r.slice(0,g);if(c===s)return M+l;if(f&&(g+=M.length-g),Ul(c)){if(r.slice(g).search(c)){var I,_=M;for(c.global||(c=el(c.source,W(xp.exec(c))+"g")),c.lastIndex=0;I=c.exec(_);)var R=I.index;M=M.slice(0,R===s?g:R)}}else if(r.indexOf(De(c),g)!=g){var T=M.lastIndexOf(c);T>-1&&(M=M.slice(0,T))}return M+l}function Cb(r){return r=W(r),r&&$d.test(r)?r.replace(Tp,oh):r}var xb=Tr(function(r,i,o){return r+(o?" ":"")+i.toUpperCase()}),Hl=tu("toUpperCase");function ju(r,i,o){return r=W(r),i=o?s:i,i===s?eh(r)?lh(r):Wf(r):r.match(i)||[]}var em=U(function(r,i){try{return Le(r,s,i)}catch(o){return Dl(o)?o:new B(o)}}),Ab=Ft(function(r,i){return Ke(i,function(o){o=ft(o),_t(r,o,Ll(r[o],r))}),r});function Ob(r){var i=r==null?0:r.length,o=x();return r=i?J(r,function(l){if(typeof l[1]!="function")throw new Xe(a);return[o(l[0]),l[1]]}):[],U(function(l){for(var c=-1;++c<i;){var m=r[c];if(Le(m[0],this,l))return Le(m[1],this,l)}})}function Bb(r){return og(ze(r,F))}function kl(r){return function(){return r}}function Lb(r,i){return r==null||r!==r?i:r}var Nb=iu(),Db=iu(!0);function Ce(r){return r}function Vl(r){return Oc(typeof r=="function"?r:ze(r,F))}function Ub(r){return Lc(ze(r,F))}function Gb(r,i){return Nc(r,ze(i,F))}var $b=U(function(r,i){return function(o){return Ci(o,r,i)}}),Hb=U(function(r,i){return function(o){return Ci(r,o,i)}});function ql(r,i,o){var l=pe(i),c=Tn(i,l);o==null&&!(Z(i)&&(c.length||!l.length))&&(o=i,i=r,r=this,c=Tn(i,pe(i)));var m=!(Z(o)&&"chain"in o)||!!o.chain,f=Tt(r);return Ke(c,function(g){var M=i[g];r[g]=M,f&&(r.prototype[g]=function(){var I=this.__chain__;if(m||I){var _=r(this.__wrapped__),R=_.__actions__=Se(this.__actions__);return R.push({func:M,args:arguments,thisArg:r}),_.__chain__=I,_}return M.apply(r,Nt([this.value()],arguments))})}),r}function kb(){return le._===this&&(le._=fh),this}function Wl(){}function Vb(r){return r=N(r),U(function(i){return Dc(i,r)})}var qb=Pl(J),Wb=Pl(nc),Kb=Pl(Xs);function tm(r){return El(r)?Ys(ft(r)):Pg(r)}function Xb(r){return function(i){return r==null?s:sr(r,i)}}var Yb=ou(),zb=ou(!0);function Kl(){return[]}function Xl(){return!1}function Qb(){return{}}function Jb(){return""}function Zb(){return!0}function jb(r,i){if(r=N(r),r<1||r>Bt)return[];var o=ut,l=fe(r,ut);i=x(i),r-=ut;for(var c=Js(l,i);++o<r;)i(o);return c}function ev(r){return L(r)?J(r,ft):Ue(r)?[r]:Se(vu(W(r)))}function tv(r){var i=++mh;return W(r)+i}var rv=Bn(function(r,i){return r+i},0),iv=Il("ceil"),nv=Bn(function(r,i){return r/i},1),ov=Il("floor");function av(r){return r&&r.length?Sn(r,Ce,ll):s}function sv(r,i){return r&&r.length?Sn(r,x(i,2),ll):s}function lv(r){return sc(r,Ce)}function pv(r,i){return sc(r,x(i,2))}function cv(r){return r&&r.length?Sn(r,Ce,ml):s}function uv(r,i){return r&&r.length?Sn(r,x(i,2),ml):s}var mv=Bn(function(r,i){return r*i},1),dv=Il("round"),fv=Bn(function(r,i){return r-i},0);function hv(r){return r&&r.length?Qs(r,Ce):0}function gv(r,i){return r&&r.length?Qs(r,x(i,2)):0}return u.after=UM,u.ary=Au,u.assign=Rw,u.assignIn=Ku,u.assignInWith=Xn,u.assignWith=Fw,u.at=Sw,u.before=Ou,u.bind=Ll,u.bindAll=Ab,u.bindKey=Bu,u.castArray=QM,u.chain=Eu,u.chunk=oy,u.compact=ay,u.concat=sy,u.cond=Ob,u.conforms=Bb,u.constant=kl,u.countBy=hM,u.create=Tw,u.curry=Lu,u.curryRight=Nu,u.debounce=Du,u.defaults=Ew,u.defaultsDeep=Cw,u.defer=GM,u.delay=$M,u.difference=ly,u.differenceBy=py,u.differenceWith=cy,u.drop=uy,u.dropRight=my,u.dropRightWhile=dy,u.dropWhile=fy,u.fill=hy,u.filter=yM,u.flatMap=bM,u.flatMapDeep=vM,u.flatMapDepth=PM,u.flatten=Ru,u.flattenDeep=gy,u.flattenDepth=yy,u.flip=HM,u.flow=Nb,u.flowRight=Db,u.fromPairs=My,u.functions=Dw,u.functionsIn=Uw,u.groupBy=IM,u.initial=by,u.intersection=vy,u.intersectionBy=Py,u.intersectionWith=Iy,u.invert=$w,u.invertBy=Hw,u.invokeMap=RM,u.iteratee=Vl,u.keyBy=FM,u.keys=pe,u.keysIn=Ee,u.map=Hn,u.mapKeys=Vw,u.mapValues=qw,u.matches=Ub,u.matchesProperty=Gb,u.memoize=Vn,u.merge=Ww,u.mergeWith=Xu,u.method=$b,u.methodOf=Hb,u.mixin=ql,u.negate=qn,u.nthArg=Vb,u.omit=Kw,u.omitBy=Xw,u.once=kM,u.orderBy=SM,u.over=qb,u.overArgs=VM,u.overEvery=Wb,u.overSome=Kb,u.partial=Nl,u.partialRight=Uu,u.partition=TM,u.pick=Yw,u.pickBy=Yu,u.property=tm,u.propertyOf=Xb,u.pull=Sy,u.pullAll=Su,u.pullAllBy=Ty,u.pullAllWith=Ey,u.pullAt=Cy,u.range=Yb,u.rangeRight=zb,u.rearg=qM,u.reject=xM,u.remove=xy,u.rest=WM,u.reverse=Ol,u.sampleSize=OM,u.set=Qw,u.setWith=Jw,u.shuffle=BM,u.slice=Ay,u.sortBy=DM,u.sortedUniq=Gy,u.sortedUniqBy=$y,u.split=bb,u.spread=KM,u.tail=Hy,u.take=ky,u.takeRight=Vy,u.takeRightWhile=qy,u.takeWhile=Wy,u.tap=aM,u.throttle=XM,u.thru=$n,u.toArray=Vu,u.toPairs=zu,u.toPairsIn=Qu,u.toPath=ev,u.toPlainObject=Wu,u.transform=Zw,u.unary=YM,u.union=Ky,u.unionBy=Xy,u.unionWith=Yy,u.uniq=zy,u.uniqBy=Qy,u.uniqWith=Jy,u.unset=jw,u.unzip=Bl,u.unzipWith=Tu,u.update=eb,u.updateWith=tb,u.values=xr,u.valuesIn=rb,u.without=Zy,u.words=ju,u.wrap=zM,u.xor=jy,u.xorBy=eM,u.xorWith=tM,u.zip=rM,u.zipObject=iM,u.zipObjectDeep=nM,u.zipWith=oM,u.entries=zu,u.entriesIn=Qu,u.extend=Ku,u.extendWith=Xn,ql(u,u),u.add=rv,u.attempt=em,u.camelCase=ab,u.capitalize=Ju,u.ceil=iv,u.clamp=ib,u.clone=JM,u.cloneDeep=jM,u.cloneDeepWith=ew,u.cloneWith=ZM,u.conformsTo=tw,u.deburr=Zu,u.defaultTo=Lb,u.divide=nv,u.endsWith=sb,u.eq=at,u.escape=lb,u.escapeRegExp=pb,u.every=gM,u.find=MM,u.findIndex=Iu,u.findKey=xw,u.findLast=wM,u.findLastIndex=_u,u.findLastKey=Aw,u.floor=ov,u.forEach=Cu,u.forEachRight=xu,u.forIn=Ow,u.forInRight=Bw,u.forOwn=Lw,u.forOwnRight=Nw,u.get=Gl,u.gt=rw,u.gte=iw,u.has=Gw,u.hasIn=$l,u.head=Fu,u.identity=Ce,u.includes=_M,u.indexOf=wy,u.inRange=nb,u.invoke=kw,u.isArguments=cr,u.isArray=L,u.isArrayBuffer=nw,u.isArrayLike=Te,u.isArrayLikeObject=te,u.isBoolean=ow,u.isBuffer=qt,u.isDate=aw,u.isElement=sw,u.isEmpty=lw,u.isEqual=pw,u.isEqualWith=cw,u.isError=Dl,u.isFinite=uw,u.isFunction=Tt,u.isInteger=Gu,u.isLength=Wn,u.isMap=$u,u.isMatch=mw,u.isMatchWith=dw,u.isNaN=fw,u.isNative=hw,u.isNil=yw,u.isNull=gw,u.isNumber=Hu,u.isObject=Z,u.isObjectLike=ee,u.isPlainObject=Ni,u.isRegExp=Ul,u.isSafeInteger=Mw,u.isSet=ku,u.isString=Kn,u.isSymbol=Ue,u.isTypedArray=Cr,u.isUndefined=ww,u.isWeakMap=bw,u.isWeakSet=vw,u.join=_y,u.kebabCase=cb,u.last=Je,u.lastIndexOf=Ry,u.lowerCase=ub,u.lowerFirst=mb,u.lt=Pw,u.lte=Iw,u.max=av,u.maxBy=sv,u.mean=lv,u.meanBy=pv,u.min=cv,u.minBy=uv,u.stubArray=Kl,u.stubFalse=Xl,u.stubObject=Qb,u.stubString=Jb,u.stubTrue=Zb,u.multiply=mv,u.nth=Fy,u.noConflict=kb,u.noop=Wl,u.now=kn,u.pad=db,u.padEnd=fb,u.padStart=hb,u.parseInt=gb,u.random=ob,u.reduce=EM,u.reduceRight=CM,u.repeat=yb,u.replace=Mb,u.result=zw,u.round=dv,u.runInContext=y,u.sample=AM,u.size=LM,u.snakeCase=wb,u.some=NM,u.sortedIndex=Oy,u.sortedIndexBy=By,u.sortedIndexOf=Ly,u.sortedLastIndex=Ny,u.sortedLastIndexBy=Dy,u.sortedLastIndexOf=Uy,u.startCase=vb,u.startsWith=Pb,u.subtract=fv,u.sum=hv,u.sumBy=gv,u.template=Ib,u.times=jb,u.toFinite=Et,u.toInteger=N,u.toLength=qu,u.toLower=_b,u.toNumber=Ze,u.toSafeInteger=_w,u.toString=W,u.toUpper=Rb,u.trim=Fb,u.trimEnd=Sb,u.trimStart=Tb,u.truncate=Eb,u.unescape=Cb,u.uniqueId=tv,u.upperCase=xb,u.upperFirst=Hl,u.each=Cu,u.eachRight=xu,u.first=Fu,ql(u,function(){var r={};return mt(u,function(i,o){X.call(u.prototype,o)||(r[o]=i)}),r}(),{chain:!1}),u.VERSION=e,Ke(["bind","bindKey","curry","curryRight","partial","partialRight"],function(r){u[r].placeholder=u}),Ke(["drop","take"],function(r,i){$.prototype[r]=function(o){o=o===s?1:ae(N(o),0);var l=this.__filtered__&&!i?new $(this):this.clone();return l.__filtered__?l.__takeCount__=fe(o,l.__takeCount__):l.__views__.push({size:fe(o,ut),type:r+(l.__dir__<0?"Right":"")}),l},$.prototype[r+"Right"]=function(o){return this.reverse()[r](o).reverse()}}),Ke(["filter","map","takeWhile"],function(r,i){var o=i+1,l=o==Rp||o==V;$.prototype[r]=function(c){var m=this.clone();return m.__iteratees__.push({iteratee:x(c,3),type:o}),m.__filtered__=m.__filtered__||l,m}}),Ke(["head","last"],function(r,i){var o="take"+(i?"Right":"");$.prototype[r]=function(){return this[o](1).value()[0]}}),Ke(["initial","tail"],function(r,i){var o="drop"+(i?"":"Right");$.prototype[r]=function(){return this.__filtered__?new $(this):this[o](1)}}),$.prototype.compact=function(){return this.filter(Ce)},$.prototype.find=function(r){return this.filter(r).head()},$.prototype.findLast=function(r){return this.reverse().find(r)},$.prototype.invokeMap=U(function(r,i){return typeof r=="function"?new $(this):this.map(function(o){return Ci(o,r,i)})}),$.prototype.reject=function(r){return this.filter(qn(x(r)))},$.prototype.slice=function(r,i){r=N(r);var o=this;return o.__filtered__&&(r>0||i<0)?new $(o):(r<0?o=o.takeRight(-r):r&&(o=o.drop(r)),i!==s&&(i=N(i),o=i<0?o.dropRight(-i):o.take(i-r)),o)},$.prototype.takeRightWhile=function(r){return this.reverse().takeWhile(r).reverse()},$.prototype.toArray=function(){return this.take(ut)},mt($.prototype,function(r,i){var o=/^(?:filter|find|map|reject)|While$/.test(i),l=/^(?:head|last)$/.test(i),c=u[l?"take"+(i=="last"?"Right":""):i],m=l||/^find/.test(i);!c||(u.prototype[i]=function(){var f=this.__wrapped__,g=l?[1]:arguments,M=f instanceof $,I=g[0],_=M||L(f),R=function(G){var H=c.apply(u,Nt([G],g));return l&&T?H[0]:H};_&&o&&typeof I=="function"&&I.length!=1&&(M=_=!1);var T=this.__chain__,C=!!this.__actions__.length,A=m&&!T,D=M&&!C;if(!m&&_){f=D?f:new $(this);var O=r.apply(f,g);return O.__actions__.push({func:$n,args:[R],thisArg:s}),new Ye(O,T)}return A&&D?r.apply(this,g):(O=this.thru(R),A?l?O.value()[0]:O.value():O)})}),Ke(["pop","push","shift","sort","splice","unshift"],function(r){var i=mn[r],o=/^(?:push|sort|unshift)$/.test(r)?"tap":"thru",l=/^(?:pop|shift)$/.test(r);u.prototype[r]=function(){var c=arguments;if(l&&!this.__chain__){var m=this.value();return i.apply(L(m)?m:[],c)}return this[o](function(f){return i.apply(L(f)?f:[],c)})}}),mt($.prototype,function(r,i){var o=u[i];if(o){var l=o.name+"";X.call(Rr,l)||(Rr[l]=[]),Rr[l].push({name:i,func:o})}}),Rr[On(s,pt).name]=[{name:"wrapper",func:s}],$.prototype.clone=Ch,$.prototype.reverse=xh,$.prototype.value=Ah,u.prototype.at=sM,u.prototype.chain=lM,u.prototype.commit=pM,u.prototype.next=cM,u.prototype.plant=mM,u.prototype.reverse=dM,u.prototype.toJSON=u.prototype.valueOf=u.prototype.value=fM,u.prototype.first=u.prototype.head,Ii&&(u.prototype[Ii]=uM),u},Ut=ph();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(le._=Ut,define(function(){return Ut})):rr?((rr.exports=Ut)._=Ut,Vs._=Ut):le._=Ut}).call(Lr)});var hp=Wt(Kt());var cd=Wt(ld());var fp=s=>{let e=200,t=[],n=0;return t[n]=[],s.forEach(a=>{t[n].length<=e-1?t[n].push(a):(n++,t[n]=[a])}),t},to=s=>{let e=[],t=200;for(;s.length>t;){let n=s.splice(0,t);e.push(n)}return e.push(s),e},Ae=(s,e)=>{let t="",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"},p={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"?t=n[e]:s==="dev"?t=a[e]:t=p[e],t},Xt=s=>s.filter((t,n,a)=>n===a.indexOf(t)),ro=s=>Array.isArray(s)?s.map(e=>ro(e)):s!=null&&s.constructor===Object?Object.keys(s).reduce((e,t)=>({...e,[(0,cd.camelCase)(t)]:ro(s[t])}),{}):s,ge=s=>s||!1,ye=()=>`&disable_cache=${Date.now()}`,ud=s=>s.sort((e,t)=>e.localeCompare(t));var io=class{id=null;name=null;nickname=null;avatar=null;gender=null;country=null;birthDate=null;interests=[];followingCount=0;followersCount=0};var no=class{profilesFromResponse=e=>e?e.map(t=>this.fullProfileFromResponse(t)):null;fullProfileFromResponse=e=>{let t=new io;return t.id=e.id,t.name=e.name,t.nickname=e.nickname,t.avatar=e.avatar,t.gender=e.gender,t.country=e.country,t.birthDate=e.birth_date,t.interests=e.interests?e.interests:[],t.followingCount=e.following_count,t.followersCount=e.followers_count,t}};var oo=class{nextPageStartsAfter=null;itemsPerPage=null};var Nr=class{pagination=new oo};var ie=class{meta=new Nr;data=[]};var ao=class{avatar=null;followingId=null;name=null;profileId=null};var so=class{followResponse=e=>e.map(t=>this.remapResponse(t));followingFromResponse=e=>{let t=new ie;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapResponse(n)),t};remapResponse=e=>{let t=new ao;return t.avatar=e.avatar,t.followingId=e.following_id,t.name=e.name,t.profileId=e.profile_id,t}};var lo=class{avatar=null;followerId=null;name=null;profileId=null};var po=class{followersFromResponse=e=>{let t=new ie;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapResponse(n)),t};remapResponse=e=>{let t=new lo;return t.avatar=e.avatar,t.followerId=e.follower_id,t.name=e.name,t.profileId=e.profile_id,t}};var Hi=class{profile_ids=[]};var yP="/countries",Oe="/profile",md="/profiles",Dr=class{instanceAuth=null;instance=null;apiSignInUrl=null;profileRemapper=null;followingRemapper=null;followersRemapper=null;lang=null;constructor(e){this.lang=e.lang;let t=Ae(e.environment,"profile");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instanceAuth=hp.default.create({baseURL:t,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 p=e.authProvider.getIdToken();return a.headers.Authorization=`Bearer ${p}`,this.instanceAuth(a)}return Promise.reject(n)}),this.instance=hp.default.create({baseURL:t,headers:{"Content-Type":"application/json"}}),this.profileRemapper=new no,this.followingRemapper=new so,this.followersRemapper=new po}getCountries=async e=>{try{let t=`&lang=${this.lang}`,n=`${yP}${this.apiSignInUrl}${t}`,a=Date.now();return e&&(n+=`&disable_cache=${a}`),(await this.instance.get(n)).data.data}catch(t){throw console.warn("There was a problem fetching the countries:",t),t.response}};getProfile=async e=>{let t=`${Oe}${this.apiSignInUrl}`;if(e){t=`${md}/${e}${this.apiSignInUrl}`;try{let n=await this.instance.get(t);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(t);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,t)=>{try{let n=`${md}${this.apiSignInUrl}&profile_ids=${e.join(",")}`,a=Date.now();t&&(n+=`&disable_cache=${a}`);let p=await this.instance.get(n);return this.profileRemapper.profilesFromResponse(p.data.data)}catch(n){throw console.warn(`There was a problem fetching the following profiles: ${e.join(",")}`,n),n.response}};getFollowers=async(e,t)=>{let n=`${Oe}/followers${this.apiSignInUrl}`;if(e&&!t){n=`${Oe}/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&&!t)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&&t?n=`${Oe}/${t}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(n=`${Oe}/${t}/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: ${t}`,a),a.response}};getFollowing=async(e,t)=>{let n=`${Oe}/following${this.apiSignInUrl}`;if(e&&!t){n=`${Oe}/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&&!t)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&&t?n=`${Oe}/${t}/following${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(n=`${Oe}/${t}/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: ${t}`,a),a.response}};follow=async e=>{let t=new Hi;t.profile_ids=e;try{let n=await this.instanceAuth.post(`${Oe}/follow${this.apiSignInUrl}`,JSON.stringify(t));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 t=new Hi;t.profile_ids=e;try{return await this.instanceAuth.delete(`${Oe}/follow${this.apiSignInUrl}`,{data:JSON.stringify(t)}),!0}catch(n){throw console.warn(`There was a problem with DELETE request for profiles: ${e.join(",")} `,n),n.response}};getBadges=async e=>{let t=`${Oe}/badges${this.apiSignInUrl}`;try{return e?(t=`${Oe}/${e}/badges${this.apiSignInUrl}`,(await this.instance.get(t)).data.data):(await this.instanceAuth.get(t)).data.data}catch(n){throw console.warn("There was a problem with fetching the badges",n),n.response}};updateProfile=async e=>{try{let t=await this.instanceAuth.patch(`${Oe}${this.apiSignInUrl}`,e);return this.profileRemapper.fullProfileFromResponse(t.data.data)}catch(t){throw console.warn("There was a problem updating the own profile:",t),t.response}}};var xt={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id"},gp={PREDICTOR_USER_RELATED_OPERATION:"https://docs.fansunitedmedia.com/docs/predictor-operations#user-related-operations"};var dd="FansUnited",yp={football:{ids:[],countries:[],competitions:[]},profile:{info:{},statistics:{},badges:null,countries:[],exparations:{profile:0,statistics:0,badges:0}}},gt=class{idSchema="";expirationTimeout=600;expirationBadgesTimeout=3600;constructor(e){this.idSchema=e.idSchema,(this.getData()===void 0||this.getData()===null)&&this.setData(yp)}clearData=()=>{this.setData(yp)};getEntityById=(e="",t="")=>this.getData().football.ids.find(n=>{let a=xt[this.idSchema];return n&&`${n[a]}`===t&&n.resource===e});getEntity=(e,t,n)=>Array.isArray(e)?this.getData().football.ids.filter(a=>{let p=xt[n];return a&&e.includes(`${a[p]}`)&&a.resource===t}):this.getData().football.ids.find(a=>{let p=xt[n];return a&&`${a[p]}`===e&&a.resource===t});getEntityByNativeId=(e="",t="")=>this.getData().football.ids.find(n=>n&&`${n.id}`===t&&n.resource===e);checkForExistingIdObjs=(e,t)=>{let n=xt[t],a={};return Object.keys(e).forEach(p=>{let d=e[p],b=this.getEntity(d,p,t).map(w=>w[n]),F=e[p].filter(w=>!b.includes(w));a[p]=d.map(w=>F.includes(w)?{id:w,exists:!1}:{id:w,exists:!0})}),a};getIdsByType=(e,t,n)=>{let a=xt[n],p=xt[t],d={};return Object.keys(e).forEach(h=>{let b=e[h],F=[];this.getData().football.ids.forEach(w=>{b.forEach((S,k)=>{S===w[p]&&h===w.resource&&(F[k]=w[a])})}),d[h]=F}),d};addIdMapping=e=>{let t=this.getData();t.football.ids.push(e),this.setData(t)};addIdMappings=e=>{let t=this.getData(),n=t.football.ids;n=[...n,...e],t.football.ids=n,this.setData(t)};setOwnProfile=e=>{let t=this.getData();t.profile.info=e,t.profile.exparations.profile=Math.floor(Date.now()/1e3)+this.expirationTimeout,this.setData(t)};getOwnProfile=()=>this.getData().profile.info;getProfileCountries=()=>this.getData().profile.countries;setProfileCountries=e=>{let t=this.getData();t.profile.countries=e,this.setData(t)};getProfileStats=()=>this.getData().profile.statistics;setProfileStats=e=>{let t=this.getData();t.profile.statistics=e,t.profile.exparations.statistics=Math.floor(Date.now()/1e3)+this.expirationTimeout,this.setData(t)};getProfileBadges=()=>this.getData().profile.badges;setProfileBadges=e=>{let t=this.getData();t.profile.badges=e,t.profile.exparations.badges=Math.floor(Date.now()/1e3)+this.expirationBadgesTimeout,this.setData(t)};getFootballCountries=()=>this.getData().football.countries;setFootballCountries=e=>{let t=this.getData();t.football.countries=e,this.setData(t)};getCompetitions=e=>{let t=this.getData();return e?e.competitionSearchFilter(t.football.competitions):t.football.competitions};setCompetitions=e=>{let t=this.getData(),n=[...t.football.competitions];n.push(...e),t.football.competitions=this.makeCompetitionsUnique(n),this.setData(t)};getCompetitionsLength=()=>{let{football:e}=this.getData();return e.competitions.length};getExpiration=e=>{let t=this.getData();switch(this.initialNewSchema("exparations"),e){case"profile":return t.profile.exparations.profile;case"statistics":return t.profile.exparations.statistics;case"badges":return t.profile.exparations.badges}};makeCompetitionsUnique=e=>{let t=new Set;return e.filter(n=>{let a=!t.has(n.id);return t.add(n.id),a})};getData=()=>JSON.parse(localStorage.getItem(dd));setData=e=>{localStorage.setItem(dd,JSON.stringify(e))};initialNewSchema=e=>{this.getData().profile[e]||this.setData(yp)}};var fd=Wt(Kt());var ki={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},co=class{instance=null;apiSignInUrl="";constructor(e){let t=Ae(e.environment,"idMapping");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instance=fd.default.create({baseURL:t})}getEntityById=(e,t)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${config.idSchema}&${ki[e]}=${t}`)}catch(n){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,n),n.response}};getEntityByIdAndSchema=(e,t,n)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${ki[e]}=${t}`)}catch(a){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,a),a.response}};getEntityIdsByIdsAndSchema=(e,t,n)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${ki[e]}=${t.join(",")}`)}catch(a){throw console.warn(`There was a problem with id mapping request for the following ids:${t.join(",")}`,a),a.response}};getEntitiesByIds=(e,t,n)=>{t.sort((d,h)=>d.localeCompare(h));let p=fp(t).map(d=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${ki[e]}=${d.join(",")}`)}catch(h){throw console.warn(`There was a problem with id mapping request for the following ids:${d.join(",")}`,h),h.response}});return Promise.all(p).then(d=>{let h=[];return d.forEach(b=>{h.push(...b.data.data)}),h})};getEntitiesByIdObjs=async(e,t)=>{let n=[],a={},p=[];Object.keys(e).forEach(F=>{n.push.apply(n,e[F])});let d=Xt(n),h=fp(d);for(let F of h){let w="";if(Object.keys(e).forEach(S=>{a[S]=[];let k=F.filter(se=>e[S].includes(se));k&&k.length>0&&(a[S]=k)}),Object.keys(a).forEach(S=>{a[S].length>0&&(a[S].sort((k,se)=>k.localeCompare(se)),w+="&",w+=`${ki[S]}=${a[S].join(",")}`)}),w&&w.length>0)try{let S=await this.instance.get(`/football${this.apiSignInUrl}&input_provider=${t||"native"}${w}`);p.push(S.data.data)}catch(S){throw console.warn("There was a problem with id mapping request",S),S.response}else p.push([])}return Array.prototype.concat.apply([],p)}};var uo=class{isBrowser=!1;localStorage=null;https=null;constructor(e){this.isBrowser=typeof window!="undefined",this.localStorage=new gt(e),this.https=new co(e)}getEntitiesByIds=async(e,t,n)=>{if(this.isBrowser)try{let a=this.localStorage.checkForExistingIdObjs(e,t),p=this.splitForRequestAndExisting(a),d=await this.https.getEntitiesByIdObjs(p.request,t);return this.localStorage.addIdMappings(d),this.localStorage.getIdsByType(e,t,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,t);return Object.keys(e).forEach(p=>{e[p]=a.filter(d=>d.resource===p).map(d=>d[xt[n]])}),e}catch(a){return console.warn("There was a problem retrieving the entity ids ",a),Promise.resolve([])}};getEntityById=async(e,t,n)=>{if(this.isBrowser){let a=this.localStorage.getEntity(e,t,n);if(a)return a;{let p=await this.requestEntity(e,t,n);return this.localStorage.addIdMappings(p),p}}else return await this.requestEntity(e,t,n)};splitForRequestAndExisting=e=>{let t={},n={};return Object.keys(e).forEach(a=>{t[a]=e[a].filter(p=>!p.exists).map(p=>p.id),n[a]=e[a].filter(p=>p.exists).map(p=>p.id)}),{existing:n,request:t}};requestEntity=async(e,t,n)=>{try{return e=Array.isArray(e)?e:[e],await this.https.getEntitiesByIds(t,e,n)}catch(a){return console.warn(`There was a problem retrieving the requested entity: ${a}`),null}}};var mo=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 fo=class{extractedObjIds={};traverse=(e,t)=>(t=mo(t),Array.isArray(e)?this.traverseArrExtract(e,t):e&&typeof e=="object"&&this.traverseObjExtract(e,t),this.extractedObjIds);traverseArrExtract=(e,t)=>{e&&e.length>0&&e.forEach(n=>{this.traverseObjExtract(n,t)})};traverseObjExtract=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(n=>{let a=e[n];n==="id"||n==="teamId"?(this.extractedObjIds.hasOwnProperty(t)||(this.extractedObjIds[t]=[]),a&&this.extractedObjIds[t].push(a)):e[n]&&this.traverse(e[n],n)})}};var ho=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(e,t,n)=>(t=mo(t),this.replaceObjIdsIndex===null&&(this.initReplaceObjIdsIndex(n),this.remappedIdsObj=n),Array.isArray(e)?this.traverseArrReplace(e,t):e&&typeof e=="object"&&this.traverseObjReplace(e,t),e);initReplaceObjIdsIndex=e=>{this.replaceObjIdsIndex={},Object.keys(e).forEach(t=>{this.replaceObjIdsIndex[t]=0})};traverseArrReplace=(e,t)=>{e&&e.length>0&&e.forEach(n=>{this.traverseObjReplace(n,t)})};traverseObjReplace=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(n=>{n==="id"||n==="teamId"?e[n]&&(e[n]=this.remappedIdsObj[t][this.replaceObjIdsIndex[t]],this.replaceObjIdsIndex[t]=this.replaceObjIdsIndex[t]+1):e[n]&&this.traverse(e[n],n,this.remappedIdsObj)})}};var ce=class{idSchema="";idMappingFacade=null;constructor(e){this.idSchema=e.idSchema,this.idMappingFacade=new uo(e)}getEntityIdBySchemaId=(e,t)=>this.idMappingFacade.getEntityById(e,t,this.idSchema);remapEntities=async(e,t)=>{let n=JSON.parse(JSON.stringify(e));try{if(this.idSchema!=="native"){let p=new fo().traverse(n,t);return this.idMappingFacade.getEntitiesByIds(p,"native",this.idSchema).then(d=>new ho().traverse(n,t,d))}else return e}catch(a){return console.warn(`There was a problem remapping entity: ${t} with inner entity `,a),[]}};getEntityIdsBySchemaId=async(e,t,n)=>{let a={};return a[t]=e,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(a,this.idSchema,n):a}};var ke=class{completed=!1;percentage;constructor(e){this.percentage=e}};var go=class{teamFollowed=new ke(10);teamFavourite=new ke(15);playerFollowed=new ke(10);playerFavourite=new ke(10);competitionFollowed=new ke(10);competitionFavourite=new ke(5);addedBirthdate=new ke(10);addedGender=new ke(10);addedCountry=new ke(10);addedAvatar=new ke(10)};var yo=class{totalPercentage;breakdown=new go};var Vi=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 yt=class{isBrowser=!1;localStorage={};profileHttps=null;activityHttps=null;constructor(e,t,n){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.profileHttps=t,this.activityHttps=n}getOwn=async()=>{if(this.isBrowser){let e=this.getLocalStorageData("profile");if(e)return JSON.parse(JSON.stringify(e));try{let t=await this.profileHttps.getProfile();return this.localStorage.setOwnProfile(t),t}catch(t){throw console.warn("There was a problem retrieving your profile: ",t),t}}else try{return await this.profileHttps.getProfile()}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};updateOwnProfile=async()=>{try{let e=await this.profileHttps.getProfile();return this.localStorage.setOwnProfile(e),e}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};getByIds=async(e,t)=>{try{return t=t||!1,await this.profileHttps.getProfiles(e,t)}catch(n){throw console.warn(`There was a problem retrieving the selected profiles: ${e.join(",")} `,n),n}};getById=async e=>{try{return await this.profileHttps.getProfile(e)}catch(t){throw console.warn(`There was a problem retrieving the selected profile: ${e} `,t),t}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let t=this.localStorage.getProfileCountries();if(t&&t.length>0)return t;try{let n=await this.profileHttps.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.profileHttps.getCountries(e)}catch(t){throw console.warn("There was a problem retrieving profile countries: ",t),t}};getFollowers=async(e,t)=>{try{return e&&(e=new Vi(e)),await this.profileHttps.getFollowers(e,t)}catch(n){throw console.warn("There was a problem retrieving your followers: ",n),n}};getFollowing=async(e,t)=>{try{return e&&(e=new Vi(e)),await this.profileHttps.getFollowing(e,t)}catch(n){throw console.warn("There was a problem retrieving your following profiles: ",n),n}};follow=async e=>{try{return await this.profileHttps.follow(e)}catch(t){throw console.warn(`There was a problem following profiles: ${e.join(",")} `,t),t}};unfollow=async e=>{try{return await this.profileHttps.unfollow(e)}catch(t){throw console.warn(`There was a problem unfollowing profiles: ${e.join(",")} `,t),t}};showFullnessProfile=e=>{let t=new yo,n=0;return e.avatar&&(t.breakdown.addedAvatar.completed=!0,n+=t.breakdown.addedAvatar.percentage),e.birthDate&&(t.breakdown.addedBirthdate.completed=!0,n+=t.breakdown.addedBirthdate.percentage),e.country&&(t.breakdown.addedCountry.completed=!0,n+=t.breakdown.addedCountry.percentage),e.gender&&(t.breakdown.addedGender.completed=!0,n+=t.breakdown.addedGender.percentage),e.interests&&e.interests.length>0&&(e.interests.find(w=>w.type==="team"&&w.favourite)&&(t.breakdown.teamFavourite.completed=!0,n+=t.breakdown.teamFavourite.percentage),e.interests.find(w=>w.type==="team")&&(t.breakdown.teamFollowed.completed=!0,n+=t.breakdown.teamFollowed.percentage),e.interests.find(w=>w.type==="player"&&w.favourite)&&(t.breakdown.playerFavourite.completed=!0,n+=t.breakdown.playerFavourite.percentage),e.interests.find(w=>w.type==="player")&&(t.breakdown.playerFollowed.completed=!0,n+=t.breakdown.playerFollowed.percentage),e.interests.find(w=>w.type==="competition"&&w.favourite)&&(t.breakdown.competitionFavourite.completed=!0,n+=t.breakdown.competitionFavourite.percentage),e.interests.find(w=>w.type==="competition")&&(t.breakdown.competitionFollowed.completed=!0,n+=t.breakdown.competitionFollowed.percentage)),t.totalPercentage=n,t};getStats=async()=>{if(this.isBrowser){let e=this.getLocalStorageData("statistics");if(e&&Object.keys(e).length)return JSON.parse(JSON.stringify(e));try{let t=await this.activityHttps.getStats();return this.localStorage.setProfileStats(t),t}catch(t){throw console.warn("There was a problem retrieving own profile statistics: ",t),t}}else try{return await this.activityHttps.getStats()}catch(e){throw console.warn("There was a problem retrieving own profile statistics: ",e),e}};getBadges=async()=>{if(this.isBrowser){let e=this.getLocalStorageData("badges");if(e)return e;try{let t=await this.profileHttps.getBadges();return this.localStorage.setProfileBadges(t),t}catch(t){throw console.warn("There was a problem retrieving own profile badges: ",t),t}}else try{return await this.profileHttps.getBadges()}catch(e){throw console.warn("There was a problem retrieving own profile badges: ",e),e}};getLocalStorageData=e=>{let t=Math.floor(Date.now()/1e3),n=this.localStorage.getExpiration(e);switch(e){case"profile":if(n>t)return this.localStorage.getOwnProfile();case"statistics":if(n>t)return this.localStorage.getProfileStats();case"badges":if(n>t)return this.localStorage.getProfileBadges();default:return null}}};var Mo=class{id=null;name=null;assets=null};var Ur=class{idMapping=null;footballFacade=null;constructor(e,t){this.idMapping=e,this.footballFacade=t}showFullInterests=async e=>{let t=[];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 p=await this.footballFacade.getTeams(a);n.model=p.data[0]}if(n.type==="player"){a.playerIds=[n.id];let p=await this.footballFacade.getPlayers(a);n.model=p.data[0]}if(n.type==="competition"){a.competitionIds=[n.id];let p=await this.footballFacade.getCompetitions(a);n.model=p[0]}n.model===void 0&&(n.model=null),t.push(n)}else t.push(n);return t};updateInterests=(e,t)=>{if(e&&t&&e.length===t.length){let n=t.filter(p=>e.some(d=>p.id===d.id&&p.type===d.type&&p.source===d.source&&p.favourite===d.favourite)),a=t.filter(p=>!e.some(d=>p.id===d.id&&p.type===d.type&&p.source===d.source&&p.favourite===d.favourite));return[...n,...a]}else return t}};var wo=class{extractUpdatedProps=(e,t)=>{let n=["name","nickname","gender"],a={};return Object.keys(e).forEach(p=>{if(n.includes(p)&&e[p]!==t[p])a[p]=t[p];else if(p==="birthDate")(t[p]===null||e[p]===null&&t[p]||e[p]!==t[p])&&(a.birth_date=t[p]);else if(p==="country")t[p]===null?a.country_id=t[p]:(e[p]===null&&t[p]||e[p].id!==t[p].id)&&(a.country_id=t[p].id);else if(p==="interests"){let d=e[p],h=t[p];h.length&&this.isNewInterest(d,h)?a[p]=this.updateInterests(d,h):(!h.length&&d.length||d.length!==h.length&&!this.isNewInterest(d,h))&&(a[p]=h)}}),a};updateInterests=(e,t)=>{if(e.length===t.length){let[n,a]=this.extractSameAndNewInterests(e,t);return[...a,...n]}else return t};isNewInterest=(e,t)=>{let n=!1,[a]=this.extractSameAndNewInterests(e,t);return a.length&&(n=!0),n};extractSameAndNewInterests=(e,t)=>{let n=t.filter(p=>e.some(d=>p.id===d.id&&p.type===d.type&&p.source===d.source&&p.favourite===d.favourite));return[t.filter(p=>!e.some(d=>p.id===d.id&&p.type===d.type&&p.source===d.source&&p.favourite===d.favourite)),n]}};var bo=class{idsRemapper=null;profileHttps=null;profileService=null;localStorage=null;profileFacade=null;interestsService=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;constructor(e,t,n,a,p,d){this.idsRemapper=e,this.localStorage=t,this.profileHttps=n,this.profileService=new wo,this.interestsService=new Ur(p,d),this.profileFacade=new yt(t,n,a)}getOwnProfile=async()=>{for(;this.isFetching;)console.log("Another thread is fetching profile..."),await this.delay(100);if(this.modified&&this.ownProfile)return console.log("Timestamp is less than 10 minutes OR profile is modifying "),this.ownProfile;let e=Math.floor(Date.now()/1e3);if(!this.ownProfile||this.expireAt<e){this.isFetching=!0,this.expireAt=Math.floor(Date.now()/1e3)+600;try{let t=await this.profileFacade.getOwn();this.setOwnProfile(t)}catch{this.isFetching=!1}return this.modified=!1,this.isFetching=!1,this.ownProfile}return this.ownProfile};delay=e=>new Promise(t=>{setTimeout(t,e)});setOwnProfile=e=>{this.ownProfile=e};getInfo=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return delete t.interests,t};showInterests=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.inquiryCustomInterests(t.interests)};showFullInterests=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e)),n=await this.idsRemapper.inquiryCustomInterests(t.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=>{let t=await this.profileFacade.follow(e),n=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(n),t};unfollow=async e=>{let t=await this.profileFacade.unfollow(e),n=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(n),t};getStats=async()=>{let e=await this.profileFacade.getStats();return await this.idsRemapper.remapSuccessRatesEntities(e)};getBadges=async()=>await this.profileFacade.getBadges();addInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;e.source!=="custom"?t=await this.idsRemapper.remapInterestToNative(e):t=e;let n=this.ownProfile.interests.filter(a=>a.id!==t.id||a.type!==t.type||a.source!==t.source);return this.ownProfile.interests=[...n],this.ownProfile.interests.push(t),this};addInterest=e=>(this.promises.push(this.addInterestPromise(e)),this);removeInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;return e.source!=="custom"?t=await this.idsRemapper.remapInterestToNative(e):t=e,this.ownProfile.interests=this.ownProfile.interests.filter(n=>n.id!==t.id||n.type!==t.type||n.source!==t.source),this};removeInterest=e=>(this.promises.push(this.removeInterestPromise(e)),this);setBirthdatePromise=async e=>(this.modified=!0,await this.getOwnProfile(),e?this.ownProfile.birthDate=e:this.ownProfile.birthDate=null,this);setBirthdate=e=>(this.promises.push(this.setBirthdatePromise(e)),this);setGenderPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e==="male"||e==="female"?this.ownProfile.gender=e:this.ownProfile.gender="unspecified",this);setGender=e=>(this.promises.push(this.setGenderPromise(e)),this);setNicknamePromise=async e=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.nickname=e,this);setNickname=e=>(this.promises.push(this.setNicknamePromise(e)),this);setNamePromise=async e=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.name=e,this);setName=e=>(this.promises.push(this.setNamePromise(e)),this);setCountryPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e&&!this.ownProfile.country?(this.ownProfile.country=new Mo,this.ownProfile.country.id=e):e&&this.ownProfile.country?this.ownProfile.country.id=e:this.ownProfile.country=null,this);setCountry=e=>(this.promises.push(this.setCountryPromise(e)),this);showFullnessProfile=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return this.profileFacade.showFullnessProfile(t)};update=async()=>{if(this.promises.length===0)return this.ownProfile;await Promise.all(this.promises);let e=await this.profileFacade.getOwn(),t=await this.getOwnProfile(),n=this.profileService.extractUpdatedProps(e,t);if(this.modified=!1,this.expireAt=0,Object.keys(n).length){let p=await this.profileHttps.updateProfile(n);return this.setOwnProfile(p),this.localStorage.setOwnProfile(p),delete p.interests,p}let a=JSON.parse(JSON.stringify(this.ownProfile));return delete a.interests,a}};var vo=class{idsRemapper=null;profileHttps=null;activityHttps=null;profileFacade=null;interestsService=null;profileId="";constructor(e,t,n,a,p,d){this.idsRemapper=e,this.profileHttps=n,this.activityHttps=a,this.interestsService=new Ur(p,d),this.profileFacade=new yt(t,n,a)}setId=e=>(this.profileId=e,this);getProfile=async()=>await this.profileFacade.getById(this.profileId);getInfo=async()=>{let e=await this.getProfile();return delete e.interests,e};showInterests=async()=>{let e=await this.getProfile(),t=[];return t=e.interests,await this.idsRemapper.inquiryCustomInterests(t)};showFullInterests=async()=>{let e=await this.showInterests();return await this.interestsService.showFullInterests(e)};getFollowers=async e=>await this.profileFacade.getFollowers(e,this.profileId);getFollowing=async e=>await this.profileFacade.getFollowing(e,this.profileId);showFullnessProfile=async()=>{let e=await this.getProfile();return this.profileFacade.showFullnessProfile(e)};getStats=async e=>{let t=await this.activityHttps.getStats(this.profileId,e);return await this.idsRemapper.remapSuccessRatesEntities(t)};getBadges=async()=>await this.profileHttps.getBadges(this.profileId)};var Po=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,n){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=n,this.https=t}getCountriesWithIdMapping=async e=>{try{let t=await this.getCountries(e);return this.idMapping.remapEntities(t,"country")}catch(t){throw console.warn("There was a problem browsing countries as football entities",t),t}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let t=this.localStorage.getFootballCountries();if(t&&t.length>0)return t;try{let 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 qi=class{countryId=null;name=null;gender=null;type=null;sortField=null;sortOrder=null;competitionIds=null;constructor(e){this.countryId=e.countryId?`${e.countryId}`:null,this.name=e.name?e.name:null,this.gender=e.gender?e.gender:null,this.type=e.type?e.type:null,this.sortField=e.sortField?`${e.sortField}`:null,this.sortOrder=e.sortOrder?`${e.sortOrder}`:null,this.competitionIds=e.competitionIds?e.competitionIds:null}constructFilterUrl=()=>{let e="";return this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.gender&&(e=e+"&",e=e+`gender=${this.gender}`),this.type&&(e=e+"&",e=e+`type=${this.type}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),this.name&&(e=e+"&",e=e+`name=${this.name}`),this.competitionIds&&(e=e+"&",e=e+`competition_ids=${this.competitionIds.join(",")}`),e};competitionSearchFilter=e=>{try{let t=this.filter(e);return this.sortField||this.sortOrder?this.sort(t):t}catch(t){return console.warn("There was a problem filtering the local competitions",t),[]}};filter=e=>{let t=this.entitiesToSearchWith();return e.filter(n=>{let a=!0;return t.forEach(p=>{p!=="sortOrder"&&p!=="sortField"&&(p==="countryId"?a&&=n.country.id===this[p]:p==="name"?a&&=n.name.toLocaleLowerCase().includes(this[p].toLocaleLowerCase()):p==="competitionIds"?a&&=this[p].some(d=>n.id===d):a&&=n[p].toLocaleLowerCase()===this[p].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 t=[];return this.sortField==="name"?t=e.sort((n,a)=>this.sortOrder&&this.sortOrder==="desc"?a.name.localeCompare(n.name):n.name.localeCompare(a.name)):this.sortField==="country"?t=e.sort((n,a)=>this.sortOrder&&this.sortOrder==="desc"?a.country.name.localeCompare(n.country.name):n.country.name.localeCompare(a.country.name)):this.sortField==="scope"?e.forEach(n=>t[this.competitionIds.indexOf(n.id)]=n):!this.sortField&&this.sortOrder==="desc"&&(t=e.sort((n,a)=>a.id.localeCompare(n.id))),t}};var Io=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,n){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=n,this.https=t}getCompetitionsIdMapping=async(e,t)=>{try{let n=!1;if(e){if(e=new qi(e),e.countryId){let p=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");p.country.length===0&&(n=!0),e.countryId=p.country[0]}if(e.competitionIds){let p=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");p.competition.length===0&&(n=!0),e.competitionIds=p.competition}if(n)return[]}let a=await this.getCompetitions(e,t);return await this.idMapping.remapEntities(a,"competition")}catch(n){throw console.warn("There was a problem browsing all of the competitions",n),n}};getCompetitionsMapWithNativeIds=async e=>{let t=new Map,n=new qi({competitionIds:e}),a=await this.getCompetitions(n);a.sort((d,h)=>d.id.localeCompare(h.id));let p=await this.idMapping.remapEntities(a,"competition");return e.forEach((d,h)=>t.set(d,p[h])),t};getCompetitions=async(e,t)=>{let n=null;if(t=t||!1,this.isBrowser){if(!this.localStorage.getCompetitionsLength()){try{n=await this.https.getCompetitions()}catch(a){throw console.warn("There was a problem retrieving all competitions",a),a}this.localStorage.setCompetitions(n)}return this.localStorage.getCompetitions(e)}else return this.https.getCompetitions(e,t)};getCompetitionByIdIdMapping=async(e,t)=>{try{let a=(await this.idMapping.getEntityIdsBySchemaId([e],"competition","native")).competition[0],p=await this.getCompetitionById(a,t);return await this.idMapping.remapEntities(p,"competition")}catch(n){throw console.warn(`There was a problem browsing the following competition:${e}`,n),n}};getCompetitionById=async(e,t)=>{try{return t=t||!1,await this.https.getCompetitionById(e,t)}catch(n){throw console.warn(`There was a problem retrieving the competition with the following id: ${e}`,n),n}};getTopCompetitionsIdMapping=async e=>{try{let t=await this.getTopCompetitions(e);return await this.idMapping.remapEntities(t,"competition")}catch(t){throw console.warn("There was a problem browsing the top competitions",t),t}};getTopCompetitions=async e=>{try{return e=e||!1,await this.https.getTopCompetitions(e)}catch(t){throw console.warn("There was a problem retrieving the top competitions",t),t}}};var Wi=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 hd=Wt(Kt());var _o=class{general=[];predictor=[];topX=[];matchQuiz=[]};var Gr=class{points=0;gameParticipationCount=null;predictionsMade=null;correctPredictions=null};var Ro=class{id;enabled;requirements=new Gr};var Fo=class{id;weight;multiplier;conditions};var So=class{value=new Fo};var $r=class{points=null;tiers=null;badges=null};var To=class{enabled=!1;conditions={list:null};actions=new So;rewards=new $r};var Eo=class{general=null;comments=null;predictor=null;activity=null;topX=null};var Hr=class{enabled=!1;defaultMarkets=null;competitionsWhitelist=null};var kr=class{enabled=!1;minFixtures=null;maxFixtures=null;competitionsWhitelist=null};var Vr=class{enabled=!1;fullCoverageCompetitions=null;markets=null};var Co=class{remapPredictorConfig=e=>{let t=new Vr;return t.enabled=e.enabled,t.fullCoverageCompetitions=e.full_coverage_competitions,t.markets=e.markets,t};remapTopXConfig=e=>{let t=new kr;return t.enabled=e.enabled,t.minFixtures=e.min_fixtures,t.maxFixtures=e.max_fixtures,t.competitionsWhitelist=e.competitions_whitelist,t};remapMatchQuizConfig=e=>{let t=new Hr;return t.enabled=e.enabled,t.defaultMarkets=e.default_markets,t.competitionsWhitelist=e.competitions_whitelist,t};remapLoyaltyConfig=e=>{let t=new To;return t.enabled=e.enabled,t.conditions.list=e.conditions.list,t.actions.value=e.actions.value,t.rewards=this.remapRewards(e.rewards),t};remapRewards=e=>{let t=new $r;return t.points=this.remapPoints(e.points),t.tiers=e.tiers,t.badges=this.remapBadges(e.badges),t};remapPoints=e=>{let t=new Eo;return t.general=e.general,t.comments=e.comments,t.predictor=e.predictor,t.activity=e.activity,t.topX=e.top_x,t};remapBadges=e=>{let t=new _o;return t.general=e.general,t.predictor=this.remapBadgeValues(e.predictor),t.topX=this.remapBadgeValues(e.top_x),t.matchQuiz=this.remapBadgeValues(e.match_quiz),t};remapBadgeValues=e=>e.map(t=>{let n=new Ro;return n.id=t.id,n.enabled=t.enabled,n.requirements=this.remapRequirements(t.requirements),n});remapRequirements=e=>{let t=new Gr;return t.points=e.points,t.gameParticipationCount=e.game_participation_count,t.predictionsMade=e.predictions_made,t.correctPredictions=e.correct_predictions,t}};var je=class{instance=null;apiSignInUrl="";featureConfigRemapper=null;constructor(e){let t=Ae(e.environment,"client");this.apiSignInUrl=`/clients/${e.clientId}/features?key=${e.apiKey}`,this.instance=hd.default.create({baseURL:t,headers:{"Content-Type":"application/json"}}),this.featureConfigRemapper=new Co}getConfig=async e=>{try{let t=await this.instance.get(`${this.apiSignInUrl}`);switch(e){case"predictor":return this.featureConfigRemapper.remapPredictorConfig(t.data.data.predictor);case"topX":return this.featureConfigRemapper.remapTopXConfig(t.data.data.top_x);case"matchQuiz":return this.featureConfigRemapper.remapMatchQuizConfig(t.data.data.match_quiz);case"loyalty":return this.featureConfigRemapper.remapLoyaltyConfig(t.data.data.loyalty)}}catch(t){throw console.warn("There was a problem fetching configuration from Client API",t),t.response}}};var Yt=class{clientHttps=null;constructor(e){this.clientHttps=new je(e)}setAvailableMarketsForMatch=async e=>{let{fullCoverageCompetitions:t,markets:n}=await this.clientHttps.getConfig("predictor");if(Array.isArray(e))return e.map(a=>this.setAvailableMarkets(a,t,n));if(typeof e=="object"&&Object.keys(e).length)return this.setAvailableMarkets(e,t,n)};setAvailableMarkets=(e,t,n)=>{let a=e.context.competition.id;return this.isMatchInCoverageCompetition(a,t)?(e.availableMarkets=n.all,e):(e.availableMarkets=n.main,e)};isMatchInCoverageCompetition=(e,t)=>{let n=!1;return t.includes(e)&&(n=!0),n}};var Ao=class{footballService=null;https=null;idMapping=null;constructor(e,t,n){this.idMapping=n,this.https=t,this.footballService=new Yt(e)}getTeamsIdMapping=async(e,t)=>{try{let n=!1;if(e){if(e=new Wi(e),e.countryId){let p=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");p.country.length===0&&(n=!0),e.countryId=p.country[0]}if(e.scope){let p=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");p.competition.length===0&&(n=!0),e.scope=p.competition}if(e.teamIds){let p=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");p.team.length===0&&(n=!0),e.teamIds=p.team}}if(n)return[];let a=await this.getTeams(e,t);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}};getTeamsMapWithNativeIds=async e=>{let t=new Map,n=new Wi({teamIds:e}),{data:a}=await this.getTeams(n);a.sort((d,h)=>d.id.localeCompare(h.id));let p=await this.idMapping.remapEntities(a,"team");return e.forEach((d,h)=>t.set(d,p[h])),t};getTeams=async(e,t)=>{try{return t=t||!1,await this.https.getTeams(e,t)}catch(n){throw console.warn("There was a problem retrieving all teams",n),n}};getTeamByIdIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let a=await this.getTeamById(e,t);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,t)=>{try{return t=t||!1,await this.https.getTeamById(e,t)}catch(n){throw console.warn(`There was a problem retrieving the following team: ${e}`,n),n}};getTopTeamsIdMapping=async e=>{try{let t=await this.getTopTeams(e);return await this.idMapping.remapEntities(t,"team")}catch(t){throw console.warn("There was a problem browsing the top teams",t),t}};getTopTeams=async e=>{try{return e=e||!1,await this.https.getTopTeams(e)}catch(t){throw console.warn("There was a problem retrieving the top teams",t),t}};getNextMatchForTeamIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let a=await this.getNextMatchForTeam(e,t);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,t)=>{try{t=t||!1;let n=await this.https.getNextMatchForTeam(e,t);return await this.footballService.setAvailableMarketsForMatch(n)}catch(n){throw console.warn(`There was a problem retrieving the next match for the following team: ${e}`,n),n}};getPrevMatchForTeamIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let a=await this.getPrevMatchForTeam(e,t);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,t)=>{try{t=t||!1;let n=await this.https.getPrevMatchForTeam(e,t);return await this.footballService.setAvailableMarketsForMatch(n)}catch(n){throw console.warn(`There was a problem retrieving the previous match for the following team: ${e}`,n),n}}};var Ki=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 zt=class{https=null;footballService=null;idMapping=null;constructor(e,t,n){this.idMapping=n,this.https=t,this.footballService=new Yt(e)}getPlayersIdMapping=async(e,t)=>{try{let n=!1;if(e){if(e=new Ki(e),e.countryId){let p=await this.idMapping.getEntityIdsBySchemaId([e.countryId],"country","native");p.country.length===0&&(n=!0),e.countryId=p.country[0]}if(e.playerIds){let p=await this.idMapping.getEntityIdsBySchemaId(e.playerIds,"player","native");p.player.length===0&&(n=!0),e.playerIds=p.player}if(e.scope){let p=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");p.competition.length===0&&(n=!0),e.scope=p.competition}if(n)return[]}let a=await this.getPlayers(e,t);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 t=new Ki({playerIds:e}),n=await this.getPlayers(t);return n.data.sort((a,p)=>a.id.localeCompare(p.id)),await this.idMapping.remapEntities(n.data,"player")};getPlayersMapWithNativeIds=async e=>{let t={},n=Xt(e);n.sort((p,d)=>p.localeCompare(d));let a=await this.getPlayersWithNativeIds(n);return n.forEach((p,d)=>t[p]=a[d]),t};getPlayers=async(e,t)=>{try{return t=t||!1,await this.https.getPlayers(e,t)}catch(n){throw console.warn("There was a problem retrieving the players",n),n}};getPlayerIdMapping=async(e,t)=>{try{let n=await this.idMapping.getEntityIdsBySchemaId([e],"player","native"),a=await this.getPlayerById(n.player[0],t);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,t)=>{try{return t=t||!1,await this.https.getPlayerById(e,t)}catch(n){throw console.warn(`There was a problem retrieving the following player: ${e}`,n),n}};getTopPlayersIdMapping=async e=>{try{let t=await this.getTopPlayers(e);return await this.idMapping.remapEntities(t,"player")}catch(t){throw console.warn("There was a problem browsing the top players",t),t}};getTopPlayers=async e=>{try{return e=e||!1,await this.https.getTopPlayers(e)}catch(t){throw console.warn("There was a problem retrieving the top players",t),t}};getNextMatchForPlayerIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let a=await this.getNextMatchForPlayer(e,t);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,t)=>{try{t=t||!1;let n=await this.https.getNextMatchForPlayer(e,t);return await this.footballService.setAvailableMarketsForMatch(n)}catch(n){throw console.warn(`There was a problem retrieving the next match for player: ${e}`,n),n}};getPrevMatchForPlayerIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let a=await this.getPrevMatchForPlayer(e,t);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,t)=>{try{t=t||!1;let n=await this.https.getPrevMatchForPlayer(e,t);return await this.footballService.setAvailableMarketsForMatch(n)}catch(n){throw console.warn(`There was a problem retrieving the previous match for player: ${e}`,n),n}}};var Xi=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 Qt=class{https=null;idMapping=null;footballService=null;constructor(e,t,n){this.https=t,this.idMapping=n,this.footballService=new Yt(e)}getMatchesIdMapping=async(e,t)=>{try{if(e){if(e=new Xi(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,t);return n.data=await this.footballService.setAvailableMarketsForMatch([...n.data]),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 t=e.length,n=new Xi({matchIds:e,limit:t}),a=await this.getMatches(n);return a.data.sort((p,d)=>p.id.localeCompare(d.id)),await this.idMapping.remapEntities(a.data,"match")};getMatchesMapWithNativeIds=async e=>{let t={},n=Xt(e);n.sort((p,d)=>p.localeCompare(d));let a=await this.getMatchesWithNativeIds(n);return n.forEach((p,d)=>t[p]=a[d]),t};getMatches=async(e,t)=>{try{return t=t||!1,await this.https.getMatches(e,t)}catch(n){throw console.warn("There was a problem retrieving the matches",n),n}};getMatchIdMapping=async(e,t)=>{try{let n=await this.idMapping.getEntityIdsBySchemaId([e],"match","native"),a=await this.getMatchById(n.match[0],t),p=await this.footballService.setAvailableMarketsForMatch(a);return await this.idMapping.remapEntities(p,"match")}catch(n){throw console.warn(`There was a problem browsing the following match: ${e}`,n),n}};getMatchById=async(e,t)=>{try{return t=t||!1,await this.https.getMatchById(e,t)}catch(n){throw console.warn(`There was a problem retrieving the following match: ${e}`,n),n}}};var Oo=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 Bo=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}searchIdMapping=async(e,t)=>{try{if(e=new Oo(e),e.scope){let a=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");e.scope=a.competition}let n=await this.search(e,t);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,t)=>{try{return await this.https.search(e,t)}catch(n){throw console.warn("There was a problem retrieving the search response",n),n}}};var qr=class{countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(e,t,n,a){this.countriesFacade=new Po(t,n,a),this.competitionsFacade=new Io(t,n,a),this.teamsFacade=new Ao(e,n,a),this.playerFacade=new zt(e,n,a),this.matchFacade=new Qt(e,n,a),this.searchFacade=new Bo(n,a)}getCountries=async e=>this.countriesFacade.getCountriesWithIdMapping(e);getCompetitions=async(e,t)=>this.competitionsFacade.getCompetitionsIdMapping(e,t);getCompetitionById=async(e,t)=>this.competitionsFacade.getCompetitionByIdIdMapping(e,t);getTopCompetitions=async e=>this.competitionsFacade.getTopCompetitionsIdMapping(e);getCompetitionsMapWithNativeIds=async e=>await this.competitionsFacade.getCompetitionsMapWithNativeIds(e);getTeams=async(e,t)=>this.teamsFacade.getTeamsIdMapping(e,t);getTeamById=async(e,t)=>this.teamsFacade.getTeamByIdIdMapping(e,t);getTopTeams=async e=>this.teamsFacade.getTopTeamsIdMapping(e);getNextMatchForTeam=async(e,t)=>this.teamsFacade.getNextMatchForTeamIdMapping(e,t);getPrevMatchForTeam=async(e,t)=>this.teamsFacade.getPrevMatchForTeamIdMapping(e,t);getTeamsMapWithNativeIds=async e=>await this.teamsFacade.getTeamsMapWithNativeIds(e);getPlayers=async(e,t)=>this.playerFacade.getPlayersIdMapping(e,t);getPlayerById=async(e,t)=>this.playerFacade.getPlayerIdMapping(e,t);getTopPlayers=async e=>this.playerFacade.getTopPlayersIdMapping(e);getNextMatchForPlayer=async(e,t)=>this.playerFacade.getNextMatchForPlayerIdMapping(e,t);getPrevMatchForPlayer=async(e,t)=>this.playerFacade.getPrevMatchForPlayerIdMapping(e,t);getMatches=async(e,t)=>this.matchFacade.getMatchesIdMapping(e,t);getMatchById=async(e,t)=>this.matchFacade.getMatchIdMapping(e,t);search=async(e,t)=>this.searchFacade.searchIdMapping(e,t)};var gd=Wt(Kt());var Lo=class{id="";alias="";countryCode="";assets=null;name=""};var ne=class{countriesFromResponse=e=>{if(e)return e.map(t=>this.countryFromResponse(t))};countryFromResponse=e=>{try{if(e){let t=new Lo;return t.id=e.id,t.alias=e.alias,t.assets=e.assets,t.countryCode=e.country_code,t.name=e.name,t}}catch(t){throw t}return null}};var No=class{id="";country=null;gender="";assets=null;type="";name=""};var Be=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let t=new No;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var Do=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var Uo=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName=""};var Me=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let t=new Uo;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t}catch(t){throw console.warn("There was a problem remapping teams response",t),t}}};var Go=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new ne,this.teamBasicRemapper=new Me}fromResponse(e){try{let t=new Do;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t.participants=e.participants.map(n=>this.teamBasicRemapper.fromResponse(n)),t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var $o=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";squad=[]};var Ho=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var ko=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let t=new Ho;return t.id=e.id,t.startDate=e.start_date,t.endDate=e.end_date,t.shirtNumber=e.shirt_number,t.loan=e.loan,t.position=e.position,t.country=this.countryRemapper.countryFromResponse(e.country),t.name=e.name,t.assets=e.assets,t.birthDate=e.birth_date,t}catch(t){throw console.warn("There was a problem remapping the player from squad",t),t}}};var Vo=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new ne,this.competitionRemapper=new Be,this.playerRemapper=new ko}fromResponse(e){try{let t=new $o;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t.competitions=e.competitions?e.competitions.map(n=>this.competitionRemapper.fromResponse(n)):[],t.squad=e.squad?e.squad.map(n=>this.playerRemapper.fromResponse(n)):[],t}catch(t){throw console.warn("There was a problem remapping team response",t),t}}};var qo=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;context={competition:null};status={type:null,subType:null}};var Wo=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var Wr=class{fromResponse(e){try{let t=new Wo;return t.ftScore=this.statEntityFromResponse(e.ft_score),t.htScore=this.statEntityFromResponse(e.ht_score),t.aetScore=this.statEntityFromResponse(e.aet_score),t.aggScore=this.statEntityFromResponse(e.agg_score),t.penScore=this.statEntityFromResponse(e.pen_score),t}catch(t){throw console.warn("There was a problem remapping the scores",t),t}}statEntityFromResponse=e=>({homeGoals:e.home_goals,awayGoals:e.away_goals})};var Ko=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new Me,this.competitionRemapper=new Be,this.scoresRemapper=new Wr}fromResponse(e){try{let t=new qo;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.homeTeam=this.teamRemapper.fromResponse(e.home_team),t.awayTeam=this.teamRemapper.fromResponse(e.away_team),t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresRemapper.fromResponse(e.scores),t.context={competition:e.context.competition?this.competitionRemapper.fromResponse(e.context.competition):null},t.status={type:e.status.type,subType:e.status.sub_type},t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var Xo=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;stats=null;context={competition:null};timeline=[];status={type:null,subType:null};lineups=null};var Yo=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 zo=class{fromResponse(e){try{let t=new Yo;return t.corners=this.statEntityFromResponse(e.corners),t.crosses=this.statEntityFromResponse(e.crosses),t.offside=this.statEntityFromResponse(e.offside),t.shotsOn=this.statEntityFromResponse(e.shots_on),t.throwIn=this.statEntityFromResponse(e.throw_in),t.redCards=this.statEntityFromResponse(e.red_cards),t.shotsOff=this.statEntityFromResponse(e.shots_off),t.goalKicks=this.statEntityFromResponse(e.goal_kicks),t.possession=this.statEntityFromResponse(e.possession),t.treatments=this.statEntityFromResponse(e.treatments),t.yellowCards=this.statEntityFromResponse(e.yellow_cards),t.shotsBlocked=this.statEntityFromResponse(e.shots_blocked),t.substitutions=this.statEntityFromResponse(e.substitutions),t.counterAttacks=this.statEntityFromResponse(e.counter_attacks),t.foulsCommitted=this.statEntityFromResponse(e.fouls_committed),t}catch(t){throw console.warn("There was a problem remapping the stats",t),t}}statEntityFromResponse=e=>({homeTeam:e?e.home_team:null,awayTeam:e?e.away_team:null})};var Kr=class{homeTeam={players:[]};awayTeam={players:[]}};var Qo=class{id="";name="";position="";shirtNumber;assets=null;type=""};var Xr=class{fromResponse(e){try{let t=new Qo;return t.id=e.id,t.name=e.name,t.position=e.position,t.shirtNumber=e.shirt_number,t.assets=e.assets,t.type=e.type,t}catch(t){throw console.warn("There was a problem remapping the player from timeline",t),t}}};var Jo=class{playerRemapper=null;constructor(){this.playerRemapper=new Xr}fromResponse(e){try{let t=new Kr;return t.homeTeam.players=e.home_team&&e.home_team.players?e.home_team.players.map(n=>this.playerRemapper.fromResponse(n)):[],t.awayTeam.players=e.away_team&&e.away_team.players?e.away_team.players.map(n=>this.playerRemapper.fromResponse(n)):[],t}catch(t){throw console.warn("There was a problem remapping the lineups",t),t}}};var Zo=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var jo=class{playerRemapper=null;constructor(){this.playerRemapper=new Xr}fromResponse(e){try{let t=new Zo;return t.minute=e.minute,t.type=e.type,t.teamId=e.team_id,t.player=this.playerRemapper.fromResponse(e.player),t.relatedPlayer=e.related_player?this.playerRemapper.fromResponse(e.related_player):null,t.updatedAt=e.updated_at,t}catch(t){throw console.warn("There was a problem remapping timeline",t),t}}};var ea=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new Me,this.competitionsMapper=new Be,this.lineupsMapper=new Jo,this.scoresMapper=new Wr,this.statsMapper=new zo,this.timelineMapper=new jo}fromResponse(e){try{let t=new Xo;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.homeTeam=e.home_team?this.teamMapper.fromResponse(e.home_team):null,t.awayTeam=e.away_team?this.teamMapper.fromResponse(e.away_team):null,t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresMapper.fromResponse(e.scores),t.stats=this.statsMapper.fromResponse(e.stats),t.context={competition:this.competitionsMapper.fromResponse(e.context.competition)},t.timeline=e.timeline?e.timeline.map(n=>this.timelineMapper.fromResponse(n)):[],t.status={type:e.status.type,subType:e.status.sub_type},t.lineups=e.lineups?this.lineupsMapper.fromResponse(e.lineups):new Kr,t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var ta=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var ra=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let t=new ta;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping top player response",t),t}}};var ia=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;teams=[]};var Yr=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new ne,this.teamRemapper=new Me}fromResponse(e){try{let t=new ia;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(n=>this.teamRemapper.fromResponse(n)):[],t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping players response",t),t}}};var na=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;competitions=[];teams=[]};var oa=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new ne,this.teamRemapper=new Me,this.competitionRemapper=new Be}fromResponse(e){try{let t=new na;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(n=>this.teamRemapper.fromResponse(n)):[],t.position=e.position,t.competitions=e.competitions?e.competitions.map(n=>this.competitionRemapper.fromResponse(n)):[],t}catch(t){throw console.warn("There was a problem remapping player response",t),t}}};var aa=class{teams=null;players=null;competitions=null};var sa=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new Me,this.playerRemapper=new Yr,this.competitionremapper=new Be}fromResponse(e){try{let t=new aa;return t.teams=e.teams?e.teams.map(n=>this.teamRemapper.fromResponse(n)):[],t.players=e.players?e.players.map(n=>this.playerRemapper.fromResponse(n)):[],t.competitions=e.competitions?e.competitions.map(n=>this.competitionremapper.fromResponse(n)):[],t}catch(t){throw console.warn("There was a problem remapping search response",t),t}}};var zr=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var Jt=class{pagination=new zr};var Qr=class{meta=new Jt;data=[]};var la=class{remapMetaProp=e=>{let t=new Jt;return t.pagination.currentPage=e.pagination.current_page,t.pagination.itemsPerPage=e.pagination.items_per_page,t.pagination.totalItems=e.pagination.total_items,t.pagination.numberOfPages=e.pagination.number_of_pages,t}};var 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 t=Ae(e.environment,"football");this.apiSignInUrl=`?key=${e.apiKey}&lang=${e.lang}`,this.instance=gd.default.create({baseURL:t}),this.countryRemapper=new ne,this.competitionBasicRemapper=new Be,this.competitionFullRemapper=new Go,this.teamBasicRemapper=new Me,this.teamFullRemapper=new Vo,this.matchBasicRemapper=new Ko,this.matchFullRemapper=new ea,this.playerBasicRemapper=new Yr,this.playerFullRemapper=new oa,this.topPlayerRemapper=new ra,this.searchRemapper=new sa,this.footballMetaRemapper=new la}getCountries=async e=>{try{let t=`/countries${this.apiSignInUrl}`,n=Date.now();e&&(t+=`&disable_cache=${n}`);let a=await this.instance.get(t);return this.countryRemapper.countriesFromResponse(a.data.data)}catch(t){throw console.warn("There was a problem with the football countries request",t),t}};getCompetitions=async(e,t)=>{try{let n={},a=Date.now();if(t=t||!1,e&&e.competitionIds&&e.competitionIds.length>this.limitIds-1){let p=[],d=to(e.competitionIds);for(let b of d){e.competitionIds=b;let F=`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(F+=`&disable_cache=${a}`),n=await this.instance.get(F),p.push(n.data.data.map(w=>this.competitionBasicRemapper.fromResponse(w)))}return Array.prototype.concat.apply([],p)}else{let p=`/competitions${this.apiSignInUrl}`;return e&&(p+=`${e.constructFilterUrl()}`),t&&(p+=`&disable_cache=${a}`),n=await this.instance.get(p),n.data.data.map(d=>this.competitionBasicRemapper.fromResponse(d))}}catch(n){throw console.warn("There was a problem with getCompetitions request",n),n.response}};getCompetitionById=async(e,t)=>{try{let n=`/competitions/${e}${this.apiSignInUrl}`,a=Date.now();t&&(n+=`&disable_cache=${a}`);let p=await this.instance.get(n);return this.competitionFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getCompetitionById request",n),n.response}};getTopCompetitions=async e=>{try{let t=`/competitions/top${this.apiSignInUrl}&client_id=${this.clientId}`,n=Date.now();return e&&(t+=`&disable_cache=${n}`),(await this.instance.get(t)).data.data.map(p=>this.competitionBasicRemapper.fromResponse(p))}catch(t){throw console.warn("There was a problem with getTopCompetitions request",t),t.response}};getTeams=async(e,t)=>{try{let n={},a=Date.now();if(e&&e.teamIds&&e.teamIds.length>this.limitIds){let p=[],d=to(e.teamIds);for(let b of d){e.teamIds=b;let F=`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(F+=`disable_cache=${a}`),n=await this.instance.get(F),p.push(n.data.data.map(w=>this.teamBasicRemapper.fromResponse(w)))}return Array.prototype.concat.apply([],p)}else{let p=new Qr,d=`/teams${this.apiSignInUrl}`;return e&&(d+=`${e.constructFilterUrl()}`),t&&(d+=`&disable_cache=${a}`),n=await this.instance.get(d),p.meta=this.footballMetaRemapper.remapMetaProp(n.data.meta),p.data=n.data.data.map(h=>this.teamBasicRemapper.fromResponse(h)),p}}catch(n){throw console.warn("There was a problem with getTeams request",n),n.response}};getTeamById=async(e,t)=>{try{let n=`/teams/${e}${this.apiSignInUrl}`,a=Date.now();t&&(n+=`disable_cache=${a}`);let p=await this.instance.get(n);return this.teamFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getTeamById request",n),n.response}};getTopTeams=async e=>{try{let t=`/teams/top${this.apiSignInUrl}&client_id=${this.clientId}`,n=Date.now();e&&(t+=`$disable_cache=${n}`);let a=await this.instance.get(t);return a.data.data?a.data.data.map(p=>this.teamBasicRemapper.fromResponse(p)):[]}catch(t){throw console.warn("There was a problem with getTopTeams request",t),t.response}};getNextMatchForTeam=async(e,t)=>{try{let n=`/teams/${e}/next-match${this.apiSignInUrl}`,a=Date.now();t&&(n+=`&disable_cache=${a}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getNextMatchForTeam request",n),n.response}};getPrevMatchForTeam=async(e,t)=>{try{let n=`/teams/${e}/previous-match${this.apiSignInUrl}`,a=Date.now();t&&(n+=`disable_cache=${a}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getPrevMatchForTeam request",n),n.response}};getPlayers=async(e,t)=>{try{let n={},a=Date.now();if(e&&e.playerIds&&e.playerIds.length>this.limitIds-1){let p=[],d=to(e.playerIds);for(let b of d){e.playerIds=b;let F=`/players${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(F+=`&disable_cache=${a}`),n=await this.instance.get(F),p.push(n.data.data.map(w=>this.teamBasicRemapper.fromResponse(w)))}return Array.prototype.concat.apply([],p)}else{let p=new Qr,d=`/players${this.apiSignInUrl}`;return e&&(d+=`${e.constructFilterUrl()}`),t&&(d+=`&disable_cache=${a}`),n=await this.instance.get(d),p.meta=this.footballMetaRemapper.remapMetaProp(n.data.meta),p.data=n.data.data.map(h=>this.playerBasicRemapper.fromResponse(h)),p}}catch(n){throw console.warn("There was a problem with getPlayers request",n),n.response}};getPlayerById=async(e,t)=>{try{let n=`/players/${e}${this.apiSignInUrl}`,a=Date.now();t&&(n+=`&disable_cache=${a}`);let p=await this.instance.get(n);return this.playerFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getPlayerById request",n),n.response}};getTopPlayers=async e=>{try{let t=`/players/top${this.apiSignInUrl}&client_id=${this.clientId}`,n=Date.now();return e&&(t+=`&disable_cache=${n}`),(await this.instance.get(t)).data.data.map(p=>this.topPlayerRemapper.fromResponse(p))}catch(t){throw console.warn("There was a problem with getTopPlayers request",t),t.response}};getNextMatchForPlayer=async(e,t)=>{try{let n=`/players/${e}/next-match${this.apiSignInUrl}`,a=Date.now();t&&(n+=`&disable_cache=${a}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getNextMatchForPlayer request",n),n.response}};getPrevMatchForPlayer=async(e,t)=>{try{let n=`/players/${e}/previous-match${this.apiSignInUrl}`,a=Date.now();t&&(n+=`&disable_cache=${a}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getPrevMatchForPlayer request",n),n.response}};getMatchById=async(e,t)=>{try{let n=`/matches/${e}${this.apiSignInUrl}`,a=Date.now();t&&(n+=`&disable_cache=${a}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getMatchById request",n),n.response}};getMatches=async(e,t)=>{try{let n=new Qr,a=`/matches${this.apiSignInUrl}`,p=Date.now();e&&(a+=`${e.constructFilterUrl()}`),t&&(a+=`&disable_cache=${p}`);let d=await this.instance.get(a);return n.meta=this.footballMetaRemapper.remapMetaProp(d.data.meta),n.data=d.data.data.map(h=>this.matchBasicRemapper.fromResponse(h)),n}catch(n){throw console.warn("There was a problem with getMatches request",n),n.response}};search=async(e,t)=>{try{let n=`/search${this.apiSignInUrl}${e.constructFilterUrl()}`,a=Date.now();t&&(n+=`&disable_cache=${a}`);let p=await this.instance.get(n);return this.searchRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with search request",n),n.response}}};var Mp=Wt(Kt());var Ie=(V=>(V.FT_1X2="FT_1X2",V.HT_1X2="HT_1X2",V.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",V.DOUBLE_CHANCE="DOUBLE_CHANCE",V.HT_FT="HT_FT",V.PLAYER_SCORE="PLAYER_SCORE",V.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",V.PLAYER_RED_CARD="PLAYER_RED_CARD",V.RED_CARD_MATCH="RED_CARD_MATCH",V.PENALTY_MATCH="PENALTY_MATCH",V.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",V.CORNERS_MATCH="CORNERS_MATCH",V.CORRECT_SCORE="CORRECT_SCORE",V.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",V.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",V.OVER_GOALS_0_5="OVER_GOALS_0_5",V.OVER_GOALS_1_5="OVER_GOALS_1_5",V.OVER_GOALS_2_5="OVER_GOALS_2_5",V.OVER_GOALS_3_5="OVER_GOALS_3_5",V.OVER_GOALS_4_5="OVER_GOALS_4_5",V.OVER_GOALS_5_5="OVER_GOALS_5_5",V.OVER_GOALS_6_5="OVER_GOALS_6_5",V.OVER_CORNERS_6_5="OVER_CORNERS_6_5",V.OVER_CORNERS_7_5="OVER_CORNERS_7_5",V.OVER_CORNERS_8_5="OVER_CORNERS_8_5",V.OVER_CORNERS_9_5="OVER_CORNERS_9_5",V.OVER_CORNERS_10_5="OVER_CORNERS_10_5",V.OVER_CORNERS_11_5="OVER_CORNERS_11_5",V.OVER_CORNERS_12_5="OVER_CORNERS_12_5",V.OVER_CORNERS_13_5="OVER_CORNERS_13_5",V))(Ie||{}),yd=["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"],Md=["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"],Zt=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"],wd=["FT_1X2","HT_1X2","HT_FT","DOUBLE_CHANCE","CORNERS_MATCH","CORRECT_SCORE"],pa="PLAYER_SCORE_FIRST_GOAL";var ca=class{overallPercent;byFootballCompetition;byFootballTeam;byFootballMarket};var ua=class{profileId;tier;points;successRates=new ca};var ma=class{successRatePercent;model=null};var da=class{id=null;label=null};var fa=class{type=null;id=null;label=null};var Jr=class{content=new fa;tags=[];campaign=new da};var Zr=class{id=null;profileId=null;action=null;context=new Jr;points=0};var ha=class{totalItems=0};var ga=class{meta=new ha;data=[new Zr]};var ya=class{remapSingleResponse=e=>{let t=new Zr;return t.id=e.id,t.profileId=e.profile_id,t.action=e.action,t.context.content=e.context.content??t.context.content,t.context.tags=e.context.tags,t.context.campaign=e.context.campaign??t.context.campaign,t.points=e.points,t};remapActivitiesResponse=e=>{let t=new ga;return t.meta.totalItems=e.meta.total_items,t.data=e.data.map(n=>this.remapSingleResponse(n)),t};remapStatsReponse=e=>{let t=new ua;return t.profileId=e.profile_id,t.tier=e.tier,t.points=e.points,t.successRates.overallPercent=e.success_rates.overall_percent,t.successRates.byFootballCompetition=this.constructNewRecord(e.success_rates.by_competition),t.successRates.byFootballTeam=this.constructNewRecord(e.success_rates.by_team),t.successRates.byFootballMarket=this.constructNewRecord(e.success_rates.by_market),t};constructNewRecord=e=>{let t;if(Object.entries(e).length)Object.entries(e).forEach(([n,a])=>{t={...t,[n]:this.remapSuccessRatePercent(a)},Ie[n]&&delete t[n].model});else return e;return t};remapSuccessRatePercent=e=>{let t=new ma;return t.successRatePercent=e.success_rate_percent,t}};var jr=class{instanceAuth=null;instance=null;activityRemapper=null;apiSignInUrl=null;constructor(e){let t=Ae(e.environment,"loyalty");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instanceAuth=Mp.default.create({baseURL:t,headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.authProvider.getIdToken()}`}}),this.instance=Mp.default.create({baseURL:t,headers:{"Content-Type":"application/json"}}),this.activityRemapper=new ya}createActivity=async e=>{try{let t=`/activities${this.apiSignInUrl}`,n=await this.instanceAuth.post(t,JSON.stringify(e));return this.activityRemapper.remapSingleResponse(n.data)}catch(t){throw console.warn("There was a problem with creating activity for user",t),t}};deleteActivity=async e=>{try{let t=`/activities/${e}${this.apiSignInUrl}`;return await this.instanceAuth.delete(t),!0}catch(t){throw console.warn(`There was a problem deleting the following activity: ${e}`,t),t.response}};getOwnActivities=async(e,t)=>{try{let n=`/activities${this.apiSignInUrl}`,a=Date.now();e&&(n+=`${e.constructFilterUrl()}`),t&&(n+=`disable_cache=${a}`);let p=await this.instanceAuth.get(n);return this.activityRemapper.remapActivitiesResponse(p.data)}catch(n){throw console.warn("There was a problem with fetching own activities",n),n}};getActivitiesForUser=async(e,t,n)=>{try{let a=`/users/${e}/activities${this.apiSignInUrl}`,p=Date.now();t&&(a+=`${t.constructFilterUrl()}`),n&&(a+=`disable_cache=${p}`);let d=await this.instance.get(a);return this.activityRemapper.remapActivitiesResponse(d.data)}catch(a){throw console.warn(`There was a problem with fetching activities for user ${e}`,a),a}};getStats=async(e,t)=>{try{let n="",a=null;return e?(n+=ge(t)?`/users/${e}/statistics${this.apiSignInUrl}${ye()}`:`/users/${e}/statistics${this.apiSignInUrl}`,a=await this.instance.get(n)):(n+=`/statistics${this.apiSignInUrl}`,a=await this.instanceAuth.get(n)),this.activityRemapper.remapStatsReponse(a.data.data)}catch(n){throw console.warn("There was a problem fetching profile`s statistics:",n),n.response}}};var Ma=class{idMapping=null;idSchema=null;native="native";footballFacade=null;constructor(e,t,n){this.idMapping=n,this.idSchema=e.idSchema,this.footballFacade=t}remapSuccessRatesEntities=async e=>{let{successRates:t}=e,n={competition:this.getIdsKeys(t.byFootballCompetition),team:this.getIdsKeys(t.byFootballTeam)};if(Object.values(n).flat().length){let a=e.successRates.byFootballCompetition,p=e.successRates.byFootballTeam;return e.successRates.byFootballCompetition=await this.setModels(a,n.competition,"competition"),e.successRates.byFootballTeam=await this.setModels(p,n.team,"team"),e}return e};setModels=async(e,t,n)=>{let a=null,p;switch(t=ud(t),n){case"competition":a=await this.footballFacade.getCompetitionsMapWithNativeIds(t);break;case"team":a=await this.footballFacade.getTeamsMapWithNativeIds(t);break}return Object.keys(e).forEach(d=>{let h=a.get(d);p={...p,[h.id]:e[d]},p[h.id].model=h}),p};getIdsKeys=e=>{let t=JSON.parse(JSON.stringify(e));return Object.keys(t)};remapInterestsToIdSchema=async e=>{if(this.idSchema!==this.native)if(e&&e.length>0){let t={},n={};e.forEach(d=>{t.hasOwnProperty(d.type)||(t[d.type]=[],n[d.type]=[]),t[d.type].push(d.id),n[d.type].push(d)});let a=await this.remapIdsObj(t,this.native,this.idSchema),p=[];for(let[d,h]of Object.entries(n))h.forEach((b,F)=>{b.id=a[d][F],p.push(b)});return p}else return e;return e};remapInterestToNative=async e=>{if(this.idSchema!==this.native){let t={},{id:n,type:a}=e;t[a]=[n];let p=await this.remapIdsObj(t,this.idSchema,this.native);return e.id=p[a][0],e}return e};inquiryCustomInterests=async e=>{let t=[];if(e&&e.length>0&&(t=e.filter(n=>n.source==="custom")),t&&t.length>0){let n=e.filter(p=>p.source!=="custom"),a=await this.remapInterestsToIdSchema(n);return t.forEach(p=>a.push(p)),a}return await this.remapInterestsToIdSchema(e)};remapIdsObj=async(e,t,n)=>await this.idMapping.idMappingFacade.getEntitiesByIds(e,t,n)};var wa=class{idMapping=null;profileOperations=null;constructor(e,t){this.idMapping=new ce(e),this.profileOperations=new Ma(e,t,this.idMapping)}remapSuccessRatesEntities=async e=>await this.profileOperations.remapSuccessRatesEntities(e);remapInterestToNative=async e=>await this.profileOperations.remapInterestToNative(e);inquiryCustomInterests=async e=>await this.profileOperations.inquiryCustomInterests(e)};var ei=class{idsRemapper=null;profileHttps=null;activityHttps=null;footballHttps=null;footballFacade=null;idMapping=null;localStorage=null;profileFacade=null;ownProfileBuilder=null;profileBuilder=null;constructor(e){this.profileHttps=new Dr(e),this.activityHttps=new jr(e),this.footballHttps=new Mt(e),this.idMapping=new ce(e),this.localStorage=new gt(e),this.footballFacade=new qr(e,this.localStorage,this.footballHttps,this.idMapping),this.profileFacade=new yt(this.localStorage,this.profileHttps,this.activityHttps),this.idsRemapper=new wa(e,this.footballFacade),this.ownProfileBuilder=new bo(this.idsRemapper,this.localStorage,this.profileHttps,this.activityHttps,this.idMapping,this.footballFacade),this.profileBuilder=new vo(this.idsRemapper,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,t)=>await this.profileFacade.getByIds(e,t)};var ba=class{validate=e=>{let t=this.validateField(e.lang),n=this.generateMessage(t);return{validation:t,message:n}};validateField=e=>{let t=["bg","ro","en"],n=null;return e!=null&&e.length>0?t.includes(e)?n="valid":n="invalid":n="missing",n};generateMessage=e=>{let t=null,n="warning";return e==="missing"&&(t="If no lang is passed the default one will be set which is: en"),e==="invalid"&&(t="This lang value is not supported, the default one will be set which is: en"),e==="valid"&&(t=null,n=null),{text:t,type:n}}};var va=class{validate(e){let t=this.validateField(e.environment),n=this.generateMessage(t);return{validation:t,message:n}}validateField=e=>{let t=["dev","staging","prod"],n=null;return e!=null&&e.length>0?t.includes(e)?n="valid":n="invalid":n="missing",n};generateMessage=e=>{let t=null,n="warning";return e==="missing"&&(t="If no environment is passed the default one will be set which is: prod"),e==="invalid"&&(t="This environment value is not supported, the default one will be set which is: prod"),e==="valid"&&(t=null,n=null),{text:t,type:n}}};var Pa=class{validate(e){let t=this.validateField(e.apiKey),n=this.generateMessage(t);return{validation:t,message:n}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,n="error";return e==="missing"&&(t="The field apiKey with valid value must be provided to use Fans United JS SDK"),e==="valid"&&(n=null),{text:t,type:n}}};var Ia=class{validate(e){let t=this.validateField(e.idSchema),n=this.generateMessage(t);return{validation:t,message:n}}validateField=e=>{let t=["native","sportal365","enetpulse","sportradar"],n=null;return e!=null&&e.length>0?t.includes(e)?n="valid":n="invalid":n="missing",n};generateMessage=e=>{let t=null,n="warning";return e==="missing"&&(t="If no idSchema is passed the default one will be set which is: native"),e==="invalid"&&(t="This idSchema value is not supported, the default one will be set which is: native"),e==="valid"&&(t=null,n=null),{text:t,type:n}}};var dr=class{getIdToken=null;logout=null};var ri=class{text=null;type=null};var _a=class{validation=null;message=new ri;getIdToken={validation:null,message:new ri};logout={validation:null,message:new ri}};var Ra=class{validate(e){let t=this.validateAuthProvider(e.authProvider);return t.validation!=="missing"&&(t=this.validateAuthProviderConfigFields(e.authProvider,t),t=this.generateAuthProviderConfigMessages(t),t=this.checkAuthProviderConfigMessagesForErrors(t)),t}validateAuthProvider=e=>{let t=Object.keys(new dr),n=new _a;if(e){let p=Object.keys(e).filter(d=>!t.includes(d));p.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:"} ${p.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,t)=>(Object.keys(new dr).forEach(a=>{e[a]?t[a].validation="valid":t[a].validation="missing"}),t);generateAuthProviderConfigMessages=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{let n=e[t];n.validation==="missing"&&(n.message.text=`${"The following property is missing from the authProvider object:"} ${t}`,n.message.type="error")}),e);checkAuthProviderConfigMessagesForErrors=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{e[t].validation==="missing"&&e.validation==="valid"&&(e.validation="invalid",e.message.type="error",e.message.text="The field authProvider has missing properties")}),e)};var zi=class{validation;message};var Fa=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;authProvider={getIdToken:new zi,logout:new zi};isValid=!1};var Sa=class{validate(e){let t=this.validateField(e.clientId),n=this.generateMessage(t);return{validation:t,message:n}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,n="error";return e==="missing"&&(t="The field clientId must be provided to use Fans United JS SDK"),e==="valid"&&(t=null,n=null),{text:t,type:n}}};var Ta=class{validate=e=>{let t=this.checkFieldsForValues(e);return t.isValid=this.containsErrorMessage(t),t};checkFieldsForValues=e=>{let t=new Fa,n={apiKey:new Pa,environment:new va,idSchema:new Ia,clientId:new Sa,lang:new ba,authProvider:new Ra};for(let[a,p]of Object.entries(t))a!=="isValid"&&(p=n[a].validate(e));return Object.keys(n).forEach(a=>{t[a]=n[a].validate(e)}),t};containsErrorMessage=e=>{let t=!0;for(let[n,a]of Object.entries(e))if(n!=="authProvider"){if(n!=="isValid"&&a.message.type==="error")return t=!1,t;if(n!=="isValid"&&a.message.type==="warning")return t=!0,t}else if(a.message.type==="error")return t=!1,t;return t}};var Ea=class{https=null;idMapping=null;localStorage=null;footballFacade=null;constructor(e){this.https=new Mt(e),this.idMapping=new ce(e),this.localStorage=new gt(e),this.footballFacade=new qr(e,this.localStorage,this.https,this.idMapping)}getCountries=async e=>await this.footballFacade.getCountries(e);getCompetitions=async(e,t)=>await this.footballFacade.getCompetitions(e,t);getCompetitionById=async(e,t)=>await this.footballFacade.getCompetitionById(e,t);getTopCompetitions=async e=>await this.footballFacade.getTopCompetitions(e);getTeams=async(e,t)=>await this.footballFacade.getTeams(e,t);getTeamById=async(e,t)=>await this.footballFacade.getTeamById(e,t);getTopTeams=async e=>await this.footballFacade.getTopTeams(e);getNextMatchForTeam=async(e,t)=>await this.footballFacade.getNextMatchForTeam(e,t);getPrevMatchForTeam=async(e,t)=>await this.footballFacade.getPrevMatchForTeam(e,t);getPlayers=async(e,t)=>await this.footballFacade.getPlayers(e,t);getPlayerById=async(e,t)=>await this.footballFacade.getPlayerById(e,t);getTopPlayers=async e=>await this.footballFacade.getTopPlayers(e);getNextMatchForPlayer=async(e,t)=>await this.footballFacade.getNextMatchForPlayer(e,t);getPrevMatchForPlayer=async(e,t)=>await this.footballFacade.getPrevMatchForPlayer(e,t);getMatches=async(e,t)=>await this.footballFacade.getMatches(e,t);getMatchById=async(e,t)=>await this.footballFacade.getMatchById(e,t);search=async(e,t)=>await this.footballFacade.search(e,t)};var _p=Wt(Kt());var Ca=class{value=null;playerId=null;playerModel=null};var ii=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new Ca;result=null};var xa=class{value=!1;playerId=null};var et=class{matchId=null;market=null;prediction=null;constructor(e,t,n,a){this.matchId=e,this.market=t,this.prediction=new xa,this.prediction.value=n,this.prediction.playerId=a}};var ni=class{settledAt=null;resettledAt=null;status=null;outcome=null;points=0};var Aa=class{value=null};var jt=class{matchId=null;market="CORRECT_SCORE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Aa,this.prediction.value=t}};var tt=class{value=!1};var oi=class{matchId=null;market=null;prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new tt,this.prediction.value=n}};var ai=class{matchId=null;market=null;prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new tt,this.prediction.value=n}};var Oa=class{matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t,n){this.matchFacade=e,this.playerFacade=t,this.predictorService=n}remapFixturesRequest=e=>{let t={};if(t.match_id=e.matchId,t.match_type="FOOTBALL",e instanceof et)t.market=e.market,t.prediction=e.prediction.value,t.player_id=e.prediction.playerId;else if(e instanceof oi||e instanceof ai)t.market=e.market,t.prediction=e.prediction.value;else if(e instanceof jt){t.market=e.market;let n=e.prediction.value.split(":");t.goals_home=Number(n[0]),t.goals_away=Number(n[1])}else t.market=e.market,t.prediction=e.prediction.value;return t};remapFixturesResponse=async e=>{e.length>1&&e.sort((h,b)=>h.match_id.localeCompare(b.match_id));let t=[],n=[];for(let h of e)t.push(h.match_id),h.player_id&&!n.includes(h.player_id)&&n.push(h.player_id);let a=await this.matchFacade.getMatchesMapWithNativeIds(t),p=[];n.sort((h,b)=>h.localeCompare(b)),n&&n.length>0&&(p=await this.playerFacade.getPlayersMapWithNativeIds(n));let d=[];for(let h of e){let b=new ii;h.target?b.market=this.predictorService.convertMarketForResponseModel(h.market,h.target):b.market=h.market,b.matchId=a[h.match_id].id,b.matchType=h.match_type,b.matchModel=a?a[h.match_id]:null,delete b.matchModel.availableMarkets,h.goals_home!==void 0&&h.goals_away!==void 0?b.prediction.value=h.goals_home.toString()+":"+h.goals_away.toString():b.prediction.value=h.prediction,b.prediction.playerId=h.player_id?h.player_id:null,b.prediction.playerId&&(b.prediction.playerModel=p[h.player_id],b.prediction.playerId=p[h.player_id].id),b.result=this.remapResult(h.result),d.push(b)}return d};remapResult=e=>{let t=new ni;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t.points=e.points,t}};var si=class{goldenGoal=null};var Qi=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new si;points=null;createdAt=null;updatedAt=null};var j=class{no=0;yes=0};var li=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new j;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new j;penaltyMatch=new j;playerScoreFirstGoal={};cornersMatch={};correctScore={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new j;overOnePointFiveGoals=new j;overTwoPointFiveGoals=new j;overThreePointFiveGoals=new j;overFourPointFiveGoals=new j;overFivePointFiveGoals=new j;overSixPointFiveGoals=new j;overSixPointFiveCorners=new j;overSevenPointFiveCorners=new j;overEightPointFiveCorners=new j;overNinePointFiveCorners=new j;overTenPointFiveCorners=new j;overElevenPointFiveCorners=new j;overTwelvePointFiveCorners=new j;overThirteenPointFiveCorners=new j};var wp=(n=>(n.ONE="1",n.X="x",n.TWO="2",n))(wp||{}),bp=(n=>(n.ONE_X="1x",n.X_TWO="x2",n.ONE_TWO="12",n))(bp||{}),vp=(F=>(F.ONE_ONE="1/1",F.ONE_X="1/x",F.ONE_TWO="1/2",F.X_ONE="x/1",F.X_X="x/x",F.X_TWO="x/2",F.TWO_ONE="2/1",F.TWO_X="2/x",F.TWO_TWO="2/2",F))(vp||{});var Ba=class{value=null};var La=class{matchId=null;market="HT_FT";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Ba,this.prediction.value=t}};var Na=class{value=null};var Da=class{matchId=null;market="DOUBLE_CHANCE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Na,this.prediction.value=t}};var pi=class{value=null};var Ua=class{matchId=null;market="FT_1X2";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new pi,this.prediction.value=t}};var Ga=class{matchId=null;market="HT_1X2";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new pi,this.prediction.value=t}};var $a=class{value};var Ha=class{matchId=null;market="CORNERS_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new $a,this.prediction.value=t}};var ka=class{matchId=null;market="BOTH_TEAMS_SCORE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new tt,this.prediction.value=t}};var Va=class{matchId=null;market="RED_CARD_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new tt,this.prediction.value=t}};var qa=class{matchId=null;market="PENALTY_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new tt,this.prediction.value=t}};var fr=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null};var hr=class{userId=null;points=null;results=[];tiebreaker=null};var Wa=(p=>(p.ACTIVE="ACTIVE",p.WON="WON",p.LOST="LOST",p.PARTIALLY_WON="PARTIALLY_WON",p.CANCELED="CANCELED",p))(Wa||{}),Pp=["WON","LOST","PARTIALLY_WON","CANCELED"];var _e=class{limit=null;startAfter=null;status=null;type=null;matchIds=null;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null,this.status=e.status?e.status:null,this.type=e.type?e.type:null,this.matchIds=e.matchIds?e.matchIds:null}constructFiltersUrl=()=>{let e="",t=!1;return this.status&&(t=Object.values(Wa).some(n=>this.status.includes(n))),this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),this.status&&t&&(e+="&",e+=`status=${this.status.join(",")}`),this.type&&(e+="&",e+=`game_types=${this.type}`),this.matchIds&&(e+="&",e+=`match_ids=${this.matchIds.join(",")}`),e}};var Ji=(d=>(d.OPEN="OPEN",d.LIVE="LIVE",d.PENDING="PENDING",d.CANCELED="CANCELED",d.CLOSED="CLOSED",d.SETTLED="SETTLED",d))(Ji||{});var Ve=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(Ji).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 gr=class{id=null;title=null;description=null;type=null;status=null;predictionsCutoff=null;fixtures=[];rules=null;flags=null;createdAt=null;updatedAt=null};var Ot=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null};var Ip={UNEXPECTED_STATUS_PROP:`Unexpected provided property 'status'. You can NOT use this property for this method. For more information visit our documentation:
21
+ }`;var D=em(function(){return q(m,C+"return "+R).apply(s,f)});if(D.source=R,Dl(D))throw D;return D}function _b(r){return W(r).toLowerCase()}function Rb(r){return W(r).toUpperCase()}function Fb(r,i,o){if(r=W(r),r&&(o||i===s))return pc(r);if(!r||!(i=De(i)))return r;var l=nt(r),c=nt(i),m=cc(l,c),f=uc(l,c)+1;return Vt(l,m,f).join("")}function Sb(r,i,o){if(r=W(r),r&&(o||i===s))return r.slice(0,dc(r)+1);if(!r||!(i=De(i)))return r;var l=nt(r),c=uc(l,nt(i))+1;return Vt(l,0,c).join("")}function Tb(r,i,o){if(r=W(r),r&&(o||i===s))return r.replace(Ds,"");if(!r||!(i=De(i)))return r;var l=nt(r),c=cc(l,nt(i));return Vt(l,c).join("")}function Eb(r,i){var o=Pd,l=Id;if(Z(i)){var c="separator"in i?i.separator:c;o="length"in i?N(i.length):o,l="omission"in i?De(i.omission):l}r=W(r);var m=r.length;if(vr(r)){var f=nt(r);m=f.length}if(o>=m)return r;var g=o-Pr(l);if(g<1)return l;var M=f?Vt(f,0,g).join(""):r.slice(0,g);if(c===s)return M+l;if(f&&(g+=M.length-g),Ul(c)){if(r.slice(g).search(c)){var I,_=M;for(c.global||(c=el(c.source,W(xp.exec(c))+"g")),c.lastIndex=0;I=c.exec(_);)var R=I.index;M=M.slice(0,R===s?g:R)}}else if(r.indexOf(De(c),g)!=g){var T=M.lastIndexOf(c);T>-1&&(M=M.slice(0,T))}return M+l}function Cb(r){return r=W(r),r&&$d.test(r)?r.replace(Tp,oh):r}var xb=Tr(function(r,i,o){return r+(o?" ":"")+i.toUpperCase()}),Hl=tu("toUpperCase");function ju(r,i,o){return r=W(r),i=o?s:i,i===s?eh(r)?lh(r):Wf(r):r.match(i)||[]}var em=U(function(r,i){try{return Le(r,s,i)}catch(o){return Dl(o)?o:new B(o)}}),Ab=Ft(function(r,i){return Ke(i,function(o){o=ft(o),_t(r,o,Ll(r[o],r))}),r});function Ob(r){var i=r==null?0:r.length,o=x();return r=i?J(r,function(l){if(typeof l[1]!="function")throw new Xe(a);return[o(l[0]),l[1]]}):[],U(function(l){for(var c=-1;++c<i;){var m=r[c];if(Le(m[0],this,l))return Le(m[1],this,l)}})}function Bb(r){return og(ze(r,F))}function kl(r){return function(){return r}}function Lb(r,i){return r==null||r!==r?i:r}var Nb=iu(),Db=iu(!0);function Ce(r){return r}function Vl(r){return Oc(typeof r=="function"?r:ze(r,F))}function Ub(r){return Lc(ze(r,F))}function Gb(r,i){return Nc(r,ze(i,F))}var $b=U(function(r,i){return function(o){return Ci(o,r,i)}}),Hb=U(function(r,i){return function(o){return Ci(r,o,i)}});function ql(r,i,o){var l=pe(i),c=Tn(i,l);o==null&&!(Z(i)&&(c.length||!l.length))&&(o=i,i=r,r=this,c=Tn(i,pe(i)));var m=!(Z(o)&&"chain"in o)||!!o.chain,f=Tt(r);return Ke(c,function(g){var M=i[g];r[g]=M,f&&(r.prototype[g]=function(){var I=this.__chain__;if(m||I){var _=r(this.__wrapped__),R=_.__actions__=Se(this.__actions__);return R.push({func:M,args:arguments,thisArg:r}),_.__chain__=I,_}return M.apply(r,Nt([this.value()],arguments))})}),r}function kb(){return le._===this&&(le._=fh),this}function Wl(){}function Vb(r){return r=N(r),U(function(i){return Dc(i,r)})}var qb=Pl(J),Wb=Pl(nc),Kb=Pl(Xs);function tm(r){return El(r)?Ys(ft(r)):Pg(r)}function Xb(r){return function(i){return r==null?s:sr(r,i)}}var Yb=ou(),zb=ou(!0);function Kl(){return[]}function Xl(){return!1}function Qb(){return{}}function Jb(){return""}function Zb(){return!0}function jb(r,i){if(r=N(r),r<1||r>Bt)return[];var o=ut,l=fe(r,ut);i=x(i),r-=ut;for(var c=Js(l,i);++o<r;)i(o);return c}function ev(r){return L(r)?J(r,ft):Ue(r)?[r]:Se(vu(W(r)))}function tv(r){var i=++mh;return W(r)+i}var rv=Bn(function(r,i){return r+i},0),iv=Il("ceil"),nv=Bn(function(r,i){return r/i},1),ov=Il("floor");function av(r){return r&&r.length?Sn(r,Ce,ll):s}function sv(r,i){return r&&r.length?Sn(r,x(i,2),ll):s}function lv(r){return sc(r,Ce)}function pv(r,i){return sc(r,x(i,2))}function cv(r){return r&&r.length?Sn(r,Ce,ml):s}function uv(r,i){return r&&r.length?Sn(r,x(i,2),ml):s}var mv=Bn(function(r,i){return r*i},1),dv=Il("round"),fv=Bn(function(r,i){return r-i},0);function hv(r){return r&&r.length?Qs(r,Ce):0}function gv(r,i){return r&&r.length?Qs(r,x(i,2)):0}return u.after=UM,u.ary=Au,u.assign=Rw,u.assignIn=Ku,u.assignInWith=Xn,u.assignWith=Fw,u.at=Sw,u.before=Ou,u.bind=Ll,u.bindAll=Ab,u.bindKey=Bu,u.castArray=QM,u.chain=Eu,u.chunk=oy,u.compact=ay,u.concat=sy,u.cond=Ob,u.conforms=Bb,u.constant=kl,u.countBy=hM,u.create=Tw,u.curry=Lu,u.curryRight=Nu,u.debounce=Du,u.defaults=Ew,u.defaultsDeep=Cw,u.defer=GM,u.delay=$M,u.difference=ly,u.differenceBy=py,u.differenceWith=cy,u.drop=uy,u.dropRight=my,u.dropRightWhile=dy,u.dropWhile=fy,u.fill=hy,u.filter=yM,u.flatMap=bM,u.flatMapDeep=vM,u.flatMapDepth=PM,u.flatten=Ru,u.flattenDeep=gy,u.flattenDepth=yy,u.flip=HM,u.flow=Nb,u.flowRight=Db,u.fromPairs=My,u.functions=Dw,u.functionsIn=Uw,u.groupBy=IM,u.initial=by,u.intersection=vy,u.intersectionBy=Py,u.intersectionWith=Iy,u.invert=$w,u.invertBy=Hw,u.invokeMap=RM,u.iteratee=Vl,u.keyBy=FM,u.keys=pe,u.keysIn=Ee,u.map=Hn,u.mapKeys=Vw,u.mapValues=qw,u.matches=Ub,u.matchesProperty=Gb,u.memoize=Vn,u.merge=Ww,u.mergeWith=Xu,u.method=$b,u.methodOf=Hb,u.mixin=ql,u.negate=qn,u.nthArg=Vb,u.omit=Kw,u.omitBy=Xw,u.once=kM,u.orderBy=SM,u.over=qb,u.overArgs=VM,u.overEvery=Wb,u.overSome=Kb,u.partial=Nl,u.partialRight=Uu,u.partition=TM,u.pick=Yw,u.pickBy=Yu,u.property=tm,u.propertyOf=Xb,u.pull=Sy,u.pullAll=Su,u.pullAllBy=Ty,u.pullAllWith=Ey,u.pullAt=Cy,u.range=Yb,u.rangeRight=zb,u.rearg=qM,u.reject=xM,u.remove=xy,u.rest=WM,u.reverse=Ol,u.sampleSize=OM,u.set=Qw,u.setWith=Jw,u.shuffle=BM,u.slice=Ay,u.sortBy=DM,u.sortedUniq=Gy,u.sortedUniqBy=$y,u.split=bb,u.spread=KM,u.tail=Hy,u.take=ky,u.takeRight=Vy,u.takeRightWhile=qy,u.takeWhile=Wy,u.tap=aM,u.throttle=XM,u.thru=$n,u.toArray=Vu,u.toPairs=zu,u.toPairsIn=Qu,u.toPath=ev,u.toPlainObject=Wu,u.transform=Zw,u.unary=YM,u.union=Ky,u.unionBy=Xy,u.unionWith=Yy,u.uniq=zy,u.uniqBy=Qy,u.uniqWith=Jy,u.unset=jw,u.unzip=Bl,u.unzipWith=Tu,u.update=eb,u.updateWith=tb,u.values=xr,u.valuesIn=rb,u.without=Zy,u.words=ju,u.wrap=zM,u.xor=jy,u.xorBy=eM,u.xorWith=tM,u.zip=rM,u.zipObject=iM,u.zipObjectDeep=nM,u.zipWith=oM,u.entries=zu,u.entriesIn=Qu,u.extend=Ku,u.extendWith=Xn,ql(u,u),u.add=rv,u.attempt=em,u.camelCase=ab,u.capitalize=Ju,u.ceil=iv,u.clamp=ib,u.clone=JM,u.cloneDeep=jM,u.cloneDeepWith=ew,u.cloneWith=ZM,u.conformsTo=tw,u.deburr=Zu,u.defaultTo=Lb,u.divide=nv,u.endsWith=sb,u.eq=at,u.escape=lb,u.escapeRegExp=pb,u.every=gM,u.find=MM,u.findIndex=Iu,u.findKey=xw,u.findLast=wM,u.findLastIndex=_u,u.findLastKey=Aw,u.floor=ov,u.forEach=Cu,u.forEachRight=xu,u.forIn=Ow,u.forInRight=Bw,u.forOwn=Lw,u.forOwnRight=Nw,u.get=Gl,u.gt=rw,u.gte=iw,u.has=Gw,u.hasIn=$l,u.head=Fu,u.identity=Ce,u.includes=_M,u.indexOf=wy,u.inRange=nb,u.invoke=kw,u.isArguments=cr,u.isArray=L,u.isArrayBuffer=nw,u.isArrayLike=Te,u.isArrayLikeObject=te,u.isBoolean=ow,u.isBuffer=qt,u.isDate=aw,u.isElement=sw,u.isEmpty=lw,u.isEqual=pw,u.isEqualWith=cw,u.isError=Dl,u.isFinite=uw,u.isFunction=Tt,u.isInteger=Gu,u.isLength=Wn,u.isMap=$u,u.isMatch=mw,u.isMatchWith=dw,u.isNaN=fw,u.isNative=hw,u.isNil=yw,u.isNull=gw,u.isNumber=Hu,u.isObject=Z,u.isObjectLike=ee,u.isPlainObject=Ni,u.isRegExp=Ul,u.isSafeInteger=Mw,u.isSet=ku,u.isString=Kn,u.isSymbol=Ue,u.isTypedArray=Cr,u.isUndefined=ww,u.isWeakMap=bw,u.isWeakSet=vw,u.join=_y,u.kebabCase=cb,u.last=Je,u.lastIndexOf=Ry,u.lowerCase=ub,u.lowerFirst=mb,u.lt=Pw,u.lte=Iw,u.max=av,u.maxBy=sv,u.mean=lv,u.meanBy=pv,u.min=cv,u.minBy=uv,u.stubArray=Kl,u.stubFalse=Xl,u.stubObject=Qb,u.stubString=Jb,u.stubTrue=Zb,u.multiply=mv,u.nth=Fy,u.noConflict=kb,u.noop=Wl,u.now=kn,u.pad=db,u.padEnd=fb,u.padStart=hb,u.parseInt=gb,u.random=ob,u.reduce=EM,u.reduceRight=CM,u.repeat=yb,u.replace=Mb,u.result=zw,u.round=dv,u.runInContext=y,u.sample=AM,u.size=LM,u.snakeCase=wb,u.some=NM,u.sortedIndex=Oy,u.sortedIndexBy=By,u.sortedIndexOf=Ly,u.sortedLastIndex=Ny,u.sortedLastIndexBy=Dy,u.sortedLastIndexOf=Uy,u.startCase=vb,u.startsWith=Pb,u.subtract=fv,u.sum=hv,u.sumBy=gv,u.template=Ib,u.times=jb,u.toFinite=Et,u.toInteger=N,u.toLength=qu,u.toLower=_b,u.toNumber=Ze,u.toSafeInteger=_w,u.toString=W,u.toUpper=Rb,u.trim=Fb,u.trimEnd=Sb,u.trimStart=Tb,u.truncate=Eb,u.unescape=Cb,u.uniqueId=tv,u.upperCase=xb,u.upperFirst=Hl,u.each=Cu,u.eachRight=xu,u.first=Fu,ql(u,function(){var r={};return mt(u,function(i,o){X.call(u.prototype,o)||(r[o]=i)}),r}(),{chain:!1}),u.VERSION=e,Ke(["bind","bindKey","curry","curryRight","partial","partialRight"],function(r){u[r].placeholder=u}),Ke(["drop","take"],function(r,i){$.prototype[r]=function(o){o=o===s?1:ae(N(o),0);var l=this.__filtered__&&!i?new $(this):this.clone();return l.__filtered__?l.__takeCount__=fe(o,l.__takeCount__):l.__views__.push({size:fe(o,ut),type:r+(l.__dir__<0?"Right":"")}),l},$.prototype[r+"Right"]=function(o){return this.reverse()[r](o).reverse()}}),Ke(["filter","map","takeWhile"],function(r,i){var o=i+1,l=o==Rp||o==V;$.prototype[r]=function(c){var m=this.clone();return m.__iteratees__.push({iteratee:x(c,3),type:o}),m.__filtered__=m.__filtered__||l,m}}),Ke(["head","last"],function(r,i){var o="take"+(i?"Right":"");$.prototype[r]=function(){return this[o](1).value()[0]}}),Ke(["initial","tail"],function(r,i){var o="drop"+(i?"":"Right");$.prototype[r]=function(){return this.__filtered__?new $(this):this[o](1)}}),$.prototype.compact=function(){return this.filter(Ce)},$.prototype.find=function(r){return this.filter(r).head()},$.prototype.findLast=function(r){return this.reverse().find(r)},$.prototype.invokeMap=U(function(r,i){return typeof r=="function"?new $(this):this.map(function(o){return Ci(o,r,i)})}),$.prototype.reject=function(r){return this.filter(qn(x(r)))},$.prototype.slice=function(r,i){r=N(r);var o=this;return o.__filtered__&&(r>0||i<0)?new $(o):(r<0?o=o.takeRight(-r):r&&(o=o.drop(r)),i!==s&&(i=N(i),o=i<0?o.dropRight(-i):o.take(i-r)),o)},$.prototype.takeRightWhile=function(r){return this.reverse().takeWhile(r).reverse()},$.prototype.toArray=function(){return this.take(ut)},mt($.prototype,function(r,i){var o=/^(?:filter|find|map|reject)|While$/.test(i),l=/^(?:head|last)$/.test(i),c=u[l?"take"+(i=="last"?"Right":""):i],m=l||/^find/.test(i);!c||(u.prototype[i]=function(){var f=this.__wrapped__,g=l?[1]:arguments,M=f instanceof $,I=g[0],_=M||L(f),R=function(G){var H=c.apply(u,Nt([G],g));return l&&T?H[0]:H};_&&o&&typeof I=="function"&&I.length!=1&&(M=_=!1);var T=this.__chain__,C=!!this.__actions__.length,A=m&&!T,D=M&&!C;if(!m&&_){f=D?f:new $(this);var O=r.apply(f,g);return O.__actions__.push({func:$n,args:[R],thisArg:s}),new Ye(O,T)}return A&&D?r.apply(this,g):(O=this.thru(R),A?l?O.value()[0]:O.value():O)})}),Ke(["pop","push","shift","sort","splice","unshift"],function(r){var i=mn[r],o=/^(?:push|sort|unshift)$/.test(r)?"tap":"thru",l=/^(?:pop|shift)$/.test(r);u.prototype[r]=function(){var c=arguments;if(l&&!this.__chain__){var m=this.value();return i.apply(L(m)?m:[],c)}return this[o](function(f){return i.apply(L(f)?f:[],c)})}}),mt($.prototype,function(r,i){var o=u[i];if(o){var l=o.name+"";X.call(Rr,l)||(Rr[l]=[]),Rr[l].push({name:i,func:o})}}),Rr[On(s,pt).name]=[{name:"wrapper",func:s}],$.prototype.clone=Ch,$.prototype.reverse=xh,$.prototype.value=Ah,u.prototype.at=sM,u.prototype.chain=lM,u.prototype.commit=pM,u.prototype.next=cM,u.prototype.plant=mM,u.prototype.reverse=dM,u.prototype.toJSON=u.prototype.valueOf=u.prototype.value=fM,u.prototype.first=u.prototype.head,Ii&&(u.prototype[Ii]=uM),u},Ut=ph();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(le._=Ut,define(function(){return Ut})):rr?((rr.exports=Ut)._=Ut,Vs._=Ut):le._=Ut}).call(Lr)});var hp=Wt(Kt());var cd=Wt(ld());var fp=s=>{let e=200,t=[],n=0;return t[n]=[],s.forEach(a=>{t[n].length<=e-1?t[n].push(a):(n++,t[n]=[a])}),t},to=s=>{let e=[],t=200;for(;s.length>t;){let n=s.splice(0,t);e.push(n)}return e.push(s),e},Ae=(s,e)=>{let t="",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"},p={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"?t=n[e]:s==="dev"?t=a[e]:t=p[e],t},Xt=s=>s.filter((t,n,a)=>n===a.indexOf(t)),ro=s=>Array.isArray(s)?s.map(e=>ro(e)):s!=null&&s.constructor===Object?Object.keys(s).reduce((e,t)=>({...e,[(0,cd.camelCase)(t)]:ro(s[t])}),{}):s,ge=s=>s||!1,ye=()=>`&disable_cache=${Date.now()}`,ud=s=>s.sort((e,t)=>e.localeCompare(t));var io=class{id=null;name=null;nickname=null;avatar=null;gender=null;country=null;birthDate=null;interests=[];followingCount=0;followersCount=0};var no=class{profilesFromResponse=e=>e?e.map(t=>this.fullProfileFromResponse(t)):null;fullProfileFromResponse=e=>{let t=new io;return t.id=e.id,t.name=e.name,t.nickname=e.nickname,t.avatar=e.avatar,t.gender=e.gender,t.country=e.country,t.birthDate=e.birth_date,t.interests=e.interests?e.interests:[],t.followingCount=e.following_count,t.followersCount=e.followers_count,t}};var oo=class{nextPageStartsAfter=null;itemsPerPage=null};var Nr=class{pagination=new oo};var ie=class{meta=new Nr;data=[]};var ao=class{avatar=null;followingId=null;name=null;profileId=null};var so=class{followResponse=e=>e.map(t=>this.remapResponse(t));followingFromResponse=e=>{let t=new ie;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapResponse(n)),t};remapResponse=e=>{let t=new ao;return t.avatar=e.avatar,t.followingId=e.following_id,t.name=e.name,t.profileId=e.profile_id,t}};var lo=class{avatar=null;followerId=null;name=null;profileId=null};var po=class{followersFromResponse=e=>{let t=new ie;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapResponse(n)),t};remapResponse=e=>{let t=new lo;return t.avatar=e.avatar,t.followerId=e.follower_id,t.name=e.name,t.profileId=e.profile_id,t}};var Hi=class{profile_ids=[]};var yP="/countries",Oe="/profile",md="/profiles",Dr=class{instanceAuth=null;instance=null;apiSignInUrl=null;profileRemapper=null;followingRemapper=null;followersRemapper=null;lang=null;constructor(e){this.lang=e.lang;let t=Ae(e.environment,"profile");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instanceAuth=hp.default.create({baseURL:t,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 p=e.authProvider.getIdToken();return a.headers.Authorization=`Bearer ${p}`,this.instanceAuth(a)}return Promise.reject(n)}),this.instance=hp.default.create({baseURL:t,headers:{"Content-Type":"application/json"}}),this.profileRemapper=new no,this.followingRemapper=new so,this.followersRemapper=new po}getCountries=async e=>{try{let t=`&lang=${this.lang}`,n=`${yP}${this.apiSignInUrl}${t}`,a=Date.now();return e&&(n+=`&disable_cache=${a}`),(await this.instance.get(n)).data.data}catch(t){throw console.warn("There was a problem fetching the countries:",t),t.response}};getProfile=async e=>{let t=`${Oe}${this.apiSignInUrl}`;if(e){t=`${md}/${e}${this.apiSignInUrl}`;try{let n=await this.instance.get(t);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(t);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,t)=>{try{let n=`${md}${this.apiSignInUrl}&profile_ids=${e.join(",")}`,a=Date.now();t&&(n+=`&disable_cache=${a}`);let p=await this.instance.get(n);return this.profileRemapper.profilesFromResponse(p.data.data)}catch(n){throw console.warn(`There was a problem fetching the following profiles: ${e.join(",")}`,n),n.response}};getFollowers=async(e,t)=>{let n=`${Oe}/followers${this.apiSignInUrl}`;if(e&&!t){n=`${Oe}/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&&!t)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&&t?n=`${Oe}/${t}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(n=`${Oe}/${t}/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: ${t}`,a),a.response}};getFollowing=async(e,t)=>{let n=`${Oe}/following${this.apiSignInUrl}`;if(e&&!t){n=`${Oe}/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&&!t)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&&t?n=`${Oe}/${t}/following${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(n=`${Oe}/${t}/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: ${t}`,a),a.response}};follow=async e=>{let t=new Hi;t.profile_ids=e;try{let n=await this.instanceAuth.post(`${Oe}/follow${this.apiSignInUrl}`,JSON.stringify(t));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 t=new Hi;t.profile_ids=e;try{return await this.instanceAuth.delete(`${Oe}/follow${this.apiSignInUrl}`,{data:JSON.stringify(t)}),!0}catch(n){throw console.warn(`There was a problem with DELETE request for profiles: ${e.join(",")} `,n),n.response}};getBadges=async e=>{let t=`${Oe}/badges${this.apiSignInUrl}`;try{return e?(t=`${Oe}/${e}/badges${this.apiSignInUrl}`,(await this.instance.get(t)).data.data):(await this.instanceAuth.get(t)).data.data}catch(n){throw console.warn("There was a problem with fetching the badges",n),n.response}};updateProfile=async e=>{try{let t=await this.instanceAuth.patch(`${Oe}${this.apiSignInUrl}`,e);return this.profileRemapper.fullProfileFromResponse(t.data.data)}catch(t){throw console.warn("There was a problem updating the own profile:",t),t.response}}};var xt={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id"},gp={PREDICTOR_USER_RELATED_OPERATION:"https://docs.fansunitedmedia.com/docs/predictor-operations#user-related-operations"};var dd="FansUnited",yp={football:{ids:[],countries:[],competitions:[]},profile:{info:{},statistics:{},badges:null,countries:[],exparations:{profile:0,statistics:0,badges:0}}},gt=class{idSchema="";expirationTimeout=600;expirationBadgesTimeout=3600;constructor(e){this.idSchema=e.idSchema,(this.getData()===void 0||this.getData()===null)&&this.setData(yp)}clearData=()=>{this.setData(yp)};getEntityById=(e="",t="")=>this.getData().football.ids.find(n=>{let a=xt[this.idSchema];return n&&`${n[a]}`===t&&n.resource===e});getEntity=(e,t,n)=>Array.isArray(e)?this.getData().football.ids.filter(a=>{let p=xt[n];return a&&e.includes(`${a[p]}`)&&a.resource===t}):this.getData().football.ids.find(a=>{let p=xt[n];return a&&`${a[p]}`===e&&a.resource===t});getEntityByNativeId=(e="",t="")=>this.getData().football.ids.find(n=>n&&`${n.id}`===t&&n.resource===e);checkForExistingIdObjs=(e,t)=>{let n=xt[t],a={};return Object.keys(e).forEach(p=>{let d=e[p],b=this.getEntity(d,p,t).map(w=>w[n]),F=e[p].filter(w=>!b.includes(w));a[p]=d.map(w=>F.includes(w)?{id:w,exists:!1}:{id:w,exists:!0})}),a};getIdsByType=(e,t,n)=>{let a=xt[n],p=xt[t],d={};return Object.keys(e).forEach(h=>{let b=e[h],F=[];this.getData().football.ids.forEach(w=>{b.forEach((S,k)=>{S===w[p]&&h===w.resource&&(F[k]=w[a])})}),d[h]=F}),d};addIdMapping=e=>{let t=this.getData();t.football.ids.push(e),this.setData(t)};addIdMappings=e=>{let t=this.getData(),n=t.football.ids;n=[...n,...e],t.football.ids=n,this.setData(t)};setOwnProfile=e=>{let t=this.getData();t.profile.info=e,t.profile.exparations.profile=Math.floor(Date.now()/1e3)+this.expirationTimeout,this.setData(t)};getOwnProfile=()=>this.getData().profile.info;getProfileCountries=()=>this.getData().profile.countries;setProfileCountries=e=>{let t=this.getData();t.profile.countries=e,this.setData(t)};getProfileStats=()=>this.getData().profile.statistics;setProfileStats=e=>{let t=this.getData();t.profile.statistics=e,t.profile.exparations.statistics=Math.floor(Date.now()/1e3)+this.expirationTimeout,this.setData(t)};getProfileBadges=()=>this.getData().profile.badges;setProfileBadges=e=>{let t=this.getData();t.profile.badges=e,t.profile.exparations.badges=Math.floor(Date.now()/1e3)+this.expirationBadgesTimeout,this.setData(t)};getFootballCountries=()=>this.getData().football.countries;setFootballCountries=e=>{let t=this.getData();t.football.countries=e,this.setData(t)};getCompetitions=e=>{let t=this.getData();return e?e.competitionSearchFilter(t.football.competitions):t.football.competitions};setCompetitions=e=>{let t=this.getData(),n=[...t.football.competitions];n.push(...e),t.football.competitions=this.makeCompetitionsUnique(n),this.setData(t)};getCompetitionsLength=()=>{let{football:e}=this.getData();return e.competitions.length};getExpiration=e=>{let t=this.getData();switch(this.initialNewSchema("exparations"),e){case"profile":return t.profile.exparations.profile;case"statistics":return t.profile.exparations.statistics;case"badges":return t.profile.exparations.badges}};makeCompetitionsUnique=e=>{let t=new Set;return e.filter(n=>{let a=!t.has(n.id);return t.add(n.id),a})};getData=()=>JSON.parse(localStorage.getItem(dd));setData=e=>{localStorage.setItem(dd,JSON.stringify(e))};initialNewSchema=e=>{this.getData().profile[e]||this.setData(yp)}};var fd=Wt(Kt());var ki={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},co=class{instance=null;apiSignInUrl="";constructor(e){let t=Ae(e.environment,"idMapping");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instance=fd.default.create({baseURL:t})}getEntityById=(e,t)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${config.idSchema}&${ki[e]}=${t}`)}catch(n){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,n),n.response}};getEntityByIdAndSchema=(e,t,n)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${ki[e]}=${t}`)}catch(a){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,a),a.response}};getEntityIdsByIdsAndSchema=(e,t,n)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${ki[e]}=${t.join(",")}`)}catch(a){throw console.warn(`There was a problem with id mapping request for the following ids:${t.join(",")}`,a),a.response}};getEntitiesByIds=(e,t,n)=>{t.sort((d,h)=>d.localeCompare(h));let p=fp(t).map(d=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${ki[e]}=${d.join(",")}`)}catch(h){throw console.warn(`There was a problem with id mapping request for the following ids:${d.join(",")}`,h),h.response}});return Promise.all(p).then(d=>{let h=[];return d.forEach(b=>{h.push(...b.data.data)}),h})};getEntitiesByIdObjs=async(e,t)=>{let n=[],a={},p=[];Object.keys(e).forEach(F=>{n.push.apply(n,e[F])});let d=Xt(n),h=fp(d);for(let F of h){let w="";if(Object.keys(e).forEach(S=>{a[S]=[];let k=F.filter(se=>e[S].includes(se));k&&k.length>0&&(a[S]=k)}),Object.keys(a).forEach(S=>{a[S].length>0&&(a[S].sort((k,se)=>k.localeCompare(se)),w+="&",w+=`${ki[S]}=${a[S].join(",")}`)}),w&&w.length>0)try{let S=await this.instance.get(`/football${this.apiSignInUrl}&input_provider=${t||"native"}${w}`);p.push(S.data.data)}catch(S){throw console.warn("There was a problem with id mapping request",S),S.response}else p.push([])}return Array.prototype.concat.apply([],p)}};var uo=class{isBrowser=!1;localStorage=null;https=null;constructor(e){this.isBrowser=typeof window!="undefined",this.localStorage=new gt(e),this.https=new co(e)}getEntitiesByIds=async(e,t,n)=>{if(this.isBrowser)try{let a=this.localStorage.checkForExistingIdObjs(e,t),p=this.splitForRequestAndExisting(a),d=await this.https.getEntitiesByIdObjs(p.request,t);return this.localStorage.addIdMappings(d),this.localStorage.getIdsByType(e,t,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,t);return Object.keys(e).forEach(p=>{e[p]=a.filter(d=>d.resource===p).map(d=>d[xt[n]])}),e}catch(a){return console.warn("There was a problem retrieving the entity ids ",a),Promise.resolve([])}};getEntityById=async(e,t,n)=>{if(this.isBrowser){let a=this.localStorage.getEntity(e,t,n);if(a)return a;{let p=await this.requestEntity(e,t,n);return this.localStorage.addIdMappings(p),p}}else return await this.requestEntity(e,t,n)};splitForRequestAndExisting=e=>{let t={},n={};return Object.keys(e).forEach(a=>{t[a]=e[a].filter(p=>!p.exists).map(p=>p.id),n[a]=e[a].filter(p=>p.exists).map(p=>p.id)}),{existing:n,request:t}};requestEntity=async(e,t,n)=>{try{return e=Array.isArray(e)?e:[e],await this.https.getEntitiesByIds(t,e,n)}catch(a){return console.warn(`There was a problem retrieving the requested entity: ${a}`),null}}};var mo=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 fo=class{extractedObjIds={};traverse=(e,t)=>(t=mo(t),Array.isArray(e)?this.traverseArrExtract(e,t):e&&typeof e=="object"&&this.traverseObjExtract(e,t),this.extractedObjIds);traverseArrExtract=(e,t)=>{e&&e.length>0&&e.forEach(n=>{this.traverseObjExtract(n,t)})};traverseObjExtract=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(n=>{let a=e[n];n==="id"||n==="teamId"?(this.extractedObjIds.hasOwnProperty(t)||(this.extractedObjIds[t]=[]),a&&this.extractedObjIds[t].push(a)):e[n]&&this.traverse(e[n],n)})}};var ho=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(e,t,n)=>(t=mo(t),this.replaceObjIdsIndex===null&&(this.initReplaceObjIdsIndex(n),this.remappedIdsObj=n),Array.isArray(e)?this.traverseArrReplace(e,t):e&&typeof e=="object"&&this.traverseObjReplace(e,t),e);initReplaceObjIdsIndex=e=>{this.replaceObjIdsIndex={},Object.keys(e).forEach(t=>{this.replaceObjIdsIndex[t]=0})};traverseArrReplace=(e,t)=>{e&&e.length>0&&e.forEach(n=>{this.traverseObjReplace(n,t)})};traverseObjReplace=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(n=>{n==="id"||n==="teamId"?e[n]&&(e[n]=this.remappedIdsObj[t][this.replaceObjIdsIndex[t]],this.replaceObjIdsIndex[t]=this.replaceObjIdsIndex[t]+1):e[n]&&this.traverse(e[n],n,this.remappedIdsObj)})}};var ce=class{idSchema="";idMappingFacade=null;constructor(e){this.idSchema=e.idSchema,this.idMappingFacade=new uo(e)}getEntityIdBySchemaId=(e,t)=>this.idMappingFacade.getEntityById(e,t,this.idSchema);remapEntities=async(e,t)=>{let n=JSON.parse(JSON.stringify(e));try{if(this.idSchema!=="native"){let p=new fo().traverse(n,t);return this.idMappingFacade.getEntitiesByIds(p,"native",this.idSchema).then(d=>new ho().traverse(n,t,d))}else return e}catch(a){return console.warn(`There was a problem remapping entity: ${t} with inner entity `,a),[]}};getEntityIdsBySchemaId=async(e,t,n)=>{let a={};return a[t]=e,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(a,this.idSchema,n):a}};var ke=class{completed=!1;percentage;constructor(e){this.percentage=e}};var go=class{teamFollowed=new ke(10);teamFavourite=new ke(15);playerFollowed=new ke(10);playerFavourite=new ke(10);competitionFollowed=new ke(10);competitionFavourite=new ke(5);addedBirthdate=new ke(10);addedGender=new ke(10);addedCountry=new ke(10);addedAvatar=new ke(10)};var yo=class{totalPercentage;breakdown=new go};var Vi=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 yt=class{isBrowser=!1;localStorage={};profileHttps=null;activityHttps=null;constructor(e,t,n){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.profileHttps=t,this.activityHttps=n}getOwn=async()=>{if(this.isBrowser){let e=this.getLocalStorageData("profile");if(e)return JSON.parse(JSON.stringify(e));try{let t=await this.profileHttps.getProfile();return this.localStorage.setOwnProfile(t),t}catch(t){throw console.warn("There was a problem retrieving your profile: ",t),t}}else try{return await this.profileHttps.getProfile()}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};updateOwnProfile=async()=>{try{let e=await this.profileHttps.getProfile();return this.localStorage.setOwnProfile(e),e}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};getByIds=async(e,t)=>{try{return t=t||!1,await this.profileHttps.getProfiles(e,t)}catch(n){throw console.warn(`There was a problem retrieving the selected profiles: ${e.join(",")} `,n),n}};getById=async e=>{try{return await this.profileHttps.getProfile(e)}catch(t){throw console.warn(`There was a problem retrieving the selected profile: ${e} `,t),t}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let t=this.localStorage.getProfileCountries();if(t&&t.length>0)return t;try{let n=await this.profileHttps.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.profileHttps.getCountries(e)}catch(t){throw console.warn("There was a problem retrieving profile countries: ",t),t}};getFollowers=async(e,t)=>{try{return e&&(e=new Vi(e)),await this.profileHttps.getFollowers(e,t)}catch(n){throw console.warn("There was a problem retrieving your followers: ",n),n}};getFollowing=async(e,t)=>{try{return e&&(e=new Vi(e)),await this.profileHttps.getFollowing(e,t)}catch(n){throw console.warn("There was a problem retrieving your following profiles: ",n),n}};follow=async e=>{try{return await this.profileHttps.follow(e)}catch(t){throw console.warn(`There was a problem following profiles: ${e.join(",")} `,t),t}};unfollow=async e=>{try{return await this.profileHttps.unfollow(e)}catch(t){throw console.warn(`There was a problem unfollowing profiles: ${e.join(",")} `,t),t}};showFullnessProfile=e=>{let t=new yo,n=0;return e.avatar&&(t.breakdown.addedAvatar.completed=!0,n+=t.breakdown.addedAvatar.percentage),e.birthDate&&(t.breakdown.addedBirthdate.completed=!0,n+=t.breakdown.addedBirthdate.percentage),e.country&&(t.breakdown.addedCountry.completed=!0,n+=t.breakdown.addedCountry.percentage),e.gender&&(t.breakdown.addedGender.completed=!0,n+=t.breakdown.addedGender.percentage),e.interests&&e.interests.length>0&&(e.interests.find(w=>w.type==="team"&&w.favourite)&&(t.breakdown.teamFavourite.completed=!0,n+=t.breakdown.teamFavourite.percentage),e.interests.find(w=>w.type==="team")&&(t.breakdown.teamFollowed.completed=!0,n+=t.breakdown.teamFollowed.percentage),e.interests.find(w=>w.type==="player"&&w.favourite)&&(t.breakdown.playerFavourite.completed=!0,n+=t.breakdown.playerFavourite.percentage),e.interests.find(w=>w.type==="player")&&(t.breakdown.playerFollowed.completed=!0,n+=t.breakdown.playerFollowed.percentage),e.interests.find(w=>w.type==="competition"&&w.favourite)&&(t.breakdown.competitionFavourite.completed=!0,n+=t.breakdown.competitionFavourite.percentage),e.interests.find(w=>w.type==="competition")&&(t.breakdown.competitionFollowed.completed=!0,n+=t.breakdown.competitionFollowed.percentage)),t.totalPercentage=n,t};getStats=async()=>{if(this.isBrowser){let e=this.getLocalStorageData("statistics");if(e&&Object.keys(e).length)return JSON.parse(JSON.stringify(e));try{let t=await this.activityHttps.getStats();return this.localStorage.setProfileStats(t),t}catch(t){throw console.warn("There was a problem retrieving own profile statistics: ",t),t}}else try{return await this.activityHttps.getStats()}catch(e){throw console.warn("There was a problem retrieving own profile statistics: ",e),e}};getBadges=async()=>{if(this.isBrowser){let e=this.getLocalStorageData("badges");if(e)return e;try{let t=await this.profileHttps.getBadges();return this.localStorage.setProfileBadges(t),t}catch(t){throw console.warn("There was a problem retrieving own profile badges: ",t),t}}else try{return await this.profileHttps.getBadges()}catch(e){throw console.warn("There was a problem retrieving own profile badges: ",e),e}};getLocalStorageData=e=>{let t=Math.floor(Date.now()/1e3),n=this.localStorage.getExpiration(e);switch(e){case"profile":if(n>t)return this.localStorage.getOwnProfile();case"statistics":if(n>t)return this.localStorage.getProfileStats();case"badges":if(n>t)return this.localStorage.getProfileBadges();default:return null}}};var Mo=class{id=null;name=null;assets=null};var Ur=class{idMapping=null;footballFacade=null;constructor(e,t){this.idMapping=e,this.footballFacade=t}showFullInterests=async e=>{let t=[];if(e&&e.length>0)for(let n of e)if(n.source!=="custom"&&n.source.toLocaleUpperCase()==="FOOTBALL"){let a={};if(n.type==="team"){a.teamIds=[n.id];let p=await this.footballFacade.getTeams(a);n.model=p.data[0]}if(n.type==="player"){a.playerIds=[n.id];let p=await this.footballFacade.getPlayers(a);n.model=p.data[0]}if(n.type==="competition"){a.competitionIds=[n.id];let p=await this.footballFacade.getCompetitions(a);n.model=p[0]}n.model===void 0&&(n.model=null),t.push(n)}else t.push(n);return t};updateInterests=(e,t)=>{if(e&&t&&e.length===t.length){let n=t.filter(p=>e.some(d=>p.id===d.id&&p.type===d.type&&p.source===d.source&&p.favourite===d.favourite)),a=t.filter(p=>!e.some(d=>p.id===d.id&&p.type===d.type&&p.source===d.source&&p.favourite===d.favourite));return[...n,...a]}else return t}};var wo=class{extractUpdatedProps=(e,t)=>{let n=["name","nickname","gender"],a={};return Object.keys(e).forEach(p=>{if(n.includes(p)&&e[p]!==t[p])a[p]=t[p];else if(p==="birthDate")(t[p]===null||e[p]===null&&t[p]||e[p]!==t[p])&&(a.birth_date=t[p]);else if(p==="country")t[p]===null?a.country_id=t[p]:(e[p]===null&&t[p]||e[p].id!==t[p].id)&&(a.country_id=t[p].id);else if(p==="interests"){let d=e[p],h=t[p];h.length&&this.isNewInterest(d,h)?a[p]=this.updateInterests(d,h):(!h.length&&d.length||d.length!==h.length&&!this.isNewInterest(d,h))&&(a[p]=h)}}),a};updateInterests=(e,t)=>{if(e.length===t.length){let[n,a]=this.extractSameAndNewInterests(e,t);return[...a,...n]}else return t};isNewInterest=(e,t)=>{let n=!1,[a]=this.extractSameAndNewInterests(e,t);return a.length&&(n=!0),n};extractSameAndNewInterests=(e,t)=>{let n=t.filter(p=>e.some(d=>p.id===d.id&&p.type===d.type&&p.source===d.source&&p.favourite===d.favourite));return[t.filter(p=>!e.some(d=>p.id===d.id&&p.type===d.type&&p.source===d.source&&p.favourite===d.favourite)),n]}};var bo=class{idsRemapper=null;profileHttps=null;profileService=null;localStorage=null;profileFacade=null;interestsService=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;constructor(e,t,n,a,p,d){this.idsRemapper=e,this.localStorage=t,this.profileHttps=n,this.profileService=new wo,this.interestsService=new Ur(p,d),this.profileFacade=new yt(t,n,a)}getOwnProfile=async()=>{for(;this.isFetching;)console.log("Another thread is fetching profile..."),await this.delay(100);if(this.modified&&this.ownProfile)return console.log("Timestamp is less than 10 minutes OR profile is modifying "),this.ownProfile;let e=Math.floor(Date.now()/1e3);if(!this.ownProfile||this.expireAt<e){this.isFetching=!0,this.expireAt=Math.floor(Date.now()/1e3)+600;try{let t=await this.profileFacade.getOwn();this.setOwnProfile(t)}catch{this.isFetching=!1}return this.modified=!1,this.isFetching=!1,this.ownProfile}return this.ownProfile};delay=e=>new Promise(t=>{setTimeout(t,e)});setOwnProfile=e=>{this.ownProfile=e};getInfo=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return delete t.interests,t};showInterests=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.inquiryCustomInterests(t.interests)};showFullInterests=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e)),n=await this.idsRemapper.inquiryCustomInterests(t.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=>{let t=await this.profileFacade.follow(e),n=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(n),t};unfollow=async e=>{let t=await this.profileFacade.unfollow(e),n=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(n),t};getStats=async()=>{let e=await this.profileFacade.getStats();return await this.idsRemapper.remapSuccessRatesEntities(e)};getBadges=async()=>await this.profileFacade.getBadges();addInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;e.source!=="custom"?t=await this.idsRemapper.remapInterestToNative(e):t=e;let n=this.ownProfile.interests.filter(a=>a.id!==t.id||a.type!==t.type||a.source!==t.source);return this.ownProfile.interests=[...n],this.ownProfile.interests.push(t),this};addInterest=e=>(this.promises.push(this.addInterestPromise(e)),this);removeInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;return e.source!=="custom"?t=await this.idsRemapper.remapInterestToNative(e):t=e,this.ownProfile.interests=this.ownProfile.interests.filter(n=>n.id!==t.id||n.type!==t.type||n.source!==t.source),this};removeInterest=e=>(this.promises.push(this.removeInterestPromise(e)),this);setBirthdatePromise=async e=>(this.modified=!0,await this.getOwnProfile(),e?this.ownProfile.birthDate=e:this.ownProfile.birthDate=null,this);setBirthdate=e=>(this.promises.push(this.setBirthdatePromise(e)),this);setGenderPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e==="male"||e==="female"?this.ownProfile.gender=e:this.ownProfile.gender="unspecified",this);setGender=e=>(this.promises.push(this.setGenderPromise(e)),this);setNicknamePromise=async e=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.nickname=e,this);setNickname=e=>(this.promises.push(this.setNicknamePromise(e)),this);setNamePromise=async e=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.name=e,this);setName=e=>(this.promises.push(this.setNamePromise(e)),this);setCountryPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e&&!this.ownProfile.country?(this.ownProfile.country=new Mo,this.ownProfile.country.id=e):e&&this.ownProfile.country?this.ownProfile.country.id=e:this.ownProfile.country=null,this);setCountry=e=>(this.promises.push(this.setCountryPromise(e)),this);showFullnessProfile=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return this.profileFacade.showFullnessProfile(t)};update=async()=>{if(this.promises.length===0)return this.ownProfile;await Promise.all(this.promises);let e=await this.profileFacade.getOwn(),t=await this.getOwnProfile(),n=this.profileService.extractUpdatedProps(e,t);if(this.modified=!1,this.expireAt=0,Object.keys(n).length){let p=await this.profileHttps.updateProfile(n);return this.setOwnProfile(p),this.localStorage.setOwnProfile(p),delete p.interests,p}let a=JSON.parse(JSON.stringify(this.ownProfile));return delete a.interests,a}};var vo=class{idsRemapper=null;profileHttps=null;activityHttps=null;profileFacade=null;interestsService=null;profileId="";constructor(e,t,n,a,p,d){this.idsRemapper=e,this.profileHttps=n,this.activityHttps=a,this.interestsService=new Ur(p,d),this.profileFacade=new yt(t,n,a)}setId=e=>(this.profileId=e,this);getProfile=async()=>await this.profileFacade.getById(this.profileId);getInfo=async()=>{let e=await this.getProfile();return delete e.interests,e};showInterests=async()=>{let e=await this.getProfile(),t=[];return t=e.interests,await this.idsRemapper.inquiryCustomInterests(t)};showFullInterests=async()=>{let e=await this.showInterests();return await this.interestsService.showFullInterests(e)};getFollowers=async e=>await this.profileFacade.getFollowers(e,this.profileId);getFollowing=async e=>await this.profileFacade.getFollowing(e,this.profileId);showFullnessProfile=async()=>{let e=await this.getProfile();return this.profileFacade.showFullnessProfile(e)};getStats=async e=>{let t=await this.activityHttps.getStats(this.profileId,e);return await this.idsRemapper.remapSuccessRatesEntities(t)};getBadges=async()=>await this.profileHttps.getBadges(this.profileId)};var Po=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,n){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=n,this.https=t}getCountriesWithIdMapping=async e=>{try{let t=await this.getCountries(e);return this.idMapping.remapEntities(t,"country")}catch(t){throw console.warn("There was a problem browsing countries as football entities",t),t}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let t=this.localStorage.getFootballCountries();if(t&&t.length>0)return t;try{let 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 qi=class{countryId=null;name=null;gender=null;type=null;sortField=null;sortOrder=null;competitionIds=null;constructor(e){this.countryId=e.countryId?`${e.countryId}`:null,this.name=e.name?e.name:null,this.gender=e.gender?e.gender:null,this.type=e.type?e.type:null,this.sortField=e.sortField?`${e.sortField}`:null,this.sortOrder=e.sortOrder?`${e.sortOrder}`:null,this.competitionIds=e.competitionIds?e.competitionIds:null}constructFilterUrl=()=>{let e="";return this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.gender&&(e=e+"&",e=e+`gender=${this.gender}`),this.type&&(e=e+"&",e=e+`type=${this.type}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),this.name&&(e=e+"&",e=e+`name=${this.name}`),this.competitionIds&&(e=e+"&",e=e+`competition_ids=${this.competitionIds.join(",")}`),e};competitionSearchFilter=e=>{try{let t=this.filter(e);return this.sortField||this.sortOrder?this.sort(t):t}catch(t){return console.warn("There was a problem filtering the local competitions",t),[]}};filter=e=>{let t=this.entitiesToSearchWith();return e.filter(n=>{let a=!0;return t.forEach(p=>{p!=="sortOrder"&&p!=="sortField"&&(p==="countryId"?a&&=n.country.id===this[p]:p==="name"?a&&=n.name.toLocaleLowerCase().includes(this[p].toLocaleLowerCase()):p==="competitionIds"?a&&=this[p].some(d=>n.id===d):a&&=n[p].toLocaleLowerCase()===this[p].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 t=[];return this.sortField==="name"?t=e.sort((n,a)=>this.sortOrder&&this.sortOrder==="desc"?a.name.localeCompare(n.name):n.name.localeCompare(a.name)):this.sortField==="country"?t=e.sort((n,a)=>this.sortOrder&&this.sortOrder==="desc"?a.country.name.localeCompare(n.country.name):n.country.name.localeCompare(a.country.name)):this.sortField==="scope"?e.forEach(n=>t[this.competitionIds.indexOf(n.id)]=n):!this.sortField&&this.sortOrder==="desc"&&(t=e.sort((n,a)=>a.id.localeCompare(n.id))),t}};var Io=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,n){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=n,this.https=t}getCompetitionsIdMapping=async(e,t)=>{try{let n=!1;if(e){if(e=new qi(e),e.countryId){let p=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");p.country.length===0&&(n=!0),e.countryId=p.country[0]}if(e.competitionIds){let p=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");p.competition.length===0&&(n=!0),e.competitionIds=p.competition}if(n)return[]}let a=await this.getCompetitions(e,t);return await this.idMapping.remapEntities(a,"competition")}catch(n){throw console.warn("There was a problem browsing all of the competitions",n),n}};getCompetitionsMapWithNativeIds=async e=>{let t=new Map,n=new qi({competitionIds:e}),a=await this.getCompetitions(n);a.sort((d,h)=>d.id.localeCompare(h.id));let p=await this.idMapping.remapEntities(a,"competition");return e.forEach((d,h)=>t.set(d,p[h])),t};getCompetitions=async(e,t)=>{let n=null;if(t=t||!1,this.isBrowser){if(!this.localStorage.getCompetitionsLength()){try{n=await this.https.getCompetitions()}catch(a){throw console.warn("There was a problem retrieving all competitions",a),a}this.localStorage.setCompetitions(n)}return this.localStorage.getCompetitions(e)}else return this.https.getCompetitions(e,t)};getCompetitionByIdIdMapping=async(e,t)=>{try{let a=(await this.idMapping.getEntityIdsBySchemaId([e],"competition","native")).competition[0],p=await this.getCompetitionById(a,t);return await this.idMapping.remapEntities(p,"competition")}catch(n){throw console.warn(`There was a problem browsing the following competition:${e}`,n),n}};getCompetitionById=async(e,t)=>{try{return t=t||!1,await this.https.getCompetitionById(e,t)}catch(n){throw console.warn(`There was a problem retrieving the competition with the following id: ${e}`,n),n}};getTopCompetitionsIdMapping=async e=>{try{let t=await this.getTopCompetitions(e);return await this.idMapping.remapEntities(t,"competition")}catch(t){throw console.warn("There was a problem browsing the top competitions",t),t}};getTopCompetitions=async e=>{try{return e=e||!1,await this.https.getTopCompetitions(e)}catch(t){throw console.warn("There was a problem retrieving the top competitions",t),t}}};var Wi=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 hd=Wt(Kt());var _o=class{general=[];predictor=[];topX=[];matchQuiz=[]};var Gr=class{points=0;gameParticipationCount=null;predictionsMade=null;correctPredictions=null};var Ro=class{id;enabled;requirements=new Gr};var Fo=class{id;weight;multiplier;conditions};var So=class{value=new Fo};var $r=class{points=null;tiers=null;badges=null};var To=class{enabled=!1;conditions={list:null};actions=new So;rewards=new $r};var Eo=class{general=null;comments=null;predictor=null;activity=null;topX=null};var Hr=class{enabled=!1;defaultMarkets=null;competitionsWhitelist=null};var kr=class{enabled=!1;minFixtures=null;maxFixtures=null;competitionsWhitelist=null};var Vr=class{enabled=!1;fullCoverageCompetitions=null;markets=null};var Co=class{remapPredictorConfig=e=>{let t=new Vr;return t.enabled=e.enabled,t.fullCoverageCompetitions=e.full_coverage_competitions,t.markets=e.markets,t};remapTopXConfig=e=>{let t=new kr;return t.enabled=e.enabled,t.minFixtures=e.min_fixtures,t.maxFixtures=e.max_fixtures,t.competitionsWhitelist=e.competitions_whitelist,t};remapMatchQuizConfig=e=>{let t=new Hr;return t.enabled=e.enabled,t.defaultMarkets=e.default_markets,t.competitionsWhitelist=e.competitions_whitelist,t};remapLoyaltyConfig=e=>{let t=new To;return t.enabled=e.enabled,t.conditions.list=e.conditions.list,t.actions.value=e.actions.value,t.rewards=this.remapRewards(e.rewards),t};remapRewards=e=>{let t=new $r;return t.points=this.remapPoints(e.points),t.tiers=e.tiers,t.badges=this.remapBadges(e.badges),t};remapPoints=e=>{let t=new Eo;return t.general=e.general,t.comments=e.comments,t.predictor=e.predictor,t.activity=e.activity,t.topX=e.top_x,t};remapBadges=e=>{let t=new _o;return t.general=e.general,t.predictor=this.remapBadgeValues(e.predictor),t.topX=this.remapBadgeValues(e.top_x),t.matchQuiz=this.remapBadgeValues(e.match_quiz),t};remapBadgeValues=e=>e.map(t=>{let n=new Ro;return n.id=t.id,n.enabled=t.enabled,n.requirements=this.remapRequirements(t.requirements),n});remapRequirements=e=>{let t=new Gr;return t.points=e.points,t.gameParticipationCount=e.game_participation_count,t.predictionsMade=e.predictions_made,t.correctPredictions=e.correct_predictions,t}};var je=class{instance=null;apiSignInUrl="";featureConfigRemapper=null;constructor(e){let t=Ae(e.environment,"client");this.apiSignInUrl=`/clients/${e.clientId}/features?key=${e.apiKey}`,this.instance=hd.default.create({baseURL:t,headers:{"Content-Type":"application/json"}}),this.featureConfigRemapper=new Co}getConfig=async e=>{try{let t=await this.instance.get(`${this.apiSignInUrl}`);switch(e){case"predictor":return this.featureConfigRemapper.remapPredictorConfig(t.data.data.predictor);case"topX":return this.featureConfigRemapper.remapTopXConfig(t.data.data.top_x);case"matchQuiz":return this.featureConfigRemapper.remapMatchQuizConfig(t.data.data.match_quiz);case"loyalty":return this.featureConfigRemapper.remapLoyaltyConfig(t.data.data.loyalty)}}catch(t){throw console.warn("There was a problem fetching configuration from Client API",t),t.response}}};var Yt=class{clientHttps=null;constructor(e){this.clientHttps=new je(e)}setAvailableMarketsForMatch=async e=>{let{fullCoverageCompetitions:t,markets:n}=await this.clientHttps.getConfig("predictor");if(Array.isArray(e))return e.map(a=>this.setAvailableMarkets(a,t,n));if(typeof e=="object"&&Object.keys(e).length)return this.setAvailableMarkets(e,t,n)};setAvailableMarkets=(e,t,n)=>{let a=e.context.competition.id;return this.isMatchInCoverageCompetition(a,t)?(e.availableMarkets=n.all,e):(e.availableMarkets=n.main,e)};isMatchInCoverageCompetition=(e,t)=>{let n=!1;return t.includes(e)&&(n=!0),n}};var Ao=class{footballService=null;https=null;idMapping=null;constructor(e,t,n){this.idMapping=n,this.https=t,this.footballService=new Yt(e)}getTeamsIdMapping=async(e,t)=>{try{let n=!1;if(e){if(e=new Wi(e),e.countryId){let p=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");p.country.length===0&&(n=!0),e.countryId=p.country[0]}if(e.scope){let p=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");p.competition.length===0&&(n=!0),e.scope=p.competition}if(e.teamIds){let p=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");p.team.length===0&&(n=!0),e.teamIds=p.team}}if(n)return[];let a=await this.getTeams(e,t);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}};getTeamsMapWithNativeIds=async e=>{let t=new Map,n=new Wi({teamIds:e}),{data:a}=await this.getTeams(n);a.sort((d,h)=>d.id.localeCompare(h.id));let p=await this.idMapping.remapEntities(a,"team");return e.forEach((d,h)=>t.set(d,p[h])),t};getTeams=async(e,t)=>{try{return t=t||!1,await this.https.getTeams(e,t)}catch(n){throw console.warn("There was a problem retrieving all teams",n),n}};getTeamByIdIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let a=await this.getTeamById(e,t);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,t)=>{try{return t=t||!1,await this.https.getTeamById(e,t)}catch(n){throw console.warn(`There was a problem retrieving the following team: ${e}`,n),n}};getTopTeamsIdMapping=async e=>{try{let t=await this.getTopTeams(e);return await this.idMapping.remapEntities(t,"team")}catch(t){throw console.warn("There was a problem browsing the top teams",t),t}};getTopTeams=async e=>{try{return e=e||!1,await this.https.getTopTeams(e)}catch(t){throw console.warn("There was a problem retrieving the top teams",t),t}};getNextMatchForTeamIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let a=await this.getNextMatchForTeam(e,t);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,t)=>{try{t=t||!1;let n=await this.https.getNextMatchForTeam(e,t);return await this.footballService.setAvailableMarketsForMatch(n)}catch(n){throw console.warn(`There was a problem retrieving the next match for the following team: ${e}`,n),n}};getPrevMatchForTeamIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let a=await this.getPrevMatchForTeam(e,t);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,t)=>{try{t=t||!1;let n=await this.https.getPrevMatchForTeam(e,t);return await this.footballService.setAvailableMarketsForMatch(n)}catch(n){throw console.warn(`There was a problem retrieving the previous match for the following team: ${e}`,n),n}}};var Ki=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 zt=class{https=null;footballService=null;idMapping=null;constructor(e,t,n){this.idMapping=n,this.https=t,this.footballService=new Yt(e)}getPlayersIdMapping=async(e,t)=>{try{let n=!1;if(e){if(e=new Ki(e),e.countryId){let p=await this.idMapping.getEntityIdsBySchemaId([e.countryId],"country","native");p.country.length===0&&(n=!0),e.countryId=p.country[0]}if(e.playerIds){let p=await this.idMapping.getEntityIdsBySchemaId(e.playerIds,"player","native");p.player.length===0&&(n=!0),e.playerIds=p.player}if(e.scope){let p=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");p.competition.length===0&&(n=!0),e.scope=p.competition}if(n)return[]}let a=await this.getPlayers(e,t);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 t=new Ki({playerIds:e}),n=await this.getPlayers(t);return n.data.sort((a,p)=>a.id.localeCompare(p.id)),await this.idMapping.remapEntities(n.data,"player")};getPlayersMapWithNativeIds=async e=>{let t={},n=Xt(e);n.sort((p,d)=>p.localeCompare(d));let a=await this.getPlayersWithNativeIds(n);return n.forEach((p,d)=>t[p]=a[d]),t};getPlayers=async(e,t)=>{try{return t=t||!1,await this.https.getPlayers(e,t)}catch(n){throw console.warn("There was a problem retrieving the players",n),n}};getPlayerIdMapping=async(e,t)=>{try{let n=await this.idMapping.getEntityIdsBySchemaId([e],"player","native"),a=await this.getPlayerById(n.player[0],t);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,t)=>{try{return t=t||!1,await this.https.getPlayerById(e,t)}catch(n){throw console.warn(`There was a problem retrieving the following player: ${e}`,n),n}};getTopPlayersIdMapping=async e=>{try{let t=await this.getTopPlayers(e);return await this.idMapping.remapEntities(t,"player")}catch(t){throw console.warn("There was a problem browsing the top players",t),t}};getTopPlayers=async e=>{try{return e=e||!1,await this.https.getTopPlayers(e)}catch(t){throw console.warn("There was a problem retrieving the top players",t),t}};getNextMatchForPlayerIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let a=await this.getNextMatchForPlayer(e,t);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,t)=>{try{t=t||!1;let n=await this.https.getNextMatchForPlayer(e,t);return await this.footballService.setAvailableMarketsForMatch(n)}catch(n){throw console.warn(`There was a problem retrieving the next match for player: ${e}`,n),n}};getPrevMatchForPlayerIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let a=await this.getPrevMatchForPlayer(e,t);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,t)=>{try{t=t||!1;let n=await this.https.getPrevMatchForPlayer(e,t);return await this.footballService.setAvailableMarketsForMatch(n)}catch(n){throw console.warn(`There was a problem retrieving the previous match for player: ${e}`,n),n}}};var Xi=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 Qt=class{https=null;idMapping=null;footballService=null;constructor(e,t,n){this.https=t,this.idMapping=n,this.footballService=new Yt(e)}getMatchesIdMapping=async(e,t)=>{try{if(e){if(e=new Xi(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,t);return n.data=await this.footballService.setAvailableMarketsForMatch([...n.data]),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 t=e.length,n=new Xi({matchIds:e,limit:t}),a=await this.getMatches(n);return a.data.sort((p,d)=>p.id.localeCompare(d.id)),await this.idMapping.remapEntities(a.data,"match")};getMatchesMapWithNativeIds=async e=>{let t={},n=Xt(e);n.sort((p,d)=>p.localeCompare(d));let a=await this.getMatchesWithNativeIds(n);return n.forEach((p,d)=>t[p]=a[d]),t};getMatches=async(e,t)=>{try{return t=t||!1,await this.https.getMatches(e,t)}catch(n){throw console.warn("There was a problem retrieving the matches",n),n}};getMatchIdMapping=async(e,t)=>{try{let n=await this.idMapping.getEntityIdsBySchemaId([e],"match","native"),a=await this.getMatchById(n.match[0],t),p=await this.footballService.setAvailableMarketsForMatch(a);return await this.idMapping.remapEntities(p,"match")}catch(n){throw console.warn(`There was a problem browsing the following match: ${e}`,n),n}};getMatchById=async(e,t)=>{try{return t=t||!1,await this.https.getMatchById(e,t)}catch(n){throw console.warn(`There was a problem retrieving the following match: ${e}`,n),n}}};var Oo=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 Bo=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}searchIdMapping=async(e,t)=>{try{if(e=new Oo(e),e.scope){let a=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");e.scope=a.competition}let n=await this.search(e,t);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,t)=>{try{return await this.https.search(e,t)}catch(n){throw console.warn("There was a problem retrieving the search response",n),n}}};var qr=class{countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(e,t,n,a){this.countriesFacade=new Po(t,n,a),this.competitionsFacade=new Io(t,n,a),this.teamsFacade=new Ao(e,n,a),this.playerFacade=new zt(e,n,a),this.matchFacade=new Qt(e,n,a),this.searchFacade=new Bo(n,a)}getCountries=async e=>this.countriesFacade.getCountriesWithIdMapping(e);getCompetitions=async(e,t)=>this.competitionsFacade.getCompetitionsIdMapping(e,t);getCompetitionById=async(e,t)=>this.competitionsFacade.getCompetitionByIdIdMapping(e,t);getTopCompetitions=async e=>this.competitionsFacade.getTopCompetitionsIdMapping(e);getCompetitionsMapWithNativeIds=async e=>await this.competitionsFacade.getCompetitionsMapWithNativeIds(e);getTeams=async(e,t)=>this.teamsFacade.getTeamsIdMapping(e,t);getTeamById=async(e,t)=>this.teamsFacade.getTeamByIdIdMapping(e,t);getTopTeams=async e=>this.teamsFacade.getTopTeamsIdMapping(e);getNextMatchForTeam=async(e,t)=>this.teamsFacade.getNextMatchForTeamIdMapping(e,t);getPrevMatchForTeam=async(e,t)=>this.teamsFacade.getPrevMatchForTeamIdMapping(e,t);getTeamsMapWithNativeIds=async e=>await this.teamsFacade.getTeamsMapWithNativeIds(e);getPlayers=async(e,t)=>this.playerFacade.getPlayersIdMapping(e,t);getPlayerById=async(e,t)=>this.playerFacade.getPlayerIdMapping(e,t);getTopPlayers=async e=>this.playerFacade.getTopPlayersIdMapping(e);getNextMatchForPlayer=async(e,t)=>this.playerFacade.getNextMatchForPlayerIdMapping(e,t);getPrevMatchForPlayer=async(e,t)=>this.playerFacade.getPrevMatchForPlayerIdMapping(e,t);getMatches=async(e,t)=>this.matchFacade.getMatchesIdMapping(e,t);getMatchById=async(e,t)=>this.matchFacade.getMatchIdMapping(e,t);search=async(e,t)=>this.searchFacade.searchIdMapping(e,t)};var gd=Wt(Kt());var Lo=class{id="";alias="";countryCode="";assets=null;name=""};var ne=class{countriesFromResponse=e=>{if(e)return e.map(t=>this.countryFromResponse(t))};countryFromResponse=e=>{try{if(e){let t=new Lo;return t.id=e.id,t.alias=e.alias,t.assets=e.assets,t.countryCode=e.country_code,t.name=e.name,t}}catch(t){throw t}return null}};var No=class{id="";country=null;gender="";assets=null;type="";name=""};var Be=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let t=new No;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var Do=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var Uo=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName=""};var Me=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let t=new Uo;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t}catch(t){throw console.warn("There was a problem remapping teams response",t),t}}};var Go=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new ne,this.teamBasicRemapper=new Me}fromResponse(e){try{let t=new Do;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t.participants=e.participants.map(n=>this.teamBasicRemapper.fromResponse(n)),t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var $o=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";squad=[]};var Ho=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var ko=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let t=new Ho;return t.id=e.id,t.startDate=e.start_date,t.endDate=e.end_date,t.shirtNumber=e.shirt_number,t.loan=e.loan,t.position=e.position,t.country=this.countryRemapper.countryFromResponse(e.country),t.name=e.name,t.assets=e.assets,t.birthDate=e.birth_date,t}catch(t){throw console.warn("There was a problem remapping the player from squad",t),t}}};var Vo=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new ne,this.competitionRemapper=new Be,this.playerRemapper=new ko}fromResponse(e){try{let t=new $o;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t.competitions=e.competitions?e.competitions.map(n=>this.competitionRemapper.fromResponse(n)):[],t.squad=e.squad?e.squad.map(n=>this.playerRemapper.fromResponse(n)):[],t}catch(t){throw console.warn("There was a problem remapping team response",t),t}}};var qo=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;context={competition:null};status={type:null,subType:null}};var Wo=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var Wr=class{fromResponse(e){try{let t=new Wo;return t.ftScore=this.statEntityFromResponse(e.ft_score),t.htScore=this.statEntityFromResponse(e.ht_score),t.aetScore=this.statEntityFromResponse(e.aet_score),t.aggScore=this.statEntityFromResponse(e.agg_score),t.penScore=this.statEntityFromResponse(e.pen_score),t}catch(t){throw console.warn("There was a problem remapping the scores",t),t}}statEntityFromResponse=e=>({homeGoals:e.home_goals,awayGoals:e.away_goals})};var Ko=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new Me,this.competitionRemapper=new Be,this.scoresRemapper=new Wr}fromResponse(e){try{let t=new qo;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.homeTeam=this.teamRemapper.fromResponse(e.home_team),t.awayTeam=this.teamRemapper.fromResponse(e.away_team),t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresRemapper.fromResponse(e.scores),t.context={competition:e.context.competition?this.competitionRemapper.fromResponse(e.context.competition):null},t.status={type:e.status.type,subType:e.status.sub_type},t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var Xo=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;stats=null;context={competition:null};timeline=[];status={type:null,subType:null};lineups=null};var Yo=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 zo=class{fromResponse(e){try{let t=new Yo;return t.corners=this.statEntityFromResponse(e.corners),t.crosses=this.statEntityFromResponse(e.crosses),t.offside=this.statEntityFromResponse(e.offside),t.shotsOn=this.statEntityFromResponse(e.shots_on),t.throwIn=this.statEntityFromResponse(e.throw_in),t.redCards=this.statEntityFromResponse(e.red_cards),t.shotsOff=this.statEntityFromResponse(e.shots_off),t.goalKicks=this.statEntityFromResponse(e.goal_kicks),t.possession=this.statEntityFromResponse(e.possession),t.treatments=this.statEntityFromResponse(e.treatments),t.yellowCards=this.statEntityFromResponse(e.yellow_cards),t.shotsBlocked=this.statEntityFromResponse(e.shots_blocked),t.substitutions=this.statEntityFromResponse(e.substitutions),t.counterAttacks=this.statEntityFromResponse(e.counter_attacks),t.foulsCommitted=this.statEntityFromResponse(e.fouls_committed),t}catch(t){throw console.warn("There was a problem remapping the stats",t),t}}statEntityFromResponse=e=>({homeTeam:e?e.home_team:null,awayTeam:e?e.away_team:null})};var Kr=class{homeTeam={players:[]};awayTeam={players:[]}};var Qo=class{id="";name="";position="";shirtNumber;assets=null;type=""};var Xr=class{fromResponse(e){try{let t=new Qo;return t.id=e.id,t.name=e.name,t.position=e.position,t.shirtNumber=e.shirt_number,t.assets=e.assets,t.type=e.type,t}catch(t){throw console.warn("There was a problem remapping the player from timeline",t),t}}};var Jo=class{playerRemapper=null;constructor(){this.playerRemapper=new Xr}fromResponse(e){try{let t=new Kr;return t.homeTeam.players=e.home_team&&e.home_team.players?e.home_team.players.map(n=>this.playerRemapper.fromResponse(n)):[],t.awayTeam.players=e.away_team&&e.away_team.players?e.away_team.players.map(n=>this.playerRemapper.fromResponse(n)):[],t}catch(t){throw console.warn("There was a problem remapping the lineups",t),t}}};var Zo=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var jo=class{playerRemapper=null;constructor(){this.playerRemapper=new Xr}fromResponse(e){try{let t=new Zo;return t.minute=e.minute,t.type=e.type,t.teamId=e.team_id,t.player=this.playerRemapper.fromResponse(e.player),t.relatedPlayer=e.related_player?this.playerRemapper.fromResponse(e.related_player):null,t.updatedAt=e.updated_at,t}catch(t){throw console.warn("There was a problem remapping timeline",t),t}}};var ea=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new Me,this.competitionsMapper=new Be,this.lineupsMapper=new Jo,this.scoresMapper=new Wr,this.statsMapper=new zo,this.timelineMapper=new jo}fromResponse(e){try{let t=new Xo;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.homeTeam=e.home_team?this.teamMapper.fromResponse(e.home_team):null,t.awayTeam=e.away_team?this.teamMapper.fromResponse(e.away_team):null,t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresMapper.fromResponse(e.scores),t.stats=this.statsMapper.fromResponse(e.stats),t.context={competition:this.competitionsMapper.fromResponse(e.context.competition)},t.timeline=e.timeline?e.timeline.map(n=>this.timelineMapper.fromResponse(n)):[],t.status={type:e.status.type,subType:e.status.sub_type},t.lineups=e.lineups?this.lineupsMapper.fromResponse(e.lineups):new Kr,t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var ta=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var ra=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let t=new ta;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping top player response",t),t}}};var ia=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;teams=[]};var Yr=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new ne,this.teamRemapper=new Me}fromResponse(e){try{let t=new ia;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(n=>this.teamRemapper.fromResponse(n)):[],t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping players response",t),t}}};var na=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;competitions=[];teams=[]};var oa=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new ne,this.teamRemapper=new Me,this.competitionRemapper=new Be}fromResponse(e){try{let t=new na;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(n=>this.teamRemapper.fromResponse(n)):[],t.position=e.position,t.competitions=e.competitions?e.competitions.map(n=>this.competitionRemapper.fromResponse(n)):[],t}catch(t){throw console.warn("There was a problem remapping player response",t),t}}};var aa=class{teams=null;players=null;competitions=null};var sa=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new Me,this.playerRemapper=new Yr,this.competitionremapper=new Be}fromResponse(e){try{let t=new aa;return t.teams=e.teams?e.teams.map(n=>this.teamRemapper.fromResponse(n)):[],t.players=e.players?e.players.map(n=>this.playerRemapper.fromResponse(n)):[],t.competitions=e.competitions?e.competitions.map(n=>this.competitionremapper.fromResponse(n)):[],t}catch(t){throw console.warn("There was a problem remapping search response",t),t}}};var zr=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var Jt=class{pagination=new zr};var Qr=class{meta=new Jt;data=[]};var la=class{remapMetaProp=e=>{let t=new Jt;return t.pagination.currentPage=e.pagination.current_page,t.pagination.itemsPerPage=e.pagination.items_per_page,t.pagination.totalItems=e.pagination.total_items,t.pagination.numberOfPages=e.pagination.number_of_pages,t}};var 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 t=Ae(e.environment,"football");this.apiSignInUrl=`?key=${e.apiKey}&lang=${e.lang}`,this.instance=gd.default.create({baseURL:t}),this.countryRemapper=new ne,this.competitionBasicRemapper=new Be,this.competitionFullRemapper=new Go,this.teamBasicRemapper=new Me,this.teamFullRemapper=new Vo,this.matchBasicRemapper=new Ko,this.matchFullRemapper=new ea,this.playerBasicRemapper=new Yr,this.playerFullRemapper=new oa,this.topPlayerRemapper=new ra,this.searchRemapper=new sa,this.footballMetaRemapper=new la}getCountries=async e=>{try{let t=`/countries${this.apiSignInUrl}`,n=Date.now();e&&(t+=`&disable_cache=${n}`);let a=await this.instance.get(t);return this.countryRemapper.countriesFromResponse(a.data.data)}catch(t){throw console.warn("There was a problem with the football countries request",t),t}};getCompetitions=async(e,t)=>{try{let n={},a=Date.now();if(t=t||!1,e&&e.competitionIds&&e.competitionIds.length>this.limitIds-1){let p=[],d=to(e.competitionIds);for(let b of d){e.competitionIds=b;let F=`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(F+=`&disable_cache=${a}`),n=await this.instance.get(F),p.push(n.data.data.map(w=>this.competitionBasicRemapper.fromResponse(w)))}return Array.prototype.concat.apply([],p)}else{let p=`/competitions${this.apiSignInUrl}`;return e&&(p+=`${e.constructFilterUrl()}`),t&&(p+=`&disable_cache=${a}`),n=await this.instance.get(p),n.data.data.map(d=>this.competitionBasicRemapper.fromResponse(d))}}catch(n){throw console.warn("There was a problem with getCompetitions request",n),n.response}};getCompetitionById=async(e,t)=>{try{let n=`/competitions/${e}${this.apiSignInUrl}`,a=Date.now();t&&(n+=`&disable_cache=${a}`);let p=await this.instance.get(n);return this.competitionFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getCompetitionById request",n),n.response}};getTopCompetitions=async e=>{try{let t=`/competitions/top${this.apiSignInUrl}&client_id=${this.clientId}`,n=Date.now();return e&&(t+=`&disable_cache=${n}`),(await this.instance.get(t)).data.data.map(p=>this.competitionBasicRemapper.fromResponse(p))}catch(t){throw console.warn("There was a problem with getTopCompetitions request",t),t.response}};getTeams=async(e,t)=>{try{let n={},a=Date.now();if(e&&e.teamIds&&e.teamIds.length>this.limitIds){let p=[],d=to(e.teamIds);for(let b of d){e.teamIds=b;let F=`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(F+=`disable_cache=${a}`),n=await this.instance.get(F),p.push(n.data.data.map(w=>this.teamBasicRemapper.fromResponse(w)))}return Array.prototype.concat.apply([],p)}else{let p=new Qr,d=`/teams${this.apiSignInUrl}`;return e&&(d+=`${e.constructFilterUrl()}`),t&&(d+=`&disable_cache=${a}`),n=await this.instance.get(d),p.meta=this.footballMetaRemapper.remapMetaProp(n.data.meta),p.data=n.data.data.map(h=>this.teamBasicRemapper.fromResponse(h)),p}}catch(n){throw console.warn("There was a problem with getTeams request",n),n.response}};getTeamById=async(e,t)=>{try{let n=`/teams/${e}${this.apiSignInUrl}`,a=Date.now();t&&(n+=`disable_cache=${a}`);let p=await this.instance.get(n);return this.teamFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getTeamById request",n),n.response}};getTopTeams=async e=>{try{let t=`/teams/top${this.apiSignInUrl}&client_id=${this.clientId}`,n=Date.now();e&&(t+=`$disable_cache=${n}`);let a=await this.instance.get(t);return a.data.data?a.data.data.map(p=>this.teamBasicRemapper.fromResponse(p)):[]}catch(t){throw console.warn("There was a problem with getTopTeams request",t),t.response}};getNextMatchForTeam=async(e,t)=>{try{let n=`/teams/${e}/next-match${this.apiSignInUrl}`,a=Date.now();t&&(n+=`&disable_cache=${a}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getNextMatchForTeam request",n),n.response}};getPrevMatchForTeam=async(e,t)=>{try{let n=`/teams/${e}/previous-match${this.apiSignInUrl}`,a=Date.now();t&&(n+=`disable_cache=${a}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getPrevMatchForTeam request",n),n.response}};getPlayers=async(e,t)=>{try{let n={},a=Date.now();if(e&&e.playerIds&&e.playerIds.length>this.limitIds-1){let p=[],d=to(e.playerIds);for(let b of d){e.playerIds=b;let F=`/players${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(F+=`&disable_cache=${a}`),n=await this.instance.get(F),p.push(n.data.data.map(w=>this.teamBasicRemapper.fromResponse(w)))}return Array.prototype.concat.apply([],p)}else{let p=new Qr,d=`/players${this.apiSignInUrl}`;return e&&(d+=`${e.constructFilterUrl()}`),t&&(d+=`&disable_cache=${a}`),n=await this.instance.get(d),p.meta=this.footballMetaRemapper.remapMetaProp(n.data.meta),p.data=n.data.data.map(h=>this.playerBasicRemapper.fromResponse(h)),p}}catch(n){throw console.warn("There was a problem with getPlayers request",n),n.response}};getPlayerById=async(e,t)=>{try{let n=`/players/${e}${this.apiSignInUrl}`,a=Date.now();t&&(n+=`&disable_cache=${a}`);let p=await this.instance.get(n);return this.playerFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getPlayerById request",n),n.response}};getTopPlayers=async e=>{try{let t=`/players/top${this.apiSignInUrl}&client_id=${this.clientId}`,n=Date.now();return e&&(t+=`&disable_cache=${n}`),(await this.instance.get(t)).data.data.map(p=>this.topPlayerRemapper.fromResponse(p))}catch(t){throw console.warn("There was a problem with getTopPlayers request",t),t.response}};getNextMatchForPlayer=async(e,t)=>{try{let n=`/players/${e}/next-match${this.apiSignInUrl}`,a=Date.now();t&&(n+=`&disable_cache=${a}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getNextMatchForPlayer request",n),n.response}};getPrevMatchForPlayer=async(e,t)=>{try{let n=`/players/${e}/previous-match${this.apiSignInUrl}`,a=Date.now();t&&(n+=`&disable_cache=${a}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getPrevMatchForPlayer request",n),n.response}};getMatchById=async(e,t)=>{try{let n=`/matches/${e}${this.apiSignInUrl}`,a=Date.now();t&&(n+=`&disable_cache=${a}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getMatchById request",n),n.response}};getMatches=async(e,t)=>{try{let n=new Qr,a=`/matches${this.apiSignInUrl}`,p=Date.now();e&&(a+=`${e.constructFilterUrl()}`),t&&(a+=`&disable_cache=${p}`);let d=await this.instance.get(a);return n.meta=this.footballMetaRemapper.remapMetaProp(d.data.meta),n.data=d.data.data.map(h=>this.matchBasicRemapper.fromResponse(h)),n}catch(n){throw console.warn("There was a problem with getMatches request",n),n.response}};search=async(e,t)=>{try{let n=`/search${this.apiSignInUrl}${e.constructFilterUrl()}`,a=Date.now();t&&(n+=`&disable_cache=${a}`);let p=await this.instance.get(n);return this.searchRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with search request",n),n.response}}};var Mp=Wt(Kt());var Ie=(V=>(V.FT_1X2="FT_1X2",V.HT_1X2="HT_1X2",V.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",V.DOUBLE_CHANCE="DOUBLE_CHANCE",V.HT_FT="HT_FT",V.PLAYER_SCORE="PLAYER_SCORE",V.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",V.PLAYER_RED_CARD="PLAYER_RED_CARD",V.RED_CARD_MATCH="RED_CARD_MATCH",V.PENALTY_MATCH="PENALTY_MATCH",V.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",V.CORNERS_MATCH="CORNERS_MATCH",V.CORRECT_SCORE="CORRECT_SCORE",V.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",V.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",V.OVER_GOALS_0_5="OVER_GOALS_0_5",V.OVER_GOALS_1_5="OVER_GOALS_1_5",V.OVER_GOALS_2_5="OVER_GOALS_2_5",V.OVER_GOALS_3_5="OVER_GOALS_3_5",V.OVER_GOALS_4_5="OVER_GOALS_4_5",V.OVER_GOALS_5_5="OVER_GOALS_5_5",V.OVER_GOALS_6_5="OVER_GOALS_6_5",V.OVER_CORNERS_6_5="OVER_CORNERS_6_5",V.OVER_CORNERS_7_5="OVER_CORNERS_7_5",V.OVER_CORNERS_8_5="OVER_CORNERS_8_5",V.OVER_CORNERS_9_5="OVER_CORNERS_9_5",V.OVER_CORNERS_10_5="OVER_CORNERS_10_5",V.OVER_CORNERS_11_5="OVER_CORNERS_11_5",V.OVER_CORNERS_12_5="OVER_CORNERS_12_5",V.OVER_CORNERS_13_5="OVER_CORNERS_13_5",V))(Ie||{}),yd=["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"],Md=["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"],Zt=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"],wd=["FT_1X2","HT_1X2","HT_FT","DOUBLE_CHANCE","CORNERS_MATCH","CORRECT_SCORE"],pa="PLAYER_SCORE_FIRST_GOAL";var ca=class{overallPercent;byFootballCompetition;byFootballTeam;byFootballMarket};var ua=class{profileId;tier;points;successRates=new ca};var ma=class{successRatePercent;model=null};var da=class{id=null;label=null};var fa=class{type=null;id=null;label=null};var Jr=class{content=new fa;tags=[];campaign=new da};var Zr=class{id=null;profileId=null;action=null;context=new Jr;points=0};var ha=class{totalItems=0};var ga=class{meta=new ha;data=[new Zr]};var ya=class{remapSingleResponse=e=>{let t=new Zr;return t.id=e.id,t.profileId=e.profile_id,t.action=e.action,t.context.content=e.context.content??t.context.content,t.context.tags=e.context.tags,t.context.campaign=e.context.campaign??t.context.campaign,t.points=e.points,t};remapActivitiesResponse=e=>{let t=new ga;return t.meta.totalItems=e.meta.total_items,t.data=e.data.map(n=>this.remapSingleResponse(n)),t};remapStatsReponse=e=>{let t=new ua;return t.profileId=e.profile_id,t.tier=e.tier,t.points=e.points,t.successRates.overallPercent=e.success_rates.overall_percent,t.successRates.byFootballCompetition=this.constructNewRecord(e.success_rates.by_competition),t.successRates.byFootballTeam=this.constructNewRecord(e.success_rates.by_team),t.successRates.byFootballMarket=this.constructNewRecord(e.success_rates.by_market),t};constructNewRecord=e=>{let t;if(Object.entries(e).length)Object.entries(e).forEach(([n,a])=>{t={...t,[n]:this.remapSuccessRatePercent(a)},Ie[n]&&delete t[n].model});else return e;return t};remapSuccessRatePercent=e=>{let t=new ma;return t.successRatePercent=e.success_rate_percent,t}};var jr=class{instanceAuth=null;instance=null;activityRemapper=null;apiSignInUrl=null;constructor(e){let t=Ae(e.environment,"loyalty");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instanceAuth=Mp.default.create({baseURL:t,headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.authProvider.getIdToken()}`}}),this.instance=Mp.default.create({baseURL:t,headers:{"Content-Type":"application/json"}}),this.activityRemapper=new ya}createActivity=async e=>{try{let t=`/activities${this.apiSignInUrl}`,n=await this.instanceAuth.post(t,JSON.stringify(e));return this.activityRemapper.remapSingleResponse(n.data)}catch(t){throw console.warn("There was a problem with creating activity for user",t),t}};deleteActivity=async e=>{try{let t=`/activities/${e}${this.apiSignInUrl}`;return await this.instanceAuth.delete(t),!0}catch(t){throw console.warn(`There was a problem deleting the following activity: ${e}`,t),t.response}};getOwnActivities=async(e,t)=>{try{let n=`/activities${this.apiSignInUrl}`,a=Date.now();e&&(n+=`${e.constructFilterUrl()}`),t&&(n+=`disable_cache=${a}`);let p=await this.instanceAuth.get(n);return this.activityRemapper.remapActivitiesResponse(p.data)}catch(n){throw console.warn("There was a problem with fetching own activities",n),n}};getActivitiesForUser=async(e,t,n)=>{try{let a=`/users/${e}/activities${this.apiSignInUrl}`,p=Date.now();t&&(a+=`${t.constructFilterUrl()}`),n&&(a+=`disable_cache=${p}`);let d=await this.instance.get(a);return this.activityRemapper.remapActivitiesResponse(d.data)}catch(a){throw console.warn(`There was a problem with fetching activities for user ${e}`,a),a}};getStats=async(e,t)=>{try{let n="",a=null;return e?(n+=ge(t)?`/users/${e}/statistics${this.apiSignInUrl}${ye()}`:`/users/${e}/statistics${this.apiSignInUrl}`,a=await this.instance.get(n)):(n+=`/statistics${this.apiSignInUrl}`,a=await this.instanceAuth.get(n)),this.activityRemapper.remapStatsReponse(a.data.data)}catch(n){throw console.warn("There was a problem fetching profile`s statistics:",n),n.response}}};var Ma=class{idMapping=null;idSchema=null;native="native";footballFacade=null;constructor(e,t,n){this.idMapping=n,this.idSchema=e.idSchema,this.footballFacade=t}remapSuccessRatesEntities=async e=>{let{successRates:t}=e,n={competition:this.getIdsKeys(t.byFootballCompetition),team:this.getIdsKeys(t.byFootballTeam)};if(Object.values(n).flat().length){let a=e.successRates.byFootballCompetition,p=e.successRates.byFootballTeam;return e.successRates.byFootballCompetition=await this.setModels(a,n.competition,"competition"),e.successRates.byFootballTeam=await this.setModels(p,n.team,"team"),e}return e};setModels=async(e,t,n)=>{let a=null,p;switch(t=ud(t),n){case"competition":a=await this.footballFacade.getCompetitionsMapWithNativeIds(t);break;case"team":a=await this.footballFacade.getTeamsMapWithNativeIds(t);break}return Object.keys(e).forEach(d=>{let h=a.get(d);p={...p,[h.id]:e[d]},p[h.id].model=h}),p};getIdsKeys=e=>{let t=JSON.parse(JSON.stringify(e));return Object.keys(t)};remapInterestsToIdSchema=async e=>{if(this.idSchema!==this.native)if(e&&e.length>0){let t={},n={};e.forEach(d=>{t.hasOwnProperty(d.type)||(t[d.type]=[],n[d.type]=[]),t[d.type].push(d.id),n[d.type].push(d)});let a=await this.remapIdsObj(t,this.native,this.idSchema),p=[];for(let[d,h]of Object.entries(n))h.forEach((b,F)=>{b.id=a[d][F],p.push(b)});return p}else return e;return e};remapInterestToNative=async e=>{if(this.idSchema!==this.native){let t={},{id:n,type:a}=e;t[a]=[n];let p=await this.remapIdsObj(t,this.idSchema,this.native);return e.id=p[a][0],e}return e};inquiryCustomInterests=async e=>{let t=[];if(e&&e.length>0&&(t=e.filter(n=>n.source==="custom")),t&&t.length>0){let n=e.filter(p=>p.source!=="custom"),a=await this.remapInterestsToIdSchema(n);return t.forEach(p=>a.push(p)),a}return await this.remapInterestsToIdSchema(e)};remapIdsObj=async(e,t,n)=>await this.idMapping.idMappingFacade.getEntitiesByIds(e,t,n)};var wa=class{idMapping=null;profileOperations=null;constructor(e,t){this.idMapping=new ce(e),this.profileOperations=new Ma(e,t,this.idMapping)}remapSuccessRatesEntities=async e=>await this.profileOperations.remapSuccessRatesEntities(e);remapInterestToNative=async e=>await this.profileOperations.remapInterestToNative(e);inquiryCustomInterests=async e=>await this.profileOperations.inquiryCustomInterests(e)};var ei=class{idsRemapper=null;profileHttps=null;activityHttps=null;footballHttps=null;footballFacade=null;idMapping=null;localStorage=null;profileFacade=null;ownProfileBuilder=null;profileBuilder=null;constructor(e){this.profileHttps=new Dr(e),this.activityHttps=new jr(e),this.footballHttps=new Mt(e),this.idMapping=new ce(e),this.localStorage=new gt(e),this.footballFacade=new qr(e,this.localStorage,this.footballHttps,this.idMapping),this.profileFacade=new yt(this.localStorage,this.profileHttps,this.activityHttps),this.idsRemapper=new wa(e,this.footballFacade),this.ownProfileBuilder=new bo(this.idsRemapper,this.localStorage,this.profileHttps,this.activityHttps,this.idMapping,this.footballFacade),this.profileBuilder=new vo(this.idsRemapper,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,t)=>await this.profileFacade.getByIds(e,t)};var ba=class{validate=e=>{let t=this.validateField(e.lang),n=this.generateMessage(t);return{validation:t,message:n}};validateField=e=>{let t=["bg","ro","en"],n=null;return e!=null&&e.length>0?t.includes(e)?n="valid":n="invalid":n="missing",n};generateMessage=e=>{let t=null,n="warning";return e==="missing"&&(t="If no lang is passed the default one will be set which is: en"),e==="invalid"&&(t="This lang value is not supported, the default one will be set which is: en"),e==="valid"&&(t=null,n=null),{text:t,type:n}}};var va=class{validate(e){let t=this.validateField(e.environment),n=this.generateMessage(t);return{validation:t,message:n}}validateField=e=>{let t=["dev","staging","prod"],n=null;return e!=null&&e.length>0?t.includes(e)?n="valid":n="invalid":n="missing",n};generateMessage=e=>{let t=null,n="warning";return e==="missing"&&(t="If no environment is passed the default one will be set which is: prod"),e==="invalid"&&(t="This environment value is not supported, the default one will be set which is: prod"),e==="valid"&&(t=null,n=null),{text:t,type:n}}};var Pa=class{validate(e){let t=this.validateField(e.apiKey),n=this.generateMessage(t);return{validation:t,message:n}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,n="error";return e==="missing"&&(t="The field apiKey with valid value must be provided to use Fans United JS SDK"),e==="valid"&&(n=null),{text:t,type:n}}};var Ia=class{validate(e){let t=this.validateField(e.idSchema),n=this.generateMessage(t);return{validation:t,message:n}}validateField=e=>{let t=["native","sportal365","enetpulse","sportradar"],n=null;return e!=null&&e.length>0?t.includes(e)?n="valid":n="invalid":n="missing",n};generateMessage=e=>{let t=null,n="warning";return e==="missing"&&(t="If no idSchema is passed the default one will be set which is: native"),e==="invalid"&&(t="This idSchema value is not supported, the default one will be set which is: native"),e==="valid"&&(t=null,n=null),{text:t,type:n}}};var dr=class{getIdToken=null;logout=null};var ri=class{text=null;type=null};var _a=class{validation=null;message=new ri;getIdToken={validation:null,message:new ri};logout={validation:null,message:new ri}};var Ra=class{validate(e){let t=this.validateAuthProvider(e.authProvider);return t.validation!=="missing"&&(t=this.validateAuthProviderConfigFields(e.authProvider,t),t=this.generateAuthProviderConfigMessages(t),t=this.checkAuthProviderConfigMessagesForErrors(t)),t}validateAuthProvider=e=>{let t=Object.keys(new dr),n=new _a;if(e){let p=Object.keys(e).filter(d=>!t.includes(d));p.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:"} ${p.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,t)=>(Object.keys(new dr).forEach(a=>{e[a]?t[a].validation="valid":t[a].validation="missing"}),t);generateAuthProviderConfigMessages=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{let n=e[t];n.validation==="missing"&&(n.message.text=`${"The following property is missing from the authProvider object:"} ${t}`,n.message.type="error")}),e);checkAuthProviderConfigMessagesForErrors=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{e[t].validation==="missing"&&e.validation==="valid"&&(e.validation="invalid",e.message.type="error",e.message.text="The field authProvider has missing properties")}),e)};var zi=class{validation;message};var Fa=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;authProvider={getIdToken:new zi,logout:new zi};isValid=!1};var Sa=class{validate(e){let t=this.validateField(e.clientId),n=this.generateMessage(t);return{validation:t,message:n}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,n="error";return e==="missing"&&(t="The field clientId must be provided to use Fans United JS SDK"),e==="valid"&&(t=null,n=null),{text:t,type:n}}};var Ta=class{validate=e=>{let t=this.checkFieldsForValues(e);return t.isValid=this.containsErrorMessage(t),t};checkFieldsForValues=e=>{let t=new Fa,n={apiKey:new Pa,environment:new va,idSchema:new Ia,clientId:new Sa,lang:new ba,authProvider:new Ra};for(let[a,p]of Object.entries(t))a!=="isValid"&&(p=n[a].validate(e));return Object.keys(n).forEach(a=>{t[a]=n[a].validate(e)}),t};containsErrorMessage=e=>{let t=!0;for(let[n,a]of Object.entries(e))if(n!=="authProvider"){if(n!=="isValid"&&a.message.type==="error")return t=!1,t;if(n!=="isValid"&&a.message.type==="warning")return t=!0,t}else if(a.message.type==="error")return t=!1,t;return t}};var Ea=class{https=null;idMapping=null;localStorage=null;footballFacade=null;constructor(e){this.https=new Mt(e),this.idMapping=new ce(e),this.localStorage=new gt(e),this.footballFacade=new qr(e,this.localStorage,this.https,this.idMapping)}getCountries=async e=>await this.footballFacade.getCountries(e);getCompetitions=async(e,t)=>await this.footballFacade.getCompetitions(e,t);getCompetitionById=async(e,t)=>await this.footballFacade.getCompetitionById(e,t);getTopCompetitions=async e=>await this.footballFacade.getTopCompetitions(e);getTeams=async(e,t)=>await this.footballFacade.getTeams(e,t);getTeamById=async(e,t)=>await this.footballFacade.getTeamById(e,t);getTopTeams=async e=>await this.footballFacade.getTopTeams(e);getNextMatchForTeam=async(e,t)=>await this.footballFacade.getNextMatchForTeam(e,t);getPrevMatchForTeam=async(e,t)=>await this.footballFacade.getPrevMatchForTeam(e,t);getPlayers=async(e,t)=>await this.footballFacade.getPlayers(e,t);getPlayerById=async(e,t)=>await this.footballFacade.getPlayerById(e,t);getTopPlayers=async e=>await this.footballFacade.getTopPlayers(e);getNextMatchForPlayer=async(e,t)=>await this.footballFacade.getNextMatchForPlayer(e,t);getPrevMatchForPlayer=async(e,t)=>await this.footballFacade.getPrevMatchForPlayer(e,t);getMatches=async(e,t)=>await this.footballFacade.getMatches(e,t);getMatchById=async(e,t)=>await this.footballFacade.getMatchById(e,t);search=async(e,t)=>await this.footballFacade.search(e,t)};var _p=Wt(Kt());var Ca=class{value=null;playerId=null;playerModel=null};var ii=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new Ca;result=null};var xa=class{value=!1;playerId=null};var et=class{matchId=null;market=null;prediction=null;constructor(e,t,n,a){this.matchId=e,this.market=t,this.prediction=new xa,this.prediction.value=n,this.prediction.playerId=a}};var ni=class{settledAt=null;resettledAt=null;status=null;outcome=null;points=0};var Aa=class{value=null};var jt=class{matchId=null;market="CORRECT_SCORE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Aa,this.prediction.value=t}};var tt=class{value=!1};var oi=class{matchId=null;market=null;prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new tt,this.prediction.value=n}};var ai=class{matchId=null;market=null;prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new tt,this.prediction.value=n}};var Oa=class{matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t,n){this.matchFacade=e,this.playerFacade=t,this.predictorService=n}remapFixturesRequest=e=>{let t={};if(t.match_id=e.matchId,t.match_type="FOOTBALL",e instanceof et)t.market=e.market,t.prediction=e.prediction.value,t.player_id=e.prediction.playerId;else if(e instanceof oi||e instanceof ai)t.market=e.market,t.prediction=e.prediction.value;else if(e instanceof jt){t.market=e.market;let n=e.prediction.value.split(":");t.goals_home=Number(n[0]),t.goals_away=Number(n[1])}else t.market=e.market,t.prediction=e.prediction.value;return t};remapFixturesResponse=async e=>{e.length>1&&e.sort((h,b)=>h.match_id.localeCompare(b.match_id));let t=[],n=[];for(let h of e)t.push(h.match_id),h.player_id&&!n.includes(h.player_id)&&n.push(h.player_id);let a=await this.matchFacade.getMatchesMapWithNativeIds(t),p=[];n.sort((h,b)=>h.localeCompare(b)),n&&n.length>0&&(p=await this.playerFacade.getPlayersMapWithNativeIds(n));let d=[];for(let h of e){let b=new ii;h.target?b.market=this.predictorService.convertMarketForResponseModel(h.market,h.target):b.market=h.market,b.matchId=a[h.match_id].id,b.matchType=h.match_type,b.matchModel=a?a[h.match_id]:null,delete b.matchModel.availableMarkets,h.goals_home!==void 0&&h.goals_away!==void 0?b.prediction.value=h.goals_home.toString()+":"+h.goals_away.toString():b.prediction.value=h.prediction,b.prediction.playerId=h.player_id?h.player_id:null,b.prediction.playerId&&(b.prediction.playerModel=p[h.player_id],b.prediction.playerId=p[h.player_id].id),b.result=this.remapResult(h.result),d.push(b)}return d};remapResult=e=>{let t=new ni;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t.points=e.points,t}};var si=class{goldenGoal=null};var Qi=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new si;points=null;createdAt=null;updatedAt=null};var j=class{no=0;yes=0};var li=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new j;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new j;penaltyMatch=new j;playerScoreFirstGoal={};cornersMatch={};correctScore={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new j;overOnePointFiveGoals=new j;overTwoPointFiveGoals=new j;overThreePointFiveGoals=new j;overFourPointFiveGoals=new j;overFivePointFiveGoals=new j;overSixPointFiveGoals=new j;overSixPointFiveCorners=new j;overSevenPointFiveCorners=new j;overEightPointFiveCorners=new j;overNinePointFiveCorners=new j;overTenPointFiveCorners=new j;overElevenPointFiveCorners=new j;overTwelvePointFiveCorners=new j;overThirteenPointFiveCorners=new j};var wp=(n=>(n.ONE="1",n.X="x",n.TWO="2",n))(wp||{}),bp=(n=>(n.ONE_X="1x",n.X_TWO="x2",n.ONE_TWO="12",n))(bp||{}),vp=(F=>(F.ONE_ONE="1/1",F.ONE_X="1/x",F.ONE_TWO="1/2",F.X_ONE="x/1",F.X_X="x/x",F.X_TWO="x/2",F.TWO_ONE="2/1",F.TWO_X="2/x",F.TWO_TWO="2/2",F))(vp||{});var Ba=class{value=null};var La=class{matchId=null;market="HT_FT";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Ba,this.prediction.value=t}};var Na=class{value=null};var Da=class{matchId=null;market="DOUBLE_CHANCE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new Na,this.prediction.value=t}};var pi=class{value=null};var Ua=class{matchId=null;market="FT_1X2";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new pi,this.prediction.value=t}};var Ga=class{matchId=null;market="HT_1X2";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new pi,this.prediction.value=t}};var $a=class{value};var Ha=class{matchId=null;market="CORNERS_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new $a,this.prediction.value=t}};var ka=class{matchId=null;market="BOTH_TEAMS_SCORE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new tt,this.prediction.value=t}};var Va=class{matchId=null;market="RED_CARD_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new tt,this.prediction.value=t}};var qa=class{matchId=null;market="PENALTY_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new tt,this.prediction.value=t}};var fr=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null};var hr=class{userId=null;points=null;results=[];tiebreaker=null};var Wa=(p=>(p.ACTIVE="ACTIVE",p.WON="WON",p.LOST="LOST",p.PARTIALLY_WON="PARTIALLY_WON",p.CANCELED="CANCELED",p))(Wa||{}),Pp=["WON","LOST","PARTIALLY_WON","CANCELED"];var _e=class{limit=null;startAfter=null;status=null;type=null;matchIds=null;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null,this.status=e.status?e.status:null,this.type=e.type?e.type:null,this.matchIds=e.matchIds?e.matchIds:null}constructFiltersUrl=()=>{let e="",t=!1;return this.status&&(t=Object.values(Wa).some(n=>this.status.includes(n))),this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),this.status&&t&&(e+="&",e+=`status=${this.status.join(",")}`),this.type&&(e+="&",e+=`game_types=${this.type}`),this.matchIds&&(e+="&",e+=`match_ids=${this.matchIds.join(",")}`),e}};var Ji=(d=>(d.OPEN="OPEN",d.LIVE="LIVE",d.PENDING="PENDING",d.CANCELED="CANCELED",d.CLOSED="CLOSED",d.SETTLED="SETTLED",d))(Ji||{});var Ve=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(Ji).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 gr=class{id=null;title=null;description=null;type=null;status=null;predictionsCutoff=null;fixtures=[];rules=null;flags=null;createdAt=null;updatedAt=null};var Ot=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null};var Ip={UNEXPECTED_STATUS_PROP:`Unexpected provided property 'status'. You can NOT use this property for this method. For more information visit our documentation:
22
22
  ${gp.PREDICTOR_USER_RELATED_OPERATION}`,UNEXPECTED_TYPE_PROP:`Unexpected provided property 'type'. You can NOT use this property for this method. For more information visit our documentation:
23
23
  ${gp.PREDICTOR_USER_RELATED_OPERATION}`};var Ka=class{id=null;name=null;country=null};var wt=class{footballHttps=null;idMapping=null;matchFacade=null;playerFacade=null;constructor(e,t){this.footballHttps=new Mt(e),this.idMapping=t,this.matchFacade=new Qt(e,this.footballHttps,t),this.playerFacade=new zt(e,this.footballHttps,t)}remapMatchIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"match","native")).match;remapPlayerIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"player","native")).player[0];remapPlayerIdMapToNative=async e=>{let t={},n=Xt(e),p=(await this.idMapping.getEntityIdsBySchemaId(n,"player","native")).player;return n.forEach((d,h)=>t[d]=p[h]),t};remapPlayerIdToIdSchema=async e=>{let t=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"];for(let[n,a]of Object.entries(e))if(t.includes(n))for(let p of Object.keys(a)){let d={player:[p]},b=(await this.idMapping.idMappingFacade.getEntitiesByIds(d,"native",this.idMapping.idSchema)).player[0];a[b]=a[p],delete a[p]}return e};convertMarket=e=>{let t=Object.keys(new li),n=Object.values(Ie);for(let a=0;a<n.length;a++)e===n[a]&&(e=t[a]);return e};convertMarketForResponseModel=(e,t)=>{let n=t.toString();return e+"_"+n};validateFixture=(e,t,n,a)=>{let p=Object.values(wp),d=Object.values(vp),h=Object.values(bp);if(t==="FT_1X2"){if(p.includes(n))return new Ua(e,n)}else if(t==="HT_1X2"){if(p.includes(n))return new Ga(e,n)}else if(t==="HT_FT"){if(d.includes(n))return new La(e,n)}else if(t==="DOUBLE_CHANCE"){if(h.includes(n))return new Da(e,n)}else if(t==="CORRECT_SCORE"){if(typeof n=="string"&&/\d+:\d+/.test(n))return new jt(e,n)}else if(t==="CORNERS_MATCH"){if(typeof n=="number")return new Ha(e,n)}else if(t==="BOTH_TEAMS_SCORE"){if(typeof n=="boolean")return new ka(e,n)}else if(t==="RED_CARD_MATCH"){if(typeof n=="boolean")return new Va(e,n)}else if(t==="PENALTY_MATCH"){if(typeof n=="boolean")return new qa(e,n)}else if(Zt.includes(t)){if(t===pa&&typeof n=="boolean")return new et(e,t,n,a);if(a&&typeof n=="boolean")return new et(e,t,n,a)}else if(yd.includes(t)){if(typeof n=="boolean")return new ai(e,t,n)}else if(Md.includes(t)&&typeof n=="boolean")return new oi(e,t,n)};getMarketSummary=(e,t,n)=>{let a=this.convertMarket(t),p={};if(p.matchId=e.matchId,p.matchType=e.matchType,Object.keys(e.predictions).includes(a))p[a]=e.predictions[a];else throw new Error("You have passed invalid market");return Zt.includes(t)&&n?(p[a][n]||(p[a][n]=new j),p[a][n]):p};remapCompetitionsFromConfig=async e=>{if(e instanceof Vr){let t={competition:e.fullCoverageCompetitions},n=await this.idMapping.idMappingFacade.getEntitiesByIds(t,"native",this.idMapping.idSchema);return e.fullCoverageCompetitions=n.competition,e}if(e instanceof kr||e instanceof Hr){let t={competition:e.competitionsWhitelist},n=await this.idMapping.idMappingFacade.getEntitiesByIds(t,"native",this.idMapping.idSchema);return e.competitionsWhitelist=n.competition,e}};remapMatchIdsFixtures=async e=>{if(Array.isArray(e.data))if(e.data.length>0){let t=[],n=[];return e.data.forEach(a=>{a instanceof gr||a instanceof fr||a instanceof Ot?(a.fixtures.forEach(p=>t.push(p.matchId)),a instanceof Ot&&a.fixtures.forEach(p=>{p.prediction.playerId&&n.push(p.prediction.playerId)})):a instanceof hr&&a.results.forEach(p=>t.push(p.matchId))}),await this.refactorResponseArrModel(e,t,n)}else return e;else return await this.refactorResponseObjModel(e)};refactorResponseArrModel=async(e,t,n)=>{let a=[],p=await this.matchFacade.getMatchesMapWithNativeIds(t),d={};return n.length>0&&(d=await this.playerFacade.getPlayersMapWithNativeIds(n)),e.data.forEach(h=>{h instanceof gr||h instanceof fr||h instanceof Ot?(h.fixtures.forEach(b=>{b.matchModel=p[b.matchId],delete b.matchModel.availableMarkets,b.matchId=b.matchModel.id,h instanceof Ot&&b.prediction.playerId&&(b.prediction.playerModel=d[b.prediction.playerId],b.prediction.playerId=d[b.prediction.playerId].id)}),a.push(h)):h instanceof hr&&(h.results.forEach(b=>{b.matchModel=p[b.matchId],delete b.matchModel.availableMarkets,b.matchId=b.matchModel.id}),a.push(h))}),e.data=a,e};refactorResponseObjModel=async e=>{let t=[];e.fixtures.forEach(a=>t.push(a.matchId));let n=await this.matchFacade.getMatchesMapWithNativeIds(t);return e.fixtures.forEach(a=>{a.matchModel=n[a.matchId],delete a.matchModel.availableMarkets,a.matchId=n[a.matchId].id}),e};getCurrentGameId=e=>{let t=new Date;if(e.data.length>1){let n=[];return e.data.forEach(p=>n.push(p.predictionsCutoff)),e.data.sort((p,d)=>{let[h,b]=[p.predictionsCutoff,d.predictionsCutoff].map(F=>Math.abs(new Date(F)-t));return h-b})[0].id}else return e.data[0].id};initGameTypePredictions=e=>{let t={type:e};return t=new _e(t),t};initGameFilters=(e,t,n)=>{if(t&&n)return t.type=e,t.gameIds=n,t=new Ve(t),t;if(t&&!n)return t.type=e,t=new Ve(t),t;if(!t&&n){let a={type:e,gameIds:n};return a=new Ve(a),a}else{let a={type:e};return a=new Ve(a),a}};addPredictionProp=async(e,t)=>(t.data.forEach((n,a)=>{e.forEach(p=>{n.id===p.game_instance_id&&(n.outcome=p.status,n.fixtures.forEach((d,h)=>{p.fixtures[h].goals_home!==void 0&&p.fixtures[h].goals_away!==void 0?d.prediction.value=p.fixtures[h].goals_home+":"+p.fixtures[h].goals_away:d.prediction.value=p.fixtures[h].prediction,p.fixtures[h].player_id?d.prediction.playerId=p.fixtures[h].player_id:p.fixtures[h].target&&(d.prediction.target=p.fixtures[h].target),d.prediction.result=this.remapResult(p.fixtures[h].result)}),n.predictionsMadeAt=p.created_at,n.points=p.points)})}),await this.remapMatchIdsFixtures(t));remapResult=e=>{let t=new ni;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t.points=e.points,t};areIdsExceeded=e=>{let t=10;return e.length>t};initPredictionsFilters=(e,t,n)=>{switch(t){case"user":e&&(e=new _e(e));break;case"current":if(e)this.deleteUnexpectedProperties(e),e.status=["ACTIVE"],e=new _e(e);else{let a={status:["ACTIVE"]};e=new _e(a)}break;case"past":if(e)this.deleteUnexpectedProperties(e),e.status=Pp,e=new _e(e);else{let a={status:Pp};e=new _e(a)}break;case"matches":if(e)this.deleteUnexpectedProperties(e),e.matchIds=n,e=new _e(e);else{let a={matchIds:n};e=new _e(a)}break}return e};completeGameMarketResults=async(e,t)=>{switch(t){case"MATCH_QUIZ":let n={},a=e.results[0].matchId,p=e.results.map(F=>Zt.includes(F.market)?[...F.result]:[]).flat(),d=await this.matchFacade.getMatchesMapWithNativeIds([a]);return p.length&&(n=await this.playerFacade.getPlayersMapWithNativeIds(p)),e.results=e.results.map(F=>{if(F.matchModel=d[F.matchId],F.playerModels&&F.result.forEach(S=>{let k=new Ka,se=n[S];k.id=se.id,k.name=se.name,k.country=se.country,F.playerModels.push(k)}),this.idMapping.idSchema!=="native"&&(F.matchId=d[F.matchId].id,F.playerModels)){let w=F.result;F.result=w.map(S=>n[S].id)}return F}),e;case"TOP_X":let h=e.results.map(F=>F.matchId),b=await this.matchFacade.getMatchesMapWithNativeIds(h);return e.results=e.results.map(F=>(F.matchModel=b[F.matchId],this.idMapping.idSchema!=="native"&&(F.matchId=b[F.matchId].id),F)),e}};deleteUnexpectedProperties=e=>(e.status&&(console.warn(Ip.UNEXPECTED_STATUS_PROP),delete e.status),e.type&&(console.warn(Ip.UNEXPECTED_TYPE_PROP),delete e.type),e)};var ci=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(e){this.gameInstanceId=e.gameInstanceId,e.fixtures.forEach(t=>this.fixtures.push(new jt(t.matchId,t.prediction.value))),this.tiebreaker=e.tiebreaker?e.tiebreaker:null}};var ui=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t){this.footballHttps=new Mt(e),this.matchFacade=new Qt(e,this.footballHttps,t),this.playerFacade=new zt(e,this.footballHttps,t),this.predictorService=new wt(e,t),this.fixturesRemapper=new Oa(this.matchFacade,this.playerFacade,this.predictorService)}remapRequestBody=e=>{let t={};return t.game_instance_id=e.gameInstanceId,t.fixtures=e.fixtures.map(n=>this.fixturesRemapper.remapFixturesRequest(n)),e instanceof ci&&e.tiebreaker&&(t.tiebreaker={},t.tiebreaker.golden_goal=e.tiebreaker.goldenGoal?e.tiebreaker.goldenGoal:null),t};remapResponseArrayBody=async e=>{if(e.length){let t=[],n=[],a={},p=[];e.forEach(h=>{h.fixtures.forEach(b=>{t.push(b.match_id),b.player_id&&n.push(b.player_id)})});let d=await this.matchFacade.getMatchesMapWithNativeIds(t);return n.length>0&&(a=await this.playerFacade.getPlayersMapWithNativeIds(n)),e.forEach(h=>{let b=new Qi,F=[];b.id=h.id,b.gameInstanceId=h.game_instance_id,b.gameType=h.game_type,b.wager=h.wager,b.totalFixtures=h.total_fixtures,b.settledFixtures=h.settled_fixtures,b.userId=h.user_id,h.fixtures.forEach(w=>{let S=new ii;w.target?S.market=this.predictorService.convertMarketForResponseModel(w.market,w.target):S.market=w.market,S.matchId=d[w.match_id].id,S.matchType=w.match_type,S.matchModel=d[w.match_id],delete S.matchModel.availableMarkets,w.goals_home!==void 0&&w.goals_away!==void 0?S.prediction.value=w.goals_home.toString()+":"+w.goals_away.toString():S.prediction.value=w.prediction,S.prediction.playerId=w.player_id?w.player_id:null,S.prediction.playerId&&(S.prediction.playerModel=a[S.prediction.playerId],S.prediction.playerId=a[S.prediction.playerId].id),S.result=this.fixturesRemapper.remapResult(w.result),F.push(S)}),b.fixtures=F,b.status=h.status,h.tiebreaker?b.tiebreaker.goldenGoal=h.tiebreaker.golden_goal:b.tiebreaker=null,b.points=h.points,b.createdAt=h.created_at,b.updatedAt=h.updated_at,p.push(b)}),p}return e};remapResponseObjBody=async e=>{let t=new Qi;return t.id=e.id,t.gameInstanceId=e.game_instance_id,t.gameType=e.game_type,t.wager=e.wager,t.totalFixtures=e.total_fixtures,t.settledFixtures=e.settled_fixtures,t.userId=e.user_id,t.fixtures=await this.fixturesRemapper.remapFixturesResponse(e.fixtures),t.status=e.status,e.tiebreaker?t.tiebreaker.goldenGoal=e.tiebreaker.golden_goal:t.tiebreaker=null,t.points=e.points,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapPredictionModel=e=>{let t=new li;return t.fullTimeOneXTwo=e.FT_1X2,t.halfTimeOneXTwo=e.HT_1X2,t.bothTeamsScore=e.BOTH_TEAMS_SCORE,t.overZeroPointFiveGoals=e.OVER_GOALS_0_5,t.overOnePointFiveGoals=e.OVER_GOALS_1_5,t.overTwoPointFiveGoals=e.OVER_GOALS_2_5,t.overThreePointFiveGoals=e.OVER_GOALS_3_5,t.overFourPointFiveGoals=e.OVER_GOALS_4_5,t.overFivePointFiveGoals=e.OVER_GOALS_5_5,t.overSixPointFiveGoals=e.OVER_GOALS_6_5,t.overSixPointFiveCorners=e.OVER_CORNERS_6_5,t.overSevenPointFiveCorners=e.OVER_CORNERS_7_5,t.overEightPointFiveCorners=e.OVER_CORNERS_8_5,t.overNinePointFiveCorners=e.OVER_CORNERS_9_5,t.overTenPointFiveCorners=e.OVER_CORNERS_10_5,t.overElevenPointFiveCorners=e.OVER_CORNERS_11_5,t.overTwelvePointFiveCorners=e.OVER_CORNERS_12_5,t.overThirteenPointFiveCorners=e.OVER_CORNERS_13_5,t.doubleChance=e.DOUBLE_CHANCE,t.halfTimeFullTime=e.HT_FT,t.playerScore=e.PLAYER_SCORE,t.playerYellowCard=e.PLAYER_YELLOW_CARD,t.playerRedCard=e.PLAYER_RED_CARD,t.redCardMatch=e.RED_CARD_MATCH,t.penaltyMatch=e.PENALTY_MATCH,t.playerScoreFirstGoal=e.PLAYER_SCORE_FIRST_GOAL,t.cornersMatch=e.CORNERS_MATCH,t.correctScore=e.CORRECT_SCORE,t.playerScoreHattrick=e.PLAYER_SCORE_HATTRICK,t.playerScoreTwice=e.PLAYER_SCORE_TWICE,t}};var Xa=class{matchId=null;matchType=null;predictions=null};var Ya=class{remapPredictions=null;constructor(e,t){this.remapPredictions=new ui(e,t)}remapResponse=e=>{let t=new Xa;return t.matchId=e.match_id,t.matchType=e.match_type,t.predictions=this.remapPredictions.remapPredictionModel(e.predictions),t}};var za=class{matchId=null;matchType=null;market=null;matchModel=null};var Qa=class{value=null;target=null;playerId=null;playerModel=null;result=null};var Ja=class{matchId=null;matchType=null;market=null;matchModel=null;prediction=new Qa};var Za=class{value=null;result=null};var ja=class{matchId=null;matchType=null;market="CORRECT_SCORE";matchModel=null;prediction=new Za};var es=class{matchId=null;matchModel=null;outcome=null};var ts=class{gameId=null;results=null};var rs=class{remapPaginatedGames=e=>{let t=new ie;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapGamesListResponse(n)),t};remapGamesListResponse=e=>{let t=new gr;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.fixtures=e.fixtures.map(n=>this.remapFixturesResponse(n)),t.rules=e.rules,t.flags=e.flags,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapFixturesResponse=e=>{let t=new za;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t};remapPaginatedUserTopXEditions=e=>{let t=new ie;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapUserTopXEditionsResponse(n)),t};remapUserTopXEditionsResponse=e=>{let t=new fr;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.fixtures=e.fixtures.map(n=>this.remapTopXFixturesResponse(n)),t.rules=e.rules,t.flags=e.flags,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapTopXFixturesResponse=e=>{let t=new ja;return t.matchId=e.match_id,t.matchType=e.match_type,t};remapPaginatedUserMathQuizEditions=e=>{let t=new ie;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapUserMatchQuizEditionsResponse(n)),t};remapUserMatchQuizEditionsResponse=e=>{let t=new Ot;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.fixtures=e.fixtures.map(n=>this.remapMatchQuizFixturesResponse(n)),t.rules=e.rules,t.flags=e.flags,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapMatchQuizFixturesResponse=e=>{let t=new Ja;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t};remapPaginatedGameResults=e=>{let t=new ie;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapGameResults(n)),t};remapGameResults=e=>{let t=new hr;return t.userId=e.user_id,t.points=e.points?e.points:0,t.results=e.results.map(n=>this.remapResults(n)),t.tiebreaker=e.tiebreaker?this.remapTiebreaker(e.tiebreaker):null,t};remapGameMarketsResults=e=>{let t=new ts;return t.gameId=e.game_id,t.results=this.remapMarketsResults(e.results),t};remapMarketsResults=e=>{let t=[];return e.forEach(n=>{let a={matchId:n.match_id,market:n.market,result:this.remapMarketResult(n.market,n.result),matchModel:null,playerModels:[]};t.push(this.deleteUnusefulField(a))}),t};remapMarketResult=(e,t)=>{if(wd.includes(e))return t[0];if(Zt.includes(e))return t;if(t[0]==="true")return!0;if(t[0]==="false")return!1};deleteUnusefulField=e=>((!Zt.includes(e.market)||this.isPlayerMarketWithNoResult(e.market,e.result))&&delete e.playerModels,e);isPlayerMarketWithNoResult=(e,t)=>Zt.includes(e)&&t.length===0;remapResults=e=>{let t=new es;return t.matchId=e.match_id,t.outcome=e.outcome,t};remapTiebreaker=e=>{let t=new si;return t.goldenGoal=e.golden_goal,t}};var is=class{remapMetaData=e=>{let t=new Nr;return t.pagination.nextPageStartsAfter=e.pagination.next_page_starts_after,t.pagination.itemsPerPage=e.pagination.items_per_page,t}};var er=class{instanceAuth=null;instance=null;apiSignInUrl=null;predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;metaRemapper=null;constructor(e,t){let n=Ae(e.environment,"predictor");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.predictionRemapper=new ui(e,t),this.matchSummaryRemapper=new Ya(e,t),this.gamesRemapper=new rs,this.metaRemapper=new is,this.instanceAuth=_p.default.create({baseURL:n,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instance=_p.default.create({baseURL:n,headers:{"Content-Type":"application/json"}})}makeFootballPrediction=async e=>{try{let t=this.predictionRemapper.remapRequestBody(e),n=await this.instanceAuth.post(`/predictions${this.apiSignInUrl}`,JSON.stringify(t));return await this.predictionRemapper.remapResponseObjBody(n.data)}catch(t){throw console.warn("There was a problem making POST request: ",t),t.response}};getMatchSummary=async(e,t)=>{let n=ge(t)?`/predictions/summary/${e}${this.apiSignInUrl}${ye()}`:`/predictions/summary/${e}${this.apiSignInUrl}`;try{let a=await this.instance.get(n);return this.matchSummaryRemapper.remapResponse(a.data)}catch(a){throw console.warn(`There was a problem fetching predictions for match: ${e} `,a),a.response}};deleteFootballPrediction=async e=>{try{return await this.instanceAuth.delete(`/predictions/${e}${this.apiSignInUrl}`),!0}catch(t){throw console.warn(`There was a problem deleting your prediction: ${e}`,t),t.response}};getMyPredictions=async e=>{try{let t=new ie,n=`/predictions${this.apiSignInUrl}`;e&&(n+=`${e.constructFiltersUrl()}`);let a=await this.instanceAuth.get(n);return t.meta=this.metaRemapper.remapMetaData(a.data.meta),t.data=await this.predictionRemapper.remapResponseArrayBody(a.data.data),t}catch(t){throw console.warn("There was a problem fetching own predictions",t),t.response}};getMyPredictionsNoRemap=async e=>{try{return(await this.instanceAuth.get(`/predictions${this.apiSignInUrl}${e.constructFiltersUrl()}`)).data.data}catch(t){throw console.warn("There was a problem fetching own predictions",t),t.response}};getUserPredictions=async(e,t,n)=>{try{let a=new ie,p=ge(t)?`/predictions/users/${e}${this.apiSignInUrl}${ye()}`:`/predictions/users/${e}${this.apiSignInUrl}`;n&&(p+=`${n.constructFiltersUrl()}`);let d=await this.instance.get(p);return a.meta=this.metaRemapper.remapMetaData(d.data.meta),a.data=await this.predictionRemapper.remapResponseArrayBody(d.data.data),a}catch(a){throw console.warn(`There was a problem fetching predictions for user: ${e}`,a),a.response}};getUserPredictionsNoRemap=async(e,t)=>{try{return(await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}${t.constructFiltersUrl()}`)).data.data}catch(n){throw console.warn(`There was a problem fetching predictions for user: ${e}`,n),n.response}};getGames=async(e,t)=>{try{let n=ge(t)?`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}${ye()}`:`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,a=await this.instance.get(n);return this.gamesRemapper.remapPaginatedGames(a.data)}catch(n){throw console.warn("There was a problem fetching the games list",n),n.response}};getGameById=async(e,t)=>{try{let n=ge(t)?`/games/${e}${this.apiSignInUrl}${ye()}`:`/games/${e}${this.apiSignInUrl}`,a=await this.instance.get(n);return this.gamesRemapper.remapGamesListResponse(a.data)}catch(n){throw console.warn(`There was a problem fetching the following game: ${e}`,n),n.response}};getGamePredictions=async(e,t,n)=>{try{let a=new ie,p=ge(t)?`/games/${e}/predictions${this.apiSignInUrl}${ye()}`:`/games/${e}/predictions${this.apiSignInUrl}`;n&&(p+=`${n.constructFiltersUrl()}`);let d=await this.instance.get(p);return a.meta=this.metaRemapper.remapMetaData(d.data.meta),a.data=await this.predictionRemapper.remapResponseArrayBody(d.data.data),a}catch(a){throw console.warn(`There was a problem fetching the predictions for game: ${e}`,a),a.response}};getUserGameEditions=async(e,t)=>{try{let n=null,a=ge(t)?`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}${ye()}`:`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,p=await this.instance.get(a);return p.data.data.forEach(d=>{d.type==="TOP_X"?n=this.gamesRemapper.remapPaginatedUserTopXEditions(p.data):d.type==="MATCH_QUIZ"&&(n=this.gamesRemapper.remapPaginatedUserMathQuizEditions(p.data))}),n}catch(n){throw console.warn("There was a problem fetching the games list",n),n.response}};getGameResults=async(e,t,n)=>{try{let a=ge(t)?`/games/${e}/results/${this.apiSignInUrl}${ye()}`:`/games/${e}/results/${this.apiSignInUrl}`;n&&(a+=`${n.constructFiltersUrl()}`);let p=await this.instance.get(a);return this.gamesRemapper.remapPaginatedGameResults(p.data)}catch(a){throw console.warn(`There was a problem fetching the results for the following game: ${e}`,a),a.response}};getMarketResultsForGame=async(e,t)=>{let n=`/games/${e}/correct-results/${this.apiSignInUrl}`;ge(t)&&(n+=`${ye()}`);try{let a=await this.instance.get(n);return this.gamesRemapper.remapGameMarketsResults(a.data.data)}catch(a){throw console.warn(`There was a problem fetching the markets correct results for the following game: ${e}`,a),a.response}}};var ns=class{gameInstanceId=null;fixtures=null};var lt=class extends Error{constructor(e){super(e);Object.setPrototypeOf(this,new.target.prototype)}errorMessage=()=>this.message};var os=class{predictorHttps=null;clientHttps=null;idMapping=null;predictorService=null;invalidPredictionMessage=`The prediction is invalid. Please check again have you passed appropriate prediction argument. For more information visit our official documentation:
24
24
  https://docs.fansunitedmedia.com/sdks/js/predictor#matchrelatedoperations`;constructor(e,t,n,a){this.predictorHttps=t,this.idMapping=a,this.clientHttps=n,this.predictorService=new wt(e,a)}makeFootballPrediction=async(e,t,n,a)=>{let p=this.predictorService.validateFixture(e,t,n,a),d=new ns;if(p)if(this.idMapping.idSchema!=="native"){let h=p.matchId,b="",F=await this.predictorService.remapMatchIdToNative([h]);if(p.matchId=F[0],!p.matchId)throw new lt("Match id is invalid!").errorMessage();if(p instanceof et&&(b=p.prediction.playerId,p.prediction.playerId=b&&await this.predictorService.remapPlayerIdToNative([b]),p.market!==pa&&!p.prediction.playerId))throw new lt("Player id is invalid!").errorMessage();d.fixtures=[p];let w=await this.predictorHttps.makeFootballPrediction(d);return w.fixtures.map(S=>{S.prediction.playerId&&(S.prediction.playerId=b),S.matchId=h}),w}else return d.fixtures=[p],await this.predictorHttps.makeFootballPrediction(d);else throw new Error(this.invalidPredictionMessage)};getMatchSummary=async(e,t)=>{if(this.idMapping.idSchema!=="native"){let a=(await this.predictorService.remapMatchIdToNative([e]))[0],p=await this.predictorHttps.getMatchSummary(a,t);p.matchId=e;let d=p.predictions,h=await this.predictorService.remapPlayerIdToIdSchema(d);return p.predictions=h,p}else return await this.predictorHttps.getMatchSummary(e,t)};getMarketSummary=async(e,t,n,a)=>{try{let p=await this.getMatchSummary(e,a);return this.predictorService.getMarketSummary(p,t,n)}catch(p){return p.message}};getConfig=async()=>{let e=await this.clientHttps.getConfig("predictor");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(e):e};deleteFootballPrediction=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyPredictions=async e=>{let t=this.predictorService.initPredictionsFilters(e,"user");return await this.predictorHttps.getMyPredictions(t)};getMyPredictionsForMatches=async(e,t)=>{if(this.predictorService.areIdsExceeded(e))throw new lt("Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();this.idMapping.idSchema!=="native"&&(e=await this.predictorService.remapMatchIdToNative([...e]));let n=this.predictorService.initPredictionsFilters(t,"matches",e);return await this.predictorHttps.getMyPredictions(n)};getMyCurrentPredictions=async e=>{let t=this.predictorService.initPredictionsFilters(e,"current");return await this.predictorHttps.getMyPredictions(t)};getMyPastPredictions=async e=>{let t=this.predictorService.initPredictionsFilters(e,"past");return await this.predictorHttps.getMyPredictions(t)};getUserPredictions=async(e,t,n)=>{let a=this.predictorService.initPredictionsFilters(t,"user");return await this.predictorHttps.getUserPredictions(e,n,a)};getUserCurrentPredictions=async(e,t,n)=>{let a=this.predictorService.initPredictionsFilters(t,"current");return await this.predictorHttps.getUserPredictions(e,n,a)};getUserPastPredictions=async(e,t,n)=>{let a=this.predictorService.initPredictionsFilters(t,"past");return await this.predictorHttps.getUserPredictions(e,n,a)};getUserPredictionsForMatches=async(e,t,n,a)=>{if(this.predictorService.areIdsExceeded(t))throw new lt("Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();this.idMapping.idSchema!=="native"&&(t=await this.predictorService.remapMatchIdToNative([...t]));let p=this.predictorService.initPredictionsFilters(n,"matches",t);return await this.predictorHttps.getUserPredictions(e,a,p)}};var as=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(e){this.idMapping=new ce(e),this.predictorHttps=new er(e,this.idMapping),this.clientHttps=new je(e),this.predictorFacade=new os(e,this.predictorHttps,this.clientHttps,this.idMapping)}makeFootballPrediction=async(e,t,n,a)=>await this.predictorFacade.makeFootballPrediction(e,t,n,a);getMatchSummary=async(e,t)=>await this.predictorFacade.getMatchSummary(e,t);getMarketSummary=async(e,t,n,a)=>await this.predictorFacade.getMarketSummary(e,t,n,a);getConfig=async()=>await this.predictorFacade.getConfig();deleteFootballPrediction=async e=>await this.predictorFacade.deleteFootballPrediction(e);getMyPredictions=async e=>await this.predictorFacade.getMyPredictions(e);getMyCurrentPredictions=async e=>await this.predictorFacade.getMyCurrentPredictions(e);getMyPastPredictions=async e=>await this.predictorFacade.getMyPastPredictions(e);getMyPredictionsForMatches=async(e,t)=>await this.predictorFacade.getMyPredictionsForMatches(e,t);getUserPredictions=async(e,t,n)=>await this.predictorFacade.getUserPredictions(e,t,n);getUserCurrentPredictions=async(e,t,n)=>await this.predictorFacade.getUserCurrentPredictions(e,t,n);getUserPastPredictions=async(e,t,n)=>await this.predictorFacade.getUserPastPredictions(e,t,n);getUserPredictionsForMatches=async(e,t,n,a)=>await this.predictorFacade.getUserPredictionsForMatches(e,t,n,a)};var vd=Wt(Kt());var ss=class{rankType=null;fromDate=null;toDate=null;pagination=new zr};var mi=class{position=null;profileId=null;profileModel=null;points=null};var ls=class{remapResponse=e=>(e.meta=this.remapMeta(e.meta),e.data=this.remapData(e.data),e);remapMeta=e=>{let t=new ss;return t.rankType=e.rank_type,t.fromDate=e.from_date,t.toDate=e.to_date,t.pagination.currentPage=e.pagination.current_page,t.pagination.itemsPerPage=e.pagination.items_per_page,t.pagination.totalItems=e.pagination.total_items,t.pagination.numberOfPages=e.pagination.number_of_pages,t};remapData=e=>{let t=[];return e.forEach(n=>{let a=new mi;a.position=n.position,a.profileId=n.profile_id,a.points=n.points,t.push(a)}),t}};var ps=class extends mi{id=null;rankType=null};var cs=class{remapRankings=e=>(e.meta=this.remapMeta(e.meta),e.data=this.remapData(e.data),e);remapMeta=e=>{let t=new Jt;return t.pagination.currentPage=e.pagination.current_page,t.pagination.itemsPerPage=e.pagination.items_per_page,t.pagination.numberOfPages=e.pagination.number_of_pages,t.pagination.totalItems=e.pagination.total_items,t};remapData(e){let t=[];return e.forEach(n=>{let a=new ps;a.id=n.id,a.rankType=n.rank_type,a.position=n.position,a.points=n.points,delete a.profileId,delete a.profileModel,t.push(a)}),t}};var us=class{id=null;name=null;description=null;type=null;fromDate=null;toDate=null;markets=[];teamIds=[];matchIds=[];gameIds=[];gameTypes=[];competitionIds=[];rules=null;flags=null};var ms=class{remapResponse=e=>{let t=[];return e.forEach(n=>{let a=new us;a.id=n.id,a.name=n.name,a.description=n.description,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,a.rules=n.rules?n.rules:null,a.flags=n.flags?n.flags:null,t.push(a)}),t};remapMeta=e=>{let t={};return t.totalItems=e.pagination.total_items,t}};var ds=class{instance=null;apiSignInUrl=null;templateRemapper=null;leaderboardRemapper=null;rankingsRemapper=null;constructor(e){let t=Ae(e.environment,"loyalty");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.templateRemapper=new ms,this.leaderboardRemapper=new ls,this.rankingsRemapper=new cs,this.instance=vd.default.create({baseURL:t,headers:{"Content-Type":"application/json"}})}getTemplates=async(e,t)=>{try{let n=ge(e)?`/leaderboard/templates/${this.apiSignInUrl}${ye()}`:`/leaderboard/templates/${this.apiSignInUrl}`,a=await this.instance.get(n);if(t){let p=JSON.parse(JSON.stringify(a.data));return p.meta=this.templateRemapper.remapMeta(a.data.meta),p.data=this.templateRemapper.remapResponse(a.data.data),p}return this.templateRemapper.remapResponse(a.data.data)}catch(n){throw console.warn("There was a problem fetching the list of templates",n),n.response}};getLeaderboard=async(e,t,n)=>{try{let a=ge(t)?`/leaderboard/${e}/${this.apiSignInUrl}${ye()}`:`/leaderboard/${e}/${this.apiSignInUrl}`;n&&(a+=`${n.constructFiltersUrl()}`);let p=await this.instance.get(a),d=JSON.parse(JSON.stringify(p.data));return this.leaderboardRemapper.remapResponse(d)}catch(a){throw console.warn(`There was a problem fetching the leaderboard for the following template: ${e}`,a),a.response}};getLeaderboardForGame=async(e,t,n)=>{try{let a=ge(t)?`/leaderboard/games/${e}/${this.apiSignInUrl}${ye()}`:`/leaderboard/games/${e}/${this.apiSignInUrl}`;n&&(a+=`${n.constructFiltersUrl()}`);let p=await this.instance.get(a),d=JSON.parse(JSON.stringify(p.data));return ro(d)}catch(a){throw console.warn(`There was a problem fetching the leaderboard for the following game: ${e}`,a),a.response}};getUserRankings=async(e,t,n)=>{let a=`/leaderboard/users/${e}/rankings/${this.apiSignInUrl}`;t&&(a+=`${t.constructFiltersUrl()}`),ge(n)&&(a+=`${ye()}`);try{let p=await this.instance.get(a);return this.rankingsRemapper.remapRankings(p.data)}catch(p){throw console.warn(`There was a problem fetching the rankings for the following user: ${e}`,p),p.response}}};var fs=class{general;predictor;topX;matchQuiz};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 hs=class extends di{sortOrder=null;type=null;leaderboardIds=null;constructor(e){super(e);this.sortOrder=e.sortOrder,this.type=e.type,this.leaderboardIds=e.leaderboardIds}constructFiltersUrl=()=>{let e=super.constructFiltersUrl();return this.sortOrder&&(e+="&",e+=`sort_order=${this.sortOrder}`),this.type&&(e+="&",e+=`type=${this.type}`),this.leaderboardIds&&(e+="&",e+=`type_ids=${this.leaderboardIds.join(",")}`),e}};var gs=class{idMappingService=null;profileNamespace=null;constructor(e){this.idMappingService=new ce(e),this.profileNamespace=new ei(e)}remapTemplatesIds=async e=>{if(e.length>0){let t=[],n=[],a=[],p=[],d=[],h=[];e.forEach(w=>{w.teamIds&&w.teamIds.length>0?t=[...t,...w.teamIds]:w.matchIds&&w.matchIds.length>0?a=[...a,...w.matchIds]:w.competitionIds&&w.competitionIds.length>0&&(d=[...d,...w.competitionIds])});let b={team:t,match:a,competition:d},F=await this.idMappingService.idMappingFacade.getEntitiesByIds(b,"native",this.idMappingService.idSchema);return n=[...F.team],p=[...F.match],h=[...F.competition],e.forEach(w=>{w.teamIds&&w.teamIds.length>0?w.teamIds=w.teamIds.map(S=>S=F.team.shift()):w.matchIds&&w.matchIds.length>0?w.matchIds=w.matchIds.map(S=>S=F.match.shift()):w.competitionIds&&w.competitionIds.length>0&&(w.competitionIds=w.competitionIds.map(S=>S=F.competition.shift()))}),e}return e};addProfileModel=async e=>{if(e.length>0){let t=[],n=[];e.forEach(p=>{t.push(p.profileId)});let a=await this.profileNamespace.getByIds(t);return e.forEach(p=>{a.forEach(d=>{d.id===p.profileId&&(delete d.interests,p.profileModel=d)}),p.profileModel||(p.profileModel=null),n.push(p)}),n}return e};buildClientBadges=e=>{let t=new fs;return t.general=this.extractEnabledBadgesId(e.general),t.predictor=this.extractEnabledBadgesId(e.predictor),t.topX=this.extractEnabledBadgesId(e.topX),t.matchQuiz=this.extractEnabledBadgesId(e.matchQuiz),t};initFilters=(e,t)=>{switch(t){case"loyalty":e&&(e=new di(e));break;case"rankings":e&&(e=new hs(e));break}return e};extractEnabledBadgesId=e=>{let t=[];return e.forEach(n=>{n.enabled&&t.push(n.id)}),t}};var ys=class{config=null;clientHttps=null;loyaltyHttps=null;loyaltyService=null;profileFacade=null;constructor(e,t,n,a,p){this.config=e,this.clientHttps=t,this.loyaltyHttps=n,this.profileFacade=new yt(p,a),this.loyaltyService=new gs(this.config)}getConfig=async()=>await this.clientHttps.getConfig("loyalty");getClientBadges=async()=>{let e=await this.getConfig();return this.loyaltyService.buildClientBadges(e.rewards.badges)};getTemplates=async e=>{let t=!0;if(this.config.idSchema==="native")return await this.loyaltyHttps.getTemplates(e,t);let n=await this.loyaltyHttps.getTemplates(e,t);return n.data=await this.loyaltyService.remapTemplatesIds([...n.data]),n};getTemplateById=async(e,t)=>{try{let n=!1,p=(await this.loyaltyHttps.getTemplates(t,n)).filter(h=>h.id===e);if(!p.length)throw new lt("Provided template ID does NOT exist! Try again with existing template ID.").errorMessage();return this.config.idSchema==="native"?p[0]:(await this.loyaltyService.remapTemplatesIds(p))[0]}catch(n){throw console.warn("There was a problem retrieving specified template: ",n),n}};getLeaderboard=async(e,t,n)=>{t=this.loyaltyService.initFilters(t,"loyalty");let a=await this.loyaltyHttps.getLeaderboard(e,n,t);return a.data=await this.loyaltyService.addProfileModel(a.data),a};getLeaderboardForGame=async(e,t,n)=>{t=this.loyaltyService.initFilters(t,"loyalty");let a=await this.loyaltyHttps.getLeaderboardForGame(e,n,t);return a.data=await this.loyaltyService.addProfileModel(a.data),a};getOwnRankings=async(e,t)=>{let{id:n}=await this.profileFacade.getOwn();return this.getUserRankings(n,e,t)};getUserRankings=async(e,t,n)=>(t=this.loyaltyService.initFilters(t,"rankings"),await this.loyaltyHttps.getUserRankings(e,t,n))};var Ms=class{clientHttps=null;profileHttps=null;loyaltyHttps=null;loyaltyFacade=null;localStorage=null;constructor(e){this.clientHttps=new je(e),this.profileHttps=new Dr(e),this.loyaltyHttps=new ds(e),this.localStorage=new gt(e),this.loyaltyFacade=new ys(e,this.clientHttps,this.loyaltyHttps,this.profileHttps,this.localStorage)}getConfig=async()=>await this.loyaltyFacade.getConfig();getClientBadges=async()=>await this.loyaltyFacade.getClientBadges();getTemplates=async e=>await this.loyaltyFacade.getTemplates(e);getTemplateById=async(e,t)=>await this.loyaltyFacade.getTemplateById(e,t);getLeaderboard=async(e,t,n)=>await this.loyaltyFacade.getLeaderboard(e,t,n);getLeaderboardForGame=async(e,t,n)=>await this.loyaltyFacade.getLeaderboardForGame(e,t,n);getOwnRankings=async(e,t)=>await this.loyaltyFacade.getOwnRankings(e,t);getUserRankings=async(e,t,n)=>await this.loyaltyFacade.getUserRankings(e,t,n)};var ws=class{idMapping=null;predictorHttps=null;predictorService=null;clientHttps=null;constructor(e,t){this.idMapping=t,this.predictorHttps=new er(e,t),this.predictorService=new wt(e,t),this.clientHttps=new je(e)}getConfig=async()=>{let e=await this.clientHttps.getConfig("topX");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(e):e};getGames=async(e,t)=>{t=t||!1;let n=this.predictorService.initGameFilters("TOP_X",e),a=await this.predictorHttps.getGames(n,t);return await this.predictorService.remapMatchIdsFixtures(a)};getGameById=async(e,t)=>{t=t||!1;let n=await this.predictorHttps.getGameById(e,t);return await this.predictorService.remapMatchIdsFixtures(n)};getGamePredictions=async(e,t,n)=>(n=n||!1,t&&(t.type&&delete t.type,t.status&&delete t.status,t=new _e(t)),await this.predictorHttps.getGamePredictions(e,n,t));getGameResults=async(e,t,n)=>{n=n||!1,t&&(t.type&&delete t.type,t.gameIds&&delete t.gameIds,t=new Ve(t));let a=await this.predictorHttps.getGameResults(e,n,t);return await this.predictorService.remapMatchIdsFixtures(a)};getCurrentGameResults=async e=>{e=e||!1;let t={status:"OPEN",type:"TOP_X"};t=new Ve(t);let n=await this.predictorHttps.getGames(t,e),a=this.predictorService.getCurrentGameId(n);return(await this.getGameResults(a,null,e)).data[0]};play=async e=>{let t=new ci(e);if(this.idMapping.idSchema!=="native"){let a=[];t.fixtures.forEach(d=>a.push(d.matchId));let p=await this.predictorService.remapMatchIdToNative(a);t.fixtures.forEach(d=>d.matchId=p.shift())}let n=await this.predictorHttps.makeFootballPrediction(t);return n.fixtures.forEach(a=>{a.matchId=a.matchModel.id}),n};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyGameEditions=async(e,t)=>{t=t||!1;let n=this.predictorService.initGameTypePredictions("TOP_X"),a=[],p=await this.predictorHttps.getMyPredictionsNoRemap(n);if(p.length>0){p.forEach(b=>{b.game_instance_id&&a.push(b.game_instance_id)});let d=this.predictorService.initGameFilters("TOP_X",e,a),h=await this.predictorHttps.getUserGameEditions(d,t);return await this.predictorService.addPredictionProp(p,h)}else return new ie};getMyGamePrediction=async e=>{let t=this.predictorService.initGameTypePredictions("TOP_X"),n=await this.predictorHttps.getMyPredictions(t);return n.data.length>0?n.data.filter(p=>p.gameInstanceId===e)[0]:null};getUserGameEditions=async(e,t,n)=>{n=n||!1;let a=this.predictorService.initGameTypePredictions("TOP_X"),p=[],d=await this.predictorHttps.getUserPredictionsNoRemap(e,a);if(d.length>0){d.forEach(F=>{F.game_instance_id&&p.push(F.game_instance_id)});let h=this.predictorService.initGameFilters("TOP_X",t,p),b=await this.predictorHttps.getUserGameEditions(h,n);return await this.predictorService.addPredictionProp(d,b)}else return new ie};getUserGamePrediction=async(e,t,n)=>{n=n||!1;let a=this.predictorService.initGameTypePredictions("TOP_X"),p=await this.predictorHttps.getUserPredictions(e,n,a);return p.data.length>0?p.data.filter(h=>h.gameInstanceId===t)[0]:null};getMarketsResultsForGame=async(e,t)=>{let n=await this.predictorHttps.getMarketResultsForGame(e,t);return await this.predictorService.completeGameMarketResults(n,"TOP_X")}};var bs=class{topXFacade=null;idMapping=null;constructor(e){this.idMapping=new ce(e),this.topXFacade=new ws(e,this.idMapping)}getConfig=async()=>await this.topXFacade.getConfig();getGames=async(e,t)=>await this.topXFacade.getGames(e,t);getGameById=async(e,t)=>await this.topXFacade.getGameById(e,t);getGamePredictions=async(e,t,n)=>await this.topXFacade.getGamePredictions(e,t,n);getGameResults=async(e,t,n)=>await this.topXFacade.getGameResults(e,t,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,t)=>await this.topXFacade.getMyGameEditions(e,t);getMyGamePrediction=async e=>await this.topXFacade.getMyGamePrediction(e);getUserGameEditions=async(e,t,n)=>await this.topXFacade.getUserGameEditions(e,t,n);getUserGamePrediction=async(e,t,n)=>await this.topXFacade.getUserGamePrediction(e,t,n);getMarketsResultsForGame=async(e,t)=>await this.topXFacade.getMarketsResultsForGame(e,t)};var vs=class{predictorHttps=null;predictorService=null;idMapping=null;clientHttps=null;constructor(e){this.idMapping=new ce(e),this.predictorHttps=new er(e,this.idMapping),this.predictorService=new wt(e,this.idMapping),this.clientHttps=new je(e)}getConfig=async()=>{let e=await this.clientHttps.getConfig("matchQuiz");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(e):e};play=async e=>{let t=e.fixtures.map(n=>this.predictorService.validateFixture(n.matchId,n.market,n.prediction.value,n.prediction.playerId));if(t.includes(void 0))throw new lt(`The prediction is invalid. Please check again have you passed appropriate prediction model. For more information please visit our offical documentation: