fansunited-sdk-esm 1.15.2 → 1.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/index.js.map +2 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -18,7 +18,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
18
18
|
`:`;
|
|
19
19
|
`)+F+`return __p
|
|
20
20
|
}`;var U=pm(function(){return V(m,C+"return "+F).apply(s,f)});if(U.source=F,Kl(U))throw U;return U}function Ub(i){return W(i).toLowerCase()}function Gb(i){return W(i).toUpperCase()}function kb(i,r,a){if(i=W(i),i&&(a||r===s))return Mc(i);if(!i||!(r=Ge(r)))return i;var l=ot(i),c=ot(r),m=wc(l,c),f=bc(l,c)+1;return Wt(l,m,f).join("")}function Hb(i,r,a){if(i=W(i),i&&(a||r===s))return i.slice(0,Ic(i)+1);if(!i||!(r=Ge(r)))return i;var l=ot(i),c=bc(l,ot(r))+1;return Wt(l,0,c).join("")}function $b(i,r,a){if(i=W(i),i&&(a||r===s))return i.replace(Ks,"");if(!i||!(r=Ge(r)))return i;var l=ot(i),c=wc(l,ot(r));return Wt(l,c).join("")}function Vb(i,r){var a=Ld,l=Nd;if(Z(r)){var c="separator"in r?r.separator:c;a="length"in r?D(r.length):a,l="omission"in r?Ge(r.omission):l}i=W(i);var m=i.length;if(Ii(i)){var f=ot(i);m=f.length}if(a>=m)return i;var g=a-Pi(l);if(g<1)return l;var w=f?Wt(f,0,g).join(""):i.slice(0,g);if(c===s)return w+l;if(f&&(g+=w.length-g),Xl(c)){if(i.slice(g).search(c)){var _,R=w;for(c.global||(c=pl(c.source,W(kp.exec(c))+"g")),c.lastIndex=0;_=c.exec(R);)var F=_.index;w=w.slice(0,F===s?g:F)}}else if(i.indexOf(Ge(c),g)!=g){var T=w.lastIndexOf(c);T>-1&&(w=w.slice(0,T))}return w+l}function qb(i){return i=W(i),i&&ef.test(i)?i.replace(Dp,wh):i}var Wb=Ei(function(i,r,a){return i+(a?" ":"")+r.toUpperCase()}),zl=cu("toUpperCase");function lm(i,r,a){return i=W(i),r=a?s:r,r===s?fh(i)?Ih(i):ah(i):i.match(r)||[]}var pm=G(function(i,r){try{return De(i,s,r)}catch(a){return Kl(a)?a:new B(a)}}),Kb=Et(function(i,r){return Xe(r,function(a){a=ht(a),St(i,a,ql(i[a],i))}),i});function Xb(i){var r=i==null?0:i.length,a=A();return i=r?J(i,function(l){if(typeof l[1]!="function")throw new Ye(o);return[a(l[0]),l[1]]}):[],G(function(l){for(var c=-1;++c<r;){var m=i[c];if(De(m[0],this,l))return De(m[1],this,l)}})}function Yb(i){return wg(ze(i,I))}function Jl(i){return function(){return i}}function Qb(i,r){return i==null||i!==i?r:i}var zb=mu(),Jb=mu(!0);function xe(i){return i}function Zl(i){return $c(typeof i=="function"?i:ze(i,I))}function Zb(i){return qc(ze(i,I))}function jb(i,r){return Wc(i,ze(r,I))}var ev=G(function(i,r){return function(a){return Or(a,i,r)}}),tv=G(function(i,r){return function(a){return Or(i,a,r)}});function jl(i,r,a){var l=ce(r),c=Bn(r,l);a==null&&!(Z(r)&&(c.length||!l.length))&&(a=r,r=i,i=this,c=Bn(r,ce(r)));var m=!(Z(a)&&"chain"in a)||!!a.chain,f=At(i);return Xe(c,function(g){var w=r[g];i[g]=w,f&&(i.prototype[g]=function(){var _=this.__chain__;if(m||_){var R=i(this.__wrapped__),F=R.__actions__=Ee(this.__actions__);return F.push({func:w,args:arguments,thisArg:i}),R.__chain__=_,R}return w.apply(i,Ut([this.value()],arguments))})}),i}function iv(){return pe._===this&&(pe._=Th),this}function ep(){}function rv(i){return i=D(i),G(function(r){return Kc(r,i)})}var nv=Al(J),av=Al(dc),ov=Al(il);function cm(i){return Ul(i)?rl(ht(i)):Ng(i)}function sv(i){return function(r){return i==null?s:li(i,r)}}var lv=fu(),pv=fu(!0);function tp(){return[]}function ip(){return!1}function cv(){return{}}function uv(){return""}function mv(){return!0}function dv(i,r){if(i=D(i),i<1||i>N)return[];var a=mt,l=ge(i,mt);r=A(r),i-=mt;for(var c=ol(l,r);++a<i;)r(a);return c}function fv(i){return L(i)?J(i,ht):ke(i)?[i]:Ee(Cu(W(i)))}function hv(i){var r=++Fh;return W(i)+r}var gv=kn(function(i,r){return i+r},0),yv=xl("ceil"),Mv=kn(function(i,r){return i/r},1),wv=xl("floor");function bv(i){return i&&i.length?On(i,xe,yl):s}function vv(i,r){return i&&i.length?On(i,A(r,2),yl):s}function Iv(i){return gc(i,xe)}function Pv(i,r){return gc(i,A(r,2))}function _v(i){return i&&i.length?On(i,xe,vl):s}function Rv(i,r){return i&&i.length?On(i,A(r,2),vl):s}var Fv=kn(function(i,r){return i*r},1),Sv=xl("round"),Tv=kn(function(i,r){return i-r},0);function Ev(i){return i&&i.length?al(i,xe):0}function Cv(i,r){return i&&i.length?al(i,A(r,2)):0}return u.after=ZM,u.ary=Hu,u.assign=Gw,u.assignIn=tm,u.assignInWith=jn,u.assignWith=kw,u.at=Hw,u.before=$u,u.bind=ql,u.bindAll=Kb,u.bindKey=Vu,u.castArray=cw,u.chain=Uu,u.chunk=wy,u.compact=by,u.concat=vy,u.cond=Xb,u.conforms=Yb,u.constant=Jl,u.countBy=EM,u.create=$w,u.curry=qu,u.curryRight=Wu,u.debounce=Ku,u.defaults=Vw,u.defaultsDeep=qw,u.defer=jM,u.delay=ew,u.difference=Iy,u.differenceBy=Py,u.differenceWith=_y,u.drop=Ry,u.dropRight=Fy,u.dropRightWhile=Sy,u.dropWhile=Ty,u.fill=Ey,u.filter=AM,u.flatMap=BM,u.flatMapDeep=LM,u.flatMapDepth=NM,u.flatten=Bu,u.flattenDeep=Cy,u.flattenDepth=Ay,u.flip=tw,u.flow=zb,u.flowRight=Jb,u.fromPairs=xy,u.functions=Jw,u.functionsIn=Zw,u.groupBy=DM,u.initial=By,u.intersection=Ly,u.intersectionBy=Ny,u.intersectionWith=Dy,u.invert=eb,u.invertBy=tb,u.invokeMap=GM,u.iteratee=Zl,u.keyBy=kM,u.keys=ce,u.keysIn=Ae,u.map=Xn,u.mapKeys=rb,u.mapValues=nb,u.matches=Zb,u.matchesProperty=jb,u.memoize=Qn,u.merge=ab,u.mergeWith=im,u.method=ev,u.methodOf=tv,u.mixin=jl,u.negate=zn,u.nthArg=rv,u.omit=ob,u.omitBy=sb,u.once=iw,u.orderBy=HM,u.over=nv,u.overArgs=rw,u.overEvery=av,u.overSome=ov,u.partial=Wl,u.partialRight=Xu,u.partition=$M,u.pick=lb,u.pickBy=rm,u.property=cm,u.propertyOf=sv,u.pull=Hy,u.pullAll=Nu,u.pullAllBy=$y,u.pullAllWith=Vy,u.pullAt=qy,u.range=lv,u.rangeRight=pv,u.rearg=nw,u.reject=WM,u.remove=Wy,u.rest=aw,u.reverse=$l,u.sampleSize=XM,u.set=cb,u.setWith=ub,u.shuffle=YM,u.slice=Ky,u.sortBy=JM,u.sortedUniq=jy,u.sortedUniqBy=eM,u.split=Bb,u.spread=ow,u.tail=tM,u.take=iM,u.takeRight=rM,u.takeRightWhile=nM,u.takeWhile=aM,u.tap=bM,u.throttle=sw,u.thru=Kn,u.toArray=Zu,u.toPairs=nm,u.toPairsIn=am,u.toPath=fv,u.toPlainObject=em,u.transform=mb,u.unary=lw,u.union=oM,u.unionBy=sM,u.unionWith=lM,u.uniq=pM,u.uniqBy=cM,u.uniqWith=uM,u.unset=db,u.unzip=Vl,u.unzipWith=Du,u.update=fb,u.updateWith=hb,u.values=xi,u.valuesIn=gb,u.without=mM,u.words=lm,u.wrap=pw,u.xor=dM,u.xorBy=fM,u.xorWith=hM,u.zip=gM,u.zipObject=yM,u.zipObjectDeep=MM,u.zipWith=wM,u.entries=nm,u.entriesIn=am,u.extend=tm,u.extendWith=jn,jl(u,u),u.add=gv,u.attempt=pm,u.camelCase=bb,u.capitalize=om,u.ceil=yv,u.clamp=yb,u.clone=uw,u.cloneDeep=dw,u.cloneDeepWith=fw,u.cloneWith=mw,u.conformsTo=hw,u.deburr=sm,u.defaultTo=Qb,u.divide=Mv,u.endsWith=vb,u.eq=lt,u.escape=Ib,u.escapeRegExp=Pb,u.every=CM,u.find=xM,u.findIndex=xu,u.findKey=Ww,u.findLast=OM,u.findLastIndex=Ou,u.findLastKey=Kw,u.floor=wv,u.forEach=Gu,u.forEachRight=ku,u.forIn=Xw,u.forInRight=Yw,u.forOwn=Qw,u.forOwnRight=zw,u.get=Yl,u.gt=gw,u.gte=yw,u.has=jw,u.hasIn=Ql,u.head=Lu,u.identity=xe,u.includes=UM,u.indexOf=Oy,u.inRange=Mb,u.invoke=ib,u.isArguments=ui,u.isArray=L,u.isArrayBuffer=Mw,u.isArrayLike=Ce,u.isArrayLikeObject=te,u.isBoolean=ww,u.isBuffer=Kt,u.isDate=bw,u.isElement=vw,u.isEmpty=Iw,u.isEqual=Pw,u.isEqualWith=_w,u.isError=Kl,u.isFinite=Rw,u.isFunction=At,u.isInteger=Yu,u.isLength=Jn,u.isMap=Qu,u.isMatch=Fw,u.isMatchWith=Sw,u.isNaN=Tw,u.isNative=Ew,u.isNil=Aw,u.isNull=Cw,u.isNumber=zu,u.isObject=Z,u.isObjectLike=ee,u.isPlainObject=Gr,u.isRegExp=Xl,u.isSafeInteger=xw,u.isSet=Ju,u.isString=Zn,u.isSymbol=ke,u.isTypedArray=Ai,u.isUndefined=Ow,u.isWeakMap=Bw,u.isWeakSet=Lw,u.join=Uy,u.kebabCase=_b,u.last=Ze,u.lastIndexOf=Gy,u.lowerCase=Rb,u.lowerFirst=Fb,u.lt=Nw,u.lte=Dw,u.max=bv,u.maxBy=vv,u.mean=Iv,u.meanBy=Pv,u.min=_v,u.minBy=Rv,u.stubArray=tp,u.stubFalse=ip,u.stubObject=cv,u.stubString=uv,u.stubTrue=mv,u.multiply=Fv,u.nth=ky,u.noConflict=iv,u.noop=ep,u.now=Yn,u.pad=Sb,u.padEnd=Tb,u.padStart=Eb,u.parseInt=Cb,u.random=wb,u.reduce=VM,u.reduceRight=qM,u.repeat=Ab,u.replace=xb,u.result=pb,u.round=Sv,u.runInContext=M,u.sample=KM,u.size=QM,u.snakeCase=Ob,u.some=zM,u.sortedIndex=Xy,u.sortedIndexBy=Yy,u.sortedIndexOf=Qy,u.sortedLastIndex=zy,u.sortedLastIndexBy=Jy,u.sortedLastIndexOf=Zy,u.startCase=Lb,u.startsWith=Nb,u.subtract=Tv,u.sum=Ev,u.sumBy=Cv,u.template=Db,u.times=dv,u.toFinite=xt,u.toInteger=D,u.toLength=ju,u.toLower=Ub,u.toNumber=je,u.toSafeInteger=Uw,u.toString=W,u.toUpper=Gb,u.trim=kb,u.trimEnd=Hb,u.trimStart=$b,u.truncate=Vb,u.unescape=qb,u.uniqueId=hv,u.upperCase=Wb,u.upperFirst=zl,u.each=Gu,u.eachRight=ku,u.first=Lu,jl(u,function(){var i={};return dt(u,function(r,a){X.call(u.prototype,a)||(i[a]=r)}),i}(),{chain:!1}),u.VERSION=e,Xe(["bind","bindKey","curry","curryRight","partial","partialRight"],function(i){u[i].placeholder=u}),Xe(["drop","take"],function(i,r){H.prototype[i]=function(a){a=a===s?1:le(D(a),0);var l=this.__filtered__&&!r?new H(this):this.clone();return l.__filtered__?l.__takeCount__=ge(a,l.__takeCount__):l.__views__.push({size:ge(a,mt),type:i+(l.__dir__<0?"Right":"")}),l},H.prototype[i+"Right"]=function(a){return this.reverse()[i](a).reverse()}}),Xe(["filter","map","takeWhile"],function(i,r){var a=r+1,l=a==Bp||a==kd;H.prototype[i]=function(c){var m=this.clone();return m.__iteratees__.push({iteratee:A(c,3),type:a}),m.__filtered__=m.__filtered__||l,m}}),Xe(["head","last"],function(i,r){var a="take"+(r?"Right":"");H.prototype[i]=function(){return this[a](1).value()[0]}}),Xe(["initial","tail"],function(i,r){var a="drop"+(r?"":"Right");H.prototype[i]=function(){return this.__filtered__?new H(this):this[a](1)}}),H.prototype.compact=function(){return this.filter(xe)},H.prototype.find=function(i){return this.filter(i).head()},H.prototype.findLast=function(i){return this.reverse().find(i)},H.prototype.invokeMap=G(function(i,r){return typeof i=="function"?new H(this):this.map(function(a){return Or(a,i,r)})}),H.prototype.reject=function(i){return this.filter(zn(A(i)))},H.prototype.slice=function(i,r){i=D(i);var a=this;return a.__filtered__&&(i>0||r<0)?new H(a):(i<0?a=a.takeRight(-i):i&&(a=a.drop(i)),r!==s&&(r=D(r),a=r<0?a.dropRight(-r):a.take(r-i)),a)},H.prototype.takeRightWhile=function(i){return this.reverse().takeWhile(i).reverse()},H.prototype.toArray=function(){return this.take(mt)},dt(H.prototype,function(i,r){var a=/^(?:filter|find|map|reject)|While$/.test(r),l=/^(?:head|last)$/.test(r),c=u[l?"take"+(r=="last"?"Right":""):r],m=l||/^find/.test(r);!c||(u.prototype[r]=function(){var f=this.__wrapped__,g=l?[1]:arguments,w=f instanceof H,_=g[0],R=w||L(f),F=function(k){var $=c.apply(u,Ut([k],g));return l&&T?$[0]:$};R&&a&&typeof _=="function"&&_.length!=1&&(w=R=!1);var T=this.__chain__,C=!!this.__actions__.length,x=m&&!T,U=w&&!C;if(!m&&R){f=U?f:new H(this);var O=i.apply(f,g);return O.__actions__.push({func:Kn,args:[F],thisArg:s}),new Qe(O,T)}return x&&U?i.apply(this,g):(O=this.thru(F),x?l?O.value()[0]:O.value():O)})}),Xe(["pop","push","shift","sort","splice","unshift"],function(i){var r=Mn[i],a=/^(?:push|sort|unshift)$/.test(i)?"tap":"thru",l=/^(?:pop|shift)$/.test(i);u.prototype[i]=function(){var c=arguments;if(l&&!this.__chain__){var m=this.value();return r.apply(L(m)?m:[],c)}return this[a](function(f){return r.apply(L(f)?f:[],c)})}}),dt(H.prototype,function(i,r){var a=u[r];if(a){var l=a.name+"";X.call(Fi,l)||(Fi[l]=[]),Fi[l].push({name:r,func:a})}}),Fi[Gn(s,ct).name]=[{name:"wrapper",func:s}],H.prototype.clone=qh,H.prototype.reverse=Wh,H.prototype.value=Kh,u.prototype.at=vM,u.prototype.chain=IM,u.prototype.commit=PM,u.prototype.next=_M,u.prototype.plant=FM,u.prototype.reverse=SM,u.prototype.toJSON=u.prototype.valueOf=u.prototype.value=TM,u.prototype.first=u.prototype.head,Fr&&(u.prototype[Fr]=RM),u},kt=Ph();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(pe._=kt,define(function(){return kt})):ri?((ri.exports=kt)._=kt,Zs._=kt):pe._=kt}).call(Oi)});var ap=K((rP,gm)=>{"use strict";gm.exports=function(e,t){return function(){for(var o=new Array(arguments.length),p=0;p<o.length;p++)o[p]=arguments[p];return e.apply(t,o)}}});var Be=K((nP,wm)=>{"use strict";var Uv=ap(),mi=Object.prototype.toString;function op(s){return mi.call(s)==="[object Array]"}function sp(s){return typeof s=="undefined"}function Gv(s){return s!==null&&!sp(s)&&s.constructor!==null&&!sp(s.constructor)&&typeof s.constructor.isBuffer=="function"&&s.constructor.isBuffer(s)}function kv(s){return mi.call(s)==="[object ArrayBuffer]"}function Hv(s){return typeof FormData!="undefined"&&s instanceof FormData}function $v(s){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(s):e=s&&s.buffer&&s.buffer instanceof ArrayBuffer,e}function Vv(s){return typeof s=="string"}function qv(s){return typeof s=="number"}function ym(s){return s!==null&&typeof s=="object"}function pa(s){if(mi.call(s)!=="[object Object]")return!1;var e=Object.getPrototypeOf(s);return e===null||e===Object.prototype}function Wv(s){return mi.call(s)==="[object Date]"}function Kv(s){return mi.call(s)==="[object File]"}function Xv(s){return mi.call(s)==="[object Blob]"}function Mm(s){return mi.call(s)==="[object Function]"}function Yv(s){return ym(s)&&Mm(s.pipe)}function Qv(s){return typeof URLSearchParams!="undefined"&&s instanceof URLSearchParams}function zv(s){return s.trim?s.trim():s.replace(/^\s+|\s+$/g,"")}function Jv(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function lp(s,e){if(!(s===null||typeof s=="undefined"))if(typeof s!="object"&&(s=[s]),op(s))for(var t=0,n=s.length;t<n;t++)e.call(null,s[t],t,s);else for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&e.call(null,s[o],o,s)}function pp(){var s={};function e(o,p){pa(s[p])&&pa(o)?s[p]=pp(s[p],o):pa(o)?s[p]=pp({},o):op(o)?s[p]=o.slice():s[p]=o}for(var t=0,n=arguments.length;t<n;t++)lp(arguments[t],e);return s}function Zv(s,e,t){return lp(e,function(o,p){t&&typeof o=="function"?s[p]=Uv(o,t):s[p]=o}),s}function jv(s){return s.charCodeAt(0)===65279&&(s=s.slice(1)),s}wm.exports={isArray:op,isArrayBuffer:kv,isBuffer:Gv,isFormData:Hv,isArrayBufferView:$v,isString:Vv,isNumber:qv,isObject:ym,isPlainObject:pa,isUndefined:sp,isDate:Wv,isFile:Kv,isBlob:Xv,isFunction:Mm,isStream:Yv,isURLSearchParams:Qv,isStandardBrowserEnv:Jv,forEach:lp,merge:pp,extend:Zv,trim:zv,stripBOM:jv}});var cp=K((aP,vm)=>{"use strict";var Li=Be();function bm(s){return encodeURIComponent(s).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}vm.exports=function(e,t,n){if(!t)return e;var o;if(n)o=n(t);else if(Li.isURLSearchParams(t))o=t.toString();else{var p=[];Li.forEach(t,function(y,I){y===null||typeof y=="undefined"||(Li.isArray(y)?I=I+"[]":y=[y],Li.forEach(y,function(S){Li.isDate(S)?S=S.toISOString():Li.isObject(S)&&(S=JSON.stringify(S)),p.push(bm(I)+"="+bm(S))}))}),o=p.join("&")}if(o){var d=e.indexOf("#");d!==-1&&(e=e.slice(0,d)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}});var Pm=K((oP,Im)=>{"use strict";var eI=Be();function ca(){this.handlers=[]}ca.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1};ca.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};ca.prototype.forEach=function(e){eI.forEach(this.handlers,function(n){n!==null&&e(n)})};Im.exports=ca});var Rm=K((sP,_m)=>{"use strict";var tI=Be();_m.exports=function(e,t){tI.forEach(e,function(o,p){p!==t&&p.toUpperCase()===t.toUpperCase()&&(e[t]=o,delete e[p])})}});var up=K((lP,Fm)=>{"use strict";Fm.exports=function(e,t,n,o,p){return e.config=t,n&&(e.code=n),e.request=o,e.response=p,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e}});var mp=K((pP,Sm)=>{"use strict";var iI=up();Sm.exports=function(e,t,n,o,p){var d=new Error(e);return iI(d,t,n,o,p)}});var Em=K((cP,Tm)=>{"use strict";var rI=mp();Tm.exports=function(e,t,n){var o=n.config.validateStatus;!n.status||!o||o(n.status)?e(n):t(rI("Request failed with status code "+n.status,n.config,null,n.request,n))}});var Am=K((uP,Cm)=>{"use strict";var ua=Be();Cm.exports=ua.isStandardBrowserEnv()?function(){return{write:function(t,n,o,p,d,h){var y=[];y.push(t+"="+encodeURIComponent(n)),ua.isNumber(o)&&y.push("expires="+new Date(o).toGMTString()),ua.isString(p)&&y.push("path="+p),ua.isString(d)&&y.push("domain="+d),h===!0&&y.push("secure"),document.cookie=y.join("; ")},read:function(t){var n=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()});var Om=K((mP,xm)=>{"use strict";xm.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}});var Lm=K((dP,Bm)=>{"use strict";Bm.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}});var Dm=K((fP,Nm)=>{"use strict";var nI=Om(),aI=Lm();Nm.exports=function(e,t){return e&&!nI(t)?aI(e,t):t}});var Gm=K((hP,Um)=>{"use strict";var dp=Be(),oI=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];Um.exports=function(e){var t={},n,o,p;return e&&dp.forEach(e.split(`
|
|
21
|
-
`),function(h){if(p=h.indexOf(":"),n=dp.trim(h.substr(0,p)).toLowerCase(),o=dp.trim(h.substr(p+1)),n){if(t[n]&&oI.indexOf(n)>=0)return;n==="set-cookie"?t[n]=(t[n]?t[n]:[]).concat([o]):t[n]=t[n]?t[n]+", "+o:o}}),t}});var $m=K((gP,Hm)=>{"use strict";var km=Be();Hm.exports=km.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a"),n;function o(p){var d=p;return e&&(t.setAttribute("href",d),d=t.href),t.setAttribute("href",d),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return n=o(window.location.href),function(d){var h=km.isString(d)?o(d):d;return h.protocol===n.protocol&&h.host===n.host}}():function(){return function(){return!0}}()});var Vr=K((yP,Vm)=>{"use strict";function fp(s){this.message=s}fp.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};fp.prototype.__CANCEL__=!0;Vm.exports=fp});var gp=K((MP,qm)=>{"use strict";var ma=Be(),sI=Em(),lI=Am(),pI=cp(),cI=Dm(),uI=Gm(),mI=$m(),hp=mp(),dI=qr(),fI=Vr();qm.exports=function(e){return new Promise(function(n,o){var p=e.data,d=e.headers,h=e.responseType,y;function I(){e.cancelToken&&e.cancelToken.unsubscribe(y),e.signal&&e.signal.removeEventListener("abort",y)}ma.isFormData(p)&&delete d["Content-Type"];var b=new XMLHttpRequest;if(e.auth){var S=e.auth.username||"",q=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";d.Authorization="Basic "+btoa(S+":"+q)}var Fe=cI(e.baseURL,e.url);b.open(e.method.toUpperCase(),pI(Fe,e.params,e.paramsSerializer),!0),b.timeout=e.timeout;function be(){if(!!b){var Se="getAllResponseHeaders"in b?uI(b.getAllResponseHeaders()):null,ue=!h||h==="text"||h==="json"?b.responseText:b.response,Te={data:ue,status:b.status,statusText:b.statusText,headers:Se,config:e,request:b};sI(function(ut){n(ut),I()},function(ut){o(ut),I()},Te),b=null}}if("onloadend"in b?b.onloadend=be:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(be)},b.onabort=function(){!b||(o(hp("Request aborted",e,"ECONNABORTED",b)),b=null)},b.onerror=function(){o(hp("Network Error",e,null,b)),b=null},b.ontimeout=function(){var ue=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",Te=e.transitional||dI.transitional;e.timeoutErrorMessage&&(ue=e.timeoutErrorMessage),o(hp(ue,e,Te.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",b)),b=null},ma.isStandardBrowserEnv()){var ct=(e.withCredentials||mI(Fe))&&e.xsrfCookieName?lI.read(e.xsrfCookieName):void 0;ct&&(d[e.xsrfHeaderName]=ct)}"setRequestHeader"in b&&ma.forEach(d,function(ue,Te){typeof p=="undefined"&&Te.toLowerCase()==="content-type"?delete d[Te]:b.setRequestHeader(Te,ue)}),ma.isUndefined(e.withCredentials)||(b.withCredentials=!!e.withCredentials),h&&h!=="json"&&(b.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&b.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&b.upload&&b.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(y=function(Se){!b||(o(!Se||Se&&Se.type?new fI("canceled"):Se),b.abort(),b=null)},e.cancelToken&&e.cancelToken.subscribe(y),e.signal&&(e.signal.aborted?y():e.signal.addEventListener("abort",y))),p||(p=null),b.send(p)})}});var qr=K((wP,Xm)=>{"use strict";var he=Be(),Wm=Rm(),hI=up(),gI={"Content-Type":"application/x-www-form-urlencoded"};function Km(s,e){!he.isUndefined(s)&&he.isUndefined(s["Content-Type"])&&(s["Content-Type"]=e)}function yI(){var s;return typeof XMLHttpRequest!="undefined"?s=gp():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(s=gp()),s}function MI(s,e,t){if(he.isString(s))try{return(e||JSON.parse)(s),he.trim(s)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(s)}var da={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:yI(),transformRequest:[function(e,t){return Wm(t,"Accept"),Wm(t,"Content-Type"),he.isFormData(e)||he.isArrayBuffer(e)||he.isBuffer(e)||he.isStream(e)||he.isFile(e)||he.isBlob(e)?e:he.isArrayBufferView(e)?e.buffer:he.isURLSearchParams(e)?(Km(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):he.isObject(e)||t&&t["Content-Type"]==="application/json"?(Km(t,"application/json"),MI(e)):e}],transformResponse:[function(e){var t=this.transitional||da.transitional,n=t&&t.silentJSONParsing,o=t&&t.forcedJSONParsing,p=!n&&this.responseType==="json";if(p||o&&he.isString(e)&&e.length)try{return JSON.parse(e)}catch(d){if(p)throw d.name==="SyntaxError"?hI(d,this,"E_JSON_PARSE"):d}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};he.forEach(["delete","get","head"],function(e){da.headers[e]={}});he.forEach(["post","put","patch"],function(e){da.headers[e]=he.merge(gI)});Xm.exports=da});var Qm=K((bP,Ym)=>{"use strict";var wI=Be(),bI=qr();Ym.exports=function(e,t,n){var o=this||bI;return wI.forEach(n,function(d){e=d.call(o,e,t)}),e}});var yp=K((vP,zm)=>{"use strict";zm.exports=function(e){return!!(e&&e.__CANCEL__)}});var jm=K((IP,Zm)=>{"use strict";var Jm=Be(),Mp=Qm(),vI=yp(),II=qr(),PI=Vr();function wp(s){if(s.cancelToken&&s.cancelToken.throwIfRequested(),s.signal&&s.signal.aborted)throw new PI("canceled")}Zm.exports=function(e){wp(e),e.headers=e.headers||{},e.data=Mp.call(e,e.data,e.headers,e.transformRequest),e.headers=Jm.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Jm.forEach(["delete","get","head","post","put","patch","common"],function(o){delete e.headers[o]});var t=e.adapter||II.adapter;return t(e).then(function(o){return wp(e),o.data=Mp.call(e,o.data,o.headers,e.transformResponse),o},function(o){return vI(o)||(wp(e),o&&o.response&&(o.response.data=Mp.call(e,o.response.data,o.response.headers,e.transformResponse))),Promise.reject(o)})}});var bp=K((PP,ed)=>{"use strict";var Ve=Be();ed.exports=function(e,t){t=t||{};var n={};function o(b,S){return Ve.isPlainObject(b)&&Ve.isPlainObject(S)?Ve.merge(b,S):Ve.isPlainObject(S)?Ve.merge({},S):Ve.isArray(S)?S.slice():S}function p(b){if(Ve.isUndefined(t[b])){if(!Ve.isUndefined(e[b]))return o(void 0,e[b])}else return o(e[b],t[b])}function d(b){if(!Ve.isUndefined(t[b]))return o(void 0,t[b])}function h(b){if(Ve.isUndefined(t[b])){if(!Ve.isUndefined(e[b]))return o(void 0,e[b])}else return o(void 0,t[b])}function y(b){if(b in t)return o(e[b],t[b]);if(b in e)return o(void 0,e[b])}var I={url:d,method:d,data:d,baseURL:h,transformRequest:h,transformResponse:h,paramsSerializer:h,timeout:h,timeoutMessage:h,withCredentials:h,adapter:h,responseType:h,xsrfCookieName:h,xsrfHeaderName:h,onUploadProgress:h,onDownloadProgress:h,decompress:h,maxContentLength:h,maxBodyLength:h,transport:h,httpAgent:h,httpsAgent:h,cancelToken:h,socketPath:h,responseEncoding:h,validateStatus:y};return Ve.forEach(Object.keys(e).concat(Object.keys(t)),function(S){var q=I[S]||p,Fe=q(S);Ve.isUndefined(Fe)&&q!==y||(n[S]=Fe)}),n}});var vp=K((_P,td)=>{td.exports={version:"0.24.0"}});var nd=K((RP,rd)=>{"use strict";var _I=vp().version,Ip={};["object","boolean","number","function","string","symbol"].forEach(function(s,e){Ip[s]=function(n){return typeof n===s||"a"+(e<1?"n ":" ")+s}});var id={};Ip.transitional=function(e,t,n){function o(p,d){return"[Axios v"+_I+"] Transitional option '"+p+"'"+d+(n?". "+n:"")}return function(p,d,h){if(e===!1)throw new Error(o(d," has been removed"+(t?" in "+t:"")));return t&&!id[d]&&(id[d]=!0,console.warn(o(d," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(p,d,h):!0}};function RI(s,e,t){if(typeof s!="object")throw new TypeError("options must be an object");for(var n=Object.keys(s),o=n.length;o-- >0;){var p=n[o],d=e[p];if(d){var h=s[p],y=h===void 0||d(h,p,s);if(y!==!0)throw new TypeError("option "+p+" must be "+y);continue}if(t!==!0)throw Error("Unknown option "+p)}}rd.exports={assertOptions:RI,validators:Ip}});var cd=K((FP,pd)=>{"use strict";var ad=Be(),FI=cp(),od=Pm(),sd=jm(),fa=bp(),ld=nd(),Ni=ld.validators;function Wr(s){this.defaults=s,this.interceptors={request:new od,response:new od}}Wr.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=fa(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;t!==void 0&&ld.assertOptions(t,{silentJSONParsing:Ni.transitional(Ni.boolean),forcedJSONParsing:Ni.transitional(Ni.boolean),clarifyTimeoutError:Ni.transitional(Ni.boolean)},!1);var n=[],o=!0;this.interceptors.request.forEach(function(q){typeof q.runWhen=="function"&&q.runWhen(e)===!1||(o=o&&q.synchronous,n.unshift(q.fulfilled,q.rejected))});var p=[];this.interceptors.response.forEach(function(q){p.push(q.fulfilled,q.rejected)});var d;if(!o){var h=[sd,void 0];for(Array.prototype.unshift.apply(h,n),h=h.concat(p),d=Promise.resolve(e);h.length;)d=d.then(h.shift(),h.shift());return d}for(var y=e;n.length;){var I=n.shift(),b=n.shift();try{y=I(y)}catch(S){b(S);break}}try{d=sd(y)}catch(S){return Promise.reject(S)}for(;p.length;)d=d.then(p.shift(),p.shift());return d};Wr.prototype.getUri=function(e){return e=fa(this.defaults,e),FI(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};ad.forEach(["delete","get","head","options"],function(e){Wr.prototype[e]=function(t,n){return this.request(fa(n||{},{method:e,url:t,data:(n||{}).data}))}});ad.forEach(["post","put","patch"],function(e){Wr.prototype[e]=function(t,n,o){return this.request(fa(o||{},{method:e,url:t,data:n}))}});pd.exports=Wr});var md=K((SP,ud)=>{"use strict";var SI=Vr();function Di(s){if(typeof s!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(o){e=o});var t=this;this.promise.then(function(n){if(!!t._listeners){var o,p=t._listeners.length;for(o=0;o<p;o++)t._listeners[o](n);t._listeners=null}}),this.promise.then=function(n){var o,p=new Promise(function(d){t.subscribe(d),o=d}).then(n);return p.cancel=function(){t.unsubscribe(o)},p},s(function(o){t.reason||(t.reason=new SI(o),e(t.reason))})}Di.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};Di.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};Di.prototype.unsubscribe=function(e){if(!!this._listeners){var t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}};Di.source=function(){var e,t=new Di(function(o){e=o});return{token:t,cancel:e}};ud.exports=Di});var fd=K((TP,dd)=>{"use strict";dd.exports=function(e){return function(n){return e.apply(null,n)}}});var gd=K((EP,hd)=>{"use strict";hd.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var wd=K((CP,Pp)=>{"use strict";var yd=Be(),TI=ap(),ha=cd(),EI=bp(),CI=qr();function Md(s){var e=new ha(s),t=TI(ha.prototype.request,e);return yd.extend(t,ha.prototype,e),yd.extend(t,e),t.create=function(o){return Md(EI(s,o))},t}var gt=Md(CI);gt.Axios=ha;gt.Cancel=Vr();gt.CancelToken=md();gt.isCancel=yp();gt.VERSION=vp().version;gt.all=function(e){return Promise.all(e)};gt.spread=fd();gt.isAxiosError=gd();Pp.exports=gt;Pp.exports.default=gt});var vd=K((AP,bd)=>{bd.exports=wd()});var hm=mm(dm());var np=s=>{let e=200,t=[],n=0;return t[n]=[],s.forEach(o=>{t[n].length<=e-1?t[n].push(o):(n++,t[n]=[o])}),t},ea=s=>{let e=[],t=200;for(;s.length>t;){let n=s.splice(0,t);e.push(n)}return e.push(s),e},Oe=(s,e)=>{let t="",n={profile:"https://profile.fansunitedapi.com/v1",football:"https://football.fansunitedapi.com/v1",idMapping:"https://id-mapping.fansunitedapi.com/v1",predictor:"https://prediction.fansunitedapi.com/v1",client:"https://client.fansunitedapi.com/v1",loyalty:"https://loyalty.fansunitedapi.com/v1"},o={profile:"http://localhost:8010/v1",football:"http://localhost:8080/v1",idMapping:"http://localhost:8030/v1",predictor:"http://localhost:8040/v1",client:"http://localhost:8070/v1",loyalty:"http://localhost:8060/v1"},p={profile:"https://profile.fansunitedstagingapi.com/v1",football:"https://football.fansunitedstagingapi.com/v1",idMapping:"https://id-mapping.fansunitedstagingapi.com/v1",predictor:"https://prediction.fansunitedstagingapi.com/v1",client:"https://client.fansunitedstagingapi.com/v1",loyalty:"https://loyalty.fansunitedstagingapi.com/v1"};return s==="prod"?t=n[e]:s==="dev"?t=o[e]:t=p[e],t},Xt=s=>s.filter((t,n,o)=>n===o.indexOf(t)),ta=s=>Array.isArray(s)?s.map(e=>ta(e)):s!=null&&s.constructor===Object?Object.keys(s).reduce((e,t)=>({...e,[(0,hm.camelCase)(t)]:ta(s[t])}),{}):s,de=s=>s||!1,fe=()=>`&disable_cache=${Date.now()}`,Hr=s=>s.sort((e,t)=>e.localeCompare(t));var ia=class{id=null;name=null;nickname=null;avatar=null;gender=null;country=null;birthDate=null;interests=[];followingCount=0;followersCount=0};var ra=class{profilesFromResponse=e=>e?e.map(t=>this.fullProfileFromResponse(t)):null;fullProfileFromResponse=e=>{let t=new ia;return t.id=e.id,t.name=e.name,t.nickname=e.nickname,t.avatar=e.avatar,t.gender=e.gender,t.country=e.country,t.birthDate=e.birth_date,t.interests=e.interests?e.interests:[],t.followingCount=e.following_count,t.followersCount=e.followers_count,t}};var na=class{nextPageStartsAfter=null;itemsPerPage=null};var Bi=class{pagination=new na};var re=class{meta=new Bi;data=[]};var aa=class{avatar=null;followingId=null;name=null;nickname=null;profileId=null};var oa=class{followResponse=e=>e.map(t=>this.remapResponse(t));followingFromResponse=e=>{let t=new re;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapResponse(n)),t};remapResponse=e=>{let t=new aa;return t.avatar=e.avatar,t.followingId=e.following_id,t.name=e.name,t.profileId=e.profile_id,t.nickname=e.nickname,t}};var sa=class{avatar=null;followerId=null;name=null;nickname=null;profileId=null};var la=class{followersFromResponse=e=>{let t=new re;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapResponse(n)),t};remapResponse=e=>{let t=new sa;return t.avatar=e.avatar,t.followerId=e.follower_id,t.name=e.name,t.profileId=e.profile_id,t}};var $r=class{profile_ids=[]};var ya=mm(vd());function _p(s){this.message=s}_p.prototype=new Error,_p.prototype.name="InvalidCharacterError";var Id=typeof window!="undefined"&&window.atob&&window.atob.bind(window)||function(s){var e=String(s).replace(/=+$/,"");if(e.length%4==1)throw new _p("'atob' failed: The string to be decoded is not correctly encoded.");for(var t,n,o=0,p=0,d="";n=e.charAt(p++);~n&&(t=o%4?64*t+n:n,o++%4)?d+=String.fromCharCode(255&t>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return d};function AI(s){var e=s.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Id(t).replace(/(.)/g,function(n,o){var p=o.charCodeAt(0).toString(16).toUpperCase();return p.length<2&&(p="0"+p),"%"+p}))}(e)}catch{return Id(e)}}function ga(s){this.message=s}function xI(s,e){if(typeof s!="string")throw new ga("Invalid token specified");var t=(e=e||{}).header===!0?0:1;try{return JSON.parse(AI(s.split(".")[t]))}catch(n){throw new ga("Invalid token specified: "+n.message)}}ga.prototype=new Error,ga.prototype.name="InvalidTokenError";var Pd=xI;var _d=(s,e,t)=>{let n={data:s.data,status:e,statusText:t,headers:s.headers,config:s};return{code:String(e),config:s,isAxiosError:!0,toJSON:()=>({}),name:"Unauthorized",message:t,response:n}};var Me=class{instanceAuth=null;instance=null;constructor(e,t){this.instanceAuth=ya.default.create({baseURL:t,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instanceAuth.interceptors.request.use(n=>{let o=null;try{o=Pd(e.authProvider.getIdToken())}catch(d){throw _d(n,401,d.message)}return Date.now()>o.exp&&(ya.default.defaults.headers.common.Authorization=`Bearer ${e.authProvider.getIdToken()}`,n.headers.Authorization=`Bearer ${e.authProvider.getIdToken()}`),n},n=>{Promise.reject(n)}),this.instanceAuth.interceptors.response.use(n=>n,n=>{let o=n.config;if((n.response?.status===403||n.response?.status===401)&&!o._retry){o._retry=!0;let p=e.authProvider.getIdToken();return o.headers.Authorization=`Bearer ${p}`,this.instanceAuth(o)}return Promise.reject(n)}),this.instance=ya.default.create({baseURL:t,headers:{"Content-Type":"application/json"}})}};var OI="/countries",Le="/profile",Rd="/profiles",Ui=class extends Me{apiSignInUrl=null;profileRemapper=null;followingRemapper=null;followersRemapper=null;lang=null;constructor(e){super(e,Oe(e.environment,"profile"));this.lang=e.lang,this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.profileRemapper=new ra,this.followingRemapper=new oa,this.followersRemapper=new la}getCountries=async e=>{try{let t=`&lang=${this.lang}`,n=`${OI}${this.apiSignInUrl}${t}`,o=Date.now();return e&&(n+=`&disable_cache=${o}`),(await this.instance.get(n)).data.data}catch(t){throw console.warn("There was a problem fetching the countries:",t),t.response}};getProfile=async e=>{let t=`${Le}${this.apiSignInUrl}`;if(e){t=`${Rd}/${e}${this.apiSignInUrl}`;try{let n=await this.instance.get(t);return this.profileRemapper.fullProfileFromResponse(n.data.data)}catch(n){throw console.warn(`There was a problem fetching the following profile: ${e}`,n),n.response}}else try{let n=await this.instanceAuth.get(t);return this.profileRemapper.fullProfileFromResponse(n.data.data)}catch(n){throw console.warn("There was a problem fetching your profile from API:",n),n.response}};getProfiles=async(e,t)=>{try{let n=`${Rd}${this.apiSignInUrl}&profile_ids=${e.join(",")}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.profileRemapper.profilesFromResponse(p.data.data)}catch(n){throw console.warn(`There was a problem fetching the following profiles: ${e.join(",")}`,n),n.response}};getFollowers=async(e,t)=>{let n=`${Le}/followers${this.apiSignInUrl}`;if(e&&!t){n=`${Le}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let o=await this.instanceAuth.get(n);return this.followersRemapper.followersFromResponse(o.data)}catch(o){throw console.warn("There was a problem fetching the followers for own profile",o),o.response}}else if(!e&&!t)try{let o=await this.instanceAuth.get(n);return this.followersRemapper.followersFromResponse(o.data)}catch(o){throw console.warn("There was a problem fetching the followers for own profile",o),o.response}e&&t?n=`${Le}/${t}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(n=`${Le}/${t}/followers${this.apiSignInUrl}`);try{let o=await this.instance.get(n);return this.followersRemapper.followersFromResponse(o.data)}catch(o){throw console.warn(`There was a problem fetching the followers for profile: ${t}`,o),o.response}};getFollowing=async(e,t)=>{let n=`${Le}/following${this.apiSignInUrl}`;if(e&&!t){n=`${Le}/following${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let o=await this.instanceAuth.get(n);return this.followingRemapper.followingFromResponse(o.data)}catch(o){throw console.warn("There was a problem fetching the followers of own profile",o),o.response}}else if(!e&&!t)try{let o=await this.instanceAuth.get(n);return this.followingRemapper.followingFromResponse(o.data)}catch(o){throw console.warn("There was a problem fetching the followers of own profile",o),o.response}e&&t?n=`${Le}/${t}/following${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(n=`${Le}/${t}/following${this.apiSignInUrl}`);try{let o=await this.instance.get(n);return this.followingRemapper.followingFromResponse(o.data)}catch(o){throw console.warn(`There was a problem fetching the followers of the following profile: ${t}`,o),o.response}};follow=async e=>{let t=new $r;t.profile_ids=e;try{let n=await this.instanceAuth.post(`${Le}/follow${this.apiSignInUrl}`,JSON.stringify(t));return this.followingRemapper.followResponse(n.data.data)}catch(n){throw console.warn(`There was a problem with POST request for profiles: ${e.join(",")} `,n),n.response}};unfollow=async e=>{let t=new $r;t.profile_ids=e;try{return await this.instanceAuth.delete(`${Le}/follow${this.apiSignInUrl}`,{data:JSON.stringify(t)}),!0}catch(n){throw console.warn(`There was a problem with DELETE request for profiles: ${e.join(",")} `,n),n.response}};getBadges=async e=>{let t=`${Le}/badges${this.apiSignInUrl}`;try{return e?(t=`${Le}/${e}/badges${this.apiSignInUrl}`,(await this.instance.get(t)).data.data):(await this.instanceAuth.get(t)).data.data}catch(n){throw console.warn("There was a problem with fetching the badges",n),n.response}};updateProfile=async e=>{try{let t=await this.instanceAuth.patch(`${Le}${this.apiSignInUrl}`,e);return this.profileRemapper.fullProfileFromResponse(t.data.data)}catch(t){throw console.warn("There was a problem updating the own profile:",t),t.response}}};var Bt={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id"},Rp={PREDICTOR_USER_RELATED_OPERATION:"https://docs.fansunitedmedia.com/docs/predictor-operations#user-related-operations"},Fp=["matchId","matchType","market","prediction"];var Fd="FansUnited",Sp={football:{ids:[],countries:[],competitions:[]},profile:{info:{},statistics:{},badges:null,countries:[],exparations:{profile:0,statistics:0,badges:0}}},yt=class{idSchema="";expirationTimeout=600;expirationBadgesTimeout=3600;constructor(e){this.idSchema=e.idSchema,(this.getData()===void 0||this.getData()===null)&&this.setData(Sp)}clearData=()=>{this.setData(Sp)};getEntityById=(e="",t="")=>this.getData().football.ids.find(n=>{let o=Bt[this.idSchema];return n&&`${n[o]}`===t&&n.resource===e});getEntity=(e,t,n)=>Array.isArray(e)?this.getData().football.ids.filter(o=>{let p=Bt[n];return o&&e.includes(`${o[p]}`)&&o.resource===t}):this.getData().football.ids.find(o=>{let p=Bt[n];return o&&`${o[p]}`===e&&o.resource===t});getEntityByNativeId=(e="",t="")=>this.getData().football.ids.find(n=>n&&`${n.id}`===t&&n.resource===e);checkForExistingIdObjs=(e,t)=>{let n=Bt[t],o={};return Object.keys(e).forEach(p=>{let d=e[p],y=this.getEntity(d,p,t).map(b=>b[n]),I=e[p].filter(b=>!y.includes(b));o[p]=d.map(b=>I.includes(b)?{id:b,exists:!1}:{id:b,exists:!0})}),o};getIdsByType=(e,t,n)=>{let o=Bt[n],p=Bt[t],d={};return Object.keys(e).forEach(h=>{let y=e[h],I=[];this.getData().football.ids.forEach(b=>{y.forEach((S,q)=>{S===b[p]&&h===b.resource&&(I[q]=b[o])})}),d[h]=I}),d};addIdMapping=e=>{let t=this.getData();t.football.ids.push(e),this.setData(t)};addIdMappings=e=>{let t=this.getData(),n=t.football.ids;n=[...n,...e],t.football.ids=n,this.setData(t)};setOwnProfile=e=>{let t=this.getData();t.profile.info=e,t.profile.exparations.profile=Math.floor(Date.now()/1e3)+this.expirationTimeout,this.setData(t)};getOwnProfile=()=>this.getData().profile.info;getProfileCountries=()=>this.getData().profile.countries;setProfileCountries=e=>{let t=this.getData();t.profile.countries=e,this.setData(t)};getProfileStats=()=>this.getData().profile.statistics;setProfileStats=e=>{let t=this.getData();t.profile.statistics=e,t.profile.exparations.statistics=Math.floor(Date.now()/1e3)+this.expirationTimeout,this.setData(t)};getProfileBadges=()=>this.getData().profile.badges;setProfileBadges=e=>{let t=this.getData();t.profile.badges=e,t.profile.exparations.badges=Math.floor(Date.now()/1e3)+this.expirationBadgesTimeout,this.setData(t)};getFootballCountries=()=>this.getData().football.countries;setFootballCountries=e=>{let t=this.getData();t.football.countries=e,this.setData(t)};getCompetitions=e=>{let t=this.getData();return e?e.competitionSearchFilter(t.football.competitions):t.football.competitions};setCompetitions=e=>{let t=this.getData(),n=[...t.football.competitions];n.push(...e),t.football.competitions=this.makeCompetitionsUnique(n),this.setData(t)};getCompetitionsLength=()=>{let{football:e}=this.getData();return e.competitions.length};getExpiration=e=>{let t=this.getData();switch(this.initialNewSchema("exparations"),e){case"profile":return t.profile.exparations.profile;case"statistics":return t.profile.exparations.statistics;case"badges":return t.profile.exparations.badges}};makeCompetitionsUnique=e=>{let t=new Set;return e.filter(n=>{let o=!t.has(n.id);return t.add(n.id),o})};getData=()=>JSON.parse(localStorage.getItem(Fd));setData=e=>{localStorage.setItem(Fd,JSON.stringify(e))};initialNewSchema=e=>{this.getData().profile[e]||this.setData(Sp)}};var Kr={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},Ma=class extends Me{apiSignInUrl="";constructor(e){super(e,Oe(e.environment,"idMapping"));this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`}getEntityById=(e,t)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${config.idSchema}&${Kr[e]}=${t}`)}catch(n){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,n),n.response}};getEntityByIdAndSchema=(e,t,n)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${Kr[e]}=${t}`)}catch(o){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,o),o.response}};getEntityIdsByIdsAndSchema=(e,t,n)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${Kr[e]}=${t.join(",")}`)}catch(o){throw console.warn(`There was a problem with id mapping request for the following ids:${t.join(",")}`,o),o.response}};getEntitiesByIds=(e,t,n)=>{t.sort((d,h)=>d.localeCompare(h));let p=np(t).map(d=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${Kr[e]}=${d.join(",")}`)}catch(h){throw console.warn(`There was a problem with id mapping request for the following ids:${d.join(",")}`,h),h.response}});return Promise.all(p).then(d=>{let h=[];return d.forEach(y=>{h.push(...y.data.data)}),h})};getEntitiesByIdObjs=async(e,t)=>{let n=[],o={},p=[];Object.keys(e).forEach(I=>{n.push.apply(n,e[I])});let d=Xt(n),h=np(d);for(let I of h){let b="";if(Object.keys(e).forEach(S=>{o[S]=[];let q=I.filter(Fe=>e[S].includes(Fe));q&&q.length>0&&(o[S]=q)}),Object.keys(o).forEach(S=>{o[S].length>0&&(o[S].sort((q,Fe)=>q.localeCompare(Fe)),b+="&",b+=`${Kr[S]}=${o[S].join(",")}`)}),b&&b.length>0)try{let S=await this.instance.get(`/football${this.apiSignInUrl}&input_provider=${t||"native"}${b}`);p.push(S.data.data)}catch(S){throw console.warn("There was a problem with id mapping request",S),S.response}else p.push([])}return Array.prototype.concat.apply([],p)}};var wa=class{isBrowser=!1;localStorage=null;https=null;constructor(e){this.isBrowser=typeof window!="undefined",this.localStorage=new yt(e),this.https=new Ma(e)}getEntitiesByIds=async(e,t,n)=>{if(this.isBrowser)try{let o=this.localStorage.checkForExistingIdObjs(e,t),p=this.splitForRequestAndExisting(o),d=await this.https.getEntitiesByIdObjs(p.request,t);return this.localStorage.addIdMappings(d),this.localStorage.getIdsByType(e,t,n)}catch(o){return console.warn("There was a problem retrieving the entity ids ",o),Promise.resolve([])}else try{let o=await this.https.getEntitiesByIdObjs(e,t);return Object.keys(e).forEach(p=>{e[p]=o.filter(d=>d.resource===p).map(d=>d[Bt[n]])}),e}catch(o){return console.warn("There was a problem retrieving the entity ids ",o),Promise.resolve([])}};getEntityById=async(e,t,n)=>{if(this.isBrowser){let o=this.localStorage.getEntity(e,t,n);if(o)return o;{let p=await this.requestEntity(e,t,n);return this.localStorage.addIdMappings(p),p}}else return await this.requestEntity(e,t,n)};splitForRequestAndExisting=e=>{let t={},n={};return Object.keys(e).forEach(o=>{t[o]=e[o].filter(p=>!p.exists).map(p=>p.id),n[o]=e[o].filter(p=>p.exists).map(p=>p.id)}),{existing:n,request:t}};requestEntity=async(e,t,n)=>{try{return e=Array.isArray(e)?e:[e],await this.https.getEntitiesByIds(t,e,n)}catch(o){return console.warn(`There was a problem retrieving the requested entity: ${o}`),null}}};var ba=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 va=class{extractedObjIds={};traverse=(e,t)=>(t=ba(t),Array.isArray(e)?this.traverseArrExtract(e,t):e&&typeof e=="object"&&this.traverseObjExtract(e,t),this.extractedObjIds);traverseArrExtract=(e,t)=>{e&&e.length>0&&e.forEach(n=>{this.traverseObjExtract(n,t)})};traverseObjExtract=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(n=>{let o=e[n];n==="id"||n==="teamId"?(this.extractedObjIds.hasOwnProperty(t)||(this.extractedObjIds[t]=[]),o&&this.extractedObjIds[t].push(o)):e[n]&&this.traverse(e[n],n)})}};var Ia=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(e,t,n)=>(t=ba(t),this.replaceObjIdsIndex===null&&(this.initReplaceObjIdsIndex(n),this.remappedIdsObj=n),Array.isArray(e)?this.traverseArrReplace(e,t):e&&typeof e=="object"&&this.traverseObjReplace(e,t),e);initReplaceObjIdsIndex=e=>{this.replaceObjIdsIndex={},Object.keys(e).forEach(t=>{this.replaceObjIdsIndex[t]=0})};traverseArrReplace=(e,t)=>{e&&e.length>0&&e.forEach(n=>{this.traverseObjReplace(n,t)})};traverseObjReplace=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(n=>{n==="id"||n==="teamId"?e[n]&&(e[n]=this.remappedIdsObj[t][this.replaceObjIdsIndex[t]],this.replaceObjIdsIndex[t]=this.replaceObjIdsIndex[t]+1):e[n]&&this.traverse(e[n],n,this.remappedIdsObj)})}};var ae=class{idSchema="";idMappingFacade=null;constructor(e){this.idSchema=e.idSchema,this.idMappingFacade=new wa(e)}getEntityIdBySchemaId=(e,t)=>this.idMappingFacade.getEntityById(e,t,this.idSchema);remapEntities=async(e,t)=>{let n=JSON.parse(JSON.stringify(e));try{if(this.idSchema!=="native"){let p=new va().traverse(n,t);return this.idMappingFacade.getEntitiesByIds(p,"native",this.idSchema).then(d=>new Ia().traverse(n,t,d))}else return e}catch(o){return console.warn(`There was a problem remapping entity: ${t} with inner entity `,o),[]}};getEntityIdsBySchemaId=async(e,t,n)=>{let o={};return o[t]=e,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(o,this.idSchema,n):o}};var qe=class{completed=!1;percentage;constructor(e){this.percentage=e}};var Pa=class{teamFollowed=new qe(10);teamFavourite=new qe(15);playerFollowed=new qe(10);playerFavourite=new qe(10);competitionFollowed=new qe(10);competitionFavourite=new qe(5);addedBirthdate=new qe(10);addedGender=new qe(10);addedCountry=new qe(10);addedAvatar=new qe(10)};var _a=class{totalPercentage;breakdown=new Pa};var Xr=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,t,n){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.profileHttps=t,this.activityHttps=n}getOwn=async()=>{if(this.isBrowser){let e=this.getLocalStorageData("profile");if(e)return JSON.parse(JSON.stringify(e));try{let t=await this.profileHttps.getProfile();return this.localStorage.setOwnProfile(t),t}catch(t){throw console.warn("There was a problem retrieving your profile: ",t),t}}else try{return await this.profileHttps.getProfile()}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};updateOwnProfile=async()=>{try{let e=await this.profileHttps.getProfile();return this.localStorage.setOwnProfile(e),e}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};getByIds=async(e,t)=>{try{return t=t||!1,await this.profileHttps.getProfiles(e,t)}catch(n){throw console.warn(`There was a problem retrieving the selected profiles: ${e.join(",")} `,n),n}};getById=async e=>{try{return await this.profileHttps.getProfile(e)}catch(t){throw console.warn(`There was a problem retrieving the selected profile: ${e} `,t),t}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let t=this.localStorage.getProfileCountries();if(t&&t.length>0)return t;try{let n=await this.profileHttps.getCountries(e);return this.localStorage.setProfileCountries(n),n}catch(n){throw console.warn("There was a problem retrieving profile countries: ",n),n}}else try{return await this.profileHttps.getCountries(e)}catch(t){throw console.warn("There was a problem retrieving profile countries: ",t),t}};getFollowers=async(e,t)=>{try{e&&(e=new Xr(e));let n=await this.profileHttps.getFollowers(e,t),o=n.data.map(p=>p.followerId);if(o.length){let p=await this.getByIds(o),d=n.data.map(h=>(p.forEach(y=>{h.followerId===y.id&&(h.name=y.name,h.nickname=y.nickname,h.avatar=y.avatar)}),h));return n.data=d,n}return n}catch(n){throw console.warn("There was a problem retrieving your followers: ",n),n}};getFollowing=async(e,t)=>{try{e&&(e=new Xr(e));let n=await this.profileHttps.getFollowing(e,t),o=n.data.map(p=>p.followingId);if(o.length){let p=await this.getByIds(o),d=n.data.map(h=>(p.forEach(y=>{h.followingId===y.id&&(h.name=y.name,h.nickname=y.nickname,h.avatar=y.avatar)}),h));return n.data=d,n}return n}catch(n){throw console.warn("There was a problem retrieving your following profiles: ",n),n}};follow=async e=>{try{return await this.profileHttps.follow(e)}catch(t){throw console.warn(`There was a problem following profiles: ${e.join(",")} `,t),t}};unfollow=async e=>{try{return await this.profileHttps.unfollow(e)}catch(t){throw console.warn(`There was a problem unfollowing profiles: ${e.join(",")} `,t),t}};showFullnessProfile=e=>{let t=new _a,n=0;return e.avatar&&(t.breakdown.addedAvatar.completed=!0,n+=t.breakdown.addedAvatar.percentage),e.birthDate&&(t.breakdown.addedBirthdate.completed=!0,n+=t.breakdown.addedBirthdate.percentage),e.country&&(t.breakdown.addedCountry.completed=!0,n+=t.breakdown.addedCountry.percentage),e.gender&&(t.breakdown.addedGender.completed=!0,n+=t.breakdown.addedGender.percentage),e.interests&&e.interests.length>0&&(e.interests.find(b=>b.type==="team"&&b.favourite)&&(t.breakdown.teamFavourite.completed=!0,n+=t.breakdown.teamFavourite.percentage),e.interests.find(b=>b.type==="team")&&(t.breakdown.teamFollowed.completed=!0,n+=t.breakdown.teamFollowed.percentage),e.interests.find(b=>b.type==="player"&&b.favourite)&&(t.breakdown.playerFavourite.completed=!0,n+=t.breakdown.playerFavourite.percentage),e.interests.find(b=>b.type==="player")&&(t.breakdown.playerFollowed.completed=!0,n+=t.breakdown.playerFollowed.percentage),e.interests.find(b=>b.type==="competition"&&b.favourite)&&(t.breakdown.competitionFavourite.completed=!0,n+=t.breakdown.competitionFavourite.percentage),e.interests.find(b=>b.type==="competition")&&(t.breakdown.competitionFollowed.completed=!0,n+=t.breakdown.competitionFollowed.percentage)),t.totalPercentage=n,t};getStats=async()=>{if(this.isBrowser){let e=this.getLocalStorageData("statistics");if(e&&Object.keys(e).length)return JSON.parse(JSON.stringify(e));try{let t=await this.activityHttps.getStats();return this.localStorage.setProfileStats(t),t}catch(t){throw console.warn("There was a problem retrieving own profile statistics: ",t),t}}else try{return await this.activityHttps.getStats()}catch(e){throw console.warn("There was a problem retrieving own profile statistics: ",e),e}};getBadges=async()=>{if(this.isBrowser){let e=this.getLocalStorageData("badges");if(e)return e;try{let t=await this.profileHttps.getBadges();return this.localStorage.setProfileBadges(t),t}catch(t){throw console.warn("There was a problem retrieving own profile badges: ",t),t}}else try{return await this.profileHttps.getBadges()}catch(e){throw console.warn("There was a problem retrieving own profile badges: ",e),e}};getLocalStorageData=e=>{let t=Math.floor(Date.now()/1e3),n=this.localStorage.getExpiration(e);switch(e){case"profile":if(n>t)return this.localStorage.getOwnProfile();case"statistics":if(n>t)return this.localStorage.getProfileStats();case"badges":if(n>t)return this.localStorage.getProfileBadges();default:return null}}};var Ra=class{id=null;name=null;assets=null};var Fa=class{extractUpdatedProps=(e,t)=>{let n=["name","nickname","gender"],o={};return Object.keys(e).forEach(p=>{if(n.includes(p)&&e[p]!==t[p])o[p]=t[p];else if(p==="birthDate")(t[p]===null||e[p]===null&&t[p]||e[p]!==t[p])&&(o.birth_date=t[p]);else if(p==="country")t[p]===null?o.country_id=t[p]:(e[p]===null&&t[p]||e[p].id!==t[p].id)&&(o.country_id=t[p].id);else if(p==="interests"){let d=e[p],h=t[p];h.length&&this.isNewInterest(d,h)?o[p]=this.updateInterests(d,h):(!h.length&&d.length||d.length!==h.length&&!this.isNewInterest(d,h))&&(o[p]=h)}}),o};updateInterests=(e,t)=>{if(e.length===t.length){let[n,o]=this.extractSameAndNewInterests(e,t);return[...o,...n]}else return t};isNewInterest=(e,t)=>{let n=!1,[o]=this.extractSameAndNewInterests(e,t);return o.length&&(n=!0),n};extractSameAndNewInterests=(e,t)=>{let n=t.filter(p=>e.some(d=>p.id===d.id&&p.type===d.type&&p.source===d.source&&p.favourite===d.favourite));return[t.filter(p=>!e.some(d=>p.id===d.id&&p.type===d.type&&p.source===d.source&&p.favourite===d.favourite)),n]}};var Sa=class{idsRemapper=null;profileHttps=null;profileService=null;localStorage=null;profileFacade=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;constructor(e,t,n,o,p,d){this.idsRemapper=e,this.localStorage=t,this.profileHttps=n,this.profileService=new Fa,this.profileFacade=new Mt(t,n,o)}getOwnProfile=async()=>{for(;this.isFetching;)console.log("Another thread is fetching profile..."),await this.delay(100);if(this.modified&&this.ownProfile)return console.log("Timestamp is less than 10 minutes OR profile is modifying "),this.ownProfile;let e=Math.floor(Date.now()/1e3);if(!this.ownProfile||this.expireAt<e){this.isFetching=!0,this.expireAt=Math.floor(Date.now()/1e3)+600;try{let t=await this.profileFacade.getOwn();this.setOwnProfile(t)}catch(t){throw this.isFetching=!1,t}return this.modified=!1,this.isFetching=!1,this.ownProfile}return this.ownProfile};delay=e=>new Promise(t=>{setTimeout(t,e)});setOwnProfile=e=>{this.ownProfile=e};getInfo=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return delete t.interests,t};showInterests=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.remapInterests(t.interests)};showFullInterests=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.showFullInterests(t.interests)};getFollowers=async e=>await this.profileFacade.getFollowers(e);getFollowing=async e=>await this.profileFacade.getFollowing(e);follow=async e=>{let t=await this.profileFacade.follow(e),n=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(n),t};unfollow=async e=>{let t=await this.profileFacade.unfollow(e),n=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(n),t};getStats=async()=>{let e=await this.profileFacade.getStats();return await this.idsRemapper.remapSuccessRatesEntities(e)};getBadges=async()=>await this.profileFacade.getBadges();addInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;e.source!=="custom"?t=await this.idsRemapper.remapInterestToNative(e):t=e;let n=this.ownProfile.interests.filter(o=>o.id!==t.id||o.type!==t.type||o.source!==t.source);return this.ownProfile.interests=[...n],this.ownProfile.interests.push(t),this};addInterest=e=>(this.promises.push(this.addInterestPromise(e)),this);removeInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;return e.source!=="custom"?t=await this.idsRemapper.remapInterestToNative(e):t=e,this.ownProfile.interests=this.ownProfile.interests.filter(n=>n.id!==t.id||n.type!==t.type||n.source!==t.source),this};removeInterest=e=>(this.promises.push(this.removeInterestPromise(e)),this);setBirthdatePromise=async e=>(this.modified=!0,await this.getOwnProfile(),e?this.ownProfile.birthDate=e:this.ownProfile.birthDate=null,this);setBirthdate=e=>(this.promises.push(this.setBirthdatePromise(e)),this);setGenderPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e==="male"||e==="female"?this.ownProfile.gender=e:this.ownProfile.gender="unspecified",this);setGender=e=>(this.promises.push(this.setGenderPromise(e)),this);setNicknamePromise=async e=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.nickname=e,this);setNickname=e=>(this.promises.push(this.setNicknamePromise(e)),this);setNamePromise=async e=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.name=e,this);setName=e=>(this.promises.push(this.setNamePromise(e)),this);setCountryPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e&&!this.ownProfile.country?(this.ownProfile.country=new Ra,this.ownProfile.country.id=e):e&&this.ownProfile.country?this.ownProfile.country.id=e:this.ownProfile.country=null,this);setCountry=e=>(this.promises.push(this.setCountryPromise(e)),this);showFullnessProfile=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return this.profileFacade.showFullnessProfile(t)};update=async()=>{if(this.promises.length===0)return this.ownProfile;await Promise.all(this.promises);let e=await this.profileFacade.getOwn(),t=await this.getOwnProfile(),n=this.profileService.extractUpdatedProps(e,t);if(this.modified=!1,this.expireAt=0,Object.keys(n).length){let p=await this.profileHttps.updateProfile(n),d=JSON.parse(JSON.stringify(p));return this.setOwnProfile(d),this.localStorage.setOwnProfile(d),delete p.interests,p}let o=JSON.parse(JSON.stringify(this.ownProfile));return delete o.interests,o}};var Ta=class{idsRemapper=null;profileHttps=null;activityHttps=null;profileFacade=null;profileId="";constructor(e,t,n,o){this.idsRemapper=e,this.profileHttps=n,this.activityHttps=o,this.profileFacade=new Mt(t,n,o)}setId=e=>(this.profileId=e,this);getProfile=async()=>await this.profileFacade.getById(this.profileId);getInfo=async()=>{let e=await this.getProfile();return delete e.interests,e};showInterests=async()=>{let e=await this.getProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.remapInterests(t.interests)};showFullInterests=async()=>{let e=await this.getProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.showFullInterests(t.interests)};getFollowers=async e=>await this.profileFacade.getFollowers(e,this.profileId);getFollowing=async e=>await this.profileFacade.getFollowing(e,this.profileId);showFullnessProfile=async()=>{let e=await this.getProfile();return this.profileFacade.showFullnessProfile(e)};getStats=async e=>{let t=await this.activityHttps.getStats(this.profileId,e);return await this.idsRemapper.remapSuccessRatesEntities(t)};getBadges=async()=>await this.profileHttps.getBadges(this.profileId)};var Ea=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,n){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=n,this.https=t}getCountriesWithIdMapping=async e=>{try{let t=await this.getCountries(e);return this.idMapping.remapEntities(t,"country")}catch(t){throw console.warn("There was a problem browsing countries as football entities",t),t}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let t=this.localStorage.getFootballCountries();if(t&&t.length>0)return t;try{let n=await this.https.getCountries(e);return this.localStorage.setFootballCountries(n),n}catch(n){throw console.warn("There was a problem retrieving countries as football entities",n),n}}else return this.https.getCountries(e)}};var Yr=class{countryId=null;name=null;gender=null;type=null;sortField=null;sortOrder=null;competitionIds=null;constructor(e){this.countryId=e.countryId?`${e.countryId}`:null,this.name=e.name?e.name:null,this.gender=e.gender?e.gender:null,this.type=e.type?e.type:null,this.sortField=e.sortField?`${e.sortField}`:null,this.sortOrder=e.sortOrder?`${e.sortOrder}`:null,this.competitionIds=e.competitionIds?e.competitionIds:null}constructFilterUrl=()=>{let e="";return this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.gender&&(e=e+"&",e=e+`gender=${this.gender}`),this.type&&(e=e+"&",e=e+`type=${this.type}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),this.name&&(e=e+"&",e=e+`name=${this.name}`),this.competitionIds&&(e=e+"&",e=e+`competition_ids=${this.competitionIds.join(",")}`),e};competitionSearchFilter=e=>{try{let t=this.filter(e);return this.sortField||this.sortOrder?this.sort(t):t}catch(t){return console.warn("There was a problem filtering the local competitions",t),[]}};filter=e=>{let t=this.entitiesToSearchWith();return e.filter(n=>{let o=!0;return t.forEach(p=>{p!=="sortOrder"&&p!=="sortField"&&(p==="countryId"?o&&=n.country.id===this[p]:p==="name"?o&&=n.name.toLocaleLowerCase().includes(this[p].toLocaleLowerCase()):p==="competitionIds"?o&&=this[p].some(d=>n.id===d):o&&=n[p].toLocaleLowerCase()===this[p].toLocaleLowerCase())}),o})};entitiesToSearchWith=()=>{let e=[];return this.countryId&&e.push("countryId"),this.name&&e.push("name"),this.gender&&e.push("gender"),this.type&&e.push("type"),this.sortField&&e.push("sortField"),this.sortOrder&&e.push("sortOrder"),this.competitionIds&&e.push("competitionIds"),e};sort=e=>{let t=[];return this.sortField==="name"?t=e.sort((n,o)=>this.sortOrder&&this.sortOrder==="desc"?o.name.localeCompare(n.name):n.name.localeCompare(o.name)):this.sortField==="country"?t=e.sort((n,o)=>this.sortOrder&&this.sortOrder==="desc"?o.country.name.localeCompare(n.country.name):n.country.name.localeCompare(o.country.name)):this.sortField==="scope"?e.forEach(n=>t[this.competitionIds.indexOf(n.id)]=n):!this.sortField&&this.sortOrder==="desc"&&(t=e.sort((n,o)=>o.id.localeCompare(n.id))),t}};var Ca=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,n){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=n,this.https=t}getCompetitionsIdMapping=async(e,t)=>{try{let n=!1;if(e){if(e=new Yr(e),e.countryId){let p=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");p.country.length===0&&(n=!0),e.countryId=p.country[0]}if(e.competitionIds){let p=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");p.competition.length===0&&(n=!0),e.competitionIds=p.competition}if(n)return[]}let o=await this.getCompetitions(e,t);return await this.idMapping.remapEntities(o,"competition")}catch(n){throw console.warn("There was a problem browsing all of the competitions",n),n}};getCompetitionsMapWithNativeIds=async e=>{let t=new Map,n=e.length,o=new Yr({competitionIds:e,limit:n}),p=await this.getCompetitions(o);p.sort((h,y)=>h.id.localeCompare(y.id));let d=await this.idMapping.remapEntities(p,"competition");return e.forEach((h,y)=>t.set(h,d[y])),t};getCompetitions=async(e,t)=>{let n=null;if(t=t||!1,this.isBrowser){if(!this.localStorage.getCompetitionsLength()){try{n=await this.https.getCompetitions()}catch(o){throw console.warn("There was a problem retrieving all competitions",o),o}this.localStorage.setCompetitions(n)}return this.localStorage.getCompetitions(e)}else return this.https.getCompetitions(e,t)};getCompetitionByIdIdMapping=async(e,t)=>{try{let o=(await this.idMapping.getEntityIdsBySchemaId([e],"competition","native")).competition[0],p=await this.getCompetitionById(o,t);return await this.idMapping.remapEntities(p,"competition")}catch(n){throw console.warn(`There was a problem browsing the following competition:${e}`,n),n}};getCompetitionById=async(e,t)=>{try{return t=t||!1,await this.https.getCompetitionById(e,t)}catch(n){throw console.warn(`There was a problem retrieving the competition with the following id: ${e}`,n),n}};getTopCompetitionsIdMapping=async e=>{try{let t=await this.getTopCompetitions(e);return await this.idMapping.remapEntities(t,"competition")}catch(t){throw console.warn("There was a problem browsing the top competitions",t),t}};getTopCompetitions=async e=>{try{return e=e||!1,await this.https.getTopCompetitions(e)}catch(t){throw console.warn("There was a problem retrieving the top competitions",t),t}}};var Qr=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 Aa=class{general=[];predictor=[];topX=[];matchQuiz=[]};var Gi=class{points=null;gameParticipationCount=null;predictionsMade=null;correctPredictions=null};var xa=class{id;enabled;requirements=new Gi};var Oa=class{id;weight;multiplier;conditions};var Ba=class{value=[new Oa]};var ki=class{points=null;tiers=null;badges=null};var La=class{enabled=!1;conditions={list:null};actions=new Ba;rewards=new ki};var Na=class{general=null;comments=null;predictor=null;activity=null;topX=null;matchQuiz=null};var Hi=class{enabled=!1;defaultMarkets=null;competitionsWhitelist=null};var $i=class{enabled=!1;minFixtures=null;maxFixtures=null;competitionsWhitelist=null};var Da=class{competitions=[];teams=[];markets=[]};var Vi=class{enabled=!1;fullCoverageCompetitions=null;markets=null;successRateScopes=new Da};var Ua=class{remapPredictorConfig=e=>{let t=new Vi;return t.enabled=e.enabled,t.fullCoverageCompetitions=e.full_coverage_competitions,t.markets=e.markets,t.successRateScopes=e.success_rate_scopes,t};remapTopXConfig=e=>{let t=new $i;return t.enabled=e.enabled,t.minFixtures=e.min_fixtures,t.maxFixtures=e.max_fixtures,t.competitionsWhitelist=e.competitions_whitelist,t};remapMatchQuizConfig=e=>{let t=new Hi;return t.enabled=e.enabled,t.defaultMarkets=e.default_markets,t.competitionsWhitelist=e.competitions_whitelist,t};remapLoyaltyConfig=e=>{let t=new La;return t.enabled=e.enabled,t.conditions.list=e.conditions.list,t.actions.value=e.actions.value,t.rewards=this.remapRewards(e.rewards),t};remapRewards=e=>{let t=new ki;return t.points=this.remapPoints(e.points),t.tiers=e.tiers,t.badges=this.remapBadges(e.badges),t};remapPoints=e=>{let t=new Na;return t.general=e.general,t.comments=e.comments,t.predictor=e.predictor,t.activity=e.activity,t.topX=e.top_x,t.matchQuiz=e.match_quiz,t};remapBadges=e=>{let t=new Aa;return t.general=e.general,t.predictor=this.remapBadgeValues(e.predictor),t.topX=this.remapBadgeValues(e.top_x),t.matchQuiz=this.remapBadgeValues(e.match_quiz),t};remapBadgeValues=e=>e.map(t=>{let n=new xa;return n.id=t.id,n.enabled=t.enabled,n.requirements=this.remapRequirements(t.requirements),n});remapRequirements=e=>{let t=new Gi;return t.points=e.points,t.gameParticipationCount=e.game_participation_count,t.predictionsMade=e.predictions_made,t.correctPredictions=e.correct_predictions,t}};var et=class extends Me{apiSignInUrl="";featureConfigRemapper=null;constructor(e){super(e,Oe(e.environment,"client"));this.apiSignInUrl=`/clients/${e.clientId}/features?key=${e.apiKey}`,this.featureConfigRemapper=new Ua}getConfig=async e=>{try{let t=await this.instance.get(`${this.apiSignInUrl}`);switch(e){case"predictor":return this.featureConfigRemapper.remapPredictorConfig(t.data.data.predictor);case"topX":return this.featureConfigRemapper.remapTopXConfig(t.data.data.top_x);case"matchQuiz":return this.featureConfigRemapper.remapMatchQuizConfig(t.data.data.match_quiz);case"loyalty":return this.featureConfigRemapper.remapLoyaltyConfig(t.data.data.loyalty)}}catch(t){throw console.warn("There was a problem fetching configuration from Client API",t),t.response}}};var Yt=class{clientHttps=null;constructor(e){this.clientHttps=new et(e)}setAvailableMarketsForMatch=async e=>{let{fullCoverageCompetitions:t,markets:n}=await this.clientHttps.getConfig("predictor");if(Array.isArray(e))return e.map(o=>this.setAvailableMarkets(o,t,n));if(typeof e=="object"&&Object.keys(e).length)return this.setAvailableMarkets(e,t,n)};setAvailableMarkets=(e,t,n)=>{let o=e.context.competition?.id;return o&&this.isMatchInCoverageCompetition(o,t)?(e.availableMarkets=n.all,e):(e.availableMarkets=n.main,e)};isMatchInCoverageCompetition=(e,t)=>{let n=!1;return t.includes(e)&&(n=!0),n}};var ka=class{footballService=null;https=null;idMapping=null;constructor(e,t,n){this.idMapping=n,this.https=t,this.footballService=new Yt(e)}getTeamsIdMapping=async(e,t)=>{try{let n=!1;if(e){if(e=new Qr(e),e.countryId){let p=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");p.country.length===0&&(n=!0),e.countryId=p.country[0]}if(e.scope){let p=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");p.competition.length===0&&(n=!0),e.scope=p.competition}if(e.teamIds){let p=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");p.team.length===0&&(n=!0),e.teamIds=p.team}}if(n)return[];let o=await this.getTeams(e,t);return o.data=await this.idMapping.remapEntities(o.data,"team"),o}catch(n){throw console.warn("There was a problem browsing all teams",n),n}};getTeamsMapWithNativeIds=async e=>{let t=new Map,n=e.length,o=new Qr({teamIds:e,limit:n}),{data:p}=await this.getTeams(o);p.sort((h,y)=>h.id.localeCompare(y.id));let d=await this.idMapping.remapEntities(p,"team");return e.forEach((h,y)=>t.set(h,d[y])),t};getTeams=async(e,t)=>{try{return t=t||!1,await this.https.getTeams(e,t)}catch(n){throw console.warn("There was a problem retrieving all teams",n),n}};getTeamByIdIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let o=await this.getTeamById(e,t);return await this.idMapping.remapEntities(o,"team")}catch(n){throw console.warn(`There was a problem browsing the following team:${e}`,n),n}};getTeamById=async(e,t)=>{try{return t=t||!1,await this.https.getTeamById(e,t)}catch(n){throw console.warn(`There was a problem retrieving the following team: ${e}`,n),n}};getTopTeamsIdMapping=async e=>{try{let t=await this.getTopTeams(e);return await this.idMapping.remapEntities(t,"team")}catch(t){throw console.warn("There was a problem browsing the top teams",t),t}};getTopTeams=async e=>{try{return e=e||!1,await this.https.getTopTeams(e)}catch(t){throw console.warn("There was a problem retrieving the top teams",t),t}};getNextMatchForTeamIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let o=await this.getNextMatchForTeam(e,t);return await this.idMapping.remapEntities(o,"match")}catch(n){throw console.warn(`There was a problem browsing the next match for the following team:${e}`,n),n}};getNextMatchForTeam=async(e,t)=>{try{t=t||!1;let n=await this.https.getNextMatchForTeam(e,t);return await this.footballService.setAvailableMarketsForMatch(n)}catch(n){throw console.warn(`There was a problem retrieving the next match for the following team: ${e}`,n),n}};getPrevMatchForTeamIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let o=await this.getPrevMatchForTeam(e,t);return await this.idMapping.remapEntities(o,"match")}catch(n){throw console.warn(`There was a problem browsing the previous match for the following team:${e}`,n),n}};getPrevMatchForTeam=async(e,t)=>{try{t=t||!1;let n=await this.https.getPrevMatchForTeam(e,t);return await this.footballService.setAvailableMarketsForMatch(n)}catch(n){throw console.warn(`There was a problem retrieving the previous match for the following team: ${e}`,n),n}}};var zr=class{countryId=null;scope=null;name=null;playerIds=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(e){this.countryId=e.countryId?e.countryId:null,this.scope=e.scope?e.scope:null,this.name=e.name?e.name:null,this.playerIds=e.playerIds?e.playerIds:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.sortField=e.sortField?e.sortField:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFilterUrl=()=>{let e="";return this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),this.name&&(e=e+"&",e=e+`name=${this.name}`),this.playerIds&&(e=e+"&",e=e+`player_ids=${this.playerIds.join(",")}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),e}};var Qt=class{https=null;footballService=null;idMapping=null;constructor(e,t,n){this.idMapping=n,this.https=t,this.footballService=new Yt(e)}getPlayersIdMapping=async(e,t)=>{try{let n=!1;if(e){if(e=new zr(e),e.countryId){let p=await this.idMapping.getEntityIdsBySchemaId([e.countryId],"country","native");p.country.length===0&&(n=!0),e.countryId=p.country[0]}if(e.playerIds){let p=await this.idMapping.getEntityIdsBySchemaId(e.playerIds,"player","native");p.player.length===0&&(n=!0),e.playerIds=p.player}if(e.scope){let p=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");p.competition.length===0&&(n=!0),e.scope=p.competition}if(n)return[]}let o=await this.getPlayers(e,t);return o.data=await this.idMapping.remapEntities(o.data,"player"),o}catch(n){throw console.warn("There was a problem browsing the players",n),n}};getPlayersWithNativeIds=async e=>{let t=e.length,n=new zr({playerIds:e,limit:t}),o=await this.getPlayers(n);return o.data.sort((p,d)=>p.id.localeCompare(d.id)),await this.idMapping.remapEntities(o.data,"player")};getPlayersMapWithNativeIds=async e=>{let t={},n=Xt(e);n.sort((p,d)=>p.localeCompare(d));let o=await this.getPlayersWithNativeIds(n);return n.forEach((p,d)=>t[p]=o[d]),t};getPlayers=async(e,t)=>{try{return t=t||!1,await this.https.getPlayers(e,t)}catch(n){throw console.warn("There was a problem retrieving the players",n),n}};getPlayerIdMapping=async(e,t)=>{try{let n=await this.idMapping.getEntityIdsBySchemaId([e],"player","native"),o=await this.getPlayerById(n.player[0],t);return await this.idMapping.remapEntities(o,"player")}catch(n){throw console.warn(`There was a problem browsing the following player:${e}`,n),n}};getPlayerById=async(e,t)=>{try{return t=t||!1,await this.https.getPlayerById(e,t)}catch(n){throw console.warn(`There was a problem retrieving the following player: ${e}`,n),n}};getTopPlayersIdMapping=async e=>{try{let t=await this.getTopPlayers(e);return await this.idMapping.remapEntities(t,"player")}catch(t){throw console.warn("There was a problem browsing the top players",t),t}};getTopPlayers=async e=>{try{return e=e||!1,await this.https.getTopPlayers(e)}catch(t){throw console.warn("There was a problem retrieving the top players",t),t}};getNextMatchForPlayerIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let o=await this.getNextMatchForPlayer(e,t);return await this.idMapping.remapEntities(o,"match")}catch(n){throw console.warn(`There was a problem browsing the next match for player:${e}`,n),n}};getNextMatchForPlayer=async(e,t)=>{try{t=t||!1;let n=await this.https.getNextMatchForPlayer(e,t);return await this.footballService.setAvailableMarketsForMatch(n)}catch(n){throw console.warn(`There was a problem retrieving the next match for player: ${e}`,n),n}};getPrevMatchForPlayerIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let o=await this.getPrevMatchForPlayer(e,t);return await this.idMapping.remapEntities(o,"match")}catch(n){throw console.warn(`There was a problem browsing the previous match for player:${e}`,n),n}};getPrevMatchForPlayer=async(e,t)=>{try{t=t||!1;let n=await this.https.getPrevMatchForPlayer(e,t);return await this.footballService.setAvailableMarketsForMatch(n)}catch(n){throw console.warn(`There was a problem retrieving the previous match for player: ${e}`,n),n}}};var Jr=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 zt=class{https=null;idMapping=null;footballService=null;constructor(e,t,n){this.https=t,this.idMapping=n,this.footballService=new Yt(e)}getMatchesIdMapping=async(e,t)=>{try{if(e){if(e=new Jr(e),e.countryIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.countryIds,"country","native");e.countryIds=o.country}if(e.competitionIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");e.competitionIds=o.competition}if(e.matchIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.matchIds,"match","native");e.matchIds=o.match}if(e.teamIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");e.teamIds=o.team}}let n=await this.getMatches(e,t);return n.data=await this.footballService.setAvailableMarketsForMatch([...n.data]),n.data=await this.idMapping.remapEntities(n.data,"match"),n}catch(n){throw console.warn("There was a problem browsing the matches",n),n}};getMatchesWithNativeIds=async e=>{let t=e.length,n=new Jr({matchIds:e,limit:t}),o=await this.getMatches(n);return o.data.sort((p,d)=>p.id.localeCompare(d.id)),await this.idMapping.remapEntities(o.data,"match")};getMatchesMapWithNativeIds=async e=>{let t={},n=Xt(e);n.sort((p,d)=>p.localeCompare(d));let o=await this.getMatchesWithNativeIds(n);return n.forEach((p,d)=>t[p]=o[d]),t};getMatches=async(e,t)=>{try{return t=t||!1,await this.https.getMatches(e,t)}catch(n){throw console.warn("There was a problem retrieving the matches",n),n}};getMatchIdMapping=async(e,t)=>{try{let n=await this.idMapping.getEntityIdsBySchemaId([e],"match","native"),o=await this.getMatchById(n.match[0],t),p=await this.footballService.setAvailableMarketsForMatch(o);return await this.idMapping.remapEntities(p,"match")}catch(n){throw console.warn(`There was a problem browsing the following match: ${e}`,n),n}};getMatchById=async(e,t)=>{try{return t=t||!1,await this.https.getMatchById(e,t)}catch(n){throw console.warn(`There was a problem retrieving the following match: ${e}`,n),n}}};var Ha=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 $a=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}searchIdMapping=async(e,t)=>{try{if(e=new Ha(e),e.scope){let o=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");e.scope=o.competition}let n=await this.search(e,t);if(n.teams&&n.teams.length>0){let o=await this.idMapping.remapEntities(n.teams,"team");n.teams=o}if(n.players&&n.players.length>0){let o=await this.idMapping.remapEntities(n.players,"player");n.players=o}if(n.competitions&&n.competitions.length>0){let o=await this.idMapping.remapEntities(n.competitions,"competition");n.competitions=o}return n}catch(n){throw console.warn("There was a problem with browsing the search result",n),n}};search=async(e,t)=>{try{return await this.https.search(e,t)}catch(n){throw console.warn("There was a problem retrieving the search response",n),n}}};var qi=class{countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(e,t,n,o){this.countriesFacade=new Ea(t,n,o),this.competitionsFacade=new Ca(t,n,o),this.teamsFacade=new ka(e,n,o),this.playerFacade=new Qt(e,n,o),this.matchFacade=new zt(e,n,o),this.searchFacade=new $a(n,o)}getCountries=async e=>this.countriesFacade.getCountriesWithIdMapping(e);getCompetitions=async(e,t)=>this.competitionsFacade.getCompetitionsIdMapping(e,t);getCompetitionById=async(e,t)=>this.competitionsFacade.getCompetitionByIdIdMapping(e,t);getTopCompetitions=async e=>this.competitionsFacade.getTopCompetitionsIdMapping(e);getCompetitionsMapWithNativeIds=async e=>await this.competitionsFacade.getCompetitionsMapWithNativeIds(e);getTeams=async(e,t)=>this.teamsFacade.getTeamsIdMapping(e,t);getTeamById=async(e,t)=>this.teamsFacade.getTeamByIdIdMapping(e,t);getTopTeams=async e=>this.teamsFacade.getTopTeamsIdMapping(e);getNextMatchForTeam=async(e,t)=>this.teamsFacade.getNextMatchForTeamIdMapping(e,t);getPrevMatchForTeam=async(e,t)=>this.teamsFacade.getPrevMatchForTeamIdMapping(e,t);getTeamsMapWithNativeIds=async e=>await this.teamsFacade.getTeamsMapWithNativeIds(e);getPlayers=async(e,t)=>this.playerFacade.getPlayersIdMapping(e,t);getPlayerById=async(e,t)=>this.playerFacade.getPlayerIdMapping(e,t);getTopPlayers=async e=>this.playerFacade.getTopPlayersIdMapping(e);getNextMatchForPlayer=async(e,t)=>this.playerFacade.getNextMatchForPlayerIdMapping(e,t);getPrevMatchForPlayer=async(e,t)=>this.playerFacade.getPrevMatchForPlayerIdMapping(e,t);getPlayersMapWithNativeIds=async e=>this.playerFacade.getPlayersMapWithNativeIds(e);getMatches=async(e,t)=>this.matchFacade.getMatchesIdMapping(e,t);getMatchById=async(e,t)=>this.matchFacade.getMatchIdMapping(e,t);search=async(e,t)=>this.searchFacade.searchIdMapping(e,t)};var Va=class{id="";alias="";countryCode="";assets=null;name=""};var oe=class{countriesFromResponse=e=>{if(e)return e.map(t=>this.countryFromResponse(t))};countryFromResponse=e=>{try{if(e){let t=new Va;return t.id=e.id,t.alias=e.alias,t.assets=e.assets,t.countryCode=e.country_code,t.name=e.name,t}}catch(t){throw t}return null}};var qa=class{id="";country=null;gender="";assets=null;type="";name=""};var Ne=class{countryRemapper=null;constructor(){this.countryRemapper=new oe}fromResponse(e){try{let t=new qa;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var Wa=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var Ka=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName=""};var we=class{countryRemapper=null;constructor(){this.countryRemapper=new oe}fromResponse(e){try{let t=new Ka;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t}catch(t){throw console.warn("There was a problem remapping teams response",t),t}}};var Xa=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new oe,this.teamBasicRemapper=new we}fromResponse(e){try{let t=new Wa;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t.participants=e.participants.map(n=>this.teamBasicRemapper.fromResponse(n)),t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var Ya=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";squad=[]};var Qa=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var za=class{countryRemapper=null;constructor(){this.countryRemapper=new oe}fromResponse(e){try{let t=new Qa;return t.id=e.id,t.startDate=e.start_date,t.endDate=e.end_date,t.shirtNumber=e.shirt_number,t.loan=e.loan,t.position=e.position,t.country=this.countryRemapper.countryFromResponse(e.country),t.name=e.name,t.assets=e.assets,t.birthDate=e.birth_date,t}catch(t){throw console.warn("There was a problem remapping the player from squad",t),t}}};var Ja=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new oe,this.competitionRemapper=new Ne,this.playerRemapper=new za}fromResponse(e){try{let t=new Ya;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t.competitions=e.competitions?e.competitions.map(n=>this.competitionRemapper.fromResponse(n)):[],t.squad=e.squad?e.squad.map(n=>this.playerRemapper.fromResponse(n)):[],t}catch(t){throw console.warn("There was a problem remapping team response",t),t}}};var Za=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 ja=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var Wi=class{fromResponse(e){try{let t=new ja;return t.ftScore=this.statEntityFromResponse(e.ft_score),t.htScore=this.statEntityFromResponse(e.ht_score),t.aetScore=this.statEntityFromResponse(e.aet_score),t.aggScore=this.statEntityFromResponse(e.agg_score),t.penScore=this.statEntityFromResponse(e.pen_score),t}catch(t){throw console.warn("There was a problem remapping the scores",t),t}}statEntityFromResponse=e=>({homeGoals:e.home_goals,awayGoals:e.away_goals})};var eo=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new we,this.competitionRemapper=new Ne,this.scoresRemapper=new Wi}fromResponse(e){try{let t=new Za;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.homeTeam=this.teamRemapper.fromResponse(e.home_team),t.awayTeam=this.teamRemapper.fromResponse(e.away_team),t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresRemapper.fromResponse(e.scores),t.context={competition:e.context.competition?this.competitionRemapper.fromResponse(e.context.competition):null},t.status={type:e.status.type,subType:e.status.sub_type},t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var to=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 io=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 ro=class{fromResponse(e){try{let t=new io;return t.corners=this.statEntityFromResponse(e.corners),t.crosses=this.statEntityFromResponse(e.crosses),t.offside=this.statEntityFromResponse(e.offside),t.shotsOn=this.statEntityFromResponse(e.shots_on),t.throwIn=this.statEntityFromResponse(e.throw_in),t.redCards=this.statEntityFromResponse(e.red_cards),t.shotsOff=this.statEntityFromResponse(e.shots_off),t.goalKicks=this.statEntityFromResponse(e.goal_kicks),t.possession=this.statEntityFromResponse(e.possession),t.treatments=this.statEntityFromResponse(e.treatments),t.yellowCards=this.statEntityFromResponse(e.yellow_cards),t.shotsBlocked=this.statEntityFromResponse(e.shots_blocked),t.substitutions=this.statEntityFromResponse(e.substitutions),t.counterAttacks=this.statEntityFromResponse(e.counter_attacks),t.foulsCommitted=this.statEntityFromResponse(e.fouls_committed),t}catch(t){throw console.warn("There was a problem remapping the stats",t),t}}statEntityFromResponse=e=>({homeTeam:e?e.home_team:null,awayTeam:e?e.away_team:null})};var Ki=class{homeTeam={players:[]};awayTeam={players:[]}};var no=class{id="";name="";position="";shirtNumber;assets=null;type=""};var Xi=class{fromResponse(e){try{let t=new no;return t.id=e.id,t.name=e.name,t.position=e.position,t.shirtNumber=e.shirt_number,t.assets=e.assets,t.type=e.type,t}catch(t){throw console.warn("There was a problem remapping the player from timeline",t),t}}};var ao=class{playerRemapper=null;constructor(){this.playerRemapper=new Xi}fromResponse(e){try{let t=new Ki;return t.homeTeam.players=e.home_team&&e.home_team.players?e.home_team.players.map(n=>this.playerRemapper.fromResponse(n)):[],t.awayTeam.players=e.away_team&&e.away_team.players?e.away_team.players.map(n=>this.playerRemapper.fromResponse(n)):[],t}catch(t){throw console.warn("There was a problem remapping the lineups",t),t}}};var oo=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var so=class{playerRemapper=null;constructor(){this.playerRemapper=new Xi}fromResponse(e){try{let t=new oo;return t.minute=e.minute,t.type=e.type,t.teamId=e.team_id,t.player=this.playerRemapper.fromResponse(e.player),t.relatedPlayer=e.related_player?this.playerRemapper.fromResponse(e.related_player):null,t.updatedAt=e.updated_at,t}catch(t){throw console.warn("There was a problem remapping timeline",t),t}}};var lo=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new we,this.competitionsMapper=new Ne,this.lineupsMapper=new ao,this.scoresMapper=new Wi,this.statsMapper=new ro,this.timelineMapper=new so}fromResponse(e){try{let t=new to;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.homeTeam=e.home_team?this.teamMapper.fromResponse(e.home_team):null,t.awayTeam=e.away_team?this.teamMapper.fromResponse(e.away_team):null,t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresMapper.fromResponse(e.scores),t.stats=this.statsMapper.fromResponse(e.stats),t.context={competition:this.competitionsMapper.fromResponse(e.context.competition)},t.timeline=e.timeline?e.timeline.map(n=>this.timelineMapper.fromResponse(n)):[],t.status={type:e.status.type,subType:e.status.sub_type},t.lineups=e.lineups?this.lineupsMapper.fromResponse(e.lineups):new Ki,t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var po=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var co=class{countryRemapper=null;constructor(){this.countryRemapper=new oe}fromResponse(e){try{let t=new po;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping top player response",t),t}}};var uo=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;teams=[]};var Yi=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new oe,this.teamRemapper=new we}fromResponse(e){try{let t=new uo;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(n=>this.teamRemapper.fromResponse(n)):[],t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping players response",t),t}}};var mo=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;competitions=[];teams=[]};var fo=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new oe,this.teamRemapper=new we,this.competitionRemapper=new Ne}fromResponse(e){try{let t=new mo;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(n=>this.teamRemapper.fromResponse(n)):[],t.position=e.position,t.competitions=e.competitions?e.competitions.map(n=>this.competitionRemapper.fromResponse(n)):[],t}catch(t){throw console.warn("There was a problem remapping player response",t),t}}};var ho=class{teams=null;players=null;competitions=null};var go=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new we,this.playerRemapper=new Yi,this.competitionremapper=new Ne}fromResponse(e){try{let t=new ho;return t.teams=e.teams?e.teams.map(n=>this.teamRemapper.fromResponse(n)):[],t.players=e.players?e.players.map(n=>this.playerRemapper.fromResponse(n)):[],t.competitions=e.competitions?e.competitions.map(n=>this.competitionremapper.fromResponse(n)):[],t}catch(t){throw console.warn("There was a problem remapping search response",t),t}}};var Qi=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var Jt=class{pagination=new Qi};var zi=class{meta=new Jt;data=[]};var yo=class{remapMetaProp=e=>{let t=new Jt;return t.pagination.currentPage=e.pagination.current_page,t.pagination.itemsPerPage=e.pagination.items_per_page,t.pagination.totalItems=e.pagination.total_items,t.pagination.numberOfPages=e.pagination.number_of_pages,t}};var wt=class extends Me{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){super(e,Oe(e.environment,"football"));this.clientId=e.clientId,this.apiSignInUrl=`?key=${e.apiKey}&lang=${e.lang}`,this.countryRemapper=new oe,this.competitionBasicRemapper=new Ne,this.competitionFullRemapper=new Xa,this.teamBasicRemapper=new we,this.teamFullRemapper=new Ja,this.matchBasicRemapper=new eo,this.matchFullRemapper=new lo,this.playerBasicRemapper=new Yi,this.playerFullRemapper=new fo,this.topPlayerRemapper=new co,this.searchRemapper=new go,this.footballMetaRemapper=new yo}getCountries=async e=>{try{let t=`/countries${this.apiSignInUrl}`,n=Date.now();e&&(t+=`&disable_cache=${n}`);let o=await this.instance.get(t);return this.countryRemapper.countriesFromResponse(o.data.data)}catch(t){throw console.warn("There was a problem with the football countries request",t),t}};getCompetitions=async(e,t)=>{try{let n={},o=Date.now();if(t=t||!1,e&&e.competitionIds&&e.competitionIds.length>this.limitIds-1){let p=[],d=ea(e.competitionIds);for(let y of d){e.competitionIds=y;let I=`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(I+=`&disable_cache=${o}`),n=await this.instance.get(I),p.push(n.data.data.map(b=>this.competitionBasicRemapper.fromResponse(b)))}return Array.prototype.concat.apply([],p)}else{let p=`/competitions${this.apiSignInUrl}`;return e&&(p+=`${e.constructFilterUrl()}`),t&&(p+=`&disable_cache=${o}`),n=await this.instance.get(p),n.data.data.map(d=>this.competitionBasicRemapper.fromResponse(d))}}catch(n){throw console.warn("There was a problem with getCompetitions request",n),n.response}};getCompetitionById=async(e,t)=>{try{let n=`/competitions/${e}${this.apiSignInUrl}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.competitionFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getCompetitionById request",n),n.response}};getTopCompetitions=async e=>{try{let t=`/competitions/top${this.apiSignInUrl}&client_id=${this.clientId}`,n=Date.now();return e&&(t+=`&disable_cache=${n}`),(await this.instance.get(t)).data.data.map(p=>this.competitionBasicRemapper.fromResponse(p))}catch(t){throw console.warn("There was a problem with getTopCompetitions request",t),t.response}};getTeams=async(e,t)=>{try{let n={},o=Date.now();if(e&&e.teamIds&&e.teamIds.length>this.limitIds){let p=[],d=ea(e.teamIds);for(let y of d){e.teamIds=y;let I=`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(I+=`disable_cache=${o}`),n=await this.instance.get(I),p.push(n.data.data.map(b=>this.teamBasicRemapper.fromResponse(b)))}return Array.prototype.concat.apply([],p)}else{let p=new zi,d=`/teams${this.apiSignInUrl}`;return e&&(d+=`${e.constructFilterUrl()}`),t&&(d+=`&disable_cache=${o}`),n=await this.instance.get(d),p.meta=this.footballMetaRemapper.remapMetaProp(n.data.meta),p.data=n.data.data.map(h=>this.teamBasicRemapper.fromResponse(h)),p}}catch(n){throw console.warn("There was a problem with getTeams request",n),n.response}};getTeamById=async(e,t)=>{try{let n=`/teams/${e}${this.apiSignInUrl}`,o=Date.now();t&&(n+=`disable_cache=${o}`);let p=await this.instance.get(n);return this.teamFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getTeamById request",n),n.response}};getTopTeams=async e=>{try{let t=`/teams/top${this.apiSignInUrl}&client_id=${this.clientId}`,n=Date.now();e&&(t+=`$disable_cache=${n}`);let o=await this.instance.get(t);return o.data.data?o.data.data.map(p=>this.teamBasicRemapper.fromResponse(p)):[]}catch(t){throw console.warn("There was a problem with getTopTeams request",t),t.response}};getNextMatchForTeam=async(e,t)=>{try{let n=`/teams/${e}/next-match${this.apiSignInUrl}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getNextMatchForTeam request",n),n.response}};getPrevMatchForTeam=async(e,t)=>{try{let n=`/teams/${e}/previous-match${this.apiSignInUrl}`,o=Date.now();t&&(n+=`disable_cache=${o}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getPrevMatchForTeam request",n),n.response}};getPlayers=async(e,t)=>{try{let n={},o=Date.now();if(e&&e.playerIds&&e.playerIds.length>this.limitIds-1){let p=[],d=ea(e.playerIds);for(let y of d){e.playerIds=y;let I=`/players${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(I+=`&disable_cache=${o}`),n=await this.instance.get(I),p.push(n.data.data.map(b=>this.teamBasicRemapper.fromResponse(b)))}return Array.prototype.concat.apply([],p)}else{let p=new zi,d=`/players${this.apiSignInUrl}`;return e&&(d+=`${e.constructFilterUrl()}`),t&&(d+=`&disable_cache=${o}`),n=await this.instance.get(d),p.meta=this.footballMetaRemapper.remapMetaProp(n.data.meta),p.data=n.data.data.map(h=>this.playerBasicRemapper.fromResponse(h)),p}}catch(n){throw console.warn("There was a problem with getPlayers request",n),n.response}};getPlayerById=async(e,t)=>{try{let n=`/players/${e}${this.apiSignInUrl}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.playerFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getPlayerById request",n),n.response}};getTopPlayers=async e=>{try{let t=`/players/top${this.apiSignInUrl}&client_id=${this.clientId}`,n=Date.now();return e&&(t+=`&disable_cache=${n}`),(await this.instance.get(t)).data.data.map(p=>this.topPlayerRemapper.fromResponse(p))}catch(t){throw console.warn("There was a problem with getTopPlayers request",t),t.response}};getNextMatchForPlayer=async(e,t)=>{try{let n=`/players/${e}/next-match${this.apiSignInUrl}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getNextMatchForPlayer request",n),n.response}};getPrevMatchForPlayer=async(e,t)=>{try{let n=`/players/${e}/previous-match${this.apiSignInUrl}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getPrevMatchForPlayer request",n),n.response}};getMatchById=async(e,t)=>{try{let n=`/matches/${e}${this.apiSignInUrl}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getMatchById request",n),n.response}};getMatches=async(e,t)=>{try{let n=new zi,o=`/matches${this.apiSignInUrl}`,p=Date.now();e&&(o+=`${e.constructFilterUrl()}`),t&&(o+=`&disable_cache=${p}`);let d=await this.instance.get(o);return n.meta=this.footballMetaRemapper.remapMetaProp(d.data.meta),n.data=d.data.data.map(h=>this.matchBasicRemapper.fromResponse(h)),n}catch(n){throw console.warn("There was a problem with getMatches request",n),n.response}};search=async(e,t)=>{try{let n=`/search${this.apiSignInUrl}${e.constructFilterUrl()}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.searchRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with search request",n),n.response}}};var _e=(N=>(N.FT_1X2="FT_1X2",N.HT_1X2="HT_1X2",N.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",N.DOUBLE_CHANCE="DOUBLE_CHANCE",N.HT_FT="HT_FT",N.PLAYER_SCORE="PLAYER_SCORE",N.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",N.PLAYER_RED_CARD="PLAYER_RED_CARD",N.RED_CARD_MATCH="RED_CARD_MATCH",N.PENALTY_MATCH="PENALTY_MATCH",N.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",N.CORNERS_MATCH="CORNERS_MATCH",N.CORRECT_SCORE="CORRECT_SCORE",N.CORRECT_SCORE_ADVANCED="CORRECT_SCORE_ADVANCED",N.CORRECT_SCORE_HT="CORRECT_SCORE_HT",N.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",N.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",N.OVER_GOALS_0_5="OVER_GOALS_0_5",N.OVER_GOALS_1_5="OVER_GOALS_1_5",N.OVER_GOALS_2_5="OVER_GOALS_2_5",N.OVER_GOALS_3_5="OVER_GOALS_3_5",N.OVER_GOALS_4_5="OVER_GOALS_4_5",N.OVER_GOALS_5_5="OVER_GOALS_5_5",N.OVER_GOALS_6_5="OVER_GOALS_6_5",N.OVER_CORNERS_6_5="OVER_CORNERS_6_5",N.OVER_CORNERS_7_5="OVER_CORNERS_7_5",N.OVER_CORNERS_8_5="OVER_CORNERS_8_5",N.OVER_CORNERS_9_5="OVER_CORNERS_9_5",N.OVER_CORNERS_10_5="OVER_CORNERS_10_5",N.OVER_CORNERS_11_5="OVER_CORNERS_11_5",N.OVER_CORNERS_12_5="OVER_CORNERS_12_5",N.OVER_CORNERS_13_5="OVER_CORNERS_13_5",N))(_e||{}),Sd=["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"],Td=["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"],bt=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"],Ed=["FT_1X2","HT_1X2","HT_FT","DOUBLE_CHANCE","CORNERS_MATCH","CORRECT_SCORE","CORRECT_SCORE_HT","CORRECT_SCORE_ADVANCED"],Zr="PLAYER_SCORE_FIRST_GOAL";var Mo=class{overallPercent;byFootballCompetition;byFootballTeam;byFootballMarket};var wo=class{profileId;tier;points;successRates=new Mo};var bo=class{successRatePercent;model=null};var vo=class{id=null;label=null};var Io=class{type=null;id=null;label=null};var Ji=class{content=new Io;tags=[];campaign=new vo};var Zi=class{id=null;profileId=null;action=null;context=new Ji;points=0};var Po=class{totalItems=0};var _o=class{meta=new Po;data=[new Zi]};var Ro=class{remapSingleResponse=e=>{let t=new Zi;return t.id=e.id,t.profileId=e.profile_id,t.action=e.action,t.context.content=e.context.content??t.context.content,t.context.tags=e.context.tags,t.context.campaign=e.context.campaign??t.context.campaign,t.points=e.points,t};remapActivitiesResponse=e=>{let t=new _o;return t.meta.totalItems=e.meta.total_items,t.data=e.data.map(n=>this.remapSingleResponse(n)),t};remapStatsReponse=e=>{let t=new wo;return t.profileId=e.profile_id,t.tier=e.tier,t.points=e.points,t.successRates.overallPercent=e.success_rates.overall_percent,t.successRates.byFootballCompetition=this.constructNewRecord(e.success_rates.by_competition),t.successRates.byFootballTeam=this.constructNewRecord(e.success_rates.by_team),t.successRates.byFootballMarket=this.constructNewRecord(e.success_rates.by_market),t};constructNewRecord=e=>{let t;if(Object.entries(e).length)Object.entries(e).forEach(([n,o])=>{t={...t,[n]:this.remapSuccessRatePercent(o)},_e[n]&&delete t[n].model});else return e;return t};remapSuccessRatePercent=e=>{let t=new bo;return t.successRatePercent=e.success_rate_percent,t}};var ji=class extends Me{activityRemapper=null;apiSignInUrl=null;constructor(e){super(e,Oe(e.environment,"loyalty"));this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.activityRemapper=new Ro}createActivity=async e=>{try{let t=`/activities${this.apiSignInUrl}`,n=await this.instanceAuth.post(t,JSON.stringify(e));return this.activityRemapper.remapSingleResponse(n.data)}catch(t){throw console.warn("There was a problem with creating activity for user",t),t}};deleteActivity=async e=>{try{let t=`/activities/${e}${this.apiSignInUrl}`;return await this.instanceAuth.delete(t),!0}catch(t){throw console.warn(`There was a problem deleting the following activity: ${e}`,t),t.response}};getOwnActivities=async(e,t)=>{try{let n=`/activities${this.apiSignInUrl}`,o=Date.now();e&&(n+=`${e.constructFilterUrl()}`),t&&(n+=`disable_cache=${o}`);let p=await this.instanceAuth.get(n);return this.activityRemapper.remapActivitiesResponse(p.data)}catch(n){throw console.warn("There was a problem with fetching own activities",n),n}};getActivitiesForUser=async(e,t,n)=>{try{let o=`/users/${e}/activities${this.apiSignInUrl}`,p=Date.now();t&&(o+=`${t.constructFilterUrl()}`),n&&(o+=`disable_cache=${p}`);let d=await this.instance.get(o);return this.activityRemapper.remapActivitiesResponse(d.data)}catch(o){throw console.warn(`There was a problem with fetching activities for user ${e}`,o),o}};getStats=async(e,t)=>{try{let n="",o=null;return e?(n+=de(t)?`/users/${e}/statistics${this.apiSignInUrl}${fe()}`:`/users/${e}/statistics${this.apiSignInUrl}`,o=await this.instance.get(n)):(n+=`/statistics${this.apiSignInUrl}`,o=await this.instanceAuth.get(n)),this.activityRemapper.remapStatsReponse(o.data.data)}catch(n){throw console.warn("There was a problem fetching profile`s statistics:",n),n.response}}};var Fo=class{idMapping=null;idSchema=null;native="native";footballFacade=null;constructor(e,t,n){this.idMapping=n,this.idSchema=e.idSchema,this.footballFacade=t}remapSuccessRatesEntities=async e=>{let{successRates:t}=e,n={competition:this.getIdsKeys(t.byFootballCompetition),team:this.getIdsKeys(t.byFootballTeam)};if(Object.values(n).flat().length){let o=e.successRates.byFootballCompetition,p=e.successRates.byFootballTeam;return e.successRates.byFootballCompetition=await this.setModels(o,n.competition,"competition"),e.successRates.byFootballTeam=await this.setModels(p,n.team,"team"),e}return e};setModels=async(e,t,n)=>{let o=null,p;switch(t=Hr(t),n){case"competition":o=await this.footballFacade.getCompetitionsMapWithNativeIds(t);break;case"team":o=await this.footballFacade.getTeamsMapWithNativeIds(t);break}return Object.keys(e).forEach(d=>{let h=o.get(d);p={...p,[h.id]:e[d]},p[h.id].model=h}),p};getIdsKeys=e=>{let t=JSON.parse(JSON.stringify(e));return Object.keys(t)};remapInterestsToIdSchema=async e=>{if(this.idSchema!==this.native)if(e&&e.length>0){let t={},n={};e.forEach(d=>{t.hasOwnProperty(d.type)||(t[d.type]=[],n[d.type]=[]),t[d.type].push(d.id),n[d.type].push(d)});let o=await this.remapIdsObj(t,this.native,this.idSchema),p=[];for(let[d,h]of Object.entries(n))h.forEach((y,I)=>{y.id=o[d][I],p.push(y)});return p}else return e;return e};remapInterestToNative=async e=>{if(this.idSchema!==this.native){let t={},{id:n,type:o}=e;t[o]=[n];let p=await this.remapIdsObj(t,this.idSchema,this.native);return e.id=p[o][0],e}return e};inquiryCustomInterests=e=>{let t=[];return e&&e.length>0&&(t=e.filter(n=>n.source.toLocaleUpperCase()==="CUSTOM")),t};remapInterests=async e=>{let t=this.inquiryCustomInterests(e);if(t&&t.length>0){let n=e.filter(p=>p.source.toLocaleUpperCase()!=="CUSTOM"),o=await this.remapInterestsToIdSchema(n);return t.forEach(p=>o.push(p)),o}return await this.remapInterestsToIdSchema(e)};showFullInterests=async e=>{let t=[];if(e&&e.length>0){let n=this.inquiryCustomInterests(e);t.push(n);let o=e.filter(I=>I.source.toLocaleUpperCase()!=="CUSTOM"),{competitionsMap:p,teamsMap:d,playersMap:h}=await this.getInterestsEntitiesMap(o),y=o.map(I=>{let b=null;if(I.type==="competition")return b=p.get(I.id),b&&(I.id=b.id),I.model=b,I;if(I.type==="team")return b=d.get(I.id),b&&(I.id=b.id),I.model=b,I;if(I.type==="player")return h?(I.model=h[I.id],I.id=h[I.id].id):I.model=b,I});return t.push(y),t.flat()}return t};getInterestsEntitiesMap=async e=>{let t=[],n=[],o=[],p=new Map,d=new Map,h=null;if(e.forEach(y=>{y.type==="competition"?t.push(y.id):y.type==="team"?n.push(y.id):y.type==="player"&&o.push(y.id)}),t.length){let y=Hr(t);p=await this.footballFacade.getCompetitionsMapWithNativeIds(y)}if(n.length){let y=Hr(n);d=await this.footballFacade.getTeamsMapWithNativeIds(y)}if(o.length){let y=Hr(o);h=await this.footballFacade.getPlayersMapWithNativeIds(y)}return{competitionsMap:p,teamsMap:d,playersMap:h}};remapIdsObj=async(e,t,n)=>await this.idMapping.idMappingFacade.getEntitiesByIds(e,t,n)};var So=class{idMapping=null;profileOperations=null;constructor(e,t){this.idMapping=new ae(e),this.profileOperations=new Fo(e,t,this.idMapping)}remapSuccessRatesEntities=async e=>await this.profileOperations.remapSuccessRatesEntities(e);remapInterestToNative=async e=>await this.profileOperations.remapInterestToNative(e);remapInterests=async e=>await this.profileOperations.remapInterests(e);showFullInterests=async e=>await this.profileOperations.showFullInterests(e)};var er=class{idsRemapper=null;profileHttps=null;activityHttps=null;footballHttps=null;footballFacade=null;idMapping=null;localStorage=null;profileFacade=null;ownProfileBuilder=null;profileBuilder=null;constructor(e){this.profileHttps=new Ui(e),this.activityHttps=new ji(e),this.footballHttps=new wt(e),this.idMapping=new ae(e),this.localStorage=new yt(e),this.footballFacade=new qi(e,this.localStorage,this.footballHttps,this.idMapping),this.profileFacade=new Mt(this.localStorage,this.profileHttps,this.activityHttps),this.idsRemapper=new So(e,this.footballFacade),this.ownProfileBuilder=new Sa(this.idsRemapper,this.localStorage,this.profileHttps,this.activityHttps,this.idMapping,this.footballFacade),this.profileBuilder=new Ta(this.idsRemapper,this.localStorage,this.profileHttps,this.activityHttps)}getOwn=()=>this.ownProfileBuilder;getById=e=>this.profileBuilder.setId(e);getCountries=async e=>await this.profileFacade.getCountries(e);getByIds=async(e,t)=>await this.profileFacade.getByIds(e,t)};var To=class{validate=e=>{let t=this.validateField(e.lang),n=this.generateMessage(t);return{validation:t,message:n}};validateField=e=>{let t=["bg","ro","en"],n=null;return e!=null&&e.length>0?t.includes(e)?n="valid":n="invalid":n="missing",n};generateMessage=e=>{let t=null,n="warning";return e==="missing"&&(t="If no lang is passed the default one will be set which is: en"),e==="invalid"&&(t="This lang value is not supported, the default one will be set which is: en"),e==="valid"&&(t=null,n=null),{text:t,type:n}}};var Eo=class{validate(e){let t=this.validateField(e.environment),n=this.generateMessage(t);return{validation:t,message:n}}validateField=e=>{let t=["dev","staging","prod"],n=null;return e!=null&&e.length>0?t.includes(e)?n="valid":n="invalid":n="missing",n};generateMessage=e=>{let t=null,n="warning";return e==="missing"&&(t="If no environment is passed the default one will be set which is: prod"),e==="invalid"&&(t="This environment value is not supported, the default one will be set which is: prod"),e==="valid"&&(t=null,n=null),{text:t,type:n}}};var Co=class{validate(e){let t=this.validateField(e.apiKey),n=this.generateMessage(t);return{validation:t,message:n}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,n="error";return e==="missing"&&(t="The field apiKey with valid value must be provided to use Fans United JS SDK"),e==="valid"&&(n=null),{text:t,type:n}}};var Ao=class{validate(e){let t=this.validateField(e.idSchema),n=this.generateMessage(t);return{validation:t,message:n}}validateField=e=>{let t=["native","sportal365","enetpulse","sportradar"],n=null;return e!=null&&e.length>0?t.includes(e)?n="valid":n="invalid":n="missing",n};generateMessage=e=>{let t=null,n="warning";return e==="missing"&&(t="If no idSchema is passed the default one will be set which is: native"),e==="invalid"&&(t="This idSchema value is not supported, the default one will be set which is: native"),e==="valid"&&(t=null,n=null),{text:t,type:n}}};var fi=class{getIdToken=null;logout=null};var ir=class{text=null;type=null};var xo=class{validation=null;message=new ir;getIdToken={validation:null,message:new ir};logout={validation:null,message:new ir}};var Oo=class{validate(e){let t=this.validateAuthProvider(e.authProvider);return t.validation!=="missing"&&(t=this.validateAuthProviderConfigFields(e.authProvider,t),t=this.generateAuthProviderConfigMessages(t),t=this.checkAuthProviderConfigMessagesForErrors(t)),t}validateAuthProvider=e=>{let t=Object.keys(new fi),n=new xo;if(e){let p=Object.keys(e).filter(d=>!t.includes(d));p.length>0?(n.validation="invalid",n.message.type="warning",n.message.text=`${"You have passed a property which is not supported for the authentication provider:"} ${p.join(",")}`):n.validation="valid"}else n.validation="missing",n.message.type="error",n.message.text="The field authProvider must be provided to use this SDK";return n};validateAuthProviderConfigFields=(e,t)=>(Object.keys(new fi).forEach(o=>{e[o]?t[o].validation="valid":t[o].validation="missing"}),t);generateAuthProviderConfigMessages=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{let n=e[t];n.validation==="missing"&&(n.message.text=`${"The following property is missing from the authProvider object:"} ${t}`,n.message.type="error")}),e);checkAuthProviderConfigMessagesForErrors=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{e[t].validation==="missing"&&e.validation==="valid"&&(e.validation="invalid",e.message.type="error",e.message.text="The field authProvider has missing properties")}),e)};var en=class{validation;message};var Bo=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;authProvider={getIdToken:new en,logout:new en};isValid=!1};var Lo=class{validate(e){let t=this.validateField(e.clientId),n=this.generateMessage(t);return{validation:t,message:n}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,n="error";return e==="missing"&&(t="The field clientId must be provided to use Fans United JS SDK"),e==="valid"&&(t=null,n=null),{text:t,type:n}}};var No=class{validate=e=>{let t=this.checkFieldsForValues(e);return t.isValid=this.containsErrorMessage(t),t};checkFieldsForValues=e=>{let t=new Bo,n={apiKey:new Co,environment:new Eo,idSchema:new Ao,clientId:new Lo,lang:new To,authProvider:new Oo};for(let[o,p]of Object.entries(t))o!=="isValid"&&(p=n[o].validate(e));return Object.keys(n).forEach(o=>{t[o]=n[o].validate(e)}),t};containsErrorMessage=e=>{let t=!0;for(let[n,o]of Object.entries(e))if(n!=="authProvider"){if(n!=="isValid"&&o.message.type==="error")return t=!1,t;if(n!=="isValid"&&o.message.type==="warning")return t=!0,t}else if(o.message.type==="error")return t=!1,t;return t}};var Do=class{https=null;idMapping=null;localStorage=null;footballFacade=null;constructor(e){this.https=new wt(e),this.idMapping=new ae(e),this.localStorage=new yt(e),this.footballFacade=new qi(e,this.localStorage,this.https,this.idMapping)}getCountries=async e=>await this.footballFacade.getCountries(e);getCompetitions=async(e,t)=>await this.footballFacade.getCompetitions(e,t);getCompetitionById=async(e,t)=>await this.footballFacade.getCompetitionById(e,t);getTopCompetitions=async e=>await this.footballFacade.getTopCompetitions(e);getTeams=async(e,t)=>await this.footballFacade.getTeams(e,t);getTeamById=async(e,t)=>await this.footballFacade.getTeamById(e,t);getTopTeams=async e=>await this.footballFacade.getTopTeams(e);getNextMatchForTeam=async(e,t)=>await this.footballFacade.getNextMatchForTeam(e,t);getPrevMatchForTeam=async(e,t)=>await this.footballFacade.getPrevMatchForTeam(e,t);getPlayers=async(e,t)=>await this.footballFacade.getPlayers(e,t);getPlayerById=async(e,t)=>await this.footballFacade.getPlayerById(e,t);getTopPlayers=async e=>await this.footballFacade.getTopPlayers(e);getNextMatchForPlayer=async(e,t)=>await this.footballFacade.getNextMatchForPlayer(e,t);getPrevMatchForPlayer=async(e,t)=>await this.footballFacade.getPrevMatchForPlayer(e,t);getMatches=async(e,t)=>await this.footballFacade.getMatches(e,t);getMatchById=async(e,t)=>await this.footballFacade.getMatchById(e,t);search=async(e,t)=>await this.footballFacade.search(e,t)};var Uo=class{value=null;playerId=null;playerModel=null};var rr=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new Uo;result=null};var Go=class{value=!1;playerId=null};var tt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n,o){this.matchId=e,this.market=t,this.prediction=new Go,this.prediction.value=n,this.prediction.playerId=o}};var nr=class{settledAt=null;resettledAt=null;status=null;outcome=null;points=0};var ko=class{value=null};var Zt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new ko,this.prediction.value=n}};var it=class{value=!1};var ar=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new it,this.prediction.value=n}};var or=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new it,this.prediction.value=n}};var Ho=class{matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t,n){this.matchFacade=e,this.playerFacade=t,this.predictorService=n}remapFixturesRequest=e=>{let t={};if(t.match_id=e.matchId,t.match_type="FOOTBALL",e instanceof tt)t.market=e.market,t.prediction=e.prediction.value,t.player_id=e.prediction.playerId;else if(e instanceof ar||e instanceof or)t.market=e.market,t.prediction=e.prediction.value;else if(e instanceof Zt){t.market=e.market;let n=e.prediction.value.split(":");t.goals_home=Number(n[0]),t.goals_away=Number(n[1])}else t.market=e.market,t.prediction=e.prediction.value;return t};remapFixturesResponse=async e=>{e.length>1&&e.sort((h,y)=>h.match_id.localeCompare(y.match_id));let t=[],n=[];for(let h of e)t.push(h.match_id),h.player_id&&!n.includes(h.player_id)&&n.push(h.player_id);let o=await this.matchFacade.getMatchesMapWithNativeIds(t),p=[];n.sort((h,y)=>h.localeCompare(y)),n&&n.length>0&&(p=await this.playerFacade.getPlayersMapWithNativeIds(n));let d=[];for(let h of e){let y=new rr;h.target?y.market=this.predictorService.convertMarketForResponseModel(h.market,h.target):y.market=h.market,y.matchId=o[h.match_id].id,y.matchType=h.match_type,y.matchModel=o?o[h.match_id]:null,delete y.matchModel.availableMarkets,h.goals_home!==void 0&&h.goals_away!==void 0?y.prediction.value=h.goals_home.toString()+":"+h.goals_away.toString():y.prediction.value=h.prediction,y.prediction.playerId=h.player_id?h.player_id:null,y.prediction.playerId&&(y.prediction.playerModel=p[h.player_id],y.prediction.playerId=p[h.player_id].id),y.result=this.remapResult(h.result),d.push(y)}return d};remapResult=e=>{let t=new nr;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t.points=e.points,t}};var jt=class{goldenGoal=null};var tn=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new jt;points=null;createdAt=null;updatedAt=null};var j=class{no=0;yes=0};var sr=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new j;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new j;penaltyMatch=new j;playerScoreFirstGoal={};cornersMatch={};correctScore={};correctScoreHalfTime={};correctScoreAdvanced={};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 vt=class{timeTiebreaker=!1};var hi=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new vt;predictionId=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;scheduleOpenAt=null;images=null};var gi=class{userId=null;points=null;results=[];tiebreaker=null};var $o=(p=>(p.ACTIVE="ACTIVE",p.WON="WON",p.LOST="LOST",p.PARTIALLY_WON="PARTIALLY_WON",p.CANCELED="CANCELED",p))($o||{}),Tp=["WON","LOST","PARTIALLY_WON","CANCELED"];var Re=class{limit=null;startAfter=null;status=null;type=null;matchIds=null;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null,this.status=e.status?e.status:null,this.type=e.type?e.type:null,this.matchIds=e.matchIds?e.matchIds:null}constructFiltersUrl=()=>{let e="",t=!1;return this.status&&(t=Object.values($o).some(n=>this.status.includes(n))),this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),this.status&&t&&(e+="&",e+=`status=${this.status.join(",")}`),this.type&&(e+="&",e+=`game_types=${this.type}`),this.matchIds&&(e+="&",e+=`match_ids=${this.matchIds.join(",")}`),e}};var lr=class{limit;startAfter;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null}constructMainFiltersUrl(){let e="";return this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),e}};var rn=(d=>(d.OPEN="OPEN",d.LIVE="LIVE",d.PENDING="PENDING",d.CANCELED="CANCELED",d.CLOSED="CLOSED",d.SETTLED="SETTLED",d))(rn||{});var rt=class extends lr{status=null;type=null;gameIds=null;sortOrder=null;constructor(e){super(e);this.status=e.status?e.status:null,this.type=e.type?e.type:null,this.gameIds=e.gameIds?e.gameIds:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFiltersUrl=()=>{let e=super.constructMainFiltersUrl();return this.status&&Object.values(rn).includes(this.status)&&(e+="&",e+=`status=${this.status}`),this.type&&(e+="&",e+=`type=${this.type}`),this.gameIds&&this.gameIds.length>0&&(e+="&",e+=`game_ids=${this.gameIds.join(",")}`),this.sortOrder&&(e+="&",e+=`sort_order=${this.sortOrder}`),e}};var pr=class{main=null;cover=null;mobile=null};var yi=class{id=null;title=null;description=null;type=null;status=null;scheduleOpenAt=null;predictionsCutoff=null;fixtures=[];tiebreaker=new vt;rules=null;flags=null;images=new pr;createdAt=null;updatedAt=null};var Nt=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new vt;predictionId=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;images=null;scheduleOpenAt=null};var Ep={UNEXPECTED_STATUS_PROP:`Unexpected provided property 'status'. You can NOT use this property for this method. For more information visit our documentation:
|
|
21
|
+
`),function(h){if(p=h.indexOf(":"),n=dp.trim(h.substr(0,p)).toLowerCase(),o=dp.trim(h.substr(p+1)),n){if(t[n]&&oI.indexOf(n)>=0)return;n==="set-cookie"?t[n]=(t[n]?t[n]:[]).concat([o]):t[n]=t[n]?t[n]+", "+o:o}}),t}});var $m=K((gP,Hm)=>{"use strict";var km=Be();Hm.exports=km.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a"),n;function o(p){var d=p;return e&&(t.setAttribute("href",d),d=t.href),t.setAttribute("href",d),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return n=o(window.location.href),function(d){var h=km.isString(d)?o(d):d;return h.protocol===n.protocol&&h.host===n.host}}():function(){return function(){return!0}}()});var Vr=K((yP,Vm)=>{"use strict";function fp(s){this.message=s}fp.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};fp.prototype.__CANCEL__=!0;Vm.exports=fp});var gp=K((MP,qm)=>{"use strict";var ma=Be(),sI=Em(),lI=Am(),pI=cp(),cI=Dm(),uI=Gm(),mI=$m(),hp=mp(),dI=qr(),fI=Vr();qm.exports=function(e){return new Promise(function(n,o){var p=e.data,d=e.headers,h=e.responseType,y;function I(){e.cancelToken&&e.cancelToken.unsubscribe(y),e.signal&&e.signal.removeEventListener("abort",y)}ma.isFormData(p)&&delete d["Content-Type"];var b=new XMLHttpRequest;if(e.auth){var S=e.auth.username||"",q=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";d.Authorization="Basic "+btoa(S+":"+q)}var Fe=cI(e.baseURL,e.url);b.open(e.method.toUpperCase(),pI(Fe,e.params,e.paramsSerializer),!0),b.timeout=e.timeout;function be(){if(!!b){var Se="getAllResponseHeaders"in b?uI(b.getAllResponseHeaders()):null,ue=!h||h==="text"||h==="json"?b.responseText:b.response,Te={data:ue,status:b.status,statusText:b.statusText,headers:Se,config:e,request:b};sI(function(ut){n(ut),I()},function(ut){o(ut),I()},Te),b=null}}if("onloadend"in b?b.onloadend=be:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(be)},b.onabort=function(){!b||(o(hp("Request aborted",e,"ECONNABORTED",b)),b=null)},b.onerror=function(){o(hp("Network Error",e,null,b)),b=null},b.ontimeout=function(){var ue=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",Te=e.transitional||dI.transitional;e.timeoutErrorMessage&&(ue=e.timeoutErrorMessage),o(hp(ue,e,Te.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",b)),b=null},ma.isStandardBrowserEnv()){var ct=(e.withCredentials||mI(Fe))&&e.xsrfCookieName?lI.read(e.xsrfCookieName):void 0;ct&&(d[e.xsrfHeaderName]=ct)}"setRequestHeader"in b&&ma.forEach(d,function(ue,Te){typeof p=="undefined"&&Te.toLowerCase()==="content-type"?delete d[Te]:b.setRequestHeader(Te,ue)}),ma.isUndefined(e.withCredentials)||(b.withCredentials=!!e.withCredentials),h&&h!=="json"&&(b.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&b.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&b.upload&&b.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(y=function(Se){!b||(o(!Se||Se&&Se.type?new fI("canceled"):Se),b.abort(),b=null)},e.cancelToken&&e.cancelToken.subscribe(y),e.signal&&(e.signal.aborted?y():e.signal.addEventListener("abort",y))),p||(p=null),b.send(p)})}});var qr=K((wP,Xm)=>{"use strict";var he=Be(),Wm=Rm(),hI=up(),gI={"Content-Type":"application/x-www-form-urlencoded"};function Km(s,e){!he.isUndefined(s)&&he.isUndefined(s["Content-Type"])&&(s["Content-Type"]=e)}function yI(){var s;return typeof XMLHttpRequest!="undefined"?s=gp():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(s=gp()),s}function MI(s,e,t){if(he.isString(s))try{return(e||JSON.parse)(s),he.trim(s)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(s)}var da={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:yI(),transformRequest:[function(e,t){return Wm(t,"Accept"),Wm(t,"Content-Type"),he.isFormData(e)||he.isArrayBuffer(e)||he.isBuffer(e)||he.isStream(e)||he.isFile(e)||he.isBlob(e)?e:he.isArrayBufferView(e)?e.buffer:he.isURLSearchParams(e)?(Km(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):he.isObject(e)||t&&t["Content-Type"]==="application/json"?(Km(t,"application/json"),MI(e)):e}],transformResponse:[function(e){var t=this.transitional||da.transitional,n=t&&t.silentJSONParsing,o=t&&t.forcedJSONParsing,p=!n&&this.responseType==="json";if(p||o&&he.isString(e)&&e.length)try{return JSON.parse(e)}catch(d){if(p)throw d.name==="SyntaxError"?hI(d,this,"E_JSON_PARSE"):d}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};he.forEach(["delete","get","head"],function(e){da.headers[e]={}});he.forEach(["post","put","patch"],function(e){da.headers[e]=he.merge(gI)});Xm.exports=da});var Qm=K((bP,Ym)=>{"use strict";var wI=Be(),bI=qr();Ym.exports=function(e,t,n){var o=this||bI;return wI.forEach(n,function(d){e=d.call(o,e,t)}),e}});var yp=K((vP,zm)=>{"use strict";zm.exports=function(e){return!!(e&&e.__CANCEL__)}});var jm=K((IP,Zm)=>{"use strict";var Jm=Be(),Mp=Qm(),vI=yp(),II=qr(),PI=Vr();function wp(s){if(s.cancelToken&&s.cancelToken.throwIfRequested(),s.signal&&s.signal.aborted)throw new PI("canceled")}Zm.exports=function(e){wp(e),e.headers=e.headers||{},e.data=Mp.call(e,e.data,e.headers,e.transformRequest),e.headers=Jm.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Jm.forEach(["delete","get","head","post","put","patch","common"],function(o){delete e.headers[o]});var t=e.adapter||II.adapter;return t(e).then(function(o){return wp(e),o.data=Mp.call(e,o.data,o.headers,e.transformResponse),o},function(o){return vI(o)||(wp(e),o&&o.response&&(o.response.data=Mp.call(e,o.response.data,o.response.headers,e.transformResponse))),Promise.reject(o)})}});var bp=K((PP,ed)=>{"use strict";var Ve=Be();ed.exports=function(e,t){t=t||{};var n={};function o(b,S){return Ve.isPlainObject(b)&&Ve.isPlainObject(S)?Ve.merge(b,S):Ve.isPlainObject(S)?Ve.merge({},S):Ve.isArray(S)?S.slice():S}function p(b){if(Ve.isUndefined(t[b])){if(!Ve.isUndefined(e[b]))return o(void 0,e[b])}else return o(e[b],t[b])}function d(b){if(!Ve.isUndefined(t[b]))return o(void 0,t[b])}function h(b){if(Ve.isUndefined(t[b])){if(!Ve.isUndefined(e[b]))return o(void 0,e[b])}else return o(void 0,t[b])}function y(b){if(b in t)return o(e[b],t[b]);if(b in e)return o(void 0,e[b])}var I={url:d,method:d,data:d,baseURL:h,transformRequest:h,transformResponse:h,paramsSerializer:h,timeout:h,timeoutMessage:h,withCredentials:h,adapter:h,responseType:h,xsrfCookieName:h,xsrfHeaderName:h,onUploadProgress:h,onDownloadProgress:h,decompress:h,maxContentLength:h,maxBodyLength:h,transport:h,httpAgent:h,httpsAgent:h,cancelToken:h,socketPath:h,responseEncoding:h,validateStatus:y};return Ve.forEach(Object.keys(e).concat(Object.keys(t)),function(S){var q=I[S]||p,Fe=q(S);Ve.isUndefined(Fe)&&q!==y||(n[S]=Fe)}),n}});var vp=K((_P,td)=>{td.exports={version:"0.24.0"}});var nd=K((RP,rd)=>{"use strict";var _I=vp().version,Ip={};["object","boolean","number","function","string","symbol"].forEach(function(s,e){Ip[s]=function(n){return typeof n===s||"a"+(e<1?"n ":" ")+s}});var id={};Ip.transitional=function(e,t,n){function o(p,d){return"[Axios v"+_I+"] Transitional option '"+p+"'"+d+(n?". "+n:"")}return function(p,d,h){if(e===!1)throw new Error(o(d," has been removed"+(t?" in "+t:"")));return t&&!id[d]&&(id[d]=!0,console.warn(o(d," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(p,d,h):!0}};function RI(s,e,t){if(typeof s!="object")throw new TypeError("options must be an object");for(var n=Object.keys(s),o=n.length;o-- >0;){var p=n[o],d=e[p];if(d){var h=s[p],y=h===void 0||d(h,p,s);if(y!==!0)throw new TypeError("option "+p+" must be "+y);continue}if(t!==!0)throw Error("Unknown option "+p)}}rd.exports={assertOptions:RI,validators:Ip}});var cd=K((FP,pd)=>{"use strict";var ad=Be(),FI=cp(),od=Pm(),sd=jm(),fa=bp(),ld=nd(),Ni=ld.validators;function Wr(s){this.defaults=s,this.interceptors={request:new od,response:new od}}Wr.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=fa(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;t!==void 0&&ld.assertOptions(t,{silentJSONParsing:Ni.transitional(Ni.boolean),forcedJSONParsing:Ni.transitional(Ni.boolean),clarifyTimeoutError:Ni.transitional(Ni.boolean)},!1);var n=[],o=!0;this.interceptors.request.forEach(function(q){typeof q.runWhen=="function"&&q.runWhen(e)===!1||(o=o&&q.synchronous,n.unshift(q.fulfilled,q.rejected))});var p=[];this.interceptors.response.forEach(function(q){p.push(q.fulfilled,q.rejected)});var d;if(!o){var h=[sd,void 0];for(Array.prototype.unshift.apply(h,n),h=h.concat(p),d=Promise.resolve(e);h.length;)d=d.then(h.shift(),h.shift());return d}for(var y=e;n.length;){var I=n.shift(),b=n.shift();try{y=I(y)}catch(S){b(S);break}}try{d=sd(y)}catch(S){return Promise.reject(S)}for(;p.length;)d=d.then(p.shift(),p.shift());return d};Wr.prototype.getUri=function(e){return e=fa(this.defaults,e),FI(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};ad.forEach(["delete","get","head","options"],function(e){Wr.prototype[e]=function(t,n){return this.request(fa(n||{},{method:e,url:t,data:(n||{}).data}))}});ad.forEach(["post","put","patch"],function(e){Wr.prototype[e]=function(t,n,o){return this.request(fa(o||{},{method:e,url:t,data:n}))}});pd.exports=Wr});var md=K((SP,ud)=>{"use strict";var SI=Vr();function Di(s){if(typeof s!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(o){e=o});var t=this;this.promise.then(function(n){if(!!t._listeners){var o,p=t._listeners.length;for(o=0;o<p;o++)t._listeners[o](n);t._listeners=null}}),this.promise.then=function(n){var o,p=new Promise(function(d){t.subscribe(d),o=d}).then(n);return p.cancel=function(){t.unsubscribe(o)},p},s(function(o){t.reason||(t.reason=new SI(o),e(t.reason))})}Di.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};Di.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};Di.prototype.unsubscribe=function(e){if(!!this._listeners){var t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}};Di.source=function(){var e,t=new Di(function(o){e=o});return{token:t,cancel:e}};ud.exports=Di});var fd=K((TP,dd)=>{"use strict";dd.exports=function(e){return function(n){return e.apply(null,n)}}});var gd=K((EP,hd)=>{"use strict";hd.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var wd=K((CP,Pp)=>{"use strict";var yd=Be(),TI=ap(),ha=cd(),EI=bp(),CI=qr();function Md(s){var e=new ha(s),t=TI(ha.prototype.request,e);return yd.extend(t,ha.prototype,e),yd.extend(t,e),t.create=function(o){return Md(EI(s,o))},t}var gt=Md(CI);gt.Axios=ha;gt.Cancel=Vr();gt.CancelToken=md();gt.isCancel=yp();gt.VERSION=vp().version;gt.all=function(e){return Promise.all(e)};gt.spread=fd();gt.isAxiosError=gd();Pp.exports=gt;Pp.exports.default=gt});var vd=K((AP,bd)=>{bd.exports=wd()});var hm=mm(dm());var np=s=>{let e=200,t=[],n=0;return t[n]=[],s.forEach(o=>{t[n].length<=e-1?t[n].push(o):(n++,t[n]=[o])}),t},ea=s=>{let e=[],t=200;for(;s.length>t;){let n=s.splice(0,t);e.push(n)}return e.push(s),e},Oe=(s,e)=>{let t="",n={profile:"https://profile.fansunitedapi.com/v1",football:"https://football.fansunitedapi.com/v1",idMapping:"https://id-mapping.fansunitedapi.com/v1",predictor:"https://prediction.fansunitedapi.com/v1",client:"https://client.fansunitedapi.com/v1",loyalty:"https://loyalty.fansunitedapi.com/v1"},o={profile:"http://localhost:8010/v1",football:"http://localhost:8080/v1",idMapping:"http://localhost:8030/v1",predictor:"http://localhost:8040/v1",client:"http://localhost:8070/v1",loyalty:"http://localhost:8060/v1"},p={profile:"https://profile.fansunitedstagingapi.com/v1",football:"https://football.fansunitedstagingapi.com/v1",idMapping:"https://id-mapping.fansunitedstagingapi.com/v1",predictor:"https://prediction.fansunitedstagingapi.com/v1",client:"https://client.fansunitedstagingapi.com/v1",loyalty:"https://loyalty.fansunitedstagingapi.com/v1"};return s==="prod"?t=n[e]:s==="dev"?t=o[e]:t=p[e],t},Xt=s=>s.filter((t,n,o)=>n===o.indexOf(t)),ta=s=>Array.isArray(s)?s.map(e=>ta(e)):s!=null&&s.constructor===Object?Object.keys(s).reduce((e,t)=>({...e,[(0,hm.camelCase)(t)]:ta(s[t])}),{}):s,de=s=>s||!1,fe=()=>`&disable_cache=${Date.now()}`,Hr=s=>s.sort((e,t)=>e.localeCompare(t));var ia=class{id=null;name=null;nickname=null;avatar=null;gender=null;country=null;birthDate=null;interests=[];followingCount=0;followersCount=0};var ra=class{profilesFromResponse=e=>e?e.map(t=>this.fullProfileFromResponse(t)):null;fullProfileFromResponse=e=>{let t=new ia;return t.id=e.id,t.name=e.name,t.nickname=e.nickname,t.avatar=e.avatar,t.gender=e.gender,t.country=e.country,t.birthDate=e.birth_date,t.interests=e.interests?e.interests:[],t.followingCount=e.following_count,t.followersCount=e.followers_count,t}};var na=class{nextPageStartsAfter=null;itemsPerPage=null};var Bi=class{pagination=new na};var re=class{meta=new Bi;data=[]};var aa=class{avatar=null;followingId=null;name=null;nickname=null;profileId=null};var oa=class{followResponse=e=>e.map(t=>this.remapResponse(t));followingFromResponse=e=>{let t=new re;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapResponse(n)),t};remapResponse=e=>{let t=new aa;return t.avatar=e.avatar,t.followingId=e.following_id,t.name=e.name,t.profileId=e.profile_id,t.nickname=e.nickname,t}};var sa=class{avatar=null;followerId=null;name=null;nickname=null;profileId=null};var la=class{followersFromResponse=e=>{let t=new re;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapResponse(n)),t};remapResponse=e=>{let t=new sa;return t.avatar=e.avatar,t.followerId=e.follower_id,t.name=e.name,t.profileId=e.profile_id,t}};var $r=class{profile_ids=[]};var ya=mm(vd());function _p(s){this.message=s}_p.prototype=new Error,_p.prototype.name="InvalidCharacterError";var Id=typeof window!="undefined"&&window.atob&&window.atob.bind(window)||function(s){var e=String(s).replace(/=+$/,"");if(e.length%4==1)throw new _p("'atob' failed: The string to be decoded is not correctly encoded.");for(var t,n,o=0,p=0,d="";n=e.charAt(p++);~n&&(t=o%4?64*t+n:n,o++%4)?d+=String.fromCharCode(255&t>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return d};function AI(s){var e=s.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Id(t).replace(/(.)/g,function(n,o){var p=o.charCodeAt(0).toString(16).toUpperCase();return p.length<2&&(p="0"+p),"%"+p}))}(e)}catch{return Id(e)}}function ga(s){this.message=s}function xI(s,e){if(typeof s!="string")throw new ga("Invalid token specified");var t=(e=e||{}).header===!0?0:1;try{return JSON.parse(AI(s.split(".")[t]))}catch(n){throw new ga("Invalid token specified: "+n.message)}}ga.prototype=new Error,ga.prototype.name="InvalidTokenError";var Pd=xI;var _d=(s,e,t)=>{let n={data:s.data,status:e,statusText:t,headers:s.headers,config:s};return{code:String(e),config:s,isAxiosError:!0,toJSON:()=>({}),name:"Unauthorized",message:t,response:n}};var Me=class{instanceAuth=null;instance=null;constructor(e,t){this.instanceAuth=ya.default.create({baseURL:t,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instanceAuth.interceptors.request.use(n=>{let o=null;try{o=Pd(e.authProvider.getIdToken())}catch(d){throw _d(n,401,d.message)}return Date.now()>o.exp&&(ya.default.defaults.headers.common.Authorization=`Bearer ${e.authProvider.getIdToken()}`,n.headers.Authorization=`Bearer ${e.authProvider.getIdToken()}`),n},n=>{Promise.reject(n)}),this.instanceAuth.interceptors.response.use(n=>n,n=>{let o=n.config;if((n.response?.status===403||n.response?.status===401)&&!o._retry){o._retry=!0;let p=e.authProvider.getIdToken();return o.headers.Authorization=`Bearer ${p}`,this.instanceAuth(o)}return Promise.reject(n)}),this.instance=ya.default.create({baseURL:t,headers:{"Content-Type":"application/json"}})}};var OI="/countries",Le="/profile",Rd="/profiles",Ui=class extends Me{apiSignInUrl=null;profileRemapper=null;followingRemapper=null;followersRemapper=null;lang=null;constructor(e){super(e,Oe(e.environment,"profile"));this.lang=e.lang,this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.profileRemapper=new ra,this.followingRemapper=new oa,this.followersRemapper=new la}getCountries=async e=>{try{let t=`&lang=${this.lang}`,n=`${OI}${this.apiSignInUrl}${t}`,o=Date.now();return e&&(n+=`&disable_cache=${o}`),(await this.instance.get(n)).data.data}catch(t){throw console.warn("There was a problem fetching the countries:",t),t.response}};getProfile=async e=>{let t=`${Le}${this.apiSignInUrl}`;if(e){t=`${Rd}/${e}${this.apiSignInUrl}`;try{let n=await this.instance.get(t);return this.profileRemapper.fullProfileFromResponse(n.data.data)}catch(n){throw console.warn(`There was a problem fetching the following profile: ${e}`,n),n.response}}else try{let n=await this.instanceAuth.get(t);return this.profileRemapper.fullProfileFromResponse(n.data.data)}catch(n){throw console.warn("There was a problem fetching your profile from API:",n),n.response}};getProfiles=async(e,t)=>{try{let n=`${Rd}${this.apiSignInUrl}&profile_ids=${e.join(",")}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.profileRemapper.profilesFromResponse(p.data.data)}catch(n){throw console.warn(`There was a problem fetching the following profiles: ${e.join(",")}`,n),n.response}};getFollowers=async(e,t)=>{let n=`${Le}/followers${this.apiSignInUrl}`;if(e&&!t){n=`${Le}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let o=await this.instanceAuth.get(n);return this.followersRemapper.followersFromResponse(o.data)}catch(o){throw console.warn("There was a problem fetching the followers for own profile",o),o.response}}else if(!e&&!t)try{let o=await this.instanceAuth.get(n);return this.followersRemapper.followersFromResponse(o.data)}catch(o){throw console.warn("There was a problem fetching the followers for own profile",o),o.response}e&&t?n=`${Le}/${t}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(n=`${Le}/${t}/followers${this.apiSignInUrl}`);try{let o=await this.instance.get(n);return this.followersRemapper.followersFromResponse(o.data)}catch(o){throw console.warn(`There was a problem fetching the followers for profile: ${t}`,o),o.response}};getFollowing=async(e,t)=>{let n=`${Le}/following${this.apiSignInUrl}`;if(e&&!t){n=`${Le}/following${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let o=await this.instanceAuth.get(n);return this.followingRemapper.followingFromResponse(o.data)}catch(o){throw console.warn("There was a problem fetching the followers of own profile",o),o.response}}else if(!e&&!t)try{let o=await this.instanceAuth.get(n);return this.followingRemapper.followingFromResponse(o.data)}catch(o){throw console.warn("There was a problem fetching the followers of own profile",o),o.response}e&&t?n=`${Le}/${t}/following${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(n=`${Le}/${t}/following${this.apiSignInUrl}`);try{let o=await this.instance.get(n);return this.followingRemapper.followingFromResponse(o.data)}catch(o){throw console.warn(`There was a problem fetching the followers of the following profile: ${t}`,o),o.response}};follow=async e=>{let t=new $r;t.profile_ids=e;try{let n=await this.instanceAuth.post(`${Le}/follow${this.apiSignInUrl}`,JSON.stringify(t));return this.followingRemapper.followResponse(n.data.data)}catch(n){throw console.warn(`There was a problem with POST request for profiles: ${e.join(",")} `,n),n.response}};unfollow=async e=>{let t=new $r;t.profile_ids=e;try{return await this.instanceAuth.delete(`${Le}/follow${this.apiSignInUrl}`,{data:JSON.stringify(t)}),!0}catch(n){throw console.warn(`There was a problem with DELETE request for profiles: ${e.join(",")} `,n),n.response}};getBadges=async e=>{let t=`${Le}/badges${this.apiSignInUrl}`;try{return e?(t=`${Le}/${e}/badges${this.apiSignInUrl}`,(await this.instance.get(t)).data.data):(await this.instanceAuth.get(t)).data.data}catch(n){throw console.warn("There was a problem with fetching the badges",n),n.response}};updateProfile=async e=>{try{let t=await this.instanceAuth.patch(`${Le}${this.apiSignInUrl}`,e);return this.profileRemapper.fullProfileFromResponse(t.data.data)}catch(t){throw console.warn("There was a problem updating the own profile:",t),t.response}}};var Bt={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id"},Rp={PREDICTOR_USER_RELATED_OPERATION:"https://docs.fansunitedmedia.com/docs/predictor-operations#user-related-operations"},Fp=["matchId","matchType","market","prediction"];var Fd="FansUnited",Sp={football:{ids:[],countries:[],competitions:[]},profile:{info:{},statistics:{},badges:null,countries:[],exparations:{profile:0,statistics:0,badges:0}}},yt=class{idSchema="";expirationTimeout=600;expirationBadgesTimeout=3600;constructor(e){this.idSchema=e.idSchema,(this.getData()===void 0||this.getData()===null)&&this.setData(Sp)}clearData=()=>{this.setData(Sp)};getEntityById=(e="",t="")=>this.getData().football.ids.find(n=>{let o=Bt[this.idSchema];return n&&`${n[o]}`===t&&n.resource===e});getEntity=(e,t,n)=>Array.isArray(e)?this.getData().football.ids.filter(o=>{let p=Bt[n];return o&&e.includes(`${o[p]}`)&&o.resource===t}):this.getData().football.ids.find(o=>{let p=Bt[n];return o&&`${o[p]}`===e&&o.resource===t});getEntityByNativeId=(e="",t="")=>this.getData().football.ids.find(n=>n&&`${n.id}`===t&&n.resource===e);checkForExistingIdObjs=(e,t)=>{let n=Bt[t],o={};return Object.keys(e).forEach(p=>{let d=e[p],y=this.getEntity(d,p,t).map(b=>b[n]),I=e[p].filter(b=>!y.includes(b));o[p]=d.map(b=>I.includes(b)?{id:b,exists:!1}:{id:b,exists:!0})}),o};getIdsByType=(e,t,n)=>{let o=Bt[n],p=Bt[t],d={};return Object.keys(e).forEach(h=>{let y=e[h],I=[];this.getData().football.ids.forEach(b=>{y.forEach((S,q)=>{S===b[p]&&h===b.resource&&(I[q]=b[o])})}),d[h]=I}),d};addIdMapping=e=>{let t=this.getData();t.football.ids.push(e),this.setData(t)};addIdMappings=e=>{let t=this.getData(),n=t.football.ids;n=[...n,...e],t.football.ids=n,this.setData(t)};setOwnProfile=e=>{let t=this.getData();t.profile.info=e,t.profile.exparations.profile=Math.floor(Date.now()/1e3)+this.expirationTimeout,this.setData(t)};getOwnProfile=()=>this.getData().profile.info;getProfileCountries=()=>this.getData().profile.countries;setProfileCountries=e=>{let t=this.getData();t.profile.countries=e,this.setData(t)};getProfileStats=()=>this.getData().profile.statistics;setProfileStats=e=>{let t=this.getData();t.profile.statistics=e,t.profile.exparations.statistics=Math.floor(Date.now()/1e3)+this.expirationTimeout,this.setData(t)};getProfileBadges=()=>this.getData().profile.badges;setProfileBadges=e=>{let t=this.getData();t.profile.badges=e,t.profile.exparations.badges=Math.floor(Date.now()/1e3)+this.expirationBadgesTimeout,this.setData(t)};getFootballCountries=()=>this.getData().football.countries;setFootballCountries=e=>{let t=this.getData();t.football.countries=e,this.setData(t)};getCompetitions=e=>{let t=this.getData();return e?e.competitionSearchFilter(t.football.competitions):t.football.competitions};setCompetitions=e=>{let t=this.getData(),n=[...t.football.competitions];n.push(...e),t.football.competitions=this.makeCompetitionsUnique(n),this.setData(t)};getCompetitionsLength=()=>{let{football:e}=this.getData();return e.competitions.length};getExpiration=e=>{let t=this.getData();switch(this.initialNewSchema("exparations"),e){case"profile":return t.profile.exparations.profile;case"statistics":return t.profile.exparations.statistics;case"badges":return t.profile.exparations.badges}};makeCompetitionsUnique=e=>{let t=new Set;return e.filter(n=>{let o=!t.has(n.id);return t.add(n.id),o})};getData=()=>JSON.parse(localStorage.getItem(Fd));setData=e=>{localStorage.setItem(Fd,JSON.stringify(e))};initialNewSchema=e=>{this.getData().profile[e]||this.setData(Sp)}};var Kr={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},Ma=class extends Me{apiSignInUrl="";constructor(e){super(e,Oe(e.environment,"idMapping"));this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`}getEntityById=(e,t)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${config.idSchema}&${Kr[e]}=${t}`)}catch(n){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,n),n.response}};getEntityByIdAndSchema=(e,t,n)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${Kr[e]}=${t}`)}catch(o){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,o),o.response}};getEntityIdsByIdsAndSchema=(e,t,n)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${Kr[e]}=${t.join(",")}`)}catch(o){throw console.warn(`There was a problem with id mapping request for the following ids:${t.join(",")}`,o),o.response}};getEntitiesByIds=(e,t,n)=>{t.sort((d,h)=>d.localeCompare(h));let p=np(t).map(d=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${n}&${Kr[e]}=${d.join(",")}`)}catch(h){throw console.warn(`There was a problem with id mapping request for the following ids:${d.join(",")}`,h),h.response}});return Promise.all(p).then(d=>{let h=[];return d.forEach(y=>{h.push(...y.data.data)}),h})};getEntitiesByIdObjs=async(e,t)=>{let n=[],o={},p=[];Object.keys(e).forEach(I=>{n.push.apply(n,e[I])});let d=Xt(n),h=np(d);for(let I of h){let b="";if(Object.keys(e).forEach(S=>{o[S]=[];let q=I.filter(Fe=>e[S].includes(Fe));q&&q.length>0&&(o[S]=q)}),Object.keys(o).forEach(S=>{o[S].length>0&&(o[S].sort((q,Fe)=>q.localeCompare(Fe)),b+="&",b+=`${Kr[S]}=${o[S].join(",")}`)}),b&&b.length>0)try{let S=await this.instance.get(`/football${this.apiSignInUrl}&input_provider=${t||"native"}${b}`);p.push(S.data.data)}catch(S){throw console.warn("There was a problem with id mapping request",S),S.response}else p.push([])}return Array.prototype.concat.apply([],p)}};var wa=class{isBrowser=!1;localStorage=null;https=null;constructor(e){this.isBrowser=typeof window!="undefined",this.localStorage=new yt(e),this.https=new Ma(e)}getEntitiesByIds=async(e,t,n)=>{if(this.isBrowser)try{let o=this.localStorage.checkForExistingIdObjs(e,t),p=this.splitForRequestAndExisting(o),d=await this.https.getEntitiesByIdObjs(p.request,t);return this.localStorage.addIdMappings(d),this.localStorage.getIdsByType(e,t,n)}catch(o){return console.warn("There was a problem retrieving the entity ids ",o),Promise.resolve([])}else try{let o=await this.https.getEntitiesByIdObjs(e,t);return Object.keys(e).forEach(p=>{e[p]=o.filter(d=>d.resource===p).map(d=>d[Bt[n]])}),e}catch(o){return console.warn("There was a problem retrieving the entity ids ",o),Promise.resolve([])}};getEntityById=async(e,t,n)=>{if(this.isBrowser){let o=this.localStorage.getEntity(e,t,n);if(o)return o;{let p=await this.requestEntity(e,t,n);return this.localStorage.addIdMappings(p),p}}else return await this.requestEntity(e,t,n)};splitForRequestAndExisting=e=>{let t={},n={};return Object.keys(e).forEach(o=>{t[o]=e[o].filter(p=>!p.exists).map(p=>p.id),n[o]=e[o].filter(p=>p.exists).map(p=>p.id)}),{existing:n,request:t}};requestEntity=async(e,t,n)=>{try{return e=Array.isArray(e)?e:[e],await this.https.getEntitiesByIds(t,e,n)}catch(o){return console.warn(`There was a problem retrieving the requested entity: ${o}`),null}}};var ba=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 va=class{extractedObjIds={};traverse=(e,t)=>(t=ba(t),Array.isArray(e)?this.traverseArrExtract(e,t):e&&typeof e=="object"&&this.traverseObjExtract(e,t),this.extractedObjIds);traverseArrExtract=(e,t)=>{e&&e.length>0&&e.forEach(n=>{this.traverseObjExtract(n,t)})};traverseObjExtract=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(n=>{let o=e[n];n==="id"||n==="teamId"?(this.extractedObjIds.hasOwnProperty(t)||(this.extractedObjIds[t]=[]),o&&this.extractedObjIds[t].push(o)):e[n]&&this.traverse(e[n],n)})}};var Ia=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(e,t,n)=>(t=ba(t),this.replaceObjIdsIndex===null&&(this.initReplaceObjIdsIndex(n),this.remappedIdsObj=n),Array.isArray(e)?this.traverseArrReplace(e,t):e&&typeof e=="object"&&this.traverseObjReplace(e,t),e);initReplaceObjIdsIndex=e=>{this.replaceObjIdsIndex={},Object.keys(e).forEach(t=>{this.replaceObjIdsIndex[t]=0})};traverseArrReplace=(e,t)=>{e&&e.length>0&&e.forEach(n=>{this.traverseObjReplace(n,t)})};traverseObjReplace=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(n=>{n==="id"||n==="teamId"?e[n]&&(e[n]=this.remappedIdsObj[t][this.replaceObjIdsIndex[t]],this.replaceObjIdsIndex[t]=this.replaceObjIdsIndex[t]+1):e[n]&&this.traverse(e[n],n,this.remappedIdsObj)})}};var ae=class{idSchema="";idMappingFacade=null;constructor(e){this.idSchema=e.idSchema,this.idMappingFacade=new wa(e)}getEntityIdBySchemaId=(e,t)=>this.idMappingFacade.getEntityById(e,t,this.idSchema);remapEntities=async(e,t)=>{let n=JSON.parse(JSON.stringify(e));try{if(this.idSchema!=="native"){let p=new va().traverse(n,t);return this.idMappingFacade.getEntitiesByIds(p,"native",this.idSchema).then(d=>new Ia().traverse(n,t,d))}else return e}catch(o){return console.warn(`There was a problem remapping entity: ${t} with inner entity `,o),[]}};getEntityIdsBySchemaId=async(e,t,n)=>{let o={};return o[t]=e,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(o,this.idSchema,n):o}};var qe=class{completed=!1;percentage;constructor(e){this.percentage=e}};var Pa=class{teamFollowed=new qe(10);teamFavourite=new qe(15);playerFollowed=new qe(10);playerFavourite=new qe(10);competitionFollowed=new qe(10);competitionFavourite=new qe(5);addedBirthdate=new qe(10);addedGender=new qe(10);addedCountry=new qe(10);addedAvatar=new qe(10)};var _a=class{totalPercentage;breakdown=new Pa};var Xr=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,t,n){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.profileHttps=t,this.activityHttps=n}getOwn=async()=>{if(this.isBrowser){let e=this.getLocalStorageData("profile");if(e)return JSON.parse(JSON.stringify(e));try{let t=await this.profileHttps.getProfile();return this.localStorage.setOwnProfile(t),t}catch(t){throw console.warn("There was a problem retrieving your profile: ",t),t}}else try{return await this.profileHttps.getProfile()}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};updateOwnProfile=async()=>{try{let e=await this.profileHttps.getProfile();return this.localStorage.setOwnProfile(e),e}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};getByIds=async(e,t)=>{try{return t=t||!1,await this.profileHttps.getProfiles(e,t)}catch(n){throw console.warn(`There was a problem retrieving the selected profiles: ${e.join(",")} `,n),n}};getById=async e=>{try{return await this.profileHttps.getProfile(e)}catch(t){throw console.warn(`There was a problem retrieving the selected profile: ${e} `,t),t}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let t=this.localStorage.getProfileCountries();if(t&&t.length>0)return t;try{let n=await this.profileHttps.getCountries(e);return this.localStorage.setProfileCountries(n),n}catch(n){throw console.warn("There was a problem retrieving profile countries: ",n),n}}else try{return await this.profileHttps.getCountries(e)}catch(t){throw console.warn("There was a problem retrieving profile countries: ",t),t}};getFollowers=async(e,t)=>{try{e&&(e=new Xr(e));let n=await this.profileHttps.getFollowers(e,t),o=n.data.map(p=>p.followerId);if(o.length){let p=await this.getByIds(o),d=n.data.map(h=>(p.forEach(y=>{h.followerId===y.id&&(h.name=y.name,h.nickname=y.nickname,h.avatar=y.avatar)}),h));return n.data=d,n}return n}catch(n){throw console.warn("There was a problem retrieving your followers: ",n),n}};getFollowing=async(e,t)=>{try{e&&(e=new Xr(e));let n=await this.profileHttps.getFollowing(e,t),o=n.data.map(p=>p.followingId);if(o.length){let p=await this.getByIds(o),d=n.data.map(h=>(p.forEach(y=>{h.followingId===y.id&&(h.name=y.name,h.nickname=y.nickname,h.avatar=y.avatar)}),h));return n.data=d,n}return n}catch(n){throw console.warn("There was a problem retrieving your following profiles: ",n),n}};follow=async e=>{try{return await this.profileHttps.follow(e)}catch(t){throw console.warn(`There was a problem following profiles: ${e.join(",")} `,t),t}};unfollow=async e=>{try{return await this.profileHttps.unfollow(e)}catch(t){throw console.warn(`There was a problem unfollowing profiles: ${e.join(",")} `,t),t}};showFullnessProfile=e=>{let t=new _a,n=0;return e.avatar&&(t.breakdown.addedAvatar.completed=!0,n+=t.breakdown.addedAvatar.percentage),e.birthDate&&(t.breakdown.addedBirthdate.completed=!0,n+=t.breakdown.addedBirthdate.percentage),e.country&&(t.breakdown.addedCountry.completed=!0,n+=t.breakdown.addedCountry.percentage),e.gender&&(t.breakdown.addedGender.completed=!0,n+=t.breakdown.addedGender.percentage),e.interests&&e.interests.length>0&&(e.interests.find(b=>b.type==="team"&&b.favourite)&&(t.breakdown.teamFavourite.completed=!0,n+=t.breakdown.teamFavourite.percentage),e.interests.find(b=>b.type==="team")&&(t.breakdown.teamFollowed.completed=!0,n+=t.breakdown.teamFollowed.percentage),e.interests.find(b=>b.type==="player"&&b.favourite)&&(t.breakdown.playerFavourite.completed=!0,n+=t.breakdown.playerFavourite.percentage),e.interests.find(b=>b.type==="player")&&(t.breakdown.playerFollowed.completed=!0,n+=t.breakdown.playerFollowed.percentage),e.interests.find(b=>b.type==="competition"&&b.favourite)&&(t.breakdown.competitionFavourite.completed=!0,n+=t.breakdown.competitionFavourite.percentage),e.interests.find(b=>b.type==="competition")&&(t.breakdown.competitionFollowed.completed=!0,n+=t.breakdown.competitionFollowed.percentage)),t.totalPercentage=n,t};getStats=async()=>{if(this.isBrowser){let e=this.getLocalStorageData("statistics");if(e&&Object.keys(e).length)return JSON.parse(JSON.stringify(e));try{let t=await this.activityHttps.getStats();return this.localStorage.setProfileStats(t),t}catch(t){throw console.warn("There was a problem retrieving own profile statistics: ",t),t}}else try{return await this.activityHttps.getStats()}catch(e){throw console.warn("There was a problem retrieving own profile statistics: ",e),e}};getBadges=async()=>{if(this.isBrowser){let e=this.getLocalStorageData("badges");if(e)return e;try{let t=await this.profileHttps.getBadges();return this.localStorage.setProfileBadges(t),t}catch(t){throw console.warn("There was a problem retrieving own profile badges: ",t),t}}else try{return await this.profileHttps.getBadges()}catch(e){throw console.warn("There was a problem retrieving own profile badges: ",e),e}};getLocalStorageData=e=>{let t=Math.floor(Date.now()/1e3),n=this.localStorage.getExpiration(e);switch(e){case"profile":if(n>t)return this.localStorage.getOwnProfile();case"statistics":if(n>t)return this.localStorage.getProfileStats();case"badges":if(n>t)return this.localStorage.getProfileBadges();default:return null}}};var Ra=class{id=null;name=null;assets=null};var Fa=class{extractUpdatedProps=(e,t)=>{let n=["name","nickname","gender"],o={};return Object.keys(e).forEach(p=>{if(n.includes(p)&&e[p]!==t[p])o[p]=t[p];else if(p==="birthDate")(t[p]===null||e[p]===null&&t[p]||e[p]!==t[p])&&(o.birth_date=t[p]);else if(p==="country")t[p]===null?o.country_id=t[p]:(e[p]===null&&t[p]||e[p].id!==t[p].id)&&(o.country_id=t[p].id);else if(p==="interests"){let d=e[p],h=t[p];h.length&&this.isNewInterest(d,h)?o[p]=this.updateInterests(d,h):(!h.length&&d.length||d.length!==h.length&&!this.isNewInterest(d,h))&&(o[p]=h)}}),o};updateInterests=(e,t)=>{if(e.length===t.length){let[n,o]=this.extractSameAndNewInterests(e,t);return[...o,...n]}else return t};isNewInterest=(e,t)=>{let n=!1,[o]=this.extractSameAndNewInterests(e,t);return o.length&&(n=!0),n};extractSameAndNewInterests=(e,t)=>{let n=t.filter(p=>e.some(d=>p.id===d.id&&p.type===d.type&&p.source===d.source&&p.favourite===d.favourite));return[t.filter(p=>!e.some(d=>p.id===d.id&&p.type===d.type&&p.source===d.source&&p.favourite===d.favourite)),n]}};var Sa=class{idsRemapper=null;profileHttps=null;profileService=null;localStorage=null;profileFacade=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;constructor(e,t,n,o,p,d){this.idsRemapper=e,this.localStorage=t,this.profileHttps=n,this.profileService=new Fa,this.profileFacade=new Mt(t,n,o)}getOwnProfile=async()=>{for(;this.isFetching;)console.log("Another thread is fetching profile..."),await this.delay(100);if(this.modified&&this.ownProfile)return console.log("Timestamp is less than 10 minutes OR profile is modifying "),this.ownProfile;let e=Math.floor(Date.now()/1e3);if(!this.ownProfile||this.expireAt<e){this.isFetching=!0,this.expireAt=Math.floor(Date.now()/1e3)+600;try{let t=await this.profileFacade.getOwn();this.setOwnProfile(t)}catch(t){throw this.isFetching=!1,t}return this.modified=!1,this.isFetching=!1,this.ownProfile}return this.ownProfile};delay=e=>new Promise(t=>{setTimeout(t,e)});setOwnProfile=e=>{this.ownProfile=e};getInfo=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return delete t.interests,t};showInterests=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.remapInterests(t.interests)};showFullInterests=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.showFullInterests(t.interests)};getFollowers=async e=>await this.profileFacade.getFollowers(e);getFollowing=async e=>await this.profileFacade.getFollowing(e);follow=async e=>{let t=await this.profileFacade.follow(e),n=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(n),t};unfollow=async e=>{let t=await this.profileFacade.unfollow(e),n=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(n),t};getStats=async()=>{let e=await this.profileFacade.getStats();return await this.idsRemapper.remapSuccessRatesEntities(e)};getBadges=async()=>await this.profileFacade.getBadges();addInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;e.source!=="custom"?t=await this.idsRemapper.remapInterestToNative(e):t=e;let n=this.ownProfile.interests.filter(o=>o.id!==t.id||o.type!==t.type||o.source!==t.source);return this.ownProfile.interests=[...n],this.ownProfile.interests.push(t),this};addInterest=e=>(this.promises.push(this.addInterestPromise(e)),this);removeInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;return e.source!=="custom"?t=await this.idsRemapper.remapInterestToNative(e):t=e,this.ownProfile.interests=this.ownProfile.interests.filter(n=>n.id!==t.id||n.type!==t.type||n.source!==t.source),this};removeInterest=e=>(this.promises.push(this.removeInterestPromise(e)),this);setBirthdatePromise=async e=>(this.modified=!0,await this.getOwnProfile(),e?this.ownProfile.birthDate=e:this.ownProfile.birthDate=null,this);setBirthdate=e=>(this.promises.push(this.setBirthdatePromise(e)),this);setGenderPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e==="male"||e==="female"?this.ownProfile.gender=e:this.ownProfile.gender="unspecified",this);setGender=e=>(this.promises.push(this.setGenderPromise(e)),this);setNicknamePromise=async e=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.nickname=e,this);setNickname=e=>(this.promises.push(this.setNicknamePromise(e)),this);setNamePromise=async e=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.name=e,this);setName=e=>(this.promises.push(this.setNamePromise(e)),this);setCountryPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e&&!this.ownProfile.country?(this.ownProfile.country=new Ra,this.ownProfile.country.id=e):e&&this.ownProfile.country?this.ownProfile.country.id=e:this.ownProfile.country=null,this);setCountry=e=>(this.promises.push(this.setCountryPromise(e)),this);showFullnessProfile=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return this.profileFacade.showFullnessProfile(t)};update=async()=>{if(this.promises.length===0)return this.ownProfile;await Promise.all(this.promises);let e=await this.profileFacade.getOwn(),t=await this.getOwnProfile(),n=this.profileService.extractUpdatedProps(e,t);if(this.modified=!1,this.expireAt=0,Object.keys(n).length){let p=await this.profileHttps.updateProfile(n),d=JSON.parse(JSON.stringify(p));return this.setOwnProfile(d),this.localStorage.setOwnProfile(d),delete p.interests,p}let o=JSON.parse(JSON.stringify(this.ownProfile));return delete o.interests,o}};var Ta=class{idsRemapper=null;profileHttps=null;activityHttps=null;profileFacade=null;profileId="";constructor(e,t,n,o){this.idsRemapper=e,this.profileHttps=n,this.activityHttps=o,this.profileFacade=new Mt(t,n,o)}setId=e=>(this.profileId=e,this);getProfile=async()=>await this.profileFacade.getById(this.profileId);getInfo=async()=>{let e=await this.getProfile();return delete e.interests,e};showInterests=async()=>{let e=await this.getProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.remapInterests(t.interests)};showFullInterests=async()=>{let e=await this.getProfile(),t=JSON.parse(JSON.stringify(e));return await this.idsRemapper.showFullInterests(t.interests)};getFollowers=async e=>await this.profileFacade.getFollowers(e,this.profileId);getFollowing=async e=>await this.profileFacade.getFollowing(e,this.profileId);showFullnessProfile=async()=>{let e=await this.getProfile();return this.profileFacade.showFullnessProfile(e)};getStats=async e=>{let t=await this.activityHttps.getStats(this.profileId,e);return await this.idsRemapper.remapSuccessRatesEntities(t)};getBadges=async()=>await this.profileHttps.getBadges(this.profileId)};var Ea=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,n){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=n,this.https=t}getCountriesWithIdMapping=async e=>{try{let t=await this.getCountries(e);return this.idMapping.remapEntities(t,"country")}catch(t){throw console.warn("There was a problem browsing countries as football entities",t),t}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let t=this.localStorage.getFootballCountries();if(t&&t.length>0)return t;try{let n=await this.https.getCountries(e);return this.localStorage.setFootballCountries(n),n}catch(n){throw console.warn("There was a problem retrieving countries as football entities",n),n}}else return this.https.getCountries(e)}};var Yr=class{countryId=null;name=null;gender=null;type=null;sortField=null;sortOrder=null;competitionIds=null;constructor(e){this.countryId=e.countryId?`${e.countryId}`:null,this.name=e.name?e.name:null,this.gender=e.gender?e.gender:null,this.type=e.type?e.type:null,this.sortField=e.sortField?`${e.sortField}`:null,this.sortOrder=e.sortOrder?`${e.sortOrder}`:null,this.competitionIds=e.competitionIds?e.competitionIds:null}constructFilterUrl=()=>{let e="";return this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.gender&&(e=e+"&",e=e+`gender=${this.gender}`),this.type&&(e=e+"&",e=e+`type=${this.type}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),this.name&&(e=e+"&",e=e+`name=${this.name}`),this.competitionIds&&(e=e+"&",e=e+`competition_ids=${this.competitionIds.join(",")}`),e};competitionSearchFilter=e=>{try{let t=this.filter(e);return this.sortField||this.sortOrder?this.sort(t):t}catch(t){return console.warn("There was a problem filtering the local competitions",t),[]}};filter=e=>{let t=this.entitiesToSearchWith();return e.filter(n=>{let o=!0;return t.forEach(p=>{p!=="sortOrder"&&p!=="sortField"&&(p==="countryId"?o&&=n.country.id===this[p]:p==="name"?o&&=n.name.toLocaleLowerCase().includes(this[p].toLocaleLowerCase()):p==="competitionIds"?o&&=this[p].some(d=>n.id===d):o&&=n[p].toLocaleLowerCase()===this[p].toLocaleLowerCase())}),o})};entitiesToSearchWith=()=>{let e=[];return this.countryId&&e.push("countryId"),this.name&&e.push("name"),this.gender&&e.push("gender"),this.type&&e.push("type"),this.sortField&&e.push("sortField"),this.sortOrder&&e.push("sortOrder"),this.competitionIds&&e.push("competitionIds"),e};sort=e=>{let t=[];return this.sortField==="name"?t=e.sort((n,o)=>this.sortOrder&&this.sortOrder==="desc"?o.name.localeCompare(n.name):n.name.localeCompare(o.name)):this.sortField==="country"?t=e.sort((n,o)=>this.sortOrder&&this.sortOrder==="desc"?o.country.name.localeCompare(n.country.name):n.country.name.localeCompare(o.country.name)):this.sortField==="scope"?e.forEach(n=>t[this.competitionIds.indexOf(n.id)]=n):!this.sortField&&this.sortOrder==="desc"&&(t=e.sort((n,o)=>o.id.localeCompare(n.id))),t}};var Ca=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,n){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=n,this.https=t}getCompetitionsIdMapping=async(e,t)=>{try{let n=!1;if(e){if(e=new Yr(e),e.countryId){let p=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");p.country.length===0&&(n=!0),e.countryId=p.country[0]}if(e.competitionIds){let p=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");p.competition.length===0&&(n=!0),e.competitionIds=p.competition}if(n)return[]}let o=await this.getCompetitions(e,t);return await this.idMapping.remapEntities(o,"competition")}catch(n){throw console.warn("There was a problem browsing all of the competitions",n),n}};getCompetitionsMapWithNativeIds=async e=>{let t=new Map,n=e.length,o=new Yr({competitionIds:e,limit:n}),p=await this.getCompetitions(o);p.sort((h,y)=>h.id.localeCompare(y.id));let d=await this.idMapping.remapEntities(p,"competition");return e.forEach((h,y)=>t.set(h,d[y])),t};getCompetitions=async(e,t)=>{let n=null;if(t=t||!1,this.isBrowser){if(!this.localStorage.getCompetitionsLength()){try{n=await this.https.getCompetitions()}catch(o){throw console.warn("There was a problem retrieving all competitions",o),o}this.localStorage.setCompetitions(n)}return this.localStorage.getCompetitions(e)}else return this.https.getCompetitions(e,t)};getCompetitionByIdIdMapping=async(e,t)=>{try{let o=(await this.idMapping.getEntityIdsBySchemaId([e],"competition","native")).competition[0],p=await this.getCompetitionById(o,t);return await this.idMapping.remapEntities(p,"competition")}catch(n){throw console.warn(`There was a problem browsing the following competition:${e}`,n),n}};getCompetitionById=async(e,t)=>{try{return t=t||!1,await this.https.getCompetitionById(e,t)}catch(n){throw console.warn(`There was a problem retrieving the competition with the following id: ${e}`,n),n}};getTopCompetitionsIdMapping=async e=>{try{let t=await this.getTopCompetitions(e);return await this.idMapping.remapEntities(t,"competition")}catch(t){throw console.warn("There was a problem browsing the top competitions",t),t}};getTopCompetitions=async e=>{try{return e=e||!1,await this.https.getTopCompetitions(e)}catch(t){throw console.warn("There was a problem retrieving the top competitions",t),t}}};var Qr=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 Aa=class{general=[];predictor=[];topX=[];matchQuiz=[]};var Gi=class{points=null;gameParticipationCount=null;predictionsMade=null;correctPredictions=null};var xa=class{id;enabled;requirements=new Gi};var Oa=class{id;weight;multiplier;conditions};var Ba=class{value=[new Oa]};var ki=class{points=null;tiers=null;badges=null};var La=class{enabled=!1;conditions={list:null};actions=new Ba;rewards=new ki};var Na=class{general=null;comments=null;predictor=null;activity=null;topX=null;matchQuiz=null};var Hi=class{enabled=!1;defaultMarkets=null;competitionsWhitelist=null};var $i=class{enabled=!1;minFixtures=null;maxFixtures=null;competitionsWhitelist=null};var Da=class{competitions=[];teams=[];markets=[]};var Vi=class{enabled=!1;fullCoverageCompetitions=null;markets=null;successRateScopes=new Da};var Ua=class{remapPredictorConfig=e=>{let t=new Vi;return t.enabled=e.enabled,t.fullCoverageCompetitions=e.full_coverage_competitions,t.markets=e.markets,t.successRateScopes=e.success_rate_scopes,t};remapTopXConfig=e=>{let t=new $i;return t.enabled=e.enabled,t.minFixtures=e.min_fixtures,t.maxFixtures=e.max_fixtures,t.competitionsWhitelist=e.competitions_whitelist,t};remapMatchQuizConfig=e=>{let t=new Hi;return t.enabled=e.enabled,t.defaultMarkets=e.default_markets,t.competitionsWhitelist=e.competitions_whitelist,t};remapLoyaltyConfig=e=>{let t=new La;return t.enabled=e.enabled,t.conditions.list=e.conditions.list,t.actions.value=e.actions.value,t.rewards=this.remapRewards(e.rewards),t};remapRewards=e=>{let t=new ki;return t.points=this.remapPoints(e.points),t.tiers=e.tiers,t.badges=this.remapBadges(e.badges),t};remapPoints=e=>{let t=new Na;return t.general=e.general,t.comments=e.comments,t.predictor=e.predictor,t.activity=e.activity,t.topX=e.top_x,t.matchQuiz=e.match_quiz,t};remapBadges=e=>{let t=new Aa;return t.general=e.general,t.predictor=this.remapBadgeValues(e.predictor),t.topX=this.remapBadgeValues(e.top_x),t.matchQuiz=this.remapBadgeValues(e.match_quiz),t};remapBadgeValues=e=>e.map(t=>{let n=new xa;return n.id=t.id,n.enabled=t.enabled,n.requirements=this.remapRequirements(t.requirements),n});remapRequirements=e=>{let t=new Gi;return t.points=e.points,t.gameParticipationCount=e.game_participation_count,t.predictionsMade=e.predictions_made,t.correctPredictions=e.correct_predictions,t}};var et=class extends Me{apiSignInUrl="";featureConfigRemapper=null;constructor(e){super(e,Oe(e.environment,"client"));this.apiSignInUrl=`/clients/${e.clientId}/features?key=${e.apiKey}`,this.featureConfigRemapper=new Ua}getConfig=async e=>{try{let t=await this.instance.get(`${this.apiSignInUrl}`);switch(e){case"predictor":return this.featureConfigRemapper.remapPredictorConfig(t.data.data.predictor);case"topX":return this.featureConfigRemapper.remapTopXConfig(t.data.data.top_x);case"matchQuiz":return this.featureConfigRemapper.remapMatchQuizConfig(t.data.data.match_quiz);case"loyalty":return this.featureConfigRemapper.remapLoyaltyConfig(t.data.data.loyalty)}}catch(t){throw console.warn("There was a problem fetching configuration from Client API",t),t.response}}};var Yt=class{clientHttps=null;constructor(e){this.clientHttps=new et(e)}setAvailableMarketsForMatch=async e=>{let{fullCoverageCompetitions:t,markets:n}=await this.clientHttps.getConfig("predictor");if(Array.isArray(e))return e.map(o=>this.setAvailableMarkets(o,t,n));if(typeof e=="object"&&Object.keys(e).length)return this.setAvailableMarkets(e,t,n)};setAvailableMarkets=(e,t,n)=>{let o=e.context.competition?.id;return o&&this.isMatchInCoverageCompetition(o,t)?(e.availableMarkets=n.all,e):(e.availableMarkets=n.main,e)};isMatchInCoverageCompetition=(e,t)=>{let n=!1;return t.includes(e)&&(n=!0),n}};var ka=class{footballService=null;https=null;idMapping=null;constructor(e,t,n){this.idMapping=n,this.https=t,this.footballService=new Yt(e)}getTeamsIdMapping=async(e,t)=>{try{let n=!1;if(e){if(e=new Qr(e),e.countryId){let p=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");p.country.length===0&&(n=!0),e.countryId=p.country[0]}if(e.scope){let p=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");p.competition.length===0&&(n=!0),e.scope=p.competition}if(e.teamIds){let p=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");p.team.length===0&&(n=!0),e.teamIds=p.team}}if(n)return[];let o=await this.getTeams(e,t);return o.data=await this.idMapping.remapEntities(o.data,"team"),o}catch(n){throw console.warn("There was a problem browsing all teams",n),n}};getTeamsMapWithNativeIds=async e=>{let t=new Map,n=e.length,o=new Qr({teamIds:e,limit:n}),{data:p}=await this.getTeams(o);p.sort((h,y)=>h.id.localeCompare(y.id));let d=await this.idMapping.remapEntities(p,"team");return e.forEach((h,y)=>t.set(h,d[y])),t};getTeams=async(e,t)=>{try{return t=t||!1,await this.https.getTeams(e,t)}catch(n){throw console.warn("There was a problem retrieving all teams",n),n}};getTeamByIdIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let o=await this.getTeamById(e,t);return await this.idMapping.remapEntities(o,"team")}catch(n){throw console.warn(`There was a problem browsing the following team:${e}`,n),n}};getTeamById=async(e,t)=>{try{return t=t||!1,await this.https.getTeamById(e,t)}catch(n){throw console.warn(`There was a problem retrieving the following team: ${e}`,n),n}};getTopTeamsIdMapping=async e=>{try{let t=await this.getTopTeams(e);return await this.idMapping.remapEntities(t,"team")}catch(t){throw console.warn("There was a problem browsing the top teams",t),t}};getTopTeams=async e=>{try{return e=e||!1,await this.https.getTopTeams(e)}catch(t){throw console.warn("There was a problem retrieving the top teams",t),t}};getNextMatchForTeamIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let o=await this.getNextMatchForTeam(e,t);return await this.idMapping.remapEntities(o,"match")}catch(n){throw console.warn(`There was a problem browsing the next match for the following team:${e}`,n),n}};getNextMatchForTeam=async(e,t)=>{try{t=t||!1;let n=await this.https.getNextMatchForTeam(e,t);return await this.footballService.setAvailableMarketsForMatch(n)}catch(n){throw console.warn(`There was a problem retrieving the next match for the following team: ${e}`,n),n}};getPrevMatchForTeamIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let o=await this.getPrevMatchForTeam(e,t);return await this.idMapping.remapEntities(o,"match")}catch(n){throw console.warn(`There was a problem browsing the previous match for the following team:${e}`,n),n}};getPrevMatchForTeam=async(e,t)=>{try{t=t||!1;let n=await this.https.getPrevMatchForTeam(e,t);return await this.footballService.setAvailableMarketsForMatch(n)}catch(n){throw console.warn(`There was a problem retrieving the previous match for the following team: ${e}`,n),n}}};var zr=class{countryId=null;scope=null;name=null;playerIds=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(e){this.countryId=e.countryId?e.countryId:null,this.scope=e.scope?e.scope:null,this.name=e.name?e.name:null,this.playerIds=e.playerIds?e.playerIds:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.sortField=e.sortField?e.sortField:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFilterUrl=()=>{let e="";return this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),this.name&&(e=e+"&",e=e+`name=${this.name}`),this.playerIds&&(e=e+"&",e=e+`player_ids=${this.playerIds.join(",")}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),e}};var Qt=class{https=null;footballService=null;idMapping=null;constructor(e,t,n){this.idMapping=n,this.https=t,this.footballService=new Yt(e)}getPlayersIdMapping=async(e,t)=>{try{let n=!1;if(e){if(e=new zr(e),e.countryId){let p=await this.idMapping.getEntityIdsBySchemaId([e.countryId],"country","native");p.country.length===0&&(n=!0),e.countryId=p.country[0]}if(e.playerIds){let p=await this.idMapping.getEntityIdsBySchemaId(e.playerIds,"player","native");p.player.length===0&&(n=!0),e.playerIds=p.player}if(e.scope){let p=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");p.competition.length===0&&(n=!0),e.scope=p.competition}if(n)return[]}let o=await this.getPlayers(e,t);return o.data=await this.idMapping.remapEntities(o.data,"player"),o}catch(n){throw console.warn("There was a problem browsing the players",n),n}};getPlayersWithNativeIds=async e=>{let t=e.length,n=new zr({playerIds:e,limit:t}),o=await this.getPlayers(n);return o.data.sort((p,d)=>p.id.localeCompare(d.id)),await this.idMapping.remapEntities(o.data,"player")};getPlayersMapWithNativeIds=async e=>{let t={},n=Xt(e);n.sort((p,d)=>p.localeCompare(d));let o=await this.getPlayersWithNativeIds(n);return n.forEach((p,d)=>t[p]=o[d]),t};getPlayers=async(e,t)=>{try{return t=t||!1,await this.https.getPlayers(e,t)}catch(n){throw console.warn("There was a problem retrieving the players",n),n}};getPlayerIdMapping=async(e,t)=>{try{let n=await this.idMapping.getEntityIdsBySchemaId([e],"player","native"),o=await this.getPlayerById(n.player[0],t);return await this.idMapping.remapEntities(o,"player")}catch(n){throw console.warn(`There was a problem browsing the following player:${e}`,n),n}};getPlayerById=async(e,t)=>{try{return t=t||!1,await this.https.getPlayerById(e,t)}catch(n){throw console.warn(`There was a problem retrieving the following player: ${e}`,n),n}};getTopPlayersIdMapping=async e=>{try{let t=await this.getTopPlayers(e);return await this.idMapping.remapEntities(t,"player")}catch(t){throw console.warn("There was a problem browsing the top players",t),t}};getTopPlayers=async e=>{try{return e=e||!1,await this.https.getTopPlayers(e)}catch(t){throw console.warn("There was a problem retrieving the top players",t),t}};getNextMatchForPlayerIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let o=await this.getNextMatchForPlayer(e,t);return await this.idMapping.remapEntities(o,"match")}catch(n){throw console.warn(`There was a problem browsing the next match for player:${e}`,n),n}};getNextMatchForPlayer=async(e,t)=>{try{t=t||!1;let n=await this.https.getNextMatchForPlayer(e,t);return await this.footballService.setAvailableMarketsForMatch(n)}catch(n){throw console.warn(`There was a problem retrieving the next match for player: ${e}`,n),n}};getPrevMatchForPlayerIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let o=await this.getPrevMatchForPlayer(e,t);return await this.idMapping.remapEntities(o,"match")}catch(n){throw console.warn(`There was a problem browsing the previous match for player:${e}`,n),n}};getPrevMatchForPlayer=async(e,t)=>{try{t=t||!1;let n=await this.https.getPrevMatchForPlayer(e,t);return await this.footballService.setAvailableMarketsForMatch(n)}catch(n){throw console.warn(`There was a problem retrieving the previous match for player: ${e}`,n),n}}};var Jr=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 zt=class{https=null;idMapping=null;footballService=null;constructor(e,t,n){this.https=t,this.idMapping=n,this.footballService=new Yt(e)}getMatchesIdMapping=async(e,t)=>{try{if(e){if(e=new Jr(e),e.countryIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.countryIds,"country","native");e.countryIds=o.country}if(e.competitionIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");e.competitionIds=o.competition}if(e.matchIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.matchIds,"match","native");e.matchIds=o.match}if(e.teamIds){let o=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");e.teamIds=o.team}}let n=await this.getMatches(e,t);return n.data=await this.footballService.setAvailableMarketsForMatch([...n.data]),n.data=await this.idMapping.remapEntities(n.data,"match"),n}catch(n){throw console.warn("There was a problem browsing the matches",n),n}};getMatchesWithNativeIds=async e=>{let t=e.length,n=new Jr({matchIds:e,limit:t}),o=await this.getMatches(n);return o.data.sort((p,d)=>p.id.localeCompare(d.id)),await this.idMapping.remapEntities(o.data,"match")};getMatchesMapWithNativeIds=async e=>{let t={},n=Xt(e);n.sort((p,d)=>p.localeCompare(d));let o=await this.getMatchesWithNativeIds(n);return n.forEach((p,d)=>t[p]=o[d]),t};getMatches=async(e,t)=>{try{return t=t||!1,await this.https.getMatches(e,t)}catch(n){throw console.warn("There was a problem retrieving the matches",n),n}};getMatchIdMapping=async(e,t)=>{try{let n=await this.idMapping.getEntityIdsBySchemaId([e],"match","native"),o=await this.getMatchById(n.match[0],t),p=await this.footballService.setAvailableMarketsForMatch(o);return await this.idMapping.remapEntities(p,"match")}catch(n){throw console.warn(`There was a problem browsing the following match: ${e}`,n),n}};getMatchById=async(e,t)=>{try{return t=t||!1,await this.https.getMatchById(e,t)}catch(n){throw console.warn(`There was a problem retrieving the following match: ${e}`,n),n}}};var Ha=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 $a=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}searchIdMapping=async(e,t)=>{try{if(e=new Ha(e),e.scope){let o=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");e.scope=o.competition}let n=await this.search(e,t);if(n.teams&&n.teams.length>0){let o=await this.idMapping.remapEntities(n.teams,"team");n.teams=o}if(n.players&&n.players.length>0){let o=await this.idMapping.remapEntities(n.players,"player");n.players=o}if(n.competitions&&n.competitions.length>0){let o=await this.idMapping.remapEntities(n.competitions,"competition");n.competitions=o}return n}catch(n){throw console.warn("There was a problem with browsing the search result",n),n}};search=async(e,t)=>{try{return await this.https.search(e,t)}catch(n){throw console.warn("There was a problem retrieving the search response",n),n}}};var qi=class{countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(e,t,n,o){this.countriesFacade=new Ea(t,n,o),this.competitionsFacade=new Ca(t,n,o),this.teamsFacade=new ka(e,n,o),this.playerFacade=new Qt(e,n,o),this.matchFacade=new zt(e,n,o),this.searchFacade=new $a(n,o)}getCountries=async e=>this.countriesFacade.getCountriesWithIdMapping(e);getCompetitions=async(e,t)=>this.competitionsFacade.getCompetitionsIdMapping(e,t);getCompetitionById=async(e,t)=>this.competitionsFacade.getCompetitionByIdIdMapping(e,t);getTopCompetitions=async e=>this.competitionsFacade.getTopCompetitionsIdMapping(e);getCompetitionsMapWithNativeIds=async e=>await this.competitionsFacade.getCompetitionsMapWithNativeIds(e);getTeams=async(e,t)=>this.teamsFacade.getTeamsIdMapping(e,t);getTeamById=async(e,t)=>this.teamsFacade.getTeamByIdIdMapping(e,t);getTopTeams=async e=>this.teamsFacade.getTopTeamsIdMapping(e);getNextMatchForTeam=async(e,t)=>this.teamsFacade.getNextMatchForTeamIdMapping(e,t);getPrevMatchForTeam=async(e,t)=>this.teamsFacade.getPrevMatchForTeamIdMapping(e,t);getTeamsMapWithNativeIds=async e=>await this.teamsFacade.getTeamsMapWithNativeIds(e);getPlayers=async(e,t)=>this.playerFacade.getPlayersIdMapping(e,t);getPlayerById=async(e,t)=>this.playerFacade.getPlayerIdMapping(e,t);getTopPlayers=async e=>this.playerFacade.getTopPlayersIdMapping(e);getNextMatchForPlayer=async(e,t)=>this.playerFacade.getNextMatchForPlayerIdMapping(e,t);getPrevMatchForPlayer=async(e,t)=>this.playerFacade.getPrevMatchForPlayerIdMapping(e,t);getPlayersMapWithNativeIds=async e=>this.playerFacade.getPlayersMapWithNativeIds(e);getMatches=async(e,t)=>this.matchFacade.getMatchesIdMapping(e,t);getMatchById=async(e,t)=>this.matchFacade.getMatchIdMapping(e,t);search=async(e,t)=>this.searchFacade.searchIdMapping(e,t)};var Va=class{id="";alias="";countryCode="";assets=null;name=""};var oe=class{countriesFromResponse=e=>{if(e)return e.map(t=>this.countryFromResponse(t))};countryFromResponse=e=>{try{if(e){let t=new Va;return t.id=e.id,t.alias=e.alias,t.assets=e.assets,t.countryCode=e.country_code,t.name=e.name,t}}catch(t){throw t}return null}};var qa=class{id="";country=null;gender="";assets=null;type="";name=""};var Ne=class{countryRemapper=null;constructor(){this.countryRemapper=new oe}fromResponse(e){try{let t=new qa;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var Wa=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var Ka=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName=""};var we=class{countryRemapper=null;constructor(){this.countryRemapper=new oe}fromResponse(e){try{let t=new Ka;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t}catch(t){throw console.warn("There was a problem remapping teams response",t),t}}};var Xa=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new oe,this.teamBasicRemapper=new we}fromResponse(e){try{let t=new Wa;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t.participants=e.participants.map(n=>this.teamBasicRemapper.fromResponse(n)),t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var Ya=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";squad=[]};var Qa=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var za=class{countryRemapper=null;constructor(){this.countryRemapper=new oe}fromResponse(e){try{let t=new Qa;return t.id=e.id,t.startDate=e.start_date,t.endDate=e.end_date,t.shirtNumber=e.shirt_number,t.loan=e.loan,t.position=e.position,t.country=this.countryRemapper.countryFromResponse(e.country),t.name=e.name,t.assets=e.assets,t.birthDate=e.birth_date,t}catch(t){throw console.warn("There was a problem remapping the player from squad",t),t}}};var Ja=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new oe,this.competitionRemapper=new Ne,this.playerRemapper=new za}fromResponse(e){try{let t=new Ya;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t.competitions=e.competitions?e.competitions.map(n=>this.competitionRemapper.fromResponse(n)):[],t.squad=e.squad?e.squad.map(n=>this.playerRemapper.fromResponse(n)):[],t}catch(t){throw console.warn("There was a problem remapping team response",t),t}}};var Za=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 ja=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var Wi=class{fromResponse(e){try{let t=new ja;return t.ftScore=this.statEntityFromResponse(e.ft_score),t.htScore=this.statEntityFromResponse(e.ht_score),t.aetScore=this.statEntityFromResponse(e.aet_score),t.aggScore=this.statEntityFromResponse(e.agg_score),t.penScore=this.statEntityFromResponse(e.pen_score),t}catch(t){throw console.warn("There was a problem remapping the scores",t),t}}statEntityFromResponse=e=>({homeGoals:e.home_goals,awayGoals:e.away_goals})};var eo=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new we,this.competitionRemapper=new Ne,this.scoresRemapper=new Wi}fromResponse(e){try{let t=new Za;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.homeTeam=this.teamRemapper.fromResponse(e.home_team),t.awayTeam=this.teamRemapper.fromResponse(e.away_team),t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresRemapper.fromResponse(e.scores),t.context={competition:e.context.competition?this.competitionRemapper.fromResponse(e.context.competition):null},t.status={type:e.status.type,subType:e.status.sub_type},t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var to=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 io=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 ro=class{fromResponse(e){try{let t=new io;return t.corners=this.statEntityFromResponse(e.corners),t.crosses=this.statEntityFromResponse(e.crosses),t.offside=this.statEntityFromResponse(e.offside),t.shotsOn=this.statEntityFromResponse(e.shots_on),t.throwIn=this.statEntityFromResponse(e.throw_in),t.redCards=this.statEntityFromResponse(e.red_cards),t.shotsOff=this.statEntityFromResponse(e.shots_off),t.goalKicks=this.statEntityFromResponse(e.goal_kicks),t.possession=this.statEntityFromResponse(e.possession),t.treatments=this.statEntityFromResponse(e.treatments),t.yellowCards=this.statEntityFromResponse(e.yellow_cards),t.shotsBlocked=this.statEntityFromResponse(e.shots_blocked),t.substitutions=this.statEntityFromResponse(e.substitutions),t.counterAttacks=this.statEntityFromResponse(e.counter_attacks),t.foulsCommitted=this.statEntityFromResponse(e.fouls_committed),t}catch(t){throw console.warn("There was a problem remapping the stats",t),t}}statEntityFromResponse=e=>({homeTeam:e?e.home_team:null,awayTeam:e?e.away_team:null})};var Ki=class{homeTeam={players:[]};awayTeam={players:[]}};var no=class{id="";name="";position="";shirtNumber;assets=null;type=""};var Xi=class{fromResponse(e){try{let t=new no;return t.id=e.id,t.name=e.name,t.position=e.position,t.shirtNumber=e.shirt_number,t.assets=e.assets,t.type=e.type,t}catch(t){throw console.warn("There was a problem remapping the player from timeline",t),t}}};var ao=class{playerRemapper=null;constructor(){this.playerRemapper=new Xi}fromResponse(e){try{let t=new Ki;return t.homeTeam.players=e.home_team&&e.home_team.players?e.home_team.players.map(n=>this.playerRemapper.fromResponse(n)):[],t.awayTeam.players=e.away_team&&e.away_team.players?e.away_team.players.map(n=>this.playerRemapper.fromResponse(n)):[],t}catch(t){throw console.warn("There was a problem remapping the lineups",t),t}}};var oo=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var so=class{playerRemapper=null;constructor(){this.playerRemapper=new Xi}fromResponse(e){try{let t=new oo;return t.minute=e.minute,t.type=e.type,t.teamId=e.team_id,t.player=this.playerRemapper.fromResponse(e.player),t.relatedPlayer=e.related_player?this.playerRemapper.fromResponse(e.related_player):null,t.updatedAt=e.updated_at,t}catch(t){throw console.warn("There was a problem remapping timeline",t),t}}};var lo=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new we,this.competitionsMapper=new Ne,this.lineupsMapper=new ao,this.scoresMapper=new Wi,this.statsMapper=new ro,this.timelineMapper=new so}fromResponse(e){try{let t=new to;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.homeTeam=e.home_team?this.teamMapper.fromResponse(e.home_team):null,t.awayTeam=e.away_team?this.teamMapper.fromResponse(e.away_team):null,t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresMapper.fromResponse(e.scores),t.stats=this.statsMapper.fromResponse(e.stats),t.context={competition:this.competitionsMapper.fromResponse(e.context.competition)},t.timeline=e.timeline?e.timeline.map(n=>this.timelineMapper.fromResponse(n)):[],t.status={type:e.status.type,subType:e.status.sub_type},t.lineups=e.lineups?this.lineupsMapper.fromResponse(e.lineups):new Ki,t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var po=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var co=class{countryRemapper=null;constructor(){this.countryRemapper=new oe}fromResponse(e){try{let t=new po;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping top player response",t),t}}};var uo=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;teams=[]};var Yi=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new oe,this.teamRemapper=new we}fromResponse(e){try{let t=new uo;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(n=>this.teamRemapper.fromResponse(n)):[],t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping players response",t),t}}};var mo=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;competitions=[];teams=[]};var fo=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new oe,this.teamRemapper=new we,this.competitionRemapper=new Ne}fromResponse(e){try{let t=new mo;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(n=>this.teamRemapper.fromResponse(n)):[],t.position=e.position,t.competitions=e.competitions?e.competitions.map(n=>this.competitionRemapper.fromResponse(n)):[],t}catch(t){throw console.warn("There was a problem remapping player response",t),t}}};var ho=class{teams=null;players=null;competitions=null};var go=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new we,this.playerRemapper=new Yi,this.competitionremapper=new Ne}fromResponse(e){try{let t=new ho;return t.teams=e.teams?e.teams.map(n=>this.teamRemapper.fromResponse(n)):[],t.players=e.players?e.players.map(n=>this.playerRemapper.fromResponse(n)):[],t.competitions=e.competitions?e.competitions.map(n=>this.competitionremapper.fromResponse(n)):[],t}catch(t){throw console.warn("There was a problem remapping search response",t),t}}};var Qi=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var Jt=class{pagination=new Qi};var zi=class{meta=new Jt;data=[]};var yo=class{remapMetaProp=e=>{let t=new Jt;return t.pagination.currentPage=e.pagination.current_page,t.pagination.itemsPerPage=e.pagination.items_per_page,t.pagination.totalItems=e.pagination.total_items,t.pagination.numberOfPages=e.pagination.number_of_pages,t}};var wt=class extends Me{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){super(e,Oe(e.environment,"football"));this.clientId=e.clientId,this.apiSignInUrl=`?key=${e.apiKey}&lang=${e.lang}`,this.countryRemapper=new oe,this.competitionBasicRemapper=new Ne,this.competitionFullRemapper=new Xa,this.teamBasicRemapper=new we,this.teamFullRemapper=new Ja,this.matchBasicRemapper=new eo,this.matchFullRemapper=new lo,this.playerBasicRemapper=new Yi,this.playerFullRemapper=new fo,this.topPlayerRemapper=new co,this.searchRemapper=new go,this.footballMetaRemapper=new yo}getCountries=async e=>{try{let t=`/countries${this.apiSignInUrl}`,n=Date.now();e&&(t+=`&disable_cache=${n}`);let o=await this.instance.get(t);return this.countryRemapper.countriesFromResponse(o.data.data)}catch(t){throw console.warn("There was a problem with the football countries request",t),t}};getCompetitions=async(e,t)=>{try{let n={},o=Date.now();if(t=t||!1,e&&e.competitionIds&&e.competitionIds.length>this.limitIds-1){let p=[],d=ea(e.competitionIds);for(let y of d){e.competitionIds=y;let I=`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(I+=`&disable_cache=${o}`),n=await this.instance.get(I),p.push(n.data.data.map(b=>this.competitionBasicRemapper.fromResponse(b)))}return Array.prototype.concat.apply([],p)}else{let p=`/competitions${this.apiSignInUrl}`;return e&&(p+=`${e.constructFilterUrl()}`),t&&(p+=`&disable_cache=${o}`),n=await this.instance.get(p),n.data.data.map(d=>this.competitionBasicRemapper.fromResponse(d))}}catch(n){throw console.warn("There was a problem with getCompetitions request",n),n.response}};getCompetitionById=async(e,t)=>{try{let n=`/competitions/${e}${this.apiSignInUrl}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.competitionFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getCompetitionById request",n),n.response}};getTopCompetitions=async e=>{try{let t=`/competitions/top${this.apiSignInUrl}&client_id=${this.clientId}`,n=Date.now();return e&&(t+=`&disable_cache=${n}`),(await this.instance.get(t)).data.data.map(p=>this.competitionBasicRemapper.fromResponse(p))}catch(t){throw console.warn("There was a problem with getTopCompetitions request",t),t.response}};getTeams=async(e,t)=>{try{let n={},o=Date.now();if(e&&e.teamIds&&e.teamIds.length>this.limitIds){let p=[],d=ea(e.teamIds);for(let y of d){e.teamIds=y;let I=`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(I+=`disable_cache=${o}`),n=await this.instance.get(I),p.push(n.data.data.map(b=>this.teamBasicRemapper.fromResponse(b)))}return Array.prototype.concat.apply([],p)}else{let p=new zi,d=`/teams${this.apiSignInUrl}`;return e&&(d+=`${e.constructFilterUrl()}`),t&&(d+=`&disable_cache=${o}`),n=await this.instance.get(d),p.meta=this.footballMetaRemapper.remapMetaProp(n.data.meta),p.data=n.data.data.map(h=>this.teamBasicRemapper.fromResponse(h)),p}}catch(n){throw console.warn("There was a problem with getTeams request",n),n.response}};getTeamById=async(e,t)=>{try{let n=`/teams/${e}${this.apiSignInUrl}`,o=Date.now();t&&(n+=`disable_cache=${o}`);let p=await this.instance.get(n);return this.teamFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getTeamById request",n),n.response}};getTopTeams=async e=>{try{let t=`/teams/top${this.apiSignInUrl}&client_id=${this.clientId}`,n=Date.now();e&&(t+=`$disable_cache=${n}`);let o=await this.instance.get(t);return o.data.data?o.data.data.map(p=>this.teamBasicRemapper.fromResponse(p)):[]}catch(t){throw console.warn("There was a problem with getTopTeams request",t),t.response}};getNextMatchForTeam=async(e,t)=>{try{let n=`/teams/${e}/next-match${this.apiSignInUrl}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getNextMatchForTeam request",n),n.response}};getPrevMatchForTeam=async(e,t)=>{try{let n=`/teams/${e}/previous-match${this.apiSignInUrl}`,o=Date.now();t&&(n+=`disable_cache=${o}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getPrevMatchForTeam request",n),n.response}};getPlayers=async(e,t)=>{try{let n={},o=Date.now();if(e&&e.playerIds&&e.playerIds.length>this.limitIds-1){let p=[],d=ea(e.playerIds);for(let y of d){e.playerIds=y;let I=`/players${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(I+=`&disable_cache=${o}`),n=await this.instance.get(I),p.push(n.data.data.map(b=>this.teamBasicRemapper.fromResponse(b)))}return Array.prototype.concat.apply([],p)}else{let p=new zi,d=`/players${this.apiSignInUrl}`;return e&&(d+=`${e.constructFilterUrl()}`),t&&(d+=`&disable_cache=${o}`),n=await this.instance.get(d),p.meta=this.footballMetaRemapper.remapMetaProp(n.data.meta),p.data=n.data.data.map(h=>this.playerBasicRemapper.fromResponse(h)),p}}catch(n){throw console.warn("There was a problem with getPlayers request",n),n.response}};getPlayerById=async(e,t)=>{try{let n=`/players/${e}${this.apiSignInUrl}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.playerFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getPlayerById request",n),n.response}};getTopPlayers=async e=>{try{let t=`/players/top${this.apiSignInUrl}&client_id=${this.clientId}`,n=Date.now();return e&&(t+=`&disable_cache=${n}`),(await this.instance.get(t)).data.data.map(p=>this.topPlayerRemapper.fromResponse(p))}catch(t){throw console.warn("There was a problem with getTopPlayers request",t),t.response}};getNextMatchForPlayer=async(e,t)=>{try{let n=`/players/${e}/next-match${this.apiSignInUrl}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getNextMatchForPlayer request",n),n.response}};getPrevMatchForPlayer=async(e,t)=>{try{let n=`/players/${e}/previous-match${this.apiSignInUrl}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getPrevMatchForPlayer request",n),n.response}};getMatchById=async(e,t)=>{try{let n=`/matches/${e}${this.apiSignInUrl}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.matchFullRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with getMatchById request",n),n.response}};getMatches=async(e,t)=>{try{let n=new zi,o=`/matches${this.apiSignInUrl}`,p=Date.now();e&&(o+=`${e.constructFilterUrl()}`),t&&(o+=`&disable_cache=${p}`);let d=await this.instance.get(o);return n.meta=this.footballMetaRemapper.remapMetaProp(d.data.meta),n.data=d.data.data.map(h=>this.matchBasicRemapper.fromResponse(h)),n}catch(n){throw console.warn("There was a problem with getMatches request",n),n.response}};search=async(e,t)=>{try{let n=`/search${this.apiSignInUrl}${e.constructFilterUrl()}`,o=Date.now();t&&(n+=`&disable_cache=${o}`);let p=await this.instance.get(n);return this.searchRemapper.fromResponse(p.data.data)}catch(n){throw console.warn("There was a problem with search request",n),n.response}}};var _e=(N=>(N.FT_1X2="FT_1X2",N.HT_1X2="HT_1X2",N.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",N.DOUBLE_CHANCE="DOUBLE_CHANCE",N.HT_FT="HT_FT",N.PLAYER_SCORE="PLAYER_SCORE",N.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",N.PLAYER_RED_CARD="PLAYER_RED_CARD",N.RED_CARD_MATCH="RED_CARD_MATCH",N.PENALTY_MATCH="PENALTY_MATCH",N.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",N.CORNERS_MATCH="CORNERS_MATCH",N.CORRECT_SCORE="CORRECT_SCORE",N.CORRECT_SCORE_ADVANCED="CORRECT_SCORE_ADVANCED",N.CORRECT_SCORE_HT="CORRECT_SCORE_HT",N.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",N.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",N.OVER_GOALS_0_5="OVER_GOALS_0_5",N.OVER_GOALS_1_5="OVER_GOALS_1_5",N.OVER_GOALS_2_5="OVER_GOALS_2_5",N.OVER_GOALS_3_5="OVER_GOALS_3_5",N.OVER_GOALS_4_5="OVER_GOALS_4_5",N.OVER_GOALS_5_5="OVER_GOALS_5_5",N.OVER_GOALS_6_5="OVER_GOALS_6_5",N.OVER_CORNERS_6_5="OVER_CORNERS_6_5",N.OVER_CORNERS_7_5="OVER_CORNERS_7_5",N.OVER_CORNERS_8_5="OVER_CORNERS_8_5",N.OVER_CORNERS_9_5="OVER_CORNERS_9_5",N.OVER_CORNERS_10_5="OVER_CORNERS_10_5",N.OVER_CORNERS_11_5="OVER_CORNERS_11_5",N.OVER_CORNERS_12_5="OVER_CORNERS_12_5",N.OVER_CORNERS_13_5="OVER_CORNERS_13_5",N))(_e||{}),Sd=["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"],Td=["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"],bt=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"],Ed=["FT_1X2","HT_1X2","HT_FT","DOUBLE_CHANCE","CORNERS_MATCH","CORRECT_SCORE","CORRECT_SCORE_HT","CORRECT_SCORE_ADVANCED"],Zr="PLAYER_SCORE_FIRST_GOAL";var Mo=class{overallPercent;byFootballCompetition;byFootballTeam;byFootballMarket};var wo=class{profileId;tier;points;successRates=new Mo};var bo=class{successRatePercent;model=null};var vo=class{id=null;label=null};var Io=class{type=null;id=null;label=null};var Ji=class{content=new Io;tags=[];campaign=new vo};var Zi=class{id=null;profileId=null;action=null;context=new Ji;points=0};var Po=class{totalItems=0};var _o=class{meta=new Po;data=[new Zi]};var Ro=class{remapSingleResponse=e=>{let t=new Zi;return t.id=e.id,t.profileId=e.profile_id,t.action=e.action,t.context.content=e.context.content??t.context.content,t.context.tags=e.context.tags,t.context.campaign=e.context.campaign??t.context.campaign,t.points=e.points,t};remapActivitiesResponse=e=>{let t=new _o;return t.meta.totalItems=e.meta.total_items,t.data=e.data.map(n=>this.remapSingleResponse(n)),t};remapStatsReponse=e=>{let t=new wo;return t.profileId=e.profile_id,t.tier=e.tier,t.points=e.points,t.successRates.overallPercent=e.success_rates.overall_percent,t.successRates.byFootballCompetition=this.constructNewRecord(e.success_rates.by_competition),t.successRates.byFootballTeam=this.constructNewRecord(e.success_rates.by_team),t.successRates.byFootballMarket=this.constructNewRecord(e.success_rates.by_market),t};constructNewRecord=e=>{let t;if(Object.entries(e).length)Object.entries(e).forEach(([n,o])=>{t={...t,[n]:this.remapSuccessRatePercent(o)},_e[n]&&delete t[n].model});else return e;return t};remapSuccessRatePercent=e=>{let t=new bo;return t.successRatePercent=e.success_rate_percent,t}};var ji=class extends Me{activityRemapper=null;apiSignInUrl=null;constructor(e){super(e,Oe(e.environment,"loyalty"));this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.activityRemapper=new Ro}createActivity=async e=>{try{let t=`/activities${this.apiSignInUrl}`,n=await this.instanceAuth.post(t,JSON.stringify(e));return this.activityRemapper.remapSingleResponse(n.data)}catch(t){throw console.warn("There was a problem with creating activity for user",t),t}};deleteActivity=async e=>{try{let t=`/activities/${e}${this.apiSignInUrl}`;return await this.instanceAuth.delete(t),!0}catch(t){throw console.warn(`There was a problem deleting the following activity: ${e}`,t),t.response}};getOwnActivities=async(e,t)=>{try{let n=`/activities${this.apiSignInUrl}`,o=Date.now();e&&(n+=`${e.constructFilterUrl()}`),t&&(n+=`disable_cache=${o}`);let p=await this.instanceAuth.get(n);return this.activityRemapper.remapActivitiesResponse(p.data)}catch(n){throw console.warn("There was a problem with fetching own activities",n),n}};getActivitiesForUser=async(e,t,n)=>{try{let o=`/users/${e}/activities${this.apiSignInUrl}`,p=Date.now();t&&(o+=`${t.constructFilterUrl()}`),n&&(o+=`disable_cache=${p}`);let d=await this.instance.get(o);return this.activityRemapper.remapActivitiesResponse(d.data)}catch(o){throw console.warn(`There was a problem with fetching activities for user ${e}`,o),o}};getStats=async(e,t)=>{try{let n="",o=null;return e?(n+=de(t)?`/users/${e}/statistics${this.apiSignInUrl}${fe()}`:`/users/${e}/statistics${this.apiSignInUrl}`,o=await this.instance.get(n)):(n+=`/statistics${this.apiSignInUrl}`,o=await this.instanceAuth.get(n)),this.activityRemapper.remapStatsReponse(o.data.data)}catch(n){throw console.warn("There was a problem fetching profile`s statistics:",n),n.response}}};var Fo=class{idMapping=null;idSchema=null;native="native";footballFacade=null;constructor(e,t,n){this.idMapping=n,this.idSchema=e.idSchema,this.footballFacade=t}remapSuccessRatesEntities=async e=>{let{successRates:t}=e,n={competition:this.getIdsKeys(t.byFootballCompetition),team:this.getIdsKeys(t.byFootballTeam)};if(Object.values(n.competition).length){let o=e.successRates.byFootballCompetition;e.successRates.byFootballCompetition=await this.setModels(o,n.competition,"competition")}if(Object.values(n.team).length){let o=e.successRates.byFootballTeam;e.successRates.byFootballTeam=await this.setModels(o,n.team,"team")}return e};setModels=async(e,t,n)=>{let o=null,p;switch(t=Hr(t),n){case"competition":o=await this.footballFacade.getCompetitionsMapWithNativeIds(t);break;case"team":o=await this.footballFacade.getTeamsMapWithNativeIds(t);break}return Object.keys(e).forEach(d=>{let h=o.get(d);p={...p,[h.id]:e[d]},p[h.id].model=h}),p};getIdsKeys=e=>{let t=JSON.parse(JSON.stringify(e));return Object.keys(t)};remapInterestsToIdSchema=async e=>{if(this.idSchema!==this.native)if(e&&e.length>0){let t={},n={};e.forEach(d=>{t.hasOwnProperty(d.type)||(t[d.type]=[],n[d.type]=[]),t[d.type].push(d.id),n[d.type].push(d)});let o=await this.remapIdsObj(t,this.native,this.idSchema),p=[];for(let[d,h]of Object.entries(n))h.forEach((y,I)=>{y.id=o[d][I],p.push(y)});return p}else return e;return e};remapInterestToNative=async e=>{if(this.idSchema!==this.native){let t={},{id:n,type:o}=e;t[o]=[n];let p=await this.remapIdsObj(t,this.idSchema,this.native);return e.id=p[o][0],e}return e};inquiryCustomInterests=e=>{let t=[];return e&&e.length>0&&(t=e.filter(n=>n.source.toLocaleUpperCase()==="CUSTOM")),t};remapInterests=async e=>{let t=this.inquiryCustomInterests(e);if(t&&t.length>0){let n=e.filter(p=>p.source.toLocaleUpperCase()!=="CUSTOM"),o=await this.remapInterestsToIdSchema(n);return t.forEach(p=>o.push(p)),o}return await this.remapInterestsToIdSchema(e)};showFullInterests=async e=>{let t=[];if(e&&e.length>0){let n=this.inquiryCustomInterests(e);t.push(n);let o=e.filter(I=>I.source.toLocaleUpperCase()!=="CUSTOM"),{competitionsMap:p,teamsMap:d,playersMap:h}=await this.getInterestsEntitiesMap(o),y=o.map(I=>{let b=null;if(I.type==="competition")return b=p.get(I.id),b&&(I.id=b.id),I.model=b,I;if(I.type==="team")return b=d.get(I.id),b&&(I.id=b.id),I.model=b,I;if(I.type==="player")return h?(I.model=h[I.id],I.id=h[I.id].id):I.model=b,I});return t.push(y),t.flat()}return t};getInterestsEntitiesMap=async e=>{let t=[],n=[],o=[],p=new Map,d=new Map,h=null;if(e.forEach(y=>{y.type==="competition"?t.push(y.id):y.type==="team"?n.push(y.id):y.type==="player"&&o.push(y.id)}),t.length){let y=Hr(t);p=await this.footballFacade.getCompetitionsMapWithNativeIds(y)}if(n.length){let y=Hr(n);d=await this.footballFacade.getTeamsMapWithNativeIds(y)}if(o.length){let y=Hr(o);h=await this.footballFacade.getPlayersMapWithNativeIds(y)}return{competitionsMap:p,teamsMap:d,playersMap:h}};remapIdsObj=async(e,t,n)=>await this.idMapping.idMappingFacade.getEntitiesByIds(e,t,n)};var So=class{idMapping=null;profileOperations=null;constructor(e,t){this.idMapping=new ae(e),this.profileOperations=new Fo(e,t,this.idMapping)}remapSuccessRatesEntities=async e=>await this.profileOperations.remapSuccessRatesEntities(e);remapInterestToNative=async e=>await this.profileOperations.remapInterestToNative(e);remapInterests=async e=>await this.profileOperations.remapInterests(e);showFullInterests=async e=>await this.profileOperations.showFullInterests(e)};var er=class{idsRemapper=null;profileHttps=null;activityHttps=null;footballHttps=null;footballFacade=null;idMapping=null;localStorage=null;profileFacade=null;ownProfileBuilder=null;profileBuilder=null;constructor(e){this.profileHttps=new Ui(e),this.activityHttps=new ji(e),this.footballHttps=new wt(e),this.idMapping=new ae(e),this.localStorage=new yt(e),this.footballFacade=new qi(e,this.localStorage,this.footballHttps,this.idMapping),this.profileFacade=new Mt(this.localStorage,this.profileHttps,this.activityHttps),this.idsRemapper=new So(e,this.footballFacade),this.ownProfileBuilder=new Sa(this.idsRemapper,this.localStorage,this.profileHttps,this.activityHttps,this.idMapping,this.footballFacade),this.profileBuilder=new Ta(this.idsRemapper,this.localStorage,this.profileHttps,this.activityHttps)}getOwn=()=>this.ownProfileBuilder;getById=e=>this.profileBuilder.setId(e);getCountries=async e=>await this.profileFacade.getCountries(e);getByIds=async(e,t)=>await this.profileFacade.getByIds(e,t)};var To=class{validate=e=>{let t=this.validateField(e.lang),n=this.generateMessage(t);return{validation:t,message:n}};validateField=e=>{let t=["bg","ro","en"],n=null;return e!=null&&e.length>0?t.includes(e)?n="valid":n="invalid":n="missing",n};generateMessage=e=>{let t=null,n="warning";return e==="missing"&&(t="If no lang is passed the default one will be set which is: en"),e==="invalid"&&(t="This lang value is not supported, the default one will be set which is: en"),e==="valid"&&(t=null,n=null),{text:t,type:n}}};var Eo=class{validate(e){let t=this.validateField(e.environment),n=this.generateMessage(t);return{validation:t,message:n}}validateField=e=>{let t=["dev","staging","prod"],n=null;return e!=null&&e.length>0?t.includes(e)?n="valid":n="invalid":n="missing",n};generateMessage=e=>{let t=null,n="warning";return e==="missing"&&(t="If no environment is passed the default one will be set which is: prod"),e==="invalid"&&(t="This environment value is not supported, the default one will be set which is: prod"),e==="valid"&&(t=null,n=null),{text:t,type:n}}};var Co=class{validate(e){let t=this.validateField(e.apiKey),n=this.generateMessage(t);return{validation:t,message:n}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,n="error";return e==="missing"&&(t="The field apiKey with valid value must be provided to use Fans United JS SDK"),e==="valid"&&(n=null),{text:t,type:n}}};var Ao=class{validate(e){let t=this.validateField(e.idSchema),n=this.generateMessage(t);return{validation:t,message:n}}validateField=e=>{let t=["native","sportal365","enetpulse","sportradar"],n=null;return e!=null&&e.length>0?t.includes(e)?n="valid":n="invalid":n="missing",n};generateMessage=e=>{let t=null,n="warning";return e==="missing"&&(t="If no idSchema is passed the default one will be set which is: native"),e==="invalid"&&(t="This idSchema value is not supported, the default one will be set which is: native"),e==="valid"&&(t=null,n=null),{text:t,type:n}}};var fi=class{getIdToken=null;logout=null};var ir=class{text=null;type=null};var xo=class{validation=null;message=new ir;getIdToken={validation:null,message:new ir};logout={validation:null,message:new ir}};var Oo=class{validate(e){let t=this.validateAuthProvider(e.authProvider);return t.validation!=="missing"&&(t=this.validateAuthProviderConfigFields(e.authProvider,t),t=this.generateAuthProviderConfigMessages(t),t=this.checkAuthProviderConfigMessagesForErrors(t)),t}validateAuthProvider=e=>{let t=Object.keys(new fi),n=new xo;if(e){let p=Object.keys(e).filter(d=>!t.includes(d));p.length>0?(n.validation="invalid",n.message.type="warning",n.message.text=`${"You have passed a property which is not supported for the authentication provider:"} ${p.join(",")}`):n.validation="valid"}else n.validation="missing",n.message.type="error",n.message.text="The field authProvider must be provided to use this SDK";return n};validateAuthProviderConfigFields=(e,t)=>(Object.keys(new fi).forEach(o=>{e[o]?t[o].validation="valid":t[o].validation="missing"}),t);generateAuthProviderConfigMessages=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{let n=e[t];n.validation==="missing"&&(n.message.text=`${"The following property is missing from the authProvider object:"} ${t}`,n.message.type="error")}),e);checkAuthProviderConfigMessagesForErrors=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{e[t].validation==="missing"&&e.validation==="valid"&&(e.validation="invalid",e.message.type="error",e.message.text="The field authProvider has missing properties")}),e)};var en=class{validation;message};var Bo=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;authProvider={getIdToken:new en,logout:new en};isValid=!1};var Lo=class{validate(e){let t=this.validateField(e.clientId),n=this.generateMessage(t);return{validation:t,message:n}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,n="error";return e==="missing"&&(t="The field clientId must be provided to use Fans United JS SDK"),e==="valid"&&(t=null,n=null),{text:t,type:n}}};var No=class{validate=e=>{let t=this.checkFieldsForValues(e);return t.isValid=this.containsErrorMessage(t),t};checkFieldsForValues=e=>{let t=new Bo,n={apiKey:new Co,environment:new Eo,idSchema:new Ao,clientId:new Lo,lang:new To,authProvider:new Oo};for(let[o,p]of Object.entries(t))o!=="isValid"&&(p=n[o].validate(e));return Object.keys(n).forEach(o=>{t[o]=n[o].validate(e)}),t};containsErrorMessage=e=>{let t=!0;for(let[n,o]of Object.entries(e))if(n!=="authProvider"){if(n!=="isValid"&&o.message.type==="error")return t=!1,t;if(n!=="isValid"&&o.message.type==="warning")return t=!0,t}else if(o.message.type==="error")return t=!1,t;return t}};var Do=class{https=null;idMapping=null;localStorage=null;footballFacade=null;constructor(e){this.https=new wt(e),this.idMapping=new ae(e),this.localStorage=new yt(e),this.footballFacade=new qi(e,this.localStorage,this.https,this.idMapping)}getCountries=async e=>await this.footballFacade.getCountries(e);getCompetitions=async(e,t)=>await this.footballFacade.getCompetitions(e,t);getCompetitionById=async(e,t)=>await this.footballFacade.getCompetitionById(e,t);getTopCompetitions=async e=>await this.footballFacade.getTopCompetitions(e);getTeams=async(e,t)=>await this.footballFacade.getTeams(e,t);getTeamById=async(e,t)=>await this.footballFacade.getTeamById(e,t);getTopTeams=async e=>await this.footballFacade.getTopTeams(e);getNextMatchForTeam=async(e,t)=>await this.footballFacade.getNextMatchForTeam(e,t);getPrevMatchForTeam=async(e,t)=>await this.footballFacade.getPrevMatchForTeam(e,t);getPlayers=async(e,t)=>await this.footballFacade.getPlayers(e,t);getPlayerById=async(e,t)=>await this.footballFacade.getPlayerById(e,t);getTopPlayers=async e=>await this.footballFacade.getTopPlayers(e);getNextMatchForPlayer=async(e,t)=>await this.footballFacade.getNextMatchForPlayer(e,t);getPrevMatchForPlayer=async(e,t)=>await this.footballFacade.getPrevMatchForPlayer(e,t);getMatches=async(e,t)=>await this.footballFacade.getMatches(e,t);getMatchById=async(e,t)=>await this.footballFacade.getMatchById(e,t);search=async(e,t)=>await this.footballFacade.search(e,t)};var Uo=class{value=null;playerId=null;playerModel=null};var rr=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new Uo;result=null};var Go=class{value=!1;playerId=null};var tt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n,o){this.matchId=e,this.market=t,this.prediction=new Go,this.prediction.value=n,this.prediction.playerId=o}};var nr=class{settledAt=null;resettledAt=null;status=null;outcome=null;points=0};var ko=class{value=null};var Zt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new ko,this.prediction.value=n}};var it=class{value=!1};var ar=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new it,this.prediction.value=n}};var or=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new it,this.prediction.value=n}};var Ho=class{matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t,n){this.matchFacade=e,this.playerFacade=t,this.predictorService=n}remapFixturesRequest=e=>{let t={};if(t.match_id=e.matchId,t.match_type="FOOTBALL",e instanceof tt)t.market=e.market,t.prediction=e.prediction.value,t.player_id=e.prediction.playerId;else if(e instanceof ar||e instanceof or)t.market=e.market,t.prediction=e.prediction.value;else if(e instanceof Zt){t.market=e.market;let n=e.prediction.value.split(":");t.goals_home=Number(n[0]),t.goals_away=Number(n[1])}else t.market=e.market,t.prediction=e.prediction.value;return t};remapFixturesResponse=async e=>{e.length>1&&e.sort((h,y)=>h.match_id.localeCompare(y.match_id));let t=[],n=[];for(let h of e)t.push(h.match_id),h.player_id&&!n.includes(h.player_id)&&n.push(h.player_id);let o=await this.matchFacade.getMatchesMapWithNativeIds(t),p=[];n.sort((h,y)=>h.localeCompare(y)),n&&n.length>0&&(p=await this.playerFacade.getPlayersMapWithNativeIds(n));let d=[];for(let h of e){let y=new rr;h.target?y.market=this.predictorService.convertMarketForResponseModel(h.market,h.target):y.market=h.market,y.matchId=o[h.match_id].id,y.matchType=h.match_type,y.matchModel=o?o[h.match_id]:null,delete y.matchModel.availableMarkets,h.goals_home!==void 0&&h.goals_away!==void 0?y.prediction.value=h.goals_home.toString()+":"+h.goals_away.toString():y.prediction.value=h.prediction,y.prediction.playerId=h.player_id?h.player_id:null,y.prediction.playerId&&(y.prediction.playerModel=p[h.player_id],y.prediction.playerId=p[h.player_id].id),y.result=this.remapResult(h.result),d.push(y)}return d};remapResult=e=>{let t=new nr;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t.points=e.points,t}};var jt=class{goldenGoal=null};var tn=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new jt;points=null;createdAt=null;updatedAt=null};var j=class{no=0;yes=0};var sr=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new j;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new j;penaltyMatch=new j;playerScoreFirstGoal={};cornersMatch={};correctScore={};correctScoreHalfTime={};correctScoreAdvanced={};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 vt=class{timeTiebreaker=!1};var hi=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new vt;predictionId=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;scheduleOpenAt=null;images=null};var gi=class{userId=null;points=null;results=[];tiebreaker=null};var $o=(p=>(p.ACTIVE="ACTIVE",p.WON="WON",p.LOST="LOST",p.PARTIALLY_WON="PARTIALLY_WON",p.CANCELED="CANCELED",p))($o||{}),Tp=["WON","LOST","PARTIALLY_WON","CANCELED"];var Re=class{limit=null;startAfter=null;status=null;type=null;matchIds=null;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null,this.status=e.status?e.status:null,this.type=e.type?e.type:null,this.matchIds=e.matchIds?e.matchIds:null}constructFiltersUrl=()=>{let e="",t=!1;return this.status&&(t=Object.values($o).some(n=>this.status.includes(n))),this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),this.status&&t&&(e+="&",e+=`status=${this.status.join(",")}`),this.type&&(e+="&",e+=`game_types=${this.type}`),this.matchIds&&(e+="&",e+=`match_ids=${this.matchIds.join(",")}`),e}};var lr=class{limit;startAfter;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null}constructMainFiltersUrl(){let e="";return this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),e}};var rn=(d=>(d.OPEN="OPEN",d.LIVE="LIVE",d.PENDING="PENDING",d.CANCELED="CANCELED",d.CLOSED="CLOSED",d.SETTLED="SETTLED",d))(rn||{});var rt=class extends lr{status=null;type=null;gameIds=null;sortOrder=null;constructor(e){super(e);this.status=e.status?e.status:null,this.type=e.type?e.type:null,this.gameIds=e.gameIds?e.gameIds:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFiltersUrl=()=>{let e=super.constructMainFiltersUrl();return this.status&&Object.values(rn).includes(this.status)&&(e+="&",e+=`status=${this.status}`),this.type&&(e+="&",e+=`type=${this.type}`),this.gameIds&&this.gameIds.length>0&&(e+="&",e+=`game_ids=${this.gameIds.join(",")}`),this.sortOrder&&(e+="&",e+=`sort_order=${this.sortOrder}`),e}};var pr=class{main=null;cover=null;mobile=null};var yi=class{id=null;title=null;description=null;type=null;status=null;scheduleOpenAt=null;predictionsCutoff=null;fixtures=[];tiebreaker=new vt;rules=null;flags=null;images=new pr;createdAt=null;updatedAt=null};var Nt=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new vt;predictionId=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;images=null;scheduleOpenAt=null};var Ep={UNEXPECTED_STATUS_PROP:`Unexpected provided property 'status'. You can NOT use this property for this method. For more information visit our documentation:
|
|
22
22
|
${Rp.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
|
${Rp.PREDICTOR_USER_RELATED_OPERATION}`},Cd=(s,e)=>`The prediction '${s}' is invalid for market '${e}'. Please check again have you passed appropriate prediction model. For more information please visit our documentation: https://docs.fansunitedmedia.com/sdks/js/match.quiz#gamerelatedoperations`,Vo=s=>`The market '${s}' is not supported from Fans United. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,Ad=s=>`The market '${s}' is not valid for Top X game. The only available market is CORRECT_SCORE.`,xd=s=>`The field/s '${s.length>1?s.join(", "):s[0]}' is/are invalid. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/javascript-sdk`,Od=(s,e)=>`The following field/s is/are missing from ${s}: '${e.length>1?e.join(", "):e[0]}'. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,Bd=(s,e)=>`The field ${s} has incorrect type. The correct type is ${e}`;var It=class{footballHttps=null;idMapping=null;matchFacade=null;playerFacade=null;constructor(e,t){this.footballHttps=new wt(e),this.idMapping=t,this.matchFacade=new zt(e,this.footballHttps,t),this.playerFacade=new Qt(e,this.footballHttps,t)}remapMatchIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"match","native")).match;remapPlayerIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"player","native")).player[0];remapPlayerIdMapToNative=async e=>{let t={},n=Xt(e),p=(await this.idMapping.getEntityIdsBySchemaId(n,"player","native")).player;return n.forEach((d,h)=>t[d]=p[h]),t};remapPlayerIdToIdSchema=async e=>{let t=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"];for(let[n,o]of Object.entries(e))if(t.includes(n))for(let p of Object.keys(o)){let d={player:[p]},y=(await this.idMapping.idMappingFacade.getEntitiesByIds(d,"native",this.idMapping.idSchema)).player[0];o[y]=o[p],delete o[p]}return e};convertMarket=e=>{let t=Object.keys(new sr),n=Object.values(_e);for(let o=0;o<n.length;o++)e===n[o]&&(e=t[o]);return e};convertMarketForResponseModel=(e,t)=>{let n=t.toString();return e+"_"+n};getMarketSummary=(e,t,n)=>{let o=this.convertMarket(t),p={};if(p.matchId=e.matchId,p.matchType=e.matchType,Object.keys(e.predictions).includes(o))p[o]=e.predictions[o];else throw new Error("You have passed invalid market");return bt.includes(t)&&n?(p[o][n]||(p[o][n]=new j),p[o][n]):p};remapCompetitionsFromConfig=async e=>{if(e instanceof Vi){let t={competition:e.fullCoverageCompetitions},n={competition:e.successRateScopes.competitions},o={team:e.successRateScopes.teams},p=await this.idMapping.idMappingFacade.getEntitiesByIds(t,"native",this.idMapping.idSchema),d=await this.idMapping.idMappingFacade.getEntitiesByIds(n,"native",this.idMapping.idSchema),h=await this.idMapping.idMappingFacade.getEntitiesByIds(o,"native",this.idMapping.idSchema);return e.fullCoverageCompetitions=p.competition,e.successRateScopes.competitions=d.competition,e.successRateScopes.teams=h.team,e}if(e instanceof $i||e instanceof Hi){let t={competition:e.competitionsWhitelist},n=await this.idMapping.idMappingFacade.getEntitiesByIds(t,"native",this.idMapping.idSchema);return e.competitionsWhitelist=n.competition,e}};remapMatchIdsFixtures=async e=>{if(Array.isArray(e.data))if(e.data.length>0){let t=[],n=[];return e.data.forEach(o=>{o instanceof yi||o instanceof hi||o instanceof Nt?(o.fixtures.forEach(p=>t.push(p.matchId)),o instanceof Nt&&o.fixtures.forEach(p=>{p.prediction.playerId&&n.push(p.prediction.playerId)})):o instanceof gi&&o.results.forEach(p=>t.push(p.matchId))}),await this.refactorResponseArrModel(e,t,n)}else return e;else return await this.refactorResponseObjModel(e)};refactorResponseArrModel=async(e,t,n)=>{let o=[],p=await this.matchFacade.getMatchesMapWithNativeIds(t),d={};return n.length>0&&(d=await this.playerFacade.getPlayersMapWithNativeIds(n)),e.data.forEach(h=>{h instanceof yi||h instanceof hi||h instanceof Nt?(h.fixtures.forEach(y=>{y.matchModel=p[y.matchId],delete y.matchModel.availableMarkets,y.matchId=y.matchModel.id,h instanceof Nt&&y.prediction.playerId&&(y.prediction.playerModel=d[y.prediction.playerId],y.prediction.playerId=d[y.prediction.playerId].id)}),o.push(h)):h instanceof gi&&(h.results.forEach(y=>{y.matchModel=p[y.matchId],delete y.matchModel.availableMarkets,y.matchId=y.matchModel.id}),o.push(h))}),e.data=o,e};refactorResponseObjModel=async e=>{let t=[];e.fixtures.forEach(o=>t.push(o.matchId));let n=await this.matchFacade.getMatchesMapWithNativeIds(t);return e.fixtures.forEach(o=>{o.matchModel=n[o.matchId],delete o.matchModel.availableMarkets,o.matchId=n[o.matchId].id}),e};getCurrentGameId=e=>{let t=new Date;if(e.data.length>1){let n=[];return e.data.forEach(p=>n.push(p.predictionsCutoff)),e.data.sort((p,d)=>{let[h,y]=[p.predictionsCutoff,d.predictionsCutoff].map(I=>Math.abs(new Date(I)-t));return h-y})[0].id}else return e.data[0].id};initGameTypePredictions=(e,t)=>{let n={type:e,limit:null,startAfter:null};return t&&(n={...n,limit:t.limit,startAfter:t.startAfter}),n=new Re(n),n};initGameFilters=(e,t,n)=>{if(t&&n)return t.type=e,t.gameIds=n,t=new rt(t),t;if(t&&!n)return t.type=e,t=new rt(t),t;if(!t&&n){let o={type:e,gameIds:n};return o=new rt(o),o}else{let o={type:e};return o=new rt(o),o}};addPredictionProp=async(e,t)=>(t.data.forEach(n=>{e.data.forEach(o=>{n.id===o.game_instance_id&&(n.predictionId=o.id,n.outcome=o.status,n.fixtures.forEach((p,d)=>{o.fixtures[d].goals_home!==void 0&&o.fixtures[d].goals_away!==void 0?p.prediction.value=o.fixtures[d].goals_home+":"+o.fixtures[d].goals_away:p.prediction.value=o.fixtures[d].prediction,o.fixtures[d].player_id?p.prediction.playerId=o.fixtures[d].player_id:o.fixtures[d].target&&(p.prediction.target=o.fixtures[d].target),p.prediction.result=this.remapResult(o.fixtures[d].result)}),n.predictionsMadeAt=o.created_at,n.points=o.points)})}),t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,await this.remapMatchIdsFixtures(t));remapResult=e=>{let t=new nr;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t.points=e.points,t};areIdsExceeded=e=>{let t=10;return e.length>t};initPredictionsFilters=(e,t,n)=>{switch(t){case"user":e&&(e=new Re(e));break;case"current":if(e)this.deleteUnexpectedProperties(e),e.status=["ACTIVE"],e=new Re(e);else{let o={status:["ACTIVE"]};e=new Re(o)}break;case"past":if(e)this.deleteUnexpectedProperties(e),e.status=Tp,e=new Re(e);else{let o={status:Tp};e=new Re(o)}break;case"matches":if(e)this.deleteUnexpectedProperties(e),e.matchIds=n,e=new Re(e);else{let o={matchIds:n};e=new Re(o)}break}return e};completeGameMarketResults=async(e,t)=>{switch(t){case"MATCH_QUIZ":let n={},o=e.results[0].matchId,p=e.results.map(I=>bt.includes(I.market)?[...I.result]:[]).flat(),d=await this.matchFacade.getMatchesMapWithNativeIds([o]);return p.length&&(n=await this.playerFacade.getPlayersMapWithNativeIds(p)),e.results=e.results.map(I=>{if(I.matchModel=d[I.matchId],I.playerModels&&I.result.forEach(S=>{let q=n[S];I.playerModels.push(q)}),this.idMapping.idSchema!=="native"&&(I.matchId=d[I.matchId].id,I.playerModels)){let b=I.result;I.result=b.map(S=>n[S].id)}return I}),e;case"TOP_X":let h=e.results.map(I=>I.matchId),y=await this.matchFacade.getMatchesMapWithNativeIds(h);if(e.results=e.results.map(I=>(I.matchModel=y[I.matchId],this.idMapping.idSchema!=="native"&&(I.matchId=y[I.matchId].id),I)),e.tieBreakers.goldenGoals.length){let I=e.tieBreakers.goldenGoals.map(S=>S.playerId),b=await this.playerFacade.getPlayersMapWithNativeIds(I);e.tieBreakers.goldenGoals=e.tieBreakers.goldenGoals.map(S=>(S.matchModel=y[S.matchId],S.playerModel=b[S.playerId],this.idMapping.idSchema!=="native"&&(S.matchId=y[S.matchId].id,S.playerId=b[S.playerId].id),S))}return e}};deleteUnexpectedProperties=e=>(e.status&&(console.warn(Ep.UNEXPECTED_STATUS_PROP),delete e.status),e.type&&(console.warn(Ep.UNEXPECTED_TYPE_PROP),delete e.type),e)};var cr=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(e){this.gameInstanceId=e.gameInstanceId,e.fixtures.forEach(t=>this.fixtures.push(new Zt(t.matchId,t.market,t.prediction.value))),this.tiebreaker=e.tiebreaker?e.tiebreaker:null}};var ur=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t){this.footballHttps=new wt(e),this.matchFacade=new zt(e,this.footballHttps,t),this.playerFacade=new Qt(e,this.footballHttps,t),this.predictorService=new It(e,t),this.fixturesRemapper=new Ho(this.matchFacade,this.playerFacade,this.predictorService)}remapRequestBody=e=>{let t={};return t.game_instance_id=e.gameInstanceId,t.fixtures=e.fixtures.map(n=>this.fixturesRemapper.remapFixturesRequest(n)),e instanceof cr&&e.tiebreaker&&(t.tiebreaker={},t.tiebreaker.golden_goal=e.tiebreaker.goldenGoal?e.tiebreaker.goldenGoal:null),t};remapResponseArrayBody=async e=>{if(e.length){let t=[],n=[],o={},p=[];e.forEach(h=>{h.fixtures.forEach(y=>{t.push(y.match_id),y.player_id&&n.push(y.player_id)})});let d=await this.matchFacade.getMatchesMapWithNativeIds(t);return n.length>0&&(o=await this.playerFacade.getPlayersMapWithNativeIds(n)),e.forEach(h=>{let y=new tn,I=[];y.id=h.id,y.gameInstanceId=h.game_instance_id,y.gameType=h.game_type,y.wager=h.wager,y.totalFixtures=h.total_fixtures,y.settledFixtures=h.settled_fixtures,y.userId=h.user_id,h.fixtures.forEach(b=>{let S=new rr;b.target?S.market=this.predictorService.convertMarketForResponseModel(b.market,b.target):S.market=b.market,S.matchId=d[b.match_id].id,S.matchType=b.match_type,S.matchModel=d[b.match_id],delete S.matchModel.availableMarkets,b.goals_home!==void 0&&b.goals_away!==void 0?S.prediction.value=b.goals_home.toString()+":"+b.goals_away.toString():S.prediction.value=b.prediction,S.prediction.playerId=b.player_id?b.player_id:null,S.prediction.playerId&&(S.prediction.playerModel=o[S.prediction.playerId],S.prediction.playerId=o[S.prediction.playerId].id),S.result=this.fixturesRemapper.remapResult(b.result),I.push(S)}),y.fixtures=I,y.status=h.status,h.tiebreaker?y.tiebreaker.goldenGoal=h.tiebreaker.golden_goal:y.tiebreaker=null,y.points=h.points,y.createdAt=h.created_at,y.updatedAt=h.updated_at,p.push(y)}),p}return e};remapResponseObjBody=async e=>{let t=new tn;return t.id=e.id,t.gameInstanceId=e.game_instance_id,t.gameType=e.game_type,t.wager=e.wager,t.totalFixtures=e.total_fixtures,t.settledFixtures=e.settled_fixtures,t.userId=e.user_id,t.fixtures=await this.fixturesRemapper.remapFixturesResponse(e.fixtures),t.status=e.status,e.tiebreaker?t.tiebreaker.goldenGoal=e.tiebreaker.golden_goal:t.tiebreaker=null,t.points=e.points,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapPredictionModel=e=>{let t=new sr;return t.fullTimeOneXTwo=e.FT_1X2,t.halfTimeOneXTwo=e.HT_1X2,t.bothTeamsScore=e.BOTH_TEAMS_SCORE,t.overZeroPointFiveGoals=e.OVER_GOALS_0_5,t.overOnePointFiveGoals=e.OVER_GOALS_1_5,t.overTwoPointFiveGoals=e.OVER_GOALS_2_5,t.overThreePointFiveGoals=e.OVER_GOALS_3_5,t.overFourPointFiveGoals=e.OVER_GOALS_4_5,t.overFivePointFiveGoals=e.OVER_GOALS_5_5,t.overSixPointFiveGoals=e.OVER_GOALS_6_5,t.overSixPointFiveCorners=e.OVER_CORNERS_6_5,t.overSevenPointFiveCorners=e.OVER_CORNERS_7_5,t.overEightPointFiveCorners=e.OVER_CORNERS_8_5,t.overNinePointFiveCorners=e.OVER_CORNERS_9_5,t.overTenPointFiveCorners=e.OVER_CORNERS_10_5,t.overElevenPointFiveCorners=e.OVER_CORNERS_11_5,t.overTwelvePointFiveCorners=e.OVER_CORNERS_12_5,t.overThirteenPointFiveCorners=e.OVER_CORNERS_13_5,t.doubleChance=e.DOUBLE_CHANCE,t.halfTimeFullTime=e.HT_FT,t.playerScore=e.PLAYER_SCORE,t.playerYellowCard=e.PLAYER_YELLOW_CARD,t.playerRedCard=e.PLAYER_RED_CARD,t.redCardMatch=e.RED_CARD_MATCH,t.penaltyMatch=e.PENALTY_MATCH,t.playerScoreFirstGoal=e.PLAYER_SCORE_FIRST_GOAL,t.cornersMatch=e.CORNERS_MATCH,t.correctScore=e.CORRECT_SCORE,t.correctScoreHalfTime=e.CORRECT_SCORE_HT,t.correctScoreAdvanced=e.CORRECT_SCORE_ADVANCED,t.playerScoreHattrick=e.PLAYER_SCORE_HATTRICK,t.playerScoreTwice=e.PLAYER_SCORE_TWICE,t}};var qo=class{matchId=null;matchType=null;predictions=null};var Wo=class{remapPredictions=null;constructor(e,t){this.remapPredictions=new ur(e,t)}remapResponse=e=>{let t=new qo;return t.matchId=e.match_id,t.matchType=e.match_type,t.predictions=this.remapPredictions.remapPredictionModel(e.predictions),t}};var Ko=class{matchId=null;matchType=null;market=null;matchModel=null};var Xo=class{value=null;target=null;playerId=null;playerModel=null;result=null};var Yo=class{matchId=null;matchType=null;market=null;matchModel=null;prediction=new Xo};var Qo=class{value=null;result=null};var zo=class{matchId=null;matchType=null;market=null;matchModel=null;prediction=new Qo};var Jo=class{matchId=null;matchModel=null;outcome=null};var Zo=class{gameId=null;results=null;tieBreakers=null};var jo=class{remapPaginatedGames=e=>{let t=new re;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapGamesListResponse(n)),t};remapGamesListResponse=e=>{let t=new yi;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.scheduleOpenAt=e.schedule_open_at,t.predictionsCutoff=e.predictions_cutoff,t.fixtures=e.fixtures.map(n=>this.remapFixturesResponse(n)),t.tiebreaker=e.tiebreaker?this.remapTimeTiebreaker(e.tiebreaker.time_tiebreaker):null,t.rules=e.rules,t.flags=e.flags,t.images=e.images,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapFixturesResponse=e=>{let t=new Ko;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t};remapPaginatedUserTopXEditions=e=>{let t=new re;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapUserTopXEditionsResponse(n)),t};remapUserTopXEditionsResponse=e=>{let t=new hi;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.scheduleOpenAt=e.schedule_open_at,t.fixtures=e.fixtures.map(n=>this.remapTopXFixturesResponse(n)),t.tiebreaker=e.tiebreaker?this.remapTimeTiebreaker(e.tiebreaker.time_tiebreaker):null,t.rules=e.rules,t.flags=e.flags,t.images=e.images,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapTopXFixturesResponse=e=>{let t=new zo;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t};remapPaginatedUserMathQuizEditions=e=>{let t=new re;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapUserMatchQuizEditionsResponse(n)),t};remapUserMatchQuizEditionsResponse=e=>{let t=new Nt;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.scheduleOpenAt=e.schedule_open_at,t.fixtures=e.fixtures.map(n=>this.remapMatchQuizFixturesResponse(n)),t.tiebreaker=e.tiebreaker?this.remapTimeTiebreaker(e.tiebreaker.time_tiebreaker):null,t.rules=e.rules,t.flags=e.flags,t.images=e.images,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapMatchQuizFixturesResponse=e=>{let t=new Yo;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t};remapPaginatedGameResults=e=>{let t=new re;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(n=>this.remapGameResults(n)),t};remapGameResults=e=>{let t=new gi;return t.userId=e.user_id,t.points=e.points?e.points:0,t.results=e.results.map(n=>this.remapResults(n)),t.tiebreaker=e.tiebreaker?this.remapTiebreaker(e.tiebreaker):null,t};remapGameMarketsResults=e=>{let t=new Zo;return t.gameId=e.game_id,t.results=this.remapMarketsResults(e.results),t.tieBreakers=e.tie_breakers?this.remapTieBreakers(e.tie_breakers):null,t};remapTieBreakers=e=>{let t={goldenGoals:[]};return t.goldenGoals=e.golden_goals.map(n=>({minute:n.minute,matchId:n.match_id,matchModel:null,playerId:n.player_id,playerModel:null,goalType:n.goal_type})),t};remapMarketsResults=e=>{let t=[];return e.forEach(n=>{let o={matchId:n.match_id,market:n.market,result:this.remapMarketResult(n.market,n.result),matchModel:null,playerModels:[]};t.push(this.deleteUnusefulField(o))}),t};remapMarketResult=(e,t)=>{if(Ed.includes(e))return t[0];if(bt.includes(e))return t;if(t[0]==="true")return!0;if(t[0]==="false")return!1};deleteUnusefulField=e=>((!bt.includes(e.market)||this.isPlayerMarketWithNoResult(e.market,e.result))&&delete e.playerModels,e);isPlayerMarketWithNoResult=(e,t)=>bt.includes(e)&&t.length===0;remapResults=e=>{let t=new Jo;return t.matchId=e.match_id,t.outcome=e.outcome,t};remapTiebreaker=e=>{let t=new jt;return t.goldenGoal=e.golden_goal,t};remapTimeTiebreaker=e=>{let t=new vt;return t.timeTiebreaker=e,t}};var es=class{remapMetaData=e=>{let t=new Bi;return t.pagination.nextPageStartsAfter=e.pagination.next_page_starts_after,t.pagination.itemsPerPage=e.pagination.items_per_page,t}};var ei=class extends Me{apiSignInUrl=null;predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;metaRemapper=null;constructor(e,t){super(e,Oe(e.environment,"predictor"));this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.predictionRemapper=new ur(e,t),this.matchSummaryRemapper=new Wo(e,t),this.gamesRemapper=new jo,this.metaRemapper=new es}makeFootballPrediction=async e=>{try{let t=this.predictionRemapper.remapRequestBody(e),n=await this.instanceAuth.post(`/predictions${this.apiSignInUrl}`,JSON.stringify(t));return await this.predictionRemapper.remapResponseObjBody(n.data)}catch(t){throw console.warn("There was a problem making POST request: ",t),t.response}};getMatchSummary=async(e,t)=>{let n=de(t)?`/predictions/summary/${e}${this.apiSignInUrl}${fe()}`:`/predictions/summary/${e}${this.apiSignInUrl}`;try{let o=await this.instance.get(n);return this.matchSummaryRemapper.remapResponse(o.data)}catch(o){throw console.warn(`There was a problem fetching predictions for match: ${e} `,o),o.response}};deleteFootballPrediction=async e=>{try{return await this.instanceAuth.delete(`/predictions/${e}${this.apiSignInUrl}`),!0}catch(t){throw console.warn(`There was a problem deleting your prediction: ${e}`,t),t.response}};getMyPredictions=async e=>{try{let t=new re,n=`/predictions${this.apiSignInUrl}`;e&&(n+=`${e.constructFiltersUrl()}`);let o=await this.instanceAuth.get(n);return t.meta=this.metaRemapper.remapMetaData(o.data.meta),t.data=await this.predictionRemapper.remapResponseArrayBody(o.data.data),t}catch(t){throw console.warn("There was a problem fetching own predictions",t),t.response}};getMyPredictionsNoRemap=async e=>{try{return(await this.instanceAuth.get(`/predictions${this.apiSignInUrl}${e.constructFiltersUrl()}`)).data}catch(t){throw console.warn("There was a problem fetching own predictions",t),t.response}};getUserPredictions=async(e,t,n)=>{try{let o=new re,p=de(t)?`/predictions/users/${e}${this.apiSignInUrl}${fe()}`:`/predictions/users/${e}${this.apiSignInUrl}`;n&&(p+=`${n.constructFiltersUrl()}`);let d=await this.instance.get(p);return o.meta=this.metaRemapper.remapMetaData(d.data.meta),o.data=await this.predictionRemapper.remapResponseArrayBody(d.data.data),o}catch(o){throw console.warn(`There was a problem fetching predictions for user: ${e}`,o),o.response}};getUserPredictionsNoRemap=async(e,t)=>{try{return(await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}${t.constructFiltersUrl()}`)).data}catch(n){throw console.warn(`There was a problem fetching predictions for user: ${e}`,n),n.response}};getGames=async(e,t)=>{try{let n=de(t)?`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}${fe()}`:`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,o=await this.instance.get(n);return this.gamesRemapper.remapPaginatedGames(o.data)}catch(n){throw console.warn("There was a problem fetching the games list",n),n.response}};getGameById=async(e,t)=>{try{let n=de(t)?`/games/${e}${this.apiSignInUrl}${fe()}`:`/games/${e}${this.apiSignInUrl}`,o=await this.instance.get(n);return this.gamesRemapper.remapGamesListResponse(o.data)}catch(n){throw console.warn(`There was a problem fetching the following game: ${e}`,n),n.response}};getGamePredictions=async(e,t,n)=>{try{let o=new re,p=de(t)?`/games/${e}/predictions${this.apiSignInUrl}${fe()}`:`/games/${e}/predictions${this.apiSignInUrl}`;n&&(p+=`${n.constructFiltersUrl()}`);let d=await this.instance.get(p);return o.meta=this.metaRemapper.remapMetaData(d.data.meta),o.data=await this.predictionRemapper.remapResponseArrayBody(d.data.data),o}catch(o){throw console.warn(`There was a problem fetching the predictions for game: ${e}`,o),o.response}};getUserGameEditions=async(e,t)=>{try{let n=null,o=de(t)?`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}${fe()}`:`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,p=await this.instance.get(o);return p.data.data.forEach(d=>{d.type==="TOP_X"?n=this.gamesRemapper.remapPaginatedUserTopXEditions(p.data):d.type==="MATCH_QUIZ"&&(n=this.gamesRemapper.remapPaginatedUserMathQuizEditions(p.data))}),n}catch(n){throw console.warn("There was a problem fetching the games list",n),n.response}};getGameResults=async(e,t,n)=>{try{let o=de(t)?`/games/${e}/results/${this.apiSignInUrl}${fe()}`:`/games/${e}/results/${this.apiSignInUrl}`;n&&(o+=`${n.constructMainFiltersUrl()}`);let p=await this.instance.get(o);return this.gamesRemapper.remapPaginatedGameResults(p.data)}catch(o){throw console.warn(`There was a problem fetching the results for the following game: ${e}`,o),o.response}};getMarketResultsForGame=async(e,t)=>{let n=`/games/${e}/correct-results/${this.apiSignInUrl}`;de(t)&&(n+=`${fe()}`);try{let o=await this.instance.get(n);return this.gamesRemapper.remapGameMarketsResults(o.data.data)}catch(o){throw console.warn(`There was a problem fetching the markets correct results for the following game: ${e}`,o),o.response}}};var mr=class{gameInstanceId=null;fixtures=null};var ne=class extends Error{code=0;status=null;message=null;constructor(e,t,n){super();this.code=e,this.status=t,this.message=n}errorMessage=()=>this.message};var Cp=(n=>(n.ONE="1",n.X="x",n.TWO="2",n))(Cp||{}),Ap=(n=>(n.ONE_X="1x",n.X_TWO="x2",n.ONE_TWO="12",n))(Ap||{}),xp=(I=>(I.ONE_ONE="1/1",I.ONE_X="1/x",I.ONE_TWO="1/2",I.X_ONE="x/1",I.X_X="x/x",I.X_TWO="x/2",I.TWO_ONE="2/1",I.TWO_X="2/x",I.TWO_TWO="2/2",I))(xp||{});var ts=class{matchId=null;market="BOTH_TEAMS_SCORE";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new it,this.prediction.value=t}};var is=class{value};var rs=class{matchId=null;market="CORNERS_MATCH";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new is,this.prediction.value=t}};var ns=class{value=null};var as=class{matchId=null;market="DOUBLE_CHANCE";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new ns,this.prediction.value=t}};var os=class{value=null};var ss=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(e,t,n){this.matchId=e,this.market=t,this.prediction=new os,this.prediction.value=n}};var ls=class{value=null};var ps=class{matchId=null;market="HT_FT";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new ls,this.prediction.value=t}};var cs=class{matchId=null;market="PENALTY_MATCH";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new it,this.prediction.value=t}};var us=class{matchId=null;market="RED_CARD_MATCH";matchType="FOOTBALL";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new it,this.prediction.value=t}};var ti=class{validateBodyFields=(e,t)=>{let n=Object.keys(t),o=Object.keys(new mr);switch(e){case"MATCH_QUIZ":n.forEach(y=>{o.includes(y)||this.throwInvalidParamException([y])});break;case"TOP_X":let d=t;d.fixtures.forEach(y=>this.validateMarketTopX(y.market));let h="tiebreaker";n.includes(h)&&d.tiebreaker&&this.validateTiebreaker(d.tiebreaker),n.forEach(y=>{y!=="tiebreaker"&&!o.includes(y)&&this.throwInvalidParamException([y])});break}let p=o.filter(d=>!n.includes(d));return p.length&&this.throwMissingFieldsException("game prediction body",p),t.fixtures.forEach(d=>{this.validateFixtureFields(d)}),t};validateFixture=(e,t,n,o)=>{this.validateMarket(t);let p=Object.values(Cp),d=Object.values(xp),h=Object.values(Ap);if(t==="FT_1X2"||t==="HT_1X2"){if(p.includes(n))return new ss(e,t,n)}else if(t==="HT_FT"){if(d.includes(n))return new ps(e,n)}else if(t==="DOUBLE_CHANCE"){if(h.includes(n))return new as(e,n)}else if(t==="CORRECT_SCORE"||t==="CORRECT_SCORE_ADVANCED"||t==="CORRECT_SCORE_HT"){if(typeof n=="string"&&/\d+:\d+/.test(n))return new Zt(e,t,n)}else if(t==="CORNERS_MATCH"){if(typeof n=="number")return new rs(e,n)}else if(t==="BOTH_TEAMS_SCORE"){if(this.isPredictionBoolean(n))return new ts(e,n)}else if(t==="RED_CARD_MATCH"){if(this.isPredictionBoolean(n))return new us(e,n)}else if(t==="PENALTY_MATCH"){if(this.isPredictionBoolean(n))return new cs(e,n)}else if(bt.includes(t)){if(this.validatePlayerId(t,o),t===Zr&&this.isPredictionBoolean(n))return new tt(e,t,n,o);if(o&&this.isPredictionBoolean(n))return new tt(e,t,n,o)}else if(Sd.includes(t)){if(this.isPredictionBoolean(n))return new or(e,t,n)}else if(Td.includes(t)&&this.isPredictionBoolean(n))return new ar(e,t,n);this.throwInvalidPredictionException(n,t)};validateFixtureFields=e=>{let t=Object.keys(e);t.forEach(o=>{Fp.includes(o)||this.throwInvalidParamException([o])});let n=Fp.filter(o=>{if(o!=="matchType"&&!t.includes(o))return o});n.length&&this.throwMissingFieldsException("fixtures",n),this.validatePredictionKey(e.market,e.prediction)};validateTiebreaker=e=>{let t=Object.keys(e);(!t.length||typeof e!="object")&&this.throwInvalidType("tiebreaker","object");let n=Object.keys(new jt)[0];t.forEach(o=>{n!==o&&this.throwInvalidParamException([o])}),t.includes(n)||this.throwMissingFieldsException("tiebreaker",[n]),typeof e.goldenGoal!="number"&&this.throwInvalidType("goldenGoal","number")};validatePredictionKey=(e,t)=>{if(typeof t=="object"){let n=Object.keys(t),o=["value"];if(n.length||this.throwMissingFieldsException("prediction",o),n.length===1&&!n.includes(o[0])&&this.throwInvalidParamException(n),n.length>1){bt.includes(e)&&o.push("playerId");let p=n.filter(d=>!o.includes(d));p.length&&this.throwInvalidParamException(p)}}else this.throwInvalidType("prediction","object")};validatePlayerId=(e,t)=>{let n="playerId";e!==Zr&&(t||this.throwInvalidParamException([n]),typeof t!="string"&&this.throwInvalidType(n,"string"))};validateMarket=e=>{Object.values(_e).includes(e)||this.throwInvalidMarketException(e)};validateMarketTopX=e=>{e!=="CORRECT_SCORE"&&e!=="CORRECT_SCORE_ADVANCED"&&this.throwInvalidMarketException(e,"TOP_X")};isPredictionBoolean=e=>typeof e=="boolean";throwInvalidPredictionException=(e,t)=>{let n=Cd(e,t);throw new ne(400,"INVALID_PREDICTION",n)};throwInvalidMarketException=(e,t)=>{let n=null;throw t&&t==="TOP_X"?n=Ad(e):n=Vo(e),new ne(400,"INVALID_MARKET",n)};throwInvalidParamException=e=>{let t=xd(e);throw new ne(400,"INVALID_FIELD",t)};throwMissingFieldsException=(e,t)=>{let n=Od(e,t);throw new ne(400,"INVALID_FIELD",n)};throwInvalidType=(e,t)=>{let n=Bd(e,t);throw new ne(400,"INVALID_TYPE",n)}};var ds=class{predictorHttps=null;clientHttps=null;idMapping=null;predictorService=null;predictorValidator=null;constructor(e,t,n,o){this.predictorHttps=t,this.idMapping=o,this.clientHttps=n,this.predictorValidator=new ti,this.predictorService=new It(e,o)}makeFootballPrediction=async(e,t,n,o)=>{let p=this.predictorValidator.validateFixture(e,t,n,o),d=new mr;if(this.idMapping.idSchema!=="native"){let h=p.matchId,y="",I=await this.predictorService.remapMatchIdToNative([h]);if(p.matchId=I[0],!p.matchId)throw new ne(400,"INVALID_FIELD","Match id is invalid!").errorMessage();if(p instanceof tt&&(y=p.prediction.playerId,p.prediction.playerId=y&&await this.predictorService.remapPlayerIdToNative([y]),p.market!==Zr&&!p.prediction.playerId))throw new ne(400,"INVALID_FIELD","Player id is invalid!").errorMessage();d.fixtures=[p];let b=await this.predictorHttps.makeFootballPrediction(d);return b.fixtures.map(S=>{S.prediction.playerId&&(S.prediction.playerId=y),S.matchId=h}),b}else return d.fixtures=[p],await this.predictorHttps.makeFootballPrediction(d)};getMatchSummary=async(e,t)=>{if(this.idMapping.idSchema!=="native"){let o=(await this.predictorService.remapMatchIdToNative([e]))[0],p=await this.predictorHttps.getMatchSummary(o,t);p.matchId=e;let d=p.predictions,h=await this.predictorService.remapPlayerIdToIdSchema(d);return p.predictions=h,p}else return await this.predictorHttps.getMatchSummary(e,t)};getMarketSummary=async(e,t,n,o)=>{try{let p=await this.getMatchSummary(e,o);return this.predictorService.getMarketSummary(p,t,n)}catch(p){return p.message}};getConfig=async()=>{let e=await this.clientHttps.getConfig("predictor");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(e):e};deleteFootballPrediction=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyPredictions=async e=>{let t=this.predictorService.initPredictionsFilters(e,"user");return await this.predictorHttps.getMyPredictions(t)};getMyPredictionsForMatches=async(e,t)=>{if(this.predictorService.areIdsExceeded(e))throw new ne(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();this.idMapping.idSchema!=="native"&&(e=await this.predictorService.remapMatchIdToNative([...e]));let n=this.predictorService.initPredictionsFilters(t,"matches",e);return await this.predictorHttps.getMyPredictions(n)};getMyCurrentPredictions=async e=>{let t=this.predictorService.initPredictionsFilters(e,"current");return await this.predictorHttps.getMyPredictions(t)};getMyPastPredictions=async e=>{let t=this.predictorService.initPredictionsFilters(e,"past");return await this.predictorHttps.getMyPredictions(t)};getUserPredictions=async(e,t,n)=>{let o=this.predictorService.initPredictionsFilters(t,"user");return await this.predictorHttps.getUserPredictions(e,n,o)};getUserCurrentPredictions=async(e,t,n)=>{let o=this.predictorService.initPredictionsFilters(t,"current");return await this.predictorHttps.getUserPredictions(e,n,o)};getUserPastPredictions=async(e,t,n)=>{let o=this.predictorService.initPredictionsFilters(t,"past");return await this.predictorHttps.getUserPredictions(e,n,o)};getUserPredictionsForMatches=async(e,t,n,o)=>{if(this.predictorService.areIdsExceeded(t))throw new ne(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();this.idMapping.idSchema!=="native"&&(t=await this.predictorService.remapMatchIdToNative([...t]));let p=this.predictorService.initPredictionsFilters(n,"matches",t);return await this.predictorHttps.getUserPredictions(e,o,p)}};var fs=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(e){this.idMapping=new ae(e),this.predictorHttps=new ei(e,this.idMapping),this.clientHttps=new et(e),this.predictorFacade=new ds(e,this.predictorHttps,this.clientHttps,this.idMapping)}makeFootballPrediction=async(e,t,n,o)=>await this.predictorFacade.makeFootballPrediction(e,t,n,o);getMatchSummary=async(e,t)=>await this.predictorFacade.getMatchSummary(e,t);getMarketSummary=async(e,t,n,o)=>await this.predictorFacade.getMarketSummary(e,t,n,o);getConfig=async()=>await this.predictorFacade.getConfig();deleteFootballPrediction=async e=>await this.predictorFacade.deleteFootballPrediction(e);getMyPredictions=async e=>await this.predictorFacade.getMyPredictions(e);getMyCurrentPredictions=async e=>await this.predictorFacade.getMyCurrentPredictions(e);getMyPastPredictions=async e=>await this.predictorFacade.getMyPastPredictions(e);getMyPredictionsForMatches=async(e,t)=>await this.predictorFacade.getMyPredictionsForMatches(e,t);getUserPredictions=async(e,t,n)=>await this.predictorFacade.getUserPredictions(e,t,n);getUserCurrentPredictions=async(e,t,n)=>await this.predictorFacade.getUserCurrentPredictions(e,t,n);getUserPastPredictions=async(e,t,n)=>await this.predictorFacade.getUserPastPredictions(e,t,n);getUserPredictionsForMatches=async(e,t,n,o)=>await this.predictorFacade.getUserPredictionsForMatches(e,t,n,o)};var hs=class{rankType=null;fromDate=null;toDate=null;pagination=new Qi};var dr=class{position=null;profileId=null;profileModel=null;points=null;predictionsMade=null};var gs=class{remapResponse=e=>(e.meta=this.remapMeta(e.meta),e.data=this.remapData(e.data),e);remapMeta=e=>{let t=new hs;return t.rankType=e.rank_type,t.fromDate=e.from_date,t.toDate=e.to_date,t.pagination.currentPage=e.pagination.current_page,t.pagination.itemsPerPage=e.pagination.items_per_page,t.pagination.totalItems=e.pagination.total_items,t.pagination.numberOfPages=e.pagination.number_of_pages,t};remapData=e=>{let t=[];return e.forEach(n=>{let o=new dr;o.position=n.position,o.profileId=n.profile_id,o.points=n.points,o.predictionsMade=n.predictions_made,t.push(o)}),t}};var ys=class extends dr{id=null;rankType=null;model=null;gameType=null};var Ms=class{remapRankings=e=>(e.meta=this.remapMeta(e.meta),e.data=this.remapData(e.data),e);remapMeta=e=>{let t=new Jt;return t.pagination.currentPage=e.pagination.current_page,t.pagination.itemsPerPage=e.pagination.items_per_page,t.pagination.numberOfPages=e.pagination.number_of_pages,t.pagination.totalItems=e.pagination.total_items,t};remapData(e){let t=[];return e.forEach(n=>{let o=new ys;o.id=n.id,o.rankType=n.rank_type,o.position=n.position,o.points=n.points,o.gameType=n.game_type,delete o.profileId,delete o.profileModel,delete o.predictionsMade,t.push(o)}),t}};var ws=class{id=null;name=null;description=null;type=null;fromDate=null;toDate=null;markets=[];teamIds=[];matchIds=[];gameIds=[];gameTypes=[];competitionIds=[];rules=null;flags=null;images=new pr;status=null;automaticallyChangeStatus=!0};var bs=class{remapResponse=e=>{let t=[];return e.forEach(n=>{let o=new ws;o.id=n.id,o.name=n.name,o.description=n.description,o.type=n.type,o.fromDate=n.from_date,o.toDate=n.to_date,o.markets=n.markets?n.markets:null,o.teamIds=n.team_ids?n.team_ids:null,o.matchIds=n.match_ids?n.match_ids:null,o.gameIds=n.game_ids?n.game_ids:null,o.gameTypes=n.game_types?n.game_types:null,o.competitionIds=n.competition_ids?n.competition_ids:null,o.rules=n.rules?n.rules:null,o.flags=n.flags?n.flags:null,o.images=n.images?n.images:null,o.status=n.status?n.status:null,o.automaticallyChangeStatus=n.automatically_change_status,t.push(o)}),t};remapMeta=e=>{let t={};return t.totalItems=e.pagination.total_items,t}};var vs=class{position=null;points=null;predictionsMade=null;profileId=null;profileModel=null;successRatePercent=null};var Is=class{remapHighestSuccessRate=e=>e.map(t=>{let n=new vs;return n.position=t.position,n.points=t.points,n.predictionsMade=t.predictions_made,n.profileId=t.profile_id,n.successRatePercent=t.success_rate_percent,n})};var Ps=class extends Me{apiSignInUrl=null;templateRemapper=null;leaderboardRemapper=null;rankingsRemapper=null;highestSuccessRateRemapper=null;constructor(e){super(e,Oe(e.environment,"loyalty"));this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.templateRemapper=new bs,this.leaderboardRemapper=new gs,this.rankingsRemapper=new Ms,this.highestSuccessRateRemapper=new Is}getTemplates=async(e,t)=>{try{let n=de(e)?`/leaderboard/templates/${this.apiSignInUrl}${fe()}`:`/leaderboard/templates/${this.apiSignInUrl}`,o=await this.instance.get(n);if(t){let p=JSON.parse(JSON.stringify(o.data));return p.meta=this.templateRemapper.remapMeta(o.data.meta),p.data=this.templateRemapper.remapResponse(o.data.data),p}return this.templateRemapper.remapResponse(o.data.data)}catch(n){throw console.warn("There was a problem fetching the list of templates",n),n.response}};getLeaderboard=async(e,t,n)=>{try{let o=de(t)?`/leaderboard/${e}/${this.apiSignInUrl}${fe()}`:`/leaderboard/${e}/${this.apiSignInUrl}`;n&&(o+=`${n.constructFiltersUrl()}`);let p=await this.instance.get(o),d=JSON.parse(JSON.stringify(p.data));return this.leaderboardRemapper.remapResponse(d)}catch(o){throw console.warn(`There was a problem fetching the leaderboard for the following template: ${e}`,o),o.response}};getLeaderboardForGame=async(e,t,n)=>{try{let o=de(t)?`/leaderboard/games/${e}/${this.apiSignInUrl}${fe()}`:`/leaderboard/games/${e}/${this.apiSignInUrl}`;n&&(o+=`${n.constructFiltersUrl()}`);let p=await this.instance.get(o),d=JSON.parse(JSON.stringify(p.data));return ta(d)}catch(o){throw console.warn(`There was a problem fetching the leaderboard for the following game: ${e}`,o),o.response}};getUserRankings=async(e,t,n)=>{let o=`/leaderboard/users/${e}/rankings/${this.apiSignInUrl}`;t&&(o+=`${t.constructFiltersUrl()}`),de(n)&&(o+=`${fe()}`);try{let p=await this.instance.get(o);return this.rankingsRemapper.remapRankings(p.data)}catch(p){throw console.warn(`There was a problem fetching the rankings for the following user: ${e}`,p),p.response}};getHighestSuccessRate=async(e,t)=>{let n=de(t)?`/statistics/top${this.apiSignInUrl}${fe()}`:`/statistics/top${this.apiSignInUrl}`;e&&(n+=`&market=${e}`);try{let o=await this.instance.get(n);return this.highestSuccessRateRemapper.remapHighestSuccessRate(o.data.data)}catch(o){throw console.warn("There was a problem fetching highest success rate",o),o.response}}};var _s=class{general;predictor;topX;matchQuiz};var fr=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 Rs=class extends fr{sortOrder=null;rankType=null;leaderboardIds=null;gameType=null;constructor(e){super(e);this.sortOrder=e.sortOrder,this.rankType=e.rankType,this.leaderboardIds=e.leaderboardIds,this.gameType=e.type&&e.type.toLowerCase()==="game"?e.gameType:null}constructFiltersUrl=()=>{let e=super.constructFiltersUrl();return this.sortOrder&&(e+="&",e+=`sort_order=${this.sortOrder}`),this.rankType&&(e+="&",e+=`rank_type=${this.rankType}`),this.leaderboardIds&&(e+="&",e+=`type_ids=${this.leaderboardIds.join(",")}`),this.gameType&&(e+="&",e+=`game_type=${this.gameType}`),e}};var Fs=class{idMappingService=null;profileNamespace=null;constructor(e){this.idMappingService=new ae(e),this.profileNamespace=new er(e)}remapTemplatesIds=async e=>{if(e.length>0){let t=[],n=[],o=[],p=[],d=[],h=[];e.forEach(b=>{b.teamIds&&b.teamIds.length>0?t=[...t,...b.teamIds]:b.matchIds&&b.matchIds.length>0?o=[...o,...b.matchIds]:b.competitionIds&&b.competitionIds.length>0&&(d=[...d,...b.competitionIds])});let y={team:t,match:o,competition:d},I=await this.idMappingService.idMappingFacade.getEntitiesByIds(y,"native",this.idMappingService.idSchema);return n=[...I.team],p=[...I.match],h=[...I.competition],e.forEach(b=>{b.teamIds&&b.teamIds.length>0?b.teamIds=b.teamIds.map(S=>S=I.team.shift()):b.matchIds&&b.matchIds.length>0?b.matchIds=b.matchIds.map(S=>S=I.match.shift()):b.competitionIds&&b.competitionIds.length>0&&(b.competitionIds=b.competitionIds.map(S=>S=I.competition.shift()))}),e}return e};addProfileModelToLeaderboad=async e=>{if(e.length>0){let t=[],n=[];e.forEach(p=>{t.push(p.profileId)});let o=await this.profileNamespace.getByIds(t);return e.forEach(p=>{o.forEach(d=>{d.id===p.profileId&&(delete d.interests,p.profileModel=d)}),p.profileModel||(p.profileModel=null),n.push(p)}),n}return e};buildClientBadges=e=>{let t=new _s;return t.general=this.extractEnabledBadgesId(e.general),t.predictor=this.extractEnabledBadgesId(e.predictor),t.topX=this.extractEnabledBadgesId(e.topX),t.matchQuiz=this.extractEnabledBadgesId(e.matchQuiz),t};initFilters=(e,t)=>{switch(t){case"loyalty":e&&(e=new fr(e));break;case"rankings":e&&(e=new Rs(e));break}return e};addProfileModelToHighestSuccessRate=async e=>{let t=e.map(o=>o.profileId),n=await this.profileNamespace.getByIds(t);return e.map(o=>(n.forEach(p=>{p.id===o.profileId&&(delete p.interests,o.profileModel=p)}),o))};extractRankingsIdsMap=e=>{let t=[],n=[],o=[];return e.forEach(p=>{p.rankType==="GAME"&&p.gameType==="TOP_X"?t.push(p.id):p.rankType==="GAME"&&p.gameType==="MATCH_QUIZ"?n.push(p.id):p.rankType==="TEMPLATE"&&o.push(p.id)}),[t,n,o]};setModelsForUserRankings=(e,t,n,o)=>(o.data.forEach(p=>{p.gameType==="MATCH_QUIZ"&&t?p.model=t.filter(d=>d.id===p.id)[0]:p.gameType==="TOP_X"&&e?p.model=e.filter(d=>d.id===p.id)[0]:p.rankType==="TEMPLATE"&&n&&(p.model=n.filter(d=>d.id===p.id)[0])}),o);extractEnabledBadgesId=e=>{let t=[];return e.forEach(n=>{n.enabled&&t.push(n.id)}),t}};var Ss=class{validateMarket=e=>{if(!Object.keys(_e).includes(e)){let n=Vo(e);throw new ne(400,"INVALID_MARKET",n)}}};var hr=class{idMapping=null;predictorHttps=null;predictorService=null;predictorValidator=null;clientHttps=null;constructor(e,t){this.idMapping=t,this.predictorValidator=new ti,this.predictorHttps=new ei(e,t),this.predictorService=new It(e,t),this.clientHttps=new et(e)}getConfig=async()=>{let e=await this.clientHttps.getConfig("topX");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(e):e};getGames=async(e,t)=>{t=t||!1;let n=this.predictorService.initGameFilters("TOP_X",e),o=await this.predictorHttps.getGames(n,t);return await this.predictorService.remapMatchIdsFixtures(o)};getGameById=async(e,t)=>{t=t||!1;let n=await this.predictorHttps.getGameById(e,t);return await this.predictorService.remapMatchIdsFixtures(n)};getGamePredictions=async(e,t,n)=>(n=n||!1,t&&(t.type&&delete t.type,t.status&&delete t.status,t=new Re(t)),await this.predictorHttps.getGamePredictions(e,n,t));getGameResults=async(e,t,n)=>{n=n||!1,t&&(t=new rt(t));let o=await this.predictorHttps.getGameResults(e,n,t);return await this.predictorService.remapMatchIdsFixtures(o)};getCurrentGameResults=async e=>{e=e||!1;let t={status:"OPEN",type:"TOP_X"};t=new rt(t);let n=await this.predictorHttps.getGames(t,e),o=this.predictorService.getCurrentGameId(n);return(await this.getGameResults(o,null,e)).data[0]};play=async e=>{let t=new cr(e);if(t=this.predictorValidator.validateBodyFields("TOP_X",t),t.fixtures=t.fixtures.map(o=>this.predictorValidator.validateFixture(o.matchId,o.market,o.prediction.value)),this.idMapping.idSchema!=="native"){let o=[];t.fixtures.forEach(d=>o.push(d.matchId));let p=await this.predictorService.remapMatchIdToNative(o);t.fixtures.forEach(d=>d.matchId=p.shift())}let n=await this.predictorHttps.makeFootballPrediction(t);return n.fixtures.forEach(o=>{o.matchId=o.matchModel.id}),n};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyGameEditions=async(e,t)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),t=t||!1;let n=this.predictorService.initGameTypePredictions("TOP_X",e),o=[],p=await this.predictorHttps.getMyPredictionsNoRemap(n);if(p.data.length>0){p.data.forEach(y=>{y.game_instance_id&&o.push(y.game_instance_id)});let d=this.predictorService.initGameFilters("TOP_X",null,o),h=await this.predictorHttps.getUserGameEditions(d,t);return await this.predictorService.addPredictionProp(p,h)}else return new re};getMyGamePrediction=async e=>{let t=this.predictorService.initGameTypePredictions("TOP_X"),n=await this.predictorHttps.getMyPredictions(t);if(n.data.length>0){let o=n.data.filter(p=>p.gameInstanceId===e);return o.length?o[0]:null}return null};getUserGameEditions=async(e,t,n)=>{t&&t.limit&&this.validateLimitFilterOnGames(t.limit),n=n||!1;let o=this.predictorService.initGameTypePredictions("TOP_X",t),p=[],d=await this.predictorHttps.getUserPredictionsNoRemap(e,o);if(d.data.length>0){d.data.forEach(I=>{I.game_instance_id&&p.push(I.game_instance_id)});let h=this.predictorService.initGameFilters("TOP_X",null,p),y=await this.predictorHttps.getUserGameEditions(h,n);return await this.predictorService.addPredictionProp(d,y)}else return new re};getUserGamePrediction=async(e,t,n)=>{n=n||!1;let o=this.predictorService.initGameTypePredictions("TOP_X"),p=await this.predictorHttps.getUserPredictions(e,n,o);if(p.data.length>0){let d=p.data.filter(h=>h.gameInstanceId===t);return d.length?d[0]:null}else return null};getMarketsResultsForGame=async(e,t)=>{let n=await this.predictorHttps.getMarketResultsForGame(e,t);return await this.predictorService.completeGameMarketResults(n,"TOP_X")};validateLimitFilterOnGames=e=>{if(e>50)throw new ne(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.")}};var gr=class{predictorHttps=null;predictorService=null;idMapping=null;clientHttps=null;predictorValidator=null;constructor(e){this.predictorValidator=new ti,this.idMapping=new ae(e),this.predictorHttps=new ei(e,this.idMapping),this.predictorService=new It(e,this.idMapping),this.clientHttps=new et(e)}getConfig=async()=>{let e=await this.clientHttps.getConfig("matchQuiz");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(e):e};play=async e=>{e=this.predictorValidator.validateBodyFields("MATCH_QUIZ",e);let t=e.fixtures.map(n=>this.predictorValidator.validateFixture(n.matchId,n.market,n.prediction.value,n.prediction.playerId));if(t&&t.length&&this.idMapping.idSchema!=="native"){let n=[],o=[];t.forEach(h=>{n.push(h.matchId),h instanceof tt&&h.prediction.playerId&&o.push(h.prediction.playerId)});let p=await this.predictorService.remapMatchIdToNative(n),d={};o&&o.length>0&&(d=await this.predictorService.remapPlayerIdMapToNative(o)),t.forEach((h,y)=>{h.matchId=p[y],h instanceof tt&&(h.prediction.playerId=d[h.prediction.playerId])})}return e.fixtures=t,await this.predictorHttps.makeFootballPrediction(e)};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getGames=async(e,t)=>{t=t||!1;let n=this.predictorService.initGameFilters("MATCH_QUIZ",e),o=await this.predictorHttps.getGames(n,t);return await this.predictorService.remapMatchIdsFixtures(o)};getGameById=async(e,t)=>{t=t||!1;let n=await this.predictorHttps.getGameById(e,t);return await this.predictorService.remapMatchIdsFixtures(n)};getGamePredictions=async(e,t,n)=>(n=n||!1,t&&(t.type&&delete t.type,t.status&&delete t.status,t=new Re(t)),await this.predictorHttps.getGamePredictions(e,n,t));getGameResults=async(e,t,n)=>{n=n||!1,t&&(t=new lr(t));let o=await this.predictorHttps.getGameResults(e,n,t);return await this.predictorService.remapMatchIdsFixtures(o)};getCurrentGameResults=async e=>{e=e||!1;let t={status:"OPEN",type:"MATCH_QUIZ"};t=new rt(t);let n=await this.predictorHttps.getGames(t,e),o=this.predictorService.getCurrentGameId(n);return(await this.getGameResults(o,null,e)).data[0]};getMyGameEditions=async(e,t)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),t=t||!1;let n=this.predictorService.initGameTypePredictions("MATCH_QUIZ",e),o=[],p=await this.predictorHttps.getMyPredictionsNoRemap(n);if(p.data.length>0){p.data.forEach(y=>{y.game_instance_id&&o.push(y.game_instance_id)});let d=this.predictorService.initGameFilters("MATCH_QUIZ",null,o),h=await this.predictorHttps.getUserGameEditions(d,t);return await this.predictorService.addPredictionProp(p,h)}else return new re};getMyGamePrediction=async e=>{let t=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),n=await this.predictorHttps.getMyPredictions(t);if(n.data.length>0){let o=n.data.filter(p=>p.gameInstanceId===e);return o.length?o[0]:null}return null};getUserGameEditions=async(e,t,n)=>{t&&t.limit&&this.validateLimitFilterOnGames(t.limit),n=n||!1;let o=this.predictorService.initGameTypePredictions("MATCH_QUIZ",t),p=[],d=await this.predictorHttps.getUserPredictionsNoRemap(e,o);if(d.data.length>0){d.data.forEach(I=>{I.game_instance_id&&p.push(I.game_instance_id)});let h=this.predictorService.initGameFilters("MATCH_QUIZ",null,p),y=await this.predictorHttps.getUserGameEditions(h,n);return await this.predictorService.addPredictionProp(d,y)}else return new re};getUserGamePrediction=async(e,t,n)=>{n=n||!1;let o=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),p=await this.predictorHttps.getUserPredictions(e,n,o);if(p.data.length>0){let d=p.data.filter(h=>h.gameInstanceId===t);return d.length?d[0]:null}else return null};getMarketsResultsForGame=async(e,t)=>{let n=await this.predictorHttps.getMarketResultsForGame(e,t);return await this.predictorService.completeGameMarketResults(n,"MATCH_QUIZ")};validateLimitFilterOnGames=e=>{if(e>50)throw new ne(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.")}};var Ts=class{config=null;clientHttps=null;loyaltyHttps=null;loyaltyService=null;profileFacade=null;loyaltyValidator=null;idMapping=null;topXFacade=null;matchQuizFacade=null;constructor(e,t,n,o,p){this.config=e,this.clientHttps=t,this.loyaltyHttps=n,this.profileFacade=new Mt(p,o),this.loyaltyService=new Fs(this.config),this.loyaltyValidator=new Ss,this.idMapping=new ae(e),this.topXFacade=new hr(e,this.idMapping),this.matchQuizFacade=new gr(e)}getConfig=async()=>await this.clientHttps.getConfig("loyalty");getClientBadges=async()=>{let e=await this.getConfig();return this.loyaltyService.buildClientBadges(e.rewards.badges)};getTemplates=async e=>{let t=!0;if(this.config.idSchema==="native")return await this.loyaltyHttps.getTemplates(e,t);let n=await this.loyaltyHttps.getTemplates(e,t);return n.data=await this.loyaltyService.remapTemplatesIds([...n.data]),n};getTemplateById=async(e,t)=>{try{let n=!1,p=(await this.loyaltyHttps.getTemplates(t,n)).filter(h=>h.id===e);if(!p.length)throw new ne(400,"INVALID_TEMPLATE","Provided template ID does NOT exist! Try again with existing template ID.").errorMessage();return this.config.idSchema==="native"?p[0]:(await this.loyaltyService.remapTemplatesIds(p))[0]}catch(n){throw console.warn("There was a problem retrieving specified template: ",n),n}};getLeaderboard=async(e,t,n)=>{t=this.loyaltyService.initFilters(t,"loyalty");let o=await this.loyaltyHttps.getLeaderboard(e,n,t);return o.data=await this.loyaltyService.addProfileModelToLeaderboad(o.data),o};getLeaderboardForGame=async(e,t,n)=>{t=this.loyaltyService.initFilters(t,"loyalty");let o=await this.loyaltyHttps.getLeaderboardForGame(e,n,t);return o.data=await this.loyaltyService.addProfileModelToLeaderboad(o.data),o};getOwnRankings=async(e,t)=>{let{id:n}=await this.profileFacade.getOwn();return this.getUserRankings(n,e,t)};getUserRankings=async(e,t,n)=>{t=this.loyaltyService.initFilters(t,"rankings");let o=await this.loyaltyHttps.getUserRankings(e,t,n);return await this.getModelsForUserRankings(o)};getHighestSuccessRate=async(e,t)=>{e&&this.loyaltyValidator.validateMarket(e);let n=await this.loyaltyHttps.getHighestSuccessRate(e,t);return this.loyaltyService.addProfileModelToHighestSuccessRate(n)};getModelsForUserRankings=async e=>{let t=null,n=null,o=null,[p,d,h]=this.loyaltyService.extractRankingsIdsMap(e.data);if(h.length&&(t=(await this.getTemplates()).data.filter(I=>h.includes(I.id))),p.length){let y={gameIds:p};n=(await this.topXFacade.getGames(y)).data}if(d.length){let y={gameIds:d};o=(await this.matchQuizFacade.getGames(y)).data}return this.loyaltyService.setModelsForUserRankings(n,o,t,e)}};var Es=class{clientHttps=null;profileHttps=null;loyaltyHttps=null;loyaltyFacade=null;localStorage=null;constructor(e){this.clientHttps=new et(e),this.profileHttps=new Ui(e),this.loyaltyHttps=new Ps(e),this.localStorage=new yt(e),this.loyaltyFacade=new Ts(e,this.clientHttps,this.loyaltyHttps,this.profileHttps,this.localStorage)}getConfig=async()=>await this.loyaltyFacade.getConfig();getClientBadges=async()=>await this.loyaltyFacade.getClientBadges();getTemplates=async e=>await this.loyaltyFacade.getTemplates(e);getTemplateById=async(e,t)=>await this.loyaltyFacade.getTemplateById(e,t);getLeaderboard=async(e,t,n)=>await this.loyaltyFacade.getLeaderboard(e,t,n);getLeaderboardForGame=async(e,t,n)=>await this.loyaltyFacade.getLeaderboardForGame(e,t,n);getOwnRankings=async(e,t)=>await this.loyaltyFacade.getOwnRankings(e,t);getUserRankings=async(e,t,n)=>await this.loyaltyFacade.getUserRankings(e,t,n);getHighestSuccessRate=async(e,t)=>await this.loyaltyFacade.getHighestSuccessRate(e,t)};var Cs=class{topXFacade=null;idMapping=null;constructor(e){this.idMapping=new ae(e),this.topXFacade=new hr(e,this.idMapping)}getConfig=async()=>await this.topXFacade.getConfig();getGames=async(e,t)=>await this.topXFacade.getGames(e,t);getGameById=async(e,t)=>await this.topXFacade.getGameById(e,t);getGamePredictions=async(e,t,n)=>await this.topXFacade.getGamePredictions(e,t,n);getGameResults=async(e,t,n)=>await this.topXFacade.getGameResults(e,t,n);getCurrentGameResults=async e=>await this.topXFacade.getCurrentGameResults(e);play=async e=>await this.topXFacade.play(e);delete=async e=>await this.topXFacade.delete(e);getMyGameEditions=async(e,t)=>await this.topXFacade.getMyGameEditions(e,t);getMyGamePrediction=async e=>await this.topXFacade.getMyGamePrediction(e);getUserGameEditions=async(e,t,n)=>await this.topXFacade.getUserGameEditions(e,t,n);getUserGamePrediction=async(e,t,n)=>await this.topXFacade.getUserGamePrediction(e,t,n);getMarketsResultsForGame=async(e,t)=>await this.topXFacade.getMarketsResultsForGame(e,t)};var As=class{matchQuizFacade=null;constructor(e){this.matchQuizFacade=new gr(e)}getConfig=async()=>await this.matchQuizFacade.getConfig();play=async e=>await this.matchQuizFacade.play(e);delete=async e=>await this.matchQuizFacade.delete(e);getGames=async(e,t)=>await this.matchQuizFacade.getGames(e,t);getGameById=async(e,t)=>await this.matchQuizFacade.getGameById(e,t);getGamePredictions=async(e,t,n)=>await this.matchQuizFacade.getGamePredictions(e,t,n);getGameResults=async(e,t,n)=>await this.matchQuizFacade.getGameResults(e,t,n);getCurrentGameResults=async e=>await this.matchQuizFacade.getCurrentGameResults(e);getMyGameEditions=async(e,t)=>await this.matchQuizFacade.getMyGameEditions(e,t);getMyGamePrediction=async e=>await this.matchQuizFacade.getMyGamePrediction(e);getUserGameEditions=async(e,t,n)=>await this.matchQuizFacade.getUserGameEditions(e,t,n);getUserGamePrediction=async(e,t,n)=>await this.matchQuizFacade.getUserGamePrediction(e,t,n);getMarketsResultsForGame=async(e,t)=>await this.matchQuizFacade.getMarketsResultsForGame(e,t)};var an=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 on=class{action=null;context=new Ji;constructor(e,t,n,o){this.action=e,this.context.tags=t,n&&(this.context.content=n),o&&(this.context.campaign=o)}};var xs=class{idSchema;idMapping;constructor(e){this.idSchema=e.idSchema,this.idMapping=new ae(e)}remapTagsIds=async(e,t,n)=>{let o={},p={},d=[];e.forEach(y=>{o.hasOwnProperty(y.type)||(o[y.type]=[],p[y.type]=[]),o[y.type].push(y.id),p[y.type].push(y)});let h=await this.idMapping.idMappingFacade.getEntitiesByIds(o,t,n);for(let[y,I]of Object.entries(p))I.forEach((b,S)=>{b.id=h[y][S],d.push(b)});return d}};var Os=class{idSchema;activityHttps;activityService;constructor(e){this.idSchema=e.idSchema,this.activityHttps=new ji(e),this.activityService=new xs(e)}add=async(e,t,n,o)=>{if(this.idSchema!="native"){let d=JSON.parse(JSON.stringify(t)),h=await this.activityService.remapTagsIds(t,this.idSchema,"native"),y=new on(e,h,n,o),I=await this.activityHttps.createActivity(y);return I.context.tags=d,I}let p=new on(e,t,n,o);return this.activityHttps.createActivity(p)};delete=async e=>await this.activityHttps.deleteActivity(e);like=async(e,t,n)=>{let o="like";return await this.add(o,e,t,n)};dislike=async(e,t,n)=>{let o="dislike";return await this.add(o,e,t,n)};addPageview=async(e,t,n)=>{let o="page_view";return await this.add(o,e,t,n)};addContentConsumed=async(e,t,n)=>{let o="content_consumed";return await this.add(o,e,t,n)};addShare=async(e,t,n)=>{let o="share";return await this.add(o,e,t,n)};addComment=async(e,t,n)=>{let o="comment";return await this.add(o,e,t,n)};addClickAd=async(e,t,n)=>{let o="click_ad";return await this.add(o,e,t,n)};addConversion=async(e,t,n)=>{let o="conversion";return await this.add(o,e,t,n)};getOwn=async(e,t)=>{if(t=t||!1,e&&(e=new an(e)),this.idSchema!="native"){let n=await this.activityHttps.getOwnActivities(e,t);for(let o of n.data)await this.activityService.remapTagsIds(o.context.tags,"native",this.idSchema);return n}return await this.activityHttps.getOwnActivities(e,t)};getForUser=async(e,t,n)=>{if(n=n||!1,t&&(t=new an(t)),this.idSchema!="native"){let o=await this.activityHttps.getActivitiesForUser(e,t,n);for(let p of o.data)await this.activityService.remapTagsIds(p.context.tags,"native",this.idSchema);return o}return await this.activityHttps.getActivitiesForUser(e,t,n)}};var Bs=class{activityFacade;constructor(e){this.activityFacade=new Os(e)}add=async(e,t,n,o)=>await this.activityFacade.add(e,t,n,o);delete=async e=>await this.activityFacade.delete(e);like=async(e,t,n)=>await this.activityFacade.like(e,t,n);dislike=async(e,t,n)=>await this.activityFacade.dislike(e,t,n);addPageview=async(e,t,n)=>await this.activityFacade.addPageview(e,t,n);addContentConsumed=async(e,t,n)=>await this.activityFacade.addContentConsumed(e,t,n);addShare=async(e,t,n)=>await this.activityFacade.addShare(e,t,n);addComment=async(e,t,n)=>await this.activityFacade.addComment(e,t,n);addClickAd=async(e,t,n)=>await this.activityFacade.addClickAd(e,t,n);addConversion=async(e,t,n)=>await this.activityFacade.addConversion(e,t,n);getOwn=async(e,t)=>await this.activityFacade.getOwn(e,t);getForUser=async(e,t,n)=>await this.activityFacade.getForUser(e,t,n)};function yB(s){let t=new No().validate(s);if((t.idSchema.validation==="missing"||t.idSchema.validation==="invalid")&&(console.warn(t.idSchema.message.text),s.idSchema="native"),(t.environment.validation==="missing"||t.environment.validation==="invalid")&&(console.warn(t.environment.message.text),s.environment="prod"),(t.lang.validation==="missing"||t.lang.validation==="invalid")&&(console.warn(t.lang.message.text),s.lang="en"),t.authProvider.validation==="invalid"&&console.warn(t.authProvider.message.text),t.isValid)return{profile:new er(s),football:new Do(s),predictor:new fs(s),loyalty:new Es(s),topX:new Cs(s),matchQuiz:new As(s),activity:new Bs(s)};LI(t)}var LI=s=>{let e="authProvider",t="isValid";Object.keys(s).forEach(n=>{let o=s[n];if(n!==t&&n!==e){if(o.message.type==="error")throw new Error(o.message.text)}else n!==t&&n===e&&Object.keys(new fi).forEach(p=>{if(o[p].message.type==="error")throw new Error(o[p].message.text)})})};export{yB as FansUnitedSDK};
|
|
24
24
|
/**
|