fansunited-sdk-esm 1.44.0 → 1.44.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  var Mo=Object.create;var wa=Object.defineProperty;var bo=Object.getOwnPropertyDescriptor;var wo=Object.getOwnPropertyNames;var Io=Object.getPrototypeOf,Po=Object.prototype.hasOwnProperty;var Fo=(o,t,e)=>t in o?wa(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var na=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports);var To=(o,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of wo(t))!Po.call(o,r)&&r!==e&&wa(o,r,{get:()=>t[r],enumerable:!(i=bo(t,r))||i.enumerable});return o};var _o=(o,t,e)=>(e=o!=null?Mo(Io(o)):{},To(t||!o||!o.__esModule?wa(e,"default",{value:o,enumerable:!0}):e,o));var Ia=(o,t,e)=>(Fo(o,typeof t!="symbol"?t+"":t,e),e);var Ya=na((ks,ma)=>{var So=function(){"use strict";function o(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 mt=[],Mt=[],bt=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,Fe;if(typeof f!="object")return f;if(o(f,t))P=new t;else if(o(f,e))P=new e;else if(o(f,i))P=new i(function(Te,u){f.then(function(_e){Te(N(_e,it-1))},function(_e){u(N(_e,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(bt&&Buffer.isBuffer(f))return Buffer.allocUnsafe?P=Buffer.allocUnsafe(f.length):P=new Buffer(f.length),f.copy(P),P;o(f,Error)?P=Object.create(f):typeof M>"u"?(Fe=Object.getPrototypeOf(f),P=Object.create(Fe)):(P=Object.create(M),Fe=M)}if(m){var Da=mt.indexOf(f);if(Da!=-1)return Mt[Da];mt.push(f),Mt.push(P)}o(f,t)&&f.forEach(function(Te,u){var _e=N(u,it-1),yo=N(Te,it-1);P.set(_e,yo)}),o(f,e)&&f.forEach(function(Te){var u=N(Te,it-1);P.add(u)});for(var K in f){var ba;Fe&&(ba=Object.getOwnPropertyDescriptor(Fe,K)),!(ba&&ba.set==null)&&(P[K]=N(f[K],it-1))}if(Object.getOwnPropertySymbols)for(var Na=Object.getOwnPropertySymbols(f),K=0;K<Na.length;K++){var oa=Na[K],le=Object.getOwnPropertyDescriptor(f,oa);le&&!le.enumerable&&!h||(P[oa]=N(f[oa],it-1),le.enumerable||Object.defineProperty(P,oa,{enumerable:!1}))}if(h)for(var Ba=Object.getOwnPropertyNames(f),K=0;K<Ba.length;K++){var sa=Ba[K],le=Object.getOwnPropertyDescriptor(f,sa);le&&le.enumerable||(P[sa]=N(f[sa],it-1),Object.defineProperty(P,sa,{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 a(c){return Object.prototype.toString.call(c)}r.__objToStr=a;function s(c){return typeof c=="object"&&a(c)==="[object Date]"}r.__isDate=s;function p(c){return typeof c=="object"&&a(c)==="[object Array]"}r.__isArray=p;function n(c){return typeof c=="object"&&a(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 ma=="object"&&ma.exports&&(ma.exports=So)});var oo=na((Hs,Sa)=>{"use strict";var de=typeof Reflect=="object"?Reflect:null,qa=de&&typeof de.apply=="function"?de.apply:function(t,e,i){return Function.prototype.apply.call(t,e,i)},da;de&&typeof de.ownKeys=="function"?da=de.ownKeys:Object.getOwnPropertySymbols?da=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:da=function(t){return Object.getOwnPropertyNames(t)};function Co(o){console&&console.warn&&console.warn(o)}var za=Number.isNaN||function(t){return t!==t};function w(){w.init.call(this)}Sa.exports=w;Sa.exports.once=xo;w.EventEmitter=w;w.prototype._events=void 0;w.prototype._eventsCount=0;w.prototype._maxListeners=void 0;var Qa=10;function ua(o){if(typeof o!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof o)}Object.defineProperty(w,"defaultMaxListeners",{enumerable:!0,get:function(){return Qa},set:function(o){if(typeof o!="number"||o<0||za(o))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+o+".");Qa=o}});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||za(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 Ja(o){return o._maxListeners===void 0?w.defaultMaxListeners:o._maxListeners}w.prototype.getMaxListeners=function(){return Ja(this)};w.prototype.emit=function(t){for(var e=[],i=1;i<arguments.length;i++)e.push(arguments[i]);var r=t==="error",a=this._events;if(a!==void 0)r=r&&a.error===void 0;else if(!r)return!1;if(r){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var p=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw p.context=s,p}var n=a[t];if(n===void 0)return!1;if(typeof n=="function")qa(n,this,e);else for(var l=n.length,c=ro(n,l),i=0;i<l;++i)qa(c[i],this,e);return!0};function Za(o,t,e,i){var r,a,s;if(ua(e),a=o._events,a===void 0?(a=o._events=Object.create(null),o._eventsCount=0):(a.newListener!==void 0&&(o.emit("newListener",t,e.listener?e.listener:e),a=o._events),s=a[t]),s===void 0)s=a[t]=e,++o._eventsCount;else if(typeof s=="function"?s=a[t]=i?[e,s]:[s,e]:i?s.unshift(e):s.push(e),r=Ja(o),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=o,p.type=t,p.count=s.length,Co(p)}return o}w.prototype.addListener=function(t,e){return Za(this,t,e,!1)};w.prototype.on=w.prototype.addListener;w.prototype.prependListener=function(t,e){return Za(this,t,e,!0)};function Ao(){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 to(o,t,e){var i={fired:!1,wrapFn:void 0,target:o,type:t,listener:e},r=Ao.bind(i);return r.listener=e,i.wrapFn=r,r}w.prototype.once=function(t,e){return ua(e),this.on(t,to(this,t,e)),this};w.prototype.prependOnceListener=function(t,e){return ua(e),this.prependListener(t,to(this,t,e)),this};w.prototype.removeListener=function(t,e){var i,r,a,s,p;if(ua(e),r=this._events,r===void 0)return this;if(i=r[t],i===void 0)return this;if(i===e||i.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,i.listener||e));else if(typeof i!="function"){for(a=-1,s=i.length-1;s>=0;s--)if(i[s]===e||i[s].listener===e){p=i[s].listener,a=s;break}if(a<0)return this;a===0?i.shift():Oo(i,a),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 a=Object.keys(i),s;for(r=0;r<a.length;++r)s=a[r],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=i[t],typeof e=="function")this.removeListener(t,e);else if(e!==void 0)for(r=e.length-1;r>=0;r--)this.removeListener(t,e[r]);return this};function eo(o,t,e){var i=o._events;if(i===void 0)return[];var r=i[t];return r===void 0?[]:typeof r=="function"?e?[r.listener||r]:[r]:e?Lo(r):ro(r,r.length)}w.prototype.listeners=function(t){return eo(this,t,!0)};w.prototype.rawListeners=function(t){return eo(this,t,!1)};w.listenerCount=function(o,t){return typeof o.listenerCount=="function"?o.listenerCount(t):io.call(o,t)};w.prototype.listenerCount=io;function io(o){var t=this._events;if(t!==void 0){var e=t[o];if(typeof e=="function")return 1;if(e!==void 0)return e.length}return 0}w.prototype.eventNames=function(){return this._eventsCount>0?da(this._events):[]};function ro(o,t){for(var e=new Array(t),i=0;i<t;++i)e[i]=o[i];return e}function Oo(o,t){for(;t+1<o.length;t++)o[t]=o[t+1];o.pop()}function Lo(o){for(var t=new Array(o.length),e=0;e<t.length;++e)t[e]=o[e].listener||o[e];return t}function xo(o,t){return new Promise(function(e,i){function r(s){o.removeListener(t,a),i(s)}function a(){typeof o.removeListener=="function"&&o.removeListener("error",r),e([].slice.call(arguments))}ao(o,t,a,{once:!0}),t!=="error"&&Do(o,r,{once:!0})})}function Do(o,t,e){typeof o.on=="function"&&ao(o,"error",t,e)}function ao(o,t,e,i){if(typeof o.on=="function")i.once?o.once(t,e):o.on(t,e);else if(typeof o.addEventListener=="function")o.addEventListener(t,function r(a){i.once&&o.removeEventListener(t,r),e(a)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof o)}});var lo=na((so,no)=>{(function(){var o,t,e,i=[].splice,r=function(s,p){if(!(s instanceof p))throw new Error("Bound instance method accessed before binding")},a=[].indexOf;e=Ya(),o=oo().EventEmitter,no.exports=t=function(){class s extends o{constructor(n={}){super(),this.get=this.get.bind(this),this.mget=this.mget.bind(this),this.set=this.set.bind(this),this.mset=this.mset.bind(this),this.del=this.del.bind(this),this.take=this.take.bind(this),this.ttl=this.ttl.bind(this),this.getTtl=this.getTtl.bind(this),this.keys=this.keys.bind(this),this.has=this.has.bind(this),this.getStats=this.getStats.bind(this),this.flushAll=this.flushAll.bind(this),this.flushStats=this.flushStats.bind(this),this.close=this.close.bind(this),this._checkData=this._checkData.bind(this),this._check=this._check.bind(this),this._isInvalidKey=this._isInvalidKey.bind(this),this._wrap=this._wrap.bind(this),this._getValLength=this._getValLength.bind(this),this._error=this._error.bind(this),this._initErrors=this._initErrors.bind(this),this.options=n,this._initErrors(),this.data={},this.options=Object.assign({forceString:!1,objectValueSize:80,promiseValueSize:80,arrayValueSize:40,stdTTL:0,checkperiod:600,useClones:!0,deleteOnExpire:!0,enableLegacyCallbacks:!1,maxKeys:-1},this.options),this.options.enableLegacyCallbacks&&(console.warn("WARNING! node-cache legacy callback support will drop in v6.x"),["get","mget","set","del","ttl","getTtl","keys","has"].forEach(l=>{var c;c=this[l],this[l]=function(...m){var d,M,h,mt;if(h=m,[...m]=h,[d]=i.call(m,-1),typeof d=="function")try{mt=c(...m),d(null,mt)}catch(Mt){M=Mt,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,mt,Mt,bt,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,mt=n.length;m<mt;m++){if(h=n[m],{key:M,val:N,ttl:bt}=h,bt&&typeof bt!="number")throw l=this._error("ETTLTYPE"),l;if((c=this._isInvalidKey(M))!=null)throw c}for(d=0,Mt=n.length;d<Mt;d++)h=n[d],{key:M,val:N,ttl:bt}=h,this.set(M,N,bt);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,a.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(so)});var mo=na((po,co)=>{(function(){var o;o=co.exports=lo(),o.version="5.1.2"}).call(po)});var Pa=o=>{let t=200,e=[],i=0;return e[i]=[],o.forEach(r=>{e[i].length<=t-1?e[i].push(r):(i++,e[i]=[r])}),e},pe=(o,t)=>{let e=[];for(;o.length>t;){let i=o.splice(0,t);e.push(i)}return e.push(o),e},L=(o,t)=>{let e="",i={profile:"https://profile.fansunitedapi.com/v1",football:"https://football.fansunitedapi.com/v1",idMapping:"https://id-mapping.fansunitedapi.com/v1",predictor:"https://prediction.fansunitedapi.com/v1",client:"https://client.fansunitedapi.com/v1",loyalty:"https://loyalty.fansunitedapi.com/v1"},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"},a={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 o==="prod"?e=i[t]:o==="dev"?e=r[t]:e=a[t],e},dt=o=>o.filter((e,i,r)=>i===r.indexOf(e)),R=o=>o||!1,E=()=>`&disable_cache=${Date.now()}`,la=o=>JSON.parse(JSON.stringify(o.sort((t,e)=>t.localeCompare(e))));var Re=class{id=null;name=null;nickname=null;avatar=null;gender=null;country=null;birthDate=null;interests=[];followingCount=0;followersCount=0};var Ee=class{profilesFromResponse=t=>t?t.map(e=>this.fullProfileFromResponse(e)):null;fullProfileFromResponse=t=>{let e=new Re;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 ve=class{nextPageStartsAfter=null;itemsPerPage=null};var wt=class{pagination=new ve};var F=class{meta=new wt;data=[]};var Se=class{avatar=null;followingId=null;name=null;nickname=null;profileId=null};var Ce=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 Se;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 Ae=class{avatar=null;followerId=null;name=null;nickname=null;profileId=null};var Oe=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 Ae;return e.avatar=t.avatar,e.followerId=t.follower_id,e.name=t.name,e.profileId=t.profile_id,e}};var ce=class{profile_ids=[]};function Fa(o){this.message=o}Fa.prototype=new Error,Fa.prototype.name="InvalidCharacterError";var Ha=typeof window<"u"&&window.atob&&window.atob.bind(window)||function(o){var t=String(o).replace(/=+$/,"");if(t.length%4==1)throw new Fa("'atob' failed: The string to be decoded is not correctly encoded.");for(var e,i,r=0,a=0,s="";i=t.charAt(a++);~i&&(e=r%4?64*e+i:i,r++%4)?s+=String.fromCharCode(255&e>>(-2*r&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return s};function Ro(o){var t=o.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(Ha(e).replace(/(.)/g,function(i,r){var a=r.charCodeAt(0).toString(16).toUpperCase();return a.length<2&&(a="0"+a),"%"+a}))}(t)}catch{return Ha(t)}}function pa(o){this.message=o}function Eo(o,t){if(typeof o!="string")throw new pa("Invalid token specified");var e=(t=t||{}).header===!0?0:1;try{return JSON.parse(Ro(o.split(".")[e]))}catch(i){throw new pa("Invalid token specified: "+i.message)}}pa.prototype=new Error,pa.prototype.name="InvalidTokenError";var Ua=Eo;var v={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id",api_football:"api_football_id"},Ta={PREDICTOR_USER_RELATED_OPERATION:"https://docs.fansunitedmedia.com/docs/predictor-operations#user-related-operations"},_a=["matchId","matchType","market","prediction"],Ga=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 Ra={UNEXPECTED_STATUS_PROP:`Unexpected provided property 'status'. You can NOT use this property for this method. For more information visit our documentation:
2
2
  ${Ta.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
- ${Ta.PREDICTOR_USER_RELATED_OPERATION}`},Va=(o,t)=>`The prediction '${o}' is invalid for market '${t}'. Please check again have you passed appropriate prediction model. For more information please visit our documentation: https://docs.fansunitedmedia.com/sdks/js/match.quiz#gamerelatedoperations`,ca=o=>`The market '${o}' is not supported from Fans United. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,$a=o=>`The market '${o}' is not valid for Top X game. The only available market is CORRECT_SCORE.`,Wa=o=>`The field/s '${o.length>1?o.join(", "):o[0]}' is/are invalid. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/javascript-sdk`,Ka=(o,t)=>`The following field/s is/are missing from ${o}: '${t.length>1?t.join(", "):t[0]}'. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,ja=(o,t)=>`The field ${o} has incorrect type. The correct type is ${t}`;var ut=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 a=this.transformFetchException(i,r);throw console.warn(e,a),a}return r};fetchWithAuth=async(t,e,i,r)=>{this.validateJWTToken();let a=null,s=null;if(i&&r?a=await fetch(this.baseUrl+t,{method:i,headers:this.authHeaders,body:JSON.stringify(r)}):i&&!r?a=await fetch(this.baseUrl+t,{method:i,headers:this.authHeaders}):a=await fetch(this.baseUrl+t,{headers:this.authHeaders}),i!=="DELETE"&&(s=await a.json()),!a.ok){(a.status===401||a.status===403)&&!this.retryRequest&&(this.retryRequest=!0,await this.fetchWithAuth(t,e,i,r)),this.retryRequest=!1;let p=this.transformFetchException(a,s||await a.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 ut(t,s)}let{code:i,status:r,message:a}=e.error;return this.errorHandlingMode==="standard"?new y(i,r,a):new ut(t,e.error)};validateJWTToken=()=>{let t=null;try{t=Ua(this.jwtToken)}catch(i){if(this.errorHandlingMode==="default"){let r={status:401,statusText:i.message,headers:{}},a={code:401,status:"invalid_token",message:"Invalid JWT token is provided"};throw new ut(r,a)}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 ut(i,r)}else if(this.errorHandlingMode==="standard")throw new y(401,"invalid_token","The provided JWT token is expired")}}};var vo="/countries",x="/profile",Ea="/profiles",Ft=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 Ee,this.followingRemapper=new Ce,this.followersRemapper=new Oe}getCountries=async t=>{let e=`&lang=${this.lang}`,i=`${vo}${this.apiSignInUrl}${e}`,r=Date.now(),a="There was a problem fetching profile countries";return t&&(i+=`&disable_cache=${r}`),(await this.fetchWithoutAuth(i,a)).data};getProfile=async t=>{let e=`${x}${this.apiSignInUrl}`,i="";if(t){e=`${Ea}/${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=pe(t,this.limitIds);for(let l of n){let c=`${Ea}${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 a=`${Ea}${this.apiSignInUrl}&profile_ids=${t.join(",")}`;e&&(a+=`&disable_cache=${i}`);let s=await this.fetchWithoutAuth(a,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 a=await this.fetchWithoutAuth(i,r);return this.followersRemapper.followersFromResponse(a)};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 a=await this.fetchWithoutAuth(i,r);return this.followingRemapper.followingFromResponse(a)};follow=async t=>{let e=new ce;e.profile_ids=t;let i=x+`/follow${this.apiSignInUrl}`,r=`There was a problem with following profiles: ${t.join(",")}`,a="POST",s=await this.fetchWithAuth(i,r,a,e);return this.followingRemapper.followResponse(s.data)};unfollow=async t=>{let e=new ce;e.profile_ids=t;let i=x+`/follow${this.apiSignInUrl}`,r=`There was a problem with unfollowing profiles: ${t.join(",")}`,a="DELETE";return await this.fetchWithAuth(i,r,a,e),!0};getBadges=async t=>{let e=`${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",a=await this.fetchWithAuth(e,i,r,t);return this.profileRemapper.fullProfileFromResponse(a.data)}};var B=(a=>(a.NATIVE="native",a.ENETPULSE="enetpulse",a.SPORTRADAR="sportradar",a.SPORTAL_365="sportal365",a.API_FOOTBALL="api_football",a))(B||{});var Le={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},xe=class extends S{constructor(t){super(t,L(t.environment,"idMapping"))}getEntityById=async(t,e)=>{let i=`/football${this.apiSignInUrl}&input_provider=${this.idSchema}&${Le[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}&${Le[t]}=${e}`,a=`There was a problem with id mapping request for the following id: ${e}`;return await this.fetchWithoutAuth(r,a)};getEntityIdsByIdsAndSchema=async(t,e,i)=>{let r=`/football${this.apiSignInUrl}&input_provider=${i}&${Le[t]}=${e.join(",")}`,a=`There was a problem with id mapping request for the following ids: ${e.join(",")}`;return await this.fetchWithoutAuth(r,a)};getEntitiesByIds=async(t,e,i)=>{e.sort((s,p)=>s.localeCompare(p));let r=Pa(e),a=[];for(let s of r){let p=`/football${this.apiSignInUrl}&input_provider=${i}&${Le[t]}=${s.join(",")}`,n=`There was a problem with id mapping request for the following ids :${s.join(",")}`,l=await this.fetchWithoutAuth(p,n);a=[...a,...l.data]}return a};getEntitiesByIdObjs=async(t,e)=>{let i=[],r={},a=[];Object.keys(t).forEach(l=>{i.push.apply(i,t[l])});let s=dt(i),p=Pa(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+=`${Le[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);a.push(M.data)}else a.push([])}return Array.prototype.concat.apply([],a)};getTopEntities=async()=>{let t=`/football/top${this.apiSignInUrl}`,e="There was a problem with top id mappings request";return(await this.fetchWithoutAuth(t,e)).data}};var Xa="FansUnited",va={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}}},De=class{idSchema="";expirationProfileTimeout=600;expirationBadgesTimeout=3600;expirationClientFeaturesTimeout=14400;expirationFootballIdsTimeout=604800;constructor(t){this.idSchema=t,(this.getData()===void 0||this.getData()===null)&&this.setData(va)}clearData=()=>{this.setData(va)};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 a=v[i];return r&&t.includes(`${r[a]}`)&&r.resource===e}):this.getData().football.ids.find(r=>{let a=v[i];return r&&`${r[a]}`===t&&r.resource===e});getEntityByNativeId=(t="",e="")=>this.getData().football.ids.find(i=>i&&`${i.id}`===e&&i.resource===t);checkForExistingIdObjs=(t,e)=>{let i=v[e],r={};return Object.keys(t).forEach(a=>{let s=t[a],n=this.getEntity(s,a,e).map(c=>c[i]),l=t[a].filter(c=>!n.includes(c));r[a]=s.map(c=>l.includes(c)?{id:c,exists:!1}:{id:c,exists:!0})}),r};getIdsByType=(t,e,i)=>{let r=v[i],a=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[a]&&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(Xa));setData=t=>{localStorage.setItem(Xa,JSON.stringify(t))};initialNewSchema=(t,e)=>{let i=this.getData();(!i||!i[t]||!i[t][e])&&this.setData(va)}};var uo=_o(mo());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 a=v[this.idSchema];return r&&`${r[a]}`===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(a=>{let s=v[i];return a&&t.includes(`${a[s]}`)&&a.resource===e}):r.find(a=>{let s=v[i];return a&&`${a[s]}`===t&&a.resource===e})};checkForExistingIdObjs=(t,e)=>{let i=v[e],r={};return Object.keys(t).forEach(a=>{let s=t[a],n=this.getEntity(s,a,e).map(c=>c[i]),l=t[a].filter(c=>!n.includes(c));r[a]=s.map(c=>l.includes(c)?{id:c,exists:!1}:{id:c,exists:!0})}),r};getIdsByType=(t,e,i)=>{let r=v[i],a=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[a]&&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(a=>a.resource!=="match"),t=t.filter(a=>a.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"}}},Tt=g;Ia(Tt,"instance"),Ia(Tt,"nodeCache",new uo.default);var k=class{createLocalCacheInstance=t=>typeof window>"u"?Tt.getInstance(t):new De(t)};var Ne=class{localCache=null;https=null;constructor(t){this.localCache=new k().createLocalCacheInstance(t.idSchema),this.https=new xe(t)}getEntitiesByIds=async(t,e,i)=>{await this.setTopIdMappings();try{let r=this.localCache.checkForExistingIdObjs(t,e),a=this.splitForRequestAndExisting(r),s=await this.https.getEntitiesByIdObjs(a.request,e);return this.localCache.addIdMappings(s),this.localCache.getIdsByType(t,e,i)}catch(r){return console.warn("There was a problem retrieving the entity ids ",r),Promise.resolve([])}};getEntityById=async(t,e,i)=>{let r=this.localCache.getEntity(t,e,i);if(r)return r;let a=await this.requestEntity(t,e,i);return this.localCache.addIdMappings(a),a};splitForRequestAndExisting=t=>{let e={},i={};return Object.keys(t).forEach(r=>{e[r]=t[r].filter(a=>!a.exists).map(a=>a.id),i[r]=t[r].filter(a=>a.exists).map(a=>a.id)}),{existing:i,request:e}};requestEntity=async(t,e,i)=>{try{return t=Array.isArray(t)?t:[t],await this.https.getEntitiesByIds(e,t,i)}catch(r){return console.warn(`There was a problem retrieving the requested entity: ${r}`),null}};setTopIdMappings=async()=>{let t=Math.floor(Date.now()/1e3);if(this.localCache.getExpiration("football","ids")>t)return Promise.resolve();let i=await this.https.getTopEntities();this.localCache.addTopIdMappings(i)}};var ha=o=>{switch(o){case"competitions":return"competition";case"players":case"relatedPlayer":case"squad":return"player";case"teams":case"participants":case"homeTeam":case"awayTeam":case"timeline":case"teamId":return"team";default:return o}};var Be=class{extractedObjIds={};traverse=(t,e)=>(e=ha(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 ke=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(t,e,i)=>(e=ha(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 Ne(t)}getEntityIdBySchemaId=(t,e)=>this.idMappingFacade.getEntityById(e,t,this.idSchema);remapEntities=async(t,e)=>{let i=JSON.parse(JSON.stringify(t));try{if(this.idSchema!=="native"){let a=new Be().traverse(i,e);return this.idMappingFacade.getEntitiesByIds(a,"native",this.idSchema).then(s=>new ke().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 He=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 Ue=class{totalPercentage;breakdown=new He};var ue=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 ue(t));let i=await this.profileHttps.getFollowers(t,e),r=i.data.map(a=>a.followerId);if(r.length){let a=await this.getByIds(r),s=i.data.map(p=>(a.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 ue(t));let i=await this.profileHttps.getFollowing(t,e),r=i.data.map(a=>a.followingId);if(r.length){let a=await this.getByIds(r),s=i.data.map(p=>(a.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 Ue,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 Ge=class{id=null;name=null;assets=null};var Ve=class{extractUpdatedProps=(t,e)=>{let i=["name","nickname","gender","avatar"],r={};return Object.keys(t).forEach(a=>{if(i.includes(a)&&t[a]!==e[a])r[a]=e[a];else if(a==="birthDate")(e[a]===null||t[a]===null&&e[a]||t[a]!==e[a])&&(r.birth_date=e[a]);else if(a==="country")e[a]===null?r.country_id=e[a]:(t[a]===null&&e[a]||t[a].id!==e[a].id)&&(r.country_id=e[a].id);else if(a==="interests"){let s=t[a],p=e[a];p.length&&this.isNewInterest(s,p)?r[a]=this.updateInterests(s,p):(!p.length&&s.length||s.length!==p.length&&!this.isNewInterest(s,p))&&(r[a]=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(a=>t.some(s=>a.id===s.id&&a.type===s.type&&a.source===s.source&&a.favourite===s.favourite));return[e.filter(a=>!t.some(s=>a.id===s.id&&a.type===s.type&&a.source===s.source&&a.favourite===s.favourite)),i]};isAvatarValidURL=t=>{try{return new URL(t),!0}catch{return!1}}};var 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 $e=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,a){this.idsRemapper=t,this.localCache=e,this.profileHttps=i,this.errorHandlingMode=a,this.profileService=new Ve,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(a=>a.id!==i.id||a.type!==i.type||a.source!==i.source);return this.ownProfile.interests=[...r],this.ownProfile.interests.push(i),this};addInterest=t=>(this.promises.push(this.addInterestPromise(t)),this);removeInterestPromise=async t=>{this.modified=!0;let e={...t};await this.getOwnProfile();let i=null;return t.source!=="custom"?i=await this.idsRemapper.remapInterestToNative(e):i=e,this.ownProfile.interests=this.ownProfile.interests.filter(r=>r.id!==i.id||r.type!==i.type||r.source!==i.source),this};removeInterest=t=>(this.promises.push(this.removeInterestPromise(t)),this);setBirthdatePromise=async t=>(this.modified=!0,await this.getOwnProfile(),t?this.ownProfile.birthDate=t:this.ownProfile.birthDate=null,this);setBirthdate=t=>(this.promises.push(this.setBirthdatePromise(t)),this);setGenderPromise=async t=>(this.modified=!0,await this.getOwnProfile(),t==="male"||t==="female"?this.ownProfile.gender=t:this.ownProfile.gender="unspecified",this);setGender=t=>(this.promises.push(this.setGenderPromise(t)),this);setNicknamePromise=async t=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.nickname=t,this);setNickname=t=>(this.promises.push(this.setNicknamePromise(t)),this);setNamePromise=async t=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.name=t,this);setName=t=>(this.promises.push(this.setNamePromise(t)),this);setCountryPromise=async t=>(this.modified=!0,await this.getOwnProfile(),t&&!this.ownProfile.country?(this.ownProfile.country=new Ge,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 a=await this.profileHttps.updateProfile(i),s=JSON.parse(JSON.stringify(a));return this.setOwnProfile(s),this.localCache.setOwnProfile(s),delete a.interests,a}let r=JSON.parse(JSON.stringify(this.ownProfile));return delete r.interests,r}};var We=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 Ke=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 he=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(a=>{a!=="sortOrder"&&a!=="sortField"&&(a==="countryId"?r&&=i.country.id===this[a]:a==="name"?r&&=i.name.toLocaleLowerCase().includes(this[a].toLocaleLowerCase()):a==="competitionIds"?r&&=this[a].some(s=>i.id===s):r&&=i[a].toLocaleLowerCase()===this[a].toLocaleLowerCase())}),r})};entitiesToSearchWith=()=>{let t=[];return this.countryId&&t.push("countryId"),this.name&&t.push("name"),this.gender&&t.push("gender"),this.type&&t.push("type"),this.sortField&&t.push("sortField"),this.sortOrder&&t.push("sortOrder"),this.competitionIds&&t.push("competitionIds"),t};sort=t=>{let e=[];return this.sortField==="name"?e=t.sort((i,r)=>this.sortOrder&&this.sortOrder==="desc"?r.name.localeCompare(i.name):i.name.localeCompare(r.name)):this.sortField==="country"?e=t.sort((i,r)=>this.sortOrder&&this.sortOrder==="desc"?r.country.name.localeCompare(i.country.name):i.country.name.localeCompare(r.country.name)):this.sortField==="scope"?t.forEach(i=>e[this.competitionIds.indexOf(i.id)]=i):!this.sortField&&this.sortOrder==="desc"&&(e=t.sort((i,r)=>r.id.localeCompare(i.id))),e}};var je=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 he(t),t.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([`${t.countryId}`],"country","native");a.country.length===0&&(i=!0),t.countryId=a.country[0]}if(t.competitionIds){let a=await this.idMapping.getEntityIdsBySchemaId(t.competitionIds,"competition","native");a.competition.length===0&&(i=!0),t.competitionIds=a.competition}if(i)return[]}let r=await this.getCompetitions(t,e);return await this.idMapping.remapEntities(r,"competition")}catch(i){throw console.warn("There was a problem browsing all of the competitions",i),i}};getCompetitionsMapWithNativeIds=async t=>{let e=new Map,i=t.length,r=new he({competitionIds:t,limit:i}),a=await this.getCompetitions(r);a.sort((n,l)=>n.id.localeCompare(l.id));let s=la(t),p=await this.idMapping.remapEntities(a,"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],a=await this.getCompetitionById(r,e);return await this.idMapping.remapEntities(a,"competition")}catch(i){throw console.warn(`There was a problem browsing the following competition:${t}`,i),i}};getCompetitionById=async(t,e)=>{try{return e=e||!1,await this.https.getCompetitionById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the competition with the following id: ${t}`,i),i}};getTopCompetitionsIdMapping=async t=>{try{let e=await this.getTopCompetitions(t);return await this.idMapping.remapEntities(e,"competition")}catch(e){throw console.warn("There was a problem browsing the top competitions",e),e}};getTopCompetitions=async t=>{try{return t=t||!1,await this.https.getTopCompetitions(t)}catch(e){throw console.warn("There was a problem retrieving the top competitions",e),e}}};var fe=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 Xe=class{general=[];predictor=[];topX=[];matchQuiz=[]};var _t=class{points=null;gameParticipationCount=null;entityId=null;entityType=null;predictionsMade=null;correctPredictions=null};var Ye=class{id;label;assets={mainImageUrl:""};enabled;requirements=new _t};var qe=class{id;weight;multiplier;conditions};var Qe=class{value=[new qe]};var Rt=class{points=null;tiers=null;badges=null};var ze=class{enabled=!1;clientId=null;conditions={list:null};actions=new Qe;rewards=new Rt};var Je=class{general=null;comments=null;predictor=null;activity=null;topX=null;matchQuiz=null};var Et=class{enabled=!1;clientId=null;defaultMarkets=null;competitionsWhitelist=null};var vt=class{enabled=!1;clientId=null;minFixtures=null;maxFixtures=null;competitionsWhitelist=null};var Ze=class{competitions=[];teams=[];markets=[]};var St=class{enabled=!1;clientId=null;fullCoverageCompetitions=null;markets=null;successRateScopes=new Ze;userDataConfig=null};var ti=class{storeIp=!1;storeDeviceId=!1;storeAgent=!1};var ei=class{remapPredictorConfig=t=>{let e=new St;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 vt;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 Et;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 ze;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 Rt;return e.points=this.remapPoints(t.points),e.tiers=t.tiers,e.badges=this.remapBadges(t.badges),e};remapPoints=t=>{let e=new Je;return e.general=t.general,e.comments=t.comments,e.predictor=t.predictor,e.activity=t.activity,e.topX=t.top_x,e.matchQuiz=t.match_quiz,e};remapBadges=t=>{let e=new Xe;return e.general=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 Ye;return i.id=e.id,i.label=e.label,i.enabled=e.enabled,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,i.requirements=this.remapRequirements(e.requirements),i});remapRequirements=t=>{let e=new _t;return e.points=t.points,e.gameParticipationCount=t.game_participation_count,e.entityId=t.entity_id,e.entityType=t.entity_type,e.predictionsMade=t.predictions_made,e.correctPredictions=t.correct_predictions,e};remapUserDataConfig=t=>{let e=new ti;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 ei}getConfig=async t=>{let e=this.getCachedFeatures();if(!e){let i=`/clients/${this.clientId}/features`,r=this.apiSignInUrl.split("&")[0],a=i+r,s="There was a problem fetching client features from Client API";e=(await this.fetchWithoutAuth(a,s)).data,this.localStorage.setClientFeatures(e)}switch(t){case"predictor":return this.featureConfigRemapper.remapPredictorConfig(e.predictor);case"topX":return this.featureConfigRemapper.remapTopXConfig(e.top_x);case"matchQuiz":return this.featureConfigRemapper.remapMatchQuizConfig(e.match_quiz);case"loyalty":return this.featureConfigRemapper.remapLoyaltyConfig(e.loyalty)}};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 rt=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 ii=class{footballService=null;https=null;idMapping=null;constructor(t,e,i){this.idMapping=i,this.https=e,this.footballService=new rt(t)}getTeamsIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new fe(t),t.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([`${t.countryId}`],"country","native");a.country.length===0&&(i=!0),t.countryId=a.country[0]}if(t.scope){let a=await this.idMapping.getEntityIdsBySchemaId(t.scope,"competition","native");a.competition.length===0&&(i=!0),t.scope=a.competition}if(t.teamIds){let a=await this.idMapping.getEntityIdsBySchemaId(t.teamIds,"team","native");a.team.length===0&&(i=!0),t.teamIds=a.team}}if(i)return[];let r=await this.getTeams(t,e);return r.data=await this.idMapping.remapEntities(r.data,"team"),r}catch(i){throw console.warn("There was a problem browsing all teams",i),i}};getTeamsMapWithNativeIds=async t=>{let e=new Map,i=t.length,r=new fe({teamIds:t,limit:i}),{data:a}=await this.getTeams(r);a.sort((n,l)=>n.id.localeCompare(l.id));let s=la(t),p=await this.idMapping.remapEntities(a,"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 ge=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 rt(t)}getPlayersIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new ge(t),t.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([t.countryId],"country","native");a.country.length===0&&(i=!0),t.countryId=a.country[0]}if(t.playerIds){let a=await this.idMapping.getEntityIdsBySchemaId(t.playerIds,"player","native");a.player.length===0&&(i=!0),t.playerIds=a.player}if(t.scope){let a=await this.idMapping.getEntityIdsBySchemaId(t.scope,"competition","native");a.competition.length===0&&(i=!0),t.scope=a.competition}if(i)return[]}let r=await this.getPlayers(t,e);return r.data=await this.idMapping.remapEntities(r.data,"player"),r}catch(i){throw console.warn("There was a problem browsing the players",i),i}};getPlayersWithNativeIds=async t=>{let e=t.length,i=new ge({playerIds:t,limit:e}),r=await this.getPlayers(i);return r.data.sort((a,s)=>a.id.localeCompare(s.id)),await this.idMapping.remapEntities(r.data,"player")};getPlayersMapWithNativeIds=async t=>{let e={},i=dt(t);i.sort((a,s)=>a.localeCompare(s));let r=await this.getPlayersWithNativeIds(i);return i.forEach((a,s)=>e[a]=r[s]),e};getPlayers=async(t,e)=>{try{return e=e||!1,await this.https.getPlayers(t,e)}catch(i){throw console.warn("There was a problem retrieving the players",i),i}};getPlayerIdMapping=async(t,e)=>{try{let i=await this.idMapping.getEntityIdsBySchemaId([t],"player","native"),r=await this.getPlayerById(i.player[0],e);return await this.idMapping.remapEntities(r,"player")}catch(i){throw console.warn(`There was a problem browsing the following player:${t}`,i),i}};getPlayerById=async(t,e)=>{try{return e=e||!1,await this.https.getPlayerById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the following player: ${t}`,i),i}};getTopPlayersIdMapping=async t=>{try{let e=await this.getTopPlayers(t);return await this.idMapping.remapEntities(e,"player")}catch(e){throw console.warn("There was a problem browsing the top players",e),e}};getTopPlayers=async t=>{try{return t=t||!1,await this.https.getTopPlayers(t)}catch(e){throw console.warn("There was a problem retrieving the top players",e),e}};getNextMatchForPlayerIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"player","native")).player[0];let r=await this.getNextMatchForPlayer(t,e);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the next match for player:${t}`,i),i}};getNextMatchForPlayer=async(t,e)=>{try{e=e||!1;let i=await this.https.getNextMatchForPlayer(t,e);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the next match for player: ${t}`,i),i}};getPrevMatchForPlayerIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"player","native")).player[0];let r=await this.getPrevMatchForPlayer(t,e);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the previous match for player:${t}`,i),i}};getPrevMatchForPlayer=async(t,e)=>{try{e=e||!1;let i=await this.https.getPrevMatchForPlayer(t,e);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the previous match for player: ${t}`,i),i}}};var Ct=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 ot=class{https=null;idMapping=null;footballService=null;constructor(t,e,i){this.https=e,this.idMapping=i,this.footballService=new rt(t)}getMatchesIdMapping=async(t,e)=>{try{if(t){if(t=new Ct(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 Ct({matchIds:t,limit:e}),r=await this.getMatches(i);return r.data.sort((a,s)=>a.id.localeCompare(s.id)),await this.idMapping.remapEntities(r.data,"match")};getMatchesMapWithNativeIds=async t=>{let e={},i=dt(t);i.sort((a,s)=>a.localeCompare(s));let r=await this.getMatchesWithNativeIds(i);if(i.length!==r.length){let a=new Ct({matchIds:i,limit:i.length}),s=await this.getMatches(a),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((a,s)=>e[a]=r[s]),e};getMatches=async(t,e)=>{try{return e=e||!1,await this.https.getMatches(t,e)}catch(i){throw console.warn("There was a problem retrieving the matches",i),i}};getMatchIdMapping=async(t,e)=>{try{let i=await this.idMapping.getEntityIdsBySchemaId([t],"match","native"),r=await this.getMatchById(i.match[0],e),a=await this.footballService.setAvailableMarketsForMatch(r);return await this.idMapping.remapEntities(a,"match")}catch(i){throw console.warn(`There was a problem browsing the following match: ${t}`,i),i}};getMatchById=async(t,e)=>{try{return e=e||!1,await this.https.getMatchById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the following match: ${t}`,i),i}}};var ri=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 ai=class{https=null;idMapping=null;constructor(t,e){this.https=t,this.idMapping=e}searchIdMapping=async(t,e)=>{try{if(t=new ri(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 At=class{countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(t,e,i,r){this.countriesFacade=new Ke(e,i,r),this.competitionsFacade=new je(e,i,r),this.teamsFacade=new ii(t,i,r),this.playerFacade=new at(t,i,r),this.matchFacade=new ot(t,i,r),this.searchFacade=new ai(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 oi=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 oi;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 si=class{id="";country=null;gender="";assets=null;type="";name=""};var O=class{countryRemapper=null;constructor(){this.countryRemapper=new _}fromResponse(t){try{let e=new si;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 ni=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var li=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 li;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 pi=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new _,this.teamBasicRemapper=new C}fromResponse(t){try{let e=new ni;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 ci=class{primary=null;secondary=null;tertiary=null};var mi=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";isDeleted=!1;colors=new ci;squad=[]};var di=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var ui=class{countryRemapper=null;constructor(){this.countryRemapper=new _}fromResponse(t){try{let e=new di;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 hi=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new _,this.competitionRemapper=new O,this.playerRemapper=new ui}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.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 fi=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 gi=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var Ot=class{fromResponse(t){try{let e=new gi;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 yi=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new C,this.competitionRemapper=new O,this.scoresRemapper=new Ot}fromResponse(t){try{let e=new fi;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 Mi=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 bi=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 wi=class{fromResponse(t){try{let e=new bi;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 Lt=class{homeTeam={players:[]};awayTeam={players:[]}};var Ii=class{id="";name="";position="";shirtNumber;assets=null;type=""};var xt=class{fromResponse(t){try{let e=new Ii;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 Pi=class{playerRemapper=null;constructor(){this.playerRemapper=new xt}fromResponse(t){try{let e=new Lt;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 Fi=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var Ti=class{playerRemapper=null;constructor(){this.playerRemapper=new xt}fromResponse(t){try{let e=new Fi;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 _i=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 Pi,this.scoresMapper=new Ot,this.statsMapper=new wi,this.timelineMapper=new Ti}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=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 Lt,e}catch(e){throw console.warn("There was a problem remapping the match response",e),e}}};var Ri=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var Ei=class{countryRemapper=null;constructor(){this.countryRemapper=new _}fromResponse(t){try{let e=new Ri;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 vi=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;teams=[]};var Dt=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new _,this.teamRemapper=new C}fromResponse(t){try{let e=new vi;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 Si=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;competitions=[];teams=[]};var Ci=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 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.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 Ai=class{teams=null;players=null;competitions=null};var Oi=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new C,this.playerRemapper=new Dt,this.competitionremapper=new O}fromResponse(t){try{let e=new Ai;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 st=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var X=class{pagination=new st};var Nt=class{meta=new X;data=[]};var Li=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 pi,this.teamBasicRemapper=new C,this.teamFullRemapper=new hi,this.matchBasicRemapper=new yi,this.matchFullRemapper=new _i,this.playerBasicRemapper=new Dt,this.playerFullRemapper=new Ci,this.topPlayerRemapper=new Ei,this.searchRemapper=new Oi,this.footballMetaRemapper=new Li}getCountries=async t=>{let e="There was a problem with the football countries request",i=`/countries${this.apiSignInUrl}`,r=Date.now();t&&(i+=`&disable_cache=${r}`);let a=await this.fetchWithoutAuth(i,e);return this.countryRemapper.countriesFromResponse(a.data)};getCompetitions=async(t,e)=>{let i=Date.now(),r="There was a problem with football competitions request";if(e=e||!1,t&&t.competitionIds&&t.competitionIds.length>this.limitIds-1){let a=[],s=pe(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);a.push(c.data.map(m=>this.competitionBasicRemapper.fromResponse(m)))}return Array.prototype.concat.apply([],a)}else{let a=`/competitions${this.apiSignInUrl}`;return t&&(a+=`${t.constructFilterUrl()}`),e&&(a+=`&disable_cache=${i}`),(await this.fetchWithoutAuth(a,r)).data.map(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",a=Date.now();e&&(i+=`&disable_cache=${a}`);let s=await this.fetchWithoutAuth(i,r);return this.competitionFullRemapper.fromResponse(s.data)};getTopCompetitions=async t=>{let e="There was a problem with top football competitions request",i=`/competitions/top${this.apiSignInUrl}`,r=Date.now();return t&&(i+=`&disable_cache=${r}`),(await this.fetchWithoutAuth(i,e)).data.map(s=>this.competitionBasicRemapper.fromResponse(s))};getTeams=async(t,e)=>{let i=Date.now(),r="There was a problem with football teams request";if(t&&t.teamIds&&t.teamIds.length>this.limitIds){let a=[],s=pe(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);a.push(c.data.map(m=>this.teamBasicRemapper.fromResponse(m)))}return Array.prototype.concat.apply([],a)}else{let a=new Nt,s=`/teams${this.apiSignInUrl}`;t&&(s+=`${t.constructFilterUrl()}`),e&&(s+=`&disable_cache=${i}`);let p=await this.fetchWithoutAuth(s,r);return a.meta=this.footballMetaRemapper.remapMetaProp(p.meta),a.data=p.data.map(n=>this.teamBasicRemapper.fromResponse(n)),a}};getTeamById=async(t,e)=>{let i="There was a problem with football team by ID request",r=`/teams/${t}${this.apiSignInUrl}`,a=Date.now();e&&(r+=`disable_cache=${a}`);let s=await this.fetchWithoutAuth(r,i);return this.teamFullRemapper.fromResponse(s.data)};getTopTeams=async t=>{let e=`/teams/top${this.apiSignInUrl}`,i="There was a problem with top football teams request",r=Date.now();t&&(e+=`$disable_cache=${r}`);let a=await this.fetchWithoutAuth(e,i);return a.data?a.data.map(s=>this.teamBasicRemapper.fromResponse(s)):[]};getNextMatchForTeam=async(t,e)=>{let i=`/teams/${t}/next-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with next match for team request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getPrevMatchForTeam=async(t,e)=>{let i=`/teams/${t}/previous-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with previous match for team request";e&&(i+=`disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getPlayers=async(t,e)=>{let i=Date.now(),r="There was a problem with football players request";if(t&&t.playerIds&&t.playerIds.length>this.limitIds-1){let a=[],s=pe(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);a.push(c.data.map(m=>this.teamBasicRemapper.fromResponse(m)))}return Array.prototype.concat.apply([],a)}else{let a=new Nt,s=`/players${this.apiSignInUrl}`;t&&(s+=`${t.constructFilterUrl()}`),e&&(s+=`&disable_cache=${i}`);let p=await this.fetchWithoutAuth(s,r);return a.meta=this.footballMetaRemapper.remapMetaProp(p.meta),a.data=p.data.map(n=>this.playerBasicRemapper.fromResponse(n)),a}};getPlayerById=async(t,e)=>{let i=`/players/${t}${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with football player by ID request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.playerFullRemapper.fromResponse(s.data)};getTopPlayers=async t=>{let e=`/players/top${this.apiSignInUrl}`,i=Date.now(),r="There was a problem with top football players request";return t&&(e+=`&disable_cache=${i}`),(await this.fetchWithoutAuth(e,r)).data.map(s=>this.topPlayerRemapper.fromResponse(s))};getNextMatchForPlayer=async(t,e)=>{let i=`/players/${t}/next-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with next match for player request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getPrevMatchForPlayer=async(t,e)=>{let i=`/players/${t}/previous-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with previous match for player request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getMatchById=async(t,e)=>{let i=`/matches/${t}${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with match by ID request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getMatches=async(t,e)=>{let i=new Nt,r=`/matches${this.apiSignInUrl}`,a=Date.now(),s="There was a problem with football matches request";t&&(r+=`${t.constructFilterUrl()}`),e&&(r+=`&disable_cache=${a}`);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(),a="There was a problem with football search request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.searchRemapper.fromResponse(s.data)}};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||{}),ho=["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"],fo=["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"],go=["FT_1X2","HT_1X2","HT_FT","DOUBLE_CHANCE","CORNERS_MATCH","CORRECT_SCORE","CORRECT_SCORE_HT","CORRECT_SCORE_ADVANCED"],ye="PLAYER_SCORE_FIRST_GOAL";var xi=class{id="";achievedAt=""};var Me=class{participations=0;points=0};var ht=class{footballCompetitions=[];footballTeams=[]};var Bt=class{predictionsMade=0;correct=0;points=0;breakdown=new ht};var kt=class{single=new Bt;topX=new Me;matchQuiz=new Me};var Di=class{overallPercent;byFootballCompetition;byFootballTeam;byFootballMarket};var Ni=class{profileId;tier;points;predictionsMade;successRates=new Di;predictions=new kt;tiers=[];badges=[]};var Bi=class{entityId="";entityType="";entitySource="";model=null;predictionsMade=0;correct=0;points=0};var ki=class{successRatePercent;model=null};var Ht=class{content=null;tags=[];campaign=null};var Ut=class{id=null;profileId=null;property=null;value=null;action=null;context=new Ht;points=0};var Hi=class{meta=new X;data=[new Ut]};var Ui=class{remapSingleResponse=t=>{let e=new Ut;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 Hi;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 Ni;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=this.remapPredictionsStats(t.predictions),e.tiers=this.remapAchievementsStats(t.tiers),e.badges=this.remapAchievementsStats(t.badges),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 ki;return e.successRatePercent=t.success_rate_percent,e};remapPredictionsStats=t=>{let e=new kt;return e.single=this.remapSinglePredictionsStats(t.single),e.topX=t.top_x,e.matchQuiz=t.match_quiz,e};remapSinglePredictionsStats=t=>{let e=new Bt;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 ht,i=[],r=[];return Object.keys(t).forEach(a=>{let s=new Bi;s.entityId=a,s.entityType=t[a].entity_type,s.entitySource=t[a].entity_source,s.predictionsMade=t[a].predictions_made,s.correct=t[a].correct,s.points=t[a].points,s.entityType==="competition"?i.push(s):s.entityType==="team"&&r.push(s)}),e.footballCompetitions=i,e.footballTeams=r,e}return new ht};remapAchievementsStats=t=>t.map(e=>{let i=new xi;return i.id=e.id,i.achievedAt=e.achieved_at,i})};var Gt=class extends S{activityRemapper=null;constructor(t){super(t,L(t.environment,"loyalty")),this.activityRemapper=new Ui}createActivity=async t=>{let e=`/activities${this.apiSignInUrl}`,i="There was a problem with creating activity",r="POST",a=await this.fetchWithAuth(e,i,r,t);return this.activityRemapper.remapSingleResponse(a)};deleteActivity=async t=>{let e=`/activities/${t}${this.apiSignInUrl}`,i=`There was a problem deleting the following activity: ${t}`,r="DELETE";return await this.fetchWithAuth(e,i,r),!0};getOwnActivities=async(t,e)=>{let i=`/activities${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with fetching own activities";t&&(i+=`${t.constructFilterUrl()}`),e&&(i+=`disable_cache=${r}`);let s=await this.fetchWithAuth(i,a);return this.activityRemapper.remapActivitiesResponse(s)};getActivitiesForUser=async(t,e,i)=>{let r=`/users/${t}/activities${this.apiSignInUrl}`,a=Date.now(),s=`There was a problem with fetching activities for user: ${t}`;e&&(r+=`${e.constructFilterUrl()}`),i&&(r+=`disable_cache=${a}`);let p=await this.fetchWithoutAuth(r,s);return this.activityRemapper.remapActivitiesResponse(p)};getStats=async(t,e)=>{let i="",r="",a=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}`,a=await this.fetchWithoutAuth(i,r)):(i+=`/statistics${this.apiSignInUrl}`,r="There was a problem fetching profile`s statistics",a=await this.fetchWithAuth(i,r)),this.activityRemapper.remapStatsResponse(a.data)}};var Gi=class{id="";source="";type="";favourite=!1};var Vi=class extends Gi{model=null};var $i=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 a=JSON.parse(JSON.stringify(t.successRates.byFootballCompetition)),s=await this.getEntitiesMap(r.competition,"competition"),p=await this.setSuccessRatesModels(a,s);t.successRates.byFootballCompetition=p,i.single.breakdown.footballCompetitions=this.reconstructBreakdown(i.single.breakdown.footballCompetitions,s)}if(Object.values(r.team).length){let a=JSON.parse(JSON.stringify(t.successRates.byFootballTeam)),s=await this.getEntitiesMap(r.team,"team"),p=await this.setSuccessRatesModels(a,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 a=i.get(r);e={...e,[a.id]:t[r]},e[a.id].model=a}),e):t;reconstructBreakdown=(t,e)=>t.length?t.map(i=>{let r=e.get(i.entityId);return i.entityId=r.id,i.model=r,i}):t;getIdsKeys=(t,e)=>{let i=Object.keys(t);if(e.length){let r=e.map(a=>a.entityId);return Array.from(new Set([...i,...r]))}return i};remapInterestsToIdSchema=async t=>{if(this.idSchema!==this.native)if(t&&t.length>0){let e={},i={},r=t.filter(n=>n.source.toLocaleUpperCase()==="FOOTBALL"),a=t.filter(n=>n.source.toLocaleUpperCase()!=="FOOTBALL");r.forEach(n=>{e.hasOwnProperty(n.type)||(e[n.type]=[],i[n.type]=[]),e[n.type].push(n.id),i[n.type].push(n)});let s=await this.remapIdsObj(e,this.native,this.idSchema),p=[];for(let[n,l]of Object.entries(i))l.forEach((c,m)=>{c.id=s[n][m],p.push(c)});return p.concat(a)}else return t;return t};remapInterestToNative=async t=>{if(this.idSchema!==this.native&&t.source.toLocaleUpperCase()==="FOOTBALL"){let e={},{id:i,type:r}=t;e[r]=[i];let a=await this.remapIdsObj(e,this.idSchema,this.native);return t.id=a[r][0],t}return t};inquiryCustomInterests=(t,e)=>{let i=[];return t&&t.length>0&&(i=t.filter(r=>r.source.toLocaleUpperCase()==="CUSTOM"),e)?i.map(r=>{let a=new Vi;return a.id=r.id,a.type=r.type,a.source=r.source,a.favourite=r.favourite,a}):i};remapInterests=async t=>{let i=this.inquiryCustomInterests(t,!1);if(i&&i.length>0){let r=t.filter(s=>s.source.toLocaleUpperCase()!=="CUSTOM"),a=await this.remapInterestsToIdSchema(r);return i.forEach(s=>a.push(s)),a}return await this.remapInterestsToIdSchema(t)};showFullInterests=async t=>{let e=[];if(t&&t.length>0){let r=this.inquiryCustomInterests(t,!0);e.push(r);let a=t.filter(c=>c.source.toLocaleUpperCase()!=="CUSTOM"),{competitionsMap:s,teamsMap:p,playersMap:n}=await this.getInterestsEntitiesMap(a),l=a.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=[],a=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&&(a=await this.footballFacade.getCompetitionsMapWithNativeIds(e)),i.length&&(s=await this.footballFacade.getTeamsMapWithNativeIds(i)),r.length&&(p=await this.footballFacade.getPlayersMapWithNativeIds(r)),{competitionsMap:a,teamsMap:s,playersMap:p}};remapIdsObj=async(t,e,i)=>await this.idMapping.idMappingFacade.getEntitiesByIds(t,e,i)};var Wi=class{idMapping=null;profileOperations=null;constructor(t,e){this.idMapping=new T(t),this.profileOperations=new $i(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 nt=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 Ft(t),this.activityHttps=new Gt(t),this.footballHttps=new Y(t),this.idMapping=new T(t),this.localCache=new k().createLocalCacheInstance(t.idSchema),this.footballFacade=new At(t,this.localCache,this.footballHttps,this.idMapping),this.profileFacade=new j(this.localCache,this.profileHttps,this.activityHttps),this.idsRemapper=new Wi(t,this.footballFacade),this.ownProfileBuilder=new $e(this.idsRemapper,this.localCache,this.profileHttps,this.activityHttps,t.errorHandlingMode),this.profileBuilder=new We(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 ga=(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))(ga||{});var Ki=class{validate=t=>{let e=this.validateField(t.lang),i=this.generateMessage(e);return{validation:e,message:i}};validateField=t=>{let e=Object.values(ga),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 ji=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 Xi=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 Yi=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 gt=class{getIdToken=null;logout=null};var $t=class{text=null;type=null};var qi=class{validation=null;message=new $t;getIdToken={validation:null,message:new $t};logout={validation:null,message:new $t}};var Qi=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 gt),i=new qi;if(t){let a=Object.keys(t).filter(s=>!e.includes(s));a.length>0?(i.validation="invalid",i.message.type="warning",i.message.text=`${"You have passed a property which is not supported for the authentication provider:"} ${a.join(",")}`):i.validation="valid"}else i.validation="missing",i.message.type="error",i.message.text="The field authProvider must be provided to use this SDK";return i};validateAuthProviderConfigFields=(t,e)=>(Object.keys(new gt).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 we=class{validation;message};var zi=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;errorHandlingMode=null;authProvider={getIdToken:new we,logout:new we};isValid=!1};var Ji=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 Zi=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 tr=class{validate=t=>{let e=this.checkFieldsForValues(t);return e.isValid=this.containsErrorMessage(e),e};checkFieldsForValues=t=>{let e=new zi,i={apiKey:new Xi,environment:new ji,idSchema:new Yi,clientId:new Ji,lang:new Ki,errorHandlingMode:new Zi,authProvider:new Qi};for(let[r,a]of Object.entries(e))r!=="isValid"&&(a=i[r].validate(t));return Object.keys(i).forEach(r=>{e[r]=i[r].validate(t)}),e};containsErrorMessage=t=>{let e=!0;for(let[i,r]of Object.entries(t))if(i!=="authProvider"){if(i!=="isValid"&&r.message.type==="error")return e=!1,e;if(i!=="isValid"&&r.message.type==="warning")return e=!0,e}else if(r.message.type==="error")return e=!1,e;return e}};var Wt=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 At(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 er=class{value=null;playerId=null;playerModel=null};var Kt=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new er;result=null};var ir=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 ir,this.prediction.value=i,this.prediction.playerId=r}};var jt=class{settledAt=null;resettledAt=null;status=null;outcome=null;points=0};var rr=class{value=null};var lt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new rr,this.prediction.value=i}};var $=class{value=!1};var Xt=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 Yt=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 ar=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 Xt||t instanceof Yt)e.market=t.market,e.prediction=t.prediction.value;else if(t instanceof lt){e.market=t.market;let i=t.prediction.value.split(":");e.goals_home=Number(i[0]),e.goals_away=Number(i[1])}else e.market=t.market,e.prediction=t.prediction.value;return e};remapFixturesResponse=async t=>{let e="OWN_GOAL",i=[],r=[],a=null,s=[];t.length>1&&t.sort((n,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)&&(a=await this.playerFacade.getPlayersMapWithNativeIds(r));for(let n of t){let l=new Kt;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=a[n.player_id],l.prediction.playerId=a[n.player_id].id),l.result=this.remapResult(n.result),s.push(l)}return s};remapResult=t=>{let e=new jt;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 Ie=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 or=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 pt=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 yt=class{userId=null;points=null;results=[];tiebreaker=null};var ya=(a=>(a.ACTIVE="ACTIVE",a.WON="WON",a.LOST="LOST",a.PARTIALLY_WON="PARTIALLY_WON",a.CANCELED="CANCELED",a))(ya||{}),Ca=["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(ya).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 qt=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 sr=(s=>(s.OPEN="OPEN",s.LIVE="LIVE",s.PENDING="PENDING",s.CANCELED="CANCELED",s.CLOSED="CLOSED",s.SETTLED="SETTLED",s))(sr||{});var W=class extends qt{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(sr).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 Qt=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 Qt;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 ot(t,this.footballHttps,e),this.playerFacade=new at(t,this.footballHttps,e),this.profileNamespace=new nt(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=dt(t),a=(await this.idMapping.getEntityIdsBySchemaId(i,"player","native")).player;return i.forEach((s,p)=>e[s]=a[p]),e};remapPlayerIdToIdSchema=async t=>{let e=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"],i=[];for(let[a,s]of Object.entries(t))if(e.includes(a))for(let 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[a,s]of Object.entries(t))if(e.includes(a))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=Ga.get(e),a={};if(a.matchId=t.matchId,a.matchType=t.matchType,Object.keys(t.predictions).includes(r))a[r]=t.predictions[r];else throw new Error("You have passed invalid market");if(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&&a[r][p]){let n=await this.playerFacade.getPlayersMapWithNativeIds([p]);return a[r][p].model=n[p],a[r][p]}else return p?(a[r][p]=new I,a[r][p]):a[r][i]}else if(q.includes(e)&&!i){let p=Object.keys(a[r]).filter(l=>l!=="NOBODY"&&l!=="OWN_GOAL"),n=p.length?await this.playerFacade.getPlayersMapWithNativeIds(p):{};Object.keys(n).length&&Object.keys(a[r]).forEach(l=>{l!=="NOBODY"&&l!=="OWN_GOAL"&&(a[r][n[l].id]=a[r][l],a[r][n[l].id].model=n[l],this.idMapping.idSchema!=="native"&&delete a[r][l])})}return a};remapCompetitionsFromConfig=async t=>{if(t instanceof St){let e={competition:t.fullCoverageCompetitions},i={competition:t.successRateScopes.competitions},r={team:t.successRateScopes.teams},a=await this.idMapping.idMappingFacade.getEntitiesByIds(e,"native",this.idMapping.idSchema),s=await this.idMapping.idMappingFacade.getEntitiesByIds(i,"native",this.idMapping.idSchema),p=await this.idMapping.idMappingFacade.getEntitiesByIds(r,"native",this.idMapping.idSchema);return t.fullCoverageCompetitions=a.competition,t.successRateScopes.competitions=s.competition,t.successRateScopes.teams=p.team,t}if(t instanceof vt||t instanceof Et){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 pt||r instanceof et||r instanceof zt?(r.fixtures.forEach(a=>e.push(a.matchId)),r instanceof et&&r.fixtures.forEach(a=>{a.prediction.playerId&&a.prediction.playerId!=="OWN_GOAL"&&i.push(a.prediction.playerId)})):r instanceof yt&&r.results.forEach(a=>e.push(a.matchId))}),await this.refactorResponseArrModel(t,e,i)}else return t;else return await this.refactorResponseObjModel(t)};refactorResponseArrModel=async(t,e,i)=>{let r=[],a=await this.matchFacade.getMatchesMapWithNativeIds(e),s={};return i.length>0&&(s=await this.playerFacade.getPlayersMapWithNativeIds(i)),t.data.forEach(p=>{p instanceof tt||p instanceof pt||p instanceof et?(p.fixtures.forEach(n=>{this.handleMatchModel(a,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 yt&&(p.results.forEach(n=>{n.matchModel=a[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(a=>i.push(a.predictionsCutoff)),t.data.sort((a,s)=>{let[p,n]=[a.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((a,s)=>{r.fixtures[s].goals_home!==void 0&&r.fixtures[s].goals_away!==void 0?a.prediction.value=r.fixtures[s].goals_home+":"+r.fixtures[s].goals_away:a.prediction.value=r.fixtures[s].prediction,r.fixtures[s].player_id?a.prediction.playerId=r.fixtures[s].player_id:r.fixtures[s].target&&(a.prediction.target=r.fixtures[s].target),a.prediction.result=this.remapResult(r.fixtures[s].result)}),i.predictionsMadeAt=r.created_at,i.points=r.points,i instanceof pt&&(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 jt;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=Ca,t=new A(t);else{let r={status:Ca};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,a=t.results.map(l=>q.includes(l.market)&&!l.result.includes("OWN_GOAL")?[...l.result]:[]).flat(),s=await this.matchFacade.getMatchesMapWithNativeIds([r]);return a.length&&(i=await this.playerFacade.getPlayersMapWithNativeIds(a)),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=>{let e=t.userList.map(r=>r.profileId),i=await this.profileNamespace.getByIds(e);return t.userList.forEach(r=>{let a=i.filter(s=>s.id===r.profileId)[0];delete a.interests,r.profileModel=a}),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(Ra.UNEXPECTED_STATUS_PROP),delete t.status),t.type&&(console.warn(Ra.UNEXPECTED_TYPE_PROP),delete t.type),t)};var Jt=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(t){this.gameInstanceId=t.gameInstanceId,t.fixtures.forEach(e=>this.fixtures.push(new lt(e.matchId,e.market,e.prediction.value))),this.tiebreaker=t.tiebreaker?t.tiebreaker:null}};var Zt=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(t,e){this.footballHttps=new Y(t),this.matchFacade=new ot(t,this.footballHttps,e),this.playerFacade=new at(t,this.footballHttps,e),this.predictorService=new J(t,e),this.fixturesRemapper=new ar(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 Jt&&t.tiebreaker&&(e.tiebreaker={},e.tiebreaker.golden_goal=t.tiebreaker.goldenGoal?t.tiebreaker.goldenGoal:null),e};remapResponseArrayBody=async t=>{if(t.length){let e="OWN_GOAL",i=[],r=[],a={},s=[];t.forEach(n=>{n.fixtures.forEach(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&&(a=await this.playerFacade.getPlayersMapWithNativeIds(r)),t.forEach(n=>{let l=new Ie,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 Kt;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=a[d.prediction.playerId],d.prediction.playerId=a[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 Ie;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 or;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 nr=class{matchId=null;matchType=null;predictions=null};var lr=class{remapPredictions=null;constructor(t,e){this.remapPredictions=new Zt(t,e)}remapResponse=t=>{let e=new nr;return e.matchId=t.match_id,e.matchType=t.match_type,e.predictions=this.remapPredictions.remapPredictionModel(t.predictions),e}};var pr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new U};var cr=class{value=null;target=null;playerId=null;playerModel=null;result=null};var mr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new U;prediction=new cr};var dr=class{value=null;result=null};var ur=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new U;prediction=new dr};var hr=class{matchId=null;matchModel=null;outcome=null};var fr=class{gameId=null;results=null;tieBreakers=null};var te=class{entityId=null;entityType=null};var gr=class{contestId="";contestType="GAME";contestModel=null;description="";userList=[]};var yr=class{position="";profileId="";profileModel=null;note="";tags=[]};var Mr=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 pr;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 pt;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 ur;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 mr;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 yt;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 fr;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 gr;return e.contestId=t.contest_id,e.contestType=t.contest_type,e.description=t.description,e.userList=t.user_list.map(i=>this.remapUserListWinners(i)),e};remapUserListWinners=t=>{let e=new yr;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(go.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 hr;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 te;return i.entityId=e.entity_id,i.entityType=e.entity_type,i})};var br=class{remapMetaData=t=>{let e=new wt;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 Zt(t,e),this.matchSummaryRemapper=new lr(t,e),this.gamesRemapper=new Mr,this.metaRemapper=new br}makeFootballPrediction=async t=>{let e=`/predictions${this.apiSignInUrl}`,i="There was a problem making POST request",r="POST",a=await this.fetchWithAuth(e,i,r,this.predictionRemapper.remapRequestBody(t));return await this.predictionRemapper.remapResponseObjBody(a)};getMatchSummary=async(t,e)=>{let i=R(e)?`/predictions/summary/${t}${this.apiSignInUrl}${E()}`:`/predictions/summary/${t}${this.apiSignInUrl}`,r=`There was a problem fetching predictions for match: ${t}`,a=await this.fetchWithoutAuth(i,r);return this.matchSummaryRemapper.remapResponse(a)};deleteFootballPrediction=async t=>{let e=`/predictions/${t}${this.apiSignInUrl}`,i=`There was a problem deleting your prediction: ${t}`,r="DELETE";return await this.fetchWithAuth(e,i,r),!0};getMyPredictions=async t=>{let e=new F,i=`/predictions${this.apiSignInUrl}`,r="There was a problem fetching own predictions";t&&(i+=`${t.constructFiltersUrl()}`);let a=await this.fetchWithAuth(i,r);return e.meta=this.metaRemapper.remapMetaData(a.meta),e.data=await this.predictionRemapper.remapResponseArrayBody(a.data),e};getMyPredictionsNoRemap=async t=>{let e=`/predictions${this.apiSignInUrl}${t.constructFiltersUrl()}`,i="There was a problem fetching own predictions";return await this.fetchWithAuth(e,i)};getUserPredictions=async(t,e,i)=>{let r=new F,a=R(e)?`/predictions/users/${t}${this.apiSignInUrl}${E()}`:`/predictions/users/${t}${this.apiSignInUrl}`,s=`There was a problem fetching predictions for user: ${t}`;i&&(a+=`${i.constructFiltersUrl()}`);let p=await this.fetchWithoutAuth(a,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",a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapPaginatedGames(a)};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}`,a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapGameByIdResponse(a)};getGamePredictions=async(t,e,i)=>{let r=new F,a=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&&(a+=`${i.constructFiltersUrl()}`);let p=await this.fetchWithoutAuth(a,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()}`,a="There was a problem fetching the games list",s=await this.fetchWithoutAuth(r,a);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}`,a=`There was a problem fetching the results for the following game: ${t}`;i&&(r+=`${i.constructMainFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a);return this.gamesRemapper.remapPaginatedGameResults(s)};getMarketResultsForGame=async(t,e)=>{let i=`/games/${t}/correct-results/${this.apiSignInUrl}`,r=`There was a problem fetching the markets correct results for the following game: ${t}`;R(e)&&(i+=`${E()}`);let a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapGameMarketsResults(a.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 ee=class{gameInstanceId=null;fixtures=null};var Aa=(i=>(i.ONE="1",i.X="x",i.TWO="2",i))(Aa||{}),Oa=(i=>(i.ONE_X="1x",i.X_TWO="x2",i.ONE_TWO="12",i))(Oa||{}),La=(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))(La||{});var wr=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 Ir=class{value};var Pr=class{matchId=null;market="CORNERS_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new Ir,this.prediction.value=e}};var Fr=class{value=null};var Tr=class{matchId=null;market="DOUBLE_CHANCE";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new Fr,this.prediction.value=e}};var _r=class{value=null};var Rr=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new _r,this.prediction.value=i}};var Er=class{value=null};var vr=class{matchId=null;market="HT_FT";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new Er,this.prediction.value=e}};var Sr=class{matchId=null;market="PENALTY_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new $,this.prediction.value=e}};var Cr=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 ct=class{errorHandlingMode=null;constructor(t){this.errorHandlingMode=t}validateBodyFields=(t,e)=>{let i=Object.keys(e),r=Object.keys(new ee);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 a=r.filter(s=>!i.includes(s));return a.length&&this.throwMissingFieldsException("game prediction body",a),e.fixtures.forEach(s=>{this.validateFixtureFields(s)}),e};validateFixture=(t,e,i,r)=>{this.validateMarket(e);let a=Object.values(Aa),s=Object.values(La),p=Object.values(Oa);if(e==="FT_1X2"||e==="HT_1X2"){if(a.includes(i))return new Rr(t,e,i)}else if(e==="HT_FT"){if(s.includes(i))return new vr(t,i)}else if(e==="DOUBLE_CHANCE"){if(p.includes(i))return new Tr(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 lt(t,e,i)}else if(e==="CORNERS_MATCH"){if(typeof i=="number")return new Pr(t,i)}else if(e==="BOTH_TEAMS_SCORE"){if(this.isPredictionBoolean(i))return new wr(t,i)}else if(e==="RED_CARD_MATCH"){if(this.isPredictionBoolean(i))return new Cr(t,i)}else if(e==="PENALTY_MATCH"){if(this.isPredictionBoolean(i))return new Sr(t,i)}else if(q.includes(e)){let n="OWN_GOAL";if(this.validatePlayerId(e,r),e===ye&&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(ho.includes(e)){if(this.isPredictionBoolean(i))return new Yt(t,e,i)}else if(fo.includes(e)&&this.isPredictionBoolean(i))return new Xt(t,e,i);this.throwInvalidPredictionException(i,e)};validateFixtureFields=t=>{let e=Object.keys(t);e.forEach(r=>{_a.includes(r)||this.throwInvalidParamException([r])});let i=_a.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 a=i.filter(s=>!r.includes(s));a.length&&this.throwInvalidParamException(a)}}else this.throwInvalidType("prediction","object")};validatePlayerId=(t,e)=>{let i="playerId";t!==ye&&(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=Va(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=$a(t):i=ca(t),this.errorHandlingMode==="default"?new b(400,"INVALID_MARKET",i):new y(400,"INVALID_TYPE",i)};throwInvalidParamException=t=>{let e=Wa(t);throw this.errorHandlingMode==="default"?new b(400,"INVALID_FIELD",e):new y(400,"INVALID_TYPE",e)};throwMissingFieldsException=(t,e)=>{let i=Ka(t,e);throw this.errorHandlingMode==="default"?new b(400,"INVALID_FIELD",i):new y(400,"INVALID_TYPE",i)};throwInvalidType=(t,e)=>{let i=ja(t,e);throw this.errorHandlingMode==="default"?new b(400,"INVALID_TYPE",i):new y(400,"INVALID_TYPE",i)}};var Ar=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 ct(t.errorHandlingMode),this.predictorService=new J(t,r)}makeFootballPrediction=async(t,e,i,r)=>{let a=this.predictorValidator.validateFixture(t,e,i,r),s=new ee;if(this.idMapping.idSchema!=="native"){let p=a.matchId,n="",l=await this.predictorService.remapMatchIdToNative([p]);if(a.matchId=l[0],this.errorHandlingMode==="default"&&!a.matchId)throw new b(400,"INVALID_FIELD","Match id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&!a.matchId)throw new y(400,"INVALID_FIELD","Match id is invalid!");if(a instanceof V&&a.prediction.playerId!=="OWN_GOAL"){if(a.prediction.playerId&&(n=a.prediction.playerId,a.prediction.playerId=await this.predictorService.remapPlayerIdToNative([n])),this.errorHandlingMode==="default"&&a.market!==ye&&!a.prediction.playerId)throw new b(400,"INVALID_FIELD","Player id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&a.market!==ye&&!a.prediction.playerId)throw new y(400,"INVALID_FIELD","Player id is invalid!")}s.fixtures=[a];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=[a],await this.predictorHttps.makeFootballPrediction(s)};getMatchSummary=async(t,e)=>{let i=await this.getMatchSummaryBase(t,e),r=JSON.parse(JSON.stringify(i.predictions)),a=await this.predictorService.remapPlayerIdToIdSchema(r);return i.predictions=a,i};getMarketSummary=async(t,e,i,r)=>{try{let a=await this.getMatchSummaryBase(t,r);return await this.predictorService.getMarketSummary(a,e,i)}catch(a){throw a}};getMatchSummaryBase=async(t,e)=>{if(this.idMapping.idSchema!=="native"){let r=(await this.predictorService.remapMatchIdToNative([t]))[0],a=await this.predictorHttps.getMatchSummary(r,e);return a.matchId=t,a}else return await this.predictorHttps.getMatchSummary(t,e)};getConfig=async()=>{let t=await this.clientHttps.getConfig("predictor");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(t):t};deleteFootballPrediction=async t=>await this.predictorHttps.deleteFootballPrediction(t);getMyPredictions=async t=>{let e=this.predictorService.initPredictionsFilters(t,"user");return await this.predictorHttps.getMyPredictions(e)};getMyPredictionsForMatches=async(t,e)=>{if(this.errorHandlingMode==="default"&&this.predictorService.areIdsExceeded(t))throw new 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 a=this.predictorService.initPredictionsFilters(i,"matches",e);return await this.predictorHttps.getUserPredictions(t,r,a)};getPredictionById=async t=>await this.predictorHttps.getPredictionById(t)};var Or=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 Ar(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 Lr=class{rankType=null;fromDate=null;toDate=null;pagination=new st};var ie=class{position=null;profileId=null;profileModel=null;points=null;predictionsMade=null};var xr=class{remapResponse=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapData(t.data),t);remapMeta=t=>{let e=new Lr;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 ie;r.position=i.position,r.profileId=i.profile_id,r.points=i.points,r.predictionsMade=i.predictions_made,e.push(r)}),e}};var Dr=class extends ie{id=null;rankType=null;model=null;gameType=null};var Nr=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 Dr;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 Br=class{flags="";status="";type="";activeFrom="";activeTo="";createdFrom="";createdTo="";updatedFrom="";updatedTo=""};var kr=class{pagination=new st;filters=new Br};var re=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 Qt;status=null;automaticallyChangeStatus=!0;createdAt=null;updatedAt=null;related=null};var Hr=class extends re{labels=null;customFields=null;adContent=null};var Ur=class{remapResponse=t=>{let e=[];return t.forEach(i=>{let r=new re;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 Hr;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 kr;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 te;return i.entityId=e.entity_id,i.entityType=e.entity_type,i})};var Gr=class{position=null;points=null;predictionsMade=null;profileId=null;profileModel=null;successRatePercent=null};var Vr=class{remapHighestSuccessRate=t=>t.map(e=>{let i=new Gr;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 $r=class extends S{templateRemapper=null;leaderboardRemapper=null;rankingsRemapper=null;highestSuccessRateRemapper=null;constructor(t){super(t,L(t.environment,"loyalty")),this.templateRemapper=new Ur,this.leaderboardRemapper=new xr,this.rankingsRemapper=new Nr,this.highestSuccessRateRemapper=new Vr}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",a=await this.fetchWithoutAuth(i,r),s=JSON.parse(JSON.stringify(a));return s.meta=this.templateRemapper.remapMeta(a.meta),s.data=this.templateRemapper.remapResponse(a.data),s};getTemplateById=async(t,e)=>{let i=R(e)?`/leaderboard/templates/${t}${this.apiSignInUrl}${E()}`:`/leaderboard/templates/${t}${this.apiSignInUrl}`,r=`There was a problem requesting the following template: ${t}`,a=await this.fetchWithoutAuth(i,r);return this.templateRemapper.remapResponseId(a.data)};getLeaderboard=async(t,e,i)=>{let r=R(e)?`/leaderboard/${t}/${this.apiSignInUrl}${E()}`:`/leaderboard/${t}/${this.apiSignInUrl}`,a=`There was a problem fetching the leaderboard for the following template: ${t}`;i&&(r+=`${i.constructFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a),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}`,a=`There was a problem fetching the leaderboard for the following game: ${t}`;i&&(r+=`${i.constructFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a),p=JSON.parse(JSON.stringify(s));return this.leaderboardRemapper.remapResponse(p)};getUserRankings=async(t,e,i)=>{let r=`/leaderboard/users/${t}/rankings/${this.apiSignInUrl}`,a=`There was a problem fetching the rankings for the following user: ${t}`;e&&(r+=`${e.constructFiltersUrl()}`),R(i)&&(r+=`${E()}`);let s=await this.fetchWithoutAuth(r,a);return this.rankingsRemapper.remapRankings(s)};getHighestSuccessRate=async(t,e)=>{let i=`/statistics/top${this.apiSignInUrl}`,r="There was a problem fetching highest success rate";t&&(i+=`${t.constructFiltersUrl()}`),R(e)&&(i+=`${E()}`);let a=await this.fetchWithoutAuth(i,r);return this.highestSuccessRateRemapper.remapHighestSuccessRate(a.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 Wr=class{general;predictor;topX;matchQuiz};var ae=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 Kr=class extends ae{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 jr=class{idMappingService=null;profileNamespace=null;footballNamespace=null;errorHandlingMode=null;constructor(t){this.idMappingService=new T(t),this.profileNamespace=new nt(t),this.footballNamespace=new Wt(t),this.errorHandlingMode=t.errorHandlingMode}remapTemplatesIds=async t=>{if(t.length>0){let e=[],i=[],r=[],a=[],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],a=[...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(a=>a.profileId);if(!i.length)return t;let r=await this.profileNamespace.getByIds(i);return t.forEach(a=>{r.forEach(s=>{s.id===a.profileId&&(delete s.interests,a.profileModel=s)}),a.profileModel||(a.profileModel=null),e.push(a)}),e}return t};buildClientBadges=t=>{let e=new Wr;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 ae(t));break;case"rankings":t&&(t=new Kr(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(a=>{a.id===r.profileId&&(delete a.interests,r.profileModel=a)}),r))};extractRankingsIdsMap=t=>{let e=[],i=[],r=[];return t.forEach(a=>{a.rankType==="GAME"&&a.gameType==="TOP_X"?e.push(a.id):a.rankType==="GAME"&&a.gameType==="MATCH_QUIZ"?i.push(a.id):a.rankType==="TEMPLATE"&&r.push(a.id)}),[e,i,r]};setModelsForUserRankings=(t,e,i,r)=>(r.data.forEach(a=>{a.gameType==="MATCH_QUIZ"&&e?a.model=e.filter(s=>s.id===a.id)[0]:a.gameType==="TOP_X"&&t?a.model=t.filter(s=>s.id===a.id)[0]:a.rankType==="TEMPLATE"&&i&&(a.model=i.filter(s=>s.id===a.id)[0])}),r);completeContestWinners=async t=>{let e=t.userList.map(r=>r.profileId),i=await this.profileNamespace.getByIds(e);return t.userList.forEach(r=>{let a=i.filter(s=>s.id===r.profileId)[0];delete a.interests,r.profileModel=a}),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 a=await this.idMappingService.idMappingFacade.getEntitiesByIds(r,this.idMappingService.idSchema,"native");return Object.keys(a).forEach(s=>{s==="competition"?i.footballCompetitions=a[s]:s==="team"?i.footballTeams=a[s]:s==="player"&&(i.footballPlayers=a[s])}),i};addModelsToEntitiesFollows=async t=>{let e=[],i="fb:c:",r=new Map,a=[],s="fb:t:",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)?a.push(m.id):m.id.includes(l)&&n.push(m.id)}),e.length&&(r=await this.footballNamespace.footballFacade.competitionsFacade.getCompetitionsMapWithNativeIds(e)),a.length&&(p=await this.footballNamespace.footballFacade.teamsFacade.getTeamsMapWithNativeIds(a)),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 Xr=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=ca(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,a=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>a)throw i==="default"?new b(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${a}`):new y(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${a}`)}};var oe=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 ct(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 Jt(t);if(e=this.predictorValidator.validateBodyFields("TOP_X",e),e.fixtures=e.fixtures.map(r=>this.predictorValidator.validateFixture(r.matchId,r.market,r.prediction.value)),this.idMapping.idSchema!=="native"){let r=[];e.fixtures.forEach(s=>r.push(s.matchId));let a=await this.predictorService.remapMatchIdToNative(r);e.fixtures.forEach(s=>s.matchId=a.shift())}let i=await this.predictorHttps.makeFootballPrediction(e);return i.fixtures.forEach(r=>{r.matchId=r.matchModel.id}),i};delete=async t=>await this.predictorHttps.deleteFootballPrediction(t);getMyGameEditions=async(t,e)=>{t&&t.limit&&this.validateLimitFilterOnGames(t.limit),e=e||!1;let i=this.predictorService.initGameTypePredictions("TOP_X",t),r=[],a=await this.predictorHttps.getMyPredictionsNoRemap(i);if(a.data.length>0){a.data.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let s=this.predictorService.initGameFilters("TOP_X",null,r),p=await this.predictorHttps.getUserGameEditions(s,e);return await this.predictorService.addPredictionProp(a,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(a=>a.gameInstanceId===t);return r.length?r[0]:null}return null};getUserGameEditions=async(t,e,i)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),i=i||!1;let r=this.predictorService.initGameTypePredictions("TOP_X",e),a=[],s=await this.predictorHttps.getUserPredictionsNoRemap(t,r);if(s.data.length>0){s.data.forEach(l=>{l.game_instance_id&&a.push(l.game_instance_id)});let p=this.predictorService.initGameFilters("TOP_X",null,a),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"),a=await this.predictorHttps.getUserPredictions(t,i,r);if(a.data.length>0){let s=a.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 se=class{predictorHttps=null;predictorService=null;idMapping=null;clientHttps=null;predictorValidator=null;errorHandlingMode=null;constructor(t){this.predictorValidator=new ct(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 a=await this.predictorService.remapMatchIdToNative(i),s={};r&&r.length>0&&(s=await this.predictorService.remapPlayerIdMapToNative(r)),e.forEach((p,n)=>{p.matchId=a[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 qt(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=[],a=await this.predictorHttps.getMyPredictionsNoRemap(i);if(a.data.length>0){a.data.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let s=this.predictorService.initGameFilters("MATCH_QUIZ",null,r),p=await this.predictorHttps.getUserGameEditions(s,e);return await this.predictorService.addPredictionProp(a,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(a=>a.gameInstanceId===t);return r.length?r[0]:null}return null};getUserGameEditions=async(t,e,i)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),i=i||!1;let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ",e),a=[],s=await this.predictorHttps.getUserPredictionsNoRemap(t,r);if(s.data.length>0){s.data.forEach(l=>{l.game_instance_id&&a.push(l.game_instance_id)});let p=this.predictorService.initGameFilters("MATCH_QUIZ",null,a),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"),a=await this.predictorHttps.getUserPredictions(t,i,r);if(a.data.length>0){let s=a.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 Yr=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 qr=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 Qr=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,a){this.config=t,this.clientHttps=e,this.loyaltyHttps=i,this.profileFacade=new j(a,r),this.loyaltyService=new jr(this.config),this.loyaltyValidator=new Xr,this.idMapping=new T(t),this.topXFacade=new oe(t,this.idMapping),this.matchQuizFacade=new se(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 qr(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 Yr(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,[a,s,p]=this.loyaltyService.extractRankingsIdsMap(t.data);if(p.length&&(e=(await this.getTemplates()).data.filter(l=>p.includes(l.id))),a.length){let n={gameIds:a};i=(await this.topXFacade.getGames(n)).data}if(s.length){let n={gameIds:s};r=(await this.matchQuizFacade.getGames(n)).data}return this.loyaltyService.setModelsForUserRankings(i,r,e,t)}};var zr=class{clientHttps=null;profileHttps=null;loyaltyHttps=null;loyaltyFacade=null;localCache=null;constructor(t){this.clientHttps=new H(t),this.profileHttps=new Ft(t),this.loyaltyHttps=new $r(t),this.localCache=new k().createLocalCacheInstance(t.idSchema),this.loyaltyFacade=new Qr(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 Jr=class{topXFacade=null;idMapping=null;constructor(t){this.idMapping=new T(t),this.topXFacade=new oe(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 Zr=class{matchQuizFacade=null;constructor(t){this.matchQuizFacade=new se(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 Pe=class{action=null;context=new Ht;constructor(t,e,i,r){this.action=t,this.context.tags=e,i&&(this.context.content=i),r&&(this.context.campaign=r)}};var ta=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={},a={},s=[];t.forEach(n=>{r.hasOwnProperty(n.type)||(r[n.type]=[],a[n.type]=[]),r[n.type].push(n.id),a[n.type].push(n)});let p=await this.idMapping.idMappingFacade.getEntitiesByIds(r,e,i);for(let[n,l]of Object.entries(a))l.forEach((c,m)=>{c.id=p[n][m],s.push(c)});return s}};var ne=class{page=null;limit=null;constructor(t){this.page=t.page?t.page:null,this.limit=t.limit?t.limit:null}};var ea=class extends ne{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 ia=class extends ne{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 ra=class{idSchema;activityHttps;activityService;constructor(t){this.idSchema=t.idSchema,this.activityHttps=new Gt(t),this.activityService=new ta(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 Pe(t,p,i,r),l=await this.activityHttps.createActivity(n);return l.context.tags=s,l}let a=new Pe(t,e,i,r);return this.activityHttps.createActivity(a)};delete=async t=>await this.activityHttps.deleteActivity(t);like=async(t,e,i)=>{let r="like";return await this.add(r,t,e,i)};dislike=async(t,e,i)=>{let r="dislike";return await this.add(r,t,e,i)};addPageview=async(t,e,i)=>{let r="page_view";return await this.add(r,t,e,i)};addContentConsumed=async(t,e,i)=>{let r="content_consumed";return await this.add(r,t,e,i)};addShare=async(t,e,i)=>{let r="share";return await this.add(r,t,e,i)};addComment=async(t,e,i)=>{let r="comment";return await this.add(r,t,e,i)};addClickAd=async(t,e,i)=>{let r="click_ad";return await this.add(r,t,e,i)};addConversion=async(t,e,i)=>{let r="conversion";return await this.add(r,t,e,i)};getOwn=async(t,e)=>{if(e=e||!1,t&&(t=new ea(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 ia(e)),this.idSchema!="native"){let r=await this.activityHttps.getActivitiesForUser(t,e,i),a=JSON.parse(JSON.stringify(r));for(let s of a.data)await this.activityService.remapTagsIds([...s.context.tags],"native",this.idSchema);return a}return await this.activityHttps.getActivitiesForUser(t,e,i)}};var aa=class{activityFacade;constructor(t){this.activityFacade=new ra(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 Ma=null,xa=null;function Hb(o){if(ko(o)){let t=Ho(o);if(t.isValid)return Ma={profile:new nt(o),football:new Wt(o),predictor:new Or(o),loyalty:new zr(o),topX:new Jr(o),matchQuiz:new Zr(o),activity:new aa(o)},xa={...o},Ma;Uo(t)}return Ma}var ko=o=>!Ma||JSON.stringify(o)!==JSON.stringify(xa)||o.authProvider.getIdToken()!==xa.authProvider.getIdToken(),Ho=o=>{let e=new tr().validate(o);return(e.idSchema.validation==="missing"||e.idSchema.validation==="invalid")&&(console.warn(e.idSchema.message.text),o.idSchema="native"),(e.environment.validation==="missing"||e.environment.validation==="invalid")&&(console.warn(e.environment.message.text),o.environment="prod"),(e.lang.validation==="missing"||e.lang.validation==="invalid")&&(console.warn(e.lang.message.text),o.lang="en"),(e.errorHandlingMode.validation==="missing"||e.errorHandlingMode.validation==="invalid")&&(console.warn(e.errorHandlingMode.message.text),o.errorHandlingMode="default"),e.authProvider.validation==="invalid"&&console.warn(e.authProvider.message.text),e},Uo=o=>{let t="authProvider",e="isValid";Object.keys(o).forEach(i=>{let r=o[i];if(i!==e&&i!==t){if(r.message.type==="error")throw new Error(r.message.text)}else i!==e&&i===t&&Object.keys(new gt).forEach(a=>{if(r[a].message.type==="error")throw new Error(r[a].message.text)})})};export{Hb as FansUnitedSDK};
3
+ ${Ta.PREDICTOR_USER_RELATED_OPERATION}`},Va=(o,t)=>`The prediction '${o}' is invalid for market '${t}'. Please check again have you passed appropriate prediction model. For more information please visit our documentation: https://docs.fansunitedmedia.com/sdks/js/match.quiz#gamerelatedoperations`,ca=o=>`The market '${o}' is not supported from Fans United. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,$a=o=>`The market '${o}' is not valid for Top X game. The only available market is CORRECT_SCORE.`,Wa=o=>`The field/s '${o.length>1?o.join(", "):o[0]}' is/are invalid. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/javascript-sdk`,Ka=(o,t)=>`The following field/s is/are missing from ${o}: '${t.length>1?t.join(", "):t[0]}'. For more information please visit our documentation: https://docs.fansunitedmedia.com/docs/predictor-operations#make-football-prediction`,ja=(o,t)=>`The field ${o} has incorrect type. The correct type is ${t}`;var ut=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 a=this.transformFetchException(i,r);throw console.warn(e,a),a}return r};fetchWithAuth=async(t,e,i,r)=>{this.validateJWTToken();let a=null,s=null;if(i&&r?a=await fetch(this.baseUrl+t,{method:i,headers:this.authHeaders,body:JSON.stringify(r)}):i&&!r?a=await fetch(this.baseUrl+t,{method:i,headers:this.authHeaders}):a=await fetch(this.baseUrl+t,{headers:this.authHeaders}),i!=="DELETE"&&(s=await a.json()),!a.ok){(a.status===401||a.status===403)&&!this.retryRequest&&(this.retryRequest=!0,await this.fetchWithAuth(t,e,i,r)),this.retryRequest=!1;let p=this.transformFetchException(a,s||await a.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 ut(t,s)}let{code:i,status:r,message:a}=e.error;return this.errorHandlingMode==="standard"?new y(i,r,a):new ut(t,e.error)};validateJWTToken=()=>{let t=null;try{t=Ua(this.jwtToken)}catch(i){if(this.errorHandlingMode==="default"){let r={status:401,statusText:i.message,headers:{}},a={code:401,status:"invalid_token",message:"Invalid JWT token is provided"};throw new ut(r,a)}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 ut(i,r)}else if(this.errorHandlingMode==="standard")throw new y(401,"invalid_token","The provided JWT token is expired")}}};var vo="/countries",x="/profile",Ea="/profiles",Ft=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 Ee,this.followingRemapper=new Ce,this.followersRemapper=new Oe}getCountries=async t=>{let e=`&lang=${this.lang}`,i=`${vo}${this.apiSignInUrl}${e}`,r=Date.now(),a="There was a problem fetching profile countries";return t&&(i+=`&disable_cache=${r}`),(await this.fetchWithoutAuth(i,a)).data};getProfile=async t=>{let e=`${x}${this.apiSignInUrl}`,i="";if(t){e=`${Ea}/${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=pe(t,this.limitIds);for(let l of n){let c=`${Ea}${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 a=`${Ea}${this.apiSignInUrl}&profile_ids=${t.join(",")}`;e&&(a+=`&disable_cache=${i}`);let s=await this.fetchWithoutAuth(a,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 a=await this.fetchWithoutAuth(i,r);return this.followersRemapper.followersFromResponse(a)};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 a=await this.fetchWithoutAuth(i,r);return this.followingRemapper.followingFromResponse(a)};follow=async t=>{let e=new ce;e.profile_ids=t;let i=x+`/follow${this.apiSignInUrl}`,r=`There was a problem with following profiles: ${t.join(",")}`,a="POST",s=await this.fetchWithAuth(i,r,a,e);return this.followingRemapper.followResponse(s.data)};unfollow=async t=>{let e=new ce;e.profile_ids=t;let i=x+`/follow${this.apiSignInUrl}`,r=`There was a problem with unfollowing profiles: ${t.join(",")}`,a="DELETE";return await this.fetchWithAuth(i,r,a,e),!0};getBadges=async t=>{let e=`${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",a=await this.fetchWithAuth(e,i,r,t);return this.profileRemapper.fullProfileFromResponse(a.data)}};var B=(a=>(a.NATIVE="native",a.ENETPULSE="enetpulse",a.SPORTRADAR="sportradar",a.SPORTAL_365="sportal365",a.API_FOOTBALL="api_football",a))(B||{});var Le={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},xe=class extends S{constructor(t){super(t,L(t.environment,"idMapping"))}getEntityById=async(t,e)=>{let i=`/football${this.apiSignInUrl}&input_provider=${this.idSchema}&${Le[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}&${Le[t]}=${e}`,a=`There was a problem with id mapping request for the following id: ${e}`;return await this.fetchWithoutAuth(r,a)};getEntityIdsByIdsAndSchema=async(t,e,i)=>{let r=`/football${this.apiSignInUrl}&input_provider=${i}&${Le[t]}=${e.join(",")}`,a=`There was a problem with id mapping request for the following ids: ${e.join(",")}`;return await this.fetchWithoutAuth(r,a)};getEntitiesByIds=async(t,e,i)=>{e.sort((s,p)=>s.localeCompare(p));let r=Pa(e),a=[];for(let s of r){let p=`/football${this.apiSignInUrl}&input_provider=${i}&${Le[t]}=${s.join(",")}`,n=`There was a problem with id mapping request for the following ids :${s.join(",")}`,l=await this.fetchWithoutAuth(p,n);a=[...a,...l.data]}return a};getEntitiesByIdObjs=async(t,e)=>{let i=[],r={},a=[];Object.keys(t).forEach(l=>{i.push.apply(i,t[l])});let s=dt(i),p=Pa(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+=`${Le[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);a.push(M.data)}else a.push([])}return Array.prototype.concat.apply([],a)};getTopEntities=async()=>{let t=`/football/top${this.apiSignInUrl}`,e="There was a problem with top id mappings request";return(await this.fetchWithoutAuth(t,e)).data}};var Xa="FansUnited",va={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}}},De=class{idSchema="";expirationProfileTimeout=600;expirationBadgesTimeout=3600;expirationClientFeaturesTimeout=14400;expirationFootballIdsTimeout=604800;constructor(t){this.idSchema=t,(this.getData()===void 0||this.getData()===null)&&this.setData(va)}clearData=()=>{this.setData(va)};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 a=v[i];return r&&t.includes(`${r[a]}`)&&r.resource===e}):this.getData().football.ids.find(r=>{let a=v[i];return r&&`${r[a]}`===t&&r.resource===e});getEntityByNativeId=(t="",e="")=>this.getData().football.ids.find(i=>i&&`${i.id}`===e&&i.resource===t);checkForExistingIdObjs=(t,e)=>{let i=v[e],r={};return Object.keys(t).forEach(a=>{let s=t[a],n=this.getEntity(s,a,e).map(c=>c[i]),l=t[a].filter(c=>!n.includes(c));r[a]=s.map(c=>l.includes(c)?{id:c,exists:!1}:{id:c,exists:!0})}),r};getIdsByType=(t,e,i)=>{let r=v[i],a=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[a]&&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(Xa));setData=t=>{localStorage.setItem(Xa,JSON.stringify(t))};initialNewSchema=(t,e)=>{let i=this.getData();(!i||!i[t]||!i[t][e])&&this.setData(va)}};var uo=_o(mo());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 a=v[this.idSchema];return r&&`${r[a]}`===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(a=>{let s=v[i];return a&&t.includes(`${a[s]}`)&&a.resource===e}):r.find(a=>{let s=v[i];return a&&`${a[s]}`===t&&a.resource===e})};checkForExistingIdObjs=(t,e)=>{let i=v[e],r={};return Object.keys(t).forEach(a=>{let s=t[a],n=this.getEntity(s,a,e).map(c=>c[i]),l=t[a].filter(c=>!n.includes(c));r[a]=s.map(c=>l.includes(c)?{id:c,exists:!1}:{id:c,exists:!0})}),r};getIdsByType=(t,e,i)=>{let r=v[i],a=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[a]&&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(a=>a.resource!=="match"),t=t.filter(a=>a.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"}}},Tt=g;Ia(Tt,"instance"),Ia(Tt,"nodeCache",new uo.default);var k=class{createLocalCacheInstance=t=>typeof window>"u"?Tt.getInstance(t):new De(t)};var Ne=class{localCache=null;https=null;constructor(t){this.localCache=new k().createLocalCacheInstance(t.idSchema),this.https=new xe(t)}getEntitiesByIds=async(t,e,i)=>{await this.setTopIdMappings();try{let r=this.localCache.checkForExistingIdObjs(t,e),a=this.splitForRequestAndExisting(r),s=await this.https.getEntitiesByIdObjs(a.request,e);return this.localCache.addIdMappings(s),this.localCache.getIdsByType(t,e,i)}catch(r){return console.warn("There was a problem retrieving the entity ids ",r),Promise.resolve([])}};getEntityById=async(t,e,i)=>{let r=this.localCache.getEntity(t,e,i);if(r)return r;let a=await this.requestEntity(t,e,i);return this.localCache.addIdMappings(a),a};splitForRequestAndExisting=t=>{let e={},i={};return Object.keys(t).forEach(r=>{e[r]=t[r].filter(a=>!a.exists).map(a=>a.id),i[r]=t[r].filter(a=>a.exists).map(a=>a.id)}),{existing:i,request:e}};requestEntity=async(t,e,i)=>{try{return t=Array.isArray(t)?t:[t],await this.https.getEntitiesByIds(e,t,i)}catch(r){return console.warn(`There was a problem retrieving the requested entity: ${r}`),null}};setTopIdMappings=async()=>{let t=Math.floor(Date.now()/1e3);if(this.localCache.getExpiration("football","ids")>t)return Promise.resolve();let i=await this.https.getTopEntities();this.localCache.addTopIdMappings(i)}};var ha=o=>{switch(o){case"competitions":return"competition";case"players":case"relatedPlayer":case"squad":return"player";case"teams":case"participants":case"homeTeam":case"awayTeam":case"timeline":case"teamId":return"team";default:return o}};var Be=class{extractedObjIds={};traverse=(t,e)=>(e=ha(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 ke=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(t,e,i)=>(e=ha(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 Ne(t)}getEntityIdBySchemaId=(t,e)=>this.idMappingFacade.getEntityById(e,t,this.idSchema);remapEntities=async(t,e)=>{let i=JSON.parse(JSON.stringify(t));try{if(this.idSchema!=="native"){let a=new Be().traverse(i,e);return this.idMappingFacade.getEntitiesByIds(a,"native",this.idSchema).then(s=>new ke().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 He=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 Ue=class{totalPercentage;breakdown=new He};var ue=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 ue(t));let i=await this.profileHttps.getFollowers(t,e),r=i.data.map(a=>a.followerId);if(r.length){let a=await this.getByIds(r),s=i.data.map(p=>(a.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 ue(t));let i=await this.profileHttps.getFollowing(t,e),r=i.data.map(a=>a.followingId);if(r.length){let a=await this.getByIds(r),s=i.data.map(p=>(a.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 Ue,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 Ge=class{id=null;name=null;assets=null};var Ve=class{extractUpdatedProps=(t,e)=>{let i=["name","nickname","gender","avatar"],r={};return Object.keys(t).forEach(a=>{if(i.includes(a)&&t[a]!==e[a])r[a]=e[a];else if(a==="birthDate")(e[a]===null||t[a]===null&&e[a]||t[a]!==e[a])&&(r.birth_date=e[a]);else if(a==="country")e[a]===null?r.country_id=e[a]:(t[a]===null&&e[a]||t[a].id!==e[a].id)&&(r.country_id=e[a].id);else if(a==="interests"){let s=t[a],p=e[a];p.length&&this.isNewInterest(s,p)?r[a]=this.updateInterests(s,p):(!p.length&&s.length||s.length!==p.length&&!this.isNewInterest(s,p))&&(r[a]=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(a=>t.some(s=>a.id===s.id&&a.type===s.type&&a.source===s.source&&a.favourite===s.favourite));return[e.filter(a=>!t.some(s=>a.id===s.id&&a.type===s.type&&a.source===s.source&&a.favourite===s.favourite)),i]};isAvatarValidURL=t=>{try{return new URL(t),!0}catch{return!1}}};var 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 $e=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,a){this.idsRemapper=t,this.localCache=e,this.profileHttps=i,this.errorHandlingMode=a,this.profileService=new Ve,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(a=>a.id!==i.id||a.type!==i.type||a.source!==i.source);return this.ownProfile.interests=[...r],this.ownProfile.interests.push(i),this};addInterest=t=>(this.promises.push(this.addInterestPromise(t)),this);removeInterestPromise=async t=>{this.modified=!0;let e={...t};await this.getOwnProfile();let i=null;return t.source!=="custom"?i=await this.idsRemapper.remapInterestToNative(e):i=e,this.ownProfile.interests=this.ownProfile.interests.filter(r=>r.id!==i.id||r.type!==i.type||r.source!==i.source),this};removeInterest=t=>(this.promises.push(this.removeInterestPromise(t)),this);setBirthdatePromise=async t=>(this.modified=!0,await this.getOwnProfile(),t?this.ownProfile.birthDate=t:this.ownProfile.birthDate=null,this);setBirthdate=t=>(this.promises.push(this.setBirthdatePromise(t)),this);setGenderPromise=async t=>(this.modified=!0,await this.getOwnProfile(),t==="male"||t==="female"?this.ownProfile.gender=t:this.ownProfile.gender="unspecified",this);setGender=t=>(this.promises.push(this.setGenderPromise(t)),this);setNicknamePromise=async t=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.nickname=t,this);setNickname=t=>(this.promises.push(this.setNicknamePromise(t)),this);setNamePromise=async t=>(this.modified=!0,await this.getOwnProfile(),this.ownProfile.name=t,this);setName=t=>(this.promises.push(this.setNamePromise(t)),this);setCountryPromise=async t=>(this.modified=!0,await this.getOwnProfile(),t&&!this.ownProfile.country?(this.ownProfile.country=new Ge,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 a=await this.profileHttps.updateProfile(i),s=JSON.parse(JSON.stringify(a));return this.setOwnProfile(s),this.localCache.setOwnProfile(s),delete a.interests,a}let r=JSON.parse(JSON.stringify(this.ownProfile));return delete r.interests,r}};var We=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 Ke=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 he=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(a=>{a!=="sortOrder"&&a!=="sortField"&&(a==="countryId"?r&&=i.country.id===this[a]:a==="name"?r&&=i.name.toLocaleLowerCase().includes(this[a].toLocaleLowerCase()):a==="competitionIds"?r&&=this[a].some(s=>i.id===s):r&&=i[a].toLocaleLowerCase()===this[a].toLocaleLowerCase())}),r})};entitiesToSearchWith=()=>{let t=[];return this.countryId&&t.push("countryId"),this.name&&t.push("name"),this.gender&&t.push("gender"),this.type&&t.push("type"),this.sortField&&t.push("sortField"),this.sortOrder&&t.push("sortOrder"),this.competitionIds&&t.push("competitionIds"),t};sort=t=>{let e=[];return this.sortField==="name"?e=t.sort((i,r)=>this.sortOrder&&this.sortOrder==="desc"?r.name.localeCompare(i.name):i.name.localeCompare(r.name)):this.sortField==="country"?e=t.sort((i,r)=>this.sortOrder&&this.sortOrder==="desc"?r.country.name.localeCompare(i.country.name):i.country.name.localeCompare(r.country.name)):this.sortField==="scope"?t.forEach(i=>e[this.competitionIds.indexOf(i.id)]=i):!this.sortField&&this.sortOrder==="desc"&&(e=t.sort((i,r)=>r.id.localeCompare(i.id))),e}};var je=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 he(t),t.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([`${t.countryId}`],"country","native");a.country.length===0&&(i=!0),t.countryId=a.country[0]}if(t.competitionIds){let a=await this.idMapping.getEntityIdsBySchemaId(t.competitionIds,"competition","native");a.competition.length===0&&(i=!0),t.competitionIds=a.competition}if(i)return[]}let r=await this.getCompetitions(t,e);return await this.idMapping.remapEntities(r,"competition")}catch(i){throw console.warn("There was a problem browsing all of the competitions",i),i}};getCompetitionsMapWithNativeIds=async t=>{let e=new Map,i=t.length,r=new he({competitionIds:t,limit:i}),a=await this.getCompetitions(r);a.sort((n,l)=>n.id.localeCompare(l.id));let s=la(t),p=await this.idMapping.remapEntities(a,"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],a=await this.getCompetitionById(r,e);return await this.idMapping.remapEntities(a,"competition")}catch(i){throw console.warn(`There was a problem browsing the following competition:${t}`,i),i}};getCompetitionById=async(t,e)=>{try{return e=e||!1,await this.https.getCompetitionById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the competition with the following id: ${t}`,i),i}};getTopCompetitionsIdMapping=async t=>{try{let e=await this.getTopCompetitions(t);return await this.idMapping.remapEntities(e,"competition")}catch(e){throw console.warn("There was a problem browsing the top competitions",e),e}};getTopCompetitions=async t=>{try{return t=t||!1,await this.https.getTopCompetitions(t)}catch(e){throw console.warn("There was a problem retrieving the top competitions",e),e}}};var fe=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 Xe=class{general=[];predictor=[];topX=[];matchQuiz=[]};var _t=class{points=null;gameParticipationCount=null;entityId=null;entityType=null;predictionsMade=null;correctPredictions=null};var Ye=class{id;label;assets={mainImageUrl:""};enabled;requirements=new _t};var qe=class{id;weight;multiplier;conditions};var Qe=class{value=[new qe]};var Rt=class{points=null;tiers=null;badges=null};var ze=class{enabled=!1;clientId=null;conditions={list:null};actions=new Qe;rewards=new Rt};var Je=class{general=null;comments=null;predictor=null;activity=null;topX=null;matchQuiz=null};var Et=class{enabled=!1;clientId=null;defaultMarkets=null;competitionsWhitelist=null};var vt=class{enabled=!1;clientId=null;minFixtures=null;maxFixtures=null;competitionsWhitelist=null};var Ze=class{competitions=[];teams=[];markets=[]};var St=class{enabled=!1;clientId=null;fullCoverageCompetitions=null;markets=null;successRateScopes=new Ze;userDataConfig=null};var ti=class{storeIp=!1;storeDeviceId=!1;storeAgent=!1};var ei=class{remapPredictorConfig=t=>{let e=new St;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 vt;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 Et;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 ze;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 Rt;return e.points=this.remapPoints(t.points),e.tiers=t.tiers,e.badges=this.remapBadges(t.badges),e};remapPoints=t=>{let e=new Je;return e.general=t.general,e.comments=t.comments,e.predictor=t.predictor,e.activity=t.activity,e.topX=t.top_x,e.matchQuiz=t.match_quiz,e};remapBadges=t=>{let e=new Xe;return e.general=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 Ye;return i.id=e.id,i.label=e.label,i.enabled=e.enabled,e.assets?i.assets.mainImageUrl=e.assets.main_image_url:i.assets=e.assets,i.requirements=this.remapRequirements(e.requirements),i});remapRequirements=t=>{let e=new _t;return e.points=t.points,e.gameParticipationCount=t.game_participation_count,e.entityId=t.entity_id,e.entityType=t.entity_type,e.predictionsMade=t.predictions_made,e.correctPredictions=t.correct_predictions,e};remapUserDataConfig=t=>{let e=new ti;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 ei}getConfig=async t=>{let e=this.getCachedFeatures();if(!e){let i=`/clients/${this.clientId}/features`,r=this.apiSignInUrl.split("&")[0],a=i+r,s="There was a problem fetching client features from Client API";e=(await this.fetchWithoutAuth(a,s)).data,this.localStorage.setClientFeatures(e)}switch(t){case"predictor":return this.featureConfigRemapper.remapPredictorConfig(e.predictor);case"topX":return this.featureConfigRemapper.remapTopXConfig(e.top_x);case"matchQuiz":return this.featureConfigRemapper.remapMatchQuizConfig(e.match_quiz);case"loyalty":return this.featureConfigRemapper.remapLoyaltyConfig(e.loyalty)}};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 rt=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 ii=class{footballService=null;https=null;idMapping=null;constructor(t,e,i){this.idMapping=i,this.https=e,this.footballService=new rt(t)}getTeamsIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new fe(t),t.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([`${t.countryId}`],"country","native");a.country.length===0&&(i=!0),t.countryId=a.country[0]}if(t.scope){let a=await this.idMapping.getEntityIdsBySchemaId(t.scope,"competition","native");a.competition.length===0&&(i=!0),t.scope=a.competition}if(t.teamIds){let a=await this.idMapping.getEntityIdsBySchemaId(t.teamIds,"team","native");a.team.length===0&&(i=!0),t.teamIds=a.team}}if(i)return[];let r=await this.getTeams(t,e);return r.data=await this.idMapping.remapEntities(r.data,"team"),r}catch(i){throw console.warn("There was a problem browsing all teams",i),i}};getTeamsMapWithNativeIds=async t=>{let e=new Map,i=t.length,r=new fe({teamIds:t,limit:i}),{data:a}=await this.getTeams(r);a.sort((n,l)=>n.id.localeCompare(l.id));let s=la(t),p=await this.idMapping.remapEntities(a,"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 ge=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 rt(t)}getPlayersIdMapping=async(t,e)=>{try{let i=!1;if(t){if(t=new ge(t),t.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([t.countryId],"country","native");a.country.length===0&&(i=!0),t.countryId=a.country[0]}if(t.playerIds){let a=await this.idMapping.getEntityIdsBySchemaId(t.playerIds,"player","native");a.player.length===0&&(i=!0),t.playerIds=a.player}if(t.scope){let a=await this.idMapping.getEntityIdsBySchemaId(t.scope,"competition","native");a.competition.length===0&&(i=!0),t.scope=a.competition}if(i)return[]}let r=await this.getPlayers(t,e);return r.data=await this.idMapping.remapEntities(r.data,"player"),r}catch(i){throw console.warn("There was a problem browsing the players",i),i}};getPlayersWithNativeIds=async t=>{let e=t.length,i=new ge({playerIds:t,limit:e}),r=await this.getPlayers(i);return r.data.sort((a,s)=>a.id.localeCompare(s.id)),await this.idMapping.remapEntities(r.data,"player")};getPlayersMapWithNativeIds=async t=>{let e={},i=dt(t);i.sort((a,s)=>a.localeCompare(s));let r=await this.getPlayersWithNativeIds(i);return i.forEach((a,s)=>e[a]=r[s]),e};getPlayers=async(t,e)=>{try{return e=e||!1,await this.https.getPlayers(t,e)}catch(i){throw console.warn("There was a problem retrieving the players",i),i}};getPlayerIdMapping=async(t,e)=>{try{let i=await this.idMapping.getEntityIdsBySchemaId([t],"player","native"),r=await this.getPlayerById(i.player[0],e);return await this.idMapping.remapEntities(r,"player")}catch(i){throw console.warn(`There was a problem browsing the following player:${t}`,i),i}};getPlayerById=async(t,e)=>{try{return e=e||!1,await this.https.getPlayerById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the following player: ${t}`,i),i}};getTopPlayersIdMapping=async t=>{try{let e=await this.getTopPlayers(t);return await this.idMapping.remapEntities(e,"player")}catch(e){throw console.warn("There was a problem browsing the top players",e),e}};getTopPlayers=async t=>{try{return t=t||!1,await this.https.getTopPlayers(t)}catch(e){throw console.warn("There was a problem retrieving the top players",e),e}};getNextMatchForPlayerIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"player","native")).player[0];let r=await this.getNextMatchForPlayer(t,e);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the next match for player:${t}`,i),i}};getNextMatchForPlayer=async(t,e)=>{try{e=e||!1;let i=await this.https.getNextMatchForPlayer(t,e);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the next match for player: ${t}`,i),i}};getPrevMatchForPlayerIdMapping=async(t,e)=>{try{t=(await this.idMapping.getEntityIdsBySchemaId([t],"player","native")).player[0];let r=await this.getPrevMatchForPlayer(t,e);return await this.idMapping.remapEntities(r,"match")}catch(i){throw console.warn(`There was a problem browsing the previous match for player:${t}`,i),i}};getPrevMatchForPlayer=async(t,e)=>{try{e=e||!1;let i=await this.https.getPrevMatchForPlayer(t,e);return await this.footballService.setAvailableMarketsForMatch(i)}catch(i){throw console.warn(`There was a problem retrieving the previous match for player: ${t}`,i),i}}};var Ct=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 ot=class{https=null;idMapping=null;footballService=null;constructor(t,e,i){this.https=e,this.idMapping=i,this.footballService=new rt(t)}getMatchesIdMapping=async(t,e)=>{try{if(t){if(t=new Ct(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 Ct({matchIds:t,limit:e}),r=await this.getMatches(i);return r.data.sort((a,s)=>a.id.localeCompare(s.id)),await this.idMapping.remapEntities(r.data,"match")};getMatchesMapWithNativeIds=async t=>{let e={},i=dt(t);i.sort((a,s)=>a.localeCompare(s));let r=await this.getMatchesWithNativeIds(i);if(i.length!==r.length){let a=new Ct({matchIds:i,limit:i.length}),s=await this.getMatches(a),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((a,s)=>e[a]=r[s]),e};getMatches=async(t,e)=>{try{return e=e||!1,await this.https.getMatches(t,e)}catch(i){throw console.warn("There was a problem retrieving the matches",i),i}};getMatchIdMapping=async(t,e)=>{try{let i=await this.idMapping.getEntityIdsBySchemaId([t],"match","native"),r=await this.getMatchById(i.match[0],e),a=await this.footballService.setAvailableMarketsForMatch(r);return await this.idMapping.remapEntities(a,"match")}catch(i){throw console.warn(`There was a problem browsing the following match: ${t}`,i),i}};getMatchById=async(t,e)=>{try{return e=e||!1,await this.https.getMatchById(t,e)}catch(i){throw console.warn(`There was a problem retrieving the following match: ${t}`,i),i}}};var ri=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 ai=class{https=null;idMapping=null;constructor(t,e){this.https=t,this.idMapping=e}searchIdMapping=async(t,e)=>{try{if(t=new ri(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 At=class{countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(t,e,i,r){this.countriesFacade=new Ke(e,i,r),this.competitionsFacade=new je(e,i,r),this.teamsFacade=new ii(t,i,r),this.playerFacade=new at(t,i,r),this.matchFacade=new ot(t,i,r),this.searchFacade=new ai(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 oi=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 oi;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 si=class{id="";country=null;gender="";assets=null;type="";name=""};var O=class{countryRemapper=null;constructor(){this.countryRemapper=new _}fromResponse(t){try{let e=new si;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 ni=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var li=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 li;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 pi=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new _,this.teamBasicRemapper=new C}fromResponse(t){try{let e=new ni;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 ci=class{primary=null;secondary=null;tertiary=null};var mi=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";isDeleted=!1;colors=new ci;squad=[]};var di=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var ui=class{countryRemapper=null;constructor(){this.countryRemapper=new _}fromResponse(t){try{let e=new di;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 hi=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new _,this.competitionRemapper=new O,this.playerRemapper=new ui}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.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 fi=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 gi=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var Ot=class{fromResponse(t){try{let e=new gi;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 yi=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new C,this.competitionRemapper=new O,this.scoresRemapper=new Ot}fromResponse(t){try{let e=new fi;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 Mi=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 bi=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 wi=class{fromResponse(t){try{let e=new bi;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 Lt=class{homeTeam={players:[]};awayTeam={players:[]}};var Ii=class{id="";name="";position="";shirtNumber;assets=null;type=""};var xt=class{fromResponse(t){try{let e=new Ii;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 Pi=class{playerRemapper=null;constructor(){this.playerRemapper=new xt}fromResponse(t){try{let e=new Lt;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 Fi=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var Ti=class{playerRemapper=null;constructor(){this.playerRemapper=new xt}fromResponse(t){try{let e=new Fi;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 _i=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 Pi,this.scoresMapper=new Ot,this.statsMapper=new wi,this.timelineMapper=new Ti}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=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 Lt,e}catch(e){throw console.warn("There was a problem remapping the match response",e),e}}};var Ri=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var Ei=class{countryRemapper=null;constructor(){this.countryRemapper=new _}fromResponse(t){try{let e=new Ri;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 vi=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;teams=[]};var Dt=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new _,this.teamRemapper=new C}fromResponse(t){try{let e=new vi;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 Si=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;isDeleted=!1;competitions=[];teams=[]};var Ci=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 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.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 Ai=class{teams=null;players=null;competitions=null};var Oi=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new C,this.playerRemapper=new Dt,this.competitionremapper=new O}fromResponse(t){try{let e=new Ai;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 st=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var X=class{pagination=new st};var Nt=class{meta=new X;data=[]};var Li=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 pi,this.teamBasicRemapper=new C,this.teamFullRemapper=new hi,this.matchBasicRemapper=new yi,this.matchFullRemapper=new _i,this.playerBasicRemapper=new Dt,this.playerFullRemapper=new Ci,this.topPlayerRemapper=new Ei,this.searchRemapper=new Oi,this.footballMetaRemapper=new Li}getCountries=async t=>{let e="There was a problem with the football countries request",i=`/countries${this.apiSignInUrl}`,r=Date.now();t&&(i+=`&disable_cache=${r}`);let a=await this.fetchWithoutAuth(i,e);return this.countryRemapper.countriesFromResponse(a.data)};getCompetitions=async(t,e)=>{let i=Date.now(),r="There was a problem with football competitions request";if(e=e||!1,t&&t.competitionIds&&t.competitionIds.length>this.limitIds-1){let a=[],s=pe(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);a.push(c.data.map(m=>this.competitionBasicRemapper.fromResponse(m)))}return Array.prototype.concat.apply([],a)}else{let a=`/competitions${this.apiSignInUrl}`;return t&&(a+=`${t.constructFilterUrl()}`),e&&(a+=`&disable_cache=${i}`),(await this.fetchWithoutAuth(a,r)).data.map(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",a=Date.now();e&&(i+=`&disable_cache=${a}`);let s=await this.fetchWithoutAuth(i,r);return this.competitionFullRemapper.fromResponse(s.data)};getTopCompetitions=async t=>{let e="There was a problem with top football competitions request",i=`/competitions/top${this.apiSignInUrl}`,r=Date.now();return t&&(i+=`&disable_cache=${r}`),(await this.fetchWithoutAuth(i,e)).data.map(s=>this.competitionBasicRemapper.fromResponse(s))};getTeams=async(t,e)=>{let i=Date.now(),r="There was a problem with football teams request";if(t&&t.teamIds&&t.teamIds.length>this.limitIds){let a=[],s=pe(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);a.push(c.data.map(m=>this.teamBasicRemapper.fromResponse(m)))}return Array.prototype.concat.apply([],a)}else{let a=new Nt,s=`/teams${this.apiSignInUrl}`;t&&(s+=`${t.constructFilterUrl()}`),e&&(s+=`&disable_cache=${i}`);let p=await this.fetchWithoutAuth(s,r);return a.meta=this.footballMetaRemapper.remapMetaProp(p.meta),a.data=p.data.map(n=>this.teamBasicRemapper.fromResponse(n)),a}};getTeamById=async(t,e)=>{let i="There was a problem with football team by ID request",r=`/teams/${t}${this.apiSignInUrl}`,a=Date.now();e&&(r+=`disable_cache=${a}`);let s=await this.fetchWithoutAuth(r,i);return this.teamFullRemapper.fromResponse(s.data)};getTopTeams=async t=>{let e=`/teams/top${this.apiSignInUrl}`,i="There was a problem with top football teams request",r=Date.now();t&&(e+=`$disable_cache=${r}`);let a=await this.fetchWithoutAuth(e,i);return a.data?a.data.map(s=>this.teamBasicRemapper.fromResponse(s)):[]};getNextMatchForTeam=async(t,e)=>{let i=`/teams/${t}/next-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with next match for team request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getPrevMatchForTeam=async(t,e)=>{let i=`/teams/${t}/previous-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with previous match for team request";e&&(i+=`disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getPlayers=async(t,e)=>{let i=Date.now(),r="There was a problem with football players request";if(t&&t.playerIds&&t.playerIds.length>this.limitIds-1){let a=[],s=pe(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);a.push(c.data.map(m=>this.teamBasicRemapper.fromResponse(m)))}return Array.prototype.concat.apply([],a)}else{let a=new Nt,s=`/players${this.apiSignInUrl}`;t&&(s+=`${t.constructFilterUrl()}`),e&&(s+=`&disable_cache=${i}`);let p=await this.fetchWithoutAuth(s,r);return a.meta=this.footballMetaRemapper.remapMetaProp(p.meta),a.data=p.data.map(n=>this.playerBasicRemapper.fromResponse(n)),a}};getPlayerById=async(t,e)=>{let i=`/players/${t}${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with football player by ID request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.playerFullRemapper.fromResponse(s.data)};getTopPlayers=async t=>{let e=`/players/top${this.apiSignInUrl}`,i=Date.now(),r="There was a problem with top football players request";return t&&(e+=`&disable_cache=${i}`),(await this.fetchWithoutAuth(e,r)).data.map(s=>this.topPlayerRemapper.fromResponse(s))};getNextMatchForPlayer=async(t,e)=>{let i=`/players/${t}/next-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with next match for player request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getPrevMatchForPlayer=async(t,e)=>{let i=`/players/${t}/previous-match${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with previous match for player request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getMatchById=async(t,e)=>{let i=`/matches/${t}${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with match by ID request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.matchFullRemapper.fromResponse(s.data)};getMatches=async(t,e)=>{let i=new Nt,r=`/matches${this.apiSignInUrl}`,a=Date.now(),s="There was a problem with football matches request";t&&(r+=`${t.constructFilterUrl()}`),e&&(r+=`&disable_cache=${a}`);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(),a="There was a problem with football search request";e&&(i+=`&disable_cache=${r}`);let s=await this.fetchWithoutAuth(i,a);return this.searchRemapper.fromResponse(s.data)}};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||{}),ho=["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"],fo=["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"],go=["FT_1X2","HT_1X2","HT_FT","DOUBLE_CHANCE","CORNERS_MATCH","CORRECT_SCORE","CORRECT_SCORE_HT","CORRECT_SCORE_ADVANCED"],ye="PLAYER_SCORE_FIRST_GOAL";var xi=class{id="";achievedAt=""};var Me=class{participations=0;points=0};var ht=class{footballCompetitions=[];footballTeams=[]};var Bt=class{predictionsMade=0;correct=0;points=0;breakdown=new ht};var kt=class{single=new Bt;topX=new Me;matchQuiz=new Me};var Di=class{overallPercent;byFootballCompetition;byFootballTeam;byFootballMarket};var Ni=class{profileId;tier;points;predictionsMade;successRates=new Di;predictions=new kt;tiers=[];badges=[]};var Bi=class{entityId="";entityType="";entitySource="";model=null;predictionsMade=0;correct=0;points=0};var ki=class{successRatePercent;model=null};var Ht=class{content=null;tags=[];campaign=null};var Ut=class{id=null;profileId=null;property=null;value=null;action=null;context=new Ht;points=0};var Hi=class{meta=new X;data=[new Ut]};var Ui=class{remapSingleResponse=t=>{let e=new Ut;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 Hi;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 Ni;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=this.remapPredictionsStats(t.predictions),e.tiers=this.remapAchievementsStats(t.tiers),e.badges=this.remapAchievementsStats(t.badges),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 ki;return e.successRatePercent=t.success_rate_percent,e};remapPredictionsStats=t=>{let e=new kt;return e.single=this.remapSinglePredictionsStats(t.single),e.topX=t.top_x,e.matchQuiz=t.match_quiz,e};remapSinglePredictionsStats=t=>{let e=new Bt;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 ht,i=[],r=[];return Object.keys(t).forEach(a=>{let s=new Bi;s.entityId=a,s.entityType=t[a].entity_type,s.entitySource=t[a].entity_source,s.predictionsMade=t[a].predictions_made,s.correct=t[a].correct,s.points=t[a].points,s.entityType==="competition"?i.push(s):s.entityType==="team"&&r.push(s)}),e.footballCompetitions=i,e.footballTeams=r,e}return new ht};remapAchievementsStats=t=>t.map(e=>{let i=new xi;return i.id=e.id,i.achievedAt=e.achieved_at,i})};var Gt=class extends S{activityRemapper=null;constructor(t){super(t,L(t.environment,"loyalty")),this.activityRemapper=new Ui}createActivity=async t=>{let e=`/activities${this.apiSignInUrl}`,i="There was a problem with creating activity",r="POST",a=await this.fetchWithAuth(e,i,r,t);return this.activityRemapper.remapSingleResponse(a)};deleteActivity=async t=>{let e=`/activities/${t}${this.apiSignInUrl}`,i=`There was a problem deleting the following activity: ${t}`,r="DELETE";return await this.fetchWithAuth(e,i,r),!0};getOwnActivities=async(t,e)=>{let i=`/activities${this.apiSignInUrl}`,r=Date.now(),a="There was a problem with fetching own activities";t&&(i+=`${t.constructFilterUrl()}`),e&&(i+=`disable_cache=${r}`);let s=await this.fetchWithAuth(i,a);return this.activityRemapper.remapActivitiesResponse(s)};getActivitiesForUser=async(t,e,i)=>{let r=`/users/${t}/activities${this.apiSignInUrl}`,a=Date.now(),s=`There was a problem with fetching activities for user: ${t}`;e&&(r+=`${e.constructFilterUrl()}`),i&&(r+=`disable_cache=${a}`);let p=await this.fetchWithoutAuth(r,s);return this.activityRemapper.remapActivitiesResponse(p)};getStats=async(t,e)=>{let i="",r="",a=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}`,a=await this.fetchWithoutAuth(i,r)):(i+=`/statistics${this.apiSignInUrl}`,r="There was a problem fetching profile`s statistics",a=await this.fetchWithAuth(i,r)),this.activityRemapper.remapStatsResponse(a.data)}};var Gi=class{id="";source="";type="";favourite=!1};var Vi=class extends Gi{model=null};var $i=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 a=JSON.parse(JSON.stringify(t.successRates.byFootballCompetition)),s=await this.getEntitiesMap(r.competition,"competition"),p=await this.setSuccessRatesModels(a,s);t.successRates.byFootballCompetition=p,i.single.breakdown.footballCompetitions=this.reconstructBreakdown(i.single.breakdown.footballCompetitions,s)}if(Object.values(r.team).length){let a=JSON.parse(JSON.stringify(t.successRates.byFootballTeam)),s=await this.getEntitiesMap(r.team,"team"),p=await this.setSuccessRatesModels(a,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 a=i.get(r);e={...e,[a.id]:t[r]},e[a.id].model=a}),e):t;reconstructBreakdown=(t,e)=>t.length?t.map(i=>{let r=e.get(i.entityId);return i.entityId=r.id,i.model=r,i}):t;getIdsKeys=(t,e)=>{let i=Object.keys(t);if(e.length){let r=e.map(a=>a.entityId);return Array.from(new Set([...i,...r]))}return i};remapInterestsToIdSchema=async t=>{if(this.idSchema!==this.native)if(t&&t.length>0){let e={},i={},r=t.filter(n=>n.source.toLocaleUpperCase()==="FOOTBALL"),a=t.filter(n=>n.source.toLocaleUpperCase()!=="FOOTBALL");r.forEach(n=>{e.hasOwnProperty(n.type)||(e[n.type]=[],i[n.type]=[]),e[n.type].push(n.id),i[n.type].push(n)});let s=await this.remapIdsObj(e,this.native,this.idSchema),p=[];for(let[n,l]of Object.entries(i))l.forEach((c,m)=>{c.id=s[n][m],p.push(c)});return p.concat(a)}else return t;return t};remapInterestToNative=async t=>{if(this.idSchema!==this.native&&t.source.toLocaleUpperCase()==="FOOTBALL"){let e={},{id:i,type:r}=t;e[r]=[i];let a=await this.remapIdsObj(e,this.idSchema,this.native);return t.id=a[r][0],t}return t};inquiryCustomInterests=(t,e)=>{let i=[];return t&&t.length>0&&(i=t.filter(r=>r.source.toLocaleUpperCase()==="CUSTOM"),e)?i.map(r=>{let a=new Vi;return a.id=r.id,a.type=r.type,a.source=r.source,a.favourite=r.favourite,a}):i};remapInterests=async t=>{let i=this.inquiryCustomInterests(t,!1);if(i&&i.length>0){let r=t.filter(s=>s.source.toLocaleUpperCase()!=="CUSTOM"),a=await this.remapInterestsToIdSchema(r);return i.forEach(s=>a.push(s)),a}return await this.remapInterestsToIdSchema(t)};showFullInterests=async t=>{let e=[];if(t&&t.length>0){let r=this.inquiryCustomInterests(t,!0);e.push(r);let a=t.filter(c=>c.source.toLocaleUpperCase()!=="CUSTOM"),{competitionsMap:s,teamsMap:p,playersMap:n}=await this.getInterestsEntitiesMap(a),l=a.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=[],a=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&&(a=await this.footballFacade.getCompetitionsMapWithNativeIds(e)),i.length&&(s=await this.footballFacade.getTeamsMapWithNativeIds(i)),r.length&&(p=await this.footballFacade.getPlayersMapWithNativeIds(r)),{competitionsMap:a,teamsMap:s,playersMap:p}};remapIdsObj=async(t,e,i)=>await this.idMapping.idMappingFacade.getEntitiesByIds(t,e,i)};var Wi=class{idMapping=null;profileOperations=null;constructor(t,e){this.idMapping=new T(t),this.profileOperations=new $i(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 nt=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 Ft(t),this.activityHttps=new Gt(t),this.footballHttps=new Y(t),this.idMapping=new T(t),this.localCache=new k().createLocalCacheInstance(t.idSchema),this.footballFacade=new At(t,this.localCache,this.footballHttps,this.idMapping),this.profileFacade=new j(this.localCache,this.profileHttps,this.activityHttps),this.idsRemapper=new Wi(t,this.footballFacade),this.ownProfileBuilder=new $e(this.idsRemapper,this.localCache,this.profileHttps,this.activityHttps,t.errorHandlingMode),this.profileBuilder=new We(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 ga=(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))(ga||{});var Ki=class{validate=t=>{let e=this.validateField(t.lang),i=this.generateMessage(e);return{validation:e,message:i}};validateField=t=>{let e=Object.values(ga),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 ji=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 Xi=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 Yi=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 gt=class{getIdToken=null;logout=null};var $t=class{text=null;type=null};var qi=class{validation=null;message=new $t;getIdToken={validation:null,message:new $t};logout={validation:null,message:new $t}};var Qi=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 gt),i=new qi;if(t){let a=Object.keys(t).filter(s=>!e.includes(s));a.length>0?(i.validation="invalid",i.message.type="warning",i.message.text=`${"You have passed a property which is not supported for the authentication provider:"} ${a.join(",")}`):i.validation="valid"}else i.validation="missing",i.message.type="error",i.message.text="The field authProvider must be provided to use this SDK";return i};validateAuthProviderConfigFields=(t,e)=>(Object.keys(new gt).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 we=class{validation;message};var zi=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;errorHandlingMode=null;authProvider={getIdToken:new we,logout:new we};isValid=!1};var Ji=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 Zi=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 tr=class{validate=t=>{let e=this.checkFieldsForValues(t);return e.isValid=this.containsErrorMessage(e),e};checkFieldsForValues=t=>{let e=new zi,i={apiKey:new Xi,environment:new ji,idSchema:new Yi,clientId:new Ji,lang:new Ki,errorHandlingMode:new Zi,authProvider:new Qi};for(let[r,a]of Object.entries(e))r!=="isValid"&&(a=i[r].validate(t));return Object.keys(i).forEach(r=>{e[r]=i[r].validate(t)}),e};containsErrorMessage=t=>{let e=!0;for(let[i,r]of Object.entries(t))if(i!=="authProvider"){if(i!=="isValid"&&r.message.type==="error")return e=!1,e;if(i!=="isValid"&&r.message.type==="warning")return e=!0,e}else if(r.message.type==="error")return e=!1,e;return e}};var Wt=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 At(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 er=class{value=null;playerId=null;playerModel=null};var Kt=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new er;result=null};var ir=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 ir,this.prediction.value=i,this.prediction.playerId=r}};var jt=class{settledAt=null;resettledAt=null;status=null;outcome=null;points=0};var rr=class{value=null};var lt=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new rr,this.prediction.value=i}};var $=class{value=!1};var Xt=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 Yt=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 ar=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 Xt||t instanceof Yt)e.market=t.market,e.prediction=t.prediction.value;else if(t instanceof lt){e.market=t.market;let i=t.prediction.value.split(":");e.goals_home=Number(i[0]),e.goals_away=Number(i[1])}else e.market=t.market,e.prediction=t.prediction.value;return e};remapFixturesResponse=async t=>{let e="OWN_GOAL",i=[],r=[],a=null,s=[];t.length>1&&t.sort((n,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)&&(a=await this.playerFacade.getPlayersMapWithNativeIds(r));for(let n of t){let l=new Kt;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=a[n.player_id],l.prediction.playerId=a[n.player_id].id),l.result=this.remapResult(n.result),s.push(l)}return s};remapResult=t=>{let e=new jt;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 Ie=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 or=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 pt=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 yt=class{userId=null;points=null;results=[];tiebreaker=null};var ya=(a=>(a.ACTIVE="ACTIVE",a.WON="WON",a.LOST="LOST",a.PARTIALLY_WON="PARTIALLY_WON",a.CANCELED="CANCELED",a))(ya||{}),Ca=["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(ya).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 qt=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 sr=(s=>(s.OPEN="OPEN",s.LIVE="LIVE",s.PENDING="PENDING",s.CANCELED="CANCELED",s.CLOSED="CLOSED",s.SETTLED="SETTLED",s))(sr||{});var W=class extends qt{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(sr).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 Qt=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 Qt;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 ot(t,this.footballHttps,e),this.playerFacade=new at(t,this.footballHttps,e),this.profileNamespace=new nt(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=dt(t),a=(await this.idMapping.getEntityIdsBySchemaId(i,"player","native")).player;return i.forEach((s,p)=>e[s]=a[p]),e};remapPlayerIdToIdSchema=async t=>{let e=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"],i=[];for(let[a,s]of Object.entries(t))if(e.includes(a))for(let 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[a,s]of Object.entries(t))if(e.includes(a))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=Ga.get(e),a={};if(a.matchId=t.matchId,a.matchType=t.matchType,Object.keys(t.predictions).includes(r))a[r]=t.predictions[r];else throw new Error("You have passed invalid market");if(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&&a[r][p]){let n=await this.playerFacade.getPlayersMapWithNativeIds([p]);return a[r][p].model=n[p],a[r][p]}else return p?(a[r][p]=new I,a[r][p]):a[r][i]}else if(q.includes(e)&&!i){let p=Object.keys(a[r]).filter(l=>l!=="NOBODY"&&l!=="OWN_GOAL"),n=p.length?await this.playerFacade.getPlayersMapWithNativeIds(p):{};Object.keys(n).length&&Object.keys(a[r]).forEach(l=>{l!=="NOBODY"&&l!=="OWN_GOAL"&&(a[r][n[l].id]=a[r][l],a[r][n[l].id].model=n[l],this.idMapping.idSchema!=="native"&&delete a[r][l])})}return a};remapCompetitionsFromConfig=async t=>{if(t instanceof St){let e={competition:t.fullCoverageCompetitions},i={competition:t.successRateScopes.competitions},r={team:t.successRateScopes.teams},a=await this.idMapping.idMappingFacade.getEntitiesByIds(e,"native",this.idMapping.idSchema),s=await this.idMapping.idMappingFacade.getEntitiesByIds(i,"native",this.idMapping.idSchema),p=await this.idMapping.idMappingFacade.getEntitiesByIds(r,"native",this.idMapping.idSchema);return t.fullCoverageCompetitions=a.competition,t.successRateScopes.competitions=s.competition,t.successRateScopes.teams=p.team,t}if(t instanceof vt||t instanceof Et){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 pt||r instanceof et||r instanceof zt?(r.fixtures.forEach(a=>e.push(a.matchId)),r instanceof et&&r.fixtures.forEach(a=>{a.prediction.playerId&&a.prediction.playerId!=="OWN_GOAL"&&i.push(a.prediction.playerId)})):r instanceof yt&&r.results.forEach(a=>e.push(a.matchId))}),await this.refactorResponseArrModel(t,e,i)}else return t;else return await this.refactorResponseObjModel(t)};refactorResponseArrModel=async(t,e,i)=>{let r=[],a=await this.matchFacade.getMatchesMapWithNativeIds(e),s={};return i.length>0&&(s=await this.playerFacade.getPlayersMapWithNativeIds(i)),t.data.forEach(p=>{p instanceof tt||p instanceof pt||p instanceof et?(p.fixtures.forEach(n=>{this.handleMatchModel(a,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 yt&&(p.results.forEach(n=>{n.matchModel=a[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(a=>i.push(a.predictionsCutoff)),t.data.sort((a,s)=>{let[p,n]=[a.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((a,s)=>{r.fixtures[s].goals_home!==void 0&&r.fixtures[s].goals_away!==void 0?a.prediction.value=r.fixtures[s].goals_home+":"+r.fixtures[s].goals_away:a.prediction.value=r.fixtures[s].prediction,r.fixtures[s].player_id?a.prediction.playerId=r.fixtures[s].player_id:r.fixtures[s].target&&(a.prediction.target=r.fixtures[s].target),a.prediction.result=this.remapResult(r.fixtures[s].result)}),i.predictionsMadeAt=r.created_at,i.points=r.points,i instanceof pt&&(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 jt;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=Ca,t=new A(t);else{let r={status:Ca};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,a=t.results.map(l=>q.includes(l.market)&&!l.result.includes("OWN_GOAL")?[...l.result]:[]).flat(),s=await this.matchFacade.getMatchesMapWithNativeIds([r]);return a.length&&(i=await this.playerFacade.getPlayersMapWithNativeIds(a)),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 a=i.filter(s=>s.id===r.profileId)[0];delete a.interests,r.profileModel=a})}return t};handleMatchModel=(t,e)=>{t[e.matchId]?(e.matchModel=t[e.matchId],delete e.matchModel.availableMarkets,e.matchId=e.matchModel.id):(e.matchModel=null,this.idMapping.idSchema!=="native"&&this.idMapping.idMappingFacade.getEntityById(e.matchId,"match","native").then(i=>{e.matchId=i[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(Ra.UNEXPECTED_STATUS_PROP),delete t.status),t.type&&(console.warn(Ra.UNEXPECTED_TYPE_PROP),delete t.type),t)};var Jt=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(t){this.gameInstanceId=t.gameInstanceId,t.fixtures.forEach(e=>this.fixtures.push(new lt(e.matchId,e.market,e.prediction.value))),this.tiebreaker=t.tiebreaker?t.tiebreaker:null}};var Zt=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(t,e){this.footballHttps=new Y(t),this.matchFacade=new ot(t,this.footballHttps,e),this.playerFacade=new at(t,this.footballHttps,e),this.predictorService=new J(t,e),this.fixturesRemapper=new ar(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 Jt&&t.tiebreaker&&(e.tiebreaker={},e.tiebreaker.golden_goal=t.tiebreaker.goldenGoal?t.tiebreaker.goldenGoal:null),e};remapResponseArrayBody=async t=>{if(t.length){let e="OWN_GOAL",i=[],r=[],a={},s=[];t.forEach(n=>{n.fixtures.forEach(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&&(a=await this.playerFacade.getPlayersMapWithNativeIds(r)),t.forEach(n=>{let l=new Ie,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 Kt;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=a[d.prediction.playerId],d.prediction.playerId=a[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 Ie;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 or;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 nr=class{matchId=null;matchType=null;predictions=null};var lr=class{remapPredictions=null;constructor(t,e){this.remapPredictions=new Zt(t,e)}remapResponse=t=>{let e=new nr;return e.matchId=t.match_id,e.matchType=t.match_type,e.predictions=this.remapPredictions.remapPredictionModel(t.predictions),e}};var pr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new U};var cr=class{value=null;target=null;playerId=null;playerModel=null;result=null};var mr=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new U;prediction=new cr};var dr=class{value=null;result=null};var ur=class{matchId=null;matchType=null;market=null;matchModel=null;matchStatus=new U;prediction=new dr};var hr=class{matchId=null;matchModel=null;outcome=null};var fr=class{gameId=null;results=null;tieBreakers=null};var te=class{entityId=null;entityType=null};var gr=class{contestId="";contestType="GAME";contestModel=null;description="";userList=[]};var yr=class{position="";profileId="";profileModel=null;note="";tags=[]};var Mr=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 pr;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 pt;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 ur;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 mr;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 yt;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 fr;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 gr;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 yr;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(go.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 hr;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 te;return i.entityId=e.entity_id,i.entityType=e.entity_type,i})};var br=class{remapMetaData=t=>{let e=new wt;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 Zt(t,e),this.matchSummaryRemapper=new lr(t,e),this.gamesRemapper=new Mr,this.metaRemapper=new br}makeFootballPrediction=async t=>{let e=`/predictions${this.apiSignInUrl}`,i="There was a problem making POST request",r="POST",a=await this.fetchWithAuth(e,i,r,this.predictionRemapper.remapRequestBody(t));return await this.predictionRemapper.remapResponseObjBody(a)};getMatchSummary=async(t,e)=>{let i=R(e)?`/predictions/summary/${t}${this.apiSignInUrl}${E()}`:`/predictions/summary/${t}${this.apiSignInUrl}`,r=`There was a problem fetching predictions for match: ${t}`,a=await this.fetchWithoutAuth(i,r);return this.matchSummaryRemapper.remapResponse(a)};deleteFootballPrediction=async t=>{let e=`/predictions/${t}${this.apiSignInUrl}`,i=`There was a problem deleting your prediction: ${t}`,r="DELETE";return await this.fetchWithAuth(e,i,r),!0};getMyPredictions=async t=>{let e=new F,i=`/predictions${this.apiSignInUrl}`,r="There was a problem fetching own predictions";t&&(i+=`${t.constructFiltersUrl()}`);let a=await this.fetchWithAuth(i,r);return e.meta=this.metaRemapper.remapMetaData(a.meta),e.data=await this.predictionRemapper.remapResponseArrayBody(a.data),e};getMyPredictionsNoRemap=async t=>{let e=`/predictions${this.apiSignInUrl}${t.constructFiltersUrl()}`,i="There was a problem fetching own predictions";return await this.fetchWithAuth(e,i)};getUserPredictions=async(t,e,i)=>{let r=new F,a=R(e)?`/predictions/users/${t}${this.apiSignInUrl}${E()}`:`/predictions/users/${t}${this.apiSignInUrl}`,s=`There was a problem fetching predictions for user: ${t}`;i&&(a+=`${i.constructFiltersUrl()}`);let p=await this.fetchWithoutAuth(a,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",a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapPaginatedGames(a)};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}`,a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapGameByIdResponse(a)};getGamePredictions=async(t,e,i)=>{let r=new F,a=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&&(a+=`${i.constructFiltersUrl()}`);let p=await this.fetchWithoutAuth(a,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()}`,a="There was a problem fetching the games list",s=await this.fetchWithoutAuth(r,a);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}`,a=`There was a problem fetching the results for the following game: ${t}`;i&&(r+=`${i.constructMainFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a);return this.gamesRemapper.remapPaginatedGameResults(s)};getMarketResultsForGame=async(t,e)=>{let i=`/games/${t}/correct-results/${this.apiSignInUrl}`,r=`There was a problem fetching the markets correct results for the following game: ${t}`;R(e)&&(i+=`${E()}`);let a=await this.fetchWithoutAuth(i,r);return this.gamesRemapper.remapGameMarketsResults(a.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 ee=class{gameInstanceId=null;fixtures=null};var Aa=(i=>(i.ONE="1",i.X="x",i.TWO="2",i))(Aa||{}),Oa=(i=>(i.ONE_X="1x",i.X_TWO="x2",i.ONE_TWO="12",i))(Oa||{}),La=(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))(La||{});var wr=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 Ir=class{value};var Pr=class{matchId=null;market="CORNERS_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new Ir,this.prediction.value=e}};var Fr=class{value=null};var Tr=class{matchId=null;market="DOUBLE_CHANCE";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new Fr,this.prediction.value=e}};var _r=class{value=null};var Rr=class{matchId=null;market=null;matchType="FOOTBALL";prediction=null;constructor(t,e,i){this.matchId=t,this.market=e,this.prediction=new _r,this.prediction.value=i}};var Er=class{value=null};var vr=class{matchId=null;market="HT_FT";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new Er,this.prediction.value=e}};var Sr=class{matchId=null;market="PENALTY_MATCH";matchType="FOOTBALL";prediction=null;constructor(t,e){this.matchId=t,this.prediction=new $,this.prediction.value=e}};var Cr=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 ct=class{errorHandlingMode=null;constructor(t){this.errorHandlingMode=t}validateBodyFields=(t,e)=>{let i=Object.keys(e),r=Object.keys(new ee);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 a=r.filter(s=>!i.includes(s));return a.length&&this.throwMissingFieldsException("game prediction body",a),e.fixtures.forEach(s=>{this.validateFixtureFields(s)}),e};validateFixture=(t,e,i,r)=>{this.validateMarket(e);let a=Object.values(Aa),s=Object.values(La),p=Object.values(Oa);if(e==="FT_1X2"||e==="HT_1X2"){if(a.includes(i))return new Rr(t,e,i)}else if(e==="HT_FT"){if(s.includes(i))return new vr(t,i)}else if(e==="DOUBLE_CHANCE"){if(p.includes(i))return new Tr(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 lt(t,e,i)}else if(e==="CORNERS_MATCH"){if(typeof i=="number")return new Pr(t,i)}else if(e==="BOTH_TEAMS_SCORE"){if(this.isPredictionBoolean(i))return new wr(t,i)}else if(e==="RED_CARD_MATCH"){if(this.isPredictionBoolean(i))return new Cr(t,i)}else if(e==="PENALTY_MATCH"){if(this.isPredictionBoolean(i))return new Sr(t,i)}else if(q.includes(e)){let n="OWN_GOAL";if(this.validatePlayerId(e,r),e===ye&&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(ho.includes(e)){if(this.isPredictionBoolean(i))return new Yt(t,e,i)}else if(fo.includes(e)&&this.isPredictionBoolean(i))return new Xt(t,e,i);this.throwInvalidPredictionException(i,e)};validateFixtureFields=t=>{let e=Object.keys(t);e.forEach(r=>{_a.includes(r)||this.throwInvalidParamException([r])});let i=_a.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 a=i.filter(s=>!r.includes(s));a.length&&this.throwInvalidParamException(a)}}else this.throwInvalidType("prediction","object")};validatePlayerId=(t,e)=>{let i="playerId";t!==ye&&(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=Va(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=$a(t):i=ca(t),this.errorHandlingMode==="default"?new b(400,"INVALID_MARKET",i):new y(400,"INVALID_TYPE",i)};throwInvalidParamException=t=>{let e=Wa(t);throw this.errorHandlingMode==="default"?new b(400,"INVALID_FIELD",e):new y(400,"INVALID_TYPE",e)};throwMissingFieldsException=(t,e)=>{let i=Ka(t,e);throw this.errorHandlingMode==="default"?new b(400,"INVALID_FIELD",i):new y(400,"INVALID_TYPE",i)};throwInvalidType=(t,e)=>{let i=ja(t,e);throw this.errorHandlingMode==="default"?new b(400,"INVALID_TYPE",i):new y(400,"INVALID_TYPE",i)}};var Ar=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 ct(t.errorHandlingMode),this.predictorService=new J(t,r)}makeFootballPrediction=async(t,e,i,r)=>{let a=this.predictorValidator.validateFixture(t,e,i,r),s=new ee;if(this.idMapping.idSchema!=="native"){let p=a.matchId,n="",l=await this.predictorService.remapMatchIdToNative([p]);if(a.matchId=l[0],this.errorHandlingMode==="default"&&!a.matchId)throw new b(400,"INVALID_FIELD","Match id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&!a.matchId)throw new y(400,"INVALID_FIELD","Match id is invalid!");if(a instanceof V&&a.prediction.playerId!=="OWN_GOAL"){if(a.prediction.playerId&&(n=a.prediction.playerId,a.prediction.playerId=await this.predictorService.remapPlayerIdToNative([n])),this.errorHandlingMode==="default"&&a.market!==ye&&!a.prediction.playerId)throw new b(400,"INVALID_FIELD","Player id is invalid!").errorMessage();if(this.errorHandlingMode==="standard"&&a.market!==ye&&!a.prediction.playerId)throw new y(400,"INVALID_FIELD","Player id is invalid!")}s.fixtures=[a];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=[a],await this.predictorHttps.makeFootballPrediction(s)};getMatchSummary=async(t,e)=>{let i=await this.getMatchSummaryBase(t,e),r=JSON.parse(JSON.stringify(i.predictions)),a=await this.predictorService.remapPlayerIdToIdSchema(r);return i.predictions=a,i};getMarketSummary=async(t,e,i,r)=>{try{let a=await this.getMatchSummaryBase(t,r);return await this.predictorService.getMarketSummary(a,e,i)}catch(a){throw a}};getMatchSummaryBase=async(t,e)=>{if(this.idMapping.idSchema!=="native"){let r=(await this.predictorService.remapMatchIdToNative([t]))[0],a=await this.predictorHttps.getMatchSummary(r,e);return a.matchId=t,a}else return await this.predictorHttps.getMatchSummary(t,e)};getConfig=async()=>{let t=await this.clientHttps.getConfig("predictor");return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(t):t};deleteFootballPrediction=async t=>await this.predictorHttps.deleteFootballPrediction(t);getMyPredictions=async t=>{let e=this.predictorService.initPredictionsFilters(t,"user");return await this.predictorHttps.getMyPredictions(e)};getMyPredictionsForMatches=async(t,e)=>{if(this.errorHandlingMode==="default"&&this.predictorService.areIdsExceeded(t))throw new 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 a=this.predictorService.initPredictionsFilters(i,"matches",e);return await this.predictorHttps.getUserPredictions(t,r,a)};getPredictionById=async t=>await this.predictorHttps.getPredictionById(t)};var Or=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 Ar(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 Lr=class{rankType=null;fromDate=null;toDate=null;pagination=new st};var ie=class{position=null;profileId=null;profileModel=null;points=null;predictionsMade=null};var xr=class{remapResponse=t=>(t.meta=this.remapMeta(t.meta),t.data=this.remapData(t.data),t);remapMeta=t=>{let e=new Lr;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 ie;r.position=i.position,r.profileId=i.profile_id,r.points=i.points,r.predictionsMade=i.predictions_made,e.push(r)}),e}};var Dr=class extends ie{id=null;rankType=null;model=null;gameType=null};var Nr=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 Dr;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 Br=class{flags="";status="";type="";activeFrom="";activeTo="";createdFrom="";createdTo="";updatedFrom="";updatedTo=""};var kr=class{pagination=new st;filters=new Br};var re=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 Qt;status=null;automaticallyChangeStatus=!0;createdAt=null;updatedAt=null;related=null};var Hr=class extends re{labels=null;customFields=null;adContent=null};var Ur=class{remapResponse=t=>{let e=[];return t.forEach(i=>{let r=new re;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 Hr;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 kr;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 te;return i.entityId=e.entity_id,i.entityType=e.entity_type,i})};var Gr=class{position=null;points=null;predictionsMade=null;profileId=null;profileModel=null;successRatePercent=null};var Vr=class{remapHighestSuccessRate=t=>t.map(e=>{let i=new Gr;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 $r=class extends S{templateRemapper=null;leaderboardRemapper=null;rankingsRemapper=null;highestSuccessRateRemapper=null;constructor(t){super(t,L(t.environment,"loyalty")),this.templateRemapper=new Ur,this.leaderboardRemapper=new xr,this.rankingsRemapper=new Nr,this.highestSuccessRateRemapper=new Vr}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",a=await this.fetchWithoutAuth(i,r),s=JSON.parse(JSON.stringify(a));return s.meta=this.templateRemapper.remapMeta(a.meta),s.data=this.templateRemapper.remapResponse(a.data),s};getTemplateById=async(t,e)=>{let i=R(e)?`/leaderboard/templates/${t}${this.apiSignInUrl}${E()}`:`/leaderboard/templates/${t}${this.apiSignInUrl}`,r=`There was a problem requesting the following template: ${t}`,a=await this.fetchWithoutAuth(i,r);return this.templateRemapper.remapResponseId(a.data)};getLeaderboard=async(t,e,i)=>{let r=R(e)?`/leaderboard/${t}/${this.apiSignInUrl}${E()}`:`/leaderboard/${t}/${this.apiSignInUrl}`,a=`There was a problem fetching the leaderboard for the following template: ${t}`;i&&(r+=`${i.constructFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a),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}`,a=`There was a problem fetching the leaderboard for the following game: ${t}`;i&&(r+=`${i.constructFiltersUrl()}`);let s=await this.fetchWithoutAuth(r,a),p=JSON.parse(JSON.stringify(s));return this.leaderboardRemapper.remapResponse(p)};getUserRankings=async(t,e,i)=>{let r=`/leaderboard/users/${t}/rankings/${this.apiSignInUrl}`,a=`There was a problem fetching the rankings for the following user: ${t}`;e&&(r+=`${e.constructFiltersUrl()}`),R(i)&&(r+=`${E()}`);let s=await this.fetchWithoutAuth(r,a);return this.rankingsRemapper.remapRankings(s)};getHighestSuccessRate=async(t,e)=>{let i=`/statistics/top${this.apiSignInUrl}`,r="There was a problem fetching highest success rate";t&&(i+=`${t.constructFiltersUrl()}`),R(e)&&(i+=`${E()}`);let a=await this.fetchWithoutAuth(i,r);return this.highestSuccessRateRemapper.remapHighestSuccessRate(a.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 Wr=class{general;predictor;topX;matchQuiz};var ae=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 Kr=class extends ae{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 jr=class{idMappingService=null;profileNamespace=null;footballNamespace=null;errorHandlingMode=null;constructor(t){this.idMappingService=new T(t),this.profileNamespace=new nt(t),this.footballNamespace=new Wt(t),this.errorHandlingMode=t.errorHandlingMode}remapTemplatesIds=async t=>{if(t.length>0){let e=[],i=[],r=[],a=[],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],a=[...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(a=>a.profileId);if(!i.length)return t;let r=await this.profileNamespace.getByIds(i);return t.forEach(a=>{r.forEach(s=>{s.id===a.profileId&&(delete s.interests,a.profileModel=s)}),a.profileModel||(a.profileModel=null),e.push(a)}),e}return t};buildClientBadges=t=>{let e=new Wr;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 ae(t));break;case"rankings":t&&(t=new Kr(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(a=>{a.id===r.profileId&&(delete a.interests,r.profileModel=a)}),r))};extractRankingsIdsMap=t=>{let e=[],i=[],r=[];return t.forEach(a=>{a.rankType==="GAME"&&a.gameType==="TOP_X"?e.push(a.id):a.rankType==="GAME"&&a.gameType==="MATCH_QUIZ"?i.push(a.id):a.rankType==="TEMPLATE"&&r.push(a.id)}),[e,i,r]};setModelsForUserRankings=(t,e,i,r)=>(r.data.forEach(a=>{a.gameType==="MATCH_QUIZ"&&e?a.model=e.filter(s=>s.id===a.id)[0]:a.gameType==="TOP_X"&&t?a.model=t.filter(s=>s.id===a.id)[0]:a.rankType==="TEMPLATE"&&i&&(a.model=i.filter(s=>s.id===a.id)[0])}),r);completeContestWinners=async t=>{if(t.userList&&t.userList.length){let e=t.userList.map(r=>r.profileId),i=await this.profileNamespace.getByIds(e);t.userList.forEach(r=>{let a=i.filter(s=>s.id===r.profileId)[0];delete a.interests,r.profileModel=a})}return t};validateEntitiesFollowsFilters=t=>{if(!t||(!t.footballCompetitions||!t.footballCompetitions.length)&&(!t.footballTeams||!t.footballTeams.length)&&(!t.footballPlayers||!t.footballPlayers.length))throw this.errorHandlingMode==="default"?new 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 a=await this.idMappingService.idMappingFacade.getEntitiesByIds(r,this.idMappingService.idSchema,"native");return Object.keys(a).forEach(s=>{s==="competition"?i.footballCompetitions=a[s]:s==="team"?i.footballTeams=a[s]:s==="player"&&(i.footballPlayers=a[s])}),i};addModelsToEntitiesFollows=async t=>{let e=[],i="fb:c:",r=new Map,a=[],s="fb:t:",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)?a.push(m.id):m.id.includes(l)&&n.push(m.id)}),e.length&&(r=await this.footballNamespace.footballFacade.competitionsFacade.getCompetitionsMapWithNativeIds(e)),a.length&&(p=await this.footballNamespace.footballFacade.teamsFacade.getTeamsMapWithNativeIds(a)),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 Xr=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=ca(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,a=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>a)throw i==="default"?new b(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${a}`):new y(400,"invalid_filters","You have provided invalid value. The valid value is "+`between ${r} and ${a}`)}};var oe=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 ct(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 Jt(t);if(e=this.predictorValidator.validateBodyFields("TOP_X",e),e.fixtures=e.fixtures.map(r=>this.predictorValidator.validateFixture(r.matchId,r.market,r.prediction.value)),this.idMapping.idSchema!=="native"){let r=[];e.fixtures.forEach(s=>r.push(s.matchId));let a=await this.predictorService.remapMatchIdToNative(r);e.fixtures.forEach(s=>s.matchId=a.shift())}let i=await this.predictorHttps.makeFootballPrediction(e);return i.fixtures.forEach(r=>{r.matchId=r.matchModel.id}),i};delete=async t=>await this.predictorHttps.deleteFootballPrediction(t);getMyGameEditions=async(t,e)=>{t&&t.limit&&this.validateLimitFilterOnGames(t.limit),e=e||!1;let i=this.predictorService.initGameTypePredictions("TOP_X",t),r=[],a=await this.predictorHttps.getMyPredictionsNoRemap(i);if(a.data.length>0){a.data.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let s=this.predictorService.initGameFilters("TOP_X",null,r),p=await this.predictorHttps.getUserGameEditions(s,e);return await this.predictorService.addPredictionProp(a,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(a=>a.gameInstanceId===t);return r.length?r[0]:null}return null};getUserGameEditions=async(t,e,i)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),i=i||!1;let r=this.predictorService.initGameTypePredictions("TOP_X",e),a=[],s=await this.predictorHttps.getUserPredictionsNoRemap(t,r);if(s.data.length>0){s.data.forEach(l=>{l.game_instance_id&&a.push(l.game_instance_id)});let p=this.predictorService.initGameFilters("TOP_X",null,a),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"),a=await this.predictorHttps.getUserPredictions(t,i,r);if(a.data.length>0){let s=a.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 se=class{predictorHttps=null;predictorService=null;idMapping=null;clientHttps=null;predictorValidator=null;errorHandlingMode=null;constructor(t){this.predictorValidator=new ct(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 a=await this.predictorService.remapMatchIdToNative(i),s={};r&&r.length>0&&(s=await this.predictorService.remapPlayerIdMapToNative(r)),e.forEach((p,n)=>{p.matchId=a[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 qt(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=[],a=await this.predictorHttps.getMyPredictionsNoRemap(i);if(a.data.length>0){a.data.forEach(n=>{n.game_instance_id&&r.push(n.game_instance_id)});let s=this.predictorService.initGameFilters("MATCH_QUIZ",null,r),p=await this.predictorHttps.getUserGameEditions(s,e);return await this.predictorService.addPredictionProp(a,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(a=>a.gameInstanceId===t);return r.length?r[0]:null}return null};getUserGameEditions=async(t,e,i)=>{e&&e.limit&&this.validateLimitFilterOnGames(e.limit),i=i||!1;let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ",e),a=[],s=await this.predictorHttps.getUserPredictionsNoRemap(t,r);if(s.data.length>0){s.data.forEach(l=>{l.game_instance_id&&a.push(l.game_instance_id)});let p=this.predictorService.initGameFilters("MATCH_QUIZ",null,a),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"),a=await this.predictorHttps.getUserPredictions(t,i,r);if(a.data.length>0){let s=a.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 Yr=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 qr=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 Qr=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,a){this.config=t,this.clientHttps=e,this.loyaltyHttps=i,this.profileFacade=new j(a,r),this.loyaltyService=new jr(this.config),this.loyaltyValidator=new Xr,this.idMapping=new T(t),this.topXFacade=new oe(t,this.idMapping),this.matchQuizFacade=new se(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 qr(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 Yr(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,[a,s,p]=this.loyaltyService.extractRankingsIdsMap(t.data);if(p.length&&(e=(await this.getTemplates()).data.filter(l=>p.includes(l.id))),a.length){let n={gameIds:a};i=(await this.topXFacade.getGames(n)).data}if(s.length){let n={gameIds:s};r=(await this.matchQuizFacade.getGames(n)).data}return this.loyaltyService.setModelsForUserRankings(i,r,e,t)}};var zr=class{clientHttps=null;profileHttps=null;loyaltyHttps=null;loyaltyFacade=null;localCache=null;constructor(t){this.clientHttps=new H(t),this.profileHttps=new Ft(t),this.loyaltyHttps=new $r(t),this.localCache=new k().createLocalCacheInstance(t.idSchema),this.loyaltyFacade=new Qr(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 Jr=class{topXFacade=null;idMapping=null;constructor(t){this.idMapping=new T(t),this.topXFacade=new oe(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 Zr=class{matchQuizFacade=null;constructor(t){this.matchQuizFacade=new se(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 Pe=class{action=null;context=new Ht;constructor(t,e,i,r){this.action=t,this.context.tags=e,i&&(this.context.content=i),r&&(this.context.campaign=r)}};var ta=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={},a={},s=[];t.forEach(n=>{r.hasOwnProperty(n.type)||(r[n.type]=[],a[n.type]=[]),r[n.type].push(n.id),a[n.type].push(n)});let p=await this.idMapping.idMappingFacade.getEntitiesByIds(r,e,i);for(let[n,l]of Object.entries(a))l.forEach((c,m)=>{c.id=p[n][m],s.push(c)});return s}};var ne=class{page=null;limit=null;constructor(t){this.page=t.page?t.page:null,this.limit=t.limit?t.limit:null}};var ea=class extends ne{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 ia=class extends ne{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 ra=class{idSchema;activityHttps;activityService;constructor(t){this.idSchema=t.idSchema,this.activityHttps=new Gt(t),this.activityService=new ta(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 Pe(t,p,i,r),l=await this.activityHttps.createActivity(n);return l.context.tags=s,l}let a=new Pe(t,e,i,r);return this.activityHttps.createActivity(a)};delete=async t=>await this.activityHttps.deleteActivity(t);like=async(t,e,i)=>{let r="like";return await this.add(r,t,e,i)};dislike=async(t,e,i)=>{let r="dislike";return await this.add(r,t,e,i)};addPageview=async(t,e,i)=>{let r="page_view";return await this.add(r,t,e,i)};addContentConsumed=async(t,e,i)=>{let r="content_consumed";return await this.add(r,t,e,i)};addShare=async(t,e,i)=>{let r="share";return await this.add(r,t,e,i)};addComment=async(t,e,i)=>{let r="comment";return await this.add(r,t,e,i)};addClickAd=async(t,e,i)=>{let r="click_ad";return await this.add(r,t,e,i)};addConversion=async(t,e,i)=>{let r="conversion";return await this.add(r,t,e,i)};getOwn=async(t,e)=>{if(e=e||!1,t&&(t=new ea(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 ia(e)),this.idSchema!="native"){let r=await this.activityHttps.getActivitiesForUser(t,e,i),a=JSON.parse(JSON.stringify(r));for(let s of a.data)await this.activityService.remapTagsIds([...s.context.tags],"native",this.idSchema);return a}return await this.activityHttps.getActivitiesForUser(t,e,i)}};var aa=class{activityFacade;constructor(t){this.activityFacade=new ra(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 Ma=null,xa=null;function Hb(o){if(ko(o)){let t=Ho(o);if(t.isValid)return Ma={profile:new nt(o),football:new Wt(o),predictor:new Or(o),loyalty:new zr(o),topX:new Jr(o),matchQuiz:new Zr(o),activity:new aa(o)},xa={...o},Ma;Uo(t)}return Ma}var ko=o=>!Ma||JSON.stringify(o)!==JSON.stringify(xa)||o.authProvider.getIdToken()!==xa.authProvider.getIdToken(),Ho=o=>{let e=new tr().validate(o);return(e.idSchema.validation==="missing"||e.idSchema.validation==="invalid")&&(console.warn(e.idSchema.message.text),o.idSchema="native"),(e.environment.validation==="missing"||e.environment.validation==="invalid")&&(console.warn(e.environment.message.text),o.environment="prod"),(e.lang.validation==="missing"||e.lang.validation==="invalid")&&(console.warn(e.lang.message.text),o.lang="en"),(e.errorHandlingMode.validation==="missing"||e.errorHandlingMode.validation==="invalid")&&(console.warn(e.errorHandlingMode.message.text),o.errorHandlingMode="default"),e.authProvider.validation==="invalid"&&console.warn(e.authProvider.message.text),e},Uo=o=>{let t="authProvider",e="isValid";Object.keys(o).forEach(i=>{let r=o[i];if(i!==e&&i!==t){if(r.message.type==="error")throw new Error(r.message.text)}else i!==e&&i===t&&Object.keys(new gt).forEach(a=>{if(r[a].message.type==="error")throw new Error(r[a].message.text)})})};export{Hb as FansUnitedSDK};
4
4
  //# sourceMappingURL=index.js.map