fansunited-sdk-esm 1.45.1 → 1.45.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/index.js.map +2 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
var Ia=Object.create;var To=Object.defineProperty;var Pa=Object.getOwnPropertyDescriptor;var Fa=Object.getOwnPropertyNames;var Ta=Object.getPrototypeOf,_a=Object.prototype.hasOwnProperty;var Ra=(a,t,e)=>t in a?To(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var co=(a,t)=>()=>(t||a((t={exports:{}}).exports,t),t.exports);var Ea=(a,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Fa(t))!_a.call(a,r)&&r!==e&&To(a,r,{get:()=>t[r],enumerable:!(i=Pa(t,r))||i.enumerable});return a};var va=(a,t,e)=>(e=a!=null?Ia(Ta(a)):{},Ea(t||!a||!a.__esModule?To(e,"default",{value:a,enumerable:!0}):e,a));var _o=(a,t,e)=>(Ra(a,typeof t!="symbol"?t+"":t,e),e);var Jo=co((Gs,fo)=>{var Oa=function(){"use strict";function a(c,m){return m!=null&&c instanceof m}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,m,d,M,h){typeof m=="object"&&(d=m.depth,M=m.prototype,h=m.includeNonEnumerable,m=m.circular);var dt=[],bt=[],wt=typeof Buffer<"u";typeof m>"u"&&(m=!0),typeof d>"u"&&(d=1/0);function N(f,it){if(f===null)return null;if(it===0)return f;var P,_e;if(typeof f!="object")return f;if(a(f,t))P=new t;else if(a(f,e))P=new e;else if(a(f,i))P=new i(function(Re,u){f.then(function(Ee){Re(N(Ee,it-1))},function(Ee){u(N(Ee,it-1))})});else if(r.__isArray(f))P=[];else if(r.__isRegExp(f))P=new RegExp(f.source,l(f)),f.lastIndex&&(P.lastIndex=f.lastIndex);else if(r.__isDate(f))P=new Date(f.getTime());else{if(wt&&Buffer.isBuffer(f))return Buffer.allocUnsafe?P=Buffer.allocUnsafe(f.length):P=new Buffer(f.length),f.copy(P),P;a(f,Error)?P=Object.create(f):typeof M>"u"?(_e=Object.getPrototypeOf(f),P=Object.create(_e)):(P=Object.create(M),_e=M)}if(m){var Ho=dt.indexOf(f);if(Ho!=-1)return bt[Ho];dt.push(f),bt.push(P)}a(f,t)&&f.forEach(function(Re,u){var Ee=N(u,it-1),wa=N(Re,it-1);P.set(Ee,wa)}),a(f,e)&&f.forEach(function(Re){var u=N(Re,it-1);P.add(u)});for(var K in f){var Fo;_e&&(Fo=Object.getOwnPropertyDescriptor(_e,K)),!(Fo&&Fo.set==null)&&(P[K]=N(f[K],it-1))}if(Object.getOwnPropertySymbols)for(var Uo=Object.getOwnPropertySymbols(f),K=0;K<Uo.length;K++){var lo=Uo[K],ce=Object.getOwnPropertyDescriptor(f,lo);ce&&!ce.enumerable&&!h||(P[lo]=N(f[lo],it-1),ce.enumerable||Object.defineProperty(P,lo,{enumerable:!1}))}if(h)for(var Go=Object.getOwnPropertyNames(f),K=0;K<Go.length;K++){var po=Go[K],ce=Object.getOwnPropertyDescriptor(f,po);ce&&ce.enumerable||(P[po]=N(f[po],it-1),Object.defineProperty(P,po,{enumerable:!1}))}return P}return N(c,d)}r.clonePrototype=function(m){if(m===null)return null;var d=function(){};return d.prototype=m,new d};function o(c){return Object.prototype.toString.call(c)}r.__objToStr=o;function s(c){return typeof c=="object"&&o(c)==="[object Date]"}r.__isDate=s;function p(c){return typeof c=="object"&&o(c)==="[object Array]"}r.__isArray=p;function n(c){return typeof c=="object"&&o(c)==="[object RegExp]"}r.__isRegExp=n;function l(c){var m="";return c.global&&(m+="g"),c.ignoreCase&&(m+="i"),c.multiline&&(m+="m"),m}return r.__getRegExpFlags=l,r}();typeof fo=="object"&&fo.exports&&(fo.exports=Oa)});var pa=co((Vs,Lo)=>{"use strict";var he=typeof Reflect=="object"?Reflect:null,Zo=he&&typeof he.apply=="function"?he.apply:function(t,e,i){return Function.prototype.apply.call(t,e,i)},go;he&&typeof he.ownKeys=="function"?go=he.ownKeys:Object.getOwnPropertySymbols?go=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:go=function(t){return Object.getOwnPropertyNames(t)};function La(a){console&&console.warn&&console.warn(a)}var ea=Number.isNaN||function(t){return t!==t};function w(){w.init.call(this)}Lo.exports=w;Lo.exports.once=Ba;w.EventEmitter=w;w.prototype._events=void 0;w.prototype._eventsCount=0;w.prototype._maxListeners=void 0;var ta=10;function yo(a){if(typeof a!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof a)}Object.defineProperty(w,"defaultMaxListeners",{enumerable:!0,get:function(){return ta},set:function(a){if(typeof a!="number"||a<0||ea(a))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+a+".");ta=a}});w.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};w.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||ea(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 ia(a){return a._maxListeners===void 0?w.defaultMaxListeners:a._maxListeners}w.prototype.getMaxListeners=function(){return ia(this)};w.prototype.emit=function(t){for(var e=[],i=1;i<arguments.length;i++)e.push(arguments[i]);var r=t==="error",o=this._events;if(o!==void 0)r=r&&o.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 p=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw p.context=s,p}var n=o[t];if(n===void 0)return!1;if(typeof n=="function")Zo(n,this,e);else for(var l=n.length,c=na(n,l),i=0;i<l;++i)Zo(c[i],this,e);return!0};function ra(a,t,e,i){var r,o,s;if(yo(e),o=a._events,o===void 0?(o=a._events=Object.create(null),a._eventsCount=0):(o.newListener!==void 0&&(a.emit("newListener",t,e.listener?e.listener:e),o=a._events),s=o[t]),s===void 0)s=o[t]=e,++a._eventsCount;else if(typeof s=="function"?s=o[t]=i?[e,s]:[s,e]:i?s.unshift(e):s.push(e),r=ia(a),r>0&&s.length>r&&!s.warned){s.warned=!0;var p=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");p.name="MaxListenersExceededWarning",p.emitter=a,p.type=t,p.count=s.length,La(p)}return a}w.prototype.addListener=function(t,e){return ra(this,t,e,!1)};w.prototype.on=w.prototype.addListener;w.prototype.prependListener=function(t,e){return ra(this,t,e,!0)};function xa(){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 oa(a,t,e){var i={fired:!1,wrapFn:void 0,target:a,type:t,listener:e},r=xa.bind(i);return r.listener=e,i.wrapFn=r,r}w.prototype.once=function(t,e){return yo(e),this.on(t,oa(this,t,e)),this};w.prototype.prependOnceListener=function(t,e){return yo(e),this.prependListener(t,oa(this,t,e)),this};w.prototype.removeListener=function(t,e){var i,r,o,s,p;if(yo(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(o=-1,s=i.length-1;s>=0;s--)if(i[s]===e||i[s].listener===e){p=i[s].listener,o=s;break}if(o<0)return this;o===0?i.shift():Da(i,o),i.length===1&&(r[t]=i[0]),r.removeListener!==void 0&&this.emit("removeListener",t,p||e)}return this};w.prototype.off=w.prototype.removeListener;w.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 o=Object.keys(i),s;for(r=0;r<o.length;++r)s=o[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 aa(a,t,e){var i=a._events;if(i===void 0)return[];var r=i[t];return r===void 0?[]:typeof r=="function"?e?[r.listener||r]:[r]:e?Na(r):na(r,r.length)}w.prototype.listeners=function(t){return aa(this,t,!0)};w.prototype.rawListeners=function(t){return aa(this,t,!1)};w.listenerCount=function(a,t){return typeof a.listenerCount=="function"?a.listenerCount(t):sa.call(a,t)};w.prototype.listenerCount=sa;function sa(a){var t=this._events;if(t!==void 0){var e=t[a];if(typeof e=="function")return 1;if(e!==void 0)return e.length}return 0}w.prototype.eventNames=function(){return this._eventsCount>0?go(this._events):[]};function na(a,t){for(var e=new Array(t),i=0;i<t;++i)e[i]=a[i];return e}function Da(a,t){for(;t+1<a.length;t++)a[t]=a[t+1];a.pop()}function Na(a){for(var t=new Array(a.length),e=0;e<t.length;++e)t[e]=a[e].listener||a[e];return t}function Ba(a,t){return new Promise(function(e,i){function r(s){a.removeListener(t,o),i(s)}function o(){typeof a.removeListener=="function"&&a.removeListener("error",r),e([].slice.call(arguments))}la(a,t,o,{once:!0}),t!=="error"&&ka(a,r,{once:!0})})}function ka(a,t,e){typeof a.on=="function"&&la(a,"error",t,e)}function la(a,t,e,i){if(typeof a.on=="function")i.once?a.once(t,e):a.on(t,e);else if(typeof a.addEventListener=="function")a.addEventListener(t,function r(o){i.once&&a.removeEventListener(t,r),e(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof a)}});var da=co((ca,ma)=>{(function(){var a,t,e,i=[].splice,r=function(s,p){if(!(s instanceof p))throw new Error("Bound instance method accessed before binding")},o=[].indexOf;e=Jo(),a=pa().EventEmitter,ma.exports=t=function(){class s extends a{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(l=>{var c;c=this[l],this[l]=function(...m){var d,M,h,dt;if(h=m,[...m]=h,[d]=i.call(m,-1),typeof d=="function")try{dt=c(...m),d(null,dt)}catch(bt){M=bt,d(M)}else return c(...m,d)}})),this.stats={hits:0,misses:0,keys:0,ksize:0,vsize:0},this.validKeyTypes=["string","number"],this._checkData()}get(n){var l,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++,l=this._unwrap(this.data[n]),l;this.stats.misses++}mget(n){var l,c,m,d,M,h;if(r(this,s),!Array.isArray(n))throw l=this._error("EKEYSTYPE"),l;for(h={},m=0,M=n.length;m<M;m++){if(d=n[m],(c=this._isInvalidKey(d))!=null)throw c;this.data[d]!=null&&this._check(d,this.data[d])?(this.stats.hits++,h[d]=this._unwrap(this.data[d])):this.stats.misses++}return h}set(n,l,c){var m,d,M;if(r(this,s),this.options.maxKeys>-1&&this.stats.keys>=this.options.maxKeys)throw m=this._error("ECACHEFULL"),m;if(this.options.forceString&&!typeof l==="string"&&(l=JSON.stringify(l)),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(l,c),this.stats.vsize+=this._getValLength(l),M||(this.stats.ksize+=this._getKeyLength(n),this.stats.keys++),this.emit("set",n,l),!0}mset(n){var l,c,m,d,M,h,dt,bt,wt,N;if(r(this,s),this.options.maxKeys>-1&&this.stats.keys+n.length>=this.options.maxKeys)throw l=this._error("ECACHEFULL"),l;for(m=0,dt=n.length;m<dt;m++){if(h=n[m],{key:M,val:N,ttl:wt}=h,wt&&typeof wt!="number")throw l=this._error("ETTLTYPE"),l;if((c=this._isInvalidKey(M))!=null)throw c}for(d=0,bt=n.length;d<bt;d++)h=n[d],{key:M,val:N,ttl:wt}=h,this.set(M,N,wt);return!0}del(n){var l,c,m,d,M,h;for(r(this,s),Array.isArray(n)||(n=[n]),l=0,m=0,M=n.length;m<M;m++){if(d=n[m],(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--,l++,h=this.data[d],delete this.data[d],this.emit("del",d,h.v))}return l}take(n){var l;return r(this,s),l=this.get(n),l!=null&&this.del(n),l}ttl(n,l){var c;if(r(this,s),l||(l=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])?(l>=0?this.data[n]=this._wrap(this.data[n].v,l,!1):this.del(n),!0):!1}getTtl(n){var l,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 l=this.data[n].t,l}}keys(){var n;return r(this,s),n=Object.keys(this.data),n}has(n){var l;return r(this,s),l=this.data[n]!=null&&this._check(n,this.data[n]),l}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 l,c,m;r(this,s),c=this.data;for(l in c)m=c[l],this._check(l,m);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,l){var c;return r(this,s),c=!0,l.t!==0&&l.t<Date.now()&&(this.options.deleteOnExpire&&(c=!1,this.del(n)),this.emit("expired",n,this._unwrap(l))),c}_isInvalidKey(n){var l;if(r(this,s),l=typeof n,o.call(this.validKeyTypes,l)<0)return this._error("EKEYTYPE",{type:typeof n})}_wrap(n,l,c=!0){var m,d,M,h;return r(this,s),this.options.useClones||(c=!1),d=Date.now(),m=0,h=1e3,l===0?m=0:l?m=d+l*h:this.options.stdTTL===0?m=this.options.stdTTL:m=d+this.options.stdTTL*h,M={t:m,v:c?e(n):n}}_unwrap(n,l=!0){return this.options.useClones||(l=!1),n.v!=null?l?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,l={}){var c;return r(this,s),c=new Error,c.name=n,c.errorcode=n,c.message=this.ERRORS[n]!=null?this.ERRORS[n](l):"-",c.data=l,c}_initErrors(){var n,l,c;r(this,s),this.ERRORS={},c=this._ERRORS;for(l in c)n=c[l],this.ERRORS[l]=this.createErrorMessage(n)}createErrorMessage(n){return function(l){return n.replace("__key",l.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(ca)});var fa=co((ua,ha)=>{(function(){var a;a=ha.exports=da(),a.version="5.1.2"}).call(ua)});var Ro=a=>{let t=200,e=[],i=0;return e[i]=[],a.forEach(r=>{e[i].length<=t-1?e[i].push(r):(i++,e[i]=[r])}),e},me=(a,t)=>{let e=[];for(;a.length>t;){let i=a.splice(0,t);e.push(i)}return e.push(a),e},L=(a,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"},r={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"},o={profile:"https://profile.fansunitedstagingapi.com/v1",football:"https://football.fansunitedstagingapi.com/v1",idMapping:"https://id-mapping.fansunitedstagingapi.com/v1",predictor:"https://prediction.fansunitedstagingapi.com/v1",client:"https://client.fansunitedstagingapi.com/v1",loyalty:"https://loyalty.fansunitedstagingapi.com/v1"};return a==="prod"?e=i[t]:a==="dev"?e=r[t]:e=o[t],e},ut=a=>a.filter((e,i,r)=>i===r.indexOf(e)),R=a=>a||!1,E=()=>`&disable_cache=${Date.now()}`,mo=a=>JSON.parse(JSON.stringify(a.sort((t,e)=>t.localeCompare(e))));var ve=class{id=null;name=null;nickname=null;avatar=null;gender=null;country=null;birthDate=null;interests=[];followingCount=0;followersCount=0};var Se=class{profilesFromResponse=t=>t?t.map(e=>this.fullProfileFromResponse(e)):null;fullProfileFromResponse=t=>{let e=new ve;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.interests=t.interests?t.interests:[],e.followingCount=t.following_count,e.followersCount=t.followers_count,e}};var Ce=class{nextPageStartsAfter=null;itemsPerPage=null};var It=class{pagination=new Ce};var F=class{meta=new It;data=[]};var Ae=class{avatar=null;followingId=null;name=null;nickname=null;profileId=null};var Oe=class{followResponse=t=>t.map(e=>this.remapResponse(e));followingFromResponse=t=>{let e=new F;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 Ae;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 Le=class{avatar=null;followerId=null;name=null;nickname=null;profileId=null};var xe=class{followersFromResponse=t=>{let e=new F;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 Le;return e.avatar=t.avatar,e.followerId=t.follower_id,e.name=t.name,e.profileId=t.profile_id,e}};var de=class{profile_ids=[]};function Eo(a){this.message=a}Eo.prototype=new Error,Eo.prototype.name="InvalidCharacterError";var $o=typeof window<"u"&&window.atob&&window.atob.bind(window)||function(a){var t=String(a).replace(/=+$/,"");if(t.length%4==1)throw new Eo("'atob' failed: The string to be decoded is not correctly encoded.");for(var e,i,r=0,o=0,s="";i=t.charAt(o++);~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 Sa(a){var t=a.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($o(e).replace(/(.)/g,function(i,r){var o=r.charCodeAt(0).toString(16).toUpperCase();return o.length<2&&(o="0"+o),"%"+o}))}(t)}catch{return $o(t)}}function uo(a){this.message=a}function Ca(a,t){if(typeof a!="string")throw new uo("Invalid token specified");var e=(t=t||{}).header===!0?0:1;try{return JSON.parse(Sa(a.split(".")[e]))}catch(i){throw new uo("Invalid token specified: "+i.message)}}uo.prototype=new Error,uo.prototype.name="InvalidTokenError";var Wo=Ca;var v={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id",api_football:"api_football_id"},vo={PREDICTOR_USER_RELATED_OPERATION:"https://docs.fansunitedmedia.com/docs/predictor-operations#user-related-operations"},So=["matchId","matchType","market","prediction"],Ko=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 Co={UNEXPECTED_STATUS_PROP:`Unexpected provided property 'status'. You can NOT use this property for this method. For more information visit our documentation:
|
|
2
2
|
${vo.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
|
-
${vo.PREDICTOR_USER_RELATED_OPERATION}`},jo=(a,t)=>`The prediction '${a}' 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`,ho=a=>`The market '${a}' is not supported from Fans United. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,Xo=a=>`The market '${a}' is not valid for Top X game. The only available market is CORRECT_SCORE.`,Yo=a=>`The field/s '${a.length>1?a.join(", "):a[0]}' is/are invalid. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/javascript-sdk`,qo=(a,t)=>`The following field/s is/are missing from ${a}: '${t.length>1?t.join(", "):t[0]}'. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,Qo=(a,t)=>`The field ${a} has incorrect type. The correct type is ${t}`;var ht=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 y=class{error={code:0,status:"",message:""};constructor(t,e,i){this.error.code=t,this.error.status=e,this.error.message=i}};var S=class{baseUrl=null;apiSignInUrl=null;jwtToken=null;idSchema=null;retryRequest=!1;headers=null;authHeaders=null;errorHandlingMode=null;constructor(t,e){this.baseUrl=e,this.apiSignInUrl=`?key=${t.apiKey}&client_id=${t.clientId}`,this.jwtToken=t.authProvider.getIdToken(),this.errorHandlingMode=t.errorHandlingMode,this.idSchema=t.idSchema,this.headers={"Content-Type":"application/json"},this.authHeaders={"Content-Type":"application/json",Authorization:`Bearer ${t.authProvider.getIdToken()}`}}fetchWithoutAuth=async(t,e)=>{let i=await fetch(this.baseUrl+t,{headers:this.headers}),r=await i.json();if(!i.ok){let o=this.transformFetchException(i,r);throw console.warn(e,o),o}return r};fetchWithAuth=async(t,e,i,r)=>{this.validateJWTToken();let o=null,s=null;if(i&&r?o=await fetch(this.baseUrl+t,{method:i,headers:this.authHeaders,body:JSON.stringify(r)}):i&&!r?o=await fetch(this.baseUrl+t,{method:i,headers:this.authHeaders}):o=await fetch(this.baseUrl+t,{headers:this.authHeaders}),i!=="DELETE"&&(s=await o.json()),!o.ok){(o.status===401||o.status===403)&&!this.retryRequest&&(this.retryRequest=!0,await this.fetchWithAuth(t,e,i,r)),this.retryRequest=!1;let p=this.transformFetchException(o,s||await o.json());throw console.warn(e,p),p}return this.retryRequest=!1,s};transformFetchException=(t,e)=>{if(!e&&t.status===401){if(this.errorHandlingMode==="standard")return new y(401,"unauthorized","Invalid JWT token is provided");let s={code:401,status:"unauthorized",message:"Invalid JWT token is provided"};return new ht(t,s)}let{code:i,status:r,message:o}=e.error;return this.errorHandlingMode==="standard"?new y(i,r,o):new ht(t,e.error)};validateJWTToken=()=>{let t=null;try{t=Wo(this.jwtToken)}catch(i){if(this.errorHandlingMode==="default"){let r={status:401,statusText:i.message,headers:{}},o={code:401,status:"invalid_token",message:"Invalid JWT token is provided"};throw new ht(r,o)}else if(this.errorHandlingMode==="standard")throw new y(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 ht(i,r)}else if(this.errorHandlingMode==="standard")throw new y(401,"invalid_token","The provided JWT token is expired")}}};var Aa="/countries",x="/profile",Ao="/profiles",Tt=class extends S{profileRemapper=null;followingRemapper=null;followersRemapper=null;lang=null;limitIds=100;constructor(t){super(t,L(t.environment,"profile")),this.lang=t.lang,this.profileRemapper=new Se,this.followingRemapper=new Oe,this.followersRemapper=new xe}getCountries=async t=>{let e=`&lang=${this.lang}`,i=`${Aa}${this.apiSignInUrl}${e}`,r=Date.now(),o="There was a problem fetching profile countries";return t&&(i+=`&disable_cache=${r}`),(await this.fetchWithoutAuth(i,o)).data};getProfile=async t=>{let e=`${x}${this.apiSignInUrl}`,i="";if(t){e=`${Ao}/${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)=>{let i=Date.now(),r=`There was a problem fetching the following profiles: ${t.join(",")}`;if(t.length>this.limitIds){let p=[],n=me(t,this.limitIds);for(let l of n){let c=`${Ao}${this.apiSignInUrl}&profile_ids=${l.join(",")}`;r=`There was a problem fetching the following profiles: ${l.join(",")}`,e&&(c+=`&disable_cache=${i}`);let m=await this.fetchWithoutAuth(c,r);p.push(...this.profileRemapper.profilesFromResponse(m.data))}return p}let o=`${Ao}${this.apiSignInUrl}&profile_ids=${t.join(",")}`;e&&(o+=`&disable_cache=${i}`);let s=await this.fetchWithoutAuth(o,r);return this.profileRemapper.profilesFromResponse(s.data)};getFollowers=async(t,e)=>{let i=`${x}/followers${this.apiSignInUrl}`,r="There was a problem fetching the followers for own profile";if(t&&!e){i=`${x}/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=`${x}/${e}/followers${this.apiSignInUrl}${t.constructFilterUrl()}`:!t&&e&&(i=`${x}/${e}/followers${this.apiSignInUrl}`),r=`There was a problem fetching the followers for profile: ${e}`;let o=await this.fetchWithoutAuth(i,r);return this.followersRemapper.followersFromResponse(o)};getFollowing=async(t,e)=>{let i=`${x}/following${this.apiSignInUrl}`,r="There was a problem fetching the followers of own profile";if(t&&!e){i=`${x}/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=`${x}/${e}/following${this.apiSignInUrl}${t.constructFilterUrl()}`:!t&&e&&(i=`${x}/${e}/following${this.apiSignInUrl}`),r=`There was a problem fetching the followers of the following profile: ${e}`;let o=await this.fetchWithoutAuth(i,r);return this.followingRemapper.followingFromResponse(o)};follow=async t=>{let e=new de;e.profile_ids=t;let i=x+`/follow${this.apiSignInUrl}`,r=`There was a problem with following profiles: ${t.join(",")}`,o="POST",s=await this.fetchWithAuth(i,r,o,e);return this.followingRemapper.followResponse(s.data)};unfollow=async t=>{let e=new de;e.profile_ids=t;let i=x+`/follow${this.apiSignInUrl}`,r=`There was a problem with unfollowing profiles: ${t.join(",")}`,o="DELETE";return await this.fetchWithAuth(i,r,o,e),!0};getBadges=async t=>{let e=`${x}/badges${this.apiSignInUrl}`,i="There was a problem with fetching own badges";return t?(e=`${x}/${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=x+this.apiSignInUrl,i="There was a problem updating the own profile",r="PATCH",o=await this.fetchWithAuth(e,i,r,t);return this.profileRemapper.fullProfileFromResponse(o.data)}};var B=(o=>(o.NATIVE="native",o.ENETPULSE="enetpulse",o.SPORTRADAR="sportradar",o.SPORTAL_365="sportal365",o.API_FOOTBALL="api_football",o))(B||{});var De={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},Ne=class extends S{constructor(t){super(t,L(t.environment,"idMapping"))}getEntityById=async(t,e)=>{let i=`/football${this.apiSignInUrl}&input_provider=${this.idSchema}&${De[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}&${De[t]}=${e}`,o=`There was a problem with id mapping request for the following id: ${e}`;return await this.fetchWithoutAuth(r,o)};getEntityIdsByIdsAndSchema=async(t,e,i)=>{let r=`/football${this.apiSignInUrl}&input_provider=${i}&${De[t]}=${e.join(",")}`,o=`There was a problem with id mapping request for the following ids: ${e.join(",")}`;return await this.fetchWithoutAuth(r,o)};getEntitiesByIds=async(t,e,i)=>{e.sort((s,p)=>s.localeCompare(p));let r=Ro(e),o=[];for(let s of r){let p=`/football${this.apiSignInUrl}&input_provider=${i}&${De[t]}=${s.join(",")}`,n=`There was a problem with id mapping request for the following ids :${s.join(",")}`,l=await this.fetchWithoutAuth(p,n);o=[...o,...l.data]}return o};getEntitiesByIdObjs=async(t,e)=>{let i=[],r={},o=[];Object.keys(t).forEach(l=>{i.push.apply(i,t[l])});let s=ut(i),p=Ro(s);for(let l of p){let c="";if(Object.keys(t).forEach(m=>{r[m]=[];let d=l.filter(M=>t[m].includes(M));d&&d.length>0&&(r[m]=d)}),Object.keys(r).forEach(m=>{r[m].length>0&&(r[m].sort((d,M)=>d.localeCompare(M)),c+="&",c+=`${De[m]}=${r[m].join(",")}`)}),c&&c.length>0){let m=`/football${this.apiSignInUrl}&input_provider=${e||"native"}${c}`,d="There was a problem with id mapping request",M=await this.fetchWithoutAuth(m,d);o.push(M.data)}else o.push([])}return Array.prototype.concat.apply([],o)};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 zo="FansUnited",Oo={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}}},Be=class{idSchema="";expirationProfileTimeout=600;expirationBadgesTimeout=3600;expirationClientFeaturesTimeout=14400;expirationFootballIdsTimeout=604800;constructor(t){this.idSchema=t,(this.getData()===void 0||this.getData()===null)&&this.setData(Oo)}clearData=()=>{this.setData(Oo)};getEntityById=(t="",e="")=>this.getData().football.ids.find(i=>{let r=v[this.idSchema];return i&&`${i[r]}`===e&&i.resource===t});getEntity=(t,e,i)=>Array.isArray(t)?this.getData().football.ids.filter(r=>{let o=v[i];return r&&t.includes(`${r[o]}`)&&r.resource===e}):this.getData().football.ids.find(r=>{let o=v[i];return r&&`${r[o]}`===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=v[e],r={};return Object.keys(t).forEach(o=>{let s=t[o],n=this.getEntity(s,o,e).map(c=>c[i]),l=t[o].filter(c=>!n.includes(c));r[o]=s.map(c=>l.includes(c)?{id:c,exists:!1}:{id:c,exists:!0})}),r};getIdsByType=(t,e,i)=>{let r=v[i],o=v[e],s={};return Object.keys(t).forEach(p=>{let n=t[p],l=[];this.getData().football.ids.forEach(c=>{n.forEach((m,d)=>{m===c[o]&&p===c.resource&&(l[d]=c[r])})}),s[p]=l}),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=()=>JSON.parse(localStorage.getItem(zo));setData=t=>{localStorage.setItem(zo,JSON.stringify(t))};initialNewSchema=(t,e)=>{let i=this.getData();(!i||!i[t]||!i[t][e])&&this.setData(Oo)}};var ga=va(fa());var g=class{profileTTL=600;clientTTL=14400;profileBadgesTTL=3600;idMappingsExpiration=0;idSchema="";constructor(t){}static getInstance(t){return g.instance||(g.instance=new g(t),g.nodeCache.options.useClones=!1),g.instance}clearData=()=>g.nodeCache.flushAll();getEntityById=(t,e)=>{let i=g.nodeCache.get("ids");return i?i.find(r=>{let o=v[this.idSchema];return r&&`${r[o]}`===e&&r.resource===t}):null};getEntity=(t,e,i)=>{let r=g.nodeCache.get("ids");return r?Array.isArray(t)?[]:null:Array.isArray(t)?r.filter(o=>{let s=v[i];return o&&t.includes(`${o[s]}`)&&o.resource===e}):r.find(o=>{let s=v[i];return o&&`${o[s]}`===t&&o.resource===e})};checkForExistingIdObjs=(t,e)=>{let i=v[e],r={};return Object.keys(t).forEach(o=>{let s=t[o],n=this.getEntity(s,o,e).map(c=>c[i]),l=t[o].filter(c=>!n.includes(c));r[o]=s.map(c=>l.includes(c)?{id:c,exists:!1}:{id:c,exists:!0})}),r};getIdsByType=(t,e,i)=>{let r=v[i],o=v[e],s=g.nodeCache.get("ids"),p={};return s?(Object.keys(t).forEach(n=>{let l=t[n],c=[];s.forEach(m=>{l.forEach((d,M)=>{d===m[o]&&n===m.resource&&(c[M]=m[r])})}),p[n]=c}),p):null};addIdMapping=t=>{let e=g.nodeCache.get("ids");e.push(t),g.nodeCache.set("ids",e)};addIdMappings=t=>{let e=g.nodeCache.get("ids");e=[...e,...t],g.nodeCache.set("ids",e)};addTopIdMappings=t=>{let e=g.nodeCache.get("ids"),i=604800;if(e){let r=JSON.parse(JSON.stringify(e));r=r.filter(o=>o.resource!=="match"),t=t.filter(o=>o.resource==="match"),r=[...r,...t],g.nodeCache.set("ids",r)}else g.nodeCache.set("ids",t);this.idMappingsExpiration=Math.floor(Date.now()/1e3)+i};setOwnProfile=t=>g.nodeCache.set("profile",t,this.profileTTL);getOwnProfile=()=>g.nodeCache.get("profile");getProfileCountries=()=>g.nodeCache.get("profile_countries");setProfileCountries=t=>g.nodeCache.set("profile_countries",t);getProfileStats=()=>g.nodeCache.get("profile_stats");setProfileStats=t=>g.nodeCache.set("profile_stats",t,this.profileTTL);getProfileBadges=()=>g.nodeCache.get("profile_badges");setProfileBadges=t=>{g.nodeCache.set("profile_badges",t,this.profileBadgesTTL)};getFootballCountries=()=>g.nodeCache.get("football_countries");setFootballCountries=t=>g.nodeCache.set("football_countries",t);getCompetitions=t=>{let e=g.nodeCache.get("football_competitions");return e?t?t.competitionSearchFilter(e):e:null};setCompetitions=t=>g.nodeCache.set("football_competitions",t);getCompetitionsLength=()=>{let t=g.nodeCache.get("football_competitions");return t?t.length:0};getClientFeatures=()=>g.nodeCache.get("client");setClientFeatures=t=>g.nodeCache.set("client",t,this.clientTTL);deleteClientFeatures=()=>g.nodeCache.del("client");getExpiration=(t,e)=>{let i=this.getKeyFromExpirationType(e);return i==="ids"?this.idMappingsExpiration:g.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"}}},_t=g;_o(_t,"instance"),_o(_t,"nodeCache",new ga.default);var k=class{createLocalCacheInstance=t=>typeof window>"u"?_t.getInstance(t):new Be(t)};var ke=class{localCache=null;https=null;constructor(t){this.localCache=new k().createLocalCacheInstance(t.idSchema),this.https=new Ne(t)}getEntitiesByIds=async(t,e,i)=>{await this.setTopIdMappings();try{let r=this.localCache.checkForExistingIdObjs(t,e),o=this.splitForRequestAndExisting(r),s=await this.https.getEntitiesByIdObjs(o.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 o=await this.requestEntity(t,e,i);return this.localCache.addIdMappings(o),o};splitForRequestAndExisting=t=>{let e={},i={};return Object.keys(t).forEach(r=>{e[r]=t[r].filter(o=>!o.exists).map(o=>o.id),i[r]=t[r].filter(o=>o.exists).map(o=>o.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 Mo=a=>{switch(a){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 a}};var He=class{extractedObjIds={};traverse=(t,e)=>(e=Mo(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 Ue=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(t,e,i)=>(e=Mo(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 T=class{idSchema="";idMappingFacade=null;constructor(t){this.idSchema=t.idSchema,this.idMappingFacade=new ke(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 o=new He().traverse(i,e);return this.idMappingFacade.getEntitiesByIds(o,"native",this.idSchema).then(s=>new Ue().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 D=class{completed=!1;percentage;constructor(t){this.percentage=t}};var Ge=class{teamFollowed=new D(10);teamFavourite=new D(15);playerFollowed=new D(10);playerFavourite=new D(10);competitionFollowed=new D(10);competitionFavourite=new D(5);addedBirthdate=new D(10);addedGender=new D(10);addedCountry=new D(10);addedAvatar=new D(10)};var Ve=class{totalPercentage;breakdown=new Ge};var fe=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 j=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)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}};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)=>{try{return e=e||!1,await this.profileHttps.getProfiles(t,e)}catch(i){throw console.warn(`There was a problem retrieving the selected profiles: ${t.join(",")} `,i),i}};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 fe(t));let i=await this.profileHttps.getFollowers(t,e),r=i.data.map(o=>o.followerId);if(r.length){let o=await this.getByIds(r),s=i.data.map(p=>(o.forEach(n=>{p.followerId===n.id&&(p.name=n.name,p.nickname=n.nickname,p.avatar=n.avatar)}),p));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 fe(t));let i=await this.profileHttps.getFollowing(t,e),r=i.data.map(o=>o.followingId);if(r.length){let o=await this.getByIds(r),s=i.data.map(p=>(o.forEach(n=>{p.followingId===n.id&&(p.name=n.name,p.nickname=n.nickname,p.avatar=n.avatar)}),p));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 Ve,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=["predictionsMade","predictions","tiers","badges"],e=this.getLocalStorageData("statistics"),i=e?t.every(r=>Object.keys(e).includes(r)):!1;if(e&&Object.keys(e).length&&i)return JSON.parse(JSON.stringify(e));try{let r=await this.activityHttps.getStats();return this.localCache.setProfileStats(r),r}catch(r){throw console.warn("There was a problem retrieving own profile statistics: ",r),r}};getBadges=async()=>{let t=this.getLocalStorageData("badges");if(t)return t;try{let e=await this.profileHttps.getBadges();return this.localCache.setProfileBadges(e),e}catch(e){throw console.warn("There was a problem retrieving own profile badges: ",e),e}};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 $e=class{id=null;name=null;assets=null};var We=class{extractUpdatedProps=(t,e)=>{let i=["name","nickname","gender","avatar"],r={};return Object.keys(t).forEach(o=>{if(i.includes(o)&&t[o]!==e[o])r[o]=e[o];else if(o==="birthDate")(e[o]===null||t[o]===null&&e[o]||t[o]!==e[o])&&(r.birth_date=e[o]);else if(o==="country")e[o]===null?r.country_id=e[o]:(t[o]===null&&e[o]||t[o].id!==e[o].id)&&(r.country_id=e[o].id);else if(o==="interests"){let s=t[o],p=e[o];p.length&&this.isNewInterest(s,p)?r[o]=this.updateInterests(s,p):(!p.length&&s.length||s.length!==p.length&&!this.isNewInterest(s,p))&&(r[o]=p)}}),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(o=>t.some(s=>o.id===s.id&&o.type===s.type&&o.source===s.source&&o.favourite===s.favourite));return[e.filter(o=>!t.some(s=>o.id===s.id&&o.type===s.type&&o.source===s.source&&o.favourite===s.favourite)),i]};isAvatarValidURL=t=>{try{return new URL(t),!0}catch{return!1}}};var b=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 Ke=class{idsRemapper=null;profileHttps=null;profileService=null;localCache=null;profileFacade=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;errorHandlingMode=null;constructor(t,e,i,r,o){this.idsRemapper=t,this.localCache=e,this.profileHttps=i,this.errorHandlingMode=o,this.profileService=new We,this.profileFacade=new j(e,i,r)}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.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()=>{let t=await this.profileFacade.getStats();return await this.idsRemapper.remapProfileStats(t)};getBadges=async()=>await this.profileFacade.getBadges();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(o=>o.id!==i.id||o.type!==i.type||o.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 $e,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.errorHandlingMode==="default")throw new b(400,"invalid_avatar","Invalid URL syntax for avatar image.");if(this.errorHandlingMode==="standard")throw new y(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 o=await this.profileHttps.updateProfile(i),s=JSON.parse(JSON.stringify(o));return this.setOwnProfile(s),this.localCache.setOwnProfile(s),delete o.interests,o}let r=JSON.parse(JSON.stringify(this.ownProfile));return delete r.interests,r}};var je=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 j(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 Xe=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 ge=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&&(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(o=>{o!=="sortOrder"&&o!=="sortField"&&(o==="countryId"?r&&=i.country.id===this[o]:o==="name"?r&&=i.name.toLocaleLowerCase().includes(this[o].toLocaleLowerCase()):o==="competitionIds"?r&&=this[o].some(s=>i.id===s):r&&=i[o].toLocaleLowerCase()===this[o].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 Ye=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 ge(t),t.countryId){let o=await this.idMapping.getEntityIdsBySchemaId([`${t.countryId}`],"country","native");o.country.length===0&&(i=!0),t.countryId=o.country[0]}if(t.competitionIds){let o=await this.idMapping.getEntityIdsBySchemaId(t.competitionIds,"competition","native");o.competition.length===0&&(i=!0),t.competitionIds=o.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 ge({competitionIds:t,limit:i}),o=await this.getCompetitions(r);o.sort((n,l)=>n.id.localeCompare(l.id));let s=mo(t),p=await this.idMapping.remapEntities(o,"competition");return s.forEach((n,l)=>e.set(n,p[l])),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],o=await this.getCompetitionById(r,e);return await this.idMapping.remapEntities(o,"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 ye=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&&(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&&(t=t+"&",t=t+`team_ids=${this.teamIds.join(",")}`),t}};var qe=class{general=[];predictor=[];topX=[];matchQuiz=[]};var rt=class{points=null;gameParticipationCount=null;entityId=null;entityType=null;predictionsMade=null;correctPredictions=null};var Qe=class{id;label;assets={mainImageUrl:""};enabled;requirements=new rt};var Rt=class extends rt{postPoints=null;postsCount=null;reactionsCount=null;totalDiscussionPoints=null};var ze=class{id;label;assets={mainImageUrl:""};enabled;requirements=new Rt};var Je=class{id;weight;multiplier;conditions};var Ze=class{value=[new Je]};var Et=class{points=null;tiers=null;badges=null};var ti=class{enabled=!1;clientId=null;conditions={list:null};actions=new Ze;rewards=new Et};var ei=class{general=null;predictor=null;activity=null;topX=null;matchQuiz=null;discussionPost=null};var vt=class{enabled=!1;clientId=null;defaultMarkets=null;competitionsWhitelist=null};var St=class{enabled=!1;clientId=null;minFixtures=null;maxFixtures=null;competitionsWhitelist=null};var ii=class{competitions=[];teams=[];markets=[]};var Ct=class{enabled=!1;clientId=null;fullCoverageCompetitions=null;markets=null;successRateScopes=new ii;userDataConfig=null};var ri=class{storeIp=!1;storeDeviceId=!1;storeAgent=!1};var oi=class{remapPredictorConfig=t=>{let e=new Ct;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 St;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 vt;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 ti;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};remapRewards=t=>{let e=new Et;return e.points=this.remapPoints(t.points),e.tiers=t.tiers,e.badges=this.remapBadges(t.badges),e};remapPoints=t=>{let e=new ei;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 qe;return e.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};remapBadgeValues=t=>t.map(e=>{let i=new Qe;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});remapGeneralBadgeValues=t=>t.map(e=>{let i=new ze;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});remapRequirements=t=>{let e=new rt;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};remapGeneralRequirements=t=>{let e=new Rt;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};remapUserDataConfig=t=>{let e=new ri;return e.storeIp=t.store_ip,e.storeDeviceId=t.store_device_id,e.storeAgent=t.store_agent,e}};var H=class extends S{featureConfigRemapper=null;localStorage=null;clientId=null;constructor(t){super(t,L(t.environment,"client")),this.clientId=t.clientId,this.localStorage=new k().createLocalCacheInstance(t.idSchema),this.featureConfigRemapper=new oi}getConfig=async t=>{let e=this.getCachedFeatures();if(!e){let i=`/clients/${this.clientId}/features`,r=this.apiSignInUrl.split("&")[0],o=i+r,s="There was a problem fetching client features from Client API";e=(await this.fetchWithoutAuth(o,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)}};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 ot=class{clientHttps=null;constructor(t){this.clientHttps=new H(t)}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)};isMatchInCoverageCompetition=(t,e)=>{let i=!1;return e.includes(t)&&(i=!0),i}};var ai=class{footballService=null;https=null;idMapping=null;constructor(t,e,i){this.idMapping=i,this.https=e,this.footballService=new ot(t)}getTeamsIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new ye(t),t.countryId){let o=await this.idMapping.getEntityIdsBySchemaId([`${t.countryId}`],"country","native");o.country.length===0&&(i=!0),t.countryId=o.country[0]}if(t.scope){let o=await this.idMapping.getEntityIdsBySchemaId(t.scope,"competition","native");o.competition.length===0&&(i=!0),t.scope=o.competition}if(t.teamIds){let o=await this.idMapping.getEntityIdsBySchemaId(t.teamIds,"team","native");o.team.length===0&&(i=!0),t.teamIds=o.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 ye({teamIds:t,limit:i}),{data:o}=await this.getTeams(r);o.sort((n,l)=>n.id.localeCompare(l.id));let s=mo(t),p=await this.idMapping.remapEntities(o,"team");return s.forEach((n,l)=>e.set(n,p[l])),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 Me=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&&(t=t+"&",t=t+`scope=${this.scope.join(",")}`),this.name&&(t=t+"&",t=t+`name=${this.name}`),this.playerIds&&(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 at=class{https=null;footballService=null;idMapping=null;constructor(t,e,i){this.idMapping=i,this.https=e,this.footballService=new ot(t)}getPlayersIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new Me(t),t.countryId){let o=await this.idMapping.getEntityIdsBySchemaId([t.countryId],"country","native");o.country.length===0&&(i=!0),t.countryId=o.country[0]}if(t.playerIds){let o=await this.idMapping.getEntityIdsBySchemaId(t.playerIds,"player","native");o.player.length===0&&(i=!0),t.playerIds=o.player}if(t.scope){let o=await this.idMapping.getEntityIdsBySchemaId(t.scope,"competition","native");o.competition.length===0&&(i=!0),t.scope=o.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 Me({playerIds:t,limit:e}),r=await this.getPlayers(i);return r.data.sort((o,s)=>o.id.localeCompare(s.id)),await this.idMapping.remapEntities(r.data,"player")};getPlayersMapWithNativeIds=async t=>{let e={},i=ut(t);i.sort((o,s)=>o.localeCompare(s));let r=await this.getPlayersWithNativeIds(i);return i.forEach((o,s)=>e[o]=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 At=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=()=>{let t="";return this.countryIds&&(t=t+"&",t=t+`countries=${this.countryIds.join(",")}`),this.competitionIds&&(t=t+"&",t=t+`competitions=${this.competitionIds.join(",")}`),this.matchIds&&(t=t+"&",t=t+`matches=${this.matchIds.join(",")}`),this.status&&(t=t+"&",t=t+`status=${this.status}`),this.teamIds&&(t=t+"&",t=t+`teams=${this.teamIds.join(",")}`),this.fromDate&&(t=t+"&",t=t+`from_date=${this.fromDate}`),this.toDate&&(t=t+"&",t=t+`to_date=${this.toDate}`),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 st=class{https=null;idMapping=null;footballService=null;constructor(t,e,i){this.https=e,this.idMapping=i,this.footballService=new ot(t)}getMatchesIdMapping=async(t,e)=>{try{if(t){if(t=new At(t),t.countryIds){let r=await this.idMapping.getEntityIdsBySchemaId(t.countryIds,"country","native");t.countryIds=r.country}if(t.competitionIds){let r=await this.idMapping.getEntityIdsBySchemaId(t.competitionIds,"competition","native");t.competitionIds=r.competition}if(t.matchIds){let r=await this.idMapping.getEntityIdsBySchemaId(t.matchIds,"match","native");t.matchIds=r.match}if(t.teamIds){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 At({matchIds:t,limit:e}),r=await this.getMatches(i);return r.data.sort((o,s)=>o.id.localeCompare(s.id)),await this.idMapping.remapEntities(r.data,"match")};getMatchesMapWithNativeIds=async t=>{let e={},i=ut(t);i.sort((o,s)=>o.localeCompare(s));let r=await this.getMatchesWithNativeIds(i);if(i.length!==r.length){let o=new At({matchIds:i,limit:i.length}),s=await this.getMatches(o),p=i.filter(n=>{if(s.data.every(l=>l.id!==n))return n});i=i.filter(n=>{if(!p.includes(n))return n})}return i.forEach((o,s)=>e[o]=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),o=await this.footballService.setAvailableMarketsForMatch(r);return await this.idMapping.remapEntities(o,"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 si=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 ni=class{https=null;idMapping=null;constructor(t,e){this.https=t,this.idMapping=e}searchIdMapping=async(t,e)=>{try{if(t=new si(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 Ot=class{countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(t,e,i,r){this.countriesFacade=new Xe(e,i,r),this.competitionsFacade=new Ye(e,i,r),this.teamsFacade=new ai(t,i,r),this.playerFacade=new at(t,i,r),this.matchFacade=new st(t,i,r),this.searchFacade=new ni(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);getMatchById=async(t,e)=>this.matchFacade.getMatchIdMapping(t,e);search=async(t,e)=>this.searchFacade.searchIdMapping(t,e)};var li=class{id="";alias="";countryCode="";assets=null;name=""};var _=class{countriesFromResponse=t=>{if(t)return t.map(e=>this.countryFromResponse(e))};countryFromResponse=t=>{try{if(t){let e=new li;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 pi=class{id="";country=null;gender="";assets=null;type="";name=""};var O=class{countryRemapper=null;constructor(){this.countryRemapper=new _}fromResponse(t){try{let e=new pi;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 ci=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var mi=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName="";isDeleted=!1};var C=class{countryRemapper=null;constructor(){this.countryRemapper=new _}fromResponse(t){try{let e=new mi;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}catch(e){throw console.warn("There was a problem remapping teams response",e),e}}};var di=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new _,this.teamBasicRemapper=new C}fromResponse(t){try{let e=new ci;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 ui=class{primary=null;secondary=null;tertiary=null};var hi=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";isDeleted=!1;colors=new ui;squad=[]};var fi=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var gi=class{countryRemapper=null;constructor(){this.countryRemapper=new _}fromResponse(t){try{let e=new fi;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 yi=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new _,this.competitionRemapper=new O,this.playerRemapper=new gi}fromResponse(t){try{let e=new hi;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.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 Mi=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;homeTeam=null;awayTeam=null;isDeleted=!1;lineupsConfirmed=!1;startedAt="";minute="";scores=null;context={competition:null};status={type:null,subType:null}};var bi=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var Lt=class{fromResponse(t){try{let e=new bi;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 wi=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new C,this.competitionRemapper=new O,this.scoresRemapper=new Lt}fromResponse(t){try{let e=new Mi;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.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 U=class{type=null;subType=null};var Ii=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;isDeleted=!1;homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;stats=null;context={competition:null};timeline=[];status=new U;lineups=null};var Pi=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 Fi=class{fromResponse(t){try{let e=new Pi;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 xt=class{homeTeam={players:[]};awayTeam={players:[]}};var Ti=class{id="";name="";position="";shirtNumber;assets=null;type=""};var Dt=class{fromResponse(t){try{let e=new Ti;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 _i=class{playerRemapper=null;constructor(){this.playerRemapper=new Dt}fromResponse(t){try{let e=new xt;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 Ri=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var Ei=class{playerRemapper=null;constructor(){this.playerRemapper=new Dt}fromResponse(t){try{let e=new Ri;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 vi=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new C,this.competitionsMapper=new O,this.lineupsMapper=new _i,this.scoresMapper=new Lt,this.statsMapper=new Fi,this.timelineMapper=new Ei}fromResponse(t){try{let e=new Ii;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.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.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 xt,e}catch(e){throw console.warn("There was a problem remapping the match response",e),e}}};var Si=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var Ci=class{countryRemapper=null;constructor(){this.countryRemapper=new _}fromResponse(t){try{let e=new Si;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 Ai=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;teams=[]};var Nt=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new _,this.teamRemapper=new C}fromResponse(t){try{let e=new Ai;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 Oi=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;competitions=[];teams=[]};var Li=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new _,this.teamRemapper=new C,this.competitionRemapper=new O}fromResponse(t){try{let e=new Oi;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 xi=class{teams=null;players=null;competitions=null};var Di=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new C,this.playerRemapper=new Nt,this.competitionremapper=new O}fromResponse(t){try{let e=new xi;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 nt=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var X=class{pagination=new nt};var Bt=class{meta=new X;data=[]};var Ni=class{remapMetaProp=t=>{let e=new X;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 Y=class extends S{limitIds=200;countryRemapper=null;competitionBasicRemapper=null;competitionFullRemapper=null;teamBasicRemapper=null;teamFullRemapper=null;matchBasicRemapper=null;matchFullRemapper=null;playerBasicRemapper=null;playerFullRemapper=null;topPlayerRemapper=null;searchRemapper=null;footballMetaRemapper=null;constructor(t){super(t,L(t.environment,"football")),this.apiSignInUrl=t.lang!=="en"?this.apiSignInUrl+`&lang=${t.lang}`:this.apiSignInUrl,this.countryRemapper=new _,this.competitionBasicRemapper=new O,this.competitionFullRemapper=new di,this.teamBasicRemapper=new C,this.teamFullRemapper=new yi,this.matchBasicRemapper=new wi,this.matchFullRemapper=new vi,this.playerBasicRemapper=new Nt,this.playerFullRemapper=new Li,this.topPlayerRemapper=new Ci,this.searchRemapper=new Di,this.footballMetaRemapper=new Ni}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 o=await this.fetchWithoutAuth(i,e);return this.countryRemapper.countriesFromResponse(o.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 o=[],s=me(t.competitionIds,this.limitIds);for(let n of s){t.competitionIds=n;let l=`/competitions${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(l+=`&disable_cache=${i}`);let c=await this.fetchWithoutAuth(l,r);o.push(c.data.map(m=>this.competitionBasicRemapper.fromResponse(m)))}return Array.prototype.concat.apply([],o)}else{let o=`/competitions${this.apiSignInUrl}`;return t&&(o+=`${t.constructFilterUrl()}`),e&&(o+=`&disable_cache=${i}`),(await this.fetchWithoutAuth(o,r)).data.map(p=>this.competitionBasicRemapper.fromResponse(p))}};getCompetitionById=async(t,e)=>{let i=`/competitions/${t}${this.apiSignInUrl}`,r="There was a problem with football competition by ID request",o=Date.now();e&&(i+=`&disable_cache=${o}`);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 o=[],s=me(t.teamIds,this.limitIds);for(let n of s){t.teamIds=n;let l=`/teams${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(l+=`disable_cache=${i}`);let c=await this.fetchWithoutAuth(l,r);o.push(c.data.map(m=>this.teamBasicRemapper.fromResponse(m)))}return Array.prototype.concat.apply([],o)}else{let o=new Bt,s=`/teams${this.apiSignInUrl}`;t&&(s+=`${t.constructFilterUrl()}`),e&&(s+=`&disable_cache=${i}`);let p=await this.fetchWithoutAuth(s,r);return o.meta=this.footballMetaRemapper.remapMetaProp(p.meta),o.data=p.data.map(n=>this.teamBasicRemapper.fromResponse(n)),o}};getTeamById=async(t,e)=>{let i="There was a problem with football team by ID request",r=`/teams/${t}${this.apiSignInUrl}`,o=Date.now();e&&(r+=`disable_cache=${o}`);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 o=await this.fetchWithoutAuth(e,i);return o.data?o.data.map(s=>this.teamBasicRemapper.fromResponse(s)):[]};getNextMatchForTeam=async(t,e)=>{let i=`/teams/${t}/next-match${this.apiSignInUrl}`,r=Date.now(),o="There was a problem with next match for team request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,o);return this.matchFullRemapper.fromResponse(s.data)};getPrevMatchForTeam=async(t,e)=>{let i=`/teams/${t}/previous-match${this.apiSignInUrl}`,r=Date.now(),o="There was a problem with previous match for team request";e&&(i+=`disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,o);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 o=[],s=me(t.playerIds,this.limitIds);for(let n of s){t.playerIds=n;let l=`/players${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(l+=`&disable_cache=${i}`);let c=await this.fetchWithoutAuth(l,r);o.push(c.data.map(m=>this.teamBasicRemapper.fromResponse(m)))}return Array.prototype.concat.apply([],o)}else{let o=new Bt,s=`/players${this.apiSignInUrl}`;t&&(s+=`${t.constructFilterUrl()}`),e&&(s+=`&disable_cache=${i}`);let p=await this.fetchWithoutAuth(s,r);return o.meta=this.footballMetaRemapper.remapMetaProp(p.meta),o.data=p.data.map(n=>this.playerBasicRemapper.fromResponse(n)),o}};getPlayerById=async(t,e)=>{let i=`/players/${t}${this.apiSignInUrl}`,r=Date.now(),o="There was a problem with football player by ID request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,o);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(),o="There was a problem with next match for player request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,o);return this.matchFullRemapper.fromResponse(s.data)};getPrevMatchForPlayer=async(t,e)=>{let i=`/players/${t}/previous-match${this.apiSignInUrl}`,r=Date.now(),o="There was a problem with previous match for player request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,o);return this.matchFullRemapper.fromResponse(s.data)};getMatchById=async(t,e)=>{let i=`/matches/${t}${this.apiSignInUrl}`,r=Date.now(),o="There was a problem with match by ID request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,o);return this.matchFullRemapper.fromResponse(s.data)};getMatches=async(t,e)=>{let i=new Bt,r=`/matches${this.apiSignInUrl}`,o=Date.now(),s="There was a problem with football matches request";t&&(r+=`${t.constructFilterUrl()}`),e&&(r+=`&disable_cache=${o}`);let p=await this.fetchWithoutAuth(r,s);return i.meta=this.footballMetaRemapper.remapMetaProp(p.meta),i.data=p.data.map(n=>this.matchBasicRemapper.fromResponse(n)),i};search=async(t,e)=>{let i=`/search${this.apiSignInUrl}${t.constructFilterUrl()}`,r=Date.now(),o="There was a problem with football search request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,o);return this.searchRemapper.fromResponse(s.data)}};var G=(u=>(u.FT_1X2="FT_1X2",u.HT_1X2="HT_1X2",u.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",u.DOUBLE_CHANCE="DOUBLE_CHANCE",u.HT_FT="HT_FT",u.PLAYER_SCORE="PLAYER_SCORE",u.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",u.PLAYER_RED_CARD="PLAYER_RED_CARD",u.RED_CARD_MATCH="RED_CARD_MATCH",u.PENALTY_MATCH="PENALTY_MATCH",u.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",u.CORNERS_MATCH="CORNERS_MATCH",u.CORRECT_SCORE="CORRECT_SCORE",u.CORRECT_SCORE_ADVANCED="CORRECT_SCORE_ADVANCED",u.CORRECT_SCORE_HT="CORRECT_SCORE_HT",u.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",u.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",u.OVER_GOALS_0_5="OVER_GOALS_0_5",u.OVER_GOALS_1_5="OVER_GOALS_1_5",u.OVER_GOALS_2_5="OVER_GOALS_2_5",u.OVER_GOALS_3_5="OVER_GOALS_3_5",u.OVER_GOALS_4_5="OVER_GOALS_4_5",u.OVER_GOALS_5_5="OVER_GOALS_5_5",u.OVER_GOALS_6_5="OVER_GOALS_6_5",u.OVER_CORNERS_6_5="OVER_CORNERS_6_5",u.OVER_CORNERS_7_5="OVER_CORNERS_7_5",u.OVER_CORNERS_8_5="OVER_CORNERS_8_5",u.OVER_CORNERS_9_5="OVER_CORNERS_9_5",u.OVER_CORNERS_10_5="OVER_CORNERS_10_5",u.OVER_CORNERS_11_5="OVER_CORNERS_11_5",u.OVER_CORNERS_12_5="OVER_CORNERS_12_5",u.OVER_CORNERS_13_5="OVER_CORNERS_13_5",u))(G||{}),ya=["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"],Ma=["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"],q=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"],ba=["FT_1X2","HT_1X2","HT_FT","DOUBLE_CHANCE","CORNERS_MATCH","CORRECT_SCORE","CORRECT_SCORE_HT","CORRECT_SCORE_ADVANCED"],be="PLAYER_SCORE_FIRST_GOAL";var Bi=class{id="";achievedAt=""};var kt=class{totalPoints=null;postPoints=null;postsMade=null;reactionPoints=null;reactionCount=null};var we=class{participations=0;points=0};var ft=class{footballCompetitions=[];footballTeams=[]};var Ht=class{predictionsMade=0;correct=0;points=0;breakdown=new ft};var Ut=class{single=new Ht;topX=new we;matchQuiz=new we};var ki=class{overallPercent;byFootballCompetition;byFootballTeam;byFootballMarket};var Hi=class{profileId;tier;points;predictionsMade;successRates=new ki;predictions=new Ut;tiers=[];badges=[];discussions=new kt};var Ui=class{entityId="";entityType="";entitySource="";model=null;predictionsMade=0;correct=0;points=0};var Gi=class{successRatePercent;model=null};var Gt=class{content=null;tags=[];campaign=null};var Vt=class{id=null;profileId=null;property=null;value=null;action=null;context=new Gt;points=0};var Vi=class{meta=new X;data=[new Vt]};var $i=class{remapSingleResponse=t=>{let e=new Vt;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 Vi;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 Hi;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};constructNewRecord=t=>{let e;if(Object.entries(t).length)Object.entries(t).forEach(([i,r])=>{e={...e,[i]:this.remapSuccessRatePercent(r)},G[i]&&delete e[i].model});else return t;return e};remapSuccessRatePercent=t=>{let e=new Gi;return e.successRatePercent=t.success_rate_percent,e};remapPredictionsStats=t=>{let e=new Ut;return e.single=this.remapSinglePredictionsStats(t.single),e.topX=t.top_x,e.matchQuiz=t.match_quiz,e};remapSinglePredictionsStats=t=>{let e=new Ht;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 ft,i=[],r=[];return Object.keys(t).forEach(o=>{let s=new Ui;s.entityId=o,s.entityType=t[o].entity_type,s.entitySource=t[o].entity_source,s.predictionsMade=t[o].predictions_made,s.correct=t[o].correct,s.points=t[o].points,s.entityType==="competition"?i.push(s):s.entityType==="team"&&r.push(s)}),e.footballCompetitions=i,e.footballTeams=r,e}return new ft};remapAchievementsStats=t=>t.map(e=>{let i=new Bi;return i.id=e.id,i.achievedAt=e.achieved_at,i});remapDiscussionStats=t=>{let e=new kt;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}};var $t=class extends S{activityRemapper=null;constructor(t){super(t,L(t.environment,"loyalty")),this.activityRemapper=new $i}createActivity=async t=>{let e=`/activities${this.apiSignInUrl}`,i="There was a problem with creating activity",r="POST",o=await this.fetchWithAuth(e,i,r,t);return this.activityRemapper.remapSingleResponse(o)};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(),o="There was a problem with fetching own activities";t&&(i+=`${t.constructFilterUrl()}`),e&&(i+=`disable_cache=${r}`);let s=await this.fetchWithAuth(i,o);return this.activityRemapper.remapActivitiesResponse(s)};getActivitiesForUser=async(t,e,i)=>{let r=`/users/${t}/activities${this.apiSignInUrl}`,o=Date.now(),s=`There was a problem with fetching activities for user: ${t}`;e&&(r+=`${e.constructFilterUrl()}`),i&&(r+=`disable_cache=${o}`);let p=await this.fetchWithoutAuth(r,s);return this.activityRemapper.remapActivitiesResponse(p)};getStats=async(t,e)=>{let i="",r="",o=null;return t?(i+=R(e)?`/users/${t}/statistics${this.apiSignInUrl}${E()}`:`/users/${t}/statistics${this.apiSignInUrl}`,r=`There was a problem fetching statistics for profile: ${t}`,o=await this.fetchWithoutAuth(i,r)):(i+=`/statistics${this.apiSignInUrl}`,r="There was a problem fetching profile`s statistics",o=await this.fetchWithAuth(i,r)),this.activityRemapper.remapStatsResponse(o.data)}};var Wi=class{id="";source="";type="";favourite=!1};var Ki=class extends Wi{model=null};var ji=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=>{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 o=JSON.parse(JSON.stringify(t.successRates.byFootballCompetition)),s=await this.getEntitiesMap(r.competition,"competition"),p=await this.setSuccessRatesModels(o,s);t.successRates.byFootballCompetition=p,i.single.breakdown.footballCompetitions=this.reconstructBreakdown(i.single.breakdown.footballCompetitions,s)}if(Object.values(r.team).length){let o=JSON.parse(JSON.stringify(t.successRates.byFootballTeam)),s=await this.getEntitiesMap(r.team,"team"),p=await this.setSuccessRatesModels(o,s);t.successRates.byFootballTeam=p,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 o=i.get(r);e={...e,[o.id]:t[r]},e[o.id].model=o}),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(o=>o.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"),o=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),p=[];for(let[n,l]of Object.entries(i))l.forEach((c,m)=>{c.id=s[n][m],p.push(c)});return p.concat(o)}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 o=await this.remapIdsObj(e,this.idSchema,this.native);return t.id=o[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 o=new Ki;return o.id=r.id,o.type=r.type,o.source=r.source,o.favourite=r.favourite,o}):i};remapInterests=async t=>{let i=this.inquiryCustomInterests(t,!1);if(i&&i.length>0){let r=t.filter(s=>s.source.toLocaleUpperCase()!=="CUSTOM"),o=await this.remapInterestsToIdSchema(r);return i.forEach(s=>o.push(s)),o}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 o=t.filter(c=>c.source.toLocaleUpperCase()!=="CUSTOM"),{competitionsMap:s,teamsMap:p,playersMap:n}=await this.getInterestsEntitiesMap(o),l=o.map(c=>{let m=null;if(c.source.toLocaleUpperCase()==="FOOTBALL"){if(c.type==="competition")return m=s.get(c.id),m&&(c.id=m.id),c.model=m,c;if(c.type==="team")return m=p.get(c.id),m&&(c.id=m.id),c.model=m,c;if(c.type==="player")return n?(c.model=n[c.id],c.id=n[c.id].id):c.model=m,c}else return c.model=m,c});return e.push(l),e.flat()}return e};getInterestsEntitiesMap=async t=>{let e=[],i=[],r=[],o=new Map,s=new Map,p=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&&(o=await this.footballFacade.getCompetitionsMapWithNativeIds(e)),i.length&&(s=await this.footballFacade.getTeamsMapWithNativeIds(i)),r.length&&(p=await this.footballFacade.getPlayersMapWithNativeIds(r)),{competitionsMap:o,teamsMap:s,playersMap:p}};remapIdsObj=async(t,e,i)=>await this.idMapping.idMappingFacade.getEntitiesByIds(t,e,i)};var Xi=class{idMapping=null;profileOperations=null;constructor(t,e){this.idMapping=new T(t),this.profileOperations=new ji(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 lt=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 Tt(t),this.activityHttps=new $t(t),this.footballHttps=new Y(t),this.idMapping=new T(t),this.localCache=new k().createLocalCacheInstance(t.idSchema),this.footballFacade=new Ot(t,this.localCache,this.footballHttps,this.idMapping),this.profileFacade=new j(this.localCache,this.profileHttps,this.activityHttps),this.idsRemapper=new Xi(t,this.footballFacade),this.ownProfileBuilder=new Ke(this.idsRemapper,this.localCache,this.profileHttps,this.activityHttps,t.errorHandlingMode),this.profileBuilder=new je(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)=>await this.profileFacade.getByIds(t,e)};var wo=(h=>(h.EN="en",h.BG="bg",h.RO="ro",h.EL="el",h.SK="sk",h.PT="pt",h.SR="sr",h.HU="hu",h.SV="sv",h.ES="es",h.FR="fr",h.NL="nl",h.DE="de",h.IT="it",h))(wo||{});var Yi=class{validate=t=>{let e=this.validateField(t.lang),i=this.generateMessage(e);return{validation:e,message:i}};validateField=t=>{let e=Object.values(wo),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 qi=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"],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 Qi=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 zi=class{validate(t){let e=this.validateField(t.idSchema),i=this.generateMessage(e);return{validation:e,message:i}}validateField=t=>{let e=Object.values(B),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 yt=class{getIdToken=null;logout=null};var Kt=class{text=null;type=null};var Ji=class{validation=null;message=new Kt;getIdToken={validation:null,message:new Kt};logout={validation:null,message:new Kt}};var Zi=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 yt),i=new Ji;if(t){let o=Object.keys(t).filter(s=>!e.includes(s));o.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:"} ${o.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 yt).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 Pe=class{validation;message};var tr=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;errorHandlingMode=null;authProvider={getIdToken:new Pe,logout:new Pe};isValid=!1};var er=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 ir=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 rr=class{validate=t=>{let e=this.checkFieldsForValues(t);return e.isValid=this.containsErrorMessage(e),e};checkFieldsForValues=t=>{let e=new tr,i={apiKey:new Qi,environment:new qi,idSchema:new zi,clientId:new er,lang:new Yi,errorHandlingMode:new ir,authProvider:new Zi};for(let[r,o]of Object.entries(e))r!=="isValid"&&(o=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 jt=class{https=null;idMapping=null;localCache=null;footballFacade=null;constructor(t){this.https=new Y(t),this.idMapping=new T(t),this.localCache=new k().createLocalCacheInstance(t.idSchema),this.footballFacade=new Ot(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 or=class{value=null;playerId=null;playerModel=null};var Xt=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new or;result=null};var ar=class{value=!1;playerId=null};var V=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i,r){this.matchId=t,this.market=e,this.prediction=new ar,this.prediction.value=i,this.prediction.playerId=r}};var Yt=class{settledAt=null;resettledAt=null;status=null;outcome=null;points=0};var sr=class{value=null};var pt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new sr,this.prediction.value=i}};var $=class{value=!1};var qt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new $,this.prediction.value=i}};var Qt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new $,this.prediction.value=i}};var nr=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 V)e.market=t.market,e.prediction=t.prediction.value,e.player_id=t.prediction.playerId;else if(t instanceof qt||t instanceof Qt)e.market=t.market,e.prediction=t.prediction.value;else if(t instanceof pt){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=[],o=null,s=[];t.length>1&&t.sort((n,l)=>n.match_id.localeCompare(l.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 p=await this.matchFacade.getMatchesMapWithNativeIds(i);r.sort((n,l)=>n.localeCompare(l)),r&&r.length>0&&!r.includes(e)&&(o=await this.playerFacade.getPlayersMapWithNativeIds(r));for(let n of t){let l=new Xt;n.target?l.market=this.predictorService.convertMarketForResponseModel(n.market,n.target):l.market=n.market,l.matchId=p[n.match_id].id,l.matchType=n.match_type,l.matchModel=p?p[n.match_id]:null,delete l.matchModel.availableMarkets,n.goals_home!==void 0&&n.goals_away!==void 0?l.prediction.value=n.goals_home.toString()+":"+n.goals_away.toString():l.prediction.value=n.prediction,l.prediction.playerId=n.player_id?n.player_id:null,l.prediction.playerId&&l.prediction.playerId!==e&&(l.prediction.playerModel=o[n.player_id],l.prediction.playerId=o[n.player_id].id),l.result=this.remapResult(n.result),s.push(l)}return s};remapResult=t=>{let e=new Yt;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 Q=class{goldenGoal=null};var Fe=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new Q;points=null;createdAt=null;updatedAt=null};var I=class{no=0;yes=0};var lr=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new I;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new I;penaltyMatch=new I;playerScoreFirstGoal={};cornersMatch={};correctScore={};correctScoreHalfTime={};correctScoreAdvanced={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new I;overOnePointFiveGoals=new I;overTwoPointFiveGoals=new I;overThreePointFiveGoals=new I;overFourPointFiveGoals=new I;overFivePointFiveGoals=new I;overSixPointFiveGoals=new I;overSixPointFiveCorners=new I;overSevenPointFiveCorners=new I;overEightPointFiveCorners=new I;overNinePointFiveCorners=new I;overTenPointFiveCorners=new I;overElevenPointFiveCorners=new I;overTwelvePointFiveCorners=new I;overThirteenPointFiveCorners=new I};var z=class{timeTiebreaker=!1};var ct=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new z;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 Q};var Mt=class{userId=null;points=null;results=[];tiebreaker=null};var Io=(o=>(o.ACTIVE="ACTIVE",o.WON="WON",o.LOST="LOST",o.PARTIALLY_WON="PARTIALLY_WON",o.CANCELED="CANCELED",o))(Io||{}),xo=["WON","LOST","PARTIALLY_WON","CANCELED"];var A=class{limit=null;startAfter=null;status=null;type=null;matchIds=null;constructor(t){this.limit=t.limit?t.limit:null,this.startAfter=t.startAfter?t.startAfter:null,this.status=t.status?t.status:null,this.type=t.type?t.type:null,this.matchIds=t.matchIds?t.matchIds:null}constructFiltersUrl=()=>{let t="",e=!1;return this.status&&(e=Object.values(Io).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&&(t+="&",t+=`match_ids=${this.matchIds.join(",")}`),t}};var zt=class{limit;startAfter;constructor(t){this.limit=t.limit?t.limit:null,this.startAfter=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 pr=(s=>(s.OPEN="OPEN",s.LIVE="LIVE",s.PENDING="PENDING",s.CANCELED="CANCELED",s.CLOSED="CLOSED",s.SETTLED="SETTLED",s))(pr||{});var W=class extends zt{status=null;type=null;gameIds=null;sortOrder=null;constructor(t){super(t),this.status=t.status?t.status:null,this.type=t.type?t.type:null,this.gameIds=t.gameIds?t.gameIds:null,this.sortOrder=t.sortOrder?t.sortOrder:null}constructFiltersUrl=()=>{let t=super.constructMainFiltersUrl();return this.status&&Object.values(pr).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 Jt=class{main=null;cover=null;mobile=null};var tt=class{id=null;title=null;description=null;type=null;status=null;scheduleOpenAt=null;predictionsCutoff=null;fixtures=[];tiebreaker=new z;participantsCount=0;related=null;excludedProfileIds=null;rules=null;flags=null;images=new Jt;createdAt=null;updatedAt=null};var et=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new z;predictionId=null;participantsCount=0;related=null;excludedProfileIds=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;images=null;scheduleOpenAt=null};var Zt=class extends tt{adContent=null;labels=null;customFields=null};var J=class{footballHttps=null;idMapping=null;matchFacade=null;playerFacade=null;profileNamespace=null;constructor(t,e){this.footballHttps=new Y(t),this.idMapping=e,this.matchFacade=new st(t,this.footballHttps,e),this.playerFacade=new at(t,this.footballHttps,e),this.profileNamespace=new lt(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=ut(t),o=(await this.idMapping.getEntityIdsBySchemaId(i,"player","native")).player;return i.forEach((s,p)=>e[s]=o[p]),e};remapPlayerIdToIdSchema=async t=>{let e=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"],i=[];for(let[o,s]of Object.entries(t))if(e.includes(o))for(let p of Object.keys(s))p!=="NOBODY"&&p!=="OWN_GOAL"&&i.push(p);if(!i.length)return t;let r=await this.playerFacade.getPlayersMapWithNativeIds(i);for(let[o,s]of Object.entries(t))if(e.includes(o))for(let p of Object.keys(s))p!=="NOBODY"&&p!=="OWN_GOAL"&&(s[r[p].id]=s[p],s[r[p].id].model=r[p],this.idMapping.idSchema!=="native"&&delete s[p]);return t};convertMarketForResponseModel=(t,e)=>{let i=e.toString();return t+"_"+i};getMarketSummary=async(t,e,i)=>{let r=Ko.get(e),o={};if(o.matchId=t.matchId,o.matchType=t.matchType,Object.keys(t.predictions).includes(r))o[r]=t.predictions[r];else throw new Error("You have passed invalid market");if(q.includes(e)&&i){let p="";if(i!=="OWN_GOAL"&&i!=="NOBODY"&&(p=(await this.idMapping.idMappingFacade.getEntitiesByIds({player:[i]},this.idMapping.idSchema,"native")).player[0]),p&&o[r][p]){let n=await this.playerFacade.getPlayersMapWithNativeIds([p]);return o[r][p].model=n[p],o[r][p]}else return p?(o[r][p]=new I,o[r][p]):o[r][i]}else if(q.includes(e)&&!i){let p=Object.keys(o[r]).filter(l=>l!=="NOBODY"&&l!=="OWN_GOAL"),n=p.length?await this.playerFacade.getPlayersMapWithNativeIds(p):{};Object.keys(n).length&&Object.keys(o[r]).forEach(l=>{l!=="NOBODY"&&l!=="OWN_GOAL"&&(o[r][n[l].id]=o[r][l],o[r][n[l].id].model=n[l],this.idMapping.idSchema!=="native"&&delete o[r][l])})}return o};remapCompetitionsFromConfig=async t=>{if(t instanceof Ct){let e={competition:t.fullCoverageCompetitions},i={competition:t.successRateScopes.competitions},r={team:t.successRateScopes.teams},o=await this.idMapping.idMappingFacade.getEntitiesByIds(e,"native",this.idMapping.idSchema),s=await this.idMapping.idMappingFacade.getEntitiesByIds(i,"native",this.idMapping.idSchema),p=await this.idMapping.idMappingFacade.getEntitiesByIds(r,"native",this.idMapping.idSchema);return t.fullCoverageCompetitions=o.competition,t.successRateScopes.competitions=s.competition,t.successRateScopes.teams=p.team,t}if(t instanceof St||t instanceof vt){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 tt||r instanceof ct||r instanceof et||r instanceof Zt?(r.fixtures.forEach(o=>e.push(o.matchId)),r instanceof et&&r.fixtures.forEach(o=>{o.prediction.playerId&&o.prediction.playerId!=="OWN_GOAL"&&i.push(o.prediction.playerId)})):r instanceof Mt&&r.results.forEach(o=>e.push(o.matchId))}),await this.refactorResponseArrModel(t,e,i)}else return t;else return await this.refactorResponseObjModel(t)};refactorResponseArrModel=async(t,e,i)=>{let r=[],o=await this.matchFacade.getMatchesMapWithNativeIds(e),s={};return i.length>0&&(s=await this.playerFacade.getPlayersMapWithNativeIds(i)),t.data.forEach(p=>{p instanceof tt||p instanceof ct||p instanceof et?(p.fixtures.forEach(n=>{this.handleMatchModel(o,n),p instanceof et&&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(p)):p instanceof Mt&&(p.results.forEach(n=>{n.matchModel=o[n.matchId],delete n.matchModel.availableMarkets,n.matchId=n.matchModel.id}),r.push(p))}),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(o=>i.push(o.predictionsCutoff)),t.data.sort((o,s)=>{let[p,n]=[o.predictionsCutoff,s.predictionsCutoff].map(l=>Math.abs(new Date(l)-e));return p-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 A(i),i};initGameFilters=(t,e,i)=>{if(e&&i)return e.type=t,e.gameIds=i,e=new W(e),e;if(e&&!i)return e.type=t,e=new W(e),e;if(!e&&i){let r={type:t,gameIds:i};return r=new W(r),r}else{let r={type:t};return r=new W(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((o,s)=>{r.fixtures[s].goals_home!==void 0&&r.fixtures[s].goals_away!==void 0?o.prediction.value=r.fixtures[s].goals_home+":"+r.fixtures[s].goals_away:o.prediction.value=r.fixtures[s].prediction,r.fixtures[s].player_id?o.prediction.playerId=r.fixtures[s].player_id:r.fixtures[s].target&&(o.prediction.target=r.fixtures[s].target),o.prediction.result=this.remapResult(r.fixtures[s].result)}),i.predictionsMadeAt=r.created_at,i.points=r.points,i instanceof ct&&(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 Yt;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 A(t));break;case"current":if(t)this.deleteUnexpectedProperties(t),t.status=["ACTIVE"],t=new A(t);else{let r={status:["ACTIVE"]};t=new A(r)}break;case"past":if(t)this.deleteUnexpectedProperties(t),t.status=xo,t=new A(t);else{let r={status:xo};t=new A(r)}break;case"matches":if(t)this.deleteUnexpectedProperties(t),t.matchIds=i,t=new A(t);else{let r={matchIds:i};t=new A(r)}break}return t};completeGameMarketResults=async(t,e)=>{switch(e){case"MATCH_QUIZ":let i={},r=t.results[0].matchId,o=t.results.map(l=>q.includes(l.market)&&!l.result.includes("OWN_GOAL")?[...l.result]:[]).flat(),s=await this.matchFacade.getMatchesMapWithNativeIds([r]);return o.length&&(i=await this.playerFacade.getPlayersMapWithNativeIds(o)),t.results=t.results.map(l=>{if(l.matchModel=s[l.matchId]?s[l.matchId]:null,l.playerModels&&Object.keys(i).length&&l.result.forEach(m=>{let d=i[m];l.playerModels.push(d)}),this.idMapping.idSchema!=="native"&&(this.remapMatchIdForResultsMarkets(s,l),l.playerModels&&Object.keys(i).length)){let c=l.result;l.result=c.map(m=>i[m].id)}return l}),t;case"TOP_X":let p=t.results.map(l=>l.matchId),n=await this.matchFacade.getMatchesMapWithNativeIds(p);if(t.results=t.results.map(l=>(l.matchModel=n[l.matchId]?n[l.matchId]:null,this.idMapping.idSchema!=="native"&&this.remapMatchIdForResultsMarkets(n,l),l)),t.tieBreakers.goldenGoals.length){let l=t.tieBreakers.goldenGoals.map(m=>m.playerId),c=await this.playerFacade.getPlayersMapWithNativeIds(l);t.tieBreakers.goldenGoals=t.tieBreakers.goldenGoals.map(m=>(m.matchModel=n[m.matchId],m.playerModel=c[m.playerId],this.idMapping.idSchema!=="native"&&(m.matchId=n[m.matchId].id,m.playerId=c[m.playerId].id),m))}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 o=i.filter(s=>s.id===r.profileId)[0];delete o.interests,r.profileModel=o})}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[v[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[v[this.idMapping.idSchema]]})};deleteUnexpectedProperties=t=>(t.status&&(console.warn(Co.UNEXPECTED_STATUS_PROP),delete t.status),t.type&&(console.warn(Co.UNEXPECTED_TYPE_PROP),delete t.type),t)};var te=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(t){this.gameInstanceId=t.gameInstanceId,t.fixtures.forEach(e=>this.fixtures.push(new pt(e.matchId,e.market,e.prediction.value))),this.tiebreaker=t.tiebreaker?t.tiebreaker:null}};var ee=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(t,e){this.footballHttps=new Y(t),this.matchFacade=new st(t,this.footballHttps,e),this.playerFacade=new at(t,this.footballHttps,e),this.predictorService=new J(t,e),this.fixturesRemapper=new nr(this.matchFacade,this.playerFacade,this.predictorService)}remapRequestBody=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=[],o={},s=[];t.forEach(n=>{n.fixtures.forEach(l=>{i.push(l.match_id),l.player_id&&l.player_id!==e&&r.push(l.player_id)})});let p=await this.matchFacade.getMatchesMapWithNativeIds(i);return r.length>0&&(o=await this.playerFacade.getPlayersMapWithNativeIds(r)),t.forEach(n=>{let l=new Fe,c=[];l.id=n.id,l.gameInstanceId=n.game_instance_id,l.gameType=n.game_type,l.wager=n.wager,l.totalFixtures=n.total_fixtures,l.settledFixtures=n.settled_fixtures,l.userId=n.user_id,n.fixtures.forEach(m=>{let d=new Xt;m.target?d.market=this.predictorService.convertMarketForResponseModel(m.market,m.target):d.market=m.market,d.matchId=p[m.match_id].id,d.matchType=m.match_type,d.matchModel=p[m.match_id],delete d.matchModel.availableMarkets,m.goals_home!==void 0&&m.goals_away!==void 0?d.prediction.value=m.goals_home.toString()+":"+m.goals_away.toString():d.prediction.value=m.prediction,d.prediction.playerId=m.player_id?m.player_id:null,d.prediction.playerId&&d.prediction.playerId!==e&&(d.prediction.playerModel=o[d.prediction.playerId],d.prediction.playerId=o[d.prediction.playerId].id),d.result=this.fixturesRemapper.remapResult(m.result),c.push(d)}),l.fixtures=c,l.status=n.status,n.tiebreaker?l.tiebreaker.goldenGoal=n.tiebreaker.golden_goal:l.tiebreaker=null,l.points=n.points,l.createdAt=n.created_at,l.updatedAt=n.updated_at,s.push(l)}),s}return t};remapResponseObjBody=async t=>{let e=new Fe;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.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 lr;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 cr=class{matchId=null;matchType=null;predictions=null};var mr=class{remapPredictions=null;constructor(t,e){this.remapPredictions=new ee(t,e)}remapResponse=t=>{let e=new cr;return e.matchId=t.match_id,e.matchType=t.match_type,e.predictions=this.remapPredictions.remapPredictionModel(t.predictions),e}};var dr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new U};var ur=class{value=null;target=null;playerId=null;playerModel=null;result=null};var hr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new U;prediction=new ur};var fr=class{value=null;result=null};var gr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new U;prediction=new fr};var yr=class{matchId=null;matchModel=null;outcome=null};var Mr=class{gameId=null;results=null;tieBreakers=null};var ie=class{entityId=null;entityType=null};var br=class{contestId="";contestType="GAME";contestModel=null;description="";userList=[]};var wr=class{position="";profileId="";profileModel=null;note="";tags=[]};var Ir=class{remapPaginatedGames=t=>{let e=new F;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 tt;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.images=t.images,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapGameByIdResponse=t=>{let e=new Zt;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.images=t.images,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapFixturesResponse=t=>{let e=new dr;return e.matchId=t.match_id,e.matchType=t.match_type,e.market=t.market,e.matchStatus.type=t.match_status.type,e.matchStatus.subType=t.match_status.sub_type,e};remapPaginatedUserTopXEditions=t=>{let e=new F;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 ct;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.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapTopXFixturesResponse=t=>{let e=new gr;return e.matchId=t.match_id,e.matchType=t.match_type,e.market=t.market,e.matchStatus.type=t.match_status.type,e.matchStatus.subType=t.match_status.sub_type,e};remapPaginatedUserMathQuizEditions=t=>{let e=new F;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 et;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.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapMatchQuizFixturesResponse=t=>{let e=new hr;return e.matchId=t.match_id,e.matchType=t.match_type,e.market=t.market,e.matchStatus.type=t.match_status.type,e.matchStatus.subType=t.match_status.sub_type,e};remapPaginatedGameResults=t=>{let e=new F;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 Mt;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 Mr;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 br;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 wr;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 U;return e.type=t.type,e.subType=t.sub_type,e};remapMarketResult=(t,e)=>{if(ba.includes(t))return e[0];if(q.includes(t))return e;if(e[0]==="true")return!0;if(e[0]==="false")return!1};deleteUnusefulField=t=>((!q.includes(t.market)||this.isPlayerMarketWithNoResult(t.market,t.result))&&delete t.playerModels,t);isPlayerMarketWithNoResult=(t,e)=>q.includes(t)&&e.length===0;remapResults=t=>{let e=new yr;return e.matchId=t.match_id,e.outcome=t.outcome,e};remapTiebreaker=t=>{let e=new Q;return e.goldenGoal=t.golden_goal,e};remapTimeTiebreaker=t=>{let e=new z;return e.timeTiebreaker=t,e};remapRelated=t=>t.map(e=>{let i=new ie;return i.entityId=e.entity_id,i.entityType=e.entity_type,i})};var Pr=class{remapMetaData=t=>{let e=new It;return e.pagination.nextPageStartsAfter=t.pagination.next_page_starts_after,e.pagination.itemsPerPage=t.pagination.items_per_page,e}};var Z=class extends S{predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;metaRemapper=null;constructor(t,e){super(t,L(t.environment,"predictor")),this.predictionRemapper=new ee(t,e),this.matchSummaryRemapper=new mr(t,e),this.gamesRemapper=new Ir,this.metaRemapper=new Pr}makeFootballPrediction=async t=>{let e=`/predictions${this.apiSignInUrl}`,i="There was a problem making POST request",r="POST",o=await this.fetchWithAuth(e,i,r,this.predictionRemapper.remapRequestBody(t));return await this.predictionRemapper.remapResponseObjBody(o)};getMatchSummary=async(t,e)=>{let i=R(e)?`/predictions/summary/${t}${this.apiSignInUrl}${E()}`:`/predictions/summary/${t}${this.apiSignInUrl}`,r=`There was a problem fetching predictions for match: ${t}`,o=await this.fetchWithoutAuth(i,r);return this.matchSummaryRemapper.remapResponse(o)};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 F,i=`/predictions${this.apiSignInUrl}`,r="There was a problem fetching own predictions";t&&(i+=`${t.constructFiltersUrl()}`);let o=await this.fetchWithAuth(i,r);return e.meta=this.metaRemapper.remapMetaData(o.meta),e.data=await this.predictionRemapper.remapResponseArrayBody(o.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 F,o=R(e)?`/predictions/users/${t}${this.apiSignInUrl}${E()}`:`/predictions/users/${t}${this.apiSignInUrl}`,s=`There was a problem fetching predictions for user: ${t}`;i&&(o+=`${i.constructFiltersUrl()}`);let p=await this.fetchWithoutAuth(o,s);return r.meta=this.metaRemapper.remapMetaData(p.meta),r.data=await this.predictionRemapper.remapResponseArrayBody(p.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=R(e)?`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}${E()}`:`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}`,r="There was a problem fetching the games list",o=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapPaginatedGames(o)};getGameById=async(t,e)=>{let i=R(e)?`/games/${t}${this.apiSignInUrl}${E()}`:`/games/${t}${this.apiSignInUrl}`,r=`There was a problem fetching the following game: ${t}`,o=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapGameByIdResponse(o)};getGamePredictions=async(t,e,i)=>{let r=new F,o=R(e)?`/games/${t}/predictions${this.apiSignInUrl}${E()}`:`/games/${t}/predictions${this.apiSignInUrl}`,s=`There was a problem fetching the predictions for game: ${t}`;i&&(o+=`${i.constructFiltersUrl()}`);let p=await this.fetchWithoutAuth(o,s);return r.meta=this.metaRemapper.remapMetaData(p.meta),r.data=await this.predictionRemapper.remapResponseArrayBody(p.data),r};getUserGameEditions=async(t,e)=>{let i=null,r=R(e)?`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}${E()}`:`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}`,o="There was a problem fetching the games list",s=await this.fetchWithoutAuth(r,o);return s.data.forEach(p=>{p.type==="TOP_X"?i=this.gamesRemapper.remapPaginatedUserTopXEditions(s):p.type==="MATCH_QUIZ"&&(i=this.gamesRemapper.remapPaginatedUserMathQuizEditions(s))}),i};getGameResults=async(t,e,i)=>{let r=R(e)?`/games/${t}/results/${this.apiSignInUrl}${E()}`:`/games/${t}/results/${this.apiSignInUrl}`,o=`There was a problem fetching the results for the following game: ${t}`;i&&(r+=`${i.constructMainFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,o);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}`;R(e)&&(i+=`${E()}`);let o=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapGameMarketsResults(o.data)};getContestWinners=async t=>{let e=`/winners/${this.apiSignInUrl}&contest_id=${t}`,i=`There was a problem fetching winners for the following game: ${t}`,r=await this.fetchWithoutAuth(e,i);return this.gamesRemapper.remapContestWinners(r)};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]}};var re=class{gameInstanceId=null;fixtures=null};var Do=(i=>(i.ONE="1",i.X="x",i.TWO="2",i))(Do||{}),No=(i=>(i.ONE_X="1x",i.X_TWO="x2",i.ONE_TWO="12",i))(No||{}),Bo=(l=>(l.ONE_ONE="1/1",l.ONE_X="1/x",l.ONE_TWO="1/2",l.X_ONE="x/1",l.X_X="x/x",l.X_TWO="x/2",l.TWO_ONE="2/1",l.TWO_X="2/x",l.TWO_TWO="2/2",l))(Bo||{});var Fr=class{matchId=null;market="BOTH_TEAMS_SCORE";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new $,this.prediction.value=e}};var Tr=class{value};var _r=class{matchId=null;market="CORNERS_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new Tr,this.prediction.value=e}};var Rr=class{value=null};var Er=class{matchId=null;market="DOUBLE_CHANCE";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new Rr,this.prediction.value=e}};var vr=class{value=null};var Sr=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new vr,this.prediction.value=i}};var Cr=class{value=null};var Ar=class{matchId=null;market="HT_FT";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new Cr,this.prediction.value=e}};var Or=class{matchId=null;market="PENALTY_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new $,this.prediction.value=e}};var Lr=class{matchId=null;market="RED_CARD_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new $,this.prediction.value=e}};var mt=class{errorHandlingMode=null;constructor(t){this.errorHandlingMode=t}validateBodyFields=(t,e)=>{let i=Object.keys(e),r=Object.keys(new re);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 p="tiebreaker";i.includes(p)&&s.tiebreaker&&this.validateTiebreaker(s.tiebreaker),i.forEach(n=>{n!=="tiebreaker"&&!r.includes(n)&&this.throwInvalidParamException([n])});break}let o=r.filter(s=>!i.includes(s));return o.length&&this.throwMissingFieldsException("game prediction body",o),e.fixtures.forEach(s=>{this.validateFixtureFields(s)}),e};validateFixture=(t,e,i,r)=>{this.validateMarket(e);let o=Object.values(Do),s=Object.values(Bo),p=Object.values(No);if(e==="FT_1X2"||e==="HT_1X2"){if(o.includes(i))return new Sr(t,e,i)}else if(e==="HT_FT"){if(s.includes(i))return new Ar(t,i)}else if(e==="DOUBLE_CHANCE"){if(p.includes(i))return new Er(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 pt(t,e,i)}else if(e==="CORNERS_MATCH"){if(typeof i=="number")return new _r(t,i)}else if(e==="BOTH_TEAMS_SCORE"){if(this.isPredictionBoolean(i))return new Fr(t,i)}else if(e==="RED_CARD_MATCH"){if(this.isPredictionBoolean(i))return new Lr(t,i)}else if(e==="PENALTY_MATCH"){if(this.isPredictionBoolean(i))return new Or(t,i)}else if(q.includes(e)){let n="OWN_GOAL";if(this.validatePlayerId(e,r),e===be&&this.isPredictionBoolean(i)){let l=r&&r===n?n:r;return new V(t,e,i,l)}if(r&&this.isPredictionBoolean(i))return new V(t,e,i,r)}else if(ya.includes(e)){if(this.isPredictionBoolean(i))return new Qt(t,e,i)}else if(Ma.includes(e)&&this.isPredictionBoolean(i))return new qt(t,e,i);this.throwInvalidPredictionException(i,e)};validateFixtureFields=t=>{let e=Object.keys(t);e.forEach(r=>{So.includes(r)||this.throwInvalidParamException([r])});let i=So.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 Q)[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){q.includes(t)&&r.push("playerId");let o=i.filter(s=>!r.includes(s));o.length&&this.throwInvalidParamException(o)}}else this.throwInvalidType("prediction","object")};validatePlayerId=(t,e)=>{let i="playerId";t!==be&&(e||this.throwInvalidParamException([i]),typeof e!="string"&&this.throwInvalidType(i,"string"))};validateMarket=t=>{Object.values(G).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=jo(t,e);throw this.errorHandlingMode==="default"?new b(400,"INVALID_PREDICTION",i):new y(400,"INVALID_TYPE",i)};throwInvalidMarketException=(t,e)=>{let i=null;throw e&&e==="TOP_X"?i=Xo(t):i=ho(t),this.errorHandlingMode==="default"?new b(400,"INVALID_MARKET",i):new y(400,"INVALID_TYPE",i)};throwInvalidParamException=t=>{let e=Yo(t);throw this.errorHandlingMode==="default"?new b(400,"INVALID_FIELD",e):new y(400,"INVALID_TYPE",e)};throwMissingFieldsException=(t,e)=>{let i=qo(t,e);throw this.errorHandlingMode==="default"?new b(400,"INVALID_FIELD",i):new y(400,"INVALID_TYPE",i)};throwInvalidType=(t,e)=>{let i=Qo(t,e);throw this.errorHandlingMode==="default"?new b(400,"INVALID_TYPE",i):new y(400,"INVALID_TYPE",i)}};var xr=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 mt(t.errorHandlingMode),this.predictorService=new J(t,r)}makeFootballPrediction=async(t,e,i,r)=>{let o=this.predictorValidator.validateFixture(t,e,i,r),s=new re;if(this.idMapping.idSchema!=="native"){let p=o.matchId,n="",l=await this.predictorService.remapMatchIdToNative([p]);if(o.matchId=l[0],this.errorHandlingMode==="default"&&!o.matchId)throw new b(400,"INVALID_FIELD","Match id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&!o.matchId)throw new y(400,"INVALID_FIELD","Match id is invalid!");if(o instanceof V&&o.prediction.playerId!=="OWN_GOAL"){if(o.prediction.playerId&&(n=o.prediction.playerId,o.prediction.playerId=await this.predictorService.remapPlayerIdToNative([n])),this.errorHandlingMode==="default"&&o.market!==be&&!o.prediction.playerId)throw new b(400,"INVALID_FIELD","Player id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&o.market!==be&&!o.prediction.playerId)throw new y(400,"INVALID_FIELD","Player id is invalid!")}s.fixtures=[o];let c=await this.predictorHttps.makeFootballPrediction(s);return c.fixtures.forEach(m=>{m.prediction.playerId&&m.prediction.playerId!=="OWN_GOAL"&&(m.prediction.playerId=n),m.matchId=p}),c}else return s.fixtures=[o],await this.predictorHttps.makeFootballPrediction(s)};getMatchSummary=async(t,e)=>{let i=await this.getMatchSummaryBase(t,e),r=JSON.parse(JSON.stringify(i.predictions)),o=await this.predictorService.remapPlayerIdToIdSchema(r);return i.predictions=o,i};getMarketSummary=async(t,e,i,r)=>{try{let o=await this.getMatchSummaryBase(t,r);return await this.predictorService.getMarketSummary(o,e,i)}catch(o){throw o}};getMatchSummaryBase=async(t,e)=>{if(this.idMapping.idSchema!=="native"){let r=(await this.predictorService.remapMatchIdToNative([t]))[0],o=await this.predictorHttps.getMatchSummary(r,e);return o.matchId=t,o}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 b(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();if(this.errorHandlingMode==="standard"&&this.predictorService.areIdsExceeded(t))throw new y(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 b(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();if(this.errorHandlingMode==="standard"&&this.predictorService.areIdsExceeded(e))throw new y(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.");this.idMapping.idSchema!=="native"&&(e=await this.predictorService.remapMatchIdToNative([...e]));let o=this.predictorService.initPredictionsFilters(i,"matches",e);return await this.predictorHttps.getUserPredictions(t,r,o)};getPredictionById=async t=>await this.predictorHttps.getPredictionById(t)};var Dr=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(t){this.idMapping=new T(t),this.predictorHttps=new Z(t,this.idMapping),this.clientHttps=new H(t),this.predictorFacade=new xr(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)};var Nr=class{rankType=null;fromDate=null;toDate=null;pagination=new nt};var oe=class{position=null;profileId=null;profileModel=null;points=null;predictionsMade=null};var Br=class{remapResponse=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapData(t.data),t);remapMeta=t=>{let e=new Nr;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};remapData=t=>{let e=[];return t.forEach(i=>{let r=new oe;r.position=i.position,r.profileId=i.profile_id,r.points=i.points,r.predictionsMade=i.predictions_made,e.push(r)}),e}};var kr=class extends oe{id=null;rankType=null;model=null;gameType=null};var Hr=class{remapRankings=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapData(t.data),t);remapMeta=t=>{let e=new X;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 kr;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}};var Ur=class{flags="";status="";type="";activeFrom="";activeTo="";createdFrom="";createdTo="";updatedFrom="";updatedTo=""};var Gr=class{pagination=new nt;filters=new Ur};var ae=class{id=null;name=null;description=null;type=null;fromDate=null;toDate=null;markets=[];teamIds=[];matchIds=[];gameIds=[];gameTypes=[];competitionIds=[];excludedProfileIds=[];rules=null;flags=null;images=new Jt;status=null;automaticallyChangeStatus=!0;createdAt=null;updatedAt=null;related=null};var Vr=class extends ae{labels=null;customFields=null;adContent=null};var $r=class{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.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.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 Vr;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.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.adContent=t.ad_content,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapMeta=t=>{let e=new Gr;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 ie;return i.entityId=e.entity_id,i.entityType=e.entity_type,i})};var Wr=class{position=null;points=null;predictionsMade=null;profileId=null;profileModel=null;successRatePercent=null};var Kr=class{remapHighestSuccessRate=t=>t.map(e=>{let i=new Wr;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 jr=class extends S{templateRemapper=null;leaderboardRemapper=null;rankingsRemapper=null;highestSuccessRateRemapper=null;constructor(t){super(t,L(t.environment,"loyalty")),this.templateRemapper=new $r,this.leaderboardRemapper=new Br,this.rankingsRemapper=new Hr,this.highestSuccessRateRemapper=new Kr}getTemplates=async(t,e)=>{let i=t?`/leaderboard/templates/${this.apiSignInUrl}${t.constructFiltersUrl()}`:`/leaderboard/templates/${this.apiSignInUrl}`;i+=R(e)?E():"";let r="There was a problem fetching the list of templates",o=await this.fetchWithoutAuth(i,r),s=JSON.parse(JSON.stringify(o));return s.meta=this.templateRemapper.remapMeta(o.meta),s.data=this.templateRemapper.remapResponse(o.data),s};getTemplateById=async(t,e)=>{let i=R(e)?`/leaderboard/templates/${t}${this.apiSignInUrl}${E()}`:`/leaderboard/templates/${t}${this.apiSignInUrl}`,r=`There was a problem requesting the following template: ${t}`,o=await this.fetchWithoutAuth(i,r);return this.templateRemapper.remapResponseId(o.data)};getLeaderboard=async(t,e,i)=>{let r=R(e)?`/leaderboard/${t}/${this.apiSignInUrl}${E()}`:`/leaderboard/${t}/${this.apiSignInUrl}`,o=`There was a problem fetching the leaderboard for the following template: ${t}`;i&&(r+=`${i.constructFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,o),p=JSON.parse(JSON.stringify(s));return this.leaderboardRemapper.remapResponse(p)};getLeaderboardForGame=async(t,e,i)=>{let r=R(e)?`/leaderboard/games/${t}/${this.apiSignInUrl}${E()}`:`/leaderboard/games/${t}/${this.apiSignInUrl}`,o=`There was a problem fetching the leaderboard for the following game: ${t}`;i&&(r+=`${i.constructFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,o),p=JSON.parse(JSON.stringify(s));return this.leaderboardRemapper.remapResponse(p)};getUserRankings=async(t,e,i)=>{let r=`/leaderboard/users/${t}/rankings/${this.apiSignInUrl}`,o=`There was a problem fetching the rankings for the following user: ${t}`;e&&(r+=`${e.constructFiltersUrl()}`),R(i)&&(r+=`${E()}`);let s=await this.fetchWithoutAuth(r,o);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()}`),R(e)&&(i+=`${E()}`);let o=await this.fetchWithoutAuth(i,r);return this.highestSuccessRateRemapper.remapHighestSuccessRate(o.data)};getEntitiesFollows=async(t,e)=>{let i=R(e)?`/statistics/follows${this.apiSignInUrl}${E()}`:`/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}};var Xr=class{general;predictor;topX;matchQuiz};var se=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 Yr=class extends se{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 qr=class{idMappingService=null;profileNamespace=null;footballNamespace=null;errorHandlingMode=null;constructor(t){this.idMappingService=new T(t),this.profileNamespace=new lt(t),this.footballNamespace=new jt(t),this.errorHandlingMode=t.errorHandlingMode}remapTemplatesIds=async t=>{if(t.length>0){let e=[],i=[],r=[],o=[],s=[],p=[];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},l=await this.idMappingService.idMappingFacade.getEntitiesByIds(n,"native",this.idMappingService.idSchema);return i=[...l.team],o=[...l.match],p=[...l.competition],t.forEach(c=>{c.teamIds&&c.teamIds.length>0?c.teamIds=c.teamIds.map(m=>m=l.team.shift()):c.matchIds&&c.matchIds.length>0?c.matchIds=c.matchIds.map(m=>m=l.match.shift()):c.competitionIds&&c.competitionIds.length>0&&(c.competitionIds=c.competitionIds.map(m=>m=l.competition.shift()))}),t}return t};addProfileModelToLeaderboad=async t=>{if(t.length>0){let e=[],i=t.map(o=>o.profileId);if(!i.length)return t;let r=await this.profileNamespace.getByIds(i);return t.forEach(o=>{r.forEach(s=>{s.id===o.profileId&&(delete s.interests,o.profileModel=s)}),o.profileModel||(o.profileModel=null),e.push(o)}),e}return t};buildClientBadges=t=>{let e=new Xr;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};initFilters=(t,e)=>{switch(e){case"loyalty":t&&(t=new se(t));break;case"rankings":t&&(t=new Yr(t));break}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(o=>{o.id===r.profileId&&(delete o.interests,r.profileModel=o)}),r))};extractRankingsIdsMap=t=>{let e=[],i=[],r=[];return t.forEach(o=>{o.rankType==="GAME"&&o.gameType==="TOP_X"?e.push(o.id):o.rankType==="GAME"&&o.gameType==="MATCH_QUIZ"?i.push(o.id):o.rankType==="TEMPLATE"&&r.push(o.id)}),[e,i,r]};setModelsForUserRankings=(t,e,i,r)=>(r.data.forEach(o=>{o.gameType==="MATCH_QUIZ"&&e?o.model=e.filter(s=>s.id===o.id)[0]:o.gameType==="TOP_X"&&t?o.model=t.filter(s=>s.id===o.id)[0]:o.rankType==="TEMPLATE"&&i&&(o.model=i.filter(s=>s.id===o.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 o=i.filter(s=>s.id===r.profileId)[0];delete o.interests,r.profileModel=o})}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 b(400,"invalid_filters","At least one of footballCompetitions, footballTeams or footballPlayers properties should be provided for filters."):new y(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 b(400,"EXCEEDED_LENGTH","Maximum length per entity should be 24 or less."):new y(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 o=await this.idMappingService.idMappingFacade.getEntitiesByIds(r,this.idMappingService.idSchema,"native");return Object.keys(o).forEach(s=>{s==="competition"?i.footballCompetitions=o[s]:s==="team"?i.footballTeams=o[s]:s==="player"&&(i.footballPlayers=o[s])}),i};addModelsToEntitiesFollows=async t=>{let e=[],i="fb:c:",r=new Map,o=[],s="fb:t:",p=new Map,n=[],l="fb:p:",c=null;return t.breakdown.forEach(m=>{m.id.includes(i)?e.push(m.id):m.id.includes(s)?o.push(m.id):m.id.includes(l)&&n.push(m.id)}),e.length&&(r=await this.footballNamespace.footballFacade.competitionsFacade.getCompetitionsMapWithNativeIds(e)),o.length&&(p=await this.footballNamespace.footballFacade.teamsFacade.getTeamsMapWithNativeIds(o)),n.length&&(c=await this.footballNamespace.footballFacade.playerFacade.getPlayersMapWithNativeIds(n)),t.breakdown.forEach(m=>{m.id.includes(i)?(m.model=r.get(m.id),m.id=m.model.id):m.id.includes(s)?(m.model=p.get(m.id),m.id=m.model.id):m.id.includes(l)&&(m.model=c[m.id],m.id=m.model.id)}),t};extractEnabledBadgesId=t=>{let e=[];return t.forEach(i=>{i.enabled&&e.push(i.id)}),e}};var Qr=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(G).includes(t)){let r=ho(t);throw e==="default"?new b(400,"INVALID_MARKET",r):new y(400,"INVALID_MARKET",r)}};validateDate=(t,e,i)=>{let r=/^\d{4}-\d{2}-\d{2}$/;if(typeof t!="string")throw i==="default"?new b(400,"invalid_filters","You have provided invalid type. The valid type is "+`string for ${e} filter`):new y(400,"invalid_filters","You have provided invalid type. The valid type is "+`string for ${e} filter`);if(!r.test(t))throw i==="default"?new b(400,"invalid_filters","You have provided invalid value. The valid value is "+`YYYY-MM-DD for ${e}`):new y(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,o=e==="usersCount"?1e3:1e6;if(typeof t!="number")throw i==="default"?new b(400,"invalid_filters","You have provided invalid type. The valid type is "+`number for ${e} filter`):new y(400,"invalid_filters","You have provided invalid type. The valid type is "+`number for ${e} filter`);if(t<r||t>o)throw i==="default"?new b(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${o}`):new y(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${o}`)}};var ne=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 mt(t.errorHandlingMode),this.predictorHttps=new Z(t,e),this.predictorService=new J(t,e),this.clientHttps=new H(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 A(e)),await this.predictorHttps.getGamePredictions(t,i,e));getGameResults=async(t,e,i)=>{i=i||!1,e&&(e=new W(e));let r=await this.predictorHttps.getGameResults(t,i,e);return await this.predictorService.remapMatchIdsFixtures(r)};getCurrentGameResults=async t=>{t=t||!1;let e={status:"OPEN",type:"TOP_X"};e=new W(e);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 o=await this.predictorService.remapMatchIdToNative(r);e.fixtures.forEach(s=>s.matchId=o.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=[],o=await this.predictorHttps.getMyPredictionsNoRemap(i);if(o.data.length>0){o.data.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let s=this.predictorService.initGameFilters("TOP_X",null,r),p=await this.predictorHttps.getUserGameEditions(s,e);return await this.predictorService.addPredictionProp(o,p)}else return new F};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(o=>o.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),o=[],s=await this.predictorHttps.getUserPredictionsNoRemap(t,r);if(s.data.length>0){s.data.forEach(l=>{l.game_instance_id&&o.push(l.game_instance_id)});let p=this.predictorService.initGameFilters("TOP_X",null,o),n=await this.predictorHttps.getUserGameEditions(p,i);return await this.predictorService.addPredictionProp(s,n)}else return new F};getUserGamePrediction=async(t,e,i)=>{i=i||!1;let r=this.predictorService.initGameTypePredictions("TOP_X"),o=await this.predictorHttps.getUserPredictions(t,i,r);if(o.data.length>0){let s=o.data.filter(p=>p.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=>{let e=await this.predictorHttps.getContestWinners(t),i=await this.getGameById(t);return e.contestModel=i,this.predictorService.completeContestWinners(e)};validateLimitFilterOnGames=t=>{if(this.errorHandlingMode==="default"&&t>50)throw new b(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.");if(this.errorHandlingMode==="standard"&&t>50)throw new y(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.")}};var le=class{predictorHttps=null;predictorService=null;idMapping=null;clientHttps=null;predictorValidator=null;errorHandlingMode=null;constructor(t){this.predictorValidator=new mt(t.errorHandlingMode),this.idMapping=new T(t),this.predictorHttps=new Z(t,this.idMapping),this.predictorService=new J(t,this.idMapping),this.clientHttps=new H(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(p=>{i.push(p.matchId),p instanceof V&&p.prediction.playerId&&p.prediction.playerId!=="OWN_GOAL"&&r.push(p.prediction.playerId)});let o=await this.predictorService.remapMatchIdToNative(i),s={};r&&r.length>0&&(s=await this.predictorService.remapPlayerIdMapToNative(r)),e.forEach((p,n)=>{p.matchId=o[n],p instanceof V&&p.prediction.playerId!=="OWN_GOAL"&&(p.prediction.playerId=s[p.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 A(e)),await this.predictorHttps.getGamePredictions(t,i,e));getGameResults=async(t,e,i)=>{i=i||!1,e&&(e=new zt(e));let r=await this.predictorHttps.getGameResults(t,i,e);return await this.predictorService.remapMatchIdsFixtures(r)};getCurrentGameResults=async t=>{t=t||!1;let e={status:"OPEN",type:"MATCH_QUIZ"};e=new W(e);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=[],o=await this.predictorHttps.getMyPredictionsNoRemap(i);if(o.data.length>0){o.data.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let s=this.predictorService.initGameFilters("MATCH_QUIZ",null,r),p=await this.predictorHttps.getUserGameEditions(s,e);return await this.predictorService.addPredictionProp(o,p)}else return new F};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(o=>o.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),o=[],s=await this.predictorHttps.getUserPredictionsNoRemap(t,r);if(s.data.length>0){s.data.forEach(l=>{l.game_instance_id&&o.push(l.game_instance_id)});let p=this.predictorService.initGameFilters("MATCH_QUIZ",null,o),n=await this.predictorHttps.getUserGameEditions(p,i);return await this.predictorService.addPredictionProp(s,n)}else return new F};getUserGamePrediction=async(t,e,i)=>{i=i||!1;let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),o=await this.predictorHttps.getUserPredictions(t,i,r);if(o.data.length>0){let s=o.data.filter(p=>p.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=>{let e=await this.predictorHttps.getContestWinners(t),i=await this.getGameById(t);return e.contestModel=i,this.predictorService.completeContestWinners(e)};validateLimitFilterOnGames=t=>{if(this.errorHandlingMode==="default"&&t>50)throw new b(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.");if(this.errorHandlingMode==="standard"&&t>50)throw new y(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.")}};var zr=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 Jr=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&&(t+="&",t+=`flags=${this.flags}`),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 Zr=class{config=null;clientHttps=null;loyaltyHttps=null;loyaltyService=null;profileFacade=null;loyaltyValidator=null;idMapping=null;topXFacade=null;matchQuizFacade=null;predictorHttps=null;errorHandlingMode=null;constructor(t,e,i,r,o){this.config=t,this.clientHttps=e,this.loyaltyHttps=i,this.profileFacade=new j(o,r),this.loyaltyService=new qr(this.config),this.loyaltyValidator=new Qr,this.idMapping=new T(t),this.topXFacade=new ne(t,this.idMapping),this.matchQuizFacade=new le(t),this.predictorHttps=new Z(t,this.idMapping),this.errorHandlingMode=t.errorHandlingMode}getConfig=async()=>await this.clientHttps.getConfig("loyalty");getClientBadges=async()=>{let t=await this.getConfig();return this.loyaltyService.buildClientBadges(t.rewards.badges)};getTemplates=async(t,e)=>{if(t&&(t=new Jr(t)),this.config.idSchema==="native")return await this.loyaltyHttps.getTemplates(t,e);let i=await this.loyaltyHttps.getTemplates(t,e);return i.data=await this.loyaltyService.remapTemplatesIds([...i.data]),i};getTemplateById=async(t,e)=>{let i=await this.loyaltyHttps.getTemplateById(t,e);return this.config.idSchema==="native"?i:(await this.loyaltyService.remapTemplatesIds([i]))[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.addProfileModelToLeaderboad(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.addProfileModelToLeaderboad(r.data),r};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 zr(t),this.loyaltyValidator.validate(t,this.errorHandlingMode));let i=await this.loyaltyHttps.getHighestSuccessRate(t,e);return this.loyaltyService.addProfileModelToHighestSuccessRate(i)};getTemplateWinners=async t=>{let e=await this.predictorHttps.getContestWinners(t),i=await this.getTemplateById(t);return e.contestModel=i,this.loyaltyService.completeContestWinners(e)};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,[o,s,p]=this.loyaltyService.extractRankingsIdsMap(t.data);if(p.length&&(e=(await this.getTemplates()).data.filter(l=>p.includes(l.id))),o.length){let n={gameIds:o};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)}};var to=class{clientHttps=null;profileHttps=null;loyaltyHttps=null;loyaltyFacade=null;localCache=null;constructor(t){this.clientHttps=new H(t),this.profileHttps=new Tt(t),this.loyaltyHttps=new jr(t),this.localCache=new k().createLocalCacheInstance(t.idSchema),this.loyaltyFacade=new Zr(t,this.clientHttps,this.loyaltyHttps,this.profileHttps,this.localCache)}getConfig=async()=>await this.loyaltyFacade.getConfig();getClientBadges=async()=>await this.loyaltyFacade.getClientBadges();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);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=>await this.loyaltyFacade.getTemplateWinners(t);getEntitiesFollows=async(t,e)=>await this.loyaltyFacade.getEntitiesFollows(t,e)};var eo=class{topXFacade=null;idMapping=null;constructor(t){this.idMapping=new T(t),this.topXFacade=new ne(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=>await this.topXFacade.getGameWinners(t)};var io=class{matchQuizFacade=null;constructor(t){this.matchQuizFacade=new le(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=>await this.matchQuizFacade.getGameWinners(t)};var Te=class{action=null;context=new Gt;constructor(t,e,i,r){this.action=t,this.context.tags=e,i&&(this.context.content=i),r&&(this.context.campaign=r)}};var ro=class{idSchema;idMapping;constructor(t){this.idSchema=t.idSchema,this.idMapping=new T(t)}remapTagsIds=async(t,e,i)=>{if(!t||!t.length)return t;let r={},o={},s=[];t.forEach(n=>{r.hasOwnProperty(n.type)||(r[n.type]=[],o[n.type]=[]),r[n.type].push(n.id),o[n.type].push(n)});let p=await this.idMapping.idMappingFacade.getEntitiesByIds(r,e,i);for(let[n,l]of Object.entries(o))l.forEach((c,m)=>{c.id=p[n][m],s.push(c)});return s}};var pe=class{page=null;limit=null;constructor(t){this.page=t.page?t.page:null,this.limit=t.limit?t.limit:null}};var oo=class extends pe{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 ao=class extends pe{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 so=class{idSchema;activityHttps;activityService;constructor(t){this.idSchema=t.idSchema,this.activityHttps=new $t(t),this.activityService=new ro(t)}add=async(t,e,i,r)=>{if(this.idSchema!="native"){let s=JSON.parse(JSON.stringify(e)),p=await this.activityService.remapTagsIds(e,this.idSchema,"native"),n=new Te(t,p,i,r),l=await this.activityHttps.createActivity(n);return l.context.tags=s,l}let o=new Te(t,e,i,r);return this.activityHttps.createActivity(o)};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 oo(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 ao(e)),this.idSchema!="native"){let r=await this.activityHttps.getActivitiesForUser(t,e,i),o=JSON.parse(JSON.stringify(r));for(let s of o.data)await this.activityService.remapTagsIds([...s.context.tags],"native",this.idSchema);return o}return await this.activityHttps.getActivitiesForUser(t,e,i)}};var no=class{activityFacade;constructor(t){this.activityFacade=new so(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 Po=null,ko=null;function zb(a){if(Ga(a)){let t=Va(a);if(t.isValid)return Po={profile:new lt(a),football:new jt(a),predictor:new Dr(a),loyalty:new to(a),topX:new eo(a),matchQuiz:new io(a),activity:new no(a)},ko={...a},Po;$a(t)}return Po}var Ga=a=>!Po||JSON.stringify(a)!==JSON.stringify(ko)||a.authProvider.getIdToken()!==ko.authProvider.getIdToken(),Va=a=>{let e=new rr().validate(a);return(e.idSchema.validation==="missing"||e.idSchema.validation==="invalid")&&(console.warn(e.idSchema.message.text),a.idSchema="native"),(e.environment.validation==="missing"||e.environment.validation==="invalid")&&(console.warn(e.environment.message.text),a.environment="prod"),(e.lang.validation==="missing"||e.lang.validation==="invalid")&&(console.warn(e.lang.message.text),a.lang="en"),(e.errorHandlingMode.validation==="missing"||e.errorHandlingMode.validation==="invalid")&&(console.warn(e.errorHandlingMode.message.text),a.errorHandlingMode="default"),e.authProvider.validation==="invalid"&&console.warn(e.authProvider.message.text),e},$a=a=>{let t="authProvider",e="isValid";Object.keys(a).forEach(i=>{let r=a[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 yt).forEach(o=>{if(r[o].message.type==="error")throw new Error(r[o].message.text)})})};export{zb as FansUnitedSDK};
|
|
3
|
+
${vo.PREDICTOR_USER_RELATED_OPERATION}`},jo=(a,t)=>`The prediction '${a}' 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`,ho=a=>`The market '${a}' is not supported from Fans United. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,Xo=a=>`The market '${a}' is not valid for Top X game. The only available market is CORRECT_SCORE.`,Yo=a=>`The field/s '${a.length>1?a.join(", "):a[0]}' is/are invalid. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/javascript-sdk`,qo=(a,t)=>`The following field/s is/are missing from ${a}: '${t.length>1?t.join(", "):t[0]}'. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,Qo=(a,t)=>`The field ${a} has incorrect type. The correct type is ${t}`;var ht=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 y=class{error={code:0,status:"",message:""};constructor(t,e,i){this.error.code=t,this.error.status=e,this.error.message=i}};var S=class{baseUrl=null;apiSignInUrl=null;jwtToken=null;idSchema=null;retryRequest=!1;headers=null;authHeaders=null;errorHandlingMode=null;constructor(t,e){this.baseUrl=e,this.apiSignInUrl=`?key=${t.apiKey}&client_id=${t.clientId}`,this.jwtToken=t.authProvider.getIdToken(),this.errorHandlingMode=t.errorHandlingMode,this.idSchema=t.idSchema,this.headers={"Content-Type":"application/json"},this.authHeaders={"Content-Type":"application/json",Authorization:`Bearer ${t.authProvider.getIdToken()}`}}fetchWithoutAuth=async(t,e)=>{let i=await fetch(this.baseUrl+t,{headers:this.headers}),r=await i.json();if(!i.ok){let o=this.transformFetchException(i,r);throw console.warn(e,o),o}return r};fetchWithAuth=async(t,e,i,r)=>{this.validateJWTToken();let o=null,s=null;if(i&&r?o=await fetch(this.baseUrl+t,{method:i,headers:this.authHeaders,body:JSON.stringify(r)}):i&&!r?o=await fetch(this.baseUrl+t,{method:i,headers:this.authHeaders}):o=await fetch(this.baseUrl+t,{headers:this.authHeaders}),i!=="DELETE"&&(s=await o.json()),!o.ok){(o.status===401||o.status===403)&&!this.retryRequest&&(this.retryRequest=!0,await this.fetchWithAuth(t,e,i,r)),this.retryRequest=!1;let p=this.transformFetchException(o,s||await o.json());throw console.warn(e,p),p}return this.retryRequest=!1,s};transformFetchException=(t,e)=>{if(!e&&t.status===401){if(this.errorHandlingMode==="standard")return new y(401,"unauthorized","Invalid JWT token is provided");let s={code:401,status:"unauthorized",message:"Invalid JWT token is provided"};return new ht(t,s)}let{code:i,status:r,message:o}=e.error;return this.errorHandlingMode==="standard"?new y(i,r,o):new ht(t,e.error)};validateJWTToken=()=>{let t=null;try{t=Wo(this.jwtToken)}catch(i){if(this.errorHandlingMode==="default"){let r={status:401,statusText:i.message,headers:{}},o={code:401,status:"invalid_token",message:"Invalid JWT token is provided"};throw new ht(r,o)}else if(this.errorHandlingMode==="standard")throw new y(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 ht(i,r)}else if(this.errorHandlingMode==="standard")throw new y(401,"invalid_token","The provided JWT token is expired")}}};var Aa="/countries",x="/profile",Ao="/profiles",Tt=class extends S{profileRemapper=null;followingRemapper=null;followersRemapper=null;lang=null;limitIds=100;constructor(t){super(t,L(t.environment,"profile")),this.lang=t.lang,this.profileRemapper=new Se,this.followingRemapper=new Oe,this.followersRemapper=new xe}getCountries=async t=>{let e=`&lang=${this.lang}`,i=`${Aa}${this.apiSignInUrl}${e}`,r=Date.now(),o="There was a problem fetching profile countries";return t&&(i+=`&disable_cache=${r}`),(await this.fetchWithoutAuth(i,o)).data};getProfile=async t=>{let e=`${x}${this.apiSignInUrl}`,i="";if(t){e=`${Ao}/${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)=>{let i=Date.now(),r=`There was a problem fetching the following profiles: ${t.join(",")}`;if(t.length>this.limitIds){let p=[],n=me(t,this.limitIds);for(let l of n){let c=`${Ao}${this.apiSignInUrl}&profile_ids=${l.join(",")}`;r=`There was a problem fetching the following profiles: ${l.join(",")}`,e&&(c+=`&disable_cache=${i}`);let m=await this.fetchWithoutAuth(c,r);p.push(...this.profileRemapper.profilesFromResponse(m.data))}return p}let o=`${Ao}${this.apiSignInUrl}&profile_ids=${t.join(",")}`;e&&(o+=`&disable_cache=${i}`);let s=await this.fetchWithoutAuth(o,r);return this.profileRemapper.profilesFromResponse(s.data)};getFollowers=async(t,e)=>{let i=`${x}/followers${this.apiSignInUrl}`,r="There was a problem fetching the followers for own profile";if(t&&!e){i=`${x}/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=`${x}/${e}/followers${this.apiSignInUrl}${t.constructFilterUrl()}`:!t&&e&&(i=`${x}/${e}/followers${this.apiSignInUrl}`),r=`There was a problem fetching the followers for profile: ${e}`;let o=await this.fetchWithoutAuth(i,r);return this.followersRemapper.followersFromResponse(o)};getFollowing=async(t,e)=>{let i=`${x}/following${this.apiSignInUrl}`,r="There was a problem fetching the followers of own profile";if(t&&!e){i=`${x}/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=`${x}/${e}/following${this.apiSignInUrl}${t.constructFilterUrl()}`:!t&&e&&(i=`${x}/${e}/following${this.apiSignInUrl}`),r=`There was a problem fetching the followers of the following profile: ${e}`;let o=await this.fetchWithoutAuth(i,r);return this.followingRemapper.followingFromResponse(o)};follow=async t=>{let e=new de;e.profile_ids=t;let i=x+`/follow${this.apiSignInUrl}`,r=`There was a problem with following profiles: ${t.join(",")}`,o="POST",s=await this.fetchWithAuth(i,r,o,e);return this.followingRemapper.followResponse(s.data)};unfollow=async t=>{let e=new de;e.profile_ids=t;let i=x+`/follow${this.apiSignInUrl}`,r=`There was a problem with unfollowing profiles: ${t.join(",")}`,o="DELETE";return await this.fetchWithAuth(i,r,o,e),!0};getBadges=async t=>{let e=`${x}/badges${this.apiSignInUrl}`,i="There was a problem with fetching own badges";return t?(e=`${x}/${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=x+this.apiSignInUrl,i="There was a problem updating the own profile",r="PATCH",o=await this.fetchWithAuth(e,i,r,t);return this.profileRemapper.fullProfileFromResponse(o.data)}};var B=(o=>(o.NATIVE="native",o.ENETPULSE="enetpulse",o.SPORTRADAR="sportradar",o.SPORTAL_365="sportal365",o.API_FOOTBALL="api_football",o))(B||{});var De={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},Ne=class extends S{constructor(t){super(t,L(t.environment,"idMapping"))}getEntityById=async(t,e)=>{let i=`/football${this.apiSignInUrl}&input_provider=${this.idSchema}&${De[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}&${De[t]}=${e}`,o=`There was a problem with id mapping request for the following id: ${e}`;return await this.fetchWithoutAuth(r,o)};getEntityIdsByIdsAndSchema=async(t,e,i)=>{let r=`/football${this.apiSignInUrl}&input_provider=${i}&${De[t]}=${e.join(",")}`,o=`There was a problem with id mapping request for the following ids: ${e.join(",")}`;return await this.fetchWithoutAuth(r,o)};getEntitiesByIds=async(t,e,i)=>{e.sort((s,p)=>s.localeCompare(p));let r=Ro(e),o=[];for(let s of r){let p=`/football${this.apiSignInUrl}&input_provider=${i}&${De[t]}=${s.join(",")}`,n=`There was a problem with id mapping request for the following ids :${s.join(",")}`,l=await this.fetchWithoutAuth(p,n);o=[...o,...l.data]}return o};getEntitiesByIdObjs=async(t,e)=>{let i=[],r={},o=[];Object.keys(t).forEach(l=>{i.push.apply(i,t[l])});let s=ut(i),p=Ro(s);for(let l of p){let c="";if(Object.keys(t).forEach(m=>{r[m]=[];let d=l.filter(M=>t[m].includes(M));d&&d.length>0&&(r[m]=d)}),Object.keys(r).forEach(m=>{r[m].length>0&&(r[m].sort((d,M)=>d.localeCompare(M)),c+="&",c+=`${De[m]}=${r[m].join(",")}`)}),c&&c.length>0){let m=`/football${this.apiSignInUrl}&input_provider=${e||"native"}${c}`,d="There was a problem with id mapping request",M=await this.fetchWithoutAuth(m,d);o.push(M.data)}else o.push([])}return Array.prototype.concat.apply([],o)};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 zo="FansUnited",Oo={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}}},Be=class{idSchema="";expirationProfileTimeout=600;expirationBadgesTimeout=3600;expirationClientFeaturesTimeout=14400;expirationFootballIdsTimeout=604800;constructor(t){this.idSchema=t,(this.getData()===void 0||this.getData()===null)&&this.setData(Oo)}clearData=()=>{this.setData(Oo)};getEntityById=(t="",e="")=>this.getData().football.ids.find(i=>{let r=v[this.idSchema];return i&&`${i[r]}`===e&&i.resource===t});getEntity=(t,e,i)=>Array.isArray(t)?this.getData().football.ids.filter(r=>{let o=v[i];return r&&t.includes(`${r[o]}`)&&r.resource===e}):this.getData().football.ids.find(r=>{let o=v[i];return r&&`${r[o]}`===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=v[e],r={};return Object.keys(t).forEach(o=>{let s=t[o],n=this.getEntity(s,o,e).map(c=>c[i]),l=t[o].filter(c=>!n.includes(c));r[o]=s.map(c=>l.includes(c)?{id:c,exists:!1}:{id:c,exists:!0})}),r};getIdsByType=(t,e,i)=>{let r=v[i],o=v[e],s={};return Object.keys(t).forEach(p=>{let n=t[p],l=[];this.getData().football.ids.forEach(c=>{n.forEach((m,d)=>{m===c[o]&&p===c.resource&&(l[d]=c[r])})}),s[p]=l}),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=()=>JSON.parse(localStorage.getItem(zo));setData=t=>{localStorage.setItem(zo,JSON.stringify(t))};initialNewSchema=(t,e)=>{let i=this.getData();(!i||!i[t]||!i[t][e])&&this.setData(Oo)}};var ga=va(fa());var g=class{profileTTL=600;clientTTL=14400;profileBadgesTTL=3600;idMappingsExpiration=0;idSchema="";constructor(t){}static getInstance(t){return g.instance||(g.instance=new g(t),g.nodeCache.options.useClones=!1),g.instance}clearData=()=>g.nodeCache.flushAll();getEntityById=(t,e)=>{let i=g.nodeCache.get("ids");return i?i.find(r=>{let o=v[this.idSchema];return r&&`${r[o]}`===e&&r.resource===t}):null};getEntity=(t,e,i)=>{let r=g.nodeCache.get("ids");return r?Array.isArray(t)?[]:null:Array.isArray(t)?r.filter(o=>{let s=v[i];return o&&t.includes(`${o[s]}`)&&o.resource===e}):r.find(o=>{let s=v[i];return o&&`${o[s]}`===t&&o.resource===e})};checkForExistingIdObjs=(t,e)=>{let i=v[e],r={};return Object.keys(t).forEach(o=>{let s=t[o],n=this.getEntity(s,o,e).map(c=>c[i]),l=t[o].filter(c=>!n.includes(c));r[o]=s.map(c=>l.includes(c)?{id:c,exists:!1}:{id:c,exists:!0})}),r};getIdsByType=(t,e,i)=>{let r=v[i],o=v[e],s=g.nodeCache.get("ids"),p={};return s?(Object.keys(t).forEach(n=>{let l=t[n],c=[];s.forEach(m=>{l.forEach((d,M)=>{d===m[o]&&n===m.resource&&(c[M]=m[r])})}),p[n]=c}),p):null};addIdMapping=t=>{let e=g.nodeCache.get("ids");e.push(t),g.nodeCache.set("ids",e)};addIdMappings=t=>{let e=g.nodeCache.get("ids");e=[...e,...t],g.nodeCache.set("ids",e)};addTopIdMappings=t=>{let e=g.nodeCache.get("ids"),i=604800;if(e){let r=JSON.parse(JSON.stringify(e));r=r.filter(o=>o.resource!=="match"),t=t.filter(o=>o.resource==="match"),r=[...r,...t],g.nodeCache.set("ids",r)}else g.nodeCache.set("ids",t);this.idMappingsExpiration=Math.floor(Date.now()/1e3)+i};setOwnProfile=t=>g.nodeCache.set("profile",t,this.profileTTL);getOwnProfile=()=>g.nodeCache.get("profile");getProfileCountries=()=>g.nodeCache.get("profile_countries");setProfileCountries=t=>g.nodeCache.set("profile_countries",t);getProfileStats=()=>g.nodeCache.get("profile_stats");setProfileStats=t=>g.nodeCache.set("profile_stats",t,this.profileTTL);getProfileBadges=()=>g.nodeCache.get("profile_badges");setProfileBadges=t=>{g.nodeCache.set("profile_badges",t,this.profileBadgesTTL)};getFootballCountries=()=>g.nodeCache.get("football_countries");setFootballCountries=t=>g.nodeCache.set("football_countries",t);getCompetitions=t=>{let e=g.nodeCache.get("football_competitions");return e?t?t.competitionSearchFilter(e):e:null};setCompetitions=t=>g.nodeCache.set("football_competitions",t);getCompetitionsLength=()=>{let t=g.nodeCache.get("football_competitions");return t?t.length:0};getClientFeatures=()=>g.nodeCache.get("client");setClientFeatures=t=>g.nodeCache.set("client",t,this.clientTTL);deleteClientFeatures=()=>g.nodeCache.del("client");getExpiration=(t,e)=>{let i=this.getKeyFromExpirationType(e);return i==="ids"?this.idMappingsExpiration:g.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"}}},_t=g;_o(_t,"instance"),_o(_t,"nodeCache",new ga.default);var k=class{createLocalCacheInstance=t=>typeof window>"u"?_t.getInstance(t):new Be(t)};var ke=class{localCache=null;https=null;constructor(t){this.localCache=new k().createLocalCacheInstance(t.idSchema),this.https=new Ne(t)}getEntitiesByIds=async(t,e,i)=>{await this.setTopIdMappings();try{let r=this.localCache.checkForExistingIdObjs(t,e),o=this.splitForRequestAndExisting(r),s=await this.https.getEntitiesByIdObjs(o.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 o=await this.requestEntity(t,e,i);return this.localCache.addIdMappings(o),o};splitForRequestAndExisting=t=>{let e={},i={};return Object.keys(t).forEach(r=>{e[r]=t[r].filter(o=>!o.exists).map(o=>o.id),i[r]=t[r].filter(o=>o.exists).map(o=>o.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 Mo=a=>{switch(a){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 a}};var He=class{extractedObjIds={};traverse=(t,e)=>(e=Mo(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 Ue=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(t,e,i)=>(e=Mo(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 T=class{idSchema="";idMappingFacade=null;constructor(t){this.idSchema=t.idSchema,this.idMappingFacade=new ke(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 o=new He().traverse(i,e);return this.idMappingFacade.getEntitiesByIds(o,"native",this.idSchema).then(s=>new Ue().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 D=class{completed=!1;percentage;constructor(t){this.percentage=t}};var Ge=class{teamFollowed=new D(10);teamFavourite=new D(15);playerFollowed=new D(10);playerFavourite=new D(10);competitionFollowed=new D(10);competitionFavourite=new D(5);addedBirthdate=new D(10);addedGender=new D(10);addedCountry=new D(10);addedAvatar=new D(10)};var Ve=class{totalPercentage;breakdown=new Ge};var fe=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 j=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)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}};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)=>{try{return e=e||!1,await this.profileHttps.getProfiles(t,e)}catch(i){throw console.warn(`There was a problem retrieving the selected profiles: ${t.join(",")} `,i),i}};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 fe(t));let i=await this.profileHttps.getFollowers(t,e),r=i.data.map(o=>o.followerId);if(r.length){let o=await this.getByIds(r),s=i.data.map(p=>(o.forEach(n=>{p.followerId===n.id&&(p.name=n.name,p.nickname=n.nickname,p.avatar=n.avatar)}),p));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 fe(t));let i=await this.profileHttps.getFollowing(t,e),r=i.data.map(o=>o.followingId);if(r.length){let o=await this.getByIds(r),s=i.data.map(p=>(o.forEach(n=>{p.followingId===n.id&&(p.name=n.name,p.nickname=n.nickname,p.avatar=n.avatar)}),p));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 Ve,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=["predictionsMade","predictions","tiers","badges"],e=this.getLocalStorageData("statistics"),i=e?t.every(r=>Object.keys(e).includes(r)):!1;if(e&&Object.keys(e).length&&i)return JSON.parse(JSON.stringify(e));try{let r=await this.activityHttps.getStats();return this.localCache.setProfileStats(r),r}catch(r){throw console.warn("There was a problem retrieving own profile statistics: ",r),r}};getBadges=async()=>{let t=this.getLocalStorageData("badges");if(t)return t;try{let e=await this.profileHttps.getBadges();return this.localCache.setProfileBadges(e),e}catch(e){throw console.warn("There was a problem retrieving own profile badges: ",e),e}};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 $e=class{id=null;name=null;assets=null};var We=class{extractUpdatedProps=(t,e)=>{let i=["name","nickname","gender","avatar"],r={};return Object.keys(t).forEach(o=>{if(i.includes(o)&&t[o]!==e[o])r[o]=e[o];else if(o==="birthDate")(e[o]===null||t[o]===null&&e[o]||t[o]!==e[o])&&(r.birth_date=e[o]);else if(o==="country")e[o]===null?r.country_id=e[o]:(t[o]===null&&e[o]||t[o].id!==e[o].id)&&(r.country_id=e[o].id);else if(o==="interests"){let s=t[o],p=e[o];p.length&&this.isNewInterest(s,p)?r[o]=this.updateInterests(s,p):(!p.length&&s.length||s.length!==p.length&&!this.isNewInterest(s,p))&&(r[o]=p)}}),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(o=>t.some(s=>o.id===s.id&&o.type===s.type&&o.source===s.source&&o.favourite===s.favourite));return[e.filter(o=>!t.some(s=>o.id===s.id&&o.type===s.type&&o.source===s.source&&o.favourite===s.favourite)),i]};isAvatarValidURL=t=>{try{return new URL(t),!0}catch{return!1}}};var b=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 Ke=class{idsRemapper=null;profileHttps=null;profileService=null;localCache=null;profileFacade=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;errorHandlingMode=null;constructor(t,e,i,r,o){this.idsRemapper=t,this.localCache=e,this.profileHttps=i,this.errorHandlingMode=o,this.profileService=new We,this.profileFacade=new j(e,i,r)}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.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()=>{let t=await this.profileFacade.getStats();return await this.idsRemapper.remapProfileStats(t)};getBadges=async()=>await this.profileFacade.getBadges();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(o=>o.id!==i.id||o.type!==i.type||o.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 $e,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.errorHandlingMode==="default")throw new b(400,"invalid_avatar","Invalid URL syntax for avatar image.");if(this.errorHandlingMode==="standard")throw new y(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 o=await this.profileHttps.updateProfile(i),s=JSON.parse(JSON.stringify(o));return this.setOwnProfile(s),this.localCache.setOwnProfile(s),delete o.interests,o}let r=JSON.parse(JSON.stringify(this.ownProfile));return delete r.interests,r}};var je=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 j(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 Xe=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 ge=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&&(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(o=>{o!=="sortOrder"&&o!=="sortField"&&(o==="countryId"?r&&=i.country.id===this[o]:o==="name"?r&&=i.name.toLocaleLowerCase().includes(this[o].toLocaleLowerCase()):o==="competitionIds"?r&&=this[o].some(s=>i.id===s):r&&=i[o].toLocaleLowerCase()===this[o].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 Ye=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 ge(t),t.countryId){let o=await this.idMapping.getEntityIdsBySchemaId([`${t.countryId}`],"country","native");o.country.length===0&&(i=!0),t.countryId=o.country[0]}if(t.competitionIds){let o=await this.idMapping.getEntityIdsBySchemaId(t.competitionIds,"competition","native");o.competition.length===0&&(i=!0),t.competitionIds=o.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 ge({competitionIds:t,limit:i}),o=await this.getCompetitions(r);o.sort((n,l)=>n.id.localeCompare(l.id));let s=mo(t),p=await this.idMapping.remapEntities(o,"competition");return s.forEach((n,l)=>e.set(n,p[l])),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],o=await this.getCompetitionById(r,e);return await this.idMapping.remapEntities(o,"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 ye=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&&(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&&(t=t+"&",t=t+`team_ids=${this.teamIds.join(",")}`),t}};var qe=class{general=[];predictor=[];topX=[];matchQuiz=[]};var rt=class{points=null;gameParticipationCount=null;entityId=null;entityType=null;predictionsMade=null;correctPredictions=null};var Qe=class{id;label;assets={mainImageUrl:""};enabled;requirements=new rt};var Rt=class extends rt{postPoints=null;postsCount=null;reactionsCount=null;totalDiscussionPoints=null};var ze=class{id;label;assets={mainImageUrl:""};enabled;requirements=new Rt};var Je=class{id;weight;multiplier;conditions};var Ze=class{value=[new Je]};var Et=class{points=null;tiers=null;badges=null};var ti=class{enabled=!1;clientId=null;conditions={list:null};actions=new Ze;rewards=new Et};var ei=class{general=null;predictor=null;activity=null;topX=null;matchQuiz=null;discussionPost=null};var vt=class{enabled=!1;clientId=null;defaultMarkets=null;competitionsWhitelist=null};var St=class{enabled=!1;clientId=null;minFixtures=null;maxFixtures=null;competitionsWhitelist=null};var ii=class{competitions=[];teams=[];markets=[]};var Ct=class{enabled=!1;clientId=null;fullCoverageCompetitions=null;markets=null;successRateScopes=new ii;userDataConfig=null};var ri=class{storeIp=!1;storeDeviceId=!1;storeAgent=!1};var oi=class{remapPredictorConfig=t=>{let e=new Ct;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 St;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 vt;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 ti;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};remapRewards=t=>{let e=new Et;return e.points=this.remapPoints(t.points),e.tiers=t.tiers,e.badges=this.remapBadges(t.badges),e};remapPoints=t=>{let e=new ei;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 qe;return e.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};remapBadgeValues=t=>t.map(e=>{let i=new Qe;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});remapGeneralBadgeValues=t=>t.map(e=>{let i=new ze;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});remapRequirements=t=>{let e=new rt;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};remapGeneralRequirements=t=>{let e=new Rt;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};remapUserDataConfig=t=>{let e=new ri;return e.storeIp=t.store_ip,e.storeDeviceId=t.store_device_id,e.storeAgent=t.store_agent,e}};var H=class extends S{featureConfigRemapper=null;localStorage=null;clientId=null;constructor(t){super(t,L(t.environment,"client")),this.clientId=t.clientId,this.localStorage=new k().createLocalCacheInstance(t.idSchema),this.featureConfigRemapper=new oi}getConfig=async t=>{let e=this.getCachedFeatures();if(!e){let i=`/clients/${this.clientId}/features`,r=this.apiSignInUrl.split("&")[0],o=i+r,s="There was a problem fetching client features from Client API";e=(await this.fetchWithoutAuth(o,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)}};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 ot=class{clientHttps=null;constructor(t){this.clientHttps=new H(t)}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)};isMatchInCoverageCompetition=(t,e)=>{let i=!1;return e.includes(t)&&(i=!0),i}};var ai=class{footballService=null;https=null;idMapping=null;constructor(t,e,i){this.idMapping=i,this.https=e,this.footballService=new ot(t)}getTeamsIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new ye(t),t.countryId){let o=await this.idMapping.getEntityIdsBySchemaId([`${t.countryId}`],"country","native");o.country.length===0&&(i=!0),t.countryId=o.country[0]}if(t.scope){let o=await this.idMapping.getEntityIdsBySchemaId(t.scope,"competition","native");o.competition.length===0&&(i=!0),t.scope=o.competition}if(t.teamIds){let o=await this.idMapping.getEntityIdsBySchemaId(t.teamIds,"team","native");o.team.length===0&&(i=!0),t.teamIds=o.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 ye({teamIds:t,limit:i}),{data:o}=await this.getTeams(r);o.sort((n,l)=>n.id.localeCompare(l.id));let s=mo(t),p=await this.idMapping.remapEntities(o,"team");return s.forEach((n,l)=>e.set(n,p[l])),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 Me=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&&(t=t+"&",t=t+`scope=${this.scope.join(",")}`),this.name&&(t=t+"&",t=t+`name=${this.name}`),this.playerIds&&(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 at=class{https=null;footballService=null;idMapping=null;constructor(t,e,i){this.idMapping=i,this.https=e,this.footballService=new ot(t)}getPlayersIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new Me(t),t.countryId){let o=await this.idMapping.getEntityIdsBySchemaId([t.countryId],"country","native");o.country.length===0&&(i=!0),t.countryId=o.country[0]}if(t.playerIds){let o=await this.idMapping.getEntityIdsBySchemaId(t.playerIds,"player","native");o.player.length===0&&(i=!0),t.playerIds=o.player}if(t.scope){let o=await this.idMapping.getEntityIdsBySchemaId(t.scope,"competition","native");o.competition.length===0&&(i=!0),t.scope=o.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 Me({playerIds:t,limit:e}),r=await this.getPlayers(i);return r.data.sort((o,s)=>o.id.localeCompare(s.id)),await this.idMapping.remapEntities(r.data,"player")};getPlayersMapWithNativeIds=async t=>{let e={},i=ut(t);i.sort((o,s)=>o.localeCompare(s));let r=await this.getPlayersWithNativeIds(i);return i.forEach((o,s)=>e[o]=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 At=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=()=>{let t="";return this.countryIds&&(t=t+"&",t=t+`countries=${this.countryIds.join(",")}`),this.competitionIds&&(t=t+"&",t=t+`competitions=${this.competitionIds.join(",")}`),this.matchIds&&(t=t+"&",t=t+`matches=${this.matchIds.join(",")}`),this.status&&(t=t+"&",t=t+`status=${this.status}`),this.teamIds&&(t=t+"&",t=t+`teams=${this.teamIds.join(",")}`),this.fromDate&&(t=t+"&",t=t+`from_date=${this.fromDate}`),this.toDate&&(t=t+"&",t=t+`to_date=${this.toDate}`),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 st=class{https=null;idMapping=null;footballService=null;constructor(t,e,i){this.https=e,this.idMapping=i,this.footballService=new ot(t)}getMatchesIdMapping=async(t,e)=>{try{if(t){if(t=new At(t),t.countryIds){let r=await this.idMapping.getEntityIdsBySchemaId(t.countryIds,"country","native");t.countryIds=r.country}if(t.competitionIds){let r=await this.idMapping.getEntityIdsBySchemaId(t.competitionIds,"competition","native");t.competitionIds=r.competition}if(t.matchIds){let r=await this.idMapping.getEntityIdsBySchemaId(t.matchIds,"match","native");t.matchIds=r.match}if(t.teamIds){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 At({matchIds:t,limit:e}),r=await this.getMatches(i);return r.data.sort((o,s)=>o.id.localeCompare(s.id)),await this.idMapping.remapEntities(r.data,"match")};getMatchesMapWithNativeIds=async t=>{let e={},i=ut(t);i.sort((o,s)=>o.localeCompare(s));let r=await this.getMatchesWithNativeIds(i);if(i.length!==r.length){let o=new At({matchIds:i,limit:i.length}),s=await this.getMatches(o),p=i.filter(n=>{if(s.data.every(l=>l.id!==n))return n});i=i.filter(n=>{if(!p.includes(n))return n})}return i.forEach((o,s)=>e[o]=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),o=await this.footballService.setAvailableMarketsForMatch(r);return await this.idMapping.remapEntities(o,"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 si=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 ni=class{https=null;idMapping=null;constructor(t,e){this.https=t,this.idMapping=e}searchIdMapping=async(t,e)=>{try{if(t=new si(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 Ot=class{countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(t,e,i,r){this.countriesFacade=new Xe(e,i,r),this.competitionsFacade=new Ye(e,i,r),this.teamsFacade=new ai(t,i,r),this.playerFacade=new at(t,i,r),this.matchFacade=new st(t,i,r),this.searchFacade=new ni(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);getMatchById=async(t,e)=>this.matchFacade.getMatchIdMapping(t,e);search=async(t,e)=>this.searchFacade.searchIdMapping(t,e)};var li=class{id="";alias="";countryCode="";assets=null;name=""};var _=class{countriesFromResponse=t=>{if(t)return t.map(e=>this.countryFromResponse(e))};countryFromResponse=t=>{try{if(t){let e=new li;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 pi=class{id="";country=null;gender="";assets=null;type="";name=""};var O=class{countryRemapper=null;constructor(){this.countryRemapper=new _}fromResponse(t){try{let e=new pi;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 ci=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var mi=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName="";isDeleted=!1};var C=class{countryRemapper=null;constructor(){this.countryRemapper=new _}fromResponse(t){try{let e=new mi;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}catch(e){throw console.warn("There was a problem remapping teams response",e),e}}};var di=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new _,this.teamBasicRemapper=new C}fromResponse(t){try{let e=new ci;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 ui=class{primary=null;secondary=null;tertiary=null};var hi=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";isDeleted=!1;colors=new ui;squad=[]};var fi=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var gi=class{countryRemapper=null;constructor(){this.countryRemapper=new _}fromResponse(t){try{let e=new fi;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 yi=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new _,this.competitionRemapper=new O,this.playerRemapper=new gi}fromResponse(t){try{let e=new hi;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.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 Mi=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;homeTeam=null;awayTeam=null;isDeleted=!1;lineupsConfirmed=!1;startedAt="";minute="";scores=null;context={competition:null};status={type:null,subType:null}};var bi=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var Lt=class{fromResponse(t){try{let e=new bi;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 wi=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new C,this.competitionRemapper=new O,this.scoresRemapper=new Lt}fromResponse(t){try{let e=new Mi;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.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 U=class{type=null;subType=null};var Ii=class{id="";kickoffAt="";finishedAt="";updatedAt="";availableMarkets=null;isDeleted=!1;homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;stats=null;context={competition:null};timeline=[];status=new U;lineups=null};var Pi=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 Fi=class{fromResponse(t){try{let e=new Pi;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 xt=class{homeTeam={players:[]};awayTeam={players:[]}};var Ti=class{id="";name="";position="";shirtNumber;assets=null;type=""};var Dt=class{fromResponse(t){try{let e=new Ti;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 _i=class{playerRemapper=null;constructor(){this.playerRemapper=new Dt}fromResponse(t){try{let e=new xt;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 Ri=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var Ei=class{playerRemapper=null;constructor(){this.playerRemapper=new Dt}fromResponse(t){try{let e=new Ri;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 vi=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new C,this.competitionsMapper=new O,this.lineupsMapper=new _i,this.scoresMapper=new Lt,this.statsMapper=new Fi,this.timelineMapper=new Ei}fromResponse(t){try{let e=new Ii;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.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.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 xt,e}catch(e){throw console.warn("There was a problem remapping the match response",e),e}}};var Si=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var Ci=class{countryRemapper=null;constructor(){this.countryRemapper=new _}fromResponse(t){try{let e=new Si;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 Ai=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;teams=[]};var Nt=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new _,this.teamRemapper=new C}fromResponse(t){try{let e=new Ai;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 Oi=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;competitions=[];teams=[]};var Li=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new _,this.teamRemapper=new C,this.competitionRemapper=new O}fromResponse(t){try{let e=new Oi;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 xi=class{teams=null;players=null;competitions=null};var Di=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new C,this.playerRemapper=new Nt,this.competitionremapper=new O}fromResponse(t){try{let e=new xi;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 nt=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var X=class{pagination=new nt};var Bt=class{meta=new X;data=[]};var Ni=class{remapMetaProp=t=>{let e=new X;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 Y=class extends S{limitIds=200;countryRemapper=null;competitionBasicRemapper=null;competitionFullRemapper=null;teamBasicRemapper=null;teamFullRemapper=null;matchBasicRemapper=null;matchFullRemapper=null;playerBasicRemapper=null;playerFullRemapper=null;topPlayerRemapper=null;searchRemapper=null;footballMetaRemapper=null;constructor(t){super(t,L(t.environment,"football")),this.apiSignInUrl=t.lang!=="en"?this.apiSignInUrl+`&lang=${t.lang}`:this.apiSignInUrl,this.countryRemapper=new _,this.competitionBasicRemapper=new O,this.competitionFullRemapper=new di,this.teamBasicRemapper=new C,this.teamFullRemapper=new yi,this.matchBasicRemapper=new wi,this.matchFullRemapper=new vi,this.playerBasicRemapper=new Nt,this.playerFullRemapper=new Li,this.topPlayerRemapper=new Ci,this.searchRemapper=new Di,this.footballMetaRemapper=new Ni}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 o=await this.fetchWithoutAuth(i,e);return this.countryRemapper.countriesFromResponse(o.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 o=[],s=me(t.competitionIds,this.limitIds);for(let n of s){t.competitionIds=n;let l=`/competitions${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(l+=`&disable_cache=${i}`);let c=await this.fetchWithoutAuth(l,r);o.push(c.data.map(m=>this.competitionBasicRemapper.fromResponse(m)))}return Array.prototype.concat.apply([],o)}else{let o=`/competitions${this.apiSignInUrl}`;return t&&(o+=`${t.constructFilterUrl()}`),e&&(o+=`&disable_cache=${i}`),(await this.fetchWithoutAuth(o,r)).data.map(p=>this.competitionBasicRemapper.fromResponse(p))}};getCompetitionById=async(t,e)=>{let i=`/competitions/${t}${this.apiSignInUrl}`,r="There was a problem with football competition by ID request",o=Date.now();e&&(i+=`&disable_cache=${o}`);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 o=[],s=me(t.teamIds,this.limitIds);for(let n of s){t.teamIds=n;let l=`/teams${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(l+=`disable_cache=${i}`);let c=await this.fetchWithoutAuth(l,r);o.push(c.data.map(m=>this.teamBasicRemapper.fromResponse(m)))}return Array.prototype.concat.apply([],o)}else{let o=new Bt,s=`/teams${this.apiSignInUrl}`;t&&(s+=`${t.constructFilterUrl()}`),e&&(s+=`&disable_cache=${i}`);let p=await this.fetchWithoutAuth(s,r);return o.meta=this.footballMetaRemapper.remapMetaProp(p.meta),o.data=p.data.map(n=>this.teamBasicRemapper.fromResponse(n)),o}};getTeamById=async(t,e)=>{let i="There was a problem with football team by ID request",r=`/teams/${t}${this.apiSignInUrl}`,o=Date.now();e&&(r+=`disable_cache=${o}`);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 o=await this.fetchWithoutAuth(e,i);return o.data?o.data.map(s=>this.teamBasicRemapper.fromResponse(s)):[]};getNextMatchForTeam=async(t,e)=>{let i=`/teams/${t}/next-match${this.apiSignInUrl}`,r=Date.now(),o="There was a problem with next match for team request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,o);return this.matchFullRemapper.fromResponse(s.data)};getPrevMatchForTeam=async(t,e)=>{let i=`/teams/${t}/previous-match${this.apiSignInUrl}`,r=Date.now(),o="There was a problem with previous match for team request";e&&(i+=`disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,o);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 o=[],s=me(t.playerIds,this.limitIds);for(let n of s){t.playerIds=n;let l=`/players${this.apiSignInUrl}${t.constructFilterUrl()}`;e&&(l+=`&disable_cache=${i}`);let c=await this.fetchWithoutAuth(l,r);o.push(c.data.map(m=>this.teamBasicRemapper.fromResponse(m)))}return Array.prototype.concat.apply([],o)}else{let o=new Bt,s=`/players${this.apiSignInUrl}`;t&&(s+=`${t.constructFilterUrl()}`),e&&(s+=`&disable_cache=${i}`);let p=await this.fetchWithoutAuth(s,r);return o.meta=this.footballMetaRemapper.remapMetaProp(p.meta),o.data=p.data.map(n=>this.playerBasicRemapper.fromResponse(n)),o}};getPlayerById=async(t,e)=>{let i=`/players/${t}${this.apiSignInUrl}`,r=Date.now(),o="There was a problem with football player by ID request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,o);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(),o="There was a problem with next match for player request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,o);return this.matchFullRemapper.fromResponse(s.data)};getPrevMatchForPlayer=async(t,e)=>{let i=`/players/${t}/previous-match${this.apiSignInUrl}`,r=Date.now(),o="There was a problem with previous match for player request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,o);return this.matchFullRemapper.fromResponse(s.data)};getMatchById=async(t,e)=>{let i=`/matches/${t}${this.apiSignInUrl}`,r=Date.now(),o="There was a problem with match by ID request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,o);return this.matchFullRemapper.fromResponse(s.data)};getMatches=async(t,e)=>{let i=new Bt,r=`/matches${this.apiSignInUrl}`,o=Date.now(),s="There was a problem with football matches request";t&&(r+=`${t.constructFilterUrl()}`),e&&(r+=`&disable_cache=${o}`);let p=await this.fetchWithoutAuth(r,s);return i.meta=this.footballMetaRemapper.remapMetaProp(p.meta),i.data=p.data.map(n=>this.matchBasicRemapper.fromResponse(n)),i};search=async(t,e)=>{let i=`/search${this.apiSignInUrl}${t.constructFilterUrl()}`,r=Date.now(),o="There was a problem with football search request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,o);return this.searchRemapper.fromResponse(s.data)}};var G=(u=>(u.FT_1X2="FT_1X2",u.HT_1X2="HT_1X2",u.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",u.DOUBLE_CHANCE="DOUBLE_CHANCE",u.HT_FT="HT_FT",u.PLAYER_SCORE="PLAYER_SCORE",u.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",u.PLAYER_RED_CARD="PLAYER_RED_CARD",u.RED_CARD_MATCH="RED_CARD_MATCH",u.PENALTY_MATCH="PENALTY_MATCH",u.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",u.CORNERS_MATCH="CORNERS_MATCH",u.CORRECT_SCORE="CORRECT_SCORE",u.CORRECT_SCORE_ADVANCED="CORRECT_SCORE_ADVANCED",u.CORRECT_SCORE_HT="CORRECT_SCORE_HT",u.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",u.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",u.OVER_GOALS_0_5="OVER_GOALS_0_5",u.OVER_GOALS_1_5="OVER_GOALS_1_5",u.OVER_GOALS_2_5="OVER_GOALS_2_5",u.OVER_GOALS_3_5="OVER_GOALS_3_5",u.OVER_GOALS_4_5="OVER_GOALS_4_5",u.OVER_GOALS_5_5="OVER_GOALS_5_5",u.OVER_GOALS_6_5="OVER_GOALS_6_5",u.OVER_CORNERS_6_5="OVER_CORNERS_6_5",u.OVER_CORNERS_7_5="OVER_CORNERS_7_5",u.OVER_CORNERS_8_5="OVER_CORNERS_8_5",u.OVER_CORNERS_9_5="OVER_CORNERS_9_5",u.OVER_CORNERS_10_5="OVER_CORNERS_10_5",u.OVER_CORNERS_11_5="OVER_CORNERS_11_5",u.OVER_CORNERS_12_5="OVER_CORNERS_12_5",u.OVER_CORNERS_13_5="OVER_CORNERS_13_5",u))(G||{}),ya=["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"],Ma=["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"],q=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"],ba=["FT_1X2","HT_1X2","HT_FT","DOUBLE_CHANCE","CORNERS_MATCH","CORRECT_SCORE","CORRECT_SCORE_HT","CORRECT_SCORE_ADVANCED"],be="PLAYER_SCORE_FIRST_GOAL";var Bi=class{id="";achievedAt=""};var kt=class{totalPoints=null;postPoints=null;postsMade=null;reactionPoints=null;reactionCount=null};var we=class{participations=0;points=0};var ft=class{footballCompetitions=[];footballTeams=[]};var Ht=class{predictionsMade=0;correct=0;points=0;breakdown=new ft};var Ut=class{single=new Ht;topX=new we;matchQuiz=new we};var ki=class{overallPercent;byFootballCompetition;byFootballTeam;byFootballMarket};var Hi=class{profileId;tier;points;predictionsMade;successRates=new ki;predictions=new Ut;tiers=[];badges=[];discussions=new kt};var Ui=class{entityId="";entityType="";entitySource="";model=null;predictionsMade=0;correct=0;points=0};var Gi=class{successRatePercent;model=null};var Gt=class{content=null;tags=[];campaign=null};var Vt=class{id=null;profileId=null;property=null;value=null;action=null;context=new Gt;points=0};var Vi=class{meta=new X;data=[new Vt]};var $i=class{remapSingleResponse=t=>{let e=new Vt;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 Vi;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 Hi;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};constructNewRecord=t=>{let e;if(Object.entries(t).length)Object.entries(t).forEach(([i,r])=>{e={...e,[i]:this.remapSuccessRatePercent(r)},G[i]&&delete e[i].model});else return t;return e};remapSuccessRatePercent=t=>{let e=new Gi;return e.successRatePercent=t.success_rate_percent,e};remapPredictionsStats=t=>{let e=new Ut;return e.single=this.remapSinglePredictionsStats(t.single),e.topX=t.top_x,e.matchQuiz=t.match_quiz,e};remapSinglePredictionsStats=t=>{let e=new Ht;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 ft,i=[],r=[];return Object.keys(t).forEach(o=>{let s=new Ui;s.entityId=o,s.entityType=t[o].entity_type,s.entitySource=t[o].entity_source,s.predictionsMade=t[o].predictions_made,s.correct=t[o].correct,s.points=t[o].points,s.entityType==="competition"?i.push(s):s.entityType==="team"&&r.push(s)}),e.footballCompetitions=i,e.footballTeams=r,e}return new ft};remapAchievementsStats=t=>t.map(e=>{let i=new Bi;return i.id=e.id,i.achievedAt=e.achieved_at,i});remapDiscussionStats=t=>{let e=new kt;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}};var $t=class extends S{activityRemapper=null;constructor(t){super(t,L(t.environment,"loyalty")),this.activityRemapper=new $i}createActivity=async t=>{let e=`/activities${this.apiSignInUrl}`,i="There was a problem with creating activity",r="POST",o=await this.fetchWithAuth(e,i,r,t);return this.activityRemapper.remapSingleResponse(o)};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(),o="There was a problem with fetching own activities";t&&(i+=`${t.constructFilterUrl()}`),e&&(i+=`disable_cache=${r}`);let s=await this.fetchWithAuth(i,o);return this.activityRemapper.remapActivitiesResponse(s)};getActivitiesForUser=async(t,e,i)=>{let r=`/users/${t}/activities${this.apiSignInUrl}`,o=Date.now(),s=`There was a problem with fetching activities for user: ${t}`;e&&(r+=`${e.constructFilterUrl()}`),i&&(r+=`disable_cache=${o}`);let p=await this.fetchWithoutAuth(r,s);return this.activityRemapper.remapActivitiesResponse(p)};getStats=async(t,e)=>{let i="",r="",o=null;return t?(i+=R(e)?`/users/${t}/statistics${this.apiSignInUrl}${E()}`:`/users/${t}/statistics${this.apiSignInUrl}`,r=`There was a problem fetching statistics for profile: ${t}`,o=await this.fetchWithoutAuth(i,r)):(i+=`/statistics${this.apiSignInUrl}`,r="There was a problem fetching profile`s statistics",o=await this.fetchWithAuth(i,r)),this.activityRemapper.remapStatsResponse(o.data)}};var Wi=class{id="";source="";type="";favourite=!1};var Ki=class extends Wi{model=null};var ji=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 o=JSON.parse(JSON.stringify(t.successRates.byFootballCompetition)),s=await this.getEntitiesMap(r.competition,"competition"),p=await this.setSuccessRatesModels(o,s);t.successRates.byFootballCompetition=p,i.single.breakdown.footballCompetitions=this.reconstructBreakdown(i.single.breakdown.footballCompetitions,s)}if(Object.values(r.team).length){let o=JSON.parse(JSON.stringify(t.successRates.byFootballTeam)),s=await this.getEntitiesMap(r.team,"team"),p=await this.setSuccessRatesModels(o,s);t.successRates.byFootballTeam=p,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 o=i.get(r);e={...e,[o.id]:t[r]},e[o.id].model=o}),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(o=>o.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"),o=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),p=[];for(let[n,l]of Object.entries(i))l.forEach((c,m)=>{c.id=s[n][m],p.push(c)});return p.concat(o)}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 o=await this.remapIdsObj(e,this.idSchema,this.native);return t.id=o[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 o=new Ki;return o.id=r.id,o.type=r.type,o.source=r.source,o.favourite=r.favourite,o}):i};remapInterests=async t=>{let i=this.inquiryCustomInterests(t,!1);if(i&&i.length>0){let r=t.filter(s=>s.source.toLocaleUpperCase()!=="CUSTOM"),o=await this.remapInterestsToIdSchema(r);return i.forEach(s=>o.push(s)),o}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 o=t.filter(c=>c.source.toLocaleUpperCase()!=="CUSTOM"),{competitionsMap:s,teamsMap:p,playersMap:n}=await this.getInterestsEntitiesMap(o),l=o.map(c=>{let m=null;if(c.source.toLocaleUpperCase()==="FOOTBALL"){if(c.type==="competition")return m=s.get(c.id),m&&(c.id=m.id),c.model=m,c;if(c.type==="team")return m=p.get(c.id),m&&(c.id=m.id),c.model=m,c;if(c.type==="player")return n?(c.model=n[c.id],c.id=n[c.id].id):c.model=m,c}else return c.model=m,c});return e.push(l),e.flat()}return e};getInterestsEntitiesMap=async t=>{let e=[],i=[],r=[],o=new Map,s=new Map,p=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&&(o=await this.footballFacade.getCompetitionsMapWithNativeIds(e)),i.length&&(s=await this.footballFacade.getTeamsMapWithNativeIds(i)),r.length&&(p=await this.footballFacade.getPlayersMapWithNativeIds(r)),{competitionsMap:o,teamsMap:s,playersMap:p}};remapIdsObj=async(t,e,i)=>await this.idMapping.idMappingFacade.getEntitiesByIds(t,e,i)};var Xi=class{idMapping=null;profileOperations=null;constructor(t,e){this.idMapping=new T(t),this.profileOperations=new ji(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 lt=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 Tt(t),this.activityHttps=new $t(t),this.footballHttps=new Y(t),this.idMapping=new T(t),this.localCache=new k().createLocalCacheInstance(t.idSchema),this.footballFacade=new Ot(t,this.localCache,this.footballHttps,this.idMapping),this.profileFacade=new j(this.localCache,this.profileHttps,this.activityHttps),this.idsRemapper=new Xi(t,this.footballFacade),this.ownProfileBuilder=new Ke(this.idsRemapper,this.localCache,this.profileHttps,this.activityHttps,t.errorHandlingMode),this.profileBuilder=new je(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)=>await this.profileFacade.getByIds(t,e)};var wo=(h=>(h.EN="en",h.BG="bg",h.RO="ro",h.EL="el",h.SK="sk",h.PT="pt",h.SR="sr",h.HU="hu",h.SV="sv",h.ES="es",h.FR="fr",h.NL="nl",h.DE="de",h.IT="it",h))(wo||{});var Yi=class{validate=t=>{let e=this.validateField(t.lang),i=this.generateMessage(e);return{validation:e,message:i}};validateField=t=>{let e=Object.values(wo),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 qi=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"],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 Qi=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 zi=class{validate(t){let e=this.validateField(t.idSchema),i=this.generateMessage(e);return{validation:e,message:i}}validateField=t=>{let e=Object.values(B),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 yt=class{getIdToken=null;logout=null};var Kt=class{text=null;type=null};var Ji=class{validation=null;message=new Kt;getIdToken={validation:null,message:new Kt};logout={validation:null,message:new Kt}};var Zi=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 yt),i=new Ji;if(t){let o=Object.keys(t).filter(s=>!e.includes(s));o.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:"} ${o.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 yt).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 Pe=class{validation;message};var tr=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;errorHandlingMode=null;authProvider={getIdToken:new Pe,logout:new Pe};isValid=!1};var er=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 ir=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 rr=class{validate=t=>{let e=this.checkFieldsForValues(t);return e.isValid=this.containsErrorMessage(e),e};checkFieldsForValues=t=>{let e=new tr,i={apiKey:new Qi,environment:new qi,idSchema:new zi,clientId:new er,lang:new Yi,errorHandlingMode:new ir,authProvider:new Zi};for(let[r,o]of Object.entries(e))r!=="isValid"&&(o=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 jt=class{https=null;idMapping=null;localCache=null;footballFacade=null;constructor(t){this.https=new Y(t),this.idMapping=new T(t),this.localCache=new k().createLocalCacheInstance(t.idSchema),this.footballFacade=new Ot(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 or=class{value=null;playerId=null;playerModel=null};var Xt=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new or;result=null};var ar=class{value=!1;playerId=null};var V=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i,r){this.matchId=t,this.market=e,this.prediction=new ar,this.prediction.value=i,this.prediction.playerId=r}};var Yt=class{settledAt=null;resettledAt=null;status=null;outcome=null;points=0};var sr=class{value=null};var pt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new sr,this.prediction.value=i}};var $=class{value=!1};var qt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new $,this.prediction.value=i}};var Qt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new $,this.prediction.value=i}};var nr=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 V)e.market=t.market,e.prediction=t.prediction.value,e.player_id=t.prediction.playerId;else if(t instanceof qt||t instanceof Qt)e.market=t.market,e.prediction=t.prediction.value;else if(t instanceof pt){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=[],o=null,s=[];t.length>1&&t.sort((n,l)=>n.match_id.localeCompare(l.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 p=await this.matchFacade.getMatchesMapWithNativeIds(i);r.sort((n,l)=>n.localeCompare(l)),r&&r.length>0&&!r.includes(e)&&(o=await this.playerFacade.getPlayersMapWithNativeIds(r));for(let n of t){let l=new Xt;n.target?l.market=this.predictorService.convertMarketForResponseModel(n.market,n.target):l.market=n.market,l.matchId=p[n.match_id].id,l.matchType=n.match_type,l.matchModel=p?p[n.match_id]:null,delete l.matchModel.availableMarkets,n.goals_home!==void 0&&n.goals_away!==void 0?l.prediction.value=n.goals_home.toString()+":"+n.goals_away.toString():l.prediction.value=n.prediction,l.prediction.playerId=n.player_id?n.player_id:null,l.prediction.playerId&&l.prediction.playerId!==e&&(l.prediction.playerModel=o[n.player_id],l.prediction.playerId=o[n.player_id].id),l.result=this.remapResult(n.result),s.push(l)}return s};remapResult=t=>{let e=new Yt;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 Q=class{goldenGoal=null};var Fe=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new Q;points=null;createdAt=null;updatedAt=null};var I=class{no=0;yes=0};var lr=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new I;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new I;penaltyMatch=new I;playerScoreFirstGoal={};cornersMatch={};correctScore={};correctScoreHalfTime={};correctScoreAdvanced={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new I;overOnePointFiveGoals=new I;overTwoPointFiveGoals=new I;overThreePointFiveGoals=new I;overFourPointFiveGoals=new I;overFivePointFiveGoals=new I;overSixPointFiveGoals=new I;overSixPointFiveCorners=new I;overSevenPointFiveCorners=new I;overEightPointFiveCorners=new I;overNinePointFiveCorners=new I;overTenPointFiveCorners=new I;overElevenPointFiveCorners=new I;overTwelvePointFiveCorners=new I;overThirteenPointFiveCorners=new I};var z=class{timeTiebreaker=!1};var ct=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new z;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 Q};var Mt=class{userId=null;points=null;results=[];tiebreaker=null};var Io=(o=>(o.ACTIVE="ACTIVE",o.WON="WON",o.LOST="LOST",o.PARTIALLY_WON="PARTIALLY_WON",o.CANCELED="CANCELED",o))(Io||{}),xo=["WON","LOST","PARTIALLY_WON","CANCELED"];var A=class{limit=null;startAfter=null;status=null;type=null;matchIds=null;constructor(t){this.limit=t.limit?t.limit:null,this.startAfter=t.startAfter?t.startAfter:null,this.status=t.status?t.status:null,this.type=t.type?t.type:null,this.matchIds=t.matchIds?t.matchIds:null}constructFiltersUrl=()=>{let t="",e=!1;return this.status&&(e=Object.values(Io).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&&(t+="&",t+=`match_ids=${this.matchIds.join(",")}`),t}};var zt=class{limit;startAfter;constructor(t){this.limit=t.limit?t.limit:null,this.startAfter=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 pr=(s=>(s.OPEN="OPEN",s.LIVE="LIVE",s.PENDING="PENDING",s.CANCELED="CANCELED",s.CLOSED="CLOSED",s.SETTLED="SETTLED",s))(pr||{});var W=class extends zt{status=null;type=null;gameIds=null;sortOrder=null;constructor(t){super(t),this.status=t.status?t.status:null,this.type=t.type?t.type:null,this.gameIds=t.gameIds?t.gameIds:null,this.sortOrder=t.sortOrder?t.sortOrder:null}constructFiltersUrl=()=>{let t=super.constructMainFiltersUrl();return this.status&&Object.values(pr).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 Jt=class{main=null;cover=null;mobile=null};var tt=class{id=null;title=null;description=null;type=null;status=null;scheduleOpenAt=null;predictionsCutoff=null;fixtures=[];tiebreaker=new z;participantsCount=0;related=null;excludedProfileIds=null;rules=null;flags=null;images=new Jt;createdAt=null;updatedAt=null};var et=class{id=null;title=null;description=null;type=null;status=null;outcome=null;predictionsCutoff=null;fixtures=[];tiebreaker=new z;predictionId=null;participantsCount=0;related=null;excludedProfileIds=null;rules=null;flags=null;points=null;createdAt=null;updatedAt=null;predictionsMadeAt=null;images=null;scheduleOpenAt=null};var Zt=class extends tt{adContent=null;labels=null;customFields=null};var J=class{footballHttps=null;idMapping=null;matchFacade=null;playerFacade=null;profileNamespace=null;constructor(t,e){this.footballHttps=new Y(t),this.idMapping=e,this.matchFacade=new st(t,this.footballHttps,e),this.playerFacade=new at(t,this.footballHttps,e),this.profileNamespace=new lt(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=ut(t),o=(await this.idMapping.getEntityIdsBySchemaId(i,"player","native")).player;return i.forEach((s,p)=>e[s]=o[p]),e};remapPlayerIdToIdSchema=async t=>{let e=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"],i=[];for(let[o,s]of Object.entries(t))if(e.includes(o))for(let p of Object.keys(s))p!=="NOBODY"&&p!=="OWN_GOAL"&&i.push(p);if(!i.length)return t;let r=await this.playerFacade.getPlayersMapWithNativeIds(i);for(let[o,s]of Object.entries(t))if(e.includes(o))for(let p of Object.keys(s))p!=="NOBODY"&&p!=="OWN_GOAL"&&(s[r[p].id]=s[p],s[r[p].id].model=r[p],this.idMapping.idSchema!=="native"&&delete s[p]);return t};convertMarketForResponseModel=(t,e)=>{let i=e.toString();return t+"_"+i};getMarketSummary=async(t,e,i)=>{let r=Ko.get(e),o={};if(o.matchId=t.matchId,o.matchType=t.matchType,Object.keys(t.predictions).includes(r))o[r]=t.predictions[r];else throw new Error("You have passed invalid market");if(q.includes(e)&&i){let p="";if(i!=="OWN_GOAL"&&i!=="NOBODY"&&(p=(await this.idMapping.idMappingFacade.getEntitiesByIds({player:[i]},this.idMapping.idSchema,"native")).player[0]),p&&o[r][p]){let n=await this.playerFacade.getPlayersMapWithNativeIds([p]);return o[r][p].model=n[p],o[r][p]}else return p?(o[r][p]=new I,o[r][p]):o[r][i]}else if(q.includes(e)&&!i){let p=Object.keys(o[r]).filter(l=>l!=="NOBODY"&&l!=="OWN_GOAL"),n=p.length?await this.playerFacade.getPlayersMapWithNativeIds(p):{};Object.keys(n).length&&Object.keys(o[r]).forEach(l=>{l!=="NOBODY"&&l!=="OWN_GOAL"&&(o[r][n[l].id]=o[r][l],o[r][n[l].id].model=n[l],this.idMapping.idSchema!=="native"&&delete o[r][l])})}return o};remapCompetitionsFromConfig=async t=>{if(t instanceof Ct){let e={competition:t.fullCoverageCompetitions},i={competition:t.successRateScopes.competitions},r={team:t.successRateScopes.teams},o=await this.idMapping.idMappingFacade.getEntitiesByIds(e,"native",this.idMapping.idSchema),s=await this.idMapping.idMappingFacade.getEntitiesByIds(i,"native",this.idMapping.idSchema),p=await this.idMapping.idMappingFacade.getEntitiesByIds(r,"native",this.idMapping.idSchema);return t.fullCoverageCompetitions=o.competition,t.successRateScopes.competitions=s.competition,t.successRateScopes.teams=p.team,t}if(t instanceof St||t instanceof vt){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 tt||r instanceof ct||r instanceof et||r instanceof Zt?(r.fixtures.forEach(o=>e.push(o.matchId)),r instanceof et&&r.fixtures.forEach(o=>{o.prediction.playerId&&o.prediction.playerId!=="OWN_GOAL"&&i.push(o.prediction.playerId)})):r instanceof Mt&&r.results.forEach(o=>e.push(o.matchId))}),await this.refactorResponseArrModel(t,e,i)}else return t;else return await this.refactorResponseObjModel(t)};refactorResponseArrModel=async(t,e,i)=>{let r=[],o=await this.matchFacade.getMatchesMapWithNativeIds(e),s={};return i.length>0&&(s=await this.playerFacade.getPlayersMapWithNativeIds(i)),t.data.forEach(p=>{p instanceof tt||p instanceof ct||p instanceof et?(p.fixtures.forEach(n=>{this.handleMatchModel(o,n),p instanceof et&&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(p)):p instanceof Mt&&(p.results.forEach(n=>{n.matchModel=o[n.matchId],delete n.matchModel.availableMarkets,n.matchId=n.matchModel.id}),r.push(p))}),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(o=>i.push(o.predictionsCutoff)),t.data.sort((o,s)=>{let[p,n]=[o.predictionsCutoff,s.predictionsCutoff].map(l=>Math.abs(new Date(l)-e));return p-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 A(i),i};initGameFilters=(t,e,i)=>{if(e&&i)return e.type=t,e.gameIds=i,e=new W(e),e;if(e&&!i)return e.type=t,e=new W(e),e;if(!e&&i){let r={type:t,gameIds:i};return r=new W(r),r}else{let r={type:t};return r=new W(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((o,s)=>{r.fixtures[s].goals_home!==void 0&&r.fixtures[s].goals_away!==void 0?o.prediction.value=r.fixtures[s].goals_home+":"+r.fixtures[s].goals_away:o.prediction.value=r.fixtures[s].prediction,r.fixtures[s].player_id?o.prediction.playerId=r.fixtures[s].player_id:r.fixtures[s].target&&(o.prediction.target=r.fixtures[s].target),o.prediction.result=this.remapResult(r.fixtures[s].result)}),i.predictionsMadeAt=r.created_at,i.points=r.points,i instanceof ct&&(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 Yt;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 A(t));break;case"current":if(t)this.deleteUnexpectedProperties(t),t.status=["ACTIVE"],t=new A(t);else{let r={status:["ACTIVE"]};t=new A(r)}break;case"past":if(t)this.deleteUnexpectedProperties(t),t.status=xo,t=new A(t);else{let r={status:xo};t=new A(r)}break;case"matches":if(t)this.deleteUnexpectedProperties(t),t.matchIds=i,t=new A(t);else{let r={matchIds:i};t=new A(r)}break}return t};completeGameMarketResults=async(t,e)=>{switch(e){case"MATCH_QUIZ":let i={},r=t.results[0].matchId,o=t.results.map(l=>q.includes(l.market)&&!l.result.includes("OWN_GOAL")?[...l.result]:[]).flat(),s=await this.matchFacade.getMatchesMapWithNativeIds([r]);return o.length&&(i=await this.playerFacade.getPlayersMapWithNativeIds(o)),t.results=t.results.map(l=>{if(l.matchModel=s[l.matchId]?s[l.matchId]:null,l.playerModels&&Object.keys(i).length&&l.result.forEach(m=>{let d=i[m];l.playerModels.push(d)}),this.idMapping.idSchema!=="native"&&(this.remapMatchIdForResultsMarkets(s,l),l.playerModels&&Object.keys(i).length)){let c=l.result;l.result=c.map(m=>i[m].id)}return l}),t;case"TOP_X":let p=t.results.map(l=>l.matchId),n=await this.matchFacade.getMatchesMapWithNativeIds(p);if(t.results=t.results.map(l=>(l.matchModel=n[l.matchId]?n[l.matchId]:null,this.idMapping.idSchema!=="native"&&this.remapMatchIdForResultsMarkets(n,l),l)),t.tieBreakers.goldenGoals.length){let l=t.tieBreakers.goldenGoals.map(m=>m.playerId),c=await this.playerFacade.getPlayersMapWithNativeIds(l);t.tieBreakers.goldenGoals=t.tieBreakers.goldenGoals.map(m=>(m.matchModel=n[m.matchId],m.playerModel=c[m.playerId],this.idMapping.idSchema!=="native"&&(m.matchId=n[m.matchId].id,m.playerId=c[m.playerId].id),m))}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 o=i.filter(s=>s.id===r.profileId)[0];delete o.interests,r.profileModel=o})}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[v[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[v[this.idMapping.idSchema]]})};deleteUnexpectedProperties=t=>(t.status&&(console.warn(Co.UNEXPECTED_STATUS_PROP),delete t.status),t.type&&(console.warn(Co.UNEXPECTED_TYPE_PROP),delete t.type),t)};var te=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(t){this.gameInstanceId=t.gameInstanceId,t.fixtures.forEach(e=>this.fixtures.push(new pt(e.matchId,e.market,e.prediction.value))),this.tiebreaker=t.tiebreaker?t.tiebreaker:null}};var ee=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(t,e){this.footballHttps=new Y(t),this.matchFacade=new st(t,this.footballHttps,e),this.playerFacade=new at(t,this.footballHttps,e),this.predictorService=new J(t,e),this.fixturesRemapper=new nr(this.matchFacade,this.playerFacade,this.predictorService)}remapRequestBody=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=[],o={},s=[];t.forEach(n=>{n.fixtures.forEach(l=>{i.push(l.match_id),l.player_id&&l.player_id!==e&&r.push(l.player_id)})});let p=await this.matchFacade.getMatchesMapWithNativeIds(i);return r.length>0&&(o=await this.playerFacade.getPlayersMapWithNativeIds(r)),t.forEach(n=>{let l=new Fe,c=[];l.id=n.id,l.gameInstanceId=n.game_instance_id,l.gameType=n.game_type,l.wager=n.wager,l.totalFixtures=n.total_fixtures,l.settledFixtures=n.settled_fixtures,l.userId=n.user_id,n.fixtures.forEach(m=>{let d=new Xt;m.target?d.market=this.predictorService.convertMarketForResponseModel(m.market,m.target):d.market=m.market,d.matchId=p[m.match_id].id,d.matchType=m.match_type,d.matchModel=p[m.match_id],delete d.matchModel.availableMarkets,m.goals_home!==void 0&&m.goals_away!==void 0?d.prediction.value=m.goals_home.toString()+":"+m.goals_away.toString():d.prediction.value=m.prediction,d.prediction.playerId=m.player_id?m.player_id:null,d.prediction.playerId&&d.prediction.playerId!==e&&(d.prediction.playerModel=o[d.prediction.playerId],d.prediction.playerId=o[d.prediction.playerId].id),d.result=this.fixturesRemapper.remapResult(m.result),c.push(d)}),l.fixtures=c,l.status=n.status,n.tiebreaker?l.tiebreaker.goldenGoal=n.tiebreaker.golden_goal:l.tiebreaker=null,l.points=n.points,l.createdAt=n.created_at,l.updatedAt=n.updated_at,s.push(l)}),s}return t};remapResponseObjBody=async t=>{let e=new Fe;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.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 lr;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 cr=class{matchId=null;matchType=null;predictions=null};var mr=class{remapPredictions=null;constructor(t,e){this.remapPredictions=new ee(t,e)}remapResponse=t=>{let e=new cr;return e.matchId=t.match_id,e.matchType=t.match_type,e.predictions=this.remapPredictions.remapPredictionModel(t.predictions),e}};var dr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new U};var ur=class{value=null;target=null;playerId=null;playerModel=null;result=null};var hr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new U;prediction=new ur};var fr=class{value=null;result=null};var gr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new U;prediction=new fr};var yr=class{matchId=null;matchModel=null;outcome=null};var Mr=class{gameId=null;results=null;tieBreakers=null};var ie=class{entityId=null;entityType=null};var br=class{contestId="";contestType="GAME";contestModel=null;description="";userList=[]};var wr=class{position="";profileId="";profileModel=null;note="";tags=[]};var Ir=class{remapPaginatedGames=t=>{let e=new F;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 tt;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.images=t.images,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapGameByIdResponse=t=>{let e=new Zt;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.images=t.images,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapFixturesResponse=t=>{let e=new dr;return e.matchId=t.match_id,e.matchType=t.match_type,e.market=t.market,e.matchStatus.type=t.match_status.type,e.matchStatus.subType=t.match_status.sub_type,e};remapPaginatedUserTopXEditions=t=>{let e=new F;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 ct;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.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapTopXFixturesResponse=t=>{let e=new gr;return e.matchId=t.match_id,e.matchType=t.match_type,e.market=t.market,e.matchStatus.type=t.match_status.type,e.matchStatus.subType=t.match_status.sub_type,e};remapPaginatedUserMathQuizEditions=t=>{let e=new F;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 et;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.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapMatchQuizFixturesResponse=t=>{let e=new hr;return e.matchId=t.match_id,e.matchType=t.match_type,e.market=t.market,e.matchStatus.type=t.match_status.type,e.matchStatus.subType=t.match_status.sub_type,e};remapPaginatedGameResults=t=>{let e=new F;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 Mt;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 Mr;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 br;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 wr;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 U;return e.type=t.type,e.subType=t.sub_type,e};remapMarketResult=(t,e)=>{if(ba.includes(t))return e[0];if(q.includes(t))return e;if(e[0]==="true")return!0;if(e[0]==="false")return!1};deleteUnusefulField=t=>((!q.includes(t.market)||this.isPlayerMarketWithNoResult(t.market,t.result))&&delete t.playerModels,t);isPlayerMarketWithNoResult=(t,e)=>q.includes(t)&&e.length===0;remapResults=t=>{let e=new yr;return e.matchId=t.match_id,e.outcome=t.outcome,e};remapTiebreaker=t=>{let e=new Q;return e.goldenGoal=t.golden_goal,e};remapTimeTiebreaker=t=>{let e=new z;return e.timeTiebreaker=t,e};remapRelated=t=>t.map(e=>{let i=new ie;return i.entityId=e.entity_id,i.entityType=e.entity_type,i})};var Pr=class{remapMetaData=t=>{let e=new It;return e.pagination.nextPageStartsAfter=t.pagination.next_page_starts_after,e.pagination.itemsPerPage=t.pagination.items_per_page,e}};var Z=class extends S{predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;metaRemapper=null;constructor(t,e){super(t,L(t.environment,"predictor")),this.predictionRemapper=new ee(t,e),this.matchSummaryRemapper=new mr(t,e),this.gamesRemapper=new Ir,this.metaRemapper=new Pr}makeFootballPrediction=async t=>{let e=`/predictions${this.apiSignInUrl}`,i="There was a problem making POST request",r="POST",o=await this.fetchWithAuth(e,i,r,this.predictionRemapper.remapRequestBody(t));return await this.predictionRemapper.remapResponseObjBody(o)};getMatchSummary=async(t,e)=>{let i=R(e)?`/predictions/summary/${t}${this.apiSignInUrl}${E()}`:`/predictions/summary/${t}${this.apiSignInUrl}`,r=`There was a problem fetching predictions for match: ${t}`,o=await this.fetchWithoutAuth(i,r);return this.matchSummaryRemapper.remapResponse(o)};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 F,i=`/predictions${this.apiSignInUrl}`,r="There was a problem fetching own predictions";t&&(i+=`${t.constructFiltersUrl()}`);let o=await this.fetchWithAuth(i,r);return e.meta=this.metaRemapper.remapMetaData(o.meta),e.data=await this.predictionRemapper.remapResponseArrayBody(o.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 F,o=R(e)?`/predictions/users/${t}${this.apiSignInUrl}${E()}`:`/predictions/users/${t}${this.apiSignInUrl}`,s=`There was a problem fetching predictions for user: ${t}`;i&&(o+=`${i.constructFiltersUrl()}`);let p=await this.fetchWithoutAuth(o,s);return r.meta=this.metaRemapper.remapMetaData(p.meta),r.data=await this.predictionRemapper.remapResponseArrayBody(p.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=R(e)?`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}${E()}`:`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}`,r="There was a problem fetching the games list",o=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapPaginatedGames(o)};getGameById=async(t,e)=>{let i=R(e)?`/games/${t}${this.apiSignInUrl}${E()}`:`/games/${t}${this.apiSignInUrl}`,r=`There was a problem fetching the following game: ${t}`,o=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapGameByIdResponse(o)};getGamePredictions=async(t,e,i)=>{let r=new F,o=R(e)?`/games/${t}/predictions${this.apiSignInUrl}${E()}`:`/games/${t}/predictions${this.apiSignInUrl}`,s=`There was a problem fetching the predictions for game: ${t}`;i&&(o+=`${i.constructFiltersUrl()}`);let p=await this.fetchWithoutAuth(o,s);return r.meta=this.metaRemapper.remapMetaData(p.meta),r.data=await this.predictionRemapper.remapResponseArrayBody(p.data),r};getUserGameEditions=async(t,e)=>{let i=null,r=R(e)?`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}${E()}`:`/games/${this.apiSignInUrl}${t.constructFiltersUrl()}`,o="There was a problem fetching the games list",s=await this.fetchWithoutAuth(r,o);return s.data.forEach(p=>{p.type==="TOP_X"?i=this.gamesRemapper.remapPaginatedUserTopXEditions(s):p.type==="MATCH_QUIZ"&&(i=this.gamesRemapper.remapPaginatedUserMathQuizEditions(s))}),i};getGameResults=async(t,e,i)=>{let r=R(e)?`/games/${t}/results/${this.apiSignInUrl}${E()}`:`/games/${t}/results/${this.apiSignInUrl}`,o=`There was a problem fetching the results for the following game: ${t}`;i&&(r+=`${i.constructMainFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,o);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}`;R(e)&&(i+=`${E()}`);let o=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapGameMarketsResults(o.data)};getContestWinners=async t=>{let e=`/winners/${this.apiSignInUrl}&contest_id=${t}`,i=`There was a problem fetching winners for the following game: ${t}`,r=await this.fetchWithoutAuth(e,i);return this.gamesRemapper.remapContestWinners(r)};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]}};var re=class{gameInstanceId=null;fixtures=null};var Do=(i=>(i.ONE="1",i.X="x",i.TWO="2",i))(Do||{}),No=(i=>(i.ONE_X="1x",i.X_TWO="x2",i.ONE_TWO="12",i))(No||{}),Bo=(l=>(l.ONE_ONE="1/1",l.ONE_X="1/x",l.ONE_TWO="1/2",l.X_ONE="x/1",l.X_X="x/x",l.X_TWO="x/2",l.TWO_ONE="2/1",l.TWO_X="2/x",l.TWO_TWO="2/2",l))(Bo||{});var Fr=class{matchId=null;market="BOTH_TEAMS_SCORE";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new $,this.prediction.value=e}};var Tr=class{value};var _r=class{matchId=null;market="CORNERS_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new Tr,this.prediction.value=e}};var Rr=class{value=null};var Er=class{matchId=null;market="DOUBLE_CHANCE";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new Rr,this.prediction.value=e}};var vr=class{value=null};var Sr=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new vr,this.prediction.value=i}};var Cr=class{value=null};var Ar=class{matchId=null;market="HT_FT";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new Cr,this.prediction.value=e}};var Or=class{matchId=null;market="PENALTY_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new $,this.prediction.value=e}};var Lr=class{matchId=null;market="RED_CARD_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new $,this.prediction.value=e}};var mt=class{errorHandlingMode=null;constructor(t){this.errorHandlingMode=t}validateBodyFields=(t,e)=>{let i=Object.keys(e),r=Object.keys(new re);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 p="tiebreaker";i.includes(p)&&s.tiebreaker&&this.validateTiebreaker(s.tiebreaker),i.forEach(n=>{n!=="tiebreaker"&&!r.includes(n)&&this.throwInvalidParamException([n])});break}let o=r.filter(s=>!i.includes(s));return o.length&&this.throwMissingFieldsException("game prediction body",o),e.fixtures.forEach(s=>{this.validateFixtureFields(s)}),e};validateFixture=(t,e,i,r)=>{this.validateMarket(e);let o=Object.values(Do),s=Object.values(Bo),p=Object.values(No);if(e==="FT_1X2"||e==="HT_1X2"){if(o.includes(i))return new Sr(t,e,i)}else if(e==="HT_FT"){if(s.includes(i))return new Ar(t,i)}else if(e==="DOUBLE_CHANCE"){if(p.includes(i))return new Er(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 pt(t,e,i)}else if(e==="CORNERS_MATCH"){if(typeof i=="number")return new _r(t,i)}else if(e==="BOTH_TEAMS_SCORE"){if(this.isPredictionBoolean(i))return new Fr(t,i)}else if(e==="RED_CARD_MATCH"){if(this.isPredictionBoolean(i))return new Lr(t,i)}else if(e==="PENALTY_MATCH"){if(this.isPredictionBoolean(i))return new Or(t,i)}else if(q.includes(e)){let n="OWN_GOAL";if(this.validatePlayerId(e,r),e===be&&this.isPredictionBoolean(i)){let l=r&&r===n?n:r;return new V(t,e,i,l)}if(r&&this.isPredictionBoolean(i))return new V(t,e,i,r)}else if(ya.includes(e)){if(this.isPredictionBoolean(i))return new Qt(t,e,i)}else if(Ma.includes(e)&&this.isPredictionBoolean(i))return new qt(t,e,i);this.throwInvalidPredictionException(i,e)};validateFixtureFields=t=>{let e=Object.keys(t);e.forEach(r=>{So.includes(r)||this.throwInvalidParamException([r])});let i=So.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 Q)[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){q.includes(t)&&r.push("playerId");let o=i.filter(s=>!r.includes(s));o.length&&this.throwInvalidParamException(o)}}else this.throwInvalidType("prediction","object")};validatePlayerId=(t,e)=>{let i="playerId";t!==be&&(e||this.throwInvalidParamException([i]),typeof e!="string"&&this.throwInvalidType(i,"string"))};validateMarket=t=>{Object.values(G).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=jo(t,e);throw this.errorHandlingMode==="default"?new b(400,"INVALID_PREDICTION",i):new y(400,"INVALID_TYPE",i)};throwInvalidMarketException=(t,e)=>{let i=null;throw e&&e==="TOP_X"?i=Xo(t):i=ho(t),this.errorHandlingMode==="default"?new b(400,"INVALID_MARKET",i):new y(400,"INVALID_TYPE",i)};throwInvalidParamException=t=>{let e=Yo(t);throw this.errorHandlingMode==="default"?new b(400,"INVALID_FIELD",e):new y(400,"INVALID_TYPE",e)};throwMissingFieldsException=(t,e)=>{let i=qo(t,e);throw this.errorHandlingMode==="default"?new b(400,"INVALID_FIELD",i):new y(400,"INVALID_TYPE",i)};throwInvalidType=(t,e)=>{let i=Qo(t,e);throw this.errorHandlingMode==="default"?new b(400,"INVALID_TYPE",i):new y(400,"INVALID_TYPE",i)}};var xr=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 mt(t.errorHandlingMode),this.predictorService=new J(t,r)}makeFootballPrediction=async(t,e,i,r)=>{let o=this.predictorValidator.validateFixture(t,e,i,r),s=new re;if(this.idMapping.idSchema!=="native"){let p=o.matchId,n="",l=await this.predictorService.remapMatchIdToNative([p]);if(o.matchId=l[0],this.errorHandlingMode==="default"&&!o.matchId)throw new b(400,"INVALID_FIELD","Match id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&!o.matchId)throw new y(400,"INVALID_FIELD","Match id is invalid!");if(o instanceof V&&o.prediction.playerId!=="OWN_GOAL"){if(o.prediction.playerId&&(n=o.prediction.playerId,o.prediction.playerId=await this.predictorService.remapPlayerIdToNative([n])),this.errorHandlingMode==="default"&&o.market!==be&&!o.prediction.playerId)throw new b(400,"INVALID_FIELD","Player id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&o.market!==be&&!o.prediction.playerId)throw new y(400,"INVALID_FIELD","Player id is invalid!")}s.fixtures=[o];let c=await this.predictorHttps.makeFootballPrediction(s);return c.fixtures.forEach(m=>{m.prediction.playerId&&m.prediction.playerId!=="OWN_GOAL"&&(m.prediction.playerId=n),m.matchId=p}),c}else return s.fixtures=[o],await this.predictorHttps.makeFootballPrediction(s)};getMatchSummary=async(t,e)=>{let i=await this.getMatchSummaryBase(t,e),r=JSON.parse(JSON.stringify(i.predictions)),o=await this.predictorService.remapPlayerIdToIdSchema(r);return i.predictions=o,i};getMarketSummary=async(t,e,i,r)=>{try{let o=await this.getMatchSummaryBase(t,r);return await this.predictorService.getMarketSummary(o,e,i)}catch(o){throw o}};getMatchSummaryBase=async(t,e)=>{if(this.idMapping.idSchema!=="native"){let r=(await this.predictorService.remapMatchIdToNative([t]))[0],o=await this.predictorHttps.getMatchSummary(r,e);return o.matchId=t,o}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 b(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();if(this.errorHandlingMode==="standard"&&this.predictorService.areIdsExceeded(t))throw new y(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 b(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.").errorMessage();if(this.errorHandlingMode==="standard"&&this.predictorService.areIdsExceeded(e))throw new y(400,"EXCEEDED_LENGTH","Maximum matchIds in PredictionFilters should be 10 or less.");this.idMapping.idSchema!=="native"&&(e=await this.predictorService.remapMatchIdToNative([...e]));let o=this.predictorService.initPredictionsFilters(i,"matches",e);return await this.predictorHttps.getUserPredictions(t,r,o)};getPredictionById=async t=>await this.predictorHttps.getPredictionById(t)};var Dr=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(t){this.idMapping=new T(t),this.predictorHttps=new Z(t,this.idMapping),this.clientHttps=new H(t),this.predictorFacade=new xr(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)};var Nr=class{rankType=null;fromDate=null;toDate=null;pagination=new nt};var oe=class{position=null;profileId=null;profileModel=null;points=null;predictionsMade=null};var Br=class{remapResponse=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapData(t.data),t);remapMeta=t=>{let e=new Nr;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};remapData=t=>{let e=[];return t.forEach(i=>{let r=new oe;r.position=i.position,r.profileId=i.profile_id,r.points=i.points,r.predictionsMade=i.predictions_made,e.push(r)}),e}};var kr=class extends oe{id=null;rankType=null;model=null;gameType=null};var Hr=class{remapRankings=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapData(t.data),t);remapMeta=t=>{let e=new X;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 kr;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}};var Ur=class{flags="";status="";type="";activeFrom="";activeTo="";createdFrom="";createdTo="";updatedFrom="";updatedTo=""};var Gr=class{pagination=new nt;filters=new Ur};var ae=class{id=null;name=null;description=null;type=null;fromDate=null;toDate=null;markets=[];teamIds=[];matchIds=[];gameIds=[];gameTypes=[];competitionIds=[];excludedProfileIds=[];rules=null;flags=null;images=new Jt;status=null;automaticallyChangeStatus=!0;createdAt=null;updatedAt=null;related=null};var Vr=class extends ae{labels=null;customFields=null;adContent=null};var $r=class{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.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.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 Vr;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.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.adContent=t.ad_content,e.createdAt=t.created_at,e.updatedAt=t.updated_at,e};remapMeta=t=>{let e=new Gr;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 ie;return i.entityId=e.entity_id,i.entityType=e.entity_type,i})};var Wr=class{position=null;points=null;predictionsMade=null;profileId=null;profileModel=null;successRatePercent=null};var Kr=class{remapHighestSuccessRate=t=>t.map(e=>{let i=new Wr;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 jr=class extends S{templateRemapper=null;leaderboardRemapper=null;rankingsRemapper=null;highestSuccessRateRemapper=null;constructor(t){super(t,L(t.environment,"loyalty")),this.templateRemapper=new $r,this.leaderboardRemapper=new Br,this.rankingsRemapper=new Hr,this.highestSuccessRateRemapper=new Kr}getTemplates=async(t,e)=>{let i=t?`/leaderboard/templates/${this.apiSignInUrl}${t.constructFiltersUrl()}`:`/leaderboard/templates/${this.apiSignInUrl}`;i+=R(e)?E():"";let r="There was a problem fetching the list of templates",o=await this.fetchWithoutAuth(i,r),s=JSON.parse(JSON.stringify(o));return s.meta=this.templateRemapper.remapMeta(o.meta),s.data=this.templateRemapper.remapResponse(o.data),s};getTemplateById=async(t,e)=>{let i=R(e)?`/leaderboard/templates/${t}${this.apiSignInUrl}${E()}`:`/leaderboard/templates/${t}${this.apiSignInUrl}`,r=`There was a problem requesting the following template: ${t}`,o=await this.fetchWithoutAuth(i,r);return this.templateRemapper.remapResponseId(o.data)};getLeaderboard=async(t,e,i)=>{let r=R(e)?`/leaderboard/${t}/${this.apiSignInUrl}${E()}`:`/leaderboard/${t}/${this.apiSignInUrl}`,o=`There was a problem fetching the leaderboard for the following template: ${t}`;i&&(r+=`${i.constructFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,o),p=JSON.parse(JSON.stringify(s));return this.leaderboardRemapper.remapResponse(p)};getLeaderboardForGame=async(t,e,i)=>{let r=R(e)?`/leaderboard/games/${t}/${this.apiSignInUrl}${E()}`:`/leaderboard/games/${t}/${this.apiSignInUrl}`,o=`There was a problem fetching the leaderboard for the following game: ${t}`;i&&(r+=`${i.constructFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,o),p=JSON.parse(JSON.stringify(s));return this.leaderboardRemapper.remapResponse(p)};getUserRankings=async(t,e,i)=>{let r=`/leaderboard/users/${t}/rankings/${this.apiSignInUrl}`,o=`There was a problem fetching the rankings for the following user: ${t}`;e&&(r+=`${e.constructFiltersUrl()}`),R(i)&&(r+=`${E()}`);let s=await this.fetchWithoutAuth(r,o);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()}`),R(e)&&(i+=`${E()}`);let o=await this.fetchWithoutAuth(i,r);return this.highestSuccessRateRemapper.remapHighestSuccessRate(o.data)};getEntitiesFollows=async(t,e)=>{let i=R(e)?`/statistics/follows${this.apiSignInUrl}${E()}`:`/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}};var Xr=class{general;predictor;topX;matchQuiz};var se=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 Yr=class extends se{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 qr=class{idMappingService=null;profileNamespace=null;footballNamespace=null;errorHandlingMode=null;constructor(t){this.idMappingService=new T(t),this.profileNamespace=new lt(t),this.footballNamespace=new jt(t),this.errorHandlingMode=t.errorHandlingMode}remapTemplatesIds=async t=>{if(t.length>0){let e=[],i=[],r=[],o=[],s=[],p=[];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},l=await this.idMappingService.idMappingFacade.getEntitiesByIds(n,"native",this.idMappingService.idSchema);return i=[...l.team],o=[...l.match],p=[...l.competition],t.forEach(c=>{c.teamIds&&c.teamIds.length>0?c.teamIds=c.teamIds.map(m=>m=l.team.shift()):c.matchIds&&c.matchIds.length>0?c.matchIds=c.matchIds.map(m=>m=l.match.shift()):c.competitionIds&&c.competitionIds.length>0&&(c.competitionIds=c.competitionIds.map(m=>m=l.competition.shift()))}),t}return t};addProfileModelToLeaderboad=async t=>{if(t.length>0){let e=[],i=t.map(o=>o.profileId);if(!i.length)return t;let r=await this.profileNamespace.getByIds(i);return t.forEach(o=>{r.forEach(s=>{s.id===o.profileId&&(delete s.interests,o.profileModel=s)}),o.profileModel||(o.profileModel=null),e.push(o)}),e}return t};buildClientBadges=t=>{let e=new Xr;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};initFilters=(t,e)=>{switch(e){case"loyalty":t&&(t=new se(t));break;case"rankings":t&&(t=new Yr(t));break}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(o=>{o.id===r.profileId&&(delete o.interests,r.profileModel=o)}),r))};extractRankingsIdsMap=t=>{let e=[],i=[],r=[];return t.forEach(o=>{o.rankType==="GAME"&&o.gameType==="TOP_X"?e.push(o.id):o.rankType==="GAME"&&o.gameType==="MATCH_QUIZ"?i.push(o.id):o.rankType==="TEMPLATE"&&r.push(o.id)}),[e,i,r]};setModelsForUserRankings=(t,e,i,r)=>(r.data.forEach(o=>{o.gameType==="MATCH_QUIZ"&&e?o.model=e.filter(s=>s.id===o.id)[0]:o.gameType==="TOP_X"&&t?o.model=t.filter(s=>s.id===o.id)[0]:o.rankType==="TEMPLATE"&&i&&(o.model=i.filter(s=>s.id===o.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 o=i.filter(s=>s.id===r.profileId)[0];delete o.interests,r.profileModel=o})}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 b(400,"invalid_filters","At least one of footballCompetitions, footballTeams or footballPlayers properties should be provided for filters."):new y(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 b(400,"EXCEEDED_LENGTH","Maximum length per entity should be 24 or less."):new y(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 o=await this.idMappingService.idMappingFacade.getEntitiesByIds(r,this.idMappingService.idSchema,"native");return Object.keys(o).forEach(s=>{s==="competition"?i.footballCompetitions=o[s]:s==="team"?i.footballTeams=o[s]:s==="player"&&(i.footballPlayers=o[s])}),i};addModelsToEntitiesFollows=async t=>{let e=[],i="fb:c:",r=new Map,o=[],s="fb:t:",p=new Map,n=[],l="fb:p:",c=null;return t.breakdown.forEach(m=>{m.id.includes(i)?e.push(m.id):m.id.includes(s)?o.push(m.id):m.id.includes(l)&&n.push(m.id)}),e.length&&(r=await this.footballNamespace.footballFacade.competitionsFacade.getCompetitionsMapWithNativeIds(e)),o.length&&(p=await this.footballNamespace.footballFacade.teamsFacade.getTeamsMapWithNativeIds(o)),n.length&&(c=await this.footballNamespace.footballFacade.playerFacade.getPlayersMapWithNativeIds(n)),t.breakdown.forEach(m=>{m.id.includes(i)?(m.model=r.get(m.id),m.id=m.model.id):m.id.includes(s)?(m.model=p.get(m.id),m.id=m.model.id):m.id.includes(l)&&(m.model=c[m.id],m.id=m.model.id)}),t};extractEnabledBadgesId=t=>{let e=[];return t.forEach(i=>{i.enabled&&e.push(i.id)}),e}};var Qr=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(G).includes(t)){let r=ho(t);throw e==="default"?new b(400,"INVALID_MARKET",r):new y(400,"INVALID_MARKET",r)}};validateDate=(t,e,i)=>{let r=/^\d{4}-\d{2}-\d{2}$/;if(typeof t!="string")throw i==="default"?new b(400,"invalid_filters","You have provided invalid type. The valid type is "+`string for ${e} filter`):new y(400,"invalid_filters","You have provided invalid type. The valid type is "+`string for ${e} filter`);if(!r.test(t))throw i==="default"?new b(400,"invalid_filters","You have provided invalid value. The valid value is "+`YYYY-MM-DD for ${e}`):new y(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,o=e==="usersCount"?1e3:1e6;if(typeof t!="number")throw i==="default"?new b(400,"invalid_filters","You have provided invalid type. The valid type is "+`number for ${e} filter`):new y(400,"invalid_filters","You have provided invalid type. The valid type is "+`number for ${e} filter`);if(t<r||t>o)throw i==="default"?new b(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${o}`):new y(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${o}`)}};var ne=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 mt(t.errorHandlingMode),this.predictorHttps=new Z(t,e),this.predictorService=new J(t,e),this.clientHttps=new H(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 A(e)),await this.predictorHttps.getGamePredictions(t,i,e));getGameResults=async(t,e,i)=>{i=i||!1,e&&(e=new W(e));let r=await this.predictorHttps.getGameResults(t,i,e);return await this.predictorService.remapMatchIdsFixtures(r)};getCurrentGameResults=async t=>{t=t||!1;let e={status:"OPEN",type:"TOP_X"};e=new W(e);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 o=await this.predictorService.remapMatchIdToNative(r);e.fixtures.forEach(s=>s.matchId=o.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=[],o=await this.predictorHttps.getMyPredictionsNoRemap(i);if(o.data.length>0){o.data.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let s=this.predictorService.initGameFilters("TOP_X",null,r),p=await this.predictorHttps.getUserGameEditions(s,e);return await this.predictorService.addPredictionProp(o,p)}else return new F};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(o=>o.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),o=[],s=await this.predictorHttps.getUserPredictionsNoRemap(t,r);if(s.data.length>0){s.data.forEach(l=>{l.game_instance_id&&o.push(l.game_instance_id)});let p=this.predictorService.initGameFilters("TOP_X",null,o),n=await this.predictorHttps.getUserGameEditions(p,i);return await this.predictorService.addPredictionProp(s,n)}else return new F};getUserGamePrediction=async(t,e,i)=>{i=i||!1;let r=this.predictorService.initGameTypePredictions("TOP_X"),o=await this.predictorHttps.getUserPredictions(t,i,r);if(o.data.length>0){let s=o.data.filter(p=>p.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=>{let e=await this.predictorHttps.getContestWinners(t),i=await this.getGameById(t);return e.contestModel=i,this.predictorService.completeContestWinners(e)};validateLimitFilterOnGames=t=>{if(this.errorHandlingMode==="default"&&t>50)throw new b(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.");if(this.errorHandlingMode==="standard"&&t>50)throw new y(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.")}};var le=class{predictorHttps=null;predictorService=null;idMapping=null;clientHttps=null;predictorValidator=null;errorHandlingMode=null;constructor(t){this.predictorValidator=new mt(t.errorHandlingMode),this.idMapping=new T(t),this.predictorHttps=new Z(t,this.idMapping),this.predictorService=new J(t,this.idMapping),this.clientHttps=new H(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(p=>{i.push(p.matchId),p instanceof V&&p.prediction.playerId&&p.prediction.playerId!=="OWN_GOAL"&&r.push(p.prediction.playerId)});let o=await this.predictorService.remapMatchIdToNative(i),s={};r&&r.length>0&&(s=await this.predictorService.remapPlayerIdMapToNative(r)),e.forEach((p,n)=>{p.matchId=o[n],p instanceof V&&p.prediction.playerId!=="OWN_GOAL"&&(p.prediction.playerId=s[p.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 A(e)),await this.predictorHttps.getGamePredictions(t,i,e));getGameResults=async(t,e,i)=>{i=i||!1,e&&(e=new zt(e));let r=await this.predictorHttps.getGameResults(t,i,e);return await this.predictorService.remapMatchIdsFixtures(r)};getCurrentGameResults=async t=>{t=t||!1;let e={status:"OPEN",type:"MATCH_QUIZ"};e=new W(e);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=[],o=await this.predictorHttps.getMyPredictionsNoRemap(i);if(o.data.length>0){o.data.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let s=this.predictorService.initGameFilters("MATCH_QUIZ",null,r),p=await this.predictorHttps.getUserGameEditions(s,e);return await this.predictorService.addPredictionProp(o,p)}else return new F};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(o=>o.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),o=[],s=await this.predictorHttps.getUserPredictionsNoRemap(t,r);if(s.data.length>0){s.data.forEach(l=>{l.game_instance_id&&o.push(l.game_instance_id)});let p=this.predictorService.initGameFilters("MATCH_QUIZ",null,o),n=await this.predictorHttps.getUserGameEditions(p,i);return await this.predictorService.addPredictionProp(s,n)}else return new F};getUserGamePrediction=async(t,e,i)=>{i=i||!1;let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),o=await this.predictorHttps.getUserPredictions(t,i,r);if(o.data.length>0){let s=o.data.filter(p=>p.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=>{let e=await this.predictorHttps.getContestWinners(t),i=await this.getGameById(t);return e.contestModel=i,this.predictorService.completeContestWinners(e)};validateLimitFilterOnGames=t=>{if(this.errorHandlingMode==="default"&&t>50)throw new b(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.");if(this.errorHandlingMode==="standard"&&t>50)throw new y(400,"EXCEEDED_LENGTH","Maximum limit for filtering games is 50 or less.")}};var zr=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 Jr=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&&(t+="&",t+=`flags=${this.flags}`),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 Zr=class{config=null;clientHttps=null;loyaltyHttps=null;loyaltyService=null;profileFacade=null;loyaltyValidator=null;idMapping=null;topXFacade=null;matchQuizFacade=null;predictorHttps=null;errorHandlingMode=null;constructor(t,e,i,r,o){this.config=t,this.clientHttps=e,this.loyaltyHttps=i,this.profileFacade=new j(o,r),this.loyaltyService=new qr(this.config),this.loyaltyValidator=new Qr,this.idMapping=new T(t),this.topXFacade=new ne(t,this.idMapping),this.matchQuizFacade=new le(t),this.predictorHttps=new Z(t,this.idMapping),this.errorHandlingMode=t.errorHandlingMode}getConfig=async()=>await this.clientHttps.getConfig("loyalty");getClientBadges=async()=>{let t=await this.getConfig();return this.loyaltyService.buildClientBadges(t.rewards.badges)};getTemplates=async(t,e)=>{if(t&&(t=new Jr(t)),this.config.idSchema==="native")return await this.loyaltyHttps.getTemplates(t,e);let i=await this.loyaltyHttps.getTemplates(t,e);return i.data=await this.loyaltyService.remapTemplatesIds([...i.data]),i};getTemplateById=async(t,e)=>{let i=await this.loyaltyHttps.getTemplateById(t,e);return this.config.idSchema==="native"?i:(await this.loyaltyService.remapTemplatesIds([i]))[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.addProfileModelToLeaderboad(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.addProfileModelToLeaderboad(r.data),r};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 zr(t),this.loyaltyValidator.validate(t,this.errorHandlingMode));let i=await this.loyaltyHttps.getHighestSuccessRate(t,e);return this.loyaltyService.addProfileModelToHighestSuccessRate(i)};getTemplateWinners=async t=>{let e=await this.predictorHttps.getContestWinners(t),i=await this.getTemplateById(t);return e.contestModel=i,this.loyaltyService.completeContestWinners(e)};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,[o,s,p]=this.loyaltyService.extractRankingsIdsMap(t.data);if(p.length&&(e=(await this.getTemplates()).data.filter(l=>p.includes(l.id))),o.length){let n={gameIds:o};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)}};var to=class{clientHttps=null;profileHttps=null;loyaltyHttps=null;loyaltyFacade=null;localCache=null;constructor(t){this.clientHttps=new H(t),this.profileHttps=new Tt(t),this.loyaltyHttps=new jr(t),this.localCache=new k().createLocalCacheInstance(t.idSchema),this.loyaltyFacade=new Zr(t,this.clientHttps,this.loyaltyHttps,this.profileHttps,this.localCache)}getConfig=async()=>await this.loyaltyFacade.getConfig();getClientBadges=async()=>await this.loyaltyFacade.getClientBadges();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);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=>await this.loyaltyFacade.getTemplateWinners(t);getEntitiesFollows=async(t,e)=>await this.loyaltyFacade.getEntitiesFollows(t,e)};var eo=class{topXFacade=null;idMapping=null;constructor(t){this.idMapping=new T(t),this.topXFacade=new ne(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=>await this.topXFacade.getGameWinners(t)};var io=class{matchQuizFacade=null;constructor(t){this.matchQuizFacade=new le(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=>await this.matchQuizFacade.getGameWinners(t)};var Te=class{action=null;context=new Gt;constructor(t,e,i,r){this.action=t,this.context.tags=e,i&&(this.context.content=i),r&&(this.context.campaign=r)}};var ro=class{idSchema;idMapping;constructor(t){this.idSchema=t.idSchema,this.idMapping=new T(t)}remapTagsIds=async(t,e,i)=>{if(!t||!t.length)return t;let r={},o={},s=[];t.forEach(n=>{r.hasOwnProperty(n.type)||(r[n.type]=[],o[n.type]=[]),r[n.type].push(n.id),o[n.type].push(n)});let p=await this.idMapping.idMappingFacade.getEntitiesByIds(r,e,i);for(let[n,l]of Object.entries(o))l.forEach((c,m)=>{c.id=p[n][m],s.push(c)});return s}};var pe=class{page=null;limit=null;constructor(t){this.page=t.page?t.page:null,this.limit=t.limit?t.limit:null}};var oo=class extends pe{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 ao=class extends pe{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 so=class{idSchema;activityHttps;activityService;constructor(t){this.idSchema=t.idSchema,this.activityHttps=new $t(t),this.activityService=new ro(t)}add=async(t,e,i,r)=>{if(this.idSchema!="native"){let s=JSON.parse(JSON.stringify(e)),p=await this.activityService.remapTagsIds(e,this.idSchema,"native"),n=new Te(t,p,i,r),l=await this.activityHttps.createActivity(n);return l.context.tags=s,l}let o=new Te(t,e,i,r);return this.activityHttps.createActivity(o)};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 oo(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 ao(e)),this.idSchema!="native"){let r=await this.activityHttps.getActivitiesForUser(t,e,i),o=JSON.parse(JSON.stringify(r));for(let s of o.data)await this.activityService.remapTagsIds([...s.context.tags],"native",this.idSchema);return o}return await this.activityHttps.getActivitiesForUser(t,e,i)}};var no=class{activityFacade;constructor(t){this.activityFacade=new so(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 Po=null,ko=null;function zb(a){if(Ga(a)){let t=Va(a);if(t.isValid)return Po={profile:new lt(a),football:new jt(a),predictor:new Dr(a),loyalty:new to(a),topX:new eo(a),matchQuiz:new io(a),activity:new no(a)},ko={...a},Po;$a(t)}return Po}var Ga=a=>!Po||JSON.stringify(a)!==JSON.stringify(ko)||a.authProvider.getIdToken()!==ko.authProvider.getIdToken(),Va=a=>{let e=new rr().validate(a);return(e.idSchema.validation==="missing"||e.idSchema.validation==="invalid")&&(console.warn(e.idSchema.message.text),a.idSchema="native"),(e.environment.validation==="missing"||e.environment.validation==="invalid")&&(console.warn(e.environment.message.text),a.environment="prod"),(e.lang.validation==="missing"||e.lang.validation==="invalid")&&(console.warn(e.lang.message.text),a.lang="en"),(e.errorHandlingMode.validation==="missing"||e.errorHandlingMode.validation==="invalid")&&(console.warn(e.errorHandlingMode.message.text),a.errorHandlingMode="default"),e.authProvider.validation==="invalid"&&console.warn(e.authProvider.message.text),e},$a=a=>{let t="authProvider",e="isValid";Object.keys(a).forEach(i=>{let r=a[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 yt).forEach(o=>{if(r[o].message.type==="error")throw new Error(r[o].message.text)})})};export{zb as FansUnitedSDK};
|
|
4
4
|
//# sourceMappingURL=index.js.map
|