fansunited-sdk-esm 1.13.0 → 1.13.2

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 += '`),$&&(F+=`' +
18
18
  function print() { __p += __j.call(arguments, '') }
19
19
  `:`;
20
20
  `)+F+`return __p
21
- }`;var U=lm(function(){return V(m,C+"return "+F).apply(s,f)});if(U.source=F,Vl(U))throw U;return U}function Db(i){return W(i).toLowerCase()}function Ub(i){return W(i).toUpperCase()}function Gb(i,r,a){if(i=W(i),i&&(a||r===s))return yc(i);if(!i||!(r=Ue(r)))return i;var l=at(i),c=at(r),m=Mc(l,c),f=wc(l,c)+1;return qt(l,m,f).join("")}function kb(i,r,a){if(i=W(i),i&&(a||r===s))return i.slice(0,vc(i)+1);if(!i||!(r=Ue(r)))return i;var l=at(i),c=wc(l,at(r))+1;return qt(l,0,c).join("")}function Hb(i,r,a){if(i=W(i),i&&(a||r===s))return i.replace(Vs,"");if(!i||!(r=Ue(r)))return i;var l=at(i),c=Mc(l,at(r));return qt(l,c).join("")}function $b(i,r){var a=Bd,l=Ld;if(j(r)){var c="separator"in r?r.separator:c;a="length"in r?D(r.length):a,l="omission"in r?Ue(r.omission):l}i=W(i);var m=i.length;if(Pi(i)){var f=at(i);m=f.length}if(a>=m)return i;var g=a-_i(l);if(g<1)return l;var w=f?qt(f,0,g).join(""):i.slice(0,g);if(c===s)return w+l;if(f&&(g+=w.length-g),ql(c)){if(i.slice(g).search(c)){var _,R=w;for(c.global||(c=ol(c.source,W(Gp.exec(c))+"g")),c.lastIndex=0;_=c.exec(R);)var F=_.index;w=w.slice(0,F===s?g:F)}}else if(i.indexOf(Ue(c),g)!=g){var T=w.lastIndexOf(c);T>-1&&(w=w.slice(0,T))}return w+l}function Vb(i){return i=W(i),i&&Zd.test(i)?i.replace(Np,Mh):i}var qb=Ci(function(i,r,a){return i+(a?" ":"")+r.toUpperCase()}),Xl=pu("toUpperCase");function sm(i,r,a){return i=W(i),r=a?s:r,r===s?dh(i)?vh(i):nh(i):i.match(r)||[]}var lm=G(function(i,r){try{return Ne(i,s,r)}catch(a){return Vl(a)?a:new B(a)}}),Wb=Tt(function(i,r){return Ke(r,function(a){a=ft(a),Ft(i,a,Hl(i[a],i))}),i});function Kb(i){var r=i==null?0:i.length,a=A();return i=r?J(i,function(l){if(typeof l[1]!="function")throw new Xe(o);return[a(l[0]),l[1]]}):[],G(function(l){for(var c=-1;++c<r;){var m=i[c];if(Ne(m[0],this,l))return Ne(m[1],this,l)}})}function Xb(i){return Mg(ze(i,P))}function Yl(i){return function(){return i}}function Yb(i,r){return i==null||i!==i?r:i}var zb=uu(),Qb=uu(!0);function Ae(i){return i}function zl(i){return Hc(typeof i=="function"?i:ze(i,P))}function Jb(i){return Vc(ze(i,P))}function jb(i,r){return qc(i,ze(r,P))}var Zb=G(function(i,r){return function(a){return xr(a,i,r)}}),ev=G(function(i,r){return function(a){return xr(i,a,r)}});function Ql(i,r,a){var l=le(r),c=xn(r,l);a==null&&!(j(r)&&(c.length||!l.length))&&(a=r,r=i,i=this,c=xn(r,le(r)));var m=!(j(a)&&"chain"in a)||!!a.chain,f=Ct(i);return Ke(c,function(g){var w=r[g];i[g]=w,f&&(i.prototype[g]=function(){var _=this.__chain__;if(m||_){var R=i(this.__wrapped__),F=R.__actions__=Te(this.__actions__);return F.push({func:w,args:arguments,thisArg:i}),R.__chain__=_,R}return w.apply(i,Dt([this.value()],arguments))})}),i}function tv(){return se._===this&&(se._=Sh),this}function Jl(){}function iv(i){return i=D(i),G(function(r){return Wc(r,i)})}var rv=Tl(J),nv=Tl(mc),av=Tl(Zs);function pm(i){return Ll(i)?el(ft(i)):Lg(i)}function ov(i){return function(r){return i==null?s:pi(i,r)}}var sv=du(),lv=du(!0);function jl(){return[]}function Zl(){return!1}function pv(){return{}}function cv(){return""}function uv(){return!0}function mv(i,r){if(i=D(i),i<1||i>N)return[];var a=ut,l=ge(i,ut);r=A(r),i-=ut;for(var c=rl(l,r);++a<i;)r(a);return c}function dv(i){return L(i)?J(i,ft):Ge(i)?[i]:Te(Eu(W(i)))}function fv(i){var r=++Rh;return W(i)+r}var hv=Un(function(i,r){return i+r},0),gv=El("ceil"),yv=Un(function(i,r){return i/r},1),Mv=El("floor");function wv(i){return i&&i.length?An(i,Ae,fl):s}function bv(i,r){return i&&i.length?An(i,A(r,2),fl):s}function vv(i){return hc(i,Ae)}function Iv(i,r){return hc(i,A(r,2))}function Pv(i){return i&&i.length?An(i,Ae,Ml):s}function _v(i,r){return i&&i.length?An(i,A(r,2),Ml):s}var Rv=Un(function(i,r){return i*r},1),Fv=El("round"),Sv=Un(function(i,r){return i-r},0);function Tv(i){return i&&i.length?il(i,Ae):0}function Ev(i,r){return i&&i.length?il(i,A(r,2)):0}return u.after=JM,u.ary=ku,u.assign=Uw,u.assignIn=em,u.assignInWith=Jn,u.assignWith=Gw,u.at=kw,u.before=Hu,u.bind=Hl,u.bindAll=Wb,u.bindKey=$u,u.castArray=pw,u.chain=Du,u.chunk=My,u.compact=wy,u.concat=by,u.cond=Kb,u.conforms=Xb,u.constant=Yl,u.countBy=TM,u.create=Hw,u.curry=Vu,u.curryRight=qu,u.debounce=Wu,u.defaults=$w,u.defaultsDeep=Vw,u.defer=jM,u.delay=ZM,u.difference=vy,u.differenceBy=Iy,u.differenceWith=Py,u.drop=_y,u.dropRight=Ry,u.dropRightWhile=Fy,u.dropWhile=Sy,u.fill=Ty,u.filter=CM,u.flatMap=OM,u.flatMapDeep=BM,u.flatMapDepth=LM,u.flatten=Ou,u.flattenDeep=Ey,u.flattenDepth=Cy,u.flip=ew,u.flow=zb,u.flowRight=Qb,u.fromPairs=Ay,u.functions=Qw,u.functionsIn=Jw,u.groupBy=NM,u.initial=Oy,u.intersection=By,u.intersectionBy=Ly,u.intersectionWith=Ny,u.invert=Zw,u.invertBy=eb,u.invokeMap=UM,u.iteratee=zl,u.keyBy=GM,u.keys=le,u.keysIn=Ce,u.map=Wn,u.mapKeys=ib,u.mapValues=rb,u.matches=Jb,u.matchesProperty=jb,u.memoize=Xn,u.merge=nb,u.mergeWith=tm,u.method=Zb,u.methodOf=ev,u.mixin=Ql,u.negate=Yn,u.nthArg=iv,u.omit=ab,u.omitBy=ob,u.once=tw,u.orderBy=kM,u.over=rv,u.overArgs=iw,u.overEvery=nv,u.overSome=av,u.partial=$l,u.partialRight=Ku,u.partition=HM,u.pick=sb,u.pickBy=im,u.property=pm,u.propertyOf=ov,u.pull=ky,u.pullAll=Lu,u.pullAllBy=Hy,u.pullAllWith=$y,u.pullAt=Vy,u.range=sv,u.rangeRight=lv,u.rearg=rw,u.reject=qM,u.remove=qy,u.rest=nw,u.reverse=Gl,u.sampleSize=KM,u.set=pb,u.setWith=cb,u.shuffle=XM,u.slice=Wy,u.sortBy=QM,u.sortedUniq=jy,u.sortedUniqBy=Zy,u.split=Ob,u.spread=aw,u.tail=eM,u.take=tM,u.takeRight=iM,u.takeRightWhile=rM,u.takeWhile=nM,u.tap=wM,u.throttle=ow,u.thru=qn,u.toArray=Ju,u.toPairs=rm,u.toPairsIn=nm,u.toPath=dv,u.toPlainObject=Zu,u.transform=ub,u.unary=sw,u.union=aM,u.unionBy=oM,u.unionWith=sM,u.uniq=lM,u.uniqBy=pM,u.uniqWith=cM,u.unset=mb,u.unzip=kl,u.unzipWith=Nu,u.update=db,u.updateWith=fb,u.values=Oi,u.valuesIn=hb,u.without=uM,u.words=sm,u.wrap=lw,u.xor=mM,u.xorBy=dM,u.xorWith=fM,u.zip=hM,u.zipObject=gM,u.zipObjectDeep=yM,u.zipWith=MM,u.entries=rm,u.entriesIn=nm,u.extend=em,u.extendWith=Jn,Ql(u,u),u.add=hv,u.attempt=lm,u.camelCase=wb,u.capitalize=am,u.ceil=gv,u.clamp=gb,u.clone=cw,u.cloneDeep=mw,u.cloneDeepWith=dw,u.cloneWith=uw,u.conformsTo=fw,u.deburr=om,u.defaultTo=Yb,u.divide=yv,u.endsWith=bb,u.eq=st,u.escape=vb,u.escapeRegExp=Ib,u.every=EM,u.find=AM,u.findIndex=Au,u.findKey=qw,u.findLast=xM,u.findLastIndex=xu,u.findLastKey=Ww,u.floor=Mv,u.forEach=Uu,u.forEachRight=Gu,u.forIn=Kw,u.forInRight=Xw,u.forOwn=Yw,u.forOwnRight=zw,u.get=Wl,u.gt=hw,u.gte=gw,u.has=jw,u.hasIn=Kl,u.head=Bu,u.identity=Ae,u.includes=DM,u.indexOf=xy,u.inRange=yb,u.invoke=tb,u.isArguments=mi,u.isArray=L,u.isArrayBuffer=yw,u.isArrayLike=Ee,u.isArrayLikeObject=te,u.isBoolean=Mw,u.isBuffer=Wt,u.isDate=ww,u.isElement=bw,u.isEmpty=vw,u.isEqual=Iw,u.isEqualWith=Pw,u.isError=Vl,u.isFinite=_w,u.isFunction=Ct,u.isInteger=Xu,u.isLength=zn,u.isMap=Yu,u.isMatch=Rw,u.isMatchWith=Fw,u.isNaN=Sw,u.isNative=Tw,u.isNil=Cw,u.isNull=Ew,u.isNumber=zu,u.isObject=j,u.isObjectLike=ee,u.isPlainObject=Ur,u.isRegExp=ql,u.isSafeInteger=Aw,u.isSet=Qu,u.isString=Qn,u.isSymbol=Ge,u.isTypedArray=xi,u.isUndefined=xw,u.isWeakMap=Ow,u.isWeakSet=Bw,u.join=Dy,u.kebabCase=Pb,u.last=Je,u.lastIndexOf=Uy,u.lowerCase=_b,u.lowerFirst=Rb,u.lt=Lw,u.lte=Nw,u.max=wv,u.maxBy=bv,u.mean=vv,u.meanBy=Iv,u.min=Pv,u.minBy=_v,u.stubArray=jl,u.stubFalse=Zl,u.stubObject=pv,u.stubString=cv,u.stubTrue=uv,u.multiply=Rv,u.nth=Gy,u.noConflict=tv,u.noop=Jl,u.now=Kn,u.pad=Fb,u.padEnd=Sb,u.padStart=Tb,u.parseInt=Eb,u.random=Mb,u.reduce=$M,u.reduceRight=VM,u.repeat=Cb,u.replace=Ab,u.result=lb,u.round=Fv,u.runInContext=M,u.sample=WM,u.size=YM,u.snakeCase=xb,u.some=zM,u.sortedIndex=Ky,u.sortedIndexBy=Xy,u.sortedIndexOf=Yy,u.sortedLastIndex=zy,u.sortedLastIndexBy=Qy,u.sortedLastIndexOf=Jy,u.startCase=Bb,u.startsWith=Lb,u.subtract=Sv,u.sum=Tv,u.sumBy=Ev,u.template=Nb,u.times=mv,u.toFinite=At,u.toInteger=D,u.toLength=ju,u.toLower=Db,u.toNumber=je,u.toSafeInteger=Dw,u.toString=W,u.toUpper=Ub,u.trim=Gb,u.trimEnd=kb,u.trimStart=Hb,u.truncate=$b,u.unescape=Vb,u.uniqueId=fv,u.upperCase=qb,u.upperFirst=Xl,u.each=Uu,u.eachRight=Gu,u.first=Bu,Ql(u,function(){var i={};return mt(u,function(r,a){X.call(u.prototype,a)||(i[a]=r)}),i}(),{chain:!1}),u.VERSION=e,Ke(["bind","bindKey","curry","curryRight","partial","partialRight"],function(i){u[i].placeholder=u}),Ke(["drop","take"],function(i,r){H.prototype[i]=function(a){a=a===s?1:oe(D(a),0);var l=this.__filtered__&&!r?new H(this):this.clone();return l.__filtered__?l.__takeCount__=ge(a,l.__takeCount__):l.__views__.push({size:ge(a,ut),type:i+(l.__dir__<0?"Right":"")}),l},H.prototype[i+"Right"]=function(a){return this.reverse()[i](a).reverse()}}),Ke(["filter","map","takeWhile"],function(i,r){var a=r+1,l=a==Op||a==Gd;H.prototype[i]=function(c){var m=this.clone();return m.__iteratees__.push({iteratee:A(c,3),type:a}),m.__filtered__=m.__filtered__||l,m}}),Ke(["head","last"],function(i,r){var a="take"+(r?"Right":"");H.prototype[i]=function(){return this[a](1).value()[0]}}),Ke(["initial","tail"],function(i,r){var a="drop"+(r?"":"Right");H.prototype[i]=function(){return this.__filtered__?new H(this):this[a](1)}}),H.prototype.compact=function(){return this.filter(Ae)},H.prototype.find=function(i){return this.filter(i).head()},H.prototype.findLast=function(i){return this.reverse().find(i)},H.prototype.invokeMap=G(function(i,r){return typeof i=="function"?new H(this):this.map(function(a){return xr(a,i,r)})}),H.prototype.reject=function(i){return this.filter(Yn(A(i)))},H.prototype.slice=function(i,r){i=D(i);var a=this;return a.__filtered__&&(i>0||r<0)?new H(a):(i<0?a=a.takeRight(-i):i&&(a=a.drop(i)),r!==s&&(r=D(r),a=r<0?a.dropRight(-r):a.take(r-i)),a)},H.prototype.takeRightWhile=function(i){return this.reverse().takeWhile(i).reverse()},H.prototype.toArray=function(){return this.take(ut)},mt(H.prototype,function(i,r){var a=/^(?:filter|find|map|reject)|While$/.test(r),l=/^(?:head|last)$/.test(r),c=u[l?"take"+(r=="last"?"Right":""):r],m=l||/^find/.test(r);!c||(u.prototype[r]=function(){var f=this.__wrapped__,g=l?[1]:arguments,w=f instanceof H,_=g[0],R=w||L(f),F=function(k){var $=c.apply(u,Dt([k],g));return l&&T?$[0]:$};R&&a&&typeof _=="function"&&_.length!=1&&(w=R=!1);var T=this.__chain__,C=!!this.__actions__.length,x=m&&!T,U=w&&!C;if(!m&&R){f=U?f:new H(this);var O=i.apply(f,g);return O.__actions__.push({func:qn,args:[F],thisArg:s}),new Ye(O,T)}return x&&U?i.apply(this,g):(O=this.thru(F),x?l?O.value()[0]:O.value():O)})}),Ke(["pop","push","shift","sort","splice","unshift"],function(i){var r=gn[i],a=/^(?:push|sort|unshift)$/.test(i)?"tap":"thru",l=/^(?:pop|shift)$/.test(i);u.prototype[i]=function(){var c=arguments;if(l&&!this.__chain__){var m=this.value();return r.apply(L(m)?m:[],c)}return this[a](function(f){return r.apply(L(f)?f:[],c)})}}),mt(H.prototype,function(i,r){var a=u[r];if(a){var l=a.name+"";X.call(Si,l)||(Si[l]=[]),Si[l].push({name:r,func:a})}}),Si[Dn(s,pt).name]=[{name:"wrapper",func:s}],H.prototype.clone=Vh,H.prototype.reverse=qh,H.prototype.value=Wh,u.prototype.at=bM,u.prototype.chain=vM,u.prototype.commit=IM,u.prototype.next=PM,u.prototype.plant=RM,u.prototype.reverse=FM,u.prototype.toJSON=u.prototype.valueOf=u.prototype.value=SM,u.prototype.first=u.prototype.head,Rr&&(u.prototype[Rr]=_M),u},Gt=Ih();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(se._=Gt,define(function(){return Gt})):ni?((ni.exports=Gt)._=Gt,zs._=Gt):se._=Gt}).call(Di)});var vp=Kt(Xt());var Md=Kt(gd());var bp=s=>{let e=200,t=[],n=0;return t[n]=[],s.forEach(o=>{t[n].length<=e-1?t[n].push(o):(n++,t[n]=[o])}),t},aa=s=>{let e=[],t=200;for(;s.length>t;){let n=s.splice(0,t);e.push(n)}return e.push(s),e},Oe=(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"},o={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=o[e]:t=p[e],t},Yt=s=>s.filter((t,n,o)=>n===o.indexOf(t)),oa=s=>Array.isArray(s)?s.map(e=>oa(e)):s!=null&&s.constructor===Object?Object.keys(s).reduce((e,t)=>({...e,[(0,Md.camelCase)(t)]:oa(s[t])}),{}):s,de=s=>s||!1,fe=()=>`&disable_cache=${Date.now()}`,Vr=s=>s.sort((e,t)=>e.localeCompare(t));var sa=class{id=null;name=null;nickname=null;avatar=null;gender=null;country=null;birthDate=null;interests=[];followingCount=0;followersCount=0};var la=class{profilesFromResponse=e=>e?e.map(t=>this.fullProfileFromResponse(t)):null;fullProfileFromResponse=e=>{let t=new sa;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 pa=class{nextPageStartsAfter=null;itemsPerPage=null};var Ui=class{pagination=new pa};var re=class{meta=new Ui;data=[]};var ca=class{avatar=null;followingId=null;name=null;nickname=null;profileId=null};var ua=class{followResponse=e=>e.map(t=>this.remapResponse(t));followingFromResponse=e=>{let t=new re;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 ca;return t.avatar=e.avatar,t.followingId=e.following_id,t.name=e.name,t.profileId=e.profile_id,t.nickname=e.nickname,t}};var ma=class{avatar=null;followerId=null;name=null;nickname=null;profileId=null};var da=class{followersFromResponse=e=>{let t=new re;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 ma;return t.avatar=e.avatar,t.followerId=e.follower_id,t.name=e.name,t.profileId=e.profile_id,t}};var qr=class{profile_ids=[]};var CI="/countries",Be="/profile",wd="/profiles",Gi=class{instanceAuth=null;instance=null;apiSignInUrl=null;profileRemapper=null;followingRemapper=null;followersRemapper=null;lang=null;constructor(e){this.lang=e.lang;let t=Oe(e.environment,"profile");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instanceAuth=vp.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 o=n.config;if((n.response.status===403||n.response.status===401)&&!o._retry){o._retry=!0;let p=e.authProvider.getIdToken();return o.headers.Authorization=`Bearer ${p}`,this.instanceAuth(o)}return Promise.reject(n)}),this.instance=vp.default.create({baseURL:t,headers:{"Content-Type":"application/json"}}),this.profileRemapper=new la,this.followingRemapper=new ua,this.followersRemapper=new da}getCountries=async e=>{try{let t=`&lang=${this.lang}`,n=`${CI}${this.apiSignInUrl}${t}`,o=Date.now();return e&&(n+=`&disable_cache=${o}`),(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=`${Be}${this.apiSignInUrl}`;if(e){t=`${wd}/${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=`${wd}${this.apiSignInUrl}&profile_ids=${e.join(",")}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);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=`${Be}/followers${this.apiSignInUrl}`;if(e&&!t){n=`${Be}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let o=await this.instanceAuth.get(n);return this.followersRemapper.followersFromResponse(o.data)}catch(o){throw console.warn("There was a problem fetching the followers for own profile",o),o.response}}else if(!e&&!t)try{let o=await this.instanceAuth.get(n);return this.followersRemapper.followersFromResponse(o.data)}catch(o){throw console.warn("There was a problem fetching the followers for own profile",o),o.response}e&&t?n=`${Be}/${t}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(n=`${Be}/${t}/followers${this.apiSignInUrl}`);try{let o=await this.instance.get(n);return this.followersRemapper.followersFromResponse(o.data)}catch(o){throw console.warn(`There was a problem fetching the followers for profile: ${t}`,o),o.response}};getFollowing=async(e,t)=>{let n=`${Be}/following${this.apiSignInUrl}`;if(e&&!t){n=`${Be}/following${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let o=await this.instanceAuth.get(n);return this.followingRemapper.followingFromResponse(o.data)}catch(o){throw console.warn("There was a problem fetching the followers of own profile",o),o.response}}else if(!e&&!t)try{let o=await this.instanceAuth.get(n);return this.followingRemapper.followingFromResponse(o.data)}catch(o){throw console.warn("There was a problem fetching the followers of own profile",o),o.response}e&&t?n=`${Be}/${t}/following${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(n=`${Be}/${t}/following${this.apiSignInUrl}`);try{let o=await this.instance.get(n);return this.followingRemapper.followingFromResponse(o.data)}catch(o){throw console.warn(`There was a problem fetching the followers of the following profile: ${t}`,o),o.response}};follow=async e=>{let t=new qr;t.profile_ids=e;try{let n=await this.instanceAuth.post(`${Be}/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 qr;t.profile_ids=e;try{return await this.instanceAuth.delete(`${Be}/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=`${Be}/badges${this.apiSignInUrl}`;try{return e?(t=`${Be}/${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(`${Be}${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 Ot={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id"},Ip={PREDICTOR_USER_RELATED_OPERATION:"https://docs.fansunitedmedia.com/docs/predictor-operations#user-related-operations"},Pp=["matchId","matchType","market","prediction"];var bd="FansUnited",_p={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(_p)}clearData=()=>{this.setData(_p)};getEntityById=(e="",t="")=>this.getData().football.ids.find(n=>{let o=Ot[this.idSchema];return n&&`${n[o]}`===t&&n.resource===e});getEntity=(e,t,n)=>Array.isArray(e)?this.getData().football.ids.filter(o=>{let p=Ot[n];return o&&e.includes(`${o[p]}`)&&o.resource===t}):this.getData().football.ids.find(o=>{let p=Ot[n];return o&&`${o[p]}`===e&&o.resource===t});getEntityByNativeId=(e="",t="")=>this.getData().football.ids.find(n=>n&&`${n.id}`===t&&n.resource===e);checkForExistingIdObjs=(e,t)=>{let n=Ot[t],o={};return Object.keys(e).forEach(p=>{let d=e[p],y=this.getEntity(d,p,t).map(b=>b[n]),P=e[p].filter(b=>!y.includes(b));o[p]=d.map(b=>P.includes(b)?{id:b,exists:!1}:{id:b,exists:!0})}),o};getIdsByType=(e,t,n)=>{let o=Ot[n],p=Ot[t],d={};return Object.keys(e).forEach(h=>{let y=e[h],P=[];this.getData().football.ids.forEach(b=>{y.forEach((S,q)=>{S===b[p]&&h===b.resource&&(P[q]=b[o])})}),d[h]=P}),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 o=!t.has(n.id);return t.add(n.id),o})};getData=()=>JSON.parse(localStorage.getItem(bd));setData=e=>{localStorage.setItem(bd,JSON.stringify(e))};initialNewSchema=e=>{this.getData().profile[e]||this.setData(_p)}};var vd=Kt(Xt());var Wr={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},fa=class{instance=null;apiSignInUrl="";constructor(e){let t=Oe(e.environment,"idMapping");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instance=vd.default.create({baseURL:t})}getEntityById=(e,t)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${config.idSchema}&${Wr[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}&${Wr[e]}=${t}`)}catch(o){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,o),o.response}};getEntityIdsByIdsAndSchema=(e,t,n)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${Wr[e]}=${t.join(",")}`)}catch(o){throw console.warn(`There was a problem with id mapping request for the following ids:${t.join(",")}`,o),o.response}};getEntitiesByIds=(e,t,n)=>{t.sort((d,h)=>d.localeCompare(h));let p=bp(t).map(d=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${Wr[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(y=>{h.push(...y.data.data)}),h})};getEntitiesByIdObjs=async(e,t)=>{let n=[],o={},p=[];Object.keys(e).forEach(P=>{n.push.apply(n,e[P])});let d=Yt(n),h=bp(d);for(let P of h){let b="";if(Object.keys(e).forEach(S=>{o[S]=[];let q=P.filter(Re=>e[S].includes(Re));q&&q.length>0&&(o[S]=q)}),Object.keys(o).forEach(S=>{o[S].length>0&&(o[S].sort((q,Re)=>q.localeCompare(Re)),b+="&",b+=`${Wr[S]}=${o[S].join(",")}`)}),b&&b.length>0)try{let S=await this.instance.get(`/football${this.apiSignInUrl}&input_provider=${t||"native"}${b}`);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 ha=class{isBrowser=!1;localStorage=null;https=null;constructor(e){this.isBrowser=typeof window!="undefined",this.localStorage=new gt(e),this.https=new fa(e)}getEntitiesByIds=async(e,t,n)=>{if(this.isBrowser)try{let o=this.localStorage.checkForExistingIdObjs(e,t),p=this.splitForRequestAndExisting(o),d=await this.https.getEntitiesByIdObjs(p.request,t);return this.localStorage.addIdMappings(d),this.localStorage.getIdsByType(e,t,n)}catch(o){return console.warn("There was a problem retrieving the entity ids ",o),Promise.resolve([])}else try{let o=await this.https.getEntitiesByIdObjs(e,t);return Object.keys(e).forEach(p=>{e[p]=o.filter(d=>d.resource===p).map(d=>d[Ot[n]])}),e}catch(o){return console.warn("There was a problem retrieving the entity ids ",o),Promise.resolve([])}};getEntityById=async(e,t,n)=>{if(this.isBrowser){let o=this.localStorage.getEntity(e,t,n);if(o)return o;{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(o=>{t[o]=e[o].filter(p=>!p.exists).map(p=>p.id),n[o]=e[o].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(o){return console.warn(`There was a problem retrieving the requested entity: ${o}`),null}}};var ga=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 ya=class{extractedObjIds={};traverse=(e,t)=>(t=ga(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 o=e[n];n==="id"||n==="teamId"?(this.extractedObjIds.hasOwnProperty(t)||(this.extractedObjIds[t]=[]),o&&this.extractedObjIds[t].push(o)):e[n]&&this.traverse(e[n],n)})}};var Ma=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(e,t,n)=>(t=ga(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 pe=class{idSchema="";idMappingFacade=null;constructor(e){this.idSchema=e.idSchema,this.idMappingFacade=new ha(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 ya().traverse(n,t);return this.idMappingFacade.getEntitiesByIds(p,"native",this.idSchema).then(d=>new Ma().traverse(n,t,d))}else return e}catch(o){return console.warn(`There was a problem remapping entity: ${t} with inner entity `,o),[]}};getEntityIdsBySchemaId=async(e,t,n)=>{let o={};return o[t]=e,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(o,this.idSchema,n):o}};var Ve=class{completed=!1;percentage;constructor(e){this.percentage=e}};var wa=class{teamFollowed=new Ve(10);teamFavourite=new Ve(15);playerFollowed=new Ve(10);playerFavourite=new Ve(10);competitionFollowed=new Ve(10);competitionFavourite=new Ve(5);addedBirthdate=new Ve(10);addedGender=new Ve(10);addedCountry=new Ve(10);addedAvatar=new Ve(10)};var ba=class{totalPercentage;breakdown=new wa};var Kr=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{e&&(e=new Kr(e));let n=await this.profileHttps.getFollowers(e,t),o=n.data.map(p=>p.followerId);if(o.length){let p=await this.getByIds(o),d=n.data.map(h=>(p.forEach(y=>{h.followerId===y.id&&(h.name=y.name,h.nickname=y.nickname,h.avatar=y.avatar)}),h));return n.data=d,n}return n}catch(n){throw console.warn("There was a problem retrieving your followers: ",n),n}};getFollowing=async(e,t)=>{try{e&&(e=new Kr(e));let n=await this.profileHttps.getFollowing(e,t),o=n.data.map(p=>p.followingId);if(o.length){let p=await this.getByIds(o),d=n.data.map(h=>(p.forEach(y=>{h.followingId===y.id&&(h.name=y.name,h.nickname=y.nickname,h.avatar=y.avatar)}),h));return n.data=d,n}return n}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 ba,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(b=>b.type==="team"&&b.favourite)&&(t.breakdown.teamFavourite.completed=!0,n+=t.breakdown.teamFavourite.percentage),e.interests.find(b=>b.type==="team")&&(t.breakdown.teamFollowed.completed=!0,n+=t.breakdown.teamFollowed.percentage),e.interests.find(b=>b.type==="player"&&b.favourite)&&(t.breakdown.playerFavourite.completed=!0,n+=t.breakdown.playerFavourite.percentage),e.interests.find(b=>b.type==="player")&&(t.breakdown.playerFollowed.completed=!0,n+=t.breakdown.playerFollowed.percentage),e.interests.find(b=>b.type==="competition"&&b.favourite)&&(t.breakdown.competitionFavourite.completed=!0,n+=t.breakdown.competitionFavourite.percentage),e.interests.find(b=>b.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 va=class{id=null;name=null;assets=null};var Ia=class{extractUpdatedProps=(e,t)=>{let n=["name","nickname","gender"],o={};return Object.keys(e).forEach(p=>{if(n.includes(p)&&e[p]!==t[p])o[p]=t[p];else if(p==="birthDate")(t[p]===null||e[p]===null&&t[p]||e[p]!==t[p])&&(o.birth_date=t[p]);else if(p==="country")t[p]===null?o.country_id=t[p]:(e[p]===null&&t[p]||e[p].id!==t[p].id)&&(o.country_id=t[p].id);else if(p==="interests"){let d=e[p],h=t[p];h.length&&this.isNewInterest(d,h)?o[p]=this.updateInterests(d,h):(!h.length&&d.length||d.length!==h.length&&!this.isNewInterest(d,h))&&(o[p]=h)}}),o};updateInterests=(e,t)=>{if(e.length===t.length){let[n,o]=this.extractSameAndNewInterests(e,t);return[...o,...n]}else return t};isNewInterest=(e,t)=>{let n=!1,[o]=this.extractSameAndNewInterests(e,t);return o.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 Pa=class{idsRemapper=null;profileHttps=null;profileService=null;localStorage=null;profileFacade=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;constructor(e,t,n,o,p,d){this.idsRemapper=e,this.localStorage=t,this.profileHttps=n,this.profileService=new Ia,this.profileFacade=new yt(t,n,o)}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.remapInterests(t.interests)};showFullInterests=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.showFullInterests(t.interests)};getFollowers=async e=>await this.profileFacade.getFollowers(e);getFollowing=async e=>await this.profileFacade.getFollowing(e);follow=async e=>{let t=await this.profileFacade.follow(e),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(o=>o.id!==t.id||o.type!==t.type||o.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 va,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),d=JSON.parse(JSON.stringify(p));return this.setOwnProfile(d),this.localStorage.setOwnProfile(d),delete p.interests,p}let o=JSON.parse(JSON.stringify(this.ownProfile));return delete o.interests,o}};var _a=class{idsRemapper=null;profileHttps=null;activityHttps=null;profileFacade=null;profileId="";constructor(e,t,n,o){this.idsRemapper=e,this.profileHttps=n,this.activityHttps=o,this.profileFacade=new yt(t,n,o)}setId=e=>(this.profileId=e,this);getProfile=async()=>await this.profileFacade.getById(this.profileId);getInfo=async()=>{let e=await this.getProfile();return delete e.interests,e};showInterests=async()=>{let e=await this.getProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.remapInterests(t.interests)};showFullInterests=async()=>{let e=await this.getProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.showFullInterests(t.interests)};getFollowers=async e=>await this.profileFacade.getFollowers(e,this.profileId);getFollowing=async e=>await this.profileFacade.getFollowing(e,this.profileId);showFullnessProfile=async()=>{let e=await this.getProfile();return this.profileFacade.showFullnessProfile(e)};getStats=async e=>{let t=await this.activityHttps.getStats(this.profileId,e);return await this.idsRemapper.remapSuccessRatesEntities(t)};getBadges=async()=>await this.profileHttps.getBadges(this.profileId)};var Ra=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 Xr=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 o=!0;return t.forEach(p=>{p!=="sortOrder"&&p!=="sortField"&&(p==="countryId"?o&&=n.country.id===this[p]:p==="name"?o&&=n.name.toLocaleLowerCase().includes(this[p].toLocaleLowerCase()):p==="competitionIds"?o&&=this[p].some(d=>n.id===d):o&&=n[p].toLocaleLowerCase()===this[p].toLocaleLowerCase())}),o})};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,o)=>this.sortOrder&&this.sortOrder==="desc"?o.name.localeCompare(n.name):n.name.localeCompare(o.name)):this.sortField==="country"?t=e.sort((n,o)=>this.sortOrder&&this.sortOrder==="desc"?o.country.name.localeCompare(n.country.name):n.country.name.localeCompare(o.country.name)):this.sortField==="scope"?e.forEach(n=>t[this.competitionIds.indexOf(n.id)]=n):!this.sortField&&this.sortOrder==="desc"&&(t=e.sort((n,o)=>o.id.localeCompare(n.id))),t}};var Fa=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 Xr(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 o=await this.getCompetitions(e,t);return await this.idMapping.remapEntities(o,"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 Xr({competitionIds:e}),o=await this.getCompetitions(n);o.sort((d,h)=>d.id.localeCompare(h.id));let p=await this.idMapping.remapEntities(o,"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(o){throw console.warn("There was a problem retrieving all competitions",o),o}this.localStorage.setCompetitions(n)}return this.localStorage.getCompetitions(e)}else return this.https.getCompetitions(e,t)};getCompetitionByIdIdMapping=async(e,t)=>{try{let o=(await this.idMapping.getEntityIdsBySchemaId([e],"competition","native")).competition[0],p=await this.getCompetitionById(o,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 Yr=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 Id=Kt(Xt());var Sa=class{general=[];predictor=[];topX=[];matchQuiz=[]};var ki=class{points=null;gameParticipationCount=null;predictionsMade=null;correctPredictions=null};var Ta=class{id;enabled;requirements=new ki};var Ea=class{id;weight;multiplier;conditions};var Ca=class{value=[new Ea]};var Hi=class{points=null;tiers=null;badges=null};var Aa=class{enabled=!1;conditions={list:null};actions=new Ca;rewards=new Hi};var xa=class{general=null;comments=null;predictor=null;activity=null;topX=null;matchQuiz=null};var $i=class{enabled=!1;defaultMarkets=null;competitionsWhitelist=null};var Vi=class{enabled=!1;minFixtures=null;maxFixtures=null;competitionsWhitelist=null};var Oa=class{competitions=[];teams=[];markets=[]};var qi=class{enabled=!1;fullCoverageCompetitions=null;markets=null;successRateScopes=new Oa};var Ba=class{remapPredictorConfig=e=>{let t=new qi;return t.enabled=e.enabled,t.fullCoverageCompetitions=e.full_coverage_competitions,t.markets=e.markets,t.successRateScopes=e.success_rate_scopes,t};remapTopXConfig=e=>{let t=new Vi;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 $i;return t.enabled=e.enabled,t.defaultMarkets=e.default_markets,t.competitionsWhitelist=e.competitions_whitelist,t};remapLoyaltyConfig=e=>{let t=new Aa;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 Hi;return t.points=this.remapPoints(e.points),t.tiers=e.tiers,t.badges=this.remapBadges(e.badges),t};remapPoints=e=>{let t=new xa;return t.general=e.general,t.comments=e.comments,t.predictor=e.predictor,t.activity=e.activity,t.topX=e.top_x,t.matchQuiz=e.match_quiz,t};remapBadges=e=>{let t=new Sa;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 Ta;return n.id=t.id,n.enabled=t.enabled,n.requirements=this.remapRequirements(t.requirements),n});remapRequirements=e=>{let t=new ki;return t.points=e.points,t.gameParticipationCount=e.game_participation_count,t.predictionsMade=e.predictions_made,t.correctPredictions=e.correct_predictions,t}};var Ze=class{instance=null;apiSignInUrl="";featureConfigRemapper=null;constructor(e){let t=Oe(e.environment,"client");this.apiSignInUrl=`/clients/${e.clientId}/features?key=${e.apiKey}`,this.instance=Id.default.create({baseURL:t,headers:{"Content-Type":"application/json"}}),this.featureConfigRemapper=new Ba}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 zt=class{clientHttps=null;constructor(e){this.clientHttps=new Ze(e)}setAvailableMarketsForMatch=async e=>{let{fullCoverageCompetitions:t,markets:n}=await this.clientHttps.getConfig("predictor");if(Array.isArray(e))return e.map(o=>this.setAvailableMarkets(o,t,n));if(typeof e=="object"&&Object.keys(e).length)return this.setAvailableMarkets(e,t,n)};setAvailableMarkets=(e,t,n)=>{let o=e.context.competition?.id;return o&&this.isMatchInCoverageCompetition(o,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 Na=class{footballService=null;https=null;idMapping=null;constructor(e,t,n){this.idMapping=n,this.https=t,this.footballService=new zt(e)}getTeamsIdMapping=async(e,t)=>{try{let n=!1;if(e){if(e=new Yr(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 o=await this.getTeams(e,t);return o.data=await this.idMapping.remapEntities(o.data,"team"),o}catch(n){throw console.warn("There was a problem browsing all teams",n),n}};getTeamsMapWithNativeIds=async e=>{let t=new Map,n=new Yr({teamIds:e}),{data:o}=await this.getTeams(n);o.sort((d,h)=>d.id.localeCompare(h.id));let p=await this.idMapping.remapEntities(o,"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 o=await this.getTeamById(e,t);return await this.idMapping.remapEntities(o,"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 o=await this.getNextMatchForTeam(e,t);return await this.idMapping.remapEntities(o,"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 o=await this.getPrevMatchForTeam(e,t);return await this.idMapping.remapEntities(o,"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 zr=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 Qt=class{https=null;footballService=null;idMapping=null;constructor(e,t,n){this.idMapping=n,this.https=t,this.footballService=new zt(e)}getPlayersIdMapping=async(e,t)=>{try{let n=!1;if(e){if(e=new zr(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 o=await this.getPlayers(e,t);return o.data=await this.idMapping.remapEntities(o.data,"player"),o}catch(n){throw console.warn("There was a problem browsing the players",n),n}};getPlayersWithNativeIds=async e=>{let t=new zr({playerIds:e}),n=await this.getPlayers(t);return n.data.sort((o,p)=>o.id.localeCompare(p.id)),await this.idMapping.remapEntities(n.data,"player")};getPlayersMapWithNativeIds=async e=>{let t={},n=Yt(e);n.sort((p,d)=>p.localeCompare(d));let o=await this.getPlayersWithNativeIds(n);return n.forEach((p,d)=>t[p]=o[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"),o=await this.getPlayerById(n.player[0],t);return await this.idMapping.remapEntities(o,"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 o=await this.getNextMatchForPlayer(e,t);return await this.idMapping.remapEntities(o,"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 o=await this.getPrevMatchForPlayer(e,t);return await this.idMapping.remapEntities(o,"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 Qr=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 Jt=class{https=null;idMapping=null;footballService=null;constructor(e,t,n){this.https=t,this.idMapping=n,this.footballService=new zt(e)}getMatchesIdMapping=async(e,t)=>{try{if(e){if(e=new Qr(e),e.countryIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.countryIds,"country","native");e.countryIds=o.country}if(e.competitionIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");e.competitionIds=o.competition}if(e.matchIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.matchIds,"match","native");e.matchIds=o.match}if(e.teamIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");e.teamIds=o.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 Qr({matchIds:e,limit:t}),o=await this.getMatches(n);return o.data.sort((p,d)=>p.id.localeCompare(d.id)),await this.idMapping.remapEntities(o.data,"match")};getMatchesMapWithNativeIds=async e=>{let t={},n=Yt(e);n.sort((p,d)=>p.localeCompare(d));let o=await this.getMatchesWithNativeIds(n);return n.forEach((p,d)=>t[p]=o[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"),o=await this.getMatchById(n.match[0],t),p=await this.footballService.setAvailableMarketsForMatch(o);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 Da=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 Ua=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}searchIdMapping=async(e,t)=>{try{if(e=new Da(e),e.scope){let o=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");e.scope=o.competition}let n=await this.search(e,t);if(n.teams&&n.teams.length>0){let o=await this.idMapping.remapEntities(n.teams,"team");n.teams=o}if(n.players&&n.players.length>0){let o=await this.idMapping.remapEntities(n.players,"player");n.players=o}if(n.competitions&&n.competitions.length>0){let o=await this.idMapping.remapEntities(n.competitions,"competition");n.competitions=o}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 Wi=class{countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(e,t,n,o){this.countriesFacade=new Ra(t,n,o),this.competitionsFacade=new Fa(t,n,o),this.teamsFacade=new Na(e,n,o),this.playerFacade=new Qt(e,n,o),this.matchFacade=new Jt(e,n,o),this.searchFacade=new Ua(n,o)}getCountries=async e=>this.countriesFacade.getCountriesWithIdMapping(e);getCompetitions=async(e,t)=>this.competitionsFacade.getCompetitionsIdMapping(e,t);getCompetitionById=async(e,t)=>this.competitionsFacade.getCompetitionByIdIdMapping(e,t);getTopCompetitions=async e=>this.competitionsFacade.getTopCompetitionsIdMapping(e);getCompetitionsMapWithNativeIds=async e=>await this.competitionsFacade.getCompetitionsMapWithNativeIds(e);getTeams=async(e,t)=>this.teamsFacade.getTeamsIdMapping(e,t);getTeamById=async(e,t)=>this.teamsFacade.getTeamByIdIdMapping(e,t);getTopTeams=async e=>this.teamsFacade.getTopTeamsIdMapping(e);getNextMatchForTeam=async(e,t)=>this.teamsFacade.getNextMatchForTeamIdMapping(e,t);getPrevMatchForTeam=async(e,t)=>this.teamsFacade.getPrevMatchForTeamIdMapping(e,t);getTeamsMapWithNativeIds=async e=>await this.teamsFacade.getTeamsMapWithNativeIds(e);getPlayers=async(e,t)=>this.playerFacade.getPlayersIdMapping(e,t);getPlayerById=async(e,t)=>this.playerFacade.getPlayerIdMapping(e,t);getTopPlayers=async e=>this.playerFacade.getTopPlayersIdMapping(e);getNextMatchForPlayer=async(e,t)=>this.playerFacade.getNextMatchForPlayerIdMapping(e,t);getPrevMatchForPlayer=async(e,t)=>this.playerFacade.getPrevMatchForPlayerIdMapping(e,t);getPlayersMapWithNativeIds=async e=>this.playerFacade.getPlayersMapWithNativeIds(e);getMatches=async(e,t)=>this.matchFacade.getMatchesIdMapping(e,t);getMatchById=async(e,t)=>this.matchFacade.getMatchIdMapping(e,t);search=async(e,t)=>this.searchFacade.searchIdMapping(e,t)};var Pd=Kt(Xt());var Ga=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 Ga;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 ka=class{id="";country=null;gender="";assets=null;type="";name=""};var Le=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let t=new ka;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 Ha=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var $a=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 $a;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 Va=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new ne,this.teamBasicRemapper=new Me}fromResponse(e){try{let t=new Ha;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 qa=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";squad=[]};var Wa=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var Ka=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let t=new Wa;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 Xa=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new ne,this.competitionRemapper=new Le,this.playerRemapper=new Ka}fromResponse(e){try{let t=new qa;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 Ya=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 za=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var Ki=class{fromResponse(e){try{let t=new za;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 Qa=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new Me,this.competitionRemapper=new Le,this.scoresRemapper=new Ki}fromResponse(e){try{let t=new Ya;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 Ja=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 ja=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 Za=class{fromResponse(e){try{let t=new ja;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 Xi=class{homeTeam={players:[]};awayTeam={players:[]}};var eo=class{id="";name="";position="";shirtNumber;assets=null;type=""};var Yi=class{fromResponse(e){try{let t=new eo;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 to=class{playerRemapper=null;constructor(){this.playerRemapper=new Yi}fromResponse(e){try{let t=new Xi;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 io=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var ro=class{playerRemapper=null;constructor(){this.playerRemapper=new Yi}fromResponse(e){try{let t=new io;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 no=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new Me,this.competitionsMapper=new Le,this.lineupsMapper=new to,this.scoresMapper=new Ki,this.statsMapper=new Za,this.timelineMapper=new ro}fromResponse(e){try{let t=new Ja;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 Xi,t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var ao=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var oo=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let t=new ao;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 so=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;teams=[]};var zi=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new ne,this.teamRemapper=new Me}fromResponse(e){try{let t=new so;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 lo=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;competitions=[];teams=[]};var po=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new ne,this.teamRemapper=new Me,this.competitionRemapper=new Le}fromResponse(e){try{let t=new lo;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 co=class{teams=null;players=null;competitions=null};var uo=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new Me,this.playerRemapper=new zi,this.competitionremapper=new Le}fromResponse(e){try{let t=new co;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 Qi=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var jt=class{pagination=new Qi};var Ji=class{meta=new jt;data=[]};var mo=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=Oe(e.environment,"football");this.apiSignInUrl=`?key=${e.apiKey}&lang=${e.lang}`,this.instance=Pd.default.create({baseURL:t}),this.countryRemapper=new ne,this.competitionBasicRemapper=new Le,this.competitionFullRemapper=new Va,this.teamBasicRemapper=new Me,this.teamFullRemapper=new Xa,this.matchBasicRemapper=new Qa,this.matchFullRemapper=new no,this.playerBasicRemapper=new zi,this.playerFullRemapper=new po,this.topPlayerRemapper=new oo,this.searchRemapper=new uo,this.footballMetaRemapper=new mo}getCountries=async e=>{try{let t=`/countries${this.apiSignInUrl}`,n=Date.now();e&&(t+=`&disable_cache=${n}`);let o=await this.instance.get(t);return this.countryRemapper.countriesFromResponse(o.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={},o=Date.now();if(t=t||!1,e&&e.competitionIds&&e.competitionIds.length>this.limitIds-1){let p=[],d=aa(e.competitionIds);for(let y of d){e.competitionIds=y;let P=`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(P+=`&disable_cache=${o}`),n=await this.instance.get(P),p.push(n.data.data.map(b=>this.competitionBasicRemapper.fromResponse(b)))}return Array.prototype.concat.apply([],p)}else{let p=`/competitions${this.apiSignInUrl}`;return e&&(p+=`${e.constructFilterUrl()}`),t&&(p+=`&disable_cache=${o}`),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}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);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={},o=Date.now();if(e&&e.teamIds&&e.teamIds.length>this.limitIds){let p=[],d=aa(e.teamIds);for(let y of d){e.teamIds=y;let P=`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(P+=`disable_cache=${o}`),n=await this.instance.get(P),p.push(n.data.data.map(b=>this.teamBasicRemapper.fromResponse(b)))}return Array.prototype.concat.apply([],p)}else{let p=new Ji,d=`/teams${this.apiSignInUrl}`;return e&&(d+=`${e.constructFilterUrl()}`),t&&(d+=`&disable_cache=${o}`),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}`,o=Date.now();t&&(n+=`disable_cache=${o}`);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 o=await this.instance.get(t);return o.data.data?o.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}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);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}`,o=Date.now();t&&(n+=`disable_cache=${o}`);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={},o=Date.now();if(e&&e.playerIds&&e.playerIds.length>this.limitIds-1){let p=[],d=aa(e.playerIds);for(let y of d){e.playerIds=y;let P=`/players${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(P+=`&disable_cache=${o}`),n=await this.instance.get(P),p.push(n.data.data.map(b=>this.teamBasicRemapper.fromResponse(b)))}return Array.prototype.concat.apply([],p)}else{let p=new Ji,d=`/players${this.apiSignInUrl}`;return e&&(d+=`${e.constructFilterUrl()}`),t&&(d+=`&disable_cache=${o}`),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}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);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}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);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}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);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}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);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 Ji,o=`/matches${this.apiSignInUrl}`,p=Date.now();e&&(o+=`${e.constructFilterUrl()}`),t&&(o+=`&disable_cache=${p}`);let d=await this.instance.get(o);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()}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);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 Rp=Kt(Xt());var Pe=(N=>(N.FT_1X2="FT_1X2",N.HT_1X2="HT_1X2",N.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",N.DOUBLE_CHANCE="DOUBLE_CHANCE",N.HT_FT="HT_FT",N.PLAYER_SCORE="PLAYER_SCORE",N.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",N.PLAYER_RED_CARD="PLAYER_RED_CARD",N.RED_CARD_MATCH="RED_CARD_MATCH",N.PENALTY_MATCH="PENALTY_MATCH",N.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",N.CORNERS_MATCH="CORNERS_MATCH",N.CORRECT_SCORE="CORRECT_SCORE",N.CORRECT_SCORE_ADVANCED="CORRECT_SCORE_ADVANCED",N.CORRECT_SCORE_HT="CORRECT_SCORE_HT",N.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",N.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",N.OVER_GOALS_0_5="OVER_GOALS_0_5",N.OVER_GOALS_1_5="OVER_GOALS_1_5",N.OVER_GOALS_2_5="OVER_GOALS_2_5",N.OVER_GOALS_3_5="OVER_GOALS_3_5",N.OVER_GOALS_4_5="OVER_GOALS_4_5",N.OVER_GOALS_5_5="OVER_GOALS_5_5",N.OVER_GOALS_6_5="OVER_GOALS_6_5",N.OVER_CORNERS_6_5="OVER_CORNERS_6_5",N.OVER_CORNERS_7_5="OVER_CORNERS_7_5",N.OVER_CORNERS_8_5="OVER_CORNERS_8_5",N.OVER_CORNERS_9_5="OVER_CORNERS_9_5",N.OVER_CORNERS_10_5="OVER_CORNERS_10_5",N.OVER_CORNERS_11_5="OVER_CORNERS_11_5",N.OVER_CORNERS_12_5="OVER_CORNERS_12_5",N.OVER_CORNERS_13_5="OVER_CORNERS_13_5",N))(Pe||{}),_d=["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"],Rd=["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"],wt=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"],Fd=["FT_1X2","HT_1X2","HT_FT","DOUBLE_CHANCE","CORNERS_MATCH","CORRECT_SCORE"],Jr="PLAYER_SCORE_FIRST_GOAL";var fo=class{overallPercent;byFootballCompetition;byFootballTeam;byFootballMarket};var ho=class{profileId;tier;points;successRates=new fo};var go=class{successRatePercent;model=null};var yo=class{id=null;label=null};var Mo=class{type=null;id=null;label=null};var ji=class{content=new Mo;tags=[];campaign=new yo};var Zi=class{id=null;profileId=null;action=null;context=new ji;points=0};var wo=class{totalItems=0};var bo=class{meta=new wo;data=[new Zi]};var vo=class{remapSingleResponse=e=>{let t=new Zi;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 bo;return t.meta.totalItems=e.meta.total_items,t.data=e.data.map(n=>this.remapSingleResponse(n)),t};remapStatsReponse=e=>{let t=new ho;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,o])=>{t={...t,[n]:this.remapSuccessRatePercent(o)},Pe[n]&&delete t[n].model});else return e;return t};remapSuccessRatePercent=e=>{let t=new go;return t.successRatePercent=e.success_rate_percent,t}};var er=class{instanceAuth=null;instance=null;activityRemapper=null;apiSignInUrl=null;constructor(e){let t=Oe(e.environment,"loyalty");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instanceAuth=Rp.default.create({baseURL:t,headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.authProvider.getIdToken()}`}}),this.instance=Rp.default.create({baseURL:t,headers:{"Content-Type":"application/json"}}),this.activityRemapper=new vo}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}`,o=Date.now();e&&(n+=`${e.constructFilterUrl()}`),t&&(n+=`disable_cache=${o}`);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 o=`/users/${e}/activities${this.apiSignInUrl}`,p=Date.now();t&&(o+=`${t.constructFilterUrl()}`),n&&(o+=`disable_cache=${p}`);let d=await this.instance.get(o);return this.activityRemapper.remapActivitiesResponse(d.data)}catch(o){throw console.warn(`There was a problem with fetching activities for user ${e}`,o),o}};getStats=async(e,t)=>{try{let n="",o=null;return e?(n+=de(t)?`/users/${e}/statistics${this.apiSignInUrl}${fe()}`:`/users/${e}/statistics${this.apiSignInUrl}`,o=await this.instance.get(n)):(n+=`/statistics${this.apiSignInUrl}`,o=await this.instanceAuth.get(n)),this.activityRemapper.remapStatsReponse(o.data.data)}catch(n){throw console.warn("There was a problem fetching profile`s statistics:",n),n.response}}};var Io=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 o=e.successRates.byFootballCompetition,p=e.successRates.byFootballTeam;return e.successRates.byFootballCompetition=await this.setModels(o,n.competition,"competition"),e.successRates.byFootballTeam=await this.setModels(p,n.team,"team"),e}return e};setModels=async(e,t,n)=>{let o=null,p;switch(t=Vr(t),n){case"competition":o=await this.footballFacade.getCompetitionsMapWithNativeIds(t);break;case"team":o=await this.footballFacade.getTeamsMapWithNativeIds(t);break}return Object.keys(e).forEach(d=>{let h=o.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 o=await this.remapIdsObj(t,this.native,this.idSchema),p=[];for(let[d,h]of Object.entries(n))h.forEach((y,P)=>{y.id=o[d][P],p.push(y)});return p}else return e;return e};remapInterestToNative=async e=>{if(this.idSchema!==this.native){let t={},{id:n,type:o}=e;t[o]=[n];let p=await this.remapIdsObj(t,this.idSchema,this.native);return e.id=p[o][0],e}return e};inquiryCustomInterests=e=>{let t=[];return e&&e.length>0&&(t=e.filter(n=>n.source.toLocaleUpperCase()==="CUSTOM")),t};remapInterests=async e=>{let t=this.inquiryCustomInterests(e);if(t&&t.length>0){let n=e.filter(p=>p.source.toLocaleUpperCase()!=="CUSTOM"),o=await this.remapInterestsToIdSchema(n);return t.forEach(p=>o.push(p)),o}return await this.remapInterestsToIdSchema(e)};showFullInterests=async e=>{let t=[];if(e&&e.length>0){let n=this.inquiryCustomInterests(e);t.push(n);let o=e.filter(P=>P.source.toLocaleUpperCase()!=="CUSTOM"),{competitionsMap:p,teamsMap:d,playersMap:h}=await this.getInterestsEntitiesMap(o),y=o.map(P=>{let b=null;if(P.type==="competition")return b=p.get(P.id),b&&(P.id=b.id),P.model=b,P;if(P.type==="team")return b=d.get(P.id),b&&(P.id=b.id),P.model=b,P;if(P.type==="player")return h?(P.model=h[P.id],P.id=h[P.id].id):P.model=b,P});return t.push(y),t.flat()}return t};getInterestsEntitiesMap=async e=>{let t=[],n=[],o=[],p=new Map,d=new Map,h=null;if(e.forEach(y=>{y.type==="competition"?t.push(y.id):y.type==="team"?n.push(y.id):y.type==="player"&&o.push(y.id)}),t.length){let y=Vr(t);p=await this.footballFacade.getCompetitionsMapWithNativeIds(y)}if(n.length){let y=Vr(n);d=await this.footballFacade.getTeamsMapWithNativeIds(y)}if(o.length){let y=Vr(o);h=await this.footballFacade.getPlayersMapWithNativeIds(y)}return{competitionsMap:p,teamsMap:d,playersMap:h}};remapIdsObj=async(e,t,n)=>await this.idMapping.idMappingFacade.getEntitiesByIds(e,t,n)};var Po=class{idMapping=null;profileOperations=null;constructor(e,t){this.idMapping=new pe(e),this.profileOperations=new Io(e,t,this.idMapping)}remapSuccessRatesEntities=async e=>await this.profileOperations.remapSuccessRatesEntities(e);remapInterestToNative=async e=>await this.profileOperations.remapInterestToNative(e);remapInterests=async e=>await this.profileOperations.remapInterests(e);showFullInterests=async e=>await this.profileOperations.showFullInterests(e)};var tr=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 Gi(e),this.activityHttps=new er(e),this.footballHttps=new Mt(e),this.idMapping=new pe(e),this.localStorage=new gt(e),this.footballFacade=new Wi(e,this.localStorage,this.footballHttps,this.idMapping),this.profileFacade=new yt(this.localStorage,this.profileHttps,this.activityHttps),this.idsRemapper=new Po(e,this.footballFacade),this.ownProfileBuilder=new Pa(this.idsRemapper,this.localStorage,this.profileHttps,this.activityHttps,this.idMapping,this.footballFacade),this.profileBuilder=new _a(this.idsRemapper,this.localStorage,this.profileHttps,this.activityHttps)}getOwn=()=>this.ownProfileBuilder;getById=e=>this.profileBuilder.setId(e);getCountries=async e=>await this.profileFacade.getCountries(e);getByIds=async(e,t)=>await this.profileFacade.getByIds(e,t)};var _o=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 Ro=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 Fo=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 So=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 hi=class{getIdToken=null;logout=null};var rr=class{text=null;type=null};var To=class{validation=null;message=new rr;getIdToken={validation:null,message:new rr};logout={validation:null,message:new rr}};var Eo=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 hi),n=new To;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 hi).forEach(o=>{e[o]?t[o].validation="valid":t[o].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 Zr=class{validation;message};var Co=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;authProvider={getIdToken:new Zr,logout:new Zr};isValid=!1};var Ao=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 xo=class{validate=e=>{let t=this.checkFieldsForValues(e);return t.isValid=this.containsErrorMessage(t),t};checkFieldsForValues=e=>{let t=new Co,n={apiKey:new Fo,environment:new Ro,idSchema:new So,clientId:new Ao,lang:new _o,authProvider:new Eo};for(let[o,p]of Object.entries(t))o!=="isValid"&&(p=n[o].validate(e));return Object.keys(n).forEach(o=>{t[o]=n[o].validate(e)}),t};containsErrorMessage=e=>{let t=!0;for(let[n,o]of Object.entries(e))if(n!=="authProvider"){if(n!=="isValid"&&o.message.type==="error")return t=!1,t;if(n!=="isValid"&&o.message.type==="warning")return t=!0,t}else if(o.message.type==="error")return t=!1,t;return t}};var Oo=class{https=null;idMapping=null;localStorage=null;footballFacade=null;constructor(e){this.https=new Mt(e),this.idMapping=new pe(e),this.localStorage=new gt(e),this.footballFacade=new Wi(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 Tp=Kt(Xt());var Bo=class{value=null;playerId=null;playerModel=null};var nr=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new Bo;result=null};var Lo=class{value=!1;playerId=null};var et=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n,o){this.matchId=e,this.market=t,this.prediction=new Lo,this.prediction.value=n,this.prediction.playerId=o}};var ar=class{settledAt=null;resettledAt=null;status=null;outcome=null;points=0};var No=class{value=null};var Zt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new No,this.prediction.value=n}};var tt=class{value=!1};var or=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new tt,this.prediction.value=n}};var sr=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new tt,this.prediction.value=n}};var Do=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 or||e instanceof sr)t.market=e.market,t.prediction=e.prediction.value;else if(e instanceof Zt){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,y)=>h.match_id.localeCompare(y.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 o=await this.matchFacade.getMatchesMapWithNativeIds(t),p=[];n.sort((h,y)=>h.localeCompare(y)),n&&n.length>0&&(p=await this.playerFacade.getPlayersMapWithNativeIds(n));let d=[];for(let h of e){let y=new nr;h.target?y.market=this.predictorService.convertMarketForResponseModel(h.market,h.target):y.market=h.market,y.matchId=o[h.match_id].id,y.matchType=h.match_type,y.matchModel=o?o[h.match_id]:null,delete y.matchModel.availableMarkets,h.goals_home!==void 0&&h.goals_away!==void 0?y.prediction.value=h.goals_home.toString()+":"+h.goals_away.toString():y.prediction.value=h.prediction,y.prediction.playerId=h.player_id?h.player_id:null,y.prediction.playerId&&(y.prediction.playerModel=p[h.player_id],y.prediction.playerId=p[h.player_id].id),y.result=this.remapResult(h.result),d.push(y)}return d};remapResult=e=>{let t=new ar;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 ei=class{goldenGoal=null};var en=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new ei;points=null;createdAt=null;updatedAt=null};var Z=class{no=0;yes=0};var lr=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new Z;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new Z;penaltyMatch=new Z;playerScoreFirstGoal={};cornersMatch={};correctScore={};correctScoreHalfTime={};correctScoreAdvanced={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new Z;overOnePointFiveGoals=new Z;overTwoPointFiveGoals=new Z;overThreePointFiveGoals=new Z;overFourPointFiveGoals=new Z;overFivePointFiveGoals=new Z;overSixPointFiveGoals=new Z;overSixPointFiveCorners=new Z;overSevenPointFiveCorners=new Z;overEightPointFiveCorners=new Z;overNinePointFiveCorners=new Z;overTenPointFiveCorners=new Z;overElevenPointFiveCorners=new Z;overTwelvePointFiveCorners=new Z;overThirteenPointFiveCorners=new Z};var bt=class{timeTiebreaker=!1};var gi=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new bt;predictionId=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;scheduleOpenAt=null;images=null};var yi=class{userId=null;points=null;results=[];tiebreaker=null};var Uo=(p=>(p.ACTIVE="ACTIVE",p.WON="WON",p.LOST="LOST",p.PARTIALLY_WON="PARTIALLY_WON",p.CANCELED="CANCELED",p))(Uo||{}),Fp=["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(Uo).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 pr=class{limit;startAfter;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null}constructMainFiltersUrl(){let e="";return this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),e}};var tn=(d=>(d.OPEN="OPEN",d.LIVE="LIVE",d.PENDING="PENDING",d.CANCELED="CANCELED",d.CLOSED="CLOSED",d.SETTLED="SETTLED",d))(tn||{});var it=class extends pr{status=null;type=null;gameIds=null;sortOrder=null;constructor(e){super(e);this.status=e.status?e.status:null,this.type=e.type?e.type:null,this.gameIds=e.gameIds?e.gameIds:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFiltersUrl=()=>{let e=super.constructMainFiltersUrl();return this.status&&Object.values(tn).includes(this.status)&&(e+="&",e+=`status=${this.status}`),this.type&&(e+="&",e+=`type=${this.type}`),this.gameIds&&this.gameIds.length>0&&(e+="&",e+=`game_ids=${this.gameIds.join(",")}`),this.sortOrder&&(e+="&",e+=`sort_order=${this.sortOrder}`),e}};var cr=class{main=null;cover=null;mobile=null};var Mi=class{id=null;title=null;description=null;type=null;status=null;scheduleOpenAt=null;predictionsCutoff=null;fixtures=[];tiebreaker=new bt;rules=null;flags=null;images=new cr;createdAt=null;updatedAt=null};var Lt=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new bt;predictionId=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;images=null;scheduleOpenAt=null};var Sp={UNEXPECTED_STATUS_PROP:`Unexpected provided property 'status'. You can NOT use this property for this method. For more information visit our documentation:
21
+ }`;var U=lm(function(){return V(m,C+"return "+F).apply(s,f)});if(U.source=F,Vl(U))throw U;return U}function Db(i){return W(i).toLowerCase()}function Ub(i){return W(i).toUpperCase()}function Gb(i,r,a){if(i=W(i),i&&(a||r===s))return yc(i);if(!i||!(r=Ue(r)))return i;var l=at(i),c=at(r),m=Mc(l,c),f=wc(l,c)+1;return qt(l,m,f).join("")}function kb(i,r,a){if(i=W(i),i&&(a||r===s))return i.slice(0,vc(i)+1);if(!i||!(r=Ue(r)))return i;var l=at(i),c=wc(l,at(r))+1;return qt(l,0,c).join("")}function Hb(i,r,a){if(i=W(i),i&&(a||r===s))return i.replace(Vs,"");if(!i||!(r=Ue(r)))return i;var l=at(i),c=Mc(l,at(r));return qt(l,c).join("")}function $b(i,r){var a=Bd,l=Ld;if(j(r)){var c="separator"in r?r.separator:c;a="length"in r?D(r.length):a,l="omission"in r?Ue(r.omission):l}i=W(i);var m=i.length;if(Pi(i)){var f=at(i);m=f.length}if(a>=m)return i;var g=a-_i(l);if(g<1)return l;var w=f?qt(f,0,g).join(""):i.slice(0,g);if(c===s)return w+l;if(f&&(g+=w.length-g),ql(c)){if(i.slice(g).search(c)){var _,R=w;for(c.global||(c=ol(c.source,W(Gp.exec(c))+"g")),c.lastIndex=0;_=c.exec(R);)var F=_.index;w=w.slice(0,F===s?g:F)}}else if(i.indexOf(Ue(c),g)!=g){var T=w.lastIndexOf(c);T>-1&&(w=w.slice(0,T))}return w+l}function Vb(i){return i=W(i),i&&Zd.test(i)?i.replace(Np,Mh):i}var qb=Ci(function(i,r,a){return i+(a?" ":"")+r.toUpperCase()}),Xl=pu("toUpperCase");function sm(i,r,a){return i=W(i),r=a?s:r,r===s?dh(i)?vh(i):nh(i):i.match(r)||[]}var lm=G(function(i,r){try{return Ne(i,s,r)}catch(a){return Vl(a)?a:new B(a)}}),Wb=Tt(function(i,r){return Ke(r,function(a){a=ft(a),Ft(i,a,Hl(i[a],i))}),i});function Kb(i){var r=i==null?0:i.length,a=A();return i=r?J(i,function(l){if(typeof l[1]!="function")throw new Xe(o);return[a(l[0]),l[1]]}):[],G(function(l){for(var c=-1;++c<r;){var m=i[c];if(Ne(m[0],this,l))return Ne(m[1],this,l)}})}function Xb(i){return Mg(ze(i,P))}function Yl(i){return function(){return i}}function Yb(i,r){return i==null||i!==i?r:i}var zb=uu(),Qb=uu(!0);function Ae(i){return i}function zl(i){return Hc(typeof i=="function"?i:ze(i,P))}function Jb(i){return Vc(ze(i,P))}function jb(i,r){return qc(i,ze(r,P))}var Zb=G(function(i,r){return function(a){return xr(a,i,r)}}),ev=G(function(i,r){return function(a){return xr(i,a,r)}});function Ql(i,r,a){var l=le(r),c=xn(r,l);a==null&&!(j(r)&&(c.length||!l.length))&&(a=r,r=i,i=this,c=xn(r,le(r)));var m=!(j(a)&&"chain"in a)||!!a.chain,f=Ct(i);return Ke(c,function(g){var w=r[g];i[g]=w,f&&(i.prototype[g]=function(){var _=this.__chain__;if(m||_){var R=i(this.__wrapped__),F=R.__actions__=Te(this.__actions__);return F.push({func:w,args:arguments,thisArg:i}),R.__chain__=_,R}return w.apply(i,Dt([this.value()],arguments))})}),i}function tv(){return se._===this&&(se._=Sh),this}function Jl(){}function iv(i){return i=D(i),G(function(r){return Wc(r,i)})}var rv=Tl(J),nv=Tl(mc),av=Tl(Zs);function pm(i){return Ll(i)?el(ft(i)):Lg(i)}function ov(i){return function(r){return i==null?s:pi(i,r)}}var sv=du(),lv=du(!0);function jl(){return[]}function Zl(){return!1}function pv(){return{}}function cv(){return""}function uv(){return!0}function mv(i,r){if(i=D(i),i<1||i>N)return[];var a=ut,l=ge(i,ut);r=A(r),i-=ut;for(var c=rl(l,r);++a<i;)r(a);return c}function dv(i){return L(i)?J(i,ft):Ge(i)?[i]:Te(Eu(W(i)))}function fv(i){var r=++Rh;return W(i)+r}var hv=Un(function(i,r){return i+r},0),gv=El("ceil"),yv=Un(function(i,r){return i/r},1),Mv=El("floor");function wv(i){return i&&i.length?An(i,Ae,fl):s}function bv(i,r){return i&&i.length?An(i,A(r,2),fl):s}function vv(i){return hc(i,Ae)}function Iv(i,r){return hc(i,A(r,2))}function Pv(i){return i&&i.length?An(i,Ae,Ml):s}function _v(i,r){return i&&i.length?An(i,A(r,2),Ml):s}var Rv=Un(function(i,r){return i*r},1),Fv=El("round"),Sv=Un(function(i,r){return i-r},0);function Tv(i){return i&&i.length?il(i,Ae):0}function Ev(i,r){return i&&i.length?il(i,A(r,2)):0}return u.after=JM,u.ary=ku,u.assign=Uw,u.assignIn=em,u.assignInWith=Jn,u.assignWith=Gw,u.at=kw,u.before=Hu,u.bind=Hl,u.bindAll=Wb,u.bindKey=$u,u.castArray=pw,u.chain=Du,u.chunk=My,u.compact=wy,u.concat=by,u.cond=Kb,u.conforms=Xb,u.constant=Yl,u.countBy=TM,u.create=Hw,u.curry=Vu,u.curryRight=qu,u.debounce=Wu,u.defaults=$w,u.defaultsDeep=Vw,u.defer=jM,u.delay=ZM,u.difference=vy,u.differenceBy=Iy,u.differenceWith=Py,u.drop=_y,u.dropRight=Ry,u.dropRightWhile=Fy,u.dropWhile=Sy,u.fill=Ty,u.filter=CM,u.flatMap=OM,u.flatMapDeep=BM,u.flatMapDepth=LM,u.flatten=Ou,u.flattenDeep=Ey,u.flattenDepth=Cy,u.flip=ew,u.flow=zb,u.flowRight=Qb,u.fromPairs=Ay,u.functions=Qw,u.functionsIn=Jw,u.groupBy=NM,u.initial=Oy,u.intersection=By,u.intersectionBy=Ly,u.intersectionWith=Ny,u.invert=Zw,u.invertBy=eb,u.invokeMap=UM,u.iteratee=zl,u.keyBy=GM,u.keys=le,u.keysIn=Ce,u.map=Wn,u.mapKeys=ib,u.mapValues=rb,u.matches=Jb,u.matchesProperty=jb,u.memoize=Xn,u.merge=nb,u.mergeWith=tm,u.method=Zb,u.methodOf=ev,u.mixin=Ql,u.negate=Yn,u.nthArg=iv,u.omit=ab,u.omitBy=ob,u.once=tw,u.orderBy=kM,u.over=rv,u.overArgs=iw,u.overEvery=nv,u.overSome=av,u.partial=$l,u.partialRight=Ku,u.partition=HM,u.pick=sb,u.pickBy=im,u.property=pm,u.propertyOf=ov,u.pull=ky,u.pullAll=Lu,u.pullAllBy=Hy,u.pullAllWith=$y,u.pullAt=Vy,u.range=sv,u.rangeRight=lv,u.rearg=rw,u.reject=qM,u.remove=qy,u.rest=nw,u.reverse=Gl,u.sampleSize=KM,u.set=pb,u.setWith=cb,u.shuffle=XM,u.slice=Wy,u.sortBy=QM,u.sortedUniq=jy,u.sortedUniqBy=Zy,u.split=Ob,u.spread=aw,u.tail=eM,u.take=tM,u.takeRight=iM,u.takeRightWhile=rM,u.takeWhile=nM,u.tap=wM,u.throttle=ow,u.thru=qn,u.toArray=Ju,u.toPairs=rm,u.toPairsIn=nm,u.toPath=dv,u.toPlainObject=Zu,u.transform=ub,u.unary=sw,u.union=aM,u.unionBy=oM,u.unionWith=sM,u.uniq=lM,u.uniqBy=pM,u.uniqWith=cM,u.unset=mb,u.unzip=kl,u.unzipWith=Nu,u.update=db,u.updateWith=fb,u.values=Oi,u.valuesIn=hb,u.without=uM,u.words=sm,u.wrap=lw,u.xor=mM,u.xorBy=dM,u.xorWith=fM,u.zip=hM,u.zipObject=gM,u.zipObjectDeep=yM,u.zipWith=MM,u.entries=rm,u.entriesIn=nm,u.extend=em,u.extendWith=Jn,Ql(u,u),u.add=hv,u.attempt=lm,u.camelCase=wb,u.capitalize=am,u.ceil=gv,u.clamp=gb,u.clone=cw,u.cloneDeep=mw,u.cloneDeepWith=dw,u.cloneWith=uw,u.conformsTo=fw,u.deburr=om,u.defaultTo=Yb,u.divide=yv,u.endsWith=bb,u.eq=st,u.escape=vb,u.escapeRegExp=Ib,u.every=EM,u.find=AM,u.findIndex=Au,u.findKey=qw,u.findLast=xM,u.findLastIndex=xu,u.findLastKey=Ww,u.floor=Mv,u.forEach=Uu,u.forEachRight=Gu,u.forIn=Kw,u.forInRight=Xw,u.forOwn=Yw,u.forOwnRight=zw,u.get=Wl,u.gt=hw,u.gte=gw,u.has=jw,u.hasIn=Kl,u.head=Bu,u.identity=Ae,u.includes=DM,u.indexOf=xy,u.inRange=yb,u.invoke=tb,u.isArguments=mi,u.isArray=L,u.isArrayBuffer=yw,u.isArrayLike=Ee,u.isArrayLikeObject=te,u.isBoolean=Mw,u.isBuffer=Wt,u.isDate=ww,u.isElement=bw,u.isEmpty=vw,u.isEqual=Iw,u.isEqualWith=Pw,u.isError=Vl,u.isFinite=_w,u.isFunction=Ct,u.isInteger=Xu,u.isLength=zn,u.isMap=Yu,u.isMatch=Rw,u.isMatchWith=Fw,u.isNaN=Sw,u.isNative=Tw,u.isNil=Cw,u.isNull=Ew,u.isNumber=zu,u.isObject=j,u.isObjectLike=ee,u.isPlainObject=Ur,u.isRegExp=ql,u.isSafeInteger=Aw,u.isSet=Qu,u.isString=Qn,u.isSymbol=Ge,u.isTypedArray=xi,u.isUndefined=xw,u.isWeakMap=Ow,u.isWeakSet=Bw,u.join=Dy,u.kebabCase=Pb,u.last=Je,u.lastIndexOf=Uy,u.lowerCase=_b,u.lowerFirst=Rb,u.lt=Lw,u.lte=Nw,u.max=wv,u.maxBy=bv,u.mean=vv,u.meanBy=Iv,u.min=Pv,u.minBy=_v,u.stubArray=jl,u.stubFalse=Zl,u.stubObject=pv,u.stubString=cv,u.stubTrue=uv,u.multiply=Rv,u.nth=Gy,u.noConflict=tv,u.noop=Jl,u.now=Kn,u.pad=Fb,u.padEnd=Sb,u.padStart=Tb,u.parseInt=Eb,u.random=Mb,u.reduce=$M,u.reduceRight=VM,u.repeat=Cb,u.replace=Ab,u.result=lb,u.round=Fv,u.runInContext=M,u.sample=WM,u.size=YM,u.snakeCase=xb,u.some=zM,u.sortedIndex=Ky,u.sortedIndexBy=Xy,u.sortedIndexOf=Yy,u.sortedLastIndex=zy,u.sortedLastIndexBy=Qy,u.sortedLastIndexOf=Jy,u.startCase=Bb,u.startsWith=Lb,u.subtract=Sv,u.sum=Tv,u.sumBy=Ev,u.template=Nb,u.times=mv,u.toFinite=At,u.toInteger=D,u.toLength=ju,u.toLower=Db,u.toNumber=je,u.toSafeInteger=Dw,u.toString=W,u.toUpper=Ub,u.trim=Gb,u.trimEnd=kb,u.trimStart=Hb,u.truncate=$b,u.unescape=Vb,u.uniqueId=fv,u.upperCase=qb,u.upperFirst=Xl,u.each=Uu,u.eachRight=Gu,u.first=Bu,Ql(u,function(){var i={};return mt(u,function(r,a){X.call(u.prototype,a)||(i[a]=r)}),i}(),{chain:!1}),u.VERSION=e,Ke(["bind","bindKey","curry","curryRight","partial","partialRight"],function(i){u[i].placeholder=u}),Ke(["drop","take"],function(i,r){H.prototype[i]=function(a){a=a===s?1:oe(D(a),0);var l=this.__filtered__&&!r?new H(this):this.clone();return l.__filtered__?l.__takeCount__=ge(a,l.__takeCount__):l.__views__.push({size:ge(a,ut),type:i+(l.__dir__<0?"Right":"")}),l},H.prototype[i+"Right"]=function(a){return this.reverse()[i](a).reverse()}}),Ke(["filter","map","takeWhile"],function(i,r){var a=r+1,l=a==Op||a==Gd;H.prototype[i]=function(c){var m=this.clone();return m.__iteratees__.push({iteratee:A(c,3),type:a}),m.__filtered__=m.__filtered__||l,m}}),Ke(["head","last"],function(i,r){var a="take"+(r?"Right":"");H.prototype[i]=function(){return this[a](1).value()[0]}}),Ke(["initial","tail"],function(i,r){var a="drop"+(r?"":"Right");H.prototype[i]=function(){return this.__filtered__?new H(this):this[a](1)}}),H.prototype.compact=function(){return this.filter(Ae)},H.prototype.find=function(i){return this.filter(i).head()},H.prototype.findLast=function(i){return this.reverse().find(i)},H.prototype.invokeMap=G(function(i,r){return typeof i=="function"?new H(this):this.map(function(a){return xr(a,i,r)})}),H.prototype.reject=function(i){return this.filter(Yn(A(i)))},H.prototype.slice=function(i,r){i=D(i);var a=this;return a.__filtered__&&(i>0||r<0)?new H(a):(i<0?a=a.takeRight(-i):i&&(a=a.drop(i)),r!==s&&(r=D(r),a=r<0?a.dropRight(-r):a.take(r-i)),a)},H.prototype.takeRightWhile=function(i){return this.reverse().takeWhile(i).reverse()},H.prototype.toArray=function(){return this.take(ut)},mt(H.prototype,function(i,r){var a=/^(?:filter|find|map|reject)|While$/.test(r),l=/^(?:head|last)$/.test(r),c=u[l?"take"+(r=="last"?"Right":""):r],m=l||/^find/.test(r);!c||(u.prototype[r]=function(){var f=this.__wrapped__,g=l?[1]:arguments,w=f instanceof H,_=g[0],R=w||L(f),F=function(k){var $=c.apply(u,Dt([k],g));return l&&T?$[0]:$};R&&a&&typeof _=="function"&&_.length!=1&&(w=R=!1);var T=this.__chain__,C=!!this.__actions__.length,x=m&&!T,U=w&&!C;if(!m&&R){f=U?f:new H(this);var O=i.apply(f,g);return O.__actions__.push({func:qn,args:[F],thisArg:s}),new Ye(O,T)}return x&&U?i.apply(this,g):(O=this.thru(F),x?l?O.value()[0]:O.value():O)})}),Ke(["pop","push","shift","sort","splice","unshift"],function(i){var r=gn[i],a=/^(?:push|sort|unshift)$/.test(i)?"tap":"thru",l=/^(?:pop|shift)$/.test(i);u.prototype[i]=function(){var c=arguments;if(l&&!this.__chain__){var m=this.value();return r.apply(L(m)?m:[],c)}return this[a](function(f){return r.apply(L(f)?f:[],c)})}}),mt(H.prototype,function(i,r){var a=u[r];if(a){var l=a.name+"";X.call(Si,l)||(Si[l]=[]),Si[l].push({name:r,func:a})}}),Si[Dn(s,pt).name]=[{name:"wrapper",func:s}],H.prototype.clone=Vh,H.prototype.reverse=qh,H.prototype.value=Wh,u.prototype.at=bM,u.prototype.chain=vM,u.prototype.commit=IM,u.prototype.next=PM,u.prototype.plant=RM,u.prototype.reverse=FM,u.prototype.toJSON=u.prototype.valueOf=u.prototype.value=SM,u.prototype.first=u.prototype.head,Rr&&(u.prototype[Rr]=_M),u},Gt=Ih();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(se._=Gt,define(function(){return Gt})):ni?((ni.exports=Gt)._=Gt,zs._=Gt):se._=Gt}).call(Di)});var vp=Kt(Xt());var Md=Kt(gd());var bp=s=>{let e=200,t=[],n=0;return t[n]=[],s.forEach(o=>{t[n].length<=e-1?t[n].push(o):(n++,t[n]=[o])}),t},aa=s=>{let e=[],t=200;for(;s.length>t;){let n=s.splice(0,t);e.push(n)}return e.push(s),e},Oe=(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"},o={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=o[e]:t=p[e],t},Yt=s=>s.filter((t,n,o)=>n===o.indexOf(t)),oa=s=>Array.isArray(s)?s.map(e=>oa(e)):s!=null&&s.constructor===Object?Object.keys(s).reduce((e,t)=>({...e,[(0,Md.camelCase)(t)]:oa(s[t])}),{}):s,de=s=>s||!1,fe=()=>`&disable_cache=${Date.now()}`,Vr=s=>s.sort((e,t)=>e.localeCompare(t));var sa=class{id=null;name=null;nickname=null;avatar=null;gender=null;country=null;birthDate=null;interests=[];followingCount=0;followersCount=0};var la=class{profilesFromResponse=e=>e?e.map(t=>this.fullProfileFromResponse(t)):null;fullProfileFromResponse=e=>{let t=new sa;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 pa=class{nextPageStartsAfter=null;itemsPerPage=null};var Ui=class{pagination=new pa};var re=class{meta=new Ui;data=[]};var ca=class{avatar=null;followingId=null;name=null;nickname=null;profileId=null};var ua=class{followResponse=e=>e.map(t=>this.remapResponse(t));followingFromResponse=e=>{let t=new re;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 ca;return t.avatar=e.avatar,t.followingId=e.following_id,t.name=e.name,t.profileId=e.profile_id,t.nickname=e.nickname,t}};var ma=class{avatar=null;followerId=null;name=null;nickname=null;profileId=null};var da=class{followersFromResponse=e=>{let t=new re;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 ma;return t.avatar=e.avatar,t.followerId=e.follower_id,t.name=e.name,t.profileId=e.profile_id,t}};var qr=class{profile_ids=[]};var CI="/countries",Be="/profile",wd="/profiles",Gi=class{instanceAuth=null;instance=null;apiSignInUrl=null;profileRemapper=null;followingRemapper=null;followersRemapper=null;lang=null;constructor(e){this.lang=e.lang;let t=Oe(e.environment,"profile");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instanceAuth=vp.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 o=n.config;if((n.response.status===403||n.response.status===401)&&!o._retry){o._retry=!0;let p=e.authProvider.getIdToken();return o.headers.Authorization=`Bearer ${p}`,this.instanceAuth(o)}return Promise.reject(n)}),this.instance=vp.default.create({baseURL:t,headers:{"Content-Type":"application/json"}}),this.profileRemapper=new la,this.followingRemapper=new ua,this.followersRemapper=new da}getCountries=async e=>{try{let t=`&lang=${this.lang}`,n=`${CI}${this.apiSignInUrl}${t}`,o=Date.now();return e&&(n+=`&disable_cache=${o}`),(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=`${Be}${this.apiSignInUrl}`;if(e){t=`${wd}/${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=`${wd}${this.apiSignInUrl}&profile_ids=${e.join(",")}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);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=`${Be}/followers${this.apiSignInUrl}`;if(e&&!t){n=`${Be}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let o=await this.instanceAuth.get(n);return this.followersRemapper.followersFromResponse(o.data)}catch(o){throw console.warn("There was a problem fetching the followers for own profile",o),o.response}}else if(!e&&!t)try{let o=await this.instanceAuth.get(n);return this.followersRemapper.followersFromResponse(o.data)}catch(o){throw console.warn("There was a problem fetching the followers for own profile",o),o.response}e&&t?n=`${Be}/${t}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(n=`${Be}/${t}/followers${this.apiSignInUrl}`);try{let o=await this.instance.get(n);return this.followersRemapper.followersFromResponse(o.data)}catch(o){throw console.warn(`There was a problem fetching the followers for profile: ${t}`,o),o.response}};getFollowing=async(e,t)=>{let n=`${Be}/following${this.apiSignInUrl}`;if(e&&!t){n=`${Be}/following${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let o=await this.instanceAuth.get(n);return this.followingRemapper.followingFromResponse(o.data)}catch(o){throw console.warn("There was a problem fetching the followers of own profile",o),o.response}}else if(!e&&!t)try{let o=await this.instanceAuth.get(n);return this.followingRemapper.followingFromResponse(o.data)}catch(o){throw console.warn("There was a problem fetching the followers of own profile",o),o.response}e&&t?n=`${Be}/${t}/following${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(n=`${Be}/${t}/following${this.apiSignInUrl}`);try{let o=await this.instance.get(n);return this.followingRemapper.followingFromResponse(o.data)}catch(o){throw console.warn(`There was a problem fetching the followers of the following profile: ${t}`,o),o.response}};follow=async e=>{let t=new qr;t.profile_ids=e;try{let n=await this.instanceAuth.post(`${Be}/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 qr;t.profile_ids=e;try{return await this.instanceAuth.delete(`${Be}/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=`${Be}/badges${this.apiSignInUrl}`;try{return e?(t=`${Be}/${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(`${Be}${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 Ot={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id"},Ip={PREDICTOR_USER_RELATED_OPERATION:"https://docs.fansunitedmedia.com/docs/predictor-operations#user-related-operations"},Pp=["matchId","matchType","market","prediction"];var bd="FansUnited",_p={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(_p)}clearData=()=>{this.setData(_p)};getEntityById=(e="",t="")=>this.getData().football.ids.find(n=>{let o=Ot[this.idSchema];return n&&`${n[o]}`===t&&n.resource===e});getEntity=(e,t,n)=>Array.isArray(e)?this.getData().football.ids.filter(o=>{let p=Ot[n];return o&&e.includes(`${o[p]}`)&&o.resource===t}):this.getData().football.ids.find(o=>{let p=Ot[n];return o&&`${o[p]}`===e&&o.resource===t});getEntityByNativeId=(e="",t="")=>this.getData().football.ids.find(n=>n&&`${n.id}`===t&&n.resource===e);checkForExistingIdObjs=(e,t)=>{let n=Ot[t],o={};return Object.keys(e).forEach(p=>{let d=e[p],y=this.getEntity(d,p,t).map(b=>b[n]),P=e[p].filter(b=>!y.includes(b));o[p]=d.map(b=>P.includes(b)?{id:b,exists:!1}:{id:b,exists:!0})}),o};getIdsByType=(e,t,n)=>{let o=Ot[n],p=Ot[t],d={};return Object.keys(e).forEach(h=>{let y=e[h],P=[];this.getData().football.ids.forEach(b=>{y.forEach((S,q)=>{S===b[p]&&h===b.resource&&(P[q]=b[o])})}),d[h]=P}),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 o=!t.has(n.id);return t.add(n.id),o})};getData=()=>JSON.parse(localStorage.getItem(bd));setData=e=>{localStorage.setItem(bd,JSON.stringify(e))};initialNewSchema=e=>{this.getData().profile[e]||this.setData(_p)}};var vd=Kt(Xt());var Wr={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},fa=class{instance=null;apiSignInUrl="";constructor(e){let t=Oe(e.environment,"idMapping");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instance=vd.default.create({baseURL:t})}getEntityById=(e,t)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${config.idSchema}&${Wr[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}&${Wr[e]}=${t}`)}catch(o){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,o),o.response}};getEntityIdsByIdsAndSchema=(e,t,n)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${Wr[e]}=${t.join(",")}`)}catch(o){throw console.warn(`There was a problem with id mapping request for the following ids:${t.join(",")}`,o),o.response}};getEntitiesByIds=(e,t,n)=>{t.sort((d,h)=>d.localeCompare(h));let p=bp(t).map(d=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${Wr[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(y=>{h.push(...y.data.data)}),h})};getEntitiesByIdObjs=async(e,t)=>{let n=[],o={},p=[];Object.keys(e).forEach(P=>{n.push.apply(n,e[P])});let d=Yt(n),h=bp(d);for(let P of h){let b="";if(Object.keys(e).forEach(S=>{o[S]=[];let q=P.filter(Re=>e[S].includes(Re));q&&q.length>0&&(o[S]=q)}),Object.keys(o).forEach(S=>{o[S].length>0&&(o[S].sort((q,Re)=>q.localeCompare(Re)),b+="&",b+=`${Wr[S]}=${o[S].join(",")}`)}),b&&b.length>0)try{let S=await this.instance.get(`/football${this.apiSignInUrl}&input_provider=${t||"native"}${b}`);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 ha=class{isBrowser=!1;localStorage=null;https=null;constructor(e){this.isBrowser=typeof window!="undefined",this.localStorage=new gt(e),this.https=new fa(e)}getEntitiesByIds=async(e,t,n)=>{if(this.isBrowser)try{let o=this.localStorage.checkForExistingIdObjs(e,t),p=this.splitForRequestAndExisting(o),d=await this.https.getEntitiesByIdObjs(p.request,t);return this.localStorage.addIdMappings(d),this.localStorage.getIdsByType(e,t,n)}catch(o){return console.warn("There was a problem retrieving the entity ids ",o),Promise.resolve([])}else try{let o=await this.https.getEntitiesByIdObjs(e,t);return Object.keys(e).forEach(p=>{e[p]=o.filter(d=>d.resource===p).map(d=>d[Ot[n]])}),e}catch(o){return console.warn("There was a problem retrieving the entity ids ",o),Promise.resolve([])}};getEntityById=async(e,t,n)=>{if(this.isBrowser){let o=this.localStorage.getEntity(e,t,n);if(o)return o;{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(o=>{t[o]=e[o].filter(p=>!p.exists).map(p=>p.id),n[o]=e[o].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(o){return console.warn(`There was a problem retrieving the requested entity: ${o}`),null}}};var ga=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 ya=class{extractedObjIds={};traverse=(e,t)=>(t=ga(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 o=e[n];n==="id"||n==="teamId"?(this.extractedObjIds.hasOwnProperty(t)||(this.extractedObjIds[t]=[]),o&&this.extractedObjIds[t].push(o)):e[n]&&this.traverse(e[n],n)})}};var Ma=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(e,t,n)=>(t=ga(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 pe=class{idSchema="";idMappingFacade=null;constructor(e){this.idSchema=e.idSchema,this.idMappingFacade=new ha(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 ya().traverse(n,t);return this.idMappingFacade.getEntitiesByIds(p,"native",this.idSchema).then(d=>new Ma().traverse(n,t,d))}else return e}catch(o){return console.warn(`There was a problem remapping entity: ${t} with inner entity `,o),[]}};getEntityIdsBySchemaId=async(e,t,n)=>{let o={};return o[t]=e,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(o,this.idSchema,n):o}};var Ve=class{completed=!1;percentage;constructor(e){this.percentage=e}};var wa=class{teamFollowed=new Ve(10);teamFavourite=new Ve(15);playerFollowed=new Ve(10);playerFavourite=new Ve(10);competitionFollowed=new Ve(10);competitionFavourite=new Ve(5);addedBirthdate=new Ve(10);addedGender=new Ve(10);addedCountry=new Ve(10);addedAvatar=new Ve(10)};var ba=class{totalPercentage;breakdown=new wa};var Kr=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{e&&(e=new Kr(e));let n=await this.profileHttps.getFollowers(e,t),o=n.data.map(p=>p.followerId);if(o.length){let p=await this.getByIds(o),d=n.data.map(h=>(p.forEach(y=>{h.followerId===y.id&&(h.name=y.name,h.nickname=y.nickname,h.avatar=y.avatar)}),h));return n.data=d,n}return n}catch(n){throw console.warn("There was a problem retrieving your followers: ",n),n}};getFollowing=async(e,t)=>{try{e&&(e=new Kr(e));let n=await this.profileHttps.getFollowing(e,t),o=n.data.map(p=>p.followingId);if(o.length){let p=await this.getByIds(o),d=n.data.map(h=>(p.forEach(y=>{h.followingId===y.id&&(h.name=y.name,h.nickname=y.nickname,h.avatar=y.avatar)}),h));return n.data=d,n}return n}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 ba,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(b=>b.type==="team"&&b.favourite)&&(t.breakdown.teamFavourite.completed=!0,n+=t.breakdown.teamFavourite.percentage),e.interests.find(b=>b.type==="team")&&(t.breakdown.teamFollowed.completed=!0,n+=t.breakdown.teamFollowed.percentage),e.interests.find(b=>b.type==="player"&&b.favourite)&&(t.breakdown.playerFavourite.completed=!0,n+=t.breakdown.playerFavourite.percentage),e.interests.find(b=>b.type==="player")&&(t.breakdown.playerFollowed.completed=!0,n+=t.breakdown.playerFollowed.percentage),e.interests.find(b=>b.type==="competition"&&b.favourite)&&(t.breakdown.competitionFavourite.completed=!0,n+=t.breakdown.competitionFavourite.percentage),e.interests.find(b=>b.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 va=class{id=null;name=null;assets=null};var Ia=class{extractUpdatedProps=(e,t)=>{let n=["name","nickname","gender"],o={};return Object.keys(e).forEach(p=>{if(n.includes(p)&&e[p]!==t[p])o[p]=t[p];else if(p==="birthDate")(t[p]===null||e[p]===null&&t[p]||e[p]!==t[p])&&(o.birth_date=t[p]);else if(p==="country")t[p]===null?o.country_id=t[p]:(e[p]===null&&t[p]||e[p].id!==t[p].id)&&(o.country_id=t[p].id);else if(p==="interests"){let d=e[p],h=t[p];h.length&&this.isNewInterest(d,h)?o[p]=this.updateInterests(d,h):(!h.length&&d.length||d.length!==h.length&&!this.isNewInterest(d,h))&&(o[p]=h)}}),o};updateInterests=(e,t)=>{if(e.length===t.length){let[n,o]=this.extractSameAndNewInterests(e,t);return[...o,...n]}else return t};isNewInterest=(e,t)=>{let n=!1,[o]=this.extractSameAndNewInterests(e,t);return o.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 Pa=class{idsRemapper=null;profileHttps=null;profileService=null;localStorage=null;profileFacade=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;constructor(e,t,n,o,p,d){this.idsRemapper=e,this.localStorage=t,this.profileHttps=n,this.profileService=new Ia,this.profileFacade=new yt(t,n,o)}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.remapInterests(t.interests)};showFullInterests=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.showFullInterests(t.interests)};getFollowers=async e=>await this.profileFacade.getFollowers(e);getFollowing=async e=>await this.profileFacade.getFollowing(e);follow=async e=>{let t=await this.profileFacade.follow(e),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(o=>o.id!==t.id||o.type!==t.type||o.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 va,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),d=JSON.parse(JSON.stringify(p));return this.setOwnProfile(d),this.localStorage.setOwnProfile(d),delete p.interests,p}let o=JSON.parse(JSON.stringify(this.ownProfile));return delete o.interests,o}};var _a=class{idsRemapper=null;profileHttps=null;activityHttps=null;profileFacade=null;profileId="";constructor(e,t,n,o){this.idsRemapper=e,this.profileHttps=n,this.activityHttps=o,this.profileFacade=new yt(t,n,o)}setId=e=>(this.profileId=e,this);getProfile=async()=>await this.profileFacade.getById(this.profileId);getInfo=async()=>{let e=await this.getProfile();return delete e.interests,e};showInterests=async()=>{let e=await this.getProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.remapInterests(t.interests)};showFullInterests=async()=>{let e=await this.getProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.showFullInterests(t.interests)};getFollowers=async e=>await this.profileFacade.getFollowers(e,this.profileId);getFollowing=async e=>await this.profileFacade.getFollowing(e,this.profileId);showFullnessProfile=async()=>{let e=await this.getProfile();return this.profileFacade.showFullnessProfile(e)};getStats=async e=>{let t=await this.activityHttps.getStats(this.profileId,e);return await this.idsRemapper.remapSuccessRatesEntities(t)};getBadges=async()=>await this.profileHttps.getBadges(this.profileId)};var Ra=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 Xr=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 o=!0;return t.forEach(p=>{p!=="sortOrder"&&p!=="sortField"&&(p==="countryId"?o&&=n.country.id===this[p]:p==="name"?o&&=n.name.toLocaleLowerCase().includes(this[p].toLocaleLowerCase()):p==="competitionIds"?o&&=this[p].some(d=>n.id===d):o&&=n[p].toLocaleLowerCase()===this[p].toLocaleLowerCase())}),o})};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,o)=>this.sortOrder&&this.sortOrder==="desc"?o.name.localeCompare(n.name):n.name.localeCompare(o.name)):this.sortField==="country"?t=e.sort((n,o)=>this.sortOrder&&this.sortOrder==="desc"?o.country.name.localeCompare(n.country.name):n.country.name.localeCompare(o.country.name)):this.sortField==="scope"?e.forEach(n=>t[this.competitionIds.indexOf(n.id)]=n):!this.sortField&&this.sortOrder==="desc"&&(t=e.sort((n,o)=>o.id.localeCompare(n.id))),t}};var Fa=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 Xr(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 o=await this.getCompetitions(e,t);return await this.idMapping.remapEntities(o,"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=e.length,o=new Xr({competitionIds:e,limit:n}),p=await this.getCompetitions(o);p.sort((h,y)=>h.id.localeCompare(y.id));let d=await this.idMapping.remapEntities(p,"competition");return e.forEach((h,y)=>t.set(h,d[y])),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(o){throw console.warn("There was a problem retrieving all competitions",o),o}this.localStorage.setCompetitions(n)}return this.localStorage.getCompetitions(e)}else return this.https.getCompetitions(e,t)};getCompetitionByIdIdMapping=async(e,t)=>{try{let o=(await this.idMapping.getEntityIdsBySchemaId([e],"competition","native")).competition[0],p=await this.getCompetitionById(o,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 Yr=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 Id=Kt(Xt());var Sa=class{general=[];predictor=[];topX=[];matchQuiz=[]};var ki=class{points=null;gameParticipationCount=null;predictionsMade=null;correctPredictions=null};var Ta=class{id;enabled;requirements=new ki};var Ea=class{id;weight;multiplier;conditions};var Ca=class{value=[new Ea]};var Hi=class{points=null;tiers=null;badges=null};var Aa=class{enabled=!1;conditions={list:null};actions=new Ca;rewards=new Hi};var xa=class{general=null;comments=null;predictor=null;activity=null;topX=null;matchQuiz=null};var $i=class{enabled=!1;defaultMarkets=null;competitionsWhitelist=null};var Vi=class{enabled=!1;minFixtures=null;maxFixtures=null;competitionsWhitelist=null};var Oa=class{competitions=[];teams=[];markets=[]};var qi=class{enabled=!1;fullCoverageCompetitions=null;markets=null;successRateScopes=new Oa};var Ba=class{remapPredictorConfig=e=>{let t=new qi;return t.enabled=e.enabled,t.fullCoverageCompetitions=e.full_coverage_competitions,t.markets=e.markets,t.successRateScopes=e.success_rate_scopes,t};remapTopXConfig=e=>{let t=new Vi;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 $i;return t.enabled=e.enabled,t.defaultMarkets=e.default_markets,t.competitionsWhitelist=e.competitions_whitelist,t};remapLoyaltyConfig=e=>{let t=new Aa;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 Hi;return t.points=this.remapPoints(e.points),t.tiers=e.tiers,t.badges=this.remapBadges(e.badges),t};remapPoints=e=>{let t=new xa;return t.general=e.general,t.comments=e.comments,t.predictor=e.predictor,t.activity=e.activity,t.topX=e.top_x,t.matchQuiz=e.match_quiz,t};remapBadges=e=>{let t=new Sa;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 Ta;return n.id=t.id,n.enabled=t.enabled,n.requirements=this.remapRequirements(t.requirements),n});remapRequirements=e=>{let t=new ki;return t.points=e.points,t.gameParticipationCount=e.game_participation_count,t.predictionsMade=e.predictions_made,t.correctPredictions=e.correct_predictions,t}};var Ze=class{instance=null;apiSignInUrl="";featureConfigRemapper=null;constructor(e){let t=Oe(e.environment,"client");this.apiSignInUrl=`/clients/${e.clientId}/features?key=${e.apiKey}`,this.instance=Id.default.create({baseURL:t,headers:{"Content-Type":"application/json"}}),this.featureConfigRemapper=new Ba}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 zt=class{clientHttps=null;constructor(e){this.clientHttps=new Ze(e)}setAvailableMarketsForMatch=async e=>{let{fullCoverageCompetitions:t,markets:n}=await this.clientHttps.getConfig("predictor");if(Array.isArray(e))return e.map(o=>this.setAvailableMarkets(o,t,n));if(typeof e=="object"&&Object.keys(e).length)return this.setAvailableMarkets(e,t,n)};setAvailableMarkets=(e,t,n)=>{let o=e.context.competition?.id;return o&&this.isMatchInCoverageCompetition(o,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 Na=class{footballService=null;https=null;idMapping=null;constructor(e,t,n){this.idMapping=n,this.https=t,this.footballService=new zt(e)}getTeamsIdMapping=async(e,t)=>{try{let n=!1;if(e){if(e=new Yr(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 o=await this.getTeams(e,t);return o.data=await this.idMapping.remapEntities(o.data,"team"),o}catch(n){throw console.warn("There was a problem browsing all teams",n),n}};getTeamsMapWithNativeIds=async e=>{let t=new Map,n=e.length,o=new Yr({teamIds:e,limit:n}),{data:p}=await this.getTeams(o);p.sort((h,y)=>h.id.localeCompare(y.id));let d=await this.idMapping.remapEntities(p,"team");return e.forEach((h,y)=>t.set(h,d[y])),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 o=await this.getTeamById(e,t);return await this.idMapping.remapEntities(o,"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 o=await this.getNextMatchForTeam(e,t);return await this.idMapping.remapEntities(o,"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 o=await this.getPrevMatchForTeam(e,t);return await this.idMapping.remapEntities(o,"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 zr=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 Qt=class{https=null;footballService=null;idMapping=null;constructor(e,t,n){this.idMapping=n,this.https=t,this.footballService=new zt(e)}getPlayersIdMapping=async(e,t)=>{try{let n=!1;if(e){if(e=new zr(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 o=await this.getPlayers(e,t);return o.data=await this.idMapping.remapEntities(o.data,"player"),o}catch(n){throw console.warn("There was a problem browsing the players",n),n}};getPlayersWithNativeIds=async e=>{let t=e.length,n=new zr({playerIds:e,limit:t}),o=await this.getPlayers(n);return o.data.sort((p,d)=>p.id.localeCompare(d.id)),await this.idMapping.remapEntities(o.data,"player")};getPlayersMapWithNativeIds=async e=>{let t={},n=Yt(e);n.sort((p,d)=>p.localeCompare(d));let o=await this.getPlayersWithNativeIds(n);return n.forEach((p,d)=>t[p]=o[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"),o=await this.getPlayerById(n.player[0],t);return await this.idMapping.remapEntities(o,"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 o=await this.getNextMatchForPlayer(e,t);return await this.idMapping.remapEntities(o,"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 o=await this.getPrevMatchForPlayer(e,t);return await this.idMapping.remapEntities(o,"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 Qr=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 Jt=class{https=null;idMapping=null;footballService=null;constructor(e,t,n){this.https=t,this.idMapping=n,this.footballService=new zt(e)}getMatchesIdMapping=async(e,t)=>{try{if(e){if(e=new Qr(e),e.countryIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.countryIds,"country","native");e.countryIds=o.country}if(e.competitionIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");e.competitionIds=o.competition}if(e.matchIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.matchIds,"match","native");e.matchIds=o.match}if(e.teamIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");e.teamIds=o.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 Qr({matchIds:e,limit:t}),o=await this.getMatches(n);return o.data.sort((p,d)=>p.id.localeCompare(d.id)),await this.idMapping.remapEntities(o.data,"match")};getMatchesMapWithNativeIds=async e=>{let t={},n=Yt(e);n.sort((p,d)=>p.localeCompare(d));let o=await this.getMatchesWithNativeIds(n);return n.forEach((p,d)=>t[p]=o[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"),o=await this.getMatchById(n.match[0],t),p=await this.footballService.setAvailableMarketsForMatch(o);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 Da=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 Ua=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}searchIdMapping=async(e,t)=>{try{if(e=new Da(e),e.scope){let o=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");e.scope=o.competition}let n=await this.search(e,t);if(n.teams&&n.teams.length>0){let o=await this.idMapping.remapEntities(n.teams,"team");n.teams=o}if(n.players&&n.players.length>0){let o=await this.idMapping.remapEntities(n.players,"player");n.players=o}if(n.competitions&&n.competitions.length>0){let o=await this.idMapping.remapEntities(n.competitions,"competition");n.competitions=o}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 Wi=class{countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(e,t,n,o){this.countriesFacade=new Ra(t,n,o),this.competitionsFacade=new Fa(t,n,o),this.teamsFacade=new Na(e,n,o),this.playerFacade=new Qt(e,n,o),this.matchFacade=new Jt(e,n,o),this.searchFacade=new Ua(n,o)}getCountries=async e=>this.countriesFacade.getCountriesWithIdMapping(e);getCompetitions=async(e,t)=>this.competitionsFacade.getCompetitionsIdMapping(e,t);getCompetitionById=async(e,t)=>this.competitionsFacade.getCompetitionByIdIdMapping(e,t);getTopCompetitions=async e=>this.competitionsFacade.getTopCompetitionsIdMapping(e);getCompetitionsMapWithNativeIds=async e=>await this.competitionsFacade.getCompetitionsMapWithNativeIds(e);getTeams=async(e,t)=>this.teamsFacade.getTeamsIdMapping(e,t);getTeamById=async(e,t)=>this.teamsFacade.getTeamByIdIdMapping(e,t);getTopTeams=async e=>this.teamsFacade.getTopTeamsIdMapping(e);getNextMatchForTeam=async(e,t)=>this.teamsFacade.getNextMatchForTeamIdMapping(e,t);getPrevMatchForTeam=async(e,t)=>this.teamsFacade.getPrevMatchForTeamIdMapping(e,t);getTeamsMapWithNativeIds=async e=>await this.teamsFacade.getTeamsMapWithNativeIds(e);getPlayers=async(e,t)=>this.playerFacade.getPlayersIdMapping(e,t);getPlayerById=async(e,t)=>this.playerFacade.getPlayerIdMapping(e,t);getTopPlayers=async e=>this.playerFacade.getTopPlayersIdMapping(e);getNextMatchForPlayer=async(e,t)=>this.playerFacade.getNextMatchForPlayerIdMapping(e,t);getPrevMatchForPlayer=async(e,t)=>this.playerFacade.getPrevMatchForPlayerIdMapping(e,t);getPlayersMapWithNativeIds=async e=>this.playerFacade.getPlayersMapWithNativeIds(e);getMatches=async(e,t)=>this.matchFacade.getMatchesIdMapping(e,t);getMatchById=async(e,t)=>this.matchFacade.getMatchIdMapping(e,t);search=async(e,t)=>this.searchFacade.searchIdMapping(e,t)};var Pd=Kt(Xt());var Ga=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 Ga;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 ka=class{id="";country=null;gender="";assets=null;type="";name=""};var Le=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let t=new ka;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 Ha=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var $a=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 $a;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 Va=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new ne,this.teamBasicRemapper=new Me}fromResponse(e){try{let t=new Ha;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 qa=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";squad=[]};var Wa=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var Ka=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let t=new Wa;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 Xa=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new ne,this.competitionRemapper=new Le,this.playerRemapper=new Ka}fromResponse(e){try{let t=new qa;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 Ya=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 za=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var Ki=class{fromResponse(e){try{let t=new za;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 Qa=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new Me,this.competitionRemapper=new Le,this.scoresRemapper=new Ki}fromResponse(e){try{let t=new Ya;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 Ja=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 ja=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 Za=class{fromResponse(e){try{let t=new ja;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 Xi=class{homeTeam={players:[]};awayTeam={players:[]}};var eo=class{id="";name="";position="";shirtNumber;assets=null;type=""};var Yi=class{fromResponse(e){try{let t=new eo;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 to=class{playerRemapper=null;constructor(){this.playerRemapper=new Yi}fromResponse(e){try{let t=new Xi;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 io=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var ro=class{playerRemapper=null;constructor(){this.playerRemapper=new Yi}fromResponse(e){try{let t=new io;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 no=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new Me,this.competitionsMapper=new Le,this.lineupsMapper=new to,this.scoresMapper=new Ki,this.statsMapper=new Za,this.timelineMapper=new ro}fromResponse(e){try{let t=new Ja;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 Xi,t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var ao=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var oo=class{countryRemapper=null;constructor(){this.countryRemapper=new ne}fromResponse(e){try{let t=new ao;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 so=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;teams=[]};var zi=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new ne,this.teamRemapper=new Me}fromResponse(e){try{let t=new so;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 lo=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;competitions=[];teams=[]};var po=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new ne,this.teamRemapper=new Me,this.competitionRemapper=new Le}fromResponse(e){try{let t=new lo;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 co=class{teams=null;players=null;competitions=null};var uo=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new Me,this.playerRemapper=new zi,this.competitionremapper=new Le}fromResponse(e){try{let t=new co;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 Qi=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var jt=class{pagination=new Qi};var Ji=class{meta=new jt;data=[]};var mo=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=Oe(e.environment,"football");this.apiSignInUrl=`?key=${e.apiKey}&lang=${e.lang}`,this.instance=Pd.default.create({baseURL:t}),this.countryRemapper=new ne,this.competitionBasicRemapper=new Le,this.competitionFullRemapper=new Va,this.teamBasicRemapper=new Me,this.teamFullRemapper=new Xa,this.matchBasicRemapper=new Qa,this.matchFullRemapper=new no,this.playerBasicRemapper=new zi,this.playerFullRemapper=new po,this.topPlayerRemapper=new oo,this.searchRemapper=new uo,this.footballMetaRemapper=new mo}getCountries=async e=>{try{let t=`/countries${this.apiSignInUrl}`,n=Date.now();e&&(t+=`&disable_cache=${n}`);let o=await this.instance.get(t);return this.countryRemapper.countriesFromResponse(o.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={},o=Date.now();if(t=t||!1,e&&e.competitionIds&&e.competitionIds.length>this.limitIds-1){let p=[],d=aa(e.competitionIds);for(let y of d){e.competitionIds=y;let P=`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(P+=`&disable_cache=${o}`),n=await this.instance.get(P),p.push(n.data.data.map(b=>this.competitionBasicRemapper.fromResponse(b)))}return Array.prototype.concat.apply([],p)}else{let p=`/competitions${this.apiSignInUrl}`;return e&&(p+=`${e.constructFilterUrl()}`),t&&(p+=`&disable_cache=${o}`),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}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);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={},o=Date.now();if(e&&e.teamIds&&e.teamIds.length>this.limitIds){let p=[],d=aa(e.teamIds);for(let y of d){e.teamIds=y;let P=`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(P+=`disable_cache=${o}`),n=await this.instance.get(P),p.push(n.data.data.map(b=>this.teamBasicRemapper.fromResponse(b)))}return Array.prototype.concat.apply([],p)}else{let p=new Ji,d=`/teams${this.apiSignInUrl}`;return e&&(d+=`${e.constructFilterUrl()}`),t&&(d+=`&disable_cache=${o}`),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}`,o=Date.now();t&&(n+=`disable_cache=${o}`);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 o=await this.instance.get(t);return o.data.data?o.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}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);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}`,o=Date.now();t&&(n+=`disable_cache=${o}`);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={},o=Date.now();if(e&&e.playerIds&&e.playerIds.length>this.limitIds-1){let p=[],d=aa(e.playerIds);for(let y of d){e.playerIds=y;let P=`/players${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(P+=`&disable_cache=${o}`),n=await this.instance.get(P),p.push(n.data.data.map(b=>this.teamBasicRemapper.fromResponse(b)))}return Array.prototype.concat.apply([],p)}else{let p=new Ji,d=`/players${this.apiSignInUrl}`;return e&&(d+=`${e.constructFilterUrl()}`),t&&(d+=`&disable_cache=${o}`),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}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);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}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);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}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);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}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);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 Ji,o=`/matches${this.apiSignInUrl}`,p=Date.now();e&&(o+=`${e.constructFilterUrl()}`),t&&(o+=`&disable_cache=${p}`);let d=await this.instance.get(o);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()}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);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 Rp=Kt(Xt());var Pe=(N=>(N.FT_1X2="FT_1X2",N.HT_1X2="HT_1X2",N.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",N.DOUBLE_CHANCE="DOUBLE_CHANCE",N.HT_FT="HT_FT",N.PLAYER_SCORE="PLAYER_SCORE",N.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",N.PLAYER_RED_CARD="PLAYER_RED_CARD",N.RED_CARD_MATCH="RED_CARD_MATCH",N.PENALTY_MATCH="PENALTY_MATCH",N.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",N.CORNERS_MATCH="CORNERS_MATCH",N.CORRECT_SCORE="CORRECT_SCORE",N.CORRECT_SCORE_ADVANCED="CORRECT_SCORE_ADVANCED",N.CORRECT_SCORE_HT="CORRECT_SCORE_HT",N.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",N.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",N.OVER_GOALS_0_5="OVER_GOALS_0_5",N.OVER_GOALS_1_5="OVER_GOALS_1_5",N.OVER_GOALS_2_5="OVER_GOALS_2_5",N.OVER_GOALS_3_5="OVER_GOALS_3_5",N.OVER_GOALS_4_5="OVER_GOALS_4_5",N.OVER_GOALS_5_5="OVER_GOALS_5_5",N.OVER_GOALS_6_5="OVER_GOALS_6_5",N.OVER_CORNERS_6_5="OVER_CORNERS_6_5",N.OVER_CORNERS_7_5="OVER_CORNERS_7_5",N.OVER_CORNERS_8_5="OVER_CORNERS_8_5",N.OVER_CORNERS_9_5="OVER_CORNERS_9_5",N.OVER_CORNERS_10_5="OVER_CORNERS_10_5",N.OVER_CORNERS_11_5="OVER_CORNERS_11_5",N.OVER_CORNERS_12_5="OVER_CORNERS_12_5",N.OVER_CORNERS_13_5="OVER_CORNERS_13_5",N))(Pe||{}),_d=["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"],Rd=["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"],wt=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"],Fd=["FT_1X2","HT_1X2","HT_FT","DOUBLE_CHANCE","CORNERS_MATCH","CORRECT_SCORE","CORRECT_SCORE_HT","CORRECT_SCORE_ADVANCED"],Jr="PLAYER_SCORE_FIRST_GOAL";var fo=class{overallPercent;byFootballCompetition;byFootballTeam;byFootballMarket};var ho=class{profileId;tier;points;successRates=new fo};var go=class{successRatePercent;model=null};var yo=class{id=null;label=null};var Mo=class{type=null;id=null;label=null};var ji=class{content=new Mo;tags=[];campaign=new yo};var Zi=class{id=null;profileId=null;action=null;context=new ji;points=0};var wo=class{totalItems=0};var bo=class{meta=new wo;data=[new Zi]};var vo=class{remapSingleResponse=e=>{let t=new Zi;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 bo;return t.meta.totalItems=e.meta.total_items,t.data=e.data.map(n=>this.remapSingleResponse(n)),t};remapStatsReponse=e=>{let t=new ho;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,o])=>{t={...t,[n]:this.remapSuccessRatePercent(o)},Pe[n]&&delete t[n].model});else return e;return t};remapSuccessRatePercent=e=>{let t=new go;return t.successRatePercent=e.success_rate_percent,t}};var er=class{instanceAuth=null;instance=null;activityRemapper=null;apiSignInUrl=null;constructor(e){let t=Oe(e.environment,"loyalty");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instanceAuth=Rp.default.create({baseURL:t,headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.authProvider.getIdToken()}`}}),this.instance=Rp.default.create({baseURL:t,headers:{"Content-Type":"application/json"}}),this.activityRemapper=new vo}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}`,o=Date.now();e&&(n+=`${e.constructFilterUrl()}`),t&&(n+=`disable_cache=${o}`);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 o=`/users/${e}/activities${this.apiSignInUrl}`,p=Date.now();t&&(o+=`${t.constructFilterUrl()}`),n&&(o+=`disable_cache=${p}`);let d=await this.instance.get(o);return this.activityRemapper.remapActivitiesResponse(d.data)}catch(o){throw console.warn(`There was a problem with fetching activities for user ${e}`,o),o}};getStats=async(e,t)=>{try{let n="",o=null;return e?(n+=de(t)?`/users/${e}/statistics${this.apiSignInUrl}${fe()}`:`/users/${e}/statistics${this.apiSignInUrl}`,o=await this.instance.get(n)):(n+=`/statistics${this.apiSignInUrl}`,o=await this.instanceAuth.get(n)),this.activityRemapper.remapStatsReponse(o.data.data)}catch(n){throw console.warn("There was a problem fetching profile`s statistics:",n),n.response}}};var Io=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 o=e.successRates.byFootballCompetition,p=e.successRates.byFootballTeam;return e.successRates.byFootballCompetition=await this.setModels(o,n.competition,"competition"),e.successRates.byFootballTeam=await this.setModels(p,n.team,"team"),e}return e};setModels=async(e,t,n)=>{let o=null,p;switch(t=Vr(t),n){case"competition":o=await this.footballFacade.getCompetitionsMapWithNativeIds(t);break;case"team":o=await this.footballFacade.getTeamsMapWithNativeIds(t);break}return Object.keys(e).forEach(d=>{let h=o.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 o=await this.remapIdsObj(t,this.native,this.idSchema),p=[];for(let[d,h]of Object.entries(n))h.forEach((y,P)=>{y.id=o[d][P],p.push(y)});return p}else return e;return e};remapInterestToNative=async e=>{if(this.idSchema!==this.native){let t={},{id:n,type:o}=e;t[o]=[n];let p=await this.remapIdsObj(t,this.idSchema,this.native);return e.id=p[o][0],e}return e};inquiryCustomInterests=e=>{let t=[];return e&&e.length>0&&(t=e.filter(n=>n.source.toLocaleUpperCase()==="CUSTOM")),t};remapInterests=async e=>{let t=this.inquiryCustomInterests(e);if(t&&t.length>0){let n=e.filter(p=>p.source.toLocaleUpperCase()!=="CUSTOM"),o=await this.remapInterestsToIdSchema(n);return t.forEach(p=>o.push(p)),o}return await this.remapInterestsToIdSchema(e)};showFullInterests=async e=>{let t=[];if(e&&e.length>0){let n=this.inquiryCustomInterests(e);t.push(n);let o=e.filter(P=>P.source.toLocaleUpperCase()!=="CUSTOM"),{competitionsMap:p,teamsMap:d,playersMap:h}=await this.getInterestsEntitiesMap(o),y=o.map(P=>{let b=null;if(P.type==="competition")return b=p.get(P.id),b&&(P.id=b.id),P.model=b,P;if(P.type==="team")return b=d.get(P.id),b&&(P.id=b.id),P.model=b,P;if(P.type==="player")return h?(P.model=h[P.id],P.id=h[P.id].id):P.model=b,P});return t.push(y),t.flat()}return t};getInterestsEntitiesMap=async e=>{let t=[],n=[],o=[],p=new Map,d=new Map,h=null;if(e.forEach(y=>{y.type==="competition"?t.push(y.id):y.type==="team"?n.push(y.id):y.type==="player"&&o.push(y.id)}),t.length){let y=Vr(t);p=await this.footballFacade.getCompetitionsMapWithNativeIds(y)}if(n.length){let y=Vr(n);d=await this.footballFacade.getTeamsMapWithNativeIds(y)}if(o.length){let y=Vr(o);h=await this.footballFacade.getPlayersMapWithNativeIds(y)}return{competitionsMap:p,teamsMap:d,playersMap:h}};remapIdsObj=async(e,t,n)=>await this.idMapping.idMappingFacade.getEntitiesByIds(e,t,n)};var Po=class{idMapping=null;profileOperations=null;constructor(e,t){this.idMapping=new pe(e),this.profileOperations=new Io(e,t,this.idMapping)}remapSuccessRatesEntities=async e=>await this.profileOperations.remapSuccessRatesEntities(e);remapInterestToNative=async e=>await this.profileOperations.remapInterestToNative(e);remapInterests=async e=>await this.profileOperations.remapInterests(e);showFullInterests=async e=>await this.profileOperations.showFullInterests(e)};var tr=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 Gi(e),this.activityHttps=new er(e),this.footballHttps=new Mt(e),this.idMapping=new pe(e),this.localStorage=new gt(e),this.footballFacade=new Wi(e,this.localStorage,this.footballHttps,this.idMapping),this.profileFacade=new yt(this.localStorage,this.profileHttps,this.activityHttps),this.idsRemapper=new Po(e,this.footballFacade),this.ownProfileBuilder=new Pa(this.idsRemapper,this.localStorage,this.profileHttps,this.activityHttps,this.idMapping,this.footballFacade),this.profileBuilder=new _a(this.idsRemapper,this.localStorage,this.profileHttps,this.activityHttps)}getOwn=()=>this.ownProfileBuilder;getById=e=>this.profileBuilder.setId(e);getCountries=async e=>await this.profileFacade.getCountries(e);getByIds=async(e,t)=>await this.profileFacade.getByIds(e,t)};var _o=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 Ro=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 Fo=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 So=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 hi=class{getIdToken=null;logout=null};var rr=class{text=null;type=null};var To=class{validation=null;message=new rr;getIdToken={validation:null,message:new rr};logout={validation:null,message:new rr}};var Eo=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 hi),n=new To;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 hi).forEach(o=>{e[o]?t[o].validation="valid":t[o].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 Zr=class{validation;message};var Co=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;authProvider={getIdToken:new Zr,logout:new Zr};isValid=!1};var Ao=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 xo=class{validate=e=>{let t=this.checkFieldsForValues(e);return t.isValid=this.containsErrorMessage(t),t};checkFieldsForValues=e=>{let t=new Co,n={apiKey:new Fo,environment:new Ro,idSchema:new So,clientId:new Ao,lang:new _o,authProvider:new Eo};for(let[o,p]of Object.entries(t))o!=="isValid"&&(p=n[o].validate(e));return Object.keys(n).forEach(o=>{t[o]=n[o].validate(e)}),t};containsErrorMessage=e=>{let t=!0;for(let[n,o]of Object.entries(e))if(n!=="authProvider"){if(n!=="isValid"&&o.message.type==="error")return t=!1,t;if(n!=="isValid"&&o.message.type==="warning")return t=!0,t}else if(o.message.type==="error")return t=!1,t;return t}};var Oo=class{https=null;idMapping=null;localStorage=null;footballFacade=null;constructor(e){this.https=new Mt(e),this.idMapping=new pe(e),this.localStorage=new gt(e),this.footballFacade=new Wi(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 Tp=Kt(Xt());var Bo=class{value=null;playerId=null;playerModel=null};var nr=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new Bo;result=null};var Lo=class{value=!1;playerId=null};var et=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n,o){this.matchId=e,this.market=t,this.prediction=new Lo,this.prediction.value=n,this.prediction.playerId=o}};var ar=class{settledAt=null;resettledAt=null;status=null;outcome=null;points=0};var No=class{value=null};var Zt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new No,this.prediction.value=n}};var tt=class{value=!1};var or=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new tt,this.prediction.value=n}};var sr=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new tt,this.prediction.value=n}};var Do=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 or||e instanceof sr)t.market=e.market,t.prediction=e.prediction.value;else if(e instanceof Zt){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,y)=>h.match_id.localeCompare(y.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 o=await this.matchFacade.getMatchesMapWithNativeIds(t),p=[];n.sort((h,y)=>h.localeCompare(y)),n&&n.length>0&&(p=await this.playerFacade.getPlayersMapWithNativeIds(n));let d=[];for(let h of e){let y=new nr;h.target?y.market=this.predictorService.convertMarketForResponseModel(h.market,h.target):y.market=h.market,y.matchId=o[h.match_id].id,y.matchType=h.match_type,y.matchModel=o?o[h.match_id]:null,delete y.matchModel.availableMarkets,h.goals_home!==void 0&&h.goals_away!==void 0?y.prediction.value=h.goals_home.toString()+":"+h.goals_away.toString():y.prediction.value=h.prediction,y.prediction.playerId=h.player_id?h.player_id:null,y.prediction.playerId&&(y.prediction.playerModel=p[h.player_id],y.prediction.playerId=p[h.player_id].id),y.result=this.remapResult(h.result),d.push(y)}return d};remapResult=e=>{let t=new ar;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 ei=class{goldenGoal=null};var en=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new ei;points=null;createdAt=null;updatedAt=null};var Z=class{no=0;yes=0};var lr=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new Z;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new Z;penaltyMatch=new Z;playerScoreFirstGoal={};cornersMatch={};correctScore={};correctScoreHalfTime={};correctScoreAdvanced={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new Z;overOnePointFiveGoals=new Z;overTwoPointFiveGoals=new Z;overThreePointFiveGoals=new Z;overFourPointFiveGoals=new Z;overFivePointFiveGoals=new Z;overSixPointFiveGoals=new Z;overSixPointFiveCorners=new Z;overSevenPointFiveCorners=new Z;overEightPointFiveCorners=new Z;overNinePointFiveCorners=new Z;overTenPointFiveCorners=new Z;overElevenPointFiveCorners=new Z;overTwelvePointFiveCorners=new Z;overThirteenPointFiveCorners=new Z};var bt=class{timeTiebreaker=!1};var gi=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new bt;predictionId=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;scheduleOpenAt=null;images=null};var yi=class{userId=null;points=null;results=[];tiebreaker=null};var Uo=(p=>(p.ACTIVE="ACTIVE",p.WON="WON",p.LOST="LOST",p.PARTIALLY_WON="PARTIALLY_WON",p.CANCELED="CANCELED",p))(Uo||{}),Fp=["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(Uo).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 pr=class{limit;startAfter;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null}constructMainFiltersUrl(){let e="";return this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),e}};var tn=(d=>(d.OPEN="OPEN",d.LIVE="LIVE",d.PENDING="PENDING",d.CANCELED="CANCELED",d.CLOSED="CLOSED",d.SETTLED="SETTLED",d))(tn||{});var it=class extends pr{status=null;type=null;gameIds=null;sortOrder=null;constructor(e){super(e);this.status=e.status?e.status:null,this.type=e.type?e.type:null,this.gameIds=e.gameIds?e.gameIds:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFiltersUrl=()=>{let e=super.constructMainFiltersUrl();return this.status&&Object.values(tn).includes(this.status)&&(e+="&",e+=`status=${this.status}`),this.type&&(e+="&",e+=`type=${this.type}`),this.gameIds&&this.gameIds.length>0&&(e+="&",e+=`game_ids=${this.gameIds.join(",")}`),this.sortOrder&&(e+="&",e+=`sort_order=${this.sortOrder}`),e}};var cr=class{main=null;cover=null;mobile=null};var Mi=class{id=null;title=null;description=null;type=null;status=null;scheduleOpenAt=null;predictionsCutoff=null;fixtures=[];tiebreaker=new bt;rules=null;flags=null;images=new cr;createdAt=null;updatedAt=null};var Lt=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new bt;predictionId=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;images=null;scheduleOpenAt=null};var Sp={UNEXPECTED_STATUS_PROP:`Unexpected provided property 'status'. You can NOT use this property for this method. For more information visit our documentation:
22
22
  ${Ip.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
  ${Ip.PREDICTOR_USER_RELATED_OPERATION}`},Sd=(s,e)=>`The prediction '${s}' is invalid for market '${e}'. Please check again have you passed appropriate prediction model. For more information please visit our documentation: https://docs.fansunitedmedia.com/sdks/js/match.quiz#gamerelatedoperations`,Go=s=>`The market '${s}' is not supported from Fans United. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,Td=s=>`The market '${s}' is not valid for Top X game. The only available market is CORRECT_SCORE.`,Ed=s=>`The field/s '${s.length>1?s.join(", "):s[0]}' is/are invalid. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/javascript-sdk`,Cd=(s,e)=>`The following field/s is/are missing from ${s}: '${e.length>1?e.join(", "):e[0]}'. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,Ad=(s,e)=>`The field ${s} has incorrect type. The correct type is ${e}`;var vt=class{footballHttps=null;idMapping=null;matchFacade=null;playerFacade=null;constructor(e,t){this.footballHttps=new Mt(e),this.idMapping=t,this.matchFacade=new Jt(e,this.footballHttps,t),this.playerFacade=new Qt(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=Yt(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,o]of Object.entries(e))if(t.includes(n))for(let p of Object.keys(o)){let d={player:[p]},y=(await this.idMapping.idMappingFacade.getEntitiesByIds(d,"native",this.idMapping.idSchema)).player[0];o[y]=o[p],delete o[p]}return e};convertMarket=e=>{let t=Object.keys(new lr),n=Object.values(Pe);for(let o=0;o<n.length;o++)e===n[o]&&(e=t[o]);return e};convertMarketForResponseModel=(e,t)=>{let n=t.toString();return e+"_"+n};getMarketSummary=(e,t,n)=>{let o=this.convertMarket(t),p={};if(p.matchId=e.matchId,p.matchType=e.matchType,Object.keys(e.predictions).includes(o))p[o]=e.predictions[o];else throw new Error("You have passed invalid market");return wt.includes(t)&&n?(p[o][n]||(p[o][n]=new Z),p[o][n]):p};remapCompetitionsFromConfig=async e=>{if(e instanceof qi){let t={competition:e.fullCoverageCompetitions},n={competition:e.successRateScopes.competitions},o={team:e.successRateScopes.teams},p=await this.idMapping.idMappingFacade.getEntitiesByIds(t,"native",this.idMapping.idSchema),d=await this.idMapping.idMappingFacade.getEntitiesByIds(n,"native",this.idMapping.idSchema),h=await this.idMapping.idMappingFacade.getEntitiesByIds(o,"native",this.idMapping.idSchema);return e.fullCoverageCompetitions=p.competition,e.successRateScopes.competitions=d.competition,e.successRateScopes.teams=h.team,e}if(e instanceof Vi||e instanceof $i){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(o=>{o instanceof Mi||o instanceof gi||o instanceof Lt?(o.fixtures.forEach(p=>t.push(p.matchId)),o instanceof Lt&&o.fixtures.forEach(p=>{p.prediction.playerId&&n.push(p.prediction.playerId)})):o instanceof yi&&o.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 o=[],p=await this.matchFacade.getMatchesMapWithNativeIds(t),d={};return n.length>0&&(d=await this.playerFacade.getPlayersMapWithNativeIds(n)),e.data.forEach(h=>{h instanceof Mi||h instanceof gi||h instanceof Lt?(h.fixtures.forEach(y=>{y.matchModel=p[y.matchId],delete y.matchModel.availableMarkets,y.matchId=y.matchModel.id,h instanceof Lt&&y.prediction.playerId&&(y.prediction.playerModel=d[y.prediction.playerId],y.prediction.playerId=d[y.prediction.playerId].id)}),o.push(h)):h instanceof yi&&(h.results.forEach(y=>{y.matchModel=p[y.matchId],delete y.matchModel.availableMarkets,y.matchId=y.matchModel.id}),o.push(h))}),e.data=o,e};refactorResponseObjModel=async e=>{let t=[];e.fixtures.forEach(o=>t.push(o.matchId));let n=await this.matchFacade.getMatchesMapWithNativeIds(t);return e.fixtures.forEach(o=>{o.matchModel=n[o.matchId],delete o.matchModel.availableMarkets,o.matchId=n[o.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,y]=[p.predictionsCutoff,d.predictionsCutoff].map(P=>Math.abs(new Date(P)-t));return h-y})[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 it(t),t;if(t&&!n)return t.type=e,t=new it(t),t;if(!t&&n){let o={type:e,gameIds:n};return o=new it(o),o}else{let o={type:e};return o=new it(o),o}};addPredictionProp=async(e,t)=>(t.data.forEach(n=>{e.forEach(o=>{n.id===o.game_instance_id&&(n.predictionId=o.id,n.outcome=o.status,n.fixtures.forEach((p,d)=>{o.fixtures[d].goals_home!==void 0&&o.fixtures[d].goals_away!==void 0?p.prediction.value=o.fixtures[d].goals_home+":"+o.fixtures[d].goals_away:p.prediction.value=o.fixtures[d].prediction,o.fixtures[d].player_id?p.prediction.playerId=o.fixtures[d].player_id:o.fixtures[d].target&&(p.prediction.target=o.fixtures[d].target),p.prediction.result=this.remapResult(o.fixtures[d].result)}),n.predictionsMadeAt=o.created_at,n.points=o.points)})}),await this.remapMatchIdsFixtures(t));remapResult=e=>{let t=new ar;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 o={status:["ACTIVE"]};e=new _e(o)}break;case"past":if(e)this.deleteUnexpectedProperties(e),e.status=Fp,e=new _e(e);else{let o={status:Fp};e=new _e(o)}break;case"matches":if(e)this.deleteUnexpectedProperties(e),e.matchIds=n,e=new _e(e);else{let o={matchIds:n};e=new _e(o)}break}return e};completeGameMarketResults=async(e,t)=>{switch(t){case"MATCH_QUIZ":let n={},o=e.results[0].matchId,p=e.results.map(P=>wt.includes(P.market)?[...P.result]:[]).flat(),d=await this.matchFacade.getMatchesMapWithNativeIds([o]);return p.length&&(n=await this.playerFacade.getPlayersMapWithNativeIds(p)),e.results=e.results.map(P=>{if(P.matchModel=d[P.matchId],P.playerModels&&P.result.forEach(S=>{let q=n[S];P.playerModels.push(q)}),this.idMapping.idSchema!=="native"&&(P.matchId=d[P.matchId].id,P.playerModels)){let b=P.result;P.result=b.map(S=>n[S].id)}return P}),e;case"TOP_X":let h=e.results.map(P=>P.matchId),y=await this.matchFacade.getMatchesMapWithNativeIds(h);if(e.results=e.results.map(P=>(P.matchModel=y[P.matchId],this.idMapping.idSchema!=="native"&&(P.matchId=y[P.matchId].id),P)),e.tieBreakers.goldenGoals.length){let P=e.tieBreakers.goldenGoals.map(S=>S.playerId),b=await this.playerFacade.getPlayersMapWithNativeIds(P);e.tieBreakers.goldenGoals=e.tieBreakers.goldenGoals.map(S=>(S.matchModel=y[S.matchId],S.playerModel=b[S.playerId],this.idMapping.idSchema!=="native"&&(S.matchId=y[S.matchId].id,S.playerId=b[S.playerId].id),S))}return e}};deleteUnexpectedProperties=e=>(e.status&&(console.warn(Sp.UNEXPECTED_STATUS_PROP),delete e.status),e.type&&(console.warn(Sp.UNEXPECTED_TYPE_PROP),delete e.type),e)};var ur=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(e){this.gameInstanceId=e.gameInstanceId,e.fixtures.forEach(t=>this.fixtures.push(new Zt(t.matchId,t.market,t.prediction.value))),this.tiebreaker=e.tiebreaker?e.tiebreaker:null}};var mr=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t){this.footballHttps=new Mt(e),this.matchFacade=new Jt(e,this.footballHttps,t),this.playerFacade=new Qt(e,this.footballHttps,t),this.predictorService=new vt(e,t),this.fixturesRemapper=new Do(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 ur&&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=[],o={},p=[];e.forEach(h=>{h.fixtures.forEach(y=>{t.push(y.match_id),y.player_id&&n.push(y.player_id)})});let d=await this.matchFacade.getMatchesMapWithNativeIds(t);return n.length>0&&(o=await this.playerFacade.getPlayersMapWithNativeIds(n)),e.forEach(h=>{let y=new en,P=[];y.id=h.id,y.gameInstanceId=h.game_instance_id,y.gameType=h.game_type,y.wager=h.wager,y.totalFixtures=h.total_fixtures,y.settledFixtures=h.settled_fixtures,y.userId=h.user_id,h.fixtures.forEach(b=>{let S=new nr;b.target?S.market=this.predictorService.convertMarketForResponseModel(b.market,b.target):S.market=b.market,S.matchId=d[b.match_id].id,S.matchType=b.match_type,S.matchModel=d[b.match_id],delete S.matchModel.availableMarkets,b.goals_home!==void 0&&b.goals_away!==void 0?S.prediction.value=b.goals_home.toString()+":"+b.goals_away.toString():S.prediction.value=b.prediction,S.prediction.playerId=b.player_id?b.player_id:null,S.prediction.playerId&&(S.prediction.playerModel=o[S.prediction.playerId],S.prediction.playerId=o[S.prediction.playerId].id),S.result=this.fixturesRemapper.remapResult(b.result),P.push(S)}),y.fixtures=P,y.status=h.status,h.tiebreaker?y.tiebreaker.goldenGoal=h.tiebreaker.golden_goal:y.tiebreaker=null,y.points=h.points,y.createdAt=h.created_at,y.updatedAt=h.updated_at,p.push(y)}),p}return e};remapResponseObjBody=async e=>{let t=new en;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 lr;return t.fullTimeOneXTwo=e.FT_1X2,t.halfTimeOneXTwo=e.HT_1X2,t.bothTeamsScore=e.BOTH_TEAMS_SCORE,t.overZeroPointFiveGoals=e.OVER_GOALS_0_5,t.overOnePointFiveGoals=e.OVER_GOALS_1_5,t.overTwoPointFiveGoals=e.OVER_GOALS_2_5,t.overThreePointFiveGoals=e.OVER_GOALS_3_5,t.overFourPointFiveGoals=e.OVER_GOALS_4_5,t.overFivePointFiveGoals=e.OVER_GOALS_5_5,t.overSixPointFiveGoals=e.OVER_GOALS_6_5,t.overSixPointFiveCorners=e.OVER_CORNERS_6_5,t.overSevenPointFiveCorners=e.OVER_CORNERS_7_5,t.overEightPointFiveCorners=e.OVER_CORNERS_8_5,t.overNinePointFiveCorners=e.OVER_CORNERS_9_5,t.overTenPointFiveCorners=e.OVER_CORNERS_10_5,t.overElevenPointFiveCorners=e.OVER_CORNERS_11_5,t.overTwelvePointFiveCorners=e.OVER_CORNERS_12_5,t.overThirteenPointFiveCorners=e.OVER_CORNERS_13_5,t.doubleChance=e.DOUBLE_CHANCE,t.halfTimeFullTime=e.HT_FT,t.playerScore=e.PLAYER_SCORE,t.playerYellowCard=e.PLAYER_YELLOW_CARD,t.playerRedCard=e.PLAYER_RED_CARD,t.redCardMatch=e.RED_CARD_MATCH,t.penaltyMatch=e.PENALTY_MATCH,t.playerScoreFirstGoal=e.PLAYER_SCORE_FIRST_GOAL,t.cornersMatch=e.CORNERS_MATCH,t.correctScore=e.CORRECT_SCORE,t.correctScoreHalfTime=e.CORRECT_SCORE_HT,t.correctScoreAdvanced=e.CORRECT_SCORE_ADVANCED,t.playerScoreHattrick=e.PLAYER_SCORE_HATTRICK,t.playerScoreTwice=e.PLAYER_SCORE_TWICE,t}};var ko=class{matchId=null;matchType=null;predictions=null};var Ho=class{remapPredictions=null;constructor(e,t){this.remapPredictions=new mr(e,t)}remapResponse=e=>{let t=new ko;return t.matchId=e.match_id,t.matchType=e.match_type,t.predictions=this.remapPredictions.remapPredictionModel(e.predictions),t}};var $o=class{matchId=null;matchType=null;market=null;matchModel=null};var Vo=class{value=null;target=null;playerId=null;playerModel=null;result=null};var qo=class{matchId=null;matchType=null;market=null;matchModel=null;prediction=new Vo};var Wo=class{value=null;result=null};var Ko=class{matchId=null;matchType=null;market=null;matchModel=null;prediction=new Wo};var Xo=class{matchId=null;matchModel=null;outcome=null};var Yo=class{gameId=null;results=null;tieBreakers=null};var zo=class{remapPaginatedGames=e=>{let t=new re;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 Mi;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.scheduleOpenAt=e.schedule_open_at,t.predictionsCutoff=e.predictions_cutoff,t.fixtures=e.fixtures.map(n=>this.remapFixturesResponse(n)),t.tiebreaker=e.tiebreaker?this.remapTimeTiebreaker(e.tiebreaker.time_tiebreaker):null,t.rules=e.rules,t.flags=e.flags,t.images=e.images,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapFixturesResponse=e=>{let t=new $o;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t};remapPaginatedUserTopXEditions=e=>{let t=new re;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 gi;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.scheduleOpenAt=e.schedule_open_at,t.fixtures=e.fixtures.map(n=>this.remapTopXFixturesResponse(n)),t.tiebreaker=e.tiebreaker?this.remapTimeTiebreaker(e.tiebreaker.time_tiebreaker):null,t.rules=e.rules,t.flags=e.flags,t.images=e.images,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapTopXFixturesResponse=e=>{let t=new Ko;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t};remapPaginatedUserMathQuizEditions=e=>{let t=new re;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 Lt;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.scheduleOpenAt=e.schedule_open_at,t.fixtures=e.fixtures.map(n=>this.remapMatchQuizFixturesResponse(n)),t.tiebreaker=e.tiebreaker?this.remapTimeTiebreaker(e.tiebreaker.time_tiebreaker):null,t.rules=e.rules,t.flags=e.flags,t.images=e.images,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapMatchQuizFixturesResponse=e=>{let t=new qo;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t};remapPaginatedGameResults=e=>{let t=new re;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 yi;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 Yo;return t.gameId=e.game_id,t.results=this.remapMarketsResults(e.results),t.tieBreakers=e.tie_breakers?this.remapTieBreakers(e.tie_breakers):null,t};remapTieBreakers=e=>{let t={goldenGoals:[]};return t.goldenGoals=e.golden_goals.map(n=>({minute:n.minute,matchId:n.match_id,matchModel:null,playerId:n.player_id,playerModel:null,goalType:n.goal_type})),t};remapMarketsResults=e=>{let t=[];return e.forEach(n=>{let o={matchId:n.match_id,market:n.market,result:this.remapMarketResult(n.market,n.result),matchModel:null,playerModels:[]};t.push(this.deleteUnusefulField(o))}),t};remapMarketResult=(e,t)=>{if(Fd.includes(e))return t[0];if(wt.includes(e))return t;if(t[0]==="true")return!0;if(t[0]==="false")return!1};deleteUnusefulField=e=>((!wt.includes(e.market)||this.isPlayerMarketWithNoResult(e.market,e.result))&&delete e.playerModels,e);isPlayerMarketWithNoResult=(e,t)=>wt.includes(e)&&t.length===0;remapResults=e=>{let t=new Xo;return t.matchId=e.match_id,t.outcome=e.outcome,t};remapTiebreaker=e=>{let t=new ei;return t.goldenGoal=e.golden_goal,t};remapTimeTiebreaker=e=>{let t=new bt;return t.timeTiebreaker=e,t}};var Qo=class{remapMetaData=e=>{let t=new Ui;return t.pagination.nextPageStartsAfter=e.pagination.next_page_starts_after,t.pagination.itemsPerPage=e.pagination.items_per_page,t}};var ti=class{instanceAuth=null;instance=null;apiSignInUrl=null;predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;metaRemapper=null;constructor(e,t){let n=Oe(e.environment,"predictor");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.predictionRemapper=new mr(e,t),this.matchSummaryRemapper=new Ho(e,t),this.gamesRemapper=new zo,this.metaRemapper=new Qo,this.instanceAuth=Tp.default.create({baseURL:n,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instance=Tp.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=de(t)?`/predictions/summary/${e}${this.apiSignInUrl}${fe()}`:`/predictions/summary/${e}${this.apiSignInUrl}`;try{let o=await this.instance.get(n);return this.matchSummaryRemapper.remapResponse(o.data)}catch(o){throw console.warn(`There was a problem fetching predictions for match: ${e} `,o),o.response}};deleteFootballPrediction=async e=>{try{return await this.instanceAuth.delete(`/predictions/${e}${this.apiSignInUrl}`),!0}catch(t){throw console.warn(`There was a problem deleting your prediction: ${e}`,t),t.response}};getMyPredictions=async e=>{try{let t=new re,n=`/predictions${this.apiSignInUrl}`;e&&(n+=`${e.constructFiltersUrl()}`);let o=await this.instanceAuth.get(n);return t.meta=this.metaRemapper.remapMetaData(o.data.meta),t.data=await this.predictionRemapper.remapResponseArrayBody(o.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 o=new re,p=de(t)?`/predictions/users/${e}${this.apiSignInUrl}${fe()}`:`/predictions/users/${e}${this.apiSignInUrl}`;n&&(p+=`${n.constructFiltersUrl()}`);let d=await this.instance.get(p);return o.meta=this.metaRemapper.remapMetaData(d.data.meta),o.data=await this.predictionRemapper.remapResponseArrayBody(d.data.data),o}catch(o){throw console.warn(`There was a problem fetching predictions for user: ${e}`,o),o.response}};getUserPredictionsNoRemap=async(e,t)=>{try{return(await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}${t.constructFiltersUrl()}`)).data.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=de(t)?`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}${fe()}`:`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,o=await this.instance.get(n);return this.gamesRemapper.remapPaginatedGames(o.data)}catch(n){throw console.warn("There was a problem fetching the games list",n),n.response}};getGameById=async(e,t)=>{try{let n=de(t)?`/games/${e}${this.apiSignInUrl}${fe()}`:`/games/${e}${this.apiSignInUrl}`,o=await this.instance.get(n);return this.gamesRemapper.remapGamesListResponse(o.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 o=new re,p=de(t)?`/games/${e}/predictions${this.apiSignInUrl}${fe()}`:`/games/${e}/predictions${this.apiSignInUrl}`;n&&(p+=`${n.constructFiltersUrl()}`);let d=await this.instance.get(p);return o.meta=this.metaRemapper.remapMetaData(d.data.meta),o.data=await this.predictionRemapper.remapResponseArrayBody(d.data.data),o}catch(o){throw console.warn(`There was a problem fetching the predictions for game: ${e}`,o),o.response}};getUserGameEditions=async(e,t)=>{try{let n=null,o=de(t)?`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}${fe()}`:`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,p=await this.instance.get(o);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 o=de(t)?`/games/${e}/results/${this.apiSignInUrl}${fe()}`:`/games/${e}/results/${this.apiSignInUrl}`;n&&(o+=`${n.constructMainFiltersUrl()}`);let p=await this.instance.get(o);return this.gamesRemapper.remapPaginatedGameResults(p.data)}catch(o){throw console.warn(`There was a problem fetching the results for the following game: ${e}`,o),o.response}};getMarketResultsForGame=async(e,t)=>{let n=`/games/${e}/correct-results/${this.apiSignInUrl}`;de(t)&&(n+=`${fe()}`);try{let o=await this.instance.get(n);return this.gamesRemapper.remapGameMarketsResults(o.data.data)}catch(o){throw console.warn(`There was a problem fetching the markets correct results for the following game: ${e}`,o),o.response}}};var dr=class{gameInstanceId=null;fixtures=null};var he=class extends Error{code=0;status=null;message=null;constructor(e,t,n){super();this.code=e,this.status=t,this.message=n}errorMessage=()=>this.message};var Ep=(n=>(n.ONE="1",n.X="x",n.TWO="2",n))(Ep||{}),Cp=(n=>(n.ONE_X="1x",n.X_TWO="x2",n.ONE_TWO="12",n))(Cp||{}),Ap=(P=>(P.ONE_ONE="1/1",P.ONE_X="1/x",P.ONE_TWO="1/2",P.X_ONE="x/1",P.X_X="x/x",P.X_TWO="x/2",P.TWO_ONE="2/1",P.TWO_X="2/x",P.TWO_TWO="2/2",P))(Ap||{});var Jo=class{matchId=null;market="BOTH_TEAMS_SCORE";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new tt,this.prediction.value=t}};var jo=class{value};var Zo=class{matchId=null;market="CORNERS_MATCH";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new jo,this.prediction.value=t}};var es=class{value=null};var ts=class{matchId=null;market="DOUBLE_CHANCE";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new es,this.prediction.value=t}};var is=class{value=null};var rs=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new is,this.prediction.value=n}};var ns=class{value=null};var as=class{matchId=null;market="HT_FT";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new ns,this.prediction.value=t}};var os=class{matchId=null;market="PENALTY_MATCH";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new tt,this.prediction.value=t}};var ss=class{matchId=null;market="RED_CARD_MATCH";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new tt,this.prediction.value=t}};var ii=class{validateBodyFields=(e,t)=>{let n=Object.keys(t),o=Object.keys(new dr);switch(e){case"MATCH_QUIZ":n.forEach(y=>{o.includes(y)||this.throwInvalidParamException([y])});break;case"TOP_X":let d=t;d.fixtures.forEach(y=>this.validateMarketTopX(y.market));let h="tiebreaker";n.includes(h)&&d.tiebreaker&&this.validateTiebreaker(d.tiebreaker),n.forEach(y=>{y!=="tiebreaker"&&!o.includes(y)&&this.throwInvalidParamException([y])});break}let p=o.filter(d=>!n.includes(d));return p.length&&this.throwMissingFieldsException("game prediction body",p),t.fixtures.forEach(d=>{this.validateFixtureFields(d)}),t};validateFixture=(e,t,n,o)=>{this.validateMarket(t);let p=Object.values(Ep),d=Object.values(Ap),h=Object.values(Cp);if(t==="FT_1X2"||t==="HT_1X2"){if(p.includes(n))return new rs(e,t,n)}else if(t==="HT_FT"){if(d.includes(n))return new as(e,n)}else if(t==="DOUBLE_CHANCE"){if(h.includes(n))return new ts(e,n)}else if(t==="CORRECT_SCORE"||t==="CORRECT_SCORE_ADVANCED"||t==="CORRECT_SCORE_HT"){if(typeof n=="string"&&/\d+:\d+/.test(n))return new Zt(e,t,n)}else if(t==="CORNERS_MATCH"){if(typeof n=="number")return new Zo(e,n)}else if(t==="BOTH_TEAMS_SCORE"){if(this.isPredictionBoolean(n))return new Jo(e,n)}else if(t==="RED_CARD_MATCH"){if(this.isPredictionBoolean(n))return new ss(e,n)}else if(t==="PENALTY_MATCH"){if(this.isPredictionBoolean(n))return new os(e,n)}else if(wt.includes(t)){if(this.validatePlayerId(t,o),t===Jr&&this.isPredictionBoolean(n))return new et(e,t,n,o);if(o&&this.isPredictionBoolean(n))return new et(e,t,n,o)}else if(_d.includes(t)){if(this.isPredictionBoolean(n))return new sr(e,t,n)}else if(Rd.includes(t)&&this.isPredictionBoolean(n))return new or(e,t,n);this.throwInvalidPredictionException(n,t)};validateFixtureFields=e=>{let t=Object.keys(e);t.forEach(o=>{Pp.includes(o)||this.throwInvalidParamException([o])});let n=Pp.filter(o=>{if(o!=="matchType"&&!t.includes(o))return o});n.length&&this.throwMissingFieldsException("fixtures",n),this.validatePredictionKey(e.market,e.prediction)};validateTiebreaker=e=>{let t=Object.keys(e);(!t.length||typeof e!="object")&&this.throwInvalidType("tiebreaker","object");let n=Object.keys(new ei)[0];t.forEach(o=>{n!==o&&this.throwInvalidParamException([o])}),t.includes(n)||this.throwMissingFieldsException("tiebreaker",[n]),typeof e.goldenGoal!="number"&&this.throwInvalidType("goldenGoal","number")};validatePredictionKey=(e,t)=>{if(typeof t=="object"){let n=Object.keys(t),o=["value"];if(n.length||this.throwMissingFieldsException("prediction",o),n.length===1&&!n.includes(o[0])&&this.throwInvalidParamException(n),n.length>1){wt.includes(e)&&o.push("playerId");let p=n.filter(d=>!o.includes(d));p.length&&this.throwInvalidParamException(p)}}else this.throwInvalidType("prediction","object")};validatePlayerId=(e,t)=>{let n="playerId";e!==Jr&&(t||this.throwInvalidParamException([n]),typeof t!="string"&&this.throwInvalidType(n,"string"))};validateMarket=e=>{Object.values(Pe).includes(e)||this.throwInvalidMarketException(e)};validateMarketTopX=e=>{e!=="CORRECT_SCORE"&&e!=="CORRECT_SCORE_ADVANCED"&&this.throwInvalidMarketException(e,"TOP_X")};isPredictionBoolean=e=>typeof e=="boolean";throwInvalidPredictionException=(e,t)=>{let n=Sd(e,t);throw new he(400,"INVALID_PREDICTION",n)};throwInvalidMarketException=(e,t)=>{let n=null;throw t&&t==="TOP_X"?n=Td(e):n=Go(e),new he(400,"INVALID_MARKET",n)};throwInvalidParamException=e=>{let t=Ed(e);throw new he(400,"INVALID_FIELD",t)};throwMissingFieldsException=(e,t)=>{let n=Cd(e,t);throw new he(400,"INVALID_FIELD",n)};throwInvalidType=(e,t)=>{let n=Ad(e,t);throw new he(400,"INVALID_TYPE",n)}};var ls=class{predictorHttps=null;clientHttps=null;idMapping=null;predictorService=null;predictorValidator=null;constructor(e,t,n,o){this.predictorHttps=t,this.idMapping=o,this.clientHttps=n,this.predictorValidator=new ii,this.predictorService=new vt(e,o)}makeFootballPrediction=async(e,t,n,o)=>{let p=this.predictorValidator.validateFixture(e,t,n,o),d=new dr;if(this.idMapping.idSchema!=="native"){let h=p.matchId,y="",P=await this.predictorService.remapMatchIdToNative([h]);if(p.matchId=P[0],!p.matchId)throw new he(400,"INVALID_FIELD","Match id is invalid!").errorMessage();if(p instanceof et&&(y=p.prediction.playerId,p.prediction.playerId=y&&await this.predictorService.remapPlayerIdToNative([y]),p.market!==Jr&&!p.prediction.playerId))throw new he(400,"INVALID_FIELD","Player id is invalid!").errorMessage();d.fixtures=[p];let b=await this.predictorHttps.makeFootballPrediction(d);return b.fixtures.map(S=>{S.prediction.playerId&&(S.prediction.playerId=y),S.matchId=h}),b}else return d.fixtures=[p],await this.predictorHttps.makeFootballPrediction(d)};getMatchSummary=async(e,t)=>{if(this.idMapping.idSchema!=="native"){let o=(await this.predictorService.remapMatchIdToNative([e]))[0],p=await this.predictorHttps.getMatchSummary(o,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,o)=>{try{let p=await this.getMatchSummary(e,o);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 he(400,"EXCEEDED_LENGTH","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 o=this.predictorService.initPredictionsFilters(t,"user");return await this.predictorHttps.getUserPredictions(e,n,o)};getUserCurrentPredictions=async(e,t,n)=>{let o=this.predictorService.initPredictionsFilters(t,"current");return await this.predictorHttps.getUserPredictions(e,n,o)};getUserPastPredictions=async(e,t,n)=>{let o=this.predictorService.initPredictionsFilters(t,"past");return await this.predictorHttps.getUserPredictions(e,n,o)};getUserPredictionsForMatches=async(e,t,n,o)=>{if(this.predictorService.areIdsExceeded(t))throw new he(400,"EXCEEDED_LENGTH","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,o,p)}};var ps=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(e){this.idMapping=new pe(e),this.predictorHttps=new ti(e,this.idMapping),this.clientHttps=new Ze(e),this.predictorFacade=new ls(e,this.predictorHttps,this.clientHttps,this.idMapping)}makeFootballPrediction=async(e,t,n,o)=>await this.predictorFacade.makeFootballPrediction(e,t,n,o);getMatchSummary=async(e,t)=>await this.predictorFacade.getMatchSummary(e,t);getMarketSummary=async(e,t,n,o)=>await this.predictorFacade.getMarketSummary(e,t,n,o);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,o)=>await this.predictorFacade.getUserPredictionsForMatches(e,t,n,o)};var Od=Kt(Xt());var cs=class{rankType=null;fromDate=null;toDate=null;pagination=new Qi};var fr=class{position=null;profileId=null;profileModel=null;points=null;predictionsMade=null};var us=class{remapResponse=e=>(e.meta=this.remapMeta(e.meta),e.data=this.remapData(e.data),e);remapMeta=e=>{let t=new cs;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 o=new fr;o.position=n.position,o.profileId=n.profile_id,o.points=n.points,o.predictionsMade=n.predictions_made,t.push(o)}),t}};var ms=class extends fr{id=null;rankType=null};var ds=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 o=new ms;o.id=n.id,o.rankType=n.rank_type,o.position=n.position,o.points=n.points,delete o.profileId,delete o.profileModel,delete o.predictionsMade,t.push(o)}),t}};var fs=class{id=null;name=null;description=null;type=null;fromDate=null;toDate=null;markets=[];teamIds=[];matchIds=[];gameIds=[];gameTypes=[];competitionIds=[];rules=null;flags=null;images=new cr};var hs=class{remapResponse=e=>{let t=[];return e.forEach(n=>{let o=new fs;o.id=n.id,o.name=n.name,o.description=n.description,o.type=n.type,o.fromDate=n.from_date,o.toDate=n.to_date,o.markets=n.markets?n.markets:null,o.teamIds=n.team_ids?n.team_ids:null,o.matchIds=n.match_ids?n.match_ids:null,o.gameIds=n.game_ids?n.game_ids:null,o.gameTypes=n.game_types?n.game_types:null,o.competitionIds=n.competition_ids?n.competition_ids:null,o.rules=n.rules?n.rules:null,o.flags=n.flags?n.flags:null,o.images=n.images?n.images:null,t.push(o)}),t};remapMeta=e=>{let t={};return t.totalItems=e.pagination.total_items,t}};var gs=class{position=null;points=null;predictionsMade=null;profileId=null;profileModel=null;successRatePercent=null};var ys=class{remapHighestSuccessRate=e=>e.map(t=>{let n=new gs;return n.position=t.position,n.points=t.points,n.predictionsMade=t.predictions_made,n.profileId=t.profile_id,n.successRatePercent=t.success_rate_percent,n})};var Ms=class{instance=null;apiSignInUrl=null;templateRemapper=null;leaderboardRemapper=null;rankingsRemapper=null;highestSuccessRateRemapper=null;constructor(e){let t=Oe(e.environment,"loyalty");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.templateRemapper=new hs,this.leaderboardRemapper=new us,this.rankingsRemapper=new ds,this.highestSuccessRateRemapper=new ys,this.instance=Od.default.create({baseURL:t,headers:{"Content-Type":"application/json"}})}getTemplates=async(e,t)=>{try{let n=de(e)?`/leaderboard/templates/${this.apiSignInUrl}${fe()}`:`/leaderboard/templates/${this.apiSignInUrl}`,o=await this.instance.get(n);if(t){let p=JSON.parse(JSON.stringify(o.data));return p.meta=this.templateRemapper.remapMeta(o.data.meta),p.data=this.templateRemapper.remapResponse(o.data.data),p}return this.templateRemapper.remapResponse(o.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 o=de(t)?`/leaderboard/${e}/${this.apiSignInUrl}${fe()}`:`/leaderboard/${e}/${this.apiSignInUrl}`;n&&(o+=`${n.constructFiltersUrl()}`);let p=await this.instance.get(o),d=JSON.parse(JSON.stringify(p.data));return this.leaderboardRemapper.remapResponse(d)}catch(o){throw console.warn(`There was a problem fetching the leaderboard for the following template: ${e}`,o),o.response}};getLeaderboardForGame=async(e,t,n)=>{try{let o=de(t)?`/leaderboard/games/${e}/${this.apiSignInUrl}${fe()}`:`/leaderboard/games/${e}/${this.apiSignInUrl}`;n&&(o+=`${n.constructFiltersUrl()}`);let p=await this.instance.get(o),d=JSON.parse(JSON.stringify(p.data));return oa(d)}catch(o){throw console.warn(`There was a problem fetching the leaderboard for the following game: ${e}`,o),o.response}};getUserRankings=async(e,t,n)=>{let o=`/leaderboard/users/${e}/rankings/${this.apiSignInUrl}`;t&&(o+=`${t.constructFiltersUrl()}`),de(n)&&(o+=`${fe()}`);try{let p=await this.instance.get(o);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}};getHighestSuccessRate=async(e,t)=>{let n=de(t)?`/statistics/top${this.apiSignInUrl}${fe()}`:`/statistics/top${this.apiSignInUrl}`;e&&(n+=`&market=${e}`);try{let o=await this.instance.get(n);return this.highestSuccessRateRemapper.remapHighestSuccessRate(o.data.data)}catch(o){throw console.warn("There was a problem fetching highest success rate",o),o.response}}};var ws=class{general;predictor;topX;matchQuiz};var hr=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 bs=class extends hr{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 vs=class{idMappingService=null;profileNamespace=null;constructor(e){this.idMappingService=new pe(e),this.profileNamespace=new tr(e)}remapTemplatesIds=async e=>{if(e.length>0){let t=[],n=[],o=[],p=[],d=[],h=[];e.forEach(b=>{b.teamIds&&b.teamIds.length>0?t=[...t,...b.teamIds]:b.matchIds&&b.matchIds.length>0?o=[...o,...b.matchIds]:b.competitionIds&&b.competitionIds.length>0&&(d=[...d,...b.competitionIds])});let y={team:t,match:o,competition:d},P=await this.idMappingService.idMappingFacade.getEntitiesByIds(y,"native",this.idMappingService.idSchema);return n=[...P.team],p=[...P.match],h=[...P.competition],e.forEach(b=>{b.teamIds&&b.teamIds.length>0?b.teamIds=b.teamIds.map(S=>S=P.team.shift()):b.matchIds&&b.matchIds.length>0?b.matchIds=b.matchIds.map(S=>S=P.match.shift()):b.competitionIds&&b.competitionIds.length>0&&(b.competitionIds=b.competitionIds.map(S=>S=P.competition.shift()))}),e}return e};addProfileModelToLeaderboad=async e=>{if(e.length>0){let t=[],n=[];e.forEach(p=>{t.push(p.profileId)});let o=await this.profileNamespace.getByIds(t);return e.forEach(p=>{o.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 ws;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 hr(e));break;case"rankings":e&&(e=new bs(e));break}return e};addProfileModelToHighestSuccessRate=async e=>{let t=e.map(o=>o.profileId),n=await this.profileNamespace.getByIds(t);return e.map(o=>(n.forEach(p=>{p.id===o.profileId&&(delete p.interests,o.profileModel=p)}),o))};extractEnabledBadgesId=e=>{let t=[];return e.forEach(n=>{n.enabled&&t.push(n.id)}),t}};var Is=class{validateMarket=e=>{if(!Object.keys(Pe).includes(e)){let n=Go(e);throw new he(400,"INVALID_MARKET",n)}}};var Ps=class{config=null;clientHttps=null;loyaltyHttps=null;loyaltyService=null;profileFacade=null;loyaltyValidator=null;constructor(e,t,n,o,p){this.config=e,this.clientHttps=t,this.loyaltyHttps=n,this.profileFacade=new yt(p,o),this.loyaltyService=new vs(this.config),this.loyaltyValidator=new Is}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 he(400,"INVALID_TEMPLATE","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 o=await this.loyaltyHttps.getLeaderboard(e,n,t);return o.data=await this.loyaltyService.addProfileModelToLeaderboad(o.data),o};getLeaderboardForGame=async(e,t,n)=>{t=this.loyaltyService.initFilters(t,"loyalty");let o=await this.loyaltyHttps.getLeaderboardForGame(e,n,t);return o.data=await this.loyaltyService.addProfileModelToLeaderboad(o.data),o};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));getHighestSuccessRate=async(e,t)=>{e&&this.loyaltyValidator.validateMarket(e);let n=await this.loyaltyHttps.getHighestSuccessRate(e,t);return this.loyaltyService.addProfileModelToHighestSuccessRate(n)}};var _s=class{clientHttps=null;profileHttps=null;loyaltyHttps=null;loyaltyFacade=null;localStorage=null;constructor(e){this.clientHttps=new Ze(e),this.profileHttps=new Gi(e),this.loyaltyHttps=new Ms(e),this.localStorage=new gt(e),this.loyaltyFacade=new Ps(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);getHighestSuccessRate=async(e,t)=>await this.loyaltyFacade.getHighestSuccessRate(e,t)};var Rs=class{idMapping=null;predictorHttps=null;predictorService=null;predictorValidator=null;clientHttps=null;constructor(e,t){this.idMapping=t,this.predictorValidator=new ii,this.predictorHttps=new ti(e,t),this.predictorService=new vt(e,t),this.clientHttps=new Ze(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),o=await this.predictorHttps.getGames(n,t);return await this.predictorService.remapMatchIdsFixtures(o)};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=new it(t));let o=await this.predictorHttps.getGameResults(e,n,t);return await this.predictorService.remapMatchIdsFixtures(o)};getCurrentGameResults=async e=>{e=e||!1;let t={status:"OPEN",type:"TOP_X"};t=new it(t);let n=await this.predictorHttps.getGames(t,e),o=this.predictorService.getCurrentGameId(n);return(await this.getGameResults(o,null,e)).data[0]};play=async e=>{let t=new ur(e);if(t=this.predictorValidator.validateBodyFields("TOP_X",t),t.fixtures=t.fixtures.map(o=>this.predictorValidator.validateFixture(o.matchId,o.market,o.prediction.value)),this.idMapping.idSchema!=="native"){let o=[];t.fixtures.forEach(d=>o.push(d.matchId));let p=await this.predictorService.remapMatchIdToNative(o);t.fixtures.forEach(d=>d.matchId=p.shift())}let n=await this.predictorHttps.makeFootballPrediction(t);return n.fixtures.forEach(o=>{o.matchId=o.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"),o=[],p=await this.predictorHttps.getMyPredictionsNoRemap(n);if(p.length>0){p.forEach(y=>{y.game_instance_id&&o.push(y.game_instance_id)});let d=this.predictorService.initGameFilters("TOP_X",e,o),h=await this.predictorHttps.getUserGameEditions(d,t);return await this.predictorService.addPredictionProp(p,h)}else return new re};getMyGamePrediction=async e=>{let t=this.predictorService.initGameTypePredictions("TOP_X"),n=await this.predictorHttps.getMyPredictions(t);if(n.data.length>0){let o=n.data.filter(p=>p.gameInstanceId===e);return o.length?o[0]:null}return null};getUserGameEditions=async(e,t,n)=>{n=n||!1;let o=this.predictorService.initGameTypePredictions("TOP_X"),p=[],d=await this.predictorHttps.getUserPredictionsNoRemap(e,o);if(d.length>0){d.forEach(P=>{P.game_instance_id&&p.push(P.game_instance_id)});let h=this.predictorService.initGameFilters("TOP_X",t,p),y=await this.predictorHttps.getUserGameEditions(h,n);return await this.predictorService.addPredictionProp(d,y)}else return new re};getUserGamePrediction=async(e,t,n)=>{n=n||!1;let o=this.predictorService.initGameTypePredictions("TOP_X"),p=await this.predictorHttps.getUserPredictions(e,n,o);if(p.data.length>0){let d=p.data.filter(h=>h.gameInstanceId===t);return d.length?d[0]:null}else return null};getMarketsResultsForGame=async(e,t)=>{let n=await this.predictorHttps.getMarketResultsForGame(e,t);return await this.predictorService.completeGameMarketResults(n,"TOP_X")}};var Fs=class{topXFacade=null;idMapping=null;constructor(e){this.idMapping=new pe(e),this.topXFacade=new Rs(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 Ss=class{predictorHttps=null;predictorService=null;idMapping=null;clientHttps=null;predictorValidator=null;constructor(e){this.predictorValidator=new ii,this.idMapping=new pe(e),this.predictorHttps=new ti(e,this.idMapping),this.predictorService=new vt(e,this.idMapping),this.clientHttps=new Ze(e)}getConfig=async()=>{let e=await this.clientHttps.getConfig("matchQuiz");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(e):e};play=async e=>{e=this.predictorValidator.validateBodyFields("MATCH_QUIZ",e);let t=e.fixtures.map(n=>this.predictorValidator.validateFixture(n.matchId,n.market,n.prediction.value,n.prediction.playerId));if(t&&t.length&&this.idMapping.idSchema!=="native"){let n=[],o=[];t.forEach(h=>{n.push(h.matchId),h instanceof et&&h.prediction.playerId&&o.push(h.prediction.playerId)});let p=await this.predictorService.remapMatchIdToNative(n),d={};o&&o.length>0&&(d=await this.predictorService.remapPlayerIdMapToNative(o)),t.forEach((h,y)=>{h.matchId=p[y],h instanceof et&&(h.prediction.playerId=d[h.prediction.playerId])})}return e.fixtures=t,await this.predictorHttps.makeFootballPrediction(e)};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getGames=async(e,t)=>{t=t||!1;let n=this.predictorService.initGameFilters("MATCH_QUIZ",e),o=await this.predictorHttps.getGames(n,t);return await this.predictorService.remapMatchIdsFixtures(o)};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=new pr(t));let o=await this.predictorHttps.getGameResults(e,n,t);return await this.predictorService.remapMatchIdsFixtures(o)};getCurrentGameResults=async e=>{e=e||!1;let t={status:"OPEN",type:"MATCH_QUIZ"};t=new it(t);let n=await this.predictorHttps.getGames(t,e),o=this.predictorService.getCurrentGameId(n);return(await this.getGameResults(o,null,e)).data[0]};getMyGameEditions=async(e,t)=>{t=t||!1;let n=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),o=[],p=await this.predictorHttps.getMyPredictionsNoRemap(n);if(p.length>0){p.forEach(y=>{y.game_instance_id&&o.push(y.game_instance_id)});let d=this.predictorService.initGameFilters("MATCH_QUIZ",e,o),h=await this.predictorHttps.getUserGameEditions(d,t);return await this.predictorService.addPredictionProp(p,h)}else return new re};getMyGamePrediction=async e=>{let t=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),n=await this.predictorHttps.getMyPredictions(t);if(n.data.length>0){let o=n.data.filter(p=>p.gameInstanceId===e);return o.length?o[0]:null}return null};getUserGameEditions=async(e,t,n)=>{n=n||!1;let o=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),p=[],d=await this.predictorHttps.getUserPredictionsNoRemap(e,o);if(d.length>0){d.forEach(P=>{P.game_instance_id&&p.push(P.game_instance_id)});let h=this.predictorService.initGameFilters("MATCH_QUIZ",t,p),y=await this.predictorHttps.getUserGameEditions(h,n);return await this.predictorService.addPredictionProp(d,y)}else return new re};getUserGamePrediction=async(e,t,n)=>{n=n||!1;let o=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),p=await this.predictorHttps.getUserPredictions(e,n,o);if(p.data.length>0){let d=p.data.filter(h=>h.gameInstanceId===t);return d.length?d[0]:null}else return null};getMarketsResultsForGame=async(e,t)=>{let n=await this.predictorHttps.getMarketResultsForGame(e,t);return await this.predictorService.completeGameMarketResults(n,"MATCH_QUIZ")}};var Ts=class{matchQuizFacade=null;constructor(e){this.matchQuizFacade=new Ss(e)}getConfig=async()=>await this.matchQuizFacade.getConfig();play=async e=>await this.matchQuizFacade.play(e);delete=async e=>await this.matchQuizFacade.delete(e);getGames=async(e,t)=>await this.matchQuizFacade.getGames(e,t);getGameById=async(e,t)=>await this.matchQuizFacade.getGameById(e,t);getGamePredictions=async(e,t,n)=>await this.matchQuizFacade.getGamePredictions(e,t,n);getGameResults=async(e,t,n)=>await this.matchQuizFacade.getGameResults(e,t,n);getCurrentGameResults=async e=>await this.matchQuizFacade.getCurrentGameResults(e);getMyGameEditions=async(e,t)=>await this.matchQuizFacade.getMyGameEditions(e,t);getMyGamePrediction=async e=>await this.matchQuizFacade.getMyGamePrediction(e);getUserGameEditions=async(e,t,n)=>await this.matchQuizFacade.getUserGameEditions(e,t,n);getUserGamePrediction=async(e,t,n)=>await this.matchQuizFacade.getUserGamePrediction(e,t,n);getMarketsResultsForGame=async(e,t)=>await this.matchQuizFacade.getMarketsResultsForGame(e,t)};var rn=class{action=null;page=null;limit=null;constructor(e){this.action=e.action?e.action:null,this.page=e.page?e.page:null,this.limit=e.limit?e.limit:null}constructFilterUrl=()=>{let e="";return this.action&&(e+="&",e+=`action=${this.action}`),this.page&&(e+="&",e+=`page=${this.page}`),this.limit&&(e+="&",e+=`limit=${this.limit}`),e}};var nn=class{action=null;context=new ji;constructor(e,t,n,o){this.action=e,this.context.tags=t,n&&(this.context.content=n),o&&(this.context.campaign=o)}};var Es=class{idSchema;idMapping;constructor(e){this.idSchema=e.idSchema,this.idMapping=new pe(e)}remapTagsIds=async(e,t,n)=>{let o={},p={},d=[];e.forEach(y=>{o.hasOwnProperty(y.type)||(o[y.type]=[],p[y.type]=[]),o[y.type].push(y.id),p[y.type].push(y)});let h=await this.idMapping.idMappingFacade.getEntitiesByIds(o,t,n);for(let[y,P]of Object.entries(p))P.forEach((b,S)=>{b.id=h[y][S],d.push(b)});return d}};var Cs=class{idSchema;activityHttps;activityService;constructor(e){this.idSchema=e.idSchema,this.activityHttps=new er(e),this.activityService=new Es(e)}add=async(e,t,n,o)=>{if(this.idSchema!="native"){let d=JSON.parse(JSON.stringify(t)),h=await this.activityService.remapTagsIds(t,this.idSchema,"native"),y=new nn(e,h,n,o),P=await this.activityHttps.createActivity(y);return P.context.tags=d,P}let p=new nn(e,t,n,o);return this.activityHttps.createActivity(p)};delete=async e=>await this.activityHttps.deleteActivity(e);like=async(e,t,n)=>{let o="like";return await this.add(o,e,t,n)};dislike=async(e,t,n)=>{let o="dislike";return await this.add(o,e,t,n)};addPageview=async(e,t,n)=>{let o="page_view";return await this.add(o,e,t,n)};addContentConsumed=async(e,t,n)=>{let o="content_consumed";return await this.add(o,e,t,n)};addShare=async(e,t,n)=>{let o="share";return await this.add(o,e,t,n)};addComment=async(e,t,n)=>{let o="comment";return await this.add(o,e,t,n)};addClickAd=async(e,t,n)=>{let o="click_ad";return await this.add(o,e,t,n)};addConversion=async(e,t,n)=>{let o="conversion";return await this.add(o,e,t,n)};getOwn=async(e,t)=>{if(t=t||!1,e&&(e=new rn(e)),this.idSchema!="native"){let n=await this.activityHttps.getOwnActivities(e,t);for(let o of n.data)await this.activityService.remapTagsIds(o.context.tags,"native",this.idSchema);return n}return await this.activityHttps.getOwnActivities(e,t)};getForUser=async(e,t,n)=>{if(n=n||!1,t&&(t=new rn(t)),this.idSchema!="native"){let o=await this.activityHttps.getActivitiesForUser(e,t,n);for(let p of o.data)await this.activityService.remapTagsIds(p.context.tags,"native",this.idSchema);return o}return await this.activityHttps.getActivitiesForUser(e,t,n)}};var As=class{activityFacade;constructor(e){this.activityFacade=new Cs(e)}add=async(e,t,n,o)=>await this.activityFacade.add(e,t,n,o);delete=async e=>await this.activityFacade.delete(e);like=async(e,t,n)=>await this.activityFacade.like(e,t,n);dislike=async(e,t,n)=>await this.activityFacade.dislike(e,t,n);addPageview=async(e,t,n)=>await this.activityFacade.addPageview(e,t,n);addContentConsumed=async(e,t,n)=>await this.activityFacade.addContentConsumed(e,t,n);addShare=async(e,t,n)=>await this.activityFacade.addShare(e,t,n);addComment=async(e,t,n)=>await this.activityFacade.addComment(e,t,n);addClickAd=async(e,t,n)=>await this.activityFacade.addClickAd(e,t,n);addConversion=async(e,t,n)=>await this.activityFacade.addConversion(e,t,n);getOwn=async(e,t)=>await this.activityFacade.getOwn(e,t);getForUser=async(e,t,n)=>await this.activityFacade.getForUser(e,t,n)};function eB(s){let t=new xo().validate(s);if((t.idSchema.validation==="missing"||t.idSchema.validation==="invalid")&&(console.warn(t.idSchema.message.text),s.idSchema="native"),(t.environment.validation==="missing"||t.environment.validation==="invalid")&&(console.warn(t.environment.message.text),s.environment="prod"),(t.lang.validation==="missing"||t.lang.validation==="invalid")&&(console.warn(t.lang.message.text),s.lang="en"),t.authProvider.validation==="invalid"&&console.warn(t.authProvider.message.text),t.isValid)return{profile:new tr(s),football:new Oo(s),predictor:new ps(s),loyalty:new _s(s),topX:new Fs(s),matchQuiz:new Ts(s),activity:new As(s)};OI(t)}var OI=s=>{let e="authProvider",t="isValid";Object.keys(s).forEach(n=>{let o=s[n];if(n!==t&&n!==e){if(o.message.type==="error")throw new Error(o.message.text)}else n!==t&&n===e&&Object.keys(new hi).forEach(p=>{if(o[p].message.type==="error")throw new Error(o[p].message.text)})})};export{eB as FansUnitedSDK};
24
24
  /**