fansunited-sdk-esm 1.76.0 → 1.76.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/index.js.map +3 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
var Tl=Object.create;var Ln=Object.defineProperty;var vl=Object.getOwnPropertyDescriptor;var Fl=Object.getOwnPropertyNames;var El=Object.getPrototypeOf,Sl=Object.prototype.hasOwnProperty;var Rl=(o,t,e)=>t in o?Ln(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var gn=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports);var Cl=(o,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Fl(t))!Sl.call(o,r)&&r!==e&&Ln(o,r,{get:()=>t[r],enumerable:!(i=vl(t,r))||i.enumerable});return o};var Al=(o,t,e)=>(e=o!=null?Tl(El(o)):{},Cl(t||!o||!o.__esModule?Ln(e,"default",{value:o,enumerable:!0}):e,o));var ot=(o,t,e)=>(Rl(o,typeof t!="symbol"?t+"":t,e),e);var el=gn((Kp,In)=>{var Dl=function(){"use strict";function o(c,u){return u!=null&&c instanceof u}var t;try{t=Map}catch{t=function(){}}var e;try{e=Set}catch{e=function(){}}var i;try{i=Promise}catch{i=function(){}}function r(c,u,d,M,g){typeof u=="object"&&(d=u.depth,M=u.prototype,g=u.includeNonEnumerable,u=u.circular);var Ot=[],Vt=[],Ht=typeof Buffer<"u";typeof u>"u"&&(u=!0),typeof d>"u"&&(d=1/0);function Q(b,bt){if(b===null)return null;if(bt===0)return b;var E,vi;if(typeof b!="object")return b;if(o(b,t))E=new t;else if(o(b,e))E=new e;else if(o(b,i))E=new i(function(Fi,y){b.then(function(Ei){Fi(Q(Ei,bt-1))},function(Ei){y(Q(Ei,bt-1))})});else if(r.__isArray(b))E=[];else if(r.__isRegExp(b))E=new RegExp(b.source,p(b)),b.lastIndex&&(E.lastIndex=b.lastIndex);else if(r.__isDate(b))E=new Date(b.getTime());else{if(Ht&&Buffer.isBuffer(b))return Buffer.allocUnsafe?E=Buffer.allocUnsafe(b.length):E=new Buffer(b.length),b.copy(E),E;o(b,Error)?E=Object.create(b):typeof M>"u"?(vi=Object.getPrototypeOf(b),E=Object.create(vi)):(E=Object.create(M),vi=M)}if(u){var Wn=Ot.indexOf(b);if(Wn!=-1)return Vt[Wn];Ot.push(b),Vt.push(E)}o(b,t)&&b.forEach(function(Fi,y){var Ei=Q(y,bt-1),_l=Q(Fi,bt-1);E.set(Ei,_l)}),o(b,e)&&b.forEach(function(Fi){var y=Q(Fi,bt-1);E.add(y)});for(var st in b){var On;vi&&(On=Object.getOwnPropertyDescriptor(vi,st)),!(On&&On.set==null)&&(E[st]=Q(b[st],bt-1))}if(Object.getOwnPropertySymbols)for(var zn=Object.getOwnPropertySymbols(b),st=0;st<zn.length;st++){var mn=zn[st],li=Object.getOwnPropertyDescriptor(b,mn);li&&!li.enumerable&&!g||(E[mn]=Q(b[mn],bt-1),li.enumerable||Object.defineProperty(E,mn,{enumerable:!1}))}if(g)for(var qn=Object.getOwnPropertyNames(b),st=0;st<qn.length;st++){var hn=qn[st],li=Object.getOwnPropertyDescriptor(b,hn);li&&li.enumerable||(E[hn]=Q(b[hn],bt-1),Object.defineProperty(E,hn,{enumerable:!1}))}return E}return Q(c,d)}r.clonePrototype=function(u){if(u===null)return null;var d=function(){};return d.prototype=u,new d};function a(c){return Object.prototype.toString.call(c)}r.__objToStr=a;function s(c){return typeof c=="object"&&a(c)==="[object Date]"}r.__isDate=s;function l(c){return typeof c=="object"&&a(c)==="[object Array]"}r.__isArray=l;function n(c){return typeof c=="object"&&a(c)==="[object RegExp]"}r.__isRegExp=n;function p(c){var u="";return c.global&&(u+="g"),c.ignoreCase&&(u+="i"),c.multiline&&(u+="m"),u}return r.__getRegExpFlags=p,r}();typeof In=="object"&&In.exports&&(In.exports=Dl)});var dl=gn((jp,Vn)=>{"use strict";var di=typeof Reflect=="object"?Reflect:null,il=di&&typeof di.apply=="function"?di.apply:function(t,e,i){return Function.prototype.apply.call(t,e,i)},Pn;di&&typeof di.ownKeys=="function"?Pn=di.ownKeys:Object.getOwnPropertySymbols?Pn=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Pn=function(t){return Object.getOwnPropertyNames(t)};function Bl(o){console&&console.warn&&console.warn(o)}var al=Number.isNaN||function(t){return t!==t};function _(){_.init.call(this)}Vn.exports=_;Vn.exports.once=Gl;_.EventEmitter=_;_.prototype._events=void 0;_.prototype._eventsCount=0;_.prototype._maxListeners=void 0;var rl=10;function _n(o){if(typeof o!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof o)}Object.defineProperty(_,"defaultMaxListeners",{enumerable:!0,get:function(){return rl},set:function(o){if(typeof o!="number"||o<0||al(o))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+o+".");rl=o}});_.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};_.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||al(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function ol(o){return o._maxListeners===void 0?_.defaultMaxListeners:o._maxListeners}_.prototype.getMaxListeners=function(){return ol(this)};_.prototype.emit=function(t){for(var e=[],i=1;i<arguments.length;i++)e.push(arguments[i]);var r=t==="error",a=this._events;if(a!==void 0)r=r&&a.error===void 0;else if(!r)return!1;if(r){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var l=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw l.context=s,l}var n=a[t];if(n===void 0)return!1;if(typeof n=="function")il(n,this,e);else for(var p=n.length,c=cl(n,p),i=0;i<p;++i)il(c[i],this,e);return!0};function sl(o,t,e,i){var r,a,s;if(_n(e),a=o._events,a===void 0?(a=o._events=Object.create(null),o._eventsCount=0):(a.newListener!==void 0&&(o.emit("newListener",t,e.listener?e.listener:e),a=o._events),s=a[t]),s===void 0)s=a[t]=e,++o._eventsCount;else if(typeof s=="function"?s=a[t]=i?[e,s]:[s,e]:i?s.unshift(e):s.push(e),r=ol(o),r>0&&s.length>r&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=o,l.type=t,l.count=s.length,Bl(l)}return o}_.prototype.addListener=function(t,e){return sl(this,t,e,!1)};_.prototype.on=_.prototype.addListener;_.prototype.prependListener=function(t,e){return sl(this,t,e,!0)};function Nl(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function nl(o,t,e){var i={fired:!1,wrapFn:void 0,target:o,type:t,listener:e},r=Nl.bind(i);return r.listener=e,i.wrapFn=r,r}_.prototype.once=function(t,e){return _n(e),this.on(t,nl(this,t,e)),this};_.prototype.prependOnceListener=function(t,e){return _n(e),this.prependListener(t,nl(this,t,e)),this};_.prototype.removeListener=function(t,e){var i,r,a,s,l;if(_n(e),r=this._events,r===void 0)return this;if(i=r[t],i===void 0)return this;if(i===e||i.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,i.listener||e));else if(typeof i!="function"){for(a=-1,s=i.length-1;s>=0;s--)if(i[s]===e||i[s].listener===e){l=i[s].listener,a=s;break}if(a<0)return this;a===0?i.shift():kl(i,a),i.length===1&&(r[t]=i[0]),r.removeListener!==void 0&&this.emit("removeListener",t,l||e)}return this};_.prototype.off=_.prototype.removeListener;_.prototype.removeAllListeners=function(t){var e,i,r;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[t]),this;if(arguments.length===0){var a=Object.keys(i),s;for(r=0;r<a.length;++r)s=a[r],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=i[t],typeof e=="function")this.removeListener(t,e);else if(e!==void 0)for(r=e.length-1;r>=0;r--)this.removeListener(t,e[r]);return this};function ll(o,t,e){var i=o._events;if(i===void 0)return[];var r=i[t];return r===void 0?[]:typeof r=="function"?e?[r.listener||r]:[r]:e?Ul(r):cl(r,r.length)}_.prototype.listeners=function(t){return ll(this,t,!0)};_.prototype.rawListeners=function(t){return ll(this,t,!1)};_.listenerCount=function(o,t){return typeof o.listenerCount=="function"?o.listenerCount(t):pl.call(o,t)};_.prototype.listenerCount=pl;function pl(o){var t=this._events;if(t!==void 0){var e=t[o];if(typeof e=="function")return 1;if(e!==void 0)return e.length}return 0}_.prototype.eventNames=function(){return this._eventsCount>0?Pn(this._events):[]};function cl(o,t){for(var e=new Array(t),i=0;i<t;++i)e[i]=o[i];return e}function kl(o,t){for(;t+1<o.length;t++)o[t]=o[t+1];o.pop()}function Ul(o){for(var t=new Array(o.length),e=0;e<t.length;++e)t[e]=o[e].listener||o[e];return t}function Gl(o,t){return new Promise(function(e,i){function r(s){o.removeListener(t,a),i(s)}function a(){typeof o.removeListener=="function"&&o.removeListener("error",r),e([].slice.call(arguments))}ul(o,t,a,{once:!0}),t!=="error"&&Vl(o,r,{once:!0})})}function Vl(o,t,e){typeof o.on=="function"&&ul(o,"error",t,e)}function ul(o,t,e,i){if(typeof o.on=="function")i.once?o.once(t,e):o.on(t,e);else if(typeof o.addEventListener=="function")o.addEventListener(t,function r(a){i.once&&o.removeEventListener(t,r),e(a)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof o)}});var gl=gn((ml,hl)=>{(function(){var o,t,e,i=[].splice,r=function(s,l){if(!(s instanceof l))throw new Error("Bound instance method accessed before binding")},a=[].indexOf;e=el(),o=dl().EventEmitter,hl.exports=t=function(){class s extends o{constructor(n={}){super(),this.get=this.get.bind(this),this.mget=this.mget.bind(this),this.set=this.set.bind(this),this.mset=this.mset.bind(this),this.del=this.del.bind(this),this.take=this.take.bind(this),this.ttl=this.ttl.bind(this),this.getTtl=this.getTtl.bind(this),this.keys=this.keys.bind(this),this.has=this.has.bind(this),this.getStats=this.getStats.bind(this),this.flushAll=this.flushAll.bind(this),this.flushStats=this.flushStats.bind(this),this.close=this.close.bind(this),this._checkData=this._checkData.bind(this),this._check=this._check.bind(this),this._isInvalidKey=this._isInvalidKey.bind(this),this._wrap=this._wrap.bind(this),this._getValLength=this._getValLength.bind(this),this._error=this._error.bind(this),this._initErrors=this._initErrors.bind(this),this.options=n,this._initErrors(),this.data={},this.options=Object.assign({forceString:!1,objectValueSize:80,promiseValueSize:80,arrayValueSize:40,stdTTL:0,checkperiod:600,useClones:!0,deleteOnExpire:!0,enableLegacyCallbacks:!1,maxKeys:-1},this.options),this.options.enableLegacyCallbacks&&(console.warn("WARNING! node-cache legacy callback support will drop in v6.x"),["get","mget","set","del","ttl","getTtl","keys","has"].forEach(p=>{var c;c=this[p],this[p]=function(...u){var d,M,g,Ot;if(g=u,[...u]=g,[d]=i.call(u,-1),typeof d=="function")try{Ot=c(...u),d(null,Ot)}catch(Vt){M=Vt,d(M)}else return c(...u,d)}})),this.stats={hits:0,misses:0,keys:0,ksize:0,vsize:0},this.validKeyTypes=["string","number"],this._checkData()}get(n){var p,c;if(r(this,s),(c=this._isInvalidKey(n))!=null)throw c;if(this.data[n]!=null&&this._check(n,this.data[n]))return this.stats.hits++,p=this._unwrap(this.data[n]),p;this.stats.misses++}mget(n){var p,c,u,d,M,g;if(r(this,s),!Array.isArray(n))throw p=this._error("EKEYSTYPE"),p;for(g={},u=0,M=n.length;u<M;u++){if(d=n[u],(c=this._isInvalidKey(d))!=null)throw c;this.data[d]!=null&&this._check(d,this.data[d])?(this.stats.hits++,g[d]=this._unwrap(this.data[d])):this.stats.misses++}return g}set(n,p,c){var u,d,M;if(r(this,s),this.options.maxKeys>-1&&this.stats.keys>=this.options.maxKeys)throw u=this._error("ECACHEFULL"),u;if(this.options.forceString&&!typeof p==="string"&&(p=JSON.stringify(p)),c==null&&(c=this.options.stdTTL),(d=this._isInvalidKey(n))!=null)throw d;return M=!1,this.data[n]&&(M=!0,this.stats.vsize-=this._getValLength(this._unwrap(this.data[n],!1))),this.data[n]=this._wrap(p,c),this.stats.vsize+=this._getValLength(p),M||(this.stats.ksize+=this._getKeyLength(n),this.stats.keys++),this.emit("set",n,p),!0}mset(n){var p,c,u,d,M,g,Ot,Vt,Ht,Q;if(r(this,s),this.options.maxKeys>-1&&this.stats.keys+n.length>=this.options.maxKeys)throw p=this._error("ECACHEFULL"),p;for(u=0,Ot=n.length;u<Ot;u++){if(g=n[u],{key:M,val:Q,ttl:Ht}=g,Ht&&typeof Ht!="number")throw p=this._error("ETTLTYPE"),p;if((c=this._isInvalidKey(M))!=null)throw c}for(d=0,Vt=n.length;d<Vt;d++)g=n[d],{key:M,val:Q,ttl:Ht}=g,this.set(M,Q,Ht);return!0}del(n){var p,c,u,d,M,g;for(r(this,s),Array.isArray(n)||(n=[n]),p=0,u=0,M=n.length;u<M;u++){if(d=n[u],(c=this._isInvalidKey(d))!=null)throw c;this.data[d]!=null&&(this.stats.vsize-=this._getValLength(this._unwrap(this.data[d],!1)),this.stats.ksize-=this._getKeyLength(d),this.stats.keys--,p++,g=this.data[d],delete this.data[d],this.emit("del",d,g.v))}return p}take(n){var p;return r(this,s),p=this.get(n),p!=null&&this.del(n),p}ttl(n,p){var c;if(r(this,s),p||(p=this.options.stdTTL),!n)return!1;if((c=this._isInvalidKey(n))!=null)throw c;return this.data[n]!=null&&this._check(n,this.data[n])?(p>=0?this.data[n]=this._wrap(this.data[n].v,p,!1):this.del(n),!0):!1}getTtl(n){var p,c;if(r(this,s),!!n){if((c=this._isInvalidKey(n))!=null)throw c;if(this.data[n]!=null&&this._check(n,this.data[n]))return p=this.data[n].t,p}}keys(){var n;return r(this,s),n=Object.keys(this.data),n}has(n){var p;return r(this,s),p=this.data[n]!=null&&this._check(n,this.data[n]),p}getStats(){return r(this,s),this.stats}flushAll(n=!0){r(this,s),this.data={},this.stats={hits:0,misses:0,keys:0,ksize:0,vsize:0},this._killCheckPeriod(),this._checkData(n),this.emit("flush")}flushStats(){r(this,s),this.stats={hits:0,misses:0,keys:0,ksize:0,vsize:0},this.emit("flush_stats")}close(){r(this,s),this._killCheckPeriod()}_checkData(n=!0){var p,c,u;r(this,s),c=this.data;for(p in c)u=c[p],this._check(p,u);n&&this.options.checkperiod>0&&(this.checkTimeout=setTimeout(this._checkData,this.options.checkperiod*1e3,n),this.checkTimeout!=null&&this.checkTimeout.unref!=null&&this.checkTimeout.unref())}_killCheckPeriod(){if(this.checkTimeout!=null)return clearTimeout(this.checkTimeout)}_check(n,p){var c;return r(this,s),c=!0,p.t!==0&&p.t<Date.now()&&(this.options.deleteOnExpire&&(c=!1,this.del(n)),this.emit("expired",n,this._unwrap(p))),c}_isInvalidKey(n){var p;if(r(this,s),p=typeof n,a.call(this.validKeyTypes,p)<0)return this._error("EKEYTYPE",{type:typeof n})}_wrap(n,p,c=!0){var u,d,M,g;return r(this,s),this.options.useClones||(c=!1),d=Date.now(),u=0,g=1e3,p===0?u=0:p?u=d+p*g:this.options.stdTTL===0?u=this.options.stdTTL:u=d+this.options.stdTTL*g,M={t:u,v:c?e(n):n}}_unwrap(n,p=!0){return this.options.useClones||(p=!1),n.v!=null?p?e(n.v):n.v:null}_getKeyLength(n){return n.toString().length}_getValLength(n){return r(this,s),typeof n=="string"?n.length:this.options.forceString?JSON.stringify(n).length:Array.isArray(n)?this.options.arrayValueSize*n.length:typeof n=="number"?8:typeof n?.then=="function"?this.options.promiseValueSize:typeof Buffer<"u"&&Buffer!==null&&Buffer.isBuffer(n)?n.length:n!=null&&typeof n=="object"?this.options.objectValueSize*Object.keys(n).length:typeof n=="boolean"?8:0}_error(n,p={}){var c;return r(this,s),c=new Error,c.name=n,c.errorcode=n,c.message=this.ERRORS[n]!=null?this.ERRORS[n](p):"-",c.data=p,c}_initErrors(){var n,p,c;r(this,s),this.ERRORS={},c=this._ERRORS;for(p in c)n=c[p],this.ERRORS[p]=this.createErrorMessage(n)}createErrorMessage(n){return function(p){return n.replace("__key",p.type)}}}return s.prototype._ERRORS={ENOTFOUND:"Key `__key` not found",ECACHEFULL:"Cache max keys amount exceeded",EKEYTYPE:"The key argument has to be of type `string` or `number`. Found: `__key`",EKEYSTYPE:"The keys argument has to be an array.",ETTLTYPE:"The ttl argument has to be a number."},s}.call(this)}).call(ml)});var bl=gn((fl,yl)=>{(function(){var o;o=yl.exports=gl(),o.version="5.1.2"}).call(fl)});var xn=o=>{let t=200,e=[],i=0;return e[i]=[],o.forEach(r=>{e[i].length<=t-1?e[i].push(r):(i++,e[i]=[r])}),e},$t=(o,t)=>{let e=[];for(;o.length>t;){let i=o.splice(0,t);e.push(i)}return e.push(o),e},S=(o,t)=>{let e="",i={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",miniGames:"https://mini-games.fansunitedapi.com/v1",discussions:"https://discussions.fansunitedapi.com/v1",privateLeagues:"https://private-leagues.fansunitedapi.com/v1",voting:"https://voting.fansunitedapi.com/v1"},r={profile:"https://profile.watg.fansunitedapi.com/v1",football:"https://football.watg.fansunitedapi.com/v1",idMapping:"https://id-mapping.watg.fansunitedapi.com/v1",predictor:"https://prediction.watg.fansunitedapi.com/v1",client:"https://client.watg.fansunitedapi.com/v1",loyalty:"https://loyalty.watg.fansunitedapi.com/v1",miniGames:"https://mini-games.watg.fansunitedapi.com/v1",discussions:"https://discussions.watg.fansunitedapi.com/v1",privateLeagues:"https://private-leagues.watg.fansunitedapi.com/v1",voting:"https://voting.watg.fansunitedapi.com/v1"},a={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",miniGames:"http://localhost:9040/v1",discussions:"http://localhost:9020/v1",privateLeagues:"http://localhost:9010/v1",voting:"http://localhost:9030/v1"},s={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",miniGames:"https://mini-games.fansunitedstagingapi.com/v1",discussions:"https://discussions.fansunitedstagingapi.com/v1",privateLeagues:"https://private-leagues.fansunitedstagingapi.com/v1",voting:"https://voting.fansunitedstagingapi.com/v1"};return o==="prod"?e=i[t]:o==="dev"?e=a[t]:o==="watg"?e=r[t]:e=s[t],e},Lt=o=>Array.from(new Set(o)),w=o=>o||!1,h=()=>`&disable_cache=${Date.now()}`,fn=o=>JSON.parse(JSON.stringify(o.sort((t,e)=>t.localeCompare(e))));var Si=class{id=null;name=null;nickname=null;avatar=null;gender=null;country=null;birthDate=null;verified=!1;staffMember=!1;interests=[];followingCount=0;followersCount=0};var Ri=class{profilesFromResponse=t=>t?t.map(e=>this.fullProfileFromResponse(e)):null;fullProfileFromResponse=t=>{let e=new Si;return e.id=t.id,e.name=t.name,e.nickname=t.nickname,e.avatar=t.avatar,e.gender=t.gender,e.country=t.country,e.birthDate=t.birth_date,e.verified=t.verified,e.staffMember=t.staff_member,e.interests=t.interests?t.interests:[],e.followingCount=t.following_count,e.followersCount=t.followers_count,e}};var nt=class{nextPageStartsAfter=null;itemsPerPage=null};var x=class{pagination=new nt};var R=class{meta=new x;data=[]};var Ci=class{avatar=null;followingId=null;name=null;nickname=null;profileId=null};var Ai=class{followResponse=t=>t.map(e=>this.remapResponse(e));followingFromResponse=t=>{let e=new R;return e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.data=t.data.map(i=>this.remapResponse(i)),e};remapResponse=t=>{let e=new Ci;return e.avatar=t.avatar,e.followingId=t.following_id,e.name=t.name,e.profileId=t.profile_id,e.nickname=t.nickname,e}};var Oi=class{avatar=null;followerId=null;name=null;nickname=null;profileId=null};var Li=class{followersFromResponse=t=>{let e=new R;return e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.data=t.data.map(i=>this.remapResponse(i)),e};remapResponse=t=>{let e=new Oi;return e.avatar=t.avatar,e.followerId=t.follower_id,e.name=t.name,e.profileId=t.profile_id,e}};var pi=class{profile_ids=[]};function Dn(o){this.message=o}Dn.prototype=new Error,Dn.prototype.name="InvalidCharacterError";var Kn=typeof window<"u"&&window.atob&&window.atob.bind(window)||function(o){var t=String(o).replace(/=+$/,"");if(t.length%4==1)throw new Dn("'atob' failed: The string to be decoded is not correctly encoded.");for(var e,i,r=0,a=0,s="";i=t.charAt(a++);~i&&(e=r%4?64*e+i:i,r++%4)?s+=String.fromCharCode(255&e>>(-2*r&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return s};function Ol(o){var t=o.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(Kn(e).replace(/(.)/g,function(i,r){var a=r.charCodeAt(0).toString(16).toUpperCase();return a.length<2&&(a="0"+a),"%"+a}))}(t)}catch{return Kn(t)}}function yn(o){this.message=o}function Ll(o,t){if(typeof o!="string")throw new yn("Invalid token specified");var e=(t=t||{}).header===!0?0:1;try{return JSON.parse(Ol(o.split(".")[e]))}catch(i){throw new yn("Invalid token specified: "+i.message)}}yn.prototype=new Error,yn.prototype.name="InvalidTokenError";var bn=Ll;var D={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id",api_football:"api_football_id"},Bn={PREDICTOR_USER_RELATED_OPERATION:"https://docs.fansunitedmedia.com/docs/predictor-operations#user-related-operations"},Nn=["matchId","matchType","market","prediction"],jn=new Map().set("FT_1X2","fullTimeOneXTwo").set("HT_1X2","halfTimeOneXTwo").set("BOTH_TEAMS_SCORE","bothTeamsScore").set("DOUBLE_CHANCE","doubleChance").set("HT_FT","halfTimeFullTime").set("PLAYER_SCORE","playerScore").set("PLAYER_YELLOW_CARD","playerYellowCard").set("PLAYER_RED_CARD","playerRedCard").set("RED_CARD_MATCH","redCardMatch").set("PENALTY_MATCH","penaltyMatch").set("PLAYER_SCORE_FIRST_GOAL","playerScoreFirstGoal").set("CORNERS_MATCH","cornersMatch").set("CORRECT_SCORE","correctScore").set("CORRECT_SCORE_ADVANCED","correctScoreAdvanced").set("CORRECT_SCORE_HT","correctScoreHalfTime").set("PLAYER_SCORE_HATTRICK","playerScoreHattrick").set("PLAYER_SCORE_TWICE","playerScoreTwice").set("OVER_GOALS_0_5","overZeroPointFiveGoals").set("OVER_GOALS_1_5","overOnePointFiveGoals").set("OVER_GOALS_2_5","overTwoPointFiveGoals").set("OVER_GOALS_3_5","overThreePointFiveGoals").set("OVER_GOALS_4_5","overFourPointFiveGoals").set("OVER_GOALS_5_5","overFivePointFiveGoals").set("OVER_GOALS_6_5","overSixPointFiveGoals").set("OVER_CORNERS_6_5","overSixPointFiveCorners").set("OVER_CORNERS_7_5","overSevenPointFiveCorners").set("OVER_CORNERS_8_5","overEightPointFiveCorners").set("OVER_CORNERS_9_5","overNinePointFiveCorners").set("OVER_CORNERS_10_5","overTenPointFiveCorners").set("OVER_CORNERS_11_5","overElevenPointFiveCorners").set("OVER_CORNERS_12_5","overTwelvePointFiveCorners").set("OVER_CORNERS_13_5","overThirteenPointFiveCorners");var kn={UNEXPECTED_STATUS_PROP:`Unexpected provided property 'status'. You can NOT use this property for this method. For more information visit our documentation:
|
|
2
2
|
${Bn.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:
|
|
3
|
-
${Bn.PREDICTOR_USER_RELATED_OPERATION}`},Xn=(o,t)=>`The prediction '${o}' is invalid for market '${t}'. 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`,Mn=o=>`The market '${o}' is not supported from Fans United. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,Yn=o=>`The market '${o}' is not valid for Top X game. The only available market is CORRECT_SCORE.`,Jn=o=>`The field/s '${o.length>1?o.join(", "):o[0]}' is/are invalid. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/javascript-sdk`,Zn=(o,t)=>`The following field/s is/are missing from ${o}: '${t.length>1?t.join(", "):t[0]}'. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,tl=(o,t)=>`The field ${o} has incorrect type. The correct type is ${t}`;var xt=class{data={error:{code:0,status:"",message:""}};status=0;statusText="";headers=null;constructor(t,e){this.data.error.code=e.code,this.data.error.status=e.status,this.data.error.message=e.message,this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}errorMessage=()=>this.data.error.message};var m=class{error={code:0,status:"",message:""};constructor(t,e,i){this.error.code=t,this.error.status=e,this.error.message=i}};var T=class{baseUrl=null;apiSignInUrl=null;jwtToken=null;idSchema=null;retryRequest=!1;headers=null;authHeaders=null;errorHandlingMode=null;configuration=null;constructor(t,e){this.baseUrl=e,this.configuration=t,this.apiSignInUrl=`?key=${t.apiKey}&client_id=${t.clientId}`,this.errorHandlingMode=t.errorHandlingMode,this.idSchema=t.idSchema,this.headers={"Content-Type":"application/json"}}getJwtToken=()=>this.configuration.authProvider.getIdToken();getAuthHeaders=()=>({"Content-Type":"application/json",Authorization:`Bearer ${this.getJwtToken()}`});fetchWithoutAuth=async(t,e)=>{let i=await fetch(this.baseUrl+t,{headers:this.headers}),r=await i.json();if(!i.ok){let a=this.transformFetchException(i,r);throw console.warn(e,a),a}return r};fetchWithoutAuthAdditionalHeaders=async(t,e,i)=>{let r=await fetch(this.baseUrl+t,{headers:{...this.headers,...i}}),a=await r.json();if(!r.ok){let s=this.transformFetchException(r,a);throw console.warn(e,s),s}return a};fetchWithAuth=async(t,e,i,r)=>{this.validateJWTToken();let a=null,s=null;if(i&&r?a=await fetch(this.baseUrl+t,{method:i,headers:this.getAuthHeaders(),body:JSON.stringify(r)}):i&&!r?a=await fetch(this.baseUrl+t,{method:i,headers:this.getAuthHeaders()}):a=await fetch(this.baseUrl+t,{headers:this.getAuthHeaders()}),i!=="DELETE"&&(s=await a.json()),!a.ok){(a.status===401||a.status===403)&&!this.retryRequest&&(this.retryRequest=!0,await this.fetchWithAuth(t,e,i,r)),this.retryRequest=!1;let l=this.transformFetchException(a,s||await a.json());throw console.warn(e,l),l}return this.retryRequest=!1,s};fetchWithAuthNewBaseURL=async(t,e,i,r,a)=>{this.validateJWTToken();let s=null,l=null;if(r&&a?s=await fetch(t+e,{method:r,headers:this.getAuthHeaders(),body:JSON.stringify(a)}):r&&!a?s=await fetch(t+e,{method:r,headers:this.getAuthHeaders()}):s=await fetch(t+e,{headers:this.getAuthHeaders()}),r!=="DELETE"&&(l=await s.json()),!s.ok){(s.status===401||s.status===403)&&!this.retryRequest&&(this.retryRequest=!0,await this.fetchWithAuthNewBaseURL(t,e,i,r,a)),this.retryRequest=!1;let n=this.transformFetchException(s,l||await s.json());throw console.warn(i,n),n}return this.retryRequest=!1,l};transformFetchException=(t,e)=>{if(!e&&t.status===401){if(this.errorHandlingMode==="standard")return new m(401,"unauthorized","Invalid JWT token is provided");let s={code:401,status:"unauthorized",message:"Invalid JWT token is provided"};return new xt(t,s)}let{code:i,status:r,message:a}=e.error;return this.errorHandlingMode==="standard"?new m(i,r,a):new xt(t,e.error)};validateJWTToken=()=>{let t=null;try{t=bn(this.getJwtToken())}catch(i){if(this.errorHandlingMode==="default"){let r={status:401,statusText:i.message,headers:{}},a={code:401,status:"invalid_token",message:"Invalid JWT token is provided"};throw new xt(r,a)}else if(this.errorHandlingMode==="standard")throw new m(401,"invalid_token","Invalid JWT token is provided")}if(Date.now()>t.exp*1e3){if(this.errorHandlingMode==="default"){let i={status:401,statusText:"",headers:{}},r={code:401,status:"invalid_token",message:"The provided JWT token is expired"};throw new xt(i,r)}else if(this.errorHandlingMode==="standard")throw new m(401,"invalid_token","The provided JWT token is expired")}}};var xl="/countries",z="/profile",wn="/profiles",Wt=class extends T{profileRemapper=null;followingRemapper=null;followersRemapper=null;lang=null;limitIds=100;constructor(t){super(t,S(t.environment,"profile")),this.lang=t.lang,this.profileRemapper=new Ri,this.followingRemapper=new Ai,this.followersRemapper=new Li}getCountries=async t=>{let e=`&lang=${this.lang}`,i=`${xl}${this.apiSignInUrl}${e}`,r=Date.now(),a="There was a problem fetching profile countries";return t&&(i+=`&disable_cache=${r}`),(await this.fetchWithoutAuth(i,a)).data};getProfile=async t=>{let e=`${z}${this.apiSignInUrl}`,i="";if(t){e=`${wn}/${t}${this.apiSignInUrl}`,i=`There was a problem fetching the following profile: ${t}`;let r=await this.fetchWithoutAuth(e,i);return this.profileRemapper.fullProfileFromResponse(r.data)}else{i="There was a problem fetching your profile from API";let r=await this.fetchWithAuth(e,i);return this.profileRemapper.fullProfileFromResponse(r.data)}};getProfiles=async(t,e,i)=>{let r=Date.now(),a=`There was a problem fetching the following profiles: ${t.join(",")}`;if(t&&t.length){if(t.length>this.limitIds){let c=[],u=$t(t,this.limitIds);for(let d of u){let M=`${wn}${this.apiSignInUrl}&profile_ids=${d.join(",")}`;a=`There was a problem fetching the following profiles: ${d.join(",")}`,i&&(M+=`&disable_cache=${r}`);let g=await this.fetchWithoutAuth(M,a);c.push(...this.profileRemapper.profilesFromResponse(g.data))}return c}let n=`${wn}${this.apiSignInUrl}&profile_ids=${t.join(",")}`;i&&(n+=`&disable_cache=${r}`);let p=await this.fetchWithoutAuth(n,a);return this.profileRemapper.profilesFromResponse(p.data)}let s=`${wn}${this.apiSignInUrl}&search=${e}`;i&&(s+=`&disable_cache=${r}`);let l=await this.fetchWithoutAuth(s,a);return this.profileRemapper.profilesFromResponse(l.data)};getFollowers=async(t,e)=>{let i=`${z}/followers${this.apiSignInUrl}`,r="There was a problem fetching the followers for own profile";if(t&&!e){i=`${z}/followers${this.apiSignInUrl}${t.constructFilterUrl()}`;let s=await this.fetchWithAuth(i,r);return this.followersRemapper.followersFromResponse(s)}else if(!t&&!e){let s=await this.fetchWithAuth(i,r);return this.followersRemapper.followersFromResponse(s)}t&&e?i=`${z}/${e}/followers${this.apiSignInUrl}${t.constructFilterUrl()}`:!t&&e&&(i=`${z}/${e}/followers${this.apiSignInUrl}`),r=`There was a problem fetching the followers for profile: ${e}`;let a=await this.fetchWithoutAuth(i,r);return this.followersRemapper.followersFromResponse(a)};getFollowing=async(t,e)=>{let i=`${z}/following${this.apiSignInUrl}`,r="There was a problem fetching the followers of own profile";if(t&&!e){i=`${z}/following${this.apiSignInUrl}${t.constructFilterUrl()}`;let s=await this.fetchWithAuth(i,r);return this.followingRemapper.followingFromResponse(s)}else if(!t&&!e){let s=await this.fetchWithAuth(i,r);return this.followingRemapper.followingFromResponse(s)}t&&e?i=`${z}/${e}/following${this.apiSignInUrl}${t.constructFilterUrl()}`:!t&&e&&(i=`${z}/${e}/following${this.apiSignInUrl}`),r=`There was a problem fetching the followers of the following profile: ${e}`;let a=await this.fetchWithoutAuth(i,r);return this.followingRemapper.followingFromResponse(a)};follow=async t=>{let e=new pi;e.profile_ids=t;let i=z+`/follow${this.apiSignInUrl}`,r=`There was a problem with following profiles: ${t.join(",")}`,a="POST",s=await this.fetchWithAuth(i,r,a,e);return this.followingRemapper.followResponse(s.data)};unfollow=async t=>{let e=new pi;e.profile_ids=t;let i=z+`/follow${this.apiSignInUrl}`,r=`There was a problem with unfollowing profiles: ${t.join(",")}`,a="DELETE";return await this.fetchWithAuth(i,r,a,e),!0};getBadges=async t=>{let e=`${z}/badges${this.apiSignInUrl}`,i="There was a problem with fetching own badges";return t?(e=`${z}/${t}/badges${this.apiSignInUrl}`,i="There was a problem with fetching the badges",(await this.fetchWithoutAuth(e,i)).data):(await this.fetchWithAuth(e,i)).data};updateProfile=async t=>{let e=z+this.apiSignInUrl,i="There was a problem updating the own profile",r="PATCH",a=await this.fetchWithAuth(e,i,r,t);return this.profileRemapper.fullProfileFromResponse(a.data)}};var C=(a=>(a.NATIVE="native",a.ENETPULSE="enetpulse",a.SPORTRADAR="sportradar",a.SPORTAL_365="sportal365",a.API_FOOTBALL="api_football",a))(C||{});var xi={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},Di=class extends T{constructor(t){super(t,S(t.environment,"idMapping"))}getEntityById=async(t,e)=>{let i=`/football${this.apiSignInUrl}&input_provider=${this.idSchema}&${xi[t]}=${e}`,r=`There was a problem with id mapping request for the following id: ${e}`;return await this.fetchWithoutAuth(i,r)};getEntityByIdAndSchema=async(t,e,i)=>{let r=`/football${this.apiSignInUrl}&input_provider=${i}&${xi[t]}=${e}`,a=`There was a problem with id mapping request for the following id: ${e}`;return await this.fetchWithoutAuth(r,a)};getEntityIdsByIdsAndSchema=async(t,e,i)=>{let r=`/football${this.apiSignInUrl}&input_provider=${i}&${xi[t]}=${e.join(",")}`,a=`There was a problem with id mapping request for the following ids: ${e.join(",")}`;return await this.fetchWithoutAuth(r,a)};getEntitiesByIds=async(t,e,i)=>{e.sort((s,l)=>s.localeCompare(l));let r=xn(e),a=[];for(let s of r){let l=`/football${this.apiSignInUrl}&input_provider=${i}&${xi[t]}=${s.join(",")}`,n=`There was a problem with id mapping request for the following ids :${s.join(",")}`,p=await this.fetchWithoutAuth(l,n);a=[...a,...p.data]}return a};getEntitiesByIdObjs=async(t,e)=>{let i=[],r={},a=[];Object.keys(t).forEach(p=>{i.push.apply(i,t[p])});let s=Lt(i),l=xn(s);for(let p of l){let c="";if(Object.keys(t).forEach(u=>{r[u]=[];let d=p.filter(M=>t[u].includes(M));d&&d.length>0&&(r[u]=d)}),Object.keys(r).forEach(u=>{r[u].length>0&&(r[u].sort((d,M)=>d.localeCompare(M)),c+="&",c+=`${xi[u]}=${r[u].join(",")}`)}),c&&c.length>0){let u=`/football${this.apiSignInUrl}&input_provider=${e||"native"}${c}`,d="There was a problem with id mapping request",M=await this.fetchWithoutAuth(u,d);a.push(M.data)}else a.push([])}return Array.prototype.concat.apply([],a)};getTopEntities=async()=>{let t=`/football/top${this.apiSignInUrl}`,e="There was a problem with top id mappings request";return(await this.fetchWithoutAuth(t,e)).data}};var Un="FansUnited",Gn={football:{ids:[],countries:[],competitions:[],expirations:{ids:0}},profile:{info:{},statistics:{},badges:null,countries:[],expirations:{profile:0,statistics:0,badges:0}},client:{features:{},expirations:{features:0}}},ci=class{idSchema="";expirationProfileTimeout=600;expirationBadgesTimeout=3600;expirationClientFeaturesTimeout=14400;expirationFootballIdsTimeout=604800;constructor(t){this.idSchema=t}static getInstance(t){return ci.instance||(ci.instance=new ci(t)),ci.instance}clearData=()=>{this.setData(Gn)};getEntityById=(t="",e="")=>this.getData().football.ids.find(i=>{let r=D[this.idSchema];return i&&`${i[r]}`===e&&i.resource===t});getEntity=(t,e,i)=>Array.isArray(t)?this.getData().football.ids.filter(r=>{let a=D[i];return r&&t.includes(`${r[a]}`)&&r.resource===e}):this.getData().football.ids.find(r=>{let a=D[i];return r&&`${r[a]}`===t&&r.resource===e});getEntityByNativeId=(t="",e="")=>this.getData().football.ids.find(i=>i&&`${i.id}`===e&&i.resource===t);checkForExistingIdObjs=(t,e)=>{let i=D[e],r={};return Object.keys(t).forEach(a=>{let s=t[a],n=this.getEntity(s,a,e).map(c=>c[i]),p=t[a].filter(c=>!n.includes(c));r[a]=s.map(c=>p.includes(c)?{id:c,exists:!1}:{id:c,exists:!0})}),r};getIdsByType=(t,e,i)=>{let r=D[i],a=D[e],s={};return Object.keys(t).forEach(l=>{let n=t[l],p=[];this.getData().football.ids.forEach(c=>{n.forEach((u,d)=>{u===c[a]&&l===c.resource&&(p[d]=c[r])})}),s[l]=p}),s};addIdMapping=t=>{let e=this.getData();e.football.ids.push(t),this.setData(e)};addIdMappings=t=>{let e=this.getData(),i=e.football.ids;i=[...i,...t],e.football.ids=i,this.setData(e)};addTopIdMappings=t=>{let e=this.getData();if(e.football.ids.length){let i=JSON.parse(JSON.stringify(e.football.ids));i=i.filter(r=>r.resource!=="match"),t=t.filter(r=>r.resource==="match"),i=[...i,...t],e.football.ids=i}else e.football.ids=t;e.football.expirations.ids=Math.floor(Date.now()/1e3)+this.expirationFootballIdsTimeout,this.setData(e)};setOwnProfile=t=>{let e=this.getData();e.profile.info=t,e.profile.expirations.profile=Math.floor(Date.now()/1e3)+this.expirationProfileTimeout,this.setData(e)};getOwnProfile=()=>this.getData().profile.info;getProfileCountries=()=>this.getData().profile.countries;setProfileCountries=t=>{let e=this.getData();e.profile.countries=t,this.setData(e)};getProfileStats=()=>this.getData().profile.statistics;setProfileStats=t=>{let e=this.getData();e.profile.statistics=t,e.profile.expirations.statistics=Math.floor(Date.now()/1e3)+this.expirationProfileTimeout,this.setData(e)};getProfileBadges=()=>this.getData().profile.badges;setProfileBadges=t=>{let e=this.getData();e.profile.badges=t,e.profile.expirations.badges=Math.floor(Date.now()/1e3)+this.expirationBadgesTimeout,this.setData(e)};getFootballCountries=()=>this.getData().football.countries;setFootballCountries=t=>{let e=this.getData();e.football.countries=t,this.setData(e)};getCompetitions=t=>{let e=this.getData();return t?t.competitionSearchFilter(e.football.competitions):e.football.competitions};setCompetitions=t=>{let e=this.getData(),i=[...e.football.competitions];i.push(...t),e.football.competitions=this.makeCompetitionsUnique(i),this.setData(e)};getCompetitionsLength=()=>{let{football:t}=this.getData();return t.competitions.length};getClientFeatures=()=>this.getData().client.features;setClientFeatures=t=>{let e=this.getData(),i=JSON.parse(JSON.stringify(t));e.client.expirations.features=Math.floor(Date.now()/1e3)+this.expirationClientFeaturesTimeout,e.client.features=i,this.setData(e)};deleteClientFeatures=()=>{let t=this.getData(),e=JSON.parse(JSON.stringify(t));e.client={features:{},expirations:{features:0}},this.setData(e)};getExpiration=(t,e)=>{this.initialNewSchema(t,"expirations");let i=this.getData();switch(e){case"profile":return i.profile.expirations.profile;case"statistics":return i.profile.expirations.statistics;case"badges":return i.profile.expirations.badges;case"features":return i.client.expirations.features;case"ids":return i.football.expirations.ids}};makeCompetitionsUnique=t=>{let e=new Set;return t.filter(i=>{let r=!e.has(i.id);return e.add(i.id),r})};getData=()=>(localStorage.getItem(Un)||this.setData(Gn),JSON.parse(localStorage.getItem(Un)));setData=t=>{localStorage.setItem(Un,JSON.stringify(t))};initialNewSchema=(t,e)=>{let i=this.getData();(!i||!i[t]||!i[t][e])&&this.setData(Gn)}},ui=ci;ot(ui,"instance");var Ml=Al(bl());var I=class{profileTTL=600;clientTTL=14400;profileBadgesTTL=3600;idMappingsExpiration=0;idSchema="";constructor(t){}static getInstance(t){return I.instance||(I.instance=new I(t),I.nodeCache.options.useClones=!1),I.instance}clearData=()=>I.nodeCache.flushAll();getEntityById=(t,e)=>{let i=I.nodeCache.get("ids");return i?i.find(r=>{let a=D[this.idSchema];return r&&`${r[a]}`===e&&r.resource===t}):null};getEntity=(t,e,i)=>{let r=I.nodeCache.get("ids");return r?Array.isArray(t)?[]:null:Array.isArray(t)?r.filter(a=>{let s=D[i];return a&&t.includes(`${a[s]}`)&&a.resource===e}):r.find(a=>{let s=D[i];return a&&`${a[s]}`===t&&a.resource===e})};checkForExistingIdObjs=(t,e)=>{let i=D[e],r={};return Object.keys(t).forEach(a=>{let s=t[a],n=this.getEntity(s,a,e).map(c=>c[i]),p=t[a].filter(c=>!n.includes(c));r[a]=s.map(c=>p.includes(c)?{id:c,exists:!1}:{id:c,exists:!0})}),r};getIdsByType=(t,e,i)=>{let r=D[i],a=D[e],s=I.nodeCache.get("ids"),l={};return s?(Object.keys(t).forEach(n=>{let p=t[n],c=[];s.forEach(u=>{p.forEach((d,M)=>{d===u[a]&&n===u.resource&&(c[M]=u[r])})}),l[n]=c}),l):null};addIdMapping=t=>{let e=I.nodeCache.get("ids");e.push(t),I.nodeCache.set("ids",e)};addIdMappings=t=>{let e=I.nodeCache.get("ids");e=[...e,...t],I.nodeCache.set("ids",e)};addTopIdMappings=t=>{let e=I.nodeCache.get("ids"),i=604800;if(e){let r=JSON.parse(JSON.stringify(e));r=r.filter(a=>a.resource!=="match"),t=t.filter(a=>a.resource==="match"),r=[...r,...t],I.nodeCache.set("ids",r)}else I.nodeCache.set("ids",t);this.idMappingsExpiration=Math.floor(Date.now()/1e3)+i};setOwnProfile=t=>I.nodeCache.set("profile",t,this.profileTTL);getOwnProfile=()=>I.nodeCache.get("profile");getProfileCountries=()=>I.nodeCache.get("profile_countries");setProfileCountries=t=>I.nodeCache.set("profile_countries",t);getProfileStats=()=>I.nodeCache.get("profile_stats");setProfileStats=t=>I.nodeCache.set("profile_stats",t,this.profileTTL);getProfileBadges=()=>I.nodeCache.get("profile_badges");setProfileBadges=t=>{I.nodeCache.set("profile_badges",t,this.profileBadgesTTL)};getFootballCountries=()=>I.nodeCache.get("football_countries");setFootballCountries=t=>I.nodeCache.set("football_countries",t);getCompetitions=t=>{let e=I.nodeCache.get("football_competitions");return e?t?t.competitionSearchFilter(e):e:null};setCompetitions=t=>I.nodeCache.set("football_competitions",t);getCompetitionsLength=()=>{let t=I.nodeCache.get("football_competitions");return t?t.length:0};getClientFeatures=()=>I.nodeCache.get("client");setClientFeatures=t=>I.nodeCache.set("client",t,this.clientTTL);deleteClientFeatures=()=>I.nodeCache.del("client");getExpiration=(t,e)=>{let i=this.getKeyFromExpirationType(e);return i==="ids"?this.idMappingsExpiration:I.nodeCache.getTtl(i)};getKeyFromExpirationType=t=>{switch(t){case"profile":return"profile";case"statistics":return"profile_stats";case"badges":return"profile_badges";case"features":return"client";case"ids":return"ids"}}},zt=I;ot(zt,"instance"),ot(zt,"nodeCache",new Ml.default);var K=class{createLocalCacheInstance=t=>typeof window>"u"?zt.getInstance(t):ui.getInstance(t)};var Bi=class{localCache=null;https=null;constructor(t){this.localCache=new K().createLocalCacheInstance(t.idSchema),this.https=new Di(t)}getEntitiesByIds=async(t,e,i)=>{await this.setTopIdMappings();try{let r=this.localCache.checkForExistingIdObjs(t,e),a=this.splitForRequestAndExisting(r),s=await this.https.getEntitiesByIdObjs(a.request,e);return this.localCache.addIdMappings(s),this.localCache.getIdsByType(t,e,i)}catch(r){return console.warn("There was a problem retrieving the entity ids ",r),Promise.resolve([])}};getEntityById=async(t,e,i)=>{let r=this.localCache.getEntity(t,e,i);if(r)return r;let a=await this.requestEntity(t,e,i);return this.localCache.addIdMappings(a),a&&a.length>0?a[0]:null};splitForRequestAndExisting=t=>{let e={},i={};return Object.keys(t).forEach(r=>{e[r]=t[r].filter(a=>!a.exists).map(a=>a.id),i[r]=t[r].filter(a=>a.exists).map(a=>a.id)}),{existing:i,request:e}};requestEntity=async(t,e,i)=>{try{return t=Array.isArray(t)?t:[t],await this.https.getEntitiesByIds(e,t,i)}catch(r){return console.warn(`There was a problem retrieving the requested entity: ${r}`),null}};setTopIdMappings=async()=>{let t=Math.floor(Date.now()/1e3);if(this.localCache.getExpiration("football","ids")>t)return Promise.resolve();let i=await this.https.getTopEntities();this.localCache.addTopIdMappings(i)}};var Tn=o=>{switch(o){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 o}};var Ni=class{extractedObjIds={};traverse=(t,e)=>(e=Tn(e),Array.isArray(t)?this.traverseArrExtract(t,e):t&&typeof t=="object"&&this.traverseObjExtract(t,e),this.extractedObjIds);traverseArrExtract=(t,e)=>{t&&t.length>0&&t.forEach(i=>{this.traverseObjExtract(i,e)})};traverseObjExtract=(t,e)=>{t&&Object.keys(t).length>0&&Object.keys(t).forEach(i=>{let r=t[i];i==="id"||i==="teamId"?(this.extractedObjIds.hasOwnProperty(e)||(this.extractedObjIds[e]=[]),r&&this.extractedObjIds[e].push(r)):t[i]&&this.traverse(t[i],i)})}};var ki=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(t,e,i)=>(e=Tn(e),this.replaceObjIdsIndex===null&&(this.initReplaceObjIdsIndex(i),this.remappedIdsObj=i),Array.isArray(t)?this.traverseArrReplace(t,e):t&&typeof t=="object"&&this.traverseObjReplace(t,e),t);initReplaceObjIdsIndex=t=>{this.replaceObjIdsIndex={},Object.keys(t).forEach(e=>{this.replaceObjIdsIndex[e]=0})};traverseArrReplace=(t,e)=>{t&&t.length>0&&t.forEach(i=>{this.traverseObjReplace(i,e)})};traverseObjReplace=(t,e)=>{t&&Object.keys(t).length>0&&Object.keys(t).forEach(i=>{i==="id"||i==="teamId"?t[i]&&(t[i]=this.remappedIdsObj[e][this.replaceObjIdsIndex[e]],this.replaceObjIdsIndex[e]=this.replaceObjIdsIndex[e]+1):t[i]&&this.traverse(t[i],i,this.remappedIdsObj)})}};var P=class{idSchema="";idMappingFacade=null;constructor(t){this.idSchema=t.idSchema,this.idMappingFacade=new Bi(t)}getEntityIdBySchemaId=(t,e)=>this.idMappingFacade.getEntityById(e,t,this.idSchema);remapEntities=async(t,e)=>{let i=JSON.parse(JSON.stringify(t));try{if(this.idSchema!=="native"){let a=new Ni().traverse(i,e);return this.idMappingFacade.getEntitiesByIds(a,"native",this.idSchema).then(s=>new ki().traverse(i,e,s))}else return t}catch(r){return console.warn(`There was a problem remapping entity: ${e} with inner entity `,r),[]}};getEntityIdsBySchemaId=async(t,e,i)=>{let r={};return r[e]=t,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(r,this.idSchema,i):r}};var q=class{completed=!1;percentage;constructor(t){this.percentage=t}};var Ui=class{teamFollowed=new q(10);teamFavourite=new q(15);playerFollowed=new q(10);playerFavourite=new q(10);competitionFollowed=new q(10);competitionFavourite=new q(5);addedBirthdate=new q(10);addedGender=new q(10);addedCountry=new q(10);addedAvatar=new q(10)};var Gi=class{totalPercentage;breakdown=new Ui};var mi=class{limit=0;startAfter=null;constructor(t){this.limit=t.limit?t.limit:20,this.startAfter=t.startAfter?t.startAfter:null}constructFilterUrl=()=>{let t="";return this.limit&&(t=t+"&",t=t+`limit=${this.limit}`),this.startAfter&&(t=t+"&",t=t+`start_after=${this.startAfter}`),t}};var lt=class{localCache;profileHttps=null;activityHttps=null;constructor(t,e,i){this.localCache=t,this.profileHttps=e,this.activityHttps=i}getOwn=async()=>{let t=this.getLocalStorageData("profile");if(t&&Object.keys(t).length)return JSON.parse(JSON.stringify(t));try{let e=await this.profileHttps.getProfile();return this.localCache.setOwnProfile(e),e}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};getOwnProfileFromCache=()=>this.localCache.getOwnProfile();updateOwnProfile=async()=>{try{let t=await this.profileHttps.getProfile();return this.localCache.setOwnProfile(t),t}catch(t){throw console.warn("There was a problem retrieving your profile: ",t),t}};getByIds=async(t,e,i)=>{if(t&&t.length>0&&e||!t&&t.length===0&&!e)throw new m(400,"invalid_method_call","The method 'getByIds' from Profile namespace is not called correctly. You need to provide 'profileIds' OR 'search' parameters to the method, but you can't use both of them or neither of them.");try{return await this.profileHttps.getProfiles(t,e,i)}catch(r){throw console.warn(`There was a problem retrieving the selected profiles: ${t.join(",")} `,r),r}};getById=async t=>{try{return await this.profileHttps.getProfile(t)}catch(e){throw console.warn(`There was a problem retrieving the selected profile: ${t} `,e),e}};getCountries=async t=>{t=t||!1;let e=this.localCache.getProfileCountries();if(e&&e.length>0)return e;try{let i=await this.profileHttps.getCountries(t);return this.localCache.setProfileCountries(i),i}catch(i){throw console.warn("There was a problem retrieving profile countries: ",i),i}};getFollowers=async(t,e)=>{try{t&&(t=new mi(t));let i=await this.profileHttps.getFollowers(t,e),r=i.data.map(a=>a.followerId);if(r.length){let a=await this.getByIds(r),s=i.data.map(l=>(a.forEach(n=>{l.followerId===n.id&&(l.name=n.name,l.nickname=n.nickname,l.avatar=n.avatar)}),l));return i.data=s,i}return i}catch(i){throw console.warn("There was a problem retrieving your followers: ",i),i}};getFollowing=async(t,e)=>{try{t&&(t=new mi(t));let i=await this.profileHttps.getFollowing(t,e),r=i.data.map(a=>a.followingId);if(r.length){let a=await this.getByIds(r),s=i.data.map(l=>(a.forEach(n=>{l.followingId===n.id&&(l.name=n.name,l.nickname=n.nickname,l.avatar=n.avatar)}),l));return i.data=s,i}return i}catch(i){throw console.warn("There was a problem retrieving your following profiles: ",i),i}};follow=async t=>{try{return await this.profileHttps.follow(t)}catch(e){throw console.warn(`There was a problem following profiles: ${t.join(",")} `,e),e}};unfollow=async t=>{try{return await this.profileHttps.unfollow(t)}catch(e){throw console.warn(`There was a problem unfollowing profiles: ${t.join(",")} `,e),e}};showFullnessProfile=t=>{let e=new Gi,i=0;return t.avatar&&(e.breakdown.addedAvatar.completed=!0,i+=e.breakdown.addedAvatar.percentage),t.birthDate&&(e.breakdown.addedBirthdate.completed=!0,i+=e.breakdown.addedBirthdate.percentage),t.country&&(e.breakdown.addedCountry.completed=!0,i+=e.breakdown.addedCountry.percentage),t.gender&&(e.breakdown.addedGender.completed=!0,i+=e.breakdown.addedGender.percentage),t.interests&&t.interests.length>0&&(t.interests.find(c=>c.type==="team"&&c.favourite)&&(e.breakdown.teamFavourite.completed=!0,i+=e.breakdown.teamFavourite.percentage),t.interests.find(c=>c.type==="team")&&(e.breakdown.teamFollowed.completed=!0,i+=e.breakdown.teamFollowed.percentage),t.interests.find(c=>c.type==="player"&&c.favourite)&&(e.breakdown.playerFavourite.completed=!0,i+=e.breakdown.playerFavourite.percentage),t.interests.find(c=>c.type==="player")&&(e.breakdown.playerFollowed.completed=!0,i+=e.breakdown.playerFollowed.percentage),t.interests.find(c=>c.type==="competition"&&c.favourite)&&(e.breakdown.competitionFavourite.completed=!0,i+=e.breakdown.competitionFavourite.percentage),t.interests.find(c=>c.type==="competition")&&(e.breakdown.competitionFollowed.completed=!0,i+=e.breakdown.competitionFollowed.percentage)),e.totalPercentage=i,e};getStats=async()=>{let t=this.getLocalStorageData("statistics");if(t&&Object.keys(t).length)return JSON.parse(JSON.stringify(t));try{let e=await this.activityHttps.getStats();return this.localCache.setProfileStats(e),e}catch(e){throw console.warn("There was a problem retrieving own profile statistics: ",e),e}};getBadges=async t=>{if(t)try{return await this.profileHttps.getBadges()}catch(i){throw console.warn("There was a problem retrieving own profile badges: ",i),i}let e=this.getLocalStorageData("badges");if(e)return e;try{let i=await this.profileHttps.getBadges();return this.localCache.setProfileBadges(i),i}catch(i){throw console.warn("There was a problem retrieving own profile badges: ",i),i}};clearLocalStorageData=()=>{this.localCache.setOwnProfile({}),this.localCache.setProfileStats({}),this.localCache.setProfileBadges(null)};getLocalStorageData=t=>{let e=Math.floor(Date.now()/1e3),i=this.localCache.getExpiration("profile",t);switch(t){case"profile":if(i>e)return this.localCache.getOwnProfile();case"statistics":if(i>e)return this.localCache.getProfileStats();case"badges":if(i>e)return this.localCache.getProfileBadges();default:return null}}};var Vi=class{id=null;name=null;assets=null};var Hi=class{extractUpdatedProps=(t,e)=>{let i=["name","nickname","gender","avatar"],r={};return Object.keys(t).forEach(a=>{if(i.includes(a)&&t[a]!==e[a])r[a]=e[a];else if(a==="birthDate")(e[a]===null||t[a]===null&&e[a]||t[a]!==e[a])&&(r.birth_date=e[a]);else if(a==="country")e[a]===null?r.country_id=e[a]:(t[a]===null&&e[a]||t[a].id!==e[a].id)&&(r.country_id=e[a].id);else if(a==="interests"){let s=t[a],l=e[a];l.length&&this.isNewInterest(s,l)?r[a]=this.updateInterests(s,l):(!l.length&&s.length||s.length!==l.length&&!this.isNewInterest(s,l))&&(r[a]=l)}}),r};updateInterests=(t,e)=>{if(t.length===e.length){let[i,r]=this.extractSameAndNewInterests(t,e);return[...r,...i]}else return e};isNewInterest=(t,e)=>{let i=!1,[r]=this.extractSameAndNewInterests(t,e);return r.length&&(i=!0),i};extractSameAndNewInterests=(t,e)=>{let i=e.filter(a=>t.some(s=>a.id===s.id&&a.type===s.type&&a.source===s.source&&a.favourite===s.favourite));return[e.filter(a=>!t.some(s=>a.id===s.id&&a.type===s.type&&a.source===s.source&&a.favourite===s.favourite)),i]};isAvatarValidURL=t=>{try{return new URL(t),!0}catch{return!1}}};var f=class extends Error{code=0;status=null;message=null;constructor(t,e,i){super(),this.code=t,this.status=e,this.message=i}errorMessage=()=>this.message};var $i=class{idsRemapper=null;profileHttps=null;profileService=null;localCache=null;profileFacade=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;configuration=null;constructor(t,e,i,r,a){this.configuration=t,this.idsRemapper=e,this.localCache=i,this.profileHttps=r,this.profileService=new Hi,this.profileFacade=new lt(i,r,a)}getOwnProfile=async()=>{for(;this.isFetching;)console.log("Another thread is fetching profile..."),await this.delay(100);if(this.modified&&this.ownProfile)return console.log("Timestamp is less than 10 minutes OR profile is modifying "),this.ownProfile;let t=Math.floor(Date.now()/1e3);if(this.clearAllProfileData(),!this.ownProfile||this.expireAt<t){this.isFetching=!0,this.expireAt=Math.floor(Date.now()/1e3)+600;try{let e=await this.profileFacade.getOwn();this.setOwnProfile(e)}catch(e){throw this.isFetching=!1,e}return this.modified=!1,this.isFetching=!1,this.ownProfile}return this.ownProfile};delay=t=>new Promise(e=>{setTimeout(e,t)});setOwnProfile=t=>{this.ownProfile=t};getInfo=async()=>{let t=await this.getOwnProfile(),e=JSON.parse(JSON.stringify(t));return delete e.interests,e};showInterests=async()=>{let t=await this.getOwnProfile(),e=JSON.parse(JSON.stringify(t));return await this.idsRemapper.remapInterests(e.interests)};showFullInterests=async()=>{let t=await this.getOwnProfile(),e=JSON.parse(JSON.stringify(t));return await this.idsRemapper.showFullInterests(e.interests)};getFollowers=async t=>await this.profileFacade.getFollowers(t);getFollowing=async t=>await this.profileFacade.getFollowing(t);follow=async t=>{let e=await this.profileFacade.follow(t),i=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(i),e};unfollow=async t=>{let e=await this.profileFacade.unfollow(t),i=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(i),e};getStats=async()=>{this.clearAllProfileData();let t=await this.profileFacade.getStats();return await this.idsRemapper.remapProfileStats(t)};getBadges=async t=>(this.clearAllProfileData(),await this.profileFacade.getBadges(t));addInterestPromise=async t=>{this.modified=!0;let e={...t};await this.getOwnProfile();let i=null;t.source!=="custom"?i=await this.idsRemapper.remapInterestToNative(e):i=e;let r=this.ownProfile.interests.filter(a=>a.id!==i.id||a.type!==i.type||a.source!==i.source);return this.ownProfile.interests=[...r],this.ownProfile.interests.push(i),this};addInterest=t=>(this.promises.push(this.addInterestPromise(t)),this);removeInterestPromise=async t=>{this.modified=!0;let e={...t};await this.getOwnProfile();let i=null;return t.source!=="custom"?i=await this.idsRemapper.remapInterestToNative(e):i=e,this.ownProfile.interests=this.ownProfile.interests.filter(r=>r.id!==i.id||r.type!==i.type||r.source!==i.source),this};removeInterest=t=>(this.promises.push(this.removeInterestPromise(t)),this);setBirthdatePromise=async t=>(this.modified=!0,await this.getOwnProfile(),t?this.ownProfile.birthDate=t:this.ownProfile.birthDate=null,this);setBirthdate=t=>(this.promises.push(this.setBirthdatePromise(t)),this);setGenderPromise=async t=>(this.modified=!0,await this.getOwnProfile(),t==="male"||t==="female"?this.ownProfile.gender=t:this.ownProfile.gender="unspecified",this);setGender=t=>(this.promises.push(this.setGenderPromise(t)),this);setNicknamePromise=async t=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.nickname=t,this);setNickname=t=>(this.promises.push(this.setNicknamePromise(t)),this);setNamePromise=async t=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.name=t,this);setName=t=>(this.promises.push(this.setNamePromise(t)),this);setCountryPromise=async t=>(this.modified=!0,await this.getOwnProfile(),t&&!this.ownProfile.country?(this.ownProfile.country=new Vi,this.ownProfile.country.id=t):t&&this.ownProfile.country?this.ownProfile.country.id=t:this.ownProfile.country=null,this);setCountry=t=>(this.promises.push(this.setCountryPromise(t)),this);showFullnessProfile=async()=>{let t=await this.getOwnProfile(),e=JSON.parse(JSON.stringify(t));return this.profileFacade.showFullnessProfile(e)};setAvatarPromise=async t=>{if(this.modified=!0,await this.getOwnProfile(),this.profileService.isAvatarValidURL(t))this.ownProfile.avatar=t;else{if(this.configuration.errorHandlingMode==="default")throw new f(400,"invalid_avatar","Invalid URL syntax for avatar image.");if(this.configuration.errorHandlingMode==="standard")throw new m(400,"invalid_avatar","Invalid URL syntax for avatar image.")}return this};setAvatar=t=>(this.promises.push(this.setAvatarPromise(t)),this);update=async()=>{if(this.promises.length===0)return this.ownProfile;await Promise.all(this.promises);let t=await this.profileFacade.getOwn(),e=await this.getOwnProfile(),i=this.profileService.extractUpdatedProps(t,e);if(this.modified=!1,this.expireAt=0,Object.keys(i).length){let a=await this.profileHttps.updateProfile(i),s=JSON.parse(JSON.stringify(a));return this.setOwnProfile(s),this.localCache.setOwnProfile(s),delete a.interests,a}let r=JSON.parse(JSON.stringify(this.ownProfile));return delete r.interests,r};clearAllProfileData=()=>{this.isNewProfileRequested()&&this.profileFacade.clearLocalStorageData()};isNewProfileRequested=()=>{let t=this.extractUserIdFromToken();if(!t)return!1;if(!this.ownProfile){let e=this.profileFacade.getOwnProfileFromCache();return!!(e&&Object.keys(e).length&&e.id!==t)}return this.ownProfile.id!==t};extractUserIdFromToken=()=>{try{return bn(this.configuration.authProvider.getIdToken())?.sub||""}catch(t){return console.error(t),""}}};var Wi=class{idsRemapper=null;profileHttps=null;activityHttps=null;profileFacade=null;profileId="";constructor(t,e,i,r){this.idsRemapper=t,this.profileHttps=i,this.activityHttps=r,this.profileFacade=new lt(e,i,r)}setId=t=>(this.profileId=t,this);getProfile=async()=>await this.profileFacade.getById(this.profileId);getInfo=async()=>{let t=await this.getProfile();return delete t.interests,t};showInterests=async()=>{let t=await this.getProfile(),e=JSON.parse(JSON.stringify(t));return await this.idsRemapper.remapInterests(e.interests)};showFullInterests=async()=>{let t=await this.getProfile(),e=JSON.parse(JSON.stringify(t));return await this.idsRemapper.showFullInterests(e.interests)};getFollowers=async t=>await this.profileFacade.getFollowers(t,this.profileId);getFollowing=async t=>await this.profileFacade.getFollowing(t,this.profileId);showFullnessProfile=async()=>{let t=await this.getProfile();return this.profileFacade.showFullnessProfile(t)};getStats=async t=>{let e=await this.activityHttps.getStats(this.profileId,t);return await this.idsRemapper.remapProfileStats(e)};getBadges=async()=>await this.profileHttps.getBadges(this.profileId)};var zi=class{localCache=null;https=null;idMapping=null;constructor(t,e,i){this.localCache=t,this.idMapping=i,this.https=e}getCountriesWithIdMapping=async t=>{try{let e=await this.getCountries(t);return this.idMapping.remapEntities(e,"country")}catch(e){throw console.warn("There was a problem browsing countries as football entities",e),e}};getCountries=async t=>{t=t||!1;let e=this.localCache.getFootballCountries();if(e&&e.length>0)return e;try{let i=await this.https.getCountries(t);return this.localCache.setFootballCountries(i),i}catch(i){throw console.warn("There was a problem retrieving countries as football entities",i),i}}};var hi=class{countryId=null;name=null;gender=null;type=null;sortField=null;sortOrder=null;competitionIds=null;constructor(t){this.countryId=t.countryId?`${t.countryId}`:null,this.name=t.name?t.name:null,this.gender=t.gender?t.gender:null,this.type=t.type?t.type:null,this.sortField=t.sortField?`${t.sortField}`:null,this.sortOrder=t.sortOrder?`${t.sortOrder}`:null,this.competitionIds=t.competitionIds?t.competitionIds:null}constructFilterUrl=()=>{let t="";return this.countryId&&(t=t+"&",t=t+`country_id=${this.countryId}`),this.gender&&(t=t+"&",t=t+`gender=${this.gender}`),this.type&&(t=t+"&",t=t+`type=${this.type}`),this.sortField&&(t=t+"&",t=t+`sort_field=${this.sortField}`),this.sortOrder&&(t=t+"&",t=t+`sort_order=${this.sortOrder}`),this.name&&(t=t+"&",t=t+`name=${this.name}`),this.competitionIds&&this.competitionIds.length>0&&(t=t+"&",t=t+`competition_ids=${this.competitionIds.join(",")}`),t};competitionSearchFilter=t=>{try{let e=this.filter(t);return this.sortField||this.sortOrder?this.sort(e):e}catch(e){return console.warn("There was a problem filtering the local competitions",e),[]}};filter=t=>{let e=this.entitiesToSearchWith();return t.filter(i=>{let r=!0;return e.forEach(a=>{a!=="sortOrder"&&a!=="sortField"&&(a==="countryId"?r&&=i.country.id===this[a]:a==="name"?r&&=i.name.toLocaleLowerCase().includes(this[a].toLocaleLowerCase()):a==="competitionIds"?r&&=this[a].some(s=>i.id===s):r&&=i[a].toLocaleLowerCase()===this[a].toLocaleLowerCase())}),r})};entitiesToSearchWith=()=>{let t=[];return this.countryId&&t.push("countryId"),this.name&&t.push("name"),this.gender&&t.push("gender"),this.type&&t.push("type"),this.sortField&&t.push("sortField"),this.sortOrder&&t.push("sortOrder"),this.competitionIds&&t.push("competitionIds"),t};sort=t=>{let e=[];return this.sortField==="name"?e=t.sort((i,r)=>this.sortOrder&&this.sortOrder==="desc"?r.name.localeCompare(i.name):i.name.localeCompare(r.name)):this.sortField==="country"?e=t.sort((i,r)=>this.sortOrder&&this.sortOrder==="desc"?r.country.name.localeCompare(i.country.name):i.country.name.localeCompare(r.country.name)):this.sortField==="scope"?t.forEach(i=>e[this.competitionIds.indexOf(i.id)]=i):!this.sortField&&this.sortOrder==="desc"&&(e=t.sort((i,r)=>r.id.localeCompare(i.id))),e}};var qi=class{localStorage=null;https=null;idMapping=null;constructor(t,e,i){this.localStorage=t,this.idMapping=i,this.https=e}getCompetitionsIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new hi(t),t.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([`${t.countryId}`],"country","native");a.country.length===0&&(i=!0),t.countryId=a.country[0]}if(t.competitionIds){let a=await this.idMapping.getEntityIdsBySchemaId(t.competitionIds,"competition","native");a.competition.length===0&&(i=!0),t.competitionIds=a.competition}if(i)return[]}let r=await this.getCompetitions(t,e);return await this.idMapping.remapEntities(r,"competition")}catch(i){throw console.warn("There was a problem browsing all of the competitions",i),i}};getCompetitionsMapWithNativeIds=async t=>{let e=new Map,i=t.length,r=new hi({competitionIds:t,limit:i}),a=await this.getCompetitions(r);a.sort((n,p)=>n.id.localeCompare(p.id));let s=fn(t),l=await this.idMapping.remapEntities(a,"competition");return s.forEach((n,p)=>e.set(n,l[p])),e};getCompetitions=async(t,e)=>{let i=null;if(e=e||!1,!this.localStorage.getCompetitionsLength()){try{i=await this.https.getCompetitions()}catch(r){throw console.warn("There was a problem retrieving all competitions",r),r}this.localStorage.setCompetitions(i)}return this.localStorage.getCompetitions(t)};getCompetitionByIdIdMapping=async(t,e)=>{try{let r=(await this.idMapping.getEntityIdsBySchemaId([t],"competition","native")).competition[0],a=await this.getCompetitionById(r,e);return await this.idMapping.remapEntities(a,"competition")}catch(i){throw console.warn(`There was a problem browsing the following competition:${t}`,i),i}};getCompetitionById=async(t,e)=>{try{return e=e||!1,await this.https.getCompetitionById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the competition with the following id: ${t}`,i),i}};getTopCompetitionsIdMapping=async t=>{try{let e=await this.getTopCompetitions(t);return await this.idMapping.remapEntities(e,"competition")}catch(e){throw console.warn("There was a problem browsing the top competitions",e),e}};getTopCompetitions=async t=>{try{return t=t||!1,await this.https.getTopCompetitions(t)}catch(e){throw console.warn("There was a problem retrieving the top competitions",e),e}}};var gi=class{name=null;countryId=null;national=!1;gender=null;limit=null;page=null;scope=null;sortField=null;sortOrder=null;teamIds=null;constructor(t){this.name=t.name?t.name:null,this.countryId=t.countryId?`${t.countryId}`:null,this.national=t.national?t.national:!1,this.gender=t.gender?t.gender:null,this.limit=t.limit?t.limit:null,this.page=t.page?t.page:null,this.scope=t.scope?t.scope:null,this.sortField=t.sortField?`${t.sortField}`:null,this.sortOrder=t.sortOrder?`${t.sortOrder}`:null,this.teamIds=t.teamIds?t.teamIds:null}constructFilterUrl=()=>{let t="";return this.name&&(t=t+"&",t=t+`name=${this.name}`),this.countryId&&(t=t+"&",t=t+`country_id=${this.countryId}`),this.national&&(t=t+"&",t=t+`national=${this.national}`),this.gender&&(t=t+"&",t=t+`gender=${this.gender}`),this.limit&&(t=t+"&",t=t+`limit=${this.limit}`),this.scope&&this.scope.length>0&&(t=t+"&",t=t+`scope=${this.scope.join(",")}`),this.page&&(t=t+"&",t=t+`page=${this.page}`),this.sortField&&(t=t+"&",t=t+`sort_field=${this.sortField}`),this.sortOrder&&(t=t+"&",t=t+`sort_order=${this.sortOrder}`),this.teamIds&&this.teamIds.length>0&&(t=t+"&",t=t+`team_ids=${this.teamIds.join(",")}`),t}};var Qi=class{reason="";words=[]};var qt=class{enabled=!1;moderateLinks=!1;linksWhitelist=[];moderatorProfileId="";dictionary=new Qi};var Ki=class{enabled=!1;clientId=null;automaticModeration=new qt};var Mt=class{points=null;gameParticipationCount=null;entityId=null;entityType=null;predictionsMade=null;correctPredictions=null};var ji=class{id;weight;multiplier;conditions};var Qt=class{value=[new ji]};var Kt=class{points=null;tiers=null;badges=null};var Xi=class{enabled=!1;clientId=null;conditions={list:null};actions=new Qt;rewards=new Kt};var Yi=class{general=null;predictor=null;activity=null;topX=null;matchQuiz=null;discussionPost=null};var jt=class{enabled=!1;clientId=null;defaultMarkets=null;competitionsWhitelist=null};var Xt=class{enabled=!1;clientId=null;minFixtures=null;maxFixtures=null;competitionsWhitelist=null};var Ji=class{competitions=[];teams=[];markets=[]};var Yt=class{enabled=!1;clientId=null;fullCoverageCompetitions=null;markets=null;successRateScopes=new Ji;userDataConfig=null};var Zi=class{storeIp=!1;storeDeviceId=!1;storeAgent=!1};var tr=class{potm=[];poll=[]};var er=class{predictor=[];topX=[];matchQuiz=[];games=[];football=[];classicQuizzes=[];eitherOr=[];discussions=[];voting=new tr};var B=class{id;label;description;flags;assets={mainImageUrl:""};enabled};var ir=class{predictionsNumber;correctPredictions;points;fromDate;toDate};var rr=class extends B{requirements=new ir};var ar=class{participationCount;points;fromDate;toDate};var or=class extends B{requirements=new ar};var sr=class{participationCount;points;specificGames;fromDate;toDate};var nr=class extends B{requirements=new sr};var lr=class{predictionsNumber;correctPredictions;points;entityId;entityType;entityModel=null};var pr=class extends B{requirements=new lr};var cr=class{participationCount;fromDate;toDate};var ur=class extends B{requirements=new cr};var dr=class{totalDiscussionPoints;postsCount;postPoints;reactionsCount};var mr=class extends B{requirements=new dr};var hr=class{points;voteCount;entityId;entityType;entityModel};var gr=class extends B{requirements=new hr};var Jt=class{points=null;tiers=null;badges=null};var fr=class{enabled=!1;clientId=null;conditions={list:null};actions=new Qt;rewards=new Jt};var yr=class{general=[];predictor=[];topX=[];matchQuiz=[]};var br=class{id;label;assets={mainImageUrl:""};enabled;requirements=new Mt};var Zt=class extends Mt{postPoints=null;postsCount=null;reactionsCount=null;totalDiscussionPoints=null};var Mr=class{id;label;assets={mainImageUrl:""};enabled;requirements=new Zt};var te=class{assists=null;shots=null;offsides=null;tackles=null;saves=null;minutesEqualOrOver60=null;minutesUnder60=null;yellowCards=null;redCards=null;goalsGoalkeeper=null;goalsDefender=null;goalsMidfielder=null;goalsForwards=null;penaltyGoals=null;ownGoals=null;cleanSheetsGoalkeeper=null;cleanSheetsDefender=null;cleanSheetsMidfielder=null;cleanSheetsForwards=null;shotsOn=null;foulsCommitted=null;penaltyCommitted=null;penaltyWon=null;penaltyMissed=null;concededGoals=null;caughtBall=null};var ee=class{total=null;minGoalkeepers=null;maxGoalkeepers=null;minDefenders=null;maxDefenders=null;minMidfielders=null;maxMidfielders=null;minStrikers=null;maxStrikers=null};var wr=class{enabled=!1;clientId=null;addPointsToProfileTotal=!1;coefficients=new te;players=new ee;competitionsWhitelist=[]};var Ir=class{remapPredictorConfig=t=>{let e=new Yt;return e.enabled=t.enabled,e.clientId=t.client_id,e.fullCoverageCompetitions=t.full_coverage_competitions,e.markets=t.markets,e.successRateScopes=t.success_rate_scopes,e.userDataConfig=t.user_data_config?this.remapUserDataConfig(t.user_data_config):null,e};remapTopXConfig=t=>{let e=new Xt;return e.enabled=t.enabled,e.clientId=t.client_id,e.minFixtures=t.min_fixtures,e.maxFixtures=t.max_fixtures,e.competitionsWhitelist=t.competitions_whitelist,e};remapMatchQuizConfig=t=>{let e=new jt;return e.enabled=t.enabled,e.clientId=t.client_id,e.defaultMarkets=t.default_markets,e.competitionsWhitelist=t.competitions_whitelist,e};remapLoyaltyConfig=t=>{let e=new Xi;return e.enabled=t.enabled,e.clientId=t.client_id,e.conditions.list=t.conditions.list,e.actions.value=t.actions.value,e.rewards=this.remapRewards(t.rewards),e};remapLoyaltyNewConfig=t=>{let e=new fr;return e.enabled=t.enabled,e.clientId=t.client_id,e.conditions.list=t.conditions.list,e.actions.value=t.actions.value,e.rewards=this.remapNewRewards(t.rewards),e};remapDiscussionsConfig=t=>{let e=new Ki;return e.enabled=t.enabled,e.clientId=t.client_id,e.automaticModeration=t.automatic_moderation?this.remapAutomaticModeration(t.automatic_moderation):null,e};remapFantasyConfig=t=>{let e=new wr;return e.enabled=t.enabled,e.clientId=t.client_id,e.addPointsToProfileTotal=t.add_points_to_profile_total,e.competitionsWhitelist=t.competitions_whitelist,e.players=this.remapFantasyPlayers(t.players),e.coefficients=this.remapFantasyCoefficients(t.coefficients),e};remapFantasyPlayers=t=>{let e=new ee;return e.total=t.total,e.minGoalkeepers=t.min_goalkeepers,e.maxGoalkeepers=t.max_goalkeepers,e.minDefenders=t.min_defenders,e.maxDefenders=t.max_defenders,e.minMidfielders=t.min_midfielders,e.maxMidfielders=t.max_midfielders,e.minStrikers=t.min_strikers,e.maxStrikers=t.max_strikers,e};remapFantasyCoefficients=t=>{let e=new te;return e.assists=t.assists,e.shots=t.shots,e.offsides=t.offsides,e.tackles=t.tackles,e.saves=t.saves,e.minutesEqualOrOver60=t.minutes_equal_or_over_60,e.minutesUnder60=t.minutes_under_60,e.yellowCards=t.yellow_cards,e.redCards=t.red_cards,e.goalsGoalkeeper=t.goals_goalkeeper,e.goalsDefender=t.goals_defender,e.goalsMidfielder=t.goals_midfielder,e.goalsForwards=t.goals_forwards,e.penaltyGoals=t.penalty_goals,e.ownGoals=t.own_goals,e.cleanSheetsGoalkeeper=t.clean_sheets_goalkeeper,e.cleanSheetsDefender=t.clean_sheets_defender,e.cleanSheetsMidfielder=t.clean_sheets_midfielder,e.cleanSheetsForwards=t.clean_sheets_forwards,e.shotsOn=t.shots_on,e.foulsCommitted=t.fouls_committed,e.penaltyCommitted=t.penalty_committed,e.penaltyWon=t.penalty_won,e.penaltyMissed=t.penalty_missed,e.concededGoals=t.conceded_goals,e.caughtBall=t.caught_ball,e};remapAutomaticModeration=t=>{let e=new qt;return e.enabled=t.enabled,e.moderateLinks=t.moderate_links,e.linksWhitelist=t.links_whitelist,e.moderatorProfileId=t.moderator_profile_id,e.dictionary=t.dictionary,e};remapNewRewards=t=>{let e=new Jt;return e.points=this.remapPoints(t.points),e.tiers=t.tiers,e.badges=this.remapNewBadges(t.badges),e};remapRewards=t=>{let e=new Kt;return e.points=this.remapPoints(t.points),e.tiers=t.tiers,e.badges=this.remapBadges(t.badges),e};remapPoints=t=>{let e=new Yi;return e.general=t.general,e.discussionPost=t.discussion_post,e.predictor=t.predictor,e.activity=t.activity,e.topX=t.top_x,e.matchQuiz=t.match_quiz,e};remapBadges=t=>{let e=new yr;return e.general=t.general?this.remapGeneralBadgeValues(t.general):[],e.predictor=this.remapBadgeValues(t.predictor),e.topX=this.remapBadgeValues(t.top_x),e.matchQuiz=this.remapBadgeValues(t.match_quiz),e};remapNewBadges=t=>{let e=new er;return e.predictor=this.remapBadgeValuesPredictor(t.predictor),e.topX=this.remapBadgeValuesGame(t.top_x),e.matchQuiz=this.remapBadgeValuesGame(t.match_quiz),t.games&&(e.games=this.remapBadgeValuesGames(t.games)),t.football&&(e.football=this.remapBadgeValuesFootball(t.football)),t.classic_quizzes&&(e.classicQuizzes=this.remapBadgeValuesMiniGames(t.classic_quizzes)),t.either_or&&(e.eitherOr=this.remapBadgeValuesMiniGames(t.either_or)),t.discussions&&(e.discussions=this.remapBadgeValuesDiscussions(t.discussions)),t.voting&&t.voting.potm&&(e.voting.potm=this.remapBadgeValuesVoting(t.voting.potm)),t.voting&&t.voting.poll&&(e.voting.poll=this.remapBadgeValuesVoting(t.voting.poll)),e};remapBadgeValuesPredictor=t=>t.map(e=>{let i=new rr;return i.id=e.id,i.enabled=e.enabled,i.label=e.label,i.description=e.description,i.flags=e.flags,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,e.requirements&&(i.requirements.predictionsNumber=e.requirements.predictions_number,i.requirements.correctPredictions=e.requirements.correct_predictions,i.requirements.points=e.requirements.points,i.requirements.fromDate=e.requirements.from_date,i.requirements.toDate=e.requirements.to_date),i});remapBadgeValuesGame=t=>t.map(e=>{let i=new or;return i.id=e.id,i.enabled=e.enabled,i.label=e.label,i.description=e.description,i.flags=e.flags,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,e.requirements&&(i.requirements.participationCount=e.requirements.participation_count,i.requirements.points=e.requirements.points,i.requirements.fromDate=e.requirements.from_date,i.requirements.toDate=e.requirements.to_date),i});remapBadgeValuesGames=t=>t.map(e=>{let i=new nr;return i.id=e.id,i.enabled=e.enabled,i.label=e.label,i.description=e.description,i.flags=e.flags,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,e.requirements&&(i.requirements.participationCount=e.requirements.participation_count,i.requirements.points=e.requirements.points,i.requirements.fromDate=e.requirements.from_date,i.requirements.toDate=e.requirements.to_date,i.requirements.specificGames=e.requirements.specific_games?this.remapSpecificGamesRequirement(e.requirements.specific_games):null),i});remapSpecificGamesRequirement=t=>t.map(e=>({gameId:e.game_id,gameType:e.game_type,gameModel:null}));remapBadgeValuesFootball=t=>t.map(e=>{let i=new pr;return i.id=e.id,i.enabled=e.enabled,i.label=e.label,i.description=e.description,i.flags=e.flags,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,e.requirements&&(i.requirements.predictionsNumber=e.requirements.predictions_number,i.requirements.correctPredictions=e.requirements.correct_predictions,i.requirements.points=e.requirements.points,i.requirements.entityId=e.requirements.entity_id,i.requirements.entityType=e.requirements.entity_type),i});remapBadgeValuesMiniGames=t=>t.map(e=>{let i=new ur;return i.id=e.id,i.enabled=e.enabled,i.label=e.label,i.description=e.description,i.flags=e.flags,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,e.requirements&&(i.requirements.participationCount=e.requirements.participation_count,i.requirements.fromDate=e.requirements.from_date,i.requirements.toDate=e.requirements.to_date),i});remapBadgeValuesDiscussions=t=>t.map(e=>{let i=new mr;return i.id=e.id,i.enabled=e.enabled,i.label=e.label,i.description=e.description,i.flags=e.flags,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,e.requirements&&(i.requirements.totalDiscussionPoints=e.requirements.total_discussion_points,i.requirements.postsCount=e.requirements.posts_count,i.requirements.postPoints=e.requirements.post_points,i.requirements.reactionsCount=e.requirements.reactions_count),i});remapBadgeValuesVoting=t=>t.map(e=>{let i=new gr;return i.id=e.id,i.enabled=e.enabled,i.label=e.label,i.description=e.description,i.flags=e.flags,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,e.requirements&&(i.requirements.points=e.requirements.points,i.requirements.voteCount=e.requirements.vote_count,i.requirements.entityId=e.requirements.entity_id,i.requirements.entityType=e.requirements.entity_type),i});remapBadgeValues=t=>t.map(e=>{let i=new br;return i.id=e.id,i.label=e.label,i.enabled=e.enabled,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,i.requirements=this.remapRequirements(e.requirements),i});remapRequirements=t=>{let e=new Mt;return e.points=t.points,e.gameParticipationCount=t.game_participation_count,e.entityId=t.entity_id,e.entityType=t.entity_type,e.predictionsMade=t.predictions_made,e.correctPredictions=t.correct_predictions,e};remapUserDataConfig=t=>{let e=new Zi;return e.storeIp=t.store_ip,e.storeDeviceId=t.store_device_id,e.storeAgent=t.store_agent,e};remapGeneralBadgeValues=t=>t.map(e=>{let i=new Mr;return i.id=e.id,i.label=e.label,i.enabled=e.enabled,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,i.requirements=this.remapGeneralRequirements(e.requirements),i});remapGeneralRequirements=t=>{let e=new Zt;return e.points=t.points,e.gameParticipationCount=t.game_participation_count,e.entityId=t.entity_id,e.entityType=t.entity_type,e.predictionsMade=t.predictions_made,e.correctPredictions=t.correct_predictions,e.postPoints=t.post_points,e.postsCount=t.posts_count,e.reactionsCount=t.reactions_count,e.totalDiscussionPoints=t.total_discussion_points,e}};var N=class extends T{featureConfigRemapper=null;localStorage=null;clientId=null;constructor(t){super(t,S(t.environment,"client")),this.clientId=t.clientId,this.localStorage=new K().createLocalCacheInstance(t.idSchema),this.featureConfigRemapper=new Ir}getConfig=async t=>{let e=this.getCachedFeatures();if(!e){let i=`/clients/${this.clientId}/features`,r=this.apiSignInUrl.split("&")[0],a=i+r,s="There was a problem fetching client features from Client API";e=(await this.fetchWithoutAuth(a,s)).data,this.localStorage.setClientFeatures(e)}switch(t){case"predictor":return this.featureConfigRemapper.remapPredictorConfig(e.predictor);case"topX":return this.featureConfigRemapper.remapTopXConfig(e.top_x);case"matchQuiz":return this.featureConfigRemapper.remapMatchQuizConfig(e.match_quiz);case"loyalty":return this.featureConfigRemapper.remapLoyaltyConfig(e.loyalty);case"discussions":return this.featureConfigRemapper.remapDiscussionsConfig(e.discussions);case"fantasy":return this.featureConfigRemapper.remapFantasyConfig(e.football_fantasy)}};getNewLoyaltyConfig=async t=>{let e=`/clients/${this.clientId}/features`,i=this.apiSignInUrl.split("&")[0],r="There was a problem fetching client features from Client API";if(t){let s=e+i+h(),l=await this.fetchWithoutAuthAdditionalHeaders(s,r,{"x-api-version":"2"});this.localStorage.setClientFeatures(l.data)}let a=this.getCachedFeatures();if(!a){let s=e+i;a=(await this.fetchWithoutAuthAdditionalHeaders(s,r,{"x-api-version":"2"})).data,this.localStorage.setClientFeatures(a)}return this.featureConfigRemapper.remapLoyaltyNewConfig(a.loyalty)};getCachedFeatures=()=>{let t=this.getLocalStorageData();if(!(!t||!Object.keys(t).length))return t.predictor.client_id&&t.predictor.client_id!==this.clientId?(this.localStorage.deleteClientFeatures(),null):t};getLocalStorageData=()=>{let t=Math.floor(Date.now()/1e3);return this.localStorage.getExpiration("client","features")>t?this.localStorage.getClientFeatures():null}};var V=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var H=class{pagination=new V};var pt=class{clientHttps=null;errorHandlingMode=null;constructor(t){this.clientHttps=new N(t),this.errorHandlingMode=t.errorHandlingMode}setAvailableMarketsForMatch=async t=>{let{fullCoverageCompetitions:e,markets:i}=await this.clientHttps.getConfig("predictor");if(Array.isArray(t))return t.map(r=>this.setAvailableMarkets(r,e,i));if(typeof t=="object"&&Object.keys(t).length)return this.setAvailableMarkets(t,e,i)};setAvailableMarkets=(t,e,i)=>{let r=t.context.competition?.id;return r&&this.isMatchInCoverageCompetition(r,e)?(t.availableMarkets=i.all,t):(t.availableMarkets=i.main,t)};setMetaDataBatchRequest=(t,e,i)=>{let r=new H;if(r.pagination.totalItems=t,r.pagination.itemsPerPage=e,r.pagination.numberOfPages=t?Math.ceil(t/e):0,r.pagination.currentPage=i,r.pagination.numberOfPages>0&&i>r.pagination.numberOfPages)throw this.errorHandlingMode==="standard"?new m(400,"invalid_page_number","Invalid page number provided. Use number between 1 and max number of pages."):new f(400,"invalid_page_number","Invalid page number provided. Use number between 1 and max number of pages.");return r};finalizeMatchesDataBatchRequest=(t,e)=>{t=t.sort((r,a)=>new Date(r.kickoffAt).getTime()-new Date(a.kickoffAt).getTime());let i=e.limit||20;if(e.page){let r=e.page>1?i*(e.page-1):0;t=t.slice(r,r+i)}return!e.page&&t.length>i&&(t=t.slice(0,i)),t};isMatchInCoverageCompetition=(t,e)=>{let i=!1;return e.includes(t)&&(i=!0),i}};var Pr=class{footballService=null;https=null;idMapping=null;constructor(t,e,i){this.idMapping=i,this.https=e,this.footballService=new pt(t)}getTeamsIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new gi(t),t.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([`${t.countryId}`],"country","native");a.country.length===0&&(i=!0),t.countryId=a.country[0]}if(t.scope){let a=await this.idMapping.getEntityIdsBySchemaId(t.scope,"competition","native");a.competition.length===0&&(i=!0),t.scope=a.competition}if(t.teamIds){let a=await this.idMapping.getEntityIdsBySchemaId(t.teamIds,"team","native");a.team.length===0&&(i=!0),t.teamIds=a.team}}if(i)return[];let r=await this.getTeams(t,e);return r.data=await this.idMapping.remapEntities(r.data,"team"),r}catch(i){throw console.warn("There was a problem browsing all teams",i),i}};getTeamsMapWithNativeIds=async t=>{let e=new Map,i=t.length,r=new gi({teamIds:t,limit:i}),{data:a}=await this.getTeams(r);a.sort((n,p)=>n.id.localeCompare(p.id));let s=fn(t),l=await this.idMapping.remapEntities(a,"team");return s.forEach((n,p)=>e.set(n,l[p])),e};getTeams=async(t,e)=>{try{return e=e||!1,await this.https.getTeams(t,e)}catch(i){throw console.warn("There was a problem retrieving all teams",i),i}};getTeamByIdIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"team","native")).team[0];let r=await this.getTeamById(t,e);return await this.idMapping.remapEntities(r,"team")}catch(i){throw console.warn(`There was a problem browsing the following team:${t}`,i),i}};getTeamById=async(t,e)=>{try{return e=e||!1,await this.https.getTeamById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the following team: ${t}`,i),i}};getTopTeamsIdMapping=async t=>{try{let e=await this.getTopTeams(t);return await this.idMapping.remapEntities(e,"team")}catch(e){throw console.warn("There was a problem browsing the top teams",e),e}};getTopTeams=async t=>{try{return t=t||!1,await this.https.getTopTeams(t)}catch(e){throw console.warn("There was a problem retrieving the top teams",e),e}};getNextMatchForTeamIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"team","native")).team[0];let r=await this.getNextMatchForTeam(t,e);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the next match for the following team:${t}`,i),i}};getNextMatchForTeam=async(t,e)=>{try{e=e||!1;let i=await this.https.getNextMatchForTeam(t,e);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the next match for the following team: ${t}`,i),i}};getPrevMatchForTeamIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"team","native")).team[0];let r=await this.getPrevMatchForTeam(t,e);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the previous match for the following team:${t}`,i),i}};getPrevMatchForTeam=async(t,e)=>{try{e=e||!1;let i=await this.https.getPrevMatchForTeam(t,e);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the previous match for the following team: ${t}`,i),i}}};var yi=class{countryId=null;scope=null;name=null;playerIds=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(t){this.countryId=t.countryId?t.countryId:null,this.scope=t.scope?t.scope:null,this.name=t.name?t.name:null,this.playerIds=t.playerIds?t.playerIds:null,this.limit=t.limit?t.limit:null,this.page=t.page?t.page:null,this.sortField=t.sortField?t.sortField:null,this.sortOrder=t.sortOrder?t.sortOrder:null}constructFilterUrl=()=>{let t="";return this.countryId&&(t=t+"&",t=t+`country_id=${this.countryId}`),this.scope&&this.scope.length>0&&(t=t+"&",t=t+`scope=${this.scope.join(",")}`),this.name&&(t=t+"&",t=t+`name=${this.name}`),this.playerIds&&this.playerIds.length>0&&(t=t+"&",t=t+`player_ids=${this.playerIds.join(",")}`),this.limit&&(t=t+"&",t=t+`limit=${this.limit}`),this.page&&(t=t+"&",t=t+`page=${this.page}`),this.sortField&&(t=t+"&",t=t+`sort_field=${this.sortField}`),this.sortOrder&&(t=t+"&",t=t+`sort_order=${this.sortOrder}`),t}};var wt=class{https=null;footballService=null;idMapping=null;constructor(t,e,i){this.idMapping=i,this.https=e,this.footballService=new pt(t)}getPlayersIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new yi(t),t.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([t.countryId],"country","native");a.country.length===0&&(i=!0),t.countryId=a.country[0]}if(t.playerIds){let a=await this.idMapping.getEntityIdsBySchemaId(t.playerIds,"player","native");a.player.length===0&&(i=!0),t.playerIds=a.player}if(t.scope){let a=await this.idMapping.getEntityIdsBySchemaId(t.scope,"competition","native");a.competition.length===0&&(i=!0),t.scope=a.competition}if(i)return[]}let r=await this.getPlayers(t,e);return r.data=await this.idMapping.remapEntities(r.data,"player"),r}catch(i){throw console.warn("There was a problem browsing the players",i),i}};getPlayersWithNativeIds=async t=>{let e=t.length,i=new yi({playerIds:t,limit:e}),r=await this.getPlayers(i);return r.data.sort((a,s)=>a.id.localeCompare(s.id)),await this.idMapping.remapEntities(r.data,"player")};getPlayersMapWithNativeIds=async t=>{let e={},i=Lt(t);i.sort((a,s)=>a.localeCompare(s));let r=await this.getPlayersWithNativeIds(Array.from(i));return i.forEach((a,s)=>e[a]=r[s]),e};getPlayers=async(t,e)=>{try{return e=e||!1,await this.https.getPlayers(t,e)}catch(i){throw console.warn("There was a problem retrieving the players",i),i}};getPlayerIdMapping=async(t,e)=>{try{let i=await this.idMapping.getEntityIdsBySchemaId([t],"player","native"),r=await this.getPlayerById(i.player[0],e);return await this.idMapping.remapEntities(r,"player")}catch(i){throw console.warn(`There was a problem browsing the following player:${t}`,i),i}};getPlayerById=async(t,e)=>{try{return e=e||!1,await this.https.getPlayerById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the following player: ${t}`,i),i}};getTopPlayersIdMapping=async t=>{try{let e=await this.getTopPlayers(t);return await this.idMapping.remapEntities(e,"player")}catch(e){throw console.warn("There was a problem browsing the top players",e),e}};getTopPlayers=async t=>{try{return t=t||!1,await this.https.getTopPlayers(t)}catch(e){throw console.warn("There was a problem retrieving the top players",e),e}};getNextMatchForPlayerIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"player","native")).player[0];let r=await this.getNextMatchForPlayer(t,e);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the next match for player:${t}`,i),i}};getNextMatchForPlayer=async(t,e)=>{try{e=e||!1;let i=await this.https.getNextMatchForPlayer(t,e);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the next match for player: ${t}`,i),i}};getPrevMatchForPlayerIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"player","native")).player[0];let r=await this.getPrevMatchForPlayer(t,e);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the previous match for player:${t}`,i),i}};getPrevMatchForPlayer=async(t,e)=>{try{e=e||!1;let i=await this.https.getPrevMatchForPlayer(t,e);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the previous match for player: ${t}`,i),i}}};var It=class{countryIds=null;competitionIds=null;matchIds=null;status=null;teamIds=null;fromDate=null;toDate=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(t){this.countryIds=t.countryIds?t.countryIds:null,this.competitionIds=t.competitionIds?t.competitionIds:null,this.matchIds=t.matchIds?t.matchIds:null,this.status=t.status?t.status:null,this.teamIds=t.teamIds?t.teamIds:null,this.fromDate=t.fromDate?t.fromDate:null,this.toDate=t.toDate?t.toDate:null,this.limit=t.limit?t.limit:null,this.page=t.page?t.page:null,this.sortField=t.sortField?t.sortField:null,this.sortOrder=t.sortOrder?t.sortOrder:null}constructFilterUrl=t=>{let e="";return this.countryIds&&(e=e+"&",e=e+`countries=${this.countryIds.join(",")}`),this.competitionIds&&this.competitionIds.length>0&&(e=e+"&",e=e+`competitions=${this.competitionIds.join(",")}`),this.matchIds&&this.matchIds.length>0&&(e=e+"&",e=e+`matches=${this.matchIds.join(",")}`),this.status&&(e=e+"&",e=e+`status=${this.status}`),this.teamIds&&this.teamIds.length>0&&(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&&!t&&(e=e+"&",e=e+`limit=${this.limit}`),this.page&&!t&&(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 Pt=class{https=null;idMapping=null;footballService=null;constructor(t,e,i){this.https=e,this.idMapping=i,this.footballService=new pt(t)}getMatchesIdMapping=async(t,e)=>{try{if(t){if(t=new It(t),t.countryIds&&t.countryIds.length>0){let r=await this.idMapping.getEntityIdsBySchemaId(t.countryIds,"country","native");t.countryIds=r.country}if(t.competitionIds&&t.competitionIds.length>0){let r=await this.idMapping.getEntityIdsBySchemaId(t.competitionIds,"competition","native");t.competitionIds=r.competition}if(t.matchIds&&t.matchIds.length>0){let r=await this.idMapping.getEntityIdsBySchemaId(t.matchIds,"match","native");t.matchIds=r.match}if(t.teamIds&&t.teamIds.length>0){let r=await this.idMapping.getEntityIdsBySchemaId(t.teamIds,"team","native");t.teamIds=r.team}}let i=await this.getMatches(t,e);return i.data=await this.footballService.setAvailableMarketsForMatch([...i.data]),i.data=await this.idMapping.remapEntities(i.data,"match"),i}catch(i){throw console.warn("There was a problem browsing the matches",i),i}};getMatchesWithNativeIds=async t=>{let e=t.length,i=new It({matchIds:t,limit:e}),r=await this.getMatches(i);return r.data.sort((a,s)=>a.id.localeCompare(s.id)),await this.idMapping.remapEntities(r.data,"match")};getMatchesMapWithNativeIds=async t=>{let e={},i=Lt(t);i.sort((a,s)=>a.localeCompare(s));let r=await this.getMatchesWithNativeIds(Array.from(i));if(i.length!==r.length){let a=new It({matchIds:i,limit:i.length}),s=await this.getMatches(a),l=i.filter(n=>{if(s.data.every(p=>p.id!==n))return n});i=i.filter(n=>{if(!l.includes(n))return n})}return i.forEach((a,s)=>e[a]=r[s]),e};getMatches=async(t,e)=>{try{return e=e||!1,await this.https.getMatches(t,e)}catch(i){throw console.warn("There was a problem retrieving the matches",i),i}};getMatchIdMapping=async(t,e)=>{try{let i=await this.idMapping.getEntityIdsBySchemaId([t],"match","native"),r=await this.getMatchById(i.match[0],e),a=await this.footballService.setAvailableMarketsForMatch(r);return await this.idMapping.remapEntities(a,"match")}catch(i){throw console.warn(`There was a problem browsing the following match: ${t}`,i),i}};getMatchById=async(t,e)=>{try{return e=e||!1,await this.https.getMatchById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the following match: ${t}`,i),i}}};var _r=class{entities=null;query=null;scope=null;constructor(t){this.entities=t.entities?t.entities:null,this.query=t.query?t.query:null,this.scope=t.scope?t.scope:null}constructFilterUrl=()=>{let t="";return this.entities&&(t=t+"&",t=t+`entities=${this.entities.join(",")}`),this.query&&(t=t+"&",t=t+`q=${this.query}`),this.scope&&(t=t+"&",t=t+`scope=${this.scope.join(",")}`),t}};var Tr=class{https=null;idMapping=null;constructor(t,e){this.https=t,this.idMapping=e}searchIdMapping=async(t,e)=>{try{if(t=new _r(t),t.scope){let r=await this.idMapping.getEntityIdsBySchemaId(t.scope,"competition","native");t.scope=r.competition}let i=await this.search(t,e);if(i.teams&&i.teams.length>0){let r=await this.idMapping.remapEntities(i.teams,"team");i.teams=r}if(i.players&&i.players.length>0){let r=await this.idMapping.remapEntities(i.players,"player");i.players=r}if(i.competitions&&i.competitions.length>0){let r=await this.idMapping.remapEntities(i.competitions,"competition");i.competitions=r}return i}catch(i){throw console.warn("There was a problem with browsing the search result",i),i}};search=async(t,e)=>{try{return await this.https.search(t,e)}catch(i){throw console.warn("There was a problem retrieving the search response",i),i}}};var ie=class{countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(t,e,i,r){this.countriesFacade=new zi(e,i,r),this.competitionsFacade=new qi(e,i,r),this.teamsFacade=new Pr(t,i,r),this.playerFacade=new wt(t,i,r),this.matchFacade=new Pt(t,i,r),this.searchFacade=new Tr(i,r)}getCountries=async t=>this.countriesFacade.getCountriesWithIdMapping(t);getCompetitions=async(t,e)=>this.competitionsFacade.getCompetitionsIdMapping(t,e);getCompetitionById=async(t,e)=>this.competitionsFacade.getCompetitionByIdIdMapping(t,e);getTopCompetitions=async t=>this.competitionsFacade.getTopCompetitionsIdMapping(t);getCompetitionsMapWithNativeIds=async t=>await this.competitionsFacade.getCompetitionsMapWithNativeIds(t);getTeams=async(t,e)=>this.teamsFacade.getTeamsIdMapping(t,e);getTeamById=async(t,e)=>this.teamsFacade.getTeamByIdIdMapping(t,e);getTopTeams=async t=>this.teamsFacade.getTopTeamsIdMapping(t);getNextMatchForTeam=async(t,e)=>this.teamsFacade.getNextMatchForTeamIdMapping(t,e);getPrevMatchForTeam=async(t,e)=>this.teamsFacade.getPrevMatchForTeamIdMapping(t,e);getTeamsMapWithNativeIds=async t=>await this.teamsFacade.getTeamsMapWithNativeIds(t);getPlayers=async(t,e)=>this.playerFacade.getPlayersIdMapping(t,e);getPlayerById=async(t,e)=>this.playerFacade.getPlayerIdMapping(t,e);getTopPlayers=async t=>this.playerFacade.getTopPlayersIdMapping(t);getNextMatchForPlayer=async(t,e)=>this.playerFacade.getNextMatchForPlayerIdMapping(t,e);getPrevMatchForPlayer=async(t,e)=>this.playerFacade.getPrevMatchForPlayerIdMapping(t,e);getPlayersMapWithNativeIds=async t=>this.playerFacade.getPlayersMapWithNativeIds(t);getMatches=async(t,e)=>this.matchFacade.getMatchesIdMapping(t,e);getMatchesMapWithNativeIds=async t=>this.matchFacade.getMatchesMapWithNativeIds(t);getMatchById=async(t,e)=>this.matchFacade.getMatchIdMapping(t,e);search=async(t,e)=>this.searchFacade.searchIdMapping(t,e)};var vr=class{id="";alias="";countryCode="";assets=null;name=""};var A=class{countriesFromResponse=t=>{if(t)return t.map(e=>this.countryFromResponse(e))};countryFromResponse=t=>{try{if(t){let e=new vr;return e.id=t.id,e.alias=t.alias,e.assets=t.assets,e.countryCode=t.country_code,e.name=t.name,e}}catch(e){throw e}return null}};var Fr=class{id="";country=null;gender="";assets=null;type="";name=""};var $=class{countryRemapper=null;constructor(){this.countryRemapper=new A}fromResponse(t){try{let e=new Fr;return e.id=t.id,e.country=this.countryRemapper.countryFromResponse(t.country),e.gender=t.gender,e.assets=t.assets,e.type=t.type,e.name=t.name,e}catch(e){throw console.warn("There was a problem remapping the competition response",e),e}}};var Er=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var Sr=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;undecided=!1;fullName="";shortName="";isDeleted=!1};var k=class{countryRemapper=null;constructor(){this.countryRemapper=new A}fromResponse(t){try{let e=new Sr;return e.id=t.id,e.country=this.countryRemapper.countryFromResponse(t.country),e.gender=t.gender,e.assets=t.assets,e.code=t.code,e.national=t.national,e.fullName=t.full_name,e.shortName=t.short_name,e.name=t.name,e.isDeleted=t.is_deleted,e.undecided=t.undecided,e}catch(e){throw console.warn("There was a problem remapping teams response",e),e}}};var Rr=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new A,this.teamBasicRemapper=new k}fromResponse(t){try{let e=new Er;return e.id=t.id,e.country=this.countryRemapper.countryFromResponse(t.country),e.gender=t.gender,e.assets=t.assets,e.type=t.type,e.name=t.name,e.participants=t.participants.map(i=>this.teamBasicRemapper.fromResponse(i)),e}catch(e){throw console.warn("There was a problem remapping the competition response",e),e}}};var Cr=class{primary=null;secondary=null;tertiary=null};var Ar=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";isDeleted=!1;undecided=!1;colors=new Cr;squad=[]};var Or=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var Lr=class{countryRemapper=null;constructor(){this.countryRemapper=new A}fromResponse(t){try{let e=new Or;return e.id=t.id,e.startDate=t.start_date,e.endDate=t.end_date,e.shirtNumber=t.shirt_number,e.loan=t.loan,e.position=t.position,e.country=this.countryRemapper.countryFromResponse(t.country),e.name=t.name,e.assets=t.assets,e.birthDate=t.birth_date,e}catch(e){throw console.warn("There was a problem remapping the player from squad",e),e}}};var xr=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new A,this.competitionRemapper=new $,this.playerRemapper=new Lr}fromResponse(t){try{let e=new Ar;return e.id=t.id,e.country=this.countryRemapper.countryFromResponse(t.country),e.gender=t.gender,e.assets=t.assets,e.code=t.code,e.national=t.national,e.fullName=t.full_name,e.shortName=t.short_name,e.name=t.name,e.isDeleted=t.is_deleted,e.undecided=t.undecided,e.competitions=t.competitions?t.competitions.map(i=>this.competitionRemapper.fromResponse(i)):[],e.colors=t.colors?t.colors:e.colors,e.squad=t.squad?t.squad.map(i=>this.playerRemapper.fromResponse(i)):[],e}catch(e){throw console.warn("There was a problem remapping team response",e),e}}};var Dr=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;homeTeam=null;awayTeam=null;isDeleted=!1;undecided=!1;lineupsConfirmed=!1;startedAt="";minute="";scores=null;context={competition:null};status={type:null,subType:null}};var Br=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var re=class{fromResponse(t){try{let e=new Br;return e.ftScore=this.statEntityFromResponse(t.ft_score),e.htScore=this.statEntityFromResponse(t.ht_score),e.aetScore=this.statEntityFromResponse(t.aet_score),e.aggScore=this.statEntityFromResponse(t.agg_score),e.penScore=this.statEntityFromResponse(t.pen_score),e}catch(e){throw console.warn("There was a problem remapping the scores",e),e}}statEntityFromResponse=t=>({homeGoals:t.home_goals,awayGoals:t.away_goals})};var Nr=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new k,this.competitionRemapper=new $,this.scoresRemapper=new re}fromResponse(t){try{let e=new Dr;return e.id=t.id,e.kickoffAt=t.kickoff_at,e.finishedAt=t.finished_at,e.updatedAt=t.updated_at,e.isDeleted=t.is_deleted,e.undecided=t.undecided,e.homeTeam=this.teamRemapper.fromResponse(t.home_team),e.awayTeam=this.teamRemapper.fromResponse(t.away_team),e.lineupsConfirmed=t.lineups_confirmed,e.startedAt=t.started_at,e.minute=t.minute,e.scores=this.scoresRemapper.fromResponse(t.scores),e.context={competition:t.context.competition?this.competitionRemapper.fromResponse(t.context.competition):null},e.status={type:t.status.type,subType:t.status.sub_type},e}catch(e){throw console.warn("There was a problem remapping the match response",e),e}}};var j=class{type=null;subType=null};var kr=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;isDeleted=!1;undecided=!1;homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;stats=null;playerStats=[];context={competition:null};timeline=[];status=new j;lineups=null};var Ur=class{corners=null;cornersFirstHalf=null;cornersSecondHalf=null;cornersExtraTime=null;crosses=null;crossesFirstHalf=null;crossesSecondHalf=null;crossesExtraTime=null;offside=null;offsideFirstHalf=null;offsideSecondHalf=null;offsideExtraTime=null;shotsOn=null;shotsOnFirstHalf=null;shotsOnSecondHalf=null;shotsOnExtraTime=null;throwIn=null;throwInFirstHalf=null;throwInSecondHalf=null;throwInExtraTime=null;redCards=null;redCardsFirstHalf=null;redCardsSecondHalf=null;redCardsExtraTime=null;shotsOff=null;shotsOffFirstHalf=null;shotsOffSecondHalf=null;shotsOffExtraTime=null;goalKicks=null;goalKicksFirstHalf=null;goalKicksSecondHalf=null;goalKicksExtraTime=null;possession=null;possessionFirstHalf=null;possessionSecondHalf=null;possessionExtraTime=null;treatments=null;treatmentsFirstHalf=null;treatmentsSecondHalf=null;treatmentsExtraTime=null;yellowCards=null;yellowCardsFirstHalf=null;yellowCardsSecondHalf=null;yellowCardsExtraTime=null;shotsBlocked=null;shotsBlockedFirstHalf=null;shotsBlockedSecondHalf=null;shotsBlockedExtraTime=null;substitutions=null;substitutionsFirstHalf=null;substitutionsSecondHalf=null;substitutionsExtraTime=null;counterAttacks=null;counterAttacksFirstHalf=null;counterAttacksSecondHalf=null;counterAttacksExtraTime=null;foulsCommitted=null;foulsCommittedFirstHalf=null;foulsCommittedSecondHalf=null;foulsCommittedExtraTime=null};var Gr=class{fromResponse(t){try{let e=new Ur;return e.corners=this.statEntityFromResponse(t.corners),e.cornersFirstHalf=this.statEntityFromResponse(t.corners_1h),e.cornersSecondHalf=this.statEntityFromResponse(t.corners_2h),e.cornersExtraTime=this.statEntityFromResponse(t.corners_et),e.crosses=this.statEntityFromResponse(t.crosses),e.crossesFirstHalf=this.statEntityFromResponse(t.crosses_1h),e.crossesSecondHalf=this.statEntityFromResponse(t.crosses_2h),e.crossesExtraTime=this.statEntityFromResponse(t.crosses_et),e.offside=this.statEntityFromResponse(t.offside),e.offsideFirstHalf=this.statEntityFromResponse(t.offside_1h),e.offsideSecondHalf=this.statEntityFromResponse(t.offside_2h),e.offsideExtraTime=this.statEntityFromResponse(t.offside_et),e.shotsOn=this.statEntityFromResponse(t.shots_on),e.shotsOnFirstHalf=this.statEntityFromResponse(t.shots_on_1h),e.shotsOnSecondHalf=this.statEntityFromResponse(t.shots_on_2h),e.shotsOnExtraTime=this.statEntityFromResponse(t.shots_on_et),e.throwIn=this.statEntityFromResponse(t.throw_in),e.throwInFirstHalf=this.statEntityFromResponse(t.throw_in_1h),e.throwInSecondHalf=this.statEntityFromResponse(t.throw_in_2h),e.throwInExtraTime=this.statEntityFromResponse(t.throw_in_et),e.redCards=this.statEntityFromResponse(t.red_cards),e.redCardsFirstHalf=this.statEntityFromResponse(t.red_cards_1h),e.redCardsSecondHalf=this.statEntityFromResponse(t.red_cards_2h),e.redCardsExtraTime=this.statEntityFromResponse(t.red_cards_et),e.shotsOff=this.statEntityFromResponse(t.shots_off),e.shotsOffFirstHalf=this.statEntityFromResponse(t.shots_off_1h),e.shotsOffSecondHalf=this.statEntityFromResponse(t.shots_off_2h),e.shotsOffExtraTime=this.statEntityFromResponse(t.shots_off_et),e.goalKicks=this.statEntityFromResponse(t.goal_kicks),e.goalKicksFirstHalf=this.statEntityFromResponse(t.goal_kicks_1h),e.goalKicksSecondHalf=this.statEntityFromResponse(t.goal_kicks_2h),e.goalKicksExtraTime=this.statEntityFromResponse(t.goal_kicks_et),e.possession=this.statEntityFromResponse(t.possession),e.possessionFirstHalf=this.statEntityFromResponse(t.possession_1h),e.possessionSecondHalf=this.statEntityFromResponse(t.possession_2h),e.possessionExtraTime=this.statEntityFromResponse(t.possession_et),e.treatments=this.statEntityFromResponse(t.treatments),e.treatmentsFirstHalf=this.statEntityFromResponse(t.treatments_1h),e.treatmentsSecondHalf=this.statEntityFromResponse(t.treatments_2h),e.treatmentsExtraTime=this.statEntityFromResponse(t.treatments_et),e.yellowCards=this.statEntityFromResponse(t.yellow_cards),e.yellowCardsFirstHalf=this.statEntityFromResponse(t.yellow_cards_1h),e.yellowCardsSecondHalf=this.statEntityFromResponse(t.yellow_cards_2h),e.yellowCardsExtraTime=this.statEntityFromResponse(t.yellow_cards_et),e.shotsBlocked=this.statEntityFromResponse(t.shots_blocked),e.shotsBlockedFirstHalf=this.statEntityFromResponse(t.shots_blocked_1h),e.shotsBlockedSecondHalf=this.statEntityFromResponse(t.shots_blocked_2h),e.shotsBlockedExtraTime=this.statEntityFromResponse(t.shots_blocked_et),e.substitutions=this.statEntityFromResponse(t.substitutions),e.substitutionsFirstHalf=this.statEntityFromResponse(t.substitutions_1h),e.substitutionsSecondHalf=this.statEntityFromResponse(t.substitutions_2h),e.substitutionsExtraTime=this.statEntityFromResponse(t.substitutions_et),e.counterAttacks=this.statEntityFromResponse(t.counter_attacks),e.counterAttacksFirstHalf=this.statEntityFromResponse(t.counter_attacks_1h),e.counterAttacksSecondHalf=this.statEntityFromResponse(t.counter_attacks_2h),e.counterAttacksExtraTime=this.statEntityFromResponse(t.counter_attacks_et),e.foulsCommitted=this.statEntityFromResponse(t.fouls_committed),e.foulsCommittedFirstHalf=this.statEntityFromResponse(t.fouls_committed_1h),e.foulsCommittedSecondHalf=this.statEntityFromResponse(t.fouls_committed_2h),e.foulsCommittedExtraTime=this.statEntityFromResponse(t.fouls_committed_et),e}catch(e){throw console.warn("There was a problem remapping the stats",e),e}}statEntityFromResponse=t=>({homeTeam:t?t.home_team:null,awayTeam:t?t.away_team:null})};var ae=class{homeTeam={players:[]};awayTeam={players:[]}};var Vr=class{id="";name="";position="";shirtNumber;assets=null;type=""};var oe=class{fromResponse(t){try{let e=new Vr;return e.id=t.id,e.name=t.name,e.position=t.position,e.shirtNumber=t.shirt_number,e.assets=t.assets,e.type=t.type,e}catch(e){throw console.warn("There was a problem remapping the player from timeline",e),e}}};var Hr=class{playerRemapper=null;constructor(){this.playerRemapper=new oe}fromResponse(t){try{let e=new ae;return e.homeTeam.players=t.home_team&&t.home_team.players?t.home_team.players.map(i=>this.playerRemapper.fromResponse(i)):[],e.awayTeam.players=t.away_team&&t.away_team.players?t.away_team.players.map(i=>this.playerRemapper.fromResponse(i)):[],e}catch(e){throw console.warn("There was a problem remapping the lineups",e),e}}};var $r=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var Wr=class{playerRemapper=null;constructor(){this.playerRemapper=new oe}fromResponse(t){try{let e=new $r;return e.minute=t.minute,e.type=t.type,e.teamId=t.team_id,e.player=this.playerRemapper.fromResponse(t.player),e.relatedPlayer=t.related_player?this.playerRemapper.fromResponse(t.related_player):null,e.updatedAt=t.updated_at,e}catch(e){throw console.warn("There was a problem remapping timeline",e),e}}};var zr=class{playerId=null;minutesPlayed=null;yellowCards=null;redCards=null;goals=null;penaltyGoals=null;penaltyCommitted=null;penaltyWon=null;penaltyMissed=null;penaltySaved=null;penaltyReceived=null;ownGoals=null;assists=null;cleanSheets=null;shots=null;shotsOn=null;shotsBlocked=null;offsides=null;foulsCommitted=null;foulsWon=null;tackles=null;tacklesBlocks=null;tacklesInterceptions=null;concededGoals=null;caughtBall=null;saves=null;passes=null;crosses=null;interceptions=null;keyPasses=null;passesAccuracy=null;duels=null;duelsWon=null;dribblesAttempts=null;dribblesSuccess=null;dribblesPast=null;updatedAt=null};var qr=class{fromResponse(t){try{let e=new zr;return e.playerId=t.player_id,e.minutesPlayed=t.minutes_played,e.yellowCards=t.yellow_cards,e.redCards=t.red_cards,e.goals=t.goals,e.penaltyGoals=t.penalty_goals,e.penaltyCommitted=t.penalty_committed,e.penaltyWon=t.penalty_won,e.penaltyMissed=t.penalty_missed,e.penaltySaved=t.penalty_saved,e.penaltyReceived=t.penalty_received,e.ownGoals=t.own_goals,e.assists=t.assists,e.cleanSheets=t.clean_sheets,e.shots=t.shots,e.shotsOn=t.shots_on,e.shotsBlocked=t.shots_blocked,e.offsides=t.offsides,e.foulsCommitted=t.fouls_committed,e.foulsWon=t.fouls_won,e.tackles=t.tackles,e.tacklesBlocks=t.tackles_blocks,e.tacklesInterceptions=t.tackles_interceptions,e.concededGoals=t.conceded_goals,e.caughtBall=t.caught_ball,e.saves=t.saves,e.passes=t.passes,e.crosses=t.crosses,e.interceptions=t.interceptions,e.keyPasses=t.key_passes,e.passesAccuracy=t.passes_accuracy,e.duels=t.duels,e.duelsWon=t.duels_won,e.dribblesAttempts=t.dribbles_attempts,e.dribblesSuccess=t.dribbles_success,e.dribblesPast=t.dribbles_past,e.updatedAt=t.updated_at,e}catch(e){throw console.warn("There was a problem remapping the player stats",e),e}}};var Qr=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;playerStatsMapper=null;constructor(){this.teamMapper=new k,this.competitionsMapper=new $,this.lineupsMapper=new Hr,this.scoresMapper=new re,this.statsMapper=new Gr,this.timelineMapper=new Wr,this.playerStatsMapper=new qr}fromResponse(t){try{let e=new kr;return e.id=t.id,e.kickoffAt=t.kickoff_at,e.finishedAt=t.finished_at,e.updatedAt=t.updated_at,e.isDeleted=t.is_deleted,e.undecided=t.undecided,e.homeTeam=t.home_team?this.teamMapper.fromResponse(t.home_team):null,e.awayTeam=t.away_team?this.teamMapper.fromResponse(t.away_team):null,e.lineupsConfirmed=t.lineups_confirmed,e.startedAt=t.started_at,e.minute=t.minute,e.scores=this.scoresMapper.fromResponse(t.scores),e.stats=this.statsMapper.fromResponse(t.stats),e.playerStats=t.player_stats?t.player_stats.map(i=>this.playerStatsMapper.fromResponse(i)):t.player_stats,e.context={competition:this.competitionsMapper.fromResponse(t.context.competition)},e.timeline=t.timeline?t.timeline.map(i=>this.timelineMapper.fromResponse(i)):[],e.status={type:t.status.type,subType:t.status.sub_type},e.lineups=t.lineups?this.lineupsMapper.fromResponse(t.lineups):new ae,e}catch(e){throw console.warn("There was a problem remapping the match response",e),e}}};var Kr=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var jr=class{countryRemapper=null;constructor(){this.countryRemapper=new A}fromResponse(t){try{let e=new Kr;return e.id=t.id,e.firstName=t.first_name?t.first_name:null,e.lastName=t.last_name?t.last_name:null,e.name=t.name?t.name:null,e.birthDate=t.birth_date,e.country=this.countryRemapper.countryFromResponse(t.country),e.assets=t.assets,e.position=t.position,e}catch(e){throw console.warn("There was a problem remapping top player response",e),e}}};var Xr=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;teams=[]};var se=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new A,this.teamRemapper=new k}fromResponse(t){try{let e=new Xr;return e.id=t.id,e.firstName=t.first_name?t.first_name:null,e.lastName=t.last_name?t.last_name:null,e.name=t.name?t.name:null,e.birthDate=t.birth_date,e.country=this.countryRemapper.countryFromResponse(t.country),e.assets=t.assets,e.teams=t.teams?t.teams.map(i=>this.teamRemapper.fromResponse(i)):[],e.position=t.position,e.isDeleted=t.is_deleted,e}catch(e){throw console.warn("There was a problem remapping players response",e),e}}};var Yr=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;competitions=[];teams=[]};var Jr=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new A,this.teamRemapper=new k,this.competitionRemapper=new $}fromResponse(t){try{let e=new Yr;return e.id=t.id,e.firstName=t.first_name?t.first_name:null,e.lastName=t.last_name?t.last_name:null,e.name=t.name?t.name:null,e.birthDate=t.birth_date,e.country=this.countryRemapper.countryFromResponse(t.country),e.assets=t.assets,e.teams=t.teams?t.teams.map(i=>this.teamRemapper.fromResponse(i)):[],e.position=t.position,e.isDeleted=t.is_deleted,e.competitions=t.competitions?t.competitions.map(i=>this.competitionRemapper.fromResponse(i)):[],e}catch(e){throw console.warn("There was a problem remapping player response",e),e}}};var Zr=class{teams=null;players=null;competitions=null};var ta=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new k,this.playerRemapper=new se,this.competitionremapper=new $}fromResponse(t){try{let e=new Zr;return e.teams=t.teams?t.teams.map(i=>this.teamRemapper.fromResponse(i)):[],e.players=t.players?t.players.map(i=>this.playerRemapper.fromResponse(i)):[],e.competitions=t.competitions?t.competitions.map(i=>this.competitionremapper.fromResponse(i)):[],e}catch(e){throw console.warn("There was a problem remapping search response",e),e}}};var Dt=class{meta=new H;data=[]};var ea=class{remapMetaProp=t=>{let e=new H;return e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.totalItems=t.pagination.total_items,e.pagination.numberOfPages=t.pagination.number_of_pages,e}};var ia=class{templateId=null;playerId=null};var ra=class{filters=new ia};var aa=class{meta=new ra;data=[]};var oa=class{templateId=null};var sa=class{filters=new oa};var na=class{meta=new sa;data=[]};var ne=class{total=null;minutesPlayed=null;yellowCards=null;redCards=null;goals=null;penaltyGoals=null;ownGoals=null;assists=null;cleanSheets=null;shots=null;shotsOn=null;offsides=null;foulsCommitted=null;penaltyCommitted=null;penaltyWon=null;penaltyMissed=null;tackles=null;concededGoals=null;caughtBall=null;saves=null};var le=class{minutesPlayed=null;yellowCards=null;redCards=null;goals=null;penaltyGoals=null;penaltyCommitted=null;penaltyWon=null;penaltyMissed=null;penaltySaved=null;penaltyReceived=null;ownGoals=null;assists=null;cleanSheets=null;shots=null;shotsOn=null;shotsBlocked=null;offsides=null;foulsCommitted=null;foulsWon=null;tackles=null;tacklesBlocks=null;tacklesInterceptions=null;concededGoals=null;caughtBall=null;saves=null;passes=null;crosses=null;interceptions=null;keyPasses=null;passesAccuracy=null;duels=null;duelsWon=null;dribblesAttempts=null;dribblesSuccess=null;dribblesPast=null};var la=class{matchId=null;matchModel=null;points=new ne;stats=new le};var pa=class{playerId=null;playerModel=null;points=null;rank=null};var ca=class{remapPlayersPoints=t=>{let e=new na;return e.meta.filters.templateId=t.meta.filters.template_id,e.data=t.data.map(i=>this.remapPlayersPointsData(i)),e};remapPlayersPointsData=t=>{let e=new pa;return e.playerId=t.player_id,e.points=t.points,e.rank=t.rank,e};remapPlayerDetailedStats=t=>{let e=new aa;return e.meta.filters.templateId=t.meta.filters.template_id,e.meta.filters.playerId=t.meta.filters.player_id,e.data=t.data.map(i=>this.remapPlayerDetailedData(i)),e};remapPlayerDetailedData=t=>{let e=new la;return e.matchId=t.match_id,e.points=t.points?this.remapPlayerDetailedPoints(t.points):null,e.stats=t.stats?this.remapPlayerDetailedStatsData(t.stats):null,e};remapPlayerDetailedPoints=t=>{let e=new ne;return e.total=t.total,e.minutesPlayed=t.minutes_played,e.yellowCards=t.yellow_cards,e.redCards=t.red_cards,e.goals=t.goals,e.penaltyGoals=t.penalty_goals,e.ownGoals=t.own_goals,e.assists=t.assists,e.cleanSheets=t.clean_sheets,e.shots=t.shots,e.shotsOn=t.shots_on,e.offsides=t.offsides,e.foulsCommitted=t.fouls_committed,e.penaltyCommitted=t.penalty_committed,e.penaltyWon=t.penalty_won,e.penaltyMissed=t.penalty_missed,e.tackles=t.tackles,e.concededGoals=t.conceded_goals,e.caughtBall=t.caught_ball,e.saves=t.saves,e};remapPlayerDetailedStatsData=t=>{let e=new le;return e.minutesPlayed=t.minutes_played,e.yellowCards=t.yellow_cards,e.redCards=t.red_cards,e.goals=t.goals,e.penaltyGoals=t.penalty_goals,e.penaltyCommitted=t.penalty_committed,e.penaltyWon=t.penalty_won,e.penaltyMissed=t.penalty_missed,e.penaltySaved=t.penalty_saved,e.penaltyReceived=t.penalty_received,e.ownGoals=t.own_goals,e.assists=t.assists,e.cleanSheets=t.clean_sheets,e.shots=t.shots,e.shotsOn=t.shots_on,e.shotsBlocked=t.shots_blocked,e.offsides=t.offsides,e.foulsCommitted=t.fouls_committed,e.foulsWon=t.fouls_won,e.tackles=t.tackles,e.tacklesBlocks=t.tackles_blocks,e.tacklesInterceptions=t.tackles_interceptions,e.concededGoals=t.conceded_goals,e.caughtBall=t.caught_ball,e.saves=t.saves,e.passes=t.passes,e.crosses=t.crosses,e.interceptions=t.interceptions,e.keyPasses=t.key_passes,e.passesAccuracy=t.passes_accuracy,e.duels=t.duels,e.duelsWon=t.duels_won,e.dribblesAttempts=t.dribbles_attempts,e.dribblesSuccess=t.dribbles_success,e.dribblesPast=t.dribbles_past,e}};var X=class extends T{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;fantasyRemapper=null;footballService=null;constructor(t){super(t,S(t.environment,"football")),this.apiSignInUrl=t.lang!=="en"?this.apiSignInUrl+`&lang=${t.lang}`:this.apiSignInUrl,this.countryRemapper=new A,this.competitionBasicRemapper=new $,this.competitionFullRemapper=new Rr,this.teamBasicRemapper=new k,this.teamFullRemapper=new xr,this.matchBasicRemapper=new Nr,this.matchFullRemapper=new Qr,this.playerBasicRemapper=new se,this.playerFullRemapper=new Jr,this.topPlayerRemapper=new jr,this.searchRemapper=new ta,this.footballMetaRemapper=new ea,this.footballService=new pt(t),this.fantasyRemapper=new ca}getCountries=async t=>{let e="There was a problem with the football countries request",i=`/countries${this.apiSignInUrl}`,r=Date.now();t&&(i+=`&disable_cache=${r}`);let a=await this.fetchWithoutAuth(i,e);return this.countryRemapper.countriesFromResponse(a.data)};getCompetitions=async(t,e)=>{let i=Date.now(),r="There was a problem with football competitions request";if(e=e||!1,t&&t.competitionIds&&t.competitionIds.length>this.limitIds-1){let a=[],s=$t(t.competitionIds,this.limitIds);for(let n of s){t.competitionIds=n;let p=`/competitions${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(p+=`&disable_cache=${i}`);let c=await this.fetchWithoutAuth(p,r);a.push(c.data.map(u=>this.competitionBasicRemapper.fromResponse(u)))}return Array.prototype.concat.apply([],a)}else{let a=`/competitions${this.apiSignInUrl}`;return t&&(a+=`${t.constructFilterUrl()}`),e&&(a+=`&disable_cache=${i}`),(await this.fetchWithoutAuth(a,r)).data.map(l=>this.competitionBasicRemapper.fromResponse(l))}};getCompetitionById=async(t,e)=>{let i=`/competitions/${t}${this.apiSignInUrl}`,r="There was a problem with football competition by ID request",a=Date.now();e&&(i+=`&disable_cache=${a}`);let s=await this.fetchWithoutAuth(i,r);return this.competitionFullRemapper.fromResponse(s.data)};getTopCompetitions=async t=>{let e="There was a problem with top football competitions request",i=`/competitions/top${this.apiSignInUrl}`,r=Date.now();return t&&(i+=`&disable_cache=${r}`),(await this.fetchWithoutAuth(i,e)).data.map(s=>this.competitionBasicRemapper.fromResponse(s))};getTeams=async(t,e)=>{let i=Date.now(),r="There was a problem with football teams request";if(t&&t.teamIds&&t.teamIds.length>this.limitIds){let a=[],s=$t(t.teamIds,this.limitIds);for(let n of s){t.teamIds=n;let p=`/teams${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(p+=`disable_cache=${i}`);let c=await this.fetchWithoutAuth(p,r);a.push(c.data.map(u=>this.teamBasicRemapper.fromResponse(u)))}return Array.prototype.concat.apply([],a)}else{let a=new Dt,s=`/teams${this.apiSignInUrl}`;t&&(s+=`${t.constructFilterUrl()}`),e&&(s+=`&disable_cache=${i}`);let l=await this.fetchWithoutAuth(s,r);return a.meta=this.footballMetaRemapper.remapMetaProp(l.meta),a.data=l.data.map(n=>this.teamBasicRemapper.fromResponse(n)),a}};getTeamById=async(t,e)=>{let i="There was a problem with football team by ID request",r=`/teams/${t}${this.apiSignInUrl}`,a=Date.now();e&&(r+=`disable_cache=${a}`);let s=await this.fetchWithoutAuth(r,i);return this.teamFullRemapper.fromResponse(s.data)};getTopTeams=async t=>{let e=`/teams/top${this.apiSignInUrl}`,i="There was a problem with top football teams request",r=Date.now();t&&(e+=`$disable_cache=${r}`);let a=await this.fetchWithoutAuth(e,i);return a.data?a.data.map(s=>this.teamBasicRemapper.fromResponse(s)):[]};getNextMatchForTeam=async(t,e)=>{let i=`/teams/${t}/next-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with next match for team request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getPrevMatchForTeam=async(t,e)=>{let i=`/teams/${t}/previous-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with previous match for team request";e&&(i+=`disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getPlayers=async(t,e)=>{let i=Date.now(),r="There was a problem with football players request";if(t&&t.playerIds&&t.playerIds.length>this.limitIds-1){let a=[],s=$t(t.playerIds,this.limitIds);for(let p of s){t.playerIds=p;let c=`/players${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(c+=`&disable_cache=${i}`);let u=await this.fetchWithoutAuth(c,r);a.push(u.data.map(d=>this.teamBasicRemapper.fromResponse(d)))}let l=Array.prototype.concat.apply([],a),n=new Dt;return n.data=l,n}else{let a=new Dt,s=`/players${this.apiSignInUrl}`;t&&(s+=`${t.constructFilterUrl()}`),e&&(s+=`&disable_cache=${i}`);let l=await this.fetchWithoutAuth(s,r);return a.meta=this.footballMetaRemapper.remapMetaProp(l.meta),a.data=l.data.map(n=>this.playerBasicRemapper.fromResponse(n)),a}};getPlayerById=async(t,e)=>{let i=`/players/${t}${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with football player by ID request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.playerFullRemapper.fromResponse(s.data)};getTopPlayers=async t=>{let e=`/players/top${this.apiSignInUrl}`,i=Date.now(),r="There was a problem with top football players request";return t&&(e+=`&disable_cache=${i}`),(await this.fetchWithoutAuth(e,r)).data.map(s=>this.topPlayerRemapper.fromResponse(s))};getNextMatchForPlayer=async(t,e)=>{let i=`/players/${t}/next-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with next match for player request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getPrevMatchForPlayer=async(t,e)=>{let i=`/players/${t}/previous-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with previous match for player request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getMatchById=async(t,e)=>{let i=`/matches/${t}${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with match by ID request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getMatches=async(t,e)=>{let i=new Dt,r="There was a problem with football matches request";if(t&&t.matchIds&&t.matchIds.length>this.limitIds){let a=[],s=$t(t.matchIds,this.limitIds);for(let n of s){t.matchIds=n;let p=!0,c=`/matches${this.apiSignInUrl}${t.constructFilterUrl(p)}&limit=${n.length}`;e&&(c+=h());let u=await this.fetchWithoutAuth(c,r);a.push(u.data.map(d=>this.matchBasicRemapper.fromResponse(d)))}let l=Array.prototype.concat.apply([],a);return i.meta=this.footballService.setMetaDataBatchRequest(l.length,t.limit||20,t.page||1),i.data=this.footballService.finalizeMatchesDataBatchRequest(l,t),i}else{let a=`/matches${this.apiSignInUrl}`;t&&(a+=`${t.constructFilterUrl()}`),e&&(a+=h());let s=await this.fetchWithoutAuth(a,r);return i.meta=this.footballMetaRemapper.remapMetaProp(s.meta),i.data=s.data.map(l=>this.matchBasicRemapper.fromResponse(l)),i}};search=async(t,e)=>{let i=`/search${this.apiSignInUrl}${t.constructFilterUrl()}`,r=Date.now(),a="There was a problem with football search request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.searchRemapper.fromResponse(s.data)};getPlayersPoints=async(t,e,i)=>{let r=`/players/points/${t}${this.apiSignInUrl}`,a=Date.now(),s="There was a problem with players points request";e&&(r+=`&position=${e.toLocaleLowerCase()}`),i&&(r+=`&disable_cache=${a}`);let l=await this.fetchWithoutAuth(r,s);return this.fantasyRemapper.remapPlayersPoints(l)};getPlayerDetailedStatistics=async(t,e,i)=>{let r=`/players/${e}/points/${t}${this.apiSignInUrl}`,a=Date.now(),s="There was a problem with detailed player points request";i&&(r+=`&disable_cache=${a}`);let l=await this.fetchWithoutAuth(r,s);return this.fantasyRemapper.remapPlayerDetailedStats(l)}};var Y=(y=>(y.FT_1X2="FT_1X2",y.HT_1X2="HT_1X2",y.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",y.DOUBLE_CHANCE="DOUBLE_CHANCE",y.HT_FT="HT_FT",y.PLAYER_SCORE="PLAYER_SCORE",y.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",y.PLAYER_RED_CARD="PLAYER_RED_CARD",y.RED_CARD_MATCH="RED_CARD_MATCH",y.PENALTY_MATCH="PENALTY_MATCH",y.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",y.CORNERS_MATCH="CORNERS_MATCH",y.CORRECT_SCORE="CORRECT_SCORE",y.CORRECT_SCORE_ADVANCED="CORRECT_SCORE_ADVANCED",y.CORRECT_SCORE_HT="CORRECT_SCORE_HT",y.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",y.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",y.OVER_GOALS_0_5="OVER_GOALS_0_5",y.OVER_GOALS_1_5="OVER_GOALS_1_5",y.OVER_GOALS_2_5="OVER_GOALS_2_5",y.OVER_GOALS_3_5="OVER_GOALS_3_5",y.OVER_GOALS_4_5="OVER_GOALS_4_5",y.OVER_GOALS_5_5="OVER_GOALS_5_5",y.OVER_GOALS_6_5="OVER_GOALS_6_5",y.OVER_CORNERS_6_5="OVER_CORNERS_6_5",y.OVER_CORNERS_7_5="OVER_CORNERS_7_5",y.OVER_CORNERS_8_5="OVER_CORNERS_8_5",y.OVER_CORNERS_9_5="OVER_CORNERS_9_5",y.OVER_CORNERS_10_5="OVER_CORNERS_10_5",y.OVER_CORNERS_11_5="OVER_CORNERS_11_5",y.OVER_CORNERS_12_5="OVER_CORNERS_12_5",y.OVER_CORNERS_13_5="OVER_CORNERS_13_5",y))(Y||{}),wl=["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"],Il=["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"],ct=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"],Pl=["FT_1X2","HT_1X2","HT_FT","DOUBLE_CHANCE","CORNERS_MATCH","CORRECT_SCORE","CORRECT_SCORE_HT","CORRECT_SCORE_ADVANCED"],bi="PLAYER_SCORE_FIRST_GOAL";var ua=class{id="";achievedAt=""};var pe=class{participationCount=null;points=null};var ce=class{totalPoints=null;postPoints=null;postsMade=null;reactionPoints=null;reactionCount=null};var ue=class{participationCount=null};var Mi=class{participations=0;points=0};var Bt=class{footballCompetitions=[];footballTeams=[]};var de=class{predictionsMade=0;correct=0;points=0;breakdown=new Bt};var me=class{single=new de;topX=new Mi;matchQuiz=new Mi};var da=class{overallPercent;byFootballCompetition;byFootballTeam;byFootballMarket};var ma=class{profileId;tier;points;predictionsMade;successRates=new da;predictions=new me;tiers=[];badges=[];discussions=new ce;classicQuizzes=new pe;eitherOr=new ue};var ha=class{entityId="";entityType="";entitySource="";model=null;predictionsMade=0;correct=0;points=0};var ga=class{successRatePercent;model=null};var _t=class{content=null;tags=[];campaign=null};var he=class{id=null;profileId=null;property=null;value=null;action=null;context=new _t;points=0};var fa=class{meta=new H;data=[new he]};var ya=class{remapSingleResponse=t=>{let e=new he;return e.id=t.id,e.profileId=t.profile_id,e.property=t.property,e.value=t.value,e.action=t.action,e.context.content=t.context.content,e.context.tags=t.context.tags,e.context.campaign=t.context.campaign,e.points=t.points,e};remapActivitiesResponse=t=>{let e=new fa;return e.meta.pagination.currentPage=t.meta.pagination.current_page,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.meta.pagination.numberOfPages=t.meta.pagination.number_of_pages,e.meta.pagination.totalItems=t.meta.pagination.total_items,e.data=t.data.map(i=>this.remapSingleResponse(i)),e};remapStatsResponse=t=>{let e=new ma;return e.profileId=t.profile_id,e.tier=t.tier,e.points=t.points,e.predictionsMade=t.predictions_made,e.successRates.overallPercent=t.success_rates.overall_percent,e.successRates.byFootballCompetition=this.constructNewRecord(t.success_rates.by_competition),e.successRates.byFootballTeam=this.constructNewRecord(t.success_rates.by_team),e.successRates.byFootballMarket=this.constructNewRecord(t.success_rates.by_market),e.predictions=t.predictions?this.remapPredictionsStats(t.predictions):null,e.tiers=t.tiers?this.remapAchievementsStats(t.tiers):null,e.badges=t.badges?this.remapAchievementsStats(t.badges):null,e.discussions=t.discussions?this.remapDiscussionStats(t.discussions):null,e.classicQuizzes=t.classic_quizzes?this.remapClassicQuizStats(t.classic_quizzes):null,e.eitherOr=t.either_or?this.remapEitherOrStats(t.either_or):null,e};constructNewRecord=t=>{let e;if(Object.entries(t).length)Object.entries(t).forEach(([i,r])=>{e={...e,[i]:this.remapSuccessRatePercent(r)},Y[i]&&delete e[i].model});else return t;return e};remapSuccessRatePercent=t=>{let e=new ga;return e.successRatePercent=t.success_rate_percent,e};remapPredictionsStats=t=>{let e=new me;return e.single=this.remapSinglePredictionsStats(t.single),e.topX=t.top_x,e.matchQuiz=t.match_quiz,e};remapSinglePredictionsStats=t=>{let e=new de;return e.predictionsMade=t.predictions_made,e.correct=t.correct,e.points=t.points,e.breakdown=this.remapBreakdownSinglePredictionsStats(t.breakdown),e};remapBreakdownSinglePredictionsStats=t=>{if(t&&Object.keys(t).length){let e=new Bt,i=[],r=[];return Object.keys(t).forEach(a=>{let s=new ha;s.entityId=a,s.entityType=t[a].entity_type,s.entitySource=t[a].entity_source,s.predictionsMade=t[a].predictions_made,s.correct=t[a].correct,s.points=t[a].points,s.entityType==="competition"?i.push(s):s.entityType==="team"&&r.push(s)}),e.footballCompetitions=i,e.footballTeams=r,e}return new Bt};remapAchievementsStats=t=>t.map(e=>{let i=new ua;return i.id=e.id,i.achievedAt=e.achieved_at,i});remapDiscussionStats=t=>{let e=new ce;return e.totalPoints=t.total_points,e.postPoints=t.post_points,e.postsMade=t.posts_made,e.reactionPoints=t.reaction_points,e.reactionCount=t.reaction_count,e};remapClassicQuizStats=t=>{let e=new pe;return e.participationCount=t.participation_count,e.points=t.points,e};remapEitherOrStats=t=>{let e=new ue;return e.participationCount=t.participation_count,e}};var ge=class extends T{activityRemapper=null;constructor(t){super(t,S(t.environment,"loyalty")),this.activityRemapper=new ya}createActivity=async t=>{let e=`/activities${this.apiSignInUrl}`,i="There was a problem with creating activity",r="POST",a=await this.fetchWithAuth(e,i,r,t);return this.activityRemapper.remapSingleResponse(a)};deleteActivity=async t=>{let e=`/activities/${t}${this.apiSignInUrl}`,i=`There was a problem deleting the following activity: ${t}`,r="DELETE";return await this.fetchWithAuth(e,i,r),!0};getOwnActivities=async(t,e)=>{let i=`/activities${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with fetching own activities";t&&(i+=`${t.constructFilterUrl()}`),e&&(i+=`disable_cache=${r}`);let s=await this.fetchWithAuth(i,a);return this.activityRemapper.remapActivitiesResponse(s)};getActivitiesForUser=async(t,e,i)=>{let r=`/users/${t}/activities${this.apiSignInUrl}`,a=Date.now(),s=`There was a problem with fetching activities for user: ${t}`;e&&(r+=`${e.constructFilterUrl()}`),i&&(r+=`disable_cache=${a}`);let l=await this.fetchWithoutAuth(r,s);return this.activityRemapper.remapActivitiesResponse(l)};getStats=async(t,e)=>{let i="",r="",a=null;return t?(i+=w(e)?`/users/${t}/statistics${this.apiSignInUrl}${h()}`:`/users/${t}/statistics${this.apiSignInUrl}`,r=`There was a problem fetching statistics for profile: ${t}`,a=await this.fetchWithoutAuth(i,r)):(i+=`/statistics${this.apiSignInUrl}`,r="There was a problem fetching profile`s statistics",a=await this.fetchWithAuth(i,r)),this.activityRemapper.remapStatsResponse(a.data)}};var ba=class{id="";source="";type="";favourite=!1};var Ma=class extends ba{model=null};var wa=class{idMapping=null;idSchema=null;native="native";footballFacade=null;constructor(t,e,i){this.idMapping=i,this.idSchema=t.idSchema,this.footballFacade=e}remapProfileStats=async t=>{if(!t.predictions)return t;let{successRates:e,predictions:i}=t,r={competition:this.getIdsKeys(e.byFootballCompetition,i.single.breakdown.footballCompetitions),team:this.getIdsKeys(e.byFootballTeam,i.single.breakdown.footballTeams)};if(Object.values(r.competition).length){let a=JSON.parse(JSON.stringify(t.successRates.byFootballCompetition)),s=await this.getEntitiesMap(r.competition,"competition"),l=await this.setSuccessRatesModels(a,s);t.successRates.byFootballCompetition=l,i.single.breakdown.footballCompetitions=this.reconstructBreakdown(i.single.breakdown.footballCompetitions,s)}if(Object.values(r.team).length){let a=JSON.parse(JSON.stringify(t.successRates.byFootballTeam)),s=await this.getEntitiesMap(r.team,"team"),l=await this.setSuccessRatesModels(a,s);t.successRates.byFootballTeam=l,i.single.breakdown.footballTeams=this.reconstructBreakdown(i.single.breakdown.footballTeams,s)}return t};setSuccessRatesModels=async(t,e)=>{let i;return this.reconstructRecords(t,i,e)};getEntitiesMap=async(t,e)=>{switch(e){case"competition":return await this.footballFacade.getCompetitionsMapWithNativeIds(t);case"team":return await this.footballFacade.getTeamsMapWithNativeIds(t)}};reconstructRecords=(t,e,i)=>t&&Object.keys(t).length?(Object.keys(t).forEach(r=>{let a=i.get(r);e={...e,[a.id]:t[r]},e[a.id].model=a}),e):t;reconstructBreakdown=(t,e)=>t.length?t.map(i=>{let r=e.get(i.entityId);return i.entityId=r.id,i.model=r,i}):t;getIdsKeys=(t,e)=>{let i=Object.keys(t);if(e.length){let r=e.map(a=>a.entityId);return Array.from(new Set([...i,...r]))}return i};remapInterestsToIdSchema=async t=>{if(this.idSchema!==this.native)if(t&&t.length>0){let e={},i={},r=t.filter(n=>n.source.toLocaleUpperCase()==="FOOTBALL"),a=t.filter(n=>n.source.toLocaleUpperCase()!=="FOOTBALL");r.forEach(n=>{e.hasOwnProperty(n.type)||(e[n.type]=[],i[n.type]=[]),e[n.type].push(n.id),i[n.type].push(n)});let s=await this.remapIdsObj(e,this.native,this.idSchema),l=[];for(let[n,p]of Object.entries(i))p.forEach((c,u)=>{c.id=s[n][u],l.push(c)});return l.concat(a)}else return t;return t};remapInterestToNative=async t=>{if(this.idSchema!==this.native&&t.source.toLocaleUpperCase()==="FOOTBALL"){let e={},{id:i,type:r}=t;e[r]=[i];let a=await this.remapIdsObj(e,this.idSchema,this.native);return t.id=a[r][0],t}return t};inquiryCustomInterests=(t,e)=>{let i=[];return t&&t.length>0&&(i=t.filter(r=>r.source.toLocaleUpperCase()==="CUSTOM"),e)?i.map(r=>{let a=new Ma;return a.id=r.id,a.type=r.type,a.source=r.source,a.favourite=r.favourite,a}):i};remapInterests=async t=>{let i=this.inquiryCustomInterests(t,!1);if(i&&i.length>0){let r=t.filter(s=>s.source.toLocaleUpperCase()!=="CUSTOM"),a=await this.remapInterestsToIdSchema(r);return i.forEach(s=>a.push(s)),a}return await this.remapInterestsToIdSchema(t)};showFullInterests=async t=>{let e=[];if(t&&t.length>0){let r=this.inquiryCustomInterests(t,!0);e.push(r);let a=t.filter(c=>c.source.toLocaleUpperCase()!=="CUSTOM"),{competitionsMap:s,teamsMap:l,playersMap:n}=await this.getInterestsEntitiesMap(a),p=a.map(c=>{let u=null;if(c.source.toLocaleUpperCase()==="FOOTBALL"){if(c.type==="competition")return u=s.get(c.id),u&&(c.id=u.id),c.model=u,c;if(c.type==="team")return u=l.get(c.id),u&&(c.id=u.id),c.model=u,c;if(c.type==="player")return n?(c.model=n[c.id],c.id=n[c.id].id):c.model=u,c}else return c.model=u,c});return e.push(p),e.flat()}return e};getInterestsEntitiesMap=async t=>{let e=[],i=[],r=[],a=new Map,s=new Map,l=null;return t.forEach(n=>{n.type==="competition"&&n.source.toLocaleUpperCase()==="FOOTBALL"?e.push(n.id):n.type==="team"&&n.source.toLocaleUpperCase()==="FOOTBALL"?i.push(n.id):n.type==="player"&&n.source.toLocaleUpperCase()==="FOOTBALL"&&r.push(n.id)}),e.length&&(a=await this.footballFacade.getCompetitionsMapWithNativeIds(e)),i.length&&(s=await this.footballFacade.getTeamsMapWithNativeIds(i)),r.length&&(l=await this.footballFacade.getPlayersMapWithNativeIds(r)),{competitionsMap:a,teamsMap:s,playersMap:l}};remapIdsObj=async(t,e,i)=>await this.idMapping.idMappingFacade.getEntitiesByIds(t,e,i)};var Ia=class{idMapping=null;profileOperations=null;constructor(t,e){this.idMapping=new P(t),this.profileOperations=new wa(t,e,this.idMapping)}remapProfileStats=async t=>await this.profileOperations.remapProfileStats(t);remapInterestToNative=async t=>await this.profileOperations.remapInterestToNative(t);remapInterests=async t=>await this.profileOperations.remapInterests(t);showFullInterests=async t=>await this.profileOperations.showFullInterests(t)};var O=class{idsRemapper=null;profileHttps=null;activityHttps=null;footballHttps=null;footballFacade=null;idMapping=null;localCache=null;profileFacade=null;ownProfileBuilder=null;profileBuilder=null;constructor(t){this.profileHttps=new Wt(t),this.activityHttps=new ge(t),this.footballHttps=new X(t),this.idMapping=new P(t),this.localCache=new K().createLocalCacheInstance(t.idSchema),this.footballFacade=new ie(t,this.localCache,this.footballHttps,this.idMapping),this.profileFacade=new lt(this.localCache,this.profileHttps,this.activityHttps),this.idsRemapper=new Ia(t,this.footballFacade),this.ownProfileBuilder=new $i(t,this.idsRemapper,this.localCache,this.profileHttps,this.activityHttps),this.profileBuilder=new Wi(this.idsRemapper,this.localCache,this.profileHttps,this.activityHttps)}getOwn=()=>this.ownProfileBuilder;getById=t=>this.profileBuilder.setId(t);getCountries=async t=>await this.profileFacade.getCountries(t);getByIds=async(t,e,i)=>await this.profileFacade.getByIds(t,e,i)};var vn=(g=>(g.EN="en",g.BG="bg",g.RO="ro",g.EL="el",g.SK="sk",g.PT="pt",g.SR="sr",g.HU="hu",g.SV="sv",g.ES="es",g.FR="fr",g.NL="nl",g.DE="de",g.IT="it",g))(vn||{});var Pa=class{validate=t=>{let e=this.validateField(t.lang),i=this.generateMessage(e);return{validation:e,message:i}};validateField=t=>{let e=Object.values(vn),i=null;return t!=null&&t.length>0?e.includes(t)?i="valid":i="invalid":i="missing",i};generateMessage=t=>{let e=null,i="warning";return t==="missing"&&(e="If no lang is passed the default one will be set which is: en"),t==="invalid"&&(e="This lang value is not supported, the default one will be set which is: en"),t==="valid"&&(e=null,i=null),{text:e,type:i}}};var _a=class{validate(t){let e=this.validateField(t.environment),i=this.generateMessage(e);return{validation:e,message:i}}validateField=t=>{let e=["dev","staging","prod","watg"],i=null;return t!=null&&t.length>0?e.includes(t)?i="valid":i="invalid":i="missing",i};generateMessage=t=>{let e=null,i="warning";return t==="missing"&&(e="If no environment is passed the default one will be set which is: prod"),t==="invalid"&&(e="This environment value is not supported, the default one will be set which is: prod"),t==="valid"&&(e=null,i=null),{text:e,type:i}}};var Ta=class{validate(t){let e=this.validateField(t.apiKey),i=this.generateMessage(e);return{validation:e,message:i}}validateField=t=>{let e=null;return t!=null&&t.length>0?e="valid":e="missing",e};generateMessage=t=>{let e=null,i="error";return t==="missing"&&(e="The field apiKey with valid value must be provided to use Fans United JS SDK"),t==="valid"&&(i=null),{text:e,type:i}}};var va=class{validate(t){let e=this.validateField(t.idSchema),i=this.generateMessage(e);return{validation:e,message:i}}validateField=t=>{let e=Object.values(C),i=null;return t!=null&&t.length>0?e.includes(t)?i="valid":i="invalid":i="missing",i};generateMessage=t=>{let e=null,i="warning";return t==="missing"&&(e="If no idSchema is passed the default one will be set which is: native"),t==="invalid"&&(e="This idSchema value is not supported, the default one will be set which is: native"),t==="valid"&&(e=null,i=null),{text:e,type:i}}};var kt=class{getIdToken=null;logout=null};var ye=class{text=null;type=null};var Fa=class{validation=null;message=new ye;getIdToken={validation:null,message:new ye};logout={validation:null,message:new ye}};var Ea=class{validate(t){let e=this.validateAuthProvider(t.authProvider);return e.validation!=="missing"&&(e=this.validateAuthProviderConfigFields(t.authProvider,e),e=this.generateAuthProviderConfigMessages(e),e=this.checkAuthProviderConfigMessagesForErrors(e)),e}validateAuthProvider=t=>{let e=Object.keys(new kt),i=new Fa;if(t){let a=Object.keys(t).filter(s=>!e.includes(s));a.length>0?(i.validation="invalid",i.message.type="warning",i.message.text=`${"You have passed a property which is not supported for the authentication provider:"} ${a.join(",")}`):i.validation="valid"}else i.validation="missing",i.message.type="error",i.message.text="The field authProvider must be provided to use this SDK";return i};validateAuthProviderConfigFields=(t,e)=>(Object.keys(new kt).forEach(r=>{t[r]?e[r].validation="valid":e[r].validation="missing"}),e);generateAuthProviderConfigMessages=t=>(Object.keys(t).filter(e=>e!=="validation"&&e!=="message").forEach(e=>{let i=t[e];i.validation==="missing"&&(i.message.text=`${"The following property is missing from the authProvider object:"} ${e}`,i.message.type="error")}),t);checkAuthProviderConfigMessagesForErrors=t=>(Object.keys(t).filter(e=>e!=="validation"&&e!=="message").forEach(e=>{t[e].validation==="missing"&&t.validation==="valid"&&(t.validation="invalid",t.message.type="error",t.message.text="The field authProvider has missing properties")}),t)};var Ii=class{validation;message};var Sa=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;errorHandlingMode=null;authProvider={getIdToken:new Ii,logout:new Ii};isValid=!1};var Ra=class{validate(t){let e=this.validateField(t.clientId),i=this.generateMessage(e);return{validation:e,message:i}}validateField=t=>{let e=null;return t!=null&&t.length>0?e="valid":e="missing",e};generateMessage=t=>{let e=null,i="error";return t==="missing"&&(e="The field clientId must be provided to use Fans United JS SDK"),t==="valid"&&(e=null,i=null),{text:e,type:i}}};var Ca=class{validate=t=>{let e=this.validateField(t.errorHandlingMode),i=this.generateMessage(e);return{validation:e,message:i}};validateField=t=>{let e=["default","standard"],i=null;return t?e.includes(t)?i="valid":i="invalid":i="missing",i};generateMessage=t=>{let e=null,i="warning";return t==="missing"&&(e="If no errorHandlingMode is passed the default one will be set which is: default"),t==="invalid"&&(e="This errorHandlingMode value is not supported, the default one will be set which is: default"),t==="valid"&&(e=null,i=null),{text:e,type:i}}};var Aa=class{validate=t=>{let e=this.checkFieldsForValues(t);return e.isValid=this.containsErrorMessage(e),e};checkFieldsForValues=t=>{let e=new Sa,i={apiKey:new Ta,environment:new _a,idSchema:new va,clientId:new Ra,lang:new Pa,errorHandlingMode:new Ca,authProvider:new Ea};for(let[r,a]of Object.entries(e))r!=="isValid"&&(a=i[r].validate(t));return Object.keys(i).forEach(r=>{e[r]=i[r].validate(t)}),e};containsErrorMessage=t=>{let e=!0;for(let[i,r]of Object.entries(t))if(i!=="authProvider"){if(i!=="isValid"&&r.message.type==="error")return e=!1,e;if(i!=="isValid"&&r.message.type==="warning")return e=!0,e}else if(r.message.type==="error")return e=!1,e;return e}};var J=class{https=null;idMapping=null;localCache=null;footballFacade=null;constructor(t){this.https=new X(t),this.idMapping=new P(t),this.localCache=new K().createLocalCacheInstance(t.idSchema),this.footballFacade=new ie(t,this.localCache,this.https,this.idMapping)}getCountries=async t=>await this.footballFacade.getCountries(t);getCompetitions=async(t,e)=>await this.footballFacade.getCompetitions(t,e);getCompetitionById=async(t,e)=>await this.footballFacade.getCompetitionById(t,e);getTopCompetitions=async t=>await this.footballFacade.getTopCompetitions(t);getTeams=async(t,e)=>await this.footballFacade.getTeams(t,e);getTeamById=async(t,e)=>await this.footballFacade.getTeamById(t,e);getTopTeams=async t=>await this.footballFacade.getTopTeams(t);getNextMatchForTeam=async(t,e)=>await this.footballFacade.getNextMatchForTeam(t,e);getPrevMatchForTeam=async(t,e)=>await this.footballFacade.getPrevMatchForTeam(t,e);getPlayers=async(t,e)=>await this.footballFacade.getPlayers(t,e);getPlayerById=async(t,e)=>await this.footballFacade.getPlayerById(t,e);getTopPlayers=async t=>await this.footballFacade.getTopPlayers(t);getNextMatchForPlayer=async(t,e)=>await this.footballFacade.getNextMatchForPlayer(t,e);getPrevMatchForPlayer=async(t,e)=>await this.footballFacade.getPrevMatchForPlayer(t,e);getMatches=async(t,e)=>await this.footballFacade.getMatches(t,e);getMatchById=async(t,e)=>await this.footballFacade.getMatchById(t,e);search=async(t,e)=>await this.footballFacade.search(t,e)};var Oa=class{value=null;playerId=null;playerModel=null};var be=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new Oa;result=null};var La=class{value=!1;playerId=null};var Z=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i,r){this.matchId=t,this.market=e,this.prediction=new La,this.prediction.value=i,this.prediction.playerId=r}};var Me=class{settledAt=null;resettledAt=null;status=null;outcome=null;points=0};var xa=class{value=null};var Tt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new xa,this.prediction.value=i}};var tt=class{value=!1};var we=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new tt,this.prediction.value=i}};var Ie=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new tt,this.prediction.value=i}};var Da=class{matchFacade=null;playerFacade=null;predictorService=null;constructor(t,e,i){this.matchFacade=t,this.playerFacade=e,this.predictorService=i}remapFixturesRequest=t=>{let e={};if(e.match_id=t.matchId,e.match_type="FOOTBALL",t instanceof Z)e.market=t.market,e.prediction=t.prediction.value,e.player_id=t.prediction.playerId;else if(t instanceof we||t instanceof Ie)e.market=t.market,e.prediction=t.prediction.value;else if(t instanceof Tt){e.market=t.market;let i=t.prediction.value.split(":");e.goals_home=Number(i[0]),e.goals_away=Number(i[1])}else e.market=t.market,e.prediction=t.prediction.value;return e};remapFixturesResponse=async t=>{let e="OWN_GOAL",i=[],r=[],a=null,s=[];t.length>1&&t.sort((n,p)=>n.match_id.localeCompare(p.match_id));for(let n of t)i.push(n.match_id),n.player_id&&!r.includes(n.player_id)&&r.push(n.player_id);let l=await this.matchFacade.getMatchesMapWithNativeIds(i);r.sort((n,p)=>n.localeCompare(p)),r&&r.length>0&&!r.includes(e)&&(a=await this.playerFacade.getPlayersMapWithNativeIds(r));for(let n of t){let p=new be;n.target?p.market=this.predictorService.convertMarketForResponseModel(n.market,n.target):p.market=n.market,p.matchId=l[n.match_id].id,p.matchType=n.match_type,p.matchModel=l?l[n.match_id]:null,delete p.matchModel.availableMarkets,n.prediction!==void 0?p.prediction.value=n.prediction:n.goals_home!==void 0&&n.goals_away!==void 0&&(p.prediction.value=n.goals_home.toString()+":"+n.goals_away.toString()),p.prediction.playerId=n.player_id?n.player_id:null,p.prediction.playerId&&p.prediction.playerId!==e&&(p.prediction.playerModel=a[n.player_id],p.prediction.playerId=a[n.player_id].id),p.result=this.remapResult(n.result),s.push(p)}return s};remapResult=t=>{let e=new Me;return e.settledAt=t.settled_at,e.resettledAt=t.resettled_at,e.status=t.status,e.outcome=t.outcome,e.points=t.points,e}};var ut=class{goldenGoal=null};var Pi=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new ut;points=null;templateId=null;groupId=null;createdAt=null;updatedAt=null};var F=class{no=0;yes=0};var Ba=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new F;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new F;penaltyMatch=new F;playerScoreFirstGoal={};cornersMatch={};correctScore={};correctScoreHalfTime={};correctScoreAdvanced={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new F;overOnePointFiveGoals=new F;overTwoPointFiveGoals=new F;overThreePointFiveGoals=new F;overFourPointFiveGoals=new F;overFivePointFiveGoals=new F;overSixPointFiveGoals=new F;overSixPointFiveCorners=new F;overSevenPointFiveCorners=new F;overEightPointFiveCorners=new F;overNinePointFiveCorners=new F;overTenPointFiveCorners=new F;overElevenPointFiveCorners=new F;overTwelvePointFiveCorners=new F;overThirteenPointFiveCorners=new F};var dt=class{timeTiebreaker=!1};var vt=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new dt;predictionId=null;participantsCount=0;related=null;excludedProfileIds=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;scheduleOpenAt=null;images=null;predictionTiebreaker=new ut;branding=null};var Ut=class{userId=null;points=null;results=[];tiebreaker=null};var Fn=(a=>(a.ACTIVE="ACTIVE",a.WON="WON",a.LOST="LOST",a.PARTIALLY_WON="PARTIALLY_WON",a.CANCELED="CANCELED",a))(Fn||{}),Hn=["WON","LOST","PARTIALLY_WON","CANCELED"];var L=class{limit=null;startAfter=null;status=null;type=null;matchIds=null;gameIds=null;constructor(t){this.limit=t?.limit||null,this.startAfter=t?.startAfter||null,this.status=t?.status||null,this.type=t?.type||null,this.matchIds=t?.matchIds||null,this.gameIds=t?.gameIds||null}constructFiltersUrl=()=>{let t="",e=!1;return this.status&&(e=Object.values(Fn).some(i=>this.status.includes(i))),this.limit&&(t+="&",t+=`limit=${this.limit}`),this.startAfter&&(t+="&",t+=`start_after=${this.startAfter}`),this.status&&e&&(t+="&",t+=`status=${this.status.join(",")}`),this.type&&(t+="&",t+=`game_types=${this.type}`),this.matchIds&&this.matchIds.length>0&&(t+="&",t+=`match_ids=${this.matchIds.join(",")}`),this.gameIds&&this.gameIds.length>0&&(t+="&",t+=`game_ids=${this.gameIds.join(",")}`),t}};var v=class{limit;startAfter;constructor(t){this.limit=t&&t.limit?t.limit:null,this.startAfter=t&&t.startAfter?t.startAfter:null}constructMainFiltersUrl(){let t="";return this.limit&&(t+="&",t+=`limit=${this.limit}`),this.startAfter&&(t+="&",t+=`start_after=${this.startAfter}`),t}};var Na=(s=>(s.OPEN="OPEN",s.LIVE="LIVE",s.PENDING="PENDING",s.CANCELED="CANCELED",s.CLOSED="CLOSED",s.SETTLED="SETTLED",s))(Na||{});var et=class extends v{status=null;type=null;gameIds=null;sortOrder=null;constructor(t){super(t),this.status=t?.status||null,this.type=t?.type||null,this.gameIds=t?.gameIds||null,this.sortOrder=t?.sortOrder||null}constructFiltersUrl=()=>{let t=super.constructMainFiltersUrl();return this.status&&Object.values(Na).includes(this.status)&&(t+="&",t+=`status=${this.status}`),this.type&&(t+="&",t+=`type=${this.type}`),this.gameIds&&this.gameIds.length>0&&(t+="&",t+=`game_ids=${this.gameIds.join(",")}`),this.sortOrder&&(t+="&",t+=`sort_order=${this.sortOrder}`),t}};var it=class{main=null;cover=null;mobile=null};var ft=class{id=null;title=null;description=null;type=null;status=null;scheduleOpenAt=null;predictionsCutoff=null;fixtures=[];tiebreaker=new dt;participantsCount=0;related=null;excludedProfileIds=null;rules=null;labels=null;customFields=null;branding=null;flags=null;images=new it;createdAt=null;updatedAt=null};var yt=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new dt;predictionId=null;participantsCount=0;related=null;excludedProfileIds=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;images=null;scheduleOpenAt=null;branding=null};var Pe=class extends ft{adContent=null};var _e=class{homeGoals=null;awayGoals=null};var ka=class{playerId=null;playerModel=null};var Ua=class{FT_1X2=null;HT_1X2=null;BOTH_TEAMS_SCORE=null;DOUBLE_CHANCE=null;HT_FT=null;RED_CARD_MATCH=null;PENALTY_MATCH=null;CORNERS_MATCH=null;PLAYER_YELLOW_CARD=[];PLAYER_RED_CARD=[];PLAYER_SCORE_FIRST_GOAL=new ka;PLAYER_SCORE=[];PLAYER_SCORE_TWICE=[];PLAYER_SCORE_HATTRICK=[];CORRECT_SCORE=new _e;CORRECT_SCORE_ADVANCED=new _e;CORRECT_SCORE_HT=new _e;OVER_GOALS_0_5=null;OVER_GOALS_1_5=null;OVER_GOALS_2_5=null;OVER_GOALS_3_5=null;OVER_GOALS_4_5=null;OVER_GOALS_5_5=null;OVER_GOALS_6_5=null;OVER_CORNERS_6_5=null;OVER_CORNERS_7_5=null;OVER_CORNERS_8_5=null;OVER_CORNERS_9_5=null;OVER_CORNERS_10_5=null;OVER_CORNERS_11_5=null;OVER_CORNERS_12_5=null;OVER_CORNERS_13_5=null};var En=(i=>(i.ONE="1",i.X="x",i.TWO="2",i))(En||{}),Sn=(i=>(i.ONE_X="1x",i.X_TWO="x2",i.ONE_TWO="12",i))(Sn||{}),Rn=(p=>(p.ONE_ONE="1/1",p.ONE_X="1/x",p.ONE_TWO="1/2",p.X_ONE="x/1",p.X_X="x/x",p.X_TWO="x/2",p.TWO_ONE="2/1",p.TWO_X="2/x",p.TWO_TWO="2/2",p))(Rn||{});var Cn=class{constructor(){}static createMatchMarketsResultsModel(t,e){return{FT_1X2:this.createOneXTwoResult(t.scores,"full_time"),HT_1X2:this.createOneXTwoResult(t.scores,"half_time"),BOTH_TEAMS_SCORE:t.scores.ftScore.homeGoals>0&&t.scores.ftScore.awayGoals>0,DOUBLE_CHANCE:this.createDoubleChanceResult(t.scores),HT_FT:this.createHalfTimeFullTimeResult(t.scores),RED_CARD_MATCH:this.createMarketResultByCriteria(t,"red_card"),PENALTY_MATCH:this.createMarketResultByCriteria(t,"penalty"),CORNERS_MATCH:isNaN(t.stats?.corners?.homeTeam+t.stats?.corners?.awayTeam)?null:t.stats.corners.homeTeam+t.stats.corners.awayTeam,PLAYER_YELLOW_CARD:this.createPlayersMarketsResults(t,e,"yellow_card"),PLAYER_RED_CARD:this.createPlayersMarketsResults(t,e,"red_card"),PLAYER_SCORE_FIRST_GOAL:this.createPlayersMarketsResults(t,e,"first_goal"),PLAYER_SCORE:this.createPlayersMarketsResults(t,e,"one_goal"),PLAYER_SCORE_TWICE:this.createPlayersMarketsResults(t,e,"two_goals"),PLAYER_SCORE_HATTRICK:this.createPlayersMarketsResults(t,e,"hattrick"),CORRECT_SCORE:{homeGoals:t.scores.ftScore.homeGoals,awayGoals:t.scores.ftScore.awayGoals},CORRECT_SCORE_ADVANCED:{homeGoals:t.scores.ftScore.homeGoals,awayGoals:t.scores.ftScore.awayGoals},CORRECT_SCORE_HT:{homeGoals:t.scores.htScore.homeGoals,awayGoals:t.scores.htScore.awayGoals},OVER_GOALS_0_5:t.scores.ftScore.homeGoals+t.scores.ftScore.awayGoals>0,OVER_GOALS_1_5:t.scores.ftScore.homeGoals+t.scores.ftScore.awayGoals>1,OVER_GOALS_2_5:t.scores.ftScore.homeGoals+t.scores.ftScore.awayGoals>2,OVER_GOALS_3_5:t.scores.ftScore.homeGoals+t.scores.ftScore.awayGoals>3,OVER_GOALS_4_5:t.scores.ftScore.homeGoals+t.scores.ftScore.awayGoals>4,OVER_GOALS_5_5:t.scores.ftScore.homeGoals+t.scores.ftScore.awayGoals>5,OVER_GOALS_6_5:t.scores.ftScore.homeGoals+t.scores.ftScore.awayGoals>6,OVER_CORNERS_6_5:isNaN(t.stats?.corners?.homeTeam+t.stats?.corners?.awayTeam)?null:t.stats.corners.homeTeam+t.stats.corners.awayTeam>6,OVER_CORNERS_7_5:isNaN(t.stats?.corners?.homeTeam+t.stats?.corners?.awayTeam)?null:t.stats.corners.homeTeam+t.stats.corners.awayTeam>7,OVER_CORNERS_8_5:isNaN(t.stats?.corners?.homeTeam+t.stats?.corners?.awayTeam)?null:t.stats.corners.homeTeam+t.stats.corners.awayTeam>8,OVER_CORNERS_9_5:isNaN(t.stats?.corners?.homeTeam+t.stats?.corners?.awayTeam)?null:t.stats.corners.homeTeam+t.stats.corners.awayTeam>9,OVER_CORNERS_10_5:isNaN(t.stats?.corners?.homeTeam+t.stats?.corners?.awayTeam)?null:t.stats.corners.homeTeam+t.stats.corners.awayTeam>10,OVER_CORNERS_11_5:isNaN(t.stats?.corners?.homeTeam+t.stats?.corners?.awayTeam)?null:t.stats.corners.homeTeam+t.stats.corners.awayTeam>11,OVER_CORNERS_12_5:isNaN(t.stats?.corners?.homeTeam+t.stats?.corners?.awayTeam)?null:t.stats.corners.homeTeam+t.stats.corners.awayTeam>12,OVER_CORNERS_13_5:isNaN(t.stats?.corners?.homeTeam+t.stats?.corners?.awayTeam)?null:t.stats.corners.homeTeam+t.stats.corners.awayTeam>13}}},mt=Cn;ot(mt,"createOneXTwoResult",(t,e)=>e==="full_time"?t.ftScore.homeGoals>t.ftScore.awayGoals?"1":t.ftScore.homeGoals===t.ftScore.awayGoals?"x":"2":t?.htScore?.homeGoals>t?.htScore?.awayGoals?"1":t?.htScore?.homeGoals===t?.htScore?.awayGoals?"x":"2"),ot(mt,"createDoubleChanceResult",t=>t?.ftScore?.homeGoals>t?.ftScore?.awayGoals?["1x","12"]:t?.ftScore?.homeGoals===t?.ftScore?.awayGoals?["1x","x2"]:["x2","12"]),ot(mt,"createHalfTimeFullTimeResult",t=>{if(t?.htScore?.homeGoals>t?.htScore?.awayGoals){if(t?.ftScore?.homeGoals>t?.ftScore?.awayGoals)return"1/1";if(t?.ftScore?.homeGoals===t?.ftScore?.awayGoals)return"1/x";if(t?.ftScore?.homeGoals<t?.ftScore?.awayGoals)return"1/2"}if(t?.htScore?.homeGoals===t?.htScore?.awayGoals){if(t?.ftScore?.homeGoals>t?.ftScore?.awayGoals)return"x/1";if(t?.ftScore?.homeGoals===t?.ftScore?.awayGoals)return"x/x";if(t?.ftScore?.homeGoals<t?.ftScore?.awayGoals)return"x/2"}if(t?.htScore?.homeGoals<t?.htScore?.awayGoals){if(t?.ftScore?.homeGoals>t?.ftScore?.awayGoals)return"2/1";if(t?.ftScore?.homeGoals===t?.ftScore?.awayGoals)return"2/x";if(t?.ftScore?.homeGoals<t?.ftScore?.awayGoals)return"2/2"}}),ot(mt,"createMarketResultByCriteria",(t,e)=>!t.timeline||!t.timeline.length?null:e==="red_card"?t.timeline.filter(i=>Number(i.minute)<=90).some(i=>i.type==="red_card"):t.timeline.filter(i=>Number(i.minute)<=90).some(i=>i.type.startsWith(e))),ot(mt,"createPlayersMarketsResults",(t,e,i)=>{if(!t.timeline||!t.timeline.length)return i==="first_goal"?null:[];if(i==="first_goal"){let l=t.timeline.find(n=>n.type==="goal"||n.type==="penalty_goal"||n.type==="own_goal")||null;if(l){let n=e[l.player.id];return{playerId:l.type==="goal"||l.type==="penalty_goal"?l.player.id:"OWN_GOAL",playerModel:n}}return null}if(i==="yellow_card"||i==="red_card")return Cn.transformPlayerMarketResult(t.timeline.filter(l=>Number(l.minute)<=90).filter(l=>l.type===i).map(l=>e[l.player.id]));let r=new Map,a=i==="one_goal"?1:i==="two_goals"?2:3,s=[];return t.timeline.filter(l=>Number(l.minute)<=90).filter(l=>l.type==="goal"||l.type==="penalty_goal").forEach(l=>{let n=e[l.player.id];if(r.has(l.player.id)){let p=r.get(l.player.id);p.push(n),r.set(l.player.id,p)}else r.set(l.player.id,[n])}),r.forEach(l=>{l.length>=a&&s.push(l[0])}),Cn.transformPlayerMarketResult(s)}),ot(mt,"transformPlayerMarketResult",t=>t.map(e=>({playerId:e.id,playerModel:e})));var ht=class{footballHttps=null;idMapping=null;matchFacade=null;playerFacade=null;profileNamespace=null;constructor(t,e){this.footballHttps=new X(t),this.idMapping=e,this.matchFacade=new Pt(t,this.footballHttps,e),this.playerFacade=new wt(t,this.footballHttps,e),this.profileNamespace=new O(t)}remapMatchIdToNative=async t=>(await this.idMapping.getEntityIdsBySchemaId(t,"match","native")).match;remapPlayerIdToNative=async t=>(await this.idMapping.getEntityIdsBySchemaId(t,"player","native")).player[0];remapPlayerIdMapToNative=async t=>{let e={},i=Lt(t),a=(await this.idMapping.getEntityIdsBySchemaId(i,"player","native")).player;return i.forEach((s,l)=>e[s]=a[l]),e};remapPlayerIdToIdSchema=async t=>{let e=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"],i=[];for(let[a,s]of Object.entries(t))if(e.includes(a))for(let l of Object.keys(s))l!=="NOBODY"&&l!=="OWN_GOAL"&&i.push(l);if(!i.length)return t;let r=await this.playerFacade.getPlayersMapWithNativeIds(i);for(let[a,s]of Object.entries(t))if(e.includes(a))for(let l of Object.keys(s))l!=="NOBODY"&&l!=="OWN_GOAL"&&(s[r[l].id]=s[l],s[r[l].id].model=r[l],this.idMapping.idSchema!=="native"&&delete s[l]);return t};convertMarketForResponseModel=(t,e)=>{let i=e.toString();return t+"_"+i};getMarketSummary=async(t,e,i)=>{let r=jn.get(e),a={};if(a.matchId=t.matchId,a.matchType=t.matchType,Object.keys(t.predictions).includes(r))a[r]=t.predictions[r];else throw new Error("You have passed invalid market");if(ct.includes(e)&&i){let l="";if(i!=="OWN_GOAL"&&i!=="NOBODY"&&(l=(await this.idMapping.idMappingFacade.getEntitiesByIds({player:[i]},this.idMapping.idSchema,"native")).player[0]),l&&a[r][l]){let n=await this.playerFacade.getPlayersMapWithNativeIds([l]);return a[r][l].model=n[l],a[r][l]}else return l?(a[r][l]=new F,a[r][l]):a[r][i]}else if(ct.includes(e)&&!i){let l=Object.keys(a[r]).filter(p=>p!=="NOBODY"&&p!=="OWN_GOAL"),n=l.length?await this.playerFacade.getPlayersMapWithNativeIds(l):{};Object.keys(n).length&&Object.keys(a[r]).forEach(p=>{p!=="NOBODY"&&p!=="OWN_GOAL"&&(a[r][n[p].id]=a[r][p],a[r][n[p].id].model=n[p],this.idMapping.idSchema!=="native"&&delete a[r][p])})}return a};remapCompetitionsFromConfig=async t=>{if(t instanceof Yt){let e={competition:t.fullCoverageCompetitions},i={competition:t.successRateScopes.competitions},r={team:t.successRateScopes.teams},a=await this.idMapping.idMappingFacade.getEntitiesByIds(e,"native",this.idMapping.idSchema),s=await this.idMapping.idMappingFacade.getEntitiesByIds(i,"native",this.idMapping.idSchema),l=await this.idMapping.idMappingFacade.getEntitiesByIds(r,"native",this.idMapping.idSchema);return t.fullCoverageCompetitions=a.competition,t.successRateScopes.competitions=s.competition,t.successRateScopes.teams=l.team,t}if(t instanceof Xt||t instanceof jt){let e={competition:t.competitionsWhitelist},i=await this.idMapping.idMappingFacade.getEntitiesByIds(e,"native",this.idMapping.idSchema);return t.competitionsWhitelist=i.competition,t}};remapMatchIdsFixtures=async t=>{if(Array.isArray(t.data))if(t.data.length>0){let e=[],i=[];return t.data.forEach(r=>{r instanceof ft||r instanceof vt||r instanceof yt||r instanceof Pe?(r.fixtures.forEach(a=>e.push(a.matchId)),r instanceof yt&&r.fixtures.forEach(a=>{a.prediction.playerId&&a.prediction.playerId!=="OWN_GOAL"&&i.push(a.prediction.playerId)})):r instanceof Ut&&r.results.forEach(a=>e.push(a.matchId))}),await this.refactorResponseArrModel(t,e,i)}else return t;else return await this.refactorResponseObjModel(t)};refactorResponseArrModel=async(t,e,i)=>{let r=[],a=await this.matchFacade.getMatchesMapWithNativeIds(e),s={};return i.length>0&&(s=await this.playerFacade.getPlayersMapWithNativeIds(i)),t.data.forEach(l=>{l instanceof ft||l instanceof vt||l instanceof yt?(l.fixtures.forEach(n=>{this.handleMatchModel(a,n),l instanceof yt&&n.prediction.playerId&&n.prediction.playerId!=="OWN_GOAL"&&(n.prediction.playerModel=s[n.prediction.playerId],n.prediction.playerId=s[n.prediction.playerId].id)}),r.push(l)):l instanceof Ut&&(l.results.forEach(n=>{n.matchModel=a[n.matchId],delete n.matchModel.availableMarkets,n.matchId=n.matchModel.id}),r.push(l))}),t.data=r,t};refactorResponseObjModel=async t=>{let e=[];t.fixtures.forEach(r=>e.push(r.matchId));let i=await this.matchFacade.getMatchesMapWithNativeIds(e);return t.fixtures.forEach(r=>this.handleMatchModel(i,r)),t};getCurrentGameId=t=>{let e=new Date;if(t.data.length>1){let i=[];return t.data.forEach(a=>i.push(a.predictionsCutoff)),t.data.sort((a,s)=>{let[l,n]=[a.predictionsCutoff,s.predictionsCutoff].map(p=>Math.abs(new Date(p)-e));return l-n})[0].id}else return t.data[0].id};initGameTypePredictions=(t,e)=>{let i={type:t,limit:null,startAfter:null};return e&&(i={...i,limit:e.limit,startAfter:e.startAfter}),i=new L(i),i};initGameFilters=(t,e,i)=>{if(e&&i)return e.type=t,e.gameIds=i,e=new et(e),e;if(e&&!i)return e.type=t,e=new et(e),e;if(!e&&i){let r={type:t,gameIds:i};return r=new et(r),r}else{let r={type:t};return r=new et(r),r}};addPredictionProp=async(t,e)=>(e.data.forEach(i=>{t.data.forEach(r=>{i.id===r.game_instance_id&&(i.predictionId=r.id,i.outcome=r.status,i.fixtures.forEach((a,s)=>{r.fixtures[s].goals_home!==void 0&&r.fixtures[s].goals_away!==void 0?a.prediction.value=r.fixtures[s].goals_home+":"+r.fixtures[s].goals_away:a.prediction.value=r.fixtures[s].prediction,r.fixtures[s].player_id?a.prediction.playerId=r.fixtures[s].player_id:r.fixtures[s].target&&(a.prediction.target=r.fixtures[s].target),a.prediction.result=this.remapResult(r.fixtures[s].result)}),i.predictionsMadeAt=r.created_at,i.points=r.points,i instanceof vt&&(r.tiebreaker?i.predictionTiebreaker.goldenGoal=r.tiebreaker.golden_goal:i.predictionTiebreaker=r.tiebreaker))})}),e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,await this.remapMatchIdsFixtures(e));remapResult=t=>{let e=new Me;return e.settledAt=t.settled_at,e.resettledAt=t.resettled_at,e.status=t.status,e.outcome=t.outcome,e.points=t.points,e};areIdsExceeded=t=>t.length>10;initPredictionsFilters=(t,e,i)=>{switch(e){case"user":t&&(t=new L(t));break;case"current":if(t)this.deleteUnexpectedProperties(t),t.status=["ACTIVE"],t=new L(t);else{let r={status:["ACTIVE"]};t=new L(r)}break;case"past":if(t)this.deleteUnexpectedProperties(t),t.status=Hn,t=new L(t);else{let r={status:Hn};t=new L(r)}break;case"matches":if(t)this.deleteUnexpectedProperties(t),t.matchIds=i,t=new L(t);else{let r={matchIds:i};t=new L(r)}break}return t};completeGameMarketResults=async(t,e)=>{switch(e){case"MATCH_QUIZ":let i={},r=t.results[0].matchId,a=t.results.map(p=>ct.includes(p.market)&&!p.result.includes("OWN_GOAL")?[...p.result]:[]).flat(),s=await this.matchFacade.getMatchesMapWithNativeIds([r]);return a.length&&(i=await this.playerFacade.getPlayersMapWithNativeIds(a)),t.results=t.results.map(p=>{if(p.matchModel=s[p.matchId]?s[p.matchId]:null,p.playerModels&&Object.keys(i).length&&p.result.forEach(u=>{let d=i[u];p.playerModels.push(d)}),this.idMapping.idSchema!=="native"&&(this.remapMatchIdForResultsMarkets(s,p),p.playerModels&&Object.keys(i).length)){let c=p.result;p.result=c.map(u=>i[u].id)}return p}),t;case"TOP_X":let l=t.results.map(p=>p.matchId),n=await this.matchFacade.getMatchesMapWithNativeIds(l);if(t.results=t.results.map(p=>(p.matchModel=n[p.matchId]?n[p.matchId]:null,this.idMapping.idSchema!=="native"&&this.remapMatchIdForResultsMarkets(n,p),p)),t.tieBreakers.goldenGoals.length){let p=t.tieBreakers.goldenGoals.map(u=>u.playerId),c=await this.playerFacade.getPlayersMapWithNativeIds(p);t.tieBreakers.goldenGoals=t.tieBreakers.goldenGoals.map(u=>(u.matchModel=n[u.matchId],u.playerModel=c[u.playerId],this.idMapping.idSchema!=="native"&&(u.matchId=n[u.matchId].id,u.playerId=c[u.playerId].id),u))}return t}};completeContestWinners=async t=>{if(t.userList&&t.userList.length){let e=t.userList.map(r=>r.profileId),i=await this.profileNamespace.getByIds(e);t.userList.forEach(r=>{let a=i.filter(s=>s.id===r.profileId)[0];delete a.interests,r.profileModel=a})}return t};handleMatchModel=(t,e)=>{t[e.matchId]?(e.matchModel=t[e.matchId],delete e.matchModel.availableMarkets,e.matchId=e.matchModel.id):(e.matchModel=null,this.idMapping.idSchema!=="native"&&this.idMapping.idMappingFacade.getEntityById(e.matchId,"match","native").then(i=>{e.matchId=i[D[this.idMapping.idSchema]]}))};remapMatchIdForResultsMarkets=(t,e)=>{t[e.matchId]?e.matchId=t[e.matchId].id:this.idMapping.idMappingFacade.getEntityById(e.matchId,"match","native").then(i=>{e.matchId=i[D[this.idMapping.idSchema]]})};deleteUnexpectedProperties=t=>(t.status&&(console.warn(kn.UNEXPECTED_STATUS_PROP),delete t.status),t.type&&(console.warn(kn.UNEXPECTED_TYPE_PROP),delete t.type),t);getMatchMarketsResults=async t=>{let e=await this.footballHttps.getMatchById(t,!0);if(e.status.type!=="finished"||!e.finishedAt)return new Ua;let i=[];e.timeline.filter(a=>Number(a.minute)<=90).filter(a=>a.type==="goal"||a.type==="penalty_goal"||a.type==="yellow_card"||a.type==="red_card").forEach(a=>{i.push(a.player.id)});let r={};return i.length&&(r=await this.playerFacade.getPlayersMapWithNativeIds(i)),mt.createMatchMarketsResultsModel(e,r)}};var Te=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(t){this.gameInstanceId=t.gameInstanceId,t.fixtures.forEach(e=>this.fixtures.push(new Tt(e.matchId,e.market,e.prediction.value))),this.tiebreaker=t.tiebreaker?t.tiebreaker:null}};var ve=class{template_id=null;group_id=null;fixtures=[]};var Fe=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(t,e){this.footballHttps=new X(t),this.matchFacade=new Pt(t,this.footballHttps,e),this.playerFacade=new wt(t,this.footballHttps,e),this.predictorService=new ht(t,e),this.fixturesRemapper=new Da(this.matchFacade,this.playerFacade,this.predictorService)}remapRequestBody=t=>{if(t instanceof ve)return t;let e={};return e.game_instance_id=t.gameInstanceId,e.fixtures=t.fixtures.map(i=>this.fixturesRemapper.remapFixturesRequest(i)),t instanceof Te&&t.tiebreaker&&(e.tiebreaker={},e.tiebreaker.golden_goal=t.tiebreaker.goldenGoal?t.tiebreaker.goldenGoal:null),e};remapResponseArrayBody=async t=>{if(t.length){let e="OWN_GOAL",i=[],r=[],a={},s=[];t.forEach(n=>{n.fixtures.forEach(p=>{i.push(p.match_id),p.player_id&&p.player_id!==e&&r.push(p.player_id)})});let l=await this.matchFacade.getMatchesMapWithNativeIds(i);return r.length>0&&(a=await this.playerFacade.getPlayersMapWithNativeIds(r)),t.forEach(n=>{let p=new Pi,c=[];p.id=n.id,p.gameInstanceId=n.game_instance_id,p.gameType=n.game_type,p.wager=n.wager,p.totalFixtures=n.total_fixtures,p.settledFixtures=n.settled_fixtures,p.userId=n.user_id,p.templateId=n.template_id,p.groupId=n.group_id,n.fixtures.forEach(u=>{let d=new be;u.target?d.market=this.predictorService.convertMarketForResponseModel(u.market,u.target):d.market=u.market,d.matchId=l[u.match_id].id,d.matchType=u.match_type,d.matchModel=l[u.match_id],delete d.matchModel.availableMarkets,u.prediction!==void 0?d.prediction.value=u.prediction:u.goals_home!==void 0&&u.goals_away!==void 0&&(d.prediction.value=u.goals_home.toString()+":"+u.goals_away.toString()),d.prediction.playerId=u.player_id?u.player_id:null,d.prediction.playerId&&d.prediction.playerId!==e&&(d.prediction.playerModel=a[d.prediction.playerId],d.prediction.playerId=a[d.prediction.playerId].id),d.result=this.fixturesRemapper.remapResult(u.result),c.push(d)}),p.fixtures=c,p.status=n.status,n.tiebreaker?p.tiebreaker.goldenGoal=n.tiebreaker.golden_goal:p.tiebreaker=null,p.points=n.points,p.createdAt=n.created_at,p.updatedAt=n.updated_at,s.push(p)}),s}return t};remapResponseObjBody=async t=>{let e=new Pi;return e.id=t.id,e.gameInstanceId=t.game_instance_id,e.gameType=t.game_type,e.wager=t.wager,e.totalFixtures=t.total_fixtures,e.settledFixtures=t.settled_fixtures,e.userId=t.user_id,e.templateId=t.template_id,e.groupId=t.group_id,e.fixtures=await this.fixturesRemapper.remapFixturesResponse(t.fixtures),e.status=t.status,t.tiebreaker?e.tiebreaker.goldenGoal=t.tiebreaker.golden_goal:e.tiebreaker=null,e.points=t.points,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapPredictionModel=t=>{let e=new Ba;return e.fullTimeOneXTwo=t.FT_1X2,e.halfTimeOneXTwo=t.HT_1X2,e.bothTeamsScore=t.BOTH_TEAMS_SCORE,e.overZeroPointFiveGoals=t.OVER_GOALS_0_5,e.overOnePointFiveGoals=t.OVER_GOALS_1_5,e.overTwoPointFiveGoals=t.OVER_GOALS_2_5,e.overThreePointFiveGoals=t.OVER_GOALS_3_5,e.overFourPointFiveGoals=t.OVER_GOALS_4_5,e.overFivePointFiveGoals=t.OVER_GOALS_5_5,e.overSixPointFiveGoals=t.OVER_GOALS_6_5,e.overSixPointFiveCorners=t.OVER_CORNERS_6_5,e.overSevenPointFiveCorners=t.OVER_CORNERS_7_5,e.overEightPointFiveCorners=t.OVER_CORNERS_8_5,e.overNinePointFiveCorners=t.OVER_CORNERS_9_5,e.overTenPointFiveCorners=t.OVER_CORNERS_10_5,e.overElevenPointFiveCorners=t.OVER_CORNERS_11_5,e.overTwelvePointFiveCorners=t.OVER_CORNERS_12_5,e.overThirteenPointFiveCorners=t.OVER_CORNERS_13_5,e.doubleChance=t.DOUBLE_CHANCE,e.halfTimeFullTime=t.HT_FT,e.playerScore=t.PLAYER_SCORE,e.playerYellowCard=t.PLAYER_YELLOW_CARD,e.playerRedCard=t.PLAYER_RED_CARD,e.redCardMatch=t.RED_CARD_MATCH,e.penaltyMatch=t.PENALTY_MATCH,e.playerScoreFirstGoal=t.PLAYER_SCORE_FIRST_GOAL,e.cornersMatch=t.CORNERS_MATCH,e.correctScore=t.CORRECT_SCORE,e.correctScoreHalfTime=t.CORRECT_SCORE_HT,e.correctScoreAdvanced=t.CORRECT_SCORE_ADVANCED,e.playerScoreHattrick=t.PLAYER_SCORE_HATTRICK,e.playerScoreTwice=t.PLAYER_SCORE_TWICE,e}};var Ga=class{matchId=null;matchType=null;predictions=null};var Va=class{remapPredictions=null;constructor(t,e){this.remapPredictions=new Fe(t,e)}remapResponse=t=>{let e=new Ga;return e.matchId=t.match_id,e.matchType=t.match_type,e.predictions=this.remapPredictions.remapPredictionModel(t.predictions),e}};var Ha=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new j};var $a=class{value=null;target=null;playerId=null;playerModel=null;result=null};var Wa=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new j;prediction=new $a};var za=class{value=null;result=null};var qa=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new j;prediction=new za};var Qa=class{matchId=null;matchModel=null;outcome=null};var Ka=class{gameId=null;results=null;tieBreakers=null};var Ee=class{entityId=null;entityType=null};var ja=class{contestId="";contestType="GAME";contestModel=null;description="";userList=[]};var Xa=class{position="";profileId="";profileModel=null;note="";tags=[]};var Ya=class{primaryColor=null;secondaryColor=null;contentColor=null;backgroundColor=null;borderColor=null;additionalColor=null};var Ja=class{mainLogo=null;mobileLogo=null;backgroundImage=null;mobileBackgroundImage=null;additionalImage=null};var Za=class{colors=null;urls=null;images=null};var to=class{primaryUrl=null;secondaryUrl=null;privacyPolicyUrl=null;termsAndConditionsUrl=null;additionalUrl=null};var rt=class{remapBranding=t=>{let e=new Za;return t.colors&&(e.colors=new Ya,e.colors.primaryColor=t.colors.primary_color,e.colors.secondaryColor=t.colors.secondary_color,e.colors.contentColor=t.colors.content_color,e.colors.backgroundColor=t.colors.background_color,e.colors.borderColor=t.colors.border_color,e.colors.additionalColor=t.colors.additional_color),t.urls&&(e.urls=new to,e.urls.primaryUrl=t.urls.primary_url,e.urls.secondaryUrl=t.urls.secondary_url,e.urls.privacyPolicyUrl=t.urls.privacy_policy_url,e.urls.termsAndConditionsUrl=t.urls.terms_and_conditions_url,e.urls.additionalUrl=t.urls.additional_url),t.images&&(e.images=new Ja,e.images.mainLogo=t.images.main_logo,e.images.mobileLogo=t.images.mobile_logo,e.images.backgroundImage=t.images.background_image,e.images.mobileBackgroundImage=t.images.mobile_background_image,e.images.additionalImage=t.images.additional_image),e}};var eo=class extends rt{remapPaginatedGames=t=>{let e=new R;return e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.data=t.data.map(i=>this.remapGamesListResponse(i)),e};remapGamesListResponse=t=>{let e=new ft;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.status=t.status,e.scheduleOpenAt=t.schedule_open_at,e.predictionsCutoff=t.predictions_cutoff,e.fixtures=t.fixtures.map(i=>this.remapFixturesResponse(i)),e.tiebreaker=t.tiebreaker?this.remapTimeTiebreaker(t.tiebreaker.time_tiebreaker):null,e.participantsCount=t.participants_count,e.related=t.related?this.remapRelated(t.related):null,e.excludedProfileIds=t.excluded_profile_ids,e.rules=t.rules,e.labels=t.labels,e.customFields=t.custom_fields,e.branding=t.branding?this.remapBranding(t.branding):null,e.flags=t.flags,e.images=t.images,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapGameByIdResponse=t=>{let e=new Pe;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.status=t.status,e.scheduleOpenAt=t.schedule_open_at,e.predictionsCutoff=t.predictions_cutoff,e.fixtures=t.fixtures.map(i=>this.remapFixturesResponse(i)),e.tiebreaker=t.tiebreaker?this.remapTimeTiebreaker(t.tiebreaker.time_tiebreaker):null,e.participantsCount=t.participants_count,e.related=t.related?this.remapRelated(t.related):null,e.excludedProfileIds=t.excluded_profile_ids,e.rules=t.rules,e.flags=t.flags,e.adContent=t.ad_content,e.labels=t.labels,e.customFields=t.custom_fields,e.branding=t.branding?this.remapBranding(t.branding):null,e.images=t.images,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapFixturesResponse=t=>{let e=new Ha;return e.matchId=t.match_id,e.matchType=t.match_type,e.market=t.market,e.matchStatus.type=t.match_status?t.match_status.type:null,e.matchStatus.subType=t.match_status?t.match_status.sub_type:null,e};remapPaginatedUserTopXEditions=t=>{let e=new R;return e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.data=t.data.map(i=>this.remapUserTopXEditionsResponse(i)),e};remapUserTopXEditionsResponse=t=>{let e=new vt;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.status=t.status,e.predictionsCutoff=t.predictions_cutoff,e.scheduleOpenAt=t.schedule_open_at,e.fixtures=t.fixtures.map(i=>this.remapTopXFixturesResponse(i)),e.tiebreaker=t.tiebreaker?this.remapTimeTiebreaker(t.tiebreaker.time_tiebreaker):null,e.participantsCount=t.participants_count,e.related=t.related?this.remapRelated(t.related):null,e.excludedProfileIds=t.excluded_profile_ids,e.rules=t.rules,e.flags=t.flags,e.images=t.images,e.branding=t.branding?this.remapBranding(t.branding):null,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapTopXFixturesResponse=t=>{let e=new qa;return e.matchId=t.match_id,e.matchType=t.match_type,e.market=t.market,e.matchStatus.type=t.match_status?t.match_status.type:null,e.matchStatus.subType=t.match_status?t.match_status.sub_type:null,e};remapPaginatedUserMathQuizEditions=t=>{let e=new R;return e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.data=t.data.map(i=>this.remapUserMatchQuizEditionsResponse(i)),e};remapUserMatchQuizEditionsResponse=t=>{let e=new yt;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.status=t.status,e.predictionsCutoff=t.predictions_cutoff,e.scheduleOpenAt=t.schedule_open_at,e.fixtures=t.fixtures.map(i=>this.remapMatchQuizFixturesResponse(i)),e.tiebreaker=t.tiebreaker?this.remapTimeTiebreaker(t.tiebreaker.time_tiebreaker):null,e.participantsCount=t.participants_count,e.related=t.related?this.remapRelated(t.related):null,e.excludedProfileIds=t.excluded_profile_ids,e.rules=t.rules,e.flags=t.flags,e.images=t.images,e.branding=t.branding?this.remapBranding(t.branding):null,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapMatchQuizFixturesResponse=t=>{let e=new Wa;return e.matchId=t.match_id,e.matchType=t.match_type,e.market=t.market,e.matchStatus.type=t.match_status?t.match_status.type:null,e.matchStatus.subType=t.match_status?t.match_status.sub_type:null,e};remapPaginatedGameResults=t=>{let e=new R;return e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.data=t.data.map(i=>this.remapGameResults(i)),e};remapGameResults=t=>{let e=new Ut;return e.userId=t.user_id,e.points=t.points?t.points:0,e.results=t.results.map(i=>this.remapResults(i)),e.tiebreaker=t.tiebreaker?this.remapTiebreaker(t.tiebreaker):null,e};remapGameMarketsResults=t=>{let e=new Ka;return e.gameId=t.game_id,e.results=this.remapMarketsResults(t.results),e.tieBreakers=t.tie_breakers?this.remapTieBreakers(t.tie_breakers):null,e};remapContestWinners=t=>{let e=new ja;return e.contestId=t.contest_id,e.contestType=t.contest_type,e.description=t.description,e.userList=t.user_list?t.user_list.map(i=>this.remapUserListWinners(i)):null,e};remapUserListWinners=t=>{let e=new Xa;return e.position=t.position,e.profileId=t.profile_id,e.note=t.note,e.tags=t.tags,e};remapTieBreakers=t=>{let e={goldenGoals:[]};return e.goldenGoals=t.golden_goals.map(i=>({minute:i.minute,matchId:i.match_id,matchModel:null,playerId:i.player_id,playerModel:null,goalType:i.goal_type})),e};remapMarketsResults=t=>{let e=[];return t.forEach(i=>{let r={matchId:i.match_id,market:i.market,result:this.remapMarketResult(i.market,i.result),matchModel:null,playerModels:[],matchStatus:this.remapMarketsResultsMatchStatus(i.match_status)};e.push(this.deleteUnusefulField(r))}),e};remapMarketsResultsMatchStatus=t=>{let e=new j;return t&&(e.type=t.type,e.subType=t.sub_type),e};remapMarketResult=(t,e)=>{if(Pl.includes(t))return e[0];if(ct.includes(t))return e;if(e[0]==="true")return!0;if(e[0]==="false")return!1};deleteUnusefulField=t=>((!ct.includes(t.market)||this.isPlayerMarketWithNoResult(t.market,t.result))&&delete t.playerModels,t);isPlayerMarketWithNoResult=(t,e)=>ct.includes(t)&&e.length===0;remapResults=t=>{let e=new Qa;return e.matchId=t.match_id,e.outcome=t.outcome,e};remapTiebreaker=t=>{let e=new ut;return e.goldenGoal=t.golden_goal,e};remapTimeTiebreaker=t=>{let e=new dt;return e.timeTiebreaker=t,e};remapRelated=t=>t.map(e=>{let i=new Ee;return i.entityId=e.entity_id,i.entityType=e.entity_type,i})};var io=class{remapMetaData=t=>{let e=new x;return e.pagination.nextPageStartsAfter=t.pagination.next_page_starts_after,e.pagination.itemsPerPage=t.pagination.items_per_page,e}};var at=class extends T{predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;metaRemapper=null;constructor(t,e){super(t,S(t.environment,"predictor")),this.predictionRemapper=new Fe(t,e),this.matchSummaryRemapper=new Va(t,e),this.gamesRemapper=new eo,this.metaRemapper=new io}makeFootballPrediction=async t=>{let e=`/predictions${this.apiSignInUrl}`,i="There was a problem making POST request",r="POST",a=await this.fetchWithAuth(e,i,r,this.predictionRemapper.remapRequestBody(t));return await this.predictionRemapper.remapResponseObjBody(a)};getMatchSummary=async(t,e)=>{let i=w(e)?`/predictions/summary/${t}${this.apiSignInUrl}${h()}`:`/predictions/summary/${t}${this.apiSignInUrl}`,r=`There was a problem fetching predictions for match: ${t}`,a=await this.fetchWithoutAuth(i,r);return this.matchSummaryRemapper.remapResponse(a)};deleteFootballPrediction=async t=>{let e=`/predictions/${t}${this.apiSignInUrl}`,i=`There was a problem deleting your prediction: ${t}`,r="DELETE";return await this.fetchWithAuth(e,i,r),!0};getMyPredictions=async t=>{let e=new R,i=`/predictions${this.apiSignInUrl}`,r="There was a problem fetching own predictions";t&&(i+=`${t.constructFiltersUrl()}`);let a=await this.fetchWithAuth(i,r);return e.meta=this.metaRemapper.remapMetaData(a.meta),e.data=await this.predictionRemapper.remapResponseArrayBody(a.data),e};getMyPredictionsNoRemap=async t=>{let e=`/predictions${this.apiSignInUrl}${t.constructFiltersUrl()}`,i="There was a problem fetching own predictions";return await this.fetchWithAuth(e,i)};getUserPredictions=async(t,e,i)=>{let r=new R,a=w(e)?`/predictions/users/${t}${this.apiSignInUrl}${h()}`:`/predictions/users/${t}${this.apiSignInUrl}`,s=`There was a problem fetching predictions for user: ${t}`;i&&(a+=`${i.constructFiltersUrl()}`);let l=await this.fetchWithoutAuth(a,s);return r.meta=this.metaRemapper.remapMetaData(l.meta),r.data=await this.predictionRemapper.remapResponseArrayBody(l.data),r};getUserPredictionsNoRemap=async(t,e)=>{let i=`/predictions/users/${t}${this.apiSignInUrl}${e.constructFiltersUrl()}`,r=`There was a problem fetching predictions for user: ${t}`;return await this.fetchWithoutAuth(i,r)};getGames=async(t,e)=>{let i=w(e)?`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}${h()}`:`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}`,r="There was a problem fetching the games list",a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapPaginatedGames(a)};getGameById=async(t,e)=>{let i=w(e)?`/games/${t}${this.apiSignInUrl}${h()}`:`/games/${t}${this.apiSignInUrl}`,r=`There was a problem fetching the following game: ${t}`,a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapGameByIdResponse(a)};getGamePredictions=async(t,e,i)=>{let r=new R,a=w(e)?`/games/${t}/predictions${this.apiSignInUrl}${h()}`:`/games/${t}/predictions${this.apiSignInUrl}`,s=`There was a problem fetching the predictions for game: ${t}`;i&&(a+=`${i.constructFiltersUrl()}`);let l=await this.fetchWithoutAuth(a,s);return r.meta=this.metaRemapper.remapMetaData(l.meta),r.data=await this.predictionRemapper.remapResponseArrayBody(l.data),r};getUserGameEditions=async(t,e)=>{let i=null,r=w(e)?`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}${h()}`:`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}`,a="There was a problem fetching the games list",s=await this.fetchWithoutAuth(r,a);return s.data.forEach(l=>{l.type==="TOP_X"?i=this.gamesRemapper.remapPaginatedUserTopXEditions(s):l.type==="MATCH_QUIZ"&&(i=this.gamesRemapper.remapPaginatedUserMathQuizEditions(s))}),i};getGameResults=async(t,e,i)=>{let r=w(e)?`/games/${t}/results/${this.apiSignInUrl}${h()}`:`/games/${t}/results/${this.apiSignInUrl}`,a=`There was a problem fetching the results for the following game: ${t}`;i&&(r+=`${i.constructMainFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a);return this.gamesRemapper.remapPaginatedGameResults(s)};getMarketResultsForGame=async(t,e)=>{let i=`/games/${t}/correct-results/${this.apiSignInUrl}`,r=`There was a problem fetching the markets correct results for the following game: ${t}`;w(e)&&(i+=`${h()}`);let a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapGameMarketsResults(a.data)};getContestWinners=async(t,e)=>{let i=`/winners/${this.apiSignInUrl}&contest_id=${t}`,r=`There was a problem fetching winners for the following game: ${t}`;e&&(i+=h());let a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapContestWinners(a)};getPredictionById=async t=>{let e=`/predictions/${t}${this.apiSignInUrl}`,i=`There was a problem fetching info for the following prediction: ${t}`,r=await this.fetchWithoutAuth(e,i);return(await this.predictionRemapper.remapResponseArrayBody([r.data]))[0]};getPredictionsByIds=async t=>{let e=`/predictions/by-ids${this.apiSignInUrl}&prediction_ids=${t.join(",")}`,i="There was a problem fetching predictions",r=await this.fetchWithoutAuth(e,i);return await this.predictionRemapper.remapResponseArrayBody(r.data)}};var Se=class{gameInstanceId=null;fixtures=null};var ro=class{matchId=null;market="BOTH_TEAMS_SCORE";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new tt,this.prediction.value=e}};var ao=class{value};var oo=class{matchId=null;market="CORNERS_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new ao,this.prediction.value=e}};var so=class{value=null};var no=class{matchId=null;market="DOUBLE_CHANCE";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new so,this.prediction.value=e}};var lo=class{value=null};var po=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new lo,this.prediction.value=i}};var co=class{value=null};var uo=class{matchId=null;market="HT_FT";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new co,this.prediction.value=e}};var mo=class{matchId=null;market="PENALTY_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new tt,this.prediction.value=e}};var ho=class{matchId=null;market="RED_CARD_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new tt,this.prediction.value=e}};var Ft=class{errorHandlingMode=null;constructor(t){this.errorHandlingMode=t}validateBodyFields=(t,e)=>{let i=Object.keys(e),r=Object.keys(new Se);switch(t){case"MATCH_QUIZ":i.forEach(n=>{r.includes(n)||this.throwInvalidParamException([n])});break;case"TOP_X":let s=e;s.fixtures.forEach(n=>this.validateMarketTopX(n.market));let l="tiebreaker";i.includes(l)&&s.tiebreaker&&this.validateTiebreaker(s.tiebreaker),i.forEach(n=>{n!=="tiebreaker"&&!r.includes(n)&&this.throwInvalidParamException([n])});break}let a=r.filter(s=>!i.includes(s));return a.length&&this.throwMissingFieldsException("game prediction body",a),e.fixtures.forEach(s=>{this.validateFixtureFields(s)}),e};validateFixture=(t,e,i,r)=>{this.validateMarket(e);let a=Object.values(En),s=Object.values(Rn),l=Object.values(Sn);if(e==="FT_1X2"||e==="HT_1X2"){if(a.includes(i))return new po(t,e,i)}else if(e==="HT_FT"){if(s.includes(i))return new uo(t,i)}else if(e==="DOUBLE_CHANCE"){if(l.includes(i))return new no(t,i)}else if(e==="CORRECT_SCORE"||e==="CORRECT_SCORE_ADVANCED"||e==="CORRECT_SCORE_HT"){if(typeof i=="string"&&/\d+:\d+/.test(i))return new Tt(t,e,i)}else if(e==="CORNERS_MATCH"){if(typeof i=="number")return new oo(t,i)}else if(e==="BOTH_TEAMS_SCORE"){if(this.isPredictionBoolean(i))return new ro(t,i)}else if(e==="RED_CARD_MATCH"){if(this.isPredictionBoolean(i))return new ho(t,i)}else if(e==="PENALTY_MATCH"){if(this.isPredictionBoolean(i))return new mo(t,i)}else if(ct.includes(e)){let n="OWN_GOAL";if(this.validatePlayerId(e,r),e===bi&&this.isPredictionBoolean(i)){let p=r&&r===n?n:r;return new Z(t,e,i,p)}if(r&&this.isPredictionBoolean(i))return new Z(t,e,i,r)}else if(wl.includes(e)){if(this.isPredictionBoolean(i))return new Ie(t,e,i)}else if(Il.includes(e)&&this.isPredictionBoolean(i))return new we(t,e,i);this.throwInvalidPredictionException(i,e)};validateFixtureFields=t=>{let e=Object.keys(t);e.forEach(r=>{Nn.includes(r)||this.throwInvalidParamException([r])});let i=Nn.filter(r=>{if(r!=="matchType"&&!e.includes(r))return r});i.length&&this.throwMissingFieldsException("fixtures",i),this.validatePredictionKey(t.market,t.prediction)};validateTiebreaker=t=>{let e=Object.keys(t);(!e.length||typeof t!="object")&&this.throwInvalidType("tiebreaker","object");let i=Object.keys(new ut)[0];e.forEach(r=>{i!==r&&this.throwInvalidParamException([r])}),e.includes(i)||this.throwMissingFieldsException("tiebreaker",[i]),typeof t.goldenGoal!="number"&&this.throwInvalidType("goldenGoal","number")};validatePredictionKey=(t,e)=>{if(typeof e=="object"){let i=Object.keys(e),r=["value"];if(i.length||this.throwMissingFieldsException("prediction",r),i.length===1&&!i.includes(r[0])&&this.throwInvalidParamException(i),i.length>1){ct.includes(t)&&r.push("playerId");let a=i.filter(s=>!r.includes(s));a.length&&this.throwInvalidParamException(a)}}else this.throwInvalidType("prediction","object")};validatePlayerId=(t,e)=>{let i="playerId";t!==bi&&(e||this.throwInvalidParamException([i]),typeof e!="string"&&this.throwInvalidType(i,"string"))};validateMarket=t=>{Object.values(Y).includes(t)||this.throwInvalidMarketException(t)};validateMarketTopX=t=>{t!=="CORRECT_SCORE"&&t!=="CORRECT_SCORE_ADVANCED"&&this.throwInvalidMarketException(t,"TOP_X")};isPredictionBoolean=t=>typeof t=="boolean";throwInvalidPredictionException=(t,e)=>{let i=Xn(t,e);throw this.errorHandlingMode==="default"?new f(400,"INVALID_PREDICTION",i):new m(400,"INVALID_TYPE",i)};throwInvalidMarketException=(t,e)=>{let i=null;throw e&&e==="TOP_X"?i=Yn(t):i=Mn(t),this.errorHandlingMode==="default"?new f(400,"INVALID_MARKET",i):new m(400,"INVALID_TYPE",i)};throwInvalidParamException=t=>{let e=Jn(t);throw this.errorHandlingMode==="default"?new f(400,"INVALID_FIELD",e):new m(400,"INVALID_TYPE",e)};throwMissingFieldsException=(t,e)=>{let i=Zn(t,e);throw this.errorHandlingMode==="default"?new f(400,"INVALID_FIELD",i):new m(400,"INVALID_TYPE",i)};throwInvalidType=(t,e)=>{let i=tl(t,e);throw this.errorHandlingMode==="default"?new f(400,"INVALID_TYPE",i):new m(400,"INVALID_TYPE",i)}};var go=class{predictorHttps=null;clientHttps=null;idMapping=null;predictorService=null;predictorValidator=null;errorHandlingMode=null;constructor(t,e,i,r){this.predictorHttps=e,this.idMapping=r,this.clientHttps=i,this.errorHandlingMode=t.errorHandlingMode,this.predictorValidator=new Ft(t.errorHandlingMode),this.predictorService=new ht(t,r)}makeFootballPrediction=async(t,e,i,r)=>{let a=this.predictorValidator.validateFixture(t,e,i,r),s=new Se;if(this.idMapping.idSchema!=="native"){let l=a.matchId,n="",p=await this.predictorService.remapMatchIdToNative([l]);if(a.matchId=p[0],this.errorHandlingMode==="default"&&!a.matchId)throw new f(400,"INVALID_FIELD","Match id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&!a.matchId)throw new m(400,"INVALID_FIELD","Match id is invalid!");if(a instanceof Z&&a.prediction.playerId!=="OWN_GOAL"){if(a.prediction.playerId&&(n=a.prediction.playerId,a.prediction.playerId=await this.predictorService.remapPlayerIdToNative([n])),this.errorHandlingMode==="default"&&a.market!==bi&&!a.prediction.playerId)throw new f(400,"INVALID_FIELD","Player id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&a.market!==bi&&!a.prediction.playerId)throw new m(400,"INVALID_FIELD","Player id is invalid!")}s.fixtures=[a];let c=await this.predictorHttps.makeFootballPrediction(s);return c.fixtures.forEach(u=>{u.prediction.playerId&&u.prediction.playerId!=="OWN_GOAL"&&(u.prediction.playerId=n),u.matchId=l}),c}else return s.fixtures=[a],await this.predictorHttps.makeFootballPrediction(s)};getMatchSummary=async(t,e)=>{let i=await this.getMatchSummaryBase(t,e),r=JSON.parse(JSON.stringify(i.predictions)),a=await this.predictorService.remapPlayerIdToIdSchema(r);return i.predictions=a,i};getMarketSummary=async(t,e,i,r)=>{try{let a=await this.getMatchSummaryBase(t,r);return await this.predictorService.getMarketSummary(a,e,i)}catch(a){throw a}};getMatchSummaryBase=async(t,e)=>{if(this.idMapping.idSchema!=="native"){let r=(await this.predictorService.remapMatchIdToNative([t]))[0],a=await this.predictorHttps.getMatchSummary(r,e);return a.matchId=t,a}else return await this.predictorHttps.getMatchSummary(t,e)};getConfig=async()=>{let t=await this.clientHttps.getConfig("predictor");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(t):t};deleteFootballPrediction=async t=>await this.predictorHttps.deleteFootballPrediction(t);getMyPredictions=async t=>{let e=this.predictorService.initPredictionsFilters(t,"user");return await this.predictorHttps.getMyPredictions(e)};getMyPredictionsForMatches=async(t,e)=>{if(this.errorHandlingMode==="default"&&this.predictorService.areIdsExceeded(t))throw new f(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();if(this.errorHandlingMode==="standard"&&this.predictorService.areIdsExceeded(t))throw new m(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.");this.idMapping.idSchema!=="native"&&(t=await this.predictorService.remapMatchIdToNative([...t]));let i=this.predictorService.initPredictionsFilters(e,"matches",t);return await this.predictorHttps.getMyPredictions(i)};getMyCurrentPredictions=async t=>{let e=this.predictorService.initPredictionsFilters(t,"current");return await this.predictorHttps.getMyPredictions(e)};getMyPastPredictions=async t=>{let e=this.predictorService.initPredictionsFilters(t,"past");return await this.predictorHttps.getMyPredictions(e)};getUserPredictions=async(t,e,i)=>{let r=this.predictorService.initPredictionsFilters(e,"user");return await this.predictorHttps.getUserPredictions(t,i,r)};getUserCurrentPredictions=async(t,e,i)=>{let r=this.predictorService.initPredictionsFilters(e,"current");return await this.predictorHttps.getUserPredictions(t,i,r)};getUserPastPredictions=async(t,e,i)=>{let r=this.predictorService.initPredictionsFilters(e,"past");return await this.predictorHttps.getUserPredictions(t,i,r)};getUserPredictionsForMatches=async(t,e,i,r)=>{if(this.errorHandlingMode==="default"&&this.predictorService.areIdsExceeded(e))throw new f(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();if(this.errorHandlingMode==="standard"&&this.predictorService.areIdsExceeded(e))throw new m(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.");this.idMapping.idSchema!=="native"&&(e=await this.predictorService.remapMatchIdToNative([...e]));let a=this.predictorService.initPredictionsFilters(i,"matches",e);return await this.predictorHttps.getUserPredictions(t,r,a)};getPredictionById=async t=>await this.predictorHttps.getPredictionById(t);getPredictionsByIds=async t=>await this.predictorHttps.getPredictionsByIds(t);getMatchMarketsResults=async t=>(this.idMapping.idSchema!=="native"&&(t=(await this.predictorService.remapMatchIdToNative([t]))[0]),await this.predictorService.getMatchMarketsResults(t))};var Re=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(t){this.idMapping=new P(t),this.predictorHttps=new at(t,this.idMapping),this.clientHttps=new N(t),this.predictorFacade=new go(t,this.predictorHttps,this.clientHttps,this.idMapping)}makeFootballPrediction=async(t,e,i,r)=>await this.predictorFacade.makeFootballPrediction(t,e,i,r);getMatchSummary=async(t,e)=>await this.predictorFacade.getMatchSummary(t,e);getMarketSummary=async(t,e,i,r)=>await this.predictorFacade.getMarketSummary(t,e,i,r);getConfig=async()=>await this.predictorFacade.getConfig();deleteFootballPrediction=async t=>await this.predictorFacade.deleteFootballPrediction(t);getMyPredictions=async t=>await this.predictorFacade.getMyPredictions(t);getMyCurrentPredictions=async t=>await this.predictorFacade.getMyCurrentPredictions(t);getMyPastPredictions=async t=>await this.predictorFacade.getMyPastPredictions(t);getMyPredictionsForMatches=async(t,e)=>await this.predictorFacade.getMyPredictionsForMatches(t,e);getUserPredictions=async(t,e,i)=>await this.predictorFacade.getUserPredictions(t,e,i);getUserCurrentPredictions=async(t,e,i)=>await this.predictorFacade.getUserCurrentPredictions(t,e,i);getUserPastPredictions=async(t,e,i)=>await this.predictorFacade.getUserPastPredictions(t,e,i);getUserPredictionsForMatches=async(t,e,i,r)=>await this.predictorFacade.getUserPredictionsForMatches(t,e,i,r);getPredictionById=async t=>await this.predictorFacade.getPredictionById(t);getPredictionsByIds=async t=>await this.predictorFacade.getPredictionsByIds(t);getMatchMarketsResults=async t=>await this.predictorFacade.getMatchMarketsResults(t)};var fo=class{templateId=null;privateLeagueId=null;fromDate=null;toDate=null;pagination=new V};var yo=class{rankType=null;fromDate=null;toDate=null;pagination=new V};var Ce=class{position=null;profileId=null;profileModel=null;points=null;predictionsMade=null};var bo=class{remapResponse=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapData(t.data),t);remapLeagueLeaderboardResponse=t=>(t.meta=this.remapLeagueLeaderboardMeta(t.meta),t.data=this.remapData(t.data),t);remapMeta=t=>{let e=new yo;return e.rankType=t.rank_type,e.fromDate=t.from_date,e.toDate=t.to_date,e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.totalItems=t.pagination.total_items,e.pagination.numberOfPages=t.pagination.number_of_pages,e};remapLeagueLeaderboardMeta=t=>{let e=new fo;return e.templateId=t.template_id,e.privateLeagueId=t.private_league_id,e.fromDate=t.from_date,e.toDate=t.to_date,e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.totalItems=t.pagination.total_items,e.pagination.numberOfPages=t.pagination.number_of_pages,e};remapData=t=>{let e=[];return t.forEach(i=>{let r=new Ce;r.position=i.position,r.profileId=i.profile_id,r.points=i.points,r.predictionsMade=i.predictions_made,e.push(r)}),e}};var Mo=class{templateId="";templateModel=null;challengeId="";challengeModel=null;position="";points=0;type="challenge"};var wo=class{templateId="";templateModel=null;privateLeagueId="";privateLeagueModel=null;position="";points=0;type="private_league"};var Io=class extends Ce{id=null;rankType=null;model=null;gameType=null};var Po=class{remapRankings=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapData(t.data),t);remapRankingsPrivateLeague=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapDataUserRankingPrivateLeague(t.data),t);remapRankingsChallenge=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapDataUserRankingChallenge(t.data),t);remapMeta=t=>{let e=new H;return e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.numberOfPages=t.pagination.number_of_pages,e.pagination.totalItems=t.pagination.total_items,e};remapData(t){let e=[];return t.forEach(i=>{let r=new Io;r.id=i.id,r.rankType=i.rank_type,r.position=i.position,r.points=i.points,r.gameType=i.game_type,delete r.profileId,delete r.profileModel,delete r.predictionsMade,e.push(r)}),e}remapDataUserRankingPrivateLeague(t){let e=[];return t.forEach(i=>{let r=new wo;r.templateId=i.template_id,r.privateLeagueId=i.private_league_id,r.position=i.position,r.points=i.points,e.push(r)}),e}remapDataUserRankingChallenge(t){let e=[];return t.forEach(i=>{let r=new Mo;r.templateId=i.template_id,r.challengeId=i.private_league_id,r.position=i.position,r.points=i.points,e.push(r)}),e}};var _o=class{flags="";status="";type="";activeFrom="";activeTo="";createdFrom="";createdTo="";updatedFrom="";updatedTo=""};var To=class{pagination=new V;filters=new _o};var Ae=class{id=null;name=null;description=null;type=null;fromDate=null;toDate=null;markets=[];teamIds=[];matchIds=[];groups=[];gameIds=[];gameTypes=[];competitionIds=[];excludedProfileIds=[];rules=null;labels=null;customFields=null;branding=null;flags=null;images=new it;status=null;automaticallyChangeStatus=!0;createdAt=null;updatedAt=null;related=null};var vo=class extends Ae{adContent=null};var Fo=class{fromDate=null;toDate=null;matchIds=[]};var Eo=class{groupId=null;label=null;flags=[];filters=null};var So=class extends rt{remapResponse=t=>{let e=[];return t.forEach(i=>{let r=new Ae;r.id=i.id,r.name=i.name,r.description=i.description,r.type=i.type,r.fromDate=i.from_date,r.toDate=i.to_date,r.markets=i.markets?i.markets:null,r.teamIds=i.team_ids?i.team_ids:null,r.matchIds=i.match_ids?i.match_ids:null,r.groups=i.groups?this.remapGroups(i.groups):null,r.gameIds=i.game_ids?i.game_ids:null,r.gameTypes=i.game_types?i.game_types:null,r.competitionIds=i.competition_ids?i.competition_ids:null,r.excludedProfileIds=i.excluded_profile_ids?i.excluded_profile_ids:null,r.rules=i.rules?i.rules:null,r.labels=i.labels?i.labels:null,r.customFields=i.custom_fields?i.custom_fields:null,r.branding=i.branding?this.remapBranding(i.branding):null,r.flags=i.flags?i.flags:null,r.images=i.images?i.images:null,r.status=i.status?i.status:null,r.automaticallyChangeStatus=i.automatically_change_status,r.createdAt=i.created_at,r.updatedAt=i.updated_at,r.related=i.related?this.remapRelated(i.related):null,e.push(r)}),e};remapResponseId=t=>{let e=new vo;return e.id=t.id,e.name=t.name,e.description=t.description,e.type=t.type,e.fromDate=t.from_date,e.toDate=t.to_date,e.markets=t.markets?t.markets:null,e.teamIds=t.team_ids?t.team_ids:null,e.matchIds=t.match_ids?t.match_ids:null,e.groups=t.groups?this.remapGroups(t.groups):null,e.gameIds=t.game_ids?t.game_ids:null,e.gameTypes=t.game_types?t.game_types:null,e.competitionIds=t.competition_ids?t.competition_ids:null,e.excludedProfileIds=t.excluded_profile_ids?t.excluded_profile_ids:null,e.rules=t.rules?t.rules:null,e.flags=t.flags?t.flags:null,e.images=t.images?t.images:null,e.status=t.status?t.status:null,e.automaticallyChangeStatus=t.automatically_change_status,e.related=t.related?this.remapRelated(t.related):null,e.labels=t.labels,e.customFields=t.custom_fields,e.branding=t.branding?this.remapBranding(t.branding):null,e.adContent=t.ad_content,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapMeta=t=>{let e=new To;return e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.totalItems=t.pagination.total_items,e.pagination.numberOfPages=t.pagination.number_of_pages,e.filters.flags=t.filters.flags,e.filters.status=t.filters.status,e.filters.type=t.filters.type,e.filters.activeFrom=t.filters.active_from,e.filters.activeTo=t.filters.active_to,e.filters.createdFrom=t.filters.created_from,e.filters.createdTo=t.filters.created_to,e.filters.updatedFrom=t.filters.updated_from,e.filters.updatedTo=t.filters.updated_to,e};remapRelated=t=>t.map(e=>{let i=new Ee;return i.entityId=e.entity_id,i.entityType=e.entity_type,i});remapGroups=t=>t.map(e=>{let i=new Eo;return i.groupId=e.group_id,i.label=e.label,i.flags=e.flags,i.filters=this.remapGroupFilters(e.filters),i});remapGroupFilters=t=>{let e=new Fo;return e.fromDate=t.from_date,e.toDate=t.to_date,e.matchIds=t.match_ids,e}};var Ro=class{position=null;points=null;predictionsMade=null;profileId=null;profileModel=null;successRatePercent=null};var Co=class{remapHighestSuccessRate=t=>t.map(e=>{let i=new Ro;return i.position=e.position,i.points=e.points,i.predictionsMade=e.predictions_made,i.profileId=e.profile_id,i.successRatePercent=e.success_rate_percent,i})};var Et=class extends T{templateRemapper=null;leaderboardRemapper=null;rankingsRemapper=null;highestSuccessRateRemapper=null;constructor(t){super(t,S(t.environment,"loyalty")),this.templateRemapper=new So,this.leaderboardRemapper=new bo,this.rankingsRemapper=new Po,this.highestSuccessRateRemapper=new Co}getTemplates=async(t,e)=>{let i=t?`/leaderboard/templates/${this.apiSignInUrl}${t.constructFiltersUrl()}`:`/leaderboard/templates/${this.apiSignInUrl}`;i+=w(e)?h():"";let r="There was a problem fetching the list of templates",a=await this.fetchWithoutAuth(i,r),s=JSON.parse(JSON.stringify(a));return s.meta=this.templateRemapper.remapMeta(a.meta),s.data=this.templateRemapper.remapResponse(a.data),s};getTemplateById=async(t,e)=>{let i=w(e)?`/leaderboard/templates/${t}${this.apiSignInUrl}${h()}`:`/leaderboard/templates/${t}${this.apiSignInUrl}`,r=`There was a problem requesting the following template: ${t}`,a=await this.fetchWithoutAuth(i,r);return this.templateRemapper.remapResponseId(a.data)};getLeaderboard=async(t,e,i)=>{let r=w(e)?`/leaderboard/${t}${this.apiSignInUrl}${h()}`:`/leaderboard/${t}${this.apiSignInUrl}`,a=`There was a problem fetching the leaderboard for the following template: ${t}`;i&&(r+=`${i.constructFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a),l=JSON.parse(JSON.stringify(s));return this.leaderboardRemapper.remapResponse(l)};getLeaderboardForGame=async(t,e,i)=>{let r=w(e)?`/leaderboard/games/${t}${this.apiSignInUrl}${h()}`:`/leaderboard/games/${t}${this.apiSignInUrl}`,a=`There was a problem fetching the leaderboard for the following game: ${t}`;i&&(r+=`${i.constructFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a),l=JSON.parse(JSON.stringify(s));return this.leaderboardRemapper.remapResponse(l)};getLeaderboardForLeague=async(t,e)=>{let i=`/private-league/${t}${this.apiSignInUrl}`,r=`There was a problem fetching the leaderboard for the following league: ${t}`;e&&(i+=`${e.constructFiltersUrl()}`);let a=await this.fetchWithoutAuth(i,r);return this.leaderboardRemapper.remapLeagueLeaderboardResponse(a)};getUserRankings=async(t,e,i)=>{let r=`/leaderboard/users/${t}/rankings${this.apiSignInUrl}`,a=`There was a problem fetching the rankings for the following user: ${t}`;e&&(r+=`${e.constructFiltersUrl()}`),w(i)&&(r+=`${h()}`);let s=await this.fetchWithoutAuth(r,a);return this.rankingsRemapper.remapRankings(s)};getHighestSuccessRate=async(t,e)=>{let i=`/statistics/top${this.apiSignInUrl}`,r="There was a problem fetching highest success rate";t&&(i+=`${t.constructFiltersUrl()}`),w(e)&&(i+=`${h()}`);let a=await this.fetchWithoutAuth(i,r);return this.highestSuccessRateRemapper.remapHighestSuccessRate(a.data)};getEntitiesFollows=async(t,e)=>{let i=w(e)?`/statistics/follows${this.apiSignInUrl}${h()}`:`/statistics/follows${this.apiSignInUrl}`,r="There was a problem fetching follows for entities";return t.footballCompetitions&&(i+=`&competitions=${t.footballCompetitions.join(",")}`),t.footballTeams&&(i+=`&teams=${t.footballTeams.join(",")}`),t.footballPlayers&&(i+=`&players=${t.footballPlayers.join(",")}`),(await this.fetchWithoutAuth(i,r)).data};getUserRankingsForPrivateLeagueAndChallenges=async(t,e,i)=>{let r=`/private-league/users/${t}/rankings${this.apiSignInUrl}&private_league_type=${e==="PRIVATE_LEAGUE"?"private":"one_vs_one"}`,a=`There was a problem fetching user rankings for ${e}`;i&&(r+=`${i.constructFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a);return e==="PRIVATE_LEAGUE"?this.rankingsRemapper.remapRankingsPrivateLeague(s):this.rankingsRemapper.remapRankingsChallenge(s)}};var Oe=class{predictorHttps=null;predictorService=null;idMapping=null;clientHttps=null;predictorValidator=null;errorHandlingMode=null;constructor(t){this.predictorValidator=new Ft(t.errorHandlingMode),this.idMapping=new P(t),this.predictorHttps=new at(t,this.idMapping),this.predictorService=new ht(t,this.idMapping),this.clientHttps=new N(t),this.errorHandlingMode=t.errorHandlingMode}getConfig=async()=>{let t=await this.clientHttps.getConfig("matchQuiz");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(t):t};play=async t=>{t=this.predictorValidator.validateBodyFields("MATCH_QUIZ",t);let e=t.fixtures.map(i=>this.predictorValidator.validateFixture(i.matchId,i.market,i.prediction.value,i.prediction.playerId));if(e&&e.length&&this.idMapping.idSchema!=="native"){let i=[],r=[];e.forEach(l=>{i.push(l.matchId),l instanceof Z&&l.prediction.playerId&&l.prediction.playerId!=="OWN_GOAL"&&r.push(l.prediction.playerId)});let a=await this.predictorService.remapMatchIdToNative(i),s={};r&&r.length>0&&(s=await this.predictorService.remapPlayerIdMapToNative(r)),e.forEach((l,n)=>{l.matchId=a[n],l instanceof Z&&l.prediction.playerId!=="OWN_GOAL"&&(l.prediction.playerId=s[l.prediction.playerId])})}return t.fixtures=e,await this.predictorHttps.makeFootballPrediction(t)};delete=async t=>await this.predictorHttps.deleteFootballPrediction(t);getGames=async(t,e)=>{e=e||!1;let i=this.predictorService.initGameFilters("MATCH_QUIZ",t),r=await this.predictorHttps.getGames(i,e);return await this.predictorService.remapMatchIdsFixtures(r)};getGameById=async(t,e)=>{e=e||!1;let i=await this.predictorHttps.getGameById(t,e);return await this.predictorService.remapMatchIdsFixtures(i)};getGamePredictions=async(t,e,i)=>(i=i||!1,e&&(e.type&&delete e.type,e.status&&delete e.status,e=new L(e)),await this.predictorHttps.getGamePredictions(t,i,e));getGameResults=async(t,e,i)=>{i=i||!1,e&&(e=new v(e));let r=await this.predictorHttps.getGameResults(t,i,e);return await this.predictorService.remapMatchIdsFixtures(r)};getCurrentGameResults=async t=>{t=t||!1;let e=new et(null);e.status="OPEN",e.type="MATCH_QUIZ";let i=await this.predictorHttps.getGames(e,t),r=this.predictorService.getCurrentGameId(i);return(await this.getGameResults(r,null,t)).data[0]};getMyGameEditions=async(t,e)=>{t&&t.limit&&this.validateLimitFilterOnGames(t.limit),e=e||!1;let i=this.predictorService.initGameTypePredictions("MATCH_QUIZ",t),r=[],a=await this.predictorHttps.getMyPredictionsNoRemap(i);if(a.data.length>0){a.data.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let s=this.predictorService.initGameFilters("MATCH_QUIZ",null,r),l=await this.predictorHttps.getUserGameEditions(s,e);return await this.predictorService.addPredictionProp(a,l)}else return new R};getMyGamePrediction=async t=>{let e=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),i=await this.predictorHttps.getMyPredictions(e);if(i.data.length>0){let r=i.data.filter(a=>a.gameInstanceId===t);return r.length?r[0]:null}return null};getUserGameEditions=async(t,e,i)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),i=i||!1;let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ",e),a=[],s=await this.predictorHttps.getUserPredictionsNoRemap(t,r);if(s.data.length>0){s.data.forEach(p=>{p.game_instance_id&&a.push(p.game_instance_id)});let l=this.predictorService.initGameFilters("MATCH_QUIZ",null,a),n=await this.predictorHttps.getUserGameEditions(l,i);return await this.predictorService.addPredictionProp(s,n)}else return new R};getUserGamePrediction=async(t,e,i)=>{i=i||!1;let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),a=await this.predictorHttps.getUserPredictions(t,i,r);if(a.data.length>0){let s=a.data.filter(l=>l.gameInstanceId===e);return s.length?s[0]:null}else return null};getMarketsResultsForGame=async(t,e)=>{let i=await this.predictorHttps.getMarketResultsForGame(t,e);return await this.predictorService.completeGameMarketResults(i,"MATCH_QUIZ")};getGameWinners=async(t,e)=>{let i=await this.predictorHttps.getContestWinners(t,e),r=await this.getGameById(t);return i.contestModel=r,this.predictorService.completeContestWinners(i)};validateLimitFilterOnGames=t=>{if(this.errorHandlingMode==="default"&&t>50)throw new f(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.");if(this.errorHandlingMode==="standard"&&t>50)throw new m(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.")}};var Le=class{matchQuizFacade=null;constructor(t){this.matchQuizFacade=new Oe(t)}getConfig=async()=>await this.matchQuizFacade.getConfig();play=async t=>await this.matchQuizFacade.play(t);delete=async t=>await this.matchQuizFacade.delete(t);getGames=async(t,e)=>await this.matchQuizFacade.getGames(t,e);getGameById=async(t,e)=>await this.matchQuizFacade.getGameById(t,e);getGamePredictions=async(t,e,i)=>await this.matchQuizFacade.getGamePredictions(t,e,i);getGameResults=async(t,e,i)=>await this.matchQuizFacade.getGameResults(t,e,i);getCurrentGameResults=async t=>await this.matchQuizFacade.getCurrentGameResults(t);getMyGameEditions=async(t,e)=>await this.matchQuizFacade.getMyGameEditions(t,e);getMyGamePrediction=async t=>await this.matchQuizFacade.getMyGamePrediction(t);getUserGameEditions=async(t,e,i)=>await this.matchQuizFacade.getUserGameEditions(t,e,i);getUserGamePrediction=async(t,e,i)=>await this.matchQuizFacade.getUserGamePrediction(t,e,i);getMarketsResultsForGame=async(t,e)=>await this.matchQuizFacade.getMarketsResultsForGame(t,e);getGameWinners=async(t,e)=>await this.matchQuizFacade.getGameWinners(t,e)};var xe=class{id=null;title=null;description=null;type=null;images=new it;participationCount=null;questionsCount=null;status=null;flags=null;customFields=null;labels=null;branding=null;time=null;points=null;scored=!1;maxAttempts=null;averageScore=null;perfectScore=null;adContent=null;context=null;createdAt=null;updatedAt=null};var Ao=class extends xe{rules=null;questions=[]};var Oo=class{questionId=null;question=null;images=null;embedCode=null;explanation=null;options=[]};var Lo=class{optionId=null;option=null;images=null;correct=null};var xo=class{classicQuizId=null;userId=null;questions=[];correctOptions=null;personalBest=null;points=null;attempts=null};var Do=class{questionId=null;optionId=null;correct=null;correctOptionId=null};var Bo=class{classicQuizId=null;classicQuizModel=null;correct=null;classicQuizQuestions=null;personalBest=null;points=null;answers=[]};var De=class{content=null;tags=[];campaign=null};var Be=class{id=null;model=null;source=null;type=null};var Ne=class{classicQuizIds=null};var No=class{pagination=new V;filters=new Ne};var ko=class{position=null;profileId=null;profileModel=null;points=null};var Uo=class{position=null;classicQuizId=null;classicQuizModel=null;points=null};var Go=class extends rt{remapClassicQuizzes=t=>(t.meta.pagination=this.remapMetaPagination(t.meta.pagination),t.data=t.data.map(e=>this.remapBasicClassicQuiz(e)),t);remapClassicQuizById=t=>{let e=new Ao;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.images=t.images,e.participationCount=t.participation_count,e.questionsCount=t.questions_count,e.status=t.status,e.flags=t.flags,e.adContent=t.ad_content,e.rules=t.rules,e.customFields=t.custom_fields,e.branding=t.branding?this.remapBranding(t.branding):null,e.labels=t.labels,e.time=t.time,e.points=t.points,e.scored=t.scored,e.maxAttempts=t.max_attempts,e.context=t.context?this.remapContext(t.context):t.context,e.averageScore=t.average_score,e.perfectScore=t.perfect_score,e.questions=t.questions.map(i=>this.remapQuestions(i)),e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapClassicQuizParticipation=t=>{let e=new xo;return e.classicQuizId=t.classic_quiz_id,e.userId=t.user_id,e.questions=t.questions?t.questions.map(i=>this.remapParticipationQuestions(i)):null,e.correctOptions=t.correct_options,e.personalBest=t.personal_best,e.points=t.points,e.attempts=t.attempts,e};remapClassicQuizParticipationBody=t=>t.map(e=>({question_id:e.questionId,option_id:e.optionId}));remapUserClassicQuizParticipations=t=>t.map(e=>{let i=new Bo;return i.classicQuizId=e.classic_quiz_id,i.correct=e.correct,i.classicQuizQuestions=e.classic_quiz_questions,i.personalBest=e.personal_best,i.points=e.points,i.answers=e.answers?e.answers.map(r=>this.remapParticipationQuestions(r)):e.answers,i});remapClassicQuizzesLeaderboard=t=>(t.meta=this.remapClassicQuizLeaderboardMeta(t.meta),t.data=t.data.map(e=>this.remapClassicQuizLeaderboard(e)),t);remapClassicQuizUserRankings=t=>(t.meta.pagination=this.remapMetaPaginationRank(t.meta.pagination),t.data=t.data.map(e=>this.remapClassicQuizUserRanking(e)),t);remapMetaPagination=t=>{let e=new nt;return e.itemsPerPage=t.items_per_page,e.nextPageStartsAfter=t.next_page_starts_after,e};remapClassicQuizLeaderboardMeta=t=>{let e=new No;return e.pagination=this.remapMetaPaginationRank(t.pagination),e.filters=this.remapLeaderboardMetaFilters(t.filters),e};remapMetaPaginationRank=t=>{let e=new V;return e.currentPage=t.current_page,e.itemsPerPage=t.items_per_page,e.numberOfPages=t.number_of_pages,e.totalItems=t.total_items,e};remapLeaderboardMetaFilters=t=>{let e=new Ne;return e.classicQuizIds=t?.classic_quiz_ids||null,e};remapClassicQuizUserRanking=t=>{let e=new Uo;return e.position=t.position,e.classicQuizId=t.classic_quiz_id,e.points=t.points,e};remapBasicClassicQuiz=t=>{let e=new xe;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.images=t.images,e.participationCount=t.participation_count,e.questionsCount=t.questions_count,e.status=t.status,e.flags=t.flags,e.customFields=t.custom_fields,e.branding=t.branding?this.remapBranding(t.branding):null,e.labels=t.labels,e.time=t.time,e.averageScore=t.average_score,e.perfectScore=t.perfect_score,e.points=t.points,e.scored=t.scored,e.maxAttempts=t.max_attempts,e.context=t.context?this.remapContext(t.context):t.context,e.adContent=t.ad_content,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapQuestions=t=>{let e=new Oo;return e.questionId=t.question_id,e.question=t.question,e.images=t.images,e.embedCode=t.embed_code,e.explanation=t.explanation,e.options=t.options.map(i=>this.remapOptions(i)),e};remapOptions=t=>{let e=new Lo;return e.optionId=t.option_id,e.option=t.option,e.images=t.images,e.correct=t.correct,e};remapParticipationQuestions=t=>{let e=new Do;return e.questionId=t.question_id,e.optionId=t.option_id,e.correct=t.correct,e.correctOptionId=t.correct_option_id,e};remapClassicQuizLeaderboard=t=>{let e=new ko;return e.position=t.position,e.profileId=t.profile_id,e.points=t.points,e};remapContext=t=>{let e=new De;return e.content=t.content,e.tags=t.tags?t.tags.map(i=>{let r=new Be;return r.id=i.id,r.type=i.type,r.source=i.source,r}):null,e.campaign=t.campaign,e}};var ke=class{id="";title="";description="";images=new it;flags=[];status="";winningCondition="";lives=0;time=0;points=[];customFields=null;branding=null;labels=null;adContent="";context=null;type="";createdAt="";updatedAt=""};var Vo=class extends ke{rules=""};var Ho=class{correctSteps=0;score=0};var $o=class{eitherOrId="";personalBest=0};var Wo=class{instanceId="";eitherOrId="";gameStartedAt="";currentStep=0;currentStreak=0;remainingSteps=0;currentLives=0;currentPoints=0;personalBest=0;steps=[]};var zo=class{main;mobile};var _i=class{id="";label="";images=new zo;value=null};var qo=class{pairId="";userSelection="";correct=null;played=null;timestamp="";optionOne=new _i;optionTwo=new _i};var Qo=class{rangeStartInclusive=0;rangeEndInclusive=0;totalUsers=0};var Ko=class{standings=[];breakdown=[]};var jo=class{userId="";userModel=null;personalBest=""};var Xo=class extends rt{remapEitherOrs=t=>(t.meta.pagination=this.remapMetaPagination(t.meta.pagination),t.data=t.data.map(e=>this.remapBasicEitherOr(e)),t);remapEitherOrById=t=>{let e=new Vo;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.images=t.images,e.status=t.status,e.winningCondition=t.winning_condition,e.lives=t.lives,e.flags=t.flags,e.customFields=t.custom_fields,e.branding=t.branding?this.remapBranding(t.branding):null,e.labels=t.labels,e.time=t.time,e.context=t.context?this.remapContext(t.context):t.context,e.points=t.points?t.points.map(i=>this.remapPoints(i)):t.points,e.rules=t.rules,e.adContent=t.ad_content,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapEitherOrOwnStats=t=>{let e=new $o;return e.eitherOrId=t.either_or_id,e.personalBest=t.personal_best,e};remapEitherOrResults=t=>{let e=new Ko;return e.standings=t.standings?t.standings.map(i=>this.remapResultsStandings(i)):t.standings,e.breakdown=t.breakdown?t.breakdown.map(i=>this.remapResultsBreakdown(i)):t.breakdown,e};remapEitherOrParticipation=t=>{let e=new Wo;return e.instanceId=t.instance_id,e.eitherOrId=t.either_or_id,e.gameStartedAt=t.game_started_at,e.currentStep=t.current_step,e.currentStreak=t.current_streak,e.remainingSteps=t.remaining_steps,e.currentLives=t.current_lives,e.currentPoints=t.current_points,e.personalBest=t.personal_best,e.steps=t.steps?t.steps.map(i=>this.remapParticipationSteps(i)):t.steps,e};remapBasicEitherOr=t=>{let e=new ke;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.images=t.images,e.status=t.status,e.winningCondition=t.winning_condition,e.lives=t.lives,e.flags=t.flags,e.customFields=t.custom_fields,e.branding=t.branding?this.remapBranding(t.branding):null,e.labels=t.labels,e.adContent=t.ad_content,e.context=t.context?this.remapContext(t.context):t.context,e.time=t.time,e.points=t.points?t.points.map(i=>this.remapPoints(i)):t.points,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapMetaPagination=t=>{let e=new nt;return e.itemsPerPage=t.items_per_page,e.nextPageStartsAfter=t.next_page_starts_after,e};remapPoints=t=>{let e=new Ho;return e.correctSteps=t.correct_steps,e.score=t.score,e};remapResultsStandings=t=>{let e=new jo;return e.userId=t.user_id,e.personalBest=t.personal_best,e};remapResultsBreakdown=t=>{let e=new Qo;return e.rangeStartInclusive=t.range_start_inclusive,e.rangeEndInclusive=t.range_end_inclusive,e.totalUsers=t.total_users,e};remapParticipationSteps=t=>{let e=new qo;return e.pairId=t.pair_id,e.userSelection=t.user_selection,e.correct=t.correct,e.played=t.played,e.timestamp=t.timestamp,e.optionOne=t.option_one,e.optionTwo=t.option_two,e};remapContext=t=>{let e=new De;return e.content=t.content,e.tags=t.tags?t.tags.map(i=>{let r=new Be;return r.id=i.id,r.type=i.type,r.source=i.source,r}):null,e.campaign=t.campaign,e}};var Ue=class extends T{classicQuizRemapper=null;eitherOrRemapper=null;constructor(t){super(t,S(t.environment,"miniGames")),this.classicQuizRemapper=new Go,this.eitherOrRemapper=new Xo}getClassicQuizzes=async(t,e)=>{let i=`/classic-quizzes${this.apiSignInUrl}`;t&&(i+=t.constructMainFiltersUrl()),i+=w(e)?h():"";let r="There was a problem with fetching classic quizzes",a=await this.fetchWithoutAuth(i,r);return this.classicQuizRemapper.remapClassicQuizzes(a)};getClassicQuizById=async(t,e,i)=>{let r=`/classic-quizzes/${t}${this.apiSignInUrl}`;e&&(r+=`&include_correct_options=${e}`),w(i)&&(r+=h());let a="There was a problem with fetching classic quiz by ID",s=await this.fetchWithoutAuth(r,a);return this.classicQuizRemapper.remapClassicQuizById(s.data)};participateInClassicQuiz=async(t,e,i)=>{let r=`/classic-quizzes/${t}/participate${this.apiSignInUrl}`,a=`There was a problem with participating in the following classic quiz: ${t}`,s="POST",l={questions:this.classicQuizRemapper.remapClassicQuizParticipationBody(e),include_correct_options:!!i},n=await this.fetchWithAuth(r,a,s,l);return this.classicQuizRemapper.remapClassicQuizParticipation(n.data)};getMyClassicQuizParticipations=async t=>{let e=`/classic-quizzes/participations${this.apiSignInUrl}`;t&&(e+=`${t.constructMainFiltersUrl()}`);let i="There was a problem with fetching user's own Classic Quiz participations",r=await this.fetchWithAuth(e,i);return this.classicQuizRemapper.remapUserClassicQuizParticipations(r.data)};getLeaderboardForClassicQuizzes=async t=>{let e=`/classic-quizzes/rank${this.apiSignInUrl}`;t&&(e+=`${t.constructMainFiltersUrl()}`);let i="There was a problem with fetching classic quizzes leaderboard",r=await this.fetchWithoutAuth(e,i);return this.classicQuizRemapper.remapClassicQuizzesLeaderboard(r)};getClassicQuizzesUserRanking=async(t,e)=>{let i=`/classic-quizzes/users/${t}/rank${this.apiSignInUrl}`;e&&(i+=`${e.constructMainFiltersUrl()}`);let r="There was a problem with fetching user's rankings for classic quizzes",a=await this.fetchWithoutAuth(i,r);return this.classicQuizRemapper.remapClassicQuizUserRankings(a)};getEitherOrs=async(t,e)=>{let i=`/either-or${this.apiSignInUrl}`;t&&(i+=t.constructMainFiltersUrl()),i+=w(e)?h():"";let r="There was a problem with fetching list of Either/Ors",a=await this.fetchWithoutAuth(i,r);return this.eitherOrRemapper.remapEitherOrs(a)};getEitherOrById=async(t,e)=>{let i=`/either-or/${t}${this.apiSignInUrl}`;w(e)&&(i+=h());let r="There was a problem with fetching Either/Or by ID",a=await this.fetchWithoutAuth(i,r);return this.eitherOrRemapper.remapEitherOrById(a.data)};getMyEitherOrStats=async t=>{let e=`/either-or/${t}/own-stats${this.apiSignInUrl}`,i="There was a problem with fetching Either/Or own statistics",r=await this.fetchWithAuth(e,i);return this.eitherOrRemapper.remapEitherOrOwnStats(r.data)};getEitherOrResults=async(t,e)=>{let i=`/either-or/${t}/results${this.apiSignInUrl}${w(e)?h():""}`,r="There was a problem with fetching Either/Or results",a=await this.fetchWithoutAuth(i,r);return this.eitherOrRemapper.remapEitherOrResults(a.data)};participateInEitherOr=async(t,e)=>{let i=`/either-or/${t}/participate${this.apiSignInUrl}`,r="There was a problem with participating in Either/Or",a="POST",s=await this.fetchWithAuth(i,r,a,e);return this.eitherOrRemapper.remapEitherOrParticipation(s.data)}};var gt=class{idSchema;idMapping;constructor(t){this.idSchema=t.idSchema,this.idMapping=new P(t)}remapTagsIds=async(t,e,i)=>{if(!t||!t.length)return t;let r={},a={},s=[];t.forEach(n=>{r.hasOwnProperty(n.type)||(r[n.type]=[],a[n.type]=[]),r[n.type].push(n.id),a[n.type].push(n)});let l=await this.idMapping.idMappingFacade.getEntitiesByIds(r,e,i);for(let[n,p]of Object.entries(a))p.forEach((c,u)=>{c.id=l[n][u],s.push(c)});return s}};var Ge=class extends v{flags=null;status=null;entityIds=null;entityType=null;sort=null;groupByStatus=null;constructor(t){super(t),this.flags=t&&t.flags?t.flags:null,this.status=t&&t.status?t.status:null,this.entityIds=t&&t.entityIds?t.entityIds:null,this.entityType=t&&t.entityType?t.entityType:null,this.sort=t&&t.sort?t.sort:null,this.groupByStatus=t&&t.groupByStatus!==void 0?t.groupByStatus:null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.flags&&this.flags.length>0&&(t+=`&flags=${this.flags.join(",")}`),this.status&&(t+=`&status=${this.status}`),this.entityIds&&this.entityIds.length>0&&(t+=`&entity_ids=${this.entityIds}`),this.sort&&(t+=`&sort=${this.sort}`),this.groupByStatus!==null&&(t+=`&group_by_status=${this.groupByStatus}`),t}};var Yo=class extends Ge{classicQuizIds=null;constructor(t){super(t),this.classicQuizIds=t&&t.classicQuizIds?t.classicQuizIds:null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.classicQuizIds&&this.classicQuizIds.length>0&&(t+=`&classic_quiz_ids=${this.classicQuizIds.join(",")}`),t}};var Ve=class{limit=null;page=null;constructor(t){this.limit=t?.limit||null,this.page=t?.page||null}constructMainFiltersUrl(){let t="";return this.limit&&(t+=`&limit=${this.limit}`),this.page&&(t+=`&page=${this.page}`),t}};var Jo=class extends Ve{classicQuizIds=null;constructor(t){super(t),this.classicQuizIds=t?.classicQuizIds||null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.classicQuizIds&&this.classicQuizIds.length>0&&(t+=`&classic_quiz_ids=${this.classicQuizIds.join(",")}`),t}};var Zo=class extends v{classicQuizIds=null;constructor(t){super(t),this.classicQuizIds=t?.classicQuizIds||null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.classicQuizIds&&this.classicQuizIds.length>0&&(t+=`&classic_quiz_ids=${this.classicQuizIds.join(",")}`),t}};var ts=class extends Ge{eitherOrIds=null;constructor(t){super(t),this.eitherOrIds=t&&t.eitherOrIds?t.eitherOrIds:null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.eitherOrIds&&this.eitherOrIds.length>0&&(t+=`&either_or_ids=${this.eitherOrIds.join(",")}`),t}};var es=class{pair="";answer=""};var is=class extends es{expired=!1;time=0};var St=class{errorHandlingModel=null;entityTypes=["competition","team","player"];constructor(t){this.errorHandlingModel=t.errorHandlingMode}validateFilters=t=>{!t.entityIds&&!t.entityType||(t.entityIds&&!t.entityType&&this.throwException(400,"invalid_filters","You need to use both 'entityIds' and 'entityType' filters together"),!t.entityIds&&t.entityType&&this.throwException(400,"invalid_filters","You need to use both 'entityIds' and 'entityType' filters together"),this.entityTypes.includes(t.entityType)||this.throwException(400,"invalid_filters","Invalid 'entityType' filter. Please use one of the following valid options: competition, team, or player"))};throwException=(t,e,i)=>{throw this.errorHandlingModel==="standard"?new m(t,e,i):new f(t,e,i)}};var rs=class{idSchema=null;idMapping=null;validator=null;https=null;entityTypes=["competition","team","player"];profile=null;football=null;eitherOrTime=0;participationStartTimestamp=0;countdownTimer=0;intervalId=null;currentPairId="";constructor(t){this.idSchema=t.idSchema,this.idMapping=new P(t),this.validator=new St(t),this.profile=new O(t),this.football=new J(t),this.https=new Ue(t)}finalizeMiniGamesFilters=async t=>{if(this.idSchema!=="native"&&t.entityIds&&t.entityIds.length>0){this.validator.validateFilters(t);let e=await this.idMapping.getEntityIdsBySchemaId(Array.from(t.entityIds),t.entityType,"native");t.entityIds=e[t.entityType]}};setProfileModelsForEitherOrStandings=async t=>{let e=t.standings.map(r=>r.userId);if(!e.length)return t;let i=await this.profile.getByIds(e);return t.standings.forEach(r=>r.userModel=i.find(a=>a.id===r.userId)||null),t};setProfileModelsForClassicQuizLeaderboards=async t=>{let e=t.map(r=>r.profileId);if(!e.length)return t;let i=await this.profile.getByIds(e);return t.forEach(r=>r.profileModel=i.find(a=>a.id===r.profileId)||null),t};defaultEitherOrParticipation=async(t,e)=>{if(!this.eitherOrTime&&!e){let a=await this.https.getEitherOrById(t,!0);this.eitherOrTime=a.time;let s=await this.https.participateInEitherOr(t,null);return this.participationStartTimestamp=Date.now(),s}let i=0;if(this.participationStartTimestamp)i=(Date.now()-this.participationStartTimestamp)/1e3;else{if(!this.eitherOrTime){let a=await this.https.getEitherOrById(t,!0);this.eitherOrTime=a.time}i=this.eitherOrTime+1}let r=this.createNewParticipation(i,e);try{let a=await this.https.participateInEitherOr(t,r);return!a.currentLives||!a.remainingSteps?this.resetDefaultParticipationTimers():this.participationStartTimestamp=Date.now(),a}catch(a){throw this.resetDefaultParticipationTimers(),a}};handleEitherOrParticipationWithCallback=async(t,e,i)=>e?await this.eitherOrParticipationWithCallback(t,e,i):await this.initialEitherOrParticipationWithCallback(t,i);initialEitherOrParticipationWithCallback=async(t,e)=>{let i=await this.https.getEitherOrById(t,!0);this.eitherOrTime=i.time;let r=await this.https.participateInEitherOr(t,null);return this.participationStartTimestamp=Date.now(),this.countdownTimer=this.eitherOrTime,this.setCurrentPairId(r),await this.handleEitherOrParticipationCallbackInterface(t,e),r};eitherOrParticipationWithCallback=async(t,e,i)=>{this.intervalId&&clearInterval(this.intervalId);let r=0;if(this.participationStartTimestamp)r=(Date.now()-this.participationStartTimestamp)/1e3;else{if(!this.eitherOrTime){let s=await this.https.getEitherOrById(t,!0);this.eitherOrTime=s.time}r=this.eitherOrTime+1}let a=this.createNewParticipation(r,e);try{let s=await this.https.participateInEitherOr(t,a);return!s.currentLives||!s.remainingSteps?(this.resetCallbackParticipationTimers(),i.onElapsedResponse(s),clearInterval(this.intervalId)):(this.participationStartTimestamp=Date.now(),this.countdownTimer=this.eitherOrTime,this.setCurrentPairId(s),await this.handleEitherOrParticipationCallbackInterface(t,i)),s}catch(s){throw this.resetCallbackParticipationTimers(),clearInterval(this.intervalId),s}};setCurrentPairId=t=>{this.currentPairId=t.steps.find(e=>!e.played).pairId||""};handleEitherOrParticipationCallbackInterface=async(t,e)=>{this.intervalId=setInterval(async()=>{if(this.countdownTimer>0)this.countdownTimer--,e.onTimerTick(this.countdownTimer);else{clearInterval(this.intervalId);let i=(Date.now()-this.participationStartTimestamp)/1e3,r={pair:this.currentPairId,answer:this.currentPairId.split("_")[0]},a=this.createNewParticipation(i,r),s=await this.eitherOrParticipationWithCallback(t,a,e);e.onElapsedResponse(s)}},1e3)};createNewParticipation=(t,e)=>{let i=new is;return i.expired=t>this.eitherOrTime,i.time=Number(t.toFixed(3)),i.pair=e.pair,i.answer=e.answer,i};resetCallbackParticipationTimers=()=>{this.resetDefaultParticipationTimers(),this.countdownTimer=0,this.currentPairId=""};resetDefaultParticipationTimers=()=>{this.eitherOrTime=0,this.participationStartTimestamp=0};setContextTagsModels=async t=>{let e={competitions:[],teams:[],players:[]};if(t.forEach(i=>{i.context&&i.context.tags&&i.context.tags.length>0&&(e.competitions=[...e.competitions,...this.extractEntityIdsFromTags(i.context.tags,"competition")],e.competitions=Array.from(new Set(e.competitions)),e.teams=[...e.teams,...this.extractEntityIdsFromTags(i.context.tags,"team")],e.teams=Array.from(new Set(e.teams)),e.players=[...e.players,...this.extractEntityIdsFromTags(i.context.tags,"player")],e.players=Array.from(new Set(e.players)))}),e.competitions.length){let i=await this.football.footballFacade.getCompetitionsMapWithNativeIds(e.competitions);this.setModelsForContextTags(t,i,"competition")}if(e.teams.length){let i=await this.football.footballFacade.getTeamsMapWithNativeIds(e.teams);this.setModelsForContextTags(t,i,"team")}if(e.players.length){let i=await this.football.footballFacade.getPlayersMapWithNativeIds(e.players);this.setModelsForContextTags(t,i,"player")}};extractEntityIdsFromTags=(t,e)=>t.filter(i=>i.type===e).map(i=>i.id);setModelsForContextTags=(t,e,i)=>{t.forEach(r=>{r.context&&r.context.tags&&r.context.tags.length>0&&r.context.tags.forEach(a=>{a.type===i&&(a.model=i==="player"?e[a.id]:e.get(a.id),a.id=a.model.id)})})}};var as=class{https=null;service=null;activityService=null;idSchema=null;constructor(t){this.https=new Ue(t),this.service=new rs(t),this.activityService=new gt(t),this.idSchema=t.idSchema}getClassicQuizzes=async(t,e,i)=>{t&&(t=new Yo(t),await this.service.finalizeMiniGamesFilters(t));let r=await this.https.getClassicQuizzes(t,i);if(e)await this.service.setContextTagsModels(r.data);else for(let a of r.data)await this.remapTags(a,"native",this.idSchema);return r};getClassicQuizById=async(t,e,i)=>{let r=await this.https.getClassicQuizById(t,e,i);return await this.service.setContextTagsModels([r]),r};participateInClassicQuiz=async(t,e,i)=>await this.https.participateInClassicQuiz(t,e,i);getMyClassicQuizParticipations=async t=>{t&&(t=new Zo(t));let e=await this.https.getMyClassicQuizParticipations(t),i=e.map(a=>a.classicQuizId),r=await this.getClassicQuizzes({classicQuizIds:i});return e.map(a=>{let s=r.data.find(l=>l.id===a.classicQuizId)||null;return{...a,classicQuizModel:s}})};getLeaderboardForClassicQuizzes=async t=>{t&&(t=new Jo(t));let e=await this.https.getLeaderboardForClassicQuizzes(t);return e.data=await this.service.setProfileModelsForClassicQuizLeaderboards(e.data),e};getClassicQuizzesUserRanking=async(t,e)=>{e&&(e=new Ve(e));let i=await this.https.getClassicQuizzesUserRanking(t,e),r=i.data.map(s=>s.classicQuizId),a=await this.getClassicQuizzes({classicQuizIds:r});return i.data=i.data.map(s=>{let l=a.data.find(n=>n.id===s.classicQuizId)||null;return{...s,classicQuizModel:l}}),i};getEitherOrs=async(t,e,i)=>{t&&(t=new ts(t),await this.service.finalizeMiniGamesFilters(t));let r=await this.https.getEitherOrs(t,i);if(e)await this.service.setContextTagsModels(r.data);else for(let a of r.data)await this.remapTags(a,"native",this.idSchema);return r};getEitherOrById=async(t,e)=>{let i=await this.https.getEitherOrById(t,e);return await this.service.setContextTagsModels([i]),i};getMyEitherOrStats=async t=>await this.https.getMyEitherOrStats(t);getEitherOrResults=async(t,e)=>{let i=await this.https.getEitherOrResults(t,e);return await this.service.setProfileModelsForEitherOrStandings(i)};participateInEitherOr=async(t,e,i)=>i?await this.service.handleEitherOrParticipationWithCallback(t,e,i):await this.service.defaultEitherOrParticipation(t,e);calculateEitherOrResultPercentile=async(t,e)=>{if(e==null||isNaN(e)||e<0)return null;if(e===0)return e;let i=await this.getEitherOrResults(t,!0),r=i.breakdown.reduce((s,l)=>s+l.totalUsers,0),a=0;for(let s of i.breakdown)if(a+=s.totalUsers,e>=s.rangeStartInclusive&&e<=s.rangeEndInclusive)return parseFloat((a/r*100).toFixed(1));return null};remapTags=async(t,e,i)=>{if(this.idSchema!="native"&&t.context&&t.context.tags&&t.context.tags.length){let r=JSON.parse(JSON.stringify(t.context.tags)),a=await this.activityService.remapTagsIds(r,e,i);t.context.tags=a}}};var He=class{facade=null;constructor(t){this.facade=new as(t)}getClassicQuizzes=async(t,e,i)=>await this.facade.getClassicQuizzes(t,e,i);getClassicQuizById=async(t,e,i)=>await this.facade.getClassicQuizById(t,e,i);participateInClassicQuiz=async(t,e,i)=>await this.facade.participateInClassicQuiz(t,e,i);getMyClassicQuizParticipations=async t=>await this.facade.getMyClassicQuizParticipations(t);getLeaderboardForClassicQuizzes=async t=>await this.facade.getLeaderboardForClassicQuizzes(t);getClassicQuizzesUserRanking=async(t,e)=>await this.facade.getClassicQuizzesUserRanking(t,e);getEitherOrs=async(t,e,i)=>await this.facade.getEitherOrs(t,e,i);getEitherOrById=async(t,e)=>await this.facade.getEitherOrById(t,e);getMyEitherOrStats=async t=>await this.facade.getMyEitherOrStats(t);getEitherOrResults=async(t,e)=>await this.facade.getEitherOrResults(t,e);participateInEitherOr=async(t,e,i)=>await this.facade.participateInEitherOr(t,e,i);calculateEitherOrResultPercentile=async(t,e)=>await this.facade.calculateEitherOrResultPercentile(t,e)};var $e=class{idMapping=null;predictorHttps=null;predictorService=null;predictorValidator=null;clientHttps=null;errorHandlingMode=null;constructor(t,e){this.idMapping=e,this.errorHandlingMode=t.errorHandlingMode,this.predictorValidator=new Ft(t.errorHandlingMode),this.predictorHttps=new at(t,e),this.predictorService=new ht(t,e),this.clientHttps=new N(t)}getConfig=async()=>{let t=await this.clientHttps.getConfig("topX");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(t):t};getGames=async(t,e)=>{e=e||!1;let i=this.predictorService.initGameFilters("TOP_X",t),r=await this.predictorHttps.getGames(i,e);return await this.predictorService.remapMatchIdsFixtures(r)};getGameById=async(t,e)=>{e=e||!1;let i=await this.predictorHttps.getGameById(t,e);return await this.predictorService.remapMatchIdsFixtures(i)};getGamePredictions=async(t,e,i)=>(i=i||!1,e&&(e.type&&delete e.type,e.status&&delete e.status,e=new L(e)),await this.predictorHttps.getGamePredictions(t,i,e));getGameResults=async(t,e,i)=>{i=i||!1,e&&(e=new et(e));let r=await this.predictorHttps.getGameResults(t,i,e);return await this.predictorService.remapMatchIdsFixtures(r)};getCurrentGameResults=async t=>{t=t||!1;let e=new et(null);e.status="OPEN",e.type="TOP_X";let i=await this.predictorHttps.getGames(e,t),r=this.predictorService.getCurrentGameId(i);return(await this.getGameResults(r,null,t)).data[0]};play=async t=>{let e=new Te(t);if(e=this.predictorValidator.validateBodyFields("TOP_X",e),e.fixtures=e.fixtures.map(r=>this.predictorValidator.validateFixture(r.matchId,r.market,r.prediction.value)),this.idMapping.idSchema!=="native"){let r=[];e.fixtures.forEach(s=>r.push(s.matchId));let a=await this.predictorService.remapMatchIdToNative(r);e.fixtures.forEach(s=>s.matchId=a.shift())}let i=await this.predictorHttps.makeFootballPrediction(e);return i.fixtures.forEach(r=>{r.matchId=r.matchModel.id}),i};delete=async t=>await this.predictorHttps.deleteFootballPrediction(t);getMyGameEditions=async(t,e)=>{t&&t.limit&&this.validateLimitFilterOnGames(t.limit),e=e||!1;let i=this.predictorService.initGameTypePredictions("TOP_X",t),r=[],a=await this.predictorHttps.getMyPredictionsNoRemap(i);if(a.data.length>0){a.data.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let s=this.predictorService.initGameFilters("TOP_X",null,r),l=await this.predictorHttps.getUserGameEditions(s,e);return await this.predictorService.addPredictionProp(a,l)}else return new R};getMyGamePrediction=async t=>{let e=this.predictorService.initGameTypePredictions("TOP_X"),i=await this.predictorHttps.getMyPredictions(e);if(i.data.length>0){let r=i.data.filter(a=>a.gameInstanceId===t);return r.length?r[0]:null}return null};getUserGameEditions=async(t,e,i)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),i=i||!1;let r=this.predictorService.initGameTypePredictions("TOP_X",e),a=[],s=await this.predictorHttps.getUserPredictionsNoRemap(t,r);if(s.data.length>0){s.data.forEach(p=>{p.game_instance_id&&a.push(p.game_instance_id)});let l=this.predictorService.initGameFilters("TOP_X",null,a),n=await this.predictorHttps.getUserGameEditions(l,i);return await this.predictorService.addPredictionProp(s,n)}else return new R};getUserGamePrediction=async(t,e,i)=>{i=i||!1;let r=this.predictorService.initGameTypePredictions("TOP_X"),a=await this.predictorHttps.getUserPredictions(t,i,r);if(a.data.length>0){let s=a.data.filter(l=>l.gameInstanceId===e);return s.length?s[0]:null}else return null};getMarketsResultsForGame=async(t,e)=>{let i=await this.predictorHttps.getMarketResultsForGame(t,e);return await this.predictorService.completeGameMarketResults(i,"TOP_X")};getGameWinners=async(t,e)=>{let i=await this.predictorHttps.getContestWinners(t,e),r=await this.getGameById(t);return i.contestModel=r,this.predictorService.completeContestWinners(i)};validateLimitFilterOnGames=t=>{if(this.errorHandlingMode==="default"&&t>50)throw new f(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.");if(this.errorHandlingMode==="standard"&&t>50)throw new m(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.")}};var We=class{topXFacade=null;idMapping=null;constructor(t){this.idMapping=new P(t),this.topXFacade=new $e(t,this.idMapping)}getConfig=async()=>await this.topXFacade.getConfig();getGames=async(t,e)=>await this.topXFacade.getGames(t,e);getGameById=async(t,e)=>await this.topXFacade.getGameById(t,e);getGamePredictions=async(t,e,i)=>await this.topXFacade.getGamePredictions(t,e,i);getGameResults=async(t,e,i)=>await this.topXFacade.getGameResults(t,e,i);getCurrentGameResults=async t=>await this.topXFacade.getCurrentGameResults(t);play=async t=>await this.topXFacade.play(t);delete=async t=>await this.topXFacade.delete(t);getMyGameEditions=async(t,e)=>await this.topXFacade.getMyGameEditions(t,e);getMyGamePrediction=async t=>await this.topXFacade.getMyGamePrediction(t);getUserGameEditions=async(t,e,i)=>await this.topXFacade.getUserGameEditions(t,e,i);getUserGamePrediction=async(t,e,i)=>await this.topXFacade.getUserGamePrediction(t,e,i);getMarketsResultsForGame=async(t,e)=>await this.topXFacade.getMarketsResultsForGame(t,e);getGameWinners=async(t,e)=>await this.topXFacade.getGameWinners(t,e)};var os=class{general;predictor;topX;matchQuiz};var ss=class{predictor;topX;matchQuiz;games;football;classicQuizzes;eitherOr;discussions;potm;poll};var Rt=class{limit=null;page=null;constructor(t){this.limit=t.limit?t.limit:null,this.page=t.page?t.page:null}constructFiltersUrl(){let t="";return this.limit&&(t+="&",t+=`limit=${this.limit}`),this.page&&(t+="&",t+=`page=${this.page}`),t}};var ns=class extends Rt{templateId=null;constructor(t){super(t),this.templateId=t?.templateId||null}constructFiltersUrl(){let t=super.constructFiltersUrl();return this.templateId&&(t+=`&template_id=${this.templateId}`),t}};var ls=class extends Rt{sortOrder=null;rankType=null;leaderboardIds=null;gameType=null;constructor(t){super(t),this.sortOrder=t.sortOrder,this.rankType=t.rankType,this.leaderboardIds=t.leaderboardIds,this.gameType=t.type&&t.type.toLowerCase()==="game"?t.gameType:null}constructFiltersUrl=()=>{let t=super.constructFiltersUrl();return this.sortOrder&&(t+="&",t+=`sort_order=${this.sortOrder}`),this.rankType&&(t+="&",t+=`rank_type=${this.rankType}`),this.leaderboardIds&&(t+="&",t+=`type_ids=${this.leaderboardIds.join(",")}`),this.gameType&&(t+="&",t+=`game_type=${this.gameType}`),t}};var ps=class{idMappingService=null;profileNamespace=null;footballNamespace=null;topXNamespace=null;matchQuizNamespace=null;miniGamesNamespace=null;errorHandlingMode=null;constructor(t){this.idMappingService=new P(t),this.profileNamespace=new O(t),this.footballNamespace=new J(t),this.topXNamespace=new We(t),this.matchQuizNamespace=new Le(t),this.miniGamesNamespace=new He(t),this.errorHandlingMode=t.errorHandlingMode}remapTemplatesIds=async t=>{if(t.length>0){let e=[],i=[],r=[],a=[],s=[],l=[];t.forEach(c=>{c.teamIds&&c.teamIds.length>0&&(e=[...e,...c.teamIds]),c.matchIds&&c.matchIds.length>0&&(r=[...r,...c.matchIds]),c.competitionIds&&c.competitionIds.length>0&&(s=[...s,...c.competitionIds])});let n={team:e,match:r,competition:s},p=await this.idMappingService.idMappingFacade.getEntitiesByIds(n,"native",this.idMappingService.idSchema);return i=[...p.team],a=[...p.match],l=[...p.competition],t.forEach(c=>{c.teamIds&&c.teamIds.length>0&&(c.teamIds=c.teamIds.map(u=>u=p.team.shift())),c.matchIds&&c.matchIds.length>0&&(c.matchIds=c.matchIds.map(u=>u=p.match.shift())),c.competitionIds&&c.competitionIds.length>0&&(c.competitionIds=c.competitionIds.map(u=>u=p.competition.shift()))}),t}return t};remapTemplateGroupMatchIds=async t=>{if(t&&t.length>0){for(let e of t)if(!(!e.filters.matchIds||!e.filters.matchIds.every(r=>r))&&e.filters.matchIds.length>0){let r={match:Array.from(e.filters.matchIds)},a=await this.idMappingService.idMappingFacade.getEntitiesByIds(r,"native",this.idMappingService.idSchema);e.filters.matchIds=Array.from(a.match)}}};addProfileModelToLeaderboard=async t=>{if(t.length>0){let e=[],i=t.map(a=>a.profileId);if(!i.length)return t;let r=await this.profileNamespace.getByIds(i);return t.forEach(a=>{r.forEach(s=>{s.id===a.profileId&&(delete s.interests,a.profileModel=s)}),a.profileModel||(a.profileModel=null),e.push(a)}),e}return t};buildOldClientBadges=t=>{let e=new os;return e.general=this.extractEnabledBadgesId(t.general),e.predictor=this.extractEnabledBadgesId(t.predictor),e.topX=this.extractEnabledBadgesId(t.topX),e.matchQuiz=this.extractEnabledBadgesId(t.matchQuiz),e};buildNewClientBadges=t=>{let e=new ss;return e.predictor=this.extractEnabledBadgesId(t.predictor),e.topX=this.extractEnabledBadgesId(t.topX),e.matchQuiz=this.extractEnabledBadgesId(t.matchQuiz),e.games=this.extractEnabledBadgesId(t.games),e.football=this.extractEnabledBadgesId(t.football),e.classicQuizzes=this.extractEnabledBadgesId(t.classicQuizzes),e.eitherOr=this.extractEnabledBadgesId(t.eitherOr),e.discussions=this.extractEnabledBadgesId(t.discussions),e.potm=this.extractEnabledBadgesId(t.voting.potm),e.poll=this.extractEnabledBadgesId(t.voting.poll),e};initFilters=(t,e)=>{switch(e){case"loyalty":t&&(t=new Rt(t));break;case"rankings":t&&(t=new ls(t));break;case"league_leaderboard":t&&(t=new ns(t))}return t};addProfileModelToHighestSuccessRate=async t=>{let e=t.map(r=>r.profileId);if(!e.length)return t;let i=await this.profileNamespace.getByIds(e);return t.map(r=>(i.forEach(a=>{a.id===r.profileId&&(delete a.interests,r.profileModel=a)}),r))};extractRankingsIdsMap=t=>{let e=[],i=[],r=[];return t.forEach(a=>{a.rankType==="GAME"&&a.gameType==="TOP_X"?e.push(a.id):a.rankType==="GAME"&&a.gameType==="MATCH_QUIZ"?i.push(a.id):a.rankType==="TEMPLATE"&&r.push(a.id)}),[e,i,r]};setModelsForUserRankings=(t,e,i,r)=>(r.data.forEach(a=>{a.gameType==="MATCH_QUIZ"&&e?a.model=e.filter(s=>s.id===a.id)[0]:a.gameType==="TOP_X"&&t?a.model=t.filter(s=>s.id===a.id)[0]:a.rankType==="TEMPLATE"&&i&&(a.model=i.filter(s=>s.id===a.id)[0])}),r);completeContestWinners=async t=>{if(t.userList&&t.userList.length){let e=t.userList.map(r=>r.profileId),i=await this.profileNamespace.getByIds(e);t.userList.forEach(r=>{let a=i.filter(s=>s.id===r.profileId)[0];delete a.interests,r.profileModel=a})}return t};validateEntitiesFollowsFilters=t=>{if(!t||(!t.footballCompetitions||!t.footballCompetitions.length)&&(!t.footballTeams||!t.footballTeams.length)&&(!t.footballPlayers||!t.footballPlayers.length))throw this.errorHandlingMode==="default"?new f(400,"invalid_filters","At least one of footballCompetitions, footballTeams or footballPlayers properties should be provided for filters."):new m(400,"invalid_filters","At least one of footballCompetitions, footballTeams or footballPlayers properties should be provided for filters.");if(t.footballCompetitions&&t.footballCompetitions.length>24||t.footballTeams&&t.footballTeams.length>24||t.footballPlayers&&t.footballPlayers.length>24)throw this.errorHandlingMode==="default"?new f(400,"EXCEEDED_LENGTH","Maximum length per entity should be 24 or less."):new m(400,"EXCEEDED_LENGTH","Maximum length per entity should be 24 or less.")};remapEntitiesFollowsFilters=async t=>{let e=JSON.parse(JSON.stringify(t)),i={},r={};e.footballCompetitions&&e.footballCompetitions.length&&(r.competition=e.footballCompetitions),e.footballTeams&&e.footballTeams.length&&(r.team=e.footballTeams),e.footballPlayers&&e.footballPlayers.length&&(r.player=e.footballPlayers);let a=await this.idMappingService.idMappingFacade.getEntitiesByIds(r,this.idMappingService.idSchema,"native");return Object.keys(a).forEach(s=>{s==="competition"?i.footballCompetitions=a[s]:s==="team"?i.footballTeams=a[s]:s==="player"&&(i.footballPlayers=a[s])}),i};addModelsToEntitiesFollows=async t=>{let e=[],i="fb:c:",r=new Map,a=[],s="fb:t:",l=new Map,n=[],p="fb:p:",c=null;return t.breakdown.forEach(u=>{u.id.includes(i)?e.push(u.id):u.id.includes(s)?a.push(u.id):u.id.includes(p)&&n.push(u.id)}),e.length&&(r=await this.footballNamespace.footballFacade.competitionsFacade.getCompetitionsMapWithNativeIds(e)),a.length&&(l=await this.footballNamespace.footballFacade.teamsFacade.getTeamsMapWithNativeIds(a)),n.length&&(c=await this.footballNamespace.footballFacade.playerFacade.getPlayersMapWithNativeIds(n)),t.breakdown.forEach(u=>{u.id.includes(i)?(u.model=r.get(u.id),u.id=u.model.id):u.id.includes(s)?(u.model=l.get(u.id),u.id=u.model.id):u.id.includes(p)&&(u.model=c[u.id],u.id=u.model.id)}),t};initMatchFiltersForTemplates=(t,e)=>{let i=[],r=[],a=[],s=this.reformatDate(t.fromDate),l=this.reformatDate(t.toDate,!0),n=500;if(t.competitionIds&&t.competitionIds.length>0&&(i=Array.from(t.competitionIds)),t.teamIds&&t.teamIds.length>0&&(r=Array.from(t.teamIds)),t.matchIds&&t.matchIds.length>0&&(a=Array.from(t.matchIds)),e){let c=t.groups.find(d=>d.groupId===e);if(!c)throw this.errorHandlingMode==="default"?new f(400,"invalid_template_group_id","There is no group in this template with the provided groupId"):new m(400,"invalid_template_group_id","There is no group in this template with the provided groupId");if(!c.filters)throw this.errorHandlingMode==="default"?new f(400,"invalid_template_group_filters","The provided template group has no filters"):new m(400,"invalid_template_group_filters","The provided template group has no filters");s=this.reformatDate(c.filters.fromDate),l=this.reformatDate(c.filters.toDate,!0),c.filters.matchIds.every(d=>d)&&(a=Array.from(c.filters.matchIds))}return new It({competitionIds:i,teamIds:r,matchIds:a,fromDate:s,toDate:l,limit:n})};reformatDate=(t,e)=>{let i=new Date(t);e&&i.setUTCHours(23,59,59);let r=i.toISOString();return r=r.slice(0,-5)+"Z",r};extractEnabledBadgesId=t=>{let e=[];return t.forEach(i=>{i.enabled&&e.push(i.id)}),e};addEntityModelToFootballBadges=async t=>{let e=[],i=[],r=[],a=[];if(t.football&&t.football.length>0&&(e=t.football.filter(l=>l.requirements.entityType.toLocaleLowerCase()==="competition").map(l=>l.requirements.entityId),i=t.football.filter(l=>l.requirements.entityType.toLocaleLowerCase()==="team").map(l=>l.requirements.entityId),r=t.football.filter(l=>l.requirements.entityType.toLocaleLowerCase()==="player").map(l=>l.requirements.entityId),a=t.football.filter(l=>l.requirements.entityType.toLocaleLowerCase()==="match").map(l=>l.requirements.entityId)),t.voting&&t.voting.poll&&t.voting.poll.length>0){let[l,n,p,c]=this.extractEntityIdsFromBadges(t.voting.poll);e=e.concat(l),e=Array.from(new Set(e)),i=i.concat(n),i=Array.from(new Set(i)),r=r.concat(p),r=Array.from(new Set(r)),a=a.concat(c),a=Array.from(new Set(a))}if(t.voting&&t.voting.potm&&t.voting.potm.length>0){let[l,n,p,c]=this.extractEntityIdsFromBadges(t.voting.potm);e=e.concat(l),e=Array.from(new Set(e)),i=i.concat(n),i=Array.from(new Set(i)),r=r.concat(p),r=Array.from(new Set(r)),a=a.concat(c),a=Array.from(new Set(a))}let s=await this.fetchFootballEntities(e,i,r,a);t.football&&t.football.length>0&&t.football.forEach(l=>{this.setEntityModelsFromMap(l.requirements,"competition",s.competitions),this.setEntityModelsFromMap(l.requirements,"team",s.teams),this.setEntityModelsFromObject(l.requirements,"player",s.players),this.setEntityModelsFromObject(l.requirements,"match",s.matches)}),t.voting&&t.voting.poll&&t.voting.poll.length>0&&t.voting.poll.forEach(l=>{this.setEntityModelsFromMap(l.requirements,"competition",s.competitions),this.setEntityModelsFromMap(l.requirements,"team",s.teams),this.setEntityModelsFromObject(l.requirements,"player",s.players),this.setEntityModelsFromObject(l.requirements,"match",s.matches)}),t.voting&&t.voting.potm&&t.voting.potm.length>0&&t.voting.potm.forEach(l=>{this.setEntityModelsFromMap(l.requirements,"competition",s.competitions),this.setEntityModelsFromMap(l.requirements,"team",s.teams),this.setEntityModelsFromObject(l.requirements,"player",s.players),this.setEntityModelsFromObject(l.requirements,"match",s.matches)})};setEntityModelsFromMap=(t,e,i)=>{t.entityType===e&&(t.entityModel=i&&i.get(t.entityId)||null,t.entityModel&&(t.entityId=t.entityModel.id))};setEntityModelsFromObject=(t,e,i)=>{t.entityType===e&&(t.entityModel=i[t.entityId]?i[t.entityId]:null,t.entityModel&&(t.entityId=t.entityModel.id))};fetchFootballEntities=async(t,e,i,r)=>{let a={competitions:null,teams:null,players:null,matches:null};if(t.length){let s=await this.footballNamespace.footballFacade.getCompetitionsMapWithNativeIds(t);a.competitions=s}if(e.length){let s=await this.footballNamespace.footballFacade.getTeamsMapWithNativeIds(e);a.teams=s}if(i.length){let s=await this.footballNamespace.footballFacade.getPlayersMapWithNativeIds(i);a.players=s}if(r.length){let s=await this.footballNamespace.footballFacade.getMatchesMapWithNativeIds(r);a.matches=s}return a};extractEntityIdsFromBadges=t=>{let e=t.filter(s=>s.requirements.entityType&&s.requirements.entityType.toLocaleLowerCase()==="competition").map(s=>s.requirements.entityId),i=t.filter(s=>s.requirements.entityType&&s.requirements.entityType.toLocaleLowerCase()==="team").map(s=>s.requirements.entityId),r=t.filter(s=>s.requirements.entityType&&s.requirements.entityType.toLocaleLowerCase()==="player").map(s=>s.requirements.entityId),a=t.filter(s=>s.requirements.entityType&&s.requirements.entityType.toLocaleLowerCase()==="match").map(s=>s.requirements.entityId);return[e,i,r,a]};addGameModelToGamesBadges=async t=>{if(!t.games||t.games.length===0)return;let e=this.getGameIdsFromGamesBadge(t.games,"top_x"),i=this.getGameIdsFromGamesBadge(t.games,"match_quiz"),r=this.getGameIdsFromGamesBadge(t.games,"classic_quiz"),a=this.getGameIdsFromGamesBadge(t.games,"either_or"),s=await this.fetchGamesEntities(e,i,r,a);t.games.forEach(l=>{l.requirements.specificGames&&l.requirements.specificGames.forEach(n=>{n.gameModel=s.find(p=>p.id===n.gameId)||null})})};getGameIdsFromGamesBadge=(t,e)=>{let i=t.filter(r=>r.requirements.specificGames?r.requirements.specificGames.some(a=>a.gameType.toLocaleLowerCase()===e):!1).map(r=>r.requirements.specificGames.map(a=>a.gameId));return Array.prototype.concat.apply([],i)};fetchGamesEntities=async(t,e,i,r)=>{let a=[];if(t.length){let s=await this.topXNamespace.getGames({gameIds:t});a=[...a,...s.data]}if(e.length){let s=await this.matchQuizNamespace.getGames({gameIds:e});a=[...a,...s.data]}if(i.length){let s=await this.miniGamesNamespace.getClassicQuizzes({classicQuizIds:i});a=[...a,...s.data]}if(r.length){let s=await this.miniGamesNamespace.getEitherOrs({eitherOrIds:r});a=[...a,...s.data]}return a}};var cs=class{validate=(t,e)=>{t.market&&this.validateMarket(t.market,e),t.fromDate&&this.validateDate(t.fromDate,"fromDate",e),t.toDate&&this.validateDate(t.toDate,"toDate",e),t.usersCount&&this.validateNumberFilters(t.usersCount,"usersCount",e),t.minimumPredictions&&this.validateNumberFilters(t.minimumPredictions,"minimumPredictions",e)};validateMarket=(t,e)=>{if(!Object.keys(Y).includes(t)){let r=Mn(t);throw e==="default"?new f(400,"INVALID_MARKET",r):new m(400,"INVALID_MARKET",r)}};validateDate=(t,e,i)=>{let r=/^\d{4}-\d{2}-\d{2}$/;if(typeof t!="string")throw i==="default"?new f(400,"invalid_filters","You have provided invalid type. The valid type is "+`string for ${e} filter`):new m(400,"invalid_filters","You have provided invalid type. The valid type is "+`string for ${e} filter`);if(!r.test(t))throw i==="default"?new f(400,"invalid_filters","You have provided invalid value. The valid value is "+`YYYY-MM-DD for ${e}`):new m(400,"invalid_filters","You have provided invalid value. The valid value is "+`YYYY-MM-DD for ${e}`)};validateNumberFilters=(t,e,i)=>{let r=e==="usersCount"?1:0,a=e==="usersCount"?1e3:1e6;if(typeof t!="number")throw i==="default"?new f(400,"invalid_filters","You have provided invalid type. The valid type is "+`number for ${e} filter`):new m(400,"invalid_filters","You have provided invalid type. The valid type is "+`number for ${e} filter`);if(t<r||t>a)throw i==="default"?new f(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${a}`):new m(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${a}`)}};var us=class{market;fromDate;toDate;usersCount;minimumPredictions;constructor(t){this.market=t.market?t.market:null,this.fromDate=t.fromDate?t.fromDate:null,this.toDate=t.toDate?t.toDate:null,this.usersCount=t.usersCount?t.usersCount:null,this.minimumPredictions=t.minimumPredictions?t.minimumPredictions:null}constructFiltersUrl(){let t="";return this.market&&(t+="&",t+=`market=${this.market}`),this.fromDate&&(t+="&",t+=`from_date=${this.fromDate}`),this.toDate&&(t+="&",t+=`to_date=${this.toDate}`),this.usersCount&&(t+="&",t+=`users_count=${this.usersCount}`),this.minimumPredictions&&(t+="&",t+=`minimum_predictions=${this.minimumPredictions}`),t}};var ds=class{flags=null;status=null;type=null;activeFrom=null;activeTo=null;createdFrom=null;createdTo=null;updatedFrom=null;updatedTo=null;constructor(t){this.flags=t.flags?t.flags:null,this.status=t.status?t.status:null,this.type=t.type?t.type:null,this.activeFrom=t.activeFrom?t.activeFrom:null,this.activeTo=t.activeTo?t.activeTo:null,this.createdFrom=t.createdFrom?t.createdFrom:null,this.createdTo=t.createdTo?t.createdTo:null,this.updatedFrom=t.updatedFrom?t.updatedFrom:null,this.updatedTo=t.updatedTo?t.updatedTo:null}constructFiltersUrl(){let t="";return this.flags&&this.flags.length>0&&(t+="&",t+=`flags=${this.flags.join(",")}`),this.status&&(t+="&",t+=`status=${this.status}`),this.type&&(t+="&",t+=`type=${this.type}`),this.activeFrom&&(t+="&",t+=`active_from=${this.activeFrom}`),this.activeTo&&(t+="&",t+=`active_to=${this.activeTo}`),this.createdFrom&&(t+="&",t+=`created_from=${this.createdFrom}`),this.createdTo&&(t+="&",t+=`created_to=${this.createdTo}`),this.updatedFrom&&(t+="&",t+=`updated_from=${this.updatedFrom}`),this.updatedTo&&(t+="&",t+=`updated_to=${this.updatedTo}`),t}};var ms=class{config=null;clientHttps=null;loyaltyHttps=null;loyaltyService=null;profileFacade=null;loyaltyValidator=null;idMapping=null;topXFacade=null;matchQuizFacade=null;predictorHttps=null;errorHandlingMode=null;football=null;constructor(t,e,i,r,a){this.config=t,this.clientHttps=e,this.loyaltyHttps=i,this.profileFacade=new lt(a,r),this.loyaltyService=new ps(this.config),this.loyaltyValidator=new cs,this.idMapping=new P(t),this.topXFacade=new $e(t,this.idMapping),this.matchQuizFacade=new Oe(t),this.predictorHttps=new at(t,this.idMapping),this.errorHandlingMode=t.errorHandlingMode,this.football=new J(t)}getConfig=async()=>await this.clientHttps.getConfig("loyalty");getConfigV2=async t=>{let e=await this.clientHttps.getNewLoyaltyConfig(t);return await this.loyaltyService.addEntityModelToFootballBadges(e.rewards.badges),await this.loyaltyService.addGameModelToGamesBadges(e.rewards.badges),e};getClientBadges=async()=>{let t=await this.getConfig();return this.loyaltyService.buildOldClientBadges(t.rewards.badges)};getClientBadgesV2=async t=>{let e=await this.clientHttps.getNewLoyaltyConfig(t);return this.loyaltyService.buildNewClientBadges(e.rewards.badges)};getTemplates=async(t,e)=>{if(t&&(t=new ds(t)),this.config.idSchema==="native")return await this.loyaltyHttps.getTemplates(t,e);let i=await this.loyaltyHttps.getTemplates(t,e);i.data=await this.loyaltyService.remapTemplatesIds([...i.data]);for(let r of i.data)await this.loyaltyService.remapTemplateGroupMatchIds(r.groups);return i};getTemplateById=async(t,e)=>{let i=await this.loyaltyHttps.getTemplateById(t,e);if(this.config.idSchema==="native")return i;let r=await this.loyaltyService.remapTemplatesIds([i]);return await this.loyaltyService.remapTemplateGroupMatchIds(r[0].groups),r[0]};getLeaderboard=async(t,e,i)=>{e=this.loyaltyService.initFilters(e,"loyalty");let r=await this.loyaltyHttps.getLeaderboard(t,i,e);return r.data=await this.loyaltyService.addProfileModelToLeaderboard(r.data),r};getLeaderboardForGame=async(t,e,i)=>{e=this.loyaltyService.initFilters(e,"loyalty");let r=await this.loyaltyHttps.getLeaderboardForGame(t,i,e);return r.data=await this.loyaltyService.addProfileModelToLeaderboard(r.data),r};getLeaderboardForLeague=async(t,e)=>{e=this.loyaltyService.initFilters(e,"league_leaderboard");let i=await this.loyaltyHttps.getLeaderboardForLeague(t,e);return i.data=await this.loyaltyService.addProfileModelToLeaderboard(i.data),i};getOwnRankings=async(t,e)=>{let{id:i}=await this.profileFacade.getOwn();return this.getUserRankings(i,t,e)};getUserRankings=async(t,e,i)=>{e=this.loyaltyService.initFilters(e,"rankings");let r=await this.loyaltyHttps.getUserRankings(t,e,i);return await this.getModelsForUserRankings(r)};getHighestSuccessRate=async(t,e)=>{t&&(t=new us(t),this.loyaltyValidator.validate(t,this.errorHandlingMode));let i=await this.loyaltyHttps.getHighestSuccessRate(t,e);return this.loyaltyService.addProfileModelToHighestSuccessRate(i)};getTemplateWinners=async(t,e)=>{let i=await this.predictorHttps.getContestWinners(t,e),r=await this.getTemplateById(t);return i.contestModel=r,this.loyaltyService.completeContestWinners(i)};getEntitiesFollows=async(t,e)=>{this.loyaltyService.validateEntitiesFollowsFilters(t),this.config.idSchema!=="native"&&(t=await this.loyaltyService.remapEntitiesFollowsFilters(t));let i=await this.loyaltyHttps.getEntitiesFollows(t,e);return await this.loyaltyService.addModelsToEntitiesFollows(i)};getModelsForUserRankings=async t=>{let e=null,i=null,r=null,[a,s,l]=this.loyaltyService.extractRankingsIdsMap(t.data);if(l.length&&(e=(await this.getTemplates()).data.filter(p=>l.includes(p.id))),a.length){let n={gameIds:a};i=(await this.topXFacade.getGames(n)).data}if(s.length){let n={gameIds:s};r=(await this.matchQuizFacade.getGames(n)).data}return this.loyaltyService.setModelsForUserRankings(i,r,e,t)};getTemplateMatches=async(t,e,i)=>{let r=await this.getTemplateById(t,i);if((!r.competitionIds||r.competitionIds.length===0)&&(!r.teamIds||r.teamIds.length===0)&&(!r.matchIds||r.matchIds.length===0)&&(!r.groups||r.groups.length===0))return[];let a=this.loyaltyService.initMatchFiltersForTemplates(r,e);return(await this.football.getMatches(a,i)).data}};var ze=class{clientHttps=null;profileHttps=null;loyaltyHttps=null;loyaltyFacade=null;localCache=null;constructor(t){this.clientHttps=new N(t),this.profileHttps=new Wt(t),this.loyaltyHttps=new Et(t),this.localCache=new K().createLocalCacheInstance(t.idSchema),this.loyaltyFacade=new ms(t,this.clientHttps,this.loyaltyHttps,this.profileHttps,this.localCache)}getConfig=async()=>await this.loyaltyFacade.getConfig();getConfigV2=async t=>await this.loyaltyFacade.getConfigV2(t);getClientBadges=async()=>await this.loyaltyFacade.getClientBadges();getClientBadgesV2=async t=>await this.loyaltyFacade.getClientBadgesV2(t);getTemplates=async(t,e)=>await this.loyaltyFacade.getTemplates(t,e);getTemplateById=async(t,e)=>await this.loyaltyFacade.getTemplateById(t,e);getLeaderboard=async(t,e,i)=>await this.loyaltyFacade.getLeaderboard(t,e,i);getLeaderboardForGame=async(t,e,i)=>await this.loyaltyFacade.getLeaderboardForGame(t,e,i);getLeaderboardForLeague=async(t,e)=>await this.loyaltyFacade.getLeaderboardForLeague(t,e);getOwnRankings=async(t,e)=>await this.loyaltyFacade.getOwnRankings(t,e);getUserRankings=async(t,e,i)=>await this.loyaltyFacade.getUserRankings(t,e,i);getHighestSuccessRate=async(t,e)=>await this.loyaltyFacade.getHighestSuccessRate(t,e);getTemplateWinners=async(t,e)=>await this.loyaltyFacade.getTemplateWinners(t,e);getEntitiesFollows=async(t,e)=>await this.loyaltyFacade.getEntitiesFollows(t,e);getTemplateMatches=async(t,e,i)=>await this.loyaltyFacade.getTemplateMatches(t,e,i)};var Ti=class{action=null;context=new _t;constructor(t,e,i,r){this.action=t,this.context.tags=e,i&&(this.context.content=i),r&&(this.context.campaign=r)}};var qe=class{page=null;limit=null;constructor(t){this.page=t.page?t.page:null,this.limit=t.limit?t.limit:null}};var hs=class extends qe{action=null;constructor(t){super(t),this.action=t.action?t.action:null}constructFilterUrl(){let t="";return this.action&&(t+="&",t+=`action=${this.action}`),this.page&&(t+="&",t+=`page=${this.page}`),this.limit&&(t+="&",t+=`limit=${this.limit}`),t}};var gs=class extends qe{action=null;constructor(t){super(t),this.action=t.action?t.action:null}constructFilterUrl(){let t="";return this.action&&(t+="&",t+=`action=${this.action}`),this.page&&(t+="&",t+=`page=${this.page}`),this.limit&&(t+="&",t+=`limit=${this.limit}`),t}};var fs=class{idSchema;activityHttps;activityService;constructor(t){this.idSchema=t.idSchema,this.activityHttps=new ge(t),this.activityService=new gt(t)}add=async(t,e,i,r)=>{if(this.idSchema!="native"){let s=JSON.parse(JSON.stringify(e)),l=await this.activityService.remapTagsIds(e,this.idSchema,"native"),n=new Ti(t,l,i,r),p=await this.activityHttps.createActivity(n);return p.context.tags=s,p}let a=new Ti(t,e,i,r);return this.activityHttps.createActivity(a)};delete=async t=>await this.activityHttps.deleteActivity(t);like=async(t,e,i)=>{let r="like";return await this.add(r,t,e,i)};dislike=async(t,e,i)=>{let r="dislike";return await this.add(r,t,e,i)};addPageview=async(t,e,i)=>{let r="page_view";return await this.add(r,t,e,i)};addContentConsumed=async(t,e,i)=>{let r="content_consumed";return await this.add(r,t,e,i)};addShare=async(t,e,i)=>{let r="share";return await this.add(r,t,e,i)};addComment=async(t,e,i)=>{let r="comment";return await this.add(r,t,e,i)};addClickAd=async(t,e,i)=>{let r="click_ad";return await this.add(r,t,e,i)};addConversion=async(t,e,i)=>{let r="conversion";return await this.add(r,t,e,i)};getOwn=async(t,e)=>{if(e=e||!1,t&&(t=new hs(t)),this.idSchema!="native"){let i=await this.activityHttps.getOwnActivities(t,e);for(let r of i.data)await this.activityService.remapTagsIds(r.context.tags,"native",this.idSchema);return i}return await this.activityHttps.getOwnActivities(t,e)};getForUser=async(t,e,i)=>{if(i=i||!1,e&&(e=new gs(e)),this.idSchema!="native"){let r=await this.activityHttps.getActivitiesForUser(t,e,i),a=JSON.parse(JSON.stringify(r));for(let s of a.data)await this.activityService.remapTagsIds([...s.context.tags],"native",this.idSchema);return a}return await this.activityHttps.getActivitiesForUser(t,e,i)}};var ys=class{activityFacade;constructor(t){this.activityFacade=new fs(t)}add=async(t,e,i,r)=>await this.activityFacade.add(t,e,i,r);delete=async t=>await this.activityFacade.delete(t);like=async(t,e,i)=>await this.activityFacade.like(t,e,i);dislike=async(t,e,i)=>await this.activityFacade.dislike(t,e,i);addPageview=async(t,e,i)=>await this.activityFacade.addPageview(t,e,i);addContentConsumed=async(t,e,i)=>await this.activityFacade.addContentConsumed(t,e,i);addShare=async(t,e,i)=>await this.activityFacade.addShare(t,e,i);addComment=async(t,e,i)=>await this.activityFacade.addComment(t,e,i);addClickAd=async(t,e,i)=>await this.activityFacade.addClickAd(t,e,i);addConversion=async(t,e,i)=>await this.activityFacade.addConversion(t,e,i);getOwn=async(t,e)=>await this.activityFacade.getOwn(t,e);getForUser=async(t,e,i)=>await this.activityFacade.getForUser(t,e,i)};var bs=class{id="";label="";discussionType="LEAGUE";moderationType="USER";postsCount=0;pinnedPosts=[];lastPostId="";status="";deleted=!1;deletedAt="";deletedBy="";customFields=null;context=null;createdAt="";updatedAt=""};var Ct=class{pagination={totalItems:0,nextPageStartsAfter:"",lastCommentCreateTimestamp:""}};var Qe=class{id="";userId="";discussionId="";content="";repliesCount=0;replyId="";anonymousNickname="";reactions=[];reactionsCount=0;reports=[];reportsCount=0;versions=null;privatePost=!1;deleted=!1;deletedAt="";deletedBy="";moderated=!1;moderatedAt="";moderatedBy="";moderatedReason="";createdAt="";updatedAt=""};var Ms=class{meta=new Ct;data=[]};var ws=class{type="";userIds=[];reactionCount=0};var Is=class{updatedAt="";content=""};var Ps=class{userId=null;reason="AD";reasonDetails=null};var _s=class extends Qe{userModel=null};var Ts=class{meta=new Ct;data=[]};var vs=class{meta=new x;data=[]};var Fs=class{id="";postsCount=0};var Ke=class{remapToDiscussions=t=>(t.meta=this.remapToMeta(t.meta),t.data=t.data.map(e=>this.remapToDiscussionById(e)),t);remapToDiscussionById=t=>{let e=new bs;return e.id=t.id,e.label=t.label,e.status=t.status,e.deleted=t.deleted,e.deletedAt=t.deleted_at,e.deletedBy=t.deleted_by,e.discussionType=t.discussion_type,e.moderationType=t.moderation_type,e.postsCount=t.posts_count,e.pinnedPosts=t.pinned_posts,e.lastPostId=t.last_post_id,e.customFields=t.custom_fields,e.context=t.context,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapToPostsForDiscussion=(t,e)=>{let i=new Ms,r=new Ts;return i.meta=this.remapToPostMeta(t.meta),i.data=t.data.map(a=>this.remapToPostByIdBasic(a)),r.meta=this.remapToPostMeta(t.meta),r.data=t.data.map(a=>this.remapToPostByIdFull(a)),e==="basic"?i:r};remapToPosts=t=>{let e=new vs;return e.meta=this.remapToMeta(t.meta),e.data=t.data.map(i=>this.remapToPostByIdBasic(i)),e};remapToPostMeta=t=>{let e=new Ct;return e.pagination.totalItems=t.pagination.total_items,e.pagination.nextPageStartsAfter=t.pagination.next_page_starts_after,e.pagination.lastCommentCreateTimestamp=t.pagination.last_comment_create_timestamp,e};remapToMeta=t=>{let e=new x;return e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.nextPageStartsAfter=t.pagination.next_page_starts_after,e};remapToPostByIdBasic=t=>{let e=new Qe;return e.id=t.id,e.userId=t.user_id,e.discussionId=t.discussion_id,e.content=t.content,e.anonymousNickname=t.anonymous_nickname,e.reactionsCount=t.reactions_count,e.replyId=t.reply_id,e.reactions=t.reactions.length?t.reactions.map(i=>this.remapReactionsPost(i)):t.reactions,e.repliesCount=t.replies_count,e.reports=t.reports.length?t.reports.map(i=>this.remapReportPost(i)):t.reports,e.reportsCount=t.reports_count,e.versions=t.versions.length?t.versions.map(i=>this.remapVersionsPost(i)):t.versions,e.privatePost=t.private_post,e.deleted=t.deleted,e.deletedAt=t.deleted_at,e.deletedBy=t.deleted_by,e.moderated=t.moderated,e.moderatedAt=t.moderated_at,e.moderatedBy=t.moderated_by,e.moderatedReason=t.moderated_reason,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapToPostByIdFull=t=>{let e=new _s;return e.id=t.id,e.userId=t.user_id,e.discussionId=t.discussion_id,e.content=t.content,e.anonymousNickname=t.anonymous_nickname,e.reactionsCount=t.reactions_count,e.replyId=t.reply_id,e.reactions=t.reactions.length?t.reactions.map(i=>this.remapReactionsPost(i)):t.reactions,e.repliesCount=t.replies_count,e.reports=t.reports.length?t.reports.map(i=>this.remapReportPost(i)):t.reports,e.reportsCount=t.reports_count,e.versions=t.versions.length?t.versions.map(i=>this.remapVersionsPost(i)):t.versions,e.privatePost=t.private_post,e.deleted=t.deleted,e.deletedAt=t.deleted_at,e.deletedBy=t.deleted_by,e.moderated=t.moderated,e.moderatedAt=t.moderated_at,e.moderatedBy=t.moderated_by,e.moderatedReason=t.moderated_reason,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapToPostCount=t=>t.map(e=>{let i=new Fs;return i.id=e.id,i.postsCount=e.posts_count,i});remapReactionsPost=t=>{let e=new ws;return e.type=t.type,e.userIds=t.user_ids,e.reactionCount=t.reaction_count,e};remapVersionsPost=t=>{let e=new Is;return e.content=t.content,e.updatedAt=t.updated_at,e};remapReportPost=t=>{let e=new Ps;return e.userId=t.user_id,e.reason=t.reason,e.reasonDetails=t.reason_details,e}};var Es=class extends T{remapper=null;constructor(t){super(t,S(t.environment,"discussions")),this.remapper=new Ke}getAll=async(t,e)=>{let i="/discussions"+this.apiSignInUrl;t&&(i+=`${t.constructMainFiltersUrl()}`),w(e)&&(i+=h());let r="There was a problem getting discussions",a=await this.fetchWithoutAuth(i,r);return this.remapper.remapToDiscussions(a)};getById=async t=>{let e=`/discussions/${t}`+this.apiSignInUrl,i="There was a problem getting discussion",r=await this.fetchWithoutAuth(e,i);return this.remapper.remapToDiscussionById(r.data)};createPost=async(t,e)=>{let i=`/discussions/${t}/posts`+this.apiSignInUrl,r="There was a problem creating post in discussion",a="POST",s=await this.fetchWithAuth(i,r,a,e);return this.remapper.remapToPostByIdBasic(s.data)};getPostById=async t=>{let e=`/posts/${t}`+this.apiSignInUrl,i="There was a problem getting post by ID in discussion",r=await this.fetchWithoutAuth(e,i);return this.remapper.remapToPostByIdFull(r.data)};updatePost=async(t,e)=>{let i=`/posts/${t}`+this.apiSignInUrl,r="There was a problem editing post in discussion",a="PUT",s={content:e},l=await this.fetchWithAuth(i,r,a,s);return this.remapper.remapToPostByIdBasic(l.data)};reactToPost=async(t,e)=>{let i=`/posts/${t}/reaction`+this.apiSignInUrl,r="There was a problem reacting to post in discussion",a="PUT",s={reaction:e.toLocaleLowerCase()},l=await this.fetchWithAuth(i,r,a,s);return this.remapper.remapToPostByIdFull(l.data)};deletePost=async t=>{let e=`/posts/${t}`+this.apiSignInUrl,i="There was a problem deleting post in discussion",r="DELETE";return await this.fetchWithAuth(e,i,r),!0};getPosts=async(t,e)=>{let i=`/discussions/${t}/posts`+this.apiSignInUrl;e&&(i+=`${e.constructMainFiltersUrl()}`);let r="There was a problem getting posts in discussion",a=await this.fetchWithoutAuth(i,r);return this.remapper.remapToPostsForDiscussion(a,"full")};getPostReplies=async(t,e)=>{let i=`/posts/${t}/replies`+this.apiSignInUrl;e&&(i+=`${e.constructMainFiltersUrl()}`);let r="There was a problem getting post's replies in discussion",a=await this.fetchWithoutAuth(i,r);return this.remapper.remapToPostsForDiscussion(a,"full")};reportPost=async(t,e,i)=>{let r=`/posts/${t}/report`+this.apiSignInUrl,a="There was a problem reporting post in discussion",s="POST",l={reason:e.toLocaleUpperCase(),reason_details:i||null},n=await this.fetchWithAuth(r,a,s,l);return this.remapper.remapToPostByIdBasic(n.data)};getOwnPosts=async t=>{let e="/posts"+this.apiSignInUrl;t&&(e+=`${t.constructMainFiltersUrl()}`);let i="There was a problem getting own posts",r=await this.fetchWithAuth(e,i);return this.remapper.remapToPosts(r)};getUserPosts=async(t,e,i)=>{let r=`/posts/users/${t}`+this.apiSignInUrl;e&&(r+=`${e.constructMainFiltersUrl()}`),w(i)&&(r+=h());let a="There was a problem getting user's posts",s=await this.fetchWithoutAuth(r,a);return this.remapper.remapToPosts(s)};getPostsCount=async(t,e)=>{let i="/discussions/posts/count"+this.apiSignInUrl+`&discussion_ids=${t.join(",")}`;w(e)&&(i+=h());let r="There was a problem getting posts count for discussions",a=await this.fetchWithoutAuth(i,r);return this.remapper.remapToPostCount(a.data)};getTopDiscussions=async(t,e)=>{let i="/discussions/top"+this.apiSignInUrl;t&&(i+=`${t.constructMainFiltersUrl()}`),w(e)&&(i+=h());let r="There was a problem getting top discussions",a=await this.fetchWithoutAuth(i,r);return this.remapper.remapToDiscussions(a)}};var Ss=class{content="";reply_id="";anonymous_nickname="";context=null};var Rs=class{createRequestBodyFromParam=t=>{let e=new Ss;return e.content=t.content,e.reply_id=t.replyId,e.anonymous_nickname=t.userNickname,e.context=t.context,e}};var Wl=["CREATED_AT_ASC","CREATED_AT_DESC","POSTS_COUNT_ASC","POSTS_COUNT_DESC"],zl=["ACTIVE","INACTIVE"],Cs=class extends v{discussionIds;label;fromDate;toDate;fromCount;toCount;sort;status;skipDeleted;constructor(t){super(t),this.discussionIds=t&&t.discussionIds?t.discussionIds:null,this.label=t&&t.label?t.label:null,this.fromDate=t&&t.fromDate?t.fromDate:null,this.toDate=t&&t.toDate?t.toDate:null,this.fromCount=t&&t.fromCount?t.fromCount:null,this.toCount=t&&t.toCount?t.toCount:null,this.sort=t&&t.sort?t.sort:null,this.status=t?.status||null,this.skipDeleted=t&&t.skipDeleted!==void 0?t.skipDeleted:null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.discussionIds!==null&&(t+=`&discussion_ids=${this.discussionIds.join(",")}`),this.label!==null&&(t+=`&label=${this.label}`),this.fromDate!==null&&(t+=`&from_date=${this.fromDate}`),this.toDate!==null&&(t+=`&to_date=${this.toDate}`),this.fromCount!==null&&(t+=`&from_count=${this.fromCount}`),this.toCount!==null&&(t+=`&to_count=${this.toCount}`),this.sort&&Wl.includes(this.sort.toUpperCase())&&(t+=`&sort=${this.sort.toUpperCase()}`),this.status&&zl.includes(this.status.toUpperCase())&&(t+=`&status=${this.status.toUpperCase()}`),this.skipDeleted!==null&&(t+=`&skip_deleted=${this.skipDeleted}`),t}};var Gt=class extends v{skipDeleted;sort;constructor(t){super(t),this.skipDeleted=t&&t.skipDeleted!==void 0?t.skipDeleted:null,this.sort=t&&t.sort?t.sort.toLocaleLowerCase():null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.skipDeleted!==null&&(t+=`&skip_deleted=${this.skipDeleted}`),this.sort&&(t+=`&sort=${this.sort}`),t}};var As=class extends v{fromDate;toDate;entityIds;entityType;contentType;constructor(t){super(t),this.fromDate=t?.fromDate||null,this.toDate=t?.toDate||null,this.entityIds=t?.entityIds||null,this.entityType=t?.entityType||null,this.contentType=t?.contentType||null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.fromDate!==null&&(t+=`&from_date=${this.fromDate}`),this.toDate!==null&&(t+=`&to_date=${this.toDate}`),this.entityIds!==null&&this.entityIds.length>0&&(t+=`&entity_ids=${this.entityIds}`),this.contentType!==null&&(t+=`&content_type=${this.contentType}`),t}};var At=class{idSchema=null;profile=null;validator=null;idMapping=null;constructor(t){this.idSchema=t.idSchema,this.profile=new O(t),this.validator=new St(t),this.idMapping=new P(t)}finalizePostFullModel=async t=>{let e=t.map(r=>r.userId),i=await this.profile.getByIds(e);return t.map(r=>(r.userModel=this.extractModelById(i,r.userId),r))};finalizeTopDiscussionsFilters=async t=>{if(this.idSchema!=="native"&&t.entityIds&&t.entityIds.length>0){this.validator.validateFilters(t);let e=await this.idMapping.getEntityIdsBySchemaId(Array.from(t.entityIds),t.entityType,"native");t.entityIds=e[t.entityType]}};extractModelById=(t,e)=>{if(t.length){let i=t.find(r=>r.id===e);return i?(delete i.interests,i):null}return null}};var Os=class{idSchema=null;errorHandlingMode=null;https=null;clientHttps=null;activityService=null;service=null;factory=null;constructor(t){this.idSchema=t.idSchema,this.errorHandlingMode=t.errorHandlingMode,this.https=new Es(t),this.clientHttps=new N(t),this.activityService=new gt(t),this.service=new At(t),this.factory=new Rs}getAll=async(t,e)=>{t&&(t=new Cs(t));let i=await this.https.getAll(t,e);for(let r of i.data)await this.remapTags(r,"native",this.idSchema);return i};getById=async t=>{let e=await this.https.getById(t);return await this.remapTags(e,"native",this.idSchema),e};createPost=async(t,e)=>{let i=JSON.parse(JSON.stringify(e));await this.remapTags(i,this.idSchema,"native");let r=this.factory.createRequestBodyFromParam(i);return await this.https.createPost(t,r)};getPostById=async t=>{let e=await this.https.getPostById(t);return(await this.service.finalizePostFullModel([e]))[0]};updatePost=async(t,e)=>await this.https.updatePost(t,e);deletePost=async t=>await this.https.deletePost(t);getPosts=async(t,e)=>{e&&(e=new Gt(e));let i=await this.https.getPosts(t,e);return i.data=await this.service.finalizePostFullModel(i.data),i};getPostReplies=async(t,e)=>{e&&(e=new Gt(e));let i=await this.https.getPostReplies(t,e);return i.data=await this.service.finalizePostFullModel(i.data),i};reactToPost=async(t,e)=>{let i=await this.https.reactToPost(t,e);return(await this.service.finalizePostFullModel([i]))[0]};reportPost=async(t,e,i)=>await this.https.reportPost(t,e,i);getOwnPosts=async t=>(t&&(t=new Gt(t)),await this.https.getOwnPosts(t));getUserPosts=async(t,e,i)=>(e&&(e=new Gt(e)),await this.https.getUserPosts(t,e,i));getConfig=async()=>await this.clientHttps.getConfig("discussions");getPostsCount=async(t,e)=>{if(!t||!Array.isArray(t)||!t.length)throw this.errorHandlingMode==="standard"?new m(400,"invalid_discussion_ids","Invalid discussion ids argument. Please provide at least one discussion id in an array"):new f(400,"invalid_discussion_ids","Invalid discussion ids argument. Please provide at least one discussion id in an array");return await this.https.getPostsCount(t,e)};getTopDiscussions=async(t,e)=>{t&&(t=new As(t),await this.service.finalizeTopDiscussionsFilters(t));let i=await this.https.getTopDiscussions(t,e);for(let r of i.data)await this.remapTags(r,"native",this.idSchema);return i};remapTags=async(t,e,i)=>{if(this.idSchema!="native"&&t.context&&t.context.tags&&t.context.tags.length){let r=JSON.parse(JSON.stringify(t.context.tags)),a=await this.activityService.remapTagsIds(r,e,i);t.context.tags=a}}};var Ls=class{facade=null;constructor(t){this.facade=new Os(t)}getAll=async(t,e)=>await this.facade.getAll(t,e);getById=async t=>await this.facade.getById(t);createPost=async(t,e)=>await this.facade.createPost(t,e);getPostById=async t=>await this.facade.getPostById(t);updatePost=async(t,e)=>await this.facade.updatePost(t,e);deletePost=async t=>await this.facade.deletePost(t);getPosts=async(t,e)=>await this.facade.getPosts(t,e);getPostReplies=async(t,e)=>await this.facade.getPostReplies(t,e);react=async(t,e)=>await this.facade.reactToPost(t,e);reportPost=async(t,e,i)=>await this.facade.reportPost(t,e,i);getOwnPosts=async t=>await this.facade.getOwnPosts(t);getUserPosts=async(t,e,i)=>await this.facade.getUserPosts(t,e,i);getConfig=async()=>await this.facade.getConfig();getPostsCount=async(t,e)=>await this.facade.getPostsCount(t,e);getTopDiscussions=async(t,e)=>await this.facade.getTopDiscussions(t,e)};var xs=class{profileId="";profileModel=null;challengeId="";challengeModel=null;message=""};var Ds=class{profileId="";profileModel=null;leagueId="";leagueModel=null;message=""};var je=class{id="";name="";description="";type="";banned=[];invites=[];administrators=[];membersCount=0;invitationCode="";templateId="";templateModel=null;pastTemplates=[];usersCanInviteUsers=!1;scoringStartsAt="";pinnedPosts=[]};var Bs=class extends je{members=[]};var Ns=class{predictionId=null;predictionModel=null;profileId=null;profileModel=null};var ks=class{remapToPrivateLeagues=t=>(t.meta=this.remapMetaPrivateLeagues(t.meta.pagination),t.data=t.data.map(e=>this.remapToPrivateLeagueById(e)),t);remapMetaPrivateLeagues=t=>{let e=new x;return e.pagination.itemsPerPage=t.items_per_page,e.pagination.nextPageStartsAfter=t.next_page_starts_after,e};remapToPrivateLeagueById=t=>{let e=new Bs;return e.id=t.id,e.name=t.name,e.description=t.description,e.type=t.type,e.members=t.members,e.administrators=t.administrators,e.banned=t.banned,e.invites=t.invites,e.membersCount=t.members_count,e.usersCanInviteUsers=t.users_can_invite_users,e.invitationCode=t.invitation_code,e.templateId=t.template_id,e.pastTemplates=t.past_templates,e.pinnedPosts=t.pinned_posts,e.scoringStartsAt=t.scoring_starts_at,e};remapToMyPrivateLeagues=t=>{let e=new je;return e.id=t.id,e.name=t.name,e.description=t.description,e.type=t.type,e.administrators=t.administrators,e.banned=t.banned,e.invites=t.invites,e.membersCount=t.members_count,e.usersCanInviteUsers=t.users_can_invite_users,e.invitationCode=t.invitation_code,e.templateId=t.template_id,e.pastTemplates=t.past_templates,e.pinnedPosts=t.pinned_posts,e.scoringStartsAt=t.scoring_starts_at,e};remapToAcceptPrivateLeague=t=>{let e=new Ds;return e.profileId=t.profile_id,e.leagueId=t.league_id,e.message=t.message,e};remapToAcceptChallenge=t=>{let e=new xs;return e.profileId=t.profile_id,e.challengeId=t.league_id,e.message=t.message,e};remapPredictions=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapPredictionsData(t.data),t);remapMeta=t=>{let e=new H;return e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.numberOfPages=t.pagination.number_of_pages,e.pagination.totalItems=t.pagination.total_items,e};remapPredictionsData=t=>t.map(e=>{let i=new Ns;return i.predictionId=e.prediction_id,i.profileId=e.profile_id,i})};var Xe=class extends T{remapper=null;discussionsRemapper=null;discussionsBaseURL=null;constructor(t){super(t,S(t.environment,"privateLeagues")),this.discussionsBaseURL=S(t.environment,"discussions"),this.remapper=new ks,this.discussionsRemapper=new Ke}create=async(t,e)=>{let i="/leagues"+this.apiSignInUrl,a=`There was a problem ${e==="PRIVATE_LEAGUE"?"creating private league":"issuing challenge"}`,s="POST",l=await this.fetchWithAuth(i,a,s,t);return this.remapper.remapToPrivateLeagueById(l.data)};update=async(t,e,i)=>{let r=`/leagues/${t}`+this.apiSignInUrl,s=`There was a problem updating ${i==="PRIVATE_LEAGUE"?"private league":"challenge"}`,l="PUT",n=await this.fetchWithAuth(r,s,l,e);return this.remapper.remapToPrivateLeagueById(n.data)};updateLeagueTemplate=async(t,e,i,r)=>{let a=`/leagues/${t}/template`+this.apiSignInUrl,l=`There was a problem updating template for the ${r==="PRIVATE_LEAGUE"?"private league":"challenge"}`,n="POST",p={new_template_id:e,past_template_name:i},c=await this.fetchWithAuth(a,l,n,p);return this.remapper.remapToPrivateLeagueById(c.data)};getById=async(t,e,i)=>{let r=`/leagues/${t}`+this.apiSignInUrl;w(i)&&(r+=h());let s=`There was a problem getting ${e==="PRIVATE_LEAGUE"?"private league":"challenge"}`,l=await this.fetchWithAuth(r,s);return this.remapper.remapToPrivateLeagueById(l.data)};getMyLeagues=async(t,e)=>{let i="/leagues"+this.apiSignInUrl+t.constructFiltersUrl(),a=`There was a problem getting user's ${e==="PRIVATE_LEAGUE"?"private leagues":"challenges"}`;return(await this.fetchWithAuth(i,a)).data.map(l=>this.remapper.remapToMyPrivateLeagues(l))};delete=async(t,e)=>{let i=`/leagues/${t}`+this.apiSignInUrl,a=`There was a problem deleting ${e==="PRIVATE_LEAGUE"?"private league":"challenge"}`,s="DELETE";return await this.fetchWithAuth(i,a,s),!0};invite=async(t,e)=>{let i=`/membership/invite/${t}`+this.apiSignInUrl,r=`There was a problem inviting the following users: ${e.join(",")}`,a="POST",s={profiles:e};return(await this.fetchWithAuth(i,r,a,s)).data};deleteInvitation=async(t,e)=>{let i=`/membership/invite/${t}`+this.apiSignInUrl,r=`There was a problem deleting invitation for the following users: ${e.join(",")}`,a="DELETE",s={profiles:e};return await this.fetchWithAuth(i,r,a,s),!0};accept=async(t,e,i)=>{let r=`/membership/accept/${t}`+this.apiSignInUrl+`&accept=${e?"ACCEPT":"REJECT"}`,s=`There was a problem ${e?"accepting":"rejecting"} invitation for ${i==="PRIVATE_LEAGUE"?"private league":"challenge"}: ${t}`,l="POST",n=await this.fetchWithAuth(r,s,l);return i==="PRIVATE_LEAGUE"?this.remapper.remapToAcceptPrivateLeague(n.data):this.remapper.remapToAcceptChallenge(n.data)};ban=async(t,e)=>{let i=`/membership/ban/${t}`+this.apiSignInUrl,r=`There was a problem banning the following users: ${e.join(",")}`,a="POST",s={profiles:e};return(await this.fetchWithAuth(i,r,a,s)).data};unban=async(t,e)=>{let i=`/membership/unban/${t}`+this.apiSignInUrl,r=`There was a problem unbanning the following users: ${e.join(",")}`,a="POST",s={profiles:e};return(await this.fetchWithAuth(i,r,a,s)).data};join=async t=>{let e="/membership/join"+this.apiSignInUrl+`&invitation_code=${t}`,i="There was a problem joining league",r="POST",a=await this.fetchWithAuth(e,i,r);return this.remapper.remapToAcceptPrivateLeague(a.data)};leave=async(t,e)=>{let i=`/membership/leave/${t}`+this.apiSignInUrl,a=`There was a problem leaving the following ${e==="PRIVATE_LEAGUE"?"league":"challenge"}: ${t}`,s="POST";return(await this.fetchWithAuth(i,a,s)).data};getInvitations=async(t,e)=>{let i="/membership/invitations"+this.apiSignInUrl+e.constructMainFiltersUrl(),a=`There was a problem getting invitations for ${t==="PRIVATE_LEAGUE"?"leagues":"challenges"}`,s=await this.fetchWithAuth(i,a);return this.remapper.remapToPrivateLeagues(s)};getReportedPosts=async(t,e)=>{let i=`/discussions/${t}/posts/reported${this.apiSignInUrl}`,r=`There was a problem fetching posts for the following: ${t}`;e&&(i+=e.constructMainFiltersUrl());let a=await this.fetchWithAuthNewBaseURL(this.discussionsBaseURL,i,r);return this.discussionsRemapper.remapToPostsForDiscussion(a,"full")};getPredictions=async(t,e)=>{let i=`/leagues/${t}/predictions`+this.apiSignInUrl,r=`There was a problem getting predictions for private league: ${t}`;e&&(i+=e.constructFiltersUrl());let a=await this.fetchWithAuth(i,r);return this.remapper.remapPredictions(a)};moderatePost=async(t,e)=>{let i=`/posts/${t}/admin/moderate${this.apiSignInUrl}`,r=`There was a problem moderating the following post: ${t}`,a="POST",s={moderation_reason:e},l=await this.fetchWithAuthNewBaseURL(this.discussionsBaseURL,i,r,a,s);return this.discussionsRemapper.remapToPostByIdBasic(l.data)}};var Ye=class{name="";description="";invitation_code="";template_id="";users_can_invite_users=!1;administrators=[];scoring_starts_at=""};var Us=class extends Ye{type="ONE_VS_ONE"};var Gs=class extends Ye{type="PRIVATE"};var Je=class{name="";description="";invitation_code="";template_id="";users_can_invite_users=!1;administrators=[];pinned_posts=[];scoring_starts_at=""};var Vs=class extends Je{type="PRIVATE"};var Hs=class extends Je{type="ONE_VS_ONE"};var Ze=class{createRequestBodyFromParam=(t,e)=>{let i=e==="PRIVATE"?new Gs:new Us;return i.name=t.name,i.description=t.description,i.invitation_code=t.invitationCode,i.template_id=t.templateId,i.users_can_invite_users=t.usersCanInviteUsers,t.administrators?i.administrators=t.administrators:delete i.administrators,t.scoringStartsAt?i.scoring_starts_at=t.scoringStartsAt:delete i.scoring_starts_at,i};createUpdateRequestBodyFromParam=(t,e)=>{let i=e==="PRIVATE"?new Vs:new Hs;return i.name=t.name,i.description=t.description,i.invitation_code=t.invitationCode,i.template_id=t.templateId,i.users_can_invite_users=t.usersCanInviteUsers,i.administrators=t.administrators,i.pinned_posts=t.pinnedPosts,i.scoring_starts_at=t.scoringStartsAt,i}};var ti=class extends v{type=null;constructor(t){super(t),this.type=t&&t.type?t.type:null}constructMainFiltersUrl=()=>{let t=super.constructMainFiltersUrl();return this.type&&(t+=`&type=${this.type}`),t}};var $s=class{type="PRIVATE";userRole=null;constructor(t){this.userRole=t?.userRole||null}constructFiltersUrl=()=>{let t=`&type=${this.type}`;return this.userRole&&(t+=`&user_role=${this.userRole}`),t}};var Ws=class{limit=null;page=null;leagueId=null;templateId=null;sortOrder=null;constructor(t){this.limit=t&&t.limit?t.limit:null,this.page=t&&t.page?t.page:null,this.leagueId=t&&t.leagueId?t.leagueId:null,this.templateId=t&&t.templateId?t.templateId:null,this.sortOrder=t&&t.sortOrder?t.sortOrder:null}constructFiltersUrl=()=>{let t="";return this.limit&&(t+=`&limit=${this.limit}`),this.page&&(t+=`&page=${this.page}`),this.leagueId&&(t+=`&league_id=${this.leagueId}`),this.templateId&&(t+=`&template_id=${this.templateId}`),this.sortOrder&&(t+=`&sort_order=${this.sortOrder}`),t}};var ei=class extends v{reportsCount=null;constructor(t){super(t),this.reportsCount=t.reportsCount?t.reportsCount:null}constructMainFiltersUrl=()=>{let t=super.constructMainFiltersUrl();return this.reportsCount&&(t+=`&reports_count=${this.reportsCount}`),t}};var ii=class{limit=null;page=null;profileIds=null;constructor(t){this.limit=t&&t.limit?t.limit:null,this.page=t&&t.page?t.page:null,this.profileIds=t&&t.profileIds?t.leagueId:null}constructFiltersUrl=()=>{let t="";return this.limit&&(t+=`&limit=${this.limit}`),this.page&&(t+=`&page=${this.page}`),this.profileIds&&(t+=`&profile_ids=${this.profileIds.join(",")}`),t}};var ri=class{loyalty=null;profile=null;predictor=null;constructor(t){this.loyalty=new ze(t),this.profile=new O(t),this.predictor=new Re(t)}setTemplateModels=async t=>{let e=await this.loyalty.getTemplates();t.templateModel=e.data.find(i=>i.id===t.templateId),t.pastTemplates&&t.pastTemplates.length>0&&t.pastTemplates.forEach(i=>{i.model=e.data.find(r=>r.id===i.id)})};setTemplateModelsInLeagues=async t=>{if(!t.length)return;let e=await this.loyalty.getTemplates();t.forEach(i=>{i.templateModel=e.data.find(r=>r.id===i.templateId),i.pastTemplates&&i.pastTemplates.length>0&&i.pastTemplates.forEach(r=>{r.model=e.data.find(a=>a.id===r.id)})})};setTemplateModelsFromLeagueModels=(t,e)=>{if(e==="PRIVATE_LEAGUE"){t.forEach(i=>{i.templateModel=i.templateId===i.privateLeagueModel.templateId?i.privateLeagueModel.templateModel:i.privateLeagueModel.pastTemplates.find(r=>r.id===i.templateId).model});return}t.forEach(i=>{i.templateModel=i.templateId===i.challengeModel.templateId?i.challengeModel.templateModel:i.challengeModel.pastTemplates.find(r=>r.id===i.templateId).model})};setProfileModel=async t=>{let e=await this.profile.getById(t.profileId).getInfo();t.profileModel=e};setModelsForPredictions=async t=>{if(t.data.length){let e=t.data.map(s=>s.profileId),i=t.data.map(s=>s.predictionId),r=await this.getProfileModels(e),a=await this.getPredictionModels(i);t.data.forEach(s=>{s.profileModel=r.find(l=>l.id===s.profileId),s.predictionModel=a.find(l=>l.id===s.predictionId)})}return t};getProfileModels=async t=>await this.profile.getByIds(t);getPredictionModels=async t=>await this.predictor.getPredictionsByIds(t)};var zs=class{factory=null;privateLeagueHttps=null;loyaltyHttps=null;profile=null;service=null;discussionsService=null;constructor(t){this.factory=new Ze,this.privateLeagueHttps=new Xe(t),this.loyaltyHttps=new Et(t),this.profile=new O(t),this.service=new ri(t),this.discussionsService=new At(t)}create=async t=>{let e=this.factory.createRequestBodyFromParam(t,"PRIVATE"),i=await this.privateLeagueHttps.create(e,"PRIVATE_LEAGUE");return await this.service.setTemplateModels(i),i};getById=async(t,e)=>{let i=await this.privateLeagueHttps.getById(t,"PRIVATE_LEAGUE",e);return await this.service.setTemplateModels(i),i};getMyLeagues=async t=>{t=new $s(t);let e=await this.privateLeagueHttps.getMyLeagues(t,"PRIVATE_LEAGUE");return await this.service.setTemplateModelsInLeagues(e),e};update=async(t,e)=>{let i=this.factory.createUpdateRequestBodyFromParam(e,"PRIVATE"),r=await this.privateLeagueHttps.update(t,i,"PRIVATE_LEAGUE");return await this.service.setTemplateModels(r),r};updateTemplate=async(t,e,i)=>{let r=await this.privateLeagueHttps.updateLeagueTemplate(t,e,i,"PRIVATE_LEAGUE");return await this.service.setTemplateModels(r),r};delete=async t=>await this.privateLeagueHttps.delete(t,"PRIVATE_LEAGUE");invite=async(t,e)=>await this.privateLeagueHttps.invite(t,e);deleteInvitation=async(t,e)=>await this.privateLeagueHttps.deleteInvitation(t,e);accept=async t=>{let i=await this.privateLeagueHttps.accept(t,!0,"PRIVATE_LEAGUE");return await this.finalizeAcceptModel(i,!0)};reject=async t=>{let i=await this.privateLeagueHttps.accept(t,!1,"PRIVATE_LEAGUE");return await this.finalizeAcceptModel(i,!1)};banUsers=async(t,e)=>await this.privateLeagueHttps.ban(t,e);unbanUsers=async(t,e)=>await this.privateLeagueHttps.unban(t,e);join=async t=>{let e=await this.privateLeagueHttps.join(t);return await this.finalizeAcceptModel(e,!0)};leave=async t=>await this.privateLeagueHttps.leave(t,"PRIVATE_LEAGUE");finalizeAcceptModel=async(t,e)=>{if(e){let i=await this.getById(t.leagueId);t.leagueModel=i}return await this.service.setProfileModel(t),t};getMyLeaguesStandings=async t=>{t&&(t=new Ws(t));let e=await this.profile.getOwn().getInfo(),i=await this.loyaltyHttps.getUserRankingsForPrivateLeagueAndChallenges(e.id,"PRIVATE_LEAGUE",t);for(let r of i.data){let a=await this.getById(r.privateLeagueId);r.privateLeagueModel=a}return this.service.setTemplateModelsFromLeagueModels(i.data,"PRIVATE_LEAGUE"),i};getInvitations=async t=>{t=new ti(t),t.type="PRIVATE";let e=await this.privateLeagueHttps.getInvitations("PRIVATE_LEAGUE",t);return await this.service.setTemplateModelsInLeagues(e.data),e};getReportedPosts=async(t,e)=>{e&&(e=new ei(e));let i=await this.privateLeagueHttps.getReportedPosts(t,e);return i.data=await this.discussionsService.finalizePostFullModel(i.data),i};getPredictions=async(t,e)=>{if(e){if(e.limit&&e.limit>20)throw new m(400,"invalid_limit","Invalid limit filter. The maximum limit is 20");e=new ii(e)}let i=await this.privateLeagueHttps.getPredictions(t,e);return await this.service.setModelsForPredictions(i)};moderatePost=async(t,e)=>await this.privateLeagueHttps.moderatePost(t,e)};var qs=class{privateLeaguesFacade=null;constructor(t){this.privateLeaguesFacade=new zs(t)}create=async t=>await this.privateLeaguesFacade.create(t);update=async(t,e)=>await this.privateLeaguesFacade.update(t,e);updateTemplate=async(t,e,i)=>await this.privateLeaguesFacade.updateTemplate(t,e,i);delete=async t=>await this.privateLeaguesFacade.delete(t);getById=async(t,e)=>await this.privateLeaguesFacade.getById(t,e);getMyLeagues=async t=>await this.privateLeaguesFacade.getMyLeagues(t);invite=async(t,e)=>await this.privateLeaguesFacade.invite(t,e);deleteInvitation=async(t,e)=>await this.privateLeaguesFacade.deleteInvitation(t,e);accept=async t=>await this.privateLeaguesFacade.accept(t);reject=async t=>await this.privateLeaguesFacade.reject(t);banUsers=async(t,e)=>await this.privateLeaguesFacade.banUsers(t,e);unbanUsers=async(t,e)=>await this.privateLeaguesFacade.unbanUsers(t,e);join=async t=>await this.privateLeaguesFacade.join(t);leave=async t=>await this.privateLeaguesFacade.leave(t);getMyLeaguesStandings=async t=>await this.privateLeaguesFacade.getMyLeaguesStandings(t);getInvitations=async t=>await this.privateLeaguesFacade.getInvitations(t);getReportedPosts=async(t,e)=>await this.privateLeaguesFacade.getReportedPosts(t,e);getPredictions=async(t,e)=>await this.privateLeaguesFacade.getPredictions(t,e);moderatePost=async(t,e)=>await this.privateLeaguesFacade.moderatePost(t,e)};var Qs=class{limit=null;page=null;challengeId=null;templateId=null;sortOrder=null;constructor(t){this.limit=t&&t.limit?t.limit:null,this.page=t&&t.page?t.page:null,this.challengeId=t&&t.challengeId?t.challengeId:null,this.templateId=t&&t.templateId?t.templateId:null,this.sortOrder=t&&t.sortOrder?t.sortOrder:null}constructFiltersUrl=()=>{let t="";return this.limit&&(t+=`&limit=${this.limit}`),this.page&&(t+=`&page=${this.page}`),this.challengeId&&(t+=`&league_id=${this.challengeId}`),this.templateId&&(t+=`&template_id=${this.templateId}`),this.sortOrder&&(t+=`&sort_order=${this.sortOrder}`),t}};var Ks=class{type="ONE_VS_ONE";userRole=null;constructor(t){this.userRole=t?.userRole||null}constructFiltersUrl=()=>{let t=`&type=${this.type}`;return this.userRole&&(t+=`&user_role=${this.userRole}`),t}};var js=class{factory=null;https=null;loyaltyHttps=null;profile=null;service=null;discussionsService=null;constructor(t){this.factory=new Ze,this.https=new Xe(t),this.service=new ri(t),this.loyaltyHttps=new Et(t),this.profile=new O(t),this.discussionsService=new At(t)}issue=async(t,e)=>{let i=this.factory.createRequestBodyFromParam(t,"ONE_VS_ONE"),r=await this.https.create(i,"CHALLENGE");await this.service.setTemplateModels(r);let a=await this.https.invite(r.id,[e]);return r.invites=[],r.invites.push(a[0]),r};update=async(t,e)=>{let i=this.factory.createUpdateRequestBodyFromParam(e,"ONE_VS_ONE"),r=await this.https.update(t,i,"CHALLENGE");return await this.service.setTemplateModels(r),r};updateTemplate=async(t,e,i)=>{let r=await this.https.updateLeagueTemplate(t,e,i,"CHALLENGE");return await this.service.setTemplateModels(r),r};delete=async t=>await this.https.delete(t,"CHALLENGE");getById=async(t,e)=>{let i=await this.https.getById(t,"CHALLENGE",e);return await this.service.setTemplateModels(i),i};getMyChallenges=async t=>{t=new Ks(t);let e=await this.https.getMyLeagues(t,"CHALLENGE");return await this.service.setTemplateModelsInLeagues(e),e};accept=async t=>{let i=await this.https.accept(t,!0,"CHALLENGE");return await this.finalizeAcceptModel(i,!0)};reject=async t=>{let i=await this.https.accept(t,!1,"CHALLENGE");return await this.finalizeAcceptModel(i,!1)};leave=async t=>await this.https.leave(t,"CHALLENGE");finalizeAcceptModel=async(t,e)=>{if(e){let i=await this.getById(t.challengeId);t.challengeModel=i}return await this.service.setProfileModel(t),t};getMyChallengesStandings=async t=>{t&&(t=new Qs(t));let e=await this.profile.getOwn().getInfo(),i=await this.loyaltyHttps.getUserRankingsForPrivateLeagueAndChallenges(e.id,"CHALLENGE",t);for(let r of i.data){let a=await this.getById(r.challengeId);r.challengeModel=a}return this.service.setTemplateModelsFromLeagueModels(i.data,"CHALLENGE"),i};getInvitations=async t=>{t=new ti(t),t.type="ONE_VS_ONE";let e=await this.https.getInvitations("CHALLENGE",t);return await this.service.setTemplateModelsInLeagues(e.data),e};getReportedPosts=async(t,e)=>{e&&(e=new ei(e));let i=await this.https.getReportedPosts(t,e);return i.data=await this.discussionsService.finalizePostFullModel(i.data),i};getPredictions=async(t,e)=>{if(e){if(e.limit&&e.limit>20)throw new m(400,"invalid_limit","Invalid limit filter. The maximum limit is 20");e=new ii(e)}let i=await this.https.getPredictions(t,e);return await this.service.setModelsForPredictions(i)};moderatePost=async(t,e)=>await this.https.moderatePost(t,e)};var Xs=class{facade=null;constructor(t){this.facade=new js(t)}issue=async(t,e)=>await this.facade.issue(t,e);update=async(t,e)=>await this.facade.update(t,e);updateTemplate=async(t,e,i)=>await this.facade.updateTemplate(t,e,i);delete=async t=>await this.facade.delete(t);getById=async(t,e)=>await this.facade.getById(t,e);getMyChallenges=async t=>await this.facade.getMyChallenges(t);accept=async t=>await this.facade.accept(t);reject=async t=>await this.facade.reject(t);leave=async t=>await this.facade.leave(t);getMyChallengesStandings=async t=>await this.facade.getMyChallengesStandings(t);getInvitations=async t=>await this.facade.getInvitations(t);getReportedPosts=async(t,e)=>await this.facade.getReportedPosts(t,e);getPredictions=async(t,e)=>await this.facade.getPredictions(t,e);moderatePost=async(t,e)=>await this.facade.moderatePost(t,e)};var Ys=class{KEY_PREFIX="fu-progress-";get=(t,e)=>{let i=localStorage.getItem(`${this.KEY_PREFIX}${t}-${e}`);return i&&JSON.parse(i)};set=(t,e,i)=>(localStorage.setItem(`${this.KEY_PREFIX}${t}-${e}`,JSON.stringify(i)),JSON.stringify(i));delete=(t,e)=>{localStorage.removeItem(`${this.KEY_PREFIX}${t}-${e}`)}};var Js=class{id=null;source=null;type=null};var ai=class{id=null;title=null;description=null;type=null;images=new it;status=null;totalVotes=null;flags=[];customFields=null;branding=null;embedCode=null;labels=null;adContent=null;context=null;options=[];createdAt=null;updatedAt=null};var Zs=class extends ai{rules=null};var oi=class{id=null;pollId=null;optionId=null;userId=null};var tn=class extends oi{pollModel=null;optionModel=null};var en=class{meta=new x;data=[]};var rn=class{meta=new x;data=[]};var an=class extends rt{remapPolls=t=>{let e=new en;return e.meta.pagination=this.remapMetaPagination(t.meta.pagination),e.data=t.data.map(i=>this.remapPoll(i)),e};remapPollById=t=>{let e=new Zs;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.images=t.images,e.status=t.status,e.flags=t.flags,e.totalVotes=t.total_votes,e.customFields=t.custom_fields,e.branding=t.branding?this.remapBranding(t.branding):null,e.embedCode=t.embed_code,e.labels=t.labels,e.rules=t.rules,e.adContent=t.ad_content,e.options=t.options,e.context=t.context?this.remapContext(t.context):t.context,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapUserVote=t=>{let e=new oi;return e.id=t.id,e.pollId=t.poll_id,e.optionId=t.option_id,e.userId=t.user_id,e};remapPollsVotes=t=>{let e=new rn;return e.meta.pagination=this.remapMetaPagination(t.meta.pagination),e.data=t.data.map(i=>this.remapPollVote(i)),e};remapPollVote=t=>{let e=new tn;return e.id=t.id,e.pollId=t.poll_id,e.optionId=t.option_id,e.userId=t.user_id,e};remapMetaPagination=t=>{let e=new nt;return e.itemsPerPage=t.items_per_page,e.nextPageStartsAfter=t.next_page_starts_after,e};remapPoll=t=>{let e=new ai;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.images=t.images,e.status=t.status,e.flags=t.flags,e.totalVotes=t.total_votes,e.customFields=t.custom_fields,e.branding=t.branding?this.remapBranding(t.branding):null,e.embedCode=t.embed_code,e.labels=t.labels,e.adContent=t.ad_content,e.options=t.options,e.context=t.context?this.remapContext(t.context):t.context,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapContext=t=>{let e=new _t;return e.content=t.content,e.tags=t.tags?t.tags.map(i=>{let r=new Js;return r.id=i.id,r.type=i.type,r.source=i.source,r}):null,e.campaign=t.campaign,e}};var on=class extends T{pollRemapper=null;constructor(t){super(t,S(t.environment,"voting")),this.pollRemapper=new an}getPolls=async(t,e)=>{let i=`/polls${this.apiSignInUrl}`;t&&(i+=t.constructMainFiltersUrl()),w(e)&&(i+=h());let r="There was a problem fetching polls",a=await this.fetchWithoutAuth(i,r);return this.pollRemapper.remapPolls(a)};getPollById=async(t,e)=>{let i=`/polls/${t}${this.apiSignInUrl}`;w(e)&&(i+=h());let r="There was a problem fetching the following poll: "+t,a=await this.fetchWithoutAuth(i,r);return this.pollRemapper.remapPollById(a.data)};voteForPoll=async(t,e)=>{let i=`/polls/${t}/votes${this.apiSignInUrl}`,r="PUT",a={option_id:e},s="There was a problem voting for the following poll: "+t,l=await this.fetchWithAuth(i,s,r,a);return this.pollRemapper.remapUserVote(l.data)};deleteVoteForPoll=async t=>{let e=`/polls/${t}/votes${this.apiSignInUrl}`,i="DELETE",r="There was a problem deleting vote for the following poll: "+t;return await this.fetchWithAuth(e,r,i),!0};getMyPollVote=async t=>{let e=`/polls/${t}/votes${this.apiSignInUrl}`,i="There was a problem fetching user's own vote for the following poll: "+t,r=await this.fetchWithAuth(e,i);return this.pollRemapper.remapPollVote(r.data)};getMyPollsVotes=async t=>{let e=`/polls/votes${this.apiSignInUrl}`;t&&(e+=t.constructMainFiltersUrl());let i="There was a problem fetching user's votes for polls",r=await this.fetchWithAuth(e,i);return this.pollRemapper.remapPollsVotes(r)}};var si=class extends v{flags=null;status=null;entityIds=null;entityType=null;pollIds=null;sortOrder=null;minVotes=null;constructor(t){super(t),this.flags=t?.flags||null,this.status=t?.status||null,this.entityIds=t?.entityIds||null,this.entityType=t?.entityType||null,this.pollIds=t?.pollIds||null,this.sortOrder=t?.sortOrder||null,this.minVotes=t&&t.minVotes!==void 0?t.minVotes:null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.flags&&this.flags.length>0&&(t+=`&flags=${this.flags.join(",")}`),this.status&&(t+=`&status=${this.status}`),this.entityIds&&this.entityIds.length>0&&(t+=`&entity_ids=${this.entityIds.join(",")}`),this.pollIds&&this.pollIds.length>0&&(t+=`&poll_ids=${this.pollIds.join(",")}`),this.sortOrder&&(t+=`&sort_order=${this.sortOrder}`),this.minVotes&&(t+=`&min_votes=${this.minVotes}`),t}};var sn=class{idMappingService=null;idSchema=null;errorHandlingMode=null;validator=null;activityService=null;constructor(t){this.idSchema=t.idSchema,this.errorHandlingMode=t.errorHandlingMode,this.idMappingService=new P(t),this.validator=new St(t),this.activityService=new gt(t)}finalizePollsFilters=async t=>{if(this.idSchema!=="native"&&t.entityIds&&t.entityIds.length>0){this.validator.validateFilters(t);let e=await this.idMappingService.getEntityIdsBySchemaId(Array.from(t.entityIds),t.entityType,"native");t.entityIds=e[t.entityType]}};remapTags=async(t,e,i)=>{if(this.idSchema!="native"&&t.context&&t.context.tags&&t.context.tags.length){let r=JSON.parse(JSON.stringify(t.context.tags)),a=await this.activityService.remapTagsIds(r,e,i);t.context.tags=a}}};var nn=class{https=null;service=null;idSchema=null;constructor(t){this.idSchema=t.idSchema,this.https=new on(t),this.service=new sn(t)}getPolls=async(t,e)=>{t&&(t=new si(t),await this.service.finalizePollsFilters(t));let i=await this.https.getPolls(t,e);for(let r of i.data)await this.service.remapTags(r,"native",this.idSchema);return i};getPollById=async(t,e)=>{let i=await this.https.getPollById(t,e);return await this.service.remapTags(i,"native",this.idSchema),i};voteForPoll=async(t,e)=>await this.https.voteForPoll(t,e);deleteVoteForPoll=async t=>await this.https.deleteVoteForPoll(t);getMyPollVote=async(t,e)=>{let i=await this.https.getMyPollVote(t);if(e){let r=await this.getPolls(new si({pollIds:[t]}),!0);i.pollModel=r.data.find(a=>a.id===t)||null,i.optionModel=r.data.find(a=>a.id===t)?.options.find(a=>a.id===i.optionId)||null}return i};getMyPollsVotes=async t=>{t&&(t=new v(t));let e=await this.https.getMyPollsVotes(t),i=e.data.map(a=>a.id),r=await this.getPolls(new si({pollIds:i}),!0);return e.data=e.data.map(a=>(a.pollModel=r.data.find(s=>s.id===a.pollId)||null,a.optionModel=a.pollModel?.options.find(s=>s.id===a.optionId)||null,a)),e}};var ln=class{facade=null;constructor(t){this.facade=new nn(t)}getPolls=async(t,e)=>await this.facade.getPolls(t,e);getPollById=async(t,e)=>await this.facade.getPollById(t,e);voteForPoll=async(t,e)=>await this.facade.voteForPoll(t,e);deleteVoteForPoll=async t=>await this.facade.deleteVoteForPoll(t);getMyPollVote=async(t,e)=>await this.facade.getMyPollVote(t,e);getMyPollsVotes=async t=>await this.facade.getMyPollsVotes(t)};var pn=class{key=null;label=null;value=null};var ql=["minutesPlayed","cleanSheets","concededGoals","saves","penaltySaved","penaltyCommitted","yellowCards","redCards","assists","foulsCommitted","ownGoals","goals","tackles","shotsOn"],Ql=new Map().set("minutesPlayed","Minutes Played").set("cleanSheets","Clean Sheets").set("concededGoals","Goals Conceded").set("saves","Saves").set("penaltySaved","Penalties Saved").set("penaltyCommitted","Penalties Committed").set("yellowCards","Yellow Cards").set("redCards","Red Cards").set("assists","Assists").set("foulsCommitted","Fouls Committed").set("ownGoals","Own Goals").set("goals","Goals").set("tackles","Tackles").set("shotsOn","Shots On Target"),ni=class{static createFantasyPrediction(t,e,i){let r=new ve;return r.template_id=t||null,r.group_id=e||null,r.fixtures=i?.map(a=>({player_id:a,match_type:"FOOTBALL",market:"PLAYER_PERFORMANCE"}))||[],r}static createFantasyPlayerStats(t){return ql.map(e=>{let i=new pn,r=t.data.reduce((a,s)=>a+s.stats[e],0);return i.key=e,i.label=Ql.get(e),i.value=r,i})}};var cn=class{idMapping=null;idSchema=null;errorHandlingModel=null;football=null;constructor(t){this.idSchema=t.idSchema,this.errorHandlingModel=t.errorHandlingMode,this.football=new J(t),this.idMapping=new P(t)}remapCompetitions=async t=>{let e={competition:t};return(await this.idMapping.idMappingFacade.getEntitiesByIds(e,"native",this.idSchema)).competition};remapPlayers=async(t,e,i)=>{let r={player:Array.from(t)};return(await this.idMapping.idMappingFacade.getEntitiesByIds(r,e,i)).player};addPlayerModels=async t=>{let e=t.map(r=>r.playerId),i=await this.football.footballFacade.getPlayersMapWithNativeIds(e);return t.forEach(r=>{r.playerModel=Object.keys(i).length&&i[r.playerId]||null,r.playerId=r.playerModel?.id||r.playerId}),t};remapPlayerIdToNative=async t=>{let e=await this.idMapping.getEntityIdBySchemaId("player",t);if(e)return e.id;this.throwException(404,"id_mapping_not_found","No ID mappings are available for the provided ID. ID argument: "+t)};addMatchModels=async t=>{let e=t.map(r=>r.matchId),i=await this.football.footballFacade.getMatchesMapWithNativeIds(e);return t.forEach(r=>{r.matchModel=Object.keys(i).length&&i[r.matchId]||null,r.matchId=r.matchModel?.id||r.matchId}),t};throwException=(t,e,i)=>{throw this.errorHandlingModel==="standard"?new m(t,e,i):new f(t,e,i)}};var un=class{idSchema=null;clientHttps=null;footballHttps=null;predictorHttps=null;idMappingService=null;service=null;constructor(t){this.idSchema=t.idSchema,this.clientHttps=new N(t),this.footballHttps=new X(t),this.service=new cn(t),this.idMappingService=new P(t),this.predictorHttps=new at(t,this.idMappingService)}getConfig=async()=>{let t=await this.clientHttps.getConfig("fantasy");return this.idSchema!=="native"&&(t.competitionsWhitelist=await this.service.remapCompetitions([...t.competitionsWhitelist])),t};getPlayersPoints=async(t,e,i)=>{let r=await this.footballHttps.getPlayersPoints(t,e,i);return r.data=await this.service.addPlayerModels(r.data),r};getPlayerDetailedStatistics=async(t,e,i)=>{let r="";this.idSchema!=="native"&&(r=await this.service.remapPlayerIdToNative(e));let a=await this.footballHttps.getPlayerDetailedStatistics(t,r||e,i);return a.meta.filters.playerId=e,a.data=await this.service.addMatchModels(a.data),a};play=async(t,e,i)=>{(!i||!Array.isArray(i))&&this.service.throwException(400,"invalid_method_call","Invalid parameter provided. Please check the following parameter: "+"playerIds");let r=null;if(this.idSchema!=="native"){let a=await this.service.remapPlayers(i,this.idSchema,"native");r=ni.createFantasyPrediction(t,e,a)}else r=ni.createFantasyPrediction(t,e,i);return await this.predictorHttps.makeFootballPrediction(r)};getMyPrediction=async(t,e)=>{let i=`${t}_${e}`,r=new L(null);r.gameIds=[i];let a=await this.predictorHttps.getMyPredictions(r);return a.data.length===0?null:a.data[0]};getPlayerStatistics=async(t,e,i)=>{let r=await this.getPlayerDetailedStatistics(t,e,i);return ni.createFantasyPlayerStats(r)}};var dn=class{facade=null;constructor(t){this.facade=new un(t)}getConfig=async()=>await this.facade.getConfig();getPlayersPoints=async(t,e,i)=>await this.facade.getPlayersPoints(t,e,i);getPlayerDetailedStatistics=async(t,e,i)=>await this.facade.getPlayerDetailedStatistics(t,e,i);play=async(t,e,i)=>await this.facade.play(t,e,i);getMyPrediction=async(t,e)=>await this.facade.getMyPrediction(t,e);getPlayerStatistics=async(t,e,i)=>await this.facade.getPlayerStatistics(t,e,i)};var An=null,$n=null;function JA(o){if(Kl(o)){let t=jl(o);if(t.isValid)return An={profile:new O(o),football:new J(o),predictor:new Re(o),loyalty:new ze(o),topX:new We(o),matchQuiz:new Le(o),activity:new ys(o),miniGames:new He(o),discussions:new Ls(o),privateLeagues:new qs(o),challenges:new Xs(o),progress:new Ys,voting:new ln(o),fantasy:new dn(o)},$n={...o},An;Xl(t)}return An}var Kl=o=>!An||JSON.stringify(o)!==JSON.stringify($n)||o.authProvider.getIdToken()!==$n.authProvider.getIdToken(),jl=o=>{let e=new Aa().validate(o);return(e.idSchema.validation==="missing"||e.idSchema.validation==="invalid")&&(console.warn(e.idSchema.message.text),o.idSchema="native"),(e.environment.validation==="missing"||e.environment.validation==="invalid")&&(console.warn(e.environment.message.text),o.environment="prod"),(e.lang.validation==="missing"||e.lang.validation==="invalid")&&(console.warn(e.lang.message.text),o.lang="en"),(e.errorHandlingMode.validation==="missing"||e.errorHandlingMode.validation==="invalid")&&(console.warn(e.errorHandlingMode.message.text),o.errorHandlingMode="default"),e.authProvider.validation==="invalid"&&console.warn(e.authProvider.message.text),e},Xl=o=>{let t="authProvider",e="isValid";Object.keys(o).forEach(i=>{let r=o[i];if(i!==e&&i!==t){if(r.message.type==="error")throw new Error(r.message.text)}else i!==e&&i===t&&Object.keys(new kt).forEach(a=>{if(r[a].message.type==="error")throw new Error(r[a].message.text)})})};export{JA as FansUnitedSDK};
|
|
3
|
+
${Bn.PREDICTOR_USER_RELATED_OPERATION}`},Xn=(o,t)=>`The prediction '${o}' is invalid for market '${t}'. 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`,Mn=o=>`The market '${o}' is not supported from Fans United. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,Yn=o=>`The market '${o}' is not valid for Top X game. The only available market is CORRECT_SCORE.`,Jn=o=>`The field/s '${o.length>1?o.join(", "):o[0]}' is/are invalid. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/javascript-sdk`,Zn=(o,t)=>`The following field/s is/are missing from ${o}: '${t.length>1?t.join(", "):t[0]}'. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,tl=(o,t)=>`The field ${o} has incorrect type. The correct type is ${t}`;var xt=class{data={error:{code:0,status:"",message:""}};status=0;statusText="";headers=null;constructor(t,e){this.data.error.code=e.code,this.data.error.status=e.status,this.data.error.message=e.message,this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}errorMessage=()=>this.data.error.message};var m=class{error={code:0,status:"",message:""};constructor(t,e,i){this.error.code=t,this.error.status=e,this.error.message=i}};var T=class{baseUrl=null;apiSignInUrl=null;jwtToken=null;idSchema=null;retryRequest=!1;headers=null;authHeaders=null;errorHandlingMode=null;configuration=null;constructor(t,e){this.baseUrl=e,this.configuration=t,this.apiSignInUrl=`?key=${t.apiKey}&client_id=${t.clientId}`,this.errorHandlingMode=t.errorHandlingMode,this.idSchema=t.idSchema,this.headers={"Content-Type":"application/json"}}getJwtToken=()=>this.configuration.authProvider.getIdToken();getAuthHeaders=()=>({"Content-Type":"application/json",Authorization:`Bearer ${this.getJwtToken()}`});fetchWithoutAuth=async(t,e)=>{let i=await fetch(this.baseUrl+t,{headers:this.headers}),r=await i.json();if(!i.ok){let a=this.transformFetchException(i,r);throw console.warn(e,a),a}return r};fetchWithoutAuthAdditionalHeaders=async(t,e,i)=>{let r=await fetch(this.baseUrl+t,{headers:{...this.headers,...i}}),a=await r.json();if(!r.ok){let s=this.transformFetchException(r,a);throw console.warn(e,s),s}return a};fetchWithAuth=async(t,e,i,r)=>{this.validateJWTToken();let a=null,s=null;if(i&&r?a=await fetch(this.baseUrl+t,{method:i,headers:this.getAuthHeaders(),body:JSON.stringify(r)}):i&&!r?a=await fetch(this.baseUrl+t,{method:i,headers:this.getAuthHeaders()}):a=await fetch(this.baseUrl+t,{headers:this.getAuthHeaders()}),i!=="DELETE"&&(s=await a.json()),!a.ok){(a.status===401||a.status===403)&&!this.retryRequest&&(this.retryRequest=!0,await this.fetchWithAuth(t,e,i,r)),this.retryRequest=!1;let l=this.transformFetchException(a,s||await a.json());throw console.warn(e,l),l}return this.retryRequest=!1,s};fetchWithAuthNewBaseURL=async(t,e,i,r,a)=>{this.validateJWTToken();let s=null,l=null;if(r&&a?s=await fetch(t+e,{method:r,headers:this.getAuthHeaders(),body:JSON.stringify(a)}):r&&!a?s=await fetch(t+e,{method:r,headers:this.getAuthHeaders()}):s=await fetch(t+e,{headers:this.getAuthHeaders()}),r!=="DELETE"&&(l=await s.json()),!s.ok){(s.status===401||s.status===403)&&!this.retryRequest&&(this.retryRequest=!0,await this.fetchWithAuthNewBaseURL(t,e,i,r,a)),this.retryRequest=!1;let n=this.transformFetchException(s,l||await s.json());throw console.warn(i,n),n}return this.retryRequest=!1,l};transformFetchException=(t,e)=>{if(!e&&t.status===401){if(this.errorHandlingMode==="standard")return new m(401,"unauthorized","Invalid JWT token is provided");let s={code:401,status:"unauthorized",message:"Invalid JWT token is provided"};return new xt(t,s)}let{code:i,status:r,message:a}=e.error;return this.errorHandlingMode==="standard"?new m(i,r,a):new xt(t,e.error)};validateJWTToken=()=>{let t=null;try{t=bn(this.getJwtToken())}catch(i){if(this.errorHandlingMode==="default"){let r={status:401,statusText:i.message,headers:{}},a={code:401,status:"invalid_token",message:"Invalid JWT token is provided"};throw new xt(r,a)}else if(this.errorHandlingMode==="standard")throw new m(401,"invalid_token","Invalid JWT token is provided")}if(Date.now()>t.exp*1e3){if(this.errorHandlingMode==="default"){let i={status:401,statusText:"",headers:{}},r={code:401,status:"invalid_token",message:"The provided JWT token is expired"};throw new xt(i,r)}else if(this.errorHandlingMode==="standard")throw new m(401,"invalid_token","The provided JWT token is expired")}}};var xl="/countries",z="/profile",wn="/profiles",Wt=class extends T{profileRemapper=null;followingRemapper=null;followersRemapper=null;lang=null;limitIds=100;constructor(t){super(t,S(t.environment,"profile")),this.lang=t.lang,this.profileRemapper=new Ri,this.followingRemapper=new Ai,this.followersRemapper=new Li}getCountries=async t=>{let e=`&lang=${this.lang}`,i=`${xl}${this.apiSignInUrl}${e}`,r=Date.now(),a="There was a problem fetching profile countries";return t&&(i+=`&disable_cache=${r}`),(await this.fetchWithoutAuth(i,a)).data};getProfile=async t=>{let e=`${z}${this.apiSignInUrl}`,i="";if(t){e=`${wn}/${t}${this.apiSignInUrl}`,i=`There was a problem fetching the following profile: ${t}`;let r=await this.fetchWithoutAuth(e,i);return this.profileRemapper.fullProfileFromResponse(r.data)}else{i="There was a problem fetching your profile from API";let r=await this.fetchWithAuth(e,i);return this.profileRemapper.fullProfileFromResponse(r.data)}};getProfiles=async(t,e,i)=>{let r=Date.now(),a=`There was a problem fetching the following profiles: ${t.join(",")}`;if(t&&t.length){if(t.length>this.limitIds){let c=[],u=$t(t,this.limitIds);for(let d of u){let M=`${wn}${this.apiSignInUrl}&profile_ids=${d.join(",")}`;a=`There was a problem fetching the following profiles: ${d.join(",")}`,i&&(M+=`&disable_cache=${r}`);let g=await this.fetchWithoutAuth(M,a);c.push(...this.profileRemapper.profilesFromResponse(g.data))}return c}let n=`${wn}${this.apiSignInUrl}&profile_ids=${t.join(",")}`;i&&(n+=`&disable_cache=${r}`);let p=await this.fetchWithoutAuth(n,a);return this.profileRemapper.profilesFromResponse(p.data)}let s=`${wn}${this.apiSignInUrl}&search=${e}`;i&&(s+=`&disable_cache=${r}`);let l=await this.fetchWithoutAuth(s,a);return this.profileRemapper.profilesFromResponse(l.data)};getFollowers=async(t,e)=>{let i=`${z}/followers${this.apiSignInUrl}`,r="There was a problem fetching the followers for own profile";if(t&&!e){i=`${z}/followers${this.apiSignInUrl}${t.constructFilterUrl()}`;let s=await this.fetchWithAuth(i,r);return this.followersRemapper.followersFromResponse(s)}else if(!t&&!e){let s=await this.fetchWithAuth(i,r);return this.followersRemapper.followersFromResponse(s)}t&&e?i=`${z}/${e}/followers${this.apiSignInUrl}${t.constructFilterUrl()}`:!t&&e&&(i=`${z}/${e}/followers${this.apiSignInUrl}`),r=`There was a problem fetching the followers for profile: ${e}`;let a=await this.fetchWithoutAuth(i,r);return this.followersRemapper.followersFromResponse(a)};getFollowing=async(t,e)=>{let i=`${z}/following${this.apiSignInUrl}`,r="There was a problem fetching the followers of own profile";if(t&&!e){i=`${z}/following${this.apiSignInUrl}${t.constructFilterUrl()}`;let s=await this.fetchWithAuth(i,r);return this.followingRemapper.followingFromResponse(s)}else if(!t&&!e){let s=await this.fetchWithAuth(i,r);return this.followingRemapper.followingFromResponse(s)}t&&e?i=`${z}/${e}/following${this.apiSignInUrl}${t.constructFilterUrl()}`:!t&&e&&(i=`${z}/${e}/following${this.apiSignInUrl}`),r=`There was a problem fetching the followers of the following profile: ${e}`;let a=await this.fetchWithoutAuth(i,r);return this.followingRemapper.followingFromResponse(a)};follow=async t=>{let e=new pi;e.profile_ids=t;let i=z+`/follow${this.apiSignInUrl}`,r=`There was a problem with following profiles: ${t.join(",")}`,a="POST",s=await this.fetchWithAuth(i,r,a,e);return this.followingRemapper.followResponse(s.data)};unfollow=async t=>{let e=new pi;e.profile_ids=t;let i=z+`/follow${this.apiSignInUrl}`,r=`There was a problem with unfollowing profiles: ${t.join(",")}`,a="DELETE";return await this.fetchWithAuth(i,r,a,e),!0};getBadges=async t=>{let e=`${z}/badges${this.apiSignInUrl}`,i="There was a problem with fetching own badges";return t?(e=`${z}/${t}/badges${this.apiSignInUrl}`,i="There was a problem with fetching the badges",(await this.fetchWithoutAuth(e,i)).data):(await this.fetchWithAuth(e,i)).data};updateProfile=async t=>{let e=z+this.apiSignInUrl,i="There was a problem updating the own profile",r="PATCH",a=await this.fetchWithAuth(e,i,r,t);return this.profileRemapper.fullProfileFromResponse(a.data)}};var C=(a=>(a.NATIVE="native",a.ENETPULSE="enetpulse",a.SPORTRADAR="sportradar",a.SPORTAL_365="sportal365",a.API_FOOTBALL="api_football",a))(C||{});var xi={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},Di=class extends T{constructor(t){super(t,S(t.environment,"idMapping"))}getEntityById=async(t,e)=>{let i=`/football${this.apiSignInUrl}&input_provider=${this.idSchema}&${xi[t]}=${e}`,r=`There was a problem with id mapping request for the following id: ${e}`;return await this.fetchWithoutAuth(i,r)};getEntityByIdAndSchema=async(t,e,i)=>{let r=`/football${this.apiSignInUrl}&input_provider=${i}&${xi[t]}=${e}`,a=`There was a problem with id mapping request for the following id: ${e}`;return await this.fetchWithoutAuth(r,a)};getEntityIdsByIdsAndSchema=async(t,e,i)=>{let r=`/football${this.apiSignInUrl}&input_provider=${i}&${xi[t]}=${e.join(",")}`,a=`There was a problem with id mapping request for the following ids: ${e.join(",")}`;return await this.fetchWithoutAuth(r,a)};getEntitiesByIds=async(t,e,i)=>{e.sort((s,l)=>s.localeCompare(l));let r=xn(e),a=[];for(let s of r){let l=`/football${this.apiSignInUrl}&input_provider=${i}&${xi[t]}=${s.join(",")}`,n=`There was a problem with id mapping request for the following ids :${s.join(",")}`,p=await this.fetchWithoutAuth(l,n);a=[...a,...p.data]}return a};getEntitiesByIdObjs=async(t,e)=>{let i=[],r={},a=[];Object.keys(t).forEach(p=>{i.push.apply(i,t[p])});let s=Lt(i),l=xn(s);for(let p of l){let c="";if(Object.keys(t).forEach(u=>{r[u]=[];let d=p.filter(M=>t[u].includes(M));d&&d.length>0&&(r[u]=d)}),Object.keys(r).forEach(u=>{r[u].length>0&&(r[u].sort((d,M)=>d.localeCompare(M)),c+="&",c+=`${xi[u]}=${r[u].join(",")}`)}),c&&c.length>0){let u=`/football${this.apiSignInUrl}&input_provider=${e||"native"}${c}`,d="There was a problem with id mapping request",M=await this.fetchWithoutAuth(u,d);a.push(M.data)}else a.push([])}return Array.prototype.concat.apply([],a)};getTopEntities=async()=>{let t=`/football/top${this.apiSignInUrl}`,e="There was a problem with top id mappings request";return(await this.fetchWithoutAuth(t,e)).data}};var Un="FansUnited",Gn={football:{ids:[],countries:[],competitions:[],expirations:{ids:0}},profile:{info:{},statistics:{},badges:null,countries:[],expirations:{profile:0,statistics:0,badges:0}},client:{features:{},expirations:{features:0}}},ci=class{idSchema="";expirationProfileTimeout=600;expirationBadgesTimeout=3600;expirationClientFeaturesTimeout=14400;expirationFootballIdsTimeout=604800;constructor(t){this.idSchema=t}static getInstance(t){return ci.instance||(ci.instance=new ci(t)),ci.instance}clearData=()=>{this.setData(Gn)};getEntityById=(t="",e="")=>this.getData().football.ids.find(i=>{let r=D[this.idSchema];return i&&`${i[r]}`===e&&i.resource===t});getEntity=(t,e,i)=>Array.isArray(t)?this.getData().football.ids.filter(r=>{let a=D[i];return r&&t.includes(`${r[a]}`)&&r.resource===e}):this.getData().football.ids.find(r=>{let a=D[i];return r&&`${r[a]}`===t&&r.resource===e});getEntityByNativeId=(t="",e="")=>this.getData().football.ids.find(i=>i&&`${i.id}`===e&&i.resource===t);checkForExistingIdObjs=(t,e)=>{let i=D[e],r={};return Object.keys(t).forEach(a=>{let s=t[a],n=this.getEntity(s,a,e).map(c=>c[i]),p=t[a].filter(c=>!n.includes(c));r[a]=s.map(c=>p.includes(c)?{id:c,exists:!1}:{id:c,exists:!0})}),r};getIdsByType=(t,e,i)=>{let r=D[i],a=D[e],s={};return Object.keys(t).forEach(l=>{let n=t[l],p=[];this.getData().football.ids.forEach(c=>{n.forEach((u,d)=>{u===c[a]&&l===c.resource&&(p[d]=c[r])})}),s[l]=p}),s};addIdMapping=t=>{let e=this.getData();e.football.ids.push(t),this.setData(e)};addIdMappings=t=>{let e=this.getData(),i=e.football.ids;i=[...i,...t],e.football.ids=i,this.setData(e)};addTopIdMappings=t=>{let e=this.getData();if(e.football.ids.length){let i=JSON.parse(JSON.stringify(e.football.ids));i=i.filter(r=>r.resource!=="match"),t=t.filter(r=>r.resource==="match"),i=[...i,...t],e.football.ids=i}else e.football.ids=t;e.football.expirations.ids=Math.floor(Date.now()/1e3)+this.expirationFootballIdsTimeout,this.setData(e)};setOwnProfile=t=>{let e=this.getData();e.profile.info=t,e.profile.expirations.profile=Math.floor(Date.now()/1e3)+this.expirationProfileTimeout,this.setData(e)};getOwnProfile=()=>this.getData().profile.info;getProfileCountries=()=>this.getData().profile.countries;setProfileCountries=t=>{let e=this.getData();e.profile.countries=t,this.setData(e)};getProfileStats=()=>this.getData().profile.statistics;setProfileStats=t=>{let e=this.getData();e.profile.statistics=t,e.profile.expirations.statistics=Math.floor(Date.now()/1e3)+this.expirationProfileTimeout,this.setData(e)};getProfileBadges=()=>this.getData().profile.badges;setProfileBadges=t=>{let e=this.getData();e.profile.badges=t,e.profile.expirations.badges=Math.floor(Date.now()/1e3)+this.expirationBadgesTimeout,this.setData(e)};getFootballCountries=()=>this.getData().football.countries;setFootballCountries=t=>{let e=this.getData();e.football.countries=t,this.setData(e)};getCompetitions=t=>{let e=this.getData();return t?t.competitionSearchFilter(e.football.competitions):e.football.competitions};setCompetitions=t=>{let e=this.getData(),i=[...e.football.competitions];i.push(...t),e.football.competitions=this.makeCompetitionsUnique(i),this.setData(e)};getCompetitionsLength=()=>{let{football:t}=this.getData();return t.competitions.length};getClientFeatures=()=>this.getData().client.features;setClientFeatures=t=>{let e=this.getData(),i=JSON.parse(JSON.stringify(t));e.client.expirations.features=Math.floor(Date.now()/1e3)+this.expirationClientFeaturesTimeout,e.client.features=i,this.setData(e)};deleteClientFeatures=()=>{let t=this.getData(),e=JSON.parse(JSON.stringify(t));e.client={features:{},expirations:{features:0}},this.setData(e)};getExpiration=(t,e)=>{this.initialNewSchema(t,"expirations");let i=this.getData();switch(e){case"profile":return i.profile.expirations.profile;case"statistics":return i.profile.expirations.statistics;case"badges":return i.profile.expirations.badges;case"features":return i.client.expirations.features;case"ids":return i.football.expirations.ids}};makeCompetitionsUnique=t=>{let e=new Set;return t.filter(i=>{let r=!e.has(i.id);return e.add(i.id),r})};getData=()=>(localStorage.getItem(Un)||this.setData(Gn),JSON.parse(localStorage.getItem(Un)));setData=t=>{localStorage.setItem(Un,JSON.stringify(t))};initialNewSchema=(t,e)=>{let i=this.getData();(!i||!i[t]||!i[t][e])&&this.setData(Gn)}},ui=ci;ot(ui,"instance");var Ml=Al(bl());var I=class{profileTTL=600;clientTTL=14400;profileBadgesTTL=3600;idMappingsExpiration=0;idSchema="";constructor(t){}static getInstance(t){return I.instance||(I.instance=new I(t),I.nodeCache.options.useClones=!1),I.instance}clearData=()=>I.nodeCache.flushAll();getEntityById=(t,e)=>{let i=I.nodeCache.get("ids");return i?i.find(r=>{let a=D[this.idSchema];return r&&`${r[a]}`===e&&r.resource===t}):null};getEntity=(t,e,i)=>{let r=I.nodeCache.get("ids");return r?Array.isArray(t)?[]:null:Array.isArray(t)?r.filter(a=>{let s=D[i];return a&&t.includes(`${a[s]}`)&&a.resource===e}):r.find(a=>{let s=D[i];return a&&`${a[s]}`===t&&a.resource===e})};checkForExistingIdObjs=(t,e)=>{let i=D[e],r={};return Object.keys(t).forEach(a=>{let s=t[a],n=this.getEntity(s,a,e).map(c=>c[i]),p=t[a].filter(c=>!n.includes(c));r[a]=s.map(c=>p.includes(c)?{id:c,exists:!1}:{id:c,exists:!0})}),r};getIdsByType=(t,e,i)=>{let r=D[i],a=D[e],s=I.nodeCache.get("ids"),l={};return s?(Object.keys(t).forEach(n=>{let p=t[n],c=[];s.forEach(u=>{p.forEach((d,M)=>{d===u[a]&&n===u.resource&&(c[M]=u[r])})}),l[n]=c}),l):null};addIdMapping=t=>{let e=I.nodeCache.get("ids");e.push(t),I.nodeCache.set("ids",e)};addIdMappings=t=>{let e=I.nodeCache.get("ids");e=[...e,...t],I.nodeCache.set("ids",e)};addTopIdMappings=t=>{let e=I.nodeCache.get("ids"),i=604800;if(e){let r=JSON.parse(JSON.stringify(e));r=r.filter(a=>a.resource!=="match"),t=t.filter(a=>a.resource==="match"),r=[...r,...t],I.nodeCache.set("ids",r)}else I.nodeCache.set("ids",t);this.idMappingsExpiration=Math.floor(Date.now()/1e3)+i};setOwnProfile=t=>I.nodeCache.set("profile",t,this.profileTTL);getOwnProfile=()=>I.nodeCache.get("profile");getProfileCountries=()=>I.nodeCache.get("profile_countries");setProfileCountries=t=>I.nodeCache.set("profile_countries",t);getProfileStats=()=>I.nodeCache.get("profile_stats");setProfileStats=t=>I.nodeCache.set("profile_stats",t,this.profileTTL);getProfileBadges=()=>I.nodeCache.get("profile_badges");setProfileBadges=t=>{I.nodeCache.set("profile_badges",t,this.profileBadgesTTL)};getFootballCountries=()=>I.nodeCache.get("football_countries");setFootballCountries=t=>I.nodeCache.set("football_countries",t);getCompetitions=t=>{let e=I.nodeCache.get("football_competitions");return e?t?t.competitionSearchFilter(e):e:null};setCompetitions=t=>I.nodeCache.set("football_competitions",t);getCompetitionsLength=()=>{let t=I.nodeCache.get("football_competitions");return t?t.length:0};getClientFeatures=()=>I.nodeCache.get("client");setClientFeatures=t=>I.nodeCache.set("client",t,this.clientTTL);deleteClientFeatures=()=>I.nodeCache.del("client");getExpiration=(t,e)=>{let i=this.getKeyFromExpirationType(e);return i==="ids"?this.idMappingsExpiration:I.nodeCache.getTtl(i)};getKeyFromExpirationType=t=>{switch(t){case"profile":return"profile";case"statistics":return"profile_stats";case"badges":return"profile_badges";case"features":return"client";case"ids":return"ids"}}},zt=I;ot(zt,"instance"),ot(zt,"nodeCache",new Ml.default);var K=class{createLocalCacheInstance=t=>typeof window>"u"?zt.getInstance(t):ui.getInstance(t)};var Bi=class{localCache=null;https=null;constructor(t){this.localCache=new K().createLocalCacheInstance(t.idSchema),this.https=new Di(t)}getEntitiesByIds=async(t,e,i)=>{await this.setTopIdMappings();try{let r=this.localCache.checkForExistingIdObjs(t,e),a=this.splitForRequestAndExisting(r),s=await this.https.getEntitiesByIdObjs(a.request,e);return this.localCache.addIdMappings(s),this.localCache.getIdsByType(t,e,i)}catch(r){return console.warn("There was a problem retrieving the entity ids ",r),Promise.resolve([])}};getEntityById=async(t,e,i)=>{let r=this.localCache.getEntity(t,e,i);if(r)return r;let a=await this.requestEntity(t,e,i);return this.localCache.addIdMappings(a),a&&a.length>0?a[0]:null};splitForRequestAndExisting=t=>{let e={},i={};return Object.keys(t).forEach(r=>{e[r]=t[r].filter(a=>!a.exists).map(a=>a.id),i[r]=t[r].filter(a=>a.exists).map(a=>a.id)}),{existing:i,request:e}};requestEntity=async(t,e,i)=>{try{return t=Array.isArray(t)?t:[t],await this.https.getEntitiesByIds(e,t,i)}catch(r){return console.warn(`There was a problem retrieving the requested entity: ${r}`),null}};setTopIdMappings=async()=>{let t=Math.floor(Date.now()/1e3);if(this.localCache.getExpiration("football","ids")>t)return Promise.resolve();let i=await this.https.getTopEntities();this.localCache.addTopIdMappings(i)}};var Tn=o=>{switch(o){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 o}};var Ni=class{extractedObjIds={};traverse=(t,e)=>(e=Tn(e),Array.isArray(t)?this.traverseArrExtract(t,e):t&&typeof t=="object"&&this.traverseObjExtract(t,e),this.extractedObjIds);traverseArrExtract=(t,e)=>{t&&t.length>0&&t.forEach(i=>{this.traverseObjExtract(i,e)})};traverseObjExtract=(t,e)=>{t&&Object.keys(t).length>0&&Object.keys(t).forEach(i=>{let r=t[i];i==="id"||i==="teamId"?(this.extractedObjIds.hasOwnProperty(e)||(this.extractedObjIds[e]=[]),r&&this.extractedObjIds[e].push(r)):t[i]&&this.traverse(t[i],i)})}};var ki=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(t,e,i)=>(e=Tn(e),this.replaceObjIdsIndex===null&&(this.initReplaceObjIdsIndex(i),this.remappedIdsObj=i),Array.isArray(t)?this.traverseArrReplace(t,e):t&&typeof t=="object"&&this.traverseObjReplace(t,e),t);initReplaceObjIdsIndex=t=>{this.replaceObjIdsIndex={},Object.keys(t).forEach(e=>{this.replaceObjIdsIndex[e]=0})};traverseArrReplace=(t,e)=>{t&&t.length>0&&t.forEach(i=>{this.traverseObjReplace(i,e)})};traverseObjReplace=(t,e)=>{t&&Object.keys(t).length>0&&Object.keys(t).forEach(i=>{i==="id"||i==="teamId"?t[i]&&(t[i]=this.remappedIdsObj[e][this.replaceObjIdsIndex[e]],this.replaceObjIdsIndex[e]=this.replaceObjIdsIndex[e]+1):t[i]&&this.traverse(t[i],i,this.remappedIdsObj)})}};var P=class{idSchema="";idMappingFacade=null;constructor(t){this.idSchema=t.idSchema,this.idMappingFacade=new Bi(t)}getEntityIdBySchemaId=(t,e)=>this.idMappingFacade.getEntityById(e,t,this.idSchema);remapEntities=async(t,e)=>{let i=JSON.parse(JSON.stringify(t));try{if(this.idSchema!=="native"){let a=new Ni().traverse(i,e);return this.idMappingFacade.getEntitiesByIds(a,"native",this.idSchema).then(s=>new ki().traverse(i,e,s))}else return t}catch(r){return console.warn(`There was a problem remapping entity: ${e} with inner entity `,r),[]}};getEntityIdsBySchemaId=async(t,e,i)=>{let r={};return r[e]=t,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(r,this.idSchema,i):r}};var q=class{completed=!1;percentage;constructor(t){this.percentage=t}};var Ui=class{teamFollowed=new q(10);teamFavourite=new q(15);playerFollowed=new q(10);playerFavourite=new q(10);competitionFollowed=new q(10);competitionFavourite=new q(5);addedBirthdate=new q(10);addedGender=new q(10);addedCountry=new q(10);addedAvatar=new q(10)};var Gi=class{totalPercentage;breakdown=new Ui};var mi=class{limit=0;startAfter=null;constructor(t){this.limit=t.limit?t.limit:20,this.startAfter=t.startAfter?t.startAfter:null}constructFilterUrl=()=>{let t="";return this.limit&&(t=t+"&",t=t+`limit=${this.limit}`),this.startAfter&&(t=t+"&",t=t+`start_after=${this.startAfter}`),t}};var lt=class{localCache;profileHttps=null;activityHttps=null;constructor(t,e,i){this.localCache=t,this.profileHttps=e,this.activityHttps=i}getOwn=async()=>{let t=this.getLocalStorageData("profile");if(t&&Object.keys(t).length)return JSON.parse(JSON.stringify(t));try{let e=await this.profileHttps.getProfile();return this.localCache.setOwnProfile(e),e}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};getOwnProfileFromCache=()=>this.localCache.getOwnProfile();updateOwnProfile=async()=>{try{let t=await this.profileHttps.getProfile();return this.localCache.setOwnProfile(t),t}catch(t){throw console.warn("There was a problem retrieving your profile: ",t),t}};getByIds=async(t,e,i)=>{if(t&&t.length>0&&e||!t&&t.length===0&&!e)throw new m(400,"invalid_method_call","The method 'getByIds' from Profile namespace is not called correctly. You need to provide 'profileIds' OR 'search' parameters to the method, but you can't use both of them or neither of them.");try{return await this.profileHttps.getProfiles(t,e,i)}catch(r){throw console.warn(`There was a problem retrieving the selected profiles: ${t.join(",")} `,r),r}};getById=async t=>{try{return await this.profileHttps.getProfile(t)}catch(e){throw console.warn(`There was a problem retrieving the selected profile: ${t} `,e),e}};getCountries=async t=>{t=t||!1;let e=this.localCache.getProfileCountries();if(e&&e.length>0)return e;try{let i=await this.profileHttps.getCountries(t);return this.localCache.setProfileCountries(i),i}catch(i){throw console.warn("There was a problem retrieving profile countries: ",i),i}};getFollowers=async(t,e)=>{try{t&&(t=new mi(t));let i=await this.profileHttps.getFollowers(t,e),r=i.data.map(a=>a.followerId);if(r.length){let a=await this.getByIds(r),s=i.data.map(l=>(a.forEach(n=>{l.followerId===n.id&&(l.name=n.name,l.nickname=n.nickname,l.avatar=n.avatar)}),l));return i.data=s,i}return i}catch(i){throw console.warn("There was a problem retrieving your followers: ",i),i}};getFollowing=async(t,e)=>{try{t&&(t=new mi(t));let i=await this.profileHttps.getFollowing(t,e),r=i.data.map(a=>a.followingId);if(r.length){let a=await this.getByIds(r),s=i.data.map(l=>(a.forEach(n=>{l.followingId===n.id&&(l.name=n.name,l.nickname=n.nickname,l.avatar=n.avatar)}),l));return i.data=s,i}return i}catch(i){throw console.warn("There was a problem retrieving your following profiles: ",i),i}};follow=async t=>{try{return await this.profileHttps.follow(t)}catch(e){throw console.warn(`There was a problem following profiles: ${t.join(",")} `,e),e}};unfollow=async t=>{try{return await this.profileHttps.unfollow(t)}catch(e){throw console.warn(`There was a problem unfollowing profiles: ${t.join(",")} `,e),e}};showFullnessProfile=t=>{let e=new Gi,i=0;return t.avatar&&(e.breakdown.addedAvatar.completed=!0,i+=e.breakdown.addedAvatar.percentage),t.birthDate&&(e.breakdown.addedBirthdate.completed=!0,i+=e.breakdown.addedBirthdate.percentage),t.country&&(e.breakdown.addedCountry.completed=!0,i+=e.breakdown.addedCountry.percentage),t.gender&&(e.breakdown.addedGender.completed=!0,i+=e.breakdown.addedGender.percentage),t.interests&&t.interests.length>0&&(t.interests.find(c=>c.type==="team"&&c.favourite)&&(e.breakdown.teamFavourite.completed=!0,i+=e.breakdown.teamFavourite.percentage),t.interests.find(c=>c.type==="team")&&(e.breakdown.teamFollowed.completed=!0,i+=e.breakdown.teamFollowed.percentage),t.interests.find(c=>c.type==="player"&&c.favourite)&&(e.breakdown.playerFavourite.completed=!0,i+=e.breakdown.playerFavourite.percentage),t.interests.find(c=>c.type==="player")&&(e.breakdown.playerFollowed.completed=!0,i+=e.breakdown.playerFollowed.percentage),t.interests.find(c=>c.type==="competition"&&c.favourite)&&(e.breakdown.competitionFavourite.completed=!0,i+=e.breakdown.competitionFavourite.percentage),t.interests.find(c=>c.type==="competition")&&(e.breakdown.competitionFollowed.completed=!0,i+=e.breakdown.competitionFollowed.percentage)),e.totalPercentage=i,e};getStats=async()=>{let t=this.getLocalStorageData("statistics");if(t&&Object.keys(t).length)return JSON.parse(JSON.stringify(t));try{let e=await this.activityHttps.getStats();return this.localCache.setProfileStats(e),e}catch(e){throw console.warn("There was a problem retrieving own profile statistics: ",e),e}};getBadges=async t=>{if(t)try{return await this.profileHttps.getBadges()}catch(i){throw console.warn("There was a problem retrieving own profile badges: ",i),i}let e=this.getLocalStorageData("badges");if(e)return e;try{let i=await this.profileHttps.getBadges();return this.localCache.setProfileBadges(i),i}catch(i){throw console.warn("There was a problem retrieving own profile badges: ",i),i}};clearLocalStorageData=()=>{this.localCache.setOwnProfile({}),this.localCache.setProfileStats({}),this.localCache.setProfileBadges(null)};getLocalStorageData=t=>{let e=Math.floor(Date.now()/1e3),i=this.localCache.getExpiration("profile",t);switch(t){case"profile":if(i>e)return this.localCache.getOwnProfile();case"statistics":if(i>e)return this.localCache.getProfileStats();case"badges":if(i>e)return this.localCache.getProfileBadges();default:return null}}};var Vi=class{id=null;name=null;assets=null};var Hi=class{extractUpdatedProps=(t,e)=>{let i=["name","nickname","gender","avatar"],r={};return Object.keys(t).forEach(a=>{if(i.includes(a)&&t[a]!==e[a])r[a]=e[a];else if(a==="birthDate")(e[a]===null||t[a]===null&&e[a]||t[a]!==e[a])&&(r.birth_date=e[a]);else if(a==="country")e[a]===null?r.country_id=e[a]:(t[a]===null&&e[a]||t[a].id!==e[a].id)&&(r.country_id=e[a].id);else if(a==="interests"){let s=t[a],l=e[a];l.length&&this.isNewInterest(s,l)?r[a]=this.updateInterests(s,l):(!l.length&&s.length||s.length!==l.length&&!this.isNewInterest(s,l))&&(r[a]=l)}}),r};updateInterests=(t,e)=>{if(t.length===e.length){let[i,r]=this.extractSameAndNewInterests(t,e);return[...r,...i]}else return e};isNewInterest=(t,e)=>{let i=!1,[r]=this.extractSameAndNewInterests(t,e);return r.length&&(i=!0),i};extractSameAndNewInterests=(t,e)=>{let i=e.filter(a=>t.some(s=>a.id===s.id&&a.type===s.type&&a.source===s.source&&a.favourite===s.favourite));return[e.filter(a=>!t.some(s=>a.id===s.id&&a.type===s.type&&a.source===s.source&&a.favourite===s.favourite)),i]};isAvatarValidURL=t=>{try{return new URL(t),!0}catch{return!1}}};var f=class extends Error{code=0;status=null;message=null;constructor(t,e,i){super(),this.code=t,this.status=e,this.message=i}errorMessage=()=>this.message};var $i=class{idsRemapper=null;profileHttps=null;profileService=null;localCache=null;profileFacade=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;configuration=null;constructor(t,e,i,r,a){this.configuration=t,this.idsRemapper=e,this.localCache=i,this.profileHttps=r,this.profileService=new Hi,this.profileFacade=new lt(i,r,a)}getOwnProfile=async()=>{for(;this.isFetching;)console.log("Another thread is fetching profile..."),await this.delay(100);if(this.modified&&this.ownProfile)return console.log("Timestamp is less than 10 minutes OR profile is modifying "),this.ownProfile;let t=Math.floor(Date.now()/1e3);if(this.clearAllProfileData(),!this.ownProfile||this.expireAt<t){this.isFetching=!0,this.expireAt=Math.floor(Date.now()/1e3)+600;try{let e=await this.profileFacade.getOwn();this.setOwnProfile(e)}catch(e){throw this.isFetching=!1,e}return this.modified=!1,this.isFetching=!1,this.ownProfile}return this.ownProfile};delay=t=>new Promise(e=>{setTimeout(e,t)});setOwnProfile=t=>{this.ownProfile=t};getInfo=async()=>{let t=await this.getOwnProfile(),e=JSON.parse(JSON.stringify(t));return delete e.interests,e};showInterests=async()=>{let t=await this.getOwnProfile(),e=JSON.parse(JSON.stringify(t));return await this.idsRemapper.remapInterests(e.interests)};showFullInterests=async()=>{let t=await this.getOwnProfile(),e=JSON.parse(JSON.stringify(t));return await this.idsRemapper.showFullInterests(e.interests)};getFollowers=async t=>await this.profileFacade.getFollowers(t);getFollowing=async t=>await this.profileFacade.getFollowing(t);follow=async t=>{let e=await this.profileFacade.follow(t),i=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(i),e};unfollow=async t=>{let e=await this.profileFacade.unfollow(t),i=await this.profileFacade.updateOwnProfile();return this.setOwnProfile(i),e};getStats=async()=>{this.clearAllProfileData();let t=await this.profileFacade.getStats();return await this.idsRemapper.remapProfileStats(t)};getBadges=async t=>(this.clearAllProfileData(),await this.profileFacade.getBadges(t));addInterestPromise=async t=>{this.modified=!0;let e={...t};await this.getOwnProfile();let i=null;t.source!=="custom"?i=await this.idsRemapper.remapInterestToNative(e):i=e;let r=this.ownProfile.interests.filter(a=>a.id!==i.id||a.type!==i.type||a.source!==i.source);return this.ownProfile.interests=[...r],this.ownProfile.interests.push(i),this};addInterest=t=>(this.promises.push(this.addInterestPromise(t)),this);removeInterestPromise=async t=>{this.modified=!0;let e={...t};await this.getOwnProfile();let i=null;return t.source!=="custom"?i=await this.idsRemapper.remapInterestToNative(e):i=e,this.ownProfile.interests=this.ownProfile.interests.filter(r=>r.id!==i.id||r.type!==i.type||r.source!==i.source),this};removeInterest=t=>(this.promises.push(this.removeInterestPromise(t)),this);setBirthdatePromise=async t=>(this.modified=!0,await this.getOwnProfile(),t?this.ownProfile.birthDate=t:this.ownProfile.birthDate=null,this);setBirthdate=t=>(this.promises.push(this.setBirthdatePromise(t)),this);setGenderPromise=async t=>(this.modified=!0,await this.getOwnProfile(),t==="male"||t==="female"?this.ownProfile.gender=t:this.ownProfile.gender="unspecified",this);setGender=t=>(this.promises.push(this.setGenderPromise(t)),this);setNicknamePromise=async t=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.nickname=t,this);setNickname=t=>(this.promises.push(this.setNicknamePromise(t)),this);setNamePromise=async t=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.name=t,this);setName=t=>(this.promises.push(this.setNamePromise(t)),this);setCountryPromise=async t=>(this.modified=!0,await this.getOwnProfile(),t&&!this.ownProfile.country?(this.ownProfile.country=new Vi,this.ownProfile.country.id=t):t&&this.ownProfile.country?this.ownProfile.country.id=t:this.ownProfile.country=null,this);setCountry=t=>(this.promises.push(this.setCountryPromise(t)),this);showFullnessProfile=async()=>{let t=await this.getOwnProfile(),e=JSON.parse(JSON.stringify(t));return this.profileFacade.showFullnessProfile(e)};setAvatarPromise=async t=>{if(this.modified=!0,await this.getOwnProfile(),this.profileService.isAvatarValidURL(t))this.ownProfile.avatar=t;else{if(this.configuration.errorHandlingMode==="default")throw new f(400,"invalid_avatar","Invalid URL syntax for avatar image.");if(this.configuration.errorHandlingMode==="standard")throw new m(400,"invalid_avatar","Invalid URL syntax for avatar image.")}return this};setAvatar=t=>(this.promises.push(this.setAvatarPromise(t)),this);update=async()=>{if(this.promises.length===0)return this.ownProfile;await Promise.all(this.promises);let t=await this.profileFacade.getOwn(),e=await this.getOwnProfile(),i=this.profileService.extractUpdatedProps(t,e);if(this.modified=!1,this.expireAt=0,Object.keys(i).length){let a=await this.profileHttps.updateProfile(i),s=JSON.parse(JSON.stringify(a));return this.setOwnProfile(s),this.localCache.setOwnProfile(s),delete a.interests,a}let r=JSON.parse(JSON.stringify(this.ownProfile));return delete r.interests,r};clearAllProfileData=()=>{this.isNewProfileRequested()&&this.profileFacade.clearLocalStorageData()};isNewProfileRequested=()=>{let t=this.extractUserIdFromToken();if(!t)return!1;if(!this.ownProfile){let e=this.profileFacade.getOwnProfileFromCache();return!!(e&&Object.keys(e).length&&e.id!==t)}return this.ownProfile.id!==t};extractUserIdFromToken=()=>{try{return bn(this.configuration.authProvider.getIdToken())?.sub||""}catch(t){return console.error(t),""}}};var Wi=class{idsRemapper=null;profileHttps=null;activityHttps=null;profileFacade=null;profileId="";constructor(t,e,i,r){this.idsRemapper=t,this.profileHttps=i,this.activityHttps=r,this.profileFacade=new lt(e,i,r)}setId=t=>(this.profileId=t,this);getProfile=async()=>await this.profileFacade.getById(this.profileId);getInfo=async()=>{let t=await this.getProfile();return delete t.interests,t};showInterests=async()=>{let t=await this.getProfile(),e=JSON.parse(JSON.stringify(t));return await this.idsRemapper.remapInterests(e.interests)};showFullInterests=async()=>{let t=await this.getProfile(),e=JSON.parse(JSON.stringify(t));return await this.idsRemapper.showFullInterests(e.interests)};getFollowers=async t=>await this.profileFacade.getFollowers(t,this.profileId);getFollowing=async t=>await this.profileFacade.getFollowing(t,this.profileId);showFullnessProfile=async()=>{let t=await this.getProfile();return this.profileFacade.showFullnessProfile(t)};getStats=async t=>{let e=await this.activityHttps.getStats(this.profileId,t);return await this.idsRemapper.remapProfileStats(e)};getBadges=async()=>await this.profileHttps.getBadges(this.profileId)};var zi=class{localCache=null;https=null;idMapping=null;constructor(t,e,i){this.localCache=t,this.idMapping=i,this.https=e}getCountriesWithIdMapping=async t=>{try{let e=await this.getCountries(t);return this.idMapping.remapEntities(e,"country")}catch(e){throw console.warn("There was a problem browsing countries as football entities",e),e}};getCountries=async t=>{t=t||!1;let e=this.localCache.getFootballCountries();if(e&&e.length>0)return e;try{let i=await this.https.getCountries(t);return this.localCache.setFootballCountries(i),i}catch(i){throw console.warn("There was a problem retrieving countries as football entities",i),i}}};var hi=class{countryId=null;name=null;gender=null;type=null;sortField=null;sortOrder=null;competitionIds=null;constructor(t){this.countryId=t.countryId?`${t.countryId}`:null,this.name=t.name?t.name:null,this.gender=t.gender?t.gender:null,this.type=t.type?t.type:null,this.sortField=t.sortField?`${t.sortField}`:null,this.sortOrder=t.sortOrder?`${t.sortOrder}`:null,this.competitionIds=t.competitionIds?t.competitionIds:null}constructFilterUrl=()=>{let t="";return this.countryId&&(t=t+"&",t=t+`country_id=${this.countryId}`),this.gender&&(t=t+"&",t=t+`gender=${this.gender}`),this.type&&(t=t+"&",t=t+`type=${this.type}`),this.sortField&&(t=t+"&",t=t+`sort_field=${this.sortField}`),this.sortOrder&&(t=t+"&",t=t+`sort_order=${this.sortOrder}`),this.name&&(t=t+"&",t=t+`name=${this.name}`),this.competitionIds&&this.competitionIds.length>0&&(t=t+"&",t=t+`competition_ids=${this.competitionIds.join(",")}`),t};competitionSearchFilter=t=>{try{let e=this.filter(t);return this.sortField||this.sortOrder?this.sort(e):e}catch(e){return console.warn("There was a problem filtering the local competitions",e),[]}};filter=t=>{let e=this.entitiesToSearchWith();return t.filter(i=>{let r=!0;return e.forEach(a=>{a!=="sortOrder"&&a!=="sortField"&&(a==="countryId"?r&&=i.country.id===this[a]:a==="name"?r&&=i.name.toLocaleLowerCase().includes(this[a].toLocaleLowerCase()):a==="competitionIds"?r&&=this[a].some(s=>i.id===s):r&&=i[a].toLocaleLowerCase()===this[a].toLocaleLowerCase())}),r})};entitiesToSearchWith=()=>{let t=[];return this.countryId&&t.push("countryId"),this.name&&t.push("name"),this.gender&&t.push("gender"),this.type&&t.push("type"),this.sortField&&t.push("sortField"),this.sortOrder&&t.push("sortOrder"),this.competitionIds&&t.push("competitionIds"),t};sort=t=>{let e=[];return this.sortField==="name"?e=t.sort((i,r)=>this.sortOrder&&this.sortOrder==="desc"?r.name.localeCompare(i.name):i.name.localeCompare(r.name)):this.sortField==="country"?e=t.sort((i,r)=>this.sortOrder&&this.sortOrder==="desc"?r.country.name.localeCompare(i.country.name):i.country.name.localeCompare(r.country.name)):this.sortField==="scope"?t.forEach(i=>e[this.competitionIds.indexOf(i.id)]=i):!this.sortField&&this.sortOrder==="desc"&&(e=t.sort((i,r)=>r.id.localeCompare(i.id))),e}};var qi=class{localStorage=null;https=null;idMapping=null;constructor(t,e,i){this.localStorage=t,this.idMapping=i,this.https=e}getCompetitionsIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new hi(t),t.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([`${t.countryId}`],"country","native");a.country.length===0&&(i=!0),t.countryId=a.country[0]}if(t.competitionIds){let a=await this.idMapping.getEntityIdsBySchemaId(t.competitionIds,"competition","native");a.competition.length===0&&(i=!0),t.competitionIds=a.competition}if(i)return[]}let r=await this.getCompetitions(t,e);return await this.idMapping.remapEntities(r,"competition")}catch(i){throw console.warn("There was a problem browsing all of the competitions",i),i}};getCompetitionsMapWithNativeIds=async t=>{let e=new Map,i=t.length,r=new hi({competitionIds:t,limit:i}),a=await this.getCompetitions(r);a.sort((n,p)=>n.id.localeCompare(p.id));let s=fn(t),l=await this.idMapping.remapEntities(a,"competition");return s.forEach((n,p)=>e.set(n,l[p])),e};getCompetitions=async(t,e)=>{let i=null;if(e=e||!1,!this.localStorage.getCompetitionsLength()){try{i=await this.https.getCompetitions()}catch(r){throw console.warn("There was a problem retrieving all competitions",r),r}this.localStorage.setCompetitions(i)}return this.localStorage.getCompetitions(t)};getCompetitionByIdIdMapping=async(t,e)=>{try{let r=(await this.idMapping.getEntityIdsBySchemaId([t],"competition","native")).competition[0],a=await this.getCompetitionById(r,e);return await this.idMapping.remapEntities(a,"competition")}catch(i){throw console.warn(`There was a problem browsing the following competition:${t}`,i),i}};getCompetitionById=async(t,e)=>{try{return e=e||!1,await this.https.getCompetitionById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the competition with the following id: ${t}`,i),i}};getTopCompetitionsIdMapping=async t=>{try{let e=await this.getTopCompetitions(t);return await this.idMapping.remapEntities(e,"competition")}catch(e){throw console.warn("There was a problem browsing the top competitions",e),e}};getTopCompetitions=async t=>{try{return t=t||!1,await this.https.getTopCompetitions(t)}catch(e){throw console.warn("There was a problem retrieving the top competitions",e),e}}};var gi=class{name=null;countryId=null;national=!1;gender=null;limit=null;page=null;scope=null;sortField=null;sortOrder=null;teamIds=null;constructor(t){this.name=t.name?t.name:null,this.countryId=t.countryId?`${t.countryId}`:null,this.national=t.national?t.national:!1,this.gender=t.gender?t.gender:null,this.limit=t.limit?t.limit:null,this.page=t.page?t.page:null,this.scope=t.scope?t.scope:null,this.sortField=t.sortField?`${t.sortField}`:null,this.sortOrder=t.sortOrder?`${t.sortOrder}`:null,this.teamIds=t.teamIds?t.teamIds:null}constructFilterUrl=()=>{let t="";return this.name&&(t=t+"&",t=t+`name=${this.name}`),this.countryId&&(t=t+"&",t=t+`country_id=${this.countryId}`),this.national&&(t=t+"&",t=t+`national=${this.national}`),this.gender&&(t=t+"&",t=t+`gender=${this.gender}`),this.limit&&(t=t+"&",t=t+`limit=${this.limit}`),this.scope&&this.scope.length>0&&(t=t+"&",t=t+`scope=${this.scope.join(",")}`),this.page&&(t=t+"&",t=t+`page=${this.page}`),this.sortField&&(t=t+"&",t=t+`sort_field=${this.sortField}`),this.sortOrder&&(t=t+"&",t=t+`sort_order=${this.sortOrder}`),this.teamIds&&this.teamIds.length>0&&(t=t+"&",t=t+`team_ids=${this.teamIds.join(",")}`),t}};var Qi=class{reason="";words=[]};var qt=class{enabled=!1;moderateLinks=!1;linksWhitelist=[];moderatorProfileId="";dictionary=new Qi};var Ki=class{enabled=!1;clientId=null;automaticModeration=new qt};var Mt=class{points=null;gameParticipationCount=null;entityId=null;entityType=null;predictionsMade=null;correctPredictions=null};var ji=class{id;weight;multiplier;conditions};var Qt=class{value=[new ji]};var Kt=class{points=null;tiers=null;badges=null};var Xi=class{enabled=!1;clientId=null;conditions={list:null};actions=new Qt;rewards=new Kt};var Yi=class{general=null;predictor=null;activity=null;topX=null;matchQuiz=null;discussionPost=null};var jt=class{enabled=!1;clientId=null;defaultMarkets=null;competitionsWhitelist=null};var Xt=class{enabled=!1;clientId=null;minFixtures=null;maxFixtures=null;competitionsWhitelist=null};var Ji=class{competitions=[];teams=[];markets=[]};var Yt=class{enabled=!1;clientId=null;fullCoverageCompetitions=null;markets=null;successRateScopes=new Ji;userDataConfig=null};var Zi=class{storeIp=!1;storeDeviceId=!1;storeAgent=!1};var tr=class{potm=[];poll=[]};var er=class{predictor=[];topX=[];matchQuiz=[];games=[];football=[];classicQuizzes=[];eitherOr=[];discussions=[];voting=new tr};var B=class{id;label;description;flags;assets={mainImageUrl:""};enabled};var ir=class{predictionsNumber;correctPredictions;points;fromDate;toDate};var rr=class extends B{requirements=new ir};var ar=class{participationCount;points;fromDate;toDate};var or=class extends B{requirements=new ar};var sr=class{participationCount;points;specificGames;fromDate;toDate};var nr=class extends B{requirements=new sr};var lr=class{predictionsNumber;correctPredictions;points;entityId;entityType;entityModel=null};var pr=class extends B{requirements=new lr};var cr=class{participationCount;fromDate;toDate};var ur=class extends B{requirements=new cr};var dr=class{totalDiscussionPoints;postsCount;postPoints;reactionsCount};var mr=class extends B{requirements=new dr};var hr=class{points;voteCount;entityId;entityType;entityModel};var gr=class extends B{requirements=new hr};var Jt=class{points=null;tiers=null;badges=null};var fr=class{enabled=!1;clientId=null;conditions={list:null};actions=new Qt;rewards=new Jt};var yr=class{general=[];predictor=[];topX=[];matchQuiz=[]};var br=class{id;label;assets={mainImageUrl:""};enabled;requirements=new Mt};var Zt=class extends Mt{postPoints=null;postsCount=null;reactionsCount=null;totalDiscussionPoints=null};var Mr=class{id;label;assets={mainImageUrl:""};enabled;requirements=new Zt};var te=class{assists=null;shots=null;offsides=null;tackles=null;saves=null;minutesEqualOrOver60=null;minutesUnder60=null;yellowCards=null;redCards=null;goalsGoalkeeper=null;goalsDefender=null;goalsMidfielder=null;goalsForwards=null;penaltyGoals=null;ownGoals=null;cleanSheetsGoalkeeper=null;cleanSheetsDefender=null;cleanSheetsMidfielder=null;cleanSheetsForwards=null;shotsOn=null;foulsCommitted=null;penaltyCommitted=null;penaltyWon=null;penaltyMissed=null;concededGoals=null;caughtBall=null};var ee=class{total=null;minGoalkeepers=null;maxGoalkeepers=null;minDefenders=null;maxDefenders=null;minMidfielders=null;maxMidfielders=null;minStrikers=null;maxStrikers=null};var wr=class{enabled=!1;clientId=null;addPointsToProfileTotal=!1;coefficients=new te;players=new ee;competitionsWhitelist=[]};var Ir=class{remapPredictorConfig=t=>{let e=new Yt;return e.enabled=t.enabled,e.clientId=t.client_id,e.fullCoverageCompetitions=t.full_coverage_competitions,e.markets=t.markets,e.successRateScopes=t.success_rate_scopes,e.userDataConfig=t.user_data_config?this.remapUserDataConfig(t.user_data_config):null,e};remapTopXConfig=t=>{let e=new Xt;return e.enabled=t.enabled,e.clientId=t.client_id,e.minFixtures=t.min_fixtures,e.maxFixtures=t.max_fixtures,e.competitionsWhitelist=t.competitions_whitelist,e};remapMatchQuizConfig=t=>{let e=new jt;return e.enabled=t.enabled,e.clientId=t.client_id,e.defaultMarkets=t.default_markets,e.competitionsWhitelist=t.competitions_whitelist,e};remapLoyaltyConfig=t=>{let e=new Xi;return e.enabled=t.enabled,e.clientId=t.client_id,e.conditions.list=t.conditions.list,e.actions.value=t.actions.value,e.rewards=this.remapRewards(t.rewards),e};remapLoyaltyNewConfig=t=>{let e=new fr;return e.enabled=t.enabled,e.clientId=t.client_id,e.conditions.list=t.conditions.list,e.actions.value=t.actions.value,e.rewards=this.remapNewRewards(t.rewards),e};remapDiscussionsConfig=t=>{let e=new Ki;return e.enabled=t.enabled,e.clientId=t.client_id,e.automaticModeration=t.automatic_moderation?this.remapAutomaticModeration(t.automatic_moderation):null,e};remapFantasyConfig=t=>{let e=new wr;return e.enabled=t.enabled,e.clientId=t.client_id,e.addPointsToProfileTotal=t.add_points_to_profile_total,e.competitionsWhitelist=t.competitions_whitelist,e.players=this.remapFantasyPlayers(t.players),e.coefficients=this.remapFantasyCoefficients(t.coefficients),e};remapFantasyPlayers=t=>{let e=new ee;return e.total=t.total,e.minGoalkeepers=t.min_goalkeepers,e.maxGoalkeepers=t.max_goalkeepers,e.minDefenders=t.min_defenders,e.maxDefenders=t.max_defenders,e.minMidfielders=t.min_midfielders,e.maxMidfielders=t.max_midfielders,e.minStrikers=t.min_strikers,e.maxStrikers=t.max_strikers,e};remapFantasyCoefficients=t=>{let e=new te;return e.assists=t.assists,e.shots=t.shots,e.offsides=t.offsides,e.tackles=t.tackles,e.saves=t.saves,e.minutesEqualOrOver60=t.minutes_equal_or_over_60,e.minutesUnder60=t.minutes_under_60,e.yellowCards=t.yellow_cards,e.redCards=t.red_cards,e.goalsGoalkeeper=t.goals_goalkeeper,e.goalsDefender=t.goals_defender,e.goalsMidfielder=t.goals_midfielder,e.goalsForwards=t.goals_forwards,e.penaltyGoals=t.penalty_goals,e.ownGoals=t.own_goals,e.cleanSheetsGoalkeeper=t.clean_sheets_goalkeeper,e.cleanSheetsDefender=t.clean_sheets_defender,e.cleanSheetsMidfielder=t.clean_sheets_midfielder,e.cleanSheetsForwards=t.clean_sheets_forwards,e.shotsOn=t.shots_on,e.foulsCommitted=t.fouls_committed,e.penaltyCommitted=t.penalty_committed,e.penaltyWon=t.penalty_won,e.penaltyMissed=t.penalty_missed,e.concededGoals=t.conceded_goals,e.caughtBall=t.caught_ball,e};remapAutomaticModeration=t=>{let e=new qt;return e.enabled=t.enabled,e.moderateLinks=t.moderate_links,e.linksWhitelist=t.links_whitelist,e.moderatorProfileId=t.moderator_profile_id,e.dictionary=t.dictionary,e};remapNewRewards=t=>{let e=new Jt;return e.points=this.remapPoints(t.points),e.tiers=t.tiers,e.badges=this.remapNewBadges(t.badges),e};remapRewards=t=>{let e=new Kt;return e.points=this.remapPoints(t.points),e.tiers=t.tiers,e.badges=this.remapBadges(t.badges),e};remapPoints=t=>{let e=new Yi;return e.general=t.general,e.discussionPost=t.discussion_post,e.predictor=t.predictor,e.activity=t.activity,e.topX=t.top_x,e.matchQuiz=t.match_quiz,e};remapBadges=t=>{let e=new yr;return e.general=t.general?this.remapGeneralBadgeValues(t.general):[],e.predictor=this.remapBadgeValues(t.predictor),e.topX=this.remapBadgeValues(t.top_x),e.matchQuiz=this.remapBadgeValues(t.match_quiz),e};remapNewBadges=t=>{let e=new er;return e.predictor=this.remapBadgeValuesPredictor(t.predictor),e.topX=this.remapBadgeValuesGame(t.top_x),e.matchQuiz=this.remapBadgeValuesGame(t.match_quiz),t.games&&(e.games=this.remapBadgeValuesGames(t.games)),t.football&&(e.football=this.remapBadgeValuesFootball(t.football)),t.classic_quizzes&&(e.classicQuizzes=this.remapBadgeValuesMiniGames(t.classic_quizzes)),t.either_or&&(e.eitherOr=this.remapBadgeValuesMiniGames(t.either_or)),t.discussions&&(e.discussions=this.remapBadgeValuesDiscussions(t.discussions)),t.voting&&t.voting.potm&&(e.voting.potm=this.remapBadgeValuesVoting(t.voting.potm)),t.voting&&t.voting.poll&&(e.voting.poll=this.remapBadgeValuesVoting(t.voting.poll)),e};remapBadgeValuesPredictor=t=>t.map(e=>{let i=new rr;return i.id=e.id,i.enabled=e.enabled,i.label=e.label,i.description=e.description,i.flags=e.flags,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,e.requirements&&(i.requirements.predictionsNumber=e.requirements.predictions_number,i.requirements.correctPredictions=e.requirements.correct_predictions,i.requirements.points=e.requirements.points,i.requirements.fromDate=e.requirements.from_date,i.requirements.toDate=e.requirements.to_date),i});remapBadgeValuesGame=t=>t.map(e=>{let i=new or;return i.id=e.id,i.enabled=e.enabled,i.label=e.label,i.description=e.description,i.flags=e.flags,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,e.requirements&&(i.requirements.participationCount=e.requirements.participation_count,i.requirements.points=e.requirements.points,i.requirements.fromDate=e.requirements.from_date,i.requirements.toDate=e.requirements.to_date),i});remapBadgeValuesGames=t=>t.map(e=>{let i=new nr;return i.id=e.id,i.enabled=e.enabled,i.label=e.label,i.description=e.description,i.flags=e.flags,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,e.requirements&&(i.requirements.participationCount=e.requirements.participation_count,i.requirements.points=e.requirements.points,i.requirements.fromDate=e.requirements.from_date,i.requirements.toDate=e.requirements.to_date,i.requirements.specificGames=e.requirements.specific_games?this.remapSpecificGamesRequirement(e.requirements.specific_games):null),i});remapSpecificGamesRequirement=t=>t.map(e=>({gameId:e.game_id,gameType:e.game_type,gameModel:null}));remapBadgeValuesFootball=t=>t.map(e=>{let i=new pr;return i.id=e.id,i.enabled=e.enabled,i.label=e.label,i.description=e.description,i.flags=e.flags,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,e.requirements&&(i.requirements.predictionsNumber=e.requirements.predictions_number,i.requirements.correctPredictions=e.requirements.correct_predictions,i.requirements.points=e.requirements.points,i.requirements.entityId=e.requirements.entity_id,i.requirements.entityType=e.requirements.entity_type),i});remapBadgeValuesMiniGames=t=>t.map(e=>{let i=new ur;return i.id=e.id,i.enabled=e.enabled,i.label=e.label,i.description=e.description,i.flags=e.flags,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,e.requirements&&(i.requirements.participationCount=e.requirements.participation_count,i.requirements.fromDate=e.requirements.from_date,i.requirements.toDate=e.requirements.to_date),i});remapBadgeValuesDiscussions=t=>t.map(e=>{let i=new mr;return i.id=e.id,i.enabled=e.enabled,i.label=e.label,i.description=e.description,i.flags=e.flags,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,e.requirements&&(i.requirements.totalDiscussionPoints=e.requirements.total_discussion_points,i.requirements.postsCount=e.requirements.posts_count,i.requirements.postPoints=e.requirements.post_points,i.requirements.reactionsCount=e.requirements.reactions_count),i});remapBadgeValuesVoting=t=>t.map(e=>{let i=new gr;return i.id=e.id,i.enabled=e.enabled,i.label=e.label,i.description=e.description,i.flags=e.flags,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,e.requirements&&(i.requirements.points=e.requirements.points,i.requirements.voteCount=e.requirements.vote_count,i.requirements.entityId=e.requirements.entity_id,i.requirements.entityType=e.requirements.entity_type),i});remapBadgeValues=t=>t.map(e=>{let i=new br;return i.id=e.id,i.label=e.label,i.enabled=e.enabled,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,i.requirements=this.remapRequirements(e.requirements),i});remapRequirements=t=>{let e=new Mt;return e.points=t.points,e.gameParticipationCount=t.game_participation_count,e.entityId=t.entity_id,e.entityType=t.entity_type,e.predictionsMade=t.predictions_made,e.correctPredictions=t.correct_predictions,e};remapUserDataConfig=t=>{let e=new Zi;return e.storeIp=t.store_ip,e.storeDeviceId=t.store_device_id,e.storeAgent=t.store_agent,e};remapGeneralBadgeValues=t=>t.map(e=>{let i=new Mr;return i.id=e.id,i.label=e.label,i.enabled=e.enabled,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,i.requirements=this.remapGeneralRequirements(e.requirements),i});remapGeneralRequirements=t=>{let e=new Zt;return e.points=t.points,e.gameParticipationCount=t.game_participation_count,e.entityId=t.entity_id,e.entityType=t.entity_type,e.predictionsMade=t.predictions_made,e.correctPredictions=t.correct_predictions,e.postPoints=t.post_points,e.postsCount=t.posts_count,e.reactionsCount=t.reactions_count,e.totalDiscussionPoints=t.total_discussion_points,e}};var N=class extends T{featureConfigRemapper=null;localStorage=null;clientId=null;constructor(t){super(t,S(t.environment,"client")),this.clientId=t.clientId,this.localStorage=new K().createLocalCacheInstance(t.idSchema),this.featureConfigRemapper=new Ir}getConfig=async t=>{let e=this.getCachedFeatures();if(!e){let i=`/clients/${this.clientId}/features`,r=this.apiSignInUrl.split("&")[0],a=i+r,s="There was a problem fetching client features from Client API";e=(await this.fetchWithoutAuth(a,s)).data,this.localStorage.setClientFeatures(e)}switch(t){case"predictor":return this.featureConfigRemapper.remapPredictorConfig(e.predictor);case"topX":return this.featureConfigRemapper.remapTopXConfig(e.top_x);case"matchQuiz":return this.featureConfigRemapper.remapMatchQuizConfig(e.match_quiz);case"loyalty":return this.featureConfigRemapper.remapLoyaltyConfig(e.loyalty);case"discussions":return this.featureConfigRemapper.remapDiscussionsConfig(e.discussions);case"fantasy":return this.featureConfigRemapper.remapFantasyConfig(e.football_fantasy)}};getNewLoyaltyConfig=async t=>{let e=`/clients/${this.clientId}/features`,i=this.apiSignInUrl.split("&")[0],r="There was a problem fetching client features from Client API";if(t){let s=e+i+h(),l=await this.fetchWithoutAuthAdditionalHeaders(s,r,{"x-api-version":"2"});this.localStorage.setClientFeatures(l.data)}let a=this.getCachedFeatures();if(!a){let s=e+i;a=(await this.fetchWithoutAuthAdditionalHeaders(s,r,{"x-api-version":"2"})).data,this.localStorage.setClientFeatures(a)}return this.featureConfigRemapper.remapLoyaltyNewConfig(a.loyalty)};getCachedFeatures=()=>{let t=this.getLocalStorageData();if(!(!t||!Object.keys(t).length))return t.predictor.client_id&&t.predictor.client_id!==this.clientId?(this.localStorage.deleteClientFeatures(),null):t};getLocalStorageData=()=>{let t=Math.floor(Date.now()/1e3);return this.localStorage.getExpiration("client","features")>t?this.localStorage.getClientFeatures():null}};var V=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var H=class{pagination=new V};var pt=class{clientHttps=null;errorHandlingMode=null;constructor(t){this.clientHttps=new N(t),this.errorHandlingMode=t.errorHandlingMode}setAvailableMarketsForMatch=async t=>{let{fullCoverageCompetitions:e,markets:i}=await this.clientHttps.getConfig("predictor");if(Array.isArray(t))return t.map(r=>this.setAvailableMarkets(r,e,i));if(typeof t=="object"&&Object.keys(t).length)return this.setAvailableMarkets(t,e,i)};setAvailableMarkets=(t,e,i)=>{let r=t.context.competition?.id;return r&&this.isMatchInCoverageCompetition(r,e)?(t.availableMarkets=i.all,t):(t.availableMarkets=i.main,t)};setMetaDataBatchRequest=(t,e,i)=>{let r=new H;if(r.pagination.totalItems=t,r.pagination.itemsPerPage=e,r.pagination.numberOfPages=t?Math.ceil(t/e):0,r.pagination.currentPage=i,r.pagination.numberOfPages>0&&i>r.pagination.numberOfPages)throw this.errorHandlingMode==="standard"?new m(400,"invalid_page_number","Invalid page number provided. Use number between 1 and max number of pages."):new f(400,"invalid_page_number","Invalid page number provided. Use number between 1 and max number of pages.");return r};finalizeMatchesDataBatchRequest=(t,e)=>{t=t.sort((r,a)=>new Date(r.kickoffAt).getTime()-new Date(a.kickoffAt).getTime());let i=e.limit||20;if(e.page){let r=e.page>1?i*(e.page-1):0;t=t.slice(r,r+i)}return!e.page&&t.length>i&&(t=t.slice(0,i)),t};isMatchInCoverageCompetition=(t,e)=>{let i=!1;return e.includes(t)&&(i=!0),i}};var Pr=class{footballService=null;https=null;idMapping=null;constructor(t,e,i){this.idMapping=i,this.https=e,this.footballService=new pt(t)}getTeamsIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new gi(t),t.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([`${t.countryId}`],"country","native");a.country.length===0&&(i=!0),t.countryId=a.country[0]}if(t.scope){let a=await this.idMapping.getEntityIdsBySchemaId(t.scope,"competition","native");a.competition.length===0&&(i=!0),t.scope=a.competition}if(t.teamIds){let a=await this.idMapping.getEntityIdsBySchemaId(t.teamIds,"team","native");a.team.length===0&&(i=!0),t.teamIds=a.team}}if(i)return[];let r=await this.getTeams(t,e);return r.data=await this.idMapping.remapEntities(r.data,"team"),r}catch(i){throw console.warn("There was a problem browsing all teams",i),i}};getTeamsMapWithNativeIds=async t=>{let e=new Map,i=t.length,r=new gi({teamIds:t,limit:i}),{data:a}=await this.getTeams(r);a.sort((n,p)=>n.id.localeCompare(p.id));let s=fn(t),l=await this.idMapping.remapEntities(a,"team");return s.forEach((n,p)=>e.set(n,l[p])),e};getTeams=async(t,e)=>{try{return e=e||!1,await this.https.getTeams(t,e)}catch(i){throw console.warn("There was a problem retrieving all teams",i),i}};getTeamByIdIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"team","native")).team[0];let r=await this.getTeamById(t,e);return await this.idMapping.remapEntities(r,"team")}catch(i){throw console.warn(`There was a problem browsing the following team:${t}`,i),i}};getTeamById=async(t,e)=>{try{return e=e||!1,await this.https.getTeamById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the following team: ${t}`,i),i}};getTopTeamsIdMapping=async t=>{try{let e=await this.getTopTeams(t);return await this.idMapping.remapEntities(e,"team")}catch(e){throw console.warn("There was a problem browsing the top teams",e),e}};getTopTeams=async t=>{try{return t=t||!1,await this.https.getTopTeams(t)}catch(e){throw console.warn("There was a problem retrieving the top teams",e),e}};getNextMatchForTeamIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"team","native")).team[0];let r=await this.getNextMatchForTeam(t,e);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the next match for the following team:${t}`,i),i}};getNextMatchForTeam=async(t,e)=>{try{e=e||!1;let i=await this.https.getNextMatchForTeam(t,e);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the next match for the following team: ${t}`,i),i}};getPrevMatchForTeamIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"team","native")).team[0];let r=await this.getPrevMatchForTeam(t,e);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the previous match for the following team:${t}`,i),i}};getPrevMatchForTeam=async(t,e)=>{try{e=e||!1;let i=await this.https.getPrevMatchForTeam(t,e);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the previous match for the following team: ${t}`,i),i}}};var yi=class{countryId=null;scope=null;name=null;playerIds=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(t){this.countryId=t.countryId?t.countryId:null,this.scope=t.scope?t.scope:null,this.name=t.name?t.name:null,this.playerIds=t.playerIds?t.playerIds:null,this.limit=t.limit?t.limit:null,this.page=t.page?t.page:null,this.sortField=t.sortField?t.sortField:null,this.sortOrder=t.sortOrder?t.sortOrder:null}constructFilterUrl=()=>{let t="";return this.countryId&&(t=t+"&",t=t+`country_id=${this.countryId}`),this.scope&&this.scope.length>0&&(t=t+"&",t=t+`scope=${this.scope.join(",")}`),this.name&&(t=t+"&",t=t+`name=${this.name}`),this.playerIds&&this.playerIds.length>0&&(t=t+"&",t=t+`player_ids=${this.playerIds.join(",")}`),this.limit&&(t=t+"&",t=t+`limit=${this.limit}`),this.page&&(t=t+"&",t=t+`page=${this.page}`),this.sortField&&(t=t+"&",t=t+`sort_field=${this.sortField}`),this.sortOrder&&(t=t+"&",t=t+`sort_order=${this.sortOrder}`),t}};var wt=class{https=null;footballService=null;idMapping=null;constructor(t,e,i){this.idMapping=i,this.https=e,this.footballService=new pt(t)}getPlayersIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new yi(t),t.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([t.countryId],"country","native");a.country.length===0&&(i=!0),t.countryId=a.country[0]}if(t.playerIds){let a=await this.idMapping.getEntityIdsBySchemaId(t.playerIds,"player","native");a.player.length===0&&(i=!0),t.playerIds=a.player}if(t.scope){let a=await this.idMapping.getEntityIdsBySchemaId(t.scope,"competition","native");a.competition.length===0&&(i=!0),t.scope=a.competition}if(i)return[]}let r=await this.getPlayers(t,e);return r.data=await this.idMapping.remapEntities(r.data,"player"),r}catch(i){throw console.warn("There was a problem browsing the players",i),i}};getPlayersWithNativeIds=async t=>{let e=t.length,i=new yi({playerIds:t,limit:e}),r=await this.getPlayers(i);return r.data.sort((a,s)=>a.id.localeCompare(s.id)),await this.idMapping.remapEntities(r.data,"player")};getPlayersMapWithNativeIds=async t=>{let e={},i=Lt(t);i.sort((a,s)=>a.localeCompare(s));let r=await this.getPlayersWithNativeIds(Array.from(i));return i.forEach((a,s)=>e[a]=r[s]),e};getPlayers=async(t,e)=>{try{return e=e||!1,await this.https.getPlayers(t,e)}catch(i){throw console.warn("There was a problem retrieving the players",i),i}};getPlayerIdMapping=async(t,e)=>{try{let i=await this.idMapping.getEntityIdsBySchemaId([t],"player","native"),r=await this.getPlayerById(i.player[0],e);return await this.idMapping.remapEntities(r,"player")}catch(i){throw console.warn(`There was a problem browsing the following player:${t}`,i),i}};getPlayerById=async(t,e)=>{try{return e=e||!1,await this.https.getPlayerById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the following player: ${t}`,i),i}};getTopPlayersIdMapping=async t=>{try{let e=await this.getTopPlayers(t);return await this.idMapping.remapEntities(e,"player")}catch(e){throw console.warn("There was a problem browsing the top players",e),e}};getTopPlayers=async t=>{try{return t=t||!1,await this.https.getTopPlayers(t)}catch(e){throw console.warn("There was a problem retrieving the top players",e),e}};getNextMatchForPlayerIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"player","native")).player[0];let r=await this.getNextMatchForPlayer(t,e);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the next match for player:${t}`,i),i}};getNextMatchForPlayer=async(t,e)=>{try{e=e||!1;let i=await this.https.getNextMatchForPlayer(t,e);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the next match for player: ${t}`,i),i}};getPrevMatchForPlayerIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"player","native")).player[0];let r=await this.getPrevMatchForPlayer(t,e);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the previous match for player:${t}`,i),i}};getPrevMatchForPlayer=async(t,e)=>{try{e=e||!1;let i=await this.https.getPrevMatchForPlayer(t,e);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the previous match for player: ${t}`,i),i}}};var It=class{countryIds=null;competitionIds=null;matchIds=null;status=null;teamIds=null;fromDate=null;toDate=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(t){this.countryIds=t.countryIds?t.countryIds:null,this.competitionIds=t.competitionIds?t.competitionIds:null,this.matchIds=t.matchIds?t.matchIds:null,this.status=t.status?t.status:null,this.teamIds=t.teamIds?t.teamIds:null,this.fromDate=t.fromDate?t.fromDate:null,this.toDate=t.toDate?t.toDate:null,this.limit=t.limit?t.limit:null,this.page=t.page?t.page:null,this.sortField=t.sortField?t.sortField:null,this.sortOrder=t.sortOrder?t.sortOrder:null}constructFilterUrl=t=>{let e="";return this.countryIds&&(e=e+"&",e=e+`countries=${this.countryIds.join(",")}`),this.competitionIds&&this.competitionIds.length>0&&(e=e+"&",e=e+`competitions=${this.competitionIds.join(",")}`),this.matchIds&&this.matchIds.length>0&&(e=e+"&",e=e+`matches=${this.matchIds.join(",")}`),this.status&&(e=e+"&",e=e+`status=${this.status}`),this.teamIds&&this.teamIds.length>0&&(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&&!t&&(e=e+"&",e=e+`limit=${this.limit}`),this.page&&!t&&(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 Pt=class{https=null;idMapping=null;footballService=null;constructor(t,e,i){this.https=e,this.idMapping=i,this.footballService=new pt(t)}getMatchesIdMapping=async(t,e)=>{try{if(t){if(t=new It(t),t.countryIds&&t.countryIds.length>0){let r=await this.idMapping.getEntityIdsBySchemaId(t.countryIds,"country","native");t.countryIds=r.country}if(t.competitionIds&&t.competitionIds.length>0){let r=await this.idMapping.getEntityIdsBySchemaId(t.competitionIds,"competition","native");t.competitionIds=r.competition}if(t.matchIds&&t.matchIds.length>0){let r=await this.idMapping.getEntityIdsBySchemaId(t.matchIds,"match","native");t.matchIds=r.match}if(t.teamIds&&t.teamIds.length>0){let r=await this.idMapping.getEntityIdsBySchemaId(t.teamIds,"team","native");t.teamIds=r.team}}let i=await this.getMatches(t,e);return i.data=await this.footballService.setAvailableMarketsForMatch([...i.data]),i.data=await this.idMapping.remapEntities(i.data,"match"),i}catch(i){throw console.warn("There was a problem browsing the matches",i),i}};getMatchesWithNativeIds=async t=>{let e=t.length,i=new It({matchIds:t,limit:e}),r=await this.getMatches(i);return r.data.sort((a,s)=>a.id.localeCompare(s.id)),await this.idMapping.remapEntities(r.data,"match")};getMatchesMapWithNativeIds=async t=>{let e={},i=Lt(t);i.sort((a,s)=>a.localeCompare(s));let r=await this.getMatchesWithNativeIds(Array.from(i));if(i.length!==r.length){let a=new It({matchIds:i,limit:i.length}),s=await this.getMatches(a),l=i.filter(n=>{if(s.data.every(p=>p.id!==n))return n});i=i.filter(n=>{if(!l.includes(n))return n})}return i.forEach((a,s)=>e[a]=r[s]),e};getMatches=async(t,e)=>{try{return e=e||!1,await this.https.getMatches(t,e)}catch(i){throw console.warn("There was a problem retrieving the matches",i),i}};getMatchIdMapping=async(t,e)=>{try{let i=await this.idMapping.getEntityIdsBySchemaId([t],"match","native"),r=await this.getMatchById(i.match[0],e),a=await this.footballService.setAvailableMarketsForMatch(r);return await this.idMapping.remapEntities(a,"match")}catch(i){throw console.warn(`There was a problem browsing the following match: ${t}`,i),i}};getMatchById=async(t,e)=>{try{return e=e||!1,await this.https.getMatchById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the following match: ${t}`,i),i}}};var _r=class{entities=null;query=null;scope=null;constructor(t){this.entities=t.entities?t.entities:null,this.query=t.query?t.query:null,this.scope=t.scope?t.scope:null}constructFilterUrl=()=>{let t="";return this.entities&&(t=t+"&",t=t+`entities=${this.entities.join(",")}`),this.query&&(t=t+"&",t=t+`q=${this.query}`),this.scope&&(t=t+"&",t=t+`scope=${this.scope.join(",")}`),t}};var Tr=class{https=null;idMapping=null;constructor(t,e){this.https=t,this.idMapping=e}searchIdMapping=async(t,e)=>{try{if(t=new _r(t),t.scope){let r=await this.idMapping.getEntityIdsBySchemaId(t.scope,"competition","native");t.scope=r.competition}let i=await this.search(t,e);if(i.teams&&i.teams.length>0){let r=await this.idMapping.remapEntities(i.teams,"team");i.teams=r}if(i.players&&i.players.length>0){let r=await this.idMapping.remapEntities(i.players,"player");i.players=r}if(i.competitions&&i.competitions.length>0){let r=await this.idMapping.remapEntities(i.competitions,"competition");i.competitions=r}return i}catch(i){throw console.warn("There was a problem with browsing the search result",i),i}};search=async(t,e)=>{try{return await this.https.search(t,e)}catch(i){throw console.warn("There was a problem retrieving the search response",i),i}}};var ie=class{countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(t,e,i,r){this.countriesFacade=new zi(e,i,r),this.competitionsFacade=new qi(e,i,r),this.teamsFacade=new Pr(t,i,r),this.playerFacade=new wt(t,i,r),this.matchFacade=new Pt(t,i,r),this.searchFacade=new Tr(i,r)}getCountries=async t=>this.countriesFacade.getCountriesWithIdMapping(t);getCompetitions=async(t,e)=>this.competitionsFacade.getCompetitionsIdMapping(t,e);getCompetitionById=async(t,e)=>this.competitionsFacade.getCompetitionByIdIdMapping(t,e);getTopCompetitions=async t=>this.competitionsFacade.getTopCompetitionsIdMapping(t);getCompetitionsMapWithNativeIds=async t=>await this.competitionsFacade.getCompetitionsMapWithNativeIds(t);getTeams=async(t,e)=>this.teamsFacade.getTeamsIdMapping(t,e);getTeamById=async(t,e)=>this.teamsFacade.getTeamByIdIdMapping(t,e);getTopTeams=async t=>this.teamsFacade.getTopTeamsIdMapping(t);getNextMatchForTeam=async(t,e)=>this.teamsFacade.getNextMatchForTeamIdMapping(t,e);getPrevMatchForTeam=async(t,e)=>this.teamsFacade.getPrevMatchForTeamIdMapping(t,e);getTeamsMapWithNativeIds=async t=>await this.teamsFacade.getTeamsMapWithNativeIds(t);getPlayers=async(t,e)=>this.playerFacade.getPlayersIdMapping(t,e);getPlayerById=async(t,e)=>this.playerFacade.getPlayerIdMapping(t,e);getTopPlayers=async t=>this.playerFacade.getTopPlayersIdMapping(t);getNextMatchForPlayer=async(t,e)=>this.playerFacade.getNextMatchForPlayerIdMapping(t,e);getPrevMatchForPlayer=async(t,e)=>this.playerFacade.getPrevMatchForPlayerIdMapping(t,e);getPlayersMapWithNativeIds=async t=>this.playerFacade.getPlayersMapWithNativeIds(t);getMatches=async(t,e)=>this.matchFacade.getMatchesIdMapping(t,e);getMatchesMapWithNativeIds=async t=>this.matchFacade.getMatchesMapWithNativeIds(t);getMatchById=async(t,e)=>this.matchFacade.getMatchIdMapping(t,e);search=async(t,e)=>this.searchFacade.searchIdMapping(t,e)};var vr=class{id="";alias="";countryCode="";assets=null;name=""};var A=class{countriesFromResponse=t=>{if(t)return t.map(e=>this.countryFromResponse(e))};countryFromResponse=t=>{try{if(t){let e=new vr;return e.id=t.id,e.alias=t.alias,e.assets=t.assets,e.countryCode=t.country_code,e.name=t.name,e}}catch(e){throw e}return null}};var Fr=class{id="";country=null;gender="";assets=null;type="";name=""};var $=class{countryRemapper=null;constructor(){this.countryRemapper=new A}fromResponse(t){try{let e=new Fr;return e.id=t.id,e.country=this.countryRemapper.countryFromResponse(t.country),e.gender=t.gender,e.assets=t.assets,e.type=t.type,e.name=t.name,e}catch(e){throw console.warn("There was a problem remapping the competition response",e),e}}};var Er=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var Sr=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;undecided=!1;fullName="";shortName="";isDeleted=!1};var k=class{countryRemapper=null;constructor(){this.countryRemapper=new A}fromResponse(t){try{let e=new Sr;return e.id=t.id,e.country=this.countryRemapper.countryFromResponse(t.country),e.gender=t.gender,e.assets=t.assets,e.code=t.code,e.national=t.national,e.fullName=t.full_name,e.shortName=t.short_name,e.name=t.name,e.isDeleted=t.is_deleted,e.undecided=t.undecided,e}catch(e){throw console.warn("There was a problem remapping teams response",e),e}}};var Rr=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new A,this.teamBasicRemapper=new k}fromResponse(t){try{let e=new Er;return e.id=t.id,e.country=this.countryRemapper.countryFromResponse(t.country),e.gender=t.gender,e.assets=t.assets,e.type=t.type,e.name=t.name,e.participants=t.participants.map(i=>this.teamBasicRemapper.fromResponse(i)),e}catch(e){throw console.warn("There was a problem remapping the competition response",e),e}}};var Cr=class{primary=null;secondary=null;tertiary=null};var Ar=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";isDeleted=!1;undecided=!1;colors=new Cr;squad=[]};var Or=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var Lr=class{countryRemapper=null;constructor(){this.countryRemapper=new A}fromResponse(t){try{let e=new Or;return e.id=t.id,e.startDate=t.start_date,e.endDate=t.end_date,e.shirtNumber=t.shirt_number,e.loan=t.loan,e.position=t.position,e.country=this.countryRemapper.countryFromResponse(t.country),e.name=t.name,e.assets=t.assets,e.birthDate=t.birth_date,e}catch(e){throw console.warn("There was a problem remapping the player from squad",e),e}}};var xr=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new A,this.competitionRemapper=new $,this.playerRemapper=new Lr}fromResponse(t){try{let e=new Ar;return e.id=t.id,e.country=this.countryRemapper.countryFromResponse(t.country),e.gender=t.gender,e.assets=t.assets,e.code=t.code,e.national=t.national,e.fullName=t.full_name,e.shortName=t.short_name,e.name=t.name,e.isDeleted=t.is_deleted,e.undecided=t.undecided,e.competitions=t.competitions?t.competitions.map(i=>this.competitionRemapper.fromResponse(i)):[],e.colors=t.colors?t.colors:e.colors,e.squad=t.squad?t.squad.map(i=>this.playerRemapper.fromResponse(i)):[],e}catch(e){throw console.warn("There was a problem remapping team response",e),e}}};var Dr=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;homeTeam=null;awayTeam=null;isDeleted=!1;undecided=!1;lineupsConfirmed=!1;startedAt="";minute="";scores=null;context={competition:null};status={type:null,subType:null}};var Br=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var re=class{fromResponse(t){try{let e=new Br;return e.ftScore=this.statEntityFromResponse(t.ft_score),e.htScore=this.statEntityFromResponse(t.ht_score),e.aetScore=this.statEntityFromResponse(t.aet_score),e.aggScore=this.statEntityFromResponse(t.agg_score),e.penScore=this.statEntityFromResponse(t.pen_score),e}catch(e){throw console.warn("There was a problem remapping the scores",e),e}}statEntityFromResponse=t=>({homeGoals:t.home_goals,awayGoals:t.away_goals})};var Nr=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new k,this.competitionRemapper=new $,this.scoresRemapper=new re}fromResponse(t){try{let e=new Dr;return e.id=t.id,e.kickoffAt=t.kickoff_at,e.finishedAt=t.finished_at,e.updatedAt=t.updated_at,e.isDeleted=t.is_deleted,e.undecided=t.undecided,e.homeTeam=this.teamRemapper.fromResponse(t.home_team),e.awayTeam=this.teamRemapper.fromResponse(t.away_team),e.lineupsConfirmed=t.lineups_confirmed,e.startedAt=t.started_at,e.minute=t.minute,e.scores=this.scoresRemapper.fromResponse(t.scores),e.context={competition:t.context.competition?this.competitionRemapper.fromResponse(t.context.competition):null},e.status={type:t.status.type,subType:t.status.sub_type},e}catch(e){throw console.warn("There was a problem remapping the match response",e),e}}};var j=class{type=null;subType=null};var kr=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;isDeleted=!1;undecided=!1;homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;stats=null;playerStats=[];context={competition:null};timeline=[];status=new j;lineups=null};var Ur=class{corners=null;cornersFirstHalf=null;cornersSecondHalf=null;cornersExtraTime=null;crosses=null;crossesFirstHalf=null;crossesSecondHalf=null;crossesExtraTime=null;offside=null;offsideFirstHalf=null;offsideSecondHalf=null;offsideExtraTime=null;shotsOn=null;shotsOnFirstHalf=null;shotsOnSecondHalf=null;shotsOnExtraTime=null;throwIn=null;throwInFirstHalf=null;throwInSecondHalf=null;throwInExtraTime=null;redCards=null;redCardsFirstHalf=null;redCardsSecondHalf=null;redCardsExtraTime=null;shotsOff=null;shotsOffFirstHalf=null;shotsOffSecondHalf=null;shotsOffExtraTime=null;goalKicks=null;goalKicksFirstHalf=null;goalKicksSecondHalf=null;goalKicksExtraTime=null;possession=null;possessionFirstHalf=null;possessionSecondHalf=null;possessionExtraTime=null;treatments=null;treatmentsFirstHalf=null;treatmentsSecondHalf=null;treatmentsExtraTime=null;yellowCards=null;yellowCardsFirstHalf=null;yellowCardsSecondHalf=null;yellowCardsExtraTime=null;shotsBlocked=null;shotsBlockedFirstHalf=null;shotsBlockedSecondHalf=null;shotsBlockedExtraTime=null;substitutions=null;substitutionsFirstHalf=null;substitutionsSecondHalf=null;substitutionsExtraTime=null;counterAttacks=null;counterAttacksFirstHalf=null;counterAttacksSecondHalf=null;counterAttacksExtraTime=null;foulsCommitted=null;foulsCommittedFirstHalf=null;foulsCommittedSecondHalf=null;foulsCommittedExtraTime=null};var Gr=class{fromResponse(t){try{let e=new Ur;return e.corners=this.statEntityFromResponse(t.corners),e.cornersFirstHalf=this.statEntityFromResponse(t.corners_1h),e.cornersSecondHalf=this.statEntityFromResponse(t.corners_2h),e.cornersExtraTime=this.statEntityFromResponse(t.corners_et),e.crosses=this.statEntityFromResponse(t.crosses),e.crossesFirstHalf=this.statEntityFromResponse(t.crosses_1h),e.crossesSecondHalf=this.statEntityFromResponse(t.crosses_2h),e.crossesExtraTime=this.statEntityFromResponse(t.crosses_et),e.offside=this.statEntityFromResponse(t.offside),e.offsideFirstHalf=this.statEntityFromResponse(t.offside_1h),e.offsideSecondHalf=this.statEntityFromResponse(t.offside_2h),e.offsideExtraTime=this.statEntityFromResponse(t.offside_et),e.shotsOn=this.statEntityFromResponse(t.shots_on),e.shotsOnFirstHalf=this.statEntityFromResponse(t.shots_on_1h),e.shotsOnSecondHalf=this.statEntityFromResponse(t.shots_on_2h),e.shotsOnExtraTime=this.statEntityFromResponse(t.shots_on_et),e.throwIn=this.statEntityFromResponse(t.throw_in),e.throwInFirstHalf=this.statEntityFromResponse(t.throw_in_1h),e.throwInSecondHalf=this.statEntityFromResponse(t.throw_in_2h),e.throwInExtraTime=this.statEntityFromResponse(t.throw_in_et),e.redCards=this.statEntityFromResponse(t.red_cards),e.redCardsFirstHalf=this.statEntityFromResponse(t.red_cards_1h),e.redCardsSecondHalf=this.statEntityFromResponse(t.red_cards_2h),e.redCardsExtraTime=this.statEntityFromResponse(t.red_cards_et),e.shotsOff=this.statEntityFromResponse(t.shots_off),e.shotsOffFirstHalf=this.statEntityFromResponse(t.shots_off_1h),e.shotsOffSecondHalf=this.statEntityFromResponse(t.shots_off_2h),e.shotsOffExtraTime=this.statEntityFromResponse(t.shots_off_et),e.goalKicks=this.statEntityFromResponse(t.goal_kicks),e.goalKicksFirstHalf=this.statEntityFromResponse(t.goal_kicks_1h),e.goalKicksSecondHalf=this.statEntityFromResponse(t.goal_kicks_2h),e.goalKicksExtraTime=this.statEntityFromResponse(t.goal_kicks_et),e.possession=this.statEntityFromResponse(t.possession),e.possessionFirstHalf=this.statEntityFromResponse(t.possession_1h),e.possessionSecondHalf=this.statEntityFromResponse(t.possession_2h),e.possessionExtraTime=this.statEntityFromResponse(t.possession_et),e.treatments=this.statEntityFromResponse(t.treatments),e.treatmentsFirstHalf=this.statEntityFromResponse(t.treatments_1h),e.treatmentsSecondHalf=this.statEntityFromResponse(t.treatments_2h),e.treatmentsExtraTime=this.statEntityFromResponse(t.treatments_et),e.yellowCards=this.statEntityFromResponse(t.yellow_cards),e.yellowCardsFirstHalf=this.statEntityFromResponse(t.yellow_cards_1h),e.yellowCardsSecondHalf=this.statEntityFromResponse(t.yellow_cards_2h),e.yellowCardsExtraTime=this.statEntityFromResponse(t.yellow_cards_et),e.shotsBlocked=this.statEntityFromResponse(t.shots_blocked),e.shotsBlockedFirstHalf=this.statEntityFromResponse(t.shots_blocked_1h),e.shotsBlockedSecondHalf=this.statEntityFromResponse(t.shots_blocked_2h),e.shotsBlockedExtraTime=this.statEntityFromResponse(t.shots_blocked_et),e.substitutions=this.statEntityFromResponse(t.substitutions),e.substitutionsFirstHalf=this.statEntityFromResponse(t.substitutions_1h),e.substitutionsSecondHalf=this.statEntityFromResponse(t.substitutions_2h),e.substitutionsExtraTime=this.statEntityFromResponse(t.substitutions_et),e.counterAttacks=this.statEntityFromResponse(t.counter_attacks),e.counterAttacksFirstHalf=this.statEntityFromResponse(t.counter_attacks_1h),e.counterAttacksSecondHalf=this.statEntityFromResponse(t.counter_attacks_2h),e.counterAttacksExtraTime=this.statEntityFromResponse(t.counter_attacks_et),e.foulsCommitted=this.statEntityFromResponse(t.fouls_committed),e.foulsCommittedFirstHalf=this.statEntityFromResponse(t.fouls_committed_1h),e.foulsCommittedSecondHalf=this.statEntityFromResponse(t.fouls_committed_2h),e.foulsCommittedExtraTime=this.statEntityFromResponse(t.fouls_committed_et),e}catch(e){throw console.warn("There was a problem remapping the stats",e),e}}statEntityFromResponse=t=>({homeTeam:t?t.home_team:null,awayTeam:t?t.away_team:null})};var ae=class{homeTeam={players:[]};awayTeam={players:[]}};var Vr=class{id="";name="";position="";shirtNumber;assets=null;type=""};var oe=class{fromResponse(t){try{let e=new Vr;return e.id=t.id,e.name=t.name,e.position=t.position,e.shirtNumber=t.shirt_number,e.assets=t.assets,e.type=t.type,e}catch(e){throw console.warn("There was a problem remapping the player from timeline",e),e}}};var Hr=class{playerRemapper=null;constructor(){this.playerRemapper=new oe}fromResponse(t){try{let e=new ae;return e.homeTeam.players=t.home_team&&t.home_team.players?t.home_team.players.map(i=>this.playerRemapper.fromResponse(i)):[],e.awayTeam.players=t.away_team&&t.away_team.players?t.away_team.players.map(i=>this.playerRemapper.fromResponse(i)):[],e}catch(e){throw console.warn("There was a problem remapping the lineups",e),e}}};var $r=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var Wr=class{playerRemapper=null;constructor(){this.playerRemapper=new oe}fromResponse(t){try{let e=new $r;return e.minute=t.minute,e.type=t.type,e.teamId=t.team_id,e.player=this.playerRemapper.fromResponse(t.player),e.relatedPlayer=t.related_player?this.playerRemapper.fromResponse(t.related_player):null,e.updatedAt=t.updated_at,e}catch(e){throw console.warn("There was a problem remapping timeline",e),e}}};var zr=class{playerId=null;minutesPlayed=null;yellowCards=null;redCards=null;goals=null;penaltyGoals=null;penaltyCommitted=null;penaltyWon=null;penaltyMissed=null;penaltySaved=null;penaltyReceived=null;ownGoals=null;assists=null;cleanSheets=null;shots=null;shotsOn=null;shotsBlocked=null;offsides=null;foulsCommitted=null;foulsWon=null;tackles=null;tacklesBlocks=null;tacklesInterceptions=null;concededGoals=null;caughtBall=null;saves=null;passes=null;crosses=null;interceptions=null;keyPasses=null;passesAccuracy=null;duels=null;duelsWon=null;dribblesAttempts=null;dribblesSuccess=null;dribblesPast=null;updatedAt=null};var qr=class{fromResponse(t){try{let e=new zr;return e.playerId=t.player_id,e.minutesPlayed=t.minutes_played,e.yellowCards=t.yellow_cards,e.redCards=t.red_cards,e.goals=t.goals,e.penaltyGoals=t.penalty_goals,e.penaltyCommitted=t.penalty_committed,e.penaltyWon=t.penalty_won,e.penaltyMissed=t.penalty_missed,e.penaltySaved=t.penalty_saved,e.penaltyReceived=t.penalty_received,e.ownGoals=t.own_goals,e.assists=t.assists,e.cleanSheets=t.clean_sheets,e.shots=t.shots,e.shotsOn=t.shots_on,e.shotsBlocked=t.shots_blocked,e.offsides=t.offsides,e.foulsCommitted=t.fouls_committed,e.foulsWon=t.fouls_won,e.tackles=t.tackles,e.tacklesBlocks=t.tackles_blocks,e.tacklesInterceptions=t.tackles_interceptions,e.concededGoals=t.conceded_goals,e.caughtBall=t.caught_ball,e.saves=t.saves,e.passes=t.passes,e.crosses=t.crosses,e.interceptions=t.interceptions,e.keyPasses=t.key_passes,e.passesAccuracy=t.passes_accuracy,e.duels=t.duels,e.duelsWon=t.duels_won,e.dribblesAttempts=t.dribbles_attempts,e.dribblesSuccess=t.dribbles_success,e.dribblesPast=t.dribbles_past,e.updatedAt=t.updated_at,e}catch(e){throw console.warn("There was a problem remapping the player stats",e),e}}};var Qr=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;playerStatsMapper=null;constructor(){this.teamMapper=new k,this.competitionsMapper=new $,this.lineupsMapper=new Hr,this.scoresMapper=new re,this.statsMapper=new Gr,this.timelineMapper=new Wr,this.playerStatsMapper=new qr}fromResponse(t){try{let e=new kr;return e.id=t.id,e.kickoffAt=t.kickoff_at,e.finishedAt=t.finished_at,e.updatedAt=t.updated_at,e.isDeleted=t.is_deleted,e.undecided=t.undecided,e.homeTeam=t.home_team?this.teamMapper.fromResponse(t.home_team):null,e.awayTeam=t.away_team?this.teamMapper.fromResponse(t.away_team):null,e.lineupsConfirmed=t.lineups_confirmed,e.startedAt=t.started_at,e.minute=t.minute,e.scores=this.scoresMapper.fromResponse(t.scores),e.stats=this.statsMapper.fromResponse(t.stats),e.playerStats=t.player_stats?t.player_stats.map(i=>this.playerStatsMapper.fromResponse(i)):t.player_stats,e.context={competition:this.competitionsMapper.fromResponse(t.context.competition)},e.timeline=t.timeline?t.timeline.map(i=>this.timelineMapper.fromResponse(i)):[],e.status={type:t.status.type,subType:t.status.sub_type},e.lineups=t.lineups?this.lineupsMapper.fromResponse(t.lineups):new ae,e}catch(e){throw console.warn("There was a problem remapping the match response",e),e}}};var Kr=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var jr=class{countryRemapper=null;constructor(){this.countryRemapper=new A}fromResponse(t){try{let e=new Kr;return e.id=t.id,e.firstName=t.first_name?t.first_name:null,e.lastName=t.last_name?t.last_name:null,e.name=t.name?t.name:null,e.birthDate=t.birth_date,e.country=this.countryRemapper.countryFromResponse(t.country),e.assets=t.assets,e.position=t.position,e}catch(e){throw console.warn("There was a problem remapping top player response",e),e}}};var Xr=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;teams=[]};var se=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new A,this.teamRemapper=new k}fromResponse(t){try{let e=new Xr;return e.id=t.id,e.firstName=t.first_name?t.first_name:null,e.lastName=t.last_name?t.last_name:null,e.name=t.name?t.name:null,e.birthDate=t.birth_date,e.country=this.countryRemapper.countryFromResponse(t.country),e.assets=t.assets,e.teams=t.teams?t.teams.map(i=>this.teamRemapper.fromResponse(i)):[],e.position=t.position,e.isDeleted=t.is_deleted,e}catch(e){throw console.warn("There was a problem remapping players response",e),e}}};var Yr=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;competitions=[];teams=[]};var Jr=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new A,this.teamRemapper=new k,this.competitionRemapper=new $}fromResponse(t){try{let e=new Yr;return e.id=t.id,e.firstName=t.first_name?t.first_name:null,e.lastName=t.last_name?t.last_name:null,e.name=t.name?t.name:null,e.birthDate=t.birth_date,e.country=this.countryRemapper.countryFromResponse(t.country),e.assets=t.assets,e.teams=t.teams?t.teams.map(i=>this.teamRemapper.fromResponse(i)):[],e.position=t.position,e.isDeleted=t.is_deleted,e.competitions=t.competitions?t.competitions.map(i=>this.competitionRemapper.fromResponse(i)):[],e}catch(e){throw console.warn("There was a problem remapping player response",e),e}}};var Zr=class{teams=null;players=null;competitions=null};var ta=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new k,this.playerRemapper=new se,this.competitionremapper=new $}fromResponse(t){try{let e=new Zr;return e.teams=t.teams?t.teams.map(i=>this.teamRemapper.fromResponse(i)):[],e.players=t.players?t.players.map(i=>this.playerRemapper.fromResponse(i)):[],e.competitions=t.competitions?t.competitions.map(i=>this.competitionremapper.fromResponse(i)):[],e}catch(e){throw console.warn("There was a problem remapping search response",e),e}}};var Dt=class{meta=new H;data=[]};var ea=class{remapMetaProp=t=>{let e=new H;return e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.totalItems=t.pagination.total_items,e.pagination.numberOfPages=t.pagination.number_of_pages,e}};var ia=class{templateId=null;playerId=null};var ra=class{filters=new ia};var aa=class{meta=new ra;data=[]};var oa=class{templateId=null};var sa=class{filters=new oa};var na=class{meta=new sa;data=[]};var ne=class{total=null;minutesPlayed=null;yellowCards=null;redCards=null;goals=null;penaltyGoals=null;ownGoals=null;assists=null;cleanSheets=null;shots=null;shotsOn=null;offsides=null;foulsCommitted=null;penaltyCommitted=null;penaltyWon=null;penaltyMissed=null;tackles=null;concededGoals=null;caughtBall=null;saves=null};var le=class{minutesPlayed=null;yellowCards=null;redCards=null;goals=null;penaltyGoals=null;penaltyCommitted=null;penaltyWon=null;penaltyMissed=null;penaltySaved=null;penaltyReceived=null;ownGoals=null;assists=null;cleanSheets=null;shots=null;shotsOn=null;shotsBlocked=null;offsides=null;foulsCommitted=null;foulsWon=null;tackles=null;tacklesBlocks=null;tacklesInterceptions=null;concededGoals=null;caughtBall=null;saves=null;passes=null;crosses=null;interceptions=null;keyPasses=null;passesAccuracy=null;duels=null;duelsWon=null;dribblesAttempts=null;dribblesSuccess=null;dribblesPast=null};var la=class{matchId=null;matchModel=null;points=new ne;stats=new le};var pa=class{playerId=null;playerModel=null;points=null;rank=null};var ca=class{remapPlayersPoints=t=>{let e=new na;return e.meta.filters.templateId=t.meta.filters.template_id,e.data=t.data.map(i=>this.remapPlayersPointsData(i)),e};remapPlayersPointsData=t=>{let e=new pa;return e.playerId=t.player_id,e.points=t.points,e.rank=t.rank,e};remapPlayerDetailedStats=t=>{let e=new aa;return e.meta.filters.templateId=t.meta.filters.template_id,e.meta.filters.playerId=t.meta.filters.player_id,e.data=t.data.map(i=>this.remapPlayerDetailedData(i)),e};remapPlayerDetailedData=t=>{let e=new la;return e.matchId=t.match_id,e.points=t.points?this.remapPlayerDetailedPoints(t.points):null,e.stats=t.stats?this.remapPlayerDetailedStatsData(t.stats):null,e};remapPlayerDetailedPoints=t=>{let e=new ne;return e.total=t.total,e.minutesPlayed=t.minutes_played,e.yellowCards=t.yellow_cards,e.redCards=t.red_cards,e.goals=t.goals,e.penaltyGoals=t.penalty_goals,e.ownGoals=t.own_goals,e.assists=t.assists,e.cleanSheets=t.clean_sheets,e.shots=t.shots,e.shotsOn=t.shots_on,e.offsides=t.offsides,e.foulsCommitted=t.fouls_committed,e.penaltyCommitted=t.penalty_committed,e.penaltyWon=t.penalty_won,e.penaltyMissed=t.penalty_missed,e.tackles=t.tackles,e.concededGoals=t.conceded_goals,e.caughtBall=t.caught_ball,e.saves=t.saves,e};remapPlayerDetailedStatsData=t=>{let e=new le;return e.minutesPlayed=t.minutes_played,e.yellowCards=t.yellow_cards,e.redCards=t.red_cards,e.goals=t.goals,e.penaltyGoals=t.penalty_goals,e.penaltyCommitted=t.penalty_committed,e.penaltyWon=t.penalty_won,e.penaltyMissed=t.penalty_missed,e.penaltySaved=t.penalty_saved,e.penaltyReceived=t.penalty_received,e.ownGoals=t.own_goals,e.assists=t.assists,e.cleanSheets=t.clean_sheets,e.shots=t.shots,e.shotsOn=t.shots_on,e.shotsBlocked=t.shots_blocked,e.offsides=t.offsides,e.foulsCommitted=t.fouls_committed,e.foulsWon=t.fouls_won,e.tackles=t.tackles,e.tacklesBlocks=t.tackles_blocks,e.tacklesInterceptions=t.tackles_interceptions,e.concededGoals=t.conceded_goals,e.caughtBall=t.caught_ball,e.saves=t.saves,e.passes=t.passes,e.crosses=t.crosses,e.interceptions=t.interceptions,e.keyPasses=t.key_passes,e.passesAccuracy=t.passes_accuracy,e.duels=t.duels,e.duelsWon=t.duels_won,e.dribblesAttempts=t.dribbles_attempts,e.dribblesSuccess=t.dribbles_success,e.dribblesPast=t.dribbles_past,e}};var X=class extends T{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;fantasyRemapper=null;footballService=null;constructor(t){super(t,S(t.environment,"football")),this.apiSignInUrl=t.lang!=="en"?this.apiSignInUrl+`&lang=${t.lang}`:this.apiSignInUrl,this.countryRemapper=new A,this.competitionBasicRemapper=new $,this.competitionFullRemapper=new Rr,this.teamBasicRemapper=new k,this.teamFullRemapper=new xr,this.matchBasicRemapper=new Nr,this.matchFullRemapper=new Qr,this.playerBasicRemapper=new se,this.playerFullRemapper=new Jr,this.topPlayerRemapper=new jr,this.searchRemapper=new ta,this.footballMetaRemapper=new ea,this.footballService=new pt(t),this.fantasyRemapper=new ca}getCountries=async t=>{let e="There was a problem with the football countries request",i=`/countries${this.apiSignInUrl}`,r=Date.now();t&&(i+=`&disable_cache=${r}`);let a=await this.fetchWithoutAuth(i,e);return this.countryRemapper.countriesFromResponse(a.data)};getCompetitions=async(t,e)=>{let i=Date.now(),r="There was a problem with football competitions request";if(e=e||!1,t&&t.competitionIds&&t.competitionIds.length>this.limitIds-1){let a=[],s=$t(t.competitionIds,this.limitIds);for(let n of s){t.competitionIds=n;let p=`/competitions${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(p+=`&disable_cache=${i}`);let c=await this.fetchWithoutAuth(p,r);a.push(c.data.map(u=>this.competitionBasicRemapper.fromResponse(u)))}return Array.prototype.concat.apply([],a)}else{let a=`/competitions${this.apiSignInUrl}`;return t&&(a+=`${t.constructFilterUrl()}`),e&&(a+=`&disable_cache=${i}`),(await this.fetchWithoutAuth(a,r)).data.map(l=>this.competitionBasicRemapper.fromResponse(l))}};getCompetitionById=async(t,e)=>{let i=`/competitions/${t}${this.apiSignInUrl}`,r="There was a problem with football competition by ID request",a=Date.now();e&&(i+=`&disable_cache=${a}`);let s=await this.fetchWithoutAuth(i,r);return this.competitionFullRemapper.fromResponse(s.data)};getTopCompetitions=async t=>{let e="There was a problem with top football competitions request",i=`/competitions/top${this.apiSignInUrl}`,r=Date.now();return t&&(i+=`&disable_cache=${r}`),(await this.fetchWithoutAuth(i,e)).data.map(s=>this.competitionBasicRemapper.fromResponse(s))};getTeams=async(t,e)=>{let i=Date.now(),r="There was a problem with football teams request";if(t&&t.teamIds&&t.teamIds.length>this.limitIds){let a=[],s=$t(t.teamIds,this.limitIds);for(let n of s){t.teamIds=n;let p=`/teams${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(p+=`disable_cache=${i}`);let c=await this.fetchWithoutAuth(p,r);a.push(c.data.map(u=>this.teamBasicRemapper.fromResponse(u)))}return Array.prototype.concat.apply([],a)}else{let a=new Dt,s=`/teams${this.apiSignInUrl}`;t&&(s+=`${t.constructFilterUrl()}`),e&&(s+=`&disable_cache=${i}`);let l=await this.fetchWithoutAuth(s,r);return a.meta=this.footballMetaRemapper.remapMetaProp(l.meta),a.data=l.data.map(n=>this.teamBasicRemapper.fromResponse(n)),a}};getTeamById=async(t,e)=>{let i="There was a problem with football team by ID request",r=`/teams/${t}${this.apiSignInUrl}`,a=Date.now();e&&(r+=`disable_cache=${a}`);let s=await this.fetchWithoutAuth(r,i);return this.teamFullRemapper.fromResponse(s.data)};getTopTeams=async t=>{let e=`/teams/top${this.apiSignInUrl}`,i="There was a problem with top football teams request",r=Date.now();t&&(e+=`$disable_cache=${r}`);let a=await this.fetchWithoutAuth(e,i);return a.data?a.data.map(s=>this.teamBasicRemapper.fromResponse(s)):[]};getNextMatchForTeam=async(t,e)=>{let i=`/teams/${t}/next-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with next match for team request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getPrevMatchForTeam=async(t,e)=>{let i=`/teams/${t}/previous-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with previous match for team request";e&&(i+=`disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getPlayers=async(t,e)=>{let i=Date.now(),r="There was a problem with football players request";if(t&&t.playerIds&&t.playerIds.length>this.limitIds-1){let a=[],s=$t(t.playerIds,this.limitIds);for(let p of s){t.playerIds=p;let c=`/players${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(c+=`&disable_cache=${i}`);let u=await this.fetchWithoutAuth(c,r);a.push(u.data.map(d=>this.teamBasicRemapper.fromResponse(d)))}let l=Array.prototype.concat.apply([],a),n=new Dt;return n.data=l,n}else{let a=new Dt,s=`/players${this.apiSignInUrl}`;t&&(s+=`${t.constructFilterUrl()}`),e&&(s+=`&disable_cache=${i}`);let l=await this.fetchWithoutAuth(s,r);return a.meta=this.footballMetaRemapper.remapMetaProp(l.meta),a.data=l.data.map(n=>this.playerBasicRemapper.fromResponse(n)),a}};getPlayerById=async(t,e)=>{let i=`/players/${t}${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with football player by ID request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.playerFullRemapper.fromResponse(s.data)};getTopPlayers=async t=>{let e=`/players/top${this.apiSignInUrl}`,i=Date.now(),r="There was a problem with top football players request";return t&&(e+=`&disable_cache=${i}`),(await this.fetchWithoutAuth(e,r)).data.map(s=>this.topPlayerRemapper.fromResponse(s))};getNextMatchForPlayer=async(t,e)=>{let i=`/players/${t}/next-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with next match for player request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getPrevMatchForPlayer=async(t,e)=>{let i=`/players/${t}/previous-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with previous match for player request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getMatchById=async(t,e)=>{let i=`/matches/${t}${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with match by ID request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getMatches=async(t,e)=>{let i=new Dt,r="There was a problem with football matches request";if(t&&t.matchIds&&t.matchIds.length>this.limitIds){let a=[],s=$t(t.matchIds,this.limitIds);for(let n of s){t.matchIds=n;let p=!0,c=`/matches${this.apiSignInUrl}${t.constructFilterUrl(p)}&limit=${n.length}`;e&&(c+=h());let u=await this.fetchWithoutAuth(c,r);a.push(u.data.map(d=>this.matchBasicRemapper.fromResponse(d)))}let l=Array.prototype.concat.apply([],a);return i.meta=this.footballService.setMetaDataBatchRequest(l.length,t.limit||20,t.page||1),i.data=this.footballService.finalizeMatchesDataBatchRequest(l,t),i}else{let a=`/matches${this.apiSignInUrl}`;t&&(a+=`${t.constructFilterUrl()}`),e&&(a+=h());let s=await this.fetchWithoutAuth(a,r);return i.meta=this.footballMetaRemapper.remapMetaProp(s.meta),i.data=s.data.map(l=>this.matchBasicRemapper.fromResponse(l)),i}};search=async(t,e)=>{let i=`/search${this.apiSignInUrl}${t.constructFilterUrl()}`,r=Date.now(),a="There was a problem with football search request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.searchRemapper.fromResponse(s.data)};getPlayersPoints=async(t,e,i)=>{let r=`/players/points/${t}${this.apiSignInUrl}`,a=Date.now(),s="There was a problem with players points request";e&&(r+=`&position=${e.toLocaleLowerCase()}`),i&&(r+=`&disable_cache=${a}`);let l=await this.fetchWithoutAuth(r,s);return this.fantasyRemapper.remapPlayersPoints(l)};getPlayerDetailedStatistics=async(t,e,i)=>{let r=`/players/${e}/points/${t}${this.apiSignInUrl}`,a=Date.now(),s="There was a problem with detailed player points request";i&&(r+=`&disable_cache=${a}`);let l=await this.fetchWithoutAuth(r,s);return this.fantasyRemapper.remapPlayerDetailedStats(l)}};var Y=(y=>(y.FT_1X2="FT_1X2",y.HT_1X2="HT_1X2",y.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",y.DOUBLE_CHANCE="DOUBLE_CHANCE",y.HT_FT="HT_FT",y.PLAYER_SCORE="PLAYER_SCORE",y.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",y.PLAYER_RED_CARD="PLAYER_RED_CARD",y.RED_CARD_MATCH="RED_CARD_MATCH",y.PENALTY_MATCH="PENALTY_MATCH",y.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",y.CORNERS_MATCH="CORNERS_MATCH",y.CORRECT_SCORE="CORRECT_SCORE",y.CORRECT_SCORE_ADVANCED="CORRECT_SCORE_ADVANCED",y.CORRECT_SCORE_HT="CORRECT_SCORE_HT",y.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",y.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",y.OVER_GOALS_0_5="OVER_GOALS_0_5",y.OVER_GOALS_1_5="OVER_GOALS_1_5",y.OVER_GOALS_2_5="OVER_GOALS_2_5",y.OVER_GOALS_3_5="OVER_GOALS_3_5",y.OVER_GOALS_4_5="OVER_GOALS_4_5",y.OVER_GOALS_5_5="OVER_GOALS_5_5",y.OVER_GOALS_6_5="OVER_GOALS_6_5",y.OVER_CORNERS_6_5="OVER_CORNERS_6_5",y.OVER_CORNERS_7_5="OVER_CORNERS_7_5",y.OVER_CORNERS_8_5="OVER_CORNERS_8_5",y.OVER_CORNERS_9_5="OVER_CORNERS_9_5",y.OVER_CORNERS_10_5="OVER_CORNERS_10_5",y.OVER_CORNERS_11_5="OVER_CORNERS_11_5",y.OVER_CORNERS_12_5="OVER_CORNERS_12_5",y.OVER_CORNERS_13_5="OVER_CORNERS_13_5",y))(Y||{}),wl=["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"],Il=["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"],ct=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"],Pl=["FT_1X2","HT_1X2","HT_FT","DOUBLE_CHANCE","CORNERS_MATCH","CORRECT_SCORE","CORRECT_SCORE_HT","CORRECT_SCORE_ADVANCED"],bi="PLAYER_SCORE_FIRST_GOAL";var ua=class{id="";achievedAt=""};var pe=class{participationCount=null;points=null};var ce=class{totalPoints=null;postPoints=null;postsMade=null;reactionPoints=null;reactionCount=null};var ue=class{participationCount=null};var Mi=class{participations=0;points=0};var Bt=class{footballCompetitions=[];footballTeams=[]};var de=class{predictionsMade=0;correct=0;points=0;breakdown=new Bt};var me=class{single=new de;topX=new Mi;matchQuiz=new Mi};var da=class{overallPercent;byFootballCompetition;byFootballTeam;byFootballMarket};var ma=class{profileId;tier;points;predictionsMade;successRates=new da;predictions=new me;tiers=[];badges=[];discussions=new ce;classicQuizzes=new pe;eitherOr=new ue};var ha=class{entityId="";entityType="";entitySource="";model=null;predictionsMade=0;correct=0;points=0};var ga=class{successRatePercent;model=null};var _t=class{content=null;tags=[];campaign=null};var he=class{id=null;profileId=null;property=null;value=null;action=null;context=new _t;points=0};var fa=class{meta=new H;data=[new he]};var ya=class{remapSingleResponse=t=>{let e=new he;return e.id=t.id,e.profileId=t.profile_id,e.property=t.property,e.value=t.value,e.action=t.action,e.context.content=t.context.content,e.context.tags=t.context.tags,e.context.campaign=t.context.campaign,e.points=t.points,e};remapActivitiesResponse=t=>{let e=new fa;return e.meta.pagination.currentPage=t.meta.pagination.current_page,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.meta.pagination.numberOfPages=t.meta.pagination.number_of_pages,e.meta.pagination.totalItems=t.meta.pagination.total_items,e.data=t.data.map(i=>this.remapSingleResponse(i)),e};remapStatsResponse=t=>{let e=new ma;return e.profileId=t.profile_id,e.tier=t.tier,e.points=t.points,e.predictionsMade=t.predictions_made,e.successRates.overallPercent=t.success_rates.overall_percent,e.successRates.byFootballCompetition=this.constructNewRecord(t.success_rates.by_competition),e.successRates.byFootballTeam=this.constructNewRecord(t.success_rates.by_team),e.successRates.byFootballMarket=this.constructNewRecord(t.success_rates.by_market),e.predictions=t.predictions?this.remapPredictionsStats(t.predictions):null,e.tiers=t.tiers?this.remapAchievementsStats(t.tiers):null,e.badges=t.badges?this.remapAchievementsStats(t.badges):null,e.discussions=t.discussions?this.remapDiscussionStats(t.discussions):null,e.classicQuizzes=t.classic_quizzes?this.remapClassicQuizStats(t.classic_quizzes):null,e.eitherOr=t.either_or?this.remapEitherOrStats(t.either_or):null,e};constructNewRecord=t=>{let e;if(Object.entries(t).length)Object.entries(t).forEach(([i,r])=>{e={...e,[i]:this.remapSuccessRatePercent(r)},Y[i]&&delete e[i].model});else return t;return e};remapSuccessRatePercent=t=>{let e=new ga;return e.successRatePercent=t.success_rate_percent,e};remapPredictionsStats=t=>{let e=new me;return e.single=this.remapSinglePredictionsStats(t.single),e.topX=t.top_x,e.matchQuiz=t.match_quiz,e};remapSinglePredictionsStats=t=>{let e=new de;return e.predictionsMade=t.predictions_made,e.correct=t.correct,e.points=t.points,e.breakdown=this.remapBreakdownSinglePredictionsStats(t.breakdown),e};remapBreakdownSinglePredictionsStats=t=>{if(t&&Object.keys(t).length){let e=new Bt,i=[],r=[];return Object.keys(t).forEach(a=>{let s=new ha;s.entityId=a,s.entityType=t[a].entity_type,s.entitySource=t[a].entity_source,s.predictionsMade=t[a].predictions_made,s.correct=t[a].correct,s.points=t[a].points,s.entityType==="competition"?i.push(s):s.entityType==="team"&&r.push(s)}),e.footballCompetitions=i,e.footballTeams=r,e}return new Bt};remapAchievementsStats=t=>t.map(e=>{let i=new ua;return i.id=e.id,i.achievedAt=e.achieved_at,i});remapDiscussionStats=t=>{let e=new ce;return e.totalPoints=t.total_points,e.postPoints=t.post_points,e.postsMade=t.posts_made,e.reactionPoints=t.reaction_points,e.reactionCount=t.reaction_count,e};remapClassicQuizStats=t=>{let e=new pe;return e.participationCount=t.participation_count,e.points=t.points,e};remapEitherOrStats=t=>{let e=new ue;return e.participationCount=t.participation_count,e}};var ge=class extends T{activityRemapper=null;constructor(t){super(t,S(t.environment,"loyalty")),this.activityRemapper=new ya}createActivity=async t=>{let e=`/activities${this.apiSignInUrl}`,i="There was a problem with creating activity",r="POST",a=await this.fetchWithAuth(e,i,r,t);return this.activityRemapper.remapSingleResponse(a)};deleteActivity=async t=>{let e=`/activities/${t}${this.apiSignInUrl}`,i=`There was a problem deleting the following activity: ${t}`,r="DELETE";return await this.fetchWithAuth(e,i,r),!0};getOwnActivities=async(t,e)=>{let i=`/activities${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with fetching own activities";t&&(i+=`${t.constructFilterUrl()}`),e&&(i+=`disable_cache=${r}`);let s=await this.fetchWithAuth(i,a);return this.activityRemapper.remapActivitiesResponse(s)};getActivitiesForUser=async(t,e,i)=>{let r=`/users/${t}/activities${this.apiSignInUrl}`,a=Date.now(),s=`There was a problem with fetching activities for user: ${t}`;e&&(r+=`${e.constructFilterUrl()}`),i&&(r+=`disable_cache=${a}`);let l=await this.fetchWithoutAuth(r,s);return this.activityRemapper.remapActivitiesResponse(l)};getStats=async(t,e)=>{let i="",r="",a=null;return t?(i+=w(e)?`/users/${t}/statistics${this.apiSignInUrl}${h()}`:`/users/${t}/statistics${this.apiSignInUrl}`,r=`There was a problem fetching statistics for profile: ${t}`,a=await this.fetchWithoutAuth(i,r)):(i+=`/statistics${this.apiSignInUrl}`,r="There was a problem fetching profile`s statistics",a=await this.fetchWithAuth(i,r)),this.activityRemapper.remapStatsResponse(a.data)}};var ba=class{id="";source="";type="";favourite=!1};var Ma=class extends ba{model=null};var wa=class{idMapping=null;idSchema=null;native="native";footballFacade=null;constructor(t,e,i){this.idMapping=i,this.idSchema=t.idSchema,this.footballFacade=e}remapProfileStats=async t=>{if(!t.predictions)return t;let{successRates:e,predictions:i}=t,r={competition:this.getIdsKeys(e.byFootballCompetition,i.single.breakdown.footballCompetitions),team:this.getIdsKeys(e.byFootballTeam,i.single.breakdown.footballTeams)};if(Object.values(r.competition).length){let a=JSON.parse(JSON.stringify(t.successRates.byFootballCompetition)),s=await this.getEntitiesMap(r.competition,"competition"),l=await this.setSuccessRatesModels(a,s);t.successRates.byFootballCompetition=l,i.single.breakdown.footballCompetitions=this.reconstructBreakdown(i.single.breakdown.footballCompetitions,s)}if(Object.values(r.team).length){let a=JSON.parse(JSON.stringify(t.successRates.byFootballTeam)),s=await this.getEntitiesMap(r.team,"team"),l=await this.setSuccessRatesModels(a,s);t.successRates.byFootballTeam=l,i.single.breakdown.footballTeams=this.reconstructBreakdown(i.single.breakdown.footballTeams,s)}return t};setSuccessRatesModels=async(t,e)=>{let i;return this.reconstructRecords(t,i,e)};getEntitiesMap=async(t,e)=>{switch(e){case"competition":return await this.footballFacade.getCompetitionsMapWithNativeIds(t);case"team":return await this.footballFacade.getTeamsMapWithNativeIds(t)}};reconstructRecords=(t,e,i)=>t&&Object.keys(t).length?(Object.keys(t).forEach(r=>{let a=i.get(r);e={...e,[a.id]:t[r]},e[a.id].model=a}),e):t;reconstructBreakdown=(t,e)=>t.length?t.map(i=>{let r=e.get(i.entityId);return i.entityId=r.id,i.model=r,i}):t;getIdsKeys=(t,e)=>{let i=Object.keys(t);if(e.length){let r=e.map(a=>a.entityId);return Array.from(new Set([...i,...r]))}return i};remapInterestsToIdSchema=async t=>{if(this.idSchema!==this.native)if(t&&t.length>0){let e={},i={},r=t.filter(n=>n.source.toLocaleUpperCase()==="FOOTBALL"),a=t.filter(n=>n.source.toLocaleUpperCase()!=="FOOTBALL");r.forEach(n=>{e.hasOwnProperty(n.type)||(e[n.type]=[],i[n.type]=[]),e[n.type].push(n.id),i[n.type].push(n)});let s=await this.remapIdsObj(e,this.native,this.idSchema),l=[];for(let[n,p]of Object.entries(i))p.forEach((c,u)=>{c.id=s[n][u],l.push(c)});return l.concat(a)}else return t;return t};remapInterestToNative=async t=>{if(this.idSchema!==this.native&&t.source.toLocaleUpperCase()==="FOOTBALL"){let e={},{id:i,type:r}=t;e[r]=[i];let a=await this.remapIdsObj(e,this.idSchema,this.native);return t.id=a[r][0],t}return t};inquiryCustomInterests=(t,e)=>{let i=[];return t&&t.length>0&&(i=t.filter(r=>r.source.toLocaleUpperCase()==="CUSTOM"),e)?i.map(r=>{let a=new Ma;return a.id=r.id,a.type=r.type,a.source=r.source,a.favourite=r.favourite,a}):i};remapInterests=async t=>{let i=this.inquiryCustomInterests(t,!1);if(i&&i.length>0){let r=t.filter(s=>s.source.toLocaleUpperCase()!=="CUSTOM"),a=await this.remapInterestsToIdSchema(r);return i.forEach(s=>a.push(s)),a}return await this.remapInterestsToIdSchema(t)};showFullInterests=async t=>{let e=[];if(t&&t.length>0){let r=this.inquiryCustomInterests(t,!0);e.push(r);let a=t.filter(c=>c.source.toLocaleUpperCase()!=="CUSTOM"),{competitionsMap:s,teamsMap:l,playersMap:n}=await this.getInterestsEntitiesMap(a),p=a.map(c=>{let u=null;if(c.source.toLocaleUpperCase()==="FOOTBALL"){if(c.type==="competition")return u=s.get(c.id),u&&(c.id=u.id),c.model=u,c;if(c.type==="team")return u=l.get(c.id),u&&(c.id=u.id),c.model=u,c;if(c.type==="player")return n?(c.model=n[c.id],c.id=n[c.id].id):c.model=u,c}else return c.model=u,c});return e.push(p),e.flat()}return e};getInterestsEntitiesMap=async t=>{let e=[],i=[],r=[],a=new Map,s=new Map,l=null;return t.forEach(n=>{n.type==="competition"&&n.source.toLocaleUpperCase()==="FOOTBALL"?e.push(n.id):n.type==="team"&&n.source.toLocaleUpperCase()==="FOOTBALL"?i.push(n.id):n.type==="player"&&n.source.toLocaleUpperCase()==="FOOTBALL"&&r.push(n.id)}),e.length&&(a=await this.footballFacade.getCompetitionsMapWithNativeIds(e)),i.length&&(s=await this.footballFacade.getTeamsMapWithNativeIds(i)),r.length&&(l=await this.footballFacade.getPlayersMapWithNativeIds(r)),{competitionsMap:a,teamsMap:s,playersMap:l}};remapIdsObj=async(t,e,i)=>await this.idMapping.idMappingFacade.getEntitiesByIds(t,e,i)};var Ia=class{idMapping=null;profileOperations=null;constructor(t,e){this.idMapping=new P(t),this.profileOperations=new wa(t,e,this.idMapping)}remapProfileStats=async t=>await this.profileOperations.remapProfileStats(t);remapInterestToNative=async t=>await this.profileOperations.remapInterestToNative(t);remapInterests=async t=>await this.profileOperations.remapInterests(t);showFullInterests=async t=>await this.profileOperations.showFullInterests(t)};var O=class{idsRemapper=null;profileHttps=null;activityHttps=null;footballHttps=null;footballFacade=null;idMapping=null;localCache=null;profileFacade=null;ownProfileBuilder=null;profileBuilder=null;constructor(t){this.profileHttps=new Wt(t),this.activityHttps=new ge(t),this.footballHttps=new X(t),this.idMapping=new P(t),this.localCache=new K().createLocalCacheInstance(t.idSchema),this.footballFacade=new ie(t,this.localCache,this.footballHttps,this.idMapping),this.profileFacade=new lt(this.localCache,this.profileHttps,this.activityHttps),this.idsRemapper=new Ia(t,this.footballFacade),this.ownProfileBuilder=new $i(t,this.idsRemapper,this.localCache,this.profileHttps,this.activityHttps),this.profileBuilder=new Wi(this.idsRemapper,this.localCache,this.profileHttps,this.activityHttps)}getOwn=()=>this.ownProfileBuilder;getById=t=>this.profileBuilder.setId(t);getCountries=async t=>await this.profileFacade.getCountries(t);getByIds=async(t,e,i)=>await this.profileFacade.getByIds(t,e,i)};var vn=(g=>(g.EN="en",g.BG="bg",g.RO="ro",g.EL="el",g.SK="sk",g.PT="pt",g.SR="sr",g.HU="hu",g.SV="sv",g.ES="es",g.FR="fr",g.NL="nl",g.DE="de",g.IT="it",g))(vn||{});var Pa=class{validate=t=>{let e=this.validateField(t.lang),i=this.generateMessage(e);return{validation:e,message:i}};validateField=t=>{let e=Object.values(vn),i=null;return t!=null&&t.length>0?e.includes(t)?i="valid":i="invalid":i="missing",i};generateMessage=t=>{let e=null,i="warning";return t==="missing"&&(e="If no lang is passed the default one will be set which is: en"),t==="invalid"&&(e="This lang value is not supported, the default one will be set which is: en"),t==="valid"&&(e=null,i=null),{text:e,type:i}}};var _a=class{validate(t){let e=this.validateField(t.environment),i=this.generateMessage(e);return{validation:e,message:i}}validateField=t=>{let e=["dev","staging","prod","watg"],i=null;return t!=null&&t.length>0?e.includes(t)?i="valid":i="invalid":i="missing",i};generateMessage=t=>{let e=null,i="warning";return t==="missing"&&(e="If no environment is passed the default one will be set which is: prod"),t==="invalid"&&(e="This environment value is not supported, the default one will be set which is: prod"),t==="valid"&&(e=null,i=null),{text:e,type:i}}};var Ta=class{validate(t){let e=this.validateField(t.apiKey),i=this.generateMessage(e);return{validation:e,message:i}}validateField=t=>{let e=null;return t!=null&&t.length>0?e="valid":e="missing",e};generateMessage=t=>{let e=null,i="error";return t==="missing"&&(e="The field apiKey with valid value must be provided to use Fans United JS SDK"),t==="valid"&&(i=null),{text:e,type:i}}};var va=class{validate(t){let e=this.validateField(t.idSchema),i=this.generateMessage(e);return{validation:e,message:i}}validateField=t=>{let e=Object.values(C),i=null;return t!=null&&t.length>0?e.includes(t)?i="valid":i="invalid":i="missing",i};generateMessage=t=>{let e=null,i="warning";return t==="missing"&&(e="If no idSchema is passed the default one will be set which is: native"),t==="invalid"&&(e="This idSchema value is not supported, the default one will be set which is: native"),t==="valid"&&(e=null,i=null),{text:e,type:i}}};var kt=class{getIdToken=null;logout=null};var ye=class{text=null;type=null};var Fa=class{validation=null;message=new ye;getIdToken={validation:null,message:new ye};logout={validation:null,message:new ye}};var Ea=class{validate(t){let e=this.validateAuthProvider(t.authProvider);return e.validation!=="missing"&&(e=this.validateAuthProviderConfigFields(t.authProvider,e),e=this.generateAuthProviderConfigMessages(e),e=this.checkAuthProviderConfigMessagesForErrors(e)),e}validateAuthProvider=t=>{let e=Object.keys(new kt),i=new Fa;if(t){let a=Object.keys(t).filter(s=>!e.includes(s));a.length>0?(i.validation="invalid",i.message.type="warning",i.message.text=`${"You have passed a property which is not supported for the authentication provider:"} ${a.join(",")}`):i.validation="valid"}else i.validation="missing",i.message.type="error",i.message.text="The field authProvider must be provided to use this SDK";return i};validateAuthProviderConfigFields=(t,e)=>(Object.keys(new kt).forEach(r=>{t[r]?e[r].validation="valid":e[r].validation="missing"}),e);generateAuthProviderConfigMessages=t=>(Object.keys(t).filter(e=>e!=="validation"&&e!=="message").forEach(e=>{let i=t[e];i.validation==="missing"&&(i.message.text=`${"The following property is missing from the authProvider object:"} ${e}`,i.message.type="error")}),t);checkAuthProviderConfigMessagesForErrors=t=>(Object.keys(t).filter(e=>e!=="validation"&&e!=="message").forEach(e=>{t[e].validation==="missing"&&t.validation==="valid"&&(t.validation="invalid",t.message.type="error",t.message.text="The field authProvider has missing properties")}),t)};var Ii=class{validation;message};var Sa=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;errorHandlingMode=null;authProvider={getIdToken:new Ii,logout:new Ii};isValid=!1};var Ra=class{validate(t){let e=this.validateField(t.clientId),i=this.generateMessage(e);return{validation:e,message:i}}validateField=t=>{let e=null;return t!=null&&t.length>0?e="valid":e="missing",e};generateMessage=t=>{let e=null,i="error";return t==="missing"&&(e="The field clientId must be provided to use Fans United JS SDK"),t==="valid"&&(e=null,i=null),{text:e,type:i}}};var Ca=class{validate=t=>{let e=this.validateField(t.errorHandlingMode),i=this.generateMessage(e);return{validation:e,message:i}};validateField=t=>{let e=["default","standard"],i=null;return t?e.includes(t)?i="valid":i="invalid":i="missing",i};generateMessage=t=>{let e=null,i="warning";return t==="missing"&&(e="If no errorHandlingMode is passed the default one will be set which is: default"),t==="invalid"&&(e="This errorHandlingMode value is not supported, the default one will be set which is: default"),t==="valid"&&(e=null,i=null),{text:e,type:i}}};var Aa=class{validate=t=>{let e=this.checkFieldsForValues(t);return e.isValid=this.containsErrorMessage(e),e};checkFieldsForValues=t=>{let e=new Sa,i={apiKey:new Ta,environment:new _a,idSchema:new va,clientId:new Ra,lang:new Pa,errorHandlingMode:new Ca,authProvider:new Ea};for(let[r,a]of Object.entries(e))r!=="isValid"&&(a=i[r].validate(t));return Object.keys(i).forEach(r=>{e[r]=i[r].validate(t)}),e};containsErrorMessage=t=>{let e=!0;for(let[i,r]of Object.entries(t))if(i!=="authProvider"){if(i!=="isValid"&&r.message.type==="error")return e=!1,e;if(i!=="isValid"&&r.message.type==="warning")return e=!0,e}else if(r.message.type==="error")return e=!1,e;return e}};var J=class{https=null;idMapping=null;localCache=null;footballFacade=null;constructor(t){this.https=new X(t),this.idMapping=new P(t),this.localCache=new K().createLocalCacheInstance(t.idSchema),this.footballFacade=new ie(t,this.localCache,this.https,this.idMapping)}getCountries=async t=>await this.footballFacade.getCountries(t);getCompetitions=async(t,e)=>await this.footballFacade.getCompetitions(t,e);getCompetitionById=async(t,e)=>await this.footballFacade.getCompetitionById(t,e);getTopCompetitions=async t=>await this.footballFacade.getTopCompetitions(t);getTeams=async(t,e)=>await this.footballFacade.getTeams(t,e);getTeamById=async(t,e)=>await this.footballFacade.getTeamById(t,e);getTopTeams=async t=>await this.footballFacade.getTopTeams(t);getNextMatchForTeam=async(t,e)=>await this.footballFacade.getNextMatchForTeam(t,e);getPrevMatchForTeam=async(t,e)=>await this.footballFacade.getPrevMatchForTeam(t,e);getPlayers=async(t,e)=>await this.footballFacade.getPlayers(t,e);getPlayerById=async(t,e)=>await this.footballFacade.getPlayerById(t,e);getTopPlayers=async t=>await this.footballFacade.getTopPlayers(t);getNextMatchForPlayer=async(t,e)=>await this.footballFacade.getNextMatchForPlayer(t,e);getPrevMatchForPlayer=async(t,e)=>await this.footballFacade.getPrevMatchForPlayer(t,e);getMatches=async(t,e)=>await this.footballFacade.getMatches(t,e);getMatchById=async(t,e)=>await this.footballFacade.getMatchById(t,e);search=async(t,e)=>await this.footballFacade.search(t,e)};var Oa=class{value=null;playerId=null;playerModel=null};var be=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new Oa;result=null};var La=class{value=!1;playerId=null};var Z=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i,r){this.matchId=t,this.market=e,this.prediction=new La,this.prediction.value=i,this.prediction.playerId=r}};var Me=class{settledAt=null;resettledAt=null;status=null;outcome=null;points=0};var xa=class{value=null};var Tt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new xa,this.prediction.value=i}};var tt=class{value=!1};var we=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new tt,this.prediction.value=i}};var Ie=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new tt,this.prediction.value=i}};var Da=class{matchFacade=null;playerFacade=null;predictorService=null;constructor(t,e,i){this.matchFacade=t,this.playerFacade=e,this.predictorService=i}remapFixturesRequest=t=>{let e={};if(e.match_id=t.matchId,e.match_type="FOOTBALL",t instanceof Z)e.market=t.market,e.prediction=t.prediction.value,e.player_id=t.prediction.playerId;else if(t instanceof we||t instanceof Ie)e.market=t.market,e.prediction=t.prediction.value;else if(t instanceof Tt){e.market=t.market;let i=t.prediction.value.split(":");e.goals_home=Number(i[0]),e.goals_away=Number(i[1])}else e.market=t.market,e.prediction=t.prediction.value;return e};remapFixturesResponse=async t=>{let e="OWN_GOAL",i=[],r=[],a=null,s=[];t.length>1&&t.sort((n,p)=>n.match_id.localeCompare(p.match_id));for(let n of t)i.push(n.match_id),n.player_id&&!r.includes(n.player_id)&&r.push(n.player_id);let l=await this.matchFacade.getMatchesMapWithNativeIds(i);r.sort((n,p)=>n.localeCompare(p)),r&&r.length>0&&!r.includes(e)&&(a=await this.playerFacade.getPlayersMapWithNativeIds(r));for(let n of t){let p=new be;n.target?p.market=this.predictorService.convertMarketForResponseModel(n.market,n.target):p.market=n.market,p.matchId=l[n.match_id].id,p.matchType=n.match_type,p.matchModel=l?l[n.match_id]:null,delete p.matchModel.availableMarkets,n.prediction!==void 0?p.prediction.value=n.prediction:n.goals_home!==void 0&&n.goals_away!==void 0&&(p.prediction.value=n.goals_home.toString()+":"+n.goals_away.toString()),p.prediction.playerId=n.player_id?n.player_id:null,p.prediction.playerId&&p.prediction.playerId!==e&&(p.prediction.playerModel=a[n.player_id],p.prediction.playerId=a[n.player_id].id),p.result=this.remapResult(n.result),s.push(p)}return s};remapResult=t=>{let e=new Me;return e.settledAt=t.settled_at,e.resettledAt=t.resettled_at,e.status=t.status,e.outcome=t.outcome,e.points=t.points,e}};var ut=class{goldenGoal=null};var Pi=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new ut;points=null;templateId=null;groupId=null;createdAt=null;updatedAt=null};var F=class{no=0;yes=0};var Ba=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new F;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new F;penaltyMatch=new F;playerScoreFirstGoal={};cornersMatch={};correctScore={};correctScoreHalfTime={};correctScoreAdvanced={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new F;overOnePointFiveGoals=new F;overTwoPointFiveGoals=new F;overThreePointFiveGoals=new F;overFourPointFiveGoals=new F;overFivePointFiveGoals=new F;overSixPointFiveGoals=new F;overSixPointFiveCorners=new F;overSevenPointFiveCorners=new F;overEightPointFiveCorners=new F;overNinePointFiveCorners=new F;overTenPointFiveCorners=new F;overElevenPointFiveCorners=new F;overTwelvePointFiveCorners=new F;overThirteenPointFiveCorners=new F};var dt=class{timeTiebreaker=!1};var vt=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new dt;predictionId=null;participantsCount=0;related=null;excludedProfileIds=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;scheduleOpenAt=null;images=null;predictionTiebreaker=new ut;branding=null};var Ut=class{userId=null;points=null;results=[];tiebreaker=null};var Fn=(a=>(a.ACTIVE="ACTIVE",a.WON="WON",a.LOST="LOST",a.PARTIALLY_WON="PARTIALLY_WON",a.CANCELED="CANCELED",a))(Fn||{}),Hn=["WON","LOST","PARTIALLY_WON","CANCELED"];var L=class{limit=null;startAfter=null;status=null;type=null;matchIds=null;gameIds=null;constructor(t){this.limit=t?.limit||null,this.startAfter=t?.startAfter||null,this.status=t?.status||null,this.type=t?.type||null,this.matchIds=t?.matchIds||null,this.gameIds=t?.gameIds||null}constructFiltersUrl=()=>{let t="",e=!1;return this.status&&(e=Object.values(Fn).some(i=>this.status.includes(i))),this.limit&&(t+="&",t+=`limit=${this.limit}`),this.startAfter&&(t+="&",t+=`start_after=${this.startAfter}`),this.status&&e&&(t+="&",t+=`status=${this.status.join(",")}`),this.type&&(t+="&",t+=`game_types=${this.type}`),this.matchIds&&this.matchIds.length>0&&(t+="&",t+=`match_ids=${this.matchIds.join(",")}`),this.gameIds&&this.gameIds.length>0&&(t+="&",t+=`game_ids=${this.gameIds.join(",")}`),t}};var v=class{limit;startAfter;constructor(t){this.limit=t&&t.limit?t.limit:null,this.startAfter=t&&t.startAfter?t.startAfter:null}constructMainFiltersUrl(){let t="";return this.limit&&(t+="&",t+=`limit=${this.limit}`),this.startAfter&&(t+="&",t+=`start_after=${this.startAfter}`),t}};var Na=(s=>(s.OPEN="OPEN",s.LIVE="LIVE",s.PENDING="PENDING",s.CANCELED="CANCELED",s.CLOSED="CLOSED",s.SETTLED="SETTLED",s))(Na||{});var et=class extends v{status=null;type=null;gameIds=null;sortOrder=null;constructor(t){super(t),this.status=t?.status||null,this.type=t?.type||null,this.gameIds=t?.gameIds||null,this.sortOrder=t?.sortOrder||null}constructFiltersUrl=()=>{let t=super.constructMainFiltersUrl();return this.status&&Object.values(Na).includes(this.status)&&(t+="&",t+=`status=${this.status}`),this.type&&(t+="&",t+=`type=${this.type}`),this.gameIds&&this.gameIds.length>0&&(t+="&",t+=`game_ids=${this.gameIds.join(",")}`),this.sortOrder&&(t+="&",t+=`sort_order=${this.sortOrder}`),t}};var it=class{main=null;cover=null;mobile=null};var ft=class{id=null;title=null;description=null;type=null;status=null;scheduleOpenAt=null;predictionsCutoff=null;fixtures=[];tiebreaker=new dt;participantsCount=0;related=null;excludedProfileIds=null;rules=null;labels=null;customFields=null;branding=null;flags=null;images=new it;createdAt=null;updatedAt=null};var yt=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new dt;predictionId=null;participantsCount=0;related=null;excludedProfileIds=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;images=null;scheduleOpenAt=null;branding=null};var Pe=class extends ft{adContent=null};var _e=class{homeGoals=null;awayGoals=null};var ka=class{playerId=null;playerModel=null};var Ua=class{FT_1X2=null;HT_1X2=null;BOTH_TEAMS_SCORE=null;DOUBLE_CHANCE=null;HT_FT=null;RED_CARD_MATCH=null;PENALTY_MATCH=null;CORNERS_MATCH=null;PLAYER_YELLOW_CARD=[];PLAYER_RED_CARD=[];PLAYER_SCORE_FIRST_GOAL=new ka;PLAYER_SCORE=[];PLAYER_SCORE_TWICE=[];PLAYER_SCORE_HATTRICK=[];CORRECT_SCORE=new _e;CORRECT_SCORE_ADVANCED=new _e;CORRECT_SCORE_HT=new _e;OVER_GOALS_0_5=null;OVER_GOALS_1_5=null;OVER_GOALS_2_5=null;OVER_GOALS_3_5=null;OVER_GOALS_4_5=null;OVER_GOALS_5_5=null;OVER_GOALS_6_5=null;OVER_CORNERS_6_5=null;OVER_CORNERS_7_5=null;OVER_CORNERS_8_5=null;OVER_CORNERS_9_5=null;OVER_CORNERS_10_5=null;OVER_CORNERS_11_5=null;OVER_CORNERS_12_5=null;OVER_CORNERS_13_5=null};var En=(i=>(i.ONE="1",i.X="x",i.TWO="2",i))(En||{}),Sn=(i=>(i.ONE_X="1x",i.X_TWO="x2",i.ONE_TWO="12",i))(Sn||{}),Rn=(p=>(p.ONE_ONE="1/1",p.ONE_X="1/x",p.ONE_TWO="1/2",p.X_ONE="x/1",p.X_X="x/x",p.X_TWO="x/2",p.TWO_ONE="2/1",p.TWO_X="2/x",p.TWO_TWO="2/2",p))(Rn||{});var Cn=class{constructor(){}static createMatchMarketsResultsModel(t,e){return{FT_1X2:this.createOneXTwoResult(t.scores,"full_time"),HT_1X2:this.createOneXTwoResult(t.scores,"half_time"),BOTH_TEAMS_SCORE:t.scores.ftScore.homeGoals>0&&t.scores.ftScore.awayGoals>0,DOUBLE_CHANCE:this.createDoubleChanceResult(t.scores),HT_FT:this.createHalfTimeFullTimeResult(t.scores),RED_CARD_MATCH:this.createMarketResultByCriteria(t,"red_card"),PENALTY_MATCH:this.createMarketResultByCriteria(t,"penalty"),CORNERS_MATCH:isNaN(t.stats?.corners?.homeTeam+t.stats?.corners?.awayTeam)?null:t.stats.corners.homeTeam+t.stats.corners.awayTeam,PLAYER_YELLOW_CARD:this.createPlayersMarketsResults(t,e,"yellow_card"),PLAYER_RED_CARD:this.createPlayersMarketsResults(t,e,"red_card"),PLAYER_SCORE_FIRST_GOAL:this.createPlayersMarketsResults(t,e,"first_goal"),PLAYER_SCORE:this.createPlayersMarketsResults(t,e,"one_goal"),PLAYER_SCORE_TWICE:this.createPlayersMarketsResults(t,e,"two_goals"),PLAYER_SCORE_HATTRICK:this.createPlayersMarketsResults(t,e,"hattrick"),CORRECT_SCORE:{homeGoals:t.scores.ftScore.homeGoals,awayGoals:t.scores.ftScore.awayGoals},CORRECT_SCORE_ADVANCED:{homeGoals:t.scores.ftScore.homeGoals,awayGoals:t.scores.ftScore.awayGoals},CORRECT_SCORE_HT:{homeGoals:t.scores.htScore.homeGoals,awayGoals:t.scores.htScore.awayGoals},OVER_GOALS_0_5:t.scores.ftScore.homeGoals+t.scores.ftScore.awayGoals>0,OVER_GOALS_1_5:t.scores.ftScore.homeGoals+t.scores.ftScore.awayGoals>1,OVER_GOALS_2_5:t.scores.ftScore.homeGoals+t.scores.ftScore.awayGoals>2,OVER_GOALS_3_5:t.scores.ftScore.homeGoals+t.scores.ftScore.awayGoals>3,OVER_GOALS_4_5:t.scores.ftScore.homeGoals+t.scores.ftScore.awayGoals>4,OVER_GOALS_5_5:t.scores.ftScore.homeGoals+t.scores.ftScore.awayGoals>5,OVER_GOALS_6_5:t.scores.ftScore.homeGoals+t.scores.ftScore.awayGoals>6,OVER_CORNERS_6_5:isNaN(t.stats?.corners?.homeTeam+t.stats?.corners?.awayTeam)?null:t.stats.corners.homeTeam+t.stats.corners.awayTeam>6,OVER_CORNERS_7_5:isNaN(t.stats?.corners?.homeTeam+t.stats?.corners?.awayTeam)?null:t.stats.corners.homeTeam+t.stats.corners.awayTeam>7,OVER_CORNERS_8_5:isNaN(t.stats?.corners?.homeTeam+t.stats?.corners?.awayTeam)?null:t.stats.corners.homeTeam+t.stats.corners.awayTeam>8,OVER_CORNERS_9_5:isNaN(t.stats?.corners?.homeTeam+t.stats?.corners?.awayTeam)?null:t.stats.corners.homeTeam+t.stats.corners.awayTeam>9,OVER_CORNERS_10_5:isNaN(t.stats?.corners?.homeTeam+t.stats?.corners?.awayTeam)?null:t.stats.corners.homeTeam+t.stats.corners.awayTeam>10,OVER_CORNERS_11_5:isNaN(t.stats?.corners?.homeTeam+t.stats?.corners?.awayTeam)?null:t.stats.corners.homeTeam+t.stats.corners.awayTeam>11,OVER_CORNERS_12_5:isNaN(t.stats?.corners?.homeTeam+t.stats?.corners?.awayTeam)?null:t.stats.corners.homeTeam+t.stats.corners.awayTeam>12,OVER_CORNERS_13_5:isNaN(t.stats?.corners?.homeTeam+t.stats?.corners?.awayTeam)?null:t.stats.corners.homeTeam+t.stats.corners.awayTeam>13}}},mt=Cn;ot(mt,"createOneXTwoResult",(t,e)=>e==="full_time"?t.ftScore.homeGoals>t.ftScore.awayGoals?"1":t.ftScore.homeGoals===t.ftScore.awayGoals?"x":"2":t?.htScore?.homeGoals>t?.htScore?.awayGoals?"1":t?.htScore?.homeGoals===t?.htScore?.awayGoals?"x":"2"),ot(mt,"createDoubleChanceResult",t=>t?.ftScore?.homeGoals>t?.ftScore?.awayGoals?["1x","12"]:t?.ftScore?.homeGoals===t?.ftScore?.awayGoals?["1x","x2"]:["x2","12"]),ot(mt,"createHalfTimeFullTimeResult",t=>{if(t?.htScore?.homeGoals>t?.htScore?.awayGoals){if(t?.ftScore?.homeGoals>t?.ftScore?.awayGoals)return"1/1";if(t?.ftScore?.homeGoals===t?.ftScore?.awayGoals)return"1/x";if(t?.ftScore?.homeGoals<t?.ftScore?.awayGoals)return"1/2"}if(t?.htScore?.homeGoals===t?.htScore?.awayGoals){if(t?.ftScore?.homeGoals>t?.ftScore?.awayGoals)return"x/1";if(t?.ftScore?.homeGoals===t?.ftScore?.awayGoals)return"x/x";if(t?.ftScore?.homeGoals<t?.ftScore?.awayGoals)return"x/2"}if(t?.htScore?.homeGoals<t?.htScore?.awayGoals){if(t?.ftScore?.homeGoals>t?.ftScore?.awayGoals)return"2/1";if(t?.ftScore?.homeGoals===t?.ftScore?.awayGoals)return"2/x";if(t?.ftScore?.homeGoals<t?.ftScore?.awayGoals)return"2/2"}}),ot(mt,"createMarketResultByCriteria",(t,e)=>!t.timeline||!t.timeline.length?null:e==="red_card"?t.timeline.filter(i=>Number(i.minute)<=90).some(i=>i.type==="red_card"):t.timeline.filter(i=>Number(i.minute)<=90).some(i=>i.type.startsWith(e))),ot(mt,"createPlayersMarketsResults",(t,e,i)=>{if(!t.timeline||!t.timeline.length)return i==="first_goal"?null:[];if(i==="first_goal"){let l=t.timeline.find(n=>n.type==="goal"||n.type==="penalty_goal"||n.type==="own_goal")||null;if(l){let n=e[l.player.id];return{playerId:l.type==="goal"||l.type==="penalty_goal"?l.player.id:"OWN_GOAL",playerModel:n}}return null}if(i==="yellow_card"||i==="red_card")return Cn.transformPlayerMarketResult(t.timeline.filter(l=>Number(l.minute)<=90).filter(l=>l.type===i).map(l=>e[l.player.id]));let r=new Map,a=i==="one_goal"?1:i==="two_goals"?2:3,s=[];return t.timeline.filter(l=>Number(l.minute)<=90).filter(l=>l.type==="goal"||l.type==="penalty_goal").forEach(l=>{let n=e[l.player.id];if(r.has(l.player.id)){let p=r.get(l.player.id);p.push(n),r.set(l.player.id,p)}else r.set(l.player.id,[n])}),r.forEach(l=>{l.length>=a&&s.push(l[0])}),Cn.transformPlayerMarketResult(s)}),ot(mt,"transformPlayerMarketResult",t=>t.map(e=>({playerId:e.id,playerModel:e})));var ht=class{footballHttps=null;idMapping=null;matchFacade=null;playerFacade=null;profileNamespace=null;constructor(t,e){this.footballHttps=new X(t),this.idMapping=e,this.matchFacade=new Pt(t,this.footballHttps,e),this.playerFacade=new wt(t,this.footballHttps,e),this.profileNamespace=new O(t)}remapMatchIdToNative=async t=>(await this.idMapping.getEntityIdsBySchemaId(t,"match","native")).match;remapPlayerIdToNative=async t=>(await this.idMapping.getEntityIdsBySchemaId(t,"player","native")).player[0];remapPlayerIdMapToNative=async t=>{let e={},i=Lt(t),a=(await this.idMapping.getEntityIdsBySchemaId(i,"player","native")).player;return i.forEach((s,l)=>e[s]=a[l]),e};remapPlayerIdToIdSchema=async t=>{let e=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"],i=[];for(let[a,s]of Object.entries(t))if(e.includes(a))for(let l of Object.keys(s))l!=="NOBODY"&&l!=="OWN_GOAL"&&i.push(l);if(!i.length)return t;let r=await this.playerFacade.getPlayersMapWithNativeIds(i);for(let[a,s]of Object.entries(t))if(e.includes(a))for(let l of Object.keys(s))l!=="NOBODY"&&l!=="OWN_GOAL"&&(s[r[l].id]=s[l],s[r[l].id].model=r[l],this.idMapping.idSchema!=="native"&&delete s[l]);return t};convertMarketForResponseModel=(t,e)=>{let i=e.toString();return t+"_"+i};getMarketSummary=async(t,e,i)=>{let r=jn.get(e),a={};if(a.matchId=t.matchId,a.matchType=t.matchType,Object.keys(t.predictions).includes(r))a[r]=t.predictions[r];else throw new Error("You have passed invalid market");if(ct.includes(e)&&i){let l="";if(i!=="OWN_GOAL"&&i!=="NOBODY"&&(l=(await this.idMapping.idMappingFacade.getEntitiesByIds({player:[i]},this.idMapping.idSchema,"native")).player[0]),l&&a[r][l]){let n=await this.playerFacade.getPlayersMapWithNativeIds([l]);return a[r][l].model=n[l],a[r][l]}else return l?(a[r][l]=new F,a[r][l]):a[r][i]}else if(ct.includes(e)&&!i){let l=Object.keys(a[r]).filter(p=>p!=="NOBODY"&&p!=="OWN_GOAL"),n=l.length?await this.playerFacade.getPlayersMapWithNativeIds(l):{};Object.keys(n).length&&Object.keys(a[r]).forEach(p=>{p!=="NOBODY"&&p!=="OWN_GOAL"&&(a[r][n[p].id]=a[r][p],a[r][n[p].id].model=n[p],this.idMapping.idSchema!=="native"&&delete a[r][p])})}return a};remapCompetitionsFromConfig=async t=>{if(t instanceof Yt){let e={competition:t.fullCoverageCompetitions},i={competition:t.successRateScopes.competitions},r={team:t.successRateScopes.teams},a=await this.idMapping.idMappingFacade.getEntitiesByIds(e,"native",this.idMapping.idSchema),s=await this.idMapping.idMappingFacade.getEntitiesByIds(i,"native",this.idMapping.idSchema),l=await this.idMapping.idMappingFacade.getEntitiesByIds(r,"native",this.idMapping.idSchema);return t.fullCoverageCompetitions=a.competition,t.successRateScopes.competitions=s.competition,t.successRateScopes.teams=l.team,t}if(t instanceof Xt||t instanceof jt){let e={competition:t.competitionsWhitelist},i=await this.idMapping.idMappingFacade.getEntitiesByIds(e,"native",this.idMapping.idSchema);return t.competitionsWhitelist=i.competition,t}};remapMatchIdsFixtures=async t=>{if(Array.isArray(t.data))if(t.data.length>0){let e=[],i=[];return t.data.forEach(r=>{r instanceof ft||r instanceof vt||r instanceof yt||r instanceof Pe?(r.fixtures.forEach(a=>e.push(a.matchId)),r instanceof yt&&r.fixtures.forEach(a=>{a.prediction.playerId&&a.prediction.playerId!=="OWN_GOAL"&&i.push(a.prediction.playerId)})):r instanceof Ut&&r.results.forEach(a=>e.push(a.matchId))}),await this.refactorResponseArrModel(t,e,i)}else return t;else return await this.refactorResponseObjModel(t)};refactorResponseArrModel=async(t,e,i)=>{let r=[],a=await this.matchFacade.getMatchesMapWithNativeIds(e),s={};return i.length>0&&(s=await this.playerFacade.getPlayersMapWithNativeIds(i)),t.data.forEach(l=>{l instanceof ft||l instanceof vt||l instanceof yt?(l.fixtures.forEach(n=>{this.handleMatchModel(a,n),l instanceof yt&&n.prediction.playerId&&n.prediction.playerId!=="OWN_GOAL"&&(n.prediction.playerModel=s[n.prediction.playerId],n.prediction.playerId=s[n.prediction.playerId].id)}),r.push(l)):l instanceof Ut&&(l.results.forEach(n=>{n.matchModel=a[n.matchId],delete n.matchModel.availableMarkets,n.matchId=n.matchModel.id}),r.push(l))}),t.data=r,t};refactorResponseObjModel=async t=>{let e=[];t.fixtures.forEach(r=>e.push(r.matchId));let i=await this.matchFacade.getMatchesMapWithNativeIds(e);return t.fixtures.forEach(r=>this.handleMatchModel(i,r)),t};getCurrentGameId=t=>{let e=new Date;if(t.data.length>1){let i=[];return t.data.forEach(a=>i.push(a.predictionsCutoff)),t.data.sort((a,s)=>{let[l,n]=[a.predictionsCutoff,s.predictionsCutoff].map(p=>Math.abs(new Date(p)-e));return l-n})[0].id}else return t.data[0].id};initGameTypePredictions=(t,e)=>{let i={type:t,limit:null,startAfter:null};return e&&(i={...i,limit:e.limit,startAfter:e.startAfter}),i=new L(i),i};initGameFilters=(t,e,i)=>{if(e&&i)return e.type=t,e.gameIds=i,e=new et(e),e;if(e&&!i)return e.type=t,e=new et(e),e;if(!e&&i){let r={type:t,gameIds:i};return r=new et(r),r}else{let r={type:t};return r=new et(r),r}};addPredictionProp=async(t,e)=>(e.data.forEach(i=>{t.data.forEach(r=>{i.id===r.game_instance_id&&(i.predictionId=r.id,i.outcome=r.status,i.fixtures.forEach((a,s)=>{r.fixtures[s].goals_home!==void 0&&r.fixtures[s].goals_away!==void 0?a.prediction.value=r.fixtures[s].goals_home+":"+r.fixtures[s].goals_away:a.prediction.value=r.fixtures[s].prediction,r.fixtures[s].player_id?a.prediction.playerId=r.fixtures[s].player_id:r.fixtures[s].target&&(a.prediction.target=r.fixtures[s].target),a.prediction.result=this.remapResult(r.fixtures[s].result)}),i.predictionsMadeAt=r.created_at,i.points=r.points,i instanceof vt&&(r.tiebreaker?i.predictionTiebreaker.goldenGoal=r.tiebreaker.golden_goal:i.predictionTiebreaker=r.tiebreaker))})}),e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,await this.remapMatchIdsFixtures(e));remapResult=t=>{let e=new Me;return e.settledAt=t.settled_at,e.resettledAt=t.resettled_at,e.status=t.status,e.outcome=t.outcome,e.points=t.points,e};areIdsExceeded=t=>t.length>10;initPredictionsFilters=(t,e,i)=>{switch(e){case"user":t&&(t=new L(t));break;case"current":if(t)this.deleteUnexpectedProperties(t),t.status=["ACTIVE"],t=new L(t);else{let r={status:["ACTIVE"]};t=new L(r)}break;case"past":if(t)this.deleteUnexpectedProperties(t),t.status=Hn,t=new L(t);else{let r={status:Hn};t=new L(r)}break;case"matches":if(t)this.deleteUnexpectedProperties(t),t.matchIds=i,t=new L(t);else{let r={matchIds:i};t=new L(r)}break}return t};completeGameMarketResults=async(t,e)=>{switch(e){case"MATCH_QUIZ":let i={},r=t.results[0].matchId,a=t.results.map(p=>ct.includes(p.market)&&!p.result.includes("OWN_GOAL")?[...p.result]:[]).flat(),s=await this.matchFacade.getMatchesMapWithNativeIds([r]);return a.length&&(i=await this.playerFacade.getPlayersMapWithNativeIds(a)),t.results=t.results.map(p=>{if(p.matchModel=s[p.matchId]?s[p.matchId]:null,p.playerModels&&Object.keys(i).length&&p.result.forEach(u=>{let d=i[u];p.playerModels.push(d)}),this.idMapping.idSchema!=="native"&&(this.remapMatchIdForResultsMarkets(s,p),p.playerModels&&Object.keys(i).length)){let c=p.result;p.result=c.map(u=>i[u].id)}return p}),t;case"TOP_X":let l=t.results.map(p=>p.matchId),n=await this.matchFacade.getMatchesMapWithNativeIds(l);if(t.results=t.results.map(p=>(p.matchModel=n[p.matchId]?n[p.matchId]:null,this.idMapping.idSchema!=="native"&&this.remapMatchIdForResultsMarkets(n,p),p)),t.tieBreakers.goldenGoals.length){let p=t.tieBreakers.goldenGoals.map(u=>u.playerId),c=await this.playerFacade.getPlayersMapWithNativeIds(p);t.tieBreakers.goldenGoals=t.tieBreakers.goldenGoals.map(u=>(u.matchModel=n[u.matchId],u.playerModel=c[u.playerId],this.idMapping.idSchema!=="native"&&(u.matchId=n[u.matchId].id,u.playerId=c[u.playerId].id),u))}return t}};completeContestWinners=async t=>{if(t.userList&&t.userList.length){let e=t.userList.map(r=>r.profileId),i=await this.profileNamespace.getByIds(e);t.userList.forEach(r=>{let a=i.filter(s=>s.id===r.profileId)[0];delete a.interests,r.profileModel=a})}return t};handleMatchModel=(t,e)=>{t[e.matchId]?(e.matchModel=t[e.matchId],delete e.matchModel.availableMarkets,e.matchId=e.matchModel.id):(e.matchModel=null,this.idMapping.idSchema!=="native"&&this.idMapping.idMappingFacade.getEntityById(e.matchId,"match","native").then(i=>{e.matchId=i[D[this.idMapping.idSchema]]}))};remapMatchIdForResultsMarkets=(t,e)=>{t[e.matchId]?e.matchId=t[e.matchId].id:this.idMapping.idMappingFacade.getEntityById(e.matchId,"match","native").then(i=>{e.matchId=i[D[this.idMapping.idSchema]]})};deleteUnexpectedProperties=t=>(t.status&&(console.warn(kn.UNEXPECTED_STATUS_PROP),delete t.status),t.type&&(console.warn(kn.UNEXPECTED_TYPE_PROP),delete t.type),t);getMatchMarketsResults=async t=>{let e=await this.footballHttps.getMatchById(t,!0);if(e.status.type!=="finished"||!e.finishedAt)return new Ua;let i=[];e.timeline.filter(a=>Number(a.minute)<=90).filter(a=>a.type==="goal"||a.type==="penalty_goal"||a.type==="yellow_card"||a.type==="red_card").forEach(a=>{i.push(a.player.id)});let r={};return i.length&&(r=await this.playerFacade.getPlayersMapWithNativeIds(i)),mt.createMatchMarketsResultsModel(e,r)}};var Te=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(t){this.gameInstanceId=t.gameInstanceId,t.fixtures.forEach(e=>this.fixtures.push(new Tt(e.matchId,e.market,e.prediction.value))),this.tiebreaker=t.tiebreaker?t.tiebreaker:null}};var ve=class{template_id=null;group_id=null;fixtures=[]};var Fe=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(t,e){this.footballHttps=new X(t),this.matchFacade=new Pt(t,this.footballHttps,e),this.playerFacade=new wt(t,this.footballHttps,e),this.predictorService=new ht(t,e),this.fixturesRemapper=new Da(this.matchFacade,this.playerFacade,this.predictorService)}remapRequestBody=t=>{if(t instanceof ve)return t;let e={};return e.game_instance_id=t.gameInstanceId,e.fixtures=t.fixtures.map(i=>this.fixturesRemapper.remapFixturesRequest(i)),t instanceof Te&&t.tiebreaker&&(e.tiebreaker={},e.tiebreaker.golden_goal=t.tiebreaker.goldenGoal?t.tiebreaker.goldenGoal:null),e};remapResponseArrayBody=async t=>{if(t.length){let e="OWN_GOAL",i=[],r=[],a={},s=[];t.forEach(n=>{n.fixtures.forEach(p=>{i.push(p.match_id),p.player_id&&p.player_id!==e&&r.push(p.player_id)})});let l=await this.matchFacade.getMatchesMapWithNativeIds(i);return r.length>0&&(a=await this.playerFacade.getPlayersMapWithNativeIds(r)),t.forEach(n=>{let p=new Pi,c=[];p.id=n.id,p.gameInstanceId=n.game_instance_id,p.gameType=n.game_type,p.wager=n.wager,p.totalFixtures=n.total_fixtures,p.settledFixtures=n.settled_fixtures,p.userId=n.user_id,p.templateId=n.template_id,p.groupId=n.group_id,n.fixtures.forEach(u=>{let d=new be;u.target?d.market=this.predictorService.convertMarketForResponseModel(u.market,u.target):d.market=u.market,d.matchId=l[u.match_id].id,d.matchType=u.match_type,d.matchModel=l[u.match_id],delete d.matchModel.availableMarkets,u.prediction!==void 0?d.prediction.value=u.prediction:u.goals_home!==void 0&&u.goals_away!==void 0&&(d.prediction.value=u.goals_home.toString()+":"+u.goals_away.toString()),d.prediction.playerId=u.player_id?u.player_id:null,d.prediction.playerId&&d.prediction.playerId!==e&&(d.prediction.playerModel=a[d.prediction.playerId],d.prediction.playerId=a[d.prediction.playerId].id),d.result=this.fixturesRemapper.remapResult(u.result),c.push(d)}),p.fixtures=c,p.status=n.status,n.tiebreaker?p.tiebreaker.goldenGoal=n.tiebreaker.golden_goal:p.tiebreaker=null,p.points=n.points,p.createdAt=n.created_at,p.updatedAt=n.updated_at,s.push(p)}),s}return t};remapResponseObjBody=async t=>{let e=new Pi;return e.id=t.id,e.gameInstanceId=t.game_instance_id,e.gameType=t.game_type,e.wager=t.wager,e.totalFixtures=t.total_fixtures,e.settledFixtures=t.settled_fixtures,e.userId=t.user_id,e.templateId=t.template_id,e.groupId=t.group_id,e.fixtures=await this.fixturesRemapper.remapFixturesResponse(t.fixtures),e.status=t.status,t.tiebreaker?e.tiebreaker.goldenGoal=t.tiebreaker.golden_goal:e.tiebreaker=null,e.points=t.points,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapPredictionModel=t=>{let e=new Ba;return e.fullTimeOneXTwo=t.FT_1X2,e.halfTimeOneXTwo=t.HT_1X2,e.bothTeamsScore=t.BOTH_TEAMS_SCORE,e.overZeroPointFiveGoals=t.OVER_GOALS_0_5,e.overOnePointFiveGoals=t.OVER_GOALS_1_5,e.overTwoPointFiveGoals=t.OVER_GOALS_2_5,e.overThreePointFiveGoals=t.OVER_GOALS_3_5,e.overFourPointFiveGoals=t.OVER_GOALS_4_5,e.overFivePointFiveGoals=t.OVER_GOALS_5_5,e.overSixPointFiveGoals=t.OVER_GOALS_6_5,e.overSixPointFiveCorners=t.OVER_CORNERS_6_5,e.overSevenPointFiveCorners=t.OVER_CORNERS_7_5,e.overEightPointFiveCorners=t.OVER_CORNERS_8_5,e.overNinePointFiveCorners=t.OVER_CORNERS_9_5,e.overTenPointFiveCorners=t.OVER_CORNERS_10_5,e.overElevenPointFiveCorners=t.OVER_CORNERS_11_5,e.overTwelvePointFiveCorners=t.OVER_CORNERS_12_5,e.overThirteenPointFiveCorners=t.OVER_CORNERS_13_5,e.doubleChance=t.DOUBLE_CHANCE,e.halfTimeFullTime=t.HT_FT,e.playerScore=t.PLAYER_SCORE,e.playerYellowCard=t.PLAYER_YELLOW_CARD,e.playerRedCard=t.PLAYER_RED_CARD,e.redCardMatch=t.RED_CARD_MATCH,e.penaltyMatch=t.PENALTY_MATCH,e.playerScoreFirstGoal=t.PLAYER_SCORE_FIRST_GOAL,e.cornersMatch=t.CORNERS_MATCH,e.correctScore=t.CORRECT_SCORE,e.correctScoreHalfTime=t.CORRECT_SCORE_HT,e.correctScoreAdvanced=t.CORRECT_SCORE_ADVANCED,e.playerScoreHattrick=t.PLAYER_SCORE_HATTRICK,e.playerScoreTwice=t.PLAYER_SCORE_TWICE,e}};var Ga=class{matchId=null;matchType=null;predictions=null};var Va=class{remapPredictions=null;constructor(t,e){this.remapPredictions=new Fe(t,e)}remapResponse=t=>{let e=new Ga;return e.matchId=t.match_id,e.matchType=t.match_type,e.predictions=this.remapPredictions.remapPredictionModel(t.predictions),e}};var Ha=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new j};var $a=class{value=null;target=null;playerId=null;playerModel=null;result=null};var Wa=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new j;prediction=new $a};var za=class{value=null;result=null};var qa=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new j;prediction=new za};var Qa=class{matchId=null;matchModel=null;outcome=null};var Ka=class{gameId=null;results=null;tieBreakers=null};var Ee=class{entityId=null;entityType=null};var ja=class{contestId="";contestType="GAME";contestModel=null;description="";userList=[]};var Xa=class{position="";profileId="";profileModel=null;note="";tags=[]};var Ya=class{primaryColor=null;secondaryColor=null;contentColor=null;backgroundColor=null;borderColor=null;additionalColor=null};var Ja=class{mainLogo=null;mobileLogo=null;backgroundImage=null;mobileBackgroundImage=null;additionalImage=null};var Za=class{colors=null;urls=null;images=null};var to=class{primaryUrl=null;secondaryUrl=null;privacyPolicyUrl=null;termsAndConditionsUrl=null;additionalUrl=null};var rt=class{remapBranding=t=>{let e=new Za;return t.colors&&(e.colors=new Ya,e.colors.primaryColor=t.colors.primary_color,e.colors.secondaryColor=t.colors.secondary_color,e.colors.contentColor=t.colors.content_color,e.colors.backgroundColor=t.colors.background_color,e.colors.borderColor=t.colors.border_color,e.colors.additionalColor=t.colors.additional_color),t.urls&&(e.urls=new to,e.urls.primaryUrl=t.urls.primary_url,e.urls.secondaryUrl=t.urls.secondary_url,e.urls.privacyPolicyUrl=t.urls.privacy_policy_url,e.urls.termsAndConditionsUrl=t.urls.terms_and_conditions_url,e.urls.additionalUrl=t.urls.additional_url),t.images&&(e.images=new Ja,e.images.mainLogo=t.images.main_logo,e.images.mobileLogo=t.images.mobile_logo,e.images.backgroundImage=t.images.background_image,e.images.mobileBackgroundImage=t.images.mobile_background_image,e.images.additionalImage=t.images.additional_image),e}};var eo=class extends rt{remapPaginatedGames=t=>{let e=new R;return e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.data=t.data.map(i=>this.remapGamesListResponse(i)),e};remapGamesListResponse=t=>{let e=new ft;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.status=t.status,e.scheduleOpenAt=t.schedule_open_at,e.predictionsCutoff=t.predictions_cutoff,e.fixtures=t.fixtures.map(i=>this.remapFixturesResponse(i)),e.tiebreaker=t.tiebreaker?this.remapTimeTiebreaker(t.tiebreaker.time_tiebreaker):null,e.participantsCount=t.participants_count,e.related=t.related?this.remapRelated(t.related):null,e.excludedProfileIds=t.excluded_profile_ids,e.rules=t.rules,e.labels=t.labels,e.customFields=t.custom_fields,e.branding=t.branding?this.remapBranding(t.branding):null,e.flags=t.flags,e.images=t.images,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapGameByIdResponse=t=>{let e=new Pe;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.status=t.status,e.scheduleOpenAt=t.schedule_open_at,e.predictionsCutoff=t.predictions_cutoff,e.fixtures=t.fixtures.map(i=>this.remapFixturesResponse(i)),e.tiebreaker=t.tiebreaker?this.remapTimeTiebreaker(t.tiebreaker.time_tiebreaker):null,e.participantsCount=t.participants_count,e.related=t.related?this.remapRelated(t.related):null,e.excludedProfileIds=t.excluded_profile_ids,e.rules=t.rules,e.flags=t.flags,e.adContent=t.ad_content,e.labels=t.labels,e.customFields=t.custom_fields,e.branding=t.branding?this.remapBranding(t.branding):null,e.images=t.images,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapFixturesResponse=t=>{let e=new Ha;return e.matchId=t.match_id,e.matchType=t.match_type,e.market=t.market,e.matchStatus.type=t.match_status?t.match_status.type:null,e.matchStatus.subType=t.match_status?t.match_status.sub_type:null,e};remapPaginatedUserTopXEditions=t=>{let e=new R;return e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.data=t.data.map(i=>this.remapUserTopXEditionsResponse(i)),e};remapUserTopXEditionsResponse=t=>{let e=new vt;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.status=t.status,e.predictionsCutoff=t.predictions_cutoff,e.scheduleOpenAt=t.schedule_open_at,e.fixtures=t.fixtures.map(i=>this.remapTopXFixturesResponse(i)),e.tiebreaker=t.tiebreaker?this.remapTimeTiebreaker(t.tiebreaker.time_tiebreaker):null,e.participantsCount=t.participants_count,e.related=t.related?this.remapRelated(t.related):null,e.excludedProfileIds=t.excluded_profile_ids,e.rules=t.rules,e.flags=t.flags,e.images=t.images,e.branding=t.branding?this.remapBranding(t.branding):null,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapTopXFixturesResponse=t=>{let e=new qa;return e.matchId=t.match_id,e.matchType=t.match_type,e.market=t.market,e.matchStatus.type=t.match_status?t.match_status.type:null,e.matchStatus.subType=t.match_status?t.match_status.sub_type:null,e};remapPaginatedUserMathQuizEditions=t=>{let e=new R;return e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.data=t.data.map(i=>this.remapUserMatchQuizEditionsResponse(i)),e};remapUserMatchQuizEditionsResponse=t=>{let e=new yt;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.status=t.status,e.predictionsCutoff=t.predictions_cutoff,e.scheduleOpenAt=t.schedule_open_at,e.fixtures=t.fixtures.map(i=>this.remapMatchQuizFixturesResponse(i)),e.tiebreaker=t.tiebreaker?this.remapTimeTiebreaker(t.tiebreaker.time_tiebreaker):null,e.participantsCount=t.participants_count,e.related=t.related?this.remapRelated(t.related):null,e.excludedProfileIds=t.excluded_profile_ids,e.rules=t.rules,e.flags=t.flags,e.images=t.images,e.branding=t.branding?this.remapBranding(t.branding):null,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapMatchQuizFixturesResponse=t=>{let e=new Wa;return e.matchId=t.match_id,e.matchType=t.match_type,e.market=t.market,e.matchStatus.type=t.match_status?t.match_status.type:null,e.matchStatus.subType=t.match_status?t.match_status.sub_type:null,e};remapPaginatedGameResults=t=>{let e=new R;return e.meta.pagination.nextPageStartsAfter=t.meta.pagination.next_page_starts_after,e.meta.pagination.itemsPerPage=t.meta.pagination.items_per_page,e.data=t.data.map(i=>this.remapGameResults(i)),e};remapGameResults=t=>{let e=new Ut;return e.userId=t.user_id,e.points=t.points?t.points:0,e.results=t.results.map(i=>this.remapResults(i)),e.tiebreaker=t.tiebreaker?this.remapTiebreaker(t.tiebreaker):null,e};remapGameMarketsResults=t=>{let e=new Ka;return e.gameId=t.game_id,e.results=this.remapMarketsResults(t.results),e.tieBreakers=t.tie_breakers?this.remapTieBreakers(t.tie_breakers):null,e};remapContestWinners=t=>{let e=new ja;return e.contestId=t.contest_id,e.contestType=t.contest_type,e.description=t.description,e.userList=t.user_list?t.user_list.map(i=>this.remapUserListWinners(i)):null,e};remapUserListWinners=t=>{let e=new Xa;return e.position=t.position,e.profileId=t.profile_id,e.note=t.note,e.tags=t.tags,e};remapTieBreakers=t=>{let e={goldenGoals:[]};return e.goldenGoals=t.golden_goals.map(i=>({minute:i.minute,matchId:i.match_id,matchModel:null,playerId:i.player_id,playerModel:null,goalType:i.goal_type})),e};remapMarketsResults=t=>{let e=[];return t.forEach(i=>{let r={matchId:i.match_id,market:i.market,result:this.remapMarketResult(i.market,i.result),matchModel:null,playerModels:[],matchStatus:this.remapMarketsResultsMatchStatus(i.match_status)};e.push(this.deleteUnusefulField(r))}),e};remapMarketsResultsMatchStatus=t=>{let e=new j;return t&&(e.type=t.type,e.subType=t.sub_type),e};remapMarketResult=(t,e)=>{if(Pl.includes(t))return e[0];if(ct.includes(t))return e;if(e[0]==="true")return!0;if(e[0]==="false")return!1};deleteUnusefulField=t=>((!ct.includes(t.market)||this.isPlayerMarketWithNoResult(t.market,t.result))&&delete t.playerModels,t);isPlayerMarketWithNoResult=(t,e)=>ct.includes(t)&&e.length===0;remapResults=t=>{let e=new Qa;return e.matchId=t.match_id,e.outcome=t.outcome,e};remapTiebreaker=t=>{let e=new ut;return e.goldenGoal=t.golden_goal,e};remapTimeTiebreaker=t=>{let e=new dt;return e.timeTiebreaker=t,e};remapRelated=t=>t.map(e=>{let i=new Ee;return i.entityId=e.entity_id,i.entityType=e.entity_type,i})};var io=class{remapMetaData=t=>{let e=new x;return e.pagination.nextPageStartsAfter=t.pagination.next_page_starts_after,e.pagination.itemsPerPage=t.pagination.items_per_page,e}};var at=class extends T{predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;metaRemapper=null;constructor(t,e){super(t,S(t.environment,"predictor")),this.predictionRemapper=new Fe(t,e),this.matchSummaryRemapper=new Va(t,e),this.gamesRemapper=new eo,this.metaRemapper=new io}makeFootballPrediction=async t=>{let e=`/predictions${this.apiSignInUrl}`,i="There was a problem making POST request",r="POST",a=await this.fetchWithAuth(e,i,r,this.predictionRemapper.remapRequestBody(t));return await this.predictionRemapper.remapResponseObjBody(a)};getMatchSummary=async(t,e)=>{let i=w(e)?`/predictions/summary/${t}${this.apiSignInUrl}${h()}`:`/predictions/summary/${t}${this.apiSignInUrl}`,r=`There was a problem fetching predictions for match: ${t}`,a=await this.fetchWithoutAuth(i,r);return this.matchSummaryRemapper.remapResponse(a)};deleteFootballPrediction=async t=>{let e=`/predictions/${t}${this.apiSignInUrl}`,i=`There was a problem deleting your prediction: ${t}`,r="DELETE";return await this.fetchWithAuth(e,i,r),!0};getMyPredictions=async t=>{let e=new R,i=`/predictions${this.apiSignInUrl}`,r="There was a problem fetching own predictions";t&&(i+=`${t.constructFiltersUrl()}`);let a=await this.fetchWithAuth(i,r);return e.meta=this.metaRemapper.remapMetaData(a.meta),e.data=await this.predictionRemapper.remapResponseArrayBody(a.data),e};getMyPredictionsNoRemap=async t=>{let e=`/predictions${this.apiSignInUrl}${t.constructFiltersUrl()}`,i="There was a problem fetching own predictions";return await this.fetchWithAuth(e,i)};getUserPredictions=async(t,e,i)=>{let r=new R,a=w(e)?`/predictions/users/${t}${this.apiSignInUrl}${h()}`:`/predictions/users/${t}${this.apiSignInUrl}`,s=`There was a problem fetching predictions for user: ${t}`;i&&(a+=`${i.constructFiltersUrl()}`);let l=await this.fetchWithoutAuth(a,s);return r.meta=this.metaRemapper.remapMetaData(l.meta),r.data=await this.predictionRemapper.remapResponseArrayBody(l.data),r};getUserPredictionsNoRemap=async(t,e)=>{let i=`/predictions/users/${t}${this.apiSignInUrl}${e.constructFiltersUrl()}`,r=`There was a problem fetching predictions for user: ${t}`;return await this.fetchWithoutAuth(i,r)};getGames=async(t,e)=>{let i=w(e)?`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}${h()}`:`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}`,r="There was a problem fetching the games list",a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapPaginatedGames(a)};getGameById=async(t,e)=>{let i=w(e)?`/games/${t}${this.apiSignInUrl}${h()}`:`/games/${t}${this.apiSignInUrl}`,r=`There was a problem fetching the following game: ${t}`,a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapGameByIdResponse(a)};getGamePredictions=async(t,e,i)=>{let r=new R,a=w(e)?`/games/${t}/predictions${this.apiSignInUrl}${h()}`:`/games/${t}/predictions${this.apiSignInUrl}`,s=`There was a problem fetching the predictions for game: ${t}`;i&&(a+=`${i.constructFiltersUrl()}`);let l=await this.fetchWithoutAuth(a,s);return r.meta=this.metaRemapper.remapMetaData(l.meta),r.data=await this.predictionRemapper.remapResponseArrayBody(l.data),r};getUserGameEditions=async(t,e)=>{let i=null,r=w(e)?`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}${h()}`:`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}`,a="There was a problem fetching the games list",s=await this.fetchWithoutAuth(r,a);return s.data.forEach(l=>{l.type==="TOP_X"?i=this.gamesRemapper.remapPaginatedUserTopXEditions(s):l.type==="MATCH_QUIZ"&&(i=this.gamesRemapper.remapPaginatedUserMathQuizEditions(s))}),i};getGameResults=async(t,e,i)=>{let r=w(e)?`/games/${t}/results/${this.apiSignInUrl}${h()}`:`/games/${t}/results/${this.apiSignInUrl}`,a=`There was a problem fetching the results for the following game: ${t}`;i&&(r+=`${i.constructMainFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a);return this.gamesRemapper.remapPaginatedGameResults(s)};getMarketResultsForGame=async(t,e)=>{let i=`/games/${t}/correct-results/${this.apiSignInUrl}`,r=`There was a problem fetching the markets correct results for the following game: ${t}`;w(e)&&(i+=`${h()}`);let a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapGameMarketsResults(a.data)};getContestWinners=async(t,e)=>{let i=`/winners/${this.apiSignInUrl}&contest_id=${t}`,r=`There was a problem fetching winners for the following game: ${t}`;e&&(i+=h());let a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapContestWinners(a)};getPredictionById=async t=>{let e=`/predictions/${t}${this.apiSignInUrl}`,i=`There was a problem fetching info for the following prediction: ${t}`,r=await this.fetchWithoutAuth(e,i);return(await this.predictionRemapper.remapResponseArrayBody([r.data]))[0]};getPredictionsByIds=async t=>{let e=`/predictions/by-ids${this.apiSignInUrl}&prediction_ids=${t.join(",")}`,i="There was a problem fetching predictions",r=await this.fetchWithoutAuth(e,i);return await this.predictionRemapper.remapResponseArrayBody(r.data)}};var Se=class{gameInstanceId=null;fixtures=null};var ro=class{matchId=null;market="BOTH_TEAMS_SCORE";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new tt,this.prediction.value=e}};var ao=class{value};var oo=class{matchId=null;market="CORNERS_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new ao,this.prediction.value=e}};var so=class{value=null};var no=class{matchId=null;market="DOUBLE_CHANCE";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new so,this.prediction.value=e}};var lo=class{value=null};var po=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new lo,this.prediction.value=i}};var co=class{value=null};var uo=class{matchId=null;market="HT_FT";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new co,this.prediction.value=e}};var mo=class{matchId=null;market="PENALTY_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new tt,this.prediction.value=e}};var ho=class{matchId=null;market="RED_CARD_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new tt,this.prediction.value=e}};var Ft=class{errorHandlingMode=null;constructor(t){this.errorHandlingMode=t}validateBodyFields=(t,e)=>{let i=Object.keys(e),r=Object.keys(new Se);switch(t){case"MATCH_QUIZ":i.forEach(n=>{r.includes(n)||this.throwInvalidParamException([n])});break;case"TOP_X":let s=e;s.fixtures.forEach(n=>this.validateMarketTopX(n.market));let l="tiebreaker";i.includes(l)&&s.tiebreaker&&this.validateTiebreaker(s.tiebreaker),i.forEach(n=>{n!=="tiebreaker"&&!r.includes(n)&&this.throwInvalidParamException([n])});break}let a=r.filter(s=>!i.includes(s));return a.length&&this.throwMissingFieldsException("game prediction body",a),e.fixtures.forEach(s=>{this.validateFixtureFields(s)}),e};validateFixture=(t,e,i,r)=>{this.validateMarket(e);let a=Object.values(En),s=Object.values(Rn),l=Object.values(Sn);if(e==="FT_1X2"||e==="HT_1X2"){if(a.includes(i))return new po(t,e,i)}else if(e==="HT_FT"){if(s.includes(i))return new uo(t,i)}else if(e==="DOUBLE_CHANCE"){if(l.includes(i))return new no(t,i)}else if(e==="CORRECT_SCORE"||e==="CORRECT_SCORE_ADVANCED"||e==="CORRECT_SCORE_HT"){if(typeof i=="string"&&/\d+:\d+/.test(i))return new Tt(t,e,i)}else if(e==="CORNERS_MATCH"){if(typeof i=="number")return new oo(t,i)}else if(e==="BOTH_TEAMS_SCORE"){if(this.isPredictionBoolean(i))return new ro(t,i)}else if(e==="RED_CARD_MATCH"){if(this.isPredictionBoolean(i))return new ho(t,i)}else if(e==="PENALTY_MATCH"){if(this.isPredictionBoolean(i))return new mo(t,i)}else if(ct.includes(e)){let n="OWN_GOAL";if(this.validatePlayerId(e,r),e===bi&&this.isPredictionBoolean(i)){let p=r&&r===n?n:r;return new Z(t,e,i,p)}if(r&&this.isPredictionBoolean(i))return new Z(t,e,i,r)}else if(wl.includes(e)){if(this.isPredictionBoolean(i))return new Ie(t,e,i)}else if(Il.includes(e)&&this.isPredictionBoolean(i))return new we(t,e,i);this.throwInvalidPredictionException(i,e)};validateFixtureFields=t=>{let e=Object.keys(t);e.forEach(r=>{Nn.includes(r)||this.throwInvalidParamException([r])});let i=Nn.filter(r=>{if(r!=="matchType"&&!e.includes(r))return r});i.length&&this.throwMissingFieldsException("fixtures",i),this.validatePredictionKey(t.market,t.prediction)};validateTiebreaker=t=>{let e=Object.keys(t);(!e.length||typeof t!="object")&&this.throwInvalidType("tiebreaker","object");let i=Object.keys(new ut)[0];e.forEach(r=>{i!==r&&this.throwInvalidParamException([r])}),e.includes(i)||this.throwMissingFieldsException("tiebreaker",[i]),typeof t.goldenGoal!="number"&&this.throwInvalidType("goldenGoal","number")};validatePredictionKey=(t,e)=>{if(typeof e=="object"){let i=Object.keys(e),r=["value"];if(i.length||this.throwMissingFieldsException("prediction",r),i.length===1&&!i.includes(r[0])&&this.throwInvalidParamException(i),i.length>1){ct.includes(t)&&r.push("playerId");let a=i.filter(s=>!r.includes(s));a.length&&this.throwInvalidParamException(a)}}else this.throwInvalidType("prediction","object")};validatePlayerId=(t,e)=>{let i="playerId";t!==bi&&(e||this.throwInvalidParamException([i]),typeof e!="string"&&this.throwInvalidType(i,"string"))};validateMarket=t=>{Object.values(Y).includes(t)||this.throwInvalidMarketException(t)};validateMarketTopX=t=>{t!=="CORRECT_SCORE"&&t!=="CORRECT_SCORE_ADVANCED"&&this.throwInvalidMarketException(t,"TOP_X")};isPredictionBoolean=t=>typeof t=="boolean";throwInvalidPredictionException=(t,e)=>{let i=Xn(t,e);throw this.errorHandlingMode==="default"?new f(400,"INVALID_PREDICTION",i):new m(400,"INVALID_TYPE",i)};throwInvalidMarketException=(t,e)=>{let i=null;throw e&&e==="TOP_X"?i=Yn(t):i=Mn(t),this.errorHandlingMode==="default"?new f(400,"INVALID_MARKET",i):new m(400,"INVALID_TYPE",i)};throwInvalidParamException=t=>{let e=Jn(t);throw this.errorHandlingMode==="default"?new f(400,"INVALID_FIELD",e):new m(400,"INVALID_TYPE",e)};throwMissingFieldsException=(t,e)=>{let i=Zn(t,e);throw this.errorHandlingMode==="default"?new f(400,"INVALID_FIELD",i):new m(400,"INVALID_TYPE",i)};throwInvalidType=(t,e)=>{let i=tl(t,e);throw this.errorHandlingMode==="default"?new f(400,"INVALID_TYPE",i):new m(400,"INVALID_TYPE",i)}};var go=class{predictorHttps=null;clientHttps=null;idMapping=null;predictorService=null;predictorValidator=null;errorHandlingMode=null;constructor(t,e,i,r){this.predictorHttps=e,this.idMapping=r,this.clientHttps=i,this.errorHandlingMode=t.errorHandlingMode,this.predictorValidator=new Ft(t.errorHandlingMode),this.predictorService=new ht(t,r)}makeFootballPrediction=async(t,e,i,r)=>{let a=this.predictorValidator.validateFixture(t,e,i,r),s=new Se;if(this.idMapping.idSchema!=="native"){let l=a.matchId,n="",p=await this.predictorService.remapMatchIdToNative([l]);if(a.matchId=p[0],this.errorHandlingMode==="default"&&!a.matchId)throw new f(400,"INVALID_FIELD","Match id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&!a.matchId)throw new m(400,"INVALID_FIELD","Match id is invalid!");if(a instanceof Z&&a.prediction.playerId!=="OWN_GOAL"){if(a.prediction.playerId&&(n=a.prediction.playerId,a.prediction.playerId=await this.predictorService.remapPlayerIdToNative([n])),this.errorHandlingMode==="default"&&a.market!==bi&&!a.prediction.playerId)throw new f(400,"INVALID_FIELD","Player id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&a.market!==bi&&!a.prediction.playerId)throw new m(400,"INVALID_FIELD","Player id is invalid!")}s.fixtures=[a];let c=await this.predictorHttps.makeFootballPrediction(s);return c.fixtures.forEach(u=>{u.prediction.playerId&&u.prediction.playerId!=="OWN_GOAL"&&(u.prediction.playerId=n),u.matchId=l}),c}else return s.fixtures=[a],await this.predictorHttps.makeFootballPrediction(s)};getMatchSummary=async(t,e)=>{let i=await this.getMatchSummaryBase(t,e),r=JSON.parse(JSON.stringify(i.predictions)),a=await this.predictorService.remapPlayerIdToIdSchema(r);return i.predictions=a,i};getMarketSummary=async(t,e,i,r)=>{try{let a=await this.getMatchSummaryBase(t,r);return await this.predictorService.getMarketSummary(a,e,i)}catch(a){throw a}};getMatchSummaryBase=async(t,e)=>{if(this.idMapping.idSchema!=="native"){let r=(await this.predictorService.remapMatchIdToNative([t]))[0],a=await this.predictorHttps.getMatchSummary(r,e);return a.matchId=t,a}else return await this.predictorHttps.getMatchSummary(t,e)};getConfig=async()=>{let t=await this.clientHttps.getConfig("predictor");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(t):t};deleteFootballPrediction=async t=>await this.predictorHttps.deleteFootballPrediction(t);getMyPredictions=async t=>{let e=this.predictorService.initPredictionsFilters(t,"user");return await this.predictorHttps.getMyPredictions(e)};getMyPredictionsForMatches=async(t,e)=>{if(this.errorHandlingMode==="default"&&this.predictorService.areIdsExceeded(t))throw new f(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();if(this.errorHandlingMode==="standard"&&this.predictorService.areIdsExceeded(t))throw new m(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.");this.idMapping.idSchema!=="native"&&(t=await this.predictorService.remapMatchIdToNative([...t]));let i=this.predictorService.initPredictionsFilters(e,"matches",t);return await this.predictorHttps.getMyPredictions(i)};getMyCurrentPredictions=async t=>{let e=this.predictorService.initPredictionsFilters(t,"current");return await this.predictorHttps.getMyPredictions(e)};getMyPastPredictions=async t=>{let e=this.predictorService.initPredictionsFilters(t,"past");return await this.predictorHttps.getMyPredictions(e)};getUserPredictions=async(t,e,i)=>{let r=this.predictorService.initPredictionsFilters(e,"user");return await this.predictorHttps.getUserPredictions(t,i,r)};getUserCurrentPredictions=async(t,e,i)=>{let r=this.predictorService.initPredictionsFilters(e,"current");return await this.predictorHttps.getUserPredictions(t,i,r)};getUserPastPredictions=async(t,e,i)=>{let r=this.predictorService.initPredictionsFilters(e,"past");return await this.predictorHttps.getUserPredictions(t,i,r)};getUserPredictionsForMatches=async(t,e,i,r)=>{if(this.errorHandlingMode==="default"&&this.predictorService.areIdsExceeded(e))throw new f(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();if(this.errorHandlingMode==="standard"&&this.predictorService.areIdsExceeded(e))throw new m(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.");this.idMapping.idSchema!=="native"&&(e=await this.predictorService.remapMatchIdToNative([...e]));let a=this.predictorService.initPredictionsFilters(i,"matches",e);return await this.predictorHttps.getUserPredictions(t,r,a)};getPredictionById=async t=>await this.predictorHttps.getPredictionById(t);getPredictionsByIds=async t=>await this.predictorHttps.getPredictionsByIds(t);getMatchMarketsResults=async t=>(this.idMapping.idSchema!=="native"&&(t=(await this.predictorService.remapMatchIdToNative([t]))[0]),await this.predictorService.getMatchMarketsResults(t))};var Re=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(t){this.idMapping=new P(t),this.predictorHttps=new at(t,this.idMapping),this.clientHttps=new N(t),this.predictorFacade=new go(t,this.predictorHttps,this.clientHttps,this.idMapping)}makeFootballPrediction=async(t,e,i,r)=>await this.predictorFacade.makeFootballPrediction(t,e,i,r);getMatchSummary=async(t,e)=>await this.predictorFacade.getMatchSummary(t,e);getMarketSummary=async(t,e,i,r)=>await this.predictorFacade.getMarketSummary(t,e,i,r);getConfig=async()=>await this.predictorFacade.getConfig();deleteFootballPrediction=async t=>await this.predictorFacade.deleteFootballPrediction(t);getMyPredictions=async t=>await this.predictorFacade.getMyPredictions(t);getMyCurrentPredictions=async t=>await this.predictorFacade.getMyCurrentPredictions(t);getMyPastPredictions=async t=>await this.predictorFacade.getMyPastPredictions(t);getMyPredictionsForMatches=async(t,e)=>await this.predictorFacade.getMyPredictionsForMatches(t,e);getUserPredictions=async(t,e,i)=>await this.predictorFacade.getUserPredictions(t,e,i);getUserCurrentPredictions=async(t,e,i)=>await this.predictorFacade.getUserCurrentPredictions(t,e,i);getUserPastPredictions=async(t,e,i)=>await this.predictorFacade.getUserPastPredictions(t,e,i);getUserPredictionsForMatches=async(t,e,i,r)=>await this.predictorFacade.getUserPredictionsForMatches(t,e,i,r);getPredictionById=async t=>await this.predictorFacade.getPredictionById(t);getPredictionsByIds=async t=>await this.predictorFacade.getPredictionsByIds(t);getMatchMarketsResults=async t=>await this.predictorFacade.getMatchMarketsResults(t)};var fo=class{templateId=null;privateLeagueId=null;fromDate=null;toDate=null;pagination=new V};var yo=class{rankType=null;fromDate=null;toDate=null;pagination=new V};var Ce=class{position=null;profileId=null;profileModel=null;points=null;predictionsMade=null};var bo=class{remapResponse=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapData(t.data),t);remapLeagueLeaderboardResponse=t=>(t.meta=this.remapLeagueLeaderboardMeta(t.meta),t.data=this.remapData(t.data),t);remapMeta=t=>{let e=new yo;return e.rankType=t.rank_type,e.fromDate=t.from_date,e.toDate=t.to_date,e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.totalItems=t.pagination.total_items,e.pagination.numberOfPages=t.pagination.number_of_pages,e};remapLeagueLeaderboardMeta=t=>{let e=new fo;return e.templateId=t.template_id,e.privateLeagueId=t.private_league_id,e.fromDate=t.from_date,e.toDate=t.to_date,e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.totalItems=t.pagination.total_items,e.pagination.numberOfPages=t.pagination.number_of_pages,e};remapData=t=>{let e=[];return t.forEach(i=>{let r=new Ce;r.position=i.position,r.profileId=i.profile_id,r.points=i.points,r.predictionsMade=i.predictions_made,e.push(r)}),e}};var Mo=class{templateId="";templateModel=null;challengeId="";challengeModel=null;position="";points=0;type="challenge"};var wo=class{templateId="";templateModel=null;privateLeagueId="";privateLeagueModel=null;position="";points=0;type="private_league"};var Io=class extends Ce{id=null;rankType=null;model=null;gameType=null};var Po=class{remapRankings=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapData(t.data),t);remapRankingsPrivateLeague=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapDataUserRankingPrivateLeague(t.data),t);remapRankingsChallenge=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapDataUserRankingChallenge(t.data),t);remapMeta=t=>{let e=new H;return e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.numberOfPages=t.pagination.number_of_pages,e.pagination.totalItems=t.pagination.total_items,e};remapData(t){let e=[];return t.forEach(i=>{let r=new Io;r.id=i.id,r.rankType=i.rank_type,r.position=i.position,r.points=i.points,r.gameType=i.game_type,delete r.profileId,delete r.profileModel,delete r.predictionsMade,e.push(r)}),e}remapDataUserRankingPrivateLeague(t){let e=[];return t.forEach(i=>{let r=new wo;r.templateId=i.template_id,r.privateLeagueId=i.private_league_id,r.position=i.position,r.points=i.points,e.push(r)}),e}remapDataUserRankingChallenge(t){let e=[];return t.forEach(i=>{let r=new Mo;r.templateId=i.template_id,r.challengeId=i.private_league_id,r.position=i.position,r.points=i.points,e.push(r)}),e}};var _o=class{flags="";status="";type="";activeFrom="";activeTo="";createdFrom="";createdTo="";updatedFrom="";updatedTo=""};var To=class{pagination=new V;filters=new _o};var Ae=class{id=null;name=null;description=null;type=null;fromDate=null;toDate=null;markets=[];teamIds=[];matchIds=[];groups=[];gameIds=[];gameTypes=[];competitionIds=[];excludedProfileIds=[];rules=null;labels=null;customFields=null;branding=null;flags=null;images=new it;status=null;automaticallyChangeStatus=!0;createdAt=null;updatedAt=null;related=null};var vo=class extends Ae{adContent=null};var Fo=class{fromDate=null;toDate=null;matchIds=[]};var Eo=class{groupId=null;label=null;flags=[];filters=null};var So=class extends rt{remapResponse=t=>{let e=[];return t.forEach(i=>{let r=new Ae;r.id=i.id,r.name=i.name,r.description=i.description,r.type=i.type,r.fromDate=i.from_date,r.toDate=i.to_date,r.markets=i.markets?i.markets:null,r.teamIds=i.team_ids?i.team_ids:null,r.matchIds=i.match_ids?i.match_ids:null,r.groups=i.groups?this.remapGroups(i.groups):null,r.gameIds=i.game_ids?i.game_ids:null,r.gameTypes=i.game_types?i.game_types:null,r.competitionIds=i.competition_ids?i.competition_ids:null,r.excludedProfileIds=i.excluded_profile_ids?i.excluded_profile_ids:null,r.rules=i.rules?i.rules:null,r.labels=i.labels?i.labels:null,r.customFields=i.custom_fields?i.custom_fields:null,r.branding=i.branding?this.remapBranding(i.branding):null,r.flags=i.flags?i.flags:null,r.images=i.images?i.images:null,r.status=i.status?i.status:null,r.automaticallyChangeStatus=i.automatically_change_status,r.createdAt=i.created_at,r.updatedAt=i.updated_at,r.related=i.related?this.remapRelated(i.related):null,e.push(r)}),e};remapResponseId=t=>{let e=new vo;return e.id=t.id,e.name=t.name,e.description=t.description,e.type=t.type,e.fromDate=t.from_date,e.toDate=t.to_date,e.markets=t.markets?t.markets:null,e.teamIds=t.team_ids?t.team_ids:null,e.matchIds=t.match_ids?t.match_ids:null,e.groups=t.groups?this.remapGroups(t.groups):null,e.gameIds=t.game_ids?t.game_ids:null,e.gameTypes=t.game_types?t.game_types:null,e.competitionIds=t.competition_ids?t.competition_ids:null,e.excludedProfileIds=t.excluded_profile_ids?t.excluded_profile_ids:null,e.rules=t.rules?t.rules:null,e.flags=t.flags?t.flags:null,e.images=t.images?t.images:null,e.status=t.status?t.status:null,e.automaticallyChangeStatus=t.automatically_change_status,e.related=t.related?this.remapRelated(t.related):null,e.labels=t.labels,e.customFields=t.custom_fields,e.branding=t.branding?this.remapBranding(t.branding):null,e.adContent=t.ad_content,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapMeta=t=>{let e=new To;return e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.totalItems=t.pagination.total_items,e.pagination.numberOfPages=t.pagination.number_of_pages,e.filters.flags=t.filters.flags,e.filters.status=t.filters.status,e.filters.type=t.filters.type,e.filters.activeFrom=t.filters.active_from,e.filters.activeTo=t.filters.active_to,e.filters.createdFrom=t.filters.created_from,e.filters.createdTo=t.filters.created_to,e.filters.updatedFrom=t.filters.updated_from,e.filters.updatedTo=t.filters.updated_to,e};remapRelated=t=>t.map(e=>{let i=new Ee;return i.entityId=e.entity_id,i.entityType=e.entity_type,i});remapGroups=t=>t.map(e=>{let i=new Eo;return i.groupId=e.group_id,i.label=e.label,i.flags=e.flags,i.filters=this.remapGroupFilters(e.filters),i});remapGroupFilters=t=>{let e=new Fo;return e.fromDate=t.from_date,e.toDate=t.to_date,e.matchIds=t.match_ids,e}};var Ro=class{position=null;points=null;predictionsMade=null;profileId=null;profileModel=null;successRatePercent=null};var Co=class{remapHighestSuccessRate=t=>t.map(e=>{let i=new Ro;return i.position=e.position,i.points=e.points,i.predictionsMade=e.predictions_made,i.profileId=e.profile_id,i.successRatePercent=e.success_rate_percent,i})};var Et=class extends T{templateRemapper=null;leaderboardRemapper=null;rankingsRemapper=null;highestSuccessRateRemapper=null;constructor(t){super(t,S(t.environment,"loyalty")),this.templateRemapper=new So,this.leaderboardRemapper=new bo,this.rankingsRemapper=new Po,this.highestSuccessRateRemapper=new Co}getTemplates=async(t,e)=>{let i=t?`/leaderboard/templates/${this.apiSignInUrl}${t.constructFiltersUrl()}`:`/leaderboard/templates/${this.apiSignInUrl}`;i+=w(e)?h():"";let r="There was a problem fetching the list of templates",a=await this.fetchWithoutAuth(i,r),s=JSON.parse(JSON.stringify(a));return s.meta=this.templateRemapper.remapMeta(a.meta),s.data=this.templateRemapper.remapResponse(a.data),s};getTemplateById=async(t,e)=>{let i=w(e)?`/leaderboard/templates/${t}${this.apiSignInUrl}${h()}`:`/leaderboard/templates/${t}${this.apiSignInUrl}`,r=`There was a problem requesting the following template: ${t}`,a=await this.fetchWithoutAuth(i,r);return this.templateRemapper.remapResponseId(a.data)};getLeaderboard=async(t,e,i)=>{let r=w(e)?`/leaderboard/${t}${this.apiSignInUrl}${h()}`:`/leaderboard/${t}${this.apiSignInUrl}`,a=`There was a problem fetching the leaderboard for the following template: ${t}`;i&&(r+=`${i.constructFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a),l=JSON.parse(JSON.stringify(s));return this.leaderboardRemapper.remapResponse(l)};getLeaderboardForGame=async(t,e,i)=>{let r=w(e)?`/leaderboard/games/${t}${this.apiSignInUrl}${h()}`:`/leaderboard/games/${t}${this.apiSignInUrl}`,a=`There was a problem fetching the leaderboard for the following game: ${t}`;i&&(r+=`${i.constructFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a),l=JSON.parse(JSON.stringify(s));return this.leaderboardRemapper.remapResponse(l)};getLeaderboardForLeague=async(t,e)=>{let i=`/private-league/${t}${this.apiSignInUrl}`,r=`There was a problem fetching the leaderboard for the following league: ${t}`;e&&(i+=`${e.constructFiltersUrl()}`);let a=await this.fetchWithoutAuth(i,r);return this.leaderboardRemapper.remapLeagueLeaderboardResponse(a)};getUserRankings=async(t,e,i)=>{let r=`/leaderboard/users/${t}/rankings${this.apiSignInUrl}`,a=`There was a problem fetching the rankings for the following user: ${t}`;e&&(r+=`${e.constructFiltersUrl()}`),w(i)&&(r+=`${h()}`);let s=await this.fetchWithoutAuth(r,a);return this.rankingsRemapper.remapRankings(s)};getHighestSuccessRate=async(t,e)=>{let i=`/statistics/top${this.apiSignInUrl}`,r="There was a problem fetching highest success rate";t&&(i+=`${t.constructFiltersUrl()}`),w(e)&&(i+=`${h()}`);let a=await this.fetchWithoutAuth(i,r);return this.highestSuccessRateRemapper.remapHighestSuccessRate(a.data)};getEntitiesFollows=async(t,e)=>{let i=w(e)?`/statistics/follows${this.apiSignInUrl}${h()}`:`/statistics/follows${this.apiSignInUrl}`,r="There was a problem fetching follows for entities";return t.footballCompetitions&&(i+=`&competitions=${t.footballCompetitions.join(",")}`),t.footballTeams&&(i+=`&teams=${t.footballTeams.join(",")}`),t.footballPlayers&&(i+=`&players=${t.footballPlayers.join(",")}`),(await this.fetchWithoutAuth(i,r)).data};getUserRankingsForPrivateLeagueAndChallenges=async(t,e,i)=>{let r=`/private-league/users/${t}/rankings${this.apiSignInUrl}&private_league_type=${e==="PRIVATE_LEAGUE"?"private":"one_vs_one"}`,a=`There was a problem fetching user rankings for ${e}`;i&&(r+=`${i.constructFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a);return e==="PRIVATE_LEAGUE"?this.rankingsRemapper.remapRankingsPrivateLeague(s):this.rankingsRemapper.remapRankingsChallenge(s)}};var Oe=class{predictorHttps=null;predictorService=null;idMapping=null;clientHttps=null;predictorValidator=null;errorHandlingMode=null;constructor(t){this.predictorValidator=new Ft(t.errorHandlingMode),this.idMapping=new P(t),this.predictorHttps=new at(t,this.idMapping),this.predictorService=new ht(t,this.idMapping),this.clientHttps=new N(t),this.errorHandlingMode=t.errorHandlingMode}getConfig=async()=>{let t=await this.clientHttps.getConfig("matchQuiz");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(t):t};play=async t=>{t=this.predictorValidator.validateBodyFields("MATCH_QUIZ",t);let e=t.fixtures.map(i=>this.predictorValidator.validateFixture(i.matchId,i.market,i.prediction.value,i.prediction.playerId));if(e&&e.length&&this.idMapping.idSchema!=="native"){let i=[],r=[];e.forEach(l=>{i.push(l.matchId),l instanceof Z&&l.prediction.playerId&&l.prediction.playerId!=="OWN_GOAL"&&r.push(l.prediction.playerId)});let a=await this.predictorService.remapMatchIdToNative(i),s={};r&&r.length>0&&(s=await this.predictorService.remapPlayerIdMapToNative(r)),e.forEach((l,n)=>{l.matchId=a[n],l instanceof Z&&l.prediction.playerId!=="OWN_GOAL"&&(l.prediction.playerId=s[l.prediction.playerId])})}return t.fixtures=e,await this.predictorHttps.makeFootballPrediction(t)};delete=async t=>await this.predictorHttps.deleteFootballPrediction(t);getGames=async(t,e)=>{e=e||!1;let i=this.predictorService.initGameFilters("MATCH_QUIZ",t),r=await this.predictorHttps.getGames(i,e);return await this.predictorService.remapMatchIdsFixtures(r)};getGameById=async(t,e)=>{e=e||!1;let i=await this.predictorHttps.getGameById(t,e);return await this.predictorService.remapMatchIdsFixtures(i)};getGamePredictions=async(t,e,i)=>(i=i||!1,e&&(e.type&&delete e.type,e.status&&delete e.status,e=new L(e)),await this.predictorHttps.getGamePredictions(t,i,e));getGameResults=async(t,e,i)=>{i=i||!1,e&&(e=new v(e));let r=await this.predictorHttps.getGameResults(t,i,e);return await this.predictorService.remapMatchIdsFixtures(r)};getCurrentGameResults=async t=>{t=t||!1;let e=new et(null);e.status="OPEN",e.type="MATCH_QUIZ";let i=await this.predictorHttps.getGames(e,t),r=this.predictorService.getCurrentGameId(i);return(await this.getGameResults(r,null,t)).data[0]};getMyGameEditions=async(t,e)=>{t&&t.limit&&this.validateLimitFilterOnGames(t.limit),e=e||!1;let i=this.predictorService.initGameTypePredictions("MATCH_QUIZ",t),r=[],a=await this.predictorHttps.getMyPredictionsNoRemap(i);if(a.data.length>0){a.data.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let s=this.predictorService.initGameFilters("MATCH_QUIZ",null,r),l=await this.predictorHttps.getUserGameEditions(s,e);return await this.predictorService.addPredictionProp(a,l)}else return new R};getMyGamePrediction=async t=>{let e=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),i=await this.predictorHttps.getMyPredictions(e);if(i.data.length>0){let r=i.data.filter(a=>a.gameInstanceId===t);return r.length?r[0]:null}return null};getUserGameEditions=async(t,e,i)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),i=i||!1;let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ",e),a=[],s=await this.predictorHttps.getUserPredictionsNoRemap(t,r);if(s.data.length>0){s.data.forEach(p=>{p.game_instance_id&&a.push(p.game_instance_id)});let l=this.predictorService.initGameFilters("MATCH_QUIZ",null,a),n=await this.predictorHttps.getUserGameEditions(l,i);return await this.predictorService.addPredictionProp(s,n)}else return new R};getUserGamePrediction=async(t,e,i)=>{i=i||!1;let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),a=await this.predictorHttps.getUserPredictions(t,i,r);if(a.data.length>0){let s=a.data.filter(l=>l.gameInstanceId===e);return s.length?s[0]:null}else return null};getMarketsResultsForGame=async(t,e)=>{let i=await this.predictorHttps.getMarketResultsForGame(t,e);return await this.predictorService.completeGameMarketResults(i,"MATCH_QUIZ")};getGameWinners=async(t,e)=>{let i=await this.predictorHttps.getContestWinners(t,e),r=await this.getGameById(t);return i.contestModel=r,this.predictorService.completeContestWinners(i)};validateLimitFilterOnGames=t=>{if(this.errorHandlingMode==="default"&&t>50)throw new f(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.");if(this.errorHandlingMode==="standard"&&t>50)throw new m(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.")}};var Le=class{matchQuizFacade=null;constructor(t){this.matchQuizFacade=new Oe(t)}getConfig=async()=>await this.matchQuizFacade.getConfig();play=async t=>await this.matchQuizFacade.play(t);delete=async t=>await this.matchQuizFacade.delete(t);getGames=async(t,e)=>await this.matchQuizFacade.getGames(t,e);getGameById=async(t,e)=>await this.matchQuizFacade.getGameById(t,e);getGamePredictions=async(t,e,i)=>await this.matchQuizFacade.getGamePredictions(t,e,i);getGameResults=async(t,e,i)=>await this.matchQuizFacade.getGameResults(t,e,i);getCurrentGameResults=async t=>await this.matchQuizFacade.getCurrentGameResults(t);getMyGameEditions=async(t,e)=>await this.matchQuizFacade.getMyGameEditions(t,e);getMyGamePrediction=async t=>await this.matchQuizFacade.getMyGamePrediction(t);getUserGameEditions=async(t,e,i)=>await this.matchQuizFacade.getUserGameEditions(t,e,i);getUserGamePrediction=async(t,e,i)=>await this.matchQuizFacade.getUserGamePrediction(t,e,i);getMarketsResultsForGame=async(t,e)=>await this.matchQuizFacade.getMarketsResultsForGame(t,e);getGameWinners=async(t,e)=>await this.matchQuizFacade.getGameWinners(t,e)};var xe=class{id=null;title=null;description=null;type=null;images=new it;participationCount=null;questionsCount=null;status=null;flags=null;customFields=null;labels=null;branding=null;time=null;points=null;scored=!1;maxAttempts=null;averageScore=null;perfectScore=null;adContent=null;context=null;createdAt=null;updatedAt=null};var Ao=class extends xe{rules=null;questions=[]};var Oo=class{questionId=null;question=null;images=null;embedCode=null;explanation=null;options=[]};var Lo=class{optionId=null;option=null;images=null;correct=null};var xo=class{classicQuizId=null;userId=null;questions=[];correctOptions=null;personalBest=null;points=null;attempts=null};var Do=class{questionId=null;optionId=null;correct=null;correctOptionId=null};var Bo=class{classicQuizId=null;classicQuizModel=null;correct=null;classicQuizQuestions=null;personalBest=null;points=null;answers=[]};var De=class{content=null;tags=[];campaign=null};var Be=class{id=null;model=null;source=null;type=null};var Ne=class{classicQuizIds=null};var No=class{pagination=new V;filters=new Ne};var ko=class{position=null;profileId=null;profileModel=null;points=null};var Uo=class{position=null;classicQuizId=null;classicQuizModel=null;points=null};var Go=class extends rt{remapClassicQuizzes=t=>(t.meta.pagination=this.remapMetaPagination(t.meta.pagination),t.data=t.data.map(e=>this.remapBasicClassicQuiz(e)),t);remapClassicQuizById=t=>{let e=new Ao;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.images=t.images,e.participationCount=t.participation_count,e.questionsCount=t.questions_count,e.status=t.status,e.flags=t.flags,e.adContent=t.ad_content,e.rules=t.rules,e.customFields=t.custom_fields,e.branding=t.branding?this.remapBranding(t.branding):null,e.labels=t.labels,e.time=t.time,e.points=t.points,e.scored=t.scored,e.maxAttempts=t.max_attempts,e.context=t.context?this.remapContext(t.context):t.context,e.averageScore=t.average_score,e.perfectScore=t.perfect_score,e.questions=t.questions.map(i=>this.remapQuestions(i)),e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapClassicQuizParticipation=t=>{let e=new xo;return e.classicQuizId=t.classic_quiz_id,e.userId=t.user_id,e.questions=t.questions?t.questions.map(i=>this.remapParticipationQuestions(i)):null,e.correctOptions=t.correct_options,e.personalBest=t.personal_best,e.points=t.points,e.attempts=t.attempts,e};remapClassicQuizParticipationBody=t=>t.map(e=>({question_id:e.questionId,option_id:e.optionId}));remapUserClassicQuizParticipations=t=>t.map(e=>{let i=new Bo;return i.classicQuizId=e.classic_quiz_id,i.correct=e.correct,i.classicQuizQuestions=e.classic_quiz_questions,i.personalBest=e.personal_best,i.points=e.points,i.answers=e.answers?e.answers.map(r=>this.remapParticipationQuestions(r)):e.answers,i});remapClassicQuizzesLeaderboard=t=>(t.meta=this.remapClassicQuizLeaderboardMeta(t.meta),t.data=t.data.map(e=>this.remapClassicQuizLeaderboard(e)),t);remapClassicQuizUserRankings=t=>(t.meta.pagination=this.remapMetaPaginationRank(t.meta.pagination),t.data=t.data.map(e=>this.remapClassicQuizUserRanking(e)),t);remapMetaPagination=t=>{let e=new nt;return e.itemsPerPage=t.items_per_page,e.nextPageStartsAfter=t.next_page_starts_after,e};remapClassicQuizLeaderboardMeta=t=>{let e=new No;return e.pagination=this.remapMetaPaginationRank(t.pagination),e.filters=this.remapLeaderboardMetaFilters(t.filters),e};remapMetaPaginationRank=t=>{let e=new V;return e.currentPage=t.current_page,e.itemsPerPage=t.items_per_page,e.numberOfPages=t.number_of_pages,e.totalItems=t.total_items,e};remapLeaderboardMetaFilters=t=>{let e=new Ne;return e.classicQuizIds=t?.classic_quiz_ids||null,e};remapClassicQuizUserRanking=t=>{let e=new Uo;return e.position=t.position,e.classicQuizId=t.classic_quiz_id,e.points=t.points,e};remapBasicClassicQuiz=t=>{let e=new xe;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.images=t.images,e.participationCount=t.participation_count,e.questionsCount=t.questions_count,e.status=t.status,e.flags=t.flags,e.customFields=t.custom_fields,e.branding=t.branding?this.remapBranding(t.branding):null,e.labels=t.labels,e.time=t.time,e.averageScore=t.average_score,e.perfectScore=t.perfect_score,e.points=t.points,e.scored=t.scored,e.maxAttempts=t.max_attempts,e.context=t.context?this.remapContext(t.context):t.context,e.adContent=t.ad_content,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapQuestions=t=>{let e=new Oo;return e.questionId=t.question_id,e.question=t.question,e.images=t.images,e.embedCode=t.embed_code,e.explanation=t.explanation,e.options=t.options.map(i=>this.remapOptions(i)),e};remapOptions=t=>{let e=new Lo;return e.optionId=t.option_id,e.option=t.option,e.images=t.images,e.correct=t.correct,e};remapParticipationQuestions=t=>{let e=new Do;return e.questionId=t.question_id,e.optionId=t.option_id,e.correct=t.correct,e.correctOptionId=t.correct_option_id,e};remapClassicQuizLeaderboard=t=>{let e=new ko;return e.position=t.position,e.profileId=t.profile_id,e.points=t.points,e};remapContext=t=>{let e=new De;return e.content=t.content,e.tags=t.tags?t.tags.map(i=>{let r=new Be;return r.id=i.id,r.type=i.type,r.source=i.source,r}):null,e.campaign=t.campaign,e}};var ke=class{id="";title="";description="";images=new it;flags=[];status="";winningCondition="";lives=0;time=0;points=[];customFields=null;branding=null;labels=null;adContent="";context=null;type="";createdAt="";updatedAt=""};var Vo=class extends ke{rules=""};var Ho=class{correctSteps=0;score=0};var $o=class{eitherOrId="";personalBest=0};var Wo=class{instanceId="";eitherOrId="";gameStartedAt="";currentStep=0;currentStreak=0;remainingSteps=0;currentLives=0;currentPoints=0;personalBest=0;steps=[]};var zo=class{main;mobile};var _i=class{id="";label="";images=new zo;value=null};var qo=class{pairId="";userSelection="";correct=null;played=null;timestamp="";optionOne=new _i;optionTwo=new _i};var Qo=class{rangeStartInclusive=0;rangeEndInclusive=0;totalUsers=0};var Ko=class{standings=[];breakdown=[]};var jo=class{userId="";userModel=null;personalBest=""};var Xo=class extends rt{remapEitherOrs=t=>(t.meta.pagination=this.remapMetaPagination(t.meta.pagination),t.data=t.data.map(e=>this.remapBasicEitherOr(e)),t);remapEitherOrById=t=>{let e=new Vo;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.images=t.images,e.status=t.status,e.winningCondition=t.winning_condition,e.lives=t.lives,e.flags=t.flags,e.customFields=t.custom_fields,e.branding=t.branding?this.remapBranding(t.branding):null,e.labels=t.labels,e.time=t.time,e.context=t.context?this.remapContext(t.context):t.context,e.points=t.points?t.points.map(i=>this.remapPoints(i)):t.points,e.rules=t.rules,e.adContent=t.ad_content,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapEitherOrOwnStats=t=>{let e=new $o;return e.eitherOrId=t.either_or_id,e.personalBest=t.personal_best,e};remapEitherOrResults=t=>{let e=new Ko;return e.standings=t.standings?t.standings.map(i=>this.remapResultsStandings(i)):t.standings,e.breakdown=t.breakdown?t.breakdown.map(i=>this.remapResultsBreakdown(i)):t.breakdown,e};remapEitherOrParticipation=t=>{let e=new Wo;return e.instanceId=t.instance_id,e.eitherOrId=t.either_or_id,e.gameStartedAt=t.game_started_at,e.currentStep=t.current_step,e.currentStreak=t.current_streak,e.remainingSteps=t.remaining_steps,e.currentLives=t.current_lives,e.currentPoints=t.current_points,e.personalBest=t.personal_best,e.steps=t.steps?t.steps.map(i=>this.remapParticipationSteps(i)):t.steps,e};remapBasicEitherOr=t=>{let e=new ke;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.images=t.images,e.status=t.status,e.winningCondition=t.winning_condition,e.lives=t.lives,e.flags=t.flags,e.customFields=t.custom_fields,e.branding=t.branding?this.remapBranding(t.branding):null,e.labels=t.labels,e.adContent=t.ad_content,e.context=t.context?this.remapContext(t.context):t.context,e.time=t.time,e.points=t.points?t.points.map(i=>this.remapPoints(i)):t.points,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapMetaPagination=t=>{let e=new nt;return e.itemsPerPage=t.items_per_page,e.nextPageStartsAfter=t.next_page_starts_after,e};remapPoints=t=>{let e=new Ho;return e.correctSteps=t.correct_steps,e.score=t.score,e};remapResultsStandings=t=>{let e=new jo;return e.userId=t.user_id,e.personalBest=t.personal_best,e};remapResultsBreakdown=t=>{let e=new Qo;return e.rangeStartInclusive=t.range_start_inclusive,e.rangeEndInclusive=t.range_end_inclusive,e.totalUsers=t.total_users,e};remapParticipationSteps=t=>{let e=new qo;return e.pairId=t.pair_id,e.userSelection=t.user_selection,e.correct=t.correct,e.played=t.played,e.timestamp=t.timestamp,e.optionOne=t.option_one,e.optionTwo=t.option_two,e};remapContext=t=>{let e=new De;return e.content=t.content,e.tags=t.tags?t.tags.map(i=>{let r=new Be;return r.id=i.id,r.type=i.type,r.source=i.source,r}):null,e.campaign=t.campaign,e}};var Ue=class extends T{classicQuizRemapper=null;eitherOrRemapper=null;constructor(t){super(t,S(t.environment,"miniGames")),this.classicQuizRemapper=new Go,this.eitherOrRemapper=new Xo}getClassicQuizzes=async(t,e)=>{let i=`/classic-quizzes${this.apiSignInUrl}`;t&&(i+=t.constructMainFiltersUrl()),i+=w(e)?h():"";let r="There was a problem with fetching classic quizzes",a=await this.fetchWithoutAuth(i,r);return this.classicQuizRemapper.remapClassicQuizzes(a)};getClassicQuizById=async(t,e,i)=>{let r=`/classic-quizzes/${t}${this.apiSignInUrl}`;e&&(r+=`&include_correct_options=${e}`),w(i)&&(r+=h());let a="There was a problem with fetching classic quiz by ID",s=await this.fetchWithoutAuth(r,a);return this.classicQuizRemapper.remapClassicQuizById(s.data)};participateInClassicQuiz=async(t,e,i)=>{let r=`/classic-quizzes/${t}/participate${this.apiSignInUrl}`,a=`There was a problem with participating in the following classic quiz: ${t}`,s="POST",l={questions:this.classicQuizRemapper.remapClassicQuizParticipationBody(e),include_correct_options:!!i},n=await this.fetchWithAuth(r,a,s,l);return this.classicQuizRemapper.remapClassicQuizParticipation(n.data)};getMyClassicQuizParticipations=async t=>{let e=`/classic-quizzes/participations${this.apiSignInUrl}`;t&&(e+=`${t.constructMainFiltersUrl()}`);let i="There was a problem with fetching user's own Classic Quiz participations",r=await this.fetchWithAuth(e,i);return this.classicQuizRemapper.remapUserClassicQuizParticipations(r.data)};getLeaderboardForClassicQuizzes=async t=>{let e=`/classic-quizzes/rank${this.apiSignInUrl}`;t&&(e+=`${t.constructMainFiltersUrl()}`);let i="There was a problem with fetching classic quizzes leaderboard",r=await this.fetchWithoutAuth(e,i);return this.classicQuizRemapper.remapClassicQuizzesLeaderboard(r)};getClassicQuizzesUserRanking=async(t,e)=>{let i=`/classic-quizzes/users/${t}/rank${this.apiSignInUrl}`;e&&(i+=`${e.constructMainFiltersUrl()}`);let r="There was a problem with fetching user's rankings for classic quizzes",a=await this.fetchWithoutAuth(i,r);return this.classicQuizRemapper.remapClassicQuizUserRankings(a)};getEitherOrs=async(t,e)=>{let i=`/either-or${this.apiSignInUrl}`;t&&(i+=t.constructMainFiltersUrl()),i+=w(e)?h():"";let r="There was a problem with fetching list of Either/Ors",a=await this.fetchWithoutAuth(i,r);return this.eitherOrRemapper.remapEitherOrs(a)};getEitherOrById=async(t,e)=>{let i=`/either-or/${t}${this.apiSignInUrl}`;w(e)&&(i+=h());let r="There was a problem with fetching Either/Or by ID",a=await this.fetchWithoutAuth(i,r);return this.eitherOrRemapper.remapEitherOrById(a.data)};getMyEitherOrStats=async t=>{let e=`/either-or/${t}/own-stats${this.apiSignInUrl}`,i="There was a problem with fetching Either/Or own statistics",r=await this.fetchWithAuth(e,i);return this.eitherOrRemapper.remapEitherOrOwnStats(r.data)};getEitherOrResults=async(t,e)=>{let i=`/either-or/${t}/results${this.apiSignInUrl}${w(e)?h():""}`,r="There was a problem with fetching Either/Or results",a=await this.fetchWithoutAuth(i,r);return this.eitherOrRemapper.remapEitherOrResults(a.data)};participateInEitherOr=async(t,e)=>{let i=`/either-or/${t}/participate${this.apiSignInUrl}`,r="There was a problem with participating in Either/Or",a="POST",s=await this.fetchWithAuth(i,r,a,e);return this.eitherOrRemapper.remapEitherOrParticipation(s.data)}};var gt=class{idSchema;idMapping;constructor(t){this.idSchema=t.idSchema,this.idMapping=new P(t)}remapTagsIds=async(t,e,i)=>{if(!t||!t.length)return t;let r={},a={},s=[];t.forEach(n=>{r.hasOwnProperty(n.type)||(r[n.type]=[],a[n.type]=[]),r[n.type].push(n.id),a[n.type].push(n)});let l=await this.idMapping.idMappingFacade.getEntitiesByIds(r,e,i);for(let[n,p]of Object.entries(a))p.forEach((c,u)=>{c.id=l[n][u],s.push(c)});return s}};var Ge=class extends v{flags=null;status=null;entityIds=null;entityType=null;sort=null;groupByStatus=null;constructor(t){super(t),this.flags=t&&t.flags?t.flags:null,this.status=t&&t.status?t.status:null,this.entityIds=t&&t.entityIds?t.entityIds:null,this.entityType=t&&t.entityType?t.entityType:null,this.sort=t&&t.sort?t.sort:null,this.groupByStatus=t&&t.groupByStatus!==void 0?t.groupByStatus:null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.flags&&this.flags.length>0&&(t+=`&flags=${this.flags.join(",")}`),this.status&&(t+=`&status=${this.status}`),this.entityIds&&this.entityIds.length>0&&(t+=`&entity_ids=${this.entityIds}`),this.sort&&(t+=`&sort=${this.sort}`),this.groupByStatus!==null&&(t+=`&group_by_status=${this.groupByStatus}`),t}};var Yo=class extends Ge{classicQuizIds=null;constructor(t){super(t),this.classicQuizIds=t&&t.classicQuizIds?t.classicQuizIds:null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.classicQuizIds&&this.classicQuizIds.length>0&&(t+=`&classic_quiz_ids=${this.classicQuizIds.join(",")}`),t}};var Ve=class{limit=null;page=null;constructor(t){this.limit=t?.limit||null,this.page=t?.page||null}constructMainFiltersUrl(){let t="";return this.limit&&(t+=`&limit=${this.limit}`),this.page&&(t+=`&page=${this.page}`),t}};var Jo=class extends Ve{classicQuizIds=null;constructor(t){super(t),this.classicQuizIds=t?.classicQuizIds||null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.classicQuizIds&&this.classicQuizIds.length>0&&(t+=`&classic_quiz_ids=${this.classicQuizIds.join(",")}`),t}};var Zo=class extends v{classicQuizIds=null;constructor(t){super(t),this.classicQuizIds=t?.classicQuizIds||null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.classicQuizIds&&this.classicQuizIds.length>0&&(t+=`&classic_quiz_ids=${this.classicQuizIds.join(",")}`),t}};var ts=class extends Ge{eitherOrIds=null;constructor(t){super(t),this.eitherOrIds=t&&t.eitherOrIds?t.eitherOrIds:null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.eitherOrIds&&this.eitherOrIds.length>0&&(t+=`&either_or_ids=${this.eitherOrIds.join(",")}`),t}};var es=class{pair="";answer=""};var is=class extends es{expired=!1;time=0};var St=class{errorHandlingModel=null;entityTypes=["competition","team","player"];constructor(t){this.errorHandlingModel=t.errorHandlingMode}validateFilters=t=>{!t.entityIds&&!t.entityType||(t.entityIds&&!t.entityType&&this.throwException(400,"invalid_filters","You need to use both 'entityIds' and 'entityType' filters together"),!t.entityIds&&t.entityType&&this.throwException(400,"invalid_filters","You need to use both 'entityIds' and 'entityType' filters together"),this.entityTypes.includes(t.entityType)||this.throwException(400,"invalid_filters","Invalid 'entityType' filter. Please use one of the following valid options: competition, team, or player"))};throwException=(t,e,i)=>{throw this.errorHandlingModel==="standard"?new m(t,e,i):new f(t,e,i)}};var rs=class{idSchema=null;idMapping=null;validator=null;https=null;entityTypes=["competition","team","player"];profile=null;football=null;eitherOrTime=0;participationStartTimestamp=0;countdownTimer=0;intervalId=null;currentPairId="";constructor(t){this.idSchema=t.idSchema,this.idMapping=new P(t),this.validator=new St(t),this.profile=new O(t),this.football=new J(t),this.https=new Ue(t)}finalizeMiniGamesFilters=async t=>{if(this.idSchema!=="native"&&t.entityIds&&t.entityIds.length>0){this.validator.validateFilters(t);let e=await this.idMapping.getEntityIdsBySchemaId(Array.from(t.entityIds),t.entityType,"native");t.entityIds=e[t.entityType]}};setProfileModelsForEitherOrStandings=async t=>{let e=t.standings.map(r=>r.userId);if(!e.length)return t;let i=await this.profile.getByIds(e);return t.standings.forEach(r=>r.userModel=i.find(a=>a.id===r.userId)||null),t};setProfileModelsForClassicQuizLeaderboards=async t=>{let e=t.map(r=>r.profileId);if(!e.length)return t;let i=await this.profile.getByIds(e);return t.forEach(r=>r.profileModel=i.find(a=>a.id===r.profileId)||null),t};defaultEitherOrParticipation=async(t,e)=>{if(!this.eitherOrTime&&!e){let a=await this.https.getEitherOrById(t,!0);this.eitherOrTime=a.time;let s=await this.https.participateInEitherOr(t,null);return this.participationStartTimestamp=Date.now(),s}let i=0;if(this.participationStartTimestamp)i=(Date.now()-this.participationStartTimestamp)/1e3;else{if(!this.eitherOrTime){let a=await this.https.getEitherOrById(t,!0);this.eitherOrTime=a.time}i=this.eitherOrTime+1}let r=this.createNewParticipation(i,e);try{let a=await this.https.participateInEitherOr(t,r);return!a.currentLives||!a.remainingSteps?this.resetDefaultParticipationTimers():this.participationStartTimestamp=Date.now(),a}catch(a){throw this.resetDefaultParticipationTimers(),a}};handleEitherOrParticipationWithCallback=async(t,e,i)=>e?await this.eitherOrParticipationWithCallback(t,e,i):await this.initialEitherOrParticipationWithCallback(t,i);initialEitherOrParticipationWithCallback=async(t,e)=>{let i=await this.https.getEitherOrById(t,!0);this.eitherOrTime=i.time;let r=await this.https.participateInEitherOr(t,null);return this.participationStartTimestamp=Date.now(),this.countdownTimer=this.eitherOrTime,this.setCurrentPairId(r),await this.handleEitherOrParticipationCallbackInterface(t,e),r};eitherOrParticipationWithCallback=async(t,e,i)=>{this.intervalId&&clearInterval(this.intervalId);let r=0;if(this.participationStartTimestamp)r=(Date.now()-this.participationStartTimestamp)/1e3;else{if(!this.eitherOrTime){let s=await this.https.getEitherOrById(t,!0);this.eitherOrTime=s.time}r=this.eitherOrTime+1}let a=this.createNewParticipation(r,e);try{let s=await this.https.participateInEitherOr(t,a);return!s.currentLives||!s.remainingSteps?(this.resetCallbackParticipationTimers(),i.onElapsedResponse(s),clearInterval(this.intervalId)):(this.participationStartTimestamp=Date.now(),this.countdownTimer=this.eitherOrTime,this.setCurrentPairId(s),await this.handleEitherOrParticipationCallbackInterface(t,i)),s}catch(s){throw this.resetCallbackParticipationTimers(),clearInterval(this.intervalId),s}};setCurrentPairId=t=>{this.currentPairId=t.steps.find(e=>!e.played).pairId||""};handleEitherOrParticipationCallbackInterface=async(t,e)=>{this.intervalId=setInterval(async()=>{if(this.countdownTimer>0)this.countdownTimer--,e.onTimerTick(this.countdownTimer);else{clearInterval(this.intervalId);let i=(Date.now()-this.participationStartTimestamp)/1e3,r={pair:this.currentPairId,answer:this.currentPairId.split("_")[0]},a=this.createNewParticipation(i,r),s=await this.eitherOrParticipationWithCallback(t,a,e);e.onElapsedResponse(s)}},1e3)};createNewParticipation=(t,e)=>{let i=new is;return i.expired=t>this.eitherOrTime,i.time=Number(t.toFixed(3)),i.pair=e.pair,i.answer=e.answer,i};resetCallbackParticipationTimers=()=>{this.resetDefaultParticipationTimers(),this.countdownTimer=0,this.currentPairId=""};resetDefaultParticipationTimers=()=>{this.eitherOrTime=0,this.participationStartTimestamp=0};setContextTagsModels=async t=>{let e={competitions:[],teams:[],players:[]};if(t.forEach(i=>{i.context&&i.context.tags&&i.context.tags.length>0&&(e.competitions=[...e.competitions,...this.extractEntityIdsFromTags(i.context.tags,"competition")],e.competitions=Array.from(new Set(e.competitions)),e.teams=[...e.teams,...this.extractEntityIdsFromTags(i.context.tags,"team")],e.teams=Array.from(new Set(e.teams)),e.players=[...e.players,...this.extractEntityIdsFromTags(i.context.tags,"player")],e.players=Array.from(new Set(e.players)))}),e.competitions.length){let i=await this.football.footballFacade.getCompetitionsMapWithNativeIds(e.competitions);this.setModelsForContextTags(t,i,"competition")}if(e.teams.length){let i=await this.football.footballFacade.getTeamsMapWithNativeIds(e.teams);this.setModelsForContextTags(t,i,"team")}if(e.players.length){let i=await this.football.footballFacade.getPlayersMapWithNativeIds(e.players);this.setModelsForContextTags(t,i,"player")}};extractEntityIdsFromTags=(t,e)=>t.filter(i=>i.type===e).map(i=>i.id);setModelsForContextTags=(t,e,i)=>{t.forEach(r=>{r.context&&r.context.tags&&r.context.tags.length>0&&r.context.tags.forEach(a=>{a.type===i&&(a.model=i==="player"?e[a.id]:e.get(a.id),a.id=a.model.id)})})}};var as=class{https=null;service=null;activityService=null;idSchema=null;constructor(t){this.https=new Ue(t),this.service=new rs(t),this.activityService=new gt(t),this.idSchema=t.idSchema}getClassicQuizzes=async(t,e,i)=>{t&&(t=new Yo(t),await this.service.finalizeMiniGamesFilters(t));let r=await this.https.getClassicQuizzes(t,i);if(e)await this.service.setContextTagsModels(r.data);else for(let a of r.data)await this.remapTags(a,"native",this.idSchema);return r};getClassicQuizById=async(t,e,i)=>{let r=await this.https.getClassicQuizById(t,e,i);return await this.service.setContextTagsModels([r]),r};participateInClassicQuiz=async(t,e,i)=>await this.https.participateInClassicQuiz(t,e,i);getMyClassicQuizParticipations=async t=>{t&&(t=new Zo(t));let e=await this.https.getMyClassicQuizParticipations(t),i=e.map(a=>a.classicQuizId),r=await this.getClassicQuizzes({classicQuizIds:i});return e.map(a=>{let s=r.data.find(l=>l.id===a.classicQuizId)||null;return{...a,classicQuizModel:s}})};getLeaderboardForClassicQuizzes=async t=>{t&&(t=new Jo(t));let e=await this.https.getLeaderboardForClassicQuizzes(t);return e.data=await this.service.setProfileModelsForClassicQuizLeaderboards(e.data),e};getClassicQuizzesUserRanking=async(t,e)=>{e&&(e=new Ve(e));let i=await this.https.getClassicQuizzesUserRanking(t,e),r=i.data.map(s=>s.classicQuizId),a=await this.getClassicQuizzes({classicQuizIds:r});return i.data=i.data.map(s=>{let l=a.data.find(n=>n.id===s.classicQuizId)||null;return{...s,classicQuizModel:l}}),i};getEitherOrs=async(t,e,i)=>{t&&(t=new ts(t),await this.service.finalizeMiniGamesFilters(t));let r=await this.https.getEitherOrs(t,i);if(e)await this.service.setContextTagsModels(r.data);else for(let a of r.data)await this.remapTags(a,"native",this.idSchema);return r};getEitherOrById=async(t,e)=>{let i=await this.https.getEitherOrById(t,e);return await this.service.setContextTagsModels([i]),i};getMyEitherOrStats=async t=>await this.https.getMyEitherOrStats(t);getEitherOrResults=async(t,e)=>{let i=await this.https.getEitherOrResults(t,e);return await this.service.setProfileModelsForEitherOrStandings(i)};participateInEitherOr=async(t,e,i)=>i?await this.service.handleEitherOrParticipationWithCallback(t,e,i):await this.service.defaultEitherOrParticipation(t,e);calculateEitherOrResultPercentile=async(t,e)=>{if(e==null||isNaN(e)||e<0)return null;if(e===0)return e;let i=await this.getEitherOrResults(t,!0),r=i.breakdown.reduce((s,l)=>s+l.totalUsers,0),a=0;for(let s of i.breakdown)if(a+=s.totalUsers,e>=s.rangeStartInclusive&&e<=s.rangeEndInclusive)return parseFloat((a/r*100).toFixed(1));return null};remapTags=async(t,e,i)=>{if(this.idSchema!="native"&&t.context&&t.context.tags&&t.context.tags.length){let r=JSON.parse(JSON.stringify(t.context.tags)),a=await this.activityService.remapTagsIds(r,e,i);t.context.tags=a}}};var He=class{facade=null;constructor(t){this.facade=new as(t)}getClassicQuizzes=async(t,e,i)=>await this.facade.getClassicQuizzes(t,e,i);getClassicQuizById=async(t,e,i)=>await this.facade.getClassicQuizById(t,e,i);participateInClassicQuiz=async(t,e,i)=>await this.facade.participateInClassicQuiz(t,e,i);getMyClassicQuizParticipations=async t=>await this.facade.getMyClassicQuizParticipations(t);getLeaderboardForClassicQuizzes=async t=>await this.facade.getLeaderboardForClassicQuizzes(t);getClassicQuizzesUserRanking=async(t,e)=>await this.facade.getClassicQuizzesUserRanking(t,e);getEitherOrs=async(t,e,i)=>await this.facade.getEitherOrs(t,e,i);getEitherOrById=async(t,e)=>await this.facade.getEitherOrById(t,e);getMyEitherOrStats=async t=>await this.facade.getMyEitherOrStats(t);getEitherOrResults=async(t,e)=>await this.facade.getEitherOrResults(t,e);participateInEitherOr=async(t,e,i)=>await this.facade.participateInEitherOr(t,e,i);calculateEitherOrResultPercentile=async(t,e)=>await this.facade.calculateEitherOrResultPercentile(t,e)};var $e=class{idMapping=null;predictorHttps=null;predictorService=null;predictorValidator=null;clientHttps=null;errorHandlingMode=null;constructor(t,e){this.idMapping=e,this.errorHandlingMode=t.errorHandlingMode,this.predictorValidator=new Ft(t.errorHandlingMode),this.predictorHttps=new at(t,e),this.predictorService=new ht(t,e),this.clientHttps=new N(t)}getConfig=async()=>{let t=await this.clientHttps.getConfig("topX");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(t):t};getGames=async(t,e)=>{e=e||!1;let i=this.predictorService.initGameFilters("TOP_X",t),r=await this.predictorHttps.getGames(i,e);return await this.predictorService.remapMatchIdsFixtures(r)};getGameById=async(t,e)=>{e=e||!1;let i=await this.predictorHttps.getGameById(t,e);return await this.predictorService.remapMatchIdsFixtures(i)};getGamePredictions=async(t,e,i)=>(i=i||!1,e&&(e.type&&delete e.type,e.status&&delete e.status,e=new L(e)),await this.predictorHttps.getGamePredictions(t,i,e));getGameResults=async(t,e,i)=>{i=i||!1,e&&(e=new et(e));let r=await this.predictorHttps.getGameResults(t,i,e);return await this.predictorService.remapMatchIdsFixtures(r)};getCurrentGameResults=async t=>{t=t||!1;let e=new et(null);e.status="OPEN",e.type="TOP_X";let i=await this.predictorHttps.getGames(e,t),r=this.predictorService.getCurrentGameId(i);return(await this.getGameResults(r,null,t)).data[0]};play=async t=>{let e=new Te(t);if(e=this.predictorValidator.validateBodyFields("TOP_X",e),e.fixtures=e.fixtures.map(r=>this.predictorValidator.validateFixture(r.matchId,r.market,r.prediction.value)),this.idMapping.idSchema!=="native"){let r=[];e.fixtures.forEach(s=>r.push(s.matchId));let a=await this.predictorService.remapMatchIdToNative(r);e.fixtures.forEach(s=>s.matchId=a.shift())}let i=await this.predictorHttps.makeFootballPrediction(e);return i.fixtures.forEach(r=>{r.matchId=r.matchModel.id}),i};delete=async t=>await this.predictorHttps.deleteFootballPrediction(t);getMyGameEditions=async(t,e)=>{t&&t.limit&&this.validateLimitFilterOnGames(t.limit),e=e||!1;let i=this.predictorService.initGameTypePredictions("TOP_X",t),r=[],a=await this.predictorHttps.getMyPredictionsNoRemap(i);if(a.data.length>0){a.data.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let s=this.predictorService.initGameFilters("TOP_X",null,r),l=await this.predictorHttps.getUserGameEditions(s,e);return await this.predictorService.addPredictionProp(a,l)}else return new R};getMyGamePrediction=async t=>{let e=this.predictorService.initGameTypePredictions("TOP_X"),i=await this.predictorHttps.getMyPredictions(e);if(i.data.length>0){let r=i.data.filter(a=>a.gameInstanceId===t);return r.length?r[0]:null}return null};getUserGameEditions=async(t,e,i)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),i=i||!1;let r=this.predictorService.initGameTypePredictions("TOP_X",e),a=[],s=await this.predictorHttps.getUserPredictionsNoRemap(t,r);if(s.data.length>0){s.data.forEach(p=>{p.game_instance_id&&a.push(p.game_instance_id)});let l=this.predictorService.initGameFilters("TOP_X",null,a),n=await this.predictorHttps.getUserGameEditions(l,i);return await this.predictorService.addPredictionProp(s,n)}else return new R};getUserGamePrediction=async(t,e,i)=>{i=i||!1;let r=this.predictorService.initGameTypePredictions("TOP_X"),a=await this.predictorHttps.getUserPredictions(t,i,r);if(a.data.length>0){let s=a.data.filter(l=>l.gameInstanceId===e);return s.length?s[0]:null}else return null};getMarketsResultsForGame=async(t,e)=>{let i=await this.predictorHttps.getMarketResultsForGame(t,e);return await this.predictorService.completeGameMarketResults(i,"TOP_X")};getGameWinners=async(t,e)=>{let i=await this.predictorHttps.getContestWinners(t,e),r=await this.getGameById(t);return i.contestModel=r,this.predictorService.completeContestWinners(i)};validateLimitFilterOnGames=t=>{if(this.errorHandlingMode==="default"&&t>50)throw new f(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.");if(this.errorHandlingMode==="standard"&&t>50)throw new m(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.")}};var We=class{topXFacade=null;idMapping=null;constructor(t){this.idMapping=new P(t),this.topXFacade=new $e(t,this.idMapping)}getConfig=async()=>await this.topXFacade.getConfig();getGames=async(t,e)=>await this.topXFacade.getGames(t,e);getGameById=async(t,e)=>await this.topXFacade.getGameById(t,e);getGamePredictions=async(t,e,i)=>await this.topXFacade.getGamePredictions(t,e,i);getGameResults=async(t,e,i)=>await this.topXFacade.getGameResults(t,e,i);getCurrentGameResults=async t=>await this.topXFacade.getCurrentGameResults(t);play=async t=>await this.topXFacade.play(t);delete=async t=>await this.topXFacade.delete(t);getMyGameEditions=async(t,e)=>await this.topXFacade.getMyGameEditions(t,e);getMyGamePrediction=async t=>await this.topXFacade.getMyGamePrediction(t);getUserGameEditions=async(t,e,i)=>await this.topXFacade.getUserGameEditions(t,e,i);getUserGamePrediction=async(t,e,i)=>await this.topXFacade.getUserGamePrediction(t,e,i);getMarketsResultsForGame=async(t,e)=>await this.topXFacade.getMarketsResultsForGame(t,e);getGameWinners=async(t,e)=>await this.topXFacade.getGameWinners(t,e)};var os=class{general;predictor;topX;matchQuiz};var ss=class{predictor;topX;matchQuiz;games;football;classicQuizzes;eitherOr;discussions;potm;poll};var Rt=class{limit=null;page=null;constructor(t){this.limit=t.limit?t.limit:null,this.page=t.page?t.page:null}constructFiltersUrl(){let t="";return this.limit&&(t+="&",t+=`limit=${this.limit}`),this.page&&(t+="&",t+=`page=${this.page}`),t}};var ns=class extends Rt{templateId=null;constructor(t){super(t),this.templateId=t?.templateId||null}constructFiltersUrl(){let t=super.constructFiltersUrl();return this.templateId&&(t+=`&template_id=${this.templateId}`),t}};var ls=class extends Rt{sortOrder=null;rankType=null;leaderboardIds=null;gameType=null;constructor(t){super(t),this.sortOrder=t.sortOrder,this.rankType=t.rankType,this.leaderboardIds=t.leaderboardIds,this.gameType=t.type&&t.type.toLowerCase()==="game"?t.gameType:null}constructFiltersUrl=()=>{let t=super.constructFiltersUrl();return this.sortOrder&&(t+="&",t+=`sort_order=${this.sortOrder}`),this.rankType&&(t+="&",t+=`rank_type=${this.rankType}`),this.leaderboardIds&&(t+="&",t+=`type_ids=${this.leaderboardIds.join(",")}`),this.gameType&&(t+="&",t+=`game_type=${this.gameType}`),t}};var ps=class{idMappingService=null;profileNamespace=null;footballNamespace=null;topXNamespace=null;matchQuizNamespace=null;miniGamesNamespace=null;errorHandlingMode=null;constructor(t){this.idMappingService=new P(t),this.profileNamespace=new O(t),this.footballNamespace=new J(t),this.topXNamespace=new We(t),this.matchQuizNamespace=new Le(t),this.miniGamesNamespace=new He(t),this.errorHandlingMode=t.errorHandlingMode}remapTemplatesIds=async t=>{if(t.length>0){let e=[],i=[],r=[],a=[],s=[],l=[];t.forEach(c=>{c.teamIds&&c.teamIds.length>0&&(e=[...e,...c.teamIds]),c.matchIds&&c.matchIds.length>0&&(r=[...r,...c.matchIds]),c.competitionIds&&c.competitionIds.length>0&&(s=[...s,...c.competitionIds])});let n={team:e,match:r,competition:s},p=await this.idMappingService.idMappingFacade.getEntitiesByIds(n,"native",this.idMappingService.idSchema);return i=[...p.team],a=[...p.match],l=[...p.competition],t.forEach(c=>{c.teamIds&&c.teamIds.length>0&&(c.teamIds=c.teamIds.map(u=>u=p.team.shift())),c.matchIds&&c.matchIds.length>0&&(c.matchIds=c.matchIds.map(u=>u=p.match.shift())),c.competitionIds&&c.competitionIds.length>0&&(c.competitionIds=c.competitionIds.map(u=>u=p.competition.shift()))}),t}return t};remapTemplateGroupMatchIds=async t=>{if(t&&t.length>0){for(let e of t)if(!(!e.filters.matchIds||!e.filters.matchIds.every(r=>r))&&e.filters.matchIds.length>0){let r={match:Array.from(e.filters.matchIds)},a=await this.idMappingService.idMappingFacade.getEntitiesByIds(r,"native",this.idMappingService.idSchema);e.filters.matchIds=Array.from(a.match)}}};addProfileModelToLeaderboard=async t=>{if(t.length>0){let e=[],i=t.map(a=>a.profileId);if(!i.length)return t;let r=await this.profileNamespace.getByIds(i);return t.forEach(a=>{r.forEach(s=>{s.id===a.profileId&&(delete s.interests,a.profileModel=s)}),a.profileModel||(a.profileModel=null),e.push(a)}),e}return t};buildOldClientBadges=t=>{let e=new os;return e.general=this.extractEnabledBadgesId(t.general),e.predictor=this.extractEnabledBadgesId(t.predictor),e.topX=this.extractEnabledBadgesId(t.topX),e.matchQuiz=this.extractEnabledBadgesId(t.matchQuiz),e};buildNewClientBadges=t=>{let e=new ss;return e.predictor=this.extractEnabledBadgesId(t.predictor),e.topX=this.extractEnabledBadgesId(t.topX),e.matchQuiz=this.extractEnabledBadgesId(t.matchQuiz),e.games=this.extractEnabledBadgesId(t.games),e.football=this.extractEnabledBadgesId(t.football),e.classicQuizzes=this.extractEnabledBadgesId(t.classicQuizzes),e.eitherOr=this.extractEnabledBadgesId(t.eitherOr),e.discussions=this.extractEnabledBadgesId(t.discussions),e.potm=this.extractEnabledBadgesId(t.voting.potm),e.poll=this.extractEnabledBadgesId(t.voting.poll),e};initFilters=(t,e)=>{switch(e){case"loyalty":t&&(t=new Rt(t));break;case"rankings":t&&(t=new ls(t));break;case"league_leaderboard":t&&(t=new ns(t))}return t};addProfileModelToHighestSuccessRate=async t=>{let e=t.map(r=>r.profileId);if(!e.length)return t;let i=await this.profileNamespace.getByIds(e);return t.map(r=>(i.forEach(a=>{a.id===r.profileId&&(delete a.interests,r.profileModel=a)}),r))};extractRankingsIdsMap=t=>{let e=[],i=[],r=[];return t.forEach(a=>{a.rankType==="GAME"&&a.gameType==="TOP_X"?e.push(a.id):a.rankType==="GAME"&&a.gameType==="MATCH_QUIZ"?i.push(a.id):a.rankType==="TEMPLATE"&&r.push(a.id)}),[e,i,r]};setModelsForUserRankings=(t,e,i,r)=>(r.data.forEach(a=>{a.gameType==="MATCH_QUIZ"&&e?a.model=e.filter(s=>s.id===a.id)[0]:a.gameType==="TOP_X"&&t?a.model=t.filter(s=>s.id===a.id)[0]:a.rankType==="TEMPLATE"&&i&&(a.model=i.filter(s=>s.id===a.id)[0])}),r);completeContestWinners=async t=>{if(t.userList&&t.userList.length){let e=t.userList.map(r=>r.profileId),i=await this.profileNamespace.getByIds(e);t.userList.forEach(r=>{let a=i.filter(s=>s.id===r.profileId)[0];delete a.interests,r.profileModel=a})}return t};validateEntitiesFollowsFilters=t=>{if(!t||(!t.footballCompetitions||!t.footballCompetitions.length)&&(!t.footballTeams||!t.footballTeams.length)&&(!t.footballPlayers||!t.footballPlayers.length))throw this.errorHandlingMode==="default"?new f(400,"invalid_filters","At least one of footballCompetitions, footballTeams or footballPlayers properties should be provided for filters."):new m(400,"invalid_filters","At least one of footballCompetitions, footballTeams or footballPlayers properties should be provided for filters.");if(t.footballCompetitions&&t.footballCompetitions.length>24||t.footballTeams&&t.footballTeams.length>24||t.footballPlayers&&t.footballPlayers.length>24)throw this.errorHandlingMode==="default"?new f(400,"EXCEEDED_LENGTH","Maximum length per entity should be 24 or less."):new m(400,"EXCEEDED_LENGTH","Maximum length per entity should be 24 or less.")};remapEntitiesFollowsFilters=async t=>{let e=JSON.parse(JSON.stringify(t)),i={},r={};e.footballCompetitions&&e.footballCompetitions.length&&(r.competition=e.footballCompetitions),e.footballTeams&&e.footballTeams.length&&(r.team=e.footballTeams),e.footballPlayers&&e.footballPlayers.length&&(r.player=e.footballPlayers);let a=await this.idMappingService.idMappingFacade.getEntitiesByIds(r,this.idMappingService.idSchema,"native");return Object.keys(a).forEach(s=>{s==="competition"?i.footballCompetitions=a[s]:s==="team"?i.footballTeams=a[s]:s==="player"&&(i.footballPlayers=a[s])}),i};addModelsToEntitiesFollows=async t=>{let e=[],i="fb:c:",r=new Map,a=[],s="fb:t:",l=new Map,n=[],p="fb:p:",c=null;return t.breakdown.forEach(u=>{u.id.includes(i)?e.push(u.id):u.id.includes(s)?a.push(u.id):u.id.includes(p)&&n.push(u.id)}),e.length&&(r=await this.footballNamespace.footballFacade.competitionsFacade.getCompetitionsMapWithNativeIds(e)),a.length&&(l=await this.footballNamespace.footballFacade.teamsFacade.getTeamsMapWithNativeIds(a)),n.length&&(c=await this.footballNamespace.footballFacade.playerFacade.getPlayersMapWithNativeIds(n)),t.breakdown.forEach(u=>{u.id.includes(i)?(u.model=r.get(u.id),u.id=u.model.id):u.id.includes(s)?(u.model=l.get(u.id),u.id=u.model.id):u.id.includes(p)&&(u.model=c[u.id],u.id=u.model.id)}),t};initMatchFiltersForTemplates=(t,e)=>{let i=[],r=[],a=[],s=this.reformatDate(t.fromDate),l=this.reformatDate(t.toDate,!0),n=500;if(t.competitionIds&&t.competitionIds.length>0&&(i=Array.from(t.competitionIds)),t.teamIds&&t.teamIds.length>0&&(r=Array.from(t.teamIds)),t.matchIds&&t.matchIds.length>0&&(a=Array.from(t.matchIds)),e){let c=t.groups.find(d=>d.groupId===e);if(!c)throw this.errorHandlingMode==="default"?new f(400,"invalid_template_group_id","There is no group in this template with the provided groupId"):new m(400,"invalid_template_group_id","There is no group in this template with the provided groupId");if(!c.filters)throw this.errorHandlingMode==="default"?new f(400,"invalid_template_group_filters","The provided template group has no filters"):new m(400,"invalid_template_group_filters","The provided template group has no filters");s=this.reformatDate(c.filters.fromDate),l=this.reformatDate(c.filters.toDate,!0);let u=c.filters.matchIds.every(d=>d);c.filters.matchIds.length>0&&u&&(a=Array.from(c.filters.matchIds))}return new It({competitionIds:i,teamIds:r,matchIds:a,fromDate:s,toDate:l,limit:n})};reformatDate=(t,e)=>{let i=new Date(t);e&&i.setUTCHours(23,59,59);let r=i.toISOString();return r=r.slice(0,-5)+"Z",r};extractEnabledBadgesId=t=>{let e=[];return t.forEach(i=>{i.enabled&&e.push(i.id)}),e};addEntityModelToFootballBadges=async t=>{let e=[],i=[],r=[],a=[];if(t.football&&t.football.length>0&&(e=t.football.filter(l=>l.requirements.entityType.toLocaleLowerCase()==="competition").map(l=>l.requirements.entityId),i=t.football.filter(l=>l.requirements.entityType.toLocaleLowerCase()==="team").map(l=>l.requirements.entityId),r=t.football.filter(l=>l.requirements.entityType.toLocaleLowerCase()==="player").map(l=>l.requirements.entityId),a=t.football.filter(l=>l.requirements.entityType.toLocaleLowerCase()==="match").map(l=>l.requirements.entityId)),t.voting&&t.voting.poll&&t.voting.poll.length>0){let[l,n,p,c]=this.extractEntityIdsFromBadges(t.voting.poll);e=e.concat(l),e=Array.from(new Set(e)),i=i.concat(n),i=Array.from(new Set(i)),r=r.concat(p),r=Array.from(new Set(r)),a=a.concat(c),a=Array.from(new Set(a))}if(t.voting&&t.voting.potm&&t.voting.potm.length>0){let[l,n,p,c]=this.extractEntityIdsFromBadges(t.voting.potm);e=e.concat(l),e=Array.from(new Set(e)),i=i.concat(n),i=Array.from(new Set(i)),r=r.concat(p),r=Array.from(new Set(r)),a=a.concat(c),a=Array.from(new Set(a))}let s=await this.fetchFootballEntities(e,i,r,a);t.football&&t.football.length>0&&t.football.forEach(l=>{this.setEntityModelsFromMap(l.requirements,"competition",s.competitions),this.setEntityModelsFromMap(l.requirements,"team",s.teams),this.setEntityModelsFromObject(l.requirements,"player",s.players),this.setEntityModelsFromObject(l.requirements,"match",s.matches)}),t.voting&&t.voting.poll&&t.voting.poll.length>0&&t.voting.poll.forEach(l=>{this.setEntityModelsFromMap(l.requirements,"competition",s.competitions),this.setEntityModelsFromMap(l.requirements,"team",s.teams),this.setEntityModelsFromObject(l.requirements,"player",s.players),this.setEntityModelsFromObject(l.requirements,"match",s.matches)}),t.voting&&t.voting.potm&&t.voting.potm.length>0&&t.voting.potm.forEach(l=>{this.setEntityModelsFromMap(l.requirements,"competition",s.competitions),this.setEntityModelsFromMap(l.requirements,"team",s.teams),this.setEntityModelsFromObject(l.requirements,"player",s.players),this.setEntityModelsFromObject(l.requirements,"match",s.matches)})};setEntityModelsFromMap=(t,e,i)=>{t.entityType===e&&(t.entityModel=i&&i.get(t.entityId)||null,t.entityModel&&(t.entityId=t.entityModel.id))};setEntityModelsFromObject=(t,e,i)=>{t.entityType===e&&(t.entityModel=i[t.entityId]?i[t.entityId]:null,t.entityModel&&(t.entityId=t.entityModel.id))};fetchFootballEntities=async(t,e,i,r)=>{let a={competitions:null,teams:null,players:null,matches:null};if(t.length){let s=await this.footballNamespace.footballFacade.getCompetitionsMapWithNativeIds(t);a.competitions=s}if(e.length){let s=await this.footballNamespace.footballFacade.getTeamsMapWithNativeIds(e);a.teams=s}if(i.length){let s=await this.footballNamespace.footballFacade.getPlayersMapWithNativeIds(i);a.players=s}if(r.length){let s=await this.footballNamespace.footballFacade.getMatchesMapWithNativeIds(r);a.matches=s}return a};extractEntityIdsFromBadges=t=>{let e=t.filter(s=>s.requirements.entityType&&s.requirements.entityType.toLocaleLowerCase()==="competition").map(s=>s.requirements.entityId),i=t.filter(s=>s.requirements.entityType&&s.requirements.entityType.toLocaleLowerCase()==="team").map(s=>s.requirements.entityId),r=t.filter(s=>s.requirements.entityType&&s.requirements.entityType.toLocaleLowerCase()==="player").map(s=>s.requirements.entityId),a=t.filter(s=>s.requirements.entityType&&s.requirements.entityType.toLocaleLowerCase()==="match").map(s=>s.requirements.entityId);return[e,i,r,a]};addGameModelToGamesBadges=async t=>{if(!t.games||t.games.length===0)return;let e=this.getGameIdsFromGamesBadge(t.games,"top_x"),i=this.getGameIdsFromGamesBadge(t.games,"match_quiz"),r=this.getGameIdsFromGamesBadge(t.games,"classic_quiz"),a=this.getGameIdsFromGamesBadge(t.games,"either_or"),s=await this.fetchGamesEntities(e,i,r,a);t.games.forEach(l=>{l.requirements.specificGames&&l.requirements.specificGames.forEach(n=>{n.gameModel=s.find(p=>p.id===n.gameId)||null})})};getGameIdsFromGamesBadge=(t,e)=>{let i=t.filter(r=>r.requirements.specificGames?r.requirements.specificGames.some(a=>a.gameType.toLocaleLowerCase()===e):!1).map(r=>r.requirements.specificGames.map(a=>a.gameId));return Array.prototype.concat.apply([],i)};fetchGamesEntities=async(t,e,i,r)=>{let a=[];if(t.length){let s=await this.topXNamespace.getGames({gameIds:t});a=[...a,...s.data]}if(e.length){let s=await this.matchQuizNamespace.getGames({gameIds:e});a=[...a,...s.data]}if(i.length){let s=await this.miniGamesNamespace.getClassicQuizzes({classicQuizIds:i});a=[...a,...s.data]}if(r.length){let s=await this.miniGamesNamespace.getEitherOrs({eitherOrIds:r});a=[...a,...s.data]}return a}};var cs=class{validate=(t,e)=>{t.market&&this.validateMarket(t.market,e),t.fromDate&&this.validateDate(t.fromDate,"fromDate",e),t.toDate&&this.validateDate(t.toDate,"toDate",e),t.usersCount&&this.validateNumberFilters(t.usersCount,"usersCount",e),t.minimumPredictions&&this.validateNumberFilters(t.minimumPredictions,"minimumPredictions",e)};validateMarket=(t,e)=>{if(!Object.keys(Y).includes(t)){let r=Mn(t);throw e==="default"?new f(400,"INVALID_MARKET",r):new m(400,"INVALID_MARKET",r)}};validateDate=(t,e,i)=>{let r=/^\d{4}-\d{2}-\d{2}$/;if(typeof t!="string")throw i==="default"?new f(400,"invalid_filters","You have provided invalid type. The valid type is "+`string for ${e} filter`):new m(400,"invalid_filters","You have provided invalid type. The valid type is "+`string for ${e} filter`);if(!r.test(t))throw i==="default"?new f(400,"invalid_filters","You have provided invalid value. The valid value is "+`YYYY-MM-DD for ${e}`):new m(400,"invalid_filters","You have provided invalid value. The valid value is "+`YYYY-MM-DD for ${e}`)};validateNumberFilters=(t,e,i)=>{let r=e==="usersCount"?1:0,a=e==="usersCount"?1e3:1e6;if(typeof t!="number")throw i==="default"?new f(400,"invalid_filters","You have provided invalid type. The valid type is "+`number for ${e} filter`):new m(400,"invalid_filters","You have provided invalid type. The valid type is "+`number for ${e} filter`);if(t<r||t>a)throw i==="default"?new f(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${a}`):new m(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${a}`)}};var us=class{market;fromDate;toDate;usersCount;minimumPredictions;constructor(t){this.market=t.market?t.market:null,this.fromDate=t.fromDate?t.fromDate:null,this.toDate=t.toDate?t.toDate:null,this.usersCount=t.usersCount?t.usersCount:null,this.minimumPredictions=t.minimumPredictions?t.minimumPredictions:null}constructFiltersUrl(){let t="";return this.market&&(t+="&",t+=`market=${this.market}`),this.fromDate&&(t+="&",t+=`from_date=${this.fromDate}`),this.toDate&&(t+="&",t+=`to_date=${this.toDate}`),this.usersCount&&(t+="&",t+=`users_count=${this.usersCount}`),this.minimumPredictions&&(t+="&",t+=`minimum_predictions=${this.minimumPredictions}`),t}};var ds=class{flags=null;status=null;type=null;activeFrom=null;activeTo=null;createdFrom=null;createdTo=null;updatedFrom=null;updatedTo=null;constructor(t){this.flags=t.flags?t.flags:null,this.status=t.status?t.status:null,this.type=t.type?t.type:null,this.activeFrom=t.activeFrom?t.activeFrom:null,this.activeTo=t.activeTo?t.activeTo:null,this.createdFrom=t.createdFrom?t.createdFrom:null,this.createdTo=t.createdTo?t.createdTo:null,this.updatedFrom=t.updatedFrom?t.updatedFrom:null,this.updatedTo=t.updatedTo?t.updatedTo:null}constructFiltersUrl(){let t="";return this.flags&&this.flags.length>0&&(t+="&",t+=`flags=${this.flags.join(",")}`),this.status&&(t+="&",t+=`status=${this.status}`),this.type&&(t+="&",t+=`type=${this.type}`),this.activeFrom&&(t+="&",t+=`active_from=${this.activeFrom}`),this.activeTo&&(t+="&",t+=`active_to=${this.activeTo}`),this.createdFrom&&(t+="&",t+=`created_from=${this.createdFrom}`),this.createdTo&&(t+="&",t+=`created_to=${this.createdTo}`),this.updatedFrom&&(t+="&",t+=`updated_from=${this.updatedFrom}`),this.updatedTo&&(t+="&",t+=`updated_to=${this.updatedTo}`),t}};var ms=class{config=null;clientHttps=null;loyaltyHttps=null;loyaltyService=null;profileFacade=null;loyaltyValidator=null;idMapping=null;topXFacade=null;matchQuizFacade=null;predictorHttps=null;errorHandlingMode=null;football=null;constructor(t,e,i,r,a){this.config=t,this.clientHttps=e,this.loyaltyHttps=i,this.profileFacade=new lt(a,r),this.loyaltyService=new ps(this.config),this.loyaltyValidator=new cs,this.idMapping=new P(t),this.topXFacade=new $e(t,this.idMapping),this.matchQuizFacade=new Oe(t),this.predictorHttps=new at(t,this.idMapping),this.errorHandlingMode=t.errorHandlingMode,this.football=new J(t)}getConfig=async()=>await this.clientHttps.getConfig("loyalty");getConfigV2=async t=>{let e=await this.clientHttps.getNewLoyaltyConfig(t);return await this.loyaltyService.addEntityModelToFootballBadges(e.rewards.badges),await this.loyaltyService.addGameModelToGamesBadges(e.rewards.badges),e};getClientBadges=async()=>{let t=await this.getConfig();return this.loyaltyService.buildOldClientBadges(t.rewards.badges)};getClientBadgesV2=async t=>{let e=await this.clientHttps.getNewLoyaltyConfig(t);return this.loyaltyService.buildNewClientBadges(e.rewards.badges)};getTemplates=async(t,e)=>{if(t&&(t=new ds(t)),this.config.idSchema==="native")return await this.loyaltyHttps.getTemplates(t,e);let i=await this.loyaltyHttps.getTemplates(t,e);i.data=await this.loyaltyService.remapTemplatesIds([...i.data]);for(let r of i.data)await this.loyaltyService.remapTemplateGroupMatchIds(r.groups);return i};getTemplateById=async(t,e)=>{let i=await this.loyaltyHttps.getTemplateById(t,e);if(this.config.idSchema==="native")return i;let r=await this.loyaltyService.remapTemplatesIds([i]);return await this.loyaltyService.remapTemplateGroupMatchIds(r[0].groups),r[0]};getLeaderboard=async(t,e,i)=>{e=this.loyaltyService.initFilters(e,"loyalty");let r=await this.loyaltyHttps.getLeaderboard(t,i,e);return r.data=await this.loyaltyService.addProfileModelToLeaderboard(r.data),r};getLeaderboardForGame=async(t,e,i)=>{e=this.loyaltyService.initFilters(e,"loyalty");let r=await this.loyaltyHttps.getLeaderboardForGame(t,i,e);return r.data=await this.loyaltyService.addProfileModelToLeaderboard(r.data),r};getLeaderboardForLeague=async(t,e)=>{e=this.loyaltyService.initFilters(e,"league_leaderboard");let i=await this.loyaltyHttps.getLeaderboardForLeague(t,e);return i.data=await this.loyaltyService.addProfileModelToLeaderboard(i.data),i};getOwnRankings=async(t,e)=>{let{id:i}=await this.profileFacade.getOwn();return this.getUserRankings(i,t,e)};getUserRankings=async(t,e,i)=>{e=this.loyaltyService.initFilters(e,"rankings");let r=await this.loyaltyHttps.getUserRankings(t,e,i);return await this.getModelsForUserRankings(r)};getHighestSuccessRate=async(t,e)=>{t&&(t=new us(t),this.loyaltyValidator.validate(t,this.errorHandlingMode));let i=await this.loyaltyHttps.getHighestSuccessRate(t,e);return this.loyaltyService.addProfileModelToHighestSuccessRate(i)};getTemplateWinners=async(t,e)=>{let i=await this.predictorHttps.getContestWinners(t,e),r=await this.getTemplateById(t);return i.contestModel=r,this.loyaltyService.completeContestWinners(i)};getEntitiesFollows=async(t,e)=>{this.loyaltyService.validateEntitiesFollowsFilters(t),this.config.idSchema!=="native"&&(t=await this.loyaltyService.remapEntitiesFollowsFilters(t));let i=await this.loyaltyHttps.getEntitiesFollows(t,e);return await this.loyaltyService.addModelsToEntitiesFollows(i)};getModelsForUserRankings=async t=>{let e=null,i=null,r=null,[a,s,l]=this.loyaltyService.extractRankingsIdsMap(t.data);if(l.length&&(e=(await this.getTemplates()).data.filter(p=>l.includes(p.id))),a.length){let n={gameIds:a};i=(await this.topXFacade.getGames(n)).data}if(s.length){let n={gameIds:s};r=(await this.matchQuizFacade.getGames(n)).data}return this.loyaltyService.setModelsForUserRankings(i,r,e,t)};getTemplateMatches=async(t,e,i)=>{let r=await this.getTemplateById(t,i);if((!r.competitionIds||r.competitionIds.length===0)&&(!r.teamIds||r.teamIds.length===0)&&(!r.matchIds||r.matchIds.length===0)&&(!r.groups||r.groups.length===0))return[];let a=this.loyaltyService.initMatchFiltersForTemplates(r,e);return(await this.football.getMatches(a,i)).data}};var ze=class{clientHttps=null;profileHttps=null;loyaltyHttps=null;loyaltyFacade=null;localCache=null;constructor(t){this.clientHttps=new N(t),this.profileHttps=new Wt(t),this.loyaltyHttps=new Et(t),this.localCache=new K().createLocalCacheInstance(t.idSchema),this.loyaltyFacade=new ms(t,this.clientHttps,this.loyaltyHttps,this.profileHttps,this.localCache)}getConfig=async()=>await this.loyaltyFacade.getConfig();getConfigV2=async t=>await this.loyaltyFacade.getConfigV2(t);getClientBadges=async()=>await this.loyaltyFacade.getClientBadges();getClientBadgesV2=async t=>await this.loyaltyFacade.getClientBadgesV2(t);getTemplates=async(t,e)=>await this.loyaltyFacade.getTemplates(t,e);getTemplateById=async(t,e)=>await this.loyaltyFacade.getTemplateById(t,e);getLeaderboard=async(t,e,i)=>await this.loyaltyFacade.getLeaderboard(t,e,i);getLeaderboardForGame=async(t,e,i)=>await this.loyaltyFacade.getLeaderboardForGame(t,e,i);getLeaderboardForLeague=async(t,e)=>await this.loyaltyFacade.getLeaderboardForLeague(t,e);getOwnRankings=async(t,e)=>await this.loyaltyFacade.getOwnRankings(t,e);getUserRankings=async(t,e,i)=>await this.loyaltyFacade.getUserRankings(t,e,i);getHighestSuccessRate=async(t,e)=>await this.loyaltyFacade.getHighestSuccessRate(t,e);getTemplateWinners=async(t,e)=>await this.loyaltyFacade.getTemplateWinners(t,e);getEntitiesFollows=async(t,e)=>await this.loyaltyFacade.getEntitiesFollows(t,e);getTemplateMatches=async(t,e,i)=>await this.loyaltyFacade.getTemplateMatches(t,e,i)};var Ti=class{action=null;context=new _t;constructor(t,e,i,r){this.action=t,this.context.tags=e,i&&(this.context.content=i),r&&(this.context.campaign=r)}};var qe=class{page=null;limit=null;constructor(t){this.page=t.page?t.page:null,this.limit=t.limit?t.limit:null}};var hs=class extends qe{action=null;constructor(t){super(t),this.action=t.action?t.action:null}constructFilterUrl(){let t="";return this.action&&(t+="&",t+=`action=${this.action}`),this.page&&(t+="&",t+=`page=${this.page}`),this.limit&&(t+="&",t+=`limit=${this.limit}`),t}};var gs=class extends qe{action=null;constructor(t){super(t),this.action=t.action?t.action:null}constructFilterUrl(){let t="";return this.action&&(t+="&",t+=`action=${this.action}`),this.page&&(t+="&",t+=`page=${this.page}`),this.limit&&(t+="&",t+=`limit=${this.limit}`),t}};var fs=class{idSchema;activityHttps;activityService;constructor(t){this.idSchema=t.idSchema,this.activityHttps=new ge(t),this.activityService=new gt(t)}add=async(t,e,i,r)=>{if(this.idSchema!="native"){let s=JSON.parse(JSON.stringify(e)),l=await this.activityService.remapTagsIds(e,this.idSchema,"native"),n=new Ti(t,l,i,r),p=await this.activityHttps.createActivity(n);return p.context.tags=s,p}let a=new Ti(t,e,i,r);return this.activityHttps.createActivity(a)};delete=async t=>await this.activityHttps.deleteActivity(t);like=async(t,e,i)=>{let r="like";return await this.add(r,t,e,i)};dislike=async(t,e,i)=>{let r="dislike";return await this.add(r,t,e,i)};addPageview=async(t,e,i)=>{let r="page_view";return await this.add(r,t,e,i)};addContentConsumed=async(t,e,i)=>{let r="content_consumed";return await this.add(r,t,e,i)};addShare=async(t,e,i)=>{let r="share";return await this.add(r,t,e,i)};addComment=async(t,e,i)=>{let r="comment";return await this.add(r,t,e,i)};addClickAd=async(t,e,i)=>{let r="click_ad";return await this.add(r,t,e,i)};addConversion=async(t,e,i)=>{let r="conversion";return await this.add(r,t,e,i)};getOwn=async(t,e)=>{if(e=e||!1,t&&(t=new hs(t)),this.idSchema!="native"){let i=await this.activityHttps.getOwnActivities(t,e);for(let r of i.data)await this.activityService.remapTagsIds(r.context.tags,"native",this.idSchema);return i}return await this.activityHttps.getOwnActivities(t,e)};getForUser=async(t,e,i)=>{if(i=i||!1,e&&(e=new gs(e)),this.idSchema!="native"){let r=await this.activityHttps.getActivitiesForUser(t,e,i),a=JSON.parse(JSON.stringify(r));for(let s of a.data)await this.activityService.remapTagsIds([...s.context.tags],"native",this.idSchema);return a}return await this.activityHttps.getActivitiesForUser(t,e,i)}};var ys=class{activityFacade;constructor(t){this.activityFacade=new fs(t)}add=async(t,e,i,r)=>await this.activityFacade.add(t,e,i,r);delete=async t=>await this.activityFacade.delete(t);like=async(t,e,i)=>await this.activityFacade.like(t,e,i);dislike=async(t,e,i)=>await this.activityFacade.dislike(t,e,i);addPageview=async(t,e,i)=>await this.activityFacade.addPageview(t,e,i);addContentConsumed=async(t,e,i)=>await this.activityFacade.addContentConsumed(t,e,i);addShare=async(t,e,i)=>await this.activityFacade.addShare(t,e,i);addComment=async(t,e,i)=>await this.activityFacade.addComment(t,e,i);addClickAd=async(t,e,i)=>await this.activityFacade.addClickAd(t,e,i);addConversion=async(t,e,i)=>await this.activityFacade.addConversion(t,e,i);getOwn=async(t,e)=>await this.activityFacade.getOwn(t,e);getForUser=async(t,e,i)=>await this.activityFacade.getForUser(t,e,i)};var bs=class{id="";label="";discussionType="LEAGUE";moderationType="USER";postsCount=0;pinnedPosts=[];lastPostId="";status="";deleted=!1;deletedAt="";deletedBy="";customFields=null;context=null;createdAt="";updatedAt=""};var Ct=class{pagination={totalItems:0,nextPageStartsAfter:"",lastCommentCreateTimestamp:""}};var Qe=class{id="";userId="";discussionId="";content="";repliesCount=0;replyId="";anonymousNickname="";reactions=[];reactionsCount=0;reports=[];reportsCount=0;versions=null;privatePost=!1;deleted=!1;deletedAt="";deletedBy="";moderated=!1;moderatedAt="";moderatedBy="";moderatedReason="";createdAt="";updatedAt=""};var Ms=class{meta=new Ct;data=[]};var ws=class{type="";userIds=[];reactionCount=0};var Is=class{updatedAt="";content=""};var Ps=class{userId=null;reason="AD";reasonDetails=null};var _s=class extends Qe{userModel=null};var Ts=class{meta=new Ct;data=[]};var vs=class{meta=new x;data=[]};var Fs=class{id="";postsCount=0};var Ke=class{remapToDiscussions=t=>(t.meta=this.remapToMeta(t.meta),t.data=t.data.map(e=>this.remapToDiscussionById(e)),t);remapToDiscussionById=t=>{let e=new bs;return e.id=t.id,e.label=t.label,e.status=t.status,e.deleted=t.deleted,e.deletedAt=t.deleted_at,e.deletedBy=t.deleted_by,e.discussionType=t.discussion_type,e.moderationType=t.moderation_type,e.postsCount=t.posts_count,e.pinnedPosts=t.pinned_posts,e.lastPostId=t.last_post_id,e.customFields=t.custom_fields,e.context=t.context,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapToPostsForDiscussion=(t,e)=>{let i=new Ms,r=new Ts;return i.meta=this.remapToPostMeta(t.meta),i.data=t.data.map(a=>this.remapToPostByIdBasic(a)),r.meta=this.remapToPostMeta(t.meta),r.data=t.data.map(a=>this.remapToPostByIdFull(a)),e==="basic"?i:r};remapToPosts=t=>{let e=new vs;return e.meta=this.remapToMeta(t.meta),e.data=t.data.map(i=>this.remapToPostByIdBasic(i)),e};remapToPostMeta=t=>{let e=new Ct;return e.pagination.totalItems=t.pagination.total_items,e.pagination.nextPageStartsAfter=t.pagination.next_page_starts_after,e.pagination.lastCommentCreateTimestamp=t.pagination.last_comment_create_timestamp,e};remapToMeta=t=>{let e=new x;return e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.nextPageStartsAfter=t.pagination.next_page_starts_after,e};remapToPostByIdBasic=t=>{let e=new Qe;return e.id=t.id,e.userId=t.user_id,e.discussionId=t.discussion_id,e.content=t.content,e.anonymousNickname=t.anonymous_nickname,e.reactionsCount=t.reactions_count,e.replyId=t.reply_id,e.reactions=t.reactions.length?t.reactions.map(i=>this.remapReactionsPost(i)):t.reactions,e.repliesCount=t.replies_count,e.reports=t.reports.length?t.reports.map(i=>this.remapReportPost(i)):t.reports,e.reportsCount=t.reports_count,e.versions=t.versions.length?t.versions.map(i=>this.remapVersionsPost(i)):t.versions,e.privatePost=t.private_post,e.deleted=t.deleted,e.deletedAt=t.deleted_at,e.deletedBy=t.deleted_by,e.moderated=t.moderated,e.moderatedAt=t.moderated_at,e.moderatedBy=t.moderated_by,e.moderatedReason=t.moderated_reason,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapToPostByIdFull=t=>{let e=new _s;return e.id=t.id,e.userId=t.user_id,e.discussionId=t.discussion_id,e.content=t.content,e.anonymousNickname=t.anonymous_nickname,e.reactionsCount=t.reactions_count,e.replyId=t.reply_id,e.reactions=t.reactions.length?t.reactions.map(i=>this.remapReactionsPost(i)):t.reactions,e.repliesCount=t.replies_count,e.reports=t.reports.length?t.reports.map(i=>this.remapReportPost(i)):t.reports,e.reportsCount=t.reports_count,e.versions=t.versions.length?t.versions.map(i=>this.remapVersionsPost(i)):t.versions,e.privatePost=t.private_post,e.deleted=t.deleted,e.deletedAt=t.deleted_at,e.deletedBy=t.deleted_by,e.moderated=t.moderated,e.moderatedAt=t.moderated_at,e.moderatedBy=t.moderated_by,e.moderatedReason=t.moderated_reason,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapToPostCount=t=>t.map(e=>{let i=new Fs;return i.id=e.id,i.postsCount=e.posts_count,i});remapReactionsPost=t=>{let e=new ws;return e.type=t.type,e.userIds=t.user_ids,e.reactionCount=t.reaction_count,e};remapVersionsPost=t=>{let e=new Is;return e.content=t.content,e.updatedAt=t.updated_at,e};remapReportPost=t=>{let e=new Ps;return e.userId=t.user_id,e.reason=t.reason,e.reasonDetails=t.reason_details,e}};var Es=class extends T{remapper=null;constructor(t){super(t,S(t.environment,"discussions")),this.remapper=new Ke}getAll=async(t,e)=>{let i="/discussions"+this.apiSignInUrl;t&&(i+=`${t.constructMainFiltersUrl()}`),w(e)&&(i+=h());let r="There was a problem getting discussions",a=await this.fetchWithoutAuth(i,r);return this.remapper.remapToDiscussions(a)};getById=async t=>{let e=`/discussions/${t}`+this.apiSignInUrl,i="There was a problem getting discussion",r=await this.fetchWithoutAuth(e,i);return this.remapper.remapToDiscussionById(r.data)};createPost=async(t,e)=>{let i=`/discussions/${t}/posts`+this.apiSignInUrl,r="There was a problem creating post in discussion",a="POST",s=await this.fetchWithAuth(i,r,a,e);return this.remapper.remapToPostByIdBasic(s.data)};getPostById=async t=>{let e=`/posts/${t}`+this.apiSignInUrl,i="There was a problem getting post by ID in discussion",r=await this.fetchWithoutAuth(e,i);return this.remapper.remapToPostByIdFull(r.data)};updatePost=async(t,e)=>{let i=`/posts/${t}`+this.apiSignInUrl,r="There was a problem editing post in discussion",a="PUT",s={content:e},l=await this.fetchWithAuth(i,r,a,s);return this.remapper.remapToPostByIdBasic(l.data)};reactToPost=async(t,e)=>{let i=`/posts/${t}/reaction`+this.apiSignInUrl,r="There was a problem reacting to post in discussion",a="PUT",s={reaction:e.toLocaleLowerCase()},l=await this.fetchWithAuth(i,r,a,s);return this.remapper.remapToPostByIdFull(l.data)};deletePost=async t=>{let e=`/posts/${t}`+this.apiSignInUrl,i="There was a problem deleting post in discussion",r="DELETE";return await this.fetchWithAuth(e,i,r),!0};getPosts=async(t,e)=>{let i=`/discussions/${t}/posts`+this.apiSignInUrl;e&&(i+=`${e.constructMainFiltersUrl()}`);let r="There was a problem getting posts in discussion",a=await this.fetchWithoutAuth(i,r);return this.remapper.remapToPostsForDiscussion(a,"full")};getPostReplies=async(t,e)=>{let i=`/posts/${t}/replies`+this.apiSignInUrl;e&&(i+=`${e.constructMainFiltersUrl()}`);let r="There was a problem getting post's replies in discussion",a=await this.fetchWithoutAuth(i,r);return this.remapper.remapToPostsForDiscussion(a,"full")};reportPost=async(t,e,i)=>{let r=`/posts/${t}/report`+this.apiSignInUrl,a="There was a problem reporting post in discussion",s="POST",l={reason:e.toLocaleUpperCase(),reason_details:i||null},n=await this.fetchWithAuth(r,a,s,l);return this.remapper.remapToPostByIdBasic(n.data)};getOwnPosts=async t=>{let e="/posts"+this.apiSignInUrl;t&&(e+=`${t.constructMainFiltersUrl()}`);let i="There was a problem getting own posts",r=await this.fetchWithAuth(e,i);return this.remapper.remapToPosts(r)};getUserPosts=async(t,e,i)=>{let r=`/posts/users/${t}`+this.apiSignInUrl;e&&(r+=`${e.constructMainFiltersUrl()}`),w(i)&&(r+=h());let a="There was a problem getting user's posts",s=await this.fetchWithoutAuth(r,a);return this.remapper.remapToPosts(s)};getPostsCount=async(t,e)=>{let i="/discussions/posts/count"+this.apiSignInUrl+`&discussion_ids=${t.join(",")}`;w(e)&&(i+=h());let r="There was a problem getting posts count for discussions",a=await this.fetchWithoutAuth(i,r);return this.remapper.remapToPostCount(a.data)};getTopDiscussions=async(t,e)=>{let i="/discussions/top"+this.apiSignInUrl;t&&(i+=`${t.constructMainFiltersUrl()}`),w(e)&&(i+=h());let r="There was a problem getting top discussions",a=await this.fetchWithoutAuth(i,r);return this.remapper.remapToDiscussions(a)}};var Ss=class{content="";reply_id="";anonymous_nickname="";context=null};var Rs=class{createRequestBodyFromParam=t=>{let e=new Ss;return e.content=t.content,e.reply_id=t.replyId,e.anonymous_nickname=t.userNickname,e.context=t.context,e}};var Wl=["CREATED_AT_ASC","CREATED_AT_DESC","POSTS_COUNT_ASC","POSTS_COUNT_DESC"],zl=["ACTIVE","INACTIVE"],Cs=class extends v{discussionIds;label;fromDate;toDate;fromCount;toCount;sort;status;skipDeleted;constructor(t){super(t),this.discussionIds=t&&t.discussionIds?t.discussionIds:null,this.label=t&&t.label?t.label:null,this.fromDate=t&&t.fromDate?t.fromDate:null,this.toDate=t&&t.toDate?t.toDate:null,this.fromCount=t&&t.fromCount?t.fromCount:null,this.toCount=t&&t.toCount?t.toCount:null,this.sort=t&&t.sort?t.sort:null,this.status=t?.status||null,this.skipDeleted=t&&t.skipDeleted!==void 0?t.skipDeleted:null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.discussionIds!==null&&(t+=`&discussion_ids=${this.discussionIds.join(",")}`),this.label!==null&&(t+=`&label=${this.label}`),this.fromDate!==null&&(t+=`&from_date=${this.fromDate}`),this.toDate!==null&&(t+=`&to_date=${this.toDate}`),this.fromCount!==null&&(t+=`&from_count=${this.fromCount}`),this.toCount!==null&&(t+=`&to_count=${this.toCount}`),this.sort&&Wl.includes(this.sort.toUpperCase())&&(t+=`&sort=${this.sort.toUpperCase()}`),this.status&&zl.includes(this.status.toUpperCase())&&(t+=`&status=${this.status.toUpperCase()}`),this.skipDeleted!==null&&(t+=`&skip_deleted=${this.skipDeleted}`),t}};var Gt=class extends v{skipDeleted;sort;constructor(t){super(t),this.skipDeleted=t&&t.skipDeleted!==void 0?t.skipDeleted:null,this.sort=t&&t.sort?t.sort.toLocaleLowerCase():null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.skipDeleted!==null&&(t+=`&skip_deleted=${this.skipDeleted}`),this.sort&&(t+=`&sort=${this.sort}`),t}};var As=class extends v{fromDate;toDate;entityIds;entityType;contentType;constructor(t){super(t),this.fromDate=t?.fromDate||null,this.toDate=t?.toDate||null,this.entityIds=t?.entityIds||null,this.entityType=t?.entityType||null,this.contentType=t?.contentType||null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.fromDate!==null&&(t+=`&from_date=${this.fromDate}`),this.toDate!==null&&(t+=`&to_date=${this.toDate}`),this.entityIds!==null&&this.entityIds.length>0&&(t+=`&entity_ids=${this.entityIds}`),this.contentType!==null&&(t+=`&content_type=${this.contentType}`),t}};var At=class{idSchema=null;profile=null;validator=null;idMapping=null;constructor(t){this.idSchema=t.idSchema,this.profile=new O(t),this.validator=new St(t),this.idMapping=new P(t)}finalizePostFullModel=async t=>{let e=t.map(r=>r.userId),i=await this.profile.getByIds(e);return t.map(r=>(r.userModel=this.extractModelById(i,r.userId),r))};finalizeTopDiscussionsFilters=async t=>{if(this.idSchema!=="native"&&t.entityIds&&t.entityIds.length>0){this.validator.validateFilters(t);let e=await this.idMapping.getEntityIdsBySchemaId(Array.from(t.entityIds),t.entityType,"native");t.entityIds=e[t.entityType]}};extractModelById=(t,e)=>{if(t.length){let i=t.find(r=>r.id===e);return i?(delete i.interests,i):null}return null}};var Os=class{idSchema=null;errorHandlingMode=null;https=null;clientHttps=null;activityService=null;service=null;factory=null;constructor(t){this.idSchema=t.idSchema,this.errorHandlingMode=t.errorHandlingMode,this.https=new Es(t),this.clientHttps=new N(t),this.activityService=new gt(t),this.service=new At(t),this.factory=new Rs}getAll=async(t,e)=>{t&&(t=new Cs(t));let i=await this.https.getAll(t,e);for(let r of i.data)await this.remapTags(r,"native",this.idSchema);return i};getById=async t=>{let e=await this.https.getById(t);return await this.remapTags(e,"native",this.idSchema),e};createPost=async(t,e)=>{let i=JSON.parse(JSON.stringify(e));await this.remapTags(i,this.idSchema,"native");let r=this.factory.createRequestBodyFromParam(i);return await this.https.createPost(t,r)};getPostById=async t=>{let e=await this.https.getPostById(t);return(await this.service.finalizePostFullModel([e]))[0]};updatePost=async(t,e)=>await this.https.updatePost(t,e);deletePost=async t=>await this.https.deletePost(t);getPosts=async(t,e)=>{e&&(e=new Gt(e));let i=await this.https.getPosts(t,e);return i.data=await this.service.finalizePostFullModel(i.data),i};getPostReplies=async(t,e)=>{e&&(e=new Gt(e));let i=await this.https.getPostReplies(t,e);return i.data=await this.service.finalizePostFullModel(i.data),i};reactToPost=async(t,e)=>{let i=await this.https.reactToPost(t,e);return(await this.service.finalizePostFullModel([i]))[0]};reportPost=async(t,e,i)=>await this.https.reportPost(t,e,i);getOwnPosts=async t=>(t&&(t=new Gt(t)),await this.https.getOwnPosts(t));getUserPosts=async(t,e,i)=>(e&&(e=new Gt(e)),await this.https.getUserPosts(t,e,i));getConfig=async()=>await this.clientHttps.getConfig("discussions");getPostsCount=async(t,e)=>{if(!t||!Array.isArray(t)||!t.length)throw this.errorHandlingMode==="standard"?new m(400,"invalid_discussion_ids","Invalid discussion ids argument. Please provide at least one discussion id in an array"):new f(400,"invalid_discussion_ids","Invalid discussion ids argument. Please provide at least one discussion id in an array");return await this.https.getPostsCount(t,e)};getTopDiscussions=async(t,e)=>{t&&(t=new As(t),await this.service.finalizeTopDiscussionsFilters(t));let i=await this.https.getTopDiscussions(t,e);for(let r of i.data)await this.remapTags(r,"native",this.idSchema);return i};remapTags=async(t,e,i)=>{if(this.idSchema!="native"&&t.context&&t.context.tags&&t.context.tags.length){let r=JSON.parse(JSON.stringify(t.context.tags)),a=await this.activityService.remapTagsIds(r,e,i);t.context.tags=a}}};var Ls=class{facade=null;constructor(t){this.facade=new Os(t)}getAll=async(t,e)=>await this.facade.getAll(t,e);getById=async t=>await this.facade.getById(t);createPost=async(t,e)=>await this.facade.createPost(t,e);getPostById=async t=>await this.facade.getPostById(t);updatePost=async(t,e)=>await this.facade.updatePost(t,e);deletePost=async t=>await this.facade.deletePost(t);getPosts=async(t,e)=>await this.facade.getPosts(t,e);getPostReplies=async(t,e)=>await this.facade.getPostReplies(t,e);react=async(t,e)=>await this.facade.reactToPost(t,e);reportPost=async(t,e,i)=>await this.facade.reportPost(t,e,i);getOwnPosts=async t=>await this.facade.getOwnPosts(t);getUserPosts=async(t,e,i)=>await this.facade.getUserPosts(t,e,i);getConfig=async()=>await this.facade.getConfig();getPostsCount=async(t,e)=>await this.facade.getPostsCount(t,e);getTopDiscussions=async(t,e)=>await this.facade.getTopDiscussions(t,e)};var xs=class{profileId="";profileModel=null;challengeId="";challengeModel=null;message=""};var Ds=class{profileId="";profileModel=null;leagueId="";leagueModel=null;message=""};var je=class{id="";name="";description="";type="";banned=[];invites=[];administrators=[];membersCount=0;invitationCode="";templateId="";templateModel=null;pastTemplates=[];usersCanInviteUsers=!1;scoringStartsAt="";pinnedPosts=[]};var Bs=class extends je{members=[]};var Ns=class{predictionId=null;predictionModel=null;profileId=null;profileModel=null};var ks=class{remapToPrivateLeagues=t=>(t.meta=this.remapMetaPrivateLeagues(t.meta.pagination),t.data=t.data.map(e=>this.remapToPrivateLeagueById(e)),t);remapMetaPrivateLeagues=t=>{let e=new x;return e.pagination.itemsPerPage=t.items_per_page,e.pagination.nextPageStartsAfter=t.next_page_starts_after,e};remapToPrivateLeagueById=t=>{let e=new Bs;return e.id=t.id,e.name=t.name,e.description=t.description,e.type=t.type,e.members=t.members,e.administrators=t.administrators,e.banned=t.banned,e.invites=t.invites,e.membersCount=t.members_count,e.usersCanInviteUsers=t.users_can_invite_users,e.invitationCode=t.invitation_code,e.templateId=t.template_id,e.pastTemplates=t.past_templates,e.pinnedPosts=t.pinned_posts,e.scoringStartsAt=t.scoring_starts_at,e};remapToMyPrivateLeagues=t=>{let e=new je;return e.id=t.id,e.name=t.name,e.description=t.description,e.type=t.type,e.administrators=t.administrators,e.banned=t.banned,e.invites=t.invites,e.membersCount=t.members_count,e.usersCanInviteUsers=t.users_can_invite_users,e.invitationCode=t.invitation_code,e.templateId=t.template_id,e.pastTemplates=t.past_templates,e.pinnedPosts=t.pinned_posts,e.scoringStartsAt=t.scoring_starts_at,e};remapToAcceptPrivateLeague=t=>{let e=new Ds;return e.profileId=t.profile_id,e.leagueId=t.league_id,e.message=t.message,e};remapToAcceptChallenge=t=>{let e=new xs;return e.profileId=t.profile_id,e.challengeId=t.league_id,e.message=t.message,e};remapPredictions=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapPredictionsData(t.data),t);remapMeta=t=>{let e=new H;return e.pagination.currentPage=t.pagination.current_page,e.pagination.itemsPerPage=t.pagination.items_per_page,e.pagination.numberOfPages=t.pagination.number_of_pages,e.pagination.totalItems=t.pagination.total_items,e};remapPredictionsData=t=>t.map(e=>{let i=new Ns;return i.predictionId=e.prediction_id,i.profileId=e.profile_id,i})};var Xe=class extends T{remapper=null;discussionsRemapper=null;discussionsBaseURL=null;constructor(t){super(t,S(t.environment,"privateLeagues")),this.discussionsBaseURL=S(t.environment,"discussions"),this.remapper=new ks,this.discussionsRemapper=new Ke}create=async(t,e)=>{let i="/leagues"+this.apiSignInUrl,a=`There was a problem ${e==="PRIVATE_LEAGUE"?"creating private league":"issuing challenge"}`,s="POST",l=await this.fetchWithAuth(i,a,s,t);return this.remapper.remapToPrivateLeagueById(l.data)};update=async(t,e,i)=>{let r=`/leagues/${t}`+this.apiSignInUrl,s=`There was a problem updating ${i==="PRIVATE_LEAGUE"?"private league":"challenge"}`,l="PUT",n=await this.fetchWithAuth(r,s,l,e);return this.remapper.remapToPrivateLeagueById(n.data)};updateLeagueTemplate=async(t,e,i,r)=>{let a=`/leagues/${t}/template`+this.apiSignInUrl,l=`There was a problem updating template for the ${r==="PRIVATE_LEAGUE"?"private league":"challenge"}`,n="POST",p={new_template_id:e,past_template_name:i},c=await this.fetchWithAuth(a,l,n,p);return this.remapper.remapToPrivateLeagueById(c.data)};getById=async(t,e,i)=>{let r=`/leagues/${t}`+this.apiSignInUrl;w(i)&&(r+=h());let s=`There was a problem getting ${e==="PRIVATE_LEAGUE"?"private league":"challenge"}`,l=await this.fetchWithAuth(r,s);return this.remapper.remapToPrivateLeagueById(l.data)};getMyLeagues=async(t,e)=>{let i="/leagues"+this.apiSignInUrl+t.constructFiltersUrl(),a=`There was a problem getting user's ${e==="PRIVATE_LEAGUE"?"private leagues":"challenges"}`;return(await this.fetchWithAuth(i,a)).data.map(l=>this.remapper.remapToMyPrivateLeagues(l))};delete=async(t,e)=>{let i=`/leagues/${t}`+this.apiSignInUrl,a=`There was a problem deleting ${e==="PRIVATE_LEAGUE"?"private league":"challenge"}`,s="DELETE";return await this.fetchWithAuth(i,a,s),!0};invite=async(t,e)=>{let i=`/membership/invite/${t}`+this.apiSignInUrl,r=`There was a problem inviting the following users: ${e.join(",")}`,a="POST",s={profiles:e};return(await this.fetchWithAuth(i,r,a,s)).data};deleteInvitation=async(t,e)=>{let i=`/membership/invite/${t}`+this.apiSignInUrl,r=`There was a problem deleting invitation for the following users: ${e.join(",")}`,a="DELETE",s={profiles:e};return await this.fetchWithAuth(i,r,a,s),!0};accept=async(t,e,i)=>{let r=`/membership/accept/${t}`+this.apiSignInUrl+`&accept=${e?"ACCEPT":"REJECT"}`,s=`There was a problem ${e?"accepting":"rejecting"} invitation for ${i==="PRIVATE_LEAGUE"?"private league":"challenge"}: ${t}`,l="POST",n=await this.fetchWithAuth(r,s,l);return i==="PRIVATE_LEAGUE"?this.remapper.remapToAcceptPrivateLeague(n.data):this.remapper.remapToAcceptChallenge(n.data)};ban=async(t,e)=>{let i=`/membership/ban/${t}`+this.apiSignInUrl,r=`There was a problem banning the following users: ${e.join(",")}`,a="POST",s={profiles:e};return(await this.fetchWithAuth(i,r,a,s)).data};unban=async(t,e)=>{let i=`/membership/unban/${t}`+this.apiSignInUrl,r=`There was a problem unbanning the following users: ${e.join(",")}`,a="POST",s={profiles:e};return(await this.fetchWithAuth(i,r,a,s)).data};join=async t=>{let e="/membership/join"+this.apiSignInUrl+`&invitation_code=${t}`,i="There was a problem joining league",r="POST",a=await this.fetchWithAuth(e,i,r);return this.remapper.remapToAcceptPrivateLeague(a.data)};leave=async(t,e)=>{let i=`/membership/leave/${t}`+this.apiSignInUrl,a=`There was a problem leaving the following ${e==="PRIVATE_LEAGUE"?"league":"challenge"}: ${t}`,s="POST";return(await this.fetchWithAuth(i,a,s)).data};getInvitations=async(t,e)=>{let i="/membership/invitations"+this.apiSignInUrl+e.constructMainFiltersUrl(),a=`There was a problem getting invitations for ${t==="PRIVATE_LEAGUE"?"leagues":"challenges"}`,s=await this.fetchWithAuth(i,a);return this.remapper.remapToPrivateLeagues(s)};getReportedPosts=async(t,e)=>{let i=`/discussions/${t}/posts/reported${this.apiSignInUrl}`,r=`There was a problem fetching posts for the following: ${t}`;e&&(i+=e.constructMainFiltersUrl());let a=await this.fetchWithAuthNewBaseURL(this.discussionsBaseURL,i,r);return this.discussionsRemapper.remapToPostsForDiscussion(a,"full")};getPredictions=async(t,e)=>{let i=`/leagues/${t}/predictions`+this.apiSignInUrl,r=`There was a problem getting predictions for private league: ${t}`;e&&(i+=e.constructFiltersUrl());let a=await this.fetchWithAuth(i,r);return this.remapper.remapPredictions(a)};moderatePost=async(t,e)=>{let i=`/posts/${t}/admin/moderate${this.apiSignInUrl}`,r=`There was a problem moderating the following post: ${t}`,a="POST",s={moderation_reason:e},l=await this.fetchWithAuthNewBaseURL(this.discussionsBaseURL,i,r,a,s);return this.discussionsRemapper.remapToPostByIdBasic(l.data)}};var Ye=class{name="";description="";invitation_code="";template_id="";users_can_invite_users=!1;administrators=[];scoring_starts_at=""};var Us=class extends Ye{type="ONE_VS_ONE"};var Gs=class extends Ye{type="PRIVATE"};var Je=class{name="";description="";invitation_code="";template_id="";users_can_invite_users=!1;administrators=[];pinned_posts=[];scoring_starts_at=""};var Vs=class extends Je{type="PRIVATE"};var Hs=class extends Je{type="ONE_VS_ONE"};var Ze=class{createRequestBodyFromParam=(t,e)=>{let i=e==="PRIVATE"?new Gs:new Us;return i.name=t.name,i.description=t.description,i.invitation_code=t.invitationCode,i.template_id=t.templateId,i.users_can_invite_users=t.usersCanInviteUsers,t.administrators?i.administrators=t.administrators:delete i.administrators,t.scoringStartsAt?i.scoring_starts_at=t.scoringStartsAt:delete i.scoring_starts_at,i};createUpdateRequestBodyFromParam=(t,e)=>{let i=e==="PRIVATE"?new Vs:new Hs;return i.name=t.name,i.description=t.description,i.invitation_code=t.invitationCode,i.template_id=t.templateId,i.users_can_invite_users=t.usersCanInviteUsers,i.administrators=t.administrators,i.pinned_posts=t.pinnedPosts,i.scoring_starts_at=t.scoringStartsAt,i}};var ti=class extends v{type=null;constructor(t){super(t),this.type=t&&t.type?t.type:null}constructMainFiltersUrl=()=>{let t=super.constructMainFiltersUrl();return this.type&&(t+=`&type=${this.type}`),t}};var $s=class{type="PRIVATE";userRole=null;constructor(t){this.userRole=t?.userRole||null}constructFiltersUrl=()=>{let t=`&type=${this.type}`;return this.userRole&&(t+=`&user_role=${this.userRole}`),t}};var Ws=class{limit=null;page=null;leagueId=null;templateId=null;sortOrder=null;constructor(t){this.limit=t&&t.limit?t.limit:null,this.page=t&&t.page?t.page:null,this.leagueId=t&&t.leagueId?t.leagueId:null,this.templateId=t&&t.templateId?t.templateId:null,this.sortOrder=t&&t.sortOrder?t.sortOrder:null}constructFiltersUrl=()=>{let t="";return this.limit&&(t+=`&limit=${this.limit}`),this.page&&(t+=`&page=${this.page}`),this.leagueId&&(t+=`&league_id=${this.leagueId}`),this.templateId&&(t+=`&template_id=${this.templateId}`),this.sortOrder&&(t+=`&sort_order=${this.sortOrder}`),t}};var ei=class extends v{reportsCount=null;constructor(t){super(t),this.reportsCount=t.reportsCount?t.reportsCount:null}constructMainFiltersUrl=()=>{let t=super.constructMainFiltersUrl();return this.reportsCount&&(t+=`&reports_count=${this.reportsCount}`),t}};var ii=class{limit=null;page=null;profileIds=null;constructor(t){this.limit=t&&t.limit?t.limit:null,this.page=t&&t.page?t.page:null,this.profileIds=t&&t.profileIds?t.leagueId:null}constructFiltersUrl=()=>{let t="";return this.limit&&(t+=`&limit=${this.limit}`),this.page&&(t+=`&page=${this.page}`),this.profileIds&&(t+=`&profile_ids=${this.profileIds.join(",")}`),t}};var ri=class{loyalty=null;profile=null;predictor=null;constructor(t){this.loyalty=new ze(t),this.profile=new O(t),this.predictor=new Re(t)}setTemplateModels=async t=>{let e=await this.loyalty.getTemplates();t.templateModel=e.data.find(i=>i.id===t.templateId),t.pastTemplates&&t.pastTemplates.length>0&&t.pastTemplates.forEach(i=>{i.model=e.data.find(r=>r.id===i.id)})};setTemplateModelsInLeagues=async t=>{if(!t.length)return;let e=await this.loyalty.getTemplates();t.forEach(i=>{i.templateModel=e.data.find(r=>r.id===i.templateId),i.pastTemplates&&i.pastTemplates.length>0&&i.pastTemplates.forEach(r=>{r.model=e.data.find(a=>a.id===r.id)})})};setTemplateModelsFromLeagueModels=(t,e)=>{if(e==="PRIVATE_LEAGUE"){t.forEach(i=>{i.templateModel=i.templateId===i.privateLeagueModel.templateId?i.privateLeagueModel.templateModel:i.privateLeagueModel.pastTemplates.find(r=>r.id===i.templateId).model});return}t.forEach(i=>{i.templateModel=i.templateId===i.challengeModel.templateId?i.challengeModel.templateModel:i.challengeModel.pastTemplates.find(r=>r.id===i.templateId).model})};setProfileModel=async t=>{let e=await this.profile.getById(t.profileId).getInfo();t.profileModel=e};setModelsForPredictions=async t=>{if(t.data.length){let e=t.data.map(s=>s.profileId),i=t.data.map(s=>s.predictionId),r=await this.getProfileModels(e),a=await this.getPredictionModels(i);t.data.forEach(s=>{s.profileModel=r.find(l=>l.id===s.profileId),s.predictionModel=a.find(l=>l.id===s.predictionId)})}return t};getProfileModels=async t=>await this.profile.getByIds(t);getPredictionModels=async t=>await this.predictor.getPredictionsByIds(t)};var zs=class{factory=null;privateLeagueHttps=null;loyaltyHttps=null;profile=null;service=null;discussionsService=null;constructor(t){this.factory=new Ze,this.privateLeagueHttps=new Xe(t),this.loyaltyHttps=new Et(t),this.profile=new O(t),this.service=new ri(t),this.discussionsService=new At(t)}create=async t=>{let e=this.factory.createRequestBodyFromParam(t,"PRIVATE"),i=await this.privateLeagueHttps.create(e,"PRIVATE_LEAGUE");return await this.service.setTemplateModels(i),i};getById=async(t,e)=>{let i=await this.privateLeagueHttps.getById(t,"PRIVATE_LEAGUE",e);return await this.service.setTemplateModels(i),i};getMyLeagues=async t=>{t=new $s(t);let e=await this.privateLeagueHttps.getMyLeagues(t,"PRIVATE_LEAGUE");return await this.service.setTemplateModelsInLeagues(e),e};update=async(t,e)=>{let i=this.factory.createUpdateRequestBodyFromParam(e,"PRIVATE"),r=await this.privateLeagueHttps.update(t,i,"PRIVATE_LEAGUE");return await this.service.setTemplateModels(r),r};updateTemplate=async(t,e,i)=>{let r=await this.privateLeagueHttps.updateLeagueTemplate(t,e,i,"PRIVATE_LEAGUE");return await this.service.setTemplateModels(r),r};delete=async t=>await this.privateLeagueHttps.delete(t,"PRIVATE_LEAGUE");invite=async(t,e)=>await this.privateLeagueHttps.invite(t,e);deleteInvitation=async(t,e)=>await this.privateLeagueHttps.deleteInvitation(t,e);accept=async t=>{let i=await this.privateLeagueHttps.accept(t,!0,"PRIVATE_LEAGUE");return await this.finalizeAcceptModel(i,!0)};reject=async t=>{let i=await this.privateLeagueHttps.accept(t,!1,"PRIVATE_LEAGUE");return await this.finalizeAcceptModel(i,!1)};banUsers=async(t,e)=>await this.privateLeagueHttps.ban(t,e);unbanUsers=async(t,e)=>await this.privateLeagueHttps.unban(t,e);join=async t=>{let e=await this.privateLeagueHttps.join(t);return await this.finalizeAcceptModel(e,!0)};leave=async t=>await this.privateLeagueHttps.leave(t,"PRIVATE_LEAGUE");finalizeAcceptModel=async(t,e)=>{if(e){let i=await this.getById(t.leagueId);t.leagueModel=i}return await this.service.setProfileModel(t),t};getMyLeaguesStandings=async t=>{t&&(t=new Ws(t));let e=await this.profile.getOwn().getInfo(),i=await this.loyaltyHttps.getUserRankingsForPrivateLeagueAndChallenges(e.id,"PRIVATE_LEAGUE",t);for(let r of i.data){let a=await this.getById(r.privateLeagueId);r.privateLeagueModel=a}return this.service.setTemplateModelsFromLeagueModels(i.data,"PRIVATE_LEAGUE"),i};getInvitations=async t=>{t=new ti(t),t.type="PRIVATE";let e=await this.privateLeagueHttps.getInvitations("PRIVATE_LEAGUE",t);return await this.service.setTemplateModelsInLeagues(e.data),e};getReportedPosts=async(t,e)=>{e&&(e=new ei(e));let i=await this.privateLeagueHttps.getReportedPosts(t,e);return i.data=await this.discussionsService.finalizePostFullModel(i.data),i};getPredictions=async(t,e)=>{if(e){if(e.limit&&e.limit>20)throw new m(400,"invalid_limit","Invalid limit filter. The maximum limit is 20");e=new ii(e)}let i=await this.privateLeagueHttps.getPredictions(t,e);return await this.service.setModelsForPredictions(i)};moderatePost=async(t,e)=>await this.privateLeagueHttps.moderatePost(t,e)};var qs=class{privateLeaguesFacade=null;constructor(t){this.privateLeaguesFacade=new zs(t)}create=async t=>await this.privateLeaguesFacade.create(t);update=async(t,e)=>await this.privateLeaguesFacade.update(t,e);updateTemplate=async(t,e,i)=>await this.privateLeaguesFacade.updateTemplate(t,e,i);delete=async t=>await this.privateLeaguesFacade.delete(t);getById=async(t,e)=>await this.privateLeaguesFacade.getById(t,e);getMyLeagues=async t=>await this.privateLeaguesFacade.getMyLeagues(t);invite=async(t,e)=>await this.privateLeaguesFacade.invite(t,e);deleteInvitation=async(t,e)=>await this.privateLeaguesFacade.deleteInvitation(t,e);accept=async t=>await this.privateLeaguesFacade.accept(t);reject=async t=>await this.privateLeaguesFacade.reject(t);banUsers=async(t,e)=>await this.privateLeaguesFacade.banUsers(t,e);unbanUsers=async(t,e)=>await this.privateLeaguesFacade.unbanUsers(t,e);join=async t=>await this.privateLeaguesFacade.join(t);leave=async t=>await this.privateLeaguesFacade.leave(t);getMyLeaguesStandings=async t=>await this.privateLeaguesFacade.getMyLeaguesStandings(t);getInvitations=async t=>await this.privateLeaguesFacade.getInvitations(t);getReportedPosts=async(t,e)=>await this.privateLeaguesFacade.getReportedPosts(t,e);getPredictions=async(t,e)=>await this.privateLeaguesFacade.getPredictions(t,e);moderatePost=async(t,e)=>await this.privateLeaguesFacade.moderatePost(t,e)};var Qs=class{limit=null;page=null;challengeId=null;templateId=null;sortOrder=null;constructor(t){this.limit=t&&t.limit?t.limit:null,this.page=t&&t.page?t.page:null,this.challengeId=t&&t.challengeId?t.challengeId:null,this.templateId=t&&t.templateId?t.templateId:null,this.sortOrder=t&&t.sortOrder?t.sortOrder:null}constructFiltersUrl=()=>{let t="";return this.limit&&(t+=`&limit=${this.limit}`),this.page&&(t+=`&page=${this.page}`),this.challengeId&&(t+=`&league_id=${this.challengeId}`),this.templateId&&(t+=`&template_id=${this.templateId}`),this.sortOrder&&(t+=`&sort_order=${this.sortOrder}`),t}};var Ks=class{type="ONE_VS_ONE";userRole=null;constructor(t){this.userRole=t?.userRole||null}constructFiltersUrl=()=>{let t=`&type=${this.type}`;return this.userRole&&(t+=`&user_role=${this.userRole}`),t}};var js=class{factory=null;https=null;loyaltyHttps=null;profile=null;service=null;discussionsService=null;constructor(t){this.factory=new Ze,this.https=new Xe(t),this.service=new ri(t),this.loyaltyHttps=new Et(t),this.profile=new O(t),this.discussionsService=new At(t)}issue=async(t,e)=>{let i=this.factory.createRequestBodyFromParam(t,"ONE_VS_ONE"),r=await this.https.create(i,"CHALLENGE");await this.service.setTemplateModels(r);let a=await this.https.invite(r.id,[e]);return r.invites=[],r.invites.push(a[0]),r};update=async(t,e)=>{let i=this.factory.createUpdateRequestBodyFromParam(e,"ONE_VS_ONE"),r=await this.https.update(t,i,"CHALLENGE");return await this.service.setTemplateModels(r),r};updateTemplate=async(t,e,i)=>{let r=await this.https.updateLeagueTemplate(t,e,i,"CHALLENGE");return await this.service.setTemplateModels(r),r};delete=async t=>await this.https.delete(t,"CHALLENGE");getById=async(t,e)=>{let i=await this.https.getById(t,"CHALLENGE",e);return await this.service.setTemplateModels(i),i};getMyChallenges=async t=>{t=new Ks(t);let e=await this.https.getMyLeagues(t,"CHALLENGE");return await this.service.setTemplateModelsInLeagues(e),e};accept=async t=>{let i=await this.https.accept(t,!0,"CHALLENGE");return await this.finalizeAcceptModel(i,!0)};reject=async t=>{let i=await this.https.accept(t,!1,"CHALLENGE");return await this.finalizeAcceptModel(i,!1)};leave=async t=>await this.https.leave(t,"CHALLENGE");finalizeAcceptModel=async(t,e)=>{if(e){let i=await this.getById(t.challengeId);t.challengeModel=i}return await this.service.setProfileModel(t),t};getMyChallengesStandings=async t=>{t&&(t=new Qs(t));let e=await this.profile.getOwn().getInfo(),i=await this.loyaltyHttps.getUserRankingsForPrivateLeagueAndChallenges(e.id,"CHALLENGE",t);for(let r of i.data){let a=await this.getById(r.challengeId);r.challengeModel=a}return this.service.setTemplateModelsFromLeagueModels(i.data,"CHALLENGE"),i};getInvitations=async t=>{t=new ti(t),t.type="ONE_VS_ONE";let e=await this.https.getInvitations("CHALLENGE",t);return await this.service.setTemplateModelsInLeagues(e.data),e};getReportedPosts=async(t,e)=>{e&&(e=new ei(e));let i=await this.https.getReportedPosts(t,e);return i.data=await this.discussionsService.finalizePostFullModel(i.data),i};getPredictions=async(t,e)=>{if(e){if(e.limit&&e.limit>20)throw new m(400,"invalid_limit","Invalid limit filter. The maximum limit is 20");e=new ii(e)}let i=await this.https.getPredictions(t,e);return await this.service.setModelsForPredictions(i)};moderatePost=async(t,e)=>await this.https.moderatePost(t,e)};var Xs=class{facade=null;constructor(t){this.facade=new js(t)}issue=async(t,e)=>await this.facade.issue(t,e);update=async(t,e)=>await this.facade.update(t,e);updateTemplate=async(t,e,i)=>await this.facade.updateTemplate(t,e,i);delete=async t=>await this.facade.delete(t);getById=async(t,e)=>await this.facade.getById(t,e);getMyChallenges=async t=>await this.facade.getMyChallenges(t);accept=async t=>await this.facade.accept(t);reject=async t=>await this.facade.reject(t);leave=async t=>await this.facade.leave(t);getMyChallengesStandings=async t=>await this.facade.getMyChallengesStandings(t);getInvitations=async t=>await this.facade.getInvitations(t);getReportedPosts=async(t,e)=>await this.facade.getReportedPosts(t,e);getPredictions=async(t,e)=>await this.facade.getPredictions(t,e);moderatePost=async(t,e)=>await this.facade.moderatePost(t,e)};var Ys=class{KEY_PREFIX="fu-progress-";get=(t,e)=>{let i=localStorage.getItem(`${this.KEY_PREFIX}${t}-${e}`);return i&&JSON.parse(i)};set=(t,e,i)=>(localStorage.setItem(`${this.KEY_PREFIX}${t}-${e}`,JSON.stringify(i)),JSON.stringify(i));delete=(t,e)=>{localStorage.removeItem(`${this.KEY_PREFIX}${t}-${e}`)}};var Js=class{id=null;source=null;type=null};var ai=class{id=null;title=null;description=null;type=null;images=new it;status=null;totalVotes=null;flags=[];customFields=null;branding=null;embedCode=null;labels=null;adContent=null;context=null;options=[];createdAt=null;updatedAt=null};var Zs=class extends ai{rules=null};var oi=class{id=null;pollId=null;optionId=null;userId=null};var tn=class extends oi{pollModel=null;optionModel=null};var en=class{meta=new x;data=[]};var rn=class{meta=new x;data=[]};var an=class extends rt{remapPolls=t=>{let e=new en;return e.meta.pagination=this.remapMetaPagination(t.meta.pagination),e.data=t.data.map(i=>this.remapPoll(i)),e};remapPollById=t=>{let e=new Zs;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.images=t.images,e.status=t.status,e.flags=t.flags,e.totalVotes=t.total_votes,e.customFields=t.custom_fields,e.branding=t.branding?this.remapBranding(t.branding):null,e.embedCode=t.embed_code,e.labels=t.labels,e.rules=t.rules,e.adContent=t.ad_content,e.options=t.options,e.context=t.context?this.remapContext(t.context):t.context,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapUserVote=t=>{let e=new oi;return e.id=t.id,e.pollId=t.poll_id,e.optionId=t.option_id,e.userId=t.user_id,e};remapPollsVotes=t=>{let e=new rn;return e.meta.pagination=this.remapMetaPagination(t.meta.pagination),e.data=t.data.map(i=>this.remapPollVote(i)),e};remapPollVote=t=>{let e=new tn;return e.id=t.id,e.pollId=t.poll_id,e.optionId=t.option_id,e.userId=t.user_id,e};remapMetaPagination=t=>{let e=new nt;return e.itemsPerPage=t.items_per_page,e.nextPageStartsAfter=t.next_page_starts_after,e};remapPoll=t=>{let e=new ai;return e.id=t.id,e.title=t.title,e.description=t.description,e.type=t.type,e.images=t.images,e.status=t.status,e.flags=t.flags,e.totalVotes=t.total_votes,e.customFields=t.custom_fields,e.branding=t.branding?this.remapBranding(t.branding):null,e.embedCode=t.embed_code,e.labels=t.labels,e.adContent=t.ad_content,e.options=t.options,e.context=t.context?this.remapContext(t.context):t.context,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapContext=t=>{let e=new _t;return e.content=t.content,e.tags=t.tags?t.tags.map(i=>{let r=new Js;return r.id=i.id,r.type=i.type,r.source=i.source,r}):null,e.campaign=t.campaign,e}};var on=class extends T{pollRemapper=null;constructor(t){super(t,S(t.environment,"voting")),this.pollRemapper=new an}getPolls=async(t,e)=>{let i=`/polls${this.apiSignInUrl}`;t&&(i+=t.constructMainFiltersUrl()),w(e)&&(i+=h());let r="There was a problem fetching polls",a=await this.fetchWithoutAuth(i,r);return this.pollRemapper.remapPolls(a)};getPollById=async(t,e)=>{let i=`/polls/${t}${this.apiSignInUrl}`;w(e)&&(i+=h());let r="There was a problem fetching the following poll: "+t,a=await this.fetchWithoutAuth(i,r);return this.pollRemapper.remapPollById(a.data)};voteForPoll=async(t,e)=>{let i=`/polls/${t}/votes${this.apiSignInUrl}`,r="PUT",a={option_id:e},s="There was a problem voting for the following poll: "+t,l=await this.fetchWithAuth(i,s,r,a);return this.pollRemapper.remapUserVote(l.data)};deleteVoteForPoll=async t=>{let e=`/polls/${t}/votes${this.apiSignInUrl}`,i="DELETE",r="There was a problem deleting vote for the following poll: "+t;return await this.fetchWithAuth(e,r,i),!0};getMyPollVote=async t=>{let e=`/polls/${t}/votes${this.apiSignInUrl}`,i="There was a problem fetching user's own vote for the following poll: "+t,r=await this.fetchWithAuth(e,i);return this.pollRemapper.remapPollVote(r.data)};getMyPollsVotes=async t=>{let e=`/polls/votes${this.apiSignInUrl}`;t&&(e+=t.constructMainFiltersUrl());let i="There was a problem fetching user's votes for polls",r=await this.fetchWithAuth(e,i);return this.pollRemapper.remapPollsVotes(r)}};var si=class extends v{flags=null;status=null;entityIds=null;entityType=null;pollIds=null;sortOrder=null;minVotes=null;constructor(t){super(t),this.flags=t?.flags||null,this.status=t?.status||null,this.entityIds=t?.entityIds||null,this.entityType=t?.entityType||null,this.pollIds=t?.pollIds||null,this.sortOrder=t?.sortOrder||null,this.minVotes=t&&t.minVotes!==void 0?t.minVotes:null}constructMainFiltersUrl(){let t=super.constructMainFiltersUrl();return this.flags&&this.flags.length>0&&(t+=`&flags=${this.flags.join(",")}`),this.status&&(t+=`&status=${this.status}`),this.entityIds&&this.entityIds.length>0&&(t+=`&entity_ids=${this.entityIds.join(",")}`),this.pollIds&&this.pollIds.length>0&&(t+=`&poll_ids=${this.pollIds.join(",")}`),this.sortOrder&&(t+=`&sort_order=${this.sortOrder}`),this.minVotes&&(t+=`&min_votes=${this.minVotes}`),t}};var sn=class{idMappingService=null;idSchema=null;errorHandlingMode=null;validator=null;activityService=null;constructor(t){this.idSchema=t.idSchema,this.errorHandlingMode=t.errorHandlingMode,this.idMappingService=new P(t),this.validator=new St(t),this.activityService=new gt(t)}finalizePollsFilters=async t=>{if(this.idSchema!=="native"&&t.entityIds&&t.entityIds.length>0){this.validator.validateFilters(t);let e=await this.idMappingService.getEntityIdsBySchemaId(Array.from(t.entityIds),t.entityType,"native");t.entityIds=e[t.entityType]}};remapTags=async(t,e,i)=>{if(this.idSchema!="native"&&t.context&&t.context.tags&&t.context.tags.length){let r=JSON.parse(JSON.stringify(t.context.tags)),a=await this.activityService.remapTagsIds(r,e,i);t.context.tags=a}}};var nn=class{https=null;service=null;idSchema=null;constructor(t){this.idSchema=t.idSchema,this.https=new on(t),this.service=new sn(t)}getPolls=async(t,e)=>{t&&(t=new si(t),await this.service.finalizePollsFilters(t));let i=await this.https.getPolls(t,e);for(let r of i.data)await this.service.remapTags(r,"native",this.idSchema);return i};getPollById=async(t,e)=>{let i=await this.https.getPollById(t,e);return await this.service.remapTags(i,"native",this.idSchema),i};voteForPoll=async(t,e)=>await this.https.voteForPoll(t,e);deleteVoteForPoll=async t=>await this.https.deleteVoteForPoll(t);getMyPollVote=async(t,e)=>{let i=await this.https.getMyPollVote(t);if(e){let r=await this.getPolls(new si({pollIds:[t]}),!0);i.pollModel=r.data.find(a=>a.id===t)||null,i.optionModel=r.data.find(a=>a.id===t)?.options.find(a=>a.id===i.optionId)||null}return i};getMyPollsVotes=async t=>{t&&(t=new v(t));let e=await this.https.getMyPollsVotes(t),i=e.data.map(a=>a.id),r=await this.getPolls(new si({pollIds:i}),!0);return e.data=e.data.map(a=>(a.pollModel=r.data.find(s=>s.id===a.pollId)||null,a.optionModel=a.pollModel?.options.find(s=>s.id===a.optionId)||null,a)),e}};var ln=class{facade=null;constructor(t){this.facade=new nn(t)}getPolls=async(t,e)=>await this.facade.getPolls(t,e);getPollById=async(t,e)=>await this.facade.getPollById(t,e);voteForPoll=async(t,e)=>await this.facade.voteForPoll(t,e);deleteVoteForPoll=async t=>await this.facade.deleteVoteForPoll(t);getMyPollVote=async(t,e)=>await this.facade.getMyPollVote(t,e);getMyPollsVotes=async t=>await this.facade.getMyPollsVotes(t)};var pn=class{key=null;label=null;value=null};var ql=["minutesPlayed","cleanSheets","concededGoals","saves","penaltySaved","penaltyCommitted","yellowCards","redCards","assists","foulsCommitted","ownGoals","goals","tackles","shotsOn"],Ql=new Map().set("minutesPlayed","Minutes Played").set("cleanSheets","Clean Sheets").set("concededGoals","Goals Conceded").set("saves","Saves").set("penaltySaved","Penalties Saved").set("penaltyCommitted","Penalties Committed").set("yellowCards","Yellow Cards").set("redCards","Red Cards").set("assists","Assists").set("foulsCommitted","Fouls Committed").set("ownGoals","Own Goals").set("goals","Goals").set("tackles","Tackles").set("shotsOn","Shots On Target"),ni=class{static createFantasyPrediction(t,e,i){let r=new ve;return r.template_id=t||null,r.group_id=e||null,r.fixtures=i?.map(a=>({player_id:a,match_type:"FOOTBALL",market:"PLAYER_PERFORMANCE"}))||[],r}static createFantasyPlayerStats(t){return ql.map(e=>{let i=new pn,r=t.data.reduce((a,s)=>a+s.stats[e],0);return i.key=e,i.label=Ql.get(e),i.value=r,i})}};var cn=class{idMapping=null;idSchema=null;errorHandlingModel=null;football=null;constructor(t){this.idSchema=t.idSchema,this.errorHandlingModel=t.errorHandlingMode,this.football=new J(t),this.idMapping=new P(t)}remapCompetitions=async t=>{let e={competition:t};return(await this.idMapping.idMappingFacade.getEntitiesByIds(e,"native",this.idSchema)).competition};remapPlayers=async(t,e,i)=>{let r={player:Array.from(t)};return(await this.idMapping.idMappingFacade.getEntitiesByIds(r,e,i)).player};addPlayerModels=async t=>{let e=t.map(r=>r.playerId),i=await this.football.footballFacade.getPlayersMapWithNativeIds(e);return t.forEach(r=>{r.playerModel=Object.keys(i).length&&i[r.playerId]||null,r.playerId=r.playerModel?.id||r.playerId}),t};remapPlayerIdToNative=async t=>{let e=await this.idMapping.getEntityIdBySchemaId("player",t);if(e)return e.id;this.throwException(404,"id_mapping_not_found","No ID mappings are available for the provided ID. ID argument: "+t)};addMatchModels=async t=>{let e=t.map(r=>r.matchId),i=await this.football.footballFacade.getMatchesMapWithNativeIds(e);return t.forEach(r=>{r.matchModel=Object.keys(i).length&&i[r.matchId]||null,r.matchId=r.matchModel?.id||r.matchId}),t};throwException=(t,e,i)=>{throw this.errorHandlingModel==="standard"?new m(t,e,i):new f(t,e,i)}};var un=class{idSchema=null;clientHttps=null;footballHttps=null;predictorHttps=null;idMappingService=null;service=null;constructor(t){this.idSchema=t.idSchema,this.clientHttps=new N(t),this.footballHttps=new X(t),this.service=new cn(t),this.idMappingService=new P(t),this.predictorHttps=new at(t,this.idMappingService)}getConfig=async()=>{let t=await this.clientHttps.getConfig("fantasy");return this.idSchema!=="native"&&(t.competitionsWhitelist=await this.service.remapCompetitions([...t.competitionsWhitelist])),t};getPlayersPoints=async(t,e,i)=>{let r=await this.footballHttps.getPlayersPoints(t,e,i);return r.data=await this.service.addPlayerModels(r.data),r};getPlayerDetailedStatistics=async(t,e,i)=>{let r="";this.idSchema!=="native"&&(r=await this.service.remapPlayerIdToNative(e));let a=await this.footballHttps.getPlayerDetailedStatistics(t,r||e,i);return a.meta.filters.playerId=e,a.data=await this.service.addMatchModels(a.data),a};play=async(t,e,i)=>{(!i||!Array.isArray(i))&&this.service.throwException(400,"invalid_method_call","Invalid parameter provided. Please check the following parameter: "+"playerIds");let r=null;if(this.idSchema!=="native"){let a=await this.service.remapPlayers(i,this.idSchema,"native");r=ni.createFantasyPrediction(t,e,a)}else r=ni.createFantasyPrediction(t,e,i);return await this.predictorHttps.makeFootballPrediction(r)};getMyPrediction=async(t,e)=>{let i=`${t}_${e}`,r=new L(null);r.gameIds=[i];let a=await this.predictorHttps.getMyPredictions(r);return a.data.length===0?null:a.data[0]};getPlayerStatistics=async(t,e,i)=>{let r=await this.getPlayerDetailedStatistics(t,e,i);return ni.createFantasyPlayerStats(r)}};var dn=class{facade=null;constructor(t){this.facade=new un(t)}getConfig=async()=>await this.facade.getConfig();getPlayersPoints=async(t,e,i)=>await this.facade.getPlayersPoints(t,e,i);getPlayerDetailedStatistics=async(t,e,i)=>await this.facade.getPlayerDetailedStatistics(t,e,i);play=async(t,e,i)=>await this.facade.play(t,e,i);getMyPrediction=async(t,e)=>await this.facade.getMyPrediction(t,e);getPlayerStatistics=async(t,e,i)=>await this.facade.getPlayerStatistics(t,e,i)};var An=null,$n=null;function JA(o){if(Kl(o)){let t=jl(o);if(t.isValid)return An={profile:new O(o),football:new J(o),predictor:new Re(o),loyalty:new ze(o),topX:new We(o),matchQuiz:new Le(o),activity:new ys(o),miniGames:new He(o),discussions:new Ls(o),privateLeagues:new qs(o),challenges:new Xs(o),progress:new Ys,voting:new ln(o),fantasy:new dn(o)},$n={...o},An;Xl(t)}return An}var Kl=o=>!An||JSON.stringify(o)!==JSON.stringify($n)||o.authProvider.getIdToken()!==$n.authProvider.getIdToken(),jl=o=>{let e=new Aa().validate(o);return(e.idSchema.validation==="missing"||e.idSchema.validation==="invalid")&&(console.warn(e.idSchema.message.text),o.idSchema="native"),(e.environment.validation==="missing"||e.environment.validation==="invalid")&&(console.warn(e.environment.message.text),o.environment="prod"),(e.lang.validation==="missing"||e.lang.validation==="invalid")&&(console.warn(e.lang.message.text),o.lang="en"),(e.errorHandlingMode.validation==="missing"||e.errorHandlingMode.validation==="invalid")&&(console.warn(e.errorHandlingMode.message.text),o.errorHandlingMode="default"),e.authProvider.validation==="invalid"&&console.warn(e.authProvider.message.text),e},Xl=o=>{let t="authProvider",e="isValid";Object.keys(o).forEach(i=>{let r=o[i];if(i!==e&&i!==t){if(r.message.type==="error")throw new Error(r.message.text)}else i!==e&&i===t&&Object.keys(new kt).forEach(a=>{if(r[a].message.type==="error")throw new Error(r[a].message.text)})})};export{JA as FansUnitedSDK};
|
|
4
4
|
//# sourceMappingURL=index.js.map
|