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